32 #if defined(POLARSSL_CIPHER_C)
36 #if defined(POLARSSL_AES_C)
40 #if defined(POLARSSL_CAMELLIA_C)
44 #if defined(POLARSSL_DES_C)
48 #if defined(POLARSSL_BLOWFISH_C)
55 static void polarssl_zeroize(
void *v,
size_t n ) {
56 volatile unsigned char *p = v;
while( n-- ) *p++ = 0;
59 #if defined(POLARSSL_AES_C)
61 static int aes_crypt_cbc_wrap(
void *ctx,
operation_t operation,
size_t length,
62 unsigned char *iv,
const unsigned char *input,
unsigned char *output )
67 static int aes_crypt_cfb128_wrap(
void *ctx,
operation_t operation,
size_t length,
68 size_t *iv_off,
unsigned char *iv,
const unsigned char *input,
unsigned char *output )
70 #if defined(POLARSSL_CIPHER_MODE_CFB)
85 static int aes_crypt_ctr_wrap(
void *ctx,
size_t length,
86 size_t *nc_off,
unsigned char *nonce_counter,
unsigned char *stream_block,
87 const unsigned char *input,
unsigned char *output )
89 #if defined(POLARSSL_CIPHER_MODE_CTR)
91 stream_block, input, output );
96 ((void) nonce_counter);
97 ((void) stream_block);
105 static int aes_setkey_dec_wrap(
void *ctx,
const unsigned char *key,
unsigned int key_length )
110 static int aes_setkey_enc_wrap(
void *ctx,
const unsigned char *key,
unsigned int key_length )
115 static void * aes_ctx_alloc(
void )
120 static void aes_ctx_free(
void *ctx )
129 aes_crypt_cfb128_wrap,
167 #if defined(POLARSSL_CIPHER_MODE_CFB)
199 #if defined(POLARSSL_CIPHER_MODE_CTR)
233 #if defined(POLARSSL_CAMELLIA_C)
235 static int camellia_crypt_cbc_wrap(
void *ctx,
operation_t operation,
size_t length,
236 unsigned char *iv,
const unsigned char *input,
unsigned char *output )
241 static int camellia_crypt_cfb128_wrap(
void *ctx,
operation_t operation,
size_t length,
242 size_t *iv_off,
unsigned char *iv,
const unsigned char *input,
unsigned char *output )
244 #if defined(POLARSSL_CIPHER_MODE_CFB)
259 static int camellia_crypt_ctr_wrap(
void *ctx,
size_t length,
260 size_t *nc_off,
unsigned char *nonce_counter,
unsigned char *stream_block,
261 const unsigned char *input,
unsigned char *output )
263 #if defined(POLARSSL_CIPHER_MODE_CTR)
265 stream_block, input, output );
270 ((void) nonce_counter);
271 ((void) stream_block);
279 static int camellia_setkey_dec_wrap(
void *ctx,
const unsigned char *key,
unsigned int key_length )
284 static int camellia_setkey_enc_wrap(
void *ctx,
const unsigned char *key,
unsigned int key_length )
289 static void * camellia_ctx_alloc(
void )
294 static void camellia_ctx_free(
void *ctx )
302 camellia_crypt_cbc_wrap,
303 camellia_crypt_cfb128_wrap,
304 camellia_crypt_ctr_wrap,
305 camellia_setkey_enc_wrap,
306 camellia_setkey_dec_wrap,
341 #if defined(POLARSSL_CIPHER_MODE_CFB)
346 "CAMELLIA-128-CFB128",
356 "CAMELLIA-192-CFB128",
366 "CAMELLIA-256-CFB128",
373 #if defined(POLARSSL_CIPHER_MODE_CTR)
407 #if defined(POLARSSL_DES_C)
409 static int des_crypt_cbc_wrap(
void *ctx,
operation_t operation,
size_t length,
410 unsigned char *iv,
const unsigned char *input,
unsigned char *output )
415 static int des3_crypt_cbc_wrap(
void *ctx,
operation_t operation,
size_t length,
416 unsigned char *iv,
const unsigned char *input,
unsigned char *output )
421 static int des_crypt_cfb128_wrap(
void *ctx,
operation_t operation,
size_t length,
422 size_t *iv_off,
unsigned char *iv,
const unsigned char *input,
unsigned char *output )
435 static int des_crypt_ctr_wrap(
void *ctx,
size_t length,
436 size_t *nc_off,
unsigned char *nonce_counter,
unsigned char *stream_block,
437 const unsigned char *input,
unsigned char *output )
442 ((void) nonce_counter);
443 ((void) stream_block);
451 static int des_setkey_dec_wrap(
void *ctx,
const unsigned char *key,
unsigned int key_length )
458 static int des_setkey_enc_wrap(
void *ctx,
const unsigned char *key,
unsigned int key_length )
465 static int des3_set2key_dec_wrap(
void *ctx,
const unsigned char *key,
unsigned int key_length )
472 static int des3_set2key_enc_wrap(
void *ctx,
const unsigned char *key,
unsigned int key_length )
479 static int des3_set3key_dec_wrap(
void *ctx,
const unsigned char *key,
unsigned int key_length )
486 static int des3_set3key_enc_wrap(
void *ctx,
const unsigned char *key,
unsigned int key_length )
493 static void * des_ctx_alloc(
void )
498 static void * des3_ctx_alloc(
void )
503 static void des_ctx_free(
void *ctx )
509 static void des3_ctx_free(
void *ctx )
518 des_crypt_cfb128_wrap,
539 des_crypt_cfb128_wrap,
541 des3_set2key_enc_wrap,
542 des3_set2key_dec_wrap,
560 des_crypt_cfb128_wrap,
562 des3_set3key_enc_wrap,
563 des3_set3key_dec_wrap,
579 #if defined(POLARSSL_BLOWFISH_C)
581 static int blowfish_crypt_cbc_wrap(
void *ctx,
operation_t operation,
size_t length,
582 unsigned char *iv,
const unsigned char *input,
unsigned char *output )
587 static int blowfish_crypt_cfb64_wrap(
void *ctx,
operation_t operation,
size_t length,
588 size_t *iv_off,
unsigned char *iv,
const unsigned char *input,
unsigned char *output )
590 #if defined(POLARSSL_CIPHER_MODE_CFB)
605 static int blowfish_crypt_ctr_wrap(
void *ctx,
size_t length,
606 size_t *nc_off,
unsigned char *nonce_counter,
unsigned char *stream_block,
607 const unsigned char *input,
unsigned char *output )
609 #if defined(POLARSSL_CIPHER_MODE_CTR)
611 stream_block, input, output );
616 ((void) nonce_counter);
617 ((void) stream_block);
625 static int blowfish_setkey_dec_wrap(
void *ctx,
const unsigned char *key,
unsigned int key_length )
630 static int blowfish_setkey_enc_wrap(
void *ctx,
const unsigned char *key,
unsigned int key_length )
635 static void * blowfish_ctx_alloc(
void )
640 static void blowfish_ctx_free(
void *ctx )
648 blowfish_crypt_cbc_wrap,
649 blowfish_crypt_cfb64_wrap,
650 blowfish_crypt_ctr_wrap,
651 blowfish_setkey_enc_wrap,
652 blowfish_setkey_dec_wrap,
667 #if defined(POLARSSL_CIPHER_MODE_CFB)
679 #if defined(POLARSSL_CIPHER_MODE_CTR)
692 #if defined(POLARSSL_CIPHER_NULL_CIPHER)
693 static void * null_ctx_alloc(
void )
699 static void null_ctx_free(
void *ctx )
const cipher_info_t blowfish_ctr_info
int blowfish_setkey(blowfish_context *ctx, const unsigned char *key, unsigned int keysize)
Blowfish key schedule.
const cipher_info_t blowfish_cbc_info
#define POLARSSL_ERR_CIPHER_FEATURE_UNAVAILABLE
The selected feature is not available.
const cipher_info_t camellia_192_ctr_info
const cipher_info_t aes_128_ctr_info
const cipher_info_t camellia_192_cbc_info
Key length, in bits (including parity), for DES keys.
const cipher_info_t aes_256_ctr_info
int camellia_crypt_cbc(camellia_context *ctx, int mode, size_t length, unsigned char iv[16], const unsigned char *input, unsigned char *output)
CAMELLIA-CBC buffer encryption/decryption Length should be a multiple of the block size (16 bytes) ...
int aes_crypt_cfb128(aes_context *ctx, int mode, size_t length, size_t *iv_off, unsigned char iv[16], const unsigned char *input, unsigned char *output)
AES-CFB128 buffer encryption/decryption.
const cipher_info_t aes_128_cfb128_info
const cipher_info_t des_cbc_info
Configuration options (set of defines)
const cipher_info_t aes_256_cbc_info
int aes_setkey_dec(aes_context *ctx, const unsigned char *key, unsigned int keysize)
AES key schedule (decryption)
const cipher_info_t camellia_256_ctr_info
int camellia_setkey_enc(camellia_context *ctx, const unsigned char *key, unsigned int keysize)
CAMELLIA key schedule (encryption)
int camellia_crypt_ctr(camellia_context *ctx, size_t length, size_t *nc_off, unsigned char nonce_counter[16], unsigned char stream_block[16], const unsigned char *input, unsigned char *output)
CAMELLIA-CTR buffer encryption/decryption.
const cipher_info_t aes_192_ctr_info
const cipher_info_t camellia_128_ctr_info
const cipher_info_t blowfish_cfb64_info
const cipher_info_t des_ede3_cbc_info
int camellia_crypt_cfb128(camellia_context *ctx, int mode, size_t length, size_t *iv_off, unsigned char iv[16], const unsigned char *input, unsigned char *output)
CAMELLIA-CFB128 buffer encryption/decryption.
int des3_set3key_enc(des3_context *ctx, const unsigned char key[DES_KEY_SIZE *3])
Triple-DES key schedule (168-bit, encryption)
int des3_set3key_dec(des3_context *ctx, const unsigned char key[DES_KEY_SIZE *3])
Triple-DES key schedule (168-bit, decryption)
const cipher_info_t aes_128_cbc_info
const cipher_info_t des_ede_cbc_info
Triple-DES context structure.
int des3_set2key_enc(des3_context *ctx, const unsigned char key[DES_KEY_SIZE *2])
Triple-DES key schedule (112-bit, encryption)
int aes_crypt_cbc(aes_context *ctx, int mode, size_t length, unsigned char iv[16], const unsigned char *input, unsigned char *output)
AES-CBC buffer encryption/decryption Length should be a multiple of the block size (16 bytes) ...
Key length, in bits (including parity), for DES in three-key EDE.
const cipher_info_t camellia_256_cfb128_info
const cipher_info_t camellia_256_cbc_info
CAMELLIA context structure.
const cipher_info_t camellia_128_cbc_info
const cipher_info_t aes_192_cbc_info
int des_crypt_cbc(des_context *ctx, int mode, size_t length, unsigned char iv[8], const unsigned char *input, unsigned char *output)
DES-CBC buffer encryption/decryption.
int camellia_setkey_dec(camellia_context *ctx, const unsigned char *key, unsigned int keysize)
CAMELLIA key schedule (decryption)
int des_setkey_enc(des_context *ctx, const unsigned char key[DES_KEY_SIZE])
DES key schedule (56-bit, encryption)
const cipher_info_t aes_256_cfb128_info
int des_setkey_dec(des_context *ctx, const unsigned char key[DES_KEY_SIZE])
DES key schedule (56-bit, decryption)
const cipher_info_t aes_192_cfb128_info
int blowfish_crypt_ctr(blowfish_context *ctx, size_t length, size_t *nc_off, unsigned char nonce_counter[BLOWFISH_BLOCKSIZE], unsigned char stream_block[BLOWFISH_BLOCKSIZE], const unsigned char *input, unsigned char *output)
Blowfish-CTR buffer encryption/decryption.
int blowfish_crypt_cfb64(blowfish_context *ctx, int mode, size_t length, size_t *iv_off, unsigned char iv[BLOWFISH_BLOCKSIZE], const unsigned char *input, unsigned char *output)
Blowfish CFB buffer encryption/decryption.
Blowfish context structure.
const cipher_info_t camellia_192_cfb128_info
int aes_setkey_enc(aes_context *ctx, const unsigned char *key, unsigned int keysize)
AES key schedule (encryption)
Key length, in bits (including parity), for DES in two key EDE.
int aes_crypt_ctr(aes_context *ctx, size_t length, size_t *nc_off, unsigned char nonce_counter[16], unsigned char stream_block[16], const unsigned char *input, unsigned char *output)
AES-CTR buffer encryption/decryption.
int blowfish_crypt_cbc(blowfish_context *ctx, int mode, size_t length, unsigned char iv[BLOWFISH_BLOCKSIZE], const unsigned char *input, unsigned char *output)
Blowfish-CBC buffer encryption/decryption Length should be a multiple of the block size (8 bytes) ...
const cipher_info_t camellia_128_cfb128_info
int des3_set2key_dec(des3_context *ctx, const unsigned char key[DES_KEY_SIZE *2])
Triple-DES key schedule (112-bit, decryption)
int des3_crypt_cbc(des3_context *ctx, int mode, size_t length, unsigned char iv[8], const unsigned char *input, unsigned char *output)
3DES-CBC buffer encryption/decryption