Blame SOURCES/openssl-fips-0.9.8e-sha2test.patch

c4366c
diff -up openssl-fips-0.9.8e/fips/fips.c.sha2test openssl-fips-0.9.8e/fips/fips.c
c4366c
--- openssl-fips-0.9.8e/fips/fips.c.sha2test	2011-04-04 16:40:28.000000000 +0200
c4366c
+++ openssl-fips-0.9.8e/fips/fips.c	2011-10-18 16:30:21.000000000 +0200
c4366c
@@ -56,6 +56,7 @@
c4366c
 #include <openssl/bio.h>
c4366c
 #include <openssl/hmac.h>
c4366c
 #include <openssl/rsa.h>
c4366c
+#include <openssl/sha.h>
c4366c
 #include <string.h>
c4366c
 #include <limits.h>
c4366c
 #include <dlfcn.h>
c4366c
@@ -161,6 +162,7 @@ int FIPS_selftest()
c4366c
     {
c4366c
 
c4366c
     return FIPS_selftest_sha1()
c4366c
+	&& FIPS_selftest_sha2()
c4366c
 	&& FIPS_selftest_hmac()
c4366c
 	&& FIPS_selftest_aes()
c4366c
 	&& FIPS_selftest_des()
c4366c
@@ -401,6 +403,8 @@ FIPSCHECK_verify(const char *libname, co
c4366c
 		return 0;
c4366c
 
c4366c
 	hmacpath = make_hmac_path(path);
c4366c
+	if (hmacpath == NULL)
c4366c
+		return 0;
c4366c
 
c4366c
 	hf = fopen(hmacpath, "r");
c4366c
 	if (hf == NULL) {
c4366c
@@ -712,6 +716,45 @@ int fips_cipher_test(EVP_CIPHER_CTX *ctx
c4366c
 	return 1;
c4366c
 	}
c4366c
 
c4366c
+static const unsigned char msg_sha256[] = { 0xfa, 0x48, 0x59, 0x2a, 0xe1, 0xae, 0x1f, 0x30,
c4366c
+					    0xfc };
c4366c
+static const unsigned char dig_sha256[] = { 0xf7, 0x26, 0xd8, 0x98, 0x47, 0x91, 0x68, 0x5b,
c4366c
+					    0x9e, 0x39, 0xb2, 0x58, 0xbb, 0x75, 0xbf, 0x01,
c4366c
+					    0x17, 0x0c, 0x84, 0x00, 0x01, 0x7a, 0x94, 0x83,
c4366c
+					    0xf3, 0x0b, 0x15, 0x84, 0x4b, 0x69, 0x88, 0x8a };
c4366c
+
c4366c
+static const unsigned char msg_sha512[] = { 0x37, 0xd1, 0x35, 0x9d, 0x18, 0x41, 0xe9, 0xb7,
c4366c
+					    0x6d, 0x9a, 0x13, 0xda, 0x5f, 0xf3, 0xbd };
c4366c
+static const unsigned char dig_sha512[] = { 0x11, 0x13, 0xc4, 0x19, 0xed, 0x2b, 0x1d, 0x16,
c4366c
+					    0x11, 0xeb, 0x9b, 0xbe, 0xf0, 0x7f, 0xcf, 0x44,
c4366c
+					    0x8b, 0xd7, 0x57, 0xbd, 0x8d, 0xa9, 0x25, 0xb0,
c4366c
+					    0x47, 0x25, 0xd6, 0x6c, 0x9a, 0x54, 0x7f, 0x8f,
c4366c
+					    0x0b, 0x53, 0x1a, 0x10, 0x68, 0x32, 0x03, 0x38,
c4366c
+					    0x82, 0xc4, 0x87, 0xc4, 0xea, 0x0e, 0xd1, 0x04,
c4366c
+					    0xa9, 0x98, 0xc1, 0x05, 0xa3, 0xf3, 0xf8, 0xb1,
c4366c
+					    0xaf, 0xbc, 0xd9, 0x78, 0x7e, 0xee, 0x3d, 0x43 };
c4366c
+
c4366c
+int FIPS_selftest_sha2(void)
c4366c
+	{
c4366c
+	unsigned char md[SHA512_DIGEST_LENGTH];
c4366c
+
c4366c
+	EVP_Digest(msg_sha256, sizeof(msg_sha256), md, NULL, EVP_sha256(), NULL);
c4366c
+	if(memcmp(dig_sha256, md, sizeof(dig_sha256)))
c4366c
+		{
c4366c
+		FIPSerr(FIPS_F_FIPS_MODE_SET, FIPS_R_SELFTEST_FAILED);
c4366c
+		return 0;
c4366c
+		}
c4366c
+
c4366c
+	EVP_Digest(msg_sha512, sizeof(msg_sha512), md, NULL, EVP_sha512(), NULL);
c4366c
+	if(memcmp(dig_sha512, md, sizeof(dig_sha512)))
c4366c
+		{
c4366c
+		FIPSerr(FIPS_F_FIPS_MODE_SET, FIPS_R_SELFTEST_FAILED);
c4366c
+		return 0;
c4366c
+		}
c4366c
+
c4366c
+	return 1;
c4366c
+	}
c4366c
+
c4366c
 #if 0
c4366c
 /* The purpose of this is to ensure the error code exists and the function
c4366c
  * name is to keep the error checking script quiet
c4366c
diff -up openssl-fips-0.9.8e/fips/fips.h.sha2test openssl-fips-0.9.8e/fips/fips.h
c4366c
--- openssl-fips-0.9.8e/fips/fips.h.sha2test	2007-09-12 19:46:03.000000000 +0200
c4366c
+++ openssl-fips-0.9.8e/fips/fips.h	2011-09-26 10:43:08.000000000 +0200
c4366c
@@ -68,6 +68,7 @@ int FIPS_selftest_failed(void);
c4366c
 void FIPS_selftest_check(void);
c4366c
 void FIPS_corrupt_sha1(void);
c4366c
 int FIPS_selftest_sha1(void);
c4366c
+int FIPS_selftest_sha2(void);
c4366c
 void FIPS_corrupt_aes(void);
c4366c
 int FIPS_selftest_aes(void);
c4366c
 void FIPS_corrupt_des(void);