30 #ifndef POLARSSL_CIPHER_H
31 #define POLARSSL_CIPHER_H
35 #if defined(_MSC_VER) && !defined(inline)
36 #define inline _inline
38 #if defined(__ARMCC_VERSION) && !defined(inline)
39 #define inline __inline
43 #define POLARSSL_ERR_CIPHER_FEATURE_UNAVAILABLE -0x6080
44 #define POLARSSL_ERR_CIPHER_BAD_INPUT_DATA -0x6100
45 #define POLARSSL_ERR_CIPHER_ALLOC_FAILED -0x6180
46 #define POLARSSL_ERR_CIPHER_INVALID_PADDING -0x6200
47 #define POLARSSL_ERR_CIPHER_FULL_BLOCK_EXPECTED -0x6280
125 int (*cbc_func)(
void *ctx,
operation_t mode,
size_t length,
unsigned char *iv,
126 const unsigned char *input,
unsigned char *output );
129 int (*cfb_func)(
void *ctx,
operation_t mode,
size_t length,
size_t *iv_off,
130 unsigned char *iv,
const unsigned char *input,
unsigned char *output );
133 int (*ctr_func)(
void *ctx,
size_t length,
size_t *nc_off,
unsigned char *nonce_counter,
134 unsigned char *stream_block,
const unsigned char *input,
unsigned char *output );
137 int (*setkey_enc_func)(
void *ctx,
const unsigned char *key,
unsigned int key_length);
140 int (*setkey_dec_func)(
void *ctx,
const unsigned char *key,
unsigned int key_length);
143 void * (*ctx_alloc_func)( void );
146 void (*ctx_free_func)(
void *ctx );
430 unsigned char *output,
size_t *olen );
int key_length
Key length to use.
int cipher_finish(cipher_context_t *ctx, unsigned char *output, size_t *olen)
Generic cipher finalisation function.
static int cipher_get_iv_size(const cipher_context_t *ctx)
Returns the size of the cipher's IV.
Key length, in bits (including parity), for DES keys.
cipher_type_t type
Full cipher identifier (e.g.
static cipher_mode_t cipher_get_cipher_mode(const cipher_context_t *ctx)
Returns the mode of operation for the cipher.
const cipher_info_t * cipher_info_from_type(const cipher_type_t cipher_type)
Returns the cipher information structure associated with the given cipher type.
static unsigned int cipher_get_block_size(const cipher_context_t *ctx)
Returns the block size of the given cipher.
const cipher_info_t * cipher_info_from_string(const char *cipher_name)
Returns the cipher information structure associated with the given cipher name.
static const char * cipher_get_name(const cipher_context_t *ctx)
Returns the name of the given cipher, as a string.
static cipher_type_t cipher_get_type(const cipher_context_t *ctx)
Returns the type of the given cipher.
const cipher_info_t * cipher_info
Information about the associated cipher.
operation_t operation
Operation that the context's key has been initialised for.
size_t unprocessed_len
Number of bytes that still need processing.
int cipher_free_ctx(cipher_context_t *ctx)
Free the cipher-specific context of ctx.
unsigned int key_length
Cipher key length, in bits (default length for variable sized ciphers) (Includes parity bits for ciph...
int cipher_update(cipher_context_t *ctx, const unsigned char *input, size_t ilen, unsigned char *output, size_t *olen)
Generic cipher update function.
Key length, in bits (including parity), for DES in three-key EDE.
const char * name
Name of the cipher.
Maximum length of any IV, in bytes.
int cipher_reset(cipher_context_t *ctx, const unsigned char *iv)
Reset the given context, setting the IV to iv.
cipher_id_t cipher
Base Cipher type (e.g.
cipher_mode_t mode
Cipher mode (e.g.
static operation_t cipher_get_operation(const cipher_context_t *ctx)
Returns the operation of the given cipher.
int cipher_init_ctx(cipher_context_t *ctx, const cipher_info_t *cipher_info)
Initialises and fills the cipher context structure with the appropriate values.
int cipher_setkey(cipher_context_t *ctx, const unsigned char *key, int key_length, const operation_t operation)
Set the key to use with the given context.
const cipher_base_t * base
Base cipher information and functions.
const int * cipher_list(void)
Returns the list of ciphers supported by the generic cipher module.
unsigned int block_size
block size, in bytes
void * cipher_ctx
Cipher-specific context.
static int cipher_get_key_size(const cipher_context_t *ctx)
Returns the key length of the cipher.
int cipher_self_test(int verbose)
Checkup routine.
unsigned int iv_size
IV size, in bytes.
Key length, in bits (including parity), for DES in two key EDE.