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 /* null-terminated list of ciphers implemented by this version of nettle */
64 const struct nettle_cipher * const * _NETTLE_ATTRIBUTE_PURE
65 nettle_get_ciphers (void);
67 #define nettle_ciphers (nettle_get_ciphers())
69 extern const struct nettle_cipher nettle_aes128;
70 extern const struct nettle_cipher nettle_aes192;
71 extern const struct nettle_cipher nettle_aes256;
73 extern const struct nettle_cipher nettle_camellia128;
74 extern const struct nettle_cipher nettle_camellia192;
75 extern const struct nettle_cipher nettle_camellia256;
77 extern const struct nettle_cipher nettle_cast128;
79 extern const struct nettle_cipher nettle_serpent128;
80 extern const struct nettle_cipher nettle_serpent192;
81 extern const struct nettle_cipher nettle_serpent256;
83 extern const struct nettle_cipher nettle_twofish128;
84 extern const struct nettle_cipher nettle_twofish192;
85 extern const struct nettle_cipher nettle_twofish256;
87 extern const struct nettle_cipher nettle_arctwo40;
88 extern const struct nettle_cipher nettle_arctwo64;
89 extern const struct nettle_cipher nettle_arctwo128;
90 extern const struct nettle_cipher nettle_arctwo_gutmann128;
96 /* Size of the context struct */
97 unsigned context_size;
100 unsigned digest_size;
102 /* Internal block size */
105 nettle_hash_init_func *init;
106 nettle_hash_update_func *update;
107 nettle_hash_digest_func *digest;
110 #define _NETTLE_HASH(name, NAME) { \
112 sizeof(struct name##_ctx), \
113 NAME##_DIGEST_SIZE, \
115 (nettle_hash_init_func *) name##_init, \
116 (nettle_hash_update_func *) name##_update, \
117 (nettle_hash_digest_func *) name##_digest \
120 /* null-terminated list of digests implemented by this version of nettle */
121 const struct nettle_hash * const * _NETTLE_ATTRIBUTE_PURE
122 nettle_get_hashes (void);
124 #define nettle_hashes (nettle_get_hashes())
126 const struct nettle_hash *
127 nettle_lookup_hash (const char *name);
129 extern const struct nettle_hash nettle_md2;
130 extern const struct nettle_hash nettle_md4;
131 extern const struct nettle_hash nettle_md5;
132 extern const struct nettle_hash nettle_gosthash94;
133 extern const struct nettle_hash nettle_ripemd160;
134 extern const struct nettle_hash nettle_sha1;
135 extern const struct nettle_hash nettle_sha224;
136 extern const struct nettle_hash nettle_sha256;
137 extern const struct nettle_hash nettle_sha384;
138 extern const struct nettle_hash nettle_sha512;
139 extern const struct nettle_hash nettle_sha512_224;
140 extern const struct nettle_hash nettle_sha512_256;
141 extern const struct nettle_hash nettle_sha3_224;
142 extern const struct nettle_hash nettle_sha3_256;
143 extern const struct nettle_hash nettle_sha3_384;
144 extern const struct nettle_hash nettle_sha3_512;
150 unsigned context_size;
151 /* Block size for encrypt and decrypt. */
155 unsigned digest_size;
157 nettle_set_key_func *set_encrypt_key;
158 nettle_set_key_func *set_decrypt_key;
159 nettle_set_key_func *set_nonce;
160 nettle_hash_update_func *update;
161 nettle_crypt_func *encrypt;
162 nettle_crypt_func *decrypt;
163 /* FIXME: Drop length argument? */
164 nettle_hash_digest_func *digest;
167 /* null-terminated list of aead constructions implemented by this
169 const struct nettle_aead * const * _NETTLE_ATTRIBUTE_PURE
170 nettle_get_aeads (void);
172 #define nettle_aeads (nettle_get_aeads())
174 extern const struct nettle_aead nettle_gcm_aes128;
175 extern const struct nettle_aead nettle_gcm_aes192;
176 extern const struct nettle_aead nettle_gcm_aes256;
177 extern const struct nettle_aead nettle_gcm_camellia128;
178 extern const struct nettle_aead nettle_gcm_camellia256;
179 extern const struct nettle_aead nettle_eax_aes128;
180 extern const struct nettle_aead nettle_chacha_poly1305;
185 unsigned encode_context_size;
186 unsigned decode_context_size;
188 unsigned encode_final_length;
190 nettle_armor_init_func *encode_init;
191 nettle_armor_length_func *encode_length;
192 nettle_armor_encode_update_func *encode_update;
193 nettle_armor_encode_final_func *encode_final;
195 nettle_armor_init_func *decode_init;
196 nettle_armor_length_func *decode_length;
197 nettle_armor_decode_update_func *decode_update;
198 nettle_armor_decode_final_func *decode_final;
201 #define _NETTLE_ARMOR(name, NAME) { \
203 sizeof(struct name##_encode_ctx), \
204 sizeof(struct name##_decode_ctx), \
205 NAME##_ENCODE_FINAL_LENGTH, \
206 (nettle_armor_init_func *) name##_encode_init, \
207 (nettle_armor_length_func *) name##_encode_length, \
208 (nettle_armor_encode_update_func *) name##_encode_update, \
209 (nettle_armor_encode_final_func *) name##_encode_final, \
210 (nettle_armor_init_func *) name##_decode_init, \
211 (nettle_armor_length_func *) name##_decode_length, \
212 (nettle_armor_decode_update_func *) name##_decode_update, \
213 (nettle_armor_decode_final_func *) name##_decode_final, \
216 #define _NETTLE_ARMOR_0(name, NAME) { \
219 sizeof(struct name##_decode_ctx), \
220 NAME##_ENCODE_FINAL_LENGTH, \
221 (nettle_armor_init_func *) name##_encode_init, \
222 (nettle_armor_length_func *) name##_encode_length, \
223 (nettle_armor_encode_update_func *) name##_encode_update, \
224 (nettle_armor_encode_final_func *) name##_encode_final, \
225 (nettle_armor_init_func *) name##_decode_init, \
226 (nettle_armor_length_func *) name##_decode_length, \
227 (nettle_armor_decode_update_func *) name##_decode_update, \
228 (nettle_armor_decode_final_func *) name##_decode_final, \
231 /* null-terminated list of armor schemes implemented by this version of nettle */
232 const struct nettle_armor * const * _NETTLE_ATTRIBUTE_PURE
233 nettle_get_armors (void);
235 #define nettle_armors (nettle_get_armors())
237 extern const struct nettle_armor nettle_base64;
238 extern const struct nettle_armor nettle_base64url;
239 extern const struct nettle_armor nettle_base16;
245 #endif /* NETTLE_META_H_INCLUDED */