mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2024-12-24 00:55:36 +00:00
Implement two-valued handle type
This commit is contained in:
parent
020d9ba4ed
commit
f8b7c7f0ac
|
@ -126,9 +126,16 @@ typedef struct mbedtls_pk_debug_item
|
|||
/**
|
||||
* \brief Public key information and operations
|
||||
*/
|
||||
#if defined(MBEDTLS_PK_SINGLE_TYPE)
|
||||
typedef enum {
|
||||
MBEDTLS_PK_INVALID_HANDLE,
|
||||
MBEDTLS_PK_UNIQUE_VALID_HANDLE,
|
||||
} mbedtls_pk_handle_t;
|
||||
#else /* MBEDTLS_PK_SINGLE_TYPE */
|
||||
typedef struct mbedtls_pk_info_t mbedtls_pk_info_t;
|
||||
typedef const mbedtls_pk_info_t *mbedtls_pk_handle_t;
|
||||
#define MBEDTLS_PK_INVALID_HANDLE ( (mbedtls_pk_handle_t) NULL )
|
||||
#endif /* MBEDTLS_PK_SINGLE_TYPE */
|
||||
|
||||
/**
|
||||
* \brief Public key container
|
||||
|
|
|
@ -242,6 +242,7 @@ typedef struct
|
|||
} mbedtls_rsa_alt_context;
|
||||
#endif
|
||||
|
||||
#if !defined(MBEDTLS_PK_SINGLE_TYPE)
|
||||
#if defined(MBEDTLS_RSA_C)
|
||||
extern const mbedtls_pk_info_t mbedtls_rsa_info;
|
||||
#endif
|
||||
|
@ -262,5 +263,6 @@ extern const mbedtls_pk_info_t mbedtls_uecc_eckey_info;
|
|||
#if defined(MBEDTLS_PK_RSA_ALT_SUPPORT)
|
||||
extern const mbedtls_pk_info_t mbedtls_rsa_alt_info;
|
||||
#endif
|
||||
#endif /* MBEDTLS_PK_SINGLE_TYPE */
|
||||
|
||||
#endif /* MBEDTLS_PK_WRAP_H */
|
||||
|
|
11
library/pk.c
11
library/pk.c
|
@ -745,8 +745,10 @@ static void uecc_eckey_free_wrap( void *ctx )
|
|||
mbedtls_free( ctx );
|
||||
}
|
||||
|
||||
#if !defined(MBEDTLS_PK_SINGLE_TYPE)
|
||||
const mbedtls_pk_info_t mbedtls_uecc_eckey_info =
|
||||
MBEDTLS_PK_INFO( MBEDTLS_PK_INFO_ECKEY );
|
||||
#endif
|
||||
#endif /* MBEDTLS_USE_TINYCRYPT */
|
||||
|
||||
/*
|
||||
|
@ -1349,6 +1351,14 @@ void mbedtls_pk_restart_free( mbedtls_pk_restart_ctx *ctx )
|
|||
*/
|
||||
mbedtls_pk_handle_t mbedtls_pk_info_from_type( mbedtls_pk_type_t pk_type )
|
||||
{
|
||||
#if defined(MBEDTLS_PK_SINGLE_TYPE)
|
||||
if( pk_type == MBEDTLS_PK_INFO_TYPE( MBEDTLS_PK_SINGLE_TYPE ) )
|
||||
return( MBEDTLS_PK_UNIQUE_VALID_HANDLE );
|
||||
|
||||
return( MBEDTLS_PK_INVALID_HANDLE );
|
||||
|
||||
#else /* MBEDTLS_PK_SINGLE_TYPE */
|
||||
|
||||
switch( pk_type ) {
|
||||
#if defined(MBEDTLS_RSA_C)
|
||||
case MBEDTLS_PK_RSA:
|
||||
|
@ -1375,6 +1385,7 @@ mbedtls_pk_handle_t mbedtls_pk_info_from_type( mbedtls_pk_type_t pk_type )
|
|||
default:
|
||||
return( NULL );
|
||||
}
|
||||
#endif /* MBEDTLS_PK_SINGLE_TYPE */
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
Loading…
Reference in a new issue