Source LMOTS data from hsslms
So it can be reproduced
Signed-off-by: Raef Coles <raef.coles@arm.com>
diff --git a/tests/suites/test_suite_lmots.function b/tests/suites/test_suite_lmots.function
index 4821ce5..27a74b6 100644
--- a/tests/suites/test_suite_lmots.function
+++ b/tests/suites/test_suite_lmots.function
@@ -76,7 +76,7 @@
/* BEGIN_CASE */
void lmots_verify_test ( data_t *msg, data_t *sig, data_t *pub_key,
- int expected_rc )
+ int expected_rc )
{
mbedtls_lmots_public_t ctx;
unsigned int size;
@@ -91,17 +91,20 @@
/* Test negative cases if the input data is valid */
if( expected_rc == 0 )
{
- /* Altering first message byte must cause verification failure */
- msg->x[0] ^= 1;
- TEST_EQUAL(mbedtls_lmots_verify( &ctx, msg->x, msg->len, sig->x, sig->len ),
- MBEDTLS_ERR_LMS_VERIFY_FAILED);
- msg->x[0] ^= 1;
+ if( msg->len >= 1 )
+ {
+ /* Altering first message byte must cause verification failure */
+ msg->x[0] ^= 1;
+ TEST_EQUAL(mbedtls_lmots_verify( &ctx, msg->x, msg->len, sig->x, sig->len ),
+ MBEDTLS_ERR_LMS_VERIFY_FAILED);
+ msg->x[0] ^= 1;
- /* Altering last message byte must cause verification failure */
- msg->x[msg->len - 1] ^= 1;
- TEST_EQUAL(mbedtls_lmots_verify( &ctx, msg->x, msg->len, sig->x, sig->len ),
- MBEDTLS_ERR_LMS_VERIFY_FAILED);
- msg->x[msg->len - 1] ^= 1;
+ /* Altering last message byte must cause verification failure */
+ msg->x[msg->len - 1] ^= 1;
+ TEST_EQUAL(mbedtls_lmots_verify( &ctx, msg->x, msg->len, sig->x, sig->len ),
+ MBEDTLS_ERR_LMS_VERIFY_FAILED);
+ msg->x[msg->len - 1] ^= 1;
+ }
/* Altering first signature byte must cause verification failure */
sig->x[0] ^= 1;