From 5d14574bbab9c46c38a8ed591099885dbc986bb5 Mon Sep 17 00:00:00 2001 From: mdw Date: Fri, 11 Aug 2000 21:34:34 +0000 Subject: [PATCH] Change to use the new thresholds given in the draft FIPS140-2. --- fipstest.c | 31 +++++++++++++++++-------------- fipstest.h | 9 ++++++--- 2 files changed, 23 insertions(+), 17 deletions(-) diff --git a/fipstest.c b/fipstest.c index 9febfd4..30f270b 100644 --- a/fipstest.c +++ b/fipstest.c @@ -1,8 +1,8 @@ /* -*-c-*- * - * $Id: fipstest.c,v 1.2 2000/06/17 12:21:39 mdw Exp $ + * $Id: fipstest.c,v 1.3 2000/08/11 21:34:34 mdw Exp $ * - * FIPS 140-1 randomness tests + * FIPS140 randomness tests * * (c) 2000 Straylight/Edgeware */ @@ -30,6 +30,9 @@ /*----- Revision history --------------------------------------------------* * * $Log: fipstest.c,v $ + * Revision 1.3 2000/08/11 21:34:34 mdw + * Change to use the new thresholds given in the draft FIPS140-2. + * * Revision 1.2 2000/06/17 12:21:39 mdw * Add braces to shut compiler up. Reformat code slightly. * @@ -71,7 +74,7 @@ static unsigned monobit(const octet *p) } } - if (9654 >= n1 || n1 >= 10346) + if (9725 >= n1 || n1 >= 10275) return (FIPSTEST_MONOBIT); return (0); } @@ -86,7 +89,7 @@ static unsigned monobit(const octet *p) * divided into 4-bit nibbles %$x_i$%. If * %$f(x) = \sum_{x_i = x} 1$% is the frequency of each nibble, * then the test is passed if - * %$1.03 < 16/5000 \sum_i f(i)^2 - 5000 < 57.4$%. + * %$2.16 < 16/5000 \sum_i f(i)^2 - 5000 < 46.17$%. */ static unsigned poker(const octet *p) @@ -112,9 +115,9 @@ static unsigned poker(const octet *p) for (i = 0; i < 16; i++) q += f[i] * f[i]; q <<= 4; - q -= 5000 * 5000; + q -= 5000ul * 5000ul; - if (5150 >= q || q >= 287000) + if (10800 >= q || q >= 230850) return (FIPSTEST_POKER); return (0); } @@ -161,7 +164,7 @@ static unsigned runs(const octet *p) } } - if (r >= 34) + if (r >= 26) rc |= FIPSTEST_LONGRUNS; if (r > 6) r = 6; @@ -169,12 +172,12 @@ static unsigned runs(const octet *p) /* --- Check the results --- */ - if (2267 > f[0][0] || f[0][0] > 2733 || 2267 > f[1][0] || f[1][0] > 2733 || - 1079 > f[0][1] || f[0][1] > 1421 || 1079 > f[1][1] || f[1][1] > 1421 || - 502 > f[0][2] || f[0][2] > 748 || 502 > f[1][2] || f[1][2] > 748 || - 223 > f[0][3] || f[0][3] > 402 || 223 > f[1][3] || f[1][3] > 402 || - 90 > f[0][4] || f[0][4] > 223 || 90 > f[1][4] || f[1][4] > 223 || - 90 > f[0][5] || f[0][5] > 223 || 90 > f[1][5] || f[1][5] > 223) + if (2343 > f[0][0] || f[0][0] > 2657 || 2343 > f[1][0] || f[1][0] > 2657 || + 1135 > f[0][1] || f[0][1] > 1365 || 1135 > f[1][1] || f[1][1] > 1365 || + 542 > f[0][2] || f[0][2] > 708 || 542 > f[1][2] || f[1][2] > 708 || + 251 > f[0][3] || f[0][3] > 373 || 251 > f[1][3] || f[1][3] > 373 || + 111 > f[0][4] || f[0][4] > 201 || 111 > f[1][4] || f[1][4] > 201 || + 111 > f[0][5] || f[0][5] > 201 || 111 > f[1][5] || f[1][5] > 201) rc |= FIPSTEST_RUNS; return (rc); @@ -187,7 +190,7 @@ static unsigned runs(const octet *p) * * Returns: Zero if OK, or a bitmask of failed tests. * - * Use: Performs the FIPS 140-1 randomness tests on a block of data. + * Use: Performs the FIPS140 randomness tests on a block of data. */ unsigned fipstest(const octet *p) diff --git a/fipstest.h b/fipstest.h index c267876..fa150e2 100644 --- a/fipstest.h +++ b/fipstest.h @@ -1,8 +1,8 @@ /* -*-c-*- * - * $Id: fipstest.h,v 1.1 2000/06/17 10:55:38 mdw Exp $ + * $Id: fipstest.h,v 1.2 2000/08/11 21:34:34 mdw Exp $ * - * FIPS 140-1 randomness tests + * FIPS140 randomness tests * * (c) 2000 Straylight/Edgeware */ @@ -30,6 +30,9 @@ /*----- Revision history --------------------------------------------------* * * $Log: fipstest.h,v $ + * Revision 1.2 2000/08/11 21:34:34 mdw + * Change to use the new thresholds given in the draft FIPS140-2. + * * Revision 1.1 2000/06/17 10:55:38 mdw * FIPS 140-1 random generator test. * @@ -67,7 +70,7 @@ enum { * * Returns: Zero if OK, or a bitmask of failed tests. * - * Use: Performs the FIPS 140-1 randomness tests on a block of data. + * Use: Performs the FIPS140 randomness tests on a block of data. */ extern unsigned fipstest(const octet */*p*/); -- 2.11.0