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