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 extern const struct nettle_cipher * const nettle_ciphers[];
66 extern const struct nettle_cipher nettle_aes128;
67 extern const struct nettle_cipher nettle_aes192;
68 extern const struct nettle_cipher nettle_aes256;
70 extern const struct nettle_cipher nettle_camellia128;
71 extern const struct nettle_cipher nettle_camellia192;
72 extern const struct nettle_cipher nettle_camellia256;
74 extern const struct nettle_cipher nettle_cast128;
76 extern const struct nettle_cipher nettle_serpent128;
77 extern const struct nettle_cipher nettle_serpent192;
78 extern const struct nettle_cipher nettle_serpent256;
80 extern const struct nettle_cipher nettle_twofish128;
81 extern const struct nettle_cipher nettle_twofish192;
82 extern const struct nettle_cipher nettle_twofish256;
84 extern const struct nettle_cipher nettle_arctwo40;
85 extern const struct nettle_cipher nettle_arctwo64;
86 extern const struct nettle_cipher nettle_arctwo128;
87 extern const struct nettle_cipher nettle_arctwo_gutmann128;
93 /* Size of the context struct */
94 unsigned context_size;
99 /* Internal block size */
102 nettle_hash_init_func *init;
103 nettle_hash_update_func *update;
104 nettle_hash_digest_func *digest;
107 #define _NETTLE_HASH(name, NAME) { \
109 sizeof(struct name##_ctx), \
110 NAME##_DIGEST_SIZE, \
112 (nettle_hash_init_func *) name##_init, \
113 (nettle_hash_update_func *) name##_update, \
114 (nettle_hash_digest_func *) name##_digest \
117 /* null-terminated list of digests implemented by this version of nettle */
118 extern const struct nettle_hash * const nettle_hashes[];
120 extern const struct nettle_hash nettle_md2;
121 extern const struct nettle_hash nettle_md4;
122 extern const struct nettle_hash nettle_md5;
123 extern const struct nettle_hash nettle_gosthash94;
124 extern const struct nettle_hash nettle_ripemd160;
125 extern const struct nettle_hash nettle_sha1;
126 extern const struct nettle_hash nettle_sha224;
127 extern const struct nettle_hash nettle_sha256;
128 extern const struct nettle_hash nettle_sha384;
129 extern const struct nettle_hash nettle_sha512;
130 extern const struct nettle_hash nettle_sha512_224;
131 extern const struct nettle_hash nettle_sha512_256;
132 extern const struct nettle_hash nettle_sha3_224;
133 extern const struct nettle_hash nettle_sha3_256;
134 extern const struct nettle_hash nettle_sha3_384;
135 extern const struct nettle_hash nettle_sha3_512;
141 unsigned context_size;
142 /* Block size for encrypt and decrypt. */
146 unsigned digest_size;
148 nettle_set_key_func *set_encrypt_key;
149 nettle_set_key_func *set_decrypt_key;
150 nettle_set_key_func *set_nonce;
151 nettle_hash_update_func *update;
152 nettle_crypt_func *encrypt;
153 nettle_crypt_func *decrypt;
154 /* FIXME: Drop length argument? */
155 nettle_hash_digest_func *digest;
158 /* null-terminated list of aead constructions implemented by this
160 extern const struct nettle_aead * const nettle_aeads[];
162 extern const struct nettle_aead nettle_gcm_aes128;
163 extern const struct nettle_aead nettle_gcm_aes192;
164 extern const struct nettle_aead nettle_gcm_aes256;
165 extern const struct nettle_aead nettle_gcm_camellia128;
166 extern const struct nettle_aead nettle_gcm_camellia256;
167 extern const struct nettle_aead nettle_eax_aes128;
168 extern const struct nettle_aead nettle_chacha_poly1305;
173 unsigned encode_context_size;
174 unsigned decode_context_size;
176 unsigned encode_final_length;
178 nettle_armor_init_func *encode_init;
179 nettle_armor_length_func *encode_length;
180 nettle_armor_encode_update_func *encode_update;
181 nettle_armor_encode_final_func *encode_final;
183 nettle_armor_init_func *decode_init;
184 nettle_armor_length_func *decode_length;
185 nettle_armor_decode_update_func *decode_update;
186 nettle_armor_decode_final_func *decode_final;
189 #define _NETTLE_ARMOR(name, NAME) { \
191 sizeof(struct name##_encode_ctx), \
192 sizeof(struct name##_decode_ctx), \
193 NAME##_ENCODE_FINAL_LENGTH, \
194 (nettle_armor_init_func *) name##_encode_init, \
195 (nettle_armor_length_func *) name##_encode_length, \
196 (nettle_armor_encode_update_func *) name##_encode_update, \
197 (nettle_armor_encode_final_func *) name##_encode_final, \
198 (nettle_armor_init_func *) name##_decode_init, \
199 (nettle_armor_length_func *) name##_decode_length, \
200 (nettle_armor_decode_update_func *) name##_decode_update, \
201 (nettle_armor_decode_final_func *) name##_decode_final, \
204 #define _NETTLE_ARMOR_0(name, NAME) { \
207 sizeof(struct name##_decode_ctx), \
208 NAME##_ENCODE_FINAL_LENGTH, \
209 (nettle_armor_init_func *) name##_encode_init, \
210 (nettle_armor_length_func *) name##_encode_length, \
211 (nettle_armor_encode_update_func *) name##_encode_update, \
212 (nettle_armor_encode_final_func *) name##_encode_final, \
213 (nettle_armor_init_func *) name##_decode_init, \
214 (nettle_armor_length_func *) name##_decode_length, \
215 (nettle_armor_decode_update_func *) name##_decode_update, \
216 (nettle_armor_decode_final_func *) name##_decode_final, \
219 /* null-terminated list of armor schemes implemented by this version of nettle */
220 extern const struct nettle_armor * const nettle_armors[];
222 extern const struct nettle_armor nettle_base64;
223 extern const struct nettle_armor nettle_base64url;
224 extern const struct nettle_armor nettle_base16;
230 #endif /* NETTLE_META_H_INCLUDED */