6f65ffc
diff -up openssl-1.0.0/crypto/fips/fips.c.sha2test openssl-1.0.0/crypto/fips/fips.c
6f65ffc
--- openssl-1.0.0/crypto/fips/fips.c.sha2test	2011-09-12 15:07:42.000000000 +0200
6f65ffc
+++ openssl-1.0.0/crypto/fips/fips.c	2011-09-26 11:03:17.000000000 +0200
6f65ffc
@@ -163,6 +163,7 @@ int FIPS_selftest()
6f65ffc
     {
6f65ffc
 
6f65ffc
     return FIPS_selftest_sha1()
6f65ffc
+	&& FIPS_selftest_sha2()
6f65ffc
 	&& FIPS_selftest_hmac()
6f65ffc
 	&& FIPS_selftest_aes()
6f65ffc
 	&& FIPS_selftest_des()
6f65ffc
@@ -323,6 +324,8 @@ FIPSCHECK_verify(const char *libname, co
6f65ffc
 		return 0;
6f65ffc
 
6f65ffc
 	hmacpath = make_hmac_path(path);
6f65ffc
+	if (hmacpath == NULL)
6f65ffc
+		return 0;
6f65ffc
 
6f65ffc
 	hf = fopen(hmacpath, "r");
6f65ffc
 	if (hf == NULL) {
6f65ffc
@@ -627,6 +630,45 @@ int fips_cipher_test(EVP_CIPHER_CTX *ctx
6f65ffc
 	return 1;
6f65ffc
 	}
6f65ffc
 
6f65ffc
+static const unsigned char msg_sha256[] = { 0xfa, 0x48, 0x59, 0x2a, 0xe1, 0xae, 0x1f, 0x30,
6f65ffc
+					    0xfc };
6f65ffc
+static const unsigned char dig_sha256[] = { 0xf7, 0x26, 0xd8, 0x98, 0x47, 0x91, 0x68, 0x5b,
6f65ffc
+					    0x9e, 0x39, 0xb2, 0x58, 0xbb, 0x75, 0xbf, 0x01,
6f65ffc
+					    0x17, 0x0c, 0x84, 0x00, 0x01, 0x7a, 0x94, 0x83,
6f65ffc
+					    0xf3, 0x0b, 0x15, 0x84, 0x4b, 0x69, 0x88, 0x8a };
6f65ffc
+
6f65ffc
+static const unsigned char msg_sha512[] = { 0x37, 0xd1, 0x35, 0x9d, 0x18, 0x41, 0xe9, 0xb7,
6f65ffc
+					    0x6d, 0x9a, 0x13, 0xda, 0x5f, 0xf3, 0xbd };
6f65ffc
+static const unsigned char dig_sha512[] = { 0x11, 0x13, 0xc4, 0x19, 0xed, 0x2b, 0x1d, 0x16,
6f65ffc
+					    0x11, 0xeb, 0x9b, 0xbe, 0xf0, 0x7f, 0xcf, 0x44,
6f65ffc
+					    0x8b, 0xd7, 0x57, 0xbd, 0x8d, 0xa9, 0x25, 0xb0,
6f65ffc
+					    0x47, 0x25, 0xd6, 0x6c, 0x9a, 0x54, 0x7f, 0x8f,
6f65ffc
+					    0x0b, 0x53, 0x1a, 0x10, 0x68, 0x32, 0x03, 0x38,
6f65ffc
+					    0x82, 0xc4, 0x87, 0xc4, 0xea, 0x0e, 0xd1, 0x04,
6f65ffc
+					    0xa9, 0x98, 0xc1, 0x05, 0xa3, 0xf3, 0xf8, 0xb1,
6f65ffc
+					    0xaf, 0xbc, 0xd9, 0x78, 0x7e, 0xee, 0x3d, 0x43 };
6f65ffc
+
6f65ffc
+int FIPS_selftest_sha2(void)
6f65ffc
+	{
6f65ffc
+	unsigned char md[SHA512_DIGEST_LENGTH];
6f65ffc
+
6f65ffc
+	EVP_Digest(msg_sha256, sizeof(msg_sha256), md, NULL, EVP_sha256(), NULL);
6f65ffc
+	if(memcmp(dig_sha256, md, sizeof(dig_sha256)))
6f65ffc
+		{
6f65ffc
+		FIPSerr(FIPS_F_FIPS_MODE_SET, FIPS_R_SELFTEST_FAILED);
6f65ffc
+		return 0;
6f65ffc
+		}
6f65ffc
+
6f65ffc
+	EVP_Digest(msg_sha512, sizeof(msg_sha512), md, NULL, EVP_sha512(), NULL);
6f65ffc
+	if(memcmp(dig_sha512, md, sizeof(dig_sha512)))
6f65ffc
+		{
6f65ffc
+		FIPSerr(FIPS_F_FIPS_MODE_SET, FIPS_R_SELFTEST_FAILED);
6f65ffc
+		return 0;
6f65ffc
+		}
6f65ffc
+
6f65ffc
+	return 1;
6f65ffc
+	}
6f65ffc
+
6f65ffc
 #if 0
6f65ffc
 /* The purpose of this is to ensure the error code exists and the function
6f65ffc
  * name is to keep the error checking script quiet
6f65ffc
diff -up openssl-1.0.0/crypto/fips/fips.h.sha2test openssl-1.0.0/crypto/fips/fips.h
6f65ffc
--- openssl-1.0.0/crypto/fips/fips.h.sha2test	2011-09-12 15:07:42.000000000 +0200
6f65ffc
+++ openssl-1.0.0/crypto/fips/fips.h	2011-09-26 11:00:55.000000000 +0200
6f65ffc
@@ -72,6 +72,7 @@ int FIPS_selftest_failed(void);
6f65ffc
 void FIPS_selftest_check(void);
6f65ffc
 void FIPS_corrupt_sha1(void);
6f65ffc
 int FIPS_selftest_sha1(void);
6f65ffc
+int FIPS_selftest_sha2(void);
6f65ffc
 void FIPS_corrupt_aes(void);
6f65ffc
 int FIPS_selftest_aes(void);
6f65ffc
 void FIPS_corrupt_des(void);