diff --git a/ChangeLog b/ChangeLog index 6fc5cfa99..8c5995c49 100644 --- a/ChangeLog +++ b/ChangeLog @@ -20,6 +20,9 @@ API Changes mbedtls_gcm_init() -> mbedtls_gcm_setkey() mbedtls_hmac_drbg_init() -> mbedtls_hmac_drbg_init(_buf)() mbedtls_ctr_drbg_init() -> mbedtls_ctr_drbg_init(_buf)() + * Renamed mbedtls_pkcs11_priv_key_init() to ..._bind() and + mbedtls_pkcs11_x509_cert_init() as well (handled by rename.pl and + compat-1.3.h) * mbedtls_memory_bufer_alloc_init() now returns void * In the threading layer, mbedtls_mutex_init() and mbedtls_mutex_free() now return void. diff --git a/include/mbedtls/compat-1.3.h b/include/mbedtls/compat-1.3.h index f63ef3d0b..10953dbe5 100644 --- a/include/mbedtls/compat-1.3.h +++ b/include/mbedtls/compat-1.3.h @@ -2256,9 +2256,9 @@ #define pkcs11_context mbedtls_pkcs11_context #define pkcs11_decrypt mbedtls_pkcs11_decrypt #define pkcs11_priv_key_free mbedtls_pkcs11_priv_key_free -#define pkcs11_priv_key_init mbedtls_pkcs11_priv_key_init +#define pkcs11_priv_key_init mbedtls_pkcs11_priv_key_bind #define pkcs11_sign mbedtls_pkcs11_sign -#define pkcs11_x509_cert_init mbedtls_pkcs11_x509_cert_init +#define pkcs11_x509_cert_init mbedtls_pkcs11_x509_cert_bind #define pkcs12_derivation mbedtls_pkcs12_derivation #define pkcs12_pbe mbedtls_pkcs12_pbe #define pkcs12_pbe_sha1_rc4_128 mbedtls_pkcs12_pbe_sha1_rc4_128 diff --git a/include/mbedtls/pkcs11.h b/include/mbedtls/pkcs11.h index a6bda05d4..5d4cc1fe5 100644 --- a/include/mbedtls/pkcs11.h +++ b/include/mbedtls/pkcs11.h @@ -58,6 +58,12 @@ typedef struct { int len; } mbedtls_pkcs11_context; +/** + * Initialize a mbetls_pkcs11_context. + * (Just making memory references valid.) + */ +void mbedtls_pkcs11_init( mbedtls_pkcs11_context *ctx ); + /** * Fill in a mbed TLS certificate, based on the given PKCS11 helper certificate. * @@ -66,10 +72,10 @@ typedef struct { * * \return 0 on success. */ -int mbedtls_pkcs11_x509_cert_init( mbedtls_x509_crt *cert, pkcs11h_certificate_t pkcs11h_cert ); +int mbedtls_pkcs11_x509_cert_bind( mbedtls_x509_crt *cert, pkcs11h_certificate_t pkcs11h_cert ); /** - * Initialise a mbedtls_pkcs11_context, storing the given certificate. Note that the + * Set up a mbedtls_pkcs11_context storing the given certificate. Note that the * mbedtls_pkcs11_context will take over control of the certificate, freeing it when * done. * @@ -78,7 +84,7 @@ int mbedtls_pkcs11_x509_cert_init( mbedtls_x509_crt *cert, pkcs11h_certificate_t * * \return 0 on success */ -int mbedtls_pkcs11_priv_key_init( mbedtls_pkcs11_context *priv_key, +int mbedtls_pkcs11_priv_key_bind( mbedtls_pkcs11_context *priv_key, pkcs11h_certificate_t pkcs11_cert ); /** diff --git a/library/pkcs11.c b/library/pkcs11.c index fff1d1eda..e2ad9890b 100644 --- a/library/pkcs11.c +++ b/library/pkcs11.c @@ -40,7 +40,12 @@ #define mbedtls_free free #endif -int mbedtls_pkcs11_x509_cert_init( mbedtls_x509_crt *cert, pkcs11h_certificate_t pkcs11_cert ) +void mbedtls_pkcs11_init( mbedtls_pkcs11_context *ctx ) +{ + memset( ctx, 0, sizeof( mbedtls_pkcs11_context ) ); +} + +int mbedtls_pkcs11_x509_cert_bind( mbedtls_x509_crt *cert, pkcs11h_certificate_t pkcs11_cert ) { int ret = 1; unsigned char *cert_blob = NULL; @@ -89,7 +94,7 @@ cleanup: } -int mbedtls_pkcs11_priv_key_init( mbedtls_pkcs11_context *priv_key, +int mbedtls_pkcs11_priv_key_bind( mbedtls_pkcs11_context *priv_key, pkcs11h_certificate_t pkcs11_cert ) { int ret = 1; diff --git a/scripts/data_files/rename-1.3-2.0.txt b/scripts/data_files/rename-1.3-2.0.txt index 05db8d4d5..06b56feb9 100644 --- a/scripts/data_files/rename-1.3-2.0.txt +++ b/scripts/data_files/rename-1.3-2.0.txt @@ -1782,9 +1782,9 @@ pk_write_pubkey_pem mbedtls_pk_write_pubkey_pem pkcs11_context mbedtls_pkcs11_context pkcs11_decrypt mbedtls_pkcs11_decrypt pkcs11_priv_key_free mbedtls_pkcs11_priv_key_free -pkcs11_priv_key_init mbedtls_pkcs11_priv_key_init +pkcs11_priv_key_init mbedtls_pkcs11_priv_key_bind pkcs11_sign mbedtls_pkcs11_sign -pkcs11_x509_cert_init mbedtls_pkcs11_x509_cert_init +pkcs11_x509_cert_init mbedtls_pkcs11_x509_cert_bind pkcs12_derivation mbedtls_pkcs12_derivation pkcs12_pbe mbedtls_pkcs12_pbe pkcs12_pbe_sha1_rc4_128 mbedtls_pkcs12_pbe_sha1_rc4_128