Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:02:15

0001 /* ecdsa.h
0002 
0003    Copyright (C) 2013 Niels Möller
0004 
0005    This file is part of GNU Nettle.
0006 
0007    GNU Nettle is free software: you can redistribute it and/or
0008    modify it under the terms of either:
0009 
0010      * the GNU Lesser General Public License as published by the Free
0011        Software Foundation; either version 3 of the License, or (at your
0012        option) any later version.
0013 
0014    or
0015 
0016      * the GNU General Public License as published by the Free
0017        Software Foundation; either version 2 of the License, or (at your
0018        option) any later version.
0019 
0020    or both in parallel, as here.
0021 
0022    GNU Nettle is distributed in the hope that it will be useful,
0023    but WITHOUT ANY WARRANTY; without even the implied warranty of
0024    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0025    General Public License for more details.
0026 
0027    You should have received copies of the GNU General Public License and
0028    the GNU Lesser General Public License along with this program.  If
0029    not, see http://www.gnu.org/licenses/.
0030 */
0031 
0032 /* Development of Nettle's ECC support was funded by the .SE Internet Fund. */
0033 
0034 #ifndef NETTLE_ECDSA_H_INCLUDED
0035 #define NETTLE_ECDSA_H_INCLUDED
0036 
0037 #include "ecc.h"
0038 #include "dsa.h"
0039 
0040 #ifdef __cplusplus
0041 extern "C" {
0042 #endif
0043 
0044 /* Name mangling */
0045 #define ecdsa_sign nettle_ecdsa_sign
0046 #define ecdsa_verify nettle_ecdsa_verify
0047 #define ecdsa_generate_keypair nettle_ecdsa_generate_keypair
0048 #define ecc_ecdsa_sign nettle_ecc_ecdsa_sign
0049 #define ecc_ecdsa_sign_itch nettle_ecc_ecdsa_sign_itch
0050 #define ecc_ecdsa_verify nettle_ecc_ecdsa_verify
0051 #define ecc_ecdsa_verify_itch nettle_ecc_ecdsa_verify_itch
0052 
0053 /* High level ECDSA functions.
0054  *
0055  * A public key is represented as a struct ecc_point, and a private
0056  * key as a struct ecc_scalar. */
0057 void
0058 ecdsa_sign (const struct ecc_scalar *key,
0059         void *random_ctx, nettle_random_func *random,
0060         size_t digest_length,
0061         const uint8_t *digest,
0062         struct dsa_signature *signature);
0063 
0064 int
0065 ecdsa_verify (const struct ecc_point *pub,
0066           size_t length, const uint8_t *digest,
0067           const struct dsa_signature *signature);
0068 
0069 void
0070 ecdsa_generate_keypair (struct ecc_point *pub,
0071             struct ecc_scalar *key,
0072             void *random_ctx, nettle_random_func *random);
0073 
0074 /* Low-level ECDSA functions. */
0075 mp_size_t
0076 ecc_ecdsa_sign_itch (const struct ecc_curve *ecc);
0077 
0078 void
0079 ecc_ecdsa_sign (const struct ecc_curve *ecc,
0080         const mp_limb_t *zp,
0081         /* Random nonce, must be invertible mod ecc group
0082            order. */
0083         const mp_limb_t *kp,
0084         size_t length, const uint8_t *digest,
0085         mp_limb_t *rp, mp_limb_t *sp,
0086         mp_limb_t *scratch);
0087 
0088 mp_size_t
0089 ecc_ecdsa_verify_itch (const struct ecc_curve *ecc);
0090 
0091 int
0092 ecc_ecdsa_verify (const struct ecc_curve *ecc,
0093           const mp_limb_t *pp, /* Public key */
0094           size_t length, const uint8_t *digest,
0095           const mp_limb_t *rp, const mp_limb_t *sp,
0096           mp_limb_t *scratch);
0097 
0098 
0099 #ifdef __cplusplus
0100 }
0101 #endif
0102 
0103 #endif /* NETTLE_ECDSA_H_INCLUDED */