eddsa.h 3.14 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
/* eddsa.h

   Copyright (C) 2014 Niels Möller

   This file is part of GNU Nettle.

   GNU Nettle is free software: you can redistribute it and/or
   modify it under the terms of either:

     * the GNU Lesser General Public License as published by the Free
       Software Foundation; either version 3 of the License, or (at your
       option) any later version.

   or

     * the GNU General Public License as published by the Free
       Software Foundation; either version 2 of the License, or (at your
       option) any later version.

   or both in parallel, as here.

   GNU Nettle is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   General Public License for more details.

   You should have received copies of the GNU General Public License and
   the GNU Lesser General Public License along with this program.  If
   not, see http://www.gnu.org/licenses/.
*/

#ifndef NETTLE_EDDSA_H
#define NETTLE_EDDSA_H

#include "nettle-types.h"

#include "bignum.h"

#ifdef __cplusplus
extern "C" {
#endif

/* Name mangling */
#define _eddsa_compress _nettle_eddsa_compress
#define _eddsa_compress_itch _nettle_eddsa_compress_itch
#define _eddsa_decompress _nettle_eddsa_decompress
#define _eddsa_decompress_itch _nettle_eddsa_decompress_itch
48
#define _eddsa_hash _nettle_eddsa_hash
49
50
#define _eddsa_expand_key_itch _nettle_eddsa_expand_key_itch
#define _eddsa_expand_key _nettle_eddsa_expand_key
51
52
#define _eddsa_sign _nettle_eddsa_sign
#define _eddsa_sign_itch _nettle_eddsa_sign_itch
53
54
#define _eddsa_verify _nettle_eddsa_verify
#define _eddsa_verify_itch _nettle_eddsa_verify_itch
55
56
57
58

#define ED25519_KEY_SIZE 32

struct ecc_curve;
59
struct ecc_modulo;
60
61
62
63
64
65
66
67
68
69
70
71
72
73

mp_size_t
_eddsa_compress_itch (const struct ecc_curve *ecc);
void
_eddsa_compress (const struct ecc_curve *ecc, uint8_t *r, mp_limb_t *p,
		 mp_limb_t *scratch);

mp_size_t
_eddsa_decompress_itch (const struct ecc_curve *ecc);
int
_eddsa_decompress (const struct ecc_curve *ecc, mp_limb_t *p,
		   const uint8_t *cp,
		   mp_limb_t *scratch);

74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
void
_eddsa_hash (const struct ecc_modulo *m,
	     mp_limb_t *rp, const uint8_t *digest);

mp_size_t
_eddsa_sign_itch (const struct ecc_curve *ecc);

void
_eddsa_sign (const struct ecc_curve *ecc,
	     const struct nettle_hash *H,
	     const uint8_t *pub,
	     void *ctx,
	     const mp_limb_t *k2,
	     size_t length,
	     const uint8_t *msg,
	     uint8_t *signature,
	     mp_limb_t *scratch);

92
93
94
95
96
97
98
99
mp_size_t
_eddsa_verify_itch (const struct ecc_curve *ecc);

int
_eddsa_verify (const struct ecc_curve *ecc,
	       const struct nettle_hash *H,
	       const uint8_t *pub,
	       const mp_limb_t *A,
100
	       void *ctx,
101
102
103
104
105
	       size_t length,
	       const uint8_t *msg,
	       const uint8_t *signature,
	       mp_limb_t *scratch);

106
107
108
109
110
111
112
113
114
115
116
117
118
119
mp_size_t
_eddsa_expand_key_itch (const struct ecc_curve *ecc);

void
_eddsa_expand_key (const struct ecc_curve *ecc,
		   const struct nettle_hash *H,
		   void *ctx,
		   const uint8_t *key,
		   uint8_t *pub,
		   uint8_t *k1,
		   mp_limb_t *k2,
		   mp_limb_t *scratch);

			   
120
121
122
123
124
#ifdef __cplusplus
}
#endif

#endif /* NETTLE_EDDSA_H */