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