olen parameter shall contain the length of the buffer.
For SHA-3 families, it must be at least 28, 32, 48 or 64, depending on the family. Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es>
This commit is contained in:
parent
e6b8c83c7a
commit
1f3ae1639d
2 changed files with 13 additions and 7 deletions
|
@ -145,9 +145,9 @@ int mbedtls_sha3_update( mbedtls_sha3_context *ctx,
|
|||
* and have a hash operation started.
|
||||
* \param output The SHA-3 checksum result.
|
||||
* This must be a writable buffer of length \c olen bytes.
|
||||
* \param olen Defines a variable output length (in bytes). \c output must be
|
||||
* \c olen bytes length. For SHA-3 224, SHA-3 256, SHA-3 384 and
|
||||
* SHA-3 512 must equal to 28, 32, 48 and 64, respectively.
|
||||
* \param olen Defines the length of output buffer (in bytes). For SHA-3 224, SHA-3 256,
|
||||
* SHA-3 384 and SHA-3 512 \c olen must equal to 28, 32, 48 and 64,
|
||||
* respectively.
|
||||
*
|
||||
* \return \c 0 on success.
|
||||
* \return A negative error code on failure.
|
||||
|
@ -171,8 +171,9 @@ int mbedtls_sha3_finish( mbedtls_sha3_context *ctx,
|
|||
* \param ilen The length of the input data in Bytes.
|
||||
* \param output The SHA-3 checksum result.
|
||||
* This must be a writable buffer of length \c olen bytes.
|
||||
* \param olen Determines the length (in bytes) of the output. \c output
|
||||
* must be \c olen bytes length.
|
||||
* \param olen Defines the length of output buffer (in bytes). For SHA-3 224, SHA-3 256,
|
||||
* SHA-3 384 and SHA-3 512 \c olen must equal to 28, 32, 48 and 64,
|
||||
* respectively.
|
||||
*
|
||||
* \return \c 0 on success.
|
||||
* \return A negative error code on failure.
|
||||
|
|
|
@ -244,8 +244,13 @@ int mbedtls_sha3_finish( mbedtls_sha3_context *ctx,
|
|||
if( ctx == NULL || output == NULL )
|
||||
return( MBEDTLS_ERR_SHA3_BAD_INPUT_DATA );
|
||||
|
||||
if( ctx->olen > 0 && ctx->olen != olen )
|
||||
return( MBEDTLS_ERR_SHA3_BAD_INPUT_DATA );
|
||||
/* Catch SHA-3 families, with fixed output length */
|
||||
if( ctx->olen > 0 )
|
||||
{
|
||||
if ( ctx->olen > olen )
|
||||
return( MBEDTLS_ERR_SHA3_BAD_INPUT_DATA );
|
||||
olen = ctx->olen;
|
||||
}
|
||||
|
||||
ABSORB( ctx, ctx->index, ctx->xor_byte );
|
||||
ABSORB( ctx, ctx->max_block_size - 1, 0x80 );
|
||||
|
|
Loading…
Reference in a new issue