Add IV and block size getters for cipher_info

Signed-off-by: Max Fillinger <max@max-fillinger.net>
This commit is contained in:
Max Fillinger 2021-11-07 14:01:16 +01:00
parent 087f04783d
commit 3a782a0fe4

View file

@ -507,6 +507,41 @@ static inline const char *mbedtls_cipher_info_get_name(
return( info->MBEDTLS_PRIVATE(name) );
}
/**
* \brief This function returns the size of the IV or nonce
* for the cipher info structure, in bytes.
*
* \param info The cipher info structure. This may be \c NULL.
*
* \return The recommended IV size.
* \return \c 0 for ciphers not using an IV or a nonce.
*/
static inline int mbedtls_cipher_info_get_iv_size(
const mbedtls_cipher_info_t *info )
{
if( info == NULL )
return( 0 );
return( (int) info->MBEDTLS_PRIVATE(iv_size) );
}
/**
* \brief This function returns the block size of the given
* cipher info structure.
*
* \param info The cipher info structure. This may be \c NULL.
*
* \return The block size of the cipher.
*/
static inline unsigned int mbedtls_cipher_info_get_block_size(
const mbedtls_cipher_info_t *info )
{
if( info == NULL )
return( 0 );
return( info->MBEDTLS_PRIVATE(block_size) );
}
/**
* \brief This function initializes a \p cipher_context as NONE.
*