Make struct cipher_base_t opaque
This commit is contained in:
parent
3a3ae3d47e
commit
5a74e8bf19
3 changed files with 58 additions and 52 deletions
|
@ -65,6 +65,7 @@ New deprecations
|
||||||
Semi-API changes (technically public, morally private)
|
Semi-API changes (technically public, morally private)
|
||||||
* Changed md_info_t into an opaque structure (use md_get_xxx() accessors).
|
* Changed md_info_t into an opaque structure (use md_get_xxx() accessors).
|
||||||
* Changed pk_info_t into an opaque structure.
|
* Changed pk_info_t into an opaque structure.
|
||||||
|
* Change cipher_base_t into an opaque structure.
|
||||||
* Remove sig_oid2 and rename sig_oid1 to sig_oid in x509_crt and x509_crl.
|
* Remove sig_oid2 and rename sig_oid1 to sig_oid in x509_crt and x509_crl.
|
||||||
* x509_crt.key_usage changed from unsigned char to unsigned int.
|
* x509_crt.key_usage changed from unsigned char to unsigned int.
|
||||||
* Remove r and s from ecdsa_context
|
* Remove r and s from ecdsa_context
|
||||||
|
|
|
@ -175,59 +175,9 @@ enum {
|
||||||
#define MBEDTLS_MAX_BLOCK_LENGTH 16
|
#define MBEDTLS_MAX_BLOCK_LENGTH 16
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Base cipher information. The non-mode specific functions and values.
|
* Base cipher information (opaque struct).
|
||||||
*/
|
*/
|
||||||
typedef struct {
|
typedef struct mbedtls_cipher_base_t mbedtls_cipher_base_t;
|
||||||
|
|
||||||
/** Base Cipher type (e.g. MBEDTLS_CIPHER_ID_AES) */
|
|
||||||
mbedtls_cipher_id_t cipher;
|
|
||||||
|
|
||||||
/** Encrypt using ECB */
|
|
||||||
int (*ecb_func)( void *ctx, mbedtls_operation_t mode,
|
|
||||||
const unsigned char *input, unsigned char *output );
|
|
||||||
|
|
||||||
#if defined(MBEDTLS_CIPHER_MODE_CBC)
|
|
||||||
/** Encrypt using CBC */
|
|
||||||
int (*cbc_func)( void *ctx, mbedtls_operation_t mode, size_t length,
|
|
||||||
unsigned char *iv, const unsigned char *input,
|
|
||||||
unsigned char *output );
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(MBEDTLS_CIPHER_MODE_CFB)
|
|
||||||
/** Encrypt using CFB (Full length) */
|
|
||||||
int (*cfb_func)( void *ctx, mbedtls_operation_t mode, size_t length, size_t *iv_off,
|
|
||||||
unsigned char *iv, const unsigned char *input,
|
|
||||||
unsigned char *output );
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(MBEDTLS_CIPHER_MODE_CTR)
|
|
||||||
/** Encrypt using CTR */
|
|
||||||
int (*ctr_func)( void *ctx, size_t length, size_t *nc_off,
|
|
||||||
unsigned char *nonce_counter, unsigned char *stream_block,
|
|
||||||
const unsigned char *input, unsigned char *output );
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(MBEDTLS_CIPHER_MODE_STREAM)
|
|
||||||
/** Encrypt using STREAM */
|
|
||||||
int (*stream_func)( void *ctx, size_t length,
|
|
||||||
const unsigned char *input, unsigned char *output );
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/** Set key for encryption purposes */
|
|
||||||
int (*setkey_enc_func)( void *ctx, const unsigned char *key,
|
|
||||||
unsigned int key_length );
|
|
||||||
|
|
||||||
/** Set key for decryption purposes */
|
|
||||||
int (*setkey_dec_func)( void *ctx, const unsigned char *key,
|
|
||||||
unsigned int key_length);
|
|
||||||
|
|
||||||
/** Allocate a new context */
|
|
||||||
void * (*ctx_alloc_func)( void );
|
|
||||||
|
|
||||||
/** Free the given context */
|
|
||||||
void (*ctx_free_func)( void *ctx );
|
|
||||||
|
|
||||||
} mbedtls_cipher_base_t;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Cipher information. Allows cipher functions to be called in a generic way.
|
* Cipher information. Allows cipher functions to be called in a generic way.
|
||||||
|
|
|
@ -38,6 +38,61 @@
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Base cipher information. The non-mode specific functions and values.
|
||||||
|
*/
|
||||||
|
struct mbedtls_cipher_base_t
|
||||||
|
{
|
||||||
|
/** Base Cipher type (e.g. MBEDTLS_CIPHER_ID_AES) */
|
||||||
|
mbedtls_cipher_id_t cipher;
|
||||||
|
|
||||||
|
/** Encrypt using ECB */
|
||||||
|
int (*ecb_func)( void *ctx, mbedtls_operation_t mode,
|
||||||
|
const unsigned char *input, unsigned char *output );
|
||||||
|
|
||||||
|
#if defined(MBEDTLS_CIPHER_MODE_CBC)
|
||||||
|
/** Encrypt using CBC */
|
||||||
|
int (*cbc_func)( void *ctx, mbedtls_operation_t mode, size_t length,
|
||||||
|
unsigned char *iv, const unsigned char *input,
|
||||||
|
unsigned char *output );
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(MBEDTLS_CIPHER_MODE_CFB)
|
||||||
|
/** Encrypt using CFB (Full length) */
|
||||||
|
int (*cfb_func)( void *ctx, mbedtls_operation_t mode, size_t length, size_t *iv_off,
|
||||||
|
unsigned char *iv, const unsigned char *input,
|
||||||
|
unsigned char *output );
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(MBEDTLS_CIPHER_MODE_CTR)
|
||||||
|
/** Encrypt using CTR */
|
||||||
|
int (*ctr_func)( void *ctx, size_t length, size_t *nc_off,
|
||||||
|
unsigned char *nonce_counter, unsigned char *stream_block,
|
||||||
|
const unsigned char *input, unsigned char *output );
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(MBEDTLS_CIPHER_MODE_STREAM)
|
||||||
|
/** Encrypt using STREAM */
|
||||||
|
int (*stream_func)( void *ctx, size_t length,
|
||||||
|
const unsigned char *input, unsigned char *output );
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/** Set key for encryption purposes */
|
||||||
|
int (*setkey_enc_func)( void *ctx, const unsigned char *key,
|
||||||
|
unsigned int key_length );
|
||||||
|
|
||||||
|
/** Set key for decryption purposes */
|
||||||
|
int (*setkey_dec_func)( void *ctx, const unsigned char *key,
|
||||||
|
unsigned int key_length);
|
||||||
|
|
||||||
|
/** Allocate a new context */
|
||||||
|
void * (*ctx_alloc_func)( void );
|
||||||
|
|
||||||
|
/** Free the given context */
|
||||||
|
void (*ctx_free_func)( void *ctx );
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
mbedtls_cipher_type_t type;
|
mbedtls_cipher_type_t type;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue