mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2024-11-22 18:35:42 +01:00
Minor fixes to Camellia parameter validation
This commit is contained in:
parent
f10905a6a7
commit
e939de7247
@ -96,7 +96,7 @@ void mbedtls_camellia_free( mbedtls_camellia_context *ctx );
|
|||||||
*
|
*
|
||||||
* \param ctx The CAMELLIA context to use. This must be initialized.
|
* \param ctx The CAMELLIA context to use. This must be initialized.
|
||||||
* \param key The encryption key to use. This must be a readable buffer
|
* \param key The encryption key to use. This must be a readable buffer
|
||||||
* of size \p keybits bits.
|
* of size \p keybits Bits.
|
||||||
* \param keybits The length of \p key in Bits. This must be either \c 128,
|
* \param keybits The length of \p key in Bits. This must be either \c 128,
|
||||||
* \c 192 or \c 256.
|
* \c 192 or \c 256.
|
||||||
*
|
*
|
||||||
@ -112,7 +112,7 @@ int mbedtls_camellia_setkey_enc( mbedtls_camellia_context *ctx,
|
|||||||
*
|
*
|
||||||
* \param ctx The CAMELLIA context to use. This must be initialized.
|
* \param ctx The CAMELLIA context to use. This must be initialized.
|
||||||
* \param key The decryption key. This must be a readable buffer
|
* \param key The decryption key. This must be a readable buffer
|
||||||
* of size \p keybits bits.
|
* of size \p keybits Bits.
|
||||||
* \param keybits The length of \p key in Bits. This must be either \c 128,
|
* \param keybits The length of \p key in Bits. This must be either \c 128,
|
||||||
* \c 192 or \c 256.
|
* \c 192 or \c 256.
|
||||||
*
|
*
|
||||||
@ -157,7 +157,7 @@ int mbedtls_camellia_crypt_ecb( mbedtls_camellia_context *ctx,
|
|||||||
*
|
*
|
||||||
* \param ctx The CAMELLIA context to use. This must be initialized
|
* \param ctx The CAMELLIA context to use. This must be initialized
|
||||||
* and bound to a key.
|
* and bound to a key.
|
||||||
* \param mode The mode of operation. Possible values are
|
* \param mode The mode of operation. This must be either
|
||||||
* #MBEDTLS_CAMELLIA_ENCRYPT or #MBEDTLS_CAMELLIA_DECRYPT.
|
* #MBEDTLS_CAMELLIA_ENCRYPT or #MBEDTLS_CAMELLIA_DECRYPT.
|
||||||
* \param length The length in Bytes of the input data.
|
* \param length The length in Bytes of the input data.
|
||||||
* Must be a multiple of \c 16.
|
* Must be a multiple of \c 16.
|
||||||
@ -202,7 +202,7 @@ int mbedtls_camellia_crypt_cbc( mbedtls_camellia_context *ctx,
|
|||||||
*
|
*
|
||||||
* \param ctx The CAMELLIA context to use. This must be initialized
|
* \param ctx The CAMELLIA context to use. This must be initialized
|
||||||
* and bound to a key.
|
* and bound to a key.
|
||||||
* \param mode The mode of operation. Possible values are
|
* \param mode The mode of operation. This must be either
|
||||||
* #MBEDTLS_CAMELLIA_ENCRYPT or #MBEDTLS_CAMELLIA_DECRYPT.
|
* #MBEDTLS_CAMELLIA_ENCRYPT or #MBEDTLS_CAMELLIA_DECRYPT.
|
||||||
* \param length The length of the input data. Any value is allowed.
|
* \param length The length of the input data. Any value is allowed.
|
||||||
* \param iv_off The current offset in the IV. This must be smaller
|
* \param iv_off The current offset in the IV. This must be smaller
|
||||||
|
@ -12,6 +12,10 @@ void camellia_invalid_param( )
|
|||||||
{
|
{
|
||||||
mbedtls_camellia_context ctx;
|
mbedtls_camellia_context ctx;
|
||||||
unsigned char buf[16] = { 0 };
|
unsigned char buf[16] = { 0 };
|
||||||
|
const size_t valid_keybits = 128;
|
||||||
|
const size_t invalid_keybits = 42;
|
||||||
|
const int invalid_mode = 42;
|
||||||
|
const int valid_mode = MBEDTLS_CAMELLIA_ENCRYPT;
|
||||||
size_t off;
|
size_t off;
|
||||||
((void) off);
|
((void) off);
|
||||||
|
|
||||||
@ -21,70 +25,70 @@ void camellia_invalid_param( )
|
|||||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_CAMELLIA_BAD_INPUT_DATA,
|
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_CAMELLIA_BAD_INPUT_DATA,
|
||||||
mbedtls_camellia_setkey_enc( NULL,
|
mbedtls_camellia_setkey_enc( NULL,
|
||||||
buf,
|
buf,
|
||||||
128 ) );
|
valid_keybits ) );
|
||||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_CAMELLIA_BAD_INPUT_DATA,
|
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_CAMELLIA_BAD_INPUT_DATA,
|
||||||
mbedtls_camellia_setkey_enc( &ctx,
|
mbedtls_camellia_setkey_enc( &ctx,
|
||||||
NULL,
|
NULL,
|
||||||
128 ) );
|
valid_keybits ) );
|
||||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_CAMELLIA_BAD_INPUT_DATA,
|
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_CAMELLIA_BAD_INPUT_DATA,
|
||||||
mbedtls_camellia_setkey_enc( &ctx,
|
mbedtls_camellia_setkey_enc( &ctx,
|
||||||
buf,
|
buf,
|
||||||
42 ) );
|
invalid_keybits ) );
|
||||||
|
|
||||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_CAMELLIA_BAD_INPUT_DATA,
|
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_CAMELLIA_BAD_INPUT_DATA,
|
||||||
mbedtls_camellia_setkey_dec( NULL,
|
mbedtls_camellia_setkey_dec( NULL,
|
||||||
buf,
|
buf,
|
||||||
128 ) );
|
valid_keybits ) );
|
||||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_CAMELLIA_BAD_INPUT_DATA,
|
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_CAMELLIA_BAD_INPUT_DATA,
|
||||||
mbedtls_camellia_setkey_dec( &ctx,
|
mbedtls_camellia_setkey_dec( &ctx,
|
||||||
NULL,
|
NULL,
|
||||||
128 ) );
|
valid_keybits ) );
|
||||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_CAMELLIA_BAD_INPUT_DATA,
|
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_CAMELLIA_BAD_INPUT_DATA,
|
||||||
mbedtls_camellia_setkey_dec( &ctx,
|
mbedtls_camellia_setkey_dec( &ctx,
|
||||||
buf,
|
buf,
|
||||||
42 ) );
|
invalid_keybits ) );
|
||||||
|
|
||||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_CAMELLIA_BAD_INPUT_DATA,
|
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_CAMELLIA_BAD_INPUT_DATA,
|
||||||
mbedtls_camellia_crypt_ecb( NULL,
|
mbedtls_camellia_crypt_ecb( NULL,
|
||||||
MBEDTLS_CAMELLIA_ENCRYPT,
|
valid_mode,
|
||||||
buf, buf ) );
|
|
||||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_CAMELLIA_BAD_INPUT_DATA,
|
|
||||||
mbedtls_camellia_crypt_ecb( &ctx,
|
|
||||||
42,
|
|
||||||
buf, buf ) );
|
buf, buf ) );
|
||||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_CAMELLIA_BAD_INPUT_DATA,
|
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_CAMELLIA_BAD_INPUT_DATA,
|
||||||
mbedtls_camellia_crypt_ecb( &ctx,
|
mbedtls_camellia_crypt_ecb( &ctx,
|
||||||
MBEDTLS_CAMELLIA_ENCRYPT,
|
invalid_mode,
|
||||||
|
buf, buf ) );
|
||||||
|
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_CAMELLIA_BAD_INPUT_DATA,
|
||||||
|
mbedtls_camellia_crypt_ecb( &ctx,
|
||||||
|
valid_mode,
|
||||||
NULL, buf ) );
|
NULL, buf ) );
|
||||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_CAMELLIA_BAD_INPUT_DATA,
|
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_CAMELLIA_BAD_INPUT_DATA,
|
||||||
mbedtls_camellia_crypt_ecb( &ctx,
|
mbedtls_camellia_crypt_ecb( &ctx,
|
||||||
MBEDTLS_CAMELLIA_ENCRYPT,
|
valid_mode,
|
||||||
buf, NULL ) );
|
buf, NULL ) );
|
||||||
|
|
||||||
#if defined(MBEDTLS_CIPHER_MODE_CBC)
|
#if defined(MBEDTLS_CIPHER_MODE_CBC)
|
||||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_CAMELLIA_BAD_INPUT_DATA,
|
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_CAMELLIA_BAD_INPUT_DATA,
|
||||||
mbedtls_camellia_crypt_cbc( NULL,
|
mbedtls_camellia_crypt_cbc( NULL,
|
||||||
MBEDTLS_CAMELLIA_ENCRYPT,
|
valid_mode,
|
||||||
sizeof( buf ),
|
sizeof( buf ),
|
||||||
buf, buf, buf ) );
|
buf, buf, buf ) );
|
||||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_CAMELLIA_BAD_INPUT_DATA,
|
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_CAMELLIA_BAD_INPUT_DATA,
|
||||||
mbedtls_camellia_crypt_cbc( &ctx,
|
mbedtls_camellia_crypt_cbc( &ctx,
|
||||||
42,
|
invalid_mode,
|
||||||
sizeof( buf ),
|
sizeof( buf ),
|
||||||
buf, buf, buf ) );
|
buf, buf, buf ) );
|
||||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_CAMELLIA_BAD_INPUT_DATA,
|
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_CAMELLIA_BAD_INPUT_DATA,
|
||||||
mbedtls_camellia_crypt_cbc( &ctx,
|
mbedtls_camellia_crypt_cbc( &ctx,
|
||||||
MBEDTLS_CAMELLIA_ENCRYPT,
|
valid_mode,
|
||||||
sizeof( buf ),
|
sizeof( buf ),
|
||||||
NULL, buf, buf ) );
|
NULL, buf, buf ) );
|
||||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_CAMELLIA_BAD_INPUT_DATA,
|
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_CAMELLIA_BAD_INPUT_DATA,
|
||||||
mbedtls_camellia_crypt_cbc( &ctx,
|
mbedtls_camellia_crypt_cbc( &ctx,
|
||||||
MBEDTLS_CAMELLIA_ENCRYPT,
|
valid_mode,
|
||||||
sizeof( buf ),
|
sizeof( buf ),
|
||||||
buf, NULL, buf ) );
|
buf, NULL, buf ) );
|
||||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_CAMELLIA_BAD_INPUT_DATA,
|
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_CAMELLIA_BAD_INPUT_DATA,
|
||||||
mbedtls_camellia_crypt_cbc( &ctx,
|
mbedtls_camellia_crypt_cbc( &ctx,
|
||||||
MBEDTLS_CAMELLIA_ENCRYPT,
|
valid_mode,
|
||||||
sizeof( buf ),
|
sizeof( buf ),
|
||||||
buf, buf, NULL ) );
|
buf, buf, NULL ) );
|
||||||
#endif /* MBEDTLS_CIPHER_MODE_CBC */
|
#endif /* MBEDTLS_CIPHER_MODE_CBC */
|
||||||
@ -92,37 +96,37 @@ void camellia_invalid_param( )
|
|||||||
#if defined(MBEDTLS_CIPHER_MODE_CFB)
|
#if defined(MBEDTLS_CIPHER_MODE_CFB)
|
||||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_CAMELLIA_BAD_INPUT_DATA,
|
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_CAMELLIA_BAD_INPUT_DATA,
|
||||||
mbedtls_camellia_crypt_cfb128( NULL,
|
mbedtls_camellia_crypt_cfb128( NULL,
|
||||||
MBEDTLS_CAMELLIA_ENCRYPT,
|
valid_mode,
|
||||||
sizeof( buf ),
|
sizeof( buf ),
|
||||||
&off, buf,
|
&off, buf,
|
||||||
buf, buf ) );
|
buf, buf ) );
|
||||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_CAMELLIA_BAD_INPUT_DATA,
|
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_CAMELLIA_BAD_INPUT_DATA,
|
||||||
mbedtls_camellia_crypt_cfb128( &ctx,
|
mbedtls_camellia_crypt_cfb128( &ctx,
|
||||||
42,
|
invalid_mode,
|
||||||
sizeof( buf ),
|
sizeof( buf ),
|
||||||
&off, buf,
|
&off, buf,
|
||||||
buf, buf ) );
|
buf, buf ) );
|
||||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_CAMELLIA_BAD_INPUT_DATA,
|
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_CAMELLIA_BAD_INPUT_DATA,
|
||||||
mbedtls_camellia_crypt_cfb128( &ctx,
|
mbedtls_camellia_crypt_cfb128( &ctx,
|
||||||
MBEDTLS_CAMELLIA_ENCRYPT,
|
valid_mode,
|
||||||
sizeof( buf ),
|
sizeof( buf ),
|
||||||
NULL, buf,
|
NULL, buf,
|
||||||
buf, buf ) );
|
buf, buf ) );
|
||||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_CAMELLIA_BAD_INPUT_DATA,
|
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_CAMELLIA_BAD_INPUT_DATA,
|
||||||
mbedtls_camellia_crypt_cfb128( &ctx,
|
mbedtls_camellia_crypt_cfb128( &ctx,
|
||||||
MBEDTLS_CAMELLIA_ENCRYPT,
|
valid_mode,
|
||||||
sizeof( buf ),
|
sizeof( buf ),
|
||||||
&off, NULL,
|
&off, NULL,
|
||||||
buf, buf ) );
|
buf, buf ) );
|
||||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_CAMELLIA_BAD_INPUT_DATA,
|
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_CAMELLIA_BAD_INPUT_DATA,
|
||||||
mbedtls_camellia_crypt_cfb128( &ctx,
|
mbedtls_camellia_crypt_cfb128( &ctx,
|
||||||
MBEDTLS_CAMELLIA_ENCRYPT,
|
valid_mode,
|
||||||
sizeof( buf ),
|
sizeof( buf ),
|
||||||
&off, buf,
|
&off, buf,
|
||||||
NULL, buf ) );
|
NULL, buf ) );
|
||||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_CAMELLIA_BAD_INPUT_DATA,
|
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_CAMELLIA_BAD_INPUT_DATA,
|
||||||
mbedtls_camellia_crypt_cfb128( &ctx,
|
mbedtls_camellia_crypt_cfb128( &ctx,
|
||||||
MBEDTLS_CAMELLIA_ENCRYPT,
|
valid_mode,
|
||||||
sizeof( buf ),
|
sizeof( buf ),
|
||||||
&off, buf,
|
&off, buf,
|
||||||
buf, NULL ) );
|
buf, NULL ) );
|
||||||
|
Loading…
Reference in New Issue
Block a user