summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto
diff options
context:
space:
mode:
authordjm <>2009-01-09 12:15:52 +0000
committerdjm <>2009-01-09 12:15:52 +0000
commit23f8d96f0f508b8bef2602049feee9c44228d34c (patch)
treea2a7787bc00e8f6a29153b8c6d9eb5e8f73d6269 /src/lib/libcrypto
parent30562050421d947c3eb3c10edde6e87730b17471 (diff)
downloadopenbsd-23f8d96f0f508b8bef2602049feee9c44228d34c.tar.gz
openbsd-23f8d96f0f508b8bef2602049feee9c44228d34c.tar.bz2
openbsd-23f8d96f0f508b8bef2602049feee9c44228d34c.zip
resolve conflicts
Diffstat (limited to 'src/lib/libcrypto')
-rw-r--r--src/lib/libcrypto/aes/aes.h4
-rw-r--r--src/lib/libcrypto/aes/aes_cbc.c2
-rw-r--r--src/lib/libcrypto/aes/aes_core.c8
-rw-r--r--src/lib/libcrypto/aes/asm/aes-586.pl3
-rw-r--r--src/lib/libcrypto/asn1/a_mbstr.c2
-rw-r--r--src/lib/libcrypto/asn1/a_sign.c7
-rw-r--r--src/lib/libcrypto/asn1/a_strex.c2
-rw-r--r--src/lib/libcrypto/asn1/a_strnid.c2
-rw-r--r--src/lib/libcrypto/asn1/a_verify.c7
-rw-r--r--src/lib/libcrypto/asn1/asn1t.h2
-rw-r--r--src/lib/libcrypto/asn1/asn_moid.c2
-rw-r--r--src/lib/libcrypto/asn1/asn_pack.c2
-rw-r--r--src/lib/libcrypto/asn1/nsseq.c2
-rw-r--r--src/lib/libcrypto/asn1/p5_pbe.c2
-rw-r--r--src/lib/libcrypto/asn1/p5_pbev2.c2
-rw-r--r--src/lib/libcrypto/asn1/p8_pkey.c2
-rw-r--r--src/lib/libcrypto/asn1/t_bitst.c2
-rw-r--r--src/lib/libcrypto/asn1/t_crl.c2
-rw-r--r--src/lib/libcrypto/asn1/t_spki.c2
-rw-r--r--src/lib/libcrypto/asn1/t_x509.c4
-rw-r--r--src/lib/libcrypto/asn1/t_x509a.c2
-rw-r--r--src/lib/libcrypto/asn1/tasn_dec.c2
-rw-r--r--src/lib/libcrypto/asn1/tasn_enc.c2
-rw-r--r--src/lib/libcrypto/asn1/tasn_fre.c2
-rw-r--r--src/lib/libcrypto/asn1/tasn_new.c2
-rw-r--r--src/lib/libcrypto/asn1/tasn_prn.c2
-rw-r--r--src/lib/libcrypto/asn1/tasn_typ.c2
-rw-r--r--src/lib/libcrypto/asn1/tasn_utl.c2
-rw-r--r--src/lib/libcrypto/asn1/x_algor.c2
-rw-r--r--src/lib/libcrypto/asn1/x_bignum.c2
-rw-r--r--src/lib/libcrypto/asn1/x_exten.c2
-rw-r--r--src/lib/libcrypto/asn1/x_long.c2
-rw-r--r--src/lib/libcrypto/asn1/x_x509a.c2
-rw-r--r--src/lib/libcrypto/bf/bf_skey.c7
-rw-r--r--src/lib/libcrypto/bf/blowfish.h4
-rw-r--r--src/lib/libcrypto/bio/bss_bio.c2
-rw-r--r--src/lib/libcrypto/bio/bss_file.c2
-rw-r--r--src/lib/libcrypto/bn/Makefile16
-rw-r--r--src/lib/libcrypto/bn/bn.h15
-rw-r--r--src/lib/libcrypto/bn/bn_lib.c19
-rw-r--r--src/lib/libcrypto/bn/bn_nist.c706
-rw-r--r--src/lib/libcrypto/bn/bn_rand.c6
-rw-r--r--src/lib/libcrypto/bn/bn_shift.c2
-rw-r--r--src/lib/libcrypto/buffer/buffer.c58
-rw-r--r--src/lib/libcrypto/cast/c_skey.c7
-rw-r--r--src/lib/libcrypto/cast/cast.h4
-rw-r--r--src/lib/libcrypto/cms/cms_smime.c3
-rw-r--r--src/lib/libcrypto/comp/c_zlib.c4
-rw-r--r--src/lib/libcrypto/conf/conf_mall.c4
-rw-r--r--src/lib/libcrypto/conf/conf_mod.c2
-rw-r--r--src/lib/libcrypto/conf/conf_sap.c2
-rw-r--r--src/lib/libcrypto/cryptlib.c351
-rw-r--r--src/lib/libcrypto/crypto-lib.com26
-rw-r--r--src/lib/libcrypto/crypto.h84
-rw-r--r--src/lib/libcrypto/des/des_enc.c4
-rw-r--r--src/lib/libcrypto/des/ecb_enc.c47
-rw-r--r--src/lib/libcrypto/des/enc_read.c4
-rw-r--r--src/lib/libcrypto/des/enc_writ.c4
-rw-r--r--src/lib/libcrypto/des/set_key.c9
-rw-r--r--src/lib/libcrypto/dh/Makefile18
-rw-r--r--src/lib/libcrypto/dh/dh.h11
-rw-r--r--src/lib/libcrypto/dh/dh_asn1.c2
-rw-r--r--src/lib/libcrypto/dh/dh_check.c4
-rw-r--r--src/lib/libcrypto/dh/dh_err.c6
-rw-r--r--src/lib/libcrypto/dh/dh_gen.c4
-rw-r--r--src/lib/libcrypto/dh/dh_key.c4
-rw-r--r--src/lib/libcrypto/dsa/Makefile76
-rw-r--r--src/lib/libcrypto/dsa/dsa.h39
-rw-r--r--src/lib/libcrypto/dsa/dsa_asn1.c82
-rw-r--r--src/lib/libcrypto/dsa/dsa_err.c10
-rw-r--r--src/lib/libcrypto/dsa/dsa_gen.c3
-rw-r--r--src/lib/libcrypto/dsa/dsa_key.c4
-rw-r--r--src/lib/libcrypto/dsa/dsa_lib.c49
-rw-r--r--src/lib/libcrypto/dsa/dsa_ossl.c3
-rw-r--r--src/lib/libcrypto/dsa/dsa_sign.c31
-rw-r--r--src/lib/libcrypto/dsa/dsa_vrf.c32
-rw-r--r--src/lib/libcrypto/ecdh/Makefile33
-rw-r--r--src/lib/libcrypto/ecdsa/Makefile37
-rw-r--r--src/lib/libcrypto/engine/Makefile231
-rw-r--r--src/lib/libcrypto/engine/eng_cnf.c18
-rw-r--r--src/lib/libcrypto/engine/enginetest.c2
-rw-r--r--src/lib/libcrypto/err/err.c782
-rw-r--r--src/lib/libcrypto/err/err.h8
-rw-r--r--src/lib/libcrypto/err/err_all.c13
-rw-r--r--src/lib/libcrypto/err/err_prn.c70
-rw-r--r--src/lib/libcrypto/err/openssl.ec2
-rw-r--r--src/lib/libcrypto/evp/Makefile687
-rw-r--r--src/lib/libcrypto/evp/bio_md.c9
-rw-r--r--src/lib/libcrypto/evp/digest.c154
-rw-r--r--src/lib/libcrypto/evp/e_aes.c35
-rw-r--r--src/lib/libcrypto/evp/e_des.c9
-rw-r--r--src/lib/libcrypto/evp/e_des3.c29
-rw-r--r--src/lib/libcrypto/evp/e_null.c2
-rw-r--r--src/lib/libcrypto/evp/e_rc4.c1
-rw-r--r--src/lib/libcrypto/evp/evp.h78
-rw-r--r--src/lib/libcrypto/evp/evp_acnf.c2
-rw-r--r--src/lib/libcrypto/evp/evp_enc.c254
-rw-r--r--src/lib/libcrypto/evp/evp_err.c16
-rw-r--r--src/lib/libcrypto/evp/evp_lib.c39
-rw-r--r--src/lib/libcrypto/evp/evp_locl.h30
-rw-r--r--src/lib/libcrypto/evp/evp_pbe.c2
-rw-r--r--src/lib/libcrypto/evp/evp_pkey.c2
-rw-r--r--src/lib/libcrypto/evp/m_dss.c2
-rw-r--r--src/lib/libcrypto/evp/m_dss1.c3
-rw-r--r--src/lib/libcrypto/evp/m_md2.c1
-rw-r--r--src/lib/libcrypto/evp/m_md4.c1
-rw-r--r--src/lib/libcrypto/evp/m_md5.c1
-rw-r--r--src/lib/libcrypto/evp/m_mdc2.c1
-rw-r--r--src/lib/libcrypto/evp/m_sha.c1
-rw-r--r--src/lib/libcrypto/evp/m_sha1.c7
-rw-r--r--src/lib/libcrypto/evp/names.c7
-rw-r--r--src/lib/libcrypto/evp/p5_crpt.c2
-rw-r--r--src/lib/libcrypto/evp/p5_crpt2.c2
-rw-r--r--src/lib/libcrypto/evp/p_sign.c24
-rw-r--r--src/lib/libcrypto/evp/p_verify.c26
-rw-r--r--src/lib/libcrypto/hmac/hmac.c3
-rw-r--r--src/lib/libcrypto/idea/idea.h3
-rw-r--r--src/lib/libcrypto/install.com10
-rw-r--r--src/lib/libcrypto/md2/md2.h3
-rw-r--r--src/lib/libcrypto/md2/md2_dgst.c7
-rw-r--r--src/lib/libcrypto/md4/md4.h3
-rw-r--r--src/lib/libcrypto/md4/md4_dgst.c7
-rw-r--r--src/lib/libcrypto/md5/md5.h3
-rw-r--r--src/lib/libcrypto/md5/md5_dgst.c7
-rw-r--r--src/lib/libcrypto/mdc2/Makefile2
-rw-r--r--src/lib/libcrypto/mdc2/mdc2.h4
-rw-r--r--src/lib/libcrypto/mem.c47
-rw-r--r--src/lib/libcrypto/mem_dbg.c28
-rw-r--r--src/lib/libcrypto/objects/obj_dat.pl4
-rw-r--r--src/lib/libcrypto/objects/obj_mac.num2
-rw-r--r--src/lib/libcrypto/objects/objects.txt3
-rw-r--r--src/lib/libcrypto/ocsp/ocsp_asn.c2
-rw-r--r--src/lib/libcrypto/ocsp/ocsp_ht.c5
-rw-r--r--src/lib/libcrypto/ocsp/ocsp_srv.c2
-rw-r--r--src/lib/libcrypto/ocsp/ocsp_vfy.c2
-rw-r--r--src/lib/libcrypto/opensslconf.h.in15
-rw-r--r--src/lib/libcrypto/opensslv.h6
-rw-r--r--src/lib/libcrypto/ossl_typ.h2
-rw-r--r--src/lib/libcrypto/pem/pem.h1
-rw-r--r--src/lib/libcrypto/pem/pem_all.c174
-rw-r--r--src/lib/libcrypto/pem/pem_lib.c3
-rw-r--r--src/lib/libcrypto/pem/pem_x509.c2
-rw-r--r--src/lib/libcrypto/pem/pem_xaux.c2
-rw-r--r--src/lib/libcrypto/pkcs12/p12_add.c2
-rw-r--r--src/lib/libcrypto/pkcs12/p12_asn.c2
-rw-r--r--src/lib/libcrypto/pkcs12/p12_attr.c2
-rw-r--r--src/lib/libcrypto/pkcs12/p12_crpt.c2
-rw-r--r--src/lib/libcrypto/pkcs12/p12_crt.c13
-rw-r--r--src/lib/libcrypto/pkcs12/p12_decr.c2
-rw-r--r--src/lib/libcrypto/pkcs12/p12_init.c2
-rw-r--r--src/lib/libcrypto/pkcs12/p12_key.c2
-rw-r--r--src/lib/libcrypto/pkcs12/p12_kiss.c2
-rw-r--r--src/lib/libcrypto/pkcs12/p12_mutl.c2
-rw-r--r--src/lib/libcrypto/pkcs12/p12_npas.c2
-rw-r--r--src/lib/libcrypto/pkcs12/p12_p8d.c2
-rw-r--r--src/lib/libcrypto/pkcs12/p12_p8e.c2
-rw-r--r--src/lib/libcrypto/pkcs12/p12_utl.c2
-rw-r--r--src/lib/libcrypto/pkcs12/pkcs12.h2
-rw-r--r--src/lib/libcrypto/pkcs7/pk7_asn1.c2
-rw-r--r--src/lib/libcrypto/pkcs7/pk7_attr.c2
-rw-r--r--src/lib/libcrypto/pkcs7/pk7_mime.c2
-rw-r--r--src/lib/libcrypto/pkcs7/pk7_smime.c3
-rw-r--r--src/lib/libcrypto/rand/Makefile71
-rw-r--r--src/lib/libcrypto/rand/md_rand.c12
-rw-r--r--src/lib/libcrypto/rand/rand.h29
-rw-r--r--src/lib/libcrypto/rand/rand_err.c20
-rw-r--r--src/lib/libcrypto/rand/rand_lcl.h11
-rw-r--r--src/lib/libcrypto/rand/rand_lib.c71
-rw-r--r--src/lib/libcrypto/rand/randfile.c66
-rw-r--r--src/lib/libcrypto/rc2/rc2.h4
-rw-r--r--src/lib/libcrypto/rc2/rc2_skey.c17
-rwxr-xr-xsrc/lib/libcrypto/rc4/asm/rc4-x86_64.pl2
-rw-r--r--src/lib/libcrypto/rc4/rc4.h3
-rw-r--r--src/lib/libcrypto/rc4/rc4_skey.c16
-rw-r--r--src/lib/libcrypto/rc5/rc5.h5
-rw-r--r--src/lib/libcrypto/ripemd/ripemd.h4
-rw-r--r--src/lib/libcrypto/ripemd/rmd_dgst.c7
-rw-r--r--src/lib/libcrypto/ripemd/rmd_locl.h2
-rw-r--r--src/lib/libcrypto/rsa/Makefile78
-rw-r--r--src/lib/libcrypto/rsa/rsa.h39
-rw-r--r--src/lib/libcrypto/rsa/rsa_asn1.c2
-rw-r--r--src/lib/libcrypto/rsa/rsa_eay.c2
-rw-r--r--src/lib/libcrypto/rsa/rsa_err.c10
-rw-r--r--src/lib/libcrypto/rsa/rsa_gen.c3
-rw-r--r--src/lib/libcrypto/rsa/rsa_lib.c272
-rw-r--r--src/lib/libcrypto/rsa/rsa_null.c2
-rw-r--r--src/lib/libcrypto/rsa/rsa_oaep.c2
-rw-r--r--src/lib/libcrypto/rsa/rsa_sign.c24
-rw-r--r--src/lib/libcrypto/sha/sha.h3
-rw-r--r--src/lib/libcrypto/sha/sha1_one.c2
-rw-r--r--src/lib/libcrypto/sha/sha1dgst.c4
-rw-r--r--src/lib/libcrypto/sha/sha_dgst.c6
-rw-r--r--src/lib/libcrypto/sha/sha_locl.h7
-rw-r--r--src/lib/libcrypto/symhacks.h5
-rw-r--r--src/lib/libcrypto/ui/ui_openssl.c2
-rw-r--r--src/lib/libcrypto/util/libeay.num180
-rw-r--r--src/lib/libcrypto/util/mk1mf.pl404
-rw-r--r--src/lib/libcrypto/util/mkdef.pl21
-rw-r--r--src/lib/libcrypto/util/mkerr.pl3
-rw-r--r--src/lib/libcrypto/util/mkfiles.pl10
-rw-r--r--src/lib/libcrypto/util/mklink.pl12
-rw-r--r--src/lib/libcrypto/util/pl/VC-32.pl179
-rw-r--r--src/lib/libcrypto/x509/by_dir.c4
-rw-r--r--src/lib/libcrypto/x509/x509_cmp.c8
-rw-r--r--src/lib/libcrypto/x509/x509_trs.c2
-rw-r--r--src/lib/libcrypto/x509/x509cset.c2
-rw-r--r--src/lib/libcrypto/x509/x509spki.c2
-rw-r--r--src/lib/libcrypto/x509v3/ext_dat.h2
-rw-r--r--src/lib/libcrypto/x509v3/pcy_data.c2
-rw-r--r--src/lib/libcrypto/x509v3/pcy_tree.c2
-rw-r--r--src/lib/libcrypto/x509v3/tabtest.c2
-rw-r--r--src/lib/libcrypto/x509v3/v3_addr.c1
-rw-r--r--src/lib/libcrypto/x509v3/v3_akey.c2
-rw-r--r--src/lib/libcrypto/x509v3/v3_akeya.c2
-rw-r--r--src/lib/libcrypto/x509v3/v3_alt.c5
-rw-r--r--src/lib/libcrypto/x509v3/v3_bcons.c2
-rw-r--r--src/lib/libcrypto/x509v3/v3_bitst.c2
-rw-r--r--src/lib/libcrypto/x509v3/v3_conf.c2
-rw-r--r--src/lib/libcrypto/x509v3/v3_cpols.c2
-rw-r--r--src/lib/libcrypto/x509v3/v3_crld.c2
-rw-r--r--src/lib/libcrypto/x509v3/v3_enum.c2
-rw-r--r--src/lib/libcrypto/x509v3/v3_extku.c2
-rw-r--r--src/lib/libcrypto/x509v3/v3_genn.c2
-rw-r--r--src/lib/libcrypto/x509v3/v3_ia5.c2
-rw-r--r--src/lib/libcrypto/x509v3/v3_info.c2
-rw-r--r--src/lib/libcrypto/x509v3/v3_int.c2
-rw-r--r--src/lib/libcrypto/x509v3/v3_lib.c2
-rw-r--r--src/lib/libcrypto/x509v3/v3_ocsp.c2
-rw-r--r--src/lib/libcrypto/x509v3/v3_pku.c2
-rw-r--r--src/lib/libcrypto/x509v3/v3_prn.c2
-rw-r--r--src/lib/libcrypto/x509v3/v3_purp.c2
-rw-r--r--src/lib/libcrypto/x509v3/v3_skey.c2
-rw-r--r--src/lib/libcrypto/x509v3/v3_sxnet.c2
-rw-r--r--src/lib/libcrypto/x509v3/v3_utl.c23
-rw-r--r--src/lib/libcrypto/x509v3/v3conf.c2
-rw-r--r--src/lib/libcrypto/x509v3/v3prin.c2
-rw-r--r--src/lib/libcrypto/x509v3/x509v3.h2
237 files changed, 3588 insertions, 3007 deletions
diff --git a/src/lib/libcrypto/aes/aes.h b/src/lib/libcrypto/aes/aes.h
index baf0222d49..450f2b4051 100644
--- a/src/lib/libcrypto/aes/aes.h
+++ b/src/lib/libcrypto/aes/aes.h
@@ -66,6 +66,10 @@
66#define AES_MAXNR 14 66#define AES_MAXNR 14
67#define AES_BLOCK_SIZE 16 67#define AES_BLOCK_SIZE 16
68 68
69#ifdef OPENSSL_FIPS
70#define FIPS_AES_SIZE_T int
71#endif
72
69#ifdef __cplusplus 73#ifdef __cplusplus
70extern "C" { 74extern "C" {
71#endif 75#endif
diff --git a/src/lib/libcrypto/aes/aes_cbc.c b/src/lib/libcrypto/aes/aes_cbc.c
index d2ba6bcdb4..373864cd4b 100644
--- a/src/lib/libcrypto/aes/aes_cbc.c
+++ b/src/lib/libcrypto/aes/aes_cbc.c
@@ -59,6 +59,7 @@
59#include <openssl/aes.h> 59#include <openssl/aes.h>
60#include "aes_locl.h" 60#include "aes_locl.h"
61 61
62#if !defined(OPENSSL_FIPS_AES_ASM)
62void AES_cbc_encrypt(const unsigned char *in, unsigned char *out, 63void AES_cbc_encrypt(const unsigned char *in, unsigned char *out,
63 const unsigned long length, const AES_KEY *key, 64 const unsigned long length, const AES_KEY *key,
64 unsigned char *ivec, const int enc) { 65 unsigned char *ivec, const int enc) {
@@ -129,3 +130,4 @@ void AES_cbc_encrypt(const unsigned char *in, unsigned char *out,
129 } 130 }
130 } 131 }
131} 132}
133#endif
diff --git a/src/lib/libcrypto/aes/aes_core.c b/src/lib/libcrypto/aes/aes_core.c
index 3a80e18b0a..cffdd4daec 100644
--- a/src/lib/libcrypto/aes/aes_core.c
+++ b/src/lib/libcrypto/aes/aes_core.c
@@ -37,6 +37,10 @@
37 37
38#include <stdlib.h> 38#include <stdlib.h>
39#include <openssl/aes.h> 39#include <openssl/aes.h>
40#ifdef OPENSSL_FIPS
41#include <openssl/fips.h>
42#endif
43
40#include "aes_locl.h" 44#include "aes_locl.h"
41 45
42/* 46/*
@@ -631,6 +635,10 @@ int AES_set_encrypt_key(const unsigned char *userKey, const int bits,
631 int i = 0; 635 int i = 0;
632 u32 temp; 636 u32 temp;
633 637
638#ifdef OPENSSL_FIPS
639 FIPS_selftest_check();
640#endif
641
634 if (!userKey || !key) 642 if (!userKey || !key)
635 return -1; 643 return -1;
636 if (bits != 128 && bits != 192 && bits != 256) 644 if (bits != 128 && bits != 192 && bits != 256)
diff --git a/src/lib/libcrypto/aes/asm/aes-586.pl b/src/lib/libcrypto/aes/asm/aes-586.pl
index 3da307bef9..e771e83953 100644
--- a/src/lib/libcrypto/aes/asm/aes-586.pl
+++ b/src/lib/libcrypto/aes/asm/aes-586.pl
@@ -955,8 +955,9 @@ my $mark=&DWP(60+240,"esp"); #copy of aes_key->rounds
955 955
956 &align (4); 956 &align (4);
957 &set_label("enc_tail"); 957 &set_label("enc_tail");
958 &push ($key eq "edi" ? $key : ""); # push ivp 958 &mov ($s0,$key eq "edi" ? $key : "");
959 &mov ($key,$_out); # load out 959 &mov ($key,$_out); # load out
960 &push ($s0); # push ivp
960 &mov ($s1,16); 961 &mov ($s1,16);
961 &sub ($s1,$s2); 962 &sub ($s1,$s2);
962 &cmp ($key,$acc); # compare with inp 963 &cmp ($key,$acc); # compare with inp
diff --git a/src/lib/libcrypto/asn1/a_mbstr.c b/src/lib/libcrypto/asn1/a_mbstr.c
index 2d4800a22a..1bcd046893 100644
--- a/src/lib/libcrypto/asn1/a_mbstr.c
+++ b/src/lib/libcrypto/asn1/a_mbstr.c
@@ -1,5 +1,5 @@
1/* a_mbstr.c */ 1/* a_mbstr.c */
2/* Written by Dr Stephen N Henson (shenson@bigfoot.com) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 1999. 3 * project 1999.
4 */ 4 */
5/* ==================================================================== 5/* ====================================================================
diff --git a/src/lib/libcrypto/asn1/a_sign.c b/src/lib/libcrypto/asn1/a_sign.c
index 1081950518..4dee45fbb8 100644
--- a/src/lib/libcrypto/asn1/a_sign.c
+++ b/src/lib/libcrypto/asn1/a_sign.c
@@ -267,7 +267,12 @@ int ASN1_item_sign(const ASN1_ITEM *it, X509_ALGOR *algor1, X509_ALGOR *algor2,
267 goto err; 267 goto err;
268 } 268 }
269 269
270 EVP_SignInit_ex(&ctx,type, NULL); 270 if (!EVP_SignInit_ex(&ctx,type, NULL))
271 {
272 outl=0;
273 ASN1err(ASN1_F_ASN1_ITEM_SIGN,ERR_R_EVP_LIB);
274 goto err;
275 }
271 EVP_SignUpdate(&ctx,(unsigned char *)buf_in,inl); 276 EVP_SignUpdate(&ctx,(unsigned char *)buf_in,inl);
272 if (!EVP_SignFinal(&ctx,(unsigned char *)buf_out, 277 if (!EVP_SignFinal(&ctx,(unsigned char *)buf_out,
273 (unsigned int *)&outl,pkey)) 278 (unsigned int *)&outl,pkey))
diff --git a/src/lib/libcrypto/asn1/a_strex.c b/src/lib/libcrypto/asn1/a_strex.c
index c2dbb6f9a5..7fc14d3296 100644
--- a/src/lib/libcrypto/asn1/a_strex.c
+++ b/src/lib/libcrypto/asn1/a_strex.c
@@ -1,5 +1,5 @@
1/* a_strex.c */ 1/* a_strex.c */
2/* Written by Dr Stephen N Henson (shenson@bigfoot.com) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 2000. 3 * project 2000.
4 */ 4 */
5/* ==================================================================== 5/* ====================================================================
diff --git a/src/lib/libcrypto/asn1/a_strnid.c b/src/lib/libcrypto/asn1/a_strnid.c
index 613bbc4a7d..fe515b52ba 100644
--- a/src/lib/libcrypto/asn1/a_strnid.c
+++ b/src/lib/libcrypto/asn1/a_strnid.c
@@ -1,5 +1,5 @@
1/* a_strnid.c */ 1/* a_strnid.c */
2/* Written by Dr Stephen N Henson (shenson@bigfoot.com) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 1999. 3 * project 1999.
4 */ 4 */
5/* ==================================================================== 5/* ====================================================================
diff --git a/src/lib/libcrypto/asn1/a_verify.c b/src/lib/libcrypto/asn1/a_verify.c
index fdce6e4380..da3efaaf8d 100644
--- a/src/lib/libcrypto/asn1/a_verify.c
+++ b/src/lib/libcrypto/asn1/a_verify.c
@@ -100,7 +100,12 @@ int ASN1_verify(i2d_of_void *i2d, X509_ALGOR *a, ASN1_BIT_STRING *signature,
100 p=buf_in; 100 p=buf_in;
101 101
102 i2d(data,&p); 102 i2d(data,&p);
103 EVP_VerifyInit_ex(&ctx,type, NULL); 103 if (!EVP_VerifyInit_ex(&ctx,type, NULL))
104 {
105 ASN1err(ASN1_F_ASN1_VERIFY,ERR_R_EVP_LIB);
106 ret=0;
107 goto err;
108 }
104 EVP_VerifyUpdate(&ctx,(unsigned char *)buf_in,inl); 109 EVP_VerifyUpdate(&ctx,(unsigned char *)buf_in,inl);
105 110
106 OPENSSL_cleanse(buf_in,(unsigned int)inl); 111 OPENSSL_cleanse(buf_in,(unsigned int)inl);
diff --git a/src/lib/libcrypto/asn1/asn1t.h b/src/lib/libcrypto/asn1/asn1t.h
index bf315e65ed..ac14f9415b 100644
--- a/src/lib/libcrypto/asn1/asn1t.h
+++ b/src/lib/libcrypto/asn1/asn1t.h
@@ -1,5 +1,5 @@
1/* asn1t.h */ 1/* asn1t.h */
2/* Written by Dr Stephen N Henson (shenson@bigfoot.com) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 2000. 3 * project 2000.
4 */ 4 */
5/* ==================================================================== 5/* ====================================================================
diff --git a/src/lib/libcrypto/asn1/asn_moid.c b/src/lib/libcrypto/asn1/asn_moid.c
index 9132350f10..1ea6a59248 100644
--- a/src/lib/libcrypto/asn1/asn_moid.c
+++ b/src/lib/libcrypto/asn1/asn_moid.c
@@ -1,5 +1,5 @@
1/* asn_moid.c */ 1/* asn_moid.c */
2/* Written by Stephen Henson (shenson@bigfoot.com) for the OpenSSL 2/* Written by Stephen Henson (steve@openssl.org) for the OpenSSL
3 * project 2001. 3 * project 2001.
4 */ 4 */
5/* ==================================================================== 5/* ====================================================================
diff --git a/src/lib/libcrypto/asn1/asn_pack.c b/src/lib/libcrypto/asn1/asn_pack.c
index e8b671b7b5..f1a5a05632 100644
--- a/src/lib/libcrypto/asn1/asn_pack.c
+++ b/src/lib/libcrypto/asn1/asn_pack.c
@@ -1,5 +1,5 @@
1/* asn_pack.c */ 1/* asn_pack.c */
2/* Written by Dr Stephen N Henson (shenson@bigfoot.com) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 1999. 3 * project 1999.
4 */ 4 */
5/* ==================================================================== 5/* ====================================================================
diff --git a/src/lib/libcrypto/asn1/nsseq.c b/src/lib/libcrypto/asn1/nsseq.c
index 50e2d4d07a..e551c57d59 100644
--- a/src/lib/libcrypto/asn1/nsseq.c
+++ b/src/lib/libcrypto/asn1/nsseq.c
@@ -1,5 +1,5 @@
1/* nsseq.c */ 1/* nsseq.c */
2/* Written by Dr Stephen N Henson (shenson@bigfoot.com) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 1999. 3 * project 1999.
4 */ 4 */
5/* ==================================================================== 5/* ====================================================================
diff --git a/src/lib/libcrypto/asn1/p5_pbe.c b/src/lib/libcrypto/asn1/p5_pbe.c
index da91170094..c4582f8041 100644
--- a/src/lib/libcrypto/asn1/p5_pbe.c
+++ b/src/lib/libcrypto/asn1/p5_pbe.c
@@ -1,5 +1,5 @@
1/* p5_pbe.c */ 1/* p5_pbe.c */
2/* Written by Dr Stephen N Henson (shenson@bigfoot.com) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 1999. 3 * project 1999.
4 */ 4 */
5/* ==================================================================== 5/* ====================================================================
diff --git a/src/lib/libcrypto/asn1/p5_pbev2.c b/src/lib/libcrypto/asn1/p5_pbev2.c
index c834a38ddf..2b0516afee 100644
--- a/src/lib/libcrypto/asn1/p5_pbev2.c
+++ b/src/lib/libcrypto/asn1/p5_pbev2.c
@@ -1,5 +1,5 @@
1/* p5_pbev2.c */ 1/* p5_pbev2.c */
2/* Written by Dr Stephen N Henson (shenson@bigfoot.com) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 1999-2004. 3 * project 1999-2004.
4 */ 4 */
5/* ==================================================================== 5/* ====================================================================
diff --git a/src/lib/libcrypto/asn1/p8_pkey.c b/src/lib/libcrypto/asn1/p8_pkey.c
index 24b409132f..0a1957556e 100644
--- a/src/lib/libcrypto/asn1/p8_pkey.c
+++ b/src/lib/libcrypto/asn1/p8_pkey.c
@@ -1,5 +1,5 @@
1/* p8_pkey.c */ 1/* p8_pkey.c */
2/* Written by Dr Stephen N Henson (shenson@bigfoot.com) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 1999. 3 * project 1999.
4 */ 4 */
5/* ==================================================================== 5/* ====================================================================
diff --git a/src/lib/libcrypto/asn1/t_bitst.c b/src/lib/libcrypto/asn1/t_bitst.c
index 397332d9b8..2e59a25fa1 100644
--- a/src/lib/libcrypto/asn1/t_bitst.c
+++ b/src/lib/libcrypto/asn1/t_bitst.c
@@ -1,5 +1,5 @@
1/* t_bitst.c */ 1/* t_bitst.c */
2/* Written by Dr Stephen N Henson (shenson@bigfoot.com) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 1999. 3 * project 1999.
4 */ 4 */
5/* ==================================================================== 5/* ====================================================================
diff --git a/src/lib/libcrypto/asn1/t_crl.c b/src/lib/libcrypto/asn1/t_crl.c
index 929b3e5904..bdb244c015 100644
--- a/src/lib/libcrypto/asn1/t_crl.c
+++ b/src/lib/libcrypto/asn1/t_crl.c
@@ -1,5 +1,5 @@
1/* t_crl.c */ 1/* t_crl.c */
2/* Written by Dr Stephen N Henson (shenson@bigfoot.com) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 1999. 3 * project 1999.
4 */ 4 */
5/* ==================================================================== 5/* ====================================================================
diff --git a/src/lib/libcrypto/asn1/t_spki.c b/src/lib/libcrypto/asn1/t_spki.c
index c2a5797dd8..a73369b949 100644
--- a/src/lib/libcrypto/asn1/t_spki.c
+++ b/src/lib/libcrypto/asn1/t_spki.c
@@ -1,5 +1,5 @@
1/* t_spki.c */ 1/* t_spki.c */
2/* Written by Dr Stephen N Henson (shenson@bigfoot.com) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 1999. 3 * project 1999.
4 */ 4 */
5/* ==================================================================== 5/* ====================================================================
diff --git a/src/lib/libcrypto/asn1/t_x509.c b/src/lib/libcrypto/asn1/t_x509.c
index cb76c32c8d..8f746f9c05 100644
--- a/src/lib/libcrypto/asn1/t_x509.c
+++ b/src/lib/libcrypto/asn1/t_x509.c
@@ -393,7 +393,7 @@ int ASN1_GENERALIZEDTIME_print(BIO *bp, ASN1_GENERALIZEDTIME *tm)
393 d= (v[6]-'0')*10+(v[7]-'0'); 393 d= (v[6]-'0')*10+(v[7]-'0');
394 h= (v[8]-'0')*10+(v[9]-'0'); 394 h= (v[8]-'0')*10+(v[9]-'0');
395 m= (v[10]-'0')*10+(v[11]-'0'); 395 m= (v[10]-'0')*10+(v[11]-'0');
396 if (i >= 14 && 396 if (tm->length >= 14 &&
397 (v[12] >= '0') && (v[12] <= '9') && 397 (v[12] >= '0') && (v[12] <= '9') &&
398 (v[13] >= '0') && (v[13] <= '9')) 398 (v[13] >= '0') && (v[13] <= '9'))
399 s= (v[12]-'0')*10+(v[13]-'0'); 399 s= (v[12]-'0')*10+(v[13]-'0');
@@ -429,7 +429,7 @@ int ASN1_UTCTIME_print(BIO *bp, ASN1_UTCTIME *tm)
429 d= (v[4]-'0')*10+(v[5]-'0'); 429 d= (v[4]-'0')*10+(v[5]-'0');
430 h= (v[6]-'0')*10+(v[7]-'0'); 430 h= (v[6]-'0')*10+(v[7]-'0');
431 m= (v[8]-'0')*10+(v[9]-'0'); 431 m= (v[8]-'0')*10+(v[9]-'0');
432 if (i >=12 && 432 if (tm->length >=12 &&
433 (v[10] >= '0') && (v[10] <= '9') && 433 (v[10] >= '0') && (v[10] <= '9') &&
434 (v[11] >= '0') && (v[11] <= '9')) 434 (v[11] >= '0') && (v[11] <= '9'))
435 s= (v[10]-'0')*10+(v[11]-'0'); 435 s= (v[10]-'0')*10+(v[11]-'0');
diff --git a/src/lib/libcrypto/asn1/t_x509a.c b/src/lib/libcrypto/asn1/t_x509a.c
index ffbbfb51f4..8b18801a17 100644
--- a/src/lib/libcrypto/asn1/t_x509a.c
+++ b/src/lib/libcrypto/asn1/t_x509a.c
@@ -1,5 +1,5 @@
1/* t_x509a.c */ 1/* t_x509a.c */
2/* Written by Dr Stephen N Henson (shenson@bigfoot.com) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 1999. 3 * project 1999.
4 */ 4 */
5/* ==================================================================== 5/* ====================================================================
diff --git a/src/lib/libcrypto/asn1/tasn_dec.c b/src/lib/libcrypto/asn1/tasn_dec.c
index 0ee406231e..ced641698e 100644
--- a/src/lib/libcrypto/asn1/tasn_dec.c
+++ b/src/lib/libcrypto/asn1/tasn_dec.c
@@ -1,5 +1,5 @@
1/* tasn_dec.c */ 1/* tasn_dec.c */
2/* Written by Dr Stephen N Henson (shenson@bigfoot.com) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 2000. 3 * project 2000.
4 */ 4 */
5/* ==================================================================== 5/* ====================================================================
diff --git a/src/lib/libcrypto/asn1/tasn_enc.c b/src/lib/libcrypto/asn1/tasn_enc.c
index be19b36acd..2721f904a6 100644
--- a/src/lib/libcrypto/asn1/tasn_enc.c
+++ b/src/lib/libcrypto/asn1/tasn_enc.c
@@ -1,5 +1,5 @@
1/* tasn_enc.c */ 1/* tasn_enc.c */
2/* Written by Dr Stephen N Henson (shenson@bigfoot.com) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 2000. 3 * project 2000.
4 */ 4 */
5/* ==================================================================== 5/* ====================================================================
diff --git a/src/lib/libcrypto/asn1/tasn_fre.c b/src/lib/libcrypto/asn1/tasn_fre.c
index bb7c1e2af4..d7c017fa1d 100644
--- a/src/lib/libcrypto/asn1/tasn_fre.c
+++ b/src/lib/libcrypto/asn1/tasn_fre.c
@@ -1,5 +1,5 @@
1/* tasn_fre.c */ 1/* tasn_fre.c */
2/* Written by Dr Stephen N Henson (shenson@bigfoot.com) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 2000. 3 * project 2000.
4 */ 4 */
5/* ==================================================================== 5/* ====================================================================
diff --git a/src/lib/libcrypto/asn1/tasn_new.c b/src/lib/libcrypto/asn1/tasn_new.c
index 531dad365c..5c6a2ebd4d 100644
--- a/src/lib/libcrypto/asn1/tasn_new.c
+++ b/src/lib/libcrypto/asn1/tasn_new.c
@@ -1,5 +1,5 @@
1/* tasn_new.c */ 1/* tasn_new.c */
2/* Written by Dr Stephen N Henson (shenson@bigfoot.com) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 2000. 3 * project 2000.
4 */ 4 */
5/* ==================================================================== 5/* ====================================================================
diff --git a/src/lib/libcrypto/asn1/tasn_prn.c b/src/lib/libcrypto/asn1/tasn_prn.c
index 719639b511..b9c96a6dbe 100644
--- a/src/lib/libcrypto/asn1/tasn_prn.c
+++ b/src/lib/libcrypto/asn1/tasn_prn.c
@@ -1,5 +1,5 @@
1/* tasn_prn.c */ 1/* tasn_prn.c */
2/* Written by Dr Stephen N Henson (shenson@bigfoot.com) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 2000. 3 * project 2000.
4 */ 4 */
5/* ==================================================================== 5/* ====================================================================
diff --git a/src/lib/libcrypto/asn1/tasn_typ.c b/src/lib/libcrypto/asn1/tasn_typ.c
index 6f17f1bec7..6252213d15 100644
--- a/src/lib/libcrypto/asn1/tasn_typ.c
+++ b/src/lib/libcrypto/asn1/tasn_typ.c
@@ -1,5 +1,5 @@
1/* tasn_typ.c */ 1/* tasn_typ.c */
2/* Written by Dr Stephen N Henson (shenson@bigfoot.com) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 2000. 3 * project 2000.
4 */ 4 */
5/* ==================================================================== 5/* ====================================================================
diff --git a/src/lib/libcrypto/asn1/tasn_utl.c b/src/lib/libcrypto/asn1/tasn_utl.c
index 34d520b180..ca9ec7a32f 100644
--- a/src/lib/libcrypto/asn1/tasn_utl.c
+++ b/src/lib/libcrypto/asn1/tasn_utl.c
@@ -1,5 +1,5 @@
1/* tasn_utl.c */ 1/* tasn_utl.c */
2/* Written by Dr Stephen N Henson (shenson@bigfoot.com) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 2000. 3 * project 2000.
4 */ 4 */
5/* ==================================================================== 5/* ====================================================================
diff --git a/src/lib/libcrypto/asn1/x_algor.c b/src/lib/libcrypto/asn1/x_algor.c
index 33533aba86..99e53429b7 100644
--- a/src/lib/libcrypto/asn1/x_algor.c
+++ b/src/lib/libcrypto/asn1/x_algor.c
@@ -1,5 +1,5 @@
1/* x_algor.c */ 1/* x_algor.c */
2/* Written by Dr Stephen N Henson (shenson@bigfoot.com) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 2000. 3 * project 2000.
4 */ 4 */
5/* ==================================================================== 5/* ====================================================================
diff --git a/src/lib/libcrypto/asn1/x_bignum.c b/src/lib/libcrypto/asn1/x_bignum.c
index 869c05d931..9cf3204a1b 100644
--- a/src/lib/libcrypto/asn1/x_bignum.c
+++ b/src/lib/libcrypto/asn1/x_bignum.c
@@ -1,5 +1,5 @@
1/* x_bignum.c */ 1/* x_bignum.c */
2/* Written by Dr Stephen N Henson (shenson@bigfoot.com) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 2000. 3 * project 2000.
4 */ 4 */
5/* ==================================================================== 5/* ====================================================================
diff --git a/src/lib/libcrypto/asn1/x_exten.c b/src/lib/libcrypto/asn1/x_exten.c
index 1732e66712..3a21239926 100644
--- a/src/lib/libcrypto/asn1/x_exten.c
+++ b/src/lib/libcrypto/asn1/x_exten.c
@@ -1,5 +1,5 @@
1/* x_exten.c */ 1/* x_exten.c */
2/* Written by Dr Stephen N Henson (shenson@bigfoot.com) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 2000. 3 * project 2000.
4 */ 4 */
5/* ==================================================================== 5/* ====================================================================
diff --git a/src/lib/libcrypto/asn1/x_long.c b/src/lib/libcrypto/asn1/x_long.c
index 0db233cb95..bf35457c1f 100644
--- a/src/lib/libcrypto/asn1/x_long.c
+++ b/src/lib/libcrypto/asn1/x_long.c
@@ -1,5 +1,5 @@
1/* x_long.c */ 1/* x_long.c */
2/* Written by Dr Stephen N Henson (shenson@bigfoot.com) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 2000. 3 * project 2000.
4 */ 4 */
5/* ==================================================================== 5/* ====================================================================
diff --git a/src/lib/libcrypto/asn1/x_x509a.c b/src/lib/libcrypto/asn1/x_x509a.c
index 13db5fd03f..b603f82de7 100644
--- a/src/lib/libcrypto/asn1/x_x509a.c
+++ b/src/lib/libcrypto/asn1/x_x509a.c
@@ -1,5 +1,5 @@
1/* a_x509a.c */ 1/* a_x509a.c */
2/* Written by Dr Stephen N Henson (shenson@bigfoot.com) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 1999. 3 * project 1999.
4 */ 4 */
5/* ==================================================================== 5/* ====================================================================
diff --git a/src/lib/libcrypto/bf/bf_skey.c b/src/lib/libcrypto/bf/bf_skey.c
index 3673cdee6e..6ac2aeb279 100644
--- a/src/lib/libcrypto/bf/bf_skey.c
+++ b/src/lib/libcrypto/bf/bf_skey.c
@@ -59,10 +59,15 @@
59#include <stdio.h> 59#include <stdio.h>
60#include <string.h> 60#include <string.h>
61#include <openssl/blowfish.h> 61#include <openssl/blowfish.h>
62#include <openssl/crypto.h>
63#ifdef OPENSSL_FIPS
64#include <openssl/fips.h>
65#endif
66
62#include "bf_locl.h" 67#include "bf_locl.h"
63#include "bf_pi.h" 68#include "bf_pi.h"
64 69
65void BF_set_key(BF_KEY *key, int len, const unsigned char *data) 70FIPS_NON_FIPS_VCIPHER_Init(BF)
66 { 71 {
67 int i; 72 int i;
68 BF_LONG *p,ri,in[2]; 73 BF_LONG *p,ri,in[2];
diff --git a/src/lib/libcrypto/bf/blowfish.h b/src/lib/libcrypto/bf/blowfish.h
index cd49e85ab2..d24ffccb65 100644
--- a/src/lib/libcrypto/bf/blowfish.h
+++ b/src/lib/libcrypto/bf/blowfish.h
@@ -104,7 +104,9 @@ typedef struct bf_key_st
104 BF_LONG S[4*256]; 104 BF_LONG S[4*256];
105 } BF_KEY; 105 } BF_KEY;
106 106
107 107#ifdef OPENSSL_FIPS
108void private_BF_set_key(BF_KEY *key, int len, const unsigned char *data);
109#endif
108void BF_set_key(BF_KEY *key, int len, const unsigned char *data); 110void BF_set_key(BF_KEY *key, int len, const unsigned char *data);
109 111
110void BF_encrypt(BF_LONG *data,const BF_KEY *key); 112void BF_encrypt(BF_LONG *data,const BF_KEY *key);
diff --git a/src/lib/libcrypto/bio/bss_bio.c b/src/lib/libcrypto/bio/bss_bio.c
index 0f9f0955b4..76bd48e767 100644
--- a/src/lib/libcrypto/bio/bss_bio.c
+++ b/src/lib/libcrypto/bio/bss_bio.c
@@ -919,6 +919,6 @@ int BIO_nwrite(BIO *bio, char **buf, int num)
919 919
920 ret = BIO_ctrl(bio, BIO_C_NWRITE, num, buf); 920 ret = BIO_ctrl(bio, BIO_C_NWRITE, num, buf);
921 if (ret > 0) 921 if (ret > 0)
922 bio->num_read += ret; 922 bio->num_write += ret;
923 return ret; 923 return ret;
924 } 924 }
diff --git a/src/lib/libcrypto/bio/bss_file.c b/src/lib/libcrypto/bio/bss_file.c
index 0c8c8115fa..e692a08e58 100644
--- a/src/lib/libcrypto/bio/bss_file.c
+++ b/src/lib/libcrypto/bio/bss_file.c
@@ -279,7 +279,7 @@ static long MS_CALLBACK file_ctrl(BIO *b, int cmd, long num, void *ptr)
279#endif 279#endif
280 { 280 {
281#if defined(OPENSSL_SYS_WINDOWS) 281#if defined(OPENSSL_SYS_WINDOWS)
282 int fd = fileno((FILE*)ptr); 282 int fd = _fileno((FILE*)ptr);
283 if (num & BIO_FP_TEXT) 283 if (num & BIO_FP_TEXT)
284 _setmode(fd,_O_TEXT); 284 _setmode(fd,_O_TEXT);
285 else 285 else
diff --git a/src/lib/libcrypto/bn/Makefile b/src/lib/libcrypto/bn/Makefile
index 0491e3db4c..f5e8f65a46 100644
--- a/src/lib/libcrypto/bn/Makefile
+++ b/src/lib/libcrypto/bn/Makefile
@@ -28,13 +28,13 @@ LIBSRC= bn_add.c bn_div.c bn_exp.c bn_lib.c bn_ctx.c bn_mul.c bn_mod.c \
28 bn_print.c bn_rand.c bn_shift.c bn_word.c bn_blind.c \ 28 bn_print.c bn_rand.c bn_shift.c bn_word.c bn_blind.c \
29 bn_kron.c bn_sqrt.c bn_gcd.c bn_prime.c bn_err.c bn_sqr.c bn_asm.c \ 29 bn_kron.c bn_sqrt.c bn_gcd.c bn_prime.c bn_err.c bn_sqr.c bn_asm.c \
30 bn_recp.c bn_mont.c bn_mpi.c bn_exp2.c bn_gf2m.c bn_nist.c \ 30 bn_recp.c bn_mont.c bn_mpi.c bn_exp2.c bn_gf2m.c bn_nist.c \
31 bn_depr.c bn_const.c 31 bn_depr.c bn_x931p.c bn_const.c bn_opt.c
32 32
33LIBOBJ= bn_add.o bn_div.o bn_exp.o bn_lib.o bn_ctx.o bn_mul.o bn_mod.o \ 33LIBOBJ= bn_add.o bn_div.o bn_exp.o bn_lib.o bn_ctx.o bn_mul.o bn_mod.o \
34 bn_print.o bn_rand.o bn_shift.o bn_word.o bn_blind.o \ 34 bn_print.o bn_rand.o bn_shift.o bn_word.o bn_blind.o \
35 bn_kron.o bn_sqrt.o bn_gcd.o bn_prime.o bn_err.o bn_sqr.o $(BN_ASM) \ 35 bn_kron.o bn_sqrt.o bn_gcd.o bn_prime.o bn_err.o bn_sqr.o $(BN_ASM) \
36 bn_recp.o bn_mont.o bn_mpi.o bn_exp2.o bn_gf2m.o bn_nist.o \ 36 bn_recp.o bn_mont.o bn_mpi.o bn_exp2.o bn_gf2m.o bn_nist.o \
37 bn_depr.o bn_const.o 37 bn_depr.o bn_x931p.o bn_const.o bn_opt.o
38 38
39SRC= $(LIBSRC) 39SRC= $(LIBSRC)
40 40
@@ -58,7 +58,7 @@ bnbug: bnbug.c ../../libcrypto.a top
58 cc -g -I../../include bnbug.c -o bnbug ../../libcrypto.a 58 cc -g -I../../include bnbug.c -o bnbug ../../libcrypto.a
59 59
60lib: $(LIBOBJ) 60lib: $(LIBOBJ)
61 $(AR) $(LIB) $(LIBOBJ) 61 $(ARX) $(LIB) $(LIBOBJ)
62 $(RANLIB) $(LIB) || echo Never mind. 62 $(RANLIB) $(LIB) || echo Never mind.
63 @touch lib 63 @touch lib
64 64
@@ -292,6 +292,13 @@ bn_nist.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
292bn_nist.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h 292bn_nist.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
293bn_nist.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h 293bn_nist.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
294bn_nist.o: ../../include/openssl/symhacks.h ../cryptlib.h bn_lcl.h bn_nist.c 294bn_nist.o: ../../include/openssl/symhacks.h ../cryptlib.h bn_lcl.h bn_nist.c
295bn_opt.o: ../../e_os.h ../../include/openssl/bio.h ../../include/openssl/bn.h
296bn_opt.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
297bn_opt.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
298bn_opt.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
299bn_opt.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
300bn_opt.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
301bn_opt.o: ../../include/openssl/symhacks.h ../cryptlib.h bn_lcl.h bn_opt.c
295bn_prime.o: ../../e_os.h ../../include/openssl/bio.h ../../include/openssl/bn.h 302bn_prime.o: ../../e_os.h ../../include/openssl/bio.h ../../include/openssl/bn.h
296bn_prime.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 303bn_prime.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
297bn_prime.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h 304bn_prime.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
@@ -350,3 +357,6 @@ bn_word.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
350bn_word.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h 357bn_word.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
351bn_word.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h 358bn_word.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
352bn_word.o: ../../include/openssl/symhacks.h ../cryptlib.h bn_lcl.h bn_word.c 359bn_word.o: ../../include/openssl/symhacks.h ../cryptlib.h bn_lcl.h bn_word.c
360bn_x931p.o: ../../include/openssl/bn.h ../../include/openssl/e_os2.h
361bn_x931p.o: ../../include/openssl/opensslconf.h
362bn_x931p.o: ../../include/openssl/ossl_typ.h bn_x931p.c
diff --git a/src/lib/libcrypto/bn/bn.h b/src/lib/libcrypto/bn/bn.h
index 6d754d5547..f1719a5877 100644
--- a/src/lib/libcrypto/bn/bn.h
+++ b/src/lib/libcrypto/bn/bn.h
@@ -408,8 +408,8 @@ BIGNUM *BN_CTX_get(BN_CTX *ctx);
408void BN_CTX_end(BN_CTX *ctx); 408void BN_CTX_end(BN_CTX *ctx);
409int BN_rand(BIGNUM *rnd, int bits, int top,int bottom); 409int BN_rand(BIGNUM *rnd, int bits, int top,int bottom);
410int BN_pseudo_rand(BIGNUM *rnd, int bits, int top,int bottom); 410int BN_pseudo_rand(BIGNUM *rnd, int bits, int top,int bottom);
411int BN_rand_range(BIGNUM *rnd, BIGNUM *range); 411int BN_rand_range(BIGNUM *rnd, const BIGNUM *range);
412int BN_pseudo_rand_range(BIGNUM *rnd, BIGNUM *range); 412int BN_pseudo_rand_range(BIGNUM *rnd, const BIGNUM *range);
413int BN_num_bits(const BIGNUM *a); 413int BN_num_bits(const BIGNUM *a);
414int BN_num_bits_word(BN_ULONG); 414int BN_num_bits_word(BN_ULONG);
415BIGNUM *BN_new(void); 415BIGNUM *BN_new(void);
@@ -531,6 +531,17 @@ int BN_is_prime_ex(const BIGNUM *p,int nchecks, BN_CTX *ctx, BN_GENCB *cb);
531int BN_is_prime_fasttest_ex(const BIGNUM *p,int nchecks, BN_CTX *ctx, 531int BN_is_prime_fasttest_ex(const BIGNUM *p,int nchecks, BN_CTX *ctx,
532 int do_trial_division, BN_GENCB *cb); 532 int do_trial_division, BN_GENCB *cb);
533 533
534int BN_X931_generate_Xpq(BIGNUM *Xp, BIGNUM *Xq, int nbits, BN_CTX *ctx);
535
536int BN_X931_derive_prime_ex(BIGNUM *p, BIGNUM *p1, BIGNUM *p2,
537 const BIGNUM *Xp, const BIGNUM *Xp1, const BIGNUM *Xp2,
538 const BIGNUM *e, BN_CTX *ctx, BN_GENCB *cb);
539int BN_X931_generate_prime_ex(BIGNUM *p, BIGNUM *p1, BIGNUM *p2,
540 BIGNUM *Xp1, BIGNUM *Xp2,
541 const BIGNUM *Xp,
542 const BIGNUM *e, BN_CTX *ctx,
543 BN_GENCB *cb);
544
534BN_MONT_CTX *BN_MONT_CTX_new(void ); 545BN_MONT_CTX *BN_MONT_CTX_new(void );
535void BN_MONT_CTX_init(BN_MONT_CTX *ctx); 546void BN_MONT_CTX_init(BN_MONT_CTX *ctx);
536int BN_mod_mul_montgomery(BIGNUM *r,const BIGNUM *a,const BIGNUM *b, 547int BN_mod_mul_montgomery(BIGNUM *r,const BIGNUM *a,const BIGNUM *b,
diff --git a/src/lib/libcrypto/bn/bn_lib.c b/src/lib/libcrypto/bn/bn_lib.c
index 2649b8c538..32a8fbaf51 100644
--- a/src/lib/libcrypto/bn/bn_lib.c
+++ b/src/lib/libcrypto/bn/bn_lib.c
@@ -139,25 +139,6 @@ const BIGNUM *BN_value_one(void)
139 return(&const_one); 139 return(&const_one);
140 } 140 }
141 141
142char *BN_options(void)
143 {
144 static int init=0;
145 static char data[16];
146
147 if (!init)
148 {
149 init++;
150#ifdef BN_LLONG
151 BIO_snprintf(data,sizeof data,"bn(%d,%d)",
152 (int)sizeof(BN_ULLONG)*8,(int)sizeof(BN_ULONG)*8);
153#else
154 BIO_snprintf(data,sizeof data,"bn(%d,%d)",
155 (int)sizeof(BN_ULONG)*8,(int)sizeof(BN_ULONG)*8);
156#endif
157 }
158 return(data);
159 }
160
161int BN_num_bits_word(BN_ULONG l) 142int BN_num_bits_word(BN_ULONG l)
162 { 143 {
163 static const char bits[256]={ 144 static const char bits[256]={
diff --git a/src/lib/libcrypto/bn/bn_nist.c b/src/lib/libcrypto/bn/bn_nist.c
index 1fc94f55c3..2ca5b01391 100644
--- a/src/lib/libcrypto/bn/bn_nist.c
+++ b/src/lib/libcrypto/bn/bn_nist.c
@@ -66,46 +66,157 @@
66#define BN_NIST_384_TOP (384+BN_BITS2-1)/BN_BITS2 66#define BN_NIST_384_TOP (384+BN_BITS2-1)/BN_BITS2
67#define BN_NIST_521_TOP (521+BN_BITS2-1)/BN_BITS2 67#define BN_NIST_521_TOP (521+BN_BITS2-1)/BN_BITS2
68 68
69/* pre-computed tables are "carry-less" values of modulus*(i+1) */
69#if BN_BITS2 == 64 70#if BN_BITS2 == 64
70static const BN_ULONG _nist_p_192[] = 71static const BN_ULONG _nist_p_192[][BN_NIST_192_TOP] = {
71 {0xFFFFFFFFFFFFFFFFULL,0xFFFFFFFFFFFFFFFEULL, 72 {0xFFFFFFFFFFFFFFFFULL,0xFFFFFFFFFFFFFFFEULL,0xFFFFFFFFFFFFFFFFULL},
72 0xFFFFFFFFFFFFFFFFULL}; 73 {0xFFFFFFFFFFFFFFFEULL,0xFFFFFFFFFFFFFFFDULL,0xFFFFFFFFFFFFFFFFULL},
73static const BN_ULONG _nist_p_224[] = 74 {0xFFFFFFFFFFFFFFFDULL,0xFFFFFFFFFFFFFFFCULL,0xFFFFFFFFFFFFFFFFULL}
75 };
76static const BN_ULONG _nist_p_192_sqr[] = {
77 0x0000000000000001ULL,0x0000000000000002ULL,0x0000000000000001ULL,
78 0xFFFFFFFFFFFFFFFEULL,0xFFFFFFFFFFFFFFFDULL,0xFFFFFFFFFFFFFFFFULL
79 };
80static const BN_ULONG _nist_p_224[][BN_NIST_224_TOP] = {
74 {0x0000000000000001ULL,0xFFFFFFFF00000000ULL, 81 {0x0000000000000001ULL,0xFFFFFFFF00000000ULL,
75 0xFFFFFFFFFFFFFFFFULL,0x00000000FFFFFFFFULL}; 82 0xFFFFFFFFFFFFFFFFULL,0x00000000FFFFFFFFULL},
76static const BN_ULONG _nist_p_256[] = 83 {0x0000000000000002ULL,0xFFFFFFFE00000000ULL,
84 0xFFFFFFFFFFFFFFFFULL,0x00000001FFFFFFFFULL} /* this one is "carry-full" */
85 };
86static const BN_ULONG _nist_p_224_sqr[] = {
87 0x0000000000000001ULL,0xFFFFFFFE00000000ULL,
88 0xFFFFFFFFFFFFFFFFULL,0x0000000200000000ULL,
89 0x0000000000000000ULL,0xFFFFFFFFFFFFFFFEULL,
90 0xFFFFFFFFFFFFFFFFULL
91 };
92static const BN_ULONG _nist_p_256[][BN_NIST_256_TOP] = {
77 {0xFFFFFFFFFFFFFFFFULL,0x00000000FFFFFFFFULL, 93 {0xFFFFFFFFFFFFFFFFULL,0x00000000FFFFFFFFULL,
78 0x0000000000000000ULL,0xFFFFFFFF00000001ULL}; 94 0x0000000000000000ULL,0xFFFFFFFF00000001ULL},
79static const BN_ULONG _nist_p_384[] = 95 {0xFFFFFFFFFFFFFFFEULL,0x00000001FFFFFFFFULL,
80 {0x00000000FFFFFFFFULL,0xFFFFFFFF00000000ULL, 96 0x0000000000000000ULL,0xFFFFFFFE00000002ULL},
81 0xFFFFFFFFFFFFFFFEULL,0xFFFFFFFFFFFFFFFFULL, 97 {0xFFFFFFFFFFFFFFFDULL,0x00000002FFFFFFFFULL,
82 0xFFFFFFFFFFFFFFFFULL,0xFFFFFFFFFFFFFFFFULL}; 98 0x0000000000000000ULL,0xFFFFFFFD00000003ULL},
99 {0xFFFFFFFFFFFFFFFCULL,0x00000003FFFFFFFFULL,
100 0x0000000000000000ULL,0xFFFFFFFC00000004ULL},
101 {0xFFFFFFFFFFFFFFFBULL,0x00000004FFFFFFFFULL,
102 0x0000000000000000ULL,0xFFFFFFFB00000005ULL},
103 };
104static const BN_ULONG _nist_p_256_sqr[] = {
105 0x0000000000000001ULL,0xFFFFFFFE00000000ULL,
106 0xFFFFFFFFFFFFFFFFULL,0x00000001FFFFFFFEULL,
107 0x00000001FFFFFFFEULL,0x00000001FFFFFFFEULL,
108 0xFFFFFFFE00000001ULL,0xFFFFFFFE00000002ULL
109 };
110static const BN_ULONG _nist_p_384[][BN_NIST_384_TOP] = {
111 {0x00000000FFFFFFFFULL,0xFFFFFFFF00000000ULL,0xFFFFFFFFFFFFFFFEULL,
112 0xFFFFFFFFFFFFFFFFULL,0xFFFFFFFFFFFFFFFFULL,0xFFFFFFFFFFFFFFFFULL},
113 {0x00000001FFFFFFFEULL,0xFFFFFFFE00000000ULL,0xFFFFFFFFFFFFFFFDULL,
114 0xFFFFFFFFFFFFFFFFULL,0xFFFFFFFFFFFFFFFFULL,0xFFFFFFFFFFFFFFFFULL},
115 {0x00000002FFFFFFFDULL,0xFFFFFFFD00000000ULL,0xFFFFFFFFFFFFFFFCULL,
116 0xFFFFFFFFFFFFFFFFULL,0xFFFFFFFFFFFFFFFFULL,0xFFFFFFFFFFFFFFFFULL},
117 {0x00000003FFFFFFFCULL,0xFFFFFFFC00000000ULL,0xFFFFFFFFFFFFFFFBULL,
118 0xFFFFFFFFFFFFFFFFULL,0xFFFFFFFFFFFFFFFFULL,0xFFFFFFFFFFFFFFFFULL},
119 {0x00000004FFFFFFFBULL,0xFFFFFFFB00000000ULL,0xFFFFFFFFFFFFFFFAULL,
120 0xFFFFFFFFFFFFFFFFULL,0xFFFFFFFFFFFFFFFFULL,0xFFFFFFFFFFFFFFFFULL},
121 };
122static const BN_ULONG _nist_p_384_sqr[] = {
123 0xFFFFFFFE00000001ULL,0x0000000200000000ULL,0xFFFFFFFE00000000ULL,
124 0x0000000200000000ULL,0x0000000000000001ULL,0x0000000000000000ULL,
125 0x00000001FFFFFFFEULL,0xFFFFFFFE00000000ULL,0xFFFFFFFFFFFFFFFDULL,
126 0xFFFFFFFFFFFFFFFFULL,0xFFFFFFFFFFFFFFFFULL,0xFFFFFFFFFFFFFFFFULL
127 };
83static const BN_ULONG _nist_p_521[] = 128static const BN_ULONG _nist_p_521[] =
84 {0xFFFFFFFFFFFFFFFFULL,0xFFFFFFFFFFFFFFFFULL, 129 {0xFFFFFFFFFFFFFFFFULL,0xFFFFFFFFFFFFFFFFULL,
85 0xFFFFFFFFFFFFFFFFULL,0xFFFFFFFFFFFFFFFFULL, 130 0xFFFFFFFFFFFFFFFFULL,0xFFFFFFFFFFFFFFFFULL,
86 0xFFFFFFFFFFFFFFFFULL,0xFFFFFFFFFFFFFFFFULL, 131 0xFFFFFFFFFFFFFFFFULL,0xFFFFFFFFFFFFFFFFULL,
87 0xFFFFFFFFFFFFFFFFULL,0xFFFFFFFFFFFFFFFFULL, 132 0xFFFFFFFFFFFFFFFFULL,0xFFFFFFFFFFFFFFFFULL,
88 0x00000000000001FFULL}; 133 0x00000000000001FFULL};
134static const BN_ULONG _nist_p_521_sqr[] = {
135 0x0000000000000001ULL,0x0000000000000000ULL,0x0000000000000000ULL,
136 0x0000000000000000ULL,0x0000000000000000ULL,0x0000000000000000ULL,
137 0x0000000000000000ULL,0x0000000000000000ULL,0xFFFFFFFFFFFFFC00ULL,
138 0xFFFFFFFFFFFFFFFFULL,0xFFFFFFFFFFFFFFFFULL,0xFFFFFFFFFFFFFFFFULL,
139 0xFFFFFFFFFFFFFFFFULL,0xFFFFFFFFFFFFFFFFULL,0xFFFFFFFFFFFFFFFFULL,
140 0xFFFFFFFFFFFFFFFFULL,0x000000000003FFFFULL
141 };
89#elif BN_BITS2 == 32 142#elif BN_BITS2 == 32
90static const BN_ULONG _nist_p_192[] = {0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFE, 143static const BN_ULONG _nist_p_192[][BN_NIST_192_TOP] = {
91 0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF}; 144 {0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFE,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF},
92static const BN_ULONG _nist_p_224[] = {0x00000001,0x00000000,0x00000000, 145 {0xFFFFFFFE,0xFFFFFFFF,0xFFFFFFFD,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF},
93 0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF}; 146 {0xFFFFFFFD,0xFFFFFFFF,0xFFFFFFFC,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF}
94static const BN_ULONG _nist_p_256[] = {0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF, 147 };
95 0x00000000,0x00000000,0x00000000,0x00000001,0xFFFFFFFF}; 148static const BN_ULONG _nist_p_192_sqr[] = {
96static const BN_ULONG _nist_p_384[] = {0xFFFFFFFF,0x00000000,0x00000000, 149 0x00000001,0x00000000,0x00000002,0x00000000,0x00000001,0x00000000,
97 0xFFFFFFFF,0xFFFFFFFE,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF, 150 0xFFFFFFFE,0xFFFFFFFF,0xFFFFFFFD,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF
98 0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF}; 151 };
152static const BN_ULONG _nist_p_224[][BN_NIST_224_TOP] = {
153 {0x00000001,0x00000000,0x00000000,0xFFFFFFFF,
154 0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF},
155 {0x00000002,0x00000000,0x00000000,0xFFFFFFFE,
156 0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF}
157 };
158static const BN_ULONG _nist_p_224_sqr[] = {
159 0x00000001,0x00000000,0x00000000,0xFFFFFFFE,
160 0xFFFFFFFF,0xFFFFFFFF,0x00000000,0x00000002,
161 0x00000000,0x00000000,0xFFFFFFFE,0xFFFFFFFF,
162 0xFFFFFFFF,0xFFFFFFFF
163 };
164static const BN_ULONG _nist_p_256[][BN_NIST_256_TOP] = {
165 {0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0x00000000,
166 0x00000000,0x00000000,0x00000001,0xFFFFFFFF},
167 {0xFFFFFFFE,0xFFFFFFFF,0xFFFFFFFF,0x00000001,
168 0x00000000,0x00000000,0x00000002,0xFFFFFFFE},
169 {0xFFFFFFFD,0xFFFFFFFF,0xFFFFFFFF,0x00000002,
170 0x00000000,0x00000000,0x00000003,0xFFFFFFFD},
171 {0xFFFFFFFC,0xFFFFFFFF,0xFFFFFFFF,0x00000003,
172 0x00000000,0x00000000,0x00000004,0xFFFFFFFC},
173 {0xFFFFFFFB,0xFFFFFFFF,0xFFFFFFFF,0x00000004,
174 0x00000000,0x00000000,0x00000005,0xFFFFFFFB},
175 };
176static const BN_ULONG _nist_p_256_sqr[] = {
177 0x00000001,0x00000000,0x00000000,0xFFFFFFFE,
178 0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFE,0x00000001,
179 0xFFFFFFFE,0x00000001,0xFFFFFFFE,0x00000001,
180 0x00000001,0xFFFFFFFE,0x00000002,0xFFFFFFFE
181 };
182static const BN_ULONG _nist_p_384[][BN_NIST_384_TOP] = {
183 {0xFFFFFFFF,0x00000000,0x00000000,0xFFFFFFFF,0xFFFFFFFE,0xFFFFFFFF,
184 0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF},
185 {0xFFFFFFFE,0x00000001,0x00000000,0xFFFFFFFE,0xFFFFFFFD,0xFFFFFFFF,
186 0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF},
187 {0xFFFFFFFD,0x00000002,0x00000000,0xFFFFFFFD,0xFFFFFFFC,0xFFFFFFFF,
188 0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF},
189 {0xFFFFFFFC,0x00000003,0x00000000,0xFFFFFFFC,0xFFFFFFFB,0xFFFFFFFF,
190 0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF},
191 {0xFFFFFFFB,0x00000004,0x00000000,0xFFFFFFFB,0xFFFFFFFA,0xFFFFFFFF,
192 0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF},
193 };
194static const BN_ULONG _nist_p_384_sqr[] = {
195 0x00000001,0xFFFFFFFE,0x00000000,0x00000002,0x00000000,0xFFFFFFFE,
196 0x00000000,0x00000002,0x00000001,0x00000000,0x00000000,0x00000000,
197 0xFFFFFFFE,0x00000001,0x00000000,0xFFFFFFFE,0xFFFFFFFD,0xFFFFFFFF,
198 0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF
199 };
99static const BN_ULONG _nist_p_521[] = {0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF, 200static const BN_ULONG _nist_p_521[] = {0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,
100 0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF, 201 0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,
101 0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF, 202 0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,
102 0xFFFFFFFF,0x000001FF}; 203 0xFFFFFFFF,0x000001FF};
204static const BN_ULONG _nist_p_521_sqr[] = {
205 0x00000001,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,
206 0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,
207 0x00000000,0x00000000,0x00000000,0x00000000,0xFFFFFC00,0xFFFFFFFF,
208 0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,
209 0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,
210 0xFFFFFFFF,0xFFFFFFFF,0x0003FFFF
211 };
212#else
213#error "unsupported BN_BITS2"
103#endif 214#endif
104 215
105 216
106static const BIGNUM _bignum_nist_p_192 = 217static const BIGNUM _bignum_nist_p_192 =
107 { 218 {
108 (BN_ULONG *)_nist_p_192, 219 (BN_ULONG *)_nist_p_192[0],
109 BN_NIST_192_TOP, 220 BN_NIST_192_TOP,
110 BN_NIST_192_TOP, 221 BN_NIST_192_TOP,
111 0, 222 0,
@@ -114,7 +225,7 @@ static const BIGNUM _bignum_nist_p_192 =
114 225
115static const BIGNUM _bignum_nist_p_224 = 226static const BIGNUM _bignum_nist_p_224 =
116 { 227 {
117 (BN_ULONG *)_nist_p_224, 228 (BN_ULONG *)_nist_p_224[0],
118 BN_NIST_224_TOP, 229 BN_NIST_224_TOP,
119 BN_NIST_224_TOP, 230 BN_NIST_224_TOP,
120 0, 231 0,
@@ -123,7 +234,7 @@ static const BIGNUM _bignum_nist_p_224 =
123 234
124static const BIGNUM _bignum_nist_p_256 = 235static const BIGNUM _bignum_nist_p_256 =
125 { 236 {
126 (BN_ULONG *)_nist_p_256, 237 (BN_ULONG *)_nist_p_256[0],
127 BN_NIST_256_TOP, 238 BN_NIST_256_TOP,
128 BN_NIST_256_TOP, 239 BN_NIST_256_TOP,
129 0, 240 0,
@@ -132,7 +243,7 @@ static const BIGNUM _bignum_nist_p_256 =
132 243
133static const BIGNUM _bignum_nist_p_384 = 244static const BIGNUM _bignum_nist_p_384 =
134 { 245 {
135 (BN_ULONG *)_nist_p_384, 246 (BN_ULONG *)_nist_p_384[0],
136 BN_NIST_384_TOP, 247 BN_NIST_384_TOP,
137 BN_NIST_384_TOP, 248 BN_NIST_384_TOP,
138 0, 249 0,
@@ -180,7 +291,9 @@ static void nist_cp_bn_0(BN_ULONG *buf, BN_ULONG *a, int top, int max)
180 int i; 291 int i;
181 BN_ULONG *_tmp1 = (buf), *_tmp2 = (a); 292 BN_ULONG *_tmp1 = (buf), *_tmp2 = (a);
182 293
294#ifdef BN_DEBUG
183 OPENSSL_assert(top <= max); 295 OPENSSL_assert(top <= max);
296#endif
184 for (i = (top); i != 0; i--) 297 for (i = (top); i != 0; i--)
185 *_tmp1++ = *_tmp2++; 298 *_tmp1++ = *_tmp2++;
186 for (i = (max) - (top); i != 0; i--) 299 for (i = (max) - (top); i != 0; i--)
@@ -198,9 +311,14 @@ static void nist_cp_bn(BN_ULONG *buf, BN_ULONG *a, int top)
198#if BN_BITS2 == 64 311#if BN_BITS2 == 64
199#define bn_cp_64(to, n, from, m) (to)[n] = (m>=0)?((from)[m]):0; 312#define bn_cp_64(to, n, from, m) (to)[n] = (m>=0)?((from)[m]):0;
200#define bn_64_set_0(to, n) (to)[n] = (BN_ULONG)0; 313#define bn_64_set_0(to, n) (to)[n] = (BN_ULONG)0;
201/* TBD */ 314/*
202#define bn_cp_32(to, n, from, m) (to)[n] = (m>=0)?((from)[m]):0; 315 * two following macros are implemented under assumption that they
203#define bn_32_set_0(to, n) (to)[n] = (BN_ULONG)0; 316 * are called in a sequence with *ascending* n, i.e. as they are...
317 */
318#define bn_cp_32_naked(to, n, from, m) (((n)&1)?(to[(n)/2]|=((m)&1)?(from[(m)/2]&BN_MASK2h):(from[(m)/2]<<32))\
319 :(to[(n)/2] =((m)&1)?(from[(m)/2]>>32):(from[(m)/2]&BN_MASK2l)))
320#define bn_32_set_0(to, n) (((n)&1)?(to[(n)/2]&=BN_MASK2l):(to[(n)/2]=0));
321#define bn_cp_32(to,n,from,m) ((m)>=0)?bn_cp_32_naked(to,n,from,m):bn_32_set_0(to,n)
204#else 322#else
205#define bn_cp_64(to, n, from, m) \ 323#define bn_cp_64(to, n, from, m) \
206 { \ 324 { \
@@ -221,9 +339,9 @@ static void nist_cp_bn(BN_ULONG *buf, BN_ULONG *a, int top)
221 339
222#define nist_set_192(to, from, a1, a2, a3) \ 340#define nist_set_192(to, from, a1, a2, a3) \
223 { \ 341 { \
224 if (a3 != 0) bn_cp_64(to, 0, from, (a3) - 3) else bn_64_set_0(to, 0)\ 342 bn_cp_64(to, 0, from, (a3) - 3) \
225 bn_cp_64(to, 1, from, (a2) - 3) \ 343 bn_cp_64(to, 1, from, (a2) - 3) \
226 if (a1 != 0) bn_cp_64(to, 2, from, (a1) - 3) else bn_64_set_0(to, 2)\ 344 bn_cp_64(to, 2, from, (a1) - 3) \
227 } 345 }
228 346
229int BN_nist_mod_192(BIGNUM *r, const BIGNUM *a, const BIGNUM *field, 347int BN_nist_mod_192(BIGNUM *r, const BIGNUM *a, const BIGNUM *field,
@@ -237,11 +355,16 @@ int BN_nist_mod_192(BIGNUM *r, const BIGNUM *a, const BIGNUM *field,
237 c_d[BN_NIST_192_TOP], 355 c_d[BN_NIST_192_TOP],
238 *res; 356 *res;
239 size_t mask; 357 size_t mask;
358 static const BIGNUM _bignum_nist_p_192_sqr = {
359 (BN_ULONG *)_nist_p_192_sqr,
360 sizeof(_nist_p_192_sqr)/sizeof(_nist_p_192_sqr[0]),
361 sizeof(_nist_p_192_sqr)/sizeof(_nist_p_192_sqr[0]),
362 0,BN_FLG_STATIC_DATA };
240 363
241 field = &_bignum_nist_p_192; /* just to make sure */ 364 field = &_bignum_nist_p_192; /* just to make sure */
242 365
243 if (BN_is_negative(a) || a->top > 2*BN_NIST_192_TOP) 366 if (BN_is_negative(a) || BN_ucmp(a,&_bignum_nist_p_192_sqr)>=0)
244 return BN_nnmod(r, field, a, ctx); 367 return BN_nnmod(r, a, field, ctx);
245 368
246 i = BN_ucmp(field, a); 369 i = BN_ucmp(field, a);
247 if (i == 0) 370 if (i == 0)
@@ -265,50 +388,49 @@ int BN_nist_mod_192(BIGNUM *r, const BIGNUM *a, const BIGNUM *field,
265 nist_cp_bn_0(buf, a_d + BN_NIST_192_TOP, top - BN_NIST_192_TOP, BN_NIST_192_TOP); 388 nist_cp_bn_0(buf, a_d + BN_NIST_192_TOP, top - BN_NIST_192_TOP, BN_NIST_192_TOP);
266 389
267 nist_set_192(t_d, buf, 0, 3, 3); 390 nist_set_192(t_d, buf, 0, 3, 3);
268 carry = bn_add_words(r_d, r_d, t_d, BN_NIST_192_TOP); 391 carry = (int)bn_add_words(r_d, r_d, t_d, BN_NIST_192_TOP);
269 mask = 0-(size_t)bn_sub_words(c_d,r_d,_nist_p_192,BN_NIST_192_TOP);
270 mask = ~mask | (0-(size_t)carry);
271 res = (BN_ULONG *)(((size_t)c_d&mask) | ((size_t)r_d&~mask));
272
273 nist_set_192(t_d, buf, 4, 4, 0); 392 nist_set_192(t_d, buf, 4, 4, 0);
274 carry = bn_add_words(r_d, res, t_d, BN_NIST_192_TOP); 393 carry += (int)bn_add_words(r_d, r_d, t_d, BN_NIST_192_TOP);
275 mask = 0-(size_t)bn_sub_words(c_d,r_d,_nist_p_192,BN_NIST_192_TOP);
276 mask = ~mask | (0-(size_t)carry);
277 res = (BN_ULONG *)(((size_t)c_d&mask) | ((size_t)r_d&~mask));
278
279 nist_set_192(t_d, buf, 5, 5, 5) 394 nist_set_192(t_d, buf, 5, 5, 5)
280 carry = bn_add_words(r_d, res, t_d, BN_NIST_192_TOP); 395 carry += (int)bn_add_words(r_d, r_d, t_d, BN_NIST_192_TOP);
281 mask = 0-(size_t)bn_sub_words(c_d,r_d,_nist_p_192,BN_NIST_192_TOP);
282 mask = ~mask | (0-(size_t)carry);
283 res = (BN_ULONG *)(((size_t)c_d&mask) | ((size_t)r_d&~mask));
284 396
397 if (carry > 0)
398 carry = (int)bn_sub_words(r_d,r_d,_nist_p_192[carry-1],BN_NIST_192_TOP);
399 else
400 carry = 1;
401
402 /*
403 * we need 'if (carry==0 || result>=modulus) result-=modulus;'
404 * as comparison implies subtraction, we can write
405 * 'tmp=result-modulus; if (!carry || !borrow) result=tmp;'
406 * this is what happens below, but without explicit if:-) a.
407 */
408 mask = 0-(size_t)bn_sub_words(c_d,r_d,_nist_p_192[0],BN_NIST_192_TOP);
409 mask &= 0-(size_t)carry;
410 res = (BN_ULONG *)(((size_t)c_d&~mask) | ((size_t)r_d&mask));
285 nist_cp_bn(r_d, res, BN_NIST_192_TOP); 411 nist_cp_bn(r_d, res, BN_NIST_192_TOP);
286 r->top = BN_NIST_192_TOP; 412 r->top = BN_NIST_192_TOP;
287 bn_correct_top(r); 413 bn_correct_top(r);
288 414
289 if (BN_ucmp(field, r) <= 0)
290 {
291 if (!BN_usub(r, r, field)) return 0;
292 }
293
294 return 1; 415 return 1;
295 } 416 }
296 417
418typedef BN_ULONG (*bn_addsub_f)(BN_ULONG *,const BN_ULONG *,const BN_ULONG *,int);
419
297#define nist_set_224(to, from, a1, a2, a3, a4, a5, a6, a7) \ 420#define nist_set_224(to, from, a1, a2, a3, a4, a5, a6, a7) \
298 { \ 421 { \
299 if (a7 != 0) bn_cp_32(to, 0, from, (a7) - 7) else bn_32_set_0(to, 0)\ 422 bn_cp_32(to, 0, from, (a7) - 7) \
300 if (a6 != 0) bn_cp_32(to, 1, from, (a6) - 7) else bn_32_set_0(to, 1)\ 423 bn_cp_32(to, 1, from, (a6) - 7) \
301 if (a5 != 0) bn_cp_32(to, 2, from, (a5) - 7) else bn_32_set_0(to, 2)\ 424 bn_cp_32(to, 2, from, (a5) - 7) \
302 if (a4 != 0) bn_cp_32(to, 3, from, (a4) - 7) else bn_32_set_0(to, 3)\ 425 bn_cp_32(to, 3, from, (a4) - 7) \
303 if (a3 != 0) bn_cp_32(to, 4, from, (a3) - 7) else bn_32_set_0(to, 4)\ 426 bn_cp_32(to, 4, from, (a3) - 7) \
304 if (a2 != 0) bn_cp_32(to, 5, from, (a2) - 7) else bn_32_set_0(to, 5)\ 427 bn_cp_32(to, 5, from, (a2) - 7) \
305 if (a1 != 0) bn_cp_32(to, 6, from, (a1) - 7) else bn_32_set_0(to, 6)\ 428 bn_cp_32(to, 6, from, (a1) - 7) \
306 } 429 }
307 430
308int BN_nist_mod_224(BIGNUM *r, const BIGNUM *a, const BIGNUM *field, 431int BN_nist_mod_224(BIGNUM *r, const BIGNUM *a, const BIGNUM *field,
309 BN_CTX *ctx) 432 BN_CTX *ctx)
310 { 433 {
311#if BN_BITS2 == 32
312 int top = a->top, i; 434 int top = a->top, i;
313 int carry; 435 int carry;
314 BN_ULONG *r_d, *a_d = a->d; 436 BN_ULONG *r_d, *a_d = a->d;
@@ -317,11 +439,18 @@ int BN_nist_mod_224(BIGNUM *r, const BIGNUM *a, const BIGNUM *field,
317 c_d[BN_NIST_224_TOP], 439 c_d[BN_NIST_224_TOP],
318 *res; 440 *res;
319 size_t mask; 441 size_t mask;
442 union { bn_addsub_f f; size_t p; } u;
443 static const BIGNUM _bignum_nist_p_224_sqr = {
444 (BN_ULONG *)_nist_p_224_sqr,
445 sizeof(_nist_p_224_sqr)/sizeof(_nist_p_224_sqr[0]),
446 sizeof(_nist_p_224_sqr)/sizeof(_nist_p_224_sqr[0]),
447 0,BN_FLG_STATIC_DATA };
448
320 449
321 field = &_bignum_nist_p_224; /* just to make sure */ 450 field = &_bignum_nist_p_224; /* just to make sure */
322 451
323 if (BN_is_negative(a) || a->top > 2*BN_NIST_224_TOP) 452 if (BN_is_negative(a) || BN_ucmp(a,&_bignum_nist_p_224_sqr)>=0)
324 return BN_nnmod(r, field, a, ctx); 453 return BN_nnmod(r, a, field, ctx);
325 454
326 i = BN_ucmp(field, a); 455 i = BN_ucmp(field, a);
327 if (i == 0) 456 if (i == 0)
@@ -342,72 +471,77 @@ int BN_nist_mod_224(BIGNUM *r, const BIGNUM *a, const BIGNUM *field,
342 else 471 else
343 r_d = a_d; 472 r_d = a_d;
344 473
474#if BN_BITS2==64
475 /* copy upper 256 bits of 448 bit number ... */
476 nist_cp_bn_0(t_d, a_d + (BN_NIST_224_TOP-1), top - (BN_NIST_224_TOP-1), BN_NIST_224_TOP);
477 /* ... and right shift by 32 to obtain upper 224 bits */
478 nist_set_224(buf, t_d, 14, 13, 12, 11, 10, 9, 8);
479 /* truncate lower part to 224 bits too */
480 r_d[BN_NIST_224_TOP-1] &= BN_MASK2l;
481#else
345 nist_cp_bn_0(buf, a_d + BN_NIST_224_TOP, top - BN_NIST_224_TOP, BN_NIST_224_TOP); 482 nist_cp_bn_0(buf, a_d + BN_NIST_224_TOP, top - BN_NIST_224_TOP, BN_NIST_224_TOP);
346 483#endif
347 nist_set_224(t_d, buf, 10, 9, 8, 7, 0, 0, 0); 484 nist_set_224(t_d, buf, 10, 9, 8, 7, 0, 0, 0);
348 carry = bn_add_words(r_d, r_d, t_d, BN_NIST_224_TOP); 485 carry = (int)bn_add_words(r_d, r_d, t_d, BN_NIST_224_TOP);
349 mask = 0-(size_t)bn_sub_words(c_d,r_d,_nist_p_224,BN_NIST_224_TOP);
350 mask = ~mask | (0-(size_t)carry);
351 res = (BN_ULONG *)(((size_t)c_d&mask) | ((size_t)r_d&~mask));
352
353 nist_set_224(t_d, buf, 0, 13, 12, 11, 0, 0, 0); 486 nist_set_224(t_d, buf, 0, 13, 12, 11, 0, 0, 0);
354 carry = bn_add_words(r_d, res, t_d, BN_NIST_224_TOP); 487 carry += (int)bn_add_words(r_d, r_d, t_d, BN_NIST_224_TOP);
355 mask = 0-(size_t)bn_sub_words(c_d,r_d,_nist_p_224,BN_NIST_224_TOP);
356 mask = ~mask | (0-(size_t)carry);
357 res = (BN_ULONG *)(((size_t)c_d&mask) | ((size_t)r_d&~mask));
358
359 nist_set_224(t_d, buf, 13, 12, 11, 10, 9, 8, 7); 488 nist_set_224(t_d, buf, 13, 12, 11, 10, 9, 8, 7);
360#if BRANCH_FREE 489 carry -= (int)bn_sub_words(r_d, r_d, t_d, BN_NIST_224_TOP);
361 carry = bn_sub_words(r_d, res, t_d, BN_NIST_224_TOP);
362 bn_add_words(c_d,r_d,_nist_p_224,BN_NIST_224_TOP);
363 mask = 0-(size_t)carry;
364 res = (BN_ULONG *)(((size_t)c_d&mask) | ((size_t)r_d&~mask));
365#else
366 if (bn_sub_words(r_d, res, t_d, BN_NIST_224_TOP))
367 bn_add_words(r_d,r_d,_nist_p_224,BN_NIST_224_TOP);
368#endif
369 nist_set_224(t_d, buf, 0, 0, 0, 0, 13, 12, 11); 490 nist_set_224(t_d, buf, 0, 0, 0, 0, 13, 12, 11);
370#if BRANCH_FREE 491 carry -= (int)bn_sub_words(r_d, r_d, t_d, BN_NIST_224_TOP);
371 carry = bn_sub_words(r_d, res, t_d, BN_NIST_224_TOP);
372 bn_add_words(c_d,r_d,_nist_p_224,BN_NIST_224_TOP);
373 mask = 0-(size_t)carry;
374 res = (BN_ULONG *)(((size_t)c_d&mask) | ((size_t)r_d&~mask));
375 492
376 nist_cp_bn(r_d, res, BN_NIST_224_TOP); 493#if BN_BITS2==64
377#else 494 carry = (int)(r_d[BN_NIST_224_TOP-1]>>32);
378 if (bn_sub_words(r_d, r_d, t_d, BN_NIST_224_TOP))
379 bn_add_words(r_d,r_d,_nist_p_224,BN_NIST_224_TOP);
380#endif 495#endif
381 r->top = BN_NIST_224_TOP; 496 u.f = bn_sub_words;
382 bn_correct_top(r); 497 if (carry > 0)
383
384 if (BN_ucmp(field, r) <= 0)
385 { 498 {
386 if (!BN_usub(r, r, field)) return 0; 499 carry = (int)bn_sub_words(r_d,r_d,_nist_p_224[carry-1],BN_NIST_224_TOP);
500#if BN_BITS2==64
501 carry=(int)(~(r_d[BN_NIST_224_TOP-1]>>32))&1;
502#endif
387 } 503 }
504 else if (carry < 0)
505 {
506 /* it's a bit more comlicated logic in this case.
507 * if bn_add_words yields no carry, then result
508 * has to be adjusted by unconditionally *adding*
509 * the modulus. but if it does, then result has
510 * to be compared to the modulus and conditionally
511 * adjusted by *subtracting* the latter. */
512 carry = (int)bn_add_words(r_d,r_d,_nist_p_224[-carry-1],BN_NIST_224_TOP);
513 mask = 0-(size_t)carry;
514 u.p = ((size_t)bn_sub_words&mask) | ((size_t)bn_add_words&~mask);
515 }
516 else
517 carry = 1;
518
519 /* otherwise it's effectively same as in BN_nist_mod_192... */
520 mask = 0-(size_t)(*u.f)(c_d,r_d,_nist_p_224[0],BN_NIST_224_TOP);
521 mask &= 0-(size_t)carry;
522 res = (BN_ULONG *)(((size_t)c_d&~mask) | ((size_t)r_d&mask));
523 nist_cp_bn(r_d, res, BN_NIST_224_TOP);
524 r->top = BN_NIST_224_TOP;
525 bn_correct_top(r);
388 526
389 return 1; 527 return 1;
390#else /* BN_BITS!=32 */
391 return 0;
392#endif
393 } 528 }
394 529
395#define nist_set_256(to, from, a1, a2, a3, a4, a5, a6, a7, a8) \ 530#define nist_set_256(to, from, a1, a2, a3, a4, a5, a6, a7, a8) \
396 { \ 531 { \
397 if (a8 != 0) bn_cp_32(to, 0, from, (a8) - 8) else bn_32_set_0(to, 0)\ 532 bn_cp_32(to, 0, from, (a8) - 8) \
398 if (a7 != 0) bn_cp_32(to, 1, from, (a7) - 8) else bn_32_set_0(to, 1)\ 533 bn_cp_32(to, 1, from, (a7) - 8) \
399 if (a6 != 0) bn_cp_32(to, 2, from, (a6) - 8) else bn_32_set_0(to, 2)\ 534 bn_cp_32(to, 2, from, (a6) - 8) \
400 if (a5 != 0) bn_cp_32(to, 3, from, (a5) - 8) else bn_32_set_0(to, 3)\ 535 bn_cp_32(to, 3, from, (a5) - 8) \
401 if (a4 != 0) bn_cp_32(to, 4, from, (a4) - 8) else bn_32_set_0(to, 4)\ 536 bn_cp_32(to, 4, from, (a4) - 8) \
402 if (a3 != 0) bn_cp_32(to, 5, from, (a3) - 8) else bn_32_set_0(to, 5)\ 537 bn_cp_32(to, 5, from, (a3) - 8) \
403 if (a2 != 0) bn_cp_32(to, 6, from, (a2) - 8) else bn_32_set_0(to, 6)\ 538 bn_cp_32(to, 6, from, (a2) - 8) \
404 if (a1 != 0) bn_cp_32(to, 7, from, (a1) - 8) else bn_32_set_0(to, 7)\ 539 bn_cp_32(to, 7, from, (a1) - 8) \
405 } 540 }
406 541
407int BN_nist_mod_256(BIGNUM *r, const BIGNUM *a, const BIGNUM *field, 542int BN_nist_mod_256(BIGNUM *r, const BIGNUM *a, const BIGNUM *field,
408 BN_CTX *ctx) 543 BN_CTX *ctx)
409 { 544 {
410#if BN_BITS2 == 32
411 int i, top = a->top; 545 int i, top = a->top;
412 int carry = 0; 546 int carry = 0;
413 register BN_ULONG *a_d = a->d, *r_d; 547 register BN_ULONG *a_d = a->d, *r_d;
@@ -416,11 +550,17 @@ int BN_nist_mod_256(BIGNUM *r, const BIGNUM *a, const BIGNUM *field,
416 c_d[BN_NIST_256_TOP], 550 c_d[BN_NIST_256_TOP],
417 *res; 551 *res;
418 size_t mask; 552 size_t mask;
553 union { bn_addsub_f f; size_t p; } u;
554 static const BIGNUM _bignum_nist_p_256_sqr = {
555 (BN_ULONG *)_nist_p_256_sqr,
556 sizeof(_nist_p_256_sqr)/sizeof(_nist_p_256_sqr[0]),
557 sizeof(_nist_p_256_sqr)/sizeof(_nist_p_256_sqr[0]),
558 0,BN_FLG_STATIC_DATA };
419 559
420 field = &_bignum_nist_p_256; /* just to make sure */ 560 field = &_bignum_nist_p_256; /* just to make sure */
421 561
422 if (BN_is_negative(a) || a->top > 2*BN_NIST_256_TOP) 562 if (BN_is_negative(a) || BN_ucmp(a,&_bignum_nist_p_256_sqr)>=0)
423 return BN_nnmod(r, field, a, ctx); 563 return BN_nnmod(r, a, field, ctx);
424 564
425 i = BN_ucmp(field, a); 565 i = BN_ucmp(field, a);
426 if (i == 0) 566 if (i == 0)
@@ -446,116 +586,84 @@ int BN_nist_mod_256(BIGNUM *r, const BIGNUM *a, const BIGNUM *field,
446 /*S1*/ 586 /*S1*/
447 nist_set_256(t_d, buf, 15, 14, 13, 12, 11, 0, 0, 0); 587 nist_set_256(t_d, buf, 15, 14, 13, 12, 11, 0, 0, 0);
448 /*S2*/ 588 /*S2*/
449 nist_set_256(c_d,buf, 0, 15, 14, 13, 12, 0, 0, 0); 589 nist_set_256(c_d, buf, 0, 15, 14, 13, 12, 0, 0, 0);
450 carry = bn_add_words(t_d, t_d, c_d, BN_NIST_256_TOP); 590 carry = (int)bn_add_words(t_d, t_d, c_d, BN_NIST_256_TOP);
451 mask = 0-(size_t)bn_sub_words(c_d,t_d,_nist_p_256,BN_NIST_256_TOP); 591 /* left shift */
452 mask = ~mask | (0-(size_t)carry); 592 {
453 res = (BN_ULONG *)(((size_t)c_d&mask) | ((size_t)t_d&~mask)); 593 register BN_ULONG *ap,t,c;
454 594 ap = t_d;
455 carry = bn_add_words(t_d, res, res, BN_NIST_256_TOP); 595 c=0;
456 mask = 0-(size_t)bn_sub_words(c_d,t_d,_nist_p_256,BN_NIST_256_TOP); 596 for (i = BN_NIST_256_TOP; i != 0; --i)
457 mask = ~mask | (0-(size_t)carry); 597 {
458 res = (BN_ULONG *)(((size_t)c_d&mask) | ((size_t)t_d&~mask)); 598 t= *ap;
459 599 *(ap++)=((t<<1)|c)&BN_MASK2;
460 carry = bn_add_words(r_d, r_d, res, BN_NIST_256_TOP); 600 c=(t & BN_TBIT)?1:0;
461 mask = 0-(size_t)bn_sub_words(c_d,r_d,_nist_p_256,BN_NIST_256_TOP); 601 }
462 mask = ~mask | (0-(size_t)carry); 602 carry <<= 1;
463 res = (BN_ULONG *)(((size_t)c_d&mask) | ((size_t)r_d&~mask)); 603 carry |= c;
464 604 }
605 carry += (int)bn_add_words(r_d, r_d, t_d, BN_NIST_256_TOP);
465 /*S3*/ 606 /*S3*/
466 nist_set_256(t_d, buf, 15, 14, 0, 0, 0, 10, 9, 8); 607 nist_set_256(t_d, buf, 15, 14, 0, 0, 0, 10, 9, 8);
467 carry = bn_add_words(r_d, res, t_d, BN_NIST_256_TOP); 608 carry += (int)bn_add_words(r_d, r_d, t_d, BN_NIST_256_TOP);
468 mask = 0-(size_t)bn_sub_words(c_d,r_d,_nist_p_256,BN_NIST_256_TOP);
469 mask = ~mask | (0-(size_t)carry);
470 res = (BN_ULONG *)(((size_t)c_d&mask) | ((size_t)r_d&~mask));
471
472 /*S4*/ 609 /*S4*/
473 nist_set_256(t_d, buf, 8, 13, 15, 14, 13, 11, 10, 9); 610 nist_set_256(t_d, buf, 8, 13, 15, 14, 13, 11, 10, 9);
474 carry = bn_add_words(r_d, res, t_d, BN_NIST_256_TOP); 611 carry += (int)bn_add_words(r_d, r_d, t_d, BN_NIST_256_TOP);
475 mask = 0-(size_t)bn_sub_words(c_d,r_d,_nist_p_256,BN_NIST_256_TOP);
476 mask = ~mask | (0-(size_t)carry);
477 res = (BN_ULONG *)(((size_t)c_d&mask) | ((size_t)r_d&~mask));
478
479 /*D1*/ 612 /*D1*/
480 nist_set_256(t_d, buf, 10, 8, 0, 0, 0, 13, 12, 11); 613 nist_set_256(t_d, buf, 10, 8, 0, 0, 0, 13, 12, 11);
481#if BRANCH_FREE 614 carry -= (int)bn_sub_words(r_d, r_d, t_d, BN_NIST_256_TOP);
482 carry = bn_sub_words(r_d, res, t_d, BN_NIST_256_TOP);
483 bn_add_words(c_d,r_d,_nist_p_256,BN_NIST_256_TOP);
484 mask = 0-(size_t)carry;
485 res = (BN_ULONG *)(((size_t)c_d&mask) | ((size_t)r_d&~mask));
486#else
487 if (bn_sub_words(r_d, res, t_d, BN_NIST_256_TOP))
488 bn_add_words(r_d,r_d,_nist_p_256,BN_NIST_256_TOP);
489#endif
490 /*D2*/ 615 /*D2*/
491 nist_set_256(t_d, buf, 11, 9, 0, 0, 15, 14, 13, 12); 616 nist_set_256(t_d, buf, 11, 9, 0, 0, 15, 14, 13, 12);
492#if BRANCH_FREE 617 carry -= (int)bn_sub_words(r_d, r_d, t_d, BN_NIST_256_TOP);
493 carry = bn_sub_words(r_d, res, t_d, BN_NIST_256_TOP);
494 bn_add_words(c_d,r_d,_nist_p_256,BN_NIST_256_TOP);
495 mask = 0-(size_t)carry;
496 res = (BN_ULONG *)(((size_t)c_d&mask) | ((size_t)r_d&~mask));
497#else
498 if (bn_sub_words(r_d, r_d, t_d, BN_NIST_256_TOP))
499 bn_add_words(r_d,r_d,_nist_p_256,BN_NIST_256_TOP);
500#endif
501 /*D3*/ 618 /*D3*/
502 nist_set_256(t_d, buf, 12, 0, 10, 9, 8, 15, 14, 13); 619 nist_set_256(t_d, buf, 12, 0, 10, 9, 8, 15, 14, 13);
503#if BRANCH_FREE 620 carry -= (int)bn_sub_words(r_d, r_d, t_d, BN_NIST_256_TOP);
504 carry = bn_sub_words(r_d, res, t_d, BN_NIST_256_TOP);
505 bn_add_words(c_d,r_d,_nist_p_256,BN_NIST_256_TOP);
506 mask = 0-(size_t)carry;
507 res = (BN_ULONG *)(((size_t)c_d&mask) | ((size_t)r_d&~mask));
508#else
509 if (bn_sub_words(r_d, r_d, t_d, BN_NIST_256_TOP))
510 bn_add_words(r_d,r_d,_nist_p_256,BN_NIST_256_TOP);
511#endif
512 /*D4*/ 621 /*D4*/
513 nist_set_256(t_d, buf, 13, 0, 11, 10, 9, 0, 15, 14); 622 nist_set_256(t_d, buf, 13, 0, 11, 10, 9, 0, 15, 14);
514#if BRANCH_FREE 623 carry -= (int)bn_sub_words(r_d, r_d, t_d, BN_NIST_256_TOP);
515 carry = bn_sub_words(r_d, res, t_d, BN_NIST_256_TOP);
516 bn_add_words(c_d,r_d,_nist_p_256,BN_NIST_256_TOP);
517 mask = 0-(size_t)carry;
518 res = (BN_ULONG *)(((size_t)c_d&mask) | ((size_t)r_d&~mask));
519
520 nist_cp_bn(r_d, res, BN_NIST_384_TOP);
521#else
522 if (bn_sub_words(r_d, r_d, t_d, BN_NIST_256_TOP))
523 bn_add_words(r_d,r_d,_nist_p_256,BN_NIST_256_TOP);
524#endif
525 r->top = BN_NIST_256_TOP;
526 bn_correct_top(r);
527 624
528 if (BN_ucmp(field, r) <= 0) 625 /* see BN_nist_mod_224 for explanation */
626 u.f = bn_sub_words;
627 if (carry > 0)
628 carry = (int)bn_sub_words(r_d,r_d,_nist_p_256[carry-1],BN_NIST_256_TOP);
629 else if (carry < 0)
529 { 630 {
530 if (!BN_usub(r, r, field)) return 0; 631 carry = (int)bn_add_words(r_d,r_d,_nist_p_256[-carry-1],BN_NIST_256_TOP);
632 mask = 0-(size_t)carry;
633 u.p = ((size_t)bn_sub_words&mask) | ((size_t)bn_add_words&~mask);
531 } 634 }
635 else
636 carry = 1;
637
638 mask = 0-(size_t)(*u.f)(c_d,r_d,_nist_p_256[0],BN_NIST_256_TOP);
639 mask &= 0-(size_t)carry;
640 res = (BN_ULONG *)(((size_t)c_d&~mask) | ((size_t)r_d&mask));
641 nist_cp_bn(r_d, res, BN_NIST_256_TOP);
642 r->top = BN_NIST_256_TOP;
643 bn_correct_top(r);
532 644
533 return 1; 645 return 1;
534#else /* BN_BITS!=32 */
535 return 0;
536#endif
537 } 646 }
538 647
539#define nist_set_384(to,from,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12) \ 648#define nist_set_384(to,from,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12) \
540 { \ 649 { \
541 if (a12 != 0) bn_cp_32(to, 0, from, (a12) - 12) else bn_32_set_0(to, 0)\ 650 bn_cp_32(to, 0, from, (a12) - 12) \
542 if (a11 != 0) bn_cp_32(to, 1, from, (a11) - 12) else bn_32_set_0(to, 1)\ 651 bn_cp_32(to, 1, from, (a11) - 12) \
543 if (a10 != 0) bn_cp_32(to, 2, from, (a10) - 12) else bn_32_set_0(to, 2)\ 652 bn_cp_32(to, 2, from, (a10) - 12) \
544 if (a9 != 0) bn_cp_32(to, 3, from, (a9) - 12) else bn_32_set_0(to, 3)\ 653 bn_cp_32(to, 3, from, (a9) - 12) \
545 if (a8 != 0) bn_cp_32(to, 4, from, (a8) - 12) else bn_32_set_0(to, 4)\ 654 bn_cp_32(to, 4, from, (a8) - 12) \
546 if (a7 != 0) bn_cp_32(to, 5, from, (a7) - 12) else bn_32_set_0(to, 5)\ 655 bn_cp_32(to, 5, from, (a7) - 12) \
547 if (a6 != 0) bn_cp_32(to, 6, from, (a6) - 12) else bn_32_set_0(to, 6)\ 656 bn_cp_32(to, 6, from, (a6) - 12) \
548 if (a5 != 0) bn_cp_32(to, 7, from, (a5) - 12) else bn_32_set_0(to, 7)\ 657 bn_cp_32(to, 7, from, (a5) - 12) \
549 if (a4 != 0) bn_cp_32(to, 8, from, (a4) - 12) else bn_32_set_0(to, 8)\ 658 bn_cp_32(to, 8, from, (a4) - 12) \
550 if (a3 != 0) bn_cp_32(to, 9, from, (a3) - 12) else bn_32_set_0(to, 9)\ 659 bn_cp_32(to, 9, from, (a3) - 12) \
551 if (a2 != 0) bn_cp_32(to, 10, from, (a2) - 12) else bn_32_set_0(to, 10)\ 660 bn_cp_32(to, 10, from, (a2) - 12) \
552 if (a1 != 0) bn_cp_32(to, 11, from, (a1) - 12) else bn_32_set_0(to, 11)\ 661 bn_cp_32(to, 11, from, (a1) - 12) \
553 } 662 }
554 663
555int BN_nist_mod_384(BIGNUM *r, const BIGNUM *a, const BIGNUM *field, 664int BN_nist_mod_384(BIGNUM *r, const BIGNUM *a, const BIGNUM *field,
556 BN_CTX *ctx) 665 BN_CTX *ctx)
557 { 666 {
558#if BN_BITS2 == 32
559 int i, top = a->top; 667 int i, top = a->top;
560 int carry = 0; 668 int carry = 0;
561 register BN_ULONG *r_d, *a_d = a->d; 669 register BN_ULONG *r_d, *a_d = a->d;
@@ -564,11 +672,18 @@ int BN_nist_mod_384(BIGNUM *r, const BIGNUM *a, const BIGNUM *field,
564 c_d[BN_NIST_384_TOP], 672 c_d[BN_NIST_384_TOP],
565 *res; 673 *res;
566 size_t mask; 674 size_t mask;
675 union { bn_addsub_f f; size_t p; } u;
676 static const BIGNUM _bignum_nist_p_384_sqr = {
677 (BN_ULONG *)_nist_p_384_sqr,
678 sizeof(_nist_p_384_sqr)/sizeof(_nist_p_384_sqr[0]),
679 sizeof(_nist_p_384_sqr)/sizeof(_nist_p_384_sqr[0]),
680 0,BN_FLG_STATIC_DATA };
681
567 682
568 field = &_bignum_nist_p_384; /* just to make sure */ 683 field = &_bignum_nist_p_384; /* just to make sure */
569 684
570 if (BN_is_negative(a) || a->top > 2*BN_NIST_384_TOP) 685 if (BN_is_negative(a) || BN_ucmp(a,&_bignum_nist_p_384_sqr)>=0)
571 return BN_nnmod(r, field, a, ctx); 686 return BN_nnmod(r, a, field, ctx);
572 687
573 i = BN_ucmp(field, a); 688 i = BN_ucmp(field, a);
574 if (i == 0) 689 if (i == 0)
@@ -606,171 +721,116 @@ int BN_nist_mod_384(BIGNUM *r, const BIGNUM *a, const BIGNUM *field,
606 } 721 }
607 *ap=c; 722 *ap=c;
608 } 723 }
609 carry = bn_add_words(r_d+(128/BN_BITS2), r_d+(128/BN_BITS2), 724 carry = (int)bn_add_words(r_d+(128/BN_BITS2), r_d+(128/BN_BITS2),
610 t_d, BN_NIST_256_TOP); 725 t_d, BN_NIST_256_TOP);
611 /*
612 * we need if (result>=modulus) subtract(result,modulus);
613 * in n-bit space this can be expressed as
614 * if (carry || result>=modulus) subtract(result,modulus);
615 * the catch is that comparison implies subtraction and
616 * therefore one can write tmp=subtract(result,modulus);
617 * and then if(carry || !borrow) result=tmp; this's what
618 * happens below, but without explicit if:-) a.
619 */
620 mask = 0-(size_t)bn_sub_words(c_d,r_d,_nist_p_384,BN_NIST_384_TOP);
621 mask = ~mask | (0-(size_t)carry);
622 res = (BN_ULONG *)(((size_t)c_d&mask) | ((size_t)r_d&~mask));
623
624 /*S2 */ 726 /*S2 */
625 carry = bn_add_words(r_d, res, buf, BN_NIST_384_TOP); 727 carry += (int)bn_add_words(r_d, r_d, buf, BN_NIST_384_TOP);
626 mask = 0-(size_t)bn_sub_words(c_d,r_d,_nist_p_384,BN_NIST_384_TOP);
627 mask = ~mask | (0-(size_t)carry);
628 res = (BN_ULONG *)(((size_t)c_d&mask) | ((size_t)r_d&~mask));
629
630 /*S3*/ 728 /*S3*/
631 nist_set_384(t_d,buf,20,19,18,17,16,15,14,13,12,23,22,21); 729 nist_set_384(t_d,buf,20,19,18,17,16,15,14,13,12,23,22,21);
632 carry = bn_add_words(r_d, res, t_d, BN_NIST_384_TOP); 730 carry += (int)bn_add_words(r_d, r_d, t_d, BN_NIST_384_TOP);
633 mask = 0-(size_t)bn_sub_words(c_d,r_d,_nist_p_384,BN_NIST_384_TOP);
634 mask = ~mask | (0-(size_t)carry);
635 res = (BN_ULONG *)(((size_t)c_d&mask) | ((size_t)r_d&~mask));
636
637 /*S4*/ 731 /*S4*/
638 nist_set_384(t_d,buf,19,18,17,16,15,14,13,12,20,0,23,0); 732 nist_set_384(t_d,buf,19,18,17,16,15,14,13,12,20,0,23,0);
639 carry = bn_add_words(r_d, res, t_d, BN_NIST_384_TOP); 733 carry += (int)bn_add_words(r_d, r_d, t_d, BN_NIST_384_TOP);
640 mask = 0-(size_t)bn_sub_words(c_d,r_d,_nist_p_384,BN_NIST_384_TOP);
641 mask = ~mask | (0-(size_t)carry);
642 res = (BN_ULONG *)(((size_t)c_d&mask) | ((size_t)r_d&~mask));
643
644 /*S5*/ 734 /*S5*/
645 nist_set_384(t_d, buf,0,0,0,0,23,22,21,20,0,0,0,0); 735 nist_set_384(t_d, buf,0,0,0,0,23,22,21,20,0,0,0,0);
646 carry = bn_add_words(r_d, res, t_d, BN_NIST_384_TOP); 736 carry += (int)bn_add_words(r_d, r_d, t_d, BN_NIST_384_TOP);
647 mask = 0-(size_t)bn_sub_words(c_d,r_d,_nist_p_384,BN_NIST_384_TOP);
648 mask = ~mask | (0-(size_t)carry);
649 res = (BN_ULONG *)(((size_t)c_d&mask) | ((size_t)r_d&~mask));
650
651 /*S6*/ 737 /*S6*/
652 nist_set_384(t_d,buf,0,0,0,0,0,0,23,22,21,0,0,20); 738 nist_set_384(t_d,buf,0,0,0,0,0,0,23,22,21,0,0,20);
653 carry = bn_add_words(r_d, res, t_d, BN_NIST_384_TOP); 739 carry += (int)bn_add_words(r_d, r_d, t_d, BN_NIST_384_TOP);
654 mask = 0-(size_t)bn_sub_words(c_d,r_d,_nist_p_384,BN_NIST_384_TOP);
655 mask = ~mask | (0-(size_t)carry);
656 res = (BN_ULONG *)(((size_t)c_d&mask) | ((size_t)r_d&~mask));
657
658 /*D1*/ 740 /*D1*/
659 nist_set_384(t_d,buf,22,21,20,19,18,17,16,15,14,13,12,23); 741 nist_set_384(t_d,buf,22,21,20,19,18,17,16,15,14,13,12,23);
660#if BRANCH_FREE 742 carry -= (int)bn_sub_words(r_d, r_d, t_d, BN_NIST_384_TOP);
661 carry = bn_sub_words(r_d, res, t_d, BN_NIST_384_TOP);
662 bn_add_words(c_d,r_d,_nist_p_384,BN_NIST_384_TOP);
663 mask = 0-(size_t)carry;
664 res = (BN_ULONG *)(((size_t)c_d&mask) | ((size_t)r_d&~mask));
665#else
666 if (bn_sub_words(r_d, res, t_d, BN_NIST_384_TOP))
667 bn_add_words(r_d,r_d,_nist_p_384,BN_NIST_384_TOP);
668#endif
669 /*D2*/ 743 /*D2*/
670 nist_set_384(t_d,buf,0,0,0,0,0,0,0,23,22,21,20,0); 744 nist_set_384(t_d,buf,0,0,0,0,0,0,0,23,22,21,20,0);
671#if BRANCH_FREE 745 carry -= (int)bn_sub_words(r_d, r_d, t_d, BN_NIST_384_TOP);
672 carry = bn_sub_words(r_d, res, t_d, BN_NIST_384_TOP);
673 bn_add_words(c_d,r_d,_nist_p_384,BN_NIST_384_TOP);
674 mask = 0-(size_t)carry;
675 res = (BN_ULONG *)(((size_t)c_d&mask) | ((size_t)r_d&~mask));
676#else
677 if (bn_sub_words(r_d, r_d, t_d, BN_NIST_384_TOP))
678 bn_add_words(r_d,r_d,_nist_p_384,BN_NIST_384_TOP);
679#endif
680 /*D3*/ 746 /*D3*/
681 nist_set_384(t_d,buf,0,0,0,0,0,0,0,23,23,0,0,0); 747 nist_set_384(t_d,buf,0,0,0,0,0,0,0,23,23,0,0,0);
682#if BRANCH_FREE 748 carry -= (int)bn_sub_words(r_d, r_d, t_d, BN_NIST_384_TOP);
683 carry = bn_sub_words(r_d, res, t_d, BN_NIST_384_TOP);
684 bn_add_words(c_d,r_d,_nist_p_384,BN_NIST_384_TOP);
685 mask = 0-(size_t)carry;
686 res = (BN_ULONG *)(((size_t)c_d&mask) | ((size_t)r_d&~mask));
687 749
750 /* see BN_nist_mod_224 for explanation */
751 u.f = bn_sub_words;
752 if (carry > 0)
753 carry = (int)bn_sub_words(r_d,r_d,_nist_p_384[carry-1],BN_NIST_384_TOP);
754 else if (carry < 0)
755 {
756 carry = (int)bn_add_words(r_d,r_d,_nist_p_384[-carry-1],BN_NIST_384_TOP);
757 mask = 0-(size_t)carry;
758 u.p = ((size_t)bn_sub_words&mask) | ((size_t)bn_add_words&~mask);
759 }
760 else
761 carry = 1;
762
763 mask = 0-(size_t)(*u.f)(c_d,r_d,_nist_p_384[0],BN_NIST_384_TOP);
764 mask &= 0-(size_t)carry;
765 res = (BN_ULONG *)(((size_t)c_d&~mask) | ((size_t)r_d&mask));
688 nist_cp_bn(r_d, res, BN_NIST_384_TOP); 766 nist_cp_bn(r_d, res, BN_NIST_384_TOP);
689#else
690 if (bn_sub_words(r_d, r_d, t_d, BN_NIST_384_TOP))
691 bn_add_words(r_d,r_d,_nist_p_384,BN_NIST_384_TOP);
692#endif
693 r->top = BN_NIST_384_TOP; 767 r->top = BN_NIST_384_TOP;
694 bn_correct_top(r); 768 bn_correct_top(r);
695 769
696 if (BN_ucmp(field, r) <= 0)
697 {
698 if (!BN_usub(r, r, field)) return 0;
699 }
700
701 return 1; 770 return 1;
702#else /* BN_BITS!=32 */
703 return 0;
704#endif
705 } 771 }
706 772
773#define BN_NIST_521_RSHIFT (521%BN_BITS2)
774#define BN_NIST_521_LSHIFT (BN_BITS2-BN_NIST_521_RSHIFT)
775#define BN_NIST_521_TOP_MASK ((BN_ULONG)BN_MASK2>>BN_NIST_521_LSHIFT)
776
707int BN_nist_mod_521(BIGNUM *r, const BIGNUM *a, const BIGNUM *field, 777int BN_nist_mod_521(BIGNUM *r, const BIGNUM *a, const BIGNUM *field,
708 BN_CTX *ctx) 778 BN_CTX *ctx)
709 { 779 {
710#if BN_BITS2 == 64 780 int top = a->top, i;
711#define BN_NIST_521_TOP_MASK (BN_ULONG)0x1FF 781 BN_ULONG *r_d, *a_d = a->d,
712#elif BN_BITS2 == 32 782 t_d[BN_NIST_521_TOP],
713#define BN_NIST_521_TOP_MASK (BN_ULONG)0x1FF 783 val,tmp,*res;
714#endif 784 size_t mask;
715 int top, ret = 0; 785 static const BIGNUM _bignum_nist_p_521_sqr = {
716 BIGNUM *tmp; 786 (BN_ULONG *)_nist_p_521_sqr,
787 sizeof(_nist_p_521_sqr)/sizeof(_nist_p_521_sqr[0]),
788 sizeof(_nist_p_521_sqr)/sizeof(_nist_p_521_sqr[0]),
789 0,BN_FLG_STATIC_DATA };
717 790
718 field = &_bignum_nist_p_521; /* just to make sure */ 791 field = &_bignum_nist_p_521; /* just to make sure */
719 792
720 if (BN_is_negative(a)) 793 if (BN_is_negative(a) || BN_ucmp(a,&_bignum_nist_p_521_sqr)>=0)
721 return BN_nnmod(r, field, a, ctx); 794 return BN_nnmod(r, a, field, ctx);
722 795
723 /* check whether a reduction is necessary */ 796 i = BN_ucmp(field, a);
724 top = a->top; 797 if (i == 0)
725 if (top < BN_NIST_521_TOP || ( top == BN_NIST_521_TOP &&
726 (!(a->d[BN_NIST_521_TOP-1] & ~(BN_NIST_521_TOP_MASK)))))
727 { 798 {
728 int i = BN_ucmp(field, a); 799 BN_zero(r);
729 if (i == 0) 800 return 1;
730 {
731 BN_zero(r);
732 return 1;
733 }
734 else
735 {
736#ifdef BN_DEBUG
737 OPENSSL_assert(i > 0); /* because 'field' is 1111...1111 */
738#endif
739 return (r == a)? 1 : (BN_copy(r ,a) != NULL);
740 }
741 } 801 }
802 else if (i > 0)
803 return (r == a)? 1 : (BN_copy(r ,a) != NULL);
742 804
743 if (BN_num_bits(a) > 2*521) 805 if (r != a)
744 return BN_nnmod(r, field, a, ctx);
745
746 BN_CTX_start(ctx);
747 tmp = BN_CTX_get(ctx);
748 if (!tmp)
749 goto err;
750
751 if (!bn_wexpand(tmp, BN_NIST_521_TOP))
752 goto err;
753 nist_cp_bn(tmp->d, a->d, BN_NIST_521_TOP);
754
755 tmp->top = BN_NIST_521_TOP;
756 tmp->d[BN_NIST_521_TOP-1] &= BN_NIST_521_TOP_MASK;
757 bn_correct_top(tmp);
758
759 if (!BN_rshift(r, a, 521))
760 goto err;
761
762 if (!BN_uadd(r, tmp, r))
763 goto err;
764
765 if (BN_ucmp(field, r) <= 0)
766 { 806 {
767 if (!BN_usub(r, r, field)) goto err; 807 if (!bn_wexpand(r,BN_NIST_521_TOP))
808 return 0;
809 r_d = r->d;
810 nist_cp_bn(r_d,a_d, BN_NIST_521_TOP);
768 } 811 }
812 else
813 r_d = a_d;
769 814
770 ret = 1; 815 /* upper 521 bits, copy ... */
771err: 816 nist_cp_bn_0(t_d,a_d + (BN_NIST_521_TOP-1), top - (BN_NIST_521_TOP-1),BN_NIST_521_TOP);
772 BN_CTX_end(ctx); 817 /* ... and right shift */
818 for (val=t_d[0],i=0; i<BN_NIST_521_TOP-1; i++)
819 {
820 tmp = val>>BN_NIST_521_RSHIFT;
821 val = t_d[i+1];
822 t_d[i] = (tmp | val<<BN_NIST_521_LSHIFT) & BN_MASK2;
823 }
824 t_d[i] = val>>BN_NIST_521_RSHIFT;
825 /* lower 521 bits */
826 r_d[i] &= BN_NIST_521_TOP_MASK;
827
828 bn_add_words(r_d,r_d,t_d,BN_NIST_521_TOP);
829 mask = 0-(size_t)bn_sub_words(t_d,r_d,_nist_p_521,BN_NIST_521_TOP);
830 res = (BN_ULONG *)(((size_t)t_d&~mask) | ((size_t)r_d&mask));
831 nist_cp_bn(r_d,res,BN_NIST_521_TOP);
832 r->top = BN_NIST_521_TOP;
833 bn_correct_top(r);
773 834
774 bn_check_top(r); 835 return 1;
775 return ret;
776 } 836 }
diff --git a/src/lib/libcrypto/bn/bn_rand.c b/src/lib/libcrypto/bn/bn_rand.c
index f51830b12b..b376c28ff3 100644
--- a/src/lib/libcrypto/bn/bn_rand.c
+++ b/src/lib/libcrypto/bn/bn_rand.c
@@ -227,7 +227,7 @@ int BN_bntest_rand(BIGNUM *rnd, int bits, int top, int bottom)
227 227
228 228
229/* random number r: 0 <= r < range */ 229/* random number r: 0 <= r < range */
230static int bn_rand_range(int pseudo, BIGNUM *r, BIGNUM *range) 230static int bn_rand_range(int pseudo, BIGNUM *r, const BIGNUM *range)
231 { 231 {
232 int (*bn_rand)(BIGNUM *, int, int, int) = pseudo ? BN_pseudo_rand : BN_rand; 232 int (*bn_rand)(BIGNUM *, int, int, int) = pseudo ? BN_pseudo_rand : BN_rand;
233 int n; 233 int n;
@@ -294,12 +294,12 @@ static int bn_rand_range(int pseudo, BIGNUM *r, BIGNUM *range)
294 } 294 }
295 295
296 296
297int BN_rand_range(BIGNUM *r, BIGNUM *range) 297int BN_rand_range(BIGNUM *r, const BIGNUM *range)
298 { 298 {
299 return bn_rand_range(0, r, range); 299 return bn_rand_range(0, r, range);
300 } 300 }
301 301
302int BN_pseudo_rand_range(BIGNUM *r, BIGNUM *range) 302int BN_pseudo_rand_range(BIGNUM *r, const BIGNUM *range)
303 { 303 {
304 return bn_rand_range(1, r, range); 304 return bn_rand_range(1, r, range);
305 } 305 }
diff --git a/src/lib/libcrypto/bn/bn_shift.c b/src/lib/libcrypto/bn/bn_shift.c
index de9312dce2..c4d301afc4 100644
--- a/src/lib/libcrypto/bn/bn_shift.c
+++ b/src/lib/libcrypto/bn/bn_shift.c
@@ -177,7 +177,7 @@ int BN_rshift(BIGNUM *r, const BIGNUM *a, int n)
177 nw=n/BN_BITS2; 177 nw=n/BN_BITS2;
178 rb=n%BN_BITS2; 178 rb=n%BN_BITS2;
179 lb=BN_BITS2-rb; 179 lb=BN_BITS2-rb;
180 if (nw > a->top || a->top == 0) 180 if (nw >= a->top || a->top == 0)
181 { 181 {
182 BN_zero(r); 182 BN_zero(r);
183 return(1); 183 return(1);
diff --git a/src/lib/libcrypto/buffer/buffer.c b/src/lib/libcrypto/buffer/buffer.c
index 3bf03c7eff..b3e947771d 100644
--- a/src/lib/libcrypto/buffer/buffer.c
+++ b/src/lib/libcrypto/buffer/buffer.c
@@ -161,61 +161,3 @@ int BUF_MEM_grow_clean(BUF_MEM *str, int len)
161 } 161 }
162 return(len); 162 return(len);
163 } 163 }
164
165char *BUF_strdup(const char *str)
166 {
167 if (str == NULL) return(NULL);
168 return BUF_strndup(str, strlen(str));
169 }
170
171char *BUF_strndup(const char *str, size_t siz)
172 {
173 char *ret;
174
175 if (str == NULL) return(NULL);
176
177 ret=OPENSSL_malloc(siz+1);
178 if (ret == NULL)
179 {
180 BUFerr(BUF_F_BUF_STRNDUP,ERR_R_MALLOC_FAILURE);
181 return(NULL);
182 }
183 BUF_strlcpy(ret,str,siz+1);
184 return(ret);
185 }
186
187void *BUF_memdup(const void *data, size_t siz)
188 {
189 void *ret;
190
191 if (data == NULL) return(NULL);
192
193 ret=OPENSSL_malloc(siz);
194 if (ret == NULL)
195 {
196 BUFerr(BUF_F_BUF_MEMDUP,ERR_R_MALLOC_FAILURE);
197 return(NULL);
198 }
199 return memcpy(ret, data, siz);
200 }
201
202size_t BUF_strlcpy(char *dst, const char *src, size_t size)
203 {
204 size_t l = 0;
205 for(; size > 1 && *src; size--)
206 {
207 *dst++ = *src++;
208 l++;
209 }
210 if (size)
211 *dst = '\0';
212 return l + strlen(src);
213 }
214
215size_t BUF_strlcat(char *dst, const char *src, size_t size)
216 {
217 size_t l = 0;
218 for(; size > 0 && *dst; size--, dst++)
219 l++;
220 return l + BUF_strlcpy(dst, src, size);
221 }
diff --git a/src/lib/libcrypto/cast/c_skey.c b/src/lib/libcrypto/cast/c_skey.c
index 76e40005c9..68e690a60c 100644
--- a/src/lib/libcrypto/cast/c_skey.c
+++ b/src/lib/libcrypto/cast/c_skey.c
@@ -57,6 +57,11 @@
57 */ 57 */
58 58
59#include <openssl/cast.h> 59#include <openssl/cast.h>
60#include <openssl/crypto.h>
61#ifdef OPENSSL_FIPS
62#include <openssl/fips.h>
63#endif
64
60#include "cast_lcl.h" 65#include "cast_lcl.h"
61#include "cast_s.h" 66#include "cast_s.h"
62 67
@@ -72,7 +77,7 @@
72#define S6 CAST_S_table6 77#define S6 CAST_S_table6
73#define S7 CAST_S_table7 78#define S7 CAST_S_table7
74 79
75void CAST_set_key(CAST_KEY *key, int len, const unsigned char *data) 80FIPS_NON_FIPS_VCIPHER_Init(CAST)
76 { 81 {
77 CAST_LONG x[16]; 82 CAST_LONG x[16];
78 CAST_LONG z[16]; 83 CAST_LONG z[16];
diff --git a/src/lib/libcrypto/cast/cast.h b/src/lib/libcrypto/cast/cast.h
index 90b45b950a..1faf5806aa 100644
--- a/src/lib/libcrypto/cast/cast.h
+++ b/src/lib/libcrypto/cast/cast.h
@@ -83,7 +83,9 @@ typedef struct cast_key_st
83 int short_key; /* Use reduced rounds for short key */ 83 int short_key; /* Use reduced rounds for short key */
84 } CAST_KEY; 84 } CAST_KEY;
85 85
86 86#ifdef OPENSSL_FIPS
87void private_CAST_set_key(CAST_KEY *key, int len, const unsigned char *data);
88#endif
87void CAST_set_key(CAST_KEY *key, int len, const unsigned char *data); 89void CAST_set_key(CAST_KEY *key, int len, const unsigned char *data);
88void CAST_ecb_encrypt(const unsigned char *in,unsigned char *out,CAST_KEY *key, 90void CAST_ecb_encrypt(const unsigned char *in,unsigned char *out,CAST_KEY *key,
89 int enc); 91 int enc);
diff --git a/src/lib/libcrypto/cms/cms_smime.c b/src/lib/libcrypto/cms/cms_smime.c
index b35d28d411..b9463f9abb 100644
--- a/src/lib/libcrypto/cms/cms_smime.c
+++ b/src/lib/libcrypto/cms/cms_smime.c
@@ -68,7 +68,10 @@ static int cms_copy_content(BIO *out, BIO *in, unsigned int flags)
68 if (out == NULL) 68 if (out == NULL)
69 tmpout = BIO_new(BIO_s_null()); 69 tmpout = BIO_new(BIO_s_null());
70 else if (flags & CMS_TEXT) 70 else if (flags & CMS_TEXT)
71 {
71 tmpout = BIO_new(BIO_s_mem()); 72 tmpout = BIO_new(BIO_s_mem());
73 BIO_set_mem_eof_return(tmpout, 0);
74 }
72 else 75 else
73 tmpout = out; 76 tmpout = out;
74 77
diff --git a/src/lib/libcrypto/comp/c_zlib.c b/src/lib/libcrypto/comp/c_zlib.c
index 0f34597e70..eccfd09137 100644
--- a/src/lib/libcrypto/comp/c_zlib.c
+++ b/src/lib/libcrypto/comp/c_zlib.c
@@ -727,6 +727,7 @@ static long bio_zlib_ctrl(BIO *b, int cmd, long num, void *ptr)
727 case BIO_CTRL_RESET: 727 case BIO_CTRL_RESET:
728 ctx->ocount = 0; 728 ctx->ocount = 0;
729 ctx->odone = 0; 729 ctx->odone = 0;
730 ret = 1;
730 break; 731 break;
731 732
732 case BIO_CTRL_FLUSH: 733 case BIO_CTRL_FLUSH:
@@ -771,7 +772,7 @@ static long bio_zlib_ctrl(BIO *b, int cmd, long num, void *ptr)
771 } 772 }
772 ctx->obufsize = obs; 773 ctx->obufsize = obs;
773 } 774 }
774 775 ret = 1;
775 break; 776 break;
776 777
777 case BIO_C_DO_STATE_MACHINE: 778 case BIO_C_DO_STATE_MACHINE:
@@ -783,7 +784,6 @@ static long bio_zlib_ctrl(BIO *b, int cmd, long num, void *ptr)
783 default: 784 default:
784 ret = BIO_ctrl(b->next_bio, cmd, num, ptr); 785 ret = BIO_ctrl(b->next_bio, cmd, num, ptr);
785 break; 786 break;
786
787 } 787 }
788 788
789 return ret; 789 return ret;
diff --git a/src/lib/libcrypto/conf/conf_mall.c b/src/lib/libcrypto/conf/conf_mall.c
index 4ba40cf44c..1cc1fd5534 100644
--- a/src/lib/libcrypto/conf/conf_mall.c
+++ b/src/lib/libcrypto/conf/conf_mall.c
@@ -1,5 +1,5 @@
1/* conf_mall.c */ 1/* conf_mall.c */
2/* Written by Stephen Henson (shenson@bigfoot.com) for the OpenSSL 2/* Written by Stephen Henson (steve@openssl.org) for the OpenSSL
3 * project 2001. 3 * project 2001.
4 */ 4 */
5/* ==================================================================== 5/* ====================================================================
@@ -63,6 +63,7 @@
63#include <openssl/dso.h> 63#include <openssl/dso.h>
64#include <openssl/x509.h> 64#include <openssl/x509.h>
65#include <openssl/asn1.h> 65#include <openssl/asn1.h>
66#include <openssl/evp.h>
66#ifndef OPENSSL_NO_ENGINE 67#ifndef OPENSSL_NO_ENGINE
67#include <openssl/engine.h> 68#include <openssl/engine.h>
68#endif 69#endif
@@ -76,5 +77,6 @@ void OPENSSL_load_builtin_modules(void)
76#ifndef OPENSSL_NO_ENGINE 77#ifndef OPENSSL_NO_ENGINE
77 ENGINE_add_conf_module(); 78 ENGINE_add_conf_module();
78#endif 79#endif
80 EVP_add_alg_module();
79 } 81 }
80 82
diff --git a/src/lib/libcrypto/conf/conf_mod.c b/src/lib/libcrypto/conf/conf_mod.c
index 58b23ba992..e286378cb1 100644
--- a/src/lib/libcrypto/conf/conf_mod.c
+++ b/src/lib/libcrypto/conf/conf_mod.c
@@ -1,5 +1,5 @@
1/* conf_mod.c */ 1/* conf_mod.c */
2/* Written by Stephen Henson (shenson@bigfoot.com) for the OpenSSL 2/* Written by Stephen Henson (steve@openssl.org) for the OpenSSL
3 * project 2001. 3 * project 2001.
4 */ 4 */
5/* ==================================================================== 5/* ====================================================================
diff --git a/src/lib/libcrypto/conf/conf_sap.c b/src/lib/libcrypto/conf/conf_sap.c
index 9c53bac1a8..760dc2632d 100644
--- a/src/lib/libcrypto/conf/conf_sap.c
+++ b/src/lib/libcrypto/conf/conf_sap.c
@@ -1,5 +1,5 @@
1/* conf_sap.c */ 1/* conf_sap.c */
2/* Written by Stephen Henson (shenson@bigfoot.com) for the OpenSSL 2/* Written by Stephen Henson (steve@openssl.org) for the OpenSSL
3 * project 2001. 3 * project 2001.
4 */ 4 */
5/* ==================================================================== 5/* ====================================================================
diff --git a/src/lib/libcrypto/cryptlib.c b/src/lib/libcrypto/cryptlib.c
index 8c68623828..8f9e88e403 100644
--- a/src/lib/libcrypto/cryptlib.c
+++ b/src/lib/libcrypto/cryptlib.c
@@ -121,275 +121,17 @@
121static double SSLeay_MSVC5_hack=0.0; /* and for VC1.5 */ 121static double SSLeay_MSVC5_hack=0.0; /* and for VC1.5 */
122#endif 122#endif
123 123
124DECLARE_STACK_OF(CRYPTO_dynlock)
125IMPLEMENT_STACK_OF(CRYPTO_dynlock)
126
127/* real #defines in crypto.h, keep these upto date */
128static const char* const lock_names[CRYPTO_NUM_LOCKS] =
129 {
130 "<<ERROR>>",
131 "err",
132 "ex_data",
133 "x509",
134 "x509_info",
135 "x509_pkey",
136 "x509_crl",
137 "x509_req",
138 "dsa",
139 "rsa",
140 "evp_pkey",
141 "x509_store",
142 "ssl_ctx",
143 "ssl_cert",
144 "ssl_session",
145 "ssl_sess_cert",
146 "ssl",
147 "ssl_method",
148 "rand",
149 "rand2",
150 "debug_malloc",
151 "BIO",
152 "gethostbyname",
153 "getservbyname",
154 "readdir",
155 "RSA_blinding",
156 "dh",
157 "debug_malloc2",
158 "dso",
159 "dynlock",
160 "engine",
161 "ui",
162 "ecdsa",
163 "ec",
164 "ecdh",
165 "bn",
166 "ec_pre_comp",
167 "store",
168 "comp",
169#if CRYPTO_NUM_LOCKS != 39
170# error "Inconsistency between crypto.h and cryptlib.c"
171#endif
172 };
173
174/* This is for applications to allocate new type names in the non-dynamic
175 array of lock names. These are numbered with positive numbers. */
176static STACK *app_locks=NULL;
177
178/* For applications that want a more dynamic way of handling threads, the
179 following stack is used. These are externally numbered with negative
180 numbers. */
181static STACK_OF(CRYPTO_dynlock) *dyn_locks=NULL;
182
183
184static void (MS_FAR *locking_callback)(int mode,int type, 124static void (MS_FAR *locking_callback)(int mode,int type,
185 const char *file,int line)=NULL; 125 const char *file,int line)=NULL;
186static int (MS_FAR *add_lock_callback)(int *pointer,int amount, 126static int (MS_FAR *add_lock_callback)(int *pointer,int amount,
187 int type,const char *file,int line)=NULL; 127 int type,const char *file,int line)=NULL;
188static unsigned long (MS_FAR *id_callback)(void)=NULL; 128static unsigned long (MS_FAR *id_callback)(void)=NULL;
189static struct CRYPTO_dynlock_value *(MS_FAR *dynlock_create_callback)
190 (const char *file,int line)=NULL;
191static void (MS_FAR *dynlock_lock_callback)(int mode,
192 struct CRYPTO_dynlock_value *l, const char *file,int line)=NULL;
193static void (MS_FAR *dynlock_destroy_callback)(struct CRYPTO_dynlock_value *l,
194 const char *file,int line)=NULL;
195
196int CRYPTO_get_new_lockid(char *name)
197 {
198 char *str;
199 int i;
200
201#if defined(OPENSSL_SYS_WIN32) || defined(OPENSSL_SYS_WIN16)
202 /* A hack to make Visual C++ 5.0 work correctly when linking as
203 * a DLL using /MT. Without this, the application cannot use
204 * and floating point printf's.
205 * It also seems to be needed for Visual C 1.5 (win16) */
206 SSLeay_MSVC5_hack=(double)name[0]*(double)name[1];
207#endif
208
209 if ((app_locks == NULL) && ((app_locks=sk_new_null()) == NULL))
210 {
211 CRYPTOerr(CRYPTO_F_CRYPTO_GET_NEW_LOCKID,ERR_R_MALLOC_FAILURE);
212 return(0);
213 }
214 if ((str=BUF_strdup(name)) == NULL)
215 {
216 CRYPTOerr(CRYPTO_F_CRYPTO_GET_NEW_LOCKID,ERR_R_MALLOC_FAILURE);
217 return(0);
218 }
219 i=sk_push(app_locks,str);
220 if (!i)
221 OPENSSL_free(str);
222 else
223 i+=CRYPTO_NUM_LOCKS; /* gap of one :-) */
224 return(i);
225 }
226 129
227int CRYPTO_num_locks(void) 130int CRYPTO_num_locks(void)
228 { 131 {
229 return CRYPTO_NUM_LOCKS; 132 return CRYPTO_NUM_LOCKS;
230 } 133 }
231 134
232int CRYPTO_get_new_dynlockid(void)
233 {
234 int i = 0;
235 CRYPTO_dynlock *pointer = NULL;
236
237 if (dynlock_create_callback == NULL)
238 {
239 CRYPTOerr(CRYPTO_F_CRYPTO_GET_NEW_DYNLOCKID,CRYPTO_R_NO_DYNLOCK_CREATE_CALLBACK);
240 return(0);
241 }
242 CRYPTO_w_lock(CRYPTO_LOCK_DYNLOCK);
243 if ((dyn_locks == NULL)
244 && ((dyn_locks=sk_CRYPTO_dynlock_new_null()) == NULL))
245 {
246 CRYPTO_w_unlock(CRYPTO_LOCK_DYNLOCK);
247 CRYPTOerr(CRYPTO_F_CRYPTO_GET_NEW_DYNLOCKID,ERR_R_MALLOC_FAILURE);
248 return(0);
249 }
250 CRYPTO_w_unlock(CRYPTO_LOCK_DYNLOCK);
251
252 pointer = (CRYPTO_dynlock *)OPENSSL_malloc(sizeof(CRYPTO_dynlock));
253 if (pointer == NULL)
254 {
255 CRYPTOerr(CRYPTO_F_CRYPTO_GET_NEW_DYNLOCKID,ERR_R_MALLOC_FAILURE);
256 return(0);
257 }
258 pointer->references = 1;
259 pointer->data = dynlock_create_callback(__FILE__,__LINE__);
260 if (pointer->data == NULL)
261 {
262 OPENSSL_free(pointer);
263 CRYPTOerr(CRYPTO_F_CRYPTO_GET_NEW_DYNLOCKID,ERR_R_MALLOC_FAILURE);
264 return(0);
265 }
266
267 CRYPTO_w_lock(CRYPTO_LOCK_DYNLOCK);
268 /* First, try to find an existing empty slot */
269 i=sk_CRYPTO_dynlock_find(dyn_locks,NULL);
270 /* If there was none, push, thereby creating a new one */
271 if (i == -1)
272 /* Since sk_push() returns the number of items on the
273 stack, not the location of the pushed item, we need
274 to transform the returned number into a position,
275 by decreasing it. */
276 i=sk_CRYPTO_dynlock_push(dyn_locks,pointer) - 1;
277 else
278 /* If we found a place with a NULL pointer, put our pointer
279 in it. */
280 (void)sk_CRYPTO_dynlock_set(dyn_locks,i,pointer);
281 CRYPTO_w_unlock(CRYPTO_LOCK_DYNLOCK);
282
283 if (i == -1)
284 {
285 dynlock_destroy_callback(pointer->data,__FILE__,__LINE__);
286 OPENSSL_free(pointer);
287 }
288 else
289 i += 1; /* to avoid 0 */
290 return -i;
291 }
292
293void CRYPTO_destroy_dynlockid(int i)
294 {
295 CRYPTO_dynlock *pointer = NULL;
296 if (i)
297 i = -i-1;
298 if (dynlock_destroy_callback == NULL)
299 return;
300
301 CRYPTO_w_lock(CRYPTO_LOCK_DYNLOCK);
302
303 if (dyn_locks == NULL || i >= sk_CRYPTO_dynlock_num(dyn_locks))
304 {
305 CRYPTO_w_unlock(CRYPTO_LOCK_DYNLOCK);
306 return;
307 }
308 pointer = sk_CRYPTO_dynlock_value(dyn_locks, i);
309 if (pointer != NULL)
310 {
311 --pointer->references;
312#ifdef REF_CHECK
313 if (pointer->references < 0)
314 {
315 fprintf(stderr,"CRYPTO_destroy_dynlockid, bad reference count\n");
316 abort();
317 }
318 else
319#endif
320 if (pointer->references <= 0)
321 {
322 (void)sk_CRYPTO_dynlock_set(dyn_locks, i, NULL);
323 }
324 else
325 pointer = NULL;
326 }
327 CRYPTO_w_unlock(CRYPTO_LOCK_DYNLOCK);
328
329 if (pointer)
330 {
331 dynlock_destroy_callback(pointer->data,__FILE__,__LINE__);
332 OPENSSL_free(pointer);
333 }
334 }
335
336struct CRYPTO_dynlock_value *CRYPTO_get_dynlock_value(int i)
337 {
338 CRYPTO_dynlock *pointer = NULL;
339 if (i)
340 i = -i-1;
341
342 CRYPTO_w_lock(CRYPTO_LOCK_DYNLOCK);
343
344 if (dyn_locks != NULL && i < sk_CRYPTO_dynlock_num(dyn_locks))
345 pointer = sk_CRYPTO_dynlock_value(dyn_locks, i);
346 if (pointer)
347 pointer->references++;
348
349 CRYPTO_w_unlock(CRYPTO_LOCK_DYNLOCK);
350
351 if (pointer)
352 return pointer->data;
353 return NULL;
354 }
355
356struct CRYPTO_dynlock_value *(*CRYPTO_get_dynlock_create_callback(void))
357 (const char *file,int line)
358 {
359 return(dynlock_create_callback);
360 }
361
362void (*CRYPTO_get_dynlock_lock_callback(void))(int mode,
363 struct CRYPTO_dynlock_value *l, const char *file,int line)
364 {
365 return(dynlock_lock_callback);
366 }
367
368void (*CRYPTO_get_dynlock_destroy_callback(void))
369 (struct CRYPTO_dynlock_value *l, const char *file,int line)
370 {
371 return(dynlock_destroy_callback);
372 }
373
374void CRYPTO_set_dynlock_create_callback(struct CRYPTO_dynlock_value *(*func)
375 (const char *file, int line))
376 {
377 dynlock_create_callback=func;
378 }
379
380void CRYPTO_set_dynlock_lock_callback(void (*func)(int mode,
381 struct CRYPTO_dynlock_value *l, const char *file, int line))
382 {
383 dynlock_lock_callback=func;
384 }
385
386void CRYPTO_set_dynlock_destroy_callback(void (*func)
387 (struct CRYPTO_dynlock_value *l, const char *file, int line))
388 {
389 dynlock_destroy_callback=func;
390 }
391
392
393void (*CRYPTO_get_locking_callback(void))(int mode,int type,const char *file, 135void (*CRYPTO_get_locking_callback(void))(int mode,int type,const char *file,
394 int line) 136 int line)
395 { 137 {
@@ -445,6 +187,14 @@ unsigned long CRYPTO_thread_id(void)
445 return(ret); 187 return(ret);
446 } 188 }
447 189
190static void (*do_dynlock_cb)(int mode, int type, const char *file, int line);
191
192void int_CRYPTO_set_do_dynlock_callback(
193 void (*dyn_cb)(int mode, int type, const char *file, int line))
194 {
195 do_dynlock_cb = dyn_cb;
196 }
197
448void CRYPTO_lock(int mode, int type, const char *file, int line) 198void CRYPTO_lock(int mode, int type, const char *file, int line)
449 { 199 {
450#ifdef LOCK_DEBUG 200#ifdef LOCK_DEBUG
@@ -472,17 +222,8 @@ void CRYPTO_lock(int mode, int type, const char *file, int line)
472#endif 222#endif
473 if (type < 0) 223 if (type < 0)
474 { 224 {
475 if (dynlock_lock_callback != NULL) 225 if (do_dynlock_cb)
476 { 226 do_dynlock_cb(mode, type, file, line);
477 struct CRYPTO_dynlock_value *pointer
478 = CRYPTO_get_dynlock_value(type);
479
480 OPENSSL_assert(pointer != NULL);
481
482 dynlock_lock_callback(mode, pointer, file, line);
483
484 CRYPTO_destroy_dynlockid(type);
485 }
486 } 227 }
487 else 228 else
488 if (locking_callback != NULL) 229 if (locking_callback != NULL)
@@ -527,21 +268,9 @@ int CRYPTO_add_lock(int *pointer, int amount, int type, const char *file,
527 return(ret); 268 return(ret);
528 } 269 }
529 270
530const char *CRYPTO_get_lock_name(int type)
531 {
532 if (type < 0)
533 return("dynamic");
534 else if (type < CRYPTO_NUM_LOCKS)
535 return(lock_names[type]);
536 else if (type-CRYPTO_NUM_LOCKS > sk_num(app_locks))
537 return("ERROR");
538 else
539 return(sk_value(app_locks,type-CRYPTO_NUM_LOCKS));
540 }
541
542#if defined(__i386) || defined(__i386__) || defined(_M_IX86) || \ 271#if defined(__i386) || defined(__i386__) || defined(_M_IX86) || \
543 defined(__INTEL__) || \ 272 defined(__INTEL__) || \
544 defined(__x86_64) || defined(__x86_64__) || defined(_M_AMD64) 273 defined(__x86_64) || defined(__x86_64__) || defined(_M_AMD64) || defined(_M_X64)
545 274
546unsigned long OPENSSL_ia32cap_P=0; 275unsigned long OPENSSL_ia32cap_P=0;
547unsigned long *OPENSSL_ia32cap_loc(void) { return &OPENSSL_ia32cap_P; } 276unsigned long *OPENSSL_ia32cap_loc(void) { return &OPENSSL_ia32cap_P; }
@@ -577,6 +306,62 @@ void OPENSSL_cpuid_setup(void) {}
577#endif 306#endif
578 307
579#if (defined(_WIN32) || defined(__CYGWIN__)) && defined(_WINDLL) 308#if (defined(_WIN32) || defined(__CYGWIN__)) && defined(_WINDLL)
309
310#ifdef OPENSSL_FIPS
311
312#include <tlhelp32.h>
313#if defined(__GNUC__) && __GNUC__>=2
314static int DllInit(void) __attribute__((constructor));
315#elif defined(_MSC_VER)
316static int DllInit(void);
317# ifdef _WIN64
318# pragma section(".CRT$XCU",read)
319 __declspec(allocate(".CRT$XCU"))
320# else
321# pragma data_seg(".CRT$XCU")
322# endif
323 static int (*p)(void) = DllInit;
324# pragma data_seg()
325#endif
326
327static int DllInit(void)
328{
329#if defined(_WIN32_WINNT)
330 union { int(*f)(void); BYTE *p; } t = { DllInit };
331 HANDLE hModuleSnap = INVALID_HANDLE_VALUE;
332 IMAGE_DOS_HEADER *dos_header;
333 IMAGE_NT_HEADERS *nt_headers;
334 MODULEENTRY32 me32 = {sizeof(me32)};
335
336 hModuleSnap = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE,0);
337 if (hModuleSnap != INVALID_HANDLE_VALUE &&
338 Module32First(hModuleSnap,&me32)) do
339 {
340 if (t.p >= me32.modBaseAddr &&
341 t.p < me32.modBaseAddr+me32.modBaseSize)
342 {
343 dos_header=(IMAGE_DOS_HEADER *)me32.modBaseAddr;
344 if (dos_header->e_magic==IMAGE_DOS_SIGNATURE)
345 {
346 nt_headers=(IMAGE_NT_HEADERS *)
347 ((BYTE *)dos_header+dos_header->e_lfanew);
348 if (nt_headers->Signature==IMAGE_NT_SIGNATURE &&
349 me32.modBaseAddr!=(BYTE*)nt_headers->OptionalHeader.ImageBase)
350 OPENSSL_NONPIC_relocated=1;
351 }
352 break;
353 }
354 } while (Module32Next(hModuleSnap,&me32));
355
356 if (hModuleSnap != INVALID_HANDLE_VALUE)
357 CloseHandle(hModuleSnap);
358#endif
359 OPENSSL_cpuid_setup();
360 return 0;
361}
362
363#else
364
580#ifdef __CYGWIN__ 365#ifdef __CYGWIN__
581/* pick DLL_[PROCESS|THREAD]_[ATTACH|DETACH] definitions */ 366/* pick DLL_[PROCESS|THREAD]_[ATTACH|DETACH] definitions */
582#include <windows.h> 367#include <windows.h>
@@ -620,6 +405,8 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason,
620 } 405 }
621#endif 406#endif
622 407
408#endif
409
623#if defined(_WIN32) && !defined(__CYGWIN__) 410#if defined(_WIN32) && !defined(__CYGWIN__)
624#include <tchar.h> 411#include <tchar.h>
625 412
diff --git a/src/lib/libcrypto/crypto-lib.com b/src/lib/libcrypto/crypto-lib.com
index 8898f30c1f..db9c882fb0 100644
--- a/src/lib/libcrypto/crypto-lib.com
+++ b/src/lib/libcrypto/crypto-lib.com
@@ -83,7 +83,7 @@ $ ENCRYPT_TYPES = "Basic,"+ -
83 "BUFFER,BIO,STACK,LHASH,RAND,ERR,"+ - 83 "BUFFER,BIO,STACK,LHASH,RAND,ERR,"+ -
84 "EVP,EVP_2,ASN1,ASN1_2,PEM,X509,X509V3,"+ - 84 "EVP,EVP_2,ASN1,ASN1_2,PEM,X509,X509V3,"+ -
85 "CONF,TXT_DB,PKCS7,PKCS12,COMP,OCSP,UI,KRB5,"+ - 85 "CONF,TXT_DB,PKCS7,PKCS12,COMP,OCSP,UI,KRB5,"+ -
86 "STORE,CMS,PQUEUE" 86 "STORE,CMS,PQUEUE,JPAKE"
87$! 87$!
88$! Check To Make Sure We Have Valid Command Line Parameters. 88$! Check To Make Sure We Have Valid Command Line Parameters.
89$! 89$!
@@ -161,7 +161,7 @@ $!
161$ APPS_DES = "DES/DES,CBC3_ENC" 161$ APPS_DES = "DES/DES,CBC3_ENC"
162$ APPS_PKCS7 = "ENC/ENC;DEC/DEC;SIGN/SIGN;VERIFY/VERIFY,EXAMPLE" 162$ APPS_PKCS7 = "ENC/ENC;DEC/DEC;SIGN/SIGN;VERIFY/VERIFY,EXAMPLE"
163$ 163$
164$ LIB_ = "cryptlib,mem,mem_clr,mem_dbg,cversion,ex_data,tmdiff,cpt_err,ebcdic,uid,o_time,o_str,o_dir" 164$ LIB_ = "cryptlib,dyn_lck,mem,mem_clr,mem_dbg,cversion,ex_data,tmdiff,cpt_err,ebcdic,uid,o_time,o_str,o_dir,o_init,fips_err"
165$ LIB_MD2 = "md2_dgst,md2_one" 165$ LIB_MD2 = "md2_dgst,md2_one"
166$ LIB_MD4 = "md4_dgst,md4_one" 166$ LIB_MD4 = "md4_dgst,md4_one"
167$ LIB_MD5 = "md5_dgst,md5_one" 167$ LIB_MD5 = "md5_dgst,md5_one"
@@ -197,9 +197,9 @@ $ LIB_EC = "ec_lib,ecp_smpl,ecp_mont,ecp_nist,ec_cvt,ec_mult,"+ -
197 "ec2_smpl,ec2_mult" 197 "ec2_smpl,ec2_mult"
198$ LIB_RSA = "rsa_eay,rsa_gen,rsa_lib,rsa_sign,rsa_saos,rsa_err,"+ - 198$ LIB_RSA = "rsa_eay,rsa_gen,rsa_lib,rsa_sign,rsa_saos,rsa_err,"+ -
199 "rsa_pk1,rsa_ssl,rsa_none,rsa_oaep,rsa_chk,rsa_null,"+ - 199 "rsa_pk1,rsa_ssl,rsa_none,rsa_oaep,rsa_chk,rsa_null,"+ -
200 "rsa_pss,rsa_x931,rsa_asn1,rsa_depr" 200 "rsa_pss,rsa_x931,rsa_x931g,rsa_asn1,rsa_depr,rsa_eng"
201$ LIB_DSA = "dsa_gen,dsa_key,dsa_lib,dsa_asn1,dsa_vrf,dsa_sign,"+ - 201$ LIB_DSA = "dsa_gen,dsa_key,dsa_lib,dsa_asn1,dsa_vrf,dsa_sign,"+ -
202 "dsa_err,dsa_ossl,dsa_depr" 202 "dsa_err,dsa_ossl,dsa_depr,dsa_utl"
203$ LIB_ECDSA = "ecs_lib,ecs_asn1,ecs_ossl,ecs_sign,ecs_vrf,ecs_err" 203$ LIB_ECDSA = "ecs_lib,ecs_asn1,ecs_ossl,ecs_sign,ecs_vrf,ecs_err"
204$ LIB_DH = "dh_asn1,dh_gen,dh_key,dh_lib,dh_check,dh_err,dh_depr" 204$ LIB_DH = "dh_asn1,dh_gen,dh_key,dh_lib,dh_check,dh_err,dh_depr"
205$ LIB_ECDH = "ech_lib,ech_ossl,ech_key,ech_err" 205$ LIB_ECDH = "ech_lib,ech_ossl,ech_key,ech_err"
@@ -211,8 +211,8 @@ $ LIB_ENGINE = "eng_err,eng_lib,eng_list,eng_init,eng_ctrl,"+ -
211 "tb_cipher,tb_digest,"+ - 211 "tb_cipher,tb_digest,"+ -
212 "eng_openssl,eng_dyn,eng_cnf,eng_cryptodev,eng_padlock" 212 "eng_openssl,eng_dyn,eng_cnf,eng_cryptodev,eng_padlock"
213$ LIB_AES = "aes_core,aes_misc,aes_ecb,aes_cbc,aes_cfb,aes_ofb,"+ - 213$ LIB_AES = "aes_core,aes_misc,aes_ecb,aes_cbc,aes_cfb,aes_ofb,"+ -
214 "aes_ctr,aes_ige,aes_wrap" 214 "aes_ctr,aes_ige"
215$ LIB_BUFFER = "buffer,buf_err" 215$ LIB_BUFFER = "buffer,buf_str,buf_err"
216$ LIB_BIO = "bio_lib,bio_cb,bio_err,"+ - 216$ LIB_BIO = "bio_lib,bio_cb,bio_err,"+ -
217 "bss_mem,bss_null,bss_fd,"+ - 217 "bss_mem,bss_null,bss_fd,"+ -
218 "bss_file,bss_sock,bss_conn,"+ - 218 "bss_file,bss_sock,bss_conn,"+ -
@@ -224,18 +224,19 @@ $ LIB_STACK = "stack"
224$ LIB_LHASH = "lhash,lh_stats" 224$ LIB_LHASH = "lhash,lh_stats"
225$ LIB_RAND = "md_rand,randfile,rand_lib,rand_err,rand_egd,"+ - 225$ LIB_RAND = "md_rand,randfile,rand_lib,rand_err,rand_egd,"+ -
226 "rand_vms" 226 "rand_vms"
227$ LIB_ERR = "err,err_all,err_prn" 227$ LIB_ERR = "err,err_def,err_all,err_prn,err_str,err_bio"
228$ LIB_OBJECTS = "o_names,obj_dat,obj_lib,obj_err" 228$ LIB_OBJECTS = "o_names,obj_dat,obj_lib,obj_err"
229$ LIB_EVP = "encode,digest,evp_enc,evp_key,evp_acnf,"+ - 229$ LIB_EVP = "encode,digest,dig_eng,evp_enc,evp_key,evp_acnf,evp_cnf,"+ -
230 "e_des,e_bf,e_idea,e_des3,e_camellia,e_seed,"+ - 230 "e_des,e_bf,e_idea,e_des3,e_camellia,"+ -
231 "e_rc4,e_aes,names,"+ - 231 "e_rc4,e_aes,names,e_seed,"+ -
232 "e_xcbc_d,e_rc2,e_cast,e_rc5" 232 "e_xcbc_d,e_rc2,e_cast,e_rc5,enc_min"
233$ LIB_EVP_2 = "m_null,m_md2,m_md4,m_md5,m_sha,m_sha1," + - 233$ LIB_EVP_2 = "m_null,m_md2,m_md4,m_md5,m_sha,m_sha1," + -
234 "m_dss,m_dss1,m_mdc2,m_ripemd,m_ecdsa,"+ - 234 "m_dss,m_dss1,m_mdc2,m_ripemd,m_ecdsa,"+ -
235 "p_open,p_seal,p_sign,p_verify,p_lib,p_enc,p_dec,"+ - 235 "p_open,p_seal,p_sign,p_verify,p_lib,p_enc,p_dec,"+ -
236 "bio_md,bio_b64,bio_enc,evp_err,e_null,"+ - 236 "bio_md,bio_b64,bio_enc,evp_err,e_null,"+ -
237 "c_all,c_allc,c_alld,evp_lib,bio_ok,"+- 237 "c_all,c_allc,c_alld,evp_lib,bio_ok,"+-
238 "evp_pkey,evp_pbe,p5_crpt,p5_crpt2" 238 "evp_pkey,evp_pbe,p5_crpt,p5_crpt2"
239$ LIB_EVP_3 = "e_old"
239$ LIB_ASN1 = "a_object,a_bitstr,a_utctm,a_gentm,a_time,a_int,a_octet,"+ - 240$ LIB_ASN1 = "a_object,a_bitstr,a_utctm,a_gentm,a_time,a_int,a_octet,"+ -
240 "a_print,a_type,a_set,a_dup,a_d2i_fp,a_i2d_fp,"+ - 241 "a_print,a_type,a_set,a_dup,a_d2i_fp,a_i2d_fp,"+ -
241 "a_enum,a_utf8,a_sign,a_digest,a_verify,a_mbstr,a_strex,"+ - 242 "a_enum,a_utf8,a_sign,a_digest,a_verify,a_mbstr,a_strex,"+ -
@@ -245,7 +246,7 @@ $ LIB_ASN1 = "a_object,a_bitstr,a_utctm,a_gentm,a_time,a_int,a_octet,"+ -
245$ LIB_ASN1_2 = "t_req,t_x509,t_x509a,t_crl,t_pkey,t_spki,t_bitst,"+ - 246$ LIB_ASN1_2 = "t_req,t_x509,t_x509a,t_crl,t_pkey,t_spki,t_bitst,"+ -
246 "tasn_new,tasn_fre,tasn_enc,tasn_dec,tasn_utl,tasn_typ,"+ - 247 "tasn_new,tasn_fre,tasn_enc,tasn_dec,tasn_utl,tasn_typ,"+ -
247 "f_int,f_string,n_pkey,"+ - 248 "f_int,f_string,n_pkey,"+ -
248 "f_enum,a_hdr,x_pkey,a_bool,x_exten,asn_mime,"+ - 249 "f_enum,a_hdr,x_pkey,a_bool,x_exten,"+ -
249 "asn1_gen,asn1_par,asn1_lib,asn1_err,a_meth,a_bytes,a_strnid,"+ - 250 "asn1_gen,asn1_par,asn1_lib,asn1_err,a_meth,a_bytes,a_strnid,"+ -
250 "evp_asn1,asn_pack,p5_pbe,p5_pbev2,p8_pkey,asn_moid" 251 "evp_asn1,asn_pack,p5_pbe,p5_pbev2,p8_pkey,asn_moid"
251$ LIB_PEM = "pem_sign,pem_seal,pem_info,pem_lib,pem_all,pem_err,"+ - 252$ LIB_PEM = "pem_sign,pem_seal,pem_info,pem_lib,pem_all,pem_err,"+ -
@@ -280,6 +281,7 @@ $ LIB_STORE = "str_err,str_lib,str_meth,str_mem"
280$ LIB_CMS = "cms_lib,cms_asn1,cms_att,cms_io,cms_smime,cms_err,"+ - 281$ LIB_CMS = "cms_lib,cms_asn1,cms_att,cms_io,cms_smime,cms_err,"+ -
281 "cms_sd,cms_dd,cms_cd,cms_env,cms_enc,cms_ess" 282 "cms_sd,cms_dd,cms_cd,cms_env,cms_enc,cms_ess"
282$ LIB_PQUEUE = "pqueue" 283$ LIB_PQUEUE = "pqueue"
284$ LIB_JPAKE = "jpake,jpake_err"
283$! 285$!
284$! Setup exceptional compilations 286$! Setup exceptional compilations
285$! 287$!
diff --git a/src/lib/libcrypto/crypto.h b/src/lib/libcrypto/crypto.h
index fe2c1d6403..0e4fb0723c 100644
--- a/src/lib/libcrypto/crypto.h
+++ b/src/lib/libcrypto/crypto.h
@@ -219,7 +219,13 @@ typedef struct openssl_item_st
219#define CRYPTO_LOCK_EC_PRE_COMP 36 219#define CRYPTO_LOCK_EC_PRE_COMP 36
220#define CRYPTO_LOCK_STORE 37 220#define CRYPTO_LOCK_STORE 37
221#define CRYPTO_LOCK_COMP 38 221#define CRYPTO_LOCK_COMP 38
222#ifndef OPENSSL_FIPS
222#define CRYPTO_NUM_LOCKS 39 223#define CRYPTO_NUM_LOCKS 39
224#else
225#define CRYPTO_LOCK_FIPS 39
226#define CRYPTO_LOCK_FIPS2 40
227#define CRYPTO_NUM_LOCKS 41
228#endif
223 229
224#define CRYPTO_LOCK 1 230#define CRYPTO_LOCK 1
225#define CRYPTO_UNLOCK 2 231#define CRYPTO_UNLOCK 2
@@ -341,14 +347,7 @@ DECLARE_STACK_OF(CRYPTO_EX_DATA_FUNCS)
341 347
342/* Set standard debugging functions (not done by default 348/* Set standard debugging functions (not done by default
343 * unless CRYPTO_MDEBUG is defined) */ 349 * unless CRYPTO_MDEBUG is defined) */
344#define CRYPTO_malloc_debug_init() do {\ 350void CRYPTO_malloc_debug_init(void);
345 CRYPTO_set_mem_debug_functions(\
346 CRYPTO_dbg_malloc,\
347 CRYPTO_dbg_realloc,\
348 CRYPTO_dbg_free,\
349 CRYPTO_dbg_set_options,\
350 CRYPTO_dbg_get_options);\
351 } while(0)
352 351
353int CRYPTO_mem_ctrl(int mode); 352int CRYPTO_mem_ctrl(int mode);
354int CRYPTO_is_mem_check_on(void); 353int CRYPTO_is_mem_check_on(void);
@@ -363,6 +362,7 @@ int CRYPTO_is_mem_check_on(void);
363#define is_MemCheck_on() CRYPTO_is_mem_check_on() 362#define is_MemCheck_on() CRYPTO_is_mem_check_on()
364 363
365#define OPENSSL_malloc(num) CRYPTO_malloc((int)num,__FILE__,__LINE__) 364#define OPENSSL_malloc(num) CRYPTO_malloc((int)num,__FILE__,__LINE__)
365#define OPENSSL_strdup(str) CRYPTO_strdup((str),__FILE__,__LINE__)
366#define OPENSSL_realloc(addr,num) \ 366#define OPENSSL_realloc(addr,num) \
367 CRYPTO_realloc((char *)addr,(int)num,__FILE__,__LINE__) 367 CRYPTO_realloc((char *)addr,(int)num,__FILE__,__LINE__)
368#define OPENSSL_realloc_clean(addr,old_num,num) \ 368#define OPENSSL_realloc_clean(addr,old_num,num) \
@@ -427,6 +427,9 @@ const char *CRYPTO_get_lock_name(int type);
427int CRYPTO_add_lock(int *pointer,int amount,int type, const char *file, 427int CRYPTO_add_lock(int *pointer,int amount,int type, const char *file,
428 int line); 428 int line);
429 429
430void int_CRYPTO_set_do_dynlock_callback(
431 void (*do_dynlock_cb)(int mode, int type, const char *file, int line));
432
430int CRYPTO_get_new_dynlockid(void); 433int CRYPTO_get_new_dynlockid(void);
431void CRYPTO_destroy_dynlockid(int i); 434void CRYPTO_destroy_dynlockid(int i);
432struct CRYPTO_dynlock_value *CRYPTO_get_dynlock_value(int i); 435struct CRYPTO_dynlock_value *CRYPTO_get_dynlock_value(int i);
@@ -451,6 +454,10 @@ int CRYPTO_set_mem_debug_functions(void (*m)(void *,int,const char *,int,int),
451 void (*f)(void *,int), 454 void (*f)(void *,int),
452 void (*so)(long), 455 void (*so)(long),
453 long (*go)(void)); 456 long (*go)(void));
457void CRYPTO_set_mem_info_functions(
458 int (*push_info_fn)(const char *info, const char *file, int line),
459 int (*pop_info_fn)(void),
460 int (*remove_all_info_fn)(void));
454void CRYPTO_get_mem_functions(void *(**m)(size_t),void *(**r)(void *, size_t), void (**f)(void *)); 461void CRYPTO_get_mem_functions(void *(**m)(size_t),void *(**r)(void *, size_t), void (**f)(void *));
455void CRYPTO_get_locked_mem_functions(void *(**m)(size_t), void (**f)(void *)); 462void CRYPTO_get_locked_mem_functions(void *(**m)(size_t), void (**f)(void *));
456void CRYPTO_get_mem_ex_functions(void *(**m)(size_t,const char *,int), 463void CRYPTO_get_mem_ex_functions(void *(**m)(size_t,const char *,int),
@@ -467,6 +474,7 @@ void CRYPTO_get_mem_debug_functions(void (**m)(void *,int,const char *,int,int),
467void *CRYPTO_malloc_locked(int num, const char *file, int line); 474void *CRYPTO_malloc_locked(int num, const char *file, int line);
468void CRYPTO_free_locked(void *); 475void CRYPTO_free_locked(void *);
469void *CRYPTO_malloc(int num, const char *file, int line); 476void *CRYPTO_malloc(int num, const char *file, int line);
477char *CRYPTO_strdup(const char *str, const char *file, int line);
470void CRYPTO_free(void *); 478void CRYPTO_free(void *);
471void *CRYPTO_realloc(void *addr,int num, const char *file, int line); 479void *CRYPTO_realloc(void *addr,int num, const char *file, int line);
472void *CRYPTO_realloc_clean(void *addr,int old_num,int num,const char *file, 480void *CRYPTO_realloc_clean(void *addr,int old_num,int num,const char *file,
@@ -506,6 +514,9 @@ void CRYPTO_dbg_free(void *addr,int before_p);
506void CRYPTO_dbg_set_options(long bits); 514void CRYPTO_dbg_set_options(long bits);
507long CRYPTO_dbg_get_options(void); 515long CRYPTO_dbg_get_options(void);
508 516
517int CRYPTO_dbg_push_info(const char *info, const char *file, int line);
518int CRYPTO_dbg_pop_info(void);
519int CRYPTO_dbg_remove_all_info(void);
509 520
510#ifndef OPENSSL_NO_FP_API 521#ifndef OPENSSL_NO_FP_API
511void CRYPTO_mem_leaks_fp(FILE *); 522void CRYPTO_mem_leaks_fp(FILE *);
@@ -523,12 +534,69 @@ unsigned long *OPENSSL_ia32cap_loc(void);
523#define OPENSSL_ia32cap (*(OPENSSL_ia32cap_loc())) 534#define OPENSSL_ia32cap (*(OPENSSL_ia32cap_loc()))
524int OPENSSL_isservice(void); 535int OPENSSL_isservice(void);
525 536
537#ifdef OPENSSL_FIPS
538#define FIPS_ERROR_IGNORED(alg) OpenSSLDie(__FILE__, __LINE__, \
539 alg " previous FIPS forbidden algorithm error ignored");
540
541#define FIPS_BAD_ABORT(alg) OpenSSLDie(__FILE__, __LINE__, \
542 #alg " Algorithm forbidden in FIPS mode");
543
544#ifdef OPENSSL_FIPS_STRICT
545#define FIPS_BAD_ALGORITHM(alg) FIPS_BAD_ABORT(alg)
546#else
547#define FIPS_BAD_ALGORITHM(alg) \
548 { \
549 FIPSerr(FIPS_F_HASH_FINAL,FIPS_R_NON_FIPS_METHOD); \
550 ERR_add_error_data(2, "Algorithm=", #alg); \
551 return 0; \
552 }
553#endif
554
555/* Low level digest API blocking macro */
556
557#define FIPS_NON_FIPS_MD_Init(alg) \
558 int alg##_Init(alg##_CTX *c) \
559 { \
560 if (FIPS_mode()) \
561 FIPS_BAD_ALGORITHM(alg) \
562 return private_##alg##_Init(c); \
563 } \
564 int private_##alg##_Init(alg##_CTX *c)
565
566/* For ciphers the API often varies from cipher to cipher and each needs to
567 * be treated as a special case. Variable key length ciphers (Blowfish, RC4,
568 * CAST) however are very similar and can use a blocking macro.
569 */
570
571#define FIPS_NON_FIPS_VCIPHER_Init(alg) \
572 void alg##_set_key(alg##_KEY *key, int len, const unsigned char *data) \
573 { \
574 if (FIPS_mode()) \
575 FIPS_BAD_ABORT(alg) \
576 private_##alg##_set_key(key, len, data); \
577 } \
578 void private_##alg##_set_key(alg##_KEY *key, int len, \
579 const unsigned char *data)
580
581#else
582
583#define FIPS_NON_FIPS_VCIPHER_Init(alg) \
584 void alg##_set_key(alg##_KEY *key, int len, const unsigned char *data)
585
586#define FIPS_NON_FIPS_MD_Init(alg) \
587 int alg##_Init(alg##_CTX *c)
588
589#endif /* def OPENSSL_FIPS */
590
526/* BEGIN ERROR CODES */ 591/* BEGIN ERROR CODES */
527/* The following lines are auto generated by the script mkerr.pl. Any changes 592/* The following lines are auto generated by the script mkerr.pl. Any changes
528 * made after this point may be overwritten when the script is next run. 593 * made after this point may be overwritten when the script is next run.
529 */ 594 */
530void ERR_load_CRYPTO_strings(void); 595void ERR_load_CRYPTO_strings(void);
531 596
597#define OPENSSL_HAVE_INIT 1
598void OPENSSL_init(void);
599
532/* Error codes for the CRYPTO functions. */ 600/* Error codes for the CRYPTO functions. */
533 601
534/* Function codes. */ 602/* Function codes. */
diff --git a/src/lib/libcrypto/des/des_enc.c b/src/lib/libcrypto/des/des_enc.c
index 0fe4e0b2ad..22701e0669 100644
--- a/src/lib/libcrypto/des/des_enc.c
+++ b/src/lib/libcrypto/des/des_enc.c
@@ -293,6 +293,8 @@ void DES_decrypt3(DES_LONG *data, DES_key_schedule *ks1,
293 293
294#ifndef DES_DEFAULT_OPTIONS 294#ifndef DES_DEFAULT_OPTIONS
295 295
296#if !defined(OPENSSL_FIPS_DES_ASM)
297
296#undef CBC_ENC_C__DONT_UPDATE_IV 298#undef CBC_ENC_C__DONT_UPDATE_IV
297#include "ncbc_enc.c" /* DES_ncbc_encrypt */ 299#include "ncbc_enc.c" /* DES_ncbc_encrypt */
298 300
@@ -408,4 +410,6 @@ void DES_ede3_cbc_encrypt(const unsigned char *input, unsigned char *output,
408 tin[0]=tin[1]=0; 410 tin[0]=tin[1]=0;
409 } 411 }
410 412
413#endif
414
411#endif /* DES_DEFAULT_OPTIONS */ 415#endif /* DES_DEFAULT_OPTIONS */
diff --git a/src/lib/libcrypto/des/ecb_enc.c b/src/lib/libcrypto/des/ecb_enc.c
index 00d5b91e8c..75ae6cf8bb 100644
--- a/src/lib/libcrypto/des/ecb_enc.c
+++ b/src/lib/libcrypto/des/ecb_enc.c
@@ -57,54 +57,7 @@
57 */ 57 */
58 58
59#include "des_locl.h" 59#include "des_locl.h"
60#include "des_ver.h"
61#include "spr.h" 60#include "spr.h"
62#include <openssl/opensslv.h>
63#include <openssl/bio.h>
64
65OPENSSL_GLOBAL const char libdes_version[]="libdes" OPENSSL_VERSION_PTEXT;
66OPENSSL_GLOBAL const char DES_version[]="DES" OPENSSL_VERSION_PTEXT;
67
68const char *DES_options(void)
69 {
70 static int init=1;
71 static char buf[32];
72
73 if (init)
74 {
75 const char *ptr,*unroll,*risc,*size;
76
77#ifdef DES_PTR
78 ptr="ptr";
79#else
80 ptr="idx";
81#endif
82#if defined(DES_RISC1) || defined(DES_RISC2)
83#ifdef DES_RISC1
84 risc="risc1";
85#endif
86#ifdef DES_RISC2
87 risc="risc2";
88#endif
89#else
90 risc="cisc";
91#endif
92#ifdef DES_UNROLL
93 unroll="16";
94#else
95 unroll="4";
96#endif
97 if (sizeof(DES_LONG) != sizeof(long))
98 size="int";
99 else
100 size="long";
101 BIO_snprintf(buf,sizeof buf,"des(%s,%s,%s,%s)",ptr,risc,unroll,
102 size);
103 init=0;
104 }
105 return(buf);
106 }
107
108 61
109void DES_ecb_encrypt(const_DES_cblock *input, DES_cblock *output, 62void DES_ecb_encrypt(const_DES_cblock *input, DES_cblock *output,
110 DES_key_schedule *ks, int enc) 63 DES_key_schedule *ks, int enc)
diff --git a/src/lib/libcrypto/des/enc_read.c b/src/lib/libcrypto/des/enc_read.c
index c70fb686b8..e7da2ec66b 100644
--- a/src/lib/libcrypto/des/enc_read.c
+++ b/src/lib/libcrypto/des/enc_read.c
@@ -147,7 +147,11 @@ int DES_enc_read(int fd, void *buf, int len, DES_key_schedule *sched,
147 /* first - get the length */ 147 /* first - get the length */
148 while (net_num < HDRSIZE) 148 while (net_num < HDRSIZE)
149 { 149 {
150#ifndef _WIN32
150 i=read(fd,(void *)&(net[net_num]),HDRSIZE-net_num); 151 i=read(fd,(void *)&(net[net_num]),HDRSIZE-net_num);
152#else
153 i=_read(fd,(void *)&(net[net_num]),HDRSIZE-net_num);
154#endif
151#ifdef EINTR 155#ifdef EINTR
152 if ((i == -1) && (errno == EINTR)) continue; 156 if ((i == -1) && (errno == EINTR)) continue;
153#endif 157#endif
diff --git a/src/lib/libcrypto/des/enc_writ.c b/src/lib/libcrypto/des/enc_writ.c
index af5b8c2349..c2f032c9a6 100644
--- a/src/lib/libcrypto/des/enc_writ.c
+++ b/src/lib/libcrypto/des/enc_writ.c
@@ -153,7 +153,11 @@ int DES_enc_write(int fd, const void *_buf, int len,
153 { 153 {
154 /* eay 26/08/92 I was not doing writing from where we 154 /* eay 26/08/92 I was not doing writing from where we
155 * got up to. */ 155 * got up to. */
156#ifndef _WIN32
156 i=write(fd,(void *)&(outbuf[j]),outnum-j); 157 i=write(fd,(void *)&(outbuf[j]),outnum-j);
158#else
159 i=_write(fd,(void *)&(outbuf[j]),outnum-j);
160#endif
157 if (i == -1) 161 if (i == -1)
158 { 162 {
159#ifdef EINTR 163#ifdef EINTR
diff --git a/src/lib/libcrypto/des/set_key.c b/src/lib/libcrypto/des/set_key.c
index a43ef3c881..c0806d593c 100644
--- a/src/lib/libcrypto/des/set_key.c
+++ b/src/lib/libcrypto/des/set_key.c
@@ -64,6 +64,10 @@
64 * 1.0 First working version 64 * 1.0 First working version
65 */ 65 */
66#include "des_locl.h" 66#include "des_locl.h"
67#ifdef OPENSSL_FIPS
68#include <openssl/fips.h>
69#endif
70
67 71
68OPENSSL_IMPLEMENT_GLOBAL(int,DES_check_key); /* defaults to false */ 72OPENSSL_IMPLEMENT_GLOBAL(int,DES_check_key); /* defaults to false */
69 73
@@ -349,6 +353,10 @@ void DES_set_key_unchecked(const_DES_cblock *key, DES_key_schedule *schedule)
349 k = &schedule->ks->deslong[0]; 353 k = &schedule->ks->deslong[0];
350 in = &(*key)[0]; 354 in = &(*key)[0];
351 355
356#ifdef OPENSSL_FIPS
357 FIPS_selftest_check();
358#endif
359
352 c2l(in,c); 360 c2l(in,c);
353 c2l(in,d); 361 c2l(in,d);
354 362
@@ -405,3 +413,4 @@ void des_fixup_key_parity(des_cblock *key)
405 des_set_odd_parity(key); 413 des_set_odd_parity(key);
406 } 414 }
407*/ 415*/
416
diff --git a/src/lib/libcrypto/dh/Makefile b/src/lib/libcrypto/dh/Makefile
index 950cad9c5b..d01fa960eb 100644
--- a/src/lib/libcrypto/dh/Makefile
+++ b/src/lib/libcrypto/dh/Makefile
@@ -33,7 +33,7 @@ top:
33all: lib 33all: lib
34 34
35lib: $(LIBOBJ) 35lib: $(LIBOBJ)
36 $(AR) $(LIB) $(LIBOBJ) 36 $(ARX) $(LIB) $(LIBOBJ)
37 $(RANLIB) $(LIB) || echo Never mind. 37 $(RANLIB) $(LIB) || echo Never mind.
38 @touch lib 38 @touch lib
39 39
@@ -129,11 +129,11 @@ dh_lib.o: ../../include/openssl/crypto.h ../../include/openssl/dh.h
129dh_lib.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h 129dh_lib.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h
130dh_lib.o: ../../include/openssl/ecdh.h ../../include/openssl/ecdsa.h 130dh_lib.o: ../../include/openssl/ecdh.h ../../include/openssl/ecdsa.h
131dh_lib.o: ../../include/openssl/engine.h ../../include/openssl/err.h 131dh_lib.o: ../../include/openssl/engine.h ../../include/openssl/err.h
132dh_lib.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h 132dh_lib.o: ../../include/openssl/evp.h ../../include/openssl/fips.h
133dh_lib.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h 133dh_lib.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
134dh_lib.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h 134dh_lib.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
135dh_lib.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h 135dh_lib.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
136dh_lib.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h 136dh_lib.o: ../../include/openssl/pkcs7.h ../../include/openssl/safestack.h
137dh_lib.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 137dh_lib.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
138dh_lib.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h 138dh_lib.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h
139dh_lib.o: ../cryptlib.h dh_lib.c 139dh_lib.o: ../../include/openssl/x509_vfy.h ../cryptlib.h dh_lib.c
diff --git a/src/lib/libcrypto/dh/dh.h b/src/lib/libcrypto/dh/dh.h
index 0afabc7dd3..0a39742773 100644
--- a/src/lib/libcrypto/dh/dh.h
+++ b/src/lib/libcrypto/dh/dh.h
@@ -77,6 +77,8 @@
77# define OPENSSL_DH_MAX_MODULUS_BITS 10000 77# define OPENSSL_DH_MAX_MODULUS_BITS 10000
78#endif 78#endif
79 79
80#define OPENSSL_DH_FIPS_MIN_MODULUS_BITS 1024
81
80#define DH_FLAG_CACHE_MONT_P 0x01 82#define DH_FLAG_CACHE_MONT_P 0x01
81#define DH_FLAG_NO_EXP_CONSTTIME 0x02 /* new with 0.9.7h; the built-in DH 83#define DH_FLAG_NO_EXP_CONSTTIME 0x02 /* new with 0.9.7h; the built-in DH
82 * implementation now uses constant time 84 * implementation now uses constant time
@@ -167,6 +169,11 @@ struct dh_st
167 169
168const DH_METHOD *DH_OpenSSL(void); 170const DH_METHOD *DH_OpenSSL(void);
169 171
172#ifdef OPENSSL_FIPS
173DH * FIPS_dh_new(void);
174void FIPS_dh_free(DH *dh);
175#endif
176
170void DH_set_default_method(const DH_METHOD *meth); 177void DH_set_default_method(const DH_METHOD *meth);
171const DH_METHOD *DH_get_default_method(void); 178const DH_METHOD *DH_get_default_method(void);
172int DH_set_method(DH *dh, const DH_METHOD *meth); 179int DH_set_method(DH *dh, const DH_METHOD *meth);
@@ -218,6 +225,9 @@ void ERR_load_DH_strings(void);
218#define DH_F_DHPARAMS_PRINT 100 225#define DH_F_DHPARAMS_PRINT 100
219#define DH_F_DHPARAMS_PRINT_FP 101 226#define DH_F_DHPARAMS_PRINT_FP 101
220#define DH_F_DH_BUILTIN_GENPARAMS 106 227#define DH_F_DH_BUILTIN_GENPARAMS 106
228#define DH_F_DH_COMPUTE_KEY 107
229#define DH_F_DH_GENERATE_KEY 108
230#define DH_F_DH_GENERATE_PARAMETERS 109
221#define DH_F_DH_NEW_METHOD 105 231#define DH_F_DH_NEW_METHOD 105
222#define DH_F_GENERATE_KEY 103 232#define DH_F_GENERATE_KEY 103
223#define DH_F_GENERATE_PARAMETERS 104 233#define DH_F_GENERATE_PARAMETERS 104
@@ -225,6 +235,7 @@ void ERR_load_DH_strings(void);
225/* Reason codes. */ 235/* Reason codes. */
226#define DH_R_BAD_GENERATOR 101 236#define DH_R_BAD_GENERATOR 101
227#define DH_R_INVALID_PUBKEY 102 237#define DH_R_INVALID_PUBKEY 102
238#define DH_R_KEY_SIZE_TOO_SMALL 104
228#define DH_R_MODULUS_TOO_LARGE 103 239#define DH_R_MODULUS_TOO_LARGE 103
229#define DH_R_NO_PRIVATE_VALUE 100 240#define DH_R_NO_PRIVATE_VALUE 100
230#define DH_R_INVALID_PUBKEY 102 241#define DH_R_INVALID_PUBKEY 102
diff --git a/src/lib/libcrypto/dh/dh_asn1.c b/src/lib/libcrypto/dh/dh_asn1.c
index 769b5b68c5..76740af2bd 100644
--- a/src/lib/libcrypto/dh/dh_asn1.c
+++ b/src/lib/libcrypto/dh/dh_asn1.c
@@ -1,5 +1,5 @@
1/* dh_asn1.c */ 1/* dh_asn1.c */
2/* Written by Dr Stephen N Henson (shenson@bigfoot.com) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 2000. 3 * project 2000.
4 */ 4 */
5/* ==================================================================== 5/* ====================================================================
diff --git a/src/lib/libcrypto/dh/dh_check.c b/src/lib/libcrypto/dh/dh_check.c
index b846913004..316cb9221d 100644
--- a/src/lib/libcrypto/dh/dh_check.c
+++ b/src/lib/libcrypto/dh/dh_check.c
@@ -70,6 +70,8 @@
70 * should hold. 70 * should hold.
71 */ 71 */
72 72
73#ifndef OPENSSL_FIPS
74
73int DH_check(const DH *dh, int *ret) 75int DH_check(const DH *dh, int *ret)
74 { 76 {
75 int ok=0; 77 int ok=0;
@@ -140,3 +142,5 @@ err:
140 if (q != NULL) BN_free(q); 142 if (q != NULL) BN_free(q);
141 return(ok); 143 return(ok);
142 } 144 }
145
146#endif
diff --git a/src/lib/libcrypto/dh/dh_err.c b/src/lib/libcrypto/dh/dh_err.c
index b2361c7389..b364362fca 100644
--- a/src/lib/libcrypto/dh/dh_err.c
+++ b/src/lib/libcrypto/dh/dh_err.c
@@ -1,6 +1,6 @@
1/* crypto/dh/dh_err.c */ 1/* crypto/dh/dh_err.c */
2/* ==================================================================== 2/* ====================================================================
3 * Copyright (c) 1999-2005 The OpenSSL Project. All rights reserved. 3 * Copyright (c) 1999-2007 The OpenSSL Project. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
@@ -74,6 +74,9 @@ static ERR_STRING_DATA DH_str_functs[]=
74{ERR_FUNC(DH_F_DHPARAMS_PRINT), "DHparams_print"}, 74{ERR_FUNC(DH_F_DHPARAMS_PRINT), "DHparams_print"},
75{ERR_FUNC(DH_F_DHPARAMS_PRINT_FP), "DHparams_print_fp"}, 75{ERR_FUNC(DH_F_DHPARAMS_PRINT_FP), "DHparams_print_fp"},
76{ERR_FUNC(DH_F_DH_BUILTIN_GENPARAMS), "DH_BUILTIN_GENPARAMS"}, 76{ERR_FUNC(DH_F_DH_BUILTIN_GENPARAMS), "DH_BUILTIN_GENPARAMS"},
77{ERR_FUNC(DH_F_DH_COMPUTE_KEY), "DH_compute_key"},
78{ERR_FUNC(DH_F_DH_GENERATE_KEY), "DH_generate_key"},
79{ERR_FUNC(DH_F_DH_GENERATE_PARAMETERS), "DH_generate_parameters"},
77{ERR_FUNC(DH_F_DH_NEW_METHOD), "DH_new_method"}, 80{ERR_FUNC(DH_F_DH_NEW_METHOD), "DH_new_method"},
78{ERR_FUNC(DH_F_GENERATE_KEY), "GENERATE_KEY"}, 81{ERR_FUNC(DH_F_GENERATE_KEY), "GENERATE_KEY"},
79{ERR_FUNC(DH_F_GENERATE_PARAMETERS), "GENERATE_PARAMETERS"}, 82{ERR_FUNC(DH_F_GENERATE_PARAMETERS), "GENERATE_PARAMETERS"},
@@ -84,6 +87,7 @@ static ERR_STRING_DATA DH_str_reasons[]=
84 { 87 {
85{ERR_REASON(DH_R_BAD_GENERATOR) ,"bad generator"}, 88{ERR_REASON(DH_R_BAD_GENERATOR) ,"bad generator"},
86{ERR_REASON(DH_R_INVALID_PUBKEY) ,"invalid public key"}, 89{ERR_REASON(DH_R_INVALID_PUBKEY) ,"invalid public key"},
90{ERR_REASON(DH_R_KEY_SIZE_TOO_SMALL) ,"key size too small"},
87{ERR_REASON(DH_R_MODULUS_TOO_LARGE) ,"modulus too large"}, 91{ERR_REASON(DH_R_MODULUS_TOO_LARGE) ,"modulus too large"},
88{ERR_REASON(DH_R_NO_PRIVATE_VALUE) ,"no private value"}, 92{ERR_REASON(DH_R_NO_PRIVATE_VALUE) ,"no private value"},
89{ERR_REASON(DH_R_INVALID_PUBKEY) ,"invalid public key"}, 93{ERR_REASON(DH_R_INVALID_PUBKEY) ,"invalid public key"},
diff --git a/src/lib/libcrypto/dh/dh_gen.c b/src/lib/libcrypto/dh/dh_gen.c
index cfd5b11868..999e1deb40 100644
--- a/src/lib/libcrypto/dh/dh_gen.c
+++ b/src/lib/libcrypto/dh/dh_gen.c
@@ -66,6 +66,8 @@
66#include <openssl/bn.h> 66#include <openssl/bn.h>
67#include <openssl/dh.h> 67#include <openssl/dh.h>
68 68
69#ifndef OPENSSL_FIPS
70
69static int dh_builtin_genparams(DH *ret, int prime_len, int generator, BN_GENCB *cb); 71static int dh_builtin_genparams(DH *ret, int prime_len, int generator, BN_GENCB *cb);
70 72
71int DH_generate_parameters_ex(DH *ret, int prime_len, int generator, BN_GENCB *cb) 73int DH_generate_parameters_ex(DH *ret, int prime_len, int generator, BN_GENCB *cb)
@@ -173,3 +175,5 @@ err:
173 } 175 }
174 return ok; 176 return ok;
175 } 177 }
178
179#endif
diff --git a/src/lib/libcrypto/dh/dh_key.c b/src/lib/libcrypto/dh/dh_key.c
index e7db440342..79dd331863 100644
--- a/src/lib/libcrypto/dh/dh_key.c
+++ b/src/lib/libcrypto/dh/dh_key.c
@@ -62,6 +62,8 @@
62#include <openssl/rand.h> 62#include <openssl/rand.h>
63#include <openssl/dh.h> 63#include <openssl/dh.h>
64 64
65#ifndef OPENSSL_FIPS
66
65static int generate_key(DH *dh); 67static int generate_key(DH *dh);
66static int compute_key(unsigned char *key, const BIGNUM *pub_key, DH *dh); 68static int compute_key(unsigned char *key, const BIGNUM *pub_key, DH *dh);
67static int dh_bn_mod_exp(const DH *dh, BIGNUM *r, 69static int dh_bn_mod_exp(const DH *dh, BIGNUM *r,
@@ -261,3 +263,5 @@ static int dh_finish(DH *dh)
261 BN_MONT_CTX_free(dh->method_mont_p); 263 BN_MONT_CTX_free(dh->method_mont_p);
262 return(1); 264 return(1);
263 } 265 }
266
267#endif
diff --git a/src/lib/libcrypto/dsa/Makefile b/src/lib/libcrypto/dsa/Makefile
index 5493f19e85..2cc45cdc62 100644
--- a/src/lib/libcrypto/dsa/Makefile
+++ b/src/lib/libcrypto/dsa/Makefile
@@ -18,9 +18,9 @@ APPS=
18 18
19LIB=$(TOP)/libcrypto.a 19LIB=$(TOP)/libcrypto.a
20LIBSRC= dsa_gen.c dsa_key.c dsa_lib.c dsa_asn1.c dsa_vrf.c dsa_sign.c \ 20LIBSRC= dsa_gen.c dsa_key.c dsa_lib.c dsa_asn1.c dsa_vrf.c dsa_sign.c \
21 dsa_err.c dsa_ossl.c dsa_depr.c 21 dsa_err.c dsa_ossl.c dsa_depr.c dsa_utl.c
22LIBOBJ= dsa_gen.o dsa_key.o dsa_lib.o dsa_asn1.o dsa_vrf.o dsa_sign.o \ 22LIBOBJ= dsa_gen.o dsa_key.o dsa_lib.o dsa_asn1.o dsa_vrf.o dsa_sign.o \
23 dsa_err.o dsa_ossl.o dsa_depr.o 23 dsa_err.o dsa_ossl.o dsa_depr.o dsa_utl.o
24 24
25SRC= $(LIBSRC) 25SRC= $(LIBSRC)
26 26
@@ -35,7 +35,7 @@ top:
35all: lib 35all: lib
36 36
37lib: $(LIBOBJ) 37lib: $(LIBOBJ)
38 $(AR) $(LIB) $(LIBOBJ) 38 $(ARX) $(LIB) $(LIBOBJ)
39 $(RANLIB) $(LIB) || echo Never mind. 39 $(RANLIB) $(LIB) || echo Never mind.
40 @touch lib 40 @touch lib
41 41
@@ -78,9 +78,10 @@ clean:
78 78
79dsa_asn1.o: ../../e_os.h ../../include/openssl/asn1.h 79dsa_asn1.o: ../../e_os.h ../../include/openssl/asn1.h
80dsa_asn1.o: ../../include/openssl/asn1t.h ../../include/openssl/bio.h 80dsa_asn1.o: ../../include/openssl/asn1t.h ../../include/openssl/bio.h
81dsa_asn1.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 81dsa_asn1.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
82dsa_asn1.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h 82dsa_asn1.o: ../../include/openssl/crypto.h ../../include/openssl/dsa.h
83dsa_asn1.o: ../../include/openssl/err.h ../../include/openssl/lhash.h 83dsa_asn1.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
84dsa_asn1.o: ../../include/openssl/fips.h ../../include/openssl/lhash.h
84dsa_asn1.o: ../../include/openssl/opensslconf.h 85dsa_asn1.o: ../../include/openssl/opensslconf.h
85dsa_asn1.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h 86dsa_asn1.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
86dsa_asn1.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h 87dsa_asn1.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
@@ -90,8 +91,9 @@ dsa_depr.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
90dsa_depr.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 91dsa_depr.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
91dsa_depr.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h 92dsa_depr.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
92dsa_depr.o: ../../include/openssl/err.h ../../include/openssl/evp.h 93dsa_depr.o: ../../include/openssl/err.h ../../include/openssl/evp.h
93dsa_depr.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h 94dsa_depr.o: ../../include/openssl/fips.h ../../include/openssl/lhash.h
94dsa_depr.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h 95dsa_depr.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
96dsa_depr.o: ../../include/openssl/opensslconf.h
95dsa_depr.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h 97dsa_depr.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
96dsa_depr.o: ../../include/openssl/rand.h ../../include/openssl/safestack.h 98dsa_depr.o: ../../include/openssl/rand.h ../../include/openssl/safestack.h
97dsa_depr.o: ../../include/openssl/sha.h ../../include/openssl/stack.h 99dsa_depr.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
@@ -108,12 +110,13 @@ dsa_gen.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
108dsa_gen.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 110dsa_gen.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
109dsa_gen.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h 111dsa_gen.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
110dsa_gen.o: ../../include/openssl/err.h ../../include/openssl/evp.h 112dsa_gen.o: ../../include/openssl/err.h ../../include/openssl/evp.h
111dsa_gen.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h 113dsa_gen.o: ../../include/openssl/fips.h ../../include/openssl/lhash.h
112dsa_gen.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h 114dsa_gen.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
113dsa_gen.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h 115dsa_gen.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
114dsa_gen.o: ../../include/openssl/rand.h ../../include/openssl/safestack.h 116dsa_gen.o: ../../include/openssl/ossl_typ.h ../../include/openssl/rand.h
115dsa_gen.o: ../../include/openssl/sha.h ../../include/openssl/stack.h 117dsa_gen.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
116dsa_gen.o: ../../include/openssl/symhacks.h ../cryptlib.h dsa_gen.c 118dsa_gen.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
119dsa_gen.o: ../cryptlib.h dsa_gen.c
117dsa_key.o: ../../e_os.h ../../include/openssl/bio.h ../../include/openssl/bn.h 120dsa_key.o: ../../e_os.h ../../include/openssl/bio.h ../../include/openssl/bn.h
118dsa_key.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 121dsa_key.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
119dsa_key.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h 122dsa_key.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
@@ -129,14 +132,14 @@ dsa_lib.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
129dsa_lib.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h 132dsa_lib.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h
130dsa_lib.o: ../../include/openssl/ecdh.h ../../include/openssl/ecdsa.h 133dsa_lib.o: ../../include/openssl/ecdh.h ../../include/openssl/ecdsa.h
131dsa_lib.o: ../../include/openssl/engine.h ../../include/openssl/err.h 134dsa_lib.o: ../../include/openssl/engine.h ../../include/openssl/err.h
132dsa_lib.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h 135dsa_lib.o: ../../include/openssl/evp.h ../../include/openssl/fips.h
133dsa_lib.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h 136dsa_lib.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
134dsa_lib.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h 137dsa_lib.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
135dsa_lib.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h 138dsa_lib.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
136dsa_lib.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h 139dsa_lib.o: ../../include/openssl/pkcs7.h ../../include/openssl/safestack.h
137dsa_lib.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 140dsa_lib.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
138dsa_lib.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h 141dsa_lib.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h
139dsa_lib.o: ../cryptlib.h dsa_lib.c 142dsa_lib.o: ../../include/openssl/x509_vfy.h ../cryptlib.h dsa_lib.c
140dsa_ossl.o: ../../e_os.h ../../include/openssl/asn1.h 143dsa_ossl.o: ../../e_os.h ../../include/openssl/asn1.h
141dsa_ossl.o: ../../include/openssl/bio.h ../../include/openssl/bn.h 144dsa_ossl.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
142dsa_ossl.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 145dsa_ossl.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
@@ -151,19 +154,34 @@ dsa_sign.o: ../../e_os.h ../../include/openssl/asn1.h
151dsa_sign.o: ../../include/openssl/bio.h ../../include/openssl/bn.h 154dsa_sign.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
152dsa_sign.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 155dsa_sign.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
153dsa_sign.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h 156dsa_sign.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
154dsa_sign.o: ../../include/openssl/err.h ../../include/openssl/lhash.h 157dsa_sign.o: ../../include/openssl/err.h ../../include/openssl/fips.h
155dsa_sign.o: ../../include/openssl/opensslconf.h 158dsa_sign.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
156dsa_sign.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h 159dsa_sign.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
157dsa_sign.o: ../../include/openssl/rand.h ../../include/openssl/safestack.h 160dsa_sign.o: ../../include/openssl/rand.h ../../include/openssl/safestack.h
158dsa_sign.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 161dsa_sign.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
159dsa_sign.o: ../cryptlib.h dsa_sign.c 162dsa_sign.o: ../cryptlib.h dsa_sign.c
163dsa_utl.o: ../../e_os.h ../../include/openssl/asn1.h
164dsa_utl.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
165dsa_utl.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
166dsa_utl.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
167dsa_utl.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h
168dsa_utl.o: ../../include/openssl/ecdh.h ../../include/openssl/ecdsa.h
169dsa_utl.o: ../../include/openssl/engine.h ../../include/openssl/err.h
170dsa_utl.o: ../../include/openssl/evp.h ../../include/openssl/fips.h
171dsa_utl.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
172dsa_utl.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
173dsa_utl.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
174dsa_utl.o: ../../include/openssl/pkcs7.h ../../include/openssl/safestack.h
175dsa_utl.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
176dsa_utl.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h
177dsa_utl.o: ../../include/openssl/x509_vfy.h ../cryptlib.h dsa_utl.c
160dsa_vrf.o: ../../e_os.h ../../include/openssl/asn1.h 178dsa_vrf.o: ../../e_os.h ../../include/openssl/asn1.h
161dsa_vrf.o: ../../include/openssl/asn1_mac.h ../../include/openssl/bio.h 179dsa_vrf.o: ../../include/openssl/asn1_mac.h ../../include/openssl/bio.h
162dsa_vrf.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h 180dsa_vrf.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
163dsa_vrf.o: ../../include/openssl/crypto.h ../../include/openssl/dsa.h 181dsa_vrf.o: ../../include/openssl/crypto.h ../../include/openssl/dsa.h
164dsa_vrf.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h 182dsa_vrf.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
165dsa_vrf.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h 183dsa_vrf.o: ../../include/openssl/fips.h ../../include/openssl/lhash.h
166dsa_vrf.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h 184dsa_vrf.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
167dsa_vrf.o: ../../include/openssl/rand.h ../../include/openssl/safestack.h 185dsa_vrf.o: ../../include/openssl/ossl_typ.h ../../include/openssl/rand.h
168dsa_vrf.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 186dsa_vrf.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
169dsa_vrf.o: ../cryptlib.h dsa_vrf.c 187dsa_vrf.o: ../../include/openssl/symhacks.h ../cryptlib.h dsa_vrf.c
diff --git a/src/lib/libcrypto/dsa/dsa.h b/src/lib/libcrypto/dsa/dsa.h
index 3a8fe5b56b..702c50d6dc 100644
--- a/src/lib/libcrypto/dsa/dsa.h
+++ b/src/lib/libcrypto/dsa/dsa.h
@@ -88,6 +88,8 @@
88# define OPENSSL_DSA_MAX_MODULUS_BITS 10000 88# define OPENSSL_DSA_MAX_MODULUS_BITS 10000
89#endif 89#endif
90 90
91#define OPENSSL_DSA_FIPS_MIN_MODULUS_BITS 1024
92
91#define DSA_FLAG_CACHE_MONT_P 0x01 93#define DSA_FLAG_CACHE_MONT_P 0x01
92#define DSA_FLAG_NO_EXP_CONSTTIME 0x02 /* new with 0.9.7h; the built-in DSA 94#define DSA_FLAG_NO_EXP_CONSTTIME 0x02 /* new with 0.9.7h; the built-in DSA
93 * implementation now uses constant time 95 * implementation now uses constant time
@@ -97,6 +99,25 @@
97 * be used for all exponents. 99 * be used for all exponents.
98 */ 100 */
99 101
102/* If this flag is set the DSA method is FIPS compliant and can be used
103 * in FIPS mode. This is set in the validated module method. If an
104 * application sets this flag in its own methods it is its reposibility
105 * to ensure the result is compliant.
106 */
107
108#define DSA_FLAG_FIPS_METHOD 0x0400
109
110/* If this flag is set the operations normally disabled in FIPS mode are
111 * permitted it is then the applications responsibility to ensure that the
112 * usage is compliant.
113 */
114
115#define DSA_FLAG_NON_FIPS_ALLOW 0x0400
116
117#ifdef OPENSSL_FIPS
118#define FIPS_DSA_SIZE_T int
119#endif
120
100#ifdef __cplusplus 121#ifdef __cplusplus
101extern "C" { 122extern "C" {
102#endif 123#endif
@@ -189,6 +210,11 @@ void DSA_set_default_method(const DSA_METHOD *);
189const DSA_METHOD *DSA_get_default_method(void); 210const DSA_METHOD *DSA_get_default_method(void);
190int DSA_set_method(DSA *dsa, const DSA_METHOD *); 211int DSA_set_method(DSA *dsa, const DSA_METHOD *);
191 212
213#ifdef OPENSSL_FIPS
214DSA * FIPS_dsa_new(void);
215void FIPS_dsa_free (DSA *r);
216#endif
217
192DSA * DSA_new(void); 218DSA * DSA_new(void);
193DSA * DSA_new_method(ENGINE *engine); 219DSA * DSA_new_method(ENGINE *engine);
194void DSA_free (DSA *r); 220void DSA_free (DSA *r);
@@ -249,6 +275,11 @@ int DSA_print_fp(FILE *bp, const DSA *x, int off);
249DH *DSA_dup_DH(const DSA *r); 275DH *DSA_dup_DH(const DSA *r);
250#endif 276#endif
251 277
278#ifdef OPENSSL_FIPS
279int FIPS_dsa_sig_encode(unsigned char *out, DSA_SIG *sig);
280int FIPS_dsa_sig_decode(DSA_SIG *sig, const unsigned char *in, int inlen);
281#endif
282
252/* BEGIN ERROR CODES */ 283/* BEGIN ERROR CODES */
253/* The following lines are auto generated by the script mkerr.pl. Any changes 284/* The following lines are auto generated by the script mkerr.pl. Any changes
254 * made after this point may be overwritten when the script is next run. 285 * made after this point may be overwritten when the script is next run.
@@ -261,11 +292,16 @@ void ERR_load_DSA_strings(void);
261#define DSA_F_D2I_DSA_SIG 110 292#define DSA_F_D2I_DSA_SIG 110
262#define DSA_F_DSAPARAMS_PRINT 100 293#define DSA_F_DSAPARAMS_PRINT 100
263#define DSA_F_DSAPARAMS_PRINT_FP 101 294#define DSA_F_DSAPARAMS_PRINT_FP 101
295#define DSA_F_DSA_BUILTIN_KEYGEN 119
296#define DSA_F_DSA_BUILTIN_PARAMGEN 118
264#define DSA_F_DSA_DO_SIGN 112 297#define DSA_F_DSA_DO_SIGN 112
265#define DSA_F_DSA_DO_VERIFY 113 298#define DSA_F_DSA_DO_VERIFY 113
299#define DSA_F_DSA_GENERATE_PARAMETERS 117
266#define DSA_F_DSA_NEW_METHOD 103 300#define DSA_F_DSA_NEW_METHOD 103
267#define DSA_F_DSA_PRINT 104 301#define DSA_F_DSA_PRINT 104
268#define DSA_F_DSA_PRINT_FP 105 302#define DSA_F_DSA_PRINT_FP 105
303#define DSA_F_DSA_SET_DEFAULT_METHOD 115
304#define DSA_F_DSA_SET_METHOD 116
269#define DSA_F_DSA_SIGN 106 305#define DSA_F_DSA_SIGN 106
270#define DSA_F_DSA_SIGN_SETUP 107 306#define DSA_F_DSA_SIGN_SETUP 107
271#define DSA_F_DSA_SIG_NEW 109 307#define DSA_F_DSA_SIG_NEW 109
@@ -276,8 +312,11 @@ void ERR_load_DSA_strings(void);
276/* Reason codes. */ 312/* Reason codes. */
277#define DSA_R_BAD_Q_VALUE 102 313#define DSA_R_BAD_Q_VALUE 102
278#define DSA_R_DATA_TOO_LARGE_FOR_KEY_SIZE 100 314#define DSA_R_DATA_TOO_LARGE_FOR_KEY_SIZE 100
315#define DSA_R_KEY_SIZE_TOO_SMALL 106
279#define DSA_R_MISSING_PARAMETERS 101 316#define DSA_R_MISSING_PARAMETERS 101
280#define DSA_R_MODULUS_TOO_LARGE 103 317#define DSA_R_MODULUS_TOO_LARGE 103
318#define DSA_R_NON_FIPS_METHOD 104
319#define DSA_R_OPERATION_NOT_ALLOWED_IN_FIPS_MODE 105
281 320
282#ifdef __cplusplus 321#ifdef __cplusplus
283} 322}
diff --git a/src/lib/libcrypto/dsa/dsa_asn1.c b/src/lib/libcrypto/dsa/dsa_asn1.c
index 23fce555aa..0645facb4b 100644
--- a/src/lib/libcrypto/dsa/dsa_asn1.c
+++ b/src/lib/libcrypto/dsa/dsa_asn1.c
@@ -1,5 +1,5 @@
1/* dsa_asn1.c */ 1/* dsa_asn1.c */
2/* Written by Dr Stephen N Henson (shenson@bigfoot.com) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 2000. 3 * project 2000.
4 */ 4 */
5/* ==================================================================== 5/* ====================================================================
@@ -61,6 +61,11 @@
61#include <openssl/dsa.h> 61#include <openssl/dsa.h>
62#include <openssl/asn1.h> 62#include <openssl/asn1.h>
63#include <openssl/asn1t.h> 63#include <openssl/asn1t.h>
64#include <openssl/bn.h>
65#ifdef OPENSSL_FIPS
66#include <openssl/fips.h>
67#endif
68
64 69
65/* Override the default new methods */ 70/* Override the default new methods */
66static int sig_cb(int operation, ASN1_VALUE **pval, const ASN1_ITEM *it) 71static int sig_cb(int operation, ASN1_VALUE **pval, const ASN1_ITEM *it)
@@ -83,7 +88,7 @@ ASN1_SEQUENCE_cb(DSA_SIG, sig_cb) = {
83 ASN1_SIMPLE(DSA_SIG, s, CBIGNUM) 88 ASN1_SIMPLE(DSA_SIG, s, CBIGNUM)
84} ASN1_SEQUENCE_END_cb(DSA_SIG, DSA_SIG) 89} ASN1_SEQUENCE_END_cb(DSA_SIG, DSA_SIG)
85 90
86IMPLEMENT_ASN1_FUNCTIONS_const(DSA_SIG) 91IMPLEMENT_ASN1_ENCODE_FUNCTIONS_const_fname(DSA_SIG,DSA_SIG,DSA_SIG)
87 92
88/* Override the default free and new methods */ 93/* Override the default free and new methods */
89static int dsa_cb(int operation, ASN1_VALUE **pval, const ASN1_ITEM *it) 94static int dsa_cb(int operation, ASN1_VALUE **pval, const ASN1_ITEM *it)
@@ -138,3 +143,76 @@ ASN1_CHOICE_cb(DSAPublicKey, dsa_cb) = {
138} ASN1_CHOICE_END_cb(DSA, DSAPublicKey, write_params) 143} ASN1_CHOICE_END_cb(DSA, DSAPublicKey, write_params)
139 144
140IMPLEMENT_ASN1_ENCODE_FUNCTIONS_const_fname(DSA, DSAPublicKey, DSAPublicKey) 145IMPLEMENT_ASN1_ENCODE_FUNCTIONS_const_fname(DSA, DSAPublicKey, DSAPublicKey)
146
147int DSA_sign(int type, const unsigned char *dgst, int dlen, unsigned char *sig,
148 unsigned int *siglen, DSA *dsa)
149 {
150 DSA_SIG *s;
151#ifdef OPENSSL_FIPS
152 if(FIPS_mode() && !(dsa->flags & DSA_FLAG_NON_FIPS_ALLOW))
153 {
154 DSAerr(DSA_F_DSA_SIGN, DSA_R_OPERATION_NOT_ALLOWED_IN_FIPS_MODE);
155 return 0;
156 }
157#endif
158 s=DSA_do_sign(dgst,dlen,dsa);
159 if (s == NULL)
160 {
161 *siglen=0;
162 return(0);
163 }
164 *siglen=i2d_DSA_SIG(s,&sig);
165 DSA_SIG_free(s);
166 return(1);
167 }
168
169int DSA_size(const DSA *r)
170 {
171 int ret,i;
172 ASN1_INTEGER bs;
173 unsigned char buf[4]; /* 4 bytes looks really small.
174 However, i2d_ASN1_INTEGER() will not look
175 beyond the first byte, as long as the second
176 parameter is NULL. */
177
178 i=BN_num_bits(r->q);
179 bs.length=(i+7)/8;
180 bs.data=buf;
181 bs.type=V_ASN1_INTEGER;
182 /* If the top bit is set the asn1 encoding is 1 larger. */
183 buf[0]=0xff;
184
185 i=i2d_ASN1_INTEGER(&bs,NULL);
186 i+=i; /* r and s */
187 ret=ASN1_object_size(1,i,V_ASN1_SEQUENCE);
188 return(ret);
189 }
190
191/* data has already been hashed (probably with SHA or SHA-1). */
192/* returns
193 * 1: correct signature
194 * 0: incorrect signature
195 * -1: error
196 */
197int DSA_verify(int type, const unsigned char *dgst, int dgst_len,
198 const unsigned char *sigbuf, int siglen, DSA *dsa)
199 {
200 DSA_SIG *s;
201 int ret=-1;
202#ifdef OPENSSL_FIPS
203 if(FIPS_mode() && !(dsa->flags & DSA_FLAG_NON_FIPS_ALLOW))
204 {
205 DSAerr(DSA_F_DSA_VERIFY, DSA_R_OPERATION_NOT_ALLOWED_IN_FIPS_MODE);
206 return 0;
207 }
208#endif
209
210 s = DSA_SIG_new();
211 if (s == NULL) return(ret);
212 if (d2i_DSA_SIG(&s,&sigbuf,siglen) == NULL) goto err;
213 ret=DSA_do_verify(dgst,dgst_len,s,dsa);
214err:
215 DSA_SIG_free(s);
216 return(ret);
217 }
218
diff --git a/src/lib/libcrypto/dsa/dsa_err.c b/src/lib/libcrypto/dsa/dsa_err.c
index 768711994b..872839af94 100644
--- a/src/lib/libcrypto/dsa/dsa_err.c
+++ b/src/lib/libcrypto/dsa/dsa_err.c
@@ -1,6 +1,6 @@
1/* crypto/dsa/dsa_err.c */ 1/* crypto/dsa/dsa_err.c */
2/* ==================================================================== 2/* ====================================================================
3 * Copyright (c) 1999-2005 The OpenSSL Project. All rights reserved. 3 * Copyright (c) 1999-2007 The OpenSSL Project. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
@@ -73,11 +73,16 @@ static ERR_STRING_DATA DSA_str_functs[]=
73{ERR_FUNC(DSA_F_D2I_DSA_SIG), "d2i_DSA_SIG"}, 73{ERR_FUNC(DSA_F_D2I_DSA_SIG), "d2i_DSA_SIG"},
74{ERR_FUNC(DSA_F_DSAPARAMS_PRINT), "DSAparams_print"}, 74{ERR_FUNC(DSA_F_DSAPARAMS_PRINT), "DSAparams_print"},
75{ERR_FUNC(DSA_F_DSAPARAMS_PRINT_FP), "DSAparams_print_fp"}, 75{ERR_FUNC(DSA_F_DSAPARAMS_PRINT_FP), "DSAparams_print_fp"},
76{ERR_FUNC(DSA_F_DSA_BUILTIN_KEYGEN), "DSA_BUILTIN_KEYGEN"},
77{ERR_FUNC(DSA_F_DSA_BUILTIN_PARAMGEN), "DSA_BUILTIN_PARAMGEN"},
76{ERR_FUNC(DSA_F_DSA_DO_SIGN), "DSA_do_sign"}, 78{ERR_FUNC(DSA_F_DSA_DO_SIGN), "DSA_do_sign"},
77{ERR_FUNC(DSA_F_DSA_DO_VERIFY), "DSA_do_verify"}, 79{ERR_FUNC(DSA_F_DSA_DO_VERIFY), "DSA_do_verify"},
80{ERR_FUNC(DSA_F_DSA_GENERATE_PARAMETERS), "DSA_generate_parameters"},
78{ERR_FUNC(DSA_F_DSA_NEW_METHOD), "DSA_new_method"}, 81{ERR_FUNC(DSA_F_DSA_NEW_METHOD), "DSA_new_method"},
79{ERR_FUNC(DSA_F_DSA_PRINT), "DSA_print"}, 82{ERR_FUNC(DSA_F_DSA_PRINT), "DSA_print"},
80{ERR_FUNC(DSA_F_DSA_PRINT_FP), "DSA_print_fp"}, 83{ERR_FUNC(DSA_F_DSA_PRINT_FP), "DSA_print_fp"},
84{ERR_FUNC(DSA_F_DSA_SET_DEFAULT_METHOD), "DSA_set_default_method"},
85{ERR_FUNC(DSA_F_DSA_SET_METHOD), "DSA_set_method"},
81{ERR_FUNC(DSA_F_DSA_SIGN), "DSA_sign"}, 86{ERR_FUNC(DSA_F_DSA_SIGN), "DSA_sign"},
82{ERR_FUNC(DSA_F_DSA_SIGN_SETUP), "DSA_sign_setup"}, 87{ERR_FUNC(DSA_F_DSA_SIGN_SETUP), "DSA_sign_setup"},
83{ERR_FUNC(DSA_F_DSA_SIG_NEW), "DSA_SIG_new"}, 88{ERR_FUNC(DSA_F_DSA_SIG_NEW), "DSA_SIG_new"},
@@ -91,8 +96,11 @@ static ERR_STRING_DATA DSA_str_reasons[]=
91 { 96 {
92{ERR_REASON(DSA_R_BAD_Q_VALUE) ,"bad q value"}, 97{ERR_REASON(DSA_R_BAD_Q_VALUE) ,"bad q value"},
93{ERR_REASON(DSA_R_DATA_TOO_LARGE_FOR_KEY_SIZE),"data too large for key size"}, 98{ERR_REASON(DSA_R_DATA_TOO_LARGE_FOR_KEY_SIZE),"data too large for key size"},
99{ERR_REASON(DSA_R_KEY_SIZE_TOO_SMALL) ,"key size too small"},
94{ERR_REASON(DSA_R_MISSING_PARAMETERS) ,"missing parameters"}, 100{ERR_REASON(DSA_R_MISSING_PARAMETERS) ,"missing parameters"},
95{ERR_REASON(DSA_R_MODULUS_TOO_LARGE) ,"modulus too large"}, 101{ERR_REASON(DSA_R_MODULUS_TOO_LARGE) ,"modulus too large"},
102{ERR_REASON(DSA_R_NON_FIPS_METHOD) ,"non fips method"},
103{ERR_REASON(DSA_R_OPERATION_NOT_ALLOWED_IN_FIPS_MODE),"operation not allowed in fips mode"},
96{0,NULL} 104{0,NULL}
97 }; 105 };
98 106
diff --git a/src/lib/libcrypto/dsa/dsa_gen.c b/src/lib/libcrypto/dsa/dsa_gen.c
index ca0b86a6cf..6f1728e3cf 100644
--- a/src/lib/libcrypto/dsa/dsa_gen.c
+++ b/src/lib/libcrypto/dsa/dsa_gen.c
@@ -82,6 +82,8 @@
82#include <openssl/rand.h> 82#include <openssl/rand.h>
83#include <openssl/sha.h> 83#include <openssl/sha.h>
84 84
85#ifndef OPENSSL_FIPS
86
85static int dsa_builtin_paramgen(DSA *ret, int bits, 87static int dsa_builtin_paramgen(DSA *ret, int bits,
86 unsigned char *seed_in, int seed_len, 88 unsigned char *seed_in, int seed_len,
87 int *counter_ret, unsigned long *h_ret, BN_GENCB *cb); 89 int *counter_ret, unsigned long *h_ret, BN_GENCB *cb);
@@ -320,3 +322,4 @@ err:
320 return ok; 322 return ok;
321 } 323 }
322#endif 324#endif
325#endif
diff --git a/src/lib/libcrypto/dsa/dsa_key.c b/src/lib/libcrypto/dsa/dsa_key.c
index c4aa86bc6d..5e39124230 100644
--- a/src/lib/libcrypto/dsa/dsa_key.c
+++ b/src/lib/libcrypto/dsa/dsa_key.c
@@ -64,6 +64,8 @@
64#include <openssl/dsa.h> 64#include <openssl/dsa.h>
65#include <openssl/rand.h> 65#include <openssl/rand.h>
66 66
67#ifndef OPENSSL_FIPS
68
67static int dsa_builtin_keygen(DSA *dsa); 69static int dsa_builtin_keygen(DSA *dsa);
68 70
69int DSA_generate_key(DSA *dsa) 71int DSA_generate_key(DSA *dsa)
@@ -126,3 +128,5 @@ err:
126 return(ok); 128 return(ok);
127 } 129 }
128#endif 130#endif
131
132#endif
diff --git a/src/lib/libcrypto/dsa/dsa_lib.c b/src/lib/libcrypto/dsa/dsa_lib.c
index e9b75902db..7ac9dc8c89 100644
--- a/src/lib/libcrypto/dsa/dsa_lib.c
+++ b/src/lib/libcrypto/dsa/dsa_lib.c
@@ -76,6 +76,14 @@ static const DSA_METHOD *default_DSA_method = NULL;
76 76
77void DSA_set_default_method(const DSA_METHOD *meth) 77void DSA_set_default_method(const DSA_METHOD *meth)
78 { 78 {
79#ifdef OPENSSL_FIPS
80 if (FIPS_mode() && !(meth->flags & DSA_FLAG_FIPS_METHOD))
81 {
82 DSAerr(DSA_F_DSA_SET_DEFAULT_METHOD, DSA_R_NON_FIPS_METHOD);
83 return;
84 }
85#endif
86
79 default_DSA_method = meth; 87 default_DSA_method = meth;
80 } 88 }
81 89
@@ -96,6 +104,13 @@ int DSA_set_method(DSA *dsa, const DSA_METHOD *meth)
96 /* NB: The caller is specifically setting a method, so it's not up to us 104 /* NB: The caller is specifically setting a method, so it's not up to us
97 * to deal with which ENGINE it comes from. */ 105 * to deal with which ENGINE it comes from. */
98 const DSA_METHOD *mtmp; 106 const DSA_METHOD *mtmp;
107#ifdef OPENSSL_FIPS
108 if (FIPS_mode() && !(meth->flags & DSA_FLAG_FIPS_METHOD))
109 {
110 DSAerr(DSA_F_DSA_SET_METHOD, DSA_R_NON_FIPS_METHOD);
111 return 0;
112 }
113#endif
99 mtmp = dsa->meth; 114 mtmp = dsa->meth;
100 if (mtmp->finish) mtmp->finish(dsa); 115 if (mtmp->finish) mtmp->finish(dsa);
101#ifndef OPENSSL_NO_ENGINE 116#ifndef OPENSSL_NO_ENGINE
@@ -147,6 +162,18 @@ DSA *DSA_new_method(ENGINE *engine)
147 } 162 }
148 } 163 }
149#endif 164#endif
165#ifdef OPENSSL_FIPS
166 if (FIPS_mode() && !(ret->meth->flags & DSA_FLAG_FIPS_METHOD))
167 {
168 DSAerr(DSA_F_DSA_NEW_METHOD, DSA_R_NON_FIPS_METHOD);
169#ifndef OPENSSL_NO_ENGINE
170 if (ret->engine)
171 ENGINE_finish(ret->engine);
172#endif
173 OPENSSL_free(ret);
174 return NULL;
175 }
176#endif
150 177
151 ret->pad=0; 178 ret->pad=0;
152 ret->version=0; 179 ret->version=0;
@@ -233,28 +260,6 @@ int DSA_up_ref(DSA *r)
233 return ((i > 1) ? 1 : 0); 260 return ((i > 1) ? 1 : 0);
234 } 261 }
235 262
236int DSA_size(const DSA *r)
237 {
238 int ret,i;
239 ASN1_INTEGER bs;
240 unsigned char buf[4]; /* 4 bytes looks really small.
241 However, i2d_ASN1_INTEGER() will not look
242 beyond the first byte, as long as the second
243 parameter is NULL. */
244
245 i=BN_num_bits(r->q);
246 bs.length=(i+7)/8;
247 bs.data=buf;
248 bs.type=V_ASN1_INTEGER;
249 /* If the top bit is set the asn1 encoding is 1 larger. */
250 buf[0]=0xff;
251
252 i=i2d_ASN1_INTEGER(&bs,NULL);
253 i+=i; /* r and s */
254 ret=ASN1_object_size(1,i,V_ASN1_SEQUENCE);
255 return(ret);
256 }
257
258int DSA_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func, 263int DSA_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func,
259 CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func) 264 CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func)
260 { 265 {
diff --git a/src/lib/libcrypto/dsa/dsa_ossl.c b/src/lib/libcrypto/dsa/dsa_ossl.c
index 75ff7cc4af..412cf1d88b 100644
--- a/src/lib/libcrypto/dsa/dsa_ossl.c
+++ b/src/lib/libcrypto/dsa/dsa_ossl.c
@@ -65,6 +65,8 @@
65#include <openssl/rand.h> 65#include <openssl/rand.h>
66#include <openssl/asn1.h> 66#include <openssl/asn1.h>
67 67
68#ifndef OPENSSL_FIPS
69
68static DSA_SIG *dsa_do_sign(const unsigned char *dgst, int dlen, DSA *dsa); 70static DSA_SIG *dsa_do_sign(const unsigned char *dgst, int dlen, DSA *dsa);
69static int dsa_sign_setup(DSA *dsa, BN_CTX *ctx_in, BIGNUM **kinvp, BIGNUM **rp); 71static int dsa_sign_setup(DSA *dsa, BN_CTX *ctx_in, BIGNUM **kinvp, BIGNUM **rp);
70static int dsa_do_verify(const unsigned char *dgst, int dgst_len, DSA_SIG *sig, 72static int dsa_do_verify(const unsigned char *dgst, int dgst_len, DSA_SIG *sig,
@@ -391,3 +393,4 @@ static int dsa_finish(DSA *dsa)
391 return(1); 393 return(1);
392} 394}
393 395
396#endif
diff --git a/src/lib/libcrypto/dsa/dsa_sign.c b/src/lib/libcrypto/dsa/dsa_sign.c
index 89205026f0..4cfbbe57a8 100644
--- a/src/lib/libcrypto/dsa/dsa_sign.c
+++ b/src/lib/libcrypto/dsa/dsa_sign.c
@@ -64,29 +64,32 @@
64#include <openssl/dsa.h> 64#include <openssl/dsa.h>
65#include <openssl/rand.h> 65#include <openssl/rand.h>
66#include <openssl/asn1.h> 66#include <openssl/asn1.h>
67#ifdef OPENSSL_FIPS
68#include <openssl/fips.h>
69#endif
67 70
68DSA_SIG * DSA_do_sign(const unsigned char *dgst, int dlen, DSA *dsa)
69 {
70 return dsa->meth->dsa_do_sign(dgst, dlen, dsa);
71 }
72 71
73int DSA_sign(int type, const unsigned char *dgst, int dlen, unsigned char *sig, 72DSA_SIG * DSA_do_sign(const unsigned char *dgst, int dlen, DSA *dsa)
74 unsigned int *siglen, DSA *dsa)
75 { 73 {
76 DSA_SIG *s; 74#ifdef OPENSSL_FIPS
77 s=DSA_do_sign(dgst,dlen,dsa); 75 if(FIPS_mode() && !(dsa->flags & DSA_FLAG_NON_FIPS_ALLOW))
78 if (s == NULL)
79 { 76 {
80 *siglen=0; 77 DSAerr(DSA_F_DSA_DO_SIGN, DSA_R_OPERATION_NOT_ALLOWED_IN_FIPS_MODE);
81 return(0); 78 return NULL;
82 } 79 }
83 *siglen=i2d_DSA_SIG(s,&sig); 80#endif
84 DSA_SIG_free(s); 81 return dsa->meth->dsa_do_sign(dgst, dlen, dsa);
85 return(1);
86 } 82 }
87 83
88int DSA_sign_setup(DSA *dsa, BN_CTX *ctx_in, BIGNUM **kinvp, BIGNUM **rp) 84int DSA_sign_setup(DSA *dsa, BN_CTX *ctx_in, BIGNUM **kinvp, BIGNUM **rp)
89 { 85 {
86#ifdef OPENSSL_FIPS
87 if(FIPS_mode() && !(dsa->flags & DSA_FLAG_NON_FIPS_ALLOW))
88 {
89 DSAerr(DSA_F_DSA_SIGN_SETUP, DSA_R_OPERATION_NOT_ALLOWED_IN_FIPS_MODE);
90 return 0;
91 }
92#endif
90 return dsa->meth->dsa_sign_setup(dsa, ctx_in, kinvp, rp); 93 return dsa->meth->dsa_sign_setup(dsa, ctx_in, kinvp, rp);
91 } 94 }
92 95
diff --git a/src/lib/libcrypto/dsa/dsa_vrf.c b/src/lib/libcrypto/dsa/dsa_vrf.c
index c4aeddd056..c75e423048 100644
--- a/src/lib/libcrypto/dsa/dsa_vrf.c
+++ b/src/lib/libcrypto/dsa/dsa_vrf.c
@@ -64,31 +64,21 @@
64#include <openssl/dsa.h> 64#include <openssl/dsa.h>
65#include <openssl/rand.h> 65#include <openssl/rand.h>
66#include <openssl/asn1.h> 66#include <openssl/asn1.h>
67#ifdef OPENSSL_FIPS
68#include <openssl/fips.h>
69#endif
70
67#include <openssl/asn1_mac.h> 71#include <openssl/asn1_mac.h>
68 72
69int DSA_do_verify(const unsigned char *dgst, int dgst_len, DSA_SIG *sig, 73int DSA_do_verify(const unsigned char *dgst, int dgst_len, DSA_SIG *sig,
70 DSA *dsa) 74 DSA *dsa)
71 { 75 {
76#ifdef OPENSSL_FIPS
77 if(FIPS_mode() && !(dsa->flags & DSA_FLAG_NON_FIPS_ALLOW))
78 {
79 DSAerr(DSA_F_DSA_DO_VERIFY, DSA_R_OPERATION_NOT_ALLOWED_IN_FIPS_MODE);
80 return 0;
81 }
82#endif
72 return dsa->meth->dsa_do_verify(dgst, dgst_len, sig, dsa); 83 return dsa->meth->dsa_do_verify(dgst, dgst_len, sig, dsa);
73 } 84 }
74
75/* data has already been hashed (probably with SHA or SHA-1). */
76/* returns
77 * 1: correct signature
78 * 0: incorrect signature
79 * -1: error
80 */
81int DSA_verify(int type, const unsigned char *dgst, int dgst_len,
82 const unsigned char *sigbuf, int siglen, DSA *dsa)
83 {
84 DSA_SIG *s;
85 int ret=-1;
86
87 s = DSA_SIG_new();
88 if (s == NULL) return(ret);
89 if (d2i_DSA_SIG(&s,&sigbuf,siglen) == NULL) goto err;
90 ret=DSA_do_verify(dgst,dgst_len,s,dsa);
91err:
92 DSA_SIG_free(s);
93 return(ret);
94 }
diff --git a/src/lib/libcrypto/ecdh/Makefile b/src/lib/libcrypto/ecdh/Makefile
index 65d8904ee8..7a7b618eeb 100644
--- a/src/lib/libcrypto/ecdh/Makefile
+++ b/src/lib/libcrypto/ecdh/Makefile
@@ -34,7 +34,7 @@ top:
34all: lib 34all: lib
35 35
36lib: $(LIBOBJ) 36lib: $(LIBOBJ)
37 $(AR) $(LIB) $(LIBOBJ) 37 $(ARX) $(LIB) $(LIBOBJ)
38 $(RANLIB) $(LIB) || echo Never mind. 38 $(RANLIB) $(LIB) || echo Never mind.
39 @touch lib 39 @touch lib
40 40
@@ -88,26 +88,27 @@ ech_key.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
88ech_key.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h 88ech_key.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h
89ech_key.o: ../../include/openssl/ecdh.h ../../include/openssl/ecdsa.h 89ech_key.o: ../../include/openssl/ecdh.h ../../include/openssl/ecdsa.h
90ech_key.o: ../../include/openssl/engine.h ../../include/openssl/evp.h 90ech_key.o: ../../include/openssl/engine.h ../../include/openssl/evp.h
91ech_key.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h 91ech_key.o: ../../include/openssl/fips.h ../../include/openssl/lhash.h
92ech_key.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h 92ech_key.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
93ech_key.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h 93ech_key.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
94ech_key.o: ../../include/openssl/pkcs7.h ../../include/openssl/safestack.h 94ech_key.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h
95ech_key.o: ../../include/openssl/sha.h ../../include/openssl/stack.h 95ech_key.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
96ech_key.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h 96ech_key.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
97ech_key.o: ../../include/openssl/x509_vfy.h ech_key.c ech_locl.h 97ech_key.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
98ech_key.o: ech_key.c ech_locl.h
98ech_lib.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h 99ech_lib.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
99ech_lib.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 100ech_lib.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
100ech_lib.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h 101ech_lib.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h
101ech_lib.o: ../../include/openssl/ecdh.h ../../include/openssl/ecdsa.h 102ech_lib.o: ../../include/openssl/ecdh.h ../../include/openssl/ecdsa.h
102ech_lib.o: ../../include/openssl/engine.h ../../include/openssl/err.h 103ech_lib.o: ../../include/openssl/engine.h ../../include/openssl/err.h
103ech_lib.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h 104ech_lib.o: ../../include/openssl/evp.h ../../include/openssl/fips.h
104ech_lib.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h 105ech_lib.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
105ech_lib.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h 106ech_lib.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
106ech_lib.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h 107ech_lib.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
107ech_lib.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h 108ech_lib.o: ../../include/openssl/pkcs7.h ../../include/openssl/safestack.h
108ech_lib.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 109ech_lib.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
109ech_lib.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h 110ech_lib.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h
110ech_lib.o: ech_lib.c ech_locl.h 111ech_lib.o: ../../include/openssl/x509_vfy.h ech_lib.c ech_locl.h
111ech_ossl.o: ../../e_os.h ../../include/openssl/asn1.h 112ech_ossl.o: ../../e_os.h ../../include/openssl/asn1.h
112ech_ossl.o: ../../include/openssl/bio.h ../../include/openssl/bn.h 113ech_ossl.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
113ech_ossl.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 114ech_ossl.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
diff --git a/src/lib/libcrypto/ecdsa/Makefile b/src/lib/libcrypto/ecdsa/Makefile
index 9b48d5641f..4865f3c8d6 100644
--- a/src/lib/libcrypto/ecdsa/Makefile
+++ b/src/lib/libcrypto/ecdsa/Makefile
@@ -34,7 +34,7 @@ top:
34all: lib 34all: lib
35 35
36lib: $(LIBOBJ) 36lib: $(LIBOBJ)
37 $(AR) $(LIB) $(LIBOBJ) 37 $(ARX) $(LIB) $(LIBOBJ)
38 $(RANLIB) $(LIB) || echo Never mind. 38 $(RANLIB) $(LIB) || echo Never mind.
39 @touch lib 39 @touch lib
40 40
@@ -97,13 +97,14 @@ ecs_lib.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
97ecs_lib.o: ../../include/openssl/ec.h ../../include/openssl/ecdh.h 97ecs_lib.o: ../../include/openssl/ec.h ../../include/openssl/ecdh.h
98ecs_lib.o: ../../include/openssl/ecdsa.h ../../include/openssl/engine.h 98ecs_lib.o: ../../include/openssl/ecdsa.h ../../include/openssl/engine.h
99ecs_lib.o: ../../include/openssl/err.h ../../include/openssl/evp.h 99ecs_lib.o: ../../include/openssl/err.h ../../include/openssl/evp.h
100ecs_lib.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h 100ecs_lib.o: ../../include/openssl/fips.h ../../include/openssl/lhash.h
101ecs_lib.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h 101ecs_lib.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
102ecs_lib.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h 102ecs_lib.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
103ecs_lib.o: ../../include/openssl/pkcs7.h ../../include/openssl/safestack.h 103ecs_lib.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h
104ecs_lib.o: ../../include/openssl/sha.h ../../include/openssl/stack.h 104ecs_lib.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
105ecs_lib.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h 105ecs_lib.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
106ecs_lib.o: ../../include/openssl/x509_vfy.h ecs_lib.c ecs_locl.h 106ecs_lib.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
107ecs_lib.o: ecs_lib.c ecs_locl.h
107ecs_ossl.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h 108ecs_ossl.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
108ecs_ossl.o: ../../include/openssl/bn.h ../../include/openssl/crypto.h 109ecs_ossl.o: ../../include/openssl/bn.h ../../include/openssl/crypto.h
109ecs_ossl.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h 110ecs_ossl.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h
@@ -118,8 +119,9 @@ ecs_sign.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
118ecs_sign.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h 119ecs_sign.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h
119ecs_sign.o: ../../include/openssl/ecdh.h ../../include/openssl/ecdsa.h 120ecs_sign.o: ../../include/openssl/ecdh.h ../../include/openssl/ecdsa.h
120ecs_sign.o: ../../include/openssl/engine.h ../../include/openssl/evp.h 121ecs_sign.o: ../../include/openssl/engine.h ../../include/openssl/evp.h
121ecs_sign.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h 122ecs_sign.o: ../../include/openssl/fips.h ../../include/openssl/lhash.h
122ecs_sign.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h 123ecs_sign.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
124ecs_sign.o: ../../include/openssl/opensslconf.h
123ecs_sign.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h 125ecs_sign.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
124ecs_sign.o: ../../include/openssl/pkcs7.h ../../include/openssl/safestack.h 126ecs_sign.o: ../../include/openssl/pkcs7.h ../../include/openssl/safestack.h
125ecs_sign.o: ../../include/openssl/sha.h ../../include/openssl/stack.h 127ecs_sign.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
@@ -130,10 +132,11 @@ ecs_vrf.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
130ecs_vrf.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h 132ecs_vrf.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h
131ecs_vrf.o: ../../include/openssl/ecdh.h ../../include/openssl/ecdsa.h 133ecs_vrf.o: ../../include/openssl/ecdh.h ../../include/openssl/ecdsa.h
132ecs_vrf.o: ../../include/openssl/engine.h ../../include/openssl/evp.h 134ecs_vrf.o: ../../include/openssl/engine.h ../../include/openssl/evp.h
133ecs_vrf.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h 135ecs_vrf.o: ../../include/openssl/fips.h ../../include/openssl/lhash.h
134ecs_vrf.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h 136ecs_vrf.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
135ecs_vrf.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h 137ecs_vrf.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
136ecs_vrf.o: ../../include/openssl/pkcs7.h ../../include/openssl/safestack.h 138ecs_vrf.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h
137ecs_vrf.o: ../../include/openssl/sha.h ../../include/openssl/stack.h 139ecs_vrf.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
138ecs_vrf.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h 140ecs_vrf.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
139ecs_vrf.o: ../../include/openssl/x509_vfy.h ecs_locl.h ecs_vrf.c 141ecs_vrf.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
142ecs_vrf.o: ecs_locl.h ecs_vrf.c
diff --git a/src/lib/libcrypto/engine/Makefile b/src/lib/libcrypto/engine/Makefile
index 47cc619b8a..0cc3722089 100644
--- a/src/lib/libcrypto/engine/Makefile
+++ b/src/lib/libcrypto/engine/Makefile
@@ -41,7 +41,7 @@ top:
41all: lib 41all: lib
42 42
43lib: $(LIBOBJ) 43lib: $(LIBOBJ)
44 $(AR) $(LIB) $(LIBOBJ) 44 $(ARX) $(LIB) $(LIBOBJ)
45 $(RANLIB) $(LIB) || echo Never mind. 45 $(RANLIB) $(LIB) || echo Never mind.
46 @touch lib 46 @touch lib
47 47
@@ -88,34 +88,35 @@ eng_all.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
88eng_all.o: ../../include/openssl/ec.h ../../include/openssl/ecdh.h 88eng_all.o: ../../include/openssl/ec.h ../../include/openssl/ecdh.h
89eng_all.o: ../../include/openssl/ecdsa.h ../../include/openssl/engine.h 89eng_all.o: ../../include/openssl/ecdsa.h ../../include/openssl/engine.h
90eng_all.o: ../../include/openssl/err.h ../../include/openssl/evp.h 90eng_all.o: ../../include/openssl/err.h ../../include/openssl/evp.h
91eng_all.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h 91eng_all.o: ../../include/openssl/fips.h ../../include/openssl/lhash.h
92eng_all.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h 92eng_all.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
93eng_all.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h 93eng_all.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
94eng_all.o: ../../include/openssl/pkcs7.h ../../include/openssl/safestack.h 94eng_all.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h
95eng_all.o: ../../include/openssl/sha.h ../../include/openssl/stack.h 95eng_all.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
96eng_all.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h 96eng_all.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
97eng_all.o: ../../include/openssl/x509_vfy.h ../cryptlib.h eng_all.c eng_int.h 97eng_all.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
98eng_all.o: ../cryptlib.h eng_all.c eng_int.h
98eng_cnf.o: ../../e_os.h ../../include/openssl/asn1.h 99eng_cnf.o: ../../e_os.h ../../include/openssl/asn1.h
99eng_cnf.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h 100eng_cnf.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
100eng_cnf.o: ../../include/openssl/conf.h ../../include/openssl/crypto.h 101eng_cnf.o: ../../include/openssl/conf.h ../../include/openssl/crypto.h
101eng_cnf.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h 102eng_cnf.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h
102eng_cnf.o: ../../include/openssl/ecdh.h ../../include/openssl/ecdsa.h 103eng_cnf.o: ../../include/openssl/ecdh.h ../../include/openssl/ecdsa.h
103eng_cnf.o: ../../include/openssl/engine.h ../../include/openssl/err.h 104eng_cnf.o: ../../include/openssl/engine.h ../../include/openssl/err.h
104eng_cnf.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h 105eng_cnf.o: ../../include/openssl/evp.h ../../include/openssl/fips.h
105eng_cnf.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h 106eng_cnf.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
106eng_cnf.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h 107eng_cnf.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
107eng_cnf.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h 108eng_cnf.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
108eng_cnf.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h 109eng_cnf.o: ../../include/openssl/pkcs7.h ../../include/openssl/safestack.h
109eng_cnf.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 110eng_cnf.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
110eng_cnf.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h 111eng_cnf.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h
111eng_cnf.o: ../cryptlib.h eng_cnf.c eng_int.h 112eng_cnf.o: ../../include/openssl/x509_vfy.h ../cryptlib.h eng_cnf.c eng_int.h
112eng_cryptodev.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h 113eng_cryptodev.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
113eng_cryptodev.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h 114eng_cryptodev.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
114eng_cryptodev.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h 115eng_cryptodev.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
115eng_cryptodev.o: ../../include/openssl/ec.h ../../include/openssl/ecdh.h 116eng_cryptodev.o: ../../include/openssl/ec.h ../../include/openssl/ecdh.h
116eng_cryptodev.o: ../../include/openssl/ecdsa.h ../../include/openssl/engine.h 117eng_cryptodev.o: ../../include/openssl/ecdsa.h ../../include/openssl/engine.h
117eng_cryptodev.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h 118eng_cryptodev.o: ../../include/openssl/evp.h ../../include/openssl/fips.h
118eng_cryptodev.o: ../../include/openssl/obj_mac.h 119eng_cryptodev.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
119eng_cryptodev.o: ../../include/openssl/objects.h 120eng_cryptodev.o: ../../include/openssl/objects.h
120eng_cryptodev.o: ../../include/openssl/opensslconf.h 121eng_cryptodev.o: ../../include/openssl/opensslconf.h
121eng_cryptodev.o: ../../include/openssl/opensslv.h 122eng_cryptodev.o: ../../include/openssl/opensslv.h
@@ -130,8 +131,9 @@ eng_ctrl.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
130eng_ctrl.o: ../../include/openssl/ec.h ../../include/openssl/ecdh.h 131eng_ctrl.o: ../../include/openssl/ec.h ../../include/openssl/ecdh.h
131eng_ctrl.o: ../../include/openssl/ecdsa.h ../../include/openssl/engine.h 132eng_ctrl.o: ../../include/openssl/ecdsa.h ../../include/openssl/engine.h
132eng_ctrl.o: ../../include/openssl/err.h ../../include/openssl/evp.h 133eng_ctrl.o: ../../include/openssl/err.h ../../include/openssl/evp.h
133eng_ctrl.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h 134eng_ctrl.o: ../../include/openssl/fips.h ../../include/openssl/lhash.h
134eng_ctrl.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h 135eng_ctrl.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
136eng_ctrl.o: ../../include/openssl/opensslconf.h
135eng_ctrl.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h 137eng_ctrl.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
136eng_ctrl.o: ../../include/openssl/pkcs7.h ../../include/openssl/safestack.h 138eng_ctrl.o: ../../include/openssl/pkcs7.h ../../include/openssl/safestack.h
137eng_ctrl.o: ../../include/openssl/sha.h ../../include/openssl/stack.h 139eng_ctrl.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
@@ -143,49 +145,50 @@ eng_dyn.o: ../../include/openssl/crypto.h ../../include/openssl/dso.h
143eng_dyn.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h 145eng_dyn.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h
144eng_dyn.o: ../../include/openssl/ecdh.h ../../include/openssl/ecdsa.h 146eng_dyn.o: ../../include/openssl/ecdh.h ../../include/openssl/ecdsa.h
145eng_dyn.o: ../../include/openssl/engine.h ../../include/openssl/err.h 147eng_dyn.o: ../../include/openssl/engine.h ../../include/openssl/err.h
146eng_dyn.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h 148eng_dyn.o: ../../include/openssl/evp.h ../../include/openssl/fips.h
147eng_dyn.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h 149eng_dyn.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
148eng_dyn.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h 150eng_dyn.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
149eng_dyn.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h 151eng_dyn.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
150eng_dyn.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h 152eng_dyn.o: ../../include/openssl/pkcs7.h ../../include/openssl/safestack.h
151eng_dyn.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 153eng_dyn.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
152eng_dyn.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h 154eng_dyn.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h
153eng_dyn.o: ../cryptlib.h eng_dyn.c eng_int.h 155eng_dyn.o: ../../include/openssl/x509_vfy.h ../cryptlib.h eng_dyn.c eng_int.h
154eng_err.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h 156eng_err.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
155eng_err.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 157eng_err.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
156eng_err.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h 158eng_err.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h
157eng_err.o: ../../include/openssl/ecdh.h ../../include/openssl/ecdsa.h 159eng_err.o: ../../include/openssl/ecdh.h ../../include/openssl/ecdsa.h
158eng_err.o: ../../include/openssl/engine.h ../../include/openssl/err.h 160eng_err.o: ../../include/openssl/engine.h ../../include/openssl/err.h
159eng_err.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h 161eng_err.o: ../../include/openssl/evp.h ../../include/openssl/fips.h
160eng_err.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h 162eng_err.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
161eng_err.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h 163eng_err.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
162eng_err.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h 164eng_err.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
163eng_err.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h 165eng_err.o: ../../include/openssl/pkcs7.h ../../include/openssl/safestack.h
164eng_err.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 166eng_err.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
165eng_err.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h 167eng_err.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h
166eng_err.o: eng_err.c 168eng_err.o: ../../include/openssl/x509_vfy.h eng_err.c
167eng_fat.o: ../../e_os.h ../../include/openssl/asn1.h 169eng_fat.o: ../../e_os.h ../../include/openssl/asn1.h
168eng_fat.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h 170eng_fat.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
169eng_fat.o: ../../include/openssl/conf.h ../../include/openssl/crypto.h 171eng_fat.o: ../../include/openssl/conf.h ../../include/openssl/crypto.h
170eng_fat.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h 172eng_fat.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h
171eng_fat.o: ../../include/openssl/ecdh.h ../../include/openssl/ecdsa.h 173eng_fat.o: ../../include/openssl/ecdh.h ../../include/openssl/ecdsa.h
172eng_fat.o: ../../include/openssl/engine.h ../../include/openssl/err.h 174eng_fat.o: ../../include/openssl/engine.h ../../include/openssl/err.h
173eng_fat.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h 175eng_fat.o: ../../include/openssl/evp.h ../../include/openssl/fips.h
174eng_fat.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h 176eng_fat.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
175eng_fat.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h 177eng_fat.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
176eng_fat.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h 178eng_fat.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
177eng_fat.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h 179eng_fat.o: ../../include/openssl/pkcs7.h ../../include/openssl/safestack.h
178eng_fat.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 180eng_fat.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
179eng_fat.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h 181eng_fat.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h
180eng_fat.o: ../cryptlib.h eng_fat.c eng_int.h 182eng_fat.o: ../../include/openssl/x509_vfy.h ../cryptlib.h eng_fat.c eng_int.h
181eng_init.o: ../../e_os.h ../../include/openssl/asn1.h 183eng_init.o: ../../e_os.h ../../include/openssl/asn1.h
182eng_init.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h 184eng_init.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
183eng_init.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h 185eng_init.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
184eng_init.o: ../../include/openssl/ec.h ../../include/openssl/ecdh.h 186eng_init.o: ../../include/openssl/ec.h ../../include/openssl/ecdh.h
185eng_init.o: ../../include/openssl/ecdsa.h ../../include/openssl/engine.h 187eng_init.o: ../../include/openssl/ecdsa.h ../../include/openssl/engine.h
186eng_init.o: ../../include/openssl/err.h ../../include/openssl/evp.h 188eng_init.o: ../../include/openssl/err.h ../../include/openssl/evp.h
187eng_init.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h 189eng_init.o: ../../include/openssl/fips.h ../../include/openssl/lhash.h
188eng_init.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h 190eng_init.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
191eng_init.o: ../../include/openssl/opensslconf.h
189eng_init.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h 192eng_init.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
190eng_init.o: ../../include/openssl/pkcs7.h ../../include/openssl/safestack.h 193eng_init.o: ../../include/openssl/pkcs7.h ../../include/openssl/safestack.h
191eng_init.o: ../../include/openssl/sha.h ../../include/openssl/stack.h 194eng_init.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
@@ -197,22 +200,23 @@ eng_lib.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
197eng_lib.o: ../../include/openssl/ec.h ../../include/openssl/ecdh.h 200eng_lib.o: ../../include/openssl/ec.h ../../include/openssl/ecdh.h
198eng_lib.o: ../../include/openssl/ecdsa.h ../../include/openssl/engine.h 201eng_lib.o: ../../include/openssl/ecdsa.h ../../include/openssl/engine.h
199eng_lib.o: ../../include/openssl/err.h ../../include/openssl/evp.h 202eng_lib.o: ../../include/openssl/err.h ../../include/openssl/evp.h
200eng_lib.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h 203eng_lib.o: ../../include/openssl/fips.h ../../include/openssl/lhash.h
201eng_lib.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h 204eng_lib.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
202eng_lib.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h 205eng_lib.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
203eng_lib.o: ../../include/openssl/pkcs7.h ../../include/openssl/rand.h 206eng_lib.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h
204eng_lib.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h 207eng_lib.o: ../../include/openssl/rand.h ../../include/openssl/safestack.h
205eng_lib.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 208eng_lib.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
206eng_lib.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h 209eng_lib.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h
207eng_lib.o: ../cryptlib.h eng_int.h eng_lib.c 210eng_lib.o: ../../include/openssl/x509_vfy.h ../cryptlib.h eng_int.h eng_lib.c
208eng_list.o: ../../e_os.h ../../include/openssl/asn1.h 211eng_list.o: ../../e_os.h ../../include/openssl/asn1.h
209eng_list.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h 212eng_list.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
210eng_list.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h 213eng_list.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
211eng_list.o: ../../include/openssl/ec.h ../../include/openssl/ecdh.h 214eng_list.o: ../../include/openssl/ec.h ../../include/openssl/ecdh.h
212eng_list.o: ../../include/openssl/ecdsa.h ../../include/openssl/engine.h 215eng_list.o: ../../include/openssl/ecdsa.h ../../include/openssl/engine.h
213eng_list.o: ../../include/openssl/err.h ../../include/openssl/evp.h 216eng_list.o: ../../include/openssl/err.h ../../include/openssl/evp.h
214eng_list.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h 217eng_list.o: ../../include/openssl/fips.h ../../include/openssl/lhash.h
215eng_list.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h 218eng_list.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
219eng_list.o: ../../include/openssl/opensslconf.h
216eng_list.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h 220eng_list.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
217eng_list.o: ../../include/openssl/pkcs7.h ../../include/openssl/safestack.h 221eng_list.o: ../../include/openssl/pkcs7.h ../../include/openssl/safestack.h
218eng_list.o: ../../include/openssl/sha.h ../../include/openssl/stack.h 222eng_list.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
@@ -225,8 +229,9 @@ eng_openssl.o: ../../include/openssl/dsa.h ../../include/openssl/dso.h
225eng_openssl.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h 229eng_openssl.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h
226eng_openssl.o: ../../include/openssl/ecdh.h ../../include/openssl/ecdsa.h 230eng_openssl.o: ../../include/openssl/ecdh.h ../../include/openssl/ecdsa.h
227eng_openssl.o: ../../include/openssl/engine.h ../../include/openssl/err.h 231eng_openssl.o: ../../include/openssl/engine.h ../../include/openssl/err.h
228eng_openssl.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h 232eng_openssl.o: ../../include/openssl/evp.h ../../include/openssl/fips.h
229eng_openssl.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h 233eng_openssl.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
234eng_openssl.o: ../../include/openssl/objects.h
230eng_openssl.o: ../../include/openssl/opensslconf.h 235eng_openssl.o: ../../include/openssl/opensslconf.h
231eng_openssl.o: ../../include/openssl/opensslv.h 236eng_openssl.o: ../../include/openssl/opensslv.h
232eng_openssl.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pem.h 237eng_openssl.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pem.h
@@ -242,8 +247,9 @@ eng_padlock.o: ../../include/openssl/crypto.h ../../include/openssl/dso.h
242eng_padlock.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h 247eng_padlock.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h
243eng_padlock.o: ../../include/openssl/ecdh.h ../../include/openssl/ecdsa.h 248eng_padlock.o: ../../include/openssl/ecdh.h ../../include/openssl/ecdsa.h
244eng_padlock.o: ../../include/openssl/engine.h ../../include/openssl/err.h 249eng_padlock.o: ../../include/openssl/engine.h ../../include/openssl/err.h
245eng_padlock.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h 250eng_padlock.o: ../../include/openssl/evp.h ../../include/openssl/fips.h
246eng_padlock.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h 251eng_padlock.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
252eng_padlock.o: ../../include/openssl/objects.h
247eng_padlock.o: ../../include/openssl/opensslconf.h 253eng_padlock.o: ../../include/openssl/opensslconf.h
248eng_padlock.o: ../../include/openssl/opensslv.h 254eng_padlock.o: ../../include/openssl/opensslv.h
249eng_padlock.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h 255eng_padlock.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h
@@ -257,8 +263,9 @@ eng_pkey.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
257eng_pkey.o: ../../include/openssl/ec.h ../../include/openssl/ecdh.h 263eng_pkey.o: ../../include/openssl/ec.h ../../include/openssl/ecdh.h
258eng_pkey.o: ../../include/openssl/ecdsa.h ../../include/openssl/engine.h 264eng_pkey.o: ../../include/openssl/ecdsa.h ../../include/openssl/engine.h
259eng_pkey.o: ../../include/openssl/err.h ../../include/openssl/evp.h 265eng_pkey.o: ../../include/openssl/err.h ../../include/openssl/evp.h
260eng_pkey.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h 266eng_pkey.o: ../../include/openssl/fips.h ../../include/openssl/lhash.h
261eng_pkey.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h 267eng_pkey.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
268eng_pkey.o: ../../include/openssl/opensslconf.h
262eng_pkey.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h 269eng_pkey.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
263eng_pkey.o: ../../include/openssl/pkcs7.h ../../include/openssl/safestack.h 270eng_pkey.o: ../../include/openssl/pkcs7.h ../../include/openssl/safestack.h
264eng_pkey.o: ../../include/openssl/sha.h ../../include/openssl/stack.h 271eng_pkey.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
@@ -270,8 +277,8 @@ eng_table.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
270eng_table.o: ../../include/openssl/ec.h ../../include/openssl/ecdh.h 277eng_table.o: ../../include/openssl/ec.h ../../include/openssl/ecdh.h
271eng_table.o: ../../include/openssl/ecdsa.h ../../include/openssl/engine.h 278eng_table.o: ../../include/openssl/ecdsa.h ../../include/openssl/engine.h
272eng_table.o: ../../include/openssl/err.h ../../include/openssl/evp.h 279eng_table.o: ../../include/openssl/err.h ../../include/openssl/evp.h
273eng_table.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h 280eng_table.o: ../../include/openssl/fips.h ../../include/openssl/lhash.h
274eng_table.o: ../../include/openssl/objects.h 281eng_table.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
275eng_table.o: ../../include/openssl/opensslconf.h 282eng_table.o: ../../include/openssl/opensslconf.h
276eng_table.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h 283eng_table.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
277eng_table.o: ../../include/openssl/pkcs7.h ../../include/openssl/safestack.h 284eng_table.o: ../../include/openssl/pkcs7.h ../../include/openssl/safestack.h
@@ -285,8 +292,8 @@ tb_cipher.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
285tb_cipher.o: ../../include/openssl/ec.h ../../include/openssl/ecdh.h 292tb_cipher.o: ../../include/openssl/ec.h ../../include/openssl/ecdh.h
286tb_cipher.o: ../../include/openssl/ecdsa.h ../../include/openssl/engine.h 293tb_cipher.o: ../../include/openssl/ecdsa.h ../../include/openssl/engine.h
287tb_cipher.o: ../../include/openssl/err.h ../../include/openssl/evp.h 294tb_cipher.o: ../../include/openssl/err.h ../../include/openssl/evp.h
288tb_cipher.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h 295tb_cipher.o: ../../include/openssl/fips.h ../../include/openssl/lhash.h
289tb_cipher.o: ../../include/openssl/objects.h 296tb_cipher.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
290tb_cipher.o: ../../include/openssl/opensslconf.h 297tb_cipher.o: ../../include/openssl/opensslconf.h
291tb_cipher.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h 298tb_cipher.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
292tb_cipher.o: ../../include/openssl/pkcs7.h ../../include/openssl/safestack.h 299tb_cipher.o: ../../include/openssl/pkcs7.h ../../include/openssl/safestack.h
@@ -299,22 +306,22 @@ tb_dh.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
299tb_dh.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h 306tb_dh.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h
300tb_dh.o: ../../include/openssl/ecdh.h ../../include/openssl/ecdsa.h 307tb_dh.o: ../../include/openssl/ecdh.h ../../include/openssl/ecdsa.h
301tb_dh.o: ../../include/openssl/engine.h ../../include/openssl/err.h 308tb_dh.o: ../../include/openssl/engine.h ../../include/openssl/err.h
302tb_dh.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h 309tb_dh.o: ../../include/openssl/evp.h ../../include/openssl/fips.h
303tb_dh.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h 310tb_dh.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
304tb_dh.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h 311tb_dh.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
305tb_dh.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h 312tb_dh.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
306tb_dh.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h 313tb_dh.o: ../../include/openssl/pkcs7.h ../../include/openssl/safestack.h
307tb_dh.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 314tb_dh.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
308tb_dh.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h 315tb_dh.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h
309tb_dh.o: ../cryptlib.h eng_int.h tb_dh.c 316tb_dh.o: ../../include/openssl/x509_vfy.h ../cryptlib.h eng_int.h tb_dh.c
310tb_digest.o: ../../e_os.h ../../include/openssl/asn1.h 317tb_digest.o: ../../e_os.h ../../include/openssl/asn1.h
311tb_digest.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h 318tb_digest.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
312tb_digest.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h 319tb_digest.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
313tb_digest.o: ../../include/openssl/ec.h ../../include/openssl/ecdh.h 320tb_digest.o: ../../include/openssl/ec.h ../../include/openssl/ecdh.h
314tb_digest.o: ../../include/openssl/ecdsa.h ../../include/openssl/engine.h 321tb_digest.o: ../../include/openssl/ecdsa.h ../../include/openssl/engine.h
315tb_digest.o: ../../include/openssl/err.h ../../include/openssl/evp.h 322tb_digest.o: ../../include/openssl/err.h ../../include/openssl/evp.h
316tb_digest.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h 323tb_digest.o: ../../include/openssl/fips.h ../../include/openssl/lhash.h
317tb_digest.o: ../../include/openssl/objects.h 324tb_digest.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
318tb_digest.o: ../../include/openssl/opensslconf.h 325tb_digest.o: ../../include/openssl/opensslconf.h
319tb_digest.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h 326tb_digest.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
320tb_digest.o: ../../include/openssl/pkcs7.h ../../include/openssl/safestack.h 327tb_digest.o: ../../include/openssl/pkcs7.h ../../include/openssl/safestack.h
@@ -327,35 +334,37 @@ tb_dsa.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
327tb_dsa.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h 334tb_dsa.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h
328tb_dsa.o: ../../include/openssl/ecdh.h ../../include/openssl/ecdsa.h 335tb_dsa.o: ../../include/openssl/ecdh.h ../../include/openssl/ecdsa.h
329tb_dsa.o: ../../include/openssl/engine.h ../../include/openssl/err.h 336tb_dsa.o: ../../include/openssl/engine.h ../../include/openssl/err.h
330tb_dsa.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h 337tb_dsa.o: ../../include/openssl/evp.h ../../include/openssl/fips.h
331tb_dsa.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h 338tb_dsa.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
332tb_dsa.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h 339tb_dsa.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
333tb_dsa.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h 340tb_dsa.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
334tb_dsa.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h 341tb_dsa.o: ../../include/openssl/pkcs7.h ../../include/openssl/safestack.h
335tb_dsa.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 342tb_dsa.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
336tb_dsa.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h 343tb_dsa.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h
337tb_dsa.o: ../cryptlib.h eng_int.h tb_dsa.c 344tb_dsa.o: ../../include/openssl/x509_vfy.h ../cryptlib.h eng_int.h tb_dsa.c
338tb_ecdh.o: ../../e_os.h ../../include/openssl/asn1.h 345tb_ecdh.o: ../../e_os.h ../../include/openssl/asn1.h
339tb_ecdh.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h 346tb_ecdh.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
340tb_ecdh.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h 347tb_ecdh.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
341tb_ecdh.o: ../../include/openssl/ec.h ../../include/openssl/ecdh.h 348tb_ecdh.o: ../../include/openssl/ec.h ../../include/openssl/ecdh.h
342tb_ecdh.o: ../../include/openssl/ecdsa.h ../../include/openssl/engine.h 349tb_ecdh.o: ../../include/openssl/ecdsa.h ../../include/openssl/engine.h
343tb_ecdh.o: ../../include/openssl/err.h ../../include/openssl/evp.h 350tb_ecdh.o: ../../include/openssl/err.h ../../include/openssl/evp.h
344tb_ecdh.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h 351tb_ecdh.o: ../../include/openssl/fips.h ../../include/openssl/lhash.h
345tb_ecdh.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h 352tb_ecdh.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
346tb_ecdh.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h 353tb_ecdh.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
347tb_ecdh.o: ../../include/openssl/pkcs7.h ../../include/openssl/safestack.h 354tb_ecdh.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h
348tb_ecdh.o: ../../include/openssl/sha.h ../../include/openssl/stack.h 355tb_ecdh.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
349tb_ecdh.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h 356tb_ecdh.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
350tb_ecdh.o: ../../include/openssl/x509_vfy.h ../cryptlib.h eng_int.h tb_ecdh.c 357tb_ecdh.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
358tb_ecdh.o: ../cryptlib.h eng_int.h tb_ecdh.c
351tb_ecdsa.o: ../../e_os.h ../../include/openssl/asn1.h 359tb_ecdsa.o: ../../e_os.h ../../include/openssl/asn1.h
352tb_ecdsa.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h 360tb_ecdsa.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
353tb_ecdsa.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h 361tb_ecdsa.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
354tb_ecdsa.o: ../../include/openssl/ec.h ../../include/openssl/ecdh.h 362tb_ecdsa.o: ../../include/openssl/ec.h ../../include/openssl/ecdh.h
355tb_ecdsa.o: ../../include/openssl/ecdsa.h ../../include/openssl/engine.h 363tb_ecdsa.o: ../../include/openssl/ecdsa.h ../../include/openssl/engine.h
356tb_ecdsa.o: ../../include/openssl/err.h ../../include/openssl/evp.h 364tb_ecdsa.o: ../../include/openssl/err.h ../../include/openssl/evp.h
357tb_ecdsa.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h 365tb_ecdsa.o: ../../include/openssl/fips.h ../../include/openssl/lhash.h
358tb_ecdsa.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h 366tb_ecdsa.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
367tb_ecdsa.o: ../../include/openssl/opensslconf.h
359tb_ecdsa.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h 368tb_ecdsa.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
360tb_ecdsa.o: ../../include/openssl/pkcs7.h ../../include/openssl/safestack.h 369tb_ecdsa.o: ../../include/openssl/pkcs7.h ../../include/openssl/safestack.h
361tb_ecdsa.o: ../../include/openssl/sha.h ../../include/openssl/stack.h 370tb_ecdsa.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
@@ -367,34 +376,36 @@ tb_rand.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
367tb_rand.o: ../../include/openssl/ec.h ../../include/openssl/ecdh.h 376tb_rand.o: ../../include/openssl/ec.h ../../include/openssl/ecdh.h
368tb_rand.o: ../../include/openssl/ecdsa.h ../../include/openssl/engine.h 377tb_rand.o: ../../include/openssl/ecdsa.h ../../include/openssl/engine.h
369tb_rand.o: ../../include/openssl/err.h ../../include/openssl/evp.h 378tb_rand.o: ../../include/openssl/err.h ../../include/openssl/evp.h
370tb_rand.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h 379tb_rand.o: ../../include/openssl/fips.h ../../include/openssl/lhash.h
371tb_rand.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h 380tb_rand.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
372tb_rand.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h 381tb_rand.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
373tb_rand.o: ../../include/openssl/pkcs7.h ../../include/openssl/safestack.h 382tb_rand.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h
374tb_rand.o: ../../include/openssl/sha.h ../../include/openssl/stack.h 383tb_rand.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
375tb_rand.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h 384tb_rand.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
376tb_rand.o: ../../include/openssl/x509_vfy.h ../cryptlib.h eng_int.h tb_rand.c 385tb_rand.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
386tb_rand.o: ../cryptlib.h eng_int.h tb_rand.c
377tb_rsa.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h 387tb_rsa.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h
378tb_rsa.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 388tb_rsa.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
379tb_rsa.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h 389tb_rsa.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h
380tb_rsa.o: ../../include/openssl/ecdh.h ../../include/openssl/ecdsa.h 390tb_rsa.o: ../../include/openssl/ecdh.h ../../include/openssl/ecdsa.h
381tb_rsa.o: ../../include/openssl/engine.h ../../include/openssl/err.h 391tb_rsa.o: ../../include/openssl/engine.h ../../include/openssl/err.h
382tb_rsa.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h 392tb_rsa.o: ../../include/openssl/evp.h ../../include/openssl/fips.h
383tb_rsa.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h 393tb_rsa.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
384tb_rsa.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h 394tb_rsa.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
385tb_rsa.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h 395tb_rsa.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
386tb_rsa.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h 396tb_rsa.o: ../../include/openssl/pkcs7.h ../../include/openssl/safestack.h
387tb_rsa.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 397tb_rsa.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
388tb_rsa.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h 398tb_rsa.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h
389tb_rsa.o: ../cryptlib.h eng_int.h tb_rsa.c 399tb_rsa.o: ../../include/openssl/x509_vfy.h ../cryptlib.h eng_int.h tb_rsa.c
390tb_store.o: ../../e_os.h ../../include/openssl/asn1.h 400tb_store.o: ../../e_os.h ../../include/openssl/asn1.h
391tb_store.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h 401tb_store.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
392tb_store.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h 402tb_store.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
393tb_store.o: ../../include/openssl/ec.h ../../include/openssl/ecdh.h 403tb_store.o: ../../include/openssl/ec.h ../../include/openssl/ecdh.h
394tb_store.o: ../../include/openssl/ecdsa.h ../../include/openssl/engine.h 404tb_store.o: ../../include/openssl/ecdsa.h ../../include/openssl/engine.h
395tb_store.o: ../../include/openssl/err.h ../../include/openssl/evp.h 405tb_store.o: ../../include/openssl/err.h ../../include/openssl/evp.h
396tb_store.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h 406tb_store.o: ../../include/openssl/fips.h ../../include/openssl/lhash.h
397tb_store.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h 407tb_store.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
408tb_store.o: ../../include/openssl/opensslconf.h
398tb_store.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h 409tb_store.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
399tb_store.o: ../../include/openssl/pkcs7.h ../../include/openssl/safestack.h 410tb_store.o: ../../include/openssl/pkcs7.h ../../include/openssl/safestack.h
400tb_store.o: ../../include/openssl/sha.h ../../include/openssl/stack.h 411tb_store.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
diff --git a/src/lib/libcrypto/engine/eng_cnf.c b/src/lib/libcrypto/engine/eng_cnf.c
index 8417ddaaef..08066cea59 100644
--- a/src/lib/libcrypto/engine/eng_cnf.c
+++ b/src/lib/libcrypto/engine/eng_cnf.c
@@ -1,5 +1,5 @@
1/* eng_cnf.c */ 1/* eng_cnf.c */
2/* Written by Stephen Henson (shenson@bigfoot.com) for the OpenSSL 2/* Written by Stephen Henson (steve@openssl.org) for the OpenSSL
3 * project 2001. 3 * project 2001.
4 */ 4 */
5/* ==================================================================== 5/* ====================================================================
@@ -98,7 +98,7 @@ static int int_engine_configure(char *name, char *value, const CONF *cnf)
98 CONF_VALUE *ecmd; 98 CONF_VALUE *ecmd;
99 char *ctrlname, *ctrlvalue; 99 char *ctrlname, *ctrlvalue;
100 ENGINE *e = NULL; 100 ENGINE *e = NULL;
101 int soft = 0; 101 int soft = 0;
102 102
103 name = skip_dot(name); 103 name = skip_dot(name);
104#ifdef ENGINE_CONF_DEBUG 104#ifdef ENGINE_CONF_DEBUG
@@ -127,8 +127,8 @@ static int int_engine_configure(char *name, char *value, const CONF *cnf)
127 /* Override engine name to use */ 127 /* Override engine name to use */
128 if (!strcmp(ctrlname, "engine_id")) 128 if (!strcmp(ctrlname, "engine_id"))
129 name = ctrlvalue; 129 name = ctrlvalue;
130 else if (!strcmp(ctrlname, "soft_load")) 130 else if (!strcmp(ctrlname, "soft_load"))
131 soft = 1; 131 soft = 1;
132 /* Load a dynamic ENGINE */ 132 /* Load a dynamic ENGINE */
133 else if (!strcmp(ctrlname, "dynamic_path")) 133 else if (!strcmp(ctrlname, "dynamic_path"))
134 { 134 {
@@ -151,11 +151,11 @@ static int int_engine_configure(char *name, char *value, const CONF *cnf)
151 if (!e) 151 if (!e)
152 { 152 {
153 e = ENGINE_by_id(name); 153 e = ENGINE_by_id(name);
154 if (!e && soft) 154 if (!e && soft)
155 { 155 {
156 ERR_clear_error(); 156 ERR_clear_error();
157 return 1; 157 return 1;
158 } 158 }
159 if (!e) 159 if (!e)
160 return 0; 160 return 0;
161 } 161 }
diff --git a/src/lib/libcrypto/engine/enginetest.c b/src/lib/libcrypto/engine/enginetest.c
index cf82f490db..e3834611db 100644
--- a/src/lib/libcrypto/engine/enginetest.c
+++ b/src/lib/libcrypto/engine/enginetest.c
@@ -58,6 +58,7 @@
58 58
59#include <stdio.h> 59#include <stdio.h>
60#include <string.h> 60#include <string.h>
61#include <openssl/e_os2.h>
61 62
62#ifdef OPENSSL_NO_ENGINE 63#ifdef OPENSSL_NO_ENGINE
63int main(int argc, char *argv[]) 64int main(int argc, char *argv[])
@@ -66,7 +67,6 @@ int main(int argc, char *argv[])
66 return(0); 67 return(0);
67} 68}
68#else 69#else
69#include <openssl/e_os2.h>
70#include <openssl/buffer.h> 70#include <openssl/buffer.h>
71#include <openssl/crypto.h> 71#include <openssl/crypto.h>
72#include <openssl/engine.h> 72#include <openssl/engine.h>
diff --git a/src/lib/libcrypto/err/err.c b/src/lib/libcrypto/err/err.c
index 7952e70ab0..292404a2fb 100644
--- a/src/lib/libcrypto/err/err.c
+++ b/src/lib/libcrypto/err/err.c
@@ -119,480 +119,9 @@
119#include <openssl/bio.h> 119#include <openssl/bio.h>
120#include <openssl/err.h> 120#include <openssl/err.h>
121 121
122static void err_load_strings(int lib, ERR_STRING_DATA *str); 122static unsigned long get_error_values(int inc,int top,
123 123 const char **file,int *line,
124static void ERR_STATE_free(ERR_STATE *s); 124 const char **data,int *flags);
125#ifndef OPENSSL_NO_ERR
126static ERR_STRING_DATA ERR_str_libraries[]=
127 {
128{ERR_PACK(ERR_LIB_NONE,0,0) ,"unknown library"},
129{ERR_PACK(ERR_LIB_SYS,0,0) ,"system library"},
130{ERR_PACK(ERR_LIB_BN,0,0) ,"bignum routines"},
131{ERR_PACK(ERR_LIB_RSA,0,0) ,"rsa routines"},
132{ERR_PACK(ERR_LIB_DH,0,0) ,"Diffie-Hellman routines"},
133{ERR_PACK(ERR_LIB_EVP,0,0) ,"digital envelope routines"},
134{ERR_PACK(ERR_LIB_BUF,0,0) ,"memory buffer routines"},
135{ERR_PACK(ERR_LIB_OBJ,0,0) ,"object identifier routines"},
136{ERR_PACK(ERR_LIB_PEM,0,0) ,"PEM routines"},
137{ERR_PACK(ERR_LIB_DSA,0,0) ,"dsa routines"},
138{ERR_PACK(ERR_LIB_X509,0,0) ,"x509 certificate routines"},
139{ERR_PACK(ERR_LIB_ASN1,0,0) ,"asn1 encoding routines"},
140{ERR_PACK(ERR_LIB_CONF,0,0) ,"configuration file routines"},
141{ERR_PACK(ERR_LIB_CRYPTO,0,0) ,"common libcrypto routines"},
142{ERR_PACK(ERR_LIB_EC,0,0) ,"elliptic curve routines"},
143{ERR_PACK(ERR_LIB_SSL,0,0) ,"SSL routines"},
144{ERR_PACK(ERR_LIB_BIO,0,0) ,"BIO routines"},
145{ERR_PACK(ERR_LIB_PKCS7,0,0) ,"PKCS7 routines"},
146{ERR_PACK(ERR_LIB_X509V3,0,0) ,"X509 V3 routines"},
147{ERR_PACK(ERR_LIB_PKCS12,0,0) ,"PKCS12 routines"},
148{ERR_PACK(ERR_LIB_RAND,0,0) ,"random number generator"},
149{ERR_PACK(ERR_LIB_DSO,0,0) ,"DSO support routines"},
150{ERR_PACK(ERR_LIB_ENGINE,0,0) ,"engine routines"},
151{ERR_PACK(ERR_LIB_OCSP,0,0) ,"OCSP routines"},
152{ERR_PACK(ERR_LIB_FIPS,0,0) ,"FIPS routines"},
153{ERR_PACK(ERR_LIB_CMS,0,0) ,"CMS routines"},
154{0,NULL},
155 };
156
157static ERR_STRING_DATA ERR_str_functs[]=
158 {
159 {ERR_PACK(0,SYS_F_FOPEN,0), "fopen"},
160 {ERR_PACK(0,SYS_F_CONNECT,0), "connect"},
161 {ERR_PACK(0,SYS_F_GETSERVBYNAME,0), "getservbyname"},
162 {ERR_PACK(0,SYS_F_SOCKET,0), "socket"},
163 {ERR_PACK(0,SYS_F_IOCTLSOCKET,0), "ioctlsocket"},
164 {ERR_PACK(0,SYS_F_BIND,0), "bind"},
165 {ERR_PACK(0,SYS_F_LISTEN,0), "listen"},
166 {ERR_PACK(0,SYS_F_ACCEPT,0), "accept"},
167#ifdef OPENSSL_SYS_WINDOWS
168 {ERR_PACK(0,SYS_F_WSASTARTUP,0), "WSAstartup"},
169#endif
170 {ERR_PACK(0,SYS_F_OPENDIR,0), "opendir"},
171 {ERR_PACK(0,SYS_F_FREAD,0), "fread"},
172 {0,NULL},
173 };
174
175static ERR_STRING_DATA ERR_str_reasons[]=
176 {
177{ERR_R_SYS_LIB ,"system lib"},
178{ERR_R_BN_LIB ,"BN lib"},
179{ERR_R_RSA_LIB ,"RSA lib"},
180{ERR_R_DH_LIB ,"DH lib"},
181{ERR_R_EVP_LIB ,"EVP lib"},
182{ERR_R_BUF_LIB ,"BUF lib"},
183{ERR_R_OBJ_LIB ,"OBJ lib"},
184{ERR_R_PEM_LIB ,"PEM lib"},
185{ERR_R_DSA_LIB ,"DSA lib"},
186{ERR_R_X509_LIB ,"X509 lib"},
187{ERR_R_ASN1_LIB ,"ASN1 lib"},
188{ERR_R_CONF_LIB ,"CONF lib"},
189{ERR_R_CRYPTO_LIB ,"CRYPTO lib"},
190{ERR_R_EC_LIB ,"EC lib"},
191{ERR_R_SSL_LIB ,"SSL lib"},
192{ERR_R_BIO_LIB ,"BIO lib"},
193{ERR_R_PKCS7_LIB ,"PKCS7 lib"},
194{ERR_R_X509V3_LIB ,"X509V3 lib"},
195{ERR_R_PKCS12_LIB ,"PKCS12 lib"},
196{ERR_R_RAND_LIB ,"RAND lib"},
197{ERR_R_DSO_LIB ,"DSO lib"},
198{ERR_R_ENGINE_LIB ,"ENGINE lib"},
199{ERR_R_OCSP_LIB ,"OCSP lib"},
200
201{ERR_R_NESTED_ASN1_ERROR ,"nested asn1 error"},
202{ERR_R_BAD_ASN1_OBJECT_HEADER ,"bad asn1 object header"},
203{ERR_R_BAD_GET_ASN1_OBJECT_CALL ,"bad get asn1 object call"},
204{ERR_R_EXPECTING_AN_ASN1_SEQUENCE ,"expecting an asn1 sequence"},
205{ERR_R_ASN1_LENGTH_MISMATCH ,"asn1 length mismatch"},
206{ERR_R_MISSING_ASN1_EOS ,"missing asn1 eos"},
207
208{ERR_R_FATAL ,"fatal"},
209{ERR_R_MALLOC_FAILURE ,"malloc failure"},
210{ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED ,"called a function you should not call"},
211{ERR_R_PASSED_NULL_PARAMETER ,"passed a null parameter"},
212{ERR_R_INTERNAL_ERROR ,"internal error"},
213{ERR_R_DISABLED ,"called a function that was disabled at compile-time"},
214
215{0,NULL},
216 };
217#endif
218
219
220/* Define the predeclared (but externally opaque) "ERR_FNS" type */
221struct st_ERR_FNS
222 {
223 /* Works on the "error_hash" string table */
224 LHASH *(*cb_err_get)(int create);
225 void (*cb_err_del)(void);
226 ERR_STRING_DATA *(*cb_err_get_item)(const ERR_STRING_DATA *);
227 ERR_STRING_DATA *(*cb_err_set_item)(ERR_STRING_DATA *);
228 ERR_STRING_DATA *(*cb_err_del_item)(ERR_STRING_DATA *);
229 /* Works on the "thread_hash" error-state table */
230 LHASH *(*cb_thread_get)(int create);
231 void (*cb_thread_release)(LHASH **hash);
232 ERR_STATE *(*cb_thread_get_item)(const ERR_STATE *);
233 ERR_STATE *(*cb_thread_set_item)(ERR_STATE *);
234 void (*cb_thread_del_item)(const ERR_STATE *);
235 /* Returns the next available error "library" numbers */
236 int (*cb_get_next_lib)(void);
237 };
238
239/* Predeclarations of the "err_defaults" functions */
240static LHASH *int_err_get(int create);
241static void int_err_del(void);
242static ERR_STRING_DATA *int_err_get_item(const ERR_STRING_DATA *);
243static ERR_STRING_DATA *int_err_set_item(ERR_STRING_DATA *);
244static ERR_STRING_DATA *int_err_del_item(ERR_STRING_DATA *);
245static LHASH *int_thread_get(int create);
246static void int_thread_release(LHASH **hash);
247static ERR_STATE *int_thread_get_item(const ERR_STATE *);
248static ERR_STATE *int_thread_set_item(ERR_STATE *);
249static void int_thread_del_item(const ERR_STATE *);
250static int int_err_get_next_lib(void);
251/* The static ERR_FNS table using these defaults functions */
252static const ERR_FNS err_defaults =
253 {
254 int_err_get,
255 int_err_del,
256 int_err_get_item,
257 int_err_set_item,
258 int_err_del_item,
259 int_thread_get,
260 int_thread_release,
261 int_thread_get_item,
262 int_thread_set_item,
263 int_thread_del_item,
264 int_err_get_next_lib
265 };
266
267/* The replacable table of ERR_FNS functions we use at run-time */
268static const ERR_FNS *err_fns = NULL;
269
270/* Eg. rather than using "err_get()", use "ERRFN(err_get)()". */
271#define ERRFN(a) err_fns->cb_##a
272
273/* The internal state used by "err_defaults" - as such, the setting, reading,
274 * creating, and deleting of this data should only be permitted via the
275 * "err_defaults" functions. This way, a linked module can completely defer all
276 * ERR state operation (together with requisite locking) to the implementations
277 * and state in the loading application. */
278static LHASH *int_error_hash = NULL;
279static LHASH *int_thread_hash = NULL;
280static int int_thread_hash_references = 0;
281static int int_err_library_number= ERR_LIB_USER;
282
283/* Internal function that checks whether "err_fns" is set and if not, sets it to
284 * the defaults. */
285static void err_fns_check(void)
286 {
287 if (err_fns) return;
288
289 CRYPTO_w_lock(CRYPTO_LOCK_ERR);
290 if (!err_fns)
291 err_fns = &err_defaults;
292 CRYPTO_w_unlock(CRYPTO_LOCK_ERR);
293 }
294
295/* API functions to get or set the underlying ERR functions. */
296
297const ERR_FNS *ERR_get_implementation(void)
298 {
299 err_fns_check();
300 return err_fns;
301 }
302
303int ERR_set_implementation(const ERR_FNS *fns)
304 {
305 int ret = 0;
306
307 CRYPTO_w_lock(CRYPTO_LOCK_ERR);
308 /* It's too late if 'err_fns' is non-NULL. BTW: not much point setting
309 * an error is there?! */
310 if (!err_fns)
311 {
312 err_fns = fns;
313 ret = 1;
314 }
315 CRYPTO_w_unlock(CRYPTO_LOCK_ERR);
316 return ret;
317 }
318
319/* These are the callbacks provided to "lh_new()" when creating the LHASH tables
320 * internal to the "err_defaults" implementation. */
321
322/* static unsigned long err_hash(ERR_STRING_DATA *a); */
323static unsigned long err_hash(const void *a_void);
324/* static int err_cmp(ERR_STRING_DATA *a, ERR_STRING_DATA *b); */
325static int err_cmp(const void *a_void, const void *b_void);
326/* static unsigned long pid_hash(ERR_STATE *pid); */
327static unsigned long pid_hash(const void *pid_void);
328/* static int pid_cmp(ERR_STATE *a,ERR_STATE *pid); */
329static int pid_cmp(const void *a_void,const void *pid_void);
330static unsigned long get_error_values(int inc,int top,const char **file,int *line,
331 const char **data,int *flags);
332
333/* The internal functions used in the "err_defaults" implementation */
334
335static LHASH *int_err_get(int create)
336 {
337 LHASH *ret = NULL;
338
339 CRYPTO_w_lock(CRYPTO_LOCK_ERR);
340 if (!int_error_hash && create)
341 {
342 CRYPTO_push_info("int_err_get (err.c)");
343 int_error_hash = lh_new(err_hash, err_cmp);
344 CRYPTO_pop_info();
345 }
346 if (int_error_hash)
347 ret = int_error_hash;
348 CRYPTO_w_unlock(CRYPTO_LOCK_ERR);
349
350 return ret;
351 }
352
353static void int_err_del(void)
354 {
355 CRYPTO_w_lock(CRYPTO_LOCK_ERR);
356 if (int_error_hash)
357 {
358 lh_free(int_error_hash);
359 int_error_hash = NULL;
360 }
361 CRYPTO_w_unlock(CRYPTO_LOCK_ERR);
362 }
363
364static ERR_STRING_DATA *int_err_get_item(const ERR_STRING_DATA *d)
365 {
366 ERR_STRING_DATA *p;
367 LHASH *hash;
368
369 err_fns_check();
370 hash = ERRFN(err_get)(0);
371 if (!hash)
372 return NULL;
373
374 CRYPTO_r_lock(CRYPTO_LOCK_ERR);
375 p = (ERR_STRING_DATA *)lh_retrieve(hash, d);
376 CRYPTO_r_unlock(CRYPTO_LOCK_ERR);
377
378 return p;
379 }
380
381static ERR_STRING_DATA *int_err_set_item(ERR_STRING_DATA *d)
382 {
383 ERR_STRING_DATA *p;
384 LHASH *hash;
385
386 err_fns_check();
387 hash = ERRFN(err_get)(1);
388 if (!hash)
389 return NULL;
390
391 CRYPTO_w_lock(CRYPTO_LOCK_ERR);
392 p = (ERR_STRING_DATA *)lh_insert(hash, d);
393 CRYPTO_w_unlock(CRYPTO_LOCK_ERR);
394
395 return p;
396 }
397
398static ERR_STRING_DATA *int_err_del_item(ERR_STRING_DATA *d)
399 {
400 ERR_STRING_DATA *p;
401 LHASH *hash;
402
403 err_fns_check();
404 hash = ERRFN(err_get)(0);
405 if (!hash)
406 return NULL;
407
408 CRYPTO_w_lock(CRYPTO_LOCK_ERR);
409 p = (ERR_STRING_DATA *)lh_delete(hash, d);
410 CRYPTO_w_unlock(CRYPTO_LOCK_ERR);
411
412 return p;
413 }
414
415static LHASH *int_thread_get(int create)
416 {
417 LHASH *ret = NULL;
418
419 CRYPTO_w_lock(CRYPTO_LOCK_ERR);
420 if (!int_thread_hash && create)
421 {
422 CRYPTO_push_info("int_thread_get (err.c)");
423 int_thread_hash = lh_new(pid_hash, pid_cmp);
424 CRYPTO_pop_info();
425 }
426 if (int_thread_hash)
427 {
428 int_thread_hash_references++;
429 ret = int_thread_hash;
430 }
431 CRYPTO_w_unlock(CRYPTO_LOCK_ERR);
432 return ret;
433 }
434
435static void int_thread_release(LHASH **hash)
436 {
437 int i;
438
439 if (hash == NULL || *hash == NULL)
440 return;
441
442 i = CRYPTO_add(&int_thread_hash_references, -1, CRYPTO_LOCK_ERR);
443
444#ifdef REF_PRINT
445 fprintf(stderr,"%4d:%s\n",int_thread_hash_references,"ERR");
446#endif
447 if (i > 0) return;
448#ifdef REF_CHECK
449 if (i < 0)
450 {
451 fprintf(stderr,"int_thread_release, bad reference count\n");
452 abort(); /* ok */
453 }
454#endif
455 *hash = NULL;
456 }
457
458static ERR_STATE *int_thread_get_item(const ERR_STATE *d)
459 {
460 ERR_STATE *p;
461 LHASH *hash;
462
463 err_fns_check();
464 hash = ERRFN(thread_get)(0);
465 if (!hash)
466 return NULL;
467
468 CRYPTO_r_lock(CRYPTO_LOCK_ERR);
469 p = (ERR_STATE *)lh_retrieve(hash, d);
470 CRYPTO_r_unlock(CRYPTO_LOCK_ERR);
471
472 ERRFN(thread_release)(&hash);
473 return p;
474 }
475
476static ERR_STATE *int_thread_set_item(ERR_STATE *d)
477 {
478 ERR_STATE *p;
479 LHASH *hash;
480
481 err_fns_check();
482 hash = ERRFN(thread_get)(1);
483 if (!hash)
484 return NULL;
485
486 CRYPTO_w_lock(CRYPTO_LOCK_ERR);
487 p = (ERR_STATE *)lh_insert(hash, d);
488 CRYPTO_w_unlock(CRYPTO_LOCK_ERR);
489
490 ERRFN(thread_release)(&hash);
491 return p;
492 }
493
494static void int_thread_del_item(const ERR_STATE *d)
495 {
496 ERR_STATE *p;
497 LHASH *hash;
498
499 err_fns_check();
500 hash = ERRFN(thread_get)(0);
501 if (!hash)
502 return;
503
504 CRYPTO_w_lock(CRYPTO_LOCK_ERR);
505 p = (ERR_STATE *)lh_delete(hash, d);
506 /* make sure we don't leak memory */
507 if (int_thread_hash_references == 1
508 && int_thread_hash && (lh_num_items(int_thread_hash) == 0))
509 {
510 lh_free(int_thread_hash);
511 int_thread_hash = NULL;
512 }
513 CRYPTO_w_unlock(CRYPTO_LOCK_ERR);
514
515 ERRFN(thread_release)(&hash);
516 if (p)
517 ERR_STATE_free(p);
518 }
519
520static int int_err_get_next_lib(void)
521 {
522 int ret;
523
524 CRYPTO_w_lock(CRYPTO_LOCK_ERR);
525 ret = int_err_library_number++;
526 CRYPTO_w_unlock(CRYPTO_LOCK_ERR);
527
528 return ret;
529 }
530
531
532#ifndef OPENSSL_NO_ERR
533#define NUM_SYS_STR_REASONS 127
534#define LEN_SYS_STR_REASON 32
535
536static ERR_STRING_DATA SYS_str_reasons[NUM_SYS_STR_REASONS + 1];
537/* SYS_str_reasons is filled with copies of strerror() results at
538 * initialization.
539 * 'errno' values up to 127 should cover all usual errors,
540 * others will be displayed numerically by ERR_error_string.
541 * It is crucial that we have something for each reason code
542 * that occurs in ERR_str_reasons, or bogus reason strings
543 * will be returned for SYSerr(), which always gets an errno
544 * value and never one of those 'standard' reason codes. */
545
546static void build_SYS_str_reasons(void)
547 {
548 /* OPENSSL_malloc cannot be used here, use static storage instead */
549 static char strerror_tab[NUM_SYS_STR_REASONS][LEN_SYS_STR_REASON];
550 int i;
551 static int init = 1;
552
553 CRYPTO_r_lock(CRYPTO_LOCK_ERR);
554 if (!init)
555 {
556 CRYPTO_r_unlock(CRYPTO_LOCK_ERR);
557 return;
558 }
559
560 CRYPTO_r_unlock(CRYPTO_LOCK_ERR);
561 CRYPTO_w_lock(CRYPTO_LOCK_ERR);
562 if (!init)
563 {
564 CRYPTO_w_unlock(CRYPTO_LOCK_ERR);
565 return;
566 }
567
568 for (i = 1; i <= NUM_SYS_STR_REASONS; i++)
569 {
570 ERR_STRING_DATA *str = &SYS_str_reasons[i - 1];
571
572 str->error = (unsigned long)i;
573 if (str->string == NULL)
574 {
575 char (*dest)[LEN_SYS_STR_REASON] = &(strerror_tab[i - 1]);
576 char *src = strerror(i);
577 if (src != NULL)
578 {
579 strncpy(*dest, src, sizeof *dest);
580 (*dest)[sizeof *dest - 1] = '\0';
581 str->string = *dest;
582 }
583 }
584 if (str->string == NULL)
585 str->string = "unknown";
586 }
587
588 /* Now we still have SYS_str_reasons[NUM_SYS_STR_REASONS] = {0, NULL},
589 * as required by ERR_load_strings. */
590
591 init = 0;
592
593 CRYPTO_w_unlock(CRYPTO_LOCK_ERR);
594 }
595#endif
596 125
597#define err_clear_data(p,i) \ 126#define err_clear_data(p,i) \
598 do { \ 127 do { \
@@ -614,68 +143,6 @@ static void build_SYS_str_reasons(void)
614 (p)->err_line[i]= -1; \ 143 (p)->err_line[i]= -1; \
615 } while(0) 144 } while(0)
616 145
617static void ERR_STATE_free(ERR_STATE *s)
618 {
619 int i;
620
621 if (s == NULL)
622 return;
623
624 for (i=0; i<ERR_NUM_ERRORS; i++)
625 {
626 err_clear_data(s,i);
627 }
628 OPENSSL_free(s);
629 }
630
631void ERR_load_ERR_strings(void)
632 {
633 err_fns_check();
634#ifndef OPENSSL_NO_ERR
635 err_load_strings(0,ERR_str_libraries);
636 err_load_strings(0,ERR_str_reasons);
637 err_load_strings(ERR_LIB_SYS,ERR_str_functs);
638 build_SYS_str_reasons();
639 err_load_strings(ERR_LIB_SYS,SYS_str_reasons);
640#endif
641 }
642
643static void err_load_strings(int lib, ERR_STRING_DATA *str)
644 {
645 while (str->error)
646 {
647 if (lib)
648 str->error|=ERR_PACK(lib,0,0);
649 ERRFN(err_set_item)(str);
650 str++;
651 }
652 }
653
654void ERR_load_strings(int lib, ERR_STRING_DATA *str)
655 {
656 ERR_load_ERR_strings();
657 err_load_strings(lib, str);
658 }
659
660void ERR_unload_strings(int lib, ERR_STRING_DATA *str)
661 {
662 while (str->error)
663 {
664 if (lib)
665 str->error|=ERR_PACK(lib,0,0);
666 ERRFN(err_del_item)(str);
667 str++;
668 }
669 }
670
671void ERR_free_strings(void)
672 {
673 err_fns_check();
674 ERRFN(err_del)();
675 }
676
677/********************************************************/
678
679void ERR_put_error(int lib, int func, int reason, const char *file, 146void ERR_put_error(int lib, int func, int reason, const char *file,
680 int line) 147 int line)
681 { 148 {
@@ -830,218 +297,6 @@ static unsigned long get_error_values(int inc, int top, const char **file, int *
830 return ret; 297 return ret;
831 } 298 }
832 299
833void ERR_error_string_n(unsigned long e, char *buf, size_t len)
834 {
835 char lsbuf[64], fsbuf[64], rsbuf[64];
836 const char *ls,*fs,*rs;
837 unsigned long l,f,r;
838
839 l=ERR_GET_LIB(e);
840 f=ERR_GET_FUNC(e);
841 r=ERR_GET_REASON(e);
842
843 ls=ERR_lib_error_string(e);
844 fs=ERR_func_error_string(e);
845 rs=ERR_reason_error_string(e);
846
847 if (ls == NULL)
848 BIO_snprintf(lsbuf, sizeof(lsbuf), "lib(%lu)", l);
849 if (fs == NULL)
850 BIO_snprintf(fsbuf, sizeof(fsbuf), "func(%lu)", f);
851 if (rs == NULL)
852 BIO_snprintf(rsbuf, sizeof(rsbuf), "reason(%lu)", r);
853
854 BIO_snprintf(buf, len,"error:%08lX:%s:%s:%s", e, ls?ls:lsbuf,
855 fs?fs:fsbuf, rs?rs:rsbuf);
856 if (strlen(buf) == len-1)
857 {
858 /* output may be truncated; make sure we always have 5
859 * colon-separated fields, i.e. 4 colons ... */
860#define NUM_COLONS 4
861 if (len > NUM_COLONS) /* ... if possible */
862 {
863 int i;
864 char *s = buf;
865
866 for (i = 0; i < NUM_COLONS; i++)
867 {
868 char *colon = strchr(s, ':');
869 if (colon == NULL || colon > &buf[len-1] - NUM_COLONS + i)
870 {
871 /* set colon no. i at last possible position
872 * (buf[len-1] is the terminating 0)*/
873 colon = &buf[len-1] - NUM_COLONS + i;
874 *colon = ':';
875 }
876 s = colon + 1;
877 }
878 }
879 }
880 }
881
882/* BAD for multi-threading: uses a local buffer if ret == NULL */
883/* ERR_error_string_n should be used instead for ret != NULL
884 * as ERR_error_string cannot know how large the buffer is */
885char *ERR_error_string(unsigned long e, char *ret)
886 {
887 static char buf[256];
888
889 if (ret == NULL) ret=buf;
890 ERR_error_string_n(e, ret, 256);
891
892 return ret;
893 }
894
895LHASH *ERR_get_string_table(void)
896 {
897 err_fns_check();
898 return ERRFN(err_get)(0);
899 }
900
901LHASH *ERR_get_err_state_table(void)
902 {
903 err_fns_check();
904 return ERRFN(thread_get)(0);
905 }
906
907void ERR_release_err_state_table(LHASH **hash)
908 {
909 err_fns_check();
910 ERRFN(thread_release)(hash);
911 }
912
913const char *ERR_lib_error_string(unsigned long e)
914 {
915 ERR_STRING_DATA d,*p;
916 unsigned long l;
917
918 err_fns_check();
919 l=ERR_GET_LIB(e);
920 d.error=ERR_PACK(l,0,0);
921 p=ERRFN(err_get_item)(&d);
922 return((p == NULL)?NULL:p->string);
923 }
924
925const char *ERR_func_error_string(unsigned long e)
926 {
927 ERR_STRING_DATA d,*p;
928 unsigned long l,f;
929
930 err_fns_check();
931 l=ERR_GET_LIB(e);
932 f=ERR_GET_FUNC(e);
933 d.error=ERR_PACK(l,f,0);
934 p=ERRFN(err_get_item)(&d);
935 return((p == NULL)?NULL:p->string);
936 }
937
938const char *ERR_reason_error_string(unsigned long e)
939 {
940 ERR_STRING_DATA d,*p=NULL;
941 unsigned long l,r;
942
943 err_fns_check();
944 l=ERR_GET_LIB(e);
945 r=ERR_GET_REASON(e);
946 d.error=ERR_PACK(l,0,r);
947 p=ERRFN(err_get_item)(&d);
948 if (!p)
949 {
950 d.error=ERR_PACK(0,0,r);
951 p=ERRFN(err_get_item)(&d);
952 }
953 return((p == NULL)?NULL:p->string);
954 }
955
956/* static unsigned long err_hash(ERR_STRING_DATA *a) */
957static unsigned long err_hash(const void *a_void)
958 {
959 unsigned long ret,l;
960
961 l=((const ERR_STRING_DATA *)a_void)->error;
962 ret=l^ERR_GET_LIB(l)^ERR_GET_FUNC(l);
963 return(ret^ret%19*13);
964 }
965
966/* static int err_cmp(ERR_STRING_DATA *a, ERR_STRING_DATA *b) */
967static int err_cmp(const void *a_void, const void *b_void)
968 {
969 return((int)(((const ERR_STRING_DATA *)a_void)->error -
970 ((const ERR_STRING_DATA *)b_void)->error));
971 }
972
973/* static unsigned long pid_hash(ERR_STATE *a) */
974static unsigned long pid_hash(const void *a_void)
975 {
976 return(((const ERR_STATE *)a_void)->pid*13);
977 }
978
979/* static int pid_cmp(ERR_STATE *a, ERR_STATE *b) */
980static int pid_cmp(const void *a_void, const void *b_void)
981 {
982 return((int)((long)((const ERR_STATE *)a_void)->pid -
983 (long)((const ERR_STATE *)b_void)->pid));
984 }
985
986void ERR_remove_state(unsigned long pid)
987 {
988 ERR_STATE tmp;
989
990 err_fns_check();
991 if (pid == 0)
992 pid=(unsigned long)CRYPTO_thread_id();
993 tmp.pid=pid;
994 /* thread_del_item automatically destroys the LHASH if the number of
995 * items reaches zero. */
996 ERRFN(thread_del_item)(&tmp);
997 }
998
999ERR_STATE *ERR_get_state(void)
1000 {
1001 static ERR_STATE fallback;
1002 ERR_STATE *ret,tmp,*tmpp=NULL;
1003 int i;
1004 unsigned long pid;
1005
1006 err_fns_check();
1007 pid=(unsigned long)CRYPTO_thread_id();
1008 tmp.pid=pid;
1009 ret=ERRFN(thread_get_item)(&tmp);
1010
1011 /* ret == the error state, if NULL, make a new one */
1012 if (ret == NULL)
1013 {
1014 ret=(ERR_STATE *)OPENSSL_malloc(sizeof(ERR_STATE));
1015 if (ret == NULL) return(&fallback);
1016 ret->pid=pid;
1017 ret->top=0;
1018 ret->bottom=0;
1019 for (i=0; i<ERR_NUM_ERRORS; i++)
1020 {
1021 ret->err_data[i]=NULL;
1022 ret->err_data_flags[i]=0;
1023 }
1024 tmpp = ERRFN(thread_set_item)(ret);
1025 /* To check if insertion failed, do a get. */
1026 if (ERRFN(thread_get_item)(ret) != ret)
1027 {
1028 ERR_STATE_free(ret); /* could not insert it */
1029 return(&fallback);
1030 }
1031 /* If a race occured in this function and we came second, tmpp
1032 * is the first one that we just replaced. */
1033 if (tmpp)
1034 ERR_STATE_free(tmpp);
1035 }
1036 return ret;
1037 }
1038
1039int ERR_get_next_error_library(void)
1040 {
1041 err_fns_check();
1042 return ERRFN(get_next_lib)();
1043 }
1044
1045void ERR_set_error_data(char *data, int flags) 300void ERR_set_error_data(char *data, int flags)
1046 { 301 {
1047 ERR_STATE *es; 302 ERR_STATE *es;
@@ -1128,3 +383,34 @@ int ERR_pop_to_mark(void)
1128 es->err_flags[es->top]&=~ERR_FLAG_MARK; 383 es->err_flags[es->top]&=~ERR_FLAG_MARK;
1129 return 1; 384 return 1;
1130 } 385 }
386
387#ifdef OPENSSL_FIPS
388
389static ERR_STATE *fget_state(void)
390 {
391 static ERR_STATE fstate;
392 return &fstate;
393 }
394
395ERR_STATE *(*get_state_func)(void) = fget_state;
396void (*remove_state_func)(unsigned long pid);
397
398ERR_STATE *ERR_get_state(void)
399 {
400 return get_state_func();
401 }
402
403void int_ERR_set_state_func(ERR_STATE *(*get_func)(void),
404 void (*remove_func)(unsigned long pid))
405 {
406 get_state_func = get_func;
407 remove_state_func = remove_func;
408 }
409
410void ERR_remove_state(unsigned long pid)
411 {
412 if (remove_state_func)
413 remove_state_func(pid);
414 }
415
416#endif
diff --git a/src/lib/libcrypto/err/err.h b/src/lib/libcrypto/err/err.h
index 8d9f0da172..dcac415231 100644
--- a/src/lib/libcrypto/err/err.h
+++ b/src/lib/libcrypto/err/err.h
@@ -142,6 +142,7 @@ typedef struct err_state_st
142#define ERR_LIB_STORE 44 142#define ERR_LIB_STORE 44
143#define ERR_LIB_FIPS 45 143#define ERR_LIB_FIPS 45
144#define ERR_LIB_CMS 46 144#define ERR_LIB_CMS 46
145#define ERR_LIB_JPAKE 47
145 146
146#define ERR_LIB_USER 128 147#define ERR_LIB_USER 128
147 148
@@ -175,6 +176,7 @@ typedef struct err_state_st
175#define STOREerr(f,r) ERR_PUT_error(ERR_LIB_STORE,(f),(r),__FILE__,__LINE__) 176#define STOREerr(f,r) ERR_PUT_error(ERR_LIB_STORE,(f),(r),__FILE__,__LINE__)
176#define FIPSerr(f,r) ERR_PUT_error(ERR_LIB_FIPS,(f),(r),__FILE__,__LINE__) 177#define FIPSerr(f,r) ERR_PUT_error(ERR_LIB_FIPS,(f),(r),__FILE__,__LINE__)
177#define CMSerr(f,r) ERR_PUT_error(ERR_LIB_CMS,(f),(r),__FILE__,__LINE__) 178#define CMSerr(f,r) ERR_PUT_error(ERR_LIB_CMS,(f),(r),__FILE__,__LINE__)
179#define JPAKEerr(f,r) ERR_PUT_error(ERR_LIB_JPAKE,(f),(r),__FILE__,__LINE__)
178 180
179/* Borland C seems too stupid to be able to shift and do longs in 181/* Borland C seems too stupid to be able to shift and do longs in
180 * the pre-processor :-( */ 182 * the pre-processor :-( */
@@ -306,6 +308,12 @@ int ERR_get_next_error_library(void);
306int ERR_set_mark(void); 308int ERR_set_mark(void);
307int ERR_pop_to_mark(void); 309int ERR_pop_to_mark(void);
308 310
311#ifdef OPENSSL_FIPS
312void int_ERR_set_state_func(ERR_STATE *(*get_func)(void),
313 void (*remove_func)(unsigned long pid));
314void int_ERR_lib_init(void);
315#endif
316
309/* Already defined in ossl_typ.h */ 317/* Already defined in ossl_typ.h */
310/* typedef struct st_ERR_FNS ERR_FNS; */ 318/* typedef struct st_ERR_FNS ERR_FNS; */
311/* An application can use this function and provide the return value to loaded 319/* An application can use this function and provide the return value to loaded
diff --git a/src/lib/libcrypto/err/err_all.c b/src/lib/libcrypto/err/err_all.c
index 5813060ce2..f21a5276ed 100644
--- a/src/lib/libcrypto/err/err_all.c
+++ b/src/lib/libcrypto/err/err_all.c
@@ -94,9 +94,16 @@
94#include <openssl/ui.h> 94#include <openssl/ui.h>
95#include <openssl/ocsp.h> 95#include <openssl/ocsp.h>
96#include <openssl/err.h> 96#include <openssl/err.h>
97#ifdef OPENSSL_FIPS
98#include <openssl/fips.h>
99#endif
100
97#ifndef OPENSSL_NO_CMS 101#ifndef OPENSSL_NO_CMS
98#include <openssl/cms.h> 102#include <openssl/cms.h>
99#endif 103#endif
104#ifndef OPENSSL_NO_JPAKE
105#include <openssl/jpake.h>
106#endif
100 107
101void ERR_load_crypto_strings(void) 108void ERR_load_crypto_strings(void)
102 { 109 {
@@ -141,8 +148,14 @@ void ERR_load_crypto_strings(void)
141#endif 148#endif
142 ERR_load_OCSP_strings(); 149 ERR_load_OCSP_strings();
143 ERR_load_UI_strings(); 150 ERR_load_UI_strings();
151#ifdef OPENSSL_FIPS
152 ERR_load_FIPS_strings();
153#endif
144#ifndef OPENSSL_NO_CMS 154#ifndef OPENSSL_NO_CMS
145 ERR_load_CMS_strings(); 155 ERR_load_CMS_strings();
146#endif 156#endif
157#ifndef OPENSSL_NO_JPAKE
158 ERR_load_JPAKE_strings();
159#endif
147#endif 160#endif
148 } 161 }
diff --git a/src/lib/libcrypto/err/err_prn.c b/src/lib/libcrypto/err/err_prn.c
index 2224a901e5..4cdf342fa6 100644
--- a/src/lib/libcrypto/err/err_prn.c
+++ b/src/lib/libcrypto/err/err_prn.c
@@ -86,12 +86,7 @@ void ERR_print_errors_cb(int (*cb)(const char *str, size_t len, void *u),
86#ifndef OPENSSL_NO_FP_API 86#ifndef OPENSSL_NO_FP_API
87static int print_fp(const char *str, size_t len, void *fp) 87static int print_fp(const char *str, size_t len, void *fp)
88 { 88 {
89 BIO bio; 89 return fwrite(str, 1, len, fp);
90
91 BIO_set(&bio,BIO_s_file());
92 BIO_set_fp(&bio,fp,BIO_NOCLOSE);
93
94 return BIO_printf(&bio, "%s", str);
95 } 90 }
96void ERR_print_errors_fp(FILE *fp) 91void ERR_print_errors_fp(FILE *fp)
97 { 92 {
@@ -99,13 +94,64 @@ void ERR_print_errors_fp(FILE *fp)
99 } 94 }
100#endif 95#endif
101 96
102static int print_bio(const char *str, size_t len, void *bp) 97void ERR_error_string_n(unsigned long e, char *buf, size_t len)
103 { 98 {
104 return BIO_write((BIO *)bp, str, len); 99 char lsbuf[64], fsbuf[64], rsbuf[64];
100 const char *ls,*fs,*rs;
101 unsigned long l,f,r;
102
103 l=ERR_GET_LIB(e);
104 f=ERR_GET_FUNC(e);
105 r=ERR_GET_REASON(e);
106
107 ls=ERR_lib_error_string(e);
108 fs=ERR_func_error_string(e);
109 rs=ERR_reason_error_string(e);
110
111 if (ls == NULL)
112 BIO_snprintf(lsbuf, sizeof(lsbuf), "lib(%lu)", l);
113 if (fs == NULL)
114 BIO_snprintf(fsbuf, sizeof(fsbuf), "func(%lu)", f);
115 if (rs == NULL)
116 BIO_snprintf(rsbuf, sizeof(rsbuf), "reason(%lu)", r);
117
118 BIO_snprintf(buf, len,"error:%08lX:%s:%s:%s", e, ls?ls:lsbuf,
119 fs?fs:fsbuf, rs?rs:rsbuf);
120 if (strlen(buf) == len-1)
121 {
122 /* output may be truncated; make sure we always have 5
123 * colon-separated fields, i.e. 4 colons ... */
124#define NUM_COLONS 4
125 if (len > NUM_COLONS) /* ... if possible */
126 {
127 int i;
128 char *s = buf;
129
130 for (i = 0; i < NUM_COLONS; i++)
131 {
132 char *colon = strchr(s, ':');
133 if (colon == NULL || colon > &buf[len-1] - NUM_COLONS + i)
134 {
135 /* set colon no. i at last possible position
136 * (buf[len-1] is the terminating 0)*/
137 colon = &buf[len-1] - NUM_COLONS + i;
138 *colon = ':';
139 }
140 s = colon + 1;
141 }
142 }
143 }
105 } 144 }
106void ERR_print_errors(BIO *bp) 145
146/* BAD for multi-threading: uses a local buffer if ret == NULL */
147/* ERR_error_string_n should be used instead for ret != NULL
148 * as ERR_error_string cannot know how large the buffer is */
149char *ERR_error_string(unsigned long e, char *ret)
107 { 150 {
108 ERR_print_errors_cb(print_bio, bp); 151 static char buf[256];
109 } 152
153 if (ret == NULL) ret=buf;
154 ERR_error_string_n(e, ret, 256);
110 155
111 156 return ret;
157 }
diff --git a/src/lib/libcrypto/err/openssl.ec b/src/lib/libcrypto/err/openssl.ec
index 1938f081ac..868826624d 100644
--- a/src/lib/libcrypto/err/openssl.ec
+++ b/src/lib/libcrypto/err/openssl.ec
@@ -31,7 +31,9 @@ L COMP crypto/comp/comp.h crypto/comp/comp_err.c
31L ECDSA crypto/ecdsa/ecdsa.h crypto/ecdsa/ecs_err.c 31L ECDSA crypto/ecdsa/ecdsa.h crypto/ecdsa/ecs_err.c
32L ECDH crypto/ecdh/ecdh.h crypto/ecdh/ech_err.c 32L ECDH crypto/ecdh/ecdh.h crypto/ecdh/ech_err.c
33L STORE crypto/store/store.h crypto/store/str_err.c 33L STORE crypto/store/store.h crypto/store/str_err.c
34L FIPS fips/fips.h crypto/fips_err.h
34L CMS crypto/cms/cms.h crypto/cms/cms_err.c 35L CMS crypto/cms/cms.h crypto/cms/cms_err.c
36L JPAKE crypto/jpake/jpake.h crypto/jpake/jpake_err.c
35 37
36# additional header files to be scanned for function names 38# additional header files to be scanned for function names
37L NONE crypto/x509/x509_vfy.h NONE 39L NONE crypto/x509/x509_vfy.h NONE
diff --git a/src/lib/libcrypto/evp/Makefile b/src/lib/libcrypto/evp/Makefile
index 9de56dc03d..c204f84c1d 100644
--- a/src/lib/libcrypto/evp/Makefile
+++ b/src/lib/libcrypto/evp/Makefile
@@ -18,10 +18,10 @@ TESTDATA=evptests.txt
18APPS= 18APPS=
19 19
20LIB=$(TOP)/libcrypto.a 20LIB=$(TOP)/libcrypto.a
21LIBSRC= encode.c digest.c evp_enc.c evp_key.c evp_acnf.c \ 21LIBSRC= encode.c digest.c dig_eng.c evp_enc.c evp_key.c evp_acnf.c evp_cnf.c \
22 e_des.c e_bf.c e_idea.c e_des3.c e_camellia.c\ 22 e_des.c e_bf.c e_idea.c e_des3.c e_camellia.c\
23 e_rc4.c e_aes.c names.c e_seed.c \ 23 e_rc4.c e_aes.c names.c e_seed.c \
24 e_xcbc_d.c e_rc2.c e_cast.c e_rc5.c \ 24 e_xcbc_d.c e_rc2.c e_cast.c e_rc5.c enc_min.c \
25 m_null.c m_md2.c m_md4.c m_md5.c m_sha.c m_sha1.c \ 25 m_null.c m_md2.c m_md4.c m_md5.c m_sha.c m_sha1.c \
26 m_dss.c m_dss1.c m_mdc2.c m_ripemd.c m_ecdsa.c\ 26 m_dss.c m_dss1.c m_mdc2.c m_ripemd.c m_ecdsa.c\
27 p_open.c p_seal.c p_sign.c p_verify.c p_lib.c p_enc.c p_dec.c \ 27 p_open.c p_seal.c p_sign.c p_verify.c p_lib.c p_enc.c p_dec.c \
@@ -30,10 +30,10 @@ LIBSRC= encode.c digest.c evp_enc.c evp_key.c evp_acnf.c \
30 evp_pkey.c evp_pbe.c p5_crpt.c p5_crpt2.c \ 30 evp_pkey.c evp_pbe.c p5_crpt.c p5_crpt2.c \
31 e_old.c 31 e_old.c
32 32
33LIBOBJ= encode.o digest.o evp_enc.o evp_key.o evp_acnf.o \ 33LIBOBJ= encode.o digest.o dig_eng.o evp_enc.o evp_key.o evp_acnf.o evp_cnf.o \
34 e_des.o e_bf.o e_idea.o e_des3.o e_camellia.o\ 34 e_des.o e_bf.o e_idea.o e_des3.o e_camellia.o\
35 e_rc4.o e_aes.o names.o e_seed.o \ 35 e_rc4.o e_aes.o names.o e_seed.o \
36 e_xcbc_d.o e_rc2.o e_cast.o e_rc5.o \ 36 e_xcbc_d.o e_rc2.o e_cast.o e_rc5.o enc_min.o \
37 m_null.o m_md2.o m_md4.o m_md5.o m_sha.o m_sha1.o \ 37 m_null.o m_md2.o m_md4.o m_md5.o m_sha.o m_sha1.o \
38 m_dss.o m_dss1.o m_mdc2.o m_ripemd.o m_ecdsa.o\ 38 m_dss.o m_dss1.o m_mdc2.o m_ripemd.o m_ecdsa.o\
39 p_open.o p_seal.o p_sign.o p_verify.o p_lib.o p_enc.o p_dec.o \ 39 p_open.o p_seal.o p_sign.o p_verify.o p_lib.o p_enc.o p_dec.o \
@@ -55,7 +55,7 @@ top:
55all: lib 55all: lib
56 56
57lib: $(LIBOBJ) 57lib: $(LIBOBJ)
58 $(AR) $(LIB) $(LIBOBJ) 58 $(ARX) $(LIB) $(LIBOBJ)
59 $(RANLIB) $(LIB) || echo Never mind. 59 $(RANLIB) $(LIB) || echo Never mind.
60 @touch lib 60 @touch lib
61 61
@@ -101,177 +101,201 @@ bio_b64.o: ../../e_os.h ../../include/openssl/asn1.h
101bio_b64.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h 101bio_b64.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
102bio_b64.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h 102bio_b64.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
103bio_b64.o: ../../include/openssl/err.h ../../include/openssl/evp.h 103bio_b64.o: ../../include/openssl/err.h ../../include/openssl/evp.h
104bio_b64.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h 104bio_b64.o: ../../include/openssl/fips.h ../../include/openssl/lhash.h
105bio_b64.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h 105bio_b64.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
106bio_b64.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h 106bio_b64.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
107bio_b64.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h 107bio_b64.o: ../../include/openssl/ossl_typ.h ../../include/openssl/safestack.h
108bio_b64.o: ../../include/openssl/symhacks.h ../cryptlib.h bio_b64.c 108bio_b64.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
109bio_b64.o: ../cryptlib.h bio_b64.c
109bio_enc.o: ../../e_os.h ../../include/openssl/asn1.h 110bio_enc.o: ../../e_os.h ../../include/openssl/asn1.h
110bio_enc.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h 111bio_enc.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
111bio_enc.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h 112bio_enc.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
112bio_enc.o: ../../include/openssl/err.h ../../include/openssl/evp.h 113bio_enc.o: ../../include/openssl/err.h ../../include/openssl/evp.h
113bio_enc.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h 114bio_enc.o: ../../include/openssl/fips.h ../../include/openssl/lhash.h
114bio_enc.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h 115bio_enc.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
115bio_enc.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h 116bio_enc.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
116bio_enc.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h 117bio_enc.o: ../../include/openssl/ossl_typ.h ../../include/openssl/safestack.h
117bio_enc.o: ../../include/openssl/symhacks.h ../cryptlib.h bio_enc.c 118bio_enc.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
119bio_enc.o: ../cryptlib.h bio_enc.c
118bio_md.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h 120bio_md.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h
119bio_md.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 121bio_md.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
120bio_md.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h 122bio_md.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
121bio_md.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h 123bio_md.o: ../../include/openssl/evp.h ../../include/openssl/fips.h
122bio_md.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h 124bio_md.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
123bio_md.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h 125bio_md.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
124bio_md.o: ../../include/openssl/ossl_typ.h ../../include/openssl/safestack.h 126bio_md.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
125bio_md.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 127bio_md.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
126bio_md.o: ../cryptlib.h bio_md.c 128bio_md.o: ../../include/openssl/symhacks.h ../cryptlib.h bio_md.c
127bio_ok.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h 129bio_ok.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h
128bio_ok.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 130bio_ok.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
129bio_ok.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h 131bio_ok.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
130bio_ok.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h 132bio_ok.o: ../../include/openssl/evp.h ../../include/openssl/fips.h
131bio_ok.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h 133bio_ok.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
132bio_ok.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h 134bio_ok.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
133bio_ok.o: ../../include/openssl/ossl_typ.h ../../include/openssl/rand.h 135bio_ok.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
134bio_ok.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h 136bio_ok.o: ../../include/openssl/rand.h ../../include/openssl/safestack.h
135bio_ok.o: ../../include/openssl/symhacks.h ../cryptlib.h bio_ok.c 137bio_ok.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
138bio_ok.o: ../cryptlib.h bio_ok.c
136c_all.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h 139c_all.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h
137c_all.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 140c_all.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
138c_all.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h 141c_all.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h
139c_all.o: ../../include/openssl/ecdh.h ../../include/openssl/ecdsa.h 142c_all.o: ../../include/openssl/ecdh.h ../../include/openssl/ecdsa.h
140c_all.o: ../../include/openssl/engine.h ../../include/openssl/err.h 143c_all.o: ../../include/openssl/engine.h ../../include/openssl/err.h
141c_all.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h 144c_all.o: ../../include/openssl/evp.h ../../include/openssl/fips.h
142c_all.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h 145c_all.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
143c_all.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h 146c_all.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
144c_all.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h 147c_all.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
145c_all.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h 148c_all.o: ../../include/openssl/pkcs7.h ../../include/openssl/safestack.h
146c_all.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 149c_all.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
147c_all.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h 150c_all.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h
148c_all.o: ../cryptlib.h c_all.c 151c_all.o: ../../include/openssl/x509_vfy.h ../cryptlib.h c_all.c
149c_allc.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h 152c_allc.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h
150c_allc.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 153c_allc.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
151c_allc.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h 154c_allc.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h
152c_allc.o: ../../include/openssl/ecdh.h ../../include/openssl/ecdsa.h 155c_allc.o: ../../include/openssl/ecdh.h ../../include/openssl/ecdsa.h
153c_allc.o: ../../include/openssl/err.h ../../include/openssl/evp.h 156c_allc.o: ../../include/openssl/err.h ../../include/openssl/evp.h
154c_allc.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h 157c_allc.o: ../../include/openssl/fips.h ../../include/openssl/lhash.h
155c_allc.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h 158c_allc.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
156c_allc.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h 159c_allc.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
157c_allc.o: ../../include/openssl/pkcs12.h ../../include/openssl/pkcs7.h 160c_allc.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs12.h
158c_allc.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h 161c_allc.o: ../../include/openssl/pkcs7.h ../../include/openssl/safestack.h
159c_allc.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 162c_allc.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
160c_allc.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h 163c_allc.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h
161c_allc.o: ../cryptlib.h c_allc.c 164c_allc.o: ../../include/openssl/x509_vfy.h ../cryptlib.h c_allc.c
162c_alld.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h 165c_alld.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h
163c_alld.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 166c_alld.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
164c_alld.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h 167c_alld.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h
165c_alld.o: ../../include/openssl/ecdh.h ../../include/openssl/ecdsa.h 168c_alld.o: ../../include/openssl/ecdh.h ../../include/openssl/ecdsa.h
166c_alld.o: ../../include/openssl/err.h ../../include/openssl/evp.h 169c_alld.o: ../../include/openssl/err.h ../../include/openssl/evp.h
167c_alld.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h 170c_alld.o: ../../include/openssl/fips.h ../../include/openssl/lhash.h
168c_alld.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h 171c_alld.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
169c_alld.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h 172c_alld.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
170c_alld.o: ../../include/openssl/pkcs12.h ../../include/openssl/pkcs7.h 173c_alld.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs12.h
171c_alld.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h 174c_alld.o: ../../include/openssl/pkcs7.h ../../include/openssl/safestack.h
172c_alld.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 175c_alld.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
173c_alld.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h 176c_alld.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h
174c_alld.o: ../cryptlib.h c_alld.c 177c_alld.o: ../../include/openssl/x509_vfy.h ../cryptlib.h c_alld.c
178dig_eng.o: ../../e_os.h ../../include/openssl/asn1.h
179dig_eng.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
180dig_eng.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
181dig_eng.o: ../../include/openssl/ec.h ../../include/openssl/ecdh.h
182dig_eng.o: ../../include/openssl/ecdsa.h ../../include/openssl/engine.h
183dig_eng.o: ../../include/openssl/err.h ../../include/openssl/evp.h
184dig_eng.o: ../../include/openssl/fips.h ../../include/openssl/lhash.h
185dig_eng.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
186dig_eng.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
187dig_eng.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h
188dig_eng.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
189dig_eng.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
190dig_eng.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
191dig_eng.o: ../cryptlib.h dig_eng.c evp_locl.h
175digest.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h 192digest.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h
176digest.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 193digest.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
177digest.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h 194digest.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h
178digest.o: ../../include/openssl/ecdh.h ../../include/openssl/ecdsa.h 195digest.o: ../../include/openssl/ecdh.h ../../include/openssl/ecdsa.h
179digest.o: ../../include/openssl/engine.h ../../include/openssl/err.h 196digest.o: ../../include/openssl/engine.h ../../include/openssl/err.h
180digest.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h 197digest.o: ../../include/openssl/evp.h ../../include/openssl/fips.h
181digest.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h 198digest.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
182digest.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h 199digest.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
183digest.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h 200digest.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
184digest.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h 201digest.o: ../../include/openssl/pkcs7.h ../../include/openssl/safestack.h
185digest.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 202digest.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
186digest.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h 203digest.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h
187digest.o: ../cryptlib.h digest.c 204digest.o: ../../include/openssl/x509_vfy.h ../cryptlib.h digest.c evp_locl.h
188e_aes.o: ../../include/openssl/aes.h ../../include/openssl/asn1.h 205e_aes.o: ../../include/openssl/aes.h ../../include/openssl/asn1.h
189e_aes.o: ../../include/openssl/bio.h ../../include/openssl/crypto.h 206e_aes.o: ../../include/openssl/bio.h ../../include/openssl/crypto.h
190e_aes.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h 207e_aes.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
191e_aes.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h 208e_aes.o: ../../include/openssl/evp.h ../../include/openssl/fips.h
192e_aes.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h 209e_aes.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
193e_aes.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h 210e_aes.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
194e_aes.o: ../../include/openssl/ossl_typ.h ../../include/openssl/safestack.h 211e_aes.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
195e_aes.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h e_aes.c 212e_aes.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
196e_aes.o: evp_locl.h 213e_aes.o: ../../include/openssl/symhacks.h e_aes.c evp_locl.h
197e_bf.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h 214e_bf.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h
198e_bf.o: ../../include/openssl/blowfish.h ../../include/openssl/buffer.h 215e_bf.o: ../../include/openssl/blowfish.h ../../include/openssl/buffer.h
199e_bf.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h 216e_bf.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
200e_bf.o: ../../include/openssl/err.h ../../include/openssl/evp.h 217e_bf.o: ../../include/openssl/err.h ../../include/openssl/evp.h
201e_bf.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h 218e_bf.o: ../../include/openssl/fips.h ../../include/openssl/lhash.h
202e_bf.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h 219e_bf.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
203e_bf.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h 220e_bf.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
204e_bf.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h 221e_bf.o: ../../include/openssl/ossl_typ.h ../../include/openssl/safestack.h
205e_bf.o: ../../include/openssl/symhacks.h ../cryptlib.h e_bf.c evp_locl.h 222e_bf.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
223e_bf.o: ../cryptlib.h e_bf.c evp_locl.h
206e_camellia.o: ../../include/openssl/opensslconf.h e_camellia.c 224e_camellia.o: ../../include/openssl/opensslconf.h e_camellia.c
207e_cast.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h 225e_cast.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h
208e_cast.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h 226e_cast.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
209e_cast.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h 227e_cast.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
210e_cast.o: ../../include/openssl/err.h ../../include/openssl/evp.h 228e_cast.o: ../../include/openssl/err.h ../../include/openssl/evp.h
211e_cast.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h 229e_cast.o: ../../include/openssl/fips.h ../../include/openssl/lhash.h
212e_cast.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h 230e_cast.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
213e_cast.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h 231e_cast.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
214e_cast.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h 232e_cast.o: ../../include/openssl/ossl_typ.h ../../include/openssl/safestack.h
215e_cast.o: ../../include/openssl/symhacks.h ../cryptlib.h e_cast.c evp_locl.h 233e_cast.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
234e_cast.o: ../cryptlib.h e_cast.c evp_locl.h
216e_des.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h 235e_des.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h
217e_des.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 236e_des.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
218e_des.o: ../../include/openssl/des.h ../../include/openssl/des_old.h 237e_des.o: ../../include/openssl/des.h ../../include/openssl/des_old.h
219e_des.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h 238e_des.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
220e_des.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h 239e_des.o: ../../include/openssl/evp.h ../../include/openssl/fips.h
221e_des.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h 240e_des.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
222e_des.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h 241e_des.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
223e_des.o: ../../include/openssl/ossl_typ.h ../../include/openssl/rand.h 242e_des.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
224e_des.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h 243e_des.o: ../../include/openssl/rand.h ../../include/openssl/safestack.h
225e_des.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h 244e_des.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
226e_des.o: ../../include/openssl/ui_compat.h ../cryptlib.h e_des.c evp_locl.h 245e_des.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
246e_des.o: ../cryptlib.h e_des.c evp_locl.h
227e_des3.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h 247e_des3.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h
228e_des3.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 248e_des3.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
229e_des3.o: ../../include/openssl/des.h ../../include/openssl/des_old.h 249e_des3.o: ../../include/openssl/des.h ../../include/openssl/des_old.h
230e_des3.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h 250e_des3.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
231e_des3.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h 251e_des3.o: ../../include/openssl/evp.h ../../include/openssl/fips.h
232e_des3.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h 252e_des3.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
233e_des3.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h 253e_des3.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
234e_des3.o: ../../include/openssl/ossl_typ.h ../../include/openssl/rand.h 254e_des3.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
235e_des3.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h 255e_des3.o: ../../include/openssl/rand.h ../../include/openssl/safestack.h
236e_des3.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h 256e_des3.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
237e_des3.o: ../../include/openssl/ui_compat.h ../cryptlib.h e_des3.c evp_locl.h 257e_des3.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
258e_des3.o: ../cryptlib.h e_des3.c evp_locl.h
238e_idea.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h 259e_idea.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h
239e_idea.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 260e_idea.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
240e_idea.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h 261e_idea.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
241e_idea.o: ../../include/openssl/evp.h ../../include/openssl/idea.h 262e_idea.o: ../../include/openssl/evp.h ../../include/openssl/fips.h
242e_idea.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h 263e_idea.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h
243e_idea.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h 264e_idea.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
244e_idea.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h 265e_idea.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
245e_idea.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h 266e_idea.o: ../../include/openssl/ossl_typ.h ../../include/openssl/safestack.h
246e_idea.o: ../../include/openssl/symhacks.h ../cryptlib.h e_idea.c evp_locl.h 267e_idea.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
268e_idea.o: ../cryptlib.h e_idea.c evp_locl.h
247e_null.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h 269e_null.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h
248e_null.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 270e_null.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
249e_null.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h 271e_null.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
250e_null.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h 272e_null.o: ../../include/openssl/evp.h ../../include/openssl/fips.h
251e_null.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h 273e_null.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
252e_null.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h 274e_null.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
253e_null.o: ../../include/openssl/ossl_typ.h ../../include/openssl/safestack.h 275e_null.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
254e_null.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 276e_null.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
255e_null.o: ../cryptlib.h e_null.c 277e_null.o: ../../include/openssl/symhacks.h ../cryptlib.h e_null.c
256e_old.o: e_old.c 278e_old.o: e_old.c
257e_rc2.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h 279e_rc2.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h
258e_rc2.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 280e_rc2.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
259e_rc2.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h 281e_rc2.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
260e_rc2.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h 282e_rc2.o: ../../include/openssl/evp.h ../../include/openssl/fips.h
261e_rc2.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h 283e_rc2.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
262e_rc2.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h 284e_rc2.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
263e_rc2.o: ../../include/openssl/ossl_typ.h ../../include/openssl/rc2.h 285e_rc2.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
264e_rc2.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h 286e_rc2.o: ../../include/openssl/rc2.h ../../include/openssl/safestack.h
265e_rc2.o: ../../include/openssl/symhacks.h ../cryptlib.h e_rc2.c evp_locl.h 287e_rc2.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
288e_rc2.o: ../cryptlib.h e_rc2.c evp_locl.h
266e_rc4.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h 289e_rc4.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h
267e_rc4.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 290e_rc4.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
268e_rc4.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h 291e_rc4.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
269e_rc4.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h 292e_rc4.o: ../../include/openssl/evp.h ../../include/openssl/fips.h
270e_rc4.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h 293e_rc4.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
271e_rc4.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h 294e_rc4.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
272e_rc4.o: ../../include/openssl/ossl_typ.h ../../include/openssl/rc4.h 295e_rc4.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
273e_rc4.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h 296e_rc4.o: ../../include/openssl/rc4.h ../../include/openssl/safestack.h
274e_rc4.o: ../../include/openssl/symhacks.h ../cryptlib.h e_rc4.c 297e_rc4.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
298e_rc4.o: ../cryptlib.h e_rc4.c evp_locl.h
275e_rc5.o: ../../e_os.h ../../include/openssl/bio.h 299e_rc5.o: ../../e_os.h ../../include/openssl/bio.h
276e_rc5.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 300e_rc5.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
277e_rc5.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h 301e_rc5.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
@@ -282,107 +306,141 @@ e_rc5.o: ../../include/openssl/symhacks.h ../cryptlib.h e_rc5.c
282e_seed.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h 306e_seed.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
283e_seed.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h 307e_seed.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
284e_seed.o: ../../include/openssl/err.h ../../include/openssl/evp.h 308e_seed.o: ../../include/openssl/err.h ../../include/openssl/evp.h
285e_seed.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h 309e_seed.o: ../../include/openssl/fips.h ../../include/openssl/lhash.h
286e_seed.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h 310e_seed.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
287e_seed.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h 311e_seed.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
288e_seed.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h 312e_seed.o: ../../include/openssl/ossl_typ.h ../../include/openssl/safestack.h
289e_seed.o: ../../include/openssl/symhacks.h e_seed.c 313e_seed.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
314e_seed.o: e_seed.c
290e_xcbc_d.o: ../../e_os.h ../../include/openssl/asn1.h 315e_xcbc_d.o: ../../e_os.h ../../include/openssl/asn1.h
291e_xcbc_d.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h 316e_xcbc_d.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
292e_xcbc_d.o: ../../include/openssl/crypto.h ../../include/openssl/des.h 317e_xcbc_d.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
293e_xcbc_d.o: ../../include/openssl/des_old.h ../../include/openssl/e_os2.h 318e_xcbc_d.o: ../../include/openssl/des_old.h ../../include/openssl/e_os2.h
294e_xcbc_d.o: ../../include/openssl/err.h ../../include/openssl/evp.h 319e_xcbc_d.o: ../../include/openssl/err.h ../../include/openssl/evp.h
295e_xcbc_d.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h 320e_xcbc_d.o: ../../include/openssl/fips.h ../../include/openssl/lhash.h
296e_xcbc_d.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h 321e_xcbc_d.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
322e_xcbc_d.o: ../../include/openssl/opensslconf.h
297e_xcbc_d.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h 323e_xcbc_d.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
298e_xcbc_d.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h 324e_xcbc_d.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
299e_xcbc_d.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h 325e_xcbc_d.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
300e_xcbc_d.o: ../../include/openssl/ui_compat.h ../cryptlib.h e_xcbc_d.c 326e_xcbc_d.o: ../../include/openssl/ui_compat.h ../cryptlib.h e_xcbc_d.c
327enc_min.o: ../../e_os.h ../../include/openssl/asn1.h
328enc_min.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
329enc_min.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
330enc_min.o: ../../include/openssl/ec.h ../../include/openssl/ecdh.h
331enc_min.o: ../../include/openssl/ecdsa.h ../../include/openssl/engine.h
332enc_min.o: ../../include/openssl/err.h ../../include/openssl/evp.h
333enc_min.o: ../../include/openssl/fips.h ../../include/openssl/lhash.h
334enc_min.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
335enc_min.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
336enc_min.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h
337enc_min.o: ../../include/openssl/rand.h ../../include/openssl/safestack.h
338enc_min.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
339enc_min.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h
340enc_min.o: ../../include/openssl/x509_vfy.h ../cryptlib.h enc_min.c evp_locl.h
301encode.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h 341encode.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h
302encode.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 342encode.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
303encode.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h 343encode.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
304encode.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h 344encode.o: ../../include/openssl/evp.h ../../include/openssl/fips.h
305encode.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h 345encode.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
306encode.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h 346encode.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
307encode.o: ../../include/openssl/ossl_typ.h ../../include/openssl/safestack.h 347encode.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
308encode.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 348encode.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
309encode.o: ../cryptlib.h encode.c 349encode.o: ../../include/openssl/symhacks.h ../cryptlib.h encode.c
310evp_acnf.o: ../../e_os.h ../../include/openssl/asn1.h 350evp_acnf.o: ../../e_os.h ../../include/openssl/asn1.h
311evp_acnf.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h 351evp_acnf.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
312evp_acnf.o: ../../include/openssl/conf.h ../../include/openssl/crypto.h 352evp_acnf.o: ../../include/openssl/conf.h ../../include/openssl/crypto.h
313evp_acnf.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h 353evp_acnf.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
314evp_acnf.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h 354evp_acnf.o: ../../include/openssl/evp.h ../../include/openssl/fips.h
315evp_acnf.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h 355evp_acnf.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
316evp_acnf.o: ../../include/openssl/opensslconf.h 356evp_acnf.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
317evp_acnf.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h 357evp_acnf.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
318evp_acnf.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h 358evp_acnf.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
319evp_acnf.o: ../../include/openssl/symhacks.h ../cryptlib.h evp_acnf.c 359evp_acnf.o: ../../include/openssl/symhacks.h ../cryptlib.h evp_acnf.c
360evp_cnf.o: ../../e_os.h ../../include/openssl/asn1.h
361evp_cnf.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
362evp_cnf.o: ../../include/openssl/conf.h ../../include/openssl/crypto.h
363evp_cnf.o: ../../include/openssl/dso.h ../../include/openssl/e_os2.h
364evp_cnf.o: ../../include/openssl/ec.h ../../include/openssl/ecdh.h
365evp_cnf.o: ../../include/openssl/ecdsa.h ../../include/openssl/err.h
366evp_cnf.o: ../../include/openssl/evp.h ../../include/openssl/fips.h
367evp_cnf.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
368evp_cnf.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
369evp_cnf.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
370evp_cnf.o: ../../include/openssl/pkcs7.h ../../include/openssl/safestack.h
371evp_cnf.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
372evp_cnf.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h
373evp_cnf.o: ../../include/openssl/x509_vfy.h ../../include/openssl/x509v3.h
374evp_cnf.o: ../cryptlib.h evp_cnf.c
320evp_enc.o: ../../e_os.h ../../include/openssl/asn1.h 375evp_enc.o: ../../e_os.h ../../include/openssl/asn1.h
321evp_enc.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h 376evp_enc.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
322evp_enc.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h 377evp_enc.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
323evp_enc.o: ../../include/openssl/ec.h ../../include/openssl/ecdh.h 378evp_enc.o: ../../include/openssl/ec.h ../../include/openssl/ecdh.h
324evp_enc.o: ../../include/openssl/ecdsa.h ../../include/openssl/engine.h 379evp_enc.o: ../../include/openssl/ecdsa.h ../../include/openssl/engine.h
325evp_enc.o: ../../include/openssl/err.h ../../include/openssl/evp.h 380evp_enc.o: ../../include/openssl/err.h ../../include/openssl/evp.h
326evp_enc.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h 381evp_enc.o: ../../include/openssl/fips.h ../../include/openssl/lhash.h
327evp_enc.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h 382evp_enc.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
328evp_enc.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h 383evp_enc.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
329evp_enc.o: ../../include/openssl/pkcs7.h ../../include/openssl/rand.h 384evp_enc.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h
330evp_enc.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h 385evp_enc.o: ../../include/openssl/rand.h ../../include/openssl/safestack.h
331evp_enc.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 386evp_enc.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
332evp_enc.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h 387evp_enc.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h
333evp_enc.o: ../cryptlib.h evp_enc.c evp_locl.h 388evp_enc.o: ../../include/openssl/x509_vfy.h ../cryptlib.h evp_enc.c evp_locl.h
334evp_err.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h 389evp_err.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
335evp_err.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h 390evp_err.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
336evp_err.o: ../../include/openssl/err.h ../../include/openssl/evp.h 391evp_err.o: ../../include/openssl/err.h ../../include/openssl/evp.h
337evp_err.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h 392evp_err.o: ../../include/openssl/fips.h ../../include/openssl/lhash.h
338evp_err.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h 393evp_err.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
339evp_err.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h 394evp_err.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
340evp_err.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h 395evp_err.o: ../../include/openssl/ossl_typ.h ../../include/openssl/safestack.h
341evp_err.o: ../../include/openssl/symhacks.h evp_err.c 396evp_err.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
397evp_err.o: evp_err.c
342evp_key.o: ../../e_os.h ../../include/openssl/asn1.h 398evp_key.o: ../../e_os.h ../../include/openssl/asn1.h
343evp_key.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h 399evp_key.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
344evp_key.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h 400evp_key.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
345evp_key.o: ../../include/openssl/ec.h ../../include/openssl/ecdh.h 401evp_key.o: ../../include/openssl/ec.h ../../include/openssl/ecdh.h
346evp_key.o: ../../include/openssl/ecdsa.h ../../include/openssl/err.h 402evp_key.o: ../../include/openssl/ecdsa.h ../../include/openssl/err.h
347evp_key.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h 403evp_key.o: ../../include/openssl/evp.h ../../include/openssl/fips.h
348evp_key.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h 404evp_key.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
349evp_key.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h 405evp_key.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
350evp_key.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h 406evp_key.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
351evp_key.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h 407evp_key.o: ../../include/openssl/pkcs7.h ../../include/openssl/safestack.h
352evp_key.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 408evp_key.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
353evp_key.o: ../../include/openssl/ui.h ../../include/openssl/x509.h 409evp_key.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
354evp_key.o: ../../include/openssl/x509_vfy.h ../cryptlib.h evp_key.c 410evp_key.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
411evp_key.o: ../cryptlib.h evp_key.c
355evp_lib.o: ../../e_os.h ../../include/openssl/asn1.h 412evp_lib.o: ../../e_os.h ../../include/openssl/asn1.h
356evp_lib.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h 413evp_lib.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
357evp_lib.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h 414evp_lib.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
358evp_lib.o: ../../include/openssl/err.h ../../include/openssl/evp.h 415evp_lib.o: ../../include/openssl/err.h ../../include/openssl/evp.h
359evp_lib.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h 416evp_lib.o: ../../include/openssl/fips.h ../../include/openssl/lhash.h
360evp_lib.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h 417evp_lib.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
361evp_lib.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h 418evp_lib.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
362evp_lib.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h 419evp_lib.o: ../../include/openssl/ossl_typ.h ../../include/openssl/safestack.h
363evp_lib.o: ../../include/openssl/symhacks.h ../cryptlib.h evp_lib.c 420evp_lib.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
421evp_lib.o: ../cryptlib.h evp_lib.c
364evp_pbe.o: ../../e_os.h ../../include/openssl/asn1.h 422evp_pbe.o: ../../e_os.h ../../include/openssl/asn1.h
365evp_pbe.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h 423evp_pbe.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
366evp_pbe.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h 424evp_pbe.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
367evp_pbe.o: ../../include/openssl/ec.h ../../include/openssl/ecdh.h 425evp_pbe.o: ../../include/openssl/ec.h ../../include/openssl/ecdh.h
368evp_pbe.o: ../../include/openssl/ecdsa.h ../../include/openssl/err.h 426evp_pbe.o: ../../include/openssl/ecdsa.h ../../include/openssl/err.h
369evp_pbe.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h 427evp_pbe.o: ../../include/openssl/evp.h ../../include/openssl/fips.h
370evp_pbe.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h 428evp_pbe.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
371evp_pbe.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h 429evp_pbe.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
372evp_pbe.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h 430evp_pbe.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
373evp_pbe.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h 431evp_pbe.o: ../../include/openssl/pkcs7.h ../../include/openssl/safestack.h
374evp_pbe.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 432evp_pbe.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
375evp_pbe.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h 433evp_pbe.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h
376evp_pbe.o: ../cryptlib.h evp_pbe.c 434evp_pbe.o: ../../include/openssl/x509_vfy.h ../cryptlib.h evp_pbe.c
377evp_pkey.o: ../../e_os.h ../../include/openssl/asn1.h 435evp_pkey.o: ../../e_os.h ../../include/openssl/asn1.h
378evp_pkey.o: ../../include/openssl/bio.h ../../include/openssl/bn.h 436evp_pkey.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
379evp_pkey.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 437evp_pkey.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
380evp_pkey.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h 438evp_pkey.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
381evp_pkey.o: ../../include/openssl/ec.h ../../include/openssl/ecdh.h 439evp_pkey.o: ../../include/openssl/ec.h ../../include/openssl/ecdh.h
382evp_pkey.o: ../../include/openssl/ecdsa.h ../../include/openssl/err.h 440evp_pkey.o: ../../include/openssl/ecdsa.h ../../include/openssl/err.h
383evp_pkey.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h 441evp_pkey.o: ../../include/openssl/evp.h ../../include/openssl/fips.h
384evp_pkey.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h 442evp_pkey.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
385evp_pkey.o: ../../include/openssl/opensslconf.h 443evp_pkey.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
386evp_pkey.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h 444evp_pkey.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
387evp_pkey.o: ../../include/openssl/pkcs7.h ../../include/openssl/rand.h 445evp_pkey.o: ../../include/openssl/pkcs7.h ../../include/openssl/rand.h
388evp_pkey.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h 446evp_pkey.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
@@ -394,106 +452,110 @@ m_dss.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
394m_dss.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h 452m_dss.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
395m_dss.o: ../../include/openssl/ec.h ../../include/openssl/ecdh.h 453m_dss.o: ../../include/openssl/ec.h ../../include/openssl/ecdh.h
396m_dss.o: ../../include/openssl/ecdsa.h ../../include/openssl/err.h 454m_dss.o: ../../include/openssl/ecdsa.h ../../include/openssl/err.h
397m_dss.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h 455m_dss.o: ../../include/openssl/evp.h ../../include/openssl/fips.h
398m_dss.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h 456m_dss.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
399m_dss.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h 457m_dss.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
400m_dss.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h 458m_dss.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
401m_dss.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h 459m_dss.o: ../../include/openssl/pkcs7.h ../../include/openssl/safestack.h
402m_dss.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 460m_dss.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
403m_dss.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h 461m_dss.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h
404m_dss.o: ../cryptlib.h m_dss.c 462m_dss.o: ../../include/openssl/x509_vfy.h ../cryptlib.h m_dss.c
405m_dss1.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h 463m_dss1.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h
406m_dss1.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 464m_dss1.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
407m_dss1.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h 465m_dss1.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
408m_dss1.o: ../../include/openssl/ec.h ../../include/openssl/ecdh.h 466m_dss1.o: ../../include/openssl/ec.h ../../include/openssl/ecdh.h
409m_dss1.o: ../../include/openssl/ecdsa.h ../../include/openssl/err.h 467m_dss1.o: ../../include/openssl/ecdsa.h ../../include/openssl/err.h
410m_dss1.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h 468m_dss1.o: ../../include/openssl/evp.h ../../include/openssl/fips.h
411m_dss1.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h 469m_dss1.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
412m_dss1.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h 470m_dss1.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
413m_dss1.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h 471m_dss1.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
414m_dss1.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h 472m_dss1.o: ../../include/openssl/pkcs7.h ../../include/openssl/safestack.h
415m_dss1.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 473m_dss1.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
416m_dss1.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h 474m_dss1.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h
417m_dss1.o: ../cryptlib.h m_dss1.c 475m_dss1.o: ../../include/openssl/x509_vfy.h ../cryptlib.h m_dss1.c
418m_ecdsa.o: ../../e_os.h ../../include/openssl/asn1.h 476m_ecdsa.o: ../../e_os.h ../../include/openssl/asn1.h
419m_ecdsa.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h 477m_ecdsa.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
420m_ecdsa.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h 478m_ecdsa.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
421m_ecdsa.o: ../../include/openssl/ec.h ../../include/openssl/ecdh.h 479m_ecdsa.o: ../../include/openssl/ec.h ../../include/openssl/ecdh.h
422m_ecdsa.o: ../../include/openssl/ecdsa.h ../../include/openssl/err.h 480m_ecdsa.o: ../../include/openssl/ecdsa.h ../../include/openssl/err.h
423m_ecdsa.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h 481m_ecdsa.o: ../../include/openssl/evp.h ../../include/openssl/fips.h
424m_ecdsa.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h 482m_ecdsa.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
425m_ecdsa.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h 483m_ecdsa.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
426m_ecdsa.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h 484m_ecdsa.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
427m_ecdsa.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h 485m_ecdsa.o: ../../include/openssl/pkcs7.h ../../include/openssl/safestack.h
428m_ecdsa.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 486m_ecdsa.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
429m_ecdsa.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h 487m_ecdsa.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h
430m_ecdsa.o: ../cryptlib.h m_ecdsa.c 488m_ecdsa.o: ../../include/openssl/x509_vfy.h ../cryptlib.h m_ecdsa.c
431m_md2.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h 489m_md2.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h
432m_md2.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 490m_md2.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
433m_md2.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h 491m_md2.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h
434m_md2.o: ../../include/openssl/ecdh.h ../../include/openssl/ecdsa.h 492m_md2.o: ../../include/openssl/ecdh.h ../../include/openssl/ecdsa.h
435m_md2.o: ../../include/openssl/err.h ../../include/openssl/evp.h 493m_md2.o: ../../include/openssl/err.h ../../include/openssl/evp.h
436m_md2.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h 494m_md2.o: ../../include/openssl/fips.h ../../include/openssl/lhash.h
437m_md2.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h 495m_md2.o: ../../include/openssl/md2.h ../../include/openssl/obj_mac.h
438m_md2.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h 496m_md2.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
439m_md2.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h 497m_md2.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
440m_md2.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h 498m_md2.o: ../../include/openssl/pkcs7.h ../../include/openssl/rsa.h
441m_md2.o: ../../include/openssl/sha.h ../../include/openssl/stack.h 499m_md2.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
442m_md2.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h 500m_md2.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
443m_md2.o: ../../include/openssl/x509_vfy.h ../cryptlib.h m_md2.c 501m_md2.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
502m_md2.o: ../cryptlib.h evp_locl.h m_md2.c
444m_md4.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h 503m_md4.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h
445m_md4.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 504m_md4.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
446m_md4.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h 505m_md4.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h
447m_md4.o: ../../include/openssl/ecdh.h ../../include/openssl/ecdsa.h 506m_md4.o: ../../include/openssl/ecdh.h ../../include/openssl/ecdsa.h
448m_md4.o: ../../include/openssl/err.h ../../include/openssl/evp.h 507m_md4.o: ../../include/openssl/err.h ../../include/openssl/evp.h
449m_md4.o: ../../include/openssl/lhash.h ../../include/openssl/md4.h 508m_md4.o: ../../include/openssl/fips.h ../../include/openssl/lhash.h
450m_md4.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h 509m_md4.o: ../../include/openssl/md4.h ../../include/openssl/obj_mac.h
451m_md4.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h 510m_md4.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
452m_md4.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h 511m_md4.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
453m_md4.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h 512m_md4.o: ../../include/openssl/pkcs7.h ../../include/openssl/rsa.h
454m_md4.o: ../../include/openssl/sha.h ../../include/openssl/stack.h 513m_md4.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
455m_md4.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h 514m_md4.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
456m_md4.o: ../../include/openssl/x509_vfy.h ../cryptlib.h m_md4.c 515m_md4.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
516m_md4.o: ../cryptlib.h evp_locl.h m_md4.c
457m_md5.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h 517m_md5.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h
458m_md5.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 518m_md5.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
459m_md5.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h 519m_md5.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h
460m_md5.o: ../../include/openssl/ecdh.h ../../include/openssl/ecdsa.h 520m_md5.o: ../../include/openssl/ecdh.h ../../include/openssl/ecdsa.h
461m_md5.o: ../../include/openssl/err.h ../../include/openssl/evp.h 521m_md5.o: ../../include/openssl/err.h ../../include/openssl/evp.h
462m_md5.o: ../../include/openssl/lhash.h ../../include/openssl/md5.h 522m_md5.o: ../../include/openssl/fips.h ../../include/openssl/lhash.h
463m_md5.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h 523m_md5.o: ../../include/openssl/md5.h ../../include/openssl/obj_mac.h
464m_md5.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h 524m_md5.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
465m_md5.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h 525m_md5.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
466m_md5.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h 526m_md5.o: ../../include/openssl/pkcs7.h ../../include/openssl/rsa.h
467m_md5.o: ../../include/openssl/sha.h ../../include/openssl/stack.h 527m_md5.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
468m_md5.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h 528m_md5.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
469m_md5.o: ../../include/openssl/x509_vfy.h ../cryptlib.h m_md5.c 529m_md5.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
530m_md5.o: ../cryptlib.h evp_locl.h m_md5.c
470m_mdc2.o: ../../e_os.h ../../include/openssl/bio.h 531m_mdc2.o: ../../e_os.h ../../include/openssl/bio.h
471m_mdc2.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 532m_mdc2.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
472m_mdc2.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h 533m_mdc2.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
473m_mdc2.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h 534m_mdc2.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
474m_mdc2.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h 535m_mdc2.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
475m_mdc2.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h 536m_mdc2.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
476m_mdc2.o: ../../include/openssl/symhacks.h ../cryptlib.h m_mdc2.c 537m_mdc2.o: ../../include/openssl/symhacks.h ../cryptlib.h evp_locl.h m_mdc2.c
477m_null.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h 538m_null.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h
478m_null.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 539m_null.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
479m_null.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h 540m_null.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h
480m_null.o: ../../include/openssl/ecdh.h ../../include/openssl/ecdsa.h 541m_null.o: ../../include/openssl/ecdh.h ../../include/openssl/ecdsa.h
481m_null.o: ../../include/openssl/err.h ../../include/openssl/evp.h 542m_null.o: ../../include/openssl/err.h ../../include/openssl/evp.h
482m_null.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h 543m_null.o: ../../include/openssl/fips.h ../../include/openssl/lhash.h
483m_null.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h 544m_null.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
484m_null.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h 545m_null.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
485m_null.o: ../../include/openssl/pkcs7.h ../../include/openssl/safestack.h 546m_null.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h
486m_null.o: ../../include/openssl/sha.h ../../include/openssl/stack.h 547m_null.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
487m_null.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h 548m_null.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
488m_null.o: ../../include/openssl/x509_vfy.h ../cryptlib.h m_null.c 549m_null.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
550m_null.o: ../cryptlib.h m_null.c
489m_ripemd.o: ../../e_os.h ../../include/openssl/asn1.h 551m_ripemd.o: ../../e_os.h ../../include/openssl/asn1.h
490m_ripemd.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h 552m_ripemd.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
491m_ripemd.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h 553m_ripemd.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
492m_ripemd.o: ../../include/openssl/ec.h ../../include/openssl/ecdh.h 554m_ripemd.o: ../../include/openssl/ec.h ../../include/openssl/ecdh.h
493m_ripemd.o: ../../include/openssl/ecdsa.h ../../include/openssl/err.h 555m_ripemd.o: ../../include/openssl/ecdsa.h ../../include/openssl/err.h
494m_ripemd.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h 556m_ripemd.o: ../../include/openssl/evp.h ../../include/openssl/fips.h
495m_ripemd.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h 557m_ripemd.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
496m_ripemd.o: ../../include/openssl/opensslconf.h 558m_ripemd.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
497m_ripemd.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h 559m_ripemd.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
498m_ripemd.o: ../../include/openssl/pkcs7.h ../../include/openssl/ripemd.h 560m_ripemd.o: ../../include/openssl/pkcs7.h ../../include/openssl/ripemd.h
499m_ripemd.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h 561m_ripemd.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
@@ -505,60 +567,62 @@ m_sha.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
505m_sha.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h 567m_sha.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h
506m_sha.o: ../../include/openssl/ecdh.h ../../include/openssl/ecdsa.h 568m_sha.o: ../../include/openssl/ecdh.h ../../include/openssl/ecdsa.h
507m_sha.o: ../../include/openssl/err.h ../../include/openssl/evp.h 569m_sha.o: ../../include/openssl/err.h ../../include/openssl/evp.h
508m_sha.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h 570m_sha.o: ../../include/openssl/fips.h ../../include/openssl/lhash.h
509m_sha.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h 571m_sha.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
510m_sha.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h 572m_sha.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
511m_sha.o: ../../include/openssl/pkcs7.h ../../include/openssl/rsa.h 573m_sha.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h
512m_sha.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h 574m_sha.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
513m_sha.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 575m_sha.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
514m_sha.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h 576m_sha.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h
515m_sha.o: ../cryptlib.h m_sha.c 577m_sha.o: ../../include/openssl/x509_vfy.h ../cryptlib.h evp_locl.h m_sha.c
516m_sha1.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h 578m_sha1.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h
517m_sha1.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 579m_sha1.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
518m_sha1.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h 580m_sha1.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h
519m_sha1.o: ../../include/openssl/ecdh.h ../../include/openssl/ecdsa.h 581m_sha1.o: ../../include/openssl/ecdh.h ../../include/openssl/ecdsa.h
520m_sha1.o: ../../include/openssl/err.h ../../include/openssl/evp.h 582m_sha1.o: ../../include/openssl/err.h ../../include/openssl/evp.h
521m_sha1.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h 583m_sha1.o: ../../include/openssl/fips.h ../../include/openssl/lhash.h
522m_sha1.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h 584m_sha1.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
523m_sha1.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h 585m_sha1.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
524m_sha1.o: ../../include/openssl/pkcs7.h ../../include/openssl/rsa.h 586m_sha1.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h
525m_sha1.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h 587m_sha1.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
526m_sha1.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 588m_sha1.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
527m_sha1.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h 589m_sha1.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h
528m_sha1.o: ../cryptlib.h m_sha1.c 590m_sha1.o: ../../include/openssl/x509_vfy.h ../cryptlib.h m_sha1.c
529names.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h 591names.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h
530names.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 592names.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
531names.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h 593names.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h
532names.o: ../../include/openssl/ecdh.h ../../include/openssl/ecdsa.h 594names.o: ../../include/openssl/ecdh.h ../../include/openssl/ecdsa.h
533names.o: ../../include/openssl/err.h ../../include/openssl/evp.h 595names.o: ../../include/openssl/err.h ../../include/openssl/evp.h
534names.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h 596names.o: ../../include/openssl/fips.h ../../include/openssl/lhash.h
535names.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h 597names.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
536names.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h 598names.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
537names.o: ../../include/openssl/pkcs7.h ../../include/openssl/safestack.h 599names.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h
538names.o: ../../include/openssl/sha.h ../../include/openssl/stack.h 600names.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
539names.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h 601names.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
540names.o: ../../include/openssl/x509_vfy.h ../cryptlib.h names.c 602names.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
603names.o: ../cryptlib.h names.c
541p5_crpt.o: ../../e_os.h ../../include/openssl/asn1.h 604p5_crpt.o: ../../e_os.h ../../include/openssl/asn1.h
542p5_crpt.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h 605p5_crpt.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
543p5_crpt.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h 606p5_crpt.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
544p5_crpt.o: ../../include/openssl/ec.h ../../include/openssl/ecdh.h 607p5_crpt.o: ../../include/openssl/ec.h ../../include/openssl/ecdh.h
545p5_crpt.o: ../../include/openssl/ecdsa.h ../../include/openssl/err.h 608p5_crpt.o: ../../include/openssl/ecdsa.h ../../include/openssl/err.h
546p5_crpt.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h 609p5_crpt.o: ../../include/openssl/evp.h ../../include/openssl/fips.h
547p5_crpt.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h 610p5_crpt.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
548p5_crpt.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h 611p5_crpt.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
549p5_crpt.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h 612p5_crpt.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
550p5_crpt.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h 613p5_crpt.o: ../../include/openssl/pkcs7.h ../../include/openssl/safestack.h
551p5_crpt.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 614p5_crpt.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
552p5_crpt.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h 615p5_crpt.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h
553p5_crpt.o: ../cryptlib.h p5_crpt.c 616p5_crpt.o: ../../include/openssl/x509_vfy.h ../cryptlib.h p5_crpt.c
554p5_crpt2.o: ../../e_os.h ../../include/openssl/asn1.h 617p5_crpt2.o: ../../e_os.h ../../include/openssl/asn1.h
555p5_crpt2.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h 618p5_crpt2.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
556p5_crpt2.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h 619p5_crpt2.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
557p5_crpt2.o: ../../include/openssl/ec.h ../../include/openssl/ecdh.h 620p5_crpt2.o: ../../include/openssl/ec.h ../../include/openssl/ecdh.h
558p5_crpt2.o: ../../include/openssl/ecdsa.h ../../include/openssl/err.h 621p5_crpt2.o: ../../include/openssl/ecdsa.h ../../include/openssl/err.h
559p5_crpt2.o: ../../include/openssl/evp.h ../../include/openssl/hmac.h 622p5_crpt2.o: ../../include/openssl/evp.h ../../include/openssl/fips.h
560p5_crpt2.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h 623p5_crpt2.o: ../../include/openssl/hmac.h ../../include/openssl/lhash.h
561p5_crpt2.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h 624p5_crpt2.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
625p5_crpt2.o: ../../include/openssl/opensslconf.h
562p5_crpt2.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h 626p5_crpt2.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
563p5_crpt2.o: ../../include/openssl/pkcs7.h ../../include/openssl/safestack.h 627p5_crpt2.o: ../../include/openssl/pkcs7.h ../../include/openssl/safestack.h
564p5_crpt2.o: ../../include/openssl/sha.h ../../include/openssl/stack.h 628p5_crpt2.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
@@ -569,27 +633,29 @@ p_dec.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
569p_dec.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h 633p_dec.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h
570p_dec.o: ../../include/openssl/ecdh.h ../../include/openssl/ecdsa.h 634p_dec.o: ../../include/openssl/ecdh.h ../../include/openssl/ecdsa.h
571p_dec.o: ../../include/openssl/err.h ../../include/openssl/evp.h 635p_dec.o: ../../include/openssl/err.h ../../include/openssl/evp.h
572p_dec.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h 636p_dec.o: ../../include/openssl/fips.h ../../include/openssl/lhash.h
573p_dec.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h 637p_dec.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
574p_dec.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h 638p_dec.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
575p_dec.o: ../../include/openssl/pkcs7.h ../../include/openssl/rand.h 639p_dec.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h
576p_dec.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h 640p_dec.o: ../../include/openssl/rand.h ../../include/openssl/rsa.h
577p_dec.o: ../../include/openssl/sha.h ../../include/openssl/stack.h 641p_dec.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
578p_dec.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h 642p_dec.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
579p_dec.o: ../../include/openssl/x509_vfy.h ../cryptlib.h p_dec.c 643p_dec.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
644p_dec.o: ../cryptlib.h p_dec.c
580p_enc.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h 645p_enc.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h
581p_enc.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 646p_enc.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
582p_enc.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h 647p_enc.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h
583p_enc.o: ../../include/openssl/ecdh.h ../../include/openssl/ecdsa.h 648p_enc.o: ../../include/openssl/ecdh.h ../../include/openssl/ecdsa.h
584p_enc.o: ../../include/openssl/err.h ../../include/openssl/evp.h 649p_enc.o: ../../include/openssl/err.h ../../include/openssl/evp.h
585p_enc.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h 650p_enc.o: ../../include/openssl/fips.h ../../include/openssl/lhash.h
586p_enc.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h 651p_enc.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
587p_enc.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h 652p_enc.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
588p_enc.o: ../../include/openssl/pkcs7.h ../../include/openssl/rand.h 653p_enc.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h
589p_enc.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h 654p_enc.o: ../../include/openssl/rand.h ../../include/openssl/rsa.h
590p_enc.o: ../../include/openssl/sha.h ../../include/openssl/stack.h 655p_enc.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
591p_enc.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h 656p_enc.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
592p_enc.o: ../../include/openssl/x509_vfy.h ../cryptlib.h p_enc.c 657p_enc.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
658p_enc.o: ../cryptlib.h p_enc.c
593p_lib.o: ../../e_os.h ../../include/openssl/asn1.h 659p_lib.o: ../../e_os.h ../../include/openssl/asn1.h
594p_lib.o: ../../include/openssl/asn1_mac.h ../../include/openssl/bio.h 660p_lib.o: ../../include/openssl/asn1_mac.h ../../include/openssl/bio.h
595p_lib.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h 661p_lib.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
@@ -597,60 +663,63 @@ p_lib.o: ../../include/openssl/crypto.h ../../include/openssl/dh.h
597p_lib.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h 663p_lib.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
598p_lib.o: ../../include/openssl/ec.h ../../include/openssl/ecdh.h 664p_lib.o: ../../include/openssl/ec.h ../../include/openssl/ecdh.h
599p_lib.o: ../../include/openssl/ecdsa.h ../../include/openssl/err.h 665p_lib.o: ../../include/openssl/ecdsa.h ../../include/openssl/err.h
600p_lib.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h 666p_lib.o: ../../include/openssl/evp.h ../../include/openssl/fips.h
601p_lib.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h 667p_lib.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
602p_lib.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h 668p_lib.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
603p_lib.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h 669p_lib.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
604p_lib.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h 670p_lib.o: ../../include/openssl/pkcs7.h ../../include/openssl/rsa.h
605p_lib.o: ../../include/openssl/sha.h ../../include/openssl/stack.h 671p_lib.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
606p_lib.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h 672p_lib.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
607p_lib.o: ../../include/openssl/x509_vfy.h ../cryptlib.h p_lib.c 673p_lib.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
674p_lib.o: ../cryptlib.h p_lib.c
608p_open.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h 675p_open.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h
609p_open.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 676p_open.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
610p_open.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h 677p_open.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h
611p_open.o: ../../include/openssl/ecdh.h ../../include/openssl/ecdsa.h 678p_open.o: ../../include/openssl/ecdh.h ../../include/openssl/ecdsa.h
612p_open.o: ../../include/openssl/err.h ../../include/openssl/evp.h 679p_open.o: ../../include/openssl/err.h ../../include/openssl/evp.h
613p_open.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h 680p_open.o: ../../include/openssl/fips.h ../../include/openssl/lhash.h
614p_open.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h 681p_open.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
615p_open.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h 682p_open.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
616p_open.o: ../../include/openssl/pkcs7.h ../../include/openssl/rsa.h 683p_open.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h
617p_open.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h 684p_open.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
618p_open.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 685p_open.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
619p_open.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h 686p_open.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h
620p_open.o: ../cryptlib.h p_open.c 687p_open.o: ../../include/openssl/x509_vfy.h ../cryptlib.h p_open.c
621p_seal.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h 688p_seal.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h
622p_seal.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 689p_seal.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
623p_seal.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h 690p_seal.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h
624p_seal.o: ../../include/openssl/ecdh.h ../../include/openssl/ecdsa.h 691p_seal.o: ../../include/openssl/ecdh.h ../../include/openssl/ecdsa.h
625p_seal.o: ../../include/openssl/err.h ../../include/openssl/evp.h 692p_seal.o: ../../include/openssl/err.h ../../include/openssl/evp.h
626p_seal.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h 693p_seal.o: ../../include/openssl/fips.h ../../include/openssl/lhash.h
627p_seal.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h 694p_seal.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
628p_seal.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h 695p_seal.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
629p_seal.o: ../../include/openssl/pkcs7.h ../../include/openssl/rand.h 696p_seal.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h
630p_seal.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h 697p_seal.o: ../../include/openssl/rand.h ../../include/openssl/rsa.h
631p_seal.o: ../../include/openssl/sha.h ../../include/openssl/stack.h 698p_seal.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
632p_seal.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h 699p_seal.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
633p_seal.o: ../../include/openssl/x509_vfy.h ../cryptlib.h p_seal.c 700p_seal.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
701p_seal.o: ../cryptlib.h p_seal.c
634p_sign.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h 702p_sign.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h
635p_sign.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 703p_sign.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
636p_sign.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h 704p_sign.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h
637p_sign.o: ../../include/openssl/ecdh.h ../../include/openssl/ecdsa.h 705p_sign.o: ../../include/openssl/ecdh.h ../../include/openssl/ecdsa.h
638p_sign.o: ../../include/openssl/err.h ../../include/openssl/evp.h 706p_sign.o: ../../include/openssl/err.h ../../include/openssl/evp.h
639p_sign.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h 707p_sign.o: ../../include/openssl/fips.h ../../include/openssl/lhash.h
640p_sign.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h 708p_sign.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
641p_sign.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h 709p_sign.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
642p_sign.o: ../../include/openssl/pkcs7.h ../../include/openssl/safestack.h 710p_sign.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h
643p_sign.o: ../../include/openssl/sha.h ../../include/openssl/stack.h 711p_sign.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
644p_sign.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h 712p_sign.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
645p_sign.o: ../../include/openssl/x509_vfy.h ../cryptlib.h p_sign.c 713p_sign.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
714p_sign.o: ../cryptlib.h p_sign.c
646p_verify.o: ../../e_os.h ../../include/openssl/asn1.h 715p_verify.o: ../../e_os.h ../../include/openssl/asn1.h
647p_verify.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h 716p_verify.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
648p_verify.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h 717p_verify.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
649p_verify.o: ../../include/openssl/ec.h ../../include/openssl/ecdh.h 718p_verify.o: ../../include/openssl/ec.h ../../include/openssl/ecdh.h
650p_verify.o: ../../include/openssl/ecdsa.h ../../include/openssl/err.h 719p_verify.o: ../../include/openssl/ecdsa.h ../../include/openssl/err.h
651p_verify.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h 720p_verify.o: ../../include/openssl/evp.h ../../include/openssl/fips.h
652p_verify.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h 721p_verify.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
653p_verify.o: ../../include/openssl/opensslconf.h 722p_verify.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
654p_verify.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h 723p_verify.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
655p_verify.o: ../../include/openssl/pkcs7.h ../../include/openssl/safestack.h 724p_verify.o: ../../include/openssl/pkcs7.h ../../include/openssl/safestack.h
656p_verify.o: ../../include/openssl/sha.h ../../include/openssl/stack.h 725p_verify.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
diff --git a/src/lib/libcrypto/evp/bio_md.c b/src/lib/libcrypto/evp/bio_md.c
index d648ac6da6..ed5c1135fd 100644
--- a/src/lib/libcrypto/evp/bio_md.c
+++ b/src/lib/libcrypto/evp/bio_md.c
@@ -192,13 +192,8 @@ static long md_ctrl(BIO *b, int cmd, long num, void *ptr)
192 ret=0; 192 ret=0;
193 break; 193 break;
194 case BIO_C_GET_MD_CTX: 194 case BIO_C_GET_MD_CTX:
195 if (b->init) 195 pctx=ptr;
196 { 196 *pctx=ctx;
197 pctx=ptr;
198 *pctx=ctx;
199 }
200 else
201 ret=0;
202 break; 197 break;
203 case BIO_C_SET_MD_CTX: 198 case BIO_C_SET_MD_CTX:
204 if (b->init) 199 if (b->init)
diff --git a/src/lib/libcrypto/evp/digest.c b/src/lib/libcrypto/evp/digest.c
index 762e6d3450..3bc2d1295c 100644
--- a/src/lib/libcrypto/evp/digest.c
+++ b/src/lib/libcrypto/evp/digest.c
@@ -116,6 +116,7 @@
116#ifndef OPENSSL_NO_ENGINE 116#ifndef OPENSSL_NO_ENGINE
117#include <openssl/engine.h> 117#include <openssl/engine.h>
118#endif 118#endif
119#include "evp_locl.h"
119 120
120void EVP_MD_CTX_init(EVP_MD_CTX *ctx) 121void EVP_MD_CTX_init(EVP_MD_CTX *ctx)
121 { 122 {
@@ -137,18 +138,77 @@ int EVP_DigestInit(EVP_MD_CTX *ctx, const EVP_MD *type)
137 return EVP_DigestInit_ex(ctx, type, NULL); 138 return EVP_DigestInit_ex(ctx, type, NULL);
138 } 139 }
139 140
140int EVP_DigestInit_ex(EVP_MD_CTX *ctx, const EVP_MD *type, ENGINE *impl) 141#ifdef OPENSSL_FIPS
142
143/* The purpose of these is to trap programs that attempt to use non FIPS
144 * algorithms in FIPS mode and ignore the errors.
145 */
146
147static int bad_init(EVP_MD_CTX *ctx)
148 { FIPS_ERROR_IGNORED("Digest init"); return 0;}
149
150static int bad_update(EVP_MD_CTX *ctx,const void *data,size_t count)
151 { FIPS_ERROR_IGNORED("Digest update"); return 0;}
152
153static int bad_final(EVP_MD_CTX *ctx,unsigned char *md)
154 { FIPS_ERROR_IGNORED("Digest Final"); return 0;}
155
156static const EVP_MD bad_md =
141 { 157 {
142 EVP_MD_CTX_clear_flags(ctx,EVP_MD_CTX_FLAG_CLEANED); 158 0,
159 0,
160 0,
161 0,
162 bad_init,
163 bad_update,
164 bad_final,
165 NULL,
166 NULL,
167 NULL,
168 0,
169 {0,0,0,0},
170 };
171
172#endif
173
143#ifndef OPENSSL_NO_ENGINE 174#ifndef OPENSSL_NO_ENGINE
144 /* Whether it's nice or not, "Inits" can be used on "Final"'d contexts 175
145 * so this context may already have an ENGINE! Try to avoid releasing 176#ifdef OPENSSL_FIPS
146 * the previous handle, re-querying for an ENGINE, and having a 177
147 * reinitialisation, when it may all be unecessary. */ 178static int do_engine_null(ENGINE *impl) { return 0;}
148 if (ctx->engine && ctx->digest && (!type || 179static int do_evp_md_engine_null(EVP_MD_CTX *ctx,
149 (type && (type->type == ctx->digest->type)))) 180 const EVP_MD **ptype, ENGINE *impl)
150 goto skip_to_init; 181 { return 1; }
151 if (type) 182
183static int (*do_engine_init)(ENGINE *impl)
184 = do_engine_null;
185
186static int (*do_engine_finish)(ENGINE *impl)
187 = do_engine_null;
188
189static int (*do_evp_md_engine)
190 (EVP_MD_CTX *ctx, const EVP_MD **ptype, ENGINE *impl)
191 = do_evp_md_engine_null;
192
193void int_EVP_MD_set_engine_callbacks(
194 int (*eng_md_init)(ENGINE *impl),
195 int (*eng_md_fin)(ENGINE *impl),
196 int (*eng_md_evp)
197 (EVP_MD_CTX *ctx, const EVP_MD **ptype, ENGINE *impl))
198 {
199 do_engine_init = eng_md_init;
200 do_engine_finish = eng_md_fin;
201 do_evp_md_engine = eng_md_evp;
202 }
203
204#else
205
206#define do_engine_init ENGINE_init
207#define do_engine_finish ENGINE_finish
208
209static int do_evp_md_engine(EVP_MD_CTX *ctx, const EVP_MD **ptype, ENGINE *impl)
210 {
211 if (*ptype)
152 { 212 {
153 /* Ensure an ENGINE left lying around from last time is cleared 213 /* Ensure an ENGINE left lying around from last time is cleared
154 * (the previous check attempted to avoid this if the same 214 * (the previous check attempted to avoid this if the same
@@ -159,25 +219,25 @@ int EVP_DigestInit_ex(EVP_MD_CTX *ctx, const EVP_MD *type, ENGINE *impl)
159 { 219 {
160 if (!ENGINE_init(impl)) 220 if (!ENGINE_init(impl))
161 { 221 {
162 EVPerr(EVP_F_EVP_DIGESTINIT_EX,EVP_R_INITIALIZATION_ERROR); 222 EVPerr(EVP_F_DO_EVP_MD_ENGINE,EVP_R_INITIALIZATION_ERROR);
163 return 0; 223 return 0;
164 } 224 }
165 } 225 }
166 else 226 else
167 /* Ask if an ENGINE is reserved for this job */ 227 /* Ask if an ENGINE is reserved for this job */
168 impl = ENGINE_get_digest_engine(type->type); 228 impl = ENGINE_get_digest_engine((*ptype)->type);
169 if(impl) 229 if(impl)
170 { 230 {
171 /* There's an ENGINE for this job ... (apparently) */ 231 /* There's an ENGINE for this job ... (apparently) */
172 const EVP_MD *d = ENGINE_get_digest(impl, type->type); 232 const EVP_MD *d = ENGINE_get_digest(impl, (*ptype)->type);
173 if(!d) 233 if(!d)
174 { 234 {
175 /* Same comment from evp_enc.c */ 235 /* Same comment from evp_enc.c */
176 EVPerr(EVP_F_EVP_DIGESTINIT_EX,EVP_R_INITIALIZATION_ERROR); 236 EVPerr(EVP_F_DO_EVP_MD_ENGINE,EVP_R_INITIALIZATION_ERROR);
177 return 0; 237 return 0;
178 } 238 }
179 /* We'll use the ENGINE's private digest definition */ 239 /* We'll use the ENGINE's private digest definition */
180 type = d; 240 *ptype = d;
181 /* Store the ENGINE functional reference so we know 241 /* Store the ENGINE functional reference so we know
182 * 'type' came from an ENGINE and we need to release 242 * 'type' came from an ENGINE and we need to release
183 * it when done. */ 243 * it when done. */
@@ -189,12 +249,52 @@ int EVP_DigestInit_ex(EVP_MD_CTX *ctx, const EVP_MD *type, ENGINE *impl)
189 else 249 else
190 if(!ctx->digest) 250 if(!ctx->digest)
191 { 251 {
192 EVPerr(EVP_F_EVP_DIGESTINIT_EX,EVP_R_NO_DIGEST_SET); 252 EVPerr(EVP_F_DO_EVP_MD_ENGINE,EVP_R_NO_DIGEST_SET);
193 return 0; 253 return 0;
194 } 254 }
255 return 1;
256 }
257
258#endif
259
260#endif
261
262int EVP_DigestInit_ex(EVP_MD_CTX *ctx, const EVP_MD *type, ENGINE *impl)
263 {
264 M_EVP_MD_CTX_clear_flags(ctx,EVP_MD_CTX_FLAG_CLEANED);
265#ifdef OPENSSL_FIPS
266 if(FIPS_selftest_failed())
267 {
268 FIPSerr(FIPS_F_EVP_DIGESTINIT_EX,FIPS_R_FIPS_SELFTEST_FAILED);
269 ctx->digest = &bad_md;
270 return 0;
271 }
272#endif
273#ifndef OPENSSL_NO_ENGINE
274 /* Whether it's nice or not, "Inits" can be used on "Final"'d contexts
275 * so this context may already have an ENGINE! Try to avoid releasing
276 * the previous handle, re-querying for an ENGINE, and having a
277 * reinitialisation, when it may all be unecessary. */
278 if (ctx->engine && ctx->digest && (!type ||
279 (type && (type->type == ctx->digest->type))))
280 goto skip_to_init;
281 if (!do_evp_md_engine(ctx, &type, impl))
282 return 0;
195#endif 283#endif
196 if (ctx->digest != type) 284 if (ctx->digest != type)
197 { 285 {
286#ifdef OPENSSL_FIPS
287 if (FIPS_mode())
288 {
289 if (!(type->flags & EVP_MD_FLAG_FIPS)
290 && !(ctx->flags & EVP_MD_CTX_FLAG_NON_FIPS_ALLOW))
291 {
292 EVPerr(EVP_F_EVP_DIGESTINIT_EX, EVP_R_DISABLED_FOR_FIPS);
293 ctx->digest = &bad_md;
294 return 0;
295 }
296 }
297#endif
198 if (ctx->digest && ctx->digest->ctx_size) 298 if (ctx->digest && ctx->digest->ctx_size)
199 OPENSSL_free(ctx->md_data); 299 OPENSSL_free(ctx->md_data);
200 ctx->digest=type; 300 ctx->digest=type;
@@ -202,7 +302,7 @@ int EVP_DigestInit_ex(EVP_MD_CTX *ctx, const EVP_MD *type, ENGINE *impl)
202 ctx->md_data=OPENSSL_malloc(type->ctx_size); 302 ctx->md_data=OPENSSL_malloc(type->ctx_size);
203 } 303 }
204#ifndef OPENSSL_NO_ENGINE 304#ifndef OPENSSL_NO_ENGINE
205skip_to_init: 305 skip_to_init:
206#endif 306#endif
207 return ctx->digest->init(ctx); 307 return ctx->digest->init(ctx);
208 } 308 }
@@ -210,6 +310,9 @@ skip_to_init:
210int EVP_DigestUpdate(EVP_MD_CTX *ctx, const void *data, 310int EVP_DigestUpdate(EVP_MD_CTX *ctx, const void *data,
211 size_t count) 311 size_t count)
212 { 312 {
313#ifdef OPENSSL_FIPS
314 FIPS_selftest_check();
315#endif
213 return ctx->digest->update(ctx,data,count); 316 return ctx->digest->update(ctx,data,count);
214 } 317 }
215 318
@@ -226,6 +329,9 @@ int EVP_DigestFinal(EVP_MD_CTX *ctx, unsigned char *md, unsigned int *size)
226int EVP_DigestFinal_ex(EVP_MD_CTX *ctx, unsigned char *md, unsigned int *size) 329int EVP_DigestFinal_ex(EVP_MD_CTX *ctx, unsigned char *md, unsigned int *size)
227 { 330 {
228 int ret; 331 int ret;
332#ifdef OPENSSL_FIPS
333 FIPS_selftest_check();
334#endif
229 335
230 OPENSSL_assert(ctx->digest->md_size <= EVP_MAX_MD_SIZE); 336 OPENSSL_assert(ctx->digest->md_size <= EVP_MAX_MD_SIZE);
231 ret=ctx->digest->final(ctx,md); 337 ret=ctx->digest->final(ctx,md);
@@ -234,7 +340,7 @@ int EVP_DigestFinal_ex(EVP_MD_CTX *ctx, unsigned char *md, unsigned int *size)
234 if (ctx->digest->cleanup) 340 if (ctx->digest->cleanup)
235 { 341 {
236 ctx->digest->cleanup(ctx); 342 ctx->digest->cleanup(ctx);
237 EVP_MD_CTX_set_flags(ctx,EVP_MD_CTX_FLAG_CLEANED); 343 M_EVP_MD_CTX_set_flags(ctx,EVP_MD_CTX_FLAG_CLEANED);
238 } 344 }
239 memset(ctx->md_data,0,ctx->digest->ctx_size); 345 memset(ctx->md_data,0,ctx->digest->ctx_size);
240 return ret; 346 return ret;
@@ -256,7 +362,7 @@ int EVP_MD_CTX_copy_ex(EVP_MD_CTX *out, const EVP_MD_CTX *in)
256 } 362 }
257#ifndef OPENSSL_NO_ENGINE 363#ifndef OPENSSL_NO_ENGINE
258 /* Make sure it's safe to copy a digest context using an ENGINE */ 364 /* Make sure it's safe to copy a digest context using an ENGINE */
259 if (in->engine && !ENGINE_init(in->engine)) 365 if (in->engine && !do_engine_init(in->engine))
260 { 366 {
261 EVPerr(EVP_F_EVP_MD_CTX_COPY_EX,ERR_R_ENGINE_LIB); 367 EVPerr(EVP_F_EVP_MD_CTX_COPY_EX,ERR_R_ENGINE_LIB);
262 return 0; 368 return 0;
@@ -266,7 +372,7 @@ int EVP_MD_CTX_copy_ex(EVP_MD_CTX *out, const EVP_MD_CTX *in)
266 if (out->digest == in->digest) 372 if (out->digest == in->digest)
267 { 373 {
268 tmp_buf = out->md_data; 374 tmp_buf = out->md_data;
269 EVP_MD_CTX_set_flags(out,EVP_MD_CTX_FLAG_REUSE); 375 M_EVP_MD_CTX_set_flags(out,EVP_MD_CTX_FLAG_REUSE);
270 } 376 }
271 else tmp_buf = NULL; 377 else tmp_buf = NULL;
272 EVP_MD_CTX_cleanup(out); 378 EVP_MD_CTX_cleanup(out);
@@ -292,7 +398,7 @@ int EVP_Digest(const void *data, size_t count,
292 int ret; 398 int ret;
293 399
294 EVP_MD_CTX_init(&ctx); 400 EVP_MD_CTX_init(&ctx);
295 EVP_MD_CTX_set_flags(&ctx,EVP_MD_CTX_FLAG_ONESHOT); 401 M_EVP_MD_CTX_set_flags(&ctx,EVP_MD_CTX_FLAG_ONESHOT);
296 ret=EVP_DigestInit_ex(&ctx, type, impl) 402 ret=EVP_DigestInit_ex(&ctx, type, impl)
297 && EVP_DigestUpdate(&ctx, data, count) 403 && EVP_DigestUpdate(&ctx, data, count)
298 && EVP_DigestFinal_ex(&ctx, md, size); 404 && EVP_DigestFinal_ex(&ctx, md, size);
@@ -314,10 +420,10 @@ int EVP_MD_CTX_cleanup(EVP_MD_CTX *ctx)
314 * because sometimes only copies of the context are ever finalised. 420 * because sometimes only copies of the context are ever finalised.
315 */ 421 */
316 if (ctx->digest && ctx->digest->cleanup 422 if (ctx->digest && ctx->digest->cleanup
317 && !EVP_MD_CTX_test_flags(ctx,EVP_MD_CTX_FLAG_CLEANED)) 423 && !M_EVP_MD_CTX_test_flags(ctx,EVP_MD_CTX_FLAG_CLEANED))
318 ctx->digest->cleanup(ctx); 424 ctx->digest->cleanup(ctx);
319 if (ctx->digest && ctx->digest->ctx_size && ctx->md_data 425 if (ctx->digest && ctx->digest->ctx_size && ctx->md_data
320 && !EVP_MD_CTX_test_flags(ctx, EVP_MD_CTX_FLAG_REUSE)) 426 && !M_EVP_MD_CTX_test_flags(ctx, EVP_MD_CTX_FLAG_REUSE))
321 { 427 {
322 OPENSSL_cleanse(ctx->md_data,ctx->digest->ctx_size); 428 OPENSSL_cleanse(ctx->md_data,ctx->digest->ctx_size);
323 OPENSSL_free(ctx->md_data); 429 OPENSSL_free(ctx->md_data);
@@ -326,7 +432,7 @@ int EVP_MD_CTX_cleanup(EVP_MD_CTX *ctx)
326 if(ctx->engine) 432 if(ctx->engine)
327 /* The EVP_MD we used belongs to an ENGINE, release the 433 /* The EVP_MD we used belongs to an ENGINE, release the
328 * functional reference we held for this reason. */ 434 * functional reference we held for this reason. */
329 ENGINE_finish(ctx->engine); 435 do_engine_finish(ctx->engine);
330#endif 436#endif
331 memset(ctx,'\0',sizeof *ctx); 437 memset(ctx,'\0',sizeof *ctx);
332 438
diff --git a/src/lib/libcrypto/evp/e_aes.c b/src/lib/libcrypto/evp/e_aes.c
index bd6c0a3a62..c9a5ee8d75 100644
--- a/src/lib/libcrypto/evp/e_aes.c
+++ b/src/lib/libcrypto/evp/e_aes.c
@@ -69,32 +69,29 @@ typedef struct
69 69
70IMPLEMENT_BLOCK_CIPHER(aes_128, ks, AES, EVP_AES_KEY, 70IMPLEMENT_BLOCK_CIPHER(aes_128, ks, AES, EVP_AES_KEY,
71 NID_aes_128, 16, 16, 16, 128, 71 NID_aes_128, 16, 16, 16, 128,
72 0, aes_init_key, NULL, 72 EVP_CIPH_FLAG_FIPS|EVP_CIPH_FLAG_DEFAULT_ASN1,
73 EVP_CIPHER_set_asn1_iv, 73 aes_init_key,
74 EVP_CIPHER_get_asn1_iv, 74 NULL, NULL, NULL, NULL)
75 NULL)
76IMPLEMENT_BLOCK_CIPHER(aes_192, ks, AES, EVP_AES_KEY, 75IMPLEMENT_BLOCK_CIPHER(aes_192, ks, AES, EVP_AES_KEY,
77 NID_aes_192, 16, 24, 16, 128, 76 NID_aes_192, 16, 24, 16, 128,
78 0, aes_init_key, NULL, 77 EVP_CIPH_FLAG_FIPS|EVP_CIPH_FLAG_DEFAULT_ASN1,
79 EVP_CIPHER_set_asn1_iv, 78 aes_init_key,
80 EVP_CIPHER_get_asn1_iv, 79 NULL, NULL, NULL, NULL)
81 NULL)
82IMPLEMENT_BLOCK_CIPHER(aes_256, ks, AES, EVP_AES_KEY, 80IMPLEMENT_BLOCK_CIPHER(aes_256, ks, AES, EVP_AES_KEY,
83 NID_aes_256, 16, 32, 16, 128, 81 NID_aes_256, 16, 32, 16, 128,
84 0, aes_init_key, NULL, 82 EVP_CIPH_FLAG_FIPS|EVP_CIPH_FLAG_DEFAULT_ASN1,
85 EVP_CIPHER_set_asn1_iv, 83 aes_init_key,
86 EVP_CIPHER_get_asn1_iv, 84 NULL, NULL, NULL, NULL)
87 NULL)
88 85
89#define IMPLEMENT_AES_CFBR(ksize,cbits) IMPLEMENT_CFBR(aes,AES,EVP_AES_KEY,ks,ksize,cbits,16) 86#define IMPLEMENT_AES_CFBR(ksize,cbits,flags) IMPLEMENT_CFBR(aes,AES,EVP_AES_KEY,ks,ksize,cbits,16,flags)
90 87
91IMPLEMENT_AES_CFBR(128,1) 88IMPLEMENT_AES_CFBR(128,1,EVP_CIPH_FLAG_FIPS)
92IMPLEMENT_AES_CFBR(192,1) 89IMPLEMENT_AES_CFBR(192,1,EVP_CIPH_FLAG_FIPS)
93IMPLEMENT_AES_CFBR(256,1) 90IMPLEMENT_AES_CFBR(256,1,EVP_CIPH_FLAG_FIPS)
94 91
95IMPLEMENT_AES_CFBR(128,8) 92IMPLEMENT_AES_CFBR(128,8,EVP_CIPH_FLAG_FIPS)
96IMPLEMENT_AES_CFBR(192,8) 93IMPLEMENT_AES_CFBR(192,8,EVP_CIPH_FLAG_FIPS)
97IMPLEMENT_AES_CFBR(256,8) 94IMPLEMENT_AES_CFBR(256,8,EVP_CIPH_FLAG_FIPS)
98 95
99static int aes_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key, 96static int aes_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key,
100 const unsigned char *iv, int enc) 97 const unsigned char *iv, int enc)
diff --git a/src/lib/libcrypto/evp/e_des.c b/src/lib/libcrypto/evp/e_des.c
index 856323648c..04376df232 100644
--- a/src/lib/libcrypto/evp/e_des.c
+++ b/src/lib/libcrypto/evp/e_des.c
@@ -129,18 +129,21 @@ static int des_cfb8_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
129 } 129 }
130 130
131BLOCK_CIPHER_defs(des, DES_key_schedule, NID_des, 8, 8, 8, 64, 131BLOCK_CIPHER_defs(des, DES_key_schedule, NID_des, 8, 8, 8, 64,
132 EVP_CIPH_RAND_KEY, des_init_key, NULL, 132 EVP_CIPH_RAND_KEY,
133 des_init_key, NULL,
133 EVP_CIPHER_set_asn1_iv, 134 EVP_CIPHER_set_asn1_iv,
134 EVP_CIPHER_get_asn1_iv, 135 EVP_CIPHER_get_asn1_iv,
135 des_ctrl) 136 des_ctrl)
136 137
137BLOCK_CIPHER_def_cfb(des,DES_key_schedule,NID_des,8,8,1, 138BLOCK_CIPHER_def_cfb(des,DES_key_schedule,NID_des,8,8,1,
138 EVP_CIPH_RAND_KEY, des_init_key,NULL, 139 EVP_CIPH_RAND_KEY,
140 des_init_key, NULL,
139 EVP_CIPHER_set_asn1_iv, 141 EVP_CIPHER_set_asn1_iv,
140 EVP_CIPHER_get_asn1_iv,des_ctrl) 142 EVP_CIPHER_get_asn1_iv,des_ctrl)
141 143
142BLOCK_CIPHER_def_cfb(des,DES_key_schedule,NID_des,8,8,8, 144BLOCK_CIPHER_def_cfb(des,DES_key_schedule,NID_des,8,8,8,
143 EVP_CIPH_RAND_KEY,des_init_key,NULL, 145 EVP_CIPH_RAND_KEY,
146 des_init_key,NULL,
144 EVP_CIPHER_set_asn1_iv, 147 EVP_CIPHER_set_asn1_iv,
145 EVP_CIPHER_get_asn1_iv,des_ctrl) 148 EVP_CIPHER_get_asn1_iv,des_ctrl)
146 149
diff --git a/src/lib/libcrypto/evp/e_des3.c b/src/lib/libcrypto/evp/e_des3.c
index ac148efab2..f910af19b1 100644
--- a/src/lib/libcrypto/evp/e_des3.c
+++ b/src/lib/libcrypto/evp/e_des3.c
@@ -111,8 +111,7 @@ static int des_ede_cbc_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
111#ifdef KSSL_DEBUG 111#ifdef KSSL_DEBUG
112 { 112 {
113 int i; 113 int i;
114 char *cp; 114 printf("des_ede_cbc_cipher(ctx=%lx, buflen=%d)\n", (unsigned long)ctx, ctx->buf_len);
115 printf("des_ede_cbc_cipher(ctx=%lx, buflen=%d)\n", ctx, ctx->buf_len);
116 printf("\t iv= "); 115 printf("\t iv= ");
117 for(i=0;i<8;i++) 116 for(i=0;i<8;i++)
118 printf("%02X",ctx->iv[i]); 117 printf("%02X",ctx->iv[i]);
@@ -164,9 +163,9 @@ static int des_ede3_cfb8_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
164 } 163 }
165 164
166BLOCK_CIPHER_defs(des_ede, DES_EDE_KEY, NID_des_ede, 8, 16, 8, 64, 165BLOCK_CIPHER_defs(des_ede, DES_EDE_KEY, NID_des_ede, 8, 16, 8, 64,
167 EVP_CIPH_RAND_KEY, des_ede_init_key, NULL, 166 EVP_CIPH_RAND_KEY|EVP_CIPH_FLAG_FIPS|EVP_CIPH_FLAG_DEFAULT_ASN1,
168 EVP_CIPHER_set_asn1_iv, 167 des_ede_init_key,
169 EVP_CIPHER_get_asn1_iv, 168 NULL, NULL, NULL,
170 des3_ctrl) 169 des3_ctrl)
171 170
172#define des_ede3_cfb64_cipher des_ede_cfb64_cipher 171#define des_ede3_cfb64_cipher des_ede_cfb64_cipher
@@ -175,21 +174,21 @@ BLOCK_CIPHER_defs(des_ede, DES_EDE_KEY, NID_des_ede, 8, 16, 8, 64,
175#define des_ede3_ecb_cipher des_ede_ecb_cipher 174#define des_ede3_ecb_cipher des_ede_ecb_cipher
176 175
177BLOCK_CIPHER_defs(des_ede3, DES_EDE_KEY, NID_des_ede3, 8, 24, 8, 64, 176BLOCK_CIPHER_defs(des_ede3, DES_EDE_KEY, NID_des_ede3, 8, 24, 8, 64,
178 EVP_CIPH_RAND_KEY, des_ede3_init_key, NULL, 177 EVP_CIPH_RAND_KEY|EVP_CIPH_FLAG_FIPS|EVP_CIPH_FLAG_DEFAULT_ASN1,
179 EVP_CIPHER_set_asn1_iv, 178 des_ede3_init_key,
180 EVP_CIPHER_get_asn1_iv, 179 NULL, NULL, NULL,
181 des3_ctrl) 180 des3_ctrl)
182 181
183BLOCK_CIPHER_def_cfb(des_ede3,DES_EDE_KEY,NID_des_ede3,24,8,1, 182BLOCK_CIPHER_def_cfb(des_ede3,DES_EDE_KEY,NID_des_ede3,24,8,1,
184 EVP_CIPH_RAND_KEY, des_ede3_init_key,NULL, 183 EVP_CIPH_RAND_KEY|EVP_CIPH_FLAG_FIPS|EVP_CIPH_FLAG_DEFAULT_ASN1,
185 EVP_CIPHER_set_asn1_iv, 184 des_ede3_init_key,
186 EVP_CIPHER_get_asn1_iv, 185 NULL, NULL, NULL,
187 des3_ctrl) 186 des3_ctrl)
188 187
189BLOCK_CIPHER_def_cfb(des_ede3,DES_EDE_KEY,NID_des_ede3,24,8,8, 188BLOCK_CIPHER_def_cfb(des_ede3,DES_EDE_KEY,NID_des_ede3,24,8,8,
190 EVP_CIPH_RAND_KEY, des_ede3_init_key,NULL, 189 EVP_CIPH_RAND_KEY|EVP_CIPH_FLAG_FIPS|EVP_CIPH_FLAG_DEFAULT_ASN1,
191 EVP_CIPHER_set_asn1_iv, 190 des_ede3_init_key,
192 EVP_CIPHER_get_asn1_iv, 191 NULL, NULL, NULL,
193 des3_ctrl) 192 des3_ctrl)
194 193
195static int des_ede_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key, 194static int des_ede_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key,
@@ -216,7 +215,7 @@ static int des_ede3_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key,
216#ifdef KSSL_DEBUG 215#ifdef KSSL_DEBUG
217 { 216 {
218 int i; 217 int i;
219 printf("des_ede3_init_key(ctx=%lx)\n", ctx); 218 printf("des_ede3_init_key(ctx=%lx)\n", (unsigned long)ctx);
220 printf("\tKEY= "); 219 printf("\tKEY= ");
221 for(i=0;i<24;i++) printf("%02X",key[i]); printf("\n"); 220 for(i=0;i<24;i++) printf("%02X",key[i]); printf("\n");
222 printf("\t IV= "); 221 printf("\t IV= ");
diff --git a/src/lib/libcrypto/evp/e_null.c b/src/lib/libcrypto/evp/e_null.c
index 5205259f18..0872d733e4 100644
--- a/src/lib/libcrypto/evp/e_null.c
+++ b/src/lib/libcrypto/evp/e_null.c
@@ -69,7 +69,7 @@ static const EVP_CIPHER n_cipher=
69 { 69 {
70 NID_undef, 70 NID_undef,
71 1,0,0, 71 1,0,0,
72 0, 72 EVP_CIPH_FLAG_FIPS,
73 null_init_key, 73 null_init_key,
74 null_cipher, 74 null_cipher,
75 NULL, 75 NULL,
diff --git a/src/lib/libcrypto/evp/e_rc4.c b/src/lib/libcrypto/evp/e_rc4.c
index 67af850bea..55baad7446 100644
--- a/src/lib/libcrypto/evp/e_rc4.c
+++ b/src/lib/libcrypto/evp/e_rc4.c
@@ -64,6 +64,7 @@
64#include <openssl/evp.h> 64#include <openssl/evp.h>
65#include <openssl/objects.h> 65#include <openssl/objects.h>
66#include <openssl/rc4.h> 66#include <openssl/rc4.h>
67#include "evp_locl.h"
67 68
68/* FIXME: surely this is available elsewhere? */ 69/* FIXME: surely this is available elsewhere? */
69#define EVP_RC4_KEY_SIZE 16 70#define EVP_RC4_KEY_SIZE 16
diff --git a/src/lib/libcrypto/evp/evp.h b/src/lib/libcrypto/evp/evp.h
index 1aa2d6fb35..51011f2b14 100644
--- a/src/lib/libcrypto/evp/evp.h
+++ b/src/lib/libcrypto/evp/evp.h
@@ -75,6 +75,10 @@
75#include <openssl/bio.h> 75#include <openssl/bio.h>
76#endif 76#endif
77 77
78#ifdef OPENSSL_FIPS
79#include <openssl/fips.h>
80#endif
81
78/* 82/*
79#define EVP_RC2_KEY_SIZE 16 83#define EVP_RC2_KEY_SIZE 16
80#define EVP_RC4_KEY_SIZE 16 84#define EVP_RC4_KEY_SIZE 16
@@ -250,9 +254,19 @@ typedef int evp_verify_method(int type,const unsigned char *m,
250 unsigned int m_length,const unsigned char *sigbuf, 254 unsigned int m_length,const unsigned char *sigbuf,
251 unsigned int siglen, void *key); 255 unsigned int siglen, void *key);
252 256
257typedef struct
258 {
259 EVP_MD_CTX *mctx;
260 void *key;
261 } EVP_MD_SVCTX;
262
253#define EVP_MD_FLAG_ONESHOT 0x0001 /* digest can only handle a single 263#define EVP_MD_FLAG_ONESHOT 0x0001 /* digest can only handle a single
254 * block */ 264 * block */
255 265
266#define EVP_MD_FLAG_FIPS 0x0400 /* Note if suitable for use in FIPS mode */
267
268#define EVP_MD_FLAG_SVCTX 0x0800 /* pass EVP_MD_SVCTX to sign/verify */
269
256#define EVP_PKEY_NULL_method NULL,NULL,{0,0,0,0} 270#define EVP_PKEY_NULL_method NULL,NULL,{0,0,0,0}
257 271
258#ifndef OPENSSL_NO_DSA 272#ifndef OPENSSL_NO_DSA
@@ -306,6 +320,15 @@ struct env_md_ctx_st
306#define EVP_MD_CTX_FLAG_NON_FIPS_ALLOW 0x0008 /* Allow use of non FIPS digest 320#define EVP_MD_CTX_FLAG_NON_FIPS_ALLOW 0x0008 /* Allow use of non FIPS digest
307 * in FIPS mode */ 321 * in FIPS mode */
308 322
323#define EVP_MD_CTX_FLAG_PAD_MASK 0xF0 /* RSA mode to use */
324#define EVP_MD_CTX_FLAG_PAD_PKCS1 0x00 /* PKCS#1 v1.5 mode */
325#define EVP_MD_CTX_FLAG_PAD_X931 0x10 /* X9.31 mode */
326#define EVP_MD_CTX_FLAG_PAD_PSS 0x20 /* PSS mode */
327#define M_EVP_MD_CTX_FLAG_PSS_SALT(ctx) \
328 ((ctx->flags>>16) &0xFFFF) /* seed length */
329#define EVP_MD_CTX_FLAG_PSS_MDLEN 0xFFFF /* salt len same as digest */
330#define EVP_MD_CTX_FLAG_PSS_MREC 0xFFFE /* salt max or auto recovered */
331
309struct evp_cipher_st 332struct evp_cipher_st
310 { 333 {
311 int nid; 334 int nid;
@@ -349,6 +372,14 @@ struct evp_cipher_st
349#define EVP_CIPH_NO_PADDING 0x100 372#define EVP_CIPH_NO_PADDING 0x100
350/* cipher handles random key generation */ 373/* cipher handles random key generation */
351#define EVP_CIPH_RAND_KEY 0x200 374#define EVP_CIPH_RAND_KEY 0x200
375/* Note if suitable for use in FIPS mode */
376#define EVP_CIPH_FLAG_FIPS 0x400
377/* Allow non FIPS cipher in FIPS mode */
378#define EVP_CIPH_FLAG_NON_FIPS_ALLOW 0x800
379/* Allow use default ASN1 get/set iv */
380#define EVP_CIPH_FLAG_DEFAULT_ASN1 0x1000
381/* Buffer length in bits not bytes: CFB1 mode only */
382#define EVP_CIPH_FLAG_LENGTH_BITS 0x2000
352 383
353/* ctrl() values */ 384/* ctrl() values */
354 385
@@ -432,6 +463,18 @@ typedef int (EVP_PBE_KEYGEN)(EVP_CIPHER_CTX *ctx, const char *pass, int passlen,
432#define EVP_get_cipherbynid(a) EVP_get_cipherbyname(OBJ_nid2sn(a)) 463#define EVP_get_cipherbynid(a) EVP_get_cipherbyname(OBJ_nid2sn(a))
433#define EVP_get_cipherbyobj(a) EVP_get_cipherbynid(OBJ_obj2nid(a)) 464#define EVP_get_cipherbyobj(a) EVP_get_cipherbynid(OBJ_obj2nid(a))
434 465
466/* Macros to reduce FIPS dependencies: do NOT use in applications */
467#define M_EVP_MD_size(e) ((e)->md_size)
468#define M_EVP_MD_block_size(e) ((e)->block_size)
469#define M_EVP_MD_CTX_set_flags(ctx,flgs) ((ctx)->flags|=(flgs))
470#define M_EVP_MD_CTX_clear_flags(ctx,flgs) ((ctx)->flags&=~(flgs))
471#define M_EVP_MD_CTX_test_flags(ctx,flgs) ((ctx)->flags&(flgs))
472#define M_EVP_MD_type(e) ((e)->type)
473#define M_EVP_MD_CTX_type(e) M_EVP_MD_type(M_EVP_MD_CTX_md(e))
474#define M_EVP_MD_CTX_md(e) ((e)->digest)
475
476#define M_EVP_CIPHER_CTX_set_flags(ctx,flgs) ((ctx)->flags|=(flgs))
477
435int EVP_MD_type(const EVP_MD *md); 478int EVP_MD_type(const EVP_MD *md);
436#define EVP_MD_nid(e) EVP_MD_type(e) 479#define EVP_MD_nid(e) EVP_MD_type(e)
437#define EVP_MD_name(e) OBJ_nid2sn(EVP_MD_nid(e)) 480#define EVP_MD_name(e) OBJ_nid2sn(EVP_MD_nid(e))
@@ -527,6 +570,10 @@ int EVP_BytesToKey(const EVP_CIPHER *type,const EVP_MD *md,
527 const unsigned char *salt, const unsigned char *data, 570 const unsigned char *salt, const unsigned char *data,
528 int datal, int count, unsigned char *key,unsigned char *iv); 571 int datal, int count, unsigned char *key,unsigned char *iv);
529 572
573void EVP_CIPHER_CTX_set_flags(EVP_CIPHER_CTX *ctx, int flags);
574void EVP_CIPHER_CTX_clear_flags(EVP_CIPHER_CTX *ctx, int flags);
575int EVP_CIPHER_CTX_test_flags(const EVP_CIPHER_CTX *ctx,int flags);
576
530int EVP_EncryptInit(EVP_CIPHER_CTX *ctx,const EVP_CIPHER *cipher, 577int EVP_EncryptInit(EVP_CIPHER_CTX *ctx,const EVP_CIPHER *cipher,
531 const unsigned char *key, const unsigned char *iv); 578 const unsigned char *key, const unsigned char *iv);
532int EVP_EncryptInit_ex(EVP_CIPHER_CTX *ctx,const EVP_CIPHER *cipher, ENGINE *impl, 579int EVP_EncryptInit_ex(EVP_CIPHER_CTX *ctx,const EVP_CIPHER *cipher, ENGINE *impl,
@@ -885,6 +932,24 @@ int EVP_PBE_alg_add(int nid, const EVP_CIPHER *cipher, const EVP_MD *md,
885 EVP_PBE_KEYGEN *keygen); 932 EVP_PBE_KEYGEN *keygen);
886void EVP_PBE_cleanup(void); 933void EVP_PBE_cleanup(void);
887 934
935#ifdef OPENSSL_FIPS
936#ifndef OPENSSL_NO_ENGINE
937void int_EVP_MD_set_engine_callbacks(
938 int (*eng_md_init)(ENGINE *impl),
939 int (*eng_md_fin)(ENGINE *impl),
940 int (*eng_md_evp)
941 (EVP_MD_CTX *ctx, const EVP_MD **ptype, ENGINE *impl));
942void int_EVP_MD_init_engine_callbacks(void);
943void int_EVP_CIPHER_set_engine_callbacks(
944 int (*eng_ciph_fin)(ENGINE *impl),
945 int (*eng_ciph_evp)
946 (EVP_CIPHER_CTX *ctx, const EVP_CIPHER **pciph, ENGINE *impl));
947void int_EVP_CIPHER_init_engine_callbacks(void);
948#endif
949#endif
950
951void EVP_add_alg_module(void);
952
888/* BEGIN ERROR CODES */ 953/* BEGIN ERROR CODES */
889/* The following lines are auto generated by the script mkerr.pl. Any changes 954/* The following lines are auto generated by the script mkerr.pl. Any changes
890 * made after this point may be overwritten when the script is next run. 955 * made after this point may be overwritten when the script is next run.
@@ -895,16 +960,23 @@ void ERR_load_EVP_strings(void);
895 960
896/* Function codes. */ 961/* Function codes. */
897#define EVP_F_AES_INIT_KEY 133 962#define EVP_F_AES_INIT_KEY 133
963#define EVP_F_ALG_MODULE_INIT 138
898#define EVP_F_CAMELLIA_INIT_KEY 159 964#define EVP_F_CAMELLIA_INIT_KEY 159
899#define EVP_F_D2I_PKEY 100 965#define EVP_F_D2I_PKEY 100
966#define EVP_F_DO_EVP_ENC_ENGINE 140
967#define EVP_F_DO_EVP_ENC_ENGINE_FULL 141
968#define EVP_F_DO_EVP_MD_ENGINE 139
969#define EVP_F_DO_EVP_MD_ENGINE_FULL 142
900#define EVP_F_DSAPKEY2PKCS8 134 970#define EVP_F_DSAPKEY2PKCS8 134
901#define EVP_F_DSA_PKEY2PKCS8 135 971#define EVP_F_DSA_PKEY2PKCS8 135
902#define EVP_F_ECDSA_PKEY2PKCS8 129 972#define EVP_F_ECDSA_PKEY2PKCS8 129
903#define EVP_F_ECKEY_PKEY2PKCS8 132 973#define EVP_F_ECKEY_PKEY2PKCS8 132
974#define EVP_F_EVP_CIPHERINIT 137
904#define EVP_F_EVP_CIPHERINIT_EX 123 975#define EVP_F_EVP_CIPHERINIT_EX 123
905#define EVP_F_EVP_CIPHER_CTX_CTRL 124 976#define EVP_F_EVP_CIPHER_CTX_CTRL 124
906#define EVP_F_EVP_CIPHER_CTX_SET_KEY_LENGTH 122 977#define EVP_F_EVP_CIPHER_CTX_SET_KEY_LENGTH 122
907#define EVP_F_EVP_DECRYPTFINAL_EX 101 978#define EVP_F_EVP_DECRYPTFINAL_EX 101
979#define EVP_F_EVP_DIGESTINIT 136
908#define EVP_F_EVP_DIGESTINIT_EX 128 980#define EVP_F_EVP_DIGESTINIT_EX 128
909#define EVP_F_EVP_ENCRYPTFINAL_EX 127 981#define EVP_F_EVP_ENCRYPTFINAL_EX 127
910#define EVP_F_EVP_MD_CTX_COPY_EX 110 982#define EVP_F_EVP_MD_CTX_COPY_EX 110
@@ -946,15 +1018,20 @@ void ERR_load_EVP_strings(void);
946#define EVP_R_DATA_NOT_MULTIPLE_OF_BLOCK_LENGTH 138 1018#define EVP_R_DATA_NOT_MULTIPLE_OF_BLOCK_LENGTH 138
947#define EVP_R_DECODE_ERROR 114 1019#define EVP_R_DECODE_ERROR 114
948#define EVP_R_DIFFERENT_KEY_TYPES 101 1020#define EVP_R_DIFFERENT_KEY_TYPES 101
1021#define EVP_R_DISABLED_FOR_FIPS 144
949#define EVP_R_ENCODE_ERROR 115 1022#define EVP_R_ENCODE_ERROR 115
1023#define EVP_R_ERROR_LOADING_SECTION 145
1024#define EVP_R_ERROR_SETTING_FIPS_MODE 146
950#define EVP_R_EVP_PBE_CIPHERINIT_ERROR 119 1025#define EVP_R_EVP_PBE_CIPHERINIT_ERROR 119
951#define EVP_R_EXPECTING_AN_RSA_KEY 127 1026#define EVP_R_EXPECTING_AN_RSA_KEY 127
952#define EVP_R_EXPECTING_A_DH_KEY 128 1027#define EVP_R_EXPECTING_A_DH_KEY 128
953#define EVP_R_EXPECTING_A_DSA_KEY 129 1028#define EVP_R_EXPECTING_A_DSA_KEY 129
954#define EVP_R_EXPECTING_A_ECDSA_KEY 141 1029#define EVP_R_EXPECTING_A_ECDSA_KEY 141
955#define EVP_R_EXPECTING_A_EC_KEY 142 1030#define EVP_R_EXPECTING_A_EC_KEY 142
1031#define EVP_R_FIPS_MODE_NOT_SUPPORTED 147
956#define EVP_R_INITIALIZATION_ERROR 134 1032#define EVP_R_INITIALIZATION_ERROR 134
957#define EVP_R_INPUT_NOT_INITIALIZED 111 1033#define EVP_R_INPUT_NOT_INITIALIZED 111
1034#define EVP_R_INVALID_FIPS_MODE 148
958#define EVP_R_INVALID_KEY_LENGTH 130 1035#define EVP_R_INVALID_KEY_LENGTH 130
959#define EVP_R_IV_TOO_LARGE 102 1036#define EVP_R_IV_TOO_LARGE 102
960#define EVP_R_KEYGEN_FAILURE 120 1037#define EVP_R_KEYGEN_FAILURE 120
@@ -966,6 +1043,7 @@ void ERR_load_EVP_strings(void);
966#define EVP_R_NO_VERIFY_FUNCTION_CONFIGURED 105 1043#define EVP_R_NO_VERIFY_FUNCTION_CONFIGURED 105
967#define EVP_R_PKCS8_UNKNOWN_BROKEN_TYPE 117 1044#define EVP_R_PKCS8_UNKNOWN_BROKEN_TYPE 117
968#define EVP_R_PUBLIC_KEY_NOT_RSA 106 1045#define EVP_R_PUBLIC_KEY_NOT_RSA 106
1046#define EVP_R_UNKNOWN_OPTION 149
969#define EVP_R_UNKNOWN_PBE_ALGORITHM 121 1047#define EVP_R_UNKNOWN_PBE_ALGORITHM 121
970#define EVP_R_UNSUPORTED_NUMBER_OF_ROUNDS 135 1048#define EVP_R_UNSUPORTED_NUMBER_OF_ROUNDS 135
971#define EVP_R_UNSUPPORTED_CIPHER 107 1049#define EVP_R_UNSUPPORTED_CIPHER 107
diff --git a/src/lib/libcrypto/evp/evp_acnf.c b/src/lib/libcrypto/evp/evp_acnf.c
index ff3e311cc5..643a1864e8 100644
--- a/src/lib/libcrypto/evp/evp_acnf.c
+++ b/src/lib/libcrypto/evp/evp_acnf.c
@@ -1,5 +1,5 @@
1/* evp_acnf.c */ 1/* evp_acnf.c */
2/* Written by Stephen Henson (shenson@bigfoot.com) for the OpenSSL 2/* Written by Stephen Henson (steve@openssl.org) for the OpenSSL
3 * project 2001. 3 * project 2001.
4 */ 4 */
5/* ==================================================================== 5/* ====================================================================
diff --git a/src/lib/libcrypto/evp/evp_enc.c b/src/lib/libcrypto/evp/evp_enc.c
index 6e582c458d..30e0ca4d9f 100644
--- a/src/lib/libcrypto/evp/evp_enc.c
+++ b/src/lib/libcrypto/evp/evp_enc.c
@@ -66,13 +66,15 @@
66#endif 66#endif
67#include "evp_locl.h" 67#include "evp_locl.h"
68 68
69const char EVP_version[]="EVP" OPENSSL_VERSION_PTEXT; 69#ifdef OPENSSL_FIPS
70 #define M_do_cipher(ctx, out, in, inl) \
71 EVP_Cipher(ctx,out,in,inl)
72#else
73 #define M_do_cipher(ctx, out, in, inl) \
74 ctx->cipher->do_cipher(ctx,out,in,inl)
75#endif
70 76
71void EVP_CIPHER_CTX_init(EVP_CIPHER_CTX *ctx) 77const char EVP_version[]="EVP" OPENSSL_VERSION_PTEXT;
72 {
73 memset(ctx,0,sizeof(EVP_CIPHER_CTX));
74 /* ctx->cipher=NULL; */
75 }
76 78
77EVP_CIPHER_CTX *EVP_CIPHER_CTX_new(void) 79EVP_CIPHER_CTX *EVP_CIPHER_CTX_new(void)
78 { 80 {
@@ -90,144 +92,6 @@ int EVP_CipherInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher,
90 return EVP_CipherInit_ex(ctx,cipher,NULL,key,iv,enc); 92 return EVP_CipherInit_ex(ctx,cipher,NULL,key,iv,enc);
91 } 93 }
92 94
93int EVP_CipherInit_ex(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher, ENGINE *impl,
94 const unsigned char *key, const unsigned char *iv, int enc)
95 {
96 if (enc == -1)
97 enc = ctx->encrypt;
98 else
99 {
100 if (enc)
101 enc = 1;
102 ctx->encrypt = enc;
103 }
104#ifndef OPENSSL_NO_ENGINE
105 /* Whether it's nice or not, "Inits" can be used on "Final"'d contexts
106 * so this context may already have an ENGINE! Try to avoid releasing
107 * the previous handle, re-querying for an ENGINE, and having a
108 * reinitialisation, when it may all be unecessary. */
109 if (ctx->engine && ctx->cipher && (!cipher ||
110 (cipher && (cipher->nid == ctx->cipher->nid))))
111 goto skip_to_init;
112#endif
113 if (cipher)
114 {
115 /* Ensure a context left lying around from last time is cleared
116 * (the previous check attempted to avoid this if the same
117 * ENGINE and EVP_CIPHER could be used). */
118 EVP_CIPHER_CTX_cleanup(ctx);
119
120 /* Restore encrypt field: it is zeroed by cleanup */
121 ctx->encrypt = enc;
122#ifndef OPENSSL_NO_ENGINE
123 if(impl)
124 {
125 if (!ENGINE_init(impl))
126 {
127 EVPerr(EVP_F_EVP_CIPHERINIT_EX, EVP_R_INITIALIZATION_ERROR);
128 return 0;
129 }
130 }
131 else
132 /* Ask if an ENGINE is reserved for this job */
133 impl = ENGINE_get_cipher_engine(cipher->nid);
134 if(impl)
135 {
136 /* There's an ENGINE for this job ... (apparently) */
137 const EVP_CIPHER *c = ENGINE_get_cipher(impl, cipher->nid);
138 if(!c)
139 {
140 /* One positive side-effect of US's export
141 * control history, is that we should at least
142 * be able to avoid using US mispellings of
143 * "initialisation"? */
144 EVPerr(EVP_F_EVP_CIPHERINIT_EX, EVP_R_INITIALIZATION_ERROR);
145 return 0;
146 }
147 /* We'll use the ENGINE's private cipher definition */
148 cipher = c;
149 /* Store the ENGINE functional reference so we know
150 * 'cipher' came from an ENGINE and we need to release
151 * it when done. */
152 ctx->engine = impl;
153 }
154 else
155 ctx->engine = NULL;
156#endif
157
158 ctx->cipher=cipher;
159 if (ctx->cipher->ctx_size)
160 {
161 ctx->cipher_data=OPENSSL_malloc(ctx->cipher->ctx_size);
162 if (!ctx->cipher_data)
163 {
164 EVPerr(EVP_F_EVP_CIPHERINIT_EX, ERR_R_MALLOC_FAILURE);
165 return 0;
166 }
167 }
168 else
169 {
170 ctx->cipher_data = NULL;
171 }
172 ctx->key_len = cipher->key_len;
173 ctx->flags = 0;
174 if(ctx->cipher->flags & EVP_CIPH_CTRL_INIT)
175 {
176 if(!EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_INIT, 0, NULL))
177 {
178 EVPerr(EVP_F_EVP_CIPHERINIT_EX, EVP_R_INITIALIZATION_ERROR);
179 return 0;
180 }
181 }
182 }
183 else if(!ctx->cipher)
184 {
185 EVPerr(EVP_F_EVP_CIPHERINIT_EX, EVP_R_NO_CIPHER_SET);
186 return 0;
187 }
188#ifndef OPENSSL_NO_ENGINE
189skip_to_init:
190#endif
191 /* we assume block size is a power of 2 in *cryptUpdate */
192 OPENSSL_assert(ctx->cipher->block_size == 1
193 || ctx->cipher->block_size == 8
194 || ctx->cipher->block_size == 16);
195
196 if(!(EVP_CIPHER_CTX_flags(ctx) & EVP_CIPH_CUSTOM_IV)) {
197 switch(EVP_CIPHER_CTX_mode(ctx)) {
198
199 case EVP_CIPH_STREAM_CIPHER:
200 case EVP_CIPH_ECB_MODE:
201 break;
202
203 case EVP_CIPH_CFB_MODE:
204 case EVP_CIPH_OFB_MODE:
205
206 ctx->num = 0;
207
208 case EVP_CIPH_CBC_MODE:
209
210 OPENSSL_assert(EVP_CIPHER_CTX_iv_length(ctx) <=
211 (int)sizeof(ctx->iv));
212 if(iv) memcpy(ctx->oiv, iv, EVP_CIPHER_CTX_iv_length(ctx));
213 memcpy(ctx->iv, ctx->oiv, EVP_CIPHER_CTX_iv_length(ctx));
214 break;
215
216 default:
217 return 0;
218 break;
219 }
220 }
221
222 if(key || (ctx->cipher->flags & EVP_CIPH_ALWAYS_CALL_INIT)) {
223 if(!ctx->cipher->init(ctx,key,iv,enc)) return 0;
224 }
225 ctx->buf_len=0;
226 ctx->final_used=0;
227 ctx->block_mask=ctx->cipher->block_size-1;
228 return 1;
229 }
230
231int EVP_CipherUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl, 95int EVP_CipherUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl,
232 const unsigned char *in, int inl) 96 const unsigned char *in, int inl)
233 { 97 {
@@ -287,7 +151,7 @@ int EVP_EncryptUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl,
287 151
288 if(ctx->buf_len == 0 && (inl&(ctx->block_mask)) == 0) 152 if(ctx->buf_len == 0 && (inl&(ctx->block_mask)) == 0)
289 { 153 {
290 if(ctx->cipher->do_cipher(ctx,out,in,inl)) 154 if(M_do_cipher(ctx,out,in,inl))
291 { 155 {
292 *outl=inl; 156 *outl=inl;
293 return 1; 157 return 1;
@@ -314,7 +178,7 @@ int EVP_EncryptUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl,
314 { 178 {
315 j=bl-i; 179 j=bl-i;
316 memcpy(&(ctx->buf[i]),in,j); 180 memcpy(&(ctx->buf[i]),in,j);
317 if(!ctx->cipher->do_cipher(ctx,out,ctx->buf,bl)) return 0; 181 if(!M_do_cipher(ctx,out,ctx->buf,bl)) return 0;
318 inl-=j; 182 inl-=j;
319 in+=j; 183 in+=j;
320 out+=bl; 184 out+=bl;
@@ -327,7 +191,7 @@ int EVP_EncryptUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl,
327 inl-=i; 191 inl-=i;
328 if (inl > 0) 192 if (inl > 0)
329 { 193 {
330 if(!ctx->cipher->do_cipher(ctx,out,in,inl)) return 0; 194 if(!M_do_cipher(ctx,out,in,inl)) return 0;
331 *outl+=inl; 195 *outl+=inl;
332 } 196 }
333 197
@@ -371,7 +235,7 @@ int EVP_EncryptFinal_ex(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl)
371 n=b-bl; 235 n=b-bl;
372 for (i=bl; i<b; i++) 236 for (i=bl; i<b; i++)
373 ctx->buf[i]=n; 237 ctx->buf[i]=n;
374 ret=ctx->cipher->do_cipher(ctx,out,ctx->buf,b); 238 ret=M_do_cipher(ctx,out,ctx->buf,b);
375 239
376 240
377 if(ret) 241 if(ret)
@@ -493,28 +357,6 @@ void EVP_CIPHER_CTX_free(EVP_CIPHER_CTX *ctx)
493 } 357 }
494 } 358 }
495 359
496int EVP_CIPHER_CTX_cleanup(EVP_CIPHER_CTX *c)
497 {
498 if (c->cipher != NULL)
499 {
500 if(c->cipher->cleanup && !c->cipher->cleanup(c))
501 return 0;
502 /* Cleanse cipher context data */
503 if (c->cipher_data)
504 OPENSSL_cleanse(c->cipher_data, c->cipher->ctx_size);
505 }
506 if (c->cipher_data)
507 OPENSSL_free(c->cipher_data);
508#ifndef OPENSSL_NO_ENGINE
509 if (c->engine)
510 /* The EVP_CIPHER we used belongs to an ENGINE, release the
511 * functional reference we held for this reason. */
512 ENGINE_finish(c->engine);
513#endif
514 memset(c,0,sizeof(EVP_CIPHER_CTX));
515 return 1;
516 }
517
518int EVP_CIPHER_CTX_set_key_length(EVP_CIPHER_CTX *c, int keylen) 360int EVP_CIPHER_CTX_set_key_length(EVP_CIPHER_CTX *c, int keylen)
519 { 361 {
520 if(c->cipher->flags & EVP_CIPH_CUSTOM_KEY_LENGTH) 362 if(c->cipher->flags & EVP_CIPH_CUSTOM_KEY_LENGTH)
@@ -536,27 +378,6 @@ int EVP_CIPHER_CTX_set_padding(EVP_CIPHER_CTX *ctx, int pad)
536 return 1; 378 return 1;
537 } 379 }
538 380
539int EVP_CIPHER_CTX_ctrl(EVP_CIPHER_CTX *ctx, int type, int arg, void *ptr)
540{
541 int ret;
542 if(!ctx->cipher) {
543 EVPerr(EVP_F_EVP_CIPHER_CTX_CTRL, EVP_R_NO_CIPHER_SET);
544 return 0;
545 }
546
547 if(!ctx->cipher->ctrl) {
548 EVPerr(EVP_F_EVP_CIPHER_CTX_CTRL, EVP_R_CTRL_NOT_IMPLEMENTED);
549 return 0;
550 }
551
552 ret = ctx->cipher->ctrl(ctx, type, arg, ptr);
553 if(ret == -1) {
554 EVPerr(EVP_F_EVP_CIPHER_CTX_CTRL, EVP_R_CTRL_OPERATION_NOT_IMPLEMENTED);
555 return 0;
556 }
557 return ret;
558}
559
560int EVP_CIPHER_CTX_rand_key(EVP_CIPHER_CTX *ctx, unsigned char *key) 381int EVP_CIPHER_CTX_rand_key(EVP_CIPHER_CTX *ctx, unsigned char *key)
561 { 382 {
562 if (ctx->cipher->flags & EVP_CIPH_RAND_KEY) 383 if (ctx->cipher->flags & EVP_CIPH_RAND_KEY)
@@ -566,3 +387,54 @@ int EVP_CIPHER_CTX_rand_key(EVP_CIPHER_CTX *ctx, unsigned char *key)
566 return 1; 387 return 1;
567 } 388 }
568 389
390#ifndef OPENSSL_NO_ENGINE
391
392#ifdef OPENSSL_FIPS
393
394static int do_evp_enc_engine_full(EVP_CIPHER_CTX *ctx, const EVP_CIPHER **pcipher, ENGINE *impl)
395 {
396 if(impl)
397 {
398 if (!ENGINE_init(impl))
399 {
400 EVPerr(EVP_F_DO_EVP_ENC_ENGINE_FULL, EVP_R_INITIALIZATION_ERROR);
401 return 0;
402 }
403 }
404 else
405 /* Ask if an ENGINE is reserved for this job */
406 impl = ENGINE_get_cipher_engine((*pcipher)->nid);
407 if(impl)
408 {
409 /* There's an ENGINE for this job ... (apparently) */
410 const EVP_CIPHER *c = ENGINE_get_cipher(impl, (*pcipher)->nid);
411 if(!c)
412 {
413 /* One positive side-effect of US's export
414 * control history, is that we should at least
415 * be able to avoid using US mispellings of
416 * "initialisation"? */
417 EVPerr(EVP_F_DO_EVP_ENC_ENGINE_FULL, EVP_R_INITIALIZATION_ERROR);
418 return 0;
419 }
420 /* We'll use the ENGINE's private cipher definition */
421 *pcipher = c;
422 /* Store the ENGINE functional reference so we know
423 * 'cipher' came from an ENGINE and we need to release
424 * it when done. */
425 ctx->engine = impl;
426 }
427 else
428 ctx->engine = NULL;
429 return 1;
430 }
431
432void int_EVP_CIPHER_init_engine_callbacks(void)
433 {
434 int_EVP_CIPHER_set_engine_callbacks(
435 ENGINE_finish, do_evp_enc_engine_full);
436 }
437
438#endif
439
440#endif
diff --git a/src/lib/libcrypto/evp/evp_err.c b/src/lib/libcrypto/evp/evp_err.c
index e8c9e8de9c..b5b900d4fe 100644
--- a/src/lib/libcrypto/evp/evp_err.c
+++ b/src/lib/libcrypto/evp/evp_err.c
@@ -1,6 +1,6 @@
1/* crypto/evp/evp_err.c */ 1/* crypto/evp/evp_err.c */
2/* ==================================================================== 2/* ====================================================================
3 * Copyright (c) 1999-2005 The OpenSSL Project. All rights reserved. 3 * Copyright (c) 1999-2007 The OpenSSL Project. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
@@ -71,16 +71,23 @@
71static ERR_STRING_DATA EVP_str_functs[]= 71static ERR_STRING_DATA EVP_str_functs[]=
72 { 72 {
73{ERR_FUNC(EVP_F_AES_INIT_KEY), "AES_INIT_KEY"}, 73{ERR_FUNC(EVP_F_AES_INIT_KEY), "AES_INIT_KEY"},
74{ERR_FUNC(EVP_F_ALG_MODULE_INIT), "ALG_MODULE_INIT"},
74{ERR_FUNC(EVP_F_CAMELLIA_INIT_KEY), "CAMELLIA_INIT_KEY"}, 75{ERR_FUNC(EVP_F_CAMELLIA_INIT_KEY), "CAMELLIA_INIT_KEY"},
75{ERR_FUNC(EVP_F_D2I_PKEY), "D2I_PKEY"}, 76{ERR_FUNC(EVP_F_D2I_PKEY), "D2I_PKEY"},
77{ERR_FUNC(EVP_F_DO_EVP_ENC_ENGINE), "DO_EVP_ENC_ENGINE"},
78{ERR_FUNC(EVP_F_DO_EVP_ENC_ENGINE_FULL), "DO_EVP_ENC_ENGINE_FULL"},
79{ERR_FUNC(EVP_F_DO_EVP_MD_ENGINE), "DO_EVP_MD_ENGINE"},
80{ERR_FUNC(EVP_F_DO_EVP_MD_ENGINE_FULL), "DO_EVP_MD_ENGINE_FULL"},
76{ERR_FUNC(EVP_F_DSAPKEY2PKCS8), "DSAPKEY2PKCS8"}, 81{ERR_FUNC(EVP_F_DSAPKEY2PKCS8), "DSAPKEY2PKCS8"},
77{ERR_FUNC(EVP_F_DSA_PKEY2PKCS8), "DSA_PKEY2PKCS8"}, 82{ERR_FUNC(EVP_F_DSA_PKEY2PKCS8), "DSA_PKEY2PKCS8"},
78{ERR_FUNC(EVP_F_ECDSA_PKEY2PKCS8), "ECDSA_PKEY2PKCS8"}, 83{ERR_FUNC(EVP_F_ECDSA_PKEY2PKCS8), "ECDSA_PKEY2PKCS8"},
79{ERR_FUNC(EVP_F_ECKEY_PKEY2PKCS8), "ECKEY_PKEY2PKCS8"}, 84{ERR_FUNC(EVP_F_ECKEY_PKEY2PKCS8), "ECKEY_PKEY2PKCS8"},
85{ERR_FUNC(EVP_F_EVP_CIPHERINIT), "EVP_CipherInit"},
80{ERR_FUNC(EVP_F_EVP_CIPHERINIT_EX), "EVP_CipherInit_ex"}, 86{ERR_FUNC(EVP_F_EVP_CIPHERINIT_EX), "EVP_CipherInit_ex"},
81{ERR_FUNC(EVP_F_EVP_CIPHER_CTX_CTRL), "EVP_CIPHER_CTX_ctrl"}, 87{ERR_FUNC(EVP_F_EVP_CIPHER_CTX_CTRL), "EVP_CIPHER_CTX_ctrl"},
82{ERR_FUNC(EVP_F_EVP_CIPHER_CTX_SET_KEY_LENGTH), "EVP_CIPHER_CTX_set_key_length"}, 88{ERR_FUNC(EVP_F_EVP_CIPHER_CTX_SET_KEY_LENGTH), "EVP_CIPHER_CTX_set_key_length"},
83{ERR_FUNC(EVP_F_EVP_DECRYPTFINAL_EX), "EVP_DecryptFinal_ex"}, 89{ERR_FUNC(EVP_F_EVP_DECRYPTFINAL_EX), "EVP_DecryptFinal_ex"},
90{ERR_FUNC(EVP_F_EVP_DIGESTINIT), "EVP_DigestInit"},
84{ERR_FUNC(EVP_F_EVP_DIGESTINIT_EX), "EVP_DigestInit_ex"}, 91{ERR_FUNC(EVP_F_EVP_DIGESTINIT_EX), "EVP_DigestInit_ex"},
85{ERR_FUNC(EVP_F_EVP_ENCRYPTFINAL_EX), "EVP_EncryptFinal_ex"}, 92{ERR_FUNC(EVP_F_EVP_ENCRYPTFINAL_EX), "EVP_EncryptFinal_ex"},
86{ERR_FUNC(EVP_F_EVP_MD_CTX_COPY_EX), "EVP_MD_CTX_copy_ex"}, 93{ERR_FUNC(EVP_F_EVP_MD_CTX_COPY_EX), "EVP_MD_CTX_copy_ex"},
@@ -125,15 +132,20 @@ static ERR_STRING_DATA EVP_str_reasons[]=
125{ERR_REASON(EVP_R_DATA_NOT_MULTIPLE_OF_BLOCK_LENGTH),"data not multiple of block length"}, 132{ERR_REASON(EVP_R_DATA_NOT_MULTIPLE_OF_BLOCK_LENGTH),"data not multiple of block length"},
126{ERR_REASON(EVP_R_DECODE_ERROR) ,"decode error"}, 133{ERR_REASON(EVP_R_DECODE_ERROR) ,"decode error"},
127{ERR_REASON(EVP_R_DIFFERENT_KEY_TYPES) ,"different key types"}, 134{ERR_REASON(EVP_R_DIFFERENT_KEY_TYPES) ,"different key types"},
135{ERR_REASON(EVP_R_DISABLED_FOR_FIPS) ,"disabled for fips"},
128{ERR_REASON(EVP_R_ENCODE_ERROR) ,"encode error"}, 136{ERR_REASON(EVP_R_ENCODE_ERROR) ,"encode error"},
137{ERR_REASON(EVP_R_ERROR_LOADING_SECTION) ,"error loading section"},
138{ERR_REASON(EVP_R_ERROR_SETTING_FIPS_MODE),"error setting fips mode"},
129{ERR_REASON(EVP_R_EVP_PBE_CIPHERINIT_ERROR),"evp pbe cipherinit error"}, 139{ERR_REASON(EVP_R_EVP_PBE_CIPHERINIT_ERROR),"evp pbe cipherinit error"},
130{ERR_REASON(EVP_R_EXPECTING_AN_RSA_KEY) ,"expecting an rsa key"}, 140{ERR_REASON(EVP_R_EXPECTING_AN_RSA_KEY) ,"expecting an rsa key"},
131{ERR_REASON(EVP_R_EXPECTING_A_DH_KEY) ,"expecting a dh key"}, 141{ERR_REASON(EVP_R_EXPECTING_A_DH_KEY) ,"expecting a dh key"},
132{ERR_REASON(EVP_R_EXPECTING_A_DSA_KEY) ,"expecting a dsa key"}, 142{ERR_REASON(EVP_R_EXPECTING_A_DSA_KEY) ,"expecting a dsa key"},
133{ERR_REASON(EVP_R_EXPECTING_A_ECDSA_KEY) ,"expecting a ecdsa key"}, 143{ERR_REASON(EVP_R_EXPECTING_A_ECDSA_KEY) ,"expecting a ecdsa key"},
134{ERR_REASON(EVP_R_EXPECTING_A_EC_KEY) ,"expecting a ec key"}, 144{ERR_REASON(EVP_R_EXPECTING_A_EC_KEY) ,"expecting a ec key"},
145{ERR_REASON(EVP_R_FIPS_MODE_NOT_SUPPORTED),"fips mode not supported"},
135{ERR_REASON(EVP_R_INITIALIZATION_ERROR) ,"initialization error"}, 146{ERR_REASON(EVP_R_INITIALIZATION_ERROR) ,"initialization error"},
136{ERR_REASON(EVP_R_INPUT_NOT_INITIALIZED) ,"input not initialized"}, 147{ERR_REASON(EVP_R_INPUT_NOT_INITIALIZED) ,"input not initialized"},
148{ERR_REASON(EVP_R_INVALID_FIPS_MODE) ,"invalid fips mode"},
137{ERR_REASON(EVP_R_INVALID_KEY_LENGTH) ,"invalid key length"}, 149{ERR_REASON(EVP_R_INVALID_KEY_LENGTH) ,"invalid key length"},
138{ERR_REASON(EVP_R_IV_TOO_LARGE) ,"iv too large"}, 150{ERR_REASON(EVP_R_IV_TOO_LARGE) ,"iv too large"},
139{ERR_REASON(EVP_R_KEYGEN_FAILURE) ,"keygen failure"}, 151{ERR_REASON(EVP_R_KEYGEN_FAILURE) ,"keygen failure"},
@@ -145,6 +157,8 @@ static ERR_STRING_DATA EVP_str_reasons[]=
145{ERR_REASON(EVP_R_NO_VERIFY_FUNCTION_CONFIGURED),"no verify function configured"}, 157{ERR_REASON(EVP_R_NO_VERIFY_FUNCTION_CONFIGURED),"no verify function configured"},
146{ERR_REASON(EVP_R_PKCS8_UNKNOWN_BROKEN_TYPE),"pkcs8 unknown broken type"}, 158{ERR_REASON(EVP_R_PKCS8_UNKNOWN_BROKEN_TYPE),"pkcs8 unknown broken type"},
147{ERR_REASON(EVP_R_PUBLIC_KEY_NOT_RSA) ,"public key not rsa"}, 159{ERR_REASON(EVP_R_PUBLIC_KEY_NOT_RSA) ,"public key not rsa"},
160{ERR_REASON(EVP_R_SEED_KEY_SETUP_FAILED) ,"seed key setup failed"},
161{ERR_REASON(EVP_R_UNKNOWN_OPTION) ,"unknown option"},
148{ERR_REASON(EVP_R_UNKNOWN_PBE_ALGORITHM) ,"unknown pbe algorithm"}, 162{ERR_REASON(EVP_R_UNKNOWN_PBE_ALGORITHM) ,"unknown pbe algorithm"},
149{ERR_REASON(EVP_R_UNSUPORTED_NUMBER_OF_ROUNDS),"unsuported number of rounds"}, 163{ERR_REASON(EVP_R_UNSUPORTED_NUMBER_OF_ROUNDS),"unsuported number of rounds"},
150{ERR_REASON(EVP_R_UNSUPPORTED_CIPHER) ,"unsupported cipher"}, 164{ERR_REASON(EVP_R_UNSUPPORTED_CIPHER) ,"unsupported cipher"},
diff --git a/src/lib/libcrypto/evp/evp_lib.c b/src/lib/libcrypto/evp/evp_lib.c
index edb28ef38e..174cf6c594 100644
--- a/src/lib/libcrypto/evp/evp_lib.c
+++ b/src/lib/libcrypto/evp/evp_lib.c
@@ -67,6 +67,8 @@ int EVP_CIPHER_param_to_asn1(EVP_CIPHER_CTX *c, ASN1_TYPE *type)
67 67
68 if (c->cipher->set_asn1_parameters != NULL) 68 if (c->cipher->set_asn1_parameters != NULL)
69 ret=c->cipher->set_asn1_parameters(c,type); 69 ret=c->cipher->set_asn1_parameters(c,type);
70 else if (c->cipher->flags & EVP_CIPH_FLAG_DEFAULT_ASN1)
71 ret=EVP_CIPHER_set_asn1_iv(c, type);
70 else 72 else
71 ret=-1; 73 ret=-1;
72 return(ret); 74 return(ret);
@@ -78,6 +80,8 @@ int EVP_CIPHER_asn1_to_param(EVP_CIPHER_CTX *c, ASN1_TYPE *type)
78 80
79 if (c->cipher->get_asn1_parameters != NULL) 81 if (c->cipher->get_asn1_parameters != NULL)
80 ret=c->cipher->get_asn1_parameters(c,type); 82 ret=c->cipher->get_asn1_parameters(c,type);
83 else if (c->cipher->flags & EVP_CIPH_FLAG_DEFAULT_ASN1)
84 ret=EVP_CIPHER_get_asn1_iv(c, type);
81 else 85 else
82 ret=-1; 86 ret=-1;
83 return(ret); 87 return(ret);
@@ -178,11 +182,6 @@ int EVP_CIPHER_CTX_block_size(const EVP_CIPHER_CTX *ctx)
178 return ctx->cipher->block_size; 182 return ctx->cipher->block_size;
179 } 183 }
180 184
181int EVP_Cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, unsigned int inl)
182 {
183 return ctx->cipher->do_cipher(ctx,out,in,inl);
184 }
185
186const EVP_CIPHER *EVP_CIPHER_CTX_cipher(const EVP_CIPHER_CTX *ctx) 185const EVP_CIPHER *EVP_CIPHER_CTX_cipher(const EVP_CIPHER_CTX *ctx)
187 { 186 {
188 return ctx->cipher; 187 return ctx->cipher;
@@ -193,11 +192,6 @@ unsigned long EVP_CIPHER_flags(const EVP_CIPHER *cipher)
193 return cipher->flags; 192 return cipher->flags;
194 } 193 }
195 194
196unsigned long EVP_CIPHER_CTX_flags(const EVP_CIPHER_CTX *ctx)
197 {
198 return ctx->cipher->flags;
199 }
200
201void *EVP_CIPHER_CTX_get_app_data(const EVP_CIPHER_CTX *ctx) 195void *EVP_CIPHER_CTX_get_app_data(const EVP_CIPHER_CTX *ctx)
202 { 196 {
203 return ctx->app_data; 197 return ctx->app_data;
@@ -213,11 +207,6 @@ int EVP_CIPHER_iv_length(const EVP_CIPHER *cipher)
213 return cipher->iv_len; 207 return cipher->iv_len;
214 } 208 }
215 209
216int EVP_CIPHER_CTX_iv_length(const EVP_CIPHER_CTX *ctx)
217 {
218 return ctx->cipher->iv_len;
219 }
220
221int EVP_CIPHER_key_length(const EVP_CIPHER *cipher) 210int EVP_CIPHER_key_length(const EVP_CIPHER *cipher)
222 { 211 {
223 return cipher->key_len; 212 return cipher->key_len;
@@ -228,11 +217,6 @@ int EVP_CIPHER_CTX_key_length(const EVP_CIPHER_CTX *ctx)
228 return ctx->key_len; 217 return ctx->key_len;
229 } 218 }
230 219
231int EVP_CIPHER_nid(const EVP_CIPHER *cipher)
232 {
233 return cipher->nid;
234 }
235
236int EVP_CIPHER_CTX_nid(const EVP_CIPHER_CTX *ctx) 220int EVP_CIPHER_CTX_nid(const EVP_CIPHER_CTX *ctx)
237 { 221 {
238 return ctx->cipher->nid; 222 return ctx->cipher->nid;
@@ -277,3 +261,18 @@ int EVP_MD_CTX_test_flags(const EVP_MD_CTX *ctx, int flags)
277 { 261 {
278 return (ctx->flags & flags); 262 return (ctx->flags & flags);
279 } 263 }
264
265void EVP_CIPHER_CTX_set_flags(EVP_CIPHER_CTX *ctx, int flags)
266 {
267 ctx->flags |= flags;
268 }
269
270void EVP_CIPHER_CTX_clear_flags(EVP_CIPHER_CTX *ctx, int flags)
271 {
272 ctx->flags &= ~flags;
273 }
274
275int EVP_CIPHER_CTX_test_flags(const EVP_CIPHER_CTX *ctx, int flags)
276 {
277 return (ctx->flags & flags);
278 }
diff --git a/src/lib/libcrypto/evp/evp_locl.h b/src/lib/libcrypto/evp/evp_locl.h
index 073b0adcff..eabcc96f30 100644
--- a/src/lib/libcrypto/evp/evp_locl.h
+++ b/src/lib/libcrypto/evp/evp_locl.h
@@ -1,5 +1,5 @@
1/* evp_locl.h */ 1/* evp_locl.h */
2/* Written by Dr Stephen N Henson (shenson@bigfoot.com) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 2000. 3 * project 2000.
4 */ 4 */
5/* ==================================================================== 5/* ====================================================================
@@ -92,7 +92,7 @@ static int cname##_cbc_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const uns
92#define BLOCK_CIPHER_func_cfb(cname, cprefix, cbits, kstruct, ksched) \ 92#define BLOCK_CIPHER_func_cfb(cname, cprefix, cbits, kstruct, ksched) \
93static int cname##_cfb##cbits##_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, unsigned int inl) \ 93static int cname##_cfb##cbits##_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, unsigned int inl) \
94{\ 94{\
95 cprefix##_cfb##cbits##_encrypt(in, out, (long)(cbits==1?inl*8:inl), &((kstruct *)ctx->cipher_data)->ksched, ctx->iv, &ctx->num, ctx->encrypt);\ 95 cprefix##_cfb##cbits##_encrypt(in, out, (long)((cbits==1) && !(ctx->flags & EVP_CIPH_FLAG_LENGTH_BITS) ?inl*8:inl), &((kstruct *)ctx->cipher_data)->ksched, ctx->iv, &ctx->num, ctx->encrypt);\
96 return 1;\ 96 return 1;\
97} 97}
98 98
@@ -226,11 +226,27 @@ const EVP_CIPHER *EVP_##cname##_ecb(void) { return &cname##_ecb; }
226 226
227#define EVP_C_DATA(kstruct, ctx) ((kstruct *)(ctx)->cipher_data) 227#define EVP_C_DATA(kstruct, ctx) ((kstruct *)(ctx)->cipher_data)
228 228
229#define IMPLEMENT_CFBR(cipher,cprefix,kstruct,ksched,keysize,cbits,iv_len) \ 229#define IMPLEMENT_CFBR(cipher,cprefix,kstruct,ksched,keysize,cbits,iv_len,fl) \
230 BLOCK_CIPHER_func_cfb(cipher##_##keysize,cprefix,cbits,kstruct,ksched) \ 230 BLOCK_CIPHER_func_cfb(cipher##_##keysize,cprefix,cbits,kstruct,ksched) \
231 BLOCK_CIPHER_def_cfb(cipher##_##keysize,kstruct, \ 231 BLOCK_CIPHER_def_cfb(cipher##_##keysize,kstruct, \
232 NID_##cipher##_##keysize, keysize/8, iv_len, cbits, \ 232 NID_##cipher##_##keysize, keysize/8, iv_len, cbits, \
233 0, cipher##_init_key, NULL, \ 233 (fl)|EVP_CIPH_FLAG_DEFAULT_ASN1, \
234 EVP_CIPHER_set_asn1_iv, \ 234 cipher##_init_key, NULL, NULL, NULL, NULL)
235 EVP_CIPHER_get_asn1_iv, \ 235
236 NULL) 236#ifdef OPENSSL_FIPS
237#define RC2_set_key private_RC2_set_key
238#define RC4_set_key private_RC4_set_key
239#define CAST_set_key private_CAST_set_key
240#define RC5_32_set_key private_RC5_32_set_key
241#define BF_set_key private_BF_set_key
242#define Camellia_set_key private_Camellia_set_key
243#define idea_set_encrypt_key private_idea_set_encrypt_key
244
245#define MD5_Init private_MD5_Init
246#define MD4_Init private_MD4_Init
247#define MD2_Init private_MD2_Init
248#define MDC2_Init private_MDC2_Init
249#define SHA_Init private_SHA_Init
250
251#endif
252
diff --git a/src/lib/libcrypto/evp/evp_pbe.c b/src/lib/libcrypto/evp/evp_pbe.c
index c26d2de0f3..5e830be65f 100644
--- a/src/lib/libcrypto/evp/evp_pbe.c
+++ b/src/lib/libcrypto/evp/evp_pbe.c
@@ -1,5 +1,5 @@
1/* evp_pbe.c */ 1/* evp_pbe.c */
2/* Written by Dr Stephen N Henson (shenson@bigfoot.com) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 1999. 3 * project 1999.
4 */ 4 */
5/* ==================================================================== 5/* ====================================================================
diff --git a/src/lib/libcrypto/evp/evp_pkey.c b/src/lib/libcrypto/evp/evp_pkey.c
index 0147f3e02a..10d9e9e772 100644
--- a/src/lib/libcrypto/evp/evp_pkey.c
+++ b/src/lib/libcrypto/evp/evp_pkey.c
@@ -1,5 +1,5 @@
1/* evp_pkey.c */ 1/* evp_pkey.c */
2/* Written by Dr Stephen N Henson (shenson@bigfoot.com) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 1999. 3 * project 1999.
4 */ 4 */
5/* ==================================================================== 5/* ====================================================================
diff --git a/src/lib/libcrypto/evp/m_dss.c b/src/lib/libcrypto/evp/m_dss.c
index a948c77fa4..6b0c0aa7a3 100644
--- a/src/lib/libcrypto/evp/m_dss.c
+++ b/src/lib/libcrypto/evp/m_dss.c
@@ -81,7 +81,7 @@ static const EVP_MD dsa_md=
81 NID_dsaWithSHA, 81 NID_dsaWithSHA,
82 NID_dsaWithSHA, 82 NID_dsaWithSHA,
83 SHA_DIGEST_LENGTH, 83 SHA_DIGEST_LENGTH,
84 0, 84 EVP_MD_FLAG_FIPS,
85 init, 85 init,
86 update, 86 update,
87 final, 87 final,
diff --git a/src/lib/libcrypto/evp/m_dss1.c b/src/lib/libcrypto/evp/m_dss1.c
index c12e13972b..da8babc147 100644
--- a/src/lib/libcrypto/evp/m_dss1.c
+++ b/src/lib/libcrypto/evp/m_dss1.c
@@ -68,6 +68,8 @@
68#include <openssl/dsa.h> 68#include <openssl/dsa.h>
69#endif 69#endif
70 70
71#ifndef OPENSSL_FIPS
72
71static int init(EVP_MD_CTX *ctx) 73static int init(EVP_MD_CTX *ctx)
72 { return SHA1_Init(ctx->md_data); } 74 { return SHA1_Init(ctx->md_data); }
73 75
@@ -98,3 +100,4 @@ const EVP_MD *EVP_dss1(void)
98 return(&dss1_md); 100 return(&dss1_md);
99 } 101 }
100#endif 102#endif
103#endif
diff --git a/src/lib/libcrypto/evp/m_md2.c b/src/lib/libcrypto/evp/m_md2.c
index 5ce849f161..8eee6236ba 100644
--- a/src/lib/libcrypto/evp/m_md2.c
+++ b/src/lib/libcrypto/evp/m_md2.c
@@ -58,6 +58,7 @@
58 58
59#include <stdio.h> 59#include <stdio.h>
60#include "cryptlib.h" 60#include "cryptlib.h"
61#include "evp_locl.h"
61 62
62#ifndef OPENSSL_NO_MD2 63#ifndef OPENSSL_NO_MD2
63 64
diff --git a/src/lib/libcrypto/evp/m_md4.c b/src/lib/libcrypto/evp/m_md4.c
index 1e0b7c5b42..5cd2ab5ade 100644
--- a/src/lib/libcrypto/evp/m_md4.c
+++ b/src/lib/libcrypto/evp/m_md4.c
@@ -58,6 +58,7 @@
58 58
59#include <stdio.h> 59#include <stdio.h>
60#include "cryptlib.h" 60#include "cryptlib.h"
61#include "evp_locl.h"
61 62
62#ifndef OPENSSL_NO_MD4 63#ifndef OPENSSL_NO_MD4
63 64
diff --git a/src/lib/libcrypto/evp/m_md5.c b/src/lib/libcrypto/evp/m_md5.c
index 63c142119e..6455829671 100644
--- a/src/lib/libcrypto/evp/m_md5.c
+++ b/src/lib/libcrypto/evp/m_md5.c
@@ -62,6 +62,7 @@
62#ifndef OPENSSL_NO_MD5 62#ifndef OPENSSL_NO_MD5
63 63
64#include <openssl/evp.h> 64#include <openssl/evp.h>
65#include "evp_locl.h"
65#include <openssl/objects.h> 66#include <openssl/objects.h>
66#include <openssl/x509.h> 67#include <openssl/x509.h>
67#include <openssl/md5.h> 68#include <openssl/md5.h>
diff --git a/src/lib/libcrypto/evp/m_mdc2.c b/src/lib/libcrypto/evp/m_mdc2.c
index 36c4e9b134..9f9bcf06ed 100644
--- a/src/lib/libcrypto/evp/m_mdc2.c
+++ b/src/lib/libcrypto/evp/m_mdc2.c
@@ -58,6 +58,7 @@
58 58
59#include <stdio.h> 59#include <stdio.h>
60#include "cryptlib.h" 60#include "cryptlib.h"
61#include "evp_locl.h"
61 62
62#ifndef OPENSSL_NO_MDC2 63#ifndef OPENSSL_NO_MDC2
63 64
diff --git a/src/lib/libcrypto/evp/m_sha.c b/src/lib/libcrypto/evp/m_sha.c
index acccc8f92d..3f30dfc579 100644
--- a/src/lib/libcrypto/evp/m_sha.c
+++ b/src/lib/libcrypto/evp/m_sha.c
@@ -58,6 +58,7 @@
58 58
59#include <stdio.h> 59#include <stdio.h>
60#include "cryptlib.h" 60#include "cryptlib.h"
61#include "evp_locl.h"
61 62
62#if !defined(OPENSSL_NO_SHA) && !defined(OPENSSL_NO_SHA0) 63#if !defined(OPENSSL_NO_SHA) && !defined(OPENSSL_NO_SHA0)
63 64
diff --git a/src/lib/libcrypto/evp/m_sha1.c b/src/lib/libcrypto/evp/m_sha1.c
index 4679b1c463..471ec30be0 100644
--- a/src/lib/libcrypto/evp/m_sha1.c
+++ b/src/lib/libcrypto/evp/m_sha1.c
@@ -68,6 +68,8 @@
68#include <openssl/rsa.h> 68#include <openssl/rsa.h>
69#endif 69#endif
70 70
71#ifndef OPENSSL_FIPS
72
71static int init(EVP_MD_CTX *ctx) 73static int init(EVP_MD_CTX *ctx)
72 { return SHA1_Init(ctx->md_data); } 74 { return SHA1_Init(ctx->md_data); }
73 75
@@ -97,7 +99,6 @@ const EVP_MD *EVP_sha1(void)
97 { 99 {
98 return(&sha1_md); 100 return(&sha1_md);
99 } 101 }
100#endif
101 102
102#ifndef OPENSSL_NO_SHA256 103#ifndef OPENSSL_NO_SHA256
103static int init224(EVP_MD_CTX *ctx) 104static int init224(EVP_MD_CTX *ctx)
@@ -202,3 +203,7 @@ static const EVP_MD sha512_md=
202const EVP_MD *EVP_sha512(void) 203const EVP_MD *EVP_sha512(void)
203 { return(&sha512_md); } 204 { return(&sha512_md); }
204#endif /* ifndef OPENSSL_NO_SHA512 */ 205#endif /* ifndef OPENSSL_NO_SHA512 */
206
207#endif
208
209#endif
diff --git a/src/lib/libcrypto/evp/names.c b/src/lib/libcrypto/evp/names.c
index 88c1e780dd..e2e04c3570 100644
--- a/src/lib/libcrypto/evp/names.c
+++ b/src/lib/libcrypto/evp/names.c
@@ -66,6 +66,10 @@ int EVP_add_cipher(const EVP_CIPHER *c)
66 { 66 {
67 int r; 67 int r;
68 68
69#ifdef OPENSSL_FIPS
70 OPENSSL_init();
71#endif
72
69 r=OBJ_NAME_add(OBJ_nid2sn(c->nid),OBJ_NAME_TYPE_CIPHER_METH,(const char *)c); 73 r=OBJ_NAME_add(OBJ_nid2sn(c->nid),OBJ_NAME_TYPE_CIPHER_METH,(const char *)c);
70 if (r == 0) return(0); 74 if (r == 0) return(0);
71 r=OBJ_NAME_add(OBJ_nid2ln(c->nid),OBJ_NAME_TYPE_CIPHER_METH,(const char *)c); 75 r=OBJ_NAME_add(OBJ_nid2ln(c->nid),OBJ_NAME_TYPE_CIPHER_METH,(const char *)c);
@@ -77,6 +81,9 @@ int EVP_add_digest(const EVP_MD *md)
77 int r; 81 int r;
78 const char *name; 82 const char *name;
79 83
84#ifdef OPENSSL_FIPS
85 OPENSSL_init();
86#endif
80 name=OBJ_nid2sn(md->type); 87 name=OBJ_nid2sn(md->type);
81 r=OBJ_NAME_add(name,OBJ_NAME_TYPE_MD_METH,(const char *)md); 88 r=OBJ_NAME_add(name,OBJ_NAME_TYPE_MD_METH,(const char *)md);
82 if (r == 0) return(0); 89 if (r == 0) return(0);
diff --git a/src/lib/libcrypto/evp/p5_crpt.c b/src/lib/libcrypto/evp/p5_crpt.c
index 48d50014a0..2a265fdee2 100644
--- a/src/lib/libcrypto/evp/p5_crpt.c
+++ b/src/lib/libcrypto/evp/p5_crpt.c
@@ -1,5 +1,5 @@
1/* p5_crpt.c */ 1/* p5_crpt.c */
2/* Written by Dr Stephen N Henson (shenson@bigfoot.com) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 1999. 3 * project 1999.
4 */ 4 */
5/* ==================================================================== 5/* ====================================================================
diff --git a/src/lib/libcrypto/evp/p5_crpt2.c b/src/lib/libcrypto/evp/p5_crpt2.c
index c969d5a206..6bec77baf9 100644
--- a/src/lib/libcrypto/evp/p5_crpt2.c
+++ b/src/lib/libcrypto/evp/p5_crpt2.c
@@ -1,5 +1,5 @@
1/* p5_crpt2.c */ 1/* p5_crpt2.c */
2/* Written by Dr Stephen N Henson (shenson@bigfoot.com) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 1999. 3 * project 1999.
4 */ 4 */
5/* ==================================================================== 5/* ====================================================================
diff --git a/src/lib/libcrypto/evp/p_sign.c b/src/lib/libcrypto/evp/p_sign.c
index e4ae5906f5..bf41a0db68 100644
--- a/src/lib/libcrypto/evp/p_sign.c
+++ b/src/lib/libcrypto/evp/p_sign.c
@@ -84,10 +84,6 @@ int EVP_SignFinal(EVP_MD_CTX *ctx, unsigned char *sigret, unsigned int *siglen,
84 MS_STATIC EVP_MD_CTX tmp_ctx; 84 MS_STATIC EVP_MD_CTX tmp_ctx;
85 85
86 *siglen=0; 86 *siglen=0;
87 EVP_MD_CTX_init(&tmp_ctx);
88 EVP_MD_CTX_copy_ex(&tmp_ctx,ctx);
89 EVP_DigestFinal_ex(&tmp_ctx,&(m[0]),&m_len);
90 EVP_MD_CTX_cleanup(&tmp_ctx);
91 for (i=0; i<4; i++) 87 for (i=0; i<4; i++)
92 { 88 {
93 v=ctx->digest->required_pkey_type[i]; 89 v=ctx->digest->required_pkey_type[i];
@@ -108,7 +104,23 @@ int EVP_SignFinal(EVP_MD_CTX *ctx, unsigned char *sigret, unsigned int *siglen,
108 EVPerr(EVP_F_EVP_SIGNFINAL,EVP_R_NO_SIGN_FUNCTION_CONFIGURED); 104 EVPerr(EVP_F_EVP_SIGNFINAL,EVP_R_NO_SIGN_FUNCTION_CONFIGURED);
109 return(0); 105 return(0);
110 } 106 }
111 return(ctx->digest->sign(ctx->digest->type,m,m_len,sigret,siglen, 107 EVP_MD_CTX_init(&tmp_ctx);
112 pkey->pkey.ptr)); 108 EVP_MD_CTX_copy_ex(&tmp_ctx,ctx);
109 if (ctx->digest->flags & EVP_MD_FLAG_SVCTX)
110 {
111 EVP_MD_SVCTX sctmp;
112 sctmp.mctx = &tmp_ctx;
113 sctmp.key = pkey->pkey.ptr;
114 i = ctx->digest->sign(ctx->digest->type,
115 NULL, -1, sigret, siglen, &sctmp);
116 }
117 else
118 {
119 EVP_DigestFinal_ex(&tmp_ctx,&(m[0]),&m_len);
120 i = ctx->digest->sign(ctx->digest->type,m,m_len,sigret,siglen,
121 pkey->pkey.ptr);
122 }
123 EVP_MD_CTX_cleanup(&tmp_ctx);
124 return i;
113 } 125 }
114 126
diff --git a/src/lib/libcrypto/evp/p_verify.c b/src/lib/libcrypto/evp/p_verify.c
index 21a40a375e..2d46dffe7e 100644
--- a/src/lib/libcrypto/evp/p_verify.c
+++ b/src/lib/libcrypto/evp/p_verify.c
@@ -85,17 +85,29 @@ int EVP_VerifyFinal(EVP_MD_CTX *ctx, const unsigned char *sigbuf,
85 EVPerr(EVP_F_EVP_VERIFYFINAL,EVP_R_WRONG_PUBLIC_KEY_TYPE); 85 EVPerr(EVP_F_EVP_VERIFYFINAL,EVP_R_WRONG_PUBLIC_KEY_TYPE);
86 return(-1); 86 return(-1);
87 } 87 }
88 EVP_MD_CTX_init(&tmp_ctx); 88 if (ctx->digest->verify == NULL)
89 EVP_MD_CTX_copy_ex(&tmp_ctx,ctx);
90 EVP_DigestFinal_ex(&tmp_ctx,&(m[0]),&m_len);
91 EVP_MD_CTX_cleanup(&tmp_ctx);
92 if (ctx->digest->verify == NULL)
93 { 89 {
94 EVPerr(EVP_F_EVP_VERIFYFINAL,EVP_R_NO_VERIFY_FUNCTION_CONFIGURED); 90 EVPerr(EVP_F_EVP_VERIFYFINAL,EVP_R_NO_VERIFY_FUNCTION_CONFIGURED);
95 return(0); 91 return(0);
96 } 92 }
97 93
98 return(ctx->digest->verify(ctx->digest->type,m,m_len, 94 EVP_MD_CTX_init(&tmp_ctx);
99 sigbuf,siglen,pkey->pkey.ptr)); 95 EVP_MD_CTX_copy_ex(&tmp_ctx,ctx);
96 if (ctx->digest->flags & EVP_MD_FLAG_SVCTX)
97 {
98 EVP_MD_SVCTX sctmp;
99 sctmp.mctx = &tmp_ctx;
100 sctmp.key = pkey->pkey.ptr;
101 i = ctx->digest->verify(ctx->digest->type,
102 NULL, -1, sigbuf, siglen, &sctmp);
103 }
104 else
105 {
106 EVP_DigestFinal_ex(&tmp_ctx,&(m[0]),&m_len);
107 i = ctx->digest->verify(ctx->digest->type,m,m_len,
108 sigbuf,siglen,pkey->pkey.ptr);
109 }
110 EVP_MD_CTX_cleanup(&tmp_ctx);
111 return i;
100 } 112 }
101 113
diff --git a/src/lib/libcrypto/hmac/hmac.c b/src/lib/libcrypto/hmac/hmac.c
index 1d140f7adb..cbc1c76a57 100644
--- a/src/lib/libcrypto/hmac/hmac.c
+++ b/src/lib/libcrypto/hmac/hmac.c
@@ -61,6 +61,8 @@
61#include "cryptlib.h" 61#include "cryptlib.h"
62#include <openssl/hmac.h> 62#include <openssl/hmac.h>
63 63
64#ifndef OPENSSL_FIPS
65
64void HMAC_Init_ex(HMAC_CTX *ctx, const void *key, int len, 66void HMAC_Init_ex(HMAC_CTX *ctx, const void *key, int len,
65 const EVP_MD *md, ENGINE *impl) 67 const EVP_MD *md, ENGINE *impl)
66 { 68 {
@@ -178,3 +180,4 @@ void HMAC_CTX_set_flags(HMAC_CTX *ctx, unsigned long flags)
178 EVP_MD_CTX_set_flags(&ctx->md_ctx, flags); 180 EVP_MD_CTX_set_flags(&ctx->md_ctx, flags);
179 } 181 }
180 182
183#endif
diff --git a/src/lib/libcrypto/idea/idea.h b/src/lib/libcrypto/idea/idea.h
index bf97a37e39..a137d4cbce 100644
--- a/src/lib/libcrypto/idea/idea.h
+++ b/src/lib/libcrypto/idea/idea.h
@@ -83,6 +83,9 @@ typedef struct idea_key_st
83const char *idea_options(void); 83const char *idea_options(void);
84void idea_ecb_encrypt(const unsigned char *in, unsigned char *out, 84void idea_ecb_encrypt(const unsigned char *in, unsigned char *out,
85 IDEA_KEY_SCHEDULE *ks); 85 IDEA_KEY_SCHEDULE *ks);
86#ifdef OPENSSL_FIPS
87void private_idea_set_encrypt_key(const unsigned char *key, IDEA_KEY_SCHEDULE *ks);
88#endif
86void idea_set_encrypt_key(const unsigned char *key, IDEA_KEY_SCHEDULE *ks); 89void idea_set_encrypt_key(const unsigned char *key, IDEA_KEY_SCHEDULE *ks);
87void idea_set_decrypt_key(const IDEA_KEY_SCHEDULE *ek, IDEA_KEY_SCHEDULE *dk); 90void idea_set_decrypt_key(const IDEA_KEY_SCHEDULE *ek, IDEA_KEY_SCHEDULE *dk);
88void idea_cbc_encrypt(const unsigned char *in, unsigned char *out, 91void idea_cbc_encrypt(const unsigned char *in, unsigned char *out,
diff --git a/src/lib/libcrypto/install.com b/src/lib/libcrypto/install.com
index 58a4fecdaa..ffad1f97a7 100644
--- a/src/lib/libcrypto/install.com
+++ b/src/lib/libcrypto/install.com
@@ -35,12 +35,12 @@ $
35$ SDIRS := ,- 35$ SDIRS := ,-
36 OBJECTS,- 36 OBJECTS,-
37 MD2,MD4,MD5,SHA,MDC2,HMAC,RIPEMD,- 37 MD2,MD4,MD5,SHA,MDC2,HMAC,RIPEMD,-
38 DES,RC2,RC4,RC5,IDEA,BF,CAST,CAMELLIA,SEED,- 38 DES,AES,RC2,RC4,RC5,IDEA,BF,CAST,CAMELLIA,SEED,-
39 BN,EC,RSA,DSA,ECDSA,DH,ECDH,DSO,ENGINE,AES,- 39 BN,EC,RSA,DSA,ECDSA,DH,ECDH,DSO,ENGINE,-
40 BUFFER,BIO,STACK,LHASH,RAND,ERR,- 40 BUFFER,BIO,STACK,LHASH,RAND,ERR,-
41 EVP,ASN1,PEM,X509,X509V3,CONF,TXT_DB,PKCS7,PKCS12,COMP,OCSP,- 41 EVP,ASN1,PEM,X509,X509V3,CONF,TXT_DB,PKCS7,PKCS12,COMP,OCSP,-
42 UI,KRB5,- 42 UI,KRB5,-
43 STORE,CMS,PQUEUE 43 STORE,PQUEUE,JPAKE
44$ EXHEADER_ := crypto.h,tmdiff.h,opensslv.h,opensslconf.h,ebcdic.h,- 44$ EXHEADER_ := crypto.h,tmdiff.h,opensslv.h,opensslconf.h,ebcdic.h,-
45 symhacks.h,ossl_typ.h 45 symhacks.h,ossl_typ.h
46$ EXHEADER_OBJECTS := objects.h,obj_mac.h 46$ EXHEADER_OBJECTS := objects.h,obj_mac.h
@@ -52,6 +52,7 @@ $ EXHEADER_MDC2 := mdc2.h
52$ EXHEADER_HMAC := hmac.h 52$ EXHEADER_HMAC := hmac.h
53$ EXHEADER_RIPEMD := ripemd.h 53$ EXHEADER_RIPEMD := ripemd.h
54$ EXHEADER_DES := des.h,des_old.h 54$ EXHEADER_DES := des.h,des_old.h
55$ EXHEADER_AES := aes.h
55$ EXHEADER_RC2 := rc2.h 56$ EXHEADER_RC2 := rc2.h
56$ EXHEADER_RC4 := rc4.h 57$ EXHEADER_RC4 := rc4.h
57$ EXHEADER_RC5 := rc5.h 58$ EXHEADER_RC5 := rc5.h
@@ -69,7 +70,6 @@ $ EXHEADER_DH := dh.h
69$ EXHEADER_ECDH := ecdh.h 70$ EXHEADER_ECDH := ecdh.h
70$ EXHEADER_DSO := dso.h 71$ EXHEADER_DSO := dso.h
71$ EXHEADER_ENGINE := engine.h 72$ EXHEADER_ENGINE := engine.h
72$ EXHEADER_AES := aes.h
73$ EXHEADER_BUFFER := buffer.h 73$ EXHEADER_BUFFER := buffer.h
74$ EXHEADER_BIO := bio.h 74$ EXHEADER_BIO := bio.h
75$ EXHEADER_STACK := stack.h,safestack.h 75$ EXHEADER_STACK := stack.h,safestack.h
@@ -92,7 +92,7 @@ $ EXHEADER_KRB5 := krb5_asn.h
92$! EXHEADER_STORE := store.h,str_compat.h 92$! EXHEADER_STORE := store.h,str_compat.h
93$ EXHEADER_STORE := store.h 93$ EXHEADER_STORE := store.h
94$ EXHEADER_PQUEUE := pqueue.h,pq_compat.h 94$ EXHEADER_PQUEUE := pqueue.h,pq_compat.h
95$ EXHEADER_CMS := cms.h 95$ EXHEADER_JPAKE := jpake.h
96$ LIBS := LIBCRYPTO 96$ LIBS := LIBCRYPTO
97$ 97$
98$ VEXE_DIR := [-.VAX.EXE.CRYPTO] 98$ VEXE_DIR := [-.VAX.EXE.CRYPTO]
diff --git a/src/lib/libcrypto/md2/md2.h b/src/lib/libcrypto/md2/md2.h
index a46120e7d4..d59c9f2593 100644
--- a/src/lib/libcrypto/md2/md2.h
+++ b/src/lib/libcrypto/md2/md2.h
@@ -81,6 +81,9 @@ typedef struct MD2state_st
81 } MD2_CTX; 81 } MD2_CTX;
82 82
83const char *MD2_options(void); 83const char *MD2_options(void);
84#ifdef OPENSSL_FIPS
85int private_MD2_Init(MD2_CTX *c);
86#endif
84int MD2_Init(MD2_CTX *c); 87int MD2_Init(MD2_CTX *c);
85int MD2_Update(MD2_CTX *c, const unsigned char *data, size_t len); 88int MD2_Update(MD2_CTX *c, const unsigned char *data, size_t len);
86int MD2_Final(unsigned char *md, MD2_CTX *c); 89int MD2_Final(unsigned char *md, MD2_CTX *c);
diff --git a/src/lib/libcrypto/md2/md2_dgst.c b/src/lib/libcrypto/md2/md2_dgst.c
index 6f68b25c6a..cc4eeaf7a7 100644
--- a/src/lib/libcrypto/md2/md2_dgst.c
+++ b/src/lib/libcrypto/md2/md2_dgst.c
@@ -62,6 +62,11 @@
62#include <openssl/md2.h> 62#include <openssl/md2.h>
63#include <openssl/opensslv.h> 63#include <openssl/opensslv.h>
64#include <openssl/crypto.h> 64#include <openssl/crypto.h>
65#ifdef OPENSSL_FIPS
66#include <openssl/fips.h>
67#endif
68
69#include <openssl/err.h>
65 70
66const char MD2_version[]="MD2" OPENSSL_VERSION_PTEXT; 71const char MD2_version[]="MD2" OPENSSL_VERSION_PTEXT;
67 72
@@ -116,7 +121,7 @@ const char *MD2_options(void)
116 return("md2(int)"); 121 return("md2(int)");
117 } 122 }
118 123
119int MD2_Init(MD2_CTX *c) 124FIPS_NON_FIPS_MD_Init(MD2)
120 { 125 {
121 c->num=0; 126 c->num=0;
122 memset(c->state,0,sizeof c->state); 127 memset(c->state,0,sizeof c->state);
diff --git a/src/lib/libcrypto/md4/md4.h b/src/lib/libcrypto/md4/md4.h
index 5598c93a4f..ba1fe4a6ee 100644
--- a/src/lib/libcrypto/md4/md4.h
+++ b/src/lib/libcrypto/md4/md4.h
@@ -105,6 +105,9 @@ typedef struct MD4state_st
105 unsigned int num; 105 unsigned int num;
106 } MD4_CTX; 106 } MD4_CTX;
107 107
108#ifdef OPENSSL_FIPS
109int private_MD4_Init(MD4_CTX *c);
110#endif
108int MD4_Init(MD4_CTX *c); 111int MD4_Init(MD4_CTX *c);
109int MD4_Update(MD4_CTX *c, const void *data, size_t len); 112int MD4_Update(MD4_CTX *c, const void *data, size_t len);
110int MD4_Final(unsigned char *md, MD4_CTX *c); 113int MD4_Final(unsigned char *md, MD4_CTX *c);
diff --git a/src/lib/libcrypto/md4/md4_dgst.c b/src/lib/libcrypto/md4/md4_dgst.c
index cfef94af39..0f5448601d 100644
--- a/src/lib/libcrypto/md4/md4_dgst.c
+++ b/src/lib/libcrypto/md4/md4_dgst.c
@@ -59,6 +59,11 @@
59#include <stdio.h> 59#include <stdio.h>
60#include "md4_locl.h" 60#include "md4_locl.h"
61#include <openssl/opensslv.h> 61#include <openssl/opensslv.h>
62#include <openssl/err.h>
63#ifdef OPENSSL_FIPS
64#include <openssl/fips.h>
65#endif
66
62 67
63const char MD4_version[]="MD4" OPENSSL_VERSION_PTEXT; 68const char MD4_version[]="MD4" OPENSSL_VERSION_PTEXT;
64 69
@@ -70,7 +75,7 @@ const char MD4_version[]="MD4" OPENSSL_VERSION_PTEXT;
70#define INIT_DATA_C (unsigned long)0x98badcfeL 75#define INIT_DATA_C (unsigned long)0x98badcfeL
71#define INIT_DATA_D (unsigned long)0x10325476L 76#define INIT_DATA_D (unsigned long)0x10325476L
72 77
73int MD4_Init(MD4_CTX *c) 78FIPS_NON_FIPS_MD_Init(MD4)
74 { 79 {
75 c->A=INIT_DATA_A; 80 c->A=INIT_DATA_A;
76 c->B=INIT_DATA_B; 81 c->B=INIT_DATA_B;
diff --git a/src/lib/libcrypto/md5/md5.h b/src/lib/libcrypto/md5/md5.h
index dbdc0e1abc..0761f84a27 100644
--- a/src/lib/libcrypto/md5/md5.h
+++ b/src/lib/libcrypto/md5/md5.h
@@ -105,6 +105,9 @@ typedef struct MD5state_st
105 unsigned int num; 105 unsigned int num;
106 } MD5_CTX; 106 } MD5_CTX;
107 107
108#ifdef OPENSSL_FIPS
109int private_MD5_Init(MD5_CTX *c);
110#endif
108int MD5_Init(MD5_CTX *c); 111int MD5_Init(MD5_CTX *c);
109int MD5_Update(MD5_CTX *c, const void *data, size_t len); 112int MD5_Update(MD5_CTX *c, const void *data, size_t len);
110int MD5_Final(unsigned char *md, MD5_CTX *c); 113int MD5_Final(unsigned char *md, MD5_CTX *c);
diff --git a/src/lib/libcrypto/md5/md5_dgst.c b/src/lib/libcrypto/md5/md5_dgst.c
index b96e332ba4..47bb9020ee 100644
--- a/src/lib/libcrypto/md5/md5_dgst.c
+++ b/src/lib/libcrypto/md5/md5_dgst.c
@@ -59,6 +59,11 @@
59#include <stdio.h> 59#include <stdio.h>
60#include "md5_locl.h" 60#include "md5_locl.h"
61#include <openssl/opensslv.h> 61#include <openssl/opensslv.h>
62#include <openssl/err.h>
63#ifdef OPENSSL_FIPS
64#include <openssl/fips.h>
65#endif
66
62 67
63const char MD5_version[]="MD5" OPENSSL_VERSION_PTEXT; 68const char MD5_version[]="MD5" OPENSSL_VERSION_PTEXT;
64 69
@@ -70,7 +75,7 @@ const char MD5_version[]="MD5" OPENSSL_VERSION_PTEXT;
70#define INIT_DATA_C (unsigned long)0x98badcfeL 75#define INIT_DATA_C (unsigned long)0x98badcfeL
71#define INIT_DATA_D (unsigned long)0x10325476L 76#define INIT_DATA_D (unsigned long)0x10325476L
72 77
73int MD5_Init(MD5_CTX *c) 78FIPS_NON_FIPS_MD_Init(MD5)
74 { 79 {
75 c->A=INIT_DATA_A; 80 c->A=INIT_DATA_A;
76 c->B=INIT_DATA_B; 81 c->B=INIT_DATA_B;
diff --git a/src/lib/libcrypto/mdc2/Makefile b/src/lib/libcrypto/mdc2/Makefile
index 1d064f17a6..ea25688d88 100644
--- a/src/lib/libcrypto/mdc2/Makefile
+++ b/src/lib/libcrypto/mdc2/Makefile
@@ -33,7 +33,7 @@ top:
33all: lib 33all: lib
34 34
35lib: $(LIBOBJ) 35lib: $(LIBOBJ)
36 $(AR) $(LIB) $(LIBOBJ) 36 $(ARX) $(LIB) $(LIBOBJ)
37 $(RANLIB) $(LIB) || echo Never mind. 37 $(RANLIB) $(LIB) || echo Never mind.
38 @touch lib 38 @touch lib
39 39
diff --git a/src/lib/libcrypto/mdc2/mdc2.h b/src/lib/libcrypto/mdc2/mdc2.h
index 72778a5212..7e1354116a 100644
--- a/src/lib/libcrypto/mdc2/mdc2.h
+++ b/src/lib/libcrypto/mdc2/mdc2.h
@@ -80,7 +80,9 @@ typedef struct mdc2_ctx_st
80 int pad_type; /* either 1 or 2, default 1 */ 80 int pad_type; /* either 1 or 2, default 1 */
81 } MDC2_CTX; 81 } MDC2_CTX;
82 82
83 83#ifdef OPENSSL_FIPS
84int private_MDC2_Init(MDC2_CTX *c);
85#endif
84int MDC2_Init(MDC2_CTX *c); 86int MDC2_Init(MDC2_CTX *c);
85int MDC2_Update(MDC2_CTX *c, const unsigned char *data, size_t len); 87int MDC2_Update(MDC2_CTX *c, const unsigned char *data, size_t len);
86int MDC2_Final(unsigned char *md, MDC2_CTX *c); 88int MDC2_Final(unsigned char *md, MDC2_CTX *c);
diff --git a/src/lib/libcrypto/mem.c b/src/lib/libcrypto/mem.c
index 6635167228..00ebaf0b9b 100644
--- a/src/lib/libcrypto/mem.c
+++ b/src/lib/libcrypto/mem.c
@@ -101,7 +101,7 @@ static void (*free_locked_func)(void *) = free;
101 101
102/* may be changed as long as 'allow_customize_debug' is set */ 102/* may be changed as long as 'allow_customize_debug' is set */
103/* XXX use correct function pointer types */ 103/* XXX use correct function pointer types */
104#ifdef CRYPTO_MDEBUG 104#if defined(CRYPTO_MDEBUG) && !defined(OPENSSL_FIPS)
105/* use default functions from mem_dbg.c */ 105/* use default functions from mem_dbg.c */
106static void (*malloc_debug_func)(void *,int,const char *,int,int) 106static void (*malloc_debug_func)(void *,int,const char *,int,int)
107 = CRYPTO_dbg_malloc; 107 = CRYPTO_dbg_malloc;
@@ -110,6 +110,14 @@ static void (*realloc_debug_func)(void *,void *,int,const char *,int,int)
110static void (*free_debug_func)(void *,int) = CRYPTO_dbg_free; 110static void (*free_debug_func)(void *,int) = CRYPTO_dbg_free;
111static void (*set_debug_options_func)(long) = CRYPTO_dbg_set_options; 111static void (*set_debug_options_func)(long) = CRYPTO_dbg_set_options;
112static long (*get_debug_options_func)(void) = CRYPTO_dbg_get_options; 112static long (*get_debug_options_func)(void) = CRYPTO_dbg_get_options;
113
114static int (*push_info_func)(const char *info, const char *file, int line)
115 = CRYPTO_dbg_push_info;
116static int (*pop_info_func)(void)
117 = CRYPTO_dbg_pop_info;
118static int (*remove_all_info_func)(void)
119 = CRYPTO_dbg_remove_all_info;
120
113#else 121#else
114/* applications can use CRYPTO_malloc_debug_init() to select above case 122/* applications can use CRYPTO_malloc_debug_init() to select above case
115 * at run-time */ 123 * at run-time */
@@ -119,6 +127,13 @@ static void (*realloc_debug_func)(void *,void *,int,const char *,int,int)
119static void (*free_debug_func)(void *,int) = NULL; 127static void (*free_debug_func)(void *,int) = NULL;
120static void (*set_debug_options_func)(long) = NULL; 128static void (*set_debug_options_func)(long) = NULL;
121static long (*get_debug_options_func)(void) = NULL; 129static long (*get_debug_options_func)(void) = NULL;
130
131
132static int (*push_info_func)(const char *info, const char *file, int line)
133 = NULL;
134static int (*pop_info_func)(void) = NULL;
135static int (*remove_all_info_func)(void) = NULL;
136
122#endif 137#endif
123 138
124 139
@@ -194,6 +209,15 @@ int CRYPTO_set_mem_debug_functions(void (*m)(void *,int,const char *,int,int),
194 return 1; 209 return 1;
195 } 210 }
196 211
212void CRYPTO_set_mem_info_functions(
213 int (*push_info_fn)(const char *info, const char *file, int line),
214 int (*pop_info_fn)(void),
215 int (*remove_all_info_fn)(void))
216 {
217 push_info_func = push_info_fn;
218 pop_info_func = pop_info_fn;
219 remove_all_info_func = remove_all_info_fn;
220 }
197 221
198void CRYPTO_get_mem_functions(void *(**m)(size_t), void *(**r)(void *, size_t), 222void CRYPTO_get_mem_functions(void *(**m)(size_t), void *(**r)(void *, size_t),
199 void (**f)(void *)) 223 void (**f)(void *))
@@ -399,3 +423,24 @@ long CRYPTO_get_mem_debug_options(void)
399 return get_debug_options_func(); 423 return get_debug_options_func();
400 return 0; 424 return 0;
401 } 425 }
426
427int CRYPTO_push_info_(const char *info, const char *file, int line)
428 {
429 if (push_info_func)
430 return push_info_func(info, file, line);
431 return 1;
432 }
433
434int CRYPTO_pop_info(void)
435 {
436 if (pop_info_func)
437 return pop_info_func();
438 return 1;
439 }
440
441int CRYPTO_remove_all_info(void)
442 {
443 if (remove_all_info_func)
444 return remove_all_info_func();
445 return 1;
446 }
diff --git a/src/lib/libcrypto/mem_dbg.c b/src/lib/libcrypto/mem_dbg.c
index 8316485217..dfeb084799 100644
--- a/src/lib/libcrypto/mem_dbg.c
+++ b/src/lib/libcrypto/mem_dbg.c
@@ -330,7 +330,7 @@ static APP_INFO *pop_info(void)
330 return(ret); 330 return(ret);
331 } 331 }
332 332
333int CRYPTO_push_info_(const char *info, const char *file, int line) 333int CRYPTO_dbg_push_info(const char *info, const char *file, int line)
334 { 334 {
335 APP_INFO *ami, *amim; 335 APP_INFO *ami, *amim;
336 int ret=0; 336 int ret=0;
@@ -380,7 +380,7 @@ int CRYPTO_push_info_(const char *info, const char *file, int line)
380 return(ret); 380 return(ret);
381 } 381 }
382 382
383int CRYPTO_pop_info(void) 383int CRYPTO_dbg_pop_info(void)
384 { 384 {
385 int ret=0; 385 int ret=0;
386 386
@@ -395,7 +395,7 @@ int CRYPTO_pop_info(void)
395 return(ret); 395 return(ret);
396 } 396 }
397 397
398int CRYPTO_remove_all_info(void) 398int CRYPTO_dbg_remove_all_info(void)
399 { 399 {
400 int ret=0; 400 int ret=0;
401 401
@@ -793,3 +793,25 @@ void CRYPTO_mem_leaks_cb(CRYPTO_MEM_LEAK_CB *cb)
793 lh_doall_arg(mh, LHASH_DOALL_ARG_FN(cb_leak), &cb); 793 lh_doall_arg(mh, LHASH_DOALL_ARG_FN(cb_leak), &cb);
794 CRYPTO_w_unlock(CRYPTO_LOCK_MALLOC2); 794 CRYPTO_w_unlock(CRYPTO_LOCK_MALLOC2);
795 } 795 }
796
797void CRYPTO_malloc_debug_init(void)
798 {
799 CRYPTO_set_mem_debug_functions(
800 CRYPTO_dbg_malloc,
801 CRYPTO_dbg_realloc,
802 CRYPTO_dbg_free,
803 CRYPTO_dbg_set_options,
804 CRYPTO_dbg_get_options);
805 CRYPTO_set_mem_info_functions(
806 CRYPTO_dbg_push_info,
807 CRYPTO_dbg_pop_info,
808 CRYPTO_dbg_remove_all_info);
809 }
810
811char *CRYPTO_strdup(const char *str, const char *file, int line)
812 {
813 char *ret = CRYPTO_malloc(strlen(str)+1, file, line);
814
815 strcpy(ret, str);
816 return ret;
817 }
diff --git a/src/lib/libcrypto/objects/obj_dat.pl b/src/lib/libcrypto/objects/obj_dat.pl
index 8a09a46ee6..7de2f77afd 100644
--- a/src/lib/libcrypto/objects/obj_dat.pl
+++ b/src/lib/libcrypto/objects/obj_dat.pl
@@ -2,7 +2,9 @@
2 2
3# fixes bug in floating point emulation on sparc64 when 3# fixes bug in floating point emulation on sparc64 when
4# this script produces off-by-one output on sparc64 4# this script produces off-by-one output on sparc64
5use integer; 5eval 'use integer;';
6
7print STDERR "Warning: perl module integer not found.\n" if ($@);
6 8
7sub obj_cmp 9sub obj_cmp
8 { 10 {
diff --git a/src/lib/libcrypto/objects/obj_mac.num b/src/lib/libcrypto/objects/obj_mac.num
index 53c9cb0d6a..e3f56bc52c 100644
--- a/src/lib/libcrypto/objects/obj_mac.num
+++ b/src/lib/libcrypto/objects/obj_mac.num
@@ -854,3 +854,5 @@ id_GostR3411_94_with_GostR3410_2001_cc 853
854id_GostR3410_2001_ParamSet_cc 854 854id_GostR3410_2001_ParamSet_cc 854
855hmac 855 855hmac 855
856LocalKeySet 856 856LocalKeySet 856
857freshest_crl 857
858id_on_permanentIdentifier 858
diff --git a/src/lib/libcrypto/objects/objects.txt b/src/lib/libcrypto/objects/objects.txt
index e009702e55..a6a811b8e7 100644
--- a/src/lib/libcrypto/objects/objects.txt
+++ b/src/lib/libcrypto/objects/objects.txt
@@ -557,6 +557,7 @@ id-cmc 24 : id-cmc-confirmCertAcceptance
557 557
558# other names 558# other names
559id-on 1 : id-on-personalData 559id-on 1 : id-on-personalData
560id-on 3 : id-on-permanentIdentifier : Permanent Identifier
560 561
561# personal data attributes 562# personal data attributes
562id-pda 1 : id-pda-dateOfBirth 563id-pda 1 : id-pda-dateOfBirth
@@ -726,6 +727,8 @@ id-ce 35 : authorityKeyIdentifier : X509v3 Authority Key Identifier
726id-ce 36 : policyConstraints : X509v3 Policy Constraints 727id-ce 36 : policyConstraints : X509v3 Policy Constraints
727!Cname ext-key-usage 728!Cname ext-key-usage
728id-ce 37 : extendedKeyUsage : X509v3 Extended Key Usage 729id-ce 37 : extendedKeyUsage : X509v3 Extended Key Usage
730!Cname freshest-crl
731id-ce 46 : freshestCRL : X509v3 Freshest CRL
729!Cname inhibit-any-policy 732!Cname inhibit-any-policy
730id-ce 54 : inhibitAnyPolicy : X509v3 Inhibit Any Policy 733id-ce 54 : inhibitAnyPolicy : X509v3 Inhibit Any Policy
731!Cname target-information 734!Cname target-information
diff --git a/src/lib/libcrypto/ocsp/ocsp_asn.c b/src/lib/libcrypto/ocsp/ocsp_asn.c
index 39b7a1c568..bfe892ac70 100644
--- a/src/lib/libcrypto/ocsp/ocsp_asn.c
+++ b/src/lib/libcrypto/ocsp/ocsp_asn.c
@@ -1,5 +1,5 @@
1/* ocsp_asn.c */ 1/* ocsp_asn.c */
2/* Written by Dr Stephen N Henson (shenson@bigfoot.com) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 2000. 3 * project 2000.
4 */ 4 */
5/* ==================================================================== 5/* ====================================================================
diff --git a/src/lib/libcrypto/ocsp/ocsp_ht.c b/src/lib/libcrypto/ocsp/ocsp_ht.c
index a8e569b74a..6abb30b2c0 100644
--- a/src/lib/libcrypto/ocsp/ocsp_ht.c
+++ b/src/lib/libcrypto/ocsp/ocsp_ht.c
@@ -1,5 +1,5 @@
1/* ocsp_ht.c */ 1/* ocsp_ht.c */
2/* Written by Dr Stephen N Henson (shenson@bigfoot.com) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 2006. 3 * project 2006.
4 */ 4 */
5/* ==================================================================== 5/* ====================================================================
@@ -56,11 +56,12 @@
56 * 56 *
57 */ 57 */
58 58
59#include <openssl/asn1.h>
60#include <stdio.h> 59#include <stdio.h>
61#include <stdlib.h> 60#include <stdlib.h>
62#include <ctype.h> 61#include <ctype.h>
63#include <string.h> 62#include <string.h>
63#include "e_os.h"
64#include <openssl/asn1.h>
64#include <openssl/ocsp.h> 65#include <openssl/ocsp.h>
65#include <openssl/err.h> 66#include <openssl/err.h>
66#include <openssl/buffer.h> 67#include <openssl/buffer.h>
diff --git a/src/lib/libcrypto/ocsp/ocsp_srv.c b/src/lib/libcrypto/ocsp/ocsp_srv.c
index fffa134e75..1c606dd0b6 100644
--- a/src/lib/libcrypto/ocsp/ocsp_srv.c
+++ b/src/lib/libcrypto/ocsp/ocsp_srv.c
@@ -1,5 +1,5 @@
1/* ocsp_srv.c */ 1/* ocsp_srv.c */
2/* Written by Dr Stephen N Henson (shenson@bigfoot.com) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 2001. 3 * project 2001.
4 */ 4 */
5/* ==================================================================== 5/* ====================================================================
diff --git a/src/lib/libcrypto/ocsp/ocsp_vfy.c b/src/lib/libcrypto/ocsp/ocsp_vfy.c
index 23ea41c847..4a0c3870d8 100644
--- a/src/lib/libcrypto/ocsp/ocsp_vfy.c
+++ b/src/lib/libcrypto/ocsp/ocsp_vfy.c
@@ -1,5 +1,5 @@
1/* ocsp_vfy.c */ 1/* ocsp_vfy.c */
2/* Written by Dr Stephen N Henson (shenson@bigfoot.com) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 2000. 3 * project 2000.
4 */ 4 */
5/* ==================================================================== 5/* ====================================================================
diff --git a/src/lib/libcrypto/opensslconf.h.in b/src/lib/libcrypto/opensslconf.h.in
index cee83acf98..1c77f03c3d 100644
--- a/src/lib/libcrypto/opensslconf.h.in
+++ b/src/lib/libcrypto/opensslconf.h.in
@@ -1,5 +1,20 @@
1/* crypto/opensslconf.h.in */ 1/* crypto/opensslconf.h.in */
2 2
3#ifdef OPENSSL_DOING_MAKEDEPEND
4
5/* Include any symbols here that have to be explicitly set to enable a feature
6 * that should be visible to makedepend.
7 *
8 * [Our "make depend" doesn't actually look at this, we use actual build settings
9 * instead; we want to make it easy to remove subdirectories with disabled algorithms.]
10 */
11
12#ifndef OPENSSL_FIPS
13#define OPENSSL_FIPS
14#endif
15
16#endif
17
3/* Generate 80386 code? */ 18/* Generate 80386 code? */
4#undef I386_ONLY 19#undef I386_ONLY
5 20
diff --git a/src/lib/libcrypto/opensslv.h b/src/lib/libcrypto/opensslv.h
index 5bdd370ac9..09687b5136 100644
--- a/src/lib/libcrypto/opensslv.h
+++ b/src/lib/libcrypto/opensslv.h
@@ -25,11 +25,11 @@
25 * (Prior to 0.9.5a beta1, a different scheme was used: MMNNFFRBB for 25 * (Prior to 0.9.5a beta1, a different scheme was used: MMNNFFRBB for
26 * major minor fix final patch/beta) 26 * major minor fix final patch/beta)
27 */ 27 */
28#define OPENSSL_VERSION_NUMBER 0x0090809fL 28#define OPENSSL_VERSION_NUMBER 0x009080afL
29#ifdef OPENSSL_FIPS 29#ifdef OPENSSL_FIPS
30#define OPENSSL_VERSION_TEXT "OpenSSL 0.9.8i-fips 15 Sep 2008" 30#define OPENSSL_VERSION_TEXT "OpenSSL 0.9.8j-fips 07 Jan 2009"
31#else 31#else
32#define OPENSSL_VERSION_TEXT "OpenSSL 0.9.8i 15 Sep 2008" 32#define OPENSSL_VERSION_TEXT "OpenSSL 0.9.8j 07 Jan 2009"
33#endif 33#endif
34#define OPENSSL_VERSION_PTEXT " part of " OPENSSL_VERSION_TEXT 34#define OPENSSL_VERSION_PTEXT " part of " OPENSSL_VERSION_TEXT
35 35
diff --git a/src/lib/libcrypto/ossl_typ.h b/src/lib/libcrypto/ossl_typ.h
index 734200428f..0e7a380880 100644
--- a/src/lib/libcrypto/ossl_typ.h
+++ b/src/lib/libcrypto/ossl_typ.h
@@ -100,6 +100,8 @@ typedef int ASN1_NULL;
100#undef X509_EXTENSIONS 100#undef X509_EXTENSIONS
101#undef X509_CERT_PAIR 101#undef X509_CERT_PAIR
102#undef PKCS7_ISSUER_AND_SERIAL 102#undef PKCS7_ISSUER_AND_SERIAL
103#undef OCSP_REQUEST
104#undef OCSP_RESPONSE
103#endif 105#endif
104 106
105#ifdef BIGNUM 107#ifdef BIGNUM
diff --git a/src/lib/libcrypto/pem/pem.h b/src/lib/libcrypto/pem/pem.h
index 670afa670b..6f8e01544b 100644
--- a/src/lib/libcrypto/pem/pem.h
+++ b/src/lib/libcrypto/pem/pem.h
@@ -125,6 +125,7 @@ extern "C" {
125#define PEM_STRING_DSA "DSA PRIVATE KEY" 125#define PEM_STRING_DSA "DSA PRIVATE KEY"
126#define PEM_STRING_DSA_PUBLIC "DSA PUBLIC KEY" 126#define PEM_STRING_DSA_PUBLIC "DSA PUBLIC KEY"
127#define PEM_STRING_PKCS7 "PKCS7" 127#define PEM_STRING_PKCS7 "PKCS7"
128#define PEM_STRING_PKCS7_SIGNED "PKCS #7 SIGNED DATA"
128#define PEM_STRING_PKCS8 "ENCRYPTED PRIVATE KEY" 129#define PEM_STRING_PKCS8 "ENCRYPTED PRIVATE KEY"
129#define PEM_STRING_PKCS8INF "PRIVATE KEY" 130#define PEM_STRING_PKCS8INF "PRIVATE KEY"
130#define PEM_STRING_DHPARAMS "DH PARAMETERS" 131#define PEM_STRING_DHPARAMS "DH PARAMETERS"
diff --git a/src/lib/libcrypto/pem/pem_all.c b/src/lib/libcrypto/pem/pem_all.c
index 66cbc7eb82..69dd19bf2e 100644
--- a/src/lib/libcrypto/pem/pem_all.c
+++ b/src/lib/libcrypto/pem/pem_all.c
@@ -194,7 +194,49 @@ RSA *PEM_read_RSAPrivateKey(FILE *fp, RSA **rsa, pem_password_cb *cb,
194 194
195#endif 195#endif
196 196
197#ifdef OPENSSL_FIPS
198
199int PEM_write_bio_RSAPrivateKey(BIO *bp, RSA *x, const EVP_CIPHER *enc,
200 unsigned char *kstr, int klen,
201 pem_password_cb *cb, void *u)
202{
203 EVP_PKEY *k;
204 int ret;
205 k = EVP_PKEY_new();
206 if (!k)
207 return 0;
208 EVP_PKEY_set1_RSA(k, x);
209
210 ret = PEM_write_bio_PrivateKey(bp, k, enc, kstr, klen, cb, u);
211 EVP_PKEY_free(k);
212 return ret;
213}
214
215#ifndef OPENSSL_NO_FP_API
216int PEM_write_RSAPrivateKey(FILE *fp, RSA *x, const EVP_CIPHER *enc,
217 unsigned char *kstr, int klen,
218 pem_password_cb *cb, void *u)
219{
220 EVP_PKEY *k;
221 int ret;
222 k = EVP_PKEY_new();
223 if (!k)
224 return 0;
225
226 EVP_PKEY_set1_RSA(k, x);
227
228 ret = PEM_write_PrivateKey(fp, k, enc, kstr, klen, cb, u);
229 EVP_PKEY_free(k);
230 return ret;
231}
232#endif
233
234#else
235
197IMPLEMENT_PEM_write_cb_const(RSAPrivateKey, RSA, PEM_STRING_RSA, RSAPrivateKey) 236IMPLEMENT_PEM_write_cb_const(RSAPrivateKey, RSA, PEM_STRING_RSA, RSAPrivateKey)
237
238#endif
239
198IMPLEMENT_PEM_rw_const(RSAPublicKey, RSA, PEM_STRING_RSA_PUBLIC, RSAPublicKey) 240IMPLEMENT_PEM_rw_const(RSAPublicKey, RSA, PEM_STRING_RSA_PUBLIC, RSAPublicKey)
199IMPLEMENT_PEM_rw(RSA_PUBKEY, RSA, PEM_STRING_PUBLIC, RSA_PUBKEY) 241IMPLEMENT_PEM_rw(RSA_PUBKEY, RSA, PEM_STRING_PUBLIC, RSA_PUBKEY)
200 242
@@ -224,7 +266,47 @@ DSA *PEM_read_bio_DSAPrivateKey(BIO *bp, DSA **dsa, pem_password_cb *cb,
224 return pkey_get_dsa(pktmp, dsa); 266 return pkey_get_dsa(pktmp, dsa);
225} 267}
226 268
269#ifdef OPENSSL_FIPS
270
271int PEM_write_bio_DSAPrivateKey(BIO *bp, DSA *x, const EVP_CIPHER *enc,
272 unsigned char *kstr, int klen,
273 pem_password_cb *cb, void *u)
274{
275 EVP_PKEY *k;
276 int ret;
277 k = EVP_PKEY_new();
278 if (!k)
279 return 0;
280 EVP_PKEY_set1_DSA(k, x);
281
282 ret = PEM_write_bio_PrivateKey(bp, k, enc, kstr, klen, cb, u);
283 EVP_PKEY_free(k);
284 return ret;
285}
286
287#ifndef OPENSSL_NO_FP_API
288int PEM_write_DSAPrivateKey(FILE *fp, DSA *x, const EVP_CIPHER *enc,
289 unsigned char *kstr, int klen,
290 pem_password_cb *cb, void *u)
291{
292 EVP_PKEY *k;
293 int ret;
294 k = EVP_PKEY_new();
295 if (!k)
296 return 0;
297 EVP_PKEY_set1_DSA(k, x);
298 ret = PEM_write_PrivateKey(fp, k, enc, kstr, klen, cb, u);
299 EVP_PKEY_free(k);
300 return ret;
301}
302#endif
303
304#else
305
227IMPLEMENT_PEM_write_cb_const(DSAPrivateKey, DSA, PEM_STRING_DSA, DSAPrivateKey) 306IMPLEMENT_PEM_write_cb_const(DSAPrivateKey, DSA, PEM_STRING_DSA, DSAPrivateKey)
307
308#endif
309
228IMPLEMENT_PEM_rw(DSA_PUBKEY, DSA, PEM_STRING_PUBLIC, DSA_PUBKEY) 310IMPLEMENT_PEM_rw(DSA_PUBKEY, DSA, PEM_STRING_PUBLIC, DSA_PUBKEY)
229 311
230#ifndef OPENSSL_NO_FP_API 312#ifndef OPENSSL_NO_FP_API
@@ -270,8 +352,49 @@ EC_KEY *PEM_read_bio_ECPrivateKey(BIO *bp, EC_KEY **key, pem_password_cb *cb,
270 352
271IMPLEMENT_PEM_rw_const(ECPKParameters, EC_GROUP, PEM_STRING_ECPARAMETERS, ECPKParameters) 353IMPLEMENT_PEM_rw_const(ECPKParameters, EC_GROUP, PEM_STRING_ECPARAMETERS, ECPKParameters)
272 354
355
356
357#ifdef OPENSSL_FIPS
358
359int PEM_write_bio_ECPrivateKey(BIO *bp, EC_KEY *x, const EVP_CIPHER *enc,
360 unsigned char *kstr, int klen,
361 pem_password_cb *cb, void *u)
362{
363 EVP_PKEY *k;
364 int ret;
365 k = EVP_PKEY_new();
366 if (!k)
367 return 0;
368 EVP_PKEY_set1_EC_KEY(k, x);
369
370 ret = PEM_write_bio_PrivateKey(bp, k, enc, kstr, klen, cb, u);
371 EVP_PKEY_free(k);
372 return ret;
373}
374
375#ifndef OPENSSL_NO_FP_API
376int PEM_write_ECPrivateKey(FILE *fp, EC_KEY *x, const EVP_CIPHER *enc,
377 unsigned char *kstr, int klen,
378 pem_password_cb *cb, void *u)
379{
380 EVP_PKEY *k;
381 int ret;
382 k = EVP_PKEY_new();
383 if (!k)
384 return 0;
385 EVP_PKEY_set1_EC_KEY(k, x);
386 ret = PEM_write_PrivateKey(fp, k, enc, kstr, klen, cb, u);
387 EVP_PKEY_free(k);
388 return ret;
389}
390#endif
391
392#else
393
273IMPLEMENT_PEM_write_cb(ECPrivateKey, EC_KEY, PEM_STRING_ECPRIVATEKEY, ECPrivateKey) 394IMPLEMENT_PEM_write_cb(ECPrivateKey, EC_KEY, PEM_STRING_ECPRIVATEKEY, ECPrivateKey)
274 395
396#endif
397
275IMPLEMENT_PEM_rw(EC_PUBKEY, EC_KEY, PEM_STRING_PUBLIC, EC_PUBKEY) 398IMPLEMENT_PEM_rw(EC_PUBKEY, EC_KEY, PEM_STRING_PUBLIC, EC_PUBKEY)
276 399
277#ifndef OPENSSL_NO_FP_API 400#ifndef OPENSSL_NO_FP_API
@@ -301,8 +424,59 @@ IMPLEMENT_PEM_rw_const(DHparams, DH, PEM_STRING_DHPARAMS, DHparams)
301 * (When reading, parameter PEM_STRING_EVP_PKEY is a wildcard for anything 424 * (When reading, parameter PEM_STRING_EVP_PKEY is a wildcard for anything
302 * appropriate.) 425 * appropriate.)
303 */ 426 */
427
428#ifdef OPENSSL_FIPS
429
430static const char *pkey_str(EVP_PKEY *x)
431 {
432 switch (x->type)
433 {
434 case EVP_PKEY_RSA:
435 return PEM_STRING_RSA;
436
437 case EVP_PKEY_DSA:
438 return PEM_STRING_DSA;
439
440 case EVP_PKEY_EC:
441 return PEM_STRING_ECPRIVATEKEY;
442
443 default:
444 return NULL;
445 }
446 }
447
448
449int PEM_write_bio_PrivateKey(BIO *bp, EVP_PKEY *x, const EVP_CIPHER *enc,
450 unsigned char *kstr, int klen,
451 pem_password_cb *cb, void *u)
452 {
453 if (FIPS_mode())
454 return PEM_write_bio_PKCS8PrivateKey(bp, x, enc,
455 (char *)kstr, klen, cb, u);
456 else
457 return PEM_ASN1_write_bio((i2d_of_void *)i2d_PrivateKey,
458 pkey_str(x), bp,(char *)x,enc,kstr,klen,cb,u);
459 }
460
461#ifndef OPENSSL_NO_FP_API
462int PEM_write_PrivateKey(FILE *fp, EVP_PKEY *x, const EVP_CIPHER *enc,
463 unsigned char *kstr, int klen,
464 pem_password_cb *cb, void *u)
465 {
466 if (FIPS_mode())
467 return PEM_write_PKCS8PrivateKey(fp, x, enc,
468 (char *)kstr, klen, cb, u);
469 else
470 return PEM_ASN1_write((i2d_of_void *)i2d_PrivateKey,
471 pkey_str(x), fp,(char *)x,enc,kstr,klen,cb,u);
472 }
473#endif
474
475#else
304IMPLEMENT_PEM_write_cb(PrivateKey, EVP_PKEY, ((x->type == EVP_PKEY_DSA)?PEM_STRING_DSA:\ 476IMPLEMENT_PEM_write_cb(PrivateKey, EVP_PKEY, ((x->type == EVP_PKEY_DSA)?PEM_STRING_DSA:\
305 (x->type == EVP_PKEY_RSA)?PEM_STRING_RSA:PEM_STRING_ECPRIVATEKEY), PrivateKey) 477 (x->type == EVP_PKEY_RSA)?PEM_STRING_RSA:PEM_STRING_ECPRIVATEKEY), PrivateKey)
306 478
479#endif
480
307IMPLEMENT_PEM_rw(PUBKEY, EVP_PKEY, PEM_STRING_PUBLIC, PUBKEY) 481IMPLEMENT_PEM_rw(PUBKEY, EVP_PKEY, PEM_STRING_PUBLIC, PUBKEY)
308 482
diff --git a/src/lib/libcrypto/pem/pem_lib.c b/src/lib/libcrypto/pem/pem_lib.c
index 9bae4c8850..cbafefe416 100644
--- a/src/lib/libcrypto/pem/pem_lib.c
+++ b/src/lib/libcrypto/pem/pem_lib.c
@@ -216,6 +216,9 @@ static int check_pem(const char *nm, const char *name)
216 if(!strcmp(nm, PEM_STRING_X509) && 216 if(!strcmp(nm, PEM_STRING_X509) &&
217 !strcmp(name, PEM_STRING_PKCS7)) return 1; 217 !strcmp(name, PEM_STRING_PKCS7)) return 1;
218 218
219 if(!strcmp(nm, PEM_STRING_PKCS7_SIGNED) &&
220 !strcmp(name, PEM_STRING_PKCS7)) return 1;
221
219 return 0; 222 return 0;
220} 223}
221 224
diff --git a/src/lib/libcrypto/pem/pem_x509.c b/src/lib/libcrypto/pem/pem_x509.c
index 19f88d8d3a..3f709f13e6 100644
--- a/src/lib/libcrypto/pem/pem_x509.c
+++ b/src/lib/libcrypto/pem/pem_x509.c
@@ -1,5 +1,5 @@
1/* pem_x509.c */ 1/* pem_x509.c */
2/* Written by Dr Stephen N Henson (shenson@bigfoot.com) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 2001. 3 * project 2001.
4 */ 4 */
5/* ==================================================================== 5/* ====================================================================
diff --git a/src/lib/libcrypto/pem/pem_xaux.c b/src/lib/libcrypto/pem/pem_xaux.c
index 63ce660cf1..7cc7491009 100644
--- a/src/lib/libcrypto/pem/pem_xaux.c
+++ b/src/lib/libcrypto/pem/pem_xaux.c
@@ -1,5 +1,5 @@
1/* pem_xaux.c */ 1/* pem_xaux.c */
2/* Written by Dr Stephen N Henson (shenson@bigfoot.com) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 2001. 3 * project 2001.
4 */ 4 */
5/* ==================================================================== 5/* ====================================================================
diff --git a/src/lib/libcrypto/pkcs12/p12_add.c b/src/lib/libcrypto/pkcs12/p12_add.c
index 41bdc00551..1f3e378f5c 100644
--- a/src/lib/libcrypto/pkcs12/p12_add.c
+++ b/src/lib/libcrypto/pkcs12/p12_add.c
@@ -1,5 +1,5 @@
1/* p12_add.c */ 1/* p12_add.c */
2/* Written by Dr Stephen N Henson (shenson@bigfoot.com) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 1999. 3 * project 1999.
4 */ 4 */
5/* ==================================================================== 5/* ====================================================================
diff --git a/src/lib/libcrypto/pkcs12/p12_asn.c b/src/lib/libcrypto/pkcs12/p12_asn.c
index a3739fee1a..6e27633817 100644
--- a/src/lib/libcrypto/pkcs12/p12_asn.c
+++ b/src/lib/libcrypto/pkcs12/p12_asn.c
@@ -1,5 +1,5 @@
1/* p12_asn.c */ 1/* p12_asn.c */
2/* Written by Dr Stephen N Henson (shenson@bigfoot.com) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 1999. 3 * project 1999.
4 */ 4 */
5/* ==================================================================== 5/* ====================================================================
diff --git a/src/lib/libcrypto/pkcs12/p12_attr.c b/src/lib/libcrypto/pkcs12/p12_attr.c
index 026cf3826a..68d6c5ad15 100644
--- a/src/lib/libcrypto/pkcs12/p12_attr.c
+++ b/src/lib/libcrypto/pkcs12/p12_attr.c
@@ -1,5 +1,5 @@
1/* p12_attr.c */ 1/* p12_attr.c */
2/* Written by Dr Stephen N Henson (shenson@bigfoot.com) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 1999. 3 * project 1999.
4 */ 4 */
5/* ==================================================================== 5/* ====================================================================
diff --git a/src/lib/libcrypto/pkcs12/p12_crpt.c b/src/lib/libcrypto/pkcs12/p12_crpt.c
index 3ad33c49d8..f8b952e27e 100644
--- a/src/lib/libcrypto/pkcs12/p12_crpt.c
+++ b/src/lib/libcrypto/pkcs12/p12_crpt.c
@@ -1,5 +1,5 @@
1/* p12_crpt.c */ 1/* p12_crpt.c */
2/* Written by Dr Stephen N Henson (shenson@bigfoot.com) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 1999. 3 * project 1999.
4 */ 4 */
5/* ==================================================================== 5/* ====================================================================
diff --git a/src/lib/libcrypto/pkcs12/p12_crt.c b/src/lib/libcrypto/pkcs12/p12_crt.c
index 9748256b6f..e863de52ce 100644
--- a/src/lib/libcrypto/pkcs12/p12_crt.c
+++ b/src/lib/libcrypto/pkcs12/p12_crt.c
@@ -1,5 +1,5 @@
1/* p12_crt.c */ 1/* p12_crt.c */
2/* Written by Dr Stephen N Henson (shenson@bigfoot.com) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project. 3 * project.
4 */ 4 */
5/* ==================================================================== 5/* ====================================================================
@@ -59,6 +59,10 @@
59#include <stdio.h> 59#include <stdio.h>
60#include "cryptlib.h" 60#include "cryptlib.h"
61#include <openssl/pkcs12.h> 61#include <openssl/pkcs12.h>
62#ifdef OPENSSL_FIPS
63#include <openssl/fips.h>
64#endif
65
62 66
63 67
64static int pkcs12_add_bag(STACK_OF(PKCS12_SAFEBAG) **pbags, PKCS12_SAFEBAG *bag); 68static int pkcs12_add_bag(STACK_OF(PKCS12_SAFEBAG) **pbags, PKCS12_SAFEBAG *bag);
@@ -90,7 +94,14 @@ PKCS12 *PKCS12_create(char *pass, char *name, EVP_PKEY *pkey, X509 *cert,
90 94
91 /* Set defaults */ 95 /* Set defaults */
92 if (!nid_cert) 96 if (!nid_cert)
97 {
98#ifdef OPENSSL_FIPS
99 if (FIPS_mode())
100 nid_cert = NID_pbe_WithSHA1And3_Key_TripleDES_CBC;
101 else
102#endif
93 nid_cert = NID_pbe_WithSHA1And40BitRC2_CBC; 103 nid_cert = NID_pbe_WithSHA1And40BitRC2_CBC;
104 }
94 if (!nid_key) 105 if (!nid_key)
95 nid_key = NID_pbe_WithSHA1And3_Key_TripleDES_CBC; 106 nid_key = NID_pbe_WithSHA1And3_Key_TripleDES_CBC;
96 if (!iter) 107 if (!iter)
diff --git a/src/lib/libcrypto/pkcs12/p12_decr.c b/src/lib/libcrypto/pkcs12/p12_decr.c
index 74c961a92b..ba77dbbe32 100644
--- a/src/lib/libcrypto/pkcs12/p12_decr.c
+++ b/src/lib/libcrypto/pkcs12/p12_decr.c
@@ -1,5 +1,5 @@
1/* p12_decr.c */ 1/* p12_decr.c */
2/* Written by Dr Stephen N Henson (shenson@bigfoot.com) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 1999. 3 * project 1999.
4 */ 4 */
5/* ==================================================================== 5/* ====================================================================
diff --git a/src/lib/libcrypto/pkcs12/p12_init.c b/src/lib/libcrypto/pkcs12/p12_init.c
index 6bdc132631..d4d84b056a 100644
--- a/src/lib/libcrypto/pkcs12/p12_init.c
+++ b/src/lib/libcrypto/pkcs12/p12_init.c
@@ -1,5 +1,5 @@
1/* p12_init.c */ 1/* p12_init.c */
2/* Written by Dr Stephen N Henson (shenson@bigfoot.com) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 1999. 3 * project 1999.
4 */ 4 */
5/* ==================================================================== 5/* ====================================================================
diff --git a/src/lib/libcrypto/pkcs12/p12_key.c b/src/lib/libcrypto/pkcs12/p12_key.c
index 18e72d0a1b..9e57eee4a4 100644
--- a/src/lib/libcrypto/pkcs12/p12_key.c
+++ b/src/lib/libcrypto/pkcs12/p12_key.c
@@ -1,5 +1,5 @@
1/* p12_key.c */ 1/* p12_key.c */
2/* Written by Dr Stephen N Henson (shenson@bigfoot.com) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 1999. 3 * project 1999.
4 */ 4 */
5/* ==================================================================== 5/* ====================================================================
diff --git a/src/lib/libcrypto/pkcs12/p12_kiss.c b/src/lib/libcrypto/pkcs12/p12_kiss.c
index c2ee2cc6f3..5c4c6ec988 100644
--- a/src/lib/libcrypto/pkcs12/p12_kiss.c
+++ b/src/lib/libcrypto/pkcs12/p12_kiss.c
@@ -1,5 +1,5 @@
1/* p12_kiss.c */ 1/* p12_kiss.c */
2/* Written by Dr Stephen N Henson (shenson@bigfoot.com) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 1999. 3 * project 1999.
4 */ 4 */
5/* ==================================================================== 5/* ====================================================================
diff --git a/src/lib/libcrypto/pkcs12/p12_mutl.c b/src/lib/libcrypto/pkcs12/p12_mutl.c
index c408cc8ab8..70bfef6e5d 100644
--- a/src/lib/libcrypto/pkcs12/p12_mutl.c
+++ b/src/lib/libcrypto/pkcs12/p12_mutl.c
@@ -1,5 +1,5 @@
1/* p12_mutl.c */ 1/* p12_mutl.c */
2/* Written by Dr Stephen N Henson (shenson@bigfoot.com) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 1999. 3 * project 1999.
4 */ 4 */
5/* ==================================================================== 5/* ====================================================================
diff --git a/src/lib/libcrypto/pkcs12/p12_npas.c b/src/lib/libcrypto/pkcs12/p12_npas.c
index 48eacc5c49..47e5e9c377 100644
--- a/src/lib/libcrypto/pkcs12/p12_npas.c
+++ b/src/lib/libcrypto/pkcs12/p12_npas.c
@@ -1,5 +1,5 @@
1/* p12_npas.c */ 1/* p12_npas.c */
2/* Written by Dr Stephen N Henson (shenson@bigfoot.com) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 1999. 3 * project 1999.
4 */ 4 */
5/* ==================================================================== 5/* ====================================================================
diff --git a/src/lib/libcrypto/pkcs12/p12_p8d.c b/src/lib/libcrypto/pkcs12/p12_p8d.c
index 3c6f377933..deba81e4a9 100644
--- a/src/lib/libcrypto/pkcs12/p12_p8d.c
+++ b/src/lib/libcrypto/pkcs12/p12_p8d.c
@@ -1,5 +1,5 @@
1/* p12_p8d.c */ 1/* p12_p8d.c */
2/* Written by Dr Stephen N Henson (shenson@bigfoot.com) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 2001. 3 * project 2001.
4 */ 4 */
5/* ==================================================================== 5/* ====================================================================
diff --git a/src/lib/libcrypto/pkcs12/p12_p8e.c b/src/lib/libcrypto/pkcs12/p12_p8e.c
index 3d47956652..bf20a77b4c 100644
--- a/src/lib/libcrypto/pkcs12/p12_p8e.c
+++ b/src/lib/libcrypto/pkcs12/p12_p8e.c
@@ -1,5 +1,5 @@
1/* p12_p8e.c */ 1/* p12_p8e.c */
2/* Written by Dr Stephen N Henson (shenson@bigfoot.com) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 2001. 3 * project 2001.
4 */ 4 */
5/* ==================================================================== 5/* ====================================================================
diff --git a/src/lib/libcrypto/pkcs12/p12_utl.c b/src/lib/libcrypto/pkcs12/p12_utl.c
index 243ec76be9..ca30ac4f6d 100644
--- a/src/lib/libcrypto/pkcs12/p12_utl.c
+++ b/src/lib/libcrypto/pkcs12/p12_utl.c
@@ -1,5 +1,5 @@
1/* p12_utl.c */ 1/* p12_utl.c */
2/* Written by Dr Stephen N Henson (shenson@bigfoot.com) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 1999. 3 * project 1999.
4 */ 4 */
5/* ==================================================================== 5/* ====================================================================
diff --git a/src/lib/libcrypto/pkcs12/pkcs12.h b/src/lib/libcrypto/pkcs12/pkcs12.h
index a2d7e359a0..4bee605dc0 100644
--- a/src/lib/libcrypto/pkcs12/pkcs12.h
+++ b/src/lib/libcrypto/pkcs12/pkcs12.h
@@ -1,5 +1,5 @@
1/* pkcs12.h */ 1/* pkcs12.h */
2/* Written by Dr Stephen N Henson (shenson@bigfoot.com) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 1999. 3 * project 1999.
4 */ 4 */
5/* ==================================================================== 5/* ====================================================================
diff --git a/src/lib/libcrypto/pkcs7/pk7_asn1.c b/src/lib/libcrypto/pkcs7/pk7_asn1.c
index 77931feeb4..1f70d31386 100644
--- a/src/lib/libcrypto/pkcs7/pk7_asn1.c
+++ b/src/lib/libcrypto/pkcs7/pk7_asn1.c
@@ -1,5 +1,5 @@
1/* pk7_asn.c */ 1/* pk7_asn.c */
2/* Written by Dr Stephen N Henson (shenson@bigfoot.com) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 2000. 3 * project 2000.
4 */ 4 */
5/* ==================================================================== 5/* ====================================================================
diff --git a/src/lib/libcrypto/pkcs7/pk7_attr.c b/src/lib/libcrypto/pkcs7/pk7_attr.c
index 735c8800e1..d549717169 100644
--- a/src/lib/libcrypto/pkcs7/pk7_attr.c
+++ b/src/lib/libcrypto/pkcs7/pk7_attr.c
@@ -1,5 +1,5 @@
1/* pk7_attr.c */ 1/* pk7_attr.c */
2/* Written by Dr Stephen N Henson (shenson@bigfoot.com) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 2001. 3 * project 2001.
4 */ 4 */
5/* ==================================================================== 5/* ====================================================================
diff --git a/src/lib/libcrypto/pkcs7/pk7_mime.c b/src/lib/libcrypto/pkcs7/pk7_mime.c
index 17b68992f7..bf190360d7 100644
--- a/src/lib/libcrypto/pkcs7/pk7_mime.c
+++ b/src/lib/libcrypto/pkcs7/pk7_mime.c
@@ -1,5 +1,5 @@
1/* pk7_mime.c */ 1/* pk7_mime.c */
2/* Written by Dr Stephen N Henson (shenson@bigfoot.com) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project. 3 * project.
4 */ 4 */
5/* ==================================================================== 5/* ====================================================================
diff --git a/src/lib/libcrypto/pkcs7/pk7_smime.c b/src/lib/libcrypto/pkcs7/pk7_smime.c
index 5c6b0fe24b..c34db1d6fe 100644
--- a/src/lib/libcrypto/pkcs7/pk7_smime.c
+++ b/src/lib/libcrypto/pkcs7/pk7_smime.c
@@ -1,5 +1,5 @@
1/* pk7_smime.c */ 1/* pk7_smime.c */
2/* Written by Dr Stephen N Henson (shenson@bigfoot.com) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project. 3 * project.
4 */ 4 */
5/* ==================================================================== 5/* ====================================================================
@@ -282,6 +282,7 @@ int PKCS7_verify(PKCS7 *p7, STACK_OF(X509) *certs, X509_STORE *store,
282 PKCS7err(PKCS7_F_PKCS7_VERIFY,ERR_R_MALLOC_FAILURE); 282 PKCS7err(PKCS7_F_PKCS7_VERIFY,ERR_R_MALLOC_FAILURE);
283 goto err; 283 goto err;
284 } 284 }
285 BIO_set_mem_eof_return(tmpout, 0);
285 } else tmpout = out; 286 } else tmpout = out;
286 287
287 /* We now have to 'read' from p7bio to calculate digests etc. */ 288 /* We now have to 'read' from p7bio to calculate digests etc. */
diff --git a/src/lib/libcrypto/rand/Makefile b/src/lib/libcrypto/rand/Makefile
index 27694aa664..30794305cb 100644
--- a/src/lib/libcrypto/rand/Makefile
+++ b/src/lib/libcrypto/rand/Makefile
@@ -17,9 +17,9 @@ TEST= randtest.c
17APPS= 17APPS=
18 18
19LIB=$(TOP)/libcrypto.a 19LIB=$(TOP)/libcrypto.a
20LIBSRC=md_rand.c randfile.c rand_lib.c rand_err.c rand_egd.c \ 20LIBSRC=md_rand.c randfile.c rand_lib.c rand_eng.c rand_err.c rand_egd.c \
21 rand_win.c rand_unix.c rand_os2.c rand_nw.c 21 rand_win.c rand_unix.c rand_os2.c rand_nw.c
22LIBOBJ=md_rand.o randfile.o rand_lib.o rand_err.o rand_egd.o \ 22LIBOBJ=md_rand.o randfile.o rand_lib.o rand_eng.o rand_err.o rand_egd.o \
23 rand_win.o rand_unix.o rand_os2.o rand_nw.o 23 rand_win.o rand_unix.o rand_os2.o rand_nw.o
24 24
25SRC= $(LIBSRC) 25SRC= $(LIBSRC)
@@ -35,7 +35,7 @@ top:
35all: lib 35all: lib
36 36
37lib: $(LIBOBJ) 37lib: $(LIBOBJ)
38 $(AR) $(LIB) $(LIBOBJ) 38 $(ARX) $(LIB) $(LIBOBJ)
39 $(RANLIB) $(LIB) || echo Never mind. 39 $(RANLIB) $(LIB) || echo Never mind.
40 @touch lib 40 @touch lib
41 41
@@ -79,17 +79,34 @@ clean:
79md_rand.o: ../../e_os.h ../../include/openssl/asn1.h 79md_rand.o: ../../e_os.h ../../include/openssl/asn1.h
80md_rand.o: ../../include/openssl/bio.h ../../include/openssl/crypto.h 80md_rand.o: ../../include/openssl/bio.h ../../include/openssl/crypto.h
81md_rand.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h 81md_rand.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
82md_rand.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h 82md_rand.o: ../../include/openssl/evp.h ../../include/openssl/fips.h
83md_rand.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h 83md_rand.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
84md_rand.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h 84md_rand.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
85md_rand.o: ../../include/openssl/ossl_typ.h ../../include/openssl/rand.h 85md_rand.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
86md_rand.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h 86md_rand.o: ../../include/openssl/rand.h ../../include/openssl/safestack.h
87md_rand.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 87md_rand.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
88md_rand.o: md_rand.c rand_lcl.h 88md_rand.o: ../../include/openssl/symhacks.h md_rand.c rand_lcl.h
89rand_egd.o: ../../include/openssl/buffer.h ../../include/openssl/e_os2.h 89rand_egd.o: ../../include/openssl/buffer.h ../../include/openssl/e_os2.h
90rand_egd.o: ../../include/openssl/opensslconf.h 90rand_egd.o: ../../include/openssl/opensslconf.h
91rand_egd.o: ../../include/openssl/ossl_typ.h ../../include/openssl/rand.h 91rand_egd.o: ../../include/openssl/ossl_typ.h ../../include/openssl/rand.h
92rand_egd.o: rand_egd.c 92rand_egd.o: rand_egd.c
93rand_eng.o: ../../e_os.h ../../include/openssl/asn1.h
94rand_eng.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
95rand_eng.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
96rand_eng.o: ../../include/openssl/des_old.h ../../include/openssl/e_os2.h
97rand_eng.o: ../../include/openssl/ec.h ../../include/openssl/ecdh.h
98rand_eng.o: ../../include/openssl/ecdsa.h ../../include/openssl/engine.h
99rand_eng.o: ../../include/openssl/err.h ../../include/openssl/evp.h
100rand_eng.o: ../../include/openssl/fips.h ../../include/openssl/fips_rand.h
101rand_eng.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
102rand_eng.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
103rand_eng.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
104rand_eng.o: ../../include/openssl/pkcs7.h ../../include/openssl/rand.h
105rand_eng.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
106rand_eng.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
107rand_eng.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
108rand_eng.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
109rand_eng.o: ../cryptlib.h rand_eng.c rand_lcl.h
93rand_err.o: ../../include/openssl/bio.h ../../include/openssl/crypto.h 110rand_err.o: ../../include/openssl/bio.h ../../include/openssl/crypto.h
94rand_err.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h 111rand_err.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
95rand_err.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h 112rand_err.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
@@ -99,34 +116,39 @@ rand_err.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
99rand_err.o: rand_err.c 116rand_err.o: rand_err.c
100rand_lib.o: ../../e_os.h ../../include/openssl/asn1.h 117rand_lib.o: ../../e_os.h ../../include/openssl/asn1.h
101rand_lib.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h 118rand_lib.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
102rand_lib.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h 119rand_lib.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
120rand_lib.o: ../../include/openssl/des_old.h ../../include/openssl/e_os2.h
103rand_lib.o: ../../include/openssl/ec.h ../../include/openssl/ecdh.h 121rand_lib.o: ../../include/openssl/ec.h ../../include/openssl/ecdh.h
104rand_lib.o: ../../include/openssl/ecdsa.h ../../include/openssl/engine.h 122rand_lib.o: ../../include/openssl/ecdsa.h ../../include/openssl/engine.h
105rand_lib.o: ../../include/openssl/err.h ../../include/openssl/evp.h 123rand_lib.o: ../../include/openssl/err.h ../../include/openssl/evp.h
124rand_lib.o: ../../include/openssl/fips.h ../../include/openssl/fips_rand.h
106rand_lib.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h 125rand_lib.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
107rand_lib.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h 126rand_lib.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
108rand_lib.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h 127rand_lib.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
109rand_lib.o: ../../include/openssl/pkcs7.h ../../include/openssl/rand.h 128rand_lib.o: ../../include/openssl/pkcs7.h ../../include/openssl/rand.h
110rand_lib.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h 129rand_lib.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
111rand_lib.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 130rand_lib.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
131rand_lib.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
112rand_lib.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h 132rand_lib.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
113rand_lib.o: ../cryptlib.h rand_lib.c 133rand_lib.o: ../cryptlib.h rand_lcl.h rand_lib.c
114rand_nw.o: ../../e_os.h ../../include/openssl/asn1.h 134rand_nw.o: ../../e_os.h ../../include/openssl/asn1.h
115rand_nw.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h 135rand_nw.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
116rand_nw.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h 136rand_nw.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
117rand_nw.o: ../../include/openssl/err.h ../../include/openssl/evp.h 137rand_nw.o: ../../include/openssl/err.h ../../include/openssl/evp.h
118rand_nw.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h 138rand_nw.o: ../../include/openssl/fips.h ../../include/openssl/lhash.h
119rand_nw.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h 139rand_nw.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
120rand_nw.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h 140rand_nw.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
121rand_nw.o: ../../include/openssl/rand.h ../../include/openssl/safestack.h 141rand_nw.o: ../../include/openssl/ossl_typ.h ../../include/openssl/rand.h
122rand_nw.o: ../../include/openssl/sha.h ../../include/openssl/stack.h 142rand_nw.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
123rand_nw.o: ../../include/openssl/symhacks.h ../cryptlib.h rand_lcl.h rand_nw.c 143rand_nw.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
144rand_nw.o: ../cryptlib.h rand_lcl.h rand_nw.c
124rand_os2.o: ../../e_os.h ../../include/openssl/asn1.h 145rand_os2.o: ../../e_os.h ../../include/openssl/asn1.h
125rand_os2.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h 146rand_os2.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
126rand_os2.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h 147rand_os2.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
127rand_os2.o: ../../include/openssl/err.h ../../include/openssl/evp.h 148rand_os2.o: ../../include/openssl/err.h ../../include/openssl/evp.h
128rand_os2.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h 149rand_os2.o: ../../include/openssl/fips.h ../../include/openssl/lhash.h
129rand_os2.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h 150rand_os2.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
151rand_os2.o: ../../include/openssl/opensslconf.h
130rand_os2.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h 152rand_os2.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
131rand_os2.o: ../../include/openssl/rand.h ../../include/openssl/safestack.h 153rand_os2.o: ../../include/openssl/rand.h ../../include/openssl/safestack.h
132rand_os2.o: ../../include/openssl/sha.h ../../include/openssl/stack.h 154rand_os2.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
@@ -136,8 +158,8 @@ rand_unix.o: ../../e_os.h ../../include/openssl/asn1.h
136rand_unix.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h 158rand_unix.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
137rand_unix.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h 159rand_unix.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
138rand_unix.o: ../../include/openssl/err.h ../../include/openssl/evp.h 160rand_unix.o: ../../include/openssl/err.h ../../include/openssl/evp.h
139rand_unix.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h 161rand_unix.o: ../../include/openssl/fips.h ../../include/openssl/lhash.h
140rand_unix.o: ../../include/openssl/objects.h 162rand_unix.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
141rand_unix.o: ../../include/openssl/opensslconf.h 163rand_unix.o: ../../include/openssl/opensslconf.h
142rand_unix.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h 164rand_unix.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
143rand_unix.o: ../../include/openssl/rand.h ../../include/openssl/safestack.h 165rand_unix.o: ../../include/openssl/rand.h ../../include/openssl/safestack.h
@@ -148,8 +170,9 @@ rand_win.o: ../../e_os.h ../../include/openssl/asn1.h
148rand_win.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h 170rand_win.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
149rand_win.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h 171rand_win.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
150rand_win.o: ../../include/openssl/err.h ../../include/openssl/evp.h 172rand_win.o: ../../include/openssl/err.h ../../include/openssl/evp.h
151rand_win.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h 173rand_win.o: ../../include/openssl/fips.h ../../include/openssl/lhash.h
152rand_win.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h 174rand_win.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
175rand_win.o: ../../include/openssl/opensslconf.h
153rand_win.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h 176rand_win.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
154rand_win.o: ../../include/openssl/rand.h ../../include/openssl/safestack.h 177rand_win.o: ../../include/openssl/rand.h ../../include/openssl/safestack.h
155rand_win.o: ../../include/openssl/sha.h ../../include/openssl/stack.h 178rand_win.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
diff --git a/src/lib/libcrypto/rand/md_rand.c b/src/lib/libcrypto/rand/md_rand.c
index 9783d0c23e..0f8dd3e00f 100644
--- a/src/lib/libcrypto/rand/md_rand.c
+++ b/src/lib/libcrypto/rand/md_rand.c
@@ -126,6 +126,10 @@
126 126
127#include <openssl/crypto.h> 127#include <openssl/crypto.h>
128#include <openssl/err.h> 128#include <openssl/err.h>
129#ifdef OPENSSL_FIPS
130#include <openssl/fips.h>
131#endif
132
129 133
130#ifdef BN_DEBUG 134#ifdef BN_DEBUG
131# define PREDICT 135# define PREDICT
@@ -332,6 +336,14 @@ static int ssleay_rand_bytes(unsigned char *buf, int num)
332#endif 336#endif
333 int do_stir_pool = 0; 337 int do_stir_pool = 0;
334 338
339#ifdef OPENSSL_FIPS
340 if(FIPS_mode())
341 {
342 FIPSerr(FIPS_F_SSLEAY_RAND_BYTES,FIPS_R_NON_FIPS_METHOD);
343 return 0;
344 }
345#endif
346
335#ifdef PREDICT 347#ifdef PREDICT
336 if (rand_predictable) 348 if (rand_predictable)
337 { 349 {
diff --git a/src/lib/libcrypto/rand/rand.h b/src/lib/libcrypto/rand/rand.h
index ac6c021763..ea89153cba 100644
--- a/src/lib/libcrypto/rand/rand.h
+++ b/src/lib/libcrypto/rand/rand.h
@@ -72,7 +72,7 @@ extern "C" {
72#endif 72#endif
73 73
74#if defined(OPENSSL_FIPS) 74#if defined(OPENSSL_FIPS)
75#define FIPS_RAND_SIZE_T size_t 75#define FIPS_RAND_SIZE_T int
76#endif 76#endif
77 77
78/* Already defined in ossl_typ.h */ 78/* Already defined in ossl_typ.h */
@@ -111,6 +111,15 @@ int RAND_query_egd_bytes(const char *path, unsigned char *buf, int bytes);
111int RAND_egd(const char *path); 111int RAND_egd(const char *path);
112int RAND_egd_bytes(const char *path,int bytes); 112int RAND_egd_bytes(const char *path,int bytes);
113int RAND_poll(void); 113int RAND_poll(void);
114#ifndef OPENSSL_NO_ENGINE
115#ifdef OPENSSL_FIPS
116void int_RAND_init_engine_callbacks(void);
117void int_RAND_set_callbacks(
118 int (*set_rand_func)(const RAND_METHOD *meth,
119 const RAND_METHOD **pmeth),
120 const RAND_METHOD *(*get_rand_func)(const RAND_METHOD **pmeth));
121#endif
122#endif
114 123
115#if defined(OPENSSL_SYS_WINDOWS) || defined(OPENSSL_SYS_WIN32) 124#if defined(OPENSSL_SYS_WINDOWS) || defined(OPENSSL_SYS_WIN32)
116 125
@@ -128,11 +137,29 @@ void ERR_load_RAND_strings(void);
128/* Error codes for the RAND functions. */ 137/* Error codes for the RAND functions. */
129 138
130/* Function codes. */ 139/* Function codes. */
140#define RAND_F_ENG_RAND_GET_RAND_METHOD 108
141#define RAND_F_FIPS_RAND 103
142#define RAND_F_FIPS_RAND_BYTES 102
143#define RAND_F_FIPS_RAND_GET_RAND_METHOD 109
144#define RAND_F_FIPS_RAND_SET_DT 106
145#define RAND_F_FIPS_SET_DT 104
146#define RAND_F_FIPS_SET_PRNG_SEED 107
147#define RAND_F_FIPS_SET_TEST_MODE 105
131#define RAND_F_RAND_GET_RAND_METHOD 101 148#define RAND_F_RAND_GET_RAND_METHOD 101
132#define RAND_F_SSLEAY_RAND_BYTES 100 149#define RAND_F_SSLEAY_RAND_BYTES 100
133 150
134/* Reason codes. */ 151/* Reason codes. */
152#define RAND_R_NON_FIPS_METHOD 105
153#define RAND_R_NOT_IN_TEST_MODE 106
154#define RAND_R_NO_KEY_SET 107
155#define RAND_R_PRNG_ASKING_FOR_TOO_MUCH 101
156#define RAND_R_PRNG_ERROR 108
157#define RAND_R_PRNG_KEYED 109
158#define RAND_R_PRNG_NOT_REKEYED 102
159#define RAND_R_PRNG_NOT_RESEEDED 103
135#define RAND_R_PRNG_NOT_SEEDED 100 160#define RAND_R_PRNG_NOT_SEEDED 100
161#define RAND_R_PRNG_SEED_MUST_NOT_MATCH_KEY 110
162#define RAND_R_PRNG_STUCK 104
136 163
137#ifdef __cplusplus 164#ifdef __cplusplus
138} 165}
diff --git a/src/lib/libcrypto/rand/rand_err.c b/src/lib/libcrypto/rand/rand_err.c
index 386934dcd1..829fb44d77 100644
--- a/src/lib/libcrypto/rand/rand_err.c
+++ b/src/lib/libcrypto/rand/rand_err.c
@@ -1,6 +1,6 @@
1/* crypto/rand/rand_err.c */ 1/* crypto/rand/rand_err.c */
2/* ==================================================================== 2/* ====================================================================
3 * Copyright (c) 1999-2005 The OpenSSL Project. All rights reserved. 3 * Copyright (c) 1999-2007 The OpenSSL Project. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
@@ -70,6 +70,14 @@
70 70
71static ERR_STRING_DATA RAND_str_functs[]= 71static ERR_STRING_DATA RAND_str_functs[]=
72 { 72 {
73{ERR_FUNC(RAND_F_ENG_RAND_GET_RAND_METHOD), "ENG_RAND_GET_RAND_METHOD"},
74{ERR_FUNC(RAND_F_FIPS_RAND), "FIPS_RAND"},
75{ERR_FUNC(RAND_F_FIPS_RAND_BYTES), "FIPS_RAND_BYTES"},
76{ERR_FUNC(RAND_F_FIPS_RAND_GET_RAND_METHOD), "FIPS_RAND_GET_RAND_METHOD"},
77{ERR_FUNC(RAND_F_FIPS_RAND_SET_DT), "FIPS_RAND_SET_DT"},
78{ERR_FUNC(RAND_F_FIPS_SET_DT), "FIPS_SET_DT"},
79{ERR_FUNC(RAND_F_FIPS_SET_PRNG_SEED), "FIPS_SET_PRNG_SEED"},
80{ERR_FUNC(RAND_F_FIPS_SET_TEST_MODE), "FIPS_SET_TEST_MODE"},
73{ERR_FUNC(RAND_F_RAND_GET_RAND_METHOD), "RAND_get_rand_method"}, 81{ERR_FUNC(RAND_F_RAND_GET_RAND_METHOD), "RAND_get_rand_method"},
74{ERR_FUNC(RAND_F_SSLEAY_RAND_BYTES), "SSLEAY_RAND_BYTES"}, 82{ERR_FUNC(RAND_F_SSLEAY_RAND_BYTES), "SSLEAY_RAND_BYTES"},
75{0,NULL} 83{0,NULL}
@@ -77,7 +85,17 @@ static ERR_STRING_DATA RAND_str_functs[]=
77 85
78static ERR_STRING_DATA RAND_str_reasons[]= 86static ERR_STRING_DATA RAND_str_reasons[]=
79 { 87 {
88{ERR_REASON(RAND_R_NON_FIPS_METHOD) ,"non fips method"},
89{ERR_REASON(RAND_R_NOT_IN_TEST_MODE) ,"not in test mode"},
90{ERR_REASON(RAND_R_NO_KEY_SET) ,"no key set"},
91{ERR_REASON(RAND_R_PRNG_ASKING_FOR_TOO_MUCH),"prng asking for too much"},
92{ERR_REASON(RAND_R_PRNG_ERROR) ,"prng error"},
93{ERR_REASON(RAND_R_PRNG_KEYED) ,"prng keyed"},
94{ERR_REASON(RAND_R_PRNG_NOT_REKEYED) ,"prng not rekeyed"},
95{ERR_REASON(RAND_R_PRNG_NOT_RESEEDED) ,"prng not reseeded"},
80{ERR_REASON(RAND_R_PRNG_NOT_SEEDED) ,"PRNG not seeded"}, 96{ERR_REASON(RAND_R_PRNG_NOT_SEEDED) ,"PRNG not seeded"},
97{ERR_REASON(RAND_R_PRNG_SEED_MUST_NOT_MATCH_KEY),"prng seed must not match key"},
98{ERR_REASON(RAND_R_PRNG_STUCK) ,"prng stuck"},
81{0,NULL} 99{0,NULL}
82 }; 100 };
83 101
diff --git a/src/lib/libcrypto/rand/rand_lcl.h b/src/lib/libcrypto/rand/rand_lcl.h
index 618a8ec899..18cc9b1e4a 100644
--- a/src/lib/libcrypto/rand/rand_lcl.h
+++ b/src/lib/libcrypto/rand/rand_lcl.h
@@ -154,5 +154,16 @@
154#define MD(a,b,c) EVP_Digest(a,b,c,NULL,EVP_md2(), NULL) 154#define MD(a,b,c) EVP_Digest(a,b,c,NULL,EVP_md2(), NULL)
155#endif 155#endif
156 156
157#ifndef OPENSSL_NO_ENGINE
158void int_RAND_set_callbacks(
159 int (*set_rand_func)(const RAND_METHOD *meth,
160 const RAND_METHOD **pmeth),
161 const RAND_METHOD *(*get_rand_func)
162 (const RAND_METHOD **pmeth));
163int eng_RAND_set_rand_method(const RAND_METHOD *meth,
164 const RAND_METHOD **pmeth);
165const RAND_METHOD *eng_RAND_get_rand_method(const RAND_METHOD **pmeth);
166#endif
167
157 168
158#endif 169#endif
diff --git a/src/lib/libcrypto/rand/rand_lib.c b/src/lib/libcrypto/rand/rand_lib.c
index 513e338985..da6b4e0e86 100644
--- a/src/lib/libcrypto/rand/rand_lib.c
+++ b/src/lib/libcrypto/rand/rand_lib.c
@@ -60,15 +60,82 @@
60#include <time.h> 60#include <time.h>
61#include "cryptlib.h" 61#include "cryptlib.h"
62#include <openssl/rand.h> 62#include <openssl/rand.h>
63#include "rand_lcl.h"
64#ifdef OPENSSL_FIPS
65#include <openssl/fips.h>
66#include <openssl/fips_rand.h>
67#endif
68
63#ifndef OPENSSL_NO_ENGINE 69#ifndef OPENSSL_NO_ENGINE
64#include <openssl/engine.h> 70#include <openssl/engine.h>
65#endif 71#endif
66 72
73static const RAND_METHOD *default_RAND_meth = NULL;
74
75#ifdef OPENSSL_FIPS
76
77static int fips_RAND_set_rand_method(const RAND_METHOD *meth,
78 const RAND_METHOD **pmeth)
79 {
80 *pmeth = meth;
81 return 1;
82 }
83
84static const RAND_METHOD *fips_RAND_get_rand_method(const RAND_METHOD **pmeth)
85 {
86 if (!*pmeth)
87 {
88 if(FIPS_mode())
89 *pmeth=FIPS_rand_method();
90 else
91 *pmeth = RAND_SSLeay();
92 }
93
94 if(FIPS_mode()
95 && *pmeth != FIPS_rand_check())
96 {
97 RANDerr(RAND_F_FIPS_RAND_GET_RAND_METHOD,RAND_R_NON_FIPS_METHOD);
98 return 0;
99 }
100
101 return *pmeth;
102 }
103
104static int (*RAND_set_rand_method_func)(const RAND_METHOD *meth,
105 const RAND_METHOD **pmeth)
106 = fips_RAND_set_rand_method;
107static const RAND_METHOD *(*RAND_get_rand_method_func)
108 (const RAND_METHOD **pmeth)
109 = fips_RAND_get_rand_method;
110
111#ifndef OPENSSL_NO_ENGINE
112void int_RAND_set_callbacks(
113 int (*set_rand_func)(const RAND_METHOD *meth,
114 const RAND_METHOD **pmeth),
115 const RAND_METHOD *(*get_rand_func)
116 (const RAND_METHOD **pmeth))
117 {
118 RAND_set_rand_method_func = set_rand_func;
119 RAND_get_rand_method_func = get_rand_func;
120 }
121#endif
122
123int RAND_set_rand_method(const RAND_METHOD *meth)
124 {
125 return RAND_set_rand_method_func(meth, &default_RAND_meth);
126 }
127
128const RAND_METHOD *RAND_get_rand_method(void)
129 {
130 return RAND_get_rand_method_func(&default_RAND_meth);
131 }
132
133#else
134
67#ifndef OPENSSL_NO_ENGINE 135#ifndef OPENSSL_NO_ENGINE
68/* non-NULL if default_RAND_meth is ENGINE-provided */ 136/* non-NULL if default_RAND_meth is ENGINE-provided */
69static ENGINE *funct_ref =NULL; 137static ENGINE *funct_ref =NULL;
70#endif 138#endif
71static const RAND_METHOD *default_RAND_meth = NULL;
72 139
73int RAND_set_rand_method(const RAND_METHOD *meth) 140int RAND_set_rand_method(const RAND_METHOD *meth)
74 { 141 {
@@ -129,6 +196,8 @@ int RAND_set_rand_engine(ENGINE *engine)
129 } 196 }
130#endif 197#endif
131 198
199#endif
200
132void RAND_cleanup(void) 201void RAND_cleanup(void)
133 { 202 {
134 const RAND_METHOD *meth = RAND_get_rand_method(); 203 const RAND_METHOD *meth = RAND_get_rand_method();
diff --git a/src/lib/libcrypto/rand/randfile.c b/src/lib/libcrypto/rand/randfile.c
index 005cb38cb0..f63fbc1731 100644
--- a/src/lib/libcrypto/rand/randfile.c
+++ b/src/lib/libcrypto/rand/randfile.c
@@ -81,10 +81,25 @@
81# include <sys/stat.h> 81# include <sys/stat.h>
82#endif 82#endif
83 83
84#ifdef _WIN32
85#define stat _stat
86#define chmod _chmod
87#define open _open
88#define fdopen _fdopen
89#endif
90
84#undef BUFSIZE 91#undef BUFSIZE
85#define BUFSIZE 1024 92#define BUFSIZE 1024
86#define RAND_DATA 1024 93#define RAND_DATA 1024
87 94
95#ifdef OPENSSL_SYS_VMS
96/* This declaration is a nasty hack to get around vms' extension to fopen
97 * for passing in sharing options being disabled by our /STANDARD=ANSI89 */
98static FILE *(*const vms_fopen)(const char *, const char *, ...) =
99 (FILE *(*)(const char *, const char *, ...))fopen;
100#define VMS_OPEN_ATTRS "shr=get,put,upd,del","ctx=bin,stm","rfm=stm","rat=none","mrs=0"
101#endif
102
88/* #define RFILE ".rnd" - defined in ../../e_os.h */ 103/* #define RFILE ".rnd" - defined in ../../e_os.h */
89 104
90/* Note that these functions are intended for seed files only. 105/* Note that these functions are intended for seed files only.
@@ -106,7 +121,11 @@ int RAND_load_file(const char *file, long bytes)
106 RAND_add(&sb,sizeof(sb),0.0); 121 RAND_add(&sb,sizeof(sb),0.0);
107 if (bytes == 0) return(ret); 122 if (bytes == 0) return(ret);
108 123
124#ifdef OPENSSL_SYS_VMS
125 in=vms_fopen(file,"rb",VMS_OPEN_ATTRS);
126#else
109 in=fopen(file,"rb"); 127 in=fopen(file,"rb");
128#endif
110 if (in == NULL) goto err; 129 if (in == NULL) goto err;
111#if defined(S_IFBLK) && defined(S_IFCHR) 130#if defined(S_IFBLK) && defined(S_IFCHR)
112 if (sb.st_mode & (S_IFBLK | S_IFCHR)) { 131 if (sb.st_mode & (S_IFBLK | S_IFCHR)) {
@@ -167,7 +186,7 @@ int RAND_write_file(const char *file)
167#endif 186#endif
168 } 187 }
169 188
170#if defined(O_CREAT) && !defined(OPENSSL_SYS_WIN32) 189#if defined(O_CREAT) && !defined(OPENSSL_SYS_WIN32) && !defined(OPENSSL_SYS_VMS)
171 { 190 {
172 /* For some reason Win32 can't write to files created this way */ 191 /* For some reason Win32 can't write to files created this way */
173 192
@@ -178,8 +197,34 @@ int RAND_write_file(const char *file)
178 out = fdopen(fd, "wb"); 197 out = fdopen(fd, "wb");
179 } 198 }
180#endif 199#endif
200
201#ifdef OPENSSL_SYS_VMS
202 /* VMS NOTE: Prior versions of this routine created a _new_
203 * version of the rand file for each call into this routine, then
204 * deleted all existing versions named ;-1, and finally renamed
205 * the current version as ';1'. Under concurrent usage, this
206 * resulted in an RMS race condition in rename() which could
207 * orphan files (see vms message help for RMS$_REENT). With the
208 * fopen() calls below, openssl/VMS now shares the top-level
209 * version of the rand file. Note that there may still be
210 * conditions where the top-level rand file is locked. If so, this
211 * code will then create a new version of the rand file. Without
212 * the delete and rename code, this can result in ascending file
213 * versions that stop at version 32767, and this routine will then
214 * return an error. The remedy for this is to recode the calling
215 * application to avoid concurrent use of the rand file, or
216 * synchronize usage at the application level. Also consider
217 * whether or not you NEED a persistent rand file in a concurrent
218 * use situation.
219 */
220
221 out = vms_fopen(file,"rb+",VMS_OPEN_ATTRS);
222 if (out == NULL)
223 out = vms_fopen(file,"wb",VMS_OPEN_ATTRS);
224#else
181 if (out == NULL) 225 if (out == NULL)
182 out = fopen(file,"wb"); 226 out = fopen(file,"wb");
227#endif
183 if (out == NULL) goto err; 228 if (out == NULL) goto err;
184 229
185#ifndef NO_CHMOD 230#ifndef NO_CHMOD
@@ -201,25 +246,6 @@ int RAND_write_file(const char *file)
201 ret+=i; 246 ret+=i;
202 if (n <= 0) break; 247 if (n <= 0) break;
203 } 248 }
204#ifdef OPENSSL_SYS_VMS
205 /* Try to delete older versions of the file, until there aren't
206 any */
207 {
208 char *tmpf;
209
210 tmpf = OPENSSL_malloc(strlen(file) + 4); /* to add ";-1" and a nul */
211 if (tmpf)
212 {
213 strcpy(tmpf, file);
214 strcat(tmpf, ";-1");
215 while(delete(tmpf) == 0)
216 ;
217 rename(file,";1"); /* Make sure it's version 1, or we
218 will reach the limit (32767) at
219 some point... */
220 }
221 }
222#endif /* OPENSSL_SYS_VMS */
223 249
224 fclose(out); 250 fclose(out);
225 OPENSSL_cleanse(buf,BUFSIZE); 251 OPENSSL_cleanse(buf,BUFSIZE);
diff --git a/src/lib/libcrypto/rc2/rc2.h b/src/lib/libcrypto/rc2/rc2.h
index 34c8362317..e542ec94ff 100644
--- a/src/lib/libcrypto/rc2/rc2.h
+++ b/src/lib/libcrypto/rc2/rc2.h
@@ -79,7 +79,9 @@ typedef struct rc2_key_st
79 RC2_INT data[64]; 79 RC2_INT data[64];
80 } RC2_KEY; 80 } RC2_KEY;
81 81
82 82#ifdef OPENSSL_FIPS
83void private_RC2_set_key(RC2_KEY *key, int len, const unsigned char *data,int bits);
84#endif
83void RC2_set_key(RC2_KEY *key, int len, const unsigned char *data,int bits); 85void RC2_set_key(RC2_KEY *key, int len, const unsigned char *data,int bits);
84void RC2_ecb_encrypt(const unsigned char *in,unsigned char *out,RC2_KEY *key, 86void RC2_ecb_encrypt(const unsigned char *in,unsigned char *out,RC2_KEY *key,
85 int enc); 87 int enc);
diff --git a/src/lib/libcrypto/rc2/rc2_skey.c b/src/lib/libcrypto/rc2/rc2_skey.c
index 4953642056..4e000e5b99 100644
--- a/src/lib/libcrypto/rc2/rc2_skey.c
+++ b/src/lib/libcrypto/rc2/rc2_skey.c
@@ -57,6 +57,11 @@
57 */ 57 */
58 58
59#include <openssl/rc2.h> 59#include <openssl/rc2.h>
60#include <openssl/crypto.h>
61#ifdef OPENSSL_FIPS
62#include <openssl/fips.h>
63#endif
64
60#include "rc2_locl.h" 65#include "rc2_locl.h"
61 66
62static unsigned char key_table[256]={ 67static unsigned char key_table[256]={
@@ -94,8 +99,20 @@ static unsigned char key_table[256]={
94 * BSAFE uses the 'retarded' version. What I previously shipped is 99 * BSAFE uses the 'retarded' version. What I previously shipped is
95 * the same as specifying 1024 for the 'bits' parameter. Bsafe uses 100 * the same as specifying 1024 for the 'bits' parameter. Bsafe uses
96 * a version where the bits parameter is the same as len*8 */ 101 * a version where the bits parameter is the same as len*8 */
102
103#ifdef OPENSSL_FIPS
97void RC2_set_key(RC2_KEY *key, int len, const unsigned char *data, int bits) 104void RC2_set_key(RC2_KEY *key, int len, const unsigned char *data, int bits)
98 { 105 {
106 if (FIPS_mode())
107 FIPS_BAD_ABORT(RC2)
108 private_RC2_set_key(key, len, data, bits);
109 }
110void private_RC2_set_key(RC2_KEY *key, int len, const unsigned char *data,
111 int bits)
112#else
113void RC2_set_key(RC2_KEY *key, int len, const unsigned char *data, int bits)
114#endif
115 {
99 int i,j; 116 int i,j;
100 unsigned char *k; 117 unsigned char *k;
101 RC2_INT *ki; 118 RC2_INT *ki;
diff --git a/src/lib/libcrypto/rc4/asm/rc4-x86_64.pl b/src/lib/libcrypto/rc4/asm/rc4-x86_64.pl
index 92c52f3433..3a54623495 100755
--- a/src/lib/libcrypto/rc4/asm/rc4-x86_64.pl
+++ b/src/lib/libcrypto/rc4/asm/rc4-x86_64.pl
@@ -358,6 +358,8 @@ ___
358 358
359$code =~ s/#([bwd])/$1/gm; 359$code =~ s/#([bwd])/$1/gm;
360 360
361$code =~ s/RC4_set_key/private_RC4_set_key/g if ($ENV{FIPSCANLIB} ne "");
362
361print $code; 363print $code;
362 364
363close STDOUT; 365close STDOUT;
diff --git a/src/lib/libcrypto/rc4/rc4.h b/src/lib/libcrypto/rc4/rc4.h
index 7aec04fe93..2d8620d33b 100644
--- a/src/lib/libcrypto/rc4/rc4.h
+++ b/src/lib/libcrypto/rc4/rc4.h
@@ -76,6 +76,9 @@ typedef struct rc4_key_st
76 76
77 77
78const char *RC4_options(void); 78const char *RC4_options(void);
79#ifdef OPENSSL_FIPS
80void private_RC4_set_key(RC4_KEY *key, int len, const unsigned char *data);
81#endif
79void RC4_set_key(RC4_KEY *key, int len, const unsigned char *data); 82void RC4_set_key(RC4_KEY *key, int len, const unsigned char *data);
80void RC4(RC4_KEY *key, unsigned long len, const unsigned char *indata, 83void RC4(RC4_KEY *key, unsigned long len, const unsigned char *indata,
81 unsigned char *outdata); 84 unsigned char *outdata);
diff --git a/src/lib/libcrypto/rc4/rc4_skey.c b/src/lib/libcrypto/rc4/rc4_skey.c
index 46b77ec321..4478d1a4b3 100644
--- a/src/lib/libcrypto/rc4/rc4_skey.c
+++ b/src/lib/libcrypto/rc4/rc4_skey.c
@@ -59,6 +59,11 @@
59#include <openssl/rc4.h> 59#include <openssl/rc4.h>
60#include "rc4_locl.h" 60#include "rc4_locl.h"
61#include <openssl/opensslv.h> 61#include <openssl/opensslv.h>
62#include <openssl/crypto.h>
63#ifdef OPENSSL_FIPS
64#include <openssl/fips.h>
65#endif
66
62 67
63const char RC4_version[]="RC4" OPENSSL_VERSION_PTEXT; 68const char RC4_version[]="RC4" OPENSSL_VERSION_PTEXT;
64 69
@@ -85,7 +90,11 @@ const char *RC4_options(void)
85 * Date: Wed, 14 Sep 1994 06:35:31 GMT 90 * Date: Wed, 14 Sep 1994 06:35:31 GMT
86 */ 91 */
87 92
93#ifdef OPENSSL_FIPS
94void private_RC4_set_key(RC4_KEY *key, int len, const unsigned char *data)
95#else
88void RC4_set_key(RC4_KEY *key, int len, const unsigned char *data) 96void RC4_set_key(RC4_KEY *key, int len, const unsigned char *data)
97#endif
89 { 98 {
90 register RC4_INT tmp; 99 register RC4_INT tmp;
91 register int id1,id2; 100 register int id1,id2;
@@ -127,7 +136,12 @@ void RC4_set_key(RC4_KEY *key, int len, const unsigned char *data)
127 * 136 *
128 * <appro@fy.chalmers.se> 137 * <appro@fy.chalmers.se>
129 */ 138 */
130 if (OPENSSL_ia32cap_P & (1<<20)) { 139#ifdef OPENSSL_FIPS
140 unsigned long *ia32cap_ptr = OPENSSL_ia32cap_loc();
141 if (ia32cap_ptr && (*ia32cap_ptr & (1<<28))) {
142#else
143 if (OPENSSL_ia32cap_P & (1<<28)) {
144#endif
131 unsigned char *cp=(unsigned char *)d; 145 unsigned char *cp=(unsigned char *)d;
132 146
133 for (i=0;i<256;i++) cp[i]=i; 147 for (i=0;i<256;i++) cp[i]=i;
diff --git a/src/lib/libcrypto/rc5/rc5.h b/src/lib/libcrypto/rc5/rc5.h
index 4b3c153b50..f73a2a02a4 100644
--- a/src/lib/libcrypto/rc5/rc5.h
+++ b/src/lib/libcrypto/rc5/rc5.h
@@ -94,7 +94,10 @@ typedef struct rc5_key_st
94 RC5_32_INT data[2*(RC5_16_ROUNDS+1)]; 94 RC5_32_INT data[2*(RC5_16_ROUNDS+1)];
95 } RC5_32_KEY; 95 } RC5_32_KEY;
96 96
97 97#ifdef OPENSSL_FIPS
98void private_RC5_32_set_key(RC5_32_KEY *key, int len, const unsigned char *data,
99 int rounds);
100#endif
98void RC5_32_set_key(RC5_32_KEY *key, int len, const unsigned char *data, 101void RC5_32_set_key(RC5_32_KEY *key, int len, const unsigned char *data,
99 int rounds); 102 int rounds);
100void RC5_32_ecb_encrypt(const unsigned char *in,unsigned char *out,RC5_32_KEY *key, 103void RC5_32_ecb_encrypt(const unsigned char *in,unsigned char *out,RC5_32_KEY *key,
diff --git a/src/lib/libcrypto/ripemd/ripemd.h b/src/lib/libcrypto/ripemd/ripemd.h
index 033a5965b5..3b6d04386d 100644
--- a/src/lib/libcrypto/ripemd/ripemd.h
+++ b/src/lib/libcrypto/ripemd/ripemd.h
@@ -90,7 +90,9 @@ typedef struct RIPEMD160state_st
90 RIPEMD160_LONG data[RIPEMD160_LBLOCK]; 90 RIPEMD160_LONG data[RIPEMD160_LBLOCK];
91 unsigned int num; 91 unsigned int num;
92 } RIPEMD160_CTX; 92 } RIPEMD160_CTX;
93 93#ifdef OPENSSL_FIPS
94int private_RIPEMD160_Init(RIPEMD160_CTX *c);
95#endif
94int RIPEMD160_Init(RIPEMD160_CTX *c); 96int RIPEMD160_Init(RIPEMD160_CTX *c);
95int RIPEMD160_Update(RIPEMD160_CTX *c, const void *data, size_t len); 97int RIPEMD160_Update(RIPEMD160_CTX *c, const void *data, size_t len);
96int RIPEMD160_Final(unsigned char *md, RIPEMD160_CTX *c); 98int RIPEMD160_Final(unsigned char *md, RIPEMD160_CTX *c);
diff --git a/src/lib/libcrypto/ripemd/rmd_dgst.c b/src/lib/libcrypto/ripemd/rmd_dgst.c
index 1f2401aa7e..a845e17ed8 100644
--- a/src/lib/libcrypto/ripemd/rmd_dgst.c
+++ b/src/lib/libcrypto/ripemd/rmd_dgst.c
@@ -59,6 +59,11 @@
59#include <stdio.h> 59#include <stdio.h>
60#include "rmd_locl.h" 60#include "rmd_locl.h"
61#include <openssl/opensslv.h> 61#include <openssl/opensslv.h>
62#include <openssl/err.h>
63#ifdef OPENSSL_FIPS
64#include <openssl/fips.h>
65#endif
66
62 67
63const char RMD160_version[]="RIPE-MD160" OPENSSL_VERSION_PTEXT; 68const char RMD160_version[]="RIPE-MD160" OPENSSL_VERSION_PTEXT;
64 69
@@ -69,7 +74,7 @@ const char RMD160_version[]="RIPE-MD160" OPENSSL_VERSION_PTEXT;
69 void ripemd160_block(RIPEMD160_CTX *c, unsigned long *p,size_t num); 74 void ripemd160_block(RIPEMD160_CTX *c, unsigned long *p,size_t num);
70# endif 75# endif
71 76
72int RIPEMD160_Init(RIPEMD160_CTX *c) 77FIPS_NON_FIPS_MD_Init(RIPEMD160)
73 { 78 {
74 c->A=RIPEMD160_A; 79 c->A=RIPEMD160_A;
75 c->B=RIPEMD160_B; 80 c->B=RIPEMD160_B;
diff --git a/src/lib/libcrypto/ripemd/rmd_locl.h b/src/lib/libcrypto/ripemd/rmd_locl.h
index f14b346e66..ce12a8000e 100644
--- a/src/lib/libcrypto/ripemd/rmd_locl.h
+++ b/src/lib/libcrypto/ripemd/rmd_locl.h
@@ -72,7 +72,7 @@
72 */ 72 */
73#ifdef RMD160_ASM 73#ifdef RMD160_ASM
74# if defined(__i386) || defined(__i386__) || defined(_M_IX86) || defined(__INTEL__) 74# if defined(__i386) || defined(__i386__) || defined(_M_IX86) || defined(__INTEL__)
75# define ripemd160_block_data_order ripemd160_block_asm_data_order 75# define ripemd160_block_host_order ripemd160_block_asm_data_order
76# endif 76# endif
77#endif 77#endif
78 78
diff --git a/src/lib/libcrypto/rsa/Makefile b/src/lib/libcrypto/rsa/Makefile
index 8f1c611800..7b1fd6428c 100644
--- a/src/lib/libcrypto/rsa/Makefile
+++ b/src/lib/libcrypto/rsa/Makefile
@@ -19,10 +19,10 @@ APPS=
19LIB=$(TOP)/libcrypto.a 19LIB=$(TOP)/libcrypto.a
20LIBSRC= rsa_eay.c rsa_gen.c rsa_lib.c rsa_sign.c rsa_saos.c rsa_err.c \ 20LIBSRC= rsa_eay.c rsa_gen.c rsa_lib.c rsa_sign.c rsa_saos.c rsa_err.c \
21 rsa_pk1.c rsa_ssl.c rsa_none.c rsa_oaep.c rsa_chk.c rsa_null.c \ 21 rsa_pk1.c rsa_ssl.c rsa_none.c rsa_oaep.c rsa_chk.c rsa_null.c \
22 rsa_pss.c rsa_x931.c rsa_asn1.c rsa_depr.c 22 rsa_pss.c rsa_x931.c rsa_x931g.c rsa_asn1.c rsa_depr.c rsa_eng.c
23LIBOBJ= rsa_eay.o rsa_gen.o rsa_lib.o rsa_sign.o rsa_saos.o rsa_err.o \ 23LIBOBJ= rsa_eay.o rsa_gen.o rsa_lib.o rsa_sign.o rsa_saos.o rsa_err.o \
24 rsa_pk1.o rsa_ssl.o rsa_none.o rsa_oaep.o rsa_chk.o rsa_null.o \ 24 rsa_pk1.o rsa_ssl.o rsa_none.o rsa_oaep.o rsa_chk.o rsa_null.o \
25 rsa_pss.o rsa_x931.o rsa_asn1.o rsa_depr.o 25 rsa_pss.o rsa_x931.o rsa_x931g.o rsa_asn1.o rsa_depr.o rsa_eng.o
26 26
27SRC= $(LIBSRC) 27SRC= $(LIBSRC)
28 28
@@ -37,7 +37,7 @@ top:
37all: lib 37all: lib
38 38
39lib: $(LIBOBJ) 39lib: $(LIBOBJ)
40 $(AR) $(LIB) $(LIBOBJ) 40 $(ARX) $(LIB) $(LIBOBJ)
41 $(RANLIB) $(LIB) || echo Never mind. 41 $(RANLIB) $(LIB) || echo Never mind.
42 @touch lib 42 @touch lib
43 43
@@ -114,6 +114,21 @@ rsa_eay.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
114rsa_eay.o: ../../include/openssl/rand.h ../../include/openssl/rsa.h 114rsa_eay.o: ../../include/openssl/rand.h ../../include/openssl/rsa.h
115rsa_eay.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h 115rsa_eay.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
116rsa_eay.o: ../../include/openssl/symhacks.h ../cryptlib.h rsa_eay.c 116rsa_eay.o: ../../include/openssl/symhacks.h ../cryptlib.h rsa_eay.c
117rsa_eng.o: ../../e_os.h ../../include/openssl/asn1.h
118rsa_eng.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
119rsa_eng.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
120rsa_eng.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h
121rsa_eng.o: ../../include/openssl/ecdh.h ../../include/openssl/ecdsa.h
122rsa_eng.o: ../../include/openssl/engine.h ../../include/openssl/err.h
123rsa_eng.o: ../../include/openssl/evp.h ../../include/openssl/fips.h
124rsa_eng.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
125rsa_eng.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
126rsa_eng.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
127rsa_eng.o: ../../include/openssl/pkcs7.h ../../include/openssl/rand.h
128rsa_eng.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
129rsa_eng.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
130rsa_eng.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h
131rsa_eng.o: ../../include/openssl/x509_vfy.h ../cryptlib.h rsa_eng.c
117rsa_err.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h 132rsa_err.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
118rsa_err.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h 133rsa_err.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
119rsa_err.o: ../../include/openssl/err.h ../../include/openssl/lhash.h 134rsa_err.o: ../../include/openssl/err.h ../../include/openssl/lhash.h
@@ -136,15 +151,15 @@ rsa_lib.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
136rsa_lib.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h 151rsa_lib.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h
137rsa_lib.o: ../../include/openssl/ecdh.h ../../include/openssl/ecdsa.h 152rsa_lib.o: ../../include/openssl/ecdh.h ../../include/openssl/ecdsa.h
138rsa_lib.o: ../../include/openssl/engine.h ../../include/openssl/err.h 153rsa_lib.o: ../../include/openssl/engine.h ../../include/openssl/err.h
139rsa_lib.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h 154rsa_lib.o: ../../include/openssl/evp.h ../../include/openssl/fips.h
140rsa_lib.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h 155rsa_lib.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
141rsa_lib.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h 156rsa_lib.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
142rsa_lib.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h 157rsa_lib.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
143rsa_lib.o: ../../include/openssl/rand.h ../../include/openssl/rsa.h 158rsa_lib.o: ../../include/openssl/pkcs7.h ../../include/openssl/rand.h
144rsa_lib.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h 159rsa_lib.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
145rsa_lib.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 160rsa_lib.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
146rsa_lib.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h 161rsa_lib.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h
147rsa_lib.o: ../cryptlib.h rsa_lib.c 162rsa_lib.o: ../../include/openssl/x509_vfy.h ../cryptlib.h rsa_lib.c
148rsa_none.o: ../../e_os.h ../../include/openssl/asn1.h 163rsa_none.o: ../../e_os.h ../../include/openssl/asn1.h
149rsa_none.o: ../../include/openssl/bio.h ../../include/openssl/bn.h 164rsa_none.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
150rsa_none.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 165rsa_none.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
@@ -167,9 +182,9 @@ rsa_oaep.o: ../../e_os.h ../../include/openssl/asn1.h
167rsa_oaep.o: ../../include/openssl/bio.h ../../include/openssl/bn.h 182rsa_oaep.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
168rsa_oaep.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 183rsa_oaep.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
169rsa_oaep.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h 184rsa_oaep.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
170rsa_oaep.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h 185rsa_oaep.o: ../../include/openssl/evp.h ../../include/openssl/fips.h
171rsa_oaep.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h 186rsa_oaep.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
172rsa_oaep.o: ../../include/openssl/opensslconf.h 187rsa_oaep.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
173rsa_oaep.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h 188rsa_oaep.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
174rsa_oaep.o: ../../include/openssl/rand.h ../../include/openssl/rsa.h 189rsa_oaep.o: ../../include/openssl/rand.h ../../include/openssl/rsa.h
175rsa_oaep.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h 190rsa_oaep.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
@@ -188,21 +203,23 @@ rsa_pss.o: ../../e_os.h ../../include/openssl/asn1.h
188rsa_pss.o: ../../include/openssl/bio.h ../../include/openssl/bn.h 203rsa_pss.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
189rsa_pss.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 204rsa_pss.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
190rsa_pss.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h 205rsa_pss.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
191rsa_pss.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h 206rsa_pss.o: ../../include/openssl/evp.h ../../include/openssl/fips.h
192rsa_pss.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h 207rsa_pss.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
193rsa_pss.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h 208rsa_pss.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
194rsa_pss.o: ../../include/openssl/ossl_typ.h ../../include/openssl/rand.h 209rsa_pss.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
195rsa_pss.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h 210rsa_pss.o: ../../include/openssl/rand.h ../../include/openssl/rsa.h
196rsa_pss.o: ../../include/openssl/sha.h ../../include/openssl/stack.h 211rsa_pss.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
197rsa_pss.o: ../../include/openssl/symhacks.h ../cryptlib.h rsa_pss.c 212rsa_pss.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
213rsa_pss.o: ../cryptlib.h rsa_pss.c
198rsa_saos.o: ../../e_os.h ../../include/openssl/asn1.h 214rsa_saos.o: ../../e_os.h ../../include/openssl/asn1.h
199rsa_saos.o: ../../include/openssl/bio.h ../../include/openssl/bn.h 215rsa_saos.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
200rsa_saos.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 216rsa_saos.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
201rsa_saos.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h 217rsa_saos.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h
202rsa_saos.o: ../../include/openssl/ecdh.h ../../include/openssl/ecdsa.h 218rsa_saos.o: ../../include/openssl/ecdh.h ../../include/openssl/ecdsa.h
203rsa_saos.o: ../../include/openssl/err.h ../../include/openssl/evp.h 219rsa_saos.o: ../../include/openssl/err.h ../../include/openssl/evp.h
204rsa_saos.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h 220rsa_saos.o: ../../include/openssl/fips.h ../../include/openssl/lhash.h
205rsa_saos.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h 221rsa_saos.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
222rsa_saos.o: ../../include/openssl/opensslconf.h
206rsa_saos.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h 223rsa_saos.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
207rsa_saos.o: ../../include/openssl/pkcs7.h ../../include/openssl/rsa.h 224rsa_saos.o: ../../include/openssl/pkcs7.h ../../include/openssl/rsa.h
208rsa_saos.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h 225rsa_saos.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
@@ -215,8 +232,9 @@ rsa_sign.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
215rsa_sign.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h 232rsa_sign.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h
216rsa_sign.o: ../../include/openssl/ecdh.h ../../include/openssl/ecdsa.h 233rsa_sign.o: ../../include/openssl/ecdh.h ../../include/openssl/ecdsa.h
217rsa_sign.o: ../../include/openssl/err.h ../../include/openssl/evp.h 234rsa_sign.o: ../../include/openssl/err.h ../../include/openssl/evp.h
218rsa_sign.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h 235rsa_sign.o: ../../include/openssl/fips.h ../../include/openssl/lhash.h
219rsa_sign.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h 236rsa_sign.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
237rsa_sign.o: ../../include/openssl/opensslconf.h
220rsa_sign.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h 238rsa_sign.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
221rsa_sign.o: ../../include/openssl/pkcs7.h ../../include/openssl/rsa.h 239rsa_sign.o: ../../include/openssl/pkcs7.h ../../include/openssl/rsa.h
222rsa_sign.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h 240rsa_sign.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
@@ -242,3 +260,11 @@ rsa_x931.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
242rsa_x931.o: ../../include/openssl/rand.h ../../include/openssl/rsa.h 260rsa_x931.o: ../../include/openssl/rand.h ../../include/openssl/rsa.h
243rsa_x931.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h 261rsa_x931.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
244rsa_x931.o: ../../include/openssl/symhacks.h ../cryptlib.h rsa_x931.c 262rsa_x931.o: ../../include/openssl/symhacks.h ../cryptlib.h rsa_x931.c
263rsa_x931g.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
264rsa_x931g.o: ../../include/openssl/bn.h ../../include/openssl/crypto.h
265rsa_x931g.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
266rsa_x931g.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
267rsa_x931g.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
268rsa_x931g.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
269rsa_x931g.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
270rsa_x931g.o: rsa_x931g.c
diff --git a/src/lib/libcrypto/rsa/rsa.h b/src/lib/libcrypto/rsa/rsa.h
index 3699afaaaf..5bb932ae15 100644
--- a/src/lib/libcrypto/rsa/rsa.h
+++ b/src/lib/libcrypto/rsa/rsa.h
@@ -74,6 +74,25 @@
74#error RSA is disabled. 74#error RSA is disabled.
75#endif 75#endif
76 76
77/* If this flag is set the RSA method is FIPS compliant and can be used
78 * in FIPS mode. This is set in the validated module method. If an
79 * application sets this flag in its own methods it is its reposibility
80 * to ensure the result is compliant.
81 */
82
83#define RSA_FLAG_FIPS_METHOD 0x0400
84
85/* If this flag is set the operations normally disabled in FIPS mode are
86 * permitted it is then the applications responsibility to ensure that the
87 * usage is compliant.
88 */
89
90#define RSA_FLAG_NON_FIPS_ALLOW 0x0400
91
92#ifdef OPENSSL_FIPS
93#define FIPS_RSA_SIZE_T int
94#endif
95
77#ifdef __cplusplus 96#ifdef __cplusplus
78extern "C" { 97extern "C" {
79#endif 98#endif
@@ -163,6 +182,8 @@ struct rsa_st
163# define OPENSSL_RSA_MAX_MODULUS_BITS 16384 182# define OPENSSL_RSA_MAX_MODULUS_BITS 16384
164#endif 183#endif
165 184
185#define OPENSSL_RSA_FIPS_MIN_MODULUS_BITS 1024
186
166#ifndef OPENSSL_RSA_SMALL_MODULUS_BITS 187#ifndef OPENSSL_RSA_SMALL_MODULUS_BITS
167# define OPENSSL_RSA_SMALL_MODULUS_BITS 3072 188# define OPENSSL_RSA_SMALL_MODULUS_BITS 3072
168#endif 189#endif
@@ -240,6 +261,11 @@ RSA * RSA_generate_key(int bits, unsigned long e,void
240 261
241/* New version */ 262/* New version */
242int RSA_generate_key_ex(RSA *rsa, int bits, BIGNUM *e, BN_GENCB *cb); 263int RSA_generate_key_ex(RSA *rsa, int bits, BIGNUM *e, BN_GENCB *cb);
264int RSA_X931_derive_ex(RSA *rsa, BIGNUM *p1, BIGNUM *p2, BIGNUM *q1, BIGNUM *q2,
265 const BIGNUM *Xp1, const BIGNUM *Xp2, const BIGNUM *Xp,
266 const BIGNUM *Xq1, const BIGNUM *Xq2, const BIGNUM *Xq,
267 const BIGNUM *e, BN_GENCB *cb);
268int RSA_X931_generate_key_ex(RSA *rsa, int bits, const BIGNUM *e, BN_GENCB *cb);
243 269
244int RSA_check_key(const RSA *); 270int RSA_check_key(const RSA *);
245 /* next 4 return -1 on error */ 271 /* next 4 return -1 on error */
@@ -257,6 +283,11 @@ int RSA_up_ref(RSA *r);
257 283
258int RSA_flags(const RSA *r); 284int RSA_flags(const RSA *r);
259 285
286#ifdef OPENSSL_FIPS
287RSA *FIPS_rsa_new(void);
288void FIPS_rsa_free(RSA *r);
289#endif
290
260void RSA_set_default_method(const RSA_METHOD *meth); 291void RSA_set_default_method(const RSA_METHOD *meth);
261const RSA_METHOD *RSA_get_default_method(void); 292const RSA_METHOD *RSA_get_default_method(void);
262const RSA_METHOD *RSA_get_method(const RSA *rsa); 293const RSA_METHOD *RSA_get_method(const RSA *rsa);
@@ -370,6 +401,8 @@ void ERR_load_RSA_strings(void);
370/* Error codes for the RSA functions. */ 401/* Error codes for the RSA functions. */
371 402
372/* Function codes. */ 403/* Function codes. */
404#define RSA_F_FIPS_RSA_SIGN 140
405#define RSA_F_FIPS_RSA_VERIFY 141
373#define RSA_F_MEMORY_LOCK 100 406#define RSA_F_MEMORY_LOCK 100
374#define RSA_F_RSA_BUILTIN_KEYGEN 129 407#define RSA_F_RSA_BUILTIN_KEYGEN 129
375#define RSA_F_RSA_CHECK_KEY 123 408#define RSA_F_RSA_CHECK_KEY 123
@@ -401,7 +434,11 @@ void ERR_load_RSA_strings(void);
401#define RSA_F_RSA_PADDING_CHECK_X931 128 434#define RSA_F_RSA_PADDING_CHECK_X931 128
402#define RSA_F_RSA_PRINT 115 435#define RSA_F_RSA_PRINT 115
403#define RSA_F_RSA_PRINT_FP 116 436#define RSA_F_RSA_PRINT_FP 116
437#define RSA_F_RSA_PRIVATE_ENCRYPT 137
438#define RSA_F_RSA_PUBLIC_DECRYPT 138
404#define RSA_F_RSA_SETUP_BLINDING 136 439#define RSA_F_RSA_SETUP_BLINDING 136
440#define RSA_F_RSA_SET_DEFAULT_METHOD 139
441#define RSA_F_RSA_SET_METHOD 142
405#define RSA_F_RSA_SIGN 117 442#define RSA_F_RSA_SIGN 117
406#define RSA_F_RSA_SIGN_ASN1_OCTET_STRING 118 443#define RSA_F_RSA_SIGN_ASN1_OCTET_STRING 118
407#define RSA_F_RSA_VERIFY 119 444#define RSA_F_RSA_VERIFY 119
@@ -435,10 +472,12 @@ void ERR_load_RSA_strings(void);
435#define RSA_R_KEY_SIZE_TOO_SMALL 120 472#define RSA_R_KEY_SIZE_TOO_SMALL 120
436#define RSA_R_LAST_OCTET_INVALID 134 473#define RSA_R_LAST_OCTET_INVALID 134
437#define RSA_R_MODULUS_TOO_LARGE 105 474#define RSA_R_MODULUS_TOO_LARGE 105
475#define RSA_R_NON_FIPS_METHOD 141
438#define RSA_R_NO_PUBLIC_EXPONENT 140 476#define RSA_R_NO_PUBLIC_EXPONENT 140
439#define RSA_R_NULL_BEFORE_BLOCK_MISSING 113 477#define RSA_R_NULL_BEFORE_BLOCK_MISSING 113
440#define RSA_R_N_DOES_NOT_EQUAL_P_Q 127 478#define RSA_R_N_DOES_NOT_EQUAL_P_Q 127
441#define RSA_R_OAEP_DECODING_ERROR 121 479#define RSA_R_OAEP_DECODING_ERROR 121
480#define RSA_R_OPERATION_NOT_ALLOWED_IN_FIPS_MODE 142
442#define RSA_R_PADDING_CHECK_FAILED 114 481#define RSA_R_PADDING_CHECK_FAILED 114
443#define RSA_R_P_NOT_PRIME 128 482#define RSA_R_P_NOT_PRIME 128
444#define RSA_R_Q_NOT_PRIME 129 483#define RSA_R_Q_NOT_PRIME 129
diff --git a/src/lib/libcrypto/rsa/rsa_asn1.c b/src/lib/libcrypto/rsa/rsa_asn1.c
index bbbf26d50e..6e8a803e81 100644
--- a/src/lib/libcrypto/rsa/rsa_asn1.c
+++ b/src/lib/libcrypto/rsa/rsa_asn1.c
@@ -1,5 +1,5 @@
1/* rsa_asn1.c */ 1/* rsa_asn1.c */
2/* Written by Dr Stephen N Henson (shenson@bigfoot.com) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 2000. 3 * project 2000.
4 */ 4 */
5/* ==================================================================== 5/* ====================================================================
diff --git a/src/lib/libcrypto/rsa/rsa_eay.c b/src/lib/libcrypto/rsa/rsa_eay.c
index 5a6eda7961..04ec789ee9 100644
--- a/src/lib/libcrypto/rsa/rsa_eay.c
+++ b/src/lib/libcrypto/rsa/rsa_eay.c
@@ -115,7 +115,7 @@
115#include <openssl/rsa.h> 115#include <openssl/rsa.h>
116#include <openssl/rand.h> 116#include <openssl/rand.h>
117 117
118#ifndef RSA_NULL 118#if !defined(RSA_NULL) && !defined(OPENSSL_FIPS)
119 119
120static int RSA_eay_public_encrypt(int flen, const unsigned char *from, 120static int RSA_eay_public_encrypt(int flen, const unsigned char *from,
121 unsigned char *to, RSA *rsa,int padding); 121 unsigned char *to, RSA *rsa,int padding);
diff --git a/src/lib/libcrypto/rsa/rsa_err.c b/src/lib/libcrypto/rsa/rsa_err.c
index fe3ba1b44b..501f5ea389 100644
--- a/src/lib/libcrypto/rsa/rsa_err.c
+++ b/src/lib/libcrypto/rsa/rsa_err.c
@@ -1,6 +1,6 @@
1/* crypto/rsa/rsa_err.c */ 1/* crypto/rsa/rsa_err.c */
2/* ==================================================================== 2/* ====================================================================
3 * Copyright (c) 1999-2005 The OpenSSL Project. All rights reserved. 3 * Copyright (c) 1999-2007 The OpenSSL Project. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
@@ -70,6 +70,8 @@
70 70
71static ERR_STRING_DATA RSA_str_functs[]= 71static ERR_STRING_DATA RSA_str_functs[]=
72 { 72 {
73{ERR_FUNC(RSA_F_FIPS_RSA_SIGN), "FIPS_RSA_SIGN"},
74{ERR_FUNC(RSA_F_FIPS_RSA_VERIFY), "FIPS_RSA_VERIFY"},
73{ERR_FUNC(RSA_F_MEMORY_LOCK), "MEMORY_LOCK"}, 75{ERR_FUNC(RSA_F_MEMORY_LOCK), "MEMORY_LOCK"},
74{ERR_FUNC(RSA_F_RSA_BUILTIN_KEYGEN), "RSA_BUILTIN_KEYGEN"}, 76{ERR_FUNC(RSA_F_RSA_BUILTIN_KEYGEN), "RSA_BUILTIN_KEYGEN"},
75{ERR_FUNC(RSA_F_RSA_CHECK_KEY), "RSA_check_key"}, 77{ERR_FUNC(RSA_F_RSA_CHECK_KEY), "RSA_check_key"},
@@ -101,7 +103,11 @@ static ERR_STRING_DATA RSA_str_functs[]=
101{ERR_FUNC(RSA_F_RSA_PADDING_CHECK_X931), "RSA_padding_check_X931"}, 103{ERR_FUNC(RSA_F_RSA_PADDING_CHECK_X931), "RSA_padding_check_X931"},
102{ERR_FUNC(RSA_F_RSA_PRINT), "RSA_print"}, 104{ERR_FUNC(RSA_F_RSA_PRINT), "RSA_print"},
103{ERR_FUNC(RSA_F_RSA_PRINT_FP), "RSA_print_fp"}, 105{ERR_FUNC(RSA_F_RSA_PRINT_FP), "RSA_print_fp"},
106{ERR_FUNC(RSA_F_RSA_PRIVATE_ENCRYPT), "RSA_private_encrypt"},
107{ERR_FUNC(RSA_F_RSA_PUBLIC_DECRYPT), "RSA_public_decrypt"},
104{ERR_FUNC(RSA_F_RSA_SETUP_BLINDING), "RSA_setup_blinding"}, 108{ERR_FUNC(RSA_F_RSA_SETUP_BLINDING), "RSA_setup_blinding"},
109{ERR_FUNC(RSA_F_RSA_SET_DEFAULT_METHOD), "RSA_set_default_method"},
110{ERR_FUNC(RSA_F_RSA_SET_METHOD), "RSA_set_method"},
105{ERR_FUNC(RSA_F_RSA_SIGN), "RSA_sign"}, 111{ERR_FUNC(RSA_F_RSA_SIGN), "RSA_sign"},
106{ERR_FUNC(RSA_F_RSA_SIGN_ASN1_OCTET_STRING), "RSA_sign_ASN1_OCTET_STRING"}, 112{ERR_FUNC(RSA_F_RSA_SIGN_ASN1_OCTET_STRING), "RSA_sign_ASN1_OCTET_STRING"},
107{ERR_FUNC(RSA_F_RSA_VERIFY), "RSA_verify"}, 113{ERR_FUNC(RSA_F_RSA_VERIFY), "RSA_verify"},
@@ -138,10 +144,12 @@ static ERR_STRING_DATA RSA_str_reasons[]=
138{ERR_REASON(RSA_R_KEY_SIZE_TOO_SMALL) ,"key size too small"}, 144{ERR_REASON(RSA_R_KEY_SIZE_TOO_SMALL) ,"key size too small"},
139{ERR_REASON(RSA_R_LAST_OCTET_INVALID) ,"last octet invalid"}, 145{ERR_REASON(RSA_R_LAST_OCTET_INVALID) ,"last octet invalid"},
140{ERR_REASON(RSA_R_MODULUS_TOO_LARGE) ,"modulus too large"}, 146{ERR_REASON(RSA_R_MODULUS_TOO_LARGE) ,"modulus too large"},
147{ERR_REASON(RSA_R_NON_FIPS_METHOD) ,"non fips method"},
141{ERR_REASON(RSA_R_NO_PUBLIC_EXPONENT) ,"no public exponent"}, 148{ERR_REASON(RSA_R_NO_PUBLIC_EXPONENT) ,"no public exponent"},
142{ERR_REASON(RSA_R_NULL_BEFORE_BLOCK_MISSING),"null before block missing"}, 149{ERR_REASON(RSA_R_NULL_BEFORE_BLOCK_MISSING),"null before block missing"},
143{ERR_REASON(RSA_R_N_DOES_NOT_EQUAL_P_Q) ,"n does not equal p q"}, 150{ERR_REASON(RSA_R_N_DOES_NOT_EQUAL_P_Q) ,"n does not equal p q"},
144{ERR_REASON(RSA_R_OAEP_DECODING_ERROR) ,"oaep decoding error"}, 151{ERR_REASON(RSA_R_OAEP_DECODING_ERROR) ,"oaep decoding error"},
152{ERR_REASON(RSA_R_OPERATION_NOT_ALLOWED_IN_FIPS_MODE),"operation not allowed in fips mode"},
145{ERR_REASON(RSA_R_PADDING_CHECK_FAILED) ,"padding check failed"}, 153{ERR_REASON(RSA_R_PADDING_CHECK_FAILED) ,"padding check failed"},
146{ERR_REASON(RSA_R_P_NOT_PRIME) ,"p not prime"}, 154{ERR_REASON(RSA_R_P_NOT_PRIME) ,"p not prime"},
147{ERR_REASON(RSA_R_Q_NOT_PRIME) ,"q not prime"}, 155{ERR_REASON(RSA_R_Q_NOT_PRIME) ,"q not prime"},
diff --git a/src/lib/libcrypto/rsa/rsa_gen.c b/src/lib/libcrypto/rsa/rsa_gen.c
index 767f7ab682..41278f83c6 100644
--- a/src/lib/libcrypto/rsa/rsa_gen.c
+++ b/src/lib/libcrypto/rsa/rsa_gen.c
@@ -68,6 +68,8 @@
68#include <openssl/bn.h> 68#include <openssl/bn.h>
69#include <openssl/rsa.h> 69#include <openssl/rsa.h>
70 70
71#ifndef OPENSSL_FIPS
72
71static int rsa_builtin_keygen(RSA *rsa, int bits, BIGNUM *e_value, BN_GENCB *cb); 73static int rsa_builtin_keygen(RSA *rsa, int bits, BIGNUM *e_value, BN_GENCB *cb);
72 74
73/* NB: this wrapper would normally be placed in rsa_lib.c and the static 75/* NB: this wrapper would normally be placed in rsa_lib.c and the static
@@ -217,3 +219,4 @@ err:
217 return ok; 219 return ok;
218 } 220 }
219 221
222#endif
diff --git a/src/lib/libcrypto/rsa/rsa_lib.c b/src/lib/libcrypto/rsa/rsa_lib.c
index 104aa4c1f2..5714841f4c 100644
--- a/src/lib/libcrypto/rsa/rsa_lib.c
+++ b/src/lib/libcrypto/rsa/rsa_lib.c
@@ -67,215 +67,6 @@
67#include <openssl/engine.h> 67#include <openssl/engine.h>
68#endif 68#endif
69 69
70const char RSA_version[]="RSA" OPENSSL_VERSION_PTEXT;
71
72static const RSA_METHOD *default_RSA_meth=NULL;
73
74RSA *RSA_new(void)
75 {
76 RSA *r=RSA_new_method(NULL);
77
78 return r;
79 }
80
81void RSA_set_default_method(const RSA_METHOD *meth)
82 {
83 default_RSA_meth = meth;
84 }
85
86const RSA_METHOD *RSA_get_default_method(void)
87 {
88 if (default_RSA_meth == NULL)
89 {
90#ifdef RSA_NULL
91 default_RSA_meth=RSA_null_method();
92#else
93#if 0 /* was: #ifdef RSAref */
94 default_RSA_meth=RSA_PKCS1_RSAref();
95#else
96 default_RSA_meth=RSA_PKCS1_SSLeay();
97#endif
98#endif
99 }
100
101 return default_RSA_meth;
102 }
103
104const RSA_METHOD *RSA_get_method(const RSA *rsa)
105 {
106 return rsa->meth;
107 }
108
109int RSA_set_method(RSA *rsa, const RSA_METHOD *meth)
110 {
111 /* NB: The caller is specifically setting a method, so it's not up to us
112 * to deal with which ENGINE it comes from. */
113 const RSA_METHOD *mtmp;
114 mtmp = rsa->meth;
115 if (mtmp->finish) mtmp->finish(rsa);
116#ifndef OPENSSL_NO_ENGINE
117 if (rsa->engine)
118 {
119 ENGINE_finish(rsa->engine);
120 rsa->engine = NULL;
121 }
122#endif
123 rsa->meth = meth;
124 if (meth->init) meth->init(rsa);
125 return 1;
126 }
127
128RSA *RSA_new_method(ENGINE *engine)
129 {
130 RSA *ret;
131
132 ret=(RSA *)OPENSSL_malloc(sizeof(RSA));
133 if (ret == NULL)
134 {
135 RSAerr(RSA_F_RSA_NEW_METHOD,ERR_R_MALLOC_FAILURE);
136 return NULL;
137 }
138
139 ret->meth = RSA_get_default_method();
140#ifndef OPENSSL_NO_ENGINE
141 if (engine)
142 {
143 if (!ENGINE_init(engine))
144 {
145 RSAerr(RSA_F_RSA_NEW_METHOD, ERR_R_ENGINE_LIB);
146 OPENSSL_free(ret);
147 return NULL;
148 }
149 ret->engine = engine;
150 }
151 else
152 ret->engine = ENGINE_get_default_RSA();
153 if(ret->engine)
154 {
155 ret->meth = ENGINE_get_RSA(ret->engine);
156 if(!ret->meth)
157 {
158 RSAerr(RSA_F_RSA_NEW_METHOD,
159 ERR_R_ENGINE_LIB);
160 ENGINE_finish(ret->engine);
161 OPENSSL_free(ret);
162 return NULL;
163 }
164 }
165#endif
166
167 ret->pad=0;
168 ret->version=0;
169 ret->n=NULL;
170 ret->e=NULL;
171 ret->d=NULL;
172 ret->p=NULL;
173 ret->q=NULL;
174 ret->dmp1=NULL;
175 ret->dmq1=NULL;
176 ret->iqmp=NULL;
177 ret->references=1;
178 ret->_method_mod_n=NULL;
179 ret->_method_mod_p=NULL;
180 ret->_method_mod_q=NULL;
181 ret->blinding=NULL;
182 ret->mt_blinding=NULL;
183 ret->bignum_data=NULL;
184 ret->flags=ret->meth->flags;
185 CRYPTO_new_ex_data(CRYPTO_EX_INDEX_RSA, ret, &ret->ex_data);
186 if ((ret->meth->init != NULL) && !ret->meth->init(ret))
187 {
188#ifndef OPENSSL_NO_ENGINE
189 if (ret->engine)
190 ENGINE_finish(ret->engine);
191#endif
192 CRYPTO_free_ex_data(CRYPTO_EX_INDEX_RSA, ret, &ret->ex_data);
193 OPENSSL_free(ret);
194 ret=NULL;
195 }
196 return(ret);
197 }
198
199void RSA_free(RSA *r)
200 {
201 int i;
202
203 if (r == NULL) return;
204
205 i=CRYPTO_add(&r->references,-1,CRYPTO_LOCK_RSA);
206#ifdef REF_PRINT
207 REF_PRINT("RSA",r);
208#endif
209 if (i > 0) return;
210#ifdef REF_CHECK
211 if (i < 0)
212 {
213 fprintf(stderr,"RSA_free, bad reference count\n");
214 abort();
215 }
216#endif
217
218 if (r->meth->finish)
219 r->meth->finish(r);
220#ifndef OPENSSL_NO_ENGINE
221 if (r->engine)
222 ENGINE_finish(r->engine);
223#endif
224
225 CRYPTO_free_ex_data(CRYPTO_EX_INDEX_RSA, r, &r->ex_data);
226
227 if (r->n != NULL) BN_clear_free(r->n);
228 if (r->e != NULL) BN_clear_free(r->e);
229 if (r->d != NULL) BN_clear_free(r->d);
230 if (r->p != NULL) BN_clear_free(r->p);
231 if (r->q != NULL) BN_clear_free(r->q);
232 if (r->dmp1 != NULL) BN_clear_free(r->dmp1);
233 if (r->dmq1 != NULL) BN_clear_free(r->dmq1);
234 if (r->iqmp != NULL) BN_clear_free(r->iqmp);
235 if (r->blinding != NULL) BN_BLINDING_free(r->blinding);
236 if (r->mt_blinding != NULL) BN_BLINDING_free(r->mt_blinding);
237 if (r->bignum_data != NULL) OPENSSL_free_locked(r->bignum_data);
238 OPENSSL_free(r);
239 }
240
241int RSA_up_ref(RSA *r)
242 {
243 int i = CRYPTO_add(&r->references, 1, CRYPTO_LOCK_RSA);
244#ifdef REF_PRINT
245 REF_PRINT("RSA",r);
246#endif
247#ifdef REF_CHECK
248 if (i < 2)
249 {
250 fprintf(stderr, "RSA_up_ref, bad reference count\n");
251 abort();
252 }
253#endif
254 return ((i > 1) ? 1 : 0);
255 }
256
257int RSA_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func,
258 CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func)
259 {
260 return CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_RSA, argl, argp,
261 new_func, dup_func, free_func);
262 }
263
264int RSA_set_ex_data(RSA *r, int idx, void *arg)
265 {
266 return(CRYPTO_set_ex_data(&r->ex_data,idx,arg));
267 }
268
269void *RSA_get_ex_data(const RSA *r, int idx)
270 {
271 return(CRYPTO_get_ex_data(&r->ex_data,idx));
272 }
273
274int RSA_size(const RSA *r)
275 {
276 return(BN_num_bytes(r->n));
277 }
278
279int RSA_public_encrypt(int flen, const unsigned char *from, unsigned char *to, 70int RSA_public_encrypt(int flen, const unsigned char *from, unsigned char *to,
280 RSA *rsa, int padding) 71 RSA *rsa, int padding)
281 { 72 {
@@ -285,6 +76,13 @@ int RSA_public_encrypt(int flen, const unsigned char *from, unsigned char *to,
285int RSA_private_encrypt(int flen, const unsigned char *from, unsigned char *to, 76int RSA_private_encrypt(int flen, const unsigned char *from, unsigned char *to,
286 RSA *rsa, int padding) 77 RSA *rsa, int padding)
287 { 78 {
79#ifdef OPENSSL_FIPS
80 if(FIPS_mode() && !(rsa->flags & RSA_FLAG_NON_FIPS_ALLOW))
81 {
82 RSAerr(RSA_F_RSA_PRIVATE_ENCRYPT, RSA_R_OPERATION_NOT_ALLOWED_IN_FIPS_MODE);
83 return 0;
84 }
85#endif
288 return(rsa->meth->rsa_priv_enc(flen, from, to, rsa, padding)); 86 return(rsa->meth->rsa_priv_enc(flen, from, to, rsa, padding));
289 } 87 }
290 88
@@ -297,12 +95,19 @@ int RSA_private_decrypt(int flen, const unsigned char *from, unsigned char *to,
297int RSA_public_decrypt(int flen, const unsigned char *from, unsigned char *to, 95int RSA_public_decrypt(int flen, const unsigned char *from, unsigned char *to,
298 RSA *rsa, int padding) 96 RSA *rsa, int padding)
299 { 97 {
98#ifdef OPENSSL_FIPS
99 if(FIPS_mode() && !(rsa->flags & RSA_FLAG_NON_FIPS_ALLOW))
100 {
101 RSAerr(RSA_F_RSA_PUBLIC_DECRYPT, RSA_R_OPERATION_NOT_ALLOWED_IN_FIPS_MODE);
102 return 0;
103 }
104#endif
300 return(rsa->meth->rsa_pub_dec(flen, from, to, rsa, padding)); 105 return(rsa->meth->rsa_pub_dec(flen, from, to, rsa, padding));
301 } 106 }
302 107
303int RSA_flags(const RSA *r) 108int RSA_size(const RSA *r)
304 { 109 {
305 return((r == NULL)?0:r->meth->flags); 110 return(BN_num_bytes(r->n));
306 } 111 }
307 112
308void RSA_blinding_off(RSA *rsa) 113void RSA_blinding_off(RSA *rsa)
@@ -427,48 +232,3 @@ err:
427 232
428 return ret; 233 return ret;
429} 234}
430
431int RSA_memory_lock(RSA *r)
432 {
433 int i,j,k,off;
434 char *p;
435 BIGNUM *bn,**t[6],*b;
436 BN_ULONG *ul;
437
438 if (r->d == NULL) return(1);
439 t[0]= &r->d;
440 t[1]= &r->p;
441 t[2]= &r->q;
442 t[3]= &r->dmp1;
443 t[4]= &r->dmq1;
444 t[5]= &r->iqmp;
445 k=sizeof(BIGNUM)*6;
446 off=k/sizeof(BN_ULONG)+1;
447 j=1;
448 for (i=0; i<6; i++)
449 j+= (*t[i])->top;
450 if ((p=OPENSSL_malloc_locked((off+j)*sizeof(BN_ULONG))) == NULL)
451 {
452 RSAerr(RSA_F_RSA_MEMORY_LOCK,ERR_R_MALLOC_FAILURE);
453 return(0);
454 }
455 bn=(BIGNUM *)p;
456 ul=(BN_ULONG *)&(p[off]);
457 for (i=0; i<6; i++)
458 {
459 b= *(t[i]);
460 *(t[i])= &(bn[i]);
461 memcpy((char *)&(bn[i]),(char *)b,sizeof(BIGNUM));
462 bn[i].flags=BN_FLG_STATIC_DATA;
463 bn[i].d=ul;
464 memcpy((char *)ul,b->d,sizeof(BN_ULONG)*b->top);
465 ul+=b->top;
466 BN_clear_free(b);
467 }
468
469 /* I should fix this so it can still be done */
470 r->flags&= ~(RSA_FLAG_CACHE_PRIVATE|RSA_FLAG_CACHE_PUBLIC);
471
472 r->bignum_data=p;
473 return(1);
474 }
diff --git a/src/lib/libcrypto/rsa/rsa_null.c b/src/lib/libcrypto/rsa/rsa_null.c
index 491572c82b..2f2202f142 100644
--- a/src/lib/libcrypto/rsa/rsa_null.c
+++ b/src/lib/libcrypto/rsa/rsa_null.c
@@ -1,5 +1,5 @@
1/* rsa_null.c */ 1/* rsa_null.c */
2/* Written by Dr Stephen N Henson (shenson@bigfoot.com) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 1999. 3 * project 1999.
4 */ 4 */
5/* ==================================================================== 5/* ====================================================================
diff --git a/src/lib/libcrypto/rsa/rsa_oaep.c b/src/lib/libcrypto/rsa/rsa_oaep.c
index 3652677a99..4d30c9d2d3 100644
--- a/src/lib/libcrypto/rsa/rsa_oaep.c
+++ b/src/lib/libcrypto/rsa/rsa_oaep.c
@@ -187,7 +187,7 @@ int PKCS1_MGF1(unsigned char *mask, long len,
187 int mdlen; 187 int mdlen;
188 188
189 EVP_MD_CTX_init(&c); 189 EVP_MD_CTX_init(&c);
190 mdlen = EVP_MD_size(dgst); 190 mdlen = M_EVP_MD_size(dgst);
191 for (i = 0; outlen < len; i++) 191 for (i = 0; outlen < len; i++)
192 { 192 {
193 cnt[0] = (unsigned char)((i >> 24) & 255); 193 cnt[0] = (unsigned char)((i >> 24) & 255);
diff --git a/src/lib/libcrypto/rsa/rsa_sign.c b/src/lib/libcrypto/rsa/rsa_sign.c
index 71aabeea1b..5488c06f6d 100644
--- a/src/lib/libcrypto/rsa/rsa_sign.c
+++ b/src/lib/libcrypto/rsa/rsa_sign.c
@@ -90,6 +90,14 @@ int RSA_sign(int type, const unsigned char *m, unsigned int m_len,
90 i = SSL_SIG_LENGTH; 90 i = SSL_SIG_LENGTH;
91 s = m; 91 s = m;
92 } else { 92 } else {
93 /* NB: in FIPS mode block anything that isn't a TLS signature */
94#ifdef OPENSSL_FIPS
95 if(FIPS_mode() && !(rsa->flags & RSA_FLAG_NON_FIPS_ALLOW))
96 {
97 RSAerr(RSA_F_RSA_SIGN, RSA_R_OPERATION_NOT_ALLOWED_IN_FIPS_MODE);
98 return 0;
99 }
100#endif
93 sig.algor= &algor; 101 sig.algor= &algor;
94 sig.algor->algorithm=OBJ_nid2obj(type); 102 sig.algor->algorithm=OBJ_nid2obj(type);
95 if (sig.algor->algorithm == NULL) 103 if (sig.algor->algorithm == NULL)
@@ -167,10 +175,22 @@ int RSA_verify(int dtype, const unsigned char *m, unsigned int m_len,
167 RSAerr(RSA_F_RSA_VERIFY,ERR_R_MALLOC_FAILURE); 175 RSAerr(RSA_F_RSA_VERIFY,ERR_R_MALLOC_FAILURE);
168 goto err; 176 goto err;
169 } 177 }
170 if((dtype == NID_md5_sha1) && (m_len != SSL_SIG_LENGTH) ) { 178 if(dtype == NID_md5_sha1)
179 {
180 if (m_len != SSL_SIG_LENGTH)
181 {
171 RSAerr(RSA_F_RSA_VERIFY,RSA_R_INVALID_MESSAGE_LENGTH); 182 RSAerr(RSA_F_RSA_VERIFY,RSA_R_INVALID_MESSAGE_LENGTH);
172 goto err; 183 goto err;
173 } 184 }
185 }
186 /* NB: in FIPS mode block anything that isn't a TLS signature */
187#ifdef OPENSSL_FIPS
188 else if(FIPS_mode() && !(rsa->flags & RSA_FLAG_NON_FIPS_ALLOW))
189 {
190 RSAerr(RSA_F_RSA_VERIFY, RSA_R_OPERATION_NOT_ALLOWED_IN_FIPS_MODE);
191 return 0;
192 }
193#endif
174 i=RSA_public_decrypt((int)siglen,sigbuf,s,rsa,RSA_PKCS1_PADDING); 194 i=RSA_public_decrypt((int)siglen,sigbuf,s,rsa,RSA_PKCS1_PADDING);
175 195
176 if (i <= 0) goto err; 196 if (i <= 0) goto err;
diff --git a/src/lib/libcrypto/sha/sha.h b/src/lib/libcrypto/sha/sha.h
index eed44d7f94..47a2c29f66 100644
--- a/src/lib/libcrypto/sha/sha.h
+++ b/src/lib/libcrypto/sha/sha.h
@@ -106,6 +106,9 @@ typedef struct SHAstate_st
106 } SHA_CTX; 106 } SHA_CTX;
107 107
108#ifndef OPENSSL_NO_SHA0 108#ifndef OPENSSL_NO_SHA0
109#ifdef OPENSSL_FIPS
110int private_SHA_Init(SHA_CTX *c);
111#endif
109int SHA_Init(SHA_CTX *c); 112int SHA_Init(SHA_CTX *c);
110int SHA_Update(SHA_CTX *c, const void *data, size_t len); 113int SHA_Update(SHA_CTX *c, const void *data, size_t len);
111int SHA_Final(unsigned char *md, SHA_CTX *c); 114int SHA_Final(unsigned char *md, SHA_CTX *c);
diff --git a/src/lib/libcrypto/sha/sha1_one.c b/src/lib/libcrypto/sha/sha1_one.c
index 7c65b60276..4831174198 100644
--- a/src/lib/libcrypto/sha/sha1_one.c
+++ b/src/lib/libcrypto/sha/sha1_one.c
@@ -61,7 +61,7 @@
61#include <openssl/sha.h> 61#include <openssl/sha.h>
62#include <openssl/crypto.h> 62#include <openssl/crypto.h>
63 63
64#ifndef OPENSSL_NO_SHA1 64#if !defined(OPENSSL_NO_SHA1)
65unsigned char *SHA1(const unsigned char *d, size_t n, unsigned char *md) 65unsigned char *SHA1(const unsigned char *d, size_t n, unsigned char *md)
66 { 66 {
67 SHA_CTX c; 67 SHA_CTX c;
diff --git a/src/lib/libcrypto/sha/sha1dgst.c b/src/lib/libcrypto/sha/sha1dgst.c
index 50d1925cde..d31f0781a0 100644
--- a/src/lib/libcrypto/sha/sha1dgst.c
+++ b/src/lib/libcrypto/sha/sha1dgst.c
@@ -63,6 +63,10 @@
63#define SHA_1 63#define SHA_1
64 64
65#include <openssl/opensslv.h> 65#include <openssl/opensslv.h>
66#ifdef OPENSSL_FIPS
67#include <openssl/fips.h>
68#endif
69
66 70
67const char SHA1_version[]="SHA1" OPENSSL_VERSION_PTEXT; 71const char SHA1_version[]="SHA1" OPENSSL_VERSION_PTEXT;
68 72
diff --git a/src/lib/libcrypto/sha/sha_dgst.c b/src/lib/libcrypto/sha/sha_dgst.c
index 70eb56032c..598f4d721a 100644
--- a/src/lib/libcrypto/sha/sha_dgst.c
+++ b/src/lib/libcrypto/sha/sha_dgst.c
@@ -57,6 +57,12 @@
57 */ 57 */
58 58
59#include <openssl/opensslconf.h> 59#include <openssl/opensslconf.h>
60#include <openssl/crypto.h>
61#ifdef OPENSSL_FIPS
62#include <openssl/fips.h>
63#endif
64
65#include <openssl/err.h>
60#if !defined(OPENSSL_NO_SHA0) && !defined(OPENSSL_NO_SHA) 66#if !defined(OPENSSL_NO_SHA0) && !defined(OPENSSL_NO_SHA)
61 67
62#undef SHA_1 68#undef SHA_1
diff --git a/src/lib/libcrypto/sha/sha_locl.h b/src/lib/libcrypto/sha/sha_locl.h
index e37e5726e3..da46ddfe79 100644
--- a/src/lib/libcrypto/sha/sha_locl.h
+++ b/src/lib/libcrypto/sha/sha_locl.h
@@ -122,8 +122,15 @@ void sha1_block_data_order (SHA_CTX *c, const void *p,size_t num);
122#define INIT_DATA_h3 0x10325476UL 122#define INIT_DATA_h3 0x10325476UL
123#define INIT_DATA_h4 0xc3d2e1f0UL 123#define INIT_DATA_h4 0xc3d2e1f0UL
124 124
125#if defined(SHA_0) && defined(OPENSSL_FIPS)
126FIPS_NON_FIPS_MD_Init(SHA)
127#else
125int HASH_INIT (SHA_CTX *c) 128int HASH_INIT (SHA_CTX *c)
129#endif
126 { 130 {
131#if defined(SHA_1) && defined(OPENSSL_FIPS)
132 FIPS_selftest_check();
133#endif
127 c->h0=INIT_DATA_h0; 134 c->h0=INIT_DATA_h0;
128 c->h1=INIT_DATA_h1; 135 c->h1=INIT_DATA_h1;
129 c->h2=INIT_DATA_h2; 136 c->h2=INIT_DATA_h2;
diff --git a/src/lib/libcrypto/symhacks.h b/src/lib/libcrypto/symhacks.h
index 64528ad5c2..6cfb5fe479 100644
--- a/src/lib/libcrypto/symhacks.h
+++ b/src/lib/libcrypto/symhacks.h
@@ -179,6 +179,11 @@
179#define ENGINE_set_load_privkey_function ENGINE_set_load_privkey_fn 179#define ENGINE_set_load_privkey_function ENGINE_set_load_privkey_fn
180#undef ENGINE_get_load_privkey_function 180#undef ENGINE_get_load_privkey_function
181#define ENGINE_get_load_privkey_function ENGINE_get_load_privkey_fn 181#define ENGINE_get_load_privkey_function ENGINE_get_load_privkey_fn
182#undef ENGINE_set_load_ssl_client_cert_function
183#define ENGINE_set_load_ssl_client_cert_function \
184 ENGINE_set_ld_ssl_clnt_cert_fn
185#undef ENGINE_get_ssl_client_cert_function
186#define ENGINE_get_ssl_client_cert_function ENGINE_get_ssl_client_cert_fn
182 187
183/* Hack some long OCSP names */ 188/* Hack some long OCSP names */
184#undef OCSP_REQUEST_get_ext_by_critical 189#undef OCSP_REQUEST_get_ext_by_critical
diff --git a/src/lib/libcrypto/ui/ui_openssl.c b/src/lib/libcrypto/ui/ui_openssl.c
index 8446673ed4..5fbedf6ff8 100644
--- a/src/lib/libcrypto/ui/ui_openssl.c
+++ b/src/lib/libcrypto/ui/ui_openssl.c
@@ -678,6 +678,8 @@ static int noecho_fgets(char *buf, int size, FILE *tty)
678 size--; 678 size--;
679#ifdef WIN16TTY 679#ifdef WIN16TTY
680 i=_inchar(); 680 i=_inchar();
681#elif defined(_WIN32)
682 i=_getch();
681#else 683#else
682 i=getch(); 684 i=getch();
683#endif 685#endif
diff --git a/src/lib/libcrypto/util/libeay.num b/src/lib/libcrypto/util/libeay.num
index 62664f3c37..0eb54ddc89 100644
--- a/src/lib/libcrypto/util/libeay.num
+++ b/src/lib/libcrypto/util/libeay.num
@@ -2804,12 +2804,12 @@ OPENSSL_cleanse 3245 EXIST::FUNCTION:
2804ENGINE_setup_bsd_cryptodev 3246 EXIST:__FreeBSD__:FUNCTION:ENGINE 2804ENGINE_setup_bsd_cryptodev 3246 EXIST:__FreeBSD__:FUNCTION:ENGINE
2805ERR_release_err_state_table 3247 EXIST::FUNCTION:LHASH 2805ERR_release_err_state_table 3247 EXIST::FUNCTION:LHASH
2806EVP_aes_128_cfb8 3248 EXIST::FUNCTION:AES 2806EVP_aes_128_cfb8 3248 EXIST::FUNCTION:AES
2807FIPS_corrupt_rsa 3249 NOEXIST::FUNCTION: 2807FIPS_corrupt_rsa 3249 EXIST:OPENSSL_FIPS:FUNCTION:
2808FIPS_selftest_des 3250 NOEXIST::FUNCTION: 2808FIPS_selftest_des 3250 EXIST:OPENSSL_FIPS:FUNCTION:
2809EVP_aes_128_cfb1 3251 EXIST::FUNCTION:AES 2809EVP_aes_128_cfb1 3251 EXIST::FUNCTION:AES
2810EVP_aes_192_cfb8 3252 EXIST::FUNCTION:AES 2810EVP_aes_192_cfb8 3252 EXIST::FUNCTION:AES
2811FIPS_mode_set 3253 NOEXIST::FUNCTION: 2811FIPS_mode_set 3253 EXIST:OPENSSL_FIPS:FUNCTION:
2812FIPS_selftest_dsa 3254 NOEXIST::FUNCTION: 2812FIPS_selftest_dsa 3254 EXIST:OPENSSL_FIPS:FUNCTION:
2813EVP_aes_256_cfb8 3255 EXIST::FUNCTION:AES 2813EVP_aes_256_cfb8 3255 EXIST::FUNCTION:AES
2814FIPS_allow_md5 3256 NOEXIST::FUNCTION: 2814FIPS_allow_md5 3256 NOEXIST::FUNCTION:
2815DES_ede3_cfb_encrypt 3257 EXIST::FUNCTION:DES 2815DES_ede3_cfb_encrypt 3257 EXIST::FUNCTION:DES
@@ -2817,44 +2817,44 @@ EVP_des_ede3_cfb8 3258 EXIST::FUNCTION:DES
2817FIPS_rand_seeded 3259 NOEXIST::FUNCTION: 2817FIPS_rand_seeded 3259 NOEXIST::FUNCTION:
2818AES_cfbr_encrypt_block 3260 EXIST::FUNCTION:AES 2818AES_cfbr_encrypt_block 3260 EXIST::FUNCTION:AES
2819AES_cfb8_encrypt 3261 EXIST::FUNCTION:AES 2819AES_cfb8_encrypt 3261 EXIST::FUNCTION:AES
2820FIPS_rand_seed 3262 NOEXIST::FUNCTION: 2820FIPS_rand_seed 3262 EXIST:OPENSSL_FIPS:FUNCTION:
2821FIPS_corrupt_des 3263 NOEXIST::FUNCTION: 2821FIPS_corrupt_des 3263 EXIST:OPENSSL_FIPS:FUNCTION:
2822EVP_aes_192_cfb1 3264 EXIST::FUNCTION:AES 2822EVP_aes_192_cfb1 3264 EXIST::FUNCTION:AES
2823FIPS_selftest_aes 3265 NOEXIST::FUNCTION: 2823FIPS_selftest_aes 3265 EXIST:OPENSSL_FIPS:FUNCTION:
2824FIPS_set_prng_key 3266 NOEXIST::FUNCTION: 2824FIPS_set_prng_key 3266 NOEXIST::FUNCTION:
2825EVP_des_cfb8 3267 EXIST::FUNCTION:DES 2825EVP_des_cfb8 3267 EXIST::FUNCTION:DES
2826FIPS_corrupt_dsa 3268 NOEXIST::FUNCTION: 2826FIPS_corrupt_dsa 3268 EXIST:OPENSSL_FIPS:FUNCTION:
2827FIPS_test_mode 3269 NOEXIST::FUNCTION: 2827FIPS_test_mode 3269 NOEXIST::FUNCTION:
2828FIPS_rand_method 3270 NOEXIST::FUNCTION: 2828FIPS_rand_method 3270 EXIST:OPENSSL_FIPS:FUNCTION:
2829EVP_aes_256_cfb1 3271 EXIST::FUNCTION:AES 2829EVP_aes_256_cfb1 3271 EXIST::FUNCTION:AES
2830ERR_load_FIPS_strings 3272 NOEXIST::FUNCTION: 2830ERR_load_FIPS_strings 3272 EXIST:OPENSSL_FIPS:FUNCTION:
2831FIPS_corrupt_aes 3273 NOEXIST::FUNCTION: 2831FIPS_corrupt_aes 3273 EXIST:OPENSSL_FIPS:FUNCTION:
2832FIPS_selftest_sha1 3274 NOEXIST::FUNCTION: 2832FIPS_selftest_sha1 3274 EXIST:OPENSSL_FIPS:FUNCTION:
2833FIPS_selftest_rsa 3275 NOEXIST::FUNCTION: 2833FIPS_selftest_rsa 3275 EXIST:OPENSSL_FIPS:FUNCTION:
2834FIPS_corrupt_sha1 3276 NOEXIST::FUNCTION: 2834FIPS_corrupt_sha1 3276 EXIST:OPENSSL_FIPS:FUNCTION:
2835EVP_des_cfb1 3277 EXIST::FUNCTION:DES 2835EVP_des_cfb1 3277 EXIST::FUNCTION:DES
2836FIPS_dsa_check 3278 NOEXIST::FUNCTION: 2836FIPS_dsa_check 3278 NOEXIST::FUNCTION:
2837AES_cfb1_encrypt 3279 EXIST::FUNCTION:AES 2837AES_cfb1_encrypt 3279 EXIST::FUNCTION:AES
2838EVP_des_ede3_cfb1 3280 EXIST::FUNCTION:DES 2838EVP_des_ede3_cfb1 3280 EXIST::FUNCTION:DES
2839FIPS_rand_check 3281 NOEXIST::FUNCTION: 2839FIPS_rand_check 3281 EXIST:OPENSSL_FIPS:FUNCTION:
2840FIPS_md5_allowed 3282 NOEXIST::FUNCTION: 2840FIPS_md5_allowed 3282 NOEXIST::FUNCTION:
2841FIPS_mode 3283 NOEXIST::FUNCTION: 2841FIPS_mode 3283 EXIST:OPENSSL_FIPS:FUNCTION:
2842FIPS_selftest_failed 3284 NOEXIST::FUNCTION: 2842FIPS_selftest_failed 3284 EXIST:OPENSSL_FIPS:FUNCTION:
2843sk_is_sorted 3285 EXIST::FUNCTION: 2843sk_is_sorted 3285 EXIST::FUNCTION:
2844X509_check_ca 3286 EXIST::FUNCTION: 2844X509_check_ca 3286 EXIST::FUNCTION:
2845private_idea_set_encrypt_key 3287 NOEXIST::FUNCTION: 2845private_idea_set_encrypt_key 3287 EXIST:OPENSSL_FIPS:FUNCTION:IDEA
2846HMAC_CTX_set_flags 3288 EXIST::FUNCTION:HMAC 2846HMAC_CTX_set_flags 3288 EXIST::FUNCTION:HMAC
2847private_SHA_Init 3289 NOEXIST::FUNCTION: 2847private_SHA_Init 3289 EXIST:OPENSSL_FIPS:FUNCTION:SHA,SHA0
2848private_CAST_set_key 3290 NOEXIST::FUNCTION: 2848private_CAST_set_key 3290 EXIST:OPENSSL_FIPS:FUNCTION:CAST
2849private_RIPEMD160_Init 3291 NOEXIST::FUNCTION: 2849private_RIPEMD160_Init 3291 EXIST:OPENSSL_FIPS:FUNCTION:RIPEMD
2850private_RC5_32_set_key 3292 NOEXIST::FUNCTION: 2850private_RC5_32_set_key 3292 EXIST:OPENSSL_FIPS:FUNCTION:RC5
2851private_MD5_Init 3293 NOEXIST::FUNCTION: 2851private_MD5_Init 3293 EXIST:OPENSSL_FIPS:FUNCTION:MD5
2852private_RC4_set_key 3294 NOEXIST::FUNCTION: 2852private_RC4_set_key 3294 EXIST:OPENSSL_FIPS:FUNCTION:RC4
2853private_MDC2_Init 3295 NOEXIST::FUNCTION: 2853private_MDC2_Init 3295 EXIST:OPENSSL_FIPS:FUNCTION:MDC2
2854private_RC2_set_key 3296 NOEXIST::FUNCTION: 2854private_RC2_set_key 3296 EXIST:OPENSSL_FIPS:FUNCTION:RC2
2855private_MD4_Init 3297 NOEXIST::FUNCTION: 2855private_MD4_Init 3297 EXIST:OPENSSL_FIPS:FUNCTION:MD4
2856private_BF_set_key 3298 NOEXIST::FUNCTION: 2856private_BF_set_key 3298 EXIST:OPENSSL_FIPS:FUNCTION:BF
2857private_MD2_Init 3299 NOEXIST::FUNCTION: 2857private_MD2_Init 3299 EXIST:OPENSSL_FIPS:FUNCTION:MD2
2858d2i_PROXY_CERT_INFO_EXTENSION 3300 EXIST::FUNCTION: 2858d2i_PROXY_CERT_INFO_EXTENSION 3300 EXIST::FUNCTION:
2859PROXY_POLICY_it 3301 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE: 2859PROXY_POLICY_it 3301 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:
2860PROXY_POLICY_it 3301 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION: 2860PROXY_POLICY_it 3301 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:
@@ -2868,13 +2868,13 @@ PROXY_CERT_INFO_EXTENSION_it 3307 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTI
2868PROXY_POLICY_free 3308 EXIST::FUNCTION: 2868PROXY_POLICY_free 3308 EXIST::FUNCTION:
2869PROXY_POLICY_new 3309 EXIST::FUNCTION: 2869PROXY_POLICY_new 3309 EXIST::FUNCTION:
2870BN_MONT_CTX_set_locked 3310 EXIST::FUNCTION: 2870BN_MONT_CTX_set_locked 3310 EXIST::FUNCTION:
2871FIPS_selftest_rng 3311 NOEXIST::FUNCTION: 2871FIPS_selftest_rng 3311 EXIST:OPENSSL_FIPS:FUNCTION:
2872EVP_sha384 3312 EXIST::FUNCTION:SHA,SHA512 2872EVP_sha384 3312 EXIST::FUNCTION:SHA,SHA512
2873EVP_sha512 3313 EXIST::FUNCTION:SHA,SHA512 2873EVP_sha512 3313 EXIST::FUNCTION:SHA,SHA512
2874EVP_sha224 3314 EXIST::FUNCTION:SHA,SHA256 2874EVP_sha224 3314 EXIST::FUNCTION:SHA,SHA256
2875EVP_sha256 3315 EXIST::FUNCTION:SHA,SHA256 2875EVP_sha256 3315 EXIST::FUNCTION:SHA,SHA256
2876FIPS_selftest_hmac 3316 NOEXIST::FUNCTION: 2876FIPS_selftest_hmac 3316 EXIST:OPENSSL_FIPS:FUNCTION:
2877FIPS_corrupt_rng 3317 NOEXIST::FUNCTION: 2877FIPS_corrupt_rng 3317 EXIST:OPENSSL_FIPS:FUNCTION:
2878BN_mod_exp_mont_consttime 3318 EXIST::FUNCTION: 2878BN_mod_exp_mont_consttime 3318 EXIST::FUNCTION:
2879RSA_X931_hash_id 3319 EXIST::FUNCTION:RSA 2879RSA_X931_hash_id 3319 EXIST::FUNCTION:RSA
2880RSA_padding_check_X931 3320 EXIST::FUNCTION:RSA 2880RSA_padding_check_X931 3320 EXIST::FUNCTION:RSA
@@ -2882,7 +2882,7 @@ RSA_verify_PKCS1_PSS 3321 EXIST::FUNCTION:RSA
2882RSA_padding_add_X931 3322 EXIST::FUNCTION:RSA 2882RSA_padding_add_X931 3322 EXIST::FUNCTION:RSA
2883RSA_padding_add_PKCS1_PSS 3323 EXIST::FUNCTION:RSA 2883RSA_padding_add_PKCS1_PSS 3323 EXIST::FUNCTION:RSA
2884PKCS1_MGF1 3324 EXIST::FUNCTION:RSA 2884PKCS1_MGF1 3324 EXIST::FUNCTION:RSA
2885BN_X931_generate_Xpq 3325 NOEXIST::FUNCTION: 2885BN_X931_generate_Xpq 3325 EXIST::FUNCTION:
2886RSA_X931_generate_key 3326 NOEXIST::FUNCTION: 2886RSA_X931_generate_key 3326 NOEXIST::FUNCTION:
2887BN_X931_derive_prime 3327 NOEXIST::FUNCTION: 2887BN_X931_derive_prime 3327 NOEXIST::FUNCTION:
2888BN_X931_generate_prime 3328 NOEXIST::FUNCTION: 2888BN_X931_generate_prime 3328 NOEXIST::FUNCTION:
@@ -3652,51 +3652,75 @@ CMS_set1_eContentType 4040 EXIST::FUNCTION:CMS
3652CMS_ReceiptRequest_create0 4041 EXIST::FUNCTION:CMS 3652CMS_ReceiptRequest_create0 4041 EXIST::FUNCTION:CMS
3653CMS_add1_signer 4042 EXIST::FUNCTION:CMS 3653CMS_add1_signer 4042 EXIST::FUNCTION:CMS
3654CMS_RecipientInfo_set0_pkey 4043 EXIST::FUNCTION:CMS 3654CMS_RecipientInfo_set0_pkey 4043 EXIST::FUNCTION:CMS
3655ENGINE_set_load_ssl_client_cert_function 4044 EXIST::FUNCTION:ENGINE 3655ENGINE_set_load_ssl_client_cert_function 4044 EXIST:!VMS:FUNCTION:ENGINE
3656ENGINE_get_ssl_client_cert_function 4045 EXIST::FUNCTION:ENGINE 3656ENGINE_set_ld_ssl_clnt_cert_fn 4044 EXIST:VMS:FUNCTION:ENGINE
3657ENGINE_get_ssl_client_cert_function 4045 EXIST:!VMS:FUNCTION:ENGINE
3658ENGINE_get_ssl_client_cert_fn 4045 EXIST:VMS:FUNCTION:ENGINE
3657ENGINE_load_ssl_client_cert 4046 EXIST::FUNCTION:ENGINE 3659ENGINE_load_ssl_client_cert 4046 EXIST::FUNCTION:ENGINE
3658ENGINE_load_capi 4047 EXIST::FUNCTION:CAPIENG,ENGINE 3660ENGINE_load_capi 4047 EXIST::FUNCTION:CAPIENG,ENGINE
3659OPENSSL_isservice 4048 EXIST::FUNCTION: 3661OPENSSL_isservice 4048 EXIST::FUNCTION:
3660FIPS_dsa_sig_decode 4049 NOEXIST::FUNCTION: 3662FIPS_dsa_sig_decode 4049 EXIST:OPENSSL_FIPS:FUNCTION:DSA
3661EVP_CIPHER_CTX_clear_flags 4050 NOEXIST::FUNCTION: 3663EVP_CIPHER_CTX_clear_flags 4050 EXIST::FUNCTION:
3662FIPS_rand_status 4051 NOEXIST::FUNCTION: 3664FIPS_rand_status 4051 EXIST:OPENSSL_FIPS:FUNCTION:
3663FIPS_rand_set_key 4052 NOEXIST::FUNCTION: 3665FIPS_rand_set_key 4052 EXIST:OPENSSL_FIPS:FUNCTION:
3664CRYPTO_set_mem_info_functions 4053 NOEXIST::FUNCTION: 3666CRYPTO_set_mem_info_functions 4053 EXIST::FUNCTION:
3665RSA_X931_generate_key_ex 4054 NOEXIST::FUNCTION: 3667RSA_X931_generate_key_ex 4054 EXIST::FUNCTION:RSA
3666int_ERR_set_state_func 4055 NOEXIST::FUNCTION: 3668int_ERR_set_state_func 4055 EXIST:OPENSSL_FIPS:FUNCTION:
3667int_EVP_MD_set_engine_callbacks 4056 NOEXIST::FUNCTION: 3669int_EVP_MD_set_engine_callbacks 4056 EXIST:OPENSSL_FIPS:FUNCTION:ENGINE
3668int_CRYPTO_set_do_dynlock_callback 4057 NOEXIST::FUNCTION: 3670int_CRYPTO_set_do_dynlock_callback 4057 EXIST::FUNCTION:
3669FIPS_rng_stick 4058 NOEXIST::FUNCTION: 3671FIPS_rng_stick 4058 EXIST:OPENSSL_FIPS:FUNCTION:
3670EVP_CIPHER_CTX_set_flags 4059 NOEXIST::FUNCTION: 3672EVP_CIPHER_CTX_set_flags 4059 EXIST::FUNCTION:
3671BN_X931_generate_prime_ex 4060 NOEXIST::FUNCTION: 3673BN_X931_generate_prime_ex 4060 EXIST::FUNCTION:
3672FIPS_selftest_check 4061 NOEXIST::FUNCTION: 3674FIPS_selftest_check 4061 EXIST:OPENSSL_FIPS:FUNCTION:
3673FIPS_rand_set_dt 4062 NOEXIST::FUNCTION: 3675FIPS_rand_set_dt 4062 EXIST:OPENSSL_FIPS:FUNCTION:
3674CRYPTO_dbg_pop_info 4063 NOEXIST::FUNCTION: 3676CRYPTO_dbg_pop_info 4063 EXIST::FUNCTION:
3675FIPS_dsa_free 4064 NOEXIST::FUNCTION: 3677FIPS_dsa_free 4064 EXIST:OPENSSL_FIPS:FUNCTION:DSA
3676RSA_X931_derive_ex 4065 NOEXIST::FUNCTION: 3678RSA_X931_derive_ex 4065 EXIST::FUNCTION:RSA
3677FIPS_rsa_new 4066 NOEXIST::FUNCTION: 3679FIPS_rsa_new 4066 EXIST:OPENSSL_FIPS:FUNCTION:RSA
3678FIPS_rand_bytes 4067 NOEXIST::FUNCTION: 3680FIPS_rand_bytes 4067 EXIST:OPENSSL_FIPS:FUNCTION:
3679fips_cipher_test 4068 NOEXIST::FUNCTION: 3681fips_cipher_test 4068 EXIST:OPENSSL_FIPS:FUNCTION:
3680EVP_CIPHER_CTX_test_flags 4069 NOEXIST::FUNCTION: 3682EVP_CIPHER_CTX_test_flags 4069 EXIST::FUNCTION:
3681CRYPTO_malloc_debug_init 4070 NOEXIST::FUNCTION: 3683CRYPTO_malloc_debug_init 4070 EXIST::FUNCTION:
3682CRYPTO_dbg_push_info 4071 NOEXIST::FUNCTION: 3684CRYPTO_dbg_push_info 4071 EXIST::FUNCTION:
3683FIPS_corrupt_rsa_keygen 4072 NOEXIST::FUNCTION: 3685FIPS_corrupt_rsa_keygen 4072 EXIST:OPENSSL_FIPS:FUNCTION:
3684FIPS_dh_new 4073 NOEXIST::FUNCTION: 3686FIPS_dh_new 4073 EXIST:OPENSSL_FIPS:FUNCTION:DH
3685FIPS_corrupt_dsa_keygen 4074 NOEXIST::FUNCTION: 3687FIPS_corrupt_dsa_keygen 4074 EXIST:OPENSSL_FIPS:FUNCTION:
3686FIPS_dh_free 4075 NOEXIST::FUNCTION: 3688FIPS_dh_free 4075 EXIST:OPENSSL_FIPS:FUNCTION:DH
3687fips_pkey_signature_test 4076 NOEXIST::FUNCTION: 3689fips_pkey_signature_test 4076 EXIST:OPENSSL_FIPS:FUNCTION:
3688EVP_add_alg_module 4077 NOEXIST::FUNCTION: 3690EVP_add_alg_module 4077 EXIST::FUNCTION:
3689int_RAND_init_engine_callbacks 4078 NOEXIST::FUNCTION: 3691int_RAND_init_engine_callbacks 4078 EXIST:OPENSSL_FIPS:FUNCTION:ENGINE
3690int_EVP_CIPHER_set_engine_callbacks 4079 NOEXIST::FUNCTION: 3692int_EVP_CIPHER_set_engine_callbacks 4079 EXIST:OPENSSL_FIPS:FUNCTION:ENGINE
3691int_EVP_MD_init_engine_callbacks 4080 NOEXIST::FUNCTION: 3693int_EVP_MD_init_engine_callbacks 4080 EXIST:OPENSSL_FIPS:FUNCTION:ENGINE
3692FIPS_rand_test_mode 4081 NOEXIST::FUNCTION: 3694FIPS_rand_test_mode 4081 EXIST:OPENSSL_FIPS:FUNCTION:
3693FIPS_rand_reset 4082 NOEXIST::FUNCTION: 3695FIPS_rand_reset 4082 EXIST:OPENSSL_FIPS:FUNCTION:
3694FIPS_dsa_new 4083 NOEXIST::FUNCTION: 3696FIPS_dsa_new 4083 EXIST:OPENSSL_FIPS:FUNCTION:DSA
3695int_RAND_set_callbacks 4084 NOEXIST::FUNCTION: 3697int_RAND_set_callbacks 4084 EXIST:OPENSSL_FIPS:FUNCTION:ENGINE
3696BN_X931_derive_prime_ex 4085 NOEXIST::FUNCTION: 3698BN_X931_derive_prime_ex 4085 EXIST::FUNCTION:
3697int_ERR_lib_init 4086 NOEXIST::FUNCTION: 3699int_ERR_lib_init 4086 EXIST:OPENSSL_FIPS:FUNCTION:
3698int_EVP_CIPHER_init_engine_callbacks 4087 NOEXIST::FUNCTION: 3700int_EVP_CIPHER_init_engine_callbacks 4087 EXIST:OPENSSL_FIPS:FUNCTION:ENGINE
3699FIPS_rsa_free 4088 NOEXIST::FUNCTION: 3701FIPS_rsa_free 4088 EXIST:OPENSSL_FIPS:FUNCTION:RSA
3700FIPS_dsa_sig_encode 4089 NOEXIST::FUNCTION: 3702FIPS_dsa_sig_encode 4089 EXIST:OPENSSL_FIPS:FUNCTION:DSA
3701CRYPTO_dbg_remove_all_info 4090 NOEXIST::FUNCTION: 3703CRYPTO_dbg_remove_all_info 4090 EXIST::FUNCTION:
3702OPENSSL_init 4091 NOEXIST::FUNCTION: 3704OPENSSL_init 4091 EXIST::FUNCTION:
3705private_Camellia_set_key 4092 EXIST:OPENSSL_FIPS:FUNCTION:CAMELLIA
3706CRYPTO_strdup 4093 EXIST::FUNCTION:
3707JPAKE_STEP3A_process 4094 EXIST::FUNCTION:JPAKE
3708JPAKE_STEP1_release 4095 EXIST::FUNCTION:JPAKE
3709JPAKE_get_shared_key 4096 EXIST::FUNCTION:JPAKE
3710JPAKE_STEP3B_init 4097 EXIST::FUNCTION:JPAKE
3711JPAKE_STEP1_generate 4098 EXIST::FUNCTION:JPAKE
3712JPAKE_STEP1_init 4099 EXIST::FUNCTION:JPAKE
3713JPAKE_STEP3B_process 4100 EXIST::FUNCTION:JPAKE
3714JPAKE_STEP2_generate 4101 EXIST::FUNCTION:JPAKE
3715JPAKE_CTX_new 4102 EXIST::FUNCTION:JPAKE
3716JPAKE_CTX_free 4103 EXIST::FUNCTION:JPAKE
3717JPAKE_STEP3B_release 4104 EXIST::FUNCTION:JPAKE
3718JPAKE_STEP3A_release 4105 EXIST::FUNCTION:JPAKE
3719JPAKE_STEP2_process 4106 EXIST::FUNCTION:JPAKE
3720JPAKE_STEP3B_generate 4107 EXIST::FUNCTION:JPAKE
3721JPAKE_STEP1_process 4108 EXIST::FUNCTION:JPAKE
3722JPAKE_STEP3A_generate 4109 EXIST::FUNCTION:JPAKE
3723JPAKE_STEP2_release 4110 EXIST::FUNCTION:JPAKE
3724JPAKE_STEP3A_init 4111 EXIST::FUNCTION:JPAKE
3725ERR_load_JPAKE_strings 4112 EXIST::FUNCTION:JPAKE
3726JPAKE_STEP2_init 4113 EXIST::FUNCTION:JPAKE
diff --git a/src/lib/libcrypto/util/mk1mf.pl b/src/lib/libcrypto/util/mk1mf.pl
index 7ba804ce33..4c16f1dc9e 100644
--- a/src/lib/libcrypto/util/mk1mf.pl
+++ b/src/lib/libcrypto/util/mk1mf.pl
@@ -15,6 +15,18 @@ my $engines = "";
15local $zlib_opt = 0; # 0 = no zlib, 1 = static, 2 = dynamic 15local $zlib_opt = 0; # 0 = no zlib, 1 = static, 2 = dynamic
16local $zlib_lib = ""; 16local $zlib_lib = "";
17 17
18local $fips_canister_path = "";
19my $fips_premain_dso_exe_path = "";
20my $fips_premain_c_path = "";
21my $fips_sha1_exe_path = "";
22
23local $fipscanisterbuild = 0;
24local $fipsdso = 0;
25
26my $fipslibdir = "";
27my $baseaddr = "";
28
29my $ex_l_libs = "";
18 30
19open(IN,"<Makefile") || die "unable to open Makefile!\n"; 31open(IN,"<Makefile") || die "unable to open Makefile!\n";
20while(<IN>) { 32while(<IN>) {
@@ -221,6 +233,7 @@ $cflags.=" -DOPENSSL_NO_SSL2" if $no_ssl2;
221$cflags.=" -DOPENSSL_NO_SSL3" if $no_ssl3; 233$cflags.=" -DOPENSSL_NO_SSL3" if $no_ssl3;
222$cflags.=" -DOPENSSL_NO_TLSEXT" if $no_tlsext; 234$cflags.=" -DOPENSSL_NO_TLSEXT" if $no_tlsext;
223$cflags.=" -DOPENSSL_NO_CMS" if $no_cms; 235$cflags.=" -DOPENSSL_NO_CMS" if $no_cms;
236$cflags.=" -DOPENSSL_NO_JPAKE" if $no_jpake;
224$cflags.=" -DOPENSSL_NO_CAPIENG" if $no_capieng; 237$cflags.=" -DOPENSSL_NO_CAPIENG" if $no_capieng;
225$cflags.=" -DOPENSSL_NO_ERR" if $no_err; 238$cflags.=" -DOPENSSL_NO_ERR" if $no_err;
226$cflags.=" -DOPENSSL_NO_KRB5" if $no_krb5; 239$cflags.=" -DOPENSSL_NO_KRB5" if $no_krb5;
@@ -229,7 +242,7 @@ $cflags.=" -DOPENSSL_NO_ECDSA" if $no_ecdsa;
229$cflags.=" -DOPENSSL_NO_ECDH" if $no_ecdh; 242$cflags.=" -DOPENSSL_NO_ECDH" if $no_ecdh;
230$cflags.=" -DOPENSSL_NO_ENGINE" if $no_engine; 243$cflags.=" -DOPENSSL_NO_ENGINE" if $no_engine;
231$cflags.=" -DOPENSSL_NO_HW" if $no_hw; 244$cflags.=" -DOPENSSL_NO_HW" if $no_hw;
232 245$cflags.=" -DOPENSSL_FIPS" if $fips;
233$cflags.= " -DZLIB" if $zlib_opt; 246$cflags.= " -DZLIB" if $zlib_opt;
234$cflags.= " -DZLIB_SHARED" if $zlib_opt == 2; 247$cflags.= " -DZLIB_SHARED" if $zlib_opt == 2;
235 248
@@ -251,9 +264,9 @@ else
251 264
252$ex_libs="$l_flags$ex_libs" if ($l_flags ne ""); 265$ex_libs="$l_flags$ex_libs" if ($l_flags ne "");
253 266
254
255%shlib_ex_cflags=("SSL" => " -DOPENSSL_BUILD_SHLIBSSL", 267%shlib_ex_cflags=("SSL" => " -DOPENSSL_BUILD_SHLIBSSL",
256 "CRYPTO" => " -DOPENSSL_BUILD_SHLIBCRYPTO"); 268 "CRYPTO" => " -DOPENSSL_BUILD_SHLIBCRYPTO",
269 "FIPS" => " -DOPENSSL_BUILD_SHLIBCRYPTO");
257 270
258if ($msdos) 271if ($msdos)
259 { 272 {
@@ -281,11 +294,21 @@ for (;;)
281 { 294 {
282 if ($lib ne "") 295 if ($lib ne "")
283 { 296 {
284 $uc=$lib; 297 if ($fips && $dir =~ /^fips/)
285 $uc =~ s/^lib(.*)\.a/$1/; 298 {
286 $uc =~ tr/a-z/A-Z/; 299 $uc = "FIPS";
287 $lib_nam{$uc}=$uc; 300 }
288 $lib_obj{$uc}.=$libobj." "; 301 else
302 {
303 $uc=$lib;
304 $uc =~ s/^lib(.*)\.a/$1/;
305 $uc =~ tr/a-z/A-Z/;
306 }
307 if (($uc ne "FIPS") || $fipscanisterbuild)
308 {
309 $lib_nam{$uc}=$uc;
310 $lib_obj{$uc}.=$libobj." ";
311 }
289 } 312 }
290 last if ($val eq "FINISHED"); 313 last if ($val eq "FINISHED");
291 $lib=""; 314 $lib="";
@@ -328,11 +351,130 @@ for (;;)
328 if ($key eq "LIBNAMES" && $dir eq "engines" && $no_static_engine) 351 if ($key eq "LIBNAMES" && $dir eq "engines" && $no_static_engine)
329 { $engines.=$val } 352 { $engines.=$val }
330 353
354 if ($key eq "FIPS_EX_OBJ")
355 {
356 $fips_ex_obj=&var_add("crypto",$val,0);
357 }
358
359 if ($key eq "FIPSLIBDIR")
360 {
361 $fipslibdir=$val;
362 $fipslibdir =~ s/\/$//;
363 $fipslibdir =~ s/\//$o/g;
364 }
365
366 if ($key eq "BASEADDR")
367 { $baseaddr=$val;}
368
331 if (!($_=<IN>)) 369 if (!($_=<IN>))
332 { $_="RELATIVE_DIRECTORY=FINISHED\n"; } 370 { $_="RELATIVE_DIRECTORY=FINISHED\n"; }
333 } 371 }
334close(IN); 372close(IN);
335 373
374if ($fips)
375 {
376
377 foreach (split " ", $fips_ex_obj)
378 {
379 $fips_exclude_obj{$1} = 1 if (/\/([^\/]*)$/);
380 }
381
382 $fips_exclude_obj{"cpu_win32"} = 1;
383 $fips_exclude_obj{"bn_asm"} = 1;
384 $fips_exclude_obj{"des_enc"} = 1;
385 $fips_exclude_obj{"fcrypt_b"} = 1;
386 $fips_exclude_obj{"aes_core"} = 1;
387 $fips_exclude_obj{"aes_cbc"} = 1;
388
389 my @ltmp = split " ", $lib_obj{"CRYPTO"};
390
391
392 $lib_obj{"CRYPTO"} = "";
393
394 foreach(@ltmp)
395 {
396 if (/\/([^\/]*)$/ && exists $fips_exclude_obj{$1})
397 {
398 if ($fipscanisterbuild)
399 {
400 $lib_obj{"FIPS"} .= "$_ ";
401 }
402 }
403 else
404 {
405 $lib_obj{"CRYPTO"} .= "$_ ";
406 }
407 }
408
409 }
410
411if ($fipscanisterbuild)
412 {
413 $fips_canister_path = "\$(LIB_D)${o}fipscanister.lib" if $fips_canister_path eq "";
414 $fips_premain_c_path = "\$(LIB_D)${o}fips_premain.c";
415 }
416else
417 {
418 if ($fips_canister_path eq "")
419 {
420 $fips_canister_path = "\$(FIPSLIB_D)${o}fipscanister.lib";
421 }
422
423 if ($fips_premain_c_path eq "")
424 {
425 $fips_premain_c_path = "\$(FIPSLIB_D)${o}fips_premain.c";
426 }
427 }
428
429if ($fips)
430 {
431 if ($fips_sha1_exe_path eq "")
432 {
433 $fips_sha1_exe_path =
434 "\$(BIN_D)${o}fips_standalone_sha1$exep";
435 }
436 }
437 else
438 {
439 $fips_sha1_exe_path = "";
440 }
441
442if ($fips_premain_dso_exe_path eq "")
443 {
444 $fips_premain_dso_exe_path = "\$(BIN_D)${o}fips_premain_dso$exep";
445 }
446
447# $ex_build_targets .= "\$(BIN_D)${o}\$(E_PREMAIN_DSO)$exep" if ($fips);
448
449#$ex_l_libs .= " \$(L_FIPS)" if $fipsdso;
450
451if ($fips)
452 {
453 if (!$shlib)
454 {
455 $ex_build_targets .= " \$(LIB_D)$o$crypto_compat \$(PREMAIN_DSO_EXE)";
456 $ex_l_libs .= " \$(O_FIPSCANISTER)";
457 $ex_libs_dep .= " \$(O_FIPSCANISTER)" if $fipscanisterbuild;
458 }
459 if ($fipscanisterbuild)
460 {
461 $fipslibdir = "\$(LIB_D)";
462 }
463 else
464 {
465 if ($fipslibdir eq "")
466 {
467 open (IN, "util/fipslib_path.txt") || fipslib_error();
468 $fipslibdir = <IN>;
469 chomp $fipslibdir;
470 close IN;
471 }
472 fips_check_files($fipslibdir,
473 "fipscanister.lib", "fipscanister.lib.sha1",
474 "fips_premain.c", "fips_premain.c.sha1");
475 }
476 }
477
336if ($shlib) 478if ($shlib)
337 { 479 {
338 $extra_install= <<"EOF"; 480 $extra_install= <<"EOF";
@@ -398,6 +540,7 @@ SRC_D=$src_dir
398LINK=$link 540LINK=$link
399LFLAGS=$lflags 541LFLAGS=$lflags
400RSC=$rsc 542RSC=$rsc
543FIPSLINK=\$(PERL) util${o}fipslink.pl
401 544
402AES_ASM_OBJ=$aes_asm_obj 545AES_ASM_OBJ=$aes_asm_obj
403AES_ASM_SRC=$aes_asm_src 546AES_ASM_SRC=$aes_asm_src
@@ -441,6 +584,17 @@ MKLIB=$bin_dir$mklib
441MLFLAGS=$mlflags 584MLFLAGS=$mlflags
442ASM=$bin_dir$asm 585ASM=$bin_dir$asm
443 586
587# FIPS validated module and support file locations
588
589E_PREMAIN_DSO=fips_premain_dso
590
591FIPSLIB_D=$fipslibdir
592BASEADDR=$baseaddr
593FIPS_PREMAIN_SRC=$fips_premain_c_path
594O_FIPSCANISTER=$fips_canister_path
595FIPS_SHA1_EXE=$fips_sha1_exe_path
596PREMAIN_DSO_EXE=$fips_premain_dso_exe_path
597
444###################################################### 598######################################################
445# You should not need to touch anything below this point 599# You should not need to touch anything below this point
446###################################################### 600######################################################
@@ -448,6 +602,7 @@ ASM=$bin_dir$asm
448E_EXE=openssl 602E_EXE=openssl
449SSL=$ssl 603SSL=$ssl
450CRYPTO=$crypto 604CRYPTO=$crypto
605LIBFIPS=libosslfips
451 606
452# BIN_D - Binary output directory 607# BIN_D - Binary output directory
453# TEST_D - Binary test file output directory 608# TEST_D - Binary test file output directory
@@ -468,12 +623,14 @@ INCL_D=\$(TMP_D)
468 623
469O_SSL= \$(LIB_D)$o$plib\$(SSL)$shlibp 624O_SSL= \$(LIB_D)$o$plib\$(SSL)$shlibp
470O_CRYPTO= \$(LIB_D)$o$plib\$(CRYPTO)$shlibp 625O_CRYPTO= \$(LIB_D)$o$plib\$(CRYPTO)$shlibp
626O_FIPS= \$(LIB_D)$o$plib\$(LIBFIPS)$shlibp
471SO_SSL= $plib\$(SSL)$so_shlibp 627SO_SSL= $plib\$(SSL)$so_shlibp
472SO_CRYPTO= $plib\$(CRYPTO)$so_shlibp 628SO_CRYPTO= $plib\$(CRYPTO)$so_shlibp
473L_SSL= \$(LIB_D)$o$plib\$(SSL)$libp 629L_SSL= \$(LIB_D)$o$plib\$(SSL)$libp
474L_CRYPTO= \$(LIB_D)$o$plib\$(CRYPTO)$libp 630L_CRYPTO= \$(LIB_D)$o$plib\$(CRYPTO)$libp
631L_FIPS= \$(LIB_D)$o$plib\$(LIBFIPS)$libp
475 632
476L_LIBS= \$(L_SSL) \$(L_CRYPTO) 633L_LIBS= \$(L_SSL) \$(L_CRYPTO) $ex_l_libs
477 634
478###################################################### 635######################################################
479# Don't touch anything below this point 636# Don't touch anything below this point
@@ -483,13 +640,13 @@ INC=-I\$(INC_D) -I\$(INCL_D)
483APP_CFLAGS=\$(INC) \$(CFLAG) \$(APP_CFLAG) 640APP_CFLAGS=\$(INC) \$(CFLAG) \$(APP_CFLAG)
484LIB_CFLAGS=\$(INC) \$(CFLAG) \$(LIB_CFLAG) 641LIB_CFLAGS=\$(INC) \$(CFLAG) \$(LIB_CFLAG)
485SHLIB_CFLAGS=\$(INC) \$(CFLAG) \$(LIB_CFLAG) \$(SHLIB_CFLAG) 642SHLIB_CFLAGS=\$(INC) \$(CFLAG) \$(LIB_CFLAG) \$(SHLIB_CFLAG)
486LIBS_DEP=\$(O_CRYPTO) \$(O_SSL) 643LIBS_DEP=\$(O_CRYPTO) \$(O_SSL) $ex_libs_dep
487 644
488############################################# 645#############################################
489EOF 646EOF
490 647
491$rules=<<"EOF"; 648$rules=<<"EOF";
492all: banner \$(TMP_D) \$(BIN_D) \$(TEST_D) \$(LIB_D) \$(INCO_D) headers lib exe 649all: banner \$(TMP_D) \$(BIN_D) \$(TEST_D) \$(LIB_D) \$(INCO_D) headers \$(FIPS_SHA1_EXE) lib exe $ex_build_targets
493 650
494banner: 651banner:
495$banner 652$banner
@@ -604,6 +761,26 @@ $rules.=&do_compile_rule("\$(OBJ_D)",$test,"\$(APP_CFLAGS)");
604$defs.=&do_defs("E_OBJ",$e_exe,"\$(OBJ_D)",$obj); 761$defs.=&do_defs("E_OBJ",$e_exe,"\$(OBJ_D)",$obj);
605$rules.=&do_compile_rule("\$(OBJ_D)",$e_exe,'-DMONOLITH $(APP_CFLAGS)'); 762$rules.=&do_compile_rule("\$(OBJ_D)",$e_exe,'-DMONOLITH $(APP_CFLAGS)');
606 763
764# Special case rules for fips_start and fips_end fips_premain_dso
765
766if ($fips)
767 {
768 if ($fipscanisterbuild)
769 {
770 $rules.=&cc_compile_target("\$(OBJ_D)${o}fips_start$obj",
771 "fips${o}fips_canister.c",
772 "-DFIPS_START \$(SHLIB_CFLAGS)");
773 $rules.=&cc_compile_target("\$(OBJ_D)${o}fips_end$obj",
774 "fips${o}fips_canister.c", "\$(SHLIB_CFLAGS)");
775 }
776 $rules.=&cc_compile_target("\$(OBJ_D)${o}fips_standalone_sha1$obj",
777 "fips${o}sha${o}fips_standalone_sha1.c",
778 "\$(SHLIB_CFLAGS)");
779 $rules.=&cc_compile_target("\$(OBJ_D)${o}\$(E_PREMAIN_DSO)$obj",
780 "fips${o}fips_premain.c",
781 "-DFINGERPRINT_PREMAIN_DSO_LOAD \$(SHLIB_CFLAGS)");
782 }
783
607foreach (values %lib_nam) 784foreach (values %lib_nam)
608 { 785 {
609 $lib_obj=$lib_obj{$_}; 786 $lib_obj=$lib_obj{$_};
@@ -614,27 +791,41 @@ foreach (values %lib_nam)
614 $rules.="\$(O_SSL):\n\n"; 791 $rules.="\$(O_SSL):\n\n";
615 next; 792 next;
616 } 793 }
617 if (($aes_asm_obj ne "") && ($_ eq "CRYPTO")) 794
618 { 795 if ((!$fips && ($_ eq "CRYPTO")) || ($fips && ($_ eq "FIPS")))
619 $lib_obj =~ s/\s(\S*\/aes_core\S*)/ \$(AES_ASM_OBJ)/;
620 $lib_obj =~ s/\s\S*\/aes_cbc\S*//;
621 $rules.=&do_asm_rule($aes_asm_obj,$aes_asm_src);
622 }
623 if (($bn_asm_obj ne "") && ($_ eq "CRYPTO"))
624 {
625 $lib_obj =~ s/\s\S*\/bn_asm\S*/ \$(BN_ASM_OBJ)/;
626 $rules.=&do_asm_rule($bn_asm_obj,$bn_asm_src);
627 }
628 if (($bnco_asm_obj ne "") && ($_ eq "CRYPTO"))
629 {
630 $lib_obj .= "\$(BNCO_ASM_OBJ)";
631 $rules.=&do_asm_rule($bnco_asm_obj,$bnco_asm_src);
632 }
633 if (($des_enc_obj ne "") && ($_ eq "CRYPTO"))
634 { 796 {
635 $lib_obj =~ s/\s\S*des_enc\S*/ \$(DES_ENC_OBJ)/; 797 if ($cpuid_asm_obj ne "")
636 $lib_obj =~ s/\s\S*\/fcrypt_b\S*\s*/ /; 798 {
637 $rules.=&do_asm_rule($des_enc_obj,$des_enc_src); 799 $lib_obj =~ s/(\S*\/cryptlib\S*)/$1 \$(CPUID_ASM_OBJ)/;
800 $rules.=&do_asm_rule($cpuid_asm_obj,$cpuid_asm_src);
801 }
802 if ($aes_asm_obj ne "")
803 {
804 $lib_obj =~ s/\s(\S*\/aes_core\S*)/ \$(AES_ASM_OBJ)/;
805 $lib_obj =~ s/\s\S*\/aes_cbc\S*//;
806 $rules.=&do_asm_rule($aes_asm_obj,$aes_asm_src);
807 }
808 if ($sha1_asm_obj ne "")
809 {
810 $lib_obj =~ s/\s(\S*\/sha1dgst\S*)/ $1 \$(SHA1_ASM_OBJ)/;
811 $rules.=&do_asm_rule($sha1_asm_obj,$sha1_asm_src);
812 }
813 if ($bn_asm_obj ne "")
814 {
815 $lib_obj =~ s/\s\S*\/bn_asm\S*/ \$(BN_ASM_OBJ)/;
816 $rules.=&do_asm_rule($bn_asm_obj,$bn_asm_src);
817 }
818 if ($bnco_asm_obj ne "")
819 {
820 $lib_obj .= "\$(BNCO_ASM_OBJ)";
821 $rules.=&do_asm_rule($bnco_asm_obj,$bnco_asm_src);
822 }
823 if ($des_enc_obj ne "")
824 {
825 $lib_obj =~ s/\s\S*des_enc\S*/ \$(DES_ENC_OBJ)/;
826 $lib_obj =~ s/\s\S*\/fcrypt_b\S*\s*/ /;
827 $rules.=&do_asm_rule($des_enc_obj,$des_enc_src);
828 }
638 } 829 }
639 if (($bf_enc_obj ne "") && ($_ eq "CRYPTO")) 830 if (($bf_enc_obj ne "") && ($_ eq "CRYPTO"))
640 { 831 {
@@ -661,21 +852,11 @@ foreach (values %lib_nam)
661 $lib_obj =~ s/\s(\S*\/md5_dgst\S*)/ $1 \$(MD5_ASM_OBJ)/; 852 $lib_obj =~ s/\s(\S*\/md5_dgst\S*)/ $1 \$(MD5_ASM_OBJ)/;
662 $rules.=&do_asm_rule($md5_asm_obj,$md5_asm_src); 853 $rules.=&do_asm_rule($md5_asm_obj,$md5_asm_src);
663 } 854 }
664 if (($sha1_asm_obj ne "") && ($_ eq "CRYPTO"))
665 {
666 $lib_obj =~ s/\s(\S*\/sha1dgst\S*)/ $1 \$(SHA1_ASM_OBJ)/;
667 $rules.=&do_asm_rule($sha1_asm_obj,$sha1_asm_src);
668 }
669 if (($rmd160_asm_obj ne "") && ($_ eq "CRYPTO")) 855 if (($rmd160_asm_obj ne "") && ($_ eq "CRYPTO"))
670 { 856 {
671 $lib_obj =~ s/\s(\S*\/rmd_dgst\S*)/ $1 \$(RMD160_ASM_OBJ)/; 857 $lib_obj =~ s/\s(\S*\/rmd_dgst\S*)/ $1 \$(RMD160_ASM_OBJ)/;
672 $rules.=&do_asm_rule($rmd160_asm_obj,$rmd160_asm_src); 858 $rules.=&do_asm_rule($rmd160_asm_obj,$rmd160_asm_src);
673 } 859 }
674 if (($cpuid_asm_obj ne "") && ($_ eq "CRYPTO"))
675 {
676 $lib_obj =~ s/\s(\S*\/cversion\S*)/ $1 \$(CPUID_ASM_OBJ)/;
677 $rules.=&do_asm_rule($cpuid_asm_obj,$cpuid_asm_src);
678 }
679 $defs.=&do_defs(${_}."OBJ",$lib_obj,"\$(OBJ_D)",$obj); 860 $defs.=&do_defs(${_}."OBJ",$lib_obj,"\$(OBJ_D)",$obj);
680 $lib=($slib)?" \$(SHLIB_CFLAGS)".$shlib_ex_cflags{$_}:" \$(LIB_CFLAGS)"; 861 $lib=($slib)?" \$(SHLIB_CFLAGS)".$shlib_ex_cflags{$_}:" \$(LIB_CFLAGS)";
681 $rules.=&do_compile_rule("\$(OBJ_D)",$lib_obj{$_},$lib); 862 $rules.=&do_compile_rule("\$(OBJ_D)",$lib_obj{$_},$lib);
@@ -690,15 +871,43 @@ if (($platform eq "VC-WIN32") || ($platform eq "VC-NT")) {
690\$(OBJ_D)\\\$(SSL).res: ms\\version32.rc 871\$(OBJ_D)\\\$(SSL).res: ms\\version32.rc
691 \$(RSC) /fo"\$(OBJ_D)\\\$(SSL).res" /d SSL ms\\version32.rc 872 \$(RSC) /fo"\$(OBJ_D)\\\$(SSL).res" /d SSL ms\\version32.rc
692 873
874\$(OBJ_D)\\\$(LIBFIPS).res: ms\\version32.rc
875 \$(RSC) /fo"\$(OBJ_D)\\\$(LIBFIPS).res" /d FIPS ms\\version32.rc
876
693EOF 877EOF
694} 878}
695 879
696$defs.=&do_defs("T_EXE",$test,"\$(TEST_D)",$exep); 880$defs.=&do_defs("T_EXE",$test,"\$(TEST_D)",$exep);
697foreach (split(/\s+/,$test)) 881foreach (split(/\s+/,$test))
698 { 882 {
883 my $t_libs;
699 $t=&bname($_); 884 $t=&bname($_);
885 my $ltype;
886 # Check to see if test program is FIPS
887 if ($fips && /fips/)
888 {
889 # If fipsdso link to libosslfips.dll
890 # otherwise perform static link to
891 # $(O_FIPSCANISTER)
892 if ($fipsdso)
893 {
894 $t_libs = "\$(L_FIPS)";
895 $ltype = 0;
896 }
897 else
898 {
899 $t_libs = "\$(O_FIPSCANISTER)";
900 $ltype = 2;
901 }
902 }
903 else
904 {
905 $t_libs = "\$(L_LIBS)";
906 $ltype = 0;
907 }
908
700 $tt="\$(OBJ_D)${o}$t${obj}"; 909 $tt="\$(OBJ_D)${o}$t${obj}";
701 $rules.=&do_link_rule("\$(TEST_D)$o$t$exep",$tt,"\$(LIBS_DEP)","\$(L_LIBS) \$(EX_LIBS)"); 910 $rules.=&do_link_rule("\$(TEST_D)$o$t$exep",$tt,"\$(LIBS_DEP)","$t_libs \$(EX_LIBS)", $ltype);
702 } 911 }
703 912
704$defs.=&do_defs("E_SHLIB",$engines,"\$(ENG_D)",$shlibp); 913$defs.=&do_defs("E_SHLIB",$engines,"\$(ENG_D)",$shlibp);
@@ -712,9 +921,69 @@ foreach (split(/\s+/,$engines))
712 921
713 922
714$rules.= &do_lib_rule("\$(SSLOBJ)","\$(O_SSL)",$ssl,$shlib,"\$(SO_SSL)"); 923$rules.= &do_lib_rule("\$(SSLOBJ)","\$(O_SSL)",$ssl,$shlib,"\$(SO_SSL)");
715$rules.= &do_lib_rule("\$(CRYPTOOBJ)","\$(O_CRYPTO)",$crypto,$shlib,"\$(SO_CRYPTO)");
716 924
717$rules.=&do_link_rule("\$(BIN_D)$o\$(E_EXE)$exep","\$(E_OBJ)","\$(LIBS_DEP)","\$(L_LIBS) \$(EX_LIBS)"); 925if ($fips)
926 {
927 if ($shlib)
928 {
929 if ($fipsdso)
930 {
931 $rules.= &do_lib_rule("\$(CRYPTOOBJ)",
932 "\$(O_CRYPTO)", "$crypto",
933 $shlib, "", "");
934 $rules.= &do_lib_rule(
935 "\$(O_FIPSCANISTER)",
936 "\$(O_FIPS)", "\$(LIBFIPS)",
937 $shlib, "\$(SO_CRYPTO)", "\$(BASEADDR)");
938 $rules.= &do_sdef_rule();
939 }
940 else
941 {
942 $rules.= &do_lib_rule(
943 "\$(CRYPTOOBJ) \$(O_FIPSCANISTER)",
944 "\$(O_CRYPTO)", "$crypto",
945 $shlib, "\$(SO_CRYPTO)", "\$(BASEADDR)");
946 }
947 }
948 else
949 {
950 $rules.= &do_lib_rule("\$(CRYPTOOBJ)",
951 "\$(O_CRYPTO)",$crypto,$shlib,"\$(SO_CRYPTO)", "");
952 $rules.= &do_lib_rule("\$(CRYPTOOBJ) \$(FIPSOBJ)",
953 "\$(LIB_D)$o$crypto_compat",$crypto,$shlib,"\$(SO_CRYPTO)", "");
954 }
955 }
956 else
957 {
958 $rules.= &do_lib_rule("\$(CRYPTOOBJ)","\$(O_CRYPTO)",$crypto,$shlib,
959 "\$(SO_CRYPTO)");
960 }
961
962if ($fips)
963 {
964 if ($fipscanisterbuild)
965 {
966 $rules.= &do_rlink_rule("\$(O_FIPSCANISTER)",
967 "\$(OBJ_D)${o}fips_start$obj",
968 "\$(FIPSOBJ)",
969 "\$(OBJ_D)${o}fips_end$obj",
970 "\$(FIPS_SHA1_EXE)", "");
971 $rules.=&do_link_rule("\$(FIPS_SHA1_EXE)",
972 "\$(OBJ_D)${o}fips_standalone_sha1$obj \$(OBJ_D)${o}sha1dgst$obj \$(SHA1_ASM_OBJ)",
973 "","\$(EX_LIBS)", 1);
974 }
975 else
976 {
977 $rules.=&do_link_rule("\$(FIPS_SHA1_EXE)",
978 "\$(OBJ_D)${o}fips_standalone_sha1$obj \$(O_FIPSCANISTER)",
979 "","", 1);
980
981 }
982 $rules.=&do_link_rule("\$(PREMAIN_DSO_EXE)","\$(OBJ_D)${o}\$(E_PREMAIN_DSO)$obj \$(CRYPTOOBJ) \$(O_FIPSCANISTER)","","\$(EX_LIBS)", 1);
983
984 }
985
986$rules.=&do_link_rule("\$(BIN_D)$o\$(E_EXE)$exep","\$(E_OBJ)","\$(LIBS_DEP)","\$(L_LIBS) \$(EX_LIBS)", ($fips && !$shlib) ? 2 : 0);
718 987
719print $defs; 988print $defs;
720 989
@@ -752,6 +1021,8 @@ sub var_add
752 return("") if $no_dh && $dir =~ /\/dh/; 1021 return("") if $no_dh && $dir =~ /\/dh/;
753 return("") if $no_ec && $dir =~ /\/ec/; 1022 return("") if $no_ec && $dir =~ /\/ec/;
754 return("") if $no_cms && $dir =~ /\/cms/; 1023 return("") if $no_cms && $dir =~ /\/cms/;
1024 return("") if $no_jpake && $dir =~ /\/jpake/;
1025 return("") if !$fips && $dir =~ /^fips/;
755 if ($no_des && $dir =~ /\/des/) 1026 if ($no_des && $dir =~ /\/des/)
756 { 1027 {
757 if ($val =~ /read_pwd/) 1028 if ($val =~ /read_pwd/)
@@ -1011,6 +1282,7 @@ sub read_options
1011 "no-hmac" => \$no_hmac, 1282 "no-hmac" => \$no_hmac,
1012 "no-asm" => \$no_asm, 1283 "no-asm" => \$no_asm,
1013 "nasm" => \$nasm, 1284 "nasm" => \$nasm,
1285 "ml64" => \$ml64,
1014 "nw-nasm" => \$nw_nasm, 1286 "nw-nasm" => \$nw_nasm,
1015 "nw-mwasm" => \$nw_mwasm, 1287 "nw-mwasm" => \$nw_mwasm,
1016 "gaswin" => \$gaswin, 1288 "gaswin" => \$gaswin,
@@ -1018,6 +1290,7 @@ sub read_options
1018 "no-ssl3" => \$no_ssl3, 1290 "no-ssl3" => \$no_ssl3,
1019 "no-tlsext" => \$no_tlsext, 1291 "no-tlsext" => \$no_tlsext,
1020 "no-cms" => \$no_cms, 1292 "no-cms" => \$no_cms,
1293 "no-jpake" => \$no_jpake,
1021 "no-capieng" => \$no_capieng, 1294 "no-capieng" => \$no_capieng,
1022 "no-err" => \$no_err, 1295 "no-err" => \$no_err,
1023 "no-sock" => \$no_sock, 1296 "no-sock" => \$no_sock,
@@ -1045,6 +1318,9 @@ sub read_options
1045 "no-shared" => 0, 1318 "no-shared" => 0,
1046 "no-zlib" => 0, 1319 "no-zlib" => 0,
1047 "no-zlib-dynamic" => 0, 1320 "no-zlib-dynamic" => 0,
1321 "fips" => \$fips,
1322 "fipscanisterbuild" => [\$fips, \$fipscanisterbuild],
1323 "fipsdso" => [\$fips, \$fipscanisterbuild, \$fipsdso],
1048 ); 1324 );
1049 1325
1050 if (exists $valid_options{$_}) 1326 if (exists $valid_options{$_})
@@ -1086,6 +1362,18 @@ sub read_options
1086 {return 1;} 1362 {return 1;}
1087 return 0; 1363 return 0;
1088 } 1364 }
1365 # experimental-xxx is mostly like enable-xxx, but opensslconf.v
1366 # will still set OPENSSL_NO_xxx unless we set OPENSSL_EXPERIMENTAL_xxx.
1367 # (No need to fail if we don't know the algorithm -- this is for adventurous users only.)
1368 elsif (/^experimental-/)
1369 {
1370 my $algo, $ALGO;
1371 ($algo = $_) =~ s/^experimental-//;
1372 ($ALGO = $algo) =~ tr/[a-z]/[A-Z]/;
1373
1374 $xcflags="-DOPENSSL_EXPERIMENTAL_$ALGO $xcflags";
1375
1376 }
1089 elsif (/^--with-krb5-flavor=(.*)$/) 1377 elsif (/^--with-krb5-flavor=(.*)$/)
1090 { 1378 {
1091 my $krb5_flavor = $1; 1379 my $krb5_flavor = $1;
@@ -1109,3 +1397,31 @@ sub read_options
1109 else { return(0); } 1397 else { return(0); }
1110 return(1); 1398 return(1);
1111 } 1399 }
1400
1401sub fipslib_error
1402 {
1403 print STDERR "***FIPS module directory sanity check failed***\n";
1404 print STDERR "FIPS module build failed, or was deleted\n";
1405 print STDERR "Please rebuild FIPS module.\n";
1406 exit 1;
1407 }
1408
1409sub fips_check_files
1410 {
1411 my $dir = shift @_;
1412 my $ret = 1;
1413 if (!-d $dir)
1414 {
1415 print STDERR "FIPS module directory $dir does not exist\n";
1416 fipslib_error();
1417 }
1418 foreach (@_)
1419 {
1420 if (!-f "$dir${o}$_")
1421 {
1422 print STDERR "FIPS module file $_ does not exist!\n";
1423 $ret = 0;
1424 }
1425 }
1426 fipslib_error() if ($ret == 0);
1427 }
diff --git a/src/lib/libcrypto/util/mkdef.pl b/src/lib/libcrypto/util/mkdef.pl
index 8ecfde1848..5ae9ebb619 100644
--- a/src/lib/libcrypto/util/mkdef.pl
+++ b/src/lib/libcrypto/util/mkdef.pl
@@ -79,7 +79,7 @@ my $OS2=0;
79my $safe_stack_def = 0; 79my $safe_stack_def = 0;
80 80
81my @known_platforms = ( "__FreeBSD__", "PERL5", "NeXT", 81my @known_platforms = ( "__FreeBSD__", "PERL5", "NeXT",
82 "EXPORT_VAR_AS_FUNCTION", "ZLIB" ); 82 "EXPORT_VAR_AS_FUNCTION", "ZLIB", "OPENSSL_FIPS");
83my @known_ossl_platforms = ( "VMS", "WIN16", "WIN32", "WINNT", "OS2" ); 83my @known_ossl_platforms = ( "VMS", "WIN16", "WIN32", "WINNT", "OS2" );
84my @known_algorithms = ( "RC2", "RC4", "RC5", "IDEA", "DES", "BF", 84my @known_algorithms = ( "RC2", "RC4", "RC5", "IDEA", "DES", "BF",
85 "CAST", "MD2", "MD4", "MD5", "SHA", "SHA0", "SHA1", 85 "CAST", "MD2", "MD4", "MD5", "SHA", "SHA0", "SHA1",
@@ -102,6 +102,8 @@ my @known_algorithms = ( "RC2", "RC4", "RC5", "IDEA", "DES", "BF",
102 "CMS", 102 "CMS",
103 # CryptoAPI Engine 103 # CryptoAPI Engine
104 "CAPIENG", 104 "CAPIENG",
105 # JPAKE
106 "JPAKE",
105 # Deprecated functions 107 # Deprecated functions
106 "DEPRECATED" ); 108 "DEPRECATED" );
107 109
@@ -122,7 +124,8 @@ my $no_rsa; my $no_dsa; my $no_dh; my $no_hmac=0; my $no_aes; my $no_krb5;
122my $no_ec; my $no_ecdsa; my $no_ecdh; my $no_engine; my $no_hw; my $no_camellia; 124my $no_ec; my $no_ecdsa; my $no_ecdh; my $no_engine; my $no_hw; my $no_camellia;
123my $no_seed; 125my $no_seed;
124my $no_fp_api; my $no_static_engine; my $no_gmp; my $no_deprecated; 126my $no_fp_api; my $no_static_engine; my $no_gmp; my $no_deprecated;
125my $no_rfc3779; my $no_tlsext; my $no_cms; my $no_capieng; 127my $no_rfc3779; my $no_tlsext; my $no_cms; my $no_capieng; my $no_jpake;
128my $fips;
126 129
127 130
128foreach (@ARGV, split(/ /, $options)) 131foreach (@ARGV, split(/ /, $options))
@@ -144,12 +147,13 @@ foreach (@ARGV, split(/ /, $options))
144 } 147 }
145 $VMS=1 if $_ eq "VMS"; 148 $VMS=1 if $_ eq "VMS";
146 $OS2=1 if $_ eq "OS2"; 149 $OS2=1 if $_ eq "OS2";
150 $fips=1 if /^fips/;
151
147 if ($_ eq "zlib" || $_ eq "zlib-dynamic" 152 if ($_ eq "zlib" || $_ eq "zlib-dynamic"
148 || $_ eq "enable-zlib-dynamic") { 153 || $_ eq "enable-zlib-dynamic") {
149 $zlib = 1; 154 $zlib = 1;
150 } 155 }
151 156
152
153 $do_ssl=1 if $_ eq "ssleay"; 157 $do_ssl=1 if $_ eq "ssleay";
154 if ($_ eq "ssl") { 158 if ($_ eq "ssl") {
155 $do_ssl=1; 159 $do_ssl=1;
@@ -209,6 +213,7 @@ foreach (@ARGV, split(/ /, $options))
209 elsif (/^no-tlsext$/) { $no_tlsext=1; } 213 elsif (/^no-tlsext$/) { $no_tlsext=1; }
210 elsif (/^no-cms$/) { $no_cms=1; } 214 elsif (/^no-cms$/) { $no_cms=1; }
211 elsif (/^no-capieng$/) { $no_capieng=1; } 215 elsif (/^no-capieng$/) { $no_capieng=1; }
216 elsif (/^no-jpake$/) { $no_jpake=1; }
212 } 217 }
213 218
214 219
@@ -305,6 +310,8 @@ $crypto.=" crypto/tmdiff.h";
305$crypto.=" crypto/store/store.h"; 310$crypto.=" crypto/store/store.h";
306$crypto.=" crypto/pqueue/pqueue.h"; 311$crypto.=" crypto/pqueue/pqueue.h";
307$crypto.=" crypto/cms/cms.h"; 312$crypto.=" crypto/cms/cms.h";
313$crypto.=" crypto/jpake/jpake.h";
314$crypto.=" fips/fips.h fips/rand/fips_rand.h";
308 315
309my $symhacks="crypto/symhacks.h"; 316my $symhacks="crypto/symhacks.h";
310 317
@@ -1090,6 +1097,9 @@ sub is_valid
1090 if ($keyword eq "EXPORT_VAR_AS_FUNCTION" && ($VMSVAX || $W32 || $W16)) { 1097 if ($keyword eq "EXPORT_VAR_AS_FUNCTION" && ($VMSVAX || $W32 || $W16)) {
1091 return 1; 1098 return 1;
1092 } 1099 }
1100 if ($keyword eq "OPENSSL_FIPS" && $fips) {
1101 return 1;
1102 }
1093 if ($keyword eq "ZLIB" && $zlib) { return 1; } 1103 if ($keyword eq "ZLIB" && $zlib) { return 1; }
1094 return 0; 1104 return 0;
1095 } else { 1105 } else {
@@ -1135,6 +1145,7 @@ sub is_valid
1135 if ($keyword eq "TLSEXT" && $no_tlsext) { return 0; } 1145 if ($keyword eq "TLSEXT" && $no_tlsext) { return 0; }
1136 if ($keyword eq "CMS" && $no_cms) { return 0; } 1146 if ($keyword eq "CMS" && $no_cms) { return 0; }
1137 if ($keyword eq "CAPIENG" && $no_capieng) { return 0; } 1147 if ($keyword eq "CAPIENG" && $no_capieng) { return 0; }
1148 if ($keyword eq "JPAKE" && $no_jpake) { return 0; }
1138 if ($keyword eq "DEPRECATED" && $no_deprecated) { return 0; } 1149 if ($keyword eq "DEPRECATED" && $no_deprecated) { return 0; }
1139 1150
1140 # Nothing recognise as true 1151 # Nothing recognise as true
diff --git a/src/lib/libcrypto/util/mkerr.pl b/src/lib/libcrypto/util/mkerr.pl
index 53e14ab4df..554bebb159 100644
--- a/src/lib/libcrypto/util/mkerr.pl
+++ b/src/lib/libcrypto/util/mkerr.pl
@@ -44,7 +44,8 @@ while (@ARGV) {
44} 44}
45 45
46if($recurse) { 46if($recurse) {
47 @source = (<crypto/*.c>, <crypto/*/*.c>, <ssl/*.c>); 47 @source = ( <crypto/*.c>, <crypto/*/*.c>, <ssl/*.c>,
48 <fips/*.c>, <fips/*/*.c>);
48} else { 49} else {
49 @source = @ARGV; 50 @source = @ARGV;
50} 51}
diff --git a/src/lib/libcrypto/util/mkfiles.pl b/src/lib/libcrypto/util/mkfiles.pl
index 1282392fea..67fb8694c8 100644
--- a/src/lib/libcrypto/util/mkfiles.pl
+++ b/src/lib/libcrypto/util/mkfiles.pl
@@ -47,6 +47,7 @@ my @dirs = (
47"crypto/x509", 47"crypto/x509",
48"crypto/x509v3", 48"crypto/x509v3",
49"crypto/conf", 49"crypto/conf",
50"crypto/jpake",
50"crypto/txt_db", 51"crypto/txt_db",
51"crypto/pkcs7", 52"crypto/pkcs7",
52"crypto/pkcs12", 53"crypto/pkcs12",
@@ -58,6 +59,15 @@ my @dirs = (
58"crypto/store", 59"crypto/store",
59"crypto/pqueue", 60"crypto/pqueue",
60"crypto/cms", 61"crypto/cms",
62"fips",
63"fips/aes",
64"fips/des",
65"fips/dsa",
66"fips/dh",
67"fips/hmac",
68"fips/rand",
69"fips/rsa",
70"fips/sha",
61"ssl", 71"ssl",
62"apps", 72"apps",
63"engines", 73"engines",
diff --git a/src/lib/libcrypto/util/mklink.pl b/src/lib/libcrypto/util/mklink.pl
index d9bc98aab8..eacc327882 100644
--- a/src/lib/libcrypto/util/mklink.pl
+++ b/src/lib/libcrypto/util/mklink.pl
@@ -15,13 +15,21 @@
15# Apart from this, this script should be able to handle even the most 15# Apart from this, this script should be able to handle even the most
16# pathological cases. 16# pathological cases.
17 17
18use Cwd; 18my $pwd;
19eval 'use Cwd;';
20if ($@)
21 {
22 $pwd = `pwd`;
23 }
24else
25 {
26 $pwd = getcwd();
27 }
19 28
20my $from = shift; 29my $from = shift;
21my @files = @ARGV; 30my @files = @ARGV;
22 31
23my @from_path = split(/[\\\/]/, $from); 32my @from_path = split(/[\\\/]/, $from);
24my $pwd = getcwd();
25chomp($pwd); 33chomp($pwd);
26my @pwd_path = split(/[\\\/]/, $pwd); 34my @pwd_path = split(/[\\\/]/, $pwd);
27 35
diff --git a/src/lib/libcrypto/util/pl/VC-32.pl b/src/lib/libcrypto/util/pl/VC-32.pl
index 1e254119e6..166785db8d 100644
--- a/src/lib/libcrypto/util/pl/VC-32.pl
+++ b/src/lib/libcrypto/util/pl/VC-32.pl
@@ -4,12 +4,26 @@
4# 4#
5 5
6$ssl= "ssleay32"; 6$ssl= "ssleay32";
7$crypto="libeay32"; 7
8if ($fips && !$shlib)
9 {
10 $crypto="libeayfips32";
11 $crypto_compat = "libeaycompat32.lib";
12 }
13else
14 {
15 $crypto="libeay32";
16 }
17
18if ($fipscanisterbuild)
19 {
20 $fips_canister_path = "\$(LIB_D)\\fipscanister.lib";
21 }
8 22
9$o='\\'; 23$o='\\';
10$cp='$(PERL) util/copy.pl'; 24$cp='$(PERL) util/copy.pl';
11$mkdir='$(PERL) util/mkdir-p.pl'; 25$mkdir='$(PERL) util/mkdir-p.pl';
12$rm='del'; 26$rm='del /Q';
13 27
14$zlib_lib="zlib1.lib"; 28$zlib_lib="zlib1.lib";
15 29
@@ -96,7 +110,7 @@ else # Win32
96 $base_cflags=' /W3 /WX /Gs0 /GF /Gy /nologo -DOPENSSL_SYSNAME_WIN32 -DWIN32_LEAN_AND_MEAN -DL_ENDIAN -DDSO_WIN32'; 110 $base_cflags=' /W3 /WX /Gs0 /GF /Gy /nologo -DOPENSSL_SYSNAME_WIN32 -DWIN32_LEAN_AND_MEAN -DL_ENDIAN -DDSO_WIN32';
97 $base_cflags.=' -D_CRT_SECURE_NO_DEPRECATE'; # shut up VC8 111 $base_cflags.=' -D_CRT_SECURE_NO_DEPRECATE'; # shut up VC8
98 $base_cflags.=' -D_CRT_NONSTDC_NO_DEPRECATE'; # shut up VC8 112 $base_cflags.=' -D_CRT_NONSTDC_NO_DEPRECATE'; # shut up VC8
99 my $f = $shlib?' /MD':' /MT'; 113 my $f = $shlib || $fips ?' /MD':' /MT';
100 $lib_cflag='/Zl' if (!$shlib); # remove /DEFAULTLIBs from static lib 114 $lib_cflag='/Zl' if (!$shlib); # remove /DEFAULTLIBs from static lib
101 $opt_cflags=$f.' /Ox /O2 /Ob2'; 115 $opt_cflags=$f.' /Ox /O2 /Ob2';
102 $dbg_cflags=$f.'d /Od -DDEBUG -D_DEBUG'; 116 $dbg_cflags=$f.'d /Od -DDEBUG -D_DEBUG';
@@ -165,12 +179,17 @@ if ($nasm) {
165 # pick newest version 179 # pick newest version
166 $asm=($ver gt $vew?"nasm":"nasmw")." -f win32"; 180 $asm=($ver gt $vew?"nasm":"nasmw")." -f win32";
167 $afile='-o '; 181 $afile='-o ';
182} elsif ($ml64) {
183 $asm='ml64 /c /Cp /Cx';
184 $asm.=' /Zi' if $debug;
185 $afile='/Fo';
168} else { 186} else {
169 $asm='ml /Cp /coff /c /Cx'; 187 $asm='ml /Cp /coff /c /Cx';
170 $asm.=" /Zi" if $debug; 188 $asm.=" /Zi" if $debug;
171 $afile='/Fo'; 189 $afile='/Fo';
172} 190}
173 191
192$aes_asm_obj='';
174$bn_asm_obj=''; 193$bn_asm_obj='';
175$bn_asm_src=''; 194$bn_asm_src='';
176$des_enc_obj=''; 195$des_enc_obj='';
@@ -179,11 +198,13 @@ $bf_enc_obj='';
179$bf_enc_src=''; 198$bf_enc_src='';
180 199
181if (!$no_asm) 200if (!$no_asm)
201 {
202 if ($FLAVOR =~ "WIN32")
182 { 203 {
183 $aes_asm_obj='crypto\aes\asm\a_win32.obj'; 204 $aes_asm_obj='crypto\aes\asm\a_win32.obj';
184 $aes_asm_src='crypto\aes\asm\a_win32.asm'; 205 $aes_asm_src='crypto\aes\asm\a_win32.asm';
185 $bn_asm_obj='crypto\bn\asm\bn_win32.obj'; 206 $bn_asm_obj='crypto\bn\asm\bn_win32.obj crypto\bn\asm\mt_win32.obj';
186 $bn_asm_src='crypto\bn\asm\bn_win32.asm'; 207 $bn_asm_src='crypto\bn\asm\bn_win32.asm crypto\bn\asm\mt_win32.asm';
187 $bnco_asm_obj='crypto\bn\asm\co_win32.obj'; 208 $bnco_asm_obj='crypto\bn\asm\co_win32.obj';
188 $bnco_asm_src='crypto\bn\asm\co_win32.asm'; 209 $bnco_asm_src='crypto\bn\asm\co_win32.asm';
189 $des_enc_obj='crypto\des\asm\d_win32.obj crypto\des\asm\y_win32.obj'; 210 $des_enc_obj='crypto\des\asm\d_win32.obj crypto\des\asm\y_win32.obj';
@@ -204,12 +225,26 @@ if (!$no_asm)
204 $rmd160_asm_src='crypto\ripemd\asm\rm_win32.asm'; 225 $rmd160_asm_src='crypto\ripemd\asm\rm_win32.asm';
205 $cpuid_asm_obj='crypto\cpu_win32.obj'; 226 $cpuid_asm_obj='crypto\cpu_win32.obj';
206 $cpuid_asm_src='crypto\cpu_win32.asm'; 227 $cpuid_asm_src='crypto\cpu_win32.asm';
207 $cflags.=" -DOPENSSL_CPUID_OBJ -DOPENSSL_IA32_SSE2 -DAES_ASM -DBN_ASM -DOPENSSL_BN_ASM_PART_WORDS -DMD5_ASM -DSHA1_ASM -DRMD160_ASM"; 228 $cflags.=" -DOPENSSL_CPUID_OBJ -DOPENSSL_IA32_SSE2 -DAES_ASM -DBN_ASM -DOPENSSL_BN_ASM_PART_WORDS -DOPENSSL_BN_ASM_MONT -DMD5_ASM -DSHA1_ASM -DRMD160_ASM";
208 } 229 }
230 elsif ($FLAVOR =~ "WIN64A")
231 {
232 $aes_asm_obj='$(OBJ_D)\aes-x86_64.obj';
233 $aes_asm_src='crypto\aes\asm\aes-x86_64.asm';
234 $bn_asm_obj='$(OBJ_D)\x86_64-mont.obj $(OBJ_D)\bn_asm.obj';
235 $bn_asm_src='crypto\bn\asm\x86_64-mont.asm';
236 $sha1_asm_obj='$(OBJ_D)\sha1-x86_64.obj $(OBJ_D)\sha256-x86_64.obj $(OBJ_D)\sha512-x86_64.obj';
237 $sha1_asm_src='crypto\sha\asm\sha1-x86_64.asm crypto\sha\asm\sha256-x86_64.asm crypto\sha\asm\sha512-x86_64.asm';
238 $cpuid_asm_obj='$(OBJ_D)\cpuid-x86_64.obj';
239 $cpuid_asm_src='crypto\cpuid-x86_64.asm';
240 $cflags.=" -DOPENSSL_CPUID_OBJ -DAES_ASM -DOPENSSL_BN_ASM_MONT -DSHA1_ASM -DSHA256_ASM -DSHA512_ASM";
241 }
242 }
209 243
210if ($shlib && $FLAVOR !~ /CE/) 244if ($shlib && $FLAVOR !~ /CE/)
211 { 245 {
212 $mlflags.=" $lflags /dll"; 246 $mlflags.=" $lflags /dll";
247# $cflags =~ s| /MD| /MT|;
213 $lib_cflag=" -D_WINDLL"; 248 $lib_cflag=" -D_WINDLL";
214 $out_def="out32dll"; 249 $out_def="out32dll";
215 $tmp_def="tmp32dll"; 250 $tmp_def="tmp32dll";
@@ -232,8 +267,8 @@ $(INCO_D)\applink.c: ms\applink.c
232EXHEADER= $(EXHEADER) $(INCO_D)\applink.c 267EXHEADER= $(EXHEADER) $(INCO_D)\applink.c
233 268
234LIBS_DEP=$(LIBS_DEP) $(OBJ_D)\applink.obj 269LIBS_DEP=$(LIBS_DEP) $(OBJ_D)\applink.obj
235CRYPTOOBJ=$(OBJ_D)\uplink.obj $(CRYPTOOBJ)
236___ 270___
271$banner .= "CRYPTOOBJ=\$(OBJ_D)\\uplink.obj \$(CRYPTOOBJ)\n";
237 $banner.=<<'___' if ($FLAVOR =~ /WIN64/); 272 $banner.=<<'___' if ($FLAVOR =~ /WIN64/);
238CRYPTOOBJ=ms\uptable.obj $(CRYPTOOBJ) 273CRYPTOOBJ=ms\uptable.obj $(CRYPTOOBJ)
239___ 274___
@@ -250,26 +285,56 @@ $cflags.=" /Fd$out_def";
250 285
251sub do_lib_rule 286sub do_lib_rule
252 { 287 {
253 local($objs,$target,$name,$shlib)=@_; 288 my($objs,$target,$name,$shlib,$ign,$base_addr) = @_;
254 local($ret); 289 local($ret);
255 290
256 $taget =~ s/\//$o/g if $o ne '/'; 291 $taget =~ s/\//$o/g if $o ne '/';
257 if ($name ne "") 292 my $base_arg;
293 if ($base_addr ne "")
294 {
295 $base_arg= " /base:$base_addr";
296 }
297 else
298 {
299 $base_arg = "";
300 }
301 if ($target =~ /O_CRYPTO/ && $fipsdso)
302 {
303 $name = "/def:ms/libeayfips.def";
304 }
305 elsif ($name ne "")
258 { 306 {
259 $name =~ tr/a-z/A-Z/; 307 $name =~ tr/a-z/A-Z/;
260 $name = "/def:ms/${name}.def"; 308 $name = "/def:ms/${name}.def";
261 } 309 }
262# $target="\$(LIB_D)$o$target"; 310# $target="\$(LIB_D)$o$target";
263 $ret.="$target: $objs\n"; 311# $ret.="$target: $objs\n";
264 if (!$shlib) 312 if (!$shlib)
265 { 313 {
266# $ret.="\t\$(RM) \$(O_$Name)\n"; 314# $ret.="\t\$(RM) \$(O_$Name)\n";
267 $ex =' '; 315 $ex =' ';
316 $ret.="$target: $objs\n";
268 $ret.="\t\$(MKLIB) $lfile$target @<<\n $objs $ex\n<<\n"; 317 $ret.="\t\$(MKLIB) $lfile$target @<<\n $objs $ex\n<<\n";
269 } 318 }
270 else 319 else
271 { 320 {
272 local($ex)=($target =~ /O_CRYPTO/)?'':' $(L_CRYPTO)'; 321 my $ex = "";
322 if ($target =~ /O_SSL/)
323 {
324 $ex .= " \$(L_CRYPTO)";
325 #$ex .= " \$(L_FIPS)" if $fipsdso;
326 }
327 my $fipstarget;
328 if ($fipsdso)
329 {
330 $fipstarget = "O_FIPS";
331 }
332 else
333 {
334 $fipstarget = "O_CRYPTO";
335 }
336
337
273 if ($name eq "") 338 if ($name eq "")
274 { 339 {
275 $ex.=' bufferoverflowu.lib' if ($FLAVOR =~ /WIN64/); 340 $ex.=' bufferoverflowu.lib' if ($FLAVOR =~ /WIN64/);
@@ -290,7 +355,39 @@ sub do_lib_rule
290 $ex.=' bufferoverflowu.lib' if ($FLAVOR =~ /WIN64/); 355 $ex.=' bufferoverflowu.lib' if ($FLAVOR =~ /WIN64/);
291 } 356 }
292 $ex.=" $zlib_lib" if $zlib_opt == 1 && $target =~ /O_CRYPTO/; 357 $ex.=" $zlib_lib" if $zlib_opt == 1 && $target =~ /O_CRYPTO/;
293 $ret.="\t\$(LINK) \$(MLFLAGS) $efile$target $name @<<\n \$(SHLIB_EX_OBJ) $objs $ex\n<<\n"; 358
359 if ($fips && $target =~ /$fipstarget/)
360 {
361 $ex.= $mwex unless $fipscanisterbuild;
362 $ret.="$target: $objs \$(PREMAIN_DSO_EXE)";
363 if ($fipsdso)
364 {
365 $ex.=" \$(OBJ_D)\\\$(LIBFIPS).res";
366 $ret.=" \$(OBJ_D)\\\$(LIBFIPS).res";
367 $ret.=" ms/\$(LIBFIPS).def";
368 }
369 $ret.="\n\tSET FIPS_LINK=\$(LINK)\n";
370 $ret.="\tSET FIPS_CC=\$(CC)\n";
371 $ret.="\tSET FIPS_CC_ARGS=/Fo\$(OBJ_D)${o}fips_premain.obj \$(SHLIB_CFLAGS) -c\n";
372 $ret.="\tSET PREMAIN_DSO_EXE=\$(PREMAIN_DSO_EXE)\n";
373 $ret.="\tSET FIPS_SHA1_EXE=\$(FIPS_SHA1_EXE)\n";
374 $ret.="\tSET FIPS_TARGET=$target\n";
375 $ret.="\tSET FIPSLIB_D=\$(FIPSLIB_D)\n";
376 $ret.="\t\$(FIPSLINK) \$(MLFLAGS) /map $base_arg $efile$target ";
377 $ret.="$name @<<\n \$(SHLIB_EX_OBJ) $objs ";
378 $ret.="\$(OBJ_D)${o}fips_premain.obj $ex\n<<\n";
379 }
380 else
381 {
382 $ret.="$target: $objs";
383 if ($target =~ /O_CRYPTO/ && $fipsdso)
384 {
385 $ret .= " \$(O_FIPS)";
386 $ex .= " \$(L_FIPS)";
387 }
388 $ret.="\n\t\$(LINK) \$(MLFLAGS) $efile$target $name @<<\n \$(SHLIB_EX_OBJ) $objs $ex\n<<\n";
389 }
390
294 $ret.="\tIF EXIST \$@.manifest mt -nologo -manifest \$@.manifest -outputresource:\$@;2\n\n"; 391 $ret.="\tIF EXIST \$@.manifest mt -nologo -manifest \$@.manifest -outputresource:\$@;2\n\n";
295 } 392 }
296 $ret.="\n"; 393 $ret.="\n";
@@ -299,16 +396,64 @@ sub do_lib_rule
299 396
300sub do_link_rule 397sub do_link_rule
301 { 398 {
302 local($target,$files,$dep_libs,$libs)=@_; 399 my($target,$files,$dep_libs,$libs,$standalone)=@_;
303 local($ret,$_); 400 local($ret,$_);
304
305 $file =~ s/\//$o/g if $o ne '/'; 401 $file =~ s/\//$o/g if $o ne '/';
306 $n=&bname($targer); 402 $n=&bname($targer);
307 $ret.="$target: $files $dep_libs\n"; 403 $ret.="$target: $files $dep_libs\n";
308 $ret.="\t\$(LINK) \$(LFLAGS) $efile$target @<<\n"; 404 if ($standalone == 1)
309 $ret.=" \$(APP_EX_OBJ) $files $libs\n<<\n"; 405 {
310 $ret.="\tIF EXIST \$@.manifest mt -nologo -manifest \$@.manifest -outputresource:\$@;1\n\n"; 406 $ret.=" \$(LINK) \$(LFLAGS) $efile$target @<<\n\t";
407 $ret.= "$mwex advapi32.lib " if ($files =~ /O_FIPSCANISTER/ && !$fipscanisterbuild);
408 $ret.="$files $libs\n<<\n";
409 }
410 elsif ($standalone == 2)
411 {
412 $ret.="\tSET FIPS_LINK=\$(LINK)\n";
413 $ret.="\tSET FIPS_CC=\$(CC)\n";
414 $ret.="\tSET FIPS_CC_ARGS=/Fo\$(OBJ_D)${o}fips_premain.obj \$(SHLIB_CFLAGS) -c\n";
415 $ret.="\tSET PREMAIN_DSO_EXE=\n";
416 $ret.="\tSET FIPS_TARGET=$target\n";
417 $ret.="\tSET FIPS_SHA1_EXE=\$(FIPS_SHA1_EXE)\n";
418 $ret.="\tSET FIPSLIB_D=\$(FIPSLIB_D)\n";
419 $ret.="\t\$(FIPSLINK) \$(LFLAGS) /map $efile$target @<<\n";
420 $ret.="\t\$(APP_EX_OBJ) $files \$(OBJ_D)${o}fips_premain.obj $libs\n<<\n";
421 }
422 else
423 {
424 $ret.="\t\$(LINK) \$(LFLAGS) $efile$target @<<\n";
425 $ret.="\t\$(APP_EX_OBJ) $files $libs\n<<\n";
426 }
427 $ret.="\tIF EXIST \$@.manifest mt -nologo -manifest \$@.manifest -outputresource:\$@;1\n\n";
311 return($ret); 428 return($ret);
312 } 429 }
313 430
431sub do_rlink_rule
432 {
433 local($target,$rl_start, $rl_mid, $rl_end,$dep_libs,$libs)=@_;
434 local($ret,$_);
435 my $files = "$rl_start $rl_mid $rl_end";
436
437 $file =~ s/\//$o/g if $o ne '/';
438 $n=&bname($targer);
439 $ret.="$target: $files $dep_libs \$(FIPS_SHA1_EXE)\n";
440 $ret.="\t\$(PERL) ms\\segrenam.pl \$\$a $rl_start\n";
441 $ret.="\t\$(PERL) ms\\segrenam.pl \$\$b $rl_mid\n";
442 $ret.="\t\$(PERL) ms\\segrenam.pl \$\$c $rl_end\n";
443 $ret.="\t\$(MKLIB) $lfile$target @<<\n\t$files\n<<\n";
444 $ret.="\t\$(FIPS_SHA1_EXE) $target > ${target}.sha1\n";
445 $ret.="\t\$(PERL) util${o}copy.pl -stripcr fips${o}fips_premain.c \$(LIB_D)${o}fips_premain.c\n";
446 $ret.="\t\$(CP) fips${o}fips_premain.c.sha1 \$(LIB_D)${o}fips_premain.c.sha1\n";
447 $ret.="\n";
448 return($ret);
449 }
450
451sub do_sdef_rule
452 {
453 my $ret = "ms/\$(LIBFIPS).def: \$(O_FIPSCANISTER)\n";
454 $ret.="\t\$(PERL) util/mksdef.pl \$(MLFLAGS) /out:dummy.dll /def:ms/libeay32.def @<<\n \$(O_FIPSCANISTER)\n<<\n";
455 $ret.="\n";
456 return $ret;
457 }
458
3141; 4591;
diff --git a/src/lib/libcrypto/x509/by_dir.c b/src/lib/libcrypto/x509/by_dir.c
index 37f9a48206..341e0ba6a4 100644
--- a/src/lib/libcrypto/x509/by_dir.c
+++ b/src/lib/libcrypto/x509/by_dir.c
@@ -74,6 +74,10 @@
74#include <openssl/lhash.h> 74#include <openssl/lhash.h>
75#include <openssl/x509.h> 75#include <openssl/x509.h>
76 76
77#ifdef _WIN32
78#define stat _stat
79#endif
80
77typedef struct lookup_dir_st 81typedef struct lookup_dir_st
78 { 82 {
79 BUF_MEM *buffer; 83 BUF_MEM *buffer;
diff --git a/src/lib/libcrypto/x509/x509_cmp.c b/src/lib/libcrypto/x509/x509_cmp.c
index 0d6bc653b2..e4c682fc44 100644
--- a/src/lib/libcrypto/x509/x509_cmp.c
+++ b/src/lib/libcrypto/x509/x509_cmp.c
@@ -322,10 +322,16 @@ unsigned long X509_NAME_hash(X509_NAME *x)
322 { 322 {
323 unsigned long ret=0; 323 unsigned long ret=0;
324 unsigned char md[16]; 324 unsigned char md[16];
325 EVP_MD_CTX md_ctx;
325 326
326 /* Make sure X509_NAME structure contains valid cached encoding */ 327 /* Make sure X509_NAME structure contains valid cached encoding */
327 i2d_X509_NAME(x,NULL); 328 i2d_X509_NAME(x,NULL);
328 EVP_Digest(x->bytes->data, x->bytes->length, md, NULL, EVP_md5(), NULL); 329 EVP_MD_CTX_init(&md_ctx);
330 EVP_MD_CTX_set_flags(&md_ctx, EVP_MD_CTX_FLAG_NON_FIPS_ALLOW);
331 EVP_DigestInit_ex(&md_ctx, EVP_md5(), NULL);
332 EVP_DigestUpdate(&md_ctx, x->bytes->data, x->bytes->length);
333 EVP_DigestFinal_ex(&md_ctx,md,NULL);
334 EVP_MD_CTX_cleanup(&md_ctx);
329 335
330 ret=( ((unsigned long)md[0] )|((unsigned long)md[1]<<8L)| 336 ret=( ((unsigned long)md[0] )|((unsigned long)md[1]<<8L)|
331 ((unsigned long)md[2]<<16L)|((unsigned long)md[3]<<24L) 337 ((unsigned long)md[2]<<16L)|((unsigned long)md[3]<<24L)
diff --git a/src/lib/libcrypto/x509/x509_trs.c b/src/lib/libcrypto/x509/x509_trs.c
index 9c84a59d52..ed18700585 100644
--- a/src/lib/libcrypto/x509/x509_trs.c
+++ b/src/lib/libcrypto/x509/x509_trs.c
@@ -1,5 +1,5 @@
1/* x509_trs.c */ 1/* x509_trs.c */
2/* Written by Dr Stephen N Henson (shenson@bigfoot.com) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 1999. 3 * project 1999.
4 */ 4 */
5/* ==================================================================== 5/* ====================================================================
diff --git a/src/lib/libcrypto/x509/x509cset.c b/src/lib/libcrypto/x509/x509cset.c
index 9d1646d5c8..7f4004b291 100644
--- a/src/lib/libcrypto/x509/x509cset.c
+++ b/src/lib/libcrypto/x509/x509cset.c
@@ -1,5 +1,5 @@
1/* crypto/x509/x509cset.c */ 1/* crypto/x509/x509cset.c */
2/* Written by Dr Stephen N Henson (shenson@bigfoot.com) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 2001. 3 * project 2001.
4 */ 4 */
5/* ==================================================================== 5/* ====================================================================
diff --git a/src/lib/libcrypto/x509/x509spki.c b/src/lib/libcrypto/x509/x509spki.c
index ed868b838e..02a203d72c 100644
--- a/src/lib/libcrypto/x509/x509spki.c
+++ b/src/lib/libcrypto/x509/x509spki.c
@@ -1,5 +1,5 @@
1/* x509spki.c */ 1/* x509spki.c */
2/* Written by Dr Stephen N Henson (shenson@bigfoot.com) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 1999. 3 * project 1999.
4 */ 4 */
5/* ==================================================================== 5/* ====================================================================
diff --git a/src/lib/libcrypto/x509v3/ext_dat.h b/src/lib/libcrypto/x509v3/ext_dat.h
index 5c063ac65d..3eaec46f8a 100644
--- a/src/lib/libcrypto/x509v3/ext_dat.h
+++ b/src/lib/libcrypto/x509v3/ext_dat.h
@@ -1,5 +1,5 @@
1/* ext_dat.h */ 1/* ext_dat.h */
2/* Written by Dr Stephen N Henson (shenson@bigfoot.com) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 1999. 3 * project 1999.
4 */ 4 */
5/* ==================================================================== 5/* ====================================================================
diff --git a/src/lib/libcrypto/x509v3/pcy_data.c b/src/lib/libcrypto/x509v3/pcy_data.c
index 4711b1ee92..fb392b901f 100644
--- a/src/lib/libcrypto/x509v3/pcy_data.c
+++ b/src/lib/libcrypto/x509v3/pcy_data.c
@@ -1,5 +1,5 @@
1/* pcy_data.c */ 1/* pcy_data.c */
2/* Written by Dr Stephen N Henson (shenson@bigfoot.com) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 2004. 3 * project 2004.
4 */ 4 */
5/* ==================================================================== 5/* ====================================================================
diff --git a/src/lib/libcrypto/x509v3/pcy_tree.c b/src/lib/libcrypto/x509v3/pcy_tree.c
index b1ce77b9af..6c87a7f506 100644
--- a/src/lib/libcrypto/x509v3/pcy_tree.c
+++ b/src/lib/libcrypto/x509v3/pcy_tree.c
@@ -1,5 +1,5 @@
1/* pcy_tree.c */ 1/* pcy_tree.c */
2/* Written by Dr Stephen N Henson (shenson@bigfoot.com) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 2004. 3 * project 2004.
4 */ 4 */
5/* ==================================================================== 5/* ====================================================================
diff --git a/src/lib/libcrypto/x509v3/tabtest.c b/src/lib/libcrypto/x509v3/tabtest.c
index dad0d38dd5..5ed6eb6891 100644
--- a/src/lib/libcrypto/x509v3/tabtest.c
+++ b/src/lib/libcrypto/x509v3/tabtest.c
@@ -1,5 +1,5 @@
1/* tabtest.c */ 1/* tabtest.c */
2/* Written by Dr Stephen N Henson (shenson@bigfoot.com) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 1999. 3 * project 1999.
4 */ 4 */
5/* ==================================================================== 5/* ====================================================================
diff --git a/src/lib/libcrypto/x509v3/v3_addr.c b/src/lib/libcrypto/x509v3/v3_addr.c
index c6730ab3fd..a37f844d3c 100644
--- a/src/lib/libcrypto/x509v3/v3_addr.c
+++ b/src/lib/libcrypto/x509v3/v3_addr.c
@@ -878,6 +878,7 @@ int v3_addr_canonize(IPAddrBlocks *addr)
878 v3_addr_get_afi(f))) 878 v3_addr_get_afi(f)))
879 return 0; 879 return 0;
880 } 880 }
881 (void)sk_IPAddressFamily_set_cmp_func(addr, IPAddressFamily_cmp);
881 sk_IPAddressFamily_sort(addr); 882 sk_IPAddressFamily_sort(addr);
882 assert(v3_addr_is_canonical(addr)); 883 assert(v3_addr_is_canonical(addr));
883 return 1; 884 return 1;
diff --git a/src/lib/libcrypto/x509v3/v3_akey.c b/src/lib/libcrypto/x509v3/v3_akey.c
index ac0548b775..c6b68ee221 100644
--- a/src/lib/libcrypto/x509v3/v3_akey.c
+++ b/src/lib/libcrypto/x509v3/v3_akey.c
@@ -1,5 +1,5 @@
1/* v3_akey.c */ 1/* v3_akey.c */
2/* Written by Dr Stephen N Henson (shenson@bigfoot.com) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 1999. 3 * project 1999.
4 */ 4 */
5/* ==================================================================== 5/* ====================================================================
diff --git a/src/lib/libcrypto/x509v3/v3_akeya.c b/src/lib/libcrypto/x509v3/v3_akeya.c
index 2aafa26ba7..2c50f7360e 100644
--- a/src/lib/libcrypto/x509v3/v3_akeya.c
+++ b/src/lib/libcrypto/x509v3/v3_akeya.c
@@ -1,5 +1,5 @@
1/* v3_akey_asn1.c */ 1/* v3_akey_asn1.c */
2/* Written by Dr Stephen N Henson (shenson@bigfoot.com) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 1999. 3 * project 1999.
4 */ 4 */
5/* ==================================================================== 5/* ====================================================================
diff --git a/src/lib/libcrypto/x509v3/v3_alt.c b/src/lib/libcrypto/x509v3/v3_alt.c
index ac3139d1e6..75fda7f268 100644
--- a/src/lib/libcrypto/x509v3/v3_alt.c
+++ b/src/lib/libcrypto/x509v3/v3_alt.c
@@ -1,5 +1,5 @@
1/* v3_alt.c */ 1/* v3_alt.c */
2/* Written by Dr Stephen N Henson (shenson@bigfoot.com) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project. 3 * project.
4 */ 4 */
5/* ==================================================================== 5/* ====================================================================
@@ -527,7 +527,8 @@ GENERAL_NAME *v2i_GENERAL_NAME_ex(GENERAL_NAME *out,
527 return gen; 527 return gen;
528 528
529 err: 529 err:
530 GENERAL_NAME_free(gen); 530 if (!out)
531 GENERAL_NAME_free(gen);
531 return NULL; 532 return NULL;
532 } 533 }
533 534
diff --git a/src/lib/libcrypto/x509v3/v3_bcons.c b/src/lib/libcrypto/x509v3/v3_bcons.c
index 74b1233071..82aa488f75 100644
--- a/src/lib/libcrypto/x509v3/v3_bcons.c
+++ b/src/lib/libcrypto/x509v3/v3_bcons.c
@@ -1,5 +1,5 @@
1/* v3_bcons.c */ 1/* v3_bcons.c */
2/* Written by Dr Stephen N Henson (shenson@bigfoot.com) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 1999. 3 * project 1999.
4 */ 4 */
5/* ==================================================================== 5/* ====================================================================
diff --git a/src/lib/libcrypto/x509v3/v3_bitst.c b/src/lib/libcrypto/x509v3/v3_bitst.c
index cf31f0816e..058d0d4dce 100644
--- a/src/lib/libcrypto/x509v3/v3_bitst.c
+++ b/src/lib/libcrypto/x509v3/v3_bitst.c
@@ -1,5 +1,5 @@
1/* v3_bitst.c */ 1/* v3_bitst.c */
2/* Written by Dr Stephen N Henson (shenson@bigfoot.com) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 1999. 3 * project 1999.
4 */ 4 */
5/* ==================================================================== 5/* ====================================================================
diff --git a/src/lib/libcrypto/x509v3/v3_conf.c b/src/lib/libcrypto/x509v3/v3_conf.c
index 2b867305fb..11eb6b7fd5 100644
--- a/src/lib/libcrypto/x509v3/v3_conf.c
+++ b/src/lib/libcrypto/x509v3/v3_conf.c
@@ -1,5 +1,5 @@
1/* v3_conf.c */ 1/* v3_conf.c */
2/* Written by Dr Stephen N Henson (shenson@bigfoot.com) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 1999. 3 * project 1999.
4 */ 4 */
5/* ==================================================================== 5/* ====================================================================
diff --git a/src/lib/libcrypto/x509v3/v3_cpols.c b/src/lib/libcrypto/x509v3/v3_cpols.c
index a40f490aa9..95596055ab 100644
--- a/src/lib/libcrypto/x509v3/v3_cpols.c
+++ b/src/lib/libcrypto/x509v3/v3_cpols.c
@@ -1,5 +1,5 @@
1/* v3_cpols.c */ 1/* v3_cpols.c */
2/* Written by Dr Stephen N Henson (shenson@bigfoot.com) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 1999. 3 * project 1999.
4 */ 4 */
5/* ==================================================================== 5/* ====================================================================
diff --git a/src/lib/libcrypto/x509v3/v3_crld.c b/src/lib/libcrypto/x509v3/v3_crld.c
index c6e3ebae7b..181a8977b1 100644
--- a/src/lib/libcrypto/x509v3/v3_crld.c
+++ b/src/lib/libcrypto/x509v3/v3_crld.c
@@ -1,5 +1,5 @@
1/* v3_crld.c */ 1/* v3_crld.c */
2/* Written by Dr Stephen N Henson (shenson@bigfoot.com) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 1999. 3 * project 1999.
4 */ 4 */
5/* ==================================================================== 5/* ====================================================================
diff --git a/src/lib/libcrypto/x509v3/v3_enum.c b/src/lib/libcrypto/x509v3/v3_enum.c
index a236cb22e1..36576eaa4d 100644
--- a/src/lib/libcrypto/x509v3/v3_enum.c
+++ b/src/lib/libcrypto/x509v3/v3_enum.c
@@ -1,5 +1,5 @@
1/* v3_enum.c */ 1/* v3_enum.c */
2/* Written by Dr Stephen N Henson (shenson@bigfoot.com) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 1999. 3 * project 1999.
4 */ 4 */
5/* ==================================================================== 5/* ====================================================================
diff --git a/src/lib/libcrypto/x509v3/v3_extku.c b/src/lib/libcrypto/x509v3/v3_extku.c
index a4efe0031e..c0d14500ed 100644
--- a/src/lib/libcrypto/x509v3/v3_extku.c
+++ b/src/lib/libcrypto/x509v3/v3_extku.c
@@ -1,5 +1,5 @@
1/* v3_extku.c */ 1/* v3_extku.c */
2/* Written by Dr Stephen N Henson (shenson@bigfoot.com) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 1999. 3 * project 1999.
4 */ 4 */
5/* ==================================================================== 5/* ====================================================================
diff --git a/src/lib/libcrypto/x509v3/v3_genn.c b/src/lib/libcrypto/x509v3/v3_genn.c
index 650b510980..84b4b1c881 100644
--- a/src/lib/libcrypto/x509v3/v3_genn.c
+++ b/src/lib/libcrypto/x509v3/v3_genn.c
@@ -1,5 +1,5 @@
1/* v3_genn.c */ 1/* v3_genn.c */
2/* Written by Dr Stephen N Henson (shenson@bigfoot.com) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 1999. 3 * project 1999.
4 */ 4 */
5/* ==================================================================== 5/* ====================================================================
diff --git a/src/lib/libcrypto/x509v3/v3_ia5.c b/src/lib/libcrypto/x509v3/v3_ia5.c
index b739ccd036..4ff12b52b5 100644
--- a/src/lib/libcrypto/x509v3/v3_ia5.c
+++ b/src/lib/libcrypto/x509v3/v3_ia5.c
@@ -1,5 +1,5 @@
1/* v3_ia5.c */ 1/* v3_ia5.c */
2/* Written by Dr Stephen N Henson (shenson@bigfoot.com) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 1999. 3 * project 1999.
4 */ 4 */
5/* ==================================================================== 5/* ====================================================================
diff --git a/src/lib/libcrypto/x509v3/v3_info.c b/src/lib/libcrypto/x509v3/v3_info.c
index e0ef69de42..e1b8699f92 100644
--- a/src/lib/libcrypto/x509v3/v3_info.c
+++ b/src/lib/libcrypto/x509v3/v3_info.c
@@ -1,5 +1,5 @@
1/* v3_info.c */ 1/* v3_info.c */
2/* Written by Dr Stephen N Henson (shenson@bigfoot.com) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 1999. 3 * project 1999.
4 */ 4 */
5/* ==================================================================== 5/* ====================================================================
diff --git a/src/lib/libcrypto/x509v3/v3_int.c b/src/lib/libcrypto/x509v3/v3_int.c
index 9a48dc1508..4bfd14cf46 100644
--- a/src/lib/libcrypto/x509v3/v3_int.c
+++ b/src/lib/libcrypto/x509v3/v3_int.c
@@ -1,5 +1,5 @@
1/* v3_int.c */ 1/* v3_int.c */
2/* Written by Dr Stephen N Henson (shenson@bigfoot.com) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 1999. 3 * project 1999.
4 */ 4 */
5/* ==================================================================== 5/* ====================================================================
diff --git a/src/lib/libcrypto/x509v3/v3_lib.c b/src/lib/libcrypto/x509v3/v3_lib.c
index f3015ea610..df3a48f43e 100644
--- a/src/lib/libcrypto/x509v3/v3_lib.c
+++ b/src/lib/libcrypto/x509v3/v3_lib.c
@@ -1,5 +1,5 @@
1/* v3_lib.c */ 1/* v3_lib.c */
2/* Written by Dr Stephen N Henson (shenson@bigfoot.com) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 1999. 3 * project 1999.
4 */ 4 */
5/* ==================================================================== 5/* ====================================================================
diff --git a/src/lib/libcrypto/x509v3/v3_ocsp.c b/src/lib/libcrypto/x509v3/v3_ocsp.c
index 62aac06335..e426ea930c 100644
--- a/src/lib/libcrypto/x509v3/v3_ocsp.c
+++ b/src/lib/libcrypto/x509v3/v3_ocsp.c
@@ -1,5 +1,5 @@
1/* v3_ocsp.c */ 1/* v3_ocsp.c */
2/* Written by Dr Stephen N Henson (shenson@bigfoot.com) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 1999. 3 * project 1999.
4 */ 4 */
5/* ==================================================================== 5/* ====================================================================
diff --git a/src/lib/libcrypto/x509v3/v3_pku.c b/src/lib/libcrypto/x509v3/v3_pku.c
index 5c4626e89b..076f3ff48e 100644
--- a/src/lib/libcrypto/x509v3/v3_pku.c
+++ b/src/lib/libcrypto/x509v3/v3_pku.c
@@ -1,5 +1,5 @@
1/* v3_pku.c */ 1/* v3_pku.c */
2/* Written by Dr Stephen N Henson (shenson@bigfoot.com) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 1999. 3 * project 1999.
4 */ 4 */
5/* ==================================================================== 5/* ====================================================================
diff --git a/src/lib/libcrypto/x509v3/v3_prn.c b/src/lib/libcrypto/x509v3/v3_prn.c
index 20bd9bda19..c1bb17f105 100644
--- a/src/lib/libcrypto/x509v3/v3_prn.c
+++ b/src/lib/libcrypto/x509v3/v3_prn.c
@@ -1,5 +1,5 @@
1/* v3_prn.c */ 1/* v3_prn.c */
2/* Written by Dr Stephen N Henson (shenson@bigfoot.com) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 1999. 3 * project 1999.
4 */ 4 */
5/* ==================================================================== 5/* ====================================================================
diff --git a/src/lib/libcrypto/x509v3/v3_purp.c b/src/lib/libcrypto/x509v3/v3_purp.c
index c54e7887c7..e18751e01c 100644
--- a/src/lib/libcrypto/x509v3/v3_purp.c
+++ b/src/lib/libcrypto/x509v3/v3_purp.c
@@ -1,5 +1,5 @@
1/* v3_purp.c */ 1/* v3_purp.c */
2/* Written by Dr Stephen N Henson (shenson@bigfoot.com) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 2001. 3 * project 2001.
4 */ 4 */
5/* ==================================================================== 5/* ====================================================================
diff --git a/src/lib/libcrypto/x509v3/v3_skey.c b/src/lib/libcrypto/x509v3/v3_skey.c
index da0a3558f6..202c9e4896 100644
--- a/src/lib/libcrypto/x509v3/v3_skey.c
+++ b/src/lib/libcrypto/x509v3/v3_skey.c
@@ -1,5 +1,5 @@
1/* v3_skey.c */ 1/* v3_skey.c */
2/* Written by Dr Stephen N Henson (shenson@bigfoot.com) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 1999. 3 * project 1999.
4 */ 4 */
5/* ==================================================================== 5/* ====================================================================
diff --git a/src/lib/libcrypto/x509v3/v3_sxnet.c b/src/lib/libcrypto/x509v3/v3_sxnet.c
index eaea9ea01b..2a6bf11b65 100644
--- a/src/lib/libcrypto/x509v3/v3_sxnet.c
+++ b/src/lib/libcrypto/x509v3/v3_sxnet.c
@@ -1,5 +1,5 @@
1/* v3_sxnet.c */ 1/* v3_sxnet.c */
2/* Written by Dr Stephen N Henson (shenson@bigfoot.com) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 1999. 3 * project 1999.
4 */ 4 */
5/* ==================================================================== 5/* ====================================================================
diff --git a/src/lib/libcrypto/x509v3/v3_utl.c b/src/lib/libcrypto/x509v3/v3_utl.c
index 57be441399..2cb53008e3 100644
--- a/src/lib/libcrypto/x509v3/v3_utl.c
+++ b/src/lib/libcrypto/x509v3/v3_utl.c
@@ -1,5 +1,5 @@
1/* v3_utl.c */ 1/* v3_utl.c */
2/* Written by Dr Stephen N Henson (shenson@bigfoot.com) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project. 3 * project.
4 */ 4 */
5/* ==================================================================== 5/* ====================================================================
@@ -736,17 +736,20 @@ static int ipv6_from_asc(unsigned char *v6, const char *in)
736 736
737 /* Format result */ 737 /* Format result */
738 738
739 /* Copy initial part */ 739 if (v6stat.zero_pos >= 0)
740 if (v6stat.zero_pos > 0) 740 {
741 /* Copy initial part */
741 memcpy(v6, v6stat.tmp, v6stat.zero_pos); 742 memcpy(v6, v6stat.tmp, v6stat.zero_pos);
742 /* Zero middle */ 743 /* Zero middle */
743 if (v6stat.total != 16)
744 memset(v6 + v6stat.zero_pos, 0, 16 - v6stat.total); 744 memset(v6 + v6stat.zero_pos, 0, 16 - v6stat.total);
745 /* Copy final part */ 745 /* Copy final part */
746 if (v6stat.total != v6stat.zero_pos) 746 if (v6stat.total != v6stat.zero_pos)
747 memcpy(v6 + v6stat.zero_pos + 16 - v6stat.total, 747 memcpy(v6 + v6stat.zero_pos + 16 - v6stat.total,
748 v6stat.tmp + v6stat.zero_pos, 748 v6stat.tmp + v6stat.zero_pos,
749 v6stat.total - v6stat.zero_pos); 749 v6stat.total - v6stat.zero_pos);
750 }
751 else
752 memcpy(v6, v6stat.tmp, 16);
750 753
751 return 1; 754 return 1;
752 } 755 }
diff --git a/src/lib/libcrypto/x509v3/v3conf.c b/src/lib/libcrypto/x509v3/v3conf.c
index 00cf5b4a5b..a9e6ca3542 100644
--- a/src/lib/libcrypto/x509v3/v3conf.c
+++ b/src/lib/libcrypto/x509v3/v3conf.c
@@ -1,5 +1,5 @@
1/* v3conf.c */ 1/* v3conf.c */
2/* Written by Dr Stephen N Henson (shenson@bigfoot.com) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 1999. 3 * project 1999.
4 */ 4 */
5/* ==================================================================== 5/* ====================================================================
diff --git a/src/lib/libcrypto/x509v3/v3prin.c b/src/lib/libcrypto/x509v3/v3prin.c
index b529814319..d5ff268296 100644
--- a/src/lib/libcrypto/x509v3/v3prin.c
+++ b/src/lib/libcrypto/x509v3/v3prin.c
@@ -1,5 +1,5 @@
1/* v3prin.c */ 1/* v3prin.c */
2/* Written by Dr Stephen N Henson (shenson@bigfoot.com) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 1999. 3 * project 1999.
4 */ 4 */
5/* ==================================================================== 5/* ====================================================================
diff --git a/src/lib/libcrypto/x509v3/x509v3.h b/src/lib/libcrypto/x509v3/x509v3.h
index 5ba59f71c9..9ef83da755 100644
--- a/src/lib/libcrypto/x509v3/x509v3.h
+++ b/src/lib/libcrypto/x509v3/x509v3.h
@@ -1,5 +1,5 @@
1/* x509v3.h */ 1/* x509v3.h */
2/* Written by Dr Stephen N Henson (shenson@bigfoot.com) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 1999. 3 * project 1999.
4 */ 4 */
5/* ==================================================================== 5/* ====================================================================