2 * Copyright (C) 1998, 2002, 2003, 2009 Free Software Foundation, Inc.
4 * This file is part of Libgcrypt.
6 * Libgcrypt is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU Lesser general Public License as
8 * published by the Free Software Foundation; either version 2.1 of
9 * the License, or (at your option) any later version.
11 * Libgcrypt is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
23 #include "gcrypt-int.h"
25 #define DBG_CIPHER _gcry_get_debug_flag( 1 )
27 #include "../random/random.h"
29 #define PUBKEY_FLAG_NO_BLINDING (1 << 0)
30 #define PUBKEY_FLAG_RFC6979 (1 << 1)
31 #define PUBKEY_FLAG_FIXEDLEN (1 << 2)
32 #define PUBKEY_FLAG_LEGACYRESULT (1 << 3)
33 #define PUBKEY_FLAG_RAW_FLAG (1 << 4)
34 #define PUBKEY_FLAG_TRANSIENT_KEY (1 << 5)
35 #define PUBKEY_FLAG_USE_X931 (1 << 6)
36 #define PUBKEY_FLAG_USE_FIPS186 (1 << 7)
37 #define PUBKEY_FLAG_USE_FIPS186_2 (1 << 8)
38 #define PUBKEY_FLAG_PARAM (1 << 9)
39 #define PUBKEY_FLAG_COMP (1 << 10)
40 #define PUBKEY_FLAG_NOCOMP (1 << 11)
41 #define PUBKEY_FLAG_EDDSA (1 << 12)
42 #define PUBKEY_FLAG_GOST (1 << 13)
62 struct pk_encoding_ctx
67 enum pk_encoding encoding;
79 int (* verify_cmp) (void *opaque, gcry_mpi_t tmp);
83 #define CIPHER_INFO_NO_WEAK_KEY 1
85 #include "cipher-proto.h"
87 /* The internal encryption modes. */
88 enum gcry_cipher_internal_modes
90 GCRY_CIPHER_MODE_INTERNAL = 0x10000,
91 GCRY_CIPHER_MODE_CMAC = 0x10000 + 1 /* Cipher-based MAC. */
96 gcry_err_code_t _gcry_cipher_open_internal (gcry_cipher_hd_t *handle,
100 /*-- cipher-cmac.c --*/
101 gcry_err_code_t _gcry_cipher_cmac_authenticate
102 /* */ (gcry_cipher_hd_t c, const unsigned char *abuf, size_t abuflen);
103 gcry_err_code_t _gcry_cipher_cmac_get_tag
104 /* */ (gcry_cipher_hd_t c,
105 unsigned char *outtag, size_t taglen);
106 gcry_err_code_t _gcry_cipher_cmac_check_tag
107 /* */ (gcry_cipher_hd_t c,
108 const unsigned char *intag, size_t taglen);
109 gcry_err_code_t _gcry_cipher_cmac_set_subkeys
110 /* */ (gcry_cipher_hd_t c);
113 void _gcry_rmd160_hash_buffer (void *outbuf,
114 const void *buffer, size_t length);
116 void _gcry_sha1_hash_buffer (void *outbuf,
117 const void *buffer, size_t length);
118 void _gcry_sha1_hash_buffers (void *outbuf,
119 const gcry_buffer_t *iov, int iovcnt);
122 void _gcry_aes_cfb_enc (void *context, unsigned char *iv,
123 void *outbuf, const void *inbuf,
125 void _gcry_aes_cfb_dec (void *context, unsigned char *iv,
126 void *outbuf_arg, const void *inbuf_arg,
128 void _gcry_aes_cbc_enc (void *context, unsigned char *iv,
129 void *outbuf_arg, const void *inbuf_arg,
130 size_t nblocks, int cbc_mac);
131 void _gcry_aes_cbc_dec (void *context, unsigned char *iv,
132 void *outbuf_arg, const void *inbuf_arg,
134 void _gcry_aes_ctr_enc (void *context, unsigned char *ctr,
135 void *outbuf_arg, const void *inbuf_arg,
139 void _gcry_blowfish_cfb_dec (void *context, unsigned char *iv,
140 void *outbuf_arg, const void *inbuf_arg,
143 void _gcry_blowfish_cbc_dec (void *context, unsigned char *iv,
144 void *outbuf_arg, const void *inbuf_arg,
147 void _gcry_blowfish_ctr_enc (void *context, unsigned char *ctr,
148 void *outbuf_arg, const void *inbuf_arg,
152 void _gcry_cast5_cfb_dec (void *context, unsigned char *iv,
153 void *outbuf_arg, const void *inbuf_arg,
156 void _gcry_cast5_cbc_dec (void *context, unsigned char *iv,
157 void *outbuf_arg, const void *inbuf_arg,
160 void _gcry_cast5_ctr_enc (void *context, unsigned char *ctr,
161 void *outbuf_arg, const void *inbuf_arg,
164 /*-- camellia-glue.c --*/
165 void _gcry_camellia_ctr_enc (void *context, unsigned char *ctr,
166 void *outbuf_arg, const void *inbuf_arg,
168 void _gcry_camellia_cbc_dec (void *context, unsigned char *iv,
169 void *outbuf_arg, const void *inbuf_arg,
171 void _gcry_camellia_cfb_dec (void *context, unsigned char *iv,
172 void *outbuf_arg, const void *inbuf_arg,
176 void _gcry_serpent_ctr_enc (void *context, unsigned char *ctr,
177 void *outbuf_arg, const void *inbuf_arg,
179 void _gcry_serpent_cbc_dec (void *context, unsigned char *iv,
180 void *outbuf_arg, const void *inbuf_arg,
182 void _gcry_serpent_cfb_dec (void *context, unsigned char *iv,
183 void *outbuf_arg, const void *inbuf_arg,
187 void _gcry_twofish_ctr_enc (void *context, unsigned char *ctr,
188 void *outbuf_arg, const void *inbuf_arg,
190 void _gcry_twofish_cbc_dec (void *context, unsigned char *iv,
191 void *outbuf_arg, const void *inbuf_arg,
193 void _gcry_twofish_cfb_dec (void *context, unsigned char *iv,
194 void *outbuf_arg, const void *inbuf_arg,
198 void _gcry_register_pk_dsa_progress (gcry_handler_progress_t cbc, void *cb_data);
201 void _gcry_register_pk_elg_progress (gcry_handler_progress_t cb,
206 void _gcry_register_pk_ecc_progress (gcry_handler_progress_t cbc,
211 void _gcry_register_primegen_progress (gcry_handler_progress_t cb,
216 /* Declarations for the cipher specifications. */
217 extern gcry_cipher_spec_t _gcry_cipher_spec_blowfish;
218 extern gcry_cipher_spec_t _gcry_cipher_spec_des;
219 extern gcry_cipher_spec_t _gcry_cipher_spec_tripledes;
220 extern gcry_cipher_spec_t _gcry_cipher_spec_arcfour;
221 extern gcry_cipher_spec_t _gcry_cipher_spec_cast5;
222 extern gcry_cipher_spec_t _gcry_cipher_spec_aes;
223 extern gcry_cipher_spec_t _gcry_cipher_spec_aes192;
224 extern gcry_cipher_spec_t _gcry_cipher_spec_aes256;
225 extern gcry_cipher_spec_t _gcry_cipher_spec_twofish;
226 extern gcry_cipher_spec_t _gcry_cipher_spec_twofish128;
227 extern gcry_cipher_spec_t _gcry_cipher_spec_serpent128;
228 extern gcry_cipher_spec_t _gcry_cipher_spec_serpent192;
229 extern gcry_cipher_spec_t _gcry_cipher_spec_serpent256;
230 extern gcry_cipher_spec_t _gcry_cipher_spec_rfc2268_40;
231 extern gcry_cipher_spec_t _gcry_cipher_spec_rfc2268_128;
232 extern gcry_cipher_spec_t _gcry_cipher_spec_seed;
233 extern gcry_cipher_spec_t _gcry_cipher_spec_camellia128;
234 extern gcry_cipher_spec_t _gcry_cipher_spec_camellia192;
235 extern gcry_cipher_spec_t _gcry_cipher_spec_camellia256;
236 extern gcry_cipher_spec_t _gcry_cipher_spec_idea;
237 extern gcry_cipher_spec_t _gcry_cipher_spec_salsa20;
238 extern gcry_cipher_spec_t _gcry_cipher_spec_salsa20r12;
239 extern gcry_cipher_spec_t _gcry_cipher_spec_gost28147;
241 /* Declarations for the digest specifications. */
242 extern gcry_md_spec_t _gcry_digest_spec_crc32;
243 extern gcry_md_spec_t _gcry_digest_spec_crc32_rfc1510;
244 extern gcry_md_spec_t _gcry_digest_spec_crc24_rfc2440;
245 extern gcry_md_spec_t _gcry_digest_spec_gost3411_94;
246 extern gcry_md_spec_t _gcry_digest_spec_stribog_256;
247 extern gcry_md_spec_t _gcry_digest_spec_stribog_512;
248 extern gcry_md_spec_t _gcry_digest_spec_md4;
249 extern gcry_md_spec_t _gcry_digest_spec_md5;
250 extern gcry_md_spec_t _gcry_digest_spec_rmd160;
251 extern gcry_md_spec_t _gcry_digest_spec_sha1;
252 extern gcry_md_spec_t _gcry_digest_spec_sha224;
253 extern gcry_md_spec_t _gcry_digest_spec_sha256;
254 extern gcry_md_spec_t _gcry_digest_spec_sha512;
255 extern gcry_md_spec_t _gcry_digest_spec_sha384;
256 extern gcry_md_spec_t _gcry_digest_spec_tiger;
257 extern gcry_md_spec_t _gcry_digest_spec_tiger1;
258 extern gcry_md_spec_t _gcry_digest_spec_tiger2;
259 extern gcry_md_spec_t _gcry_digest_spec_whirlpool;
261 /* Declarations for the pubkey cipher specifications. */
262 extern gcry_pk_spec_t _gcry_pubkey_spec_rsa;
263 extern gcry_pk_spec_t _gcry_pubkey_spec_elg;
264 extern gcry_pk_spec_t _gcry_pubkey_spec_elg_e;
265 extern gcry_pk_spec_t _gcry_pubkey_spec_dsa;
266 extern gcry_pk_spec_t _gcry_pubkey_spec_ecc;
269 #endif /*G10_CIPHER_H*/