mirror of
https://github.com/yuzu-mirror/mbedtls.git
synced 2026-04-20 22:05:15 +00:00
Introduce MD handle type
As has been previously done for ciphersuites, this commit introduces a zero-cost abstraction layer around the type mbedtls_md_info const * whose valid values represent implementations of message digest algorithms. Access to a particular digest implementation can be requested by name or digest ID through the API mbedtls_md_info_from_xxx(), which either returns a valid implementation or NULL, representing failure. This commit replaces such uses of `mbedtls_md_info const *` by an abstract type `mbedtls_md_handle_t` whose valid values represent digest implementations, and which has a designated invalid value MBEDTLS_MD_INVALID_HANDLE. The purpose of this abstraction layer is to pave the way for builds which support precisely one digest algorithm. In this case, mbedtls_md_handle_t can be implemented as a two-valued type, with one value representing the invalid handle, and the unique valid value representing the unique enabled digest.
This commit is contained in:
parent
505be8be4d
commit
a5cedbcd3f
30 changed files with 247 additions and 177 deletions
|
|
@ -102,12 +102,12 @@ static int build_transforms( mbedtls_ssl_transform *t_in,
|
|||
if( cipher_info->mode == MBEDTLS_MODE_CBC ||
|
||||
cipher_info->mode == MBEDTLS_MODE_STREAM )
|
||||
{
|
||||
mbedtls_md_info_t const *md_info;
|
||||
mbedtls_md_handle_t md_info;
|
||||
unsigned char *md0, *md1;
|
||||
|
||||
/* Pick hash */
|
||||
md_info = mbedtls_md_info_from_type( hash_id );
|
||||
CHK( md_info != NULL );
|
||||
CHK( md_info != MBEDTLS_MD_INVALID_HANDLE );
|
||||
|
||||
/* Pick hash keys */
|
||||
maclen = mbedtls_md_get_size( md_info );
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue