aboutsummaryrefslogtreecommitdiff
path: root/test_grasshopper.c
diff options
context:
space:
mode:
authorVitaly Chikunov <vt@altlinux.org>2018-07-25 10:49:38 +0300
committerVitaly Chikunov <vt@altlinux.org>2018-07-25 11:00:00 +0300
commit641223f4d077bfd41143420c852aabbef8ca7fdf (patch)
tree37325333c61b9f089686f34cade83459dc0b2153 /test_grasshopper.c
parentd44131cf7cae81da5bafb9cb1129b026b8cb0797 (diff)
downloadgost-engine-641223f4d077bfd41143420c852aabbef8ca7fdf.zip
gost-engine-641223f4d077bfd41143420c852aabbef8ca7fdf.tar.gz
gost-engine-641223f4d077bfd41143420c852aabbef8ca7fdf.tar.bz2
test_grasshopper: Warn if EVP_MD_meth_set_result_size is performed
Diffstat (limited to 'test_grasshopper.c')
-rw-r--r--test_grasshopper.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/test_grasshopper.c b/test_grasshopper.c
index 4ea195c..14252bc 100644
--- a/test_grasshopper.c
+++ b/test_grasshopper.c
@@ -23,7 +23,9 @@
}
#define cRED "\033[1;31m"
+#define cDRED "\033[0;31m"
#define cGREEN "\033[1;32m"
+#define cDGREEN "\033[0;32m"
#define cNORM "\033[m"
#define TEST_ASSERT(e) {if ((test = (e))) \
printf(cRED "Test FAILED\n" cNORM); \
@@ -240,10 +242,11 @@ static int test_omac()
/* preload cbc cipher for omac set key */
EVP_add_cipher(cipher_gost_grasshopper_cbc());
T(EVP_DigestInit_ex(ctx, grasshopper_omac(), NULL));
- if (EVP_MD_CTX_size(ctx) != 8) {
+ if (EVP_MD_CTX_size(ctx) != sizeof(mac)) {
/* strip const out of EVP_MD_CTX_md() to
* overwrite output size, as test vector is 8 bytes */
- T(EVP_MD_meth_set_result_size((EVP_MD *)EVP_MD_CTX_md(ctx), 8));
+ printf("Resize result size from %d to %zu\n", EVP_MD_CTX_size(ctx), sizeof(mac));
+ T(EVP_MD_meth_set_result_size((EVP_MD *)EVP_MD_CTX_md(ctx), sizeof(mac)));
}
T(EVP_MD_meth_get_ctrl(EVP_MD_CTX_md(ctx))(ctx, EVP_MD_CTRL_SET_KEY, sizeof(K), (void *)K));
T(EVP_DigestUpdate(ctx, P, sizeof(P)));
@@ -283,8 +286,8 @@ int main(int argc, char **argv)
ret |= test_omac();
if (ret)
- printf(cRED "= Some tests FAILED!\n" cNORM);
+ printf(cDRED "= Some tests FAILED!\n" cNORM);
else
- printf(cGREEN "= All tests passed!\n" cNORM);
+ printf(cDGREEN "= All tests passed!\n" cNORM);
return ret;
}