3 Information about algorithms.
5 Copyright (C) 2002, 2014 Niels Möller
7 This file is part of GNU Nettle.
9 GNU Nettle is free software: you can redistribute it and/or
10 modify it under the terms of either:
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.
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.
22 or both in parallel, as here.
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.
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/.
34 #ifndef NETTLE_META_H_INCLUDED
35 #define NETTLE_META_H_INCLUDED
37 #include "nettle-types.h"
48 unsigned context_size;
50 /* Zero for stream ciphers */
53 /* Suggested key size; other sizes are sometimes possible. */
56 nettle_set_key_func *set_encrypt_key;
57 nettle_set_key_func *set_decrypt_key;
59 nettle_cipher_func *encrypt;
60 nettle_cipher_func *decrypt;
63 /* FIXME: Rename with leading underscore, but keep current name (and
64 size!) for now, for ABI compatibility with nettle-3.1, soname
66 /* null-terminated list of ciphers implemented by this version of nettle */
67 extern const struct nettle_cipher * const nettle_ciphers[];
69 const struct nettle_cipher * const *
73 nettle_get_ciphers (void);
75 #define nettle_ciphers (nettle_get_ciphers())
77 extern const struct nettle_cipher nettle_aes128;
78 extern const struct nettle_cipher nettle_aes192;
79 extern const struct nettle_cipher nettle_aes256;
81 extern const struct nettle_cipher nettle_camellia128;
82 extern const struct nettle_cipher nettle_camellia192;
83 extern const struct nettle_cipher nettle_camellia256;
85 extern const struct nettle_cipher nettle_cast128;
87 extern const struct nettle_cipher nettle_serpent128;
88 extern const struct nettle_cipher nettle_serpent192;
89 extern const struct nettle_cipher nettle_serpent256;
91 extern const struct nettle_cipher nettle_twofish128;
92 extern const struct nettle_cipher nettle_twofish192;
93 extern const struct nettle_cipher nettle_twofish256;
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;
104 /* Size of the context struct */
105 unsigned context_size;
107 /* Size of digests */
108 unsigned digest_size;
110 /* Internal block size */
113 nettle_hash_init_func *init;
114 nettle_hash_update_func *update;
115 nettle_hash_digest_func *digest;
118 #define _NETTLE_HASH(name, NAME) { \
120 sizeof(struct name##_ctx), \
121 NAME##_DIGEST_SIZE, \
123 (nettle_hash_init_func *) name##_init, \
124 (nettle_hash_update_func *) name##_update, \
125 (nettle_hash_digest_func *) name##_digest \
128 /* FIXME: Rename with leading underscore, but keep current name (and
129 size!) for now, for ABI compatibility with nettle-3.1, soname
131 /* null-terminated list of digests implemented by this version of nettle */
132 extern const struct nettle_hash * const nettle_hashes[];
134 const struct nettle_hash * const *
136 __attribute__((pure))
138 nettle_get_hashes (void);
140 #define nettle_hashes (nettle_get_hashes())
142 const struct nettle_hash *
143 nettle_lookup_hash (const char *name);
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;
166 unsigned context_size;
167 /* Block size for encrypt and decrypt. */
171 unsigned digest_size;
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;
183 /* FIXME: Rename with leading underscore, but keep current name (and
184 size!) for now, for ABI compatibility with nettle-3.1, soname
186 /* null-terminated list of aead constructions implemented by this
188 extern const struct nettle_aead * const nettle_aeads[];
190 const struct nettle_aead * const *
192 __attribute__((pure))
194 nettle_get_aeads (void);
196 #define nettle_aeads (nettle_get_aeads())
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;
209 unsigned encode_context_size;
210 unsigned decode_context_size;
212 unsigned encode_final_length;
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;
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;
225 #define _NETTLE_ARMOR(name, 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, \
240 #define _NETTLE_ARMOR_0(name, NAME) { \
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, \
255 /* FIXME: Rename with leading underscore, but keep current name (and
256 size!) for now, for ABI compatibility with nettle-3.1, soname
258 /* null-terminated list of armor schemes implemented by this version of nettle */
259 extern const struct nettle_armor * const nettle_armors[];
261 const struct nettle_armor * const *
263 __attribute__((pure))
265 nettle_get_armors (void);
267 #define nettle_armors (nettle_get_armors())
269 extern const struct nettle_armor nettle_base64;
270 extern const struct nettle_armor nettle_base64url;
271 extern const struct nettle_armor nettle_base16;
277 #endif /* NETTLE_META_H_INCLUDED */