File drbg_test-reseeding.patch of Package libgcrypt.665

diff -Nurp libgcrypt-1.6.1-orig//tests/drbg_test.c libgcrypt-1.6.1/tests/drbg_test.c
--- libgcrypt-1.6.1-orig//tests/drbg_test.c	2015-04-28 12:06:24.640128000 +0200
+++ libgcrypt-1.6.1/tests/drbg_test.c	2015-04-28 12:12:24.589770000 +0200
@@ -117,6 +117,12 @@ struct gcry_drbg_test_vector
 				    this value does not apply and the memcmp
 				    in drbg_cavs_test does not apply either*/
 	size_t expectedlen;	/* length of expected random value */
+
+	unsigned char *entropyreseed;
+	size_t entropyreseed_len;
+	unsigned char *addtl_reseed;
+	size_t addtl_reseed_len;
+
 };
 
 struct gcry_drbg_test_vector drbg_test_pr[] = {
@@ -924,6 +930,66 @@ struct gcry_drbg_test_vector drbg_test_n
 		"\x80\x08\xae\xe8\xe9\x69\x40\xc5\x08\x73\xc7\x9f" "\x8e\xcf\xe0\x02",
 		.perslen = 16,
 	},
+	{
+		.flags = DRBG_NOPR_HASHSHA1,
+		.entropy = (unsigned char *)
+		"\x16\x10\xb8\x28\xcc\xd2\x7d\xe0\x8c\xee\xa0\x32"
+		"\xa2\x0e\x92\x08\x49\x2c\xf1\x70\x92\x42\xf6\xb5",
+		.entropylen = 24,
+		.expected = (unsigned char *)
+		"\x56\xf3\x3d\x4f\xdb\xb9\xa5\xb6\x4d\x26\x23\x44"
+		"\x97\xe9\xdc\xb8\x77\x98\xc6\x8d\x08\xf7\xc4\x11"
+		"\x99\xd4\xbd\xdf\x97\xeb\xbf\x6c\xb5\x55\x0e\x5d"
+		"\x14\x9f\xf4\xd5\xbd\x0f\x05\xf2\x5a\x69\x88\xc1"
+		"\x74\x36\x39\x62\x27\x18\x4a\xf8\x4a\x56\x43\x35"
+		"\x65\x8e\x2f\x85\x72\xbe\xa3\x33\xee\xe2\xab\xff"
+		"\x22\xff\xa6\xde\x3e\x22\xac\xa2",
+		.expectedlen = 80,
+		.addtla = NULL,
+		.addtlb = NULL,
+		.addtllen = 0,
+		.pers = NULL,
+		.perslen = 0,
+		.entropyreseed = (unsigned char *)
+		"\x72\xd2\x8c\x90\x8e\xda\xf9\xa4\xd1\xe5\x26\xd8"
+		"\xf2\xde\xd5\x44",
+		.entropyreseed_len = 16,
+		.addtl_reseed = NULL,
+		.addtl_reseed_len = 0,
+	},
+	{
+		.flags = DRBG_NOPR_HASHSHA1,
+		.entropy = (unsigned char *)
+		"\xd9\xba\xb5\xce\xdc\xa9\x6f\x61\x78\xd6\x45\x09"
+		"\xa0\xdf\xdc\x5e\xda\xd8\x98\x94\x14\x45\x0e\x01",
+		.entropylen = 24,
+		.expected = (unsigned char *)
+		"\xc4\x8b\x89\xf9\xda\x3f\x74\x82\x45\x55\x5d\x5d"
+		"\x03\x3b\x69\x3d\xd7\x1a\x4d\xf5\x69\x02\x05\xce"
+		"\xfc\xd7\x20\x11\x3c\xc2\x4e\x09\x89\x36\xff\x5e"
+		"\x77\xb5\x41\x53\x58\x70\xb3\x39\x46\x8c\xdd\x8d"
+		"\x6f\xaf\x8c\x56\x16\x3a\x70\x0a\x75\xb2\x3e\x59"
+		"\x9b\x5a\xec\xf1\x6f\x3b\xaf\x6d\x5f\x24\x19\x97"
+		"\x1f\x24\xf4\x46\x72\x0f\xea\xbe",
+		.expectedlen = 80,
+		.addtla = (unsigned char *)
+		"\x04\xfa\x28\x95\xaa\x5a\x6f\x8c\x57\x43\x34\x3b"
+		"\x80\x5e\x5e\xa4",
+		.addtlb = (unsigned char *)
+		"\xdf\x5d\xc4\x59\xdf\xf0\x2a\xa2\xf0\x52\xd7\x21"
+		"\xec\x60\x72\x30",
+		.addtllen = 16,
+		.pers = NULL,
+		.perslen = 0,
+		.entropyreseed = (unsigned char *)
+		"\xc6\xba\xd0\x74\xc5\x90\x67\x86\xf5\xe1\xf3\x20"
+		"\x99\xf5\xb4\x91",
+		.entropyreseed_len = 16,
+		.addtl_reseed = (unsigned char *)
+		"\x3e\x6b\xf4\x6f\x4d\xaa\x38\x25\xd7\x19\x4e\x69"
+		"\x4e\x77\x52\xf7",
+		.addtl_reseed_len = 16,
+	},
 };
 
 struct drbg_flags
@@ -1122,9 +1188,11 @@ static void usage(void)
 	fprintf(stderr, "\t-y\t1st Entropy PR string in HEX\n");
 	fprintf(stderr, "\t-z\t2nd Entropy PR string in HEX\n");
 	fprintf(stderr, "\t-c\t1st Additional intput string in HEX\n");
-	fprintf(stderr, "\t-c\t2nd Additional intput string in HEX\n");
+	fprintf(stderr, "\t-d\t2nd Additional intput string in HEX\n");
 	fprintf(stderr, "\t-p\tPersonalization string in HEX\n");
 	fprintf(stderr, "\t-l\tLength of requested random string in bytes\n");
+	fprintf(stderr, "\t-r\tReseed Entropy input string in HEX\n");
+	fprintf(stderr, "\t-a\tAdditional Reseed Entropy input string in HEX\n");
 	exit(1);
 }
 
@@ -1162,9 +1230,11 @@ main (int argc, char **argv)
 			{"addtlb", 1, 0, 0},
 			{"pers", 1, 0, 0},
 			{"len", 1, 0, 0},
+			{"entropyreseed", 1, 0, 0},
+			{"addtl_reseed", 1, 0, 0},
 			{0, 0, 0, 0}
 		};
-		c = getopt_long(argc, argv, "bgf:e:y:z:c:d:p:l:", opts, &opt_index);
+		c = getopt_long(argc, argv, "bgf:e:y:z:c:d:p:l:r:a:", opts, &opt_index);
 		if(-1 == c)
 			break;
 		switch(c)
@@ -1199,6 +1269,12 @@ main (int argc, char **argv)
 			case 'l':
 				exttest.expectedlen = atoi(optarg);
 				break;
+			case 'r':
+				hex2bin_m(optarg, &exttest.entropyreseed, &exttest.entropyreseed_len);
+				break;
+			case 'a':
+				hex2bin_m(optarg, &exttest.addtl_reseed, &exttest.addtl_reseed_len);
+				break;
 			default:
 				usage();
 		}
openSUSE Build Service is sponsored by