summaryrefslogtreecommitdiffhomepage
path: root/libtomcrypt/testprof/pkcs_1_test.c
diff options
context:
space:
mode:
authorMatt Johnston <matt@ucc.asn.au>2007-02-03 08:20:30 +0000
committerMatt Johnston <matt@ucc.asn.au>2007-02-03 08:20:30 +0000
commitc5fd7dd5548f28e32d846e39d17e5c4de4e769af (patch)
tree81b522e272facfb27ff614936b4988bf6569ef2d /libtomcrypt/testprof/pkcs_1_test.c
parent5092e30605dfc5c45990d91cf606990e5c768255 (diff)
parent4a5208512ba02f735acbf7e948ed02353583581e (diff)
merge of '1250b8af44b62d8f4fe0f8d9fc7e7a1cc34e7e1c'
and '7f8670ac3bb975f40967f3979d09d2199b7e90c8' --HG-- extra : convert_revision : 6b61c50f4cf888bea302ac8fcf5dbb573b443251
Diffstat (limited to 'libtomcrypt/testprof/pkcs_1_test.c')
-rw-r--r--libtomcrypt/testprof/pkcs_1_test.c15
1 files changed, 6 insertions, 9 deletions
diff --git a/libtomcrypt/testprof/pkcs_1_test.c b/libtomcrypt/testprof/pkcs_1_test.c
index 1a47d85..da725fc 100644
--- a/libtomcrypt/testprof/pkcs_1_test.c
+++ b/libtomcrypt/testprof/pkcs_1_test.c
@@ -5,7 +5,7 @@
int pkcs_1_test(void)
{
unsigned char buf[3][128];
- int res1, res2, res3, prng_idx, hash_idx;
+ int res1, res2, res3, prng_idx, hash_idx, err;
unsigned long x, y, l1, l2, l3, i1, i2, lparamlen, saltlen, modlen;
static const unsigned char lparam[] = { 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16 };
@@ -18,6 +18,7 @@ int pkcs_1_test(void)
return 1;
}
+ srand(time(NULL));
/* do many tests */
for (x = 0; x < 100; x++) {
zeromem(buf, sizeof(buf));
@@ -26,9 +27,6 @@ int pkcs_1_test(void)
l3 = (rand() & 31) + 8;
for (y = 0; y < l3; y++) buf[0][y] = rand() & 255;
- /* random modulus len (v1.5 must be multiple of 8 though arbitrary sizes seem to work) */
- modlen = 800 + 8 * (abs(rand()) % 28);
-
/* pick a random lparam len [0..16] */
lparamlen = abs(rand()) % 17;
@@ -69,9 +67,8 @@ int pkcs_1_test(void)
DO(pkcs_1_pss_decode(buf[0], l3, buf[1], l1, saltlen, hash_idx, modlen, &res2));
buf[0][i1] ^= 1;
- buf[1][i2 = abs(rand()) % l1] ^= 1;
- DO(pkcs_1_pss_decode(buf[0], l3, buf[1], l1, saltlen, hash_idx, modlen, &res3));
-
+ buf[1][i2 = abs(rand()) % (l1 - 1)] ^= 1;
+ pkcs_1_pss_decode(buf[0], l3, buf[1], l1, saltlen, hash_idx, modlen, &res3);
if (!(res1 == 1 && res2 == 0 && res3 == 0)) {
fprintf(stderr, "PSS failed: %d, %d, %d, %lu, %lu\n", res1, res2, res3, l3, saltlen);
return 1;
@@ -92,5 +89,5 @@ int pkcs_1_test(void)
/* $Source: /cvs/libtom/libtomcrypt/testprof/pkcs_1_test.c,v $ */
-/* $Revision: 1.6 $ */
-/* $Date: 2005/05/21 12:51:25 $ */
+/* $Revision: 1.7 $ */
+/* $Date: 2006/11/30 03:30:45 $ */