Selftests.
authorBen Laurie <ben@openssl.org>
Thu, 4 Sep 2003 07:17:43 +0000 (07:17 +0000)
committerBen Laurie <ben@openssl.org>
Thu, 4 Sep 2003 07:17:43 +0000 (07:17 +0000)
14 files changed:
fips/aes/Makefile.ssl
fips/aes/fingerprint.sha1
fips/des/Makefile.ssl
fips/des/fingerprint.sha1
fips/des/fips_desmovs.c
fips/dsa/.cvsignore
fips/fingerprint.sha1
fips/fips.c
fips/fips.h
fips/fips_err.c
fips/fips_make_sha1
fips/sha1/.cvsignore
fips/sha1/Makefile.ssl
fips/sha1/fingerprint.sha1

index ddecf55b7034cfef41e09d2a0643b9f06bf59e4d..d5f5a1052a1374ec10f3a42a63b9aa43aa16d4c2 100644 (file)
@@ -23,8 +23,8 @@ TEST=fips_aesavs.c fips_aes_data
 APPS=
 
 LIB=$(TOP)/libcrypto.a
-LIBSRC=fips_aes_core.c
-LIBOBJ=fips_aes_core.o
+LIBSRC=fips_aes_core.c fips_aes_selftest.c
+LIBOBJ=fips_aes_core.o fips_aes_selftest.o
 
 SRC= $(LIBSRC)
 
index 0d4eeddb0ec650edc70b2ad2ad4805a03b7b29ce..807e674403a951cfd46d64cfc827f2401e5a7a40 100644 (file)
@@ -1,2 +1,3 @@
 SHA1(fips_aes_core.c)= 5298df7807877eed470a1ee5f8331fc0876689da
+SHA1(fips_aes_selftest.c)= fb848010c088adbbfaf719ca77c91e8ae0932ce0
 SHA1(fips_aes_locl.h)= a3c01d9a4f9d5211e9e785852f6f1a2febfd73b6
index ea59463b7913a98a0319954c639b9ee1590714c7..acec984a2627627dc6b0a0eaed90dc34720af102 100644 (file)
@@ -23,8 +23,8 @@ TEST= fips_desmovs.c
 APPS=
 
 LIB=$(TOP)/libcrypto.a
-LIBSRC=fips_des_enc.c
-LIBOBJ=fips_des_enc.o
+LIBSRC=fips_des_enc.c fips_des_selftest.c
+LIBOBJ=fips_des_enc.o fips_des_selftest.o
 
 SRC= $(LIBSRC)
 
index 9f6bba874ab4d8a2e53b6b820181eabf66a0b7c5..4d944e0104e830f9cd5db3d7fb32d77515acd3a7 100644 (file)
@@ -1,2 +1,3 @@
 SHA1(fips_des_enc.c)= a4b88bb16782604a298d74de04a8b3bc3a204c5a
+SHA1(fips_des_selftest.c)= 5638ae4d50be6110d9efbaa5e7e19c7e04c9940d
 SHA1(fips_des_locl.h)= 5e5128f074485e72d6fdee00d22d46a694bd5abe
index 473062eab8701b62712992ea8400267964b5950b..c041403cbe161d820ee397d3b53013718a5065b3 100644 (file)
@@ -667,7 +667,11 @@ int main(int argc, char **argv)
     int f_opt = 0, d_opt = 1;
 
 #ifdef FIPS
-    FIPS_mode_set(1);
+    if(!FIPS_mode_set(1))
+       {
+       fprintf(stderr,"Failed to enter FIPS mode.\n");
+       exit(1);
+       }
 #endif
     ERR_load_crypto_strings();
     if (argc > 1)
index 695fdd005921cb0d52d7c7503b8eca2ee18b56e3..e32a5ba02148cea3499f2f0120429f82d6979312 100644 (file)
@@ -1,2 +1,3 @@
 Makefile.save
 lib
+fips_dssvs
index 9b90d65ba0ab071cfe646135e8dd5d4f7d789588..cdee38b17ad8629a638267b442e65daf74c20c03 100644 (file)
@@ -1,4 +1,4 @@
-SHA1(fips.c)= 39f2919005cb5c8d3b806b52d81a9247804dbe64
+SHA1(fips.c)= dfb2a82fcff1ee84b7674d84a0e0bf191cb759f3
 SHA1(fips_err_wrapper.c)= 0cbe881739f6e7d91308e2e74b92032e69007528
-SHA1(fips.h)= 53ce62539f2b69141693d427af9a4c4abc822cd0
-SHA1(fips_err.c)= 197ccc595c33079de87ae02da868808a9ca60648
+SHA1(fips.h)= 5dc66fb941513cb732c51eeca6f44018d4acd7ae
+SHA1(fips_err.c)= 672c470bf38e01ba2a1fa2d52492bc31330dd974
index 440258425c60d048f1a4204e5597610ae218d767..bd12d675913238d066763fc41a709d9f083cffdc 100644 (file)
 
 #ifdef FIPS
 
-void FIPS_mode_set(int onoff)
+int FIPS_selftest()
+    {
+    return FIPS_selftest_sha1()
+       && FIPS_selftest_aes()
+       && FIPS_selftest_des();
+    }
+
+int FIPS_mode_set(int onoff)
     {
     FIPS_mode=onoff;
     if(onoff)
        {
        FIPS_rand_check=&rand_fips_meth;
        RAND_set_rand_method(&rand_fips_meth);
+       return FIPS_selftest();
        }
+    return 1;
     }
 
+
 #if 0
 /* here just to cause error codes to exist */
 static void dummy()
index 020c45b726e894c463bd146d8ab71a8fa3de8add..179489b790078006e0e8aa3b5fbf463f1dd2deef 100644 (file)
@@ -55,8 +55,11 @@ extern int FIPS_mode;
 extern void *FIPS_rand_check;
 struct dsa_st;
 
-void FIPS_mode_set(int onoff);
+int FIPS_mode_set(int onoff);
 int FIPS_dsa_check(struct dsa_st *dsa);
+int FIPS_selftest_sha1(void);
+int FIPS_selftest_aes(void);
+int FIPS_selftest_des(void);
 
 /* The following lines are auto generated by the script mkerr.pl. Any changes
  * made after this point may be overwritten when the script is next run.
@@ -73,11 +76,14 @@ void ERR_load_FIPS_strings(void);
 
 /* Function codes. */
 #define FIPS_F_FIPS_DSA_CHECK                           102
+#define FIPS_F_FIPS_SELFTEST_AES                        104
+#define FIPS_F_FIPS_SELFTEST_SHA1                       103
 #define FIPS_F_HASH_FINAL                               100
 #define FIPS_F_SSLEAY_RAND_BYTES                        101
 
 /* Reason codes. */
 #define FIPS_R_NON_FIPS_METHOD                          100
+#define FIPS_R_SELFTEST_FAILED                          101
 
 #ifdef  __cplusplus
 }
index 6f67161668d9ea96dcaee2683357ce51ad8884cb..d9c55d37aa52310b71a3a1719071dec4c719c5c6 100644 (file)
@@ -1,6 +1,6 @@
 /* fips/fips_err.c */
 /* ====================================================================
- * Copyright (c) 1999-2002 The OpenSSL Project.  All rights reserved.
+ * Copyright (c) 1999-2003 The OpenSSL Project.  All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -67,6 +67,8 @@
 static ERR_STRING_DATA FIPS_str_functs[]=
        {
 {ERR_PACK(0,FIPS_F_FIPS_DSA_CHECK,0),  "FIPS_dsa_check"},
+{ERR_PACK(0,FIPS_F_FIPS_SELFTEST_AES,0),       "FIPS_selftest_aes"},
+{ERR_PACK(0,FIPS_F_FIPS_SELFTEST_SHA1,0),      "FIPS_selftest_sha1"},
 {ERR_PACK(0,FIPS_F_HASH_FINAL,0),      "HASH_FINAL"},
 {ERR_PACK(0,FIPS_F_SSLEAY_RAND_BYTES,0),       "SSLEAY_RAND_BYTES"},
 {0,NULL}
@@ -75,6 +77,7 @@ static ERR_STRING_DATA FIPS_str_functs[]=
 static ERR_STRING_DATA FIPS_str_reasons[]=
        {
 {FIPS_R_NON_FIPS_METHOD                  ,"non fips method"},
+{FIPS_R_SELFTEST_FAILED                  ,"selftest failed"},
 {0,NULL}
        };
 
index 7cb167591ba874b06b019047362d6cab0dc5f730..8d5d72fcd52b2b69ab2e942f378a0fd97f6ba71b 100755 (executable)
@@ -12,13 +12,13 @@ cd rand
 $S fips_rand.c fips_rand.h > fingerprint.sha1
 
 cd ../sha1
-$S fips_sha1dgst.c fips_sha_locl.h fips_md32_common.h > fingerprint.sha1
+$S fips_sha1dgst.c fips_sha1_selftest.c fips_sha_locl.h fips_md32_common.h > fingerprint.sha1
 
 cd ../aes
-$S fips_aes_core.c fips_aes_locl.h > fingerprint.sha1
+$S fips_aes_core.c fips_aes_selftest.c fips_aes_locl.h > fingerprint.sha1
 
 cd ../dsa
 $S fips_dsa_ossl.c fips_dsa_gen.c > fingerprint.sha1
 
 cd ../des
-$S fips_des_enc.c fips_des_locl.h > fingerprint.sha1
+$S fips_des_enc.c fips_des_selftest.c fips_des_locl.h > fingerprint.sha1
index 3c65d3f9db049bba4c0188e39f9a461015053f22..ba5158a0fac2d9191d6217bd48b85e62c03e4e9f 100644 (file)
@@ -1,3 +1,4 @@
 Makefile.save
 lib
 fips_standalone_sha1
+fips_sha1test
index 373d11a5f30d6fda9722c7027fb814fc2d1eebe9..fcb4d165bd833f8155d9d37b99efc42deb12c960 100644 (file)
@@ -24,8 +24,8 @@ APPS=
 EXE= fips_standalone_sha1
 
 LIB=$(TOP)/libcrypto.a
-LIBSRC=fips_sha1dgst.c
-LIBOBJ=fips_sha1dgst.o
+LIBSRC=fips_sha1dgst.c fips_sha1_selftest.c
+LIBOBJ=fips_sha1dgst.o fips_sha1_selftest.o
 
 SRC= $(LIBSRC) fips_standalone_sha1.c
 
index 658fab3f61ca16f386564176e0c4d9cfd839c187..ec4a6206985a79fb591bab304259a777c6f8b1ee 100644 (file)
@@ -1,3 +1,4 @@
 SHA1(fips_sha1dgst.c)= 609e2cbf5d3cdcf318ec10238a0e82b93b78e6b5
+SHA1(fips_sha1_selftest.c)= d1becdceec9f08d2cd9ab22238a3f5941a98dd01
 SHA1(fips_sha_locl.h)= 677427c495b571991f013939ea7e5dea87828f8c
 SHA1(fips_md32_common.h)= 4f41bcde24750b3b8c99a06bcba2fe06ff8db4d0