Make pk_info_t opaque

This commit is contained in:
Manuel Pégourié-Gonnard 2015-03-31 14:43:19 +02:00
parent 8c8be1ebbb
commit c89d6cf77c
3 changed files with 54 additions and 52 deletions

View File

@ -35,7 +35,8 @@ New deprecations
* ssl_set_bio() is deprecated in favor of ssl_set_bio_timeout(). * ssl_set_bio() is deprecated in favor of ssl_set_bio_timeout().
Semi-API changes (technically public, morally private) 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. * 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

View File

@ -136,57 +136,7 @@ typedef struct
/** /**
* \brief Public key information and operations * \brief Public key information and operations
*/ */
typedef struct typedef struct _pk_info_t 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 );
} pk_info_t;
/** /**
* \brief Public key container * \brief Public key container

View File

@ -33,6 +33,57 @@
#include "pk.h" #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) #if defined(POLARSSL_PK_RSA_ALT_SUPPORT)
/* Container for RSA-alt */ /* Container for RSA-alt */
typedef struct typedef struct