mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2024-11-26 19:55:36 +01:00
PKCS11: Rename mbedtls_pk_xxx functions
Rename mbedtls_pk_setup_pkcs11 and mbedtls_pk_import_to_pkcs11 to reflect the proper namespace they are in.
This commit is contained in:
parent
33f566541c
commit
12603548fd
@ -75,7 +75,7 @@ extern "C" {
|
|||||||
* exception, it's ok to call mbedtls_pk_free() itself
|
* exception, it's ok to call mbedtls_pk_free() itself
|
||||||
* even if the Cryptoki handles have become invalid.
|
* even if the Cryptoki handles have become invalid.
|
||||||
*/
|
*/
|
||||||
int mbedtls_pk_setup_pkcs11( mbedtls_pk_context *ctx,
|
int mbedtls_pkcs11_setup_pk( mbedtls_pk_context *ctx,
|
||||||
CK_SESSION_HANDLE hSession,
|
CK_SESSION_HANDLE hSession,
|
||||||
CK_OBJECT_HANDLE hPublicKey,
|
CK_OBJECT_HANDLE hPublicKey,
|
||||||
CK_OBJECT_HANDLE hPrivateKey );
|
CK_OBJECT_HANDLE hPrivateKey );
|
||||||
@ -140,7 +140,7 @@ int mbedtls_pk_setup_pkcs11( mbedtls_pk_context *ctx,
|
|||||||
* also failed, for example because the token was
|
* also failed, for example because the token was
|
||||||
* disconnected.
|
* disconnected.
|
||||||
*/
|
*/
|
||||||
int mbedtls_pk_import_to_pkcs11( const mbedtls_pk_context *ctx,
|
int mbedtls_pkcs11_import_pk( const mbedtls_pk_context *ctx,
|
||||||
uint32_t flags,
|
uint32_t flags,
|
||||||
CK_SESSION_HANDLE hSession,
|
CK_SESSION_HANDLE hSession,
|
||||||
CK_OBJECT_HANDLE *hPublicKey,
|
CK_OBJECT_HANDLE *hPublicKey,
|
||||||
|
@ -327,7 +327,7 @@ static const mbedtls_pk_info_t mbedtls_pk_pkcs11_info =
|
|||||||
, NULL //debug_func
|
, NULL //debug_func
|
||||||
);
|
);
|
||||||
|
|
||||||
int mbedtls_pk_setup_pkcs11( mbedtls_pk_context *ctx,
|
int mbedtls_pkcs11_setup_pk( mbedtls_pk_context *ctx,
|
||||||
CK_SESSION_HANDLE hSession,
|
CK_SESSION_HANDLE hSession,
|
||||||
CK_OBJECT_HANDLE hPublicKey,
|
CK_OBJECT_HANDLE hPublicKey,
|
||||||
CK_OBJECT_HANDLE hPrivateKey )
|
CK_OBJECT_HANDLE hPrivateKey )
|
||||||
@ -438,7 +438,7 @@ static int mpi_to_ck( const mbedtls_mpi *mpi,
|
|||||||
|
|
||||||
#define MBEDTLS_PKCS11_BOOL( x ) ( ( x ) ? CK_TRUE : CK_FALSE )
|
#define MBEDTLS_PKCS11_BOOL( x ) ( ( x ) ? CK_TRUE : CK_FALSE )
|
||||||
|
|
||||||
int mbedtls_pk_import_to_pkcs11( const mbedtls_pk_context *ctx,
|
int mbedtls_pkcs11_import_pk( const mbedtls_pk_context *ctx,
|
||||||
uint32_t flags,
|
uint32_t flags,
|
||||||
CK_SESSION_HANDLE hSession,
|
CK_SESSION_HANDLE hSession,
|
||||||
CK_OBJECT_HANDLE *hPublicKey,
|
CK_OBJECT_HANDLE *hPublicKey,
|
||||||
|
@ -189,7 +189,7 @@ void pk_generate_sign( int key_type )
|
|||||||
/* Prepare the mbed TLS contexts */
|
/* Prepare the mbed TLS contexts */
|
||||||
TEST_ASSERT( mbedtls_pk_setup( &transparent_ctx,
|
TEST_ASSERT( mbedtls_pk_setup( &transparent_ctx,
|
||||||
mbedtls_pk_info_from_type( key_type ) ) == 0 );
|
mbedtls_pk_info_from_type( key_type ) ) == 0 );
|
||||||
TEST_ASSERT( mbedtls_pk_setup_pkcs11( &pkcs11_ctx,
|
TEST_ASSERT( mbedtls_pkcs11_setup_pk( &pkcs11_ctx,
|
||||||
hSession,
|
hSession,
|
||||||
hPublicKey,
|
hPublicKey,
|
||||||
hPrivateKey ) == 0 );
|
hPrivateKey ) == 0 );
|
||||||
@ -288,20 +288,20 @@ void pk_import_sign( char *file )
|
|||||||
hSession = pkcs11_init( );
|
hSession = pkcs11_init( );
|
||||||
TEST_ASSERT( hSession != CK_INVALID_HANDLE );
|
TEST_ASSERT( hSession != CK_INVALID_HANDLE );
|
||||||
|
|
||||||
TEST_ASSERT( mbedtls_pk_import_to_pkcs11( &transparent_ctx,
|
TEST_ASSERT( mbedtls_pkcs11_import_pk ( &transparent_ctx,
|
||||||
MBEDTLS_PK_FLAG_SIGN |
|
MBEDTLS_PKCS11_FLAG_SIGN |
|
||||||
MBEDTLS_PK_FLAG_VERIFY,
|
MBEDTLS_PKCS11_FLAG_VERIFY,
|
||||||
hSession,
|
hSession,
|
||||||
&hPublicKey,
|
&hPublicKey,
|
||||||
&hPrivateKey ) == 0 );
|
&hPrivateKey ) == 0 );
|
||||||
TEST_ASSERT( hPublicKey != CK_INVALID_HANDLE );
|
TEST_ASSERT( hPublicKey != CK_INVALID_HANDLE );
|
||||||
TEST_ASSERT( hPrivateKey != CK_INVALID_HANDLE );
|
TEST_ASSERT( hPrivateKey != CK_INVALID_HANDLE );
|
||||||
TEST_ASSERT( mbedtls_pk_setup_pkcs11( &pkcs11_ctx,
|
TEST_ASSERT( mbedtls_pkcs11_setup_pk( &pkcs11_ctx,
|
||||||
hSession,
|
hSession,
|
||||||
hPublicKey,
|
hPublicKey,
|
||||||
hPrivateKey ) == 0 );
|
hPrivateKey ) == 0 );
|
||||||
|
|
||||||
/* Sign with the token and verify in software */
|
/* Sign with cryptoki and verify with mbedTLS */
|
||||||
TEST_ASSERT( sizeof( sig_buffer ) >= mbedtls_pk_signature_size( &pkcs11_ctx ) );
|
TEST_ASSERT( sizeof( sig_buffer ) >= mbedtls_pk_signature_size( &pkcs11_ctx ) );
|
||||||
TEST_ASSERT( mbedtls_pk_sign( &pkcs11_ctx, MBEDTLS_MD_SHA256,
|
TEST_ASSERT( mbedtls_pk_sign( &pkcs11_ctx, MBEDTLS_MD_SHA256,
|
||||||
hash_value, 32,
|
hash_value, 32,
|
||||||
@ -348,20 +348,20 @@ void pk_import_sign_verify( char *file )
|
|||||||
hSession = pkcs11_init( );
|
hSession = pkcs11_init( );
|
||||||
TEST_ASSERT( hSession != CK_INVALID_HANDLE );
|
TEST_ASSERT( hSession != CK_INVALID_HANDLE );
|
||||||
|
|
||||||
TEST_ASSERT( mbedtls_pk_import_to_pkcs11( &transparent_ctx,
|
TEST_ASSERT( mbedtls_pkcs11_import_pk ( &transparent_ctx,
|
||||||
MBEDTLS_PK_FLAG_SIGN |
|
MBEDTLS_PKCS11_FLAG_SIGN |
|
||||||
MBEDTLS_PK_FLAG_VERIFY,
|
MBEDTLS_PKCS11_FLAG_VERIFY,
|
||||||
hSession,
|
hSession,
|
||||||
&hPublicKey,
|
&hPublicKey,
|
||||||
&hPrivateKey ) == 0 );
|
&hPrivateKey ) == 0 );
|
||||||
TEST_ASSERT( hPublicKey != CK_INVALID_HANDLE );
|
TEST_ASSERT( hPublicKey != CK_INVALID_HANDLE );
|
||||||
TEST_ASSERT( hPrivateKey != CK_INVALID_HANDLE );
|
TEST_ASSERT( hPrivateKey != CK_INVALID_HANDLE );
|
||||||
TEST_ASSERT( mbedtls_pk_setup_pkcs11( &pkcs11_ctx,
|
TEST_ASSERT( mbedtls_pkcs11_setup_pk( &pkcs11_ctx,
|
||||||
hSession,
|
hSession,
|
||||||
hPublicKey,
|
hPublicKey,
|
||||||
hPrivateKey ) == 0 );
|
hPrivateKey ) == 0 );
|
||||||
|
|
||||||
/* Sign with the token and verify with cryptoki */
|
/* Sign with cryptoki and verify with cryptoki */
|
||||||
TEST_ASSERT( sizeof( sig_buffer ) >= mbedtls_pk_signature_size( &pkcs11_ctx ) );
|
TEST_ASSERT( sizeof( sig_buffer ) >= mbedtls_pk_signature_size( &pkcs11_ctx ) );
|
||||||
TEST_ASSERT( mbedtls_pk_sign( &pkcs11_ctx, MBEDTLS_MD_SHA256,
|
TEST_ASSERT( mbedtls_pk_sign( &pkcs11_ctx, MBEDTLS_MD_SHA256,
|
||||||
hash_value, 32,
|
hash_value, 32,
|
||||||
@ -407,19 +407,19 @@ void pk_import_verify_signed( char *file )
|
|||||||
hSession = pkcs11_init( );
|
hSession = pkcs11_init( );
|
||||||
TEST_ASSERT( hSession != CK_INVALID_HANDLE );
|
TEST_ASSERT( hSession != CK_INVALID_HANDLE );
|
||||||
|
|
||||||
TEST_ASSERT( mbedtls_pk_import_to_pkcs11( &transparent_ctx,
|
TEST_ASSERT( mbedtls_pkcs11_import_pk ( &transparent_ctx,
|
||||||
MBEDTLS_PK_FLAG_SIGN |
|
MBEDTLS_PKCS11_FLAG_SIGN |
|
||||||
MBEDTLS_PK_FLAG_VERIFY,
|
MBEDTLS_PKCS11_FLAG_VERIFY,
|
||||||
hSession,
|
hSession,
|
||||||
&hPublicKey,
|
&hPublicKey,
|
||||||
NULL ) == 0 );
|
NULL ) == 0 );
|
||||||
TEST_ASSERT( hPublicKey != CK_INVALID_HANDLE );
|
TEST_ASSERT( hPublicKey != CK_INVALID_HANDLE );
|
||||||
TEST_ASSERT( mbedtls_pk_setup_pkcs11( &pkcs11_ctx,
|
TEST_ASSERT( mbedtls_pkcs11_setup_pk( &pkcs11_ctx,
|
||||||
hSession,
|
hSession,
|
||||||
hPublicKey,
|
hPublicKey,
|
||||||
CK_INVALID_HANDLE ) == 0 );
|
CK_INVALID_HANDLE ) == 0 );
|
||||||
|
|
||||||
/* Sign with the token and verify with cryptoki */
|
/* Sign with mbed TLS and verify with cryptoki */
|
||||||
TEST_ASSERT( sizeof( sig_buffer ) >= mbedtls_pk_signature_size( &pkcs11_ctx ) );
|
TEST_ASSERT( sizeof( sig_buffer ) >= mbedtls_pk_signature_size( &pkcs11_ctx ) );
|
||||||
TEST_ASSERT( mbedtls_pk_sign( &transparent_ctx, MBEDTLS_MD_SHA256,
|
TEST_ASSERT( mbedtls_pk_sign( &transparent_ctx, MBEDTLS_MD_SHA256,
|
||||||
hash_value, 32,
|
hash_value, 32,
|
||||||
@ -476,14 +476,14 @@ void pk_ecdsa_hardcoded_verify( int type, int id, char *key_str,
|
|||||||
/* Initialize cryptoki and import the key into the token */
|
/* Initialize cryptoki and import the key into the token */
|
||||||
hSession = pkcs11_init( );
|
hSession = pkcs11_init( );
|
||||||
TEST_ASSERT( hSession != CK_INVALID_HANDLE );
|
TEST_ASSERT( hSession != CK_INVALID_HANDLE );
|
||||||
TEST_ASSERT( mbedtls_pk_import_to_pkcs11( &transparent_ctx,
|
TEST_ASSERT( mbedtls_pkcs11_import_pk ( &transparent_ctx,
|
||||||
MBEDTLS_PK_FLAG_SIGN |
|
MBEDTLS_PKCS11_FLAG_SIGN |
|
||||||
MBEDTLS_PK_FLAG_VERIFY,
|
MBEDTLS_PKCS11_FLAG_VERIFY,
|
||||||
hSession,
|
hSession,
|
||||||
&hPublicKey,
|
&hPublicKey,
|
||||||
NULL ) == 0 );
|
NULL ) == 0 );
|
||||||
TEST_ASSERT( hPublicKey != CK_INVALID_HANDLE );
|
TEST_ASSERT( hPublicKey != CK_INVALID_HANDLE );
|
||||||
TEST_ASSERT( mbedtls_pk_setup_pkcs11( &pkcs11_ctx,
|
TEST_ASSERT( mbedtls_pkcs11_setup_pk( &pkcs11_ctx,
|
||||||
hSession,
|
hSession,
|
||||||
hPublicKey,
|
hPublicKey,
|
||||||
CK_INVALID_HANDLE ) == 0 );
|
CK_INVALID_HANDLE ) == 0 );
|
||||||
|
Loading…
Reference in New Issue
Block a user