FIPS algorithm blocking.
authorDr. Stephen Henson <steve@openssl.org>
Wed, 26 Jan 2005 20:00:40 +0000 (20:00 +0000)
committerDr. Stephen Henson <steve@openssl.org>
Wed, 26 Jan 2005 20:00:40 +0000 (20:00 +0000)
Non FIPS algorithms are not normally allowed in FIPS mode.

Any attempt to use them via high level functions will return an error.

The low level non-FIPS algorithm functions cannot return errors so they
produce assertion failures. HMAC also has to give an assertion error because
it (erroneously) can't return an error either.

There are exceptions (such as MD5 in TLS and non cryptographic use of
algorithms) and applications can override the blocking and use non FIPS
algorithms anyway.

For low level functions the override is perfomed by prefixing the algorithm
initalization function with "private_" for example private_MD5_Init().

For high level functions an override is performed by setting a flag in
the context.

53 files changed:
apps/dgst.c
apps/pkcs12.c
crypto/bf/bf_skey.c
crypto/bf/blowfish.h
crypto/cast/c_skey.c
crypto/cast/cast.h
crypto/crypto.h
crypto/evp/bio_md.c
crypto/evp/digest.c
crypto/evp/e_aes.c
crypto/evp/e_des.c
crypto/evp/e_des3.c
crypto/evp/evp.h
crypto/evp/evp_enc.c
crypto/evp/evp_err.c
crypto/evp/evp_locl.h
crypto/evp/m_dss.c
crypto/evp/m_md2.c
crypto/evp/m_md4.c
crypto/evp/m_md5.c
crypto/evp/m_mdc2.c
crypto/evp/m_sha.c
crypto/evp/m_sha1.c
crypto/evp/names.c
crypto/hmac/hmac.c
crypto/hmac/hmac.h
crypto/idea/i_skey.c
crypto/idea/idea.h
crypto/md2/md2.h
crypto/md2/md2_dgst.c
crypto/md32_common.h
crypto/md4/md4.h
crypto/md4/md4_dgst.c
crypto/md5/md5.h
crypto/md5/md5_dgst.c
crypto/mdc2/mdc2.h
crypto/mdc2/mdc2dgst.c
crypto/rc2/rc2.h
crypto/rc2/rc2_skey.c
crypto/rc4/rc4.h
crypto/rc4/rc4_skey.c
crypto/rc5/rc5.h
crypto/rc5/rc5_skey.c
crypto/ripemd/ripemd.h
crypto/ripemd/rmd_dgst.c
crypto/sha/sha.h
crypto/sha/sha_locl.h
crypto/x509/x509_cmp.c
crypto/x509/x509_vfy.c
ssl/s3_clnt.c
ssl/s3_enc.c
ssl/s3_srvr.c
ssl/t1_enc.c

index ad32877a09d4e92a88cf3a00c8c7c0a3eea1ac38..9106b13fd9bb3bed1890c7fad62ba7bc97ef84c0 100644 (file)
@@ -108,6 +108,7 @@ int MAIN(int argc, char **argv)
        char *engine=NULL;
 #endif
        char *hmac_key=NULL;
+       int non_fips_allow = 0;
 
        apps_startup();
 
@@ -192,6 +193,8 @@ int MAIN(int argc, char **argv)
                        out_bin = 1;
                else if (strcmp(*argv,"-d") == 0)
                        debug=1;
+               else if (strcmp(*argv,"-non-fips-allow") == 0)
+                       non_fips_allow=1;
                else if (!strcmp(*argv,"-hmac"))
                        {
                        if (--argc < 1)
@@ -342,6 +345,13 @@ int MAIN(int argc, char **argv)
                }
        }
 
+       if (non_fips_allow)
+               {
+               EVP_MD_CTX *md_ctx;
+               BIO_get_md_ctx(bmd,&md_ctx);
+               EVP_MD_CTX_set_flags(md_ctx, EVP_MD_CTX_FLAG_NON_FIPS_ALLOW);
+               }
+
        /* we use md as a filter, reading from 'in' */
        if (!BIO_set_md(bmd,md))
                {
index eac28e54d741b0ce7c0eb1937747ac559f713b28..c961e6b57ba7754732353299e14b592b4c1f373e 100644 (file)
@@ -109,7 +109,7 @@ int MAIN(int argc, char **argv)
     int maciter = PKCS12_DEFAULT_ITER;
     int twopass = 0;
     int keytype = 0;
-    int cert_pbe = NID_pbe_WithSHA1And40BitRC2_CBC;
+    int cert_pbe;
     int key_pbe = NID_pbe_WithSHA1And3_Key_TripleDES_CBC;
     int ret = 1;
     int macver = 1;
@@ -126,6 +126,13 @@ int MAIN(int argc, char **argv)
 
     apps_startup();
 
+#ifdef OPENSSL_FIPS
+    if (FIPS_mode())
+       cert_pbe = NID_pbe_WithSHA1And3_Key_TripleDES_CBC;
+    else
+#endif
+    cert_pbe = NID_pbe_WithSHA1And40BitRC2_CBC;
+
     enc = EVP_des_ede3_cbc();
     if (bio_err == NULL ) bio_err = BIO_new_fp (stderr, BIO_NOCLOSE);
 
index 3673cdee6e26172c78a3de35da48eb62b4e26dee..fc5bebefce4b1c6f6ab8cac316f1fa9c6ea44d77 100644 (file)
 
 #include <stdio.h>
 #include <string.h>
+#include <openssl/crypto.h>
 #include <openssl/blowfish.h>
 #include "bf_locl.h"
 #include "bf_pi.h"
 
-void BF_set_key(BF_KEY *key, int len, const unsigned char *data)
+FIPS_NON_FIPS_VCIPHER_Init(BF)
        {
        int i;
        BF_LONG *p,ri,in[2];
index cd49e85ab29a53c1ee48459fd193061f548ae936..b4d87749619083793086d559784f765f3c5fec9d 100644 (file)
@@ -104,7 +104,10 @@ typedef struct bf_key_st
        BF_LONG S[4*256];
        } BF_KEY;
 
+
+#ifdef OPENSSL_FIPS 
+void private_BF_set_key(BF_KEY *key, int len, const unsigned char *data);
+#endif
 void BF_set_key(BF_KEY *key, int len, const unsigned char *data);
 
 void BF_encrypt(BF_LONG *data,const BF_KEY *key);
index 76e40005c998373141a3f2728786adbcd714b4a4..dc4791a8cff9b657feb213bfc82076731b304756 100644 (file)
@@ -56,7 +56,9 @@
  * [including the GNU Public Licence.]
  */
 
+#include <openssl/crypto.h>
 #include <openssl/cast.h>
+
 #include "cast_lcl.h"
 #include "cast_s.h"
 
@@ -72,7 +74,7 @@
 #define S6 CAST_S_table6
 #define S7 CAST_S_table7
 
-void CAST_set_key(CAST_KEY *key, int len, const unsigned char *data)
+FIPS_NON_FIPS_VCIPHER_Init(CAST)
        {
        CAST_LONG x[16];
        CAST_LONG z[16];
index b28e4e4f3b3c969ddfc666c981f7b7b65221f575..9e300178d90e3f418efa07e2e7b8df563e316d04 100644 (file)
@@ -81,7 +81,10 @@ typedef struct cast_key_st
        int short_key;  /* Use reduced rounds for short key */
        } CAST_KEY;
 
+
+#ifdef OPENSSL_FIPS 
+void private_CAST_set_key(CAST_KEY *key, int len, const unsigned char *data);
+#endif
 void CAST_set_key(CAST_KEY *key, int len, const unsigned char *data);
 void CAST_ecb_encrypt(const unsigned char *in,unsigned char *out,CAST_KEY *key,
                      int enc);
index b779a14d12f10feece4af82f2e00f282d3be9747..383090c327babc0e9353c0cc591f5b4c56a303c3 100644 (file)
@@ -439,6 +439,55 @@ void OpenSSLDie(const char *file,int line,const char *assertion);
 #ifdef OPENSSL_FIPS
 int FIPS_mode(void);
 void *FIPS_rand_check(void);
+
+#define FIPS_BAD_ABORT(alg) OpenSSLDie(__FILE__, __LINE__, \
+               #alg " Algorithm forbidden in FIPS mode");
+
+#ifdef OPENSSL_FIPS_STRICT
+#define FIPS_BAD_ALGORITHM(alg) FIPS_BAD_ABORT(alg)
+#else
+#define FIPS_BAD_ALGORITHM(alg) \
+       { \
+       FIPSerr(FIPS_F_HASH_FINAL,FIPS_R_NON_FIPS_METHOD); \
+       ERR_add_error_data(2, "Algorithm=", #alg); \
+       return 0; \
+       }
+#endif
+
+/* Low level digest API blocking macro */
+
+#define FIPS_NON_FIPS_MD_Init(alg) \
+       int alg##_Init(alg##_CTX *c) \
+               { \
+               if (FIPS_mode()) \
+                       FIPS_BAD_ALGORITHM(alg) \
+               return private_##alg##_Init(c); \
+               } \
+       int private_##alg##_Init(alg##_CTX *c)
+
+/* For ciphers the API often varies from cipher to cipher and each needs to
+ * be treated as a special case. Variable key length ciphers (Blowfish, RC4,
+ * CAST) however are very similar and can use a blocking macro.
+ */
+
+#define FIPS_NON_FIPS_VCIPHER_Init(alg) \
+       void alg##_set_key(alg##_KEY *key, int len, const unsigned char *data) \
+               { \
+               if (FIPS_mode()) \
+                       FIPS_BAD_ABORT(alg) \
+               private_##alg##_set_key(key, len, data); \
+               } \
+       void private_##alg##_set_key(alg##_KEY *key, int len, \
+                                       const unsigned char *data)
+
+#else
+
+#define FIPS_NON_FIPS_VCIPHER_Init(alg) \
+       void alg##_set_key(alg##_KEY *key, int len, const unsigned char *data)
+
+#define FIPS_NON_FIPS_MD_Init(alg) \
+       int alg##_Init(alg##_CTX *c) 
+
 #endif /* def OPENSSL_FIPS */
 
 /* BEGIN ERROR CODES */
index e4a4d663cb2e18a50648bd30e11b3773c0978763..f4aa41ac4b4fc85678a1d08c094c800fdce89015 100644 (file)
@@ -192,13 +192,8 @@ static long md_ctrl(BIO *b, int cmd, long num, void *ptr)
                        ret=0;
                break;
        case BIO_C_GET_MD_CTX:
-               if (b->init)
-                       {
-                       pctx=ptr;
-                       *pctx=ctx;
-                       }
-               else
-                       ret=0;
+               pctx=ptr;
+               *pctx=ctx;
                break;
        case BIO_C_SET_MD_CTX:
                if (b->init)
index 0623ddf1f05f87c7f6929839d0334e974475ed1f..2b6480fddc36555109b7831a43b871e353c7f146 100644 (file)
@@ -195,6 +195,17 @@ int EVP_DigestInit_ex(EVP_MD_CTX *ctx, const EVP_MD *type, ENGINE *impl)
 #endif
        if (ctx->digest != type)
                {
+#ifdef OPENSSL_FIPS
+               if (FIPS_mode())
+                       {
+                       if (!(type->flags & EVP_MD_FLAG_FIPS) 
+                        && !(ctx->flags & EVP_MD_CTX_FLAG_NON_FIPS_ALLOW))
+                               {
+                               EVPerr(EVP_F_EVP_DIGESTINIT, EVP_R_DISABLED_FOR_FIPS);
+                               return 0;
+                               }
+                       }
+#endif
                if (ctx->digest && ctx->digest->ctx_size)
                        OPENSSL_free(ctx->md_data);
                ctx->digest=type;
index 9844d7f9bcc6963f85f913d2d1ef9bcb5c2b4a03..f35036c9d76e48aaf5524448fb889fc26924050f 100644 (file)
@@ -67,32 +67,32 @@ typedef struct
 
 IMPLEMENT_BLOCK_CIPHER(aes_128, ks, AES, EVP_AES_KEY,
                       NID_aes_128, 16, 16, 16, 128,
-                      0, aes_init_key, NULL, 
+                      EVP_CIPH_FLAG_FIPS, aes_init_key, NULL, 
                       EVP_CIPHER_set_asn1_iv,
                       EVP_CIPHER_get_asn1_iv,
                       NULL)
 IMPLEMENT_BLOCK_CIPHER(aes_192, ks, AES, EVP_AES_KEY,
                       NID_aes_192, 16, 24, 16, 128,
-                      0, aes_init_key, NULL, 
+                      EVP_CIPH_FLAG_FIPS, aes_init_key, NULL, 
                       EVP_CIPHER_set_asn1_iv,
                       EVP_CIPHER_get_asn1_iv,
                       NULL)
 IMPLEMENT_BLOCK_CIPHER(aes_256, ks, AES, EVP_AES_KEY,
                       NID_aes_256, 16, 32, 16, 128,
-                      0, aes_init_key, NULL, 
+                      EVP_CIPH_FLAG_FIPS, aes_init_key, NULL, 
                       EVP_CIPHER_set_asn1_iv,
                       EVP_CIPHER_get_asn1_iv,
                       NULL)
 
-#define IMPLEMENT_AES_CFBR(ksize,cbits)        IMPLEMENT_CFBR(aes,AES,EVP_AES_KEY,ks,ksize,cbits,16)
+#define IMPLEMENT_AES_CFBR(ksize,cbits,flags)  IMPLEMENT_CFBR(aes,AES,EVP_AES_KEY,ks,ksize,cbits,16,flags)
 
-IMPLEMENT_AES_CFBR(128,1)
-IMPLEMENT_AES_CFBR(192,1)
-IMPLEMENT_AES_CFBR(256,1)
+IMPLEMENT_AES_CFBR(128,1,0)
+IMPLEMENT_AES_CFBR(192,1,0)
+IMPLEMENT_AES_CFBR(256,1,0)
 
-IMPLEMENT_AES_CFBR(128,8)
-IMPLEMENT_AES_CFBR(192,8)
-IMPLEMENT_AES_CFBR(256,8)
+IMPLEMENT_AES_CFBR(128,8,EVP_CIPH_FLAG_FIPS)
+IMPLEMENT_AES_CFBR(192,8,EVP_CIPH_FLAG_FIPS)
+IMPLEMENT_AES_CFBR(256,8,EVP_CIPH_FLAG_FIPS)
 
 static int aes_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key,
                   const unsigned char *iv, int enc)
index f2554ecc6a2ef50170632939e4ef223ae6bbbbff..46e2899825f51d1356e0c054cd122618e4536fc0 100644 (file)
@@ -127,16 +127,18 @@ static int des_cfb8_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
     }
 
 BLOCK_CIPHER_defs(des, DES_key_schedule, NID_des, 8, 8, 8, 64,
-                       0, des_init_key, NULL,
+                       EVP_CIPH_FLAG_FIPS, des_init_key, NULL,
                        EVP_CIPHER_set_asn1_iv,
                        EVP_CIPHER_get_asn1_iv,
                        NULL)
 
-BLOCK_CIPHER_def_cfb(des,DES_key_schedule,NID_des,8,8,1,0,des_init_key,NULL,
+BLOCK_CIPHER_def_cfb(des,DES_key_schedule,NID_des,8,8,1,
+                    EVP_CIPH_FLAG_FIPS,des_init_key,NULL,
                     EVP_CIPHER_set_asn1_iv,
                     EVP_CIPHER_get_asn1_iv,NULL)
 
-BLOCK_CIPHER_def_cfb(des,DES_key_schedule,NID_des,8,8,8,0,des_init_key,NULL,
+BLOCK_CIPHER_def_cfb(des,DES_key_schedule,NID_des,8,8,8,
+                    EVP_CIPH_FLAG_FIPS,des_init_key,NULL,
                     EVP_CIPHER_set_asn1_iv,
                     EVP_CIPHER_get_asn1_iv,NULL)
 
index b462d7c6af9d7a3116a37493f0a9f1409d085f3a..677322bf02175b9ecba0fa536d94086914077534 100644 (file)
@@ -160,7 +160,7 @@ static int des_ede3_cfb8_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
     }
 
 BLOCK_CIPHER_defs(des_ede, DES_EDE_KEY, NID_des_ede, 8, 16, 8, 64,
-                       0, des_ede_init_key, NULL, 
+                       EVP_CIPH_FLAG_FIPS, des_ede_init_key, NULL, 
                        EVP_CIPHER_set_asn1_iv,
                        EVP_CIPHER_get_asn1_iv,
                        NULL)
@@ -171,18 +171,18 @@ BLOCK_CIPHER_defs(des_ede, DES_EDE_KEY, NID_des_ede, 8, 16, 8, 64,
 #define des_ede3_ecb_cipher des_ede_ecb_cipher
 
 BLOCK_CIPHER_defs(des_ede3, DES_EDE_KEY, NID_des_ede3, 8, 24, 8, 64,
-                       0, des_ede3_init_key, NULL, 
+                       EVP_CIPH_FLAG_FIPS, des_ede3_init_key, NULL, 
                        EVP_CIPHER_set_asn1_iv,
                        EVP_CIPHER_get_asn1_iv,
                        NULL)
 
-BLOCK_CIPHER_def_cfb(des_ede3,DES_EDE_KEY,NID_des_ede3,24,8,1,0,
-                    des_ede3_init_key,NULL,
+BLOCK_CIPHER_def_cfb(des_ede3,DES_EDE_KEY,NID_des_ede3,24,8,1,
+                    EVP_CIPH_FLAG_FIPS, des_ede3_init_key,NULL,
                     EVP_CIPHER_set_asn1_iv,
                     EVP_CIPHER_get_asn1_iv,NULL)
 
-BLOCK_CIPHER_def_cfb(des_ede3,DES_EDE_KEY,NID_des_ede3,24,8,8,0,
-                    des_ede3_init_key,NULL,
+BLOCK_CIPHER_def_cfb(des_ede3,DES_EDE_KEY,NID_des_ede3,24,8,8,
+                    EVP_CIPH_FLAG_FIPS, des_ede3_init_key,NULL,
                     EVP_CIPHER_set_asn1_iv,
                     EVP_CIPHER_get_asn1_iv,NULL)
 
index 115878ff179928dca04912899d25ce4a2168d15b..8aab0a5cb410f799fb524bafa877360e738769a3 100644 (file)
 #include <openssl/aes.h>
 #endif
 
+#ifdef OPENSSL_FIPS
+#include <openssl/fips.h>
+#endif
+
 /*
 #define EVP_RC2_KEY_SIZE               16
 #define EVP_RC4_KEY_SIZE               16
@@ -290,6 +294,7 @@ struct env_md_st
 
 #define EVP_MD_FLAG_ONESHOT    0x0001 /* digest can only handle a single
                                        * block */
+#define EVP_MD_FLAG_FIPS       0x0400 /* Note if suitable for use in FIPS mode */
 
 #define EVP_PKEY_NULL_method   NULL,NULL,{0,0,0,0}
 
@@ -332,6 +337,9 @@ struct env_md_ctx_st
 #define EVP_MD_CTX_FLAG_REUSE          0x0004 /* Don't free up ctx->md_data
                                                * in EVP_MD_CTX_cleanup */
 
+#define EVP_MD_CTX_FLAG_NON_FIPS_ALLOW 0x0008  /* Allow use of non FIPS digest
+                                                * in FIPS mode */
+
 struct evp_cipher_st
        {
        int nid;
@@ -373,6 +381,10 @@ struct evp_cipher_st
 #define        EVP_CIPH_CUSTOM_KEY_LENGTH      0x80
 /* Don't use standard block padding */
 #define        EVP_CIPH_NO_PADDING             0x100
+/* Note if suitable for use in FIPS mode */
+#define                EVP_CIPH_FLAG_FIPS              0x400
+/* Allow non FIPS cipher in FIPS mode */
+#define                EVP_CIPH_FLAG_NON_FIPS_ALLOW    0x800
 
 /* ctrl() values */
 
@@ -853,12 +865,16 @@ void ERR_load_EVP_strings(void);
 /* Function codes. */
 #define EVP_F_AES_INIT_KEY                              129
 #define EVP_F_D2I_PKEY                                  100
+#define EVP_F_EVP_ADD_CIPHER                            130
+#define EVP_F_EVP_ADD_DIGEST                            131
 #define EVP_F_EVP_CIPHERINIT                            123
 #define EVP_F_EVP_CIPHER_CTX_CTRL                       124
 #define EVP_F_EVP_CIPHER_CTX_SET_KEY_LENGTH             122
 #define EVP_F_EVP_DECRYPTFINAL                          101
 #define EVP_F_EVP_DIGESTINIT                            128
 #define EVP_F_EVP_ENCRYPTFINAL                          127
+#define EVP_F_EVP_GET_CIPHERBYNAME                      132
+#define EVP_F_EVP_GET_DIGESTBYNAME                      133
 #define EVP_F_EVP_MD_CTX_COPY                           110
 #define EVP_F_EVP_OPENINIT                              102
 #define EVP_F_EVP_PBE_ALG_ADD                           115
@@ -894,6 +910,7 @@ void ERR_load_EVP_strings(void);
 #define EVP_R_DATA_NOT_MULTIPLE_OF_BLOCK_LENGTH                 138
 #define EVP_R_DECODE_ERROR                              114
 #define EVP_R_DIFFERENT_KEY_TYPES                       101
+#define EVP_R_DISABLED_FOR_FIPS                                 141
 #define EVP_R_ENCODE_ERROR                              115
 #define EVP_R_EVP_PBE_CIPHERINIT_ERROR                  119
 #define EVP_R_EXPECTING_AN_RSA_KEY                      127
index 8ea5aa935dda7c1f03f1ed2bf12fea06bafc5c25..d8ff552d3b7034bd72bfa6ad9bfb6a3dbfd0c939 100644 (file)
@@ -146,7 +146,18 @@ int EVP_CipherInit_ex(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher, ENGINE *imp
                else
                        ctx->engine = NULL;
 #endif
-
+#ifdef OPENSSL_FIPS
+               if (FIPS_mode())
+                       {
+                       if (!(cipher->flags & EVP_CIPH_FLAG_FIPS)
+                               & !(ctx->flags & EVP_CIPH_FLAG_NON_FIPS_ALLOW))
+                               {
+                               EVPerr(EVP_F_EVP_CIPHERINIT, EVP_R_DISABLED_FOR_FIPS);
+                               ERR_add_error_data(2, "cipher=", EVP_CIPHER_name(cipher));
+                               return 0;
+                               }
+                       }
+#endif
                ctx->cipher=cipher;
                if (ctx->cipher->ctx_size)
                        {
@@ -271,6 +282,9 @@ int EVP_EncryptUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl,
        int i,j,bl;
 
        OPENSSL_assert(inl > 0);
+#ifdef OPENSSL_FIPS
+       OPENSSL_assert(!FIPS_mode() || ctx->cipher->flags & EVP_CIPH_FLAG_FIPS);
+#endif
        if(ctx->buf_len == 0 && (inl&(ctx->block_mask)) == 0)
                {
                if(ctx->cipher->do_cipher(ctx,out,in,inl))
index be6d442521c8b80b0728500eab4d5188e27aa84b..40135d07292ed0322a2101bcdd39db4f1bf08a37 100644 (file)
@@ -1,6 +1,6 @@
 /* crypto/evp/evp_err.c */
 /* ====================================================================
- * Copyright (c) 1999-2002 The OpenSSL Project.  All rights reserved.
+ * Copyright (c) 1999-2005 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
@@ -68,12 +68,16 @@ static ERR_STRING_DATA EVP_str_functs[]=
        {
 {ERR_PACK(0,EVP_F_AES_INIT_KEY,0),     "AES_INIT_KEY"},
 {ERR_PACK(0,EVP_F_D2I_PKEY,0), "D2I_PKEY"},
+{ERR_PACK(0,EVP_F_EVP_ADD_CIPHER,0),   "EVP_add_cipher"},
+{ERR_PACK(0,EVP_F_EVP_ADD_DIGEST,0),   "EVP_add_digest"},
 {ERR_PACK(0,EVP_F_EVP_CIPHERINIT,0),   "EVP_CipherInit"},
 {ERR_PACK(0,EVP_F_EVP_CIPHER_CTX_CTRL,0),      "EVP_CIPHER_CTX_ctrl"},
 {ERR_PACK(0,EVP_F_EVP_CIPHER_CTX_SET_KEY_LENGTH,0),    "EVP_CIPHER_CTX_set_key_length"},
 {ERR_PACK(0,EVP_F_EVP_DECRYPTFINAL,0), "EVP_DecryptFinal"},
 {ERR_PACK(0,EVP_F_EVP_DIGESTINIT,0),   "EVP_DigestInit"},
 {ERR_PACK(0,EVP_F_EVP_ENCRYPTFINAL,0), "EVP_EncryptFinal"},
+{ERR_PACK(0,EVP_F_EVP_GET_CIPHERBYNAME,0),     "EVP_get_cipherbyname"},
+{ERR_PACK(0,EVP_F_EVP_GET_DIGESTBYNAME,0),     "EVP_get_digestbyname"},
 {ERR_PACK(0,EVP_F_EVP_MD_CTX_COPY,0),  "EVP_MD_CTX_copy"},
 {ERR_PACK(0,EVP_F_EVP_OPENINIT,0),     "EVP_OpenInit"},
 {ERR_PACK(0,EVP_F_EVP_PBE_ALG_ADD,0),  "EVP_PBE_alg_add"},
@@ -112,6 +116,7 @@ static ERR_STRING_DATA EVP_str_reasons[]=
 {EVP_R_DATA_NOT_MULTIPLE_OF_BLOCK_LENGTH ,"data not multiple of block length"},
 {EVP_R_DECODE_ERROR                      ,"decode error"},
 {EVP_R_DIFFERENT_KEY_TYPES               ,"different key types"},
+{EVP_R_DISABLED_FOR_FIPS                 ,"disabled for fips"},
 {EVP_R_ENCODE_ERROR                      ,"encode error"},
 {EVP_R_EVP_PBE_CIPHERINIT_ERROR          ,"evp pbe cipherinit error"},
 {EVP_R_EXPECTING_AN_RSA_KEY              ,"expecting an rsa key"},
index 2204e345ad1af7e869541b232bd670a945b8f761..845f222eec1cd6063105e2274ee6a904325f29a3 100644 (file)
@@ -226,11 +226,26 @@ const EVP_CIPHER *EVP_##cname##_ecb(void) { return &cname##_ecb; }
 
 #define EVP_C_DATA(kstruct, ctx)       ((kstruct *)(ctx)->cipher_data)
 
-#define IMPLEMENT_CFBR(cipher,cprefix,kstruct,ksched,keysize,cbits,iv_len) \
+#define IMPLEMENT_CFBR(cipher,cprefix,kstruct,ksched,keysize,cbits,iv_len,flags) \
        BLOCK_CIPHER_func_cfb(cipher##_##keysize,cprefix,cbits,kstruct,ksched) \
        BLOCK_CIPHER_def_cfb(cipher##_##keysize,kstruct, \
                             NID_##cipher##_##keysize, keysize/8, iv_len, cbits, \
-                            0, cipher##_init_key, NULL, \
+                            flags, cipher##_init_key, NULL, \
                             EVP_CIPHER_set_asn1_iv, \
                             EVP_CIPHER_get_asn1_iv, \
                             NULL)
+
+#ifdef OPENSSL_FIPS
+#define RC2_set_key    private_RC2_set_key
+#define RC4_set_key    private_RC4_set_key
+#define CAST_set_key   private_CAST_set_key
+#define RC5_32_set_key private_RC5_32_set_key
+#define BF_set_key     private_BF_set_key
+
+#define MD5_Init       private_MD5_Init
+#define MD4_Init       private_MD4_Init
+#define MD2_Init       private_MD2_Init
+#define MDC2_Init      private_MDC2_Init
+#define SHA_Init       private_SHA_Init
+
+#endif
index beb8d7fc5c934b36ac26062a789e544bd3b82a6b..d393eb34009f15fee4c477b8a1d57d4aa8b65546 100644 (file)
@@ -77,7 +77,7 @@ static const EVP_MD dsa_md=
        NID_dsaWithSHA,
        NID_dsaWithSHA,
        SHA_DIGEST_LENGTH,
-       0,
+       EVP_MD_FLAG_FIPS,
        init,
        update,
        final,
index 50914c83b3afaadaef388b5a4f7bbf18fd04e441..0df48e5199e0602adb6c592d2cc4e53885f475f7 100644 (file)
@@ -60,6 +60,7 @@
 #include <stdio.h>
 #include "cryptlib.h"
 #include <openssl/evp.h>
+#include "evp_locl.h"
 #include <openssl/objects.h>
 #include <openssl/x509.h>
 #include <openssl/md2.h>
index e19b6637546c019e87c4c3778e7f8ecc2f13b0f0..0605e4b707c1e7ae88e4d2be990a227b7d87fc75 100644 (file)
@@ -60,6 +60,7 @@
 #include <stdio.h>
 #include "cryptlib.h"
 #include <openssl/evp.h>
+#include "evp_locl.h"
 #include <openssl/objects.h>
 #include <openssl/x509.h>
 #include <openssl/md4.h>
index b00a03e048b605d8e4dd4f5600af3e696ddaf3a2..752615d473a8a76f60e0d33b3ca06ec590084cd7 100644 (file)
@@ -60,6 +60,7 @@
 #include <stdio.h>
 #include "cryptlib.h"
 #include <openssl/evp.h>
+#include "evp_locl.h"
 #include <openssl/objects.h>
 #include <openssl/x509.h>
 #include <openssl/md5.h>
index 9f6467c931439415774dd70f528cb34c1d528f5a..62de1336b856b99589c616a858da838e9acace29 100644 (file)
@@ -60,6 +60,7 @@
 #include <stdio.h>
 #include "cryptlib.h"
 #include <openssl/evp.h>
+#include "evp_locl.h"
 #include <openssl/objects.h>
 #include <openssl/x509.h>
 #include <openssl/mdc2.h>
index ada74065316193f319ab30790615a38eab4a731a..d1785e5f745d938ca169ea97d6a06e70b59004e6 100644 (file)
@@ -60,6 +60,7 @@
 #include <stdio.h>
 #include "cryptlib.h"
 #include <openssl/evp.h>
+#include "evp_locl.h"
 #include <openssl/objects.h>
 #include <openssl/x509.h>
 
index d6be3502f0a2b0aa7012258a3f484533140fdb8a..fe4402389aeae4f104a917a65038d12cb08e8bd9 100644 (file)
@@ -77,7 +77,7 @@ static const EVP_MD sha1_md=
        NID_sha1,
        NID_sha1WithRSAEncryption,
        SHA_DIGEST_LENGTH,
-       0,
+       EVP_MD_FLAG_FIPS,
        init,
        update,
        final,
index eb9f4329cd4dda102e7ccb469a49c0530ec35ad9..771245304615c01e61655e82f48e6c3b22a4fa5a 100644 (file)
@@ -61,6 +61,9 @@
 #include <openssl/evp.h>
 #include <openssl/objects.h>
 #include <openssl/x509.h>
+#ifdef OPENSSL_FIPS
+#include <openssl/fips.h>
+#endif
 
 int EVP_add_cipher(const EVP_CIPHER *c)
        {
index 4c91f919d56d9ac619c6dd2b7572bcb93bc63f65..f4ea6ab29faaf567e4c8fc890005c9453b3b2859 100644 (file)
@@ -171,3 +171,10 @@ unsigned char *HMAC(const EVP_MD *evp_md, const void *key, int key_len,
        return(md);
        }
 
+void HMAC_CTX_set_flags(HMAC_CTX *ctx, unsigned long flags)
+       {
+       EVP_MD_CTX_set_flags(&ctx->i_ctx, flags);
+       EVP_MD_CTX_set_flags(&ctx->o_ctx, flags);
+       EVP_MD_CTX_set_flags(&ctx->md_ctx, flags);
+       }
+
index 0364a1fcbd93485c0808b7ef0d0cf530c35f804d..294ab3b36a01060d1f604c904bff70494dccb8b2 100644 (file)
@@ -98,6 +98,7 @@ unsigned char *HMAC(const EVP_MD *evp_md, const void *key, int key_len,
                    const unsigned char *d, int n, unsigned char *md,
                    unsigned int *md_len);
 
+void HMAC_CTX_set_flags(HMAC_CTX *ctx, unsigned long flags);
 
 #ifdef  __cplusplus
 }
index 1c95bc9c7b8872e15d5df3df6cbece14fe5094b1..794d1258e01e6560a09b611720bd8db0dd902e44 100644 (file)
  */
 
 #include <openssl/idea.h>
+#include <openssl/crypto.h>
 #include "idea_lcl.h"
 
 static IDEA_INT inverse(unsigned int xin);
+
+#ifdef OPENSSL_FIPS
+void idea_set_encrypt_key(const unsigned char *key, IDEA_KEY_SCHEDULE *ks)
+       {
+       if (FIPS_mode())
+               FIPS_BAD_ABORT(IDEA)
+       private_idea_set_encrypt_key(key, ks);
+       }
+void private_idea_set_encrypt_key(const unsigned char *key,
+                                               IDEA_KEY_SCHEDULE *ks)
+#else
 void idea_set_encrypt_key(const unsigned char *key, IDEA_KEY_SCHEDULE *ks)
+#endif
        {
        int i;
        register IDEA_INT *kt,*kf,r0,r1,r2;
index 67132414ee7baaffd55f87ae38306b92d9b61323..bf41844fd764e4c2a346f6c5cb40c676b7111ab0 100644 (file)
@@ -82,6 +82,10 @@ typedef struct idea_key_st
 const char *idea_options(void);
 void idea_ecb_encrypt(const unsigned char *in, unsigned char *out,
        IDEA_KEY_SCHEDULE *ks);
+#ifdef OPENSSL_FIPS
+void private_idea_set_encrypt_key(const unsigned char *key,
+                                               IDEA_KEY_SCHEDULE *ks);
+#endif
 void idea_set_encrypt_key(const unsigned char *key, IDEA_KEY_SCHEDULE *ks);
 void idea_set_decrypt_key(IDEA_KEY_SCHEDULE *ek, IDEA_KEY_SCHEDULE *dk);
 void idea_cbc_encrypt(const unsigned char *in, unsigned char *out,
index ad9241455caf8ec5192169e403582547a88147fa..d0ef9da08e78ec6934169879520f97c11c77d59a 100644 (file)
@@ -80,6 +80,9 @@ typedef struct MD2state_st
        } MD2_CTX;
 
 const char *MD2_options(void);
+#ifdef OPENSSL_FIPS
+int private_MD2_Init(MD2_CTX *c);
+#endif
 int MD2_Init(MD2_CTX *c);
 int MD2_Update(MD2_CTX *c, const unsigned char *data, unsigned long len);
 int MD2_Final(unsigned char *md, MD2_CTX *c);
index ecb64f0ec40d360ce3457077b4c22f5f82fdc4ab..8124acd6877bddd3229232c2922197c0f64390a7 100644 (file)
@@ -62,6 +62,8 @@
 #include <openssl/md2.h>
 #include <openssl/opensslv.h>
 #include <openssl/crypto.h>
+#include <openssl/fips.h>
+#include <openssl/err.h>
 
 const char *MD2_version="MD2" OPENSSL_VERSION_PTEXT;
 
@@ -116,7 +118,7 @@ const char *MD2_options(void)
                return("md2(int)");
        }
 
-int MD2_Init(MD2_CTX *c)
+FIPS_NON_FIPS_MD_Init(MD2)
        {
        c->num=0;
        memset(c->state,0,sizeof c->state);
index fe157a173136f137899ff51634cc7591e00af686..733da6acafe2222d7558b94c5224c77591af2837 100644 (file)
@@ -559,7 +559,7 @@ int HASH_FINAL (unsigned char *md, HASH_CTX *c)
        static const unsigned char end[4]={0x80,0x00,0x00,0x00};
        const unsigned char *cp=end;
 
-#ifdef OPENSSL_FIPS
+#if 0
        if(FIPS_mode() && !FIPS_md5_allowed())
            {
            FIPSerr(FIPS_F_HASH_FINAL,FIPS_R_NON_FIPS_METHOD);
index 7a7b23682f8d68f0b952090a7a9d5a224f0f7c43..7e761efb62137ce158169dd0f5cf25fc171e8208 100644 (file)
@@ -104,6 +104,9 @@ typedef struct MD4state_st
        int num;
        } MD4_CTX;
 
+#ifdef OPENSSL_FIPS
+int private_MD4_Init(MD4_CTX *c);
+#endif
 int MD4_Init(MD4_CTX *c);
 int MD4_Update(MD4_CTX *c, const void *data, unsigned long len);
 int MD4_Final(unsigned char *md, MD4_CTX *c);
index 7afb7185b68a72f201db82f33c43a1d025279d97..ee7cc72262a18638e31688e09dc9f463f21d028b 100644 (file)
@@ -70,7 +70,7 @@ const char *MD4_version="MD4" OPENSSL_VERSION_PTEXT;
 #define INIT_DATA_C (unsigned long)0x98badcfeL
 #define INIT_DATA_D (unsigned long)0x10325476L
 
-int MD4_Init(MD4_CTX *c)
+FIPS_NON_FIPS_MD_Init(MD4)
        {
        c->A=INIT_DATA_A;
        c->B=INIT_DATA_B;
index a252e02115439f943bd8094fbf5c558a2ad53d80..c663dd18160d054c8088b58ce12504dae4b2722d 100644 (file)
@@ -104,6 +104,9 @@ typedef struct MD5state_st
        int num;
        } MD5_CTX;
 
+#ifdef OPENSSL_FIPS
+int private_MD5_Init(MD5_CTX *c);
+#endif
 int MD5_Init(MD5_CTX *c);
 int MD5_Update(MD5_CTX *c, const void *data, unsigned long len);
 int MD5_Final(unsigned char *md, MD5_CTX *c);
index 9c7abc36972e9bba9133f3873622b5e85a78a4ce..54b33c6509aa4c30392c98f7b15429f4620265c6 100644 (file)
@@ -70,7 +70,7 @@ const char *MD5_version="MD5" OPENSSL_VERSION_PTEXT;
 #define INIT_DATA_C (unsigned long)0x98badcfeL
 #define INIT_DATA_D (unsigned long)0x10325476L
 
-int MD5_Init(MD5_CTX *c)
+FIPS_NON_FIPS_MD_Init(MD5)
        {
        c->A=INIT_DATA_A;
        c->B=INIT_DATA_B;
index 793a8a0f13fb9fe764eac07f3ea8b32163409250..4cba101f378b7e416751d05d7c252f65c20c323f 100644 (file)
@@ -80,7 +80,9 @@ typedef struct mdc2_ctx_st
        int pad_type; /* either 1 or 2, default 1 */
        } MDC2_CTX;
 
-
+#ifdef OPENSSL_FIPS
+int private_MDC2_Init(MDC2_CTX *c);
+#endif
 int MDC2_Init(MDC2_CTX *c);
 int MDC2_Update(MDC2_CTX *c, const unsigned char *data, unsigned long len);
 int MDC2_Final(unsigned char *md, MDC2_CTX *c);
index 32daa9b0da35944af7f9bd6987ee0025125ec622..20d1a6e6c404708fc52624c36a25fed92719adf0 100644 (file)
@@ -60,6 +60,8 @@
 #include <stdlib.h>
 #include <string.h>
 #include <openssl/des.h>
+#include <openssl/fips.h>
+#include <openssl/err.h>
 #include <openssl/mdc2.h>
 
 #undef c2l
@@ -75,7 +77,7 @@
                        *((c)++)=(unsigned char)(((l)>>24L)&0xff))
 
 static void mdc2_body(MDC2_CTX *c, const unsigned char *in, unsigned int len);
-int MDC2_Init(MDC2_CTX *c)
+FIPS_NON_FIPS_MD_Init(MDC2)
        {
        c->num=0;
        c->pad_type=1;
index 7816b454dcdf92a1a76b80e8c9ccc16f929d5f61..71788158d84aa8636e9fdff6986f29f0820c821c 100644 (file)
@@ -79,7 +79,10 @@ typedef struct rc2_key_st
        RC2_INT data[64];
        } RC2_KEY;
 
+#ifdef OPENSSL_FIPS 
+void private_RC2_set_key(RC2_KEY *key, int len, const unsigned char *data,
+                                                               int bits);
+#endif
 void RC2_set_key(RC2_KEY *key, int len, const unsigned char *data,int bits);
 void RC2_ecb_encrypt(const unsigned char *in,unsigned char *out,RC2_KEY *key,
                     int enc);
index cab3080c73dc7042cc7197c9936e446589a32188..22f372f85ccfab3327719b915138095ea9da4b1c 100644 (file)
@@ -57,6 +57,7 @@
  */
 
 #include <openssl/rc2.h>
+#include <openssl/crypto.h>
 #include "rc2_locl.h"
 
 static unsigned char key_table[256]={
@@ -90,7 +91,19 @@ static unsigned char key_table[256]={
  * BSAFE uses the 'retarded' version.  What I previously shipped is
  * the same as specifying 1024 for the 'bits' parameter.  Bsafe uses
  * a version where the bits parameter is the same as len*8 */
+
+#ifdef OPENSSL_FIPS
+void RC2_set_key(RC2_KEY *key, int len, const unsigned char *data, int bits)
+       {
+       if (FIPS_mode())
+               FIPS_BAD_ABORT(RC2)
+       private_RC2_set_key(key, len, data, bits);
+       }
+void private_RC2_set_key(RC2_KEY *key, int len, const unsigned char *data,
+                                                               int bits)
+#else
 void RC2_set_key(RC2_KEY *key, int len, const unsigned char *data, int bits)
+#endif
        {
        int i,j;
        unsigned char *k;
index 6878abc5e170c1b18d3bc50028eaea507006a7f4..dd90d9fde0956d709b4136af7f079f5bbfa4ee97 100644 (file)
@@ -81,6 +81,9 @@ typedef struct rc4_key_st
 
  
 const char *RC4_options(void);
+#ifdef OPENSSL_FIPS
+void private_RC4_set_key(RC4_KEY *key, int len, const unsigned char *data);
+#endif
 void RC4_set_key(RC4_KEY *key, int len, const unsigned char *data);
 void RC4(RC4_KEY *key, unsigned long len, const unsigned char *indata,
                unsigned char *outdata);
index ca69a5a7eebace626a91e776d4f2649e91e4c1ca..07234f061afd25796216160522f663daa0763691 100644 (file)
@@ -57,6 +57,7 @@
  */
 
 #include <openssl/rc4.h>
+#include <openssl/crypto.h>
 #include "rc4_locl.h"
 #include <openssl/opensslv.h>
 
@@ -85,7 +86,7 @@ const char *RC4_options(void)
  * Date: Wed, 14 Sep 1994 06:35:31 GMT
  */
 
-void RC4_set_key(RC4_KEY *key, int len, const unsigned char *data)
+FIPS_NON_FIPS_VCIPHER_Init(RC4)
        {
         register RC4_INT tmp;
         register int id1,id2;
index 4adfd2db5ab1856a3074159d29cc847e634bfd14..aa3f26920bfcfaeaf746eef609d5171a0d78630d 100644 (file)
@@ -92,7 +92,10 @@ typedef struct rc5_key_st
        RC5_32_INT data[2*(RC5_16_ROUNDS+1)];
        } RC5_32_KEY;
 
+#ifdef OPENSSL_FIPS 
+void private_RC5_32_set_key(RC5_32_KEY *key, int len, const unsigned char *data,
+       int rounds);
+#endif
 void RC5_32_set_key(RC5_32_KEY *key, int len, const unsigned char *data,
        int rounds);
 void RC5_32_ecb_encrypt(const unsigned char *in,unsigned char *out,RC5_32_KEY *key,
index a2e00a41c5501d52fab1f6e6aa9ac229bf814912..f259ab712621986ff85acdc6b056bbdfa5c23be6 100644 (file)
  * [including the GNU Public Licence.]
  */
 
+#include <openssl/crypto.h>
 #include <openssl/rc5.h>
 #include "rc5_locl.h"
 
+
+#ifdef OPENSSL_FIPS
+void RC5_32_set_key(RC5_32_KEY *key, int len, const unsigned char *data,
+                   int rounds)
+       {
+       if (FIPS_mode())
+               FIPS_BAD_ABORT(RC5)
+       private_RC5_32_set_key(key, len, data, rounds);
+       }
+void private_RC5_32_set_key(RC5_32_KEY *key, int len, const unsigned char *data,
+                   int rounds)
+#else
 void RC5_32_set_key(RC5_32_KEY *key, int len, const unsigned char *data,
                    int rounds)
+#endif
        {
        RC5_32_INT L[64],l,ll,A,B,*S,k;
        int i,j,m,c,t,ii,jj;
index 78d5f365605b5baf400bec0d762d1564169993fb..7d0d99818945ce0453b549ef4f8fae78ef563982 100644 (file)
@@ -90,6 +90,9 @@ typedef struct RIPEMD160state_st
        int num;
        } RIPEMD160_CTX;
 
+#ifdef OPENSSL_FIPS
+int private_RIPEMD160_Init(RIPEMD160_CTX *c);
+#endif
 int RIPEMD160_Init(RIPEMD160_CTX *c);
 int RIPEMD160_Update(RIPEMD160_CTX *c, const void *data, unsigned long len);
 int RIPEMD160_Final(unsigned char *md, RIPEMD160_CTX *c);
index f351f00eea0e4b9355a406f611a0969bcb5e9de1..5dff6bafa194f53e3ff719173e59e8fd811d3b3c 100644 (file)
@@ -58,6 +58,7 @@
 
 #include <stdio.h>
 #include "rmd_locl.h"
+#include <openssl/fips.h>
 #include <openssl/opensslv.h>
 
 const char *RMD160_version="RIPE-MD160" OPENSSL_VERSION_PTEXT;
@@ -69,7 +70,7 @@ const char *RMD160_version="RIPE-MD160" OPENSSL_VERSION_PTEXT;
      void ripemd160_block(RIPEMD160_CTX *c, unsigned long *p,int num);
 #  endif
 
-int RIPEMD160_Init(RIPEMD160_CTX *c)
+FIPS_NON_FIPS_MD_Init(RIPEMD160)
        {
        c->A=RIPEMD160_A;
        c->B=RIPEMD160_B;
index a26ed5ddc1c06e06c7d635fa4dea80099b261fa5..79c07b0fd1f33a4ef418312c0eb17163e1319623 100644 (file)
@@ -105,6 +105,9 @@ typedef struct SHAstate_st
        } SHA_CTX;
 
 #ifndef OPENSSL_NO_SHA0
+#ifdef OPENSSL_FIPS
+int private_SHA_Init(SHA_CTX *c);
+#endif
 int SHA_Init(SHA_CTX *c);
 int SHA_Update(SHA_CTX *c, const void *data, unsigned long len);
 int SHA_Final(unsigned char *md, SHA_CTX *c);
index 7a25c70bfc07da5b91bca6b0c6fbbdc714bfdce2..a3623f72da19b6d6f1e30c0f5e44c1f0b41f3a15 100644 (file)
 #define INIT_DATA_h3 0x10325476UL
 #define INIT_DATA_h4 0xc3d2e1f0UL
 
+#if defined(SHA_0) && defined(OPENSSL_FIPS)
+FIPS_NON_FIPS_MD_Init(SHA)
+#else
 int HASH_INIT (SHA_CTX *c)
+#endif
        {
        c->h0=INIT_DATA_h0;
        c->h1=INIT_DATA_h1;
index 4e71ade1abdfdcedae0a9c5b4ae91ea8121e3934..030d0966fc0cd7afb639c39c2f6fb98de26a7aee 100644 (file)
@@ -322,10 +322,16 @@ unsigned long X509_NAME_hash(X509_NAME *x)
        {
        unsigned long ret=0;
        unsigned char md[16];
+       EVP_MD_CTX md_ctx;
 
        /* Make sure X509_NAME structure contains valid cached encoding */
        i2d_X509_NAME(x,NULL);
-       EVP_Digest(x->bytes->data, x->bytes->length, md, NULL, EVP_md5(), NULL);
+       EVP_MD_CTX_init(&md_ctx);
+       EVP_MD_CTX_set_flags(&md_ctx, EVP_MD_CTX_FLAG_NON_FIPS_ALLOW);
+       EVP_DigestInit_ex(&md_ctx, EVP_md5(), NULL);
+       EVP_DigestUpdate(&md_ctx, x->bytes->data, x->bytes->length);
+       EVP_DigestFinal_ex(&md_ctx,md,NULL);
+       EVP_MD_CTX_cleanup(&md_ctx);
 
        ret=(   ((unsigned long)md[0]     )|((unsigned long)md[1]<<8L)|
                ((unsigned long)md[2]<<16L)|((unsigned long)md[3]<<24L)
index 8c61ea0cba1e33bf630f632723e5456b692d1e3b..e60055c342ca8fc4c92521a658847fdc17a6cf47 100644 (file)
@@ -365,7 +365,7 @@ static int get_issuer_sk(X509 **issuer, X509_STORE_CTX *ctx, X509 *x)
        else
                return 0;
 }
-       
+
 
 /* Check a certificate chains extensions for consistency
  * with the supplied purpose
index 6b4dc3e67284c2678631b8d421de042a63a1bf82..a18be3e2f112cdb5cfbeed30b1fdaa4500146668 100644 (file)
@@ -1162,6 +1162,8 @@ static int ssl3_get_key_exchange(SSL *s)
                        q=md_buf;
                        for (num=2; num > 0; num--)
                                {
+                               EVP_MD_CTX_set_flags(&md_ctx,
+                                       EVP_MD_CTX_FLAG_NON_FIPS_ALLOW);
                                EVP_DigestInit_ex(&md_ctx,(num == 2)
                                        ?s->ctx->md5:s->ctx->sha1, NULL);
                                EVP_DigestUpdate(&md_ctx,&(s->s3->client_random[0]),SSL3_RANDOM_SIZE);
index 92efb9597d3898ae54435ba5ff627ffec12b8577..beb6c64b93342287014ab5d19ed32c00c203fd7d 100644 (file)
@@ -146,6 +146,7 @@ static int ssl3_generate_key_block(SSL *s, unsigned char *km, int num)
 #endif
        k=0;
        EVP_MD_CTX_init(&m5);
+       EVP_MD_CTX_set_flags(&m5, EVP_MD_CTX_FLAG_NON_FIPS_ALLOW);
        EVP_MD_CTX_init(&s1);
        for (i=0; i<num; i+=MD5_DIGEST_LENGTH)
                {
@@ -501,6 +502,8 @@ int ssl3_enc(SSL *s, int send)
 
 void ssl3_init_finished_mac(SSL *s)
        {
+       EVP_MD_CTX_set_flags(&(s->s3->finish_dgst1),
+               EVP_MD_CTX_FLAG_NON_FIPS_ALLOW);
        EVP_DigestInit_ex(&(s->s3->finish_dgst1),s->ctx->md5, NULL);
        EVP_DigestInit_ex(&(s->s3->finish_dgst2),s->ctx->sha1, NULL);
        }
index 44248ba55941afa074ab72665d0dd1577c24f268..a7184891cdf6500aa2acdd1f2e7ca806baa8dfb8 100644 (file)
@@ -1213,6 +1213,8 @@ static int ssl3_send_server_key_exchange(SSL *s)
                                j=0;
                                for (num=2; num > 0; num--)
                                        {
+                                       EVP_MD_CTX_set_flags(&md_ctx,
+                                               EVP_MD_CTX_FLAG_NON_FIPS_ALLOW);
                                        EVP_DigestInit_ex(&md_ctx,(num == 2)
                                                ?s->ctx->md5:s->ctx->sha1, NULL);
                                        EVP_DigestUpdate(&md_ctx,&(s->s3->client_random[0]),SSL3_RANDOM_SIZE);
index ac224ddfa18142a6eaa901537d5c6a20c912604a..3dec4099cb2538d4a19591fb1fa1e7e540a8d5c9 100644 (file)
@@ -132,6 +132,8 @@ static void tls1_P_hash(const EVP_MD *md, const unsigned char *sec,
 
        HMAC_CTX_init(&ctx);
        HMAC_CTX_init(&ctx_tmp);
+       HMAC_CTX_set_flags(&ctx, EVP_MD_CTX_FLAG_NON_FIPS_ALLOW);
+       HMAC_CTX_set_flags(&ctx_tmp, EVP_MD_CTX_FLAG_NON_FIPS_ALLOW);
        HMAC_Init_ex(&ctx,sec,sec_len,md, NULL);
        HMAC_Init_ex(&ctx_tmp,sec,sec_len,md, NULL);
        HMAC_Update(&ctx,seed,seed_len);