Update mini-gmp version for _rsa_sec_compute_root_tr rename.
[gd/nettle] / nettle-meta.h
1 /* nettle-meta.h
2
3    Information about algorithms.
4
5    Copyright (C) 2002, 2014 Niels Möller
6
7    This file is part of GNU Nettle.
8
9    GNU Nettle is free software: you can redistribute it and/or
10    modify it under the terms of either:
11
12      * the GNU Lesser General Public License as published by the Free
13        Software Foundation; either version 3 of the License, or (at your
14        option) any later version.
15
16    or
17
18      * the GNU General Public License as published by the Free
19        Software Foundation; either version 2 of the License, or (at your
20        option) any later version.
21
22    or both in parallel, as here.
23
24    GNU Nettle is distributed in the hope that it will be useful,
25    but WITHOUT ANY WARRANTY; without even the implied warranty of
26    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
27    General Public License for more details.
28
29    You should have received copies of the GNU General Public License and
30    the GNU Lesser General Public License along with this program.  If
31    not, see http://www.gnu.org/licenses/.
32 */
33
34 #ifndef NETTLE_META_H_INCLUDED
35 #define NETTLE_META_H_INCLUDED
36
37 #include "nettle-types.h"
38
39 #ifdef __cplusplus
40 extern "C" {
41 #endif
42
43
44 struct nettle_cipher
45 {
46   const char *name;
47   
48   unsigned context_size;
49   
50   /* Zero for stream ciphers */
51   unsigned block_size;
52
53   /* Suggested key size; other sizes are sometimes possible. */
54   unsigned key_size;
55
56   nettle_set_key_func *set_encrypt_key;
57   nettle_set_key_func *set_decrypt_key;
58
59   nettle_cipher_func *encrypt;
60   nettle_cipher_func *decrypt;
61 };
62
63 /* FIXME: Rename with leading underscore, but keep current name (and
64    size!) for now, for ABI compatibility with nettle-3.1, soname
65    libnettle.so.6. */
66 /* null-terminated list of ciphers implemented by this version of nettle */
67 extern const struct nettle_cipher * const nettle_ciphers[];
68
69 const struct nettle_cipher * const *
70 #ifdef __GNUC__
71 __attribute__((pure))
72 #endif
73 nettle_get_ciphers (void);
74
75 #define nettle_ciphers (nettle_get_ciphers())
76
77 extern const struct nettle_cipher nettle_aes128;
78 extern const struct nettle_cipher nettle_aes192;
79 extern const struct nettle_cipher nettle_aes256;
80
81 extern const struct nettle_cipher nettle_camellia128;
82 extern const struct nettle_cipher nettle_camellia192;
83 extern const struct nettle_cipher nettle_camellia256;
84
85 extern const struct nettle_cipher nettle_cast128;
86
87 extern const struct nettle_cipher nettle_serpent128;
88 extern const struct nettle_cipher nettle_serpent192;
89 extern const struct nettle_cipher nettle_serpent256;
90
91 extern const struct nettle_cipher nettle_twofish128;
92 extern const struct nettle_cipher nettle_twofish192;
93 extern const struct nettle_cipher nettle_twofish256;
94
95 extern const struct nettle_cipher nettle_arctwo40;
96 extern const struct nettle_cipher nettle_arctwo64;
97 extern const struct nettle_cipher nettle_arctwo128;
98 extern const struct nettle_cipher nettle_arctwo_gutmann128;
99
100 struct nettle_hash
101 {
102   const char *name;
103
104   /* Size of the context struct */
105   unsigned context_size;
106
107   /* Size of digests */
108   unsigned digest_size;
109   
110   /* Internal block size */
111   unsigned block_size;
112
113   nettle_hash_init_func *init;
114   nettle_hash_update_func *update;
115   nettle_hash_digest_func *digest;
116 };
117
118 #define _NETTLE_HASH(name, NAME) {              \
119  #name,                                         \
120  sizeof(struct name##_ctx),                     \
121  NAME##_DIGEST_SIZE,                            \
122  NAME##_BLOCK_SIZE,                             \
123  (nettle_hash_init_func *) name##_init,         \
124  (nettle_hash_update_func *) name##_update,     \
125  (nettle_hash_digest_func *) name##_digest      \
126
127
128 /* FIXME: Rename with leading underscore, but keep current name (and
129    size!) for now, for ABI compatibility with nettle-3.1, soname
130    libnettle.so.6. */
131 /* null-terminated list of digests implemented by this version of nettle */
132 extern const struct nettle_hash * const nettle_hashes[];
133
134 const struct nettle_hash * const *
135 #ifdef __GNUC__
136 __attribute__((pure))
137 #endif
138 nettle_get_hashes (void);
139
140 #define nettle_hashes (nettle_get_hashes())
141
142 const struct nettle_hash *
143 nettle_lookup_hash (const char *name);
144
145 extern const struct nettle_hash nettle_md2;
146 extern const struct nettle_hash nettle_md4;
147 extern const struct nettle_hash nettle_md5;
148 extern const struct nettle_hash nettle_gosthash94;
149 extern const struct nettle_hash nettle_ripemd160;
150 extern const struct nettle_hash nettle_sha1;
151 extern const struct nettle_hash nettle_sha224;
152 extern const struct nettle_hash nettle_sha256;
153 extern const struct nettle_hash nettle_sha384;
154 extern const struct nettle_hash nettle_sha512;
155 extern const struct nettle_hash nettle_sha512_224;
156 extern const struct nettle_hash nettle_sha512_256;
157 extern const struct nettle_hash nettle_sha3_224;
158 extern const struct nettle_hash nettle_sha3_256;
159 extern const struct nettle_hash nettle_sha3_384;
160 extern const struct nettle_hash nettle_sha3_512;
161
162 struct nettle_aead
163 {
164   const char *name;
165   
166   unsigned context_size;
167   /* Block size for encrypt and decrypt. */
168   unsigned block_size;
169   unsigned key_size;
170   unsigned nonce_size;
171   unsigned digest_size;
172
173   nettle_set_key_func *set_encrypt_key;
174   nettle_set_key_func *set_decrypt_key;
175   nettle_set_key_func *set_nonce;
176   nettle_hash_update_func *update;
177   nettle_crypt_func *encrypt;
178   nettle_crypt_func *decrypt;
179   /* FIXME: Drop length argument? */
180   nettle_hash_digest_func *digest;
181 };
182
183 /* FIXME: Rename with leading underscore, but keep current name (and
184    size!) for now, for ABI compatibility with nettle-3.1, soname
185    libnettle.so.6. */
186 /* null-terminated list of aead constructions implemented by this
187    version of nettle */
188 extern const struct nettle_aead * const nettle_aeads[];
189
190 const struct nettle_aead * const *
191 #ifdef __GNUC__
192 __attribute__((pure))
193 #endif
194 nettle_get_aeads (void);
195
196 #define nettle_aeads (nettle_get_aeads())
197
198 extern const struct nettle_aead nettle_gcm_aes128;
199 extern const struct nettle_aead nettle_gcm_aes192;
200 extern const struct nettle_aead nettle_gcm_aes256;
201 extern const struct nettle_aead nettle_gcm_camellia128;
202 extern const struct nettle_aead nettle_gcm_camellia256;
203 extern const struct nettle_aead nettle_eax_aes128;
204 extern const struct nettle_aead nettle_chacha_poly1305;
205
206 struct nettle_armor
207 {
208   const char *name;
209   unsigned encode_context_size;
210   unsigned decode_context_size;
211
212   unsigned encode_final_length;
213
214   nettle_armor_init_func *encode_init;
215   nettle_armor_length_func *encode_length;
216   nettle_armor_encode_update_func *encode_update;
217   nettle_armor_encode_final_func *encode_final;
218   
219   nettle_armor_init_func *decode_init;
220   nettle_armor_length_func *decode_length;
221   nettle_armor_decode_update_func *decode_update;
222   nettle_armor_decode_final_func *decode_final;
223 };
224
225 #define _NETTLE_ARMOR(name, NAME) {                             \
226   #name,                                                        \
227   sizeof(struct name##_encode_ctx),                             \
228   sizeof(struct name##_decode_ctx),                             \
229   NAME##_ENCODE_FINAL_LENGTH,                                   \
230   (nettle_armor_init_func *) name##_encode_init,                \
231   (nettle_armor_length_func *) name##_encode_length,            \
232   (nettle_armor_encode_update_func *) name##_encode_update,     \
233   (nettle_armor_encode_final_func *) name##_encode_final,       \
234   (nettle_armor_init_func *) name##_decode_init,                \
235   (nettle_armor_length_func *) name##_decode_length,            \
236   (nettle_armor_decode_update_func *) name##_decode_update,     \
237   (nettle_armor_decode_final_func *) name##_decode_final,       \
238 }
239
240 #define _NETTLE_ARMOR_0(name, NAME) {                           \
241   #name,                                                        \
242   0,                                                            \
243   sizeof(struct name##_decode_ctx),                             \
244   NAME##_ENCODE_FINAL_LENGTH,                                   \
245   (nettle_armor_init_func *) name##_encode_init,                \
246   (nettle_armor_length_func *) name##_encode_length,            \
247   (nettle_armor_encode_update_func *) name##_encode_update,     \
248   (nettle_armor_encode_final_func *) name##_encode_final,       \
249   (nettle_armor_init_func *) name##_decode_init,                \
250   (nettle_armor_length_func *) name##_decode_length,            \
251   (nettle_armor_decode_update_func *) name##_decode_update,     \
252   (nettle_armor_decode_final_func *) name##_decode_final,       \
253 }
254
255 /* FIXME: Rename with leading underscore, but keep current name (and
256    size!) for now, for ABI compatibility with nettle-3.1, soname
257    libnettle.so.6. */
258 /* null-terminated list of armor schemes implemented by this version of nettle */
259 extern const struct nettle_armor * const nettle_armors[];
260
261 const struct nettle_armor * const *
262 #ifdef __GNUC__
263 __attribute__((pure))
264 #endif
265 nettle_get_armors (void);
266
267 #define nettle_armors (nettle_get_armors())
268
269 extern const struct nettle_armor nettle_base64;
270 extern const struct nettle_armor nettle_base64url;
271 extern const struct nettle_armor nettle_base16;
272
273 #ifdef __cplusplus
274 }
275 #endif
276
277 #endif /* NETTLE_META_H_INCLUDED */