From c89d6cf77cb174d84eb37c5fa60050bc26675279 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20P=C3=A9gouri=C3=A9-Gonnard?= Date: Tue, 31 Mar 2015 14:43:19 +0200 Subject: [PATCH] Make pk_info_t opaque --- ChangeLog | 3 ++- include/mbedtls/pk.h | 52 +-------------------------------------- include/mbedtls/pk_wrap.h | 51 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 54 insertions(+), 52 deletions(-) diff --git a/ChangeLog b/ChangeLog index 206a3a825..76fb13f16 100644 --- a/ChangeLog +++ b/ChangeLog @@ -35,7 +35,8 @@ New deprecations * ssl_set_bio() is deprecated in favor of ssl_set_bio_timeout(). Semi-API changes (technically public, morally private) - * Change 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. * 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. * Remove r and s from ecdsa_context diff --git a/include/mbedtls/pk.h b/include/mbedtls/pk.h index 207d3542d..903f9e4e7 100644 --- a/include/mbedtls/pk.h +++ b/include/mbedtls/pk.h @@ -136,57 +136,7 @@ typedef struct /** * \brief Public key information and operations */ -typedef struct -{ - /** Public key type */ - pk_type_t type; - - /** Type name */ - const char *name; - - /** Get key size in bits */ - size_t (*get_size)( const void * ); - - /** Tell if the context implements this type (e.g. ECKEY can do ECDSA) */ - int (*can_do)( pk_type_t type ); - - /** Verify signature */ - int (*verify_func)( void *ctx, md_type_t md_alg, - const unsigned char *hash, size_t hash_len, - const unsigned char *sig, size_t sig_len ); - - /** Make signature */ - int (*sign_func)( void *ctx, md_type_t md_alg, - const unsigned char *hash, size_t hash_len, - unsigned char *sig, size_t *sig_len, - int (*f_rng)(void *, unsigned char *, size_t), - void *p_rng ); - - /** Decrypt message */ - int (*decrypt_func)( void *ctx, const unsigned char *input, size_t ilen, - unsigned char *output, size_t *olen, size_t osize, - int (*f_rng)(void *, unsigned char *, size_t), - void *p_rng ); - - /** Encrypt message */ - int (*encrypt_func)( void *ctx, const unsigned char *input, size_t ilen, - unsigned char *output, size_t *olen, size_t osize, - int (*f_rng)(void *, unsigned char *, size_t), - void *p_rng ); - - /** Check public-private key pair */ - int (*check_pair_func)( const void *pub, const void *prv ); - - /** Allocate a new context */ - void * (*ctx_alloc_func)( void ); - - /** Free the given context */ - void (*ctx_free_func)( void *ctx ); - - /** Interface with the debug module */ - void (*debug_func)( const void *ctx, pk_debug_item *items ); - -} pk_info_t; +typedef struct _pk_info_t pk_info_t; /** * \brief Public key container diff --git a/include/mbedtls/pk_wrap.h b/include/mbedtls/pk_wrap.h index 7a7f4fa01..7eb4f72b3 100644 --- a/include/mbedtls/pk_wrap.h +++ b/include/mbedtls/pk_wrap.h @@ -33,6 +33,57 @@ #include "pk.h" +struct _pk_info_t +{ + /** Public key type */ + pk_type_t type; + + /** Type name */ + const char *name; + + /** Get key size in bits */ + size_t (*get_size)( const void * ); + + /** Tell if the context implements this type (e.g. ECKEY can do ECDSA) */ + int (*can_do)( pk_type_t type ); + + /** Verify signature */ + int (*verify_func)( void *ctx, md_type_t md_alg, + const unsigned char *hash, size_t hash_len, + const unsigned char *sig, size_t sig_len ); + + /** Make signature */ + int (*sign_func)( void *ctx, md_type_t md_alg, + const unsigned char *hash, size_t hash_len, + unsigned char *sig, size_t *sig_len, + int (*f_rng)(void *, unsigned char *, size_t), + void *p_rng ); + + /** Decrypt message */ + int (*decrypt_func)( void *ctx, const unsigned char *input, size_t ilen, + unsigned char *output, size_t *olen, size_t osize, + int (*f_rng)(void *, unsigned char *, size_t), + void *p_rng ); + + /** Encrypt message */ + int (*encrypt_func)( void *ctx, const unsigned char *input, size_t ilen, + unsigned char *output, size_t *olen, size_t osize, + int (*f_rng)(void *, unsigned char *, size_t), + void *p_rng ); + + /** Check public-private key pair */ + int (*check_pair_func)( const void *pub, const void *prv ); + + /** Allocate a new context */ + void * (*ctx_alloc_func)( void ); + + /** Free the given context */ + void (*ctx_free_func)( void *ctx ); + + /** Interface with the debug module */ + void (*debug_func)( const void *ctx, pk_debug_item *items ); + +}; #if defined(POLARSSL_PK_RSA_ALT_SUPPORT) /* Container for RSA-alt */ typedef struct