summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorwtchang%redhat.com <devnull@localhost>2005-11-07 19:05:45 +0000
committerwtchang%redhat.com <devnull@localhost>2005-11-07 19:05:45 +0000
commit8cc45e71f9fc30fa57743e057f1b678ee163c4e9 (patch)
treee4b5e43cede1fa58c3e11a58695c23ecb81e316f
parentb31eb64545f65147a51975bcd45f933dc025b86a (diff)
downloadnss-hg-8cc45e71f9fc30fa57743e057f1b678ee163c4e9.tar.gz
Bugzilla Bug 298522: added power-up self tests for HMAC SHA-384 and HMAC
SHA-512. The patch was written by Glen Beasley of Sun. r=wtc.
-rw-r--r--security/nss/lib/softoken/fipstest.c52
1 files changed, 52 insertions, 0 deletions
diff --git a/security/nss/lib/softoken/fipstest.c b/security/nss/lib/softoken/fipstest.c
index 2a6876917..acee77676 100644
--- a/security/nss/lib/softoken/fipstest.c
+++ b/security/nss/lib/softoken/fipstest.c
@@ -865,6 +865,26 @@ sftk_fips_HMAC_PowerUpSelfTest( void )
0x1b, 0x92, 0x8a, 0x0c, 0xfe, 0xf5, 0x49, 0xe9,
0xa7, 0x1b, 0x56, 0x7d, 0x1d, 0x29, 0x40, 0x48};
+ /* known SHA384 hmac (48 bytes) */
+ static const PRUint8 known_SHA384_hmac[] = {
+ 0xcd, 0x56, 0x14, 0xec, 0x05, 0x53, 0x06, 0x2b,
+ 0x7e, 0x9c, 0x8a, 0x18, 0x5e, 0xea, 0xf3, 0x91,
+ 0x33, 0xfb, 0x64, 0xf6, 0xe3, 0x9f, 0x89, 0x0b,
+ 0xaf, 0xbe, 0x83, 0x4d, 0x3f, 0x3c, 0x43, 0x4d,
+ 0x4a, 0x0c, 0x56, 0x98, 0xf8, 0xca, 0xb4, 0xaa,
+ 0x9a, 0xf4, 0x0a, 0xaf, 0x4f, 0x69, 0xca, 0x87};
+
+ /* known SHA512 hmac (64 bytes) */
+ static const PRUint8 known_SHA512_hmac[] = {
+ 0xf6, 0x0e, 0x97, 0x12, 0x00, 0x67, 0x6e, 0xb9,
+ 0x0c, 0xb2, 0x63, 0xf0, 0x60, 0xac, 0x75, 0x62,
+ 0x70, 0x95, 0x2a, 0x52, 0x22, 0xee, 0xdd, 0xd2,
+ 0x71, 0xb1, 0xe8, 0x26, 0x33, 0xd3, 0x13, 0x27,
+ 0xcb, 0xff, 0x44, 0xef, 0x87, 0x97, 0x16, 0xfb,
+ 0xd3, 0x0b, 0x48, 0xbe, 0x12, 0x4e, 0xda, 0xb1,
+ 0x89, 0x90, 0xfb, 0x06, 0x0c, 0xbe, 0xe5, 0xc4,
+ 0xff, 0x24, 0x37, 0x3d, 0xc7, 0xe4, 0xe4, 0x37};
+
SECStatus hmac_status;
PRUint8 hmac_computed[HASH_LENGTH_MAX];
@@ -900,6 +920,38 @@ sftk_fips_HMAC_PowerUpSelfTest( void )
SHA256_LENGTH ) != 0 ) )
return( CKR_DEVICE_ERROR );
+ /***************************************************/
+ /* HMAC SHA-384 Single-Round Known Answer Test. */
+ /***************************************************/
+
+ hmac_status = sftk_fips_HMAC(hmac_computed,
+ HMAC_known_secret_key,
+ HMAC_known_secret_key_length,
+ known_hash_message,
+ FIPS_KNOWN_HASH_MESSAGE_LENGTH,
+ HASH_AlgSHA384);
+
+ if( ( hmac_status != SECSuccess ) ||
+ ( PORT_Memcmp( hmac_computed, known_SHA384_hmac,
+ SHA384_LENGTH ) != 0 ) )
+ return( CKR_DEVICE_ERROR );
+
+ /***************************************************/
+ /* HMAC SHA-512 Single-Round Known Answer Test. */
+ /***************************************************/
+
+ hmac_status = sftk_fips_HMAC(hmac_computed,
+ HMAC_known_secret_key,
+ HMAC_known_secret_key_length,
+ known_hash_message,
+ FIPS_KNOWN_HASH_MESSAGE_LENGTH,
+ HASH_AlgSHA512);
+
+ if( ( hmac_status != SECSuccess ) ||
+ ( PORT_Memcmp( hmac_computed, known_SHA512_hmac,
+ SHA512_LENGTH ) != 0 ) )
+ return( CKR_DEVICE_ERROR );
+
return( CKR_OK );
}