michael@0: #include michael@0: #include michael@0: #include michael@0: michael@0: #include "nspr.h" michael@0: michael@0: /* nss headers */ michael@0: #include "prtypes.h" michael@0: #include "plgetopt.h" michael@0: #include "hasht.h" michael@0: #include "nsslowhash.h" michael@0: #include "secport.h" michael@0: #include "hasht.h" michael@0: #include "basicutil.h" michael@0: michael@0: static char *progName = NULL; michael@0: michael@0: static int test_long_message(NSSLOWInitContext *initCtx, michael@0: HASH_HashType algoType, unsigned int hashLen, michael@0: const PRUint8 expected[], PRUint8 results[]) michael@0: { michael@0: unsigned int len, i, rv = 0; michael@0: NSSLOWHASHContext *ctx; michael@0: michael@0: /* The message is meant to be 'a' repeated 1,000,000 times. michael@0: * This is too much to allocate on the stack so we will use a 1,000 char michael@0: * buffer and call update 1,000 times. michael@0: */ michael@0: unsigned char buf[1000]; michael@0: (void) PORT_Memset(buf, 'a', sizeof(buf)); michael@0: michael@0: ctx = NSSLOWHASH_NewContext(initCtx, algoType); michael@0: if (ctx == NULL) { michael@0: SECU_PrintError(progName, "Couldn't get hash context\n"); michael@0: return 1; michael@0: } michael@0: michael@0: NSSLOWHASH_Begin(ctx); michael@0: for (i = 0; i < 1000; ++i) { michael@0: NSSLOWHASH_Update(ctx, buf, 1000); michael@0: } michael@0: michael@0: NSSLOWHASH_End(ctx, results, &len, hashLen); michael@0: PR_ASSERT(len == hashLen); michael@0: PR_ASSERT(PORT_Memcmp(expected, results, hashLen) == 0); michael@0: if (PORT_Memcmp(expected, results, len) != 0) { michael@0: SECU_PrintError(progName, "Hash mismatch\n"); michael@0: SECU_PrintBuf(stdout, "Expected: ", expected, hashLen); michael@0: SECU_PrintBuf(stdout, "Actual: ", results, len); michael@0: rv = 1; michael@0: } michael@0: michael@0: NSSLOWHASH_Destroy(ctx); michael@0: NSSLOW_Shutdown(initCtx); michael@0: michael@0: return rv; michael@0: } michael@0: michael@0: static int test_long_message_sha1(NSSLOWInitContext *initCtx) { michael@0: PRUint8 results[SHA1_LENGTH]; michael@0: /* Test vector from FIPS 180-2: appendix B.3. */ michael@0: michael@0: /* 34aa973c d4c4daa4 f61eeb2b dbad2731 6534016f. */ michael@0: static const PRUint8 expected[SHA256_LENGTH] = michael@0: { 0x34,0xaa,0x97,0x3c, 0xd4,0xc4,0xda,0xa4, 0xf6,0x1e,0xeb,0x2b, michael@0: 0xdb,0xad,0x27,0x31, 0x65,0x34,0x01,0x6f }; michael@0: unsigned char buf[1000]; michael@0: (void) PORT_Memset(buf, 'a', sizeof(buf)); michael@0: return test_long_message(initCtx, HASH_AlgSHA1, michael@0: SHA1_LENGTH, &expected[0], results); michael@0: } michael@0: michael@0: static int test_long_message_sha256(NSSLOWInitContext *initCtx) { michael@0: PRUint8 results[SHA256_LENGTH]; michael@0: /* cdc76e5c 9914fb92 81a1c7e2 84d73e67 f1809a48 a497200e 046d39cc c7112cd0. */ michael@0: static const PRUint8 expected[SHA256_LENGTH] = michael@0: { 0xcd,0xc7,0x6e,0x5c, 0x99,0x14,0xfb,0x92, 0x81,0xa1,0xc7,0xe2, 0x84,0xd7,0x3e,0x67, michael@0: 0xf1,0x80,0x9a,0x48, 0xa4,0x97,0x20,0x0e, 0x04,0x6d,0x39,0xcc, 0xc7,0x11,0x2c,0xd0 }; michael@0: unsigned char buf[1000]; michael@0: (void) PORT_Memset(buf, 'a', sizeof(buf)); michael@0: return test_long_message(initCtx, HASH_AlgSHA256, michael@0: SHA256_LENGTH, &expected[0], results); michael@0: } michael@0: michael@0: static int test_long_message_sha384(NSSLOWInitContext *initCtx) { michael@0: PRUint8 results[SHA384_LENGTH]; michael@0: /* Test vector from FIPS 180-2: appendix B.3. */ michael@0: /* michael@0: 9d0e1809716474cb michael@0: 086e834e310a4a1c michael@0: ed149e9c00f24852 michael@0: 7972cec5704c2a5b michael@0: 07b8b3dc38ecc4eb michael@0: ae97ddd87f3d8985. michael@0: */ michael@0: static const PRUint8 expected[SHA384_LENGTH] = michael@0: { 0x9d,0x0e,0x18,0x09,0x71,0x64,0x74,0xcb, michael@0: 0x08,0x6e,0x83,0x4e,0x31,0x0a,0x4a,0x1c, michael@0: 0xed,0x14,0x9e,0x9c,0x00,0xf2,0x48,0x52, michael@0: 0x79,0x72,0xce,0xc5,0x70,0x4c,0x2a,0x5b, michael@0: 0x07,0xb8,0xb3,0xdc,0x38,0xec,0xc4,0xeb, michael@0: 0xae,0x97,0xdd,0xd8,0x7f,0x3d,0x89,0x85 }; michael@0: unsigned char buf[1000]; michael@0: (void) PORT_Memset(buf, 'a', sizeof(buf)); michael@0: michael@0: return test_long_message(initCtx, HASH_AlgSHA384, michael@0: SHA384_LENGTH, &expected[0], results); michael@0: } michael@0: michael@0: static int test_long_message_sha512(NSSLOWInitContext *initCtx) { michael@0: PRUint8 results[SHA512_LENGTH]; michael@0: /* Test vector from FIPS 180-2: appendix B.3. */ michael@0: static const PRUint8 expected[SHA512_LENGTH] = michael@0: { 0xe7,0x18,0x48,0x3d,0x0c,0xe7,0x69,0x64,0x4e,0x2e,0x42,0xc7,0xbc,0x15,0xb4,0x63, michael@0: 0x8e,0x1f,0x98,0xb1,0x3b,0x20,0x44,0x28,0x56,0x32,0xa8,0x03,0xaf,0xa9,0x73,0xeb, michael@0: 0xde,0x0f,0xf2,0x44,0x87,0x7e,0xa6,0x0a,0x4c,0xb0,0x43,0x2c,0xe5,0x77,0xc3,0x1b, michael@0: 0xeb,0x00,0x9c,0x5c,0x2c,0x49,0xaa,0x2e,0x4e,0xad,0xb2,0x17,0xad,0x8c,0xc0,0x9b}; michael@0: unsigned char buf[1000]; michael@0: (void) PORT_Memset(buf, 'a', sizeof(buf)); michael@0: michael@0: return test_long_message(initCtx, HASH_AlgSHA512, michael@0: SHA512_LENGTH, &expected[0], results); michael@0: } michael@0: michael@0: michael@0: static int testMessageDigest(NSSLOWInitContext *initCtx, michael@0: HASH_HashType algoType, unsigned int hashLen, michael@0: const unsigned char *message, michael@0: const PRUint8 expected[], PRUint8 results[]) michael@0: { michael@0: NSSLOWHASHContext *ctx; michael@0: unsigned int len; michael@0: int rv = 0; michael@0: michael@0: ctx = NSSLOWHASH_NewContext(initCtx, algoType); michael@0: if (ctx == NULL) { michael@0: SECU_PrintError(progName, "Couldn't get hash context\n"); michael@0: return 1; michael@0: } michael@0: michael@0: NSSLOWHASH_Begin(ctx); michael@0: NSSLOWHASH_Update(ctx, message, PORT_Strlen((const char *)message)); michael@0: NSSLOWHASH_End(ctx, results, &len, hashLen); michael@0: PR_ASSERT(len == hashLen); michael@0: PR_ASSERT(PORT_Memcmp(expected, results, len) == 0); michael@0: michael@0: if (PORT_Memcmp(expected, results, len) != 0) { michael@0: SECU_PrintError(progName, "Hash mismatch\n"); michael@0: SECU_PrintBuf(stdout, "Expected: ", expected, hashLen); michael@0: SECU_PrintBuf(stdout, "Actual: ", results, len); michael@0: rv = 1; michael@0: } michael@0: michael@0: NSSLOWHASH_Destroy(ctx); michael@0: NSSLOW_Shutdown(initCtx); michael@0: michael@0: return rv; michael@0: } michael@0: michael@0: michael@0: static int testMD5(NSSLOWInitContext *initCtx) michael@0: { michael@0: /* test vectors that glibc, our API main client, uses */ michael@0: michael@0: static const struct { michael@0: const unsigned char *input; michael@0: const PRUint8 result[MD5_LENGTH]; michael@0: } md5tests[] = { michael@0: { (unsigned char *) "", michael@0: {0xd4,0x1d,0x8c,0xd9,0x8f,0x00,0xb2,0x04,0xe9,0x80,0x09,0x98,0xec,0xf8,0x42,0x7e} }, michael@0: { (unsigned char *) "a", michael@0: {0x0c,0xc1,0x75,0xb9,0xc0,0xf1,0xb6,0xa8,0x31,0xc3,0x99,0xe2,0x69,0x77,0x26,0x61} }, michael@0: { (unsigned char *) "abc", michael@0: {0x90,0x01,0x50,0x98,0x3c,0xd2,0x4f,0xb0,0xd6,0x96,0x3f,0x7d,0x28,0xe1,0x7f,0x72} }, michael@0: { (unsigned char *) "message digest", michael@0: {0xf9,0x6b,0x69,0x7d,0x7c,0xb7,0x93,0x8d,0x52,0x5a,0x2f,0x31,0xaa,0xf1,0x61,0xd0} }, michael@0: { (unsigned char *) "abcdefghijklmnopqrstuvwxyz", michael@0: {0xc3,0xfc,0xd3,0xd7,0x61,0x92,0xe4,0x00,0x7d,0xfb,0x49,0x6c,0xca,0x67,0xe1,0x3b} }, michael@0: { (unsigned char *) "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", michael@0: {0xd1,0x74,0xab,0x98,0xd2,0x77,0xd9,0xf5,0xa5,0x61,0x1c,0x2c,0x9f,0x41,0x9d,0x9f} }, michael@0: { (unsigned char *) "123456789012345678901234567890123456789012345678901234567890" michael@0: "12345678901234567890", michael@0: {0x57,0xed,0xf4,0xa2,0x2b,0xe3,0xc9,0x55,0xac,0x49,0xda,0x2e,0x21,0x07,0xb6,0x7a} } michael@0: }; michael@0: PRUint8 results[MD5_LENGTH]; michael@0: int rv = 0, cnt, numTests; michael@0: michael@0: numTests = sizeof(md5tests)/sizeof(md5tests[0]); michael@0: for (cnt = 0; cnt < numTests; cnt++) { michael@0: rv += testMessageDigest(initCtx, HASH_AlgMD5, MD5_LENGTH, michael@0: (const unsigned char *) md5tests[cnt].input, michael@0: md5tests[cnt].result, &results[0]); michael@0: } michael@0: return rv; michael@0: } michael@0: michael@0: /* michael@0: * Tests with test vectors from FIPS 180-2 Appendixes B.1, B.2, B.3, C, and D michael@0: * michael@0: */ michael@0: michael@0: static int testSHA1(NSSLOWInitContext *initCtx) michael@0: { michael@0: static const struct { michael@0: const unsigned char *input; michael@0: const PRUint8 result[SHA1_LENGTH]; michael@0: } sha1tests[] = { michael@0: /* one block messsage */ michael@0: { (const unsigned char *) michael@0: "abc", michael@0: /* a9993e36 4706816a ba3e2571 7850c26c 9cd0d89d. */ michael@0: michael@0: { 0xa9,0x99,0x3e,0x36, 0x47,0x06,0x81,0x6a, /* a9993e36 4706816a */ michael@0: 0xba,0x3e,0x25,0x71, /* ba3e2571 */ michael@0: 0x78,0x50,0xc2,0x6c, 0x9c,0xd0,0xd8,0x9d} /* 7850c26c 9cd0d89d */ michael@0: }, michael@0: { (const unsigned char *) michael@0: "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq", michael@0: /* 84983e44 1c3bd26e baae4aa1 f95129e5 e54670f1. */ michael@0: {0x84,0x98,0x3e,0x44, 0x1c,0x3b,0xd2,0x6e, 0xba,0xae,0x4a,0xa1, michael@0: 0xf9,0x51,0x29,0xe5, 0xe5,0x46,0x70,0xf1} michael@0: } michael@0: }; michael@0: michael@0: PRUint8 results[SHA1_LENGTH]; michael@0: int rv = 0, cnt, numTests; michael@0: michael@0: numTests = sizeof(sha1tests)/sizeof(sha1tests[0]); michael@0: for (cnt = 0; cnt < numTests; cnt++) { michael@0: rv += testMessageDigest(initCtx, HASH_AlgSHA1, SHA1_LENGTH, michael@0: (const unsigned char *) sha1tests[cnt].input, michael@0: sha1tests[cnt].result, &results[0]); michael@0: } michael@0: michael@0: rv += test_long_message_sha1(initCtx); michael@0: return rv; michael@0: } michael@0: michael@0: static int testSHA224(NSSLOWInitContext *initCtx) michael@0: { michael@0: static const struct { michael@0: const unsigned char *input; michael@0: const PRUint8 result[SHA224_LENGTH]; michael@0: } sha224tests[] = { michael@0: /* one block messsage */ michael@0: { (const unsigned char *) "abc", michael@0: {0x23,0x09,0x7D,0x22,0x34,0x05,0xD8,0x22,0x86,0x42,0xA4,0x77,0xBD,0xA2,0x55,0xB3, michael@0: 0x2A,0xAD,0xBC,0xE4,0xBD,0xA0,0xB3,0xF7,0xE3,0x6C,0x9D,0xA7} michael@0: }, michael@0: /* two block message */ michael@0: { (const unsigned char *) "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq", michael@0: {0x75,0x38,0x8B,0x16,0x51,0x27,0x76,0xCC,0x5D,0xBA,0x5D,0xA1,0xFD,0x89,0x01,0x50, michael@0: 0xB0,0xC6,0x45,0x5C,0xB4,0xF5,0x8B,0x19,0x52,0x52,0x25,0x25} michael@0: } michael@0: }; michael@0: michael@0: PRUint8 results[SHA224_LENGTH]; michael@0: int rv = 0, cnt, numTests; michael@0: michael@0: numTests = sizeof(sha224tests)/sizeof(sha224tests[0]); michael@0: for (cnt = 0; cnt < numTests; cnt++) { michael@0: rv += testMessageDigest(initCtx, HASH_AlgSHA224, SHA224_LENGTH, michael@0: (const unsigned char *) sha224tests[cnt].input, michael@0: sha224tests[cnt].result, &results[0]); michael@0: } michael@0: michael@0: return rv; michael@0: } michael@0: michael@0: static int testSHA256(NSSLOWInitContext *initCtx) michael@0: { michael@0: static const struct { michael@0: const unsigned char *input; michael@0: const PRUint8 result[SHA256_LENGTH]; michael@0: } sha256tests[] = { michael@0: /* Test vectors from FIPS 180-2: appendix B.1. */ michael@0: { (unsigned char *) "abc", michael@0: {0xba,0x78,0x16,0xbf,0x8f,0x01,0xcf,0xea,0x41,0x41,0x40,0xde,0x5d,0xae,0x22,0x23, michael@0: 0xb0,0x03,0x61,0xa3,0x96,0x17,0x7a,0x9c,0xb4,0x10,0xff,0x61,0xf2,0x00,0x15,0xad} michael@0: }, michael@0: /* Test vectors from FIPS 180-2: appendix B.2. */ michael@0: { (unsigned char *) "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq", michael@0: {0x24,0x8d,0x6a,0x61,0xd2,0x06,0x38,0xb8,0xe5,0xc0,0x26,0x93,0x0c,0x3e,0x60,0x39, michael@0: 0xa3,0x3c,0xe4,0x59,0x64,0xff,0x21,0x67,0xf6,0xec,0xed,0xd4,0x19,0xdb,0x06,0xc1} michael@0: } michael@0: }; michael@0: michael@0: PRUint8 results[SHA256_LENGTH]; michael@0: int rv = 0, cnt, numTests; michael@0: michael@0: numTests = sizeof(sha256tests)/sizeof(sha256tests[0]); michael@0: for (cnt = 0; cnt < numTests; cnt++) { michael@0: rv += testMessageDigest(initCtx, HASH_AlgSHA256, SHA256_LENGTH, michael@0: (const unsigned char *) sha256tests[cnt].input, michael@0: sha256tests[cnt].result, &results[0]); michael@0: } michael@0: michael@0: rv += test_long_message_sha256(initCtx); michael@0: return rv; michael@0: } michael@0: michael@0: static int testSHA384(NSSLOWInitContext *initCtx) michael@0: { michael@0: static const struct { michael@0: const unsigned char *input; michael@0: const PRUint8 result[SHA384_LENGTH]; michael@0: } sha384tests[] = { michael@0: /* Test vector from FIPS 180-2: appendix D, single-block message. */ michael@0: { (unsigned char *) "abc", michael@0: {0xcb,0x00,0x75,0x3f,0x45,0xa3,0x5e,0x8b, michael@0: 0xb5,0xa0,0x3d,0x69,0x9a,0xc6,0x50,0x07, michael@0: 0x27,0x2c,0x32,0xab,0x0e,0xde,0xd1,0x63, michael@0: 0x1a,0x8b,0x60,0x5a,0x43,0xff,0x5b,0xed, michael@0: 0x80,0x86,0x07,0x2b,0xa1,0xe7,0xcc,0x23, michael@0: 0x58,0xba,0xec,0xa1,0x34,0xc8,0x25,0xa7} }, michael@0: michael@0: /* Test vectors from FIPS 180-2: appendix D, multi-block message. */ michael@0: { (unsigned char *) michael@0: "abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmn" michael@0: "hijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu", michael@0: /* michael@0: 09330c33f71147e8 michael@0: 3d192fc782cd1b47 michael@0: 53111b173b3b05d2 michael@0: 2fa08086e3b0f712 michael@0: fcc7c71a557e2db9 michael@0: 66c3e9fa91746039. michael@0: */ michael@0: {0x09,0x33,0x0c,0x33,0xf7,0x11,0x47,0xe8, michael@0: 0x3d,0x19,0x2f,0xc7,0x82,0xcd,0x1b,0x47, michael@0: 0x53,0x11,0x1b,0x17,0x3b,0x3b,0x05,0xd2, michael@0: 0x2f,0xa0,0x80,0x86,0xe3,0xb0,0xf7,0x12, michael@0: 0xfc,0xc7,0xc7,0x1a,0x55,0x7e,0x2d,0xb9, michael@0: 0x66,0xc3,0xe9,0xfa,0x91,0x74,0x60,0x39} } michael@0: }; michael@0: michael@0: PRUint8 results[SHA384_LENGTH]; michael@0: int rv = 0, cnt, numTests; michael@0: michael@0: numTests = sizeof(sha384tests)/sizeof(sha384tests[0]); michael@0: for (cnt = 0; cnt < numTests; cnt++) { michael@0: rv += testMessageDigest(initCtx, HASH_AlgSHA384, SHA384_LENGTH, michael@0: (const unsigned char *) sha384tests[cnt].input, michael@0: sha384tests[cnt].result, &results[0]); michael@0: } michael@0: rv += test_long_message_sha384(initCtx); michael@0: michael@0: return rv; michael@0: } michael@0: michael@0: michael@0: int testSHA512(NSSLOWInitContext *initCtx) michael@0: { michael@0: static const struct { michael@0: const unsigned char *input; michael@0: const PRUint8 result[SHA512_LENGTH]; michael@0: } sha512tests[] = { michael@0: /* Test vectors from FIPS 180-2: appendix C.1. */ michael@0: { (unsigned char *) "abc", michael@0: { 0xdd,0xaf,0x35,0xa1,0x93,0x61,0x7a,0xba,0xcc,0x41,0x73,0x49,0xae,0x20,0x41,0x31, michael@0: 0x12,0xe6,0xfa,0x4e,0x89,0xa9,0x7e,0xa2,0x0a,0x9e,0xee,0xe6,0x4b,0x55,0xd3,0x9a, michael@0: 0x21,0x92,0x99,0x2a,0x27,0x4f,0xc1,0xa8,0x36,0xba,0x3c,0x23,0xa3,0xfe,0xeb,0xbd, michael@0: 0x45,0x4d,0x44,0x23,0x64,0x3c,0xe8,0x0e,0x2a,0x9a,0xc9,0x4f,0xa5,0x4c,0xa4,0x9f} michael@0: }, michael@0: /* Test vectors from FIPS 180-2: appendix C.2. */ michael@0: { (unsigned char *) "abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmn" michael@0: "hijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu", michael@0: {0x8e,0x95,0x9b,0x75,0xda,0xe3,0x13,0xda,0x8c,0xf4,0xf7,0x28,0x14,0xfc,0x14,0x3f, michael@0: 0x8f,0x77,0x79,0xc6,0xeb,0x9f,0x7f,0xa1,0x72,0x99,0xae,0xad,0xb6,0x88,0x90,0x18, michael@0: 0x50,0x1d,0x28,0x9e,0x49,0x00,0xf7,0xe4,0x33,0x1b,0x99,0xde,0xc4,0xb5,0x43,0x3a, michael@0: 0xc7,0xd3,0x29,0xee,0xb6,0xdd,0x26,0x54,0x5e,0x96,0xe5,0x5b,0x87,0x4b,0xe9,0x09} michael@0: } michael@0: }; michael@0: michael@0: PRUint8 results[SHA512_LENGTH]; michael@0: int rv = 0, cnt, numTests; michael@0: michael@0: numTests = sizeof(sha512tests)/sizeof(sha512tests[0]); michael@0: for (cnt = 0; cnt < numTests; cnt++) { michael@0: rv = testMessageDigest(initCtx, HASH_AlgSHA512, SHA512_LENGTH, michael@0: (const unsigned char *) sha512tests[cnt].input, michael@0: sha512tests[cnt].result, &results[0]); michael@0: } michael@0: rv += test_long_message_sha512(initCtx); michael@0: return rv; michael@0: } michael@0: michael@0: static void michael@0: Usage(char *progName) michael@0: { michael@0: fprintf(stderr, "Usage: %s [algorithm]\n", michael@0: progName); michael@0: fprintf(stderr, "algorithm must be one of %s\n", michael@0: "{ MD5 | SHA1 | SHA224 | SHA256 | SHA384 | SHA512 }"); michael@0: fprintf(stderr, "default is to test all\n"); michael@0: exit(-1); michael@0: } michael@0: michael@0: int main(int argc, char **argv) michael@0: { michael@0: NSSLOWInitContext *initCtx; michael@0: int rv = 0; /* counts the number of failures */ michael@0: michael@0: progName = strrchr(argv[0], '/'); michael@0: progName = progName ? progName+1 : argv[0]; michael@0: michael@0: initCtx = NSSLOW_Init(); michael@0: if (initCtx == NULL) { michael@0: SECU_PrintError(progName, "Couldn't initialize for hashing\n"); michael@0: return 1; michael@0: } michael@0: michael@0: if (argc || !argv[1] || strlen(argv[1]) == 0) { michael@0: rv += testMD5(initCtx); michael@0: rv += testSHA1(initCtx); michael@0: rv += testSHA224(initCtx); michael@0: rv += testSHA256(initCtx); michael@0: rv += testSHA384(initCtx); michael@0: rv += testSHA512(initCtx); michael@0: } else if (strcmp(argv[1], "MD5") == 0) { michael@0: rv += testMD5(initCtx); michael@0: } else if (strcmp(argv[1], "SHA1") == 0) { michael@0: rv += testSHA1(initCtx); michael@0: } else if (strcmp(argv[1], "SHA224") == 0) { michael@0: rv += testSHA224(initCtx); michael@0: } else if (strcmp(argv[1], "SHA226") == 0) { michael@0: rv += testSHA256(initCtx); michael@0: } else if (strcmp(argv[1], "SHA384") == 0) { michael@0: rv += testSHA384(initCtx); michael@0: } else if (strcmp(argv[1], "SHA512") == 0) { michael@0: rv += testSHA512(initCtx); michael@0: } else { michael@0: SECU_PrintError(progName, "Unsupported hash type %s\n", argv[0]); michael@0: Usage(progName); michael@0: } michael@0: michael@0: NSSLOW_Shutdown(initCtx); michael@0: michael@0: return (rv == 0) ? 0 : 1; michael@0: } michael@0: