Permalink
Browse files

Reinit sign context in soter tests

When we verify signature (even incorrect one), usually the internal hash/digest
context is finalised and cannot be reused. OpenSSL is one exception: by default
it creates an internal copy of the digest context and finalises the copy, so the
original context can be reused, but it is not a generic case. Since Themis may
have other cryptobackends, update the test to cover more generic cases, where
internal hash context cannot be reused.
  • Loading branch information...
secumod committed Aug 29, 2018
1 parent 8203353 commit 0d2301835f0896c6954d1fb4bee1db69620ba51d
Showing with 18 additions and 3 deletions.
  1. +18 −3 tests/soter/soter_sign_test.c
@@ -262,9 +262,6 @@ static void soter_sign_api_test()
signature[signature_length / 2]++;
testsuite_fail_unless(SOTER_INVALID_SIGNATURE == soter_verify_final(sign_ctx, signature, signature_length), "soter_verify_final: invalid signature value");
signature[signature_length / 2]--;
testsuite_fail_unless(SOTER_SUCCESS == soter_verify_final(sign_ctx, signature, signature_length), "soter_verify_final: normal flow");
testsuite_fail_unless(SOTER_INVALID_PARAMETER == soter_verify_destroy(NULL), "soter_verify_destroy: invalid context");
res = soter_verify_destroy(sign_ctx);
if (SOTER_SUCCESS != res)
@@ -295,6 +292,24 @@ static void soter_sign_api_test()
testsuite_fail_unless(SOTER_INVALID_SIGNATURE == soter_verify_final(sign_ctx, signature, signature_length), "soter_verify_final: wrong signed message");
soter_verify_destroy(sign_ctx);
sign_ctx = soter_verify_create(SOTER_SIGN_ecdsa_none_pkcs8, NULL, 0, pub, pub_length);
if (!sign_ctx)
{
testsuite_fail_if(true, "soter_verify_create failed");
return;
}
res = soter_verify_update(sign_ctx, message, message_length);
if (SOTER_SUCCESS != res)
{
testsuite_fail_if(true, "soter_verify_update failed");
soter_verify_destroy(sign_ctx);
return;
}
testsuite_fail_unless(SOTER_SUCCESS == soter_verify_final(sign_ctx, signature, signature_length), "soter_verify_final: normal flow");
soter_verify_destroy(sign_ctx);
}
void run_soter_sign_test(){

0 comments on commit 0d23018

Please sign in to comment.