Add mbedtls_platform_memmove() as a secured memcmp()
Signed-off-by: Piotr Nowicki <piotr.nowicki@arm.com>
diff --git a/library/nist_kw.c b/library/nist_kw.c
index 0ad270a..5b5aa1c 100644
--- a/library/nist_kw.c
+++ b/library/nist_kw.c
@@ -222,7 +222,10 @@
}
mbedtls_platform_memcpy( output, NIST_KW_ICV1, KW_SEMIBLOCK_LENGTH );
- memmove( output + KW_SEMIBLOCK_LENGTH, input, in_len );
+ if( 0 != mbedtls_platform_memmove( output + KW_SEMIBLOCK_LENGTH, input, in_len ) )
+ {
+ return MBEDTLS_ERR_CIPHER_ALLOC_FAILED;
+ }
}
else
{
@@ -343,7 +346,11 @@
}
mbedtls_platform_memcpy( A, input, KW_SEMIBLOCK_LENGTH );
- memmove( output, input + KW_SEMIBLOCK_LENGTH, ( semiblocks - 1 ) * KW_SEMIBLOCK_LENGTH );
+ if( 0 != mbedtls_platform_memmove( output, input + KW_SEMIBLOCK_LENGTH,
+ ( semiblocks - 1 ) * KW_SEMIBLOCK_LENGTH ) )
+ {
+ return( MBEDTLS_ERR_CIPHER_ALLOC_FAILED );
+ }
/* Calculate intermediate values */
for( t = s; t >= 1; t-- )