Blame SOURCES/nss-softokn-3.16-lowhash-test.patch

6fbbf4
diff -up ./nss/cmd/lowhashtest/lowhashtest.c.lowhash-test ./nss/cmd/lowhashtest/lowhashtest.c
6fbbf4
--- ./nss/cmd/lowhashtest/lowhashtest.c.lowhash-test	2014-06-24 13:45:27.000000000 -0700
6fbbf4
+++ ./nss/cmd/lowhashtest/lowhashtest.c	2014-09-22 11:10:55.537028950 -0700
6fbbf4
@@ -1,23 +1,29 @@
6fbbf4
 #include <stdio.h>
6fbbf4
 #include <string.h>
6fbbf4
 #include <assert.h>
6fbbf4
-
6fbbf4
-#include "nspr.h"
6fbbf4
+#include <stdlib.h>
6fbbf4
 
6fbbf4
 /* nss headers */
6fbbf4
-#include "prtypes.h"
6fbbf4
-#include "plgetopt.h"
6fbbf4
-#include "hasht.h"
6fbbf4
+#include "prtypes.h" 
6fbbf4
+#include "hasht.h" 
6fbbf4
 #include "nsslowhash.h"
6fbbf4
-#include "secport.h"
6fbbf4
-#include "hasht.h"
6fbbf4
-#include "basicutil.h"
6fbbf4
 
6fbbf4
 static char *progName = NULL;
6fbbf4
 
6fbbf4
+static void
6fbbf4
+dump(FILE *io, const unsigned char *buf, int len)
6fbbf4
+{
6fbbf4
+    int i;
6fbbf4
+    for (i=0; i < len; i++) {
6fbbf4
+	if (i!=0) fprintf(io,", ");
6fbbf4
+	fprintf(io, "0x%02x",buf[i]);
6fbbf4
+    }
6fbbf4
+    fprintf(io, "\n");
6fbbf4
+}
6fbbf4
+
6fbbf4
 static int test_long_message(NSSLOWInitContext *initCtx,
6fbbf4
 	HASH_HashType algoType, unsigned int hashLen,
6fbbf4
-	const PRUint8 expected[], PRUint8 results[])
6fbbf4
+	const unsigned char expected[], unsigned char results[])
6fbbf4
 {
6fbbf4
     unsigned int len, i, rv = 0;
6fbbf4
     NSSLOWHASHContext *ctx;
6fbbf4
@@ -27,11 +33,11 @@ static int test_long_message(NSSLOWInitC
6fbbf4
      * buffer and call update 1,000 times.
6fbbf4
      */
6fbbf4
     unsigned char buf[1000];
6fbbf4
-    (void) PORT_Memset(buf, 'a', sizeof(buf));
6fbbf4
+    (void) memset(buf, 'a', sizeof(buf));
6fbbf4
 
6fbbf4
     ctx = NSSLOWHASH_NewContext(initCtx, algoType);
6fbbf4
     if (ctx == NULL) {
6fbbf4
-    	SECU_PrintError(progName, "Couldn't get hash context\n");
6fbbf4
+    	fprintf(stderr,"%s: Couldn't get hash context\n", progName);
6fbbf4
 	return 1;
6fbbf4
     }
6fbbf4
 
6fbbf4
@@ -41,12 +47,14 @@ static int test_long_message(NSSLOWInitC
6fbbf4
     }
6fbbf4
 
6fbbf4
     NSSLOWHASH_End(ctx, results, &len, hashLen);
6fbbf4
-    PR_ASSERT(len == hashLen);
6fbbf4
-    PR_ASSERT(PORT_Memcmp(expected, results, hashLen) == 0);
6fbbf4
-    if (PORT_Memcmp(expected, results, len) != 0) {
6fbbf4
-  	SECU_PrintError(progName, "Hash mismatch\n");
6fbbf4
-	SECU_PrintBuf(stdout, "Expected: ", expected, hashLen);
6fbbf4
-	SECU_PrintBuf(stdout, "Actual:   ", results, len);
6fbbf4
+    assert(len == hashLen);
6fbbf4
+    assert(memcmp(expected, results, hashLen) == 0);
6fbbf4
+    if (memcmp(expected, results, len) != 0) {
6fbbf4
+    	fprintf(stderr,"%s: Hash mismatch\n", progName);
6fbbf4
+	fprintf(stderr," Expected: (len=%d) ", hashLen);
6fbbf4
+	dump(stderr,expected, hashLen);
6fbbf4
+	fprintf(stderr," Actual: (len=%d) ", len);
6fbbf4
+	dump(stderr, results, len);
6fbbf4
 	rv = 1;
6fbbf4
     }
6fbbf4
 
6fbbf4
@@ -57,33 +65,33 @@ static int test_long_message(NSSLOWInitC
6fbbf4
 }
6fbbf4
 
6fbbf4
 static int test_long_message_sha1(NSSLOWInitContext *initCtx) {
6fbbf4
-    PRUint8 results[SHA1_LENGTH];
6fbbf4
+    unsigned char results[SHA1_LENGTH];
6fbbf4
     /* Test vector from FIPS 180-2: appendix B.3.  */
6fbbf4
 
6fbbf4
     /* 34aa973c d4c4daa4 f61eeb2b dbad2731 6534016f. */
6fbbf4
-    static const PRUint8 expected[SHA256_LENGTH] =
6fbbf4
+    static const unsigned char expected[SHA256_LENGTH] =
6fbbf4
     { 0x34,0xaa,0x97,0x3c, 0xd4,0xc4,0xda,0xa4, 0xf6,0x1e,0xeb,0x2b,
6fbbf4
       0xdb,0xad,0x27,0x31, 0x65,0x34,0x01,0x6f };
6fbbf4
     unsigned char buf[1000];
6fbbf4
-    (void) PORT_Memset(buf, 'a', sizeof(buf));
6fbbf4
+    (void) memset(buf, 'a', sizeof(buf));
6fbbf4
     return test_long_message(initCtx, HASH_AlgSHA1,
6fbbf4
 		SHA1_LENGTH, &expected[0], results);
6fbbf4
 }
6fbbf4
 
6fbbf4
 static int test_long_message_sha256(NSSLOWInitContext *initCtx) {
6fbbf4
-    PRUint8 results[SHA256_LENGTH];
6fbbf4
+    unsigned char results[SHA256_LENGTH];
6fbbf4
     /* cdc76e5c 9914fb92 81a1c7e2 84d73e67 f1809a48 a497200e 046d39cc c7112cd0. */
6fbbf4
-    static const PRUint8 expected[SHA256_LENGTH] =
6fbbf4
+    static const unsigned char expected[SHA256_LENGTH] =
6fbbf4
     { 0xcd,0xc7,0x6e,0x5c, 0x99,0x14,0xfb,0x92, 0x81,0xa1,0xc7,0xe2, 0x84,0xd7,0x3e,0x67,
6fbbf4
       0xf1,0x80,0x9a,0x48, 0xa4,0x97,0x20,0x0e, 0x04,0x6d,0x39,0xcc, 0xc7,0x11,0x2c,0xd0 };
6fbbf4
     unsigned char buf[1000];
6fbbf4
-    (void) PORT_Memset(buf, 'a', sizeof(buf));
6fbbf4
+    (void) memset(buf, 'a', sizeof(buf));
6fbbf4
     return test_long_message(initCtx, HASH_AlgSHA256,
6fbbf4
 		SHA256_LENGTH, &expected[0], results);
6fbbf4
 }
6fbbf4
 
6fbbf4
 static int test_long_message_sha384(NSSLOWInitContext *initCtx) {
6fbbf4
-    PRUint8 results[SHA384_LENGTH];
6fbbf4
+    unsigned char results[SHA384_LENGTH];
6fbbf4
     /* Test vector from FIPS 180-2: appendix B.3.  */
6fbbf4
     /*
6fbbf4
 	9d0e1809716474cb 
6fbbf4
@@ -93,7 +101,7 @@ static int test_long_message_sha384(NSSL
6fbbf4
 	07b8b3dc38ecc4eb 
6fbbf4
 	ae97ddd87f3d8985.
6fbbf4
     */
6fbbf4
-    static const PRUint8 expected[SHA384_LENGTH] =
6fbbf4
+    static const unsigned char expected[SHA384_LENGTH] =
6fbbf4
     { 0x9d,0x0e,0x18,0x09,0x71,0x64,0x74,0xcb, 
6fbbf4
       0x08,0x6e,0x83,0x4e,0x31,0x0a,0x4a,0x1c, 
6fbbf4
       0xed,0x14,0x9e,0x9c,0x00,0xf2,0x48,0x52,
6fbbf4
@@ -101,22 +109,22 @@ static int test_long_message_sha384(NSSL
6fbbf4
       0x07,0xb8,0xb3,0xdc,0x38,0xec,0xc4,0xeb, 
6fbbf4
       0xae,0x97,0xdd,0xd8,0x7f,0x3d,0x89,0x85 };
6fbbf4
     unsigned char buf[1000];
6fbbf4
-    (void) PORT_Memset(buf, 'a', sizeof(buf));
6fbbf4
+    (void) memset(buf, 'a', sizeof(buf));
6fbbf4
 
6fbbf4
     return test_long_message(initCtx, HASH_AlgSHA384,
6fbbf4
 		SHA384_LENGTH, &expected[0], results);
6fbbf4
 }
6fbbf4
 
6fbbf4
 static int test_long_message_sha512(NSSLOWInitContext *initCtx) {
6fbbf4
-    PRUint8 results[SHA512_LENGTH];
6fbbf4
+    unsigned char results[SHA512_LENGTH];
6fbbf4
     /* Test vector from FIPS 180-2: appendix B.3.  */
6fbbf4
-    static const PRUint8 expected[SHA512_LENGTH] =
6fbbf4
+    static const unsigned char expected[SHA512_LENGTH] =
6fbbf4
     { 0xe7,0x18,0x48,0x3d,0x0c,0xe7,0x69,0x64,0x4e,0x2e,0x42,0xc7,0xbc,0x15,0xb4,0x63,
6fbbf4
       0x8e,0x1f,0x98,0xb1,0x3b,0x20,0x44,0x28,0x56,0x32,0xa8,0x03,0xaf,0xa9,0x73,0xeb,
6fbbf4
       0xde,0x0f,0xf2,0x44,0x87,0x7e,0xa6,0x0a,0x4c,0xb0,0x43,0x2c,0xe5,0x77,0xc3,0x1b,
6fbbf4
       0xeb,0x00,0x9c,0x5c,0x2c,0x49,0xaa,0x2e,0x4e,0xad,0xb2,0x17,0xad,0x8c,0xc0,0x9b};
6fbbf4
     unsigned char buf[1000];
6fbbf4
-    (void) PORT_Memset(buf, 'a', sizeof(buf));
6fbbf4
+    (void) memset(buf, 'a', sizeof(buf));
6fbbf4
 
6fbbf4
     return test_long_message(initCtx, HASH_AlgSHA512,
6fbbf4
 		SHA512_LENGTH, &expected[0], results);
6fbbf4
@@ -126,7 +134,7 @@ static int test_long_message_sha512(NSSL
6fbbf4
 static int testMessageDigest(NSSLOWInitContext *initCtx,
6fbbf4
 	HASH_HashType algoType, unsigned int hashLen,
6fbbf4
 	const unsigned char *message,
6fbbf4
-	const PRUint8 expected[], PRUint8 results[])
6fbbf4
+	const unsigned char expected[], unsigned char results[])
6fbbf4
 {
6fbbf4
     NSSLOWHASHContext *ctx;
6fbbf4
     unsigned int len;
6fbbf4
@@ -134,20 +142,22 @@ static int testMessageDigest(NSSLOWInitC
6fbbf4
 
6fbbf4
     ctx = NSSLOWHASH_NewContext(initCtx, algoType);
6fbbf4
     if (ctx == NULL) {
6fbbf4
-    	SECU_PrintError(progName, "Couldn't get hash context\n");
6fbbf4
+    	fprintf(stderr, "%s: Couldn't get hash context\n", progName);
6fbbf4
 	return 1;
6fbbf4
     }
6fbbf4
 
6fbbf4
     NSSLOWHASH_Begin(ctx);
6fbbf4
-    NSSLOWHASH_Update(ctx, message, PORT_Strlen((const char *)message));
6fbbf4
+    NSSLOWHASH_Update(ctx, message, strlen((const char *)message));
6fbbf4
     NSSLOWHASH_End(ctx, results, &len, hashLen);
6fbbf4
-    PR_ASSERT(len == hashLen);
6fbbf4
-    PR_ASSERT(PORT_Memcmp(expected, results, len) == 0);
6fbbf4
+    assert(len == hashLen);
6fbbf4
+    assert(memcmp(expected, results, len) == 0);
6fbbf4
 
6fbbf4
-    if (PORT_Memcmp(expected, results, len) != 0) {
6fbbf4
-  	SECU_PrintError(progName, "Hash mismatch\n");
6fbbf4
-	SECU_PrintBuf(stdout, "Expected: ", expected, hashLen);
6fbbf4
-	SECU_PrintBuf(stdout, "Actual:   ", results, len);
6fbbf4
+    if (memcmp(expected, results, len) != 0) {
6fbbf4
+    	fprintf(stderr,"%s: Hash mismatch\n", progName);
6fbbf4
+	fprintf(stderr," Expected: (len=%d) ", hashLen);
6fbbf4
+	dump(stderr,expected, hashLen);
6fbbf4
+	fprintf(stderr," Actual: (len=%d) ", len);
6fbbf4
+	dump(stderr, results, len);
6fbbf4
 	rv = 1;
6fbbf4
     }
6fbbf4
 
6fbbf4
@@ -164,7 +174,7 @@ static int testMD5(NSSLOWInitContext *in
6fbbf4
 
6fbbf4
     static const struct {
6fbbf4
 	const unsigned char *input;
6fbbf4
-	const PRUint8 result[MD5_LENGTH];
6fbbf4
+	const unsigned char result[MD5_LENGTH];
6fbbf4
    } md5tests[] = {
6fbbf4
 	{ (unsigned char *) "",
6fbbf4
 	  {0xd4,0x1d,0x8c,0xd9,0x8f,0x00,0xb2,0x04,0xe9,0x80,0x09,0x98,0xec,0xf8,0x42,0x7e} },
6fbbf4
@@ -182,7 +192,7 @@ static int testMD5(NSSLOWInitContext *in
6fbbf4
 	  "12345678901234567890",
6fbbf4
 	  {0x57,0xed,0xf4,0xa2,0x2b,0xe3,0xc9,0x55,0xac,0x49,0xda,0x2e,0x21,0x07,0xb6,0x7a} }
6fbbf4
     };
6fbbf4
-    PRUint8 results[MD5_LENGTH];
6fbbf4
+    unsigned char results[MD5_LENGTH];
6fbbf4
     int rv = 0, cnt, numTests;
6fbbf4
 
6fbbf4
     numTests = sizeof(md5tests)/sizeof(md5tests[0]);
6fbbf4
@@ -203,7 +213,7 @@ static int testSHA1(NSSLOWInitContext *i
6fbbf4
 {
6fbbf4
     static const struct {
6fbbf4
 	const unsigned char *input;
6fbbf4
-	const PRUint8 result[SHA1_LENGTH];
6fbbf4
+	const unsigned char result[SHA1_LENGTH];
6fbbf4
     } sha1tests[] = {
6fbbf4
 	/* one block messsage */
6fbbf4
 	{ (const unsigned char *)
6fbbf4
@@ -222,7 +232,7 @@ static int testSHA1(NSSLOWInitContext *i
6fbbf4
 	}
6fbbf4
     };
6fbbf4
 
6fbbf4
-    PRUint8 results[SHA1_LENGTH];
6fbbf4
+    unsigned char results[SHA1_LENGTH];
6fbbf4
     int rv = 0, cnt, numTests;
6fbbf4
 
6fbbf4
     numTests = sizeof(sha1tests)/sizeof(sha1tests[0]);
6fbbf4
@@ -240,7 +250,7 @@ static int testSHA224(NSSLOWInitContext
6fbbf4
 {
6fbbf4
     static const struct {
6fbbf4
 	const unsigned char *input;
6fbbf4
-	const PRUint8 result[SHA224_LENGTH];
6fbbf4
+	const unsigned char result[SHA224_LENGTH];
6fbbf4
     } sha224tests[] = {
6fbbf4
 	/* one block messsage */
6fbbf4
 	{ (const unsigned char *) "abc",
6fbbf4
@@ -254,7 +264,7 @@ static int testSHA224(NSSLOWInitContext
6fbbf4
 	}
6fbbf4
     };
6fbbf4
 
6fbbf4
-    PRUint8 results[SHA224_LENGTH];
6fbbf4
+    unsigned char results[SHA224_LENGTH];
6fbbf4
     int rv = 0, cnt, numTests;
6fbbf4
 
6fbbf4
     numTests = sizeof(sha224tests)/sizeof(sha224tests[0]);
6fbbf4
@@ -271,7 +281,7 @@ static int testSHA256(NSSLOWInitContext
6fbbf4
 {
6fbbf4
     static const struct {
6fbbf4
 	const unsigned char *input;
6fbbf4
-	const PRUint8 result[SHA256_LENGTH];
6fbbf4
+	const unsigned char result[SHA256_LENGTH];
6fbbf4
     } sha256tests[] = {
6fbbf4
 	/* Test vectors from FIPS 180-2: appendix B.1.  */
6fbbf4
 	{ (unsigned char *) "abc",
6fbbf4
@@ -285,7 +295,7 @@ static int testSHA256(NSSLOWInitContext
6fbbf4
 	}
6fbbf4
     };
6fbbf4
 
6fbbf4
-    PRUint8 results[SHA256_LENGTH];
6fbbf4
+    unsigned char results[SHA256_LENGTH];
6fbbf4
     int rv = 0, cnt, numTests;
6fbbf4
 
6fbbf4
     numTests = sizeof(sha256tests)/sizeof(sha256tests[0]);
6fbbf4
@@ -303,7 +313,7 @@ static int testSHA384(NSSLOWInitContext
6fbbf4
 {
6fbbf4
     static const struct {
6fbbf4
 	const unsigned char *input;
6fbbf4
-	const PRUint8 result[SHA384_LENGTH];
6fbbf4
+	const unsigned char result[SHA384_LENGTH];
6fbbf4
     } sha384tests[] = {
6fbbf4
 	/* Test vector from FIPS 180-2: appendix D, single-block message.  */
6fbbf4
 	{ (unsigned char *) "abc",
6fbbf4
@@ -334,7 +344,7 @@ static int testSHA384(NSSLOWInitContext
6fbbf4
          0x66,0xc3,0xe9,0xfa,0x91,0x74,0x60,0x39} }
6fbbf4
    };
6fbbf4
 
6fbbf4
-    PRUint8 results[SHA384_LENGTH];
6fbbf4
+    unsigned char results[SHA384_LENGTH];
6fbbf4
     int rv = 0, cnt, numTests;
6fbbf4
 
6fbbf4
     numTests = sizeof(sha384tests)/sizeof(sha384tests[0]);
6fbbf4
@@ -353,7 +363,7 @@ int testSHA512(NSSLOWInitContext *initCt
6fbbf4
 {
6fbbf4
     static const struct {
6fbbf4
 	const unsigned char *input;
6fbbf4
-	const PRUint8 result[SHA512_LENGTH];
6fbbf4
+	const unsigned char result[SHA512_LENGTH];
6fbbf4
     } sha512tests[] = {
6fbbf4
 	/* Test vectors from FIPS 180-2: appendix C.1.  */
6fbbf4
 	{ (unsigned char *) "abc",
6fbbf4
@@ -372,7 +382,7 @@ int testSHA512(NSSLOWInitContext *initCt
6fbbf4
 	}
6fbbf4
     };
6fbbf4
 
6fbbf4
-    PRUint8 results[SHA512_LENGTH];
6fbbf4
+    unsigned char results[SHA512_LENGTH];
6fbbf4
     int rv = 0, cnt, numTests;
6fbbf4
 
6fbbf4
     numTests = sizeof(sha512tests)/sizeof(sha512tests[0]);
6fbbf4
@@ -406,7 +416,7 @@ int main(int argc, char **argv)
6fbbf4
 
6fbbf4
     initCtx = NSSLOW_Init();
6fbbf4
     if (initCtx == NULL) {
6fbbf4
-	SECU_PrintError(progName, "Couldn't initialize for hashing\n");
6fbbf4
+	fprintf(stderr, "%s: Couldn't initialize for hashing\n", progName);
6fbbf4
 	return 1;
6fbbf4
     }
6fbbf4
 
6fbbf4
@@ -430,7 +440,7 @@ int main(int argc, char **argv)
6fbbf4
     } else if (strcmp(argv[1], "SHA512") == 0) {
6fbbf4
 	rv += testSHA512(initCtx);
6fbbf4
     } else {
6fbbf4
-    	SECU_PrintError(progName, "Unsupported hash type %s\n", argv[0]);
6fbbf4
+    	fprintf(stderr,"%s: Unsupported hash type %s\n", progName, argv[0]);
6fbbf4
     	Usage(progName);
6fbbf4
     }
6fbbf4
 
6fbbf4
diff -up ./nss/lib/freebl/nsslowhash.c.lowhash-test ./nss/lib/freebl/nsslowhash.c
6fbbf4
--- ./nss/lib/freebl/nsslowhash.c.lowhash-test	2014-09-22 11:10:55.518028631 -0700
6fbbf4
+++ ./nss/lib/freebl/nsslowhash.c	2014-09-22 11:10:55.545029084 -0700
6fbbf4
@@ -28,6 +28,13 @@ static int nsslow_GetFIPSEnabled(void) {
6fbbf4
     FILE *f;
6fbbf4
     char d;
6fbbf4
     size_t size;
6fbbf4
+    char *env = getenv("NSS_FIPS");
6fbbf4
+
6fbbf4
+    /* if the enviroment variable is set, force fips anyway. This lets us
6fbbf4
+     * test FIPS mode even if the system isn't in FIPS mode */
6fbbf4
+    if (env && *env == '1') {
6fbbf4
+	return 1;
6fbbf4
+    }
6fbbf4
 
6fbbf4
     f = fopen("/proc/sys/crypto/fips_enabled", "r");
6fbbf4
     if (!f)
6fbbf4
diff -up ./nss/tests/lowhash/lowhash.sh.lowhash-test ./nss/tests/lowhash/lowhash.sh
6fbbf4
--- ./nss/tests/lowhash/lowhash.sh.lowhash-test	2014-06-24 13:45:27.000000000 -0700
6fbbf4
+++ ./nss/tests/lowhash/lowhash.sh	2014-09-22 11:10:55.546029101 -0700
6fbbf4
@@ -95,3 +95,100 @@ lowhash_init
6fbbf4
 lowhash_test
6fbbf4
 lowhash_cleanup
6fbbf4
 echo "lowhash.sh done"
6fbbf4
+#! /bin/bash  
6fbbf4
+#
6fbbf4
+# This Source Code Form is subject to the terms of the Mozilla Public
6fbbf4
+# License, v. 2.0. If a copy of the MPL was not distributed with this
6fbbf4
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
6fbbf4
+
6fbbf4
+########################################################################
6fbbf4
+# mozilla/security/nss/tests/lowhash/lowhash.sh
6fbbf4
+#
6fbbf4
+# Script to test basic functionallity of the NSSLoHash API
6fbbf4
+#
6fbbf4
+# included from 
6fbbf4
+# --------------
6fbbf4
+#   all.sh
6fbbf4
+#
6fbbf4
+# needs to work on all Linux platforms
6fbbf4
+#
6fbbf4
+# tests implemented:
6fbbf4
+# lowash (verify encryption cert - bugzilla bug 119059)
6fbbf4
+#
6fbbf4
+# special strings
6fbbf4
+# ---------------
6fbbf4
+#
6fbbf4
+########################################################################
6fbbf4
+
6fbbf4
+errors=0
6fbbf4
+
6fbbf4
+############################## lowhash_init ##############################
6fbbf4
+# local shell function to initialize this script 
6fbbf4
+########################################################################
6fbbf4
+lowhash_init()
6fbbf4
+{
6fbbf4
+  SCRIPTNAME=lowhash.sh      # sourced - $0 would point to all.sh
6fbbf4
+
6fbbf4
+  if [ -z "${CLEANUP}" ] ; then     # if nobody else is responsible for
6fbbf4
+      CLEANUP="${SCRIPTNAME}"       # cleaning this script will do it
6fbbf4
+  fi
6fbbf4
+
6fbbf4
+  if [ -z "${INIT_SOURCED}" -o "${INIT_SOURCED}" != "TRUE" ]; then
6fbbf4
+      cd ../common
6fbbf4
+      . ./init.sh
6fbbf4
+  fi
6fbbf4
+  LOWHASHDIR=../lowhash
6fbbf4
+  mkdir -p ${LOWHASHDIR}
6fbbf4
+  if [ -f /proc/sys/crypto/fips_enabled ]; then
6fbbf4
+    FVAL=`cat /proc/sys/crypto/fips_enabled`
6fbbf4
+    html_head "Lowhash Tests - /proc/sys/crypto/fips_enabled is ${FVAL}"
6fbbf4
+  else
6fbbf4
+    html_head "Lowhash Tests"
6fbbf4
+  fi
6fbbf4
+  cd ${LOWHASHDIR}
6fbbf4
+}
6fbbf4
+
6fbbf4
+############################## lowhash_test ##############################
6fbbf4
+# local shell function to test basic the NSS Low Hash API both in
6fbbf4
+# FIPS 140 compliant mode and not
6fbbf4
+########################################################################
6fbbf4
+lowhash_test()
6fbbf4
+{
6fbbf4
+  if [ ! -f ${BINDIR}/lowhashtest -a  \
6fbbf4
+       ! -f ${BINDIR}/lowhashtest${PROG_SUFFIX} ]; then
6fbbf4
+    echo "freebl lowhash not supported in this plaform."
6fbbf4
+  else
6fbbf4
+    TESTS="MD5 SHA1 SHA224 SHA256 SHA384 SHA512"
6fbbf4
+    OLD_MODE=`echo ${NSS_FIPS}`
6fbbf4
+    for fips_mode in 0 1; do
6fbbf4
+      echo "lowhashtest with fips mode=${fips_mode}"
6fbbf4
+      export NSS_FIPS=${fips_mode}
6fbbf4
+      for TEST in ${TESTS}
6fbbf4
+      do
6fbbf4
+        echo "lowhashtest ${TEST}"
6fbbf4
+        ${BINDIR}/lowhashtest ${TEST} 2>&1
6fbbf4
+        RESULT=$?
6fbbf4
+        html_msg ${RESULT} 0 "lowhashtest with fips mode=${fips_mode} for ${TEST}"
6fbbf4
+      done
6fbbf4
+    done
6fbbf4
+    export NSS_FIPS=${OLD_MODE}
6fbbf4
+  fi
6fbbf4
+}
6fbbf4
+
6fbbf4
+############################## lowhash_cleanup ############################
6fbbf4
+# local shell function to finish this script (no exit since it might be 
6fbbf4
+# sourced)
6fbbf4
+########################################################################
6fbbf4
+lowhash_cleanup()
6fbbf4
+{
6fbbf4
+  html "
"
6fbbf4
+  cd ${QADIR}
6fbbf4
+  . common/cleanup.sh
6fbbf4
+}
6fbbf4
+
6fbbf4
+################## main #################################################
6fbbf4
+
6fbbf4
+lowhash_init
6fbbf4
+lowhash_test
6fbbf4
+lowhash_cleanup
6fbbf4
+echo "lowhash.sh done"