[PATCH] Limit digest checks to enabled algorithms

Dmitry Eremin-Solenikov dbaryshkov at gmail.com
Wed Mar 12 19:10:22 CET 2014


* tests/basic.c (check_digests): put #ifdef USE_xxx around checks to
  disable checks for algorithms being compiled out.

Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov at gmail.com>
---
The actual error was triggered by md2 algo which is disabled by default.
 tests/basic.c | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/tests/basic.c b/tests/basic.c
index 0eb0f77..ebfe5ee 100644
--- a/tests/basic.c
+++ b/tests/basic.c
@@ -3784,18 +3784,23 @@ check_digests (void)
     const char *expect;
   } algos[] =
     {
+#ifdef USE_MD2
       { GCRY_MD_MD2, "",
         "\x83\x50\xe5\xa3\xe2\x4c\x15\x3d\xf2\x27\x5c\x9f\x80\x69\x27\x73" },
       { GCRY_MD_MD2, "a",
         "\x32\xec\x01\xec\x4a\x6d\xac\x72\xc0\xab\x96\xfb\x34\xc0\xb5\xd1" },
       {	GCRY_MD_MD2, "message digest",
         "\xab\x4f\x49\x6b\xfb\x2a\x53\x0b\x21\x9f\xf3\x30\x31\xfe\x06\xb0" },
+#endif
+#ifdef USE_MD4
       { GCRY_MD_MD4, "",
 	"\x31\xD6\xCF\xE0\xD1\x6A\xE9\x31\xB7\x3C\x59\xD7\xE0\xC0\x89\xC0" },
       { GCRY_MD_MD4, "a",
 	"\xbd\xe5\x2c\xb3\x1d\xe3\x3e\x46\x24\x5e\x05\xfb\xdb\xd6\xfb\x24" },
       {	GCRY_MD_MD4, "message digest",
 	"\xd9\x13\x0a\x81\x64\x54\x9f\xe8\x18\x87\x48\x06\xe1\xc7\x01\x4b" },
+#endif
+#ifdef USE_MD5
       {	GCRY_MD_MD5, "",
 	"\xD4\x1D\x8C\xD9\x8F\x00\xB2\x04\xE9\x80\x09\x98\xEC\xF8\x42\x7E" },
       {	GCRY_MD_MD5, "a",
@@ -3804,6 +3809,8 @@ check_digests (void)
 	"\x90\x01\x50\x98\x3C\xD2\x4F\xB0\xD6\x96\x3F\x7D\x28\xE1\x7F\x72" },
       { GCRY_MD_MD5, "message digest",
 	"\xF9\x6B\x69\x7D\x7C\xB7\x93\x8D\x52\x5A\x2F\x31\xAA\xF1\x61\xD0" },
+#endif
+#ifdef USE_SHA1
       { GCRY_MD_SHA1, "abc",
 	"\xA9\x99\x3E\x36\x47\x06\x81\x6A\xBA\x3E"
 	"\x25\x71\x78\x50\xC2\x6C\x9C\xD0\xD8\x9D" },
@@ -3814,6 +3821,8 @@ check_digests (void)
       { GCRY_MD_SHA1, "!" /* kludge for "a"*1000000 */ ,
 	"\x34\xAA\x97\x3C\xD4\xC4\xDA\xA4\xF6\x1E"
 	"\xEB\x2B\xDB\xAD\x27\x31\x65\x34\x01\x6F" },
+#endif
+#ifdef USE_SHA256
       /* From RFC3874 */
       {	GCRY_MD_SHA224, "abc",
 	"\x23\x09\x7d\x22\x34\x05\xd8\x22\x86\x42\xa4\x77\xbd\xa2\x55\xb3"
@@ -3835,6 +3844,8 @@ check_digests (void)
       {	GCRY_MD_SHA256, "!",
 	"\xcd\xc7\x6e\x5c\x99\x14\xfb\x92\x81\xa1\xc7\xe2\x84\xd7\x3e\x67"
 	"\xf1\x80\x9a\x48\xa4\x97\x20\x0e\x04\x6d\x39\xcc\xc7\x11\x2c\xd0" },
+#endif
+#ifdef USE_SHA512
       {	GCRY_MD_SHA384, "abc",
 	"\xcb\x00\x75\x3f\x45\xa3\x5e\x8b\xb5\xa0\x3d\x69\x9a\xc6\x50\x07"
 	"\x27\x2c\x32\xab\x0e\xde\xd1\x63\x1a\x8b\x60\x5a\x43\xff\x5b\xed"
@@ -3844,6 +3855,8 @@ check_digests (void)
 	"\x12\xE6\xFA\x4E\x89\xA9\x7E\xA2\x0A\x9E\xEE\xE6\x4B\x55\xD3\x9A"
 	"\x21\x92\x99\x2A\x27\x4F\xC1\xA8\x36\xBA\x3C\x23\xA3\xFE\xEB\xBD"
 	"\x45\x4D\x44\x23\x64\x3C\xE8\x0E\x2A\x9A\xC9\x4F\xA5\x4C\xA4\x9F" },
+#endif
+#ifdef USE_RMD160
       {	GCRY_MD_RMD160, "",
 	"\x9c\x11\x85\xa5\xc5\xe9\xfc\x54\x61\x28"
 	"\x08\x97\x7e\xe8\xf5\x48\xb2\x25\x8d\x31" },
@@ -3856,6 +3869,8 @@ check_digests (void)
       {	GCRY_MD_RMD160, "message digest",
 	"\x5d\x06\x89\xef\x49\xd2\xfa\xe5\x72\xb8"
 	"\x81\xb1\x23\xa8\x5f\xfa\x21\x59\x5f\x36" },
+#endif
+#ifdef USE_CRC
       {	GCRY_MD_CRC32, "", "\x00\x00\x00\x00" },
       {	GCRY_MD_CRC32, "foo", "\x8c\x73\x65\x21" },
       { GCRY_MD_CRC32_RFC1510, "", "\x00\x00\x00\x00" },
@@ -3875,7 +3890,9 @@ check_digests (void)
 #endif
       {	GCRY_MD_CRC24_RFC2440, "", "\xb7\x04\xce" },
       {	GCRY_MD_CRC24_RFC2440, "foo", "\x4f\xc2\x55" },
+#endif
 
+#ifdef USE_TIGER
       {	GCRY_MD_TIGER, "",
 	"\x24\xF0\x13\x0C\x63\xAC\x93\x32\x16\x16\x6E\x76"
 	"\xB1\xBB\x92\x5F\xF3\x73\xDE\x2D\x49\x58\x4E\x7A" },
@@ -3978,7 +3995,9 @@ check_digests (void)
       {	GCRY_MD_TIGER2, "!",
         "\xE0\x68\x28\x1F\x06\x0F\x55\x16\x28\xCC\x57\x15"
         "\xB9\xD0\x22\x67\x96\x91\x4D\x45\xF7\x71\x7C\xF4" },
+#endif
 
+#ifdef USE_WHIRLPOOL
       { GCRY_MD_WHIRLPOOL, "",
 	"\x19\xFA\x61\xD7\x55\x22\xA4\x66\x9B\x44\xE3\x9C\x1D\x2E\x17\x26"
 	"\xC5\x30\x23\x21\x30\xD4\x07\xF8\x9A\xFE\xE0\x96\x49\x97\xF7\xA7"
@@ -4006,6 +4025,7 @@ check_digests (void)
         "\x29\x05\x7F\xD8\x6B\x20\xBF\xD6\x2D\xEC\xA0\xF1\xCC\xEA\x4A\xF5"
         "\x1F\xC1\x54\x90\xED\xDC\x47\xAF\x32\xBB\x2B\x66\xC3\x4F\xF9\xAD"
         "\x8C\x60\x08\xAD\x67\x7F\x77\x12\x69\x53\xB2\x26\xE4\xED\x8B\x01" },
+#endif
 #ifdef USE_GOST_R_3411_94
       { GCRY_MD_GOSTR3411_94,
 	"This is message, length=32 bytes",
-- 
1.9.0




More information about the Gcrypt-devel mailing list