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
31 /* Randomness. Used by key generation and dsa signature creation. */
32 typedef void (*nettle_random_func
)(void *ctx
,
33 unsigned length
, uint8_t *dst
);
35 /* Progress report function, mainly for key generation. */
36 typedef void (*nettle_progress_func
)(void *ctx
,
40 typedef void (*nettle_crypt_func
)(void *ctx
,
41 unsigned length
, uint8_t *dst
,
44 typedef void (*nettle_set_key_func
)(void *ctx
,
53 unsigned context_size
;
55 /* Zero for stream ciphers */
58 /* Suggested key size; other sizes are sometimes possible. */
61 nettle_set_key_func set_encrypt_key
;
62 nettle_set_key_func set_decrypt_key
;
64 nettle_crypt_func encrypt
;
65 nettle_crypt_func decrypt
;
68 #define _NETTLE_CIPHER(name, NAME, keysize) { \
70 sizeof(struct name##_ctx), \
73 (nettle_set_key_func) name##_set_key, \
74 (nettle_set_key_func) name##_set_key, \
75 (nettle_crypt_func) name##_encrypt, \
76 (nettle_crypt_func) name##_decrypt, \
79 #define _NETTLE_CIPHER_SEP(name, NAME, keysize) { \
81 sizeof(struct name##_ctx), \
84 (nettle_set_key_func) name##_set_encrypt_key, \
85 (nettle_set_key_func) name##_set_decrypt_key, \
86 (nettle_crypt_func) name##_encrypt, \
87 (nettle_crypt_func) name##_decrypt, \
90 #define _NETTLE_CIPHER_FIX(name, NAME, keysize) { \
92 sizeof(struct name##_ctx), \
95 (nettle_set_key_func) name##_set_key, \
96 (nettle_set_key_func) name##_set_key, \
97 (nettle_crypt_func) name##_encrypt, \
98 (nettle_crypt_func) name##_decrypt, \
101 extern const struct nettle_cipher nettle_aes128
;
102 extern const struct nettle_cipher nettle_aes192
;
103 extern const struct nettle_cipher nettle_aes256
;
105 extern const struct nettle_cipher nettle_arcfour128
;
106 extern const struct nettle_cipher nettle_cast128
;
108 extern const struct nettle_cipher nettle_serpent128
;
109 extern const struct nettle_cipher nettle_serpent192
;
110 extern const struct nettle_cipher nettle_serpent256
;
112 extern const struct nettle_cipher nettle_twofish128
;
113 extern const struct nettle_cipher nettle_twofish192
;
114 extern const struct nettle_cipher nettle_twofish256
;
117 /* Hash algorithms */
118 typedef void (*nettle_hash_init_func
)(void *ctx
);
119 typedef void (*nettle_hash_update_func
)(void *ctx
,
122 typedef void (*nettle_hash_digest_func
)(void *ctx
,
123 unsigned length
, uint8_t *dst
);
129 /* Size of the context struct */
130 unsigned context_size
;
132 /* Size of digests */
133 unsigned digest_size
;
135 /* Internal block size */
138 nettle_hash_init_func init
;
139 nettle_hash_update_func update
;
140 nettle_hash_digest_func digest
;
143 #define _NETTLE_HASH(name, NAME) { \
145 sizeof(struct name##_ctx), \
146 NAME##_DIGEST_SIZE, \
148 (nettle_hash_init_func) name##_init, \
149 (nettle_hash_update_func) name##_update, \
150 (nettle_hash_digest_func) name##_digest \
153 extern const struct nettle_hash nettle_md2
;
154 extern const struct nettle_hash nettle_md4
;
155 extern const struct nettle_hash nettle_md5
;
156 extern const struct nettle_hash nettle_sha1
;
157 extern const struct nettle_hash nettle_sha256
;
160 /* ASCII armor codecs. NOTE: Experimental and subject to change. */
162 typedef unsigned (*nettle_armor_length_func
)(unsigned length
);
163 typedef void (*nettle_armor_init_func
)(void *ctx
);
165 typedef unsigned (*nettle_armor_encode_update_func
)(void *ctx
,
170 typedef unsigned (*nettle_armor_encode_final_func
)(void *ctx
, uint8_t *dst
);
172 typedef int (*nettle_armor_decode_update_func
)(void *ctx
,
173 unsigned *dst_length
,
178 typedef int (*nettle_armor_decode_final_func
)(void *ctx
);
183 unsigned encode_context_size
;
184 unsigned decode_context_size
;
186 unsigned encode_final_length
;
188 nettle_armor_init_func encode_init
;
189 nettle_armor_length_func encode_length
;
190 nettle_armor_encode_update_func encode_update
;
191 nettle_armor_encode_final_func encode_final
;
193 nettle_armor_init_func decode_init
;
194 nettle_armor_length_func decode_length
;
195 nettle_armor_decode_update_func decode_update
;
196 nettle_armor_decode_final_func decode_final
;
199 #define _NETTLE_ARMOR(name, NAME) { \
201 sizeof(struct name##_encode_ctx), \
202 sizeof(struct name##_decode_ctx), \
203 NAME##_ENCODE_FINAL_LENGTH, \
204 (nettle_armor_init_func) name##_encode_init, \
205 (nettle_armor_length_func) name##_encode_length, \
206 (nettle_armor_encode_update_func) name##_encode_update, \
207 (nettle_armor_encode_final_func) name##_encode_final, \
208 (nettle_armor_init_func) name##_decode_init, \
209 (nettle_armor_length_func) name##_decode_length, \
210 (nettle_armor_decode_update_func) name##_decode_update, \
211 (nettle_armor_decode_final_func) name##_decode_final, \
214 #define _NETTLE_ARMOR_0(name, NAME) { \
217 sizeof(struct name##_decode_ctx), \
218 NAME##_ENCODE_FINAL_LENGTH, \
219 (nettle_armor_init_func) name##_encode_init, \
220 (nettle_armor_length_func) name##_encode_length, \
221 (nettle_armor_encode_update_func) name##_encode_update, \
222 (nettle_armor_encode_final_func) name##_encode_final, \
223 (nettle_armor_init_func) name##_decode_init, \
224 (nettle_armor_length_func) name##_decode_length, \
225 (nettle_armor_decode_update_func) name##_decode_update, \
226 (nettle_armor_decode_final_func) name##_decode_final, \
230 extern const struct nettle_armor nettle_base64
;
231 extern const struct nettle_armor nettle_base16
;
233 #endif /* NETTLE_META_H_INCLUDED */