3 * Information about algorithms.
6 /* nettle, low-level cryptographics library
8 * Copyright (C) 2002 Niels Möller
10 * The nettle library is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU Lesser General Public License as published by
12 * the Free Software Foundation; either version 2.1 of the License, or (at your
13 * option) any later version.
15 * The nettle library is distributed in the hope that it will be useful, but
16 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
17 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
18 * License for more details.
20 * You should have received a copy of the GNU Lesser General Public License
21 * along with the nettle library; see the file COPYING.LIB. If not, write to
22 * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
26 #ifndef NETTLE_META_H_INCLUDED
27 #define NETTLE_META_H_INCLUDED
29 #include "nettle-types.h"
40 unsigned context_size;
42 /* Zero for stream ciphers */
45 /* Suggested key size; other sizes are sometimes possible. */
48 nettle_set_key_func *set_encrypt_key;
49 nettle_set_key_func *set_decrypt_key;
51 nettle_crypt_func *encrypt;
52 nettle_crypt_func *decrypt;
55 #define _NETTLE_CIPHER(name, NAME, key_size) { \
57 sizeof(struct name##_ctx), \
60 (nettle_set_key_func *) name##_set_key, \
61 (nettle_set_key_func *) name##_set_key, \
62 (nettle_crypt_func *) name##_encrypt, \
63 (nettle_crypt_func *) name##_decrypt, \
66 #define _NETTLE_CIPHER_SEP(name, NAME, key_size) { \
68 sizeof(struct name##_ctx), \
71 (nettle_set_key_func *) name##_set_encrypt_key, \
72 (nettle_set_key_func *) name##_set_decrypt_key, \
73 (nettle_crypt_func *) name##_encrypt, \
74 (nettle_crypt_func *) name##_decrypt, \
77 #define _NETTLE_CIPHER_SEP_SET_KEY(name, NAME, key_size) {\
79 sizeof(struct name##_ctx), \
82 (nettle_set_key_func *) name##_set_encrypt_key, \
83 (nettle_set_key_func *) name##_set_decrypt_key, \
84 (nettle_crypt_func *) name##_crypt, \
85 (nettle_crypt_func *) name##_crypt, \
88 #define _NETTLE_CIPHER_FIX(name, NAME) { \
90 sizeof(struct name##_ctx), \
93 (nettle_set_key_func *) name##_set_key, \
94 (nettle_set_key_func *) name##_set_key, \
95 (nettle_crypt_func *) name##_encrypt, \
96 (nettle_crypt_func *) name##_decrypt, \
99 /* null-terminated list of ciphers implemented by this version of nettle */
100 extern const struct nettle_cipher * const nettle_ciphers[];
102 extern const struct nettle_cipher nettle_aes128;
103 extern const struct nettle_cipher nettle_aes192;
104 extern const struct nettle_cipher nettle_aes256;
106 extern const struct nettle_cipher nettle_arcfour128;
108 extern const struct nettle_cipher nettle_camellia128;
109 extern const struct nettle_cipher nettle_camellia192;
110 extern const struct nettle_cipher nettle_camellia256;
112 extern const struct nettle_cipher nettle_cast128;
114 extern const struct nettle_cipher nettle_serpent128;
115 extern const struct nettle_cipher nettle_serpent192;
116 extern const struct nettle_cipher nettle_serpent256;
118 extern const struct nettle_cipher nettle_twofish128;
119 extern const struct nettle_cipher nettle_twofish192;
120 extern const struct nettle_cipher nettle_twofish256;
122 extern const struct nettle_cipher nettle_arctwo40;
123 extern const struct nettle_cipher nettle_arctwo64;
124 extern const struct nettle_cipher nettle_arctwo128;
125 extern const struct nettle_cipher nettle_arctwo_gutmann128;
131 /* Size of the context struct */
132 unsigned context_size;
134 /* Size of digests */
135 unsigned digest_size;
137 /* Internal block size */
140 nettle_hash_init_func *init;
141 nettle_hash_update_func *update;
142 nettle_hash_digest_func *digest;
145 #define _NETTLE_HASH(name, NAME) { \
147 sizeof(struct name##_ctx), \
148 NAME##_DIGEST_SIZE, \
150 (nettle_hash_init_func *) name##_init, \
151 (nettle_hash_update_func *) name##_update, \
152 (nettle_hash_digest_func *) name##_digest \
155 /* null-terminated list of digests implemented by this version of nettle */
156 extern const struct nettle_hash * const nettle_hashes[];
158 extern const struct nettle_hash nettle_md2;
159 extern const struct nettle_hash nettle_md4;
160 extern const struct nettle_hash nettle_md5;
161 extern const struct nettle_hash nettle_ripemd160;
162 extern const struct nettle_hash nettle_sha1;
163 extern const struct nettle_hash nettle_sha224;
164 extern const struct nettle_hash nettle_sha256;
165 extern const struct nettle_hash nettle_sha384;
166 extern const struct nettle_hash nettle_sha512;
171 unsigned encode_context_size;
172 unsigned decode_context_size;
174 unsigned encode_final_length;
176 nettle_armor_init_func *encode_init;
177 nettle_armor_length_func *encode_length;
178 nettle_armor_encode_update_func *encode_update;
179 nettle_armor_encode_final_func *encode_final;
181 nettle_armor_init_func *decode_init;
182 nettle_armor_length_func *decode_length;
183 nettle_armor_decode_update_func *decode_update;
184 nettle_armor_decode_final_func *decode_final;
187 #define _NETTLE_ARMOR(name, NAME) { \
189 sizeof(struct name##_encode_ctx), \
190 sizeof(struct name##_decode_ctx), \
191 NAME##_ENCODE_FINAL_LENGTH, \
192 (nettle_armor_init_func *) name##_encode_init, \
193 (nettle_armor_length_func *) name##_encode_length, \
194 (nettle_armor_encode_update_func *) name##_encode_update, \
195 (nettle_armor_encode_final_func *) name##_encode_final, \
196 (nettle_armor_init_func *) name##_decode_init, \
197 (nettle_armor_length_func *) name##_decode_length, \
198 (nettle_armor_decode_update_func *) name##_decode_update, \
199 (nettle_armor_decode_final_func *) name##_decode_final, \
202 #define _NETTLE_ARMOR_0(name, NAME) { \
205 sizeof(struct name##_decode_ctx), \
206 NAME##_ENCODE_FINAL_LENGTH, \
207 (nettle_armor_init_func *) name##_encode_init, \
208 (nettle_armor_length_func *) name##_encode_length, \
209 (nettle_armor_encode_update_func *) name##_encode_update, \
210 (nettle_armor_encode_final_func *) name##_encode_final, \
211 (nettle_armor_init_func *) name##_decode_init, \
212 (nettle_armor_length_func *) name##_decode_length, \
213 (nettle_armor_decode_update_func *) name##_decode_update, \
214 (nettle_armor_decode_final_func *) name##_decode_final, \
217 /* null-terminated list of armor schemes implemented by this version of nettle */
218 extern const struct nettle_armor * const nettle_armors[];
220 extern const struct nettle_armor nettle_base64;
221 extern const struct nettle_armor nettle_base16;
227 #endif /* NETTLE_META_H_INCLUDED */