summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libcrypto')
-rw-r--r--src/lib/libcrypto/Makefile.ssl12
-rw-r--r--src/lib/libcrypto/aes/Makefile.ssl2
-rw-r--r--src/lib/libcrypto/aes/aes.h9
-rw-r--r--src/lib/libcrypto/aes/aes_cbc.c58
-rw-r--r--src/lib/libcrypto/aes/aes_cfb.c6
-rw-r--r--src/lib/libcrypto/aes/aes_core.c12
-rw-r--r--src/lib/libcrypto/aes/aes_ctr.c21
-rw-r--r--src/lib/libcrypto/aes/aes_ecb.c6
-rw-r--r--src/lib/libcrypto/aes/aes_locl.h2
-rw-r--r--src/lib/libcrypto/aes/aes_ofb.c6
-rw-r--r--src/lib/libcrypto/asn1/Makefile.ssl19
-rw-r--r--src/lib/libcrypto/asn1/a_bitstr.c4
-rw-r--r--src/lib/libcrypto/asn1/a_bytes.c2
-rw-r--r--src/lib/libcrypto/asn1/a_d2i_fp.c24
-rw-r--r--src/lib/libcrypto/asn1/a_object.c4
-rw-r--r--src/lib/libcrypto/asn1/a_sign.c8
-rw-r--r--src/lib/libcrypto/asn1/a_strex.c14
-rw-r--r--src/lib/libcrypto/asn1/a_strnid.c35
-rw-r--r--src/lib/libcrypto/asn1/a_time.c3
-rw-r--r--src/lib/libcrypto/asn1/a_type.c2
-rw-r--r--src/lib/libcrypto/asn1/a_verify.c4
-rw-r--r--src/lib/libcrypto/asn1/asn1.h5
-rw-r--r--src/lib/libcrypto/asn1/asn1_err.c4
-rw-r--r--src/lib/libcrypto/asn1/asn1_par.c7
-rw-r--r--src/lib/libcrypto/asn1/f_int.c3
-rw-r--r--src/lib/libcrypto/asn1/n_pkey.c6
-rw-r--r--src/lib/libcrypto/asn1/p8_pkey.c4
-rw-r--r--src/lib/libcrypto/asn1/t_crl.c7
-rw-r--r--src/lib/libcrypto/asn1/t_pkey.c32
-rw-r--r--src/lib/libcrypto/asn1/t_req.c19
-rw-r--r--src/lib/libcrypto/asn1/t_x509.c9
-rw-r--r--src/lib/libcrypto/asn1/t_x509a.c4
-rw-r--r--src/lib/libcrypto/asn1/tasn_dec.c4
-rw-r--r--src/lib/libcrypto/asn1/tasn_fre.c5
-rw-r--r--src/lib/libcrypto/asn1/tasn_new.c5
-rw-r--r--src/lib/libcrypto/asn1/tasn_prn.c2
-rw-r--r--src/lib/libcrypto/bf/Makefile.ssl14
-rw-r--r--src/lib/libcrypto/bf/bftest.c10
-rw-r--r--src/lib/libcrypto/bio/Makefile.ssl2
-rw-r--r--src/lib/libcrypto/bio/b_print.c29
-rw-r--r--src/lib/libcrypto/bio/b_sock.c16
-rw-r--r--src/lib/libcrypto/bio/bf_buff.c2
-rw-r--r--src/lib/libcrypto/bio/bio.h7
-rw-r--r--src/lib/libcrypto/bio/bio_lib.c15
-rw-r--r--src/lib/libcrypto/bio/bss_bio.c3
-rw-r--r--src/lib/libcrypto/bio/bss_conn.c4
-rw-r--r--src/lib/libcrypto/bio/bss_file.c2
-rw-r--r--src/lib/libcrypto/bio/bss_log.c13
-rw-r--r--src/lib/libcrypto/bio/bss_mem.c8
-rw-r--r--src/lib/libcrypto/bio/bss_sock.c6
-rw-r--r--src/lib/libcrypto/bn/Makefile.ssl33
-rw-r--r--src/lib/libcrypto/bn/asm/ia64.S235
-rw-r--r--src/lib/libcrypto/bn/asm/pa-risc2.s36
-rw-r--r--src/lib/libcrypto/bn/asm/vms.mar254
-rw-r--r--src/lib/libcrypto/bn/bn.h2
-rw-r--r--src/lib/libcrypto/bn/bn_div.c28
-rw-r--r--src/lib/libcrypto/bn/bn_lcl.h26
-rw-r--r--src/lib/libcrypto/bn/bn_lib.c4
-rw-r--r--src/lib/libcrypto/bn/bn_mul.c529
-rw-r--r--src/lib/libcrypto/bn/bn_prime.c2
-rw-r--r--src/lib/libcrypto/bn/bn_rand.c2
-rw-r--r--src/lib/libcrypto/bn/bn_word.c5
-rw-r--r--src/lib/libcrypto/bn/bntest.c23
-rw-r--r--src/lib/libcrypto/bn/divtest.c6
-rw-r--r--src/lib/libcrypto/bn/exptest.c22
-rw-r--r--src/lib/libcrypto/buffer/Makefile.ssl2
-rw-r--r--src/lib/libcrypto/buffer/buffer.c57
-rw-r--r--src/lib/libcrypto/buffer/buffer.h9
-rw-r--r--src/lib/libcrypto/cast/Makefile.ssl14
-rw-r--r--src/lib/libcrypto/cast/casttest.c4
-rw-r--r--src/lib/libcrypto/comp/Makefile.ssl2
-rw-r--r--src/lib/libcrypto/comp/c_zlib.c4
-rw-r--r--src/lib/libcrypto/conf/Makefile.ssl2
-rw-r--r--src/lib/libcrypto/conf/conf_def.c18
-rw-r--r--src/lib/libcrypto/conf/conf_mall.c4
-rw-r--r--src/lib/libcrypto/conf/conf_sap.c4
-rw-r--r--src/lib/libcrypto/cryptlib.c40
-rw-r--r--src/lib/libcrypto/cryptlib.h6
-rw-r--r--src/lib/libcrypto/crypto-lib.com344
-rw-r--r--src/lib/libcrypto/crypto.h65
-rw-r--r--src/lib/libcrypto/des/Makefile.ssl23
-rw-r--r--src/lib/libcrypto/des/asm/crypt586.pl46
-rw-r--r--src/lib/libcrypto/des/asm/des-586.pl50
-rw-r--r--src/lib/libcrypto/des/cbc_cksm.c9
-rw-r--r--src/lib/libcrypto/des/des.c32
-rw-r--r--src/lib/libcrypto/des/des_locl.h13
-rw-r--r--src/lib/libcrypto/des/des_old.h2
-rw-r--r--src/lib/libcrypto/des/des_ver.h8
-rw-r--r--src/lib/libcrypto/des/destest.c6
-rw-r--r--src/lib/libcrypto/des/read2pwd.c8
-rw-r--r--src/lib/libcrypto/des/read_pwd.c44
-rw-r--r--src/lib/libcrypto/des/str2key.c4
-rw-r--r--src/lib/libcrypto/dh/Makefile.ssl19
-rw-r--r--src/lib/libcrypto/dh/dh_key.c1
-rw-r--r--src/lib/libcrypto/dh/dh_lib.c10
-rw-r--r--src/lib/libcrypto/dh/dhtest.c14
-rw-r--r--src/lib/libcrypto/doc/DH_generate_parameters.pod3
-rw-r--r--src/lib/libcrypto/doc/DSA_SIG_new.pod3
-rw-r--r--src/lib/libcrypto/doc/DSA_generate_key.pod3
-rw-r--r--src/lib/libcrypto/doc/ERR_get_error.pod2
-rw-r--r--src/lib/libcrypto/doc/EVP_EncryptInit.pod2
-rw-r--r--src/lib/libcrypto/doc/EVP_SealInit.pod26
-rw-r--r--src/lib/libcrypto/doc/RAND_bytes.pod3
-rw-r--r--src/lib/libcrypto/doc/RSA_generate_key.pod3
-rw-r--r--src/lib/libcrypto/doc/RSA_print.pod6
-rw-r--r--src/lib/libcrypto/doc/RSA_private_encrypt.pod4
-rw-r--r--src/lib/libcrypto/doc/RSA_public_encrypt.pod3
-rw-r--r--src/lib/libcrypto/doc/RSA_set_method.pod13
-rw-r--r--src/lib/libcrypto/doc/RSA_sign_ASN1_OCTET_STRING.pod4
-rw-r--r--src/lib/libcrypto/doc/d2i_DHparams.pod14
-rw-r--r--src/lib/libcrypto/doc/d2i_RSAPublicKey.pod39
-rw-r--r--src/lib/libcrypto/dsa/Makefile.ssl32
-rw-r--r--src/lib/libcrypto/dsa/dsa_lib.c15
-rw-r--r--src/lib/libcrypto/dsa/dsa_ossl.c14
-rw-r--r--src/lib/libcrypto/dsa/dsa_sign.c1
-rw-r--r--src/lib/libcrypto/dsa/dsa_vrf.c1
-rw-r--r--src/lib/libcrypto/dsa/dsagen.c2
-rw-r--r--src/lib/libcrypto/dsa/dsatest.c17
-rw-r--r--src/lib/libcrypto/dso/Makefile.ssl2
-rw-r--r--src/lib/libcrypto/dso/dso_dl.c2
-rw-r--r--src/lib/libcrypto/dso/dso_win32.c2
-rw-r--r--src/lib/libcrypto/ec/Makefile.ssl2
-rw-r--r--src/lib/libcrypto/ec/ec.h2
-rw-r--r--src/lib/libcrypto/ec/ec_err.c2
-rw-r--r--src/lib/libcrypto/ec/ec_lib.c8
-rw-r--r--src/lib/libcrypto/ec/ec_mult.c11
-rw-r--r--src/lib/libcrypto/ec/ectest.c11
-rw-r--r--src/lib/libcrypto/engine/Makefile.ssl64
-rw-r--r--src/lib/libcrypto/engine/eng_all.c18
-rw-r--r--src/lib/libcrypto/engine/eng_err.c3
-rw-r--r--src/lib/libcrypto/engine/eng_fat.c8
-rw-r--r--src/lib/libcrypto/engine/eng_list.c33
-rw-r--r--src/lib/libcrypto/engine/eng_openssl.c18
-rw-r--r--src/lib/libcrypto/engine/engine.h13
-rw-r--r--src/lib/libcrypto/engine/enginetest.c11
-rw-r--r--src/lib/libcrypto/engine/hw_4758_cca.c6
-rw-r--r--src/lib/libcrypto/engine/hw_atalla.c2
-rw-r--r--src/lib/libcrypto/engine/hw_cryptodev.c43
-rw-r--r--src/lib/libcrypto/engine/hw_cswift.c73
-rw-r--r--src/lib/libcrypto/engine/hw_ncipher.c68
-rw-r--r--src/lib/libcrypto/engine/hw_ncipher_err.c3
-rw-r--r--src/lib/libcrypto/engine/hw_ncipher_err.h1
-rw-r--r--src/lib/libcrypto/engine/hw_nuron.c2
-rw-r--r--src/lib/libcrypto/engine/hw_ubsec.c2
-rw-r--r--src/lib/libcrypto/engine/tb_cipher.c4
-rw-r--r--src/lib/libcrypto/engine/tb_dh.c4
-rw-r--r--src/lib/libcrypto/engine/tb_digest.c4
-rw-r--r--src/lib/libcrypto/engine/tb_dsa.c4
-rw-r--r--src/lib/libcrypto/engine/tb_rand.c4
-rw-r--r--src/lib/libcrypto/engine/tb_rsa.c4
-rw-r--r--src/lib/libcrypto/err/Makefile.ssl2
-rw-r--r--src/lib/libcrypto/err/err.c2
-rw-r--r--src/lib/libcrypto/err/err_all.c4
-rw-r--r--src/lib/libcrypto/err/err_prn.c1
-rw-r--r--src/lib/libcrypto/evp/Makefile.ssl30
-rw-r--r--src/lib/libcrypto/evp/bio_b64.c1
-rw-r--r--src/lib/libcrypto/evp/bio_enc.c9
-rw-r--r--src/lib/libcrypto/evp/bio_ok.c2
-rw-r--r--src/lib/libcrypto/evp/c_all.c6
-rw-r--r--src/lib/libcrypto/evp/digest.c17
-rw-r--r--src/lib/libcrypto/evp/e_aes.c1
-rw-r--r--src/lib/libcrypto/evp/e_idea.c2
-rw-r--r--src/lib/libcrypto/evp/e_rc2.c1
-rw-r--r--src/lib/libcrypto/evp/e_rc4.c5
-rw-r--r--src/lib/libcrypto/evp/encode.c2
-rw-r--r--src/lib/libcrypto/evp/evp_acnf.c1
-rw-r--r--src/lib/libcrypto/evp/evp_enc.c30
-rw-r--r--src/lib/libcrypto/evp/evp_key.c6
-rw-r--r--src/lib/libcrypto/evp/evp_lib.c2
-rw-r--r--src/lib/libcrypto/evp/evp_pbe.c2
-rw-r--r--src/lib/libcrypto/evp/evp_test.c58
-rw-r--r--src/lib/libcrypto/evp/p5_crpt.c8
-rw-r--r--src/lib/libcrypto/evp/p5_crpt2.c3
-rw-r--r--src/lib/libcrypto/evp/p_open.c2
-rw-r--r--src/lib/libcrypto/hmac/Makefile.ssl36
-rw-r--r--src/lib/libcrypto/hmac/hmac.c3
-rw-r--r--src/lib/libcrypto/hmac/hmactest.c21
-rw-r--r--src/lib/libcrypto/idea/Makefile.ssl2
-rw-r--r--src/lib/libcrypto/krb5/Makefile.ssl4
-rw-r--r--src/lib/libcrypto/lhash/Makefile.ssl2
-rw-r--r--src/lib/libcrypto/lhash/lh_stats.c101
-rw-r--r--src/lib/libcrypto/md2/Makefile.ssl7
-rw-r--r--src/lib/libcrypto/md2/md2_dgst.c9
-rw-r--r--src/lib/libcrypto/md2/md2_one.c2
-rw-r--r--src/lib/libcrypto/md2/md2test.c5
-rw-r--r--src/lib/libcrypto/md32_common.h38
-rw-r--r--src/lib/libcrypto/md4/Makefile.ssl9
-rw-r--r--src/lib/libcrypto/md4/md4.c4
-rw-r--r--src/lib/libcrypto/md4/md4_dgst.c36
-rw-r--r--src/lib/libcrypto/md4/md4_one.c3
-rw-r--r--src/lib/libcrypto/md4/md4test.c4
-rw-r--r--src/lib/libcrypto/md5/Makefile.ssl31
-rw-r--r--src/lib/libcrypto/md5/md5.c2
-rw-r--r--src/lib/libcrypto/md5/md5.h4
-rw-r--r--src/lib/libcrypto/md5/md5_dgst.c36
-rw-r--r--src/lib/libcrypto/md5/md5_locl.h2
-rw-r--r--src/lib/libcrypto/md5/md5_one.c3
-rw-r--r--src/lib/libcrypto/md5/md5test.c4
-rw-r--r--src/lib/libcrypto/mdc2/Makefile.ssl2
-rw-r--r--src/lib/libcrypto/mem.c45
-rw-r--r--src/lib/libcrypto/mem_dbg.c24
-rw-r--r--src/lib/libcrypto/o_time.c3
-rw-r--r--src/lib/libcrypto/objects/Makefile.ssl2
-rw-r--r--src/lib/libcrypto/objects/obj_dat.c7
-rw-r--r--src/lib/libcrypto/objects/obj_mac.num2
-rw-r--r--src/lib/libcrypto/objects/objects.txt6
-rw-r--r--src/lib/libcrypto/ocsp/Makefile.ssl4
-rw-r--r--src/lib/libcrypto/ocsp/ocsp_asn.c2
-rw-r--r--src/lib/libcrypto/ocsp/ocsp_ht.c19
-rw-r--r--src/lib/libcrypto/opensslconf.h.in2
-rw-r--r--src/lib/libcrypto/opensslv.h4
-rw-r--r--src/lib/libcrypto/ossl_typ.h2
-rw-r--r--src/lib/libcrypto/pem/Makefile.ssl2
-rw-r--r--src/lib/libcrypto/pem/pem.h8
-rw-r--r--src/lib/libcrypto/pem/pem_info.c5
-rw-r--r--src/lib/libcrypto/pem/pem_lib.c26
-rw-r--r--src/lib/libcrypto/pem/pem_pk8.c2
-rw-r--r--src/lib/libcrypto/pem/pem_seal.c2
-rw-r--r--src/lib/libcrypto/perlasm/cbc.pl41
-rw-r--r--src/lib/libcrypto/perlasm/x86asm.pl9
-rw-r--r--src/lib/libcrypto/perlasm/x86ms.pl15
-rw-r--r--src/lib/libcrypto/perlasm/x86nasm.pl15
-rw-r--r--src/lib/libcrypto/perlasm/x86unix.pl53
-rw-r--r--src/lib/libcrypto/pkcs12/Makefile.ssl2
-rw-r--r--src/lib/libcrypto/pkcs12/p12_crpt.c4
-rw-r--r--src/lib/libcrypto/pkcs12/p12_decr.c4
-rw-r--r--src/lib/libcrypto/pkcs12/p12_key.c2
-rw-r--r--src/lib/libcrypto/pkcs12/p12_npas.c2
-rw-r--r--src/lib/libcrypto/pkcs7/Makefile.ssl2
-rw-r--r--src/lib/libcrypto/pkcs7/bio_ber.c2
-rw-r--r--src/lib/libcrypto/pkcs7/pk7_doit.c6
-rw-r--r--src/lib/libcrypto/rand/Makefile.ssl2
-rw-r--r--src/lib/libcrypto/rand/md_rand.c4
-rw-r--r--src/lib/libcrypto/rand/rand.h2
-rw-r--r--src/lib/libcrypto/rand/rand_egd.c6
-rw-r--r--src/lib/libcrypto/rand/rand_lib.c10
-rw-r--r--src/lib/libcrypto/rand/rand_unix.c11
-rw-r--r--src/lib/libcrypto/rand/rand_win.c84
-rw-r--r--src/lib/libcrypto/rand/randfile.c8
-rw-r--r--src/lib/libcrypto/rand/randtest.c4
-rw-r--r--src/lib/libcrypto/rc2/Makefile.ssl2
-rw-r--r--src/lib/libcrypto/rc2/rc2test.c4
-rw-r--r--src/lib/libcrypto/rc4/Makefile.ssl14
-rw-r--r--src/lib/libcrypto/rc4/rc4.c4
-rw-r--r--src/lib/libcrypto/rc4/rc4test.c4
-rw-r--r--src/lib/libcrypto/rc5/Makefile.ssl14
-rw-r--r--src/lib/libcrypto/ripemd/Makefile.ssl21
-rw-r--r--src/lib/libcrypto/ripemd/rmd160.c2
-rw-r--r--src/lib/libcrypto/ripemd/rmd_dgst.c12
-rw-r--r--src/lib/libcrypto/ripemd/rmd_one.c3
-rw-r--r--src/lib/libcrypto/ripemd/rmdtest.c4
-rw-r--r--src/lib/libcrypto/rsa/Makefile.ssl44
-rw-r--r--src/lib/libcrypto/rsa/rsa.h9
-rw-r--r--src/lib/libcrypto/rsa/rsa_eay.c131
-rw-r--r--src/lib/libcrypto/rsa/rsa_lib.c43
-rw-r--r--src/lib/libcrypto/rsa/rsa_pk1.c2
-rw-r--r--src/lib/libcrypto/rsa/rsa_saos.c6
-rw-r--r--src/lib/libcrypto/rsa/rsa_sign.c25
-rw-r--r--src/lib/libcrypto/rsa/rsa_test.c1
-rw-r--r--src/lib/libcrypto/sha/Makefile.ssl28
-rw-r--r--src/lib/libcrypto/sha/sha1_one.c3
-rw-r--r--src/lib/libcrypto/sha/sha1test.c4
-rw-r--r--src/lib/libcrypto/sha/sha_locl.h12
-rw-r--r--src/lib/libcrypto/sha/sha_one.c3
-rw-r--r--src/lib/libcrypto/sha/shatest.c4
-rw-r--r--src/lib/libcrypto/stack/Makefile.ssl2
-rw-r--r--src/lib/libcrypto/threads/mttest.c5
-rw-r--r--src/lib/libcrypto/tmdiff.c32
-rw-r--r--src/lib/libcrypto/txt_db/Makefile.ssl2
-rw-r--r--src/lib/libcrypto/txt_db/txt_db.c4
-rw-r--r--src/lib/libcrypto/ui/Makefile.ssl18
-rw-r--r--src/lib/libcrypto/ui/ui_lib.c10
-rw-r--r--src/lib/libcrypto/ui/ui_openssl.c26
-rw-r--r--src/lib/libcrypto/ui/ui_util.c8
-rw-r--r--src/lib/libcrypto/uid.c2
-rw-r--r--src/lib/libcrypto/util/cygwin.sh2
-rw-r--r--src/lib/libcrypto/util/domd7
-rw-r--r--src/lib/libcrypto/util/libeay.num226
-rw-r--r--src/lib/libcrypto/util/mk1mf.pl33
-rw-r--r--src/lib/libcrypto/util/mkdef.pl25
-rw-r--r--src/lib/libcrypto/util/mkerr.pl16
-rw-r--r--src/lib/libcrypto/util/pl/BC-32.pl4
-rw-r--r--src/lib/libcrypto/util/pl/Mingw32.pl34
-rw-r--r--src/lib/libcrypto/util/pl/VC-32.pl2
-rw-r--r--src/lib/libcrypto/util/ssleay.num2
-rw-r--r--src/lib/libcrypto/x509/Makefile.ssl2
-rw-r--r--src/lib/libcrypto/x509/by_file.c20
-rw-r--r--src/lib/libcrypto/x509/x509.h3
-rw-r--r--src/lib/libcrypto/x509/x509_cmp.c119
-rw-r--r--src/lib/libcrypto/x509/x509_v3.c2
-rw-r--r--src/lib/libcrypto/x509/x509_vfy.c2
-rw-r--r--src/lib/libcrypto/x509v3/Makefile.ssl2
-rw-r--r--src/lib/libcrypto/x509v3/ext_dat.h6
-rw-r--r--src/lib/libcrypto/x509v3/v3_info.c4
-rw-r--r--src/lib/libcrypto/x509v3/v3_ocsp.c3
-rw-r--r--src/lib/libcrypto/x509v3/v3_prn.c2
-rw-r--r--src/lib/libcrypto/x509v3/v3_purp.c4
-rw-r--r--src/lib/libcrypto/x509v3/v3_utl.c2
-rw-r--r--src/lib/libcrypto/x509v3/v3conf.c2
-rw-r--r--src/lib/libcrypto/x509v3/x509v3.h1
300 files changed, 2951 insertions, 2319 deletions
diff --git a/src/lib/libcrypto/Makefile.ssl b/src/lib/libcrypto/Makefile.ssl
index db8baf385e..3071e3cb86 100644
--- a/src/lib/libcrypto/Makefile.ssl
+++ b/src/lib/libcrypto/Makefile.ssl
@@ -36,8 +36,8 @@ GENERAL=Makefile README crypto-lib.com install.com
36 36
37LIB= $(TOP)/libcrypto.a 37LIB= $(TOP)/libcrypto.a
38SHARED_LIB= libcrypto$(SHLIB_EXT) 38SHARED_LIB= libcrypto$(SHLIB_EXT)
39LIBSRC= cryptlib.c mem.c mem_dbg.c cversion.c ex_data.c tmdiff.c cpt_err.c ebcdic.c uid.c o_time.c 39LIBSRC= cryptlib.c mem.c mem_clr.c mem_dbg.c cversion.c ex_data.c tmdiff.c cpt_err.c ebcdic.c uid.c o_time.c
40LIBOBJ= cryptlib.o mem.o mem_dbg.o cversion.o ex_data.o tmdiff.o cpt_err.o ebcdic.o uid.o o_time.o 40LIBOBJ= cryptlib.o mem.o mem_clr.o mem_dbg.o cversion.o ex_data.o tmdiff.o cpt_err.o ebcdic.o uid.o o_time.o
41 41
42SRC= $(LIBSRC) 42SRC= $(LIBSRC)
43 43
@@ -136,12 +136,12 @@ lint:
136 136
137depend: 137depend:
138 if [ ! -f buildinf.h ]; then touch buildinf.h; fi # fake buildinf.h if it does not exist 138 if [ ! -f buildinf.h ]; then touch buildinf.h; fi # fake buildinf.h if it does not exist
139 $(MAKEDEPEND) $(CFLAG) $(INCLUDE) $(DEPFLAG) $(PROGS) $(LIBSRC) 139 $(MAKEDEPEND) -- $(CFLAG) $(INCLUDE) $(DEPFLAG) -- $(PROGS) $(LIBSRC)
140 if [ ! -s buildinf.h ]; then rm buildinf.h; fi 140 if [ ! -s buildinf.h ]; then rm buildinf.h; fi
141 @for i in $(SDIRS) ;\ 141 @for i in $(SDIRS) ;\
142 do \ 142 do \
143 (cd $$i && echo "making depend in crypto/$$i..." && \ 143 (cd $$i && echo "making depend in crypto/$$i..." && \
144 $(MAKE) MAKEFILE='${MAKEFILE}' INCLUDES='${INCLUDES}' CFLAG='${CFLAG}' DEPFLAG='${DEPFLAG}' PERL='${PERL}' depend ); \ 144 $(MAKE) MAKEFILE='${MAKEFILE}' INCLUDES='${INCLUDES}' CFLAG='${CFLAG}' DEPFLAG='${DEPFLAG}' MAKEDEPPROG='${MAKEDEPPROG}' KRB5_INCLUDES='${KRB5_INCLUDES}' PERL='${PERL}' depend ); \
145 done; 145 done;
146 146
147clean: 147clean:
@@ -193,6 +193,10 @@ mem.o: ../include/openssl/err.h ../include/openssl/lhash.h
193mem.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h 193mem.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h
194mem.o: ../include/openssl/safestack.h ../include/openssl/stack.h 194mem.o: ../include/openssl/safestack.h ../include/openssl/stack.h
195mem.o: ../include/openssl/symhacks.h cryptlib.h mem.c 195mem.o: ../include/openssl/symhacks.h cryptlib.h mem.c
196mem_clr.o: ../include/openssl/crypto.h ../include/openssl/e_os2.h
197mem_clr.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h
198mem_clr.o: ../include/openssl/safestack.h ../include/openssl/stack.h
199mem_clr.o: ../include/openssl/symhacks.h mem_clr.c
196mem_dbg.o: ../e_os.h ../include/openssl/bio.h ../include/openssl/buffer.h 200mem_dbg.o: ../e_os.h ../include/openssl/bio.h ../include/openssl/buffer.h
197mem_dbg.o: ../include/openssl/crypto.h ../include/openssl/e_os2.h 201mem_dbg.o: ../include/openssl/crypto.h ../include/openssl/e_os2.h
198mem_dbg.o: ../include/openssl/err.h ../include/openssl/lhash.h 202mem_dbg.o: ../include/openssl/err.h ../include/openssl/lhash.h
diff --git a/src/lib/libcrypto/aes/Makefile.ssl b/src/lib/libcrypto/aes/Makefile.ssl
index 9358802a2e..f353aeb697 100644
--- a/src/lib/libcrypto/aes/Makefile.ssl
+++ b/src/lib/libcrypto/aes/Makefile.ssl
@@ -75,7 +75,7 @@ lint:
75 lint -DLINT $(INCLUDES) $(SRC)>fluff 75 lint -DLINT $(INCLUDES) $(SRC)>fluff
76 76
77depend: 77depend:
78 $(MAKEDEPEND) $(CFLAG) $(INCLUDES) $(DEPFLAG) $(PROGS) $(LIBSRC) 78 $(MAKEDEPEND) -- $(CFLAG) $(INCLUDES) $(DEPFLAG) -- $(PROGS) $(LIBSRC)
79 79
80dclean: 80dclean:
81 $(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new 81 $(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
diff --git a/src/lib/libcrypto/aes/aes.h b/src/lib/libcrypto/aes/aes.h
index e8da921ec5..8294a41a3a 100644
--- a/src/lib/libcrypto/aes/aes.h
+++ b/src/lib/libcrypto/aes/aes.h
@@ -56,8 +56,9 @@
56#error AES is disabled. 56#error AES is disabled.
57#endif 57#endif
58 58
59static const int AES_DECRYPT = 0; 59#define AES_ENCRYPT 1
60static const int AES_ENCRYPT = 1; 60#define AES_DECRYPT 0
61
61/* Because array size can't be a const in C, the following two are macros. 62/* Because array size can't be a const in C, the following two are macros.
62 Both sizes are in bytes. */ 63 Both sizes are in bytes. */
63#define AES_MAXNR 14 64#define AES_MAXNR 14
@@ -99,7 +100,9 @@ void AES_ofb128_encrypt(const unsigned char *in, unsigned char *out,
99 unsigned char *ivec, int *num); 100 unsigned char *ivec, int *num);
100void AES_ctr128_encrypt(const unsigned char *in, unsigned char *out, 101void AES_ctr128_encrypt(const unsigned char *in, unsigned char *out,
101 const unsigned long length, const AES_KEY *key, 102 const unsigned long length, const AES_KEY *key,
102 unsigned char *counter, unsigned int *num); 103 unsigned char counter[AES_BLOCK_SIZE],
104 unsigned char ecount_buf[AES_BLOCK_SIZE],
105 unsigned int *num);
103 106
104 107
105#ifdef __cplusplus 108#ifdef __cplusplus
diff --git a/src/lib/libcrypto/aes/aes_cbc.c b/src/lib/libcrypto/aes/aes_cbc.c
index 3dfd7aba2a..de438306b1 100644
--- a/src/lib/libcrypto/aes/aes_cbc.c
+++ b/src/lib/libcrypto/aes/aes_cbc.c
@@ -49,7 +49,13 @@
49 * 49 *
50 */ 50 */
51 51
52#ifndef AES_DEBUG
53# ifndef NDEBUG
54# define NDEBUG
55# endif
56#endif
52#include <assert.h> 57#include <assert.h>
58
53#include <openssl/aes.h> 59#include <openssl/aes.h>
54#include "aes_locl.h" 60#include "aes_locl.h"
55 61
@@ -57,33 +63,49 @@ void AES_cbc_encrypt(const unsigned char *in, unsigned char *out,
57 const unsigned long length, const AES_KEY *key, 63 const unsigned long length, const AES_KEY *key,
58 unsigned char *ivec, const int enc) { 64 unsigned char *ivec, const int enc) {
59 65
60 int n; 66 unsigned long n;
61 unsigned long len = length; 67 unsigned long len = length;
62 unsigned char tmp[16]; 68 unsigned char tmp[AES_BLOCK_SIZE];
63 69
64 assert(in && out && key && ivec); 70 assert(in && out && key && ivec);
65 assert(length % AES_BLOCK_SIZE == 0);
66 assert((AES_ENCRYPT == enc)||(AES_DECRYPT == enc)); 71 assert((AES_ENCRYPT == enc)||(AES_DECRYPT == enc));
67 72
68 if (AES_ENCRYPT == enc) 73 if (AES_ENCRYPT == enc) {
69 while (len > 0) { 74 while (len >= AES_BLOCK_SIZE) {
70 for(n=0; n < 16; ++n) 75 for(n=0; n < sizeof tmp; ++n)
71 tmp[n] = in[n] ^ ivec[n]; 76 tmp[n] = in[n] ^ ivec[n];
72 AES_encrypt(tmp, out, key); 77 AES_encrypt(tmp, out, key);
73 memcpy(ivec, out, 16); 78 memcpy(ivec, out, AES_BLOCK_SIZE);
74 len -= 16; 79 len -= AES_BLOCK_SIZE;
75 in += 16; 80 in += AES_BLOCK_SIZE;
76 out += 16; 81 out += AES_BLOCK_SIZE;
77 } 82 }
78 else 83 if (len) {
79 while (len > 0) { 84 for(n=0; n < len; ++n)
80 memcpy(tmp, in, 16); 85 tmp[n] = in[n] ^ ivec[n];
86 for(n=len; n < AES_BLOCK_SIZE; ++n)
87 tmp[n] = ivec[n];
88 AES_encrypt(tmp, tmp, key);
89 memcpy(out, tmp, len);
90 memcpy(ivec, tmp, sizeof tmp);
91 }
92 } else {
93 while (len >= AES_BLOCK_SIZE) {
94 memcpy(tmp, in, sizeof tmp);
81 AES_decrypt(in, out, key); 95 AES_decrypt(in, out, key);
82 for(n=0; n < 16; ++n) 96 for(n=0; n < AES_BLOCK_SIZE; ++n)
83 out[n] ^= ivec[n]; 97 out[n] ^= ivec[n];
84 memcpy(ivec, tmp, 16); 98 memcpy(ivec, tmp, AES_BLOCK_SIZE);
85 len -= 16; 99 len -= AES_BLOCK_SIZE;
86 in += 16; 100 in += AES_BLOCK_SIZE;
87 out += 16; 101 out += AES_BLOCK_SIZE;
88 } 102 }
103 if (len) {
104 memcpy(tmp, in, sizeof tmp);
105 AES_decrypt(tmp, tmp, key);
106 for(n=0; n < len; ++n)
107 out[n] ^= ivec[n];
108 memcpy(ivec, tmp, sizeof tmp);
109 }
110 }
89} 111}
diff --git a/src/lib/libcrypto/aes/aes_cfb.c b/src/lib/libcrypto/aes/aes_cfb.c
index 41c2a5ec3d..9b569dda90 100644
--- a/src/lib/libcrypto/aes/aes_cfb.c
+++ b/src/lib/libcrypto/aes/aes_cfb.c
@@ -105,7 +105,13 @@
105 * [including the GNU Public Licence.] 105 * [including the GNU Public Licence.]
106 */ 106 */
107 107
108#ifndef AES_DEBUG
109# ifndef NDEBUG
110# define NDEBUG
111# endif
112#endif
108#include <assert.h> 113#include <assert.h>
114
109#include <openssl/aes.h> 115#include <openssl/aes.h>
110#include "aes_locl.h" 116#include "aes_locl.h"
111 117
diff --git a/src/lib/libcrypto/aes/aes_core.c b/src/lib/libcrypto/aes/aes_core.c
index 937988dd8c..2f41a825f8 100644
--- a/src/lib/libcrypto/aes/aes_core.c
+++ b/src/lib/libcrypto/aes/aes_core.c
@@ -28,7 +28,13 @@
28/* Note: rewritten a little bit to provide error control and an OpenSSL- 28/* Note: rewritten a little bit to provide error control and an OpenSSL-
29 compatible API */ 29 compatible API */
30 30
31#ifndef AES_DEBUG
32# ifndef NDEBUG
33# define NDEBUG
34# endif
35#endif
31#include <assert.h> 36#include <assert.h>
37
32#include <stdlib.h> 38#include <stdlib.h>
33#include <openssl/aes.h> 39#include <openssl/aes.h>
34#include "aes_locl.h" 40#include "aes_locl.h"
@@ -744,7 +750,7 @@ int AES_set_encrypt_key(const unsigned char *userKey, const int bits,
744 rk[2] = GETU32(userKey + 8); 750 rk[2] = GETU32(userKey + 8);
745 rk[3] = GETU32(userKey + 12); 751 rk[3] = GETU32(userKey + 12);
746 if (bits == 128) { 752 if (bits == 128) {
747 for (;;) { 753 while (1) {
748 temp = rk[3]; 754 temp = rk[3];
749 rk[4] = rk[0] ^ 755 rk[4] = rk[0] ^
750 (Te4[(temp >> 16) & 0xff] & 0xff000000) ^ 756 (Te4[(temp >> 16) & 0xff] & 0xff000000) ^
@@ -764,7 +770,7 @@ int AES_set_encrypt_key(const unsigned char *userKey, const int bits,
764 rk[4] = GETU32(userKey + 16); 770 rk[4] = GETU32(userKey + 16);
765 rk[5] = GETU32(userKey + 20); 771 rk[5] = GETU32(userKey + 20);
766 if (bits == 192) { 772 if (bits == 192) {
767 for (;;) { 773 while (1) {
768 temp = rk[ 5]; 774 temp = rk[ 5];
769 rk[ 6] = rk[ 0] ^ 775 rk[ 6] = rk[ 0] ^
770 (Te4[(temp >> 16) & 0xff] & 0xff000000) ^ 776 (Te4[(temp >> 16) & 0xff] & 0xff000000) ^
@@ -786,7 +792,7 @@ int AES_set_encrypt_key(const unsigned char *userKey, const int bits,
786 rk[6] = GETU32(userKey + 24); 792 rk[6] = GETU32(userKey + 24);
787 rk[7] = GETU32(userKey + 28); 793 rk[7] = GETU32(userKey + 28);
788 if (bits == 256) { 794 if (bits == 256) {
789 for (;;) { 795 while (1) {
790 temp = rk[ 7]; 796 temp = rk[ 7];
791 rk[ 8] = rk[ 0] ^ 797 rk[ 8] = rk[ 0] ^
792 (Te4[(temp >> 16) & 0xff] & 0xff000000) ^ 798 (Te4[(temp >> 16) & 0xff] & 0xff000000) ^
diff --git a/src/lib/libcrypto/aes/aes_ctr.c b/src/lib/libcrypto/aes/aes_ctr.c
index aea3db2092..59088499a0 100644
--- a/src/lib/libcrypto/aes/aes_ctr.c
+++ b/src/lib/libcrypto/aes/aes_ctr.c
@@ -49,7 +49,13 @@
49 * 49 *
50 */ 50 */
51 51
52#ifndef AES_DEBUG
53# ifndef NDEBUG
54# define NDEBUG
55# endif
56#endif
52#include <assert.h> 57#include <assert.h>
58
53#include <openssl/aes.h> 59#include <openssl/aes.h>
54#include "aes_locl.h" 60#include "aes_locl.h"
55 61
@@ -90,26 +96,31 @@ static void AES_ctr128_inc(unsigned char *counter) {
90 96
91/* The input encrypted as though 128bit counter mode is being 97/* The input encrypted as though 128bit counter mode is being
92 * used. The extra state information to record how much of the 98 * used. The extra state information to record how much of the
93 * 128bit block we have used is contained in *num; 99 * 128bit block we have used is contained in *num, and the
100 * encrypted counter is kept in ecount_buf. Both *num and
101 * ecount_buf must be initialised with zeros before the first
102 * call to AES_ctr128_encrypt().
94 */ 103 */
95void AES_ctr128_encrypt(const unsigned char *in, unsigned char *out, 104void AES_ctr128_encrypt(const unsigned char *in, unsigned char *out,
96 const unsigned long length, const AES_KEY *key, 105 const unsigned long length, const AES_KEY *key,
97 unsigned char *counter, unsigned int *num) { 106 unsigned char counter[AES_BLOCK_SIZE],
107 unsigned char ecount_buf[AES_BLOCK_SIZE],
108 unsigned int *num) {
98 109
99 unsigned int n; 110 unsigned int n;
100 unsigned long l=length; 111 unsigned long l=length;
101 unsigned char tmp[AES_BLOCK_SIZE];
102 112
103 assert(in && out && key && counter && num); 113 assert(in && out && key && counter && num);
114 assert(*num < AES_BLOCK_SIZE);
104 115
105 n = *num; 116 n = *num;
106 117
107 while (l--) { 118 while (l--) {
108 if (n == 0) { 119 if (n == 0) {
109 AES_encrypt(counter, tmp, key); 120 AES_encrypt(counter, ecount_buf, key);
110 AES_ctr128_inc(counter); 121 AES_ctr128_inc(counter);
111 } 122 }
112 *(out++) = *(in++) ^ tmp[n]; 123 *(out++) = *(in++) ^ ecount_buf[n];
113 n = (n+1) % AES_BLOCK_SIZE; 124 n = (n+1) % AES_BLOCK_SIZE;
114 } 125 }
115 126
diff --git a/src/lib/libcrypto/aes/aes_ecb.c b/src/lib/libcrypto/aes/aes_ecb.c
index 1cb2e07d3d..28aa561c2d 100644
--- a/src/lib/libcrypto/aes/aes_ecb.c
+++ b/src/lib/libcrypto/aes/aes_ecb.c
@@ -49,7 +49,13 @@
49 * 49 *
50 */ 50 */
51 51
52#ifndef AES_DEBUG
53# ifndef NDEBUG
54# define NDEBUG
55# endif
56#endif
52#include <assert.h> 57#include <assert.h>
58
53#include <openssl/aes.h> 59#include <openssl/aes.h>
54#include "aes_locl.h" 60#include "aes_locl.h"
55 61
diff --git a/src/lib/libcrypto/aes/aes_locl.h b/src/lib/libcrypto/aes/aes_locl.h
index 18fc2d0747..f290946058 100644
--- a/src/lib/libcrypto/aes/aes_locl.h
+++ b/src/lib/libcrypto/aes/aes_locl.h
@@ -62,7 +62,7 @@
62#include <stdlib.h> 62#include <stdlib.h>
63#include <string.h> 63#include <string.h>
64 64
65#ifdef _MSC_VER 65#if defined(_MSC_VER) && !defined(OPENSSL_SYS_WINCE)
66# define SWAP(x) (_lrotl(x, 8) & 0x00ff00ff | _lrotr(x, 8) & 0xff00ff00) 66# define SWAP(x) (_lrotl(x, 8) & 0x00ff00ff | _lrotr(x, 8) & 0xff00ff00)
67# define GETU32(p) SWAP(*((u32 *)(p))) 67# define GETU32(p) SWAP(*((u32 *)(p)))
68# define PUTU32(ct, st) { *((u32 *)(ct)) = SWAP((st)); } 68# define PUTU32(ct, st) { *((u32 *)(ct)) = SWAP((st)); }
diff --git a/src/lib/libcrypto/aes/aes_ofb.c b/src/lib/libcrypto/aes/aes_ofb.c
index e33bdaea28..f358bb39e2 100644
--- a/src/lib/libcrypto/aes/aes_ofb.c
+++ b/src/lib/libcrypto/aes/aes_ofb.c
@@ -105,7 +105,13 @@
105 * [including the GNU Public Licence.] 105 * [including the GNU Public Licence.]
106 */ 106 */
107 107
108#ifndef AES_DEBUG
109# ifndef NDEBUG
110# define NDEBUG
111# endif
112#endif
108#include <assert.h> 113#include <assert.h>
114
109#include <openssl/aes.h> 115#include <openssl/aes.h>
110#include "aes_locl.h" 116#include "aes_locl.h"
111 117
diff --git a/src/lib/libcrypto/asn1/Makefile.ssl b/src/lib/libcrypto/asn1/Makefile.ssl
index b5a186c904..cb45194d48 100644
--- a/src/lib/libcrypto/asn1/Makefile.ssl
+++ b/src/lib/libcrypto/asn1/Makefile.ssl
@@ -98,7 +98,7 @@ lint:
98 lint -DLINT $(INCLUDES) $(SRC)>fluff 98 lint -DLINT $(INCLUDES) $(SRC)>fluff
99 99
100depend: 100depend:
101 $(MAKEDEPEND) $(CFLAG) $(INCLUDES) $(DEPFLAG) $(PROGS) $(LIBSRC) 101 $(MAKEDEPEND) -- $(CFLAG) $(INCLUDES) $(DEPFLAG) -- $(PROGS) $(LIBSRC)
102 102
103dclean: 103dclean:
104 $(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new 104 $(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
@@ -286,13 +286,14 @@ a_sign.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
286a_sign.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h 286a_sign.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
287a_sign.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h 287a_sign.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
288a_sign.o: ../cryptlib.h a_sign.c 288a_sign.o: ../cryptlib.h a_sign.c
289a_strex.o: ../../include/openssl/aes.h ../../include/openssl/asn1.h 289a_strex.o: ../../e_os.h ../../include/openssl/aes.h
290a_strex.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h 290a_strex.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
291a_strex.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h 291a_strex.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
292a_strex.o: ../../include/openssl/cast.h ../../include/openssl/crypto.h 292a_strex.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
293a_strex.o: ../../include/openssl/des.h ../../include/openssl/des_old.h 293a_strex.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
294a_strex.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h 294a_strex.o: ../../include/openssl/des_old.h ../../include/openssl/dh.h
295a_strex.o: ../../include/openssl/e_os2.h ../../include/openssl/evp.h 295a_strex.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
296a_strex.o: ../../include/openssl/err.h ../../include/openssl/evp.h
296a_strex.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h 297a_strex.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h
297a_strex.o: ../../include/openssl/md2.h ../../include/openssl/md4.h 298a_strex.o: ../../include/openssl/md2.h ../../include/openssl/md4.h
298a_strex.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h 299a_strex.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
@@ -305,7 +306,7 @@ a_strex.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
305a_strex.o: ../../include/openssl/sha.h ../../include/openssl/stack.h 306a_strex.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
306a_strex.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h 307a_strex.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
307a_strex.o: ../../include/openssl/ui_compat.h ../../include/openssl/x509.h 308a_strex.o: ../../include/openssl/ui_compat.h ../../include/openssl/x509.h
308a_strex.o: ../../include/openssl/x509_vfy.h a_strex.c charmap.h 309a_strex.o: ../../include/openssl/x509_vfy.h ../cryptlib.h a_strex.c charmap.h
309a_strnid.o: ../../e_os.h ../../include/openssl/asn1.h 310a_strnid.o: ../../e_os.h ../../include/openssl/asn1.h
310a_strnid.o: ../../include/openssl/bio.h ../../include/openssl/bn.h 311a_strnid.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
311a_strnid.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 312a_strnid.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
diff --git a/src/lib/libcrypto/asn1/a_bitstr.c b/src/lib/libcrypto/asn1/a_bitstr.c
index e0265f69d2..f4ea96cd54 100644
--- a/src/lib/libcrypto/asn1/a_bitstr.c
+++ b/src/lib/libcrypto/asn1/a_bitstr.c
@@ -191,7 +191,9 @@ int ASN1_BIT_STRING_set_bit(ASN1_BIT_STRING *a, int n, int value)
191 if (a->data == NULL) 191 if (a->data == NULL)
192 c=(unsigned char *)OPENSSL_malloc(w+1); 192 c=(unsigned char *)OPENSSL_malloc(w+1);
193 else 193 else
194 c=(unsigned char *)OPENSSL_realloc(a->data,w+1); 194 c=(unsigned char *)OPENSSL_realloc_clean(a->data,
195 a->length,
196 w+1);
195 if (c == NULL) return(0); 197 if (c == NULL) return(0);
196 if (w+1-a->length > 0) memset(c+a->length, 0, w+1-a->length); 198 if (w+1-a->length > 0) memset(c+a->length, 0, w+1-a->length);
197 a->data=c; 199 a->data=c;
diff --git a/src/lib/libcrypto/asn1/a_bytes.c b/src/lib/libcrypto/asn1/a_bytes.c
index bb88660f58..afd27b80e1 100644
--- a/src/lib/libcrypto/asn1/a_bytes.c
+++ b/src/lib/libcrypto/asn1/a_bytes.c
@@ -285,7 +285,7 @@ static int asn1_collate_primitive(ASN1_STRING *a, ASN1_CTX *c)
285 goto err; 285 goto err;
286 } 286 }
287 287
288 if (!BUF_MEM_grow(&b,num+os->length)) 288 if (!BUF_MEM_grow_clean(&b,num+os->length))
289 { 289 {
290 c->error=ERR_R_BUF_LIB; 290 c->error=ERR_R_BUF_LIB;
291 goto err; 291 goto err;
diff --git a/src/lib/libcrypto/asn1/a_d2i_fp.c b/src/lib/libcrypto/asn1/a_d2i_fp.c
index a80fbe9ff7..b67b75e7c2 100644
--- a/src/lib/libcrypto/asn1/a_d2i_fp.c
+++ b/src/lib/libcrypto/asn1/a_d2i_fp.c
@@ -149,7 +149,12 @@ static int asn1_d2i_read_bio(BIO *in, BUF_MEM **pb)
149 ASN1_CTX c; 149 ASN1_CTX c;
150 int want=HEADER_SIZE; 150 int want=HEADER_SIZE;
151 int eos=0; 151 int eos=0;
152#if defined(__GNUC__) && defined(__ia64)
153 /* pathetic compiler bug in all known versions as of Nov. 2002 */
154 long off=0;
155#else
152 int off=0; 156 int off=0;
157#endif
153 int len=0; 158 int len=0;
154 159
155 b=BUF_MEM_new(); 160 b=BUF_MEM_new();
@@ -166,7 +171,7 @@ static int asn1_d2i_read_bio(BIO *in, BUF_MEM **pb)
166 { 171 {
167 want-=(len-off); 172 want-=(len-off);
168 173
169 if (!BUF_MEM_grow(b,len+want)) 174 if (!BUF_MEM_grow_clean(b,len+want))
170 { 175 {
171 ASN1err(ASN1_F_ASN1_D2I_BIO,ERR_R_MALLOC_FAILURE); 176 ASN1err(ASN1_F_ASN1_D2I_BIO,ERR_R_MALLOC_FAILURE);
172 goto err; 177 goto err;
@@ -221,18 +226,23 @@ static int asn1_d2i_read_bio(BIO *in, BUF_MEM **pb)
221 if (want > (len-off)) 226 if (want > (len-off))
222 { 227 {
223 want-=(len-off); 228 want-=(len-off);
224 if (!BUF_MEM_grow(b,len+want)) 229 if (!BUF_MEM_grow_clean(b,len+want))
225 { 230 {
226 ASN1err(ASN1_F_ASN1_D2I_BIO,ERR_R_MALLOC_FAILURE); 231 ASN1err(ASN1_F_ASN1_D2I_BIO,ERR_R_MALLOC_FAILURE);
227 goto err; 232 goto err;
228 } 233 }
229 i=BIO_read(in,&(b->data[len]),want); 234 while (want > 0)
230 if (i <= 0)
231 { 235 {
232 ASN1err(ASN1_F_ASN1_D2I_BIO,ASN1_R_NOT_ENOUGH_DATA); 236 i=BIO_read(in,&(b->data[len]),want);
233 goto err; 237 if (i <= 0)
238 {
239 ASN1err(ASN1_F_ASN1_D2I_BIO,
240 ASN1_R_NOT_ENOUGH_DATA);
241 goto err;
242 }
243 len+=i;
244 want -= i;
234 } 245 }
235 len+=i;
236 } 246 }
237 off+=(int)c.slen; 247 off+=(int)c.slen;
238 if (eos <= 0) 248 if (eos <= 0)
diff --git a/src/lib/libcrypto/asn1/a_object.c b/src/lib/libcrypto/asn1/a_object.c
index 71ce7c3896..0a8e6c287c 100644
--- a/src/lib/libcrypto/asn1/a_object.c
+++ b/src/lib/libcrypto/asn1/a_object.c
@@ -183,8 +183,8 @@ int i2a_ASN1_OBJECT(BIO *bp, ASN1_OBJECT *a)
183 183
184 if ((a == NULL) || (a->data == NULL)) 184 if ((a == NULL) || (a->data == NULL))
185 return(BIO_write(bp,"NULL",4)); 185 return(BIO_write(bp,"NULL",4));
186 i=i2t_ASN1_OBJECT(buf,80,a); 186 i=i2t_ASN1_OBJECT(buf,sizeof buf,a);
187 if (i > 80) i=80; 187 if (i > sizeof buf) i=sizeof buf;
188 BIO_write(bp,buf,i); 188 BIO_write(bp,buf,i);
189 return(i); 189 return(i);
190 } 190 }
diff --git a/src/lib/libcrypto/asn1/a_sign.c b/src/lib/libcrypto/asn1/a_sign.c
index de53b44144..52ce7e3974 100644
--- a/src/lib/libcrypto/asn1/a_sign.c
+++ b/src/lib/libcrypto/asn1/a_sign.c
@@ -204,9 +204,9 @@ int ASN1_sign(int (*i2d)(), X509_ALGOR *algor1, X509_ALGOR *algor2,
204err: 204err:
205 EVP_MD_CTX_cleanup(&ctx); 205 EVP_MD_CTX_cleanup(&ctx);
206 if (buf_in != NULL) 206 if (buf_in != NULL)
207 { memset((char *)buf_in,0,(unsigned int)inl); OPENSSL_free(buf_in); } 207 { OPENSSL_cleanse((char *)buf_in,(unsigned int)inl); OPENSSL_free(buf_in); }
208 if (buf_out != NULL) 208 if (buf_out != NULL)
209 { memset((char *)buf_out,0,outll); OPENSSL_free(buf_out); } 209 { OPENSSL_cleanse((char *)buf_out,outll); OPENSSL_free(buf_out); }
210 return(outl); 210 return(outl);
211 } 211 }
212 212
@@ -287,8 +287,8 @@ int ASN1_item_sign(const ASN1_ITEM *it, X509_ALGOR *algor1, X509_ALGOR *algor2,
287err: 287err:
288 EVP_MD_CTX_cleanup(&ctx); 288 EVP_MD_CTX_cleanup(&ctx);
289 if (buf_in != NULL) 289 if (buf_in != NULL)
290 { memset((char *)buf_in,0,(unsigned int)inl); OPENSSL_free(buf_in); } 290 { OPENSSL_cleanse((char *)buf_in,(unsigned int)inl); OPENSSL_free(buf_in); }
291 if (buf_out != NULL) 291 if (buf_out != NULL)
292 { memset((char *)buf_out,0,outll); OPENSSL_free(buf_out); } 292 { OPENSSL_cleanse((char *)buf_out,outll); OPENSSL_free(buf_out); }
293 return(outl); 293 return(outl);
294 } 294 }
diff --git a/src/lib/libcrypto/asn1/a_strex.c b/src/lib/libcrypto/asn1/a_strex.c
index 7ddb7662f1..1def6c6549 100644
--- a/src/lib/libcrypto/asn1/a_strex.c
+++ b/src/lib/libcrypto/asn1/a_strex.c
@@ -63,6 +63,7 @@
63#include <openssl/asn1.h> 63#include <openssl/asn1.h>
64 64
65#include "charmap.h" 65#include "charmap.h"
66#include "cryptlib.h"
66 67
67/* ASN1_STRING_print_ex() and X509_NAME_print_ex(). 68/* ASN1_STRING_print_ex() and X509_NAME_print_ex().
68 * Enhanced string and name printing routines handling 69 * Enhanced string and name printing routines handling
@@ -114,14 +115,17 @@ typedef int char_io(void *arg, const void *buf, int len);
114static int do_esc_char(unsigned long c, unsigned char flags, char *do_quotes, char_io *io_ch, void *arg) 115static int do_esc_char(unsigned long c, unsigned char flags, char *do_quotes, char_io *io_ch, void *arg)
115{ 116{
116 unsigned char chflgs, chtmp; 117 unsigned char chflgs, chtmp;
117 char tmphex[11]; 118 char tmphex[HEX_SIZE(long)+3];
119
120 if(c > 0xffffffffL)
121 return -1;
118 if(c > 0xffff) { 122 if(c > 0xffff) {
119 BIO_snprintf(tmphex, 11, "\\W%08lX", c); 123 BIO_snprintf(tmphex, sizeof tmphex, "\\W%08lX", c);
120 if(!io_ch(arg, tmphex, 10)) return -1; 124 if(!io_ch(arg, tmphex, 10)) return -1;
121 return 10; 125 return 10;
122 } 126 }
123 if(c > 0xff) { 127 if(c > 0xff) {
124 BIO_snprintf(tmphex, 11, "\\U%04lX", c); 128 BIO_snprintf(tmphex, sizeof tmphex, "\\U%04lX", c);
125 if(!io_ch(arg, tmphex, 6)) return -1; 129 if(!io_ch(arg, tmphex, 6)) return -1;
126 return 6; 130 return 6;
127 } 131 }
@@ -195,7 +199,7 @@ static int do_buf(unsigned char *buf, int buflen,
195 if(type & BUF_TYPE_CONVUTF8) { 199 if(type & BUF_TYPE_CONVUTF8) {
196 unsigned char utfbuf[6]; 200 unsigned char utfbuf[6];
197 int utflen; 201 int utflen;
198 utflen = UTF8_putc(utfbuf, 6, c); 202 utflen = UTF8_putc(utfbuf, sizeof utfbuf, c);
199 for(i = 0; i < utflen; i++) { 203 for(i = 0; i < utflen; i++) {
200 /* We don't need to worry about setting orflags correctly 204 /* We don't need to worry about setting orflags correctly
201 * because if utflen==1 its value will be correct anyway 205 * because if utflen==1 its value will be correct anyway
@@ -461,7 +465,7 @@ static int do_name_ex(char_io *io_ch, void *arg, X509_NAME *n,
461 if(fn_opt != XN_FLAG_FN_NONE) { 465 if(fn_opt != XN_FLAG_FN_NONE) {
462 int objlen, fld_len; 466 int objlen, fld_len;
463 if((fn_opt == XN_FLAG_FN_OID) || (fn_nid==NID_undef) ) { 467 if((fn_opt == XN_FLAG_FN_OID) || (fn_nid==NID_undef) ) {
464 OBJ_obj2txt(objtmp, 80, fn, 1); 468 OBJ_obj2txt(objtmp, sizeof objtmp, fn, 1);
465 fld_len = 0; /* XXX: what should this be? */ 469 fld_len = 0; /* XXX: what should this be? */
466 objbuf = objtmp; 470 objbuf = objtmp;
467 } else { 471 } else {
diff --git a/src/lib/libcrypto/asn1/a_strnid.c b/src/lib/libcrypto/asn1/a_strnid.c
index 04789d1c63..aa49e9d7d0 100644
--- a/src/lib/libcrypto/asn1/a_strnid.c
+++ b/src/lib/libcrypto/asn1/a_strnid.c
@@ -173,6 +173,7 @@ static ASN1_STRING_TABLE tbl_standard[] = {
173{NID_friendlyName, -1, -1, B_ASN1_BMPSTRING, STABLE_NO_MASK}, 173{NID_friendlyName, -1, -1, B_ASN1_BMPSTRING, STABLE_NO_MASK},
174{NID_name, 1, ub_name, DIRSTRING_TYPE, 0}, 174{NID_name, 1, ub_name, DIRSTRING_TYPE, 0},
175{NID_dnQualifier, -1, -1, B_ASN1_PRINTABLESTRING, STABLE_NO_MASK}, 175{NID_dnQualifier, -1, -1, B_ASN1_PRINTABLESTRING, STABLE_NO_MASK},
176{NID_domainComponent, 1, -1, B_ASN1_IA5STRING, STABLE_NO_MASK},
176{NID_ms_csp_name, -1, -1, B_ASN1_BMPSTRING, STABLE_NO_MASK} 177{NID_ms_csp_name, -1, -1, B_ASN1_BMPSTRING, STABLE_NO_MASK}
177}; 178};
178 179
@@ -249,4 +250,38 @@ static void st_free(ASN1_STRING_TABLE *tbl)
249 if(tbl->flags & STABLE_FLAGS_MALLOC) OPENSSL_free(tbl); 250 if(tbl->flags & STABLE_FLAGS_MALLOC) OPENSSL_free(tbl);
250} 251}
251 252
253
252IMPLEMENT_STACK_OF(ASN1_STRING_TABLE) 254IMPLEMENT_STACK_OF(ASN1_STRING_TABLE)
255
256#ifdef STRING_TABLE_TEST
257
258main()
259{
260 ASN1_STRING_TABLE *tmp;
261 int i, last_nid = -1;
262
263 for (tmp = tbl_standard, i = 0;
264 i < sizeof(tbl_standard)/sizeof(ASN1_STRING_TABLE); i++, tmp++)
265 {
266 if (tmp->nid < last_nid)
267 {
268 last_nid = 0;
269 break;
270 }
271 last_nid = tmp->nid;
272 }
273
274 if (last_nid != 0)
275 {
276 printf("Table order OK\n");
277 exit(0);
278 }
279
280 for (tmp = tbl_standard, i = 0;
281 i < sizeof(tbl_standard)/sizeof(ASN1_STRING_TABLE); i++, tmp++)
282 printf("Index %d, NID %d, Name=%s\n", i, tmp->nid,
283 OBJ_nid2ln(tmp->nid));
284
285}
286
287#endif
diff --git a/src/lib/libcrypto/asn1/a_time.c b/src/lib/libcrypto/asn1/a_time.c
index 8216783aa8..b8c031fc8f 100644
--- a/src/lib/libcrypto/asn1/a_time.c
+++ b/src/lib/libcrypto/asn1/a_time.c
@@ -105,7 +105,10 @@ ASN1_TIME *ASN1_TIME_set(ASN1_TIME *s, time_t t)
105 105
106 ts=OPENSSL_gmtime(&t,&data); 106 ts=OPENSSL_gmtime(&t,&data);
107 if (ts == NULL) 107 if (ts == NULL)
108 {
109 ASN1err(ASN1_F_ASN1_TIME_SET, ASN1_R_ERROR_GETTING_TIME);
108 return NULL; 110 return NULL;
111 }
109 if((ts->tm_year >= 50) && (ts->tm_year < 150)) 112 if((ts->tm_year >= 50) && (ts->tm_year < 150))
110 return ASN1_UTCTIME_set(s, t); 113 return ASN1_UTCTIME_set(s, t);
111 return ASN1_GENERALIZEDTIME_set(s,t); 114 return ASN1_GENERALIZEDTIME_set(s,t);
diff --git a/src/lib/libcrypto/asn1/a_type.c b/src/lib/libcrypto/asn1/a_type.c
index 96e111cf23..fe3fcd40b0 100644
--- a/src/lib/libcrypto/asn1/a_type.c
+++ b/src/lib/libcrypto/asn1/a_type.c
@@ -62,7 +62,7 @@
62 62
63int ASN1_TYPE_get(ASN1_TYPE *a) 63int ASN1_TYPE_get(ASN1_TYPE *a)
64 { 64 {
65 if (a->value.ptr != NULL) 65 if ((a->value.ptr != NULL) || (a->type == V_ASN1_NULL))
66 return(a->type); 66 return(a->type);
67 else 67 else
68 return(0); 68 return(0);
diff --git a/src/lib/libcrypto/asn1/a_verify.c b/src/lib/libcrypto/asn1/a_verify.c
index bf41de5146..da2a0a6d69 100644
--- a/src/lib/libcrypto/asn1/a_verify.c
+++ b/src/lib/libcrypto/asn1/a_verify.c
@@ -103,7 +103,7 @@ int ASN1_verify(int (*i2d)(), X509_ALGOR *a, ASN1_BIT_STRING *signature,
103 EVP_VerifyInit_ex(&ctx,type, NULL); 103 EVP_VerifyInit_ex(&ctx,type, NULL);
104 EVP_VerifyUpdate(&ctx,(unsigned char *)buf_in,inl); 104 EVP_VerifyUpdate(&ctx,(unsigned char *)buf_in,inl);
105 105
106 memset(buf_in,0,(unsigned int)inl); 106 OPENSSL_cleanse(buf_in,(unsigned int)inl);
107 OPENSSL_free(buf_in); 107 OPENSSL_free(buf_in);
108 108
109 if (EVP_VerifyFinal(&ctx,(unsigned char *)signature->data, 109 if (EVP_VerifyFinal(&ctx,(unsigned char *)signature->data,
@@ -153,7 +153,7 @@ int ASN1_item_verify(const ASN1_ITEM *it, X509_ALGOR *a, ASN1_BIT_STRING *signat
153 EVP_VerifyInit_ex(&ctx,type, NULL); 153 EVP_VerifyInit_ex(&ctx,type, NULL);
154 EVP_VerifyUpdate(&ctx,(unsigned char *)buf_in,inl); 154 EVP_VerifyUpdate(&ctx,(unsigned char *)buf_in,inl);
155 155
156 memset(buf_in,0,(unsigned int)inl); 156 OPENSSL_cleanse(buf_in,(unsigned int)inl);
157 OPENSSL_free(buf_in); 157 OPENSSL_free(buf_in);
158 158
159 if (EVP_VerifyFinal(&ctx,(unsigned char *)signature->data, 159 if (EVP_VerifyFinal(&ctx,(unsigned char *)signature->data,
diff --git a/src/lib/libcrypto/asn1/asn1.h b/src/lib/libcrypto/asn1/asn1.h
index dbb30f4f22..3414509f1b 100644
--- a/src/lib/libcrypto/asn1/asn1.h
+++ b/src/lib/libcrypto/asn1/asn1.h
@@ -70,7 +70,6 @@
70 70
71#include <openssl/symhacks.h> 71#include <openssl/symhacks.h>
72 72
73#include <openssl/e_os2.h>
74#include <openssl/ossl_typ.h> 73#include <openssl/ossl_typ.h>
75 74
76#ifdef OPENSSL_BUILD_SHLIBCRYPTO 75#ifdef OPENSSL_BUILD_SHLIBCRYPTO
@@ -133,7 +132,7 @@ extern "C" {
133#define B_ASN1_NUMERICSTRING 0x0001 132#define B_ASN1_NUMERICSTRING 0x0001
134#define B_ASN1_PRINTABLESTRING 0x0002 133#define B_ASN1_PRINTABLESTRING 0x0002
135#define B_ASN1_T61STRING 0x0004 134#define B_ASN1_T61STRING 0x0004
136#define B_ASN1_TELETEXSTRING 0x0008 135#define B_ASN1_TELETEXSTRING 0x0004
137#define B_ASN1_VIDEOTEXSTRING 0x0008 136#define B_ASN1_VIDEOTEXSTRING 0x0008
138#define B_ASN1_IA5STRING 0x0010 137#define B_ASN1_IA5STRING 0x0010
139#define B_ASN1_GRAPHICSTRING 0x0020 138#define B_ASN1_GRAPHICSTRING 0x0020
@@ -981,6 +980,7 @@ void ERR_load_ASN1_strings(void);
981#define ASN1_F_ASN1_TEMPLATE_D2I 131 980#define ASN1_F_ASN1_TEMPLATE_D2I 131
982#define ASN1_F_ASN1_TEMPLATE_EX_D2I 132 981#define ASN1_F_ASN1_TEMPLATE_EX_D2I 132
983#define ASN1_F_ASN1_TEMPLATE_NEW 133 982#define ASN1_F_ASN1_TEMPLATE_NEW 133
983#define ASN1_F_ASN1_TIME_SET 175
984#define ASN1_F_ASN1_TYPE_GET_INT_OCTETSTRING 134 984#define ASN1_F_ASN1_TYPE_GET_INT_OCTETSTRING 134
985#define ASN1_F_ASN1_TYPE_GET_OCTETSTRING 135 985#define ASN1_F_ASN1_TYPE_GET_OCTETSTRING 135
986#define ASN1_F_ASN1_UNPACK_STRING 136 986#define ASN1_F_ASN1_UNPACK_STRING 136
@@ -1038,6 +1038,7 @@ void ERR_load_ASN1_strings(void);
1038#define ASN1_R_DECODE_ERROR 110 1038#define ASN1_R_DECODE_ERROR 110
1039#define ASN1_R_DECODING_ERROR 111 1039#define ASN1_R_DECODING_ERROR 111
1040#define ASN1_R_ENCODE_ERROR 112 1040#define ASN1_R_ENCODE_ERROR 112
1041#define ASN1_R_ERROR_GETTING_TIME 173
1041#define ASN1_R_ERROR_LOADING_SECTION 172 1042#define ASN1_R_ERROR_LOADING_SECTION 172
1042#define ASN1_R_ERROR_PARSING_SET_ELEMENT 113 1043#define ASN1_R_ERROR_PARSING_SET_ELEMENT 113
1043#define ASN1_R_ERROR_SETTING_CIPHER_PARAMS 114 1044#define ASN1_R_ERROR_SETTING_CIPHER_PARAMS 114
diff --git a/src/lib/libcrypto/asn1/asn1_err.c b/src/lib/libcrypto/asn1/asn1_err.c
index c4c3d2a91d..094ec06fda 100644
--- a/src/lib/libcrypto/asn1/asn1_err.c
+++ b/src/lib/libcrypto/asn1/asn1_err.c
@@ -1,6 +1,6 @@
1/* crypto/asn1/asn1_err.c */ 1/* crypto/asn1/asn1_err.c */
2/* ==================================================================== 2/* ====================================================================
3 * Copyright (c) 1999 The OpenSSL Project. All rights reserved. 3 * Copyright (c) 1999-2002 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
@@ -100,6 +100,7 @@ static ERR_STRING_DATA ASN1_str_functs[]=
100{ERR_PACK(0,ASN1_F_ASN1_TEMPLATE_D2I,0), "ASN1_TEMPLATE_D2I"}, 100{ERR_PACK(0,ASN1_F_ASN1_TEMPLATE_D2I,0), "ASN1_TEMPLATE_D2I"},
101{ERR_PACK(0,ASN1_F_ASN1_TEMPLATE_EX_D2I,0), "ASN1_TEMPLATE_EX_D2I"}, 101{ERR_PACK(0,ASN1_F_ASN1_TEMPLATE_EX_D2I,0), "ASN1_TEMPLATE_EX_D2I"},
102{ERR_PACK(0,ASN1_F_ASN1_TEMPLATE_NEW,0), "ASN1_TEMPLATE_NEW"}, 102{ERR_PACK(0,ASN1_F_ASN1_TEMPLATE_NEW,0), "ASN1_TEMPLATE_NEW"},
103{ERR_PACK(0,ASN1_F_ASN1_TIME_SET,0), "ASN1_TIME_set"},
103{ERR_PACK(0,ASN1_F_ASN1_TYPE_GET_INT_OCTETSTRING,0), "ASN1_TYPE_get_int_octetstring"}, 104{ERR_PACK(0,ASN1_F_ASN1_TYPE_GET_INT_OCTETSTRING,0), "ASN1_TYPE_get_int_octetstring"},
104{ERR_PACK(0,ASN1_F_ASN1_TYPE_GET_OCTETSTRING,0), "ASN1_TYPE_get_octetstring"}, 105{ERR_PACK(0,ASN1_F_ASN1_TYPE_GET_OCTETSTRING,0), "ASN1_TYPE_get_octetstring"},
105{ERR_PACK(0,ASN1_F_ASN1_UNPACK_STRING,0), "ASN1_unpack_string"}, 106{ERR_PACK(0,ASN1_F_ASN1_UNPACK_STRING,0), "ASN1_unpack_string"},
@@ -160,6 +161,7 @@ static ERR_STRING_DATA ASN1_str_reasons[]=
160{ASN1_R_DECODE_ERROR ,"decode error"}, 161{ASN1_R_DECODE_ERROR ,"decode error"},
161{ASN1_R_DECODING_ERROR ,"decoding error"}, 162{ASN1_R_DECODING_ERROR ,"decoding error"},
162{ASN1_R_ENCODE_ERROR ,"encode error"}, 163{ASN1_R_ENCODE_ERROR ,"encode error"},
164{ASN1_R_ERROR_GETTING_TIME ,"error getting time"},
163{ASN1_R_ERROR_LOADING_SECTION ,"error loading section"}, 165{ASN1_R_ERROR_LOADING_SECTION ,"error loading section"},
164{ASN1_R_ERROR_PARSING_SET_ELEMENT ,"error parsing set element"}, 166{ASN1_R_ERROR_PARSING_SET_ELEMENT ,"error parsing set element"},
165{ASN1_R_ERROR_SETTING_CIPHER_PARAMS ,"error setting cipher params"}, 167{ASN1_R_ERROR_SETTING_CIPHER_PARAMS ,"error setting cipher params"},
diff --git a/src/lib/libcrypto/asn1/asn1_par.c b/src/lib/libcrypto/asn1/asn1_par.c
index 4223c9ae45..1799657141 100644
--- a/src/lib/libcrypto/asn1/asn1_par.c
+++ b/src/lib/libcrypto/asn1/asn1_par.c
@@ -79,12 +79,7 @@ static int asn1_print_info(BIO *bp, int tag, int xclass, int constructed,
79 else 79 else
80 p="prim: "; 80 p="prim: ";
81 if (BIO_write(bp,p,6) < 6) goto err; 81 if (BIO_write(bp,p,6) < 6) goto err;
82 if (indent) 82 BIO_indent(bp,indent,128);
83 {
84 if (indent > 128) indent=128;
85 memset(str,' ',indent);
86 if (BIO_write(bp,str,indent) < indent) goto err;
87 }
88 83
89 p=str; 84 p=str;
90 if ((xclass & V_ASN1_PRIVATE) == V_ASN1_PRIVATE) 85 if ((xclass & V_ASN1_PRIVATE) == V_ASN1_PRIVATE)
diff --git a/src/lib/libcrypto/asn1/f_int.c b/src/lib/libcrypto/asn1/f_int.c
index 48cc3bfb90..9494e597ab 100644
--- a/src/lib/libcrypto/asn1/f_int.c
+++ b/src/lib/libcrypto/asn1/f_int.c
@@ -169,8 +169,7 @@ int a2i_ASN1_INTEGER(BIO *bp, ASN1_INTEGER *bs, char *buf, int size)
169 sp=(unsigned char *)OPENSSL_malloc( 169 sp=(unsigned char *)OPENSSL_malloc(
170 (unsigned int)num+i*2); 170 (unsigned int)num+i*2);
171 else 171 else
172 sp=(unsigned char *)OPENSSL_realloc(s, 172 sp=OPENSSL_realloc_clean(s,slen,num+i*2);
173 (unsigned int)num+i*2);
174 if (sp == NULL) 173 if (sp == NULL)
175 { 174 {
176 ASN1err(ASN1_F_A2I_ASN1_INTEGER,ERR_R_MALLOC_FAILURE); 175 ASN1err(ASN1_F_A2I_ASN1_INTEGER,ERR_R_MALLOC_FAILURE);
diff --git a/src/lib/libcrypto/asn1/n_pkey.c b/src/lib/libcrypto/asn1/n_pkey.c
index 9146ee02c9..766b51c538 100644
--- a/src/lib/libcrypto/asn1/n_pkey.c
+++ b/src/lib/libcrypto/asn1/n_pkey.c
@@ -187,7 +187,7 @@ int i2d_RSA_NET(const RSA *a, unsigned char **pp, int (*cb)(), int sgckey)
187 i2d_NETSCAPE_PKEY(pkey,&zz); 187 i2d_NETSCAPE_PKEY(pkey,&zz);
188 188
189 /* Wipe the private key encoding */ 189 /* Wipe the private key encoding */
190 memset(pkey->private_key->data, 0, rsalen); 190 OPENSSL_cleanse(pkey->private_key->data, rsalen);
191 191
192 if (cb == NULL) 192 if (cb == NULL)
193 cb=EVP_read_pw_string; 193 cb=EVP_read_pw_string;
@@ -206,7 +206,7 @@ int i2d_RSA_NET(const RSA *a, unsigned char **pp, int (*cb)(), int sgckey)
206 } 206 }
207 207
208 EVP_BytesToKey(EVP_rc4(),EVP_md5(),NULL,buf,i,1,key,NULL); 208 EVP_BytesToKey(EVP_rc4(),EVP_md5(),NULL,buf,i,1,key,NULL);
209 memset(buf,0,256); 209 OPENSSL_cleanse(buf,256);
210 210
211 /* Encrypt private key in place */ 211 /* Encrypt private key in place */
212 zz = enckey->enckey->digest->data; 212 zz = enckey->enckey->digest->data;
@@ -294,7 +294,7 @@ static RSA *d2i_RSA_NET_2(RSA **a, ASN1_OCTET_STRING *os,
294 } 294 }
295 295
296 EVP_BytesToKey(EVP_rc4(),EVP_md5(),NULL,buf,i,1,key,NULL); 296 EVP_BytesToKey(EVP_rc4(),EVP_md5(),NULL,buf,i,1,key,NULL);
297 memset(buf,0,256); 297 OPENSSL_cleanse(buf,256);
298 298
299 EVP_CIPHER_CTX_init(&ctx); 299 EVP_CIPHER_CTX_init(&ctx);
300 EVP_DecryptInit_ex(&ctx,EVP_rc4(),NULL, key,NULL); 300 EVP_DecryptInit_ex(&ctx,EVP_rc4(),NULL, key,NULL);
diff --git a/src/lib/libcrypto/asn1/p8_pkey.c b/src/lib/libcrypto/asn1/p8_pkey.c
index b634d5bc85..24b409132f 100644
--- a/src/lib/libcrypto/asn1/p8_pkey.c
+++ b/src/lib/libcrypto/asn1/p8_pkey.c
@@ -68,8 +68,8 @@ static int pkey_cb(int operation, ASN1_VALUE **pval, const ASN1_ITEM *it)
68 if(operation == ASN1_OP_FREE_PRE) { 68 if(operation == ASN1_OP_FREE_PRE) {
69 PKCS8_PRIV_KEY_INFO *key = (PKCS8_PRIV_KEY_INFO *)*pval; 69 PKCS8_PRIV_KEY_INFO *key = (PKCS8_PRIV_KEY_INFO *)*pval;
70 if (key->pkey->value.octet_string) 70 if (key->pkey->value.octet_string)
71 memset(key->pkey->value.octet_string->data, 71 OPENSSL_cleanse(key->pkey->value.octet_string->data,
72 0, key->pkey->value.octet_string->length); 72 key->pkey->value.octet_string->length);
73 } 73 }
74 return 1; 74 return 1;
75} 75}
diff --git a/src/lib/libcrypto/asn1/t_crl.c b/src/lib/libcrypto/asn1/t_crl.c
index 60db305756..757c148df8 100644
--- a/src/lib/libcrypto/asn1/t_crl.c
+++ b/src/lib/libcrypto/asn1/t_crl.c
@@ -84,11 +84,11 @@ int X509_CRL_print_fp(FILE *fp, X509_CRL *x)
84 84
85int X509_CRL_print(BIO *out, X509_CRL *x) 85int X509_CRL_print(BIO *out, X509_CRL *x)
86{ 86{
87 char buf[256];
88 STACK_OF(X509_REVOKED) *rev; 87 STACK_OF(X509_REVOKED) *rev;
89 X509_REVOKED *r; 88 X509_REVOKED *r;
90 long l; 89 long l;
91 int i, n; 90 int i, n;
91 char *p;
92 92
93 BIO_printf(out, "Certificate Revocation List (CRL):\n"); 93 BIO_printf(out, "Certificate Revocation List (CRL):\n");
94 l = X509_CRL_get_version(x); 94 l = X509_CRL_get_version(x);
@@ -96,8 +96,9 @@ int X509_CRL_print(BIO *out, X509_CRL *x)
96 i = OBJ_obj2nid(x->sig_alg->algorithm); 96 i = OBJ_obj2nid(x->sig_alg->algorithm);
97 BIO_printf(out, "%8sSignature Algorithm: %s\n", "", 97 BIO_printf(out, "%8sSignature Algorithm: %s\n", "",
98 (i == NID_undef) ? "NONE" : OBJ_nid2ln(i)); 98 (i == NID_undef) ? "NONE" : OBJ_nid2ln(i));
99 X509_NAME_oneline(X509_CRL_get_issuer(x),buf,256); 99 p=X509_NAME_oneline(X509_CRL_get_issuer(x),NULL,0);
100 BIO_printf(out,"%8sIssuer: %s\n","",buf); 100 BIO_printf(out,"%8sIssuer: %s\n","",p);
101 OPENSSL_free(p);
101 BIO_printf(out,"%8sLast Update: ",""); 102 BIO_printf(out,"%8sLast Update: ","");
102 ASN1_TIME_print(out,X509_CRL_get_lastUpdate(x)); 103 ASN1_TIME_print(out,X509_CRL_get_lastUpdate(x));
103 BIO_printf(out,"\n%8sNext Update: ",""); 104 BIO_printf(out,"\n%8sNext Update: ","");
diff --git a/src/lib/libcrypto/asn1/t_pkey.c b/src/lib/libcrypto/asn1/t_pkey.c
index b3f8364012..e1c5e5ae13 100644
--- a/src/lib/libcrypto/asn1/t_pkey.c
+++ b/src/lib/libcrypto/asn1/t_pkey.c
@@ -130,14 +130,10 @@ int RSA_print(BIO *bp, const RSA *x, int off)
130 goto err; 130 goto err;
131 } 131 }
132 132
133 if (off)
134 {
135 if (off > 128) off=128;
136 memset(str,' ',off);
137 }
138 if (x->d != NULL) 133 if (x->d != NULL)
139 { 134 {
140 if (off && (BIO_write(bp,str,off) <= 0)) goto err; 135 if(!BIO_indent(bp,off,128))
136 goto err;
141 if (BIO_printf(bp,"Private-Key: (%d bit)\n",BN_num_bits(x->n)) 137 if (BIO_printf(bp,"Private-Key: (%d bit)\n",BN_num_bits(x->n))
142 <= 0) goto err; 138 <= 0) goto err;
143 } 139 }
@@ -183,7 +179,6 @@ int DSA_print_fp(FILE *fp, const DSA *x, int off)
183 179
184int DSA_print(BIO *bp, const DSA *x, int off) 180int DSA_print(BIO *bp, const DSA *x, int off)
185 { 181 {
186 char str[128];
187 unsigned char *m=NULL; 182 unsigned char *m=NULL;
188 int ret=0; 183 int ret=0;
189 size_t buf_len=0,i; 184 size_t buf_len=0,i;
@@ -210,14 +205,10 @@ int DSA_print(BIO *bp, const DSA *x, int off)
210 goto err; 205 goto err;
211 } 206 }
212 207
213 if (off)
214 {
215 if (off > 128) off=128;
216 memset(str,' ',off);
217 }
218 if (x->priv_key != NULL) 208 if (x->priv_key != NULL)
219 { 209 {
220 if (off && (BIO_write(bp,str,off) <= 0)) goto err; 210 if(!BIO_indent(bp,off,128))
211 goto err;
221 if (BIO_printf(bp,"Private-Key: (%d bit)\n",BN_num_bits(x->p)) 212 if (BIO_printf(bp,"Private-Key: (%d bit)\n",BN_num_bits(x->p))
222 <= 0) goto err; 213 <= 0) goto err;
223 } 214 }
@@ -240,17 +231,12 @@ static int print(BIO *bp, const char *number, BIGNUM *num, unsigned char *buf,
240 int off) 231 int off)
241 { 232 {
242 int n,i; 233 int n,i;
243 char str[128];
244 const char *neg; 234 const char *neg;
245 235
246 if (num == NULL) return(1); 236 if (num == NULL) return(1);
247 neg=(num->neg)?"-":""; 237 neg=(num->neg)?"-":"";
248 if (off) 238 if(!BIO_indent(bp,off,128))
249 { 239 return 0;
250 if (off > 128) off=128;
251 memset(str,' ',off);
252 if (BIO_write(bp,str,off) <= 0) return(0);
253 }
254 240
255 if (BN_num_bytes(num) <= BN_BYTES) 241 if (BN_num_bytes(num) <= BN_BYTES)
256 { 242 {
@@ -274,9 +260,9 @@ static int print(BIO *bp, const char *number, BIGNUM *num, unsigned char *buf,
274 { 260 {
275 if ((i%15) == 0) 261 if ((i%15) == 0)
276 { 262 {
277 str[0]='\n'; 263 if(BIO_puts(bp,"\n") <= 0
278 memset(&(str[1]),' ',off+4); 264 || !BIO_indent(bp,off+4,128))
279 if (BIO_write(bp,str,off+1+4) <= 0) return(0); 265 return 0;
280 } 266 }
281 if (BIO_printf(bp,"%02x%s",buf[i],((i+1) == n)?"":":") 267 if (BIO_printf(bp,"%02x%s",buf[i],((i+1) == n)?"":":")
282 <= 0) return(0); 268 <= 0) return(0);
diff --git a/src/lib/libcrypto/asn1/t_req.c b/src/lib/libcrypto/asn1/t_req.c
index eca97e00cb..740cee80c0 100644
--- a/src/lib/libcrypto/asn1/t_req.c
+++ b/src/lib/libcrypto/asn1/t_req.c
@@ -91,7 +91,6 @@ int X509_REQ_print_ex(BIO *bp, X509_REQ *x, unsigned long nmflags, unsigned long
91 EVP_PKEY *pkey; 91 EVP_PKEY *pkey;
92 STACK_OF(X509_ATTRIBUTE) *sk; 92 STACK_OF(X509_ATTRIBUTE) *sk;
93 STACK_OF(X509_EXTENSION) *exts; 93 STACK_OF(X509_EXTENSION) *exts;
94 char str[128];
95 char mlch = ' '; 94 char mlch = ' ';
96 int nmindent = 0; 95 int nmindent = 0;
97 96
@@ -116,9 +115,9 @@ int X509_REQ_print_ex(BIO *bp, X509_REQ *x, unsigned long nmflags, unsigned long
116 l=0; 115 l=0;
117 for (i=0; i<ri->version->length; i++) 116 for (i=0; i<ri->version->length; i++)
118 { l<<=8; l+=ri->version->data[i]; } 117 { l<<=8; l+=ri->version->data[i]; }
119 snprintf(str,sizeof str,"%8sVersion: %s%lu (%s0x%lx)\n","",neg, 118 if(BIO_printf(bp,"%8sVersion: %s%lu (%s0x%lx)\n","",neg,l,neg,
120 l,neg,l); 119 l) <= 0)
121 if (BIO_puts(bp,str) <= 0) goto err; 120 goto err;
122 } 121 }
123 if(!(cflag & X509_FLAG_NO_SUBJECT)) 122 if(!(cflag & X509_FLAG_NO_SUBJECT))
124 { 123 {
@@ -169,14 +168,14 @@ int X509_REQ_print_ex(BIO *bp, X509_REQ *x, unsigned long nmflags, unsigned long
169 if(!(cflag & X509_FLAG_NO_ATTRIBUTES)) 168 if(!(cflag & X509_FLAG_NO_ATTRIBUTES))
170 { 169 {
171 /* may not be */ 170 /* may not be */
172 snprintf(str,sizeof str,"%8sAttributes:\n",""); 171 if(BIO_printf(bp,"%8sAttributes:\n","") <= 0)
173 if (BIO_puts(bp,str) <= 0) goto err; 172 goto err;
174 173
175 sk=x->req_info->attributes; 174 sk=x->req_info->attributes;
176 if (sk_X509_ATTRIBUTE_num(sk) == 0) 175 if (sk_X509_ATTRIBUTE_num(sk) == 0)
177 { 176 {
178 snprintf(str,sizeof str,"%12sa0:00\n",""); 177 if(BIO_printf(bp,"%12sa0:00\n","") <= 0)
179 if (BIO_puts(bp,str) <= 0) goto err; 178 goto err;
180 } 179 }
181 else 180 else
182 { 181 {
@@ -191,8 +190,8 @@ int X509_REQ_print_ex(BIO *bp, X509_REQ *x, unsigned long nmflags, unsigned long
191 a=sk_X509_ATTRIBUTE_value(sk,i); 190 a=sk_X509_ATTRIBUTE_value(sk,i);
192 if(X509_REQ_extension_nid(OBJ_obj2nid(a->object))) 191 if(X509_REQ_extension_nid(OBJ_obj2nid(a->object)))
193 continue; 192 continue;
194 snprintf(str,sizeof str,"%12s",""); 193 if(BIO_printf(bp,"%12s","") <= 0)
195 if (BIO_puts(bp,str) <= 0) goto err; 194 goto err;
196 if ((j=i2a_ASN1_OBJECT(bp,a->object)) > 0) 195 if ((j=i2a_ASN1_OBJECT(bp,a->object)) > 0)
197 { 196 {
198 if (a->single) 197 if (a->single)
diff --git a/src/lib/libcrypto/asn1/t_x509.c b/src/lib/libcrypto/asn1/t_x509.c
index 5de4833ed0..d1034c47f8 100644
--- a/src/lib/libcrypto/asn1/t_x509.c
+++ b/src/lib/libcrypto/asn1/t_x509.c
@@ -433,15 +433,17 @@ err:
433 433
434int X509_NAME_print(BIO *bp, X509_NAME *name, int obase) 434int X509_NAME_print(BIO *bp, X509_NAME *name, int obase)
435 { 435 {
436 char *s,*c; 436 char *s,*c,*b;
437 int ret=0,l,ll,i,first=1; 437 int ret=0,l,ll,i,first=1;
438 char buf[256];
439 438
440 ll=80-2-obase; 439 ll=80-2-obase;
441 440
442 s=X509_NAME_oneline(name,buf,256); 441 b=s=X509_NAME_oneline(name,NULL,0);
443 if (!*s) 442 if (!*s)
443 {
444 OPENSSL_free(b);
444 return 1; 445 return 1;
446 }
445 s++; /* skip the first slash */ 447 s++; /* skip the first slash */
446 448
447 l=ll; 449 l=ll;
@@ -497,6 +499,7 @@ int X509_NAME_print(BIO *bp, X509_NAME *name, int obase)
497err: 499err:
498 X509err(X509_F_X509_NAME_PRINT,ERR_R_BUF_LIB); 500 X509err(X509_F_X509_NAME_PRINT,ERR_R_BUF_LIB);
499 } 501 }
502 OPENSSL_free(b);
500 return(ret); 503 return(ret);
501 } 504 }
502 505
diff --git a/src/lib/libcrypto/asn1/t_x509a.c b/src/lib/libcrypto/asn1/t_x509a.c
index 7d4a6e6084..ffbbfb51f4 100644
--- a/src/lib/libcrypto/asn1/t_x509a.c
+++ b/src/lib/libcrypto/asn1/t_x509a.c
@@ -77,7 +77,7 @@ int X509_CERT_AUX_print(BIO *out, X509_CERT_AUX *aux, int indent)
77 for(i = 0; i < sk_ASN1_OBJECT_num(aux->trust); i++) { 77 for(i = 0; i < sk_ASN1_OBJECT_num(aux->trust); i++) {
78 if(!first) BIO_puts(out, ", "); 78 if(!first) BIO_puts(out, ", ");
79 else first = 0; 79 else first = 0;
80 OBJ_obj2txt(oidstr, 80, 80 OBJ_obj2txt(oidstr, sizeof oidstr,
81 sk_ASN1_OBJECT_value(aux->trust, i), 0); 81 sk_ASN1_OBJECT_value(aux->trust, i), 0);
82 BIO_puts(out, oidstr); 82 BIO_puts(out, oidstr);
83 } 83 }
@@ -90,7 +90,7 @@ int X509_CERT_AUX_print(BIO *out, X509_CERT_AUX *aux, int indent)
90 for(i = 0; i < sk_ASN1_OBJECT_num(aux->reject); i++) { 90 for(i = 0; i < sk_ASN1_OBJECT_num(aux->reject); i++) {
91 if(!first) BIO_puts(out, ", "); 91 if(!first) BIO_puts(out, ", ");
92 else first = 0; 92 else first = 0;
93 OBJ_obj2txt(oidstr, 80, 93 OBJ_obj2txt(oidstr, sizeof oidstr,
94 sk_ASN1_OBJECT_value(aux->reject, i), 0); 94 sk_ASN1_OBJECT_value(aux->reject, i), 0);
95 BIO_puts(out, oidstr); 95 BIO_puts(out, oidstr);
96 } 96 }
diff --git a/src/lib/libcrypto/asn1/tasn_dec.c b/src/lib/libcrypto/asn1/tasn_dec.c
index f87c08793a..76fc023230 100644
--- a/src/lib/libcrypto/asn1/tasn_dec.c
+++ b/src/lib/libcrypto/asn1/tasn_dec.c
@@ -664,7 +664,7 @@ static int asn1_d2i_ex_primitive(ASN1_VALUE **pval, unsigned char **in, long inl
664 if(!asn1_collect(&buf, &p, plen, inf, -1, V_ASN1_UNIVERSAL)) goto err; 664 if(!asn1_collect(&buf, &p, plen, inf, -1, V_ASN1_UNIVERSAL)) goto err;
665 len = buf.length; 665 len = buf.length;
666 /* Append a final null to string */ 666 /* Append a final null to string */
667 if(!BUF_MEM_grow(&buf, len + 1)) { 667 if(!BUF_MEM_grow_clean(&buf, len + 1)) {
668 ASN1err(ASN1_F_ASN1_D2I_EX_PRIMITIVE, ERR_R_MALLOC_FAILURE); 668 ASN1err(ASN1_F_ASN1_D2I_EX_PRIMITIVE, ERR_R_MALLOC_FAILURE);
669 return 0; 669 return 0;
670 } 670 }
@@ -857,7 +857,7 @@ static int collect_data(BUF_MEM *buf, unsigned char **p, long plen)
857 int len; 857 int len;
858 if(buf) { 858 if(buf) {
859 len = buf->length; 859 len = buf->length;
860 if(!BUF_MEM_grow(buf, len + plen)) { 860 if(!BUF_MEM_grow_clean(buf, len + plen)) {
861 ASN1err(ASN1_F_COLLECT_DATA, ERR_R_MALLOC_FAILURE); 861 ASN1err(ASN1_F_COLLECT_DATA, ERR_R_MALLOC_FAILURE);
862 return 0; 862 return 0;
863 } 863 }
diff --git a/src/lib/libcrypto/asn1/tasn_fre.c b/src/lib/libcrypto/asn1/tasn_fre.c
index c7610776f2..2dd844159e 100644
--- a/src/lib/libcrypto/asn1/tasn_fre.c
+++ b/src/lib/libcrypto/asn1/tasn_fre.c
@@ -206,7 +206,10 @@ void ASN1_primitive_free(ASN1_VALUE **pval, const ASN1_ITEM *it)
206 break; 206 break;
207 207
208 case V_ASN1_BOOLEAN: 208 case V_ASN1_BOOLEAN:
209 *(ASN1_BOOLEAN *)pval = it->size; 209 if (it)
210 *(ASN1_BOOLEAN *)pval = it->size;
211 else
212 *(ASN1_BOOLEAN *)pval = -1;
210 return; 213 return;
211 214
212 case V_ASN1_NULL: 215 case V_ASN1_NULL:
diff --git a/src/lib/libcrypto/asn1/tasn_new.c b/src/lib/libcrypto/asn1/tasn_new.c
index e33861f864..a0e3db574f 100644
--- a/src/lib/libcrypto/asn1/tasn_new.c
+++ b/src/lib/libcrypto/asn1/tasn_new.c
@@ -305,7 +305,10 @@ int ASN1_primitive_new(ASN1_VALUE **pval, const ASN1_ITEM *it)
305 return 1; 305 return 1;
306 306
307 case V_ASN1_BOOLEAN: 307 case V_ASN1_BOOLEAN:
308 *(ASN1_BOOLEAN *)pval = it->size; 308 if (it)
309 *(ASN1_BOOLEAN *)pval = it->size;
310 else
311 *(ASN1_BOOLEAN *)pval = -1;
309 return 1; 312 return 1;
310 313
311 case V_ASN1_NULL: 314 case V_ASN1_NULL:
diff --git a/src/lib/libcrypto/asn1/tasn_prn.c b/src/lib/libcrypto/asn1/tasn_prn.c
index fab67ae5ac..719639b511 100644
--- a/src/lib/libcrypto/asn1/tasn_prn.c
+++ b/src/lib/libcrypto/asn1/tasn_prn.c
@@ -186,7 +186,7 @@ if(*bool == -1) printf("BOOL MISSING\n");
186 char objbuf[80], *ln; 186 char objbuf[80], *ln;
187 ln = OBJ_nid2ln(OBJ_obj2nid(fld)); 187 ln = OBJ_nid2ln(OBJ_obj2nid(fld));
188 if(!ln) ln = ""; 188 if(!ln) ln = "";
189 OBJ_obj2txt(objbuf, 80, fld, 1); 189 OBJ_obj2txt(objbuf, sizeof objbuf, fld, 1);
190 BIO_printf(out, "%*s%s:%s (%s)", indent, "", "OBJECT", ln, objbuf); 190 BIO_printf(out, "%*s%s:%s (%s)", indent, "", "OBJECT", ln, objbuf);
191 } else { 191 } else {
192 BIO_printf(out, "%*s%s:", indent, "", name); 192 BIO_printf(out, "%*s%s:", indent, "", name);
diff --git a/src/lib/libcrypto/bf/Makefile.ssl b/src/lib/libcrypto/bf/Makefile.ssl
index 079f7e860c..7dfdf9d871 100644
--- a/src/lib/libcrypto/bf/Makefile.ssl
+++ b/src/lib/libcrypto/bf/Makefile.ssl
@@ -49,14 +49,8 @@ lib: $(LIBOBJ)
49 @touch lib 49 @touch lib
50 50
51# elf 51# elf
52asm/bx86-elf.o: asm/bx86unix.cpp 52asm/bx86-elf.s: asm/bf-586.pl ../perlasm/x86asm.pl ../perlasm/cbc.pl
53 $(CPP) -DELF -x c asm/bx86unix.cpp | as -o asm/bx86-elf.o 53 (cd asm; $(PERL) bf-586.pl elf $(CFLAGS) $(PROCESSOR) > bx86-elf.s)
54
55# solaris
56asm/bx86-sol.o: asm/bx86unix.cpp
57 $(CC) -E -DSOL asm/bx86unix.cpp | sed 's/^#.*//' > asm/bx86-sol.s
58 as -o asm/bx86-sol.o asm/bx86-sol.s
59 rm -f asm/bx86-sol.s
60 54
61# a.out 55# a.out
62asm/bx86-out.o: asm/bx86unix.cpp 56asm/bx86-out.o: asm/bx86unix.cpp
@@ -96,14 +90,14 @@ lint:
96 lint -DLINT $(INCLUDES) $(SRC)>fluff 90 lint -DLINT $(INCLUDES) $(SRC)>fluff
97 91
98depend: 92depend:
99 $(MAKEDEPEND) $(CFLAG) $(INCLUDES) $(DEPFLAG) $(PROGS) $(LIBSRC) 93 $(MAKEDEPEND) -- $(CFLAG) $(INCLUDES) $(DEPFLAG) -- $(PROGS) $(LIBSRC)
100 94
101dclean: 95dclean:
102 $(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new 96 $(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
103 mv -f Makefile.new $(MAKEFILE) 97 mv -f Makefile.new $(MAKEFILE)
104 98
105clean: 99clean:
106 rm -f asm/bx86unix.cpp *.o asm/*.o *.obj lib tags core .pure .nfs* *.old *.bak fluff 100 rm -f asm/bx86unix.cpp asm/*-elf.* *.o asm/*.o *.obj lib tags core .pure .nfs* *.old *.bak fluff
107 101
108# DO NOT DELETE THIS LINE -- make depend depends on it. 102# DO NOT DELETE THIS LINE -- make depend depends on it.
109 103
diff --git a/src/lib/libcrypto/bf/bftest.c b/src/lib/libcrypto/bf/bftest.c
index 09895f2542..24d526b14b 100644
--- a/src/lib/libcrypto/bf/bftest.c
+++ b/src/lib/libcrypto/bf/bftest.c
@@ -63,6 +63,8 @@
63#include <string.h> 63#include <string.h>
64#include <stdlib.h> 64#include <stdlib.h>
65 65
66#include "../e_os.h"
67
66#ifdef OPENSSL_NO_BF 68#ifdef OPENSSL_NO_BF
67int main(int argc, char *argv[]) 69int main(int argc, char *argv[])
68{ 70{
@@ -275,7 +277,7 @@ int main(int argc, char *argv[])
275 else 277 else
276 ret=test(); 278 ret=test();
277 279
278 exit(ret); 280 EXIT(ret);
279 return(0); 281 return(0);
280 } 282 }
281 283
@@ -454,9 +456,9 @@ static int test(void)
454 len=strlen(cbc_data)+1; 456 len=strlen(cbc_data)+1;
455 457
456 BF_set_key(&key,16,cbc_key); 458 BF_set_key(&key,16,cbc_key);
457 memset(cbc_in,0,40); 459 memset(cbc_in,0,sizeof cbc_in);
458 memset(cbc_out,0,40); 460 memset(cbc_out,0,sizeof cbc_out);
459 memcpy(iv,cbc_iv,8); 461 memcpy(iv,cbc_iv,sizeof iv);
460 BF_cbc_encrypt((unsigned char *)cbc_data,cbc_out,len, 462 BF_cbc_encrypt((unsigned char *)cbc_data,cbc_out,len,
461 &key,iv,BF_ENCRYPT); 463 &key,iv,BF_ENCRYPT);
462 if (memcmp(cbc_out,cbc_ok,32) != 0) 464 if (memcmp(cbc_out,cbc_ok,32) != 0)
diff --git a/src/lib/libcrypto/bio/Makefile.ssl b/src/lib/libcrypto/bio/Makefile.ssl
index dfcee03448..d0b9e297b0 100644
--- a/src/lib/libcrypto/bio/Makefile.ssl
+++ b/src/lib/libcrypto/bio/Makefile.ssl
@@ -78,7 +78,7 @@ lint:
78 lint -DLINT $(INCLUDES) $(SRC)>fluff 78 lint -DLINT $(INCLUDES) $(SRC)>fluff
79 79
80depend: 80depend:
81 $(MAKEDEPEND) $(CFLAG) $(INCLUDES) $(DEPFLAG) $(PROGS) $(LIBSRC) 81 $(MAKEDEPEND) -- $(CFLAG) $(INCLUDES) $(DEPFLAG) -- $(PROGS) $(LIBSRC)
82 82
83dclean: 83dclean:
84 $(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new 84 $(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
diff --git a/src/lib/libcrypto/bio/b_print.c b/src/lib/libcrypto/bio/b_print.c
index 80c9cb69db..a9e552f245 100644
--- a/src/lib/libcrypto/bio/b_print.c
+++ b/src/lib/libcrypto/bio/b_print.c
@@ -378,7 +378,7 @@ _dopr(
378 case 'p': 378 case 'p':
379 value = (long)va_arg(args, void *); 379 value = (long)va_arg(args, void *);
380 fmtint(sbuffer, buffer, &currlen, maxlen, 380 fmtint(sbuffer, buffer, &currlen, maxlen,
381 value, 16, min, max, flags); 381 value, 16, min, max, flags|DP_F_NUM);
382 break; 382 break;
383 case 'n': /* XXX */ 383 case 'n': /* XXX */
384 if (cflags == DP_C_SHORT) { 384 if (cflags == DP_C_SHORT) {
@@ -482,8 +482,9 @@ fmtint(
482 int flags) 482 int flags)
483{ 483{
484 int signvalue = 0; 484 int signvalue = 0;
485 char *prefix = "";
485 unsigned LLONG uvalue; 486 unsigned LLONG uvalue;
486 char convert[20]; 487 char convert[DECIMAL_SIZE(value)+3];
487 int place = 0; 488 int place = 0;
488 int spadlen = 0; 489 int spadlen = 0;
489 int zpadlen = 0; 490 int zpadlen = 0;
@@ -501,6 +502,10 @@ fmtint(
501 else if (flags & DP_F_SPACE) 502 else if (flags & DP_F_SPACE)
502 signvalue = ' '; 503 signvalue = ' ';
503 } 504 }
505 if (flags & DP_F_NUM) {
506 if (base == 8) prefix = "0";
507 if (base == 16) prefix = "0x";
508 }
504 if (flags & DP_F_UP) 509 if (flags & DP_F_UP)
505 caps = 1; 510 caps = 1;
506 do { 511 do {
@@ -508,13 +513,13 @@ fmtint(
508 (caps ? "0123456789ABCDEF" : "0123456789abcdef") 513 (caps ? "0123456789ABCDEF" : "0123456789abcdef")
509 [uvalue % (unsigned) base]; 514 [uvalue % (unsigned) base];
510 uvalue = (uvalue / (unsigned) base); 515 uvalue = (uvalue / (unsigned) base);
511 } while (uvalue && (place < 20)); 516 } while (uvalue && (place < sizeof convert));
512 if (place == 20) 517 if (place == sizeof convert)
513 place--; 518 place--;
514 convert[place] = 0; 519 convert[place] = 0;
515 520
516 zpadlen = max - place; 521 zpadlen = max - place;
517 spadlen = min - OSSL_MAX(max, place) - (signvalue ? 1 : 0); 522 spadlen = min - OSSL_MAX(max, place) - (signvalue ? 1 : 0) - strlen(prefix);
518 if (zpadlen < 0) 523 if (zpadlen < 0)
519 zpadlen = 0; 524 zpadlen = 0;
520 if (spadlen < 0) 525 if (spadlen < 0)
@@ -536,6 +541,12 @@ fmtint(
536 if (signvalue) 541 if (signvalue)
537 doapr_outch(sbuffer, buffer, currlen, maxlen, signvalue); 542 doapr_outch(sbuffer, buffer, currlen, maxlen, signvalue);
538 543
544 /* prefix */
545 while (*prefix) {
546 doapr_outch(sbuffer, buffer, currlen, maxlen, *prefix);
547 prefix++;
548 }
549
539 /* zeros */ 550 /* zeros */
540 if (zpadlen > 0) { 551 if (zpadlen > 0) {
541 while (zpadlen > 0) { 552 while (zpadlen > 0) {
@@ -641,8 +652,8 @@ fmtfp(
641 (caps ? "0123456789ABCDEF" 652 (caps ? "0123456789ABCDEF"
642 : "0123456789abcdef")[intpart % 10]; 653 : "0123456789abcdef")[intpart % 10];
643 intpart = (intpart / 10); 654 intpart = (intpart / 10);
644 } while (intpart && (iplace < 20)); 655 } while (intpart && (iplace < sizeof iplace));
645 if (iplace == 20) 656 if (iplace == sizeof iplace)
646 iplace--; 657 iplace--;
647 iconvert[iplace] = 0; 658 iconvert[iplace] = 0;
648 659
@@ -653,7 +664,7 @@ fmtfp(
653 : "0123456789abcdef")[fracpart % 10]; 664 : "0123456789abcdef")[fracpart % 10];
654 fracpart = (fracpart / 10); 665 fracpart = (fracpart / 10);
655 } while (fplace < max); 666 } while (fplace < max);
656 if (fplace == 20) 667 if (fplace == sizeof fplace)
657 fplace--; 668 fplace--;
658 fconvert[fplace] = 0; 669 fconvert[fplace] = 0;
659 670
@@ -692,7 +703,7 @@ fmtfp(
692 * Decimal point. This should probably use locale to find the correct 703 * Decimal point. This should probably use locale to find the correct
693 * char to print out. 704 * char to print out.
694 */ 705 */
695 if (max > 0) { 706 if (max > 0 || (flags & DP_F_NUM)) {
696 doapr_outch(sbuffer, buffer, currlen, maxlen, '.'); 707 doapr_outch(sbuffer, buffer, currlen, maxlen, '.');
697 708
698 while (fplace > 0) 709 while (fplace > 0)
diff --git a/src/lib/libcrypto/bio/b_sock.c b/src/lib/libcrypto/bio/b_sock.c
index 7632c2d85e..5282f8a8f7 100644
--- a/src/lib/libcrypto/bio/b_sock.c
+++ b/src/lib/libcrypto/bio/b_sock.c
@@ -83,6 +83,7 @@
83static int wsa_init_done=0; 83static int wsa_init_done=0;
84#endif 84#endif
85 85
86#if 0
86static unsigned long BIO_ghbn_hits=0L; 87static unsigned long BIO_ghbn_hits=0L;
87static unsigned long BIO_ghbn_miss=0L; 88static unsigned long BIO_ghbn_miss=0L;
88 89
@@ -93,6 +94,7 @@ static struct ghbn_cache_st
93 struct hostent *ent; 94 struct hostent *ent;
94 unsigned long order; 95 unsigned long order;
95 } ghbn_cache[GHBN_NUM]; 96 } ghbn_cache[GHBN_NUM];
97#endif
96 98
97static int get_ip(const char *str,unsigned char *ip); 99static int get_ip(const char *str,unsigned char *ip);
98#if 0 100#if 0
@@ -230,6 +232,7 @@ int BIO_sock_error(int sock)
230 return(j); 232 return(j);
231 } 233 }
232 234
235#if 0
233long BIO_ghbn_ctrl(int cmd, int iarg, char *parg) 236long BIO_ghbn_ctrl(int cmd, int iarg, char *parg)
234 { 237 {
235 int i; 238 int i;
@@ -267,6 +270,7 @@ long BIO_ghbn_ctrl(int cmd, int iarg, char *parg)
267 } 270 }
268 return(1); 271 return(1);
269 } 272 }
273#endif
270 274
271#if 0 275#if 0
272static struct hostent *ghbn_dup(struct hostent *a) 276static struct hostent *ghbn_dup(struct hostent *a)
@@ -463,6 +467,12 @@ int BIO_sock_init(void)
463 } 467 }
464 } 468 }
465#endif /* OPENSSL_SYS_WINDOWS */ 469#endif /* OPENSSL_SYS_WINDOWS */
470#ifdef WATT32
471 extern int _watt_do_exit;
472 _watt_do_exit = 0; /* don't make sock_init() call exit() */
473 if (sock_init())
474 return (-1);
475#endif
466 return(1); 476 return(1);
467 } 477 }
468 478
@@ -472,7 +482,9 @@ void BIO_sock_cleanup(void)
472 if (wsa_init_done) 482 if (wsa_init_done)
473 { 483 {
474 wsa_init_done=0; 484 wsa_init_done=0;
485#ifndef OPENSSL_SYS_WINCE
475 WSACancelBlockingCall(); 486 WSACancelBlockingCall();
487#endif
476 WSACleanup(); 488 WSACleanup();
477 } 489 }
478#endif 490#endif
@@ -480,7 +492,7 @@ void BIO_sock_cleanup(void)
480 492
481#if !defined(OPENSSL_SYS_VMS) || __VMS_VER >= 70000000 493#if !defined(OPENSSL_SYS_VMS) || __VMS_VER >= 70000000
482 494
483int BIO_socket_ioctl(int fd, long type, unsigned long *arg) 495int BIO_socket_ioctl(int fd, long type, void *arg)
484 { 496 {
485 int i; 497 int i;
486 498
@@ -730,7 +742,7 @@ int BIO_set_tcp_ndelay(int s, int on)
730int BIO_socket_nbio(int s, int mode) 742int BIO_socket_nbio(int s, int mode)
731 { 743 {
732 int ret= -1; 744 int ret= -1;
733 unsigned long l; 745 int l;
734 746
735 l=mode; 747 l=mode;
736#ifdef FIONBIO 748#ifdef FIONBIO
diff --git a/src/lib/libcrypto/bio/bf_buff.c b/src/lib/libcrypto/bio/bf_buff.c
index 6ccda06596..1cecd70579 100644
--- a/src/lib/libcrypto/bio/bf_buff.c
+++ b/src/lib/libcrypto/bio/bf_buff.c
@@ -482,7 +482,7 @@ static int buffer_gets(BIO *b, char *buf, int size)
482 size-=i; 482 size-=i;
483 ctx->ibuf_len-=i; 483 ctx->ibuf_len-=i;
484 ctx->ibuf_off+=i; 484 ctx->ibuf_off+=i;
485 if ((flag) || (i == size)) 485 if (flag || size == 0)
486 { 486 {
487 *buf='\0'; 487 *buf='\0';
488 return(num); 488 return(num);
diff --git a/src/lib/libcrypto/bio/bio.h b/src/lib/libcrypto/bio/bio.h
index c5caf253c9..fbbc16d00c 100644
--- a/src/lib/libcrypto/bio/bio.h
+++ b/src/lib/libcrypto/bio/bio.h
@@ -244,7 +244,7 @@ typedef struct bio_method_st
244 long (_far *ctrl)(); 244 long (_far *ctrl)();
245 int (_far *create)(); 245 int (_far *create)();
246 int (_far *destroy)(); 246 int (_far *destroy)();
247 long (_fat *callback_ctrl)(); 247 long (_far *callback_ctrl)();
248 } BIO_METHOD; 248 } BIO_METHOD;
249#endif 249#endif
250 250
@@ -522,6 +522,7 @@ int BIO_read(BIO *b, void *data, int len);
522int BIO_gets(BIO *bp,char *buf, int size); 522int BIO_gets(BIO *bp,char *buf, int size);
523int BIO_write(BIO *b, const void *data, int len); 523int BIO_write(BIO *b, const void *data, int len);
524int BIO_puts(BIO *bp,const char *buf); 524int BIO_puts(BIO *bp,const char *buf);
525int BIO_indent(BIO *b,int indent,int max);
525long BIO_ctrl(BIO *bp,int cmd,long larg,void *parg); 526long BIO_ctrl(BIO *bp,int cmd,long larg,void *parg);
526long BIO_callback_ctrl(BIO *b, int cmd, void (*fp)(struct bio_st *, int, const char *, int, long, long)); 527long BIO_callback_ctrl(BIO *b, int cmd, void (*fp)(struct bio_st *, int, const char *, int, long, long));
527char * BIO_ptr_ctrl(BIO *bp,int cmd,long larg); 528char * BIO_ptr_ctrl(BIO *bp,int cmd,long larg);
@@ -584,7 +585,7 @@ struct hostent *BIO_gethostbyname(const char *name);
584 * and an appropriate error code is set). 585 * and an appropriate error code is set).
585 */ 586 */
586int BIO_sock_error(int sock); 587int BIO_sock_error(int sock);
587int BIO_socket_ioctl(int fd, long type, unsigned long *arg); 588int BIO_socket_ioctl(int fd, long type, void *arg);
588int BIO_socket_nbio(int fd,int mode); 589int BIO_socket_nbio(int fd,int mode);
589int BIO_get_port(const char *str, unsigned short *port_ptr); 590int BIO_get_port(const char *str, unsigned short *port_ptr);
590int BIO_get_host_ip(const char *str, unsigned char *ip); 591int BIO_get_host_ip(const char *str, unsigned char *ip);
@@ -608,7 +609,7 @@ int BIO_new_bio_pair(BIO **bio1, size_t writebuf1,
608 609
609void BIO_copy_next_retry(BIO *b); 610void BIO_copy_next_retry(BIO *b);
610 611
611long BIO_ghbn_ctrl(int cmd,int iarg,char *parg); 612/*long BIO_ghbn_ctrl(int cmd,int iarg,char *parg);*/
612 613
613int BIO_printf(BIO *bio, const char *format, ...); 614int BIO_printf(BIO *bio, const char *format, ...);
614int BIO_vprintf(BIO *bio, const char *format, va_list args); 615int BIO_vprintf(BIO *bio, const char *format, va_list args);
diff --git a/src/lib/libcrypto/bio/bio_lib.c b/src/lib/libcrypto/bio/bio_lib.c
index 50df2238fa..692c8fb5c6 100644
--- a/src/lib/libcrypto/bio/bio_lib.c
+++ b/src/lib/libcrypto/bio/bio_lib.c
@@ -272,6 +272,18 @@ int BIO_gets(BIO *b, char *in, int inl)
272 return(i); 272 return(i);
273 } 273 }
274 274
275int BIO_indent(BIO *b,int indent,int max)
276 {
277 if(indent < 0)
278 indent=0;
279 if(indent > max)
280 indent=max;
281 while(indent--)
282 if(BIO_puts(b," ") != 1)
283 return 0;
284 return 1;
285 }
286
275long BIO_int_ctrl(BIO *b, int cmd, long larg, int iarg) 287long BIO_int_ctrl(BIO *b, int cmd, long larg, int iarg)
276 { 288 {
277 int i; 289 int i;
@@ -383,6 +395,8 @@ BIO *BIO_pop(BIO *b)
383 if (b == NULL) return(NULL); 395 if (b == NULL) return(NULL);
384 ret=b->next_bio; 396 ret=b->next_bio;
385 397
398 BIO_ctrl(b,BIO_CTRL_POP,0,NULL);
399
386 if (b->prev_bio != NULL) 400 if (b->prev_bio != NULL)
387 b->prev_bio->next_bio=b->next_bio; 401 b->prev_bio->next_bio=b->next_bio;
388 if (b->next_bio != NULL) 402 if (b->next_bio != NULL)
@@ -390,7 +404,6 @@ BIO *BIO_pop(BIO *b)
390 404
391 b->next_bio=NULL; 405 b->next_bio=NULL;
392 b->prev_bio=NULL; 406 b->prev_bio=NULL;
393 BIO_ctrl(b,BIO_CTRL_POP,0,NULL);
394 return(ret); 407 return(ret);
395 } 408 }
396 409
diff --git a/src/lib/libcrypto/bio/bss_bio.c b/src/lib/libcrypto/bio/bss_bio.c
index 1c485a4479..aa58dab046 100644
--- a/src/lib/libcrypto/bio/bss_bio.c
+++ b/src/lib/libcrypto/bio/bss_bio.c
@@ -28,13 +28,12 @@
28 28
29#include <openssl/bio.h> 29#include <openssl/bio.h>
30#include <openssl/err.h> 30#include <openssl/err.h>
31#include <openssl/err.h>
32#include <openssl/crypto.h> 31#include <openssl/crypto.h>
33 32
34#include "e_os.h" 33#include "e_os.h"
35 34
36/* VxWorks defines SSIZE_MAX with an empty value causing compile errors */ 35/* VxWorks defines SSIZE_MAX with an empty value causing compile errors */
37#if defined(OPENSSL_SYS_VSWORKS) 36#if defined(OPENSSL_SYS_VXWORKS)
38# undef SSIZE_MAX 37# undef SSIZE_MAX
39#endif 38#endif
40#ifndef SSIZE_MAX 39#ifndef SSIZE_MAX
diff --git a/src/lib/libcrypto/bio/bss_conn.c b/src/lib/libcrypto/bio/bss_conn.c
index 81f27dba4c..8c694140ed 100644
--- a/src/lib/libcrypto/bio/bss_conn.c
+++ b/src/lib/libcrypto/bio/bss_conn.c
@@ -519,7 +519,7 @@ static long conn_ctrl(BIO *b, int cmd, long num, void *ptr)
519 else if (num == 2) 519 else if (num == 2)
520 { 520 {
521 char buf[16]; 521 char buf[16];
522 char *p = ptr; 522 unsigned char *p = ptr;
523 523
524 snprintf(buf,sizeof buf,"%d.%d.%d.%d", 524 snprintf(buf,sizeof buf,"%d.%d.%d.%d",
525 p[0],p[1],p[2],p[3]); 525 p[0],p[1],p[2],p[3]);
@@ -530,7 +530,7 @@ static long conn_ctrl(BIO *b, int cmd, long num, void *ptr)
530 } 530 }
531 else if (num == 3) 531 else if (num == 3)
532 { 532 {
533 char buf[16]; 533 char buf[DECIMAL_SIZE(int)+1];
534 534
535 snprintf(buf,sizeof buf,"%d",*(int *)ptr); 535 snprintf(buf,sizeof buf,"%d",*(int *)ptr);
536 if (data->param_port != NULL) 536 if (data->param_port != NULL)
diff --git a/src/lib/libcrypto/bio/bss_file.c b/src/lib/libcrypto/bio/bss_file.c
index 18e7bb86e6..e4e9df144c 100644
--- a/src/lib/libcrypto/bio/bss_file.c
+++ b/src/lib/libcrypto/bio/bss_file.c
@@ -247,7 +247,7 @@ static long MS_CALLBACK file_ctrl(BIO *b, int cmd, long num, void *ptr)
247 ret=0; 247 ret=0;
248 break; 248 break;
249 } 249 }
250#if defined(OPENSSL_SYS_MSDOS) || defined(OPENSSL_SYS_WINDOWS) 250#if defined(OPENSSL_SYS_MSDOS) || defined(OPENSSL_SYS_WINDOWS) || defined(OPENSSL_SYS_OS2)
251 if (!(num & BIO_FP_TEXT)) 251 if (!(num & BIO_FP_TEXT))
252 strcat(p,"b"); 252 strcat(p,"b");
253 else 253 else
diff --git a/src/lib/libcrypto/bio/bss_log.c b/src/lib/libcrypto/bio/bss_log.c
index a39d95297c..1eb678cac0 100644
--- a/src/lib/libcrypto/bio/bss_log.c
+++ b/src/lib/libcrypto/bio/bss_log.c
@@ -68,7 +68,8 @@
68 68
69#include "cryptlib.h" 69#include "cryptlib.h"
70 70
71#if defined(OPENSSL_SYS_WIN32) 71#if defined(OPENSSL_SYS_WINCE)
72#elif defined(OPENSSL_SYS_WIN32)
72# include <process.h> 73# include <process.h>
73#elif defined(OPENSSL_SYS_VMS) 74#elif defined(OPENSSL_SYS_VMS)
74# include <opcdef.h> 75# include <opcdef.h>
@@ -77,7 +78,7 @@
77# include <starlet.h> 78# include <starlet.h>
78#elif defined(__ultrix) 79#elif defined(__ultrix)
79# include <sys/syslog.h> 80# include <sys/syslog.h>
80#elif !defined(MSDOS) && !defined(OPENSSL_SYS_VXWORKS) && !defined(NO_SYSLOG) /* Unix */ 81#elif (!defined(MSDOS) || defined(WATT32)) && !defined(OPENSSL_SYS_VXWORKS) && !defined(NO_SYSLOG)
81# include <syslog.h> 82# include <syslog.h>
82#endif 83#endif
83 84
@@ -274,7 +275,7 @@ static void xsyslog(BIO *bp, int priority, const char *string)
274 LPCSTR lpszStrings[2]; 275 LPCSTR lpszStrings[2];
275 WORD evtype= EVENTLOG_ERROR_TYPE; 276 WORD evtype= EVENTLOG_ERROR_TYPE;
276 int pid = _getpid(); 277 int pid = _getpid();
277 char pidbuf[20]; 278 char pidbuf[DECIMAL_SIZE(pid)+4];
278 279
279 switch (priority) 280 switch (priority)
280 { 281 {
@@ -373,11 +374,15 @@ static void xcloselog(BIO* bp)
373{ 374{
374} 375}
375 376
376#else /* Unix */ 377#else /* Unix/Watt32 */
377 378
378static void xopenlog(BIO* bp, char* name, int level) 379static void xopenlog(BIO* bp, char* name, int level)
379{ 380{
381#ifdef WATT32 /* djgpp/DOS */
382 openlog(name, LOG_PID|LOG_CONS|LOG_NDELAY, level);
383#else
380 openlog(name, LOG_PID|LOG_CONS, level); 384 openlog(name, LOG_PID|LOG_CONS, level);
385#endif
381} 386}
382 387
383static void xsyslog(BIO *bp, int priority, const char *string) 388static void xsyslog(BIO *bp, int priority, const char *string)
diff --git a/src/lib/libcrypto/bio/bss_mem.c b/src/lib/libcrypto/bio/bss_mem.c
index 28ff7582bf..a4edb711ae 100644
--- a/src/lib/libcrypto/bio/bss_mem.c
+++ b/src/lib/libcrypto/bio/bss_mem.c
@@ -190,7 +190,7 @@ static int mem_write(BIO *b, const char *in, int inl)
190 190
191 BIO_clear_retry_flags(b); 191 BIO_clear_retry_flags(b);
192 blen=bm->length; 192 blen=bm->length;
193 if (BUF_MEM_grow(bm,blen+inl) != (blen+inl)) 193 if (BUF_MEM_grow_clean(bm,blen+inl) != (blen+inl))
194 goto end; 194 goto end;
195 memcpy(&(bm->data[blen]),in,inl); 195 memcpy(&(bm->data[blen]),in,inl);
196 ret=inl; 196 ret=inl;
@@ -284,7 +284,11 @@ static int mem_gets(BIO *bp, char *buf, int size)
284 284
285 BIO_clear_retry_flags(bp); 285 BIO_clear_retry_flags(bp);
286 j=bm->length; 286 j=bm->length;
287 if (j <= 0) return(0); 287 if (j <= 0)
288 {
289 *buf='\0';
290 return 0;
291 }
288 p=bm->data; 292 p=bm->data;
289 for (i=0; i<j; i++) 293 for (i=0; i<j; i++)
290 { 294 {
diff --git a/src/lib/libcrypto/bio/bss_sock.c b/src/lib/libcrypto/bio/bss_sock.c
index fdabd16d7e..2c1c405ec7 100644
--- a/src/lib/libcrypto/bio/bss_sock.c
+++ b/src/lib/libcrypto/bio/bss_sock.c
@@ -64,6 +64,12 @@
64#include "cryptlib.h" 64#include "cryptlib.h"
65#include <openssl/bio.h> 65#include <openssl/bio.h>
66 66
67#ifdef WATT32
68#define sock_write SockWrite /* Watt-32 uses same names */
69#define sock_read SockRead
70#define sock_puts SockPuts
71#endif
72
67static int sock_write(BIO *h, const char *buf, int num); 73static int sock_write(BIO *h, const char *buf, int num);
68static int sock_read(BIO *h, char *buf, int size); 74static int sock_read(BIO *h, char *buf, int size);
69static int sock_puts(BIO *h, const char *str); 75static int sock_puts(BIO *h, const char *str);
diff --git a/src/lib/libcrypto/bn/Makefile.ssl b/src/lib/libcrypto/bn/Makefile.ssl
index 6a479726c4..fa17d3c7d8 100644
--- a/src/lib/libcrypto/bn/Makefile.ssl
+++ b/src/lib/libcrypto/bn/Makefile.ssl
@@ -23,14 +23,6 @@ BN_ASM= bn_asm.o
23 23
24CFLAGS= $(INCLUDES) $(CFLAG) 24CFLAGS= $(INCLUDES) $(CFLAG)
25 25
26# We let the C compiler driver to take care of .s files. This is done in
27# order to be excused from maintaining a separate set of architecture
28# dependent assembler flags. E.g. if you throw -mcpu=ultrasparc at SPARC
29# gcc, then the driver will automatically translate it to -xarch=v8plus
30# and pass it down to assembler.
31AS=$(CC) -c
32ASFLAGS=$(CFLAGS)
33
34GENERAL=Makefile 26GENERAL=Makefile
35TEST=bntest.c exptest.c 27TEST=bntest.c exptest.c
36APPS= 28APPS=
@@ -73,22 +65,11 @@ lib: $(LIBOBJ)
73 @touch lib 65 @touch lib
74 66
75# elf 67# elf
76asm/bn86-elf.o: asm/bn86unix.cpp 68asm/bn86-elf.s: asm/bn-586.pl ../perlasm/x86asm.pl
77 $(CPP) -DELF -x c asm/bn86unix.cpp | as -o asm/bn86-elf.o 69 (cd asm; $(PERL) bn-586.pl elf $(CFLAGS) > bn86-elf.s)
78
79asm/co86-elf.o: asm/co86unix.cpp
80 $(CPP) -DELF -x c asm/co86unix.cpp | as -o asm/co86-elf.o
81 70
82# solaris 71asm/co86-elf.s: asm/co-586.pl ../perlasm/x86asm.pl
83asm/bn86-sol.o: asm/bn86unix.cpp 72 (cd asm; $(PERL) co-586.pl elf $(CFLAGS) > co86-elf.s)
84 $(CC) -E -DSOL asm/bn86unix.cpp | sed 's/^#.*//' > asm/bn86-sol.s
85 as -o asm/bn86-sol.o asm/bn86-sol.s
86 rm -f asm/bn86-sol.s
87
88asm/co86-sol.o: asm/co86unix.cpp
89 $(CC) -E -DSOL asm/co86unix.cpp | sed 's/^#.*//' > asm/co86-sol.s
90 as -o asm/co86-sol.o asm/co86-sol.s
91 rm -f asm/co86-sol.s
92 73
93# a.out 74# a.out
94asm/bn86-out.o: asm/bn86unix.cpp 75asm/bn86-out.o: asm/bn86unix.cpp
@@ -136,6 +117,8 @@ asm/ia64-cpp.o: asm/ia64.S
136 $(CC) $(ASFLAGS) -c -o asm/ia64-cpp.o /tmp/ia64.$$$$.s; \ 117 $(CC) $(ASFLAGS) -c -o asm/ia64-cpp.o /tmp/ia64.$$$$.s; \
137 rm -f /tmp/ia64.$$$$.s 118 rm -f /tmp/ia64.$$$$.s
138 119
120asm/x86_64-gcc.o: asm/x86_64-gcc.c
121
139files: 122files:
140 $(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO 123 $(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO
141 124
@@ -169,14 +152,14 @@ lint:
169 lint -DLINT $(INCLUDES) $(SRC)>fluff 152 lint -DLINT $(INCLUDES) $(SRC)>fluff
170 153
171depend: 154depend:
172 $(MAKEDEPEND) $(CFLAG) $(INCLUDES) $(DEPFLAG) $(PROGS) $(LIBSRC) 155 $(MAKEDEPEND) -- $(CFLAG) $(INCLUDES) $(DEPFLAG) -- $(PROGS) $(LIBSRC)
173 156
174dclean: 157dclean:
175 $(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new 158 $(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
176 mv -f Makefile.new $(MAKEFILE) 159 mv -f Makefile.new $(MAKEFILE)
177 160
178clean: 161clean:
179 rm -f asm/co86unix.cpp asm/bn86unix.cpp *.o */*.o *.obj lib tags core .pure .nfs* *.old *.bak fluff bn_asm.s 162 rm -f asm/co86unix.cpp asm/bn86unix.cpp asm/*-elf.* *.o */*.o *.obj lib tags core .pure .nfs* *.old *.bak fluff bn_asm.s
180 163
181# DO NOT DELETE THIS LINE -- make depend depends on it. 164# DO NOT DELETE THIS LINE -- make depend depends on it.
182 165
diff --git a/src/lib/libcrypto/bn/asm/ia64.S b/src/lib/libcrypto/bn/asm/ia64.S
index ae56066310..7dfda85566 100644
--- a/src/lib/libcrypto/bn/asm/ia64.S
+++ b/src/lib/libcrypto/bn/asm/ia64.S
@@ -1,6 +1,6 @@
1.explicit 1.explicit
2.text 2.text
3.ident "ia64.S, Version 1.1" 3.ident "ia64.S, Version 2.0"
4.ident "IA-64 ISA artwork by Andy Polyakov <appro@fy.chalmers.se>" 4.ident "IA-64 ISA artwork by Andy Polyakov <appro@fy.chalmers.se>"
5 5
6// 6//
@@ -13,6 +13,35 @@
13// disclaimed. 13// disclaimed.
14// ==================================================================== 14// ====================================================================
15// 15//
16// Version 2.x is Itanium2 re-tune. Few words about how Itanum2 is
17// different from Itanium to this module viewpoint. Most notably, is it
18// "wider" than Itanium? Can you experience loop scalability as
19// discussed in commentary sections? Not really:-( Itanium2 has 6
20// integer ALU ports, i.e. it's 2 ports wider, but it's not enough to
21// spin twice as fast, as I need 8 IALU ports. Amount of floating point
22// ports is the same, i.e. 2, while I need 4. In other words, to this
23// module Itanium2 remains effectively as "wide" as Itanium. Yet it's
24// essentially different in respect to this module, and a re-tune was
25// required. Well, because some intruction latencies has changed. Most
26// noticeably those intensively used:
27//
28// Itanium Itanium2
29// ldf8 9 6 L2 hit
30// ld8 2 1 L1 hit
31// getf 2 5
32// xma[->getf] 7[+1] 4[+0]
33// add[->st8] 1[+1] 1[+0]
34//
35// What does it mean? You might ratiocinate that the original code
36// should run just faster... Because sum of latencies is smaller...
37// Wrong! Note that getf latency increased. This means that if a loop is
38// scheduled for lower latency (and they are), then it will suffer from
39// stall condition and the code will therefore turn anti-scalable, e.g.
40// original bn_mul_words spun at 5*n or 2.5 times slower than expected
41// on Itanium2! What to do? Reschedule loops for Itanium2? But then
42// Itanium would exhibit anti-scalability. So I've chosen to reschedule
43// for worst latency for every instruction aiming for best *all-round*
44// performance.
16 45
17// Q. How much faster does it get? 46// Q. How much faster does it get?
18// A. Here is the output from 'openssl speed rsa dsa' for vanilla 47// A. Here is the output from 'openssl speed rsa dsa' for vanilla
@@ -149,12 +178,27 @@ bn_add_words:
149 brp.loop.imp .L_bn_add_words_ctop,.L_bn_add_words_cend-16 178 brp.loop.imp .L_bn_add_words_ctop,.L_bn_add_words_cend-16
150 } 179 }
151 .body 180 .body
152{ .mib; mov r14=r32 // rp 181{ .mib;
182#if defined(_HPUX_SOURCE) && defined(_ILP32)
183 addp4 r14=0,r32 // rp
184#else
185 mov r14=r32 // rp
186#endif
153 mov r9=pr };; 187 mov r9=pr };;
154{ .mii; mov r15=r33 // ap 188{ .mii;
189#if defined(_HPUX_SOURCE) && defined(_ILP32)
190 addp4 r15=0,r33 // ap
191#else
192 mov r15=r33 // ap
193#endif
155 mov ar.lc=r10 194 mov ar.lc=r10
156 mov ar.ec=6 } 195 mov ar.ec=6 }
157{ .mib; mov r16=r34 // bp 196{ .mib;
197#if defined(_HPUX_SOURCE) && defined(_ILP32)
198 addp4 r16=0,r34 // bp
199#else
200 mov r16=r34 // bp
201#endif
158 mov pr.rot=1<<16 };; 202 mov pr.rot=1<<16 };;
159 203
160.L_bn_add_words_ctop: 204.L_bn_add_words_ctop:
@@ -174,7 +218,7 @@ bn_add_words:
174 218
175{ .mii; 219{ .mii;
176(p59) add r8=1,r8 // return value 220(p59) add r8=1,r8 // return value
177 mov pr=r9,-1 221 mov pr=r9,0x1ffff
178 mov ar.lc=r3 } 222 mov ar.lc=r3 }
179{ .mbb; nop.b 0x0 223{ .mbb; nop.b 0x0
180 br.ret.sptk.many b0 };; 224 br.ret.sptk.many b0 };;
@@ -202,12 +246,27 @@ bn_sub_words:
202 brp.loop.imp .L_bn_sub_words_ctop,.L_bn_sub_words_cend-16 246 brp.loop.imp .L_bn_sub_words_ctop,.L_bn_sub_words_cend-16
203 } 247 }
204 .body 248 .body
205{ .mib; mov r14=r32 // rp 249{ .mib;
250#if defined(_HPUX_SOURCE) && defined(_ILP32)
251 addp4 r14=0,r32 // rp
252#else
253 mov r14=r32 // rp
254#endif
206 mov r9=pr };; 255 mov r9=pr };;
207{ .mii; mov r15=r33 // ap 256{ .mii;
257#if defined(_HPUX_SOURCE) && defined(_ILP32)
258 addp4 r15=0,r33 // ap
259#else
260 mov r15=r33 // ap
261#endif
208 mov ar.lc=r10 262 mov ar.lc=r10
209 mov ar.ec=6 } 263 mov ar.ec=6 }
210{ .mib; mov r16=r34 // bp 264{ .mib;
265#if defined(_HPUX_SOURCE) && defined(_ILP32)
266 addp4 r16=0,r34 // bp
267#else
268 mov r16=r34 // bp
269#endif
211 mov pr.rot=1<<16 };; 270 mov pr.rot=1<<16 };;
212 271
213.L_bn_sub_words_ctop: 272.L_bn_sub_words_ctop:
@@ -227,7 +286,7 @@ bn_sub_words:
227 286
228{ .mii; 287{ .mii;
229(p59) add r8=1,r8 // return value 288(p59) add r8=1,r8 // return value
230 mov pr=r9,-1 289 mov pr=r9,0x1ffff
231 mov ar.lc=r3 } 290 mov ar.lc=r3 }
232{ .mbb; nop.b 0x0 291{ .mbb; nop.b 0x0
233 br.ret.sptk.many b0 };; 292 br.ret.sptk.many b0 };;
@@ -253,7 +312,7 @@ bn_mul_words:
253#ifdef XMA_TEMPTATION 312#ifdef XMA_TEMPTATION
254{ .mfi; alloc r2=ar.pfs,4,0,0,0 };; 313{ .mfi; alloc r2=ar.pfs,4,0,0,0 };;
255#else 314#else
256{ .mfi; alloc r2=ar.pfs,4,4,0,8 };; 315{ .mfi; alloc r2=ar.pfs,4,12,0,16 };;
257#endif 316#endif
258{ .mib; mov r8=r0 // return value 317{ .mib; mov r8=r0 // return value
259 cmp4.le p6,p0=r34,r0 318 cmp4.le p6,p0=r34,r0
@@ -266,24 +325,30 @@ bn_mul_words:
266 325
267 .body 326 .body
268{ .mib; setf.sig f8=r35 // w 327{ .mib; setf.sig f8=r35 // w
269 mov pr.rot=0x400001<<16 328 mov pr.rot=0x800001<<16
270 // ------^----- serves as (p48) at first (p26) 329 // ------^----- serves as (p50) at first (p27)
271 brp.loop.imp .L_bn_mul_words_ctop,.L_bn_mul_words_cend-16 330 brp.loop.imp .L_bn_mul_words_ctop,.L_bn_mul_words_cend-16
272 } 331 }
273 332
274#ifndef XMA_TEMPTATION 333#ifndef XMA_TEMPTATION
275 334
276{ .mii; mov r14=r32 // rp 335{ .mii;
277 mov r15=r33 // ap 336#if defined(_HPUX_SOURCE) && defined(_ILP32)
337 addp4 r14=0,r32 // rp
338 addp4 r15=0,r33 // ap
339#else
340 mov r14=r32 // rp
341 mov r15=r33 // ap
342#endif
278 mov ar.lc=r10 } 343 mov ar.lc=r10 }
279{ .mii; mov r39=0 // serves as r33 at first (p26) 344{ .mii; mov r40=0 // serves as r35 at first (p27)
280 mov ar.ec=12 };; 345 mov ar.ec=13 };;
281 346
282// This loop spins in 2*(n+11) ticks. It's scheduled for data in L2 347// This loop spins in 2*(n+12) ticks. It's scheduled for data in Itanium
283// cache (i.e. 9 ticks away) as floating point load/store instructions 348// L2 cache (i.e. 9 ticks away) as floating point load/store instructions
284// bypass L1 cache and L2 latency is actually best-case scenario for 349// bypass L1 cache and L2 latency is actually best-case scenario for
285// ldf8. The loop is not scalable and shall run in 2*(n+11) even on 350// ldf8. The loop is not scalable and shall run in 2*(n+12) even on
286// "wider" IA-64 implementations. It's a trade-off here. n+22 loop 351// "wider" IA-64 implementations. It's a trade-off here. n+24 loop
287// would give us ~5% in *overall* performance improvement on "wider" 352// would give us ~5% in *overall* performance improvement on "wider"
288// IA-64, but would hurt Itanium for about same because of longer 353// IA-64, but would hurt Itanium for about same because of longer
289// epilogue. As it's a matter of few percents in either case I've 354// epilogue. As it's a matter of few percents in either case I've
@@ -291,25 +356,25 @@ bn_mul_words:
291// this very instruction sequence in bn_mul_add_words loop which in 356// this very instruction sequence in bn_mul_add_words loop which in
292// turn is scalable). 357// turn is scalable).
293.L_bn_mul_words_ctop: 358.L_bn_mul_words_ctop:
294{ .mfi; (p25) getf.sig r36=f49 // low 359{ .mfi; (p25) getf.sig r36=f52 // low
295 (p21) xmpy.lu f45=f37,f8 360 (p21) xmpy.lu f48=f37,f8
296 (p27) cmp.ltu p52,p48=r39,r38 } 361 (p28) cmp.ltu p54,p50=r41,r39 }
297{ .mfi; (p16) ldf8 f32=[r15],8 362{ .mfi; (p16) ldf8 f32=[r15],8
298 (p21) xmpy.hu f38=f37,f8 363 (p21) xmpy.hu f40=f37,f8
299 (p0) nop.i 0x0 };; 364 (p0) nop.i 0x0 };;
300{ .mii; (p26) getf.sig r32=f43 // high 365{ .mii; (p25) getf.sig r32=f44 // high
301 .pred.rel "mutex",p48,p52 366 .pred.rel "mutex",p50,p54
302 (p48) add r38=r37,r33 // (p26) 367 (p50) add r40=r38,r35 // (p27)
303 (p52) add r38=r37,r33,1 } // (p26) 368 (p54) add r40=r38,r35,1 } // (p27)
304{ .mfb; (p27) st8 [r14]=r39,8 369{ .mfb; (p28) st8 [r14]=r41,8
305 (p0) nop.f 0x0 370 (p0) nop.f 0x0
306 br.ctop.sptk .L_bn_mul_words_ctop };; 371 br.ctop.sptk .L_bn_mul_words_ctop };;
307.L_bn_mul_words_cend: 372.L_bn_mul_words_cend:
308 373
309{ .mii; nop.m 0x0 374{ .mii; nop.m 0x0
310.pred.rel "mutex",p49,p53 375.pred.rel "mutex",p51,p55
311(p49) add r8=r34,r0 376(p51) add r8=r36,r0
312(p53) add r8=r34,r0,1 } 377(p55) add r8=r36,r0,1 }
313{ .mfb; nop.m 0x0 378{ .mfb; nop.m 0x0
314 nop.f 0x0 379 nop.f 0x0
315 nop.b 0x0 } 380 nop.b 0x0 }
@@ -344,7 +409,7 @@ bn_mul_words:
344#endif // XMA_TEMPTATION 409#endif // XMA_TEMPTATION
345 410
346{ .mii; nop.m 0x0 411{ .mii; nop.m 0x0
347 mov pr=r9,-1 412 mov pr=r9,0x1ffff
348 mov ar.lc=r3 } 413 mov ar.lc=r3 }
349{ .mfb; rum 1<<5 // clear um.mfh 414{ .mfb; rum 1<<5 // clear um.mfh
350 nop.f 0x0 415 nop.f 0x0
@@ -376,59 +441,69 @@ bn_mul_add_words:
376 441
377 .body 442 .body
378{ .mib; setf.sig f8=r35 // w 443{ .mib; setf.sig f8=r35 // w
379 mov pr.rot=0x400001<<16 444 mov pr.rot=0x800001<<16
380 // ------^----- serves as (p48) at first (p26) 445 // ------^----- serves as (p50) at first (p27)
381 brp.loop.imp .L_bn_mul_add_words_ctop,.L_bn_mul_add_words_cend-16 446 brp.loop.imp .L_bn_mul_add_words_ctop,.L_bn_mul_add_words_cend-16
382 } 447 }
383{ .mii; mov r14=r32 // rp 448{ .mii;
384 mov r15=r33 // ap 449#if defined(_HPUX_SOURCE) && defined(_ILP32)
450 addp4 r14=0,r32 // rp
451 addp4 r15=0,r33 // ap
452#else
453 mov r14=r32 // rp
454 mov r15=r33 // ap
455#endif
385 mov ar.lc=r10 } 456 mov ar.lc=r10 }
386{ .mii; mov r39=0 // serves as r33 at first (p26) 457{ .mii; mov r40=0 // serves as r35 at first (p27)
387 mov r18=r32 // rp copy 458#if defined(_HPUX_SOURCE) && defined(_ILP32)
388 mov ar.ec=14 };; 459 addp4 r18=0,r32 // rp copy
460#else
461 mov r18=r32 // rp copy
462#endif
463 mov ar.ec=15 };;
389 464
390// This loop spins in 3*(n+13) ticks on Itanium and should spin in 465// This loop spins in 3*(n+14) ticks on Itanium and should spin in
391// 2*(n+13) on "wider" IA-64 implementations (to be verified with new 466// 2*(n+14) on "wider" IA-64 implementations (to be verified with new
392// µ-architecture manuals as they become available). As usual it's 467// µ-architecture manuals as they become available). As usual it's
393// possible to compress the epilogue, down to 10 in this case, at the 468// possible to compress the epilogue, down to 10 in this case, at the
394// cost of scalability. Compressed (and therefore non-scalable) loop 469// cost of scalability. Compressed (and therefore non-scalable) loop
395// running at 3*(n+10) would buy you ~10% on Itanium but take ~35% 470// running at 3*(n+11) would buy you ~10% on Itanium but take ~35%
396// from "wider" IA-64 so let it be scalable! Special attention was 471// from "wider" IA-64 so let it be scalable! Special attention was
397// paid for having the loop body split at 64-byte boundary. ld8 is 472// paid for having the loop body split at 64-byte boundary. ld8 is
398// scheduled for L1 cache as the data is more than likely there. 473// scheduled for L1 cache as the data is more than likely there.
399// Indeed, bn_mul_words has put it there a moment ago:-) 474// Indeed, bn_mul_words has put it there a moment ago:-)
400.L_bn_mul_add_words_ctop: 475.L_bn_mul_add_words_ctop:
401{ .mfi; (p25) getf.sig r36=f49 // low 476{ .mfi; (p25) getf.sig r36=f52 // low
402 (p21) xmpy.lu f45=f37,f8 477 (p21) xmpy.lu f48=f37,f8
403 (p27) cmp.ltu p52,p48=r39,r38 } 478 (p28) cmp.ltu p54,p50=r41,r39 }
404{ .mfi; (p16) ldf8 f32=[r15],8 479{ .mfi; (p16) ldf8 f32=[r15],8
405 (p21) xmpy.hu f38=f37,f8 480 (p21) xmpy.hu f40=f37,f8
406 (p27) add r43=r43,r39 };; 481 (p28) add r45=r45,r41 };;
407{ .mii; (p26) getf.sig r32=f43 // high 482{ .mii; (p25) getf.sig r32=f44 // high
408 .pred.rel "mutex",p48,p52 483 .pred.rel "mutex",p50,p54
409 (p48) add r38=r37,r33 // (p26) 484 (p50) add r40=r38,r35 // (p27)
410 (p52) add r38=r37,r33,1 } // (p26) 485 (p54) add r40=r38,r35,1 } // (p27)
411{ .mfb; (p27) cmp.ltu.unc p56,p0=r43,r39 486{ .mfb; (p28) cmp.ltu.unc p60,p0=r45,r41
412 (p0) nop.f 0x0 487 (p0) nop.f 0x0
413 (p0) nop.b 0x0 } 488 (p0) nop.b 0x0 }
414{ .mii; (p26) ld8 r42=[r18],8 489{ .mii; (p27) ld8 r44=[r18],8
415 (p58) cmp.eq.or p57,p0=-1,r44 490 (p62) cmp.eq.or p61,p0=-1,r46
416 (p58) add r44=1,r44 } 491 (p62) add r46=1,r46 }
417{ .mfb; (p29) st8 [r14]=r45,8 492{ .mfb; (p30) st8 [r14]=r47,8
418 (p0) nop.f 0x0 493 (p0) nop.f 0x0
419 br.ctop.sptk .L_bn_mul_add_words_ctop};; 494 br.ctop.sptk .L_bn_mul_add_words_ctop};;
420.L_bn_mul_add_words_cend: 495.L_bn_mul_add_words_cend:
421 496
422{ .mii; nop.m 0x0 497{ .mii; nop.m 0x0
423.pred.rel "mutex",p51,p55 498.pred.rel "mutex",p53,p57
424(p51) add r8=r36,r0 499(p53) add r8=r38,r0
425(p55) add r8=r36,r0,1 } 500(p57) add r8=r38,r0,1 }
426{ .mfb; nop.m 0x0 501{ .mfb; nop.m 0x0
427 nop.f 0x0 502 nop.f 0x0
428 nop.b 0x0 };; 503 nop.b 0x0 };;
429{ .mii; 504{ .mii;
430(p59) add r8=1,r8 505(p63) add r8=1,r8
431 mov pr=r9,-1 506 mov pr=r9,0x1ffff
432 mov ar.lc=r3 } 507 mov ar.lc=r3 }
433{ .mfb; rum 1<<5 // clear um.mfh 508{ .mfb; rum 1<<5 // clear um.mfh
434 nop.f 0x0 509 nop.f 0x0
@@ -461,6 +536,10 @@ bn_sqr_words:
461 mov r9=pr };; 536 mov r9=pr };;
462 537
463 .body 538 .body
539#if defined(_HPUX_SOURCE) && defined(_ILP32)
540{ .mii; addp4 r32=0,r32
541 addp4 r33=0,r33 };;
542#endif
464{ .mib; 543{ .mib;
465 mov pr.rot=1<<16 544 mov pr.rot=1<<16
466 brp.loop.imp .L_bn_sqr_words_ctop,.L_bn_sqr_words_cend-16 545 brp.loop.imp .L_bn_sqr_words_ctop,.L_bn_sqr_words_cend-16
@@ -492,7 +571,7 @@ bn_sqr_words:
492.L_bn_sqr_words_cend: 571.L_bn_sqr_words_cend:
493 572
494{ .mii; nop.m 0x0 573{ .mii; nop.m 0x0
495 mov pr=r9,-1 574 mov pr=r9,0x1ffff
496 mov ar.lc=r3 } 575 mov ar.lc=r3 }
497{ .mfb; rum 1<<5 // clear um.mfh 576{ .mfb; rum 1<<5 // clear um.mfh
498 nop.f 0x0 577 nop.f 0x0
@@ -526,7 +605,14 @@ bn_sqr_comba8:
526 .prologue 605 .prologue
527 .fframe 0 606 .fframe 0
528 .save ar.pfs,r2 607 .save ar.pfs,r2
608#if defined(_HPUX_SOURCE) && defined(_ILP32)
529{ .mii; alloc r2=ar.pfs,2,1,0,0 609{ .mii; alloc r2=ar.pfs,2,1,0,0
610 addp4 r33=0,r33
611 addp4 r32=0,r32 };;
612{ .mii;
613#else
614{ .mii; alloc r2=ar.pfs,2,1,0,0
615#endif
530 mov r34=r33 616 mov r34=r33
531 add r14=8,r33 };; 617 add r14=8,r33 };;
532 .body 618 .body
@@ -587,7 +673,14 @@ bn_mul_comba8:
587 .prologue 673 .prologue
588 .fframe 0 674 .fframe 0
589 .save ar.pfs,r2 675 .save ar.pfs,r2
676#if defined(_HPUX_SOURCE) && defined(_ILP32)
590{ .mii; alloc r2=ar.pfs,3,0,0,0 677{ .mii; alloc r2=ar.pfs,3,0,0,0
678 addp4 r33=0,r33
679 addp4 r34=0,r34 };;
680{ .mii; addp4 r32=0,r32
681#else
682{ .mii; alloc r2=ar.pfs,3,0,0,0
683#endif
591 add r14=8,r33 684 add r14=8,r33
592 add r17=8,r34 } 685 add r17=8,r34 }
593 .body 686 .body
@@ -1138,7 +1231,14 @@ bn_sqr_comba4:
1138 .prologue 1231 .prologue
1139 .fframe 0 1232 .fframe 0
1140 .save ar.pfs,r2 1233 .save ar.pfs,r2
1234#if defined(_HPUX_SOURCE) && defined(_ILP32)
1235{ .mii; alloc r2=ar.pfs,2,1,0,0
1236 addp4 r32=0,r32
1237 addp4 r33=0,r33 };;
1238{ .mii;
1239#else
1141{ .mii; alloc r2=ar.pfs,2,1,0,0 1240{ .mii; alloc r2=ar.pfs,2,1,0,0
1241#endif
1142 mov r34=r33 1242 mov r34=r33
1143 add r14=8,r33 };; 1243 add r14=8,r33 };;
1144 .body 1244 .body
@@ -1164,7 +1264,14 @@ bn_mul_comba4:
1164 .prologue 1264 .prologue
1165 .fframe 0 1265 .fframe 0
1166 .save ar.pfs,r2 1266 .save ar.pfs,r2
1267#if defined(_HPUX_SOURCE) && defined(_ILP32)
1268{ .mii; alloc r2=ar.pfs,3,0,0,0
1269 addp4 r33=0,r33
1270 addp4 r34=0,r34 };;
1271{ .mii; addp4 r32=0,r32
1272#else
1167{ .mii; alloc r2=ar.pfs,3,0,0,0 1273{ .mii; alloc r2=ar.pfs,3,0,0,0
1274#endif
1168 add r14=8,r33 1275 add r14=8,r33
1169 add r17=8,r34 } 1276 add r17=8,r34 }
1170 .body 1277 .body
@@ -1464,7 +1571,7 @@ bn_div_words:
1464 or r8=r8,r33 1571 or r8=r8,r33
1465 mov ar.pfs=r2 };; 1572 mov ar.pfs=r2 };;
1466{ .mii; shr.u r9=H,I // remainder if anybody wants it 1573{ .mii; shr.u r9=H,I // remainder if anybody wants it
1467 mov pr=r10,-1 } 1574 mov pr=r10,0x1ffff }
1468{ .mfb; br.ret.sptk.many b0 };; 1575{ .mfb; br.ret.sptk.many b0 };;
1469 1576
1470// Unsigned 64 by 32 (well, by 64 for the moment) bit integer division 1577// Unsigned 64 by 32 (well, by 64 for the moment) bit integer division
diff --git a/src/lib/libcrypto/bn/asm/pa-risc2.s b/src/lib/libcrypto/bn/asm/pa-risc2.s
index af9730d062..f3b16290eb 100644
--- a/src/lib/libcrypto/bn/asm/pa-risc2.s
+++ b/src/lib/libcrypto/bn/asm/pa-risc2.s
@@ -747,8 +747,8 @@ bn_div_words
747 .PROC 747 .PROC
748 .EXPORT bn_div_words,ENTRY,PRIV_LEV=3,ARGW0=GR,ARGW1=GR,ARGW2=GR,ARGW3=GR,RTNVAL=GR,LONG_RETURN 748 .EXPORT bn_div_words,ENTRY,PRIV_LEV=3,ARGW0=GR,ARGW1=GR,ARGW2=GR,ARGW3=GR,RTNVAL=GR,LONG_RETURN
749 .IMPORT BN_num_bits_word,CODE 749 .IMPORT BN_num_bits_word,CODE
750 .IMPORT __iob,DATA 750 ;--- not PIC .IMPORT __iob,DATA
751 .IMPORT fprintf,CODE 751 ;--- not PIC .IMPORT fprintf,CODE
752 .IMPORT abort,CODE 752 .IMPORT abort,CODE
753 .IMPORT $$div2U,MILLICODE 753 .IMPORT $$div2U,MILLICODE
754 .CALLINFO CALLER,FRAME=144,ENTRY_GR=%r9,SAVE_RP,ARGS_SAVED,ORDERING_AWARE 754 .CALLINFO CALLER,FRAME=144,ENTRY_GR=%r9,SAVE_RP,ARGS_SAVED,ORDERING_AWARE
@@ -844,12 +844,12 @@ $0006001A
844 MOVIB,TR 2,%r8,$0006001C ;offset 0xa18 844 MOVIB,TR 2,%r8,$0006001C ;offset 0xa18
845 EXTRD,U %r3,63,32,%r7 ;offset 0xa1c 845 EXTRD,U %r3,63,32,%r7 ;offset 0xa1c
846$D2 846$D2
847 ADDIL LR'__iob-$global$,%r27,%r1 ;offset 0xa20 847 ;--- not PIC ADDIL LR'__iob-$global$,%r27,%r1 ;offset 0xa20
848 LDIL LR'C$7,%r21 ;offset 0xa24 848 ;--- not PIC LDIL LR'C$7,%r21 ;offset 0xa24
849 LDO RR'__iob-$global$+32(%r1),%r26 ;offset 0xa28 849 ;--- not PIC LDO RR'__iob-$global$+32(%r1),%r26 ;offset 0xa28
850 .CALL ARGW0=GR,ARGW1=GR,ARGW2=GR,RTNVAL=GR ;in=24,25,26;out=28; 850 ;--- not PIC .CALL ARGW0=GR,ARGW1=GR,ARGW2=GR,RTNVAL=GR ;in=24,25,26;out=28;
851 B,L fprintf,%r2 ;offset 0xa2c 851 ;--- not PIC B,L fprintf,%r2 ;offset 0xa2c
852 LDO RR'C$7(%r21),%r25 ;offset 0xa30 852 ;--- not PIC LDO RR'C$7(%r21),%r25 ;offset 0xa30
853 .CALL ; 853 .CALL ;
854 B,L abort,%r2 ;offset 0xa34 854 B,L abort,%r2 ;offset 0xa34
855 NOP ;offset 0xa38 855 NOP ;offset 0xa38
@@ -1605,14 +1605,14 @@ bn_mul_comba4
1605 .PROCEND 1605 .PROCEND
1606 1606
1607 1607
1608 .SPACE $TEXT$ 1608;--- not PIC .SPACE $TEXT$
1609 .SUBSPA $CODE$ 1609;--- not PIC .SUBSPA $CODE$
1610 .SPACE $PRIVATE$,SORT=16 1610;--- not PIC .SPACE $PRIVATE$,SORT=16
1611 .IMPORT $global$,DATA 1611;--- not PIC .IMPORT $global$,DATA
1612 .SPACE $TEXT$ 1612;--- not PIC .SPACE $TEXT$
1613 .SUBSPA $CODE$ 1613;--- not PIC .SUBSPA $CODE$
1614 .SUBSPA $LIT$,ACCESS=0x2c 1614;--- not PIC .SUBSPA $LIT$,ACCESS=0x2c
1615C$7 1615;--- not PIC C$7
1616 .ALIGN 8 1616;--- not PIC .ALIGN 8
1617 .STRINGZ "Division would overflow (%d)\n" 1617;--- not PIC .STRINGZ "Division would overflow (%d)\n"
1618 .END 1618 .END
diff --git a/src/lib/libcrypto/bn/asm/vms.mar b/src/lib/libcrypto/bn/asm/vms.mar
index 465f2774b6..aefab15cdb 100644
--- a/src/lib/libcrypto/bn/asm/vms.mar
+++ b/src/lib/libcrypto/bn/asm/vms.mar
@@ -1,4 +1,4 @@
1 .title vax_bn_mul_add_word unsigned multiply & add, 32*32+32+32=>64 1 .title vax_bn_mul_add_words unsigned multiply & add, 32*32+32+32=>64
2; 2;
3; w.j.m. 15-jan-1999 3; w.j.m. 15-jan-1999
4; 4;
@@ -59,7 +59,7 @@ w=16 ;(AP) w by value (input)
59 movl r6,r0 ; return c 59 movl r6,r0 ; return c
60 ret 60 ret
61 61
62 .title vax_bn_mul_word unsigned multiply & add, 32*32+32=>64 62 .title vax_bn_mul_words unsigned multiply & add, 32*32+32=>64
63; 63;
64; w.j.m. 15-jan-1999 64; w.j.m. 15-jan-1999
65; 65;
@@ -172,147 +172,175 @@ n=12 ;(AP) n by value (input)
172; } 172; }
173; 173;
174; Using EDIV would be very easy, if it didn't do signed calculations. 174; Using EDIV would be very easy, if it didn't do signed calculations.
175; Therefore, som extra things have to happen around it. The way to 175; Any time any of the input numbers are signed, there are problems,
176; handle that is to shift all operands right one step (basically dividing 176; usually with integer overflow, at which point it returns useless
177; them by 2) and handle the different cases depending on what the lowest 177; data (the quotient gets the value of l, and the remainder becomes 0).
178; bit of each operand was.
179; 178;
180; To start with, let's define the following: 179; If it was just for the dividend, it would be very easy, just divide
180; it by 2 (unsigned), do the division, multiply the resulting quotient
181; and remainder by 2, add the bit that was dropped when dividing by 2
182; to the remainder, and do some adjustment so the remainder doesn't
183; end up larger than the divisor. For some cases when the divisor is
184; negative (from EDIV's point of view, i.e. when the highest bit is set),
185; dividing the dividend by 2 isn't enough, and since some operations
186; might generate integer overflows even when the dividend is divided by
187; 4 (when the high part of the shifted down dividend ends up being exactly
188; half of the divisor, the result is the quotient 0x80000000, which is
189; negative...) it needs to be divided by 8. Furthermore, the divisor needs
190; to be divided by 2 (unsigned) as well, to avoid more problems with the sign.
191; In this case, a little extra fiddling with the remainder is required.
181; 192;
182; a' = l & 1 193; So, the simplest way to handle this is always to divide the dividend
183; a2 = <h,l> >> 1 # UNSIGNED shift! 194; by 8, and to divide the divisor by 2 if it's highest bit is set.
184; b' = d & 1 195; After EDIV has been used, the quotient gets multiplied by 8 if the
185; b2 = d >> 1 # UNSIGNED shift! 196; original divisor was positive, otherwise 4. The remainder, oddly
197; enough, is *always* multiplied by 8.
198; NOTE: in the case mentioned above, where the high part of the shifted
199; down dividend ends up being exactly half the shifted down divisor, we
200; end up with a 33 bit quotient. That's no problem however, it usually
201; means we have ended up with a too large remainder as well, and the
202; problem is fixed by the last part of the algorithm (next paragraph).
186; 203;
187; Now, use EDIV to calculate a quotient and a remainder: 204; The routine ends with comparing the resulting remainder with the
205; original divisor and if the remainder is larger, subtract the
206; original divisor from it, and increase the quotient by 1. This is
207; done until the remainder is smaller than the divisor.
188; 208;
189; q'' = a2/b2 209; The complete algorithm looks like this:
190; r'' = a2 - q''*b2
191; 210;
192; If b' is 0, the quotient is already correct, we just need to adjust the 211; d' = d
193; remainder: 212; l' = l & 7
213; [h,l] = [h,l] >> 3
214; [q,r] = floor([h,l] / d) # This is the EDIV operation
215; if (q < 0) q = -q # I doubt this is necessary any more
194; 216;
195; if (b' == 0) 217; r' = r >> 29
196; { 218; if (d' >= 0)
197; r = 2*r'' + a' 219; q' = q >> 29
198; q = q'' 220; q = q << 3
199; } 221; else
200; 222; q' = q >> 30
201; If b' is 1, we need to do other adjustements. The first thought is the 223; q = q << 2
202; following (note that r' will not always have the right value, but an 224; r = (r << 3) + l'
203; adjustement follows further down):
204;
205; if (b' == 1)
206; {
207; q' = q''
208; r' = a - q'*b
209;
210; However, one can note the folowing relationship:
211;
212; r'' = a2 - q''*b2
213; => 2*r'' = 2*a2 - 2*q''*b2
214; = { a = 2*a2 + a', b = 2*b2 + b' = 2*b2 + 1,
215; q' = q'' }
216; = a - a' - q'*(b - 1)
217; = a - q'*b - a' + q'
218; = r' - a' + q'
219; => r' = 2*r'' - q' + a'
220; 225;
221; This enables us to use r'' instead of discarding and calculating another 226; if (d' < 0)
222; modulo:
223;
224; if (b' == 1)
225; { 227; {
226; q' = q'' 228; [r',r] = [r',r] - q
227; r' = (r'' << 1) - q' + a' 229; while ([r',r] < 0)
228;
229; Now, all we have to do is adjust r', because it might be < 0:
230;
231; while (r' < 0)
232; { 230; {
233; r' = r' + b 231; [r',r] = [r',r] + d
234; q' = q' - 1 232; [q',q] = [q',q] - 1
235; } 233; }
236; } 234; }
237; 235;
238; return q' 236; while ([r',r] >= d')
237; {
238; [r',r] = [r',r] - d'
239; [q',q] = [q',q] + 1
240; }
241;
242; return q
239 243
240h=4 ;(AP) h by value (input) 244h=4 ;(AP) h by value (input)
241l=8 ;(AP) l by value (input) 245l=8 ;(AP) l by value (input)
242d=12 ;(AP) d by value (input) 246d=12 ;(AP) d by value (input)
243 247
244;aprim=r5 248;r2 = l, q
245;a2=r6 249;r3 = h, r
246;a20=r6 250;r4 = d
247;a21=r7 251;r5 = l'
248;bprim=r8 252;r6 = r'
249;b2=r9 253;r7 = d'
250;qprim=r10 ; initially used as q'' 254;r8 = q'
251;rprim=r11 ; initially used as r''
252
253 255
254 .psect code,nowrt 256 .psect code,nowrt
255 257
256.entry bn_div_words,^m<r2,r3,r4,r5,r6,r7,r8,r9,r10,r11> 258.entry bn_div_words,^m<r2,r3,r4,r5,r6,r7,r8>
257 movl l(ap),r2 259 movl l(ap),r2
258 movl h(ap),r3 260 movl h(ap),r3
259 movl d(ap),r4 261 movl d(ap),r4
260 262
261 movl #0,r5 263 bicl3 #^XFFFFFFF8,r2,r5 ; l' = l & 7
262 movl #0,r8 264 bicl3 #^X00000007,r2,r2
263 movl #0,r0
264; movl #0,r1
265 265
266 rotl #-1,r2,r6 ; a20 = l >> 1 (almost) 266 bicl3 #^XFFFFFFF8,r3,r6
267 rotl #-1,r3,r7 ; a21 = h >> 1 (almost) 267 bicl3 #^X00000007,r3,r3
268 rotl #-1,r4,r9 ; b2 = d >> 1 (almost) 268
269 addl r6,r2
269 270
270 tstl r6 271 rotl #-3,r2,r2 ; l = l >> 3
271 bgeq 1$ 272 rotl #-3,r3,r3 ; h = h >> 3
272 xorl2 #^X80000000,r6 ; fixup a20 so highest bit is 0 273
273 incl r5 ; a' = 1 274 movl r4,r7 ; d' = d
2741$: 275
275 tstl r7 276 movl #0,r6 ; r' = 0
276 bgeq 2$ 277 movl #0,r8 ; q' = 0
277 xorl2 #^X80000000,r6 ; fixup a20 so highest bit is 1, 278
278 ; since that's what was lowest in a21 279 tstl r4
279 xorl2 #^X80000000,r7 ; fixup a21 so highest bit is 1
2802$:
281 tstl r9
282 beql 666$ ; Uh-oh, the divisor is 0... 280 beql 666$ ; Uh-oh, the divisor is 0...
283 bgtr 3$ 281 bgtr 1$
284 xorl2 #^X80000000,r9 ; fixup b2 so highest bit is 0 282 rotl #-1,r4,r4 ; If d is negative, shift it right.
285 incl r8 ; b' = 1 283 bicl2 #^X80000000,r4 ; Since d is then a large number, the
2863$: 284 ; lowest bit is insignificant
287 tstl r9 285 ; (contradict that, and I'll fix the problem!)
288 bneq 4$ ; if b2 is 0, we know that b' is 1 2861$:
289 tstl r3 287 ediv r4,r2,r2,r3 ; Do the actual division
290 bneq 666$ ; if higher half isn't 0, we overflow 288
291 movl r2,r10 ; otherwise, we have our result 289 tstl r2
292 brb 42$ ; This is a success, really. 290 bgeq 3$
2934$: 291 mnegl r2,r2 ; if q < 0, negate it
294 ediv r9,r6,r10,r11 2923$:
295 293 tstl r7
296 tstl r8 294 blss 4$
297 bneq 5$ ; If b' != 0, go to the other part 295 rotl #3,r2,r2 ; q = q << 3
298; addl3 r11,r11,r1 296 bicl3 #^XFFFFFFF8,r2,r8 ; q' gets the high bits from q
299; addl2 r5,r1 297 bicl3 #^X00000007,r2,r2
300 brb 42$ 298 bsb 41$
3015$: 2994$: ; else
302 ashl #1,r11,r11 300 rotl #2,r2,r2 ; q = q << 2
303 subl2 r10,r11 301 bicl3 #^XFFFFFFFC,r2,r8 ; q' gets the high bits from q
304 addl2 r5,r11 302 bicl3 #^X00000003,r2,r2
305 bgeq 7$ 30341$:
3066$: 304 rotl #3,r3,r3 ; r = r << 3
307 decl r10 305 bicl3 #^XFFFFFFF8,r3,r6 ; r' gets the high bits from r
308 addl2 r4,r11 306 bicl3 #^X00000007,r3,r3
309 blss 6$ 307 addl r5,r3 ; r = r + l'
3107$: 308
311; movl r11,r1 309 tstl r7
310 bgeq 5$
311 bitl #1,r7
312 beql 5$ ; if d' < 0 && d' & 1
313 subl r2,r3 ; [r',r] = [r',r] - [q',q]
314 sbwc r8,r6
31545$:
316 bgeq 5$ ; while r < 0
317 decl r2 ; [q',q] = [q',q] - 1
318 sbwc #0,r8
319 addl r7,r3 ; [r',r] = [r',r] + d'
320 adwc #0,r6
321 brb 45$
322
323; The return points are placed in the middle to keep a short distance from
324; all the branch points
31242$: 32542$:
313 movl r10,r0 326; movl r3,r1
327 movl r2,r0
328 ret
314666$: 329666$:
330 movl #^XFFFFFFFF,r0
315 ret 331 ret
332
3335$:
334 tstl r6
335 bneq 6$
336 cmpl r3,r7
337 blssu 42$ ; while [r',r] >= d'
3386$:
339 subl r7,r3 ; [r',r] = [r',r] - d'
340 sbwc #0,r6
341 incl r2 ; [q',q] = [q',q] + 1
342 adwc #0,r8
343 brb 5$
316 344
317 .title vax_bn_add_words unsigned add of two arrays 345 .title vax_bn_add_words unsigned add of two arrays
318; 346;
diff --git a/src/lib/libcrypto/bn/bn.h b/src/lib/libcrypto/bn/bn.h
index b40682f831..3da6d8ced9 100644
--- a/src/lib/libcrypto/bn/bn.h
+++ b/src/lib/libcrypto/bn/bn.h
@@ -248,6 +248,8 @@ typedef struct bn_blinding_st
248 BIGNUM *A; 248 BIGNUM *A;
249 BIGNUM *Ai; 249 BIGNUM *Ai;
250 BIGNUM *mod; /* just a reference */ 250 BIGNUM *mod; /* just a reference */
251 unsigned long thread_id; /* added in OpenSSL 0.9.6j and 0.9.7b;
252 * used only by crypto/rsa/rsa_eay.c, rsa_lib.c */
251 } BN_BLINDING; 253 } BN_BLINDING;
252 254
253/* Used for montgomery multiplication */ 255/* Used for montgomery multiplication */
diff --git a/src/lib/libcrypto/bn/bn_div.c b/src/lib/libcrypto/bn/bn_div.c
index f9a095e3b3..580d1201bc 100644
--- a/src/lib/libcrypto/bn/bn_div.c
+++ b/src/lib/libcrypto/bn/bn_div.c
@@ -150,6 +150,20 @@ int BN_div(BIGNUM *dv, BIGNUM *rem, const BIGNUM *m, const BIGNUM *d,
150 q; \ 150 q; \
151 }) 151 })
152# define REMAINDER_IS_ALREADY_CALCULATED 152# define REMAINDER_IS_ALREADY_CALCULATED
153# elif defined(__x86_64) && defined(SIXTY_FOUR_BIT_LONG)
154 /*
155 * Same story here, but it's 128-bit by 64-bit division. Wow!
156 * <appro@fy.chalmers.se>
157 */
158# define bn_div_words(n0,n1,d0) \
159 ({ asm volatile ( \
160 "divq %4" \
161 : "=a"(q), "=d"(rem) \
162 : "a"(n1), "d"(n0), "g"(d0) \
163 : "cc"); \
164 q; \
165 })
166# define REMAINDER_IS_ALREADY_CALCULATED
153# endif /* __<cpu> */ 167# endif /* __<cpu> */
154# endif /* __GNUC__ */ 168# endif /* __GNUC__ */
155#endif /* OPENSSL_NO_ASM */ 169#endif /* OPENSSL_NO_ASM */
@@ -268,6 +282,11 @@ int BN_div(BIGNUM *dv, BIGNUM *rm, const BIGNUM *num, const BIGNUM *divisor,
268 q=(BN_ULONG)(((((BN_ULLONG)n0)<<BN_BITS2)|n1)/d0); 282 q=(BN_ULONG)(((((BN_ULLONG)n0)<<BN_BITS2)|n1)/d0);
269#else 283#else
270 q=bn_div_words(n0,n1,d0); 284 q=bn_div_words(n0,n1,d0);
285#ifdef BN_DEBUG_LEVITTE
286 fprintf(stderr,"DEBUG: bn_div_words(0x%08X,0x%08X,0x%08\
287X) -> 0x%08X\n",
288 n0, n1, d0, q);
289#endif
271#endif 290#endif
272 291
273#ifndef REMAINDER_IS_ALREADY_CALCULATED 292#ifndef REMAINDER_IS_ALREADY_CALCULATED
@@ -292,11 +311,18 @@ int BN_div(BIGNUM *dv, BIGNUM *rm, const BIGNUM *num, const BIGNUM *divisor,
292 BN_ULONG t2l,t2h,ql,qh; 311 BN_ULONG t2l,t2h,ql,qh;
293 312
294 q=bn_div_words(n0,n1,d0); 313 q=bn_div_words(n0,n1,d0);
314#ifdef BN_DEBUG_LEVITTE
315 fprintf(stderr,"DEBUG: bn_div_words(0x%08X,0x%08X,0x%08\
316X) -> 0x%08X\n",
317 n0, n1, d0, q);
318#endif
295#ifndef REMAINDER_IS_ALREADY_CALCULATED 319#ifndef REMAINDER_IS_ALREADY_CALCULATED
296 rem=(n1-q*d0)&BN_MASK2; 320 rem=(n1-q*d0)&BN_MASK2;
297#endif 321#endif
298 322
299#ifdef BN_UMULT_HIGH 323#if defined(BN_UMULT_LOHI)
324 BN_UMULT_LOHI(t2l,t2h,d1,q);
325#elif defined(BN_UMULT_HIGH)
300 t2l = d1 * q; 326 t2l = d1 * q;
301 t2h = BN_UMULT_HIGH(d1,q); 327 t2h = BN_UMULT_HIGH(d1,q);
302#else 328#else
diff --git a/src/lib/libcrypto/bn/bn_lcl.h b/src/lib/libcrypto/bn/bn_lcl.h
index 8a4dba375a..5614bc6164 100644
--- a/src/lib/libcrypto/bn/bn_lcl.h
+++ b/src/lib/libcrypto/bn/bn_lcl.h
@@ -230,6 +230,21 @@ struct bignum_ctx
230 : "r"(a), "r"(b)); \ 230 : "r"(a), "r"(b)); \
231 ret; }) 231 ret; })
232# endif /* compiler */ 232# endif /* compiler */
233# elif defined(__x86_64) && defined(SIXTY_FOUR_BIT_LONG)
234# if defined(__GNUC__)
235# define BN_UMULT_HIGH(a,b) ({ \
236 register BN_ULONG ret,discard; \
237 asm ("mulq %3" \
238 : "=a"(discard),"=d"(ret) \
239 : "a"(a), "g"(b) \
240 : "cc"); \
241 ret; })
242# define BN_UMULT_LOHI(low,high,a,b) \
243 asm ("mulq %3" \
244 : "=a"(low),"=d"(high) \
245 : "a"(a),"g"(b) \
246 : "cc");
247# endif
233# endif /* cpu */ 248# endif /* cpu */
234#endif /* OPENSSL_NO_ASM */ 249#endif /* OPENSSL_NO_ASM */
235 250
@@ -337,7 +352,7 @@ struct bignum_ctx
337 352
338#define LBITS(a) ((a)&BN_MASK2l) 353#define LBITS(a) ((a)&BN_MASK2l)
339#define HBITS(a) (((a)>>BN_BITS4)&BN_MASK2l) 354#define HBITS(a) (((a)>>BN_BITS4)&BN_MASK2l)
340#define L2HBITS(a) ((BN_ULONG)((a)&BN_MASK2l)<<BN_BITS4) 355#define L2HBITS(a) (((a)<<BN_BITS4)&BN_MASK2)
341 356
342#define LLBITS(a) ((a)&BN_MASKl) 357#define LLBITS(a) ((a)&BN_MASKl)
343#define LHBITS(a) (((a)>>BN_BITS2)&BN_MASKl) 358#define LHBITS(a) (((a)>>BN_BITS2)&BN_MASKl)
@@ -353,7 +368,7 @@ struct bignum_ctx
353 lt=(bl)*(lt); \ 368 lt=(bl)*(lt); \
354 m1=(bl)*(ht); \ 369 m1=(bl)*(ht); \
355 ht =(bh)*(ht); \ 370 ht =(bh)*(ht); \
356 m=(m+m1)&BN_MASK2; if (m < m1) ht+=L2HBITS(1L); \ 371 m=(m+m1)&BN_MASK2; if (m < m1) ht+=L2HBITS((BN_ULONG)1); \
357 ht+=HBITS(m); \ 372 ht+=HBITS(m); \
358 m1=L2HBITS(m); \ 373 m1=L2HBITS(m); \
359 lt=(lt+m1)&BN_MASK2; if (lt < m1) ht++; \ 374 lt=(lt+m1)&BN_MASK2; if (lt < m1) ht++; \
@@ -418,20 +433,19 @@ void bn_sqr_comba4(BN_ULONG *r,const BN_ULONG *a);
418int bn_cmp_words(const BN_ULONG *a,const BN_ULONG *b,int n); 433int bn_cmp_words(const BN_ULONG *a,const BN_ULONG *b,int n);
419int bn_cmp_part_words(const BN_ULONG *a, const BN_ULONG *b, 434int bn_cmp_part_words(const BN_ULONG *a, const BN_ULONG *b,
420 int cl, int dl); 435 int cl, int dl);
436#if 0
437/* bn_mul.c rollback <appro> */
421void bn_mul_recursive(BN_ULONG *r,BN_ULONG *a,BN_ULONG *b,int n2, 438void bn_mul_recursive(BN_ULONG *r,BN_ULONG *a,BN_ULONG *b,int n2,
422 int dna,int dnb,BN_ULONG *t); 439 int dna,int dnb,BN_ULONG *t);
423void bn_mul_part_recursive(BN_ULONG *r,BN_ULONG *a,BN_ULONG *b, 440void bn_mul_part_recursive(BN_ULONG *r,BN_ULONG *a,BN_ULONG *b,
424 int n,int tna,int tnb,BN_ULONG *t); 441 int n,int tna,int tnb,BN_ULONG *t);
442#endif
425void bn_sqr_recursive(BN_ULONG *r,const BN_ULONG *a, int n2, BN_ULONG *t); 443void bn_sqr_recursive(BN_ULONG *r,const BN_ULONG *a, int n2, BN_ULONG *t);
426void bn_mul_low_normal(BN_ULONG *r,BN_ULONG *a,BN_ULONG *b, int n); 444void bn_mul_low_normal(BN_ULONG *r,BN_ULONG *a,BN_ULONG *b, int n);
427void bn_mul_low_recursive(BN_ULONG *r,BN_ULONG *a,BN_ULONG *b,int n2, 445void bn_mul_low_recursive(BN_ULONG *r,BN_ULONG *a,BN_ULONG *b,int n2,
428 BN_ULONG *t); 446 BN_ULONG *t);
429void bn_mul_high(BN_ULONG *r,BN_ULONG *a,BN_ULONG *b,BN_ULONG *l,int n2, 447void bn_mul_high(BN_ULONG *r,BN_ULONG *a,BN_ULONG *b,BN_ULONG *l,int n2,
430 BN_ULONG *t); 448 BN_ULONG *t);
431BN_ULONG bn_add_part_words(BN_ULONG *r, const BN_ULONG *a, const BN_ULONG *b,
432 int cl, int dl);
433BN_ULONG bn_sub_part_words(BN_ULONG *r, const BN_ULONG *a, const BN_ULONG *b,
434 int cl, int dl);
435 449
436#ifdef __cplusplus 450#ifdef __cplusplus
437} 451}
diff --git a/src/lib/libcrypto/bn/bn_lib.c b/src/lib/libcrypto/bn/bn_lib.c
index ce2ae78419..463463cfcb 100644
--- a/src/lib/libcrypto/bn/bn_lib.c
+++ b/src/lib/libcrypto/bn/bn_lib.c
@@ -263,12 +263,12 @@ void BN_clear_free(BIGNUM *a)
263 if (a == NULL) return; 263 if (a == NULL) return;
264 if (a->d != NULL) 264 if (a->d != NULL)
265 { 265 {
266 memset(a->d,0,a->dmax*sizeof(a->d[0])); 266 OPENSSL_cleanse(a->d,a->dmax*sizeof(a->d[0]));
267 if (!(BN_get_flags(a,BN_FLG_STATIC_DATA))) 267 if (!(BN_get_flags(a,BN_FLG_STATIC_DATA)))
268 OPENSSL_free(a->d); 268 OPENSSL_free(a->d);
269 } 269 }
270 i=BN_get_flags(a,BN_FLG_MALLOCED); 270 i=BN_get_flags(a,BN_FLG_MALLOCED);
271 memset(a,0,sizeof(BIGNUM)); 271 OPENSSL_cleanse(a,sizeof(BIGNUM));
272 if (i) 272 if (i)
273 OPENSSL_free(a); 273 OPENSSL_free(a);
274 } 274 }
diff --git a/src/lib/libcrypto/bn/bn_mul.c b/src/lib/libcrypto/bn/bn_mul.c
index b03458d002..cb93ac3356 100644
--- a/src/lib/libcrypto/bn/bn_mul.c
+++ b/src/lib/libcrypto/bn/bn_mul.c
@@ -56,325 +56,10 @@
56 * [including the GNU Public Licence.] 56 * [including the GNU Public Licence.]
57 */ 57 */
58 58
59#ifndef BN_DEBUG
60# undef NDEBUG /* avoid conflicting definitions */
61# define NDEBUG
62#endif
63
64#include <stdio.h> 59#include <stdio.h>
65#include <assert.h>
66#include "cryptlib.h" 60#include "cryptlib.h"
67#include "bn_lcl.h" 61#include "bn_lcl.h"
68 62
69#if defined(OPENSSL_NO_ASM) || !(defined(__i386) || defined(__i386__)) || defined(__DJGPP__) /* Assembler implementation exists only for x86 */
70/* Here follows specialised variants of bn_add_words() and
71 bn_sub_words(). They have the property performing operations on
72 arrays of different sizes. The sizes of those arrays is expressed through
73 cl, which is the common length ( basicall, min(len(a),len(b)) ), and dl,
74 which is the delta between the two lengths, calculated as len(a)-len(b).
75 All lengths are the number of BN_ULONGs... For the operations that require
76 a result array as parameter, it must have the length cl+abs(dl).
77 These functions should probably end up in bn_asm.c as soon as there are
78 assembler counterparts for the systems that use assembler files. */
79
80BN_ULONG bn_sub_part_words(BN_ULONG *r,
81 const BN_ULONG *a, const BN_ULONG *b,
82 int cl, int dl)
83 {
84 BN_ULONG c, t;
85
86 assert(cl >= 0);
87 c = bn_sub_words(r, a, b, cl);
88
89 if (dl == 0)
90 return c;
91
92 r += cl;
93 a += cl;
94 b += cl;
95
96 if (dl < 0)
97 {
98#ifdef BN_COUNT
99 fprintf(stderr, " bn_sub_part_words %d + %d (dl < 0, c = %d)\n", cl, dl, c);
100#endif
101 for (;;)
102 {
103 t = b[0];
104 r[0] = (0-t-c)&BN_MASK2;
105 if (t != 0) c=1;
106 if (++dl >= 0) break;
107
108 t = b[1];
109 r[1] = (0-t-c)&BN_MASK2;
110 if (t != 0) c=1;
111 if (++dl >= 0) break;
112
113 t = b[2];
114 r[2] = (0-t-c)&BN_MASK2;
115 if (t != 0) c=1;
116 if (++dl >= 0) break;
117
118 t = b[3];
119 r[3] = (0-t-c)&BN_MASK2;
120 if (t != 0) c=1;
121 if (++dl >= 0) break;
122
123 b += 4;
124 r += 4;
125 }
126 }
127 else
128 {
129 int save_dl = dl;
130#ifdef BN_COUNT
131 fprintf(stderr, " bn_sub_part_words %d + %d (dl > 0, c = %d)\n", cl, dl, c);
132#endif
133 while(c)
134 {
135 t = a[0];
136 r[0] = (t-c)&BN_MASK2;
137 if (t != 0) c=0;
138 if (--dl <= 0) break;
139
140 t = a[1];
141 r[1] = (t-c)&BN_MASK2;
142 if (t != 0) c=0;
143 if (--dl <= 0) break;
144
145 t = a[2];
146 r[2] = (t-c)&BN_MASK2;
147 if (t != 0) c=0;
148 if (--dl <= 0) break;
149
150 t = a[3];
151 r[3] = (t-c)&BN_MASK2;
152 if (t != 0) c=0;
153 if (--dl <= 0) break;
154
155 save_dl = dl;
156 a += 4;
157 r += 4;
158 }
159 if (dl > 0)
160 {
161#ifdef BN_COUNT
162 fprintf(stderr, " bn_sub_part_words %d + %d (dl > 0, c == 0)\n", cl, dl);
163#endif
164 if (save_dl > dl)
165 {
166 switch (save_dl - dl)
167 {
168 case 1:
169 r[1] = a[1];
170 if (--dl <= 0) break;
171 case 2:
172 r[2] = a[2];
173 if (--dl <= 0) break;
174 case 3:
175 r[3] = a[3];
176 if (--dl <= 0) break;
177 }
178 a += 4;
179 r += 4;
180 }
181 }
182 if (dl > 0)
183 {
184#ifdef BN_COUNT
185 fprintf(stderr, " bn_sub_part_words %d + %d (dl > 0, copy)\n", cl, dl);
186#endif
187 for(;;)
188 {
189 r[0] = a[0];
190 if (--dl <= 0) break;
191 r[1] = a[1];
192 if (--dl <= 0) break;
193 r[2] = a[2];
194 if (--dl <= 0) break;
195 r[3] = a[3];
196 if (--dl <= 0) break;
197
198 a += 4;
199 r += 4;
200 }
201 }
202 }
203 return c;
204 }
205#endif
206
207BN_ULONG bn_add_part_words(BN_ULONG *r,
208 const BN_ULONG *a, const BN_ULONG *b,
209 int cl, int dl)
210 {
211 BN_ULONG c, l, t;
212
213 assert(cl >= 0);
214 c = bn_add_words(r, a, b, cl);
215
216 if (dl == 0)
217 return c;
218
219 r += cl;
220 a += cl;
221 b += cl;
222
223 if (dl < 0)
224 {
225 int save_dl = dl;
226#ifdef BN_COUNT
227 fprintf(stderr, " bn_add_part_words %d + %d (dl < 0, c = %d)\n", cl, dl, c);
228#endif
229 while (c)
230 {
231 l=(c+b[0])&BN_MASK2;
232 c=(l < c);
233 r[0]=l;
234 if (++dl >= 0) break;
235
236 l=(c+b[1])&BN_MASK2;
237 c=(l < c);
238 r[1]=l;
239 if (++dl >= 0) break;
240
241 l=(c+b[2])&BN_MASK2;
242 c=(l < c);
243 r[2]=l;
244 if (++dl >= 0) break;
245
246 l=(c+b[3])&BN_MASK2;
247 c=(l < c);
248 r[3]=l;
249 if (++dl >= 0) break;
250
251 save_dl = dl;
252 b+=4;
253 r+=4;
254 }
255 if (dl < 0)
256 {
257#ifdef BN_COUNT
258 fprintf(stderr, " bn_add_part_words %d + %d (dl < 0, c == 0)\n", cl, dl);
259#endif
260 if (save_dl < dl)
261 {
262 switch (dl - save_dl)
263 {
264 case 1:
265 r[1] = b[1];
266 if (++dl >= 0) break;
267 case 2:
268 r[2] = b[2];
269 if (++dl >= 0) break;
270 case 3:
271 r[3] = b[3];
272 if (++dl >= 0) break;
273 }
274 b += 4;
275 r += 4;
276 }
277 }
278 if (dl < 0)
279 {
280#ifdef BN_COUNT
281 fprintf(stderr, " bn_add_part_words %d + %d (dl < 0, copy)\n", cl, dl);
282#endif
283 for(;;)
284 {
285 r[0] = b[0];
286 if (++dl >= 0) break;
287 r[1] = b[1];
288 if (++dl >= 0) break;
289 r[2] = b[2];
290 if (++dl >= 0) break;
291 r[3] = b[3];
292 if (++dl >= 0) break;
293
294 b += 4;
295 r += 4;
296 }
297 }
298 }
299 else
300 {
301 int save_dl = dl;
302#ifdef BN_COUNT
303 fprintf(stderr, " bn_add_part_words %d + %d (dl > 0)\n", cl, dl);
304#endif
305 while (c)
306 {
307 t=(a[0]+c)&BN_MASK2;
308 c=(t < c);
309 r[0]=t;
310 if (--dl <= 0) break;
311
312 t=(a[1]+c)&BN_MASK2;
313 c=(t < c);
314 r[1]=t;
315 if (--dl <= 0) break;
316
317 t=(a[2]+c)&BN_MASK2;
318 c=(t < c);
319 r[2]=t;
320 if (--dl <= 0) break;
321
322 t=(a[3]+c)&BN_MASK2;
323 c=(t < c);
324 r[3]=t;
325 if (--dl <= 0) break;
326
327 save_dl = dl;
328 a+=4;
329 r+=4;
330 }
331#ifdef BN_COUNT
332 fprintf(stderr, " bn_add_part_words %d + %d (dl > 0, c == 0)\n", cl, dl);
333#endif
334 if (dl > 0)
335 {
336 if (save_dl > dl)
337 {
338 switch (save_dl - dl)
339 {
340 case 1:
341 r[1] = a[1];
342 if (--dl <= 0) break;
343 case 2:
344 r[2] = a[2];
345 if (--dl <= 0) break;
346 case 3:
347 r[3] = a[3];
348 if (--dl <= 0) break;
349 }
350 a += 4;
351 r += 4;
352 }
353 }
354 if (dl > 0)
355 {
356#ifdef BN_COUNT
357 fprintf(stderr, " bn_add_part_words %d + %d (dl > 0, copy)\n", cl, dl);
358#endif
359 for(;;)
360 {
361 r[0] = a[0];
362 if (--dl <= 0) break;
363 r[1] = a[1];
364 if (--dl <= 0) break;
365 r[2] = a[2];
366 if (--dl <= 0) break;
367 r[3] = a[3];
368 if (--dl <= 0) break;
369
370 a += 4;
371 r += 4;
372 }
373 }
374 }
375 return c;
376 }
377
378#ifdef BN_RECURSION 63#ifdef BN_RECURSION
379/* Karatsuba recursive multiplication algorithm 64/* Karatsuba recursive multiplication algorithm
380 * (cf. Knuth, The Art of Computer Programming, Vol. 2) */ 65 * (cf. Knuth, The Art of Computer Programming, Vol. 2) */
@@ -390,15 +75,14 @@ BN_ULONG bn_add_part_words(BN_ULONG *r,
390 * a[1]*b[1] 75 * a[1]*b[1]
391 */ 76 */
392void bn_mul_recursive(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, int n2, 77void bn_mul_recursive(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, int n2,
393 int dna, int dnb, BN_ULONG *t) 78 BN_ULONG *t)
394 { 79 {
395 int n=n2/2,c1,c2; 80 int n=n2/2,c1,c2;
396 int tna=n+dna, tnb=n+dnb;
397 unsigned int neg,zero; 81 unsigned int neg,zero;
398 BN_ULONG ln,lo,*p; 82 BN_ULONG ln,lo,*p;
399 83
400# ifdef BN_COUNT 84# ifdef BN_COUNT
401 fprintf(stderr," bn_mul_recursive %d * %d\n",n2,n2); 85 printf(" bn_mul_recursive %d * %d\n",n2,n2);
402# endif 86# endif
403# ifdef BN_MUL_COMBA 87# ifdef BN_MUL_COMBA
404# if 0 88# if 0
@@ -408,40 +92,34 @@ void bn_mul_recursive(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, int n2,
408 return; 92 return;
409 } 93 }
410# endif 94# endif
411 /* Only call bn_mul_comba 8 if n2 == 8 and the 95 if (n2 == 8)
412 * two arrays are complete [steve]
413 */
414 if (n2 == 8 && dna == 0 && dnb == 0)
415 { 96 {
416 bn_mul_comba8(r,a,b); 97 bn_mul_comba8(r,a,b);
417 return; 98 return;
418 } 99 }
419# endif /* BN_MUL_COMBA */ 100# endif /* BN_MUL_COMBA */
420 /* Else do normal multiply */
421 if (n2 < BN_MUL_RECURSIVE_SIZE_NORMAL) 101 if (n2 < BN_MUL_RECURSIVE_SIZE_NORMAL)
422 { 102 {
423 bn_mul_normal(r,a,n2+dna,b,n2+dnb); 103 /* This should not happen */
424 if ((dna + dnb) < 0) 104 bn_mul_normal(r,a,n2,b,n2);
425 memset(&r[2*n2 + dna + dnb], 0,
426 sizeof(BN_ULONG) * -(dna + dnb));
427 return; 105 return;
428 } 106 }
429 /* r=(a[0]-a[1])*(b[1]-b[0]) */ 107 /* r=(a[0]-a[1])*(b[1]-b[0]) */
430 c1=bn_cmp_part_words(a,&(a[n]),tna,n-tna); 108 c1=bn_cmp_words(a,&(a[n]),n);
431 c2=bn_cmp_part_words(&(b[n]),b,tnb,tnb-n); 109 c2=bn_cmp_words(&(b[n]),b,n);
432 zero=neg=0; 110 zero=neg=0;
433 switch (c1*3+c2) 111 switch (c1*3+c2)
434 { 112 {
435 case -4: 113 case -4:
436 bn_sub_part_words(t, &(a[n]),a, tna,tna-n); /* - */ 114 bn_sub_words(t, &(a[n]),a, n); /* - */
437 bn_sub_part_words(&(t[n]),b, &(b[n]),tnb,n-tnb); /* - */ 115 bn_sub_words(&(t[n]),b, &(b[n]),n); /* - */
438 break; 116 break;
439 case -3: 117 case -3:
440 zero=1; 118 zero=1;
441 break; 119 break;
442 case -2: 120 case -2:
443 bn_sub_part_words(t, &(a[n]),a, tna,tna-n); /* - */ 121 bn_sub_words(t, &(a[n]),a, n); /* - */
444 bn_sub_part_words(&(t[n]),&(b[n]),b, tnb,tnb-n); /* + */ 122 bn_sub_words(&(t[n]),&(b[n]),b, n); /* + */
445 neg=1; 123 neg=1;
446 break; 124 break;
447 case -1: 125 case -1:
@@ -450,22 +128,21 @@ void bn_mul_recursive(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, int n2,
450 zero=1; 128 zero=1;
451 break; 129 break;
452 case 2: 130 case 2:
453 bn_sub_part_words(t, a, &(a[n]),tna,n-tna); /* + */ 131 bn_sub_words(t, a, &(a[n]),n); /* + */
454 bn_sub_part_words(&(t[n]),b, &(b[n]),tnb,n-tnb); /* - */ 132 bn_sub_words(&(t[n]),b, &(b[n]),n); /* - */
455 neg=1; 133 neg=1;
456 break; 134 break;
457 case 3: 135 case 3:
458 zero=1; 136 zero=1;
459 break; 137 break;
460 case 4: 138 case 4:
461 bn_sub_part_words(t, a, &(a[n]),tna,n-tna); 139 bn_sub_words(t, a, &(a[n]),n);
462 bn_sub_part_words(&(t[n]),&(b[n]),b, tnb,tnb-n); 140 bn_sub_words(&(t[n]),&(b[n]),b, n);
463 break; 141 break;
464 } 142 }
465 143
466# ifdef BN_MUL_COMBA 144# ifdef BN_MUL_COMBA
467 if (n == 4 && dna == 0 && dnb == 0) /* XXX: bn_mul_comba4 could take 145 if (n == 4)
468 extra args to do this well */
469 { 146 {
470 if (!zero) 147 if (!zero)
471 bn_mul_comba4(&(t[n2]),t,&(t[n])); 148 bn_mul_comba4(&(t[n2]),t,&(t[n]));
@@ -475,9 +152,7 @@ void bn_mul_recursive(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, int n2,
475 bn_mul_comba4(r,a,b); 152 bn_mul_comba4(r,a,b);
476 bn_mul_comba4(&(r[n2]),&(a[n]),&(b[n])); 153 bn_mul_comba4(&(r[n2]),&(a[n]),&(b[n]));
477 } 154 }
478 else if (n == 8 && dna == 0 && dnb == 0) /* XXX: bn_mul_comba8 could 155 else if (n == 8)
479 take extra args to do this
480 well */
481 { 156 {
482 if (!zero) 157 if (!zero)
483 bn_mul_comba8(&(t[n2]),t,&(t[n])); 158 bn_mul_comba8(&(t[n2]),t,&(t[n]));
@@ -492,11 +167,11 @@ void bn_mul_recursive(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, int n2,
492 { 167 {
493 p= &(t[n2*2]); 168 p= &(t[n2*2]);
494 if (!zero) 169 if (!zero)
495 bn_mul_recursive(&(t[n2]),t,&(t[n]),n,0,0,p); 170 bn_mul_recursive(&(t[n2]),t,&(t[n]),n,p);
496 else 171 else
497 memset(&(t[n2]),0,n2*sizeof(BN_ULONG)); 172 memset(&(t[n2]),0,n2*sizeof(BN_ULONG));
498 bn_mul_recursive(r,a,b,n,0,0,p); 173 bn_mul_recursive(r,a,b,n,p);
499 bn_mul_recursive(&(r[n2]),&(a[n]),&(b[n]),n,dna,dnb,p); 174 bn_mul_recursive(&(r[n2]),&(a[n]),&(b[n]),n,p);
500 } 175 }
501 176
502 /* t[32] holds (a[0]-a[1])*(b[1]-b[0]), c1 is the sign 177 /* t[32] holds (a[0]-a[1])*(b[1]-b[0]), c1 is the sign
@@ -545,39 +220,39 @@ void bn_mul_recursive(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, int n2,
545 220
546/* n+tn is the word length 221/* n+tn is the word length
547 * t needs to be n*4 is size, as does r */ 222 * t needs to be n*4 is size, as does r */
548void bn_mul_part_recursive(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, int n, 223void bn_mul_part_recursive(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, int tn,
549 int tna, int tnb, BN_ULONG *t) 224 int n, BN_ULONG *t)
550 { 225 {
551 int i,j,n2=n*2; 226 int i,j,n2=n*2;
552 unsigned int c1,c2,neg,zero; 227 unsigned int c1,c2,neg,zero;
553 BN_ULONG ln,lo,*p; 228 BN_ULONG ln,lo,*p;
554 229
555# ifdef BN_COUNT 230# ifdef BN_COUNT
556 fprintf(stderr," bn_mul_part_recursive (%d+%d) * (%d+%d)\n", 231 printf(" bn_mul_part_recursive %d * %d\n",tn+n,tn+n);
557 tna, n, tnb, n);
558# endif 232# endif
559 if (n < 8) 233 if (n < 8)
560 { 234 {
561 bn_mul_normal(r,a,n+tna,b,n+tnb); 235 i=tn+n;
236 bn_mul_normal(r,a,i,b,i);
562 return; 237 return;
563 } 238 }
564 239
565 /* r=(a[0]-a[1])*(b[1]-b[0]) */ 240 /* r=(a[0]-a[1])*(b[1]-b[0]) */
566 c1=bn_cmp_part_words(a,&(a[n]),tna,n-tna); 241 c1=bn_cmp_words(a,&(a[n]),n);
567 c2=bn_cmp_part_words(&(b[n]),b,tnb,tnb-n); 242 c2=bn_cmp_words(&(b[n]),b,n);
568 zero=neg=0; 243 zero=neg=0;
569 switch (c1*3+c2) 244 switch (c1*3+c2)
570 { 245 {
571 case -4: 246 case -4:
572 bn_sub_part_words(t, &(a[n]),a, tna,tna-n); /* - */ 247 bn_sub_words(t, &(a[n]),a, n); /* - */
573 bn_sub_part_words(&(t[n]),b, &(b[n]),tnb,n-tnb); /* - */ 248 bn_sub_words(&(t[n]),b, &(b[n]),n); /* - */
574 break; 249 break;
575 case -3: 250 case -3:
576 zero=1; 251 zero=1;
577 /* break; */ 252 /* break; */
578 case -2: 253 case -2:
579 bn_sub_part_words(t, &(a[n]),a, tna,tna-n); /* - */ 254 bn_sub_words(t, &(a[n]),a, n); /* - */
580 bn_sub_part_words(&(t[n]),&(b[n]),b, tnb,tnb-n); /* + */ 255 bn_sub_words(&(t[n]),&(b[n]),b, n); /* + */
581 neg=1; 256 neg=1;
582 break; 257 break;
583 case -1: 258 case -1:
@@ -586,16 +261,16 @@ void bn_mul_part_recursive(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, int n,
586 zero=1; 261 zero=1;
587 /* break; */ 262 /* break; */
588 case 2: 263 case 2:
589 bn_sub_part_words(t, a, &(a[n]),tna,n-tna); /* + */ 264 bn_sub_words(t, a, &(a[n]),n); /* + */
590 bn_sub_part_words(&(t[n]),b, &(b[n]),tnb,n-tnb); /* - */ 265 bn_sub_words(&(t[n]),b, &(b[n]),n); /* - */
591 neg=1; 266 neg=1;
592 break; 267 break;
593 case 3: 268 case 3:
594 zero=1; 269 zero=1;
595 /* break; */ 270 /* break; */
596 case 4: 271 case 4:
597 bn_sub_part_words(t, a, &(a[n]),tna,n-tna); 272 bn_sub_words(t, a, &(a[n]),n);
598 bn_sub_part_words(&(t[n]),&(b[n]),b, tnb,tnb-n); 273 bn_sub_words(&(t[n]),&(b[n]),b, n);
599 break; 274 break;
600 } 275 }
601 /* The zero case isn't yet implemented here. The speedup 276 /* The zero case isn't yet implemented here. The speedup
@@ -614,59 +289,54 @@ void bn_mul_part_recursive(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, int n,
614 { 289 {
615 bn_mul_comba8(&(t[n2]),t,&(t[n])); 290 bn_mul_comba8(&(t[n2]),t,&(t[n]));
616 bn_mul_comba8(r,a,b); 291 bn_mul_comba8(r,a,b);
617 bn_mul_normal(&(r[n2]),&(a[n]),tna,&(b[n]),tnb); 292 bn_mul_normal(&(r[n2]),&(a[n]),tn,&(b[n]),tn);
618 memset(&(r[n2+tna+tnb]),0,sizeof(BN_ULONG)*(n2-tna-tnb)); 293 memset(&(r[n2+tn*2]),0,sizeof(BN_ULONG)*(n2-tn*2));
619 } 294 }
620 else 295 else
621 { 296 {
622 p= &(t[n2*2]); 297 p= &(t[n2*2]);
623 bn_mul_recursive(&(t[n2]),t,&(t[n]),n,0,0,p); 298 bn_mul_recursive(&(t[n2]),t,&(t[n]),n,p);
624 bn_mul_recursive(r,a,b,n,0,0,p); 299 bn_mul_recursive(r,a,b,n,p);
625 i=n/2; 300 i=n/2;
626 /* If there is only a bottom half to the number, 301 /* If there is only a bottom half to the number,
627 * just do it */ 302 * just do it */
628 if (tna > tnb) 303 j=tn-i;
629 j = tna - i;
630 else
631 j = tnb - i;
632 if (j == 0) 304 if (j == 0)
633 { 305 {
634 bn_mul_recursive(&(r[n2]),&(a[n]),&(b[n]), 306 bn_mul_recursive(&(r[n2]),&(a[n]),&(b[n]),i,p);
635 i,tna-i,tnb-i,p);
636 memset(&(r[n2+i*2]),0,sizeof(BN_ULONG)*(n2-i*2)); 307 memset(&(r[n2+i*2]),0,sizeof(BN_ULONG)*(n2-i*2));
637 } 308 }
638 else if (j > 0) /* eg, n == 16, i == 8 and tn == 11 */ 309 else if (j > 0) /* eg, n == 16, i == 8 and tn == 11 */
639 { 310 {
640 bn_mul_part_recursive(&(r[n2]),&(a[n]),&(b[n]), 311 bn_mul_part_recursive(&(r[n2]),&(a[n]),&(b[n]),
641 i,tna-i,tnb-i,p); 312 j,i,p);
642 memset(&(r[n2+tna+tnb]),0, 313 memset(&(r[n2+tn*2]),0,
643 sizeof(BN_ULONG)*(n2-tna-tnb)); 314 sizeof(BN_ULONG)*(n2-tn*2));
644 } 315 }
645 else /* (j < 0) eg, n == 16, i == 8 and tn == 5 */ 316 else /* (j < 0) eg, n == 16, i == 8 and tn == 5 */
646 { 317 {
647 memset(&(r[n2]),0,sizeof(BN_ULONG)*n2); 318 memset(&(r[n2]),0,sizeof(BN_ULONG)*n2);
648 if (tna < BN_MUL_RECURSIVE_SIZE_NORMAL 319 if (tn < BN_MUL_RECURSIVE_SIZE_NORMAL)
649 && tnb < BN_MUL_RECURSIVE_SIZE_NORMAL)
650 { 320 {
651 bn_mul_normal(&(r[n2]),&(a[n]),tna,&(b[n]),tnb); 321 bn_mul_normal(&(r[n2]),&(a[n]),tn,&(b[n]),tn);
652 } 322 }
653 else 323 else
654 { 324 {
655 for (;;) 325 for (;;)
656 { 326 {
657 i/=2; 327 i/=2;
658 if (i < tna && i < tnb) 328 if (i < tn)
659 { 329 {
660 bn_mul_part_recursive(&(r[n2]), 330 bn_mul_part_recursive(&(r[n2]),
661 &(a[n]),&(b[n]), 331 &(a[n]),&(b[n]),
662 i,tna-i,tnb-i,p); 332 tn-i,i,p);
663 break; 333 break;
664 } 334 }
665 else if (i <= tna && i <= tnb) 335 else if (i == tn)
666 { 336 {
667 bn_mul_recursive(&(r[n2]), 337 bn_mul_recursive(&(r[n2]),
668 &(a[n]),&(b[n]), 338 &(a[n]),&(b[n]),
669 i,tna-i,tnb-i,p); 339 i,p);
670 break; 340 break;
671 } 341 }
672 } 342 }
@@ -727,10 +397,10 @@ void bn_mul_low_recursive(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, int n2,
727 int n=n2/2; 397 int n=n2/2;
728 398
729# ifdef BN_COUNT 399# ifdef BN_COUNT
730 fprintf(stderr," bn_mul_low_recursive %d * %d\n",n2,n2); 400 printf(" bn_mul_low_recursive %d * %d\n",n2,n2);
731# endif 401# endif
732 402
733 bn_mul_recursive(r,a,b,n,0,0,&(t[0])); 403 bn_mul_recursive(r,a,b,n,&(t[0]));
734 if (n >= BN_MUL_LOW_RECURSIVE_SIZE_NORMAL) 404 if (n >= BN_MUL_LOW_RECURSIVE_SIZE_NORMAL)
735 { 405 {
736 bn_mul_low_recursive(&(t[0]),&(a[0]),&(b[n]),n,&(t[n2])); 406 bn_mul_low_recursive(&(t[0]),&(a[0]),&(b[n]),n,&(t[n2]));
@@ -761,7 +431,7 @@ void bn_mul_high(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, BN_ULONG *l, int n2,
761 BN_ULONG ll,lc,*lp,*mp; 431 BN_ULONG ll,lc,*lp,*mp;
762 432
763# ifdef BN_COUNT 433# ifdef BN_COUNT
764 fprintf(stderr," bn_mul_high %d * %d\n",n2,n2); 434 printf(" bn_mul_high %d * %d\n",n2,n2);
765# endif 435# endif
766 n=n2/2; 436 n=n2/2;
767 437
@@ -814,8 +484,8 @@ void bn_mul_high(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, BN_ULONG *l, int n2,
814 else 484 else
815# endif 485# endif
816 { 486 {
817 bn_mul_recursive(&(t[0]),&(r[0]),&(r[n]),n,0,0,&(t[n2])); 487 bn_mul_recursive(&(t[0]),&(r[0]),&(r[n]),n,&(t[n2]));
818 bn_mul_recursive(r,&(a[n]),&(b[n]),n,0,0,&(t[n2])); 488 bn_mul_recursive(r,&(a[n]),&(b[n]),n,&(t[n2]));
819 } 489 }
820 490
821 /* s0 == low(al*bl) 491 /* s0 == low(al*bl)
@@ -940,19 +610,19 @@ void bn_mul_high(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, BN_ULONG *l, int n2,
940 610
941int BN_mul(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx) 611int BN_mul(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx)
942 { 612 {
943 int ret=0;
944 int top,al,bl; 613 int top,al,bl;
945 BIGNUM *rr; 614 BIGNUM *rr;
615 int ret = 0;
946#if defined(BN_MUL_COMBA) || defined(BN_RECURSION) 616#if defined(BN_MUL_COMBA) || defined(BN_RECURSION)
947 int i; 617 int i;
948#endif 618#endif
949#ifdef BN_RECURSION 619#ifdef BN_RECURSION
950 BIGNUM *t=NULL; 620 BIGNUM *t;
951 int j=0,k; 621 int j,k;
952#endif 622#endif
953 623
954#ifdef BN_COUNT 624#ifdef BN_COUNT
955 fprintf(stderr,"BN_mul %d * %d\n",a->top,b->top); 625 printf("BN_mul %d * %d\n",a->top,b->top);
956#endif 626#endif
957 627
958 bn_check_top(a); 628 bn_check_top(a);
@@ -1005,55 +675,21 @@ int BN_mul(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx)
1005#ifdef BN_RECURSION 675#ifdef BN_RECURSION
1006 if ((al >= BN_MULL_SIZE_NORMAL) && (bl >= BN_MULL_SIZE_NORMAL)) 676 if ((al >= BN_MULL_SIZE_NORMAL) && (bl >= BN_MULL_SIZE_NORMAL))
1007 { 677 {
1008 if (i >= -1 && i <= 1) 678 if (i == 1 && !BN_get_flags(b,BN_FLG_STATIC_DATA) && bl<b->dmax)
1009 { 679 {
1010 int sav_j =0; 680#if 0 /* tribute to const-ification, bl<b->dmax above covers for this */
1011 /* Find out the power of two lower or equal 681 if (bn_wexpand(b,al) == NULL) goto err;
1012 to the longest of the two numbers */ 682#endif
1013 if (i >= 0) 683 b->d[bl]=0;
1014 {
1015 j = BN_num_bits_word((BN_ULONG)al);
1016 }
1017 if (i == -1)
1018 {
1019 j = BN_num_bits_word((BN_ULONG)bl);
1020 }
1021 sav_j = j;
1022 j = 1<<(j-1);
1023 assert(j <= al || j <= bl);
1024 k = j+j;
1025 t = BN_CTX_get(ctx);
1026 if (al > j || bl > j)
1027 {
1028 bn_wexpand(t,k*4);
1029 bn_wexpand(rr,k*4);
1030 bn_mul_part_recursive(rr->d,a->d,b->d,
1031 j,al-j,bl-j,t->d);
1032 }
1033 else /* al <= j || bl <= j */
1034 {
1035 bn_wexpand(t,k*2);
1036 bn_wexpand(rr,k*2);
1037 bn_mul_recursive(rr->d,a->d,b->d,
1038 j,al-j,bl-j,t->d);
1039 }
1040 rr->top=top;
1041 goto end;
1042 }
1043#if 0
1044 if (i == 1 && !BN_get_flags(b,BN_FLG_STATIC_DATA))
1045 {
1046 BIGNUM *tmp_bn = (BIGNUM *)b;
1047 if (bn_wexpand(tmp_bn,al) == NULL) goto err;
1048 tmp_bn->d[bl]=0;
1049 bl++; 684 bl++;
1050 i--; 685 i--;
1051 } 686 }
1052 else if (i == -1 && !BN_get_flags(a,BN_FLG_STATIC_DATA)) 687 else if (i == -1 && !BN_get_flags(a,BN_FLG_STATIC_DATA) && al<a->dmax)
1053 { 688 {
1054 BIGNUM *tmp_bn = (BIGNUM *)a; 689#if 0 /* tribute to const-ification, al<a->dmax above covers for this */
1055 if (bn_wexpand(tmp_bn,bl) == NULL) goto err; 690 if (bn_wexpand(a,bl) == NULL) goto err;
1056 tmp_bn->d[al]=0; 691#endif
692 a->d[al]=0;
1057 al++; 693 al++;
1058 i++; 694 i++;
1059 } 695 }
@@ -1070,17 +706,26 @@ int BN_mul(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx)
1070 if (bn_wexpand(t,k*2) == NULL) goto err; 706 if (bn_wexpand(t,k*2) == NULL) goto err;
1071 if (bn_wexpand(rr,k*2) == NULL) goto err; 707 if (bn_wexpand(rr,k*2) == NULL) goto err;
1072 bn_mul_recursive(rr->d,a->d,b->d,al,t->d); 708 bn_mul_recursive(rr->d,a->d,b->d,al,t->d);
709 rr->top=top;
710 goto end;
1073 } 711 }
712#if 0 /* tribute to const-ification, rsa/dsa performance is not affected */
1074 else 713 else
1075 { 714 {
1076 if (bn_wexpand(t,k*4) == NULL) goto err; 715 if (bn_wexpand(a,k) == NULL ) goto err;
1077 if (bn_wexpand(rr,k*4) == NULL) goto err; 716 if (bn_wexpand(b,k) == NULL ) goto err;
717 if (bn_wexpand(t,k*4) == NULL ) goto err;
718 if (bn_wexpand(rr,k*4) == NULL ) goto err;
719 for (i=a->top; i<k; i++)
720 a->d[i]=0;
721 for (i=b->top; i<k; i++)
722 b->d[i]=0;
1078 bn_mul_part_recursive(rr->d,a->d,b->d,al-j,j,t->d); 723 bn_mul_part_recursive(rr->d,a->d,b->d,al-j,j,t->d);
1079 } 724 }
1080 rr->top=top; 725 rr->top=top;
1081 goto end; 726 goto end;
1082 }
1083#endif 727#endif
728 }
1084 } 729 }
1085#endif /* BN_RECURSION */ 730#endif /* BN_RECURSION */
1086 if (bn_wexpand(rr,top) == NULL) goto err; 731 if (bn_wexpand(rr,top) == NULL) goto err;
@@ -1103,7 +748,7 @@ void bn_mul_normal(BN_ULONG *r, BN_ULONG *a, int na, BN_ULONG *b, int nb)
1103 BN_ULONG *rr; 748 BN_ULONG *rr;
1104 749
1105#ifdef BN_COUNT 750#ifdef BN_COUNT
1106 fprintf(stderr," bn_mul_normal %d * %d\n",na,nb); 751 printf(" bn_mul_normal %d * %d\n",na,nb);
1107#endif 752#endif
1108 753
1109 if (na < nb) 754 if (na < nb)
@@ -1116,13 +761,7 @@ void bn_mul_normal(BN_ULONG *r, BN_ULONG *a, int na, BN_ULONG *b, int nb)
1116 761
1117 } 762 }
1118 rr= &(r[na]); 763 rr= &(r[na]);
1119 if (nb <= 0) 764 rr[0]=bn_mul_words(r,a,na,b[0]);
1120 {
1121 (void)bn_mul_words(r,a,na,0);
1122 return;
1123 }
1124 else
1125 rr[0]=bn_mul_words(r,a,na,b[0]);
1126 765
1127 for (;;) 766 for (;;)
1128 { 767 {
@@ -1143,7 +782,7 @@ void bn_mul_normal(BN_ULONG *r, BN_ULONG *a, int na, BN_ULONG *b, int nb)
1143void bn_mul_low_normal(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, int n) 782void bn_mul_low_normal(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, int n)
1144 { 783 {
1145#ifdef BN_COUNT 784#ifdef BN_COUNT
1146 fprintf(stderr," bn_mul_low_normal %d * %d\n",n,n); 785 printf(" bn_mul_low_normal %d * %d\n",n,n);
1147#endif 786#endif
1148 bn_mul_words(r,a,n,b[0]); 787 bn_mul_words(r,a,n,b[0]);
1149 788
diff --git a/src/lib/libcrypto/bn/bn_prime.c b/src/lib/libcrypto/bn/bn_prime.c
index 918b9237c6..e072d9255c 100644
--- a/src/lib/libcrypto/bn/bn_prime.c
+++ b/src/lib/libcrypto/bn/bn_prime.c
@@ -140,6 +140,7 @@ BIGNUM *BN_generate_prime(BIGNUM *ret, int bits, int safe,
140 BN_CTX *ctx; 140 BN_CTX *ctx;
141 int checks = BN_prime_checks_for_size(bits); 141 int checks = BN_prime_checks_for_size(bits);
142 142
143 BN_init(&t);
143 ctx=BN_CTX_new(); 144 ctx=BN_CTX_new();
144 if (ctx == NULL) goto err; 145 if (ctx == NULL) goto err;
145 if (ret == NULL) 146 if (ret == NULL)
@@ -148,7 +149,6 @@ BIGNUM *BN_generate_prime(BIGNUM *ret, int bits, int safe,
148 } 149 }
149 else 150 else
150 rnd=ret; 151 rnd=ret;
151 BN_init(&t);
152loop: 152loop:
153 /* make a random number and set the top and bottom bits */ 153 /* make a random number and set the top and bottom bits */
154 if (add == NULL) 154 if (add == NULL)
diff --git a/src/lib/libcrypto/bn/bn_rand.c b/src/lib/libcrypto/bn/bn_rand.c
index 9e08ccd22e..893c9d2af9 100644
--- a/src/lib/libcrypto/bn/bn_rand.c
+++ b/src/lib/libcrypto/bn/bn_rand.c
@@ -201,7 +201,7 @@ static int bnrand(int pseudorand, BIGNUM *rnd, int bits, int top, int bottom)
201err: 201err:
202 if (buf != NULL) 202 if (buf != NULL)
203 { 203 {
204 memset(buf,0,bytes); 204 OPENSSL_cleanse(buf,bytes);
205 OPENSSL_free(buf); 205 OPENSSL_free(buf);
206 } 206 }
207 return(ret); 207 return(ret);
diff --git a/src/lib/libcrypto/bn/bn_word.c b/src/lib/libcrypto/bn/bn_word.c
index cd59baa2c4..988e0ca7b3 100644
--- a/src/lib/libcrypto/bn/bn_word.c
+++ b/src/lib/libcrypto/bn/bn_word.c
@@ -123,7 +123,10 @@ int BN_add_word(BIGNUM *a, BN_ULONG w)
123 i=0; 123 i=0;
124 for (;;) 124 for (;;)
125 { 125 {
126 l=(a->d[i]+(BN_ULONG)w)&BN_MASK2; 126 if (i >= a->top)
127 l=w;
128 else
129 l=(a->d[i]+(BN_ULONG)w)&BN_MASK2;
127 a->d[i]=l; 130 a->d[i]=l;
128 if (w > l) 131 if (w > l)
129 w=1; 132 w=1;
diff --git a/src/lib/libcrypto/bn/bntest.c b/src/lib/libcrypto/bn/bntest.c
index 8158a67374..3c8c540387 100644
--- a/src/lib/libcrypto/bn/bntest.c
+++ b/src/lib/libcrypto/bn/bntest.c
@@ -68,10 +68,6 @@
68#include <openssl/x509.h> 68#include <openssl/x509.h>
69#include <openssl/err.h> 69#include <openssl/err.h>
70 70
71#ifdef OPENSSL_SYS_WINDOWS
72#include "../bio/bss_file.c"
73#endif
74
75const int num0 = 100; /* number of tests */ 71const int num0 = 100; /* number of tests */
76const int num1 = 50; /* additional tests for some functions */ 72const int num1 = 50; /* additional tests for some functions */
77const int num2 = 5; /* number of tests for slow functions */ 73const int num2 = 5; /* number of tests for slow functions */
@@ -96,11 +92,6 @@ int test_sqrt(BIO *bp,BN_CTX *ctx);
96int rand_neg(void); 92int rand_neg(void);
97static int results=0; 93static int results=0;
98 94
99#ifdef OPENSSL_NO_STDIO
100#define APPS_WIN16
101#include "bss_file.c"
102#endif
103
104static unsigned char lst[]="\xC6\x4F\x43\x04\x2A\xEA\xCA\x6E\x58\x36\x80\x5B\xE8\xC9" 95static unsigned char lst[]="\xC6\x4F\x43\x04\x2A\xEA\xCA\x6E\x58\x36\x80\x5B\xE8\xC9"
105"\x9B\x04\x5D\x48\x36\xC2\xFD\x16\xC9\x64\xF0"; 96"\x9B\x04\x5D\x48\x36\xC2\xFD\x16\xC9\x64\xF0";
106 97
@@ -141,10 +132,10 @@ int main(int argc, char *argv[])
141 132
142 133
143 ctx=BN_CTX_new(); 134 ctx=BN_CTX_new();
144 if (ctx == NULL) exit(1); 135 if (ctx == NULL) EXIT(1);
145 136
146 out=BIO_new(BIO_s_file()); 137 out=BIO_new(BIO_s_file());
147 if (out == NULL) exit(1); 138 if (out == NULL) EXIT(1);
148 if (outfile == NULL) 139 if (outfile == NULL)
149 { 140 {
150 BIO_set_fp(out,stdout,BIO_NOCLOSE); 141 BIO_set_fp(out,stdout,BIO_NOCLOSE);
@@ -154,7 +145,7 @@ int main(int argc, char *argv[])
154 if (!BIO_write_filename(out,outfile)) 145 if (!BIO_write_filename(out,outfile))
155 { 146 {
156 perror(outfile); 147 perror(outfile);
157 exit(1); 148 EXIT(1);
158 } 149 }
159 } 150 }
160 151
@@ -238,14 +229,14 @@ int main(int argc, char *argv[])
238 BIO_free(out); 229 BIO_free(out);
239 230
240/**/ 231/**/
241 exit(0); 232 EXIT(0);
242err: 233err:
243 BIO_puts(out,"1\n"); /* make sure the Perl script fed by bc notices 234 BIO_puts(out,"1\n"); /* make sure the Perl script fed by bc notices
244 * the failure, see test_bn in test/Makefile.ssl*/ 235 * the failure, see test_bn in test/Makefile.ssl*/
245 BIO_flush(out); 236 BIO_flush(out);
246 ERR_load_crypto_strings(); 237 ERR_load_crypto_strings();
247 ERR_print_errors_fp(stderr); 238 ERR_print_errors_fp(stderr);
248 exit(1); 239 EXIT(1);
249 return(1); 240 return(1);
250 } 241 }
251 242
@@ -488,7 +479,7 @@ int test_mul(BIO *bp)
488 BN_CTX *ctx; 479 BN_CTX *ctx;
489 480
490 ctx = BN_CTX_new(); 481 ctx = BN_CTX_new();
491 if (ctx == NULL) exit(1); 482 if (ctx == NULL) EXIT(1);
492 483
493 BN_init(&a); 484 BN_init(&a);
494 BN_init(&b); 485 BN_init(&b);
@@ -726,7 +717,7 @@ int test_mod_mul(BIO *bp, BN_CTX *ctx)
726 while ((l=ERR_get_error())) 717 while ((l=ERR_get_error()))
727 fprintf(stderr,"ERROR:%s\n", 718 fprintf(stderr,"ERROR:%s\n",
728 ERR_error_string(l,NULL)); 719 ERR_error_string(l,NULL));
729 exit(1); 720 EXIT(1);
730 } 721 }
731 if (bp != NULL) 722 if (bp != NULL)
732 { 723 {
diff --git a/src/lib/libcrypto/bn/divtest.c b/src/lib/libcrypto/bn/divtest.c
index 13ba86e3c4..d3fc688f33 100644
--- a/src/lib/libcrypto/bn/divtest.c
+++ b/src/lib/libcrypto/bn/divtest.c
@@ -1,7 +1,7 @@
1#include <openssl/bn.h> 1#include <openssl/bn.h>
2#include <openssl/rand.h> 2#include <openssl/rand.h>
3 3
4static int rand(n) 4static int Rand(n)
5{ 5{
6 unsigned char x[2]; 6 unsigned char x[2];
7 RAND_pseudo_bytes(x,2); 7 RAND_pseudo_bytes(x,2);
@@ -26,8 +26,8 @@ main()
26 BN_CTX *ctx=BN_CTX_new(); 26 BN_CTX *ctx=BN_CTX_new();
27 27
28 for(;;) { 28 for(;;) {
29 BN_pseudo_rand(a,rand(),0,0); 29 BN_pseudo_rand(a,Rand(),0,0);
30 BN_pseudo_rand(b,rand(),0,0); 30 BN_pseudo_rand(b,Rand(),0,0);
31 if (BN_is_zero(b)) continue; 31 if (BN_is_zero(b)) continue;
32 32
33 BN_RECP_CTX_set(recp,b,ctx); 33 BN_RECP_CTX_set(recp,b,ctx);
diff --git a/src/lib/libcrypto/bn/exptest.c b/src/lib/libcrypto/bn/exptest.c
index 5ca570d1a8..b09cf88705 100644
--- a/src/lib/libcrypto/bn/exptest.c
+++ b/src/lib/libcrypto/bn/exptest.c
@@ -59,13 +59,13 @@
59#include <stdio.h> 59#include <stdio.h>
60#include <stdlib.h> 60#include <stdlib.h>
61#include <string.h> 61#include <string.h>
62
63#include "../e_os.h"
64
62#include <openssl/bio.h> 65#include <openssl/bio.h>
63#include <openssl/bn.h> 66#include <openssl/bn.h>
64#include <openssl/rand.h> 67#include <openssl/rand.h>
65#include <openssl/err.h> 68#include <openssl/err.h>
66#ifdef OPENSSL_SYS_WINDOWS
67#include "../bio/bss_file.c"
68#endif
69 69
70#define NUM_BITS (BN_BITS*2) 70#define NUM_BITS (BN_BITS*2)
71 71
@@ -86,7 +86,7 @@ int main(int argc, char *argv[])
86 ERR_load_BN_strings(); 86 ERR_load_BN_strings();
87 87
88 ctx=BN_CTX_new(); 88 ctx=BN_CTX_new();
89 if (ctx == NULL) exit(1); 89 if (ctx == NULL) EXIT(1);
90 r_mont=BN_new(); 90 r_mont=BN_new();
91 r_recp=BN_new(); 91 r_recp=BN_new();
92 r_simple=BN_new(); 92 r_simple=BN_new();
@@ -99,7 +99,7 @@ int main(int argc, char *argv[])
99 99
100 out=BIO_new(BIO_s_file()); 100 out=BIO_new(BIO_s_file());
101 101
102 if (out == NULL) exit(1); 102 if (out == NULL) EXIT(1);
103 BIO_set_fp(out,stdout,BIO_NOCLOSE); 103 BIO_set_fp(out,stdout,BIO_NOCLOSE);
104 104
105 for (i=0; i<200; i++) 105 for (i=0; i<200; i++)
@@ -124,7 +124,7 @@ int main(int argc, char *argv[])
124 { 124 {
125 printf("BN_mod_exp_mont() problems\n"); 125 printf("BN_mod_exp_mont() problems\n");
126 ERR_print_errors(out); 126 ERR_print_errors(out);
127 exit(1); 127 EXIT(1);
128 } 128 }
129 129
130 ret=BN_mod_exp_recp(r_recp,a,b,m,ctx); 130 ret=BN_mod_exp_recp(r_recp,a,b,m,ctx);
@@ -132,7 +132,7 @@ int main(int argc, char *argv[])
132 { 132 {
133 printf("BN_mod_exp_recp() problems\n"); 133 printf("BN_mod_exp_recp() problems\n");
134 ERR_print_errors(out); 134 ERR_print_errors(out);
135 exit(1); 135 EXIT(1);
136 } 136 }
137 137
138 ret=BN_mod_exp_simple(r_simple,a,b,m,ctx); 138 ret=BN_mod_exp_simple(r_simple,a,b,m,ctx);
@@ -140,7 +140,7 @@ int main(int argc, char *argv[])
140 { 140 {
141 printf("BN_mod_exp_simple() problems\n"); 141 printf("BN_mod_exp_simple() problems\n");
142 ERR_print_errors(out); 142 ERR_print_errors(out);
143 exit(1); 143 EXIT(1);
144 } 144 }
145 145
146 if (BN_cmp(r_simple, r_mont) == 0 146 if (BN_cmp(r_simple, r_mont) == 0
@@ -163,7 +163,7 @@ int main(int argc, char *argv[])
163 printf("\nrecp ="); BN_print(out,r_recp); 163 printf("\nrecp ="); BN_print(out,r_recp);
164 printf("\nmont ="); BN_print(out,r_mont); 164 printf("\nmont ="); BN_print(out,r_mont);
165 printf("\n"); 165 printf("\n");
166 exit(1); 166 EXIT(1);
167 } 167 }
168 } 168 }
169 BN_free(r_mont); 169 BN_free(r_mont);
@@ -177,11 +177,11 @@ int main(int argc, char *argv[])
177 CRYPTO_mem_leaks(out); 177 CRYPTO_mem_leaks(out);
178 BIO_free(out); 178 BIO_free(out);
179 printf(" done\n"); 179 printf(" done\n");
180 exit(0); 180 EXIT(0);
181err: 181err:
182 ERR_load_crypto_strings(); 182 ERR_load_crypto_strings();
183 ERR_print_errors(out); 183 ERR_print_errors(out);
184 exit(1); 184 EXIT(1);
185 return(1); 185 return(1);
186 } 186 }
187 187
diff --git a/src/lib/libcrypto/buffer/Makefile.ssl b/src/lib/libcrypto/buffer/Makefile.ssl
index 240a6b9a89..b131ca3078 100644
--- a/src/lib/libcrypto/buffer/Makefile.ssl
+++ b/src/lib/libcrypto/buffer/Makefile.ssl
@@ -68,7 +68,7 @@ lint:
68 lint -DLINT $(INCLUDES) $(SRC)>fluff 68 lint -DLINT $(INCLUDES) $(SRC)>fluff
69 69
70depend: 70depend:
71 $(MAKEDEPEND) $(CFLAG) $(INCLUDES) $(DEPFLAG) $(PROGS) $(LIBSRC) 71 $(MAKEDEPEND) -- $(CFLAG) $(INCLUDES) $(DEPFLAG) -- $(PROGS) $(LIBSRC)
72 72
73dclean: 73dclean:
74 $(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new 74 $(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
diff --git a/src/lib/libcrypto/buffer/buffer.c b/src/lib/libcrypto/buffer/buffer.c
index 9299baba9e..d96487e7db 100644
--- a/src/lib/libcrypto/buffer/buffer.c
+++ b/src/lib/libcrypto/buffer/buffer.c
@@ -125,6 +125,43 @@ int BUF_MEM_grow(BUF_MEM *str, int len)
125 return(len); 125 return(len);
126 } 126 }
127 127
128int BUF_MEM_grow_clean(BUF_MEM *str, int len)
129 {
130 char *ret;
131 unsigned int n;
132
133 if (str->length >= len)
134 {
135 memset(&str->data[len],0,str->length-len);
136 str->length=len;
137 return(len);
138 }
139 if (str->max >= len)
140 {
141 memset(&str->data[str->length],0,len-str->length);
142 str->length=len;
143 return(len);
144 }
145 n=(len+3)/3*4;
146 if (str->data == NULL)
147 ret=OPENSSL_malloc(n);
148 else
149 ret=OPENSSL_realloc_clean(str->data,str->max,n);
150 if (ret == NULL)
151 {
152 BUFerr(BUF_F_BUF_MEM_GROW,ERR_R_MALLOC_FAILURE);
153 len=0;
154 }
155 else
156 {
157 str->data=ret;
158 str->max=n;
159 memset(&str->data[str->length],0,len-str->length);
160 str->length=len;
161 }
162 return(len);
163 }
164
128char *BUF_strdup(const char *str) 165char *BUF_strdup(const char *str)
129 { 166 {
130 char *ret; 167 char *ret;
@@ -143,3 +180,23 @@ char *BUF_strdup(const char *str)
143 return(ret); 180 return(ret);
144 } 181 }
145 182
183size_t BUF_strlcpy(char *dst, const char *src, size_t size)
184 {
185 size_t l = 0;
186 for(; size > 1 && *src; size--)
187 {
188 *dst++ = *src++;
189 l++;
190 }
191 if (size)
192 *dst = '\0';
193 return l + strlen(src);
194 }
195
196size_t BUF_strlcat(char *dst, const char *src, size_t size)
197 {
198 size_t l = 0;
199 for(; size > 0 && *dst; size--, dst++)
200 l++;
201 return l + BUF_strlcpy(dst, src, size);
202 }
diff --git a/src/lib/libcrypto/buffer/buffer.h b/src/lib/libcrypto/buffer/buffer.h
index 11e2d0359a..465dc34f3f 100644
--- a/src/lib/libcrypto/buffer/buffer.h
+++ b/src/lib/libcrypto/buffer/buffer.h
@@ -63,6 +63,9 @@
63extern "C" { 63extern "C" {
64#endif 64#endif
65 65
66#include <stddef.h>
67#include <sys/types.h>
68
66typedef struct buf_mem_st 69typedef struct buf_mem_st
67 { 70 {
68 int length; /* current number of bytes */ 71 int length; /* current number of bytes */
@@ -73,8 +76,14 @@ typedef struct buf_mem_st
73BUF_MEM *BUF_MEM_new(void); 76BUF_MEM *BUF_MEM_new(void);
74void BUF_MEM_free(BUF_MEM *a); 77void BUF_MEM_free(BUF_MEM *a);
75int BUF_MEM_grow(BUF_MEM *str, int len); 78int BUF_MEM_grow(BUF_MEM *str, int len);
79int BUF_MEM_grow_clean(BUF_MEM *str, int len);
76char * BUF_strdup(const char *str); 80char * BUF_strdup(const char *str);
77 81
82/* safe string functions */
83size_t BUF_strlcpy(char *dst,const char *src,size_t siz);
84size_t BUF_strlcat(char *dst,const char *src,size_t siz);
85
86
78/* BEGIN ERROR CODES */ 87/* BEGIN ERROR CODES */
79/* The following lines are auto generated by the script mkerr.pl. Any changes 88/* The following lines are auto generated by the script mkerr.pl. Any changes
80 * made after this point may be overwritten when the script is next run. 89 * made after this point may be overwritten when the script is next run.
diff --git a/src/lib/libcrypto/cast/Makefile.ssl b/src/lib/libcrypto/cast/Makefile.ssl
index 2defbdd68a..2dc1c855ad 100644
--- a/src/lib/libcrypto/cast/Makefile.ssl
+++ b/src/lib/libcrypto/cast/Makefile.ssl
@@ -52,14 +52,8 @@ lib: $(LIBOBJ)
52 @touch lib 52 @touch lib
53 53
54# elf 54# elf
55asm/cx86-elf.o: asm/cx86unix.cpp 55asm/cx86-elf.s: asm/cast-586.pl ../perlasm/x86asm.pl ../perlasm/cbc.pl
56 $(CPP) -DELF -x c asm/cx86unix.cpp | as -o asm/cx86-elf.o 56 (cd asm; $(PERL) cast-586.pl elf $(CLAGS) $(PROCESSOR) > cx86-elf.s)
57
58# solaris
59asm/cx86-sol.o: asm/cx86unix.cpp
60 $(CC) -E -DSOL asm/cx86unix.cpp | sed 's/^#.*//' > asm/cx86-sol.s
61 as -o asm/cx86-sol.o asm/cx86-sol.s
62 rm -f asm/cx86-sol.s
63 57
64# a.out 58# a.out
65asm/cx86-out.o: asm/cx86unix.cpp 59asm/cx86-out.o: asm/cx86unix.cpp
@@ -97,14 +91,14 @@ lint:
97 lint -DLINT $(INCLUDES) $(SRC)>fluff 91 lint -DLINT $(INCLUDES) $(SRC)>fluff
98 92
99depend: 93depend:
100 $(MAKEDEPEND) $(CFLAG) $(INCLUDES) $(DEPFLAG) $(PROGS) $(LIBSRC) 94 $(MAKEDEPEND) -- $(CFLAG) $(INCLUDES) $(DEPFLAG) -- $(PROGS) $(LIBSRC)
101 95
102dclean: 96dclean:
103 $(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new 97 $(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
104 mv -f Makefile.new $(MAKEFILE) 98 mv -f Makefile.new $(MAKEFILE)
105 99
106clean: 100clean:
107 rm -f asm/cx86unix.cpp *.o asm/*.o *.obj lib tags core .pure .nfs* *.old *.bak fluff 101 rm -f asm/cx86unix.cpp asm/*-elf.* *.o asm/*.o *.obj lib tags core .pure .nfs* *.old *.bak fluff
108 102
109# DO NOT DELETE THIS LINE -- make depend depends on it. 103# DO NOT DELETE THIS LINE -- make depend depends on it.
110 104
diff --git a/src/lib/libcrypto/cast/casttest.c b/src/lib/libcrypto/cast/casttest.c
index 099e790886..83e5a16c73 100644
--- a/src/lib/libcrypto/cast/casttest.c
+++ b/src/lib/libcrypto/cast/casttest.c
@@ -60,6 +60,8 @@
60#include <string.h> 60#include <string.h>
61#include <stdlib.h> 61#include <stdlib.h>
62 62
63#include "../e_os.h"
64
63#ifdef OPENSSL_NO_CAST 65#ifdef OPENSSL_NO_CAST
64int main(int argc, char *argv[]) 66int main(int argc, char *argv[])
65{ 67{
@@ -224,7 +226,7 @@ int main(int argc, char *argv[])
224 } 226 }
225#endif 227#endif
226 228
227 exit(err); 229 EXIT(err);
228 return(err); 230 return(err);
229 } 231 }
230#endif 232#endif
diff --git a/src/lib/libcrypto/comp/Makefile.ssl b/src/lib/libcrypto/comp/Makefile.ssl
index 7c1ec81229..f70ba1b285 100644
--- a/src/lib/libcrypto/comp/Makefile.ssl
+++ b/src/lib/libcrypto/comp/Makefile.ssl
@@ -71,7 +71,7 @@ lint:
71 lint -DLINT $(INCLUDES) $(SRC)>fluff 71 lint -DLINT $(INCLUDES) $(SRC)>fluff
72 72
73depend: 73depend:
74 $(MAKEDEPEND) $(CFLAG) $(INCLUDES) $(DEPFLAG) $(LIBSRC) 74 $(MAKEDEPEND) -- $(CFLAG) $(INCLUDES) $(DEPFLAG) -- $(LIBSRC)
75 75
76dclean: 76dclean:
77 $(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new 77 $(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
diff --git a/src/lib/libcrypto/comp/c_zlib.c b/src/lib/libcrypto/comp/c_zlib.c
index cd2f8a491b..8c0876151a 100644
--- a/src/lib/libcrypto/comp/c_zlib.c
+++ b/src/lib/libcrypto/comp/c_zlib.c
@@ -208,11 +208,11 @@ COMP_METHOD *COMP_zlib(void)
208 = (inflateInit__ft) DSO_bind_func(zlib_dso, 208 = (inflateInit__ft) DSO_bind_func(zlib_dso,
209 "inflateInit_"); 209 "inflateInit_");
210 zlib_loaded++; 210 zlib_loaded++;
211 meth = &zlib_method;
212 } 211 }
213 } 212 }
214 213
215#elif defined(ZLIB) 214#endif
215#if defined(ZLIB) || defined(ZLIB_SHARED)
216 meth = &zlib_method; 216 meth = &zlib_method;
217#endif 217#endif
218 218
diff --git a/src/lib/libcrypto/conf/Makefile.ssl b/src/lib/libcrypto/conf/Makefile.ssl
index 133c2329e6..c5873bc6e7 100644
--- a/src/lib/libcrypto/conf/Makefile.ssl
+++ b/src/lib/libcrypto/conf/Makefile.ssl
@@ -71,7 +71,7 @@ lint:
71 lint -DLINT $(INCLUDES) $(SRC)>fluff 71 lint -DLINT $(INCLUDES) $(SRC)>fluff
72 72
73depend: 73depend:
74 $(MAKEDEPEND) $(CFLAG) $(INCLUDES) $(DEPFLAG) $(LIBSRC) 74 $(MAKEDEPEND) -- $(CFLAG) $(INCLUDES) $(DEPFLAG) -- $(LIBSRC)
75 75
76dclean: 76dclean:
77 $(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new 77 $(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
diff --git a/src/lib/libcrypto/conf/conf_def.c b/src/lib/libcrypto/conf/conf_def.c
index 48ff6f1120..b52ee01a3c 100644
--- a/src/lib/libcrypto/conf/conf_def.c
+++ b/src/lib/libcrypto/conf/conf_def.c
@@ -208,7 +208,8 @@ static int def_load(CONF *conf, const char *name, long *line)
208 208
209static int def_load_bio(CONF *conf, BIO *in, long *line) 209static int def_load_bio(CONF *conf, BIO *in, long *line)
210 { 210 {
211#define BUFSIZE 512 211/* The macro BUFSIZE conflicts with a system macro in VxWorks */
212#define CONFBUFSIZE 512
212 int bufnum=0,i,ii; 213 int bufnum=0,i,ii;
213 BUF_MEM *buff=NULL; 214 BUF_MEM *buff=NULL;
214 char *s,*p,*end; 215 char *s,*p,*end;
@@ -252,20 +253,21 @@ static int def_load_bio(CONF *conf, BIO *in, long *line)
252 section_sk=(STACK_OF(CONF_VALUE) *)sv->value; 253 section_sk=(STACK_OF(CONF_VALUE) *)sv->value;
253 254
254 bufnum=0; 255 bufnum=0;
256 again=0;
255 for (;;) 257 for (;;)
256 { 258 {
257 again=0; 259 if (!BUF_MEM_grow(buff,bufnum+CONFBUFSIZE))
258 if (!BUF_MEM_grow(buff,bufnum+BUFSIZE))
259 { 260 {
260 CONFerr(CONF_F_CONF_LOAD_BIO,ERR_R_BUF_LIB); 261 CONFerr(CONF_F_CONF_LOAD_BIO,ERR_R_BUF_LIB);
261 goto err; 262 goto err;
262 } 263 }
263 p= &(buff->data[bufnum]); 264 p= &(buff->data[bufnum]);
264 *p='\0'; 265 *p='\0';
265 BIO_gets(in, p, BUFSIZE-1); 266 BIO_gets(in, p, CONFBUFSIZE-1);
266 p[BUFSIZE-1]='\0'; 267 p[CONFBUFSIZE-1]='\0';
267 ii=i=strlen(p); 268 ii=i=strlen(p);
268 if (i == 0) break; 269 if (i == 0 && !again) break;
270 again=0;
269 while (i > 0) 271 while (i > 0)
270 { 272 {
271 if ((p[i-1] != '\r') && (p[i-1] != '\n')) 273 if ((p[i-1] != '\r') && (p[i-1] != '\n'))
@@ -275,7 +277,7 @@ static int def_load_bio(CONF *conf, BIO *in, long *line)
275 } 277 }
276 /* we removed some trailing stuff so there is a new 278 /* we removed some trailing stuff so there is a new
277 * line on the end. */ 279 * line on the end. */
278 if (i == ii) 280 if (ii && i == ii)
279 again=1; /* long line */ 281 again=1; /* long line */
280 else 282 else
281 { 283 {
@@ -627,7 +629,7 @@ static int str_copy(CONF *conf, char *section, char **pto, char *from)
627 CONFerr(CONF_F_STR_COPY,CONF_R_VARIABLE_HAS_NO_VALUE); 629 CONFerr(CONF_F_STR_COPY,CONF_R_VARIABLE_HAS_NO_VALUE);
628 goto err; 630 goto err;
629 } 631 }
630 BUF_MEM_grow(buf,(strlen(p)+len-(e-from))); 632 BUF_MEM_grow_clean(buf,(strlen(p)+len-(e-from)));
631 while (*p) 633 while (*p)
632 buf->data[to++]= *(p++); 634 buf->data[to++]= *(p++);
633 from=e; 635 from=e;
diff --git a/src/lib/libcrypto/conf/conf_mall.c b/src/lib/libcrypto/conf/conf_mall.c
index d702af689b..4ba40cf44c 100644
--- a/src/lib/libcrypto/conf/conf_mall.c
+++ b/src/lib/libcrypto/conf/conf_mall.c
@@ -63,7 +63,9 @@
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#ifndef OPENSSL_NO_ENGINE
66#include <openssl/engine.h> 67#include <openssl/engine.h>
68#endif
67 69
68/* Load all OpenSSL builtin modules */ 70/* Load all OpenSSL builtin modules */
69 71
@@ -71,6 +73,8 @@ void OPENSSL_load_builtin_modules(void)
71 { 73 {
72 /* Add builtin modules here */ 74 /* Add builtin modules here */
73 ASN1_add_oid_module(); 75 ASN1_add_oid_module();
76#ifndef OPENSSL_NO_ENGINE
74 ENGINE_add_conf_module(); 77 ENGINE_add_conf_module();
78#endif
75 } 79 }
76 80
diff --git a/src/lib/libcrypto/conf/conf_sap.c b/src/lib/libcrypto/conf/conf_sap.c
index 97fb174303..e15c2e5546 100644
--- a/src/lib/libcrypto/conf/conf_sap.c
+++ b/src/lib/libcrypto/conf/conf_sap.c
@@ -63,7 +63,9 @@
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#ifndef OPENSSL_NO_ENGINE
66#include <openssl/engine.h> 67#include <openssl/engine.h>
68#endif
67 69
68/* This is the automatic configuration loader: it is called automatically by 70/* This is the automatic configuration loader: it is called automatically by
69 * OpenSSL when any of a number of standard initialisation functions are called, 71 * OpenSSL when any of a number of standard initialisation functions are called,
@@ -78,8 +80,10 @@ void OPENSSL_config(const char *config_name)
78 return; 80 return;
79 81
80 OPENSSL_load_builtin_modules(); 82 OPENSSL_load_builtin_modules();
83#ifndef OPENSSL_NO_ENGINE
81 /* Need to load ENGINEs */ 84 /* Need to load ENGINEs */
82 ENGINE_load_builtin_engines(); 85 ENGINE_load_builtin_engines();
86#endif
83 /* Add others here? */ 87 /* Add others here? */
84 88
85 89
diff --git a/src/lib/libcrypto/cryptlib.c b/src/lib/libcrypto/cryptlib.c
index 612b3b93b4..2924def2bb 100644
--- a/src/lib/libcrypto/cryptlib.c
+++ b/src/lib/libcrypto/cryptlib.c
@@ -89,6 +89,7 @@ static const char* lock_names[CRYPTO_NUM_LOCKS] =
89 "ssl_session", 89 "ssl_session",
90 "ssl_sess_cert", 90 "ssl_sess_cert",
91 "ssl", 91 "ssl",
92 "ssl_method",
92 "rand", 93 "rand",
93 "rand2", 94 "rand2",
94 "debug_malloc", 95 "debug_malloc",
@@ -103,7 +104,8 @@ static const char* lock_names[CRYPTO_NUM_LOCKS] =
103 "dynlock", 104 "dynlock",
104 "engine", 105 "engine",
105 "ui", 106 "ui",
106#if CRYPTO_NUM_LOCKS != 31 107 "hwcrhk", /* This is a HACK which will disappear in 0.9.8 */
108#if CRYPTO_NUM_LOCKS != 33
107# error "Inconsistency between crypto.h and cryptlib.c" 109# error "Inconsistency between crypto.h and cryptlib.c"
108#endif 110#endif
109 }; 111 };
@@ -206,10 +208,18 @@ int CRYPTO_get_new_dynlockid(void)
206 i=sk_CRYPTO_dynlock_find(dyn_locks,NULL); 208 i=sk_CRYPTO_dynlock_find(dyn_locks,NULL);
207 /* If there was none, push, thereby creating a new one */ 209 /* If there was none, push, thereby creating a new one */
208 if (i == -1) 210 if (i == -1)
209 i=sk_CRYPTO_dynlock_push(dyn_locks,pointer); 211 /* Since sk_push() returns the number of items on the
212 stack, not the location of the pushed item, we need
213 to transform the returned number into a position,
214 by decreasing it. */
215 i=sk_CRYPTO_dynlock_push(dyn_locks,pointer) - 1;
216 else
217 /* If we found a place with a NULL pointer, put our pointer
218 in it. */
219 sk_CRYPTO_dynlock_set(dyn_locks,i,pointer);
210 CRYPTO_w_unlock(CRYPTO_LOCK_DYNLOCK); 220 CRYPTO_w_unlock(CRYPTO_LOCK_DYNLOCK);
211 221
212 if (!i) 222 if (i == -1)
213 { 223 {
214 dynlock_destroy_callback(pointer->data,__FILE__,__LINE__); 224 dynlock_destroy_callback(pointer->data,__FILE__,__LINE__);
215 OPENSSL_free(pointer); 225 OPENSSL_free(pointer);
@@ -401,15 +411,17 @@ void CRYPTO_lock(int mode, int type, const char *file, int line)
401#endif 411#endif
402 if (type < 0) 412 if (type < 0)
403 { 413 {
404 struct CRYPTO_dynlock_value *pointer 414 if (dynlock_lock_callback != NULL)
405 = CRYPTO_get_dynlock_value(type);
406
407 if (pointer && dynlock_lock_callback)
408 { 415 {
416 struct CRYPTO_dynlock_value *pointer
417 = CRYPTO_get_dynlock_value(type);
418
419 OPENSSL_assert(pointer != NULL);
420
409 dynlock_lock_callback(mode, pointer, file, line); 421 dynlock_lock_callback(mode, pointer, file, line);
410 }
411 422
412 CRYPTO_destroy_dynlockid(type); 423 CRYPTO_destroy_dynlockid(type);
424 }
413 } 425 }
414 else 426 else
415 if (locking_callback != NULL) 427 if (locking_callback != NULL)
@@ -460,7 +472,7 @@ const char *CRYPTO_get_lock_name(int type)
460 return("dynamic"); 472 return("dynamic");
461 else if (type < CRYPTO_NUM_LOCKS) 473 else if (type < CRYPTO_NUM_LOCKS)
462 return(lock_names[type]); 474 return(lock_names[type]);
463 else if (type-CRYPTO_NUM_LOCKS >= sk_num(app_locks)) 475 else if (type-CRYPTO_NUM_LOCKS > sk_num(app_locks))
464 return("ERROR"); 476 return("ERROR");
465 else 477 else
466 return(sk_value(app_locks,type-CRYPTO_NUM_LOCKS)); 478 return(sk_value(app_locks,type-CRYPTO_NUM_LOCKS));
@@ -492,3 +504,11 @@ BOOL WINAPI DLLEntryPoint(HINSTANCE hinstDLL, DWORD fdwReason,
492#endif 504#endif
493 505
494#endif 506#endif
507
508void OpenSSLDie(const char *file,int line,const char *assertion)
509 {
510 fprintf(stderr,
511 "%s(%d): OpenSSL internal error, assertion failed: %s\n",
512 file,line,assertion);
513 abort();
514 }
diff --git a/src/lib/libcrypto/cryptlib.h b/src/lib/libcrypto/cryptlib.h
index 88e4ae509f..0d6b9d59f0 100644
--- a/src/lib/libcrypto/cryptlib.h
+++ b/src/lib/libcrypto/cryptlib.h
@@ -89,9 +89,9 @@ extern "C" {
89#define X509_CERT_DIR_EVP "SSL_CERT_DIR" 89#define X509_CERT_DIR_EVP "SSL_CERT_DIR"
90#define X509_CERT_FILE_EVP "SSL_CERT_FILE" 90#define X509_CERT_FILE_EVP "SSL_CERT_FILE"
91 91
92/* size of string represenations */ 92/* size of string representations */
93#define DECIMAL_SIZE(type) ((sizeof(type)*8+2)/3+1) 93#define DECIMAL_SIZE(type) ((sizeof(type)*8+2)/3+1)
94#define HEX_SIZE(type) ((sizeof(type)*2) 94#define HEX_SIZE(type) (sizeof(type)*2)
95 95
96#ifdef __cplusplus 96#ifdef __cplusplus
97} 97}
diff --git a/src/lib/libcrypto/crypto-lib.com b/src/lib/libcrypto/crypto-lib.com
index dfcff11860..39e78c69e5 100644
--- a/src/lib/libcrypto/crypto-lib.com
+++ b/src/lib/libcrypto/crypto-lib.com
@@ -21,22 +21,10 @@ $! LIBRARY To just compile the [.xxx.EXE.CRYPTO]LIBCRYPTO.OLB Library.
21$! APPS To just compile the [.xxx.EXE.CRYPTO]*.EXE 21$! APPS To just compile the [.xxx.EXE.CRYPTO]*.EXE
22$! ALL To do both LIBRARY and APPS 22$! ALL To do both LIBRARY and APPS
23$! 23$!
24$! Specify RSAREF as P2 to compile with the RSAREF library instead of 24$! Specify DEBUG or NODEBUG as P2 to compile with or without debugger
25$! the regular one. If you specify NORSAREF it will compile with the
26$! regular RSAREF routines. (Note: If you are in the United States
27$! you MUST compile with RSAREF unless you have a license from RSA).
28$!
29$! Note: The RSAREF libraries are NOT INCLUDED and you have to
30$! download it from "ftp://ftp.rsa.com/rsaref". You have to
31$! get the ".tar-Z" file as the ".zip" file dosen't have the
32$! directory structure stored. You have to extract the file
33$! into the [.RSAREF] directory under the root directory as that
34$! is where the scripts will look for the files.
35$!
36$! Specify DEBUG or NODEBUG as P3 to compile with or without debugger
37$! information. 25$! information.
38$! 26$!
39$! Specify which compiler at P4 to try to compile under. 27$! Specify which compiler at P3 to try to compile under.
40$! 28$!
41$! VAXC For VAX C. 29$! VAXC For VAX C.
42$! DECC For DEC C. 30$! DECC For DEC C.
@@ -45,16 +33,16 @@ $!
45$! If you don't speficy a compiler, it will try to determine which 33$! If you don't speficy a compiler, it will try to determine which
46$! "C" compiler to use. 34$! "C" compiler to use.
47$! 35$!
48$! P5, if defined, sets a TCP/IP library to use, through one of the following 36$! P4, if defined, sets a TCP/IP library to use, through one of the following
49$! keywords: 37$! keywords:
50$! 38$!
51$! UCX for UCX 39$! UCX for UCX
52$! TCPIP for TCPIP (post UCX) 40$! TCPIP for TCPIP (post UCX)
53$! SOCKETSHR for SOCKETSHR+NETLIB 41$! SOCKETSHR for SOCKETSHR+NETLIB
54$! 42$!
55$! P6, if defined, sets a compiler thread NOT needed on OpenVMS 7.1 (and up) 43$! P5, if defined, sets a compiler thread NOT needed on OpenVMS 7.1 (and up)
56$! 44$!
57$! P7, if defined, sets a choice of crypto methods to compile. 45$! P6, if defined, sets a choice of crypto methods to compile.
58$! WARNING: this should only be done to recompile some part of an already 46$! WARNING: this should only be done to recompile some part of an already
59$! fully compiled library. 47$! fully compiled library.
60$! 48$!
@@ -93,7 +81,6 @@ $ ENCRYPT_TYPES = "Basic,MD2,MD4,MD5,SHA,MDC2,HMAC,RIPEMD,"+ -
93 "BUFFER,BIO,STACK,LHASH,RAND,ERR,OBJECTS,"+ - 81 "BUFFER,BIO,STACK,LHASH,RAND,ERR,OBJECTS,"+ -
94 "EVP,EVP_2,ASN1,ASN1_2,PEM,X509,X509V3,"+ - 82 "EVP,EVP_2,ASN1,ASN1_2,PEM,X509,X509V3,"+ -
95 "CONF,TXT_DB,PKCS7,PKCS12,COMP,OCSP,UI,KRB5" 83 "CONF,TXT_DB,PKCS7,PKCS12,COMP,OCSP,UI,KRB5"
96$ ENCRYPT_PROGRAMS = "DES,PKCS7"
97$! 84$!
98$! Check To Make Sure We Have Valid Command Line Parameters. 85$! Check To Make Sure We Have Valid Command Line Parameters.
99$! 86$!
@@ -149,10 +136,6 @@ $! Define The CRYPTO-LIB We Are To Use.
149$! 136$!
150$ CRYPTO_LIB := 'EXE_DIR'LIBCRYPTO.OLB 137$ CRYPTO_LIB := 'EXE_DIR'LIBCRYPTO.OLB
151$! 138$!
152$! Define The RSAREF-LIB We Are To Use.
153$!
154$ RSAREF_LIB := SYS$DISK:[-.'ARCH'.EXE.RSAREF]LIBRSAGLUE.OLB
155$!
156$! Check To See If We Already Have A "[.xxx.EXE.CRYPTO]LIBCRYPTO.OLB" Library... 139$! Check To See If We Already Have A "[.xxx.EXE.CRYPTO]LIBCRYPTO.OLB" Library...
157$! 140$!
158$ IF (F$SEARCH(LIB_NAME).EQS."") 141$ IF (F$SEARCH(LIB_NAME).EQS."")
@@ -175,7 +158,7 @@ $!
175$ APPS_DES = "DES/DES,CBC3_ENC" 158$ APPS_DES = "DES/DES,CBC3_ENC"
176$ APPS_PKCS7 = "ENC/ENC;DEC/DEC;SIGN/SIGN;VERIFY/VERIFY,EXAMPLE" 159$ APPS_PKCS7 = "ENC/ENC;DEC/DEC;SIGN/SIGN;VERIFY/VERIFY,EXAMPLE"
177$ 160$
178$ LIB_ = "cryptlib,mem,mem_dbg,cversion,ex_data,tmdiff,cpt_err,ebcdic,uid,o_time" 161$ LIB_ = "cryptlib,mem,mem_clr,mem_dbg,cversion,ex_data,tmdiff,cpt_err,ebcdic,uid,o_time"
179$ LIB_MD2 = "md2_dgst,md2_one" 162$ LIB_MD2 = "md2_dgst,md2_one"
180$ LIB_MD4 = "md4_dgst,md4_one" 163$ LIB_MD4 = "md4_dgst,md4_one"
181$ LIB_MD5 = "md5_dgst,md5_one" 164$ LIB_MD5 = "md5_dgst,md5_one"
@@ -216,7 +199,7 @@ $ LIB_ENGINE = "eng_err,eng_lib,eng_list,eng_init,eng_ctrl,"+ -
216 "tb_rsa,tb_dsa,tb_dh,tb_rand,tb_cipher,tb_digest,"+ - 199 "tb_rsa,tb_dsa,tb_dh,tb_rand,tb_cipher,tb_digest,"+ -
217 "eng_openssl,eng_dyn,eng_cnf,"+ - 200 "eng_openssl,eng_dyn,eng_cnf,"+ -
218 "hw_atalla,hw_cswift,hw_ncipher,hw_nuron,hw_ubsec,"+ - 201 "hw_atalla,hw_cswift,hw_ncipher,hw_nuron,hw_ubsec,"+ -
219 "hw_openbsd_dev_crypto,hw_aep,hw_sureware,hw_4758_cca" 202 "hw_cryptodev,hw_aep,hw_sureware,hw_4758_cca"
220$ LIB_AES = "aes_core,aes_misc,aes_ecb,aes_cbc,aes_cfb,aes_ofb,aes_ctr" 203$ LIB_AES = "aes_core,aes_misc,aes_ecb,aes_cbc,aes_cfb,aes_ofb,aes_ctr"
221$ LIB_BUFFER = "buffer,buf_err" 204$ LIB_BUFFER = "buffer,buf_err"
222$ LIB_BIO = "bio_lib,bio_cb,bio_err,"+ - 205$ LIB_BIO = "bio_lib,bio_cb,bio_err,"+ -
@@ -287,86 +270,6 @@ $ COMPILEWITH_CC4 = ",a_utctm,bss_log,o_time,"
287$ COMPILEWITH_CC5 = ",md2_dgst,md4_dgst,md5_dgst,mdc2dgst," + - 270$ COMPILEWITH_CC5 = ",md2_dgst,md4_dgst,md5_dgst,mdc2dgst," + -
288 "sha_dgst,sha1dgst,rmd_dgst,bf_enc," 271 "sha_dgst,sha1dgst,rmd_dgst,bf_enc,"
289$! 272$!
290$! Check To See If We Are Going To Use RSAREF.
291$!
292$ IF (RSAREF.EQS."TRUE" .AND. ENCRYPT_TYPES - "RSA".NES.ENCRYPT_TYPES -
293 .AND. (BUILDALL .EQS. "TRUE" .OR. BUILDALL .EQS. "LIBRARY"))
294$ THEN
295$!
296$! Check To See If The File [-.RSAREF]RSAREF.C Is Actually There.
297$!
298$ IF (F$SEARCH("SYS$DISK:[-.RSAREF]RSAREF.C").EQS."")
299$ THEN
300$!
301$! Tell The User That The File Doesn't Exist.
302$!
303$ WRITE SYS$OUTPUT ""
304$ WRITE SYS$OUTPUT "The File [-.RSAREF]RSAREF.C Doesn't Exist."
305$ WRITE SYS$OUTPUT ""
306$!
307$! Exit The Build.
308$!
309$ GOTO EXIT
310$!
311$! End The [-.RSAREF]RSAREF.C Check.
312$!
313$ ENDIF
314$!
315$! Tell The User We Are Compiling The [-.RSAREF]RSAREF File.
316$!
317$ WRITE SYS$OUTPUT "Compiling The [-.RSAREF]RSAREF File."
318$!
319$! Compile [-.RSAREF]RSAREF.C
320$!
321$ CC/OBJECT='OBJ_DIR'RSAREF.OBJ SYS$DISK:[-.RSAREF]RSAREF.C
322$!
323$! Add It To The Library.
324$!
325$ LIBRARY/REPLACE 'LIB_NAME' 'OBJ_DIR'RSAREF.OBJ
326$!
327$! Delete The Object File.
328$!
329$ DELETE 'OBJ_DIR'RSAREF.OBJ;*
330$!
331$! Check To See If The File [-.RSAREF]RSAR_ERR.C Is Actually There.
332$!
333$ IF (F$SEARCH("SYS$DISK:[-.RSAREF]RSAR_ERR.C").EQS."")
334$ THEN
335$!
336$! Tell The User That The File Doesn't Exist.
337$!
338$ WRITE SYS$OUTPUT ""
339$ WRITE SYS$OUTPUT "The File [-.RSAREF]RSAR_ERR.C Doesn't Exist."
340$ WRITE SYS$OUTPUT ""
341$!
342$! Exit The Build.
343$!
344$ GOTO EXIT
345$!
346$! End The [-.RSAREF]RSAR_ERR.C File Check.
347$!
348$ ENDIF
349$!
350$! Tell The User We Are Compiling The [-.RSAREF]RSAR_ERR File.
351$!
352$ WRITE SYS$OUTPUT "Compiling The [-.RSAREF]RSAR_ERR File."
353$!
354$! Compile [-.RSAREF]RSAR_ERR.C
355$!
356$ CC/OBJECT='OBJ_DIR'RSAR_ERR.OBJ SYS$DISK:[-.RSAREF]RSAR_ERR.C
357$!
358$! Add It To The Library.
359$!
360$ LIBRARY/REPLACE 'LIB_NAME' 'OBJ_DIR'RSAR_ERR.OBJ
361$!
362$! Delete The Object File.
363$!
364$ DELETE 'OBJ_DIR'RSAR_ERR.OBJ;*
365$!
366$! End The RSAREF Check.
367$!
368$ ENDIF
369$!
370$! Figure Out What Other Modules We Are To Build. 273$! Figure Out What Other Modules We Are To Build.
371$! 274$!
372$ BUILD_SET: 275$ BUILD_SET:
@@ -639,74 +542,34 @@ $! Tell the user what happens
639$! 542$!
640$ WRITE SYS$OUTPUT " ",APPLICATION,".exe" 543$ WRITE SYS$OUTPUT " ",APPLICATION,".exe"
641$! 544$!
642$! Link The Program, Check To See If We Need To Link With RSAREF Or Not. 545$! Link The Program.
643$! 546$!
644$ ON ERROR THEN GOTO NEXT_APPLICATION 547$ ON ERROR THEN GOTO NEXT_APPLICATION
645$ IF (RSAREF.EQS."TRUE")
646$ THEN
647$! 548$!
648$! Check To See If We Are To Link With A Specific TCP/IP Library. 549$! Check To See If We Are To Link With A Specific TCP/IP Library.
649$! 550$!
650$ IF (TCPIP_LIB.NES."") 551$ IF (TCPIP_LIB.NES."")
651$ THEN 552$ THEN
652$!
653$! Link With The RSAREF Library And A Specific TCP/IP Library.
654$!
655$ LINK/'DEBUGGER'/'TRACEBACK'/EXE='EXE_DIR''APPLICATION'.EXE -
656 'OBJ_DIR''APPLICATION_OBJECTS', -
657 'CRYPTO_LIB'/LIBRARY,'RSAREF_LIB'/LIBRARY, -
658 'TCPIP_LIB','OPT_FILE'/OPTION
659$!
660$! Else...
661$!
662$ ELSE
663$!
664$! Link With The RSAREF Library And NO TCP/IP Library.
665$! 553$!
666$ LINK/'DEBUGGER'/'TRACEBACK'/EXE='EXE_DIR''APPLICATION'.EXE - 554$! Link With A TCP/IP Library.
667 'OBJ_DIR''APPLICATION_OBJECTS', -
668 'CRYPTO_LIB'/LIBRARY,'RSAREF_LIB'/LIBRARY, -
669 'OPT_FILE'/OPTION
670$! 555$!
671$! End The TCP/IP Library Check. 556$ LINK/'DEBUGGER'/'TRACEBACK'/EXE='EXE_DIR''APPLICATION'.EXE -
557 'OBJ_DIR''APPLICATION_OBJECTS', -
558 'CRYPTO_LIB'/LIBRARY, -
559 'TCPIP_LIB','OPT_FILE'/OPTION
672$! 560$!
673$ ENDIF 561$! Else...
674$!
675$! Else...
676$! 562$!
677$ ELSE 563$ ELSE
678$! 564$!
679$! Don't Link With The RSAREF Routines. 565$! Don't Link With A TCP/IP Library.
680$!
681$!
682$! Check To See If We Are To Link With A Specific TCP/IP Library.
683$!
684$ IF (TCPIP_LIB.NES."")
685$ THEN
686$!
687$! Don't Link With The RSAREF Routines And TCP/IP Library.
688$!
689$ LINK/'DEBUGGER'/'TRACEBACK'/EXE='EXE_DIR''APPLICATION'.EXE -
690 'OBJ_DIR''APPLICATION_OBJECTS', -
691 'CRYPTO_LIB'/LIBRARY, -
692 'TCPIP_LIB','OPT_FILE'/OPTION
693$!
694$! Else...
695$!
696$ ELSE
697$!
698$! Don't Link With The RSAREF Routines And Link With A TCP/IP Library.
699$!
700$ LINK/'DEBUGGER'/'TRACEBACK'/EXE='EXE_DIR''APPLICATION'.EXE -
701 'OBJ_DIR''APPLICATION_OBJECTS',-
702 'CRYPTO_LIB'/LIBRARY, -
703 'OPT_FILE'/OPTION
704$! 566$!
705$! End The TCP/IP Library Check. 567$ LINK/'DEBUGGER'/'TRACEBACK'/EXE='EXE_DIR''APPLICATION'.EXE -
568 'OBJ_DIR''APPLICATION_OBJECTS',-
569 'CRYPTO_LIB'/LIBRARY, -
570 'OPT_FILE'/OPTION
706$! 571$!
707$ ENDIF 572$! End The TCP/IP Library Check.
708$!
709$! End The RSAREF Link Check.
710$! 573$!
711$ ENDIF 574$ ENDIF
712$ GOTO NEXT_APPLICATION 575$ GOTO NEXT_APPLICATION
@@ -912,75 +775,10 @@ $ ENDIF
912$! 775$!
913$! Check To See If P2 Is Blank. 776$! Check To See If P2 Is Blank.
914$! 777$!
915$ P2 = "NORSAREF" 778$ IF (P2.EQS."NODEBUG")
916$ IF (P2.EQS."NORSAREF")
917$ THEN 779$ THEN
918$! 780$!
919$! P2 Is NORSAREF, So Compile With The Regular RSA Libraries. 781$! P2 Is NODEBUG, So Compile Without The Debugger Information.
920$!
921$ RSAREF = "FALSE"
922$ ELSE
923$!
924$! Check To See If We Are To Use The RSAREF Library.
925$!
926$ IF (P2.EQS."RSAREF")
927$ THEN
928$!
929$! Check To Make Sure We Have The RSAREF Source Code Directory.
930$!
931$ IF (F$SEARCH("SYS$DISK:[-.RSAREF]SOURCE.DIR").EQS."")
932$ THEN
933$!
934$! We Don't Have The RSAREF Souce Code Directory, So Tell The
935$! User This.
936$!
937$ WRITE SYS$OUTPUT ""
938$ WRITE SYS$OUTPUT "It appears that you don't have the RSAREF Souce Code."
939$ WRITE SYS$OUTPUT "You need to go to 'ftp://ftp.rsa.com/rsaref'. You have to"
940$ WRITE SYS$OUTPUT "get the '.tar-Z' file as the '.zip' file doesn't have the"
941$ WRITE SYS$OUTPUT "directory structure stored. You have to extract the file"
942$ WRITE SYS$OUTPUT "into the [.RSAREF] directory under the root directory"
943$ WRITE SYS$OUTPUT "as that is where the scripts will look for the files."
944$ WRITE SYS$OUTPUT ""
945$!
946$! Time To Exit.
947$!
948$ EXIT
949$!
950$! Else, Compile Using The RSAREF Library.
951$!
952$ ELSE
953$ RSAREF = "TRUE"
954$ ENDIF
955$ ELSE
956$!
957$! They Entered An Invalid Option..
958$!
959$ WRITE SYS$OUTPUT ""
960$ WRITE SYS$OUTPUT "The Option ",P2," Is Invalid. The Valid Options Are:"
961$ WRITE SYS$OUTPUT ""
962$ WRITE SYS$OUTPUT " RSAREF : Compile With The RSAREF Library."
963$ WRITE SYS$OUTPUT " NORSAREF : Compile With The Regular RSA Library."
964$ WRITE SYS$OUTPUT ""
965$!
966$! Time To EXIT.
967$!
968$ EXIT
969$!
970$! End The Valid Arguement Check.
971$!
972$ ENDIF
973$!
974$! End The P2 Check.
975$!
976$ ENDIF
977$!
978$! Check To See If P3 Is Blank.
979$!
980$ IF (P3.EQS."NODEBUG")
981$ THEN
982$!
983$! P3 Is NODEBUG, So Compile Without The Debugger Information.
984$! 782$!
985$ DEBUGGER = "NODEBUG" 783$ DEBUGGER = "NODEBUG"
986$ TRACEBACK = "NOTRACEBACK" 784$ TRACEBACK = "NOTRACEBACK"
@@ -993,7 +791,7 @@ $ ELSE
993$! 791$!
994$! Check To See If We Are To Compile With Debugger Information. 792$! Check To See If We Are To Compile With Debugger Information.
995$! 793$!
996$ IF (P3.EQS."DEBUG") 794$ IF (P2.EQS."DEBUG")
997$ THEN 795$ THEN
998$! 796$!
999$! Compile With Debugger Information. 797$! Compile With Debugger Information.
@@ -1010,7 +808,7 @@ $!
1010$! They Entered An Invalid Option.. 808$! They Entered An Invalid Option..
1011$! 809$!
1012$ WRITE SYS$OUTPUT "" 810$ WRITE SYS$OUTPUT ""
1013$ WRITE SYS$OUTPUT "The Option ",P3," Is Invalid. The Valid Options Are:" 811$ WRITE SYS$OUTPUT "The Option ",P2," Is Invalid. The Valid Options Are:"
1014$ WRITE SYS$OUTPUT "" 812$ WRITE SYS$OUTPUT ""
1015$ WRITE SYS$OUTPUT " DEBUG : Compile With The Debugger Information." 813$ WRITE SYS$OUTPUT " DEBUG : Compile With The Debugger Information."
1016$ WRITE SYS$OUTPUT " NODEBUG : Compile Without The Debugger Information." 814$ WRITE SYS$OUTPUT " NODEBUG : Compile Without The Debugger Information."
@@ -1024,7 +822,7 @@ $! End The Valid Arguement Check.
1024$! 822$!
1025$ ENDIF 823$ ENDIF
1026$! 824$!
1027$! End The P3 Check. 825$! End The P2 Check.
1028$! 826$!
1029$ ENDIF 827$ ENDIF
1030$! 828$!
@@ -1034,9 +832,9 @@ $! Written By: Richard Levitte
1034$! richard@levitte.org 832$! richard@levitte.org
1035$! 833$!
1036$! 834$!
1037$! Check To See If We Have A Option For P6. 835$! Check To See If We Have A Option For P5.
1038$! 836$!
1039$ IF (P6.EQS."") 837$ IF (P5.EQS."")
1040$ THEN 838$ THEN
1041$! 839$!
1042$! Get The Version Of VMS We Are Using. 840$! Get The Version Of VMS We Are Using.
@@ -1058,13 +856,13 @@ $! End The VMS Version Check.
1058$! 856$!
1059$ ENDIF 857$ ENDIF
1060$! 858$!
1061$! End The P6 Check. 859$! End The P5 Check.
1062$! 860$!
1063$ ENDIF 861$ ENDIF
1064$! 862$!
1065$! Check To See If P4 Is Blank. 863$! Check To See If P3 Is Blank.
1066$! 864$!
1067$ IF (P4.EQS."") 865$ IF (P3.EQS."")
1068$ THEN 866$ THEN
1069$! 867$!
1070$! O.K., The User Didn't Specify A Compiler, Let's Try To 868$! O.K., The User Didn't Specify A Compiler, Let's Try To
@@ -1077,7 +875,7 @@ $ THEN
1077$! 875$!
1078$! Looks Like GNUC, Set To Use GNUC. 876$! Looks Like GNUC, Set To Use GNUC.
1079$! 877$!
1080$ P4 = "GNUC" 878$ P3 = "GNUC"
1081$! 879$!
1082$! Else... 880$! Else...
1083$! 881$!
@@ -1090,7 +888,7 @@ $ THEN
1090$! 888$!
1091$! Looks Like DECC, Set To Use DECC. 889$! Looks Like DECC, Set To Use DECC.
1092$! 890$!
1093$ P4 = "DECC" 891$ P3 = "DECC"
1094$! 892$!
1095$! Else... 893$! Else...
1096$! 894$!
@@ -1098,7 +896,7 @@ $ ELSE
1098$! 896$!
1099$! Looks Like VAXC, Set To Use VAXC. 897$! Looks Like VAXC, Set To Use VAXC.
1100$! 898$!
1101$ P4 = "VAXC" 899$ P3 = "VAXC"
1102$! 900$!
1103$! End The VAXC Compiler Check. 901$! End The VAXC Compiler Check.
1104$! 902$!
@@ -1112,9 +910,9 @@ $! End The Compiler Check.
1112$! 910$!
1113$ ENDIF 911$ ENDIF
1114$! 912$!
1115$! Check To See If We Have A Option For P5. 913$! Check To See If We Have A Option For P4.
1116$! 914$!
1117$ IF (P5.EQS."") 915$ IF (P4.EQS."")
1118$ THEN 916$ THEN
1119$! 917$!
1120$! Find out what socket library we have available 918$! Find out what socket library we have available
@@ -1124,7 +922,7 @@ $ THEN
1124$! 922$!
1125$! We have SOCKETSHR, and it is my opinion that it's the best to use. 923$! We have SOCKETSHR, and it is my opinion that it's the best to use.
1126$! 924$!
1127$ P5 = "SOCKETSHR" 925$ P4 = "SOCKETSHR"
1128$! 926$!
1129$! Tell the user 927$! Tell the user
1130$! 928$!
@@ -1144,7 +942,7 @@ $ THEN
1144$! 942$!
1145$! Last resort: a UCX or UCX-compatible library 943$! Last resort: a UCX or UCX-compatible library
1146$! 944$!
1147$ P5 = "UCX" 945$ P4 = "UCX"
1148$! 946$!
1149$! Tell the user 947$! Tell the user
1150$! 948$!
@@ -1158,7 +956,7 @@ $ ENDIF
1158$! 956$!
1159$! Set Up Initial CC Definitions, Possibly With User Ones 957$! Set Up Initial CC Definitions, Possibly With User Ones
1160$! 958$!
1161$ CCDEFS = "TCPIP_TYPE_''P5',DSO_VMS" 959$ CCDEFS = "TCPIP_TYPE_''P4',DSO_VMS"
1162$ IF F$TYPE(USER_CCDEFS) .NES. "" THEN CCDEFS = CCDEFS + "," + USER_CCDEFS 960$ IF F$TYPE(USER_CCDEFS) .NES. "" THEN CCDEFS = CCDEFS + "," + USER_CCDEFS
1163$ CCEXTRAFLAGS = "" 961$ CCEXTRAFLAGS = ""
1164$ IF F$TYPE(USER_CCFLAGS) .NES. "" THEN CCEXTRAFLAGS = USER_CCFLAGS 962$ IF F$TYPE(USER_CCFLAGS) .NES. "" THEN CCEXTRAFLAGS = USER_CCFLAGS
@@ -1168,12 +966,12 @@ $ IF F$TYPE(USER_CCDISABLEWARNINGS) .NES. "" THEN -
1168$! 966$!
1169$! Check To See If The User Entered A Valid Paramter. 967$! Check To See If The User Entered A Valid Paramter.
1170$! 968$!
1171$ IF (P4.EQS."VAXC").OR.(P4.EQS."DECC").OR.(P4.EQS."GNUC") 969$ IF (P3.EQS."VAXC").OR.(P3.EQS."DECC").OR.(P3.EQS."GNUC")
1172$ THEN 970$ THEN
1173$! 971$!
1174$! Check To See If The User Wanted DECC. 972$! Check To See If The User Wanted DECC.
1175$! 973$!
1176$ IF (P4.EQS."DECC") 974$ IF (P3.EQS."DECC")
1177$ THEN 975$ THEN
1178$! 976$!
1179$! Looks Like DECC, Set To Use DECC. 977$! Looks Like DECC, Set To Use DECC.
@@ -1204,7 +1002,7 @@ $ ENDIF
1204$! 1002$!
1205$! Check To See If We Are To Use VAXC. 1003$! Check To See If We Are To Use VAXC.
1206$! 1004$!
1207$ IF (P4.EQS."VAXC") 1005$ IF (P3.EQS."VAXC")
1208$ THEN 1006$ THEN
1209$! 1007$!
1210$! Looks Like VAXC, Set To Use VAXC. 1008$! Looks Like VAXC, Set To Use VAXC.
@@ -1243,7 +1041,7 @@ $ ENDIF
1243$! 1041$!
1244$! Check To See If We Are To Use GNU C. 1042$! Check To See If We Are To Use GNU C.
1245$! 1043$!
1246$ IF (P4.EQS."GNUC") 1044$ IF (P3.EQS."GNUC")
1247$ THEN 1045$ THEN
1248$! 1046$!
1249$! Looks Like GNUC, Set To Use GNUC. 1047$! Looks Like GNUC, Set To Use GNUC.
@@ -1272,31 +1070,6 @@ $! Set up default defines
1272$! 1070$!
1273$ CCDEFS = """FLAT_INC=1""," + CCDEFS 1071$ CCDEFS = """FLAT_INC=1""," + CCDEFS
1274$! 1072$!
1275$! Check To See If We Are To Compile With RSAREF Routines.
1276$!
1277$ IF (RSAREF.EQS."TRUE")
1278$ THEN
1279$!
1280$! Compile With RSAREF.
1281$!
1282$ CCDEFS = CCDEFS + ",""RSAref=1"""
1283$!
1284$! Tell The User This.
1285$!
1286$ WRITE SYS$OUTPUT "Compiling With RSAREF Routines."
1287$!
1288$! Else, We Don't Care. Compile Without The RSAREF Library.
1289$!
1290$ ELSE
1291$!
1292$! Tell The User We Are Compile Without The RSAREF Routines.
1293$!
1294$ WRITE SYS$OUTPUT "Compiling Without The RSAREF Routines.
1295$!
1296$! End The RSAREF Check.
1297$!
1298$ ENDIF
1299$!
1300$! Finish up the definition of CC. 1073$! Finish up the definition of CC.
1301$! 1074$!
1302$ IF COMPILER .EQS. "DECC" 1075$ IF COMPILER .EQS. "DECC"
@@ -1315,7 +1088,7 @@ $ CC4DISABLEWARNINGS = ""
1315$ ENDIF 1088$ ENDIF
1316$ CC3 = CC + "/DEFINE=(" + CCDEFS + ISSEVEN + ")" + CCDISABLEWARNINGS 1089$ CC3 = CC + "/DEFINE=(" + CCDEFS + ISSEVEN + ")" + CCDISABLEWARNINGS
1317$ CC = CC + "/DEFINE=(" + CCDEFS + ")" + CCDISABLEWARNINGS 1090$ CC = CC + "/DEFINE=(" + CCDEFS + ")" + CCDISABLEWARNINGS
1318$ IF ARCH .EQS. "VAX" .AND. COMPILER .EQS. "DECC" .AND. P3 .NES. "DEBUG" 1091$ IF ARCH .EQS. "VAX" .AND. COMPILER .EQS. "DECC" .AND. P2 .NES. "DEBUG"
1319$ THEN 1092$ THEN
1320$ CC5 = CC + "/OPTIMIZE=NODISJOINT" 1093$ CC5 = CC + "/OPTIMIZE=NODISJOINT"
1321$ ELSE 1094$ ELSE
@@ -1334,7 +1107,7 @@ $!
1334$! Tell The User We Don't Know What They Want. 1107$! Tell The User We Don't Know What They Want.
1335$! 1108$!
1336$ WRITE SYS$OUTPUT "" 1109$ WRITE SYS$OUTPUT ""
1337$ WRITE SYS$OUTPUT "The Option ",P4," Is Invalid. The Valid Options Are:" 1110$ WRITE SYS$OUTPUT "The Option ",P3," Is Invalid. The Valid Options Are:"
1338$ WRITE SYS$OUTPUT "" 1111$ WRITE SYS$OUTPUT ""
1339$ WRITE SYS$OUTPUT " VAXC : To Compile With VAX C." 1112$ WRITE SYS$OUTPUT " VAXC : To Compile With VAX C."
1340$ WRITE SYS$OUTPUT " DECC : To Compile With DEC C." 1113$ WRITE SYS$OUTPUT " DECC : To Compile With DEC C."
@@ -1360,13 +1133,13 @@ $ WRITE/SYMBOL SYS$OUTPUT "Main MACRO Compiling Command: ",MACRO
1360$! 1133$!
1361$! Time to check the contents, and to make sure we get the correct library. 1134$! Time to check the contents, and to make sure we get the correct library.
1362$! 1135$!
1363$ IF P5.EQS."SOCKETSHR" .OR. P5.EQS."MULTINET" .OR. P5.EQS."UCX" - 1136$ IF P4.EQS."SOCKETSHR" .OR. P4.EQS."MULTINET" .OR. P4.EQS."UCX" -
1364 .OR. P5.EQS."TCPIP" .OR. P5.EQS."NONE" 1137 .OR. P4.EQS."TCPIP" .OR. P4.EQS."NONE"
1365$ THEN 1138$ THEN
1366$! 1139$!
1367$! Check to see if SOCKETSHR was chosen 1140$! Check to see if SOCKETSHR was chosen
1368$! 1141$!
1369$ IF P5.EQS."SOCKETSHR" 1142$ IF P4.EQS."SOCKETSHR"
1370$ THEN 1143$ THEN
1371$! 1144$!
1372$! Set the library to use SOCKETSHR 1145$! Set the library to use SOCKETSHR
@@ -1379,12 +1152,12 @@ $ ENDIF
1379$! 1152$!
1380$! Check to see if MULTINET was chosen 1153$! Check to see if MULTINET was chosen
1381$! 1154$!
1382$ IF P5.EQS."MULTINET" 1155$ IF P4.EQS."MULTINET"
1383$ THEN 1156$ THEN
1384$! 1157$!
1385$! Set the library to use UCX emulation. 1158$! Set the library to use UCX emulation.
1386$! 1159$!
1387$ P5 = "UCX" 1160$ P4 = "UCX"
1388$! 1161$!
1389$! Done with MULTINET 1162$! Done with MULTINET
1390$! 1163$!
@@ -1392,7 +1165,7 @@ $ ENDIF
1392$! 1165$!
1393$! Check to see if UCX was chosen 1166$! Check to see if UCX was chosen
1394$! 1167$!
1395$ IF P5.EQS."UCX" 1168$ IF P4.EQS."UCX"
1396$ THEN 1169$ THEN
1397$! 1170$!
1398$! Set the library to use UCX. 1171$! Set the library to use UCX.
@@ -1412,7 +1185,7 @@ $ ENDIF
1412$! 1185$!
1413$! Check to see if TCPIP was chosen 1186$! Check to see if TCPIP was chosen
1414$! 1187$!
1415$ IF P5.EQS."TCPIP" 1188$ IF P4.EQS."TCPIP"
1416$ THEN 1189$ THEN
1417$! 1190$!
1418$! Set the library to use TCPIP (post UCX). 1191$! Set the library to use TCPIP (post UCX).
@@ -1425,7 +1198,7 @@ $ ENDIF
1425$! 1198$!
1426$! Check to see if NONE was chosen 1199$! Check to see if NONE was chosen
1427$! 1200$!
1428$ IF P5.EQS."NONE" 1201$ IF P4.EQS."NONE"
1429$ THEN 1202$ THEN
1430$! 1203$!
1431$! Do not use a TCPIP library. 1204$! Do not use a TCPIP library.
@@ -1447,7 +1220,7 @@ $!
1447$! Tell The User We Don't Know What They Want. 1220$! Tell The User We Don't Know What They Want.
1448$! 1221$!
1449$ WRITE SYS$OUTPUT "" 1222$ WRITE SYS$OUTPUT ""
1450$ WRITE SYS$OUTPUT "The Option ",P5," Is Invalid. The Valid Options Are:" 1223$ WRITE SYS$OUTPUT "The Option ",P4," Is Invalid. The Valid Options Are:"
1451$ WRITE SYS$OUTPUT "" 1224$ WRITE SYS$OUTPUT ""
1452$ WRITE SYS$OUTPUT " SOCKETSHR : To link with SOCKETSHR TCP/IP library." 1225$ WRITE SYS$OUTPUT " SOCKETSHR : To link with SOCKETSHR TCP/IP library."
1453$ WRITE SYS$OUTPUT " UCX : To link with UCX TCP/IP library." 1226$ WRITE SYS$OUTPUT " UCX : To link with UCX TCP/IP library."
@@ -1465,10 +1238,9 @@ $!
1465$! Check if the user wanted to compile just a subset of all the encryption 1238$! Check if the user wanted to compile just a subset of all the encryption
1466$! methods. 1239$! methods.
1467$! 1240$!
1468$ IF P7 .NES. "" 1241$ IF P6 .NES. ""
1469$ THEN 1242$ THEN
1470$ ENCRYPT_TYPES = P7 1243$ ENCRYPT_TYPES = P6
1471$! NYI: ENCRYPT_PROGRAMS = P7
1472$ ENDIF 1244$ ENDIF
1473$! 1245$!
1474$! Time To RETURN... 1246$! Time To RETURN...
diff --git a/src/lib/libcrypto/crypto.h b/src/lib/libcrypto/crypto.h
index fc6ff860af..273bc5e3f8 100644
--- a/src/lib/libcrypto/crypto.h
+++ b/src/lib/libcrypto/crypto.h
@@ -96,37 +96,39 @@ extern "C" {
96 * names in cryptlib.c 96 * names in cryptlib.c
97 */ 97 */
98 98
99#define CRYPTO_LOCK_ERR 1 99#define CRYPTO_LOCK_ERR 1
100#define CRYPTO_LOCK_EX_DATA 2 100#define CRYPTO_LOCK_EX_DATA 2
101#define CRYPTO_LOCK_X509 3 101#define CRYPTO_LOCK_X509 3
102#define CRYPTO_LOCK_X509_INFO 4 102#define CRYPTO_LOCK_X509_INFO 4
103#define CRYPTO_LOCK_X509_PKEY 5 103#define CRYPTO_LOCK_X509_PKEY 5
104#define CRYPTO_LOCK_X509_CRL 6 104#define CRYPTO_LOCK_X509_CRL 6
105#define CRYPTO_LOCK_X509_REQ 7 105#define CRYPTO_LOCK_X509_REQ 7
106#define CRYPTO_LOCK_DSA 8 106#define CRYPTO_LOCK_DSA 8
107#define CRYPTO_LOCK_RSA 9 107#define CRYPTO_LOCK_RSA 9
108#define CRYPTO_LOCK_EVP_PKEY 10 108#define CRYPTO_LOCK_EVP_PKEY 10
109#define CRYPTO_LOCK_X509_STORE 11 109#define CRYPTO_LOCK_X509_STORE 11
110#define CRYPTO_LOCK_SSL_CTX 12 110#define CRYPTO_LOCK_SSL_CTX 12
111#define CRYPTO_LOCK_SSL_CERT 13 111#define CRYPTO_LOCK_SSL_CERT 13
112#define CRYPTO_LOCK_SSL_SESSION 14 112#define CRYPTO_LOCK_SSL_SESSION 14
113#define CRYPTO_LOCK_SSL_SESS_CERT 15 113#define CRYPTO_LOCK_SSL_SESS_CERT 15
114#define CRYPTO_LOCK_SSL 16 114#define CRYPTO_LOCK_SSL 16
115#define CRYPTO_LOCK_RAND 17 115#define CRYPTO_LOCK_SSL_METHOD 17
116#define CRYPTO_LOCK_RAND2 18 116#define CRYPTO_LOCK_RAND 18
117#define CRYPTO_LOCK_MALLOC 19 117#define CRYPTO_LOCK_RAND2 19
118#define CRYPTO_LOCK_BIO 20 118#define CRYPTO_LOCK_MALLOC 20
119#define CRYPTO_LOCK_GETHOSTBYNAME 21 119#define CRYPTO_LOCK_BIO 21
120#define CRYPTO_LOCK_GETSERVBYNAME 22 120#define CRYPTO_LOCK_GETHOSTBYNAME 22
121#define CRYPTO_LOCK_READDIR 23 121#define CRYPTO_LOCK_GETSERVBYNAME 23
122#define CRYPTO_LOCK_RSA_BLINDING 24 122#define CRYPTO_LOCK_READDIR 24
123#define CRYPTO_LOCK_DH 25 123#define CRYPTO_LOCK_RSA_BLINDING 25
124#define CRYPTO_LOCK_MALLOC2 26 124#define CRYPTO_LOCK_DH 26
125#define CRYPTO_LOCK_DSO 27 125#define CRYPTO_LOCK_MALLOC2 27
126#define CRYPTO_LOCK_DYNLOCK 28 126#define CRYPTO_LOCK_DSO 28
127#define CRYPTO_LOCK_ENGINE 29 127#define CRYPTO_LOCK_DYNLOCK 29
128#define CRYPTO_LOCK_UI 30 128#define CRYPTO_LOCK_ENGINE 30
129#define CRYPTO_NUM_LOCKS 31 129#define CRYPTO_LOCK_UI 31
130#define CRYPTO_LOCK_HWCRHK 32 /* This is a HACK which will disappear in 0.9.8 */
131#define CRYPTO_NUM_LOCKS 33
130 132
131#define CRYPTO_LOCK 1 133#define CRYPTO_LOCK 1
132#define CRYPTO_UNLOCK 2 134#define CRYPTO_UNLOCK 2
@@ -148,7 +150,7 @@ extern "C" {
148#endif 150#endif
149#else 151#else
150#define CRYPTO_w_lock(a) 152#define CRYPTO_w_lock(a)
151#define CRYPTO_w_unlock(a) 153#define CRYPTO_w_unlock(a)
152#define CRYPTO_r_lock(a) 154#define CRYPTO_r_lock(a)
153#define CRYPTO_r_unlock(a) 155#define CRYPTO_r_unlock(a)
154#define CRYPTO_add(a,b,c) ((*(a))+=(b)) 156#define CRYPTO_add(a,b,c) ((*(a))+=(b))
@@ -278,6 +280,8 @@ int CRYPTO_is_mem_check_on(void);
278#define OPENSSL_malloc(num) CRYPTO_malloc((int)num,__FILE__,__LINE__) 280#define OPENSSL_malloc(num) CRYPTO_malloc((int)num,__FILE__,__LINE__)
279#define OPENSSL_realloc(addr,num) \ 281#define OPENSSL_realloc(addr,num) \
280 CRYPTO_realloc((char *)addr,(int)num,__FILE__,__LINE__) 282 CRYPTO_realloc((char *)addr,(int)num,__FILE__,__LINE__)
283#define OPENSSL_realloc_clean(addr,old_num,num) \
284 CRYPTO_realloc_clean(addr,old_num,num,__FILE__,__LINE__)
281#define OPENSSL_remalloc(addr,num) \ 285#define OPENSSL_remalloc(addr,num) \
282 CRYPTO_remalloc((char **)addr,(int)num,__FILE__,__LINE__) 286 CRYPTO_remalloc((char **)addr,(int)num,__FILE__,__LINE__)
283#define OPENSSL_freeFunc CRYPTO_free 287#define OPENSSL_freeFunc CRYPTO_free
@@ -380,8 +384,12 @@ void CRYPTO_free_locked(void *);
380void *CRYPTO_malloc(int num, const char *file, int line); 384void *CRYPTO_malloc(int num, const char *file, int line);
381void CRYPTO_free(void *); 385void CRYPTO_free(void *);
382void *CRYPTO_realloc(void *addr,int num, const char *file, int line); 386void *CRYPTO_realloc(void *addr,int num, const char *file, int line);
387void *CRYPTO_realloc_clean(void *addr,int old_num,int num,const char *file,
388 int line);
383void *CRYPTO_remalloc(void *addr,int num, const char *file, int line); 389void *CRYPTO_remalloc(void *addr,int num, const char *file, int line);
384 390
391void OPENSSL_cleanse(void *ptr, size_t len);
392
385void CRYPTO_set_mem_debug_options(long bits); 393void CRYPTO_set_mem_debug_options(long bits);
386long CRYPTO_get_mem_debug_options(void); 394long CRYPTO_get_mem_debug_options(void);
387 395
@@ -422,6 +430,9 @@ void CRYPTO_mem_leaks(struct bio_st *bio);
422typedef void *CRYPTO_MEM_LEAK_CB(unsigned long, const char *, int, int, void *); 430typedef void *CRYPTO_MEM_LEAK_CB(unsigned long, const char *, int, int, void *);
423void CRYPTO_mem_leaks_cb(CRYPTO_MEM_LEAK_CB *cb); 431void CRYPTO_mem_leaks_cb(CRYPTO_MEM_LEAK_CB *cb);
424 432
433/* die if we have to */
434void OpenSSLDie(const char *file,int line,const char *assertion);
435#define OPENSSL_assert(e) ((e) ? (void)0 : OpenSSLDie(__FILE__, __LINE__, #e))
425 436
426/* BEGIN ERROR CODES */ 437/* BEGIN ERROR CODES */
427/* The following lines are auto generated by the script mkerr.pl. Any changes 438/* The following lines are auto generated by the script mkerr.pl. Any changes
diff --git a/src/lib/libcrypto/des/Makefile.ssl b/src/lib/libcrypto/des/Makefile.ssl
index 826ffcc58c..45eba0b3c9 100644
--- a/src/lib/libcrypto/des/Makefile.ssl
+++ b/src/lib/libcrypto/des/Makefile.ssl
@@ -66,22 +66,11 @@ des: des.o cbc3_enc.o lib
66 $(CC) $(CFLAGS) -o des des.o cbc3_enc.o $(LIB) 66 $(CC) $(CFLAGS) -o des des.o cbc3_enc.o $(LIB)
67 67
68# elf 68# elf
69asm/dx86-elf.o: asm/dx86unix.cpp 69asm/dx86-elf.s: asm/des-586.pl ../perlasm/x86asm.pl ../perlasm/cbc.pl
70 $(CPP) -DELF -x c asm/dx86unix.cpp | as -o asm/dx86-elf.o 70 (cd asm; $(PERL) des-586.pl elf $(CFLAGS) > dx86-elf.s)
71 71
72asm/yx86-elf.o: asm/yx86unix.cpp 72asm/yx86-elf.s: asm/crypt586.pl ../perlasm/x86asm.pl ../perlasm/cbc.pl
73 $(CPP) -DELF -x c asm/yx86unix.cpp | as -o asm/yx86-elf.o 73 (cd asm; $(PERL) crypt586.pl elf $(CFLAGS) > yx86-elf.s)
74
75# solaris
76asm/dx86-sol.o: asm/dx86unix.cpp
77 $(CC) -E -DSOL asm/dx86unix.cpp | sed 's/^#.*//' > asm/dx86-sol.s
78 as -o asm/dx86-sol.o asm/dx86-sol.s
79 rm -f asm/dx86-sol.s
80
81asm/yx86-sol.o: asm/yx86unix.cpp
82 $(CC) -E -DSOL asm/yx86unix.cpp | sed 's/^#.*//' > asm/yx86-sol.s
83 as -o asm/yx86-sol.o asm/yx86-sol.s
84 rm -f asm/yx86-sol.s
85 74
86# a.out 75# a.out
87asm/dx86-out.o: asm/dx86unix.cpp 76asm/dx86-out.o: asm/dx86unix.cpp
@@ -130,14 +119,14 @@ lint:
130 lint -DLINT $(INCLUDES) $(SRC)>fluff 119 lint -DLINT $(INCLUDES) $(SRC)>fluff
131 120
132depend: 121depend:
133 $(MAKEDEPEND) $(CFLAG) $(INCLUDES) $(DEPFLAG) $(PROGS) $(LIBSRC) 122 $(MAKEDEPEND) -- $(CFLAG) $(INCLUDES) $(DEPFLAG) -- $(PROGS) $(LIBSRC)
134 123
135dclean: 124dclean:
136 $(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new 125 $(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
137 mv -f Makefile.new $(MAKEFILE) 126 mv -f Makefile.new $(MAKEFILE)
138 127
139clean: 128clean:
140 rm -f asm/dx86unix.cpp asm/yx86unix.cpp *.o asm/*.o *.obj des lib tags core .pure .nfs* *.old *.bak fluff 129 rm -f asm/dx86unix.cpp asm/yx86unix.cpp asm/*-elf.* *.o asm/*.o *.obj des lib tags core .pure .nfs* *.old *.bak fluff
141 130
142# DO NOT DELETE THIS LINE -- make depend depends on it. 131# DO NOT DELETE THIS LINE -- make depend depends on it.
143 132
diff --git a/src/lib/libcrypto/des/asm/crypt586.pl b/src/lib/libcrypto/des/asm/crypt586.pl
index 3d41d82f69..1d04ed6def 100644
--- a/src/lib/libcrypto/des/asm/crypt586.pl
+++ b/src/lib/libcrypto/des/asm/crypt586.pl
@@ -26,11 +26,18 @@ sub fcrypt_body
26 26
27 &comment(""); 27 &comment("");
28 &comment("Load the 2 words"); 28 &comment("Load the 2 words");
29 $ks="ebp"; 29 $trans="ebp";
30 30
31 &xor( $L, $L); 31 &xor( $L, $L);
32 &xor( $R, $R); 32 &xor( $R, $R);
33 &mov($ks,&wparam(1)); 33
34 # PIC-ification:-)
35 &picmeup("edx","DES_SPtrans");
36 #if ($cpp) { &picmeup("edx","DES_SPtrans"); }
37 #else { &lea("edx",&DWP("DES_SPtrans")); }
38 &push("edx"); # becomes &swtmp(1)
39 #
40 &mov($trans,&wparam(1)); # reloaded with DES_SPtrans in D_ENCRYPT
34 41
35 &push(&DWC(25)); # add a variable 42 &push(&DWC(25)); # add a variable
36 43
@@ -39,11 +46,11 @@ sub fcrypt_body
39 { 46 {
40 &comment(""); 47 &comment("");
41 &comment("Round $i"); 48 &comment("Round $i");
42 &D_ENCRYPT($i,$L,$R,$i*2,$ks,"DES_SPtrans","eax","ebx","ecx","edx"); 49 &D_ENCRYPT($i,$L,$R,$i*2,$trans,"eax","ebx","ecx","edx");
43 50
44 &comment(""); 51 &comment("");
45 &comment("Round ".sprintf("%d",$i+1)); 52 &comment("Round ".sprintf("%d",$i+1));
46 &D_ENCRYPT($i+1,$R,$L,($i+1)*2,$ks,"DES_SPtrans","eax","ebx","ecx","edx"); 53 &D_ENCRYPT($i+1,$R,$L,($i+1)*2,$trans,"eax","ebx","ecx","edx");
47 } 54 }
48 &mov("ebx", &swtmp(0)); 55 &mov("ebx", &swtmp(0));
49 &mov("eax", $L); 56 &mov("eax", $L);
@@ -61,14 +68,14 @@ sub fcrypt_body
61 &mov(&DWP(0,"edx","",0),"eax"); 68 &mov(&DWP(0,"edx","",0),"eax");
62 &mov(&DWP(4,"edx","",0),$L); 69 &mov(&DWP(4,"edx","",0),$L);
63 70
64 &pop("ecx"); # remove variable 71 &add("esp",8); # remove variables
65 72
66 &function_end($name); 73 &function_end($name);
67 } 74 }
68 75
69sub D_ENCRYPT 76sub D_ENCRYPT
70 { 77 {
71 local($r,$L,$R,$S,$ks,$desSP,$u,$tmp1,$tmp2,$t)=@_; 78 local($r,$L,$R,$S,$trans,$u,$tmp1,$tmp2,$t)=@_;
72 79
73 &mov( $u, &wparam(2)); # 2 80 &mov( $u, &wparam(2)); # 2
74 &mov( $t, $R); 81 &mov( $t, $R);
@@ -85,9 +92,9 @@ sub D_ENCRYPT
85 &shl( $tmp2, 16); # 1 92 &shl( $tmp2, 16); # 1
86 &xor( $u, $tmp1); # 2 93 &xor( $u, $tmp1); # 2
87 &xor( $t, $tmp2); # 2 94 &xor( $t, $tmp2); # 2
88 &mov( $tmp1, &DWP(&n2a($S*4),$ks,"",0)); # 2 95 &mov( $tmp1, &DWP(&n2a($S*4),$trans,"",0)); # 2
89 &xor( $u, $tmp1); 96 &xor( $u, $tmp1);
90 &mov( $tmp2, &DWP(&n2a(($S+1)*4),$ks,"",0)); # 2 97 &mov( $tmp2, &DWP(&n2a(($S+1)*4),$trans,"",0)); # 2
91 &xor( $u, $R); 98 &xor( $u, $R);
92 &xor( $t, $R); 99 &xor( $t, $R);
93 &xor( $t, $tmp2); 100 &xor( $t, $tmp2);
@@ -99,31 +106,28 @@ sub D_ENCRYPT
99 &movb( &LB($tmp1), &LB($u) ); 106 &movb( &LB($tmp1), &LB($u) );
100 &movb( &LB($tmp2), &HB($u) ); 107 &movb( &LB($tmp2), &HB($u) );
101 &rotr( $t, 4 ); 108 &rotr( $t, 4 );
102 &mov( $ks, &DWP(" $desSP",$tmp1,"",0)); 109 &mov( $trans, &swtmp(1));
110 &xor( $L, &DWP(" ",$trans,$tmp1,0));
103 &movb( &LB($tmp1), &LB($t) ); 111 &movb( &LB($tmp1), &LB($t) );
104 &xor( $L, $ks); 112 &xor( $L, &DWP("0x200",$trans,$tmp2,0));
105 &mov( $ks, &DWP("0x200+$desSP",$tmp2,"",0));
106 &xor( $L, $ks);
107 &movb( &LB($tmp2), &HB($t) ); 113 &movb( &LB($tmp2), &HB($t) );
108 &shr( $u, 16); 114 &shr( $u, 16);
109 &mov( $ks, &DWP("0x100+$desSP",$tmp1,"",0)); 115 &xor( $L, &DWP("0x100",$trans,$tmp1,0));
110 &xor( $L, $ks);
111 &movb( &LB($tmp1), &HB($u) ); 116 &movb( &LB($tmp1), &HB($u) );
112 &shr( $t, 16); 117 &shr( $t, 16);
113 &mov( $ks, &DWP("0x300+$desSP",$tmp2,"",0)); 118 &xor( $L, &DWP("0x300",$trans,$tmp2,0));
114 &xor( $L, $ks);
115 &mov( $ks, &wparam(1));
116 &movb( &LB($tmp2), &HB($t) ); 119 &movb( &LB($tmp2), &HB($t) );
117 &and( $u, "0xff" ); 120 &and( $u, "0xff" );
118 &and( $t, "0xff" ); 121 &and( $t, "0xff" );
119 &mov( $tmp1, &DWP("0x600+$desSP",$tmp1,"",0)); 122 &mov( $tmp1, &DWP("0x600",$trans,$tmp1,0));
120 &xor( $L, $tmp1); 123 &xor( $L, $tmp1);
121 &mov( $tmp1, &DWP("0x700+$desSP",$tmp2,"",0)); 124 &mov( $tmp1, &DWP("0x700",$trans,$tmp2,0));
122 &xor( $L, $tmp1); 125 &xor( $L, $tmp1);
123 &mov( $tmp1, &DWP("0x400+$desSP",$u,"",0)); 126 &mov( $tmp1, &DWP("0x400",$trans,$u,0));
124 &xor( $L, $tmp1); 127 &xor( $L, $tmp1);
125 &mov( $tmp1, &DWP("0x500+$desSP",$t,"",0)); 128 &mov( $tmp1, &DWP("0x500",$trans,$t,0));
126 &xor( $L, $tmp1); 129 &xor( $L, $tmp1);
130 &mov( $trans, &wparam(1));
127 } 131 }
128 132
129sub n2a 133sub n2a
diff --git a/src/lib/libcrypto/des/asm/des-586.pl b/src/lib/libcrypto/des/asm/des-586.pl
index 0d08e8a3a9..b75d3c6b3a 100644
--- a/src/lib/libcrypto/des/asm/des-586.pl
+++ b/src/lib/libcrypto/des/asm/des-586.pl
@@ -40,7 +40,7 @@ sub DES_encrypt
40 40
41 &comment(""); 41 &comment("");
42 &comment("Load the 2 words"); 42 &comment("Load the 2 words");
43 $ks="ebp"; 43 $trans="ebp";
44 44
45 if ($do_ip) 45 if ($do_ip)
46 { 46 {
@@ -72,7 +72,12 @@ sub DES_encrypt
72 &rotl($L,3); 72 &rotl($L,3);
73 } 73 }
74 74
75 &mov( $ks, &wparam(1) ); 75 # PIC-ification:-)
76 &picmeup($trans,"DES_SPtrans");
77 #if ($cpp) { &picmeup($trans,"DES_SPtrans"); }
78 #else { &lea($trans,&DWP("DES_SPtrans")); }
79
80 &mov( "ecx", &wparam(1) );
76 &cmp("ebx","0"); 81 &cmp("ebx","0");
77 &je(&label("start_decrypt")); 82 &je(&label("start_decrypt"));
78 83
@@ -80,11 +85,11 @@ sub DES_encrypt
80 { 85 {
81 &comment(""); 86 &comment("");
82 &comment("Round $i"); 87 &comment("Round $i");
83 &D_ENCRYPT($i,$L,$R,$i*2,$ks,"DES_SPtrans","eax","ebx","ecx","edx"); 88 &D_ENCRYPT($i,$L,$R,$i*2,$trans,"eax","ebx","ecx","edx");
84 89
85 &comment(""); 90 &comment("");
86 &comment("Round ".sprintf("%d",$i+1)); 91 &comment("Round ".sprintf("%d",$i+1));
87 &D_ENCRYPT($i+1,$R,$L,($i+1)*2,$ks,"DES_SPtrans","eax","ebx","ecx","edx"); 92 &D_ENCRYPT($i+1,$R,$L,($i+1)*2,$trans,"eax","ebx","ecx","edx");
88 } 93 }
89 &jmp(&label("end")); 94 &jmp(&label("end"));
90 95
@@ -94,10 +99,10 @@ sub DES_encrypt
94 { 99 {
95 &comment(""); 100 &comment("");
96 &comment("Round $i"); 101 &comment("Round $i");
97 &D_ENCRYPT(15-$i,$L,$R,$i*2,$ks,"DES_SPtrans","eax","ebx","ecx","edx"); 102 &D_ENCRYPT(15-$i,$L,$R,$i*2,$trans,"eax","ebx","ecx","edx");
98 &comment(""); 103 &comment("");
99 &comment("Round ".sprintf("%d",$i-1)); 104 &comment("Round ".sprintf("%d",$i-1));
100 &D_ENCRYPT(15-$i+1,$R,$L,($i-1)*2,$ks,"DES_SPtrans","eax","ebx","ecx","edx"); 105 &D_ENCRYPT(15-$i+1,$R,$L,($i-1)*2,$trans,"eax","ebx","ecx","edx");
101 } 106 }
102 107
103 &set_label("end"); 108 &set_label("end");
@@ -134,43 +139,36 @@ sub DES_encrypt
134 139
135sub D_ENCRYPT 140sub D_ENCRYPT
136 { 141 {
137 local($r,$L,$R,$S,$ks,$desSP,$u,$tmp1,$tmp2,$t)=@_; 142 local($r,$L,$R,$S,$trans,$u,$tmp1,$tmp2,$t)=@_;
138 143
139 &mov( $u, &DWP(&n2a($S*4),$ks,"",0)); 144 &mov( $u, &DWP(&n2a($S*4),$tmp2,"",0));
140 &xor( $tmp1, $tmp1); 145 &xor( $tmp1, $tmp1);
141 &mov( $t, &DWP(&n2a(($S+1)*4),$ks,"",0)); 146 &mov( $t, &DWP(&n2a(($S+1)*4),$tmp2,"",0));
142 &xor( $u, $R); 147 &xor( $u, $R);
148 &xor( $tmp2, $tmp2);
143 &xor( $t, $R); 149 &xor( $t, $R);
144 &and( $u, "0xfcfcfcfc" ); 150 &and( $u, "0xfcfcfcfc" );
145 &and( $t, "0xcfcfcfcf" ); 151 &and( $t, "0xcfcfcfcf" );
146 &movb( &LB($tmp1), &LB($u) ); 152 &movb( &LB($tmp1), &LB($u) );
147 &movb( &LB($tmp2), &HB($u) ); 153 &movb( &LB($tmp2), &HB($u) );
148 &rotr( $t, 4 ); 154 &rotr( $t, 4 );
149 &mov( $ks, &DWP(" $desSP",$tmp1,"",0)); 155 &xor( $L, &DWP(" ",$trans,$tmp1,0));
150 &movb( &LB($tmp1), &LB($t) ); 156 &movb( &LB($tmp1), &LB($t) );
151 &xor( $L, $ks); 157 &xor( $L, &DWP("0x200",$trans,$tmp2,0));
152 &mov( $ks, &DWP("0x200+$desSP",$tmp2,"",0));
153 &xor( $L, $ks); ######
154 &movb( &LB($tmp2), &HB($t) ); 158 &movb( &LB($tmp2), &HB($t) );
155 &shr( $u, 16); 159 &shr( $u, 16);
156 &mov( $ks, &DWP("0x100+$desSP",$tmp1,"",0)); 160 &xor( $L, &DWP("0x100",$trans,$tmp1,0));
157 &xor( $L, $ks); ######
158 &movb( &LB($tmp1), &HB($u) ); 161 &movb( &LB($tmp1), &HB($u) );
159 &shr( $t, 16); 162 &shr( $t, 16);
160 &mov( $ks, &DWP("0x300+$desSP",$tmp2,"",0)); 163 &xor( $L, &DWP("0x300",$trans,$tmp2,0));
161 &xor( $L, $ks);
162 &mov( $ks, &wparam(1) );
163 &movb( &LB($tmp2), &HB($t) ); 164 &movb( &LB($tmp2), &HB($t) );
164 &and( $u, "0xff" ); 165 &and( $u, "0xff" );
165 &and( $t, "0xff" ); 166 &and( $t, "0xff" );
166 &mov( $tmp1, &DWP("0x600+$desSP",$tmp1,"",0)); 167 &xor( $L, &DWP("0x600",$trans,$tmp1,0));
167 &xor( $L, $tmp1); 168 &xor( $L, &DWP("0x700",$trans,$tmp2,0));
168 &mov( $tmp1, &DWP("0x700+$desSP",$tmp2,"",0)); 169 &mov( $tmp2, &wparam(1) );
169 &xor( $L, $tmp1); 170 &xor( $L, &DWP("0x400",$trans,$u,0));
170 &mov( $tmp1, &DWP("0x400+$desSP",$u,"",0)); 171 &xor( $L, &DWP("0x500",$trans,$t,0));
171 &xor( $L, $tmp1);
172 &mov( $tmp1, &DWP("0x500+$desSP",$t,"",0));
173 &xor( $L, $tmp1);
174 } 172 }
175 173
176sub n2a 174sub n2a
diff --git a/src/lib/libcrypto/des/cbc_cksm.c b/src/lib/libcrypto/des/cbc_cksm.c
index 6c5305b99d..09a7ba56aa 100644
--- a/src/lib/libcrypto/des/cbc_cksm.c
+++ b/src/lib/libcrypto/des/cbc_cksm.c
@@ -93,5 +93,14 @@ DES_LONG DES_cbc_cksum(const unsigned char *in, DES_cblock *output,
93 l2c(tout1,out); 93 l2c(tout1,out);
94 } 94 }
95 tout0=tin0=tin1=tin[0]=tin[1]=0; 95 tout0=tin0=tin1=tin[0]=tin[1]=0;
96 /*
97 Transform the data in tout1 so that it will
98 match the return value that the MIT Kerberos
99 mit_des_cbc_cksum API returns.
100 */
101 tout1 = ((tout1 >> 24L) & 0x000000FF)
102 | ((tout1 >> 8L) & 0x0000FF00)
103 | ((tout1 << 8L) & 0x00FF0000)
104 | ((tout1 << 24L) & 0xFF000000);
96 return(tout1); 105 return(tout1);
97 } 106 }
diff --git a/src/lib/libcrypto/des/des.c b/src/lib/libcrypto/des/des.c
index d8c846b23d..343135ff9e 100644
--- a/src/lib/libcrypto/des/des.c
+++ b/src/lib/libcrypto/des/des.c
@@ -427,7 +427,7 @@ void doencryption(void)
427 k2[i-8]=k; 427 k2[i-8]=k;
428 } 428 }
429 DES_set_key_unchecked(&k2,&ks2); 429 DES_set_key_unchecked(&k2,&ks2);
430 memset(k2,0,sizeof(k2)); 430 OPENSSL_cleanse(k2,sizeof(k2));
431 } 431 }
432 else if (longk || flag3) 432 else if (longk || flag3)
433 { 433 {
@@ -435,7 +435,7 @@ void doencryption(void)
435 { 435 {
436 DES_string_to_2keys(key,&kk,&k2); 436 DES_string_to_2keys(key,&kk,&k2);
437 DES_set_key_unchecked(&k2,&ks2); 437 DES_set_key_unchecked(&k2,&ks2);
438 memset(k2,0,sizeof(k2)); 438 OPENSSL_cleanse(k2,sizeof(k2));
439 } 439 }
440 else 440 else
441 DES_string_to_key(key,&kk); 441 DES_string_to_key(key,&kk);
@@ -457,8 +457,8 @@ void doencryption(void)
457 } 457 }
458 458
459 DES_set_key_unchecked(&kk,&ks); 459 DES_set_key_unchecked(&kk,&ks);
460 memset(key,0,sizeof(key)); 460 OPENSSL_cleanse(key,sizeof(key));
461 memset(kk,0,sizeof(kk)); 461 OPENSSL_cleanse(kk,sizeof(kk));
462 /* woops - A bug that does not showup under unix :-( */ 462 /* woops - A bug that does not showup under unix :-( */
463 memset(iv,0,sizeof(iv)); 463 memset(iv,0,sizeof(iv));
464 memset(iv2,0,sizeof(iv2)); 464 memset(iv2,0,sizeof(iv2));
@@ -666,18 +666,18 @@ void doencryption(void)
666 if (l) fclose(CKSUM_OUT); 666 if (l) fclose(CKSUM_OUT);
667 } 667 }
668problems: 668problems:
669 memset(buf,0,sizeof(buf)); 669 OPENSSL_cleanse(buf,sizeof(buf));
670 memset(obuf,0,sizeof(obuf)); 670 OPENSSL_cleanse(obuf,sizeof(obuf));
671 memset(&ks,0,sizeof(ks)); 671 OPENSSL_cleanse(&ks,sizeof(ks));
672 memset(&ks2,0,sizeof(ks2)); 672 OPENSSL_cleanse(&ks2,sizeof(ks2));
673 memset(iv,0,sizeof(iv)); 673 OPENSSL_cleanse(iv,sizeof(iv));
674 memset(iv2,0,sizeof(iv2)); 674 OPENSSL_cleanse(iv2,sizeof(iv2));
675 memset(kk,0,sizeof(kk)); 675 OPENSSL_cleanse(kk,sizeof(kk));
676 memset(k2,0,sizeof(k2)); 676 OPENSSL_cleanse(k2,sizeof(k2));
677 memset(uubuf,0,sizeof(uubuf)); 677 OPENSSL_cleanse(uubuf,sizeof(uubuf));
678 memset(b,0,sizeof(b)); 678 OPENSSL_cleanse(b,sizeof(b));
679 memset(bb,0,sizeof(bb)); 679 OPENSSL_cleanse(bb,sizeof(bb));
680 memset(cksum,0,sizeof(cksum)); 680 OPENSSL_cleanse(cksum,sizeof(cksum));
681 if (Exit) EXIT(Exit); 681 if (Exit) EXIT(Exit);
682 } 682 }
683 683
diff --git a/src/lib/libcrypto/des/des_locl.h b/src/lib/libcrypto/des/des_locl.h
index 70e833be3f..e44e8e98b2 100644
--- a/src/lib/libcrypto/des/des_locl.h
+++ b/src/lib/libcrypto/des/des_locl.h
@@ -162,7 +162,18 @@
162 162
163#if defined(OPENSSL_SYS_WIN32) && defined(_MSC_VER) 163#if defined(OPENSSL_SYS_WIN32) && defined(_MSC_VER)
164#define ROTATE(a,n) (_lrotr(a,n)) 164#define ROTATE(a,n) (_lrotr(a,n))
165#else 165#elif defined(__GNUC__) && __GNUC__>=2 && !defined(__STRICT_ANSI__) && !defined(OPENSSL_NO_ASM) && !defined(OPENSSL_NO_INLINE_ASM) && !defined(PEDANTIC)
166# if defined(__i386) || defined(__i386__) || defined(__x86_64) || defined(__x86_64__)
167# define ROTATE(a,n) ({ register unsigned int ret; \
168 asm ("rorl %1,%0" \
169 : "=r"(ret) \
170 : "I"(n),"0"(a) \
171 : "cc"); \
172 ret; \
173 })
174# endif
175#endif
176#ifndef ROTATE
166#define ROTATE(a,n) (((a)>>(n))+((a)<<(32-(n)))) 177#define ROTATE(a,n) (((a)>>(n))+((a)<<(32-(n))))
167#endif 178#endif
168 179
diff --git a/src/lib/libcrypto/des/des_old.h b/src/lib/libcrypto/des/des_old.h
index fe32f21f61..1d8bf65101 100644
--- a/src/lib/libcrypto/des/des_old.h
+++ b/src/lib/libcrypto/des/des_old.h
@@ -173,10 +173,12 @@ typedef struct _ossl_old_des_ks_struct
173 DES_fcrypt((b),(s),(r)) 173 DES_fcrypt((b),(s),(r))
174#define des_crypt(b,s)\ 174#define des_crypt(b,s)\
175 DES_crypt((b),(s)) 175 DES_crypt((b),(s))
176#if 0
176#if !defined(PERL5) && !defined(__FreeBSD__) && !defined(NeXT) && !defined(__OpenBSD__) 177#if !defined(PERL5) && !defined(__FreeBSD__) && !defined(NeXT) && !defined(__OpenBSD__)
177#define crypt(b,s)\ 178#define crypt(b,s)\
178 DES_crypt((b),(s)) 179 DES_crypt((b),(s))
179#endif 180#endif
181#endif
180#define des_ofb_encrypt(i,o,n,l,k,iv)\ 182#define des_ofb_encrypt(i,o,n,l,k,iv)\
181 DES_ofb_encrypt((i),(o),(n),(l),&(k),(iv)) 183 DES_ofb_encrypt((i),(o),(n),(l),&(k),(iv))
182#define des_pcbc_encrypt(i,o,l,k,iv,e)\ 184#define des_pcbc_encrypt(i,o,l,k,iv,e)\
diff --git a/src/lib/libcrypto/des/des_ver.h b/src/lib/libcrypto/des/des_ver.h
index ec9cc736e3..379bbadda2 100644
--- a/src/lib/libcrypto/des/des_ver.h
+++ b/src/lib/libcrypto/des/des_ver.h
@@ -63,5 +63,9 @@
63# define OPENSSL_EXTERN OPENSSL_EXPORT 63# define OPENSSL_EXTERN OPENSSL_EXPORT
64#endif 64#endif
65 65
66OPENSSL_EXTERN const char *DES_version; /* SSLeay version string */ 66/* The following macros make sure the names are different from libdes names */
67OPENSSL_EXTERN const char *libdes_version; /* old libdes version string */ 67#define DES_version OSSL_DES_version
68#define libdes_version OSSL_libdes_version
69
70OPENSSL_EXTERN const char *OSSL_DES_version; /* SSLeay version string */
71OPENSSL_EXTERN const char *OSSL_libdes_version; /* old libdes version string */
diff --git a/src/lib/libcrypto/des/destest.c b/src/lib/libcrypto/des/destest.c
index 58e8c35dcb..687c00c792 100644
--- a/src/lib/libcrypto/des/destest.c
+++ b/src/lib/libcrypto/des/destest.c
@@ -84,9 +84,7 @@ int main(int argc, char *argv[])
84#else 84#else
85#include <openssl/des.h> 85#include <openssl/des.h>
86 86
87#if defined(PERL5) || defined(__FreeBSD__) || defined(NeXT)
88#define crypt(c,s) (des_crypt((c),(s))) 87#define crypt(c,s) (des_crypt((c),(s)))
89#endif
90 88
91/* tisk tisk - the test keys don't all have odd parity :-( */ 89/* tisk tisk - the test keys don't all have odd parity :-( */
92/* test data */ 90/* test data */
@@ -322,7 +320,11 @@ static unsigned char ofb_cipher[24]=
322 0x3d,0x6d,0x5b,0xe3,0x25,0x5a,0xf8,0xc3 320 0x3d,0x6d,0x5b,0xe3,0x25,0x5a,0xf8,0xc3
323 }; 321 };
324 322
323#if 0
325static DES_LONG cbc_cksum_ret=0xB462FEF7L; 324static DES_LONG cbc_cksum_ret=0xB462FEF7L;
325#else
326static DES_LONG cbc_cksum_ret=0xF7FE62B4L;
327#endif
326static unsigned char cbc_cksum_data[8]={0x1D,0x26,0x93,0x97,0xf7,0xfe,0x62,0xb4}; 328static unsigned char cbc_cksum_data[8]={0x1D,0x26,0x93,0x97,0xf7,0xfe,0x62,0xb4};
327 329
328static char *pt(unsigned char *p); 330static char *pt(unsigned char *p);
diff --git a/src/lib/libcrypto/des/read2pwd.c b/src/lib/libcrypto/des/read2pwd.c
index b4720c3a98..3a63c4016c 100644
--- a/src/lib/libcrypto/des/read2pwd.c
+++ b/src/lib/libcrypto/des/read2pwd.c
@@ -120,8 +120,8 @@ int DES_read_password(DES_cblock *key, const char *prompt, int verify)
120 120
121 if ((ok=UI_UTIL_read_pw(buf,buff,BUFSIZ,prompt,verify)) == 0) 121 if ((ok=UI_UTIL_read_pw(buf,buff,BUFSIZ,prompt,verify)) == 0)
122 DES_string_to_key(buf,key); 122 DES_string_to_key(buf,key);
123 memset(buf,0,BUFSIZ); 123 OPENSSL_cleanse(buf,BUFSIZ);
124 memset(buff,0,BUFSIZ); 124 OPENSSL_cleanse(buff,BUFSIZ);
125 return(ok); 125 return(ok);
126 } 126 }
127 127
@@ -133,7 +133,7 @@ int DES_read_2passwords(DES_cblock *key1, DES_cblock *key2, const char *prompt,
133 133
134 if ((ok=UI_UTIL_read_pw(buf,buff,BUFSIZ,prompt,verify)) == 0) 134 if ((ok=UI_UTIL_read_pw(buf,buff,BUFSIZ,prompt,verify)) == 0)
135 DES_string_to_2keys(buf,key1,key2); 135 DES_string_to_2keys(buf,key1,key2);
136 memset(buf,0,BUFSIZ); 136 OPENSSL_cleanse(buf,BUFSIZ);
137 memset(buff,0,BUFSIZ); 137 OPENSSL_cleanse(buff,BUFSIZ);
138 return(ok); 138 return(ok);
139 } 139 }
diff --git a/src/lib/libcrypto/des/read_pwd.c b/src/lib/libcrypto/des/read_pwd.c
index 9061935f21..ce5fa00a37 100644
--- a/src/lib/libcrypto/des/read_pwd.c
+++ b/src/lib/libcrypto/des/read_pwd.c
@@ -101,8 +101,10 @@
101 101
102#ifdef WIN_CONSOLE_BUG 102#ifdef WIN_CONSOLE_BUG
103#include <windows.h> 103#include <windows.h>
104#ifndef OPENSSL_SYS_WINCE
104#include <wincon.h> 105#include <wincon.h>
105#endif 106#endif
107#endif
106 108
107 109
108/* There are 5 types of terminal interface supported, 110/* There are 5 types of terminal interface supported,
@@ -133,7 +135,7 @@
133#define SGTTY 135#define SGTTY
134#endif 136#endif
135 137
136#if defined(OPENSSL_SYS_VSWORKS) 138#if defined(OPENSSL_SYS_VXWORKS)
137#undef TERMIOS 139#undef TERMIOS
138#undef TERMIO 140#undef TERMIO
139#undef SGTTY 141#undef SGTTY
@@ -167,7 +169,7 @@
167#include <sys/ioctl.h> 169#include <sys/ioctl.h>
168#endif 170#endif
169 171
170#if defined(OPENSSL_SYS_MSDOS) && !defined(__CYGWIN32__) 172#if defined(OPENSSL_SYS_MSDOS) && !defined(__CYGWIN32__) && !defined(OPENSSL_SYS_WINCE)
171#include <conio.h> 173#include <conio.h>
172#define fgets(a,b,c) noecho_fgets(a,b,c) 174#define fgets(a,b,c) noecho_fgets(a,b,c)
173#endif 175#endif
@@ -218,11 +220,29 @@ int des_read_pw_string(char *buf, int length, const char *prompt,
218 int ret; 220 int ret;
219 221
220 ret=des_read_pw(buf,buff,(length>BUFSIZ)?BUFSIZ:length,prompt,verify); 222 ret=des_read_pw(buf,buff,(length>BUFSIZ)?BUFSIZ:length,prompt,verify);
221 memset(buff,0,BUFSIZ); 223 OPENSSL_cleanse(buff,BUFSIZ);
222 return(ret); 224 return(ret);
223 } 225 }
224 226
225#ifndef OPENSSL_SYS_WIN16 227#ifdef OPENSSL_SYS_WINCE
228
229int des_read_pw(char *buf, char *buff, int size, const char *prompt, int verify)
230 {
231 memset(buf,0,size);
232 memset(buff,0,size);
233 return(0);
234 }
235
236#elif defined(OPENSSL_SYS_WIN16)
237
238int des_read_pw(char *buf, char *buff, int size, char *prompt, int verify)
239 {
240 memset(buf,0,size);
241 memset(buff,0,size);
242 return(0);
243 }
244
245#else /* !OPENSSL_SYS_WINCE && !OPENSSL_SYS_WIN16 */
226 246
227static void read_till_nl(FILE *in) 247static void read_till_nl(FILE *in)
228 { 248 {
@@ -274,7 +294,7 @@ int des_read_pw(char *buf, char *buff, int size, const char *prompt,
274#ifdef OPENSSL_SYS_MSDOS 294#ifdef OPENSSL_SYS_MSDOS
275 if ((tty=fopen("con","r")) == NULL) 295 if ((tty=fopen("con","r")) == NULL)
276 tty=stdin; 296 tty=stdin;
277#elif defined(MAC_OS_pre_X) || defined(OPENSSL_SYS_VSWORKS) 297#elif defined(MAC_OS_pre_X) || defined(OPENSSL_SYS_VXWORKS)
278 tty=stdin; 298 tty=stdin;
279#else 299#else
280#ifndef OPENSSL_SYS_MPE 300#ifndef OPENSSL_SYS_MPE
@@ -393,17 +413,6 @@ error:
393 return(!ok); 413 return(!ok);
394 } 414 }
395 415
396#else /* OPENSSL_SYS_WIN16 */
397
398int des_read_pw(char *buf, char *buff, int size, char *prompt, int verify)
399 {
400 memset(buf,0,size);
401 memset(buff,0,size);
402 return(0);
403 }
404
405#endif
406
407static void pushsig(void) 416static void pushsig(void)
408 { 417 {
409 int i; 418 int i;
@@ -466,7 +475,7 @@ static void recsig(int i)
466#endif 475#endif
467 } 476 }
468 477
469#if defined(OPENSSL_SYS_MSDOS) && !defined(OPENSSL_SYS_WIN16) 478#ifdef OPENSSL_SYS_MSDOS
470static int noecho_fgets(char *buf, int size, FILE *tty) 479static int noecho_fgets(char *buf, int size, FILE *tty)
471 { 480 {
472 int i; 481 int i;
@@ -509,3 +518,4 @@ static int noecho_fgets(char *buf, int size, FILE *tty)
509 return(strlen(buf)); 518 return(strlen(buf));
510 } 519 }
511#endif 520#endif
521#endif /* !OPENSSL_SYS_WINCE && !WIN16 */
diff --git a/src/lib/libcrypto/des/str2key.c b/src/lib/libcrypto/des/str2key.c
index 36c3f81d99..0373db469c 100644
--- a/src/lib/libcrypto/des/str2key.c
+++ b/src/lib/libcrypto/des/str2key.c
@@ -94,7 +94,7 @@ void DES_string_to_key(const char *str, DES_cblock *key)
94 DES_set_key_unchecked(key,&ks); 94 DES_set_key_unchecked(key,&ks);
95#endif 95#endif
96 DES_cbc_cksum((const unsigned char*)str,key,length,&ks,key); 96 DES_cbc_cksum((const unsigned char*)str,key,length,&ks,key);
97 memset(&ks,0,sizeof(ks)); 97 OPENSSL_cleanse(&ks,sizeof(ks));
98 DES_set_odd_parity(key); 98 DES_set_odd_parity(key);
99 } 99 }
100 100
@@ -167,7 +167,7 @@ void DES_string_to_2keys(const char *str, DES_cblock *key1, DES_cblock *key2)
167 DES_set_key_unchecked(key2,&ks); 167 DES_set_key_unchecked(key2,&ks);
168#endif 168#endif
169 DES_cbc_cksum((const unsigned char*)str,key2,length,&ks,key2); 169 DES_cbc_cksum((const unsigned char*)str,key2,length,&ks,key2);
170 memset(&ks,0,sizeof(ks)); 170 OPENSSL_cleanse(&ks,sizeof(ks));
171 DES_set_odd_parity(key1); 171 DES_set_odd_parity(key1);
172 DES_set_odd_parity(key2); 172 DES_set_odd_parity(key2);
173 } 173 }
diff --git a/src/lib/libcrypto/dh/Makefile.ssl b/src/lib/libcrypto/dh/Makefile.ssl
index 5e1aaae160..e05fc01a12 100644
--- a/src/lib/libcrypto/dh/Makefile.ssl
+++ b/src/lib/libcrypto/dh/Makefile.ssl
@@ -68,7 +68,7 @@ lint:
68 lint -DLINT $(INCLUDES) $(SRC)>fluff 68 lint -DLINT $(INCLUDES) $(SRC)>fluff
69 69
70depend: 70depend:
71 $(MAKEDEPEND) $(CFLAG) $(INCLUDES) $(DEPFLAG) $(PROGS) $(LIBSRC) 71 $(MAKEDEPEND) -- $(CFLAG) $(INCLUDES) $(DEPFLAG) -- $(PROGS) $(LIBSRC)
72 72
73dclean: 73dclean:
74 $(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new 74 $(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
@@ -112,17 +112,14 @@ dh_gen.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
112dh_gen.o: ../../include/openssl/ossl_typ.h ../../include/openssl/safestack.h 112dh_gen.o: ../../include/openssl/ossl_typ.h ../../include/openssl/safestack.h
113dh_gen.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 113dh_gen.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
114dh_gen.o: ../cryptlib.h dh_gen.c 114dh_gen.o: ../cryptlib.h dh_gen.c
115dh_key.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h 115dh_key.o: ../../e_os.h ../../include/openssl/bio.h ../../include/openssl/bn.h
116dh_key.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h 116dh_key.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
117dh_key.o: ../../include/openssl/crypto.h ../../include/openssl/dh.h 117dh_key.o: ../../include/openssl/dh.h ../../include/openssl/e_os2.h
118dh_key.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h 118dh_key.o: ../../include/openssl/err.h ../../include/openssl/lhash.h
119dh_key.o: ../../include/openssl/engine.h ../../include/openssl/err.h 119dh_key.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
120dh_key.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h 120dh_key.o: ../../include/openssl/ossl_typ.h ../../include/openssl/rand.h
121dh_key.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
122dh_key.o: ../../include/openssl/rand.h ../../include/openssl/rsa.h
123dh_key.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h 121dh_key.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
124dh_key.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h 122dh_key.o: ../../include/openssl/symhacks.h ../cryptlib.h dh_key.c
125dh_key.o: ../cryptlib.h dh_key.c
126dh_lib.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h 123dh_lib.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h
127dh_lib.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h 124dh_lib.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
128dh_lib.o: ../../include/openssl/crypto.h ../../include/openssl/dh.h 125dh_lib.o: ../../include/openssl/crypto.h ../../include/openssl/dh.h
diff --git a/src/lib/libcrypto/dh/dh_key.c b/src/lib/libcrypto/dh/dh_key.c
index 1a0efca2c4..77f2f50b51 100644
--- a/src/lib/libcrypto/dh/dh_key.c
+++ b/src/lib/libcrypto/dh/dh_key.c
@@ -61,7 +61,6 @@
61#include <openssl/bn.h> 61#include <openssl/bn.h>
62#include <openssl/rand.h> 62#include <openssl/rand.h>
63#include <openssl/dh.h> 63#include <openssl/dh.h>
64#include <openssl/engine.h>
65 64
66static int generate_key(DH *dh); 65static int generate_key(DH *dh);
67static int compute_key(unsigned char *key, const BIGNUM *pub_key, DH *dh); 66static int compute_key(unsigned char *key, const BIGNUM *pub_key, DH *dh);
diff --git a/src/lib/libcrypto/dh/dh_lib.c b/src/lib/libcrypto/dh/dh_lib.c
index ba5fd41057..09965ee2ea 100644
--- a/src/lib/libcrypto/dh/dh_lib.c
+++ b/src/lib/libcrypto/dh/dh_lib.c
@@ -60,7 +60,9 @@
60#include "cryptlib.h" 60#include "cryptlib.h"
61#include <openssl/bn.h> 61#include <openssl/bn.h>
62#include <openssl/dh.h> 62#include <openssl/dh.h>
63#ifndef OPENSSL_NO_ENGINE
63#include <openssl/engine.h> 64#include <openssl/engine.h>
65#endif
64 66
65const char *DH_version="Diffie-Hellman" OPENSSL_VERSION_PTEXT; 67const char *DH_version="Diffie-Hellman" OPENSSL_VERSION_PTEXT;
66 68
@@ -85,11 +87,13 @@ int DH_set_method(DH *dh, const DH_METHOD *meth)
85 const DH_METHOD *mtmp; 87 const DH_METHOD *mtmp;
86 mtmp = dh->meth; 88 mtmp = dh->meth;
87 if (mtmp->finish) mtmp->finish(dh); 89 if (mtmp->finish) mtmp->finish(dh);
90#ifndef OPENSSL_NO_ENGINE
88 if (dh->engine) 91 if (dh->engine)
89 { 92 {
90 ENGINE_finish(dh->engine); 93 ENGINE_finish(dh->engine);
91 dh->engine = NULL; 94 dh->engine = NULL;
92 } 95 }
96#endif
93 dh->meth = meth; 97 dh->meth = meth;
94 if (meth->init) meth->init(dh); 98 if (meth->init) meth->init(dh);
95 return 1; 99 return 1;
@@ -112,6 +116,7 @@ DH *DH_new_method(ENGINE *engine)
112 } 116 }
113 117
114 ret->meth = DH_get_default_method(); 118 ret->meth = DH_get_default_method();
119#ifndef OPENSSL_NO_ENGINE
115 if (engine) 120 if (engine)
116 { 121 {
117 if (!ENGINE_init(engine)) 122 if (!ENGINE_init(engine))
@@ -135,6 +140,7 @@ DH *DH_new_method(ENGINE *engine)
135 return NULL; 140 return NULL;
136 } 141 }
137 } 142 }
143#endif
138 144
139 ret->pad=0; 145 ret->pad=0;
140 ret->version=0; 146 ret->version=0;
@@ -154,8 +160,10 @@ DH *DH_new_method(ENGINE *engine)
154 CRYPTO_new_ex_data(CRYPTO_EX_INDEX_DH, ret, &ret->ex_data); 160 CRYPTO_new_ex_data(CRYPTO_EX_INDEX_DH, ret, &ret->ex_data);
155 if ((ret->meth->init != NULL) && !ret->meth->init(ret)) 161 if ((ret->meth->init != NULL) && !ret->meth->init(ret))
156 { 162 {
163#ifndef OPENSSL_NO_ENGINE
157 if (ret->engine) 164 if (ret->engine)
158 ENGINE_finish(ret->engine); 165 ENGINE_finish(ret->engine);
166#endif
159 CRYPTO_free_ex_data(CRYPTO_EX_INDEX_DH, ret, &ret->ex_data); 167 CRYPTO_free_ex_data(CRYPTO_EX_INDEX_DH, ret, &ret->ex_data);
160 OPENSSL_free(ret); 168 OPENSSL_free(ret);
161 ret=NULL; 169 ret=NULL;
@@ -182,8 +190,10 @@ void DH_free(DH *r)
182 190
183 if (r->meth->finish) 191 if (r->meth->finish)
184 r->meth->finish(r); 192 r->meth->finish(r);
193#ifndef OPENSSL_NO_ENGINE
185 if (r->engine) 194 if (r->engine)
186 ENGINE_finish(r->engine); 195 ENGINE_finish(r->engine);
196#endif
187 197
188 CRYPTO_free_ex_data(CRYPTO_EX_INDEX_DH, r, &r->ex_data); 198 CRYPTO_free_ex_data(CRYPTO_EX_INDEX_DH, r, &r->ex_data);
189 199
diff --git a/src/lib/libcrypto/dh/dhtest.c b/src/lib/libcrypto/dh/dhtest.c
index 34894ced73..d75077f9fa 100644
--- a/src/lib/libcrypto/dh/dhtest.c
+++ b/src/lib/libcrypto/dh/dhtest.c
@@ -59,9 +59,9 @@
59#include <stdio.h> 59#include <stdio.h>
60#include <stdlib.h> 60#include <stdlib.h>
61#include <string.h> 61#include <string.h>
62#ifdef OPENSSL_SYS_WINDOWS 62
63#include "../bio/bss_file.c" 63#include "../e_os.h"
64#endif 64
65#include <openssl/crypto.h> 65#include <openssl/crypto.h>
66#include <openssl/bio.h> 66#include <openssl/bio.h>
67#include <openssl/bn.h> 67#include <openssl/bn.h>
@@ -84,10 +84,6 @@ int main(int argc, char *argv[])
84#endif 84#endif
85 85
86static void MS_CALLBACK cb(int p, int n, void *arg); 86static void MS_CALLBACK cb(int p, int n, void *arg);
87#ifdef OPENSSL_NO_STDIO
88#define APPS_WIN16
89#include "bss_file.c"
90#endif
91 87
92static const char rnd_seed[] = "string to make the random number generator think it has entropy"; 88static const char rnd_seed[] = "string to make the random number generator think it has entropy";
93 89
@@ -111,7 +107,7 @@ int main(int argc, char *argv[])
111 RAND_seed(rnd_seed, sizeof rnd_seed); 107 RAND_seed(rnd_seed, sizeof rnd_seed);
112 108
113 out=BIO_new(BIO_s_file()); 109 out=BIO_new(BIO_s_file());
114 if (out == NULL) exit(1); 110 if (out == NULL) EXIT(1);
115 BIO_set_fp(out,stdout,BIO_NOCLOSE); 111 BIO_set_fp(out,stdout,BIO_NOCLOSE);
116 112
117 a=DH_generate_parameters(64,DH_GENERATOR_5,cb,out); 113 a=DH_generate_parameters(64,DH_GENERATOR_5,cb,out);
@@ -195,7 +191,7 @@ err:
195 CRYPTO_cleanup_all_ex_data(); 191 CRYPTO_cleanup_all_ex_data();
196 ERR_remove_state(0); 192 ERR_remove_state(0);
197 CRYPTO_mem_leaks_fp(stderr); 193 CRYPTO_mem_leaks_fp(stderr);
198 exit(ret); 194 EXIT(ret);
199 return(ret); 195 return(ret);
200 } 196 }
201 197
diff --git a/src/lib/libcrypto/doc/DH_generate_parameters.pod b/src/lib/libcrypto/doc/DH_generate_parameters.pod
index 4a2d653758..9081e9ea7c 100644
--- a/src/lib/libcrypto/doc/DH_generate_parameters.pod
+++ b/src/lib/libcrypto/doc/DH_generate_parameters.pod
@@ -59,7 +59,8 @@ a usable generator.
59 59
60=head1 SEE ALSO 60=head1 SEE ALSO
61 61
62L<dh(3)|dh(3)>, L<ERR_get_error(3)|ERR_get_error(3)>, L<rand(3)|rand(3)>, L<DH_free(3)|DH_free(3)> 62L<dh(3)|dh(3)>, L<ERR_get_error(3)|ERR_get_error(3)>, L<rand(3)|rand(3)>,
63L<DH_free(3)|DH_free(3)>
63 64
64=head1 HISTORY 65=head1 HISTORY
65 66
diff --git a/src/lib/libcrypto/doc/DSA_SIG_new.pod b/src/lib/libcrypto/doc/DSA_SIG_new.pod
index 45df4c0661..3ac6140038 100644
--- a/src/lib/libcrypto/doc/DSA_SIG_new.pod
+++ b/src/lib/libcrypto/doc/DSA_SIG_new.pod
@@ -30,7 +30,8 @@ DSA_SIG_free() returns no value.
30 30
31=head1 SEE ALSO 31=head1 SEE ALSO
32 32
33L<dsa(3)|dsa(3)>, L<ERR_get_error(3)|ERR_get_error(3)>, L<DSA_do_sign(3)|DSA_do_sign(3)> 33L<dsa(3)|dsa(3)>, L<ERR_get_error(3)|ERR_get_error(3)>,
34L<DSA_do_sign(3)|DSA_do_sign(3)>
34 35
35=head1 HISTORY 36=head1 HISTORY
36 37
diff --git a/src/lib/libcrypto/doc/DSA_generate_key.pod b/src/lib/libcrypto/doc/DSA_generate_key.pod
index 9906a2d7e0..af83ccfaa1 100644
--- a/src/lib/libcrypto/doc/DSA_generate_key.pod
+++ b/src/lib/libcrypto/doc/DSA_generate_key.pod
@@ -24,7 +24,8 @@ The error codes can be obtained by L<ERR_get_error(3)|ERR_get_error(3)>.
24 24
25=head1 SEE ALSO 25=head1 SEE ALSO
26 26
27L<dsa(3)|dsa(3)>, L<ERR_get_error(3)|ERR_get_error(3)>, L<rand(3)|rand(3)>, L<DSA_generate_parameters(3)|DSA_generate_parameters(3)> 27L<dsa(3)|dsa(3)>, L<ERR_get_error(3)|ERR_get_error(3)>, L<rand(3)|rand(3)>,
28L<DSA_generate_parameters(3)|DSA_generate_parameters(3)>
28 29
29=head1 HISTORY 30=head1 HISTORY
30 31
diff --git a/src/lib/libcrypto/doc/ERR_get_error.pod b/src/lib/libcrypto/doc/ERR_get_error.pod
index 9fdedbcb91..34443045fc 100644
--- a/src/lib/libcrypto/doc/ERR_get_error.pod
+++ b/src/lib/libcrypto/doc/ERR_get_error.pod
@@ -5,7 +5,7 @@
5ERR_get_error, ERR_peek_error, ERR_peek_last_error, 5ERR_get_error, ERR_peek_error, ERR_peek_last_error,
6ERR_get_error_line, ERR_peek_error_line, ERR_peek_last_error_line, 6ERR_get_error_line, ERR_peek_error_line, ERR_peek_last_error_line,
7ERR_get_error_line_data, ERR_peek_error_line_data, 7ERR_get_error_line_data, ERR_peek_error_line_data,
8ERR_peek_error_line_data - obtain error code and data 8ERR_peek_last_error_line_data - obtain error code and data
9 9
10=head1 SYNOPSIS 10=head1 SYNOPSIS
11 11
diff --git a/src/lib/libcrypto/doc/EVP_EncryptInit.pod b/src/lib/libcrypto/doc/EVP_EncryptInit.pod
index 75cceb1ca2..daf57e5895 100644
--- a/src/lib/libcrypto/doc/EVP_EncryptInit.pod
+++ b/src/lib/libcrypto/doc/EVP_EncryptInit.pod
@@ -419,7 +419,7 @@ Encrypt a string using blowfish:
419 EVP_CIPHER_CTX ctx; 419 EVP_CIPHER_CTX ctx;
420 FILE *out; 420 FILE *out;
421 EVP_CIPHER_CTX_init(&ctx); 421 EVP_CIPHER_CTX_init(&ctx);
422 EVP_EncryptInit_ex(&ctx, NULL, EVP_bf_cbc(), key, iv); 422 EVP_EncryptInit_ex(&ctx, EVP_bf_cbc(), NULL, key, iv);
423 423
424 if(!EVP_EncryptUpdate(&ctx, outbuf, &outlen, intext, strlen(intext))) 424 if(!EVP_EncryptUpdate(&ctx, outbuf, &outlen, intext, strlen(intext)))
425 { 425 {
diff --git a/src/lib/libcrypto/doc/EVP_SealInit.pod b/src/lib/libcrypto/doc/EVP_SealInit.pod
index 25ef07f7c7..b5e477e294 100644
--- a/src/lib/libcrypto/doc/EVP_SealInit.pod
+++ b/src/lib/libcrypto/doc/EVP_SealInit.pod
@@ -18,22 +18,28 @@ EVP_SealInit, EVP_SealUpdate, EVP_SealFinal - EVP envelope encryption
18=head1 DESCRIPTION 18=head1 DESCRIPTION
19 19
20The EVP envelope routines are a high level interface to envelope 20The EVP envelope routines are a high level interface to envelope
21encryption. They generate a random key and then "envelope" it by 21encryption. They generate a random key and IV (if required) then
22using public key encryption. Data can then be encrypted using this 22"envelope" it by using public key encryption. Data can then be
23key. 23encrypted using this key.
24 24
25EVP_SealInit() initializes a cipher context B<ctx> for encryption 25EVP_SealInit() initializes a cipher context B<ctx> for encryption
26with cipher B<type> using a random secret key and IV supplied in 26with cipher B<type> using a random secret key and IV. B<type> is normally
27the B<iv> parameter. B<type> is normally supplied by a function such 27supplied by a function such as EVP_des_cbc(). The secret key is encrypted
28as EVP_des_cbc(). The secret key is encrypted using one or more public 28using one or more public keys, this allows the same encrypted data to be
29keys, this allows the same encrypted data to be decrypted using any 29decrypted using any of the corresponding private keys. B<ek> is an array of
30of the corresponding private keys. B<ek> is an array of buffers where 30buffers where the public key encrypted secret key will be written, each buffer
31the public key encrypted secret key will be written, each buffer must 31must contain enough room for the corresponding encrypted key: that is
32contain enough room for the corresponding encrypted key: that is
33B<ek[i]> must have room for B<EVP_PKEY_size(pubk[i])> bytes. The actual 32B<ek[i]> must have room for B<EVP_PKEY_size(pubk[i])> bytes. The actual
34size of each encrypted secret key is written to the array B<ekl>. B<pubk> is 33size of each encrypted secret key is written to the array B<ekl>. B<pubk> is
35an array of B<npubk> public keys. 34an array of B<npubk> public keys.
36 35
36The B<iv> parameter is a buffer where the generated IV is written to. It must
37contain enough room for the corresponding cipher's IV, as determined by (for
38example) EVP_CIPHER_iv_length(type).
39
40If the cipher does not require an IV then the B<iv> parameter is ignored
41and can be B<NULL>.
42
37EVP_SealUpdate() and EVP_SealFinal() have exactly the same properties 43EVP_SealUpdate() and EVP_SealFinal() have exactly the same properties
38as the EVP_EncryptUpdate() and EVP_EncryptFinal() routines, as 44as the EVP_EncryptUpdate() and EVP_EncryptFinal() routines, as
39documented on the L<EVP_EncryptInit(3)|EVP_EncryptInit(3)> manual 45documented on the L<EVP_EncryptInit(3)|EVP_EncryptInit(3)> manual
diff --git a/src/lib/libcrypto/doc/RAND_bytes.pod b/src/lib/libcrypto/doc/RAND_bytes.pod
index b03748b918..ce6329ce54 100644
--- a/src/lib/libcrypto/doc/RAND_bytes.pod
+++ b/src/lib/libcrypto/doc/RAND_bytes.pod
@@ -35,7 +35,8 @@ method.
35 35
36=head1 SEE ALSO 36=head1 SEE ALSO
37 37
38L<rand(3)|rand(3)>, L<ERR_get_error(3)|ERR_get_error(3)>, L<RAND_add(3)|RAND_add(3)> 38L<rand(3)|rand(3)>, L<ERR_get_error(3)|ERR_get_error(3)>,
39L<RAND_add(3)|RAND_add(3)>
39 40
40=head1 HISTORY 41=head1 HISTORY
41 42
diff --git a/src/lib/libcrypto/doc/RSA_generate_key.pod b/src/lib/libcrypto/doc/RSA_generate_key.pod
index 11bc0b3459..52dbb14a53 100644
--- a/src/lib/libcrypto/doc/RSA_generate_key.pod
+++ b/src/lib/libcrypto/doc/RSA_generate_key.pod
@@ -59,7 +59,8 @@ RSA_generate_key() goes into an infinite loop for illegal input values.
59 59
60=head1 SEE ALSO 60=head1 SEE ALSO
61 61
62L<ERR_get_error(3)|ERR_get_error(3)>, L<rand(3)|rand(3)>, L<rsa(3)|rsa(3)>, L<RSA_free(3)|RSA_free(3)> 62L<ERR_get_error(3)|ERR_get_error(3)>, L<rand(3)|rand(3)>, L<rsa(3)|rsa(3)>,
63L<RSA_free(3)|RSA_free(3)>
63 64
64=head1 HISTORY 65=head1 HISTORY
65 66
diff --git a/src/lib/libcrypto/doc/RSA_print.pod b/src/lib/libcrypto/doc/RSA_print.pod
index ff2d353d1a..c971e91f4d 100644
--- a/src/lib/libcrypto/doc/RSA_print.pod
+++ b/src/lib/libcrypto/doc/RSA_print.pod
@@ -2,9 +2,9 @@
2 2
3=head1 NAME 3=head1 NAME
4 4
5RSA_print, RSA_print_fp, DHparams_print, DHparams_print_fp, DSA_print, 5RSA_print, RSA_print_fp,
6DSA_print_fp, DHparams_print, DHparams_print_fp - print cryptographic 6DSAparams_print, DSAparams_print_fp, DSA_print, DSA_print_fp,
7parameters 7DHparams_print, DHparams_print_fp - print cryptographic parameters
8 8
9=head1 SYNOPSIS 9=head1 SYNOPSIS
10 10
diff --git a/src/lib/libcrypto/doc/RSA_private_encrypt.pod b/src/lib/libcrypto/doc/RSA_private_encrypt.pod
index 0d1b2bd541..746a80c79e 100644
--- a/src/lib/libcrypto/doc/RSA_private_encrypt.pod
+++ b/src/lib/libcrypto/doc/RSA_private_encrypt.pod
@@ -59,8 +59,8 @@ obtained by L<ERR_get_error(3)|ERR_get_error(3)>.
59 59
60=head1 SEE ALSO 60=head1 SEE ALSO
61 61
62L<ERR_get_error(3)|ERR_get_error(3)>, L<rsa(3)|rsa(3)>, L<RSA_sign(3)|RSA_sign(3)>, 62L<ERR_get_error(3)|ERR_get_error(3)>, L<rsa(3)|rsa(3)>,
63L<RSA_verify(3)|RSA_verify(3)> 63L<RSA_sign(3)|RSA_sign(3)>, L<RSA_verify(3)|RSA_verify(3)>
64 64
65=head1 HISTORY 65=head1 HISTORY
66 66
diff --git a/src/lib/libcrypto/doc/RSA_public_encrypt.pod b/src/lib/libcrypto/doc/RSA_public_encrypt.pod
index 8022a23f99..d53e19d2b7 100644
--- a/src/lib/libcrypto/doc/RSA_public_encrypt.pod
+++ b/src/lib/libcrypto/doc/RSA_public_encrypt.pod
@@ -72,7 +72,8 @@ SSL, PKCS #1 v2.0
72 72
73=head1 SEE ALSO 73=head1 SEE ALSO
74 74
75L<ERR_get_error(3)|ERR_get_error(3)>, L<rand(3)|rand(3)>, L<rsa(3)|rsa(3)>, L<RSA_size(3)|RSA_size(3)> 75L<ERR_get_error(3)|ERR_get_error(3)>, L<rand(3)|rand(3)>, L<rsa(3)|rsa(3)>,
76L<RSA_size(3)|RSA_size(3)>
76 77
77=head1 HISTORY 78=head1 HISTORY
78 79
diff --git a/src/lib/libcrypto/doc/RSA_set_method.pod b/src/lib/libcrypto/doc/RSA_set_method.pod
index 0687c2242a..0a305f6b14 100644
--- a/src/lib/libcrypto/doc/RSA_set_method.pod
+++ b/src/lib/libcrypto/doc/RSA_set_method.pod
@@ -3,13 +3,12 @@
3=head1 NAME 3=head1 NAME
4 4
5RSA_set_default_method, RSA_get_default_method, RSA_set_method, 5RSA_set_default_method, RSA_get_default_method, RSA_set_method,
6RSA_get_method, RSA_PKCS1_SSLeay, 6RSA_get_method, RSA_PKCS1_SSLeay, RSA_null_method, RSA_flags,
7RSA_null_method, RSA_flags, RSA_new_method - select RSA method 7RSA_new_method - select RSA method
8 8
9=head1 SYNOPSIS 9=head1 SYNOPSIS
10 10
11 #include <openssl/rsa.h> 11 #include <openssl/rsa.h>
12 #include <openssl/engine.h>
13 12
14 void RSA_set_default_method(const RSA_METHOD *meth); 13 void RSA_set_default_method(const RSA_METHOD *meth);
15 14
@@ -25,7 +24,7 @@ RSA_null_method, RSA_flags, RSA_new_method - select RSA method
25 24
26 int RSA_flags(const RSA *rsa); 25 int RSA_flags(const RSA *rsa);
27 26
28 RSA *RSA_new_method(ENGINE *engine); 27 RSA *RSA_new_method(RSA_METHOD *method);
29 28
30=head1 DESCRIPTION 29=head1 DESCRIPTION
31 30
@@ -70,6 +69,12 @@ B<engine> will be used for the RSA operations. If B<engine> is NULL, the
70default ENGINE for RSA operations is used, and if no default ENGINE is set, 69default ENGINE for RSA operations is used, and if no default ENGINE is set,
71the RSA_METHOD controlled by RSA_set_default_method() is used. 70the RSA_METHOD controlled by RSA_set_default_method() is used.
72 71
72RSA_flags() returns the B<flags> that are set for B<rsa>'s current method.
73
74RSA_new_method() allocates and initializes an B<RSA> structure so that
75B<method> will be used for the RSA operations. If B<method> is B<NULL>,
76the default method is used.
77
73=head1 THE RSA_METHOD STRUCTURE 78=head1 THE RSA_METHOD STRUCTURE
74 79
75 typedef struct rsa_meth_st 80 typedef struct rsa_meth_st
diff --git a/src/lib/libcrypto/doc/RSA_sign_ASN1_OCTET_STRING.pod b/src/lib/libcrypto/doc/RSA_sign_ASN1_OCTET_STRING.pod
index b8c7bbb7e3..e70380bbfc 100644
--- a/src/lib/libcrypto/doc/RSA_sign_ASN1_OCTET_STRING.pod
+++ b/src/lib/libcrypto/doc/RSA_sign_ASN1_OCTET_STRING.pod
@@ -47,8 +47,8 @@ These functions serve no recognizable purpose.
47 47
48=head1 SEE ALSO 48=head1 SEE ALSO
49 49
50L<ERR_get_error(3)|ERR_get_error(3)>, L<objects(3)|objects(3)>, L<rand(3)|rand(3)>, 50L<ERR_get_error(3)|ERR_get_error(3)>, L<objects(3)|objects(3)>,
51L<rsa(3)|rsa(3)>, L<RSA_sign(3)|RSA_sign(3)>, 51L<rand(3)|rand(3)>, L<rsa(3)|rsa(3)>, L<RSA_sign(3)|RSA_sign(3)>,
52L<RSA_verify(3)|RSA_verify(3)> 52L<RSA_verify(3)|RSA_verify(3)>
53 53
54=head1 HISTORY 54=head1 HISTORY
diff --git a/src/lib/libcrypto/doc/d2i_DHparams.pod b/src/lib/libcrypto/doc/d2i_DHparams.pod
index a6d1743d39..1e98aebeca 100644
--- a/src/lib/libcrypto/doc/d2i_DHparams.pod
+++ b/src/lib/libcrypto/doc/d2i_DHparams.pod
@@ -2,7 +2,7 @@
2 2
3=head1 NAME 3=head1 NAME
4 4
5d2i_DHparams, i2d_DHparams - ... 5d2i_DHparams, i2d_DHparams - PKCS#3 DH parameter functions.
6 6
7=head1 SYNOPSIS 7=head1 SYNOPSIS
8 8
@@ -13,18 +13,18 @@ d2i_DHparams, i2d_DHparams - ...
13 13
14=head1 DESCRIPTION 14=head1 DESCRIPTION
15 15
16... 16These functions decode and encode PKCS#3 DH parameters using the
17DHparameter structure described in PKCS#3.
17 18
18=head1 RETURN VALUES 19Othewise these behave in a similar way to d2i_X509() and i2d_X509()
19 20described in the L<d2i_X509(3)|d2i_X509(3)> manual page.
20...
21 21
22=head1 SEE ALSO 22=head1 SEE ALSO
23 23
24... 24L<d2i_X509(3)|d2i_X509(3)>
25 25
26=head1 HISTORY 26=head1 HISTORY
27 27
28... 28TBA
29 29
30=cut 30=cut
diff --git a/src/lib/libcrypto/doc/d2i_RSAPublicKey.pod b/src/lib/libcrypto/doc/d2i_RSAPublicKey.pod
index ff4d0d57db..7c71bcbf3d 100644
--- a/src/lib/libcrypto/doc/d2i_RSAPublicKey.pod
+++ b/src/lib/libcrypto/doc/d2i_RSAPublicKey.pod
@@ -2,7 +2,9 @@
2 2
3=head1 NAME 3=head1 NAME
4 4
5d2i_RSAPublicKey, i2d_RSAPublicKey, d2i_RSAPrivateKey, i2d_RSAPrivateKey, i2d_Netscape_RSA, d2i_Netscape_RSA - ... 5d2i_RSAPublicKey, i2d_RSAPublicKey, d2i_RSAPrivateKey, i2d_RSAPrivateKey,
6d2i_RSA_PUBKEY, i2d_RSA_PUBKEY, i2d_Netscape_RSA,
7d2i_Netscape_RSA - RSA public and private key encoding functions.
6 8
7=head1 SYNOPSIS 9=head1 SYNOPSIS
8 10
@@ -12,6 +14,10 @@ d2i_RSAPublicKey, i2d_RSAPublicKey, d2i_RSAPrivateKey, i2d_RSAPrivateKey, i2d_Ne
12 14
13 int i2d_RSAPublicKey(RSA *a, unsigned char **pp); 15 int i2d_RSAPublicKey(RSA *a, unsigned char **pp);
14 16
17 RSA * d2i_RSA_PUBKEY(RSA **a, unsigned char **pp, long length);
18
19 int i2d_RSA_PUBKEY(RSA *a, unsigned char **pp);
20
15 RSA * d2i_RSAPrivateKey(RSA **a, unsigned char **pp, long length); 21 RSA * d2i_RSAPrivateKey(RSA **a, unsigned char **pp, long length);
16 22
17 int i2d_RSAPrivateKey(RSA *a, unsigned char **pp); 23 int i2d_RSAPrivateKey(RSA *a, unsigned char **pp);
@@ -22,18 +28,39 @@ d2i_RSAPublicKey, i2d_RSAPublicKey, d2i_RSAPrivateKey, i2d_RSAPrivateKey, i2d_Ne
22 28
23=head1 DESCRIPTION 29=head1 DESCRIPTION
24 30
25... 31d2i_RSAPublicKey() and i2d_RSAPublicKey() decode and encode a PKCS#1 RSAPublicKey
32structure.
33
34d2i_RSA_PUKEY() and i2d_RSA_PUKEY() decode and encode an RSA public key using a
35SubjectPublicKeyInfo (certificate public key) structure.
36
37d2i_RSAPrivateKey(), i2d_RSAPrivateKey() decode and encode a PKCS#1 RSAPrivateKey
38structure.
39
40d2i_Netscape_RSA(), i2d_Netscape_RSA() decode and encode an RSA private key in
41NET format.
42
43The usage of all of these functions is similar to the d2i_X509() and
44i2d_X509() described in the L<d2i_X509(3)|d2i_X509(3)> manual page.
45
46=head1 NOTES
47
48The B<RSA> structure passed to the private key encoding functions should have
49all the PKCS#1 private key components present.
26 50
27=head1 RETURN VALUES 51The data encoded by the private key functions is unencrypted and therefore
52offers no private key security.
28 53
29... 54The NET format functions are present to provide compatibility with certain very
55old software. This format has some severe security weaknesses and should be
56avoided if possible.
30 57
31=head1 SEE ALSO 58=head1 SEE ALSO
32 59
33... 60L<d2i_X509(3)|d2i_X509(3)>
34 61
35=head1 HISTORY 62=head1 HISTORY
36 63
37... 64TBA
38 65
39=cut 66=cut
diff --git a/src/lib/libcrypto/dsa/Makefile.ssl b/src/lib/libcrypto/dsa/Makefile.ssl
index d308caafca..e5f8a8cf51 100644
--- a/src/lib/libcrypto/dsa/Makefile.ssl
+++ b/src/lib/libcrypto/dsa/Makefile.ssl
@@ -70,7 +70,7 @@ lint:
70 lint -DLINT $(INCLUDES) $(SRC)>fluff 70 lint -DLINT $(INCLUDES) $(SRC)>fluff
71 71
72depend: 72depend:
73 $(MAKEDEPEND) $(CFLAG) $(INCLUDES) $(DEPFLAG) $(PROGS) $(LIBSRC) 73 $(MAKEDEPEND) -- $(CFLAG) $(INCLUDES) $(DEPFLAG) -- $(PROGS) $(LIBSRC)
74 74
75dclean: 75dclean:
76 $(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new 76 $(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
@@ -143,35 +143,29 @@ dsa_ossl.o: ../../e_os.h ../../include/openssl/asn1.h
143dsa_ossl.o: ../../include/openssl/bio.h ../../include/openssl/bn.h 143dsa_ossl.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
144dsa_ossl.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 144dsa_ossl.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
145dsa_ossl.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h 145dsa_ossl.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
146dsa_ossl.o: ../../include/openssl/e_os2.h ../../include/openssl/engine.h 146dsa_ossl.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
147dsa_ossl.o: ../../include/openssl/err.h ../../include/openssl/lhash.h 147dsa_ossl.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
148dsa_ossl.o: ../../include/openssl/opensslconf.h
149dsa_ossl.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h 148dsa_ossl.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
150dsa_ossl.o: ../../include/openssl/rand.h ../../include/openssl/rsa.h 149dsa_ossl.o: ../../include/openssl/rand.h ../../include/openssl/safestack.h
151dsa_ossl.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h 150dsa_ossl.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
152dsa_ossl.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
153dsa_ossl.o: ../cryptlib.h dsa_ossl.c 151dsa_ossl.o: ../cryptlib.h dsa_ossl.c
154dsa_sign.o: ../../e_os.h ../../include/openssl/asn1.h 152dsa_sign.o: ../../e_os.h ../../include/openssl/asn1.h
155dsa_sign.o: ../../include/openssl/bio.h ../../include/openssl/bn.h 153dsa_sign.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
156dsa_sign.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 154dsa_sign.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
157dsa_sign.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h 155dsa_sign.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
158dsa_sign.o: ../../include/openssl/e_os2.h ../../include/openssl/engine.h 156dsa_sign.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
159dsa_sign.o: ../../include/openssl/err.h ../../include/openssl/lhash.h 157dsa_sign.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
160dsa_sign.o: ../../include/openssl/opensslconf.h
161dsa_sign.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h 158dsa_sign.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
162dsa_sign.o: ../../include/openssl/rand.h ../../include/openssl/rsa.h 159dsa_sign.o: ../../include/openssl/rand.h ../../include/openssl/safestack.h
163dsa_sign.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h 160dsa_sign.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
164dsa_sign.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
165dsa_sign.o: ../cryptlib.h dsa_sign.c 161dsa_sign.o: ../cryptlib.h dsa_sign.c
166dsa_vrf.o: ../../e_os.h ../../include/openssl/asn1.h 162dsa_vrf.o: ../../e_os.h ../../include/openssl/asn1.h
167dsa_vrf.o: ../../include/openssl/asn1_mac.h ../../include/openssl/bio.h 163dsa_vrf.o: ../../include/openssl/asn1_mac.h ../../include/openssl/bio.h
168dsa_vrf.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h 164dsa_vrf.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
169dsa_vrf.o: ../../include/openssl/crypto.h ../../include/openssl/dh.h 165dsa_vrf.o: ../../include/openssl/crypto.h ../../include/openssl/dh.h
170dsa_vrf.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h 166dsa_vrf.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
171dsa_vrf.o: ../../include/openssl/engine.h ../../include/openssl/err.h 167dsa_vrf.o: ../../include/openssl/err.h ../../include/openssl/lhash.h
172dsa_vrf.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h 168dsa_vrf.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
173dsa_vrf.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h 169dsa_vrf.o: ../../include/openssl/ossl_typ.h ../../include/openssl/rand.h
174dsa_vrf.o: ../../include/openssl/rand.h ../../include/openssl/rsa.h
175dsa_vrf.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h 170dsa_vrf.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
176dsa_vrf.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h 171dsa_vrf.o: ../../include/openssl/symhacks.h ../cryptlib.h dsa_vrf.c
177dsa_vrf.o: ../cryptlib.h dsa_vrf.c
diff --git a/src/lib/libcrypto/dsa/dsa_lib.c b/src/lib/libcrypto/dsa/dsa_lib.c
index da2cdfa3d6..4171af24c6 100644
--- a/src/lib/libcrypto/dsa/dsa_lib.c
+++ b/src/lib/libcrypto/dsa/dsa_lib.c
@@ -63,7 +63,9 @@
63#include <openssl/bn.h> 63#include <openssl/bn.h>
64#include <openssl/dsa.h> 64#include <openssl/dsa.h>
65#include <openssl/asn1.h> 65#include <openssl/asn1.h>
66#ifndef OPENSSL_NO_ENGINE
66#include <openssl/engine.h> 67#include <openssl/engine.h>
68#endif
67 69
68const char *DSA_version="DSA" OPENSSL_VERSION_PTEXT; 70const char *DSA_version="DSA" OPENSSL_VERSION_PTEXT;
69 71
@@ -93,11 +95,13 @@ int DSA_set_method(DSA *dsa, const DSA_METHOD *meth)
93 const DSA_METHOD *mtmp; 95 const DSA_METHOD *mtmp;
94 mtmp = dsa->meth; 96 mtmp = dsa->meth;
95 if (mtmp->finish) mtmp->finish(dsa); 97 if (mtmp->finish) mtmp->finish(dsa);
98#ifndef OPENSSL_NO_ENGINE
96 if (dsa->engine) 99 if (dsa->engine)
97 { 100 {
98 ENGINE_finish(dsa->engine); 101 ENGINE_finish(dsa->engine);
99 dsa->engine = NULL; 102 dsa->engine = NULL;
100 } 103 }
104#endif
101 dsa->meth = meth; 105 dsa->meth = meth;
102 if (meth->init) meth->init(dsa); 106 if (meth->init) meth->init(dsa);
103 return 1; 107 return 1;
@@ -114,6 +118,7 @@ DSA *DSA_new_method(ENGINE *engine)
114 return(NULL); 118 return(NULL);
115 } 119 }
116 ret->meth = DSA_get_default_method(); 120 ret->meth = DSA_get_default_method();
121#ifndef OPENSSL_NO_ENGINE
117 if (engine) 122 if (engine)
118 { 123 {
119 if (!ENGINE_init(engine)) 124 if (!ENGINE_init(engine))
@@ -138,6 +143,7 @@ DSA *DSA_new_method(ENGINE *engine)
138 return NULL; 143 return NULL;
139 } 144 }
140 } 145 }
146#endif
141 147
142 ret->pad=0; 148 ret->pad=0;
143 ret->version=0; 149 ret->version=0;
@@ -158,8 +164,10 @@ DSA *DSA_new_method(ENGINE *engine)
158 CRYPTO_new_ex_data(CRYPTO_EX_INDEX_DSA, ret, &ret->ex_data); 164 CRYPTO_new_ex_data(CRYPTO_EX_INDEX_DSA, ret, &ret->ex_data);
159 if ((ret->meth->init != NULL) && !ret->meth->init(ret)) 165 if ((ret->meth->init != NULL) && !ret->meth->init(ret))
160 { 166 {
167#ifndef OPENSSL_NO_ENGINE
161 if (ret->engine) 168 if (ret->engine)
162 ENGINE_finish(ret->engine); 169 ENGINE_finish(ret->engine);
170#endif
163 CRYPTO_free_ex_data(CRYPTO_EX_INDEX_DSA, ret, &ret->ex_data); 171 CRYPTO_free_ex_data(CRYPTO_EX_INDEX_DSA, ret, &ret->ex_data);
164 OPENSSL_free(ret); 172 OPENSSL_free(ret);
165 ret=NULL; 173 ret=NULL;
@@ -189,8 +197,10 @@ void DSA_free(DSA *r)
189 197
190 if(r->meth->finish) 198 if(r->meth->finish)
191 r->meth->finish(r); 199 r->meth->finish(r);
200#ifndef OPENSSL_NO_ENGINE
192 if(r->engine) 201 if(r->engine)
193 ENGINE_finish(r->engine); 202 ENGINE_finish(r->engine);
203#endif
194 204
195 CRYPTO_free_ex_data(CRYPTO_EX_INDEX_DSA, r, &r->ex_data); 205 CRYPTO_free_ex_data(CRYPTO_EX_INDEX_DSA, r, &r->ex_data);
196 206
@@ -224,7 +234,10 @@ int DSA_size(const DSA *r)
224 { 234 {
225 int ret,i; 235 int ret,i;
226 ASN1_INTEGER bs; 236 ASN1_INTEGER bs;
227 unsigned char buf[4]; 237 unsigned char buf[4]; /* 4 bytes looks really small.
238 However, i2d_ASN1_INTEGER() will not look
239 beyond the first byte, as long as the second
240 parameter is NULL. */
228 241
229 i=BN_num_bits(r->q); 242 i=BN_num_bits(r->q);
230 bs.length=(i+7)/8; 243 bs.length=(i+7)/8;
diff --git a/src/lib/libcrypto/dsa/dsa_ossl.c b/src/lib/libcrypto/dsa/dsa_ossl.c
index 37dd5fc994..b9e7f3ea5c 100644
--- a/src/lib/libcrypto/dsa/dsa_ossl.c
+++ b/src/lib/libcrypto/dsa/dsa_ossl.c
@@ -64,7 +64,6 @@
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#include <openssl/engine.h>
68 67
69static DSA_SIG *dsa_do_sign(const unsigned char *dgst, int dlen, DSA *dsa); 68static DSA_SIG *dsa_do_sign(const unsigned char *dgst, int dlen, DSA *dsa);
70static int dsa_sign_setup(DSA *dsa, BN_CTX *ctx_in, BIGNUM **kinvp, BIGNUM **rp); 69static int dsa_sign_setup(DSA *dsa, BN_CTX *ctx_in, BIGNUM **kinvp, BIGNUM **rp);
@@ -106,13 +105,15 @@ static DSA_SIG *dsa_do_sign(const unsigned char *dgst, int dlen, DSA *dsa)
106 int i,reason=ERR_R_BN_LIB; 105 int i,reason=ERR_R_BN_LIB;
107 DSA_SIG *ret=NULL; 106 DSA_SIG *ret=NULL;
108 107
108 BN_init(&m);
109 BN_init(&xr);
110
109 if (!dsa->p || !dsa->q || !dsa->g) 111 if (!dsa->p || !dsa->q || !dsa->g)
110 { 112 {
111 reason=DSA_R_MISSING_PARAMETERS; 113 reason=DSA_R_MISSING_PARAMETERS;
112 goto err; 114 goto err;
113 } 115 }
114 BN_init(&m); 116
115 BN_init(&xr);
116 s=BN_new(); 117 s=BN_new();
117 if (s == NULL) goto err; 118 if (s == NULL) goto err;
118 119
@@ -178,6 +179,9 @@ static int dsa_sign_setup(DSA *dsa, BN_CTX *ctx_in, BIGNUM **kinvp, BIGNUM **rp)
178 DSAerr(DSA_F_DSA_SIGN_SETUP,DSA_R_MISSING_PARAMETERS); 179 DSAerr(DSA_F_DSA_SIGN_SETUP,DSA_R_MISSING_PARAMETERS);
179 return 0; 180 return 0;
180 } 181 }
182
183 BN_init(&k);
184
181 if (ctx_in == NULL) 185 if (ctx_in == NULL)
182 { 186 {
183 if ((ctx=BN_CTX_new()) == NULL) goto err; 187 if ((ctx=BN_CTX_new()) == NULL) goto err;
@@ -185,7 +189,6 @@ static int dsa_sign_setup(DSA *dsa, BN_CTX *ctx_in, BIGNUM **kinvp, BIGNUM **rp)
185 else 189 else
186 ctx=ctx_in; 190 ctx=ctx_in;
187 191
188 BN_init(&k);
189 if ((r=BN_new()) == NULL) goto err; 192 if ((r=BN_new()) == NULL) goto err;
190 kinv=NULL; 193 kinv=NULL;
191 194
@@ -241,11 +244,12 @@ static int dsa_do_verify(const unsigned char *dgst, int dgst_len, DSA_SIG *sig,
241 return -1; 244 return -1;
242 } 245 }
243 246
244 if ((ctx=BN_CTX_new()) == NULL) goto err;
245 BN_init(&u1); 247 BN_init(&u1);
246 BN_init(&u2); 248 BN_init(&u2);
247 BN_init(&t1); 249 BN_init(&t1);
248 250
251 if ((ctx=BN_CTX_new()) == NULL) goto err;
252
249 if (BN_is_zero(sig->r) || sig->r->neg || BN_ucmp(sig->r, dsa->q) >= 0) 253 if (BN_is_zero(sig->r) || sig->r->neg || BN_ucmp(sig->r, dsa->q) >= 0)
250 { 254 {
251 ret = 0; 255 ret = 0;
diff --git a/src/lib/libcrypto/dsa/dsa_sign.c b/src/lib/libcrypto/dsa/dsa_sign.c
index e9469ca62f..89205026f0 100644
--- a/src/lib/libcrypto/dsa/dsa_sign.c
+++ b/src/lib/libcrypto/dsa/dsa_sign.c
@@ -64,7 +64,6 @@
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#include <openssl/engine.h>
68 67
69DSA_SIG * DSA_do_sign(const unsigned char *dgst, int dlen, DSA *dsa) 68DSA_SIG * DSA_do_sign(const unsigned char *dgst, int dlen, DSA *dsa)
70 { 69 {
diff --git a/src/lib/libcrypto/dsa/dsa_vrf.c b/src/lib/libcrypto/dsa/dsa_vrf.c
index 066c6b5b28..c4aeddd056 100644
--- a/src/lib/libcrypto/dsa/dsa_vrf.c
+++ b/src/lib/libcrypto/dsa/dsa_vrf.c
@@ -65,7 +65,6 @@
65#include <openssl/rand.h> 65#include <openssl/rand.h>
66#include <openssl/asn1.h> 66#include <openssl/asn1.h>
67#include <openssl/asn1_mac.h> 67#include <openssl/asn1_mac.h>
68#include <openssl/engine.h>
69 68
70int DSA_do_verify(const unsigned char *dgst, int dgst_len, DSA_SIG *sig, 69int DSA_do_verify(const unsigned char *dgst, int dgst_len, DSA_SIG *sig,
71 DSA *dsa) 70 DSA *dsa)
diff --git a/src/lib/libcrypto/dsa/dsagen.c b/src/lib/libcrypto/dsa/dsagen.c
index a0b0976640..1b6a1cca0f 100644
--- a/src/lib/libcrypto/dsa/dsagen.c
+++ b/src/lib/libcrypto/dsa/dsagen.c
@@ -103,7 +103,7 @@ main()
103 bio_err=BIO_new_fp(stderr,BIO_NOCLOSE); 103 bio_err=BIO_new_fp(stderr,BIO_NOCLOSE);
104 104
105 memcpy(seed_buf,seed,20); 105 memcpy(seed_buf,seed,20);
106 dsa=DSA_generate_parameters(1024,seed,20,&counter,&h,cb); 106 dsa=DSA_generate_parameters(1024,seed,20,&counter,&h,cb,bio_err);
107 107
108 if (dsa == NULL) 108 if (dsa == NULL)
109 DSA_print(bio_err,dsa,0); 109 DSA_print(bio_err,dsa,0);
diff --git a/src/lib/libcrypto/dsa/dsatest.c b/src/lib/libcrypto/dsa/dsatest.c
index 12da64f9f4..4734ce4af8 100644
--- a/src/lib/libcrypto/dsa/dsatest.c
+++ b/src/lib/libcrypto/dsa/dsatest.c
@@ -61,14 +61,13 @@
61#include <string.h> 61#include <string.h>
62#include <sys/types.h> 62#include <sys/types.h>
63#include <sys/stat.h> 63#include <sys/stat.h>
64
65#include "../e_os.h"
66
64#include <openssl/crypto.h> 67#include <openssl/crypto.h>
65#include <openssl/rand.h> 68#include <openssl/rand.h>
66#include <openssl/bio.h> 69#include <openssl/bio.h>
67#include <openssl/err.h> 70#include <openssl/err.h>
68#include <openssl/engine.h>
69#ifdef OPENSSL_SYS_WINDOWS
70#include "../bio/bss_file.c"
71#endif
72 71
73#ifdef OPENSSL_NO_DSA 72#ifdef OPENSSL_NO_DSA
74int main(int argc, char *argv[]) 73int main(int argc, char *argv[])
@@ -212,10 +211,16 @@ end:
212 BIO_free(bio_err); 211 BIO_free(bio_err);
213 bio_err = NULL; 212 bio_err = NULL;
214 } 213 }
215 exit(!ret); 214 EXIT(!ret);
216 return(0); 215 return(0);
217 } 216 }
218 217
218static int cb_exit(int ec)
219 {
220 EXIT(ec);
221 return(0); /* To keep some compilers quiet */
222 }
223
219static void MS_CALLBACK dsa_cb(int p, int n, void *arg) 224static void MS_CALLBACK dsa_cb(int p, int n, void *arg)
220 { 225 {
221 char c='*'; 226 char c='*';
@@ -231,7 +236,7 @@ static void MS_CALLBACK dsa_cb(int p, int n, void *arg)
231 if (!ok && (p == 0) && (num > 1)) 236 if (!ok && (p == 0) && (num > 1))
232 { 237 {
233 BIO_printf((BIO *)arg,"error in dsatest\n"); 238 BIO_printf((BIO *)arg,"error in dsatest\n");
234 exit(1); 239 cb_exit(1);
235 } 240 }
236 } 241 }
237#endif 242#endif
diff --git a/src/lib/libcrypto/dso/Makefile.ssl b/src/lib/libcrypto/dso/Makefile.ssl
index 5a55125824..c0449d184e 100644
--- a/src/lib/libcrypto/dso/Makefile.ssl
+++ b/src/lib/libcrypto/dso/Makefile.ssl
@@ -70,7 +70,7 @@ lint:
70 lint -DLINT $(INCLUDES) $(SRC)>fluff 70 lint -DLINT $(INCLUDES) $(SRC)>fluff
71 71
72depend: 72depend:
73 $(MAKEDEPEND) $(CFLAG) $(INCLUDES) $(DEPFLAG) $(PROGS) $(LIBSRC) 73 $(MAKEDEPEND) -- $(CFLAG) $(INCLUDES) $(DEPFLAG) -- $(PROGS) $(LIBSRC)
74 74
75dclean: 75dclean:
76 $(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new 76 $(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
diff --git a/src/lib/libcrypto/dso/dso_dl.c b/src/lib/libcrypto/dso/dso_dl.c
index 195717e993..79d2cb4d8c 100644
--- a/src/lib/libcrypto/dso/dso_dl.c
+++ b/src/lib/libcrypto/dso/dso_dl.c
@@ -126,7 +126,7 @@ static int dl_load(DSO *dso)
126 DSOerr(DSO_F_DL_LOAD,DSO_R_NO_FILENAME); 126 DSOerr(DSO_F_DL_LOAD,DSO_R_NO_FILENAME);
127 goto err; 127 goto err;
128 } 128 }
129 ptr = shl_load(filename, BIND_IMMEDIATE|DYNAMIC_PATH, NULL); 129 ptr = shl_load(filename, BIND_IMMEDIATE|DYNAMIC_PATH, 0L);
130 if(ptr == NULL) 130 if(ptr == NULL)
131 { 131 {
132 DSOerr(DSO_F_DL_LOAD,DSO_R_LOAD_FAILED); 132 DSOerr(DSO_F_DL_LOAD,DSO_R_LOAD_FAILED);
diff --git a/src/lib/libcrypto/dso/dso_win32.c b/src/lib/libcrypto/dso/dso_win32.c
index af8586d754..6c30deb250 100644
--- a/src/lib/libcrypto/dso/dso_win32.c
+++ b/src/lib/libcrypto/dso/dso_win32.c
@@ -61,7 +61,7 @@
61#include "cryptlib.h" 61#include "cryptlib.h"
62#include <openssl/dso.h> 62#include <openssl/dso.h>
63 63
64#ifndef OPENSSL_SYS_WIN32 64#if !defined(OPENSSL_SYS_WIN32) || defined(OPENSSL_SYS_WINCE)
65DSO_METHOD *DSO_METHOD_win32(void) 65DSO_METHOD *DSO_METHOD_win32(void)
66 { 66 {
67 return NULL; 67 return NULL;
diff --git a/src/lib/libcrypto/ec/Makefile.ssl b/src/lib/libcrypto/ec/Makefile.ssl
index ed602b4a7f..a2805c47a2 100644
--- a/src/lib/libcrypto/ec/Makefile.ssl
+++ b/src/lib/libcrypto/ec/Makefile.ssl
@@ -71,7 +71,7 @@ lint:
71 lint -DLINT $(INCLUDES) $(SRC)>fluff 71 lint -DLINT $(INCLUDES) $(SRC)>fluff
72 72
73depend: 73depend:
74 $(MAKEDEPEND) $(CFLAG) $(INCLUDES) $(DEPFLAG) $(PROGS) $(LIBSRC) 74 $(MAKEDEPEND) -- $(CFLAG) $(INCLUDES) $(DEPFLAG) -- $(PROGS) $(LIBSRC)
75 75
76dclean: 76dclean:
77 $(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new 77 $(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
diff --git a/src/lib/libcrypto/ec/ec.h b/src/lib/libcrypto/ec/ec.h
index a52d4edf14..6d6a9b7127 100644
--- a/src/lib/libcrypto/ec/ec.h
+++ b/src/lib/libcrypto/ec/ec.h
@@ -195,7 +195,6 @@ void ERR_load_EC_strings(void);
195#define EC_F_EC_GROUP_GET0_GENERATOR 139 195#define EC_F_EC_GROUP_GET0_GENERATOR 139
196#define EC_F_EC_GROUP_GET_COFACTOR 140 196#define EC_F_EC_GROUP_GET_COFACTOR 140
197#define EC_F_EC_GROUP_GET_CURVE_GFP 130 197#define EC_F_EC_GROUP_GET_CURVE_GFP 130
198#define EC_F_EC_GROUP_GET_EXTRA_DATA 107
199#define EC_F_EC_GROUP_GET_ORDER 141 198#define EC_F_EC_GROUP_GET_ORDER 141
200#define EC_F_EC_GROUP_NEW 108 199#define EC_F_EC_GROUP_NEW 108
201#define EC_F_EC_GROUP_PRECOMPUTE_MULT 142 200#define EC_F_EC_GROUP_PRECOMPUTE_MULT 142
@@ -232,7 +231,6 @@ void ERR_load_EC_strings(void);
232#define EC_R_INVALID_FIELD 103 231#define EC_R_INVALID_FIELD 103
233#define EC_R_INVALID_FORM 104 232#define EC_R_INVALID_FORM 104
234#define EC_R_NOT_INITIALIZED 111 233#define EC_R_NOT_INITIALIZED 111
235#define EC_R_NO_SUCH_EXTRA_DATA 105
236#define EC_R_POINT_AT_INFINITY 106 234#define EC_R_POINT_AT_INFINITY 106
237#define EC_R_POINT_IS_NOT_ON_CURVE 107 235#define EC_R_POINT_IS_NOT_ON_CURVE 107
238#define EC_R_SLOT_FULL 108 236#define EC_R_SLOT_FULL 108
diff --git a/src/lib/libcrypto/ec/ec_err.c b/src/lib/libcrypto/ec/ec_err.c
index 394cdc021f..d37b6aba87 100644
--- a/src/lib/libcrypto/ec/ec_err.c
+++ b/src/lib/libcrypto/ec/ec_err.c
@@ -84,7 +84,6 @@ static ERR_STRING_DATA EC_str_functs[]=
84{ERR_PACK(0,EC_F_EC_GROUP_GET0_GENERATOR,0), "EC_GROUP_get0_generator"}, 84{ERR_PACK(0,EC_F_EC_GROUP_GET0_GENERATOR,0), "EC_GROUP_get0_generator"},
85{ERR_PACK(0,EC_F_EC_GROUP_GET_COFACTOR,0), "EC_GROUP_get_cofactor"}, 85{ERR_PACK(0,EC_F_EC_GROUP_GET_COFACTOR,0), "EC_GROUP_get_cofactor"},
86{ERR_PACK(0,EC_F_EC_GROUP_GET_CURVE_GFP,0), "EC_GROUP_get_curve_GFp"}, 86{ERR_PACK(0,EC_F_EC_GROUP_GET_CURVE_GFP,0), "EC_GROUP_get_curve_GFp"},
87{ERR_PACK(0,EC_F_EC_GROUP_GET_EXTRA_DATA,0), "EC_GROUP_get_extra_data"},
88{ERR_PACK(0,EC_F_EC_GROUP_GET_ORDER,0), "EC_GROUP_get_order"}, 87{ERR_PACK(0,EC_F_EC_GROUP_GET_ORDER,0), "EC_GROUP_get_order"},
89{ERR_PACK(0,EC_F_EC_GROUP_NEW,0), "EC_GROUP_new"}, 88{ERR_PACK(0,EC_F_EC_GROUP_NEW,0), "EC_GROUP_new"},
90{ERR_PACK(0,EC_F_EC_GROUP_PRECOMPUTE_MULT,0), "EC_GROUP_precompute_mult"}, 89{ERR_PACK(0,EC_F_EC_GROUP_PRECOMPUTE_MULT,0), "EC_GROUP_precompute_mult"},
@@ -124,7 +123,6 @@ static ERR_STRING_DATA EC_str_reasons[]=
124{EC_R_INVALID_FIELD ,"invalid field"}, 123{EC_R_INVALID_FIELD ,"invalid field"},
125{EC_R_INVALID_FORM ,"invalid form"}, 124{EC_R_INVALID_FORM ,"invalid form"},
126{EC_R_NOT_INITIALIZED ,"not initialized"}, 125{EC_R_NOT_INITIALIZED ,"not initialized"},
127{EC_R_NO_SUCH_EXTRA_DATA ,"no such extra data"},
128{EC_R_POINT_AT_INFINITY ,"point at infinity"}, 126{EC_R_POINT_AT_INFINITY ,"point at infinity"},
129{EC_R_POINT_IS_NOT_ON_CURVE ,"point is not on curve"}, 127{EC_R_POINT_IS_NOT_ON_CURVE ,"point is not on curve"},
130{EC_R_SLOT_FULL ,"slot full"}, 128{EC_R_SLOT_FULL ,"slot full"},
diff --git a/src/lib/libcrypto/ec/ec_lib.c b/src/lib/libcrypto/ec/ec_lib.c
index 0cf485de60..deb522060f 100644
--- a/src/lib/libcrypto/ec/ec_lib.c
+++ b/src/lib/libcrypto/ec/ec_lib.c
@@ -128,7 +128,7 @@ void EC_GROUP_clear_free(EC_GROUP *group)
128 128
129 EC_GROUP_clear_free_extra_data(group); 129 EC_GROUP_clear_free_extra_data(group);
130 130
131 memset(group, 0, sizeof *group); 131 OPENSSL_cleanse(group, sizeof *group);
132 OPENSSL_free(group); 132 OPENSSL_free(group);
133 } 133 }
134 134
@@ -268,7 +268,9 @@ void *EC_GROUP_get_extra_data(const EC_GROUP *group, void *(*extra_data_dup_func
268 || (group->extra_data_free_func != extra_data_free_func) 268 || (group->extra_data_free_func != extra_data_free_func)
269 || (group->extra_data_clear_free_func != extra_data_clear_free_func)) 269 || (group->extra_data_clear_free_func != extra_data_clear_free_func))
270 { 270 {
271 ECerr(EC_F_EC_GROUP_GET_EXTRA_DATA, EC_R_NO_SUCH_EXTRA_DATA); 271#if 0 /* this was an error in 0.9.7, but that does not make a lot of sense */
272 ECerr(..._F_EC_GROUP_GET_EXTRA_DATA, ..._R_NO_SUCH_EXTRA_DATA);
273#endif
272 return NULL; 274 return NULL;
273 } 275 }
274 276
@@ -357,7 +359,7 @@ void EC_POINT_clear_free(EC_POINT *point)
357 point->meth->point_clear_finish(point); 359 point->meth->point_clear_finish(point);
358 else if (point->meth != NULL && point->meth->point_finish != 0) 360 else if (point->meth != NULL && point->meth->point_finish != 0)
359 point->meth->point_finish(point); 361 point->meth->point_finish(point);
360 memset(point, 0, sizeof *point); 362 OPENSSL_cleanse(point, sizeof *point);
361 OPENSSL_free(point); 363 OPENSSL_free(point);
362 } 364 }
363 365
diff --git a/src/lib/libcrypto/ec/ec_mult.c b/src/lib/libcrypto/ec/ec_mult.c
index 603ba31b81..4dbc931120 100644
--- a/src/lib/libcrypto/ec/ec_mult.c
+++ b/src/lib/libcrypto/ec/ec_mult.c
@@ -209,6 +209,17 @@ int EC_POINTs_mul(const EC_GROUP *group, EC_POINT *r, const BIGNUM *scalar,
209 EC_POINT ***val_sub = NULL; /* pointers to sub-arrays of 'val' */ 209 EC_POINT ***val_sub = NULL; /* pointers to sub-arrays of 'val' */
210 int ret = 0; 210 int ret = 0;
211 211
212 if (group->meth != r->meth)
213 {
214 ECerr(EC_F_EC_POINTS_MUL, EC_R_INCOMPATIBLE_OBJECTS);
215 return 0;
216 }
217
218 if ((scalar == NULL) && (num == 0))
219 {
220 return EC_POINT_set_to_infinity(group, r);
221 }
222
212 if (scalar != NULL) 223 if (scalar != NULL)
213 { 224 {
214 generator = EC_GROUP_get0_generator(group); 225 generator = EC_GROUP_get0_generator(group);
diff --git a/src/lib/libcrypto/ec/ectest.c b/src/lib/libcrypto/ec/ectest.c
index eab46cc080..345d3e4289 100644
--- a/src/lib/libcrypto/ec/ectest.c
+++ b/src/lib/libcrypto/ec/ectest.c
@@ -55,6 +55,11 @@
55 55
56#include <stdio.h> 56#include <stdio.h>
57#include <stdlib.h> 57#include <stdlib.h>
58#ifdef FLAT_INC
59#include "e_os.h"
60#else
61#include "../e_os.h"
62#endif
58#include <string.h> 63#include <string.h>
59#include <time.h> 64#include <time.h>
60 65
@@ -65,14 +70,16 @@ int main(int argc, char * argv[]) { puts("Elliptic curves are disabled."); retur
65 70
66 71
67#include <openssl/ec.h> 72#include <openssl/ec.h>
73#ifndef OPENSSL_NO_ENGINE
68#include <openssl/engine.h> 74#include <openssl/engine.h>
75#endif
69#include <openssl/err.h> 76#include <openssl/err.h>
70 77
71#define ABORT do { \ 78#define ABORT do { \
72 fflush(stdout); \ 79 fflush(stdout); \
73 fprintf(stderr, "%s:%d: ABORT\n", __FILE__, __LINE__); \ 80 fprintf(stderr, "%s:%d: ABORT\n", __FILE__, __LINE__); \
74 ERR_print_errors_fp(stderr); \ 81 ERR_print_errors_fp(stderr); \
75 exit(1); \ 82 EXIT(1); \
76} while (0) 83} while (0)
77 84
78#if 0 85#if 0
@@ -623,7 +630,9 @@ int main(int argc, char *argv[])
623 if (P_384) EC_GROUP_free(P_384); 630 if (P_384) EC_GROUP_free(P_384);
624 if (P_521) EC_GROUP_free(P_521); 631 if (P_521) EC_GROUP_free(P_521);
625 632
633#ifndef OPENSSL_NO_ENGINE
626 ENGINE_cleanup(); 634 ENGINE_cleanup();
635#endif
627 CRYPTO_cleanup_all_ex_data(); 636 CRYPTO_cleanup_all_ex_data();
628 ERR_free_strings(); 637 ERR_free_strings();
629 ERR_remove_state(0); 638 ERR_remove_state(0);
diff --git a/src/lib/libcrypto/engine/Makefile.ssl b/src/lib/libcrypto/engine/Makefile.ssl
index 8bc8985e02..30a4446ff9 100644
--- a/src/lib/libcrypto/engine/Makefile.ssl
+++ b/src/lib/libcrypto/engine/Makefile.ssl
@@ -50,7 +50,7 @@ all: lib
50 50
51lib: $(LIBOBJ) 51lib: $(LIBOBJ)
52 $(AR) $(LIB) $(LIBOBJ) 52 $(AR) $(LIB) $(LIBOBJ)
53 $(RANLIB) $(LIB) 53 $(RANLIB) $(LIB) || echo Never mind.
54 @touch lib 54 @touch lib
55 55
56files: 56files:
@@ -82,7 +82,7 @@ lint:
82 lint -DLINT $(INCLUDES) $(SRC)>fluff 82 lint -DLINT $(INCLUDES) $(SRC)>fluff
83 83
84depend: 84depend:
85 $(MAKEDEPEND) $(CFLAG) $(INCLUDES) $(DEPFLAG) $(PROGS) $(LIBSRC) 85 $(MAKEDEPEND) -- $(CFLAG) $(INCLUDES) $(DEPFLAG) -- $(PROGS) $(LIBSRC)
86 86
87dclean: 87dclean:
88 $(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new 88 $(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
@@ -304,6 +304,27 @@ hw_atalla.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
304hw_atalla.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h 304hw_atalla.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
305hw_atalla.o: ../cryptlib.h hw_atalla.c hw_atalla_err.c hw_atalla_err.h 305hw_atalla.o: ../cryptlib.h hw_atalla.c hw_atalla_err.c hw_atalla_err.h
306hw_atalla.o: vendor_defns/atalla.h 306hw_atalla.o: vendor_defns/atalla.h
307hw_cryptodev.o: ../../include/openssl/aes.h ../../include/openssl/asn1.h
308hw_cryptodev.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h
309hw_cryptodev.o: ../../include/openssl/bn.h ../../include/openssl/cast.h
310hw_cryptodev.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
311hw_cryptodev.o: ../../include/openssl/des_old.h ../../include/openssl/dh.h
312hw_cryptodev.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
313hw_cryptodev.o: ../../include/openssl/engine.h ../../include/openssl/err.h
314hw_cryptodev.o: ../../include/openssl/evp.h ../../include/openssl/idea.h
315hw_cryptodev.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h
316hw_cryptodev.o: ../../include/openssl/md4.h ../../include/openssl/md5.h
317hw_cryptodev.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h
318hw_cryptodev.o: ../../include/openssl/objects.h
319hw_cryptodev.o: ../../include/openssl/opensslconf.h
320hw_cryptodev.o: ../../include/openssl/opensslv.h
321hw_cryptodev.o: ../../include/openssl/ossl_typ.h ../../include/openssl/rand.h
322hw_cryptodev.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h
323hw_cryptodev.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h
324hw_cryptodev.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
325hw_cryptodev.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
326hw_cryptodev.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
327hw_cryptodev.o: ../../include/openssl/ui_compat.h hw_cryptodev.c
307hw_cswift.o: ../../e_os.h ../../include/openssl/asn1.h 328hw_cswift.o: ../../e_os.h ../../include/openssl/asn1.h
308hw_cswift.o: ../../include/openssl/bio.h ../../include/openssl/bn.h 329hw_cswift.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
309hw_cswift.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 330hw_cswift.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
@@ -354,45 +375,6 @@ hw_nuron.o: ../../include/openssl/rand.h ../../include/openssl/rsa.h
354hw_nuron.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h 375hw_nuron.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
355hw_nuron.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h 376hw_nuron.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
356hw_nuron.o: ../cryptlib.h hw_nuron.c hw_nuron_err.c hw_nuron_err.h 377hw_nuron.o: ../cryptlib.h hw_nuron.c hw_nuron_err.c hw_nuron_err.h
357hw_cryptodev.o: ../../include/openssl/aes.h
358hw_cryptodev.o: ../../include/openssl/asn1.h
359hw_cryptodev.o: ../../include/openssl/bio.h
360hw_cryptodev.o: ../../include/openssl/blowfish.h
361hw_cryptodev.o: ../../include/openssl/bn.h
362hw_cryptodev.o: ../../include/openssl/cast.h
363hw_cryptodev.o: ../../include/openssl/conf.h
364hw_cryptodev.o: ../../include/openssl/crypto.h
365hw_cryptodev.o: ../../include/openssl/des.h
366hw_cryptodev.o: ../../include/openssl/des_old.h
367hw_cryptodev.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
368hw_cryptodev.o: ../../include/openssl/e_os2.h
369hw_cryptodev.o: ../../include/openssl/engine.h
370hw_cryptodev.o: ../../include/openssl/err.h
371hw_cryptodev.o: ../../include/openssl/evp.h
372hw_cryptodev.o: ../../include/openssl/idea.h
373hw_cryptodev.o: ../../include/openssl/lhash.h
374hw_cryptodev.o: ../../include/openssl/md2.h
375hw_cryptodev.o: ../../include/openssl/md4.h
376hw_cryptodev.o: ../../include/openssl/md5.h
377hw_cryptodev.o: ../../include/openssl/mdc2.h
378hw_cryptodev.o: ../../include/openssl/obj_mac.h
379hw_cryptodev.o: ../../include/openssl/objects.h
380hw_cryptodev.o: ../../include/openssl/opensslconf.h
381hw_cryptodev.o: ../../include/openssl/opensslv.h
382hw_cryptodev.o: ../../include/openssl/ossl_typ.h
383hw_cryptodev.o: ../../include/openssl/rand.h
384hw_cryptodev.o: ../../include/openssl/rc2.h
385hw_cryptodev.o: ../../include/openssl/rc4.h
386hw_cryptodev.o: ../../include/openssl/rc5.h
387hw_cryptodev.o: ../../include/openssl/ripemd.h
388hw_cryptodev.o: ../../include/openssl/rsa.h
389hw_cryptodev.o: ../../include/openssl/safestack.h
390hw_cryptodev.o: ../../include/openssl/sha.h
391hw_cryptodev.o: ../../include/openssl/stack.h
392hw_cryptodev.o: ../../include/openssl/symhacks.h
393hw_cryptodev.o: ../../include/openssl/ui.h
394hw_cryptodev.o: ../../include/openssl/ui_compat.h ../evp/evp_locl.h
395hw_cryptodev.o: eng_int.h hw_cryptodev.c
396hw_sureware.o: ../../e_os.h ../../include/openssl/aes.h 378hw_sureware.o: ../../e_os.h ../../include/openssl/aes.h
397hw_sureware.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h 379hw_sureware.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
398hw_sureware.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h 380hw_sureware.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
diff --git a/src/lib/libcrypto/engine/eng_all.c b/src/lib/libcrypto/engine/eng_all.c
index bc50465422..0f6992a40d 100644
--- a/src/lib/libcrypto/engine/eng_all.c
+++ b/src/lib/libcrypto/engine/eng_all.c
@@ -60,10 +60,6 @@
60#include <openssl/engine.h> 60#include <openssl/engine.h>
61#include "eng_int.h" 61#include "eng_int.h"
62 62
63#ifdef __OpenBSD__
64static int openbsd_default_loaded = 0;
65#endif
66
67void ENGINE_load_builtin_engines(void) 63void ENGINE_load_builtin_engines(void)
68 { 64 {
69 /* There's no longer any need for an "openssl" ENGINE unless, one day, 65 /* There's no longer any need for an "openssl" ENGINE unless, one day,
@@ -99,21 +95,19 @@ void ENGINE_load_builtin_engines(void)
99#ifndef OPENSSL_NO_HW_4758_CCA 95#ifndef OPENSSL_NO_HW_4758_CCA
100 ENGINE_load_4758cca(); 96 ENGINE_load_4758cca();
101#endif 97#endif
102#ifdef OPENSSL_OPENBSD_DEV_CRYPTO 98#if defined(__OpenBSD__) || defined(__FreeBSD__)
103 ENGINE_load_openbsd_dev_crypto();
104#endif
105#ifdef __OpenBSD__
106 ENGINE_load_cryptodev(); 99 ENGINE_load_cryptodev();
107#endif 100#endif
108#endif 101#endif
109 } 102 }
110 103
111#ifdef __OpenBSD__ 104#if defined(__OpenBSD__) || defined(__FreeBSD__)
112void ENGINE_setup_openbsd(void) { 105void ENGINE_setup_bsd_cryptodev(void) {
113 if (!openbsd_default_loaded) { 106 static int bsd_cryptodev_default_loaded = 0;
107 if (!bsd_cryptodev_default_loaded) {
114 ENGINE_load_cryptodev(); 108 ENGINE_load_cryptodev();
115 ENGINE_register_all_complete(); 109 ENGINE_register_all_complete();
116 } 110 }
117 openbsd_default_loaded=1; 111 bsd_cryptodev_default_loaded=1;
118} 112}
119#endif 113#endif
diff --git a/src/lib/libcrypto/engine/eng_err.c b/src/lib/libcrypto/engine/eng_err.c
index f6c5630395..814d95ee32 100644
--- a/src/lib/libcrypto/engine/eng_err.c
+++ b/src/lib/libcrypto/engine/eng_err.c
@@ -1,6 +1,6 @@
1/* crypto/engine/eng_err.c */ 1/* crypto/engine/eng_err.c */
2/* ==================================================================== 2/* ====================================================================
3 * Copyright (c) 1999 The OpenSSL Project. All rights reserved. 3 * Copyright (c) 1999-2002 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
@@ -96,6 +96,7 @@ static ERR_STRING_DATA ENGINE_str_functs[]=
96{ERR_PACK(0,ENGINE_F_ENGINE_SET_NAME,0), "ENGINE_set_name"}, 96{ERR_PACK(0,ENGINE_F_ENGINE_SET_NAME,0), "ENGINE_set_name"},
97{ERR_PACK(0,ENGINE_F_ENGINE_TABLE_REGISTER,0), "ENGINE_TABLE_REGISTER"}, 97{ERR_PACK(0,ENGINE_F_ENGINE_TABLE_REGISTER,0), "ENGINE_TABLE_REGISTER"},
98{ERR_PACK(0,ENGINE_F_ENGINE_UNLOAD_KEY,0), "ENGINE_UNLOAD_KEY"}, 98{ERR_PACK(0,ENGINE_F_ENGINE_UNLOAD_KEY,0), "ENGINE_UNLOAD_KEY"},
99{ERR_PACK(0,ENGINE_F_ENGINE_UP_REF,0), "ENGINE_up_ref"},
99{ERR_PACK(0,ENGINE_F_INT_CTRL_HELPER,0), "INT_CTRL_HELPER"}, 100{ERR_PACK(0,ENGINE_F_INT_CTRL_HELPER,0), "INT_CTRL_HELPER"},
100{ERR_PACK(0,ENGINE_F_INT_ENGINE_CONFIGURE,0), "INT_ENGINE_CONFIGURE"}, 101{ERR_PACK(0,ENGINE_F_INT_ENGINE_CONFIGURE,0), "INT_ENGINE_CONFIGURE"},
101{ERR_PACK(0,ENGINE_F_LOG_MESSAGE,0), "LOG_MESSAGE"}, 102{ERR_PACK(0,ENGINE_F_LOG_MESSAGE,0), "LOG_MESSAGE"},
diff --git a/src/lib/libcrypto/engine/eng_fat.c b/src/lib/libcrypto/engine/eng_fat.c
index f7edb5ad32..0d7dae00b2 100644
--- a/src/lib/libcrypto/engine/eng_fat.c
+++ b/src/lib/libcrypto/engine/eng_fat.c
@@ -66,18 +66,18 @@ int ENGINE_set_default(ENGINE *e, unsigned int flags)
66 if((flags & ENGINE_METHOD_DIGESTS) && !ENGINE_set_default_digests(e)) 66 if((flags & ENGINE_METHOD_DIGESTS) && !ENGINE_set_default_digests(e))
67 return 0; 67 return 0;
68#ifndef OPENSSL_NO_RSA 68#ifndef OPENSSL_NO_RSA
69 if((flags & ENGINE_METHOD_RSA) & !ENGINE_set_default_RSA(e)) 69 if((flags & ENGINE_METHOD_RSA) && !ENGINE_set_default_RSA(e))
70 return 0; 70 return 0;
71#endif 71#endif
72#ifndef OPENSSL_NO_DSA 72#ifndef OPENSSL_NO_DSA
73 if((flags & ENGINE_METHOD_DSA) & !ENGINE_set_default_DSA(e)) 73 if((flags & ENGINE_METHOD_DSA) && !ENGINE_set_default_DSA(e))
74 return 0; 74 return 0;
75#endif 75#endif
76#ifndef OPENSSL_NO_DH 76#ifndef OPENSSL_NO_DH
77 if((flags & ENGINE_METHOD_DH) & !ENGINE_set_default_DH(e)) 77 if((flags & ENGINE_METHOD_DH) && !ENGINE_set_default_DH(e))
78 return 0; 78 return 0;
79#endif 79#endif
80 if((flags & ENGINE_METHOD_RAND) & !ENGINE_set_default_RAND(e)) 80 if((flags & ENGINE_METHOD_RAND) && !ENGINE_set_default_RAND(e))
81 return 0; 81 return 0;
82 return 1; 82 return 1;
83 } 83 }
diff --git a/src/lib/libcrypto/engine/eng_list.c b/src/lib/libcrypto/engine/eng_list.c
index 0c220558e7..1cc3217f4c 100644
--- a/src/lib/libcrypto/engine/eng_list.c
+++ b/src/lib/libcrypto/engine/eng_list.c
@@ -191,14 +191,14 @@ ENGINE *ENGINE_get_first(void)
191 { 191 {
192 ENGINE *ret; 192 ENGINE *ret;
193 193
194 CRYPTO_r_lock(CRYPTO_LOCK_ENGINE); 194 CRYPTO_w_lock(CRYPTO_LOCK_ENGINE);
195 ret = engine_list_head; 195 ret = engine_list_head;
196 if(ret) 196 if(ret)
197 { 197 {
198 ret->struct_ref++; 198 ret->struct_ref++;
199 engine_ref_debug(ret, 0, 1) 199 engine_ref_debug(ret, 0, 1)
200 } 200 }
201 CRYPTO_r_unlock(CRYPTO_LOCK_ENGINE); 201 CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE);
202 return ret; 202 return ret;
203 } 203 }
204 204
@@ -206,14 +206,14 @@ ENGINE *ENGINE_get_last(void)
206 { 206 {
207 ENGINE *ret; 207 ENGINE *ret;
208 208
209 CRYPTO_r_lock(CRYPTO_LOCK_ENGINE); 209 CRYPTO_w_lock(CRYPTO_LOCK_ENGINE);
210 ret = engine_list_tail; 210 ret = engine_list_tail;
211 if(ret) 211 if(ret)
212 { 212 {
213 ret->struct_ref++; 213 ret->struct_ref++;
214 engine_ref_debug(ret, 0, 1) 214 engine_ref_debug(ret, 0, 1)
215 } 215 }
216 CRYPTO_r_unlock(CRYPTO_LOCK_ENGINE); 216 CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE);
217 return ret; 217 return ret;
218 } 218 }
219 219
@@ -227,7 +227,7 @@ ENGINE *ENGINE_get_next(ENGINE *e)
227 ERR_R_PASSED_NULL_PARAMETER); 227 ERR_R_PASSED_NULL_PARAMETER);
228 return 0; 228 return 0;
229 } 229 }
230 CRYPTO_r_lock(CRYPTO_LOCK_ENGINE); 230 CRYPTO_w_lock(CRYPTO_LOCK_ENGINE);
231 ret = e->next; 231 ret = e->next;
232 if(ret) 232 if(ret)
233 { 233 {
@@ -235,7 +235,7 @@ ENGINE *ENGINE_get_next(ENGINE *e)
235 ret->struct_ref++; 235 ret->struct_ref++;
236 engine_ref_debug(ret, 0, 1) 236 engine_ref_debug(ret, 0, 1)
237 } 237 }
238 CRYPTO_r_unlock(CRYPTO_LOCK_ENGINE); 238 CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE);
239 /* Release the structural reference to the previous ENGINE */ 239 /* Release the structural reference to the previous ENGINE */
240 ENGINE_free(e); 240 ENGINE_free(e);
241 return ret; 241 return ret;
@@ -250,7 +250,7 @@ ENGINE *ENGINE_get_prev(ENGINE *e)
250 ERR_R_PASSED_NULL_PARAMETER); 250 ERR_R_PASSED_NULL_PARAMETER);
251 return 0; 251 return 0;
252 } 252 }
253 CRYPTO_r_lock(CRYPTO_LOCK_ENGINE); 253 CRYPTO_w_lock(CRYPTO_LOCK_ENGINE);
254 ret = e->prev; 254 ret = e->prev;
255 if(ret) 255 if(ret)
256 { 256 {
@@ -258,7 +258,7 @@ ENGINE *ENGINE_get_prev(ENGINE *e)
258 ret->struct_ref++; 258 ret->struct_ref++;
259 engine_ref_debug(ret, 0, 1) 259 engine_ref_debug(ret, 0, 1)
260 } 260 }
261 CRYPTO_r_unlock(CRYPTO_LOCK_ENGINE); 261 CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE);
262 /* Release the structural reference to the previous ENGINE */ 262 /* Release the structural reference to the previous ENGINE */
263 ENGINE_free(e); 263 ENGINE_free(e);
264 return ret; 264 return ret;
@@ -346,7 +346,7 @@ ENGINE *ENGINE_by_id(const char *id)
346 ERR_R_PASSED_NULL_PARAMETER); 346 ERR_R_PASSED_NULL_PARAMETER);
347 return NULL; 347 return NULL;
348 } 348 }
349 CRYPTO_r_lock(CRYPTO_LOCK_ENGINE); 349 CRYPTO_w_lock(CRYPTO_LOCK_ENGINE);
350 iterator = engine_list_head; 350 iterator = engine_list_head;
351 while(iterator && (strcmp(id, iterator->id) != 0)) 351 while(iterator && (strcmp(id, iterator->id) != 0))
352 iterator = iterator->next; 352 iterator = iterator->next;
@@ -372,7 +372,7 @@ ENGINE *ENGINE_by_id(const char *id)
372 engine_ref_debug(iterator, 0, 1) 372 engine_ref_debug(iterator, 0, 1)
373 } 373 }
374 } 374 }
375 CRYPTO_r_unlock(CRYPTO_LOCK_ENGINE); 375 CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE);
376 if(iterator == NULL) 376 if(iterator == NULL)
377 { 377 {
378 ENGINEerr(ENGINE_F_ENGINE_BY_ID, 378 ENGINEerr(ENGINE_F_ENGINE_BY_ID,
@@ -381,3 +381,14 @@ ENGINE *ENGINE_by_id(const char *id)
381 } 381 }
382 return iterator; 382 return iterator;
383 } 383 }
384
385int ENGINE_up_ref(ENGINE *e)
386 {
387 if (e == NULL)
388 {
389 ENGINEerr(ENGINE_F_ENGINE_UP_REF,ERR_R_PASSED_NULL_PARAMETER);
390 return 0;
391 }
392 CRYPTO_add(&e->struct_ref,1,CRYPTO_LOCK_ENGINE);
393 return 1;
394 }
diff --git a/src/lib/libcrypto/engine/eng_openssl.c b/src/lib/libcrypto/engine/eng_openssl.c
index e9d976f46b..54579eea2e 100644
--- a/src/lib/libcrypto/engine/eng_openssl.c
+++ b/src/lib/libcrypto/engine/eng_openssl.c
@@ -63,6 +63,7 @@
63#include <openssl/engine.h> 63#include <openssl/engine.h>
64#include <openssl/dso.h> 64#include <openssl/dso.h>
65#include <openssl/pem.h> 65#include <openssl/pem.h>
66#include <openssl/evp.h>
66 67
67/* This testing gunk is implemented (and explained) lower down. It also assumes 68/* This testing gunk is implemented (and explained) lower down. It also assumes
68 * the application explicitly calls "ENGINE_load_openssl()" because this is no 69 * the application explicitly calls "ENGINE_load_openssl()" because this is no
@@ -78,6 +79,21 @@
78/* #define TEST_ENG_OPENSSL_SHA_P_UPDATE */ 79/* #define TEST_ENG_OPENSSL_SHA_P_UPDATE */
79/* #define TEST_ENG_OPENSSL_SHA_P_FINAL */ 80/* #define TEST_ENG_OPENSSL_SHA_P_FINAL */
80 81
82/* Now check what of those algorithms are actually enabled */
83#ifdef OPENSSL_NO_RC4
84#undef TEST_ENG_OPENSSL_RC4
85#undef TEST_ENG_OPENSSL_RC4_OTHERS
86#undef TEST_ENG_OPENSSL_RC4_P_INIT
87#undef TEST_ENG_OPENSSL_RC4_P_CIPHER
88#endif
89#if defined(OPENSSL_NO_SHA) || defined(OPENSSL_NO_SHA0) || defined(OPENSSL_NO_SHA1)
90#undef TEST_ENG_OPENSSL_SHA
91#undef TEST_ENG_OPENSSL_SHA_OTHERS
92#undef TEST_ENG_OPENSSL_SHA_P_INIT
93#undef TEST_ENG_OPENSSL_SHA_P_UPDATE
94#undef TEST_ENG_OPENSSL_SHA_P_FINAL
95#endif
96
81#ifdef TEST_ENG_OPENSSL_RC4 97#ifdef TEST_ENG_OPENSSL_RC4
82static int openssl_ciphers(ENGINE *e, const EVP_CIPHER **cipher, 98static int openssl_ciphers(ENGINE *e, const EVP_CIPHER **cipher,
83 const int **nids, int nid); 99 const int **nids, int nid);
@@ -180,7 +196,6 @@ IMPLEMENT_DYNAMIC_BIND_FN(bind_fn)
180 * the "init_key" handler is called. 196 * the "init_key" handler is called.
181 * TEST_ENG_OPENSSL_RC4_P_CIPHER - ditto for the "cipher" handler. 197 * TEST_ENG_OPENSSL_RC4_P_CIPHER - ditto for the "cipher" handler.
182 */ 198 */
183#include <openssl/evp.h>
184#include <openssl/rc4.h> 199#include <openssl/rc4.h>
185#define TEST_RC4_KEY_SIZE 16 200#define TEST_RC4_KEY_SIZE 16
186static int test_cipher_nids[] = {NID_rc4,NID_rc4_40}; 201static int test_cipher_nids[] = {NID_rc4,NID_rc4_40};
@@ -265,7 +280,6 @@ static int openssl_ciphers(ENGINE *e, const EVP_CIPHER **cipher,
265 280
266#ifdef TEST_ENG_OPENSSL_SHA 281#ifdef TEST_ENG_OPENSSL_SHA
267/* Much the same sort of comment as for TEST_ENG_OPENSSL_RC4 */ 282/* Much the same sort of comment as for TEST_ENG_OPENSSL_RC4 */
268#include <openssl/evp.h>
269#include <openssl/sha.h> 283#include <openssl/sha.h>
270static int test_digest_nids[] = {NID_sha1}; 284static int test_digest_nids[] = {NID_sha1};
271static int test_digest_nids_number = 1; 285static int test_digest_nids_number = 1;
diff --git a/src/lib/libcrypto/engine/engine.h b/src/lib/libcrypto/engine/engine.h
index fd17ff616d..8686879e1a 100644
--- a/src/lib/libcrypto/engine/engine.h
+++ b/src/lib/libcrypto/engine/engine.h
@@ -59,6 +59,12 @@
59#ifndef HEADER_ENGINE_H 59#ifndef HEADER_ENGINE_H
60#define HEADER_ENGINE_H 60#define HEADER_ENGINE_H
61 61
62#include <openssl/opensslconf.h>
63
64#ifdef OPENSSL_NO_ENGINE
65#error ENGINE is disabled.
66#endif
67
62#include <openssl/ossl_typ.h> 68#include <openssl/ossl_typ.h>
63#include <openssl/bn.h> 69#include <openssl/bn.h>
64#ifndef OPENSSL_NO_RSA 70#ifndef OPENSSL_NO_RSA
@@ -307,11 +313,8 @@ void ENGINE_load_ubsec(void);
307void ENGINE_load_aep(void); 313void ENGINE_load_aep(void);
308void ENGINE_load_sureware(void); 314void ENGINE_load_sureware(void);
309void ENGINE_load_4758cca(void); 315void ENGINE_load_4758cca(void);
310void ENGINE_load_openbsd_dev_crypto(void);
311void ENGINE_load_builtin_engines(void);
312#ifdef __OpenBSD__
313void ENGINE_load_cryptodev(void); 316void ENGINE_load_cryptodev(void);
314#endif 317void ENGINE_load_builtin_engines(void);
315 318
316/* Get and set global flags (ENGINE_TABLE_FLAG_***) for the implementation 319/* Get and set global flags (ENGINE_TABLE_FLAG_***) for the implementation
317 * "registry" handling. */ 320 * "registry" handling. */
@@ -409,6 +412,7 @@ int ENGINE_ctrl_cmd_string(ENGINE *e, const char *cmd_name, const char *arg,
409 * compatibility! */ 412 * compatibility! */
410ENGINE *ENGINE_new(void); 413ENGINE *ENGINE_new(void);
411int ENGINE_free(ENGINE *e); 414int ENGINE_free(ENGINE *e);
415int ENGINE_up_ref(ENGINE *e);
412int ENGINE_set_id(ENGINE *e, const char *id); 416int ENGINE_set_id(ENGINE *e, const char *id);
413int ENGINE_set_name(ENGINE *e, const char *name); 417int ENGINE_set_name(ENGINE *e, const char *name);
414int ENGINE_set_RSA(ENGINE *e, const RSA_METHOD *rsa_meth); 418int ENGINE_set_RSA(ENGINE *e, const RSA_METHOD *rsa_meth);
@@ -665,6 +669,7 @@ void ERR_load_ENGINE_strings(void);
665#define ENGINE_F_ENGINE_SET_NAME 130 669#define ENGINE_F_ENGINE_SET_NAME 130
666#define ENGINE_F_ENGINE_TABLE_REGISTER 184 670#define ENGINE_F_ENGINE_TABLE_REGISTER 184
667#define ENGINE_F_ENGINE_UNLOAD_KEY 152 671#define ENGINE_F_ENGINE_UNLOAD_KEY 152
672#define ENGINE_F_ENGINE_UP_REF 190
668#define ENGINE_F_INT_CTRL_HELPER 172 673#define ENGINE_F_INT_CTRL_HELPER 172
669#define ENGINE_F_INT_ENGINE_CONFIGURE 188 674#define ENGINE_F_INT_ENGINE_CONFIGURE 188
670#define ENGINE_F_LOG_MESSAGE 141 675#define ENGINE_F_LOG_MESSAGE 141
diff --git a/src/lib/libcrypto/engine/enginetest.c b/src/lib/libcrypto/engine/enginetest.c
index 87fa8c57b7..c2d0297392 100644
--- a/src/lib/libcrypto/engine/enginetest.c
+++ b/src/lib/libcrypto/engine/enginetest.c
@@ -56,9 +56,17 @@
56 * 56 *
57 */ 57 */
58 58
59#include <openssl/e_os2.h>
60#include <stdio.h> 59#include <stdio.h>
61#include <string.h> 60#include <string.h>
61
62#ifdef OPENSSL_NO_ENGINE
63int main(int argc, char *argv[])
64{
65 printf("No ENGINE support\n");
66 return(0);
67}
68#else
69#include <openssl/e_os2.h>
62#include <openssl/buffer.h> 70#include <openssl/buffer.h>
63#include <openssl/crypto.h> 71#include <openssl/crypto.h>
64#include <openssl/engine.h> 72#include <openssl/engine.h>
@@ -272,3 +280,4 @@ end:
272 CRYPTO_mem_leaks_fp(stderr); 280 CRYPTO_mem_leaks_fp(stderr);
273 return to_return; 281 return to_return;
274 } 282 }
283#endif
diff --git a/src/lib/libcrypto/engine/hw_4758_cca.c b/src/lib/libcrypto/engine/hw_4758_cca.c
index 6d41b9ed2a..4f5ae8a46d 100644
--- a/src/lib/libcrypto/engine/hw_4758_cca.c
+++ b/src/lib/libcrypto/engine/hw_4758_cca.c
@@ -223,6 +223,7 @@ static int bind_helper(ENGINE *e)
223 return 1; 223 return 1;
224 } 224 }
225 225
226#ifndef ENGINE_DYNAMIC_SUPPORT
226static ENGINE *engine_4758_cca(void) 227static ENGINE *engine_4758_cca(void)
227 { 228 {
228 ENGINE *ret = ENGINE_new(); 229 ENGINE *ret = ENGINE_new();
@@ -244,6 +245,7 @@ void ENGINE_load_4758cca(void)
244 ENGINE_free(e_4758); 245 ENGINE_free(e_4758);
245 ERR_clear_error(); 246 ERR_clear_error();
246 } 247 }
248#endif
247 249
248static int ibm_4758_cca_destroy(ENGINE *e) 250static int ibm_4758_cca_destroy(ENGINE *e)
249 { 251 {
@@ -715,7 +717,7 @@ static int cca_rsa_verify(int type, const unsigned char *m, unsigned int m_len,
715 717
716 if (type == NID_sha1 || type == NID_md5) 718 if (type == NID_sha1 || type == NID_md5)
717 { 719 {
718 memset(hashBuffer, 0, keyLength+1); 720 OPENSSL_cleanse(hashBuffer, keyLength+1);
719 OPENSSL_free(hashBuffer); 721 OPENSSL_free(hashBuffer);
720 } 722 }
721 723
@@ -838,7 +840,7 @@ static int cca_rsa_sign(int type, const unsigned char *m, unsigned int m_len,
838 840
839 if (type == NID_sha1 || type == NID_md5) 841 if (type == NID_sha1 || type == NID_md5)
840 { 842 {
841 memset(hashBuffer, 0, keyLength+1); 843 OPENSSL_cleanse(hashBuffer, keyLength+1);
842 OPENSSL_free(hashBuffer); 844 OPENSSL_free(hashBuffer);
843 } 845 }
844 846
diff --git a/src/lib/libcrypto/engine/hw_atalla.c b/src/lib/libcrypto/engine/hw_atalla.c
index 6151c46902..e9eff9fad1 100644
--- a/src/lib/libcrypto/engine/hw_atalla.c
+++ b/src/lib/libcrypto/engine/hw_atalla.c
@@ -242,6 +242,7 @@ static int bind_helper(ENGINE *e)
242 return 1; 242 return 1;
243 } 243 }
244 244
245#ifndef ENGINE_DYNAMIC_SUPPORT
245static ENGINE *engine_atalla(void) 246static ENGINE *engine_atalla(void)
246 { 247 {
247 ENGINE *ret = ENGINE_new(); 248 ENGINE *ret = ENGINE_new();
@@ -264,6 +265,7 @@ void ENGINE_load_atalla(void)
264 ENGINE_free(toadd); 265 ENGINE_free(toadd);
265 ERR_clear_error(); 266 ERR_clear_error();
266 } 267 }
268#endif
267 269
268/* This is a process-global DSO handle used for loading and unloading 270/* This is a process-global DSO handle used for loading and unloading
269 * the Atalla library. NB: This is only set (or unset) during an 271 * the Atalla library. NB: This is only set (or unset) during an
diff --git a/src/lib/libcrypto/engine/hw_cryptodev.c b/src/lib/libcrypto/engine/hw_cryptodev.c
index 034c7ca213..139119b80c 100644
--- a/src/lib/libcrypto/engine/hw_cryptodev.c
+++ b/src/lib/libcrypto/engine/hw_cryptodev.c
@@ -29,8 +29,32 @@
29 * 29 *
30 */ 30 */
31 31
32#include <sys/types.h> 32#include <openssl/objects.h>
33#include <openssl/engine.h>
34#include <openssl/evp.h>
35
36#if (defined(__unix__) || defined(unix)) && !defined(USG)
33#include <sys/param.h> 37#include <sys/param.h>
38# if (OpenBSD >= 200112) || ((__FreeBSD_version >= 470101 && __FreeBSD_version < 500000) || __FreeBSD_version >= 500041)
39# define HAVE_CRYPTODEV
40# endif
41# if (OpenBSD >= 200110)
42# define HAVE_SYSLOG_R
43# endif
44#endif
45
46#ifndef HAVE_CRYPTODEV
47
48void
49ENGINE_load_cryptodev(void)
50{
51 /* This is a NOP on platforms without /dev/crypto */
52 return;
53}
54
55#else
56
57#include <sys/types.h>
34#include <crypto/cryptodev.h> 58#include <crypto/cryptodev.h>
35#include <sys/ioctl.h> 59#include <sys/ioctl.h>
36#include <errno.h> 60#include <errno.h>
@@ -39,9 +63,6 @@
39#include <fcntl.h> 63#include <fcntl.h>
40#include <stdarg.h> 64#include <stdarg.h>
41#include <syslog.h> 65#include <syslog.h>
42#include <ssl/objects.h>
43#include <ssl/engine.h>
44#include <ssl/evp.h>
45#include <errno.h> 66#include <errno.h>
46#include <string.h> 67#include <string.h>
47 68
@@ -101,10 +122,6 @@ static int cryptodev_ctrl(ENGINE *e, int cmd, long i, void *p,
101void ENGINE_load_cryptodev(void); 122void ENGINE_load_cryptodev(void);
102 123
103static const ENGINE_CMD_DEFN cryptodev_defns[] = { 124static const ENGINE_CMD_DEFN cryptodev_defns[] = {
104 {ENGINE_CMD_BASE,
105 "SO_PATH",
106 "Specifies the path to the some stupid shared library",
107 ENGINE_CMD_FLAG_STRING},
108 { 0, NULL, NULL, 0 } 125 { 0, NULL, NULL, 0 }
109}; 126};
110 127
@@ -1011,12 +1028,18 @@ static DH_METHOD cryptodev_dh = {
1011static int 1028static int
1012cryptodev_ctrl(ENGINE *e, int cmd, long i, void *p, void (*f)()) 1029cryptodev_ctrl(ENGINE *e, int cmd, long i, void *p, void (*f)())
1013{ 1030{
1031#ifdef HAVE_SYSLOG_R
1014 struct syslog_data sd = SYSLOG_DATA_INIT; 1032 struct syslog_data sd = SYSLOG_DATA_INIT;
1033#endif
1015 1034
1016 switch (cmd) { 1035 switch (cmd) {
1017 default: 1036 default:
1037#ifdef HAVE_SYSLOG_R
1018 syslog_r(LOG_ERR, &sd, 1038 syslog_r(LOG_ERR, &sd,
1019 "cryptodev_ctrl: unknown command %d", cmd); 1039 "cryptodev_ctrl: unknown command %d", cmd);
1040#else
1041 syslog(LOG_ERR, "cryptodev_ctrl: unknown command %d", cmd);
1042#endif
1020 break; 1043 break;
1021 } 1044 }
1022 return (1); 1045 return (1);
@@ -1043,7 +1066,7 @@ ENGINE_load_cryptodev(void)
1043 close(fd); 1066 close(fd);
1044 1067
1045 if (!ENGINE_set_id(engine, "cryptodev") || 1068 if (!ENGINE_set_id(engine, "cryptodev") ||
1046 !ENGINE_set_name(engine, "OpenBSD cryptodev engine") || 1069 !ENGINE_set_name(engine, "BSD cryptodev engine") ||
1047 !ENGINE_set_ciphers(engine, cryptodev_engine_ciphers) || 1070 !ENGINE_set_ciphers(engine, cryptodev_engine_ciphers) ||
1048 !ENGINE_set_digests(engine, cryptodev_engine_digests) || 1071 !ENGINE_set_digests(engine, cryptodev_engine_digests) ||
1049 !ENGINE_set_ctrl_function(engine, cryptodev_ctrl) || 1072 !ENGINE_set_ctrl_function(engine, cryptodev_ctrl) ||
@@ -1104,3 +1127,5 @@ ENGINE_load_cryptodev(void)
1104 ENGINE_free(engine); 1127 ENGINE_free(engine);
1105 ERR_clear_error(); 1128 ERR_clear_error();
1106} 1129}
1130
1131#endif /* HAVE_CRYPTODEV */
diff --git a/src/lib/libcrypto/engine/hw_cswift.c b/src/lib/libcrypto/engine/hw_cswift.c
index f5c897bdbb..f128ee5a68 100644
--- a/src/lib/libcrypto/engine/hw_cswift.c
+++ b/src/lib/libcrypto/engine/hw_cswift.c
@@ -121,6 +121,10 @@ static int cswift_mod_exp_dh(const DH *dh, BIGNUM *r,
121 const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx); 121 const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx);
122#endif 122#endif
123 123
124/* RAND stuff */
125static int cswift_rand_bytes(unsigned char *buf, int num);
126static int cswift_rand_status(void);
127
124/* The definitions for control commands specific to this engine */ 128/* The definitions for control commands specific to this engine */
125#define CSWIFT_CMD_SO_PATH ENGINE_CMD_BASE 129#define CSWIFT_CMD_SO_PATH ENGINE_CMD_BASE
126static const ENGINE_CMD_DEFN cswift_cmd_defns[] = { 130static const ENGINE_CMD_DEFN cswift_cmd_defns[] = {
@@ -183,6 +187,18 @@ static DH_METHOD cswift_dh =
183 }; 187 };
184#endif 188#endif
185 189
190static RAND_METHOD cswift_random =
191 {
192 /* "CryptoSwift RAND method", */
193 NULL,
194 cswift_rand_bytes,
195 NULL,
196 NULL,
197 cswift_rand_bytes,
198 cswift_rand_status,
199 };
200
201
186/* Constants used when creating the ENGINE */ 202/* Constants used when creating the ENGINE */
187static const char *engine_cswift_id = "cswift"; 203static const char *engine_cswift_id = "cswift";
188static const char *engine_cswift_name = "CryptoSwift hardware engine support"; 204static const char *engine_cswift_name = "CryptoSwift hardware engine support";
@@ -208,6 +224,7 @@ static int bind_helper(ENGINE *e)
208#ifndef OPENSSL_NO_DH 224#ifndef OPENSSL_NO_DH
209 !ENGINE_set_DH(e, &cswift_dh) || 225 !ENGINE_set_DH(e, &cswift_dh) ||
210#endif 226#endif
227 !ENGINE_set_RAND(e, &cswift_random) ||
211 !ENGINE_set_destroy_function(e, cswift_destroy) || 228 !ENGINE_set_destroy_function(e, cswift_destroy) ||
212 !ENGINE_set_init_function(e, cswift_init) || 229 !ENGINE_set_init_function(e, cswift_init) ||
213 !ENGINE_set_finish_function(e, cswift_finish) || 230 !ENGINE_set_finish_function(e, cswift_finish) ||
@@ -242,6 +259,7 @@ static int bind_helper(ENGINE *e)
242 return 1; 259 return 1;
243 } 260 }
244 261
262#ifndef ENGINE_DYNAMIC_SUPPORT
245static ENGINE *engine_cswift(void) 263static ENGINE *engine_cswift(void)
246 { 264 {
247 ENGINE *ret = ENGINE_new(); 265 ENGINE *ret = ENGINE_new();
@@ -264,6 +282,7 @@ void ENGINE_load_cswift(void)
264 ENGINE_free(toadd); 282 ENGINE_free(toadd);
265 ERR_clear_error(); 283 ERR_clear_error();
266 } 284 }
285#endif
267 286
268/* This is a process-global DSO handle used for loading and unloading 287/* This is a process-global DSO handle used for loading and unloading
269 * the CryptoSwift library. NB: This is only set (or unset) during an 288 * the CryptoSwift library. NB: This is only set (or unset) during an
@@ -905,6 +924,60 @@ static int cswift_mod_exp_dh(const DH *dh, BIGNUM *r,
905 } 924 }
906#endif 925#endif
907 926
927/* Random bytes are good */
928static int cswift_rand_bytes(unsigned char *buf, int num)
929{
930 SW_CONTEXT_HANDLE hac;
931 SW_STATUS swrc;
932 SW_LARGENUMBER largenum;
933 size_t nbytes = 0;
934 int acquired = 0;
935 int to_return = 0; /* assume failure */
936
937 if (!get_context(&hac))
938 {
939 CSWIFTerr(CSWIFT_F_CSWIFT_CTRL, CSWIFT_R_UNIT_FAILURE);
940 goto err;
941 }
942 acquired = 1;
943
944 while (nbytes < (size_t)num)
945 {
946 /* tell CryptoSwift how many bytes we want and where we want it.
947 * Note: - CryptoSwift cannot do more than 4096 bytes at a time.
948 * - CryptoSwift can only do multiple of 32-bits. */
949 largenum.value = (SW_BYTE *) buf + nbytes;
950 if (4096 > num - nbytes)
951 largenum.nbytes = num - nbytes;
952 else
953 largenum.nbytes = 4096;
954
955 swrc = p_CSwift_SimpleRequest(hac, SW_CMD_RAND, NULL, 0, &largenum, 1);
956 if (swrc != SW_OK)
957 {
958 char tmpbuf[20];
959 CSWIFTerr(CSWIFT_F_CSWIFT_CTRL, CSWIFT_R_REQUEST_FAILED);
960 sprintf(tmpbuf, "%ld", swrc);
961 ERR_add_error_data(2, "CryptoSwift error number is ", tmpbuf);
962 goto err;
963 }
964
965 nbytes += largenum.nbytes;
966 }
967 to_return = 1; /* success */
968
969err:
970 if (acquired)
971 release_context(hac);
972 return to_return;
973}
974
975static int cswift_rand_status(void)
976{
977 return 1;
978}
979
980
908/* This stuff is needed if this ENGINE is being compiled into a self-contained 981/* This stuff is needed if this ENGINE is being compiled into a self-contained
909 * shared-library. */ 982 * shared-library. */
910#ifdef ENGINE_DYNAMIC_SUPPORT 983#ifdef ENGINE_DYNAMIC_SUPPORT
diff --git a/src/lib/libcrypto/engine/hw_ncipher.c b/src/lib/libcrypto/engine/hw_ncipher.c
index a43d4360f2..0d1c6b8df0 100644
--- a/src/lib/libcrypto/engine/hw_ncipher.c
+++ b/src/lib/libcrypto/engine/hw_ncipher.c
@@ -91,11 +91,19 @@ static int hwcrhk_init(ENGINE *e);
91static int hwcrhk_finish(ENGINE *e); 91static int hwcrhk_finish(ENGINE *e);
92static int hwcrhk_ctrl(ENGINE *e, int cmd, long i, void *p, void (*f)()); 92static int hwcrhk_ctrl(ENGINE *e, int cmd, long i, void *p, void (*f)());
93 93
94/* Functions to handle mutexes */ 94/* Functions to handle mutexes if have dynamic locks */
95static int hwcrhk_mutex_init(HWCryptoHook_Mutex*, HWCryptoHook_CallerContext*); 95static int hwcrhk_mutex_init(HWCryptoHook_Mutex*, HWCryptoHook_CallerContext*);
96static int hwcrhk_mutex_lock(HWCryptoHook_Mutex*); 96static int hwcrhk_mutex_lock(HWCryptoHook_Mutex*);
97static void hwcrhk_mutex_unlock(HWCryptoHook_Mutex*); 97static void hwcrhk_mutex_unlock(HWCryptoHook_Mutex*);
98static void hwcrhk_mutex_destroy(HWCryptoHook_Mutex*); 98static void hwcrhk_mutex_destroy(HWCryptoHook_Mutex*);
99#if 1 /* This is a HACK which will disappear in 0.9.8 */
100/* Functions to handle mutexes if only have static locks */
101static int hwcrhk_static_mutex_init(HWCryptoHook_Mutex *m,
102 HWCryptoHook_CallerContext *c);
103static int hwcrhk_static_mutex_lock(HWCryptoHook_Mutex *m);
104static void hwcrhk_static_mutex_unlock(HWCryptoHook_Mutex *m);
105static void hwcrhk_static_mutex_destroy(HWCryptoHook_Mutex *m);
106#endif
99 107
100/* BIGNUM stuff */ 108/* BIGNUM stuff */
101static int hwcrhk_mod_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, 109static int hwcrhk_mod_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
@@ -373,6 +381,7 @@ static int bind_helper(ENGINE *e)
373 return 1; 381 return 1;
374 } 382 }
375 383
384#ifndef ENGINE_DYNAMIC_SUPPORT
376static ENGINE *engine_ncipher(void) 385static ENGINE *engine_ncipher(void)
377 { 386 {
378 ENGINE *ret = ENGINE_new(); 387 ENGINE *ret = ENGINE_new();
@@ -395,6 +404,7 @@ void ENGINE_load_chil(void)
395 ENGINE_free(toadd); 404 ENGINE_free(toadd);
396 ERR_clear_error(); 405 ERR_clear_error();
397 } 406 }
407#endif
398 408
399/* This is a process-global DSO handle used for loading and unloading 409/* This is a process-global DSO handle used for loading and unloading
400 * the HWCryptoHook library. NB: This is only set (or unset) during an 410 * the HWCryptoHook library. NB: This is only set (or unset) during an
@@ -558,15 +568,31 @@ static int hwcrhk_init(ENGINE *e)
558 568
559 /* Check if the application decided to support dynamic locks, 569 /* Check if the application decided to support dynamic locks,
560 and if it does, use them. */ 570 and if it does, use them. */
561 if (disable_mutex_callbacks == 0 && 571 if (disable_mutex_callbacks == 0)
562 CRYPTO_get_dynlock_create_callback() != NULL &&
563 CRYPTO_get_dynlock_lock_callback() != NULL &&
564 CRYPTO_get_dynlock_destroy_callback() != NULL)
565 { 572 {
566 hwcrhk_globals.mutex_init = hwcrhk_mutex_init; 573 if (CRYPTO_get_dynlock_create_callback() != NULL &&
567 hwcrhk_globals.mutex_acquire = hwcrhk_mutex_lock; 574 CRYPTO_get_dynlock_lock_callback() != NULL &&
568 hwcrhk_globals.mutex_release = hwcrhk_mutex_unlock; 575 CRYPTO_get_dynlock_destroy_callback() != NULL)
569 hwcrhk_globals.mutex_destroy = hwcrhk_mutex_destroy; 576 {
577 hwcrhk_globals.mutex_init = hwcrhk_mutex_init;
578 hwcrhk_globals.mutex_acquire = hwcrhk_mutex_lock;
579 hwcrhk_globals.mutex_release = hwcrhk_mutex_unlock;
580 hwcrhk_globals.mutex_destroy = hwcrhk_mutex_destroy;
581 }
582 else if (CRYPTO_get_locking_callback() != NULL)
583 {
584 HWCRHKerr(HWCRHK_F_HWCRHK_INIT,HWCRHK_R_DYNAMIC_LOCKING_MISSING);
585 ERR_add_error_data(1,"You HAVE to add dynamic locking callbacks via CRYPTO_set_dynlock_{create,lock,destroy}_callback()");
586#if 1 /* This is a HACK which will disappear in 0.9.8 */
587 hwcrhk_globals.maxmutexes = 1; /* Only have one lock */
588 hwcrhk_globals.mutex_init = hwcrhk_static_mutex_init;
589 hwcrhk_globals.mutex_acquire = hwcrhk_static_mutex_lock;
590 hwcrhk_globals.mutex_release = hwcrhk_static_mutex_unlock;
591 hwcrhk_globals.mutex_destroy = hwcrhk_static_mutex_destroy;
592#else
593 goto err;
594#endif
595 }
570 } 596 }
571 597
572 /* Try and get a context - if not, we may have a DSO but no 598 /* Try and get a context - if not, we may have a DSO but no
@@ -1020,7 +1046,7 @@ static int hwcrhk_rsa_mod_exp(BIGNUM *r, const BIGNUM *I, RSA *rsa)
1020 1046
1021 /* Perform the operation */ 1047 /* Perform the operation */
1022 ret = p_hwcrhk_ModExpCRT(hwcrhk_context, m_a, m_p, m_q, 1048 ret = p_hwcrhk_ModExpCRT(hwcrhk_context, m_a, m_p, m_q,
1023 m_dmp1, m_dmq1, m_iqmp, &m_r, NULL); 1049 m_dmp1, m_dmq1, m_iqmp, &m_r, &rmsg);
1024 1050
1025 /* Convert the response */ 1051 /* Convert the response */
1026 r->top = m_r.size / sizeof(BN_ULONG); 1052 r->top = m_r.size / sizeof(BN_ULONG);
@@ -1171,6 +1197,26 @@ static void hwcrhk_mutex_destroy(HWCryptoHook_Mutex *mt)
1171 CRYPTO_destroy_dynlockid(mt->lockid); 1197 CRYPTO_destroy_dynlockid(mt->lockid);
1172 } 1198 }
1173 1199
1200/* Mutex upcalls to use if the application does not support dynamic locks */
1201
1202static int hwcrhk_static_mutex_init(HWCryptoHook_Mutex *m,
1203 HWCryptoHook_CallerContext *c)
1204 {
1205 return 0;
1206 }
1207static int hwcrhk_static_mutex_lock(HWCryptoHook_Mutex *m)
1208 {
1209 CRYPTO_w_lock(CRYPTO_LOCK_HWCRHK);
1210 return 0;
1211 }
1212static void hwcrhk_static_mutex_unlock(HWCryptoHook_Mutex *m)
1213 {
1214 CRYPTO_w_unlock(CRYPTO_LOCK_HWCRHK);
1215 }
1216static void hwcrhk_static_mutex_destroy(HWCryptoHook_Mutex *m)
1217 {
1218 }
1219
1174static int hwcrhk_get_pass(const char *prompt_info, 1220static int hwcrhk_get_pass(const char *prompt_info,
1175 int *len_io, char *buf, 1221 int *len_io, char *buf,
1176 HWCryptoHook_PassphraseContext *ppctx, 1222 HWCryptoHook_PassphraseContext *ppctx,
@@ -1318,7 +1364,7 @@ static void hwcrhk_log_message(void *logstr, const char *message)
1318 lstream=*(BIO **)logstr; 1364 lstream=*(BIO **)logstr;
1319 if (lstream) 1365 if (lstream)
1320 { 1366 {
1321 BIO_write(lstream, message, strlen(message)); 1367 BIO_printf(lstream, "%s\n", message);
1322 } 1368 }
1323 CRYPTO_w_unlock(CRYPTO_LOCK_BIO); 1369 CRYPTO_w_unlock(CRYPTO_LOCK_BIO);
1324 } 1370 }
diff --git a/src/lib/libcrypto/engine/hw_ncipher_err.c b/src/lib/libcrypto/engine/hw_ncipher_err.c
index 24024cfc6f..5bc94581b7 100644
--- a/src/lib/libcrypto/engine/hw_ncipher_err.c
+++ b/src/lib/libcrypto/engine/hw_ncipher_err.c
@@ -1,6 +1,6 @@
1/* hw_ncipher_err.c */ 1/* hw_ncipher_err.c */
2/* ==================================================================== 2/* ====================================================================
3 * Copyright (c) 1999 The OpenSSL Project. All rights reserved. 3 * Copyright (c) 1999-2002 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
@@ -86,6 +86,7 @@ static ERR_STRING_DATA HWCRHK_str_reasons[]=
86{HWCRHK_R_CHIL_ERROR ,"chil error"}, 86{HWCRHK_R_CHIL_ERROR ,"chil error"},
87{HWCRHK_R_CTRL_COMMAND_NOT_IMPLEMENTED ,"ctrl command not implemented"}, 87{HWCRHK_R_CTRL_COMMAND_NOT_IMPLEMENTED ,"ctrl command not implemented"},
88{HWCRHK_R_DSO_FAILURE ,"dso failure"}, 88{HWCRHK_R_DSO_FAILURE ,"dso failure"},
89{HWCRHK_R_DYNAMIC_LOCKING_MISSING ,"dynamic locking missing"},
89{HWCRHK_R_MISSING_KEY_COMPONENTS ,"missing key components"}, 90{HWCRHK_R_MISSING_KEY_COMPONENTS ,"missing key components"},
90{HWCRHK_R_NOT_INITIALISED ,"not initialised"}, 91{HWCRHK_R_NOT_INITIALISED ,"not initialised"},
91{HWCRHK_R_NOT_LOADED ,"not loaded"}, 92{HWCRHK_R_NOT_LOADED ,"not loaded"},
diff --git a/src/lib/libcrypto/engine/hw_ncipher_err.h b/src/lib/libcrypto/engine/hw_ncipher_err.h
index 4d65b1d470..d232d02319 100644
--- a/src/lib/libcrypto/engine/hw_ncipher_err.h
+++ b/src/lib/libcrypto/engine/hw_ncipher_err.h
@@ -84,6 +84,7 @@ static void ERR_HWCRHK_error(int function, int reason, char *file, int line);
84#define HWCRHK_R_CHIL_ERROR 102 84#define HWCRHK_R_CHIL_ERROR 102
85#define HWCRHK_R_CTRL_COMMAND_NOT_IMPLEMENTED 103 85#define HWCRHK_R_CTRL_COMMAND_NOT_IMPLEMENTED 103
86#define HWCRHK_R_DSO_FAILURE 104 86#define HWCRHK_R_DSO_FAILURE 104
87#define HWCRHK_R_DYNAMIC_LOCKING_MISSING 114
87#define HWCRHK_R_MISSING_KEY_COMPONENTS 105 88#define HWCRHK_R_MISSING_KEY_COMPONENTS 105
88#define HWCRHK_R_NOT_INITIALISED 106 89#define HWCRHK_R_NOT_INITIALISED 106
89#define HWCRHK_R_NOT_LOADED 107 90#define HWCRHK_R_NOT_LOADED 107
diff --git a/src/lib/libcrypto/engine/hw_nuron.c b/src/lib/libcrypto/engine/hw_nuron.c
index 130b6d8b40..fb9188bfe5 100644
--- a/src/lib/libcrypto/engine/hw_nuron.c
+++ b/src/lib/libcrypto/engine/hw_nuron.c
@@ -374,6 +374,7 @@ static int bind_helper(ENGINE *e)
374 return 1; 374 return 1;
375 } 375 }
376 376
377#ifndef ENGINE_DYNAMIC_SUPPORT
377static ENGINE *engine_nuron(void) 378static ENGINE *engine_nuron(void)
378 { 379 {
379 ENGINE *ret = ENGINE_new(); 380 ENGINE *ret = ENGINE_new();
@@ -396,6 +397,7 @@ void ENGINE_load_nuron(void)
396 ENGINE_free(toadd); 397 ENGINE_free(toadd);
397 ERR_clear_error(); 398 ERR_clear_error();
398 } 399 }
400#endif
399 401
400/* This stuff is needed if this ENGINE is being compiled into a self-contained 402/* This stuff is needed if this ENGINE is being compiled into a self-contained
401 * shared-library. */ 403 * shared-library. */
diff --git a/src/lib/libcrypto/engine/hw_ubsec.c b/src/lib/libcrypto/engine/hw_ubsec.c
index ed8401ec16..6286dd851c 100644
--- a/src/lib/libcrypto/engine/hw_ubsec.c
+++ b/src/lib/libcrypto/engine/hw_ubsec.c
@@ -242,6 +242,7 @@ static int bind_helper(ENGINE *e)
242 return 1; 242 return 1;
243 } 243 }
244 244
245#ifndef ENGINE_DYNAMIC_SUPPORT
245static ENGINE *engine_ubsec(void) 246static ENGINE *engine_ubsec(void)
246 { 247 {
247 ENGINE *ret = ENGINE_new(); 248 ENGINE *ret = ENGINE_new();
@@ -264,6 +265,7 @@ void ENGINE_load_ubsec(void)
264 ENGINE_free(toadd); 265 ENGINE_free(toadd);
265 ERR_clear_error(); 266 ERR_clear_error();
266 } 267 }
268#endif
267 269
268/* This is a process-global DSO handle used for loading and unloading 270/* This is a process-global DSO handle used for loading and unloading
269 * the UBSEC library. NB: This is only set (or unset) during an 271 * the UBSEC library. NB: This is only set (or unset) during an
diff --git a/src/lib/libcrypto/engine/tb_cipher.c b/src/lib/libcrypto/engine/tb_cipher.c
index c5a50fc910..50b3cec1fa 100644
--- a/src/lib/libcrypto/engine/tb_cipher.c
+++ b/src/lib/libcrypto/engine/tb_cipher.c
@@ -81,7 +81,7 @@ int ENGINE_register_ciphers(ENGINE *e)
81 int num_nids = e->ciphers(e, NULL, &nids, 0); 81 int num_nids = e->ciphers(e, NULL, &nids, 0);
82 if(num_nids > 0) 82 if(num_nids > 0)
83 return engine_table_register(&cipher_table, 83 return engine_table_register(&cipher_table,
84 &engine_unregister_all_ciphers, e, nids, 84 engine_unregister_all_ciphers, e, nids,
85 num_nids, 0); 85 num_nids, 0);
86 } 86 }
87 return 1; 87 return 1;
@@ -103,7 +103,7 @@ int ENGINE_set_default_ciphers(ENGINE *e)
103 int num_nids = e->ciphers(e, NULL, &nids, 0); 103 int num_nids = e->ciphers(e, NULL, &nids, 0);
104 if(num_nids > 0) 104 if(num_nids > 0)
105 return engine_table_register(&cipher_table, 105 return engine_table_register(&cipher_table,
106 &engine_unregister_all_ciphers, e, nids, 106 engine_unregister_all_ciphers, e, nids,
107 num_nids, 1); 107 num_nids, 1);
108 } 108 }
109 return 1; 109 return 1;
diff --git a/src/lib/libcrypto/engine/tb_dh.c b/src/lib/libcrypto/engine/tb_dh.c
index c9347235ea..e290e1702b 100644
--- a/src/lib/libcrypto/engine/tb_dh.c
+++ b/src/lib/libcrypto/engine/tb_dh.c
@@ -78,7 +78,7 @@ int ENGINE_register_DH(ENGINE *e)
78 { 78 {
79 if(e->dh_meth) 79 if(e->dh_meth)
80 return engine_table_register(&dh_table, 80 return engine_table_register(&dh_table,
81 &engine_unregister_all_DH, e, &dummy_nid, 1, 0); 81 engine_unregister_all_DH, e, &dummy_nid, 1, 0);
82 return 1; 82 return 1;
83 } 83 }
84 84
@@ -94,7 +94,7 @@ int ENGINE_set_default_DH(ENGINE *e)
94 { 94 {
95 if(e->dh_meth) 95 if(e->dh_meth)
96 return engine_table_register(&dh_table, 96 return engine_table_register(&dh_table,
97 &engine_unregister_all_DH, e, &dummy_nid, 1, 1); 97 engine_unregister_all_DH, e, &dummy_nid, 1, 1);
98 return 1; 98 return 1;
99 } 99 }
100 100
diff --git a/src/lib/libcrypto/engine/tb_digest.c b/src/lib/libcrypto/engine/tb_digest.c
index 2c4dd6f796..e82d2a17c9 100644
--- a/src/lib/libcrypto/engine/tb_digest.c
+++ b/src/lib/libcrypto/engine/tb_digest.c
@@ -81,7 +81,7 @@ int ENGINE_register_digests(ENGINE *e)
81 int num_nids = e->digests(e, NULL, &nids, 0); 81 int num_nids = e->digests(e, NULL, &nids, 0);
82 if(num_nids > 0) 82 if(num_nids > 0)
83 return engine_table_register(&digest_table, 83 return engine_table_register(&digest_table,
84 &engine_unregister_all_digests, e, nids, 84 engine_unregister_all_digests, e, nids,
85 num_nids, 0); 85 num_nids, 0);
86 } 86 }
87 return 1; 87 return 1;
@@ -103,7 +103,7 @@ int ENGINE_set_default_digests(ENGINE *e)
103 int num_nids = e->digests(e, NULL, &nids, 0); 103 int num_nids = e->digests(e, NULL, &nids, 0);
104 if(num_nids > 0) 104 if(num_nids > 0)
105 return engine_table_register(&digest_table, 105 return engine_table_register(&digest_table,
106 &engine_unregister_all_digests, e, nids, 106 engine_unregister_all_digests, e, nids,
107 num_nids, 1); 107 num_nids, 1);
108 } 108 }
109 return 1; 109 return 1;
diff --git a/src/lib/libcrypto/engine/tb_dsa.c b/src/lib/libcrypto/engine/tb_dsa.c
index e9209476b8..80170591f2 100644
--- a/src/lib/libcrypto/engine/tb_dsa.c
+++ b/src/lib/libcrypto/engine/tb_dsa.c
@@ -78,7 +78,7 @@ int ENGINE_register_DSA(ENGINE *e)
78 { 78 {
79 if(e->dsa_meth) 79 if(e->dsa_meth)
80 return engine_table_register(&dsa_table, 80 return engine_table_register(&dsa_table,
81 &engine_unregister_all_DSA, e, &dummy_nid, 1, 0); 81 engine_unregister_all_DSA, e, &dummy_nid, 1, 0);
82 return 1; 82 return 1;
83 } 83 }
84 84
@@ -94,7 +94,7 @@ int ENGINE_set_default_DSA(ENGINE *e)
94 { 94 {
95 if(e->dsa_meth) 95 if(e->dsa_meth)
96 return engine_table_register(&dsa_table, 96 return engine_table_register(&dsa_table,
97 &engine_unregister_all_DSA, e, &dummy_nid, 1, 0); 97 engine_unregister_all_DSA, e, &dummy_nid, 1, 0);
98 return 1; 98 return 1;
99 } 99 }
100 100
diff --git a/src/lib/libcrypto/engine/tb_rand.c b/src/lib/libcrypto/engine/tb_rand.c
index 0b1d031f1e..69b67111bc 100644
--- a/src/lib/libcrypto/engine/tb_rand.c
+++ b/src/lib/libcrypto/engine/tb_rand.c
@@ -78,7 +78,7 @@ int ENGINE_register_RAND(ENGINE *e)
78 { 78 {
79 if(e->rand_meth) 79 if(e->rand_meth)
80 return engine_table_register(&rand_table, 80 return engine_table_register(&rand_table,
81 &engine_unregister_all_RAND, e, &dummy_nid, 1, 0); 81 engine_unregister_all_RAND, e, &dummy_nid, 1, 0);
82 return 1; 82 return 1;
83 } 83 }
84 84
@@ -94,7 +94,7 @@ int ENGINE_set_default_RAND(ENGINE *e)
94 { 94 {
95 if(e->rand_meth) 95 if(e->rand_meth)
96 return engine_table_register(&rand_table, 96 return engine_table_register(&rand_table,
97 &engine_unregister_all_RAND, e, &dummy_nid, 1, 1); 97 engine_unregister_all_RAND, e, &dummy_nid, 1, 1);
98 return 1; 98 return 1;
99 } 99 }
100 100
diff --git a/src/lib/libcrypto/engine/tb_rsa.c b/src/lib/libcrypto/engine/tb_rsa.c
index f84fea3968..fee4867f52 100644
--- a/src/lib/libcrypto/engine/tb_rsa.c
+++ b/src/lib/libcrypto/engine/tb_rsa.c
@@ -78,7 +78,7 @@ int ENGINE_register_RSA(ENGINE *e)
78 { 78 {
79 if(e->rsa_meth) 79 if(e->rsa_meth)
80 return engine_table_register(&rsa_table, 80 return engine_table_register(&rsa_table,
81 &engine_unregister_all_RSA, e, &dummy_nid, 1, 0); 81 engine_unregister_all_RSA, e, &dummy_nid, 1, 0);
82 return 1; 82 return 1;
83 } 83 }
84 84
@@ -94,7 +94,7 @@ int ENGINE_set_default_RSA(ENGINE *e)
94 { 94 {
95 if(e->rsa_meth) 95 if(e->rsa_meth)
96 return engine_table_register(&rsa_table, 96 return engine_table_register(&rsa_table,
97 &engine_unregister_all_RSA, e, &dummy_nid, 1, 1); 97 engine_unregister_all_RSA, e, &dummy_nid, 1, 1);
98 return 1; 98 return 1;
99 } 99 }
100 100
diff --git a/src/lib/libcrypto/err/Makefile.ssl b/src/lib/libcrypto/err/Makefile.ssl
index f0c95e2ef2..b253061d07 100644
--- a/src/lib/libcrypto/err/Makefile.ssl
+++ b/src/lib/libcrypto/err/Makefile.ssl
@@ -68,7 +68,7 @@ lint:
68 lint -DLINT $(INCLUDES) $(SRC)>fluff 68 lint -DLINT $(INCLUDES) $(SRC)>fluff
69 69
70depend: 70depend:
71 $(MAKEDEPEND) $(CFLAG) $(INCLUDES) $(DEPFLAG) $(PROGS) $(LIBSRC) 71 $(MAKEDEPEND) -- $(CFLAG) $(INCLUDES) $(DEPFLAG) -- $(PROGS) $(LIBSRC)
72 72
73dclean: 73dclean:
74 $(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new 74 $(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
diff --git a/src/lib/libcrypto/err/err.c b/src/lib/libcrypto/err/err.c
index 9b532d1f4c..a4f4a260af 100644
--- a/src/lib/libcrypto/err/err.c
+++ b/src/lib/libcrypto/err/err.c
@@ -211,6 +211,7 @@ static ERR_STRING_DATA ERR_str_reasons[]=
211 211
212{0,NULL}, 212{0,NULL},
213 }; 213 };
214#endif
214 215
215 216
216/* Define the predeclared (but externally opaque) "ERR_FNS" type */ 217/* Define the predeclared (but externally opaque) "ERR_FNS" type */
@@ -491,6 +492,7 @@ static int int_err_get_next_lib(void)
491 } 492 }
492 493
493 494
495#ifndef OPENSSL_NO_ERR
494#define NUM_SYS_STR_REASONS 127 496#define NUM_SYS_STR_REASONS 127
495#define LEN_SYS_STR_REASON 32 497#define LEN_SYS_STR_REASON 32
496 498
diff --git a/src/lib/libcrypto/err/err_all.c b/src/lib/libcrypto/err/err_all.c
index 90029fd159..dc505d9d9d 100644
--- a/src/lib/libcrypto/err/err_all.c
+++ b/src/lib/libcrypto/err/err_all.c
@@ -82,7 +82,9 @@
82#include <openssl/pkcs12.h> 82#include <openssl/pkcs12.h>
83#include <openssl/rand.h> 83#include <openssl/rand.h>
84#include <openssl/dso.h> 84#include <openssl/dso.h>
85#ifndef OPENSSL_NO_ENGINE
85#include <openssl/engine.h> 86#include <openssl/engine.h>
87#endif
86#include <openssl/ocsp.h> 88#include <openssl/ocsp.h>
87#include <openssl/err.h> 89#include <openssl/err.h>
88 90
@@ -122,7 +124,9 @@ void ERR_load_crypto_strings(void)
122 ERR_load_PKCS12_strings(); 124 ERR_load_PKCS12_strings();
123 ERR_load_RAND_strings(); 125 ERR_load_RAND_strings();
124 ERR_load_DSO_strings(); 126 ERR_load_DSO_strings();
127#ifndef OPENSSL_NO_ENGINE
125 ERR_load_ENGINE_strings(); 128 ERR_load_ENGINE_strings();
129#endif
126 ERR_load_OCSP_strings(); 130 ERR_load_OCSP_strings();
127 ERR_load_UI_strings(); 131 ERR_load_UI_strings();
128#endif 132#endif
diff --git a/src/lib/libcrypto/err/err_prn.c b/src/lib/libcrypto/err/err_prn.c
index c156663f0e..81e34bd6ce 100644
--- a/src/lib/libcrypto/err/err_prn.c
+++ b/src/lib/libcrypto/err/err_prn.c
@@ -62,7 +62,6 @@
62#include "cryptlib.h" 62#include "cryptlib.h"
63#include <openssl/buffer.h> 63#include <openssl/buffer.h>
64#include <openssl/err.h> 64#include <openssl/err.h>
65#include <openssl/crypto.h>
66 65
67void ERR_print_errors_cb(int (*cb)(const char *str, size_t len, void *u), 66void ERR_print_errors_cb(int (*cb)(const char *str, size_t len, void *u),
68 void *u) 67 void *u)
diff --git a/src/lib/libcrypto/evp/Makefile.ssl b/src/lib/libcrypto/evp/Makefile.ssl
index 58843f61a9..b4172406ae 100644
--- a/src/lib/libcrypto/evp/Makefile.ssl
+++ b/src/lib/libcrypto/evp/Makefile.ssl
@@ -70,7 +70,7 @@ links:
70 @sh $(TOP)/util/point.sh Makefile.ssl Makefile 70 @sh $(TOP)/util/point.sh Makefile.ssl Makefile
71 @$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER) 71 @$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER)
72 @$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST) 72 @$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST)
73 @$(PERL) $(TOP)/util/mklink.pl ../../test $(TESTDATA) 73 cp $(TESTDATA) ../../test
74 @$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS) 74 @$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS)
75 75
76install: 76install:
@@ -89,7 +89,7 @@ lint:
89 lint -DLINT $(INCLUDES) $(SRC)>fluff 89 lint -DLINT $(INCLUDES) $(SRC)>fluff
90 90
91depend: 91depend:
92 $(MAKEDEPEND) $(CFLAG) $(INCLUDES) $(DEPFLAG) $(LIBSRC) 92 $(MAKEDEPEND) -- $(CFLAG) $(INCLUDES) $(DEPFLAG) -- $(LIBSRC)
93 93
94dclean: 94dclean:
95 $(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new 95 $(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
@@ -496,21 +496,19 @@ evp_acnf.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
496evp_acnf.o: ../../include/openssl/conf.h ../../include/openssl/crypto.h 496evp_acnf.o: ../../include/openssl/conf.h ../../include/openssl/crypto.h
497evp_acnf.o: ../../include/openssl/des.h ../../include/openssl/des_old.h 497evp_acnf.o: ../../include/openssl/des.h ../../include/openssl/des_old.h
498evp_acnf.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h 498evp_acnf.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
499evp_acnf.o: ../../include/openssl/e_os2.h ../../include/openssl/engine.h 499evp_acnf.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
500evp_acnf.o: ../../include/openssl/err.h ../../include/openssl/evp.h 500evp_acnf.o: ../../include/openssl/evp.h ../../include/openssl/idea.h
501evp_acnf.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h 501evp_acnf.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h
502evp_acnf.o: ../../include/openssl/md2.h ../../include/openssl/md4.h 502evp_acnf.o: ../../include/openssl/md4.h ../../include/openssl/md5.h
503evp_acnf.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h 503evp_acnf.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h
504evp_acnf.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h 504evp_acnf.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
505evp_acnf.o: ../../include/openssl/opensslconf.h
506evp_acnf.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h 505evp_acnf.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
507evp_acnf.o: ../../include/openssl/rand.h ../../include/openssl/rc2.h 506evp_acnf.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h
508evp_acnf.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h 507evp_acnf.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h
509evp_acnf.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h 508evp_acnf.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
510evp_acnf.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h 509evp_acnf.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
511evp_acnf.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 510evp_acnf.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
512evp_acnf.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h 511evp_acnf.o: ../../include/openssl/ui_compat.h ../cryptlib.h evp_acnf.c
513evp_acnf.o: ../cryptlib.h evp_acnf.c
514evp_enc.o: ../../e_os.h ../../include/openssl/aes.h 512evp_enc.o: ../../e_os.h ../../include/openssl/aes.h
515evp_enc.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h 513evp_enc.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
516evp_enc.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h 514evp_enc.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
diff --git a/src/lib/libcrypto/evp/bio_b64.c b/src/lib/libcrypto/evp/bio_b64.c
index f12eac1b55..6e550f6a43 100644
--- a/src/lib/libcrypto/evp/bio_b64.c
+++ b/src/lib/libcrypto/evp/bio_b64.c
@@ -165,6 +165,7 @@ static int b64_read(BIO *b, char *out, int outl)
165 { 165 {
166 i=ctx->buf_len-ctx->buf_off; 166 i=ctx->buf_len-ctx->buf_off;
167 if (i > outl) i=outl; 167 if (i > outl) i=outl;
168 OPENSSL_assert(ctx->buf_off+i < sizeof ctx->buf);
168 memcpy(out,&(ctx->buf[ctx->buf_off]),i); 169 memcpy(out,&(ctx->buf[ctx->buf_off]),i);
169 ret=i; 170 ret=i;
170 out+=i; 171 out+=i;
diff --git a/src/lib/libcrypto/evp/bio_enc.c b/src/lib/libcrypto/evp/bio_enc.c
index 64fb2353af..ab81851503 100644
--- a/src/lib/libcrypto/evp/bio_enc.c
+++ b/src/lib/libcrypto/evp/bio_enc.c
@@ -132,7 +132,7 @@ static int enc_free(BIO *a)
132 if (a == NULL) return(0); 132 if (a == NULL) return(0);
133 b=(BIO_ENC_CTX *)a->ptr; 133 b=(BIO_ENC_CTX *)a->ptr;
134 EVP_CIPHER_CTX_cleanup(&(b->cipher)); 134 EVP_CIPHER_CTX_cleanup(&(b->cipher));
135 memset(a->ptr,0,sizeof(BIO_ENC_CTX)); 135 OPENSSL_cleanse(a->ptr,sizeof(BIO_ENC_CTX));
136 OPENSSL_free(a->ptr); 136 OPENSSL_free(a->ptr);
137 a->ptr=NULL; 137 a->ptr=NULL;
138 a->init=0; 138 a->init=0;
@@ -271,7 +271,7 @@ static int enc_write(BIO *b, const char *in, int inl)
271 if (i <= 0) 271 if (i <= 0)
272 { 272 {
273 BIO_copy_next_retry(b); 273 BIO_copy_next_retry(b);
274 return(i); 274 return (ret == inl) ? i : ret - inl;
275 } 275 }
276 n-=i; 276 n-=i;
277 ctx->buf_off+=i; 277 ctx->buf_off+=i;
@@ -325,10 +325,7 @@ again:
325 { 325 {
326 i=enc_write(b,NULL,0); 326 i=enc_write(b,NULL,0);
327 if (i < 0) 327 if (i < 0)
328 { 328 return i;
329 ret=i;
330 break;
331 }
332 } 329 }
333 330
334 if (!ctx->finished) 331 if (!ctx->finished)
diff --git a/src/lib/libcrypto/evp/bio_ok.c b/src/lib/libcrypto/evp/bio_ok.c
index d2be03be82..4e3f10141b 100644
--- a/src/lib/libcrypto/evp/bio_ok.c
+++ b/src/lib/libcrypto/evp/bio_ok.c
@@ -211,7 +211,7 @@ static int ok_free(BIO *a)
211 { 211 {
212 if (a == NULL) return(0); 212 if (a == NULL) return(0);
213 EVP_MD_CTX_cleanup(&((BIO_OK_CTX *)a->ptr)->md); 213 EVP_MD_CTX_cleanup(&((BIO_OK_CTX *)a->ptr)->md);
214 memset(a->ptr,0,sizeof(BIO_OK_CTX)); 214 OPENSSL_cleanse(a->ptr,sizeof(BIO_OK_CTX));
215 OPENSSL_free(a->ptr); 215 OPENSSL_free(a->ptr);
216 a->ptr=NULL; 216 a->ptr=NULL;
217 a->init=0; 217 a->init=0;
diff --git a/src/lib/libcrypto/evp/c_all.c b/src/lib/libcrypto/evp/c_all.c
index 3d59812e20..1b31a14e37 100644
--- a/src/lib/libcrypto/evp/c_all.c
+++ b/src/lib/libcrypto/evp/c_all.c
@@ -73,5 +73,9 @@ void OPENSSL_add_all_algorithms_noconf(void)
73 { 73 {
74 OpenSSL_add_all_ciphers(); 74 OpenSSL_add_all_ciphers();
75 OpenSSL_add_all_digests(); 75 OpenSSL_add_all_digests();
76 ENGINE_setup_openbsd(); 76#ifndef OPENSSL_NO_ENGINE
77# if defined(__OpenBSD__) || defined(__FreeBSD__)
78 ENGINE_setup_bsd_cryptodev();
79# endif
80#endif
77 } 81 }
diff --git a/src/lib/libcrypto/evp/digest.c b/src/lib/libcrypto/evp/digest.c
index a969ac69ed..b22eed4421 100644
--- a/src/lib/libcrypto/evp/digest.c
+++ b/src/lib/libcrypto/evp/digest.c
@@ -113,7 +113,9 @@
113#include "cryptlib.h" 113#include "cryptlib.h"
114#include <openssl/objects.h> 114#include <openssl/objects.h>
115#include <openssl/evp.h> 115#include <openssl/evp.h>
116#ifndef OPENSSL_NO_ENGINE
116#include <openssl/engine.h> 117#include <openssl/engine.h>
118#endif
117 119
118void EVP_MD_CTX_init(EVP_MD_CTX *ctx) 120void EVP_MD_CTX_init(EVP_MD_CTX *ctx)
119 { 121 {
@@ -138,6 +140,7 @@ int EVP_DigestInit(EVP_MD_CTX *ctx, const EVP_MD *type)
138int EVP_DigestInit_ex(EVP_MD_CTX *ctx, const EVP_MD *type, ENGINE *impl) 140int EVP_DigestInit_ex(EVP_MD_CTX *ctx, const EVP_MD *type, ENGINE *impl)
139 { 141 {
140 EVP_MD_CTX_clear_flags(ctx,EVP_MD_CTX_FLAG_CLEANED); 142 EVP_MD_CTX_clear_flags(ctx,EVP_MD_CTX_FLAG_CLEANED);
143#ifndef OPENSSL_NO_ENGINE
141 /* Whether it's nice or not, "Inits" can be used on "Final"'d contexts 144 /* Whether it's nice or not, "Inits" can be used on "Final"'d contexts
142 * so this context may already have an ENGINE! Try to avoid releasing 145 * so this context may already have an ENGINE! Try to avoid releasing
143 * the previous handle, re-querying for an ENGINE, and having a 146 * the previous handle, re-querying for an ENGINE, and having a
@@ -183,11 +186,13 @@ int EVP_DigestInit_ex(EVP_MD_CTX *ctx, const EVP_MD *type, ENGINE *impl)
183 else 186 else
184 ctx->engine = NULL; 187 ctx->engine = NULL;
185 } 188 }
186 else if(!ctx->digest) 189 else
190 if(!ctx->digest)
187 { 191 {
188 EVPerr(EVP_F_EVP_DIGESTINIT, EVP_R_NO_DIGEST_SET); 192 EVPerr(EVP_F_EVP_DIGESTINIT, EVP_R_NO_DIGEST_SET);
189 return 0; 193 return 0;
190 } 194 }
195#endif
191 if (ctx->digest != type) 196 if (ctx->digest != type)
192 { 197 {
193 if (ctx->digest && ctx->digest->ctx_size) 198 if (ctx->digest && ctx->digest->ctx_size)
@@ -196,7 +201,9 @@ int EVP_DigestInit_ex(EVP_MD_CTX *ctx, const EVP_MD *type, ENGINE *impl)
196 if (type->ctx_size) 201 if (type->ctx_size)
197 ctx->md_data=OPENSSL_malloc(type->ctx_size); 202 ctx->md_data=OPENSSL_malloc(type->ctx_size);
198 } 203 }
204#ifndef OPENSSL_NO_ENGINE
199skip_to_init: 205skip_to_init:
206#endif
200 return ctx->digest->init(ctx); 207 return ctx->digest->init(ctx);
201 } 208 }
202 209
@@ -219,6 +226,8 @@ int EVP_DigestFinal(EVP_MD_CTX *ctx, unsigned char *md, unsigned int *size)
219int EVP_DigestFinal_ex(EVP_MD_CTX *ctx, unsigned char *md, unsigned int *size) 226int EVP_DigestFinal_ex(EVP_MD_CTX *ctx, unsigned char *md, unsigned int *size)
220 { 227 {
221 int ret; 228 int ret;
229
230 OPENSSL_assert(ctx->digest->md_size <= EVP_MAX_MD_SIZE);
222 ret=ctx->digest->final(ctx,md); 231 ret=ctx->digest->final(ctx,md);
223 if (size != NULL) 232 if (size != NULL)
224 *size=ctx->digest->md_size; 233 *size=ctx->digest->md_size;
@@ -244,12 +253,14 @@ int EVP_MD_CTX_copy_ex(EVP_MD_CTX *out, const EVP_MD_CTX *in)
244 EVPerr(EVP_F_EVP_MD_CTX_COPY,EVP_R_INPUT_NOT_INITIALIZED); 253 EVPerr(EVP_F_EVP_MD_CTX_COPY,EVP_R_INPUT_NOT_INITIALIZED);
245 return 0; 254 return 0;
246 } 255 }
256#ifndef OPENSSL_NO_ENGINE
247 /* Make sure it's safe to copy a digest context using an ENGINE */ 257 /* Make sure it's safe to copy a digest context using an ENGINE */
248 if (in->engine && !ENGINE_init(in->engine)) 258 if (in->engine && !ENGINE_init(in->engine))
249 { 259 {
250 EVPerr(EVP_F_EVP_MD_CTX_COPY,ERR_R_ENGINE_LIB); 260 EVPerr(EVP_F_EVP_MD_CTX_COPY,ERR_R_ENGINE_LIB);
251 return 0; 261 return 0;
252 } 262 }
263#endif
253 264
254 EVP_MD_CTX_cleanup(out); 265 EVP_MD_CTX_cleanup(out);
255 memcpy(out,in,sizeof *out); 266 memcpy(out,in,sizeof *out);
@@ -299,13 +310,15 @@ int EVP_MD_CTX_cleanup(EVP_MD_CTX *ctx)
299 ctx->digest->cleanup(ctx); 310 ctx->digest->cleanup(ctx);
300 if (ctx->digest && ctx->digest->ctx_size && ctx->md_data) 311 if (ctx->digest && ctx->digest->ctx_size && ctx->md_data)
301 { 312 {
302 memset(ctx->md_data,0,ctx->digest->ctx_size); 313 OPENSSL_cleanse(ctx->md_data,ctx->digest->ctx_size);
303 OPENSSL_free(ctx->md_data); 314 OPENSSL_free(ctx->md_data);
304 } 315 }
316#ifndef OPENSSL_NO_ENGINE
305 if(ctx->engine) 317 if(ctx->engine)
306 /* The EVP_MD we used belongs to an ENGINE, release the 318 /* The EVP_MD we used belongs to an ENGINE, release the
307 * functional reference we held for this reason. */ 319 * functional reference we held for this reason. */
308 ENGINE_finish(ctx->engine); 320 ENGINE_finish(ctx->engine);
321#endif
309 memset(ctx,'\0',sizeof *ctx); 322 memset(ctx,'\0',sizeof *ctx);
310 323
311 return 1; 324 return 1;
diff --git a/src/lib/libcrypto/evp/e_aes.c b/src/lib/libcrypto/evp/e_aes.c
index c323fa2892..fe8bcda631 100644
--- a/src/lib/libcrypto/evp/e_aes.c
+++ b/src/lib/libcrypto/evp/e_aes.c
@@ -52,7 +52,6 @@
52#include <openssl/evp.h> 52#include <openssl/evp.h>
53#include <openssl/err.h> 53#include <openssl/err.h>
54#include <string.h> 54#include <string.h>
55#include <assert.h>
56#include <openssl/aes.h> 55#include <openssl/aes.h>
57#include "evp_locl.h" 56#include "evp_locl.h"
58 57
diff --git a/src/lib/libcrypto/evp/e_idea.c b/src/lib/libcrypto/evp/e_idea.c
index ed838d3e62..b9efa75ae7 100644
--- a/src/lib/libcrypto/evp/e_idea.c
+++ b/src/lib/libcrypto/evp/e_idea.c
@@ -109,7 +109,7 @@ static int idea_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key,
109 109
110 idea_set_encrypt_key(key,&tmp); 110 idea_set_encrypt_key(key,&tmp);
111 idea_set_decrypt_key(&tmp,ctx->cipher_data); 111 idea_set_decrypt_key(&tmp,ctx->cipher_data);
112 memset((unsigned char *)&tmp,0, 112 OPENSSL_cleanse((unsigned char *)&tmp,
113 sizeof(IDEA_KEY_SCHEDULE)); 113 sizeof(IDEA_KEY_SCHEDULE));
114 } 114 }
115 return 1; 115 return 1;
diff --git a/src/lib/libcrypto/evp/e_rc2.c b/src/lib/libcrypto/evp/e_rc2.c
index 4685198e2e..d42cbfd17e 100644
--- a/src/lib/libcrypto/evp/e_rc2.c
+++ b/src/lib/libcrypto/evp/e_rc2.c
@@ -174,6 +174,7 @@ static int rc2_get_asn1_type_and_iv(EVP_CIPHER_CTX *c, ASN1_TYPE *type)
174 if (type != NULL) 174 if (type != NULL)
175 { 175 {
176 l=EVP_CIPHER_CTX_iv_length(c); 176 l=EVP_CIPHER_CTX_iv_length(c);
177 OPENSSL_assert(l <= sizeof iv);
177 i=ASN1_TYPE_get_int_octetstring(type,&num,iv,l); 178 i=ASN1_TYPE_get_int_octetstring(type,&num,iv,l);
178 if (i != l) 179 if (i != l)
179 return(-1); 180 return(-1);
diff --git a/src/lib/libcrypto/evp/e_rc4.c b/src/lib/libcrypto/evp/e_rc4.c
index 4064cc5fa0..d58f507837 100644
--- a/src/lib/libcrypto/evp/e_rc4.c
+++ b/src/lib/libcrypto/evp/e_rc4.c
@@ -69,8 +69,6 @@
69 69
70typedef struct 70typedef struct
71 { 71 {
72 /* FIXME: what is the key for? */
73 unsigned char key[EVP_RC4_KEY_SIZE];
74 RC4_KEY ks; /* working key */ 72 RC4_KEY ks; /* working key */
75 } EVP_RC4_KEY; 73 } EVP_RC4_KEY;
76 74
@@ -121,9 +119,8 @@ const EVP_CIPHER *EVP_rc4_40(void)
121static int rc4_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key, 119static int rc4_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key,
122 const unsigned char *iv, int enc) 120 const unsigned char *iv, int enc)
123 { 121 {
124 memcpy(&data(ctx)->key[0],key,EVP_CIPHER_CTX_key_length(ctx));
125 RC4_set_key(&data(ctx)->ks,EVP_CIPHER_CTX_key_length(ctx), 122 RC4_set_key(&data(ctx)->ks,EVP_CIPHER_CTX_key_length(ctx),
126 data(ctx)->key); 123 key);
127 return 1; 124 return 1;
128 } 125 }
129 126
diff --git a/src/lib/libcrypto/evp/encode.c b/src/lib/libcrypto/evp/encode.c
index 12c6379df1..08209357ce 100644
--- a/src/lib/libcrypto/evp/encode.c
+++ b/src/lib/libcrypto/evp/encode.c
@@ -136,6 +136,7 @@ void EVP_EncodeUpdate(EVP_ENCODE_CTX *ctx, unsigned char *out, int *outl,
136 136
137 *outl=0; 137 *outl=0;
138 if (inl == 0) return; 138 if (inl == 0) return;
139 OPENSSL_assert(ctx->length <= sizeof ctx->enc_data);
139 if ((ctx->num+inl) < ctx->length) 140 if ((ctx->num+inl) < ctx->length)
140 { 141 {
141 memcpy(&(ctx->enc_data[ctx->num]),in,inl); 142 memcpy(&(ctx->enc_data[ctx->num]),in,inl);
@@ -258,6 +259,7 @@ int EVP_DecodeUpdate(EVP_ENCODE_CTX *ctx, unsigned char *out, int *outl,
258 /* only save the good data :-) */ 259 /* only save the good data :-) */
259 if (!B64_NOT_BASE64(v)) 260 if (!B64_NOT_BASE64(v))
260 { 261 {
262 OPENSSL_assert(n < sizeof ctx->enc_data);
261 d[n++]=tmp; 263 d[n++]=tmp;
262 ln++; 264 ln++;
263 } 265 }
diff --git a/src/lib/libcrypto/evp/evp_acnf.c b/src/lib/libcrypto/evp/evp_acnf.c
index a68b979bdb..ff3e311cc5 100644
--- a/src/lib/libcrypto/evp/evp_acnf.c
+++ b/src/lib/libcrypto/evp/evp_acnf.c
@@ -59,7 +59,6 @@
59#include "cryptlib.h" 59#include "cryptlib.h"
60#include <openssl/evp.h> 60#include <openssl/evp.h>
61#include <openssl/conf.h> 61#include <openssl/conf.h>
62#include <openssl/engine.h>
63 62
64 63
65/* Load all algorithms and configure OpenSSL. 64/* Load all algorithms and configure OpenSSL.
diff --git a/src/lib/libcrypto/evp/evp_enc.c b/src/lib/libcrypto/evp/evp_enc.c
index 32a1c7a2e9..be0758a879 100644
--- a/src/lib/libcrypto/evp/evp_enc.c
+++ b/src/lib/libcrypto/evp/evp_enc.c
@@ -60,11 +60,11 @@
60#include "cryptlib.h" 60#include "cryptlib.h"
61#include <openssl/evp.h> 61#include <openssl/evp.h>
62#include <openssl/err.h> 62#include <openssl/err.h>
63#ifndef OPENSSL_NO_ENGINE
63#include <openssl/engine.h> 64#include <openssl/engine.h>
65#endif
64#include "evp_locl.h" 66#include "evp_locl.h"
65 67
66#include <assert.h>
67
68const char *EVP_version="EVP" OPENSSL_VERSION_PTEXT; 68const char *EVP_version="EVP" OPENSSL_VERSION_PTEXT;
69 69
70void EVP_CIPHER_CTX_init(EVP_CIPHER_CTX *ctx) 70void EVP_CIPHER_CTX_init(EVP_CIPHER_CTX *ctx)
@@ -93,6 +93,7 @@ int EVP_CipherInit_ex(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher, ENGINE *imp
93 enc = 1; 93 enc = 1;
94 ctx->encrypt = enc; 94 ctx->encrypt = enc;
95 } 95 }
96#ifndef OPENSSL_NO_ENGINE
96 /* Whether it's nice or not, "Inits" can be used on "Final"'d contexts 97 /* Whether it's nice or not, "Inits" can be used on "Final"'d contexts
97 * so this context may already have an ENGINE! Try to avoid releasing 98 * so this context may already have an ENGINE! Try to avoid releasing
98 * the previous handle, re-querying for an ENGINE, and having a 99 * the previous handle, re-querying for an ENGINE, and having a
@@ -100,6 +101,7 @@ int EVP_CipherInit_ex(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher, ENGINE *imp
100 if (ctx->engine && ctx->cipher && (!cipher || 101 if (ctx->engine && ctx->cipher && (!cipher ||
101 (cipher && (cipher->nid == ctx->cipher->nid)))) 102 (cipher && (cipher->nid == ctx->cipher->nid))))
102 goto skip_to_init; 103 goto skip_to_init;
104#endif
103 if (cipher) 105 if (cipher)
104 { 106 {
105 /* Ensure a context left lying around from last time is cleared 107 /* Ensure a context left lying around from last time is cleared
@@ -109,6 +111,7 @@ int EVP_CipherInit_ex(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher, ENGINE *imp
109 111
110 /* Restore encrypt field: it is zeroed by cleanup */ 112 /* Restore encrypt field: it is zeroed by cleanup */
111 ctx->encrypt = enc; 113 ctx->encrypt = enc;
114#ifndef OPENSSL_NO_ENGINE
112 if(impl) 115 if(impl)
113 { 116 {
114 if (!ENGINE_init(impl)) 117 if (!ENGINE_init(impl))
@@ -142,6 +145,7 @@ int EVP_CipherInit_ex(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher, ENGINE *imp
142 } 145 }
143 else 146 else
144 ctx->engine = NULL; 147 ctx->engine = NULL;
148#endif
145 149
146 ctx->cipher=cipher; 150 ctx->cipher=cipher;
147 ctx->cipher_data=OPENSSL_malloc(ctx->cipher->ctx_size); 151 ctx->cipher_data=OPENSSL_malloc(ctx->cipher->ctx_size);
@@ -161,11 +165,13 @@ int EVP_CipherInit_ex(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher, ENGINE *imp
161 EVPerr(EVP_F_EVP_CIPHERINIT, EVP_R_NO_CIPHER_SET); 165 EVPerr(EVP_F_EVP_CIPHERINIT, EVP_R_NO_CIPHER_SET);
162 return 0; 166 return 0;
163 } 167 }
168#ifndef OPENSSL_NO_ENGINE
164skip_to_init: 169skip_to_init:
170#endif
165 /* we assume block size is a power of 2 in *cryptUpdate */ 171 /* we assume block size is a power of 2 in *cryptUpdate */
166 assert(ctx->cipher->block_size == 1 172 OPENSSL_assert(ctx->cipher->block_size == 1
167 || ctx->cipher->block_size == 8 173 || ctx->cipher->block_size == 8
168 || ctx->cipher->block_size == 16); 174 || ctx->cipher->block_size == 16);
169 175
170 if(!(EVP_CIPHER_CTX_flags(ctx) & EVP_CIPH_CUSTOM_IV)) { 176 if(!(EVP_CIPHER_CTX_flags(ctx) & EVP_CIPH_CUSTOM_IV)) {
171 switch(EVP_CIPHER_CTX_mode(ctx)) { 177 switch(EVP_CIPHER_CTX_mode(ctx)) {
@@ -181,6 +187,7 @@ skip_to_init:
181 187
182 case EVP_CIPH_CBC_MODE: 188 case EVP_CIPH_CBC_MODE:
183 189
190 OPENSSL_assert(EVP_CIPHER_CTX_iv_length(ctx) <= sizeof ctx->iv);
184 if(iv) memcpy(ctx->oiv, iv, EVP_CIPHER_CTX_iv_length(ctx)); 191 if(iv) memcpy(ctx->oiv, iv, EVP_CIPHER_CTX_iv_length(ctx));
185 memcpy(ctx->iv, ctx->oiv, EVP_CIPHER_CTX_iv_length(ctx)); 192 memcpy(ctx->iv, ctx->oiv, EVP_CIPHER_CTX_iv_length(ctx));
186 break; 193 break;
@@ -237,7 +244,7 @@ int EVP_EncryptInit_ex(EVP_CIPHER_CTX *ctx,const EVP_CIPHER *cipher, ENGINE *imp
237int EVP_DecryptInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher, 244int EVP_DecryptInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher,
238 const unsigned char *key, const unsigned char *iv) 245 const unsigned char *key, const unsigned char *iv)
239 { 246 {
240 return EVP_CipherInit_ex(ctx, cipher, NULL, key, iv, 0); 247 return EVP_CipherInit(ctx, cipher, key, iv, 0);
241 } 248 }
242 249
243int EVP_DecryptInit_ex(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher, ENGINE *impl, 250int EVP_DecryptInit_ex(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher, ENGINE *impl,
@@ -251,6 +258,7 @@ int EVP_EncryptUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl,
251 { 258 {
252 int i,j,bl; 259 int i,j,bl;
253 260
261 OPENSSL_assert(inl > 0);
254 if(ctx->buf_len == 0 && (inl&(ctx->block_mask)) == 0) 262 if(ctx->buf_len == 0 && (inl&(ctx->block_mask)) == 0)
255 { 263 {
256 if(ctx->cipher->do_cipher(ctx,out,in,inl)) 264 if(ctx->cipher->do_cipher(ctx,out,in,inl))
@@ -266,6 +274,7 @@ int EVP_EncryptUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl,
266 } 274 }
267 i=ctx->buf_len; 275 i=ctx->buf_len;
268 bl=ctx->cipher->block_size; 276 bl=ctx->cipher->block_size;
277 OPENSSL_assert(bl <= sizeof ctx->buf);
269 if (i != 0) 278 if (i != 0)
270 { 279 {
271 if (i+inl < bl) 280 if (i+inl < bl)
@@ -314,6 +323,7 @@ int EVP_EncryptFinal_ex(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl)
314 int i,n,b,bl,ret; 323 int i,n,b,bl,ret;
315 324
316 b=ctx->cipher->block_size; 325 b=ctx->cipher->block_size;
326 OPENSSL_assert(b <= sizeof ctx->buf);
317 if (b == 1) 327 if (b == 1)
318 { 328 {
319 *outl=0; 329 *outl=0;
@@ -358,6 +368,7 @@ int EVP_DecryptUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl,
358 return EVP_EncryptUpdate(ctx, out, outl, in, inl); 368 return EVP_EncryptUpdate(ctx, out, outl, in, inl);
359 369
360 b=ctx->cipher->block_size; 370 b=ctx->cipher->block_size;
371 OPENSSL_assert(b <= sizeof ctx->final);
361 372
362 if(ctx->final_used) 373 if(ctx->final_used)
363 { 374 {
@@ -420,6 +431,7 @@ int EVP_DecryptFinal_ex(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl)
420 EVPerr(EVP_F_EVP_DECRYPTFINAL,EVP_R_WRONG_FINAL_BLOCK_LENGTH); 431 EVPerr(EVP_F_EVP_DECRYPTFINAL,EVP_R_WRONG_FINAL_BLOCK_LENGTH);
421 return(0); 432 return(0);
422 } 433 }
434 OPENSSL_assert(b <= sizeof ctx->final);
423 n=ctx->final[b-1]; 435 n=ctx->final[b-1];
424 if (n > b) 436 if (n > b)
425 { 437 {
@@ -450,16 +462,18 @@ int EVP_CIPHER_CTX_cleanup(EVP_CIPHER_CTX *c)
450 { 462 {
451 if(c->cipher->cleanup && !c->cipher->cleanup(c)) 463 if(c->cipher->cleanup && !c->cipher->cleanup(c))
452 return 0; 464 return 0;
453 /* Zero cipher context data */ 465 /* Cleanse cipher context data */
454 if (c->cipher_data) 466 if (c->cipher_data)
455 memset(c->cipher_data, 0, c->cipher->ctx_size); 467 OPENSSL_cleanse(c->cipher_data, c->cipher->ctx_size);
456 } 468 }
457 if (c->cipher_data) 469 if (c->cipher_data)
458 OPENSSL_free(c->cipher_data); 470 OPENSSL_free(c->cipher_data);
471#ifndef OPENSSL_NO_ENGINE
459 if (c->engine) 472 if (c->engine)
460 /* The EVP_CIPHER we used belongs to an ENGINE, release the 473 /* The EVP_CIPHER we used belongs to an ENGINE, release the
461 * functional reference we held for this reason. */ 474 * functional reference we held for this reason. */
462 ENGINE_finish(c->engine); 475 ENGINE_finish(c->engine);
476#endif
463 memset(c,0,sizeof(EVP_CIPHER_CTX)); 477 memset(c,0,sizeof(EVP_CIPHER_CTX));
464 return 1; 478 return 1;
465 } 479 }
diff --git a/src/lib/libcrypto/evp/evp_key.c b/src/lib/libcrypto/evp/evp_key.c
index 4271393069..5f387a94d3 100644
--- a/src/lib/libcrypto/evp/evp_key.c
+++ b/src/lib/libcrypto/evp/evp_key.c
@@ -103,7 +103,7 @@ int EVP_read_pw_string(char *buf, int len, const char *prompt, int verify)
103 buff,0,(len>=BUFSIZ)?BUFSIZ-1:len,buf); 103 buff,0,(len>=BUFSIZ)?BUFSIZ-1:len,buf);
104 ret = UI_process(ui); 104 ret = UI_process(ui);
105 UI_free(ui); 105 UI_free(ui);
106 memset(buff,0,BUFSIZ); 106 OPENSSL_cleanse(buff,BUFSIZ);
107 return ret; 107 return ret;
108 } 108 }
109 109
@@ -118,6 +118,8 @@ int EVP_BytesToKey(const EVP_CIPHER *type, const EVP_MD *md,
118 118
119 nkey=type->key_len; 119 nkey=type->key_len;
120 niv=type->iv_len; 120 niv=type->iv_len;
121 OPENSSL_assert(nkey <= EVP_MAX_KEY_LENGTH);
122 OPENSSL_assert(niv <= EVP_MAX_IV_LENGTH);
121 123
122 if (data == NULL) return(nkey); 124 if (data == NULL) return(nkey);
123 125
@@ -166,7 +168,7 @@ int EVP_BytesToKey(const EVP_CIPHER *type, const EVP_MD *md,
166 if ((nkey == 0) && (niv == 0)) break; 168 if ((nkey == 0) && (niv == 0)) break;
167 } 169 }
168 EVP_MD_CTX_cleanup(&c); 170 EVP_MD_CTX_cleanup(&c);
169 memset(&(md_buf[0]),0,EVP_MAX_MD_SIZE); 171 OPENSSL_cleanse(&(md_buf[0]),EVP_MAX_MD_SIZE);
170 return(type->key_len); 172 return(type->key_len);
171 } 173 }
172 174
diff --git a/src/lib/libcrypto/evp/evp_lib.c b/src/lib/libcrypto/evp/evp_lib.c
index a431945ef5..52a3b287be 100644
--- a/src/lib/libcrypto/evp/evp_lib.c
+++ b/src/lib/libcrypto/evp/evp_lib.c
@@ -90,6 +90,7 @@ int EVP_CIPHER_get_asn1_iv(EVP_CIPHER_CTX *c, ASN1_TYPE *type)
90 if (type != NULL) 90 if (type != NULL)
91 { 91 {
92 l=EVP_CIPHER_CTX_iv_length(c); 92 l=EVP_CIPHER_CTX_iv_length(c);
93 OPENSSL_assert(l <= sizeof c->iv);
93 i=ASN1_TYPE_get_octetstring(type,c->oiv,l); 94 i=ASN1_TYPE_get_octetstring(type,c->oiv,l);
94 if (i != l) 95 if (i != l)
95 return(-1); 96 return(-1);
@@ -106,6 +107,7 @@ int EVP_CIPHER_set_asn1_iv(EVP_CIPHER_CTX *c, ASN1_TYPE *type)
106 if (type != NULL) 107 if (type != NULL)
107 { 108 {
108 j=EVP_CIPHER_CTX_iv_length(c); 109 j=EVP_CIPHER_CTX_iv_length(c);
110 OPENSSL_assert(j <= sizeof c->iv);
109 i=ASN1_TYPE_set_octetstring(type,c->oiv,j); 111 i=ASN1_TYPE_set_octetstring(type,c->oiv,j);
110 } 112 }
111 return(i); 113 return(i);
diff --git a/src/lib/libcrypto/evp/evp_pbe.c b/src/lib/libcrypto/evp/evp_pbe.c
index 4234cd7684..bc98e63363 100644
--- a/src/lib/libcrypto/evp/evp_pbe.c
+++ b/src/lib/libcrypto/evp/evp_pbe.c
@@ -88,7 +88,7 @@ int EVP_PBE_CipherInit (ASN1_OBJECT *pbe_obj, const char *pass, int passlen,
88 char obj_tmp[80]; 88 char obj_tmp[80];
89 EVPerr(EVP_F_EVP_PBE_CIPHERINIT,EVP_R_UNKNOWN_PBE_ALGORITHM); 89 EVPerr(EVP_F_EVP_PBE_CIPHERINIT,EVP_R_UNKNOWN_PBE_ALGORITHM);
90 if (!pbe_obj) strlcpy (obj_tmp, "NULL", sizeof obj_tmp); 90 if (!pbe_obj) strlcpy (obj_tmp, "NULL", sizeof obj_tmp);
91 else i2t_ASN1_OBJECT(obj_tmp, 80, pbe_obj); 91 else i2t_ASN1_OBJECT(obj_tmp, sizeof obj_tmp, pbe_obj);
92 ERR_add_error_data(2, "TYPE=", obj_tmp); 92 ERR_add_error_data(2, "TYPE=", obj_tmp);
93 return 0; 93 return 0;
94 } 94 }
diff --git a/src/lib/libcrypto/evp/evp_test.c b/src/lib/libcrypto/evp/evp_test.c
index 90294ef686..28460173f7 100644
--- a/src/lib/libcrypto/evp/evp_test.c
+++ b/src/lib/libcrypto/evp/evp_test.c
@@ -49,8 +49,14 @@
49 49
50#include <stdio.h> 50#include <stdio.h>
51#include <string.h> 51#include <string.h>
52
53#include "../e_os.h"
54
52#include <openssl/evp.h> 55#include <openssl/evp.h>
56#ifndef OPENSSL_NO_ENGINE
53#include <openssl/engine.h> 57#include <openssl/engine.h>
58#endif
59#include <openssl/err.h>
54#include <openssl/conf.h> 60#include <openssl/conf.h>
55 61
56static void hexdump(FILE *f,const char *title,const unsigned char *s,int l) 62static void hexdump(FILE *f,const char *title,const unsigned char *s,int l)
@@ -78,7 +84,7 @@ static int convert(unsigned char *s)
78 if(!s[1]) 84 if(!s[1])
79 { 85 {
80 fprintf(stderr,"Odd number of hex digits!"); 86 fprintf(stderr,"Odd number of hex digits!");
81 exit(4); 87 EXIT(4);
82 } 88 }
83 sscanf((char *)s,"%2x",&n); 89 sscanf((char *)s,"%2x",&n);
84 *d=(unsigned char)n; 90 *d=(unsigned char)n;
@@ -120,6 +126,12 @@ static char *sstrsep(char **string, const char *delim)
120static unsigned char *ustrsep(char **p,const char *sep) 126static unsigned char *ustrsep(char **p,const char *sep)
121 { return (unsigned char *)sstrsep(p,sep); } 127 { return (unsigned char *)sstrsep(p,sep); }
122 128
129static int test1_exit(int ec)
130 {
131 EXIT(ec);
132 return(0); /* To keep some compilers quiet */
133 }
134
123static void test1(const EVP_CIPHER *c,const unsigned char *key,int kn, 135static void test1(const EVP_CIPHER *c,const unsigned char *key,int kn,
124 const unsigned char *iv,int in, 136 const unsigned char *iv,int in,
125 const unsigned char *plaintext,int pn, 137 const unsigned char *plaintext,int pn,
@@ -142,7 +154,7 @@ static void test1(const EVP_CIPHER *c,const unsigned char *key,int kn,
142 { 154 {
143 fprintf(stderr,"Key length doesn't match, got %d expected %d\n",kn, 155 fprintf(stderr,"Key length doesn't match, got %d expected %d\n",kn,
144 c->key_len); 156 c->key_len);
145 exit(5); 157 test1_exit(5);
146 } 158 }
147 EVP_CIPHER_CTX_init(&ctx); 159 EVP_CIPHER_CTX_init(&ctx);
148 if (encdec != 0) 160 if (encdec != 0)
@@ -150,26 +162,26 @@ static void test1(const EVP_CIPHER *c,const unsigned char *key,int kn,
150 if(!EVP_EncryptInit_ex(&ctx,c,NULL,key,iv)) 162 if(!EVP_EncryptInit_ex(&ctx,c,NULL,key,iv))
151 { 163 {
152 fprintf(stderr,"EncryptInit failed\n"); 164 fprintf(stderr,"EncryptInit failed\n");
153 exit(10); 165 test1_exit(10);
154 } 166 }
155 EVP_CIPHER_CTX_set_padding(&ctx,0); 167 EVP_CIPHER_CTX_set_padding(&ctx,0);
156 168
157 if(!EVP_EncryptUpdate(&ctx,out,&outl,plaintext,pn)) 169 if(!EVP_EncryptUpdate(&ctx,out,&outl,plaintext,pn))
158 { 170 {
159 fprintf(stderr,"Encrypt failed\n"); 171 fprintf(stderr,"Encrypt failed\n");
160 exit(6); 172 test1_exit(6);
161 } 173 }
162 if(!EVP_EncryptFinal_ex(&ctx,out+outl,&outl2)) 174 if(!EVP_EncryptFinal_ex(&ctx,out+outl,&outl2))
163 { 175 {
164 fprintf(stderr,"EncryptFinal failed\n"); 176 fprintf(stderr,"EncryptFinal failed\n");
165 exit(7); 177 test1_exit(7);
166 } 178 }
167 179
168 if(outl+outl2 != cn) 180 if(outl+outl2 != cn)
169 { 181 {
170 fprintf(stderr,"Ciphertext length mismatch got %d expected %d\n", 182 fprintf(stderr,"Ciphertext length mismatch got %d expected %d\n",
171 outl+outl2,cn); 183 outl+outl2,cn);
172 exit(8); 184 test1_exit(8);
173 } 185 }
174 186
175 if(memcmp(out,ciphertext,cn)) 187 if(memcmp(out,ciphertext,cn))
@@ -177,7 +189,7 @@ static void test1(const EVP_CIPHER *c,const unsigned char *key,int kn,
177 fprintf(stderr,"Ciphertext mismatch\n"); 189 fprintf(stderr,"Ciphertext mismatch\n");
178 hexdump(stderr,"Got",out,cn); 190 hexdump(stderr,"Got",out,cn);
179 hexdump(stderr,"Expected",ciphertext,cn); 191 hexdump(stderr,"Expected",ciphertext,cn);
180 exit(9); 192 test1_exit(9);
181 } 193 }
182 } 194 }
183 195
@@ -186,26 +198,26 @@ static void test1(const EVP_CIPHER *c,const unsigned char *key,int kn,
186 if(!EVP_DecryptInit_ex(&ctx,c,NULL,key,iv)) 198 if(!EVP_DecryptInit_ex(&ctx,c,NULL,key,iv))
187 { 199 {
188 fprintf(stderr,"DecryptInit failed\n"); 200 fprintf(stderr,"DecryptInit failed\n");
189 exit(11); 201 test1_exit(11);
190 } 202 }
191 EVP_CIPHER_CTX_set_padding(&ctx,0); 203 EVP_CIPHER_CTX_set_padding(&ctx,0);
192 204
193 if(!EVP_DecryptUpdate(&ctx,out,&outl,ciphertext,cn)) 205 if(!EVP_DecryptUpdate(&ctx,out,&outl,ciphertext,cn))
194 { 206 {
195 fprintf(stderr,"Decrypt failed\n"); 207 fprintf(stderr,"Decrypt failed\n");
196 exit(6); 208 test1_exit(6);
197 } 209 }
198 if(!EVP_DecryptFinal_ex(&ctx,out+outl,&outl2)) 210 if(!EVP_DecryptFinal_ex(&ctx,out+outl,&outl2))
199 { 211 {
200 fprintf(stderr,"DecryptFinal failed\n"); 212 fprintf(stderr,"DecryptFinal failed\n");
201 exit(7); 213 test1_exit(7);
202 } 214 }
203 215
204 if(outl+outl2 != cn) 216 if(outl+outl2 != cn)
205 { 217 {
206 fprintf(stderr,"Plaintext length mismatch got %d expected %d\n", 218 fprintf(stderr,"Plaintext length mismatch got %d expected %d\n",
207 outl+outl2,cn); 219 outl+outl2,cn);
208 exit(8); 220 test1_exit(8);
209 } 221 }
210 222
211 if(memcmp(out,plaintext,cn)) 223 if(memcmp(out,plaintext,cn))
@@ -213,7 +225,7 @@ static void test1(const EVP_CIPHER *c,const unsigned char *key,int kn,
213 fprintf(stderr,"Plaintext mismatch\n"); 225 fprintf(stderr,"Plaintext mismatch\n");
214 hexdump(stderr,"Got",out,cn); 226 hexdump(stderr,"Got",out,cn);
215 hexdump(stderr,"Expected",plaintext,cn); 227 hexdump(stderr,"Expected",plaintext,cn);
216 exit(9); 228 test1_exit(9);
217 } 229 }
218 } 230 }
219 231
@@ -260,24 +272,24 @@ static int test_digest(const char *digest,
260 if(!EVP_DigestInit_ex(&ctx,d, NULL)) 272 if(!EVP_DigestInit_ex(&ctx,d, NULL))
261 { 273 {
262 fprintf(stderr,"DigestInit failed\n"); 274 fprintf(stderr,"DigestInit failed\n");
263 exit(100); 275 EXIT(100);
264 } 276 }
265 if(!EVP_DigestUpdate(&ctx,plaintext,pn)) 277 if(!EVP_DigestUpdate(&ctx,plaintext,pn))
266 { 278 {
267 fprintf(stderr,"DigestUpdate failed\n"); 279 fprintf(stderr,"DigestUpdate failed\n");
268 exit(101); 280 EXIT(101);
269 } 281 }
270 if(!EVP_DigestFinal_ex(&ctx,md,&mdn)) 282 if(!EVP_DigestFinal_ex(&ctx,md,&mdn))
271 { 283 {
272 fprintf(stderr,"DigestFinal failed\n"); 284 fprintf(stderr,"DigestFinal failed\n");
273 exit(101); 285 EXIT(101);
274 } 286 }
275 EVP_MD_CTX_cleanup(&ctx); 287 EVP_MD_CTX_cleanup(&ctx);
276 288
277 if(mdn != cn) 289 if(mdn != cn)
278 { 290 {
279 fprintf(stderr,"Digest length mismatch, got %d expected %d\n",mdn,cn); 291 fprintf(stderr,"Digest length mismatch, got %d expected %d\n",mdn,cn);
280 exit(102); 292 EXIT(102);
281 } 293 }
282 294
283 if(memcmp(md,ciphertext,cn)) 295 if(memcmp(md,ciphertext,cn))
@@ -285,7 +297,7 @@ static int test_digest(const char *digest,
285 fprintf(stderr,"Digest mismatch\n"); 297 fprintf(stderr,"Digest mismatch\n");
286 hexdump(stderr,"Got",md,cn); 298 hexdump(stderr,"Got",md,cn);
287 hexdump(stderr,"Expected",ciphertext,cn); 299 hexdump(stderr,"Expected",ciphertext,cn);
288 exit(103); 300 EXIT(103);
289 } 301 }
290 302
291 printf("\n"); 303 printf("\n");
@@ -303,7 +315,7 @@ int main(int argc,char **argv)
303 if(argc != 2) 315 if(argc != 2)
304 { 316 {
305 fprintf(stderr,"%s <test file>\n",argv[0]); 317 fprintf(stderr,"%s <test file>\n",argv[0]);
306 exit(1); 318 EXIT(1);
307 } 319 }
308 CRYPTO_malloc_debug_init(); 320 CRYPTO_malloc_debug_init();
309 CRYPTO_set_mem_debug_options(V_CRYPTO_MDEBUG_ALL); 321 CRYPTO_set_mem_debug_options(V_CRYPTO_MDEBUG_ALL);
@@ -315,17 +327,20 @@ int main(int argc,char **argv)
315 if(!f) 327 if(!f)
316 { 328 {
317 perror(szTestFile); 329 perror(szTestFile);
318 exit(2); 330 EXIT(2);
319 } 331 }
320 332
321 /* Load up the software EVP_CIPHER and EVP_MD definitions */ 333 /* Load up the software EVP_CIPHER and EVP_MD definitions */
322 OpenSSL_add_all_ciphers(); 334 OpenSSL_add_all_ciphers();
323 OpenSSL_add_all_digests(); 335 OpenSSL_add_all_digests();
336#ifndef OPENSSL_NO_ENGINE
324 /* Load all compiled-in ENGINEs */ 337 /* Load all compiled-in ENGINEs */
325 ENGINE_load_builtin_engines(); 338 ENGINE_load_builtin_engines();
339#endif
326#if 0 340#if 0
327 OPENSSL_config(); 341 OPENSSL_config();
328#endif 342#endif
343#ifndef OPENSSL_NO_ENGINE
329 /* Register all available ENGINE implementations of ciphers and digests. 344 /* Register all available ENGINE implementations of ciphers and digests.
330 * This could perhaps be changed to "ENGINE_register_all_complete()"? */ 345 * This could perhaps be changed to "ENGINE_register_all_complete()"? */
331 ENGINE_register_all_ciphers(); 346 ENGINE_register_all_ciphers();
@@ -334,6 +349,7 @@ int main(int argc,char **argv)
334 * It'll prevent ENGINEs being ENGINE_init()ialised for cipher/digest use if 349 * It'll prevent ENGINEs being ENGINE_init()ialised for cipher/digest use if
335 * they weren't already initialised. */ 350 * they weren't already initialised. */
336 /* ENGINE_set_cipher_flags(ENGINE_CIPHER_FLAG_NOINIT); */ 351 /* ENGINE_set_cipher_flags(ENGINE_CIPHER_FLAG_NOINIT); */
352#endif
337 353
338 for( ; ; ) 354 for( ; ; )
339 { 355 {
@@ -371,11 +387,13 @@ int main(int argc,char **argv)
371 && !test_digest(cipher,plaintext,pn,ciphertext,cn)) 387 && !test_digest(cipher,plaintext,pn,ciphertext,cn))
372 { 388 {
373 fprintf(stderr,"Can't find %s\n",cipher); 389 fprintf(stderr,"Can't find %s\n",cipher);
374 exit(3); 390 EXIT(3);
375 } 391 }
376 } 392 }
377 393
394#ifndef OPENSSL_NO_ENGINE
378 ENGINE_cleanup(); 395 ENGINE_cleanup();
396#endif
379 EVP_cleanup(); 397 EVP_cleanup();
380 CRYPTO_cleanup_all_ex_data(); 398 CRYPTO_cleanup_all_ex_data();
381 ERR_remove_state(0); 399 ERR_remove_state(0);
diff --git a/src/lib/libcrypto/evp/p5_crpt.c b/src/lib/libcrypto/evp/p5_crpt.c
index 27a8286489..a1874e83b2 100644
--- a/src/lib/libcrypto/evp/p5_crpt.c
+++ b/src/lib/libcrypto/evp/p5_crpt.c
@@ -140,12 +140,14 @@ int PKCS5_PBE_keyivgen(EVP_CIPHER_CTX *cctx, const char *pass, int passlen,
140 EVP_DigestFinal_ex (&ctx, md_tmp, NULL); 140 EVP_DigestFinal_ex (&ctx, md_tmp, NULL);
141 } 141 }
142 EVP_MD_CTX_cleanup(&ctx); 142 EVP_MD_CTX_cleanup(&ctx);
143 OPENSSL_assert(EVP_CIPHER_key_length(cipher) <= sizeof md_tmp);
143 memcpy(key, md_tmp, EVP_CIPHER_key_length(cipher)); 144 memcpy(key, md_tmp, EVP_CIPHER_key_length(cipher));
145 OPENSSL_assert(EVP_CIPHER_iv_length(cipher) <= 16);
144 memcpy(iv, md_tmp + (16 - EVP_CIPHER_iv_length(cipher)), 146 memcpy(iv, md_tmp + (16 - EVP_CIPHER_iv_length(cipher)),
145 EVP_CIPHER_iv_length(cipher)); 147 EVP_CIPHER_iv_length(cipher));
146 EVP_CipherInit_ex(cctx, cipher, NULL, key, iv, en_de); 148 EVP_CipherInit_ex(cctx, cipher, NULL, key, iv, en_de);
147 memset(md_tmp, 0, EVP_MAX_MD_SIZE); 149 OPENSSL_cleanse(md_tmp, EVP_MAX_MD_SIZE);
148 memset(key, 0, EVP_MAX_KEY_LENGTH); 150 OPENSSL_cleanse(key, EVP_MAX_KEY_LENGTH);
149 memset(iv, 0, EVP_MAX_IV_LENGTH); 151 OPENSSL_cleanse(iv, EVP_MAX_IV_LENGTH);
150 return 1; 152 return 1;
151} 153}
diff --git a/src/lib/libcrypto/evp/p5_crpt2.c b/src/lib/libcrypto/evp/p5_crpt2.c
index 7485d6a278..1f94e1ef88 100644
--- a/src/lib/libcrypto/evp/p5_crpt2.c
+++ b/src/lib/libcrypto/evp/p5_crpt2.c
@@ -190,6 +190,7 @@ int PKCS5_v2_PBE_keyivgen(EVP_CIPHER_CTX *ctx, const char *pass, int passlen,
190 goto err; 190 goto err;
191 } 191 }
192 keylen = EVP_CIPHER_CTX_key_length(ctx); 192 keylen = EVP_CIPHER_CTX_key_length(ctx);
193 OPENSSL_assert(keylen <= sizeof key);
193 194
194 /* Now decode key derivation function */ 195 /* Now decode key derivation function */
195 196
@@ -230,7 +231,7 @@ int PKCS5_v2_PBE_keyivgen(EVP_CIPHER_CTX *ctx, const char *pass, int passlen,
230 iter = ASN1_INTEGER_get(kdf->iter); 231 iter = ASN1_INTEGER_get(kdf->iter);
231 PKCS5_PBKDF2_HMAC_SHA1(pass, passlen, salt, saltlen, iter, keylen, key); 232 PKCS5_PBKDF2_HMAC_SHA1(pass, passlen, salt, saltlen, iter, keylen, key);
232 EVP_CipherInit_ex(ctx, NULL, NULL, key, NULL, en_de); 233 EVP_CipherInit_ex(ctx, NULL, NULL, key, NULL, en_de);
233 memset(key, 0, keylen); 234 OPENSSL_cleanse(key, keylen);
234 PBKDF2PARAM_free(kdf); 235 PBKDF2PARAM_free(kdf);
235 return 1; 236 return 1;
236 237
diff --git a/src/lib/libcrypto/evp/p_open.c b/src/lib/libcrypto/evp/p_open.c
index 6976f2a867..5a933d1cda 100644
--- a/src/lib/libcrypto/evp/p_open.c
+++ b/src/lib/libcrypto/evp/p_open.c
@@ -101,7 +101,7 @@ int EVP_OpenInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *type, unsigned char *ek,
101 101
102 ret=1; 102 ret=1;
103err: 103err:
104 if (key != NULL) memset(key,0,size); 104 if (key != NULL) OPENSSL_cleanse(key,size);
105 OPENSSL_free(key); 105 OPENSSL_free(key);
106 return(ret); 106 return(ret);
107 } 107 }
diff --git a/src/lib/libcrypto/hmac/Makefile.ssl b/src/lib/libcrypto/hmac/Makefile.ssl
index 2bb3264f0e..f1c07322c4 100644
--- a/src/lib/libcrypto/hmac/Makefile.ssl
+++ b/src/lib/libcrypto/hmac/Makefile.ssl
@@ -68,7 +68,7 @@ lint:
68 lint -DLINT $(INCLUDES) $(SRC)>fluff 68 lint -DLINT $(INCLUDES) $(SRC)>fluff
69 69
70depend: 70depend:
71 $(MAKEDEPEND) $(CFLAG) $(INCLUDES) $(DEPFLAG) $(PROGS) $(LIBSRC) 71 $(MAKEDEPEND) -- $(CFLAG) $(INCLUDES) $(DEPFLAG) -- $(PROGS) $(LIBSRC)
72 72
73dclean: 73dclean:
74 $(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new 74 $(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
@@ -79,21 +79,23 @@ clean:
79 79
80# DO NOT DELETE THIS LINE -- make depend depends on it. 80# DO NOT DELETE THIS LINE -- make depend depends on it.
81 81
82hmac.o: ../../include/openssl/aes.h ../../include/openssl/asn1.h 82hmac.o: ../../e_os.h ../../include/openssl/aes.h ../../include/openssl/asn1.h
83hmac.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h 83hmac.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h
84hmac.o: ../../include/openssl/bn.h ../../include/openssl/cast.h 84hmac.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
85hmac.o: ../../include/openssl/crypto.h ../../include/openssl/des.h 85hmac.o: ../../include/openssl/cast.h ../../include/openssl/crypto.h
86hmac.o: ../../include/openssl/des_old.h ../../include/openssl/dh.h 86hmac.o: ../../include/openssl/des.h ../../include/openssl/des_old.h
87hmac.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h 87hmac.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
88hmac.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
88hmac.o: ../../include/openssl/evp.h ../../include/openssl/hmac.h 89hmac.o: ../../include/openssl/evp.h ../../include/openssl/hmac.h
89hmac.o: ../../include/openssl/idea.h ../../include/openssl/md2.h 90hmac.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h
90hmac.o: ../../include/openssl/md4.h ../../include/openssl/md5.h 91hmac.o: ../../include/openssl/md2.h ../../include/openssl/md4.h
91hmac.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h 92hmac.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
92hmac.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h 93hmac.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
93hmac.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h 94hmac.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
94hmac.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h 95hmac.o: ../../include/openssl/ossl_typ.h ../../include/openssl/rc2.h
95hmac.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h 96hmac.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
96hmac.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h 97hmac.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
97hmac.o: ../../include/openssl/sha.h ../../include/openssl/stack.h 98hmac.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
98hmac.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h 99hmac.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
99hmac.o: ../../include/openssl/ui_compat.h hmac.c 100hmac.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
101hmac.o: ../cryptlib.h hmac.c
diff --git a/src/lib/libcrypto/hmac/hmac.c b/src/lib/libcrypto/hmac/hmac.c
index da363b7950..4c91f919d5 100644
--- a/src/lib/libcrypto/hmac/hmac.c
+++ b/src/lib/libcrypto/hmac/hmac.c
@@ -59,6 +59,7 @@
59#include <stdlib.h> 59#include <stdlib.h>
60#include <string.h> 60#include <string.h>
61#include <openssl/hmac.h> 61#include <openssl/hmac.h>
62#include "cryptlib.h"
62 63
63void HMAC_Init_ex(HMAC_CTX *ctx, const void *key, int len, 64void HMAC_Init_ex(HMAC_CTX *ctx, const void *key, int len,
64 const EVP_MD *md, ENGINE *impl) 65 const EVP_MD *md, ENGINE *impl)
@@ -78,6 +79,7 @@ void HMAC_Init_ex(HMAC_CTX *ctx, const void *key, int len,
78 { 79 {
79 reset=1; 80 reset=1;
80 j=EVP_MD_block_size(md); 81 j=EVP_MD_block_size(md);
82 OPENSSL_assert(j <= sizeof ctx->key);
81 if (j < len) 83 if (j < len)
82 { 84 {
83 EVP_DigestInit_ex(&ctx->md_ctx,md, impl); 85 EVP_DigestInit_ex(&ctx->md_ctx,md, impl);
@@ -87,6 +89,7 @@ void HMAC_Init_ex(HMAC_CTX *ctx, const void *key, int len,
87 } 89 }
88 else 90 else
89 { 91 {
92 OPENSSL_assert(len <= sizeof ctx->key);
90 memcpy(ctx->key,key,len); 93 memcpy(ctx->key,key,len);
91 ctx->key_length=len; 94 ctx->key_length=len;
92 } 95 }
diff --git a/src/lib/libcrypto/hmac/hmactest.c b/src/lib/libcrypto/hmac/hmactest.c
index 96d3beb8e6..1b906b81af 100644
--- a/src/lib/libcrypto/hmac/hmactest.c
+++ b/src/lib/libcrypto/hmac/hmactest.c
@@ -60,6 +60,8 @@
60#include <string.h> 60#include <string.h>
61#include <stdlib.h> 61#include <stdlib.h>
62 62
63#include "../e_os.h"
64
63#ifdef OPENSSL_NO_HMAC 65#ifdef OPENSSL_NO_HMAC
64int main(int argc, char *argv[]) 66int main(int argc, char *argv[])
65{ 67{
@@ -68,12 +70,15 @@ int main(int argc, char *argv[])
68} 70}
69#else 71#else
70#include <openssl/hmac.h> 72#include <openssl/hmac.h>
73#ifndef OPENSSL_NO_MD5
71#include <openssl/md5.h> 74#include <openssl/md5.h>
75#endif
72 76
73#ifdef CHARSET_EBCDIC 77#ifdef CHARSET_EBCDIC
74#include <openssl/ebcdic.h> 78#include <openssl/ebcdic.h>
75#endif 79#endif
76 80
81#ifndef OPENSSL_NO_MD5
77static struct test_st 82static struct test_st
78 { 83 {
79 unsigned char key[16]; 84 unsigned char key[16];
@@ -113,13 +118,20 @@ static struct test_st
113 (unsigned char *)"56be34521d144c88dbb8c733f0e8b3f6", 118 (unsigned char *)"56be34521d144c88dbb8c733f0e8b3f6",
114 }, 119 },
115 }; 120 };
116 121#endif
117 122
118static char *pt(unsigned char *md); 123static char *pt(unsigned char *md);
119int main(int argc, char *argv[]) 124int main(int argc, char *argv[])
120 { 125 {
121 int i,err=0; 126#ifndef OPENSSL_NO_MD5
127 int i;
122 char *p; 128 char *p;
129#endif
130 int err=0;
131
132#ifdef OPENSSL_NO_MD5
133 printf("test skipped: MD5 disabled\n");
134#else
123 135
124#ifdef CHARSET_EBCDIC 136#ifdef CHARSET_EBCDIC
125 ebcdic2ascii(test[0].data, test[0].data, test[0].data_len); 137 ebcdic2ascii(test[0].data, test[0].data, test[0].data_len);
@@ -144,10 +156,12 @@ int main(int argc, char *argv[])
144 else 156 else
145 printf("test %d ok\n",i); 157 printf("test %d ok\n",i);
146 } 158 }
147 exit(err); 159#endif /* OPENSSL_NO_MD5 */
160 EXIT(err);
148 return(0); 161 return(0);
149 } 162 }
150 163
164#ifndef OPENSSL_NO_MD5
151static char *pt(unsigned char *md) 165static char *pt(unsigned char *md)
152 { 166 {
153 int i; 167 int i;
@@ -158,3 +172,4 @@ static char *pt(unsigned char *md)
158 return(buf); 172 return(buf);
159 } 173 }
160#endif 174#endif
175#endif
diff --git a/src/lib/libcrypto/idea/Makefile.ssl b/src/lib/libcrypto/idea/Makefile.ssl
index 87c9aa484b..fa016ea399 100644
--- a/src/lib/libcrypto/idea/Makefile.ssl
+++ b/src/lib/libcrypto/idea/Makefile.ssl
@@ -68,7 +68,7 @@ lint:
68 lint -DLINT $(INCLUDES) $(SRC)>fluff 68 lint -DLINT $(INCLUDES) $(SRC)>fluff
69 69
70depend: 70depend:
71 $(MAKEDEPEND) $(CFLAG) $(INCLUDES) $(DEPFLAG) $(PROGS) $(LIBSRC) 71 $(MAKEDEPEND) -- $(CFLAG) $(INCLUDES) $(DEPFLAG) -- $(PROGS) $(LIBSRC)
72 72
73dclean: 73dclean:
74 $(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new 74 $(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
diff --git a/src/lib/libcrypto/krb5/Makefile.ssl b/src/lib/libcrypto/krb5/Makefile.ssl
index 7ad0cbb0bc..d9224c0f09 100644
--- a/src/lib/libcrypto/krb5/Makefile.ssl
+++ b/src/lib/libcrypto/krb5/Makefile.ssl
@@ -41,7 +41,7 @@ all: lib
41 41
42lib: $(LIBOBJ) 42lib: $(LIBOBJ)
43 $(AR) $(LIB) $(LIBOBJ) 43 $(AR) $(LIB) $(LIBOBJ)
44 $(RANLIB) $(LIB) 44 $(RANLIB) $(LIB) || echo Never mind.
45 @touch lib 45 @touch lib
46 46
47files: 47files:
@@ -69,7 +69,7 @@ lint:
69 lint -DLINT $(INCLUDES) $(SRC)>fluff 69 lint -DLINT $(INCLUDES) $(SRC)>fluff
70 70
71depend: 71depend:
72 $(MAKEDEPEND) $(CFLAG) $(INCLUDES) $(DEPFLAG) $(LIBSRC) 72 $(MAKEDEPEND) -- $(CFLAG) $(INCLUDES) $(DEPFLAG) -- $(LIBSRC)
73 73
74dclean: 74dclean:
75 $(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new 75 $(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
diff --git a/src/lib/libcrypto/lhash/Makefile.ssl b/src/lib/libcrypto/lhash/Makefile.ssl
index b3ad272cf7..60e7ee3393 100644
--- a/src/lib/libcrypto/lhash/Makefile.ssl
+++ b/src/lib/libcrypto/lhash/Makefile.ssl
@@ -68,7 +68,7 @@ lint:
68 lint -DLINT $(INCLUDES) $(SRC)>fluff 68 lint -DLINT $(INCLUDES) $(SRC)>fluff
69 69
70depend: 70depend:
71 $(MAKEDEPEND) $(CFLAG) $(INCLUDES) $(DEPFLAG) $(PROGS) $(LIBSRC) 71 $(MAKEDEPEND) -- $(CFLAG) $(INCLUDES) $(DEPFLAG) -- $(PROGS) $(LIBSRC)
72 72
73dclean: 73dclean:
74 $(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new 74 $(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
diff --git a/src/lib/libcrypto/lhash/lh_stats.c b/src/lib/libcrypto/lhash/lh_stats.c
index 8e6f57c741..5aa7766aa6 100644
--- a/src/lib/libcrypto/lhash/lh_stats.c
+++ b/src/lib/libcrypto/lhash/lh_stats.c
@@ -179,63 +179,29 @@ end:;
179 179
180void lh_stats_bio(const LHASH *lh, BIO *out) 180void lh_stats_bio(const LHASH *lh, BIO *out)
181 { 181 {
182 char buf[128]; 182 BIO_printf(out,"num_items = %lu\n",lh->num_items);
183 183 BIO_printf(out,"num_nodes = %u\n",lh->num_nodes);
184 snprintf(buf,sizeof buf,"num_items = %lu\n",lh->num_items); 184 BIO_printf(out,"num_alloc_nodes = %u\n",lh->num_alloc_nodes);
185 BIO_puts(out,buf); 185 BIO_printf(out,"num_expands = %lu\n",lh->num_expands);
186 snprintf(buf,sizeof buf,"num_nodes = %u\n",lh->num_nodes); 186 BIO_printf(out,"num_expand_reallocs = %lu\n",
187 BIO_puts(out,buf); 187 lh->num_expand_reallocs);
188 snprintf(buf,sizeof buf,"num_alloc_nodes = %u\n", 188 BIO_printf(out,"num_contracts = %lu\n",lh->num_contracts);
189 lh->num_alloc_nodes); 189 BIO_printf(out,"num_contract_reallocs = %lu\n",
190 BIO_puts(out,buf); 190 lh->num_contract_reallocs);
191 snprintf(buf,sizeof buf,"num_expands = %lu\n", 191 BIO_printf(out,"num_hash_calls = %lu\n",lh->num_hash_calls);
192 lh->num_expands); 192 BIO_printf(out,"num_comp_calls = %lu\n",lh->num_comp_calls);
193 BIO_puts(out,buf); 193 BIO_printf(out,"num_insert = %lu\n",lh->num_insert);
194 snprintf(buf,sizeof buf,"num_expand_reallocs = %lu\n", 194 BIO_printf(out,"num_replace = %lu\n",lh->num_replace);
195 lh->num_expand_reallocs); 195 BIO_printf(out,"num_delete = %lu\n",lh->num_delete);
196 BIO_puts(out,buf); 196 BIO_printf(out,"num_no_delete = %lu\n",lh->num_no_delete);
197 snprintf(buf,sizeof buf,"num_contracts = %lu\n", 197 BIO_printf(out,"num_retrieve = %lu\n",lh->num_retrieve);
198 lh->num_contracts); 198 BIO_printf(out,"num_retrieve_miss = %lu\n",lh->num_retrieve_miss);
199 BIO_puts(out,buf); 199 BIO_printf(out,"num_hash_comps = %lu\n",lh->num_hash_comps);
200 snprintf(buf,sizeof buf,"num_contract_reallocs = %lu\n",
201 lh->num_contract_reallocs);
202 BIO_puts(out,buf);
203 snprintf(buf,sizeof buf,"num_hash_calls = %lu\n",
204 lh->num_hash_calls);
205 BIO_puts(out,buf);
206 snprintf(buf,sizeof buf,"num_comp_calls = %lu\n",
207 lh->num_comp_calls);
208 BIO_puts(out,buf);
209 snprintf(buf,sizeof buf,"num_insert = %lu\n",
210 lh->num_insert);
211 BIO_puts(out,buf);
212 snprintf(buf,sizeof buf,"num_replace = %lu\n",
213 lh->num_replace);
214 BIO_puts(out,buf);
215 snprintf(buf,sizeof buf,"num_delete = %lu\n",
216 lh->num_delete);
217 BIO_puts(out,buf);
218 snprintf(buf,sizeof buf,"num_no_delete = %lu\n",
219 lh->num_no_delete);
220 BIO_puts(out,buf);
221 snprintf(buf,sizeof buf,"num_retrieve = %lu\n",
222 lh->num_retrieve);
223 BIO_puts(out,buf);
224 snprintf(buf,sizeof buf,"num_retrieve_miss = %lu\n",
225 lh->num_retrieve_miss);
226 BIO_puts(out,buf);
227 snprintf(buf,sizeof buf,"num_hash_comps = %lu\n",
228 lh->num_hash_comps);
229 BIO_puts(out,buf);
230#if 0 200#if 0
231 snprintf(buf,sizeof buf,"p = %u\n",lh->p); 201 BIO_printf(out,"p = %u\n",lh->p);
232 BIO_puts(out,buf); 202 BIO_printf(out,"pmax = %u\n",lh->pmax);
233 snprintf(buf,sizeof buf,"pmax = %u\n",lh->pmax); 203 BIO_printf(out,"up_load = %lu\n",lh->up_load);
234 BIO_puts(out,buf); 204 BIO_printf(out,"down_load = %lu\n",lh->down_load);
235 snprintf(buf,sizeof buf,"up_load = %lu\n",lh->up_load);
236 BIO_puts(out,buf);
237 snprintf(buf,sizeof buf,"down_load = %lu\n",lh->down_load);
238 BIO_puts(out,buf);
239#endif 205#endif
240 } 206 }
241 207
@@ -243,14 +209,12 @@ void lh_node_stats_bio(const LHASH *lh, BIO *out)
243 { 209 {
244 LHASH_NODE *n; 210 LHASH_NODE *n;
245 unsigned int i,num; 211 unsigned int i,num;
246 char buf[128];
247 212
248 for (i=0; i<lh->num_nodes; i++) 213 for (i=0; i<lh->num_nodes; i++)
249 { 214 {
250 for (n=lh->b[i],num=0; n != NULL; n=n->next) 215 for (n=lh->b[i],num=0; n != NULL; n=n->next)
251 num++; 216 num++;
252 snprintf(buf,sizeof buf,"node %6u -> %3u\n",i,num); 217 BIO_printf(out,"node %6u -> %3u\n",i,num);
253 BIO_puts(out,buf);
254 } 218 }
255 } 219 }
256 220
@@ -260,7 +224,6 @@ void lh_node_usage_stats_bio(const LHASH *lh, BIO *out)
260 unsigned long num; 224 unsigned long num;
261 unsigned int i; 225 unsigned int i;
262 unsigned long total=0,n_used=0; 226 unsigned long total=0,n_used=0;
263 char buf[128];
264 227
265 for (i=0; i<lh->num_nodes; i++) 228 for (i=0; i<lh->num_nodes; i++)
266 { 229 {
@@ -272,18 +235,14 @@ void lh_node_usage_stats_bio(const LHASH *lh, BIO *out)
272 total+=num; 235 total+=num;
273 } 236 }
274 } 237 }
275 snprintf(buf,sizeof buf,"%lu nodes used out of %u\n",n_used, 238 BIO_printf(out,"%lu nodes used out of %u\n",n_used,lh->num_nodes);
276 lh->num_nodes); 239 BIO_printf(out,"%lu items\n",total);
277 BIO_puts(out,buf);
278 snprintf(buf,sizeof buf,"%lu items\n",total);
279 BIO_puts(out,buf);
280 if (n_used == 0) return; 240 if (n_used == 0) return;
281 snprintf(buf,sizeof buf,"load %d.%02d actual load %d.%02d\n", 241 BIO_printf(out,"load %d.%02d actual load %d.%02d\n",
282 (int)(total/lh->num_nodes), 242 (int)(total/lh->num_nodes),
283 (int)((total%lh->num_nodes)*100/lh->num_nodes), 243 (int)((total%lh->num_nodes)*100/lh->num_nodes),
284 (int)(total/n_used), 244 (int)(total/n_used),
285 (int)((total%n_used)*100/n_used)); 245 (int)((total%n_used)*100/n_used));
286 BIO_puts(out,buf);
287 } 246 }
288 247
289#endif 248#endif
diff --git a/src/lib/libcrypto/md2/Makefile.ssl b/src/lib/libcrypto/md2/Makefile.ssl
index e89a17f3a4..3206924c90 100644
--- a/src/lib/libcrypto/md2/Makefile.ssl
+++ b/src/lib/libcrypto/md2/Makefile.ssl
@@ -68,7 +68,7 @@ lint:
68 lint -DLINT $(INCLUDES) $(SRC)>fluff 68 lint -DLINT $(INCLUDES) $(SRC)>fluff
69 69
70depend: 70depend:
71 $(MAKEDEPEND) $(CFLAG) $(INCLUDES) $(DEPFLAG) $(PROGS) $(LIBSRC) 71 $(MAKEDEPEND) -- $(CFLAG) $(INCLUDES) $(DEPFLAG) -- $(PROGS) $(LIBSRC)
72 72
73dclean: 73dclean:
74 $(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new 74 $(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
@@ -79,8 +79,11 @@ clean:
79 79
80# DO NOT DELETE THIS LINE -- make depend depends on it. 80# DO NOT DELETE THIS LINE -- make depend depends on it.
81 81
82md2_dgst.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
82md2_dgst.o: ../../include/openssl/md2.h ../../include/openssl/opensslconf.h 83md2_dgst.o: ../../include/openssl/md2.h ../../include/openssl/opensslconf.h
83md2_dgst.o: ../../include/openssl/opensslv.h md2_dgst.c 84md2_dgst.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
85md2_dgst.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
86md2_dgst.o: md2_dgst.c
84md2_one.o: ../../e_os.h ../../include/openssl/bio.h 87md2_one.o: ../../e_os.h ../../include/openssl/bio.h
85md2_one.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 88md2_one.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
86md2_one.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h 89md2_one.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
diff --git a/src/lib/libcrypto/md2/md2_dgst.c b/src/lib/libcrypto/md2/md2_dgst.c
index e25dd00e02..ecb64f0ec4 100644
--- a/src/lib/libcrypto/md2/md2_dgst.c
+++ b/src/lib/libcrypto/md2/md2_dgst.c
@@ -61,6 +61,7 @@
61#include <string.h> 61#include <string.h>
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 65
65const char *MD2_version="MD2" OPENSSL_VERSION_PTEXT; 66const char *MD2_version="MD2" OPENSSL_VERSION_PTEXT;
66 67
@@ -118,9 +119,9 @@ const char *MD2_options(void)
118int MD2_Init(MD2_CTX *c) 119int MD2_Init(MD2_CTX *c)
119 { 120 {
120 c->num=0; 121 c->num=0;
121 memset(c->state,0,MD2_BLOCK*sizeof(MD2_INT)); 122 memset(c->state,0,sizeof c->state);
122 memset(c->cksm,0,MD2_BLOCK*sizeof(MD2_INT)); 123 memset(c->cksm,0,sizeof c->cksm);
123 memset(c->data,0,MD2_BLOCK); 124 memset(c->data,0,sizeof c->data);
124 return 1; 125 return 1;
125 } 126 }
126 127
@@ -196,7 +197,7 @@ static void md2_block(MD2_CTX *c, const unsigned char *d)
196 t=(t+i)&0xff; 197 t=(t+i)&0xff;
197 } 198 }
198 memcpy(sp1,state,16*sizeof(MD2_INT)); 199 memcpy(sp1,state,16*sizeof(MD2_INT));
199 memset(state,0,48*sizeof(MD2_INT)); 200 OPENSSL_cleanse(state,48*sizeof(MD2_INT));
200 } 201 }
201 202
202int MD2_Final(unsigned char *md, MD2_CTX *c) 203int MD2_Final(unsigned char *md, MD2_CTX *c)
diff --git a/src/lib/libcrypto/md2/md2_one.c b/src/lib/libcrypto/md2/md2_one.c
index b12c37ce4d..835160ef56 100644
--- a/src/lib/libcrypto/md2/md2_one.c
+++ b/src/lib/libcrypto/md2/md2_one.c
@@ -88,6 +88,6 @@ unsigned char *MD2(const unsigned char *d, unsigned long n, unsigned char *md)
88 } 88 }
89#endif 89#endif
90 MD2_Final(md,&c); 90 MD2_Final(md,&c);
91 memset(&c,0,sizeof(c)); /* Security consideration */ 91 OPENSSL_cleanse(&c,sizeof(c)); /* Security consideration */
92 return(md); 92 return(md);
93 } 93 }
diff --git a/src/lib/libcrypto/md2/md2test.c b/src/lib/libcrypto/md2/md2test.c
index 7d3664faf5..901d0a7d8e 100644
--- a/src/lib/libcrypto/md2/md2test.c
+++ b/src/lib/libcrypto/md2/md2test.c
@@ -61,6 +61,8 @@
61#include <string.h> 61#include <string.h>
62#include <openssl/md2.h> 62#include <openssl/md2.h>
63 63
64#include "../e_os.h"
65
64#ifdef OPENSSL_NO_MD2 66#ifdef OPENSSL_NO_MD2
65int main(int argc, char *argv[]) 67int main(int argc, char *argv[])
66{ 68{
@@ -122,8 +124,7 @@ int main(int argc, char *argv[])
122 R++; 124 R++;
123 P++; 125 P++;
124 } 126 }
125 exit(err); 127 EXIT(err);
126 return(0);
127 } 128 }
128 129
129static char *pt(unsigned char *md) 130static char *pt(unsigned char *md)
diff --git a/src/lib/libcrypto/md32_common.h b/src/lib/libcrypto/md32_common.h
index 353d2b96ad..573850b122 100644
--- a/src/lib/libcrypto/md32_common.h
+++ b/src/lib/libcrypto/md32_common.h
@@ -1,6 +1,6 @@
1/* crypto/md32_common.h */ 1/* crypto/md32_common.h */
2/* ==================================================================== 2/* ====================================================================
3 * Copyright (c) 1999 The OpenSSL Project. All rights reserved. 3 * Copyright (c) 1999-2002 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
@@ -198,7 +198,7 @@
198 * 198 *
199 * <appro@fy.chalmers.se> 199 * <appro@fy.chalmers.se>
200 */ 200 */
201# if defined(__i386) || defined(__i386__) 201# if defined(__i386) || defined(__i386__) || defined(__x86_64) || defined(__x86_64__)
202# define ROTATE(a,n) ({ register unsigned int ret; \ 202# define ROTATE(a,n) ({ register unsigned int ret; \
203 asm ( \ 203 asm ( \
204 "roll %1,%0" \ 204 "roll %1,%0" \
@@ -224,7 +224,7 @@
224 */ 224 */
225# if defined(__GNUC__) && __GNUC__>=2 && !defined(OPENSSL_NO_ASM) && !defined(OPENSSL_NO_INLINE_ASM) 225# if defined(__GNUC__) && __GNUC__>=2 && !defined(OPENSSL_NO_ASM) && !defined(OPENSSL_NO_INLINE_ASM)
226 /* some GNU C inline assembler templates by <appro@fy.chalmers.se> */ 226 /* some GNU C inline assembler templates by <appro@fy.chalmers.se> */
227# if (defined(__i386) || defined(__i386__)) && !defined(I386_ONLY) 227# if (defined(__i386) || defined(__i386__) || defined(__x86_64) || defined(__x86_64__)) && !defined(I386_ONLY)
228# define BE_FETCH32(a) ({ register unsigned int l=(a);\ 228# define BE_FETCH32(a) ({ register unsigned int l=(a);\
229 asm ( \ 229 asm ( \
230 "bswapl %0" \ 230 "bswapl %0" \
@@ -456,7 +456,10 @@ int HASH_UPDATE (HASH_CTX *c, const void *data_, unsigned long len)
456 { 456 {
457 ew=(c->num>>2); 457 ew=(c->num>>2);
458 ec=(c->num&0x03); 458 ec=(c->num&0x03);
459 l=p[sw]; HOST_p_c2l(data,l,sc); p[sw++]=l; 459 if (sc)
460 l=p[sw];
461 HOST_p_c2l(data,l,sc);
462 p[sw++]=l;
460 for (; sw < ew; sw++) 463 for (; sw < ew; sw++)
461 { 464 {
462 HOST_c2l(data,l); p[sw]=l; 465 HOST_c2l(data,l); p[sw]=l;
@@ -603,7 +606,32 @@ int HASH_FINAL (unsigned char *md, HASH_CTX *c)
603 c->num=0; 606 c->num=0;
604 /* clear stuff, HASH_BLOCK may be leaving some stuff on the stack 607 /* clear stuff, HASH_BLOCK may be leaving some stuff on the stack
605 * but I'm not worried :-) 608 * but I'm not worried :-)
606 memset((void *)c,0,sizeof(HASH_CTX)); 609 OPENSSL_cleanse((void *)c,sizeof(HASH_CTX));
607 */ 610 */
608 return 1; 611 return 1;
609 } 612 }
613
614#ifndef MD32_REG_T
615#define MD32_REG_T long
616/*
617 * This comment was originaly written for MD5, which is why it
618 * discusses A-D. But it basically applies to all 32-bit digests,
619 * which is why it was moved to common header file.
620 *
621 * In case you wonder why A-D are declared as long and not
622 * as MD5_LONG. Doing so results in slight performance
623 * boost on LP64 architectures. The catch is we don't
624 * really care if 32 MSBs of a 64-bit register get polluted
625 * with eventual overflows as we *save* only 32 LSBs in
626 * *either* case. Now declaring 'em long excuses the compiler
627 * from keeping 32 MSBs zeroed resulting in 13% performance
628 * improvement under SPARC Solaris7/64 and 5% under AlphaLinux.
629 * Well, to be honest it should say that this *prevents*
630 * performance degradation.
631 * <appro@fy.chalmers.se>
632 * Apparently there're LP64 compilers that generate better
633 * code if A-D are declared int. Most notably GCC-x86_64
634 * generates better code.
635 * <appro@fy.chalmers.se>
636 */
637#endif
diff --git a/src/lib/libcrypto/md4/Makefile.ssl b/src/lib/libcrypto/md4/Makefile.ssl
index 1de72571d8..7d2e8d8d3b 100644
--- a/src/lib/libcrypto/md4/Makefile.ssl
+++ b/src/lib/libcrypto/md4/Makefile.ssl
@@ -69,7 +69,7 @@ lint:
69 lint -DLINT $(INCLUDES) $(SRC)>fluff 69 lint -DLINT $(INCLUDES) $(SRC)>fluff
70 70
71depend: 71depend:
72 $(MAKEDEPEND) $(CFLAG) $(INCLUDES) $(DEPFLAG) $(PROGS) $(LIBSRC) 72 $(MAKEDEPEND) -- $(CFLAG) $(INCLUDES) $(DEPFLAG) -- $(PROGS) $(LIBSRC)
73 73
74dclean: 74dclean:
75 $(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new 75 $(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
@@ -84,5 +84,8 @@ md4_dgst.o: ../../include/openssl/e_os2.h ../../include/openssl/md4.h
84md4_dgst.o: ../../include/openssl/opensslconf.h 84md4_dgst.o: ../../include/openssl/opensslconf.h
85md4_dgst.o: ../../include/openssl/opensslv.h ../md32_common.h md4_dgst.c 85md4_dgst.o: ../../include/openssl/opensslv.h ../md32_common.h md4_dgst.c
86md4_dgst.o: md4_locl.h 86md4_dgst.o: md4_locl.h
87md4_one.o: ../../include/openssl/e_os2.h ../../include/openssl/md4.h 87md4_one.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
88md4_one.o: ../../include/openssl/opensslconf.h md4_one.c 88md4_one.o: ../../include/openssl/md4.h ../../include/openssl/opensslconf.h
89md4_one.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
90md4_one.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
91md4_one.o: md4_one.c
diff --git a/src/lib/libcrypto/md4/md4.c b/src/lib/libcrypto/md4/md4.c
index e4b0aac011..141415ad4d 100644
--- a/src/lib/libcrypto/md4/md4.c
+++ b/src/lib/libcrypto/md4/md4.c
@@ -64,7 +64,7 @@
64 64
65void do_fp(FILE *f); 65void do_fp(FILE *f);
66void pt(unsigned char *md); 66void pt(unsigned char *md);
67#ifndef _OSD_POSIX 67#if !defined(_OSD_POSIX) && !defined(__DJGPP__)
68int read(int, void *, unsigned int); 68int read(int, void *, unsigned int);
69#endif 69#endif
70 70
@@ -108,7 +108,7 @@ void do_fp(FILE *f)
108 MD4_Init(&c); 108 MD4_Init(&c);
109 for (;;) 109 for (;;)
110 { 110 {
111 i=read(fd,buf,BUFSIZE); 111 i=read(fd,buf,sizeof buf);
112 if (i <= 0) break; 112 if (i <= 0) break;
113 MD4_Update(&c,buf,(unsigned long)i); 113 MD4_Update(&c,buf,(unsigned long)i);
114 } 114 }
diff --git a/src/lib/libcrypto/md4/md4_dgst.c b/src/lib/libcrypto/md4/md4_dgst.c
index 6446f5f5e7..7afb7185b6 100644
--- a/src/lib/libcrypto/md4/md4_dgst.c
+++ b/src/lib/libcrypto/md4/md4_dgst.c
@@ -86,21 +86,7 @@ int MD4_Init(MD4_CTX *c)
86void md4_block_host_order (MD4_CTX *c, const void *data, int num) 86void md4_block_host_order (MD4_CTX *c, const void *data, int num)
87 { 87 {
88 const MD4_LONG *X=data; 88 const MD4_LONG *X=data;
89 register unsigned long A,B,C,D; 89 register unsigned MD32_REG_T A,B,C,D;
90 /*
91 * In case you wonder why A-D are declared as long and not
92 * as MD4_LONG. Doing so results in slight performance
93 * boost on LP64 architectures. The catch is we don't
94 * really care if 32 MSBs of a 64-bit register get polluted
95 * with eventual overflows as we *save* only 32 LSBs in
96 * *either* case. Now declaring 'em long excuses the compiler
97 * from keeping 32 MSBs zeroed resulting in 13% performance
98 * improvement under SPARC Solaris7/64 and 5% under AlphaLinux.
99 * Well, to be honest it should say that this *prevents*
100 * performance degradation.
101 *
102 * <appro@fy.chalmers.se>
103 */
104 90
105 A=c->A; 91 A=c->A;
106 B=c->B; 92 B=c->B;
@@ -176,25 +162,11 @@ void md4_block_host_order (MD4_CTX *c, const void *data, int num)
176void md4_block_data_order (MD4_CTX *c, const void *data_, int num) 162void md4_block_data_order (MD4_CTX *c, const void *data_, int num)
177 { 163 {
178 const unsigned char *data=data_; 164 const unsigned char *data=data_;
179 register unsigned long A,B,C,D,l; 165 register unsigned MD32_REG_T A,B,C,D,l;
180 /*
181 * In case you wonder why A-D are declared as long and not
182 * as MD4_LONG. Doing so results in slight performance
183 * boost on LP64 architectures. The catch is we don't
184 * really care if 32 MSBs of a 64-bit register get polluted
185 * with eventual overflows as we *save* only 32 LSBs in
186 * *either* case. Now declaring 'em long excuses the compiler
187 * from keeping 32 MSBs zeroed resulting in 13% performance
188 * improvement under SPARC Solaris7/64 and 5% under AlphaLinux.
189 * Well, to be honest it should say that this *prevents*
190 * performance degradation.
191 *
192 * <appro@fy.chalmers.se>
193 */
194#ifndef MD32_XARRAY 166#ifndef MD32_XARRAY
195 /* See comment in crypto/sha/sha_locl.h for details. */ 167 /* See comment in crypto/sha/sha_locl.h for details. */
196 unsigned long XX0, XX1, XX2, XX3, XX4, XX5, XX6, XX7, 168 unsigned MD32_REG_T XX0, XX1, XX2, XX3, XX4, XX5, XX6, XX7,
197 XX8, XX9,XX10,XX11,XX12,XX13,XX14,XX15; 169 XX8, XX9,XX10,XX11,XX12,XX13,XX14,XX15;
198# define X(i) XX##i 170# define X(i) XX##i
199#else 171#else
200 MD4_LONG XX[MD4_LBLOCK]; 172 MD4_LONG XX[MD4_LBLOCK];
diff --git a/src/lib/libcrypto/md4/md4_one.c b/src/lib/libcrypto/md4/md4_one.c
index 87a995d38d..00565507e4 100644
--- a/src/lib/libcrypto/md4/md4_one.c
+++ b/src/lib/libcrypto/md4/md4_one.c
@@ -59,6 +59,7 @@
59#include <stdio.h> 59#include <stdio.h>
60#include <string.h> 60#include <string.h>
61#include <openssl/md4.h> 61#include <openssl/md4.h>
62#include <openssl/crypto.h>
62 63
63#ifdef CHARSET_EBCDIC 64#ifdef CHARSET_EBCDIC
64#include <openssl/ebcdic.h> 65#include <openssl/ebcdic.h>
@@ -89,7 +90,7 @@ unsigned char *MD4(const unsigned char *d, unsigned long n, unsigned char *md)
89 } 90 }
90#endif 91#endif
91 MD4_Final(md,&c); 92 MD4_Final(md,&c);
92 memset(&c,0,sizeof(c)); /* security consideration */ 93 OPENSSL_cleanse(&c,sizeof(c)); /* security consideration */
93 return(md); 94 return(md);
94 } 95 }
95 96
diff --git a/src/lib/libcrypto/md4/md4test.c b/src/lib/libcrypto/md4/md4test.c
index e0fdc42282..21a77d96f7 100644
--- a/src/lib/libcrypto/md4/md4test.c
+++ b/src/lib/libcrypto/md4/md4test.c
@@ -60,6 +60,8 @@
60#include <string.h> 60#include <string.h>
61#include <stdlib.h> 61#include <stdlib.h>
62 62
63#include "../e_os.h"
64
63#ifdef OPENSSL_NO_MD4 65#ifdef OPENSSL_NO_MD4
64int main(int argc, char *argv[]) 66int main(int argc, char *argv[])
65{ 67{
@@ -118,7 +120,7 @@ int main(int argc, char *argv[])
118 R++; 120 R++;
119 P++; 121 P++;
120 } 122 }
121 exit(err); 123 EXIT(err);
122 return(0); 124 return(0);
123 } 125 }
124 126
diff --git a/src/lib/libcrypto/md5/Makefile.ssl b/src/lib/libcrypto/md5/Makefile.ssl
index 5f1bbfb8ff..b11ab476d6 100644
--- a/src/lib/libcrypto/md5/Makefile.ssl
+++ b/src/lib/libcrypto/md5/Makefile.ssl
@@ -21,14 +21,6 @@ MD5_ASM_OBJ=
21 21
22CFLAGS= $(INCLUDES) $(CFLAG) 22CFLAGS= $(INCLUDES) $(CFLAG)
23 23
24# We let the C compiler driver to take care of .s files. This is done in
25# order to be excused from maintaining a separate set of architecture
26# dependent assembler flags. E.g. if you throw -mcpu=ultrasparc at SPARC
27# gcc, then the driver will automatically translate it to -xarch=v8plus
28# and pass it down to assembler.
29AS=$(CC) -c
30ASFLAGS=$(CFLAGS)
31
32GENERAL=Makefile 24GENERAL=Makefile
33TEST=md5test.c 25TEST=md5test.c
34APPS= 26APPS=
@@ -55,14 +47,8 @@ lib: $(LIBOBJ)
55 @touch lib 47 @touch lib
56 48
57# elf 49# elf
58asm/mx86-elf.o: asm/mx86unix.cpp 50asm/mx86-elf.s: asm/md5-586.pl ../perlasm/x86asm.pl
59 $(CPP) -DELF -x c asm/mx86unix.cpp | as -o asm/mx86-elf.o 51 (cd asm; $(PERL) md5-586.pl elf $(CFLAGS) > mx86-elf.s)
60
61# solaris
62asm/mx86-sol.o: asm/mx86unix.cpp
63 $(CC) -E -DSOL asm/mx86unix.cpp | sed 's/^#.*//' > asm/mx86-sol.s
64 as -o asm/mx86-sol.o asm/mx86-sol.s
65 rm -f asm/mx86-sol.s
66 52
67# a.out 53# a.out
68asm/mx86-out.o: asm/mx86unix.cpp 54asm/mx86-out.o: asm/mx86unix.cpp
@@ -118,18 +104,23 @@ lint:
118 lint -DLINT $(INCLUDES) $(SRC)>fluff 104 lint -DLINT $(INCLUDES) $(SRC)>fluff
119 105
120depend: 106depend:
121 $(MAKEDEPEND) $(CFLAG) $(INCLUDES) $(DEPFLAG) $(PROGS) $(LIBSRC) 107 $(MAKEDEPEND) -- $(CFLAG) $(INCLUDES) $(DEPFLAG) -- $(PROGS) $(LIBSRC)
122 108
123dclean: 109dclean:
124 $(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new 110 $(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
125 mv -f Makefile.new $(MAKEFILE) 111 mv -f Makefile.new $(MAKEFILE)
126 112
127clean: 113clean:
128 rm -f asm/mx86unix.cpp *.o asm/*.o *.obj lib tags core .pure .nfs* *.old *.bak fluff 114 rm -f asm/mx86unix.cpp asm/*-elf.* *.o asm/*.o *.obj lib tags core .pure .nfs* *.old *.bak fluff
129 115
130# DO NOT DELETE THIS LINE -- make depend depends on it. 116# DO NOT DELETE THIS LINE -- make depend depends on it.
131 117
132md5_dgst.o: ../../include/openssl/md5.h ../../include/openssl/opensslconf.h 118md5_dgst.o: ../../include/openssl/e_os2.h ../../include/openssl/md5.h
119md5_dgst.o: ../../include/openssl/opensslconf.h
133md5_dgst.o: ../../include/openssl/opensslv.h ../md32_common.h md5_dgst.c 120md5_dgst.o: ../../include/openssl/opensslv.h ../md32_common.h md5_dgst.c
134md5_dgst.o: md5_locl.h 121md5_dgst.o: md5_locl.h
135md5_one.o: ../../include/openssl/md5.h md5_one.c 122md5_one.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
123md5_one.o: ../../include/openssl/md5.h ../../include/openssl/opensslconf.h
124md5_one.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
125md5_one.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
126md5_one.o: md5_one.c
diff --git a/src/lib/libcrypto/md5/md5.c b/src/lib/libcrypto/md5/md5.c
index 7ed0024ae1..563733abc5 100644
--- a/src/lib/libcrypto/md5/md5.c
+++ b/src/lib/libcrypto/md5/md5.c
@@ -64,7 +64,7 @@
64 64
65void do_fp(FILE *f); 65void do_fp(FILE *f);
66void pt(unsigned char *md); 66void pt(unsigned char *md);
67#ifndef _OSD_POSIX 67#if !defined(_OSD_POSIX) && !defined(__DJGPP__)
68int read(int, void *, unsigned int); 68int read(int, void *, unsigned int);
69#endif 69#endif
70 70
diff --git a/src/lib/libcrypto/md5/md5.h b/src/lib/libcrypto/md5/md5.h
index 52cb753e6a..a252e02115 100644
--- a/src/lib/libcrypto/md5/md5.h
+++ b/src/lib/libcrypto/md5/md5.h
@@ -59,6 +59,8 @@
59#ifndef HEADER_MD5_H 59#ifndef HEADER_MD5_H
60#define HEADER_MD5_H 60#define HEADER_MD5_H
61 61
62#include <openssl/e_os2.h>
63
62#ifdef __cplusplus 64#ifdef __cplusplus
63extern "C" { 65extern "C" {
64#endif 66#endif
@@ -76,7 +78,7 @@ extern "C" {
76 78
77#if defined(OPENSSL_SYS_WIN16) || defined(__LP32__) 79#if defined(OPENSSL_SYS_WIN16) || defined(__LP32__)
78#define MD5_LONG unsigned long 80#define MD5_LONG unsigned long
79#elif defined(OENSSL_SYS_CRAY) || defined(__ILP64__) 81#elif defined(OPENSSL_SYS_CRAY) || defined(__ILP64__)
80#define MD5_LONG unsigned long 82#define MD5_LONG unsigned long
81#define MD5_LONG_LOG2 3 83#define MD5_LONG_LOG2 3
82/* 84/*
diff --git a/src/lib/libcrypto/md5/md5_dgst.c b/src/lib/libcrypto/md5/md5_dgst.c
index c38a3f021e..9c7abc3697 100644
--- a/src/lib/libcrypto/md5/md5_dgst.c
+++ b/src/lib/libcrypto/md5/md5_dgst.c
@@ -86,21 +86,7 @@ int MD5_Init(MD5_CTX *c)
86void md5_block_host_order (MD5_CTX *c, const void *data, int num) 86void md5_block_host_order (MD5_CTX *c, const void *data, int num)
87 { 87 {
88 const MD5_LONG *X=data; 88 const MD5_LONG *X=data;
89 register unsigned long A,B,C,D; 89 register unsigned MD32_REG_T A,B,C,D;
90 /*
91 * In case you wonder why A-D are declared as long and not
92 * as MD5_LONG. Doing so results in slight performance
93 * boost on LP64 architectures. The catch is we don't
94 * really care if 32 MSBs of a 64-bit register get polluted
95 * with eventual overflows as we *save* only 32 LSBs in
96 * *either* case. Now declaring 'em long excuses the compiler
97 * from keeping 32 MSBs zeroed resulting in 13% performance
98 * improvement under SPARC Solaris7/64 and 5% under AlphaLinux.
99 * Well, to be honest it should say that this *prevents*
100 * performance degradation.
101 *
102 * <appro@fy.chalmers.se>
103 */
104 90
105 A=c->A; 91 A=c->A;
106 B=c->B; 92 B=c->B;
@@ -193,25 +179,11 @@ void md5_block_host_order (MD5_CTX *c, const void *data, int num)
193void md5_block_data_order (MD5_CTX *c, const void *data_, int num) 179void md5_block_data_order (MD5_CTX *c, const void *data_, int num)
194 { 180 {
195 const unsigned char *data=data_; 181 const unsigned char *data=data_;
196 register unsigned long A,B,C,D,l; 182 register unsigned MD32_REG_T A,B,C,D,l;
197 /*
198 * In case you wonder why A-D are declared as long and not
199 * as MD5_LONG. Doing so results in slight performance
200 * boost on LP64 architectures. The catch is we don't
201 * really care if 32 MSBs of a 64-bit register get polluted
202 * with eventual overflows as we *save* only 32 LSBs in
203 * *either* case. Now declaring 'em long excuses the compiler
204 * from keeping 32 MSBs zeroed resulting in 13% performance
205 * improvement under SPARC Solaris7/64 and 5% under AlphaLinux.
206 * Well, to be honest it should say that this *prevents*
207 * performance degradation.
208 *
209 * <appro@fy.chalmers.se>
210 */
211#ifndef MD32_XARRAY 183#ifndef MD32_XARRAY
212 /* See comment in crypto/sha/sha_locl.h for details. */ 184 /* See comment in crypto/sha/sha_locl.h for details. */
213 unsigned long XX0, XX1, XX2, XX3, XX4, XX5, XX6, XX7, 185 unsigned MD32_REG_T XX0, XX1, XX2, XX3, XX4, XX5, XX6, XX7,
214 XX8, XX9,XX10,XX11,XX12,XX13,XX14,XX15; 186 XX8, XX9,XX10,XX11,XX12,XX13,XX14,XX15;
215# define X(i) XX##i 187# define X(i) XX##i
216#else 188#else
217 MD5_LONG XX[MD5_LBLOCK]; 189 MD5_LONG XX[MD5_LBLOCK];
diff --git a/src/lib/libcrypto/md5/md5_locl.h b/src/lib/libcrypto/md5/md5_locl.h
index 34c5257306..9e360da732 100644
--- a/src/lib/libcrypto/md5/md5_locl.h
+++ b/src/lib/libcrypto/md5/md5_locl.h
@@ -58,7 +58,7 @@
58 58
59#include <stdlib.h> 59#include <stdlib.h>
60#include <string.h> 60#include <string.h>
61#include <openssl/opensslconf.h> 61#include <openssl/e_os2.h>
62#include <openssl/md5.h> 62#include <openssl/md5.h>
63 63
64#ifndef MD5_LONG_LOG2 64#ifndef MD5_LONG_LOG2
diff --git a/src/lib/libcrypto/md5/md5_one.c b/src/lib/libcrypto/md5/md5_one.c
index b89dec850d..c5dd2d81db 100644
--- a/src/lib/libcrypto/md5/md5_one.c
+++ b/src/lib/libcrypto/md5/md5_one.c
@@ -59,6 +59,7 @@
59#include <stdio.h> 59#include <stdio.h>
60#include <string.h> 60#include <string.h>
61#include <openssl/md5.h> 61#include <openssl/md5.h>
62#include <openssl/crypto.h>
62 63
63#ifdef CHARSET_EBCDIC 64#ifdef CHARSET_EBCDIC
64#include <openssl/ebcdic.h> 65#include <openssl/ebcdic.h>
@@ -89,7 +90,7 @@ unsigned char *MD5(const unsigned char *d, unsigned long n, unsigned char *md)
89 } 90 }
90#endif 91#endif
91 MD5_Final(md,&c); 92 MD5_Final(md,&c);
92 memset(&c,0,sizeof(c)); /* security consideration */ 93 OPENSSL_cleanse(&c,sizeof(c)); /* security consideration */
93 return(md); 94 return(md);
94 } 95 }
95 96
diff --git a/src/lib/libcrypto/md5/md5test.c b/src/lib/libcrypto/md5/md5test.c
index 862b89658a..bfd62629ed 100644
--- a/src/lib/libcrypto/md5/md5test.c
+++ b/src/lib/libcrypto/md5/md5test.c
@@ -60,6 +60,8 @@
60#include <string.h> 60#include <string.h>
61#include <stdlib.h> 61#include <stdlib.h>
62 62
63#include "../e_os.h"
64
63#ifdef OPENSSL_NO_MD5 65#ifdef OPENSSL_NO_MD5
64int main(int argc, char *argv[]) 66int main(int argc, char *argv[])
65{ 67{
@@ -118,7 +120,7 @@ int main(int argc, char *argv[])
118 R++; 120 R++;
119 P++; 121 P++;
120 } 122 }
121 exit(err); 123 EXIT(err);
122 return(0); 124 return(0);
123 } 125 }
124 126
diff --git a/src/lib/libcrypto/mdc2/Makefile.ssl b/src/lib/libcrypto/mdc2/Makefile.ssl
index 087b8eb9ee..33f366fb08 100644
--- a/src/lib/libcrypto/mdc2/Makefile.ssl
+++ b/src/lib/libcrypto/mdc2/Makefile.ssl
@@ -68,7 +68,7 @@ lint:
68 lint -DLINT $(INCLUDES) $(SRC)>fluff 68 lint -DLINT $(INCLUDES) $(SRC)>fluff
69 69
70depend: 70depend:
71 $(MAKEDEPEND) $(CFLAG) $(INCLUDES) $(DEPFLAG) $(PROGS) $(LIBSRC) 71 $(MAKEDEPEND) -- $(CFLAG) $(INCLUDES) $(DEPFLAG) -- $(PROGS) $(LIBSRC)
72 72
73dclean: 73dclean:
74 $(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new 74 $(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
diff --git a/src/lib/libcrypto/mem.c b/src/lib/libcrypto/mem.c
index 87d0ebc714..29df7d35b2 100644
--- a/src/lib/libcrypto/mem.c
+++ b/src/lib/libcrypto/mem.c
@@ -250,6 +250,7 @@ void CRYPTO_get_mem_debug_functions(void (**m)(void *,int,const char *,int,int),
250void *CRYPTO_malloc_locked(int num, const char *file, int line) 250void *CRYPTO_malloc_locked(int num, const char *file, int line)
251 { 251 {
252 void *ret = NULL; 252 void *ret = NULL;
253 extern unsigned char cleanse_ctr;
253 254
254 if (num < 0) return NULL; 255 if (num < 0) return NULL;
255 256
@@ -266,6 +267,12 @@ void *CRYPTO_malloc_locked(int num, const char *file, int line)
266 if (malloc_debug_func != NULL) 267 if (malloc_debug_func != NULL)
267 malloc_debug_func(ret, num, file, line, 1); 268 malloc_debug_func(ret, num, file, line, 1);
268 269
270 /* Create a dependency on the value of 'cleanse_ctr' so our memory
271 * sanitisation function can't be optimised out. NB: We only do
272 * this for >2Kb so the overhead doesn't bother us. */
273 if(ret && (num > 2048))
274 ((unsigned char *)ret)[0] = cleanse_ctr;
275
269 return ret; 276 return ret;
270 } 277 }
271 278
@@ -284,6 +291,7 @@ void CRYPTO_free_locked(void *str)
284void *CRYPTO_malloc(int num, const char *file, int line) 291void *CRYPTO_malloc(int num, const char *file, int line)
285 { 292 {
286 void *ret = NULL; 293 void *ret = NULL;
294 extern unsigned char cleanse_ctr;
287 295
288 if (num < 0) return NULL; 296 if (num < 0) return NULL;
289 297
@@ -300,6 +308,12 @@ void *CRYPTO_malloc(int num, const char *file, int line)
300 if (malloc_debug_func != NULL) 308 if (malloc_debug_func != NULL)
301 malloc_debug_func(ret, num, file, line, 1); 309 malloc_debug_func(ret, num, file, line, 1);
302 310
311 /* Create a dependency on the value of 'cleanse_ctr' so our memory
312 * sanitisation function can't be optimised out. NB: We only do
313 * this for >2Kb so the overhead doesn't bother us. */
314 if(ret && (num > 2048))
315 ((unsigned char *)ret)[0] = cleanse_ctr;
316
303 return ret; 317 return ret;
304 } 318 }
305 319
@@ -310,8 +324,8 @@ void *CRYPTO_realloc(void *str, int num, const char *file, int line)
310 if (str == NULL) 324 if (str == NULL)
311 return CRYPTO_malloc(num, file, line); 325 return CRYPTO_malloc(num, file, line);
312 326
313 if (num < 0) return NULL; 327 if (num < 0) return NULL;
314 328
315 if (realloc_debug_func != NULL) 329 if (realloc_debug_func != NULL)
316 realloc_debug_func(str, NULL, num, file, line, 0); 330 realloc_debug_func(str, NULL, num, file, line, 0);
317 ret = realloc_ex_func(str,num,file,line); 331 ret = realloc_ex_func(str,num,file,line);
@@ -324,6 +338,32 @@ void *CRYPTO_realloc(void *str, int num, const char *file, int line)
324 return ret; 338 return ret;
325 } 339 }
326 340
341void *CRYPTO_realloc_clean(void *str, int old_len, int num, const char *file,
342 int line)
343 {
344 void *ret = NULL;
345
346 if (str == NULL)
347 return CRYPTO_malloc(num, file, line);
348
349 if (num < 0) return NULL;
350
351 if (realloc_debug_func != NULL)
352 realloc_debug_func(str, NULL, num, file, line, 0);
353 ret=malloc_ex_func(num,file,line);
354 if(ret)
355 memcpy(ret,str,old_len);
356 OPENSSL_cleanse(str,old_len);
357 free_func(str);
358#ifdef LEVITTE_DEBUG_MEM
359 fprintf(stderr, "LEVITTE_DEBUG_MEM: | 0x%p -> 0x%p (%d)\n", str, ret, num);
360#endif
361 if (realloc_debug_func != NULL)
362 realloc_debug_func(str, ret, num, file, line, 1);
363
364 return ret;
365 }
366
327void CRYPTO_free(void *str) 367void CRYPTO_free(void *str)
328 { 368 {
329 if (free_debug_func != NULL) 369 if (free_debug_func != NULL)
@@ -343,7 +383,6 @@ void *CRYPTO_remalloc(void *a, int num, const char *file, int line)
343 return(a); 383 return(a);
344 } 384 }
345 385
346
347void CRYPTO_set_mem_debug_options(long bits) 386void CRYPTO_set_mem_debug_options(long bits)
348 { 387 {
349 if (set_debug_options_func != NULL) 388 if (set_debug_options_func != NULL)
diff --git a/src/lib/libcrypto/mem_dbg.c b/src/lib/libcrypto/mem_dbg.c
index ea94eee6f4..9221df00bd 100644
--- a/src/lib/libcrypto/mem_dbg.c
+++ b/src/lib/libcrypto/mem_dbg.c
@@ -102,6 +102,8 @@ typedef struct app_mem_info_st
102 int references; 102 int references;
103 } APP_INFO; 103 } APP_INFO;
104 104
105static void app_info_free(APP_INFO *);
106
105static LHASH *amih=NULL; /* hash-table with those app_mem_info_st's 107static LHASH *amih=NULL; /* hash-table with those app_mem_info_st's
106 * that are at the top of their thread's stack 108 * that are at the top of their thread's stack
107 * (with `thread' as key); 109 * (with `thread' as key);
@@ -140,6 +142,18 @@ static unsigned long disabling_thread = 0; /* Valid iff num_disable > 0.
140 * thread named in disabling_thread). 142 * thread named in disabling_thread).
141 */ 143 */
142 144
145static void app_info_free(APP_INFO *inf)
146 {
147 if (--(inf->references) <= 0)
148 {
149 if (inf->next != NULL)
150 {
151 app_info_free(inf->next);
152 }
153 OPENSSL_free(inf);
154 }
155 }
156
143int CRYPTO_mem_ctrl(int mode) 157int CRYPTO_mem_ctrl(int mode)
144 { 158 {
145 int ret=mh_mode; 159 int ret=mh_mode;
@@ -502,9 +516,7 @@ void CRYPTO_dbg_free(void *addr, int before_p)
502 mp->order, mp->addr, mp->num); 516 mp->order, mp->addr, mp->num);
503#endif 517#endif
504 if (mp->app_info != NULL) 518 if (mp->app_info != NULL)
505 { 519 app_info_free(mp->app_info);
506 mp->app_info->references--;
507 }
508 OPENSSL_free(mp); 520 OPENSSL_free(mp);
509 } 521 }
510 522
@@ -669,7 +681,6 @@ static IMPLEMENT_LHASH_DOALL_ARG_FN(print_leak, const MEM *, MEM_LEAK *)
669void CRYPTO_mem_leaks(BIO *b) 681void CRYPTO_mem_leaks(BIO *b)
670 { 682 {
671 MEM_LEAK ml; 683 MEM_LEAK ml;
672 char buf[80];
673 684
674 if (mh == NULL && amih == NULL) 685 if (mh == NULL && amih == NULL)
675 return; 686 return;
@@ -684,9 +695,8 @@ void CRYPTO_mem_leaks(BIO *b)
684 (char *)&ml); 695 (char *)&ml);
685 if (ml.chunks != 0) 696 if (ml.chunks != 0)
686 { 697 {
687 snprintf(buf,sizeof buf,"%ld bytes leaked in %d chunks\n", 698 BIO_printf(b,"%ld bytes leaked in %d chunks\n",
688 ml.bytes,ml.chunks); 699 ml.bytes,ml.chunks);
689 BIO_puts(b,buf);
690 } 700 }
691 else 701 else
692 { 702 {
diff --git a/src/lib/libcrypto/o_time.c b/src/lib/libcrypto/o_time.c
index 1bc0297b36..723eb1b5af 100644
--- a/src/lib/libcrypto/o_time.c
+++ b/src/lib/libcrypto/o_time.c
@@ -80,6 +80,9 @@ struct tm *OPENSSL_gmtime(const time_t *timer, struct tm *result)
80 ts = result; 80 ts = result;
81#elif !defined(OPENSSL_SYS_VMS) 81#elif !defined(OPENSSL_SYS_VMS)
82 ts = gmtime(timer); 82 ts = gmtime(timer);
83 if (ts == NULL)
84 return NULL;
85
83 memcpy(result, ts, sizeof(struct tm)); 86 memcpy(result, ts, sizeof(struct tm));
84 ts = result; 87 ts = result;
85#endif 88#endif
diff --git a/src/lib/libcrypto/objects/Makefile.ssl b/src/lib/libcrypto/objects/Makefile.ssl
index cd5cbc95ce..3e7a194cf9 100644
--- a/src/lib/libcrypto/objects/Makefile.ssl
+++ b/src/lib/libcrypto/objects/Makefile.ssl
@@ -76,7 +76,7 @@ lint:
76 lint -DLINT $(INCLUDES) $(SRC)>fluff 76 lint -DLINT $(INCLUDES) $(SRC)>fluff
77 77
78depend: 78depend:
79 $(MAKEDEPEND) $(CFLAG) $(INCLUDES) $(DEPFLAG) $(PROGS) $(LIBSRC) 79 $(MAKEDEPEND) -- $(CFLAG) $(INCLUDES) $(DEPFLAG) -- $(PROGS) $(LIBSRC)
80 80
81dclean: 81dclean:
82 $(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new 82 $(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
diff --git a/src/lib/libcrypto/objects/obj_dat.c b/src/lib/libcrypto/objects/obj_dat.c
index 202bd168ac..ae97108e93 100644
--- a/src/lib/libcrypto/objects/obj_dat.c
+++ b/src/lib/libcrypto/objects/obj_dat.c
@@ -464,7 +464,7 @@ int OBJ_obj2txt(char *buf, int buf_len, const ASN1_OBJECT *a, int no_name)
464 464
465 snprintf(tbuf,sizeof tbuf,"%d.%lu",i,l); 465 snprintf(tbuf,sizeof tbuf,"%d.%lu",i,l);
466 i=strlen(tbuf); 466 i=strlen(tbuf);
467 strncpy(buf,tbuf,buf_len); 467 BUF_strlcpy(buf,tbuf,buf_len);
468 buf_len-=i; 468 buf_len-=i;
469 buf+=i; 469 buf+=i;
470 n+=i; 470 n+=i;
@@ -476,7 +476,7 @@ int OBJ_obj2txt(char *buf, int buf_len, const ASN1_OBJECT *a, int no_name)
476 snprintf(tbuf,sizeof tbuf,".%lu",l); 476 snprintf(tbuf,sizeof tbuf,".%lu",l);
477 i=strlen(tbuf); 477 i=strlen(tbuf);
478 if (buf_len > 0) 478 if (buf_len > 0)
479 strncpy(buf,tbuf,buf_len); 479 BUF_strlcpy(buf,tbuf,buf_len);
480 buf_len-=i; 480 buf_len-=i;
481 buf+=i; 481 buf+=i;
482 n+=i; 482 n+=i;
@@ -488,10 +488,9 @@ int OBJ_obj2txt(char *buf, int buf_len, const ASN1_OBJECT *a, int no_name)
488 s=OBJ_nid2ln(nid); 488 s=OBJ_nid2ln(nid);
489 if (s == NULL) 489 if (s == NULL)
490 s=OBJ_nid2sn(nid); 490 s=OBJ_nid2sn(nid);
491 strncpy(buf,s,buf_len); 491 BUF_strlcpy(buf,s,buf_len);
492 n=strlen(s); 492 n=strlen(s);
493 } 493 }
494 buf[buf_len-1]='\0';
495 return(n); 494 return(n);
496} 495}
497 496
diff --git a/src/lib/libcrypto/objects/obj_mac.num b/src/lib/libcrypto/objects/obj_mac.num
index 1486199661..9838072b65 100644
--- a/src/lib/libcrypto/objects/obj_mac.num
+++ b/src/lib/libcrypto/objects/obj_mac.num
@@ -645,3 +645,5 @@ rsaOAEPEncryptionSET 644
645itu_t 645 645itu_t 645
646joint_iso_itu_t 646 646joint_iso_itu_t 646
647international_organizations 647 647international_organizations 647
648ms_smartcard_login 648
649ms_upn 649
diff --git a/src/lib/libcrypto/objects/objects.txt b/src/lib/libcrypto/objects/objects.txt
index 71a4908485..3ba11f65cc 100644
--- a/src/lib/libcrypto/objects/objects.txt
+++ b/src/lib/libcrypto/objects/objects.txt
@@ -276,6 +276,10 @@ rsadsi 3 8 : RC5-CBC : rc5-cbc
2761 3 6 1 4 1 311 10 3 3 : msSGC : Microsoft Server Gated Crypto 2761 3 6 1 4 1 311 10 3 3 : msSGC : Microsoft Server Gated Crypto
277!Cname ms-efs 277!Cname ms-efs
2781 3 6 1 4 1 311 10 3 4 : msEFS : Microsoft Encrypted File System 2781 3 6 1 4 1 311 10 3 4 : msEFS : Microsoft Encrypted File System
279!Cname ms-smartcard-login
2801 3 6 1 4 1 311 20 2 2 : msSmartcardLogin : Microsoft Smartcardlogin
281!Cname ms-upn
2821 3 6 1 4 1 311 20 2 3 : msUPN : Microsoft Universal Principal Name
279 283
2801 3 6 1 4 1 188 7 1 1 2 : IDEA-CBC : idea-cbc 2841 3 6 1 4 1 188 7 1 1 2 : IDEA-CBC : idea-cbc
281 : IDEA-ECB : idea-ecb 285 : IDEA-ECB : idea-ecb
@@ -537,7 +541,7 @@ X509 11 : OU : organizationalUnitName
537X509 12 : : title 541X509 12 : : title
538X509 13 : : description 542X509 13 : : description
539X509 41 : name : name 543X509 41 : name : name
540X509 42 : gn : givenName 544X509 42 : GN : givenName
541X509 43 : : initials 545X509 43 : : initials
542X509 44 : : generationQualifier 546X509 44 : : generationQualifier
543X509 45 : : x500UniqueIdentifier 547X509 45 : : x500UniqueIdentifier
diff --git a/src/lib/libcrypto/ocsp/Makefile.ssl b/src/lib/libcrypto/ocsp/Makefile.ssl
index 2be98179ae..02477be538 100644
--- a/src/lib/libcrypto/ocsp/Makefile.ssl
+++ b/src/lib/libcrypto/ocsp/Makefile.ssl
@@ -43,7 +43,7 @@ all: lib
43 43
44lib: $(LIBOBJ) 44lib: $(LIBOBJ)
45 $(AR) $(LIB) $(LIBOBJ) 45 $(AR) $(LIB) $(LIBOBJ)
46 $(RANLIB) $(LIB) 46 $(RANLIB) $(LIB) || echo Never mind.
47 @touch lib 47 @touch lib
48 48
49files: 49files:
@@ -71,7 +71,7 @@ lint:
71 lint -DLINT $(INCLUDES) $(SRC)>fluff 71 lint -DLINT $(INCLUDES) $(SRC)>fluff
72 72
73depend: 73depend:
74 $(MAKEDEPEND) $(CFLAG) $(INCLUDES) $(DEPFLAG) $(LIBSRC) 74 $(MAKEDEPEND) -- $(CFLAG) $(INCLUDES) $(DEPFLAG) -- $(LIBSRC)
75 75
76dclean: 76dclean:
77 $(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new 77 $(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
diff --git a/src/lib/libcrypto/ocsp/ocsp_asn.c b/src/lib/libcrypto/ocsp/ocsp_asn.c
index 8c148cda6a..6a3a360d54 100644
--- a/src/lib/libcrypto/ocsp/ocsp_asn.c
+++ b/src/lib/libcrypto/ocsp/ocsp_asn.c
@@ -117,7 +117,7 @@ IMPLEMENT_ASN1_FUNCTIONS(OCSP_RESPONSE)
117 117
118ASN1_CHOICE(OCSP_RESPID) = { 118ASN1_CHOICE(OCSP_RESPID) = {
119 ASN1_EXP(OCSP_RESPID, value.byName, X509_NAME, 1), 119 ASN1_EXP(OCSP_RESPID, value.byName, X509_NAME, 1),
120 ASN1_IMP(OCSP_RESPID, value.byKey, ASN1_OCTET_STRING, 2) 120 ASN1_EXP(OCSP_RESPID, value.byKey, ASN1_OCTET_STRING, 2)
121} ASN1_CHOICE_END(OCSP_RESPID) 121} ASN1_CHOICE_END(OCSP_RESPID)
122 122
123IMPLEMENT_ASN1_FUNCTIONS(OCSP_RESPID) 123IMPLEMENT_ASN1_FUNCTIONS(OCSP_RESPID)
diff --git a/src/lib/libcrypto/ocsp/ocsp_ht.c b/src/lib/libcrypto/ocsp/ocsp_ht.c
index b78cd37092..9213e58ae4 100644
--- a/src/lib/libcrypto/ocsp/ocsp_ht.c
+++ b/src/lib/libcrypto/ocsp/ocsp_ht.c
@@ -64,6 +64,9 @@
64#include <openssl/ocsp.h> 64#include <openssl/ocsp.h>
65#include <openssl/err.h> 65#include <openssl/err.h>
66#include <openssl/buffer.h> 66#include <openssl/buffer.h>
67#ifdef OPENSSL_SYS_SUNOS
68#define strtoul (unsigned long)strtol
69#endif /* OPENSSL_SYS_SUNOS */
67 70
68/* Quick and dirty HTTP OCSP request handler. 71/* Quick and dirty HTTP OCSP request handler.
69 * Could make this a bit cleverer by adding 72 * Could make this a bit cleverer by adding
@@ -94,7 +97,7 @@ Content-Length: %d\r\n\r\n";
94 } 97 }
95 if(!(mem = BIO_new(BIO_s_mem()))) goto err; 98 if(!(mem = BIO_new(BIO_s_mem()))) goto err;
96 /* Copy response to a memory BIO: socket bios can't do gets! */ 99 /* Copy response to a memory BIO: socket bios can't do gets! */
97 while ((len = BIO_read(b, tmpbuf, 1024))) { 100 while ((len = BIO_read(b, tmpbuf, sizeof tmpbuf))) {
98 if(len < 0) { 101 if(len < 0) {
99 OCSPerr(OCSP_F_OCSP_SENDREQ_BIO,OCSP_R_SERVER_READ_ERROR); 102 OCSPerr(OCSP_F_OCSP_SENDREQ_BIO,OCSP_R_SERVER_READ_ERROR);
100 goto err; 103 goto err;
@@ -107,7 +110,7 @@ Content-Length: %d\r\n\r\n";
107 } 110 }
108 /* Parse the HTTP response. This will look like this: 111 /* Parse the HTTP response. This will look like this:
109 * "HTTP/1.0 200 OK". We need to obtain the numeric code and 112 * "HTTP/1.0 200 OK". We need to obtain the numeric code and
110 * informational message. 113 * (optional) informational message.
111 */ 114 */
112 115
113 /* Skip to first white space (passed protocol info) */ 116 /* Skip to first white space (passed protocol info) */
@@ -135,13 +138,19 @@ Content-Length: %d\r\n\r\n";
135 if(*r) goto err; 138 if(*r) goto err;
136 /* Skip over any leading white space in message */ 139 /* Skip over any leading white space in message */
137 while(*q && isspace((unsigned char)*q)) q++; 140 while(*q && isspace((unsigned char)*q)) q++;
138 if(!*q) goto err; 141 if(*q) {
139 /* Finally zap any trailing white space in message (include CRLF) */ 142 /* Finally zap any trailing white space in message (include CRLF) */
140 /* We know q has a non white space character so this is OK */ 143 /* We know q has a non white space character so this is OK */
141 for(r = q + strlen(q) - 1; isspace((unsigned char)*r); r--) *r = 0; 144 for(r = q + strlen(q) - 1; isspace((unsigned char)*r); r--) *r = 0;
145 }
142 if(retcode != 200) { 146 if(retcode != 200) {
143 OCSPerr(OCSP_F_OCSP_SENDREQ_BIO,OCSP_R_SERVER_RESPONSE_ERROR); 147 OCSPerr(OCSP_F_OCSP_SENDREQ_BIO,OCSP_R_SERVER_RESPONSE_ERROR);
144 ERR_add_error_data(4, "Code=", p, ",Reason=", q); 148 if(!*q) {
149 ERR_add_error_data(2, "Code=", p);
150 }
151 else {
152 ERR_add_error_data(4, "Code=", p, ",Reason=", q);
153 }
145 goto err; 154 goto err;
146 } 155 }
147 /* Find blank line marking beginning of content */ 156 /* Find blank line marking beginning of content */
diff --git a/src/lib/libcrypto/opensslconf.h.in b/src/lib/libcrypto/opensslconf.h.in
index 9082a16c46..685e83b7a3 100644
--- a/src/lib/libcrypto/opensslconf.h.in
+++ b/src/lib/libcrypto/opensslconf.h.in
@@ -47,7 +47,7 @@
47#endif 47#endif
48#endif 48#endif
49 49
50#if (defined(HEADER_DES_H) || defined(HEADER_DES_OLD_H)) && !defined(DES_LONG) 50#if (defined(HEADER_NEW_DES_H) || defined(HEADER_DES_H)) && !defined(DES_LONG)
51/* If this is set to 'unsigned int' on a DEC Alpha, this gives about a 51/* If this is set to 'unsigned int' on a DEC Alpha, this gives about a
52 * %20 speed up (longs are 8 bytes, int's are 4). */ 52 * %20 speed up (longs are 8 bytes, int's are 4). */
53#ifndef DES_LONG 53#ifndef DES_LONG
diff --git a/src/lib/libcrypto/opensslv.h b/src/lib/libcrypto/opensslv.h
index 9689b49c5b..08cb1d5018 100644
--- a/src/lib/libcrypto/opensslv.h
+++ b/src/lib/libcrypto/opensslv.h
@@ -25,8 +25,8 @@
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 0x00907003L 28#define OPENSSL_VERSION_NUMBER 0x0090702fL
29#define OPENSSL_VERSION_TEXT "OpenSSL 0.9.7-beta3 30 Jul 2002" 29#define OPENSSL_VERSION_TEXT "OpenSSL 0.9.7b 10 Apr 2003"
30#define OPENSSL_VERSION_PTEXT " part of " OPENSSL_VERSION_TEXT 30#define OPENSSL_VERSION_PTEXT " part of " OPENSSL_VERSION_TEXT
31 31
32 32
diff --git a/src/lib/libcrypto/ossl_typ.h b/src/lib/libcrypto/ossl_typ.h
index 6bd42aee4d..285fd0b1d9 100644
--- a/src/lib/libcrypto/ossl_typ.h
+++ b/src/lib/libcrypto/ossl_typ.h
@@ -55,6 +55,8 @@
55#ifndef HEADER_OPENSSL_TYPES_H 55#ifndef HEADER_OPENSSL_TYPES_H
56#define HEADER_OPENSSL_TYPES_H 56#define HEADER_OPENSSL_TYPES_H
57 57
58#include <openssl/e_os2.h>
59
58#ifdef NO_ASN1_TYPEDEFS 60#ifdef NO_ASN1_TYPEDEFS
59#define ASN1_INTEGER ASN1_STRING 61#define ASN1_INTEGER ASN1_STRING
60#define ASN1_ENUMERATED ASN1_STRING 62#define ASN1_ENUMERATED ASN1_STRING
diff --git a/src/lib/libcrypto/pem/Makefile.ssl b/src/lib/libcrypto/pem/Makefile.ssl
index 5075d9107b..d3043eb401 100644
--- a/src/lib/libcrypto/pem/Makefile.ssl
+++ b/src/lib/libcrypto/pem/Makefile.ssl
@@ -71,7 +71,7 @@ lint:
71 lint -DLINT $(INCLUDES) $(SRC)>fluff 71 lint -DLINT $(INCLUDES) $(SRC)>fluff
72 72
73depend: 73depend:
74 $(MAKEDEPEND) $(CFLAG) $(INCLUDES) $(DEPFLAG) $(LIBSRC) 74 $(MAKEDEPEND) -- $(CFLAG) $(INCLUDES) $(DEPFLAG) -- $(LIBSRC)
75 75
76dclean: 76dclean:
77 $(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new 77 $(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
diff --git a/src/lib/libcrypto/pem/pem.h b/src/lib/libcrypto/pem/pem.h
index 3785fca77d..d330cbf9a3 100644
--- a/src/lib/libcrypto/pem/pem.h
+++ b/src/lib/libcrypto/pem/pem.h
@@ -149,7 +149,7 @@ typedef struct pem_recip_st
149 149
150 int cipher; 150 int cipher;
151 int key_enc; 151 int key_enc;
152 char iv[8]; 152 /* char iv[8]; unused and wrong size */
153 } PEM_USER; 153 } PEM_USER;
154 154
155typedef struct pem_ctx_st 155typedef struct pem_ctx_st
@@ -165,7 +165,8 @@ typedef struct pem_ctx_st
165 165
166 struct { 166 struct {
167 int cipher; 167 int cipher;
168 unsigned char iv[8]; 168 /* unused, and wrong size
169 unsigned char iv[8]; */
169 } DEK_info; 170 } DEK_info;
170 171
171 PEM_USER *originator; 172 PEM_USER *originator;
@@ -187,7 +188,8 @@ typedef struct pem_ctx_st
187 EVP_CIPHER *dec; /* date encryption cipher */ 188 EVP_CIPHER *dec; /* date encryption cipher */
188 int key_len; /* key length */ 189 int key_len; /* key length */
189 unsigned char *key; /* key */ 190 unsigned char *key; /* key */
190 unsigned char iv[8]; /* the iv */ 191 /* unused, and wrong size
192 unsigned char iv[8]; */
191 193
192 194
193 int data_enc; /* is the data encrypted */ 195 int data_enc; /* is the data encrypted */
diff --git a/src/lib/libcrypto/pem/pem_info.c b/src/lib/libcrypto/pem/pem_info.c
index 9a6dffb45c..9e4af29c95 100644
--- a/src/lib/libcrypto/pem/pem_info.c
+++ b/src/lib/libcrypto/pem/pem_info.c
@@ -324,6 +324,7 @@ int PEM_X509_INFO_write_bio(BIO *bp, X509_INFO *xi, EVP_CIPHER *enc,
324 } 324 }
325 325
326 /* create the right magic header stuff */ 326 /* create the right magic header stuff */
327 OPENSSL_assert(strlen(objstr)+23+2*enc->iv_len+13 <= sizeof buf);
327 buf[0]='\0'; 328 buf[0]='\0';
328 PEM_proc_type(buf,PEM_TYPE_ENCRYPTED); 329 PEM_proc_type(buf,PEM_TYPE_ENCRYPTED);
329 PEM_dek_info(buf,objstr,enc->iv_len,(char *)iv); 330 PEM_dek_info(buf,objstr,enc->iv_len,(char *)iv);
@@ -358,7 +359,7 @@ int PEM_X509_INFO_write_bio(BIO *bp, X509_INFO *xi, EVP_CIPHER *enc,
358 ret=1; 359 ret=1;
359 360
360err: 361err:
361 memset((char *)&ctx,0,sizeof(ctx)); 362 OPENSSL_cleanse((char *)&ctx,sizeof(ctx));
362 memset(buf,0,PEM_BUFSIZE); 363 OPENSSL_cleanse(buf,PEM_BUFSIZE);
363 return(ret); 364 return(ret);
364 } 365 }
diff --git a/src/lib/libcrypto/pem/pem_lib.c b/src/lib/libcrypto/pem/pem_lib.c
index 50f5733654..3bec2d7e9f 100644
--- a/src/lib/libcrypto/pem/pem_lib.c
+++ b/src/lib/libcrypto/pem/pem_lib.c
@@ -138,7 +138,7 @@ void PEM_proc_type(char *buf, int type)
138 138
139void PEM_dek_info(char *buf, const char *type, int len, char *str) 139void PEM_dek_info(char *buf, const char *type, int len, char *str)
140 { 140 {
141 static unsigned char map[17]="0123456789ABCDEF"; 141 static const unsigned char map[17]="0123456789ABCDEF";
142 long i; 142 long i;
143 int j; 143 int j;
144 144
@@ -251,7 +251,7 @@ int PEM_bytes_read_bio(unsigned char **pdata, long *plen, char **pnm, const char
251 ret = 1; 251 ret = 1;
252 252
253err: 253err:
254 if (!pnm) OPENSSL_free(nm); 254 if (!ret || !pnm) OPENSSL_free(nm);
255 OPENSSL_free(header); 255 OPENSSL_free(header);
256 if (!ret) OPENSSL_free(data); 256 if (!ret) OPENSSL_free(data);
257 return ret; 257 return ret;
@@ -306,6 +306,7 @@ int PEM_ASN1_write_bio(int (*i2d)(), const char *name, BIO *bp, char *x,
306 goto err; 306 goto err;
307 } 307 }
308 /* dzise + 8 bytes are needed */ 308 /* dzise + 8 bytes are needed */
309 /* actually it needs the cipher block size extra... */
309 data=(unsigned char *)OPENSSL_malloc((unsigned int)dsize+20); 310 data=(unsigned char *)OPENSSL_malloc((unsigned int)dsize+20);
310 if (data == NULL) 311 if (data == NULL)
311 { 312 {
@@ -335,13 +336,16 @@ int PEM_ASN1_write_bio(int (*i2d)(), const char *name, BIO *bp, char *x,
335 kstr=(unsigned char *)buf; 336 kstr=(unsigned char *)buf;
336 } 337 }
337 RAND_add(data,i,0);/* put in the RSA key. */ 338 RAND_add(data,i,0);/* put in the RSA key. */
339 OPENSSL_assert(enc->iv_len <= sizeof iv);
338 if (RAND_pseudo_bytes(iv,enc->iv_len) < 0) /* Generate a salt */ 340 if (RAND_pseudo_bytes(iv,enc->iv_len) < 0) /* Generate a salt */
339 goto err; 341 goto err;
340 /* The 'iv' is used as the iv and as a salt. It is 342 /* The 'iv' is used as the iv and as a salt. It is
341 * NOT taken from the BytesToKey function */ 343 * NOT taken from the BytesToKey function */
342 EVP_BytesToKey(enc,EVP_md5(),iv,kstr,klen,1,key,NULL); 344 EVP_BytesToKey(enc,EVP_md5(),iv,kstr,klen,1,key,NULL);
343 345
344 if (kstr == (unsigned char *)buf) memset(buf,0,PEM_BUFSIZE); 346 if (kstr == (unsigned char *)buf) OPENSSL_cleanse(buf,PEM_BUFSIZE);
347
348 OPENSSL_assert(strlen(objstr)+23+2*enc->iv_len+13 <= sizeof buf);
345 349
346 buf[0]='\0'; 350 buf[0]='\0';
347 PEM_proc_type(buf,PEM_TYPE_ENCRYPTED); 351 PEM_proc_type(buf,PEM_TYPE_ENCRYPTED);
@@ -364,13 +368,13 @@ int PEM_ASN1_write_bio(int (*i2d)(), const char *name, BIO *bp, char *x,
364 i=PEM_write_bio(bp,name,buf,data,i); 368 i=PEM_write_bio(bp,name,buf,data,i);
365 if (i <= 0) ret=0; 369 if (i <= 0) ret=0;
366err: 370err:
367 memset(key,0,sizeof(key)); 371 OPENSSL_cleanse(key,sizeof(key));
368 memset(iv,0,sizeof(iv)); 372 OPENSSL_cleanse(iv,sizeof(iv));
369 memset((char *)&ctx,0,sizeof(ctx)); 373 OPENSSL_cleanse((char *)&ctx,sizeof(ctx));
370 memset(buf,0,PEM_BUFSIZE); 374 OPENSSL_cleanse(buf,PEM_BUFSIZE);
371 if (data != NULL) 375 if (data != NULL)
372 { 376 {
373 memset(data,0,(unsigned int)dsize); 377 OPENSSL_cleanse(data,(unsigned int)dsize);
374 OPENSSL_free(data); 378 OPENSSL_free(data);
375 } 379 }
376 return(ret); 380 return(ret);
@@ -411,8 +415,8 @@ int PEM_do_header(EVP_CIPHER_INFO *cipher, unsigned char *data, long *plen,
411 EVP_DecryptUpdate(&ctx,data,&i,data,j); 415 EVP_DecryptUpdate(&ctx,data,&i,data,j);
412 o=EVP_DecryptFinal_ex(&ctx,&(data[i]),&j); 416 o=EVP_DecryptFinal_ex(&ctx,&(data[i]),&j);
413 EVP_CIPHER_CTX_cleanup(&ctx); 417 EVP_CIPHER_CTX_cleanup(&ctx);
414 memset((char *)buf,0,sizeof(buf)); 418 OPENSSL_cleanse((char *)buf,sizeof(buf));
415 memset((char *)key,0,sizeof(key)); 419 OPENSSL_cleanse((char *)key,sizeof(key));
416 j+=i; 420 j+=i;
417 if (!o) 421 if (!o)
418 { 422 {
@@ -693,7 +697,7 @@ int PEM_read_bio(BIO *bp, char **name, char **header, unsigned char **data,
693 if (strncmp(buf,"-----END ",9) == 0) 697 if (strncmp(buf,"-----END ",9) == 0)
694 break; 698 break;
695 if (i > 65) break; 699 if (i > 65) break;
696 if (!BUF_MEM_grow(dataB,i+bl+9)) 700 if (!BUF_MEM_grow_clean(dataB,i+bl+9))
697 { 701 {
698 PEMerr(PEM_F_PEM_READ_BIO,ERR_R_MALLOC_FAILURE); 702 PEMerr(PEM_F_PEM_READ_BIO,ERR_R_MALLOC_FAILURE);
699 goto err; 703 goto err;
diff --git a/src/lib/libcrypto/pem/pem_pk8.c b/src/lib/libcrypto/pem/pem_pk8.c
index f44182ffb5..db38a2a79d 100644
--- a/src/lib/libcrypto/pem/pem_pk8.c
+++ b/src/lib/libcrypto/pem/pem_pk8.c
@@ -136,7 +136,7 @@ static int do_pk8pkey(BIO *bp, EVP_PKEY *x, int isder, int nid, const EVP_CIPHER
136 kstr = buf; 136 kstr = buf;
137 } 137 }
138 p8 = PKCS8_encrypt(nid, enc, kstr, klen, NULL, 0, 0, p8inf); 138 p8 = PKCS8_encrypt(nid, enc, kstr, klen, NULL, 0, 0, p8inf);
139 if(kstr == buf) memset(buf, 0, klen); 139 if(kstr == buf) OPENSSL_cleanse(buf, klen);
140 PKCS8_PRIV_KEY_INFO_free(p8inf); 140 PKCS8_PRIV_KEY_INFO_free(p8inf);
141 if(isder) ret = i2d_PKCS8_bio(bp, p8); 141 if(isder) ret = i2d_PKCS8_bio(bp, p8);
142 else ret = PEM_write_bio_PKCS8(bp, p8); 142 else ret = PEM_write_bio_PKCS8(bp, p8);
diff --git a/src/lib/libcrypto/pem/pem_seal.c b/src/lib/libcrypto/pem/pem_seal.c
index ae463a301d..56e08abd70 100644
--- a/src/lib/libcrypto/pem/pem_seal.c
+++ b/src/lib/libcrypto/pem/pem_seal.c
@@ -112,7 +112,7 @@ int PEM_SealInit(PEM_ENCODE_SEAL_CTX *ctx, EVP_CIPHER *type, EVP_MD *md_type,
112 ret=npubk; 112 ret=npubk;
113err: 113err:
114 if (s != NULL) OPENSSL_free(s); 114 if (s != NULL) OPENSSL_free(s);
115 memset(key,0,EVP_MAX_KEY_LENGTH); 115 OPENSSL_cleanse(key,EVP_MAX_KEY_LENGTH);
116 return(ret); 116 return(ret);
117 } 117 }
118 118
diff --git a/src/lib/libcrypto/perlasm/cbc.pl b/src/lib/libcrypto/perlasm/cbc.pl
index 0145c4f0cc..22149c680e 100644
--- a/src/lib/libcrypto/perlasm/cbc.pl
+++ b/src/lib/libcrypto/perlasm/cbc.pl
@@ -146,9 +146,15 @@ sub cbc
146 &mov($count, &wparam(2)); # length 146 &mov($count, &wparam(2)); # length
147 &and($count, 7); 147 &and($count, 7);
148 &jz(&label("finish")); 148 &jz(&label("finish"));
149 &call(&label("PIC_point"));
150&set_label("PIC_point");
151 &blindpop("edx");
152 &lea("ecx",&DWP(&label("cbc_enc_jmp_table")."-".&label("PIC_point"),"edx"));
153 &mov($count,&DWP(0,"ecx",$count,4))
154 &add($count,"edx");
149 &xor("ecx","ecx"); 155 &xor("ecx","ecx");
150 &xor("edx","edx"); 156 &xor("edx","edx");
151 &mov($count,&DWP(&label("cbc_enc_jmp_table"),"",$count,4)); 157 #&mov($count,&DWP(&label("cbc_enc_jmp_table"),"",$count,4));
152 &jmp_ptr($count); 158 &jmp_ptr($count);
153 159
154&set_label("ej7"); 160&set_label("ej7");
@@ -318,22 +324,23 @@ sub cbc
318 324
319 &set_label("cbc_enc_jmp_table",1); 325 &set_label("cbc_enc_jmp_table",1);
320 &data_word("0"); 326 &data_word("0");
321 &data_word(&label("ej1")); 327 &data_word(&label("ej1")."-".&label("PIC_point"));
322 &data_word(&label("ej2")); 328 &data_word(&label("ej2")."-".&label("PIC_point"));
323 &data_word(&label("ej3")); 329 &data_word(&label("ej3")."-".&label("PIC_point"));
324 &data_word(&label("ej4")); 330 &data_word(&label("ej4")."-".&label("PIC_point"));
325 &data_word(&label("ej5")); 331 &data_word(&label("ej5")."-".&label("PIC_point"));
326 &data_word(&label("ej6")); 332 &data_word(&label("ej6")."-".&label("PIC_point"));
327 &data_word(&label("ej7")); 333 &data_word(&label("ej7")."-".&label("PIC_point"));
328 &set_label("cbc_dec_jmp_table",1); 334 # not used
329 &data_word("0"); 335 #&set_label("cbc_dec_jmp_table",1);
330 &data_word(&label("dj1")); 336 #&data_word("0");
331 &data_word(&label("dj2")); 337 #&data_word(&label("dj1")."-".&label("PIC_point"));
332 &data_word(&label("dj3")); 338 #&data_word(&label("dj2")."-".&label("PIC_point"));
333 &data_word(&label("dj4")); 339 #&data_word(&label("dj3")."-".&label("PIC_point"));
334 &data_word(&label("dj5")); 340 #&data_word(&label("dj4")."-".&label("PIC_point"));
335 &data_word(&label("dj6")); 341 #&data_word(&label("dj5")."-".&label("PIC_point"));
336 &data_word(&label("dj7")); 342 #&data_word(&label("dj6")."-".&label("PIC_point"));
343 #&data_word(&label("dj7")."-".&label("PIC_point"));
337 344
338 &function_end_B($name); 345 &function_end_B($name);
339 346
diff --git a/src/lib/libcrypto/perlasm/x86asm.pl b/src/lib/libcrypto/perlasm/x86asm.pl
index 9a3d85b098..1cb96e914a 100644
--- a/src/lib/libcrypto/perlasm/x86asm.pl
+++ b/src/lib/libcrypto/perlasm/x86asm.pl
@@ -18,9 +18,9 @@ sub main'asm_init
18 ($type,$fn,$i386)=@_; 18 ($type,$fn,$i386)=@_;
19 $filename=$fn; 19 $filename=$fn;
20 20
21 $cpp=$sol=$aout=$win32=$gaswin=0; 21 $elf=$cpp=$sol=$aout=$win32=$gaswin=0;
22 if ( ($type eq "elf")) 22 if ( ($type eq "elf"))
23 { require "x86unix.pl"; } 23 { $elf=1; require "x86unix.pl"; }
24 elsif ( ($type eq "a.out")) 24 elsif ( ($type eq "a.out"))
25 { $aout=1; require "x86unix.pl"; } 25 { $aout=1; require "x86unix.pl"; }
26 elsif ( ($type eq "gaswin")) 26 elsif ( ($type eq "gaswin"))
@@ -47,6 +47,9 @@ EOF
47 exit(1); 47 exit(1);
48 } 48 }
49 49
50 $pic=0;
51 for (@ARGV) { $pic=1 if (/\-[fK]PIC/i); }
52
50 &asm_init_output(); 53 &asm_init_output();
51 54
52&comment("Don't even think of reading this code"); 55&comment("Don't even think of reading this code");
@@ -91,7 +94,7 @@ $tmp
91#undef SIZE 94#undef SIZE
92#undef TYPE 95#undef TYPE
93#define SIZE(a,b) 96#define SIZE(a,b)
94#define TYPE(a,b) 97#define TYPE(a,b) .def a; .scl 2; .type 32; .endef
95#endif /* __CYGWIN || __DJGPP */ 98#endif /* __CYGWIN || __DJGPP */
96#endif 99#endif
97 100
diff --git a/src/lib/libcrypto/perlasm/x86ms.pl b/src/lib/libcrypto/perlasm/x86ms.pl
index 206452341d..35f1a4ddb9 100644
--- a/src/lib/libcrypto/perlasm/x86ms.pl
+++ b/src/lib/libcrypto/perlasm/x86ms.pl
@@ -92,6 +92,8 @@ sub get_mem
92 $addr="_$addr"; 92 $addr="_$addr";
93 } 93 }
94 94
95 if ($addr =~ /^.+\-.+$/) { $addr="($addr)"; }
96
95 $reg1="$regs{$reg1}" if defined($regs{$reg1}); 97 $reg1="$regs{$reg1}" if defined($regs{$reg1});
96 $reg2="$regs{$reg2}" if defined($regs{$reg2}); 98 $reg2="$regs{$reg2}" if defined($regs{$reg2});
97 if (($addr ne "") && ($addr ne 0)) 99 if (($addr ne "") && ($addr ne 0))
@@ -111,6 +113,7 @@ sub get_mem
111 { 113 {
112 $ret.="[$reg1$post]" 114 $ret.="[$reg1$post]"
113 } 115 }
116 $ret =~ s/\[\]//; # in case $addr was the only argument
114 return($ret); 117 return($ret);
115 } 118 }
116 119
@@ -151,7 +154,7 @@ sub main'push { &out1("push",@_); $stack+=4; }
151sub main'pop { &out1("pop",@_); $stack-=4; } 154sub main'pop { &out1("pop",@_); $stack-=4; }
152sub main'bswap { &out1("bswap",@_); &using486(); } 155sub main'bswap { &out1("bswap",@_); &using486(); }
153sub main'not { &out1("not",@_); } 156sub main'not { &out1("not",@_); }
154sub main'call { &out1("call",'_'.$_[0]); } 157sub main'call { &out1("call",($_[0]=~/^\$L/?'':'_').$_[0]); }
155sub main'ret { &out0("ret"); } 158sub main'ret { &out0("ret"); }
156sub main'nop { &out0("nop"); } 159sub main'nop { &out0("nop"); }
157 160
@@ -338,7 +341,7 @@ sub main'set_label
338 { 341 {
339 if (!defined($label{$_[0]})) 342 if (!defined($label{$_[0]}))
340 { 343 {
341 $label{$_[0]}="${label}${_[0]}"; 344 $label{$_[0]}="\$${label}${_[0]}";
342 $label++; 345 $label++;
343 } 346 }
344 if((defined $_[2]) && ($_[2] == 1)) 347 if((defined $_[2]) && ($_[2] == 1))
@@ -363,3 +366,11 @@ sub out1p
363 366
364 push(@out,"\t$name\t ".&conv($p1)."\n"); 367 push(@out,"\t$name\t ".&conv($p1)."\n");
365 } 368 }
369
370sub main'picmeup
371 {
372 local($dst,$sym)=@_;
373 &main'lea($dst,&main'DWP($sym));
374 }
375
376sub main'blindpop { &out1("pop",@_); }
diff --git a/src/lib/libcrypto/perlasm/x86nasm.pl b/src/lib/libcrypto/perlasm/x86nasm.pl
index 519d8a5867..f30b7466d4 100644
--- a/src/lib/libcrypto/perlasm/x86nasm.pl
+++ b/src/lib/libcrypto/perlasm/x86nasm.pl
@@ -98,6 +98,8 @@ sub get_mem
98 $addr="_$addr"; 98 $addr="_$addr";
99 } 99 }
100 100
101 if ($addr =~ /^.+\-.+$/) { $addr="($addr)"; }
102
101 $reg1="$regs{$reg1}" if defined($regs{$reg1}); 103 $reg1="$regs{$reg1}" if defined($regs{$reg1});
102 $reg2="$regs{$reg2}" if defined($regs{$reg2}); 104 $reg2="$regs{$reg2}" if defined($regs{$reg2});
103 if (($addr ne "") && ($addr ne 0)) 105 if (($addr ne "") && ($addr ne 0))
@@ -117,6 +119,7 @@ sub get_mem
117 { 119 {
118 $ret.="$reg1$post]" 120 $ret.="$reg1$post]"
119 } 121 }
122 $ret =~ s/\+\]/]/; # in case $addr was the only argument
120 return($ret); 123 return($ret);
121 } 124 }
122 125
@@ -160,7 +163,7 @@ sub main'push { &out1("push",@_); $stack+=4; }
160sub main'pop { &out1("pop",@_); $stack-=4; } 163sub main'pop { &out1("pop",@_); $stack-=4; }
161sub main'bswap { &out1("bswap",@_); &using486(); } 164sub main'bswap { &out1("bswap",@_); &using486(); }
162sub main'not { &out1("not",@_); } 165sub main'not { &out1("not",@_); }
163sub main'call { &out1("call",'_'.$_[0]); } 166sub main'call { &out1("call",($_[0]=~/^\$L/?'':'_').$_[0]); }
164sub main'ret { &out0("ret"); } 167sub main'ret { &out0("ret"); }
165sub main'nop { &out0("nop"); } 168sub main'nop { &out0("nop"); }
166 169
@@ -322,7 +325,7 @@ sub main'set_label
322 { 325 {
323 if (!defined($label{$_[0]})) 326 if (!defined($label{$_[0]}))
324 { 327 {
325 $label{$_[0]}="${label}${_[0]}"; 328 $label{$_[0]}="\$${label}${_[0]}";
326 $label++; 329 $label++;
327 } 330 }
328 push(@out,"$label{$_[0]}:\n"); 331 push(@out,"$label{$_[0]}:\n");
@@ -340,3 +343,11 @@ sub out1p
340 343
341 push(@out,"\t$name\t ".&conv($p1)."\n"); 344 push(@out,"\t$name\t ".&conv($p1)."\n");
342 } 345 }
346
347sub main'picmeup
348 {
349 local($dst,$sym)=@_;
350 &main'lea($dst,&main'DWP($sym));
351 }
352
353sub main'blindpop { &out1("pop",@_); }
diff --git a/src/lib/libcrypto/perlasm/x86unix.pl b/src/lib/libcrypto/perlasm/x86unix.pl
index 9ceabf0705..72bde061c5 100644
--- a/src/lib/libcrypto/perlasm/x86unix.pl
+++ b/src/lib/libcrypto/perlasm/x86unix.pl
@@ -87,12 +87,12 @@ sub main'DWP
87 $ret.=$addr if ($addr ne "") && ($addr ne 0); 87 $ret.=$addr if ($addr ne "") && ($addr ne 0);
88 if ($reg2 ne "") 88 if ($reg2 ne "")
89 { 89 {
90 if($idx ne "") 90 if($idx ne "" && $idx != 0)
91 { $ret.="($reg1,$reg2,$idx)"; } 91 { $ret.="($reg1,$reg2,$idx)"; }
92 else 92 else
93 { $ret.="($reg1,$reg2)"; } 93 { $ret.="($reg1,$reg2)"; }
94 } 94 }
95 else 95 elsif ($reg1 ne "")
96 { $ret.="($reg1)" } 96 { $ret.="($reg1)" }
97 return($ret); 97 return($ret);
98 } 98 }
@@ -167,7 +167,7 @@ sub main'pop { &out1("popl",@_); $stack-=4; }
167sub main'pushf { &out0("pushf"); $stack+=4; } 167sub main'pushf { &out0("pushf"); $stack+=4; }
168sub main'popf { &out0("popf"); $stack-=4; } 168sub main'popf { &out0("popf"); $stack-=4; }
169sub main'not { &out1("notl",@_); } 169sub main'not { &out1("notl",@_); }
170sub main'call { &out1("call",$under.$_[0]); } 170sub main'call { &out1("call",($_[0]=~/^\.L/?'':$under).$_[0]); }
171sub main'ret { &out0("ret"); } 171sub main'ret { &out0("ret"); }
172sub main'nop { &out0("nop"); } 172sub main'nop { &out0("nop"); }
173 173
@@ -345,15 +345,15 @@ sub main'function_end
345 popl %ebx 345 popl %ebx
346 popl %ebp 346 popl %ebp
347 ret 347 ret
348.${func}_end: 348.L_${func}_end:
349EOF 349EOF
350 push(@out,$tmp); 350 push(@out,$tmp);
351 351
352 if ($main'cpp) 352 if ($main'cpp)
353 { push(@out,"\tSIZE($func,.${func}_end-$func)\n"); } 353 { push(@out,"\tSIZE($func,.L_${func}_end-$func)\n"); }
354 elsif ($main'gaswin) 354 elsif ($main'gaswin)
355 { $tmp=push(@out,"\t.align 4\n"); } 355 { $tmp=push(@out,"\t.align 4\n"); }
356 else { push(@out,"\t.size\t$func,.${func}_end-$func\n"); } 356 else { push(@out,"\t.size\t$func,.L_${func}_end-$func\n"); }
357 push(@out,".ident \"$func\"\n"); 357 push(@out,".ident \"$func\"\n");
358 $stack=0; 358 $stack=0;
359 %label=(); 359 %label=();
@@ -426,6 +426,11 @@ sub main'swtmp
426 426
427sub main'comment 427sub main'comment
428 { 428 {
429 if ($main'elf) # GNU and SVR4 as'es use different comment delimiters,
430 { # so we just skip comments...
431 push(@out,"\n");
432 return;
433 }
429 foreach (@_) 434 foreach (@_)
430 { 435 {
431 if (/^\s*$/) 436 if (/^\s*$/)
@@ -542,3 +547,39 @@ sub popvars
542 &main'pop("edx"); 547 &main'pop("edx");
543 &main'popf(); 548 &main'popf();
544 } 549 }
550
551sub main'picmeup
552 {
553 local($dst,$sym)=@_;
554 if ($main'cpp)
555 {
556 local($tmp)=<<___;
557#if (defined(ELF) || defined(SOL)) && defined(PIC)
558 .align 8
559 call 1f
5601: popl $regs{$dst}
561 addl \$_GLOBAL_OFFSET_TABLE_+[.-1b],$regs{$dst}
562 movl $sym\@GOT($regs{$dst}),$regs{$dst}
563#else
564 leal $sym,$regs{$dst}
565#endif
566___
567 push(@out,$tmp);
568 }
569 elsif ($main'pic && ($main'elf || $main'aout))
570 {
571 push(@out,"\t.align\t8\n");
572 &main'call(&main'label("PIC_me_up"));
573 &main'set_label("PIC_me_up");
574 &main'blindpop($dst);
575 &main'add($dst,"\$$under"."_GLOBAL_OFFSET_TABLE_+[.-".
576 &main'label("PIC_me_up") . "]");
577 &main'mov($dst,&main'DWP($sym."\@GOT",$dst));
578 }
579 else
580 {
581 &main'lea($dst,&main'DWP($sym));
582 }
583 }
584
585sub main'blindpop { &out1("popl",@_); }
diff --git a/src/lib/libcrypto/pkcs12/Makefile.ssl b/src/lib/libcrypto/pkcs12/Makefile.ssl
index 2b1d175157..a6e47b4085 100644
--- a/src/lib/libcrypto/pkcs12/Makefile.ssl
+++ b/src/lib/libcrypto/pkcs12/Makefile.ssl
@@ -74,7 +74,7 @@ lint:
74 lint -DLINT $(INCLUDES) $(SRC)>fluff 74 lint -DLINT $(INCLUDES) $(SRC)>fluff
75 75
76depend: 76depend:
77 $(MAKEDEPEND) $(CFLAG) $(INCLUDES) $(DEPFLAG) $(PROGS) $(LIBSRC) 77 $(MAKEDEPEND) -- $(CFLAG) $(INCLUDES) $(DEPFLAG) -- $(PROGS) $(LIBSRC)
78 78
79dclean: 79dclean:
80 $(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new 80 $(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
diff --git a/src/lib/libcrypto/pkcs12/p12_crpt.c b/src/lib/libcrypto/pkcs12/p12_crpt.c
index 97be6a5fb5..5e8958612b 100644
--- a/src/lib/libcrypto/pkcs12/p12_crpt.c
+++ b/src/lib/libcrypto/pkcs12/p12_crpt.c
@@ -118,7 +118,7 @@ int PKCS12_PBE_keyivgen (EVP_CIPHER_CTX *ctx, const char *pass, int passlen,
118 } 118 }
119 PBEPARAM_free(pbe); 119 PBEPARAM_free(pbe);
120 EVP_CipherInit_ex(ctx, cipher, NULL, key, iv, en_de); 120 EVP_CipherInit_ex(ctx, cipher, NULL, key, iv, en_de);
121 memset(key, 0, EVP_MAX_KEY_LENGTH); 121 OPENSSL_cleanse(key, EVP_MAX_KEY_LENGTH);
122 memset(iv, 0, EVP_MAX_IV_LENGTH); 122 OPENSSL_cleanse(iv, EVP_MAX_IV_LENGTH);
123 return 1; 123 return 1;
124} 124}
diff --git a/src/lib/libcrypto/pkcs12/p12_decr.c b/src/lib/libcrypto/pkcs12/p12_decr.c
index 394af368f4..b5684a83ba 100644
--- a/src/lib/libcrypto/pkcs12/p12_decr.c
+++ b/src/lib/libcrypto/pkcs12/p12_decr.c
@@ -136,7 +136,7 @@ void * PKCS12_item_decrypt_d2i(X509_ALGOR *algor, const ASN1_ITEM *it,
136 } 136 }
137#endif 137#endif
138 ret = ASN1_item_d2i(NULL, &p, outlen, it); 138 ret = ASN1_item_d2i(NULL, &p, outlen, it);
139 if (zbuf) memset(out, 0, outlen); 139 if (zbuf) OPENSSL_cleanse(out, outlen);
140 if(!ret) PKCS12err(PKCS12_F_PKCS12_DECRYPT_D2I,PKCS12_R_DECODE_ERROR); 140 if(!ret) PKCS12err(PKCS12_F_PKCS12_DECRYPT_D2I,PKCS12_R_DECODE_ERROR);
141 OPENSSL_free(out); 141 OPENSSL_free(out);
142 return ret; 142 return ret;
@@ -168,7 +168,7 @@ ASN1_OCTET_STRING *PKCS12_item_i2d_encrypt(X509_ALGOR *algor, const ASN1_ITEM *i
168 OPENSSL_free(in); 168 OPENSSL_free(in);
169 return NULL; 169 return NULL;
170 } 170 }
171 if (zbuf) memset(in, 0, inlen); 171 if (zbuf) OPENSSL_cleanse(in, inlen);
172 OPENSSL_free(in); 172 OPENSSL_free(in);
173 return oct; 173 return oct;
174} 174}
diff --git a/src/lib/libcrypto/pkcs12/p12_key.c b/src/lib/libcrypto/pkcs12/p12_key.c
index 0d39ebde8c..9196a34b4a 100644
--- a/src/lib/libcrypto/pkcs12/p12_key.c
+++ b/src/lib/libcrypto/pkcs12/p12_key.c
@@ -91,7 +91,7 @@ int PKCS12_key_gen_asc(const char *pass, int passlen, unsigned char *salt,
91 ret = PKCS12_key_gen_uni(unipass, uniplen, salt, saltlen, 91 ret = PKCS12_key_gen_uni(unipass, uniplen, salt, saltlen,
92 id, iter, n, out, md_type); 92 id, iter, n, out, md_type);
93 if(unipass) { 93 if(unipass) {
94 memset(unipass, 0, uniplen); /* Clear password from memory */ 94 OPENSSL_cleanse(unipass, uniplen); /* Clear password from memory */
95 OPENSSL_free(unipass); 95 OPENSSL_free(unipass);
96 } 96 }
97 return ret; 97 return ret;
diff --git a/src/lib/libcrypto/pkcs12/p12_npas.c b/src/lib/libcrypto/pkcs12/p12_npas.c
index a549433eeb..af708a2743 100644
--- a/src/lib/libcrypto/pkcs12/p12_npas.c
+++ b/src/lib/libcrypto/pkcs12/p12_npas.c
@@ -107,7 +107,7 @@ static int newpass_p12(PKCS12 *p12, char *oldpass, char *newpass)
107{ 107{
108 STACK_OF(PKCS7) *asafes, *newsafes; 108 STACK_OF(PKCS7) *asafes, *newsafes;
109 STACK_OF(PKCS12_SAFEBAG) *bags; 109 STACK_OF(PKCS12_SAFEBAG) *bags;
110 int i, bagnid, pbe_nid, pbe_iter, pbe_saltlen; 110 int i, bagnid, pbe_nid = 0, pbe_iter = 0, pbe_saltlen = 0;
111 PKCS7 *p7, *p7new; 111 PKCS7 *p7, *p7new;
112 ASN1_OCTET_STRING *p12_data_tmp = NULL, *macnew = NULL; 112 ASN1_OCTET_STRING *p12_data_tmp = NULL, *macnew = NULL;
113 unsigned char mac[EVP_MAX_MD_SIZE]; 113 unsigned char mac[EVP_MAX_MD_SIZE];
diff --git a/src/lib/libcrypto/pkcs7/Makefile.ssl b/src/lib/libcrypto/pkcs7/Makefile.ssl
index 1302469def..c3bfc7d560 100644
--- a/src/lib/libcrypto/pkcs7/Makefile.ssl
+++ b/src/lib/libcrypto/pkcs7/Makefile.ssl
@@ -89,7 +89,7 @@ lint:
89 lint -DLINT $(INCLUDES) $(SRC)>fluff 89 lint -DLINT $(INCLUDES) $(SRC)>fluff
90 90
91depend: 91depend:
92 $(MAKEDEPEND) $(CFLAG) $(INCLUDES) $(DEPFLAG) $(PROGS) $(LIBSRC) 92 $(MAKEDEPEND) -- $(CFLAG) $(INCLUDES) $(DEPFLAG) -- $(PROGS) $(LIBSRC)
93 93
94dclean: 94dclean:
95 $(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new 95 $(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
diff --git a/src/lib/libcrypto/pkcs7/bio_ber.c b/src/lib/libcrypto/pkcs7/bio_ber.c
index 42331f7ab0..895a91177b 100644
--- a/src/lib/libcrypto/pkcs7/bio_ber.c
+++ b/src/lib/libcrypto/pkcs7/bio_ber.c
@@ -145,7 +145,7 @@ static int ber_free(BIO *a)
145 145
146 if (a == NULL) return(0); 146 if (a == NULL) return(0);
147 b=(BIO_BER_CTX *)a->ptr; 147 b=(BIO_BER_CTX *)a->ptr;
148 memset(a->ptr,0,sizeof(BIO_BER_CTX)); 148 OPENSSL_cleanse(a->ptr,sizeof(BIO_BER_CTX));
149 OPENSSL_free(a->ptr); 149 OPENSSL_free(a->ptr);
150 a->ptr=NULL; 150 a->ptr=NULL;
151 a->init=0; 151 a->init=0;
diff --git a/src/lib/libcrypto/pkcs7/pk7_doit.c b/src/lib/libcrypto/pkcs7/pk7_doit.c
index 4a4ff340ce..0060a2ea3d 100644
--- a/src/lib/libcrypto/pkcs7/pk7_doit.c
+++ b/src/lib/libcrypto/pkcs7/pk7_doit.c
@@ -241,7 +241,7 @@ BIO *PKCS7_dataInit(PKCS7 *p7, BIO *bio)
241 M_ASN1_OCTET_STRING_set(ri->enc_key,tmp,jj); 241 M_ASN1_OCTET_STRING_set(ri->enc_key,tmp,jj);
242 } 242 }
243 OPENSSL_free(tmp); 243 OPENSSL_free(tmp);
244 memset(key, 0, keylen); 244 OPENSSL_cleanse(key, keylen);
245 245
246 if (out == NULL) 246 if (out == NULL)
247 out=btmp; 247 out=btmp;
@@ -448,7 +448,7 @@ BIO *PKCS7_dataDecode(PKCS7 *p7, EVP_PKEY *pkey, BIO *in_bio, X509 *pcert)
448 } 448 }
449 EVP_CipherInit_ex(evp_ctx,NULL,NULL,tmp,NULL,0); 449 EVP_CipherInit_ex(evp_ctx,NULL,NULL,tmp,NULL,0);
450 450
451 memset(tmp,0,jj); 451 OPENSSL_cleanse(tmp,jj);
452 452
453 if (out == NULL) 453 if (out == NULL)
454 out=etmp; 454 out=etmp;
@@ -578,7 +578,7 @@ int PKCS7_dataFinal(PKCS7 *p7, BIO *bio)
578 /* We now have the EVP_MD_CTX, lets do the 578 /* We now have the EVP_MD_CTX, lets do the
579 * signing. */ 579 * signing. */
580 EVP_MD_CTX_copy_ex(&ctx_tmp,mdc); 580 EVP_MD_CTX_copy_ex(&ctx_tmp,mdc);
581 if (!BUF_MEM_grow(buf,EVP_PKEY_size(si->pkey))) 581 if (!BUF_MEM_grow_clean(buf,EVP_PKEY_size(si->pkey)))
582 { 582 {
583 PKCS7err(PKCS7_F_PKCS7_DATASIGN,ERR_R_BIO_LIB); 583 PKCS7err(PKCS7_F_PKCS7_DATASIGN,ERR_R_BIO_LIB);
584 goto err; 584 goto err;
diff --git a/src/lib/libcrypto/rand/Makefile.ssl b/src/lib/libcrypto/rand/Makefile.ssl
index 73b5f568e8..df80702373 100644
--- a/src/lib/libcrypto/rand/Makefile.ssl
+++ b/src/lib/libcrypto/rand/Makefile.ssl
@@ -70,7 +70,7 @@ lint:
70 lint -DLINT $(INCLUDES) $(SRC)>fluff 70 lint -DLINT $(INCLUDES) $(SRC)>fluff
71 71
72depend: 72depend:
73 $(MAKEDEPEND) $(CFLAG) $(INCLUDES) $(DEPFLAG) $(PROGS) $(LIBSRC) 73 $(MAKEDEPEND) -- $(CFLAG) $(INCLUDES) $(DEPFLAG) -- $(PROGS) $(LIBSRC)
74 74
75dclean: 75dclean:
76 $(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new 76 $(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
diff --git a/src/lib/libcrypto/rand/md_rand.c b/src/lib/libcrypto/rand/md_rand.c
index a00ed70718..eeffc0df4c 100644
--- a/src/lib/libcrypto/rand/md_rand.c
+++ b/src/lib/libcrypto/rand/md_rand.c
@@ -177,10 +177,10 @@ RAND_METHOD *RAND_SSLeay(void)
177 177
178static void ssleay_rand_cleanup(void) 178static void ssleay_rand_cleanup(void)
179 { 179 {
180 memset(state,0,sizeof(state)); 180 OPENSSL_cleanse(state,sizeof(state));
181 state_num=0; 181 state_num=0;
182 state_index=0; 182 state_index=0;
183 memset(md,0,MD_DIGEST_LENGTH); 183 OPENSSL_cleanse(md,MD_DIGEST_LENGTH);
184 md_count[0]=0; 184 md_count[0]=0;
185 md_count[1]=0; 185 md_count[1]=0;
186 entropy=0; 186 entropy=0;
diff --git a/src/lib/libcrypto/rand/rand.h b/src/lib/libcrypto/rand/rand.h
index 66e39991ec..606382dd21 100644
--- a/src/lib/libcrypto/rand/rand.h
+++ b/src/lib/libcrypto/rand/rand.h
@@ -87,7 +87,9 @@ extern int rand_predictable;
87 87
88int RAND_set_rand_method(const RAND_METHOD *meth); 88int RAND_set_rand_method(const RAND_METHOD *meth);
89const RAND_METHOD *RAND_get_rand_method(void); 89const RAND_METHOD *RAND_get_rand_method(void);
90#ifndef OPENSSL_NO_ENGINE
90int RAND_set_rand_engine(ENGINE *engine); 91int RAND_set_rand_engine(ENGINE *engine);
92#endif
91RAND_METHOD *RAND_SSLeay(void); 93RAND_METHOD *RAND_SSLeay(void);
92void RAND_cleanup(void ); 94void RAND_cleanup(void );
93int RAND_bytes(unsigned char *buf,int num); 95int RAND_bytes(unsigned char *buf,int num);
diff --git a/src/lib/libcrypto/rand/rand_egd.c b/src/lib/libcrypto/rand/rand_egd.c
index 96019c07a6..895967476e 100644
--- a/src/lib/libcrypto/rand/rand_egd.c
+++ b/src/lib/libcrypto/rand/rand_egd.c
@@ -94,7 +94,7 @@
94 * RAND_egd() is a wrapper for RAND_egd_bytes() with numbytes=255. 94 * RAND_egd() is a wrapper for RAND_egd_bytes() with numbytes=255.
95 */ 95 */
96 96
97#if defined(OPENSSL_SYS_WIN32) || defined(OPENSSL_SYS_VMS) || defined(__DJGPP__) 97#if defined(OPENSSL_SYS_WIN32) || defined(OPENSSL_SYS_VMS) || defined(OPENSSL_SYS_MSDOS) || defined(OPENSSL_SYS_VXWORKS)
98int RAND_query_egd_bytes(const char *path, unsigned char *buf, int bytes) 98int RAND_query_egd_bytes(const char *path, unsigned char *buf, int bytes)
99 { 99 {
100 return(-1); 100 return(-1);
@@ -114,7 +114,7 @@ int RAND_egd_bytes(const char *path,int bytes)
114#include <sys/types.h> 114#include <sys/types.h>
115#include <sys/socket.h> 115#include <sys/socket.h>
116#ifndef NO_SYS_UN_H 116#ifndef NO_SYS_UN_H
117# ifdef OPENSSL_SYS_VSWORKS 117# ifdef OPENSSL_SYS_VXWORKS
118# include <streams/un.h> 118# include <streams/un.h>
119# else 119# else
120# include <sys/un.h> 120# include <sys/un.h>
@@ -143,7 +143,7 @@ int RAND_query_egd_bytes(const char *path, unsigned char *buf, int bytes)
143 143
144 memset(&addr, 0, sizeof(addr)); 144 memset(&addr, 0, sizeof(addr));
145 addr.sun_family = AF_UNIX; 145 addr.sun_family = AF_UNIX;
146 if (strlen(path) > sizeof(addr.sun_path)) 146 if (strlen(path) >= sizeof(addr.sun_path))
147 return (-1); 147 return (-1);
148 strlcpy(addr.sun_path,path,sizeof addr.sun_path); 148 strlcpy(addr.sun_path,path,sizeof addr.sun_path);
149 len = offsetof(struct sockaddr_un, sun_path) + strlen(path); 149 len = offsetof(struct sockaddr_un, sun_path) + strlen(path);
diff --git a/src/lib/libcrypto/rand/rand_lib.c b/src/lib/libcrypto/rand/rand_lib.c
index 5cf5dc1188..513e338985 100644
--- a/src/lib/libcrypto/rand/rand_lib.c
+++ b/src/lib/libcrypto/rand/rand_lib.c
@@ -60,19 +60,25 @@
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#ifndef OPENSSL_NO_ENGINE
63#include <openssl/engine.h> 64#include <openssl/engine.h>
65#endif
64 66
67#ifndef OPENSSL_NO_ENGINE
65/* non-NULL if default_RAND_meth is ENGINE-provided */ 68/* non-NULL if default_RAND_meth is ENGINE-provided */
66static ENGINE *funct_ref =NULL; 69static ENGINE *funct_ref =NULL;
70#endif
67static const RAND_METHOD *default_RAND_meth = NULL; 71static const RAND_METHOD *default_RAND_meth = NULL;
68 72
69int RAND_set_rand_method(const RAND_METHOD *meth) 73int RAND_set_rand_method(const RAND_METHOD *meth)
70 { 74 {
75#ifndef OPENSSL_NO_ENGINE
71 if(funct_ref) 76 if(funct_ref)
72 { 77 {
73 ENGINE_finish(funct_ref); 78 ENGINE_finish(funct_ref);
74 funct_ref = NULL; 79 funct_ref = NULL;
75 } 80 }
81#endif
76 default_RAND_meth = meth; 82 default_RAND_meth = meth;
77 return 1; 83 return 1;
78 } 84 }
@@ -81,6 +87,7 @@ const RAND_METHOD *RAND_get_rand_method(void)
81 { 87 {
82 if (!default_RAND_meth) 88 if (!default_RAND_meth)
83 { 89 {
90#ifndef OPENSSL_NO_ENGINE
84 ENGINE *e = ENGINE_get_default_RAND(); 91 ENGINE *e = ENGINE_get_default_RAND();
85 if(e) 92 if(e)
86 { 93 {
@@ -94,11 +101,13 @@ const RAND_METHOD *RAND_get_rand_method(void)
94 if(e) 101 if(e)
95 funct_ref = e; 102 funct_ref = e;
96 else 103 else
104#endif
97 default_RAND_meth = RAND_SSLeay(); 105 default_RAND_meth = RAND_SSLeay();
98 } 106 }
99 return default_RAND_meth; 107 return default_RAND_meth;
100 } 108 }
101 109
110#ifndef OPENSSL_NO_ENGINE
102int RAND_set_rand_engine(ENGINE *engine) 111int RAND_set_rand_engine(ENGINE *engine)
103 { 112 {
104 const RAND_METHOD *tmp_meth = NULL; 113 const RAND_METHOD *tmp_meth = NULL;
@@ -118,6 +127,7 @@ int RAND_set_rand_engine(ENGINE *engine)
118 funct_ref = engine; 127 funct_ref = engine;
119 return 1; 128 return 1;
120 } 129 }
130#endif
121 131
122void RAND_cleanup(void) 132void RAND_cleanup(void)
123 { 133 {
diff --git a/src/lib/libcrypto/rand/rand_unix.c b/src/lib/libcrypto/rand/rand_unix.c
index fa2bab57c6..0599719dd1 100644
--- a/src/lib/libcrypto/rand/rand_unix.c
+++ b/src/lib/libcrypto/rand/rand_unix.c
@@ -115,7 +115,7 @@
115#include <openssl/rand.h> 115#include <openssl/rand.h>
116#include "rand_lcl.h" 116#include "rand_lcl.h"
117 117
118#if !(defined(OPENSSL_SYS_WINDOWS) || defined(OPENSSL_SYS_WIN32) || defined(OPENSSL_SYS_VMS) || defined(OPENSSL_SYS_OS2)) 118#if !(defined(OPENSSL_SYS_WINDOWS) || defined(OPENSSL_SYS_WIN32) || defined(OPENSSL_SYS_VMS) || defined(OPENSSL_SYS_OS2) || defined(OPENSSL_SYS_VXWORKS))
119 119
120#include <sys/types.h> 120#include <sys/types.h>
121#include <sys/time.h> 121#include <sys/time.h>
@@ -233,7 +233,7 @@ int RAND_poll(void)
233 if (n > 0) 233 if (n > 0)
234 { 234 {
235 RAND_add(tmpbuf,sizeof tmpbuf,n); 235 RAND_add(tmpbuf,sizeof tmpbuf,n);
236 memset(tmpbuf,0,n); 236 OPENSSL_cleanse(tmpbuf,n);
237 } 237 }
238#endif 238#endif
239 239
@@ -255,3 +255,10 @@ int RAND_poll(void)
255 255
256#endif 256#endif
257#endif 257#endif
258
259#if defined(OPENSSL_SYS_VXWORKS)
260int RAND_poll(void)
261{
262 return 0;
263}
264#endif
diff --git a/src/lib/libcrypto/rand/rand_win.c b/src/lib/libcrypto/rand/rand_win.c
index c1b955b06f..113b58678f 100644
--- a/src/lib/libcrypto/rand/rand_win.c
+++ b/src/lib/libcrypto/rand/rand_win.c
@@ -125,7 +125,7 @@
125 * http://developer.intel.com/design/security/rng/redist_license.htm 125 * http://developer.intel.com/design/security/rng/redist_license.htm
126 */ 126 */
127#define PROV_INTEL_SEC 22 127#define PROV_INTEL_SEC 22
128#define INTEL_DEF_PROV "Intel Hardware Cryptographic Service Provider" 128#define INTEL_DEF_PROV TEXT("Intel Hardware Cryptographic Service Provider")
129 129
130static void readtimer(void); 130static void readtimer(void);
131static void readscreen(void); 131static void readscreen(void);
@@ -170,7 +170,9 @@ typedef BOOL (WINAPI *THREAD32)(HANDLE, LPTHREADENTRY32);
170typedef BOOL (WINAPI *MODULE32)(HANDLE, LPMODULEENTRY32); 170typedef BOOL (WINAPI *MODULE32)(HANDLE, LPMODULEENTRY32);
171 171
172#include <lmcons.h> 172#include <lmcons.h>
173#ifndef OPENSSL_SYS_WINCE
173#include <lmstats.h> 174#include <lmstats.h>
175#endif
174#if 1 /* The NET API is Unicode only. It requires the use of the UNICODE 176#if 1 /* The NET API is Unicode only. It requires the use of the UNICODE
175 * macro. When UNICODE is defined LPTSTR becomes LPWSTR. LMSTR was 177 * macro. When UNICODE is defined LPTSTR becomes LPWSTR. LMSTR was
176 * was added to the Platform SDK to allow the NET API to be used in 178 * was added to the Platform SDK to allow the NET API to be used in
@@ -209,20 +211,32 @@ int RAND_poll(void)
209 osverinfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO) ; 211 osverinfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO) ;
210 GetVersionEx( &osverinfo ) ; 212 GetVersionEx( &osverinfo ) ;
211 213
214#if defined(OPENSSL_SYS_WINCE) && WCEPLATFORM!=MS_HPC_PRO
215 /* poll the CryptoAPI PRNG */
216 /* The CryptoAPI returns sizeof(buf) bytes of randomness */
217 if (CryptAcquireContext(&hProvider, 0, 0, PROV_RSA_FULL, CRYPT_VERIFYCONTEXT))
218 {
219 if (CryptGenRandom(hProvider, sizeof(buf), buf))
220 RAND_add(buf, sizeof(buf), sizeof(buf));
221 CryptReleaseContext(hProvider, 0);
222 }
223#endif
224
212 /* load functions dynamically - not available on all systems */ 225 /* load functions dynamically - not available on all systems */
213 advapi = LoadLibrary("ADVAPI32.DLL"); 226 advapi = LoadLibrary(TEXT("ADVAPI32.DLL"));
214 kernel = LoadLibrary("KERNEL32.DLL"); 227 kernel = LoadLibrary(TEXT("KERNEL32.DLL"));
215 user = LoadLibrary("USER32.DLL"); 228 user = LoadLibrary(TEXT("USER32.DLL"));
216 netapi = LoadLibrary("NETAPI32.DLL"); 229 netapi = LoadLibrary(TEXT("NETAPI32.DLL"));
217 230
231#ifndef OPENSSL_SYS_WINCE
218#if 1 /* There was previously a problem with NETSTATGET. Currently, this 232#if 1 /* There was previously a problem with NETSTATGET. Currently, this
219 * section is still experimental, but if all goes well, this conditional 233 * section is still experimental, but if all goes well, this conditional
220 * will be removed 234 * will be removed
221 */ 235 */
222 if (netapi) 236 if (netapi)
223 { 237 {
224 netstatget = (NETSTATGET) GetProcAddress(netapi,"NetStatisticsGet"); 238 netstatget = (NETSTATGET) GetProcAddress(netapi,TEXT("NetStatisticsGet"));
225 netfree = (NETFREE) GetProcAddress(netapi,"NetApiBufferFree"); 239 netfree = (NETFREE) GetProcAddress(netapi,TEXT("NetApiBufferFree"));
226 } 240 }
227 241
228 if (netstatget && netfree) 242 if (netstatget && netfree)
@@ -249,7 +263,9 @@ int RAND_poll(void)
249 if (netapi) 263 if (netapi)
250 FreeLibrary(netapi); 264 FreeLibrary(netapi);
251#endif /* 1 */ 265#endif /* 1 */
266#endif /* !OPENSSL_SYS_WINCE */
252 267
268#ifndef OPENSSL_SYS_WINCE
253 /* It appears like this can cause an exception deep within ADVAPI32.DLL 269 /* It appears like this can cause an exception deep within ADVAPI32.DLL
254 * at random times on Windows 2000. Reported by Jeffrey Altman. 270 * at random times on Windows 2000. Reported by Jeffrey Altman.
255 * Only use it on NT. 271 * Only use it on NT.
@@ -280,30 +296,40 @@ int RAND_poll(void)
280 bufsz += 8192; 296 bufsz += 8192;
281 297
282 length = bufsz; 298 length = bufsz;
283 rc = RegQueryValueEx(HKEY_PERFORMANCE_DATA, "Global", 299 rc = RegQueryValueEx(HKEY_PERFORMANCE_DATA, TEXT("Global"),
284 NULL, NULL, buf, &length); 300 NULL, NULL, buf, &length);
285 } 301 }
286 if (rc == ERROR_SUCCESS) 302 if (rc == ERROR_SUCCESS)
287 { 303 {
288 /* For entropy count assume only least significant 304 /* For entropy count assume only least significant
289 * byte of each DWORD is random. 305 * byte of each DWORD is random.
290 */ 306 */
291 RAND_add(&length, sizeof(length), 0); 307 RAND_add(&length, sizeof(length), 0);
292 RAND_add(buf, length, length / 4.0); 308 RAND_add(buf, length, length / 4.0);
309
310 /* Close the Registry Key to allow Windows to cleanup/close
311 * the open handle
312 * Note: The 'HKEY_PERFORMANCE_DATA' key is implicitly opened
313 * when the RegQueryValueEx above is done. However, if
314 * it is not explicitly closed, it can cause disk
315 * partition manipulation problems.
316 */
317 RegCloseKey(HKEY_PERFORMANCE_DATA);
293 } 318 }
294 if (buf) 319 if (buf)
295 free(buf); 320 free(buf);
296 } 321 }
297#endif 322#endif
323#endif /* !OPENSSL_SYS_WINCE */
298 324
299 if (advapi) 325 if (advapi)
300 { 326 {
301 acquire = (CRYPTACQUIRECONTEXT) GetProcAddress(advapi, 327 acquire = (CRYPTACQUIRECONTEXT) GetProcAddress(advapi,
302 "CryptAcquireContextA"); 328 TEXT("CryptAcquireContextA"));
303 gen = (CRYPTGENRANDOM) GetProcAddress(advapi, 329 gen = (CRYPTGENRANDOM) GetProcAddress(advapi,
304 "CryptGenRandom"); 330 TEXT("CryptGenRandom"));
305 release = (CRYPTRELEASECONTEXT) GetProcAddress(advapi, 331 release = (CRYPTRELEASECONTEXT) GetProcAddress(advapi,
306 "CryptReleaseContext"); 332 TEXT("CryptReleaseContext"));
307 } 333 }
308 334
309 if (acquire && gen && release) 335 if (acquire && gen && release)
@@ -357,9 +383,9 @@ int RAND_poll(void)
357 GETFOREGROUNDWINDOW win; 383 GETFOREGROUNDWINDOW win;
358 GETQUEUESTATUS queue; 384 GETQUEUESTATUS queue;
359 385
360 win = (GETFOREGROUNDWINDOW) GetProcAddress(user, "GetForegroundWindow"); 386 win = (GETFOREGROUNDWINDOW) GetProcAddress(user, TEXT("GetForegroundWindow"));
361 cursor = (GETCURSORINFO) GetProcAddress(user, "GetCursorInfo"); 387 cursor = (GETCURSORINFO) GetProcAddress(user, TEXT("GetCursorInfo"));
362 queue = (GETQUEUESTATUS) GetProcAddress(user, "GetQueueStatus"); 388 queue = (GETQUEUESTATUS) GetProcAddress(user, TEXT("GetQueueStatus"));
363 389
364 if (win) 390 if (win)
365 { 391 {
@@ -430,17 +456,17 @@ int RAND_poll(void)
430 MODULEENTRY32 m; 456 MODULEENTRY32 m;
431 457
432 snap = (CREATETOOLHELP32SNAPSHOT) 458 snap = (CREATETOOLHELP32SNAPSHOT)
433 GetProcAddress(kernel, "CreateToolhelp32Snapshot"); 459 GetProcAddress(kernel, TEXT("CreateToolhelp32Snapshot"));
434 heap_first = (HEAP32FIRST) GetProcAddress(kernel, "Heap32First"); 460 heap_first = (HEAP32FIRST) GetProcAddress(kernel, TEXT("Heap32First"));
435 heap_next = (HEAP32NEXT) GetProcAddress(kernel, "Heap32Next"); 461 heap_next = (HEAP32NEXT) GetProcAddress(kernel, TEXT("Heap32Next"));
436 heaplist_first = (HEAP32LIST) GetProcAddress(kernel, "Heap32ListFirst"); 462 heaplist_first = (HEAP32LIST) GetProcAddress(kernel, TEXT("Heap32ListFirst"));
437 heaplist_next = (HEAP32LIST) GetProcAddress(kernel, "Heap32ListNext"); 463 heaplist_next = (HEAP32LIST) GetProcAddress(kernel, TEXT("Heap32ListNext"));
438 process_first = (PROCESS32) GetProcAddress(kernel, "Process32First"); 464 process_first = (PROCESS32) GetProcAddress(kernel, TEXT("Process32First"));
439 process_next = (PROCESS32) GetProcAddress(kernel, "Process32Next"); 465 process_next = (PROCESS32) GetProcAddress(kernel, TEXT("Process32Next"));
440 thread_first = (THREAD32) GetProcAddress(kernel, "Thread32First"); 466 thread_first = (THREAD32) GetProcAddress(kernel, TEXT("Thread32First"));
441 thread_next = (THREAD32) GetProcAddress(kernel, "Thread32Next"); 467 thread_next = (THREAD32) GetProcAddress(kernel, TEXT("Thread32Next"));
442 module_first = (MODULE32) GetProcAddress(kernel, "Module32First"); 468 module_first = (MODULE32) GetProcAddress(kernel, TEXT("Module32First"));
443 module_next = (MODULE32) GetProcAddress(kernel, "Module32Next"); 469 module_next = (MODULE32) GetProcAddress(kernel, TEXT("Module32Next"));
444 470
445 if (snap && heap_first && heap_next && heaplist_first && 471 if (snap && heap_first && heap_next && heaplist_first &&
446 heaplist_next && process_first && process_next && 472 heaplist_next && process_first && process_next &&
@@ -575,7 +601,7 @@ static void readtimer(void)
575 DWORD w; 601 DWORD w;
576 LARGE_INTEGER l; 602 LARGE_INTEGER l;
577 static int have_perfc = 1; 603 static int have_perfc = 1;
578#ifdef _MSC_VER 604#if defined(_MSC_VER) && !defined(OPENSSL_SYS_WINCE)
579 static int have_tsc = 1; 605 static int have_tsc = 1;
580 DWORD cyclecount; 606 DWORD cyclecount;
581 607
@@ -628,6 +654,7 @@ static void readtimer(void)
628 654
629static void readscreen(void) 655static void readscreen(void)
630{ 656{
657#ifndef OPENSSL_SYS_WINCE
631 HDC hScrDC; /* screen DC */ 658 HDC hScrDC; /* screen DC */
632 HDC hMemDC; /* memory DC */ 659 HDC hMemDC; /* memory DC */
633 HBITMAP hBitmap; /* handle for our bitmap */ 660 HBITMAP hBitmap; /* handle for our bitmap */
@@ -641,7 +668,7 @@ static void readscreen(void)
641 int n = 16; /* number of screen lines to grab at a time */ 668 int n = 16; /* number of screen lines to grab at a time */
642 669
643 /* Create a screen DC and a memory DC compatible to screen DC */ 670 /* Create a screen DC and a memory DC compatible to screen DC */
644 hScrDC = CreateDC("DISPLAY", NULL, NULL, NULL); 671 hScrDC = CreateDC(TEXT("DISPLAY"), NULL, NULL, NULL);
645 hMemDC = CreateCompatibleDC(hScrDC); 672 hMemDC = CreateCompatibleDC(hScrDC);
646 673
647 /* Get screen resolution */ 674 /* Get screen resolution */
@@ -688,6 +715,7 @@ static void readscreen(void)
688 DeleteObject(hBitmap); 715 DeleteObject(hBitmap);
689 DeleteDC(hMemDC); 716 DeleteDC(hMemDC);
690 DeleteDC(hScrDC); 717 DeleteDC(hScrDC);
718#endif /* !OPENSSL_SYS_WINCE */
691} 719}
692 720
693#endif 721#endif
diff --git a/src/lib/libcrypto/rand/randfile.c b/src/lib/libcrypto/rand/randfile.c
index 311dd27a7b..cfbec2ac1f 100644
--- a/src/lib/libcrypto/rand/randfile.c
+++ b/src/lib/libcrypto/rand/randfile.c
@@ -132,7 +132,7 @@ int RAND_load_file(const char *file, long bytes)
132 } 132 }
133 } 133 }
134 fclose(in); 134 fclose(in);
135 memset(buf,0,BUFSIZE); 135 OPENSSL_cleanse(buf,BUFSIZE);
136err: 136err:
137 return(ret); 137 return(ret);
138 } 138 }
@@ -210,7 +210,7 @@ int RAND_write_file(const char *file)
210#endif /* OPENSSL_SYS_VMS */ 210#endif /* OPENSSL_SYS_VMS */
211 211
212 fclose(out); 212 fclose(out);
213 memset(buf,0,BUFSIZE); 213 OPENSSL_cleanse(buf,BUFSIZE);
214err: 214err:
215 return (rand_err ? -1 : ret); 215 return (rand_err ? -1 : ret);
216 } 216 }
@@ -225,8 +225,8 @@ const char *RAND_file_name(char *buf, size_t size)
225 s=getenv("RANDFILE"); 225 s=getenv("RANDFILE");
226 if (s != NULL && *s && strlen(s) + 1 < size) 226 if (s != NULL && *s && strlen(s) + 1 < size)
227 { 227 {
228 strlcpy(buf,s,size); 228 if (strlcpy(buf,s,size) >= size)
229 ok = 1; 229 return NULL;
230 } 230 }
231 else 231 else
232 { 232 {
diff --git a/src/lib/libcrypto/rand/randtest.c b/src/lib/libcrypto/rand/randtest.c
index b64de616db..701932e6ee 100644
--- a/src/lib/libcrypto/rand/randtest.c
+++ b/src/lib/libcrypto/rand/randtest.c
@@ -60,6 +60,8 @@
60#include <stdlib.h> 60#include <stdlib.h>
61#include <openssl/rand.h> 61#include <openssl/rand.h>
62 62
63#include "../e_os.h"
64
63/* some FIPS 140-1 random number test */ 65/* some FIPS 140-1 random number test */
64/* some simple tests */ 66/* some simple tests */
65 67
@@ -209,6 +211,6 @@ int main()
209 printf("test 4 done\n"); 211 printf("test 4 done\n");
210 err: 212 err:
211 err=((err)?1:0); 213 err=((err)?1:0);
212 exit(err); 214 EXIT(err);
213 return(err); 215 return(err);
214 } 216 }
diff --git a/src/lib/libcrypto/rc2/Makefile.ssl b/src/lib/libcrypto/rc2/Makefile.ssl
index 88e41bb98e..98d5960d5d 100644
--- a/src/lib/libcrypto/rc2/Makefile.ssl
+++ b/src/lib/libcrypto/rc2/Makefile.ssl
@@ -68,7 +68,7 @@ lint:
68 lint -DLINT $(INCLUDES) $(SRC)>fluff 68 lint -DLINT $(INCLUDES) $(SRC)>fluff
69 69
70depend: 70depend:
71 $(MAKEDEPEND) $(CFLAG) $(INCLUDES) $(DEPFLAG) $(PROGS) $(LIBSRC) 71 $(MAKEDEPEND) -- $(CFLAG) $(INCLUDES) $(DEPFLAG) -- $(PROGS) $(LIBSRC)
72 72
73dclean: 73dclean:
74 $(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new 74 $(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
diff --git a/src/lib/libcrypto/rc2/rc2test.c b/src/lib/libcrypto/rc2/rc2test.c
index d9a2a0a1cb..b67bafb49f 100644
--- a/src/lib/libcrypto/rc2/rc2test.c
+++ b/src/lib/libcrypto/rc2/rc2test.c
@@ -63,6 +63,8 @@
63#include <string.h> 63#include <string.h>
64#include <stdlib.h> 64#include <stdlib.h>
65 65
66#include "../e_os.h"
67
66#ifdef OPENSSL_NO_RC2 68#ifdef OPENSSL_NO_RC2
67int main(int argc, char *argv[]) 69int main(int argc, char *argv[])
68{ 70{
@@ -203,7 +205,7 @@ int main(int argc, char *argv[])
203 printf("ok\n"); 205 printf("ok\n");
204#endif 206#endif
205 207
206 exit(err); 208 EXIT(err);
207 return(err); 209 return(err);
208 } 210 }
209 211
diff --git a/src/lib/libcrypto/rc4/Makefile.ssl b/src/lib/libcrypto/rc4/Makefile.ssl
index 6e5bbf9894..9f9e16068f 100644
--- a/src/lib/libcrypto/rc4/Makefile.ssl
+++ b/src/lib/libcrypto/rc4/Makefile.ssl
@@ -52,14 +52,8 @@ lib: $(LIBOBJ)
52 @touch lib 52 @touch lib
53 53
54# elf 54# elf
55asm/rx86-elf.o: asm/rx86unix.cpp 55asm/rx86-elf.s: asm/rc4-586.pl ../perlasm/x86asm.pl
56 $(CPP) -DELF -x c asm/rx86unix.cpp | as -o asm/rx86-elf.o 56 (cd asm; $(PERL) rc4-586.pl elf $(CFLAGS) > rx86-elf.s)
57
58# solaris
59asm/rx86-sol.o: asm/rx86unix.cpp
60 $(CC) -E -DSOL asm/rx86unix.cpp | sed 's/^#.*//' > asm/rx86-sol.s
61 as -o asm/rx86-sol.o asm/rx86-sol.s
62 rm -f asm/rx86-sol.s
63 57
64# a.out 58# a.out
65asm/rx86-out.o: asm/rx86unix.cpp 59asm/rx86-out.o: asm/rx86unix.cpp
@@ -97,14 +91,14 @@ lint:
97 lint -DLINT $(INCLUDES) $(SRC)>fluff 91 lint -DLINT $(INCLUDES) $(SRC)>fluff
98 92
99depend: 93depend:
100 $(MAKEDEPEND) $(CFLAG) $(INCLUDES) $(DEPFLAG) $(PROGS) $(LIBSRC) 94 $(MAKEDEPEND) -- $(CFLAG) $(INCLUDES) $(DEPFLAG) -- $(PROGS) $(LIBSRC)
101 95
102dclean: 96dclean:
103 $(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new 97 $(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
104 mv -f Makefile.new $(MAKEFILE) 98 mv -f Makefile.new $(MAKEFILE)
105 99
106clean: 100clean:
107 rm -f asm/rx86unix.cpp *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff asm/*.o 101 rm -f asm/rx86unix.cpp asm/*-elf.* *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff asm/*.o
108 102
109# DO NOT DELETE THIS LINE -- make depend depends on it. 103# DO NOT DELETE THIS LINE -- make depend depends on it.
110 104
diff --git a/src/lib/libcrypto/rc4/rc4.c b/src/lib/libcrypto/rc4/rc4.c
index c2165b0b75..b39c070292 100644
--- a/src/lib/libcrypto/rc4/rc4.c
+++ b/src/lib/libcrypto/rc4/rc4.c
@@ -155,7 +155,7 @@ bad:
155 i=EVP_read_pw_string(buf,BUFSIZ,"Enter RC4 password:",0); 155 i=EVP_read_pw_string(buf,BUFSIZ,"Enter RC4 password:",0);
156 if (i != 0) 156 if (i != 0)
157 { 157 {
158 memset(buf,0,BUFSIZ); 158 OPENSSL_cleanse(buf,BUFSIZ);
159 fprintf(stderr,"bad password read\n"); 159 fprintf(stderr,"bad password read\n");
160 exit(1); 160 exit(1);
161 } 161 }
@@ -163,7 +163,7 @@ bad:
163 } 163 }
164 164
165 EVP_Digest((unsigned char *)keystr,(unsigned long)strlen(keystr),md,NULL,EVP_md5()); 165 EVP_Digest((unsigned char *)keystr,(unsigned long)strlen(keystr),md,NULL,EVP_md5());
166 memset(keystr,0,strlen(keystr)); 166 OPENSSL_cleanse(keystr,strlen(keystr));
167 RC4_set_key(&key,MD5_DIGEST_LENGTH,md); 167 RC4_set_key(&key,MD5_DIGEST_LENGTH,md);
168 168
169 for(;;) 169 for(;;)
diff --git a/src/lib/libcrypto/rc4/rc4test.c b/src/lib/libcrypto/rc4/rc4test.c
index a28d457c8d..b9d8f20975 100644
--- a/src/lib/libcrypto/rc4/rc4test.c
+++ b/src/lib/libcrypto/rc4/rc4test.c
@@ -60,6 +60,8 @@
60#include <stdlib.h> 60#include <stdlib.h>
61#include <string.h> 61#include <string.h>
62 62
63#include "../e_os.h"
64
63#ifdef OPENSSL_NO_RC4 65#ifdef OPENSSL_NO_RC4
64int main(int argc, char *argv[]) 66int main(int argc, char *argv[])
65{ 67{
@@ -195,7 +197,7 @@ int main(int argc, char *argv[])
195 } 197 }
196 } 198 }
197 printf("done\n"); 199 printf("done\n");
198 exit(err); 200 EXIT(err);
199 return(0); 201 return(0);
200 } 202 }
201#endif 203#endif
diff --git a/src/lib/libcrypto/rc5/Makefile.ssl b/src/lib/libcrypto/rc5/Makefile.ssl
index ff31ab47a9..a86f202f7b 100644
--- a/src/lib/libcrypto/rc5/Makefile.ssl
+++ b/src/lib/libcrypto/rc5/Makefile.ssl
@@ -49,14 +49,8 @@ lib: $(LIBOBJ)
49 @touch lib 49 @touch lib
50 50
51# elf 51# elf
52asm/r586-elf.o: asm/r586unix.cpp 52asm/r586-elf.s: asm/rc5-586.pl ../perlasm/x86asm.pl ../perlasm/cbc.pl
53 $(CPP) -DELF -x c asm/r586unix.cpp | as -o asm/r586-elf.o 53 (cd asm; $(PERL) rc5-586.pl elf $(CFLAGS) > r586-elf.s)
54
55# solaris
56asm/r586-sol.o: asm/r586unix.cpp
57 $(CC) -E -DSOL asm/r586unix.cpp | sed 's/^#.*//' > asm/r586-sol.s
58 as -o asm/r586-sol.o asm/r586-sol.s
59 rm -f asm/r586-sol.s
60 54
61# a.out 55# a.out
62asm/r586-out.o: asm/r586unix.cpp 56asm/r586-out.o: asm/r586unix.cpp
@@ -94,14 +88,14 @@ lint:
94 lint -DLINT $(INCLUDES) $(SRC)>fluff 88 lint -DLINT $(INCLUDES) $(SRC)>fluff
95 89
96depend: 90depend:
97 $(MAKEDEPEND) $(CFLAG) $(INCLUDES) $(DEPFLAG) $(PROGS) $(LIBSRC) 91 $(MAKEDEPEND) -- $(CFLAG) $(INCLUDES) $(DEPFLAG) -- $(PROGS) $(LIBSRC)
98 92
99dclean: 93dclean:
100 $(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new 94 $(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
101 mv -f Makefile.new $(MAKEFILE) 95 mv -f Makefile.new $(MAKEFILE)
102 96
103clean: 97clean:
104 rm -f asm/r586unix.cpp *.o asm/*.o *.obj lib tags core .pure .nfs* *.old *.bak fluff 98 rm -f asm/r586unix.cpp asm/*-elf.* *.o asm/*.o *.obj lib tags core .pure .nfs* *.old *.bak fluff
105 99
106# DO NOT DELETE THIS LINE -- make depend depends on it. 100# DO NOT DELETE THIS LINE -- make depend depends on it.
107 101
diff --git a/src/lib/libcrypto/ripemd/Makefile.ssl b/src/lib/libcrypto/ripemd/Makefile.ssl
index 7ab5d2fc9e..d85515353b 100644
--- a/src/lib/libcrypto/ripemd/Makefile.ssl
+++ b/src/lib/libcrypto/ripemd/Makefile.ssl
@@ -47,14 +47,8 @@ lib: $(LIBOBJ)
47 @touch lib 47 @touch lib
48 48
49# elf 49# elf
50asm/rm86-elf.o: asm/rm86unix.cpp 50asm/rm86-elf.s: asm/rmd-586.pl ../perlasm/x86asm.pl
51 $(CPP) -DELF -x c asm/rm86unix.cpp | as -o asm/rm86-elf.o 51 (cd asm; $(PERL) rmd-586.pl elf $(CFLAGS) > rm86-elf.s)
52
53# solaris
54asm/rm86-sol.o: asm/rm86unix.cpp
55 $(CC) -E -DSOL asm/rm86unix.cpp | sed 's/^#.*//' > asm/rm86-sol.s
56 as -o asm/rm86-sol.o asm/rm86-sol.s
57 rm -f asm/rm86-sol.s
58 52
59# a.out 53# a.out
60asm/rm86-out.o: asm/rm86unix.cpp 54asm/rm86-out.o: asm/rm86unix.cpp
@@ -92,19 +86,22 @@ lint:
92 lint -DLINT $(INCLUDES) $(SRC)>fluff 86 lint -DLINT $(INCLUDES) $(SRC)>fluff
93 87
94depend: 88depend:
95 $(MAKEDEPEND) $(CFLAG) $(INCLUDES) $(DEPFLAG) $(PROGS) $(LIBSRC) 89 $(MAKEDEPEND) -- $(CFLAG) $(INCLUDES) $(DEPFLAG) -- $(PROGS) $(LIBSRC)
96 90
97dclean: 91dclean:
98 $(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new 92 $(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
99 mv -f Makefile.new $(MAKEFILE) 93 mv -f Makefile.new $(MAKEFILE)
100 94
101clean: 95clean:
102 rm -f asm/rm86unix.cpp *.o asm/*.o *.obj lib tags core .pure .nfs* *.old *.bak fluff 96 rm -f asm/rm86unix.cpp asm/*-elf.* *.o asm/*.o *.obj lib tags core .pure .nfs* *.old *.bak fluff
103 97
104# DO NOT DELETE THIS LINE -- make depend depends on it. 98# DO NOT DELETE THIS LINE -- make depend depends on it.
105 99
106rmd_dgst.o: ../../include/openssl/e_os2.h ../../include/openssl/opensslconf.h 100rmd_dgst.o: ../../include/openssl/e_os2.h ../../include/openssl/opensslconf.h
107rmd_dgst.o: ../../include/openssl/opensslv.h ../../include/openssl/ripemd.h 101rmd_dgst.o: ../../include/openssl/opensslv.h ../../include/openssl/ripemd.h
108rmd_dgst.o: ../md32_common.h rmd_dgst.c rmd_locl.h rmdconst.h 102rmd_dgst.o: ../md32_common.h rmd_dgst.c rmd_locl.h rmdconst.h
109rmd_one.o: ../../include/openssl/e_os2.h ../../include/openssl/opensslconf.h 103rmd_one.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
110rmd_one.o: ../../include/openssl/ripemd.h rmd_one.c 104rmd_one.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
105rmd_one.o: ../../include/openssl/ripemd.h ../../include/openssl/safestack.h
106rmd_one.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
107rmd_one.o: rmd_one.c
diff --git a/src/lib/libcrypto/ripemd/rmd160.c b/src/lib/libcrypto/ripemd/rmd160.c
index 4f8b88a18a..b0ec574498 100644
--- a/src/lib/libcrypto/ripemd/rmd160.c
+++ b/src/lib/libcrypto/ripemd/rmd160.c
@@ -64,7 +64,7 @@
64 64
65void do_fp(FILE *f); 65void do_fp(FILE *f);
66void pt(unsigned char *md); 66void pt(unsigned char *md);
67#ifndef _OSD_POSIX 67#if !defined(_OSD_POSIX) && !defined(__DJGPP__)
68int read(int, void *, unsigned int); 68int read(int, void *, unsigned int);
69#endif 69#endif
70 70
diff --git a/src/lib/libcrypto/ripemd/rmd_dgst.c b/src/lib/libcrypto/ripemd/rmd_dgst.c
index a3170f7c8a..f351f00eea 100644
--- a/src/lib/libcrypto/ripemd/rmd_dgst.c
+++ b/src/lib/libcrypto/ripemd/rmd_dgst.c
@@ -90,8 +90,8 @@ int RIPEMD160_Init(RIPEMD160_CTX *c)
90void ripemd160_block_host_order (RIPEMD160_CTX *ctx, const void *p, int num) 90void ripemd160_block_host_order (RIPEMD160_CTX *ctx, const void *p, int num)
91 { 91 {
92 const RIPEMD160_LONG *XX=p; 92 const RIPEMD160_LONG *XX=p;
93 register unsigned long A,B,C,D,E; 93 register unsigned MD32_REG_T A,B,C,D,E;
94 register unsigned long a,b,c,d,e; 94 register unsigned MD32_REG_T a,b,c,d,e;
95 95
96 for (;num--;XX+=HASH_LBLOCK) 96 for (;num--;XX+=HASH_LBLOCK)
97 { 97 {
@@ -290,12 +290,12 @@ void ripemd160_block_host_order (RIPEMD160_CTX *ctx, const void *p, int num)
290void ripemd160_block_data_order (RIPEMD160_CTX *ctx, const void *p, int num) 290void ripemd160_block_data_order (RIPEMD160_CTX *ctx, const void *p, int num)
291 { 291 {
292 const unsigned char *data=p; 292 const unsigned char *data=p;
293 register unsigned long A,B,C,D,E; 293 register unsigned MD32_REG_T A,B,C,D,E;
294 unsigned long a,b,c,d,e,l; 294 unsigned MD32_REG_T a,b,c,d,e,l;
295#ifndef MD32_XARRAY 295#ifndef MD32_XARRAY
296 /* See comment in crypto/sha/sha_locl.h for details. */ 296 /* See comment in crypto/sha/sha_locl.h for details. */
297 unsigned long XX0, XX1, XX2, XX3, XX4, XX5, XX6, XX7, 297 unsigned MD32_REG_T XX0, XX1, XX2, XX3, XX4, XX5, XX6, XX7,
298 XX8, XX9,XX10,XX11,XX12,XX13,XX14,XX15; 298 XX8, XX9,XX10,XX11,XX12,XX13,XX14,XX15;
299# define X(i) XX##i 299# define X(i) XX##i
300#else 300#else
301 RIPEMD160_LONG XX[16]; 301 RIPEMD160_LONG XX[16];
diff --git a/src/lib/libcrypto/ripemd/rmd_one.c b/src/lib/libcrypto/ripemd/rmd_one.c
index efdf2dd6ef..f8b580c33a 100644
--- a/src/lib/libcrypto/ripemd/rmd_one.c
+++ b/src/lib/libcrypto/ripemd/rmd_one.c
@@ -59,6 +59,7 @@
59#include <stdio.h> 59#include <stdio.h>
60#include <string.h> 60#include <string.h>
61#include <openssl/ripemd.h> 61#include <openssl/ripemd.h>
62#include <openssl/crypto.h>
62 63
63unsigned char *RIPEMD160(const unsigned char *d, unsigned long n, 64unsigned char *RIPEMD160(const unsigned char *d, unsigned long n,
64 unsigned char *md) 65 unsigned char *md)
@@ -70,7 +71,7 @@ unsigned char *RIPEMD160(const unsigned char *d, unsigned long n,
70 RIPEMD160_Init(&c); 71 RIPEMD160_Init(&c);
71 RIPEMD160_Update(&c,d,n); 72 RIPEMD160_Update(&c,d,n);
72 RIPEMD160_Final(md,&c); 73 RIPEMD160_Final(md,&c);
73 memset(&c,0,sizeof(c)); /* security consideration */ 74 OPENSSL_cleanse(&c,sizeof(c)); /* security consideration */
74 return(md); 75 return(md);
75 } 76 }
76 77
diff --git a/src/lib/libcrypto/ripemd/rmdtest.c b/src/lib/libcrypto/ripemd/rmdtest.c
index be1fb8b1f6..d4c709e646 100644
--- a/src/lib/libcrypto/ripemd/rmdtest.c
+++ b/src/lib/libcrypto/ripemd/rmdtest.c
@@ -60,6 +60,8 @@
60#include <string.h> 60#include <string.h>
61#include <stdlib.h> 61#include <stdlib.h>
62 62
63#include "../e_os.h"
64
63#ifdef OPENSSL_NO_RIPEMD 65#ifdef OPENSSL_NO_RIPEMD
64int main(int argc, char *argv[]) 66int main(int argc, char *argv[])
65{ 67{
@@ -127,7 +129,7 @@ int main(int argc, char *argv[])
127 R++; 129 R++;
128 P++; 130 P++;
129 } 131 }
130 exit(err); 132 EXIT(err);
131 return(0); 133 return(0);
132 } 134 }
133 135
diff --git a/src/lib/libcrypto/rsa/Makefile.ssl b/src/lib/libcrypto/rsa/Makefile.ssl
index 8c44b7f142..8089344a04 100644
--- a/src/lib/libcrypto/rsa/Makefile.ssl
+++ b/src/lib/libcrypto/rsa/Makefile.ssl
@@ -72,7 +72,7 @@ lint:
72 lint -DLINT $(INCLUDES) $(SRC)>fluff 72 lint -DLINT $(INCLUDES) $(SRC)>fluff
73 73
74depend: 74depend:
75 $(MAKEDEPEND) $(CFLAG) $(INCLUDES) $(DEPFLAG) $(PROGS) $(LIBSRC) 75 $(MAKEDEPEND) -- $(CFLAG) $(INCLUDES) $(DEPFLAG) -- $(PROGS) $(LIBSRC)
76 76
77dclean: 77dclean:
78 $(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new 78 $(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
@@ -104,14 +104,12 @@ rsa_chk.o: rsa_chk.c
104rsa_eay.o: ../../e_os.h ../../include/openssl/asn1.h 104rsa_eay.o: ../../e_os.h ../../include/openssl/asn1.h
105rsa_eay.o: ../../include/openssl/bio.h ../../include/openssl/bn.h 105rsa_eay.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
106rsa_eay.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 106rsa_eay.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
107rsa_eay.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h 107rsa_eay.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
108rsa_eay.o: ../../include/openssl/e_os2.h ../../include/openssl/engine.h 108rsa_eay.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
109rsa_eay.o: ../../include/openssl/err.h ../../include/openssl/lhash.h 109rsa_eay.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
110rsa_eay.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h 110rsa_eay.o: ../../include/openssl/rand.h ../../include/openssl/rsa.h
111rsa_eay.o: ../../include/openssl/ossl_typ.h ../../include/openssl/rand.h 111rsa_eay.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
112rsa_eay.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h 112rsa_eay.o: ../../include/openssl/symhacks.h ../cryptlib.h rsa_eay.c
113rsa_eay.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
114rsa_eay.o: ../../include/openssl/ui.h ../cryptlib.h rsa_eay.c
115rsa_err.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h 113rsa_err.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
116rsa_err.o: ../../include/openssl/bn.h ../../include/openssl/crypto.h 114rsa_err.o: ../../include/openssl/bn.h ../../include/openssl/crypto.h
117rsa_err.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h 115rsa_err.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
@@ -217,21 +215,21 @@ rsa_sign.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
217rsa_sign.o: ../../include/openssl/crypto.h ../../include/openssl/des.h 215rsa_sign.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
218rsa_sign.o: ../../include/openssl/des_old.h ../../include/openssl/dh.h 216rsa_sign.o: ../../include/openssl/des_old.h ../../include/openssl/dh.h
219rsa_sign.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h 217rsa_sign.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
220rsa_sign.o: ../../include/openssl/engine.h ../../include/openssl/err.h 218rsa_sign.o: ../../include/openssl/err.h ../../include/openssl/evp.h
221rsa_sign.o: ../../include/openssl/evp.h ../../include/openssl/idea.h 219rsa_sign.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h
222rsa_sign.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h 220rsa_sign.o: ../../include/openssl/md2.h ../../include/openssl/md4.h
223rsa_sign.o: ../../include/openssl/md4.h ../../include/openssl/md5.h 221rsa_sign.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
224rsa_sign.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h 222rsa_sign.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
225rsa_sign.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h 223rsa_sign.o: ../../include/openssl/opensslconf.h
226rsa_sign.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h 224rsa_sign.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
227rsa_sign.o: ../../include/openssl/pkcs7.h ../../include/openssl/rand.h 225rsa_sign.o: ../../include/openssl/pkcs7.h ../../include/openssl/rc2.h
228rsa_sign.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h 226rsa_sign.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
229rsa_sign.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h 227rsa_sign.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
230rsa_sign.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h 228rsa_sign.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
231rsa_sign.o: ../../include/openssl/sha.h ../../include/openssl/stack.h 229rsa_sign.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
232rsa_sign.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h 230rsa_sign.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
233rsa_sign.o: ../../include/openssl/ui_compat.h ../../include/openssl/x509.h 231rsa_sign.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
234rsa_sign.o: ../../include/openssl/x509_vfy.h ../cryptlib.h rsa_sign.c 232rsa_sign.o: ../cryptlib.h rsa_sign.c
235rsa_ssl.o: ../../e_os.h ../../include/openssl/asn1.h 233rsa_ssl.o: ../../e_os.h ../../include/openssl/asn1.h
236rsa_ssl.o: ../../include/openssl/bio.h ../../include/openssl/bn.h 234rsa_ssl.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
237rsa_ssl.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 235rsa_ssl.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
diff --git a/src/lib/libcrypto/rsa/rsa.h b/src/lib/libcrypto/rsa/rsa.h
index 98b3bd7cc5..e26a68b482 100644
--- a/src/lib/libcrypto/rsa/rsa.h
+++ b/src/lib/libcrypto/rsa/rsa.h
@@ -158,6 +158,11 @@ struct rsa_st
158#define RSA_FLAG_CACHE_PUBLIC 0x02 158#define RSA_FLAG_CACHE_PUBLIC 0x02
159#define RSA_FLAG_CACHE_PRIVATE 0x04 159#define RSA_FLAG_CACHE_PRIVATE 0x04
160#define RSA_FLAG_BLINDING 0x08 160#define RSA_FLAG_BLINDING 0x08
161#define RSA_FLAG_NO_BLINDING 0x80 /* new with 0.9.6j and 0.9.7b; the built-in
162 * RSA implementation now uses blinding by
163 * default (ignoring RSA_FLAG_BLINDING),
164 * but other engines might not need it
165 */
161#define RSA_FLAG_THREAD_SAFE 0x10 166#define RSA_FLAG_THREAD_SAFE 0x10
162/* This flag means the private key operations will be handled by rsa_mod_exp 167/* This flag means the private key operations will be handled by rsa_mod_exp
163 * and that they do not depend on the private key components being present: 168 * and that they do not depend on the private key components being present:
@@ -170,11 +175,15 @@ struct rsa_st
170 */ 175 */
171#define RSA_FLAG_SIGN_VER 0x40 176#define RSA_FLAG_SIGN_VER 0x40
172 177
178#define RSA_FLAG_NO_BLINDING 0x80
179
173#define RSA_PKCS1_PADDING 1 180#define RSA_PKCS1_PADDING 1
174#define RSA_SSLV23_PADDING 2 181#define RSA_SSLV23_PADDING 2
175#define RSA_NO_PADDING 3 182#define RSA_NO_PADDING 3
176#define RSA_PKCS1_OAEP_PADDING 4 183#define RSA_PKCS1_OAEP_PADDING 4
177 184
185#define RSA_PKCS1_PADDING_SIZE 11
186
178#define RSA_set_app_data(s,arg) RSA_set_ex_data(s,0,arg) 187#define RSA_set_app_data(s,arg) RSA_set_ex_data(s,0,arg)
179#define RSA_get_app_data(s) RSA_get_ex_data(s,0) 188#define RSA_get_app_data(s) RSA_get_ex_data(s,0)
180 189
diff --git a/src/lib/libcrypto/rsa/rsa_eay.c b/src/lib/libcrypto/rsa/rsa_eay.c
index a3f549d8e6..027b4dc754 100644
--- a/src/lib/libcrypto/rsa/rsa_eay.c
+++ b/src/lib/libcrypto/rsa/rsa_eay.c
@@ -61,7 +61,6 @@
61#include <openssl/bn.h> 61#include <openssl/bn.h>
62#include <openssl/rsa.h> 62#include <openssl/rsa.h>
63#include <openssl/rand.h> 63#include <openssl/rand.h>
64#include <openssl/engine.h>
65 64
66#ifndef RSA_NULL 65#ifndef RSA_NULL
67 66
@@ -187,7 +186,7 @@ err:
187 BN_clear_free(&ret); 186 BN_clear_free(&ret);
188 if (buf != NULL) 187 if (buf != NULL)
189 { 188 {
190 memset(buf,0,num); 189 OPENSSL_cleanse(buf,num);
191 OPENSSL_free(buf); 190 OPENSSL_free(buf);
192 } 191 }
193 return(r); 192 return(r);
@@ -206,12 +205,46 @@ static int rsa_eay_blinding(RSA *rsa, BN_CTX *ctx)
206 205
207#define BLINDING_HELPER(rsa, ctx, err_instr) \ 206#define BLINDING_HELPER(rsa, ctx, err_instr) \
208 do { \ 207 do { \
209 if(((rsa)->flags & RSA_FLAG_BLINDING) && \ 208 if((!((rsa)->flags & RSA_FLAG_NO_BLINDING)) && \
210 ((rsa)->blinding == NULL) && \ 209 ((rsa)->blinding == NULL) && \
211 !rsa_eay_blinding(rsa, ctx)) \ 210 !rsa_eay_blinding(rsa, ctx)) \
212 err_instr \ 211 err_instr \
213 } while(0) 212 } while(0)
214 213
214static BN_BLINDING *setup_blinding(RSA *rsa, BN_CTX *ctx)
215 {
216 BIGNUM *A, *Ai;
217 BN_BLINDING *ret = NULL;
218
219 /* added in OpenSSL 0.9.6j and 0.9.7b */
220
221 /* NB: similar code appears in RSA_blinding_on (rsa_lib.c);
222 * this should be placed in a new function of its own, but for reasons
223 * of binary compatibility can't */
224
225 BN_CTX_start(ctx);
226 A = BN_CTX_get(ctx);
227 if ((RAND_status() == 0) && rsa->d != NULL && rsa->d->d != NULL)
228 {
229 /* if PRNG is not properly seeded, resort to secret exponent as unpredictable seed */
230 RAND_add(rsa->d->d, rsa->d->dmax * sizeof rsa->d->d[0], 0);
231 if (!BN_pseudo_rand_range(A,rsa->n)) goto err;
232 }
233 else
234 {
235 if (!BN_rand_range(A,rsa->n)) goto err;
236 }
237 if ((Ai=BN_mod_inverse(NULL,A,rsa->n,ctx)) == NULL) goto err;
238
239 if (!rsa->meth->bn_mod_exp(A,A,rsa->e,rsa->n,ctx,rsa->_method_mod_n))
240 goto err;
241 ret = BN_BLINDING_new(A,Ai,rsa->n);
242 BN_free(Ai);
243err:
244 BN_CTX_end(ctx);
245 return ret;
246 }
247
215/* signing */ 248/* signing */
216static int RSA_eay_private_encrypt(int flen, const unsigned char *from, 249static int RSA_eay_private_encrypt(int flen, const unsigned char *from,
217 unsigned char *to, RSA *rsa, int padding) 250 unsigned char *to, RSA *rsa, int padding)
@@ -220,6 +253,8 @@ static int RSA_eay_private_encrypt(int flen, const unsigned char *from,
220 int i,j,k,num=0,r= -1; 253 int i,j,k,num=0,r= -1;
221 unsigned char *buf=NULL; 254 unsigned char *buf=NULL;
222 BN_CTX *ctx=NULL; 255 BN_CTX *ctx=NULL;
256 int local_blinding = 0;
257 BN_BLINDING *blinding = NULL;
223 258
224 BN_init(&f); 259 BN_init(&f);
225 BN_init(&ret); 260 BN_init(&ret);
@@ -257,9 +292,38 @@ static int RSA_eay_private_encrypt(int flen, const unsigned char *from,
257 } 292 }
258 293
259 BLINDING_HELPER(rsa, ctx, goto err;); 294 BLINDING_HELPER(rsa, ctx, goto err;);
295 blinding = rsa->blinding;
296
297 /* Now unless blinding is disabled, 'blinding' is non-NULL.
298 * But the BN_BLINDING object may be owned by some other thread
299 * (we don't want to keep it constant and we don't want to use
300 * lots of locking to avoid race conditions, so only a single
301 * thread can use it; other threads have to use local blinding
302 * factors) */
303 if (!(rsa->flags & RSA_FLAG_NO_BLINDING))
304 {
305 if (blinding == NULL)
306 {
307 RSAerr(RSA_F_RSA_EAY_PRIVATE_ENCRYPT, ERR_R_INTERNAL_ERROR);
308 goto err;
309 }
310 }
311
312 if (blinding != NULL)
313 {
314 if (blinding->thread_id != CRYPTO_thread_id())
315 {
316 /* we need a local one-time blinding factor */
317
318 blinding = setup_blinding(rsa, ctx);
319 if (blinding == NULL)
320 goto err;
321 local_blinding = 1;
322 }
323 }
260 324
261 if (rsa->flags & RSA_FLAG_BLINDING) 325 if (blinding)
262 if (!BN_BLINDING_convert(&f,rsa->blinding,ctx)) goto err; 326 if (!BN_BLINDING_convert(&f, blinding, ctx)) goto err;
263 327
264 if ( (rsa->flags & RSA_FLAG_EXT_PKEY) || 328 if ( (rsa->flags & RSA_FLAG_EXT_PKEY) ||
265 ((rsa->p != NULL) && 329 ((rsa->p != NULL) &&
@@ -273,8 +337,8 @@ static int RSA_eay_private_encrypt(int flen, const unsigned char *from,
273 if (!rsa->meth->bn_mod_exp(&ret,&f,rsa->d,rsa->n,ctx,NULL)) goto err; 337 if (!rsa->meth->bn_mod_exp(&ret,&f,rsa->d,rsa->n,ctx,NULL)) goto err;
274 } 338 }
275 339
276 if (rsa->flags & RSA_FLAG_BLINDING) 340 if (blinding)
277 if (!BN_BLINDING_invert(&ret,rsa->blinding,ctx)) goto err; 341 if (!BN_BLINDING_invert(&ret, blinding, ctx)) goto err;
278 342
279 /* put in leading 0 bytes if the number is less than the 343 /* put in leading 0 bytes if the number is less than the
280 * length of the modulus */ 344 * length of the modulus */
@@ -288,9 +352,11 @@ err:
288 if (ctx != NULL) BN_CTX_free(ctx); 352 if (ctx != NULL) BN_CTX_free(ctx);
289 BN_clear_free(&ret); 353 BN_clear_free(&ret);
290 BN_clear_free(&f); 354 BN_clear_free(&f);
355 if (local_blinding)
356 BN_BLINDING_free(blinding);
291 if (buf != NULL) 357 if (buf != NULL)
292 { 358 {
293 memset(buf,0,num); 359 OPENSSL_cleanse(buf,num);
294 OPENSSL_free(buf); 360 OPENSSL_free(buf);
295 } 361 }
296 return(r); 362 return(r);
@@ -304,6 +370,8 @@ static int RSA_eay_private_decrypt(int flen, const unsigned char *from,
304 unsigned char *p; 370 unsigned char *p;
305 unsigned char *buf=NULL; 371 unsigned char *buf=NULL;
306 BN_CTX *ctx=NULL; 372 BN_CTX *ctx=NULL;
373 int local_blinding = 0;
374 BN_BLINDING *blinding = NULL;
307 375
308 BN_init(&f); 376 BN_init(&f);
309 BN_init(&ret); 377 BN_init(&ret);
@@ -336,9 +404,38 @@ static int RSA_eay_private_decrypt(int flen, const unsigned char *from,
336 } 404 }
337 405
338 BLINDING_HELPER(rsa, ctx, goto err;); 406 BLINDING_HELPER(rsa, ctx, goto err;);
407 blinding = rsa->blinding;
408
409 /* Now unless blinding is disabled, 'blinding' is non-NULL.
410 * But the BN_BLINDING object may be owned by some other thread
411 * (we don't want to keep it constant and we don't want to use
412 * lots of locking to avoid race conditions, so only a single
413 * thread can use it; other threads have to use local blinding
414 * factors) */
415 if (!(rsa->flags & RSA_FLAG_NO_BLINDING))
416 {
417 if (blinding == NULL)
418 {
419 RSAerr(RSA_F_RSA_EAY_PRIVATE_DECRYPT, ERR_R_INTERNAL_ERROR);
420 goto err;
421 }
422 }
423
424 if (blinding != NULL)
425 {
426 if (blinding->thread_id != CRYPTO_thread_id())
427 {
428 /* we need a local one-time blinding factor */
429
430 blinding = setup_blinding(rsa, ctx);
431 if (blinding == NULL)
432 goto err;
433 local_blinding = 1;
434 }
435 }
339 436
340 if (rsa->flags & RSA_FLAG_BLINDING) 437 if (blinding)
341 if (!BN_BLINDING_convert(&f,rsa->blinding,ctx)) goto err; 438 if (!BN_BLINDING_convert(&f, blinding, ctx)) goto err;
342 439
343 /* do the decrypt */ 440 /* do the decrypt */
344 if ( (rsa->flags & RSA_FLAG_EXT_PKEY) || 441 if ( (rsa->flags & RSA_FLAG_EXT_PKEY) ||
@@ -354,8 +451,8 @@ static int RSA_eay_private_decrypt(int flen, const unsigned char *from,
354 goto err; 451 goto err;
355 } 452 }
356 453
357 if (rsa->flags & RSA_FLAG_BLINDING) 454 if (blinding)
358 if (!BN_BLINDING_invert(&ret,rsa->blinding,ctx)) goto err; 455 if (!BN_BLINDING_invert(&ret, blinding, ctx)) goto err;
359 456
360 p=buf; 457 p=buf;
361 j=BN_bn2bin(&ret,p); /* j is only used with no-padding mode */ 458 j=BN_bn2bin(&ret,p); /* j is only used with no-padding mode */
@@ -389,7 +486,7 @@ err:
389 BN_clear_free(&ret); 486 BN_clear_free(&ret);
390 if (buf != NULL) 487 if (buf != NULL)
391 { 488 {
392 memset(buf,0,num); 489 OPENSSL_cleanse(buf,num);
393 OPENSSL_free(buf); 490 OPENSSL_free(buf);
394 } 491 }
395 return(r); 492 return(r);
@@ -486,7 +583,7 @@ err:
486 BN_clear_free(&ret); 583 BN_clear_free(&ret);
487 if (buf != NULL) 584 if (buf != NULL)
488 { 585 {
489 memset(buf,0,num); 586 OPENSSL_cleanse(buf,num);
490 OPENSSL_free(buf); 587 OPENSSL_free(buf);
491 } 588 }
492 return(r); 589 return(r);
diff --git a/src/lib/libcrypto/rsa/rsa_lib.c b/src/lib/libcrypto/rsa/rsa_lib.c
index 37fff8bce3..53c5092014 100644
--- a/src/lib/libcrypto/rsa/rsa_lib.c
+++ b/src/lib/libcrypto/rsa/rsa_lib.c
@@ -62,7 +62,10 @@
62#include <openssl/lhash.h> 62#include <openssl/lhash.h>
63#include <openssl/bn.h> 63#include <openssl/bn.h>
64#include <openssl/rsa.h> 64#include <openssl/rsa.h>
65#include <openssl/rand.h>
66#ifndef OPENSSL_NO_ENGINE
65#include <openssl/engine.h> 67#include <openssl/engine.h>
68#endif
66 69
67const char *RSA_version="RSA" OPENSSL_VERSION_PTEXT; 70const char *RSA_version="RSA" OPENSSL_VERSION_PTEXT;
68 71
@@ -72,10 +75,6 @@ RSA *RSA_new(void)
72 { 75 {
73 RSA *r=RSA_new_method(NULL); 76 RSA *r=RSA_new_method(NULL);
74 77
75#ifndef OPENSSL_NO_FORCE_RSA_BLINDING
76 r->flags|=RSA_FLAG_BLINDING;
77#endif
78
79 return r; 78 return r;
80 } 79 }
81 80
@@ -114,11 +113,13 @@ int RSA_set_method(RSA *rsa, const RSA_METHOD *meth)
114 const RSA_METHOD *mtmp; 113 const RSA_METHOD *mtmp;
115 mtmp = rsa->meth; 114 mtmp = rsa->meth;
116 if (mtmp->finish) mtmp->finish(rsa); 115 if (mtmp->finish) mtmp->finish(rsa);
116#ifndef OPENSSL_NO_ENGINE
117 if (rsa->engine) 117 if (rsa->engine)
118 { 118 {
119 ENGINE_finish(rsa->engine); 119 ENGINE_finish(rsa->engine);
120 rsa->engine = NULL; 120 rsa->engine = NULL;
121 } 121 }
122#endif
122 rsa->meth = meth; 123 rsa->meth = meth;
123 if (meth->init) meth->init(rsa); 124 if (meth->init) meth->init(rsa);
124 return 1; 125 return 1;
@@ -136,6 +137,7 @@ RSA *RSA_new_method(ENGINE *engine)
136 } 137 }
137 138
138 ret->meth = RSA_get_default_method(); 139 ret->meth = RSA_get_default_method();
140#ifndef OPENSSL_NO_ENGINE
139 if (engine) 141 if (engine)
140 { 142 {
141 if (!ENGINE_init(engine)) 143 if (!ENGINE_init(engine))
@@ -160,6 +162,7 @@ RSA *RSA_new_method(ENGINE *engine)
160 return NULL; 162 return NULL;
161 } 163 }
162 } 164 }
165#endif
163 166
164 ret->pad=0; 167 ret->pad=0;
165 ret->version=0; 168 ret->version=0;
@@ -181,8 +184,10 @@ RSA *RSA_new_method(ENGINE *engine)
181 CRYPTO_new_ex_data(CRYPTO_EX_INDEX_RSA, ret, &ret->ex_data); 184 CRYPTO_new_ex_data(CRYPTO_EX_INDEX_RSA, ret, &ret->ex_data);
182 if ((ret->meth->init != NULL) && !ret->meth->init(ret)) 185 if ((ret->meth->init != NULL) && !ret->meth->init(ret))
183 { 186 {
187#ifndef OPENSSL_NO_ENGINE
184 if (ret->engine) 188 if (ret->engine)
185 ENGINE_finish(ret->engine); 189 ENGINE_finish(ret->engine);
190#endif
186 CRYPTO_free_ex_data(CRYPTO_EX_INDEX_RSA, ret, &ret->ex_data); 191 CRYPTO_free_ex_data(CRYPTO_EX_INDEX_RSA, ret, &ret->ex_data);
187 OPENSSL_free(ret); 192 OPENSSL_free(ret);
188 ret=NULL; 193 ret=NULL;
@@ -211,8 +216,10 @@ void RSA_free(RSA *r)
211 216
212 if (r->meth->finish) 217 if (r->meth->finish)
213 r->meth->finish(r); 218 r->meth->finish(r);
219#ifndef OPENSSL_NO_ENGINE
214 if (r->engine) 220 if (r->engine)
215 ENGINE_finish(r->engine); 221 ENGINE_finish(r->engine);
222#endif
216 223
217 CRYPTO_free_ex_data(CRYPTO_EX_INDEX_RSA, r, &r->ex_data); 224 CRYPTO_free_ex_data(CRYPTO_EX_INDEX_RSA, r, &r->ex_data);
218 225
@@ -303,7 +310,8 @@ void RSA_blinding_off(RSA *rsa)
303 BN_BLINDING_free(rsa->blinding); 310 BN_BLINDING_free(rsa->blinding);
304 rsa->blinding=NULL; 311 rsa->blinding=NULL;
305 } 312 }
306 rsa->flags&= ~RSA_FLAG_BLINDING; 313 rsa->flags &= ~RSA_FLAG_BLINDING;
314 rsa->flags |= RSA_FLAG_NO_BLINDING;
307 } 315 }
308 316
309int RSA_blinding_on(RSA *rsa, BN_CTX *p_ctx) 317int RSA_blinding_on(RSA *rsa, BN_CTX *p_ctx)
@@ -322,15 +330,32 @@ int RSA_blinding_on(RSA *rsa, BN_CTX *p_ctx)
322 if (rsa->blinding != NULL) 330 if (rsa->blinding != NULL)
323 BN_BLINDING_free(rsa->blinding); 331 BN_BLINDING_free(rsa->blinding);
324 332
333 /* NB: similar code appears in setup_blinding (rsa_eay.c);
334 * this should be placed in a new function of its own, but for reasons
335 * of binary compatibility can't */
336
325 BN_CTX_start(ctx); 337 BN_CTX_start(ctx);
326 A = BN_CTX_get(ctx); 338 A = BN_CTX_get(ctx);
327 if (!BN_rand_range(A,rsa->n)) goto err; 339 if ((RAND_status() == 0) && rsa->d != NULL && rsa->d->d != NULL)
340 {
341 /* if PRNG is not properly seeded, resort to secret exponent as unpredictable seed */
342 RAND_add(rsa->d->d, rsa->d->dmax * sizeof rsa->d->d[0], 0);
343 if (!BN_pseudo_rand_range(A,rsa->n)) goto err;
344 }
345 else
346 {
347 if (!BN_rand_range(A,rsa->n)) goto err;
348 }
328 if ((Ai=BN_mod_inverse(NULL,A,rsa->n,ctx)) == NULL) goto err; 349 if ((Ai=BN_mod_inverse(NULL,A,rsa->n,ctx)) == NULL) goto err;
329 350
330 if (!rsa->meth->bn_mod_exp(A,A,rsa->e,rsa->n,ctx,rsa->_method_mod_n)) 351 if (!rsa->meth->bn_mod_exp(A,A,rsa->e,rsa->n,ctx,rsa->_method_mod_n))
331 goto err; 352 goto err;
332 rsa->blinding=BN_BLINDING_new(A,Ai,rsa->n); 353 if ((rsa->blinding=BN_BLINDING_new(A,Ai,rsa->n)) == NULL) goto err;
333 rsa->flags|=RSA_FLAG_BLINDING; 354 /* to make things thread-safe without excessive locking,
355 * rsa->blinding will be used just by the current thread: */
356 rsa->blinding->thread_id = CRYPTO_thread_id();
357 rsa->flags |= RSA_FLAG_BLINDING;
358 rsa->flags &= ~RSA_FLAG_NO_BLINDING;
334 BN_free(Ai); 359 BN_free(Ai);
335 ret=1; 360 ret=1;
336err: 361err:
diff --git a/src/lib/libcrypto/rsa/rsa_pk1.c b/src/lib/libcrypto/rsa/rsa_pk1.c
index c1edd6764f..8560755f1d 100644
--- a/src/lib/libcrypto/rsa/rsa_pk1.c
+++ b/src/lib/libcrypto/rsa/rsa_pk1.c
@@ -68,7 +68,7 @@ int RSA_padding_add_PKCS1_type_1(unsigned char *to, int tlen,
68 int j; 68 int j;
69 unsigned char *p; 69 unsigned char *p;
70 70
71 if (flen > (tlen-11)) 71 if (flen > (tlen-RSA_PKCS1_PADDING_SIZE))
72 { 72 {
73 RSAerr(RSA_F_RSA_PADDING_ADD_PKCS1_TYPE_1,RSA_R_DATA_TOO_LARGE_FOR_KEY_SIZE); 73 RSAerr(RSA_F_RSA_PADDING_ADD_PKCS1_TYPE_1,RSA_R_DATA_TOO_LARGE_FOR_KEY_SIZE);
74 return(0); 74 return(0);
diff --git a/src/lib/libcrypto/rsa/rsa_saos.c b/src/lib/libcrypto/rsa/rsa_saos.c
index 85adacc08f..f462716a57 100644
--- a/src/lib/libcrypto/rsa/rsa_saos.c
+++ b/src/lib/libcrypto/rsa/rsa_saos.c
@@ -77,7 +77,7 @@ int RSA_sign_ASN1_OCTET_STRING(int type,
77 77
78 i=i2d_ASN1_OCTET_STRING(&sig,NULL); 78 i=i2d_ASN1_OCTET_STRING(&sig,NULL);
79 j=RSA_size(rsa); 79 j=RSA_size(rsa);
80 if ((i-RSA_PKCS1_PADDING) > j) 80 if (i > (j-RSA_PKCS1_PADDING_SIZE))
81 { 81 {
82 RSAerr(RSA_F_RSA_SIGN_ASN1_OCTET_STRING,RSA_R_DIGEST_TOO_BIG_FOR_RSA_KEY); 82 RSAerr(RSA_F_RSA_SIGN_ASN1_OCTET_STRING,RSA_R_DIGEST_TOO_BIG_FOR_RSA_KEY);
83 return(0); 83 return(0);
@@ -96,7 +96,7 @@ int RSA_sign_ASN1_OCTET_STRING(int type,
96 else 96 else
97 *siglen=i; 97 *siglen=i;
98 98
99 memset(s,0,(unsigned int)j+1); 99 OPENSSL_cleanse(s,(unsigned int)j+1);
100 OPENSSL_free(s); 100 OPENSSL_free(s);
101 return(ret); 101 return(ret);
102 } 102 }
@@ -139,7 +139,7 @@ int RSA_verify_ASN1_OCTET_STRING(int dtype,
139 ret=1; 139 ret=1;
140err: 140err:
141 if (sig != NULL) M_ASN1_OCTET_STRING_free(sig); 141 if (sig != NULL) M_ASN1_OCTET_STRING_free(sig);
142 memset(s,0,(unsigned int)siglen); 142 OPENSSL_cleanse(s,(unsigned int)siglen);
143 OPENSSL_free(s); 143 OPENSSL_free(s);
144 return(ret); 144 return(ret);
145 } 145 }
diff --git a/src/lib/libcrypto/rsa/rsa_sign.c b/src/lib/libcrypto/rsa/rsa_sign.c
index 2a440901de..8a1e642183 100644
--- a/src/lib/libcrypto/rsa/rsa_sign.c
+++ b/src/lib/libcrypto/rsa/rsa_sign.c
@@ -62,7 +62,6 @@
62#include <openssl/rsa.h> 62#include <openssl/rsa.h>
63#include <openssl/objects.h> 63#include <openssl/objects.h>
64#include <openssl/x509.h> 64#include <openssl/x509.h>
65#include <openssl/engine.h>
66 65
67/* Size of an SSL signature: MD5+SHA1 */ 66/* Size of an SSL signature: MD5+SHA1 */
68#define SSL_SIG_LENGTH 36 67#define SSL_SIG_LENGTH 36
@@ -77,10 +76,11 @@ int RSA_sign(int type, const unsigned char *m, unsigned int m_len,
77 const unsigned char *s = NULL; 76 const unsigned char *s = NULL;
78 X509_ALGOR algor; 77 X509_ALGOR algor;
79 ASN1_OCTET_STRING digest; 78 ASN1_OCTET_STRING digest;
80 if((rsa->flags & RSA_FLAG_SIGN_VER) 79 if((rsa->flags & RSA_FLAG_SIGN_VER) && rsa->meth->rsa_sign)
81 && ENGINE_get_RSA(rsa->engine)->rsa_sign) 80 {
82 return ENGINE_get_RSA(rsa->engine)->rsa_sign(type, 81 return rsa->meth->rsa_sign(type, m, m_len,
83 m, m_len, sigret, siglen, rsa); 82 sigret, siglen, rsa);
83 }
84 /* Special case: SSL signature, just check the length */ 84 /* Special case: SSL signature, just check the length */
85 if(type == NID_md5_sha1) { 85 if(type == NID_md5_sha1) {
86 if(m_len != SSL_SIG_LENGTH) { 86 if(m_len != SSL_SIG_LENGTH) {
@@ -113,7 +113,7 @@ int RSA_sign(int type, const unsigned char *m, unsigned int m_len,
113 i=i2d_X509_SIG(&sig,NULL); 113 i=i2d_X509_SIG(&sig,NULL);
114 } 114 }
115 j=RSA_size(rsa); 115 j=RSA_size(rsa);
116 if ((i-RSA_PKCS1_PADDING) > j) 116 if (i > (j-RSA_PKCS1_PADDING_SIZE))
117 { 117 {
118 RSAerr(RSA_F_RSA_SIGN,RSA_R_DIGEST_TOO_BIG_FOR_RSA_KEY); 118 RSAerr(RSA_F_RSA_SIGN,RSA_R_DIGEST_TOO_BIG_FOR_RSA_KEY);
119 return(0); 119 return(0);
@@ -136,7 +136,7 @@ int RSA_sign(int type, const unsigned char *m, unsigned int m_len,
136 *siglen=i; 136 *siglen=i;
137 137
138 if(type != NID_md5_sha1) { 138 if(type != NID_md5_sha1) {
139 memset(tmps,0,(unsigned int)j+1); 139 OPENSSL_cleanse(tmps,(unsigned int)j+1);
140 OPENSSL_free(tmps); 140 OPENSSL_free(tmps);
141 } 141 }
142 return(ret); 142 return(ret);
@@ -155,10 +155,11 @@ int RSA_verify(int dtype, const unsigned char *m, unsigned int m_len,
155 return(0); 155 return(0);
156 } 156 }
157 157
158 if((rsa->flags & RSA_FLAG_SIGN_VER) 158 if((rsa->flags & RSA_FLAG_SIGN_VER) && rsa->meth->rsa_verify)
159 && ENGINE_get_RSA(rsa->engine)->rsa_verify) 159 {
160 return ENGINE_get_RSA(rsa->engine)->rsa_verify(dtype, 160 return rsa->meth->rsa_verify(dtype, m, m_len,
161 m, m_len, sigbuf, siglen, rsa); 161 sigbuf, siglen, rsa);
162 }
162 163
163 s=(unsigned char *)OPENSSL_malloc((unsigned int)siglen); 164 s=(unsigned char *)OPENSSL_malloc((unsigned int)siglen);
164 if (s == NULL) 165 if (s == NULL)
@@ -221,7 +222,7 @@ int RSA_verify(int dtype, const unsigned char *m, unsigned int m_len,
221 } 222 }
222err: 223err:
223 if (sig != NULL) X509_SIG_free(sig); 224 if (sig != NULL) X509_SIG_free(sig);
224 memset(s,0,(unsigned int)siglen); 225 OPENSSL_cleanse(s,(unsigned int)siglen);
225 OPENSSL_free(s); 226 OPENSSL_free(s);
226 return(ret); 227 return(ret);
227 } 228 }
diff --git a/src/lib/libcrypto/rsa/rsa_test.c b/src/lib/libcrypto/rsa/rsa_test.c
index b8b462d33b..924e9ad1f6 100644
--- a/src/lib/libcrypto/rsa/rsa_test.c
+++ b/src/lib/libcrypto/rsa/rsa_test.c
@@ -16,7 +16,6 @@ int main(int argc, char *argv[])
16} 16}
17#else 17#else
18#include <openssl/rsa.h> 18#include <openssl/rsa.h>
19#include <openssl/engine.h>
20 19
21#define SetKey \ 20#define SetKey \
22 key->n = BN_bin2bn(n, sizeof(n)-1, key->n); \ 21 key->n = BN_bin2bn(n, sizeof(n)-1, key->n); \
diff --git a/src/lib/libcrypto/sha/Makefile.ssl b/src/lib/libcrypto/sha/Makefile.ssl
index 0aa678d6f4..d52fb62b4f 100644
--- a/src/lib/libcrypto/sha/Makefile.ssl
+++ b/src/lib/libcrypto/sha/Makefile.ssl
@@ -47,14 +47,8 @@ lib: $(LIBOBJ)
47 @touch lib 47 @touch lib
48 48
49# elf 49# elf
50asm/sx86-elf.o: asm/sx86unix.cpp 50asm/sx86-elf.s: asm/sha1-586.pl ../perlasm/x86asm.pl
51 $(CPP) -DELF -x c asm/sx86unix.cpp | as -o asm/sx86-elf.o 51 (cd asm; $(PERL) sha1-586.pl elf $(CFLAGS) $(PROCESSOR) > sx86-elf.s)
52
53# solaris
54asm/sx86-sol.o: asm/sx86unix.cpp
55 $(CC) -E -DSOL asm/sx86unix.cpp | sed 's/^#.*//' > asm/sx86-sol.s
56 as -o asm/sx86-sol.o asm/sx86-sol.s
57 rm -f asm/sx86-sol.s
58 52
59# a.out 53# a.out
60asm/sx86-out.o: asm/sx86unix.cpp 54asm/sx86-out.o: asm/sx86unix.cpp
@@ -92,24 +86,30 @@ lint:
92 lint -DLINT $(INCLUDES) $(SRC)>fluff 86 lint -DLINT $(INCLUDES) $(SRC)>fluff
93 87
94depend: 88depend:
95 $(MAKEDEPEND) $(CFLAG) $(INCLUDES) $(DEPFLAG) $(PROGS) $(LIBSRC) 89 $(MAKEDEPEND) -- $(CFLAG) $(INCLUDES) $(DEPFLAG) -- $(PROGS) $(LIBSRC)
96 90
97dclean: 91dclean:
98 $(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new 92 $(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
99 mv -f Makefile.new $(MAKEFILE) 93 mv -f Makefile.new $(MAKEFILE)
100 94
101clean: 95clean:
102 rm -f asm/sx86unix.cpp *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff asm/*.o 96 rm -f asm/sx86unix.cpp asm/*-elf.* *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff asm/*.o
103 97
104# DO NOT DELETE THIS LINE -- make depend depends on it. 98# DO NOT DELETE THIS LINE -- make depend depends on it.
105 99
106sha1_one.o: ../../include/openssl/e_os2.h ../../include/openssl/opensslconf.h 100sha1_one.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
107sha1_one.o: ../../include/openssl/sha.h sha1_one.c 101sha1_one.o: ../../include/openssl/opensslconf.h
102sha1_one.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
103sha1_one.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
104sha1_one.o: ../../include/openssl/symhacks.h sha1_one.c
108sha1dgst.o: ../../include/openssl/e_os2.h ../../include/openssl/opensslconf.h 105sha1dgst.o: ../../include/openssl/e_os2.h ../../include/openssl/opensslconf.h
109sha1dgst.o: ../../include/openssl/opensslv.h ../../include/openssl/sha.h 106sha1dgst.o: ../../include/openssl/opensslv.h ../../include/openssl/sha.h
110sha1dgst.o: ../md32_common.h sha1dgst.c sha_locl.h 107sha1dgst.o: ../md32_common.h sha1dgst.c sha_locl.h
111sha_dgst.o: ../../include/openssl/e_os2.h ../../include/openssl/opensslconf.h 108sha_dgst.o: ../../include/openssl/e_os2.h ../../include/openssl/opensslconf.h
112sha_dgst.o: ../../include/openssl/opensslv.h ../../include/openssl/sha.h 109sha_dgst.o: ../../include/openssl/opensslv.h ../../include/openssl/sha.h
113sha_dgst.o: ../md32_common.h sha_dgst.c sha_locl.h 110sha_dgst.o: ../md32_common.h sha_dgst.c sha_locl.h
114sha_one.o: ../../include/openssl/e_os2.h ../../include/openssl/opensslconf.h 111sha_one.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
115sha_one.o: ../../include/openssl/sha.h sha_one.c 112sha_one.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
113sha_one.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
114sha_one.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
115sha_one.o: sha_one.c
diff --git a/src/lib/libcrypto/sha/sha1_one.c b/src/lib/libcrypto/sha/sha1_one.c
index e6a24888ed..20e660c71d 100644
--- a/src/lib/libcrypto/sha/sha1_one.c
+++ b/src/lib/libcrypto/sha/sha1_one.c
@@ -59,6 +59,7 @@
59#include <stdio.h> 59#include <stdio.h>
60#include <string.h> 60#include <string.h>
61#include <openssl/sha.h> 61#include <openssl/sha.h>
62#include <openssl/crypto.h>
62 63
63#ifndef OPENSSL_NO_SHA1 64#ifndef OPENSSL_NO_SHA1
64unsigned char *SHA1(const unsigned char *d, unsigned long n, unsigned char *md) 65unsigned char *SHA1(const unsigned char *d, unsigned long n, unsigned char *md)
@@ -70,7 +71,7 @@ unsigned char *SHA1(const unsigned char *d, unsigned long n, unsigned char *md)
70 SHA1_Init(&c); 71 SHA1_Init(&c);
71 SHA1_Update(&c,d,n); 72 SHA1_Update(&c,d,n);
72 SHA1_Final(md,&c); 73 SHA1_Final(md,&c);
73 memset(&c,0,sizeof(c)); 74 OPENSSL_cleanse(&c,sizeof(c));
74 return(md); 75 return(md);
75 } 76 }
76#endif 77#endif
diff --git a/src/lib/libcrypto/sha/sha1test.c b/src/lib/libcrypto/sha/sha1test.c
index 499a1cf5af..4f2e4ada2d 100644
--- a/src/lib/libcrypto/sha/sha1test.c
+++ b/src/lib/libcrypto/sha/sha1test.c
@@ -60,6 +60,8 @@
60#include <string.h> 60#include <string.h>
61#include <stdlib.h> 61#include <stdlib.h>
62 62
63#include "../e_os.h"
64
63#ifdef OPENSSL_NO_SHA 65#ifdef OPENSSL_NO_SHA
64int main(int argc, char *argv[]) 66int main(int argc, char *argv[])
65{ 67{
@@ -155,7 +157,7 @@ int main(int argc, char *argv[])
155 } 157 }
156 else 158 else
157 printf("test 3 ok\n"); 159 printf("test 3 ok\n");
158 exit(err); 160 EXIT(err);
159 EVP_MD_CTX_cleanup(&c); 161 EVP_MD_CTX_cleanup(&c);
160 return(0); 162 return(0);
161 } 163 }
diff --git a/src/lib/libcrypto/sha/sha_locl.h b/src/lib/libcrypto/sha/sha_locl.h
index 471dfb9f8f..2dd63a62a6 100644
--- a/src/lib/libcrypto/sha/sha_locl.h
+++ b/src/lib/libcrypto/sha/sha_locl.h
@@ -224,10 +224,10 @@ int HASH_INIT (SHA_CTX *c)
224void HASH_BLOCK_HOST_ORDER (SHA_CTX *c, const void *d, int num) 224void HASH_BLOCK_HOST_ORDER (SHA_CTX *c, const void *d, int num)
225 { 225 {
226 const SHA_LONG *W=d; 226 const SHA_LONG *W=d;
227 register unsigned long A,B,C,D,E,T; 227 register unsigned MD32_REG_T A,B,C,D,E,T;
228#ifndef MD32_XARRAY 228#ifndef MD32_XARRAY
229 unsigned long XX0, XX1, XX2, XX3, XX4, XX5, XX6, XX7, 229 unsigned MD32_REG_T XX0, XX1, XX2, XX3, XX4, XX5, XX6, XX7,
230 XX8, XX9,XX10,XX11,XX12,XX13,XX14,XX15; 230 XX8, XX9,XX10,XX11,XX12,XX13,XX14,XX15;
231#else 231#else
232 SHA_LONG XX[16]; 232 SHA_LONG XX[16];
233#endif 233#endif
@@ -349,10 +349,10 @@ void HASH_BLOCK_HOST_ORDER (SHA_CTX *c, const void *d, int num)
349void HASH_BLOCK_DATA_ORDER (SHA_CTX *c, const void *p, int num) 349void HASH_BLOCK_DATA_ORDER (SHA_CTX *c, const void *p, int num)
350 { 350 {
351 const unsigned char *data=p; 351 const unsigned char *data=p;
352 register unsigned long A,B,C,D,E,T,l; 352 register unsigned MD32_REG_T A,B,C,D,E,T,l;
353#ifndef MD32_XARRAY 353#ifndef MD32_XARRAY
354 unsigned long XX0, XX1, XX2, XX3, XX4, XX5, XX6, XX7, 354 unsigned MD32_REG_T XX0, XX1, XX2, XX3, XX4, XX5, XX6, XX7,
355 XX8, XX9,XX10,XX11,XX12,XX13,XX14,XX15; 355 XX8, XX9,XX10,XX11,XX12,XX13,XX14,XX15;
356#else 356#else
357 SHA_LONG XX[16]; 357 SHA_LONG XX[16];
358#endif 358#endif
diff --git a/src/lib/libcrypto/sha/sha_one.c b/src/lib/libcrypto/sha/sha_one.c
index 5426faae4a..e61c63f3e9 100644
--- a/src/lib/libcrypto/sha/sha_one.c
+++ b/src/lib/libcrypto/sha/sha_one.c
@@ -59,6 +59,7 @@
59#include <stdio.h> 59#include <stdio.h>
60#include <string.h> 60#include <string.h>
61#include <openssl/sha.h> 61#include <openssl/sha.h>
62#include <openssl/crypto.h>
62 63
63#ifndef OPENSSL_NO_SHA0 64#ifndef OPENSSL_NO_SHA0
64unsigned char *SHA(const unsigned char *d, unsigned long n, unsigned char *md) 65unsigned char *SHA(const unsigned char *d, unsigned long n, unsigned char *md)
@@ -70,7 +71,7 @@ unsigned char *SHA(const unsigned char *d, unsigned long n, unsigned char *md)
70 SHA_Init(&c); 71 SHA_Init(&c);
71 SHA_Update(&c,d,n); 72 SHA_Update(&c,d,n);
72 SHA_Final(md,&c); 73 SHA_Final(md,&c);
73 memset(&c,0,sizeof(c)); 74 OPENSSL_cleanse(&c,sizeof(c));
74 return(md); 75 return(md);
75 } 76 }
76#endif 77#endif
diff --git a/src/lib/libcrypto/sha/shatest.c b/src/lib/libcrypto/sha/shatest.c
index 331294a74f..5d2b1d3b1a 100644
--- a/src/lib/libcrypto/sha/shatest.c
+++ b/src/lib/libcrypto/sha/shatest.c
@@ -60,6 +60,8 @@
60#include <string.h> 60#include <string.h>
61#include <stdlib.h> 61#include <stdlib.h>
62 62
63#include "../e_os.h"
64
63#ifdef OPENSSL_NO_SHA 65#ifdef OPENSSL_NO_SHA
64int main(int argc, char *argv[]) 66int main(int argc, char *argv[])
65{ 67{
@@ -156,7 +158,7 @@ int main(int argc, char *argv[])
156 else 158 else
157 printf("test 3 ok\n"); 159 printf("test 3 ok\n");
158 EVP_MD_CTX_cleanup(&c); 160 EVP_MD_CTX_cleanup(&c);
159 exit(err); 161 EXIT(err);
160 return(0); 162 return(0);
161 } 163 }
162 164
diff --git a/src/lib/libcrypto/stack/Makefile.ssl b/src/lib/libcrypto/stack/Makefile.ssl
index 8574739c76..7120fb804a 100644
--- a/src/lib/libcrypto/stack/Makefile.ssl
+++ b/src/lib/libcrypto/stack/Makefile.ssl
@@ -68,7 +68,7 @@ lint:
68 lint -DLINT $(INCLUDES) $(SRC)>fluff 68 lint -DLINT $(INCLUDES) $(SRC)>fluff
69 69
70depend: 70depend:
71 $(MAKEDEPEND) $(CFLAG) $(INCLUDES) $(DEPFLAG) $(PROGS) $(LIBSRC) 71 $(MAKEDEPEND) -- $(CFLAG) $(INCLUDES) $(DEPFLAG) -- $(PROGS) $(LIBSRC)
72 72
73dclean: 73dclean:
74 $(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new 74 $(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
diff --git a/src/lib/libcrypto/threads/mttest.c b/src/lib/libcrypto/threads/mttest.c
index c474a63c74..8973921778 100644
--- a/src/lib/libcrypto/threads/mttest.c
+++ b/src/lib/libcrypto/threads/mttest.c
@@ -86,11 +86,6 @@
86#include <openssl/err.h> 86#include <openssl/err.h>
87#include <openssl/rand.h> 87#include <openssl/rand.h>
88 88
89#ifdef OPENSSL_NO_FP_API
90#define APPS_WIN16
91#include "../buffer/bss_file.c"
92#endif
93
94#define TEST_SERVER_CERT "../../apps/server.pem" 89#define TEST_SERVER_CERT "../../apps/server.pem"
95#define TEST_CLIENT_CERT "../../apps/client.pem" 90#define TEST_CLIENT_CERT "../../apps/client.pem"
96 91
diff --git a/src/lib/libcrypto/tmdiff.c b/src/lib/libcrypto/tmdiff.c
index 7ebf2b202a..307523ebba 100644
--- a/src/lib/libcrypto/tmdiff.c
+++ b/src/lib/libcrypto/tmdiff.c
@@ -59,13 +59,16 @@
59#include <stdlib.h> 59#include <stdlib.h>
60#include "cryptlib.h" 60#include "cryptlib.h"
61#include <openssl/tmdiff.h> 61#include <openssl/tmdiff.h>
62#if !defined(OPENSSL_SYS_MSDOS)
63#include OPENSSL_UNISTD
64#endif
62 65
63#ifdef TIMEB 66#ifdef TIMEB
64#undef OPENSSL_SYS_WIN32 67#undef OPENSSL_SYS_WIN32
65#undef TIMES 68#undef TIMES
66#endif 69#endif
67 70
68#if !defined(OPENSSL_SYS_MSDOS) && !defined(OPENSSL_SYS_WIN32) && !defined(OPENSSL_SYS_VMS) || defined(__DECC) && !defined(OPENSSL_SYS_MACOSX) && !defined(OPENSSL_SYS_VXWORKS) 71#if !defined(OPENSSL_SYS_MSDOS) && !defined(OPENSSL_SYS_WIN32) && !(defined(OPENSSL_SYS_VMS) || defined(__DECC)) && !defined(OPENSSL_SYS_MACOSX_RHAPSODY) && !defined(OPENSSL_SYS_VXWORKS)
69# define TIMES 72# define TIMES
70#endif 73#endif
71 74
@@ -101,14 +104,19 @@
101 104
102/* The following if from times(3) man page. It may need to be changed */ 105/* The following if from times(3) man page. It may need to be changed */
103#ifndef HZ 106#ifndef HZ
104# ifndef CLK_TCK 107# if defined(_SC_CLK_TCK) \
105# ifndef _BSD_CLK_TCK_ /* FreeBSD hack */ 108 && (!defined(OPENSSL_SYS_VMS) || __CTRL_VER >= 70000000)
106# define HZ 100.0 109# define HZ ((double)sysconf(_SC_CLK_TCK))
107# else /* _BSD_CLK_TCK_ */ 110# else
108# define HZ ((double)_BSD_CLK_TCK_) 111# ifndef CLK_TCK
112# ifndef _BSD_CLK_TCK_ /* FreeBSD hack */
113# define HZ 100.0
114# else /* _BSD_CLK_TCK_ */
115# define HZ ((double)_BSD_CLK_TCK_)
116# endif
117# else /* CLK_TCK */
118# define HZ ((double)CLK_TCK)
109# endif 119# endif
110# else /* CLK_TCK */
111# define HZ ((double)CLK_TCK)
112# endif 120# endif
113#endif 121#endif
114 122
@@ -121,7 +129,7 @@ typedef struct ms_tm
121 HANDLE thread_id; 129 HANDLE thread_id;
122 FILETIME ms_win32; 130 FILETIME ms_win32;
123# else 131# else
124# ifdef OPENSSL_SYS_VSWORKS 132# ifdef OPENSSL_SYS_VXWORKS
125 unsigned long ticks; 133 unsigned long ticks;
126# else 134# else
127 struct timeb ms_timeb; 135 struct timeb ms_timeb;
@@ -163,7 +171,7 @@ void ms_time_get(char *a)
163# ifdef OPENSSL_SYS_WIN32 171# ifdef OPENSSL_SYS_WIN32
164 GetThreadTimes(tm->thread_id,&tmpa,&tmpb,&tmpc,&(tm->ms_win32)); 172 GetThreadTimes(tm->thread_id,&tmpa,&tmpb,&tmpc,&(tm->ms_win32));
165# else 173# else
166# ifdef OPENSSL_SYS_VSWORKS 174# ifdef OPENSSL_SYS_VXWORKS
167 tm->ticks = tickGet(); 175 tm->ticks = tickGet();
168# else 176# else
169 ftime(&tm->ms_timeb); 177 ftime(&tm->ms_timeb);
@@ -197,7 +205,7 @@ double ms_time_diff(char *ap, char *bp)
197 ret=((double)(lb-la))/1e7; 205 ret=((double)(lb-la))/1e7;
198 } 206 }
199# else 207# else
200# ifdef OPENSSL_SYS_VSWORKS 208# ifdef OPENSSL_SYS_VXWORKS
201 ret = (double)(b->ticks - a->ticks) / (double)sysClkRateGet(); 209 ret = (double)(b->ticks - a->ticks) / (double)sysClkRateGet();
202# else 210# else
203 ret= (double)(b->ms_timeb.time-a->ms_timeb.time)+ 211 ret= (double)(b->ms_timeb.time-a->ms_timeb.time)+
@@ -222,7 +230,7 @@ int ms_time_cmp(char *ap, char *bp)
222 d =(b->ms_win32.dwHighDateTime&0x000fffff)*10+b->ms_win32.dwLowDateTime/1e7; 230 d =(b->ms_win32.dwHighDateTime&0x000fffff)*10+b->ms_win32.dwLowDateTime/1e7;
223 d-=(a->ms_win32.dwHighDateTime&0x000fffff)*10+a->ms_win32.dwLowDateTime/1e7; 231 d-=(a->ms_win32.dwHighDateTime&0x000fffff)*10+a->ms_win32.dwLowDateTime/1e7;
224# else 232# else
225# ifdef OPENSSL_SYS_VSWORKS 233# ifdef OPENSSL_SYS_VXWORKS
226 d = (b->ticks - a->ticks); 234 d = (b->ticks - a->ticks);
227# else 235# else
228 d= (double)(b->ms_timeb.time-a->ms_timeb.time)+ 236 d= (double)(b->ms_timeb.time-a->ms_timeb.time)+
diff --git a/src/lib/libcrypto/txt_db/Makefile.ssl b/src/lib/libcrypto/txt_db/Makefile.ssl
index 61ff361348..6221dfae4d 100644
--- a/src/lib/libcrypto/txt_db/Makefile.ssl
+++ b/src/lib/libcrypto/txt_db/Makefile.ssl
@@ -68,7 +68,7 @@ lint:
68 lint -DLINT $(INCLUDES) $(SRC)>fluff 68 lint -DLINT $(INCLUDES) $(SRC)>fluff
69 69
70depend: 70depend:
71 $(MAKEDEPEND) $(CFLAG) $(INCLUDES) $(DEPFLAG) $(PROGS) $(LIBSRC) 71 $(MAKEDEPEND) -- $(CFLAG) $(INCLUDES) $(DEPFLAG) -- $(PROGS) $(LIBSRC)
72 72
73dclean: 73dclean:
74 $(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new 74 $(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
diff --git a/src/lib/libcrypto/txt_db/txt_db.c b/src/lib/libcrypto/txt_db/txt_db.c
index 9b186f2da5..58b300b00b 100644
--- a/src/lib/libcrypto/txt_db/txt_db.c
+++ b/src/lib/libcrypto/txt_db/txt_db.c
@@ -108,7 +108,7 @@ TXT_DB *TXT_DB_read(BIO *in, int num)
108 if (offset != 0) 108 if (offset != 0)
109 { 109 {
110 size+=BUFSIZE; 110 size+=BUFSIZE;
111 if (!BUF_MEM_grow(buf,size)) goto err; 111 if (!BUF_MEM_grow_clean(buf,size)) goto err;
112 } 112 }
113 buf->data[offset]='\0'; 113 buf->data[offset]='\0';
114 BIO_gets(in,&(buf->data[offset]),size-offset); 114 BIO_gets(in,&(buf->data[offset]),size-offset);
@@ -268,7 +268,7 @@ long TXT_DB_write(BIO *out, TXT_DB *db)
268 if (pp[j] != NULL) 268 if (pp[j] != NULL)
269 l+=strlen(pp[j]); 269 l+=strlen(pp[j]);
270 } 270 }
271 if (!BUF_MEM_grow(buf,(int)(l*2+nn))) goto err; 271 if (!BUF_MEM_grow_clean(buf,(int)(l*2+nn))) goto err;
272 272
273 p=buf->data; 273 p=buf->data;
274 for (j=0; j<nn; j++) 274 for (j=0; j<nn; j++)
diff --git a/src/lib/libcrypto/ui/Makefile.ssl b/src/lib/libcrypto/ui/Makefile.ssl
index 57b2e38335..ba46951d1c 100644
--- a/src/lib/libcrypto/ui/Makefile.ssl
+++ b/src/lib/libcrypto/ui/Makefile.ssl
@@ -44,7 +44,7 @@ all: lib
44 44
45lib: $(LIBOBJ) 45lib: $(LIBOBJ)
46 $(AR) $(LIB) $(LIBOBJ) 46 $(AR) $(LIB) $(LIBOBJ)
47 $(RANLIB) $(LIB) 47 $(RANLIB) $(LIB) || echo Never mind.
48 @touch lib 48 @touch lib
49 49
50files: 50files:
@@ -72,7 +72,7 @@ lint:
72 lint -DLINT $(INCLUDES) $(SRC)>fluff 72 lint -DLINT $(INCLUDES) $(SRC)>fluff
73 73
74depend: 74depend:
75 $(MAKEDEPEND) $(CFLAG) $(INCLUDES) $(DEPFLAG) $(PROGS) $(LIBSRC) 75 $(MAKEDEPEND) -- $(CFLAG) $(INCLUDES) $(DEPFLAG) -- $(PROGS) $(LIBSRC)
76 76
77dclean: 77dclean:
78 $(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new 78 $(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
@@ -95,13 +95,13 @@ ui_err.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
95ui_err.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h 95ui_err.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
96ui_err.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 96ui_err.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
97ui_err.o: ../../include/openssl/ui.h ui_err.c 97ui_err.o: ../../include/openssl/ui.h ui_err.c
98ui_lib.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h 98ui_lib.o: ../../e_os.h ../../include/openssl/bio.h
99ui_lib.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h 99ui_lib.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
100ui_lib.o: ../../include/openssl/err.h ../../include/openssl/lhash.h 100ui_lib.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
101ui_lib.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h 101ui_lib.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
102ui_lib.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h 102ui_lib.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
103ui_lib.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h ui_lib.c 103ui_lib.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
104ui_lib.o: ui_locl.h 104ui_lib.o: ../../include/openssl/ui.h ../cryptlib.h ui_lib.c ui_locl.h
105ui_openssl.o: ../../e_os.h ../../include/openssl/bio.h 105ui_openssl.o: ../../e_os.h ../../include/openssl/bio.h
106ui_openssl.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 106ui_openssl.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
107ui_openssl.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h 107ui_openssl.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
diff --git a/src/lib/libcrypto/ui/ui_lib.c b/src/lib/libcrypto/ui/ui_lib.c
index cce9075ac1..33c86d76ef 100644
--- a/src/lib/libcrypto/ui/ui_lib.c
+++ b/src/lib/libcrypto/ui/ui_lib.c
@@ -62,6 +62,7 @@
62#include <openssl/ui.h> 62#include <openssl/ui.h>
63#include <openssl/err.h> 63#include <openssl/err.h>
64#include "ui_locl.h" 64#include "ui_locl.h"
65#include "cryptlib.h"
65 66
66IMPLEMENT_STACK_OF(UI_STRING_ST) 67IMPLEMENT_STACK_OF(UI_STRING_ST)
67 68
@@ -144,7 +145,8 @@ static UI_STRING *general_allocate_prompt(UI *ui, const char *prompt,
144 { 145 {
145 UIerr(UI_F_GENERAL_ALLOCATE_PROMPT,ERR_R_PASSED_NULL_PARAMETER); 146 UIerr(UI_F_GENERAL_ALLOCATE_PROMPT,ERR_R_PASSED_NULL_PARAMETER);
146 } 147 }
147 else if (result_buf == NULL) 148 else if ((type == UIT_PROMPT || type == UIT_VERIFY
149 || type == UIT_BOOLEAN) && result_buf == NULL)
148 { 150 {
149 UIerr(UI_F_GENERAL_ALLOCATE_PROMPT,UI_R_NO_RESULT_BUFFER); 151 UIerr(UI_F_GENERAL_ALLOCATE_PROMPT,UI_R_NO_RESULT_BUFFER);
150 } 152 }
@@ -235,7 +237,7 @@ static int general_allocate_boolean(UI *ui,
235 return ret; 237 return ret;
236 } 238 }
237 239
238/* Returns the index to the place in the stack or 0 for error. Uses a 240/* Returns the index to the place in the stack or -1 for error. Uses a
239 direct reference to the prompt. */ 241 direct reference to the prompt. */
240int UI_add_input_string(UI *ui, const char *prompt, int flags, 242int UI_add_input_string(UI *ui, const char *prompt, int flags,
241 char *result_buf, int minsize, int maxsize) 243 char *result_buf, int minsize, int maxsize)
@@ -831,8 +833,8 @@ int UI_set_result(UI *ui, UI_STRING *uis, const char *result)
831 case UIT_PROMPT: 833 case UIT_PROMPT:
832 case UIT_VERIFY: 834 case UIT_VERIFY:
833 { 835 {
834 char number1[20]; 836 char number1[DECIMAL_SIZE(uis->_.string_data.result_minsize)+1];
835 char number2[20]; 837 char number2[DECIMAL_SIZE(uis->_.string_data.result_maxsize)+1];
836 838
837 BIO_snprintf(number1, sizeof(number1), "%d", 839 BIO_snprintf(number1, sizeof(number1), "%d",
838 uis->_.string_data.result_minsize); 840 uis->_.string_data.result_minsize);
diff --git a/src/lib/libcrypto/ui/ui_openssl.c b/src/lib/libcrypto/ui/ui_openssl.c
index f47ed31cb0..75318d48a1 100644
--- a/src/lib/libcrypto/ui/ui_openssl.c
+++ b/src/lib/libcrypto/ui/ui_openssl.c
@@ -159,8 +159,10 @@
159 159
160#ifdef WIN_CONSOLE_BUG 160#ifdef WIN_CONSOLE_BUG
161# include <windows.h> 161# include <windows.h>
162#ifndef OPENSSL_SYS_WINCE
162# include <wincon.h> 163# include <wincon.h>
163#endif 164#endif
165#endif
164 166
165 167
166/* There are 5 types of terminal interface supported, 168/* There are 5 types of terminal interface supported,
@@ -191,7 +193,7 @@
191# define SGTTY 193# define SGTTY
192#endif 194#endif
193 195
194#if defined(OPENSSL_SYS_VSWORKS) 196#if defined(OPENSSL_SYS_VXWORKS)
195#undef TERMIOS 197#undef TERMIOS
196#undef TERMIO 198#undef TERMIO
197#undef SGTTY 199#undef SGTTY
@@ -221,7 +223,7 @@
221# define TTY_set(tty,data) ioctl(tty,TIOCSETP,data) 223# define TTY_set(tty,data) ioctl(tty,TIOCSETP,data)
222#endif 224#endif
223 225
224#if !defined(_LIBC) && !defined(OPENSSL_SYS_MSDOS) && !defined(OPENSSL_SYS_VMS) && !defined(OPENSSL_SYS_MACINTOSH_CLASSIC) 226#if !defined(_LIBC) && !defined(OPENSSL_SYS_MSDOS) && !defined(OPENSSL_SYS_VMS) && !defined(OPENSSL_SYS_MACINTOSH_CLASSIC) && !defined(OPENSSL_SYS_SUNOS)
225# include <sys/ioctl.h> 227# include <sys/ioctl.h>
226#endif 228#endif
227 229
@@ -241,6 +243,10 @@ struct IOSB {
241 }; 243 };
242#endif 244#endif
243 245
246#ifdef OPENSSL_SYS_SUNOS
247 typedef int sig_atomic_t;
248#endif
249
244#if defined(OPENSSL_SYS_MACINTOSH_CLASSIC) || defined(MAC_OS_GUSI_SOURCE) 250#if defined(OPENSSL_SYS_MACINTOSH_CLASSIC) || defined(MAC_OS_GUSI_SOURCE)
245/* 251/*
246 * This one needs work. As a matter of fact the code is unoperational 252 * This one needs work. As a matter of fact the code is unoperational
@@ -277,10 +283,12 @@ static FILE *tty_in, *tty_out;
277static int is_a_tty; 283static int is_a_tty;
278 284
279/* Declare static functions */ 285/* Declare static functions */
286#if !defined(OPENSSL_SYS_WIN16) && !defined(OPENSSL_SYS_WINCE)
280static void read_till_nl(FILE *); 287static void read_till_nl(FILE *);
281static void recsig(int); 288static void recsig(int);
282static void pushsig(void); 289static void pushsig(void);
283static void popsig(void); 290static void popsig(void);
291#endif
284#if defined(OPENSSL_SYS_MSDOS) && !defined(OPENSSL_SYS_WIN16) 292#if defined(OPENSSL_SYS_MSDOS) && !defined(OPENSSL_SYS_WIN16)
285static int noecho_fgets(char *buf, int size, FILE *tty); 293static int noecho_fgets(char *buf, int size, FILE *tty);
286#endif 294#endif
@@ -367,6 +375,7 @@ static int read_string(UI *ui, UI_STRING *uis)
367 } 375 }
368 376
369 377
378#if !defined(OPENSSL_SYS_WIN16) && !defined(OPENSSL_SYS_WINCE)
370/* Internal functions to read a string without echoing */ 379/* Internal functions to read a string without echoing */
371static void read_till_nl(FILE *in) 380static void read_till_nl(FILE *in)
372 { 381 {
@@ -379,6 +388,7 @@ static void read_till_nl(FILE *in)
379 } 388 }
380 389
381static volatile sig_atomic_t intr_signal; 390static volatile sig_atomic_t intr_signal;
391#endif
382 392
383static int read_string_inner(UI *ui, UI_STRING *uis, int echo, int strip_nl) 393static int read_string_inner(UI *ui, UI_STRING *uis, int echo, int strip_nl)
384 { 394 {
@@ -386,9 +396,9 @@ static int read_string_inner(UI *ui, UI_STRING *uis, int echo, int strip_nl)
386 int ok; 396 int ok;
387 char result[BUFSIZ]; 397 char result[BUFSIZ];
388 int maxsize = BUFSIZ-1; 398 int maxsize = BUFSIZ-1;
399#if !defined(OPENSSL_SYS_WIN16) && !defined(OPENSSL_SYS_WINCE)
389 char *p; 400 char *p;
390 401
391#ifndef OPENSSL_SYS_WIN16
392 intr_signal=0; 402 intr_signal=0;
393 ok=0; 403 ok=0;
394 ps=0; 404 ps=0;
@@ -439,7 +449,7 @@ error:
439 ok=1; 449 ok=1;
440#endif 450#endif
441 451
442 memset(result,0,BUFSIZ); 452 OPENSSL_cleanse(result,BUFSIZ);
443 return ok; 453 return ok;
444 } 454 }
445 455
@@ -450,7 +460,7 @@ static int open_console(UI *ui)
450 CRYPTO_w_lock(CRYPTO_LOCK_UI); 460 CRYPTO_w_lock(CRYPTO_LOCK_UI);
451 is_a_tty = 1; 461 is_a_tty = 1;
452 462
453#if defined(OPENSSL_SYS_MACINTOSH_CLASSIC) || defined(OPENSSL_SYS_VSWORKS) 463#if defined(OPENSSL_SYS_MACINTOSH_CLASSIC) || defined(OPENSSL_SYS_VXWORKS)
454 tty_in=stdin; 464 tty_in=stdin;
455 tty_out=stderr; 465 tty_out=stderr;
456#else 466#else
@@ -540,7 +550,7 @@ static int echo_console(UI *ui)
540 550
541static int close_console(UI *ui) 551static int close_console(UI *ui)
542 { 552 {
543 if (tty_in != stderr) fclose(tty_in); 553 if (tty_in != stdin) fclose(tty_in);
544 if (tty_out != stderr) fclose(tty_out); 554 if (tty_out != stderr) fclose(tty_out);
545#ifdef OPENSSL_SYS_VMS 555#ifdef OPENSSL_SYS_VMS
546 status = sys$dassgn(channel); 556 status = sys$dassgn(channel);
@@ -551,6 +561,7 @@ static int close_console(UI *ui)
551 } 561 }
552 562
553 563
564#if !defined(OPENSSL_SYS_WIN16) && !defined(OPENSSL_SYS_WINCE)
554/* Internal functions to handle signals and act on them */ 565/* Internal functions to handle signals and act on them */
555static void pushsig(void) 566static void pushsig(void)
556 { 567 {
@@ -614,9 +625,10 @@ static void recsig(int i)
614 { 625 {
615 intr_signal=i; 626 intr_signal=i;
616 } 627 }
628#endif
617 629
618/* Internal functions specific for Windows */ 630/* Internal functions specific for Windows */
619#if defined(OPENSSL_SYS_MSDOS) && !defined(OPENSSL_SYS_WIN16) 631#if defined(OPENSSL_SYS_MSDOS) && !defined(OPENSSL_SYS_WIN16) && !defined(OPENSSL_SYS_WINCE)
620static int noecho_fgets(char *buf, int size, FILE *tty) 632static int noecho_fgets(char *buf, int size, FILE *tty)
621 { 633 {
622 int i; 634 int i;
diff --git a/src/lib/libcrypto/ui/ui_util.c b/src/lib/libcrypto/ui/ui_util.c
index f05573df33..46bc8c1a9a 100644
--- a/src/lib/libcrypto/ui/ui_util.c
+++ b/src/lib/libcrypto/ui/ui_util.c
@@ -62,7 +62,7 @@ int UI_UTIL_read_pw_string(char *buf,int length,const char *prompt,int verify)
62 int ret; 62 int ret;
63 63
64 ret=UI_UTIL_read_pw(buf,buff,(length>BUFSIZ)?BUFSIZ:length,prompt,verify); 64 ret=UI_UTIL_read_pw(buf,buff,(length>BUFSIZ)?BUFSIZ:length,prompt,verify);
65 memset(buff,0,BUFSIZ); 65 OPENSSL_cleanse(buff,BUFSIZ);
66 return(ret); 66 return(ret);
67 } 67 }
68 68
@@ -78,12 +78,14 @@ int UI_UTIL_read_pw(char *buf,char *buff,int size,const char *prompt,int verify)
78 if (ui) 78 if (ui)
79 { 79 {
80 ok = UI_add_input_string(ui,prompt,0,buf,0,size-1); 80 ok = UI_add_input_string(ui,prompt,0,buf,0,size-1);
81 if (ok == 0 && verify) 81 if (ok >= 0 && verify)
82 ok = UI_add_verify_string(ui,prompt,0,buff,0,size-1, 82 ok = UI_add_verify_string(ui,prompt,0,buff,0,size-1,
83 buf); 83 buf);
84 if (ok == 0) 84 if (ok >= 0)
85 ok=UI_process(ui); 85 ok=UI_process(ui);
86 UI_free(ui); 86 UI_free(ui);
87 } 87 }
88 if (ok > 0)
89 ok = 0;
88 return(ok); 90 return(ok);
89 } 91 }
diff --git a/src/lib/libcrypto/uid.c b/src/lib/libcrypto/uid.c
index d3d249c36f..73205a4baa 100644
--- a/src/lib/libcrypto/uid.c
+++ b/src/lib/libcrypto/uid.c
@@ -65,7 +65,7 @@ int OPENSSL_issetugid(void)
65 return issetugid(); 65 return issetugid();
66 } 66 }
67 67
68#elif defined(OPENSSL_SYS_WIN32) 68#elif defined(OPENSSL_SYS_WIN32) || defined(OPENSSL_SYS_VXWORKS)
69 69
70int OPENSSL_issetugid(void) 70int OPENSSL_issetugid(void)
71 { 71 {
diff --git a/src/lib/libcrypto/util/cygwin.sh b/src/lib/libcrypto/util/cygwin.sh
index b607399b02..930f766b4f 100644
--- a/src/lib/libcrypto/util/cygwin.sh
+++ b/src/lib/libcrypto/util/cygwin.sh
@@ -96,6 +96,8 @@ fi
96 96
97get_openssl_version 97get_openssl_version
98 98
99make depend || exit 1
100
99make || exit 1 101make || exit 1
100 102
101base_install 103base_install
diff --git a/src/lib/libcrypto/util/domd b/src/lib/libcrypto/util/domd
index 8cbe383c16..49310bbdd1 100644
--- a/src/lib/libcrypto/util/domd
+++ b/src/lib/libcrypto/util/domd
@@ -15,9 +15,14 @@ cp Makefile.ssl Makefile.save
15# fake the presence of Kerberos 15# fake the presence of Kerberos
16touch $TOP/krb5.h 16touch $TOP/krb5.h
17if [ "$MAKEDEPEND" = "gcc" ]; then 17if [ "$MAKEDEPEND" = "gcc" ]; then
18 args=""
19 while [ $# -gt 0 ]; do
20 if [ "$1" != "--" ]; then args="$args $1"; fi
21 shift
22 done
18 sed -e '/^# DO NOT DELETE.*/,$d' < Makefile.ssl > Makefile.tmp 23 sed -e '/^# DO NOT DELETE.*/,$d' < Makefile.ssl > Makefile.tmp
19 echo '# DO NOT DELETE THIS LINE -- make depend depends on it.' >> Makefile.tmp 24 echo '# DO NOT DELETE THIS LINE -- make depend depends on it.' >> Makefile.tmp
20 gcc -D OPENSSL_DOING_MAKEDEPEND -M $@ >> Makefile.tmp 25 gcc -D OPENSSL_DOING_MAKEDEPEND -M $args >> Makefile.tmp
21 ${PERL} $TOP/util/clean-depend.pl < Makefile.tmp > Makefile.new 26 ${PERL} $TOP/util/clean-depend.pl < Makefile.tmp > Makefile.new
22 rm -f Makefile.tmp 27 rm -f Makefile.tmp
23else 28else
diff --git a/src/lib/libcrypto/util/libeay.num b/src/lib/libcrypto/util/libeay.num
index 7e5728495f..f5c8c0be8a 100644
--- a/src/lib/libcrypto/util/libeay.num
+++ b/src/lib/libcrypto/util/libeay.num
@@ -980,7 +980,7 @@ BN_mul_word 999 EXIST::FUNCTION:
980BN_sub_word 1000 EXIST::FUNCTION: 980BN_sub_word 1000 EXIST::FUNCTION:
981BN_dec2bn 1001 EXIST::FUNCTION: 981BN_dec2bn 1001 EXIST::FUNCTION:
982BN_bn2dec 1002 EXIST::FUNCTION: 982BN_bn2dec 1002 EXIST::FUNCTION:
983BIO_ghbn_ctrl 1003 EXIST::FUNCTION: 983BIO_ghbn_ctrl 1003 NOEXIST::FUNCTION:
984CRYPTO_free_ex_data 1004 EXIST::FUNCTION: 984CRYPTO_free_ex_data 1004 EXIST::FUNCTION:
985CRYPTO_get_ex_data 1005 EXIST::FUNCTION: 985CRYPTO_get_ex_data 1005 EXIST::FUNCTION:
986CRYPTO_set_ex_data 1007 EXIST::FUNCTION: 986CRYPTO_set_ex_data 1007 EXIST::FUNCTION:
@@ -1881,72 +1881,72 @@ BIO_f_linebuffer 2463 EXIST:VMS:FUNCTION:
1881BN_bntest_rand 2464 EXIST::FUNCTION: 1881BN_bntest_rand 2464 EXIST::FUNCTION:
1882OPENSSL_issetugid 2465 EXIST::FUNCTION: 1882OPENSSL_issetugid 2465 EXIST::FUNCTION:
1883BN_rand_range 2466 EXIST::FUNCTION: 1883BN_rand_range 2466 EXIST::FUNCTION:
1884ERR_load_ENGINE_strings 2467 EXIST::FUNCTION: 1884ERR_load_ENGINE_strings 2467 EXIST::FUNCTION:ENGINE
1885ENGINE_set_DSA 2468 EXIST::FUNCTION: 1885ENGINE_set_DSA 2468 EXIST::FUNCTION:ENGINE
1886ENGINE_get_finish_function 2469 EXIST::FUNCTION: 1886ENGINE_get_finish_function 2469 EXIST::FUNCTION:ENGINE
1887ENGINE_get_default_RSA 2470 EXIST::FUNCTION: 1887ENGINE_get_default_RSA 2470 EXIST::FUNCTION:ENGINE
1888ENGINE_get_BN_mod_exp 2471 NOEXIST::FUNCTION: 1888ENGINE_get_BN_mod_exp 2471 NOEXIST::FUNCTION:
1889DSA_get_default_openssl_method 2472 NOEXIST::FUNCTION: 1889DSA_get_default_openssl_method 2472 NOEXIST::FUNCTION:
1890ENGINE_set_DH 2473 EXIST::FUNCTION: 1890ENGINE_set_DH 2473 EXIST::FUNCTION:ENGINE
1891ENGINE_set_def_BN_mod_exp_crt 2474 NOEXIST::FUNCTION: 1891ENGINE_set_def_BN_mod_exp_crt 2474 NOEXIST::FUNCTION:
1892ENGINE_set_default_BN_mod_exp_crt 2474 NOEXIST::FUNCTION: 1892ENGINE_set_default_BN_mod_exp_crt 2474 NOEXIST::FUNCTION:
1893ENGINE_init 2475 EXIST::FUNCTION: 1893ENGINE_init 2475 EXIST::FUNCTION:ENGINE
1894DH_get_default_openssl_method 2476 NOEXIST::FUNCTION: 1894DH_get_default_openssl_method 2476 NOEXIST::FUNCTION:
1895RSA_set_default_openssl_method 2477 NOEXIST::FUNCTION: 1895RSA_set_default_openssl_method 2477 NOEXIST::FUNCTION:
1896ENGINE_finish 2478 EXIST::FUNCTION: 1896ENGINE_finish 2478 EXIST::FUNCTION:ENGINE
1897ENGINE_load_public_key 2479 EXIST::FUNCTION: 1897ENGINE_load_public_key 2479 EXIST::FUNCTION:ENGINE
1898ENGINE_get_DH 2480 EXIST::FUNCTION: 1898ENGINE_get_DH 2480 EXIST::FUNCTION:ENGINE
1899ENGINE_ctrl 2481 EXIST::FUNCTION: 1899ENGINE_ctrl 2481 EXIST::FUNCTION:ENGINE
1900ENGINE_get_init_function 2482 EXIST::FUNCTION: 1900ENGINE_get_init_function 2482 EXIST::FUNCTION:ENGINE
1901ENGINE_set_init_function 2483 EXIST::FUNCTION: 1901ENGINE_set_init_function 2483 EXIST::FUNCTION:ENGINE
1902ENGINE_set_default_DSA 2484 EXIST::FUNCTION: 1902ENGINE_set_default_DSA 2484 EXIST::FUNCTION:ENGINE
1903ENGINE_get_name 2485 EXIST::FUNCTION: 1903ENGINE_get_name 2485 EXIST::FUNCTION:ENGINE
1904ENGINE_get_last 2486 EXIST::FUNCTION: 1904ENGINE_get_last 2486 EXIST::FUNCTION:ENGINE
1905ENGINE_get_prev 2487 EXIST::FUNCTION: 1905ENGINE_get_prev 2487 EXIST::FUNCTION:ENGINE
1906ENGINE_get_default_DH 2488 EXIST::FUNCTION: 1906ENGINE_get_default_DH 2488 EXIST::FUNCTION:ENGINE
1907ENGINE_get_RSA 2489 EXIST::FUNCTION: 1907ENGINE_get_RSA 2489 EXIST::FUNCTION:ENGINE
1908ENGINE_set_default 2490 EXIST::FUNCTION: 1908ENGINE_set_default 2490 EXIST::FUNCTION:ENGINE
1909ENGINE_get_RAND 2491 EXIST::FUNCTION: 1909ENGINE_get_RAND 2491 EXIST::FUNCTION:ENGINE
1910ENGINE_get_first 2492 EXIST::FUNCTION: 1910ENGINE_get_first 2492 EXIST::FUNCTION:ENGINE
1911ENGINE_by_id 2493 EXIST::FUNCTION: 1911ENGINE_by_id 2493 EXIST::FUNCTION:ENGINE
1912ENGINE_set_finish_function 2494 EXIST::FUNCTION: 1912ENGINE_set_finish_function 2494 EXIST::FUNCTION:ENGINE
1913ENGINE_get_def_BN_mod_exp_crt 2495 NOEXIST::FUNCTION: 1913ENGINE_get_def_BN_mod_exp_crt 2495 NOEXIST::FUNCTION:
1914ENGINE_get_default_BN_mod_exp_crt 2495 NOEXIST::FUNCTION: 1914ENGINE_get_default_BN_mod_exp_crt 2495 NOEXIST::FUNCTION:
1915RSA_get_default_openssl_method 2496 NOEXIST::FUNCTION: 1915RSA_get_default_openssl_method 2496 NOEXIST::FUNCTION:
1916ENGINE_set_RSA 2497 EXIST::FUNCTION: 1916ENGINE_set_RSA 2497 EXIST::FUNCTION:ENGINE
1917ENGINE_load_private_key 2498 EXIST::FUNCTION: 1917ENGINE_load_private_key 2498 EXIST::FUNCTION:ENGINE
1918ENGINE_set_default_RAND 2499 EXIST::FUNCTION: 1918ENGINE_set_default_RAND 2499 EXIST::FUNCTION:ENGINE
1919ENGINE_set_BN_mod_exp 2500 NOEXIST::FUNCTION: 1919ENGINE_set_BN_mod_exp 2500 NOEXIST::FUNCTION:
1920ENGINE_remove 2501 EXIST::FUNCTION: 1920ENGINE_remove 2501 EXIST::FUNCTION:ENGINE
1921ENGINE_free 2502 EXIST::FUNCTION: 1921ENGINE_free 2502 EXIST::FUNCTION:ENGINE
1922ENGINE_get_BN_mod_exp_crt 2503 NOEXIST::FUNCTION: 1922ENGINE_get_BN_mod_exp_crt 2503 NOEXIST::FUNCTION:
1923ENGINE_get_next 2504 EXIST::FUNCTION: 1923ENGINE_get_next 2504 EXIST::FUNCTION:ENGINE
1924ENGINE_set_name 2505 EXIST::FUNCTION: 1924ENGINE_set_name 2505 EXIST::FUNCTION:ENGINE
1925ENGINE_get_default_DSA 2506 EXIST::FUNCTION: 1925ENGINE_get_default_DSA 2506 EXIST::FUNCTION:ENGINE
1926ENGINE_set_default_BN_mod_exp 2507 NOEXIST::FUNCTION: 1926ENGINE_set_default_BN_mod_exp 2507 NOEXIST::FUNCTION:
1927ENGINE_set_default_RSA 2508 EXIST::FUNCTION: 1927ENGINE_set_default_RSA 2508 EXIST::FUNCTION:ENGINE
1928ENGINE_get_default_RAND 2509 EXIST::FUNCTION: 1928ENGINE_get_default_RAND 2509 EXIST::FUNCTION:ENGINE
1929ENGINE_get_default_BN_mod_exp 2510 NOEXIST::FUNCTION: 1929ENGINE_get_default_BN_mod_exp 2510 NOEXIST::FUNCTION:
1930ENGINE_set_RAND 2511 EXIST::FUNCTION: 1930ENGINE_set_RAND 2511 EXIST::FUNCTION:ENGINE
1931ENGINE_set_id 2512 EXIST::FUNCTION: 1931ENGINE_set_id 2512 EXIST::FUNCTION:ENGINE
1932ENGINE_set_BN_mod_exp_crt 2513 NOEXIST::FUNCTION: 1932ENGINE_set_BN_mod_exp_crt 2513 NOEXIST::FUNCTION:
1933ENGINE_set_default_DH 2514 EXIST::FUNCTION: 1933ENGINE_set_default_DH 2514 EXIST::FUNCTION:ENGINE
1934ENGINE_new 2515 EXIST::FUNCTION: 1934ENGINE_new 2515 EXIST::FUNCTION:ENGINE
1935ENGINE_get_id 2516 EXIST::FUNCTION: 1935ENGINE_get_id 2516 EXIST::FUNCTION:ENGINE
1936DSA_set_default_openssl_method 2517 NOEXIST::FUNCTION: 1936DSA_set_default_openssl_method 2517 NOEXIST::FUNCTION:
1937ENGINE_add 2518 EXIST::FUNCTION: 1937ENGINE_add 2518 EXIST::FUNCTION:ENGINE
1938DH_set_default_openssl_method 2519 NOEXIST::FUNCTION: 1938DH_set_default_openssl_method 2519 NOEXIST::FUNCTION:
1939ENGINE_get_DSA 2520 EXIST::FUNCTION: 1939ENGINE_get_DSA 2520 EXIST::FUNCTION:ENGINE
1940ENGINE_get_ctrl_function 2521 EXIST::FUNCTION: 1940ENGINE_get_ctrl_function 2521 EXIST::FUNCTION:ENGINE
1941ENGINE_set_ctrl_function 2522 EXIST::FUNCTION: 1941ENGINE_set_ctrl_function 2522 EXIST::FUNCTION:ENGINE
1942BN_pseudo_rand_range 2523 EXIST::FUNCTION: 1942BN_pseudo_rand_range 2523 EXIST::FUNCTION:
1943X509_STORE_CTX_set_verify_cb 2524 EXIST::FUNCTION: 1943X509_STORE_CTX_set_verify_cb 2524 EXIST::FUNCTION:
1944ERR_load_COMP_strings 2525 EXIST::FUNCTION: 1944ERR_load_COMP_strings 2525 EXIST::FUNCTION:
1945PKCS12_item_decrypt_d2i 2526 EXIST::FUNCTION: 1945PKCS12_item_decrypt_d2i 2526 EXIST::FUNCTION:
1946ASN1_UTF8STRING_it 2527 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE: 1946ASN1_UTF8STRING_it 2527 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:
1947ASN1_UTF8STRING_it 2527 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION: 1947ASN1_UTF8STRING_it 2527 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:
1948ENGINE_unregister_ciphers 2528 EXIST::FUNCTION: 1948ENGINE_unregister_ciphers 2528 EXIST::FUNCTION:ENGINE
1949ENGINE_get_ciphers 2529 EXIST::FUNCTION: 1949ENGINE_get_ciphers 2529 EXIST::FUNCTION:ENGINE
1950d2i_OCSP_BASICRESP 2530 EXIST::FUNCTION: 1950d2i_OCSP_BASICRESP 2530 EXIST::FUNCTION:
1951KRB5_CHECKSUM_it 2531 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE: 1951KRB5_CHECKSUM_it 2531 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:
1952KRB5_CHECKSUM_it 2531 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION: 1952KRB5_CHECKSUM_it 2531 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:
@@ -1959,15 +1959,15 @@ X509V3_add1_i2d 2536 EXIST::FUNCTION:
1959PKCS7_ENVELOPE_it 2537 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE: 1959PKCS7_ENVELOPE_it 2537 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:
1960PKCS7_ENVELOPE_it 2537 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION: 1960PKCS7_ENVELOPE_it 2537 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:
1961UI_add_input_boolean 2538 EXIST::FUNCTION: 1961UI_add_input_boolean 2538 EXIST::FUNCTION:
1962ENGINE_unregister_RSA 2539 EXIST::FUNCTION: 1962ENGINE_unregister_RSA 2539 EXIST::FUNCTION:ENGINE
1963X509V3_EXT_nconf 2540 EXIST::FUNCTION: 1963X509V3_EXT_nconf 2540 EXIST::FUNCTION:
1964ASN1_GENERALSTRING_free 2541 EXIST::FUNCTION: 1964ASN1_GENERALSTRING_free 2541 EXIST::FUNCTION:
1965d2i_OCSP_CERTSTATUS 2542 EXIST::FUNCTION: 1965d2i_OCSP_CERTSTATUS 2542 EXIST::FUNCTION:
1966X509_REVOKED_set_serialNumber 2543 EXIST::FUNCTION: 1966X509_REVOKED_set_serialNumber 2543 EXIST::FUNCTION:
1967X509_print_ex 2544 EXIST::FUNCTION:BIO 1967X509_print_ex 2544 EXIST::FUNCTION:BIO
1968OCSP_ONEREQ_get1_ext_d2i 2545 EXIST::FUNCTION: 1968OCSP_ONEREQ_get1_ext_d2i 2545 EXIST::FUNCTION:
1969ENGINE_register_all_RAND 2546 EXIST::FUNCTION: 1969ENGINE_register_all_RAND 2546 EXIST::FUNCTION:ENGINE
1970ENGINE_load_dynamic 2547 EXIST::FUNCTION: 1970ENGINE_load_dynamic 2547 EXIST::FUNCTION:ENGINE
1971PBKDF2PARAM_it 2548 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE: 1971PBKDF2PARAM_it 2548 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:
1972PBKDF2PARAM_it 2548 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION: 1972PBKDF2PARAM_it 2548 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:
1973EXTENDED_KEY_USAGE_new 2549 EXIST::FUNCTION: 1973EXTENDED_KEY_USAGE_new 2549 EXIST::FUNCTION:
@@ -1987,7 +1987,7 @@ X509_STORE_set_purpose 2559 EXIST::FUNCTION:
1987i2d_ASN1_GENERALSTRING 2560 EXIST::FUNCTION: 1987i2d_ASN1_GENERALSTRING 2560 EXIST::FUNCTION:
1988OCSP_response_status 2561 EXIST::FUNCTION: 1988OCSP_response_status 2561 EXIST::FUNCTION:
1989i2d_OCSP_SERVICELOC 2562 EXIST::FUNCTION: 1989i2d_OCSP_SERVICELOC 2562 EXIST::FUNCTION:
1990ENGINE_get_digest_engine 2563 EXIST::FUNCTION: 1990ENGINE_get_digest_engine 2563 EXIST::FUNCTION:ENGINE
1991EC_GROUP_set_curve_GFp 2564 EXIST::FUNCTION:EC 1991EC_GROUP_set_curve_GFp 2564 EXIST::FUNCTION:EC
1992OCSP_REQUEST_get_ext_by_OBJ 2565 EXIST::FUNCTION: 1992OCSP_REQUEST_get_ext_by_OBJ 2565 EXIST::FUNCTION:
1993_ossl_old_des_random_key 2566 EXIST::FUNCTION:DES 1993_ossl_old_des_random_key 2566 EXIST::FUNCTION:DES
@@ -2011,7 +2011,7 @@ _shadow_DES_rw_mode 2581 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIA
2011_shadow_DES_rw_mode 2581 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:DES 2011_shadow_DES_rw_mode 2581 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:DES
2012asn1_do_adb 2582 EXIST::FUNCTION: 2012asn1_do_adb 2582 EXIST::FUNCTION:
2013ASN1_template_i2d 2583 EXIST::FUNCTION: 2013ASN1_template_i2d 2583 EXIST::FUNCTION:
2014ENGINE_register_DH 2584 EXIST::FUNCTION: 2014ENGINE_register_DH 2584 EXIST::FUNCTION:ENGINE
2015UI_construct_prompt 2585 EXIST::FUNCTION: 2015UI_construct_prompt 2585 EXIST::FUNCTION:
2016X509_STORE_set_trust 2586 EXIST::FUNCTION: 2016X509_STORE_set_trust 2586 EXIST::FUNCTION:
2017UI_dup_input_string 2587 EXIST::FUNCTION: 2017UI_dup_input_string 2587 EXIST::FUNCTION:
@@ -2039,7 +2039,7 @@ OCSP_resp_find 2605 EXIST::FUNCTION:
2039BN_nnmod 2606 EXIST::FUNCTION: 2039BN_nnmod 2606 EXIST::FUNCTION:
2040X509_CRL_sort 2607 EXIST::FUNCTION: 2040X509_CRL_sort 2607 EXIST::FUNCTION:
2041X509_REVOKED_set_revocationDate 2608 EXIST::FUNCTION: 2041X509_REVOKED_set_revocationDate 2608 EXIST::FUNCTION:
2042ENGINE_register_RAND 2609 EXIST::FUNCTION: 2042ENGINE_register_RAND 2609 EXIST::FUNCTION:ENGINE
2043OCSP_SERVICELOC_new 2610 EXIST::FUNCTION: 2043OCSP_SERVICELOC_new 2610 EXIST::FUNCTION:
2044EC_POINT_set_affine_coordinates_GFp 2611 EXIST:!VMS:FUNCTION:EC 2044EC_POINT_set_affine_coordinates_GFp 2611 EXIST:!VMS:FUNCTION:EC
2045EC_POINT_set_affine_coords_GFp 2611 EXIST:VMS:FUNCTION:EC 2045EC_POINT_set_affine_coords_GFp 2611 EXIST:VMS:FUNCTION:EC
@@ -2049,11 +2049,11 @@ SXNET_it 2613 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTI
2049UI_dup_input_boolean 2614 EXIST::FUNCTION: 2049UI_dup_input_boolean 2614 EXIST::FUNCTION:
2050PKCS12_add_CSPName_asc 2615 EXIST::FUNCTION: 2050PKCS12_add_CSPName_asc 2615 EXIST::FUNCTION:
2051EC_POINT_is_at_infinity 2616 EXIST::FUNCTION:EC 2051EC_POINT_is_at_infinity 2616 EXIST::FUNCTION:EC
2052ENGINE_load_openbsd_dev_crypto 2617 EXIST::FUNCTION: 2052ENGINE_load_cryptodev 2617 EXIST::FUNCTION:ENGINE
2053DSO_convert_filename 2618 EXIST::FUNCTION: 2053DSO_convert_filename 2618 EXIST::FUNCTION:
2054POLICYQUALINFO_it 2619 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE: 2054POLICYQUALINFO_it 2619 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:
2055POLICYQUALINFO_it 2619 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION: 2055POLICYQUALINFO_it 2619 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:
2056ENGINE_register_ciphers 2620 EXIST::FUNCTION: 2056ENGINE_register_ciphers 2620 EXIST::FUNCTION:ENGINE
2057BN_mod_lshift_quick 2621 EXIST::FUNCTION: 2057BN_mod_lshift_quick 2621 EXIST::FUNCTION:
2058DSO_set_filename 2622 EXIST::FUNCTION: 2058DSO_set_filename 2622 EXIST::FUNCTION:
2059ASN1_item_free 2623 EXIST::FUNCTION: 2059ASN1_item_free 2623 EXIST::FUNCTION:
@@ -2062,7 +2062,7 @@ AUTHORITY_KEYID_it 2625 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIA
2062AUTHORITY_KEYID_it 2625 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION: 2062AUTHORITY_KEYID_it 2625 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:
2063KRB5_APREQBODY_new 2626 EXIST::FUNCTION: 2063KRB5_APREQBODY_new 2626 EXIST::FUNCTION:
2064X509V3_EXT_REQ_add_nconf 2627 EXIST::FUNCTION: 2064X509V3_EXT_REQ_add_nconf 2627 EXIST::FUNCTION:
2065ENGINE_ctrl_cmd_string 2628 EXIST::FUNCTION: 2065ENGINE_ctrl_cmd_string 2628 EXIST::FUNCTION:ENGINE
2066i2d_OCSP_RESPDATA 2629 EXIST::FUNCTION: 2066i2d_OCSP_RESPDATA 2629 EXIST::FUNCTION:
2067EVP_MD_CTX_init 2630 EXIST::FUNCTION: 2067EVP_MD_CTX_init 2630 EXIST::FUNCTION:
2068EXTENDED_KEY_USAGE_free 2631 EXIST::FUNCTION: 2068EXTENDED_KEY_USAGE_free 2631 EXIST::FUNCTION:
@@ -2071,8 +2071,8 @@ PKCS7_ATTR_SIGN_it 2632 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTI
2071UI_add_error_string 2633 EXIST::FUNCTION: 2071UI_add_error_string 2633 EXIST::FUNCTION:
2072KRB5_CHECKSUM_free 2634 EXIST::FUNCTION: 2072KRB5_CHECKSUM_free 2634 EXIST::FUNCTION:
2073OCSP_REQUEST_get_ext 2635 EXIST::FUNCTION: 2073OCSP_REQUEST_get_ext 2635 EXIST::FUNCTION:
2074ENGINE_load_ubsec 2636 EXIST::FUNCTION: 2074ENGINE_load_ubsec 2636 EXIST::FUNCTION:ENGINE
2075ENGINE_register_all_digests 2637 EXIST::FUNCTION: 2075ENGINE_register_all_digests 2637 EXIST::FUNCTION:ENGINE
2076PKEY_USAGE_PERIOD_it 2638 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE: 2076PKEY_USAGE_PERIOD_it 2638 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:
2077PKEY_USAGE_PERIOD_it 2638 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION: 2077PKEY_USAGE_PERIOD_it 2638 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:
2078PKCS12_unpack_authsafes 2639 EXIST::FUNCTION: 2078PKCS12_unpack_authsafes 2639 EXIST::FUNCTION:
@@ -2098,16 +2098,16 @@ OCSP_CERTSTATUS_free 2653 EXIST::FUNCTION:
2098_ossl_old_des_crypt 2654 EXIST::FUNCTION:DES 2098_ossl_old_des_crypt 2654 EXIST::FUNCTION:DES
2099ASN1_item_i2d 2655 EXIST::FUNCTION: 2099ASN1_item_i2d 2655 EXIST::FUNCTION:
2100EVP_DecryptFinal_ex 2656 EXIST::FUNCTION: 2100EVP_DecryptFinal_ex 2656 EXIST::FUNCTION:
2101ENGINE_load_openssl 2657 EXIST::FUNCTION: 2101ENGINE_load_openssl 2657 EXIST::FUNCTION:ENGINE
2102ENGINE_get_cmd_defns 2658 EXIST::FUNCTION: 2102ENGINE_get_cmd_defns 2658 EXIST::FUNCTION:ENGINE
2103ENGINE_set_load_privkey_function 2659 EXIST:!VMS:FUNCTION: 2103ENGINE_set_load_privkey_function 2659 EXIST:!VMS:FUNCTION:ENGINE
2104ENGINE_set_load_privkey_fn 2659 EXIST:VMS:FUNCTION: 2104ENGINE_set_load_privkey_fn 2659 EXIST:VMS:FUNCTION:ENGINE
2105EVP_EncryptFinal_ex 2660 EXIST::FUNCTION: 2105EVP_EncryptFinal_ex 2660 EXIST::FUNCTION:
2106ENGINE_set_default_digests 2661 EXIST::FUNCTION: 2106ENGINE_set_default_digests 2661 EXIST::FUNCTION:ENGINE
2107X509_get0_pubkey_bitstr 2662 EXIST::FUNCTION: 2107X509_get0_pubkey_bitstr 2662 EXIST::FUNCTION:
2108asn1_ex_i2c 2663 EXIST::FUNCTION: 2108asn1_ex_i2c 2663 EXIST::FUNCTION:
2109ENGINE_register_RSA 2664 EXIST::FUNCTION: 2109ENGINE_register_RSA 2664 EXIST::FUNCTION:ENGINE
2110ENGINE_unregister_DSA 2665 EXIST::FUNCTION: 2110ENGINE_unregister_DSA 2665 EXIST::FUNCTION:ENGINE
2111_ossl_old_des_key_sched 2666 EXIST::FUNCTION:DES 2111_ossl_old_des_key_sched 2666 EXIST::FUNCTION:DES
2112X509_EXTENSION_it 2667 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE: 2112X509_EXTENSION_it 2667 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:
2113X509_EXTENSION_it 2667 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION: 2113X509_EXTENSION_it 2667 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:
@@ -2120,7 +2120,7 @@ PKCS12_certbag2x509 2672 EXIST::FUNCTION:
2120_ossl_old_des_ofb64_encrypt 2673 EXIST::FUNCTION:DES 2120_ossl_old_des_ofb64_encrypt 2673 EXIST::FUNCTION:DES
2121d2i_EXTENDED_KEY_USAGE 2674 EXIST::FUNCTION: 2121d2i_EXTENDED_KEY_USAGE 2674 EXIST::FUNCTION:
2122ERR_print_errors_cb 2675 EXIST::FUNCTION: 2122ERR_print_errors_cb 2675 EXIST::FUNCTION:
2123ENGINE_set_ciphers 2676 EXIST::FUNCTION: 2123ENGINE_set_ciphers 2676 EXIST::FUNCTION:ENGINE
2124d2i_KRB5_APREQBODY 2677 EXIST::FUNCTION: 2124d2i_KRB5_APREQBODY 2677 EXIST::FUNCTION:
2125UI_method_get_flusher 2678 EXIST::FUNCTION: 2125UI_method_get_flusher 2678 EXIST::FUNCTION:
2126X509_PUBKEY_it 2679 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE: 2126X509_PUBKEY_it 2679 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:
@@ -2156,7 +2156,7 @@ NCONF_get_number_e 2704 EXIST::FUNCTION:
2156_ossl_old_des_decrypt3 2705 EXIST::FUNCTION:DES 2156_ossl_old_des_decrypt3 2705 EXIST::FUNCTION:DES
2157X509_signature_print 2706 EXIST::FUNCTION:EVP 2157X509_signature_print 2706 EXIST::FUNCTION:EVP
2158OCSP_SINGLERESP_free 2707 EXIST::FUNCTION: 2158OCSP_SINGLERESP_free 2707 EXIST::FUNCTION:
2159ENGINE_load_builtin_engines 2708 EXIST::FUNCTION: 2159ENGINE_load_builtin_engines 2708 EXIST::FUNCTION:ENGINE
2160i2d_OCSP_ONEREQ 2709 EXIST::FUNCTION: 2160i2d_OCSP_ONEREQ 2709 EXIST::FUNCTION:
2161OCSP_REQUEST_add_ext 2710 EXIST::FUNCTION: 2161OCSP_REQUEST_add_ext 2710 EXIST::FUNCTION:
2162OCSP_RESPBYTES_new 2711 EXIST::FUNCTION: 2162OCSP_RESPBYTES_new 2711 EXIST::FUNCTION:
@@ -2184,7 +2184,7 @@ X509_CERT_AUX_it 2727 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTI
2184CERTIFICATEPOLICIES_it 2728 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE: 2184CERTIFICATEPOLICIES_it 2728 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:
2185CERTIFICATEPOLICIES_it 2728 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION: 2185CERTIFICATEPOLICIES_it 2728 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:
2186_ossl_old_des_ede3_cbc_encrypt 2729 EXIST::FUNCTION:DES 2186_ossl_old_des_ede3_cbc_encrypt 2729 EXIST::FUNCTION:DES
2187RAND_set_rand_engine 2730 EXIST::FUNCTION: 2187RAND_set_rand_engine 2730 EXIST::FUNCTION:ENGINE
2188DSO_get_loaded_filename 2731 EXIST::FUNCTION: 2188DSO_get_loaded_filename 2731 EXIST::FUNCTION:
2189X509_ATTRIBUTE_it 2732 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE: 2189X509_ATTRIBUTE_it 2732 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:
2190X509_ATTRIBUTE_it 2732 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION: 2190X509_ATTRIBUTE_it 2732 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:
@@ -2206,7 +2206,7 @@ i2d_OCSP_BASICRESP 2744 EXIST::FUNCTION:
2206i2d_OCSP_RESPBYTES 2745 EXIST::FUNCTION: 2206i2d_OCSP_RESPBYTES 2745 EXIST::FUNCTION:
2207PKCS12_unpack_p7encdata 2746 EXIST::FUNCTION: 2207PKCS12_unpack_p7encdata 2746 EXIST::FUNCTION:
2208HMAC_CTX_init 2747 EXIST::FUNCTION:HMAC 2208HMAC_CTX_init 2747 EXIST::FUNCTION:HMAC
2209ENGINE_get_digest 2748 EXIST::FUNCTION: 2209ENGINE_get_digest 2748 EXIST::FUNCTION:ENGINE
2210OCSP_RESPONSE_print 2749 EXIST::FUNCTION: 2210OCSP_RESPONSE_print 2749 EXIST::FUNCTION:
2211KRB5_TKTBODY_it 2750 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE: 2211KRB5_TKTBODY_it 2750 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:
2212KRB5_TKTBODY_it 2750 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION: 2212KRB5_TKTBODY_it 2750 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:
@@ -2219,16 +2219,16 @@ PBE2PARAM_it 2753 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTI
2219PKCS12_certbag2x509crl 2754 EXIST::FUNCTION: 2219PKCS12_certbag2x509crl 2754 EXIST::FUNCTION:
2220PKCS7_SIGNED_it 2755 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE: 2220PKCS7_SIGNED_it 2755 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:
2221PKCS7_SIGNED_it 2755 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION: 2221PKCS7_SIGNED_it 2755 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:
2222ENGINE_get_cipher 2756 EXIST::FUNCTION: 2222ENGINE_get_cipher 2756 EXIST::FUNCTION:ENGINE
2223i2d_OCSP_CRLID 2757 EXIST::FUNCTION: 2223i2d_OCSP_CRLID 2757 EXIST::FUNCTION:
2224OCSP_SINGLERESP_new 2758 EXIST::FUNCTION: 2224OCSP_SINGLERESP_new 2758 EXIST::FUNCTION:
2225ENGINE_cmd_is_executable 2759 EXIST::FUNCTION: 2225ENGINE_cmd_is_executable 2759 EXIST::FUNCTION:ENGINE
2226RSA_up_ref 2760 EXIST::FUNCTION:RSA 2226RSA_up_ref 2760 EXIST::FUNCTION:RSA
2227ASN1_GENERALSTRING_it 2761 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE: 2227ASN1_GENERALSTRING_it 2761 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:
2228ASN1_GENERALSTRING_it 2761 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION: 2228ASN1_GENERALSTRING_it 2761 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:
2229ENGINE_register_DSA 2762 EXIST::FUNCTION: 2229ENGINE_register_DSA 2762 EXIST::FUNCTION:ENGINE
2230X509V3_EXT_add_nconf_sk 2763 EXIST::FUNCTION: 2230X509V3_EXT_add_nconf_sk 2763 EXIST::FUNCTION:
2231ENGINE_set_load_pubkey_function 2764 EXIST::FUNCTION: 2231ENGINE_set_load_pubkey_function 2764 EXIST::FUNCTION:ENGINE
2232PKCS8_decrypt 2765 EXIST::FUNCTION: 2232PKCS8_decrypt 2765 EXIST::FUNCTION:
2233PEM_bytes_read_bio 2766 EXIST::FUNCTION:BIO 2233PEM_bytes_read_bio 2766 EXIST::FUNCTION:BIO
2234DIRECTORYSTRING_it 2767 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE: 2234DIRECTORYSTRING_it 2767 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:
@@ -2265,7 +2265,7 @@ UI_method_set_flusher 2789 EXIST::FUNCTION:
2265X509_ocspid_print 2790 EXIST::FUNCTION:BIO 2265X509_ocspid_print 2790 EXIST::FUNCTION:BIO
2266KRB5_ENCDATA_it 2791 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE: 2266KRB5_ENCDATA_it 2791 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:
2267KRB5_ENCDATA_it 2791 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION: 2267KRB5_ENCDATA_it 2791 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:
2268ENGINE_get_load_pubkey_function 2792 EXIST::FUNCTION: 2268ENGINE_get_load_pubkey_function 2792 EXIST::FUNCTION:ENGINE
2269UI_add_user_data 2793 EXIST::FUNCTION: 2269UI_add_user_data 2793 EXIST::FUNCTION:
2270OCSP_REQUEST_delete_ext 2794 EXIST::FUNCTION: 2270OCSP_REQUEST_delete_ext 2794 EXIST::FUNCTION:
2271UI_get_method 2795 EXIST::FUNCTION: 2271UI_get_method 2795 EXIST::FUNCTION:
@@ -2289,16 +2289,16 @@ ASN1_FBOOLEAN_it 2806 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIA
2289ASN1_FBOOLEAN_it 2806 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION: 2289ASN1_FBOOLEAN_it 2806 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:
2290UI_set_ex_data 2807 EXIST::FUNCTION: 2290UI_set_ex_data 2807 EXIST::FUNCTION:
2291_ossl_old_des_string_to_key 2808 EXIST::FUNCTION:DES 2291_ossl_old_des_string_to_key 2808 EXIST::FUNCTION:DES
2292ENGINE_register_all_RSA 2809 EXIST::FUNCTION: 2292ENGINE_register_all_RSA 2809 EXIST::FUNCTION:ENGINE
2293d2i_KRB5_PRINCNAME 2810 EXIST::FUNCTION: 2293d2i_KRB5_PRINCNAME 2810 EXIST::FUNCTION:
2294OCSP_RESPBYTES_it 2811 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE: 2294OCSP_RESPBYTES_it 2811 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:
2295OCSP_RESPBYTES_it 2811 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION: 2295OCSP_RESPBYTES_it 2811 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:
2296X509_CINF_it 2812 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE: 2296X509_CINF_it 2812 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:
2297X509_CINF_it 2812 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION: 2297X509_CINF_it 2812 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:
2298ENGINE_unregister_digests 2813 EXIST::FUNCTION: 2298ENGINE_unregister_digests 2813 EXIST::FUNCTION:ENGINE
2299d2i_EDIPARTYNAME 2814 EXIST::FUNCTION: 2299d2i_EDIPARTYNAME 2814 EXIST::FUNCTION:
2300d2i_OCSP_SERVICELOC 2815 EXIST::FUNCTION: 2300d2i_OCSP_SERVICELOC 2815 EXIST::FUNCTION:
2301ENGINE_get_digests 2816 EXIST::FUNCTION: 2301ENGINE_get_digests 2816 EXIST::FUNCTION:ENGINE
2302_ossl_old_des_set_odd_parity 2817 EXIST::FUNCTION:DES 2302_ossl_old_des_set_odd_parity 2817 EXIST::FUNCTION:DES
2303OCSP_RESPDATA_free 2818 EXIST::FUNCTION: 2303OCSP_RESPDATA_free 2818 EXIST::FUNCTION:
2304d2i_KRB5_TICKET 2819 EXIST::FUNCTION: 2304d2i_KRB5_TICKET 2819 EXIST::FUNCTION:
@@ -2309,7 +2309,7 @@ d2i_ASN1_GENERALSTRING 2822 EXIST::FUNCTION:
2309X509_CRL_set_version 2823 EXIST::FUNCTION: 2309X509_CRL_set_version 2823 EXIST::FUNCTION:
2310BN_mod_sub 2824 EXIST::FUNCTION: 2310BN_mod_sub 2824 EXIST::FUNCTION:
2311OCSP_SINGLERESP_get_ext_by_NID 2825 EXIST::FUNCTION: 2311OCSP_SINGLERESP_get_ext_by_NID 2825 EXIST::FUNCTION:
2312ENGINE_get_ex_new_index 2826 EXIST::FUNCTION: 2312ENGINE_get_ex_new_index 2826 EXIST::FUNCTION:ENGINE
2313OCSP_REQUEST_free 2827 EXIST::FUNCTION: 2313OCSP_REQUEST_free 2827 EXIST::FUNCTION:
2314OCSP_REQUEST_add1_ext_i2d 2828 EXIST::FUNCTION: 2314OCSP_REQUEST_add1_ext_i2d 2828 EXIST::FUNCTION:
2315X509_VAL_it 2829 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE: 2315X509_VAL_it 2829 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:
@@ -2343,7 +2343,7 @@ EC_POINT_method_of 2852 EXIST::FUNCTION:EC
2343i2d_KRB5_APREQBODY 2853 EXIST::FUNCTION: 2343i2d_KRB5_APREQBODY 2853 EXIST::FUNCTION:
2344_ossl_old_des_ecb3_encrypt 2854 EXIST::FUNCTION:DES 2344_ossl_old_des_ecb3_encrypt 2854 EXIST::FUNCTION:DES
2345CRYPTO_get_mem_ex_functions 2855 EXIST::FUNCTION: 2345CRYPTO_get_mem_ex_functions 2855 EXIST::FUNCTION:
2346ENGINE_get_ex_data 2856 EXIST::FUNCTION: 2346ENGINE_get_ex_data 2856 EXIST::FUNCTION:ENGINE
2347UI_destroy_method 2857 EXIST::FUNCTION: 2347UI_destroy_method 2857 EXIST::FUNCTION:
2348ASN1_item_i2d_bio 2858 EXIST::FUNCTION:BIO 2348ASN1_item_i2d_bio 2858 EXIST::FUNCTION:BIO
2349OCSP_ONEREQ_get_ext_by_OBJ 2859 EXIST::FUNCTION: 2349OCSP_ONEREQ_get_ext_by_OBJ 2859 EXIST::FUNCTION:
@@ -2367,7 +2367,7 @@ PKCS12_SAFEBAGS_it 2872 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIA
2367PKCS12_SAFEBAGS_it 2872 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION: 2367PKCS12_SAFEBAGS_it 2872 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:
2368d2i_OCSP_SIGNATURE 2873 EXIST::FUNCTION: 2368d2i_OCSP_SIGNATURE 2873 EXIST::FUNCTION:
2369OCSP_request_add1_nonce 2874 EXIST::FUNCTION: 2369OCSP_request_add1_nonce 2874 EXIST::FUNCTION:
2370ENGINE_set_cmd_defns 2875 EXIST::FUNCTION: 2370ENGINE_set_cmd_defns 2875 EXIST::FUNCTION:ENGINE
2371OCSP_SERVICELOC_free 2876 EXIST::FUNCTION: 2371OCSP_SERVICELOC_free 2876 EXIST::FUNCTION:
2372EC_GROUP_free 2877 EXIST::FUNCTION:EC 2372EC_GROUP_free 2877 EXIST::FUNCTION:EC
2373ASN1_BIT_STRING_it 2878 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE: 2373ASN1_BIT_STRING_it 2878 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:
@@ -2384,7 +2384,7 @@ EC_GROUP_new_curve_GFp 2885 EXIST::FUNCTION:EC
2384OCSP_REQUEST_get1_ext_d2i 2886 EXIST::FUNCTION: 2384OCSP_REQUEST_get1_ext_d2i 2886 EXIST::FUNCTION:
2385PKCS12_item_pack_safebag 2887 EXIST::FUNCTION: 2385PKCS12_item_pack_safebag 2887 EXIST::FUNCTION:
2386asn1_ex_c2i 2888 EXIST::FUNCTION: 2386asn1_ex_c2i 2888 EXIST::FUNCTION:
2387ENGINE_register_digests 2889 EXIST::FUNCTION: 2387ENGINE_register_digests 2889 EXIST::FUNCTION:ENGINE
2388i2d_OCSP_REVOKEDINFO 2890 EXIST::FUNCTION: 2388i2d_OCSP_REVOKEDINFO 2890 EXIST::FUNCTION:
2389asn1_enc_restore 2891 EXIST::FUNCTION: 2389asn1_enc_restore 2891 EXIST::FUNCTION:
2390UI_free 2892 EXIST::FUNCTION: 2390UI_free 2892 EXIST::FUNCTION:
@@ -2395,7 +2395,7 @@ EC_POINT_invert 2896 EXIST::FUNCTION:EC
2395OCSP_basic_sign 2897 EXIST::FUNCTION: 2395OCSP_basic_sign 2897 EXIST::FUNCTION:
2396i2d_OCSP_RESPID 2898 EXIST::FUNCTION: 2396i2d_OCSP_RESPID 2898 EXIST::FUNCTION:
2397OCSP_check_nonce 2899 EXIST::FUNCTION: 2397OCSP_check_nonce 2899 EXIST::FUNCTION:
2398ENGINE_ctrl_cmd 2900 EXIST::FUNCTION: 2398ENGINE_ctrl_cmd 2900 EXIST::FUNCTION:ENGINE
2399d2i_KRB5_ENCKEY 2901 EXIST::FUNCTION: 2399d2i_KRB5_ENCKEY 2901 EXIST::FUNCTION:
2400OCSP_parse_url 2902 EXIST::FUNCTION: 2400OCSP_parse_url 2902 EXIST::FUNCTION:
2401OCSP_SINGLERESP_get_ext 2903 EXIST::FUNCTION: 2401OCSP_SINGLERESP_get_ext 2903 EXIST::FUNCTION:
@@ -2403,12 +2403,12 @@ OCSP_CRLID_free 2904 EXIST::FUNCTION:
2403OCSP_BASICRESP_get1_ext_d2i 2905 EXIST::FUNCTION: 2403OCSP_BASICRESP_get1_ext_d2i 2905 EXIST::FUNCTION:
2404RSAPrivateKey_it 2906 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:RSA 2404RSAPrivateKey_it 2906 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:RSA
2405RSAPrivateKey_it 2906 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:RSA 2405RSAPrivateKey_it 2906 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:RSA
2406ENGINE_register_all_DH 2907 EXIST::FUNCTION: 2406ENGINE_register_all_DH 2907 EXIST::FUNCTION:ENGINE
2407i2d_EDIPARTYNAME 2908 EXIST::FUNCTION: 2407i2d_EDIPARTYNAME 2908 EXIST::FUNCTION:
2408EC_POINT_get_affine_coordinates_GFp 2909 EXIST:!VMS:FUNCTION:EC 2408EC_POINT_get_affine_coordinates_GFp 2909 EXIST:!VMS:FUNCTION:EC
2409EC_POINT_get_affine_coords_GFp 2909 EXIST:VMS:FUNCTION:EC 2409EC_POINT_get_affine_coords_GFp 2909 EXIST:VMS:FUNCTION:EC
2410OCSP_CRLID_new 2910 EXIST::FUNCTION: 2410OCSP_CRLID_new 2910 EXIST::FUNCTION:
2411ENGINE_get_flags 2911 EXIST::FUNCTION: 2411ENGINE_get_flags 2911 EXIST::FUNCTION:ENGINE
2412OCSP_ONEREQ_it 2912 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE: 2412OCSP_ONEREQ_it 2912 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:
2413OCSP_ONEREQ_it 2912 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION: 2413OCSP_ONEREQ_it 2912 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:
2414UI_process 2913 EXIST::FUNCTION: 2414UI_process 2913 EXIST::FUNCTION:
@@ -2416,8 +2416,8 @@ ASN1_INTEGER_it 2914 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIA
2416ASN1_INTEGER_it 2914 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION: 2416ASN1_INTEGER_it 2914 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:
2417EVP_CipherInit_ex 2915 EXIST::FUNCTION: 2417EVP_CipherInit_ex 2915 EXIST::FUNCTION:
2418UI_get_string_type 2916 EXIST::FUNCTION: 2418UI_get_string_type 2916 EXIST::FUNCTION:
2419ENGINE_unregister_DH 2917 EXIST::FUNCTION: 2419ENGINE_unregister_DH 2917 EXIST::FUNCTION:ENGINE
2420ENGINE_register_all_DSA 2918 EXIST::FUNCTION: 2420ENGINE_register_all_DSA 2918 EXIST::FUNCTION:ENGINE
2421OCSP_ONEREQ_get_ext_by_critical 2919 EXIST::FUNCTION: 2421OCSP_ONEREQ_get_ext_by_critical 2919 EXIST::FUNCTION:
2422bn_dup_expand 2920 EXIST::FUNCTION: 2422bn_dup_expand 2920 EXIST::FUNCTION:
2423OCSP_cert_id_new 2921 EXIST::FUNCTION: 2423OCSP_cert_id_new 2921 EXIST::FUNCTION:
@@ -2438,11 +2438,11 @@ BN_mod_sub_quick 2933 EXIST::FUNCTION:
2438OCSP_ONEREQ_add_ext 2934 EXIST::FUNCTION: 2438OCSP_ONEREQ_add_ext 2934 EXIST::FUNCTION:
2439OCSP_request_sign 2935 EXIST::FUNCTION: 2439OCSP_request_sign 2935 EXIST::FUNCTION:
2440EVP_DigestFinal_ex 2936 EXIST::FUNCTION: 2440EVP_DigestFinal_ex 2936 EXIST::FUNCTION:
2441ENGINE_set_digests 2937 EXIST::FUNCTION: 2441ENGINE_set_digests 2937 EXIST::FUNCTION:ENGINE
2442OCSP_id_issuer_cmp 2938 EXIST::FUNCTION: 2442OCSP_id_issuer_cmp 2938 EXIST::FUNCTION:
2443OBJ_NAME_do_all 2939 EXIST::FUNCTION: 2443OBJ_NAME_do_all 2939 EXIST::FUNCTION:
2444EC_POINTs_mul 2940 EXIST::FUNCTION:EC 2444EC_POINTs_mul 2940 EXIST::FUNCTION:EC
2445ENGINE_register_complete 2941 EXIST::FUNCTION: 2445ENGINE_register_complete 2941 EXIST::FUNCTION:ENGINE
2446X509V3_EXT_nconf_nid 2942 EXIST::FUNCTION: 2446X509V3_EXT_nconf_nid 2942 EXIST::FUNCTION:
2447ASN1_SEQUENCE_it 2943 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE: 2447ASN1_SEQUENCE_it 2943 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:
2448ASN1_SEQUENCE_it 2943 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION: 2448ASN1_SEQUENCE_it 2943 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:
@@ -2451,7 +2451,7 @@ RAND_query_egd_bytes 2945 EXIST::FUNCTION:
2451UI_method_get_writer 2946 EXIST::FUNCTION: 2451UI_method_get_writer 2946 EXIST::FUNCTION:
2452UI_OpenSSL 2947 EXIST::FUNCTION: 2452UI_OpenSSL 2947 EXIST::FUNCTION:
2453PEM_def_callback 2948 EXIST::FUNCTION: 2453PEM_def_callback 2948 EXIST::FUNCTION:
2454ENGINE_cleanup 2949 EXIST::FUNCTION: 2454ENGINE_cleanup 2949 EXIST::FUNCTION:ENGINE
2455DIST_POINT_it 2950 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE: 2455DIST_POINT_it 2950 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:
2456DIST_POINT_it 2950 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION: 2456DIST_POINT_it 2950 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:
2457OCSP_SINGLERESP_it 2951 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE: 2457OCSP_SINGLERESP_it 2951 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:
@@ -2475,7 +2475,7 @@ OCSP_RESPID_new 2967 EXIST::FUNCTION:
2475OCSP_RESPDATA_it 2968 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE: 2475OCSP_RESPDATA_it 2968 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:
2476OCSP_RESPDATA_it 2968 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION: 2476OCSP_RESPDATA_it 2968 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:
2477d2i_OCSP_RESPDATA 2969 EXIST::FUNCTION: 2477d2i_OCSP_RESPDATA 2969 EXIST::FUNCTION:
2478ENGINE_register_all_complete 2970 EXIST::FUNCTION: 2478ENGINE_register_all_complete 2970 EXIST::FUNCTION:ENGINE
2479OCSP_check_validity 2971 EXIST::FUNCTION: 2479OCSP_check_validity 2971 EXIST::FUNCTION:
2480PKCS12_BAGS_it 2972 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE: 2480PKCS12_BAGS_it 2972 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:
2481PKCS12_BAGS_it 2972 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION: 2481PKCS12_BAGS_it 2972 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:
@@ -2487,7 +2487,7 @@ KRB5_AUTHENTBODY_it 2976 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTI
2487X509_supported_extension 2977 EXIST::FUNCTION: 2487X509_supported_extension 2977 EXIST::FUNCTION:
2488i2d_KRB5_AUTHDATA 2978 EXIST::FUNCTION: 2488i2d_KRB5_AUTHDATA 2978 EXIST::FUNCTION:
2489UI_method_get_opener 2979 EXIST::FUNCTION: 2489UI_method_get_opener 2979 EXIST::FUNCTION:
2490ENGINE_set_ex_data 2980 EXIST::FUNCTION: 2490ENGINE_set_ex_data 2980 EXIST::FUNCTION:ENGINE
2491OCSP_REQUEST_print 2981 EXIST::FUNCTION: 2491OCSP_REQUEST_print 2981 EXIST::FUNCTION:
2492CBIGNUM_it 2982 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE: 2492CBIGNUM_it 2982 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:
2493CBIGNUM_it 2982 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION: 2493CBIGNUM_it 2982 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:
@@ -2501,7 +2501,7 @@ OCSP_single_get0_status 2989 EXIST::FUNCTION:
2501BN_swap 2990 EXIST::FUNCTION: 2501BN_swap 2990 EXIST::FUNCTION:
2502POLICYINFO_it 2991 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE: 2502POLICYINFO_it 2991 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:
2503POLICYINFO_it 2991 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION: 2503POLICYINFO_it 2991 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:
2504ENGINE_set_destroy_function 2992 EXIST::FUNCTION: 2504ENGINE_set_destroy_function 2992 EXIST::FUNCTION:ENGINE
2505asn1_enc_free 2993 EXIST::FUNCTION: 2505asn1_enc_free 2993 EXIST::FUNCTION:
2506OCSP_RESPID_it 2994 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE: 2506OCSP_RESPID_it 2994 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:
2507OCSP_RESPID_it 2994 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION: 2507OCSP_RESPID_it 2994 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:
@@ -2523,8 +2523,8 @@ EDIPARTYNAME_it 3005 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTI
2523NETSCAPE_SPKI_it 3006 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE: 2523NETSCAPE_SPKI_it 3006 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:
2524NETSCAPE_SPKI_it 3006 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION: 2524NETSCAPE_SPKI_it 3006 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:
2525UI_get0_test_string 3007 EXIST::FUNCTION: 2525UI_get0_test_string 3007 EXIST::FUNCTION:
2526ENGINE_get_cipher_engine 3008 EXIST::FUNCTION: 2526ENGINE_get_cipher_engine 3008 EXIST::FUNCTION:ENGINE
2527ENGINE_register_all_ciphers 3009 EXIST::FUNCTION: 2527ENGINE_register_all_ciphers 3009 EXIST::FUNCTION:ENGINE
2528EC_POINT_copy 3010 EXIST::FUNCTION:EC 2528EC_POINT_copy 3010 EXIST::FUNCTION:EC
2529BN_kronecker 3011 EXIST::FUNCTION: 2529BN_kronecker 3011 EXIST::FUNCTION:
2530_ossl_old_des_ede3_ofb64_encrypt 3012 EXIST:!VMS:FUNCTION:DES 2530_ossl_old_des_ede3_ofb64_encrypt 3012 EXIST:!VMS:FUNCTION:DES
@@ -2545,9 +2545,9 @@ OCSP_RESPONSE_new 3023 EXIST::FUNCTION:
2545AES_set_encrypt_key 3024 EXIST::FUNCTION:AES 2545AES_set_encrypt_key 3024 EXIST::FUNCTION:AES
2546OCSP_resp_count 3025 EXIST::FUNCTION: 2546OCSP_resp_count 3025 EXIST::FUNCTION:
2547KRB5_CHECKSUM_new 3026 EXIST::FUNCTION: 2547KRB5_CHECKSUM_new 3026 EXIST::FUNCTION:
2548ENGINE_load_cswift 3027 EXIST::FUNCTION: 2548ENGINE_load_cswift 3027 EXIST::FUNCTION:ENGINE
2549OCSP_onereq_get0_id 3028 EXIST::FUNCTION: 2549OCSP_onereq_get0_id 3028 EXIST::FUNCTION:
2550ENGINE_set_default_ciphers 3029 EXIST::FUNCTION: 2550ENGINE_set_default_ciphers 3029 EXIST::FUNCTION:ENGINE
2551NOTICEREF_it 3030 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE: 2551NOTICEREF_it 3030 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:
2552NOTICEREF_it 3030 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION: 2552NOTICEREF_it 3030 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:
2553X509V3_EXT_CRL_add_nconf 3031 EXIST::FUNCTION: 2553X509V3_EXT_CRL_add_nconf 3031 EXIST::FUNCTION:
@@ -2565,7 +2565,7 @@ AES_decrypt 3040 EXIST::FUNCTION:AES
2565asn1_enc_init 3041 EXIST::FUNCTION: 2565asn1_enc_init 3041 EXIST::FUNCTION:
2566UI_get_result_maxsize 3042 EXIST::FUNCTION: 2566UI_get_result_maxsize 3042 EXIST::FUNCTION:
2567OCSP_CERTID_new 3043 EXIST::FUNCTION: 2567OCSP_CERTID_new 3043 EXIST::FUNCTION:
2568ENGINE_unregister_RAND 3044 EXIST::FUNCTION: 2568ENGINE_unregister_RAND 3044 EXIST::FUNCTION:ENGINE
2569UI_method_get_closer 3045 EXIST::FUNCTION: 2569UI_method_get_closer 3045 EXIST::FUNCTION:
2570d2i_KRB5_ENCDATA 3046 EXIST::FUNCTION: 2570d2i_KRB5_ENCDATA 3046 EXIST::FUNCTION:
2571OCSP_request_onereq_count 3047 EXIST::FUNCTION: 2571OCSP_request_onereq_count 3047 EXIST::FUNCTION:
@@ -2576,7 +2576,7 @@ ASN1_primitive_free 3051 EXIST::FUNCTION:
2576i2d_EXTENDED_KEY_USAGE 3052 EXIST::FUNCTION: 2576i2d_EXTENDED_KEY_USAGE 3052 EXIST::FUNCTION:
2577i2d_OCSP_SIGNATURE 3053 EXIST::FUNCTION: 2577i2d_OCSP_SIGNATURE 3053 EXIST::FUNCTION:
2578asn1_enc_save 3054 EXIST::FUNCTION: 2578asn1_enc_save 3054 EXIST::FUNCTION:
2579ENGINE_load_nuron 3055 EXIST::FUNCTION: 2579ENGINE_load_nuron 3055 EXIST::FUNCTION:ENGINE
2580_ossl_old_des_pcbc_encrypt 3056 EXIST::FUNCTION:DES 2580_ossl_old_des_pcbc_encrypt 3056 EXIST::FUNCTION:DES
2581PKCS12_MAC_DATA_it 3057 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE: 2581PKCS12_MAC_DATA_it 3057 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:
2582PKCS12_MAC_DATA_it 3057 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION: 2582PKCS12_MAC_DATA_it 3057 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:
@@ -2598,15 +2598,15 @@ ASN1_item_d2i_bio 3069 EXIST::FUNCTION:BIO
2598EC_POINT_dbl 3070 EXIST::FUNCTION:EC 2598EC_POINT_dbl 3070 EXIST::FUNCTION:EC
2599asn1_get_choice_selector 3071 EXIST::FUNCTION: 2599asn1_get_choice_selector 3071 EXIST::FUNCTION:
2600i2d_KRB5_CHECKSUM 3072 EXIST::FUNCTION: 2600i2d_KRB5_CHECKSUM 3072 EXIST::FUNCTION:
2601ENGINE_set_table_flags 3073 EXIST::FUNCTION: 2601ENGINE_set_table_flags 3073 EXIST::FUNCTION:ENGINE
2602AES_options 3074 EXIST::FUNCTION:AES 2602AES_options 3074 EXIST::FUNCTION:AES
2603ENGINE_load_chil 3075 EXIST::FUNCTION: 2603ENGINE_load_chil 3075 EXIST::FUNCTION:ENGINE
2604OCSP_id_cmp 3076 EXIST::FUNCTION: 2604OCSP_id_cmp 3076 EXIST::FUNCTION:
2605OCSP_BASICRESP_new 3077 EXIST::FUNCTION: 2605OCSP_BASICRESP_new 3077 EXIST::FUNCTION:
2606OCSP_REQUEST_get_ext_by_NID 3078 EXIST::FUNCTION: 2606OCSP_REQUEST_get_ext_by_NID 3078 EXIST::FUNCTION:
2607KRB5_APREQ_it 3079 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE: 2607KRB5_APREQ_it 3079 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:
2608KRB5_APREQ_it 3079 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION: 2608KRB5_APREQ_it 3079 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:
2609ENGINE_get_destroy_function 3080 EXIST::FUNCTION: 2609ENGINE_get_destroy_function 3080 EXIST::FUNCTION:ENGINE
2610CONF_set_nconf 3081 EXIST::FUNCTION: 2610CONF_set_nconf 3081 EXIST::FUNCTION:
2611ASN1_PRINTABLE_free 3082 EXIST::FUNCTION: 2611ASN1_PRINTABLE_free 3082 EXIST::FUNCTION:
2612OCSP_BASICRESP_get_ext_by_NID 3083 EXIST::FUNCTION: 2612OCSP_BASICRESP_get_ext_by_NID 3083 EXIST::FUNCTION:
@@ -2667,7 +2667,7 @@ OCSP_CRLID_it 3127 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIA
2667OCSP_CRLID_it 3127 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION: 2667OCSP_CRLID_it 3127 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:
2668i2d_KRB5_AUTHENTBODY 3128 EXIST::FUNCTION: 2668i2d_KRB5_AUTHENTBODY 3128 EXIST::FUNCTION:
2669OCSP_REQUEST_get_ext_count 3129 EXIST::FUNCTION: 2669OCSP_REQUEST_get_ext_count 3129 EXIST::FUNCTION:
2670ENGINE_load_atalla 3130 EXIST::FUNCTION: 2670ENGINE_load_atalla 3130 EXIST::FUNCTION:ENGINE
2671X509_NAME_it 3131 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE: 2671X509_NAME_it 3131 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:
2672X509_NAME_it 3131 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION: 2672X509_NAME_it 3131 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:
2673USERNOTICE_it 3132 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE: 2673USERNOTICE_it 3132 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:
@@ -2685,7 +2685,7 @@ UI_method_set_opener 3140 EXIST::FUNCTION:
2685ASN1_item_ex_free 3141 EXIST::FUNCTION: 2685ASN1_item_ex_free 3141 EXIST::FUNCTION:
2686ASN1_BOOLEAN_it 3142 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE: 2686ASN1_BOOLEAN_it 3142 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:
2687ASN1_BOOLEAN_it 3142 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION: 2687ASN1_BOOLEAN_it 3142 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:
2688ENGINE_get_table_flags 3143 EXIST::FUNCTION: 2688ENGINE_get_table_flags 3143 EXIST::FUNCTION:ENGINE
2689UI_create_method 3144 EXIST::FUNCTION: 2689UI_create_method 3144 EXIST::FUNCTION:
2690OCSP_ONEREQ_add1_ext_i2d 3145 EXIST::FUNCTION: 2690OCSP_ONEREQ_add1_ext_i2d 3145 EXIST::FUNCTION:
2691_shadow_DES_check_key 3146 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:DES 2691_shadow_DES_check_key 3146 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:DES
@@ -2709,7 +2709,7 @@ PKCS7_it 3160 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIA
2709PKCS7_it 3160 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION: 2709PKCS7_it 3160 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:
2710OCSP_REQUEST_get_ext_by_critical 3161 EXIST:!VMS:FUNCTION: 2710OCSP_REQUEST_get_ext_by_critical 3161 EXIST:!VMS:FUNCTION:
2711OCSP_REQUEST_get_ext_by_crit 3161 EXIST:VMS:FUNCTION: 2711OCSP_REQUEST_get_ext_by_crit 3161 EXIST:VMS:FUNCTION:
2712ENGINE_set_flags 3162 EXIST::FUNCTION: 2712ENGINE_set_flags 3162 EXIST::FUNCTION:ENGINE
2713_ossl_old_des_ecb_encrypt 3163 EXIST::FUNCTION:DES 2713_ossl_old_des_ecb_encrypt 3163 EXIST::FUNCTION:DES
2714OCSP_response_get1_basic 3164 EXIST::FUNCTION: 2714OCSP_response_get1_basic 3164 EXIST::FUNCTION:
2715EVP_Digest 3165 EXIST::FUNCTION: 2715EVP_Digest 3165 EXIST::FUNCTION:
@@ -2721,8 +2721,8 @@ ASN1_TIME_to_generalizedtime 3169 EXIST::FUNCTION:
2721BIGNUM_it 3170 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE: 2721BIGNUM_it 3170 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:
2722BIGNUM_it 3170 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION: 2722BIGNUM_it 3170 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:
2723AES_cbc_encrypt 3171 EXIST::FUNCTION:AES 2723AES_cbc_encrypt 3171 EXIST::FUNCTION:AES
2724ENGINE_get_load_privkey_function 3172 EXIST:!VMS:FUNCTION: 2724ENGINE_get_load_privkey_function 3172 EXIST:!VMS:FUNCTION:ENGINE
2725ENGINE_get_load_privkey_fn 3172 EXIST:VMS:FUNCTION: 2725ENGINE_get_load_privkey_fn 3172 EXIST:VMS:FUNCTION:ENGINE
2726OCSP_RESPONSE_free 3173 EXIST::FUNCTION: 2726OCSP_RESPONSE_free 3173 EXIST::FUNCTION:
2727UI_method_set_reader 3174 EXIST::FUNCTION: 2727UI_method_set_reader 3174 EXIST::FUNCTION:
2728i2d_ASN1_T61STRING 3175 EXIST::FUNCTION: 2728i2d_ASN1_T61STRING 3175 EXIST::FUNCTION:
@@ -2736,7 +2736,7 @@ OCSP_crlID_new 3181 EXIST:!OS2,!VMS,!WIN16:FUNCTION:
2736OCSP_crlID2_new 3181 EXIST:OS2,VMS,WIN16:FUNCTION: 2736OCSP_crlID2_new 3181 EXIST:OS2,VMS,WIN16:FUNCTION:
2737CONF_modules_load_file 3182 EXIST::FUNCTION: 2737CONF_modules_load_file 3182 EXIST::FUNCTION:
2738CONF_imodule_set_usr_data 3183 EXIST::FUNCTION: 2738CONF_imodule_set_usr_data 3183 EXIST::FUNCTION:
2739ENGINE_set_default_string 3184 EXIST::FUNCTION: 2739ENGINE_set_default_string 3184 EXIST::FUNCTION:ENGINE
2740CONF_module_get_usr_data 3185 EXIST::FUNCTION: 2740CONF_module_get_usr_data 3185 EXIST::FUNCTION:
2741ASN1_add_oid_module 3186 EXIST::FUNCTION: 2741ASN1_add_oid_module 3186 EXIST::FUNCTION:
2742CONF_modules_finish 3187 EXIST::FUNCTION: 2742CONF_modules_finish 3187 EXIST::FUNCTION:
@@ -2754,7 +2754,7 @@ CONF_imodule_get_name 3198 EXIST::FUNCTION:
2754ERR_peek_top_error 3199 NOEXIST::FUNCTION: 2754ERR_peek_top_error 3199 NOEXIST::FUNCTION:
2755CONF_imodule_get_usr_data 3200 EXIST::FUNCTION: 2755CONF_imodule_get_usr_data 3200 EXIST::FUNCTION:
2756CONF_imodule_set_flags 3201 EXIST::FUNCTION: 2756CONF_imodule_set_flags 3201 EXIST::FUNCTION:
2757ENGINE_add_conf_module 3202 EXIST::FUNCTION: 2757ENGINE_add_conf_module 3202 EXIST::FUNCTION:ENGINE
2758ERR_peek_last_error_line 3203 EXIST::FUNCTION: 2758ERR_peek_last_error_line 3203 EXIST::FUNCTION:
2759ERR_peek_last_error_line_data 3204 EXIST::FUNCTION: 2759ERR_peek_last_error_line_data 3204 EXIST::FUNCTION:
2760ERR_peek_last_error 3205 EXIST::FUNCTION: 2760ERR_peek_last_error 3205 EXIST::FUNCTION:
@@ -2762,8 +2762,8 @@ DES_read_2passwords 3206 EXIST::FUNCTION:DES
2762DES_read_password 3207 EXIST::FUNCTION:DES 2762DES_read_password 3207 EXIST::FUNCTION:DES
2763UI_UTIL_read_pw 3208 EXIST::FUNCTION: 2763UI_UTIL_read_pw 3208 EXIST::FUNCTION:
2764UI_UTIL_read_pw_string 3209 EXIST::FUNCTION: 2764UI_UTIL_read_pw_string 3209 EXIST::FUNCTION:
2765ENGINE_load_aep 3210 EXIST::FUNCTION: 2765ENGINE_load_aep 3210 EXIST::FUNCTION:ENGINE
2766ENGINE_load_sureware 3211 EXIST::FUNCTION: 2766ENGINE_load_sureware 3211 EXIST::FUNCTION:ENGINE
2767OPENSSL_add_all_algorithms_noconf 3212 EXIST:!VMS:FUNCTION: 2767OPENSSL_add_all_algorithms_noconf 3212 EXIST:!VMS:FUNCTION:
2768OPENSSL_add_all_algo_noconf 3212 EXIST:VMS:FUNCTION: 2768OPENSSL_add_all_algo_noconf 3212 EXIST:VMS:FUNCTION:
2769OPENSSL_add_all_algorithms_conf 3213 EXIST:!VMS:FUNCTION: 2769OPENSSL_add_all_algorithms_conf 3213 EXIST:!VMS:FUNCTION:
@@ -2772,7 +2772,7 @@ OPENSSL_load_builtin_modules 3214 EXIST::FUNCTION:
2772AES_ofb128_encrypt 3215 EXIST::FUNCTION:AES 2772AES_ofb128_encrypt 3215 EXIST::FUNCTION:AES
2773AES_ctr128_encrypt 3216 EXIST::FUNCTION:AES 2773AES_ctr128_encrypt 3216 EXIST::FUNCTION:AES
2774AES_cfb128_encrypt 3217 EXIST::FUNCTION:AES 2774AES_cfb128_encrypt 3217 EXIST::FUNCTION:AES
2775ENGINE_load_4758cca 3218 EXIST::FUNCTION: 2775ENGINE_load_4758cca 3218 EXIST::FUNCTION:ENGINE
2776_ossl_096_des_random_seed 3219 EXIST::FUNCTION:DES 2776_ossl_096_des_random_seed 3219 EXIST::FUNCTION:DES
2777EVP_aes_256_ofb 3220 EXIST::FUNCTION:AES 2777EVP_aes_256_ofb 3220 EXIST::FUNCTION:AES
2778EVP_aes_192_ofb 3221 EXIST::FUNCTION:AES 2778EVP_aes_192_ofb 3221 EXIST::FUNCTION:AES
@@ -2793,3 +2793,11 @@ ASN1_UNIVERSALSTRING_it 3234 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTI
2793d2i_ASN1_UNIVERSALSTRING 3235 EXIST::FUNCTION: 2793d2i_ASN1_UNIVERSALSTRING 3235 EXIST::FUNCTION:
2794EVP_des_ede3_ecb 3236 EXIST::FUNCTION:DES 2794EVP_des_ede3_ecb 3236 EXIST::FUNCTION:DES
2795X509_REQ_print_ex 3237 EXIST::FUNCTION:BIO 2795X509_REQ_print_ex 3237 EXIST::FUNCTION:BIO
2796ENGINE_up_ref 3238 EXIST::FUNCTION:ENGINE
2797BUF_MEM_grow_clean 3239 EXIST::FUNCTION:
2798CRYPTO_realloc_clean 3240 EXIST::FUNCTION:
2799BUF_strlcat 3241 EXIST::FUNCTION:
2800BIO_indent 3242 EXIST::FUNCTION:
2801BUF_strlcpy 3243 EXIST::FUNCTION:
2802OpenSSLDie 3244 EXIST::FUNCTION:
2803OPENSSL_cleanse 3245 EXIST::FUNCTION:
diff --git a/src/lib/libcrypto/util/mk1mf.pl b/src/lib/libcrypto/util/mk1mf.pl
index c9271bbffe..c538f9dffb 100644
--- a/src/lib/libcrypto/util/mk1mf.pl
+++ b/src/lib/libcrypto/util/mk1mf.pl
@@ -24,6 +24,7 @@ $infile="MINFO";
24 24
25%ops=( 25%ops=(
26 "VC-WIN32", "Microsoft Visual C++ [4-6] - Windows NT or 9X", 26 "VC-WIN32", "Microsoft Visual C++ [4-6] - Windows NT or 9X",
27 "VC-CE", "Microsoft eMbedded Visual C++ 3.0 - Windows CE ONLY",
27 "VC-NT", "Microsoft Visual C++ [4-6] - Windows NT ONLY", 28 "VC-NT", "Microsoft Visual C++ [4-6] - Windows NT ONLY",
28 "VC-W31-16", "Microsoft Visual C++ 1.52 - Windows 3.1 - 286", 29 "VC-W31-16", "Microsoft Visual C++ 1.52 - Windows 3.1 - 286",
29 "VC-WIN16", "Alias for VC-W31-32", 30 "VC-WIN16", "Alias for VC-W31-32",
@@ -63,6 +64,8 @@ and [options] can be one of
63 no-asm - No x86 asm 64 no-asm - No x86 asm
64 no-krb5 - No KRB5 65 no-krb5 - No KRB5
65 no-ec - No EC 66 no-ec - No EC
67 no-engine - No engine
68 no-hw - No hw
66 nasm - Use NASM for x86 asm 69 nasm - Use NASM for x86 asm
67 gaswin - Use GNU as with Mingw32 70 gaswin - Use GNU as with Mingw32
68 no-socks - No socket code 71 no-socks - No socket code
@@ -137,6 +140,10 @@ elsif (($platform eq "VC-WIN32") || ($platform eq "VC-NT"))
137 $NT = 1 if $platform eq "VC-NT"; 140 $NT = 1 if $platform eq "VC-NT";
138 require 'VC-32.pl'; 141 require 'VC-32.pl';
139 } 142 }
143elsif ($platform eq "VC-CE")
144 {
145 require 'VC-CE.pl';
146 }
140elsif ($platform eq "Mingw32") 147elsif ($platform eq "Mingw32")
141 { 148 {
142 require 'Mingw32.pl'; 149 require 'Mingw32.pl';
@@ -213,7 +220,7 @@ $cflags.=" -DOPENSSL_NO_MD4" if $no_md4;
213$cflags.=" -DOPENSSL_NO_MD5" if $no_md5; 220$cflags.=" -DOPENSSL_NO_MD5" if $no_md5;
214$cflags.=" -DOPENSSL_NO_SHA" if $no_sha; 221$cflags.=" -DOPENSSL_NO_SHA" if $no_sha;
215$cflags.=" -DOPENSSL_NO_SHA1" if $no_sha1; 222$cflags.=" -DOPENSSL_NO_SHA1" if $no_sha1;
216$cflags.=" -DOPENSSL_NO_RIPEMD" if $no_rmd160; 223$cflags.=" -DOPENSSL_NO_RIPEMD" if $no_ripemd;
217$cflags.=" -DOPENSSL_NO_MDC2" if $no_mdc2; 224$cflags.=" -DOPENSSL_NO_MDC2" if $no_mdc2;
218$cflags.=" -DOPENSSL_NO_BF" if $no_bf; 225$cflags.=" -DOPENSSL_NO_BF" if $no_bf;
219$cflags.=" -DOPENSSL_NO_CAST" if $no_cast; 226$cflags.=" -DOPENSSL_NO_CAST" if $no_cast;
@@ -227,6 +234,8 @@ $cflags.=" -DOPENSSL_NO_SSL3" if $no_ssl3;
227$cflags.=" -DOPENSSL_NO_ERR" if $no_err; 234$cflags.=" -DOPENSSL_NO_ERR" if $no_err;
228$cflags.=" -DOPENSSL_NO_KRB5" if $no_krb5; 235$cflags.=" -DOPENSSL_NO_KRB5" if $no_krb5;
229$cflags.=" -DOPENSSL_NO_EC" if $no_ec; 236$cflags.=" -DOPENSSL_NO_EC" if $no_ec;
237$cflags.=" -DOPENSSL_NO_ENGINE" if $no_engine;
238$cflags.=" -DOPENSSL_NO_HW" if $no_hw;
230#$cflags.=" -DRSAref" if $rsaref ne ""; 239#$cflags.=" -DRSAref" if $rsaref ne "";
231 240
232## if ($unix) 241## if ($unix)
@@ -266,6 +275,17 @@ $defs= <<"EOF";
266# The one monster makefile better suits building in non-unix 275# The one monster makefile better suits building in non-unix
267# environments. 276# environments.
268 277
278EOF
279
280if ($platform eq "VC-CE")
281 {
282 $defs.= <<"EOF";
283!INCLUDE <\$(WCECOMPAT)/wcedefs.mak>
284
285EOF
286 }
287
288$defs.= <<"EOF";
269INSTALLTOP=$INSTALLTOP 289INSTALLTOP=$INSTALLTOP
270 290
271# Set your compiler options 291# Set your compiler options
@@ -632,6 +652,8 @@ sub var_add
632 local($dir,$val)=@_; 652 local($dir,$val)=@_;
633 local(@a,$_,$ret); 653 local(@a,$_,$ret);
634 654
655 return("") if $no_engine && $dir =~ /\/engine/;
656 return("") if $no_hw && $dir =~ /\/hw/;
635 return("") if $no_idea && $dir =~ /\/idea/; 657 return("") if $no_idea && $dir =~ /\/idea/;
636 return("") if $no_aes && $dir =~ /\/aes/; 658 return("") if $no_aes && $dir =~ /\/aes/;
637 return("") if $no_rc2 && $dir =~ /\/rc2/; 659 return("") if $no_rc2 && $dir =~ /\/rc2/;
@@ -641,6 +663,7 @@ sub var_add
641 return("") if $no_rsa && $dir =~ /^rsaref/; 663 return("") if $no_rsa && $dir =~ /^rsaref/;
642 return("") if $no_dsa && $dir =~ /\/dsa/; 664 return("") if $no_dsa && $dir =~ /\/dsa/;
643 return("") if $no_dh && $dir =~ /\/dh/; 665 return("") if $no_dh && $dir =~ /\/dh/;
666 return("") if $no_ec && $dir =~ /\/ec/;
644 if ($no_des && $dir =~ /\/des/) 667 if ($no_des && $dir =~ /\/des/)
645 { 668 {
646 if ($val =~ /read_pwd/) 669 if ($val =~ /read_pwd/)
@@ -675,7 +698,7 @@ sub var_add
675 @a=grep(!/(^md2)|(_md2$)/,@a) if $no_md2; 698 @a=grep(!/(^md2)|(_md2$)/,@a) if $no_md2;
676 @a=grep(!/(^md4)|(_md4$)/,@a) if $no_md4; 699 @a=grep(!/(^md4)|(_md4$)/,@a) if $no_md4;
677 @a=grep(!/(^md5)|(_md5$)/,@a) if $no_md5; 700 @a=grep(!/(^md5)|(_md5$)/,@a) if $no_md5;
678 @a=grep(!/(rmd)|(ripemd)/,@a) if $no_rmd160; 701 @a=grep(!/(rmd)|(ripemd)/,@a) if $no_ripemd;
679 702
680 @a=grep(!/(^d2i_r_)|(^i2d_r_)/,@a) if $no_rsa; 703 @a=grep(!/(^d2i_r_)|(^i2d_r_)/,@a) if $no_rsa;
681 @a=grep(!/(^p_open$)|(^p_seal$)/,@a) if $no_rsa; 704 @a=grep(!/(^p_open$)|(^p_seal$)/,@a) if $no_rsa;
@@ -692,6 +715,8 @@ sub var_add
692 @a=grep(!/(^sha1)|(_sha1$)|(m_dss1$)/,@a) if $no_sha1; 715 @a=grep(!/(^sha1)|(_sha1$)|(m_dss1$)/,@a) if $no_sha1;
693 @a=grep(!/_mdc2$/,@a) if $no_mdc2; 716 @a=grep(!/_mdc2$/,@a) if $no_mdc2;
694 717
718 @a=grep(!/^engine$/,@a) if $no_engine;
719 @a=grep(!/^hw$/,@a) if $no_hw;
695 @a=grep(!/(^rsa$)|(^genrsa$)/,@a) if $no_rsa; 720 @a=grep(!/(^rsa$)|(^genrsa$)/,@a) if $no_rsa;
696 @a=grep(!/(^dsa$)|(^gendsa$)|(^dsaparam$)/,@a) if $no_dsa; 721 @a=grep(!/(^dsa$)|(^gendsa$)|(^dsaparam$)/,@a) if $no_dsa;
697 @a=grep(!/^gendsa$/,@a) if $no_sha1; 722 @a=grep(!/^gendsa$/,@a) if $no_sha1;
@@ -885,10 +910,12 @@ sub read_options
885 elsif (/^no-sock$/) { $no_sock=1; } 910 elsif (/^no-sock$/) { $no_sock=1; }
886 elsif (/^no-krb5$/) { $no_krb5=1; } 911 elsif (/^no-krb5$/) { $no_krb5=1; }
887 elsif (/^no-ec$/) { $no_ec=1; } 912 elsif (/^no-ec$/) { $no_ec=1; }
913 elsif (/^no-engine$/) { $no_engine=1; }
914 elsif (/^no-hw$/) { $no_hw=1; }
888 915
889 elsif (/^just-ssl$/) { $no_rc2=$no_idea=$no_des=$no_bf=$no_cast=1; 916 elsif (/^just-ssl$/) { $no_rc2=$no_idea=$no_des=$no_bf=$no_cast=1;
890 $no_md2=$no_sha=$no_mdc2=$no_dsa=$no_dh=1; 917 $no_md2=$no_sha=$no_mdc2=$no_dsa=$no_dh=1;
891 $no_ssl2=$no_err=$no_rmd160=$no_rc5=1; 918 $no_ssl2=$no_err=$no_ripemd=$no_rc5=1;
892 $no_aes=1; } 919 $no_aes=1; }
893 920
894 elsif (/^rsaref$/) { } 921 elsif (/^rsaref$/) { }
diff --git a/src/lib/libcrypto/util/mkdef.pl b/src/lib/libcrypto/util/mkdef.pl
index adfd447dd3..cdd2164c4e 100644
--- a/src/lib/libcrypto/util/mkdef.pl
+++ b/src/lib/libcrypto/util/mkdef.pl
@@ -91,7 +91,7 @@ my @known_algorithms = ( "RC2", "RC4", "RC5", "IDEA", "DES", "BF",
91 "BIO", "COMP", "BUFFER", "LHASH", "STACK", "ERR", 91 "BIO", "COMP", "BUFFER", "LHASH", "STACK", "ERR",
92 "LOCKING", 92 "LOCKING",
93 # External "algorithms" 93 # External "algorithms"
94 "FP_API", "STDIO", "SOCK", "KRB5" ); 94 "FP_API", "STDIO", "SOCK", "KRB5", "ENGINE", "HW" );
95 95
96my $options=""; 96my $options="";
97open(IN,"<Makefile.ssl") || die "unable to open Makefile.ssl!\n"; 97open(IN,"<Makefile.ssl") || die "unable to open Makefile.ssl!\n";
@@ -107,7 +107,7 @@ my $no_rc2; my $no_rc4; my $no_rc5; my $no_idea; my $no_des; my $no_bf;
107my $no_cast; 107my $no_cast;
108my $no_md2; my $no_md4; my $no_md5; my $no_sha; my $no_ripemd; my $no_mdc2; 108my $no_md2; my $no_md4; my $no_md5; my $no_sha; my $no_ripemd; my $no_mdc2;
109my $no_rsa; my $no_dsa; my $no_dh; my $no_hmac=0; my $no_aes; my $no_krb5; 109my $no_rsa; my $no_dsa; my $no_dh; my $no_hmac=0; my $no_aes; my $no_krb5;
110my $no_ec; 110my $no_ec; my $no_engine; my $no_hw;
111my $no_fp_api; 111my $no_fp_api;
112 112
113foreach (@ARGV, split(/ /, $options)) 113foreach (@ARGV, split(/ /, $options))
@@ -176,6 +176,8 @@ foreach (@ARGV, split(/ /, $options))
176 elsif (/^no-comp$/) { $no_comp=1; } 176 elsif (/^no-comp$/) { $no_comp=1; }
177 elsif (/^no-dso$/) { $no_dso=1; } 177 elsif (/^no-dso$/) { $no_dso=1; }
178 elsif (/^no-krb5$/) { $no_krb5=1; } 178 elsif (/^no-krb5$/) { $no_krb5=1; }
179 elsif (/^no-engine$/) { $no_engine=1; }
180 elsif (/^no-hw$/) { $no_hw=1; }
179 } 181 }
180 182
181 183
@@ -235,7 +237,7 @@ $crypto.=" crypto/dh/dh.h" ; # unless $no_dh;
235$crypto.=" crypto/ec/ec.h" ; # unless $no_ec; 237$crypto.=" crypto/ec/ec.h" ; # unless $no_ec;
236$crypto.=" crypto/hmac/hmac.h" ; # unless $no_hmac; 238$crypto.=" crypto/hmac/hmac.h" ; # unless $no_hmac;
237 239
238$crypto.=" crypto/engine/engine.h"; 240$crypto.=" crypto/engine/engine.h"; # unless $no_engine;
239$crypto.=" crypto/stack/stack.h" ; # unless $no_stack; 241$crypto.=" crypto/stack/stack.h" ; # unless $no_stack;
240$crypto.=" crypto/buffer/buffer.h" ; # unless $no_buffer; 242$crypto.=" crypto/buffer/buffer.h" ; # unless $no_buffer;
241$crypto.=" crypto/bio/bio.h" ; # unless $no_bio; 243$crypto.=" crypto/bio/bio.h" ; # unless $no_bio;
@@ -438,7 +440,12 @@ sub do_defs
438 } 440 }
439 441
440 s/\/\*.*?\*\///gs; # ignore comments 442 s/\/\*.*?\*\///gs; # ignore comments
443 if (/\/\*/) { # if we have part
444 $line = $_; # of a comment,
445 next; # continue reading
446 }
441 s/{[^{}]*}//gs; # ignore {} blocks 447 s/{[^{}]*}//gs; # ignore {} blocks
448 print STDERR "DEBUG: \$def=\"$def\"\n" if $debug && $def ne "";
442 print STDERR "DEBUG: \$_=\"$_\"\n" if $debug; 449 print STDERR "DEBUG: \$_=\"$_\"\n" if $debug;
443 if (/^\#\s*ifndef\s+(.*)/) { 450 if (/^\#\s*ifndef\s+(.*)/) {
444 push(@tag,"-"); 451 push(@tag,"-");
@@ -812,14 +819,14 @@ sub do_defs
812 } elsif (/\(\*(\w*(\{[0-9]+\})?)\([^\)]+/) { 819 } elsif (/\(\*(\w*(\{[0-9]+\})?)\([^\)]+/) {
813 $s = $1; 820 $s = $1;
814 print STDERR "DEBUG: found ANSI C function $s\n" if $debug; 821 print STDERR "DEBUG: found ANSI C function $s\n" if $debug;
815 } elsif (/\w+\W+(\w+)\W*\(\s*\)$/s) { 822 } elsif (/\w+\W+(\w+)\W*\(\s*\)(\s*__attribute__\(.*\)\s*)?$/s) {
816 # K&R C 823 # K&R C
817 print STDERR "DEBUG: found K&R C function $s\n" if $debug; 824 print STDERR "DEBUG: found K&R C function $s\n" if $debug;
818 next; 825 next;
819 } elsif (/\w+\W+\w+(\{[0-9]+\})?\W*\(.*\)$/s) { 826 } elsif (/\w+\W+\w+(\{[0-9]+\})?\W*\(.*\)(\s*__attribute__\(.*\)\s*)?$/s) {
820 while (not /\(\)$/s) { 827 while (not /\(\)(\s*__attribute__\(.*\)\s*)?$/s) {
821 s/[^\(\)]*\)$/\)/s; 828 s/[^\(\)]*\)(\s*__attribute__\(.*\)\s*)?$/\)/s;
822 s/\([^\(\)]*\)\)$/\)/s; 829 s/\([^\(\)]*\)\)(\s*__attribute__\(.*\)\s*)?$/\)/s;
823 } 830 }
824 s/\(void\)//; 831 s/\(void\)//;
825 /(\w+(\{[0-9]+\})?)\W*\(\)/s; 832 /(\w+(\{[0-9]+\})?)\W*\(\)/s;
@@ -1052,6 +1059,8 @@ sub is_valid
1052 if ($keyword eq "COMP" && $no_comp) { return 0; } 1059 if ($keyword eq "COMP" && $no_comp) { return 0; }
1053 if ($keyword eq "DSO" && $no_dso) { return 0; } 1060 if ($keyword eq "DSO" && $no_dso) { return 0; }
1054 if ($keyword eq "KRB5" && $no_krb5) { return 0; } 1061 if ($keyword eq "KRB5" && $no_krb5) { return 0; }
1062 if ($keyword eq "ENGINE" && $no_engine) { return 0; }
1063 if ($keyword eq "HW" && $no_hw) { return 0; }
1055 if ($keyword eq "FP_API" && $no_fp_api) { return 0; } 1064 if ($keyword eq "FP_API" && $no_fp_api) { return 0; }
1056 1065
1057 # Nothing recognise as true 1066 # Nothing recognise as true
diff --git a/src/lib/libcrypto/util/mkerr.pl b/src/lib/libcrypto/util/mkerr.pl
index 4105047b21..1b2915c767 100644
--- a/src/lib/libcrypto/util/mkerr.pl
+++ b/src/lib/libcrypto/util/mkerr.pl
@@ -132,16 +132,16 @@ while (($hdr, $lib) = each %libinc)
132 my $name = $1; 132 my $name = $1;
133 $name =~ tr/[a-z]/[A-Z]/; 133 $name =~ tr/[a-z]/[A-Z]/;
134 $ftrans{$name} = $1; 134 $ftrans{$name} = $1;
135 } elsif (/\w+\W+(\w+)\W*\(\s*\)$/s){ 135 } elsif (/\w+\W+(\w+)\W*\(\s*\)(\s*__attribute__\(.*\)\s*)?$/s){
136 # K&R C 136 # K&R C
137 next ; 137 next ;
138 } elsif (/\w+\W+\w+\W*\(.*\)$/s) { 138 } elsif (/\w+\W+\w+\W*\(.*\)(\s*__attribute__\(.*\)\s*)?$/s) {
139 while (not /\(\)$/s) { 139 while (not /\(\)(\s*__attribute__\(.*\)\s*)?$/s) {
140 s/[^\(\)]*\)$/\)/s; 140 s/[^\(\)]*\)(\s*__attribute__\(.*\)\s*)?$/\)/s;
141 s/\([^\(\)]*\)\)$/\)/s; 141 s/\([^\(\)]*\)\)(\s*__attribute__\(.*\)\s*)?$/\)/s;
142 } 142 }
143 s/\(void\)//; 143 s/\(void\)//;
144 /(\w+)\W*\(\)/s; 144 /(\w+(\{[0-9]+\})?)\W*\(\)/s;
145 my $name = $1; 145 my $name = $1;
146 $name =~ tr/[a-z]/[A-Z]/; 146 $name =~ tr/[a-z]/[A-Z]/;
147 $ftrans{$name} = $1; 147 $ftrans{$name} = $1;
@@ -262,7 +262,7 @@ foreach $lib (keys %csrc)
262 } else { 262 } else {
263 push @out, 263 push @out,
264"/* ====================================================================\n", 264"/* ====================================================================\n",
265" * Copyright (c) 2001-2002 The OpenSSL Project. All rights reserved.\n", 265" * Copyright (c) 2001-2003 The OpenSSL Project. All rights reserved.\n",
266" *\n", 266" *\n",
267" * Redistribution and use in source and binary forms, with or without\n", 267" * Redistribution and use in source and binary forms, with or without\n",
268" * modification, are permitted provided that the following conditions\n", 268" * modification, are permitted provided that the following conditions\n",
@@ -404,7 +404,7 @@ EOF
404 print OUT <<"EOF"; 404 print OUT <<"EOF";
405/* $cfile */ 405/* $cfile */
406/* ==================================================================== 406/* ====================================================================
407 * Copyright (c) 1999-2002 The OpenSSL Project. All rights reserved. 407 * Copyright (c) 1999-2003 The OpenSSL Project. All rights reserved.
408 * 408 *
409 * Redistribution and use in source and binary forms, with or without 409 * Redistribution and use in source and binary forms, with or without
410 * modification, are permitted provided that the following conditions 410 * modification, are permitted provided that the following conditions
diff --git a/src/lib/libcrypto/util/pl/BC-32.pl b/src/lib/libcrypto/util/pl/BC-32.pl
index bd7a9d9301..e83b336190 100644
--- a/src/lib/libcrypto/util/pl/BC-32.pl
+++ b/src/lib/libcrypto/util/pl/BC-32.pl
@@ -51,9 +51,9 @@ $lfile='';
51$shlib_ex_obj=""; 51$shlib_ex_obj="";
52$app_ex_obj="c0x32.obj"; 52$app_ex_obj="c0x32.obj";
53 53
54$asm='nasmw'; 54$asm='nasmw -f obj';
55$asm.=" /Zi" if $debug; 55$asm.=" /Zi" if $debug;
56$afile='-f obj -o'; 56$afile='-o';
57 57
58$bn_mulw_obj=''; 58$bn_mulw_obj='';
59$bn_mulw_src=''; 59$bn_mulw_src='';
diff --git a/src/lib/libcrypto/util/pl/Mingw32.pl b/src/lib/libcrypto/util/pl/Mingw32.pl
index 45ab685974..043a3a53ee 100644
--- a/src/lib/libcrypto/util/pl/Mingw32.pl
+++ b/src/lib/libcrypto/util/pl/Mingw32.pl
@@ -1,17 +1,17 @@
1#!/usr/local/bin/perl 1#!/usr/local/bin/perl
2# 2#
3# Mingw32.pl -- Mingw32 with GNU cp (Mingw32f.pl uses DOS tools) 3# Mingw32.pl -- Mingw
4# 4#
5 5
6$o='/'; 6$o='/';
7$cp='cp'; 7$cp='cp';
8$rm='rem'; # use 'rm -f' if using GNU file utilities 8$rm='rm -f';
9$mkdir='gmkdir'; 9$mkdir='gmkdir';
10 10
11# gcc wouldn't accept backslashes in paths 11$o='\\';
12#$o='\\'; 12$cp='copy';
13#$cp='copy'; 13$rm='del';
14#$rm='del'; 14$mkdir='mkdir';
15 15
16# C compiler stuff 16# C compiler stuff
17 17
@@ -19,29 +19,29 @@ $cc='gcc';
19if ($debug) 19if ($debug)
20 { $cflags="-DL_ENDIAN -DDSO_WIN32 -g2 -ggdb"; } 20 { $cflags="-DL_ENDIAN -DDSO_WIN32 -g2 -ggdb"; }
21else 21else
22 { $cflags="-DL_ENDIAN -DDSO_WIN32 -fomit-frame-pointer -O3 -m486 -Wall"; } 22 { $cflags="-DL_ENDIAN -DDSO_WIN32 -fomit-frame-pointer -O3 -mcpu=i486 -Wall"; }
23 23
24if ($gaswin and !$no_asm) 24if ($gaswin and !$no_asm)
25 { 25 {
26 $bn_asm_obj='$(OBJ_D)/bn-win32.o'; 26 $bn_asm_obj='$(OBJ_D)\bn-win32.o';
27 $bn_asm_src='crypto/bn/asm/bn-win32.s'; 27 $bn_asm_src='crypto/bn/asm/bn-win32.s';
28 $bnco_asm_obj='$(OBJ_D)/co-win32.o'; 28 $bnco_asm_obj='$(OBJ_D)\co-win32.o';
29 $bnco_asm_src='crypto/bn/asm/co-win32.s'; 29 $bnco_asm_src='crypto/bn/asm/co-win32.s';
30 $des_enc_obj='$(OBJ_D)/d-win32.o $(OBJ_D)/y-win32.o'; 30 $des_enc_obj='$(OBJ_D)\d-win32.o $(OBJ_D)\y-win32.o';
31 $des_enc_src='crypto/des/asm/d-win32.s crypto/des/asm/y-win32.s'; 31 $des_enc_src='crypto/des/asm/d-win32.s crypto/des/asm/y-win32.s';
32 $bf_enc_obj='$(OBJ_D)/b-win32.o'; 32 $bf_enc_obj='$(OBJ_D)\b-win32.o';
33 $bf_enc_src='crypto/bf/asm/b-win32.s'; 33 $bf_enc_src='crypto/bf/asm/b-win32.s';
34# $cast_enc_obj='$(OBJ_D)/c-win32.o'; 34# $cast_enc_obj='$(OBJ_D)\c-win32.o';
35# $cast_enc_src='crypto/cast/asm/c-win32.s'; 35# $cast_enc_src='crypto/cast/asm/c-win32.s';
36 $rc4_enc_obj='$(OBJ_D)/r4-win32.o'; 36 $rc4_enc_obj='$(OBJ_D)\r4-win32.o';
37 $rc4_enc_src='crypto/rc4/asm/r4-win32.s'; 37 $rc4_enc_src='crypto/rc4/asm/r4-win32.s';
38 $rc5_enc_obj='$(OBJ_D)/r5-win32.o'; 38 $rc5_enc_obj='$(OBJ_D)\r5-win32.o';
39 $rc5_enc_src='crypto/rc5/asm/r5-win32.s'; 39 $rc5_enc_src='crypto/rc5/asm/r5-win32.s';
40 $md5_asm_obj='$(OBJ_D)/m5-win32.o'; 40 $md5_asm_obj='$(OBJ_D)\m5-win32.o';
41 $md5_asm_src='crypto/md5/asm/m5-win32.s'; 41 $md5_asm_src='crypto/md5/asm/m5-win32.s';
42 $rmd160_asm_obj='$(OBJ_D)/rm-win32.o'; 42 $rmd160_asm_obj='$(OBJ_D)\rm-win32.o';
43 $rmd160_asm_src='crypto/ripemd/asm/rm-win32.s'; 43 $rmd160_asm_src='crypto/ripemd/asm/rm-win32.s';
44 $sha1_asm_obj='$(OBJ_D)/s1-win32.o'; 44 $sha1_asm_obj='$(OBJ_D)\s1-win32.o';
45 $sha1_asm_src='crypto/sha/asm/s1-win32.s'; 45 $sha1_asm_src='crypto/sha/asm/s1-win32.s';
46 $cflags.=" -DBN_ASM -DMD5_ASM -DSHA1_ASM"; 46 $cflags.=" -DBN_ASM -DMD5_ASM -DSHA1_ASM";
47 } 47 }
diff --git a/src/lib/libcrypto/util/pl/VC-32.pl b/src/lib/libcrypto/util/pl/VC-32.pl
index d6e3a11530..285990c589 100644
--- a/src/lib/libcrypto/util/pl/VC-32.pl
+++ b/src/lib/libcrypto/util/pl/VC-32.pl
@@ -91,7 +91,7 @@ if ($shlib)
91 { 91 {
92 $mlflags.=" $lflags /dll"; 92 $mlflags.=" $lflags /dll";
93# $cflags =~ s| /MD| /MT|; 93# $cflags =~ s| /MD| /MT|;
94 $lib_cflag=" -D_WINDLL -D_DLL"; 94 $lib_cflag=" -D_WINDLL";
95 $out_def="out32dll"; 95 $out_def="out32dll";
96 $tmp_def="tmp32dll"; 96 $tmp_def="tmp32dll";
97 } 97 }
diff --git a/src/lib/libcrypto/util/ssleay.num b/src/lib/libcrypto/util/ssleay.num
index fdea47205d..46e38a131f 100644
--- a/src/lib/libcrypto/util/ssleay.num
+++ b/src/lib/libcrypto/util/ssleay.num
@@ -169,7 +169,7 @@ SSL_add_file_cert_subjects_to_stack 185 EXIST:!VMS:FUNCTION:STDIO
169SSL_add_file_cert_subjs_to_stk 185 EXIST:VMS:FUNCTION:STDIO 169SSL_add_file_cert_subjs_to_stk 185 EXIST:VMS:FUNCTION:STDIO
170SSL_set_tmp_rsa_callback 186 EXIST::FUNCTION:RSA 170SSL_set_tmp_rsa_callback 186 EXIST::FUNCTION:RSA
171SSL_set_tmp_dh_callback 187 EXIST::FUNCTION:DH 171SSL_set_tmp_dh_callback 187 EXIST::FUNCTION:DH
172SSL_add_dir_cert_subjects_to_stack 188 EXIST:!VMS,!WIN32:FUNCTION:STDIO 172SSL_add_dir_cert_subjects_to_stack 188 EXIST:!VMS:FUNCTION:STDIO
173SSL_add_dir_cert_subjs_to_stk 188 NOEXIST::FUNCTION: 173SSL_add_dir_cert_subjs_to_stk 188 NOEXIST::FUNCTION:
174SSL_set_session_id_context 189 EXIST::FUNCTION: 174SSL_set_session_id_context 189 EXIST::FUNCTION:
175SSL_CTX_use_certificate_chain_file 222 EXIST:!VMS:FUNCTION:STDIO 175SSL_CTX_use_certificate_chain_file 222 EXIST:!VMS:FUNCTION:STDIO
diff --git a/src/lib/libcrypto/x509/Makefile.ssl b/src/lib/libcrypto/x509/Makefile.ssl
index ee53294699..3a3452536c 100644
--- a/src/lib/libcrypto/x509/Makefile.ssl
+++ b/src/lib/libcrypto/x509/Makefile.ssl
@@ -78,7 +78,7 @@ lint:
78 lint -DLINT $(INCLUDES) $(SRC)>fluff 78 lint -DLINT $(INCLUDES) $(SRC)>fluff
79 79
80depend: 80depend:
81 $(MAKEDEPEND) $(CFLAG) $(INCLUDES) $(DEPFLAG) $(PROGS) $(LIBSRC) 81 $(MAKEDEPEND) -- $(CFLAG) $(INCLUDES) $(DEPFLAG) -- $(PROGS) $(LIBSRC)
82 82
83dclean: 83dclean:
84 $(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new 84 $(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
diff --git a/src/lib/libcrypto/x509/by_file.c b/src/lib/libcrypto/x509/by_file.c
index 92e00d2d73..b4b04183d0 100644
--- a/src/lib/libcrypto/x509/by_file.c
+++ b/src/lib/libcrypto/x509/by_file.c
@@ -100,18 +100,19 @@ static int by_file_ctrl(X509_LOOKUP *ctx, int cmd, const char *argp, long argl,
100 case X509_L_FILE_LOAD: 100 case X509_L_FILE_LOAD:
101 if (argl == X509_FILETYPE_DEFAULT) 101 if (argl == X509_FILETYPE_DEFAULT)
102 { 102 {
103 ok = (X509_load_cert_crl_file(ctx,X509_get_default_cert_file(), 103 file = (char *)Getenv(X509_get_default_cert_file_env());
104 X509_FILETYPE_PEM) != 0); 104 if (file)
105 ok = (X509_load_cert_crl_file(ctx,file,
106 X509_FILETYPE_PEM) != 0);
107
108 else
109 ok = (X509_load_cert_crl_file(ctx,X509_get_default_cert_file(),
110 X509_FILETYPE_PEM) != 0);
111
105 if (!ok) 112 if (!ok)
106 { 113 {
107 X509err(X509_F_BY_FILE_CTRL,X509_R_LOADING_DEFAULTS); 114 X509err(X509_F_BY_FILE_CTRL,X509_R_LOADING_DEFAULTS);
108 } 115 }
109 else
110 {
111 file=(char *)Getenv(X509_get_default_cert_file_env());
112 ok = (X509_load_cert_crl_file(ctx,file,
113 X509_FILETYPE_PEM) != 0);
114 }
115 } 116 }
116 else 117 else
117 { 118 {
@@ -284,7 +285,8 @@ int X509_load_cert_crl_file(X509_LOOKUP *ctx, const char *file, int type)
284 if(itmp->x509) { 285 if(itmp->x509) {
285 X509_STORE_add_cert(ctx->store_ctx, itmp->x509); 286 X509_STORE_add_cert(ctx->store_ctx, itmp->x509);
286 count++; 287 count++;
287 } else if(itmp->crl) { 288 }
289 if(itmp->crl) {
288 X509_STORE_add_crl(ctx->store_ctx, itmp->crl); 290 X509_STORE_add_crl(ctx->store_ctx, itmp->crl);
289 count++; 291 count++;
290 } 292 }
diff --git a/src/lib/libcrypto/x509/x509.h b/src/lib/libcrypto/x509/x509.h
index 7095440d36..eaad5685a8 100644
--- a/src/lib/libcrypto/x509/x509.h
+++ b/src/lib/libcrypto/x509/x509.h
@@ -87,7 +87,6 @@
87#ifndef OPENSSL_NO_SHA 87#ifndef OPENSSL_NO_SHA
88#include <openssl/sha.h> 88#include <openssl/sha.h>
89#endif 89#endif
90#include <openssl/evp.h>
91#include <openssl/e_os2.h> 90#include <openssl/e_os2.h>
92#include <openssl/ossl_typ.h> 91#include <openssl/ossl_typ.h>
93 92
@@ -487,10 +486,12 @@ typedef struct Netscape_certificate_sequence
487 STACK_OF(X509) *certs; 486 STACK_OF(X509) *certs;
488 } NETSCAPE_CERT_SEQUENCE; 487 } NETSCAPE_CERT_SEQUENCE;
489 488
489/* Unused (and iv length is wrong)
490typedef struct CBCParameter_st 490typedef struct CBCParameter_st
491 { 491 {
492 unsigned char iv[8]; 492 unsigned char iv[8];
493 } CBC_PARAM; 493 } CBC_PARAM;
494*/
494 495
495/* Password based encryption structure */ 496/* Password based encryption structure */
496 497
diff --git a/src/lib/libcrypto/x509/x509_cmp.c b/src/lib/libcrypto/x509/x509_cmp.c
index cd20b6d66f..f460102f49 100644
--- a/src/lib/libcrypto/x509/x509_cmp.c
+++ b/src/lib/libcrypto/x509/x509_cmp.c
@@ -57,6 +57,7 @@
57 */ 57 */
58 58
59#include <stdio.h> 59#include <stdio.h>
60#include <ctype.h>
60#include "cryptlib.h" 61#include "cryptlib.h"
61#include <openssl/asn1.h> 62#include <openssl/asn1.h>
62#include <openssl/objects.h> 63#include <openssl/objects.h>
@@ -81,13 +82,14 @@ unsigned long X509_issuer_and_serial_hash(X509 *a)
81 unsigned long ret=0; 82 unsigned long ret=0;
82 EVP_MD_CTX ctx; 83 EVP_MD_CTX ctx;
83 unsigned char md[16]; 84 unsigned char md[16];
84 char str[256]; 85 char *f;
85 86
86 EVP_MD_CTX_init(&ctx); 87 EVP_MD_CTX_init(&ctx);
87 X509_NAME_oneline(a->cert_info->issuer,str,256); 88 f=X509_NAME_oneline(a->cert_info->issuer,NULL,0);
88 ret=strlen(str); 89 ret=strlen(f);
89 EVP_DigestInit_ex(&ctx, EVP_md5(), NULL); 90 EVP_DigestInit_ex(&ctx, EVP_md5(), NULL);
90 EVP_DigestUpdate(&ctx,(unsigned char *)str,ret); 91 EVP_DigestUpdate(&ctx,(unsigned char *)f,ret);
92 OPENSSL_free(f);
91 EVP_DigestUpdate(&ctx,(unsigned char *)a->cert_info->serialNumber->data, 93 EVP_DigestUpdate(&ctx,(unsigned char *)a->cert_info->serialNumber->data,
92 (unsigned long)a->cert_info->serialNumber->length); 94 (unsigned long)a->cert_info->serialNumber->length);
93 EVP_DigestFinal_ex(&ctx,&(md[0]),NULL); 95 EVP_DigestFinal_ex(&ctx,&(md[0]),NULL);
@@ -159,6 +161,99 @@ int X509_cmp(const X509 *a, const X509 *b)
159} 161}
160#endif 162#endif
161 163
164
165/* Case insensitive string comparision */
166static int nocase_cmp(const ASN1_STRING *a, const ASN1_STRING *b)
167{
168 int i;
169
170 if (a->length != b->length)
171 return (a->length - b->length);
172
173 for (i=0; i<a->length; i++)
174 {
175 int ca, cb;
176
177 ca = tolower(a->data[i]);
178 cb = tolower(b->data[i]);
179
180 if (ca != cb)
181 return(ca-cb);
182 }
183 return 0;
184}
185
186/* Case insensitive string comparision with space normalization
187 * Space normalization - ignore leading, trailing spaces,
188 * multiple spaces between characters are replaced by single space
189 */
190static int nocase_spacenorm_cmp(const ASN1_STRING *a, const ASN1_STRING *b)
191{
192 unsigned char *pa = NULL, *pb = NULL;
193 int la, lb;
194
195 la = a->length;
196 lb = b->length;
197 pa = a->data;
198 pb = b->data;
199
200 /* skip leading spaces */
201 while (la > 0 && isspace(*pa))
202 {
203 la--;
204 pa++;
205 }
206 while (lb > 0 && isspace(*pb))
207 {
208 lb--;
209 pb++;
210 }
211
212 /* skip trailing spaces */
213 while (la > 0 && isspace(pa[la-1]))
214 la--;
215 while (lb > 0 && isspace(pb[lb-1]))
216 lb--;
217
218 /* compare strings with space normalization */
219 while (la > 0 && lb > 0)
220 {
221 int ca, cb;
222
223 /* compare character */
224 ca = tolower(*pa);
225 cb = tolower(*pb);
226 if (ca != cb)
227 return (ca - cb);
228
229 pa++; pb++;
230 la--; lb--;
231
232 if (la <= 0 || lb <= 0)
233 break;
234
235 /* is white space next character ? */
236 if (isspace(*pa) && isspace(*pb))
237 {
238 /* skip remaining white spaces */
239 while (la > 0 && isspace(*pa))
240 {
241 la--;
242 pa++;
243 }
244 while (lb > 0 && isspace(*pb))
245 {
246 lb--;
247 pb++;
248 }
249 }
250 }
251 if (la > 0 || lb > 0)
252 return la - lb;
253
254 return 0;
255}
256
162int X509_NAME_cmp(const X509_NAME *a, const X509_NAME *b) 257int X509_NAME_cmp(const X509_NAME *a, const X509_NAME *b)
163 { 258 {
164 int i,j; 259 int i,j;
@@ -172,10 +267,20 @@ int X509_NAME_cmp(const X509_NAME *a, const X509_NAME *b)
172 { 267 {
173 na=sk_X509_NAME_ENTRY_value(a->entries,i); 268 na=sk_X509_NAME_ENTRY_value(a->entries,i);
174 nb=sk_X509_NAME_ENTRY_value(b->entries,i); 269 nb=sk_X509_NAME_ENTRY_value(b->entries,i);
175 j=na->value->length-nb->value->length; 270 j=na->value->type-nb->value->type;
176 if (j) return(j); 271 if (j) return(j);
177 j=memcmp(na->value->data,nb->value->data, 272 if (na->value->type == V_ASN1_PRINTABLESTRING)
178 na->value->length); 273 j=nocase_spacenorm_cmp(na->value, nb->value);
274 else if (na->value->type == V_ASN1_IA5STRING
275 && OBJ_obj2nid(na->object) == NID_pkcs9_emailAddress)
276 j=nocase_cmp(na->value, nb->value);
277 else
278 {
279 j=na->value->length-nb->value->length;
280 if (j) return(j);
281 j=memcmp(na->value->data,nb->value->data,
282 na->value->length);
283 }
179 if (j) return(j); 284 if (j) return(j);
180 j=na->set-nb->set; 285 j=na->set-nb->set;
181 if (j) return(j); 286 if (j) return(j);
diff --git a/src/lib/libcrypto/x509/x509_v3.c b/src/lib/libcrypto/x509/x509_v3.c
index b5f7daa2e5..67b1796a92 100644
--- a/src/lib/libcrypto/x509/x509_v3.c
+++ b/src/lib/libcrypto/x509/x509_v3.c
@@ -116,7 +116,7 @@ int X509v3_get_ext_by_critical(const STACK_OF(X509_EXTENSION) *sk, int crit,
116 { 116 {
117 ex=sk_X509_EXTENSION_value(sk,lastpos); 117 ex=sk_X509_EXTENSION_value(sk,lastpos);
118 if ( ((ex->critical > 0) && crit) || 118 if ( ((ex->critical > 0) && crit) ||
119 (!(ex->critical <= 0) && !crit)) 119 ((ex->critical <= 0) && !crit))
120 return(lastpos); 120 return(lastpos);
121 } 121 }
122 return(-1); 122 return(-1);
diff --git a/src/lib/libcrypto/x509/x509_vfy.c b/src/lib/libcrypto/x509/x509_vfy.c
index db12f7bd35..552d1e7251 100644
--- a/src/lib/libcrypto/x509/x509_vfy.c
+++ b/src/lib/libcrypto/x509/x509_vfy.c
@@ -756,7 +756,7 @@ int X509_cmp_time(ASN1_TIME *ctm, time_t *cmp_time)
756 { 756 {
757 char *str; 757 char *str;
758 ASN1_TIME atm; 758 ASN1_TIME atm;
759 time_t offset; 759 long offset;
760 char buff1[24],buff2[24],*p; 760 char buff1[24],buff2[24],*p;
761 int i,j; 761 int i,j;
762 762
diff --git a/src/lib/libcrypto/x509v3/Makefile.ssl b/src/lib/libcrypto/x509v3/Makefile.ssl
index 3534e8b236..66df90c346 100644
--- a/src/lib/libcrypto/x509v3/Makefile.ssl
+++ b/src/lib/libcrypto/x509v3/Makefile.ssl
@@ -74,7 +74,7 @@ lint:
74 lint -DLINT $(INCLUDES) $(SRC)>fluff 74 lint -DLINT $(INCLUDES) $(SRC)>fluff
75 75
76depend: 76depend:
77 $(MAKEDEPEND) $(CFLAG) $(INCLUDES) $(DEPFLAG) $(PROGS) $(LIBSRC) 77 $(MAKEDEPEND) -- $(CFLAG) $(INCLUDES) $(DEPFLAG) -- $(PROGS) $(LIBSRC)
78 78
79dclean: 79dclean:
80 $(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new 80 $(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
diff --git a/src/lib/libcrypto/x509v3/ext_dat.h b/src/lib/libcrypto/x509v3/ext_dat.h
index 2fb97d8925..5442480595 100644
--- a/src/lib/libcrypto/x509v3/ext_dat.h
+++ b/src/lib/libcrypto/x509v3/ext_dat.h
@@ -90,17 +90,23 @@ static X509V3_EXT_METHOD *standard_exts[] = {
90&v3_crld, 90&v3_crld,
91&v3_ext_ku, 91&v3_ext_ku,
92&v3_crl_reason, 92&v3_crl_reason,
93#ifndef OPENSSL_NO_OCSP
93&v3_crl_invdate, 94&v3_crl_invdate,
95#endif
94&v3_sxnet, 96&v3_sxnet,
95&v3_info, 97&v3_info,
98#ifndef OPENSSL_NO_OCSP
96&v3_ocsp_nonce, 99&v3_ocsp_nonce,
97&v3_ocsp_crlid, 100&v3_ocsp_crlid,
98&v3_ocsp_accresp, 101&v3_ocsp_accresp,
99&v3_ocsp_nocheck, 102&v3_ocsp_nocheck,
100&v3_ocsp_acutoff, 103&v3_ocsp_acutoff,
101&v3_ocsp_serviceloc, 104&v3_ocsp_serviceloc,
105#endif
102&v3_sinfo, 106&v3_sinfo,
107#ifndef OPENSSL_NO_OCSP
103&v3_crl_hold 108&v3_crl_hold
109#endif
104}; 110};
105 111
106/* Number of standard extensions */ 112/* Number of standard extensions */
diff --git a/src/lib/libcrypto/x509v3/v3_info.c b/src/lib/libcrypto/x509v3/v3_info.c
index 92b9316b02..28cc00686a 100644
--- a/src/lib/libcrypto/x509v3/v3_info.c
+++ b/src/lib/libcrypto/x509v3/v3_info.c
@@ -113,8 +113,8 @@ static STACK_OF(CONF_VALUE) *i2v_AUTHORITY_INFO_ACCESS(X509V3_EXT_METHOD *method
113 ret = i2v_GENERAL_NAME(method, desc->location, ret); 113 ret = i2v_GENERAL_NAME(method, desc->location, ret);
114 if(!ret) break; 114 if(!ret) break;
115 vtmp = sk_CONF_VALUE_value(ret, i); 115 vtmp = sk_CONF_VALUE_value(ret, i);
116 i2t_ASN1_OBJECT(objtmp, 80, desc->method); 116 i2t_ASN1_OBJECT(objtmp, sizeof objtmp, desc->method);
117 nlen = strlen(objtmp) + strlen(vtmp->name) + 4; 117 nlen = strlen(objtmp) + strlen(vtmp->name) + 5;
118 ntmp = OPENSSL_malloc(nlen); 118 ntmp = OPENSSL_malloc(nlen);
119 if(!ntmp) { 119 if(!ntmp) {
120 X509V3err(X509V3_F_I2V_AUTHORITY_INFO_ACCESS, 120 X509V3err(X509V3_F_I2V_AUTHORITY_INFO_ACCESS,
diff --git a/src/lib/libcrypto/x509v3/v3_ocsp.c b/src/lib/libcrypto/x509v3/v3_ocsp.c
index 083112314e..21badc13f9 100644
--- a/src/lib/libcrypto/x509v3/v3_ocsp.c
+++ b/src/lib/libcrypto/x509v3/v3_ocsp.c
@@ -56,6 +56,8 @@
56 * 56 *
57 */ 57 */
58 58
59#ifndef OPENSSL_NO_OCSP
60
59#include <stdio.h> 61#include <stdio.h>
60#include "cryptlib.h" 62#include "cryptlib.h"
61#include <openssl/conf.h> 63#include <openssl/conf.h>
@@ -270,3 +272,4 @@ static int i2r_ocsp_serviceloc(X509V3_EXT_METHOD *method, void *in, BIO *bp, int
270err: 272err:
271 return 0; 273 return 0;
272 } 274 }
275#endif
diff --git a/src/lib/libcrypto/x509v3/v3_prn.c b/src/lib/libcrypto/x509v3/v3_prn.c
index aeaf6170fe..754808b625 100644
--- a/src/lib/libcrypto/x509v3/v3_prn.c
+++ b/src/lib/libcrypto/x509v3/v3_prn.c
@@ -178,7 +178,7 @@ int X509V3_extensions_print(BIO *bp, char *title, STACK_OF(X509_EXTENSION) *exts
178 ASN1_OBJECT *obj; 178 ASN1_OBJECT *obj;
179 X509_EXTENSION *ex; 179 X509_EXTENSION *ex;
180 ex=sk_X509_EXTENSION_value(exts, i); 180 ex=sk_X509_EXTENSION_value(exts, i);
181 if (BIO_printf(bp,"%*s",indent, "") <= 0) return 0; 181 if (indent && BIO_printf(bp,"%*s",indent, "") <= 0) return 0;
182 obj=X509_EXTENSION_get_object(ex); 182 obj=X509_EXTENSION_get_object(ex);
183 i2a_ASN1_OBJECT(bp,obj); 183 i2a_ASN1_OBJECT(bp,obj);
184 j=X509_EXTENSION_get_critical(ex); 184 j=X509_EXTENSION_get_critical(ex);
diff --git a/src/lib/libcrypto/x509v3/v3_purp.c b/src/lib/libcrypto/x509v3/v3_purp.c
index b739e4fd83..4d145f71fd 100644
--- a/src/lib/libcrypto/x509v3/v3_purp.c
+++ b/src/lib/libcrypto/x509v3/v3_purp.c
@@ -378,6 +378,10 @@ static void x509v3_cache_extensions(X509 *x)
378 case NID_time_stamp: 378 case NID_time_stamp:
379 x->ex_xkusage |= XKU_TIMESTAMP; 379 x->ex_xkusage |= XKU_TIMESTAMP;
380 break; 380 break;
381
382 case NID_dvcs:
383 x->ex_xkusage |= XKU_DVCS;
384 break;
381 } 385 }
382 } 386 }
383 sk_ASN1_OBJECT_pop_free(extusage, ASN1_OBJECT_free); 387 sk_ASN1_OBJECT_pop_free(extusage, ASN1_OBJECT_free);
diff --git a/src/lib/libcrypto/x509v3/v3_utl.c b/src/lib/libcrypto/x509v3/v3_utl.c
index 283e943e46..34ac2998de 100644
--- a/src/lib/libcrypto/x509v3/v3_utl.c
+++ b/src/lib/libcrypto/x509v3/v3_utl.c
@@ -491,7 +491,7 @@ static STACK *get_email(X509_NAME *name, GENERAL_NAMES *gens)
491 i = -1; 491 i = -1;
492 /* First supplied X509_NAME */ 492 /* First supplied X509_NAME */
493 while((i = X509_NAME_get_index_by_NID(name, 493 while((i = X509_NAME_get_index_by_NID(name,
494 NID_pkcs9_emailAddress, i)) > 0) { 494 NID_pkcs9_emailAddress, i)) >= 0) {
495 ne = X509_NAME_get_entry(name, i); 495 ne = X509_NAME_get_entry(name, i);
496 email = X509_NAME_ENTRY_get_data(ne); 496 email = X509_NAME_ENTRY_get_data(ne);
497 if(!append_ia5(&ret, email)) return NULL; 497 if(!append_ia5(&ret, email)) return NULL;
diff --git a/src/lib/libcrypto/x509v3/v3conf.c b/src/lib/libcrypto/x509v3/v3conf.c
index 67ee14f334..00cf5b4a5b 100644
--- a/src/lib/libcrypto/x509v3/v3conf.c
+++ b/src/lib/libcrypto/x509v3/v3conf.c
@@ -118,7 +118,7 @@ int main(int argc, char **argv)
118 printf("%s", OBJ_nid2ln(OBJ_obj2nid(ext->object))); 118 printf("%s", OBJ_nid2ln(OBJ_obj2nid(ext->object)));
119 if(ext->critical) printf(",critical:\n"); 119 if(ext->critical) printf(",critical:\n");
120 else printf(":\n"); 120 else printf(":\n");
121 X509V3_EXT_print_fp(stdout, ext, 0); 121 X509V3_EXT_print_fp(stdout, ext, 0, 0);
122 printf("\n"); 122 printf("\n");
123 123
124 } 124 }
diff --git a/src/lib/libcrypto/x509v3/x509v3.h b/src/lib/libcrypto/x509v3/x509v3.h
index daecc55271..fb07a19016 100644
--- a/src/lib/libcrypto/x509v3/x509v3.h
+++ b/src/lib/libcrypto/x509v3/x509v3.h
@@ -352,6 +352,7 @@ DECLARE_ASN1_SET_OF(POLICYINFO)
352#define XKU_SGC 0x10 352#define XKU_SGC 0x10
353#define XKU_OCSP_SIGN 0x20 353#define XKU_OCSP_SIGN 0x20
354#define XKU_TIMESTAMP 0x40 354#define XKU_TIMESTAMP 0x40
355#define XKU_DVCS 0x80
355 356
356#define X509_PURPOSE_DYNAMIC 0x1 357#define X509_PURPOSE_DYNAMIC 0x1
357#define X509_PURPOSE_DYNAMIC_NAME 0x2 358#define X509_PURPOSE_DYNAMIC_NAME 0x2