Fix some typos in the documentation.
[gd/nettle] / ecdsa.h
1 /* ecdsa.h
2
3    Copyright (C) 2013 Niels Möller
4
5    This file is part of GNU Nettle.
6
7    GNU Nettle is free software: you can redistribute it and/or
8    modify it under the terms of either:
9
10      * the GNU Lesser General Public License as published by the Free
11        Software Foundation; either version 3 of the License, or (at your
12        option) any later version.
13
14    or
15
16      * the GNU General Public License as published by the Free
17        Software Foundation; either version 2 of the License, or (at your
18        option) any later version.
19
20    or both in parallel, as here.
21
22    GNU Nettle is distributed in the hope that it will be useful,
23    but WITHOUT ANY WARRANTY; without even the implied warranty of
24    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
25    General Public License for more details.
26
27    You should have received copies of the GNU General Public License and
28    the GNU Lesser General Public License along with this program.  If
29    not, see http://www.gnu.org/licenses/.
30 */
31
32 /* Development of Nettle's ECC support was funded by the .SE Internet Fund. */
33
34 #ifndef NETTLE_ECDSA_H_INCLUDED
35 #define NETTLE_ECDSA_H_INCLUDED
36
37 #include "ecc.h"
38 #include "dsa.h"
39
40 #ifdef __cplusplus
41 extern "C" {
42 #endif
43
44 /* Name mangling */
45 #define ecdsa_sign nettle_ecdsa_sign
46 #define ecdsa_verify nettle_ecdsa_verify
47 #define ecdsa_generate_keypair nettle_ecdsa_generate_keypair
48 #define ecc_ecdsa_sign nettle_ecc_ecdsa_sign
49 #define ecc_ecdsa_sign_itch nettle_ecc_ecdsa_sign_itch
50 #define ecc_ecdsa_verify nettle_ecc_ecdsa_verify
51 #define ecc_ecdsa_verify_itch nettle_ecc_ecdsa_verify_itch
52
53 /* High level ECDSA functions.
54  *
55  * A public key is represented as a struct ecc_point, and a private
56  * key as a struct ecc_scalar. FIXME: Introduce some aliases? */
57 void
58 ecdsa_sign (const struct ecc_scalar *key,
59             void *random_ctx, nettle_random_func *random,
60             size_t digest_length,
61             const uint8_t *digest,
62             struct dsa_signature *signature);
63
64 int
65 ecdsa_verify (const struct ecc_point *pub,
66               size_t length, const uint8_t *digest,
67               const struct dsa_signature *signature);
68
69 void
70 ecdsa_generate_keypair (struct ecc_point *pub,
71                         struct ecc_scalar *key,
72                         void *random_ctx, nettle_random_func *random);
73
74 /* Low-level ECDSA functions. */
75 mp_size_t
76 ecc_ecdsa_sign_itch (const struct ecc_curve *ecc);
77
78 void
79 ecc_ecdsa_sign (const struct ecc_curve *ecc,
80                 const mp_limb_t *zp,
81                 /* Random nonce, must be invertible mod ecc group
82                    order. */
83                 const mp_limb_t *kp,
84                 size_t length, const uint8_t *digest,
85                 mp_limb_t *rp, mp_limb_t *sp,
86                 mp_limb_t *scratch);
87
88 mp_size_t
89 ecc_ecdsa_verify_itch (const struct ecc_curve *ecc);
90
91 int
92 ecc_ecdsa_verify (const struct ecc_curve *ecc,
93                   const mp_limb_t *pp, /* Public key */
94                   size_t length, const uint8_t *digest,
95                   const mp_limb_t *rp, const mp_limb_t *sp,
96                   mp_limb_t *scratch);
97
98
99 #ifdef __cplusplus
100 }
101 #endif
102
103 #endif /* NETTLE_ECDSA_H_INCLUDED */