summaryrefslogtreecommitdiff
path: root/src/lib/libssl/src
diff options
context:
space:
mode:
authormarkus <>2003-05-11 21:36:59 +0000
committermarkus <>2003-05-11 21:36:59 +0000
commit9cea7b85baecb1a02a3ea617de73d9693a9792eb (patch)
treeb0ca83a03e35572831c5818cd2011868d462a5d1 /src/lib/libssl/src
parentf8f1d7fabf136ce9810602509c477d2c42bf6d1c (diff)
downloadopenbsd-9cea7b85baecb1a02a3ea617de73d9693a9792eb.tar.gz
openbsd-9cea7b85baecb1a02a3ea617de73d9693a9792eb.tar.bz2
openbsd-9cea7b85baecb1a02a3ea617de73d9693a9792eb.zip
import 0.9.7b (without idea and rc5)
Diffstat (limited to 'src/lib/libssl/src')
-rw-r--r--src/lib/libssl/src/CHANGES354
-rw-r--r--src/lib/libssl/src/Configure199
-rw-r--r--src/lib/libssl/src/FAQ107
-rw-r--r--src/lib/libssl/src/INSTALL42
-rw-r--r--src/lib/libssl/src/INSTALL.DJGPP14
-rw-r--r--src/lib/libssl/src/INSTALL.W32130
-rw-r--r--src/lib/libssl/src/INSTALL.WCE71
-rw-r--r--src/lib/libssl/src/LICENSE2
-rw-r--r--src/lib/libssl/src/MacOS/GetHTTPS.src/MacSocket.cpp4
-rw-r--r--src/lib/libssl/src/MacOS/GetHTTPS.src/MacSocket.h2
-rw-r--r--src/lib/libssl/src/Makefile.org218
-rw-r--r--src/lib/libssl/src/NEWS58
-rw-r--r--src/lib/libssl/src/PROBLEMS83
-rw-r--r--src/lib/libssl/src/README4
-rw-r--r--src/lib/libssl/src/apps/CA.pl2
-rw-r--r--src/lib/libssl/src/apps/apps.c104
-rw-r--r--src/lib/libssl/src/apps/apps.h78
-rw-r--r--src/lib/libssl/src/apps/asn1pars.c2
-rw-r--r--src/lib/libssl/src/apps/ca.c140
-rw-r--r--src/lib/libssl/src/apps/ciphers.c4
-rw-r--r--src/lib/libssl/src/apps/crl.c3
-rw-r--r--src/lib/libssl/src/apps/crl2p7.c2
-rw-r--r--src/lib/libssl/src/apps/dgst.c14
-rw-r--r--src/lib/libssl/src/apps/dh.c17
-rw-r--r--src/lib/libssl/src/apps/dhparam.c15
-rw-r--r--src/lib/libssl/src/apps/dsa.c17
-rw-r--r--src/lib/libssl/src/apps/dsaparam.c12
-rw-r--r--src/lib/libssl/src/apps/enc.c32
-rw-r--r--src/lib/libssl/src/apps/engine.c11
-rw-r--r--src/lib/libssl/src/apps/errstr.c2
-rw-r--r--src/lib/libssl/src/apps/gendh.c12
-rw-r--r--src/lib/libssl/src/apps/gendsa.c12
-rw-r--r--src/lib/libssl/src/apps/genrsa.c12
-rw-r--r--src/lib/libssl/src/apps/makeapps.com294
-rw-r--r--src/lib/libssl/src/apps/nseq.c4
-rw-r--r--src/lib/libssl/src/apps/ocsp.c35
-rw-r--r--src/lib/libssl/src/apps/openssl.c32
-rw-r--r--src/lib/libssl/src/apps/passwd.c5
-rw-r--r--src/lib/libssl/src/apps/pkcs12.c16
-rw-r--r--src/lib/libssl/src/apps/pkcs7.c12
-rw-r--r--src/lib/libssl/src/apps/pkcs8.c14
-rw-r--r--src/lib/libssl/src/apps/progs.h6
-rw-r--r--src/lib/libssl/src/apps/rand.c12
-rw-r--r--src/lib/libssl/src/apps/req.c57
-rw-r--r--src/lib/libssl/src/apps/rsa.c10
-rw-r--r--src/lib/libssl/src/apps/rsautl.c8
-rw-r--r--src/lib/libssl/src/apps/s_cb.c4
-rw-r--r--src/lib/libssl/src/apps/s_client.c46
-rw-r--r--src/lib/libssl/src/apps/s_server.c32
-rw-r--r--src/lib/libssl/src/apps/s_socket.c39
-rw-r--r--src/lib/libssl/src/apps/s_time.c21
-rw-r--r--src/lib/libssl/src/apps/sess_id.c2
-rw-r--r--src/lib/libssl/src/apps/smime.c8
-rw-r--r--src/lib/libssl/src/apps/speed.c19
-rw-r--r--src/lib/libssl/src/apps/spkac.c10
-rw-r--r--src/lib/libssl/src/apps/verify.c17
-rw-r--r--src/lib/libssl/src/apps/version.c2
-rw-r--r--src/lib/libssl/src/apps/winrand.c1
-rw-r--r--src/lib/libssl/src/apps/x509.c27
-rw-r--r--src/lib/libssl/src/config87
-rw-r--r--src/lib/libssl/src/crypto/aes/aes.h9
-rw-r--r--src/lib/libssl/src/crypto/aes/aes_cbc.c58
-rw-r--r--src/lib/libssl/src/crypto/aes/aes_cfb.c6
-rw-r--r--src/lib/libssl/src/crypto/aes/aes_core.c12
-rw-r--r--src/lib/libssl/src/crypto/aes/aes_ctr.c21
-rw-r--r--src/lib/libssl/src/crypto/aes/aes_ecb.c6
-rw-r--r--src/lib/libssl/src/crypto/aes/aes_locl.h2
-rw-r--r--src/lib/libssl/src/crypto/aes/aes_ofb.c6
-rw-r--r--src/lib/libssl/src/crypto/asn1/a_bitstr.c4
-rw-r--r--src/lib/libssl/src/crypto/asn1/a_bytes.c2
-rw-r--r--src/lib/libssl/src/crypto/asn1/a_d2i_fp.c24
-rw-r--r--src/lib/libssl/src/crypto/asn1/a_object.c4
-rw-r--r--src/lib/libssl/src/crypto/asn1/a_sign.c8
-rw-r--r--src/lib/libssl/src/crypto/asn1/a_strex.c14
-rw-r--r--src/lib/libssl/src/crypto/asn1/a_strnid.c35
-rw-r--r--src/lib/libssl/src/crypto/asn1/a_time.c5
-rw-r--r--src/lib/libssl/src/crypto/asn1/a_type.c2
-rw-r--r--src/lib/libssl/src/crypto/asn1/a_verify.c4
-rw-r--r--src/lib/libssl/src/crypto/asn1/asn1.h5
-rw-r--r--src/lib/libssl/src/crypto/asn1/asn1_err.c4
-rw-r--r--src/lib/libssl/src/crypto/asn1/asn1_par.c7
-rw-r--r--src/lib/libssl/src/crypto/asn1/f_int.c3
-rw-r--r--src/lib/libssl/src/crypto/asn1/n_pkey.c6
-rw-r--r--src/lib/libssl/src/crypto/asn1/p8_pkey.c4
-rw-r--r--src/lib/libssl/src/crypto/asn1/t_crl.c7
-rw-r--r--src/lib/libssl/src/crypto/asn1/t_pkey.c32
-rw-r--r--src/lib/libssl/src/crypto/asn1/t_req.c18
-rw-r--r--src/lib/libssl/src/crypto/asn1/t_x509.c9
-rw-r--r--src/lib/libssl/src/crypto/asn1/t_x509a.c4
-rw-r--r--src/lib/libssl/src/crypto/asn1/tasn_dec.c4
-rw-r--r--src/lib/libssl/src/crypto/asn1/tasn_fre.c5
-rw-r--r--src/lib/libssl/src/crypto/asn1/tasn_new.c5
-rw-r--r--src/lib/libssl/src/crypto/asn1/tasn_prn.c2
-rw-r--r--src/lib/libssl/src/crypto/bf/bftest.c10
-rw-r--r--src/lib/libssl/src/crypto/bio/b_print.c29
-rw-r--r--src/lib/libssl/src/crypto/bio/b_sock.c16
-rw-r--r--src/lib/libssl/src/crypto/bio/bf_buff.c2
-rw-r--r--src/lib/libssl/src/crypto/bio/bio.h7
-rw-r--r--src/lib/libssl/src/crypto/bio/bio_lib.c15
-rw-r--r--src/lib/libssl/src/crypto/bio/bss_bio.c3
-rw-r--r--src/lib/libssl/src/crypto/bio/bss_conn.c4
-rw-r--r--src/lib/libssl/src/crypto/bio/bss_file.c2
-rw-r--r--src/lib/libssl/src/crypto/bio/bss_log.c13
-rw-r--r--src/lib/libssl/src/crypto/bio/bss_mem.c8
-rw-r--r--src/lib/libssl/src/crypto/bio/bss_sock.c6
-rw-r--r--src/lib/libssl/src/crypto/bn/asm/ia64.S235
-rw-r--r--src/lib/libssl/src/crypto/bn/asm/pa-risc2.s36
-rw-r--r--src/lib/libssl/src/crypto/bn/asm/vms.mar254
-rw-r--r--src/lib/libssl/src/crypto/bn/asm/x86_64-gcc.c575
-rw-r--r--src/lib/libssl/src/crypto/bn/bn.h2
-rw-r--r--src/lib/libssl/src/crypto/bn/bn_div.c28
-rw-r--r--src/lib/libssl/src/crypto/bn/bn_lcl.h26
-rw-r--r--src/lib/libssl/src/crypto/bn/bn_lib.c4
-rw-r--r--src/lib/libssl/src/crypto/bn/bn_mul.c529
-rw-r--r--src/lib/libssl/src/crypto/bn/bn_prime.c2
-rw-r--r--src/lib/libssl/src/crypto/bn/bn_rand.c2
-rw-r--r--src/lib/libssl/src/crypto/bn/bn_word.c5
-rw-r--r--src/lib/libssl/src/crypto/bn/bntest.c23
-rw-r--r--src/lib/libssl/src/crypto/bn/divtest.c6
-rw-r--r--src/lib/libssl/src/crypto/bn/exptest.c22
-rw-r--r--src/lib/libssl/src/crypto/buffer/buffer.c57
-rw-r--r--src/lib/libssl/src/crypto/buffer/buffer.h9
-rw-r--r--src/lib/libssl/src/crypto/cast/casttest.c4
-rw-r--r--src/lib/libssl/src/crypto/comp/c_zlib.c4
-rw-r--r--src/lib/libssl/src/crypto/conf/conf_def.c18
-rw-r--r--src/lib/libssl/src/crypto/conf/conf_mall.c4
-rw-r--r--src/lib/libssl/src/crypto/conf/conf_sap.c4
-rw-r--r--src/lib/libssl/src/crypto/cryptlib.c40
-rw-r--r--src/lib/libssl/src/crypto/cryptlib.h6
-rw-r--r--src/lib/libssl/src/crypto/crypto-lib.com344
-rw-r--r--src/lib/libssl/src/crypto/crypto.h65
-rw-r--r--src/lib/libssl/src/crypto/des/FILES096
-rw-r--r--src/lib/libssl/src/crypto/des/asm/crypt586.pl46
-rw-r--r--src/lib/libssl/src/crypto/des/asm/des-586.pl50
-rw-r--r--src/lib/libssl/src/crypto/des/cbc_cksm.c9
-rw-r--r--src/lib/libssl/src/crypto/des/des.c32
-rw-r--r--src/lib/libssl/src/crypto/des/des.h4
-rw-r--r--src/lib/libssl/src/crypto/des/des_locl.h13
-rw-r--r--src/lib/libssl/src/crypto/des/des_old.h10
-rw-r--r--src/lib/libssl/src/crypto/des/destest.c6
-rw-r--r--src/lib/libssl/src/crypto/des/read2pwd.c8
-rw-r--r--src/lib/libssl/src/crypto/des/read_pwd.c44
-rw-r--r--src/lib/libssl/src/crypto/des/str2key.c4
-rw-r--r--src/lib/libssl/src/crypto/dh/dh_key.c1
-rw-r--r--src/lib/libssl/src/crypto/dh/dh_lib.c10
-rw-r--r--src/lib/libssl/src/crypto/dh/dhtest.c14
-rw-r--r--src/lib/libssl/src/crypto/dsa/dsa_lib.c15
-rw-r--r--src/lib/libssl/src/crypto/dsa/dsa_ossl.c14
-rw-r--r--src/lib/libssl/src/crypto/dsa/dsa_sign.c1
-rw-r--r--src/lib/libssl/src/crypto/dsa/dsa_vrf.c1
-rw-r--r--src/lib/libssl/src/crypto/dsa/dsagen.c2
-rw-r--r--src/lib/libssl/src/crypto/dsa/dsatest.c17
-rw-r--r--src/lib/libssl/src/crypto/dso/dso_dl.c2
-rw-r--r--src/lib/libssl/src/crypto/dso/dso_win32.c2
-rw-r--r--src/lib/libssl/src/crypto/ec/ec.h2
-rw-r--r--src/lib/libssl/src/crypto/ec/ec_err.c2
-rw-r--r--src/lib/libssl/src/crypto/ec/ec_lib.c8
-rw-r--r--src/lib/libssl/src/crypto/ec/ec_mult.c11
-rw-r--r--src/lib/libssl/src/crypto/ec/ectest.c11
-rw-r--r--src/lib/libssl/src/crypto/engine/eng_all.c15
-rw-r--r--src/lib/libssl/src/crypto/engine/eng_err.c3
-rw-r--r--src/lib/libssl/src/crypto/engine/eng_fat.c8
-rw-r--r--src/lib/libssl/src/crypto/engine/eng_init.c2
-rw-r--r--src/lib/libssl/src/crypto/engine/eng_list.c33
-rw-r--r--src/lib/libssl/src/crypto/engine/eng_openssl.c18
-rw-r--r--src/lib/libssl/src/crypto/engine/engine.h10
-rw-r--r--src/lib/libssl/src/crypto/engine/enginetest.c11
-rw-r--r--src/lib/libssl/src/crypto/engine/hw_4758_cca.c6
-rw-r--r--src/lib/libssl/src/crypto/engine/hw_atalla.c2
-rw-r--r--src/lib/libssl/src/crypto/engine/hw_cryptodev.c540
-rw-r--r--src/lib/libssl/src/crypto/engine/hw_cswift.c73
-rw-r--r--src/lib/libssl/src/crypto/engine/hw_ncipher.c68
-rw-r--r--src/lib/libssl/src/crypto/engine/hw_ncipher_err.c3
-rw-r--r--src/lib/libssl/src/crypto/engine/hw_ncipher_err.h1
-rw-r--r--src/lib/libssl/src/crypto/engine/hw_nuron.c2
-rw-r--r--src/lib/libssl/src/crypto/engine/hw_sureware.c1039
-rw-r--r--src/lib/libssl/src/crypto/engine/hw_ubsec.c2
-rw-r--r--src/lib/libssl/src/crypto/engine/tb_cipher.c4
-rw-r--r--src/lib/libssl/src/crypto/engine/tb_dh.c4
-rw-r--r--src/lib/libssl/src/crypto/engine/tb_digest.c4
-rw-r--r--src/lib/libssl/src/crypto/engine/tb_dsa.c4
-rw-r--r--src/lib/libssl/src/crypto/engine/tb_rand.c4
-rw-r--r--src/lib/libssl/src/crypto/engine/tb_rsa.c4
-rw-r--r--src/lib/libssl/src/crypto/engine/vendor_defns/hw_ubsec.h100
-rw-r--r--src/lib/libssl/src/crypto/engine/vendor_defns/hwcryptohook.h486
-rw-r--r--src/lib/libssl/src/crypto/engine/vendor_defns/sureware.h239
-rw-r--r--src/lib/libssl/src/crypto/err/err.c2
-rw-r--r--src/lib/libssl/src/crypto/err/err_all.c4
-rw-r--r--src/lib/libssl/src/crypto/err/err_prn.c1
-rw-r--r--src/lib/libssl/src/crypto/evp/bio_b64.c1
-rw-r--r--src/lib/libssl/src/crypto/evp/bio_enc.c9
-rw-r--r--src/lib/libssl/src/crypto/evp/bio_ok.c2
-rw-r--r--src/lib/libssl/src/crypto/evp/c_all.c5
-rw-r--r--src/lib/libssl/src/crypto/evp/digest.c17
-rw-r--r--src/lib/libssl/src/crypto/evp/e_aes.c1
-rw-r--r--src/lib/libssl/src/crypto/evp/e_idea.c2
-rw-r--r--src/lib/libssl/src/crypto/evp/e_rc2.c1
-rw-r--r--src/lib/libssl/src/crypto/evp/e_rc4.c5
-rw-r--r--src/lib/libssl/src/crypto/evp/encode.c2
-rw-r--r--src/lib/libssl/src/crypto/evp/evp_acnf.c1
-rw-r--r--src/lib/libssl/src/crypto/evp/evp_enc.c30
-rw-r--r--src/lib/libssl/src/crypto/evp/evp_key.c6
-rw-r--r--src/lib/libssl/src/crypto/evp/evp_lib.c2
-rw-r--r--src/lib/libssl/src/crypto/evp/evp_pbe.c2
-rw-r--r--src/lib/libssl/src/crypto/evp/evp_test.c58
-rw-r--r--src/lib/libssl/src/crypto/evp/p5_crpt.c8
-rw-r--r--src/lib/libssl/src/crypto/evp/p5_crpt2.c3
-rw-r--r--src/lib/libssl/src/crypto/evp/p_open.c2
-rw-r--r--src/lib/libssl/src/crypto/hmac/hmac.c3
-rw-r--r--src/lib/libssl/src/crypto/hmac/hmactest.c21
-rw-r--r--src/lib/libssl/src/crypto/idea/version12
-rw-r--r--src/lib/libssl/src/crypto/lhash/lh_stats.c86
-rw-r--r--src/lib/libssl/src/crypto/md2/md2_dgst.c9
-rw-r--r--src/lib/libssl/src/crypto/md2/md2_one.c2
-rw-r--r--src/lib/libssl/src/crypto/md2/md2test.c5
-rw-r--r--src/lib/libssl/src/crypto/md32_common.h38
-rw-r--r--src/lib/libssl/src/crypto/md4/md4.c4
-rw-r--r--src/lib/libssl/src/crypto/md4/md4_dgst.c36
-rw-r--r--src/lib/libssl/src/crypto/md4/md4_one.c3
-rw-r--r--src/lib/libssl/src/crypto/md4/md4test.c4
-rw-r--r--src/lib/libssl/src/crypto/md5/md5.c2
-rw-r--r--src/lib/libssl/src/crypto/md5/md5.h4
-rw-r--r--src/lib/libssl/src/crypto/md5/md5_dgst.c36
-rw-r--r--src/lib/libssl/src/crypto/md5/md5_locl.h2
-rw-r--r--src/lib/libssl/src/crypto/md5/md5_one.c3
-rw-r--r--src/lib/libssl/src/crypto/md5/md5test.c4
-rw-r--r--src/lib/libssl/src/crypto/mdc2/mdc2test.c146
-rw-r--r--src/lib/libssl/src/crypto/mem.c47
-rw-r--r--src/lib/libssl/src/crypto/mem_clr.c75
-rw-r--r--src/lib/libssl/src/crypto/mem_dbg.c24
-rw-r--r--src/lib/libssl/src/crypto/o_time.c3
-rw-r--r--src/lib/libssl/src/crypto/objects/obj_dat.c7
-rw-r--r--src/lib/libssl/src/crypto/objects/obj_dat.h29
-rw-r--r--src/lib/libssl/src/crypto/objects/obj_mac.h12
-rw-r--r--src/lib/libssl/src/crypto/objects/obj_mac.num2
-rw-r--r--src/lib/libssl/src/crypto/objects/objects.txt6
-rw-r--r--src/lib/libssl/src/crypto/ocsp/ocsp_asn.c2
-rw-r--r--src/lib/libssl/src/crypto/ocsp/ocsp_ht.c19
-rw-r--r--src/lib/libssl/src/crypto/opensslconf.h2
-rw-r--r--src/lib/libssl/src/crypto/opensslconf.h.in2
-rw-r--r--src/lib/libssl/src/crypto/opensslv.h4
-rw-r--r--src/lib/libssl/src/crypto/ossl_typ.h2
-rw-r--r--src/lib/libssl/src/crypto/pem/pem.h8
-rw-r--r--src/lib/libssl/src/crypto/pem/pem_info.c5
-rw-r--r--src/lib/libssl/src/crypto/pem/pem_lib.c26
-rw-r--r--src/lib/libssl/src/crypto/pem/pem_pk8.c2
-rw-r--r--src/lib/libssl/src/crypto/pem/pem_seal.c2
-rw-r--r--src/lib/libssl/src/crypto/perlasm/cbc.pl41
-rw-r--r--src/lib/libssl/src/crypto/perlasm/x86asm.pl9
-rw-r--r--src/lib/libssl/src/crypto/perlasm/x86ms.pl15
-rw-r--r--src/lib/libssl/src/crypto/perlasm/x86nasm.pl15
-rw-r--r--src/lib/libssl/src/crypto/perlasm/x86unix.pl53
-rw-r--r--src/lib/libssl/src/crypto/pkcs12/p12_crpt.c4
-rw-r--r--src/lib/libssl/src/crypto/pkcs12/p12_decr.c4
-rw-r--r--src/lib/libssl/src/crypto/pkcs12/p12_key.c2
-rw-r--r--src/lib/libssl/src/crypto/pkcs12/p12_npas.c2
-rw-r--r--src/lib/libssl/src/crypto/pkcs7/bio_ber.c2
-rw-r--r--src/lib/libssl/src/crypto/pkcs7/pk7_doit.c6
-rw-r--r--src/lib/libssl/src/crypto/rand/md_rand.c4
-rw-r--r--src/lib/libssl/src/crypto/rand/rand.h2
-rw-r--r--src/lib/libssl/src/crypto/rand/rand_egd.c6
-rw-r--r--src/lib/libssl/src/crypto/rand/rand_lib.c10
-rw-r--r--src/lib/libssl/src/crypto/rand/rand_unix.c11
-rw-r--r--src/lib/libssl/src/crypto/rand/rand_win.c84
-rw-r--r--src/lib/libssl/src/crypto/rand/randfile.c9
-rw-r--r--src/lib/libssl/src/crypto/rand/randtest.c4
-rw-r--r--src/lib/libssl/src/crypto/rc2/rc2test.c4
-rw-r--r--src/lib/libssl/src/crypto/rc4/rc4.c4
-rw-r--r--src/lib/libssl/src/crypto/rc4/rc4test.c4
-rw-r--r--src/lib/libssl/src/crypto/rc5/rc5s.cpp70
-rw-r--r--src/lib/libssl/src/crypto/ripemd/rmd160.c2
-rw-r--r--src/lib/libssl/src/crypto/ripemd/rmd_dgst.c12
-rw-r--r--src/lib/libssl/src/crypto/ripemd/rmd_one.c3
-rw-r--r--src/lib/libssl/src/crypto/ripemd/rmdtest.c4
-rw-r--r--src/lib/libssl/src/crypto/rsa/rsa.h9
-rw-r--r--src/lib/libssl/src/crypto/rsa/rsa_eay.c150
-rw-r--r--src/lib/libssl/src/crypto/rsa/rsa_lib.c43
-rw-r--r--src/lib/libssl/src/crypto/rsa/rsa_pk1.c2
-rw-r--r--src/lib/libssl/src/crypto/rsa/rsa_saos.c6
-rw-r--r--src/lib/libssl/src/crypto/rsa/rsa_sign.c25
-rw-r--r--src/lib/libssl/src/crypto/rsa/rsa_test.c1
-rw-r--r--src/lib/libssl/src/crypto/sha/sha1_one.c3
-rw-r--r--src/lib/libssl/src/crypto/sha/sha1test.c4
-rw-r--r--src/lib/libssl/src/crypto/sha/sha_locl.h12
-rw-r--r--src/lib/libssl/src/crypto/sha/sha_one.c3
-rw-r--r--src/lib/libssl/src/crypto/sha/shatest.c4
-rw-r--r--src/lib/libssl/src/crypto/threads/mttest.c5
-rw-r--r--src/lib/libssl/src/crypto/tmdiff.c32
-rw-r--r--src/lib/libssl/src/crypto/txt_db/txt_db.c4
-rw-r--r--src/lib/libssl/src/crypto/ui/ui_lib.c10
-rw-r--r--src/lib/libssl/src/crypto/ui/ui_openssl.c28
-rw-r--r--src/lib/libssl/src/crypto/ui/ui_util.c8
-rw-r--r--src/lib/libssl/src/crypto/uid.c2
-rw-r--r--src/lib/libssl/src/crypto/x509/by_file.c20
-rw-r--r--src/lib/libssl/src/crypto/x509/x509.h3
-rw-r--r--src/lib/libssl/src/crypto/x509/x509_cmp.c119
-rw-r--r--src/lib/libssl/src/crypto/x509/x509_v3.c2
-rw-r--r--src/lib/libssl/src/crypto/x509/x509_vfy.c2
-rw-r--r--src/lib/libssl/src/crypto/x509v3/ext_dat.h6
-rw-r--r--src/lib/libssl/src/crypto/x509v3/v3_info.c2
-rw-r--r--src/lib/libssl/src/crypto/x509v3/v3_ocsp.c3
-rw-r--r--src/lib/libssl/src/crypto/x509v3/v3_prn.c2
-rw-r--r--src/lib/libssl/src/crypto/x509v3/v3_purp.c4
-rw-r--r--src/lib/libssl/src/crypto/x509v3/v3_utl.c2
-rw-r--r--src/lib/libssl/src/crypto/x509v3/v3conf.c2
-rw-r--r--src/lib/libssl/src/crypto/x509v3/x509v3.h1
-rw-r--r--src/lib/libssl/src/demos/b64.c2
-rw-r--r--src/lib/libssl/src/demos/bio/saccept.c5
-rw-r--r--src/lib/libssl/src/demos/bio/sconnect.c5
-rw-r--r--src/lib/libssl/src/demos/engines/cluster_labs/hw_cluster_labs.c7
-rw-r--r--src/lib/libssl/src/demos/engines/ibmca/hw_ibmca.c3
-rw-r--r--src/lib/libssl/src/demos/engines/rsaref/Makefile16
-rw-r--r--src/lib/libssl/src/demos/engines/rsaref/rsaref.c47
-rw-r--r--src/lib/libssl/src/demos/engines/zencod/hw_zencod.c5
-rw-r--r--src/lib/libssl/src/demos/spkigen.c3
-rw-r--r--src/lib/libssl/src/demos/x509/mkcert.c6
-rw-r--r--src/lib/libssl/src/demos/x509/mkreq.c4
-rw-r--r--src/lib/libssl/src/doc/HOWTO/certificates.txt53
-rw-r--r--src/lib/libssl/src/doc/HOWTO/keys.txt73
-rw-r--r--src/lib/libssl/src/doc/apps/ca.pod66
-rw-r--r--src/lib/libssl/src/doc/apps/ciphers.pod26
-rw-r--r--src/lib/libssl/src/doc/apps/dhparam.pod8
-rw-r--r--src/lib/libssl/src/doc/apps/dsa.pod8
-rw-r--r--src/lib/libssl/src/doc/apps/dsaparam.pod8
-rw-r--r--src/lib/libssl/src/doc/apps/gendsa.pod8
-rw-r--r--src/lib/libssl/src/doc/apps/genrsa.pod8
-rw-r--r--src/lib/libssl/src/doc/apps/ocsp.pod37
-rw-r--r--src/lib/libssl/src/doc/apps/passwd.pod2
-rw-r--r--src/lib/libssl/src/doc/apps/pkcs7.pod8
-rw-r--r--src/lib/libssl/src/doc/apps/pkcs8.pod8
-rw-r--r--src/lib/libssl/src/doc/apps/req.pod18
-rw-r--r--src/lib/libssl/src/doc/apps/rsa.pod8
-rw-r--r--src/lib/libssl/src/doc/apps/s_client.pod7
-rw-r--r--src/lib/libssl/src/doc/apps/s_server.pod8
-rw-r--r--src/lib/libssl/src/doc/apps/smime.pod4
-rw-r--r--src/lib/libssl/src/doc/apps/speed.pod2
-rw-r--r--src/lib/libssl/src/doc/apps/spkac.pod8
-rw-r--r--src/lib/libssl/src/doc/apps/x509.pod40
-rw-r--r--src/lib/libssl/src/doc/c-indentation.el10
-rw-r--r--src/lib/libssl/src/doc/crypto/ASN1_OBJECT_new.pod43
-rw-r--r--src/lib/libssl/src/doc/crypto/ASN1_STRING_length.pod81
-rw-r--r--src/lib/libssl/src/doc/crypto/ASN1_STRING_new.pod44
-rw-r--r--src/lib/libssl/src/doc/crypto/ASN1_STRING_print_ex.pod96
-rw-r--r--src/lib/libssl/src/doc/crypto/BIO_f_cipher.pod2
-rw-r--r--src/lib/libssl/src/doc/crypto/BIO_s_accept.pod2
-rw-r--r--src/lib/libssl/src/doc/crypto/BIO_s_bio.pod56
-rw-r--r--src/lib/libssl/src/doc/crypto/BN_CTX_new.pod2
-rw-r--r--src/lib/libssl/src/doc/crypto/BN_add.pod2
-rw-r--r--src/lib/libssl/src/doc/crypto/BN_add_word.pod2
-rw-r--r--src/lib/libssl/src/doc/crypto/BN_bn2bin.pod2
-rw-r--r--src/lib/libssl/src/doc/crypto/BN_copy.pod2
-rw-r--r--src/lib/libssl/src/doc/crypto/BN_generate_prime.pod4
-rw-r--r--src/lib/libssl/src/doc/crypto/BN_mod_inverse.pod2
-rw-r--r--src/lib/libssl/src/doc/crypto/BN_mod_mul_montgomery.pod2
-rw-r--r--src/lib/libssl/src/doc/crypto/BN_mod_mul_reciprocal.pod2
-rw-r--r--src/lib/libssl/src/doc/crypto/BN_new.pod2
-rw-r--r--src/lib/libssl/src/doc/crypto/BN_rand.pod2
-rw-r--r--src/lib/libssl/src/doc/crypto/DH_generate_key.pod2
-rw-r--r--src/lib/libssl/src/doc/crypto/DH_generate_parameters.pod3
-rw-r--r--src/lib/libssl/src/doc/crypto/DH_new.pod2
-rw-r--r--src/lib/libssl/src/doc/crypto/DSA_SIG_new.pod3
-rw-r--r--src/lib/libssl/src/doc/crypto/DSA_do_sign.pod2
-rw-r--r--src/lib/libssl/src/doc/crypto/DSA_dup_DH.pod2
-rw-r--r--src/lib/libssl/src/doc/crypto/DSA_generate_key.pod3
-rw-r--r--src/lib/libssl/src/doc/crypto/DSA_generate_parameters.pod2
-rw-r--r--src/lib/libssl/src/doc/crypto/DSA_new.pod2
-rw-r--r--src/lib/libssl/src/doc/crypto/DSA_sign.pod2
-rw-r--r--src/lib/libssl/src/doc/crypto/ERR_get_error.pod2
-rw-r--r--src/lib/libssl/src/doc/crypto/EVP_EncryptInit.pod2
-rw-r--r--src/lib/libssl/src/doc/crypto/EVP_PKEY_new.pod47
-rw-r--r--src/lib/libssl/src/doc/crypto/EVP_PKEY_set1_RSA.pod80
-rw-r--r--src/lib/libssl/src/doc/crypto/EVP_SealInit.pod26
-rw-r--r--src/lib/libssl/src/doc/crypto/OBJ_nid2obj.pod149
-rw-r--r--src/lib/libssl/src/doc/crypto/PKCS12_create.pod57
-rw-r--r--src/lib/libssl/src/doc/crypto/PKCS12_parse.pod50
-rw-r--r--src/lib/libssl/src/doc/crypto/PKCS7_decrypt.pod53
-rw-r--r--src/lib/libssl/src/doc/crypto/PKCS7_encrypt.pod65
-rw-r--r--src/lib/libssl/src/doc/crypto/PKCS7_sign.pod85
-rw-r--r--src/lib/libssl/src/doc/crypto/PKCS7_verify.pod116
-rw-r--r--src/lib/libssl/src/doc/crypto/RAND_bytes.pod3
-rw-r--r--src/lib/libssl/src/doc/crypto/RSA_check_key.pod2
-rw-r--r--src/lib/libssl/src/doc/crypto/RSA_generate_key.pod3
-rw-r--r--src/lib/libssl/src/doc/crypto/RSA_new.pod3
-rw-r--r--src/lib/libssl/src/doc/crypto/RSA_print.pod6
-rw-r--r--src/lib/libssl/src/doc/crypto/RSA_private_encrypt.pod3
-rw-r--r--src/lib/libssl/src/doc/crypto/RSA_public_encrypt.pod3
-rw-r--r--src/lib/libssl/src/doc/crypto/RSA_set_method.pod13
-rw-r--r--src/lib/libssl/src/doc/crypto/RSA_sign.pod4
-rw-r--r--src/lib/libssl/src/doc/crypto/RSA_sign_ASN1_OCTET_STRING.pod4
-rw-r--r--src/lib/libssl/src/doc/crypto/SMIME_read_PKCS7.pod71
-rw-r--r--src/lib/libssl/src/doc/crypto/SMIME_write_PKCS7.pod59
-rw-r--r--src/lib/libssl/src/doc/crypto/X509_NAME_ENTRY_get_object.pod72
-rw-r--r--src/lib/libssl/src/doc/crypto/X509_NAME_add_entry_by_txt.pod110
-rw-r--r--src/lib/libssl/src/doc/crypto/X509_NAME_get_index_by_NID.pod106
-rw-r--r--src/lib/libssl/src/doc/crypto/X509_NAME_print_ex.pod105
-rw-r--r--src/lib/libssl/src/doc/crypto/X509_new.pod37
-rw-r--r--src/lib/libssl/src/doc/crypto/crypto.pod16
-rw-r--r--src/lib/libssl/src/doc/crypto/d2i_ASN1_OBJECT.pod29
-rw-r--r--src/lib/libssl/src/doc/crypto/d2i_DHparams.pod14
-rw-r--r--src/lib/libssl/src/doc/crypto/d2i_DSAPublicKey.pod82
-rw-r--r--src/lib/libssl/src/doc/crypto/d2i_PKCS8PrivateKey.pod56
-rw-r--r--src/lib/libssl/src/doc/crypto/d2i_RSAPublicKey.pod39
-rw-r--r--src/lib/libssl/src/doc/crypto/d2i_X509.pod231
-rw-r--r--src/lib/libssl/src/doc/crypto/d2i_X509_ALGOR.pod30
-rw-r--r--src/lib/libssl/src/doc/crypto/d2i_X509_CRL.pod37
-rw-r--r--src/lib/libssl/src/doc/crypto/d2i_X509_NAME.pod31
-rw-r--r--src/lib/libssl/src/doc/crypto/d2i_X509_REQ.pod36
-rw-r--r--src/lib/libssl/src/doc/crypto/d2i_X509_SIG.pod30
-rw-r--r--src/lib/libssl/src/doc/crypto/engine.pod12
-rw-r--r--src/lib/libssl/src/doc/openssl-shared.txt32
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_CTX_add_session.pod8
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_CTX_free.pod12
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_CTX_sess_set_get_cb.pod12
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_CTX_set_options.pod2
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_CTX_set_session_cache_mode.pod53
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_CTX_set_verify.pod2
-rw-r--r--src/lib/libssl/src/doc/ssl/ssl.pod2
-rw-r--r--src/lib/libssl/src/doc/standards.txt173
-rw-r--r--src/lib/libssl/src/e_os.h91
-rw-r--r--src/lib/libssl/src/e_os2.h18
-rw-r--r--src/lib/libssl/src/makevms.com124
-rw-r--r--src/lib/libssl/src/ms/do_ms.bat2
-rw-r--r--src/lib/libssl/src/ms/mingw32.bat11
-rw-r--r--src/lib/libssl/src/ms/mw.bat5
-rw-r--r--src/lib/libssl/src/ms/tencce.bat19
-rw-r--r--src/lib/libssl/src/ms/test.bat4
-rw-r--r--src/lib/libssl/src/ms/testce.bat234
-rw-r--r--src/lib/libssl/src/ms/testce2.bat2
-rw-r--r--src/lib/libssl/src/ms/testenc.bat4
-rw-r--r--src/lib/libssl/src/ms/testencce.bat97
-rw-r--r--src/lib/libssl/src/ms/testpem.bat2
-rw-r--r--src/lib/libssl/src/ms/testpemce.bat42
-rw-r--r--src/lib/libssl/src/ms/testss.bat2
-rw-r--r--src/lib/libssl/src/ms/testssce.bat104
-rw-r--r--src/lib/libssl/src/ms/tpemce.bat8
-rw-r--r--src/lib/libssl/src/openssl.spec6
-rw-r--r--src/lib/libssl/src/shlib/sco5-shared-gcc.sh48
-rw-r--r--src/lib/libssl/src/shlib/sco5-shared-installed28
-rw-r--r--src/lib/libssl/src/shlib/sco5-shared.sh48
-rw-r--r--src/lib/libssl/src/shlib/svr5-shared-gcc.sh2
-rw-r--r--src/lib/libssl/src/shlib/svr5-shared-installed3
-rw-r--r--src/lib/libssl/src/shlib/svr5-shared.sh2
-rw-r--r--src/lib/libssl/src/ssl/bio_ssl.c6
-rw-r--r--src/lib/libssl/src/ssl/kssl.c83
-rw-r--r--src/lib/libssl/src/ssl/s23_clnt.c24
-rw-r--r--src/lib/libssl/src/ssl/s23_meth.c19
-rw-r--r--src/lib/libssl/src/ssl/s23_srvr.c19
-rw-r--r--src/lib/libssl/src/ssl/s2_clnt.c34
-rw-r--r--src/lib/libssl/src/ssl/s2_enc.c3
-rw-r--r--src/lib/libssl/src/ssl/s2_lib.c25
-rw-r--r--src/lib/libssl/src/ssl/s2_meth.c19
-rw-r--r--src/lib/libssl/src/ssl/s2_pkt.c2
-rw-r--r--src/lib/libssl/src/ssl/s2_srvr.c21
-rw-r--r--src/lib/libssl/src/ssl/s3_both.c25
-rw-r--r--src/lib/libssl/src/ssl/s3_clnt.c73
-rw-r--r--src/lib/libssl/src/ssl/s3_enc.c14
-rw-r--r--src/lib/libssl/src/ssl/s3_lib.c193
-rw-r--r--src/lib/libssl/src/ssl/s3_meth.c19
-rw-r--r--src/lib/libssl/src/ssl/s3_pkt.c47
-rw-r--r--src/lib/libssl/src/ssl/s3_srvr.c53
-rw-r--r--src/lib/libssl/src/ssl/ssl-lib.com280
-rw-r--r--src/lib/libssl/src/ssl/ssl.h30
-rw-r--r--src/lib/libssl/src/ssl/ssl3.h48
-rw-r--r--src/lib/libssl/src/ssl/ssl_asn1.c11
-rw-r--r--src/lib/libssl/src/ssl/ssl_cert.c30
-rw-r--r--src/lib/libssl/src/ssl/ssl_ciph.c14
-rw-r--r--src/lib/libssl/src/ssl/ssl_err.c1
-rw-r--r--src/lib/libssl/src/ssl/ssl_lib.c45
-rw-r--r--src/lib/libssl/src/ssl/ssl_sess.c17
-rw-r--r--src/lib/libssl/src/ssl/ssl_task.c2
-rw-r--r--src/lib/libssl/src/ssl/ssltest.c52
-rw-r--r--src/lib/libssl/src/ssl/t1_clnt.c17
-rw-r--r--src/lib/libssl/src/ssl/t1_enc.c20
-rw-r--r--src/lib/libssl/src/ssl/t1_meth.c20
-rw-r--r--src/lib/libssl/src/ssl/t1_srvr.c17
-rw-r--r--src/lib/libssl/src/test/evptests.txt183
-rw-r--r--src/lib/libssl/src/test/maketests.com262
-rw-r--r--src/lib/libssl/src/test/methtest.c4
-rw-r--r--src/lib/libssl/src/test/testgen2
-rw-r--r--src/lib/libssl/src/test/testssl16
-rw-r--r--src/lib/libssl/src/test/testssl.com32
-rw-r--r--src/lib/libssl/src/tools/c_rehash8
-rw-r--r--src/lib/libssl/src/tools/c_rehash.in6
-rw-r--r--src/lib/libssl/src/util/bat.sh2
-rw-r--r--src/lib/libssl/src/util/cygwin.sh2
-rw-r--r--src/lib/libssl/src/util/domd7
-rw-r--r--src/lib/libssl/src/util/extract-names.pl22
-rw-r--r--src/lib/libssl/src/util/libeay.num226
-rw-r--r--src/lib/libssl/src/util/mk1mf.pl33
-rw-r--r--src/lib/libssl/src/util/mkcerts.sh6
-rw-r--r--src/lib/libssl/src/util/mkdef.pl25
-rw-r--r--src/lib/libssl/src/util/mkerr.pl16
-rw-r--r--src/lib/libssl/src/util/pl/BC-32.pl4
-rw-r--r--src/lib/libssl/src/util/pl/Mingw32.pl34
-rw-r--r--src/lib/libssl/src/util/pl/VC-32.pl2
-rw-r--r--src/lib/libssl/src/util/pl/VC-CE.pl111
-rw-r--r--src/lib/libssl/src/util/ssleay.num2
497 files changed, 12554 insertions, 4050 deletions
diff --git a/src/lib/libssl/src/CHANGES b/src/lib/libssl/src/CHANGES
index 03b697cd7e..1e85275800 100644
--- a/src/lib/libssl/src/CHANGES
+++ b/src/lib/libssl/src/CHANGES
@@ -2,7 +2,266 @@
2 OpenSSL CHANGES 2 OpenSSL CHANGES
3 _______________ 3 _______________
4 4
5 Changes between 0.9.6h and 0.9.7 [XX xxx 2002] 5 Changes between 0.9.7a and 0.9.7b [10 Apr 2003]
6
7 *) Countermeasure against the Klima-Pokorny-Rosa extension of
8 Bleichbacher's attack on PKCS #1 v1.5 padding: treat
9 a protocol version number mismatch like a decryption error
10 in ssl3_get_client_key_exchange (ssl/s3_srvr.c).
11 [Bodo Moeller]
12
13 *) Turn on RSA blinding by default in the default implementation
14 to avoid a timing attack. Applications that don't want it can call
15 RSA_blinding_off() or use the new flag RSA_FLAG_NO_BLINDING.
16 They would be ill-advised to do so in most cases.
17 [Ben Laurie, Steve Henson, Geoff Thorpe, Bodo Moeller]
18
19 *) Change RSA blinding code so that it works when the PRNG is not
20 seeded (in this case, the secret RSA exponent is abused as
21 an unpredictable seed -- if it is not unpredictable, there
22 is no point in blinding anyway). Make RSA blinding thread-safe
23 by remembering the creator's thread ID in rsa->blinding and
24 having all other threads use local one-time blinding factors
25 (this requires more computation than sharing rsa->blinding, but
26 avoids excessive locking; and if an RSA object is not shared
27 between threads, blinding will still be very fast).
28 [Bodo Moeller]
29
30 *) Fixed a typo bug that would cause ENGINE_set_default() to set an
31 ENGINE as defaults for all supported algorithms irrespective of
32 the 'flags' parameter. 'flags' is now honoured, so applications
33 should make sure they are passing it correctly.
34 [Geoff Thorpe]
35
36 *) Target "mingw" now allows native Windows code to be generated in
37 the Cygwin environment as well as with the MinGW compiler.
38 [Ulf Moeller]
39
40 Changes between 0.9.7 and 0.9.7a [19 Feb 2003]
41
42 *) In ssl3_get_record (ssl/s3_pkt.c), minimize information leaked
43 via timing by performing a MAC computation even if incorrrect
44 block cipher padding has been found. This is a countermeasure
45 against active attacks where the attacker has to distinguish
46 between bad padding and a MAC verification error. (CAN-2003-0078)
47
48 [Bodo Moeller; problem pointed out by Brice Canvel (EPFL),
49 Alain Hiltgen (UBS), Serge Vaudenay (EPFL), and
50 Martin Vuagnoux (EPFL, Ilion)]
51
52 *) Make the no-err option work as intended. The intention with no-err
53 is not to have the whole error stack handling routines removed from
54 libcrypto, it's only intended to remove all the function name and
55 reason texts, thereby removing some of the footprint that may not
56 be interesting if those errors aren't displayed anyway.
57
58 NOTE: it's still possible for any application or module to have it's
59 own set of error texts inserted. The routines are there, just not
60 used by default when no-err is given.
61 [Richard Levitte]
62
63 *) Add support for FreeBSD on IA64.
64 [dirk.meyer@dinoex.sub.org via Richard Levitte, resolves #454]
65
66 *) Adjust DES_cbc_cksum() so it returns the same value as the MIT
67 Kerberos function mit_des_cbc_cksum(). Before this change,
68 the value returned by DES_cbc_cksum() was like the one from
69 mit_des_cbc_cksum(), except the bytes were swapped.
70 [Kevin Greaney <Kevin.Greaney@hp.com> and Richard Levitte]
71
72 *) Allow an application to disable the automatic SSL chain building.
73 Before this a rather primitive chain build was always performed in
74 ssl3_output_cert_chain(): an application had no way to send the
75 correct chain if the automatic operation produced an incorrect result.
76
77 Now the chain builder is disabled if either:
78
79 1. Extra certificates are added via SSL_CTX_add_extra_chain_cert().
80
81 2. The mode flag SSL_MODE_NO_AUTO_CHAIN is set.
82
83 The reasoning behind this is that an application would not want the
84 auto chain building to take place if extra chain certificates are
85 present and it might also want a means of sending no additional
86 certificates (for example the chain has two certificates and the
87 root is omitted).
88 [Steve Henson]
89
90 *) Add the possibility to build without the ENGINE framework.
91 [Steven Reddie <smr@essemer.com.au> via Richard Levitte]
92
93 *) Under Win32 gmtime() can return NULL: check return value in
94 OPENSSL_gmtime(). Add error code for case where gmtime() fails.
95 [Steve Henson]
96
97 *) DSA routines: under certain error conditions uninitialized BN objects
98 could be freed. Solution: make sure initialization is performed early
99 enough. (Reported and fix supplied by Ivan D Nestlerode <nestler@MIT.EDU>,
100 Nils Larsch <nla@trustcenter.de> via PR#459)
101 [Lutz Jaenicke]
102
103 *) Another fix for SSLv2 session ID handling: the session ID was incorrectly
104 checked on reconnect on the client side, therefore session resumption
105 could still fail with a "ssl session id is different" error. This
106 behaviour is masked when SSL_OP_ALL is used due to
107 SSL_OP_MICROSOFT_SESS_ID_BUG being set.
108 Behaviour observed by Crispin Flowerday <crispin@flowerday.cx> as
109 followup to PR #377.
110 [Lutz Jaenicke]
111
112 *) IA-32 assembler support enhancements: unified ELF targets, support
113 for SCO/Caldera platforms, fix for Cygwin shared build.
114 [Andy Polyakov]
115
116 *) Add support for FreeBSD on sparc64. As a consequence, support for
117 FreeBSD on non-x86 processors is separate from x86 processors on
118 the config script, much like the NetBSD support.
119 [Richard Levitte & Kris Kennaway <kris@obsecurity.org>]
120
121 Changes between 0.9.6h and 0.9.7 [31 Dec 2002]
122
123 *) Fix session ID handling in SSLv2 client code: the SERVER FINISHED
124 code (06) was taken as the first octet of the session ID and the last
125 octet was ignored consequently. As a result SSLv2 client side session
126 caching could not have worked due to the session ID mismatch between
127 client and server.
128 Behaviour observed by Crispin Flowerday <crispin@flowerday.cx> as
129 PR #377.
130 [Lutz Jaenicke]
131
132 *) Change the declaration of needed Kerberos libraries to use EX_LIBS
133 instead of the special (and badly supported) LIBKRB5. LIBKRB5 is
134 removed entirely.
135 [Richard Levitte]
136
137 *) The hw_ncipher.c engine requires dynamic locks. Unfortunately, it
138 seems that in spite of existing for more than a year, many application
139 author have done nothing to provide the necessary callbacks, which
140 means that this particular engine will not work properly anywhere.
141 This is a very unfortunate situation which forces us, in the name
142 of usability, to give the hw_ncipher.c a static lock, which is part
143 of libcrypto.
144 NOTE: This is for the 0.9.7 series ONLY. This hack will never
145 appear in 0.9.8 or later. We EXPECT application authors to have
146 dealt properly with this when 0.9.8 is released (unless we actually
147 make such changes in the libcrypto locking code that changes will
148 have to be made anyway).
149 [Richard Levitte]
150
151 *) In asn1_d2i_read_bio() repeatedly call BIO_read() until all content
152 octets have been read, EOF or an error occurs. Without this change
153 some truncated ASN1 structures will not produce an error.
154 [Steve Henson]
155
156 *) Disable Heimdal support, since it hasn't been fully implemented.
157 Still give the possibility to force the use of Heimdal, but with
158 warnings and a request that patches get sent to openssl-dev.
159 [Richard Levitte]
160
161 *) Add the VC-CE target, introduce the WINCE sysname, and add
162 INSTALL.WCE and appropriate conditionals to make it build.
163 [Steven Reddie <smr@essemer.com.au> via Richard Levitte]
164
165 *) Change the DLL names for Cygwin to cygcrypto-x.y.z.dll and
166 cygssl-x.y.z.dll, where x, y and z are the major, minor and
167 edit numbers of the version.
168 [Corinna Vinschen <vinschen@redhat.com> and Richard Levitte]
169
170 *) Introduce safe string copy and catenation functions
171 (BUF_strlcpy() and BUF_strlcat()).
172 [Ben Laurie (CHATS) and Richard Levitte]
173
174 *) Avoid using fixed-size buffers for one-line DNs.
175 [Ben Laurie (CHATS)]
176
177 *) Add BUF_MEM_grow_clean() to avoid information leakage when
178 resizing buffers containing secrets, and use where appropriate.
179 [Ben Laurie (CHATS)]
180
181 *) Avoid using fixed size buffers for configuration file location.
182 [Ben Laurie (CHATS)]
183
184 *) Avoid filename truncation for various CA files.
185 [Ben Laurie (CHATS)]
186
187 *) Use sizeof in preference to magic numbers.
188 [Ben Laurie (CHATS)]
189
190 *) Avoid filename truncation in cert requests.
191 [Ben Laurie (CHATS)]
192
193 *) Add assertions to check for (supposedly impossible) buffer
194 overflows.
195 [Ben Laurie (CHATS)]
196
197 *) Don't cache truncated DNS entries in the local cache (this could
198 potentially lead to a spoofing attack).
199 [Ben Laurie (CHATS)]
200
201 *) Fix various buffers to be large enough for hex/decimal
202 representations in a platform independent manner.
203 [Ben Laurie (CHATS)]
204
205 *) Add CRYPTO_realloc_clean() to avoid information leakage when
206 resizing buffers containing secrets, and use where appropriate.
207 [Ben Laurie (CHATS)]
208
209 *) Add BIO_indent() to avoid much slightly worrying code to do
210 indents.
211 [Ben Laurie (CHATS)]
212
213 *) Convert sprintf()/BIO_puts() to BIO_printf().
214 [Ben Laurie (CHATS)]
215
216 *) buffer_gets() could terminate with the buffer only half
217 full. Fixed.
218 [Ben Laurie (CHATS)]
219
220 *) Add assertions to prevent user-supplied crypto functions from
221 overflowing internal buffers by having large block sizes, etc.
222 [Ben Laurie (CHATS)]
223
224 *) New OPENSSL_assert() macro (similar to assert(), but enabled
225 unconditionally).
226 [Ben Laurie (CHATS)]
227
228 *) Eliminate unused copy of key in RC4.
229 [Ben Laurie (CHATS)]
230
231 *) Eliminate unused and incorrectly sized buffers for IV in pem.h.
232 [Ben Laurie (CHATS)]
233
234 *) Fix off-by-one error in EGD path.
235 [Ben Laurie (CHATS)]
236
237 *) If RANDFILE path is too long, ignore instead of truncating.
238 [Ben Laurie (CHATS)]
239
240 *) Eliminate unused and incorrectly sized X.509 structure
241 CBCParameter.
242 [Ben Laurie (CHATS)]
243
244 *) Eliminate unused and dangerous function knumber().
245 [Ben Laurie (CHATS)]
246
247 *) Eliminate unused and dangerous structure, KSSL_ERR.
248 [Ben Laurie (CHATS)]
249
250 *) Protect against overlong session ID context length in an encoded
251 session object. Since these are local, this does not appear to be
252 exploitable.
253 [Ben Laurie (CHATS)]
254
255 *) Change from security patch (see 0.9.6e below) that did not affect
256 the 0.9.6 release series:
257
258 Remote buffer overflow in SSL3 protocol - an attacker could
259 supply an oversized master key in Kerberos-enabled versions.
260 (CAN-2002-0657)
261 [Ben Laurie (CHATS)]
262
263 *) Change the SSL kerb5 codes to match RFC 2712.
264 [Richard Levitte]
6 265
7 *) Make -nameopt work fully for req and add -reqopt switch. 266 *) Make -nameopt work fully for req and add -reqopt switch.
8 [Michael Bell <michael.bell@rz.hu-berlin.de>, Steve Henson] 267 [Michael Bell <michael.bell@rz.hu-berlin.de>, Steve Henson]
@@ -34,7 +293,7 @@
34 # is assumed to contain the absolute OpenSSL source directory. 293 # is assumed to contain the absolute OpenSSL source directory.
35 mkdir -p objtree/"`uname -s`-`uname -r`-`uname -m`" 294 mkdir -p objtree/"`uname -s`-`uname -r`-`uname -m`"
36 cd objtree/"`uname -s`-`uname -r`-`uname -m`" 295 cd objtree/"`uname -s`-`uname -r`-`uname -m`"
37 (cd $OPENSSL_SOURCE; find . -type f -o -type l) | while read F; do 296 (cd $OPENSSL_SOURCE; find . -type f) | while read F; do
38 mkdir -p `dirname $F` 297 mkdir -p `dirname $F`
39 ln -s $OPENSSL_SOURCE/$F $F 298 ln -s $OPENSSL_SOURCE/$F $F
40 done 299 done
@@ -1534,6 +1793,11 @@ des-cbc 3624.96k 5258.21k 5530.91k 5624.30k 5628.26k
1534 be reduced modulo m. 1793 be reduced modulo m.
1535 [Lenka Fibikova <fibikova@exp-math.uni-essen.de>, Bodo Moeller] 1794 [Lenka Fibikova <fibikova@exp-math.uni-essen.de>, Bodo Moeller]
1536 1795
1796#if 0
1797 The following entry accidentily appeared in the CHANGES file
1798 distributed with OpenSSL 0.9.7. The modifications described in
1799 it do *not* apply to OpenSSL 0.9.7.
1800
1537 *) Remove a few calls to bn_wexpand() in BN_sqr() (the one in there 1801 *) Remove a few calls to bn_wexpand() in BN_sqr() (the one in there
1538 was actually never needed) and in BN_mul(). The removal in BN_mul() 1802 was actually never needed) and in BN_mul(). The removal in BN_mul()
1539 required a small change in bn_mul_part_recursive() and the addition 1803 required a small change in bn_mul_part_recursive() and the addition
@@ -1542,6 +1806,7 @@ des-cbc 3624.96k 5258.21k 5530.91k 5624.30k 5628.26k
1542 bn_sub_words() and bn_add_words() except they take arrays with 1806 bn_sub_words() and bn_add_words() except they take arrays with
1543 differing sizes. 1807 differing sizes.
1544 [Richard Levitte] 1808 [Richard Levitte]
1809#endif
1545 1810
1546 *) In 'openssl passwd', verify passwords read from the terminal 1811 *) In 'openssl passwd', verify passwords read from the terminal
1547 unless the '-salt' option is used (which usually means that 1812 unless the '-salt' option is used (which usually means that
@@ -1673,7 +1938,76 @@ des-cbc 3624.96k 5258.21k 5530.91k 5624.30k 5628.26k
1673 *) Clean old EAY MD5 hack from e_os.h. 1938 *) Clean old EAY MD5 hack from e_os.h.
1674 [Richard Levitte] 1939 [Richard Levitte]
1675 1940
1676 Changes between 0.9.6g and 0.9.6h [xx XXX xxxx] 1941 Changes between 0.9.6h and 0.9.6i [19 Feb 2003]
1942
1943 *) In ssl3_get_record (ssl/s3_pkt.c), minimize information leaked
1944 via timing by performing a MAC computation even if incorrrect
1945 block cipher padding has been found. This is a countermeasure
1946 against active attacks where the attacker has to distinguish
1947 between bad padding and a MAC verification error. (CAN-2003-0078)
1948
1949 [Bodo Moeller; problem pointed out by Brice Canvel (EPFL),
1950 Alain Hiltgen (UBS), Serge Vaudenay (EPFL), and
1951 Martin Vuagnoux (EPFL, Ilion)]
1952
1953 Changes between 0.9.6g and 0.9.6h [5 Dec 2002]
1954
1955 *) New function OPENSSL_cleanse(), which is used to cleanse a section of
1956 memory from it's contents. This is done with a counter that will
1957 place alternating values in each byte. This can be used to solve
1958 two issues: 1) the removal of calls to memset() by highly optimizing
1959 compilers, and 2) cleansing with other values than 0, since those can
1960 be read through on certain media, for example a swap space on disk.
1961 [Geoff Thorpe]
1962
1963 *) Bugfix: client side session caching did not work with external caching,
1964 because the session->cipher setting was not restored when reloading
1965 from the external cache. This problem was masked, when
1966 SSL_OP_NETSCAPE_REUSE_CIPHER_CHANGE_BUG (part of SSL_OP_ALL) was set.
1967 (Found by Steve Haslam <steve@araqnid.ddts.net>.)
1968 [Lutz Jaenicke]
1969
1970 *) Fix client_certificate (ssl/s2_clnt.c): The permissible total
1971 length of the REQUEST-CERTIFICATE message is 18 .. 34, not 17 .. 33.
1972 [Zeev Lieber <zeev-l@yahoo.com>]
1973
1974 *) Undo an undocumented change introduced in 0.9.6e which caused
1975 repeated calls to OpenSSL_add_all_ciphers() and
1976 OpenSSL_add_all_digests() to be ignored, even after calling
1977 EVP_cleanup().
1978 [Richard Levitte]
1979
1980 *) Change the default configuration reader to deal with last line not
1981 being properly terminated.
1982 [Richard Levitte]
1983
1984 *) Change X509_NAME_cmp() so it applies the special rules on handling
1985 DN values that are of type PrintableString, as well as RDNs of type
1986 emailAddress where the value has the type ia5String.
1987 [stefank@valicert.com via Richard Levitte]
1988
1989 *) Add a SSL_SESS_CACHE_NO_INTERNAL_STORE flag to take over half
1990 the job SSL_SESS_CACHE_NO_INTERNAL_LOOKUP was inconsistently
1991 doing, define a new flag (SSL_SESS_CACHE_NO_INTERNAL) to be
1992 the bitwise-OR of the two for use by the majority of applications
1993 wanting this behaviour, and update the docs. The documented
1994 behaviour and actual behaviour were inconsistent and had been
1995 changing anyway, so this is more a bug-fix than a behavioural
1996 change.
1997 [Geoff Thorpe, diagnosed by Nadav Har'El]
1998
1999 *) Don't impose a 16-byte length minimum on session IDs in ssl/s3_clnt.c
2000 (the SSL 3.0 and TLS 1.0 specifications allow any length up to 32 bytes).
2001 [Bodo Moeller]
2002
2003 *) Fix initialization code race conditions in
2004 SSLv23_method(), SSLv23_client_method(), SSLv23_server_method(),
2005 SSLv2_method(), SSLv2_client_method(), SSLv2_server_method(),
2006 SSLv3_method(), SSLv3_client_method(), SSLv3_server_method(),
2007 TLSv1_method(), TLSv1_client_method(), TLSv1_server_method(),
2008 ssl2_get_cipher_by_char(),
2009 ssl3_get_cipher_by_char().
2010 [Patrick McCormick <patrick@tellme.com>, Bodo Moeller]
1677 2011
1678 *) Reorder cleanup sequence in SSL_CTX_free(): only remove the ex_data after 2012 *) Reorder cleanup sequence in SSL_CTX_free(): only remove the ex_data after
1679 the cached sessions are flushed, as the remove_cb() might use ex_data 2013 the cached sessions are flushed, as the remove_cb() might use ex_data
@@ -1703,7 +2037,7 @@ des-cbc 3624.96k 5258.21k 5530.91k 5624.30k 5628.26k
1703 overflow checks added in 0.9.6e. This prevents DoS (the 2037 overflow checks added in 0.9.6e. This prevents DoS (the
1704 assertions could call abort()). 2038 assertions could call abort()).
1705 [Arne Ansper <arne@ats.cyber.ee>, Bodo Moeller] 2039 [Arne Ansper <arne@ats.cyber.ee>, Bodo Moeller]
1706 2040
1707 Changes between 0.9.6d and 0.9.6e [30 Jul 2002] 2041 Changes between 0.9.6d and 0.9.6e [30 Jul 2002]
1708 2042
1709 *) Add various sanity checks to asn1_get_length() to reject 2043 *) Add various sanity checks to asn1_get_length() to reject
@@ -1755,11 +2089,6 @@ des-cbc 3624.96k 5258.21k 5530.91k 5624.30k 5628.26k
1755 [Matthew Byng-Maddick <mbm@aldigital.co.uk> and Ben Laurie (CHATS)> 2089 [Matthew Byng-Maddick <mbm@aldigital.co.uk> and Ben Laurie (CHATS)>
1756 2090
1757 *) Remote buffer overflow in SSL3 protocol - an attacker could 2091 *) Remote buffer overflow in SSL3 protocol - an attacker could
1758 supply an oversized master key in Kerberos-enabled versions.
1759 (CAN-2002-0657)
1760 [Ben Laurie (CHATS)]
1761
1762 *) Remote buffer overflow in SSL3 protocol - an attacker could
1763 supply an oversized session ID to a client. (CAN-2002-0656) 2092 supply an oversized session ID to a client. (CAN-2002-0656)
1764 [Ben Laurie (CHATS)] 2093 [Ben Laurie (CHATS)]
1765 2094
@@ -1767,7 +2096,6 @@ des-cbc 3624.96k 5258.21k 5530.91k 5624.30k 5628.26k
1767 supply an oversized client master key. (CAN-2002-0656) 2096 supply an oversized client master key. (CAN-2002-0656)
1768 [Ben Laurie (CHATS)] 2097 [Ben Laurie (CHATS)]
1769 2098
1770
1771 Changes between 0.9.6c and 0.9.6d [9 May 2002] 2099 Changes between 0.9.6c and 0.9.6d [9 May 2002]
1772 2100
1773 *) Fix crypto/asn1/a_sign.c so that 'parameters' is omitted (not 2101 *) Fix crypto/asn1/a_sign.c so that 'parameters' is omitted (not
@@ -1854,13 +2182,13 @@ des-cbc 3624.96k 5258.21k 5530.91k 5624.30k 5628.26k
1854 value is 0. 2182 value is 0.
1855 [Richard Levitte] 2183 [Richard Levitte]
1856 2184
1857 *) Add the configuration target linux-s390x.
1858 [Neale Ferguson <Neale.Ferguson@SoftwareAG-USA.com> via Richard Levitte]
1859
1860 *) [In 0.9.6d-engine release:] 2185 *) [In 0.9.6d-engine release:]
1861 Fix a crashbug and a logic bug in hwcrhk_load_pubkey(). 2186 Fix a crashbug and a logic bug in hwcrhk_load_pubkey().
1862 [Toomas Kiisk <vix@cyber.ee> via Richard Levitte] 2187 [Toomas Kiisk <vix@cyber.ee> via Richard Levitte]
1863 2188
2189 *) Add the configuration target linux-s390x.
2190 [Neale Ferguson <Neale.Ferguson@SoftwareAG-USA.com> via Richard Levitte]
2191
1864 *) The earlier bugfix for the SSL3_ST_SW_HELLO_REQ_C case of 2192 *) The earlier bugfix for the SSL3_ST_SW_HELLO_REQ_C case of
1865 ssl3_accept (ssl/s3_srvr.c) incorrectly used a local flag 2193 ssl3_accept (ssl/s3_srvr.c) incorrectly used a local flag
1866 variable as an indication that a ClientHello message has been 2194 variable as an indication that a ClientHello message has been
diff --git a/src/lib/libssl/src/Configure b/src/lib/libssl/src/Configure
index 292ca877c6..7763dc4138 100644
--- a/src/lib/libssl/src/Configure
+++ b/src/lib/libssl/src/Configure
@@ -10,7 +10,7 @@ use strict;
10 10
11# see INSTALL for instructions. 11# see INSTALL for instructions.
12 12
13my $usage="Usage: Configure [no-<cipher> ...] [-Dxxx] [-lxxx] [-Lxxx] [-fxxx] [-Kxxx] [no-hw-xxx|no-hw] [[no-]threads] [[no-]shared] [[no-]zlib|zlib-dynamic] [no-asm] [no-dso] [no-krb5] [386] [--prefix=DIR] [--openssldir=OPENSSLDIR] [--with-xxx[=vvv]] [--test-sanity] os/compiler[:flags]\n"; 13my $usage="Usage: Configure [no-<cipher> ...] [-Dxxx] [-lxxx] [-Lxxx] [-fxxx] [-Kxxx] [no-engine] [no-hw-xxx|no-hw] [[no-]threads] [[no-]shared] [[no-]zlib|zlib-dynamic] [no-asm] [no-dso] [no-krb5] [386] [--prefix=DIR] [--openssldir=OPENSSLDIR] [--with-xxx[=vvv]] [--test-sanity] os/compiler[:flags]\n";
14 14
15# Options: 15# Options:
16# 16#
@@ -38,6 +38,7 @@ my $usage="Usage: Configure [no-<cipher> ...] [-Dxxx] [-lxxx] [-Lxxx] [-fxxx] [-
38# --test-sanity Make a number of sanity checks on the data in this file. 38# --test-sanity Make a number of sanity checks on the data in this file.
39# This is a debugging tool for OpenSSL developers. 39# This is a debugging tool for OpenSSL developers.
40# 40#
41# no-engine do not compile in any engine code.
41# no-hw-xxx do not compile support for specific crypto hardware. 42# no-hw-xxx do not compile support for specific crypto hardware.
42# Generic OpenSSL-style methods relating to this support 43# Generic OpenSSL-style methods relating to this support
43# are always compiled but return NULL if the hardware 44# are always compiled but return NULL if the hardware
@@ -107,7 +108,6 @@ my $tlib="-lnsl -lsocket";
107my $bits1="THIRTY_TWO_BIT "; 108my $bits1="THIRTY_TWO_BIT ";
108my $bits2="SIXTY_FOUR_BIT "; 109my $bits2="SIXTY_FOUR_BIT ";
109 110
110my $x86_sol_asm="asm/bn86-sol.o asm/co86-sol.o:asm/dx86-sol.o asm/yx86-sol.o:asm/bx86-sol.o:asm/mx86-sol.o:asm/sx86-sol.o:asm/cx86-sol.o:asm/rx86-sol.o:asm/rm86-sol.o:asm/r586-sol.o";
111my $x86_elf_asm="asm/bn86-elf.o asm/co86-elf.o:asm/dx86-elf.o asm/yx86-elf.o:asm/bx86-elf.o:asm/mx86-elf.o:asm/sx86-elf.o:asm/cx86-elf.o:asm/rx86-elf.o:asm/rm86-elf.o:asm/r586-elf.o"; 111my $x86_elf_asm="asm/bn86-elf.o asm/co86-elf.o:asm/dx86-elf.o asm/yx86-elf.o:asm/bx86-elf.o:asm/mx86-elf.o:asm/sx86-elf.o:asm/cx86-elf.o:asm/rx86-elf.o:asm/rm86-elf.o:asm/r586-elf.o";
112my $x86_out_asm="asm/bn86-out.o asm/co86-out.o:asm/dx86-out.o asm/yx86-out.o:asm/bx86-out.o:asm/mx86-out.o:asm/sx86-out.o:asm/cx86-out.o:asm/rx86-out.o:asm/rm86-out.o:asm/r586-out.o"; 112my $x86_out_asm="asm/bn86-out.o asm/co86-out.o:asm/dx86-out.o asm/yx86-out.o:asm/bx86-out.o:asm/mx86-out.o:asm/sx86-out.o:asm/cx86-out.o:asm/rx86-out.o:asm/rm86-out.o:asm/r586-out.o";
113my $x86_bsdi_asm="asm/bn86bsdi.o asm/co86bsdi.o:asm/dx86bsdi.o asm/yx86bsdi.o:asm/bx86bsdi.o:asm/mx86bsdi.o:asm/sx86bsdi.o:asm/cx86bsdi.o:asm/rx86bsdi.o:asm/rm86bsdi.o:asm/r586bsdi.o"; 113my $x86_bsdi_asm="asm/bn86bsdi.o asm/co86bsdi.o:asm/dx86bsdi.o asm/yx86bsdi.o:asm/bx86bsdi.o:asm/mx86bsdi.o:asm/sx86bsdi.o:asm/cx86bsdi.o:asm/rx86bsdi.o:asm/rm86bsdi.o:asm/r586bsdi.o";
@@ -145,8 +145,10 @@ my %table=(
145"debug-ulf", "gcc:-DL_ENDIAN -DREF_CHECK -DCONF_DEBUG -DBN_DEBUG -DBN_CTX_DEBUG -DCRYPTO_MDEBUG_ALL -g -O2 -m486 -Wall -Werror -Wshadow -pipe::-D_REENTRANT:::${x86_gcc_des} ${x86_gcc_opts}:${x86_elf_asm}", 145"debug-ulf", "gcc:-DL_ENDIAN -DREF_CHECK -DCONF_DEBUG -DBN_DEBUG -DBN_CTX_DEBUG -DCRYPTO_MDEBUG_ALL -g -O2 -m486 -Wall -Werror -Wshadow -pipe::-D_REENTRANT:::${x86_gcc_des} ${x86_gcc_opts}:${x86_elf_asm}",
146"debug-steve", "gcc:-DL_ENDIAN -DREF_CHECK -DCONF_DEBUG -DBN_CTX_DEBUG -DDEBUG_SAFESTACK -DCRYPTO_MDEBUG_ALL -DPEDANTIC -g -mcpu=i486 -pedantic -Wall -Werror -Wshadow -pipe::-D_REENTRANT::-rdynamic -ldl:${x86_gcc_des} ${x86_gcc_opts}:${x86_elf_asm}:dlfcn", 146"debug-steve", "gcc:-DL_ENDIAN -DREF_CHECK -DCONF_DEBUG -DBN_CTX_DEBUG -DDEBUG_SAFESTACK -DCRYPTO_MDEBUG_ALL -DPEDANTIC -g -mcpu=i486 -pedantic -Wall -Werror -Wshadow -pipe::-D_REENTRANT::-rdynamic -ldl:${x86_gcc_des} ${x86_gcc_opts}:${x86_elf_asm}:dlfcn",
147"debug-steve-linux-pseudo64", "gcc:-DL_ENDIAN -DREF_CHECK -DCONF_DEBUG -DBN_CTX_DEBUG -DDEBUG_SAFESTACK -DCRYPTO_MDEBUG_ALL -DOPENSSL_NO_ASM -g -mcpu=i486 -Wall -Werror -Wshadow -pipe::-D_REENTRANT::-rdynamic -ldl:SIXTY_FOUR_BIT::dlfcn", 147"debug-steve-linux-pseudo64", "gcc:-DL_ENDIAN -DREF_CHECK -DCONF_DEBUG -DBN_CTX_DEBUG -DDEBUG_SAFESTACK -DCRYPTO_MDEBUG_ALL -DOPENSSL_NO_ASM -g -mcpu=i486 -Wall -Werror -Wshadow -pipe::-D_REENTRANT::-rdynamic -ldl:SIXTY_FOUR_BIT::dlfcn",
148"debug-levitte-linux-elf","gcc:-DLEVITTE_DEBUG -DREF_CHECK -DCONF_DEBUG -DBN_CTX_DEBUG -DCRYPTO_MDEBUG -DL_ENDIAN -DTERMIO -D_POSIX_SOURCE -DPEDANTIC -ggdb -g3 -mcpu=i486 -pedantic -ansi -Wall -W -Wundef -Wshadow -Wid-clash-31 -Wcast-align -Wconversion -Wno-long-long -pipe::-D_REENTRANT::-ldl:BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:${x86_elf_asm}:dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)", 148"debug-levitte-linux-elf","gcc:-DLEVITTE_DEBUG -DREF_CHECK -DCONF_DEBUG -DBN_CTX_DEBUG -DCRYPTO_MDEBUG -DL_ENDIAN -DTERMIO -D_POSIX_SOURCE -DPEDANTIC -ggdb -g3 -mcpu=i486 -pedantic -ansi -Wall -Wshadow -Wcast-align -Wstrict-prototypes -Wmissing-prototypes -Wno-long-long -pipe::-D_REENTRANT::-ldl:BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:${x86_elf_asm}:dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
149"debug-levitte-linux-noasm","gcc:-DLEVITTE_DEBUG -DREF_CHECK -DCONF_DEBUG -DBN_CTX_DEBUG -DCRYPTO_MDEBUG -DOPENSSL_NO_ASM -DL_ENDIAN -DTERMIO -D_POSIX_SOURCE -DPEDANTIC -ggdb -g3 -mcpu=i486 -pedantic -ansi -Wall -W -Wundef -Wshadow -Wid-clash-31 -Wcast-align -Wconversion -Wno-long-long -pipe::-D_REENTRANT::-ldl:BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}::::::::::dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)", 149"debug-levitte-linux-noasm","gcc:-DLEVITTE_DEBUG -DREF_CHECK -DCONF_DEBUG -DBN_CTX_DEBUG -DCRYPTO_MDEBUG -DOPENSSL_NO_ASM -DL_ENDIAN -DTERMIO -D_POSIX_SOURCE -DPEDANTIC -ggdb -g3 -mcpu=i486 -pedantic -ansi -Wall -Wshadow -Wcast-align -Wstrict-prototypes -Wmissing-prototypes -Wno-long-long -pipe::-D_REENTRANT::-ldl:BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}::::::::::dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
150"debug-levitte-linux-elf-extreme","gcc:-DLEVITTE_DEBUG -DREF_CHECK -DCONF_DEBUG -DBN_CTX_DEBUG -DCRYPTO_MDEBUG -DL_ENDIAN -DTERMIO -D_POSIX_SOURCE -DPEDANTIC -ggdb -g3 -mcpu=i486 -pedantic -ansi -Wall -W -Wundef -Wshadow -Wcast-align -Wstrict-prototypes -Wmissing-prototypes -Wconversion -Wno-long-long -pipe::-D_REENTRANT::-ldl:BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:${x86_elf_asm}:dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
151"debug-levitte-linux-noasm-extreme","gcc:-DLEVITTE_DEBUG -DREF_CHECK -DCONF_DEBUG -DBN_CTX_DEBUG -DCRYPTO_MDEBUG -DOPENSSL_NO_ASM -DL_ENDIAN -DTERMIO -D_POSIX_SOURCE -DPEDANTIC -ggdb -g3 -mcpu=i486 -pedantic -ansi -Wall -W -Wundef -Wshadow -Wcast-align -Wstrict-prototypes -Wmissing-prototypes -Wconversion -Wno-long-long -pipe::-D_REENTRANT::-ldl:BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}::::::::::dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
150"dist", "cc:-O::(unknown)::::::", 152"dist", "cc:-O::(unknown)::::::",
151 153
152# Basic configs that should work on any (32 and less bit) box 154# Basic configs that should work on any (32 and less bit) box
@@ -159,25 +161,25 @@ my %table=(
159# surrounds it with #APP #NO_APP comment pair which (at least Solaris 161# surrounds it with #APP #NO_APP comment pair which (at least Solaris
160# 7_x86) /usr/ccs/bin/as fails to assemble with "Illegal mnemonic" 162# 7_x86) /usr/ccs/bin/as fails to assemble with "Illegal mnemonic"
161# error message. 163# error message.
162"solaris-x86-gcc","gcc:-O3 -fomit-frame-pointer -m486 -Wall -DL_ENDIAN -DOPENSSL_NO_INLINE_ASM::-D_REENTRANT::-lsocket -lnsl -ldl:BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:${x86_sol_asm}:dlfcn:solaris-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)", 164"solaris-x86-gcc","gcc:-O3 -fomit-frame-pointer -m486 -Wall -DL_ENDIAN -DOPENSSL_NO_INLINE_ASM::-D_REENTRANT::-lsocket -lnsl -ldl:BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:${x86_elf_asm}:dlfcn:solaris-shared:-fPIC:-shared:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
163 165
164#### Solaris x86 with Sun C setups 166#### Solaris x86 with Sun C setups
165"solaris-x86-cc","cc:-fast -O -Xa::-D_REENTRANT::-lsocket -lnsl -ldl:BN_LLONG RC4_CHAR RC4_CHUNK DES_PTR DES_UNROLL BF_PTR::::::::::dlfcn:solaris-shared:-KPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)", 167"solaris-x86-cc","cc:-fast -O -Xa::-D_REENTRANT::-lsocket -lnsl -ldl:BN_LLONG RC4_CHAR RC4_CHUNK DES_PTR DES_UNROLL BF_PTR::::::::::dlfcn:solaris-shared:-KPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
166 168
167#### SPARC Solaris with GNU C setups 169#### SPARC Solaris with GNU C setups
168"solaris-sparcv7-gcc","gcc:-O3 -fomit-frame-pointer -Wall -DB_ENDIAN -DBN_DIV2W::-D_REENTRANT::-lsocket -lnsl -ldl:BN_LLONG RC4_CHAR RC4_CHUNK DES_UNROLL BF_PTR::::::::::dlfcn:solaris-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)", 170"solaris-sparcv7-gcc","gcc:-O3 -fomit-frame-pointer -Wall -DB_ENDIAN -DBN_DIV2W::-D_REENTRANT::-lsocket -lnsl -ldl:BN_LLONG RC4_CHAR RC4_CHUNK DES_UNROLL BF_PTR::::::::::dlfcn:solaris-shared:-fPIC:-shared:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
169"solaris-sparcv8-gcc","gcc:-mv8 -O3 -fomit-frame-pointer -Wall -DB_ENDIAN -DBN_DIV2W::-D_REENTRANT::-lsocket -lnsl -ldl:BN_LLONG RC4_CHAR RC4_CHUNK DES_UNROLL BF_PTR:asm/sparcv8.o:::::::::dlfcn:solaris-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)", 171"solaris-sparcv8-gcc","gcc:-mv8 -O3 -fomit-frame-pointer -Wall -DB_ENDIAN -DBN_DIV2W::-D_REENTRANT::-lsocket -lnsl -ldl:BN_LLONG RC4_CHAR RC4_CHUNK DES_UNROLL BF_PTR:asm/sparcv8.o:::::::::dlfcn:solaris-shared:-fPIC:-shared:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
170# -m32 should be safe to add as long as driver recognizes -mcpu=ultrasparc 172# -m32 should be safe to add as long as driver recognizes -mcpu=ultrasparc
171"solaris-sparcv9-gcc","gcc:-m32 -mcpu=ultrasparc -O3 -fomit-frame-pointer -Wall -DB_ENDIAN -DBN_DIV2W::-D_REENTRANT:ULTRASPARC:-lsocket -lnsl -ldl:BN_LLONG RC4_CHAR RC4_CHUNK DES_UNROLL BF_PTR:asm/sparcv8plus.o:::asm/md5-sparcv8plus.o::::::dlfcn:solaris-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)", 173"solaris-sparcv9-gcc","gcc:-m32 -mcpu=ultrasparc -O3 -fomit-frame-pointer -Wall -DB_ENDIAN -DBN_DIV2W::-D_REENTRANT:ULTRASPARC:-lsocket -lnsl -ldl:BN_LLONG RC4_CHAR RC4_CHUNK DES_UNROLL BF_PTR:asm/sparcv8plus.o:::asm/md5-sparcv8plus.o::::::dlfcn:solaris-shared:-fPIC:-shared:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
172"solaris64-sparcv9-gcc31","gcc:-mcpu=ultrasparc -m64 -O3 -fomit-frame-pointer -Wall -DB_ENDIAN::-D_REENTRANT:ULTRASPARC:-lsocket -lnsl -ldl:SIXTY_FOUR_BIT_LONG RC4_CHAR RC4_CHUNK DES_INT DES_PTR DES_RISC1 DES_UNROLL BF_PTR::::asm/md5-sparcv9.o::::::dlfcn:solaris-shared:-fPIC:-m64:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)", 174"solaris64-sparcv9-gcc31","gcc:-mcpu=ultrasparc -m64 -O3 -fomit-frame-pointer -Wall -DB_ENDIAN::-D_REENTRANT:ULTRASPARC:-lsocket -lnsl -ldl:SIXTY_FOUR_BIT_LONG RC4_CHAR RC4_CHUNK DES_INT DES_PTR DES_RISC1 DES_UNROLL BF_PTR::::asm/md5-sparcv9.o::::::dlfcn:solaris-shared:-fPIC:-m64 -shared:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
173# gcc pre-2.8 doesn't understand -mcpu=ultrasparc, so fall down to -mv8 175# gcc pre-2.8 doesn't understand -mcpu=ultrasparc, so fall down to -mv8
174# but keep the assembler modules. 176# but keep the assembler modules.
175"solaris-sparcv9-gcc27","gcc:-mv8 -O3 -fomit-frame-pointer -Wall -DB_ENDIAN -DBN_DIV2W::-D_REENTRANT:ULTRASPARC:-lsocket -lnsl -ldl:BN_LLONG RC4_CHAR RC4_CHUNK DES_UNROLL BF_PTR:asm/sparcv8plus-gcc27.o:::asm/md5-sparcv8plus-gcc27.o::::::dlfcn:solaris-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)", 177"solaris-sparcv9-gcc27","gcc:-mv8 -O3 -fomit-frame-pointer -Wall -DB_ENDIAN -DBN_DIV2W::-D_REENTRANT:ULTRASPARC:-lsocket -lnsl -ldl:BN_LLONG RC4_CHAR RC4_CHUNK DES_UNROLL BF_PTR:asm/sparcv8plus-gcc27.o:::asm/md5-sparcv8plus-gcc27.o::::::dlfcn:solaris-shared:-fPIC:-shared:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
176"solaris64-sparcv9-gcc","gcc:-m64 -mcpu=ultrasparc -O3 -Wall -DB_ENDIAN::-D_REENTRANT:ULTRASPARC:-lsocket -lnsl -ldl:SIXTY_FOUR_BIT_LONG RC4_CHAR RC4_CHUNK DES_INT DES_PTR DES_RISC1 DES_UNROLL BF_PTR::::asm/md5-sparcv9.o::::::dlfcn:solaris-shared:-fPIC:-m64:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)", 178"solaris64-sparcv9-gcc","gcc:-m64 -mcpu=ultrasparc -O3 -Wall -DB_ENDIAN::-D_REENTRANT:ULTRASPARC:-lsocket -lnsl -ldl:SIXTY_FOUR_BIT_LONG RC4_CHAR RC4_CHUNK DES_INT DES_PTR DES_RISC1 DES_UNROLL BF_PTR::::asm/md5-sparcv9.o::::::dlfcn:solaris-shared:-fPIC:-m64 -shared:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
177 179
178#### 180####
179"debug-solaris-sparcv8-gcc","gcc:-DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DBN_CTX_DEBUG -DCRYPTO_MDEBUG_ALL -O -g -mv8 -Wall -DB_ENDIAN::-D_REENTRANT::-lsocket -lnsl -ldl:BN_LLONG RC4_CHAR RC4_CHUNK DES_UNROLL BF_PTR:asm/sparcv8.o:::::::::dlfcn:solaris-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)", 181"debug-solaris-sparcv8-gcc","gcc:-DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DBN_CTX_DEBUG -DCRYPTO_MDEBUG_ALL -O -g -mv8 -Wall -DB_ENDIAN::-D_REENTRANT::-lsocket -lnsl -ldl:BN_LLONG RC4_CHAR RC4_CHUNK DES_UNROLL BF_PTR:asm/sparcv8.o:::::::::dlfcn:solaris-shared:-fPIC:-shared:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
180"debug-solaris-sparcv9-gcc","gcc:-DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DBN_CTX_DEBUG -DCRYPTO_MDEBUG_ALL -O -g -mcpu=ultrasparc -Wall -DB_ENDIAN::-D_REENTRANT::-lsocket -lnsl -ldl:BN_LLONG RC4_CHAR RC4_CHUNK DES_UNROLL BF_PTR:asm/sparcv8plus.o:::::::::dlfcn:solaris-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)", 182"debug-solaris-sparcv9-gcc","gcc:-DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DBN_CTX_DEBUG -DCRYPTO_MDEBUG_ALL -O -g -mcpu=ultrasparc -Wall -DB_ENDIAN::-D_REENTRANT::-lsocket -lnsl -ldl:BN_LLONG RC4_CHAR RC4_CHUNK DES_UNROLL BF_PTR:asm/sparcv8plus.o:::::::::dlfcn:solaris-shared:-fPIC:-shared:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
181 183
182#### SPARC Solaris with Sun C setups 184#### SPARC Solaris with Sun C setups
183# DO NOT use /xO[34] on sparc with SC3.0. It is broken, and will not pass the tests 185# DO NOT use /xO[34] on sparc with SC3.0. It is broken, and will not pass the tests
@@ -201,13 +203,12 @@ my %table=(
201# it's a real mess with -mcpu=ultrasparc option under Linux, but 203# it's a real mess with -mcpu=ultrasparc option under Linux, but
202# -Wa,-Av8plus should do the trick no matter what. 204# -Wa,-Av8plus should do the trick no matter what.
203"linux-sparcv9","gcc:-mcpu=ultrasparc -DB_ENDIAN -DTERMIO -O3 -fomit-frame-pointer -Wall -Wa,-Av8plus -DBN_DIV2W::-D_REENTRANT:ULTRASPARC:-ldl:BN_LLONG RC4_CHAR RC4_CHUNK DES_UNROLL BF_PTR:asm/sparcv8plus.o:::asm/md5-sparcv8plus.o::::::dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)", 205"linux-sparcv9","gcc:-mcpu=ultrasparc -DB_ENDIAN -DTERMIO -O3 -fomit-frame-pointer -Wall -Wa,-Av8plus -DBN_DIV2W::-D_REENTRANT:ULTRASPARC:-ldl:BN_LLONG RC4_CHAR RC4_CHUNK DES_UNROLL BF_PTR:asm/sparcv8plus.o:::asm/md5-sparcv8plus.o::::::dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
204# !!!Folowing can't be even tested yet!!! 206# GCC 3.1 is a requirement
205# We have to wait till 64-bit glibc for SPARC is operational!!! 207"linux64-sparcv9","gcc:-m64 -mcpu=ultrasparc -DB_ENDIAN -DTERMIO -O3 -fomit-frame-pointer -Wall::-D_REENTRANT:ULTRASPARC:-ldl:SIXTY_FOUR_BIT_LONG RC4_CHAR RC4_CHUNK DES_UNROLL BF_PTR::::asm/md5-sparcv9.o::::::dlfcn:linux-shared:-fPIC:-m64:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
206#"linux64-sparcv9","sparc64-linux-gcc:-m64 -mcpu=v9 -DB_ENDIAN -DTERMIO -O3 -fomit-frame-pointer -Wall -DBN_DIV2W::-D_REENTRANT:ULTRASPARC::BN_LLONG RC4_CHAR RC4_CHUNK DES_UNROLL BF_PTR::::asm/md5-sparcv9.o:",
207 208
208# Sunos configs, assuming sparc for the gcc one. 209# Sunos configs, assuming sparc for the gcc one.
209##"sunos-cc", "cc:-O4 -DNOPROTO -DNOCONST::(unknown):::DES_UNROLL:::", 210##"sunos-cc", "cc:-O4 -DNOPROTO -DNOCONST::(unknown):SUNOS::DES_UNROLL:::",
210"sunos-gcc","gcc:-O3 -mv8 -Dssize_t=int::(unknown):::BN_LLONG RC4_CHAR RC4_CHUNK DES_UNROLL DES_PTR DES_RISC1:::", 211"sunos-gcc","gcc:-O3 -mv8 -Dssize_t=int::(unknown):SUNOS::BN_LLONG RC4_CHAR RC4_CHUNK DES_UNROLL DES_PTR DES_RISC1:::",
211 212
212#### IRIX 5.x configs 213#### IRIX 5.x configs
213# -mips2 flag is added by ./config when appropriate. 214# -mips2 flag is added by ./config when appropriate.
@@ -218,7 +219,7 @@ my %table=(
218# './Configure irix-[g]cc' manually. 219# './Configure irix-[g]cc' manually.
219# -mips4 flag is added by ./config when appropriate. 220# -mips4 flag is added by ./config when appropriate.
220"irix-mips3-gcc","gcc:-mabi=n32 -mmips-as -O3 -DTERMIOS -DB_ENDIAN -DBN_DIV3W::-D_SGI_MP_SOURCE:::MD2_CHAR RC4_INDEX RC4_CHAR RC4_CHUNK_LL DES_UNROLL DES_RISC2 DES_PTR BF_PTR SIXTY_FOUR_BIT:${mips3_irix_asm}:dlfcn:irix-shared:::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)", 221"irix-mips3-gcc","gcc:-mabi=n32 -mmips-as -O3 -DTERMIOS -DB_ENDIAN -DBN_DIV3W::-D_SGI_MP_SOURCE:::MD2_CHAR RC4_INDEX RC4_CHAR RC4_CHUNK_LL DES_UNROLL DES_RISC2 DES_PTR BF_PTR SIXTY_FOUR_BIT:${mips3_irix_asm}:dlfcn:irix-shared:::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
221"irix-mips3-cc", "cc:-n32 -O2 -use_readonly_const -DTERMIOS -DB_ENDIAN -DBN_DIV3W::-D_SGI_MP_SOURCE:::DES_PTR RC4_CHAR RC4_CHUNK_LL DES_RISC2 DES_UNROLL BF_PTR SIXTY_FOUR_BIT:${mips3_irix_asm}:dlfcn:irix-shared:::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)", 222"irix-mips3-cc", "cc:-n32 -mips3 -O2 -use_readonly_const -DTERMIOS -DB_ENDIAN -DBN_DIV3W::-D_SGI_MP_SOURCE:::DES_PTR RC4_CHAR RC4_CHUNK_LL DES_RISC2 DES_UNROLL BF_PTR SIXTY_FOUR_BIT:${mips3_irix_asm}:dlfcn:irix-shared:::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
222# N64 ABI builds. 223# N64 ABI builds.
223"irix64-mips4-gcc","gcc:-mabi=64 -mips4 -mmips-as -O3 -DTERMIOS -DB_ENDIAN -DBN_DIV3W::-D_SGI_MP_SOURCE:::RC4_CHAR RC4_CHUNK DES_RISC2 DES_UNROLL SIXTY_FOUR_BIT_LONG:${mips3_irix_asm}:dlfcn:irix-shared:::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)", 224"irix64-mips4-gcc","gcc:-mabi=64 -mips4 -mmips-as -O3 -DTERMIOS -DB_ENDIAN -DBN_DIV3W::-D_SGI_MP_SOURCE:::RC4_CHAR RC4_CHUNK DES_RISC2 DES_UNROLL SIXTY_FOUR_BIT_LONG:${mips3_irix_asm}:dlfcn:irix-shared:::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
224"irix64-mips4-cc", "cc:-64 -mips4 -O2 -use_readonly_const -DTERMIOS -DB_ENDIAN -DBN_DIV3W::-D_SGI_MP_SOURCE:::RC4_CHAR RC4_CHUNK DES_RISC2 DES_UNROLL SIXTY_FOUR_BIT_LONG:${mips3_irix_asm}:dlfcn:irix-shared:::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)", 225"irix64-mips4-cc", "cc:-64 -mips4 -O2 -use_readonly_const -DTERMIOS -DB_ENDIAN -DBN_DIV3W::-D_SGI_MP_SOURCE:::RC4_CHAR RC4_CHUNK DES_RISC2 DES_UNROLL SIXTY_FOUR_BIT_LONG:${mips3_irix_asm}:dlfcn:irix-shared:::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
@@ -261,22 +262,21 @@ my %table=(
261"hpux64-parisc-gcc","gcc:-DB_ENDIAN -DMD32_XARRAY::-D_REENTRANT::-ldl:SIXTY_FOUR_BIT_LONG MD2_CHAR RC4_INDEX RC4_CHAR DES_UNROLL DES_RISC1 DES_INT::::::::::dlfcn:hpux64-shared:-fpic::.sl.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)", 262"hpux64-parisc-gcc","gcc:-DB_ENDIAN -DMD32_XARRAY::-D_REENTRANT::-ldl:SIXTY_FOUR_BIT_LONG MD2_CHAR RC4_INDEX RC4_CHAR DES_UNROLL DES_RISC1 DES_INT::::::::::dlfcn:hpux64-shared:-fpic::.sl.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
262 263
263# IA-64 targets 264# IA-64 targets
264# I have no idea if this one actually works, feedback needed. <appro> 265"hpux-ia64-cc","cc:-Ae +DD32 +O3 +Olit=all -z -DB_ENDIAN::-D_REENTRANT::-ldl:SIXTY_FOUR_BIT MD2_CHAR RC4_INDEX RC4_CHAR DES_UNROLL DES_RISC1 DES_INT:asm/ia64-cpp.o:::::::::dlfcn:hpux-shared:+Z::.sl.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
265"hpux-ia64-cc","cc:-Ae +DD32 +O3 +ESlit -z -DB_ENDIAN::-D_REENTRANT::-ldl:SIXTY_FOUR_BIT MD2_CHAR RC4_INDEX RC4_CHAR DES_UNROLL DES_RISC1 DES_INT:asm/ia64-cpp.o:::::::::dlfcn:hpux-shared:+Z::.sl.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
266# Frank Geurts <frank.geurts@nl.abnamro.com> has patiently assisted with 266# Frank Geurts <frank.geurts@nl.abnamro.com> has patiently assisted with
267# with debugging of the following config. 267# with debugging of the following config.
268"hpux64-ia64-cc","cc:-Ae +DD64 +O3 +ESlit -z -DB_ENDIAN::-D_REENTRANT::-ldl:SIXTY_FOUR_BIT_LONG MD2_CHAR RC4_INDEX RC4_CHAR DES_UNROLL DES_RISC1 DES_INT:asm/ia64-cpp.o:::::::::dlfcn:hpux64-shared:+Z::.sl.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)", 268"hpux64-ia64-cc","cc:-Ae +DD64 +O3 +Olit=all -z -DB_ENDIAN::-D_REENTRANT::-ldl:SIXTY_FOUR_BIT_LONG MD2_CHAR RC4_INDEX RC4_CHAR DES_UNROLL DES_RISC1 DES_INT:asm/ia64-cpp.o:::::::::dlfcn:hpux64-shared:+Z::.sl.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
269 269
270# More attempts at unified 10.X and 11.X targets for HP C compiler. 270# More attempts at unified 10.X and 11.X targets for HP C compiler.
271# 271#
272# Chris Ruemmler <ruemmler@cup.hp.com> 272# Chris Ruemmler <ruemmler@cup.hp.com>
273# Kevin Steves <ks@hp.se> 273# Kevin Steves <ks@hp.se>
274"hpux-parisc-cc","cc:+O3 +Optrs_strongly_typed +Olibcalls -Ae +ESlit -DB_ENDIAN -DBN_DIV2W -DMD32_XARRAY::-D_REENTRANT::-Wl,+s -ldld:MD2_CHAR RC4_INDEX RC4_CHAR DES_UNROLL DES_RISC1 DES_INT::::::::::dl:hpux-shared:+Z::.sl.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)", 274"hpux-parisc-cc","cc:+O3 +Optrs_strongly_typed -Ae +ESlit -DB_ENDIAN -DBN_DIV2W -DMD32_XARRAY::-D_REENTRANT::-Wl,+s -ldld:MD2_CHAR RC4_INDEX RC4_CHAR DES_UNROLL DES_RISC1 DES_INT::::::::::dl:hpux-shared:+Z::.sl.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
275"hpux-parisc2-cc","cc:+DA2.0 +DS2.0 +O3 +Optrs_strongly_typed +Olibcalls -Ae +ESlit -DB_ENDIAN -DMD32_XARRAY::-D_REENTRANT::-Wl,+s -ldld:SIXTY_FOUR_BIT MD2_CHAR RC4_INDEX RC4_CHAR DES_UNROLL DES_RISC1 DES_INT:asm/pa-risc2.o:::::::::dl:hpux-shared:+Z::.sl.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)", 275"hpux-parisc2-cc","cc:+DA2.0 +DS2.0 +O3 +Optrs_strongly_typed -Ae +ESlit -DB_ENDIAN -DMD32_XARRAY::-D_REENTRANT::-Wl,+s -ldld:SIXTY_FOUR_BIT MD2_CHAR RC4_INDEX RC4_CHAR DES_UNROLL DES_RISC1 DES_INT:asm/pa-risc2.o:::::::::dl:hpux-shared:+Z::.sl.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
276"hpux64-parisc2-cc","cc:+DD64 +O3 +Optrs_strongly_typed +Olibcalls -Ae +ESlit -DB_ENDIAN -DMD32_XARRAY::-D_REENTRANT::-ldl:SIXTY_FOUR_BIT_LONG MD2_CHAR RC4_INDEX RC4_CHAR DES_UNROLL DES_RISC1 DES_INT:asm/pa-risc2W.o:::::::::dlfcn:hpux64-shared:+Z::.sl.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)", 276"hpux64-parisc2-cc","cc:+DD64 +O3 +Optrs_strongly_typed -Ae +ESlit -DB_ENDIAN -DMD32_XARRAY::-D_REENTRANT::-ldl:SIXTY_FOUR_BIT_LONG MD2_CHAR RC4_INDEX RC4_CHAR DES_UNROLL DES_RISC1 DES_INT:asm/pa-risc2W.o:::::::::dlfcn:hpux64-shared:+Z::.sl.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
277# Isn't the line below meaningless? HP-UX cc optimizes for host by default. 277# Isn't the line below meaningless? HP-UX cc optimizes for host by default.
278# hpux-parisc1_0-cc with +DAportable flag would make more sense. <appro> 278# hpux-parisc1_0-cc with +DAportable flag would make more sense. <appro>
279"hpux-parisc1_1-cc","cc:+DA1.1 +DS1.1 +O3 +Optrs_strongly_typed +Olibcalls -Ae +ESlit -DB_ENDIAN -DMD32_XARRAY::-D_REENTRANT::-Wl,+s -ldld:MD2_CHAR RC4_INDEX RC4_CHAR DES_UNROLL DES_RISC1 DES_INT::::::::::dl:hpux-shared:+Z::.sl.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)", 279"hpux-parisc1_1-cc","cc:+DA1.1 +DS1.1 +O3 +Optrs_strongly_typed -Ae +ESlit -DB_ENDIAN -DMD32_XARRAY::-D_REENTRANT::-Wl,+s -ldld:MD2_CHAR RC4_INDEX RC4_CHAR DES_UNROLL DES_RISC1 DES_INT::::::::::dl:hpux-shared:+Z::.sl.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
280 280
281# HPUX 9.X config. 281# HPUX 9.X config.
282# Don't use the bundled cc. It is broken. Use HP ANSI C if possible, or 282# Don't use the bundled cc. It is broken. Use HP ANSI C if possible, or
@@ -383,17 +383,21 @@ my %table=(
383"debug-linux-elf","gcc:-DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DBN_CTX_DEBUG -DCRYPTO_MDEBUG -DL_ENDIAN -DTERMIO -g -m486 -Wall::-D_REENTRANT::-lefence -ldl:BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:${x86_elf_asm}:dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)", 383"debug-linux-elf","gcc:-DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DBN_CTX_DEBUG -DCRYPTO_MDEBUG -DL_ENDIAN -DTERMIO -g -m486 -Wall::-D_REENTRANT::-lefence -ldl:BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:${x86_elf_asm}:dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
384"debug-linux-elf-noefence","gcc:-DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DBN_CTX_DEBUG -DCRYPTO_MDEBUG -DL_ENDIAN -DTERMIO -g -m486 -Wall::-D_REENTRANT::-ldl:BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:${x86_elf_asm}:dlfcn", 384"debug-linux-elf-noefence","gcc:-DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DBN_CTX_DEBUG -DCRYPTO_MDEBUG -DL_ENDIAN -DTERMIO -g -m486 -Wall::-D_REENTRANT::-ldl:BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:${x86_elf_asm}:dlfcn",
385"linux-aout", "gcc:-DL_ENDIAN -DTERMIO -O3 -fomit-frame-pointer -m486 -Wall::(unknown):::BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:${x86_out_asm}", 385"linux-aout", "gcc:-DL_ENDIAN -DTERMIO -O3 -fomit-frame-pointer -m486 -Wall::(unknown):::BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:${x86_out_asm}",
386"linux-mipsel", "gcc:-DL_ENDIAN -DTERMIO -O3 -fomit-frame-pointer -Wall::(unknown):::BN_LLONG:::", 386"linux-mipsel", "gcc:-DL_ENDIAN -DTERMIO -O3 -fomit-frame-pointer -Wall::-D_REENTRANT::-ldl:BN_LLONG RC2_CHAR RC4_INDEX DES_INT DES_UNROLL DES_RISC2::::::::::dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
387"linux-mips", "gcc:-DB_ENDIAN -DTERMIO -O3 -fomit-frame-pointer -Wall::(unknown):::BN_LLONG:::", 387"linux-mips", "gcc:-DB_ENDIAN -DTERMIO -O3 -fomit-frame-pointer -Wall::-D_REENTRANT::-ldl:BN_LLONG RC2_CHAR RC4_INDEX DES_INT DES_UNROLL DES_RISC2::::::::::dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
388"linux-ppc", "gcc:-DB_ENDIAN -DTERMIO -O3 -fomit-frame-pointer -Wall::-D_REENTRANT::-ldl:BN_LLONG RC4_CHAR RC4_CHUNK DES_RISC1 DES_UNROLL::::::::::dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)", 388"linux-ppc", "gcc:-DB_ENDIAN -DTERMIO -O3 -fomit-frame-pointer -Wall::-D_REENTRANT::-ldl:BN_LLONG RC4_CHAR RC4_CHUNK DES_RISC1 DES_UNROLL::::::::::dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
389"linux-m68k", "gcc:-DB_ENDIAN -DTERMIO -O2 -fomit-frame-pointer -Wall::-D_REENTRANT:::BN_LLONG::", 389"linux-m68k", "gcc:-DB_ENDIAN -DTERMIO -O2 -fomit-frame-pointer -Wall::-D_REENTRANT:::BN_LLONG::",
390"linux-s390", "gcc:-DB_ENDIAN -DTERMIO -DNO_ASM -O3 -fomit-frame-pointer -Wall::-D_REENTRANT::-ldl:BN_LLONG::::::::::dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)", 390"linux-s390", "gcc:-DB_ENDIAN -DTERMIO -DNO_ASM -O3 -fomit-frame-pointer -Wall::-D_REENTRANT::-ldl:BN_LLONG::::::::::dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
391"linux-s390x", "gcc:-DB_ENDIAN -DTERMIO -DNO_ASM -O3 -fomit-frame-pointer -Wall::-D_REENTRANT::-ldl:SIXTY_FOUR_BIT_LONG::::::::::dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)", 391"linux-s390x", "gcc:-DB_ENDIAN -DTERMIO -DNO_ASM -O3 -fomit-frame-pointer -Wall::-D_REENTRANT::-ldl:SIXTY_FOUR_BIT_LONG::::::::::dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
392"linux-ia64", "gcc:-DL_ENDIAN -DTERMIO -O3 -fomit-frame-pointer -Wall::-D_REENTRANT::-ldl:SIXTY_FOUR_BIT_LONG RC4_CHUNK RC4_CHAR:asm/ia64.o:::::::::dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)", 392"linux-ia64", "gcc:-DL_ENDIAN -DTERMIO -O3 -fomit-frame-pointer -Wall::-D_REENTRANT::-ldl:SIXTY_FOUR_BIT_LONG RC4_CHUNK RC4_CHAR:asm/ia64.o:::::::::dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
393"linux-ia64-ecc", "ecc:-DL_ENDIAN -DTERMIO -O2 -Wall::-D_REENTRANT::-ldl:SIXTY_FOUR_BIT_LONG RC4_CHUNK RC4_CHAR:asm/ia64.o:::::::::dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
394"linux-x86_64", "gcc:-m64 -DL_ENDIAN -DTERMIO -O3 -Wall -DMD32_REG_T=int::-D_REENTRANT::-ldl:SIXTY_FOUR_BIT_LONG RC4_CHUNK RC4_CHAR BF_PTR2 DES_INT DES_UNROLL:asm/x86_64-gcc.o:::::::::dlfcn:linux-shared:-fPIC:-m64:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
393"NetBSD-sparc", "gcc:-DTERMIOS -O3 -fomit-frame-pointer -mv8 -Wall -DB_ENDIAN::(unknown):::BN_LLONG MD2_CHAR RC4_INDEX DES_UNROLL::::::::::dlfcn:bsd-gcc-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)", 395"NetBSD-sparc", "gcc:-DTERMIOS -O3 -fomit-frame-pointer -mv8 -Wall -DB_ENDIAN::(unknown):::BN_LLONG MD2_CHAR RC4_INDEX DES_UNROLL::::::::::dlfcn:bsd-gcc-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
394"NetBSD-m68", "gcc:-DTERMIOS -O3 -fomit-frame-pointer -Wall -DB_ENDIAN::(unknown):::BN_LLONG MD2_CHAR RC4_INDEX DES_UNROLL::::::::::dlfcn:bsd-gcc-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)", 396"NetBSD-m68", "gcc:-DTERMIOS -O3 -fomit-frame-pointer -Wall -DB_ENDIAN::(unknown):::BN_LLONG MD2_CHAR RC4_INDEX DES_UNROLL::::::::::dlfcn:bsd-gcc-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
395"NetBSD-x86", "gcc:-DTERMIOS -O3 -fomit-frame-pointer -m486 -Wall::(unknown):::BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}::::::::::dlfcn:bsd-gcc-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)", 397"NetBSD-x86", "gcc:-DTERMIOS -O3 -fomit-frame-pointer -m486 -Wall::(unknown):::BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}::::::::::dlfcn:bsd-gcc-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
396"FreeBSD-elf", "gcc:-DTERMIOS -DL_ENDIAN -fomit-frame-pointer -O3 -m486 -Wall::-pthread -D_REENTRANT -D_THREAD_SAFE -D_THREADSAFE:::BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:${x86_elf_asm}:dlfcn:bsd-gcc-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)", 398"FreeBSD-elf", "gcc:-DTERMIOS -DL_ENDIAN -fomit-frame-pointer -O3 -m486 -Wall::-pthread -D_REENTRANT -D_THREAD_SAFE -D_THREADSAFE:::BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:${x86_elf_asm}:dlfcn:bsd-gcc-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
399"FreeBSD-sparc64","gcc:-DB_ENDIAN -DTERMIOS -O3 -fomit-frame-pointer::-pthread -D_REENTRANT -D_THREAD_SAFE -D_THREADSAFE:::SIXTY_FOUR_BIT_LONG DES_INT DES_PTR DES_RISC2 BF_PTR::::::::::dlfcn:bsd-gcc-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
400"FreeBSD-ia64","gcc:-DL_ENDIAN -DTERMIOS -O -fomit-frame-pointer::(unknown):::SIXTY_FOUR_BIT_LONG RC4_CHUNK RC4_CHAR:asm/ia64-cpp.o:::::::::dlfcn:bsd-gcc-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
397"FreeBSD", "gcc:-DTERMIOS -DL_ENDIAN -fomit-frame-pointer -O3 -m486 -Wall::(unknown):::BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:${x86_out_asm}", 401"FreeBSD", "gcc:-DTERMIOS -DL_ENDIAN -fomit-frame-pointer -O3 -m486 -Wall::(unknown):::BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:${x86_out_asm}",
398"bsdi-gcc", "gcc:-O3 -ffast-math -DL_ENDIAN -DPERL5 -m486::(unknown):::RSA_LLONG ${x86_gcc_des} ${x86_gcc_opts}:${x86_bsdi_asm}", 402"bsdi-gcc", "gcc:-O3 -ffast-math -DL_ENDIAN -DPERL5 -m486::(unknown):::RSA_LLONG ${x86_gcc_des} ${x86_gcc_opts}:${x86_bsdi_asm}",
399"bsdi-elf-gcc", "gcc:-DPERL5 -DL_ENDIAN -fomit-frame-pointer -O3 -m486 -Wall::(unknown)::-ldl:BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:${x86_elf_asm}:dlfcn:bsd-gcc-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)", 403"bsdi-elf-gcc", "gcc:-DPERL5 -DL_ENDIAN -fomit-frame-pointer -O3 -m486 -Wall::(unknown)::-ldl:BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:${x86_elf_asm}:dlfcn:bsd-gcc-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
@@ -401,7 +405,7 @@ my %table=(
401"nextstep3.3", "cc:-O3 -Wall:<libc.h>:(unknown):::BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:::", 405"nextstep3.3", "cc:-O3 -Wall:<libc.h>:(unknown):::BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:::",
402 406
403# NCR MP-RAS UNIX ver 02.03.01 407# NCR MP-RAS UNIX ver 02.03.01
404"ncr-scde","cc:-O6 -Xa -Hoff=BEHAVED -686 -Hwide -Hiw::(unknown)::-lsocket -lnsl:${x86_gcc_des} ${x86_gcc_opts}:::", 408"ncr-scde","cc:-O6 -Xa -Hoff=BEHAVED -686 -Hwide -Hiw::(unknown)::-lsocket -lnsl -lc89:${x86_gcc_des} ${x86_gcc_opts}:::",
405 409
406# QNX 4 410# QNX 4
407"qnx4", "cc:-DL_ENDIAN -DTERMIO::(unknown):::${x86_gcc_des} ${x86_gcc_opts}:", 411"qnx4", "cc:-DL_ENDIAN -DTERMIO::(unknown):::${x86_gcc_des} ${x86_gcc_opts}:",
@@ -412,33 +416,36 @@ my %table=(
412# Linux on ARM 416# Linux on ARM
413"linux-elf-arm","gcc:-DL_ENDIAN -DTERMIO -O3 -fomit-frame-pointer -Wall::-D_REENTRANT:::BN_LLONG::::::::::dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)", 417"linux-elf-arm","gcc:-DL_ENDIAN -DTERMIO -O3 -fomit-frame-pointer -Wall::-D_REENTRANT:::BN_LLONG::::::::::dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
414 418
419# SCO/Caldera targets.
420#
421# Originally we had like unixware-*, unixware-*-pentium, unixware-*-p6, etc.
422# Now we only have blended unixware-* as it's the only one used by ./config.
423# If you want to optimize for particular microarchitecture, bypass ./config
424# and './Configure unixware-7 -Kpentium_pro' or whatever appropriate.
425# Note that not all targets include assembler support. Mostly because of
426# lack of motivation to support out-of-date platforms with out-of-date
427# compiler drivers and assemblers. Tim Rice <tim@multitalents.net> has
428# patiently assisted to debug most of it.
429#
415# UnixWare 2.0x fails destest with -O 430# UnixWare 2.0x fails destest with -O
416"unixware-2.0","cc:-DFILIO_H -DNO_STRINGS_H::-Kthread::-lsocket -lnsl -lresolv -lx:${x86_gcc_des} ${x86_gcc_opts}:::", 431"unixware-2.0","cc:-DFILIO_H -DNO_STRINGS_H::-Kthread::-lsocket -lnsl -lresolv -lx:${x86_gcc_des} ${x86_gcc_opts}:::",
417"unixware-2.0-pentium","cc:-DFILIO_H -DNO_STRINGS_H -Kpentium::-Kthread::-lsocket -lnsl -lresolv -lx:MD2_CHAR RC4_INDEX ${x86_gcc_des}::",
418
419# UnixWare 2.1
420"unixware-2.1","cc:-O -DFILIO_H::-Kthread::-lsocket -lnsl -lresolv -lx:${x86_gcc_des} ${x86_gcc_opts}:::", 432"unixware-2.1","cc:-O -DFILIO_H::-Kthread::-lsocket -lnsl -lresolv -lx:${x86_gcc_des} ${x86_gcc_opts}:::",
421"unixware-2.1-pentium","cc:-O -DFILIO_H -Kpentium::-Kthread::-lsocket -lnsl -lresolv -lx:MD2_CHAR RC4_INDEX ${x86_gcc_des}::", 433"unixware-7","cc:-O -DFILIO_H -Kalloca::-Kthread::-lsocket -lnsl:BN_LLONG MD2_CHAR RC4_INDEX ${x86_gcc_des}:${x86_elf_asm}:dlfcn:svr5-shared:-Kpic::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
422"unixware-2.1-p6","cc:-O -DFILIO_H -Kp6::-Kthread::-lsocket -lnsl -lresolv -lx:MD2_CHAR RC4_INDEX ${x86_gcc_des}::", 434"unixware-7-gcc","gcc:-DL_ENDIAN -DFILIO_H -O3 -fomit-frame-pointer -m486 -Wall::-D_REENTRANT::-lsocket -lnsl:BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:${x86_elf_asm}:dlfcn:gnu-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
423 435"OpenUNIX-8","cc:-O -DFILIO_H -Kalloca::-Kthread::-lsocket -lnsl:BN_LLONG MD2_CHAR RC4_INDEX ${x86_gcc_des}:${x86_elf_asm}:dlfcn:svr5-shared:-Kpic::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
424# UnixWare 7 436"OpenUNIX-8-gcc","gcc:-O -DFILIO_H -fomit-frame-pointer::-pthread::-lsocket -lnsl:BN_LLONG MD2_CHAR RC4_INDEX ${x86_gcc_des}:${x86_elf_asm}:dlfcn:svr5-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
425"unixware-7","cc:-O -DFILIO_H -Kalloca::-Kthread::-lsocket -lnsl:BN_LLONG MD2_CHAR RC4_INDEX ${x86_gcc_des}::::::::::dlfcn:svr5-shared:-Kpic::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)", 437"sco3-gcc", "gcc:-O3 -fomit-frame-pointer -Dssize_t=int -DNO_SYS_UN_H::(unknown)::-lsocket:BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:::", # the SCO assembler doesn't seem to like our assembler files ...
426"unixware-7-pentium","cc:-O -DFILIO_H -Kalloca -Kpentium::-Kthread::-lsocket -lnsl:BN_LLONG MD2_CHAR RC4_INDEX ${x86_gcc_des}::::::::::dlfcn:svr5-shared:-Kpic::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)", 438# SCO 5 - Ben Laurie <ben@algroup.co.uk> says the -O breaks the SCO cc.
427"unixware-7-pentium_pro","cc:-O -DFILIO_H -Kalloca -Kpentium_pro::-Kthread::-lsocket -lnsl:BN_LLONG MD2_CHAR RC4_INDEX ${x86_gcc_des}::::::::::dlfcn:svr5-shared:-Kpic::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)", 439"sco5-cc", "cc:-belf::(unknown)::-lsocket -lnsl:${x86_gcc_des} ${x86_gcc_opts}:${x86_elf_asm}:dlfcn:svr3-shared:-Kpic::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
428"unixware-7-gcc","gcc:-DL_ENDIAN -DFILIO_H -O3 -fomit-frame-pointer -m486 -Wall::-D_REENTRANT::-lsocket -lnsl:BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}::::::::::dlfcn:gnu-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)", 440"sco5-gcc", "gcc:-O3 -fomit-frame-pointer::(unknown)::-lsocket -lnsl:BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:${x86_elf_asm}:dlfcn:svr3-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
429 441
430# OpenUNIX 8
431"OpenUNIX-8","cc:-O -DFILIO_H -Kalloca::-Kthread::-lsocket -lnsl:BN_LLONG MD2_CHAR RC4_INDEX ${x86_gcc_des}::::::::::dlfcn:svr5-shared:-Kpic::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
432"OpenUNIX-8-gcc","gcc:-O -DFILIO_H -fomit-frame-pointer::-pthread::-lsocket -lnsl:BN_LLONG MD2_CHAR RC4_INDEX ${x86_gcc_des}::::::::::dlfcn:svr5-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
433"OpenUNIX-8-pentium","cc:-O -DFILIO_H -Kalloca -Kpentium::-Kthread::-lsocket -lnsl:BN_LLONG MD2_CHAR RC4_INDEX ${x86_gcc_des}::::::::::dlfcn:svr5-shared:-Kpic::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
434"OpenUNIX-8-pentium_pro","cc:-O -DFILIO_H -Kalloca -Kpentium_pro::-Kthread::-lsocket -lnsl:BN_LLONG MD2_CHAR RC4_INDEX ${x86_gcc_des}::::::::::dlfcn:svr5-shared:-Kpic::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
435 442
436# IBM's AIX. 443# IBM's AIX.
437"aix-cc", "cc:-O -DB_ENDIAN -qmaxmem=16384::(unknown):AIX::BN_LLONG RC4_CHAR:::", 444"aix-cc", "cc:-O -DB_ENDIAN -qmaxmem=16384::(unknown):AIX::BN_LLONG RC4_CHAR:::",
438"aix-gcc", "gcc:-O3 -DB_ENDIAN::(unknown):AIX::BN_LLONG RC4_CHAR:::", 445"aix-gcc", "gcc:-O3 -DB_ENDIAN::(unknown):AIX::BN_LLONG RC4_CHAR:::",
439"aix43-cc", "cc:-O -DAIX -DB_ENDIAN -qmaxmem=16384::(unknown):::BN_LLONG RC4_CHAR::::::::::dlfcn:", 446"aix43-cc", "cc:-O -DAIX -DB_ENDIAN -qmaxmem=16384::(unknown):::BN_LLONG RC4_CHAR::::::::::dlfcn:aix-shared:::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)::",
440"aix43-gcc", "gcc:-O3 -DAIX -DB_ENDIAN::(unknown):::BN_LLONG RC4_CHAR::::::::::dlfcn:", 447"aix43-gcc", "gcc:-O1 -DAIX -DB_ENDIAN::(unknown):::BN_LLONG RC4_CHAR::::::::::dlfcn:",
441"aix64-cc", "cc:-O -DAIX -DB_ENDIAN -qmaxmem=16384 -q64::(unknown):::SIXTY_FOUR_BIT_LONG RC4_CHAR::::::::::dlfcn::::::-X 64", 448"aix64-cc", "cc:-O -DAIX -DB_ENDIAN -qmaxmem=16384 -q64::(unknown):::SIXTY_FOUR_BIT_LONG RC4_CHAR::::::::::dlfcn:aix-shared::-q64:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)::-X 64",
442 449
443# 450#
444# Cray T90 and similar (SDSC) 451# Cray T90 and similar (SDSC)
@@ -471,15 +478,6 @@ my %table=(
471"dgux-R4-gcc", "gcc:-O3 -fomit-frame-pointer::(unknown)::-lnsl -lsocket:RC4_INDEX DES_UNROLL:::", 478"dgux-R4-gcc", "gcc:-O3 -fomit-frame-pointer::(unknown)::-lnsl -lsocket:RC4_INDEX DES_UNROLL:::",
472"dgux-R4-x86-gcc", "gcc:-O3 -fomit-frame-pointer -DL_ENDIAN::(unknown)::-lnsl -lsocket:BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:${x86_elf_asm}", 479"dgux-R4-x86-gcc", "gcc:-O3 -fomit-frame-pointer -DL_ENDIAN::(unknown)::-lnsl -lsocket:BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:${x86_elf_asm}",
473 480
474# SCO 3 - Tim Rice <tim@multitalents.net>
475"sco3-gcc", "gcc:-O3 -fomit-frame-pointer -Dssize_t=int -DNO_SYS_UN_H::(unknown)::-lsocket:BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:::", # the SCO assembler doesn't seem to like our assembler files ...
476
477# SCO 5 - Ben Laurie <ben@algroup.co.uk> says the -O breaks the
478# SCO cc.
479"sco5-cc", "cc:-belf::(unknown)::-lsocket -lresolv -lnsl:${x86_gcc_des} ${x86_gcc_opts}::::::::::dlfcn:svr3-shared:-Kpic", # des options?
480"sco5-cc-pentium", "cc:-Kpentium::(unknown)::-lsocket:${x86_gcc_des} ${x86_gcc_opts}:::", # des options?
481"sco5-gcc", "gcc:-O3 -fomit-frame-pointer::(unknown)::-lsocket -lresolv -lnsl:BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:${x86_elf_asm}:dlfcn:svr3-shared:-fPIC", # the SCO assembler doesn't seem to like our assembler files ...
482
483# Sinix/ReliantUNIX RM400 481# Sinix/ReliantUNIX RM400
484# NOTE: The CDS++ Compiler up to V2.0Bsomething has the IRIX_CC_BUG optimizer problem. Better use -g */ 482# NOTE: The CDS++ Compiler up to V2.0Bsomething has the IRIX_CC_BUG optimizer problem. Better use -g */
485"ReliantUNIX","cc:-KPIC -g -DTERMIOS -DB_ENDIAN::-Kthread:SNI:-lsocket -lnsl -lc -L/usr/ucblib -lucb:BN_LLONG DES_PTR DES_RISC2 DES_UNROLL BF_PTR::::::::::dlfcn:reliantunix-shared:::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)", 483"ReliantUNIX","cc:-KPIC -g -DTERMIOS -DB_ENDIAN::-Kthread:SNI:-lsocket -lnsl -lc -L/usr/ucblib -lucb:BN_LLONG DES_PTR DES_RISC2 DES_UNROLL BF_PTR::::::::::dlfcn:reliantunix-shared:::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
@@ -498,6 +496,7 @@ my %table=(
498# Windows NT, Microsoft Visual C++ 4.0 496# Windows NT, Microsoft Visual C++ 4.0
499 497
500"VC-NT","cl::::WINNT::BN_LLONG RC4_INDEX EXPORT_VAR_AS_FN ${x86_gcc_opts}::::::::::win32", 498"VC-NT","cl::::WINNT::BN_LLONG RC4_INDEX EXPORT_VAR_AS_FN ${x86_gcc_opts}::::::::::win32",
499"VC-CE","cl::::WINCE::BN_LLONG RC4_INDEX EXPORT_VAR_AS_FN ${x86_gcc_opts}::::::::::win32",
501"VC-WIN32","cl::::WIN32::BN_LLONG RC4_INDEX EXPORT_VAR_AS_FN ${x86_gcc_opts}::::::::::win32", 500"VC-WIN32","cl::::WIN32::BN_LLONG RC4_INDEX EXPORT_VAR_AS_FN ${x86_gcc_opts}::::::::::win32",
502"VC-WIN16","cl:::(unknown):WIN16::MD2_CHAR DES_UNROLL DES_PTR RC4_INDEX THIRTY_TWO_BIT:::", 501"VC-WIN16","cl:::(unknown):WIN16::MD2_CHAR DES_UNROLL DES_PTR RC4_INDEX THIRTY_TWO_BIT:::",
503"VC-W31-16","cl:::(unknown):WIN16::BN_LLONG MD2_CHAR DES_UNROLL DES_PTR RC4_INDEX SIXTEEN_BIT:::", 502"VC-W31-16","cl:::(unknown):WIN16::BN_LLONG MD2_CHAR DES_UNROLL DES_PTR RC4_INDEX SIXTEEN_BIT:::",
@@ -505,26 +504,24 @@ my %table=(
505"VC-MSDOS","cl:::(unknown):MSDOS::BN_LLONG MD2_CHAR DES_UNROLL DES_PTR RC4_INDEX SIXTEEN_BIT:::", 504"VC-MSDOS","cl:::(unknown):MSDOS::BN_LLONG MD2_CHAR DES_UNROLL DES_PTR RC4_INDEX SIXTEEN_BIT:::",
506 505
507# Borland C++ 4.5 506# Borland C++ 4.5
508"BC-32","bcc32::::WIN32::BN_LLONG DES_PTR RC4_INDEX::::::::::win32", 507"BC-32","bcc32::::WIN32::BN_LLONG DES_PTR RC4_INDEX EXPORT_VAR_AS_FN::::::::::win32",
509"BC-16","bcc:::(unknown):WIN16::BN_LLONG DES_PTR RC4_INDEX SIXTEEN_BIT:::", 508"BC-16","bcc:::(unknown):WIN16::BN_LLONG DES_PTR RC4_INDEX SIXTEEN_BIT:::",
510 509
511# Mingw32 510# MinGW
512# (Note: the real CFLAGS for Windows builds are defined by util/mk1mf.pl 511"mingw", "gcc:-DL_ENDIAN -fomit-frame-pointer -O3 -march=i486 -mno-cygwin -Wall:::MINGW32:-mno-cygwin -lwsock32 -lgdi32:BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:${x86_out_asm}:win32::::.dll",
513# and its library files in util/pl/*)
514"Mingw32", "gcc:-DL_ENDIAN -fomit-frame-pointer -O3 -m486 -Wall:::::BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}::::::::::win32",
515 512
516# UWIN 513# UWIN
517"UWIN", "cc:-DTERMIOS -DL_ENDIAN -O -Wall:::UWIN::BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}::::::::::win32", 514"UWIN", "cc:-DTERMIOS -DL_ENDIAN -O -Wall:::UWIN::BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}::::::::::win32",
518 515
519# Cygwin 516# Cygwin
520"Cygwin-pre1.3", "gcc:-DTERMIOS -DL_ENDIAN -fomit-frame-pointer -O3 -m486 -Wall::(unknown):CYGWIN32::BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}::::::::::win32", 517"Cygwin-pre1.3", "gcc:-DTERMIOS -DL_ENDIAN -fomit-frame-pointer -O3 -m486 -Wall::(unknown):CYGWIN32::BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}::::::::::win32",
521"Cygwin", "gcc:-DTERMIOS -DL_ENDIAN -fomit-frame-pointer -O3 -m486 -Wall:::CYGWIN32::BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:${x86_out_asm}:win32:cygwin-shared:::.dll", 518"Cygwin", "gcc:-DTERMIOS -DL_ENDIAN -fomit-frame-pointer -O3 -march=i486 -Wall:::CYGWIN32::BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:${x86_out_asm}:win32:cygwin-shared:::.dll",
522 519
523# DJGPP 520# DJGPP
524"DJGPP", "gcc:-I/dev/env/DJDIR/watt32/inc -DTERMIOS -DL_ENDIAN -fomit-frame-pointer -O2 -Wall:::MSDOS:-L/dev/env/DJDIR/watt32/lib -lwatt:BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}::::::::::", 521"DJGPP", "gcc:-I/dev/env/WATT_ROOT/inc -DTERMIOS -DL_ENDIAN -fomit-frame-pointer -O2 -Wall:::MSDOS:-L/dev/env/WATT_ROOT/lib -lwatt:BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}::::::::::",
525 522
526# Ultrix from Bernhard Simon <simon@zid.tuwien.ac.at> 523# Ultrix from Bernhard Simon <simon@zid.tuwien.ac.at>
527"ultrix-cc","cc:-std1 -O -Olimit 1000 -DL_ENDIAN::(unknown):::::::", 524"ultrix-cc","cc:-std1 -O -Olimit 2500 -DL_ENDIAN::(unknown):::::::",
528"ultrix-gcc","gcc:-O3 -DL_ENDIAN::(unknown):::::::", 525"ultrix-gcc","gcc:-O3 -DL_ENDIAN::(unknown):::::::",
529# K&R C is no longer supported; you need gcc on old Ultrix installations 526# K&R C is no longer supported; you need gcc on old Ultrix installations
530##"ultrix","cc:-O2 -DNOPROTO -DNOCONST -DL_ENDIAN::(unknown):::::::", 527##"ultrix","cc:-O2 -DNOPROTO -DNOCONST -DL_ENDIAN::(unknown):::::::",
@@ -543,10 +540,13 @@ my %table=(
543"OpenBSD-hppa", "gcc:-DTERMIOS -O3 -fomit-frame-pointer::(unknown):::BN_LLONG RC2_CHAR RC4_INDEX DES_UNROLL::::::::::dlfcn:bsd-gcc-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)", 540"OpenBSD-hppa", "gcc:-DTERMIOS -O3 -fomit-frame-pointer::(unknown):::BN_LLONG RC2_CHAR RC4_INDEX DES_UNROLL::::::::::dlfcn:bsd-gcc-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
544 541
545##### MacOS X (a.k.a. Rhapsody or Darwin) setup 542##### MacOS X (a.k.a. Rhapsody or Darwin) setup
546"rhapsody-ppc-cc","cc:-O3 -DB_ENDIAN::(unknown):MACOSX::BN_LLONG RC4_CHAR RC4_CHUNK DES_UNROLL BF_PTR:::", 543"rhapsody-ppc-cc","cc:-O3 -DB_ENDIAN::(unknown):MACOSX_RHAPSODY::BN_LLONG RC4_CHAR RC4_CHUNK DES_UNROLL BF_PTR:::",
547"darwin-ppc-cc","cc:-O3 -fomit-frame-pointer -fno-common -DB_ENDIAN::-D_REENTRANT:MACOSX::BN_LLONG RC4_CHAR RC4_CHUNK DES_UNROLL BF_PTR:::::::::::darwin-shared:-fPIC::.\$(SHLIB_MAJOR).\$(SHLIB_MINOR).dylib", 544"darwin-ppc-cc","cc:-O3 -fomit-frame-pointer -fno-common -DB_ENDIAN::-D_REENTRANT:MACOSX::BN_LLONG RC4_CHAR RC4_CHUNK DES_UNROLL BF_PTR:::::::::::darwin-shared:-fPIC::.\$(SHLIB_MAJOR).\$(SHLIB_MINOR).dylib",
548"darwin-i386-cc","cc:-O3 -fomit-frame-pointer -fno-common -DB_ENDIAN::-D_REENTRANT:MACOSX::BN_LLONG RC4_CHAR RC4_CHUNK DES_UNROLL BF_PTR:::::::::::darwin-shared:-fPIC::.\$(SHLIB_MAJOR).\$(SHLIB_MINOR).dylib", 545"darwin-i386-cc","cc:-O3 -fomit-frame-pointer -fno-common -DB_ENDIAN::-D_REENTRANT:MACOSX::BN_LLONG RC4_CHAR RC4_CHUNK DES_UNROLL BF_PTR:::::::::::darwin-shared:-fPIC::.\$(SHLIB_MAJOR).\$(SHLIB_MINOR).dylib",
549 546
547##### A/UX
548"aux3-gcc","gcc:-O2 -DTERMIO::(unknown):AUX:-lbsd:RC4_CHAR RC4_CHUNK DES_UNROLL BF_PTR:::",
549
550##### Sony NEWS-OS 4.x 550##### Sony NEWS-OS 4.x
551"newsos4-gcc","gcc:-O -DB_ENDIAN::(unknown):NEWS4:-lmld -liberty:BN_LLONG RC4_CHAR RC4_CHUNK DES_PTR DES_RISC1 DES_UNROLL BF_PTR::::", 551"newsos4-gcc","gcc:-O -DB_ENDIAN::(unknown):NEWS4:-lmld -liberty:BN_LLONG RC4_CHAR RC4_CHUNK DES_PTR DES_RISC1 DES_UNROLL BF_PTR::::",
552 552
@@ -558,11 +558,16 @@ my %table=(
558 558
559##### VxWorks for various targets 559##### VxWorks for various targets
560"vxworks-ppc405","ccppc:-g -msoft-float -mlongcall -DCPU=PPC405 -I\$(WIND_BASE)/target/h:::VXWORKS:-r:::::", 560"vxworks-ppc405","ccppc:-g -msoft-float -mlongcall -DCPU=PPC405 -I\$(WIND_BASE)/target/h:::VXWORKS:-r:::::",
561"vxworks-ppc750","ccppc:-ansi -nostdinc -DPPC750 -D_REENTRANT -fvolatile -fno-builtin -fno-for-scope -fsigned-char -Wall -msoft-float -mlongcall -DCPU=PPC604 -I\$(WIND_BASE)/target/h \$(DEBUG_FLAG):::VXWORKS:-r:::::",
562"vxworks-ppc750-debug","ccppc:-ansi -nostdinc -DPPC750 -D_REENTRANT -fvolatile -fno-builtin -fno-for-scope -fsigned-char -Wall -msoft-float -mlongcall -DCPU=PPC604 -I\$(WIND_BASE)/target/h -DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DBN_CTX_DEBUG -DCRYPTO_MDEBUG -DPEDANTIC -DDEBUG_SAFESTACK -DDEBUG -g:::VXWORKS:-r:::::",
563
564##### Compaq Non-Stop Kernel (Tandem)
565"tandem-c89","c89:-Ww -D__TANDEM -D_XOPEN_SOURCE -D_XOPEN_SOURCE_EXTENDED=1 -D_TANDEM_SOURCE -DB_ENDIAN::(unknown):::THIRTY_TWO_BIT:::",
561 566
562); 567);
563 568
564my @WinTargets=qw(VC-NT VC-WIN32 VC-WIN16 VC-W31-16 VC-W31-32 VC-MSDOS BC-32 569my @WinTargets=qw(VC-NT VC-CE VC-WIN32 VC-WIN16 VC-W31-16 VC-W31-32 VC-MSDOS
565 BC-16 Mingw32 OS2-EMX); 570 BC-32 BC-16 Mingw32 OS2-EMX);
566 571
567my $idx = 0; 572my $idx = 0;
568my $idx_cc = $idx++; 573my $idx_cc = $idx++;
@@ -645,6 +650,7 @@ my $openssl_thread_defines;
645my $openssl_sys_defines=""; 650my $openssl_sys_defines="";
646my $openssl_other_defines; 651my $openssl_other_defines;
647my $libs; 652my $libs;
653my $libkrb5="";
648my $target; 654my $target;
649my $options; 655my $options;
650my $symlink; 656my $symlink;
@@ -685,6 +691,11 @@ PROCESS_ARGS:
685 $flags .= "-DOPENSSL_NO_ASM "; 691 $flags .= "-DOPENSSL_NO_ASM ";
686 $openssl_other_defines .= "#define OPENSSL_NO_ASM\n"; 692 $openssl_other_defines .= "#define OPENSSL_NO_ASM\n";
687 } 693 }
694 elsif (/^no-err$/)
695 {
696 $flags .= "-DOPENSSL_NO_ERR ";
697 $openssl_other_defines .= "#define OPENSSL_NO_ERR\n";
698 }
688 elsif (/^no-hw-(.+)$/) 699 elsif (/^no-hw-(.+)$/)
689 { 700 {
690 my $hw=$1; 701 my $hw=$1;
@@ -707,7 +718,7 @@ PROCESS_ARGS:
707 { $threads=1; } 718 { $threads=1; }
708 elsif (/^no-shared$/) 719 elsif (/^no-shared$/)
709 { $no_shared=1; } 720 { $no_shared=1; }
710 elsif (/^shared$/) 721 elsif (/^shared$/ || /^-shared$/ || /^--shared$/)
711 { $no_shared=0; } 722 { $no_shared=0; }
712 elsif (/^no-zlib$/) 723 elsif (/^no-zlib$/)
713 { $zlib=0; } 724 { $zlib=0; }
@@ -735,6 +746,7 @@ PROCESS_ARGS:
735 $openssl_algorithm_defines .= "#define OPENSSL_NO_$algo\n"; 746 $openssl_algorithm_defines .= "#define OPENSSL_NO_$algo\n";
736 if ($algo eq "RIJNDAEL") 747 if ($algo eq "RIJNDAEL")
737 { 748 {
749 push @skip, "aes";
738 $flags .= "-DOPENSSL_NO_AES "; 750 $flags .= "-DOPENSSL_NO_AES ";
739 $depflags .= "-DOPENSSL_NO_AES "; 751 $depflags .= "-DOPENSSL_NO_AES ";
740 $openssl_algorithm_defines .= "#define OPENSSL_NO_AES\n"; 752 $openssl_algorithm_defines .= "#define OPENSSL_NO_AES\n";
@@ -944,6 +956,8 @@ my $shared_extension = $fields[$idx_shared_extension];
944my $ranlib = $fields[$idx_ranlib]; 956my $ranlib = $fields[$idx_ranlib];
945my $arflags = $fields[$idx_arflags]; 957my $arflags = $fields[$idx_arflags];
946 958
959my $no_shared_warn=0;
960
947$cflags="$flags$cflags" if ($flags ne ""); 961$cflags="$flags$cflags" if ($flags ne "");
948 962
949# Kerberos settings. The flavor must be provided from outside, either through 963# Kerberos settings. The flavor must be provided from outside, either through
@@ -961,6 +975,17 @@ else
961 my ($lresolv, $lpath, $lext); 975 my ($lresolv, $lpath, $lext);
962 if ($withargs{"krb5-flavor"} =~ /^[Hh]eimdal$/) 976 if ($withargs{"krb5-flavor"} =~ /^[Hh]eimdal$/)
963 { 977 {
978 die "Sorry, Heimdal is currently not supported\n";
979 }
980 ##### HACK to force use of Heimdal.
981 ##### WARNING: Since we don't really have adequate support for Heimdal,
982 ##### using this will break the build. You'll have to make
983 ##### changes to the source, and if you do, please send
984 ##### patches to openssl-dev@openssl.org
985 if ($withargs{"krb5-flavor"} =~ /^force-[Hh]eimdal$/)
986 {
987 warn "Heimdal isn't really supported. Your build WILL break\n";
988 warn "If you fix the problems, please send a patch to openssl-dev\@openssl.org\n";
964 $withargs{"krb5-dir"} = "/usr/heimdal" 989 $withargs{"krb5-dir"} = "/usr/heimdal"
965 if $withargs{"krb5-dir"} eq ""; 990 if $withargs{"krb5-dir"} eq "";
966 $withargs{"krb5-lib"} = "-L".$withargs{"krb5-dir"}. 991 $withargs{"krb5-lib"} = "-L".$withargs{"krb5-dir"}.
@@ -993,7 +1018,7 @@ else
993 } 1018 }
994 } 1019 }
995 $withargs{"krb5-lib"} .= " -lresolv" 1020 $withargs{"krb5-lib"} .= " -lresolv"
996 if ("$lresolv"); 1021 if ("$lresolv" ne "");
997 $withargs{"krb5-include"} = "-I".$withargs{"krb5-dir"}."/include" 1022 $withargs{"krb5-include"} = "-I".$withargs{"krb5-dir"}."/include"
998 if $withargs{"krb5-include"} eq "" && 1023 if $withargs{"krb5-include"} eq "" &&
999 $withargs{"krb5-dir"} ne ""; 1024 $withargs{"krb5-dir"} ne "";
@@ -1052,7 +1077,7 @@ else
1052# } 1077# }
1053 } 1078 }
1054 1079
1055$lflags="$libs$lflags"if ($libs ne ""); 1080$lflags="$libs$lflags" if ($libs ne "");
1056 1081
1057if ($no_asm) 1082if ($no_asm)
1058 { 1083 {
@@ -1060,6 +1085,11 @@ if ($no_asm)
1060 $sha1_obj=$md5_obj=$rmd160_obj=""; 1085 $sha1_obj=$md5_obj=$rmd160_obj="";
1061 } 1086 }
1062 1087
1088if (!$no_shared)
1089 {
1090 $cast_obj=""; # CAST assembler is not PIC
1091 }
1092
1063if ($threads) 1093if ($threads)
1064 { 1094 {
1065 $cflags=$thread_cflags; 1095 $cflags=$thread_cflags;
@@ -1075,20 +1105,17 @@ if ($zlib)
1075 1105
1076# You will find shlib_mark1 and shlib_mark2 explained in Makefile.org 1106# You will find shlib_mark1 and shlib_mark2 explained in Makefile.org
1077my $shared_mark = ""; 1107my $shared_mark = "";
1078if ($shared_target ne "") 1108if ($shared_target eq "")
1109 {
1110 $no_shared_warn = 1 if !$no_shared;
1111 $no_shared = 1;
1112 }
1113if (!$no_shared)
1079 { 1114 {
1080 if ($shared_cflag ne "") 1115 if ($shared_cflag ne "")
1081 { 1116 {
1082 $cflags = "$shared_cflag $cflags"; 1117 $cflags = "$shared_cflag $cflags";
1083 } 1118 }
1084 if (!$no_shared)
1085 {
1086 #$shared_mark = "\$(SHARED_LIBS)";
1087 }
1088 }
1089else
1090 {
1091 $no_shared = 1;
1092 } 1119 }
1093 1120
1094if ($sys_id ne "") 1121if ($sys_id ne "")
@@ -1262,8 +1289,6 @@ print "ARFLAGS =$arflags\n";
1262print "PERL =$perl\n"; 1289print "PERL =$perl\n";
1263print "KRB5_INCLUDES =",$withargs{"krb5-include"},"\n" 1290print "KRB5_INCLUDES =",$withargs{"krb5-include"},"\n"
1264 if $withargs{"krb5-include"} ne ""; 1291 if $withargs{"krb5-include"} ne "";
1265print "LIBKRB5 =",$withargs{"krb5-lib"},"\n"
1266 if $withargs{"krb5-lib"} ne "";
1267 1292
1268my $des_ptr=0; 1293my $des_ptr=0;
1269my $des_risc1=0; 1294my $des_risc1=0;
@@ -1490,6 +1515,16 @@ applications as the compiler options required on this system are not known.
1490See file INSTALL for details if you need multi-threading. 1515See file INSTALL for details if you need multi-threading.
1491EOF 1516EOF
1492 1517
1518print <<\EOF if ($no_shared_warn);
1519
1520You gave the option 'shared'. Normally, that would give you shared libraries.
1521Unfortunately, the OpenSSL configuration doesn't include shared library support
1522for this platform yet, so it will pretend you gave the option 'no-shared'. If
1523you can inform the developpers (openssl-dev\@openssl.org) how to support shared
1524libraries on this platform, they will at least look at it and try their best
1525(but please first make sure you have tried with a current version of OpenSSL).
1526EOF
1527
1493exit(0); 1528exit(0);
1494 1529
1495sub usage 1530sub usage
diff --git a/src/lib/libssl/src/FAQ b/src/lib/libssl/src/FAQ
index 28027fdcac..7812ae88cb 100644
--- a/src/lib/libssl/src/FAQ
+++ b/src/lib/libssl/src/FAQ
@@ -9,6 +9,7 @@ OpenSSL - Frequently Asked Questions
9* Where can I get a compiled version of OpenSSL? 9* Where can I get a compiled version of OpenSSL?
10* Why aren't tools like 'autoconf' and 'libtool' used? 10* Why aren't tools like 'autoconf' and 'libtool' used?
11* What is an 'engine' version? 11* What is an 'engine' version?
12* How do I check the authenticity of the OpenSSL distribution?
12 13
13[LEGAL] Legal questions 14[LEGAL] Legal questions
14 15
@@ -43,6 +44,8 @@ OpenSSL - Frequently Asked Questions
43* What is special about OpenSSL on Redhat? 44* What is special about OpenSSL on Redhat?
44* Why does the OpenSSL compilation fail on MacOS X? 45* Why does the OpenSSL compilation fail on MacOS X?
45* Why does the OpenSSL test suite fail on MacOS X? 46* Why does the OpenSSL test suite fail on MacOS X?
47* Why does the OpenSSL test suite fail in BN_sqr test [on a 64-bit platform]?
48* Why does OpenBSD-i386 build fail on des-586.s with "Unimplemented segment type"?
46 49
47[PROG] Questions about programming with OpenSSL 50[PROG] Questions about programming with OpenSSL
48 51
@@ -65,7 +68,7 @@ OpenSSL - Frequently Asked Questions
65* Which is the current version of OpenSSL? 68* Which is the current version of OpenSSL?
66 69
67The current version is available from <URL: http://www.openssl.org>. 70The current version is available from <URL: http://www.openssl.org>.
68OpenSSL 0.9.6g was released on August 9, 2002. 71OpenSSL 0.9.7b was released on April 10, 2003.
69 72
70In addition to the current stable release, you can also access daily 73In addition to the current stable release, you can also access daily
71snapshots of the OpenSSL development version at <URL: 74snapshots of the OpenSSL development version at <URL:
@@ -136,6 +139,19 @@ hardware. This was realized in a special release '0.9.6-engine'. With
136version 0.9.7 (not yet released) the changes were merged into the main 139version 0.9.7 (not yet released) the changes were merged into the main
137development line, so that the special release is no longer necessary. 140development line, so that the special release is no longer necessary.
138 141
142* How do I check the authenticity of the OpenSSL distribution?
143
144We provide MD5 digests and ASC signatures of each tarball.
145Use MD5 to check that a tarball from a mirror site is identical:
146
147 md5sum TARBALL | awk '{print $1;}' | cmp - TARBALL.md5
148
149You can check authenticity using pgp or gpg. You need the OpenSSL team
150member public key used to sign it (download it from a key server). Then
151just do:
152
153 pgp TARBALL.asc
154
139[LEGAL] ======================================================================= 155[LEGAL] =======================================================================
140 156
141* Do I need patent licenses to use OpenSSL? 157* Do I need patent licenses to use OpenSSL?
@@ -173,18 +189,30 @@ for permission to use their software with OpenSSL.
173 189
174Cryptographic software needs a source of unpredictable data to work 190Cryptographic software needs a source of unpredictable data to work
175correctly. Many open source operating systems provide a "randomness 191correctly. Many open source operating systems provide a "randomness
176device" that serves this purpose. On other systems, applications have 192device" (/dev/urandom or /dev/random) that serves this purpose.
177to call the RAND_add() or RAND_seed() function with appropriate data 193All OpenSSL versions try to use /dev/urandom by default; starting with
178before generating keys or performing public key encryption. 194version 0.9.7, OpenSSL also tries /dev/random if /dev/urandom is not
179(These functions initialize the pseudo-random number generator, PRNG.) 195available.
180 196
181Some broken applications do not do this. As of version 0.9.5, the 197On other systems, applications have to call the RAND_add() or
182OpenSSL functions that need randomness report an error if the random 198RAND_seed() function with appropriate data before generating keys or
183number generator has not been seeded with at least 128 bits of 199performing public key encryption. (These functions initialize the
184randomness. If this error occurs, please contact the author of the 200pseudo-random number generator, PRNG.) Some broken applications do
185application you are using. It is likely that it never worked 201not do this. As of version 0.9.5, the OpenSSL functions that need
186correctly. OpenSSL 0.9.5 and later make the error visible by refusing 202randomness report an error if the random number generator has not been
187to perform potentially insecure encryption. 203seeded with at least 128 bits of randomness. If this error occurs and
204is not discussed in the documentation of the application you are
205using, please contact the author of that application; it is likely
206that it never worked correctly. OpenSSL 0.9.5 and later make the
207error visible by refusing to perform potentially insecure encryption.
208
209If you are using Solaris 8, you can add /dev/urandom and /dev/random
210devices by installing patch 112438 (Sparc) or 112439 (x86), which are
211available via the Patchfinder at <URL: http://sunsolve.sun.com>
212(Solaris 9 includes these devices by default). For /dev/random support
213for earlier Solaris versions, see Sun's statement at
214<URL: http://sunsolve.sun.com/pub-cgi/retrieve.pl?doc=fsrdb/27606&zone_32=SUNWski>
215(the SUNWski package is available in patch 105710).
188 216
189On systems without /dev/urandom and /dev/random, it is a good idea to 217On systems without /dev/urandom and /dev/random, it is a good idea to
190use the Entropy Gathering Demon (EGD); see the RAND_egd() manpage for 218use the Entropy Gathering Demon (EGD); see the RAND_egd() manpage for
@@ -217,16 +245,6 @@ OpenSSL command line tools. Applications using the OpenSSL library
217provide their own configuration options to specify the entropy source, 245provide their own configuration options to specify the entropy source,
218please check out the documentation coming the with application. 246please check out the documentation coming the with application.
219 247
220For Solaris 2.6, Tim Nibbe <tnibbe@sprint.net> and others have suggested
221installing the SUNski package from Sun patch 105710-01 (Sparc) which
222adds a /dev/random device and make sure it gets used, usually through
223$RANDFILE. There are probably similar patches for the other Solaris
224versions. An official statement from Sun with respect to /dev/random
225support can be found at
226 http://sunsolve.sun.com/pub-cgi/retrieve.pl?doc=fsrdb/27606&zone_32=SUNWski
227However, be warned that /dev/random is usually a blocking device, which
228may have some effects on OpenSSL.
229
230 248
231* Why do I get an "unable to write 'random state'" error message? 249* Why do I get an "unable to write 'random state'" error message?
232 250
@@ -472,10 +490,13 @@ and then redo the compilation. What you should really do is make sure
472Sometimes, you may get reports from VC++ command line (cl) that it 490Sometimes, you may get reports from VC++ command line (cl) that it
473can't find standard include files like stdio.h and other weirdnesses. 491can't find standard include files like stdio.h and other weirdnesses.
474One possible cause is that the environment isn't correctly set up. 492One possible cause is that the environment isn't correctly set up.
475To solve that problem, one should run VCVARS32.BAT which is found in 493To solve that problem for VC++ versions up to 6, one should run
476the 'bin' subdirectory of the VC++ installation directory (somewhere 494VCVARS32.BAT which is found in the 'bin' subdirectory of the VC++
477under 'Program Files'). This needs to be done prior to running NMAKE, 495installation directory (somewhere under 'Program Files'). For VC++
478and the changes are only valid for the current DOS session. 496version 7 (and up?), which is also called VS.NET, the file is called
497VSVARS32.BAT instead.
498This needs to be done prior to running NMAKE, and the changes are only
499valid for the current DOS session.
479 500
480 501
481* What is special about OpenSSL on Redhat? 502* What is special about OpenSSL on Redhat?
@@ -536,6 +557,37 @@ libraries you just built.
536Look in the file PROBLEMS for a more detailed explanation and for possible 557Look in the file PROBLEMS for a more detailed explanation and for possible
537solutions. 558solutions.
538 559
560* Why does the OpenSSL test suite fail in BN_sqr test [on a 64-bit platform]?
561
562Failure in BN_sqr test is most likely caused by a failure to configure the
563toolkit for current platform or lack of support for the platform in question.
564Run './config -t' and './apps/openssl version -p'. Do these platform
565identifiers match? If they don't, then you most likely failed to run
566./config and you're hereby advised to do so before filing a bug report.
567If ./config itself fails to run, then it's most likely problem with your
568local environment and you should turn to your system administrator (or
569similar). If identifiers match (and/or no alternative identifier is
570suggested by ./config script), then the platform is unsupported. There might
571or might not be a workaround. Most notably on SPARC64 platforms with GNU
572C compiler you should be able to produce a working build by running
573'./config -m32'. I understand that -m32 might not be what you want/need,
574but the build should be operational. For further details turn to
575<openssl-dev@openssl.org>.
576
577* Why does OpenBSD-i386 build fail on des-586.s with "Unimplemented segment type"?
578
579As of 0.9.7 assembler routines were overhauled for position independence
580of the machine code, which is essential for shared library support. For
581some reason OpenBSD is equipped with an out-of-date GNU assembler which
582finds the new code offensive. To work around the problem, configure with
583no-asm (and sacrifice a great deal of performance) or patch your assembler
584according to <URL: http://www.openssl.org/~appro/gas-1.92.3.OpenBSD.patch>.
585For your convenience a pre-compiled replacement binary is provided at
586<URL: http://www.openssl.org/~appro/gas-1.92.3.static.aout.bin>.
587Reportedly elder *BSD a.out platforms also suffer from this problem and
588remedy should be same. Provided binary is statically linked and should be
589working across wider range of *BSD branches, not just OpenBSD.
590
539[PROG] ======================================================================== 591[PROG] ========================================================================
540 592
541* Is OpenSSL thread-safe? 593* Is OpenSSL thread-safe?
@@ -680,6 +732,7 @@ The general answer is to check the config.log file generated when running
680the OpenSSH configure script. It should contain the detailed information 732the OpenSSH configure script. It should contain the detailed information
681on why the OpenSSL library was not detected or considered incompatible. 733on why the OpenSSL library was not detected or considered incompatible.
682 734
735
683* Can I use OpenSSL's SSL library with non-blocking I/O? 736* Can I use OpenSSL's SSL library with non-blocking I/O?
684 737
685Yes; make sure to read the SSL_get_error(3) manual page! 738Yes; make sure to read the SSL_get_error(3) manual page!
diff --git a/src/lib/libssl/src/INSTALL b/src/lib/libssl/src/INSTALL
index af86485e00..1c3f3c3fe9 100644
--- a/src/lib/libssl/src/INSTALL
+++ b/src/lib/libssl/src/INSTALL
@@ -140,8 +140,8 @@
140 standard headers). If it is a problem with OpenSSL itself, please 140 standard headers). If it is a problem with OpenSSL itself, please
141 report the problem to <openssl-bugs@openssl.org> (note that your 141 report the problem to <openssl-bugs@openssl.org> (note that your
142 message will be recorded in the request tracker publicly readable 142 message will be recorded in the request tracker publicly readable
143 via http://www.openssl.org/rt2.html and will be forwarded to a public 143 via http://www.openssl.org/support/rt2.html and will be forwarded to a
144 mailing list). Include the output of "make report" in your message. 144 public mailing list). Include the output of "make report" in your message.
145 Please check out the request tracker. Maybe the bug was already 145 Please check out the request tracker. Maybe the bug was already
146 reported or has already been fixed. 146 reported or has already been fixed.
147 147
@@ -158,11 +158,11 @@
158 If a test fails, look at the output. There may be reasons for 158 If a test fails, look at the output. There may be reasons for
159 the failure that isn't a problem in OpenSSL itself (like a missing 159 the failure that isn't a problem in OpenSSL itself (like a missing
160 or malfunctioning bc). If it is a problem with OpenSSL itself, 160 or malfunctioning bc). If it is a problem with OpenSSL itself,
161 try removing any compiler optimization flags from the CFLAGS line 161 try removing any compiler optimization flags from the CFLAG line
162 in Makefile.ssl and run "make clean; make". Please send a bug 162 in Makefile.ssl and run "make clean; make". Please send a bug
163 report to <openssl-bugs@openssl.org>, including the output of 163 report to <openssl-bugs@openssl.org>, including the output of
164 "make report" in order to be added to the request tracker at 164 "make report" in order to be added to the request tracker at
165 http://www.openssl.org/rt2.html. 165 http://www.openssl.org/support/rt2.html.
166 166
167 4. If everything tests ok, install OpenSSL with 167 4. If everything tests ok, install OpenSSL with
168 168
@@ -296,3 +296,37 @@
296 targets for shared library creation, like linux-shared. Those targets 296 targets for shared library creation, like linux-shared. Those targets
297 can currently be used on their own just as well, but this is expected 297 can currently be used on their own just as well, but this is expected
298 to change in future versions of OpenSSL. 298 to change in future versions of OpenSSL.
299
300 Note on random number generation
301 --------------------------------
302
303 Availability of cryptographically secure random numbers is required for
304 secret key generation. OpenSSL provides several options to seed the
305 internal PRNG. If not properly seeded, the internal PRNG will refuse
306 to deliver random bytes and a "PRNG not seeded error" will occur.
307 On systems without /dev/urandom (or similar) device, it may be necessary
308 to install additional support software to obtain random seed.
309 Please check out the manual pages for RAND_add(), RAND_bytes(), RAND_egd(),
310 and the FAQ for more information.
311
312 Note on support for multiple builds
313 -----------------------------------
314
315 OpenSSL is usually built in it's source tree. Unfortunately, this doesn't
316 support building for multiple platforms from the same source tree very well.
317 It is however possible to build in a separate tree through the use of lots
318 of symbolic links, which should be prepared like this:
319
320 mkdir -p objtree/"`uname -s`-`uname -r`-`uname -m`"
321 cd objtree/"`uname -s`-`uname -r`-`uname -m`"
322 (cd $OPENSSL_SOURCE; find . -type f) | while read F; do
323 mkdir -p `dirname $F`
324 rm -f $F; ln -s $OPENSSL_SOURCE/$F $F
325 echo $F '->' $OPENSSL_SOURCE/$F
326 done
327 make -f Makefile.org clean
328
329 OPENSSL_SOURCE is an environment variable that contains the absolute (this
330 is important!) path to the OpenSSL source tree.
331
332 Also, operations like 'make update' should still be made in the source tree.
diff --git a/src/lib/libssl/src/INSTALL.DJGPP b/src/lib/libssl/src/INSTALL.DJGPP
index 0120b946b5..cdeac222b2 100644
--- a/src/lib/libssl/src/INSTALL.DJGPP
+++ b/src/lib/libssl/src/INSTALL.DJGPP
@@ -12,12 +12,14 @@
12 latest versions of DJGPP, GCC, BINUTILS, BASH, etc. This package 12 latest versions of DJGPP, GCC, BINUTILS, BASH, etc. This package
13 requires that PERL and BC also be installed. 13 requires that PERL and BC also be installed.
14 14
15 All of these can be obtained from the usual DJGPP mirror sites, such as 15 All of these can be obtained from the usual DJGPP mirror sites, such
16 "ftp://ftp.simtel.net/pub/simtelnet/gnu/djgpp". You also need to have 16 as "ftp://ftp.simtel.net/pub/simtelnet/gnu/djgpp". You also need to
17 the WATT-32 networking package installed before you try to compile 17 have the WATT-32 networking package installed before you try to compile
18 openssl. This can be obtained from "http://www.bgnett.no/~giva/". The 18 openssl. This can be obtained from "http://www.bgnett.no/~giva/".
19 Makefile assumes that the WATT-32 code is in directory "watt32" under 19 The Makefile assumes that the WATT-32 code is in the directory
20 /dev/env/DJDIR. 20 specified by the environment variable WATT_ROOT. If you have watt-32
21 in directory "watt32" under your main DJGPP directory, specify
22 WATT_ROOT="/dev/env/DJDIR/watt32".
21 23
22 To compile openssl, start your BASH shell. Then configure for DOS by 24 To compile openssl, start your BASH shell. Then configure for DOS by
23 running "./Configure" with appropriate arguments. The basic syntax for 25 running "./Configure" with appropriate arguments. The basic syntax for
diff --git a/src/lib/libssl/src/INSTALL.W32 b/src/lib/libssl/src/INSTALL.W32
index 3de6544fc5..78d289e16a 100644
--- a/src/lib/libssl/src/INSTALL.W32
+++ b/src/lib/libssl/src/INSTALL.W32
@@ -2,19 +2,28 @@
2 INSTALLATION ON THE WIN32 PLATFORM 2 INSTALLATION ON THE WIN32 PLATFORM
3 ---------------------------------- 3 ----------------------------------
4 4
5 [Instructions for building for Windows CE can be found in INSTALL.WCE]
6
5 Heres a few comments about building OpenSSL in Windows environments. Most 7 Heres a few comments about building OpenSSL in Windows environments. Most
6 of this is tested on Win32 but it may also work in Win 3.1 with some 8 of this is tested on Win32 but it may also work in Win 3.1 with some
7 modification. 9 modification.
8 10
9 You need Perl for Win32. Unless you will build on Cygwin, you will need 11 You need Perl for Win32. Unless you will build on Cygwin, you will need
10 ActiveState Perl, available from http://www.activestate.com/ActivePerl. 12 ActiveState Perl, available from http://www.activestate.com/ActivePerl.
11 For Cygwin users, there's more info in the Cygwin section.
12 13
13 and one of the following C compilers: 14 and one of the following C compilers:
14 15
15 * Visual C++ 16 * Visual C++
16 * Borland C 17 * Borland C
17 * GNU C (Mingw32 or Cygwin) 18 * GNU C (Cygwin or MinGW)
19
20 If you are compiling from a tarball or a CVS snapshot then the Win32 files
21 may well be not up to date. This may mean that some "tweaking" is required to
22 get it all to work. See the trouble shooting section later on for if (when?)
23 it goes wrong.
24
25 Visual C++
26 ----------
18 27
19 If you want to compile in the assembly language routines with Visual C++ then 28 If you want to compile in the assembly language routines with Visual C++ then
20 you will need an assembler. This is worth doing because it will result in 29 you will need an assembler. This is worth doing because it will result in
@@ -24,26 +33,19 @@
24 * Microsoft MASM (aka "ml") 33 * Microsoft MASM (aka "ml")
25 * Free Netwide Assembler NASM. 34 * Free Netwide Assembler NASM.
26 35
27 MASM was at one point distributed with VC++. It is now distributed with some 36 MASM is distributed with most versions of VC++. For the versions where it is
28 Microsoft DDKs, for example the Windows NT 4.0 DDK and the Windows 98 DDK. If 37 not included in VC++, it is also distributed with some Microsoft DDKs, for
29 you do not have either of these DDKs then you can just download the binaries 38 example the Windows NT 4.0 DDK and the Windows 98 DDK. If you do not have
30 for the Windows 98 DDK and extract and rename the two files XXXXXml.exe and 39 either of these DDKs then you can just download the binaries for the Windows
31 XXXXXml.err, to ml.exe and ml.err and install somewhere on your PATH. Both 40 98 DDK and extract and rename the two files XXXXXml.exe and XXXXXml.err, to
32 DDKs can be downloaded from the Microsoft developers site www.msdn.com. 41 ml.exe and ml.err and install somewhere on your PATH. Both DDKs can be
42 downloaded from the Microsoft developers site www.msdn.com.
33 43
34 NASM is freely available. Version 0.98 was used during testing: other versions 44 NASM is freely available. Version 0.98 was used during testing: other versions
35 may also work. It is available from many places, see for example: 45 may also work. It is available from many places, see for example:
36 http://www.kernel.org/pub/software/devel/nasm/binaries/win32/ 46 http://www.kernel.org/pub/software/devel/nasm/binaries/win32/
37 The NASM binary nasmw.exe needs to be installed anywhere on your PATH. 47 The NASM binary nasmw.exe needs to be installed anywhere on your PATH.
38 48
39 If you are compiling from a tarball or a CVS snapshot then the Win32 files
40 may well be not up to date. This may mean that some "tweaking" is required to
41 get it all to work. See the trouble shooting section later on for if (when?)
42 it goes wrong.
43
44 Visual C++
45 ----------
46
47 Firstly you should run Configure: 49 Firstly you should run Configure:
48 50
49 > perl Configure VC-WIN32 51 > perl Configure VC-WIN32
@@ -82,7 +84,8 @@
82 There are various changes you can make to the Win32 compile environment. By 84 There are various changes you can make to the Win32 compile environment. By
83 default the library is not compiled with debugging symbols. If you add 'debug' 85 default the library is not compiled with debugging symbols. If you add 'debug'
84 to the mk1mf.pl lines in the do_* batch file then debugging symbols will be 86 to the mk1mf.pl lines in the do_* batch file then debugging symbols will be
85 compiled in. 87 compiled in. Note that mk1mf.pl expects the platform to be the last argument
88 on the command line, so 'debug' must appear before that, as all other options.
86 89
87 The default Win32 environment is to leave out any Windows NT specific 90 The default Win32 environment is to leave out any Windows NT specific
88 features. 91 features.
@@ -116,62 +119,35 @@
116 * Run make: 119 * Run make:
117 > make -f bcb.mak 120 > make -f bcb.mak
118 121
119 GNU C (Mingw32)
120 ---------------
121
122 To build OpenSSL, you need the Mingw32 package and GNU make.
123
124 * Compiler installation:
125
126 Mingw32 is available from <ftp://ftp.xraylith.wisc.edu/pub/khan/
127 gnu-win32/mingw32/gcc-2.95.2/gcc-2.95.2-msvcrt.exe>. Extract it
128 to a directory such as C:\gcc-2.95.2 and add c:\gcc-2.95.2\bin to
129 the PATH environment variable in "System Properties"; or edit and
130 run C:\gcc-2.95.2\mingw32.bat to set the PATH.
131
132 * Compile OpenSSL:
133
134 > ms\mingw32
135
136 This will create the library and binaries in out. In case any problems
137 occur, try
138 > ms\mingw32 no-asm
139 instead.
140
141 libcrypto.a and libssl.a are the static libraries. To use the DLLs,
142 link with libeay32.a and libssl32.a instead.
143
144 See troubleshooting if you get error messages about functions not having
145 a number assigned.
146
147 * You can now try the tests:
148
149 > cd out
150 > ..\ms\test
151
152 GNU C (Cygwin) 122 GNU C (Cygwin)
153 -------------- 123 --------------
154 124
155 Cygwin provides a bash shell and GNU tools environment running 125 Cygwin provides a bash shell and GNU tools environment running
156 on NT 4.0, Windows 9x, Windows ME, Windows 2000, and Windows XP. 126 on NT 4.0, Windows 9x, Windows ME, Windows 2000, and Windows XP.
157 Consequently, a make of OpenSSL with Cygwin is closer to a GNU 127 Consequently, a make of OpenSSL with Cygwin is closer to a GNU
158 bash environment such as Linux than to other W32 makes which are 128 bash environment such as Linux than to other the other Win32
159 based on a single makefile approach. Cygwin implements Posix/Unix 129 makes.
160 calls through cygwin1.dll, and is contrasted to Mingw32 which links 130
161 dynamically to msvcrt.dll or crtdll.dll. 131 Cygwin implements a Posix/Unix runtime system (cygwin1.dll).
132 It is also possible to create Win32 binaries that only use the
133 Microsoft C runtime system (msvcrt.dll or crtdll.dll) using
134 MinGW. MinGW can be used in the Cygwin development environment
135 or in a standalone setup as described in the following section.
162 136
163 To build OpenSSL using Cygwin: 137 To build OpenSSL using Cygwin:
164 138
165 * Install Cygwin (see http://cygwin.com/) 139 * Install Cygwin (see http://cygwin.com/)
166 140
167 * Install Perl and ensure it is in the path (recent Cygwin perl 141 * Install Perl and ensure it is in the path. Both Cygwin perl
168 (version 5.6.1-2 of the latter has been reported to work) or 142 (5.6.1-2 or newer) and ActivePerl work.
169 ActivePerl)
170 143
171 * Run the Cygwin bash shell 144 * Run the Cygwin bash shell
172 145
173 * $ tar zxvf openssl-x.x.x.tar.gz 146 * $ tar zxvf openssl-x.x.x.tar.gz
174 $ cd openssl-x.x.x 147 $ cd openssl-x.x.x
148
149 To build the Cygwin version of OpenSSL:
150
175 $ ./config 151 $ ./config
176 [...] 152 [...]
177 $ make 153 $ make
@@ -179,7 +155,16 @@
179 $ make test 155 $ make test
180 $ make install 156 $ make install
181 157
182 This will create a default install in /usr/local/ssl. 158 This will create a default install in /usr/local/ssl.
159
160 To build the MinGW version (native Windows) in Cygwin:
161
162 $ ./Configure mingw
163 [...]
164 $ make
165 [...]
166 $ make test
167 $ make install
183 168
184 Cygwin Notes: 169 Cygwin Notes:
185 170
@@ -192,6 +177,35 @@
192 non-fatal error in "make test" but is otherwise harmless. If 177 non-fatal error in "make test" but is otherwise harmless. If
193 desired and needed, GNU bc can be built with Cygwin without change. 178 desired and needed, GNU bc can be built with Cygwin without change.
194 179
180 GNU C (MinGW)
181 -------------
182
183 * Compiler installation:
184
185 MinGW is available from http://www.mingw.org. Run the installer and
186 set the MinGW bin directory to the PATH in "System Properties" or
187 autoexec.bat.
188
189 * Compile OpenSSL:
190
191 > ms\mingw32
192
193 This will create the library and binaries in out. In case any problems
194 occur, try
195 > ms\mingw32 no-asm
196 instead.
197
198 libcrypto.a and libssl.a are the static libraries. To use the DLLs,
199 link with libeay32.a and libssl32.a instead.
200
201 See troubleshooting if you get error messages about functions not having
202 a number assigned.
203
204 * You can now try the tests:
205
206 > cd out
207 > ..\ms\test
208
195 209
196 Installation 210 Installation
197 ------------ 211 ------------
diff --git a/src/lib/libssl/src/INSTALL.WCE b/src/lib/libssl/src/INSTALL.WCE
new file mode 100644
index 0000000000..ac587d6bd2
--- /dev/null
+++ b/src/lib/libssl/src/INSTALL.WCE
@@ -0,0 +1,71 @@
1
2 INSTALLATION FOR THE WINDOWS CE PLATFORM
3 ----------------------------------------
4
5 Building OpenSSL for Windows CE requires the following external tools:
6
7 * Microsoft eMbedded Visual C++ 3.0
8 * wcecompat compatibility library (www.essemer.com.au)
9 * Optionally ceutils for running automated tests (www.essemer.com.au)
10
11 You also need Perl for Win32. You will need ActiveState Perl, available
12 from http://www.activestate.com/ActivePerl.
13
14 Windows CE support in OpenSSL relies on wcecompat. All Windows CE specific
15 issues should be directed to www.essemer.com.au.
16
17 The C Runtime Library implementation for Windows CE that is included with
18 Microsoft eMbedded Visual C++ 3.0 is incomplete and in some places
19 incorrect. wcecompat plugs the holes and tries to bring the Windows CE
20 CRT to a level that is more compatible with ANSI C. wcecompat goes further
21 and provides low-level IO and stream IO support for stdin/stdout/stderr
22 (which Windows CE does not provide). This IO functionality is not needed
23 by the OpenSSL library itself but is used for the tests and openssl.exe.
24 More information is available at www.essemer.com.au.
25
26 Building
27 --------
28
29 Setup the eMbedded Visual C++ environment. There are batch files for doing
30 this installed with eVC++. For an ARM processor, for example, execute:
31
32 > "C:\Program Files\Microsoft eMbedded Tools\EVC\WCE300\BIN\WCEARM.BAT"
33
34 Next indicate where wcecompat is located:
35
36 > set WCECOMPAT=C:\wcecompat
37
38 Next you should run Configure:
39
40 > perl Configure VC-CE
41
42 Next you need to build the Makefiles:
43
44 > ms\do_ms
45
46 If you get errors about things not having numbers assigned then check the
47 troubleshooting section in INSTALL.W32: you probably won't be able to compile
48 it as it stands.
49
50 Then from the VC++ environment at a prompt do:
51
52 - to build static libraries:
53
54 > nmake -f ms\ce.mak
55
56 - or to build DLLs:
57
58 > nmake -f ms\cedll.mak
59
60 If all is well it should compile and you will have some static libraries and
61 executables in out32, or some DLLs and executables in out32dll. If you want
62 to try the tests then make sure the ceutils are in the path and do:
63
64 > cd out32
65 > ..\ms\testce
66
67 This will copy each of the test programs to the Windows CE device and execute
68 them, displaying the output of the tests on this computer. The output should
69 look similar to the output produced by running the tests for a regular Windows
70 build.
71
diff --git a/src/lib/libssl/src/LICENSE b/src/lib/libssl/src/LICENSE
index 7b93e0dbce..dddb07842b 100644
--- a/src/lib/libssl/src/LICENSE
+++ b/src/lib/libssl/src/LICENSE
@@ -12,7 +12,7 @@
12 --------------- 12 ---------------
13 13
14/* ==================================================================== 14/* ====================================================================
15 * Copyright (c) 1998-2002 The OpenSSL Project. All rights reserved. 15 * Copyright (c) 1998-2003 The OpenSSL Project. All rights reserved.
16 * 16 *
17 * Redistribution and use in source and binary forms, with or without 17 * Redistribution and use in source and binary forms, with or without
18 * modification, are permitted provided that the following conditions 18 * modification, are permitted provided that the following conditions
diff --git a/src/lib/libssl/src/MacOS/GetHTTPS.src/MacSocket.cpp b/src/lib/libssl/src/MacOS/GetHTTPS.src/MacSocket.cpp
index 2726136347..c95d804d5d 100644
--- a/src/lib/libssl/src/MacOS/GetHTTPS.src/MacSocket.cpp
+++ b/src/lib/libssl/src/MacOS/GetHTTPS.src/MacSocket.cpp
@@ -1287,7 +1287,7 @@ EXITPOINT:
1287 1287
1288// Send some bytes 1288// Send some bytes
1289 1289
1290int MacSocket_send(const int inSocketNum,void *inBuff,int inBuffLength) 1290int MacSocket_send(const int inSocketNum,const void *inBuff,int inBuffLength)
1291{ 1291{
1292OSErr errCode = noErr; 1292OSErr errCode = noErr;
1293int bytesSent = 0; 1293int bytesSent = 0;
@@ -1604,4 +1604,4 @@ EPInfo* epi = (EPInfo*) context;
1604 } 1604 }
1605 } 1605 }
1606} 1606}
1607*/ \ No newline at end of file 1607*/
diff --git a/src/lib/libssl/src/MacOS/GetHTTPS.src/MacSocket.h b/src/lib/libssl/src/MacOS/GetHTTPS.src/MacSocket.h
index 6e90a5bb44..ad59dc9e4f 100644
--- a/src/lib/libssl/src/MacOS/GetHTTPS.src/MacSocket.h
+++ b/src/lib/libssl/src/MacOS/GetHTTPS.src/MacSocket.h
@@ -62,7 +62,7 @@ int MacSocket_recv(const int inSocketNum,void *outBuff,int outBuffLength,const B
62 62
63// Call this to send data on a socket 63// Call this to send data on a socket
64 64
65int MacSocket_send(const int inSocketNum,void *inBuff,int inBuffLength); 65int MacSocket_send(const int inSocketNum,const void *inBuff,int inBuffLength);
66 66
67 67
68// If zero bytes were read in a call to MacSocket_recv(), it may be that the remote end has done a half-close 68// If zero bytes were read in a call to MacSocket_recv(), it may be that the remote end has done a half-close
diff --git a/src/lib/libssl/src/Makefile.org b/src/lib/libssl/src/Makefile.org
index d7af0815f3..4d0627bfdd 100644
--- a/src/lib/libssl/src/Makefile.org
+++ b/src/lib/libssl/src/Makefile.org
@@ -15,6 +15,11 @@ OPTIONS=
15CONFIGURE_ARGS= 15CONFIGURE_ARGS=
16SHLIB_TARGET= 16SHLIB_TARGET=
17 17
18# HERE indicates where this Makefile lives. This can be used to indicate
19# where sub-Makefiles are expected to be. Currently has very limited usage,
20# and should probably not be bothered with at all.
21HERE=.
22
18# INSTALL_PREFIX is for package builders so that they can configure 23# INSTALL_PREFIX is for package builders so that they can configure
19# for, say, /usr/ and yet have everything installed to /tmp/somedir/usr/. 24# for, say, /usr/ and yet have everything installed to /tmp/somedir/usr/.
20# Normally it is left empty. 25# Normally it is left empty.
@@ -67,6 +72,14 @@ TAR= tar
67TARFLAGS= --no-recursion 72TARFLAGS= --no-recursion
68MAKEDEPPROG=makedepend 73MAKEDEPPROG=makedepend
69 74
75# We let the C compiler driver to take care of .s files. This is done in
76# order to be excused from maintaining a separate set of architecture
77# dependent assembler flags. E.g. if you throw -mcpu=ultrasparc at SPARC
78# gcc, then the driver will automatically translate it to -xarch=v8plus
79# and pass it down to assembler.
80AS=$(CC) -c
81ASFLAGS=$(CFLAG)
82
70# Set BN_ASM to bn_asm.o if you want to use the C version 83# Set BN_ASM to bn_asm.o if you want to use the C version
71BN_ASM= bn_asm.o 84BN_ASM= bn_asm.o
72#BN_ASM= bn_asm.o 85#BN_ASM= bn_asm.o
@@ -205,14 +218,14 @@ HEADER= e_os.h
205# When we're prepared to use shared libraries in the programs we link here 218# When we're prepared to use shared libraries in the programs we link here
206# we might remove 'clean-shared' from the targets to perform at this stage 219# we might remove 'clean-shared' from the targets to perform at this stage
207 220
208all: Makefile.ssl sub_all 221all: Makefile.ssl sub_all openssl.pc
209 222
210sub_all: 223sub_all:
211 @for i in $(DIRS); \ 224 @for i in $(DIRS); \
212 do \ 225 do \
213 if [ -d "$$i" ]; then \ 226 if [ -d "$$i" ]; then \
214 (cd $$i && echo "making all in $$i..." && \ 227 (cd $$i && echo "making all in $$i..." && \
215 $(MAKE) CC='${CC}' PLATFORM='${PLATFORM}' CFLAG='${CFLAG}' SDIRS='$(SDIRS)' INSTALLTOP='${INSTALLTOP}' PEX_LIBS='${PEX_LIBS}' EX_LIBS='${EX_LIBS}' BN_ASM='${BN_ASM}' DES_ENC='${DES_ENC}' BF_ENC='${BF_ENC}' CAST_ENC='${CAST_ENC}' RC4_ENC='${RC4_ENC}' RC5_ENC='${RC5_ENC}' SHA1_ASM_OBJ='${SHA1_ASM_OBJ}' MD5_ASM_OBJ='${MD5_ASM_OBJ}' RMD160_ASM_OBJ='${RMD160_ASM_OBJ}' AR='${AR}' PROCESSOR='${PROCESSOR}' PERL='${PERL}' RANLIB='${RANLIB}' KRB5_INCLUDES='${KRB5_INCLUDES}' LIBKRB5='${LIBKRB5}' EXE_EXT='${EXE_EXT}' SHARED_LIBS='${SHARED_LIBS}' SHLIB_EXT='${SHLIB_EXT}' SHLIB_TARGET='${SHLIB_TARGET}' all ) || exit 1; \ 228 $(MAKE) CC='${CC}' PLATFORM='${PLATFORM}' CFLAG='${CFLAG}' AS='${AS}' ASFLAGS='${ASFLAGS}' SDIRS='$(SDIRS)' INSTALLTOP='${INSTALLTOP}' PEX_LIBS='${PEX_LIBS}' EX_LIBS='${EX_LIBS}' BN_ASM='${BN_ASM}' DES_ENC='${DES_ENC}' BF_ENC='${BF_ENC}' CAST_ENC='${CAST_ENC}' RC4_ENC='${RC4_ENC}' RC5_ENC='${RC5_ENC}' SHA1_ASM_OBJ='${SHA1_ASM_OBJ}' MD5_ASM_OBJ='${MD5_ASM_OBJ}' RMD160_ASM_OBJ='${RMD160_ASM_OBJ}' AR='${AR}' PROCESSOR='${PROCESSOR}' PERL='${PERL}' RANLIB='${RANLIB}' KRB5_INCLUDES='${KRB5_INCLUDES}' LIBKRB5='${LIBKRB5}' EXE_EXT='${EXE_EXT}' SHARED_LIBS='${SHARED_LIBS}' SHLIB_EXT='${SHLIB_EXT}' SHLIB_TARGET='${SHLIB_TARGET}' all ) || exit 1; \
216 else \ 229 else \
217 $(MAKE) $$i; \ 230 $(MAKE) $$i; \
218 fi; \ 231 fi; \
@@ -242,7 +255,7 @@ clean-shared:
242 fi; \ 255 fi; \
243 ( set -x; rm -f lib$$i$(SHLIB_EXT) ); \ 256 ( set -x; rm -f lib$$i$(SHLIB_EXT) ); \
244 if [ "$(PLATFORM)" = "Cygwin" ]; then \ 257 if [ "$(PLATFORM)" = "Cygwin" ]; then \
245 ( set -x; rm -f cyg$$i$(SHLIB_EXT) lib$$i$(SHLIB_EXT).a ); \ 258 ( set -x; rm -f cyg$$i-$(SHLIB_VERSION_NUMBER)$(SHLIB_EXT) lib$$i$(SHLIB_EXT).a ); \
246 fi; \ 259 fi; \
247 done 260 done
248 261
@@ -265,39 +278,45 @@ do_bsd-gcc-shared: do_gnu-shared
265do_linux-shared: do_gnu-shared 278do_linux-shared: do_gnu-shared
266do_gnu-shared: 279do_gnu-shared:
267 libs='-L. ${SHLIBDEPS}'; for i in ${SHLIBDIRS}; do \ 280 libs='-L. ${SHLIBDEPS}'; for i in ${SHLIBDIRS}; do \
281 if [ "${SHLIBDIRS}" = "ssl" -a -n "$(LIBKRB5)" ]; then \
282 libs="$(LIBKRB5) $$libs"; \
283 fi; \
268 ( set -x; ${CC} ${SHARED_LDFLAGS} \ 284 ( set -x; ${CC} ${SHARED_LDFLAGS} \
269 -shared -o lib$$i.so.${SHLIB_MAJOR}.${SHLIB_MINOR} \ 285 -shared -o lib$$i.so.${SHLIB_MAJOR}.${SHLIB_MINOR} \
270 -Wl,-soname=lib$$i.so.${SHLIB_MAJOR}.${SHLIB_MINOR} \ 286 -Wl,-soname=lib$$i.so.${SHLIB_MAJOR}.${SHLIB_MINOR} \
271 -Wl,-Bsymbolic \ 287 -Wl,-Bsymbolic \
272 -Wl,--whole-archive lib$$i.a \ 288 -Wl,--whole-archive lib$$i.a \
273 -Wl,--no-whole-archive $$libs ${EX_LIBS} -lc ) || exit 1; \ 289 -Wl,--no-whole-archive $$libs ${EX_LIBS} -lc ) || exit 1; \
274 libs="$$libs -l$$i"; \ 290 libs="-l$$i $$libs"; \
275 done 291 done
276 292
277DETECT_GNU_LD=${CC} -v 2>&1 | grep '^gcc' >/dev/null 2>&1 && \ 293DETECT_GNU_LD=(${CC} -Wl,-V /dev/null 2>&1 | grep '^GNU ld' )>/dev/null
278 my_ld=`gcc -print-prog-name=ld 2>&1` && \
279 [ -n "$$my_ld" ] && \
280 $$my_ld -v 2>&1 | grep 'GNU ld' >/dev/null 2>&1
281 294
282# For Darwin AKA Mac OS/X (dyld) 295# For Darwin AKA Mac OS/X (dyld)
283do_darwin-shared: 296do_darwin-shared:
284 libs='-L. ${SHLIBDEPS}'; for i in ${SHLIBDIRS}; do \ 297 libs='-L. ${SHLIBDEPS}'; for i in ${SHLIBDIRS}; do \
285 ( set -x ; ${CC} --verbose -dynamiclib -o lib$$i${SHLIB_EXT} \ 298 if [ "${SHLIBDIRS}" = "ssl" -a -n "$(LIBKRB5)" ]; then \
299 libs="$(LIBKRB5) $$libs"; \
300 fi; \
301 ( set -x; ${CC} --verbose -dynamiclib -o lib$$i${SHLIB_EXT} \
286 lib$$i.a $$libs -all_load -current_version ${SHLIB_MAJOR}.${SHLIB_MINOR} \ 302 lib$$i.a $$libs -all_load -current_version ${SHLIB_MAJOR}.${SHLIB_MINOR} \
287 -compatibility_version ${SHLIB_MAJOR}.`echo ${SHLIB_MINOR} | cut -d. -f1` \ 303 -compatibility_version ${SHLIB_MAJOR}.`echo ${SHLIB_MINOR} | cut -d. -f1` \
288 -install_name ${INSTALLTOP}/lib/lib$$i${SHLIB_EXT} ) || exit 1; \ 304 -install_name ${INSTALLTOP}/lib/lib$$i${SHLIB_EXT} ) || exit 1; \
289 libs="$$libs -l`basename $$i${SHLIB_EXT} .dylib`"; \ 305 libs="-l`basename $$i${SHLIB_EXT} .dylib` $$libs"; \
290 echo "" ; \ 306 echo "" ; \
291 done 307 done
292 308
293do_cygwin-shared: 309do_cygwin-shared:
294 libs='-L. ${SHLIBDEPS}'; for i in ${SHLIBDIRS}; do \ 310 libs='-L. ${SHLIBDEPS}'; for i in ${SHLIBDIRS}; do \
295 ( set -x; ${CC} -shared -o cyg$$i.dll \ 311 if [ "${SHLIBDIRS}" = "ssl" -a -n "$(LIBKRB5)" ]; then \
312 libs="$(LIBKRB5) $$libs"; \
313 fi; \
314 ( set -x; ${CC} -shared -o cyg$$i-$(SHLIB_VERSION_NUMBER).dll \
296 -Wl,-Bsymbolic \ 315 -Wl,-Bsymbolic \
297 -Wl,--whole-archive lib$$i.a \ 316 -Wl,--whole-archive lib$$i.a \
298 -Wl,--out-implib,lib$$i.dll.a \ 317 -Wl,--out-implib,lib$$i.dll.a \
299 -Wl,--no-whole-archive $$libs ) || exit 1; \ 318 -Wl,--no-whole-archive $$libs ) || exit 1; \
300 libs="$$libs -l$$i"; \ 319 libs="-l$$i $$libs"; \
301 done 320 done
302 321
303# This assumes that GNU utilities are *not* used 322# This assumes that GNU utilities are *not* used
@@ -306,11 +325,14 @@ do_alpha-osf1-shared:
306 $(MAKE) do_gnu-shared; \ 325 $(MAKE) do_gnu-shared; \
307 else \ 326 else \
308 libs='-L. ${SHLIBDEPS}'; for i in ${SHLIBDIRS}; do \ 327 libs='-L. ${SHLIBDEPS}'; for i in ${SHLIBDIRS}; do \
328 if [ "${SHLIBDIRS}" = "ssl" -a -n "$(LIBKRB5)" ]; then \
329 libs="$(LIBKRB5) $$libs"; \
330 fi; \
309 ( set -x; ${CC} ${SHARED_LDFLAGS} \ 331 ( set -x; ${CC} ${SHARED_LDFLAGS} \
310 -shared -o lib$$i.so \ 332 -shared -o lib$$i.so \
311 -set_version "${SHLIB_VERSION_HISTORY}${SHLIB_VERSION_NUMBER}" \ 333 -set_version "${SHLIB_VERSION_HISTORY}${SHLIB_VERSION_NUMBER}" \
312 -all lib$$i.a -none $$libs ${EX_LIBS} -lc ) || exit 1; \ 334 -all lib$$i.a -none $$libs ${EX_LIBS} -lc ) || exit 1; \
313 libs="$$libs -l$$i"; \ 335 libs="-l$$i $$libs"; \
314 done; \ 336 done; \
315 fi 337 fi
316 338
@@ -322,11 +344,14 @@ do_tru64-shared:
322 $(MAKE) do_gnu-shared; \ 344 $(MAKE) do_gnu-shared; \
323 else \ 345 else \
324 libs='-L. ${SHLIBDEPS}'; for i in ${SHLIBDIRS}; do \ 346 libs='-L. ${SHLIBDEPS}'; for i in ${SHLIBDIRS}; do \
347 if [ "${SHLIBDIRS}" = "ssl" -a -n "$(LIBKRB5)" ]; then \
348 libs="$(LIBKRB5) $$libs"; \
349 fi; \
325 ( set -x; ${CC} ${SHARED_LDFLAGS} \ 350 ( set -x; ${CC} ${SHARED_LDFLAGS} \
326 -shared -msym -o lib$$i.so \ 351 -shared -msym -o lib$$i.so \
327 -set_version "${SHLIB_VERSION_HISTORY}${SHLIB_VERSION_NUMBER}" \ 352 -set_version "${SHLIB_VERSION_HISTORY}${SHLIB_VERSION_NUMBER}" \
328 -all lib$$i.a -none $$libs ${EX_LIBS} -lc ) || exit 1; \ 353 -all lib$$i.a -none $$libs ${EX_LIBS} -lc ) || exit 1; \
329 libs="$$libs -l$$i"; \ 354 libs="-l$$i $$libs"; \
330 done; \ 355 done; \
331 fi 356 fi
332 357
@@ -338,12 +363,15 @@ do_tru64-shared-rpath:
338 $(MAKE) do_gnu-shared; \ 363 $(MAKE) do_gnu-shared; \
339 else \ 364 else \
340 libs='-L. ${SHLIBDEPS}'; for i in ${SHLIBDIRS}; do \ 365 libs='-L. ${SHLIBDEPS}'; for i in ${SHLIBDIRS}; do \
366 if [ "${SHLIBDIRS}" = "ssl" -a -n "$(LIBKRB5)" ]; then \
367 libs="$(LIBKRB5) $$libs"; \
368 fi; \
341 ( set -x; ${CC} ${SHARED_LDFLAGS} \ 369 ( set -x; ${CC} ${SHARED_LDFLAGS} \
342 -shared -msym -o lib$$i.so \ 370 -shared -msym -o lib$$i.so \
343 -rpath ${INSTALLTOP}/lib \ 371 -rpath ${INSTALLTOP}/lib \
344 -set_version "${SHLIB_VERSION_HISTORY}${SHLIB_VERSION_NUMBER}" \ 372 -set_version "${SHLIB_VERSION_HISTORY}${SHLIB_VERSION_NUMBER}" \
345 -all lib$$i.a -none $$libs ${EX_LIBS} -lc ) || exit 1; \ 373 -all lib$$i.a -none $$libs ${EX_LIBS} -lc ) || exit 1; \
346 libs="$$libs -l$$i"; \ 374 libs="-l$$i $$libs"; \
347 done; \ 375 done; \
348 fi 376 fi
349 377
@@ -354,12 +382,18 @@ do_solaris-shared:
354 $(MAKE) do_gnu-shared; \ 382 $(MAKE) do_gnu-shared; \
355 else \ 383 else \
356 libs='-L. ${SHLIBDEPS}'; for i in ${SHLIBDIRS}; do \ 384 libs='-L. ${SHLIBDEPS}'; for i in ${SHLIBDIRS}; do \
385 if [ "${SHLIBDIRS}" = "ssl" -a -n "$(LIBKRB5)" ]; then \
386 libs="$(LIBKRB5) $$libs"; \
387 fi; \
357 ( PATH=/usr/ccs/bin:$$PATH ; export PATH; \ 388 ( PATH=/usr/ccs/bin:$$PATH ; export PATH; \
358 set -x; ${CC} ${SHARED_LDFLAGS} \ 389 MINUSZ='-z '; \
359 -G -o lib$$i.so.${SHLIB_MAJOR}.${SHLIB_MINOR} \ 390 (${CC} -v 2>&1 | grep gcc) > /dev/null && MINUSZ='-Wl,-z,'; \
391 set -x; ${CC} ${SHARED_LDFLAGS} -G -dy -z text \
392 -o lib$$i.so.${SHLIB_MAJOR}.${SHLIB_MINOR} \
360 -h lib$$i.so.${SHLIB_MAJOR}.${SHLIB_MINOR} \ 393 -h lib$$i.so.${SHLIB_MAJOR}.${SHLIB_MINOR} \
361 -z allextract lib$$i.a $$libs ${EX_LIBS} -lc ) || exit 1; \ 394 $${MINUSZ}allextract lib$$i.a $${MINUSZ}defaultextract \
362 libs="$$libs -l$$i"; \ 395 $$libs ${EX_LIBS} -lc ) || exit 1; \
396 libs="-l$$i $$libs"; \
363 done; \ 397 done; \
364 fi 398 fi
365 399
@@ -369,16 +403,20 @@ do_svr3-shared:
369 $(MAKE) do_gnu-shared; \ 403 $(MAKE) do_gnu-shared; \
370 else \ 404 else \
371 libs='-L. ${SHLIBDEPS}'; for i in ${SHLIBDIRS}; do \ 405 libs='-L. ${SHLIBDEPS}'; for i in ${SHLIBDIRS}; do \
406 if [ "${SHLIBDIRS}" = "ssl" -a -n "$(LIBKRB5)" ]; then \
407 libs="$(LIBKRB5) $$libs"; \
408 fi; \
372 ( PATH=/usr/ccs/bin:$$PATH ; export PATH; \ 409 ( PATH=/usr/ccs/bin:$$PATH ; export PATH; \
373 find . -name "*.o" -print > allobjs ; \ 410 find . -name "*.o" -print > allobjs ; \
374 OBJS= ; export OBJS ; \ 411 OBJS= ; export OBJS ; \
375 for obj in `ar t lib$$i.a` ; do \ 412 for obj in `ar t lib$$i.a` ; do \
376 OBJS="$${OBJS} `grep $$obj allobjs`" ; \ 413 OBJS="$${OBJS} `grep $$obj allobjs`" ; \
377 done ; \ 414 done ; \
378 set -x; ${CC} -G -o lib$$i.so.${SHLIB_MAJOR}.${SHLIB_MINOR} \ 415 set -x; ${CC} ${SHARED_LDFLAGS} \
416 -G -o lib$$i.so.${SHLIB_MAJOR}.${SHLIB_MINOR} \
379 -h lib$$i.so.${SHLIB_MAJOR}.${SHLIB_MINOR} \ 417 -h lib$$i.so.${SHLIB_MAJOR}.${SHLIB_MINOR} \
380 $${OBJS} $$libs ${EX_LIBS} ) || exit 1; \ 418 $${OBJS} $$libs ${EX_LIBS} ) || exit 1; \
381 libs="$$libs -l$$i"; \ 419 libs="-l$$i $$libs"; \
382 done; \ 420 done; \
383 fi 421 fi
384 422
@@ -388,17 +426,23 @@ do_svr5-shared:
388 $(MAKE) do_gnu-shared; \ 426 $(MAKE) do_gnu-shared; \
389 else \ 427 else \
390 libs='-L. ${SHLIBDEPS}'; for i in ${SHLIBDIRS}; do \ 428 libs='-L. ${SHLIBDEPS}'; for i in ${SHLIBDIRS}; do \
429 if [ "${SHLIBDIRS}" = "ssl" -a -n "$(LIBKRB5)" ]; then \
430 libs="$(LIBKRB5) $$libs"; \
431 fi; \
391 ( PATH=/usr/ccs/bin:$$PATH ; export PATH; \ 432 ( PATH=/usr/ccs/bin:$$PATH ; export PATH; \
433 SHARE_FLAG='-G'; \
434 (${CC} -v 2>&1 | grep gcc) > /dev/null && SHARE_FLAG='-shared'; \
392 find . -name "*.o" -print > allobjs ; \ 435 find . -name "*.o" -print > allobjs ; \
393 OBJS= ; export OBJS ; \ 436 OBJS= ; export OBJS ; \
394 for obj in `ar t lib$$i.a` ; do \ 437 for obj in `ar t lib$$i.a` ; do \
395 OBJS="$${OBJS} `grep $$obj allobjs`" ; \ 438 OBJS="$${OBJS} `grep $$obj allobjs`" ; \
396 done ; \ 439 done ; \
397 set -x; ${CC} ${SHARED_LDFLAGS} \ 440 set -x; LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH \
398 -G -o lib$$i.so.${SHLIB_MAJOR}.${SHLIB_MINOR} \ 441 ${CC} ${SHARED_LDFLAGS} \
442 $${SHARE_FLAG} -o lib$$i.so.${SHLIB_MAJOR}.${SHLIB_MINOR} \
399 -h lib$$i.so.${SHLIB_MAJOR}.${SHLIB_MINOR} \ 443 -h lib$$i.so.${SHLIB_MAJOR}.${SHLIB_MINOR} \
400 $${OBJS} $$libs ${EX_LIBS} ) || exit 1; \ 444 $${OBJS} $$libs ${EX_LIBS} ) || exit 1; \
401 libs="$$libs -l$$i"; \ 445 libs="-l$$i $$libs"; \
402 done; \ 446 done; \
403 fi 447 fi
404 448
@@ -408,11 +452,14 @@ do_irix-shared:
408 $(MAKE) do_gnu-shared; \ 452 $(MAKE) do_gnu-shared; \
409 else \ 453 else \
410 libs='-L. ${SHLIBDEPS}'; for i in ${SHLIBDIRS}; do \ 454 libs='-L. ${SHLIBDEPS}'; for i in ${SHLIBDIRS}; do \
455 if [ "${SHLIBDIRS}" = "ssl" -a -n "$(LIBKRB5)" ]; then \
456 libs="$(LIBKRB5) $$libs"; \
457 fi; \
411 ( set -x; ${CC} ${SHARED_LDFLAGS} \ 458 ( set -x; ${CC} ${SHARED_LDFLAGS} \
412 -shared -o lib$$i.so.${SHLIB_MAJOR}.${SHLIB_MINOR} \ 459 -shared -o lib$$i.so.${SHLIB_MAJOR}.${SHLIB_MINOR} \
413 -Wl,-soname,lib$$i.so.${SHLIB_MAJOR}.${SHLIB_MINOR} \ 460 -Wl,-soname,lib$$i.so.${SHLIB_MAJOR}.${SHLIB_MINOR} \
414 -all lib$$i.a $$libs ${EX_LIBS} -lc) || exit 1; \ 461 -all lib$$i.a $$libs ${EX_LIBS} -lc) || exit 1; \
415 libs="$$libs -l$$i"; \ 462 libs="-l$$i $$libs"; \
416 done; \ 463 done; \
417 fi 464 fi
418 465
@@ -429,6 +476,9 @@ do_irix-shared:
429# 476#
430do_hpux-shared: 477do_hpux-shared:
431 for i in ${SHLIBDIRS}; do \ 478 for i in ${SHLIBDIRS}; do \
479 if [ "${SHLIBDIRS}" = "ssl" -a -n "$(LIBKRB5)" ]; then \
480 libs="$(LIBKRB5) $$libs"; \
481 fi; \
432 ( set -x; /usr/ccs/bin/ld ${SHARED_LDFLAGS} \ 482 ( set -x; /usr/ccs/bin/ld ${SHARED_LDFLAGS} \
433 +vnocompatwarnings \ 483 +vnocompatwarnings \
434 -b -z +s \ 484 -b -z +s \
@@ -449,6 +499,9 @@ do_hpux-shared:
449# 499#
450do_hpux64-shared: 500do_hpux64-shared:
451 for i in ${SHLIBDIRS}; do \ 501 for i in ${SHLIBDIRS}; do \
502 if [ "${SHLIBDIRS}" = "ssl" -a -n "$(LIBKRB5)" ]; then \
503 libs="$(LIBKRB5) $$libs"; \
504 fi; \
452 ( set -x; /usr/ccs/bin/ld ${SHARED_LDFLAGS} \ 505 ( set -x; /usr/ccs/bin/ld ${SHARED_LDFLAGS} \
453 -b -z \ 506 -b -z \
454 -o lib$$i.sl.${SHLIB_MAJOR}.${SHLIB_MINOR} \ 507 -o lib$$i.sl.${SHLIB_MAJOR}.${SHLIB_MINOR} \
@@ -491,17 +544,24 @@ SHAREDFLAGS=${SHARED_LDFLAGS} -G -bE:lib$$i.exp -bM:SRE
491SHAREDCMD=$(CC) 544SHAREDCMD=$(CC)
492do_aix-shared: 545do_aix-shared:
493 libs='-L. ${SHLIBDEPS}'; for i in ${SHLIBDIRS}; do \ 546 libs='-L. ${SHLIBDEPS}'; for i in ${SHLIBDIRS}; do \
547 if [ "${SHLIBDIRS}" = "ssl" -a -n "$(LIBKRB5)" ]; then \
548 libs="$(LIBKRB5) $$libs"; \
549 fi; \
494 ( set -x; \ 550 ( set -x; \
495 ld -r -o $$i.o $(ALLSYMSFLAG) lib$$i.a && \ 551 ld -r -o lib$$i.o $(ALLSYMSFLAG) lib$$i.a && \
496 ( nm -Pg lib$$i.o | grep ' [BD] ' | cut -f1 -d' ' > lib$$i.exp; \ 552 ( nm -Pg lib$$i.o | grep ' [BD] ' | cut -f1 -d' ' > lib$$i.exp; \
497 $(SHAREDCMD) $(SHAREDFLAG) -o lib$$i.so lib$$i.o \ 553 $(SHAREDCMD) $(SHAREDFLAGS) \
554 -o lib$$i.so.${SHLIB_MAJOR}.${SHLIB_MINOR} lib$$i.o \
498 $$libs ${EX_LIBS} ) ) \ 555 $$libs ${EX_LIBS} ) ) \
499 || exit 1; \ 556 || exit 1; \
500 libs="$$libs -l$$i"; \ 557 libs="-l$$i $$libs"; \
501 done 558 done
502 559
503do_reliantunix-shared: 560do_reliantunix-shared:
504 libs='-L. ${SHLIBDEPS}'; for i in ${SHLIBDIRS}; do \ 561 libs='-L. ${SHLIBDEPS}'; for i in ${SHLIBDIRS}; do \
562 if [ "${SHLIBDIRS}" = "ssl" -a -n "$(LIBKRB5)" ]; then \
563 libs="$(LIBKRB5) $$libs"; \
564 fi; \
505 tmpdir=/tmp/openssl.$$$$ ; rm -rf $$tmpdir ; \ 565 tmpdir=/tmp/openssl.$$$$ ; rm -rf $$tmpdir ; \
506 ( set -x; \ 566 ( set -x; \
507 ( Opwd=`pwd` ; mkdir $$tmpdir || exit 1; \ 567 ( Opwd=`pwd` ; mkdir $$tmpdir || exit 1; \
@@ -511,19 +571,32 @@ do_reliantunix-shared:
511 cp $$tmpdir/lib$$i.so.${SHLIB_MAJOR}.${SHLIB_MINOR} . ; \ 571 cp $$tmpdir/lib$$i.so.${SHLIB_MAJOR}.${SHLIB_MINOR} . ; \
512 ) || exit 1; \ 572 ) || exit 1; \
513 rm -rf $$tmpdir ; \ 573 rm -rf $$tmpdir ; \
514 libs="$$libs -l$$i"; \ 574 libs="-l$$i $$libs"; \
515 done 575 done
516 576
577openssl.pc: Makefile.ssl
578 @ ( echo 'prefix=$(INSTALLTOP)'; \
579 echo 'exec_prefix=$${prefix}'; \
580 echo 'libdir=$${exec_prefix}/lib'; \
581 echo 'includedir=$${prefix}/include'; \
582 echo ''; \
583 echo 'Name: OpenSSL'; \
584 echo 'Description: Secure Sockets Layer and cryptography libraries and tools'; \
585 echo 'Version: '$(VERSION); \
586 echo 'Requires: '; \
587 echo 'Libs: -L$${libdir} -lssl -lcrypto $(LIBKRB5) $(EX_LIBS)'; \
588 echo 'Cflags: -I$${includedir} $(KRB5_INCLUDES)' ) > openssl.pc
589
517Makefile.ssl: Makefile.org 590Makefile.ssl: Makefile.org
518 @echo "Makefile.ssl is older than Makefile.org." 591 @echo "Makefile.ssl is older than Makefile.org."
519 @echo "Reconfigure the source tree (via './config' or 'perl Configure'), please." 592 @echo "Reconfigure the source tree (via './config' or 'perl Configure'), please."
520 @false 593 @false
521 594
522libclean: 595libclean:
523 rm -f *.a */lib */*/lib 596 rm -f *.map *.so *.so.* engines/*.so *.a */lib */*/lib
524 597
525clean: 598clean: libclean
526 rm -f shlib/*.o *.o core a.out fluff *.map rehash.time testlog make.log cctest cctest.c 599 rm -f shlib/*.o *.o core a.out fluff rehash.time testlog make.log cctest cctest.c
527 @for i in $(DIRS) ;\ 600 @for i in $(DIRS) ;\
528 do \ 601 do \
529 if [ -d "$$i" ]; then \ 602 if [ -d "$$i" ]; then \
@@ -532,7 +605,8 @@ clean:
532 rm -f $(LIBS); \ 605 rm -f $(LIBS); \
533 fi; \ 606 fi; \
534 done; 607 done;
535 rm -f *.a *.o speed.* *.map *.so .pure core 608 rm -f openssl.pc
609 rm -f speed.* .pure
536 rm -f $(TARFILE) 610 rm -f $(TARFILE)
537 @for i in $(ONEDIRS) ;\ 611 @for i in $(ONEDIRS) ;\
538 do \ 612 do \
@@ -582,8 +656,12 @@ rehash: rehash.time
582rehash.time: certs 656rehash.time: certs
583 @(OPENSSL="`pwd`/apps/openssl"; OPENSSL_DEBUG_MEMORY=on; \ 657 @(OPENSSL="`pwd`/apps/openssl"; OPENSSL_DEBUG_MEMORY=on; \
584 export OPENSSL OPENSSL_DEBUG_MEMORY; \ 658 export OPENSSL OPENSSL_DEBUG_MEMORY; \
585 LD_LIBRARY_PATH="`pwd`"; DYLD_LIBRARY_PATH="`pwd`"; SHLIB_PATH="`pwd`"; LIBPATH="`pwd`"; \ 659 LD_LIBRARY_PATH="`pwd`:$$LD_LIBRARY_PATH"; \
586 export LD_LIBRARY_PATH DYLD_LIBRARY_PATH SHLIB_PATH LIBPATH; \ 660 DYLD_LIBRARY_PATH="`pwd`:$$DYLD_LIBRARY_PATH"; \
661 SHLIB_PATH="`pwd`:$$SHLIB_PATH"; \
662 LIBPATH="`pwd`:$$LIBPATH"; \
663 if [ "$(PLATFORM)" = "Cygwin" ]; then PATH="`pwd`:$$PATH"; fi; \
664 export LD_LIBRARY_PATH DYLD_LIBRARY_PATH SHLIB_PATH LIBPATH PATH; \
587 $(PERL) tools/c_rehash certs) 665 $(PERL) tools/c_rehash certs)
588 touch rehash.time 666 touch rehash.time
589 667
@@ -592,9 +670,13 @@ test: tests
592tests: rehash 670tests: rehash
593 @(cd test && echo "testing..." && \ 671 @(cd test && echo "testing..." && \
594 $(MAKE) CC='${CC}' PLATFORM='${PLATFORM}' CFLAG='${CFLAG}' SDIRS='$(SDIRS)' INSTALLTOP='${INSTALLTOP}' PEX_LIBS='${PEX_LIBS}' EX_LIBS='${EX_LIBS}' BN_ASM='${BN_ASM}' DES_ENC='${DES_ENC}' BF_ENC='${BF_ENC}' CAST_ENC='${CAST_ENC}' RC4_ENC='${RC4_ENC}' RC5_ENC='${RC5_ENC}' SHA1_ASM_OBJ='${SHA1_ASM_OBJ}' MD5_ASM_OBJ='${MD5_ASM_OBJ}' RMD160_ASM_OBJ='${RMD160_ASM_OBJ}' AR='${AR}' PROCESSOR='${PROCESSOR}' PERL='${PERL}' RANLIB='${RANLIB}' TESTS='${TESTS}' KRB5_INCLUDES='${KRB5_INCLUDES}' LIBKRB5='${LIBKRB5}' EXE_EXT='${EXE_EXT}' SHARED_LIBS='${SHARED_LIBS}' SHLIB_EXT='${SHLIB_EXT}' SHLIB_TARGET='${SHLIB_TARGET}' TESTS='${TESTS}' OPENSSL_DEBUG_MEMORY=on tests ); 672 $(MAKE) CC='${CC}' PLATFORM='${PLATFORM}' CFLAG='${CFLAG}' SDIRS='$(SDIRS)' INSTALLTOP='${INSTALLTOP}' PEX_LIBS='${PEX_LIBS}' EX_LIBS='${EX_LIBS}' BN_ASM='${BN_ASM}' DES_ENC='${DES_ENC}' BF_ENC='${BF_ENC}' CAST_ENC='${CAST_ENC}' RC4_ENC='${RC4_ENC}' RC5_ENC='${RC5_ENC}' SHA1_ASM_OBJ='${SHA1_ASM_OBJ}' MD5_ASM_OBJ='${MD5_ASM_OBJ}' RMD160_ASM_OBJ='${RMD160_ASM_OBJ}' AR='${AR}' PROCESSOR='${PROCESSOR}' PERL='${PERL}' RANLIB='${RANLIB}' TESTS='${TESTS}' KRB5_INCLUDES='${KRB5_INCLUDES}' LIBKRB5='${LIBKRB5}' EXE_EXT='${EXE_EXT}' SHARED_LIBS='${SHARED_LIBS}' SHLIB_EXT='${SHLIB_EXT}' SHLIB_TARGET='${SHLIB_TARGET}' TESTS='${TESTS}' OPENSSL_DEBUG_MEMORY=on tests );
595 @LD_LIBRARY_PATH="`pwd`"; DYLD_LIBRARY_PATH="`pwd`"; SHLIB_PATH="`pwd`"; LIBPATH="`pwd`"; \ 673 @LD_LIBRARY_PATH="`pwd`:$$LD_LIBRARY_PATH"; \
596 export LD_LIBRARY_PATH DYLD_LIBRARY_PATH SHLIB_PATH LIBPATH; \ 674 DYLD_LIBRARY_PATH="`pwd`:$$DYLD_LIBRARY_PATH"; \
597 apps/openssl version -a 675 SHLIB_PATH="`pwd`:$$SHLIB_PATH"; \
676 LIBPATH="`pwd`:$$LIBPATH"; \
677 if [ "$(PLATFORM)" = "Cygwin" ]; then PATH="`pwd`:$$PATH"; fi; \
678 export LD_LIBRARY_PATH DYLD_LIBRARY_PATH SHLIB_PATH LIBPATH PATH; \
679 apps/openssl version -a
598 680
599report: 681report:
600 @$(PERL) util/selftest.pl 682 @$(PERL) util/selftest.pl
@@ -656,6 +738,9 @@ update: depend errors stacks util/libeay.num util/ssleay.num crypto/objects/obj_
656# and read directly, requiring GNU-Tar. Call "make TAR=gtar dist" if the normal 738# and read directly, requiring GNU-Tar. Call "make TAR=gtar dist" if the normal
657# tar does not support the --files-from option. 739# tar does not support the --files-from option.
658tar: 740tar:
741 find . -type d -print | xargs chmod 755
742 find . -type f -print | xargs chmod a+r
743 find . -type f -perm -0100 -print | xargs chmod a+x
659 find * \! -path CVS/\* \! -path \*/CVS/\* \! -name CVS \! -name .cvsignore \! -name STATUS \! -name TABLE | sort > ../$(TARFILE).list; \ 744 find * \! -path CVS/\* \! -path \*/CVS/\* \! -name CVS \! -name .cvsignore \! -name STATUS \! -name TABLE | sort > ../$(TARFILE).list; \
660 $(TAR) $(TARFLAGS) --files-from ../$(TARFILE).list -cvf - | \ 745 $(TAR) $(TARFLAGS) --files-from ../$(TARFILE).list -cvf - | \
661 tardy --user_number=0 --user_name=openssl \ 746 tardy --user_number=0 --user_name=openssl \
@@ -685,6 +770,7 @@ dist_pem_h:
685install: all install_docs 770install: all install_docs
686 @$(PERL) $(TOP)/util/mkdir-p.pl $(INSTALL_PREFIX)$(INSTALLTOP)/bin \ 771 @$(PERL) $(TOP)/util/mkdir-p.pl $(INSTALL_PREFIX)$(INSTALLTOP)/bin \
687 $(INSTALL_PREFIX)$(INSTALLTOP)/lib \ 772 $(INSTALL_PREFIX)$(INSTALLTOP)/lib \
773 $(INSTALL_PREFIX)$(INSTALLTOP)/lib/pkgconfig \
688 $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl \ 774 $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl \
689 $(INSTALL_PREFIX)$(OPENSSLDIR)/misc \ 775 $(INSTALL_PREFIX)$(OPENSSLDIR)/misc \
690 $(INSTALL_PREFIX)$(OPENSSLDIR)/certs \ 776 $(INSTALL_PREFIX)$(OPENSSLDIR)/certs \
@@ -706,9 +792,10 @@ install: all install_docs
706 do \ 792 do \
707 if [ -f "$$i" ]; then \ 793 if [ -f "$$i" ]; then \
708 ( echo installing $$i; \ 794 ( echo installing $$i; \
709 cp $$i $(INSTALL_PREFIX)$(INSTALLTOP)/lib; \ 795 cp $$i $(INSTALL_PREFIX)$(INSTALLTOP)/lib/$$i.new; \
710 $(RANLIB) $(INSTALL_PREFIX)$(INSTALLTOP)/lib/$$i; \ 796 $(RANLIB) $(INSTALL_PREFIX)$(INSTALLTOP)/lib/$$i.new; \
711 chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/lib/$$i ); \ 797 chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/lib/$$i.new; \
798 mv -f $(INSTALL_PREFIX)$(INSTALLTOP)/lib/$$i.new $(INSTALL_PREFIX)$(INSTALLTOP)/lib/$$i ); \
712 fi; \ 799 fi; \
713 done; 800 done;
714 @if [ -n "$(SHARED_LIBS)" ]; then \ 801 @if [ -n "$(SHARED_LIBS)" ]; then \
@@ -718,14 +805,17 @@ install: all install_docs
718 if [ -f "$$i" -o -f "$$i.a" ]; then \ 805 if [ -f "$$i" -o -f "$$i.a" ]; then \
719 ( echo installing $$i; \ 806 ( echo installing $$i; \
720 if [ "$(PLATFORM)" != "Cygwin" ]; then \ 807 if [ "$(PLATFORM)" != "Cygwin" ]; then \
721 cp $$i $(INSTALL_PREFIX)$(INSTALLTOP)/lib; \ 808 cp $$i $(INSTALL_PREFIX)$(INSTALLTOP)/lib/$$i.new; \
722 chmod 555 $(INSTALL_PREFIX)$(INSTALLTOP)/lib/$$i; \ 809 chmod 555 $(INSTALL_PREFIX)$(INSTALLTOP)/lib/$$i.new; \
810 mv -f $(INSTALL_PREFIX)$(INSTALLTOP)/lib/$$i.new $(INSTALL_PREFIX)$(INSTALLTOP)/lib/$$i; \
723 else \ 811 else \
724 c=`echo $$i | sed 's/^lib/cyg/'`; \ 812 c=`echo $$i | sed 's/^lib\(.*\)\.dll/cyg\1-$(SHLIB_VERSION_NUMBER).dll/'`; \
725 cp $$c $(INSTALL_PREFIX)$(INSTALLTOP)/bin/$$c; \ 813 cp $$c $(INSTALL_PREFIX)$(INSTALLTOP)/bin/$$c.new; \
726 chmod 755 $(INSTALL_PREFIX)$(INSTALLTOP)/bin/$$c; \ 814 chmod 755 $(INSTALL_PREFIX)$(INSTALLTOP)/bin/$$c.new; \
727 cp $$i.a $(INSTALL_PREFIX)$(INSTALLTOP)/lib/$$i.a; \ 815 mv -f $(INSTALL_PREFIX)$(INSTALLTOP)/bin/$$c.new $(INSTALL_PREFIX)$(INSTALLTOP)/bin/$$c; \
728 chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/lib/$$i.a; \ 816 cp $$i.a $(INSTALL_PREFIX)$(INSTALLTOP)/lib/$$i.a.new; \
817 chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/lib/$$i.a.new; \
818 mv -f $(INSTALL_PREFIX)$(INSTALLTOP)/lib/$$i.a.new $(INSTALL_PREFIX)$(INSTALLTOP)/lib/$$i.a; \
729 fi ); \ 819 fi ); \
730 fi; \ 820 fi; \
731 done; \ 821 done; \
@@ -733,7 +823,14 @@ install: all install_docs
733 cd $(INSTALL_PREFIX)$(INSTALLTOP)/lib; \ 823 cd $(INSTALL_PREFIX)$(INSTALLTOP)/lib; \
734 set $(MAKE); \ 824 set $(MAKE); \
735 $$1 -f $$here/Makefile link-shared ); \ 825 $$1 -f $$here/Makefile link-shared ); \
826 if [ "$(INSTALLTOP)" != "/usr" ]; then \
827 echo 'OpenSSL shared libraries have been installed in:'; \
828 echo ' $(INSTALLTOP)'; \
829 echo ''; \
830 sed -e '1,/^$$/d' doc/openssl-shared.txt; \
831 fi; \
736 fi 832 fi
833 cp openssl.pc $(INSTALL_PREFIX)$(INSTALLTOP)/lib/pkgconfig
737 834
738install_docs: 835install_docs:
739 @$(PERL) $(TOP)/util/mkdir-p.pl \ 836 @$(PERL) $(TOP)/util/mkdir-p.pl \
@@ -742,25 +839,42 @@ install_docs:
742 $(INSTALL_PREFIX)$(MANDIR)/man5 \ 839 $(INSTALL_PREFIX)$(MANDIR)/man5 \
743 $(INSTALL_PREFIX)$(MANDIR)/man7 840 $(INSTALL_PREFIX)$(MANDIR)/man7
744 @pod2man="`cd util; ./pod2mantest $(PERL)`"; \ 841 @pod2man="`cd util; ./pod2mantest $(PERL)`"; \
842 here="`pwd`"; \
843 filecase=; \
844 if [ "$(PLATFORM)" = "DJGPP" -o "$(PLATFORM)" = "Cygwin" ]; then \
845 filecase=-i; \
846 fi; \
745 for i in doc/apps/*.pod; do \ 847 for i in doc/apps/*.pod; do \
746 fn=`basename $$i .pod`; \ 848 fn=`basename $$i .pod`; \
747 if [ "$$fn" = "config" ]; then sec=5; else sec=1; fi; \ 849 if [ "$$fn" = "config" ]; then sec=5; else sec=1; fi; \
748 echo "installing man$$sec/`basename $$i .pod`.$$sec"; \ 850 echo "installing man$$sec/$$fn.$$sec"; \
749 (cd `$(PERL) util/dirname.pl $$i`; \ 851 (cd `$(PERL) util/dirname.pl $$i`; \
750 sh -c "$$pod2man \ 852 sh -c "$$pod2man \
751 --section=$$sec --center=OpenSSL \ 853 --section=$$sec --center=OpenSSL \
752 --release=$(VERSION) `basename $$i`") \ 854 --release=$(VERSION) `basename $$i`") \
753 > $(INSTALL_PREFIX)$(MANDIR)/man$$sec/`basename $$i .pod`.$$sec; \ 855 > $(INSTALL_PREFIX)$(MANDIR)/man$$sec/$$fn.$$sec; \
856 $(PERL) util/extract-names.pl < $$i | \
857 grep -v $$filecase "^$$fn\$$" | \
858 (cd $(INSTALL_PREFIX)$(MANDIR)/man$$sec/; \
859 while read n; do \
860 $$here/util/point.sh $$fn.$$sec $$n.$$sec; \
861 done); \
754 done; \ 862 done; \
755 for i in doc/crypto/*.pod doc/ssl/*.pod; do \ 863 for i in doc/crypto/*.pod doc/ssl/*.pod; do \
756 fn=`basename $$i .pod`; \ 864 fn=`basename $$i .pod`; \
757 if [ "$$fn" = "des_modes" ]; then sec=7; else sec=3; fi; \ 865 if [ "$$fn" = "des_modes" ]; then sec=7; else sec=3; fi; \
758 echo "installing man$$sec/`basename $$i .pod`.$$sec"; \ 866 echo "installing man$$sec/$$fn.$$sec"; \
759 (cd `$(PERL) util/dirname.pl $$i`; \ 867 (cd `$(PERL) util/dirname.pl $$i`; \
760 sh -c "$$pod2man \ 868 sh -c "$$pod2man \
761 --section=$$sec --center=OpenSSL \ 869 --section=$$sec --center=OpenSSL \
762 --release=$(VERSION) `basename $$i`") \ 870 --release=$(VERSION) `basename $$i`") \
763 > $(INSTALL_PREFIX)$(MANDIR)/man$$sec/`basename $$i .pod`.$$sec; \ 871 > $(INSTALL_PREFIX)$(MANDIR)/man$$sec/$$fn.$$sec; \
872 $(PERL) util/extract-names.pl < $$i | \
873 grep -v $$filecase "^$$fn\$$" | \
874 (cd $(INSTALL_PREFIX)$(MANDIR)/man$$sec/; \
875 while read n; do \
876 $$here/util/point.sh $$fn.$$sec $$n.$$sec; \
877 done); \
764 done 878 done
765 879
766# DO NOT DELETE THIS LINE -- make depend depends on it. 880# DO NOT DELETE THIS LINE -- make depend depends on it.
diff --git a/src/lib/libssl/src/NEWS b/src/lib/libssl/src/NEWS
index 418b3b0505..dce63f0549 100644
--- a/src/lib/libssl/src/NEWS
+++ b/src/lib/libssl/src/NEWS
@@ -5,6 +5,28 @@
5 This file gives a brief overview of the major changes between each OpenSSL 5 This file gives a brief overview of the major changes between each OpenSSL
6 release. For more details please read the CHANGES file. 6 release. For more details please read the CHANGES file.
7 7
8 Major changes between OpenSSL 0.9.7a and OpenSSL 0.9.7b:
9
10 o Security: counter the Klima-Pokorny-Rosa extension of
11 Bleichbacher's attack
12 o Security: make RSA blinding default.
13 o Configuration: Irix fixes, AIX fixes, better mingw support.
14 o Support for new platforms: linux-ia64-ecc.
15 o Build: shared library support fixes.
16 o ASN.1: treat domainComponent correctly.
17 o Documentation: fixes and additions.
18
19 Major changes between OpenSSL 0.9.7 and OpenSSL 0.9.7a:
20
21 o Security: Important security related bugfixes.
22 o Enhanced compatibility with MIT Kerberos.
23 o Can be built without the ENGINE framework.
24 o IA32 assembler enhancements.
25 o Support for new platforms: FreeBSD/IA64 and FreeBSD/Sparc64.
26 o Configuration: the no-err option now works properly.
27 o SSL/TLS: now handles manual certificate chain building.
28 o SSL/TLS: certain session ID malfunctions corrected.
29
8 Major changes between OpenSSL 0.9.6 and OpenSSL 0.9.7: 30 Major changes between OpenSSL 0.9.6 and OpenSSL 0.9.7:
9 31
10 o New library section OCSP. 32 o New library section OCSP.
@@ -17,6 +39,15 @@
17 a separate distribution. 39 a separate distribution.
18 o New elliptic curve library section. 40 o New elliptic curve library section.
19 o New AES (Rijndael) library section. 41 o New AES (Rijndael) library section.
42 o Support for new platforms: Windows CE, Tandem OSS, A/UX, AIX 64-bit,
43 Linux x86_64, Linux 64-bit on Sparc v9
44 o Extended support for some platforms: VxWorks
45 o Enhanced support for shared libraries.
46 o Now only builds PIC code when shared library support is requested.
47 o Support for pkg-config.
48 o Lots of new manuals.
49 o Makes symbolic links to or copies of manuals to cover all described
50 functions.
20 o Change DES API to clean up the namespace (some applications link also 51 o Change DES API to clean up the namespace (some applications link also
21 against libdes providing similar functions having the same name). 52 against libdes providing similar functions having the same name).
22 Provide macros for backward compatibility (will be removed in the 53 Provide macros for backward compatibility (will be removed in the
@@ -30,16 +61,43 @@
30 o Reworked parts of the BIGNUM code. 61 o Reworked parts of the BIGNUM code.
31 o Support for new engines: Broadcom ubsec, Accelerated Encryption 62 o Support for new engines: Broadcom ubsec, Accelerated Encryption
32 Processing, IBM 4758. 63 Processing, IBM 4758.
64 o A few new engines added in the demos area.
33 o Extended and corrected OID (object identifier) table. 65 o Extended and corrected OID (object identifier) table.
34 o PRNG: query at more locations for a random device, automatic query for 66 o PRNG: query at more locations for a random device, automatic query for
35 EGD style random sources at several locations. 67 EGD style random sources at several locations.
36 o SSL/TLS: allow optional cipher choice according to server's preference. 68 o SSL/TLS: allow optional cipher choice according to server's preference.
37 o SSL/TLS: allow server to explicitly set new session ids. 69 o SSL/TLS: allow server to explicitly set new session ids.
38 o SSL/TLS: support Kerberos cipher suites (RFC2712). 70 o SSL/TLS: support Kerberos cipher suites (RFC2712).
71 Only supports MIT Kerberos for now.
39 o SSL/TLS: allow more precise control of renegotiations and sessions. 72 o SSL/TLS: allow more precise control of renegotiations and sessions.
40 o SSL/TLS: add callback to retrieve SSL/TLS messages. 73 o SSL/TLS: add callback to retrieve SSL/TLS messages.
41 o SSL/TLS: support AES cipher suites (RFC3268). 74 o SSL/TLS: support AES cipher suites (RFC3268).
42 75
76 Major changes between OpenSSL 0.9.6i and OpenSSL 0.9.6j:
77
78 o Security: counter the Klima-Pokorny-Rosa extension of
79 Bleichbacher's attack
80 o Security: make RSA blinding default.
81 o Build: shared library support fixes.
82
83 Major changes between OpenSSL 0.9.6h and OpenSSL 0.9.6i:
84
85 o Important security related bugfixes.
86
87 Major changes between OpenSSL 0.9.6g and OpenSSL 0.9.6h:
88
89 o New configuration targets for Tandem OSS and A/UX.
90 o New OIDs for Microsoft attributes.
91 o Better handling of SSL session caching.
92 o Better comparison of distinguished names.
93 o Better handling of shared libraries in a mixed GNU/non-GNU environment.
94 o Support assembler code with Borland C.
95 o Fixes for length problems.
96 o Fixes for uninitialised variables.
97 o Fixes for memory leaks, some unusual crashes and some race conditions.
98 o Fixes for smaller building problems.
99 o Updates of manuals, FAQ and other instructive documents.
100
43 Major changes between OpenSSL 0.9.6f and OpenSSL 0.9.6g: 101 Major changes between OpenSSL 0.9.6f and OpenSSL 0.9.6g:
44 102
45 o Important building fixes on Unix. 103 o Important building fixes on Unix.
diff --git a/src/lib/libssl/src/PROBLEMS b/src/lib/libssl/src/PROBLEMS
index bf532d112b..85e96a5ebe 100644
--- a/src/lib/libssl/src/PROBLEMS
+++ b/src/lib/libssl/src/PROBLEMS
@@ -46,3 +46,86 @@ scripts use the same name for output and input files, which means different
46will interfere with each other and lead to test failure. 46will interfere with each other and lead to test failure.
47 47
48The solution is simple for now: don't run parallell make when testing. 48The solution is simple for now: don't run parallell make when testing.
49
50
51* Bugs in gcc 3.0 triggered
52
53According to a problem report, there are bugs in gcc 3.0 that are
54triggered by some of the code in OpenSSL, more specifically in
55PEM_get_EVP_CIPHER_INFO(). The triggering code is the following:
56
57 header+=11;
58 if (*header != '4') return(0); header++;
59 if (*header != ',') return(0); header++;
60
61What happens is that gcc might optimize a little too agressively, and
62you end up with an extra incrementation when *header != '4'.
63
64We recommend that you upgrade gcc to as high a 3.x version as you can.
65
66* solaris64-sparcv9-cc SHA-1 performance with WorkShop 6 compiler.
67
68As subject suggests SHA-1 might perform poorly (4 times slower)
69if compiled with WorkShop 6 compiler and -xarch=v9. The cause for
70this seems to be the fact that compiler emits multiplication to
71perform shift operations:-( To work the problem around configure
72with './Configure solaris64-sparcv9-cc -DMD32_REG_T=int'.
73
74* Problems with hp-parisc2-cc target when used with "no-asm" flag
75
76When using the hp-parisc2-cc target, wrong bignum code is generated.
77This is due to the SIXTY_FOUR_BIT build being compiled with the +O3
78aggressive optimization.
79The problem manifests itself by the BN_kronecker test hanging in an
80endless loop. Reason: the BN_kronecker test calls BN_generate_prime()
81which itself hangs. The reason could be tracked down to the bn_mul_comba8()
82function in bn_asm.c. At some occasions the higher 32bit value of r[7]
83is off by 1 (meaning: calculated=shouldbe+1). Further analysis failed,
84as no debugger support possible at +O3 and additional fprintf()'s
85introduced fixed the bug, therefore it is most likely a bug in the
86optimizer.
87The bug was found in the BN_kronecker test but may also lead to
88failures in other parts of the code.
89(See Ticket #426.)
90
91Workaround: modify the target to +O2 when building with no-asm.
92
93* Poor support for AIX shared builds.
94
95do_aix-shared rule is not flexible enough to parameterize through a
96config-line. './Configure aix43-cc shared' is working, but not
97'./Configure aix64-gcc shared'. In latter case make fails to create shared
98libraries. It's possible to build 64-bit shared libraries by running
99'env OBJECT_MODE=64 make', but we need more elegant solution. Preferably one
100supporting even gcc shared builds. See RT#463 for background information.
101
102* Problems building shared libraries on SCO OpenServer Release 5.0.6
103 with gcc 2.95.3
104
105The symptoms appear when running the test suite, more specifically
106test/ectest, with the following result:
107
108OSSL_LIBPATH="`cd ..; pwd`"; LD_LIBRARY_PATH="$OSSL_LIBPATH:$LD_LIBRARY_PATH"; DYLD_LIBRARY_PATH="$OSSL_LIBPATH:$DYLD_LIBRARY_PATH"; SHLIB_PATH="$OSSL_LIBPATH:$SHLIB_PATH"; LIBPATH="$OSSL_LIBPATH:$LIBPATH"; if [ "debug-sco5-gcc" = "Cygwin" ]; then PATH="${LIBPATH}:$PATH"; fi; export LD_LIBRARY_PATH DYLD_LIBRARY_PATH SHLIB_PATH LIBPATH PATH; ./ectest
109ectest.c:186: ABORT
110
111The cause of the problem seems to be that isxdigit(), called from
112BN_hex2bn(), returns 0 on a perfectly legitimate hex digit. Further
113investigation shows that any of the isxxx() macros return 0 on any
114input. A direct look in the information array that the isxxx() use,
115called __ctype, shows that it contains all zeroes...
116
117Taking a look at the newly created libcrypto.so with nm, one can see
118that the variable __ctype is defined in libcrypto's .bss (which
119explains why it is filled with zeroes):
120
121$ nm -Pg libcrypto.so | grep __ctype
122__ctype B 0011659c
123__ctype2 U
124
125Curiously, __ctype2 is undefined, in spite of being declared in
126/usr/include/ctype.h in exactly the same way as __ctype.
127
128Any information helping to solve this issue would be deeply
129appreciated.
130
131NOTE: building non-shared doesn't come with this problem.
diff --git a/src/lib/libssl/src/README b/src/lib/libssl/src/README
index 4228e145f9..3af69bfdb5 100644
--- a/src/lib/libssl/src/README
+++ b/src/lib/libssl/src/README
@@ -1,7 +1,7 @@
1 1
2 OpenSSL 0.9.7-beta3 30 Jul 2002 2 OpenSSL 0.9.7b 10 Apr 2003
3 3
4 Copyright (c) 1998-2002 The OpenSSL Project 4 Copyright (c) 1998-2003 The OpenSSL Project
5 Copyright (c) 1995-1998 Eric A. Young, Tim J. Hudson 5 Copyright (c) 1995-1998 Eric A. Young, Tim J. Hudson
6 All rights reserved. 6 All rights reserved.
7 7
diff --git a/src/lib/libssl/src/apps/CA.pl b/src/lib/libssl/src/apps/CA.pl
index 915fa5beca..8b2ce7ea42 100644
--- a/src/lib/libssl/src/apps/CA.pl
+++ b/src/lib/libssl/src/apps/CA.pl
@@ -1,4 +1,4 @@
1#!/usr/local/bin/perl5 1#!/usr/local/bin/perl
2# 2#
3# CA - wrapper around ca to make it easier to use ... basically ca requires 3# CA - wrapper around ca to make it easier to use ... basically ca requires
4# some setup stuff to be done before you can use it and this makes 4# some setup stuff to be done before you can use it and this makes
diff --git a/src/lib/libssl/src/apps/apps.c b/src/lib/libssl/src/apps/apps.c
index 1a24b1c596..007e3e06c3 100644
--- a/src/lib/libssl/src/apps/apps.c
+++ b/src/lib/libssl/src/apps/apps.c
@@ -114,9 +114,7 @@
114#include <string.h> 114#include <string.h>
115#include <sys/types.h> 115#include <sys/types.h>
116#include <sys/stat.h> 116#include <sys/stat.h>
117#define NON_MAIN 117#include <ctype.h>
118#include "apps.h"
119#undef NON_MAIN
120#include <openssl/err.h> 118#include <openssl/err.h>
121#include <openssl/x509.h> 119#include <openssl/x509.h>
122#include <openssl/x509v3.h> 120#include <openssl/x509v3.h>
@@ -124,7 +122,9 @@
124#include <openssl/pkcs12.h> 122#include <openssl/pkcs12.h>
125#include <openssl/ui.h> 123#include <openssl/ui.h>
126#include <openssl/safestack.h> 124#include <openssl/safestack.h>
125#ifndef OPENSSL_NO_ENGINE
127#include <openssl/engine.h> 126#include <openssl/engine.h>
127#endif
128 128
129#ifdef OPENSSL_SYS_WINDOWS 129#ifdef OPENSSL_SYS_WINDOWS
130#define strcasecmp _stricmp 130#define strcasecmp _stricmp
@@ -136,9 +136,9 @@
136# endif /* NO_STRINGS_H */ 136# endif /* NO_STRINGS_H */
137#endif 137#endif
138 138
139#ifdef OPENSSL_SYS_WINDOWS 139#define NON_MAIN
140# include "bss_file.c" 140#include "apps.h"
141#endif 141#undef NON_MAIN
142 142
143typedef struct { 143typedef struct {
144 char *name; 144 char *name;
@@ -335,8 +335,7 @@ void program_name(char *in, char *out, int size)
335 p++; 335 p++;
336 else 336 else
337 p=in; 337 p=in;
338 strncpy(out,p,size-1); 338 BUF_strlcpy(out,p,size);
339 out[size-1]='\0';
340 } 339 }
341#endif 340#endif
342#endif 341#endif
@@ -344,6 +343,7 @@ void program_name(char *in, char *out, int size)
344#ifdef OPENSSL_SYS_WIN32 343#ifdef OPENSSL_SYS_WIN32
345int WIN32_rename(char *from, char *to) 344int WIN32_rename(char *from, char *to)
346 { 345 {
346#ifndef OPENSSL_SYS_WINCE
347 /* Windows rename gives an error if 'to' exists, so delete it 347 /* Windows rename gives an error if 'to' exists, so delete it
348 * first and ignore file not found errror 348 * first and ignore file not found errror
349 */ 349 */
@@ -351,6 +351,46 @@ int WIN32_rename(char *from, char *to)
351 return -1; 351 return -1;
352#undef rename 352#undef rename
353 return rename(from, to); 353 return rename(from, to);
354#else
355 /* convert strings to UNICODE */
356 {
357 BOOL result = FALSE;
358 WCHAR* wfrom;
359 WCHAR* wto;
360 int i;
361 wfrom = malloc((strlen(from)+1)*2);
362 wto = malloc((strlen(to)+1)*2);
363 if (wfrom != NULL && wto != NULL)
364 {
365 for (i=0; i<(int)strlen(from)+1; i++)
366 wfrom[i] = (short)from[i];
367 for (i=0; i<(int)strlen(to)+1; i++)
368 wto[i] = (short)to[i];
369 result = MoveFile(wfrom, wto);
370 }
371 if (wfrom != NULL)
372 free(wfrom);
373 if (wto != NULL)
374 free(wto);
375 return result;
376 }
377#endif
378 }
379#endif
380
381#ifdef OPENSSL_SYS_VMS
382int VMS_strcasecmp(const char *str1, const char *str2)
383 {
384 while (*str1 && *str2)
385 {
386 int res = toupper(*str1) - toupper(*str2);
387 if (res) return res < 0 ? -1 : 1;
388 }
389 if (*str1)
390 return 1;
391 if (*str2)
392 return -1;
393 return 0;
354 } 394 }
355#endif 395#endif
356 396
@@ -429,16 +469,20 @@ int app_init(long mesgwin)
429 469
430int dump_cert_text (BIO *out, X509 *x) 470int dump_cert_text (BIO *out, X509 *x)
431{ 471{
432 char buf[256]; 472 char *p;
433 X509_NAME_oneline(X509_get_subject_name(x),buf,256); 473
474 p=X509_NAME_oneline(X509_get_subject_name(x),NULL,0);
434 BIO_puts(out,"subject="); 475 BIO_puts(out,"subject=");
435 BIO_puts(out,buf); 476 BIO_puts(out,p);
477 OPENSSL_free(p);
436 478
437 X509_NAME_oneline(X509_get_issuer_name(x),buf,256); 479 p=X509_NAME_oneline(X509_get_issuer_name(x),NULL,0);
438 BIO_puts(out,"\nissuer= "); 480 BIO_puts(out,"\nissuer=");
439 BIO_puts(out,buf); 481 BIO_puts(out,p);
440 BIO_puts(out,"\n"); 482 BIO_puts(out,"\n");
441 return 0; 483 OPENSSL_free(p);
484
485 return 0;
442} 486}
443 487
444static int ui_open(UI *ui) 488static int ui_open(UI *ui)
@@ -569,7 +613,7 @@ int password_callback(char *buf, int bufsiz, int verify,
569 613
570 if (buff) 614 if (buff)
571 { 615 {
572 memset(buff,0,(unsigned int)bufsiz); 616 OPENSSL_cleanse(buff,(unsigned int)bufsiz);
573 OPENSSL_free(buff); 617 OPENSSL_free(buff);
574 } 618 }
575 619
@@ -579,13 +623,13 @@ int password_callback(char *buf, int bufsiz, int verify,
579 { 623 {
580 BIO_printf(bio_err, "User interface error\n"); 624 BIO_printf(bio_err, "User interface error\n");
581 ERR_print_errors(bio_err); 625 ERR_print_errors(bio_err);
582 memset(buf,0,(unsigned int)bufsiz); 626 OPENSSL_cleanse(buf,(unsigned int)bufsiz);
583 res = 0; 627 res = 0;
584 } 628 }
585 if (ok == -2) 629 if (ok == -2)
586 { 630 {
587 BIO_printf(bio_err,"aborted!\n"); 631 BIO_printf(bio_err,"aborted!\n");
588 memset(buf,0,(unsigned int)bufsiz); 632 OPENSSL_cleanse(buf,(unsigned int)bufsiz);
589 res = 0; 633 res = 0;
590 } 634 }
591 UI_free(ui); 635 UI_free(ui);
@@ -813,6 +857,7 @@ EVP_PKEY *load_key(BIO *err, const char *file, int format, int maybe_stdin,
813 BIO_printf(err,"no keyfile specified\n"); 857 BIO_printf(err,"no keyfile specified\n");
814 goto end; 858 goto end;
815 } 859 }
860#ifndef OPENSSL_NO_ENGINE
816 if (format == FORMAT_ENGINE) 861 if (format == FORMAT_ENGINE)
817 { 862 {
818 if (!e) 863 if (!e)
@@ -822,6 +867,7 @@ EVP_PKEY *load_key(BIO *err, const char *file, int format, int maybe_stdin,
822 ui_method, &cb_data); 867 ui_method, &cb_data);
823 goto end; 868 goto end;
824 } 869 }
870#endif
825 key=BIO_new(BIO_s_file()); 871 key=BIO_new(BIO_s_file());
826 if (key == NULL) 872 if (key == NULL)
827 { 873 {
@@ -889,6 +935,7 @@ EVP_PKEY *load_pubkey(BIO *err, const char *file, int format, int maybe_stdin,
889 BIO_printf(err,"no keyfile specified\n"); 935 BIO_printf(err,"no keyfile specified\n");
890 goto end; 936 goto end;
891 } 937 }
938#ifndef OPENSSL_NO_ENGINE
892 if (format == FORMAT_ENGINE) 939 if (format == FORMAT_ENGINE)
893 { 940 {
894 if (!e) 941 if (!e)
@@ -898,6 +945,7 @@ EVP_PKEY *load_pubkey(BIO *err, const char *file, int format, int maybe_stdin,
898 ui_method, &cb_data); 945 ui_method, &cb_data);
899 goto end; 946 goto end;
900 } 947 }
948#endif
901 key=BIO_new(BIO_s_file()); 949 key=BIO_new(BIO_s_file());
902 if (key == NULL) 950 if (key == NULL)
903 { 951 {
@@ -960,7 +1008,7 @@ load_netscape_key(BIO *err, BIO *key, const char *file,
960 goto error; 1008 goto error;
961 for (;;) 1009 for (;;)
962 { 1010 {
963 if (!BUF_MEM_grow(buf,size+1024*10)) 1011 if (!BUF_MEM_grow_clean(buf,size+1024*10))
964 goto error; 1012 goto error;
965 i = BIO_read(key, &(buf->data[size]), 1024*10); 1013 i = BIO_read(key, &(buf->data[size]), 1024*10);
966 size += i; 1014 size += i;
@@ -1235,6 +1283,7 @@ void print_name(BIO *out, char *title, X509_NAME *nm, unsigned long lflags)
1235 char *buf; 1283 char *buf;
1236 char mline = 0; 1284 char mline = 0;
1237 int indent = 0; 1285 int indent = 0;
1286
1238 if(title) BIO_puts(out, title); 1287 if(title) BIO_puts(out, title);
1239 if((lflags & XN_FLAG_SEP_MASK) == XN_FLAG_SEP_MULTILINE) { 1288 if((lflags & XN_FLAG_SEP_MASK) == XN_FLAG_SEP_MULTILINE) {
1240 mline = 1; 1289 mline = 1;
@@ -1282,6 +1331,7 @@ X509_STORE *setup_verify(BIO *bp, char *CAfile, char *CApath)
1282 return NULL; 1331 return NULL;
1283} 1332}
1284 1333
1334#ifndef OPENSSL_NO_ENGINE
1285/* Try to load an engine in a shareable library */ 1335/* Try to load an engine in a shareable library */
1286static ENGINE *try_load_engine(BIO *err, const char *engine, int debug) 1336static ENGINE *try_load_engine(BIO *err, const char *engine, int debug)
1287 { 1337 {
@@ -1338,6 +1388,7 @@ ENGINE *setup_engine(BIO *err, const char *engine, int debug)
1338 } 1388 }
1339 return e; 1389 return e;
1340 } 1390 }
1391#endif
1341 1392
1342int load_config(BIO *err, CONF *cnf) 1393int load_config(BIO *err, CONF *cnf)
1343 { 1394 {
@@ -1356,3 +1407,18 @@ int load_config(BIO *err, CONF *cnf)
1356 } 1407 }
1357 return 1; 1408 return 1;
1358 } 1409 }
1410
1411char *make_config_name()
1412 {
1413 const char *t=X509_get_default_cert_area();
1414 char *p;
1415
1416 p=OPENSSL_malloc(strlen(t)+strlen(OPENSSL_CONF)+2);
1417 strcpy(p,t);
1418#ifndef OPENSSL_SYS_VMS
1419 strcat(p,"/");
1420#endif
1421 strcat(p,OPENSSL_CONF);
1422
1423 return p;
1424 }
diff --git a/src/lib/libssl/src/apps/apps.h b/src/lib/libssl/src/apps/apps.h
index 32a79605ee..c36b9d2566 100644
--- a/src/lib/libssl/src/apps/apps.h
+++ b/src/lib/libssl/src/apps/apps.h
@@ -121,7 +121,9 @@
121#include <openssl/lhash.h> 121#include <openssl/lhash.h>
122#include <openssl/conf.h> 122#include <openssl/conf.h>
123#include <openssl/txt_db.h> 123#include <openssl/txt_db.h>
124#ifndef OPENSSL_NO_ENGINE
124#include <openssl/engine.h> 125#include <openssl/engine.h>
126#endif
125#include <openssl/ossl_typ.h> 127#include <openssl/ossl_typ.h>
126 128
127int app_RAND_load_file(const char *file, BIO *bio_e, int dont_warn); 129int app_RAND_load_file(const char *file, BIO *bio_e, int dont_warn);
@@ -139,13 +141,21 @@ long app_RAND_load_files(char *file); /* `file' is a list of files to read,
139int WIN32_rename(char *oldname,char *newname); 141int WIN32_rename(char *oldname,char *newname);
140#endif 142#endif
141 143
144/* VMS below version 7.0 doesn't have strcasecmp() */
145#ifdef OPENSSL_SYS_VMS
146#define strcasecmp(str1,str2) VMS_strcasecmp((str1),(str2))
147int VMS_strcasecmp(const char *str1, const char *str2);
148#endif
149
142#ifndef MONOLITH 150#ifndef MONOLITH
143 151
144#define MAIN(a,v) main(a,v) 152#define MAIN(a,v) main(a,v)
145 153
146#ifndef NON_MAIN 154#ifndef NON_MAIN
155CONF *config=NULL;
147BIO *bio_err=NULL; 156BIO *bio_err=NULL;
148#else 157#else
158extern CONF *config;
149extern BIO *bio_err; 159extern BIO *bio_err;
150#endif 160#endif
151 161
@@ -171,30 +181,57 @@ extern BIO *bio_err;
171 do_pipe_sig() 181 do_pipe_sig()
172# define apps_shutdown() 182# define apps_shutdown()
173#else 183#else
174# if defined(OPENSSL_SYS_MSDOS) || defined(OPENSSL_SYS_WIN16) || \ 184# ifndef OPENSSL_NO_ENGINE
175 defined(OPENSSL_SYS_WIN32) 185# if defined(OPENSSL_SYS_MSDOS) || defined(OPENSSL_SYS_WIN16) || \
176# ifdef _O_BINARY 186 defined(OPENSSL_SYS_WIN32)
177# define apps_startup() \ 187# ifdef _O_BINARY
178 do { _fmode=_O_BINARY; do_pipe_sig(); CRYPTO_malloc_init(); \ 188# define apps_startup() \
179 ERR_load_crypto_strings(); OpenSSL_add_all_algorithms(); \ 189 do { _fmode=_O_BINARY; do_pipe_sig(); CRYPTO_malloc_init(); \
180 ENGINE_load_builtin_engines(); setup_ui_method(); } while(0) 190 ERR_load_crypto_strings(); OpenSSL_add_all_algorithms(); \
191 ENGINE_load_builtin_engines(); setup_ui_method(); } while(0)
192# else
193# define apps_startup() \
194 do { _fmode=O_BINARY; do_pipe_sig(); CRYPTO_malloc_init(); \
195 ERR_load_crypto_strings(); OpenSSL_add_all_algorithms(); \
196 ENGINE_load_builtin_engines(); setup_ui_method(); } while(0)
197# endif
181# else 198# else
182# define apps_startup() \ 199# define apps_startup() \
183 do { _fmode=O_BINARY; do_pipe_sig(); CRYPTO_malloc_init(); \ 200 do { do_pipe_sig(); OpenSSL_add_all_algorithms(); \
184 ERR_load_crypto_strings(); OpenSSL_add_all_algorithms(); \ 201 ERR_load_crypto_strings(); ENGINE_load_builtin_engines(); \
185 ENGINE_load_builtin_engines(); setup_ui_method(); } while(0) 202 setup_ui_method(); } while(0)
186# endif 203# endif
204# define apps_shutdown() \
205 do { CONF_modules_unload(1); destroy_ui_method(); \
206 EVP_cleanup(); ENGINE_cleanup(); \
207 CRYPTO_cleanup_all_ex_data(); ERR_remove_state(0); \
208 ERR_free_strings(); } while(0)
187# else 209# else
188# define apps_startup() \ 210# if defined(OPENSSL_SYS_MSDOS) || defined(OPENSSL_SYS_WIN16) || \
189 do { do_pipe_sig(); OpenSSL_add_all_algorithms(); \ 211 defined(OPENSSL_SYS_WIN32)
190 ERR_load_crypto_strings(); ENGINE_load_builtin_engines(); \ 212# ifdef _O_BINARY
191 setup_ui_method(); } while(0) 213# define apps_startup() \
214 do { _fmode=_O_BINARY; do_pipe_sig(); CRYPTO_malloc_init(); \
215 ERR_load_crypto_strings(); OpenSSL_add_all_algorithms(); \
216 setup_ui_method(); } while(0)
217# else
218# define apps_startup() \
219 do { _fmode=O_BINARY; do_pipe_sig(); CRYPTO_malloc_init(); \
220 ERR_load_crypto_strings(); OpenSSL_add_all_algorithms(); \
221 setup_ui_method(); } while(0)
222# endif
223# else
224# define apps_startup() \
225 do { do_pipe_sig(); OpenSSL_add_all_algorithms(); \
226 ERR_load_crypto_strings(); \
227 setup_ui_method(); } while(0)
228# endif
229# define apps_shutdown() \
230 do { CONF_modules_unload(1); destroy_ui_method(); \
231 EVP_cleanup(); \
232 CRYPTO_cleanup_all_ex_data(); ERR_remove_state(0); \
233 ERR_free_strings(); } while(0)
192# endif 234# endif
193# define apps_shutdown() \
194 do { CONF_modules_unload(1); destroy_ui_method(); \
195 EVP_cleanup(); ENGINE_cleanup(); \
196 CRYPTO_cleanup_all_ex_data(); ERR_remove_state(0); \
197 ERR_free_strings(); } while(0)
198#endif 235#endif
199 236
200typedef struct args_st 237typedef struct args_st
@@ -240,9 +277,12 @@ EVP_PKEY *load_pubkey(BIO *err, const char *file, int format, int maybe_stdin,
240STACK_OF(X509) *load_certs(BIO *err, const char *file, int format, 277STACK_OF(X509) *load_certs(BIO *err, const char *file, int format,
241 const char *pass, ENGINE *e, const char *cert_descrip); 278 const char *pass, ENGINE *e, const char *cert_descrip);
242X509_STORE *setup_verify(BIO *bp, char *CAfile, char *CApath); 279X509_STORE *setup_verify(BIO *bp, char *CAfile, char *CApath);
280#ifndef OPENSSL_NO_ENGINE
243ENGINE *setup_engine(BIO *err, const char *engine, int debug); 281ENGINE *setup_engine(BIO *err, const char *engine, int debug);
282#endif
244 283
245int load_config(BIO *err, CONF *cnf); 284int load_config(BIO *err, CONF *cnf);
285char *make_config_name(void);
246 286
247/* Functions defined in ca.c and also used in ocsp.c */ 287/* Functions defined in ca.c and also used in ocsp.c */
248int unpack_revinfo(ASN1_TIME **prevtm, int *preason, ASN1_OBJECT **phold, 288int unpack_revinfo(ASN1_TIME **prevtm, int *preason, ASN1_OBJECT **phold,
diff --git a/src/lib/libssl/src/apps/asn1pars.c b/src/lib/libssl/src/apps/asn1pars.c
index 8f178db851..8367415405 100644
--- a/src/lib/libssl/src/apps/asn1pars.c
+++ b/src/lib/libssl/src/apps/asn1pars.c
@@ -332,6 +332,6 @@ end:
332 if (osk != NULL) sk_free(osk); 332 if (osk != NULL) sk_free(osk);
333 OBJ_cleanup(); 333 OBJ_cleanup();
334 apps_shutdown(); 334 apps_shutdown();
335 EXIT(ret); 335 OPENSSL_EXIT(ret);
336 } 336 }
337 337
diff --git a/src/lib/libssl/src/apps/ca.c b/src/lib/libssl/src/apps/ca.c
index 492b64f04f..7ed60c7a9a 100644
--- a/src/lib/libssl/src/apps/ca.c
+++ b/src/lib/libssl/src/apps/ca.c
@@ -64,7 +64,6 @@
64#include <ctype.h> 64#include <ctype.h>
65#include <sys/types.h> 65#include <sys/types.h>
66#include <sys/stat.h> 66#include <sys/stat.h>
67#include "apps.h"
68#include <openssl/conf.h> 67#include <openssl/conf.h>
69#include <openssl/bio.h> 68#include <openssl/bio.h>
70#include <openssl/err.h> 69#include <openssl/err.h>
@@ -94,11 +93,13 @@
94# else 93# else
95# include <unixlib.h> 94# include <unixlib.h>
96# endif 95# endif
97# elif !defined(OPENSSL_SYS_VXWORKS) 96# elif !defined(OPENSSL_SYS_VXWORKS) && !defined(OPENSSL_SYS_WINDOWS)
98# include <sys/file.h> 97# include <sys/file.h>
99# endif 98# endif
100#endif 99#endif
101 100
101#include "apps.h"
102
102#ifndef W_OK 103#ifndef W_OK
103# define F_OK 0 104# define F_OK 0
104# define X_OK 1 105# define X_OK 1
@@ -195,7 +196,9 @@ static char *ca_usage[]={
195" -extensions .. - Extension section (override value in config file)\n", 196" -extensions .. - Extension section (override value in config file)\n",
196" -extfile file - Configuration file with X509v3 extentions to add\n", 197" -extfile file - Configuration file with X509v3 extentions to add\n",
197" -crlexts .. - CRL extension section (override value in config file)\n", 198" -crlexts .. - CRL extension section (override value in config file)\n",
199#ifndef OPENSSL_NO_ENGINE
198" -engine e - use engine e, possibly a hardware device.\n", 200" -engine e - use engine e, possibly a hardware device.\n",
201#endif
199" -status serial - Shows certificate status given the serial number\n", 202" -status serial - Shows certificate status given the serial number\n",
200" -updatedb - Updates db for expired certificates\n", 203" -updatedb - Updates db for expired certificates\n",
201NULL 204NULL
@@ -332,7 +335,10 @@ int MAIN(int argc, char **argv)
332#define BSIZE 256 335#define BSIZE 256
333 MS_STATIC char buf[3][BSIZE]; 336 MS_STATIC char buf[3][BSIZE];
334 char *randfile=NULL; 337 char *randfile=NULL;
338#ifndef OPENSSL_NO_ENGINE
335 char *engine = NULL; 339 char *engine = NULL;
340#endif
341 char *tofree=NULL;
336 342
337#ifdef EFENCE 343#ifdef EFENCE
338EF_PROTECT_FREE=1; 344EF_PROTECT_FREE=1;
@@ -535,11 +541,13 @@ EF_ALIGNMENT=0;
535 rev_arg = *(++argv); 541 rev_arg = *(++argv);
536 rev_type = REV_CA_COMPROMISE; 542 rev_type = REV_CA_COMPROMISE;
537 } 543 }
544#ifndef OPENSSL_NO_ENGINE
538 else if (strcmp(*argv,"-engine") == 0) 545 else if (strcmp(*argv,"-engine") == 0)
539 { 546 {
540 if (--argc < 1) goto bad; 547 if (--argc < 1) goto bad;
541 engine= *(++argv); 548 engine= *(++argv);
542 } 549 }
550#endif
543 else 551 else
544 { 552 {
545bad: 553bad:
@@ -560,25 +568,28 @@ bad:
560 568
561 ERR_load_crypto_strings(); 569 ERR_load_crypto_strings();
562 570
563 e = setup_engine(bio_err, engine, 0); 571#ifndef OPENSSL_NO_ENGINE
572 e = setup_engine(bio_err, engine, 0);
573#endif
564 574
565 /*****************************************************************/ 575 /*****************************************************************/
576 tofree=NULL;
566 if (configfile == NULL) configfile = getenv("OPENSSL_CONF"); 577 if (configfile == NULL) configfile = getenv("OPENSSL_CONF");
567 if (configfile == NULL) configfile = getenv("SSLEAY_CONF"); 578 if (configfile == NULL) configfile = getenv("SSLEAY_CONF");
568 if (configfile == NULL) 579 if (configfile == NULL)
569 { 580 {
570 /* We will just use 'buf[0]' as a temporary buffer. */ 581 const char *s=X509_get_default_cert_area();
582
571#ifdef OPENSSL_SYS_VMS 583#ifdef OPENSSL_SYS_VMS
572 strncpy(buf[0],X509_get_default_cert_area(), 584 tofree=OPENSSL_malloc(strlen(s)+sizeof(CONFIG_FILE));
573 sizeof(buf[0])-1-sizeof(CONFIG_FILE)); 585 strcpy(tofree,s);
574#else 586#else
575 strncpy(buf[0],X509_get_default_cert_area(), 587 tofree=OPENSSL_malloc(strlen(s)+sizeof(CONFIG_FILE)+1);
576 sizeof(buf[0])-2-sizeof(CONFIG_FILE)); 588 strcpy(tofree,s);
577 buf[0][sizeof(buf[0])-2-sizeof(CONFIG_FILE)]='\0'; 589 strcat(tofree,"/");
578 strcat(buf[0],"/");
579#endif 590#endif
580 strcat(buf[0],CONFIG_FILE); 591 strcat(tofree,CONFIG_FILE);
581 configfile=buf[0]; 592 configfile=tofree;
582 } 593 }
583 594
584 BIO_printf(bio_err,"Using configuration from %s\n",configfile); 595 BIO_printf(bio_err,"Using configuration from %s\n",configfile);
@@ -593,6 +604,11 @@ bad:
593 ,errorline,configfile); 604 ,errorline,configfile);
594 goto err; 605 goto err;
595 } 606 }
607 if(tofree)
608 {
609 OPENSSL_free(tofree);
610 tofree = NULL;
611 }
596 612
597 if (!load_config(bio_err, conf)) 613 if (!load_config(bio_err, conf))
598 goto err; 614 goto err;
@@ -701,7 +717,7 @@ bad:
701 } 717 }
702 pkey = load_key(bio_err, keyfile, keyform, 0, key, e, 718 pkey = load_key(bio_err, keyfile, keyform, 0, key, e,
703 "CA private key"); 719 "CA private key");
704 if (key) memset(key,0,strlen(key)); 720 if (key) OPENSSL_cleanse(key,strlen(key));
705 if (pkey == NULL) 721 if (pkey == NULL)
706 { 722 {
707 /* load_key() has already printed an appropriate message */ 723 /* load_key() has already printed an appropriate message */
@@ -1016,7 +1032,7 @@ bad:
1016 } 1032 }
1017 1033
1018 if (verbose) 1034 if (verbose)
1019 BIO_printf(bio_err, "Succesfully loaded extensions file %s\n", extfile); 1035 BIO_printf(bio_err, "Successfully loaded extensions file %s\n", extfile);
1020 1036
1021 /* We can have sections in the ext file */ 1037 /* We can have sections in the ext file */
1022 if (!extensions && !(extensions = NCONF_get_string(extconf, "default", "extensions"))) 1038 if (!extensions && !(extensions = NCONF_get_string(extconf, "default", "extensions")))
@@ -1158,9 +1174,14 @@ bad:
1158 } 1174 }
1159 if (verbose) 1175 if (verbose)
1160 { 1176 {
1161 if ((f=BN_bn2hex(serial)) == NULL) goto err; 1177 if (BN_is_zero(serial))
1162 BIO_printf(bio_err,"next serial number is %s\n",f); 1178 BIO_printf(bio_err,"next serial number is 00\n");
1163 OPENSSL_free(f); 1179 else
1180 {
1181 if ((f=BN_bn2hex(serial)) == NULL) goto err;
1182 BIO_printf(bio_err,"next serial number is %s\n",f);
1183 OPENSSL_free(f);
1184 }
1164 } 1185 }
1165 1186
1166 if ((attribs=NCONF_get_section(conf,policy)) == NULL) 1187 if ((attribs=NCONF_get_section(conf,policy)) == NULL)
@@ -1280,8 +1301,13 @@ bad:
1280 1301
1281 BIO_printf(bio_err,"Write out database with %d new entries\n",sk_X509_num(cert_sk)); 1302 BIO_printf(bio_err,"Write out database with %d new entries\n",sk_X509_num(cert_sk));
1282 1303
1283 strncpy(buf[0],serialfile,BSIZE-4); 1304 if(strlen(serialfile) > BSIZE-5 || strlen(dbfile) > BSIZE-5)
1284 buf[0][BSIZE-4]='\0'; 1305 {
1306 BIO_printf(bio_err,"file name too long\n");
1307 goto err;
1308 }
1309
1310 strcpy(buf[0],serialfile);
1285 1311
1286#ifdef OPENSSL_SYS_VMS 1312#ifdef OPENSSL_SYS_VMS
1287 strcat(buf[0],"-new"); 1313 strcat(buf[0],"-new");
@@ -1291,8 +1317,7 @@ bad:
1291 1317
1292 if (!save_serial(buf[0],serial)) goto err; 1318 if (!save_serial(buf[0],serial)) goto err;
1293 1319
1294 strncpy(buf[1],dbfile,BSIZE-4); 1320 strcpy(buf[1],dbfile);
1295 buf[1][BSIZE-4]='\0';
1296 1321
1297#ifdef OPENSSL_SYS_VMS 1322#ifdef OPENSSL_SYS_VMS
1298 strcat(buf[1],"-new"); 1323 strcat(buf[1],"-new");
@@ -1322,8 +1347,13 @@ bad:
1322 j=x->cert_info->serialNumber->length; 1347 j=x->cert_info->serialNumber->length;
1323 p=(char *)x->cert_info->serialNumber->data; 1348 p=(char *)x->cert_info->serialNumber->data;
1324 1349
1325 strncpy(buf[2],outdir,BSIZE-(j*2)-6); 1350 if(strlen(outdir) >= (size_t)(j ? BSIZE-j*2-6 : BSIZE-8))
1326 buf[2][BSIZE-(j*2)-6]='\0'; 1351 {
1352 BIO_printf(bio_err,"certificate file name too long\n");
1353 goto err;
1354 }
1355
1356 strcpy(buf[2],outdir);
1327 1357
1328#ifndef OPENSSL_SYS_VMS 1358#ifndef OPENSSL_SYS_VMS
1329 strcat(buf[2],"/"); 1359 strcat(buf[2],"/");
@@ -1557,8 +1587,13 @@ bad:
1557 if (j <= 0) goto err; 1587 if (j <= 0) goto err;
1558 X509_free(revcert); 1588 X509_free(revcert);
1559 1589
1560 strncpy(buf[0],dbfile,BSIZE-4); 1590 if(strlen(dbfile) > BSIZE-5)
1561 buf[0][BSIZE-4]='\0'; 1591 {
1592 BIO_printf(bio_err,"filename too long\n");
1593 goto err;
1594 }
1595
1596 strcpy(buf[0],dbfile);
1562#ifndef OPENSSL_SYS_VMS 1597#ifndef OPENSSL_SYS_VMS
1563 strcat(buf[0],".new"); 1598 strcat(buf[0],".new");
1564#else 1599#else
@@ -1602,16 +1637,19 @@ bad:
1602 /*****************************************************************/ 1637 /*****************************************************************/
1603 ret=0; 1638 ret=0;
1604err: 1639err:
1640 if(tofree)
1641 OPENSSL_free(tofree);
1605 BIO_free_all(Cout); 1642 BIO_free_all(Cout);
1606 BIO_free_all(Sout); 1643 BIO_free_all(Sout);
1607 BIO_free_all(out); 1644 BIO_free_all(out);
1608 BIO_free_all(in); 1645 BIO_free_all(in);
1609 1646
1610 sk_X509_pop_free(cert_sk,X509_free); 1647 if (cert_sk)
1648 sk_X509_pop_free(cert_sk,X509_free);
1611 1649
1612 if (ret) ERR_print_errors(bio_err); 1650 if (ret) ERR_print_errors(bio_err);
1613 app_RAND_write_file(randfile, bio_err); 1651 app_RAND_write_file(randfile, bio_err);
1614 if (free_key) 1652 if (free_key && key)
1615 OPENSSL_free(key); 1653 OPENSSL_free(key);
1616 BN_free(serial); 1654 BN_free(serial);
1617 TXT_DB_free(db); 1655 TXT_DB_free(db);
@@ -1621,7 +1659,7 @@ err:
1621 NCONF_free(conf); 1659 NCONF_free(conf);
1622 OBJ_cleanup(); 1660 OBJ_cleanup();
1623 apps_shutdown(); 1661 apps_shutdown();
1624 EXIT(ret); 1662 OPENSSL_EXIT(ret);
1625 } 1663 }
1626 1664
1627static void lookup_fail(char *name, char *tag) 1665static void lookup_fail(char *name, char *tag)
@@ -1686,7 +1724,7 @@ static BIGNUM *load_serial(char *serialfile)
1686 ret=ASN1_INTEGER_to_BN(ai,NULL); 1724 ret=ASN1_INTEGER_to_BN(ai,NULL);
1687 if (ret == NULL) 1725 if (ret == NULL)
1688 { 1726 {
1689 BIO_printf(bio_err,"error converting number from bin to BIGNUM"); 1727 BIO_printf(bio_err,"error converting number from bin to BIGNUM\n");
1690 goto err; 1728 goto err;
1691 } 1729 }
1692err: 1730err:
@@ -2089,7 +2127,10 @@ again2:
2089 } 2127 }
2090 } 2128 }
2091 2129
2092 row[DB_serial]=BN_bn2hex(serial); 2130 if (BN_is_zero(serial))
2131 row[DB_serial]=BUF_strdup("00");
2132 else
2133 row[DB_serial]=BN_bn2hex(serial);
2093 if (row[DB_serial] == NULL) 2134 if (row[DB_serial] == NULL)
2094 { 2135 {
2095 BIO_printf(bio_err,"Memory allocation failure\n"); 2136 BIO_printf(bio_err,"Memory allocation failure\n");
@@ -2152,7 +2193,7 @@ again2:
2152 2193
2153#ifdef X509_V3 2194#ifdef X509_V3
2154 /* Make it an X509 v3 certificate. */ 2195 /* Make it an X509 v3 certificate. */
2155 if (!X509_set_version(x509,2)) goto err; 2196 if (!X509_set_version(ret,2)) goto err;
2156#endif 2197#endif
2157 2198
2158 if (BN_to_ASN1_INTEGER(serial,ci->serialNumber) == NULL) 2199 if (BN_to_ASN1_INTEGER(serial,ci->serialNumber) == NULL)
@@ -2573,7 +2614,10 @@ static int do_revoke(X509 *x509, TXT_DB *db, int type, char *value)
2573 row[i]=NULL; 2614 row[i]=NULL;
2574 row[DB_name]=X509_NAME_oneline(X509_get_subject_name(x509),NULL,0); 2615 row[DB_name]=X509_NAME_oneline(X509_get_subject_name(x509),NULL,0);
2575 bn = ASN1_INTEGER_to_BN(X509_get_serialNumber(x509),NULL); 2616 bn = ASN1_INTEGER_to_BN(X509_get_serialNumber(x509),NULL);
2576 row[DB_serial]=BN_bn2hex(bn); 2617 if (BN_is_zero(bn))
2618 row[DB_serial]=BUF_strdup("00");
2619 else
2620 row[DB_serial]=BN_bn2hex(bn);
2577 BN_free(bn); 2621 BN_free(bn);
2578 if ((row[DB_name] == NULL) || (row[DB_serial] == NULL)) 2622 if ((row[DB_name] == NULL) || (row[DB_serial] == NULL))
2579 { 2623 {
@@ -3042,55 +3086,59 @@ X509_NAME *do_subject(char *subject, long chtype)
3042 sp++; /* skip leading / */ 3086 sp++; /* skip leading / */
3043 3087
3044 while (*sp) 3088 while (*sp)
3045 { 3089 {
3046 /* collect type */ 3090 /* collect type */
3047 ne_types[ne_num] = bp; 3091 ne_types[ne_num] = bp;
3048 while (*sp) 3092 while (*sp)
3049 { 3093 {
3050 if (*sp == '\\') /* is there anything to escape in the type...? */ 3094 if (*sp == '\\') /* is there anything to escape in the type...? */
3095 {
3051 if (*++sp) 3096 if (*++sp)
3052 *bp++ = *sp++; 3097 *bp++ = *sp++;
3053 else 3098 else
3054 { 3099 {
3055 BIO_printf(bio_err, "escape character at end of string\n"); 3100 BIO_printf(bio_err, "escape character at end of string\n");
3056 goto error; 3101 goto error;
3102 }
3057 } 3103 }
3058 else if (*sp == '=') 3104 else if (*sp == '=')
3059 { 3105 {
3060 sp++; 3106 sp++;
3061 *bp++ = '\0'; 3107 *bp++ = '\0';
3062 break; 3108 break;
3063 } 3109 }
3064 else 3110 else
3065 *bp++ = *sp++; 3111 *bp++ = *sp++;
3066 } 3112 }
3067 if (!*sp) 3113 if (!*sp)
3068 { 3114 {
3069 BIO_printf(bio_err, "end of string encountered while processing type of subject name element #%d\n", ne_num); 3115 BIO_printf(bio_err, "end of string encountered while processing type of subject name element #%d\n", ne_num);
3070 goto error; 3116 goto error;
3071 } 3117 }
3072 ne_values[ne_num] = bp; 3118 ne_values[ne_num] = bp;
3073 while (*sp) 3119 while (*sp)
3074 { 3120 {
3075 if (*sp == '\\') 3121 if (*sp == '\\')
3122 {
3076 if (*++sp) 3123 if (*++sp)
3077 *bp++ = *sp++; 3124 *bp++ = *sp++;
3078 else 3125 else
3079 { 3126 {
3080 BIO_printf(bio_err, "escape character at end of string\n"); 3127 BIO_printf(bio_err, "escape character at end of string\n");
3081 goto error; 3128 goto error;
3129 }
3082 } 3130 }
3083 else if (*sp == '/') 3131 else if (*sp == '/')
3084 { 3132 {
3085 sp++; 3133 sp++;
3086 break; 3134 break;
3087 } 3135 }
3088 else 3136 else
3089 *bp++ = *sp++; 3137 *bp++ = *sp++;
3090 } 3138 }
3091 *bp++ = '\0'; 3139 *bp++ = '\0';
3092 ne_num++; 3140 ne_num++;
3093 } 3141 }
3094 3142
3095 if (!(n = X509_NAME_new())) 3143 if (!(n = X509_NAME_new()))
3096 goto error; 3144 goto error;
diff --git a/src/lib/libssl/src/apps/ciphers.c b/src/lib/libssl/src/apps/ciphers.c
index 2d6e104790..7c62fc5dc3 100644
--- a/src/lib/libssl/src/apps/ciphers.c
+++ b/src/lib/libssl/src/apps/ciphers.c
@@ -187,7 +187,7 @@ int MAIN(int argc, char **argv)
187 { 187 {
188 BIO_puts(STDout,SSL_CIPHER_description( 188 BIO_puts(STDout,SSL_CIPHER_description(
189 sk_SSL_CIPHER_value(sk,i), 189 sk_SSL_CIPHER_value(sk,i),
190 buf,512)); 190 buf,sizeof buf));
191 } 191 }
192 } 192 }
193 193
@@ -203,6 +203,6 @@ end:
203 if (ssl != NULL) SSL_free(ssl); 203 if (ssl != NULL) SSL_free(ssl);
204 if (STDout != NULL) BIO_free_all(STDout); 204 if (STDout != NULL) BIO_free_all(STDout);
205 apps_shutdown(); 205 apps_shutdown();
206 EXIT(ret); 206 OPENSSL_EXIT(ret);
207 } 207 }
208 208
diff --git a/src/lib/libssl/src/apps/crl.c b/src/lib/libssl/src/apps/crl.c
index 00946b4d20..81d66587c1 100644
--- a/src/lib/libssl/src/apps/crl.c
+++ b/src/lib/libssl/src/apps/crl.c
@@ -81,6 +81,7 @@ static char *crl_usage[]={
81" -in arg - input file - default stdin\n", 81" -in arg - input file - default stdin\n",
82" -out arg - output file - default stdout\n", 82" -out arg - output file - default stdout\n",
83" -hash - print hash value\n", 83" -hash - print hash value\n",
84" -fingerprint - print the crl fingerprint\n",
84" -issuer - print issuer DN\n", 85" -issuer - print issuer DN\n",
85" -lastupdate - lastUpdate field\n", 86" -lastupdate - lastUpdate field\n",
86" -nextupdate - nextUpdate field\n", 87" -nextupdate - nextUpdate field\n",
@@ -377,7 +378,7 @@ end:
377 X509_STORE_free(store); 378 X509_STORE_free(store);
378 } 379 }
379 apps_shutdown(); 380 apps_shutdown();
380 EXIT(ret); 381 OPENSSL_EXIT(ret);
381 } 382 }
382 383
383static X509_CRL *load_crl(char *infile, int format) 384static X509_CRL *load_crl(char *infile, int format)
diff --git a/src/lib/libssl/src/apps/crl2p7.c b/src/lib/libssl/src/apps/crl2p7.c
index 8729068462..b2f2d121d5 100644
--- a/src/lib/libssl/src/apps/crl2p7.c
+++ b/src/lib/libssl/src/apps/crl2p7.c
@@ -280,7 +280,7 @@ end:
280 if (crl != NULL) X509_CRL_free(crl); 280 if (crl != NULL) X509_CRL_free(crl);
281 281
282 apps_shutdown(); 282 apps_shutdown();
283 EXIT(ret); 283 OPENSSL_EXIT(ret);
284 } 284 }
285 285
286/* 286/*
diff --git a/src/lib/libssl/src/apps/dgst.c b/src/lib/libssl/src/apps/dgst.c
index 32e40c1f53..47d1309b14 100644
--- a/src/lib/libssl/src/apps/dgst.c
+++ b/src/lib/libssl/src/apps/dgst.c
@@ -100,7 +100,9 @@ int MAIN(int argc, char **argv)
100 EVP_PKEY *sigkey = NULL; 100 EVP_PKEY *sigkey = NULL;
101 unsigned char *sigbuf = NULL; 101 unsigned char *sigbuf = NULL;
102 int siglen = 0; 102 int siglen = 0;
103#ifndef OPENSSL_NO_ENGINE
103 char *engine=NULL; 104 char *engine=NULL;
105#endif
104 106
105 apps_startup(); 107 apps_startup();
106 108
@@ -117,7 +119,7 @@ int MAIN(int argc, char **argv)
117 goto end; 119 goto end;
118 120
119 /* first check the program name */ 121 /* first check the program name */
120 program_name(argv[0],pname,PROG_NAME_SIZE); 122 program_name(argv[0],pname,sizeof pname);
121 123
122 md=EVP_get_digestbyname(pname); 124 md=EVP_get_digestbyname(pname);
123 125
@@ -166,11 +168,13 @@ int MAIN(int argc, char **argv)
166 if (--argc < 1) break; 168 if (--argc < 1) break;
167 keyform=str2fmt(*(++argv)); 169 keyform=str2fmt(*(++argv));
168 } 170 }
171#ifndef OPENSSL_NO_ENGINE
169 else if (strcmp(*argv,"-engine") == 0) 172 else if (strcmp(*argv,"-engine") == 0)
170 { 173 {
171 if (--argc < 1) break; 174 if (--argc < 1) break;
172 engine= *(++argv); 175 engine= *(++argv);
173 } 176 }
177#endif
174 else if (strcmp(*argv,"-hex") == 0) 178 else if (strcmp(*argv,"-hex") == 0)
175 out_bin = 0; 179 out_bin = 0;
176 else if (strcmp(*argv,"-binary") == 0) 180 else if (strcmp(*argv,"-binary") == 0)
@@ -208,7 +212,9 @@ int MAIN(int argc, char **argv)
208 BIO_printf(bio_err,"-keyform arg key file format (PEM or ENGINE)\n"); 212 BIO_printf(bio_err,"-keyform arg key file format (PEM or ENGINE)\n");
209 BIO_printf(bio_err,"-signature file signature to verify\n"); 213 BIO_printf(bio_err,"-signature file signature to verify\n");
210 BIO_printf(bio_err,"-binary output in binary form\n"); 214 BIO_printf(bio_err,"-binary output in binary form\n");
215#ifndef OPENSSL_NO_ENGINE
211 BIO_printf(bio_err,"-engine e use engine e, possibly a hardware device.\n"); 216 BIO_printf(bio_err,"-engine e use engine e, possibly a hardware device.\n");
217#endif
212 218
213 BIO_printf(bio_err,"-%3s to use the %s message digest algorithm (default)\n", 219 BIO_printf(bio_err,"-%3s to use the %s message digest algorithm (default)\n",
214 LN_md5,LN_md5); 220 LN_md5,LN_md5);
@@ -228,7 +234,9 @@ int MAIN(int argc, char **argv)
228 goto end; 234 goto end;
229 } 235 }
230 236
237#ifndef OPENSSL_NO_ENGINE
231 e = setup_engine(bio_err, engine, 0); 238 e = setup_engine(bio_err, engine, 0);
239#endif
232 240
233 in=BIO_new(BIO_s_file()); 241 in=BIO_new(BIO_s_file());
234 bmd=BIO_new(BIO_f_md()); 242 bmd=BIO_new(BIO_f_md());
@@ -356,7 +364,7 @@ int MAIN(int argc, char **argv)
356end: 364end:
357 if (buf != NULL) 365 if (buf != NULL)
358 { 366 {
359 memset(buf,0,BUFSIZE); 367 OPENSSL_cleanse(buf,BUFSIZE);
360 OPENSSL_free(buf); 368 OPENSSL_free(buf);
361 } 369 }
362 if (in != NULL) BIO_free(in); 370 if (in != NULL) BIO_free(in);
@@ -365,7 +373,7 @@ end:
365 if(sigbuf) OPENSSL_free(sigbuf); 373 if(sigbuf) OPENSSL_free(sigbuf);
366 if (bmd != NULL) BIO_free(bmd); 374 if (bmd != NULL) BIO_free(bmd);
367 apps_shutdown(); 375 apps_shutdown();
368 EXIT(err); 376 OPENSSL_EXIT(err);
369 } 377 }
370 378
371int do_fp(BIO *out, unsigned char *buf, BIO *bp, int sep, int binout, 379int do_fp(BIO *out, unsigned char *buf, BIO *bp, int sep, int binout,
diff --git a/src/lib/libssl/src/apps/dh.c b/src/lib/libssl/src/apps/dh.c
index 27c3dc8df2..cd01fed139 100644
--- a/src/lib/libssl/src/apps/dh.c
+++ b/src/lib/libssl/src/apps/dh.c
@@ -87,12 +87,17 @@ int MAIN(int, char **);
87 87
88int MAIN(int argc, char **argv) 88int MAIN(int argc, char **argv)
89 { 89 {
90#ifndef OPENSSL_NO_ENGINE
90 ENGINE *e = NULL; 91 ENGINE *e = NULL;
92#endif
91 DH *dh=NULL; 93 DH *dh=NULL;
92 int i,badops=0,text=0; 94 int i,badops=0,text=0;
93 BIO *in=NULL,*out=NULL; 95 BIO *in=NULL,*out=NULL;
94 int informat,outformat,check=0,noout=0,C=0,ret=1; 96 int informat,outformat,check=0,noout=0,C=0,ret=1;
95 char *infile,*outfile,*prog,*engine; 97 char *infile,*outfile,*prog;
98#ifndef OPENSSL_NO_ENGINE
99 char *engine;
100#endif
96 101
97 apps_startup(); 102 apps_startup();
98 103
@@ -103,7 +108,9 @@ int MAIN(int argc, char **argv)
103 if (!load_config(bio_err, NULL)) 108 if (!load_config(bio_err, NULL))
104 goto end; 109 goto end;
105 110
111#ifndef OPENSSL_NO_ENGINE
106 engine=NULL; 112 engine=NULL;
113#endif
107 infile=NULL; 114 infile=NULL;
108 outfile=NULL; 115 outfile=NULL;
109 informat=FORMAT_PEM; 116 informat=FORMAT_PEM;
@@ -134,11 +141,13 @@ int MAIN(int argc, char **argv)
134 if (--argc < 1) goto bad; 141 if (--argc < 1) goto bad;
135 outfile= *(++argv); 142 outfile= *(++argv);
136 } 143 }
144#ifndef OPENSSL_NO_ENGINE
137 else if (strcmp(*argv,"-engine") == 0) 145 else if (strcmp(*argv,"-engine") == 0)
138 { 146 {
139 if (--argc < 1) goto bad; 147 if (--argc < 1) goto bad;
140 engine= *(++argv); 148 engine= *(++argv);
141 } 149 }
150#endif
142 else if (strcmp(*argv,"-check") == 0) 151 else if (strcmp(*argv,"-check") == 0)
143 check=1; 152 check=1;
144 else if (strcmp(*argv,"-text") == 0) 153 else if (strcmp(*argv,"-text") == 0)
@@ -170,13 +179,17 @@ bad:
170 BIO_printf(bio_err," -text print a text form of the DH parameters\n"); 179 BIO_printf(bio_err," -text print a text form of the DH parameters\n");
171 BIO_printf(bio_err," -C Output C code\n"); 180 BIO_printf(bio_err," -C Output C code\n");
172 BIO_printf(bio_err," -noout no output\n"); 181 BIO_printf(bio_err," -noout no output\n");
182#ifndef OPENSSL_NO_ENGINE
173 BIO_printf(bio_err," -engine e use engine e, possibly a hardware device.\n"); 183 BIO_printf(bio_err," -engine e use engine e, possibly a hardware device.\n");
184#endif
174 goto end; 185 goto end;
175 } 186 }
176 187
177 ERR_load_crypto_strings(); 188 ERR_load_crypto_strings();
178 189
190#ifndef OPENSSL_NO_ENGINE
179 e = setup_engine(bio_err, engine, 0); 191 e = setup_engine(bio_err, engine, 0);
192#endif
180 193
181 in=BIO_new(BIO_s_file()); 194 in=BIO_new(BIO_s_file());
182 out=BIO_new(BIO_s_file()); 195 out=BIO_new(BIO_s_file());
@@ -333,6 +346,6 @@ end:
333 if (out != NULL) BIO_free_all(out); 346 if (out != NULL) BIO_free_all(out);
334 if (dh != NULL) DH_free(dh); 347 if (dh != NULL) DH_free(dh);
335 apps_shutdown(); 348 apps_shutdown();
336 EXIT(ret); 349 OPENSSL_EXIT(ret);
337 } 350 }
338#endif 351#endif
diff --git a/src/lib/libssl/src/apps/dhparam.c b/src/lib/libssl/src/apps/dhparam.c
index ea15ef3236..dc00355b95 100644
--- a/src/lib/libssl/src/apps/dhparam.c
+++ b/src/lib/libssl/src/apps/dhparam.c
@@ -148,7 +148,9 @@ int MAIN(int, char **);
148 148
149int MAIN(int argc, char **argv) 149int MAIN(int argc, char **argv)
150 { 150 {
151#ifndef OPENSSL_NO_ENGINE
151 ENGINE *e = NULL; 152 ENGINE *e = NULL;
153#endif
152 DH *dh=NULL; 154 DH *dh=NULL;
153 int i,badops=0,text=0; 155 int i,badops=0,text=0;
154#ifndef OPENSSL_NO_DSA 156#ifndef OPENSSL_NO_DSA
@@ -157,7 +159,10 @@ int MAIN(int argc, char **argv)
157 BIO *in=NULL,*out=NULL; 159 BIO *in=NULL,*out=NULL;
158 int informat,outformat,check=0,noout=0,C=0,ret=1; 160 int informat,outformat,check=0,noout=0,C=0,ret=1;
159 char *infile,*outfile,*prog; 161 char *infile,*outfile,*prog;
160 char *inrand=NULL,*engine=NULL; 162 char *inrand=NULL;
163#ifndef OPENSSL_NO_ENGINE
164 char *engine=NULL;
165#endif
161 int num = 0, g = 0; 166 int num = 0, g = 0;
162 167
163 apps_startup(); 168 apps_startup();
@@ -199,11 +204,13 @@ int MAIN(int argc, char **argv)
199 if (--argc < 1) goto bad; 204 if (--argc < 1) goto bad;
200 outfile= *(++argv); 205 outfile= *(++argv);
201 } 206 }
207#ifndef OPENSSL_NO_ENGINE
202 else if (strcmp(*argv,"-engine") == 0) 208 else if (strcmp(*argv,"-engine") == 0)
203 { 209 {
204 if (--argc < 1) goto bad; 210 if (--argc < 1) goto bad;
205 engine= *(++argv); 211 engine= *(++argv);
206 } 212 }
213#endif
207 else if (strcmp(*argv,"-check") == 0) 214 else if (strcmp(*argv,"-check") == 0)
208 check=1; 215 check=1;
209 else if (strcmp(*argv,"-text") == 0) 216 else if (strcmp(*argv,"-text") == 0)
@@ -249,7 +256,9 @@ bad:
249 BIO_printf(bio_err," -2 generate parameters using 2 as the generator value\n"); 256 BIO_printf(bio_err," -2 generate parameters using 2 as the generator value\n");
250 BIO_printf(bio_err," -5 generate parameters using 5 as the generator value\n"); 257 BIO_printf(bio_err," -5 generate parameters using 5 as the generator value\n");
251 BIO_printf(bio_err," numbits number of bits in to generate (default 512)\n"); 258 BIO_printf(bio_err," numbits number of bits in to generate (default 512)\n");
259#ifndef OPENSSL_NO_ENGINE
252 BIO_printf(bio_err," -engine e use engine e, possibly a hardware device.\n"); 260 BIO_printf(bio_err," -engine e use engine e, possibly a hardware device.\n");
261#endif
253 BIO_printf(bio_err," -rand file%cfile%c...\n", LIST_SEPARATOR_CHAR, LIST_SEPARATOR_CHAR); 262 BIO_printf(bio_err," -rand file%cfile%c...\n", LIST_SEPARATOR_CHAR, LIST_SEPARATOR_CHAR);
254 BIO_printf(bio_err," - load the file (or the files in the directory) into\n"); 263 BIO_printf(bio_err," - load the file (or the files in the directory) into\n");
255 BIO_printf(bio_err," the random number generator\n"); 264 BIO_printf(bio_err," the random number generator\n");
@@ -259,7 +268,9 @@ bad:
259 268
260 ERR_load_crypto_strings(); 269 ERR_load_crypto_strings();
261 270
271#ifndef OPENSSL_NO_ENGINE
262 e = setup_engine(bio_err, engine, 0); 272 e = setup_engine(bio_err, engine, 0);
273#endif
263 274
264 if (g && !num) 275 if (g && !num)
265 num = DEFBITS; 276 num = DEFBITS;
@@ -519,7 +530,7 @@ end:
519 if (out != NULL) BIO_free_all(out); 530 if (out != NULL) BIO_free_all(out);
520 if (dh != NULL) DH_free(dh); 531 if (dh != NULL) DH_free(dh);
521 apps_shutdown(); 532 apps_shutdown();
522 EXIT(ret); 533 OPENSSL_EXIT(ret);
523 } 534 }
524 535
525/* dh_cb is identical to dsa_cb in apps/dsaparam.c */ 536/* dh_cb is identical to dsa_cb in apps/dsaparam.c */
diff --git a/src/lib/libssl/src/apps/dsa.c b/src/lib/libssl/src/apps/dsa.c
index 9da1a41645..e9de3a3bdf 100644
--- a/src/lib/libssl/src/apps/dsa.c
+++ b/src/lib/libssl/src/apps/dsa.c
@@ -90,7 +90,9 @@ int MAIN(int, char **);
90 90
91int MAIN(int argc, char **argv) 91int MAIN(int argc, char **argv)
92 { 92 {
93#ifndef OPENSSL_NO_ENGINE
93 ENGINE *e = NULL; 94 ENGINE *e = NULL;
95#endif
94 int ret=1; 96 int ret=1;
95 DSA *dsa=NULL; 97 DSA *dsa=NULL;
96 int i,badops=0; 98 int i,badops=0;
@@ -98,7 +100,10 @@ int MAIN(int argc, char **argv)
98 BIO *in=NULL,*out=NULL; 100 BIO *in=NULL,*out=NULL;
99 int informat,outformat,text=0,noout=0; 101 int informat,outformat,text=0,noout=0;
100 int pubin = 0, pubout = 0; 102 int pubin = 0, pubout = 0;
101 char *infile,*outfile,*prog,*engine; 103 char *infile,*outfile,*prog;
104#ifndef OPENSSL_NO_ENGINE
105 char *engine;
106#endif
102 char *passargin = NULL, *passargout = NULL; 107 char *passargin = NULL, *passargout = NULL;
103 char *passin = NULL, *passout = NULL; 108 char *passin = NULL, *passout = NULL;
104 int modulus=0; 109 int modulus=0;
@@ -112,7 +117,9 @@ int MAIN(int argc, char **argv)
112 if (!load_config(bio_err, NULL)) 117 if (!load_config(bio_err, NULL))
113 goto end; 118 goto end;
114 119
120#ifndef OPENSSL_NO_ENGINE
115 engine=NULL; 121 engine=NULL;
122#endif
116 infile=NULL; 123 infile=NULL;
117 outfile=NULL; 124 outfile=NULL;
118 informat=FORMAT_PEM; 125 informat=FORMAT_PEM;
@@ -153,11 +160,13 @@ int MAIN(int argc, char **argv)
153 if (--argc < 1) goto bad; 160 if (--argc < 1) goto bad;
154 passargout= *(++argv); 161 passargout= *(++argv);
155 } 162 }
163#ifndef OPENSSL_NO_ENGINE
156 else if (strcmp(*argv,"-engine") == 0) 164 else if (strcmp(*argv,"-engine") == 0)
157 { 165 {
158 if (--argc < 1) goto bad; 166 if (--argc < 1) goto bad;
159 engine= *(++argv); 167 engine= *(++argv);
160 } 168 }
169#endif
161 else if (strcmp(*argv,"-noout") == 0) 170 else if (strcmp(*argv,"-noout") == 0)
162 noout=1; 171 noout=1;
163 else if (strcmp(*argv,"-text") == 0) 172 else if (strcmp(*argv,"-text") == 0)
@@ -189,7 +198,9 @@ bad:
189 BIO_printf(bio_err," -passin arg input file pass phrase source\n"); 198 BIO_printf(bio_err," -passin arg input file pass phrase source\n");
190 BIO_printf(bio_err," -out arg output file\n"); 199 BIO_printf(bio_err," -out arg output file\n");
191 BIO_printf(bio_err," -passout arg output file pass phrase source\n"); 200 BIO_printf(bio_err," -passout arg output file pass phrase source\n");
201#ifndef OPENSSL_NO_ENGINE
192 BIO_printf(bio_err," -engine e use engine e, possibly a hardware device.\n"); 202 BIO_printf(bio_err," -engine e use engine e, possibly a hardware device.\n");
203#endif
193 BIO_printf(bio_err," -des encrypt PEM output with cbc des\n"); 204 BIO_printf(bio_err," -des encrypt PEM output with cbc des\n");
194 BIO_printf(bio_err," -des3 encrypt PEM output with ede cbc des using 168 bit key\n"); 205 BIO_printf(bio_err," -des3 encrypt PEM output with ede cbc des using 168 bit key\n");
195#ifndef OPENSSL_NO_IDEA 206#ifndef OPENSSL_NO_IDEA
@@ -207,7 +218,9 @@ bad:
207 218
208 ERR_load_crypto_strings(); 219 ERR_load_crypto_strings();
209 220
221#ifndef OPENSSL_NO_ENGINE
210 e = setup_engine(bio_err, engine, 0); 222 e = setup_engine(bio_err, engine, 0);
223#endif
211 224
212 if(!app_passwd(bio_err, passargin, passargout, &passin, &passout)) { 225 if(!app_passwd(bio_err, passargin, passargout, &passin, &passout)) {
213 BIO_printf(bio_err, "Error getting passwords\n"); 226 BIO_printf(bio_err, "Error getting passwords\n");
@@ -314,6 +327,6 @@ end:
314 if(passin) OPENSSL_free(passin); 327 if(passin) OPENSSL_free(passin);
315 if(passout) OPENSSL_free(passout); 328 if(passout) OPENSSL_free(passout);
316 apps_shutdown(); 329 apps_shutdown();
317 EXIT(ret); 330 OPENSSL_EXIT(ret);
318 } 331 }
319#endif 332#endif
diff --git a/src/lib/libssl/src/apps/dsaparam.c b/src/lib/libssl/src/apps/dsaparam.c
index 2f436803e3..04861e8986 100644
--- a/src/lib/libssl/src/apps/dsaparam.c
+++ b/src/lib/libssl/src/apps/dsaparam.c
@@ -90,7 +90,9 @@ int MAIN(int, char **);
90 90
91int MAIN(int argc, char **argv) 91int MAIN(int argc, char **argv)
92 { 92 {
93#ifndef OPENSSL_NO_ENGINE
93 ENGINE *e = NULL; 94 ENGINE *e = NULL;
95#endif
94 DSA *dsa=NULL; 96 DSA *dsa=NULL;
95 int i,badops=0,text=0; 97 int i,badops=0,text=0;
96 BIO *in=NULL,*out=NULL; 98 BIO *in=NULL,*out=NULL;
@@ -98,7 +100,9 @@ int MAIN(int argc, char **argv)
98 char *infile,*outfile,*prog,*inrand=NULL; 100 char *infile,*outfile,*prog,*inrand=NULL;
99 int numbits= -1,num,genkey=0; 101 int numbits= -1,num,genkey=0;
100 int need_rand=0; 102 int need_rand=0;
103#ifndef OPENSSL_NO_ENGINE
101 char *engine=NULL; 104 char *engine=NULL;
105#endif
102 106
103 apps_startup(); 107 apps_startup();
104 108
@@ -139,11 +143,13 @@ int MAIN(int argc, char **argv)
139 if (--argc < 1) goto bad; 143 if (--argc < 1) goto bad;
140 outfile= *(++argv); 144 outfile= *(++argv);
141 } 145 }
146#ifndef OPENSSL_NO_ENGINE
142 else if(strcmp(*argv, "-engine") == 0) 147 else if(strcmp(*argv, "-engine") == 0)
143 { 148 {
144 if (--argc < 1) goto bad; 149 if (--argc < 1) goto bad;
145 engine = *(++argv); 150 engine = *(++argv);
146 } 151 }
152#endif
147 else if (strcmp(*argv,"-text") == 0) 153 else if (strcmp(*argv,"-text") == 0)
148 text=1; 154 text=1;
149 else if (strcmp(*argv,"-C") == 0) 155 else if (strcmp(*argv,"-C") == 0)
@@ -191,7 +197,9 @@ bad:
191 BIO_printf(bio_err," -noout no output\n"); 197 BIO_printf(bio_err," -noout no output\n");
192 BIO_printf(bio_err," -genkey generate a DSA key\n"); 198 BIO_printf(bio_err," -genkey generate a DSA key\n");
193 BIO_printf(bio_err," -rand files to use for random number input\n"); 199 BIO_printf(bio_err," -rand files to use for random number input\n");
200#ifndef OPENSSL_NO_ENGINE
194 BIO_printf(bio_err," -engine e use engine e, possibly a hardware device.\n"); 201 BIO_printf(bio_err," -engine e use engine e, possibly a hardware device.\n");
202#endif
195 BIO_printf(bio_err," number number of bits to use for generating private key\n"); 203 BIO_printf(bio_err," number number of bits to use for generating private key\n");
196 goto end; 204 goto end;
197 } 205 }
@@ -235,7 +243,9 @@ bad:
235 } 243 }
236 } 244 }
237 245
246#ifndef OPENSSL_NO_ENGINE
238 e = setup_engine(bio_err, engine, 0); 247 e = setup_engine(bio_err, engine, 0);
248#endif
239 249
240 if (need_rand) 250 if (need_rand)
241 { 251 {
@@ -372,7 +382,7 @@ end:
372 if (out != NULL) BIO_free_all(out); 382 if (out != NULL) BIO_free_all(out);
373 if (dsa != NULL) DSA_free(dsa); 383 if (dsa != NULL) DSA_free(dsa);
374 apps_shutdown(); 384 apps_shutdown();
375 EXIT(ret); 385 OPENSSL_EXIT(ret);
376 } 386 }
377 387
378static void MS_CALLBACK dsa_cb(int p, int n, void *arg) 388static void MS_CALLBACK dsa_cb(int p, int n, void *arg)
diff --git a/src/lib/libssl/src/apps/enc.c b/src/lib/libssl/src/apps/enc.c
index 1ba2ea2f68..0a9f7310bf 100644
--- a/src/lib/libssl/src/apps/enc.c
+++ b/src/lib/libssl/src/apps/enc.c
@@ -100,9 +100,11 @@ int MAIN(int, char **);
100 100
101int MAIN(int argc, char **argv) 101int MAIN(int argc, char **argv)
102 { 102 {
103#ifndef OPENSSL_NO_ENGINE
103 ENGINE *e = NULL; 104 ENGINE *e = NULL;
105#endif
104 static const char magic[]="Salted__"; 106 static const char magic[]="Salted__";
105 char mbuf[8]; /* should be 1 smaller than magic */ 107 char mbuf[sizeof magic-1];
106 char *strbuf=NULL; 108 char *strbuf=NULL;
107 unsigned char *buff=NULL,*bufsize=NULL; 109 unsigned char *buff=NULL,*bufsize=NULL;
108 int bsize=BSIZE,verbose=0; 110 int bsize=BSIZE,verbose=0;
@@ -119,7 +121,9 @@ int MAIN(int argc, char **argv)
119 BIO *in=NULL,*out=NULL,*b64=NULL,*benc=NULL,*rbio=NULL,*wbio=NULL; 121 BIO *in=NULL,*out=NULL,*b64=NULL,*benc=NULL,*rbio=NULL,*wbio=NULL;
120#define PROG_NAME_SIZE 39 122#define PROG_NAME_SIZE 39
121 char pname[PROG_NAME_SIZE+1]; 123 char pname[PROG_NAME_SIZE+1];
124#ifndef OPENSSL_NO_ENGINE
122 char *engine = NULL; 125 char *engine = NULL;
126#endif
123 127
124 apps_startup(); 128 apps_startup();
125 129
@@ -131,7 +135,7 @@ int MAIN(int argc, char **argv)
131 goto end; 135 goto end;
132 136
133 /* first check the program name */ 137 /* first check the program name */
134 program_name(argv[0],pname,PROG_NAME_SIZE); 138 program_name(argv[0],pname,sizeof pname);
135 if (strcmp(pname,"base64") == 0) 139 if (strcmp(pname,"base64") == 0)
136 base64=1; 140 base64=1;
137 141
@@ -163,11 +167,13 @@ int MAIN(int argc, char **argv)
163 if (--argc < 1) goto bad; 167 if (--argc < 1) goto bad;
164 passarg= *(++argv); 168 passarg= *(++argv);
165 } 169 }
170#ifndef OPENSSL_NO_ENGINE
166 else if (strcmp(*argv,"-engine") == 0) 171 else if (strcmp(*argv,"-engine") == 0)
167 { 172 {
168 if (--argc < 1) goto bad; 173 if (--argc < 1) goto bad;
169 engine= *(++argv); 174 engine= *(++argv);
170 } 175 }
176#endif
171 else if (strcmp(*argv,"-d") == 0) 177 else if (strcmp(*argv,"-d") == 0)
172 enc=0; 178 enc=0;
173 else if (strcmp(*argv,"-p") == 0) 179 else if (strcmp(*argv,"-p") == 0)
@@ -216,7 +222,7 @@ int MAIN(int argc, char **argv)
216 goto bad; 222 goto bad;
217 } 223 }
218 buf[0]='\0'; 224 buf[0]='\0';
219 fgets(buf,128,infile); 225 fgets(buf,sizeof buf,infile);
220 fclose(infile); 226 fclose(infile);
221 i=strlen(buf); 227 i=strlen(buf);
222 if ((i > 0) && 228 if ((i > 0) &&
@@ -270,7 +276,9 @@ bad:
270 BIO_printf(bio_err,"%-14s key/iv in hex is the next argument\n","-K/-iv"); 276 BIO_printf(bio_err,"%-14s key/iv in hex is the next argument\n","-K/-iv");
271 BIO_printf(bio_err,"%-14s print the iv/key (then exit if -P)\n","-[pP]"); 277 BIO_printf(bio_err,"%-14s print the iv/key (then exit if -P)\n","-[pP]");
272 BIO_printf(bio_err,"%-14s buffer size\n","-bufsize <n>"); 278 BIO_printf(bio_err,"%-14s buffer size\n","-bufsize <n>");
279#ifndef OPENSSL_NO_ENGINE
273 BIO_printf(bio_err,"%-14s use engine e, possibly a hardware device.\n","-engine e"); 280 BIO_printf(bio_err,"%-14s use engine e, possibly a hardware device.\n","-engine e");
281#endif
274 282
275 BIO_printf(bio_err,"Cipher Types\n"); 283 BIO_printf(bio_err,"Cipher Types\n");
276 OBJ_NAME_do_all_sorted(OBJ_NAME_TYPE_CIPHER_METH, 284 OBJ_NAME_do_all_sorted(OBJ_NAME_TYPE_CIPHER_METH,
@@ -284,7 +292,9 @@ bad:
284 argv++; 292 argv++;
285 } 293 }
286 294
295#ifndef OPENSSL_NO_ENGINE
287 e = setup_engine(bio_err, engine, 0); 296 e = setup_engine(bio_err, engine, 0);
297#endif
288 298
289 if (bufsize != NULL) 299 if (bufsize != NULL)
290 { 300 {
@@ -442,12 +452,12 @@ bad:
442 else { 452 else {
443 if(enc) { 453 if(enc) {
444 if(hsalt) { 454 if(hsalt) {
445 if(!set_hex(hsalt,salt,PKCS5_SALT_LEN)) { 455 if(!set_hex(hsalt,salt,sizeof salt)) {
446 BIO_printf(bio_err, 456 BIO_printf(bio_err,
447 "invalid hex salt value\n"); 457 "invalid hex salt value\n");
448 goto end; 458 goto end;
449 } 459 }
450 } else if (RAND_pseudo_bytes(salt, PKCS5_SALT_LEN) < 0) 460 } else if (RAND_pseudo_bytes(salt, sizeof salt) < 0)
451 goto end; 461 goto end;
452 /* If -P option then don't bother writing */ 462 /* If -P option then don't bother writing */
453 if((printkey != 2) 463 if((printkey != 2)
@@ -455,14 +465,14 @@ bad:
455 sizeof magic-1) != sizeof magic-1 465 sizeof magic-1) != sizeof magic-1
456 || BIO_write(wbio, 466 || BIO_write(wbio,
457 (char *)salt, 467 (char *)salt,
458 PKCS5_SALT_LEN) != PKCS5_SALT_LEN)) { 468 sizeof salt) != sizeof salt)) {
459 BIO_printf(bio_err,"error writing output file\n"); 469 BIO_printf(bio_err,"error writing output file\n");
460 goto end; 470 goto end;
461 } 471 }
462 } else if(BIO_read(rbio,mbuf,sizeof mbuf) != sizeof mbuf 472 } else if(BIO_read(rbio,mbuf,sizeof mbuf) != sizeof mbuf
463 || BIO_read(rbio, 473 || BIO_read(rbio,
464 (unsigned char *)salt, 474 (unsigned char *)salt,
465 PKCS5_SALT_LEN) != PKCS5_SALT_LEN) { 475 sizeof salt) != sizeof salt) {
466 BIO_printf(bio_err,"error reading input file\n"); 476 BIO_printf(bio_err,"error reading input file\n");
467 goto end; 477 goto end;
468 } else if(memcmp(mbuf,magic,sizeof magic-1)) { 478 } else if(memcmp(mbuf,magic,sizeof magic-1)) {
@@ -481,9 +491,9 @@ bad:
481 * bug picked up by 491 * bug picked up by
482 * Larry J. Hughes Jr. <hughes@indiana.edu> */ 492 * Larry J. Hughes Jr. <hughes@indiana.edu> */
483 if (str == strbuf) 493 if (str == strbuf)
484 memset(str,0,SIZE); 494 OPENSSL_cleanse(str,SIZE);
485 else 495 else
486 memset(str,0,strlen(str)); 496 OPENSSL_cleanse(str,strlen(str));
487 } 497 }
488 if ((hiv != NULL) && !set_hex(hiv,iv,sizeof iv)) 498 if ((hiv != NULL) && !set_hex(hiv,iv,sizeof iv))
489 { 499 {
@@ -524,7 +534,7 @@ bad:
524 if (!nosalt) 534 if (!nosalt)
525 { 535 {
526 printf("salt="); 536 printf("salt=");
527 for (i=0; i<PKCS5_SALT_LEN; i++) 537 for (i=0; i<sizeof salt; i++)
528 printf("%02X",salt[i]); 538 printf("%02X",salt[i]);
529 printf("\n"); 539 printf("\n");
530 } 540 }
@@ -586,7 +596,7 @@ end:
586 if (b64 != NULL) BIO_free(b64); 596 if (b64 != NULL) BIO_free(b64);
587 if(pass) OPENSSL_free(pass); 597 if(pass) OPENSSL_free(pass);
588 apps_shutdown(); 598 apps_shutdown();
589 EXIT(ret); 599 OPENSSL_EXIT(ret);
590 } 600 }
591 601
592int set_hex(char *in, unsigned char *out, int size) 602int set_hex(char *in, unsigned char *out, int size)
diff --git a/src/lib/libssl/src/apps/engine.c b/src/lib/libssl/src/apps/engine.c
index 734ecb3e5d..c3e1e8de1c 100644
--- a/src/lib/libssl/src/apps/engine.c
+++ b/src/lib/libssl/src/apps/engine.c
@@ -56,6 +56,8 @@
56 * 56 *
57 */ 57 */
58 58
59#ifndef OPENSSL_NO_ENGINE
60
59#include <stdio.h> 61#include <stdio.h>
60#include <stdlib.h> 62#include <stdlib.h>
61#include <string.h> 63#include <string.h>
@@ -516,5 +518,12 @@ end:
516 sk_pop_free(post_cmds, identity); 518 sk_pop_free(post_cmds, identity);
517 if (bio_out != NULL) BIO_free_all(bio_out); 519 if (bio_out != NULL) BIO_free_all(bio_out);
518 apps_shutdown(); 520 apps_shutdown();
519 EXIT(ret); 521 OPENSSL_EXIT(ret);
520 } 522 }
523#else
524
525# if PEDANTIC
526static void *dummy=&dummy;
527# endif
528
529#endif
diff --git a/src/lib/libssl/src/apps/errstr.c b/src/lib/libssl/src/apps/errstr.c
index fedb568d68..19489b0df3 100644
--- a/src/lib/libssl/src/apps/errstr.c
+++ b/src/lib/libssl/src/apps/errstr.c
@@ -122,5 +122,5 @@ int MAIN(int argc, char **argv)
122 } 122 }
123 } 123 }
124 apps_shutdown(); 124 apps_shutdown();
125 EXIT(ret); 125 OPENSSL_EXIT(ret);
126 } 126 }
diff --git a/src/lib/libssl/src/apps/gendh.c b/src/lib/libssl/src/apps/gendh.c
index f2542960bf..a34a862caf 100644
--- a/src/lib/libssl/src/apps/gendh.c
+++ b/src/lib/libssl/src/apps/gendh.c
@@ -81,13 +81,17 @@ int MAIN(int, char **);
81 81
82int MAIN(int argc, char **argv) 82int MAIN(int argc, char **argv)
83 { 83 {
84#ifndef OPENSSL_NO_ENGINE
84 ENGINE *e = NULL; 85 ENGINE *e = NULL;
86#endif
85 DH *dh=NULL; 87 DH *dh=NULL;
86 int ret=1,num=DEFBITS; 88 int ret=1,num=DEFBITS;
87 int g=2; 89 int g=2;
88 char *outfile=NULL; 90 char *outfile=NULL;
89 char *inrand=NULL; 91 char *inrand=NULL;
92#ifndef OPENSSL_NO_ENGINE
90 char *engine=NULL; 93 char *engine=NULL;
94#endif
91 BIO *out=NULL; 95 BIO *out=NULL;
92 96
93 apps_startup(); 97 apps_startup();
@@ -115,11 +119,13 @@ int MAIN(int argc, char **argv)
115 g=3; */ 119 g=3; */
116 else if (strcmp(*argv,"-5") == 0) 120 else if (strcmp(*argv,"-5") == 0)
117 g=5; 121 g=5;
122#ifndef OPENSSL_NO_ENGINE
118 else if (strcmp(*argv,"-engine") == 0) 123 else if (strcmp(*argv,"-engine") == 0)
119 { 124 {
120 if (--argc < 1) goto bad; 125 if (--argc < 1) goto bad;
121 engine= *(++argv); 126 engine= *(++argv);
122 } 127 }
128#endif
123 else if (strcmp(*argv,"-rand") == 0) 129 else if (strcmp(*argv,"-rand") == 0)
124 { 130 {
125 if (--argc < 1) goto bad; 131 if (--argc < 1) goto bad;
@@ -138,14 +144,18 @@ bad:
138 BIO_printf(bio_err," -2 - use 2 as the generator value\n"); 144 BIO_printf(bio_err," -2 - use 2 as the generator value\n");
139 /* BIO_printf(bio_err," -3 - use 3 as the generator value\n"); */ 145 /* BIO_printf(bio_err," -3 - use 3 as the generator value\n"); */
140 BIO_printf(bio_err," -5 - use 5 as the generator value\n"); 146 BIO_printf(bio_err," -5 - use 5 as the generator value\n");
147#ifndef OPENSSL_NO_ENGINE
141 BIO_printf(bio_err," -engine e - use engine e, possibly a hardware device.\n"); 148 BIO_printf(bio_err," -engine e - use engine e, possibly a hardware device.\n");
149#endif
142 BIO_printf(bio_err," -rand file%cfile%c...\n", LIST_SEPARATOR_CHAR, LIST_SEPARATOR_CHAR); 150 BIO_printf(bio_err," -rand file%cfile%c...\n", LIST_SEPARATOR_CHAR, LIST_SEPARATOR_CHAR);
143 BIO_printf(bio_err," - load the file (or the files in the directory) into\n"); 151 BIO_printf(bio_err," - load the file (or the files in the directory) into\n");
144 BIO_printf(bio_err," the random number generator\n"); 152 BIO_printf(bio_err," the random number generator\n");
145 goto end; 153 goto end;
146 } 154 }
147 155
156#ifndef OPENSSL_NO_ENGINE
148 e = setup_engine(bio_err, engine, 0); 157 e = setup_engine(bio_err, engine, 0);
158#endif
149 159
150 out=BIO_new(BIO_s_file()); 160 out=BIO_new(BIO_s_file());
151 if (out == NULL) 161 if (out == NULL)
@@ -198,7 +208,7 @@ end:
198 if (out != NULL) BIO_free_all(out); 208 if (out != NULL) BIO_free_all(out);
199 if (dh != NULL) DH_free(dh); 209 if (dh != NULL) DH_free(dh);
200 apps_shutdown(); 210 apps_shutdown();
201 EXIT(ret); 211 OPENSSL_EXIT(ret);
202 } 212 }
203 213
204static void MS_CALLBACK dh_cb(int p, int n, void *arg) 214static void MS_CALLBACK dh_cb(int p, int n, void *arg)
diff --git a/src/lib/libssl/src/apps/gendsa.c b/src/lib/libssl/src/apps/gendsa.c
index 1e1e9f3e4c..6d2ed06c81 100644
--- a/src/lib/libssl/src/apps/gendsa.c
+++ b/src/lib/libssl/src/apps/gendsa.c
@@ -77,7 +77,9 @@ int MAIN(int, char **);
77 77
78int MAIN(int argc, char **argv) 78int MAIN(int argc, char **argv)
79 { 79 {
80#ifndef OPENSSL_NO_ENGINE
80 ENGINE *e = NULL; 81 ENGINE *e = NULL;
82#endif
81 DSA *dsa=NULL; 83 DSA *dsa=NULL;
82 int ret=1; 84 int ret=1;
83 char *outfile=NULL; 85 char *outfile=NULL;
@@ -85,7 +87,9 @@ int MAIN(int argc, char **argv)
85 char *passargout = NULL, *passout = NULL; 87 char *passargout = NULL, *passout = NULL;
86 BIO *out=NULL,*in=NULL; 88 BIO *out=NULL,*in=NULL;
87 const EVP_CIPHER *enc=NULL; 89 const EVP_CIPHER *enc=NULL;
90#ifndef OPENSSL_NO_ENGINE
88 char *engine=NULL; 91 char *engine=NULL;
92#endif
89 93
90 apps_startup(); 94 apps_startup();
91 95
@@ -111,11 +115,13 @@ int MAIN(int argc, char **argv)
111 if (--argc < 1) goto bad; 115 if (--argc < 1) goto bad;
112 passargout= *(++argv); 116 passargout= *(++argv);
113 } 117 }
118#ifndef OPENSSL_NO_ENGINE
114 else if (strcmp(*argv,"-engine") == 0) 119 else if (strcmp(*argv,"-engine") == 0)
115 { 120 {
116 if (--argc < 1) goto bad; 121 if (--argc < 1) goto bad;
117 engine= *(++argv); 122 engine= *(++argv);
118 } 123 }
124#endif
119 else if (strcmp(*argv,"-rand") == 0) 125 else if (strcmp(*argv,"-rand") == 0)
120 { 126 {
121 if (--argc < 1) goto bad; 127 if (--argc < 1) goto bad;
@@ -167,7 +173,9 @@ bad:
167 BIO_printf(bio_err," -aes128, -aes192, -aes256\n"); 173 BIO_printf(bio_err," -aes128, -aes192, -aes256\n");
168 BIO_printf(bio_err," encrypt PEM output with cbc aes\n"); 174 BIO_printf(bio_err," encrypt PEM output with cbc aes\n");
169#endif 175#endif
176#ifndef OPENSSL_NO_ENGINE
170 BIO_printf(bio_err," -engine e - use engine e, possibly a hardware device.\n"); 177 BIO_printf(bio_err," -engine e - use engine e, possibly a hardware device.\n");
178#endif
171 BIO_printf(bio_err," -rand file%cfile%c...\n", LIST_SEPARATOR_CHAR, LIST_SEPARATOR_CHAR); 179 BIO_printf(bio_err," -rand file%cfile%c...\n", LIST_SEPARATOR_CHAR, LIST_SEPARATOR_CHAR);
172 BIO_printf(bio_err," - load the file (or the files in the directory) into\n"); 180 BIO_printf(bio_err," - load the file (or the files in the directory) into\n");
173 BIO_printf(bio_err," the random number generator\n"); 181 BIO_printf(bio_err," the random number generator\n");
@@ -176,7 +184,9 @@ bad:
176 goto end; 184 goto end;
177 } 185 }
178 186
187#ifndef OPENSSL_NO_ENGINE
179 e = setup_engine(bio_err, engine, 0); 188 e = setup_engine(bio_err, engine, 0);
189#endif
180 190
181 if(!app_passwd(bio_err, NULL, passargout, NULL, &passout)) { 191 if(!app_passwd(bio_err, NULL, passargout, NULL, &passout)) {
182 BIO_printf(bio_err, "Error getting password\n"); 192 BIO_printf(bio_err, "Error getting password\n");
@@ -246,6 +256,6 @@ end:
246 if (dsa != NULL) DSA_free(dsa); 256 if (dsa != NULL) DSA_free(dsa);
247 if(passout) OPENSSL_free(passout); 257 if(passout) OPENSSL_free(passout);
248 apps_shutdown(); 258 apps_shutdown();
249 EXIT(ret); 259 OPENSSL_EXIT(ret);
250 } 260 }
251#endif 261#endif
diff --git a/src/lib/libssl/src/apps/genrsa.c b/src/lib/libssl/src/apps/genrsa.c
index 515bd7c901..63be873b7b 100644
--- a/src/lib/libssl/src/apps/genrsa.c
+++ b/src/lib/libssl/src/apps/genrsa.c
@@ -81,7 +81,9 @@ int MAIN(int, char **);
81 81
82int MAIN(int argc, char **argv) 82int MAIN(int argc, char **argv)
83 { 83 {
84#ifndef OPENSSL_NO_ENGINE
84 ENGINE *e = NULL; 85 ENGINE *e = NULL;
86#endif
85 int ret=1; 87 int ret=1;
86 RSA *rsa=NULL; 88 RSA *rsa=NULL;
87 int i,num=DEFBITS; 89 int i,num=DEFBITS;
@@ -90,7 +92,9 @@ int MAIN(int argc, char **argv)
90 unsigned long f4=RSA_F4; 92 unsigned long f4=RSA_F4;
91 char *outfile=NULL; 93 char *outfile=NULL;
92 char *passargout = NULL, *passout = NULL; 94 char *passargout = NULL, *passout = NULL;
95#ifndef OPENSSL_NO_ENGINE
93 char *engine=NULL; 96 char *engine=NULL;
97#endif
94 char *inrand=NULL; 98 char *inrand=NULL;
95 BIO *out=NULL; 99 BIO *out=NULL;
96 100
@@ -122,11 +126,13 @@ int MAIN(int argc, char **argv)
122 f4=3; 126 f4=3;
123 else if (strcmp(*argv,"-F4") == 0 || strcmp(*argv,"-f4") == 0) 127 else if (strcmp(*argv,"-F4") == 0 || strcmp(*argv,"-f4") == 0)
124 f4=RSA_F4; 128 f4=RSA_F4;
129#ifndef OPENSSL_NO_ENGINE
125 else if (strcmp(*argv,"-engine") == 0) 130 else if (strcmp(*argv,"-engine") == 0)
126 { 131 {
127 if (--argc < 1) goto bad; 132 if (--argc < 1) goto bad;
128 engine= *(++argv); 133 engine= *(++argv);
129 } 134 }
135#endif
130 else if (strcmp(*argv,"-rand") == 0) 136 else if (strcmp(*argv,"-rand") == 0)
131 { 137 {
132 if (--argc < 1) goto bad; 138 if (--argc < 1) goto bad;
@@ -177,7 +183,9 @@ bad:
177 BIO_printf(bio_err," -passout arg output file pass phrase source\n"); 183 BIO_printf(bio_err," -passout arg output file pass phrase source\n");
178 BIO_printf(bio_err," -f4 use F4 (0x10001) for the E value\n"); 184 BIO_printf(bio_err," -f4 use F4 (0x10001) for the E value\n");
179 BIO_printf(bio_err," -3 use 3 for the E value\n"); 185 BIO_printf(bio_err," -3 use 3 for the E value\n");
186#ifndef OPENSSL_NO_ENGINE
180 BIO_printf(bio_err," -engine e use engine e, possibly a hardware device.\n"); 187 BIO_printf(bio_err," -engine e use engine e, possibly a hardware device.\n");
188#endif
181 BIO_printf(bio_err," -rand file%cfile%c...\n", LIST_SEPARATOR_CHAR, LIST_SEPARATOR_CHAR); 189 BIO_printf(bio_err," -rand file%cfile%c...\n", LIST_SEPARATOR_CHAR, LIST_SEPARATOR_CHAR);
182 BIO_printf(bio_err," load the file (or the files in the directory) into\n"); 190 BIO_printf(bio_err," load the file (or the files in the directory) into\n");
183 BIO_printf(bio_err," the random number generator\n"); 191 BIO_printf(bio_err," the random number generator\n");
@@ -191,7 +199,9 @@ bad:
191 goto err; 199 goto err;
192 } 200 }
193 201
202#ifndef OPENSSL_NO_ENGINE
194 e = setup_engine(bio_err, engine, 0); 203 e = setup_engine(bio_err, engine, 0);
204#endif
195 205
196 if (outfile == NULL) 206 if (outfile == NULL)
197 { 207 {
@@ -258,7 +268,7 @@ err:
258 if (ret != 0) 268 if (ret != 0)
259 ERR_print_errors(bio_err); 269 ERR_print_errors(bio_err);
260 apps_shutdown(); 270 apps_shutdown();
261 EXIT(ret); 271 OPENSSL_EXIT(ret);
262 } 272 }
263 273
264static void MS_CALLBACK genrsa_cb(int p, int n, void *arg) 274static void MS_CALLBACK genrsa_cb(int p, int n, void *arg)
diff --git a/src/lib/libssl/src/apps/makeapps.com b/src/lib/libssl/src/apps/makeapps.com
index 148246facc..0197c8a171 100644
--- a/src/lib/libssl/src/apps/makeapps.com
+++ b/src/lib/libssl/src/apps/makeapps.com
@@ -15,22 +15,10 @@ $!
15$! It was written so it would try to determine what "C" compiler to 15$! It was written so it would try to determine what "C" compiler to
16$! use or you can specify which "C" compiler to use. 16$! use or you can specify which "C" compiler to use.
17$! 17$!
18$! Specify RSAREF as P1 to compile with the RSAREF library instead of 18$! Specify DEBUG or NODEBUG as P1 to compile with or without debugger
19$! the regular one. If you specify NORSAREF it will compile with the
20$! regular RSAREF routines. (Note: If you are in the United States
21$! you MUST compile with RSAREF unless you have a license from RSA).
22$!
23$! Note: The RSAREF libraries are NOT INCLUDED and you have to
24$! download it from "ftp://ftp.rsa.com/rsaref". You have to
25$! get the ".tar-Z" file as the ".zip" file dosen't have the
26$! directory structure stored. You have to extract the file
27$! into the [.RSAREF] directory under the root directory as that
28$! is where the scripts will look for the files.
29$!
30$! Specify DEBUG or NODEBUG as P2 to compile with or without debugger
31$! information. 19$! information.
32$! 20$!
33$! Specify which compiler at P3 to try to compile under. 21$! Specify which compiler at P2 to try to compile under.
34$! 22$!
35$! VAXC For VAX C. 23$! VAXC For VAX C.
36$! DECC For DEC C. 24$! DECC For DEC C.
@@ -39,16 +27,16 @@ $!
39$! If you don't speficy a compiler, it will try to determine which 27$! If you don't speficy a compiler, it will try to determine which
40$! "C" compiler to use. 28$! "C" compiler to use.
41$! 29$!
42$! P4, if defined, sets a TCP/IP library to use, through one of the following 30$! P3, if defined, sets a TCP/IP library to use, through one of the following
43$! keywords: 31$! keywords:
44$! 32$!
45$! UCX for UCX 33$! UCX for UCX
46$! SOCKETSHR for SOCKETSHR+NETLIB 34$! SOCKETSHR for SOCKETSHR+NETLIB
47$! TCPIP for TCPIP (post UCX) 35$! TCPIP for TCPIP (post UCX)
48$! 36$!
49$! P5, if defined, sets a compiler thread NOT needed on OpenVMS 7.1 (and up) 37$! P4, if defined, sets a compiler thread NOT needed on OpenVMS 7.1 (and up)
50$! 38$!
51$! P6, if defined, sets a choice of programs to compile. 39$! P5, if defined, sets a choice of programs to compile.
52$! 40$!
53$! 41$!
54$! Define A TCP/IP Library That We Will Need To Link To. 42$! Define A TCP/IP Library That We Will Need To Link To.
@@ -101,10 +89,6 @@ $! Define The CRYPTO Library.
101$! 89$!
102$ CRYPTO_LIB := SYS$DISK:[-.'ARCH'.EXE.CRYPTO]LIBCRYPTO.OLB 90$ CRYPTO_LIB := SYS$DISK:[-.'ARCH'.EXE.CRYPTO]LIBCRYPTO.OLB
103$! 91$!
104$! Define The RSAREF Library.
105$!
106$ RSAREF_LIB := SYS$DISK:[-.'ARCH'.EXE.RSAREF]LIBRSAGLUE.OLB
107$!
108$! Define The SSL Library. 92$! Define The SSL Library.
109$! 93$!
110$ SSL_LIB := SYS$DISK:[-.'ARCH'.EXE.SSL]LIBSSL.OLB 94$ SSL_LIB := SYS$DISK:[-.'ARCH'.EXE.SSL]LIBSSL.OLB
@@ -182,7 +166,7 @@ $! TCPIP_PROGRAMS = ",S_SERVER,S_CLIENT,SESS_ID,CIPHERS,S_TIME,"
182$! 166$!
183$! Setup exceptional compilations 167$! Setup exceptional compilations
184$! 168$!
185$ COMPILEWITH_CC2 = ",S_SOCKET,S_SERVER,S_CLIENT," 169$ COMPILEWITH_CC2 = ",S_SERVER,S_CLIENT,"
186$! 170$!
187$ PHASE := LIB 171$ PHASE := LIB
188$! 172$!
@@ -293,73 +277,31 @@ $ WRITE SYS$OUTPUT FILE_NAME," needs a TCP/IP library. Can't link. Skipping.
293$ GOTO NEXT_FILE 277$ GOTO NEXT_FILE
294$ ENDIF 278$ ENDIF
295$! 279$!
296$! Link The Program, Check To See If We Need To Link With RSAREF Or Not. 280$! Link The Program.
281$! Check To See If We Are To Link With A Specific TCP/IP Library.
297$! 282$!
298$ IF (RSAREF.EQS."TRUE") 283$ IF (TCPIP_LIB.NES."")
299$ THEN 284$ THEN
300$! 285$!
301$! Check To See If We Are To Link With A Specific TCP/IP Library. 286$! Don't Link With The RSAREF Routines And TCP/IP Library.
302$!
303$ IF (TCPIP_LIB.NES."")
304$ THEN
305$!
306$! Link With The RSAREF Library And A Specific TCP/IP Library.
307$!
308$ LINK/'DEBUGGER'/'TRACEBACK' /EXE='EXE_FILE' -
309 'OBJECT_FILE''EXTRA_OBJ', -
310 'SSL_LIB'/LIBRARY,'CRYPTO_LIB'/LIBRARY,'RSAREF_LIB'/LIBRARY, -
311 'TCPIP_LIB','OPT_FILE'/OPTION
312$! 287$!
313$! Else... 288$ LINK/'DEBUGGER'/'TRACEBACK' /EXE='EXE_FILE' -
314$! 289 'OBJECT_FILE''EXTRA_OBJ', -
315$ ELSE 290 'SSL_LIB'/LIBRARY,'CRYPTO_LIB'/LIBRARY, -
316$! 291 'TCPIP_LIB','OPT_FILE'/OPTION
317$! Link With The RSAREF Library And NO TCP/IP Library.
318$!
319$ LINK/'DEBUGGER'/'TRACEBACK' /EXE='EXE_FILE' -
320 'OBJECT_FILE''EXTRA_OBJ', -
321 'SSL_LIB'/LIBRARY,'CRYPTO_LIB'/LIBRARY,'RSAREF_LIB'/LIBRARY, -
322 'OPT_FILE'/OPTION
323$!
324$! End The TCP/IP Library Check.
325$!
326$ ENDIF
327$! 292$!
328$! Else... 293$! Else...
329$! 294$!
330$ ELSE 295$ ELSE
331$! 296$!
332$! Don't Link With The RSAREF Routines. 297$! Don't Link With The RSAREF Routines And Link With A TCP/IP Library.
333$!
334$! 298$!
335$! Check To See If We Are To Link With A Specific TCP/IP Library. 299$ LINK/'DEBUGGER'/'TRACEBACK' /EXE='EXE_FILE' -
300 'OBJECT_FILE''EXTRA_OBJ', -
301 'SSL_LIB'/LIBRARY,'CRYPTO_LIB'/LIBRARY, -
302 'OPT_FILE'/OPTION
336$! 303$!
337$ IF (TCPIP_LIB.NES."") 304$! End The TCP/IP Library Check.
338$ THEN
339$!
340$! Don't Link With The RSAREF Routines And TCP/IP Library.
341$!
342$ LINK/'DEBUGGER'/'TRACEBACK' /EXE='EXE_FILE' -
343 'OBJECT_FILE''EXTRA_OBJ', -
344 'SSL_LIB'/LIBRARY,'CRYPTO_LIB'/LIBRARY, -
345 'TCPIP_LIB','OPT_FILE'/OPTION
346$!
347$! Else...
348$!
349$ ELSE
350$!
351$! Don't Link With The RSAREF Routines And Link With A TCP/IP Library.
352$!
353$ LINK/'DEBUGGER'/'TRACEBACK' /EXE='EXE_FILE' -
354 'OBJECT_FILE''EXTRA_OBJ', -
355 'SSL_LIB'/LIBRARY,'CRYPTO_LIB'/LIBRARY, -
356 'OPT_FILE'/OPTION
357$!
358$! End The TCP/IP Library Check.
359$!
360$ ENDIF
361$!
362$! End The RSAREF Link Check.
363$! 305$!
364$ ENDIF 306$ ENDIF
365$! 307$!
@@ -526,32 +468,6 @@ $! End The Crypto Library Check.
526$! 468$!
527$ ENDIF 469$ ENDIF
528$! 470$!
529$! See If We Need The RSAREF Library.
530$!
531$ IF (RSAREF.EQS."TRUE")
532$ THEN
533$!
534$! Look For The Library LIBRSAGLUE.OLB.
535$!
536$ IF (F$SEARCH(RSAREF_LIB).EQS."")
537$ THEN
538$!
539$! Tell The User We Can't Find The LIBRSAGLUE.OLB Library.
540$!
541$ WRITE SYS$OUTPUT ""
542$ WRITE SYS$OUTPUT "Can't Find The Library ",RSAREF_LIB,"."
543$ WRITE SYS$OUTPUT "We Can't Link Without It."
544$ WRITE SYS$OUTPUT ""
545$!
546$! Since We Can't Link Without It, Exit.
547$!
548$ EXIT
549$ ENDIF
550$!
551$! End The RSAREF Library Check.
552$!
553$ ENDIF
554$!
555$! Look For The Library LIBSSL.OLB. 471$! Look For The Library LIBSSL.OLB.
556$! 472$!
557$ IF (F$SEARCH(SSL_LIB).EQS."") 473$ IF (F$SEARCH(SSL_LIB).EQS."")
@@ -582,87 +498,10 @@ $ CHECK_OPTIONS:
582$! 498$!
583$! Check To See If P1 Is Blank. 499$! Check To See If P1 Is Blank.
584$! 500$!
585$ P1 = "NORSAREF" 501$ IF (P1.EQS."NODEBUG")
586$ IF (P1.EQS."NORSAREF")
587$ THEN 502$ THEN
588$! 503$!
589$! P1 Is NORSAREF, So Compile With The Regular RSA Libraries. 504$! P1 Is NODEBUG, So Compile Without Debugger Information.
590$!
591$ RSAREF = "FALSE"
592$!
593$! Else...
594$!
595$ ELSE
596$!
597$! Check To See If We Are To Use The RSAREF Library.
598$!
599$ IF (P1.EQS."RSAREF")
600$ THEN
601$!
602$! Check To Make Sure We Have The RSAREF Source Code Directory.
603$!
604$ IF (F$SEARCH("SYS$DISK:[-.RSAREF]SOURCE.DIR").EQS."")
605$ THEN
606$!
607$! We Don't Have The RSAREF Souce Code Directory, So Tell The
608$! User This.
609$!
610$ WRITE SYS$OUTPUT ""
611$ WRITE SYS$OUTPUT "It appears that you don't have the RSAREF Souce Code."
612$ WRITE SYS$OUTPUT "You need to go to 'ftp://ftp.rsa.com/rsaref'. You have to"
613$ WRITE SYS$OUTPUT "get the '.tar-Z' file as the '.zip' file dosen't have the"
614$ WRITE SYS$OUTPUT "directory structure stored. You have to extract the file"
615$ WRITE SYS$OUTPUT "into the [.RSAREF] directory under the root directory"
616$ WRITE SYS$OUTPUT "as that is where the scripts will look for the files."
617$ WRITE SYS$OUTPUT ""
618$!
619$! Time To Exit.
620$!
621$ EXIT
622$!
623$! Else...
624$!
625$ ELSE
626$!
627$! Compile Using The RSAREF Library.
628$!
629$ RSAREF = "TRUE"
630$!
631$! End The RSAREF Soure Directory Check.
632$!
633$ ENDIF
634$!
635$! Else...
636$!
637$ ELSE
638$!
639$! They Entered An Invalid Option..
640$!
641$ WRITE SYS$OUTPUT ""
642$ WRITE SYS$OUTPUT "The Option ",P1," Is Invalid. The Valid Options Are:"
643$ WRITE SYS$OUTPUT ""
644$ WRITE SYS$OUTPUT " RSAREF : Compile With The RSAREF Library."
645$ WRITE SYS$OUTPUT " NORSAREF : Compile With The Regular RSA Library."
646$ WRITE SYS$OUTPUT ""
647$!
648$! Time To EXIT.
649$!
650$ EXIT
651$!
652$! End The Valid Arguement Check.
653$!
654$ ENDIF
655$!
656$! End P1 Check.
657$!
658$ ENDIF
659$!
660$! Check To See If P2 Is Blank.
661$!
662$ IF (P2.EQS."NODEBUG")
663$ THEN
664$!
665$! P2 Is NODEBUG, So Compile Without Debugger Information.
666$! 505$!
667$ DEBUGGER = "NODEBUG" 506$ DEBUGGER = "NODEBUG"
668$ TRACEBACK = "NOTRACEBACK" 507$ TRACEBACK = "NOTRACEBACK"
@@ -677,7 +516,7 @@ $ ELSE
677$! 516$!
678$! Check To See If We Are To Compile With Debugger Information. 517$! Check To See If We Are To Compile With Debugger Information.
679$! 518$!
680$ IF (P2.EQS."DEBUG") 519$ IF (P1.EQS."DEBUG")
681$ THEN 520$ THEN
682$! 521$!
683$! Compile With Debugger Information. 522$! Compile With Debugger Information.
@@ -693,7 +532,7 @@ $!
693$! Tell The User Entered An Invalid Option.. 532$! Tell The User Entered An Invalid Option..
694$! 533$!
695$ WRITE SYS$OUTPUT "" 534$ WRITE SYS$OUTPUT ""
696$ WRITE SYS$OUTPUT "The Option ",P2," Is Invalid. The Valid Options Are:" 535$ WRITE SYS$OUTPUT "The Option ",P1," Is Invalid. The Valid Options Are:"
697$ WRITE SYS$OUTPUT "" 536$ WRITE SYS$OUTPUT ""
698$ WRITE SYS$OUTPUT " DEBUG : Compile With The Debugger Information." 537$ WRITE SYS$OUTPUT " DEBUG : Compile With The Debugger Information."
699$ WRITE SYS$OUTPUT " NODEBUG : Compile Without The Debugger Information." 538$ WRITE SYS$OUTPUT " NODEBUG : Compile Without The Debugger Information."
@@ -707,13 +546,13 @@ $! End The Valid Arguement Check.
707$! 546$!
708$ ENDIF 547$ ENDIF
709$! 548$!
710$! End The P2 Check. 549$! End The P1 Check.
711$! 550$!
712$ ENDIF 551$ ENDIF
713$! 552$!
714$! Check To See If P3 Is Blank. 553$! Check To See If P2 Is Blank.
715$! 554$!
716$ IF (P3.EQS."") 555$ IF (P2.EQS."")
717$ THEN 556$ THEN
718$! 557$!
719$! O.K., The User Didn't Specify A Compiler, Let's Try To 558$! O.K., The User Didn't Specify A Compiler, Let's Try To
@@ -726,7 +565,7 @@ $ THEN
726$! 565$!
727$! Looks Like GNUC, Set To Use GNUC. 566$! Looks Like GNUC, Set To Use GNUC.
728$! 567$!
729$ P3 = "GNUC" 568$ P2 = "GNUC"
730$! 569$!
731$! Else... 570$! Else...
732$! 571$!
@@ -739,7 +578,7 @@ $ THEN
739$! 578$!
740$! Looks Like DECC, Set To Use DECC. 579$! Looks Like DECC, Set To Use DECC.
741$! 580$!
742$ P3 = "DECC" 581$ P2 = "DECC"
743$! 582$!
744$! Else... 583$! Else...
745$! 584$!
@@ -747,7 +586,7 @@ $ ELSE
747$! 586$!
748$! Looks Like VAXC, Set To Use VAXC. 587$! Looks Like VAXC, Set To Use VAXC.
749$! 588$!
750$ P3 = "VAXC" 589$ P2 = "VAXC"
751$! 590$!
752$! End The VAXC Compiler Check. 591$! End The VAXC Compiler Check.
753$! 592$!
@@ -761,9 +600,9 @@ $! End The Compiler Check.
761$! 600$!
762$ ENDIF 601$ ENDIF
763$! 602$!
764$! Check To See If We Have A Option For P4. 603$! Check To See If We Have A Option For P3.
765$! 604$!
766$ IF (P4.EQS."") 605$ IF (P3.EQS."")
767$ THEN 606$ THEN
768$! 607$!
769$! Find out what socket library we have available 608$! Find out what socket library we have available
@@ -773,7 +612,7 @@ $ THEN
773$! 612$!
774$! We have SOCKETSHR, and it is my opinion that it's the best to use. 613$! We have SOCKETSHR, and it is my opinion that it's the best to use.
775$! 614$!
776$ P4 = "SOCKETSHR" 615$ P3 = "SOCKETSHR"
777$! 616$!
778$! Tell the user 617$! Tell the user
779$! 618$!
@@ -793,7 +632,7 @@ $ THEN
793$! 632$!
794$! Last resort: a UCX or UCX-compatible library 633$! Last resort: a UCX or UCX-compatible library
795$! 634$!
796$ P4 = "UCX" 635$ P3 = "UCX"
797$! 636$!
798$! Tell the user 637$! Tell the user
799$! 638$!
@@ -817,12 +656,12 @@ $ IF F$TYPE(USER_CCDISABLEWARNINGS) .NES. "" THEN -
817$! 656$!
818$! Check To See If The User Entered A Valid Paramter. 657$! Check To See If The User Entered A Valid Paramter.
819$! 658$!
820$ IF (P3.EQS."VAXC").OR.(P3.EQS."DECC").OR.(P3.EQS."GNUC") 659$ IF (P2.EQS."VAXC").OR.(P2.EQS."DECC").OR.(P2.EQS."GNUC")
821$ THEN 660$ THEN
822$! 661$!
823$! Check To See If The User Wanted DECC. 662$! Check To See If The User Wanted DECC.
824$! 663$!
825$ IF (P3.EQS."DECC") 664$ IF (P2.EQS."DECC")
826$ THEN 665$ THEN
827$! 666$!
828$! Looks Like DECC, Set To Use DECC. 667$! Looks Like DECC, Set To Use DECC.
@@ -852,7 +691,7 @@ $ ENDIF
852$! 691$!
853$! Check To See If We Are To Use VAXC. 692$! Check To See If We Are To Use VAXC.
854$! 693$!
855$ IF (P3.EQS."VAXC") 694$ IF (P2.EQS."VAXC")
856$ THEN 695$ THEN
857$! 696$!
858$! Looks Like VAXC, Set To Use VAXC. 697$! Looks Like VAXC, Set To Use VAXC.
@@ -889,7 +728,7 @@ $ ENDIF
889$! 728$!
890$! Check To See If We Are To Use GNU C. 729$! Check To See If We Are To Use GNU C.
891$! 730$!
892$ IF (P3.EQS."GNUC") 731$ IF (P2.EQS."GNUC")
893$ THEN 732$ THEN
894$! 733$!
895$! Looks Like GNUC, Set To Use GNUC. 734$! Looks Like GNUC, Set To Use GNUC.
@@ -918,31 +757,6 @@ $! Set up default defines
918$! 757$!
919$ CCDEFS = """FLAT_INC=1""," + CCDEFS 758$ CCDEFS = """FLAT_INC=1""," + CCDEFS
920$! 759$!
921$! Check To See If We Are To Compile With RSAREF Routines.
922$!
923$ IF (RSAREF.EQS."TRUE")
924$ THEN
925$!
926$! Compile With RSAREF.
927$!
928$ CCDEFS = CCDEFS + ",""RSAref=1"""
929$!
930$! Tell The User This.
931$!
932$ WRITE SYS$OUTPUT "Compiling With RSAREF Routines."
933$!
934$! Else, We Don't Care. Compile Without The RSAREF Library.
935$!
936$ ELSE
937$!
938$! Tell The User We Are Compile Without The RSAREF Routines.
939$!
940$ WRITE SYS$OUTPUT "Compiling Without The RSAREF Routines.
941$!
942$! End The RSAREF Check.
943$!
944$ ENDIF
945$!
946$! Else The User Entered An Invalid Arguement. 760$! Else The User Entered An Invalid Arguement.
947$! 761$!
948$ ELSE 762$ ELSE
@@ -950,7 +764,7 @@ $!
950$! Tell The User We Don't Know What They Want. 764$! Tell The User We Don't Know What They Want.
951$! 765$!
952$ WRITE SYS$OUTPUT "" 766$ WRITE SYS$OUTPUT ""
953$ WRITE SYS$OUTPUT "The Option ",P3," Is Invalid. The Valid Options Are:" 767$ WRITE SYS$OUTPUT "The Option ",P2," Is Invalid. The Valid Options Are:"
954$ WRITE SYS$OUTPUT "" 768$ WRITE SYS$OUTPUT ""
955$ WRITE SYS$OUTPUT " VAXC : To Compile With VAX C." 769$ WRITE SYS$OUTPUT " VAXC : To Compile With VAX C."
956$ WRITE SYS$OUTPUT " DECC : To Compile With DEC C." 770$ WRITE SYS$OUTPUT " DECC : To Compile With DEC C."
@@ -964,13 +778,13 @@ $ ENDIF
964$! 778$!
965$! Time to check the contents, and to make sure we get the correct library. 779$! Time to check the contents, and to make sure we get the correct library.
966$! 780$!
967$ IF P4.EQS."SOCKETSHR" .OR. P4.EQS."MULTINET" .OR. P4.EQS."UCX" - 781$ IF P3.EQS."SOCKETSHR" .OR. P3.EQS."MULTINET" .OR. P3.EQS."UCX" -
968 .OR. P4.EQS."TCPIP" .OR. P4.EQS."NONE" 782 .OR. P3.EQS."TCPIP" .OR. P3.EQS."NONE"
969$ THEN 783$ THEN
970$! 784$!
971$! Check to see if SOCKETSHR was chosen 785$! Check to see if SOCKETSHR was chosen
972$! 786$!
973$ IF P4.EQS."SOCKETSHR" 787$ IF P3.EQS."SOCKETSHR"
974$ THEN 788$ THEN
975$! 789$!
976$! Set the library to use SOCKETSHR 790$! Set the library to use SOCKETSHR
@@ -983,12 +797,12 @@ $ ENDIF
983$! 797$!
984$! Check to see if MULTINET was chosen 798$! Check to see if MULTINET was chosen
985$! 799$!
986$ IF P4.EQS."MULTINET" 800$ IF P3.EQS."MULTINET"
987$ THEN 801$ THEN
988$! 802$!
989$! Set the library to use UCX emulation. 803$! Set the library to use UCX emulation.
990$! 804$!
991$ P4 = "UCX" 805$ P3 = "UCX"
992$! 806$!
993$! Done with MULTINET 807$! Done with MULTINET
994$! 808$!
@@ -996,7 +810,7 @@ $ ENDIF
996$! 810$!
997$! Check to see if UCX was chosen 811$! Check to see if UCX was chosen
998$! 812$!
999$ IF P4.EQS."UCX" 813$ IF P3.EQS."UCX"
1000$ THEN 814$ THEN
1001$! 815$!
1002$! Set the library to use UCX. 816$! Set the library to use UCX.
@@ -1016,7 +830,7 @@ $ ENDIF
1016$! 830$!
1017$! Check to see if TCPIP (post UCX) was chosen 831$! Check to see if TCPIP (post UCX) was chosen
1018$! 832$!
1019$ IF P4.EQS."TCPIP" 833$ IF P3.EQS."TCPIP"
1020$ THEN 834$ THEN
1021$! 835$!
1022$! Set the library to use TCPIP. 836$! Set the library to use TCPIP.
@@ -1029,7 +843,7 @@ $ ENDIF
1029$! 843$!
1030$! Check to see if NONE was chosen 844$! Check to see if NONE was chosen
1031$! 845$!
1032$ IF P4.EQS."NONE" 846$ IF P3.EQS."NONE"
1033$ THEN 847$ THEN
1034$! 848$!
1035$! Do not use TCPIP. 849$! Do not use TCPIP.
@@ -1042,7 +856,7 @@ $ ENDIF
1042$! 856$!
1043$! Add TCP/IP type to CC definitions. 857$! Add TCP/IP type to CC definitions.
1044$! 858$!
1045$ CCDEFS = CCDEFS + ",TCPIP_TYPE_''P4'" 859$ CCDEFS = CCDEFS + ",TCPIP_TYPE_''P3'"
1046$! 860$!
1047$! Print info 861$! Print info
1048$! 862$!
@@ -1055,7 +869,7 @@ $!
1055$! Tell The User We Don't Know What They Want. 869$! Tell The User We Don't Know What They Want.
1056$! 870$!
1057$ WRITE SYS$OUTPUT "" 871$ WRITE SYS$OUTPUT ""
1058$ WRITE SYS$OUTPUT "The Option ",P4," Is Invalid. The Valid Options Are:" 872$ WRITE SYS$OUTPUT "The Option ",P3," Is Invalid. The Valid Options Are:"
1059$ WRITE SYS$OUTPUT "" 873$ WRITE SYS$OUTPUT ""
1060$ WRITE SYS$OUTPUT " SOCKETSHR : To link with SOCKETSHR TCP/IP library." 874$ WRITE SYS$OUTPUT " SOCKETSHR : To link with SOCKETSHR TCP/IP library."
1061$ WRITE SYS$OUTPUT " UCX : To link with UCX TCP/IP library." 875$ WRITE SYS$OUTPUT " UCX : To link with UCX TCP/IP library."
@@ -1094,9 +908,9 @@ $! Written By: Richard Levitte
1094$! richard@levitte.org 908$! richard@levitte.org
1095$! 909$!
1096$! 910$!
1097$! Check To See If We Have A Option For P5. 911$! Check To See If We Have A Option For P4.
1098$! 912$!
1099$ IF (P5.EQS."") 913$ IF (P4.EQS."")
1100$ THEN 914$ THEN
1101$! 915$!
1102$! Get The Version Of VMS We Are Using. 916$! Get The Version Of VMS We Are Using.
@@ -1118,15 +932,15 @@ $! End The VMS Version Check.
1118$! 932$!
1119$ ENDIF 933$ ENDIF
1120$! 934$!
1121$! End The P5 Check. 935$! End The P4 Check.
1122$! 936$!
1123$ ENDIF 937$ ENDIF
1124$! 938$!
1125$! Check if the user wanted to compile just a subset of all the programs. 939$! Check if the user wanted to compile just a subset of all the programs.
1126$! 940$!
1127$ IF P6 .NES. "" 941$ IF P5 .NES. ""
1128$ THEN 942$ THEN
1129$ PROGRAMS = P6 943$ PROGRAMS = P5
1130$ ENDIF 944$ ENDIF
1131$! 945$!
1132$! Time To RETURN... 946$! Time To RETURN...
diff --git a/src/lib/libssl/src/apps/nseq.c b/src/lib/libssl/src/apps/nseq.c
index c26f62cb61..dc71d45012 100644
--- a/src/lib/libssl/src/apps/nseq.c
+++ b/src/lib/libssl/src/apps/nseq.c
@@ -102,7 +102,7 @@ int MAIN(int argc, char **argv)
102 BIO_printf (bio_err, "-in file input file\n"); 102 BIO_printf (bio_err, "-in file input file\n");
103 BIO_printf (bio_err, "-out file output file\n"); 103 BIO_printf (bio_err, "-out file output file\n");
104 BIO_printf (bio_err, "-toseq output NS Sequence file\n"); 104 BIO_printf (bio_err, "-toseq output NS Sequence file\n");
105 EXIT(1); 105 OPENSSL_EXIT(1);
106 } 106 }
107 107
108 if (infile) { 108 if (infile) {
@@ -162,6 +162,6 @@ end:
162 BIO_free_all(out); 162 BIO_free_all(out);
163 NETSCAPE_CERT_SEQUENCE_free(seq); 163 NETSCAPE_CERT_SEQUENCE_free(seq);
164 164
165 EXIT(ret); 165 OPENSSL_EXIT(ret);
166} 166}
167 167
diff --git a/src/lib/libssl/src/apps/ocsp.c b/src/lib/libssl/src/apps/ocsp.c
index 59b97a634b..17e84366d9 100644
--- a/src/lib/libssl/src/apps/ocsp.c
+++ b/src/lib/libssl/src/apps/ocsp.c
@@ -55,6 +55,7 @@
55 * Hudson (tjh@cryptsoft.com). 55 * Hudson (tjh@cryptsoft.com).
56 * 56 *
57 */ 57 */
58#ifndef OPENSSL_NO_OCSP
58 59
59#include <stdio.h> 60#include <stdio.h>
60#include <string.h> 61#include <string.h>
@@ -523,7 +524,7 @@ int MAIN(int argc, char **argv)
523 BIO_printf (bio_err, "-serial n serial number to check\n"); 524 BIO_printf (bio_err, "-serial n serial number to check\n");
524 BIO_printf (bio_err, "-signer file certificate to sign OCSP request with\n"); 525 BIO_printf (bio_err, "-signer file certificate to sign OCSP request with\n");
525 BIO_printf (bio_err, "-signkey file private key to sign OCSP request with\n"); 526 BIO_printf (bio_err, "-signkey file private key to sign OCSP request with\n");
526 BIO_printf (bio_err, "-sign_certs file additional certificates to include in signed request\n"); 527 BIO_printf (bio_err, "-sign_other file additional certificates to include in signed request\n");
527 BIO_printf (bio_err, "-no_certs don't include any certificates in signed request\n"); 528 BIO_printf (bio_err, "-no_certs don't include any certificates in signed request\n");
528 BIO_printf (bio_err, "-req_text print text form of request\n"); 529 BIO_printf (bio_err, "-req_text print text form of request\n");
529 BIO_printf (bio_err, "-resp_text print text form of response\n"); 530 BIO_printf (bio_err, "-resp_text print text form of response\n");
@@ -543,10 +544,10 @@ int MAIN(int argc, char **argv)
543 BIO_printf (bio_err, "-validity_period n maximum validity discrepancy in seconds\n"); 544 BIO_printf (bio_err, "-validity_period n maximum validity discrepancy in seconds\n");
544 BIO_printf (bio_err, "-status_age n maximum status age in seconds\n"); 545 BIO_printf (bio_err, "-status_age n maximum status age in seconds\n");
545 BIO_printf (bio_err, "-noverify don't verify response at all\n"); 546 BIO_printf (bio_err, "-noverify don't verify response at all\n");
546 BIO_printf (bio_err, "-verify_certs file additional certificates to search for signer\n"); 547 BIO_printf (bio_err, "-verify_other file additional certificates to search for signer\n");
547 BIO_printf (bio_err, "-trust_other don't verify additional certificates\n"); 548 BIO_printf (bio_err, "-trust_other don't verify additional certificates\n");
548 BIO_printf (bio_err, "-no_intern don't search certificates contained in response for signer\n"); 549 BIO_printf (bio_err, "-no_intern don't search certificates contained in response for signer\n");
549 BIO_printf (bio_err, "-no_sig_verify don't check signature on response\n"); 550 BIO_printf (bio_err, "-no_signature_verify don't check signature on response\n");
550 BIO_printf (bio_err, "-no_cert_verify don't check signing certificate\n"); 551 BIO_printf (bio_err, "-no_cert_verify don't check signing certificate\n");
551 BIO_printf (bio_err, "-no_chain don't chain verify response\n"); 552 BIO_printf (bio_err, "-no_chain don't chain verify response\n");
552 BIO_printf (bio_err, "-no_cert_checks don't do additional checks on signing certificate\n"); 553 BIO_printf (bio_err, "-no_cert_checks don't do additional checks on signing certificate\n");
@@ -722,7 +723,12 @@ int MAIN(int argc, char **argv)
722 } 723 }
723 else if (host) 724 else if (host)
724 { 725 {
726#ifndef OPENSSL_NO_SOCK
725 cbio = BIO_new_connect(host); 727 cbio = BIO_new_connect(host);
728#else
729 BIO_printf(bio_err, "Error creating connect BIO - sockets not supported.\n");
730 goto end;
731#endif
726 if (!cbio) 732 if (!cbio)
727 { 733 {
728 BIO_printf(bio_err, "Error creating connect BIO\n"); 734 BIO_printf(bio_err, "Error creating connect BIO\n");
@@ -732,7 +738,16 @@ int MAIN(int argc, char **argv)
732 if (use_ssl == 1) 738 if (use_ssl == 1)
733 { 739 {
734 BIO *sbio; 740 BIO *sbio;
741#if !defined(OPENSSL_NO_SSL2) && !defined(OPENSSL_NO_SSL3)
735 ctx = SSL_CTX_new(SSLv23_client_method()); 742 ctx = SSL_CTX_new(SSLv23_client_method());
743#elif !defined(OPENSSL_NO_SSL3)
744 ctx = SSL_CTX_new(SSLv3_client_method());
745#elif !defined(OPENSSL_NO_SSL2)
746 ctx = SSL_CTX_new(SSLv2_client_method());
747#else
748 BIO_printf(bio_err, "SSL is disabled\n");
749 goto end;
750#endif
736 SSL_CTX_set_mode(ctx, SSL_MODE_AUTO_RETRY); 751 SSL_CTX_set_mode(ctx, SSL_MODE_AUTO_RETRY);
737 sbio = BIO_new_ssl(ctx, 1); 752 sbio = BIO_new_ssl(ctx, 1);
738 cbio = BIO_push(sbio, cbio); 753 cbio = BIO_push(sbio, cbio);
@@ -899,7 +914,7 @@ end:
899 SSL_CTX_free(ctx); 914 SSL_CTX_free(ctx);
900 } 915 }
901 916
902 EXIT(ret); 917 OPENSSL_EXIT(ret);
903} 918}
904 919
905static int add_ocsp_cert(OCSP_REQUEST **req, X509 *cert, X509 *issuer, 920static int add_ocsp_cert(OCSP_REQUEST **req, X509 *cert, X509 *issuer,
@@ -1120,7 +1135,10 @@ static char **lookup_serial(TXT_DB *db, ASN1_INTEGER *ser)
1120 char *itmp, *row[DB_NUMBER],**rrow; 1135 char *itmp, *row[DB_NUMBER],**rrow;
1121 for (i = 0; i < DB_NUMBER; i++) row[i] = NULL; 1136 for (i = 0; i < DB_NUMBER; i++) row[i] = NULL;
1122 bn = ASN1_INTEGER_to_BN(ser,NULL); 1137 bn = ASN1_INTEGER_to_BN(ser,NULL);
1123 itmp = BN_bn2hex(bn); 1138 if (BN_is_zero(bn))
1139 itmp = BUF_strdup("00");
1140 else
1141 itmp = BN_bn2hex(bn);
1124 row[DB_serial] = itmp; 1142 row[DB_serial] = itmp;
1125 BN_free(bn); 1143 BN_free(bn);
1126 rrow=TXT_DB_get_by_index(db,DB_serial,row); 1144 rrow=TXT_DB_get_by_index(db,DB_serial,row);
@@ -1136,7 +1154,11 @@ static BIO *init_responder(char *port)
1136 bufbio = BIO_new(BIO_f_buffer()); 1154 bufbio = BIO_new(BIO_f_buffer());
1137 if (!bufbio) 1155 if (!bufbio)
1138 goto err; 1156 goto err;
1157#ifndef OPENSSL_NO_SOCK
1139 acbio = BIO_new_accept(port); 1158 acbio = BIO_new_accept(port);
1159#else
1160 BIO_printf(bio_err, "Error setting up accept BIO - sockets not supported.\n");
1161#endif
1140 if (!acbio) 1162 if (!acbio)
1141 goto err; 1163 goto err;
1142 BIO_set_accept_bios(acbio, bufbio); 1164 BIO_set_accept_bios(acbio, bufbio);
@@ -1176,7 +1198,7 @@ static int do_responder(OCSP_REQUEST **preq, BIO **pcbio, BIO *acbio, char *port
1176 1198
1177 for(;;) 1199 for(;;)
1178 { 1200 {
1179 len = BIO_gets(cbio, inbuf, 1024); 1201 len = BIO_gets(cbio, inbuf, sizeof inbuf);
1180 if (len <= 0) 1202 if (len <= 0)
1181 return 1; 1203 return 1;
1182 /* Look for "POST" signalling start of query */ 1204 /* Look for "POST" signalling start of query */
@@ -1223,3 +1245,4 @@ static int send_ocsp_response(BIO *cbio, OCSP_RESPONSE *resp)
1223 return 1; 1245 return 1;
1224 } 1246 }
1225 1247
1248#endif
diff --git a/src/lib/libssl/src/apps/openssl.c b/src/lib/libssl/src/apps/openssl.c
index 1c4a4291aa..45af2ba7f9 100644
--- a/src/lib/libssl/src/apps/openssl.c
+++ b/src/lib/libssl/src/apps/openssl.c
@@ -122,7 +122,9 @@
122#include <openssl/x509.h> 122#include <openssl/x509.h>
123#include <openssl/pem.h> 123#include <openssl/pem.h>
124#include <openssl/ssl.h> 124#include <openssl/ssl.h>
125#ifndef OPENSSL_NO_ENGINE
125#include <openssl/engine.h> 126#include <openssl/engine.h>
127#endif
126#define USE_SOCKETS /* needed for the _O_BINARY defs in the MS world */ 128#define USE_SOCKETS /* needed for the _O_BINARY defs in the MS world */
127#include "progs.h" 129#include "progs.h"
128#include "s_apps.h" 130#include "s_apps.h"
@@ -139,11 +141,11 @@ static unsigned long MS_CALLBACK hash(const void *a_void);
139static int MS_CALLBACK cmp(const void *a_void,const void *b_void); 141static int MS_CALLBACK cmp(const void *a_void,const void *b_void);
140static LHASH *prog_init(void ); 142static LHASH *prog_init(void );
141static int do_cmd(LHASH *prog,int argc,char *argv[]); 143static int do_cmd(LHASH *prog,int argc,char *argv[]);
142CONF *config=NULL;
143char *default_config_file=NULL; 144char *default_config_file=NULL;
144 145
145/* Make sure there is only one when MONOLITH is defined */ 146/* Make sure there is only one when MONOLITH is defined */
146#ifdef MONOLITH 147#ifdef MONOLITH
148CONF *config=NULL;
147BIO *bio_err=NULL; 149BIO *bio_err=NULL;
148#endif 150#endif
149 151
@@ -218,7 +220,8 @@ int main(int Argc, char *Argv[])
218#define PROG_NAME_SIZE 39 220#define PROG_NAME_SIZE 39
219 char pname[PROG_NAME_SIZE+1]; 221 char pname[PROG_NAME_SIZE+1];
220 FUNCTION f,*fp; 222 FUNCTION f,*fp;
221 MS_STATIC char *prompt,buf[1024],config_name[256]; 223 MS_STATIC char *prompt,buf[1024];
224 char *to_free=NULL;
222 int n,i,ret=0; 225 int n,i,ret=0;
223 int argc; 226 int argc;
224 char **argv,*p; 227 char **argv,*p;
@@ -228,6 +231,10 @@ int main(int Argc, char *Argv[])
228 arg.data=NULL; 231 arg.data=NULL;
229 arg.count=0; 232 arg.count=0;
230 233
234 if (bio_err == NULL)
235 if ((bio_err=BIO_new(BIO_s_file())) != NULL)
236 BIO_set_fp(bio_err,stderr,BIO_NOCLOSE|BIO_FP_TEXT);
237
231 if (getenv("OPENSSL_DEBUG_MEMORY") != NULL) /* if not defined, use compiled-in library defaults */ 238 if (getenv("OPENSSL_DEBUG_MEMORY") != NULL) /* if not defined, use compiled-in library defaults */
232 { 239 {
233 if (!(0 == strcmp(getenv("OPENSSL_DEBUG_MEMORY"), "off"))) 240 if (!(0 == strcmp(getenv("OPENSSL_DEBUG_MEMORY"), "off")))
@@ -252,23 +259,12 @@ int main(int Argc, char *Argv[])
252 259
253 apps_startup(); 260 apps_startup();
254 261
255 if (bio_err == NULL)
256 if ((bio_err=BIO_new(BIO_s_file())) != NULL)
257 BIO_set_fp(bio_err,stderr,BIO_NOCLOSE|BIO_FP_TEXT);
258
259 /* Lets load up our environment a little */ 262 /* Lets load up our environment a little */
260 p=getenv("OPENSSL_CONF"); 263 p=getenv("OPENSSL_CONF");
261 if (p == NULL) 264 if (p == NULL)
262 p=getenv("SSLEAY_CONF"); 265 p=getenv("SSLEAY_CONF");
263 if (p == NULL) 266 if (p == NULL)
264 { 267 p=to_free=make_config_name();
265 strcpy(config_name,X509_get_default_cert_area());
266#ifndef OPENSSL_SYS_VMS
267 strcat(config_name,"/");
268#endif
269 strcat(config_name,OPENSSL_CONF);
270 p=config_name;
271 }
272 268
273 default_config_file=p; 269 default_config_file=p;
274 270
@@ -284,7 +280,7 @@ int main(int Argc, char *Argv[])
284 prog=prog_init(); 280 prog=prog_init();
285 281
286 /* first check the program name */ 282 /* first check the program name */
287 program_name(Argv[0],pname,PROG_NAME_SIZE); 283 program_name(Argv[0],pname,sizeof pname);
288 284
289 f.name=pname; 285 f.name=pname;
290 fp=(FUNCTION *)lh_retrieve(prog,&f); 286 fp=(FUNCTION *)lh_retrieve(prog,&f);
@@ -312,7 +308,7 @@ int main(int Argc, char *Argv[])
312 { 308 {
313 ret=0; 309 ret=0;
314 p=buf; 310 p=buf;
315 n=1024; 311 n=sizeof buf;
316 i=0; 312 i=0;
317 for (;;) 313 for (;;)
318 { 314 {
@@ -346,6 +342,8 @@ int main(int Argc, char *Argv[])
346 BIO_printf(bio_err,"bad exit\n"); 342 BIO_printf(bio_err,"bad exit\n");
347 ret=1; 343 ret=1;
348end: 344end:
345 if (to_free)
346 OPENSSL_free(to_free);
349 if (config != NULL) 347 if (config != NULL)
350 { 348 {
351 NCONF_free(config); 349 NCONF_free(config);
@@ -362,7 +360,7 @@ end:
362 BIO_free(bio_err); 360 BIO_free(bio_err);
363 bio_err=NULL; 361 bio_err=NULL;
364 } 362 }
365 EXIT(ret); 363 OPENSSL_EXIT(ret);
366 } 364 }
367 365
368#define LIST_STANDARD_COMMANDS "list-standard-commands" 366#define LIST_STANDARD_COMMANDS "list-standard-commands"
diff --git a/src/lib/libssl/src/apps/passwd.c b/src/lib/libssl/src/apps/passwd.c
index ad8e7b0349..3ad91d89d6 100644
--- a/src/lib/libssl/src/apps/passwd.c
+++ b/src/lib/libssl/src/apps/passwd.c
@@ -19,7 +19,6 @@
19# include <openssl/des.h> 19# include <openssl/des.h>
20#endif 20#endif
21#ifndef NO_MD5CRYPT_1 21#ifndef NO_MD5CRYPT_1
22# include <openssl/evp.h>
23# include <openssl/md5.h> 22# include <openssl/md5.h>
24#endif 23#endif
25 24
@@ -293,7 +292,7 @@ err:
293 if (out) 292 if (out)
294 BIO_free_all(out); 293 BIO_free_all(out);
295 apps_shutdown(); 294 apps_shutdown();
296 EXIT(ret); 295 OPENSSL_EXIT(ret);
297 } 296 }
298 297
299 298
@@ -506,6 +505,6 @@ err:
506int MAIN(int argc, char **argv) 505int MAIN(int argc, char **argv)
507 { 506 {
508 fputs("Program not available.\n", stderr) 507 fputs("Program not available.\n", stderr)
509 EXIT(1); 508 OPENSSL_EXIT(1);
510 } 509 }
511#endif 510#endif
diff --git a/src/lib/libssl/src/apps/pkcs12.c b/src/lib/libssl/src/apps/pkcs12.c
index 1697f6157f..5136acdc57 100644
--- a/src/lib/libssl/src/apps/pkcs12.c
+++ b/src/lib/libssl/src/apps/pkcs12.c
@@ -120,7 +120,9 @@ int MAIN(int argc, char **argv)
120 char *passin = NULL, *passout = NULL; 120 char *passin = NULL, *passout = NULL;
121 char *inrand = NULL; 121 char *inrand = NULL;
122 char *CApath = NULL, *CAfile = NULL; 122 char *CApath = NULL, *CAfile = NULL;
123#ifndef OPENSSL_NO_ENGINE
123 char *engine=NULL; 124 char *engine=NULL;
125#endif
124 126
125 apps_startup(); 127 apps_startup();
126 128
@@ -252,11 +254,13 @@ int MAIN(int argc, char **argv)
252 args++; 254 args++;
253 CAfile = *args; 255 CAfile = *args;
254 } else badarg = 1; 256 } else badarg = 1;
257#ifndef OPENSSL_NO_ENGINE
255 } else if (!strcmp(*args,"-engine")) { 258 } else if (!strcmp(*args,"-engine")) {
256 if (args[1]) { 259 if (args[1]) {
257 args++; 260 args++;
258 engine = *args; 261 engine = *args;
259 } else badarg = 1; 262 } else badarg = 1;
263#endif
260 } else badarg = 1; 264 } else badarg = 1;
261 265
262 } else badarg = 1; 266 } else badarg = 1;
@@ -304,14 +308,18 @@ int MAIN(int argc, char **argv)
304 BIO_printf (bio_err, "-password p set import/export password source\n"); 308 BIO_printf (bio_err, "-password p set import/export password source\n");
305 BIO_printf (bio_err, "-passin p input file pass phrase source\n"); 309 BIO_printf (bio_err, "-passin p input file pass phrase source\n");
306 BIO_printf (bio_err, "-passout p output file pass phrase source\n"); 310 BIO_printf (bio_err, "-passout p output file pass phrase source\n");
311#ifndef OPENSSL_NO_ENGINE
307 BIO_printf (bio_err, "-engine e use engine e, possibly a hardware device.\n"); 312 BIO_printf (bio_err, "-engine e use engine e, possibly a hardware device.\n");
313#endif
308 BIO_printf(bio_err, "-rand file%cfile%c...\n", LIST_SEPARATOR_CHAR, LIST_SEPARATOR_CHAR); 314 BIO_printf(bio_err, "-rand file%cfile%c...\n", LIST_SEPARATOR_CHAR, LIST_SEPARATOR_CHAR);
309 BIO_printf(bio_err, " load the file (or the files in the directory) into\n"); 315 BIO_printf(bio_err, " load the file (or the files in the directory) into\n");
310 BIO_printf(bio_err, " the random number generator\n"); 316 BIO_printf(bio_err, " the random number generator\n");
311 goto end; 317 goto end;
312 } 318 }
313 319
320#ifndef OPENSSL_NO_ENGINE
314 e = setup_engine(bio_err, engine, 0); 321 e = setup_engine(bio_err, engine, 0);
322#endif
315 323
316 if(passarg) { 324 if(passarg) {
317 if(export_cert) passargout = passarg; 325 if(export_cert) passargout = passarg;
@@ -399,7 +407,7 @@ int MAIN(int argc, char **argv)
399#ifdef CRYPTO_MDEBUG 407#ifdef CRYPTO_MDEBUG
400 CRYPTO_push_info("read MAC password"); 408 CRYPTO_push_info("read MAC password");
401#endif 409#endif
402 if(EVP_read_pw_string (macpass, 50, "Enter MAC Password:", export_cert)) 410 if(EVP_read_pw_string (macpass, sizeof macpass, "Enter MAC Password:", export_cert))
403 { 411 {
404 BIO_printf (bio_err, "Can't read Password\n"); 412 BIO_printf (bio_err, "Can't read Password\n");
405 goto end; 413 goto end;
@@ -545,7 +553,7 @@ int MAIN(int argc, char **argv)
545#endif 553#endif
546 554
547 if(!noprompt && 555 if(!noprompt &&
548 EVP_read_pw_string(pass, 50, "Enter Export Password:", 1)) { 556 EVP_read_pw_string(pass, sizeof pass, "Enter Export Password:", 1)) {
549 BIO_printf (bio_err, "Can't read Password\n"); 557 BIO_printf (bio_err, "Can't read Password\n");
550 goto export_end; 558 goto export_end;
551 } 559 }
@@ -642,7 +650,7 @@ int MAIN(int argc, char **argv)
642#ifdef CRYPTO_MDEBUG 650#ifdef CRYPTO_MDEBUG
643 CRYPTO_push_info("read import password"); 651 CRYPTO_push_info("read import password");
644#endif 652#endif
645 if(!noprompt && EVP_read_pw_string(pass, 50, "Enter Import Password:", 0)) { 653 if(!noprompt && EVP_read_pw_string(pass, sizeof pass, "Enter Import Password:", 0)) {
646 BIO_printf (bio_err, "Can't read Password\n"); 654 BIO_printf (bio_err, "Can't read Password\n");
647 goto end; 655 goto end;
648 } 656 }
@@ -696,7 +704,7 @@ int MAIN(int argc, char **argv)
696 if(passin) OPENSSL_free(passin); 704 if(passin) OPENSSL_free(passin);
697 if(passout) OPENSSL_free(passout); 705 if(passout) OPENSSL_free(passout);
698 apps_shutdown(); 706 apps_shutdown();
699 EXIT(ret); 707 OPENSSL_EXIT(ret);
700} 708}
701 709
702int dump_certs_keys_p12 (BIO *out, PKCS12 *p12, char *pass, 710int dump_certs_keys_p12 (BIO *out, PKCS12 *p12, char *pass,
diff --git a/src/lib/libssl/src/apps/pkcs7.c b/src/lib/libssl/src/apps/pkcs7.c
index 0cced40f0f..6c58c67eb2 100644
--- a/src/lib/libssl/src/apps/pkcs7.c
+++ b/src/lib/libssl/src/apps/pkcs7.c
@@ -82,7 +82,9 @@ int MAIN(int, char **);
82 82
83int MAIN(int argc, char **argv) 83int MAIN(int argc, char **argv)
84 { 84 {
85#ifndef OPENSSL_NO_ENGINE
85 ENGINE *e = NULL; 86 ENGINE *e = NULL;
87#endif
86 PKCS7 *p7=NULL; 88 PKCS7 *p7=NULL;
87 int i,badops=0; 89 int i,badops=0;
88 BIO *in=NULL,*out=NULL; 90 BIO *in=NULL,*out=NULL;
@@ -90,7 +92,9 @@ int MAIN(int argc, char **argv)
90 char *infile,*outfile,*prog; 92 char *infile,*outfile,*prog;
91 int print_certs=0,text=0,noout=0; 93 int print_certs=0,text=0,noout=0;
92 int ret=1; 94 int ret=1;
95#ifndef OPENSSL_NO_ENGINE
93 char *engine=NULL; 96 char *engine=NULL;
97#endif
94 98
95 apps_startup(); 99 apps_startup();
96 100
@@ -134,11 +138,13 @@ int MAIN(int argc, char **argv)
134 text=1; 138 text=1;
135 else if (strcmp(*argv,"-print_certs") == 0) 139 else if (strcmp(*argv,"-print_certs") == 0)
136 print_certs=1; 140 print_certs=1;
141#ifndef OPENSSL_NO_ENGINE
137 else if (strcmp(*argv,"-engine") == 0) 142 else if (strcmp(*argv,"-engine") == 0)
138 { 143 {
139 if (--argc < 1) goto bad; 144 if (--argc < 1) goto bad;
140 engine= *(++argv); 145 engine= *(++argv);
141 } 146 }
147#endif
142 else 148 else
143 { 149 {
144 BIO_printf(bio_err,"unknown option %s\n",*argv); 150 BIO_printf(bio_err,"unknown option %s\n",*argv);
@@ -161,14 +167,18 @@ bad:
161 BIO_printf(bio_err," -print_certs print any certs or crl in the input\n"); 167 BIO_printf(bio_err," -print_certs print any certs or crl in the input\n");
162 BIO_printf(bio_err," -text print full details of certificates\n"); 168 BIO_printf(bio_err," -text print full details of certificates\n");
163 BIO_printf(bio_err," -noout don't output encoded data\n"); 169 BIO_printf(bio_err," -noout don't output encoded data\n");
170#ifndef OPENSSL_NO_ENGINE
164 BIO_printf(bio_err," -engine e use engine e, possibly a hardware device.\n"); 171 BIO_printf(bio_err," -engine e use engine e, possibly a hardware device.\n");
172#endif
165 ret = 1; 173 ret = 1;
166 goto end; 174 goto end;
167 } 175 }
168 176
169 ERR_load_crypto_strings(); 177 ERR_load_crypto_strings();
170 178
179#ifndef OPENSSL_NO_ENGINE
171 e = setup_engine(bio_err, engine, 0); 180 e = setup_engine(bio_err, engine, 0);
181#endif
172 182
173 in=BIO_new(BIO_s_file()); 183 in=BIO_new(BIO_s_file());
174 out=BIO_new(BIO_s_file()); 184 out=BIO_new(BIO_s_file());
@@ -301,5 +311,5 @@ end:
301 if (in != NULL) BIO_free(in); 311 if (in != NULL) BIO_free(in);
302 if (out != NULL) BIO_free_all(out); 312 if (out != NULL) BIO_free_all(out);
303 apps_shutdown(); 313 apps_shutdown();
304 EXIT(ret); 314 OPENSSL_EXIT(ret);
305 } 315 }
diff --git a/src/lib/libssl/src/apps/pkcs8.c b/src/lib/libssl/src/apps/pkcs8.c
index 912e32006b..6be27e7f44 100644
--- a/src/lib/libssl/src/apps/pkcs8.c
+++ b/src/lib/libssl/src/apps/pkcs8.c
@@ -63,7 +63,6 @@
63#include <openssl/evp.h> 63#include <openssl/evp.h>
64#include <openssl/pkcs12.h> 64#include <openssl/pkcs12.h>
65 65
66#include "apps.h"
67#define PROG pkcs8_main 66#define PROG pkcs8_main
68 67
69int MAIN(int, char **); 68int MAIN(int, char **);
@@ -86,7 +85,9 @@ int MAIN(int argc, char **argv)
86 EVP_PKEY *pkey=NULL; 85 EVP_PKEY *pkey=NULL;
87 char pass[50], *passin = NULL, *passout = NULL, *p8pass = NULL; 86 char pass[50], *passin = NULL, *passout = NULL, *p8pass = NULL;
88 int badarg = 0; 87 int badarg = 0;
88#ifndef OPENSSL_NO_ENGINE
89 char *engine=NULL; 89 char *engine=NULL;
90#endif
90 91
91 if (bio_err == NULL) bio_err = BIO_new_fp (stderr, BIO_NOCLOSE); 92 if (bio_err == NULL) bio_err = BIO_new_fp (stderr, BIO_NOCLOSE);
92 93
@@ -146,11 +147,13 @@ int MAIN(int argc, char **argv)
146 if (!args[1]) goto bad; 147 if (!args[1]) goto bad;
147 passargout= *(++args); 148 passargout= *(++args);
148 } 149 }
150#ifndef OPENSSL_NO_ENGINE
149 else if (strcmp(*args,"-engine") == 0) 151 else if (strcmp(*args,"-engine") == 0)
150 { 152 {
151 if (!args[1]) goto bad; 153 if (!args[1]) goto bad;
152 engine= *(++args); 154 engine= *(++args);
153 } 155 }
156#endif
154 else if (!strcmp (*args, "-in")) { 157 else if (!strcmp (*args, "-in")) {
155 if (args[1]) { 158 if (args[1]) {
156 args++; 159 args++;
@@ -183,11 +186,15 @@ int MAIN(int argc, char **argv)
183 BIO_printf(bio_err, "-nocrypt use or expect unencrypted private key\n"); 186 BIO_printf(bio_err, "-nocrypt use or expect unencrypted private key\n");
184 BIO_printf(bio_err, "-v2 alg use PKCS#5 v2.0 and cipher \"alg\"\n"); 187 BIO_printf(bio_err, "-v2 alg use PKCS#5 v2.0 and cipher \"alg\"\n");
185 BIO_printf(bio_err, "-v1 obj use PKCS#5 v1.5 and cipher \"alg\"\n"); 188 BIO_printf(bio_err, "-v1 obj use PKCS#5 v1.5 and cipher \"alg\"\n");
189#ifndef OPENSSL_NO_ENGINE
186 BIO_printf(bio_err," -engine e use engine e, possibly a hardware device.\n"); 190 BIO_printf(bio_err," -engine e use engine e, possibly a hardware device.\n");
191#endif
187 return (1); 192 return (1);
188 } 193 }
189 194
195#ifndef OPENSSL_NO_ENGINE
190 e = setup_engine(bio_err, engine, 0); 196 e = setup_engine(bio_err, engine, 0);
197#endif
191 198
192 if(!app_passwd(bio_err, passargin, passargout, &passin, &passout)) { 199 if(!app_passwd(bio_err, passargin, passargout, &passin, &passout)) {
193 BIO_printf(bio_err, "Error getting passwords\n"); 200 BIO_printf(bio_err, "Error getting passwords\n");
@@ -245,7 +252,8 @@ int MAIN(int argc, char **argv)
245 if(passout) p8pass = passout; 252 if(passout) p8pass = passout;
246 else { 253 else {
247 p8pass = pass; 254 p8pass = pass;
248 EVP_read_pw_string(pass, 50, "Enter Encryption Password:", 1); 255 if (EVP_read_pw_string(pass, sizeof pass, "Enter Encryption Password:", 1))
256 return (1);
249 } 257 }
250 app_RAND_load_file(NULL, bio_err, 0); 258 app_RAND_load_file(NULL, bio_err, 0);
251 if (!(p8 = PKCS8_encrypt(pbe_nid, cipher, 259 if (!(p8 = PKCS8_encrypt(pbe_nid, cipher,
@@ -302,7 +310,7 @@ int MAIN(int argc, char **argv)
302 if(passin) p8pass = passin; 310 if(passin) p8pass = passin;
303 else { 311 else {
304 p8pass = pass; 312 p8pass = pass;
305 EVP_read_pw_string(pass, 50, "Enter Password:", 0); 313 EVP_read_pw_string(pass, sizeof pass, "Enter Password:", 0);
306 } 314 }
307 p8inf = PKCS8_decrypt(p8, p8pass, strlen(p8pass)); 315 p8inf = PKCS8_decrypt(p8, p8pass, strlen(p8pass));
308 X509_SIG_free(p8); 316 X509_SIG_free(p8);
diff --git a/src/lib/libssl/src/apps/progs.h b/src/lib/libssl/src/apps/progs.h
index 752385d3a7..70e4dbac07 100644
--- a/src/lib/libssl/src/apps/progs.h
+++ b/src/lib/libssl/src/apps/progs.h
@@ -35,7 +35,9 @@ extern int pkcs8_main(int argc,char *argv[]);
35extern int spkac_main(int argc,char *argv[]); 35extern int spkac_main(int argc,char *argv[]);
36extern int smime_main(int argc,char *argv[]); 36extern int smime_main(int argc,char *argv[]);
37extern int rand_main(int argc,char *argv[]); 37extern int rand_main(int argc,char *argv[]);
38#ifndef OPENSSL_NO_ENGINE
38extern int engine_main(int argc,char *argv[]); 39extern int engine_main(int argc,char *argv[]);
40#endif
39extern int ocsp_main(int argc,char *argv[]); 41extern int ocsp_main(int argc,char *argv[]);
40 42
41#define FUNC_TYPE_GENERAL 1 43#define FUNC_TYPE_GENERAL 1
@@ -92,7 +94,9 @@ FUNCTION functions[] = {
92#if !defined(OPENSSL_NO_SOCK) && !(defined(OPENSSL_NO_SSL2) && defined(OPENSSL_NO_SSL3)) 94#if !defined(OPENSSL_NO_SOCK) && !(defined(OPENSSL_NO_SSL2) && defined(OPENSSL_NO_SSL3))
93 {FUNC_TYPE_GENERAL,"s_client",s_client_main}, 95 {FUNC_TYPE_GENERAL,"s_client",s_client_main},
94#endif 96#endif
97#ifndef OPENSSL_NO_SPEED
95 {FUNC_TYPE_GENERAL,"speed",speed_main}, 98 {FUNC_TYPE_GENERAL,"speed",speed_main},
99#endif
96#if !defined(OPENSSL_NO_SOCK) && !(defined(OPENSSL_NO_SSL2) && defined(OPENSSL_NO_SSL3)) 100#if !defined(OPENSSL_NO_SOCK) && !(defined(OPENSSL_NO_SSL2) && defined(OPENSSL_NO_SSL3))
97 {FUNC_TYPE_GENERAL,"s_time",s_time_main}, 101 {FUNC_TYPE_GENERAL,"s_time",s_time_main},
98#endif 102#endif
@@ -111,7 +115,9 @@ FUNCTION functions[] = {
111 {FUNC_TYPE_GENERAL,"spkac",spkac_main}, 115 {FUNC_TYPE_GENERAL,"spkac",spkac_main},
112 {FUNC_TYPE_GENERAL,"smime",smime_main}, 116 {FUNC_TYPE_GENERAL,"smime",smime_main},
113 {FUNC_TYPE_GENERAL,"rand",rand_main}, 117 {FUNC_TYPE_GENERAL,"rand",rand_main},
118#ifndef OPENSSL_NO_ENGINE
114 {FUNC_TYPE_GENERAL,"engine",engine_main}, 119 {FUNC_TYPE_GENERAL,"engine",engine_main},
120#endif
115 {FUNC_TYPE_GENERAL,"ocsp",ocsp_main}, 121 {FUNC_TYPE_GENERAL,"ocsp",ocsp_main},
116#ifndef OPENSSL_NO_MD2 122#ifndef OPENSSL_NO_MD2
117 {FUNC_TYPE_MD,"md2",dgst_main}, 123 {FUNC_TYPE_MD,"md2",dgst_main},
diff --git a/src/lib/libssl/src/apps/rand.c b/src/lib/libssl/src/apps/rand.c
index f51f5bec35..63724bc730 100644
--- a/src/lib/libssl/src/apps/rand.c
+++ b/src/lib/libssl/src/apps/rand.c
@@ -76,7 +76,9 @@ int MAIN(int, char **);
76 76
77int MAIN(int argc, char **argv) 77int MAIN(int argc, char **argv)
78 { 78 {
79#ifndef OPENSSL_NO_ENGINE
79 ENGINE *e = NULL; 80 ENGINE *e = NULL;
81#endif
80 int i, r, ret = 1; 82 int i, r, ret = 1;
81 int badopt; 83 int badopt;
82 char *outfile = NULL; 84 char *outfile = NULL;
@@ -84,7 +86,9 @@ int MAIN(int argc, char **argv)
84 int base64 = 0; 86 int base64 = 0;
85 BIO *out = NULL; 87 BIO *out = NULL;
86 int num = -1; 88 int num = -1;
89#ifndef OPENSSL_NO_ENGINE
87 char *engine=NULL; 90 char *engine=NULL;
91#endif
88 92
89 apps_startup(); 93 apps_startup();
90 94
@@ -106,6 +110,7 @@ int MAIN(int argc, char **argv)
106 else 110 else
107 badopt = 1; 111 badopt = 1;
108 } 112 }
113#ifndef OPENSSL_NO_ENGINE
109 else if (strcmp(argv[i], "-engine") == 0) 114 else if (strcmp(argv[i], "-engine") == 0)
110 { 115 {
111 if ((argv[i+1] != NULL) && (engine == NULL)) 116 if ((argv[i+1] != NULL) && (engine == NULL))
@@ -113,6 +118,7 @@ int MAIN(int argc, char **argv)
113 else 118 else
114 badopt = 1; 119 badopt = 1;
115 } 120 }
121#endif
116 else if (strcmp(argv[i], "-rand") == 0) 122 else if (strcmp(argv[i], "-rand") == 0)
117 { 123 {
118 if ((argv[i+1] != NULL) && (inrand == NULL)) 124 if ((argv[i+1] != NULL) && (inrand == NULL))
@@ -150,13 +156,17 @@ int MAIN(int argc, char **argv)
150 BIO_printf(bio_err, "Usage: rand [options] num\n"); 156 BIO_printf(bio_err, "Usage: rand [options] num\n");
151 BIO_printf(bio_err, "where options are\n"); 157 BIO_printf(bio_err, "where options are\n");
152 BIO_printf(bio_err, "-out file - write to file\n"); 158 BIO_printf(bio_err, "-out file - write to file\n");
159#ifndef OPENSSL_NO_ENGINE
153 BIO_printf(bio_err, "-engine e - use engine e, possibly a hardware device.\n"); 160 BIO_printf(bio_err, "-engine e - use engine e, possibly a hardware device.\n");
161#endif
154 BIO_printf(bio_err, "-rand file%cfile%c... - seed PRNG from files\n", LIST_SEPARATOR_CHAR, LIST_SEPARATOR_CHAR); 162 BIO_printf(bio_err, "-rand file%cfile%c... - seed PRNG from files\n", LIST_SEPARATOR_CHAR, LIST_SEPARATOR_CHAR);
155 BIO_printf(bio_err, "-base64 - encode output\n"); 163 BIO_printf(bio_err, "-base64 - encode output\n");
156 goto err; 164 goto err;
157 } 165 }
158 166
167#ifndef OPENSSL_NO_ENGINE
159 e = setup_engine(bio_err, engine, 0); 168 e = setup_engine(bio_err, engine, 0);
169#endif
160 170
161 app_RAND_load_file(NULL, bio_err, (inrand != NULL)); 171 app_RAND_load_file(NULL, bio_err, (inrand != NULL));
162 if (inrand != NULL) 172 if (inrand != NULL)
@@ -213,5 +223,5 @@ err:
213 if (out) 223 if (out)
214 BIO_free_all(out); 224 BIO_free_all(out);
215 apps_shutdown(); 225 apps_shutdown();
216 EXIT(ret); 226 OPENSSL_EXIT(ret);
217 } 227 }
diff --git a/src/lib/libssl/src/apps/req.c b/src/lib/libssl/src/apps/req.c
index a3c1e0b4c4..5f6ec3d339 100644
--- a/src/lib/libssl/src/apps/req.c
+++ b/src/lib/libssl/src/apps/req.c
@@ -73,6 +73,7 @@
73#include <openssl/x509v3.h> 73#include <openssl/x509v3.h>
74#include <openssl/objects.h> 74#include <openssl/objects.h>
75#include <openssl/pem.h> 75#include <openssl/pem.h>
76#include "../crypto/cryptlib.h"
76 77
77#define SECTION "req" 78#define SECTION "req"
78 79
@@ -134,7 +135,6 @@ static int req_check_len(int len,int n_min,int n_max);
134static int check_end(char *str, char *end); 135static int check_end(char *str, char *end);
135#ifndef MONOLITH 136#ifndef MONOLITH
136static char *default_config_file=NULL; 137static char *default_config_file=NULL;
137static CONF *config=NULL;
138#endif 138#endif
139static CONF *req_conf=NULL; 139static CONF *req_conf=NULL;
140static int batch=0; 140static int batch=0;
@@ -162,7 +162,9 @@ int MAIN(int argc, char **argv)
162 int informat,outformat,verify=0,noout=0,text=0,keyform=FORMAT_PEM; 162 int informat,outformat,verify=0,noout=0,text=0,keyform=FORMAT_PEM;
163 int nodes=0,kludge=0,newhdr=0,subject=0,pubkey=0; 163 int nodes=0,kludge=0,newhdr=0,subject=0,pubkey=0;
164 char *infile,*outfile,*prog,*keyfile=NULL,*template=NULL,*keyout=NULL; 164 char *infile,*outfile,*prog,*keyfile=NULL,*template=NULL,*keyout=NULL;
165#ifndef OPENSSL_NO_ENGINE
165 char *engine=NULL; 166 char *engine=NULL;
167#endif
166 char *extensions = NULL; 168 char *extensions = NULL;
167 char *req_exts = NULL; 169 char *req_exts = NULL;
168 const EVP_CIPHER *cipher=NULL; 170 const EVP_CIPHER *cipher=NULL;
@@ -176,7 +178,7 @@ int MAIN(int argc, char **argv)
176 const EVP_MD *md_alg=NULL,*digest=EVP_md5(); 178 const EVP_MD *md_alg=NULL,*digest=EVP_md5();
177 unsigned long chtype = MBSTRING_ASC; 179 unsigned long chtype = MBSTRING_ASC;
178#ifndef MONOLITH 180#ifndef MONOLITH
179 MS_STATIC char config_name[256]; 181 char *to_free;
180 long errline; 182 long errline;
181#endif 183#endif
182 184
@@ -210,11 +212,13 @@ int MAIN(int argc, char **argv)
210 if (--argc < 1) goto bad; 212 if (--argc < 1) goto bad;
211 outformat=str2fmt(*(++argv)); 213 outformat=str2fmt(*(++argv));
212 } 214 }
215#ifndef OPENSSL_NO_ENGINE
213 else if (strcmp(*argv,"-engine") == 0) 216 else if (strcmp(*argv,"-engine") == 0)
214 { 217 {
215 if (--argc < 1) goto bad; 218 if (--argc < 1) goto bad;
216 engine= *(++argv); 219 engine= *(++argv);
217 } 220 }
221#endif
218 else if (strcmp(*argv,"-key") == 0) 222 else if (strcmp(*argv,"-key") == 0)
219 { 223 {
220 if (--argc < 1) goto bad; 224 if (--argc < 1) goto bad;
@@ -428,7 +432,9 @@ bad:
428 BIO_printf(bio_err," -verify verify signature on REQ\n"); 432 BIO_printf(bio_err," -verify verify signature on REQ\n");
429 BIO_printf(bio_err," -modulus RSA modulus\n"); 433 BIO_printf(bio_err," -modulus RSA modulus\n");
430 BIO_printf(bio_err," -nodes don't encrypt the output key\n"); 434 BIO_printf(bio_err," -nodes don't encrypt the output key\n");
435#ifndef OPENSSL_NO_ENGINE
431 BIO_printf(bio_err," -engine e use engine e, possibly a hardware device\n"); 436 BIO_printf(bio_err," -engine e use engine e, possibly a hardware device\n");
437#endif
432 BIO_printf(bio_err," -subject output the request's subject\n"); 438 BIO_printf(bio_err," -subject output the request's subject\n");
433 BIO_printf(bio_err," -passin private key password source\n"); 439 BIO_printf(bio_err," -passin private key password source\n");
434 BIO_printf(bio_err," -key file use the private key contained in file\n"); 440 BIO_printf(bio_err," -key file use the private key contained in file\n");
@@ -453,7 +459,7 @@ bad:
453 BIO_printf(bio_err," -extensions .. specify certificate extension section (override value in config file)\n"); 459 BIO_printf(bio_err," -extensions .. specify certificate extension section (override value in config file)\n");
454 BIO_printf(bio_err," -reqexts .. specify request extension section (override value in config file)\n"); 460 BIO_printf(bio_err," -reqexts .. specify request extension section (override value in config file)\n");
455 BIO_printf(bio_err," -utf8 input characters are UTF8 (default ASCII)\n"); 461 BIO_printf(bio_err," -utf8 input characters are UTF8 (default ASCII)\n");
456 BIO_printf(bio_err," -nameopt arg - various certificate name options\n"); 462 BIO_printf(bio_err," -nameopt arg - various certificate name options\n");
457 BIO_printf(bio_err," -reqopt arg - various request text options\n\n"); 463 BIO_printf(bio_err," -reqopt arg - various request text options\n\n");
458 goto end; 464 goto end;
459 } 465 }
@@ -470,14 +476,7 @@ bad:
470 if (p == NULL) 476 if (p == NULL)
471 p=getenv("SSLEAY_CONF"); 477 p=getenv("SSLEAY_CONF");
472 if (p == NULL) 478 if (p == NULL)
473 { 479 p=to_free=make_config_name();
474 strcpy(config_name,X509_get_default_cert_area());
475#ifndef OPENSSL_SYS_VMS
476 strcat(config_name,"/");
477#endif
478 strcat(config_name,OPENSSL_CONF);
479 p=config_name;
480 }
481 default_config_file=p; 480 default_config_file=p;
482 config=NCONF_new(NULL); 481 config=NCONF_new(NULL);
483 i=NCONF_load(config, p, &errline); 482 i=NCONF_load(config, p, &errline);
@@ -485,7 +484,7 @@ bad:
485 484
486 if (template != NULL) 485 if (template != NULL)
487 { 486 {
488 long errline; 487 long errline = -1;
489 488
490 if( verbose ) 489 if( verbose )
491 BIO_printf(bio_err,"Using configuration from %s\n",template); 490 BIO_printf(bio_err,"Using configuration from %s\n",template);
@@ -624,7 +623,9 @@ bad:
624 if ((in == NULL) || (out == NULL)) 623 if ((in == NULL) || (out == NULL))
625 goto end; 624 goto end;
626 625
626#ifndef OPENSSL_NO_ENGINE
627 e = setup_engine(bio_err, engine, 0); 627 e = setup_engine(bio_err, engine, 0);
628#endif
628 629
629 if (keyfile != NULL) 630 if (keyfile != NULL)
630 { 631 {
@@ -1059,6 +1060,10 @@ loop:
1059 } 1060 }
1060 ex=0; 1061 ex=0;
1061end: 1062end:
1063#ifndef MONOLITH
1064 if(to_free)
1065 OPENSSL_free(to_free);
1066#endif
1062 if (ex) 1067 if (ex)
1063 { 1068 {
1064 ERR_print_errors(bio_err); 1069 ERR_print_errors(bio_err);
@@ -1077,7 +1082,7 @@ end:
1077 if (dsa_params != NULL) DSA_free(dsa_params); 1082 if (dsa_params != NULL) DSA_free(dsa_params);
1078#endif 1083#endif
1079 apps_shutdown(); 1084 apps_shutdown();
1080 EXIT(ex); 1085 OPENSSL_EXIT(ex);
1081 } 1086 }
1082 1087
1083static int make_REQ(X509_REQ *req, EVP_PKEY *pkey, char *subj, int attribs, 1088static int make_REQ(X509_REQ *req, EVP_PKEY *pkey, char *subj, int attribs,
@@ -1218,13 +1223,19 @@ start: for (;;)
1218 } 1223 }
1219 /* If OBJ not recognised ignore it */ 1224 /* If OBJ not recognised ignore it */
1220 if ((nid=OBJ_txt2nid(type)) == NID_undef) goto start; 1225 if ((nid=OBJ_txt2nid(type)) == NID_undef) goto start;
1226
1227 if(strlen(v->name) > sizeof buf-9)
1228 {
1229 BIO_printf(bio_err,"Name '%s' too long\n",v->name);
1230 return 0;
1231 }
1232
1221 sprintf(buf,"%s_default",v->name); 1233 sprintf(buf,"%s_default",v->name);
1222 if ((def=NCONF_get_string(req_conf,dn_sect,buf)) == NULL) 1234 if ((def=NCONF_get_string(req_conf,dn_sect,buf)) == NULL)
1223 { 1235 {
1224 ERR_clear_error(); 1236 ERR_clear_error();
1225 def=""; 1237 def="";
1226 } 1238 }
1227
1228 sprintf(buf,"%s_value",v->name); 1239 sprintf(buf,"%s_value",v->name);
1229 if ((value=NCONF_get_string(req_conf,dn_sect,buf)) == NULL) 1240 if ((value=NCONF_get_string(req_conf,dn_sect,buf)) == NULL)
1230 { 1241 {
@@ -1234,11 +1245,17 @@ start: for (;;)
1234 1245
1235 sprintf(buf,"%s_min",v->name); 1246 sprintf(buf,"%s_min",v->name);
1236 if (!NCONF_get_number(req_conf,dn_sect,buf, &n_min)) 1247 if (!NCONF_get_number(req_conf,dn_sect,buf, &n_min))
1248 {
1249 ERR_clear_error();
1237 n_min = -1; 1250 n_min = -1;
1251 }
1238 1252
1239 sprintf(buf,"%s_max",v->name); 1253 sprintf(buf,"%s_max",v->name);
1240 if (!NCONF_get_number(req_conf,dn_sect,buf, &n_max)) 1254 if (!NCONF_get_number(req_conf,dn_sect,buf, &n_max))
1255 {
1256 ERR_clear_error();
1241 n_max = -1; 1257 n_max = -1;
1258 }
1242 1259
1243 if (!add_DN_object(subj,v->value,def,value,nid, 1260 if (!add_DN_object(subj,v->value,def,value,nid,
1244 n_min,n_max, chtype)) 1261 n_min,n_max, chtype))
@@ -1271,6 +1288,12 @@ start2: for (;;)
1271 if ((nid=OBJ_txt2nid(type)) == NID_undef) 1288 if ((nid=OBJ_txt2nid(type)) == NID_undef)
1272 goto start2; 1289 goto start2;
1273 1290
1291 if(strlen(v->name) > sizeof buf-9)
1292 {
1293 BIO_printf(bio_err,"Name '%s' too long\n",v->name);
1294 return 0;
1295 }
1296
1274 sprintf(buf,"%s_default",type); 1297 sprintf(buf,"%s_default",type);
1275 if ((def=NCONF_get_string(req_conf,attr_sect,buf)) 1298 if ((def=NCONF_get_string(req_conf,attr_sect,buf))
1276 == NULL) 1299 == NULL)
@@ -1374,6 +1397,7 @@ start:
1374 (void)BIO_flush(bio_err); 1397 (void)BIO_flush(bio_err);
1375 if(value != NULL) 1398 if(value != NULL)
1376 { 1399 {
1400 OPENSSL_assert(strlen(value) < sizeof buf-2);
1377 strcpy(buf,value); 1401 strcpy(buf,value);
1378 strcat(buf,"\n"); 1402 strcat(buf,"\n");
1379 BIO_printf(bio_err,"%s\n",value); 1403 BIO_printf(bio_err,"%s\n",value);
@@ -1383,7 +1407,7 @@ start:
1383 buf[0]='\0'; 1407 buf[0]='\0';
1384 if (!batch) 1408 if (!batch)
1385 { 1409 {
1386 fgets(buf,1024,stdin); 1410 fgets(buf,sizeof buf,stdin);
1387 } 1411 }
1388 else 1412 else
1389 { 1413 {
@@ -1432,6 +1456,7 @@ start:
1432 (void)BIO_flush(bio_err); 1456 (void)BIO_flush(bio_err);
1433 if (value != NULL) 1457 if (value != NULL)
1434 { 1458 {
1459 OPENSSL_assert(strlen(value) < sizeof buf-2);
1435 strcpy(buf,value); 1460 strcpy(buf,value);
1436 strcat(buf,"\n"); 1461 strcat(buf,"\n");
1437 BIO_printf(bio_err,"%s\n",value); 1462 BIO_printf(bio_err,"%s\n",value);
@@ -1441,7 +1466,7 @@ start:
1441 buf[0]='\0'; 1466 buf[0]='\0';
1442 if (!batch) 1467 if (!batch)
1443 { 1468 {
1444 fgets(buf,1024,stdin); 1469 fgets(buf,sizeof buf,stdin);
1445 } 1470 }
1446 else 1471 else
1447 { 1472 {
diff --git a/src/lib/libssl/src/apps/rsa.c b/src/lib/libssl/src/apps/rsa.c
index 4e19bc16fb..0acdb08b24 100644
--- a/src/lib/libssl/src/apps/rsa.c
+++ b/src/lib/libssl/src/apps/rsa.c
@@ -104,7 +104,9 @@ int MAIN(int argc, char **argv)
104 char *infile,*outfile,*prog; 104 char *infile,*outfile,*prog;
105 char *passargin = NULL, *passargout = NULL; 105 char *passargin = NULL, *passargout = NULL;
106 char *passin = NULL, *passout = NULL; 106 char *passin = NULL, *passout = NULL;
107#ifndef OPENSSL_NO_ENGINE
107 char *engine=NULL; 108 char *engine=NULL;
109#endif
108 int modulus=0; 110 int modulus=0;
109 111
110 apps_startup(); 112 apps_startup();
@@ -156,11 +158,13 @@ int MAIN(int argc, char **argv)
156 if (--argc < 1) goto bad; 158 if (--argc < 1) goto bad;
157 passargout= *(++argv); 159 passargout= *(++argv);
158 } 160 }
161#ifndef OPENSSL_NO_ENGINE
159 else if (strcmp(*argv,"-engine") == 0) 162 else if (strcmp(*argv,"-engine") == 0)
160 { 163 {
161 if (--argc < 1) goto bad; 164 if (--argc < 1) goto bad;
162 engine= *(++argv); 165 engine= *(++argv);
163 } 166 }
167#endif
164 else if (strcmp(*argv,"-sgckey") == 0) 168 else if (strcmp(*argv,"-sgckey") == 0)
165 sgckey=1; 169 sgckey=1;
166 else if (strcmp(*argv,"-pubin") == 0) 170 else if (strcmp(*argv,"-pubin") == 0)
@@ -212,13 +216,17 @@ bad:
212 BIO_printf(bio_err," -check verify key consistency\n"); 216 BIO_printf(bio_err," -check verify key consistency\n");
213 BIO_printf(bio_err," -pubin expect a public key in input file\n"); 217 BIO_printf(bio_err," -pubin expect a public key in input file\n");
214 BIO_printf(bio_err," -pubout output a public key\n"); 218 BIO_printf(bio_err," -pubout output a public key\n");
219#ifndef OPENSSL_NO_ENGINE
215 BIO_printf(bio_err," -engine e use engine e, possibly a hardware device.\n"); 220 BIO_printf(bio_err," -engine e use engine e, possibly a hardware device.\n");
221#endif
216 goto end; 222 goto end;
217 } 223 }
218 224
219 ERR_load_crypto_strings(); 225 ERR_load_crypto_strings();
220 226
227#ifndef OPENSSL_NO_ENGINE
221 e = setup_engine(bio_err, engine, 0); 228 e = setup_engine(bio_err, engine, 0);
229#endif
222 230
223 if(!app_passwd(bio_err, passargin, passargout, &passin, &passout)) { 231 if(!app_passwd(bio_err, passargin, passargout, &passin, &passout)) {
224 BIO_printf(bio_err, "Error getting passwords\n"); 232 BIO_printf(bio_err, "Error getting passwords\n");
@@ -369,7 +377,7 @@ end:
369 if(passin) OPENSSL_free(passin); 377 if(passin) OPENSSL_free(passin);
370 if(passout) OPENSSL_free(passout); 378 if(passout) OPENSSL_free(passout);
371 apps_shutdown(); 379 apps_shutdown();
372 EXIT(ret); 380 OPENSSL_EXIT(ret);
373 } 381 }
374#else /* !OPENSSL_NO_RSA */ 382#else /* !OPENSSL_NO_RSA */
375 383
diff --git a/src/lib/libssl/src/apps/rsautl.c b/src/lib/libssl/src/apps/rsautl.c
index 36957e5b84..5a6fd115f4 100644
--- a/src/lib/libssl/src/apps/rsautl.c
+++ b/src/lib/libssl/src/apps/rsautl.c
@@ -85,7 +85,9 @@ int MAIN(int argc, char **argv)
85 ENGINE *e = NULL; 85 ENGINE *e = NULL;
86 BIO *in = NULL, *out = NULL; 86 BIO *in = NULL, *out = NULL;
87 char *infile = NULL, *outfile = NULL; 87 char *infile = NULL, *outfile = NULL;
88#ifndef OPENSSL_NO_ENGINE
88 char *engine = NULL; 89 char *engine = NULL;
90#endif
89 char *keyfile = NULL; 91 char *keyfile = NULL;
90 char rsa_mode = RSA_VERIFY, key_type = KEY_PRIVKEY; 92 char rsa_mode = RSA_VERIFY, key_type = KEY_PRIVKEY;
91 int keyform = FORMAT_PEM; 93 int keyform = FORMAT_PEM;
@@ -125,9 +127,11 @@ int MAIN(int argc, char **argv)
125 } else if (strcmp(*argv,"-keyform") == 0) { 127 } else if (strcmp(*argv,"-keyform") == 0) {
126 if (--argc < 1) badarg = 1; 128 if (--argc < 1) badarg = 1;
127 keyform=str2fmt(*(++argv)); 129 keyform=str2fmt(*(++argv));
130#ifndef OPENSSL_NO_ENGINE
128 } else if(!strcmp(*argv, "-engine")) { 131 } else if(!strcmp(*argv, "-engine")) {
129 if (--argc < 1) badarg = 1; 132 if (--argc < 1) badarg = 1;
130 engine = *(++argv); 133 engine = *(++argv);
134#endif
131 } else if(!strcmp(*argv, "-pubin")) { 135 } else if(!strcmp(*argv, "-pubin")) {
132 key_type = KEY_PUBKEY; 136 key_type = KEY_PUBKEY;
133 } else if(!strcmp(*argv, "-certin")) { 137 } else if(!strcmp(*argv, "-certin")) {
@@ -162,7 +166,9 @@ int MAIN(int argc, char **argv)
162 goto end; 166 goto end;
163 } 167 }
164 168
169#ifndef OPENSSL_NO_ENGINE
165 e = setup_engine(bio_err, engine, 0); 170 e = setup_engine(bio_err, engine, 0);
171#endif
166 172
167/* FIXME: seed PRNG only if needed */ 173/* FIXME: seed PRNG only if needed */
168 app_RAND_load_file(NULL, bio_err, 0); 174 app_RAND_load_file(NULL, bio_err, 0);
@@ -305,7 +311,9 @@ static void usage()
305 BIO_printf(bio_err, "-encrypt encrypt with public key\n"); 311 BIO_printf(bio_err, "-encrypt encrypt with public key\n");
306 BIO_printf(bio_err, "-decrypt decrypt with private key\n"); 312 BIO_printf(bio_err, "-decrypt decrypt with private key\n");
307 BIO_printf(bio_err, "-hexdump hex dump output\n"); 313 BIO_printf(bio_err, "-hexdump hex dump output\n");
314#ifndef OPENSSL_NO_ENGINE
308 BIO_printf(bio_err, "-engine e use engine e, possibly a hardware device.\n"); 315 BIO_printf(bio_err, "-engine e use engine e, possibly a hardware device.\n");
316#endif
309 317
310} 318}
311 319
diff --git a/src/lib/libssl/src/apps/s_cb.c b/src/lib/libssl/src/apps/s_cb.c
index ca5b24548c..675527df1f 100644
--- a/src/lib/libssl/src/apps/s_cb.c
+++ b/src/lib/libssl/src/apps/s_cb.c
@@ -134,7 +134,7 @@ int MS_CALLBACK verify_callback(int ok, X509_STORE_CTX *ctx)
134 err= X509_STORE_CTX_get_error(ctx); 134 err= X509_STORE_CTX_get_error(ctx);
135 depth= X509_STORE_CTX_get_error_depth(ctx); 135 depth= X509_STORE_CTX_get_error_depth(ctx);
136 136
137 X509_NAME_oneline(X509_get_subject_name(err_cert),buf,256); 137 X509_NAME_oneline(X509_get_subject_name(err_cert),buf,sizeof buf);
138 BIO_printf(bio_err,"depth=%d %s\n",depth,buf); 138 BIO_printf(bio_err,"depth=%d %s\n",depth,buf);
139 if (!ok) 139 if (!ok)
140 { 140 {
@@ -154,7 +154,7 @@ int MS_CALLBACK verify_callback(int ok, X509_STORE_CTX *ctx)
154 switch (ctx->error) 154 switch (ctx->error)
155 { 155 {
156 case X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT: 156 case X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT:
157 X509_NAME_oneline(X509_get_issuer_name(ctx->current_cert),buf,256); 157 X509_NAME_oneline(X509_get_issuer_name(ctx->current_cert),buf,sizeof buf);
158 BIO_printf(bio_err,"issuer= %s\n",buf); 158 BIO_printf(bio_err,"issuer= %s\n",buf);
159 break; 159 break;
160 case X509_V_ERR_CERT_NOT_YET_VALID: 160 case X509_V_ERR_CERT_NOT_YET_VALID:
diff --git a/src/lib/libssl/src/apps/s_client.c b/src/lib/libssl/src/apps/s_client.c
index 658a79d390..2e73f34676 100644
--- a/src/lib/libssl/src/apps/s_client.c
+++ b/src/lib/libssl/src/apps/s_client.c
@@ -140,6 +140,14 @@ typedef unsigned int u_int;
140#include <conio.h> 140#include <conio.h>
141#endif 141#endif
142 142
143#ifdef OPENSSL_SYS_WINCE
144/* Windows CE incorrectly defines fileno as returning void*, so to avoid problems below... */
145#ifdef fileno
146#undef fileno
147#endif
148#define fileno(a) (int)_fileno(a)
149#endif
150
143 151
144#if (defined(OPENSSL_SYS_VMS) && __VMS_VER < 70000000) 152#if (defined(OPENSSL_SYS_VMS) && __VMS_VER < 70000000)
145/* FIONBIO used as a switch to enable ioctl, and that isn't in VMS < 7.0 */ 153/* FIONBIO used as a switch to enable ioctl, and that isn't in VMS < 7.0 */
@@ -214,7 +222,9 @@ static void sc_usage(void)
214 BIO_printf(bio_err," for those protocols that support it, where\n"); 222 BIO_printf(bio_err," for those protocols that support it, where\n");
215 BIO_printf(bio_err," 'prot' defines which one to assume. Currently,\n"); 223 BIO_printf(bio_err," 'prot' defines which one to assume. Currently,\n");
216 BIO_printf(bio_err," only \"smtp\" is supported.\n"); 224 BIO_printf(bio_err," only \"smtp\" is supported.\n");
225#ifndef OPENSSL_NO_ENGINE
217 BIO_printf(bio_err," -engine id - Initialise and use the specified engine\n"); 226 BIO_printf(bio_err," -engine id - Initialise and use the specified engine\n");
227#endif
218 BIO_printf(bio_err," -rand file%cfile%c...\n", LIST_SEPARATOR_CHAR, LIST_SEPARATOR_CHAR); 228 BIO_printf(bio_err," -rand file%cfile%c...\n", LIST_SEPARATOR_CHAR, LIST_SEPARATOR_CHAR);
219 229
220 } 230 }
@@ -246,8 +256,10 @@ int MAIN(int argc, char **argv)
246 SSL_METHOD *meth=NULL; 256 SSL_METHOD *meth=NULL;
247 BIO *sbio; 257 BIO *sbio;
248 char *inrand=NULL; 258 char *inrand=NULL;
259#ifndef OPENSSL_NO_ENGINE
249 char *engine_id=NULL; 260 char *engine_id=NULL;
250 ENGINE *e=NULL; 261 ENGINE *e=NULL;
262#endif
251#ifdef OPENSSL_SYS_WINDOWS 263#ifdef OPENSSL_SYS_WINDOWS
252 struct timeval tv; 264 struct timeval tv;
253#endif 265#endif
@@ -407,11 +419,13 @@ int MAIN(int argc, char **argv)
407 else 419 else
408 goto bad; 420 goto bad;
409 } 421 }
422#ifndef OPENSSL_NO_ENGINE
410 else if (strcmp(*argv,"-engine") == 0) 423 else if (strcmp(*argv,"-engine") == 0)
411 { 424 {
412 if (--argc < 1) goto bad; 425 if (--argc < 1) goto bad;
413 engine_id = *(++argv); 426 engine_id = *(++argv);
414 } 427 }
428#endif
415 else if (strcmp(*argv,"-rand") == 0) 429 else if (strcmp(*argv,"-rand") == 0)
416 { 430 {
417 if (--argc < 1) goto bad; 431 if (--argc < 1) goto bad;
@@ -436,7 +450,9 @@ bad:
436 OpenSSL_add_ssl_algorithms(); 450 OpenSSL_add_ssl_algorithms();
437 SSL_load_error_strings(); 451 SSL_load_error_strings();
438 452
453#ifndef OPENSSL_NO_ENGINE
439 e = setup_engine(bio_err, engine_id, 1); 454 e = setup_engine(bio_err, engine_id, 1);
455#endif
440 456
441 if (!app_RAND_load_file(NULL, bio_err, 1) && inrand == NULL 457 if (!app_RAND_load_file(NULL, bio_err, 1) && inrand == NULL
442 && !RAND_status()) 458 && !RAND_status())
@@ -662,7 +678,11 @@ re_start:
662 tv.tv_usec = 0; 678 tv.tv_usec = 0;
663 i=select(width,(void *)&readfds,(void *)&writefds, 679 i=select(width,(void *)&readfds,(void *)&writefds,
664 NULL,&tv); 680 NULL,&tv);
681#ifdef OPENSSL_SYS_WINCE
682 if(!i && (!_kbhit() || !read_tty) ) continue;
683#else
665 if(!i && (!((_kbhit()) || (WAIT_OBJECT_0 == WaitForSingleObject(GetStdHandle(STD_INPUT_HANDLE), 0))) || !read_tty) ) continue; 684 if(!i && (!((_kbhit()) || (WAIT_OBJECT_0 == WaitForSingleObject(GetStdHandle(STD_INPUT_HANDLE), 0))) || !read_tty) ) continue;
685#endif
666 } else i=select(width,(void *)&readfds,(void *)&writefds, 686 } else i=select(width,(void *)&readfds,(void *)&writefds,
667 NULL,NULL); 687 NULL,NULL);
668 } 688 }
@@ -746,8 +766,8 @@ re_start:
746 goto shut; 766 goto shut;
747 } 767 }
748 } 768 }
749#ifdef OPENSSL_SYS_WINDOWS 769#if defined(OPENSSL_SYS_WINDOWS) || defined(OPENSSL_SYS_MSDOS)
750 /* Assume Windows can always write */ 770 /* Assume Windows/DOS can always write */
751 else if (!ssl_pending && write_tty) 771 else if (!ssl_pending && write_tty)
752#else 772#else
753 else if (!ssl_pending && FD_ISSET(fileno(stdout),&writefds)) 773 else if (!ssl_pending && FD_ISSET(fileno(stdout),&writefds))
@@ -828,7 +848,11 @@ printf("read=%d pending=%d peek=%d\n",k,SSL_pending(con),SSL_peek(con,zbuf,10240
828 } 848 }
829 849
830#ifdef OPENSSL_SYS_WINDOWS 850#ifdef OPENSSL_SYS_WINDOWS
851#ifdef OPENSSL_SYS_WINCE
852 else if (_kbhit())
853#else
831 else if ((_kbhit()) || (WAIT_OBJECT_0 == WaitForSingleObject(GetStdHandle(STD_INPUT_HANDLE), 0))) 854 else if ((_kbhit()) || (WAIT_OBJECT_0 == WaitForSingleObject(GetStdHandle(STD_INPUT_HANDLE), 0)))
855#endif
832#else 856#else
833 else if (FD_ISSET(fileno(stdin),&readfds)) 857 else if (FD_ISSET(fileno(stdin),&readfds))
834#endif 858#endif
@@ -892,16 +916,16 @@ end:
892 if (con != NULL) SSL_free(con); 916 if (con != NULL) SSL_free(con);
893 if (con2 != NULL) SSL_free(con2); 917 if (con2 != NULL) SSL_free(con2);
894 if (ctx != NULL) SSL_CTX_free(ctx); 918 if (ctx != NULL) SSL_CTX_free(ctx);
895 if (cbuf != NULL) { memset(cbuf,0,BUFSIZZ); OPENSSL_free(cbuf); } 919 if (cbuf != NULL) { OPENSSL_cleanse(cbuf,BUFSIZZ); OPENSSL_free(cbuf); }
896 if (sbuf != NULL) { memset(sbuf,0,BUFSIZZ); OPENSSL_free(sbuf); } 920 if (sbuf != NULL) { OPENSSL_cleanse(sbuf,BUFSIZZ); OPENSSL_free(sbuf); }
897 if (mbuf != NULL) { memset(mbuf,0,BUFSIZZ); OPENSSL_free(mbuf); } 921 if (mbuf != NULL) { OPENSSL_cleanse(mbuf,BUFSIZZ); OPENSSL_free(mbuf); }
898 if (bio_c_out != NULL) 922 if (bio_c_out != NULL)
899 { 923 {
900 BIO_free(bio_c_out); 924 BIO_free(bio_c_out);
901 bio_c_out=NULL; 925 bio_c_out=NULL;
902 } 926 }
903 apps_shutdown(); 927 apps_shutdown();
904 EXIT(ret); 928 OPENSSL_EXIT(ret);
905 } 929 }
906 930
907 931
@@ -930,10 +954,10 @@ static void print_stuff(BIO *bio, SSL *s, int full)
930 for (i=0; i<sk_X509_num(sk); i++) 954 for (i=0; i<sk_X509_num(sk); i++)
931 { 955 {
932 X509_NAME_oneline(X509_get_subject_name( 956 X509_NAME_oneline(X509_get_subject_name(
933 sk_X509_value(sk,i)),buf,BUFSIZ); 957 sk_X509_value(sk,i)),buf,sizeof buf);
934 BIO_printf(bio,"%2d s:%s\n",i,buf); 958 BIO_printf(bio,"%2d s:%s\n",i,buf);
935 X509_NAME_oneline(X509_get_issuer_name( 959 X509_NAME_oneline(X509_get_issuer_name(
936 sk_X509_value(sk,i)),buf,BUFSIZ); 960 sk_X509_value(sk,i)),buf,sizeof buf);
937 BIO_printf(bio," i:%s\n",buf); 961 BIO_printf(bio," i:%s\n",buf);
938 if (c_showcerts) 962 if (c_showcerts)
939 PEM_write_bio_X509(bio,sk_X509_value(sk,i)); 963 PEM_write_bio_X509(bio,sk_X509_value(sk,i));
@@ -948,10 +972,10 @@ static void print_stuff(BIO *bio, SSL *s, int full)
948 if (!(c_showcerts && got_a_chain)) /* Redundant if we showed the whole chain */ 972 if (!(c_showcerts && got_a_chain)) /* Redundant if we showed the whole chain */
949 PEM_write_bio_X509(bio,peer); 973 PEM_write_bio_X509(bio,peer);
950 X509_NAME_oneline(X509_get_subject_name(peer), 974 X509_NAME_oneline(X509_get_subject_name(peer),
951 buf,BUFSIZ); 975 buf,sizeof buf);
952 BIO_printf(bio,"subject=%s\n",buf); 976 BIO_printf(bio,"subject=%s\n",buf);
953 X509_NAME_oneline(X509_get_issuer_name(peer), 977 X509_NAME_oneline(X509_get_issuer_name(peer),
954 buf,BUFSIZ); 978 buf,sizeof buf);
955 BIO_printf(bio,"issuer=%s\n",buf); 979 BIO_printf(bio,"issuer=%s\n",buf);
956 } 980 }
957 else 981 else
@@ -973,7 +997,7 @@ static void print_stuff(BIO *bio, SSL *s, int full)
973 { 997 {
974 BIO_printf(bio,"---\nNo client certificate CA names sent\n"); 998 BIO_printf(bio,"---\nNo client certificate CA names sent\n");
975 } 999 }
976 p=SSL_get_shared_ciphers(s,buf,BUFSIZ); 1000 p=SSL_get_shared_ciphers(s,buf,sizeof buf);
977 if (p != NULL) 1001 if (p != NULL)
978 { 1002 {
979 /* This works only for SSL 2. In later protocol 1003 /* This works only for SSL 2. In later protocol
diff --git a/src/lib/libssl/src/apps/s_server.c b/src/lib/libssl/src/apps/s_server.c
index b03231f3ba..5157aae4d1 100644
--- a/src/lib/libssl/src/apps/s_server.c
+++ b/src/lib/libssl/src/apps/s_server.c
@@ -144,6 +144,14 @@ typedef unsigned int u_int;
144#include <conio.h> 144#include <conio.h>
145#endif 145#endif
146 146
147#ifdef OPENSSL_SYS_WINCE
148/* Windows CE incorrectly defines fileno as returning void*, so to avoid problems below... */
149#ifdef fileno
150#undef fileno
151#endif
152#define fileno(a) (int)_fileno(a)
153#endif
154
147#if (defined(OPENSSL_SYS_VMS) && __VMS_VER < 70000000) 155#if (defined(OPENSSL_SYS_VMS) && __VMS_VER < 70000000)
148/* FIONBIO used as a switch to enable ioctl, and that isn't in VMS < 7.0 */ 156/* FIONBIO used as a switch to enable ioctl, and that isn't in VMS < 7.0 */
149#undef FIONBIO 157#undef FIONBIO
@@ -234,7 +242,9 @@ static int s_msg=0;
234static int s_quiet=0; 242static int s_quiet=0;
235 243
236static int hack=0; 244static int hack=0;
245#ifndef OPENSSL_NO_ENGINE
237static char *engine_id=NULL; 246static char *engine_id=NULL;
247#endif
238static const char *session_id_prefix=NULL; 248static const char *session_id_prefix=NULL;
239 249
240#ifdef MONOLITH 250#ifdef MONOLITH
@@ -259,7 +269,9 @@ static void s_server_init(void)
259 s_msg=0; 269 s_msg=0;
260 s_quiet=0; 270 s_quiet=0;
261 hack=0; 271 hack=0;
272#ifndef OPENSSL_NO_ENGINE
262 engine_id=NULL; 273 engine_id=NULL;
274#endif
263 } 275 }
264#endif 276#endif
265 277
@@ -308,7 +320,9 @@ static void sv_usage(void)
308 BIO_printf(bio_err," -WWW - Respond to a 'GET /<path> HTTP/1.0' with file ./<path>\n"); 320 BIO_printf(bio_err," -WWW - Respond to a 'GET /<path> HTTP/1.0' with file ./<path>\n");
309 BIO_printf(bio_err," -HTTP - Respond to a 'GET /<path> HTTP/1.0' with file ./<path>\n"); 321 BIO_printf(bio_err," -HTTP - Respond to a 'GET /<path> HTTP/1.0' with file ./<path>\n");
310 BIO_printf(bio_err," with the assumption it contains a complete HTTP response.\n"); 322 BIO_printf(bio_err," with the assumption it contains a complete HTTP response.\n");
323#ifndef OPENSSL_NO_ENGINE
311 BIO_printf(bio_err," -engine id - Initialise and use the specified engine\n"); 324 BIO_printf(bio_err," -engine id - Initialise and use the specified engine\n");
325#endif
312 BIO_printf(bio_err," -id_prefix arg - Generate SSL/TLS session IDs prefixed by 'arg'\n"); 326 BIO_printf(bio_err," -id_prefix arg - Generate SSL/TLS session IDs prefixed by 'arg'\n");
313 BIO_printf(bio_err," -rand file%cfile%c...\n", LIST_SEPARATOR_CHAR, LIST_SEPARATOR_CHAR); 327 BIO_printf(bio_err," -rand file%cfile%c...\n", LIST_SEPARATOR_CHAR, LIST_SEPARATOR_CHAR);
314 } 328 }
@@ -482,7 +496,9 @@ int MAIN(int argc, char *argv[])
482 int no_tmp_rsa=0,no_dhe=0,nocert=0; 496 int no_tmp_rsa=0,no_dhe=0,nocert=0;
483 int state=0; 497 int state=0;
484 SSL_METHOD *meth=NULL; 498 SSL_METHOD *meth=NULL;
499#ifndef OPENSSL_NO_ENGINE
485 ENGINE *e=NULL; 500 ENGINE *e=NULL;
501#endif
486 char *inrand=NULL; 502 char *inrand=NULL;
487 503
488#if !defined(OPENSSL_NO_SSL2) && !defined(OPENSSL_NO_SSL3) 504#if !defined(OPENSSL_NO_SSL2) && !defined(OPENSSL_NO_SSL3)
@@ -657,11 +673,13 @@ int MAIN(int argc, char *argv[])
657 if (--argc < 1) goto bad; 673 if (--argc < 1) goto bad;
658 session_id_prefix = *(++argv); 674 session_id_prefix = *(++argv);
659 } 675 }
676#ifndef OPENSSL_NO_ENGINE
660 else if (strcmp(*argv,"-engine") == 0) 677 else if (strcmp(*argv,"-engine") == 0)
661 { 678 {
662 if (--argc < 1) goto bad; 679 if (--argc < 1) goto bad;
663 engine_id= *(++argv); 680 engine_id= *(++argv);
664 } 681 }
682#endif
665 else if (strcmp(*argv,"-rand") == 0) 683 else if (strcmp(*argv,"-rand") == 0)
666 { 684 {
667 if (--argc < 1) goto bad; 685 if (--argc < 1) goto bad;
@@ -686,7 +704,9 @@ bad:
686 SSL_load_error_strings(); 704 SSL_load_error_strings();
687 OpenSSL_add_ssl_algorithms(); 705 OpenSSL_add_ssl_algorithms();
688 706
707#ifndef OPENSSL_NO_ENGINE
689 e = setup_engine(bio_err, engine_id, 1); 708 e = setup_engine(bio_err, engine_id, 1);
709#endif
690 710
691 if (!app_RAND_load_file(NULL, bio_err, 1) && inrand == NULL 711 if (!app_RAND_load_file(NULL, bio_err, 1) && inrand == NULL
692 && !RAND_status()) 712 && !RAND_status())
@@ -860,7 +880,7 @@ end:
860 bio_s_out=NULL; 880 bio_s_out=NULL;
861 } 881 }
862 apps_shutdown(); 882 apps_shutdown();
863 EXIT(ret); 883 OPENSSL_EXIT(ret);
864 } 884 }
865 885
866static void print_stats(BIO *bio, SSL_CTX *ssl_ctx) 886static void print_stats(BIO *bio, SSL_CTX *ssl_ctx)
@@ -1176,7 +1196,7 @@ err:
1176 BIO_printf(bio_s_out,"CONNECTION CLOSED\n"); 1196 BIO_printf(bio_s_out,"CONNECTION CLOSED\n");
1177 if (buf != NULL) 1197 if (buf != NULL)
1178 { 1198 {
1179 memset(buf,0,bufsize); 1199 OPENSSL_cleanse(buf,bufsize);
1180 OPENSSL_free(buf); 1200 OPENSSL_free(buf);
1181 } 1201 }
1182 if (ret >= 0) 1202 if (ret >= 0)
@@ -1228,14 +1248,14 @@ static int init_ssl_connection(SSL *con)
1228 { 1248 {
1229 BIO_printf(bio_s_out,"Client certificate\n"); 1249 BIO_printf(bio_s_out,"Client certificate\n");
1230 PEM_write_bio_X509(bio_s_out,peer); 1250 PEM_write_bio_X509(bio_s_out,peer);
1231 X509_NAME_oneline(X509_get_subject_name(peer),buf,BUFSIZ); 1251 X509_NAME_oneline(X509_get_subject_name(peer),buf,sizeof buf);
1232 BIO_printf(bio_s_out,"subject=%s\n",buf); 1252 BIO_printf(bio_s_out,"subject=%s\n",buf);
1233 X509_NAME_oneline(X509_get_issuer_name(peer),buf,BUFSIZ); 1253 X509_NAME_oneline(X509_get_issuer_name(peer),buf,sizeof buf);
1234 BIO_printf(bio_s_out,"issuer=%s\n",buf); 1254 BIO_printf(bio_s_out,"issuer=%s\n",buf);
1235 X509_free(peer); 1255 X509_free(peer);
1236 } 1256 }
1237 1257
1238 if (SSL_get_shared_ciphers(con,buf,BUFSIZ) != NULL) 1258 if (SSL_get_shared_ciphers(con,buf,sizeof buf) != NULL)
1239 BIO_printf(bio_s_out,"Shared ciphers:%s\n",buf); 1259 BIO_printf(bio_s_out,"Shared ciphers:%s\n",buf);
1240 str=SSL_CIPHER_get_name(SSL_get_current_cipher(con)); 1260 str=SSL_CIPHER_get_name(SSL_get_current_cipher(con));
1241 BIO_printf(bio_s_out,"CIPHER is %s\n",(str != NULL)?str:"(NONE)"); 1261 BIO_printf(bio_s_out,"CIPHER is %s\n",(str != NULL)?str:"(NONE)");
@@ -1395,7 +1415,7 @@ static int www_body(char *hostname, int s, unsigned char *context)
1395 else 1415 else
1396 { 1416 {
1397 BIO_printf(bio_s_out,"read R BLOCK\n"); 1417 BIO_printf(bio_s_out,"read R BLOCK\n");
1398#ifndef OPENSSL_SYS_MSDOS 1418#if !defined(OPENSSL_SYS_MSDOS) && !defined(__DJGPP__)
1399 sleep(1); 1419 sleep(1);
1400#endif 1420#endif
1401 continue; 1421 continue;
diff --git a/src/lib/libssl/src/apps/s_socket.c b/src/lib/libssl/src/apps/s_socket.c
index bd499d020c..a88de6c8c8 100644
--- a/src/lib/libssl/src/apps/s_socket.c
+++ b/src/lib/libssl/src/apps/s_socket.c
@@ -83,9 +83,9 @@ typedef unsigned int u_int;
83 83
84static struct hostent *GetHostByName(char *name); 84static struct hostent *GetHostByName(char *name);
85#ifdef OPENSSL_SYS_WINDOWS 85#ifdef OPENSSL_SYS_WINDOWS
86static void sock_cleanup(void); 86static void ssl_sock_cleanup(void);
87#endif 87#endif
88static int sock_init(void); 88static int ssl_sock_init(void);
89static int init_client_ip(int *sock,unsigned char ip[4], int port); 89static int init_client_ip(int *sock,unsigned char ip[4], int port);
90static int init_server(int *sock, int port); 90static int init_server(int *sock, int port);
91static int init_server_long(int *sock, int port,char *ip); 91static int init_server_long(int *sock, int port,char *ip);
@@ -118,7 +118,7 @@ static LONG FAR PASCAL topHookProc(HWND hwnd, UINT message, WPARAM wParam,
118 case WM_DESTROY: 118 case WM_DESTROY:
119 case WM_CLOSE: 119 case WM_CLOSE:
120 SetWindowLong(topWnd,GWL_WNDPROC,(LONG)lpTopWndProc); 120 SetWindowLong(topWnd,GWL_WNDPROC,(LONG)lpTopWndProc);
121 sock_cleanup(); 121 ssl_sock_cleanup();
122 break; 122 break;
123 } 123 }
124 } 124 }
@@ -135,26 +135,34 @@ static BOOL CALLBACK enumproc(HWND hwnd,LPARAM lParam)
135#endif /* OPENSSL_SYS_WINDOWS */ 135#endif /* OPENSSL_SYS_WINDOWS */
136 136
137#ifdef OPENSSL_SYS_WINDOWS 137#ifdef OPENSSL_SYS_WINDOWS
138static void sock_cleanup(void) 138static void ssl_sock_cleanup(void)
139 { 139 {
140 if (wsa_init_done) 140 if (wsa_init_done)
141 { 141 {
142 wsa_init_done=0; 142 wsa_init_done=0;
143#ifndef OPENSSL_SYS_WINCE
143 WSACancelBlockingCall(); 144 WSACancelBlockingCall();
145#endif
144 WSACleanup(); 146 WSACleanup();
145 } 147 }
146 } 148 }
147#endif 149#endif
148 150
149static int sock_init(void) 151static int ssl_sock_init(void)
150 { 152 {
151#ifdef OPENSSL_SYS_WINDOWS 153#ifdef WATT32
154 extern int _watt_do_exit;
155 _watt_do_exit = 0;
156 dbug_init();
157 if (sock_init())
158 return (0);
159#elif defined(OPENSSL_SYS_WINDOWS)
152 if (!wsa_init_done) 160 if (!wsa_init_done)
153 { 161 {
154 int err; 162 int err;
155 163
156#ifdef SIGINT 164#ifdef SIGINT
157 signal(SIGINT,(void (*)(int))sock_cleanup); 165 signal(SIGINT,(void (*)(int))ssl_sock_cleanup);
158#endif 166#endif
159 wsa_init_done=1; 167 wsa_init_done=1;
160 memset(&wsa_state,0,sizeof(wsa_state)); 168 memset(&wsa_state,0,sizeof(wsa_state));
@@ -196,7 +204,7 @@ static int init_client_ip(int *sock, unsigned char ip[4], int port)
196 struct sockaddr_in them; 204 struct sockaddr_in them;
197 int s,i; 205 int s,i;
198 206
199 if (!sock_init()) return(0); 207 if (!ssl_sock_init()) return(0);
200 208
201 memset((char *)&them,0,sizeof(them)); 209 memset((char *)&them,0,sizeof(them));
202 them.sin_family=AF_INET; 210 them.sin_family=AF_INET;
@@ -261,7 +269,7 @@ static int init_server_long(int *sock, int port, char *ip)
261 struct sockaddr_in server; 269 struct sockaddr_in server;
262 int s= -1,i; 270 int s= -1,i;
263 271
264 if (!sock_init()) return(0); 272 if (!ssl_sock_init()) return(0);
265 273
266 memset((char *)&server,0,sizeof(server)); 274 memset((char *)&server,0,sizeof(server));
267 server.sin_family=AF_INET; 275 server.sin_family=AF_INET;
@@ -318,7 +326,7 @@ static int do_accept(int acc_sock, int *sock, char **host)
318 int len; 326 int len;
319/* struct linger ling; */ 327/* struct linger ling; */
320 328
321 if (!sock_init()) return(0); 329 if (!ssl_sock_init()) return(0);
322 330
323#ifndef OPENSSL_SYS_WINDOWS 331#ifndef OPENSSL_SYS_WINDOWS
324redoit: 332redoit:
@@ -448,7 +456,7 @@ static int host_ip(char *str, unsigned char ip[4])
448 { /* do a gethostbyname */ 456 { /* do a gethostbyname */
449 struct hostent *he; 457 struct hostent *he;
450 458
451 if (!sock_init()) return(0); 459 if (!ssl_sock_init()) return(0);
452 460
453 he=GetHostByName(str); 461 he=GetHostByName(str);
454 if (he == NULL) 462 if (he == NULL)
@@ -529,9 +537,12 @@ static struct hostent *GetHostByName(char *name)
529 ret=gethostbyname(name); 537 ret=gethostbyname(name);
530 if (ret == NULL) return(NULL); 538 if (ret == NULL) return(NULL);
531 /* else add to cache */ 539 /* else add to cache */
532 strncpy(ghbn_cache[lowi].name,name,128); 540 if(strlen(name) < sizeof ghbn_cache[0].name)
533 memcpy((char *)&(ghbn_cache[lowi].ent),ret,sizeof(struct hostent)); 541 {
534 ghbn_cache[lowi].order=ghbn_miss+ghbn_hits; 542 strcpy(ghbn_cache[lowi].name,name);
543 memcpy((char *)&(ghbn_cache[lowi].ent),ret,sizeof(struct hostent));
544 ghbn_cache[lowi].order=ghbn_miss+ghbn_hits;
545 }
535 return(ret); 546 return(ret);
536 } 547 }
537 else 548 else
diff --git a/src/lib/libssl/src/apps/s_time.c b/src/lib/libssl/src/apps/s_time.c
index 752158460a..1ad16cd607 100644
--- a/src/lib/libssl/src/apps/s_time.c
+++ b/src/lib/libssl/src/apps/s_time.c
@@ -146,6 +146,8 @@
146#undef BUFSIZZ 146#undef BUFSIZZ
147#define BUFSIZZ 1024*10 147#define BUFSIZZ 1024*10
148 148
149#define MYBUFSIZ 1024*8
150
149#undef min 151#undef min
150#undef max 152#undef max
151#define min(a,b) (((a) < (b)) ? (a) : (b)) 153#define min(a,b) (((a) < (b)) ? (a) : (b))
@@ -320,6 +322,11 @@ static int parseArgs(int argc, char **argv)
320 { 322 {
321 if (--argc < 1) goto bad; 323 if (--argc < 1) goto bad;
322 s_www_path= *(++argv); 324 s_www_path= *(++argv);
325 if(strlen(s_www_path) > MYBUFSIZ-100)
326 {
327 BIO_printf(bio_err,"-www option too long\n");
328 badop=1;
329 }
323 } 330 }
324 else if(strcmp(*argv,"-bugs") == 0) 331 else if(strcmp(*argv,"-bugs") == 0)
325 st_bugs=1; 332 st_bugs=1;
@@ -480,7 +487,7 @@ int MAIN(int argc, char **argv)
480 tm_Time_F(START); 487 tm_Time_F(START);
481 for (;;) 488 for (;;)
482 { 489 {
483 if (finishtime < time(NULL)) break; 490 if (finishtime < (long)time(NULL)) break;
484#ifdef WIN32_STUFF 491#ifdef WIN32_STUFF
485 492
486 if( flushWinMsgs(0) == -1 ) 493 if( flushWinMsgs(0) == -1 )
@@ -531,9 +538,9 @@ int MAIN(int argc, char **argv)
531 } 538 }
532 totalTime += tm_Time_F(STOP); /* Add the time for this iteration */ 539 totalTime += tm_Time_F(STOP); /* Add the time for this iteration */
533 540
534 i=(int)(time(NULL)-finishtime+maxTime); 541 i=(int)((long)time(NULL)-finishtime+maxTime);
535 printf( "\n\n%d connections in %.2fs; %.2f connections/user sec, bytes read %ld\n", nConn, totalTime, ((double)nConn/totalTime),bytes_read); 542 printf( "\n\n%d connections in %.2fs; %.2f connections/user sec, bytes read %ld\n", nConn, totalTime, ((double)nConn/totalTime),bytes_read);
536 printf( "%d connections in %ld real seconds, %ld bytes read per connection\n",nConn,time(NULL)-finishtime+maxTime,bytes_read/nConn); 543 printf( "%d connections in %ld real seconds, %ld bytes read per connection\n",nConn,(long)time(NULL)-finishtime+maxTime,bytes_read/nConn);
537 544
538 /* Now loop and time connections using the same session id over and over */ 545 /* Now loop and time connections using the same session id over and over */
539 546
@@ -565,7 +572,7 @@ next:
565 nConn = 0; 572 nConn = 0;
566 totalTime = 0.0; 573 totalTime = 0.0;
567 574
568 finishtime=time(NULL)+maxTime; 575 finishtime=(long)time(NULL)+maxTime;
569 576
570 printf( "starting\n" ); 577 printf( "starting\n" );
571 bytes_read=0; 578 bytes_read=0;
@@ -573,7 +580,7 @@ next:
573 580
574 for (;;) 581 for (;;)
575 { 582 {
576 if (finishtime < time(NULL)) break; 583 if (finishtime < (long)time(NULL)) break;
577 584
578#ifdef WIN32_STUFF 585#ifdef WIN32_STUFF
579 if( flushWinMsgs(0) == -1 ) 586 if( flushWinMsgs(0) == -1 )
@@ -623,7 +630,7 @@ next:
623 630
624 631
625 printf( "\n\n%d connections in %.2fs; %.2f connections/user sec, bytes read %ld\n", nConn, totalTime, ((double)nConn/totalTime),bytes_read); 632 printf( "\n\n%d connections in %.2fs; %.2f connections/user sec, bytes read %ld\n", nConn, totalTime, ((double)nConn/totalTime),bytes_read);
626 printf( "%d connections in %ld real seconds, %ld bytes read per connection\n",nConn,time(NULL)-finishtime+maxTime,bytes_read/nConn); 633 printf( "%d connections in %ld real seconds, %ld bytes read per connection\n",nConn,(long)time(NULL)-finishtime+maxTime,bytes_read/nConn);
627 634
628 ret=0; 635 ret=0;
629end: 636end:
@@ -635,7 +642,7 @@ end:
635 tm_ctx=NULL; 642 tm_ctx=NULL;
636 } 643 }
637 apps_shutdown(); 644 apps_shutdown();
638 EXIT(ret); 645 OPENSSL_EXIT(ret);
639 } 646 }
640 647
641/*********************************************************************** 648/***********************************************************************
diff --git a/src/lib/libssl/src/apps/sess_id.c b/src/lib/libssl/src/apps/sess_id.c
index 41c3b3f4a3..d91d84d220 100644
--- a/src/lib/libssl/src/apps/sess_id.c
+++ b/src/lib/libssl/src/apps/sess_id.c
@@ -273,7 +273,7 @@ end:
273 if (out != NULL) BIO_free_all(out); 273 if (out != NULL) BIO_free_all(out);
274 if (x != NULL) SSL_SESSION_free(x); 274 if (x != NULL) SSL_SESSION_free(x);
275 apps_shutdown(); 275 apps_shutdown();
276 EXIT(ret); 276 OPENSSL_EXIT(ret);
277 } 277 }
278 278
279static SSL_SESSION *load_sess_id(char *infile, int format) 279static SSL_SESSION *load_sess_id(char *infile, int format)
diff --git a/src/lib/libssl/src/apps/smime.c b/src/lib/libssl/src/apps/smime.c
index ef0e477464..cc248d377b 100644
--- a/src/lib/libssl/src/apps/smime.c
+++ b/src/lib/libssl/src/apps/smime.c
@@ -104,7 +104,9 @@ int MAIN(int argc, char **argv)
104 int need_rand = 0; 104 int need_rand = 0;
105 int informat = FORMAT_SMIME, outformat = FORMAT_SMIME; 105 int informat = FORMAT_SMIME, outformat = FORMAT_SMIME;
106 int keyform = FORMAT_PEM; 106 int keyform = FORMAT_PEM;
107#ifndef OPENSSL_NO_ENGINE
107 char *engine=NULL; 108 char *engine=NULL;
109#endif
108 110
109 args = argv + 1; 111 args = argv + 1;
110 ret = 1; 112 ret = 1;
@@ -176,11 +178,13 @@ int MAIN(int argc, char **argv)
176 inrand = *args; 178 inrand = *args;
177 } else badarg = 1; 179 } else badarg = 1;
178 need_rand = 1; 180 need_rand = 1;
181#ifndef OPENSSL_NO_ENGINE
179 } else if (!strcmp(*args,"-engine")) { 182 } else if (!strcmp(*args,"-engine")) {
180 if (args[1]) { 183 if (args[1]) {
181 args++; 184 args++;
182 engine = *args; 185 engine = *args;
183 } else badarg = 1; 186 } else badarg = 1;
187#endif
184 } else if (!strcmp(*args,"-passin")) { 188 } else if (!strcmp(*args,"-passin")) {
185 if (args[1]) { 189 if (args[1]) {
186 args++; 190 args++;
@@ -330,7 +334,9 @@ int MAIN(int argc, char **argv)
330 BIO_printf (bio_err, "-CAfile file trusted certificates file\n"); 334 BIO_printf (bio_err, "-CAfile file trusted certificates file\n");
331 BIO_printf (bio_err, "-crl_check check revocation status of signer's certificate using CRLs\n"); 335 BIO_printf (bio_err, "-crl_check check revocation status of signer's certificate using CRLs\n");
332 BIO_printf (bio_err, "-crl_check_all check revocation status of signer's certificate chain using CRLs\n"); 336 BIO_printf (bio_err, "-crl_check_all check revocation status of signer's certificate chain using CRLs\n");
337#ifndef OPENSSL_NO_ENGINE
333 BIO_printf (bio_err, "-engine e use engine e, possibly a hardware device.\n"); 338 BIO_printf (bio_err, "-engine e use engine e, possibly a hardware device.\n");
339#endif
334 BIO_printf (bio_err, "-passin arg input file pass phrase source\n"); 340 BIO_printf (bio_err, "-passin arg input file pass phrase source\n");
335 BIO_printf(bio_err, "-rand file%cfile%c...\n", LIST_SEPARATOR_CHAR, LIST_SEPARATOR_CHAR); 341 BIO_printf(bio_err, "-rand file%cfile%c...\n", LIST_SEPARATOR_CHAR, LIST_SEPARATOR_CHAR);
336 BIO_printf(bio_err, " load the file (or the files in the directory) into\n"); 342 BIO_printf(bio_err, " load the file (or the files in the directory) into\n");
@@ -339,7 +345,9 @@ int MAIN(int argc, char **argv)
339 goto end; 345 goto end;
340 } 346 }
341 347
348#ifndef OPENSSL_NO_ENGINE
342 e = setup_engine(bio_err, engine, 0); 349 e = setup_engine(bio_err, engine, 0);
350#endif
343 351
344 if(!app_passwd(bio_err, passargin, NULL, &passin, NULL)) { 352 if(!app_passwd(bio_err, passargin, NULL, &passin, NULL)) {
345 BIO_printf(bio_err, "Error getting password\n"); 353 BIO_printf(bio_err, "Error getting password\n");
diff --git a/src/lib/libssl/src/apps/speed.c b/src/lib/libssl/src/apps/speed.c
index fea0ffe2cf..ec55b4188c 100644
--- a/src/lib/libssl/src/apps/speed.c
+++ b/src/lib/libssl/src/apps/speed.c
@@ -58,6 +58,8 @@
58 58
59/* most of this code has been pilfered from my libdes speed.c program */ 59/* most of this code has been pilfered from my libdes speed.c program */
60 60
61#ifndef OPENSSL_NO_SPEED
62
61#undef SECONDS 63#undef SECONDS
62#define SECONDS 3 64#define SECONDS 3
63#define RSA_SECONDS 10 65#define RSA_SECONDS 10
@@ -187,7 +189,8 @@
187 189
188/* The following if from times(3) man page. It may need to be changed */ 190/* The following if from times(3) man page. It may need to be changed */
189#ifndef HZ 191#ifndef HZ
190# ifdef _SC_CLK_TCK 192# if defined(_SC_CLK_TCK) \
193 && (!defined(OPENSSL_SYS_VMS) || __CTRL_VER >= 70000000)
191# define HZ ((double)sysconf(_SC_CLK_TCK)) 194# define HZ ((double)sysconf(_SC_CLK_TCK))
192# else 195# else
193# ifndef CLK_TCK 196# ifndef CLK_TCK
@@ -369,7 +372,9 @@ int MAIN(int, char **);
369 372
370int MAIN(int argc, char **argv) 373int MAIN(int argc, char **argv)
371 { 374 {
375#ifndef OPENSSL_NO_ENGINE
372 ENGINE *e = NULL; 376 ENGINE *e = NULL;
377#endif
373 unsigned char *buf=NULL,*buf2=NULL; 378 unsigned char *buf=NULL,*buf2=NULL;
374 int mret=1; 379 int mret=1;
375 long count=0,save_count=0; 380 long count=0,save_count=0;
@@ -589,6 +594,7 @@ int MAIN(int argc, char **argv)
589 j--; /* Otherwise, -elapsed gets confused with 594 j--; /* Otherwise, -elapsed gets confused with
590 an algorithm. */ 595 an algorithm. */
591 } 596 }
597#ifndef OPENSSL_NO_ENGINE
592 else if ((argc > 0) && (strcmp(*argv,"-engine") == 0)) 598 else if ((argc > 0) && (strcmp(*argv,"-engine") == 0))
593 { 599 {
594 argc--; 600 argc--;
@@ -605,6 +611,7 @@ int MAIN(int argc, char **argv)
605 means all of them should be run) */ 611 means all of them should be run) */
606 j--; 612 j--;
607 } 613 }
614#endif
608#ifdef HAVE_FORK 615#ifdef HAVE_FORK
609 else if ((argc > 0) && (strcmp(*argv,"-multi") == 0)) 616 else if ((argc > 0) && (strcmp(*argv,"-multi") == 0))
610 { 617 {
@@ -861,10 +868,12 @@ int MAIN(int argc, char **argv)
861 868
862 BIO_printf(bio_err,"\n"); 869 BIO_printf(bio_err,"\n");
863 BIO_printf(bio_err,"Available options:\n"); 870 BIO_printf(bio_err,"Available options:\n");
864#ifdef TIMES 871#if defined(TIMES) || defined(USE_TOD)
865 BIO_printf(bio_err,"-elapsed measure time in real time instead of CPU user time.\n"); 872 BIO_printf(bio_err,"-elapsed measure time in real time instead of CPU user time.\n");
866#endif 873#endif
874#ifndef OPENSSL_NO_ENGINE
867 BIO_printf(bio_err,"-engine e use engine e, possibly a hardware device.\n"); 875 BIO_printf(bio_err,"-engine e use engine e, possibly a hardware device.\n");
876#endif
868 BIO_printf(bio_err,"-evp e use EVP e.\n"); 877 BIO_printf(bio_err,"-evp e use EVP e.\n");
869 BIO_printf(bio_err,"-decrypt time decryption instead of encryption (only EVP).\n"); 878 BIO_printf(bio_err,"-decrypt time decryption instead of encryption (only EVP).\n");
870 BIO_printf(bio_err,"-mr produce machine readable output.\n"); 879 BIO_printf(bio_err,"-mr produce machine readable output.\n");
@@ -1392,6 +1401,7 @@ int MAIN(int argc, char **argv)
1392 else 1401 else
1393 EVP_EncryptFinal_ex(&ctx,buf,&outl); 1402 EVP_EncryptFinal_ex(&ctx,buf,&outl);
1394 d=Time_F(STOP); 1403 d=Time_F(STOP);
1404 EVP_CIPHER_CTX_cleanup(&ctx);
1395 } 1405 }
1396 if (evp_md) 1406 if (evp_md)
1397 { 1407 {
@@ -1728,7 +1738,7 @@ end:
1728 DSA_free(dsa_key[i]); 1738 DSA_free(dsa_key[i]);
1729#endif 1739#endif
1730 apps_shutdown(); 1740 apps_shutdown();
1731 EXIT(mret); 1741 OPENSSL_EXIT(mret);
1732 } 1742 }
1733 1743
1734static void print_message(const char *s, long num, int length) 1744static void print_message(const char *s, long num, int length)
@@ -1781,7 +1791,7 @@ static char *sstrsep(char **string, const char *delim)
1781 if (**string == 0) 1791 if (**string == 0)
1782 return NULL; 1792 return NULL;
1783 1793
1784 memset(isdelim, 0, 256); 1794 memset(isdelim, 0, sizeof isdelim);
1785 isdelim[0] = 1; 1795 isdelim[0] = 1;
1786 1796
1787 while (*delim) 1797 while (*delim)
@@ -1938,3 +1948,4 @@ static int do_multi(int multi)
1938 return 1; 1948 return 1;
1939 } 1949 }
1940#endif 1950#endif
1951#endif
diff --git a/src/lib/libssl/src/apps/spkac.c b/src/lib/libssl/src/apps/spkac.c
index 4ce53e36c9..47ee53f1ee 100644
--- a/src/lib/libssl/src/apps/spkac.c
+++ b/src/lib/libssl/src/apps/spkac.c
@@ -92,7 +92,9 @@ int MAIN(int argc, char **argv)
92 CONF *conf = NULL; 92 CONF *conf = NULL;
93 NETSCAPE_SPKI *spki = NULL; 93 NETSCAPE_SPKI *spki = NULL;
94 EVP_PKEY *pkey = NULL; 94 EVP_PKEY *pkey = NULL;
95#ifndef OPENSSL_NO_ENGINE
95 char *engine=NULL; 96 char *engine=NULL;
97#endif
96 98
97 apps_startup(); 99 apps_startup();
98 100
@@ -141,11 +143,13 @@ int MAIN(int argc, char **argv)
141 if (--argc < 1) goto bad; 143 if (--argc < 1) goto bad;
142 spksect= *(++argv); 144 spksect= *(++argv);
143 } 145 }
146#ifndef OPENSSL_NO_ENGINE
144 else if (strcmp(*argv,"-engine") == 0) 147 else if (strcmp(*argv,"-engine") == 0)
145 { 148 {
146 if (--argc < 1) goto bad; 149 if (--argc < 1) goto bad;
147 engine= *(++argv); 150 engine= *(++argv);
148 } 151 }
152#endif
149 else if (strcmp(*argv,"-noout") == 0) 153 else if (strcmp(*argv,"-noout") == 0)
150 noout=1; 154 noout=1;
151 else if (strcmp(*argv,"-pubkey") == 0) 155 else if (strcmp(*argv,"-pubkey") == 0)
@@ -171,7 +175,9 @@ bad:
171 BIO_printf(bio_err," -noout don't print SPKAC\n"); 175 BIO_printf(bio_err," -noout don't print SPKAC\n");
172 BIO_printf(bio_err," -pubkey output public key\n"); 176 BIO_printf(bio_err," -pubkey output public key\n");
173 BIO_printf(bio_err," -verify verify SPKAC signature\n"); 177 BIO_printf(bio_err," -verify verify SPKAC signature\n");
178#ifndef OPENSSL_NO_ENGINE
174 BIO_printf(bio_err," -engine e use engine e, possibly a hardware device.\n"); 179 BIO_printf(bio_err," -engine e use engine e, possibly a hardware device.\n");
180#endif
175 goto end; 181 goto end;
176 } 182 }
177 183
@@ -181,7 +187,9 @@ bad:
181 goto end; 187 goto end;
182 } 188 }
183 189
190#ifndef OPENSSL_NO_ENGINE
184 e = setup_engine(bio_err, engine, 0); 191 e = setup_engine(bio_err, engine, 0);
192#endif
185 193
186 if(keyfile) { 194 if(keyfile) {
187 pkey = load_key(bio_err, 195 pkey = load_key(bio_err,
@@ -295,5 +303,5 @@ end:
295 EVP_PKEY_free(pkey); 303 EVP_PKEY_free(pkey);
296 if(passin) OPENSSL_free(passin); 304 if(passin) OPENSSL_free(passin);
297 apps_shutdown(); 305 apps_shutdown();
298 EXIT(ret); 306 OPENSSL_EXIT(ret);
299 } 307 }
diff --git a/src/lib/libssl/src/apps/verify.c b/src/lib/libssl/src/apps/verify.c
index 215ef84fc7..6a93c018b8 100644
--- a/src/lib/libssl/src/apps/verify.c
+++ b/src/lib/libssl/src/apps/verify.c
@@ -86,7 +86,9 @@ int MAIN(int argc, char **argv)
86 STACK_OF(X509) *untrusted = NULL, *trusted = NULL; 86 STACK_OF(X509) *untrusted = NULL, *trusted = NULL;
87 X509_STORE *cert_ctx=NULL; 87 X509_STORE *cert_ctx=NULL;
88 X509_LOOKUP *lookup=NULL; 88 X509_LOOKUP *lookup=NULL;
89#ifndef OPENSSL_NO_ENGINE
89 char *engine=NULL; 90 char *engine=NULL;
91#endif
90 92
91 cert_ctx=X509_STORE_new(); 93 cert_ctx=X509_STORE_new();
92 if (cert_ctx == NULL) goto end; 94 if (cert_ctx == NULL) goto end;
@@ -142,11 +144,13 @@ int MAIN(int argc, char **argv)
142 if (argc-- < 1) goto end; 144 if (argc-- < 1) goto end;
143 trustfile= *(++argv); 145 trustfile= *(++argv);
144 } 146 }
147#ifndef OPENSSL_NO_ENGINE
145 else if (strcmp(*argv,"-engine") == 0) 148 else if (strcmp(*argv,"-engine") == 0)
146 { 149 {
147 if (--argc < 1) goto end; 150 if (--argc < 1) goto end;
148 engine= *(++argv); 151 engine= *(++argv);
149 } 152 }
153#endif
150 else if (strcmp(*argv,"-help") == 0) 154 else if (strcmp(*argv,"-help") == 0)
151 goto end; 155 goto end;
152 else if (strcmp(*argv,"-ignore_critical") == 0) 156 else if (strcmp(*argv,"-ignore_critical") == 0)
@@ -170,7 +174,9 @@ int MAIN(int argc, char **argv)
170 break; 174 break;
171 } 175 }
172 176
177#ifndef OPENSSL_NO_ENGINE
173 e = setup_engine(bio_err, engine, 0); 178 e = setup_engine(bio_err, engine, 0);
179#endif
174 180
175 lookup=X509_STORE_add_lookup(cert_ctx,X509_LOOKUP_file()); 181 lookup=X509_STORE_add_lookup(cert_ctx,X509_LOOKUP_file());
176 if (lookup == NULL) abort(); 182 if (lookup == NULL) abort();
@@ -219,7 +225,11 @@ int MAIN(int argc, char **argv)
219 ret=0; 225 ret=0;
220end: 226end:
221 if (ret == 1) { 227 if (ret == 1) {
222 BIO_printf(bio_err,"usage: verify [-verbose] [-CApath path] [-CAfile file] [-purpose purpose] [-crl_check] [-engine e] cert1 cert2 ...\n"); 228 BIO_printf(bio_err,"usage: verify [-verbose] [-CApath path] [-CAfile file] [-purpose purpose] [-crl_check]");
229#ifndef OPENSSL_NO_ENGINE
230 BIO_printf(bio_err," [-engine e]");
231#endif
232 BIO_printf(bio_err," cert1 cert2 ...\n");
223 BIO_printf(bio_err,"recognized usages:\n"); 233 BIO_printf(bio_err,"recognized usages:\n");
224 for(i = 0; i < X509_PURPOSE_get_count(); i++) { 234 for(i = 0; i < X509_PURPOSE_get_count(); i++) {
225 X509_PURPOSE *ptmp; 235 X509_PURPOSE *ptmp;
@@ -232,7 +242,7 @@ end:
232 sk_X509_pop_free(untrusted, X509_free); 242 sk_X509_pop_free(untrusted, X509_free);
233 sk_X509_pop_free(trusted, X509_free); 243 sk_X509_pop_free(trusted, X509_free);
234 apps_shutdown(); 244 apps_shutdown();
235 EXIT(ret); 245 OPENSSL_EXIT(ret);
236 } 246 }
237 247
238static int check(X509_STORE *ctx, char *file, STACK_OF(X509) *uchain, STACK_OF(X509) *tchain, int purpose, ENGINE *e) 248static int check(X509_STORE *ctx, char *file, STACK_OF(X509) *uchain, STACK_OF(X509) *tchain, int purpose, ENGINE *e)
@@ -330,7 +340,8 @@ static int MS_CALLBACK cb(int ok, X509_STORE_CTX *ctx)
330 if (!ok) 340 if (!ok)
331 { 341 {
332 X509_NAME_oneline( 342 X509_NAME_oneline(
333 X509_get_subject_name(ctx->current_cert),buf,256); 343 X509_get_subject_name(ctx->current_cert),buf,
344 sizeof buf);
334 printf("%s\n",buf); 345 printf("%s\n",buf);
335 printf("error %d at %d depth lookup:%s\n",ctx->error, 346 printf("error %d at %d depth lookup:%s\n",ctx->error,
336 ctx->error_depth, 347 ctx->error_depth,
diff --git a/src/lib/libssl/src/apps/version.c b/src/lib/libssl/src/apps/version.c
index 0cbcb47f88..0843b67565 100644
--- a/src/lib/libssl/src/apps/version.c
+++ b/src/lib/libssl/src/apps/version.c
@@ -200,5 +200,5 @@ int MAIN(int argc, char **argv)
200 if (dir) printf("%s\n",SSLeay_version(SSLEAY_DIR)); 200 if (dir) printf("%s\n",SSLeay_version(SSLEAY_DIR));
201end: 201end:
202 apps_shutdown(); 202 apps_shutdown();
203 EXIT(ret); 203 OPENSSL_EXIT(ret);
204 } 204 }
diff --git a/src/lib/libssl/src/apps/winrand.c b/src/lib/libssl/src/apps/winrand.c
index d042258b50..59bede3d70 100644
--- a/src/lib/libssl/src/apps/winrand.c
+++ b/src/lib/libssl/src/apps/winrand.c
@@ -118,7 +118,6 @@ LRESULT CALLBACK WndProc(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam)
118 HDC hdc; 118 HDC hdc;
119 PAINTSTRUCT ps; 119 PAINTSTRUCT ps;
120 RECT rect; 120 RECT rect;
121 char buffer[200];
122 static int seeded = 0; 121 static int seeded = 0;
123 122
124 switch (iMsg) 123 switch (iMsg)
diff --git a/src/lib/libssl/src/apps/x509.c b/src/lib/libssl/src/apps/x509.c
index 5a41c389ee..66f0074f45 100644
--- a/src/lib/libssl/src/apps/x509.c
+++ b/src/lib/libssl/src/apps/x509.c
@@ -122,7 +122,7 @@ static char *x509_usage[]={
122" -CAkey arg - set the CA key, must be PEM format\n", 122" -CAkey arg - set the CA key, must be PEM format\n",
123" missing, it is assumed to be in the CA file.\n", 123" missing, it is assumed to be in the CA file.\n",
124" -CAcreateserial - create serial number file if it does not exist\n", 124" -CAcreateserial - create serial number file if it does not exist\n",
125" -CAserial - serial file\n", 125" -CAserial arg - serial file\n",
126" -set_serial - serial number to use\n", 126" -set_serial - serial number to use\n",
127" -text - print the certificate in text form\n", 127" -text - print the certificate in text form\n",
128" -C - print out C code forms\n", 128" -C - print out C code forms\n",
@@ -131,7 +131,9 @@ static char *x509_usage[]={
131" -extensions - section from config file with X509V3 extensions to add\n", 131" -extensions - section from config file with X509V3 extensions to add\n",
132" -clrext - delete extensions before signing and input certificate\n", 132" -clrext - delete extensions before signing and input certificate\n",
133" -nameopt arg - various certificate name options\n", 133" -nameopt arg - various certificate name options\n",
134#ifndef OPENSSL_NO_ENGINE
134" -engine e - use engine e, possibly a hardware device.\n", 135" -engine e - use engine e, possibly a hardware device.\n",
136#endif
135" -certopt arg - various certificate text options\n", 137" -certopt arg - various certificate text options\n",
136NULL 138NULL
137}; 139};
@@ -183,7 +185,9 @@ int MAIN(int argc, char **argv)
183 int need_rand = 0; 185 int need_rand = 0;
184 int checkend=0,checkoffset=0; 186 int checkend=0,checkoffset=0;
185 unsigned long nmflag = 0, certflag = 0; 187 unsigned long nmflag = 0, certflag = 0;
188#ifndef OPENSSL_NO_ENGINE
186 char *engine=NULL; 189 char *engine=NULL;
190#endif
187 191
188 reqfile=0; 192 reqfile=0;
189 193
@@ -354,17 +358,13 @@ int MAIN(int argc, char **argv)
354 if (--argc < 1) goto bad; 358 if (--argc < 1) goto bad;
355 if (!set_name_ex(&nmflag, *(++argv))) goto bad; 359 if (!set_name_ex(&nmflag, *(++argv))) goto bad;
356 } 360 }
357 else if (strcmp(*argv,"-setalias") == 0) 361#ifndef OPENSSL_NO_ENGINE
358 {
359 if (--argc < 1) goto bad;
360 alias= *(++argv);
361 trustout = 1;
362 }
363 else if (strcmp(*argv,"-engine") == 0) 362 else if (strcmp(*argv,"-engine") == 0)
364 { 363 {
365 if (--argc < 1) goto bad; 364 if (--argc < 1) goto bad;
366 engine= *(++argv); 365 engine= *(++argv);
367 } 366 }
367#endif
368 else if (strcmp(*argv,"-C") == 0) 368 else if (strcmp(*argv,"-C") == 0)
369 C= ++num; 369 C= ++num;
370 else if (strcmp(*argv,"-email") == 0) 370 else if (strcmp(*argv,"-email") == 0)
@@ -450,7 +450,9 @@ bad:
450 goto end; 450 goto end;
451 } 451 }
452 452
453#ifndef OPENSSL_NO_ENGINE
453 e = setup_engine(bio_err, engine, 0); 454 e = setup_engine(bio_err, engine, 0);
455#endif
454 456
455 if (need_rand) 457 if (need_rand)
456 app_RAND_load_file(NULL, bio_err, 0); 458 app_RAND_load_file(NULL, bio_err, 0);
@@ -479,7 +481,7 @@ bad:
479 481
480 if (extfile) 482 if (extfile)
481 { 483 {
482 long errorline; 484 long errorline = -1;
483 X509V3_CTX ctx2; 485 X509V3_CTX ctx2;
484 extconf = NCONF_new(NULL); 486 extconf = NCONF_new(NULL);
485 if (!NCONF_load(extconf, extfile,&errorline)) 487 if (!NCONF_load(extconf, extfile,&errorline))
@@ -770,10 +772,11 @@ bad:
770 int y,z; 772 int y,z;
771 773
772 X509_NAME_oneline(X509_get_subject_name(x), 774 X509_NAME_oneline(X509_get_subject_name(x),
773 buf,256); 775 buf,sizeof buf);
774 BIO_printf(STDout,"/* subject:%s */\n",buf); 776 BIO_printf(STDout,"/* subject:%s */\n",buf);
775 m=X509_NAME_oneline( 777 m=X509_NAME_oneline(
776 X509_get_issuer_name(x),buf,256); 778 X509_get_issuer_name(x),buf,
779 sizeof buf);
777 BIO_printf(STDout,"/* issuer :%s */\n",buf); 780 BIO_printf(STDout,"/* issuer :%s */\n",buf);
778 781
779 z=i2d_X509(x,NULL); 782 z=i2d_X509(x,NULL);
@@ -1016,7 +1019,7 @@ end:
1016 sk_ASN1_OBJECT_pop_free(reject, ASN1_OBJECT_free); 1019 sk_ASN1_OBJECT_pop_free(reject, ASN1_OBJECT_free);
1017 if (passin) OPENSSL_free(passin); 1020 if (passin) OPENSSL_free(passin);
1018 apps_shutdown(); 1021 apps_shutdown();
1019 EXIT(ret); 1022 OPENSSL_EXIT(ret);
1020 } 1023 }
1021 1024
1022static ASN1_INTEGER *load_serial(char *CAfile, char *serialfile, int create) 1025static ASN1_INTEGER *load_serial(char *CAfile, char *serialfile, int create)
@@ -1074,7 +1077,7 @@ static ASN1_INTEGER *load_serial(char *CAfile, char *serialfile, int create)
1074 } 1077 }
1075 else 1078 else
1076 { 1079 {
1077 if (!a2i_ASN1_INTEGER(io,bs,buf2,1024)) 1080 if (!a2i_ASN1_INTEGER(io,bs,buf2,sizeof buf2))
1078 { 1081 {
1079 BIO_printf(bio_err,"unable to load serial number from %s\n",buf); 1082 BIO_printf(bio_err,"unable to load serial number from %s\n",buf);
1080 ERR_print_errors(bio_err); 1083 ERR_print_errors(bio_err);
diff --git a/src/lib/libssl/src/config b/src/lib/libssl/src/config
index 3e9af7680a..b3bd96bbfc 100644
--- a/src/lib/libssl/src/config
+++ b/src/lib/libssl/src/config
@@ -74,34 +74,27 @@ if [ "x$XREL" != "x" ]; then
74 echo "whatever-whatever-sco5"; exit 0 74 echo "whatever-whatever-sco5"; exit 0
75 ;; 75 ;;
76 4.2MP) 76 4.2MP)
77 if [ "x$VERSION" = "x2.01" ]; then 77 case "x${VERSION}" in
78 echo "${MACHINE}-whatever-unixware201"; exit 0 78 x2.0*) echo "whatever-whatever-unixware20"; exit 0 ;;
79 elif [ "x$VERSION" = "x2.02" ]; then 79 x2.1*) echo "whatever-whatever-unixware21"; exit 0 ;;
80 echo "${MACHINE}-whatever-unixware202"; exit 0 80 x2*) echo "whatever-whatever-unixware2"; exit 0 ;;
81 elif [ "x$VERSION" = "x2.03" ]; then 81 esac
82 echo "${MACHINE}-whatever-unixware203"; exit 0
83 elif [ "x$VERSION" = "x2.1.1" ]; then
84 echo "${MACHINE}-whatever-unixware211"; exit 0
85 elif [ "x$VERSION" = "x2.1.2" ]; then
86 echo "${MACHINE}-whatever-unixware212"; exit 0
87 elif [ "x$VERSION" = "x2.1.3" ]; then
88 echo "${MACHINE}-whatever-unixware213"; exit 0
89 else
90 echo "${MACHINE}-whatever-unixware2"; exit 0
91 fi
92 ;; 82 ;;
93 4.2) 83 4.2)
94 echo "whatever-whatever-unixware1"; exit 0 84 echo "i386-whatever-unixware1"; exit 0
95 ;;
96 OpenUNIX)
97 if [ "`echo x$VERSION | sed -e 's/\..*//'`" = "x8" ]; then
98 echo "${MACHINE}-unknown-OpenUNIX${VERSION}"; exit 0
99 fi
100 ;; 85 ;;
101 5) 86 5)
102 if [ "`echo x$VERSION | sed -e 's/\..*//'`" = "x7" ]; then 87 case "x${VERSION}" in
103 echo "${MACHINE}-sco-unixware7"; exit 0 88 # We hardcode i586 in place of ${MACHINE} for the
104 fi 89 # following reason. The catch is that even though Pentium
90 # is minimum requirement for platforms in question,
91 # ${MACHINE} gets always assigned to i386. Now, problem
92 # with i386 is that it makes ./config pass 386 to
93 # ./Configure, which in turn makes make generate
94 # inefficient SHA-1 (for this moment) code.
95 x7*) echo "i586-sco-unixware7"; exit 0 ;;
96 x8*) echo "i586-unkn-OpenUNIX${VERSION}"; exit 0 ;;
97 esac
105 ;; 98 ;;
106 esac 99 esac
107 fi 100 fi
@@ -196,7 +189,7 @@ case "${SYSTEM}:${RELEASE}:${VERSION}:${MACHINE}" in
196 echo "${MACHINE}-whatever-bsdi"; exit 0 189 echo "${MACHINE}-whatever-bsdi"; exit 0
197 ;; 190 ;;
198 191
199 FreeBSD:*) 192 FreeBSD:*:*:*386*)
200 VERS=`echo ${RELEASE} | sed -e 's/[-(].*//'` 193 VERS=`echo ${RELEASE} | sed -e 's/[-(].*//'`
201 MACH=`sysctl -n hw.model` 194 MACH=`sysctl -n hw.model`
202 ARCH='whatever' 195 ARCH='whatever'
@@ -205,7 +198,6 @@ case "${SYSTEM}:${RELEASE}:${VERSION}:${MACHINE}" in
205 *486* ) MACH="i486" ;; 198 *486* ) MACH="i486" ;;
206 Pentium\ II*) MACH="i686" ;; 199 Pentium\ II*) MACH="i686" ;;
207 Pentium* ) MACH="i586" ;; 200 Pentium* ) MACH="i586" ;;
208 Alpha* ) MACH="alpha" ;;
209 * ) MACH="$MACHINE" ;; 201 * ) MACH="$MACHINE" ;;
210 esac 202 esac
211 case ${MACH} in 203 case ${MACH} in
@@ -214,6 +206,10 @@ case "${SYSTEM}:${RELEASE}:${VERSION}:${MACHINE}" in
214 echo "${MACH}-${ARCH}-freebsd${VERS}"; exit 0 206 echo "${MACH}-${ARCH}-freebsd${VERS}"; exit 0
215 ;; 207 ;;
216 208
209 FreeBSD:*)
210 echo "${MACHINE}-whatever-freebsd"; exit 0
211 ;;
212
217 NetBSD:*:*:*386*) 213 NetBSD:*:*:*386*)
218 echo "`(/usr/sbin/sysctl -n hw.model || /sbin/sysctl -n hw.model) | sed 's,.*\(.\)86-class.*,i\186,'`-whatever-netbsd"; exit 0 214 echo "`(/usr/sbin/sysctl -n hw.model || /sbin/sysctl -n hw.model) | sed 's,.*\(.\)86-class.*,i\186,'`-whatever-netbsd"; exit 0
219 ;; 215 ;;
@@ -351,6 +347,10 @@ case "${SYSTEM}:${RELEASE}:${VERSION}:${MACHINE}" in
351 *CRAY*) 347 *CRAY*)
352 echo "j90-cray-unicos"; exit 0; 348 echo "j90-cray-unicos"; exit 0;
353 ;; 349 ;;
350
351 NONSTOP_KERNEL*)
352 echo "nsr-tandem-nsk"; exit 0;
353 ;;
354esac 354esac
355 355
356# 356#
@@ -457,6 +457,10 @@ if [ "${SYSTEM}-${MACHINE}" = "Linux-alpha" ]; then
457 fi 457 fi
458fi 458fi
459 459
460if [ "${SYSTEM}" = "AIX" ]; then # favor vendor cc over gcc
461 (cc) 2>&1 | grep -iv "not found" > /dev/null && CC=cc
462fi
463
460CCVER=${CCVER:-0} 464CCVER=${CCVER:-0}
461 465
462# read the output of the embedded GuessOS 466# read the output of the embedded GuessOS
@@ -469,7 +473,7 @@ echo Operating system: $GUESSOS
469# more time that I want to waste at the moment 473# more time that I want to waste at the moment
470case "$GUESSOS" in 474case "$GUESSOS" in
471 mips2-sgi-irix) 475 mips2-sgi-irix)
472 CPU=`(hinv -t cpu) 2>/dev/null | sed 's/^CPU:[^R]*R\([0-9]*\).*/\1/'` 476 CPU=`(hinv -t cpu) 2>/dev/null | head -1 | sed 's/^CPU:[^R]*R\([0-9]*\).*/\1/'`
473 CPU=${CPU:-0} 477 CPU=${CPU:-0}
474 if [ $CPU -ge 4000 ]; then 478 if [ $CPU -ge 4000 ]; then
475 options="$options -mips2" 479 options="$options -mips2"
@@ -477,7 +481,7 @@ case "$GUESSOS" in
477 OUT="irix-$CC" 481 OUT="irix-$CC"
478 ;; 482 ;;
479 mips3-sgi-irix) 483 mips3-sgi-irix)
480 CPU=`(hinv -t cpu) 2>/dev/null | sed 's/^CPU:[^R]*R\([0-9]*\).*/\1/'` 484 CPU=`(hinv -t cpu) 2>/dev/null | head -1 | sed 's/^CPU:[^R]*R\([0-9]*\).*/\1/'`
481 CPU=${CPU:-0} 485 CPU=${CPU:-0}
482 if [ $CPU -ge 5000 ]; then 486 if [ $CPU -ge 5000 ]; then
483 options="$options -mips4" 487 options="$options -mips4"
@@ -493,7 +497,7 @@ case "$GUESSOS" in
493 echo " You have about 5 seconds to press Ctrl-C to abort." 497 echo " You have about 5 seconds to press Ctrl-C to abort."
494 (stty -icanon min 0 time 50; read waste) < /dev/tty 498 (stty -icanon min 0 time 50; read waste) < /dev/tty
495 fi 499 fi
496 CPU=`(hinv -t cpu) 2>/dev/null | sed 's/^CPU:[^R]*R\([0-9]*\).*/\1/'` 500 CPU=`(hinv -t cpu) 2>/dev/null | head -1 | sed 's/^CPU:[^R]*R\([0-9]*\).*/\1/'`
497 CPU=${CPU:-0} 501 CPU=${CPU:-0}
498 if [ $CPU -ge 5000 ]; then 502 if [ $CPU -ge 5000 ]; then
499 options="$options -mips4" 503 options="$options -mips4"
@@ -543,12 +547,13 @@ EOF
543 ppc-apple-darwin*) OUT="darwin-ppc-cc" ;; 547 ppc-apple-darwin*) OUT="darwin-ppc-cc" ;;
544 i386-apple-darwin*) OUT="darwin-i386-cc" ;; 548 i386-apple-darwin*) OUT="darwin-i386-cc" ;;
545 sparc64-*-linux2) 549 sparc64-*-linux2)
546 #Before we can uncomment following lines we have to wait at least 550 echo "WARNING! If you *know* that your GNU C supports 64-bit/V9 ABI"
547 #till 64-bit glibc for SPARC is operational:-( 551 echo " and wish to build 64-bit library, then you have to"
548 #echo "WARNING! If you wish to build 64-bit library, then you have to" 552 echo " invoke './Configure linux64-sparcv9' *manually*."
549 #echo " invoke './Configure linux64-sparcv9' *manually*." 553 if [ "$TEST" = "false" ]; then
550 #echo " Type return if you want to continue, Ctrl-C to abort." 554 echo " You have about 5 seconds to press Ctrl-C to abort."
551 #read waste < /dev/tty 555 (stty -icanon min 0 time 50; read waste) < /dev/tty
556 fi
552 OUT="linux-sparcv9" ;; 557 OUT="linux-sparcv9" ;;
553 sparc-*-linux2) 558 sparc-*-linux2)
554 KARCH=`awk '/^type/{print$3}' /proc/cpuinfo` 559 KARCH=`awk '/^type/{print$3}' /proc/cpuinfo`
@@ -581,6 +586,7 @@ EOF
581 arm*-*-linux2) OUT="linux-elf-arm" ;; 586 arm*-*-linux2) OUT="linux-elf-arm" ;;
582 s390-*-linux2) OUT="linux-s390" ;; 587 s390-*-linux2) OUT="linux-s390" ;;
583 s390x-*-linux?) OUT="linux-s390x" ;; 588 s390x-*-linux?) OUT="linux-s390x" ;;
589 x86_64-*-linux?) OUT="linux-x86_64" ;;
584 *-*-linux2) OUT="linux-elf" 590 *-*-linux2) OUT="linux-elf"
585 if [ "$GCCVER" -gt 28 ]; then 591 if [ "$GCCVER" -gt 28 ]; then
586 if grep '^model.*Pentium' /proc/cpuinfo >/dev/null ; then 592 if grep '^model.*Pentium' /proc/cpuinfo >/dev/null ; then
@@ -634,6 +640,8 @@ EOF
634 *86*-*-solaris2) OUT="solaris-x86-$CC" ;; 640 *86*-*-solaris2) OUT="solaris-x86-$CC" ;;
635 *-*-sunos4) OUT="sunos-$CC" ;; 641 *-*-sunos4) OUT="sunos-$CC" ;;
636 alpha*-*-freebsd*) OUT="FreeBSD-alpha" ;; 642 alpha*-*-freebsd*) OUT="FreeBSD-alpha" ;;
643 sparc64-*-freebsd*) OUT="FreeBSD-sparc64" ;;
644 ia64-*-freebsd*) OUT="FreeBSD-ia64" ;;
637 *-freebsd[3-9]*) OUT="FreeBSD-elf" ;; 645 *-freebsd[3-9]*) OUT="FreeBSD-elf" ;;
638 *-freebsd[1-2]*) OUT="FreeBSD" ;; 646 *-freebsd[1-2]*) OUT="FreeBSD" ;;
639 *86*-*-netbsd) OUT="NetBSD-x86" ;; 647 *86*-*-netbsd) OUT="NetBSD-x86" ;;
@@ -690,9 +698,11 @@ EOF
690 CPU_VERSION=${CPU_VERSION:-0} 698 CPU_VERSION=${CPU_VERSION:-0}
691 # See <sys/unistd.h> for further info on CPU_VERSION. 699 # See <sys/unistd.h> for further info on CPU_VERSION.
692 if [ $CPU_VERSION -ge 768 ]; then # IA-64 CPU 700 if [ $CPU_VERSION -ge 768 ]; then # IA-64 CPU
693 echo "NOTICE! 64-bit is the only ABI currently operational on HP-UXi." 701 echo "WARNING! 64-bit ABI is the default configured ABI on HP-UXi."
694 echo " Post request to openssl-dev@openssl.org for 32-bit support." 702 echo " If you wish to build 32-bit library, the you have to"
703 echo " invoke './Configure hpux-ia32-cc' *manually*."
695 if [ "$TEST" = "false" ]; then 704 if [ "$TEST" = "false" ]; then
705 echo " You have about 5 seconds to press Ctrl-C to abort."
696 (stty -icanon min 0 time 50; read waste) < /dev/tty 706 (stty -icanon min 0 time 50; read waste) < /dev/tty
697 fi 707 fi
698 OUT="hpux64-ia64-cc" 708 OUT="hpux64-ia64-cc"
@@ -725,6 +735,7 @@ EOF
725 *-*-cygwin) OUT="Cygwin" ;; 735 *-*-cygwin) OUT="Cygwin" ;;
726 t3e-cray-unicosmk) OUT="cray-t3e" ;; 736 t3e-cray-unicosmk) OUT="cray-t3e" ;;
727 j90-cray-unicos) OUT="cray-j90" ;; 737 j90-cray-unicos) OUT="cray-j90" ;;
738 nsr-tandem-nsk) OUT="tandem-c89" ;;
728 *) OUT=`echo $GUESSOS | awk -F- '{print $3}'`;; 739 *) OUT=`echo $GUESSOS | awk -F- '{print $3}'`;;
729esac 740esac
730 741
@@ -759,7 +770,7 @@ case "$GUESSOS" in
759 i386-*) options="$options 386" ;; 770 i386-*) options="$options 386" ;;
760esac 771esac
761 772
762for i in bf cast des dh dsa ec hmac idea md2 md5 mdc2 rc2 rc4 rc5 rijndael ripemd rsa sha 773for i in bf cast des dh dsa ec hmac idea md2 md5 mdc2 rc2 rc4 rc5 aes ripemd rsa sha
763do 774do
764 if [ ! -d crypto/$i ] 775 if [ ! -d crypto/$i ]
765 then 776 then
diff --git a/src/lib/libssl/src/crypto/aes/aes.h b/src/lib/libssl/src/crypto/aes/aes.h
index e8da921ec5..8294a41a3a 100644
--- a/src/lib/libssl/src/crypto/aes/aes.h
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/aes/aes_cbc.c b/src/lib/libssl/src/crypto/aes/aes_cbc.c
index 3dfd7aba2a..de438306b1 100644
--- a/src/lib/libssl/src/crypto/aes/aes_cbc.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/aes/aes_cfb.c b/src/lib/libssl/src/crypto/aes/aes_cfb.c
index 41c2a5ec3d..9b569dda90 100644
--- a/src/lib/libssl/src/crypto/aes/aes_cfb.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/aes/aes_core.c b/src/lib/libssl/src/crypto/aes/aes_core.c
index 937988dd8c..2f41a825f8 100644
--- a/src/lib/libssl/src/crypto/aes/aes_core.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/aes/aes_ctr.c b/src/lib/libssl/src/crypto/aes/aes_ctr.c
index aea3db2092..59088499a0 100644
--- a/src/lib/libssl/src/crypto/aes/aes_ctr.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/aes/aes_ecb.c b/src/lib/libssl/src/crypto/aes/aes_ecb.c
index 1cb2e07d3d..28aa561c2d 100644
--- a/src/lib/libssl/src/crypto/aes/aes_ecb.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/aes/aes_locl.h b/src/lib/libssl/src/crypto/aes/aes_locl.h
index 18fc2d0747..f290946058 100644
--- a/src/lib/libssl/src/crypto/aes/aes_locl.h
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/aes/aes_ofb.c b/src/lib/libssl/src/crypto/aes/aes_ofb.c
index e33bdaea28..f358bb39e2 100644
--- a/src/lib/libssl/src/crypto/aes/aes_ofb.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/asn1/a_bitstr.c b/src/lib/libssl/src/crypto/asn1/a_bitstr.c
index e0265f69d2..f4ea96cd54 100644
--- a/src/lib/libssl/src/crypto/asn1/a_bitstr.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/asn1/a_bytes.c b/src/lib/libssl/src/crypto/asn1/a_bytes.c
index bb88660f58..afd27b80e1 100644
--- a/src/lib/libssl/src/crypto/asn1/a_bytes.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/asn1/a_d2i_fp.c b/src/lib/libssl/src/crypto/asn1/a_d2i_fp.c
index a80fbe9ff7..b67b75e7c2 100644
--- a/src/lib/libssl/src/crypto/asn1/a_d2i_fp.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/asn1/a_object.c b/src/lib/libssl/src/crypto/asn1/a_object.c
index 71ce7c3896..0a8e6c287c 100644
--- a/src/lib/libssl/src/crypto/asn1/a_object.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/asn1/a_sign.c b/src/lib/libssl/src/crypto/asn1/a_sign.c
index de53b44144..52ce7e3974 100644
--- a/src/lib/libssl/src/crypto/asn1/a_sign.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/asn1/a_strex.c b/src/lib/libssl/src/crypto/asn1/a_strex.c
index 7ddb7662f1..1def6c6549 100644
--- a/src/lib/libssl/src/crypto/asn1/a_strex.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/asn1/a_strnid.c b/src/lib/libssl/src/crypto/asn1/a_strnid.c
index 04789d1c63..aa49e9d7d0 100644
--- a/src/lib/libssl/src/crypto/asn1/a_strnid.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/asn1/a_time.c b/src/lib/libssl/src/crypto/asn1/a_time.c
index 27ddd30899..7348da9457 100644
--- a/src/lib/libssl/src/crypto/asn1/a_time.c
+++ b/src/lib/libssl/src/crypto/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);
@@ -152,7 +155,7 @@ ASN1_GENERALIZEDTIME *ASN1_TIME_to_generalizedtime(ASN1_TIME *t, ASN1_GENERALIZE
152 if (t->data[0] >= '5') strcpy(str, "19"); 155 if (t->data[0] >= '5') strcpy(str, "19");
153 else strcpy(str, "20"); 156 else strcpy(str, "20");
154 157
155 strcat(str, (char *)t->data); 158 BUF_strlcat(str, (char *)t->data, t->length+3); /* Include space for a '\0' */
156 159
157 return ret; 160 return ret;
158 } 161 }
diff --git a/src/lib/libssl/src/crypto/asn1/a_type.c b/src/lib/libssl/src/crypto/asn1/a_type.c
index 96e111cf23..fe3fcd40b0 100644
--- a/src/lib/libssl/src/crypto/asn1/a_type.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/asn1/a_verify.c b/src/lib/libssl/src/crypto/asn1/a_verify.c
index bf41de5146..da2a0a6d69 100644
--- a/src/lib/libssl/src/crypto/asn1/a_verify.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/asn1/asn1.h b/src/lib/libssl/src/crypto/asn1/asn1.h
index dbb30f4f22..3414509f1b 100644
--- a/src/lib/libssl/src/crypto/asn1/asn1.h
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/asn1/asn1_err.c b/src/lib/libssl/src/crypto/asn1/asn1_err.c
index c4c3d2a91d..094ec06fda 100644
--- a/src/lib/libssl/src/crypto/asn1/asn1_err.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/asn1/asn1_par.c b/src/lib/libssl/src/crypto/asn1/asn1_par.c
index facfdd27fc..e48532a24d 100644
--- a/src/lib/libssl/src/crypto/asn1/asn1_par.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/asn1/f_int.c b/src/lib/libssl/src/crypto/asn1/f_int.c
index 48cc3bfb90..9494e597ab 100644
--- a/src/lib/libssl/src/crypto/asn1/f_int.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/asn1/n_pkey.c b/src/lib/libssl/src/crypto/asn1/n_pkey.c
index 9146ee02c9..766b51c538 100644
--- a/src/lib/libssl/src/crypto/asn1/n_pkey.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/asn1/p8_pkey.c b/src/lib/libssl/src/crypto/asn1/p8_pkey.c
index b634d5bc85..24b409132f 100644
--- a/src/lib/libssl/src/crypto/asn1/p8_pkey.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/asn1/t_crl.c b/src/lib/libssl/src/crypto/asn1/t_crl.c
index 60db305756..757c148df8 100644
--- a/src/lib/libssl/src/crypto/asn1/t_crl.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/asn1/t_pkey.c b/src/lib/libssl/src/crypto/asn1/t_pkey.c
index 2d46914cb1..4e09c9e44e 100644
--- a/src/lib/libssl/src/crypto/asn1/t_pkey.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/asn1/t_req.c b/src/lib/libssl/src/crypto/asn1/t_req.c
index 739f272ecf..740cee80c0 100644
--- a/src/lib/libssl/src/crypto/asn1/t_req.c
+++ b/src/lib/libssl/src/crypto/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,8 +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 sprintf(str,"%8sVersion: %s%lu (%s0x%lx)\n","",neg,l,neg,l); 118 if(BIO_printf(bp,"%8sVersion: %s%lu (%s0x%lx)\n","",neg,l,neg,
120 if (BIO_puts(bp,str) <= 0) goto err; 119 l) <= 0)
120 goto err;
121 } 121 }
122 if(!(cflag & X509_FLAG_NO_SUBJECT)) 122 if(!(cflag & X509_FLAG_NO_SUBJECT))
123 { 123 {
@@ -168,14 +168,14 @@ int X509_REQ_print_ex(BIO *bp, X509_REQ *x, unsigned long nmflags, unsigned long
168 if(!(cflag & X509_FLAG_NO_ATTRIBUTES)) 168 if(!(cflag & X509_FLAG_NO_ATTRIBUTES))
169 { 169 {
170 /* may not be */ 170 /* may not be */
171 sprintf(str,"%8sAttributes:\n",""); 171 if(BIO_printf(bp,"%8sAttributes:\n","") <= 0)
172 if (BIO_puts(bp,str) <= 0) goto err; 172 goto err;
173 173
174 sk=x->req_info->attributes; 174 sk=x->req_info->attributes;
175 if (sk_X509_ATTRIBUTE_num(sk) == 0) 175 if (sk_X509_ATTRIBUTE_num(sk) == 0)
176 { 176 {
177 sprintf(str,"%12sa0:00\n",""); 177 if(BIO_printf(bp,"%12sa0:00\n","") <= 0)
178 if (BIO_puts(bp,str) <= 0) goto err; 178 goto err;
179 } 179 }
180 else 180 else
181 { 181 {
@@ -190,8 +190,8 @@ int X509_REQ_print_ex(BIO *bp, X509_REQ *x, unsigned long nmflags, unsigned long
190 a=sk_X509_ATTRIBUTE_value(sk,i); 190 a=sk_X509_ATTRIBUTE_value(sk,i);
191 if(X509_REQ_extension_nid(OBJ_obj2nid(a->object))) 191 if(X509_REQ_extension_nid(OBJ_obj2nid(a->object)))
192 continue; 192 continue;
193 sprintf(str,"%12s",""); 193 if(BIO_printf(bp,"%12s","") <= 0)
194 if (BIO_puts(bp,str) <= 0) goto err; 194 goto err;
195 if ((j=i2a_ASN1_OBJECT(bp,a->object)) > 0) 195 if ((j=i2a_ASN1_OBJECT(bp,a->object)) > 0)
196 { 196 {
197 if (a->single) 197 if (a->single)
diff --git a/src/lib/libssl/src/crypto/asn1/t_x509.c b/src/lib/libssl/src/crypto/asn1/t_x509.c
index 5de4833ed0..d1034c47f8 100644
--- a/src/lib/libssl/src/crypto/asn1/t_x509.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/asn1/t_x509a.c b/src/lib/libssl/src/crypto/asn1/t_x509a.c
index 7d4a6e6084..ffbbfb51f4 100644
--- a/src/lib/libssl/src/crypto/asn1/t_x509a.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/asn1/tasn_dec.c b/src/lib/libssl/src/crypto/asn1/tasn_dec.c
index f87c08793a..76fc023230 100644
--- a/src/lib/libssl/src/crypto/asn1/tasn_dec.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/asn1/tasn_fre.c b/src/lib/libssl/src/crypto/asn1/tasn_fre.c
index c7610776f2..2dd844159e 100644
--- a/src/lib/libssl/src/crypto/asn1/tasn_fre.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/asn1/tasn_new.c b/src/lib/libssl/src/crypto/asn1/tasn_new.c
index e33861f864..a0e3db574f 100644
--- a/src/lib/libssl/src/crypto/asn1/tasn_new.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/asn1/tasn_prn.c b/src/lib/libssl/src/crypto/asn1/tasn_prn.c
index fab67ae5ac..719639b511 100644
--- a/src/lib/libssl/src/crypto/asn1/tasn_prn.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/bf/bftest.c b/src/lib/libssl/src/crypto/bf/bftest.c
index 09895f2542..24d526b14b 100644
--- a/src/lib/libssl/src/crypto/bf/bftest.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/bio/b_print.c b/src/lib/libssl/src/crypto/bio/b_print.c
index 80c9cb69db..a9e552f245 100644
--- a/src/lib/libssl/src/crypto/bio/b_print.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/bio/b_sock.c b/src/lib/libssl/src/crypto/bio/b_sock.c
index 45bd7c47e8..601a14f37c 100644
--- a/src/lib/libssl/src/crypto/bio/b_sock.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/bio/bf_buff.c b/src/lib/libssl/src/crypto/bio/bf_buff.c
index 6ccda06596..1cecd70579 100644
--- a/src/lib/libssl/src/crypto/bio/bf_buff.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/bio/bio.h b/src/lib/libssl/src/crypto/bio/bio.h
index c5caf253c9..fbbc16d00c 100644
--- a/src/lib/libssl/src/crypto/bio/bio.h
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/bio/bio_lib.c b/src/lib/libssl/src/crypto/bio/bio_lib.c
index 50df2238fa..692c8fb5c6 100644
--- a/src/lib/libssl/src/crypto/bio/bio_lib.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/bio/bss_bio.c b/src/lib/libssl/src/crypto/bio/bss_bio.c
index 1c485a4479..aa58dab046 100644
--- a/src/lib/libssl/src/crypto/bio/bss_bio.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/bio/bss_conn.c b/src/lib/libssl/src/crypto/bio/bss_conn.c
index f91ae4c8c6..743db6ff94 100644
--- a/src/lib/libssl/src/crypto/bio/bss_conn.c
+++ b/src/lib/libssl/src/crypto/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 sprintf(buf,"%d.%d.%d.%d", 524 sprintf(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 sprintf(buf,"%d",*(int *)ptr); 535 sprintf(buf,"%d",*(int *)ptr);
536 if (data->param_port != NULL) 536 if (data->param_port != NULL)
diff --git a/src/lib/libssl/src/crypto/bio/bss_file.c b/src/lib/libssl/src/crypto/bio/bss_file.c
index 826b361fa2..a66600c1a3 100644
--- a/src/lib/libssl/src/crypto/bio/bss_file.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/bio/bss_log.c b/src/lib/libssl/src/crypto/bio/bss_log.c
index a39d95297c..1eb678cac0 100644
--- a/src/lib/libssl/src/crypto/bio/bss_log.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/bio/bss_mem.c b/src/lib/libssl/src/crypto/bio/bss_mem.c
index 28ff7582bf..a4edb711ae 100644
--- a/src/lib/libssl/src/crypto/bio/bss_mem.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/bio/bss_sock.c b/src/lib/libssl/src/crypto/bio/bss_sock.c
index fdabd16d7e..2c1c405ec7 100644
--- a/src/lib/libssl/src/crypto/bio/bss_sock.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/bn/asm/ia64.S b/src/lib/libssl/src/crypto/bn/asm/ia64.S
index ae56066310..7dfda85566 100644
--- a/src/lib/libssl/src/crypto/bn/asm/ia64.S
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/bn/asm/pa-risc2.s b/src/lib/libssl/src/crypto/bn/asm/pa-risc2.s
index af9730d062..f3b16290eb 100644
--- a/src/lib/libssl/src/crypto/bn/asm/pa-risc2.s
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/bn/asm/vms.mar b/src/lib/libssl/src/crypto/bn/asm/vms.mar
index 465f2774b6..aefab15cdb 100644
--- a/src/lib/libssl/src/crypto/bn/asm/vms.mar
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/bn/asm/x86_64-gcc.c b/src/lib/libssl/src/crypto/bn/asm/x86_64-gcc.c
new file mode 100644
index 0000000000..b97b394661
--- /dev/null
+++ b/src/lib/libssl/src/crypto/bn/asm/x86_64-gcc.c
@@ -0,0 +1,575 @@
1/*
2 * x86_64 BIGNUM accelerator version 0.1, December 2002.
3 *
4 * Implemented by Andy Polyakov <appro@fy.chalmers.se> for the OpenSSL
5 * project.
6 *
7 * Rights for redistribution and usage in source and binary forms are
8 * granted according to the OpenSSL license. Warranty of any kind is
9 * disclaimed.
10 *
11 * Q. Version 0.1? It doesn't sound like Andy, he used to assign real
12 * versions, like 1.0...
13 * A. Well, that's because this code is basically a quick-n-dirty
14 * proof-of-concept hack. As you can see it's implemented with
15 * inline assembler, which means that you're bound to GCC and that
16 * there must be a room for fine-tuning.
17 *
18 * Q. Why inline assembler?
19 * A. x86_64 features own ABI I'm not familiar with. Which is why
20 * I decided to let the compiler take care of subroutine
21 * prologue/epilogue as well as register allocation.
22 *
23 * Q. How much faster does it get?
24 * A. Unfortunately people sitting on x86_64 hardware are prohibited
25 * to disclose the performance numbers, so they (SuSE labs to be
26 * specific) wouldn't tell me. However! Very similar coding technique
27 * (reaching out for 128-bit result from 64x64-bit multiplication)
28 * results in >3 times performance improvement on MIPS and I see no
29 * reason why gain on x86_64 would be so much different:-)
30 */
31
32#define BN_ULONG unsigned long
33
34/*
35 * "m"(a), "+m"(r) is the way to favor DirectPath µ-code;
36 * "g"(0) let the compiler to decide where does it
37 * want to keep the value of zero;
38 */
39#define mul_add(r,a,word,carry) do { \
40 register BN_ULONG high,low; \
41 asm ("mulq %3" \
42 : "=a"(low),"=d"(high) \
43 : "a"(word),"m"(a) \
44 : "cc"); \
45 asm ("addq %2,%0; adcq %3,%1" \
46 : "+r"(carry),"+d"(high)\
47 : "a"(low),"g"(0) \
48 : "cc"); \
49 asm ("addq %2,%0; adcq %3,%1" \
50 : "+m"(r),"+d"(high) \
51 : "r"(carry),"g"(0) \
52 : "cc"); \
53 carry=high; \
54 } while (0)
55
56#define mul(r,a,word,carry) do { \
57 register BN_ULONG high,low; \
58 asm ("mulq %3" \
59 : "=a"(low),"=d"(high) \
60 : "a"(word),"g"(a) \
61 : "cc"); \
62 asm ("addq %2,%0; adcq %3,%1" \
63 : "+r"(carry),"+d"(high)\
64 : "a"(low),"g"(0) \
65 : "cc"); \
66 (r)=carry, carry=high; \
67 } while (0)
68
69#define sqr(r0,r1,a) \
70 asm ("mulq %2" \
71 : "=a"(r0),"=d"(r1) \
72 : "a"(a) \
73 : "cc");
74
75BN_ULONG bn_mul_add_words(BN_ULONG *rp, BN_ULONG *ap, int num, BN_ULONG w)
76 {
77 BN_ULONG c1=0;
78
79 if (num <= 0) return(c1);
80
81 while (num&~3)
82 {
83 mul_add(rp[0],ap[0],w,c1);
84 mul_add(rp[1],ap[1],w,c1);
85 mul_add(rp[2],ap[2],w,c1);
86 mul_add(rp[3],ap[3],w,c1);
87 ap+=4; rp+=4; num-=4;
88 }
89 if (num)
90 {
91 mul_add(rp[0],ap[0],w,c1); if (--num==0) return c1;
92 mul_add(rp[1],ap[1],w,c1); if (--num==0) return c1;
93 mul_add(rp[2],ap[2],w,c1); return c1;
94 }
95
96 return(c1);
97 }
98
99BN_ULONG bn_mul_words(BN_ULONG *rp, BN_ULONG *ap, int num, BN_ULONG w)
100 {
101 BN_ULONG c1=0;
102
103 if (num <= 0) return(c1);
104
105 while (num&~3)
106 {
107 mul(rp[0],ap[0],w,c1);
108 mul(rp[1],ap[1],w,c1);
109 mul(rp[2],ap[2],w,c1);
110 mul(rp[3],ap[3],w,c1);
111 ap+=4; rp+=4; num-=4;
112 }
113 if (num)
114 {
115 mul(rp[0],ap[0],w,c1); if (--num == 0) return c1;
116 mul(rp[1],ap[1],w,c1); if (--num == 0) return c1;
117 mul(rp[2],ap[2],w,c1);
118 }
119 return(c1);
120 }
121
122void bn_sqr_words(BN_ULONG *r, BN_ULONG *a, int n)
123 {
124 if (n <= 0) return;
125
126 while (n&~3)
127 {
128 sqr(r[0],r[1],a[0]);
129 sqr(r[2],r[3],a[1]);
130 sqr(r[4],r[5],a[2]);
131 sqr(r[6],r[7],a[3]);
132 a+=4; r+=8; n-=4;
133 }
134 if (n)
135 {
136 sqr(r[0],r[1],a[0]); if (--n == 0) return;
137 sqr(r[2],r[3],a[1]); if (--n == 0) return;
138 sqr(r[4],r[5],a[2]);
139 }
140 }
141
142BN_ULONG bn_div_words(BN_ULONG h, BN_ULONG l, BN_ULONG d)
143{ BN_ULONG ret,waste;
144
145 asm ("divq %3"
146 : "=a"(ret),"=d"(waste)
147 : "a"(l),"d"(h),"g"(d)
148 : "cc");
149
150 return ret;
151}
152
153BN_ULONG bn_add_words (BN_ULONG *rp, BN_ULONG *ap, BN_ULONG *bp,int n)
154{ BN_ULONG ret,i;
155
156 if (n <= 0) return 0;
157
158 asm (
159 " subq %2,%2 \n"
160 ".align 16 \n"
161 "1: movq (%4,%2,8),%0 \n"
162 " adcq (%5,%2,8),%0 \n"
163 " movq %0,(%3,%2,8) \n"
164 " leaq 1(%2),%2 \n"
165 " loop 1b \n"
166 " sbbq %0,%0 \n"
167 : "+a"(ret),"+c"(n),"+r"(i)
168 : "r"(rp),"r"(ap),"r"(bp)
169 : "cc"
170 );
171
172 return ret&1;
173}
174
175#ifndef SIMICS
176BN_ULONG bn_sub_words (BN_ULONG *rp, BN_ULONG *ap, BN_ULONG *bp,int n)
177{ BN_ULONG ret,i;
178
179 if (n <= 0) return 0;
180
181 asm (
182 " subq %2,%2 \n"
183 ".align 16 \n"
184 "1: movq (%4,%2,8),%0 \n"
185 " sbbq (%5,%2,8),%0 \n"
186 " movq %0,(%3,%2,8) \n"
187 " leaq 1(%2),%2 \n"
188 " loop 1b \n"
189 " sbbq %0,%0 \n"
190 : "+a"(ret),"+c"(n),"+r"(i)
191 : "r"(rp),"r"(ap),"r"(bp)
192 : "cc"
193 );
194
195 return ret&1;
196}
197#else
198/* Simics 1.4<7 has buggy sbbq:-( */
199#define BN_MASK2 0xffffffffffffffffL
200BN_ULONG bn_sub_words(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, int n)
201 {
202 BN_ULONG t1,t2;
203 int c=0;
204
205 if (n <= 0) return((BN_ULONG)0);
206
207 for (;;)
208 {
209 t1=a[0]; t2=b[0];
210 r[0]=(t1-t2-c)&BN_MASK2;
211 if (t1 != t2) c=(t1 < t2);
212 if (--n <= 0) break;
213
214 t1=a[1]; t2=b[1];
215 r[1]=(t1-t2-c)&BN_MASK2;
216 if (t1 != t2) c=(t1 < t2);
217 if (--n <= 0) break;
218
219 t1=a[2]; t2=b[2];
220 r[2]=(t1-t2-c)&BN_MASK2;
221 if (t1 != t2) c=(t1 < t2);
222 if (--n <= 0) break;
223
224 t1=a[3]; t2=b[3];
225 r[3]=(t1-t2-c)&BN_MASK2;
226 if (t1 != t2) c=(t1 < t2);
227 if (--n <= 0) break;
228
229 a+=4;
230 b+=4;
231 r+=4;
232 }
233 return(c);
234 }
235#endif
236
237/* mul_add_c(a,b,c0,c1,c2) -- c+=a*b for three word number c=(c2,c1,c0) */
238/* mul_add_c2(a,b,c0,c1,c2) -- c+=2*a*b for three word number c=(c2,c1,c0) */
239/* sqr_add_c(a,i,c0,c1,c2) -- c+=a[i]^2 for three word number c=(c2,c1,c0) */
240/* sqr_add_c2(a,i,c0,c1,c2) -- c+=2*a[i]*a[j] for three word number c=(c2,c1,c0) */
241
242#if 0
243/* original macros are kept for reference purposes */
244#define mul_add_c(a,b,c0,c1,c2) { \
245 BN_ULONG ta=(a),tb=(b); \
246 t1 = ta * tb; \
247 t2 = BN_UMULT_HIGH(ta,tb); \
248 c0 += t1; t2 += (c0<t1)?1:0; \
249 c1 += t2; c2 += (c1<t2)?1:0; \
250 }
251
252#define mul_add_c2(a,b,c0,c1,c2) { \
253 BN_ULONG ta=(a),tb=(b),t0; \
254 t1 = BN_UMULT_HIGH(ta,tb); \
255 t0 = ta * tb; \
256 t2 = t1+t1; c2 += (t2<t1)?1:0; \
257 t1 = t0+t0; t2 += (t1<t0)?1:0; \
258 c0 += t1; t2 += (c0<t1)?1:0; \
259 c1 += t2; c2 += (c1<t2)?1:0; \
260 }
261#else
262#define mul_add_c(a,b,c0,c1,c2) do { \
263 asm ("mulq %3" \
264 : "=a"(t1),"=d"(t2) \
265 : "a"(a),"m"(b) \
266 : "cc"); \
267 asm ("addq %2,%0; adcq %3,%1" \
268 : "+r"(c0),"+d"(t2) \
269 : "a"(t1),"g"(0) \
270 : "cc"); \
271 asm ("addq %2,%0; adcq %3,%1" \
272 : "+r"(c1),"+r"(c2) \
273 : "d"(t2),"g"(0) \
274 : "cc"); \
275 } while (0)
276
277#define sqr_add_c(a,i,c0,c1,c2) do { \
278 asm ("mulq %2" \
279 : "=a"(t1),"=d"(t2) \
280 : "a"(a[i]) \
281 : "cc"); \
282 asm ("addq %2,%0; adcq %3,%1" \
283 : "+r"(c0),"+d"(t2) \
284 : "a"(t1),"g"(0) \
285 : "cc"); \
286 asm ("addq %2,%0; adcq %3,%1" \
287 : "+r"(c1),"+r"(c2) \
288 : "d"(t2),"g"(0) \
289 : "cc"); \
290 } while (0)
291
292#define mul_add_c2(a,b,c0,c1,c2) do { \
293 asm ("mulq %3" \
294 : "=a"(t1),"=d"(t2) \
295 : "a"(a),"m"(b) \
296 : "cc"); \
297 asm ("addq %0,%0; adcq %2,%1" \
298 : "+d"(t2),"+r"(c2) \
299 : "g"(0) \
300 : "cc"); \
301 asm ("addq %0,%0; adcq %2,%1" \
302 : "+a"(t1),"+d"(t2) \
303 : "g"(0) \
304 : "cc"); \
305 asm ("addq %2,%0; adcq %3,%1" \
306 : "+r"(c0),"+d"(t2) \
307 : "a"(t1),"g"(0) \
308 : "cc"); \
309 asm ("addq %2,%0; adcq %3,%1" \
310 : "+r"(c1),"+r"(c2) \
311 : "d"(t2),"g"(0) \
312 : "cc"); \
313 } while (0)
314#endif
315
316#define sqr_add_c2(a,i,j,c0,c1,c2) \
317 mul_add_c2((a)[i],(a)[j],c0,c1,c2)
318
319void bn_mul_comba8(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b)
320 {
321 BN_ULONG bl,bh;
322 BN_ULONG t1,t2;
323 BN_ULONG c1,c2,c3;
324
325 c1=0;
326 c2=0;
327 c3=0;
328 mul_add_c(a[0],b[0],c1,c2,c3);
329 r[0]=c1;
330 c1=0;
331 mul_add_c(a[0],b[1],c2,c3,c1);
332 mul_add_c(a[1],b[0],c2,c3,c1);
333 r[1]=c2;
334 c2=0;
335 mul_add_c(a[2],b[0],c3,c1,c2);
336 mul_add_c(a[1],b[1],c3,c1,c2);
337 mul_add_c(a[0],b[2],c3,c1,c2);
338 r[2]=c3;
339 c3=0;
340 mul_add_c(a[0],b[3],c1,c2,c3);
341 mul_add_c(a[1],b[2],c1,c2,c3);
342 mul_add_c(a[2],b[1],c1,c2,c3);
343 mul_add_c(a[3],b[0],c1,c2,c3);
344 r[3]=c1;
345 c1=0;
346 mul_add_c(a[4],b[0],c2,c3,c1);
347 mul_add_c(a[3],b[1],c2,c3,c1);
348 mul_add_c(a[2],b[2],c2,c3,c1);
349 mul_add_c(a[1],b[3],c2,c3,c1);
350 mul_add_c(a[0],b[4],c2,c3,c1);
351 r[4]=c2;
352 c2=0;
353 mul_add_c(a[0],b[5],c3,c1,c2);
354 mul_add_c(a[1],b[4],c3,c1,c2);
355 mul_add_c(a[2],b[3],c3,c1,c2);
356 mul_add_c(a[3],b[2],c3,c1,c2);
357 mul_add_c(a[4],b[1],c3,c1,c2);
358 mul_add_c(a[5],b[0],c3,c1,c2);
359 r[5]=c3;
360 c3=0;
361 mul_add_c(a[6],b[0],c1,c2,c3);
362 mul_add_c(a[5],b[1],c1,c2,c3);
363 mul_add_c(a[4],b[2],c1,c2,c3);
364 mul_add_c(a[3],b[3],c1,c2,c3);
365 mul_add_c(a[2],b[4],c1,c2,c3);
366 mul_add_c(a[1],b[5],c1,c2,c3);
367 mul_add_c(a[0],b[6],c1,c2,c3);
368 r[6]=c1;
369 c1=0;
370 mul_add_c(a[0],b[7],c2,c3,c1);
371 mul_add_c(a[1],b[6],c2,c3,c1);
372 mul_add_c(a[2],b[5],c2,c3,c1);
373 mul_add_c(a[3],b[4],c2,c3,c1);
374 mul_add_c(a[4],b[3],c2,c3,c1);
375 mul_add_c(a[5],b[2],c2,c3,c1);
376 mul_add_c(a[6],b[1],c2,c3,c1);
377 mul_add_c(a[7],b[0],c2,c3,c1);
378 r[7]=c2;
379 c2=0;
380 mul_add_c(a[7],b[1],c3,c1,c2);
381 mul_add_c(a[6],b[2],c3,c1,c2);
382 mul_add_c(a[5],b[3],c3,c1,c2);
383 mul_add_c(a[4],b[4],c3,c1,c2);
384 mul_add_c(a[3],b[5],c3,c1,c2);
385 mul_add_c(a[2],b[6],c3,c1,c2);
386 mul_add_c(a[1],b[7],c3,c1,c2);
387 r[8]=c3;
388 c3=0;
389 mul_add_c(a[2],b[7],c1,c2,c3);
390 mul_add_c(a[3],b[6],c1,c2,c3);
391 mul_add_c(a[4],b[5],c1,c2,c3);
392 mul_add_c(a[5],b[4],c1,c2,c3);
393 mul_add_c(a[6],b[3],c1,c2,c3);
394 mul_add_c(a[7],b[2],c1,c2,c3);
395 r[9]=c1;
396 c1=0;
397 mul_add_c(a[7],b[3],c2,c3,c1);
398 mul_add_c(a[6],b[4],c2,c3,c1);
399 mul_add_c(a[5],b[5],c2,c3,c1);
400 mul_add_c(a[4],b[6],c2,c3,c1);
401 mul_add_c(a[3],b[7],c2,c3,c1);
402 r[10]=c2;
403 c2=0;
404 mul_add_c(a[4],b[7],c3,c1,c2);
405 mul_add_c(a[5],b[6],c3,c1,c2);
406 mul_add_c(a[6],b[5],c3,c1,c2);
407 mul_add_c(a[7],b[4],c3,c1,c2);
408 r[11]=c3;
409 c3=0;
410 mul_add_c(a[7],b[5],c1,c2,c3);
411 mul_add_c(a[6],b[6],c1,c2,c3);
412 mul_add_c(a[5],b[7],c1,c2,c3);
413 r[12]=c1;
414 c1=0;
415 mul_add_c(a[6],b[7],c2,c3,c1);
416 mul_add_c(a[7],b[6],c2,c3,c1);
417 r[13]=c2;
418 c2=0;
419 mul_add_c(a[7],b[7],c3,c1,c2);
420 r[14]=c3;
421 r[15]=c1;
422 }
423
424void bn_mul_comba4(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b)
425 {
426 BN_ULONG bl,bh;
427 BN_ULONG t1,t2;
428 BN_ULONG c1,c2,c3;
429
430 c1=0;
431 c2=0;
432 c3=0;
433 mul_add_c(a[0],b[0],c1,c2,c3);
434 r[0]=c1;
435 c1=0;
436 mul_add_c(a[0],b[1],c2,c3,c1);
437 mul_add_c(a[1],b[0],c2,c3,c1);
438 r[1]=c2;
439 c2=0;
440 mul_add_c(a[2],b[0],c3,c1,c2);
441 mul_add_c(a[1],b[1],c3,c1,c2);
442 mul_add_c(a[0],b[2],c3,c1,c2);
443 r[2]=c3;
444 c3=0;
445 mul_add_c(a[0],b[3],c1,c2,c3);
446 mul_add_c(a[1],b[2],c1,c2,c3);
447 mul_add_c(a[2],b[1],c1,c2,c3);
448 mul_add_c(a[3],b[0],c1,c2,c3);
449 r[3]=c1;
450 c1=0;
451 mul_add_c(a[3],b[1],c2,c3,c1);
452 mul_add_c(a[2],b[2],c2,c3,c1);
453 mul_add_c(a[1],b[3],c2,c3,c1);
454 r[4]=c2;
455 c2=0;
456 mul_add_c(a[2],b[3],c3,c1,c2);
457 mul_add_c(a[3],b[2],c3,c1,c2);
458 r[5]=c3;
459 c3=0;
460 mul_add_c(a[3],b[3],c1,c2,c3);
461 r[6]=c1;
462 r[7]=c2;
463 }
464
465void bn_sqr_comba8(BN_ULONG *r, BN_ULONG *a)
466 {
467 BN_ULONG bl,bh;
468 BN_ULONG t1,t2;
469 BN_ULONG c1,c2,c3;
470
471 c1=0;
472 c2=0;
473 c3=0;
474 sqr_add_c(a,0,c1,c2,c3);
475 r[0]=c1;
476 c1=0;
477 sqr_add_c2(a,1,0,c2,c3,c1);
478 r[1]=c2;
479 c2=0;
480 sqr_add_c(a,1,c3,c1,c2);
481 sqr_add_c2(a,2,0,c3,c1,c2);
482 r[2]=c3;
483 c3=0;
484 sqr_add_c2(a,3,0,c1,c2,c3);
485 sqr_add_c2(a,2,1,c1,c2,c3);
486 r[3]=c1;
487 c1=0;
488 sqr_add_c(a,2,c2,c3,c1);
489 sqr_add_c2(a,3,1,c2,c3,c1);
490 sqr_add_c2(a,4,0,c2,c3,c1);
491 r[4]=c2;
492 c2=0;
493 sqr_add_c2(a,5,0,c3,c1,c2);
494 sqr_add_c2(a,4,1,c3,c1,c2);
495 sqr_add_c2(a,3,2,c3,c1,c2);
496 r[5]=c3;
497 c3=0;
498 sqr_add_c(a,3,c1,c2,c3);
499 sqr_add_c2(a,4,2,c1,c2,c3);
500 sqr_add_c2(a,5,1,c1,c2,c3);
501 sqr_add_c2(a,6,0,c1,c2,c3);
502 r[6]=c1;
503 c1=0;
504 sqr_add_c2(a,7,0,c2,c3,c1);
505 sqr_add_c2(a,6,1,c2,c3,c1);
506 sqr_add_c2(a,5,2,c2,c3,c1);
507 sqr_add_c2(a,4,3,c2,c3,c1);
508 r[7]=c2;
509 c2=0;
510 sqr_add_c(a,4,c3,c1,c2);
511 sqr_add_c2(a,5,3,c3,c1,c2);
512 sqr_add_c2(a,6,2,c3,c1,c2);
513 sqr_add_c2(a,7,1,c3,c1,c2);
514 r[8]=c3;
515 c3=0;
516 sqr_add_c2(a,7,2,c1,c2,c3);
517 sqr_add_c2(a,6,3,c1,c2,c3);
518 sqr_add_c2(a,5,4,c1,c2,c3);
519 r[9]=c1;
520 c1=0;
521 sqr_add_c(a,5,c2,c3,c1);
522 sqr_add_c2(a,6,4,c2,c3,c1);
523 sqr_add_c2(a,7,3,c2,c3,c1);
524 r[10]=c2;
525 c2=0;
526 sqr_add_c2(a,7,4,c3,c1,c2);
527 sqr_add_c2(a,6,5,c3,c1,c2);
528 r[11]=c3;
529 c3=0;
530 sqr_add_c(a,6,c1,c2,c3);
531 sqr_add_c2(a,7,5,c1,c2,c3);
532 r[12]=c1;
533 c1=0;
534 sqr_add_c2(a,7,6,c2,c3,c1);
535 r[13]=c2;
536 c2=0;
537 sqr_add_c(a,7,c3,c1,c2);
538 r[14]=c3;
539 r[15]=c1;
540 }
541
542void bn_sqr_comba4(BN_ULONG *r, BN_ULONG *a)
543 {
544 BN_ULONG bl,bh;
545 BN_ULONG t1,t2;
546 BN_ULONG c1,c2,c3;
547
548 c1=0;
549 c2=0;
550 c3=0;
551 sqr_add_c(a,0,c1,c2,c3);
552 r[0]=c1;
553 c1=0;
554 sqr_add_c2(a,1,0,c2,c3,c1);
555 r[1]=c2;
556 c2=0;
557 sqr_add_c(a,1,c3,c1,c2);
558 sqr_add_c2(a,2,0,c3,c1,c2);
559 r[2]=c3;
560 c3=0;
561 sqr_add_c2(a,3,0,c1,c2,c3);
562 sqr_add_c2(a,2,1,c1,c2,c3);
563 r[3]=c1;
564 c1=0;
565 sqr_add_c(a,2,c2,c3,c1);
566 sqr_add_c2(a,3,1,c2,c3,c1);
567 r[4]=c2;
568 c2=0;
569 sqr_add_c2(a,3,2,c3,c1,c2);
570 r[5]=c3;
571 c3=0;
572 sqr_add_c(a,3,c1,c2,c3);
573 r[6]=c1;
574 r[7]=c2;
575 }
diff --git a/src/lib/libssl/src/crypto/bn/bn.h b/src/lib/libssl/src/crypto/bn/bn.h
index b40682f831..3da6d8ced9 100644
--- a/src/lib/libssl/src/crypto/bn/bn.h
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/bn/bn_div.c b/src/lib/libssl/src/crypto/bn/bn_div.c
index f9a095e3b3..580d1201bc 100644
--- a/src/lib/libssl/src/crypto/bn/bn_div.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/bn/bn_lcl.h b/src/lib/libssl/src/crypto/bn/bn_lcl.h
index 8a4dba375a..5614bc6164 100644
--- a/src/lib/libssl/src/crypto/bn/bn_lcl.h
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/bn/bn_lib.c b/src/lib/libssl/src/crypto/bn/bn_lib.c
index 8abe095af2..fa0ff485ad 100644
--- a/src/lib/libssl/src/crypto/bn/bn_lib.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/bn/bn_mul.c b/src/lib/libssl/src/crypto/bn/bn_mul.c
index b03458d002..cb93ac3356 100644
--- a/src/lib/libssl/src/crypto/bn/bn_mul.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/bn/bn_prime.c b/src/lib/libssl/src/crypto/bn/bn_prime.c
index 918b9237c6..e072d9255c 100644
--- a/src/lib/libssl/src/crypto/bn/bn_prime.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/bn/bn_rand.c b/src/lib/libssl/src/crypto/bn/bn_rand.c
index 9e08ccd22e..893c9d2af9 100644
--- a/src/lib/libssl/src/crypto/bn/bn_rand.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/bn/bn_word.c b/src/lib/libssl/src/crypto/bn/bn_word.c
index cd59baa2c4..988e0ca7b3 100644
--- a/src/lib/libssl/src/crypto/bn/bn_word.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/bn/bntest.c b/src/lib/libssl/src/crypto/bn/bntest.c
index 8158a67374..3c8c540387 100644
--- a/src/lib/libssl/src/crypto/bn/bntest.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/bn/divtest.c b/src/lib/libssl/src/crypto/bn/divtest.c
index 13ba86e3c4..d3fc688f33 100644
--- a/src/lib/libssl/src/crypto/bn/divtest.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/bn/exptest.c b/src/lib/libssl/src/crypto/bn/exptest.c
index 5ca570d1a8..b09cf88705 100644
--- a/src/lib/libssl/src/crypto/bn/exptest.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/buffer/buffer.c b/src/lib/libssl/src/crypto/buffer/buffer.c
index 9299baba9e..d96487e7db 100644
--- a/src/lib/libssl/src/crypto/buffer/buffer.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/buffer/buffer.h b/src/lib/libssl/src/crypto/buffer/buffer.h
index 11e2d0359a..465dc34f3f 100644
--- a/src/lib/libssl/src/crypto/buffer/buffer.h
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/cast/casttest.c b/src/lib/libssl/src/crypto/cast/casttest.c
index 099e790886..83e5a16c73 100644
--- a/src/lib/libssl/src/crypto/cast/casttest.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/comp/c_zlib.c b/src/lib/libssl/src/crypto/comp/c_zlib.c
index cd2f8a491b..8c0876151a 100644
--- a/src/lib/libssl/src/crypto/comp/c_zlib.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/conf/conf_def.c b/src/lib/libssl/src/crypto/conf/conf_def.c
index 5e194de60e..57d2739ae0 100644
--- a/src/lib/libssl/src/crypto/conf/conf_def.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/conf/conf_mall.c b/src/lib/libssl/src/crypto/conf/conf_mall.c
index d702af689b..4ba40cf44c 100644
--- a/src/lib/libssl/src/crypto/conf/conf_mall.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/conf/conf_sap.c b/src/lib/libssl/src/crypto/conf/conf_sap.c
index 97fb174303..e15c2e5546 100644
--- a/src/lib/libssl/src/crypto/conf/conf_sap.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/cryptlib.c b/src/lib/libssl/src/crypto/cryptlib.c
index 612b3b93b4..2924def2bb 100644
--- a/src/lib/libssl/src/crypto/cryptlib.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/cryptlib.h b/src/lib/libssl/src/crypto/cryptlib.h
index 88e4ae509f..0d6b9d59f0 100644
--- a/src/lib/libssl/src/crypto/cryptlib.h
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/crypto-lib.com b/src/lib/libssl/src/crypto/crypto-lib.com
index dfcff11860..39e78c69e5 100644
--- a/src/lib/libssl/src/crypto/crypto-lib.com
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/crypto.h b/src/lib/libssl/src/crypto/crypto.h
index fc6ff860af..273bc5e3f8 100644
--- a/src/lib/libssl/src/crypto/crypto.h
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/des/FILES0 b/src/lib/libssl/src/crypto/des/FILES0
new file mode 100644
index 0000000000..4c7ea2de7a
--- /dev/null
+++ b/src/lib/libssl/src/crypto/des/FILES0
@@ -0,0 +1,96 @@
1/* General stuff */
2COPYRIGHT - Copyright info.
3MODES.DES - A description of the features of the different modes of DES.
4FILES - This file.
5INSTALL - How to make things compile.
6Imakefile - For use with kerberos.
7README - What this package is.
8VERSION - Which version this is and what was changed.
9KERBEROS - Kerberos version 4 notes.
10Makefile.PL - An old makefile to build with perl5, not current.
11Makefile.ssl - The SSLeay makefile
12Makefile.uni - The normal unix makefile.
13GNUmakefile - The makefile for use with glibc.
14makefile.bc - A Borland C makefile
15times - Some outputs from 'speed' on some machines.
16vms.com - For use when compiling under VMS
17
18/* My SunOS des(1) replacement */
19des.c - des(1) source code.
20des.man - des(1) manual.
21
22/* Testing and timing programs. */
23destest.c - Source for libdes.a test program.
24speed.c - Source for libdes.a timing program.
25rpw.c - Source for libdes.a testing password reading routines.
26
27/* libdes.a source code */
28des_crypt.man - libdes.a manual page.
29des.h - Public libdes.a header file.
30ecb_enc.c - des_ecb_encrypt() source, this contains the basic DES code.
31ecb3_enc.c - des_ecb3_encrypt() source.
32cbc_ckm.c - des_cbc_cksum() source.
33cbc_enc.c - des_cbc_encrypt() source.
34ncbc_enc.c - des_cbc_encrypt() that is 'normal' in that it copies
35 the new iv values back in the passed iv vector.
36ede_enc.c - des_ede3_cbc_encrypt() cbc mode des using triple DES.
37cbc3_enc.c - des_3cbc_encrypt() source, don't use this function.
38cfb_enc.c - des_cfb_encrypt() source.
39cfb64enc.c - des_cfb64_encrypt() cfb in 64 bit mode but setup to be
40 used as a stream cipher.
41cfb64ede.c - des_ede3_cfb64_encrypt() cfb in 64 bit mode but setup to be
42 used as a stream cipher and using triple DES.
43ofb_enc.c - des_cfb_encrypt() source.
44ofb64_enc.c - des_ofb_encrypt() ofb in 64 bit mode but setup to be
45 used as a stream cipher.
46ofb64ede.c - des_ede3_ofb64_encrypt() ofb in 64 bit mode but setup to be
47 used as a stream cipher and using triple DES.
48enc_read.c - des_enc_read() source.
49enc_writ.c - des_enc_write() source.
50pcbc_enc.c - des_pcbc_encrypt() source.
51qud_cksm.c - quad_cksum() source.
52rand_key.c - des_random_key() source.
53read_pwd.c - Source for des_read_password() plus related functions.
54set_key.c - Source for des_set_key().
55str2key.c - Covert a string of any length into a key.
56fcrypt.c - A small, fast version of crypt(3).
57des_locl.h - Internal libdes.a header file.
58podd.h - Odd parity tables - used in des_set_key().
59sk.h - Lookup tables used in des_set_key().
60spr.h - What is left of the S tables - used in ecb_encrypt().
61des_ver.h - header file for the external definition of the
62 version string.
63des.doc - SSLeay documentation for the library.
64
65/* The perl scripts - you can ignore these files they are only
66 * included for the curious */
67des.pl - des in perl anyone? des_set_key and des_ecb_encrypt
68 both done in a perl library.
69testdes.pl - Testing program for des.pl
70doIP - Perl script used to develop IP xor/shift code.
71doPC1 - Perl script used to develop PC1 xor/shift code.
72doPC2 - Generates sk.h.
73PC1 - Output of doPC1 should be the same as output from PC1.
74PC2 - used in development of doPC2.
75shifts.pl - Perl library used by my perl scripts.
76
77/* I started making a perl5 dynamic library for libdes
78 * but did not fully finish, these files are part of that effort. */
79DES.pm
80DES.pod
81DES.xs
82t
83typemap
84
85/* The following are for use with sun RPC implementaions. */
86rpc_des.h
87rpc_enc.c
88
89/* The following are contibuted by Mark Murray <mark@grondar.za>. They
90 * are not normally built into libdes due to machine specific routines
91 * contained in them. They are for use in the most recent incarnation of
92 * export kerberos v 4 (eBones). */
93supp.c
94new_rkey.c
95
96
diff --git a/src/lib/libssl/src/crypto/des/asm/crypt586.pl b/src/lib/libssl/src/crypto/des/asm/crypt586.pl
index 3d41d82f69..1d04ed6def 100644
--- a/src/lib/libssl/src/crypto/des/asm/crypt586.pl
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/des/asm/des-586.pl b/src/lib/libssl/src/crypto/des/asm/des-586.pl
index 0d08e8a3a9..b75d3c6b3a 100644
--- a/src/lib/libssl/src/crypto/des/asm/des-586.pl
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/des/cbc_cksm.c b/src/lib/libssl/src/crypto/des/cbc_cksm.c
index 6c5305b99d..09a7ba56aa 100644
--- a/src/lib/libssl/src/crypto/des/cbc_cksm.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/des/des.c b/src/lib/libssl/src/crypto/des/des.c
index d8c846b23d..343135ff9e 100644
--- a/src/lib/libssl/src/crypto/des/des.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/des/des.h b/src/lib/libssl/src/crypto/des/des.h
index 4cb9d84fdf..daaf239dbe 100644
--- a/src/lib/libssl/src/crypto/des/des.h
+++ b/src/lib/libssl/src/crypto/des/des.h
@@ -56,8 +56,8 @@
56 * [including the GNU Public Licence.] 56 * [including the GNU Public Licence.]
57 */ 57 */
58 58
59#ifndef HEADER_DES_H 59#ifndef HEADER_NEW_DES_H
60#define HEADER_DES_H 60#define HEADER_NEW_DES_H
61 61
62#ifdef OPENSSL_NO_DES 62#ifdef OPENSSL_NO_DES
63#error DES is disabled. 63#error DES is disabled.
diff --git a/src/lib/libssl/src/crypto/des/des_locl.h b/src/lib/libssl/src/crypto/des/des_locl.h
index 70e833be3f..e44e8e98b2 100644
--- a/src/lib/libssl/src/crypto/des/des_locl.h
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/des/des_old.h b/src/lib/libssl/src/crypto/des/des_old.h
index 51b987422a..1d840b474a 100644
--- a/src/lib/libssl/src/crypto/des/des_old.h
+++ b/src/lib/libssl/src/crypto/des/des_old.h
@@ -88,14 +88,14 @@
88 * 88 *
89 */ 89 */
90 90
91#ifndef HEADER_DES_OLD_H 91#ifndef HEADER_DES_H
92#define HEADER_DES_OLD_H 92#define HEADER_DES_H
93 93
94#ifdef OPENSSL_NO_DES 94#ifdef OPENSSL_NO_DES
95#error DES is disabled. 95#error DES is disabled.
96#endif 96#endif
97 97
98#ifndef HEADER_DES_H 98#ifndef HEADER_NEW_DES_H
99#error You must include des.h, not des_old.h directly. 99#error You must include des.h, not des_old.h directly.
100#endif 100#endif
101 101
@@ -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)\
@@ -274,8 +276,10 @@ typedef struct _ossl_old_des_ks_struct
274 _ossl_old_des_fcrypt((b),(s),(r)) 276 _ossl_old_des_fcrypt((b),(s),(r))
275#define des_crypt(b,s)\ 277#define des_crypt(b,s)\
276 _ossl_old_des_crypt((b),(s)) 278 _ossl_old_des_crypt((b),(s))
279#if 0
277#define crypt(b,s)\ 280#define crypt(b,s)\
278 _ossl_old_crypt((b),(s)) 281 _ossl_old_crypt((b),(s))
282#endif
279#define des_ofb_encrypt(i,o,n,l,k,iv)\ 283#define des_ofb_encrypt(i,o,n,l,k,iv)\
280 _ossl_old_des_ofb_encrypt((i),(o),(n),(l),(k),(iv)) 284 _ossl_old_des_ofb_encrypt((i),(o),(n),(l),(k),(iv))
281#define des_pcbc_encrypt(i,o,l,k,iv,e)\ 285#define des_pcbc_encrypt(i,o,l,k,iv,e)\
diff --git a/src/lib/libssl/src/crypto/des/destest.c b/src/lib/libssl/src/crypto/des/destest.c
index 58e8c35dcb..687c00c792 100644
--- a/src/lib/libssl/src/crypto/des/destest.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/des/read2pwd.c b/src/lib/libssl/src/crypto/des/read2pwd.c
index b4720c3a98..3a63c4016c 100644
--- a/src/lib/libssl/src/crypto/des/read2pwd.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/des/read_pwd.c b/src/lib/libssl/src/crypto/des/read_pwd.c
index 9061935f21..ce5fa00a37 100644
--- a/src/lib/libssl/src/crypto/des/read_pwd.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/des/str2key.c b/src/lib/libssl/src/crypto/des/str2key.c
index 36c3f81d99..0373db469c 100644
--- a/src/lib/libssl/src/crypto/des/str2key.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/dh/dh_key.c b/src/lib/libssl/src/crypto/dh/dh_key.c
index 1a0efca2c4..77f2f50b51 100644
--- a/src/lib/libssl/src/crypto/dh/dh_key.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/dh/dh_lib.c b/src/lib/libssl/src/crypto/dh/dh_lib.c
index ba5fd41057..09965ee2ea 100644
--- a/src/lib/libssl/src/crypto/dh/dh_lib.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/dh/dhtest.c b/src/lib/libssl/src/crypto/dh/dhtest.c
index 34894ced73..d75077f9fa 100644
--- a/src/lib/libssl/src/crypto/dh/dhtest.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/dsa/dsa_lib.c b/src/lib/libssl/src/crypto/dsa/dsa_lib.c
index da2cdfa3d6..4171af24c6 100644
--- a/src/lib/libssl/src/crypto/dsa/dsa_lib.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/dsa/dsa_ossl.c b/src/lib/libssl/src/crypto/dsa/dsa_ossl.c
index 37dd5fc994..b9e7f3ea5c 100644
--- a/src/lib/libssl/src/crypto/dsa/dsa_ossl.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/dsa/dsa_sign.c b/src/lib/libssl/src/crypto/dsa/dsa_sign.c
index e9469ca62f..89205026f0 100644
--- a/src/lib/libssl/src/crypto/dsa/dsa_sign.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/dsa/dsa_vrf.c b/src/lib/libssl/src/crypto/dsa/dsa_vrf.c
index 066c6b5b28..c4aeddd056 100644
--- a/src/lib/libssl/src/crypto/dsa/dsa_vrf.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/dsa/dsagen.c b/src/lib/libssl/src/crypto/dsa/dsagen.c
index a0b0976640..1b6a1cca0f 100644
--- a/src/lib/libssl/src/crypto/dsa/dsagen.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/dsa/dsatest.c b/src/lib/libssl/src/crypto/dsa/dsatest.c
index 12da64f9f4..4734ce4af8 100644
--- a/src/lib/libssl/src/crypto/dsa/dsatest.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/dso/dso_dl.c b/src/lib/libssl/src/crypto/dso/dso_dl.c
index 195717e993..79d2cb4d8c 100644
--- a/src/lib/libssl/src/crypto/dso/dso_dl.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/dso/dso_win32.c b/src/lib/libssl/src/crypto/dso/dso_win32.c
index af8586d754..6c30deb250 100644
--- a/src/lib/libssl/src/crypto/dso/dso_win32.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/ec/ec.h b/src/lib/libssl/src/crypto/ec/ec.h
index a52d4edf14..6d6a9b7127 100644
--- a/src/lib/libssl/src/crypto/ec/ec.h
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/ec/ec_err.c b/src/lib/libssl/src/crypto/ec/ec_err.c
index 394cdc021f..d37b6aba87 100644
--- a/src/lib/libssl/src/crypto/ec/ec_err.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/ec/ec_lib.c b/src/lib/libssl/src/crypto/ec/ec_lib.c
index 0cf485de60..deb522060f 100644
--- a/src/lib/libssl/src/crypto/ec/ec_lib.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/ec/ec_mult.c b/src/lib/libssl/src/crypto/ec/ec_mult.c
index 603ba31b81..4dbc931120 100644
--- a/src/lib/libssl/src/crypto/ec/ec_mult.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/ec/ectest.c b/src/lib/libssl/src/crypto/ec/ectest.c
index eab46cc080..345d3e4289 100644
--- a/src/lib/libssl/src/crypto/ec/ectest.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/engine/eng_all.c b/src/lib/libssl/src/crypto/engine/eng_all.c
index b3030fe505..0f6992a40d 100644
--- a/src/lib/libssl/src/crypto/engine/eng_all.c
+++ b/src/lib/libssl/src/crypto/engine/eng_all.c
@@ -95,8 +95,19 @@ void ENGINE_load_builtin_engines(void)
95#ifndef OPENSSL_NO_HW_4758_CCA 95#ifndef OPENSSL_NO_HW_4758_CCA
96 ENGINE_load_4758cca(); 96 ENGINE_load_4758cca();
97#endif 97#endif
98#ifdef OPENSSL_OPENBSD_DEV_CRYPTO 98#if defined(__OpenBSD__) || defined(__FreeBSD__)
99 ENGINE_load_openbsd_dev_crypto(); 99 ENGINE_load_cryptodev();
100#endif 100#endif
101#endif 101#endif
102 } 102 }
103
104#if defined(__OpenBSD__) || defined(__FreeBSD__)
105void ENGINE_setup_bsd_cryptodev(void) {
106 static int bsd_cryptodev_default_loaded = 0;
107 if (!bsd_cryptodev_default_loaded) {
108 ENGINE_load_cryptodev();
109 ENGINE_register_all_complete();
110 }
111 bsd_cryptodev_default_loaded=1;
112}
113#endif
diff --git a/src/lib/libssl/src/crypto/engine/eng_err.c b/src/lib/libssl/src/crypto/engine/eng_err.c
index f6c5630395..814d95ee32 100644
--- a/src/lib/libssl/src/crypto/engine/eng_err.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/engine/eng_fat.c b/src/lib/libssl/src/crypto/engine/eng_fat.c
index f7edb5ad32..0d7dae00b2 100644
--- a/src/lib/libssl/src/crypto/engine/eng_fat.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/engine/eng_init.c b/src/lib/libssl/src/crypto/engine/eng_init.c
index 98caa21e32..170c1791b3 100644
--- a/src/lib/libssl/src/crypto/engine/eng_init.c
+++ b/src/lib/libssl/src/crypto/engine/eng_init.c
@@ -93,7 +93,7 @@ int engine_unlocked_finish(ENGINE *e, int unlock_for_handlers)
93 * there's a chance that both threads will together take the count from 93 * there's a chance that both threads will together take the count from
94 * 2 to 0 without either calling finish(). */ 94 * 2 to 0 without either calling finish(). */
95 e->funct_ref--; 95 e->funct_ref--;
96 engine_ref_debug(e, 1, -1) 96 engine_ref_debug(e, 1, -1);
97 if((e->funct_ref == 0) && e->finish) 97 if((e->funct_ref == 0) && e->finish)
98 { 98 {
99 if(unlock_for_handlers) 99 if(unlock_for_handlers)
diff --git a/src/lib/libssl/src/crypto/engine/eng_list.c b/src/lib/libssl/src/crypto/engine/eng_list.c
index 0c220558e7..1cc3217f4c 100644
--- a/src/lib/libssl/src/crypto/engine/eng_list.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/engine/eng_openssl.c b/src/lib/libssl/src/crypto/engine/eng_openssl.c
index e9d976f46b..54579eea2e 100644
--- a/src/lib/libssl/src/crypto/engine/eng_openssl.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/engine/engine.h b/src/lib/libssl/src/crypto/engine/engine.h
index cf06618286..8686879e1a 100644
--- a/src/lib/libssl/src/crypto/engine/engine.h
+++ b/src/lib/libssl/src/crypto/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,7 +313,7 @@ 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); 316void ENGINE_load_cryptodev(void);
311void ENGINE_load_builtin_engines(void); 317void ENGINE_load_builtin_engines(void);
312 318
313/* Get and set global flags (ENGINE_TABLE_FLAG_***) for the implementation 319/* Get and set global flags (ENGINE_TABLE_FLAG_***) for the implementation
@@ -406,6 +412,7 @@ int ENGINE_ctrl_cmd_string(ENGINE *e, const char *cmd_name, const char *arg,
406 * compatibility! */ 412 * compatibility! */
407ENGINE *ENGINE_new(void); 413ENGINE *ENGINE_new(void);
408int ENGINE_free(ENGINE *e); 414int ENGINE_free(ENGINE *e);
415int ENGINE_up_ref(ENGINE *e);
409int ENGINE_set_id(ENGINE *e, const char *id); 416int ENGINE_set_id(ENGINE *e, const char *id);
410int ENGINE_set_name(ENGINE *e, const char *name); 417int ENGINE_set_name(ENGINE *e, const char *name);
411int ENGINE_set_RSA(ENGINE *e, const RSA_METHOD *rsa_meth); 418int ENGINE_set_RSA(ENGINE *e, const RSA_METHOD *rsa_meth);
@@ -662,6 +669,7 @@ void ERR_load_ENGINE_strings(void);
662#define ENGINE_F_ENGINE_SET_NAME 130 669#define ENGINE_F_ENGINE_SET_NAME 130
663#define ENGINE_F_ENGINE_TABLE_REGISTER 184 670#define ENGINE_F_ENGINE_TABLE_REGISTER 184
664#define ENGINE_F_ENGINE_UNLOAD_KEY 152 671#define ENGINE_F_ENGINE_UNLOAD_KEY 152
672#define ENGINE_F_ENGINE_UP_REF 190
665#define ENGINE_F_INT_CTRL_HELPER 172 673#define ENGINE_F_INT_CTRL_HELPER 172
666#define ENGINE_F_INT_ENGINE_CONFIGURE 188 674#define ENGINE_F_INT_ENGINE_CONFIGURE 188
667#define ENGINE_F_LOG_MESSAGE 141 675#define ENGINE_F_LOG_MESSAGE 141
diff --git a/src/lib/libssl/src/crypto/engine/enginetest.c b/src/lib/libssl/src/crypto/engine/enginetest.c
index 87fa8c57b7..c2d0297392 100644
--- a/src/lib/libssl/src/crypto/engine/enginetest.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/engine/hw_4758_cca.c b/src/lib/libssl/src/crypto/engine/hw_4758_cca.c
index bfb80968e2..4f5ae8a46d 100644
--- a/src/lib/libssl/src/crypto/engine/hw_4758_cca.c
+++ b/src/lib/libssl/src/crypto/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, keyLength+1, 0); 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, keyLength+1, 0); 843 OPENSSL_cleanse(hashBuffer, keyLength+1);
842 OPENSSL_free(hashBuffer); 844 OPENSSL_free(hashBuffer);
843 } 845 }
844 846
diff --git a/src/lib/libssl/src/crypto/engine/hw_atalla.c b/src/lib/libssl/src/crypto/engine/hw_atalla.c
index 6151c46902..e9eff9fad1 100644
--- a/src/lib/libssl/src/crypto/engine/hw_atalla.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/engine/hw_cryptodev.c b/src/lib/libssl/src/crypto/engine/hw_cryptodev.c
index 7c3728f395..40af97ac24 100644
--- a/src/lib/libssl/src/crypto/engine/hw_cryptodev.c
+++ b/src/lib/libssl/src/crypto/engine/hw_cryptodev.c
@@ -1,6 +1,7 @@
1/* 1/*
2 * Copyright (c) 2002 Bob Beck <beck@openbsd.org> 2 * Copyright (c) 2002 Bob Beck <beck@openbsd.org>
3 * Copyright (c) 2002 Theo de Raadt 3 * Copyright (c) 2002 Theo de Raadt
4 * Copyright (c) 2002 Markus Friedl
4 * All rights reserved. 5 * All rights reserved.
5 * 6 *
6 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
@@ -28,33 +29,85 @@
28 * 29 *
29 */ 30 */
30 31
31#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)
32#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>
33#include <crypto/cryptodev.h> 58#include <crypto/cryptodev.h>
34#include <sys/ioctl.h> 59#include <sys/ioctl.h>
35#include <errno.h> 60#include <errno.h>
36#include <stdio.h> 61#include <stdio.h>
37#include <unistd.h> 62#include <unistd.h>
38#include <fcntl.h> 63#include <fcntl.h>
39#include <syslog.h>
40#include <stdarg.h> 64#include <stdarg.h>
41#include <ssl/objects.h> 65#include <syslog.h>
42#include <ssl/engine.h> 66#include <errno.h>
43#include <ssl/evp.h> 67#include <string.h>
44 68
45static int cryptodev_fd = -1; 69struct dev_crypto_state {
46static int cryptodev_sessions = 0; 70 struct session_op d_sess;
47static u_int32_t cryptodev_symfeat = 0; 71 int d_fd;
72};
48 73
74static u_int32_t cryptodev_asymfeat = 0;
75
76static int get_asym_dev_crypto(void);
77static int open_dev_crypto(void);
78static int get_dev_crypto(void);
79static int cryptodev_max_iv(int cipher);
80static int cryptodev_key_length_valid(int cipher, int len);
81static int cipher_nid_to_cryptodev(int nid);
82static int get_cryptodev_ciphers(const int **cnids);
83static int get_cryptodev_digests(const int **cnids);
84static int cryptodev_usable_ciphers(const int **nids);
85static int cryptodev_usable_digests(const int **nids);
86static int cryptodev_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
87 const unsigned char *in, unsigned int inl);
88static int cryptodev_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key,
89 const unsigned char *iv, int enc);
90static int cryptodev_cleanup(EVP_CIPHER_CTX *ctx);
91static int cryptodev_engine_ciphers(ENGINE *e, const EVP_CIPHER **cipher,
92 const int **nids, int nid);
93static int cryptodev_engine_digests(ENGINE *e, const EVP_MD **digest,
94 const int **nids, int nid);
49static int bn2crparam(const BIGNUM *a, struct crparam *crp); 95static int bn2crparam(const BIGNUM *a, struct crparam *crp);
50static int crparam2bn(struct crparam *crp, BIGNUM *a); 96static int crparam2bn(struct crparam *crp, BIGNUM *a);
51static void zapparams(struct crypt_kop *kop); 97static void zapparams(struct crypt_kop *kop);
98static int cryptodev_asym(struct crypt_kop *kop, int rlen, BIGNUM *r,
99 int slen, BIGNUM *s);
52 100
53static int cryptodev_rsa_mod_exp(BIGNUM *r0, const BIGNUM *I, RSA *rsa);
54static int cryptodev_bn_mod_exp(BIGNUM *r, const BIGNUM *a, 101static int cryptodev_bn_mod_exp(BIGNUM *r, const BIGNUM *a,
55 const BIGNUM *p, const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx); 102 const BIGNUM *p, const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx);
103static int cryptodev_rsa_nocrt_mod_exp(BIGNUM *r0, const BIGNUM *I,
104 RSA *rsa);
105static int cryptodev_rsa_mod_exp(BIGNUM *r0, const BIGNUM *I, RSA *rsa);
56static int cryptodev_dsa_bn_mod_exp(DSA *dsa, BIGNUM *r, BIGNUM *a, 106static int cryptodev_dsa_bn_mod_exp(DSA *dsa, BIGNUM *r, BIGNUM *a,
57 const BIGNUM *p, const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx); 107 const BIGNUM *p, const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx);
108static int cryptodev_dsa_dsa_mod_exp(DSA *dsa, BIGNUM *t1, BIGNUM *g,
109 BIGNUM *u1, BIGNUM *pub_key, BIGNUM *u2, BIGNUM *p,
110 BN_CTX *ctx, BN_MONT_CTX *mont);
58static DSA_SIG *cryptodev_dsa_do_sign(const unsigned char *dgst, 111static DSA_SIG *cryptodev_dsa_do_sign(const unsigned char *dgst,
59 int dlen, DSA *dsa); 112 int dlen, DSA *dsa);
60static int cryptodev_dsa_verify(const unsigned char *dgst, int dgst_len, 113static int cryptodev_dsa_verify(const unsigned char *dgst, int dgst_len,
@@ -64,6 +117,9 @@ static int cryptodev_mod_exp_dh(const DH *dh, BIGNUM *r, const BIGNUM *a,
64 BN_MONT_CTX *m_ctx); 117 BN_MONT_CTX *m_ctx);
65static int cryptodev_dh_compute_key(unsigned char *key, 118static int cryptodev_dh_compute_key(unsigned char *key,
66 const BIGNUM *pub_key, DH *dh); 119 const BIGNUM *pub_key, DH *dh);
120static int cryptodev_ctrl(ENGINE *e, int cmd, long i, void *p,
121 void (*f)());
122void ENGINE_load_cryptodev(void);
67 123
68static const ENGINE_CMD_DEFN cryptodev_defns[] = { 124static const ENGINE_CMD_DEFN cryptodev_defns[] = {
69 { 0, NULL, NULL, 0 } 125 { 0, NULL, NULL, 0 }
@@ -77,11 +133,10 @@ static struct {
77} ciphers[] = { 133} ciphers[] = {
78 { CRYPTO_DES_CBC, NID_des_cbc, 8, 8, }, 134 { CRYPTO_DES_CBC, NID_des_cbc, 8, 8, },
79 { CRYPTO_3DES_CBC, NID_des_ede3_cbc, 8, 24, }, 135 { CRYPTO_3DES_CBC, NID_des_ede3_cbc, 8, 24, },
80 { CRYPTO_AES_CBC, NID_undef, 8, 24, }, 136 { CRYPTO_AES_CBC, NID_aes_128_cbc, 16, 16, },
81 { CRYPTO_BLF_CBC, NID_bf_cbc, 8, 16, }, 137 { CRYPTO_BLF_CBC, NID_bf_cbc, 8, 16, },
82 { CRYPTO_CAST_CBC, NID_cast5_cbc, 8, 8, }, 138 { CRYPTO_CAST_CBC, NID_cast5_cbc, 8, 16, },
83 { CRYPTO_SKIPJACK_CBC, NID_undef, 0, 0, }, 139 { CRYPTO_SKIPJACK_CBC, NID_undef, 0, 0, },
84 { CRYPTO_ARC4, NID_rc4, 8, 16, },
85 { 0, NID_undef, 0, 0, }, 140 { 0, NID_undef, 0, 0, },
86}; 141};
87 142
@@ -99,33 +154,53 @@ static struct {
99}; 154};
100 155
101/* 156/*
102 * Return 1 if /dev/crypto seems usable, 0 otherwise , also 157 * Return a fd if /dev/crypto seems usable, 0 otherwise.
103 * does most of the work of initting the device, if not already
104 * done.. This should leave is with global fd initialized with CRIOGET.
105 */ 158 */
106static int 159static int
107check_dev_crypto() 160open_dev_crypto(void)
108{ 161{
109 int fd; 162 static int fd = -1;
110 163
111 if (cryptodev_fd == -1) { 164 if (fd == -1) {
112 if ((fd = open("/dev/crypto", O_RDWR, 0)) == -1) 165 if ((fd = open("/dev/crypto", O_RDWR, 0)) == -1)
113 return (0); 166 return (-1);
114 if (ioctl(fd, CRIOGET, &cryptodev_fd) == -1) {
115 close(fd);
116 return (0);
117 }
118 close(fd);
119 /* close on exec */ 167 /* close on exec */
120 if (fcntl(cryptodev_fd, F_SETFD, 1) == -1) { 168 if (fcntl(fd, F_SETFD, 1) == -1) {
121 close(cryptodev_fd); 169 close(fd);
122 cryptodev_fd = -1; 170 fd = -1;
123 return (0); 171 return (-1);
124 } 172 }
125 } 173 }
126 ioctl(cryptodev_fd, CIOCSYMFEAT, &cryptodev_symfeat); 174 return (fd);
175}
127 176
128 return (1); 177static int
178get_dev_crypto(void)
179{
180 int fd, retfd;
181
182 if ((fd = open_dev_crypto()) == -1)
183 return (-1);
184 if (ioctl(fd, CRIOGET, &retfd) == -1)
185 return (-1);
186
187 /* close on exec */
188 if (fcntl(retfd, F_SETFD, 1) == -1) {
189 close(retfd);
190 return (-1);
191 }
192 return (retfd);
193}
194
195/* Caching version for asym operations */
196static int
197get_asym_dev_crypto(void)
198{
199 static int fd = -1;
200
201 if (fd == -1)
202 fd = get_dev_crypto();
203 return fd;
129} 204}
130 205
131/* 206/*
@@ -183,8 +258,12 @@ get_cryptodev_ciphers(const int **cnids)
183{ 258{
184 static int nids[CRYPTO_ALGORITHM_MAX]; 259 static int nids[CRYPTO_ALGORITHM_MAX];
185 struct session_op sess; 260 struct session_op sess;
186 int i, count = 0; 261 int fd, i, count = 0;
187 262
263 if ((fd = get_dev_crypto()) < 0) {
264 *nids = NULL;
265 return (0);
266 }
188 memset(&sess, 0, sizeof(sess)); 267 memset(&sess, 0, sizeof(sess));
189 sess.key = (caddr_t)"123456781234567812345678"; 268 sess.key = (caddr_t)"123456781234567812345678";
190 269
@@ -194,10 +273,12 @@ get_cryptodev_ciphers(const int **cnids)
194 sess.cipher = ciphers[i].id; 273 sess.cipher = ciphers[i].id;
195 sess.keylen = ciphers[i].keylen; 274 sess.keylen = ciphers[i].keylen;
196 sess.mac = 0; 275 sess.mac = 0;
197 if (ioctl(cryptodev_fd, CIOCGSESSION, &sess) != -1 && 276 if (ioctl(fd, CIOCGSESSION, &sess) != -1 &&
198 ioctl(cryptodev_fd, CIOCFSESSION, &sess.ses) != -1) 277 ioctl(fd, CIOCFSESSION, &sess.ses) != -1)
199 nids[count++] = ciphers[i].nid; 278 nids[count++] = ciphers[i].nid;
200 } 279 }
280 close(fd);
281
201 if (count > 0) 282 if (count > 0)
202 *cnids = nids; 283 *cnids = nids;
203 else 284 else
@@ -216,18 +297,24 @@ get_cryptodev_digests(const int **cnids)
216{ 297{
217 static int nids[CRYPTO_ALGORITHM_MAX]; 298 static int nids[CRYPTO_ALGORITHM_MAX];
218 struct session_op sess; 299 struct session_op sess;
219 int i, count = 0; 300 int fd, i, count = 0;
220 301
302 if ((fd = get_dev_crypto()) < 0) {
303 *nids = NULL;
304 return (0);
305 }
221 memset(&sess, 0, sizeof(sess)); 306 memset(&sess, 0, sizeof(sess));
222 for (i = 0; digests[i].id && count < CRYPTO_ALGORITHM_MAX; i++) { 307 for (i = 0; digests[i].id && count < CRYPTO_ALGORITHM_MAX; i++) {
223 if (digests[i].nid == NID_undef) 308 if (digests[i].nid == NID_undef)
224 continue; 309 continue;
225 sess.mac = digests[i].id; 310 sess.mac = digests[i].id;
226 sess.cipher = 0; 311 sess.cipher = 0;
227 if (ioctl(cryptodev_fd, CIOCGSESSION, &sess) != -1 && 312 if (ioctl(fd, CIOCGSESSION, &sess) != -1 &&
228 ioctl(cryptodev_fd, CIOCFSESSION, &sess.ses) != -1) 313 ioctl(fd, CIOCFSESSION, &sess.ses) != -1)
229 nids[count++] = digests[i].nid; 314 nids[count++] = digests[i].nid;
230 } 315 }
316 close(fd);
317
231 if (count > 0) 318 if (count > 0)
232 *cnids = nids; 319 *cnids = nids;
233 else 320 else
@@ -256,25 +343,15 @@ get_cryptodev_digests(const int **cnids)
256 * want most of the decisions made about what we actually want 343 * want most of the decisions made about what we actually want
257 * to use from /dev/crypto. 344 * to use from /dev/crypto.
258 */ 345 */
259int 346static int
260cryptodev_usable_ciphers(const int **nids) 347cryptodev_usable_ciphers(const int **nids)
261{ 348{
262 if (!check_dev_crypto()) {
263 *nids = NULL;
264 return (0);
265 }
266
267 /* find what the device can do. Unfortunately, we don't
268 * necessarily want all of these yet, because we aren't
269 * yet set up to do them
270 */
271 return (get_cryptodev_ciphers(nids)); 349 return (get_cryptodev_ciphers(nids));
272} 350}
273 351
274int 352static int
275cryptodev_usable_digests(const int **nids) 353cryptodev_usable_digests(const int **nids)
276{ 354{
277#if 1
278 /* 355 /*
279 * XXXX just disable all digests for now, because it sucks. 356 * XXXX just disable all digests for now, because it sucks.
280 * we need a better way to decide this - i.e. I may not 357 * we need a better way to decide this - i.e. I may not
@@ -289,29 +366,19 @@ cryptodev_usable_digests(const int **nids)
289 */ 366 */
290 *nids = NULL; 367 *nids = NULL;
291 return (0); 368 return (0);
292#endif
293
294 if (!check_dev_crypto()) {
295 *nids = NULL;
296 return (0);
297 }
298 return (get_cryptodev_digests(nids));
299} 369}
300 370
301 371static int
302int
303cryptodev_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, 372cryptodev_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
304 const unsigned char *in, unsigned int inl) 373 const unsigned char *in, unsigned int inl)
305{ 374{
306 struct crypt_op cryp; 375 struct crypt_op cryp;
307 struct session_op *sess = ctx->cipher_data; 376 struct dev_crypto_state *state = ctx->cipher_data;
377 struct session_op *sess = &state->d_sess;
308 void *iiv; 378 void *iiv;
309 unsigned char save_iv[EVP_MAX_IV_LENGTH]; 379 unsigned char save_iv[EVP_MAX_IV_LENGTH];
310 struct syslog_data sd = SYSLOG_DATA_INIT;
311 380
312 if (cryptodev_fd == -1) 381 if (state->d_fd < 0)
313 return (0);
314 if (sess == NULL)
315 return (0); 382 return (0);
316 if (!inl) 383 if (!inl)
317 return (1); 384 return (1);
@@ -338,11 +405,10 @@ cryptodev_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
338 } else 405 } else
339 cryp.iv = NULL; 406 cryp.iv = NULL;
340 407
341 if (ioctl(cryptodev_fd, CIOCCRYPT, &cryp) == -1) { 408 if (ioctl(state->d_fd, CIOCCRYPT, &cryp) == -1) {
342 /* XXX need better errror handling 409 /* XXX need better errror handling
343 * this can fail for a number of different reasons. 410 * this can fail for a number of different reasons.
344 */ 411 */
345 syslog_r(LOG_ERR, &sd, "CIOCCRYPT failed (%m)");
346 return (0); 412 return (0);
347 } 413 }
348 414
@@ -356,20 +422,17 @@ cryptodev_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
356 return (1); 422 return (1);
357} 423}
358 424
359int 425static int
360cryptodev_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key, 426cryptodev_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key,
361 const unsigned char *iv, int enc) 427 const unsigned char *iv, int enc)
362{ 428{
363 struct session_op *sess = ctx->cipher_data; 429 struct dev_crypto_state *state = ctx->cipher_data;
364 struct syslog_data sd = SYSLOG_DATA_INIT; 430 struct session_op *sess = &state->d_sess;
365 int cipher; 431 int cipher;
366 432
367 if ((cipher = cipher_nid_to_cryptodev(ctx->cipher->nid)) == NID_undef) 433 if ((cipher = cipher_nid_to_cryptodev(ctx->cipher->nid)) == NID_undef)
368 return (0); 434 return (0);
369 435
370 if (!check_dev_crypto())
371 return (0);
372
373 if (ctx->cipher->iv_len > cryptodev_max_iv(cipher)) 436 if (ctx->cipher->iv_len > cryptodev_max_iv(cipher))
374 return (0); 437 return (0);
375 438
@@ -378,15 +441,18 @@ cryptodev_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key,
378 441
379 memset(sess, 0, sizeof(struct session_op)); 442 memset(sess, 0, sizeof(struct session_op));
380 443
444 if ((state->d_fd = get_dev_crypto()) < 0)
445 return (0);
446
381 sess->key = (unsigned char *)key; 447 sess->key = (unsigned char *)key;
382 sess->keylen = ctx->key_len; 448 sess->keylen = ctx->key_len;
383 sess->cipher = cipher; 449 sess->cipher = cipher;
384 450
385 if (ioctl(cryptodev_fd, CIOCGSESSION, sess) == -1) { 451 if (ioctl(state->d_fd, CIOCGSESSION, sess) == -1) {
386 syslog_r(LOG_ERR, &sd, "CIOCGSESSION failed (%m)"); 452 close(state->d_fd);
453 state->d_fd = -1;
387 return (0); 454 return (0);
388 } 455 }
389 cryptodev_sessions++;
390 return (1); 456 return (1);
391} 457}
392 458
@@ -394,14 +460,14 @@ cryptodev_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key,
394 * free anything we allocated earlier when initting a 460 * free anything we allocated earlier when initting a
395 * session, and close the session. 461 * session, and close the session.
396 */ 462 */
397int 463static int
398cryptodev_cleanup(EVP_CIPHER_CTX *ctx) 464cryptodev_cleanup(EVP_CIPHER_CTX *ctx)
399{ 465{
400 int ret = 0; 466 int ret = 0;
401 struct session_op *sess = ctx->cipher_data; 467 struct dev_crypto_state *state = ctx->cipher_data;
402 struct syslog_data sd = SYSLOG_DATA_INIT; 468 struct session_op *sess = &state->d_sess;
403 469
404 if (sess == NULL) 470 if (state->d_fd < 0)
405 return (0); 471 return (0);
406 472
407 /* XXX if this ioctl fails, someting's wrong. the invoker 473 /* XXX if this ioctl fails, someting's wrong. the invoker
@@ -415,17 +481,14 @@ cryptodev_cleanup(EVP_CIPHER_CTX *ctx)
415 * print messages to users of the library. hmm.. 481 * print messages to users of the library. hmm..
416 */ 482 */
417 483
418 if (ioctl(cryptodev_fd, CIOCFSESSION, &sess->ses) == -1) { 484 if (ioctl(state->d_fd, CIOCFSESSION, &sess->ses) == -1) {
419 syslog_r(LOG_ERR, &sd, "CIOCFSESSION failed (%m)");
420 ret = 0; 485 ret = 0;
421 } else { 486 } else {
422 cryptodev_sessions--;
423 ret = 1; 487 ret = 1;
424 } 488 }
425 if (cryptodev_sessions == 0 && cryptodev_fd != -1 ) { 489 close(state->d_fd);
426 close(cryptodev_fd); /* XXX should this be closed? */ 490 state->d_fd = -1;
427 cryptodev_fd = -1; 491
428 }
429 return (ret); 492 return (ret);
430} 493}
431 494
@@ -434,20 +497,6 @@ cryptodev_cleanup(EVP_CIPHER_CTX *ctx)
434 * gets called when libcrypto requests a cipher NID. 497 * gets called when libcrypto requests a cipher NID.
435 */ 498 */
436 499
437/* ARC4 (16 byte key) */
438const EVP_CIPHER cryptodev_arc4_cipher = {
439 NID_rc4,
440 1, 16, 0,
441 EVP_CIPH_VARIABLE_LENGTH,
442 cryptodev_init_key,
443 cryptodev_cipher,
444 cryptodev_cleanup,
445 sizeof(struct session_op),
446 NULL,
447 NULL,
448 NULL
449};
450
451/* DES CBC EVP */ 500/* DES CBC EVP */
452const EVP_CIPHER cryptodev_des_cbc = { 501const EVP_CIPHER cryptodev_des_cbc = {
453 NID_des_cbc, 502 NID_des_cbc,
@@ -456,7 +505,7 @@ const EVP_CIPHER cryptodev_des_cbc = {
456 cryptodev_init_key, 505 cryptodev_init_key,
457 cryptodev_cipher, 506 cryptodev_cipher,
458 cryptodev_cleanup, 507 cryptodev_cleanup,
459 sizeof(struct session_op), 508 sizeof(struct dev_crypto_state),
460 EVP_CIPHER_set_asn1_iv, 509 EVP_CIPHER_set_asn1_iv,
461 EVP_CIPHER_get_asn1_iv, 510 EVP_CIPHER_get_asn1_iv,
462 NULL 511 NULL
@@ -470,19 +519,57 @@ const EVP_CIPHER cryptodev_3des_cbc = {
470 cryptodev_init_key, 519 cryptodev_init_key,
471 cryptodev_cipher, 520 cryptodev_cipher,
472 cryptodev_cleanup, 521 cryptodev_cleanup,
473 sizeof(struct session_op), 522 sizeof(struct dev_crypto_state),
523 EVP_CIPHER_set_asn1_iv,
524 EVP_CIPHER_get_asn1_iv,
525 NULL
526};
527
528const EVP_CIPHER cryptodev_bf_cbc = {
529 NID_bf_cbc,
530 8, 16, 8,
531 EVP_CIPH_CBC_MODE,
532 cryptodev_init_key,
533 cryptodev_cipher,
534 cryptodev_cleanup,
535 sizeof(struct dev_crypto_state),
536 EVP_CIPHER_set_asn1_iv,
537 EVP_CIPHER_get_asn1_iv,
538 NULL
539};
540
541const EVP_CIPHER cryptodev_cast_cbc = {
542 NID_cast5_cbc,
543 8, 16, 8,
544 EVP_CIPH_CBC_MODE,
545 cryptodev_init_key,
546 cryptodev_cipher,
547 cryptodev_cleanup,
548 sizeof(struct dev_crypto_state),
474 EVP_CIPHER_set_asn1_iv, 549 EVP_CIPHER_set_asn1_iv,
475 EVP_CIPHER_get_asn1_iv, 550 EVP_CIPHER_get_asn1_iv,
476 NULL 551 NULL
477}; 552};
478 553
554const EVP_CIPHER cryptodev_aes_cbc = {
555 NID_aes_128_cbc,
556 16, 16, 16,
557 EVP_CIPH_CBC_MODE,
558 cryptodev_init_key,
559 cryptodev_cipher,
560 cryptodev_cleanup,
561 sizeof(struct dev_crypto_state),
562 EVP_CIPHER_set_asn1_iv,
563 EVP_CIPHER_get_asn1_iv,
564 NULL
565};
479 566
480/* 567/*
481 * Registered by the ENGINE when used to find out how to deal with 568 * Registered by the ENGINE when used to find out how to deal with
482 * a particular NID in the ENGINE. this says what we'll do at the 569 * a particular NID in the ENGINE. this says what we'll do at the
483 * top level - note, that list is restricted by what we answer with 570 * top level - note, that list is restricted by what we answer with
484 */ 571 */
485int 572static int
486cryptodev_engine_ciphers(ENGINE *e, const EVP_CIPHER **cipher, 573cryptodev_engine_ciphers(ENGINE *e, const EVP_CIPHER **cipher,
487 const int **nids, int nid) 574 const int **nids, int nid)
488{ 575{
@@ -490,15 +577,21 @@ cryptodev_engine_ciphers(ENGINE *e, const EVP_CIPHER **cipher,
490 return (cryptodev_usable_ciphers(nids)); 577 return (cryptodev_usable_ciphers(nids));
491 578
492 switch (nid) { 579 switch (nid) {
493 case NID_rc4:
494 *cipher = &cryptodev_arc4_cipher;
495 break;
496 case NID_des_ede3_cbc: 580 case NID_des_ede3_cbc:
497 *cipher = &cryptodev_3des_cbc; 581 *cipher = &cryptodev_3des_cbc;
498 break; 582 break;
499 case NID_des_cbc: 583 case NID_des_cbc:
500 *cipher = &cryptodev_des_cbc; 584 *cipher = &cryptodev_des_cbc;
501 break; 585 break;
586 case NID_bf_cbc:
587 *cipher = &cryptodev_bf_cbc;
588 break;
589 case NID_cast5_cbc:
590 *cipher = &cryptodev_cast_cbc;
591 break;
592 case NID_aes_128_cbc:
593 *cipher = &cryptodev_aes_cbc;
594 break;
502 default: 595 default:
503 *cipher = NULL; 596 *cipher = NULL;
504 break; 597 break;
@@ -506,7 +599,7 @@ cryptodev_engine_ciphers(ENGINE *e, const EVP_CIPHER **cipher,
506 return (*cipher != NULL); 599 return (*cipher != NULL);
507} 600}
508 601
509int 602static int
510cryptodev_engine_digests(ENGINE *e, const EVP_MD **digest, 603cryptodev_engine_digests(ENGINE *e, const EVP_MD **digest,
511 const int **nids, int nid) 604 const int **nids, int nid)
512{ 605{
@@ -524,7 +617,6 @@ cryptodev_engine_digests(ENGINE *e, const EVP_MD **digest,
524 return (*digest != NULL); 617 return (*digest != NULL);
525} 618}
526 619
527
528/* 620/*
529 * Convert a BIGNUM to the representation that /dev/crypto needs. 621 * Convert a BIGNUM to the representation that /dev/crypto needs.
530 * Upon completion of use, the caller is responsible for freeing 622 * Upon completion of use, the caller is responsible for freeing
@@ -533,7 +625,7 @@ cryptodev_engine_digests(ENGINE *e, const EVP_MD **digest,
533static int 625static int
534bn2crparam(const BIGNUM *a, struct crparam *crp) 626bn2crparam(const BIGNUM *a, struct crparam *crp)
535{ 627{
536 int i, j, n; 628 int i, j, k;
537 ssize_t words, bytes, bits; 629 ssize_t words, bytes, bits;
538 u_char *b; 630 u_char *b;
539 631
@@ -550,17 +642,13 @@ bn2crparam(const BIGNUM *a, struct crparam *crp)
550 crp->crp_p = b; 642 crp->crp_p = b;
551 crp->crp_nbits = bits; 643 crp->crp_nbits = bits;
552 644
553 words = (bits + BN_BITS2 - 1) / BN_BITS2; 645 for (i = 0, j = 0; i < a->top; i++) {
554 646 for (k = 0; k < BN_BITS2 / 8; k++) {
555 n = 0; 647 if ((j + k) >= bytes)
556 for (i = 0; i < words && n < bytes; i++) { 648 return (0);
557 BN_ULONG word; 649 b[j + k] = a->d[i] >> (k * 8);
558
559 word = a->d[i];
560 for (j = 0 ; j < BN_BYTES && n < bytes; j++, n++) {
561 *b++ = (word & 0xff);
562 word >>= 8;
563 } 650 }
651 j += BN_BITS2 / 8;
564 } 652 }
565 return (0); 653 return (0);
566} 654}
@@ -569,15 +657,22 @@ bn2crparam(const BIGNUM *a, struct crparam *crp)
569static int 657static int
570crparam2bn(struct crparam *crp, BIGNUM *a) 658crparam2bn(struct crparam *crp, BIGNUM *a)
571{ 659{
660 u_int8_t *pd;
572 int i, bytes; 661 int i, bytes;
573 662
574 bytes = (crp->crp_nbits + 7)/8; 663 bytes = (crp->crp_nbits + 7) / 8;
575 664
576 BN_zero(a); 665 if (bytes == 0)
577 for (i = bytes - 1; i >= 0; i--) { 666 return (-1);
578 BN_lshift(a, a, 8); 667
579 BN_add_word(a, (u_char)crp->crp_p[i]); 668 if ((pd = (u_int8_t *) malloc(bytes)) == NULL)
580 } 669 return (-1);
670
671 for (i = 0; i < bytes; i++)
672 pd[i] = crp->crp_p[bytes - i - 1];
673
674 BN_bin2bn(pd, bytes, a);
675 free(pd);
581 676
582 return (0); 677 return (0);
583} 678}
@@ -596,25 +691,32 @@ zapparams(struct crypt_kop *kop)
596} 691}
597 692
598static int 693static int
599cryptodev_sym(struct crypt_kop *kop, BIGNUM *r, BIGNUM *s) 694cryptodev_asym(struct crypt_kop *kop, int rlen, BIGNUM *r, int slen, BIGNUM *s)
600{ 695{
601 int ret = -1; 696 int fd, ret = -1;
697
698 if ((fd = get_asym_dev_crypto()) < 0)
699 return (ret);
602 700
603 if (r) { 701 if (r) {
604 kop->crk_param[kop->crk_iparams].crp_p = malloc(256); 702 kop->crk_param[kop->crk_iparams].crp_p = calloc(rlen, sizeof(char));
605 kop->crk_param[kop->crk_iparams].crp_nbits = 256 * 8; 703 kop->crk_param[kop->crk_iparams].crp_nbits = rlen * 8;
606 kop->crk_oparams++; 704 kop->crk_oparams++;
607 } 705 }
608 if (s) { 706 if (s) {
609 kop->crk_param[kop->crk_iparams+1].crp_p = malloc(256); 707 kop->crk_param[kop->crk_iparams+1].crp_p = calloc(slen, sizeof(char));
610 kop->crk_param[kop->crk_iparams+1].crp_nbits = 256 * 8; 708 kop->crk_param[kop->crk_iparams+1].crp_nbits = slen * 8;
611 kop->crk_oparams++; 709 kop->crk_oparams++;
612 } 710 }
613 711
614 if (ioctl(cryptodev_fd, CIOCKEY, &kop) == 0) { 712 if (ioctl(fd, CIOCKEY, kop) == 0) {
615 crparam2bn(&kop->crk_param[3], r); 713 if (r)
714 crparam2bn(&kop->crk_param[kop->crk_iparams], r);
715 if (s)
716 crparam2bn(&kop->crk_param[kop->crk_iparams+1], s);
616 ret = 0; 717 ret = 0;
617 } 718 }
719
618 return (ret); 720 return (ret);
619} 721}
620 722
@@ -623,38 +725,58 @@ cryptodev_bn_mod_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
623 const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *in_mont) 725 const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *in_mont)
624{ 726{
625 struct crypt_kop kop; 727 struct crypt_kop kop;
626 int ret = 0; 728 int ret = 1;
729
730 /* Currently, we know we can do mod exp iff we can do any
731 * asymmetric operations at all.
732 */
733 if (cryptodev_asymfeat == 0) {
734 ret = BN_mod_exp(r, a, p, m, ctx);
735 return (ret);
736 }
627 737
628 memset(&kop, 0, sizeof kop); 738 memset(&kop, 0, sizeof kop);
629 kop.crk_op = CRK_MOD_EXP; 739 kop.crk_op = CRK_MOD_EXP;
630 740
631 /* inputs: a m p */ 741 /* inputs: a^p % m */
632 if (bn2crparam(a, &kop.crk_param[0])) 742 if (bn2crparam(a, &kop.crk_param[0]))
633 goto err; 743 goto err;
634 if (bn2crparam(m, &kop.crk_param[1])) 744 if (bn2crparam(p, &kop.crk_param[1]))
635 goto err; 745 goto err;
636 if (bn2crparam(p, &kop.crk_param[2])) 746 if (bn2crparam(m, &kop.crk_param[2]))
637 goto err; 747 goto err;
638 kop.crk_iparams = 3; 748 kop.crk_iparams = 3;
639 749
640 if (cryptodev_sym(&kop, r, NULL) == -1) { 750 if (cryptodev_asym(&kop, BN_num_bytes(m), r, 0, NULL) == -1) {
641 ret = BN_mod_exp(r, a, p, m, ctx); 751 const RSA_METHOD *meth = RSA_PKCS1_SSLeay();
752 ret = meth->bn_mod_exp(r, a, p, m, ctx, in_mont);
642 } 753 }
643err: 754err:
644 zapparams(&kop); 755 zapparams(&kop);
645 return (ret); 756 return (ret);
646} 757}
647 758
759static int
760cryptodev_rsa_nocrt_mod_exp(BIGNUM *r0, const BIGNUM *I, RSA *rsa)
761{
762 int r;
763 BN_CTX *ctx;
764
765 ctx = BN_CTX_new();
766 r = cryptodev_bn_mod_exp(r0, I, rsa->d, rsa->n, ctx, NULL);
767 BN_CTX_free(ctx);
768 return (r);
769}
648 770
649static int 771static int
650cryptodev_rsa_mod_exp(BIGNUM *r0, const BIGNUM *I, RSA *rsa) 772cryptodev_rsa_mod_exp(BIGNUM *r0, const BIGNUM *I, RSA *rsa)
651{ 773{
652 struct crypt_kop kop; 774 struct crypt_kop kop;
653 int ret = 0; 775 int ret = 1;
654 776
655 if (!rsa->p || !rsa->q || !rsa->dmp1 || !rsa->dmq1 || !rsa->iqmp) { 777 if (!rsa->p || !rsa->q || !rsa->dmp1 || !rsa->dmq1 || !rsa->iqmp) {
656 /* XXX 0 means failure?? */ 778 /* XXX 0 means failure?? */
657 goto err; 779 return (0);
658 } 780 }
659 781
660 memset(&kop, 0, sizeof kop); 782 memset(&kop, 0, sizeof kop);
@@ -674,9 +796,8 @@ cryptodev_rsa_mod_exp(BIGNUM *r0, const BIGNUM *I, RSA *rsa)
674 goto err; 796 goto err;
675 kop.crk_iparams = 6; 797 kop.crk_iparams = 6;
676 798
677 if (cryptodev_sym(&kop, r0, NULL) == -1) { 799 if (cryptodev_asym(&kop, BN_num_bytes(rsa->n), r0, 0, NULL) == -1) {
678 const RSA_METHOD *meth = RSA_PKCS1_SSLeay(); 800 const RSA_METHOD *meth = RSA_PKCS1_SSLeay();
679
680 ret = (*meth->rsa_mod_exp)(r0, I, rsa); 801 ret = (*meth->rsa_mod_exp)(r0, I, rsa);
681 } 802 }
682err: 803err:
@@ -690,8 +811,8 @@ static RSA_METHOD cryptodev_rsa = {
690 NULL, /* rsa_pub_dec */ 811 NULL, /* rsa_pub_dec */
691 NULL, /* rsa_priv_enc */ 812 NULL, /* rsa_priv_enc */
692 NULL, /* rsa_priv_dec */ 813 NULL, /* rsa_priv_dec */
693 cryptodev_rsa_mod_exp, /* rsa_mod_exp */ 814 NULL,
694 cryptodev_bn_mod_exp, /* bn_mod_exp */ 815 NULL,
695 NULL, /* init */ 816 NULL, /* init */
696 NULL, /* finish */ 817 NULL, /* finish */
697 0, /* flags */ 818 0, /* flags */
@@ -707,6 +828,38 @@ cryptodev_dsa_bn_mod_exp(DSA *dsa, BIGNUM *r, BIGNUM *a, const BIGNUM *p,
707 return (cryptodev_bn_mod_exp(r, a, p, m, ctx, m_ctx)); 828 return (cryptodev_bn_mod_exp(r, a, p, m, ctx, m_ctx));
708} 829}
709 830
831static int
832cryptodev_dsa_dsa_mod_exp(DSA *dsa, BIGNUM *t1, BIGNUM *g,
833 BIGNUM *u1, BIGNUM *pub_key, BIGNUM *u2, BIGNUM *p,
834 BN_CTX *ctx, BN_MONT_CTX *mont)
835{
836 BIGNUM t2;
837 int ret = 0;
838
839 BN_init(&t2);
840
841 /* v = ( g^u1 * y^u2 mod p ) mod q */
842 /* let t1 = g ^ u1 mod p */
843 ret = 0;
844
845 if (!dsa->meth->bn_mod_exp(dsa,t1,dsa->g,u1,dsa->p,ctx,mont))
846 goto err;
847
848 /* let t2 = y ^ u2 mod p */
849 if (!dsa->meth->bn_mod_exp(dsa,&t2,dsa->pub_key,u2,dsa->p,ctx,mont))
850 goto err;
851 /* let u1 = t1 * t2 mod p */
852 if (!BN_mod_mul(u1,t1,&t2,dsa->p,ctx))
853 goto err;
854
855 BN_copy(t1,u1);
856
857 ret = 1;
858err:
859 BN_free(&t2);
860 return(ret);
861}
862
710static DSA_SIG * 863static DSA_SIG *
711cryptodev_dsa_do_sign(const unsigned char *dgst, int dlen, DSA *dsa) 864cryptodev_dsa_do_sign(const unsigned char *dgst, int dlen, DSA *dsa)
712{ 865{
@@ -721,6 +874,7 @@ cryptodev_dsa_do_sign(const unsigned char *dgst, int dlen, DSA *dsa)
721 goto err; 874 goto err;
722 } 875 }
723 876
877 printf("bar\n");
724 memset(&kop, 0, sizeof kop); 878 memset(&kop, 0, sizeof kop);
725 kop.crk_op = CRK_DSA_SIGN; 879 kop.crk_op = CRK_DSA_SIGN;
726 880
@@ -737,13 +891,13 @@ cryptodev_dsa_do_sign(const unsigned char *dgst, int dlen, DSA *dsa)
737 goto err; 891 goto err;
738 kop.crk_iparams = 5; 892 kop.crk_iparams = 5;
739 893
740 if (cryptodev_sym(&kop, r, s) == 0) { 894 if (cryptodev_asym(&kop, BN_num_bytes(dsa->q), r,
895 BN_num_bytes(dsa->q), s) == 0) {
741 dsaret = DSA_SIG_new(); 896 dsaret = DSA_SIG_new();
742 dsaret->r = r; 897 dsaret->r = r;
743 dsaret->s = s; 898 dsaret->s = s;
744 } else { 899 } else {
745 const DSA_METHOD *meth = DSA_OpenSSL(); 900 const DSA_METHOD *meth = DSA_OpenSSL();
746
747 BN_free(r); 901 BN_free(r);
748 BN_free(s); 902 BN_free(s);
749 dsaret = (meth->dsa_do_sign)(dgst, dlen, dsa); 903 dsaret = (meth->dsa_do_sign)(dgst, dlen, dsa);
@@ -759,7 +913,7 @@ cryptodev_dsa_verify(const unsigned char *dgst, int dlen,
759 DSA_SIG *sig, DSA *dsa) 913 DSA_SIG *sig, DSA *dsa)
760{ 914{
761 struct crypt_kop kop; 915 struct crypt_kop kop;
762 int dsaret = 0; 916 int dsaret = 1;
763 917
764 memset(&kop, 0, sizeof kop); 918 memset(&kop, 0, sizeof kop);
765 kop.crk_op = CRK_DSA_VERIFY; 919 kop.crk_op = CRK_DSA_VERIFY;
@@ -781,7 +935,7 @@ cryptodev_dsa_verify(const unsigned char *dgst, int dlen,
781 goto err; 935 goto err;
782 kop.crk_iparams = 7; 936 kop.crk_iparams = 7;
783 937
784 if (cryptodev_sym(&kop, NULL, NULL) == 0) { 938 if (cryptodev_asym(&kop, 0, NULL, 0, NULL) == 0) {
785 dsaret = kop.crk_status; 939 dsaret = kop.crk_status;
786 } else { 940 } else {
787 const DSA_METHOD *meth = DSA_OpenSSL(); 941 const DSA_METHOD *meth = DSA_OpenSSL();
@@ -796,11 +950,11 @@ err:
796 950
797static DSA_METHOD cryptodev_dsa = { 951static DSA_METHOD cryptodev_dsa = {
798 "cryptodev DSA method", 952 "cryptodev DSA method",
799 cryptodev_dsa_do_sign, 953 NULL,
800 NULL, /* dsa_sign_setup */ 954 NULL, /* dsa_sign_setup */
801 cryptodev_dsa_verify, 955 NULL,
802 NULL, /* dsa_mod_exp */ 956 NULL, /* dsa_mod_exp */
803 cryptodev_dsa_bn_mod_exp, /* bn_mod_exp */ 957 NULL,
804 NULL, /* init */ 958 NULL, /* init */
805 NULL, /* finish */ 959 NULL, /* finish */
806 0, /* flags */ 960 0, /* flags */
@@ -819,8 +973,14 @@ static int
819cryptodev_dh_compute_key(unsigned char *key, const BIGNUM *pub_key, DH *dh) 973cryptodev_dh_compute_key(unsigned char *key, const BIGNUM *pub_key, DH *dh)
820{ 974{
821 struct crypt_kop kop; 975 struct crypt_kop kop;
822 int dhret = 0; 976 int dhret = 1;
823 int keylen; 977 int fd, keylen;
978
979 if ((fd = get_asym_dev_crypto()) < 0) {
980 const DH_METHOD *meth = DH_OpenSSL();
981
982 return ((meth->compute_key)(key, pub_key, dh));
983 }
824 984
825 keylen = BN_num_bits(dh->p); 985 keylen = BN_num_bits(dh->p);
826 986
@@ -840,7 +1000,7 @@ cryptodev_dh_compute_key(unsigned char *key, const BIGNUM *pub_key, DH *dh)
840 kop.crk_param[3].crp_nbits = keylen * 8; 1000 kop.crk_param[3].crp_nbits = keylen * 8;
841 kop.crk_oparams = 1; 1001 kop.crk_oparams = 1;
842 1002
843 if (ioctl(cryptodev_fd, CIOCKEY, &kop) == -1) { 1003 if (ioctl(fd, CIOCKEY, &kop) == -1) {
844 const DH_METHOD *meth = DH_OpenSSL(); 1004 const DH_METHOD *meth = DH_OpenSSL();
845 1005
846 dhret = (meth->compute_key)(key, pub_key, dh); 1006 dhret = (meth->compute_key)(key, pub_key, dh);
@@ -854,8 +1014,8 @@ err:
854static DH_METHOD cryptodev_dh = { 1014static DH_METHOD cryptodev_dh = {
855 "cryptodev DH method", 1015 "cryptodev DH method",
856 NULL, /* cryptodev_dh_generate_key */ 1016 NULL, /* cryptodev_dh_generate_key */
857 cryptodev_dh_compute_key, 1017 NULL,
858 cryptodev_mod_exp_dh, 1018 NULL,
859 NULL, 1019 NULL,
860 NULL, 1020 NULL,
861 0, /* flags */ 1021 0, /* flags */
@@ -869,12 +1029,18 @@ static DH_METHOD cryptodev_dh = {
869static int 1029static int
870cryptodev_ctrl(ENGINE *e, int cmd, long i, void *p, void (*f)()) 1030cryptodev_ctrl(ENGINE *e, int cmd, long i, void *p, void (*f)())
871{ 1031{
1032#ifdef HAVE_SYSLOG_R
872 struct syslog_data sd = SYSLOG_DATA_INIT; 1033 struct syslog_data sd = SYSLOG_DATA_INIT;
1034#endif
873 1035
874 switch (cmd) { 1036 switch (cmd) {
875 default: 1037 default:
1038#ifdef HAVE_SYSLOG_R
876 syslog_r(LOG_ERR, &sd, 1039 syslog_r(LOG_ERR, &sd,
877 "cryptodev_ctrl: unknown command %d", cmd); 1040 "cryptodev_ctrl: unknown command %d", cmd);
1041#else
1042 syslog(LOG_ERR, "cryptodev_ctrl: unknown command %d", cmd);
1043#endif
878 break; 1044 break;
879 } 1045 }
880 return (1); 1046 return (1);
@@ -884,14 +1050,24 @@ void
884ENGINE_load_cryptodev(void) 1050ENGINE_load_cryptodev(void)
885{ 1051{
886 ENGINE *engine = ENGINE_new(); 1052 ENGINE *engine = ENGINE_new();
887 const RSA_METHOD *rsa_meth; 1053 int fd;
888 const DH_METHOD *dh_meth;
889 1054
890 if (engine == NULL) 1055 if (engine == NULL)
891 return; 1056 return;
1057 if ((fd = get_dev_crypto()) < 0)
1058 return;
1059
1060 /*
1061 * find out what asymmetric crypto algorithms we support
1062 */
1063 if (ioctl(fd, CIOCASYMFEAT, &cryptodev_asymfeat) == -1) {
1064 close(fd);
1065 return;
1066 }
1067 close(fd);
892 1068
893 if (!ENGINE_set_id(engine, "cryptodev") || 1069 if (!ENGINE_set_id(engine, "cryptodev") ||
894 !ENGINE_set_name(engine, "OpenBSD cryptodev engine") || 1070 !ENGINE_set_name(engine, "BSD cryptodev engine") ||
895 !ENGINE_set_ciphers(engine, cryptodev_engine_ciphers) || 1071 !ENGINE_set_ciphers(engine, cryptodev_engine_ciphers) ||
896 !ENGINE_set_digests(engine, cryptodev_engine_digests) || 1072 !ENGINE_set_digests(engine, cryptodev_engine_digests) ||
897 !ENGINE_set_ctrl_function(engine, cryptodev_ctrl) || 1073 !ENGINE_set_ctrl_function(engine, cryptodev_ctrl) ||
@@ -900,27 +1076,57 @@ ENGINE_load_cryptodev(void)
900 return; 1076 return;
901 } 1077 }
902 1078
903 if ((cryptodev_symfeat & CRSFEAT_RSA) && 1079 if (ENGINE_set_RSA(engine, &cryptodev_rsa)) {
904 ENGINE_set_RSA(engine, &cryptodev_rsa)) { 1080 const RSA_METHOD *rsa_meth = RSA_PKCS1_SSLeay();
905 rsa_meth = RSA_PKCS1_SSLeay(); 1081
1082 cryptodev_rsa.bn_mod_exp = rsa_meth->bn_mod_exp;
1083 cryptodev_rsa.rsa_mod_exp = rsa_meth->rsa_mod_exp;
906 cryptodev_rsa.rsa_pub_enc = rsa_meth->rsa_pub_enc; 1084 cryptodev_rsa.rsa_pub_enc = rsa_meth->rsa_pub_enc;
907 cryptodev_rsa.rsa_pub_dec = rsa_meth->rsa_pub_dec; 1085 cryptodev_rsa.rsa_pub_dec = rsa_meth->rsa_pub_dec;
908 cryptodev_rsa.rsa_priv_enc = rsa_meth->rsa_priv_dec; 1086 cryptodev_rsa.rsa_priv_enc = rsa_meth->rsa_priv_enc;
909 cryptodev_rsa.rsa_priv_dec = rsa_meth->rsa_priv_dec; 1087 cryptodev_rsa.rsa_priv_dec = rsa_meth->rsa_priv_dec;
1088 if (cryptodev_asymfeat & CRF_MOD_EXP) {
1089 cryptodev_rsa.bn_mod_exp = cryptodev_bn_mod_exp;
1090 if (cryptodev_asymfeat & CRF_MOD_EXP_CRT)
1091 cryptodev_rsa.rsa_mod_exp =
1092 cryptodev_rsa_mod_exp;
1093 else
1094 cryptodev_rsa.rsa_mod_exp =
1095 cryptodev_rsa_nocrt_mod_exp;
1096 }
910 } 1097 }
911 1098
912 if ((cryptodev_symfeat & CRSFEAT_DSA) && 1099 if (ENGINE_set_DSA(engine, &cryptodev_dsa)) {
913 ENGINE_set_DSA(engine, &cryptodev_dsa)) { 1100 const DSA_METHOD *meth = DSA_OpenSSL();
1101
1102 memcpy(&cryptodev_dsa, meth, sizeof(DSA_METHOD));
1103 if (cryptodev_asymfeat & CRF_DSA_SIGN)
1104 cryptodev_dsa.dsa_do_sign = cryptodev_dsa_do_sign;
1105 if (cryptodev_asymfeat & CRF_MOD_EXP) {
1106 cryptodev_dsa.bn_mod_exp = cryptodev_dsa_bn_mod_exp;
1107 cryptodev_dsa.dsa_mod_exp = cryptodev_dsa_dsa_mod_exp;
1108 }
1109 if (cryptodev_asymfeat & CRF_DSA_VERIFY)
1110 cryptodev_dsa.dsa_do_verify = cryptodev_dsa_verify;
914 } 1111 }
915 1112
916 if ((cryptodev_symfeat & CRSFEAT_DH) && 1113 if (ENGINE_set_DH(engine, &cryptodev_dh)){
917 ENGINE_set_DH(engine, &cryptodev_dh)) { 1114 const DH_METHOD *dh_meth = DH_OpenSSL();
918 dh_meth = DH_OpenSSL(); 1115
919 cryptodev_dh.generate_key = dh_meth->generate_key; 1116 cryptodev_dh.generate_key = dh_meth->generate_key;
920 cryptodev_dh.compute_key = dh_meth->compute_key; 1117 cryptodev_dh.compute_key = dh_meth->compute_key;
1118 cryptodev_dh.bn_mod_exp = dh_meth->bn_mod_exp;
1119 if (cryptodev_asymfeat & CRF_MOD_EXP) {
1120 cryptodev_dh.bn_mod_exp = cryptodev_mod_exp_dh;
1121 if (cryptodev_asymfeat & CRF_DH_COMPUTE_KEY)
1122 cryptodev_dh.compute_key =
1123 cryptodev_dh_compute_key;
1124 }
921 } 1125 }
922 1126
923 ENGINE_add(engine); 1127 ENGINE_add(engine);
924 ENGINE_free(engine); 1128 ENGINE_free(engine);
925 ERR_clear_error(); 1129 ERR_clear_error();
926} 1130}
1131
1132#endif /* HAVE_CRYPTODEV */
diff --git a/src/lib/libssl/src/crypto/engine/hw_cswift.c b/src/lib/libssl/src/crypto/engine/hw_cswift.c
index f5c897bdbb..f128ee5a68 100644
--- a/src/lib/libssl/src/crypto/engine/hw_cswift.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/engine/hw_ncipher.c b/src/lib/libssl/src/crypto/engine/hw_ncipher.c
index a43d4360f2..0d1c6b8df0 100644
--- a/src/lib/libssl/src/crypto/engine/hw_ncipher.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/engine/hw_ncipher_err.c b/src/lib/libssl/src/crypto/engine/hw_ncipher_err.c
index 24024cfc6f..5bc94581b7 100644
--- a/src/lib/libssl/src/crypto/engine/hw_ncipher_err.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/engine/hw_ncipher_err.h b/src/lib/libssl/src/crypto/engine/hw_ncipher_err.h
index 4d65b1d470..d232d02319 100644
--- a/src/lib/libssl/src/crypto/engine/hw_ncipher_err.h
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/engine/hw_nuron.c b/src/lib/libssl/src/crypto/engine/hw_nuron.c
index 130b6d8b40..fb9188bfe5 100644
--- a/src/lib/libssl/src/crypto/engine/hw_nuron.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/engine/hw_sureware.c b/src/lib/libssl/src/crypto/engine/hw_sureware.c
new file mode 100644
index 0000000000..fca467e690
--- /dev/null
+++ b/src/lib/libssl/src/crypto/engine/hw_sureware.c
@@ -0,0 +1,1039 @@
1/* Written by Corinne Dive-Reclus(cdive@baltimore.com)
2*
3*
4* Redistribution and use in source and binary forms, with or without
5* modification, are permitted provided that the following conditions
6* are met:
7*
8* 1. Redistributions of source code must retain the above copyright
9* notice, this list of conditions and the following disclaimer.
10*
11* 2. Redistributions in binary form must reproduce the above copyright
12* notice, this list of conditions and the following disclaimer in
13* the documentation and/or other materials provided with the
14* distribution.
15*
16* 3. All advertising materials mentioning features or use of this
17* software must display the following acknowledgment:
18* "This product includes software developed by the OpenSSL Project
19* for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
20*
21* 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
22* endorse or promote products derived from this software without
23* prior written permission. For written permission, please contact
24* licensing@OpenSSL.org.
25*
26* 5. Products derived from this software may not be called "OpenSSL"
27* nor may "OpenSSL" appear in their names without prior written
28* permission of the OpenSSL Project.
29*
30* 6. Redistributions of any form whatsoever must retain the following
31* acknowledgment:
32* "This product includes software developed by the OpenSSL Project
33* for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
34*
35* Written by Corinne Dive-Reclus(cdive@baltimore.com)
36*
37* Copyright@2001 Baltimore Technologies Ltd.
38* All right Reserved.
39* *
40* THIS FILE IS PROVIDED BY BALTIMORE TECHNOLOGIES ``AS IS'' AND *
41* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE *
42* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE *
43* ARE DISCLAIMED. IN NO EVENT SHALL BALTIMORE TECHNOLOGIES BE LIABLE *
44* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL *
45* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS *
46* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) *
47* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT *
48* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY *
49* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF *
50* SUCH DAMAGE. *
51====================================================================*/
52
53#include <stdio.h>
54#include "cryptlib.h"
55#include <openssl/crypto.h>
56#include <openssl/pem.h>
57#include <openssl/dso.h>
58#include "eng_int.h"
59#include "engine.h"
60#include <openssl/engine.h>
61
62#ifndef OPENSSL_NO_HW
63#ifndef OPENSSL_NO_HW_SUREWARE
64
65#ifdef FLAT_INC
66#include "sureware.h"
67#else
68#include "vendor_defns/sureware.h"
69#endif
70
71#define SUREWARE_LIB_NAME "sureware engine"
72#include "hw_sureware_err.c"
73
74static int surewarehk_ctrl(ENGINE *e, int cmd, long i, void *p, void (*f)());
75static int surewarehk_destroy(ENGINE *e);
76static int surewarehk_init(ENGINE *e);
77static int surewarehk_finish(ENGINE *e);
78static int surewarehk_modexp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
79 const BIGNUM *m, BN_CTX *ctx);
80
81/* RSA stuff */
82static int surewarehk_rsa_priv_dec(int flen,const unsigned char *from,unsigned char *to,
83 RSA *rsa,int padding);
84static int surewarehk_rsa_sign(int flen,const unsigned char *from,unsigned char *to,
85 RSA *rsa,int padding);
86
87/* RAND stuff */
88static int surewarehk_rand_bytes(unsigned char *buf, int num);
89static void surewarehk_rand_seed(const void *buf, int num);
90static void surewarehk_rand_add(const void *buf, int num, double entropy);
91
92/* KM stuff */
93static EVP_PKEY *surewarehk_load_privkey(ENGINE *e, const char *key_id,
94 UI_METHOD *ui_method, void *callback_data);
95static EVP_PKEY *surewarehk_load_pubkey(ENGINE *e, const char *key_id,
96 UI_METHOD *ui_method, void *callback_data);
97static void surewarehk_ex_free(void *obj, void *item, CRYPTO_EX_DATA *ad,
98 int idx,long argl, void *argp);
99#if 0
100static void surewarehk_dh_ex_free(void *obj, void *item, CRYPTO_EX_DATA *ad,
101 int idx,long argl, void *argp);
102#endif
103
104#ifndef OPENSSL_NO_RSA
105/* This function is aliased to mod_exp (with the mont stuff dropped). */
106static int surewarehk_mod_exp_mont(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
107 const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx)
108{
109 return surewarehk_modexp(r, a, p, m, ctx);
110}
111
112/* Our internal RSA_METHOD that we provide pointers to */
113static RSA_METHOD surewarehk_rsa =
114 {
115 "SureWare RSA method",
116 NULL, /* pub_enc*/
117 NULL, /* pub_dec*/
118 surewarehk_rsa_sign, /* our rsa_sign is OpenSSL priv_enc*/
119 surewarehk_rsa_priv_dec, /* priv_dec*/
120 NULL, /*mod_exp*/
121 surewarehk_mod_exp_mont, /*mod_exp_mongomery*/
122 NULL, /* init*/
123 NULL, /* finish*/
124 0, /* RSA flag*/
125 NULL,
126 NULL, /* OpenSSL sign*/
127 NULL /* OpenSSL verify*/
128 };
129#endif
130
131#ifndef OPENSSL_NO_DH
132/* Our internal DH_METHOD that we provide pointers to */
133/* This function is aliased to mod_exp (with the dh and mont dropped). */
134static int surewarehk_modexp_dh(const DH *dh, BIGNUM *r, const BIGNUM *a,
135 const BIGNUM *p, const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx)
136{
137 return surewarehk_modexp(r, a, p, m, ctx);
138}
139
140static DH_METHOD surewarehk_dh =
141 {
142 "SureWare DH method",
143 NULL,/*gen_key*/
144 NULL,/*agree,*/
145 surewarehk_modexp_dh, /*dh mod exp*/
146 NULL, /* init*/
147 NULL, /* finish*/
148 0, /* flags*/
149 NULL
150 };
151#endif
152
153static RAND_METHOD surewarehk_rand =
154 {
155 /* "SureWare RAND method", */
156 surewarehk_rand_seed,
157 surewarehk_rand_bytes,
158 NULL,/*cleanup*/
159 surewarehk_rand_add,
160 surewarehk_rand_bytes,
161 NULL,/*rand_status*/
162 };
163
164#ifndef OPENSSL_NO_DSA
165/* DSA stuff */
166static DSA_SIG * surewarehk_dsa_do_sign(const unsigned char *dgst, int dlen, DSA *dsa);
167static int surewarehk_dsa_mod_exp(DSA *dsa, BIGNUM *rr, BIGNUM *a1,
168 BIGNUM *p1, BIGNUM *a2, BIGNUM *p2, BIGNUM *m,
169 BN_CTX *ctx, BN_MONT_CTX *in_mont)
170{
171 BIGNUM t;
172 int to_return = 0;
173 BN_init(&t);
174 /* let rr = a1 ^ p1 mod m */
175 if (!surewarehk_modexp(rr,a1,p1,m,ctx)) goto end;
176 /* let t = a2 ^ p2 mod m */
177 if (!surewarehk_modexp(&t,a2,p2,m,ctx)) goto end;
178 /* let rr = rr * t mod m */
179 if (!BN_mod_mul(rr,rr,&t,m,ctx)) goto end;
180 to_return = 1;
181end:
182 BN_free(&t);
183 return to_return;
184}
185
186static DSA_METHOD surewarehk_dsa =
187 {
188 "SureWare DSA method",
189 surewarehk_dsa_do_sign,
190 NULL,/*sign setup*/
191 NULL,/*verify,*/
192 surewarehk_dsa_mod_exp,/*mod exp*/
193 NULL,/*bn mod exp*/
194 NULL, /*init*/
195 NULL,/*finish*/
196 0,
197 NULL,
198 };
199#endif
200
201static const char *engine_sureware_id = "sureware";
202static const char *engine_sureware_name = "SureWare hardware engine support";
203
204/* Now, to our own code */
205
206/* As this is only ever called once, there's no need for locking
207 * (indeed - the lock will already be held by our caller!!!) */
208static int bind_sureware(ENGINE *e)
209{
210#ifndef OPENSSL_NO_RSA
211 const RSA_METHOD *meth1;
212#endif
213#ifndef OPENSSL_NO_DSA
214 const DSA_METHOD *meth2;
215#endif
216#ifndef OPENSSL_NO_DH
217 const DH_METHOD *meth3;
218#endif
219
220 if(!ENGINE_set_id(e, engine_sureware_id) ||
221 !ENGINE_set_name(e, engine_sureware_name) ||
222#ifndef OPENSSL_NO_RSA
223 !ENGINE_set_RSA(e, &surewarehk_rsa) ||
224#endif
225#ifndef OPENSSL_NO_DSA
226 !ENGINE_set_DSA(e, &surewarehk_dsa) ||
227#endif
228#ifndef OPENSSL_NO_DH
229 !ENGINE_set_DH(e, &surewarehk_dh) ||
230#endif
231 !ENGINE_set_RAND(e, &surewarehk_rand) ||
232 !ENGINE_set_destroy_function(e, surewarehk_destroy) ||
233 !ENGINE_set_init_function(e, surewarehk_init) ||
234 !ENGINE_set_finish_function(e, surewarehk_finish) ||
235 !ENGINE_set_ctrl_function(e, surewarehk_ctrl) ||
236 !ENGINE_set_load_privkey_function(e, surewarehk_load_privkey) ||
237 !ENGINE_set_load_pubkey_function(e, surewarehk_load_pubkey))
238 return 0;
239
240#ifndef OPENSSL_NO_RSA
241 /* We know that the "PKCS1_SSLeay()" functions hook properly
242 * to the cswift-specific mod_exp and mod_exp_crt so we use
243 * those functions. NB: We don't use ENGINE_openssl() or
244 * anything "more generic" because something like the RSAref
245 * code may not hook properly, and if you own one of these
246 * cards then you have the right to do RSA operations on it
247 * anyway! */
248 meth1 = RSA_PKCS1_SSLeay();
249 if (meth1)
250 {
251 surewarehk_rsa.rsa_pub_enc = meth1->rsa_pub_enc;
252 surewarehk_rsa.rsa_pub_dec = meth1->rsa_pub_dec;
253 }
254#endif
255
256#ifndef OPENSSL_NO_DSA
257 /* Use the DSA_OpenSSL() method and just hook the mod_exp-ish
258 * bits. */
259 meth2 = DSA_OpenSSL();
260 if (meth2)
261 {
262 surewarehk_dsa.dsa_do_verify = meth2->dsa_do_verify;
263 }
264#endif
265
266#ifndef OPENSSL_NO_DH
267 /* Much the same for Diffie-Hellman */
268 meth3 = DH_OpenSSL();
269 if (meth3)
270 {
271 surewarehk_dh.generate_key = meth3->generate_key;
272 surewarehk_dh.compute_key = meth3->compute_key;
273 }
274#endif
275
276 /* Ensure the sureware error handling is set up */
277 ERR_load_SUREWARE_strings();
278 return 1;
279}
280
281#ifdef ENGINE_DYNAMIC_SUPPORT
282static int bind_helper(ENGINE *e, const char *id)
283 {
284 if(id && (strcmp(id, engine_sureware_id) != 0))
285 return 0;
286 if(!bind_sureware(e))
287 return 0;
288 return 1;
289 }
290IMPLEMENT_DYNAMIC_CHECK_FN()
291IMPLEMENT_DYNAMIC_BIND_FN(bind_helper)
292#else
293static ENGINE *engine_sureware(void)
294 {
295 ENGINE *ret = ENGINE_new();
296 if(!ret)
297 return NULL;
298 if(!bind_sureware(ret))
299 {
300 ENGINE_free(ret);
301 return NULL;
302 }
303 return ret;
304 }
305
306void ENGINE_load_sureware(void)
307 {
308 /* Copied from eng_[openssl|dyn].c */
309 ENGINE *toadd = engine_sureware();
310 if(!toadd) return;
311 ENGINE_add(toadd);
312 ENGINE_free(toadd);
313 ERR_clear_error();
314 }
315#endif
316
317/* This is a process-global DSO handle used for loading and unloading
318 * the SureWareHook library. NB: This is only set (or unset) during an
319 * init() or finish() call (reference counts permitting) and they're
320 * operating with global locks, so this should be thread-safe
321 * implicitly. */
322static DSO *surewarehk_dso = NULL;
323#ifndef OPENSSL_NO_RSA
324static int rsaHndidx = -1; /* Index for KM handle. Not really used yet. */
325#endif
326#ifndef OPENSSL_NO_DSA
327static int dsaHndidx = -1; /* Index for KM handle. Not really used yet. */
328#endif
329
330/* These are the function pointers that are (un)set when the library has
331 * successfully (un)loaded. */
332static SureWareHook_Init_t *p_surewarehk_Init = NULL;
333static SureWareHook_Finish_t *p_surewarehk_Finish = NULL;
334static SureWareHook_Rand_Bytes_t *p_surewarehk_Rand_Bytes = NULL;
335static SureWareHook_Rand_Seed_t *p_surewarehk_Rand_Seed = NULL;
336static SureWareHook_Load_Privkey_t *p_surewarehk_Load_Privkey = NULL;
337static SureWareHook_Info_Pubkey_t *p_surewarehk_Info_Pubkey = NULL;
338static SureWareHook_Load_Rsa_Pubkey_t *p_surewarehk_Load_Rsa_Pubkey = NULL;
339static SureWareHook_Load_Dsa_Pubkey_t *p_surewarehk_Load_Dsa_Pubkey = NULL;
340static SureWareHook_Free_t *p_surewarehk_Free=NULL;
341static SureWareHook_Rsa_Priv_Dec_t *p_surewarehk_Rsa_Priv_Dec=NULL;
342static SureWareHook_Rsa_Sign_t *p_surewarehk_Rsa_Sign=NULL;
343static SureWareHook_Dsa_Sign_t *p_surewarehk_Dsa_Sign=NULL;
344static SureWareHook_Mod_Exp_t *p_surewarehk_Mod_Exp=NULL;
345
346/* Used in the DSO operations. */
347static const char *surewarehk_LIBNAME = "SureWareHook";
348static const char *n_surewarehk_Init = "SureWareHook_Init";
349static const char *n_surewarehk_Finish = "SureWareHook_Finish";
350static const char *n_surewarehk_Rand_Bytes="SureWareHook_Rand_Bytes";
351static const char *n_surewarehk_Rand_Seed="SureWareHook_Rand_Seed";
352static const char *n_surewarehk_Load_Privkey="SureWareHook_Load_Privkey";
353static const char *n_surewarehk_Info_Pubkey="SureWareHook_Info_Pubkey";
354static const char *n_surewarehk_Load_Rsa_Pubkey="SureWareHook_Load_Rsa_Pubkey";
355static const char *n_surewarehk_Load_Dsa_Pubkey="SureWareHook_Load_Dsa_Pubkey";
356static const char *n_surewarehk_Free="SureWareHook_Free";
357static const char *n_surewarehk_Rsa_Priv_Dec="SureWareHook_Rsa_Priv_Dec";
358static const char *n_surewarehk_Rsa_Sign="SureWareHook_Rsa_Sign";
359static const char *n_surewarehk_Dsa_Sign="SureWareHook_Dsa_Sign";
360static const char *n_surewarehk_Mod_Exp="SureWareHook_Mod_Exp";
361static BIO *logstream = NULL;
362
363/* SureWareHook library functions and mechanics - these are used by the
364 * higher-level functions further down. NB: As and where there's no
365 * error checking, take a look lower down where these functions are
366 * called, the checking and error handling is probably down there.
367*/
368static int threadsafe=1;
369static int surewarehk_ctrl(ENGINE *e, int cmd, long i, void *p, void (*f)())
370{
371 int to_return = 1;
372
373 switch(cmd)
374 {
375 case ENGINE_CTRL_SET_LOGSTREAM:
376 {
377 BIO *bio = (BIO *)p;
378 CRYPTO_w_lock(CRYPTO_LOCK_ENGINE);
379 if (logstream)
380 {
381 BIO_free(logstream);
382 logstream = NULL;
383 }
384 if (CRYPTO_add(&bio->references,1,CRYPTO_LOCK_BIO) > 1)
385 logstream = bio;
386 else
387 SUREWAREerr(SUREWARE_F_SUREWAREHK_CTRL,SUREWARE_R_BIO_WAS_FREED);
388 }
389 CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE);
390 break;
391 /* This will prevent the initialisation function from "installing"
392 * the mutex-handling callbacks, even if they are available from
393 * within the library (or were provided to the library from the
394 * calling application). This is to remove any baggage for
395 * applications not using multithreading. */
396 case ENGINE_CTRL_CHIL_NO_LOCKING:
397 CRYPTO_w_lock(CRYPTO_LOCK_ENGINE);
398 threadsafe = 0;
399 CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE);
400 break;
401
402 /* The command isn't understood by this engine */
403 default:
404 SUREWAREerr(SUREWARE_F_SUREWAREHK_CTRL,
405 ENGINE_R_CTRL_COMMAND_NOT_IMPLEMENTED);
406 to_return = 0;
407 break;
408 }
409
410 return to_return;
411}
412
413/* Destructor (complements the "ENGINE_surewarehk()" constructor) */
414static int surewarehk_destroy(ENGINE *e)
415{
416 ERR_unload_SUREWARE_strings();
417 return 1;
418}
419
420/* (de)initialisation functions. */
421static int surewarehk_init(ENGINE *e)
422{
423 char msg[64]="ENGINE_init";
424 SureWareHook_Init_t *p1=NULL;
425 SureWareHook_Finish_t *p2=NULL;
426 SureWareHook_Rand_Bytes_t *p3=NULL;
427 SureWareHook_Rand_Seed_t *p4=NULL;
428 SureWareHook_Load_Privkey_t *p5=NULL;
429 SureWareHook_Load_Rsa_Pubkey_t *p6=NULL;
430 SureWareHook_Free_t *p7=NULL;
431 SureWareHook_Rsa_Priv_Dec_t *p8=NULL;
432 SureWareHook_Rsa_Sign_t *p9=NULL;
433 SureWareHook_Dsa_Sign_t *p12=NULL;
434 SureWareHook_Info_Pubkey_t *p13=NULL;
435 SureWareHook_Load_Dsa_Pubkey_t *p14=NULL;
436 SureWareHook_Mod_Exp_t *p15=NULL;
437
438 if(surewarehk_dso != NULL)
439 {
440 SUREWAREerr(SUREWARE_F_SUREWAREHK_INIT,ENGINE_R_ALREADY_LOADED);
441 goto err;
442 }
443 /* Attempt to load libsurewarehk.so/surewarehk.dll/whatever. */
444 surewarehk_dso = DSO_load(NULL, surewarehk_LIBNAME, NULL, 0);
445 if(surewarehk_dso == NULL)
446 {
447 SUREWAREerr(SUREWARE_F_SUREWAREHK_INIT,ENGINE_R_DSO_FAILURE);
448 goto err;
449 }
450 if(!(p1=(SureWareHook_Init_t*)DSO_bind_func(surewarehk_dso, n_surewarehk_Init)) ||
451 !(p2=(SureWareHook_Finish_t*)DSO_bind_func(surewarehk_dso, n_surewarehk_Finish)) ||
452 !(p3=(SureWareHook_Rand_Bytes_t*)DSO_bind_func(surewarehk_dso, n_surewarehk_Rand_Bytes)) ||
453 !(p4=(SureWareHook_Rand_Seed_t*)DSO_bind_func(surewarehk_dso, n_surewarehk_Rand_Seed)) ||
454 !(p5=(SureWareHook_Load_Privkey_t*)DSO_bind_func(surewarehk_dso, n_surewarehk_Load_Privkey)) ||
455 !(p6=(SureWareHook_Load_Rsa_Pubkey_t*)DSO_bind_func(surewarehk_dso, n_surewarehk_Load_Rsa_Pubkey)) ||
456 !(p7=(SureWareHook_Free_t*)DSO_bind_func(surewarehk_dso, n_surewarehk_Free)) ||
457 !(p8=(SureWareHook_Rsa_Priv_Dec_t*)DSO_bind_func(surewarehk_dso, n_surewarehk_Rsa_Priv_Dec)) ||
458 !(p9=(SureWareHook_Rsa_Sign_t*)DSO_bind_func(surewarehk_dso, n_surewarehk_Rsa_Sign)) ||
459 !(p12=(SureWareHook_Dsa_Sign_t*)DSO_bind_func(surewarehk_dso, n_surewarehk_Dsa_Sign)) ||
460 !(p13=(SureWareHook_Info_Pubkey_t*)DSO_bind_func(surewarehk_dso, n_surewarehk_Info_Pubkey)) ||
461 !(p14=(SureWareHook_Load_Dsa_Pubkey_t*)DSO_bind_func(surewarehk_dso, n_surewarehk_Load_Dsa_Pubkey)) ||
462 !(p15=(SureWareHook_Mod_Exp_t*)DSO_bind_func(surewarehk_dso, n_surewarehk_Mod_Exp)))
463 {
464 SUREWAREerr(SUREWARE_F_SUREWAREHK_INIT,ENGINE_R_DSO_FAILURE);
465 goto err;
466 }
467 /* Copy the pointers */
468 p_surewarehk_Init = p1;
469 p_surewarehk_Finish = p2;
470 p_surewarehk_Rand_Bytes = p3;
471 p_surewarehk_Rand_Seed = p4;
472 p_surewarehk_Load_Privkey = p5;
473 p_surewarehk_Load_Rsa_Pubkey = p6;
474 p_surewarehk_Free = p7;
475 p_surewarehk_Rsa_Priv_Dec = p8;
476 p_surewarehk_Rsa_Sign = p9;
477 p_surewarehk_Dsa_Sign = p12;
478 p_surewarehk_Info_Pubkey = p13;
479 p_surewarehk_Load_Dsa_Pubkey = p14;
480 p_surewarehk_Mod_Exp = p15;
481 /* Contact the hardware and initialises it. */
482 if(p_surewarehk_Init(msg,threadsafe)==SUREWAREHOOK_ERROR_UNIT_FAILURE)
483 {
484 SUREWAREerr(SUREWARE_F_SUREWAREHK_INIT,SUREWARE_R_UNIT_FAILURE);
485 goto err;
486 }
487 if(p_surewarehk_Init(msg,threadsafe)==SUREWAREHOOK_ERROR_UNIT_FAILURE)
488 {
489 SUREWAREerr(SUREWARE_F_SUREWAREHK_INIT,SUREWARE_R_UNIT_FAILURE);
490 goto err;
491 }
492 /* try to load the default private key, if failed does not return a failure but
493 wait for an explicit ENGINE_load_privakey */
494 surewarehk_load_privkey(e,NULL,NULL,NULL);
495
496 /* Everything's fine. */
497#ifndef OPENSSL_NO_RSA
498 if (rsaHndidx == -1)
499 rsaHndidx = RSA_get_ex_new_index(0,
500 "SureWareHook RSA key handle",
501 NULL, NULL, surewarehk_ex_free);
502#endif
503#ifndef OPENSSL_NO_DSA
504 if (dsaHndidx == -1)
505 dsaHndidx = DSA_get_ex_new_index(0,
506 "SureWareHook DSA key handle",
507 NULL, NULL, surewarehk_ex_free);
508#endif
509
510 return 1;
511err:
512 if(surewarehk_dso)
513 DSO_free(surewarehk_dso);
514 surewarehk_dso = NULL;
515 p_surewarehk_Init = NULL;
516 p_surewarehk_Finish = NULL;
517 p_surewarehk_Rand_Bytes = NULL;
518 p_surewarehk_Rand_Seed = NULL;
519 p_surewarehk_Load_Privkey = NULL;
520 p_surewarehk_Load_Rsa_Pubkey = NULL;
521 p_surewarehk_Free = NULL;
522 p_surewarehk_Rsa_Priv_Dec = NULL;
523 p_surewarehk_Rsa_Sign = NULL;
524 p_surewarehk_Dsa_Sign = NULL;
525 p_surewarehk_Info_Pubkey = NULL;
526 p_surewarehk_Load_Dsa_Pubkey = NULL;
527 p_surewarehk_Mod_Exp = NULL;
528 return 0;
529}
530
531static int surewarehk_finish(ENGINE *e)
532{
533 int to_return = 1;
534 if(surewarehk_dso == NULL)
535 {
536 SUREWAREerr(SUREWARE_F_SUREWAREHK_FINISH,ENGINE_R_NOT_LOADED);
537 to_return = 0;
538 goto err;
539 }
540 p_surewarehk_Finish();
541 if(!DSO_free(surewarehk_dso))
542 {
543 SUREWAREerr(SUREWARE_F_SUREWAREHK_FINISH,ENGINE_R_DSO_FAILURE);
544 to_return = 0;
545 goto err;
546 }
547 err:
548 if (logstream)
549 BIO_free(logstream);
550 surewarehk_dso = NULL;
551 p_surewarehk_Init = NULL;
552 p_surewarehk_Finish = NULL;
553 p_surewarehk_Rand_Bytes = NULL;
554 p_surewarehk_Rand_Seed = NULL;
555 p_surewarehk_Load_Privkey = NULL;
556 p_surewarehk_Load_Rsa_Pubkey = NULL;
557 p_surewarehk_Free = NULL;
558 p_surewarehk_Rsa_Priv_Dec = NULL;
559 p_surewarehk_Rsa_Sign = NULL;
560 p_surewarehk_Dsa_Sign = NULL;
561 p_surewarehk_Info_Pubkey = NULL;
562 p_surewarehk_Load_Dsa_Pubkey = NULL;
563 p_surewarehk_Mod_Exp = NULL;
564 return to_return;
565}
566
567static void surewarehk_error_handling(char *const msg,int func,int ret)
568{
569 switch (ret)
570 {
571 case SUREWAREHOOK_ERROR_UNIT_FAILURE:
572 ENGINEerr(func,SUREWARE_R_UNIT_FAILURE);
573 break;
574 case SUREWAREHOOK_ERROR_FALLBACK:
575 ENGINEerr(func,SUREWARE_R_REQUEST_FALLBACK);
576 break;
577 case SUREWAREHOOK_ERROR_DATA_SIZE:
578 ENGINEerr(func,SUREWARE_R_SIZE_TOO_LARGE_OR_TOO_SMALL);
579 break;
580 case SUREWAREHOOK_ERROR_INVALID_PAD:
581 ENGINEerr(func,RSA_R_PADDING_CHECK_FAILED);
582 break;
583 default:
584 ENGINEerr(func,SUREWARE_R_REQUEST_FAILED);
585 break;
586 case 1:/*nothing*/
587 msg[0]='\0';
588 }
589 if (*msg)
590 {
591 ERR_add_error_data(1,msg);
592 if (logstream)
593 {
594 CRYPTO_w_lock(CRYPTO_LOCK_BIO);
595 BIO_write(logstream, msg, strlen(msg));
596 CRYPTO_w_unlock(CRYPTO_LOCK_BIO);
597 }
598 }
599}
600
601static int surewarehk_rand_bytes(unsigned char *buf, int num)
602{
603 int ret=0;
604 char msg[64]="ENGINE_rand_bytes";
605 if(!p_surewarehk_Rand_Bytes)
606 {
607 SUREWAREerr(SUREWARE_F_SUREWAREHK_RAND_BYTES,ENGINE_R_NOT_INITIALISED);
608 }
609 else
610 {
611 ret = p_surewarehk_Rand_Bytes(msg,buf, num);
612 surewarehk_error_handling(msg,SUREWARE_F_SUREWAREHK_RAND_BYTES,ret);
613 }
614 return ret==1 ? 1 : 0;
615}
616
617static void surewarehk_rand_seed(const void *buf, int num)
618{
619 int ret=0;
620 char msg[64]="ENGINE_rand_seed";
621 if(!p_surewarehk_Rand_Seed)
622 {
623 SUREWAREerr(SUREWARE_F_SUREWAREHK_RAND_SEED,ENGINE_R_NOT_INITIALISED);
624 }
625 else
626 {
627 ret = p_surewarehk_Rand_Seed(msg,buf, num);
628 surewarehk_error_handling(msg,SUREWARE_F_SUREWAREHK_RAND_SEED,ret);
629 }
630}
631
632static void surewarehk_rand_add(const void *buf, int num, double entropy)
633{
634 surewarehk_rand_seed(buf,num);
635}
636
637static EVP_PKEY* sureware_load_public(ENGINE *e,const char *key_id,char *hptr,unsigned long el,char keytype)
638{
639 EVP_PKEY *res = NULL;
640#ifndef OPENSSL_NO_RSA
641 RSA *rsatmp = NULL;
642#endif
643#ifndef OPENSSL_NO_DSA
644 DSA *dsatmp=NULL;
645#endif
646 char msg[64]="sureware_load_public";
647 int ret=0;
648 if(!p_surewarehk_Load_Rsa_Pubkey || !p_surewarehk_Load_Dsa_Pubkey)
649 {
650 SUREWAREerr(SUREWARE_F_SUREWAREHK_LOAD_PUBLIC_KEY,ENGINE_R_NOT_INITIALISED);
651 goto err;
652 }
653 switch (keytype)
654 {
655#ifndef OPENSSL_NO_RSA
656 case 1: /*RSA*/
657 /* set private external reference */
658 rsatmp = RSA_new_method(e);
659 RSA_set_ex_data(rsatmp,rsaHndidx,hptr);
660 rsatmp->flags |= RSA_FLAG_EXT_PKEY;
661
662 /* set public big nums*/
663 rsatmp->e = BN_new();
664 rsatmp->n = BN_new();
665 bn_expand2(rsatmp->e, el/sizeof(BN_ULONG));
666 bn_expand2(rsatmp->n, el/sizeof(BN_ULONG));
667 if (!rsatmp->e || rsatmp->e->dmax!=(int)(el/sizeof(BN_ULONG))||
668 !rsatmp->n || rsatmp->n->dmax!=(int)(el/sizeof(BN_ULONG)))
669 goto err;
670 ret=p_surewarehk_Load_Rsa_Pubkey(msg,key_id,el,
671 (unsigned long *)rsatmp->n->d,
672 (unsigned long *)rsatmp->e->d);
673 surewarehk_error_handling(msg,SUREWARE_F_SUREWAREHK_LOAD_PUBLIC_KEY,ret);
674 if (ret!=1)
675 {
676 SUREWAREerr(SUREWARE_F_SUREWAREHK_LOAD_PRIVATE_KEY,ENGINE_R_FAILED_LOADING_PUBLIC_KEY);
677 goto err;
678 }
679 /* normalise pub e and pub n */
680 rsatmp->e->top=el/sizeof(BN_ULONG);
681 bn_fix_top(rsatmp->e);
682 rsatmp->n->top=el/sizeof(BN_ULONG);
683 bn_fix_top(rsatmp->n);
684 /* create an EVP object: engine + rsa key */
685 res = EVP_PKEY_new();
686 EVP_PKEY_assign_RSA(res, rsatmp);
687 break;
688#endif
689
690#ifndef OPENSSL_NO_DSA
691 case 2:/*DSA*/
692 /* set private/public external reference */
693 dsatmp = DSA_new_method(e);
694 DSA_set_ex_data(dsatmp,dsaHndidx,hptr);
695 /*dsatmp->flags |= DSA_FLAG_EXT_PKEY;*/
696
697 /* set public key*/
698 dsatmp->pub_key = BN_new();
699 dsatmp->p = BN_new();
700 dsatmp->q = BN_new();
701 dsatmp->g = BN_new();
702 bn_expand2(dsatmp->pub_key, el/sizeof(BN_ULONG));
703 bn_expand2(dsatmp->p, el/sizeof(BN_ULONG));
704 bn_expand2(dsatmp->q, 20/sizeof(BN_ULONG));
705 bn_expand2(dsatmp->g, el/sizeof(BN_ULONG));
706 if (!dsatmp->pub_key || dsatmp->pub_key->dmax!=(int)(el/sizeof(BN_ULONG))||
707 !dsatmp->p || dsatmp->p->dmax!=(int)(el/sizeof(BN_ULONG)) ||
708 !dsatmp->q || dsatmp->q->dmax!=20/sizeof(BN_ULONG) ||
709 !dsatmp->g || dsatmp->g->dmax!=(int)(el/sizeof(BN_ULONG)))
710 goto err;
711
712 ret=p_surewarehk_Load_Dsa_Pubkey(msg,key_id,el,
713 (unsigned long *)dsatmp->pub_key->d,
714 (unsigned long *)dsatmp->p->d,
715 (unsigned long *)dsatmp->q->d,
716 (unsigned long *)dsatmp->g->d);
717 surewarehk_error_handling(msg,SUREWARE_F_SUREWAREHK_LOAD_PUBLIC_KEY,ret);
718 if (ret!=1)
719 {
720 SUREWAREerr(SUREWARE_F_SUREWAREHK_LOAD_PRIVATE_KEY,ENGINE_R_FAILED_LOADING_PUBLIC_KEY);
721 goto err;
722 }
723 /* set parameters */
724 /* normalise pubkey and parameters in case of */
725 dsatmp->pub_key->top=el/sizeof(BN_ULONG);
726 bn_fix_top(dsatmp->pub_key);
727 dsatmp->p->top=el/sizeof(BN_ULONG);
728 bn_fix_top(dsatmp->p);
729 dsatmp->q->top=20/sizeof(BN_ULONG);
730 bn_fix_top(dsatmp->q);
731 dsatmp->g->top=el/sizeof(BN_ULONG);
732 bn_fix_top(dsatmp->g);
733
734 /* create an EVP object: engine + rsa key */
735 res = EVP_PKEY_new();
736 EVP_PKEY_assign_DSA(res, dsatmp);
737 break;
738#endif
739
740 default:
741 SUREWAREerr(SUREWARE_F_SUREWAREHK_LOAD_PRIVATE_KEY,ENGINE_R_FAILED_LOADING_PRIVATE_KEY);
742 goto err;
743 }
744 return res;
745 err:
746 if (res)
747 EVP_PKEY_free(res);
748#ifndef OPENSSL_NO_RSA
749 if (rsatmp)
750 RSA_free(rsatmp);
751#endif
752#ifndef OPENSSL_NO_DSA
753 if (dsatmp)
754 DSA_free(dsatmp);
755#endif
756 return NULL;
757}
758
759static EVP_PKEY *surewarehk_load_privkey(ENGINE *e, const char *key_id,
760 UI_METHOD *ui_method, void *callback_data)
761{
762 EVP_PKEY *res = NULL;
763 int ret=0;
764 unsigned long el=0;
765 char *hptr=NULL;
766 char keytype=0;
767 char msg[64]="ENGINE_load_privkey";
768
769 if(!p_surewarehk_Load_Privkey)
770 {
771 SUREWAREerr(SUREWARE_F_SUREWAREHK_LOAD_PRIVATE_KEY,ENGINE_R_NOT_INITIALISED);
772 }
773 else
774 {
775 ret=p_surewarehk_Load_Privkey(msg,key_id,&hptr,&el,&keytype);
776 if (ret!=1)
777 {
778 SUREWAREerr(SUREWARE_F_SUREWAREHK_LOAD_PRIVATE_KEY,ENGINE_R_FAILED_LOADING_PRIVATE_KEY);
779 ERR_add_error_data(1,msg);
780 }
781 else
782 res=sureware_load_public(e,key_id,hptr,el,keytype);
783 }
784 return res;
785}
786
787static EVP_PKEY *surewarehk_load_pubkey(ENGINE *e, const char *key_id,
788 UI_METHOD *ui_method, void *callback_data)
789{
790 EVP_PKEY *res = NULL;
791 int ret=0;
792 unsigned long el=0;
793 char *hptr=NULL;
794 char keytype=0;
795 char msg[64]="ENGINE_load_pubkey";
796
797 if(!p_surewarehk_Info_Pubkey)
798 {
799 SUREWAREerr(SUREWARE_F_SUREWAREHK_LOAD_PUBLIC_KEY,ENGINE_R_NOT_INITIALISED);
800 }
801 else
802 {
803 /* call once to identify if DSA or RSA */
804 ret=p_surewarehk_Info_Pubkey(msg,key_id,&el,&keytype);
805 if (ret!=1)
806 {
807 SUREWAREerr(SUREWARE_F_SUREWAREHK_LOAD_PUBLIC_KEY,ENGINE_R_FAILED_LOADING_PUBLIC_KEY);
808 ERR_add_error_data(1,msg);
809 }
810 else
811 res=sureware_load_public(e,key_id,hptr,el,keytype);
812 }
813 return res;
814}
815
816/* This cleans up an RSA/DSA KM key(do not destroy the key into the hardware)
817, called when ex_data is freed */
818static void surewarehk_ex_free(void *obj, void *item, CRYPTO_EX_DATA *ad,
819 int idx,long argl, void *argp)
820{
821 if(!p_surewarehk_Free)
822 {
823 SUREWAREerr(SUREWARE_F_SUREWAREHK_EX_FREE,ENGINE_R_NOT_INITIALISED);
824 }
825 else
826 p_surewarehk_Free((char *)item,0);
827}
828
829#if 0
830/* This cleans up an DH KM key (destroys the key into hardware),
831called when ex_data is freed */
832static void surewarehk_dh_ex_free(void *obj, void *item, CRYPTO_EX_DATA *ad,
833 int idx,long argl, void *argp)
834{
835 if(!p_surewarehk_Free)
836 {
837 SUREWAREerr(SUREWARE_F_SUREWAREHK_EX_FREE,ENGINE_R_NOT_INITIALISED);
838 }
839 else
840 p_surewarehk_Free((char *)item,1);
841}
842#endif
843
844/*
845* return number of decrypted bytes
846*/
847#ifndef OPENSSL_NO_RSA
848static int surewarehk_rsa_priv_dec(int flen,const unsigned char *from,unsigned char *to,
849 RSA *rsa,int padding)
850{
851 int ret=0,tlen;
852 char *buf=NULL,*hptr=NULL;
853 char msg[64]="ENGINE_rsa_priv_dec";
854 if (!p_surewarehk_Rsa_Priv_Dec)
855 {
856 SUREWAREerr(SUREWARE_F_SUREWAREHK_RSA_PRIV_DEC,ENGINE_R_NOT_INITIALISED);
857 }
858 /* extract ref to private key */
859 else if (!(hptr=RSA_get_ex_data(rsa, rsaHndidx)))
860 {
861 SUREWAREerr(SUREWARE_F_SUREWAREHK_RSA_PRIV_DEC,SUREWARE_R_MISSING_KEY_COMPONENTS);
862 goto err;
863 }
864 /* analyse what padding we can do into the hardware */
865 if (padding==RSA_PKCS1_PADDING)
866 {
867 /* do it one shot */
868 ret=p_surewarehk_Rsa_Priv_Dec(msg,flen,(unsigned char *)from,&tlen,to,hptr,SUREWARE_PKCS1_PAD);
869 surewarehk_error_handling(msg,SUREWARE_F_SUREWAREHK_RSA_PRIV_DEC,ret);
870 if (ret!=1)
871 goto err;
872 ret=tlen;
873 }
874 else /* do with no padding into hardware */
875 {
876 ret=p_surewarehk_Rsa_Priv_Dec(msg,flen,(unsigned char *)from,&tlen,to,hptr,SUREWARE_NO_PAD);
877 surewarehk_error_handling(msg,SUREWARE_F_SUREWAREHK_RSA_PRIV_DEC,ret);
878 if (ret!=1)
879 goto err;
880 /* intermediate buffer for padding */
881 if ((buf=OPENSSL_malloc(tlen)) == NULL)
882 {
883 RSAerr(SUREWARE_F_SUREWAREHK_RSA_PRIV_DEC,ERR_R_MALLOC_FAILURE);
884 goto err;
885 }
886 memcpy(buf,to,tlen);/* transfert to into buf */
887 switch (padding) /* check padding in software */
888 {
889#ifndef OPENSSL_NO_SHA
890 case RSA_PKCS1_OAEP_PADDING:
891 ret=RSA_padding_check_PKCS1_OAEP(to,tlen,(unsigned char *)buf,tlen,tlen,NULL,0);
892 break;
893#endif
894 case RSA_SSLV23_PADDING:
895 ret=RSA_padding_check_SSLv23(to,tlen,(unsigned char *)buf,flen,tlen);
896 break;
897 case RSA_NO_PADDING:
898 ret=RSA_padding_check_none(to,tlen,(unsigned char *)buf,flen,tlen);
899 break;
900 default:
901 RSAerr(SUREWARE_F_SUREWAREHK_RSA_PRIV_DEC,RSA_R_UNKNOWN_PADDING_TYPE);
902 goto err;
903 }
904 if (ret < 0)
905 RSAerr(SUREWARE_F_SUREWAREHK_RSA_PRIV_DEC,RSA_R_PADDING_CHECK_FAILED);
906 }
907err:
908 if (buf)
909 {
910 OPENSSL_cleanse(buf,tlen);
911 OPENSSL_free(buf);
912 }
913 return ret;
914}
915
916/*
917* Does what OpenSSL rsa_priv_enc does.
918*/
919static int surewarehk_rsa_sign(int flen,const unsigned char *from,unsigned char *to,
920 RSA *rsa,int padding)
921{
922 int ret=0,tlen;
923 char *hptr=NULL;
924 char msg[64]="ENGINE_rsa_sign";
925 if (!p_surewarehk_Rsa_Sign)
926 {
927 SUREWAREerr(SUREWARE_F_SUREWAREHK_RSA_PRIV_ENC,ENGINE_R_NOT_INITIALISED);
928 }
929 /* extract ref to private key */
930 else if (!(hptr=RSA_get_ex_data(rsa, rsaHndidx)))
931 {
932 SUREWAREerr(SUREWARE_F_SUREWAREHK_RSA_PRIV_ENC,SUREWARE_R_MISSING_KEY_COMPONENTS);
933 }
934 else
935 {
936 switch (padding)
937 {
938 case RSA_PKCS1_PADDING: /* do it in one shot */
939 ret=p_surewarehk_Rsa_Sign(msg,flen,(unsigned char *)from,&tlen,to,hptr,SUREWARE_PKCS1_PAD);
940 surewarehk_error_handling(msg,SUREWARE_F_SUREWAREHK_RSA_PRIV_ENC,ret);
941 break;
942 case RSA_NO_PADDING:
943 default:
944 RSAerr(SUREWARE_F_SUREWAREHK_RSA_PRIV_ENC,RSA_R_UNKNOWN_PADDING_TYPE);
945 }
946 }
947 return ret==1 ? tlen : ret;
948}
949
950#endif
951
952#ifndef OPENSSL_NO_DSA
953/* DSA sign and verify */
954static DSA_SIG * surewarehk_dsa_do_sign(const unsigned char *from, int flen, DSA *dsa)
955{
956 int ret=0;
957 char *hptr=NULL;
958 DSA_SIG *psign=NULL;
959 char msg[64]="ENGINE_dsa_do_sign";
960 if (!p_surewarehk_Dsa_Sign)
961 {
962 SUREWAREerr(SUREWARE_F_SUREWAREHK_DSA_DO_SIGN,ENGINE_R_NOT_INITIALISED);
963 }
964 /* extract ref to private key */
965 else if (!(hptr=DSA_get_ex_data(dsa, dsaHndidx)))
966 {
967 SUREWAREerr(SUREWARE_F_SUREWAREHK_DSA_DO_SIGN,SUREWARE_R_MISSING_KEY_COMPONENTS);
968 }
969 else
970 {
971 if((psign = DSA_SIG_new()) == NULL)
972 {
973 SUREWAREerr(SUREWARE_F_SUREWAREHK_DSA_DO_SIGN,ERR_R_MALLOC_FAILURE);
974 goto err;
975 }
976 psign->r=BN_new();
977 psign->s=BN_new();
978 bn_expand2(psign->r, 20/sizeof(BN_ULONG));
979 bn_expand2(psign->s, 20/sizeof(BN_ULONG));
980 if (!psign->r || psign->r->dmax!=20/sizeof(BN_ULONG) ||
981 !psign->s || psign->s->dmax!=20/sizeof(BN_ULONG))
982 goto err;
983 ret=p_surewarehk_Dsa_Sign(msg,flen,from,
984 (unsigned long *)psign->r->d,
985 (unsigned long *)psign->s->d,
986 hptr);
987 surewarehk_error_handling(msg,SUREWARE_F_SUREWAREHK_DSA_DO_SIGN,ret);
988 }
989 psign->r->top=20/sizeof(BN_ULONG);
990 bn_fix_top(psign->r);
991 psign->s->top=20/sizeof(BN_ULONG);
992 bn_fix_top(psign->s);
993
994err:
995 if (psign)
996 {
997 DSA_SIG_free(psign);
998 psign=NULL;
999 }
1000 return psign;
1001}
1002#endif
1003
1004static int surewarehk_modexp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
1005 const BIGNUM *m, BN_CTX *ctx)
1006{
1007 int ret=0;
1008 char msg[64]="ENGINE_modexp";
1009 if (!p_surewarehk_Mod_Exp)
1010 {
1011 SUREWAREerr(SUREWARE_F_SUREWAREHK_MOD_EXP,ENGINE_R_NOT_INITIALISED);
1012 }
1013 else
1014 {
1015 bn_expand2(r,m->top);
1016 if (r && r->dmax==m->top)
1017 {
1018 /* do it*/
1019 ret=p_surewarehk_Mod_Exp(msg,
1020 m->top*sizeof(BN_ULONG),
1021 (unsigned long *)m->d,
1022 p->top*sizeof(BN_ULONG),
1023 (unsigned long *)p->d,
1024 a->top*sizeof(BN_ULONG),
1025 (unsigned long *)a->d,
1026 (unsigned long *)r->d);
1027 surewarehk_error_handling(msg,SUREWARE_F_SUREWAREHK_MOD_EXP,ret);
1028 if (ret==1)
1029 {
1030 /* normalise result */
1031 r->top=m->top;
1032 bn_fix_top(r);
1033 }
1034 }
1035 }
1036 return ret;
1037}
1038#endif /* !OPENSSL_NO_HW_SureWare */
1039#endif /* !OPENSSL_NO_HW */
diff --git a/src/lib/libssl/src/crypto/engine/hw_ubsec.c b/src/lib/libssl/src/crypto/engine/hw_ubsec.c
index ed8401ec16..6286dd851c 100644
--- a/src/lib/libssl/src/crypto/engine/hw_ubsec.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/engine/tb_cipher.c b/src/lib/libssl/src/crypto/engine/tb_cipher.c
index c5a50fc910..50b3cec1fa 100644
--- a/src/lib/libssl/src/crypto/engine/tb_cipher.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/engine/tb_dh.c b/src/lib/libssl/src/crypto/engine/tb_dh.c
index c9347235ea..e290e1702b 100644
--- a/src/lib/libssl/src/crypto/engine/tb_dh.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/engine/tb_digest.c b/src/lib/libssl/src/crypto/engine/tb_digest.c
index 2c4dd6f796..e82d2a17c9 100644
--- a/src/lib/libssl/src/crypto/engine/tb_digest.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/engine/tb_dsa.c b/src/lib/libssl/src/crypto/engine/tb_dsa.c
index e9209476b8..80170591f2 100644
--- a/src/lib/libssl/src/crypto/engine/tb_dsa.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/engine/tb_rand.c b/src/lib/libssl/src/crypto/engine/tb_rand.c
index 0b1d031f1e..69b67111bc 100644
--- a/src/lib/libssl/src/crypto/engine/tb_rand.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/engine/tb_rsa.c b/src/lib/libssl/src/crypto/engine/tb_rsa.c
index f84fea3968..fee4867f52 100644
--- a/src/lib/libssl/src/crypto/engine/tb_rsa.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/engine/vendor_defns/hw_ubsec.h b/src/lib/libssl/src/crypto/engine/vendor_defns/hw_ubsec.h
new file mode 100644
index 0000000000..b6619d40f2
--- /dev/null
+++ b/src/lib/libssl/src/crypto/engine/vendor_defns/hw_ubsec.h
@@ -0,0 +1,100 @@
1/******************************************************************************
2 *
3 * Copyright 2000
4 * Broadcom Corporation
5 * 16215 Alton Parkway
6 * PO Box 57013
7 * Irvine CA 92619-7013
8 *
9 *****************************************************************************/
10/*
11 * Broadcom Corporation uBSec SDK
12 */
13/*
14 * Character device header file.
15 */
16/*
17 * Revision History:
18 *
19 * October 2000 JTT Created.
20 */
21
22#define MAX_PUBLIC_KEY_BITS (1024)
23#define MAX_PUBLIC_KEY_BYTES (1024/8)
24#define SHA_BIT_SIZE (160)
25#define MAX_CRYPTO_KEY_LENGTH 24
26#define MAX_MAC_KEY_LENGTH 64
27#define UBSEC_CRYPTO_DEVICE_NAME ((unsigned char *)"/dev/ubscrypt")
28#define UBSEC_KEY_DEVICE_NAME ((unsigned char *)"/dev/ubskey")
29
30/* Math command types. */
31#define UBSEC_MATH_MODADD 0x0001
32#define UBSEC_MATH_MODSUB 0x0002
33#define UBSEC_MATH_MODMUL 0x0004
34#define UBSEC_MATH_MODEXP 0x0008
35#define UBSEC_MATH_MODREM 0x0010
36#define UBSEC_MATH_MODINV 0x0020
37
38typedef long ubsec_MathCommand_t;
39typedef long ubsec_RNGCommand_t;
40
41typedef struct ubsec_crypto_context_s {
42 unsigned int flags;
43 unsigned char crypto[MAX_CRYPTO_KEY_LENGTH];
44 unsigned char auth[MAX_MAC_KEY_LENGTH];
45} ubsec_crypto_context_t, *ubsec_crypto_context_p;
46
47/*
48 * Predeclare the function pointer types that we dynamically load from the DSO.
49 */
50
51typedef int t_UBSEC_ubsec_bytes_to_bits(unsigned char *n, int bytes);
52
53typedef int t_UBSEC_ubsec_bits_to_bytes(int bits);
54
55typedef int t_UBSEC_ubsec_open(unsigned char *device);
56
57typedef int t_UBSEC_ubsec_close(int fd);
58
59typedef int t_UBSEC_diffie_hellman_generate_ioctl (int fd,
60 unsigned char *x, int *x_len, unsigned char *y, int *y_len,
61 unsigned char *g, int g_len, unsigned char *m, int m_len,
62 unsigned char *userX, int userX_len, int random_bits);
63
64typedef int t_UBSEC_diffie_hellman_agree_ioctl (int fd,
65 unsigned char *x, int x_len, unsigned char *y, int y_len,
66 unsigned char *m, int m_len, unsigned char *k, int *k_len);
67
68typedef int t_UBSEC_rsa_mod_exp_ioctl (int fd,
69 unsigned char *x, int x_len, unsigned char *m, int m_len,
70 unsigned char *e, int e_len, unsigned char *y, int *y_len);
71
72typedef int t_UBSEC_rsa_mod_exp_crt_ioctl (int fd,
73 unsigned char *x, int x_len, unsigned char *qinv, int qinv_len,
74 unsigned char *edq, int edq_len, unsigned char *q, int q_len,
75 unsigned char *edp, int edp_len, unsigned char *p, int p_len,
76 unsigned char *y, int *y_len);
77
78typedef int t_UBSEC_dsa_sign_ioctl (int fd,
79 int hash, unsigned char *data, int data_len,
80 unsigned char *rndom, int random_len,
81 unsigned char *p, int p_len, unsigned char *q, int q_len,
82 unsigned char *g, int g_len, unsigned char *key, int key_len,
83 unsigned char *r, int *r_len, unsigned char *s, int *s_len);
84
85typedef int t_UBSEC_dsa_verify_ioctl (int fd,
86 int hash, unsigned char *data, int data_len,
87 unsigned char *p, int p_len, unsigned char *q, int q_len,
88 unsigned char *g, int g_len, unsigned char *key, int key_len,
89 unsigned char *r, int r_len, unsigned char *s, int s_len,
90 unsigned char *v, int *v_len);
91
92typedef int t_UBSEC_math_accelerate_ioctl(int fd, ubsec_MathCommand_t command,
93 unsigned char *ModN, int *ModN_len, unsigned char *ExpE, int *ExpE_len,
94 unsigned char *ParamA, int *ParamA_len, unsigned char *ParamB, int *ParamB_len,
95 unsigned char *Result, int *Result_len);
96
97typedef int t_UBSEC_rng_ioctl(int fd, ubsec_RNGCommand_t command,
98 unsigned char *Result, int *Result_len);
99
100typedef int t_UBSEC_max_key_len_ioctl(int fd, int *max_key_len);
diff --git a/src/lib/libssl/src/crypto/engine/vendor_defns/hwcryptohook.h b/src/lib/libssl/src/crypto/engine/vendor_defns/hwcryptohook.h
new file mode 100644
index 0000000000..aaa4d4575e
--- /dev/null
+++ b/src/lib/libssl/src/crypto/engine/vendor_defns/hwcryptohook.h
@@ -0,0 +1,486 @@
1/*
2 * ModExp / RSA (with/without KM) plugin API
3 *
4 * The application will load a dynamic library which
5 * exports entrypoint(s) defined in this file.
6 *
7 * This set of entrypoints provides only a multithreaded,
8 * synchronous-within-each-thread, facility.
9 *
10 *
11 * This file is Copyright 1998-2000 nCipher Corporation Limited.
12 *
13 * Redistribution and use in source and binary forms, with opr without
14 * modification, are permitted provided that the following conditions
15 * are met:
16 *
17 * 1. Redistributions of source code must retain the copyright notice,
18 * this list of conditions, and the following disclaimer.
19 *
20 * 2. Redistributions in binary form must reproduce the above
21 * copyright notice, this list of conditions, and the following
22 * disclaimer, in the documentation and/or other materials provided
23 * with the distribution
24 *
25 * IN NO EVENT SHALL NCIPHER CORPORATION LIMITED (`NCIPHER') AND/OR
26 * ANY OTHER AUTHORS OR DISTRIBUTORS OF THIS FILE BE LIABLE for any
27 * damages arising directly or indirectly from this file, its use or
28 * this licence. Without prejudice to the generality of the
29 * foregoing: all liability shall be excluded for direct, indirect,
30 * special, incidental, consequential or other damages or any loss of
31 * profits, business, revenue goodwill or anticipated savings;
32 * liability shall be excluded even if nCipher or anyone else has been
33 * advised of the possibility of damage. In any event, if the
34 * exclusion of liability is not effective, the liability of nCipher
35 * or any author or distributor shall be limited to the lesser of the
36 * price paid and 1,000 pounds sterling. This licence only fails to
37 * exclude or limit liability for death or personal injury arising out
38 * of negligence, and only to the extent that such an exclusion or
39 * limitation is not effective.
40 *
41 * NCIPHER AND THE AUTHORS AND DISTRIBUTORS SPECIFICALLY DISCLAIM ALL
42 * AND ANY WARRANTIES (WHETHER EXPRESS OR IMPLIED), including, but not
43 * limited to, any implied warranties of merchantability, fitness for
44 * a particular purpose, satisfactory quality, and/or non-infringement
45 * of any third party rights.
46 *
47 * US Government use: This software and documentation is Commercial
48 * Computer Software and Computer Software Documentation, as defined in
49 * sub-paragraphs (a)(1) and (a)(5) of DFAR 252.227-7014, "Rights in
50 * Noncommercial Computer Software and Noncommercial Computer Software
51 * Documentation." Use, duplication or disclosure by the Government is
52 * subject to the terms and conditions specified here.
53 *
54 * By using or distributing this file you will be accepting these
55 * terms and conditions, including the limitation of liability and
56 * lack of warranty. If you do not wish to accept these terms and
57 * conditions, DO NOT USE THE FILE.
58 *
59 *
60 * The actual dynamically loadable plugin, and the library files for
61 * static linking, which are also provided in some distributions, are
62 * not covered by the licence described above. You should have
63 * received a separate licence with terms and conditions for these
64 * library files; if you received the library files without a licence,
65 * please contact nCipher.
66 *
67 *
68 * $Id: hwcryptohook.h,v 1.1.1.1 2003/05/11 21:35:16 markus Exp $
69 */
70
71#ifndef HWCRYPTOHOOK_H
72#define HWCRYPTOHOOK_H
73
74#include <sys/types.h>
75#include <stdio.h>
76
77#ifndef HWCRYPTOHOOK_DECLARE_APPTYPES
78#define HWCRYPTOHOOK_DECLARE_APPTYPES 1
79#endif
80
81#define HWCRYPTOHOOK_ERROR_FAILED -1
82#define HWCRYPTOHOOK_ERROR_FALLBACK -2
83#define HWCRYPTOHOOK_ERROR_MPISIZE -3
84
85#if HWCRYPTOHOOK_DECLARE_APPTYPES
86
87/* These structs are defined by the application and opaque to the
88 * crypto plugin. The application may define these as it sees fit.
89 * Default declarations are provided here, but the application may
90 * #define HWCRYPTOHOOK_DECLARE_APPTYPES 0
91 * to prevent these declarations, and instead provide its own
92 * declarations of these types. (Pointers to them must still be
93 * ordinary pointers to structs or unions, or the resulting combined
94 * program will have a type inconsistency.)
95 */
96typedef struct HWCryptoHook_MutexValue HWCryptoHook_Mutex;
97typedef struct HWCryptoHook_CondVarValue HWCryptoHook_CondVar;
98typedef struct HWCryptoHook_PassphraseContextValue HWCryptoHook_PassphraseContext;
99typedef struct HWCryptoHook_CallerContextValue HWCryptoHook_CallerContext;
100
101#endif /* HWCRYPTOHOOK_DECLARE_APPTYPES */
102
103/* These next two structs are opaque to the application. The crypto
104 * plugin will return pointers to them; the caller simply manipulates
105 * the pointers.
106 */
107typedef struct HWCryptoHook_Context *HWCryptoHook_ContextHandle;
108typedef struct HWCryptoHook_RSAKey *HWCryptoHook_RSAKeyHandle;
109
110typedef struct {
111 char *buf;
112 size_t size;
113} HWCryptoHook_ErrMsgBuf;
114/* Used for error reporting. When a HWCryptoHook function fails it
115 * will return a sentinel value (0 for pointer-valued functions, or a
116 * negative number, usually HWCRYPTOHOOK_ERROR_FAILED, for
117 * integer-valued ones). It will, if an ErrMsgBuf is passed, also put
118 * an error message there.
119 *
120 * size is the size of the buffer, and will not be modified. If you
121 * pass 0 for size you must pass 0 for buf, and nothing will be
122 * recorded (just as if you passed 0 for the struct pointer).
123 * Messages written to the buffer will always be null-terminated, even
124 * when truncated to fit within size bytes.
125 *
126 * The contents of the buffer are not defined if there is no error.
127 */
128
129typedef struct HWCryptoHook_MPIStruct {
130 unsigned char *buf;
131 size_t size;
132} HWCryptoHook_MPI;
133/* When one of these is returned, a pointer is passed to the function.
134 * At call, size is the space available. Afterwards it is updated to
135 * be set to the actual length (which may be more than the space available,
136 * if there was not enough room and the result was truncated).
137 * buf (the pointer) is not updated.
138 *
139 * size is in bytes and may be zero at call or return, but must be a
140 * multiple of the limb size. Zero limbs at the MS end are not
141 * permitted.
142 */
143
144#define HWCryptoHook_InitFlags_FallbackModExp 0x0002UL
145#define HWCryptoHook_InitFlags_FallbackRSAImmed 0x0004UL
146/* Enable requesting fallback to software in case of problems with the
147 * hardware support. This indicates to the crypto provider that the
148 * application is prepared to fall back to software operation if the
149 * ModExp* or RSAImmed* functions return HWCRYPTOHOOK_ERROR_FALLBACK.
150 * Without this flag those calls will never return
151 * HWCRYPTOHOOK_ERROR_FALLBACK. The flag will also cause the crypto
152 * provider to avoid repeatedly attempting to contact dead hardware
153 * within a short interval, if appropriate.
154 */
155
156#define HWCryptoHook_InitFlags_SimpleForkCheck 0x0010UL
157/* Without _SimpleForkCheck the library is allowed to assume that the
158 * application will not fork and call the library in the child(ren).
159 *
160 * When it is specified, this is allowed. However, after a fork
161 * neither parent nor child may unload any loaded keys or call
162 * _Finish. Instead, they should call exit (or die with a signal)
163 * without calling _Finish. After all the children have died the
164 * parent may unload keys or call _Finish.
165 *
166 * This flag only has any effect on UN*X platforms.
167 */
168
169typedef struct {
170 unsigned long flags;
171 void *logstream; /* usually a FILE*. See below. */
172
173 size_t limbsize; /* bignum format - size of radix type, must be power of 2 */
174 int mslimbfirst; /* 0 or 1 */
175 int msbytefirst; /* 0 or 1; -1 = native */
176
177 /* All the callback functions should return 0 on success, or a
178 * nonzero integer (whose value will be visible in the error message
179 * put in the buffer passed to the call).
180 *
181 * If a callback is not available pass a null function pointer.
182 *
183 * The callbacks may not call down again into the crypto plugin.
184 */
185
186 /* For thread-safety. Set everything to 0 if you promise only to be
187 * singlethreaded. maxsimultaneous is the number of calls to
188 * ModExp[Crt]/RSAImmed{Priv,Pub}/RSA. If you don't know what to
189 * put there then say 0 and the hook library will use a default.
190 *
191 * maxmutexes is a small limit on the number of simultaneous mutexes
192 * which will be requested by the library. If there is no small
193 * limit, set it to 0. If the crypto plugin cannot create the
194 * advertised number of mutexes the calls to its functions may fail.
195 * If a low number of mutexes is advertised the plugin will try to
196 * do the best it can. Making larger numbers of mutexes available
197 * may improve performance and parallelism by reducing contention
198 * over critical sections. Unavailability of any mutexes, implying
199 * single-threaded operation, should be indicated by the setting
200 * mutex_init et al to 0.
201 */
202 int maxmutexes;
203 int maxsimultaneous;
204 size_t mutexsize;
205 int (*mutex_init)(HWCryptoHook_Mutex*, HWCryptoHook_CallerContext *cactx);
206 int (*mutex_acquire)(HWCryptoHook_Mutex*);
207 void (*mutex_release)(HWCryptoHook_Mutex*);
208 void (*mutex_destroy)(HWCryptoHook_Mutex*);
209
210 /* For greater efficiency, can use condition vars internally for
211 * synchronisation. In this case maxsimultaneous is ignored, but
212 * the other mutex stuff must be available. In singlethreaded
213 * programs, set everything to 0.
214 */
215 size_t condvarsize;
216 int (*condvar_init)(HWCryptoHook_CondVar*, HWCryptoHook_CallerContext *cactx);
217 int (*condvar_wait)(HWCryptoHook_CondVar*, HWCryptoHook_Mutex*);
218 void (*condvar_signal)(HWCryptoHook_CondVar*);
219 void (*condvar_broadcast)(HWCryptoHook_CondVar*);
220 void (*condvar_destroy)(HWCryptoHook_CondVar*);
221
222 /* The semantics of acquiring and releasing mutexes and broadcasting
223 * and waiting on condition variables are expected to be those from
224 * POSIX threads (pthreads). The mutexes may be (in pthread-speak)
225 * fast mutexes, recursive mutexes, or nonrecursive ones.
226 *
227 * The _release/_signal/_broadcast and _destroy functions must
228 * always succeed when given a valid argument; if they are given an
229 * invalid argument then the program (crypto plugin + application)
230 * has an internal error, and they should abort the program.
231 */
232
233 int (*getpassphrase)(const char *prompt_info,
234 int *len_io, char *buf,
235 HWCryptoHook_PassphraseContext *ppctx,
236 HWCryptoHook_CallerContext *cactx);
237 /* Passphrases and the prompt_info, if they contain high-bit-set
238 * characters, are UTF-8. The prompt_info may be a null pointer if
239 * no prompt information is available (it should not be an empty
240 * string). It will not contain text like `enter passphrase';
241 * instead it might say something like `Operator Card for John
242 * Smith' or `SmartCard in nFast Module #1, Slot #1'.
243 *
244 * buf points to a buffer in which to return the passphrase; on
245 * entry *len_io is the length of the buffer. It should be updated
246 * by the callback. The returned passphrase should not be
247 * null-terminated by the callback.
248 */
249
250 int (*getphystoken)(const char *prompt_info,
251 const char *wrong_info,
252 HWCryptoHook_PassphraseContext *ppctx,
253 HWCryptoHook_CallerContext *cactx);
254 /* Requests that the human user physically insert a different
255 * smartcard, DataKey, etc. The plugin should check whether the
256 * currently inserted token(s) are appropriate, and if they are it
257 * should not make this call.
258 *
259 * prompt_info is as before. wrong_info is a description of the
260 * currently inserted token(s) so that the user is told what
261 * something is. wrong_info, like prompt_info, may be null, but
262 * should not be an empty string. Its contents should be
263 * syntactically similar to that of prompt_info.
264 */
265
266 /* Note that a single LoadKey operation might cause several calls to
267 * getpassphrase and/or requestphystoken. If requestphystoken is
268 * not provided (ie, a null pointer is passed) then the plugin may
269 * not support loading keys for which authorisation by several cards
270 * is required. If getpassphrase is not provided then cards with
271 * passphrases may not be supported.
272 *
273 * getpassphrase and getphystoken do not need to check that the
274 * passphrase has been entered correctly or the correct token
275 * inserted; the crypto plugin will do that. If this is not the
276 * case then the crypto plugin is responsible for calling these
277 * routines again as appropriate until the correct token(s) and
278 * passphrase(s) are supplied as required, or until any retry limits
279 * implemented by the crypto plugin are reached.
280 *
281 * In either case, the application must allow the user to say `no'
282 * or `cancel' to indicate that they do not know the passphrase or
283 * have the appropriate token; this should cause the callback to
284 * return nonzero indicating error.
285 */
286
287 void (*logmessage)(void *logstream, const char *message);
288 /* A log message will be generated at least every time something goes
289 * wrong and an ErrMsgBuf is filled in (or would be if one was
290 * provided). Other diagnostic information may be written there too,
291 * including more detailed reasons for errors which are reported in an
292 * ErrMsgBuf.
293 *
294 * When a log message is generated, this callback is called. It
295 * should write a message to the relevant logging arrangements.
296 *
297 * The message string passed will be null-terminated and may be of arbitrary
298 * length. It will not be prefixed by the time and date, nor by the
299 * name of the library that is generating it - if this is required,
300 * the logmessage callback must do it. The message will not have a
301 * trailing newline (though it may contain internal newlines).
302 *
303 * If a null pointer is passed for logmessage a default function is
304 * used. The default function treats logstream as a FILE* which has
305 * been converted to a void*. If logstream is 0 it does nothing.
306 * Otherwise it prepends the date and time and library name and
307 * writes the message to logstream. Each line will be prefixed by a
308 * descriptive string containing the date, time and identity of the
309 * crypto plugin. Errors on the logstream are not reported
310 * anywhere, and the default function doesn't flush the stream, so
311 * the application must set the buffering how it wants it.
312 *
313 * The crypto plugin may also provide a facility to have copies of
314 * log messages sent elsewhere, and or for adjusting the verbosity
315 * of the log messages; any such facilities will be configured by
316 * external means.
317 */
318
319} HWCryptoHook_InitInfo;
320
321typedef
322HWCryptoHook_ContextHandle HWCryptoHook_Init_t(const HWCryptoHook_InitInfo *initinfo,
323 size_t initinfosize,
324 const HWCryptoHook_ErrMsgBuf *errors,
325 HWCryptoHook_CallerContext *cactx);
326extern HWCryptoHook_Init_t HWCryptoHook_Init;
327
328/* Caller should set initinfosize to the size of the HWCryptoHook struct,
329 * so it can be extended later.
330 *
331 * On success, a message for display or logging by the server,
332 * including the name and version number of the plugin, will be filled
333 * in into *errors; on failure *errors is used for error handling, as
334 * usual.
335 */
336
337/* All these functions return 0 on success, HWCRYPTOHOOK_ERROR_FAILED
338 * on most failures. HWCRYPTOHOOK_ERROR_MPISIZE means at least one of
339 * the output MPI buffer(s) was too small; the sizes of all have been
340 * set to the desired size (and for those where the buffer was large
341 * enough, the value may have been copied in), and no error message
342 * has been recorded.
343 *
344 * You may pass 0 for the errors struct. In any case, unless you set
345 * _NoStderr at init time then messages may be reported to stderr.
346 */
347
348/* The RSAImmed* functions (and key managed RSA) only work with
349 * modules which have an RSA patent licence - currently that means KM
350 * units; the ModExp* ones work with all modules, so you need a patent
351 * licence in the software in the US. They are otherwise identical.
352 */
353
354typedef
355void HWCryptoHook_Finish_t(HWCryptoHook_ContextHandle hwctx);
356extern HWCryptoHook_Finish_t HWCryptoHook_Finish;
357/* You must not have any calls going or keys loaded when you call this. */
358
359typedef
360int HWCryptoHook_RandomBytes_t(HWCryptoHook_ContextHandle hwctx,
361 unsigned char *buf, size_t len,
362 const HWCryptoHook_ErrMsgBuf *errors);
363extern HWCryptoHook_RandomBytes_t HWCryptoHook_RandomBytes;
364
365typedef
366int HWCryptoHook_ModExp_t(HWCryptoHook_ContextHandle hwctx,
367 HWCryptoHook_MPI a,
368 HWCryptoHook_MPI p,
369 HWCryptoHook_MPI n,
370 HWCryptoHook_MPI *r,
371 const HWCryptoHook_ErrMsgBuf *errors);
372extern HWCryptoHook_ModExp_t HWCryptoHook_ModExp;
373
374typedef
375int HWCryptoHook_RSAImmedPub_t(HWCryptoHook_ContextHandle hwctx,
376 HWCryptoHook_MPI m,
377 HWCryptoHook_MPI e,
378 HWCryptoHook_MPI n,
379 HWCryptoHook_MPI *r,
380 const HWCryptoHook_ErrMsgBuf *errors);
381extern HWCryptoHook_RSAImmedPub_t HWCryptoHook_RSAImmedPub;
382
383typedef
384int HWCryptoHook_ModExpCRT_t(HWCryptoHook_ContextHandle hwctx,
385 HWCryptoHook_MPI a,
386 HWCryptoHook_MPI p,
387 HWCryptoHook_MPI q,
388 HWCryptoHook_MPI dmp1,
389 HWCryptoHook_MPI dmq1,
390 HWCryptoHook_MPI iqmp,
391 HWCryptoHook_MPI *r,
392 const HWCryptoHook_ErrMsgBuf *errors);
393extern HWCryptoHook_ModExpCRT_t HWCryptoHook_ModExpCRT;
394
395typedef
396int HWCryptoHook_RSAImmedPriv_t(HWCryptoHook_ContextHandle hwctx,
397 HWCryptoHook_MPI m,
398 HWCryptoHook_MPI p,
399 HWCryptoHook_MPI q,
400 HWCryptoHook_MPI dmp1,
401 HWCryptoHook_MPI dmq1,
402 HWCryptoHook_MPI iqmp,
403 HWCryptoHook_MPI *r,
404 const HWCryptoHook_ErrMsgBuf *errors);
405extern HWCryptoHook_RSAImmedPriv_t HWCryptoHook_RSAImmedPriv;
406
407/* The RSAImmed* and ModExp* functions may return E_FAILED or
408 * E_FALLBACK for failure.
409 *
410 * E_FAILED means the failure is permanent and definite and there
411 * should be no attempt to fall back to software. (Eg, for some
412 * applications, which support only the acceleration-only
413 * functions, the `key material' may actually be an encoded key
414 * identifier, and doing the operation in software would give wrong
415 * answers.)
416 *
417 * E_FALLBACK means that doing the computation in software would seem
418 * reasonable. If an application pays attention to this and is
419 * able to fall back, it should also set the Fallback init flags.
420 */
421
422typedef
423int HWCryptoHook_RSALoadKey_t(HWCryptoHook_ContextHandle hwctx,
424 const char *key_ident,
425 HWCryptoHook_RSAKeyHandle *keyhandle_r,
426 const HWCryptoHook_ErrMsgBuf *errors,
427 HWCryptoHook_PassphraseContext *ppctx);
428extern HWCryptoHook_RSALoadKey_t HWCryptoHook_RSALoadKey;
429/* The key_ident is a null-terminated string configured by the
430 * user via the application's usual configuration mechanisms.
431 * It is provided to the user by the crypto provider's key management
432 * system. The user must be able to enter at least any string of between
433 * 1 and 1023 characters inclusive, consisting of printable 7-bit
434 * ASCII characters. The provider should avoid using
435 * any characters except alphanumerics and the punctuation
436 * characters _ - + . / @ ~ (the user is expected to be able
437 * to enter these without quoting). The string may be case-sensitive.
438 * The application may allow the user to enter other NULL-terminated strings,
439 * and the provider must cope (returning an error if the string is not
440 * valid).
441 *
442 * If the key does not exist, no error is recorded and 0 is returned;
443 * keyhandle_r will be set to 0 instead of to a key handle.
444 */
445
446typedef
447int HWCryptoHook_RSAGetPublicKey_t(HWCryptoHook_RSAKeyHandle k,
448 HWCryptoHook_MPI *n,
449 HWCryptoHook_MPI *e,
450 const HWCryptoHook_ErrMsgBuf *errors);
451extern HWCryptoHook_RSAGetPublicKey_t HWCryptoHook_RSAGetPublicKey;
452/* The crypto plugin will not store certificates.
453 *
454 * Although this function for acquiring the public key value is
455 * provided, it is not the purpose of this API to deal fully with the
456 * handling of the public key.
457 *
458 * It is expected that the crypto supplier's key generation program
459 * will provide general facilities for producing X.509
460 * self-certificates and certificate requests in PEM format. These
461 * will be given to the user so that they can configure them in the
462 * application, send them to CAs, or whatever.
463 *
464 * In case this kind of certificate handling is not appropriate, the
465 * crypto supplier's key generation program should be able to be
466 * configured not to generate such a self-certificate or certificate
467 * request. Then the application will need to do all of this, and
468 * will need to store and handle the public key and certificates
469 * itself.
470 */
471
472typedef
473int HWCryptoHook_RSAUnloadKey_t(HWCryptoHook_RSAKeyHandle k,
474 const HWCryptoHook_ErrMsgBuf *errors);
475extern HWCryptoHook_RSAUnloadKey_t HWCryptoHook_RSAUnloadKey;
476/* Might fail due to locking problems, or other serious internal problems. */
477
478typedef
479int HWCryptoHook_RSA_t(HWCryptoHook_MPI m,
480 HWCryptoHook_RSAKeyHandle k,
481 HWCryptoHook_MPI *r,
482 const HWCryptoHook_ErrMsgBuf *errors);
483extern HWCryptoHook_RSA_t HWCryptoHook_RSA;
484/* RSA private key operation (sign or decrypt) - raw, unpadded. */
485
486#endif /*HWCRYPTOHOOK_H*/
diff --git a/src/lib/libssl/src/crypto/engine/vendor_defns/sureware.h b/src/lib/libssl/src/crypto/engine/vendor_defns/sureware.h
new file mode 100644
index 0000000000..1d3789219d
--- /dev/null
+++ b/src/lib/libssl/src/crypto/engine/vendor_defns/sureware.h
@@ -0,0 +1,239 @@
1/*
2* Written by Corinne Dive-Reclus(cdive@baltimore.com)
3*
4* Copyright@2001 Baltimore Technologies Ltd.
5* *
6* THIS FILE IS PROVIDED BY BALTIMORE TECHNOLOGIES ``AS IS'' AND *
7* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE *
8* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE *
9* ARE DISCLAIMED. IN NO EVENT SHALL BALTIMORE TECHNOLOGIES BE LIABLE *
10* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL *
11* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS *
12* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) *
13* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT *
14* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY *
15* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF *
16* SUCH DAMAGE. *
17*
18*
19*/
20#ifdef WIN32
21#define SW_EXPORT __declspec ( dllexport )
22#else
23#define SW_EXPORT
24#endif
25
26/*
27* List of exposed SureWare errors
28*/
29#define SUREWAREHOOK_ERROR_FAILED -1
30#define SUREWAREHOOK_ERROR_FALLBACK -2
31#define SUREWAREHOOK_ERROR_UNIT_FAILURE -3
32#define SUREWAREHOOK_ERROR_DATA_SIZE -4
33#define SUREWAREHOOK_ERROR_INVALID_PAD -5
34/*
35* -----------------WARNING-----------------------------------
36* In all the following functions:
37* msg is a string with at least 24 bytes free.
38* A 24 bytes string will be concatenated to the existing content of msg.
39*/
40/*
41* SureWare Initialisation function
42* in param threadsafe, if !=0, thread safe enabled
43* return SureWareHOOK_ERROR_UNIT_FAILURE if failure, 1 if success
44*/
45typedef int SureWareHook_Init_t(char*const msg,int threadsafe);
46extern SW_EXPORT SureWareHook_Init_t SureWareHook_Init;
47/*
48* SureWare Finish function
49*/
50typedef void SureWareHook_Finish_t();
51extern SW_EXPORT SureWareHook_Finish_t SureWareHook_Finish;
52/*
53* PRE_CONDITION:
54* DO NOT CALL ANY OF THE FOLLOWING FUNCTIONS IN CASE OF INIT FAILURE
55*/
56/*
57* SureWare RAND Bytes function
58* In case of failure, the content of buf is unpredictable.
59* return 1 if success
60* SureWareHOOK_ERROR_FALLBACK if function not available in hardware
61* SureWareHOOK_ERROR_FAILED if error while processing
62* SureWareHOOK_ERROR_UNIT_FAILURE if hardware failure
63* SUREWAREHOOK_ERROR_DATA_SIZE wrong size for buf
64*
65* in/out param buf : a num bytes long buffer where random bytes will be put
66* in param num : the number of bytes into buf
67*/
68typedef int SureWareHook_Rand_Bytes_t(char*const msg,unsigned char *buf, int num);
69extern SW_EXPORT SureWareHook_Rand_Bytes_t SureWareHook_Rand_Bytes;
70
71/*
72* SureWare RAND Seed function
73* Adds some seed to the Hardware Random Number Generator
74* return 1 if success
75* SureWareHOOK_ERROR_FALLBACK if function not available in hardware
76* SureWareHOOK_ERROR_FAILED if error while processing
77* SureWareHOOK_ERROR_UNIT_FAILURE if hardware failure
78* SUREWAREHOOK_ERROR_DATA_SIZE wrong size for buf
79*
80* in param buf : the seed to add into the HRNG
81* in param num : the number of bytes into buf
82*/
83typedef int SureWareHook_Rand_Seed_t(char*const msg,const void *buf, int num);
84extern SW_EXPORT SureWareHook_Rand_Seed_t SureWareHook_Rand_Seed;
85
86/*
87* SureWare Load Private Key function
88* return 1 if success
89* SureWareHOOK_ERROR_FAILED if error while processing
90* No hardware is contact for this function.
91*
92* in param key_id :the name of the private protected key file without the extension
93 ".sws"
94* out param hptr : a pointer to a buffer allocated by SureWare_Hook
95* out param num: the effective key length in bytes
96* out param keytype: 1 if RSA 2 if DSA
97*/
98typedef int SureWareHook_Load_Privkey_t(char*const msg,const char *key_id,char **hptr,unsigned long *num,char *keytype);
99extern SW_EXPORT SureWareHook_Load_Privkey_t SureWareHook_Load_Privkey;
100
101/*
102* SureWare Info Public Key function
103* return 1 if success
104* SureWareHOOK_ERROR_FAILED if error while processing
105* No hardware is contact for this function.
106*
107* in param key_id :the name of the private protected key file without the extension
108 ".swp"
109* out param hptr : a pointer to a buffer allocated by SureWare_Hook
110* out param num: the effective key length in bytes
111* out param keytype: 1 if RSA 2 if DSA
112*/
113typedef int SureWareHook_Info_Pubkey_t(char*const msg,const char *key_id,unsigned long *num,
114 char *keytype);
115extern SW_EXPORT SureWareHook_Info_Pubkey_t SureWareHook_Info_Pubkey;
116
117/*
118* SureWare Load Public Key function
119* return 1 if success
120* SureWareHOOK_ERROR_FAILED if error while processing
121* No hardware is contact for this function.
122*
123* in param key_id :the name of the public protected key file without the extension
124 ".swp"
125* in param num : the bytes size of n and e
126* out param n: where to write modulus in bn format
127* out param e: where to write exponent in bn format
128*/
129typedef int SureWareHook_Load_Rsa_Pubkey_t(char*const msg,const char *key_id,unsigned long num,
130 unsigned long *n, unsigned long *e);
131extern SW_EXPORT SureWareHook_Load_Rsa_Pubkey_t SureWareHook_Load_Rsa_Pubkey;
132
133/*
134* SureWare Load DSA Public Key function
135* return 1 if success
136* SureWareHOOK_ERROR_FAILED if error while processing
137* No hardware is contact for this function.
138*
139* in param key_id :the name of the public protected key file without the extension
140 ".swp"
141* in param num : the bytes size of n and e
142* out param pub: where to write pub key in bn format
143* out param p: where to write prime in bn format
144* out param q: where to write sunprime (length 20 bytes) in bn format
145* out param g: where to write base in bn format
146*/
147typedef int SureWareHook_Load_Dsa_Pubkey_t(char*const msg,const char *key_id,unsigned long num,
148 unsigned long *pub, unsigned long *p,unsigned long*q,
149 unsigned long *g);
150extern SW_EXPORT SureWareHook_Load_Dsa_Pubkey_t SureWareHook_Load_Dsa_Pubkey;
151
152/*
153* SureWare Free function
154* Destroy the key into the hardware if destroy==1
155*/
156typedef void SureWareHook_Free_t(char *p,int destroy);
157extern SW_EXPORT SureWareHook_Free_t SureWareHook_Free;
158
159#define SUREWARE_PKCS1_PAD 1
160#define SUREWARE_ISO9796_PAD 2
161#define SUREWARE_NO_PAD 0
162/*
163* SureWare RSA Private Decryption
164* return 1 if success
165* SureWareHOOK_ERROR_FAILED if error while processing
166* SureWareHOOK_ERROR_UNIT_FAILURE if hardware failure
167* SUREWAREHOOK_ERROR_DATA_SIZE wrong size for buf
168*
169* in param flen : byte size of from and to
170* in param from : encrypted data buffer, should be a not-null valid pointer
171* out param tlen: byte size of decrypted data, if error, unexpected value
172* out param to : decrypted data buffer, should be a not-null valid pointer
173* in param prsa: a protected key pointer, should be a not-null valid pointer
174* int padding: padding id as follow
175* SUREWARE_PKCS1_PAD
176* SUREWARE_NO_PAD
177*
178*/
179typedef int SureWareHook_Rsa_Priv_Dec_t(char*const msg,int flen,unsigned char *from,
180 int *tlen,unsigned char *to,
181 char *prsa,int padding);
182extern SW_EXPORT SureWareHook_Rsa_Priv_Dec_t SureWareHook_Rsa_Priv_Dec;
183/*
184* SureWare RSA Signature
185* return 1 if success
186* SureWareHOOK_ERROR_FAILED if error while processing
187* SureWareHOOK_ERROR_UNIT_FAILURE if hardware failure
188* SUREWAREHOOK_ERROR_DATA_SIZE wrong size for buf
189*
190* in param flen : byte size of from and to
191* in param from : encrypted data buffer, should be a not-null valid pointer
192* out param tlen: byte size of decrypted data, if error, unexpected value
193* out param to : decrypted data buffer, should be a not-null valid pointer
194* in param prsa: a protected key pointer, should be a not-null valid pointer
195* int padding: padding id as follow
196* SUREWARE_PKCS1_PAD
197* SUREWARE_ISO9796_PAD
198*
199*/
200typedef int SureWareHook_Rsa_Sign_t(char*const msg,int flen,unsigned char *from,
201 int *tlen,unsigned char *to,
202 char *prsa,int padding);
203extern SW_EXPORT SureWareHook_Rsa_Sign_t SureWareHook_Rsa_Sign;
204/*
205* SureWare DSA Signature
206* return 1 if success
207* SureWareHOOK_ERROR_FAILED if error while processing
208* SureWareHOOK_ERROR_UNIT_FAILURE if hardware failure
209* SUREWAREHOOK_ERROR_DATA_SIZE wrong size for buf
210*
211* in param flen : byte size of from and to
212* in param from : encrypted data buffer, should be a not-null valid pointer
213* out param to : decrypted data buffer, should be a 40bytes valid pointer
214* in param pdsa: a protected key pointer, should be a not-null valid pointer
215*
216*/
217typedef int SureWareHook_Dsa_Sign_t(char*const msg,int flen,const unsigned char *from,
218 unsigned long *r,unsigned long *s,char *pdsa);
219extern SW_EXPORT SureWareHook_Dsa_Sign_t SureWareHook_Dsa_Sign;
220
221
222/*
223* SureWare Mod Exp
224* return 1 if success
225* SureWareHOOK_ERROR_FAILED if error while processing
226* SureWareHOOK_ERROR_UNIT_FAILURE if hardware failure
227* SUREWAREHOOK_ERROR_DATA_SIZE wrong size for buf
228*
229* mod and res are mlen bytes long.
230* exp is elen bytes long
231* data is dlen bytes long
232* mlen,elen and dlen are all multiple of sizeof(unsigned long)
233*/
234typedef int SureWareHook_Mod_Exp_t(char*const msg,int mlen,const unsigned long *mod,
235 int elen,const unsigned long *exp,
236 int dlen,unsigned long *data,
237 unsigned long *res);
238extern SW_EXPORT SureWareHook_Mod_Exp_t SureWareHook_Mod_Exp;
239
diff --git a/src/lib/libssl/src/crypto/err/err.c b/src/lib/libssl/src/crypto/err/err.c
index 5abe44e6d5..b873270c04 100644
--- a/src/lib/libssl/src/crypto/err/err.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/err/err_all.c b/src/lib/libssl/src/crypto/err/err_all.c
index 90029fd159..dc505d9d9d 100644
--- a/src/lib/libssl/src/crypto/err/err_all.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/err/err_prn.c b/src/lib/libssl/src/crypto/err/err_prn.c
index c156663f0e..81e34bd6ce 100644
--- a/src/lib/libssl/src/crypto/err/err_prn.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/evp/bio_b64.c b/src/lib/libssl/src/crypto/evp/bio_b64.c
index f12eac1b55..6e550f6a43 100644
--- a/src/lib/libssl/src/crypto/evp/bio_b64.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/evp/bio_enc.c b/src/lib/libssl/src/crypto/evp/bio_enc.c
index 64fb2353af..ab81851503 100644
--- a/src/lib/libssl/src/crypto/evp/bio_enc.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/evp/bio_ok.c b/src/lib/libssl/src/crypto/evp/bio_ok.c
index 3cbc6e7848..530ab937ce 100644
--- a/src/lib/libssl/src/crypto/evp/bio_ok.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/evp/c_all.c b/src/lib/libssl/src/crypto/evp/c_all.c
index 2d3e57c4fa..1b31a14e37 100644
--- a/src/lib/libssl/src/crypto/evp/c_all.c
+++ b/src/lib/libssl/src/crypto/evp/c_all.c
@@ -73,4 +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#ifndef OPENSSL_NO_ENGINE
77# if defined(__OpenBSD__) || defined(__FreeBSD__)
78 ENGINE_setup_bsd_cryptodev();
79# endif
80#endif
76 } 81 }
diff --git a/src/lib/libssl/src/crypto/evp/digest.c b/src/lib/libssl/src/crypto/evp/digest.c
index a969ac69ed..b22eed4421 100644
--- a/src/lib/libssl/src/crypto/evp/digest.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/evp/e_aes.c b/src/lib/libssl/src/crypto/evp/e_aes.c
index c323fa2892..fe8bcda631 100644
--- a/src/lib/libssl/src/crypto/evp/e_aes.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/evp/e_idea.c b/src/lib/libssl/src/crypto/evp/e_idea.c
index ed838d3e62..b9efa75ae7 100644
--- a/src/lib/libssl/src/crypto/evp/e_idea.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/evp/e_rc2.c b/src/lib/libssl/src/crypto/evp/e_rc2.c
index 4685198e2e..d42cbfd17e 100644
--- a/src/lib/libssl/src/crypto/evp/e_rc2.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/evp/e_rc4.c b/src/lib/libssl/src/crypto/evp/e_rc4.c
index 4064cc5fa0..d58f507837 100644
--- a/src/lib/libssl/src/crypto/evp/e_rc4.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/evp/encode.c b/src/lib/libssl/src/crypto/evp/encode.c
index 12c6379df1..08209357ce 100644
--- a/src/lib/libssl/src/crypto/evp/encode.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/evp/evp_acnf.c b/src/lib/libssl/src/crypto/evp/evp_acnf.c
index a68b979bdb..ff3e311cc5 100644
--- a/src/lib/libssl/src/crypto/evp/evp_acnf.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/evp/evp_enc.c b/src/lib/libssl/src/crypto/evp/evp_enc.c
index 32a1c7a2e9..be0758a879 100644
--- a/src/lib/libssl/src/crypto/evp/evp_enc.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/evp/evp_key.c b/src/lib/libssl/src/crypto/evp/evp_key.c
index 4271393069..5f387a94d3 100644
--- a/src/lib/libssl/src/crypto/evp/evp_key.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/evp/evp_lib.c b/src/lib/libssl/src/crypto/evp/evp_lib.c
index a431945ef5..52a3b287be 100644
--- a/src/lib/libssl/src/crypto/evp/evp_lib.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/evp/evp_pbe.c b/src/lib/libssl/src/crypto/evp/evp_pbe.c
index bcd4d29f85..0da88fdcff 100644
--- a/src/lib/libssl/src/crypto/evp/evp_pbe.c
+++ b/src/lib/libssl/src/crypto/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) strcpy (obj_tmp, "NULL"); 90 if (!pbe_obj) strcpy (obj_tmp, "NULL");
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/libssl/src/crypto/evp/evp_test.c b/src/lib/libssl/src/crypto/evp/evp_test.c
index 90294ef686..28460173f7 100644
--- a/src/lib/libssl/src/crypto/evp/evp_test.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/evp/p5_crpt.c b/src/lib/libssl/src/crypto/evp/p5_crpt.c
index 27a8286489..a1874e83b2 100644
--- a/src/lib/libssl/src/crypto/evp/p5_crpt.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/evp/p5_crpt2.c b/src/lib/libssl/src/crypto/evp/p5_crpt2.c
index 7485d6a278..1f94e1ef88 100644
--- a/src/lib/libssl/src/crypto/evp/p5_crpt2.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/evp/p_open.c b/src/lib/libssl/src/crypto/evp/p_open.c
index 6976f2a867..5a933d1cda 100644
--- a/src/lib/libssl/src/crypto/evp/p_open.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/hmac/hmac.c b/src/lib/libssl/src/crypto/hmac/hmac.c
index da363b7950..4c91f919d5 100644
--- a/src/lib/libssl/src/crypto/hmac/hmac.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/hmac/hmactest.c b/src/lib/libssl/src/crypto/hmac/hmactest.c
index 96d3beb8e6..1b906b81af 100644
--- a/src/lib/libssl/src/crypto/hmac/hmactest.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/idea/version b/src/lib/libssl/src/crypto/idea/version
new file mode 100644
index 0000000000..3f22293795
--- /dev/null
+++ b/src/lib/libssl/src/crypto/idea/version
@@ -0,0 +1,12 @@
11.1 07/12/95 - eay
2 Many thanks to Rhys Weatherley <rweather@us.oracle.com>
3 for pointing out that I was assuming little endian byte
4 order for all quantities what idea actually used
5 bigendian. No where in the spec does it mention
6 this, it is all in terms of 16 bit numbers and even the example
7 does not use byte streams for the input example :-(.
8 If you byte swap each pair of input, keys and iv, the functions
9 would produce the output as the old version :-(.
10
111.0 ??/??/95 - eay
12 First version.
diff --git a/src/lib/libssl/src/crypto/lhash/lh_stats.c b/src/lib/libssl/src/crypto/lhash/lh_stats.c
index 39ea2885f4..5aa7766aa6 100644
--- a/src/lib/libssl/src/crypto/lhash/lh_stats.c
+++ b/src/lib/libssl/src/crypto/lhash/lh_stats.c
@@ -179,49 +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 sprintf(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 sprintf(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 sprintf(buf,"num_alloc_nodes = %u\n",lh->num_alloc_nodes); 188 BIO_printf(out,"num_contracts = %lu\n",lh->num_contracts);
189 BIO_puts(out,buf); 189 BIO_printf(out,"num_contract_reallocs = %lu\n",
190 sprintf(buf,"num_expands = %lu\n",lh->num_expands); 190 lh->num_contract_reallocs);
191 BIO_puts(out,buf); 191 BIO_printf(out,"num_hash_calls = %lu\n",lh->num_hash_calls);
192 sprintf(buf,"num_expand_reallocs = %lu\n",lh->num_expand_reallocs); 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 sprintf(buf,"num_contracts = %lu\n",lh->num_contracts); 194 BIO_printf(out,"num_replace = %lu\n",lh->num_replace);
195 BIO_puts(out,buf); 195 BIO_printf(out,"num_delete = %lu\n",lh->num_delete);
196 sprintf(buf,"num_contract_reallocs = %lu\n",lh->num_contract_reallocs); 196 BIO_printf(out,"num_no_delete = %lu\n",lh->num_no_delete);
197 BIO_puts(out,buf); 197 BIO_printf(out,"num_retrieve = %lu\n",lh->num_retrieve);
198 sprintf(buf,"num_hash_calls = %lu\n",lh->num_hash_calls); 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 sprintf(buf,"num_comp_calls = %lu\n",lh->num_comp_calls);
201 BIO_puts(out,buf);
202 sprintf(buf,"num_insert = %lu\n",lh->num_insert);
203 BIO_puts(out,buf);
204 sprintf(buf,"num_replace = %lu\n",lh->num_replace);
205 BIO_puts(out,buf);
206 sprintf(buf,"num_delete = %lu\n",lh->num_delete);
207 BIO_puts(out,buf);
208 sprintf(buf,"num_no_delete = %lu\n",lh->num_no_delete);
209 BIO_puts(out,buf);
210 sprintf(buf,"num_retrieve = %lu\n",lh->num_retrieve);
211 BIO_puts(out,buf);
212 sprintf(buf,"num_retrieve_miss = %lu\n",lh->num_retrieve_miss);
213 BIO_puts(out,buf);
214 sprintf(buf,"num_hash_comps = %lu\n",lh->num_hash_comps);
215 BIO_puts(out,buf);
216#if 0 200#if 0
217 sprintf(buf,"p = %u\n",lh->p); 201 BIO_printf(out,"p = %u\n",lh->p);
218 BIO_puts(out,buf); 202 BIO_printf(out,"pmax = %u\n",lh->pmax);
219 sprintf(buf,"pmax = %u\n",lh->pmax); 203 BIO_printf(out,"up_load = %lu\n",lh->up_load);
220 BIO_puts(out,buf); 204 BIO_printf(out,"down_load = %lu\n",lh->down_load);
221 sprintf(buf,"up_load = %lu\n",lh->up_load);
222 BIO_puts(out,buf);
223 sprintf(buf,"down_load = %lu\n",lh->down_load);
224 BIO_puts(out,buf);
225#endif 205#endif
226 } 206 }
227 207
@@ -229,14 +209,12 @@ void lh_node_stats_bio(const LHASH *lh, BIO *out)
229 { 209 {
230 LHASH_NODE *n; 210 LHASH_NODE *n;
231 unsigned int i,num; 211 unsigned int i,num;
232 char buf[128];
233 212
234 for (i=0; i<lh->num_nodes; i++) 213 for (i=0; i<lh->num_nodes; i++)
235 { 214 {
236 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)
237 num++; 216 num++;
238 sprintf(buf,"node %6u -> %3u\n",i,num); 217 BIO_printf(out,"node %6u -> %3u\n",i,num);
239 BIO_puts(out,buf);
240 } 218 }
241 } 219 }
242 220
@@ -246,7 +224,6 @@ void lh_node_usage_stats_bio(const LHASH *lh, BIO *out)
246 unsigned long num; 224 unsigned long num;
247 unsigned int i; 225 unsigned int i;
248 unsigned long total=0,n_used=0; 226 unsigned long total=0,n_used=0;
249 char buf[128];
250 227
251 for (i=0; i<lh->num_nodes; i++) 228 for (i=0; i<lh->num_nodes; i++)
252 { 229 {
@@ -258,17 +235,14 @@ void lh_node_usage_stats_bio(const LHASH *lh, BIO *out)
258 total+=num; 235 total+=num;
259 } 236 }
260 } 237 }
261 sprintf(buf,"%lu nodes used out of %u\n",n_used,lh->num_nodes); 238 BIO_printf(out,"%lu nodes used out of %u\n",n_used,lh->num_nodes);
262 BIO_puts(out,buf); 239 BIO_printf(out,"%lu items\n",total);
263 sprintf(buf,"%lu items\n",total);
264 BIO_puts(out,buf);
265 if (n_used == 0) return; 240 if (n_used == 0) return;
266 sprintf(buf,"load %d.%02d actual load %d.%02d\n", 241 BIO_printf(out,"load %d.%02d actual load %d.%02d\n",
267 (int)(total/lh->num_nodes), 242 (int)(total/lh->num_nodes),
268 (int)((total%lh->num_nodes)*100/lh->num_nodes), 243 (int)((total%lh->num_nodes)*100/lh->num_nodes),
269 (int)(total/n_used), 244 (int)(total/n_used),
270 (int)((total%n_used)*100/n_used)); 245 (int)((total%n_used)*100/n_used));
271 BIO_puts(out,buf);
272 } 246 }
273 247
274#endif 248#endif
diff --git a/src/lib/libssl/src/crypto/md2/md2_dgst.c b/src/lib/libssl/src/crypto/md2/md2_dgst.c
index e25dd00e02..ecb64f0ec4 100644
--- a/src/lib/libssl/src/crypto/md2/md2_dgst.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/md2/md2_one.c b/src/lib/libssl/src/crypto/md2/md2_one.c
index b12c37ce4d..835160ef56 100644
--- a/src/lib/libssl/src/crypto/md2/md2_one.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/md2/md2test.c b/src/lib/libssl/src/crypto/md2/md2test.c
index 7d3664faf5..901d0a7d8e 100644
--- a/src/lib/libssl/src/crypto/md2/md2test.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/md32_common.h b/src/lib/libssl/src/crypto/md32_common.h
index 353d2b96ad..573850b122 100644
--- a/src/lib/libssl/src/crypto/md32_common.h
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/md4/md4.c b/src/lib/libssl/src/crypto/md4/md4.c
index e4b0aac011..141415ad4d 100644
--- a/src/lib/libssl/src/crypto/md4/md4.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/md4/md4_dgst.c b/src/lib/libssl/src/crypto/md4/md4_dgst.c
index 6446f5f5e7..7afb7185b6 100644
--- a/src/lib/libssl/src/crypto/md4/md4_dgst.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/md4/md4_one.c b/src/lib/libssl/src/crypto/md4/md4_one.c
index 87a995d38d..00565507e4 100644
--- a/src/lib/libssl/src/crypto/md4/md4_one.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/md4/md4test.c b/src/lib/libssl/src/crypto/md4/md4test.c
index e0fdc42282..21a77d96f7 100644
--- a/src/lib/libssl/src/crypto/md4/md4test.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/md5/md5.c b/src/lib/libssl/src/crypto/md5/md5.c
index 7ed0024ae1..563733abc5 100644
--- a/src/lib/libssl/src/crypto/md5/md5.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/md5/md5.h b/src/lib/libssl/src/crypto/md5/md5.h
index 52cb753e6a..a252e02115 100644
--- a/src/lib/libssl/src/crypto/md5/md5.h
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/md5/md5_dgst.c b/src/lib/libssl/src/crypto/md5/md5_dgst.c
index c38a3f021e..9c7abc3697 100644
--- a/src/lib/libssl/src/crypto/md5/md5_dgst.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/md5/md5_locl.h b/src/lib/libssl/src/crypto/md5/md5_locl.h
index 34c5257306..9e360da732 100644
--- a/src/lib/libssl/src/crypto/md5/md5_locl.h
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/md5/md5_one.c b/src/lib/libssl/src/crypto/md5/md5_one.c
index b89dec850d..c5dd2d81db 100644
--- a/src/lib/libssl/src/crypto/md5/md5_one.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/md5/md5test.c b/src/lib/libssl/src/crypto/md5/md5test.c
index 862b89658a..bfd62629ed 100644
--- a/src/lib/libssl/src/crypto/md5/md5test.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/mdc2/mdc2test.c b/src/lib/libssl/src/crypto/mdc2/mdc2test.c
new file mode 100644
index 0000000000..c9abe99d92
--- /dev/null
+++ b/src/lib/libssl/src/crypto/mdc2/mdc2test.c
@@ -0,0 +1,146 @@
1/* crypto/mdc2/mdc2test.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#include <stdio.h>
60#include <stdlib.h>
61#include <string.h>
62
63#include "../e_os.h"
64
65#if defined(OPENSSL_NO_DES) && !defined(OPENSSL_NO_MDC2)
66#define OPENSSL_NO_MDC2
67#endif
68
69#ifdef OPENSSL_NO_MDC2
70int main(int argc, char *argv[])
71{
72 printf("No MDC2 support\n");
73 return(0);
74}
75#else
76#include <openssl/evp.h>
77#include <openssl/mdc2.h>
78
79#ifdef CHARSET_EBCDIC
80#include <openssl/ebcdic.h>
81#endif
82
83static unsigned char pad1[16]={
84 0x42,0xE5,0x0C,0xD2,0x24,0xBA,0xCE,0xBA,
85 0x76,0x0B,0xDD,0x2B,0xD4,0x09,0x28,0x1A
86 };
87
88static unsigned char pad2[16]={
89 0x2E,0x46,0x79,0xB5,0xAD,0xD9,0xCA,0x75,
90 0x35,0xD8,0x7A,0xFE,0xAB,0x33,0xBE,0xE2
91 };
92
93int main(int argc, char *argv[])
94 {
95 int ret=0;
96 unsigned char md[MDC2_DIGEST_LENGTH];
97 int i;
98 EVP_MD_CTX c;
99 static char *text="Now is the time for all ";
100
101#ifdef CHARSET_EBCDIC
102 ebcdic2ascii(text,text,strlen(text));
103#endif
104
105 EVP_MD_CTX_init(&c);
106 EVP_DigestInit_ex(&c,EVP_mdc2(), NULL);
107 EVP_DigestUpdate(&c,(unsigned char *)text,strlen(text));
108 EVP_DigestFinal_ex(&c,&(md[0]),NULL);
109
110 if (memcmp(md,pad1,MDC2_DIGEST_LENGTH) != 0)
111 {
112 for (i=0; i<MDC2_DIGEST_LENGTH; i++)
113 printf("%02X",md[i]);
114 printf(" <- generated\n");
115 for (i=0; i<MDC2_DIGEST_LENGTH; i++)
116 printf("%02X",pad1[i]);
117 printf(" <- correct\n");
118 ret=1;
119 }
120 else
121 printf("pad1 - ok\n");
122
123 EVP_DigestInit_ex(&c,EVP_mdc2(), NULL);
124 /* FIXME: use a ctl function? */
125 ((MDC2_CTX *)c.md_data)->pad_type=2;
126 EVP_DigestUpdate(&c,(unsigned char *)text,strlen(text));
127 EVP_DigestFinal_ex(&c,&(md[0]),NULL);
128
129 if (memcmp(md,pad2,MDC2_DIGEST_LENGTH) != 0)
130 {
131 for (i=0; i<MDC2_DIGEST_LENGTH; i++)
132 printf("%02X",md[i]);
133 printf(" <- generated\n");
134 for (i=0; i<MDC2_DIGEST_LENGTH; i++)
135 printf("%02X",pad2[i]);
136 printf(" <- correct\n");
137 ret=1;
138 }
139 else
140 printf("pad2 - ok\n");
141
142 EVP_MD_CTX_cleanup(&c);
143 EXIT(ret);
144 return(ret);
145 }
146#endif
diff --git a/src/lib/libssl/src/crypto/mem.c b/src/lib/libssl/src/crypto/mem.c
index a7826908e6..29df7d35b2 100644
--- a/src/lib/libssl/src/crypto/mem.c
+++ b/src/lib/libssl/src/crypto/mem.c
@@ -250,6 +250,9 @@ 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;
254
255 if (num < 0) return NULL;
253 256
254 allow_customize = 0; 257 allow_customize = 0;
255 if (malloc_debug_func != NULL) 258 if (malloc_debug_func != NULL)
@@ -264,6 +267,12 @@ void *CRYPTO_malloc_locked(int num, const char *file, int line)
264 if (malloc_debug_func != NULL) 267 if (malloc_debug_func != NULL)
265 malloc_debug_func(ret, num, file, line, 1); 268 malloc_debug_func(ret, num, file, line, 1);
266 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
267 return ret; 276 return ret;
268 } 277 }
269 278
@@ -282,6 +291,9 @@ void CRYPTO_free_locked(void *str)
282void *CRYPTO_malloc(int num, const char *file, int line) 291void *CRYPTO_malloc(int num, const char *file, int line)
283 { 292 {
284 void *ret = NULL; 293 void *ret = NULL;
294 extern unsigned char cleanse_ctr;
295
296 if (num < 0) return NULL;
285 297
286 allow_customize = 0; 298 allow_customize = 0;
287 if (malloc_debug_func != NULL) 299 if (malloc_debug_func != NULL)
@@ -296,6 +308,12 @@ void *CRYPTO_malloc(int num, const char *file, int line)
296 if (malloc_debug_func != NULL) 308 if (malloc_debug_func != NULL)
297 malloc_debug_func(ret, num, file, line, 1); 309 malloc_debug_func(ret, num, file, line, 1);
298 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
299 return ret; 317 return ret;
300 } 318 }
301 319
@@ -306,6 +324,8 @@ void *CRYPTO_realloc(void *str, int num, const char *file, int line)
306 if (str == NULL) 324 if (str == NULL)
307 return CRYPTO_malloc(num, file, line); 325 return CRYPTO_malloc(num, file, line);
308 326
327 if (num < 0) return NULL;
328
309 if (realloc_debug_func != NULL) 329 if (realloc_debug_func != NULL)
310 realloc_debug_func(str, NULL, num, file, line, 0); 330 realloc_debug_func(str, NULL, num, file, line, 0);
311 ret = realloc_ex_func(str,num,file,line); 331 ret = realloc_ex_func(str,num,file,line);
@@ -318,6 +338,32 @@ void *CRYPTO_realloc(void *str, int num, const char *file, int line)
318 return ret; 338 return ret;
319 } 339 }
320 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
321void CRYPTO_free(void *str) 367void CRYPTO_free(void *str)
322 { 368 {
323 if (free_debug_func != NULL) 369 if (free_debug_func != NULL)
@@ -337,7 +383,6 @@ void *CRYPTO_remalloc(void *a, int num, const char *file, int line)
337 return(a); 383 return(a);
338 } 384 }
339 385
340
341void CRYPTO_set_mem_debug_options(long bits) 386void CRYPTO_set_mem_debug_options(long bits)
342 { 387 {
343 if (set_debug_options_func != NULL) 388 if (set_debug_options_func != NULL)
diff --git a/src/lib/libssl/src/crypto/mem_clr.c b/src/lib/libssl/src/crypto/mem_clr.c
new file mode 100644
index 0000000000..e4b7f540b0
--- /dev/null
+++ b/src/lib/libssl/src/crypto/mem_clr.c
@@ -0,0 +1,75 @@
1/* crypto/mem_clr.c -*- mode:C; c-file-style: "eay" -*- */
2/* Written by Geoff Thorpe (geoff@geoffthorpe.net) for the OpenSSL
3 * project 2002.
4 */
5/* ====================================================================
6 * Copyright (c) 2001 The OpenSSL Project. All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 *
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 *
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in
17 * the documentation and/or other materials provided with the
18 * distribution.
19 *
20 * 3. All advertising materials mentioning features or use of this
21 * software must display the following acknowledgment:
22 * "This product includes software developed by the OpenSSL Project
23 * for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
24 *
25 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
26 * endorse or promote products derived from this software without
27 * prior written permission. For written permission, please contact
28 * openssl-core@openssl.org.
29 *
30 * 5. Products derived from this software may not be called "OpenSSL"
31 * nor may "OpenSSL" appear in their names without prior written
32 * permission of the OpenSSL Project.
33 *
34 * 6. Redistributions of any form whatsoever must retain the following
35 * acknowledgment:
36 * "This product includes software developed by the OpenSSL Project
37 * for use in the OpenSSL Toolkit (http://www.openssl.org/)"
38 *
39 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
40 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
41 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
42 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
43 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
44 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
45 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
46 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
47 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
48 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
49 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
50 * OF THE POSSIBILITY OF SUCH DAMAGE.
51 * ====================================================================
52 *
53 * This product includes cryptographic software written by Eric Young
54 * (eay@cryptsoft.com). This product includes software written by Tim
55 * Hudson (tjh@cryptsoft.com).
56 *
57 */
58
59#include <string.h>
60#include <openssl/crypto.h>
61
62unsigned char cleanse_ctr = 0;
63
64void OPENSSL_cleanse(void *ptr, size_t len)
65 {
66 unsigned char *p = ptr;
67 size_t loop = len;
68 while(loop--)
69 {
70 *(p++) = cleanse_ctr;
71 cleanse_ctr += (17 + (unsigned char)((int)p & 0xF));
72 }
73 if(memchr(ptr, cleanse_ctr, len))
74 cleanse_ctr += 63;
75 }
diff --git a/src/lib/libssl/src/crypto/mem_dbg.c b/src/lib/libssl/src/crypto/mem_dbg.c
index 1c4e04f51f..57bd08f65d 100644
--- a/src/lib/libssl/src/crypto/mem_dbg.c
+++ b/src/lib/libssl/src/crypto/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
@@ -666,7 +678,6 @@ static IMPLEMENT_LHASH_DOALL_ARG_FN(print_leak, const MEM *, MEM_LEAK *)
666void CRYPTO_mem_leaks(BIO *b) 678void CRYPTO_mem_leaks(BIO *b)
667 { 679 {
668 MEM_LEAK ml; 680 MEM_LEAK ml;
669 char buf[80];
670 681
671 if (mh == NULL && amih == NULL) 682 if (mh == NULL && amih == NULL)
672 return; 683 return;
@@ -681,9 +692,8 @@ void CRYPTO_mem_leaks(BIO *b)
681 (char *)&ml); 692 (char *)&ml);
682 if (ml.chunks != 0) 693 if (ml.chunks != 0)
683 { 694 {
684 sprintf(buf,"%ld bytes leaked in %d chunks\n", 695 BIO_printf(b,"%ld bytes leaked in %d chunks\n",
685 ml.bytes,ml.chunks); 696 ml.bytes,ml.chunks);
686 BIO_puts(b,buf);
687 } 697 }
688 else 698 else
689 { 699 {
diff --git a/src/lib/libssl/src/crypto/o_time.c b/src/lib/libssl/src/crypto/o_time.c
index 1bc0297b36..723eb1b5af 100644
--- a/src/lib/libssl/src/crypto/o_time.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/objects/obj_dat.c b/src/lib/libssl/src/crypto/objects/obj_dat.c
index ce779dc1b5..5d983e3ed4 100644
--- a/src/lib/libssl/src/crypto/objects/obj_dat.c
+++ b/src/lib/libssl/src/crypto/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 sprintf(tbuf,"%d.%lu",i,l); 465 sprintf(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 sprintf(tbuf,".%lu",l); 476 sprintf(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/libssl/src/crypto/objects/obj_dat.h b/src/lib/libssl/src/crypto/objects/obj_dat.h
index 30812c8aa6..969b18a341 100644
--- a/src/lib/libssl/src/crypto/objects/obj_dat.h
+++ b/src/lib/libssl/src/crypto/objects/obj_dat.h
@@ -62,12 +62,12 @@
62 * [including the GNU Public Licence.] 62 * [including the GNU Public Licence.]
63 */ 63 */
64 64
65#define NUM_NID 645 65#define NUM_NID 650
66#define NUM_SN 641 66#define NUM_SN 643
67#define NUM_LN 641 67#define NUM_LN 643
68#define NUM_OBJ 615 68#define NUM_OBJ 617
69 69
70static unsigned char lvalues[4435]={ 70static unsigned char lvalues[4455]={
710x00, /* [ 0] OBJ_undef */ 710x00, /* [ 0] OBJ_undef */
720x2A,0x86,0x48,0x86,0xF7,0x0D, /* [ 1] OBJ_rsadsi */ 720x2A,0x86,0x48,0x86,0xF7,0x0D, /* [ 1] OBJ_rsadsi */
730x2A,0x86,0x48,0x86,0xF7,0x0D,0x01, /* [ 7] OBJ_pkcs */ 730x2A,0x86,0x48,0x86,0xF7,0x0D,0x01, /* [ 7] OBJ_pkcs */
@@ -683,6 +683,8 @@ static unsigned char lvalues[4435]={
6830x67,0x2A,0x08,0xAE,0x7B, /* [4412] OBJ_set_brand_Novus */ 6830x67,0x2A,0x08,0xAE,0x7B, /* [4412] OBJ_set_brand_Novus */
6840x2A,0x86,0x48,0x86,0xF7,0x0D,0x03,0x0A, /* [4417] OBJ_des_cdmf */ 6840x2A,0x86,0x48,0x86,0xF7,0x0D,0x03,0x0A, /* [4417] OBJ_des_cdmf */
6850x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x01,0x06,/* [4425] OBJ_rsaOAEPEncryptionSET */ 6850x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x01,0x06,/* [4425] OBJ_rsaOAEPEncryptionSET */
6860x2B,0x06,0x01,0x04,0x01,0x82,0x37,0x14,0x02,0x02,/* [4434] OBJ_ms_smartcard_login */
6870x2B,0x06,0x01,0x04,0x01,0x82,0x37,0x14,0x02,0x03,/* [4444] OBJ_ms_upn */
686}; 688};
687 689
688static ASN1_OBJECT nid_objs[NUM_NID]={ 690static ASN1_OBJECT nid_objs[NUM_NID]={
@@ -824,7 +826,7 @@ static ASN1_OBJECT nid_objs[NUM_NID]={
824{"RSA-MDC2","mdc2WithRSA",NID_mdc2WithRSA,4,&(lvalues[531]),0}, 826{"RSA-MDC2","mdc2WithRSA",NID_mdc2WithRSA,4,&(lvalues[531]),0},
825{"RC4-40","rc4-40",NID_rc4_40,0,NULL}, 827{"RC4-40","rc4-40",NID_rc4_40,0,NULL},
826{"RC2-40-CBC","rc2-40-cbc",NID_rc2_40_cbc,0,NULL}, 828{"RC2-40-CBC","rc2-40-cbc",NID_rc2_40_cbc,0,NULL},
827{"gn","givenName",NID_givenName,3,&(lvalues[535]),0}, 829{"GN","givenName",NID_givenName,3,&(lvalues[535]),0},
828{"SN","surname",NID_surname,3,&(lvalues[538]),0}, 830{"SN","surname",NID_surname,3,&(lvalues[538]),0},
829{"initials","initials",NID_initials,3,&(lvalues[541]),0}, 831{"initials","initials",NID_initials,3,&(lvalues[541]),0},
830{NULL,NULL,NID_undef,0,NULL}, 832{NULL,NULL,NID_undef,0,NULL},
@@ -1719,6 +1721,13 @@ static ASN1_OBJECT nid_objs[NUM_NID]={
1719{"DES-CDMF","des-cdmf",NID_des_cdmf,8,&(lvalues[4417]),0}, 1721{"DES-CDMF","des-cdmf",NID_des_cdmf,8,&(lvalues[4417]),0},
1720{"rsaOAEPEncryptionSET","rsaOAEPEncryptionSET", 1722{"rsaOAEPEncryptionSET","rsaOAEPEncryptionSET",
1721 NID_rsaOAEPEncryptionSET,9,&(lvalues[4425]),0}, 1723 NID_rsaOAEPEncryptionSET,9,&(lvalues[4425]),0},
1724{NULL,NULL,NID_undef,0,NULL},
1725{NULL,NULL,NID_undef,0,NULL},
1726{NULL,NULL,NID_undef,0,NULL},
1727{"msSmartcardLogin","Microsoft Smartcardlogin",NID_ms_smartcard_login,
1728 10,&(lvalues[4434]),0},
1729{"msUPN","Microsoft Universal Principal Name",NID_ms_upn,10,
1730 &(lvalues[4444]),0},
1722}; 1731};
1723 1732
1724static ASN1_OBJECT *sn_objs[NUM_SN]={ 1733static ASN1_OBJECT *sn_objs[NUM_SN]={
@@ -1771,6 +1780,7 @@ static ASN1_OBJECT *sn_objs[NUM_SN]={
1771&(nid_objs[70]),/* "DSA-SHA1-old" */ 1780&(nid_objs[70]),/* "DSA-SHA1-old" */
1772&(nid_objs[67]),/* "DSA-old" */ 1781&(nid_objs[67]),/* "DSA-old" */
1773&(nid_objs[297]),/* "DVCS" */ 1782&(nid_objs[297]),/* "DVCS" */
1783&(nid_objs[99]),/* "GN" */
1774&(nid_objs[381]),/* "IANA" */ 1784&(nid_objs[381]),/* "IANA" */
1775&(nid_objs[34]),/* "IDEA-CBC" */ 1785&(nid_objs[34]),/* "IDEA-CBC" */
1776&(nid_objs[35]),/* "IDEA-CFB" */ 1786&(nid_objs[35]),/* "IDEA-CFB" */
@@ -1917,7 +1927,6 @@ static ASN1_OBJECT *sn_objs[NUM_SN]={
1917&(nid_objs[490]),/* "friendlyCountryName" */ 1927&(nid_objs[490]),/* "friendlyCountryName" */
1918&(nid_objs[156]),/* "friendlyName" */ 1928&(nid_objs[156]),/* "friendlyName" */
1919&(nid_objs[509]),/* "generationQualifier" */ 1929&(nid_objs[509]),/* "generationQualifier" */
1920&(nid_objs[99]),/* "gn" */
1921&(nid_objs[163]),/* "hmacWithSHA1" */ 1930&(nid_objs[163]),/* "hmacWithSHA1" */
1922&(nid_objs[432]),/* "holdInstructionCallIssuer" */ 1931&(nid_objs[432]),/* "holdInstructionCallIssuer" */
1923&(nid_objs[430]),/* "holdInstructionCode" */ 1932&(nid_objs[430]),/* "holdInstructionCode" */
@@ -2127,6 +2136,8 @@ static ASN1_OBJECT *sn_objs[NUM_SN]={
2127&(nid_objs[138]),/* "msEFS" */ 2136&(nid_objs[138]),/* "msEFS" */
2128&(nid_objs[171]),/* "msExtReq" */ 2137&(nid_objs[171]),/* "msExtReq" */
2129&(nid_objs[137]),/* "msSGC" */ 2138&(nid_objs[137]),/* "msSGC" */
2139&(nid_objs[648]),/* "msSmartcardLogin" */
2140&(nid_objs[649]),/* "msUPN" */
2130&(nid_objs[481]),/* "nSRecord" */ 2141&(nid_objs[481]),/* "nSRecord" */
2131&(nid_objs[173]),/* "name" */ 2142&(nid_objs[173]),/* "name" */
2132&(nid_objs[369]),/* "noCheck" */ 2143&(nid_objs[369]),/* "noCheck" */
@@ -2401,7 +2412,9 @@ static ASN1_OBJECT *ln_objs[NUM_LN]={
2401&(nid_objs[171]),/* "Microsoft Extension Request" */ 2412&(nid_objs[171]),/* "Microsoft Extension Request" */
2402&(nid_objs[134]),/* "Microsoft Individual Code Signing" */ 2413&(nid_objs[134]),/* "Microsoft Individual Code Signing" */
2403&(nid_objs[137]),/* "Microsoft Server Gated Crypto" */ 2414&(nid_objs[137]),/* "Microsoft Server Gated Crypto" */
2415&(nid_objs[648]),/* "Microsoft Smartcardlogin" */
2404&(nid_objs[136]),/* "Microsoft Trust List Signing" */ 2416&(nid_objs[136]),/* "Microsoft Trust List Signing" */
2417&(nid_objs[649]),/* "Microsoft Universal Principal Name" */
2405&(nid_objs[72]),/* "Netscape Base Url" */ 2418&(nid_objs[72]),/* "Netscape Base Url" */
2406&(nid_objs[76]),/* "Netscape CA Policy Url" */ 2419&(nid_objs[76]),/* "Netscape CA Policy Url" */
2407&(nid_objs[74]),/* "Netscape CA Revocation Url" */ 2420&(nid_objs[74]),/* "Netscape CA Revocation Url" */
@@ -3557,6 +3570,8 @@ static ASN1_OBJECT *obj_objs[NUM_OBJ]={
3557&(nid_objs[136]),/* OBJ_ms_ctl_sign 1 3 6 1 4 1 311 10 3 1 */ 3570&(nid_objs[136]),/* OBJ_ms_ctl_sign 1 3 6 1 4 1 311 10 3 1 */
3558&(nid_objs[137]),/* OBJ_ms_sgc 1 3 6 1 4 1 311 10 3 3 */ 3571&(nid_objs[137]),/* OBJ_ms_sgc 1 3 6 1 4 1 311 10 3 3 */
3559&(nid_objs[138]),/* OBJ_ms_efs 1 3 6 1 4 1 311 10 3 4 */ 3572&(nid_objs[138]),/* OBJ_ms_efs 1 3 6 1 4 1 311 10 3 4 */
3573&(nid_objs[648]),/* OBJ_ms_smartcard_login 1 3 6 1 4 1 311 20 2 2 */
3574&(nid_objs[649]),/* OBJ_ms_upn 1 3 6 1 4 1 311 20 2 3 */
3560&(nid_objs[196]),/* OBJ_id_smime_mod_cms 1 2 840 113549 1 9 16 0 1 */ 3575&(nid_objs[196]),/* OBJ_id_smime_mod_cms 1 2 840 113549 1 9 16 0 1 */
3561&(nid_objs[197]),/* OBJ_id_smime_mod_ess 1 2 840 113549 1 9 16 0 2 */ 3576&(nid_objs[197]),/* OBJ_id_smime_mod_ess 1 2 840 113549 1 9 16 0 2 */
3562&(nid_objs[198]),/* OBJ_id_smime_mod_oid 1 2 840 113549 1 9 16 0 3 */ 3577&(nid_objs[198]),/* OBJ_id_smime_mod_oid 1 2 840 113549 1 9 16 0 3 */
diff --git a/src/lib/libssl/src/crypto/objects/obj_mac.h b/src/lib/libssl/src/crypto/objects/obj_mac.h
index 899db8325c..7645012298 100644
--- a/src/lib/libssl/src/crypto/objects/obj_mac.h
+++ b/src/lib/libssl/src/crypto/objects/obj_mac.h
@@ -850,6 +850,16 @@
850#define NID_ms_efs 138 850#define NID_ms_efs 138
851#define OBJ_ms_efs 1L,3L,6L,1L,4L,1L,311L,10L,3L,4L 851#define OBJ_ms_efs 1L,3L,6L,1L,4L,1L,311L,10L,3L,4L
852 852
853#define SN_ms_smartcard_login "msSmartcardLogin"
854#define LN_ms_smartcard_login "Microsoft Smartcardlogin"
855#define NID_ms_smartcard_login 648
856#define OBJ_ms_smartcard_login 1L,3L,6L,1L,4L,1L,311L,20L,2L,2L
857
858#define SN_ms_upn "msUPN"
859#define LN_ms_upn "Microsoft Universal Principal Name"
860#define NID_ms_upn 649
861#define OBJ_ms_upn 1L,3L,6L,1L,4L,1L,311L,20L,2L,3L
862
853#define SN_idea_cbc "IDEA-CBC" 863#define SN_idea_cbc "IDEA-CBC"
854#define LN_idea_cbc "idea-cbc" 864#define LN_idea_cbc "idea-cbc"
855#define NID_idea_cbc 34 865#define NID_idea_cbc 34
@@ -1632,7 +1642,7 @@
1632#define NID_name 173 1642#define NID_name 173
1633#define OBJ_name OBJ_X509,41L 1643#define OBJ_name OBJ_X509,41L
1634 1644
1635#define SN_givenName "gn" 1645#define SN_givenName "GN"
1636#define LN_givenName "givenName" 1646#define LN_givenName "givenName"
1637#define NID_givenName 99 1647#define NID_givenName 99
1638#define OBJ_givenName OBJ_X509,42L 1648#define OBJ_givenName OBJ_X509,42L
diff --git a/src/lib/libssl/src/crypto/objects/obj_mac.num b/src/lib/libssl/src/crypto/objects/obj_mac.num
index 1486199661..9838072b65 100644
--- a/src/lib/libssl/src/crypto/objects/obj_mac.num
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/objects/objects.txt b/src/lib/libssl/src/crypto/objects/objects.txt
index 71a4908485..3ba11f65cc 100644
--- a/src/lib/libssl/src/crypto/objects/objects.txt
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/ocsp/ocsp_asn.c b/src/lib/libssl/src/crypto/ocsp/ocsp_asn.c
index 8c148cda6a..6a3a360d54 100644
--- a/src/lib/libssl/src/crypto/ocsp/ocsp_asn.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/ocsp/ocsp_ht.c b/src/lib/libssl/src/crypto/ocsp/ocsp_ht.c
index b78cd37092..9213e58ae4 100644
--- a/src/lib/libssl/src/crypto/ocsp/ocsp_ht.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/opensslconf.h b/src/lib/libssl/src/crypto/opensslconf.h
index c9756e47a3..492041bc7c 100644
--- a/src/lib/libssl/src/crypto/opensslconf.h
+++ b/src/lib/libssl/src/crypto/opensslconf.h
@@ -69,7 +69,7 @@
69#endif 69#endif
70#endif 70#endif
71 71
72#if (defined(HEADER_DES_H) || defined(HEADER_DES_OLD_H)) && !defined(DES_LONG) 72#if (defined(HEADER_NEW_DES_H) || defined(HEADER_DES_H)) && !defined(DES_LONG)
73/* If this is set to 'unsigned int' on a DEC Alpha, this gives about a 73/* If this is set to 'unsigned int' on a DEC Alpha, this gives about a
74 * %20 speed up (longs are 8 bytes, int's are 4). */ 74 * %20 speed up (longs are 8 bytes, int's are 4). */
75#ifndef DES_LONG 75#ifndef DES_LONG
diff --git a/src/lib/libssl/src/crypto/opensslconf.h.in b/src/lib/libssl/src/crypto/opensslconf.h.in
index 9082a16c46..685e83b7a3 100644
--- a/src/lib/libssl/src/crypto/opensslconf.h.in
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/opensslv.h b/src/lib/libssl/src/crypto/opensslv.h
index 9689b49c5b..08cb1d5018 100644
--- a/src/lib/libssl/src/crypto/opensslv.h
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/ossl_typ.h b/src/lib/libssl/src/crypto/ossl_typ.h
index 6bd42aee4d..285fd0b1d9 100644
--- a/src/lib/libssl/src/crypto/ossl_typ.h
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/pem/pem.h b/src/lib/libssl/src/crypto/pem/pem.h
index 3785fca77d..d330cbf9a3 100644
--- a/src/lib/libssl/src/crypto/pem/pem.h
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/pem/pem_info.c b/src/lib/libssl/src/crypto/pem/pem_info.c
index 9a6dffb45c..9e4af29c95 100644
--- a/src/lib/libssl/src/crypto/pem/pem_info.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/pem/pem_lib.c b/src/lib/libssl/src/crypto/pem/pem_lib.c
index a8db6ffbf5..70b5446797 100644
--- a/src/lib/libssl/src/crypto/pem/pem_lib.c
+++ b/src/lib/libssl/src/crypto/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
@@ -249,7 +249,7 @@ int PEM_bytes_read_bio(unsigned char **pdata, long *plen, char **pnm, const char
249 ret = 1; 249 ret = 1;
250 250
251err: 251err:
252 if (!pnm) OPENSSL_free(nm); 252 if (!ret || !pnm) OPENSSL_free(nm);
253 OPENSSL_free(header); 253 OPENSSL_free(header);
254 if (!ret) OPENSSL_free(data); 254 if (!ret) OPENSSL_free(data);
255 return ret; 255 return ret;
@@ -304,6 +304,7 @@ int PEM_ASN1_write_bio(int (*i2d)(), const char *name, BIO *bp, char *x,
304 goto err; 304 goto err;
305 } 305 }
306 /* dzise + 8 bytes are needed */ 306 /* dzise + 8 bytes are needed */
307 /* actually it needs the cipher block size extra... */
307 data=(unsigned char *)OPENSSL_malloc((unsigned int)dsize+20); 308 data=(unsigned char *)OPENSSL_malloc((unsigned int)dsize+20);
308 if (data == NULL) 309 if (data == NULL)
309 { 310 {
@@ -333,13 +334,16 @@ int PEM_ASN1_write_bio(int (*i2d)(), const char *name, BIO *bp, char *x,
333 kstr=(unsigned char *)buf; 334 kstr=(unsigned char *)buf;
334 } 335 }
335 RAND_add(data,i,0);/* put in the RSA key. */ 336 RAND_add(data,i,0);/* put in the RSA key. */
337 OPENSSL_assert(enc->iv_len <= sizeof iv);
336 if (RAND_pseudo_bytes(iv,enc->iv_len) < 0) /* Generate a salt */ 338 if (RAND_pseudo_bytes(iv,enc->iv_len) < 0) /* Generate a salt */
337 goto err; 339 goto err;
338 /* The 'iv' is used as the iv and as a salt. It is 340 /* The 'iv' is used as the iv and as a salt. It is
339 * NOT taken from the BytesToKey function */ 341 * NOT taken from the BytesToKey function */
340 EVP_BytesToKey(enc,EVP_md5(),iv,kstr,klen,1,key,NULL); 342 EVP_BytesToKey(enc,EVP_md5(),iv,kstr,klen,1,key,NULL);
341 343
342 if (kstr == (unsigned char *)buf) memset(buf,0,PEM_BUFSIZE); 344 if (kstr == (unsigned char *)buf) OPENSSL_cleanse(buf,PEM_BUFSIZE);
345
346 OPENSSL_assert(strlen(objstr)+23+2*enc->iv_len+13 <= sizeof buf);
343 347
344 buf[0]='\0'; 348 buf[0]='\0';
345 PEM_proc_type(buf,PEM_TYPE_ENCRYPTED); 349 PEM_proc_type(buf,PEM_TYPE_ENCRYPTED);
@@ -362,13 +366,13 @@ int PEM_ASN1_write_bio(int (*i2d)(), const char *name, BIO *bp, char *x,
362 i=PEM_write_bio(bp,name,buf,data,i); 366 i=PEM_write_bio(bp,name,buf,data,i);
363 if (i <= 0) ret=0; 367 if (i <= 0) ret=0;
364err: 368err:
365 memset(key,0,sizeof(key)); 369 OPENSSL_cleanse(key,sizeof(key));
366 memset(iv,0,sizeof(iv)); 370 OPENSSL_cleanse(iv,sizeof(iv));
367 memset((char *)&ctx,0,sizeof(ctx)); 371 OPENSSL_cleanse((char *)&ctx,sizeof(ctx));
368 memset(buf,0,PEM_BUFSIZE); 372 OPENSSL_cleanse(buf,PEM_BUFSIZE);
369 if (data != NULL) 373 if (data != NULL)
370 { 374 {
371 memset(data,0,(unsigned int)dsize); 375 OPENSSL_cleanse(data,(unsigned int)dsize);
372 OPENSSL_free(data); 376 OPENSSL_free(data);
373 } 377 }
374 return(ret); 378 return(ret);
@@ -409,8 +413,8 @@ int PEM_do_header(EVP_CIPHER_INFO *cipher, unsigned char *data, long *plen,
409 EVP_DecryptUpdate(&ctx,data,&i,data,j); 413 EVP_DecryptUpdate(&ctx,data,&i,data,j);
410 o=EVP_DecryptFinal_ex(&ctx,&(data[i]),&j); 414 o=EVP_DecryptFinal_ex(&ctx,&(data[i]),&j);
411 EVP_CIPHER_CTX_cleanup(&ctx); 415 EVP_CIPHER_CTX_cleanup(&ctx);
412 memset((char *)buf,0,sizeof(buf)); 416 OPENSSL_cleanse((char *)buf,sizeof(buf));
413 memset((char *)key,0,sizeof(key)); 417 OPENSSL_cleanse((char *)key,sizeof(key));
414 j+=i; 418 j+=i;
415 if (!o) 419 if (!o)
416 { 420 {
@@ -691,7 +695,7 @@ int PEM_read_bio(BIO *bp, char **name, char **header, unsigned char **data,
691 if (strncmp(buf,"-----END ",9) == 0) 695 if (strncmp(buf,"-----END ",9) == 0)
692 break; 696 break;
693 if (i > 65) break; 697 if (i > 65) break;
694 if (!BUF_MEM_grow(dataB,i+bl+9)) 698 if (!BUF_MEM_grow_clean(dataB,i+bl+9))
695 { 699 {
696 PEMerr(PEM_F_PEM_READ_BIO,ERR_R_MALLOC_FAILURE); 700 PEMerr(PEM_F_PEM_READ_BIO,ERR_R_MALLOC_FAILURE);
697 goto err; 701 goto err;
diff --git a/src/lib/libssl/src/crypto/pem/pem_pk8.c b/src/lib/libssl/src/crypto/pem/pem_pk8.c
index f44182ffb5..db38a2a79d 100644
--- a/src/lib/libssl/src/crypto/pem/pem_pk8.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/pem/pem_seal.c b/src/lib/libssl/src/crypto/pem/pem_seal.c
index ae463a301d..56e08abd70 100644
--- a/src/lib/libssl/src/crypto/pem/pem_seal.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/perlasm/cbc.pl b/src/lib/libssl/src/crypto/perlasm/cbc.pl
index 0145c4f0cc..22149c680e 100644
--- a/src/lib/libssl/src/crypto/perlasm/cbc.pl
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/perlasm/x86asm.pl b/src/lib/libssl/src/crypto/perlasm/x86asm.pl
index 9a3d85b098..1cb96e914a 100644
--- a/src/lib/libssl/src/crypto/perlasm/x86asm.pl
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/perlasm/x86ms.pl b/src/lib/libssl/src/crypto/perlasm/x86ms.pl
index 206452341d..35f1a4ddb9 100644
--- a/src/lib/libssl/src/crypto/perlasm/x86ms.pl
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/perlasm/x86nasm.pl b/src/lib/libssl/src/crypto/perlasm/x86nasm.pl
index 519d8a5867..f30b7466d4 100644
--- a/src/lib/libssl/src/crypto/perlasm/x86nasm.pl
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/perlasm/x86unix.pl b/src/lib/libssl/src/crypto/perlasm/x86unix.pl
index 9ceabf0705..72bde061c5 100644
--- a/src/lib/libssl/src/crypto/perlasm/x86unix.pl
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/pkcs12/p12_crpt.c b/src/lib/libssl/src/crypto/pkcs12/p12_crpt.c
index 97be6a5fb5..5e8958612b 100644
--- a/src/lib/libssl/src/crypto/pkcs12/p12_crpt.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/pkcs12/p12_decr.c b/src/lib/libssl/src/crypto/pkcs12/p12_decr.c
index 394af368f4..b5684a83ba 100644
--- a/src/lib/libssl/src/crypto/pkcs12/p12_decr.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/pkcs12/p12_key.c b/src/lib/libssl/src/crypto/pkcs12/p12_key.c
index 0d39ebde8c..9196a34b4a 100644
--- a/src/lib/libssl/src/crypto/pkcs12/p12_key.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/pkcs12/p12_npas.c b/src/lib/libssl/src/crypto/pkcs12/p12_npas.c
index a549433eeb..af708a2743 100644
--- a/src/lib/libssl/src/crypto/pkcs12/p12_npas.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/pkcs7/bio_ber.c b/src/lib/libssl/src/crypto/pkcs7/bio_ber.c
index 42331f7ab0..895a91177b 100644
--- a/src/lib/libssl/src/crypto/pkcs7/bio_ber.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/pkcs7/pk7_doit.c b/src/lib/libssl/src/crypto/pkcs7/pk7_doit.c
index 4a4ff340ce..0060a2ea3d 100644
--- a/src/lib/libssl/src/crypto/pkcs7/pk7_doit.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/rand/md_rand.c b/src/lib/libssl/src/crypto/rand/md_rand.c
index a00ed70718..eeffc0df4c 100644
--- a/src/lib/libssl/src/crypto/rand/md_rand.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/rand/rand.h b/src/lib/libssl/src/crypto/rand/rand.h
index 66e39991ec..606382dd21 100644
--- a/src/lib/libssl/src/crypto/rand/rand.h
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/rand/rand_egd.c b/src/lib/libssl/src/crypto/rand/rand_egd.c
index abc3ac27d5..1f168221e3 100644
--- a/src/lib/libssl/src/crypto/rand/rand_egd.c
+++ b/src/lib/libssl/src/crypto/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 strcpy(addr.sun_path,path); 148 strcpy(addr.sun_path,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/libssl/src/crypto/rand/rand_lib.c b/src/lib/libssl/src/crypto/rand/rand_lib.c
index 5cf5dc1188..513e338985 100644
--- a/src/lib/libssl/src/crypto/rand/rand_lib.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/rand/rand_unix.c b/src/lib/libssl/src/crypto/rand/rand_unix.c
index ec09d74603..a776e52243 100644
--- a/src/lib/libssl/src/crypto/rand/rand_unix.c
+++ b/src/lib/libssl/src/crypto/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>
@@ -215,7 +215,7 @@ int RAND_poll(void)
215 if (n > 0) 215 if (n > 0)
216 { 216 {
217 RAND_add(tmpbuf,sizeof tmpbuf,n); 217 RAND_add(tmpbuf,sizeof tmpbuf,n);
218 memset(tmpbuf,0,n); 218 OPENSSL_cleanse(tmpbuf,n);
219 } 219 }
220#endif 220#endif
221 221
@@ -236,3 +236,10 @@ int RAND_poll(void)
236} 236}
237 237
238#endif 238#endif
239
240#if defined(OPENSSL_SYS_VXWORKS)
241int RAND_poll(void)
242{
243 return 0;
244}
245#endif
diff --git a/src/lib/libssl/src/crypto/rand/rand_win.c b/src/lib/libssl/src/crypto/rand/rand_win.c
index c1b955b06f..113b58678f 100644
--- a/src/lib/libssl/src/crypto/rand/rand_win.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/rand/randfile.c b/src/lib/libssl/src/crypto/rand/randfile.c
index 982074c465..41574768ab 100644
--- a/src/lib/libssl/src/crypto/rand/randfile.c
+++ b/src/lib/libssl/src/crypto/rand/randfile.c
@@ -124,7 +124,7 @@ int RAND_load_file(const char *file, long bytes)
124 } 124 }
125 } 125 }
126 fclose(in); 126 fclose(in);
127 memset(buf,0,BUFSIZE); 127 OPENSSL_cleanse(buf,BUFSIZE);
128err: 128err:
129 return(ret); 129 return(ret);
130 } 130 }
@@ -189,7 +189,7 @@ int RAND_write_file(const char *file)
189#endif /* OPENSSL_SYS_VMS */ 189#endif /* OPENSSL_SYS_VMS */
190 190
191 fclose(out); 191 fclose(out);
192 memset(buf,0,BUFSIZE); 192 OPENSSL_cleanse(buf,BUFSIZE);
193err: 193err:
194 return (rand_err ? -1 : ret); 194 return (rand_err ? -1 : ret);
195 } 195 }
@@ -203,8 +203,9 @@ const char *RAND_file_name(char *buf, size_t size)
203 s=getenv("RANDFILE"); 203 s=getenv("RANDFILE");
204 if (s != NULL) 204 if (s != NULL)
205 { 205 {
206 strncpy(buf,s,size-1); 206 if(strlen(s) >= size)
207 buf[size-1]='\0'; 207 return NULL;
208 strcpy(buf,s);
208 ret=buf; 209 ret=buf;
209 } 210 }
210 else 211 else
diff --git a/src/lib/libssl/src/crypto/rand/randtest.c b/src/lib/libssl/src/crypto/rand/randtest.c
index b64de616db..701932e6ee 100644
--- a/src/lib/libssl/src/crypto/rand/randtest.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/rc2/rc2test.c b/src/lib/libssl/src/crypto/rc2/rc2test.c
index d9a2a0a1cb..b67bafb49f 100644
--- a/src/lib/libssl/src/crypto/rc2/rc2test.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/rc4/rc4.c b/src/lib/libssl/src/crypto/rc4/rc4.c
index c2165b0b75..b39c070292 100644
--- a/src/lib/libssl/src/crypto/rc4/rc4.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/rc4/rc4test.c b/src/lib/libssl/src/crypto/rc4/rc4test.c
index a28d457c8d..b9d8f20975 100644
--- a/src/lib/libssl/src/crypto/rc4/rc4test.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/rc5/rc5s.cpp b/src/lib/libssl/src/crypto/rc5/rc5s.cpp
new file mode 100644
index 0000000000..1c5518bc80
--- /dev/null
+++ b/src/lib/libssl/src/crypto/rc5/rc5s.cpp
@@ -0,0 +1,70 @@
1//
2// gettsc.inl
3//
4// gives access to the Pentium's (secret) cycle counter
5//
6// This software was written by Leonard Janke (janke@unixg.ubc.ca)
7// in 1996-7 and is entered, by him, into the public domain.
8
9#if defined(__WATCOMC__)
10void GetTSC(unsigned long&);
11#pragma aux GetTSC = 0x0f 0x31 "mov [edi], eax" parm [edi] modify [edx eax];
12#elif defined(__GNUC__)
13inline
14void GetTSC(unsigned long& tsc)
15{
16 asm volatile(".byte 15, 49\n\t"
17 : "=eax" (tsc)
18 :
19 : "%edx", "%eax");
20}
21#elif defined(_MSC_VER)
22inline
23void GetTSC(unsigned long& tsc)
24{
25 unsigned long a;
26 __asm _emit 0fh
27 __asm _emit 31h
28 __asm mov a, eax;
29 tsc=a;
30}
31#endif
32
33#include <stdio.h>
34#include <stdlib.h>
35#include <openssl/rc5.h>
36
37void main(int argc,char *argv[])
38 {
39 RC5_32_KEY key;
40 unsigned long s1,s2,e1,e2;
41 unsigned long data[2];
42 int i,j;
43 static unsigned char d[16]={0x01,0x23,0x45,0x67,0x89,0xAB,0xCD,0xEF};
44
45 RC5_32_set_key(&key, 16,d,12);
46
47 for (j=0; j<6; j++)
48 {
49 for (i=0; i<1000; i++) /**/
50 {
51 RC5_32_encrypt(&data[0],&key);
52 GetTSC(s1);
53 RC5_32_encrypt(&data[0],&key);
54 RC5_32_encrypt(&data[0],&key);
55 RC5_32_encrypt(&data[0],&key);
56 GetTSC(e1);
57 GetTSC(s2);
58 RC5_32_encrypt(&data[0],&key);
59 RC5_32_encrypt(&data[0],&key);
60 RC5_32_encrypt(&data[0],&key);
61 RC5_32_encrypt(&data[0],&key);
62 GetTSC(e2);
63 RC5_32_encrypt(&data[0],&key);
64 }
65
66 printf("cast %d %d (%d)\n",
67 e1-s1,e2-s2,((e2-s2)-(e1-s1)));
68 }
69 }
70
diff --git a/src/lib/libssl/src/crypto/ripemd/rmd160.c b/src/lib/libssl/src/crypto/ripemd/rmd160.c
index 4f8b88a18a..b0ec574498 100644
--- a/src/lib/libssl/src/crypto/ripemd/rmd160.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/ripemd/rmd_dgst.c b/src/lib/libssl/src/crypto/ripemd/rmd_dgst.c
index a3170f7c8a..f351f00eea 100644
--- a/src/lib/libssl/src/crypto/ripemd/rmd_dgst.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/ripemd/rmd_one.c b/src/lib/libssl/src/crypto/ripemd/rmd_one.c
index efdf2dd6ef..f8b580c33a 100644
--- a/src/lib/libssl/src/crypto/ripemd/rmd_one.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/ripemd/rmdtest.c b/src/lib/libssl/src/crypto/ripemd/rmdtest.c
index be1fb8b1f6..d4c709e646 100644
--- a/src/lib/libssl/src/crypto/ripemd/rmdtest.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/rsa/rsa.h b/src/lib/libssl/src/crypto/rsa/rsa.h
index 98b3bd7cc5..e26a68b482 100644
--- a/src/lib/libssl/src/crypto/rsa/rsa.h
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/rsa/rsa_eay.c b/src/lib/libssl/src/crypto/rsa/rsa_eay.c
index 0eda816081..027b4dc754 100644
--- a/src/lib/libssl/src/crypto/rsa/rsa_eay.c
+++ b/src/lib/libssl/src/crypto/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,12 +186,65 @@ 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);
194 } 193 }
195 194
195static int rsa_eay_blinding(RSA *rsa, BN_CTX *ctx)
196 {
197 int ret = 1;
198 CRYPTO_w_lock(CRYPTO_LOCK_RSA);
199 /* Check again inside the lock - the macro's check is racey */
200 if(rsa->blinding == NULL)
201 ret = RSA_blinding_on(rsa, ctx);
202 CRYPTO_w_unlock(CRYPTO_LOCK_RSA);
203 return ret;
204 }
205
206#define BLINDING_HELPER(rsa, ctx, err_instr) \
207 do { \
208 if((!((rsa)->flags & RSA_FLAG_NO_BLINDING)) && \
209 ((rsa)->blinding == NULL) && \
210 !rsa_eay_blinding(rsa, ctx)) \
211 err_instr \
212 } while(0)
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
196/* signing */ 248/* signing */
197static int RSA_eay_private_encrypt(int flen, const unsigned char *from, 249static int RSA_eay_private_encrypt(int flen, const unsigned char *from,
198 unsigned char *to, RSA *rsa, int padding) 250 unsigned char *to, RSA *rsa, int padding)
@@ -201,6 +253,8 @@ static int RSA_eay_private_encrypt(int flen, const unsigned char *from,
201 int i,j,k,num=0,r= -1; 253 int i,j,k,num=0,r= -1;
202 unsigned char *buf=NULL; 254 unsigned char *buf=NULL;
203 BN_CTX *ctx=NULL; 255 BN_CTX *ctx=NULL;
256 int local_blinding = 0;
257 BN_BLINDING *blinding = NULL;
204 258
205 BN_init(&f); 259 BN_init(&f);
206 BN_init(&ret); 260 BN_init(&ret);
@@ -237,10 +291,39 @@ static int RSA_eay_private_encrypt(int flen, const unsigned char *from,
237 goto err; 291 goto err;
238 } 292 }
239 293
240 if ((rsa->flags & RSA_FLAG_BLINDING) && (rsa->blinding == NULL)) 294 BLINDING_HELPER(rsa, ctx, goto err;);
241 RSA_blinding_on(rsa,ctx); 295 blinding = rsa->blinding;
242 if (rsa->flags & RSA_FLAG_BLINDING) 296
243 if (!BN_BLINDING_convert(&f,rsa->blinding,ctx)) goto err; 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 }
324
325 if (blinding)
326 if (!BN_BLINDING_convert(&f, blinding, ctx)) goto err;
244 327
245 if ( (rsa->flags & RSA_FLAG_EXT_PKEY) || 328 if ( (rsa->flags & RSA_FLAG_EXT_PKEY) ||
246 ((rsa->p != NULL) && 329 ((rsa->p != NULL) &&
@@ -254,8 +337,8 @@ static int RSA_eay_private_encrypt(int flen, const unsigned char *from,
254 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;
255 } 338 }
256 339
257 if (rsa->flags & RSA_FLAG_BLINDING) 340 if (blinding)
258 if (!BN_BLINDING_invert(&ret,rsa->blinding,ctx)) goto err; 341 if (!BN_BLINDING_invert(&ret, blinding, ctx)) goto err;
259 342
260 /* 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
261 * length of the modulus */ 344 * length of the modulus */
@@ -269,9 +352,11 @@ err:
269 if (ctx != NULL) BN_CTX_free(ctx); 352 if (ctx != NULL) BN_CTX_free(ctx);
270 BN_clear_free(&ret); 353 BN_clear_free(&ret);
271 BN_clear_free(&f); 354 BN_clear_free(&f);
355 if (local_blinding)
356 BN_BLINDING_free(blinding);
272 if (buf != NULL) 357 if (buf != NULL)
273 { 358 {
274 memset(buf,0,num); 359 OPENSSL_cleanse(buf,num);
275 OPENSSL_free(buf); 360 OPENSSL_free(buf);
276 } 361 }
277 return(r); 362 return(r);
@@ -285,6 +370,8 @@ static int RSA_eay_private_decrypt(int flen, const unsigned char *from,
285 unsigned char *p; 370 unsigned char *p;
286 unsigned char *buf=NULL; 371 unsigned char *buf=NULL;
287 BN_CTX *ctx=NULL; 372 BN_CTX *ctx=NULL;
373 int local_blinding = 0;
374 BN_BLINDING *blinding = NULL;
288 375
289 BN_init(&f); 376 BN_init(&f);
290 BN_init(&ret); 377 BN_init(&ret);
@@ -316,10 +403,39 @@ static int RSA_eay_private_decrypt(int flen, const unsigned char *from,
316 goto err; 403 goto err;
317 } 404 }
318 405
319 if ((rsa->flags & RSA_FLAG_BLINDING) && (rsa->blinding == NULL)) 406 BLINDING_HELPER(rsa, ctx, goto err;);
320 RSA_blinding_on(rsa,ctx); 407 blinding = rsa->blinding;
321 if (rsa->flags & RSA_FLAG_BLINDING) 408
322 if (!BN_BLINDING_convert(&f,rsa->blinding,ctx)) goto err; 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 }
436
437 if (blinding)
438 if (!BN_BLINDING_convert(&f, blinding, ctx)) goto err;
323 439
324 /* do the decrypt */ 440 /* do the decrypt */
325 if ( (rsa->flags & RSA_FLAG_EXT_PKEY) || 441 if ( (rsa->flags & RSA_FLAG_EXT_PKEY) ||
@@ -335,8 +451,8 @@ static int RSA_eay_private_decrypt(int flen, const unsigned char *from,
335 goto err; 451 goto err;
336 } 452 }
337 453
338 if (rsa->flags & RSA_FLAG_BLINDING) 454 if (blinding)
339 if (!BN_BLINDING_invert(&ret,rsa->blinding,ctx)) goto err; 455 if (!BN_BLINDING_invert(&ret, blinding, ctx)) goto err;
340 456
341 p=buf; 457 p=buf;
342 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 */
@@ -370,7 +486,7 @@ err:
370 BN_clear_free(&ret); 486 BN_clear_free(&ret);
371 if (buf != NULL) 487 if (buf != NULL)
372 { 488 {
373 memset(buf,0,num); 489 OPENSSL_cleanse(buf,num);
374 OPENSSL_free(buf); 490 OPENSSL_free(buf);
375 } 491 }
376 return(r); 492 return(r);
@@ -467,7 +583,7 @@ err:
467 BN_clear_free(&ret); 583 BN_clear_free(&ret);
468 if (buf != NULL) 584 if (buf != NULL)
469 { 585 {
470 memset(buf,0,num); 586 OPENSSL_cleanse(buf,num);
471 OPENSSL_free(buf); 587 OPENSSL_free(buf);
472 } 588 }
473 return(r); 589 return(r);
diff --git a/src/lib/libssl/src/crypto/rsa/rsa_lib.c b/src/lib/libssl/src/crypto/rsa/rsa_lib.c
index 93235744f7..53c5092014 100644
--- a/src/lib/libssl/src/crypto/rsa/rsa_lib.c
+++ b/src/lib/libssl/src/crypto/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
@@ -70,7 +73,9 @@ static const RSA_METHOD *default_RSA_meth=NULL;
70 73
71RSA *RSA_new(void) 74RSA *RSA_new(void)
72 { 75 {
73 return(RSA_new_method(NULL)); 76 RSA *r=RSA_new_method(NULL);
77
78 return r;
74 } 79 }
75 80
76void RSA_set_default_method(const RSA_METHOD *meth) 81void RSA_set_default_method(const RSA_METHOD *meth)
@@ -108,11 +113,13 @@ int RSA_set_method(RSA *rsa, const RSA_METHOD *meth)
108 const RSA_METHOD *mtmp; 113 const RSA_METHOD *mtmp;
109 mtmp = rsa->meth; 114 mtmp = rsa->meth;
110 if (mtmp->finish) mtmp->finish(rsa); 115 if (mtmp->finish) mtmp->finish(rsa);
116#ifndef OPENSSL_NO_ENGINE
111 if (rsa->engine) 117 if (rsa->engine)
112 { 118 {
113 ENGINE_finish(rsa->engine); 119 ENGINE_finish(rsa->engine);
114 rsa->engine = NULL; 120 rsa->engine = NULL;
115 } 121 }
122#endif
116 rsa->meth = meth; 123 rsa->meth = meth;
117 if (meth->init) meth->init(rsa); 124 if (meth->init) meth->init(rsa);
118 return 1; 125 return 1;
@@ -130,6 +137,7 @@ RSA *RSA_new_method(ENGINE *engine)
130 } 137 }
131 138
132 ret->meth = RSA_get_default_method(); 139 ret->meth = RSA_get_default_method();
140#ifndef OPENSSL_NO_ENGINE
133 if (engine) 141 if (engine)
134 { 142 {
135 if (!ENGINE_init(engine)) 143 if (!ENGINE_init(engine))
@@ -154,6 +162,7 @@ RSA *RSA_new_method(ENGINE *engine)
154 return NULL; 162 return NULL;
155 } 163 }
156 } 164 }
165#endif
157 166
158 ret->pad=0; 167 ret->pad=0;
159 ret->version=0; 168 ret->version=0;
@@ -175,8 +184,10 @@ RSA *RSA_new_method(ENGINE *engine)
175 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);
176 if ((ret->meth->init != NULL) && !ret->meth->init(ret)) 185 if ((ret->meth->init != NULL) && !ret->meth->init(ret))
177 { 186 {
187#ifndef OPENSSL_NO_ENGINE
178 if (ret->engine) 188 if (ret->engine)
179 ENGINE_finish(ret->engine); 189 ENGINE_finish(ret->engine);
190#endif
180 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);
181 OPENSSL_free(ret); 192 OPENSSL_free(ret);
182 ret=NULL; 193 ret=NULL;
@@ -205,8 +216,10 @@ void RSA_free(RSA *r)
205 216
206 if (r->meth->finish) 217 if (r->meth->finish)
207 r->meth->finish(r); 218 r->meth->finish(r);
219#ifndef OPENSSL_NO_ENGINE
208 if (r->engine) 220 if (r->engine)
209 ENGINE_finish(r->engine); 221 ENGINE_finish(r->engine);
222#endif
210 223
211 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);
212 225
@@ -297,7 +310,8 @@ void RSA_blinding_off(RSA *rsa)
297 BN_BLINDING_free(rsa->blinding); 310 BN_BLINDING_free(rsa->blinding);
298 rsa->blinding=NULL; 311 rsa->blinding=NULL;
299 } 312 }
300 rsa->flags&= ~RSA_FLAG_BLINDING; 313 rsa->flags &= ~RSA_FLAG_BLINDING;
314 rsa->flags |= RSA_FLAG_NO_BLINDING;
301 } 315 }
302 316
303int RSA_blinding_on(RSA *rsa, BN_CTX *p_ctx) 317int RSA_blinding_on(RSA *rsa, BN_CTX *p_ctx)
@@ -316,15 +330,32 @@ int RSA_blinding_on(RSA *rsa, BN_CTX *p_ctx)
316 if (rsa->blinding != NULL) 330 if (rsa->blinding != NULL)
317 BN_BLINDING_free(rsa->blinding); 331 BN_BLINDING_free(rsa->blinding);
318 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
319 BN_CTX_start(ctx); 337 BN_CTX_start(ctx);
320 A = BN_CTX_get(ctx); 338 A = BN_CTX_get(ctx);
321 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 }
322 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;
323 350
324 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))
325 goto err; 352 goto err;
326 rsa->blinding=BN_BLINDING_new(A,Ai,rsa->n); 353 if ((rsa->blinding=BN_BLINDING_new(A,Ai,rsa->n)) == NULL) goto err;
327 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;
328 BN_free(Ai); 359 BN_free(Ai);
329 ret=1; 360 ret=1;
330err: 361err:
diff --git a/src/lib/libssl/src/crypto/rsa/rsa_pk1.c b/src/lib/libssl/src/crypto/rsa/rsa_pk1.c
index c1edd6764f..8560755f1d 100644
--- a/src/lib/libssl/src/crypto/rsa/rsa_pk1.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/rsa/rsa_saos.c b/src/lib/libssl/src/crypto/rsa/rsa_saos.c
index 85adacc08f..f462716a57 100644
--- a/src/lib/libssl/src/crypto/rsa/rsa_saos.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/rsa/rsa_sign.c b/src/lib/libssl/src/crypto/rsa/rsa_sign.c
index 2a440901de..8a1e642183 100644
--- a/src/lib/libssl/src/crypto/rsa/rsa_sign.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/rsa/rsa_test.c b/src/lib/libssl/src/crypto/rsa/rsa_test.c
index b8b462d33b..924e9ad1f6 100644
--- a/src/lib/libssl/src/crypto/rsa/rsa_test.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/sha/sha1_one.c b/src/lib/libssl/src/crypto/sha/sha1_one.c
index e6a24888ed..20e660c71d 100644
--- a/src/lib/libssl/src/crypto/sha/sha1_one.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/sha/sha1test.c b/src/lib/libssl/src/crypto/sha/sha1test.c
index 499a1cf5af..4f2e4ada2d 100644
--- a/src/lib/libssl/src/crypto/sha/sha1test.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/sha/sha_locl.h b/src/lib/libssl/src/crypto/sha/sha_locl.h
index 471dfb9f8f..2dd63a62a6 100644
--- a/src/lib/libssl/src/crypto/sha/sha_locl.h
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/sha/sha_one.c b/src/lib/libssl/src/crypto/sha/sha_one.c
index 5426faae4a..e61c63f3e9 100644
--- a/src/lib/libssl/src/crypto/sha/sha_one.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/sha/shatest.c b/src/lib/libssl/src/crypto/sha/shatest.c
index 331294a74f..5d2b1d3b1a 100644
--- a/src/lib/libssl/src/crypto/sha/shatest.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/threads/mttest.c b/src/lib/libssl/src/crypto/threads/mttest.c
index 7142e4edc7..54d598565d 100644
--- a/src/lib/libssl/src/crypto/threads/mttest.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/tmdiff.c b/src/lib/libssl/src/crypto/tmdiff.c
index 7ebf2b202a..307523ebba 100644
--- a/src/lib/libssl/src/crypto/tmdiff.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/txt_db/txt_db.c b/src/lib/libssl/src/crypto/txt_db/txt_db.c
index 9b186f2da5..58b300b00b 100644
--- a/src/lib/libssl/src/crypto/txt_db/txt_db.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/ui/ui_lib.c b/src/lib/libssl/src/crypto/ui/ui_lib.c
index 16946cad95..13e5f20dcb 100644
--- a/src/lib/libssl/src/crypto/ui/ui_lib.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/ui/ui_openssl.c b/src/lib/libssl/src/crypto/ui/ui_openssl.c
index 2c2fbc0443..75318d48a1 100644
--- a/src/lib/libssl/src/crypto/ui/ui_openssl.c
+++ b/src/lib/libssl/src/crypto/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 {
@@ -378,7 +387,8 @@ static void read_till_nl(FILE *in)
378 } while (strchr(buf,'\n') == NULL); 387 } while (strchr(buf,'\n') == NULL);
379 } 388 }
380 389
381static 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/libssl/src/crypto/ui/ui_util.c b/src/lib/libssl/src/crypto/ui/ui_util.c
index f05573df33..46bc8c1a9a 100644
--- a/src/lib/libssl/src/crypto/ui/ui_util.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/uid.c b/src/lib/libssl/src/crypto/uid.c
index d3d249c36f..73205a4baa 100644
--- a/src/lib/libssl/src/crypto/uid.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/x509/by_file.c b/src/lib/libssl/src/crypto/x509/by_file.c
index 92e00d2d73..b4b04183d0 100644
--- a/src/lib/libssl/src/crypto/x509/by_file.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/x509/x509.h b/src/lib/libssl/src/crypto/x509/x509.h
index 7095440d36..eaad5685a8 100644
--- a/src/lib/libssl/src/crypto/x509/x509.h
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/x509/x509_cmp.c b/src/lib/libssl/src/crypto/x509/x509_cmp.c
index cd20b6d66f..f460102f49 100644
--- a/src/lib/libssl/src/crypto/x509/x509_cmp.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/x509/x509_v3.c b/src/lib/libssl/src/crypto/x509/x509_v3.c
index b5f7daa2e5..67b1796a92 100644
--- a/src/lib/libssl/src/crypto/x509/x509_v3.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/x509/x509_vfy.c b/src/lib/libssl/src/crypto/x509/x509_vfy.c
index db12f7bd35..552d1e7251 100644
--- a/src/lib/libssl/src/crypto/x509/x509_vfy.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/x509v3/ext_dat.h b/src/lib/libssl/src/crypto/x509v3/ext_dat.h
index 2fb97d8925..5442480595 100644
--- a/src/lib/libssl/src/crypto/x509v3/ext_dat.h
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/x509v3/v3_info.c b/src/lib/libssl/src/crypto/x509v3/v3_info.c
index e1cf01a9b4..e269df1373 100644
--- a/src/lib/libssl/src/crypto/x509v3/v3_info.c
+++ b/src/lib/libssl/src/crypto/x509v3/v3_info.c
@@ -113,7 +113,7 @@ 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 ntmp = OPENSSL_malloc(strlen(objtmp) + strlen(vtmp->name) + 5); 117 ntmp = OPENSSL_malloc(strlen(objtmp) + strlen(vtmp->name) + 5);
118 if(!ntmp) { 118 if(!ntmp) {
119 X509V3err(X509V3_F_I2V_AUTHORITY_INFO_ACCESS, 119 X509V3err(X509V3_F_I2V_AUTHORITY_INFO_ACCESS,
diff --git a/src/lib/libssl/src/crypto/x509v3/v3_ocsp.c b/src/lib/libssl/src/crypto/x509v3/v3_ocsp.c
index 083112314e..21badc13f9 100644
--- a/src/lib/libssl/src/crypto/x509v3/v3_ocsp.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/x509v3/v3_prn.c b/src/lib/libssl/src/crypto/x509v3/v3_prn.c
index aeaf6170fe..754808b625 100644
--- a/src/lib/libssl/src/crypto/x509v3/v3_prn.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/x509v3/v3_purp.c b/src/lib/libssl/src/crypto/x509v3/v3_purp.c
index b739e4fd83..4d145f71fd 100644
--- a/src/lib/libssl/src/crypto/x509v3/v3_purp.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/x509v3/v3_utl.c b/src/lib/libssl/src/crypto/x509v3/v3_utl.c
index 283e943e46..34ac2998de 100644
--- a/src/lib/libssl/src/crypto/x509v3/v3_utl.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/x509v3/v3conf.c b/src/lib/libssl/src/crypto/x509v3/v3conf.c
index 67ee14f334..00cf5b4a5b 100644
--- a/src/lib/libssl/src/crypto/x509v3/v3conf.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/x509v3/x509v3.h b/src/lib/libssl/src/crypto/x509v3/x509v3.h
index daecc55271..fb07a19016 100644
--- a/src/lib/libssl/src/crypto/x509v3/x509v3.h
+++ b/src/lib/libssl/src/crypto/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
diff --git a/src/lib/libssl/src/demos/b64.c b/src/lib/libssl/src/demos/b64.c
index 113da89baf..efdd44457d 100644
--- a/src/lib/libssl/src/demos/b64.c
+++ b/src/lib/libssl/src/demos/b64.c
@@ -83,7 +83,6 @@ char **argv;
83 unsigned char *buff=NULL,*bufsize=NULL; 83 unsigned char *buff=NULL,*bufsize=NULL;
84 int bsize=BSIZE,verbose=0; 84 int bsize=BSIZE,verbose=0;
85 int ret=1,inl; 85 int ret=1,inl;
86 unsigned char key[24],iv[MD5_DIGEST_LENGTH];
87 char *str=NULL; 86 char *str=NULL;
88 char *hkey=NULL,*hiv=NULL; 87 char *hkey=NULL,*hiv=NULL;
89 int enc=1,printkey=0,i,base64=0; 88 int enc=1,printkey=0,i,base64=0;
@@ -92,7 +91,6 @@ char **argv;
92 char *inf=NULL,*outf=NULL; 91 char *inf=NULL,*outf=NULL;
93 BIO *in=NULL,*out=NULL,*b64=NULL,*benc=NULL,*rbio=NULL,*wbio=NULL; 92 BIO *in=NULL,*out=NULL,*b64=NULL,*benc=NULL,*rbio=NULL,*wbio=NULL;
94#define PROG_NAME_SIZE 39 93#define PROG_NAME_SIZE 39
95 char pname[PROG_NAME_SIZE+1];
96 94
97 95
98 apps_startup(); 96 apps_startup();
diff --git a/src/lib/libssl/src/demos/bio/saccept.c b/src/lib/libssl/src/demos/bio/saccept.c
index 933d6699ee..40cd4daad2 100644
--- a/src/lib/libssl/src/demos/bio/saccept.c
+++ b/src/lib/libssl/src/demos/bio/saccept.c
@@ -45,6 +45,11 @@ char *argv[];
45 45
46 SSL_load_error_strings(); 46 SSL_load_error_strings();
47 47
48#ifdef WATT32
49 dbug_init();
50 sock_init();
51#endif
52
48 /* Add ciphers and message digests */ 53 /* Add ciphers and message digests */
49 OpenSSL_add_ssl_algorithms(); 54 OpenSSL_add_ssl_algorithms();
50 55
diff --git a/src/lib/libssl/src/demos/bio/sconnect.c b/src/lib/libssl/src/demos/bio/sconnect.c
index 87b380b258..880344eb78 100644
--- a/src/lib/libssl/src/demos/bio/sconnect.c
+++ b/src/lib/libssl/src/demos/bio/sconnect.c
@@ -32,6 +32,11 @@ char *argv[];
32 else 32 else
33 host=argv[1]; 33 host=argv[1];
34 34
35#ifdef WATT32
36 dbug_init();
37 sock_init();
38#endif
39
35 /* Lets get nice error messages */ 40 /* Lets get nice error messages */
36 SSL_load_error_strings(); 41 SSL_load_error_strings();
37 42
diff --git a/src/lib/libssl/src/demos/engines/cluster_labs/hw_cluster_labs.c b/src/lib/libssl/src/demos/engines/cluster_labs/hw_cluster_labs.c
index 00c14f2755..036f48bafa 100644
--- a/src/lib/libssl/src/demos/engines/cluster_labs/hw_cluster_labs.c
+++ b/src/lib/libssl/src/demos/engines/cluster_labs/hw_cluster_labs.c
@@ -103,7 +103,7 @@ static int cluster_labs_rsa_mod_exp(BIGNUM *r0, const BIGNUM *I, RSA *rsa);
103 103
104/* DSA stuff */ 104/* DSA stuff */
105#ifndef OPENSSL_NO_DSA 105#ifndef OPENSSL_NO_DSA
106DSA_SIG *cluster_labs_dsa_sign(const unsigned char *dgst, int dlen, DSA *dsa); 106static DSA_SIG *cluster_labs_dsa_sign(const unsigned char *dgst, int dlen, DSA *dsa);
107static int cluster_labs_dsa_verify(const unsigned char *dgst, int dgst_len, 107static int cluster_labs_dsa_verify(const unsigned char *dgst, int dgst_len,
108 DSA_SIG *sig, DSA *dsa); 108 DSA_SIG *sig, DSA *dsa);
109static int cluster_labs_dsa_mod_exp(DSA *dsa, BIGNUM *rr, BIGNUM *a1, 109static int cluster_labs_dsa_mod_exp(DSA *dsa, BIGNUM *rr, BIGNUM *a1,
@@ -245,6 +245,9 @@ static ENGINE *engine_cluster_labs(void)
245 return ret; 245 return ret;
246 } 246 }
247 247
248#ifdef ENGINE_DYNAMIC_SUPPORT
249static
250#endif
248void ENGINE_load_cluster_labs(void) 251void ENGINE_load_cluster_labs(void)
249 { 252 {
250 253
@@ -504,7 +507,7 @@ static int cluster_labs_rsa_mod_exp(BIGNUM *r0, const BIGNUM *I, RSA *rsa)
504 507
505 } 508 }
506 509
507DSA_SIG *cluster_labs_dsa_sign(const unsigned char *dgst, int dlen, DSA *dsa) 510static DSA_SIG *cluster_labs_dsa_sign(const unsigned char *dgst, int dlen, DSA *dsa)
508 { 511 {
509 512
510 if(cluster_labs_dso == NULL) 513 if(cluster_labs_dso == NULL)
diff --git a/src/lib/libssl/src/demos/engines/ibmca/hw_ibmca.c b/src/lib/libssl/src/demos/engines/ibmca/hw_ibmca.c
index 881b16a7cb..0c2c39b8a7 100644
--- a/src/lib/libssl/src/demos/engines/ibmca/hw_ibmca.c
+++ b/src/lib/libssl/src/demos/engines/ibmca/hw_ibmca.c
@@ -288,6 +288,9 @@ static ENGINE *engine_ibmca(void)
288 return ret; 288 return ret;
289 } 289 }
290 290
291#ifdef ENGINE_DYNAMIC_SUPPORT
292static
293#endif
291void ENGINE_load_ibmca(void) 294void ENGINE_load_ibmca(void)
292 { 295 {
293 /* Copied from eng_[openssl|dyn].c */ 296 /* Copied from eng_[openssl|dyn].c */
diff --git a/src/lib/libssl/src/demos/engines/rsaref/Makefile b/src/lib/libssl/src/demos/engines/rsaref/Makefile
index 003e35df2e..63b8c79d27 100644
--- a/src/lib/libssl/src/demos/engines/rsaref/Makefile
+++ b/src/lib/libssl/src/demos/engines/rsaref/Makefile
@@ -34,13 +34,17 @@ update: FORCE.update
34 perl ../../../util/mkerr.pl -conf rsaref.ec \ 34 perl ../../../util/mkerr.pl -conf rsaref.ec \
35 -nostatic -staticloader -write rsaref.c 35 -nostatic -staticloader -write rsaref.c
36 36
37darwin: install $(SHLIB).darwin
38cygwin: install $(SHLIB).cygwin
37gnu: install $(SHLIB).gnu 39gnu: install $(SHLIB).gnu
40alpha-osf1: install $(SHLIB).alpha-osf1
38tru64: install $(SHLIB).tru64 41tru64: install $(SHLIB).tru64
39solaris: install $(SHLIB).solaris 42solaris: install $(SHLIB).solaris
40irix: install $(SHLIB).irix 43irix: install $(SHLIB).irix
41hpux32: install $(SHLIB).hpux32 44hpux32: install $(SHLIB).hpux32
42hpux64: install $(SHLIB).hpux64 45hpux64: install $(SHLIB).hpux64
43aix: install $(SHLIB).aix 46aix: install $(SHLIB).aix
47reliantunix: install $(SHLIB).reliantunix
44 48
45$(LIB): $(OBJ) 49$(LIB): $(OBJ)
46 $(AR) $(LIB) $(OBJ) 50 $(AR) $(LIB) $(OBJ)
@@ -51,6 +55,18 @@ LINK_SO= \
51 (nm -Pg $(LIBNAME).o | grep ' [BDT] ' | cut -f1 -d' ' > $(LIBNAME).exp; \ 55 (nm -Pg $(LIBNAME).o | grep ' [BDT] ' | cut -f1 -d' ' > $(LIBNAME).exp; \
52 $$SHAREDCMD $$SHAREDFLAGS -o $(SHLIB) $(LIBNAME).o -L ../../.. -lcrypto -lc) 56 $$SHAREDCMD $$SHAREDFLAGS -o $(SHLIB) $(LIBNAME).o -L ../../.. -lcrypto -lc)
53 57
58$(SHLIB).darwin: $(LIB) install/librsaref.a
59 ALLSYMSFLAGS='-all_load' \
60 SHAREDFLAGS='-dynamiclib -install_name $(SHLIB)' \
61 SHAREDCMD='$(CC)'; \
62 $(LINK_SO)
63 touch $(SHLIB).darwin
64$(SHLIB).cygwin: $(LIB) install/librsaref.a
65 ALLSYMSFLAGS='--whole-archive' \
66 SHAREDFLAGS='-shared -Wl,-Bsymbolic -Wl,--out-implib,$(LIBNAME).dll.a' \
67 SHAREDCMD='$(CC)'; \
68 $(LINK_SO)
69 touch $(SHLIB).cygwin
54$(SHLIB).gnu: $(LIB) install/librsaref.a 70$(SHLIB).gnu: $(LIB) install/librsaref.a
55 ALLSYMSFLAGS='--whole-archive' \ 71 ALLSYMSFLAGS='--whole-archive' \
56 SHAREDFLAGS='-shared -Wl,-soname=$(SHLIB)' \ 72 SHAREDFLAGS='-shared -Wl,-soname=$(SHLIB)' \
diff --git a/src/lib/libssl/src/demos/engines/rsaref/rsaref.c b/src/lib/libssl/src/demos/engines/rsaref/rsaref.c
index f092acbf3f..872811b8f7 100644
--- a/src/lib/libssl/src/demos/engines/rsaref/rsaref.c
+++ b/src/lib/libssl/src/demos/engines/rsaref/rsaref.c
@@ -3,11 +3,14 @@
3 be found a little here and there. */ 3 be found a little here and there. */
4 4
5#include <stdio.h> 5#include <stdio.h>
6#include <string.h>
6#include "./source/global.h" 7#include "./source/global.h"
7#include "./source/rsaref.h" 8#include "./source/rsaref.h"
8#include "./source/rsa.h" 9#include "./source/rsa.h"
9#include "./source/des.h" 10#include "./source/des.h"
10#include <openssl/err.h> 11#include <openssl/err.h>
12#define OPENSSL_NO_MD2
13#define OPENSSL_NO_MD5
11#include <openssl/evp.h> 14#include <openssl/evp.h>
12#include <openssl/bn.h> 15#include <openssl/bn.h>
13#include <openssl/engine.h> 16#include <openssl/engine.h>
@@ -93,21 +96,21 @@ static int rsaref_digest_nids[] =
93/***************************************************************************** 96/*****************************************************************************
94 * DES functions 97 * DES functions
95 **/ 98 **/
96int cipher_des_cbc_init(EVP_CIPHER_CTX *ctx, const unsigned char *key, 99static int cipher_des_cbc_init(EVP_CIPHER_CTX *ctx, const unsigned char *key,
97 const unsigned char *iv, int enc); 100 const unsigned char *iv, int enc);
98int cipher_des_cbc_code(EVP_CIPHER_CTX *ctx, unsigned char *out, 101static int cipher_des_cbc_code(EVP_CIPHER_CTX *ctx, unsigned char *out,
99 const unsigned char *in, unsigned int inl); 102 const unsigned char *in, unsigned int inl);
100int cipher_des_cbc_clean(EVP_CIPHER_CTX *); 103static int cipher_des_cbc_clean(EVP_CIPHER_CTX *);
101int cipher_des_ede3_cbc_init(EVP_CIPHER_CTX *ctx, const unsigned char *key, 104static int cipher_des_ede3_cbc_init(EVP_CIPHER_CTX *ctx, const unsigned char *key,
102 const unsigned char *iv, int enc); 105 const unsigned char *iv, int enc);
103int cipher_des_ede3_cbc_code(EVP_CIPHER_CTX *ctx, unsigned char *out, 106static int cipher_des_ede3_cbc_code(EVP_CIPHER_CTX *ctx, unsigned char *out,
104 const unsigned char *in, unsigned int inl); 107 const unsigned char *in, unsigned int inl);
105int cipher_des_ede3_cbc_clean(EVP_CIPHER_CTX *); 108static int cipher_des_ede3_cbc_clean(EVP_CIPHER_CTX *);
106int cipher_desx_cbc_init(EVP_CIPHER_CTX *ctx, const unsigned char *key, 109static int cipher_desx_cbc_init(EVP_CIPHER_CTX *ctx, const unsigned char *key,
107 const unsigned char *iv, int enc); 110 const unsigned char *iv, int enc);
108int cipher_desx_cbc_code(EVP_CIPHER_CTX *ctx, unsigned char *out, 111static int cipher_desx_cbc_code(EVP_CIPHER_CTX *ctx, unsigned char *out,
109 const unsigned char *in, unsigned int inl); 112 const unsigned char *in, unsigned int inl);
110int cipher_desx_cbc_clean(EVP_CIPHER_CTX *); 113static int cipher_desx_cbc_clean(EVP_CIPHER_CTX *);
111 114
112/***************************************************************************** 115/*****************************************************************************
113 * Our DES ciphers 116 * Our DES ciphers
@@ -400,7 +403,7 @@ static int rsaref_private_decrypt(int len, const unsigned char *from, unsigned c
400 403
401 if (!RSAref_Private_eay2ref(rsa,&RSAkey)) 404 if (!RSAref_Private_eay2ref(rsa,&RSAkey))
402 goto err; 405 goto err;
403 if ((i=RSAPrivateDecrypt(to,&outlen,(unsigned char *)from,len,&RSAkey)) != 0) 406 if ((i=RSAPrivateDecrypt(to,(unsigned int *)&outlen,(unsigned char *)from,len,&RSAkey)) != 0)
404 { 407 {
405 RSAREFerr(RSAREF_F_RSAREF_PRIVATE_DECRYPT,i); 408 RSAREFerr(RSAREF_F_RSAREF_PRIVATE_DECRYPT,i);
406 outlen= -1; 409 outlen= -1;
@@ -423,7 +426,7 @@ static int rsaref_private_encrypt(int len, const unsigned char *from, unsigned c
423 } 426 }
424 if (!RSAref_Private_eay2ref(rsa,&RSAkey)) 427 if (!RSAref_Private_eay2ref(rsa,&RSAkey))
425 goto err; 428 goto err;
426 if ((i=RSAPrivateEncrypt(to,&outlen,(unsigned char *)from,len,&RSAkey)) != 0) 429 if ((i=RSAPrivateEncrypt(to,(unsigned int)&outlen,(unsigned char *)from,len,&RSAkey)) != 0)
427 { 430 {
428 RSAREFerr(RSAREF_F_RSAREF_PRIVATE_ENCRYPT,i); 431 RSAREFerr(RSAREF_F_RSAREF_PRIVATE_ENCRYPT,i);
429 outlen= -1; 432 outlen= -1;
@@ -441,7 +444,7 @@ static int rsaref_public_decrypt(int len, const unsigned char *from, unsigned ch
441 444
442 if (!RSAref_Public_eay2ref(rsa,&RSAkey)) 445 if (!RSAref_Public_eay2ref(rsa,&RSAkey))
443 goto err; 446 goto err;
444 if ((i=RSAPublicDecrypt(to,&outlen,(unsigned char *)from,len,&RSAkey)) != 0) 447 if ((i=RSAPublicDecrypt(to,(unsigned int)&outlen,(unsigned char *)from,len,&RSAkey)) != 0)
445 { 448 {
446 RSAREFerr(RSAREF_F_RSAREF_PUBLIC_DECRYPT,i); 449 RSAREFerr(RSAREF_F_RSAREF_PUBLIC_DECRYPT,i);
447 outlen= -1; 450 outlen= -1;
@@ -478,7 +481,7 @@ static int rsaref_public_encrypt(int len, const unsigned char *from, unsigned ch
478 481
479 if (!RSAref_Public_eay2ref(rsa,&RSAkey)) 482 if (!RSAref_Public_eay2ref(rsa,&RSAkey))
480 goto err; 483 goto err;
481 if ((i=RSAPublicEncrypt(to,&outlen,(unsigned char *)from,len,&RSAkey,&rnd)) != 0) 484 if ((i=RSAPublicEncrypt(to,(unsigned int)&outlen,(unsigned char *)from,len,&RSAkey,&rnd)) != 0)
482 { 485 {
483 RSAREFerr(RSAREF_F_RSAREF_PUBLIC_ENCRYPT,i); 486 RSAREFerr(RSAREF_F_RSAREF_PUBLIC_ENCRYPT,i);
484 outlen= -1; 487 outlen= -1;
@@ -550,13 +553,13 @@ static int rsaref_digests(ENGINE *e, const EVP_MD **digest,
550 **/ 553 **/
551#undef data 554#undef data
552#define data(ctx) ((DES_CBC_CTX *)(ctx)->cipher_data) 555#define data(ctx) ((DES_CBC_CTX *)(ctx)->cipher_data)
553int cipher_des_cbc_init(EVP_CIPHER_CTX *ctx, const unsigned char *key, 556static int cipher_des_cbc_init(EVP_CIPHER_CTX *ctx, const unsigned char *key,
554 const unsigned char *iv, int enc) 557 const unsigned char *iv, int enc)
555 { 558 {
556 DES_CBCInit(data(ctx), (unsigned char *)key, (unsigned char *)iv, enc); 559 DES_CBCInit(data(ctx), (unsigned char *)key, (unsigned char *)iv, enc);
557 return 1; 560 return 1;
558 } 561 }
559int cipher_des_cbc_code(EVP_CIPHER_CTX *ctx, unsigned char *out, 562static int cipher_des_cbc_code(EVP_CIPHER_CTX *ctx, unsigned char *out,
560 const unsigned char *in, unsigned int inl) 563 const unsigned char *in, unsigned int inl)
561 { 564 {
562 int ret = DES_CBCUpdate(data(ctx), out, (unsigned char *)in, inl); 565 int ret = DES_CBCUpdate(data(ctx), out, (unsigned char *)in, inl);
@@ -572,7 +575,7 @@ int cipher_des_cbc_code(EVP_CIPHER_CTX *ctx, unsigned char *out,
572 } 575 }
573 return !ret; 576 return !ret;
574 } 577 }
575int cipher_des_cbc_clean(EVP_CIPHER_CTX *ctx) 578static int cipher_des_cbc_clean(EVP_CIPHER_CTX *ctx)
576 { 579 {
577 memset(data(ctx), 0, ctx->cipher->ctx_size); 580 memset(data(ctx), 0, ctx->cipher->ctx_size);
578 return 1; 581 return 1;
@@ -580,14 +583,14 @@ int cipher_des_cbc_clean(EVP_CIPHER_CTX *ctx)
580 583
581#undef data 584#undef data
582#define data(ctx) ((DES3_CBC_CTX *)(ctx)->cipher_data) 585#define data(ctx) ((DES3_CBC_CTX *)(ctx)->cipher_data)
583int cipher_des_ede3_cbc_init(EVP_CIPHER_CTX *ctx, const unsigned char *key, 586static int cipher_des_ede3_cbc_init(EVP_CIPHER_CTX *ctx, const unsigned char *key,
584 const unsigned char *iv, int enc) 587 const unsigned char *iv, int enc)
585 { 588 {
586 DES3_CBCInit(data(ctx), (unsigned char *)key, (unsigned char *)iv, 589 DES3_CBCInit(data(ctx), (unsigned char *)key, (unsigned char *)iv,
587 enc); 590 enc);
588 return 1; 591 return 1;
589 } 592 }
590int cipher_des_ede3_cbc_code(EVP_CIPHER_CTX *ctx, unsigned char *out, 593static int cipher_des_ede3_cbc_code(EVP_CIPHER_CTX *ctx, unsigned char *out,
591 const unsigned char *in, unsigned int inl) 594 const unsigned char *in, unsigned int inl)
592 { 595 {
593 int ret = DES3_CBCUpdate(data(ctx), out, (unsigned char *)in, inl); 596 int ret = DES3_CBCUpdate(data(ctx), out, (unsigned char *)in, inl);
@@ -603,7 +606,7 @@ int cipher_des_ede3_cbc_code(EVP_CIPHER_CTX *ctx, unsigned char *out,
603 } 606 }
604 return !ret; 607 return !ret;
605 } 608 }
606int cipher_des_ede3_cbc_clean(EVP_CIPHER_CTX *ctx) 609static int cipher_des_ede3_cbc_clean(EVP_CIPHER_CTX *ctx)
607 { 610 {
608 memset(data(ctx), 0, ctx->cipher->ctx_size); 611 memset(data(ctx), 0, ctx->cipher->ctx_size);
609 return 1; 612 return 1;
@@ -611,14 +614,14 @@ int cipher_des_ede3_cbc_clean(EVP_CIPHER_CTX *ctx)
611 614
612#undef data 615#undef data
613#define data(ctx) ((DESX_CBC_CTX *)(ctx)->cipher_data) 616#define data(ctx) ((DESX_CBC_CTX *)(ctx)->cipher_data)
614int cipher_desx_cbc_init(EVP_CIPHER_CTX *ctx, const unsigned char *key, 617static int cipher_desx_cbc_init(EVP_CIPHER_CTX *ctx, const unsigned char *key,
615 const unsigned char *iv, int enc) 618 const unsigned char *iv, int enc)
616 { 619 {
617 DESX_CBCInit(data(ctx), (unsigned char *)key, (unsigned char *)iv, 620 DESX_CBCInit(data(ctx), (unsigned char *)key, (unsigned char *)iv,
618 enc); 621 enc);
619 return 1; 622 return 1;
620 } 623 }
621int cipher_desx_cbc_code(EVP_CIPHER_CTX *ctx, unsigned char *out, 624static int cipher_desx_cbc_code(EVP_CIPHER_CTX *ctx, unsigned char *out,
622 const unsigned char *in, unsigned int inl) 625 const unsigned char *in, unsigned int inl)
623 { 626 {
624 int ret = DESX_CBCUpdate(data(ctx), out, (unsigned char *)in, inl); 627 int ret = DESX_CBCUpdate(data(ctx), out, (unsigned char *)in, inl);
@@ -634,7 +637,7 @@ int cipher_desx_cbc_code(EVP_CIPHER_CTX *ctx, unsigned char *out,
634 } 637 }
635 return !ret; 638 return !ret;
636 } 639 }
637int cipher_desx_cbc_clean(EVP_CIPHER_CTX *ctx) 640static int cipher_desx_cbc_clean(EVP_CIPHER_CTX *ctx)
638 { 641 {
639 memset(data(ctx), 0, ctx->cipher->ctx_size); 642 memset(data(ctx), 0, ctx->cipher->ctx_size);
640 return 1; 643 return 1;
diff --git a/src/lib/libssl/src/demos/engines/zencod/hw_zencod.c b/src/lib/libssl/src/demos/engines/zencod/hw_zencod.c
index 308e18710f..29206b4a29 100644
--- a/src/lib/libssl/src/demos/engines/zencod/hw_zencod.c
+++ b/src/lib/libssl/src/demos/engines/zencod/hw_zencod.c
@@ -366,7 +366,7 @@ static int bind_helper ( ENGINE *e )
366/* As this is only ever called once, there's no need for locking 366/* As this is only ever called once, there's no need for locking
367 * (indeed - the lock will already be held by our caller!!!) 367 * (indeed - the lock will already be held by our caller!!!)
368 */ 368 */
369ENGINE *ENGINE_zencod ( void ) 369static ENGINE *ENGINE_zencod ( void )
370{ 370{
371 371
372 ENGINE *eng = ENGINE_new () ; 372 ENGINE *eng = ENGINE_new () ;
@@ -383,6 +383,9 @@ ENGINE *ENGINE_zencod ( void )
383} 383}
384 384
385 385
386#ifdef ENGINE_DYNAMIC_SUPPORT
387static
388#endif
386void ENGINE_load_zencod ( void ) 389void ENGINE_load_zencod ( void )
387{ 390{
388 /* Copied from eng_[openssl|dyn].c */ 391 /* Copied from eng_[openssl|dyn].c */
diff --git a/src/lib/libssl/src/demos/spkigen.c b/src/lib/libssl/src/demos/spkigen.c
index d87881197c..2cd5dfea97 100644
--- a/src/lib/libssl/src/demos/spkigen.c
+++ b/src/lib/libssl/src/demos/spkigen.c
@@ -65,7 +65,8 @@ char *argv[];
65 65
66 fprintf(stderr,"please enter challenge string:"); 66 fprintf(stderr,"please enter challenge string:");
67 fflush(stderr); 67 fflush(stderr);
68 fgets(buf,120,stdin); 68 buf[0]='\0';
69 fgets(buf,sizeof buf,stdin);
69 i=strlen(buf); 70 i=strlen(buf);
70 if (i > 0) buf[--i]='\0'; 71 if (i > 0) buf[--i]='\0';
71 if (!ASN1_STRING_set((ASN1_STRING *)spki->spkac->challenge, 72 if (!ASN1_STRING_set((ASN1_STRING *)spki->spkac->challenge,
diff --git a/src/lib/libssl/src/demos/x509/mkcert.c b/src/lib/libssl/src/demos/x509/mkcert.c
index 4709e18e7c..c5e67b8e28 100644
--- a/src/lib/libssl/src/demos/x509/mkcert.c
+++ b/src/lib/libssl/src/demos/x509/mkcert.c
@@ -9,7 +9,9 @@
9#include <openssl/pem.h> 9#include <openssl/pem.h>
10#include <openssl/conf.h> 10#include <openssl/conf.h>
11#include <openssl/x509v3.h> 11#include <openssl/x509v3.h>
12#ifndef OPENSSL_NO_ENGINE
12#include <openssl/engine.h> 13#include <openssl/engine.h>
14#endif
13 15
14int mkcert(X509 **x509p, EVP_PKEY **pkeyp, int bits, int serial, int days); 16int mkcert(X509 **x509p, EVP_PKEY **pkeyp, int bits, int serial, int days);
15int add_ext(X509 *cert, int nid, char *value); 17int add_ext(X509 *cert, int nid, char *value);
@@ -35,7 +37,9 @@ int main(int argc, char **argv)
35 X509_free(x509); 37 X509_free(x509);
36 EVP_PKEY_free(pkey); 38 EVP_PKEY_free(pkey);
37 39
40#ifndef OPENSSL_NO_ENGINE
38 ENGINE_cleanup(); 41 ENGINE_cleanup();
42#endif
39 CRYPTO_cleanup_all_ex_data(); 43 CRYPTO_cleanup_all_ex_data();
40 44
41 CRYPTO_mem_leaks(bio_err); 45 CRYPTO_mem_leaks(bio_err);
@@ -88,7 +92,7 @@ int mkcert(X509 **x509p, EVP_PKEY **pkeyp, int bits, int serial, int days)
88 } 92 }
89 rsa=NULL; 93 rsa=NULL;
90 94
91 X509_set_version(x,3); 95 X509_set_version(x,2);
92 ASN1_INTEGER_set(X509_get_serialNumber(x),serial); 96 ASN1_INTEGER_set(X509_get_serialNumber(x),serial);
93 X509_gmtime_adj(X509_get_notBefore(x),0); 97 X509_gmtime_adj(X509_get_notBefore(x),0);
94 X509_gmtime_adj(X509_get_notAfter(x),(long)60*60*24*days); 98 X509_gmtime_adj(X509_get_notAfter(x),(long)60*60*24*days);
diff --git a/src/lib/libssl/src/demos/x509/mkreq.c b/src/lib/libssl/src/demos/x509/mkreq.c
index d69dcc392b..3dfc65f164 100644
--- a/src/lib/libssl/src/demos/x509/mkreq.c
+++ b/src/lib/libssl/src/demos/x509/mkreq.c
@@ -8,7 +8,9 @@
8#include <openssl/pem.h> 8#include <openssl/pem.h>
9#include <openssl/conf.h> 9#include <openssl/conf.h>
10#include <openssl/x509v3.h> 10#include <openssl/x509v3.h>
11#ifndef OPENSSL_NO_ENGINE
11#include <openssl/engine.h> 12#include <openssl/engine.h>
13#endif
12 14
13int mkreq(X509_REQ **x509p, EVP_PKEY **pkeyp, int bits, int serial, int days); 15int mkreq(X509_REQ **x509p, EVP_PKEY **pkeyp, int bits, int serial, int days);
14int add_ext(STACK_OF(X509_REQUEST) *sk, int nid, char *value); 16int add_ext(STACK_OF(X509_REQUEST) *sk, int nid, char *value);
@@ -33,7 +35,9 @@ int main(int argc, char **argv)
33 X509_REQ_free(req); 35 X509_REQ_free(req);
34 EVP_PKEY_free(pkey); 36 EVP_PKEY_free(pkey);
35 37
38#ifndef OPENSSL_NO_ENGINE
36 ENGINE_cleanup(); 39 ENGINE_cleanup();
40#endif
37 CRYPTO_cleanup_all_ex_data(); 41 CRYPTO_cleanup_all_ex_data();
38 42
39 CRYPTO_mem_leaks(bio_err); 43 CRYPTO_mem_leaks(bio_err);
diff --git a/src/lib/libssl/src/doc/HOWTO/certificates.txt b/src/lib/libssl/src/doc/HOWTO/certificates.txt
index 88048645db..d3a62545ad 100644
--- a/src/lib/libssl/src/doc/HOWTO/certificates.txt
+++ b/src/lib/libssl/src/doc/HOWTO/certificates.txt
@@ -1,6 +1,8 @@
1<DRAFT!> 1<DRAFT!>
2 HOWTO certificates 2 HOWTO certificates
3 3
41. Introduction
5
4How you handle certificates depend a great deal on what your role is. 6How you handle certificates depend a great deal on what your role is.
5Your role can be one or several of: 7Your role can be one or several of:
6 8
@@ -13,12 +15,14 @@ Certificate authorities should read ca.txt.
13 15
14In all the cases shown below, the standard configuration file, as 16In all the cases shown below, the standard configuration file, as
15compiled into openssl, will be used. You may find it in /etc/, 17compiled into openssl, will be used. You may find it in /etc/,
16/usr/local/ssr/ or somewhere else. The name is openssl.cnf, and 18/usr/local/ssl/ or somewhere else. The name is openssl.cnf, and
17is better described in another HOWTO <config.txt?>. If you want to 19is better described in another HOWTO <config.txt?>. If you want to
18use a different configuration file, use the argument '-config {file}' 20use a different configuration file, use the argument '-config {file}'
19with the command shown below. 21with the command shown below.
20 22
21 23
242. Relationship with keys
25
22Certificates are related to public key cryptography by containing a 26Certificates are related to public key cryptography by containing a
23public key. To be useful, there must be a corresponding private key 27public key. To be useful, there must be a corresponding private key
24somewhere. With OpenSSL, public keys are easily derived from private 28somewhere. With OpenSSL, public keys are easily derived from private
@@ -26,22 +30,25 @@ keys, so before you create a certificate or a certificate request, you
26need to create a private key. 30need to create a private key.
27 31
28Private keys are generated with 'openssl genrsa' if you want a RSA 32Private keys are generated with 'openssl genrsa' if you want a RSA
29private key, or 'openssl gendsa' if you want a DSA private key. More 33private key, or 'openssl gendsa' if you want a DSA private key.
30info on how to handle these commands are found in the manual pages for 34Further information on how to create private keys can be found in
31those commands or by running them with the argument '-h'. For the 35another HOWTO <keys.txt?>. The rest of this text assumes you have
32sake of the description in this file, let's assume that the private 36a private key in the file privkey.pem.
33key ended up in the file privkey.pem (which is the default in some 37
34cases). 38
35 393. Creating a certificate request
36 40
37Let's start with the most normal way of getting a certificate. Most 41To create a certificate, you need to start with a certificate
38often, you want or need to get a certificate from a certificate 42request (or, as some certificate authorities like to put
39authority. To handle that, the certificate authority needs a
40certificate request (or, as some certificate authorities like to put
41it, "certificate signing request", since that's exactly what they do, 43it, "certificate signing request", since that's exactly what they do,
42they sign it and give you the result back, thus making it authentic 44they sign it and give you the result back, thus making it authentic
43according to their policies) from you. To generate a request, use the 45according to their policies). A certificate request can then be sent
44command 'openssl req' like this: 46to a certificate authority to get it signed into a certificate, or if
47you have your own certificate authority, you may sign it yourself, or
48if you need a self-signed certificate (because you just want a test
49certificate or because you are setting up your own CA).
50
51The certificate request is created like this:
45 52
46 openssl req -new -key privkey.pem -out cert.csr 53 openssl req -new -key privkey.pem -out cert.csr
47 54
@@ -55,9 +62,23 @@ When the certificate authority has then done the checks the need to
55do (and probably gotten payment from you), they will hand over your 62do (and probably gotten payment from you), they will hand over your
56new certificate to you. 63new certificate to you.
57 64
65Section 5 will tell you more on how to handle the certificate you
66received.
67
68
694. Creating a self-signed certificate
70
71If you don't want to deal with another certificate authority, or just
72want to create a test certificate for yourself, or are setting up a
73certificate authority of your own, you may want to make the requested
74certificate a self-signed one. This is similar to creating a
75certificate request, but creates a certificate instead of a
76certificate request (1095 is 3 years):
77
78 openssl req -new -x509 -key privkey.pem -out cacert.pem -days 1095
58 79
59[fill in on how to create a self-signed certificate]
60 80
815. What to do with the certificate
61 82
62If you created everything yourself, or if the certificate authority 83If you created everything yourself, or if the certificate authority
63was kind enough, your certificate is a raw DER thing in PEM format. 84was kind enough, your certificate is a raw DER thing in PEM format.
diff --git a/src/lib/libssl/src/doc/HOWTO/keys.txt b/src/lib/libssl/src/doc/HOWTO/keys.txt
new file mode 100644
index 0000000000..45f42eaaf1
--- /dev/null
+++ b/src/lib/libssl/src/doc/HOWTO/keys.txt
@@ -0,0 +1,73 @@
1<DRAFT!>
2 HOWTO keys
3
41. Introduction
5
6Keys are the basis of public key algorithms and PKI. Keys usually
7come in pairs, with one half being the public key and the other half
8being the private key. With OpenSSL, the private key contains the
9public key information as well, so a public key doesn't need to be
10generated separately.
11
12Public keys come in several flavors, using different cryptographic
13algorithms. The most popular ones associated with certificates are
14RSA and DSA, and this HOWTO will show how to generate each of them.
15
16
172. To generate a RSA key
18
19A RSA key can be used both for encryption and for signing.
20
21Generating a key for the RSA algorithm is quite easy, all you have to
22do is the following:
23
24 openssl genrsa -des3 -out privkey.pem 2048
25
26With this variant, you will be prompted for a protecting password. If
27you don't want your key to be protected by a password, remove the flag
28'-des3' from the command line above.
29
30 NOTE: if you intend to use the key together with a server
31 certificate, it may be a good thing to avoid protecting it
32 with a password, since that would mean someone would have to
33 type in the password every time the server needs to access
34 the key.
35
36The number 2048 is the size of the key, in bits. Today, 2048 or
37higher is recommended for RSA keys, as fewer amount of bits is
38consider insecure or to be insecure pretty soon.
39
40
413. To generate a DSA key
42
43A DSA key can be used both for signing only. This is important to
44keep in mind to know what kind of purposes a certificate request with
45a DSA key can really be used for.
46
47Generating a key for the DSA algorithm is a two-step process. First,
48you have to generate parameters from which to generate the key:
49
50 openssl dsaparam -out dsaparam.pem 2048
51
52The number 2048 is the size of the key, in bits. Today, 2048 or
53higher is recommended for DSA keys, as fewer amount of bits is
54consider insecure or to be insecure pretty soon.
55
56When that is done, you can generate a key using the parameters in
57question (actually, several keys can be generated from the same
58parameters):
59
60 openssl gendsa -des3 -out privkey.pem dsaparam.pem
61
62With this variant, you will be prompted for a protecting password. If
63you don't want your key to be protected by a password, remove the flag
64'-des3' from the command line above.
65
66 NOTE: if you intend to use the key together with a server
67 certificate, it may be a good thing to avoid protecting it
68 with a password, since that would mean someone would have to
69 type in the password every time the server needs to access
70 the key.
71
72--
73Richard Levitte
diff --git a/src/lib/libssl/src/doc/apps/ca.pod b/src/lib/libssl/src/doc/apps/ca.pod
index c2ca8f2400..de66c534b5 100644
--- a/src/lib/libssl/src/doc/apps/ca.pod
+++ b/src/lib/libssl/src/doc/apps/ca.pod
@@ -13,6 +13,10 @@ B<openssl> B<ca>
13[B<-name section>] 13[B<-name section>]
14[B<-gencrl>] 14[B<-gencrl>]
15[B<-revoke file>] 15[B<-revoke file>]
16[B<-crl_reason reason>]
17[B<-crl_hold instruction>]
18[B<-crl_compromise time>]
19[B<-crl_CA_compromise time>]
16[B<-subj arg>] 20[B<-subj arg>]
17[B<-crldays days>] 21[B<-crldays days>]
18[B<-crlhours hours>] 22[B<-crlhours hours>]
@@ -39,6 +43,7 @@ B<openssl> B<ca>
39[B<-msie_hack>] 43[B<-msie_hack>]
40[B<-extensions section>] 44[B<-extensions section>]
41[B<-extfile section>] 45[B<-extfile section>]
46[B<-engine id>]
42 47
43=head1 DESCRIPTION 48=head1 DESCRIPTION
44 49
@@ -74,7 +79,7 @@ a single self signed certificate to be signed by the CA.
74=item B<-spkac filename> 79=item B<-spkac filename>
75 80
76a file containing a single Netscape signed public key and challenge 81a file containing a single Netscape signed public key and challenge
77and additional field values to be signed by the CA. See the B<NOTES> 82and additional field values to be signed by the CA. See the B<SPKAC FORMAT>
78section for information on the required format. 83section for information on the required format.
79 84
80=item B<-infiles> 85=item B<-infiles>
@@ -191,6 +196,13 @@ an additional configuration file to read certificate extensions from
191(using the default section unless the B<-extensions> option is also 196(using the default section unless the B<-extensions> option is also
192used). 197used).
193 198
199=item B<-engine id>
200
201specifying an engine (by it's unique B<id> string) will cause B<req>
202to attempt to obtain a functional reference to the specified engine,
203thus initialising it if needed. The engine will then be set as the default
204for all available algorithms.
205
194=back 206=back
195 207
196=head1 CRL OPTIONS 208=head1 CRL OPTIONS
@@ -214,6 +226,33 @@ the number of hours before the next CRL is due.
214 226
215a filename containing a certificate to revoke. 227a filename containing a certificate to revoke.
216 228
229=item B<-crl_reason reason>
230
231revocation reason, where B<reason> is one of: B<unspecified>, B<keyCompromise>,
232B<CACompromise>, B<affiliationChanged>, B<superseded>, B<cessationOfOperation>,
233B<certificateHold> or B<removeFromCRL>. The matching of B<reason> is case
234insensitive. Setting any revocation reason will make the CRL v2.
235
236In practive B<removeFromCRL> is not particularly useful because it is only used
237in delta CRLs which are not currently implemented.
238
239=item B<-crl_hold instruction>
240
241This sets the CRL revocation reason code to B<certificateHold> and the hold
242instruction to B<instruction> which must be an OID. Although any OID can be
243used only B<holdInstructionNone> (the use of which is discouraged by RFC2459)
244B<holdInstructionCallIssuer> or B<holdInstructionReject> will normally be used.
245
246=item B<-crl_compromise time>
247
248This sets the revocation reason to B<keyCompromise> and the compromise time to
249B<time>. B<time> should be in GeneralizedTime format that is B<YYYYMMDDHHMMSSZ>.
250
251=item B<-crl_CA_compromise time>
252
253This is the same as B<crl_compromise> except the revocation reason is set to
254B<CACompromise>.
255
217=item B<-subj arg> 256=item B<-subj arg>
218 257
219supersedes subject name given in the request. 258supersedes subject name given in the request.
@@ -486,18 +525,6 @@ A sample configuration file with the relevant sections for B<ca>:
486 commonName = supplied 525 commonName = supplied
487 emailAddress = optional 526 emailAddress = optional
488 527
489=head1 WARNINGS
490
491The B<ca> command is quirky and at times downright unfriendly.
492
493The B<ca> utility was originally meant as an example of how to do things
494in a CA. It was not supposed to be used as a full blown CA itself:
495nevertheless some people are using it for this purpose.
496
497The B<ca> command is effectively a single user command: no locking is
498done on the various files and attempts to run more than one B<ca> command
499on the same database can have unpredictable results.
500
501=head1 FILES 528=head1 FILES
502 529
503Note: the location of all files can change either by compile time options, 530Note: the location of all files can change either by compile time options,
@@ -527,9 +554,6 @@ if corrupted it can be difficult to fix. It is theoretically possible
527to rebuild the index file from all the issued certificates and a current 554to rebuild the index file from all the issued certificates and a current
528CRL: however there is no option to do this. 555CRL: however there is no option to do this.
529 556
530CRL entry extensions cannot currently be created: only CRL extensions
531can be added.
532
533V2 CRL features like delta CRL support and CRL numbers are not currently 557V2 CRL features like delta CRL support and CRL numbers are not currently
534supported. 558supported.
535 559
@@ -565,6 +589,16 @@ create an empty file.
565 589
566=head1 WARNINGS 590=head1 WARNINGS
567 591
592The B<ca> command is quirky and at times downright unfriendly.
593
594The B<ca> utility was originally meant as an example of how to do things
595in a CA. It was not supposed to be used as a full blown CA itself:
596nevertheless some people are using it for this purpose.
597
598The B<ca> command is effectively a single user command: no locking is
599done on the various files and attempts to run more than one B<ca> command
600on the same database can have unpredictable results.
601
568The B<copy_extensions> option should be used with caution. If care is 602The B<copy_extensions> option should be used with caution. If care is
569not taken then it can be a security risk. For example if a certificate 603not taken then it can be a security risk. For example if a certificate
570request contains a basicConstraints extension with CA:TRUE and the 604request contains a basicConstraints extension with CA:TRUE and the
diff --git a/src/lib/libssl/src/doc/apps/ciphers.pod b/src/lib/libssl/src/doc/apps/ciphers.pod
index b7e577b24f..81a2c43893 100644
--- a/src/lib/libssl/src/doc/apps/ciphers.pod
+++ b/src/lib/libssl/src/doc/apps/ciphers.pod
@@ -203,6 +203,10 @@ cipher suites using DH, including anonymous DH.
203 203
204anonymous DH cipher suites. 204anonymous DH cipher suites.
205 205
206=item B<AES>
207
208cipher suites using AES.
209
206=item B<3DES> 210=item B<3DES>
207 211
208cipher suites using triple DES. 212cipher suites using triple DES.
@@ -236,7 +240,9 @@ cipher suites using SHA1.
236=head1 CIPHER SUITE NAMES 240=head1 CIPHER SUITE NAMES
237 241
238The following lists give the SSL or TLS cipher suites names from the 242The following lists give the SSL or TLS cipher suites names from the
239relevant specification and their OpenSSL equivalents. 243relevant specification and their OpenSSL equivalents. It should be noted,
244that several cipher suite names do not include the authentication used,
245e.g. DES-CBC3-SHA. In these cases, RSA authentication is used.
240 246
241=head2 SSL v3.0 cipher suites. 247=head2 SSL v3.0 cipher suites.
242 248
@@ -306,6 +312,24 @@ relevant specification and their OpenSSL equivalents.
306 TLS_DH_anon_WITH_DES_CBC_SHA ADH-DES-CBC-SHA 312 TLS_DH_anon_WITH_DES_CBC_SHA ADH-DES-CBC-SHA
307 TLS_DH_anon_WITH_3DES_EDE_CBC_SHA ADH-DES-CBC3-SHA 313 TLS_DH_anon_WITH_3DES_EDE_CBC_SHA ADH-DES-CBC3-SHA
308 314
315=head2 AES ciphersuites from RFC3268, extending TLS v1.0
316
317 TLS_RSA_WITH_AES_128_CBC_SHA AES128-SHA
318 TLS_RSA_WITH_AES_256_CBC_SHA AES256-SHA
319
320 TLS_DH_DSS_WITH_AES_128_CBC_SHA DH-DSS-AES128-SHA
321 TLS_DH_DSS_WITH_AES_256_CBC_SHA DH-DSS-AES256-SHA
322 TLS_DH_RSA_WITH_AES_128_CBC_SHA DH-RSA-AES128-SHA
323 TLS_DH_RSA_WITH_AES_256_CBC_SHA DH-RSA-AES256-SHA
324
325 TLS_DHE_DSS_WITH_AES_128_CBC_SHA DHE-DSS-AES128-SHA
326 TLS_DHE_DSS_WITH_AES_256_CBC_SHA DHE-DSS-AES256-SHA
327 TLS_DHE_RSA_WITH_AES_128_CBC_SHA DHE-RSA-AES128-SHA
328 TLS_DHE_RSA_WITH_AES_256_CBC_SHA DHE-RSA-AES256-SHA
329
330 TLS_DH_anon_WITH_AES_128_CBC_SHA ADH-AES128-SHA
331 TLS_DH_anon_WITH_AES_256_CBC_SHA ADH-AES256-SHA
332
309=head2 Additional Export 1024 and other cipher suites 333=head2 Additional Export 1024 and other cipher suites
310 334
311Note: these ciphers can also be used in SSL v3. 335Note: these ciphers can also be used in SSL v3.
diff --git a/src/lib/libssl/src/doc/apps/dhparam.pod b/src/lib/libssl/src/doc/apps/dhparam.pod
index ff8a6e5e5b..c31db95a47 100644
--- a/src/lib/libssl/src/doc/apps/dhparam.pod
+++ b/src/lib/libssl/src/doc/apps/dhparam.pod
@@ -18,6 +18,7 @@ B<openssl dhparam>
18[B<-2>] 18[B<-2>]
19[B<-5>] 19[B<-5>]
20[B<-rand> I<file(s)>] 20[B<-rand> I<file(s)>]
21[B<-engine id>]
21[I<numbits>] 22[I<numbits>]
22 23
23=head1 DESCRIPTION 24=head1 DESCRIPTION
@@ -96,6 +97,13 @@ this option prints out the DH parameters in human readable form.
96this option converts the parameters into C code. The parameters can then 97this option converts the parameters into C code. The parameters can then
97be loaded by calling the B<get_dh>I<numbits>B<()> function. 98be loaded by calling the B<get_dh>I<numbits>B<()> function.
98 99
100=item B<-engine id>
101
102specifying an engine (by it's unique B<id> string) will cause B<req>
103to attempt to obtain a functional reference to the specified engine,
104thus initialising it if needed. The engine will then be set as the default
105for all available algorithms.
106
99=back 107=back
100 108
101=head1 WARNINGS 109=head1 WARNINGS
diff --git a/src/lib/libssl/src/doc/apps/dsa.pod b/src/lib/libssl/src/doc/apps/dsa.pod
index 28e534bb95..ed06b8806d 100644
--- a/src/lib/libssl/src/doc/apps/dsa.pod
+++ b/src/lib/libssl/src/doc/apps/dsa.pod
@@ -21,6 +21,7 @@ B<openssl> B<dsa>
21[B<-modulus>] 21[B<-modulus>]
22[B<-pubin>] 22[B<-pubin>]
23[B<-pubout>] 23[B<-pubout>]
24[B<-engine id>]
24 25
25=head1 DESCRIPTION 26=head1 DESCRIPTION
26 27
@@ -106,6 +107,13 @@ by default a private key is output. With this option a public
106key will be output instead. This option is automatically set if the input is 107key will be output instead. This option is automatically set if the input is
107a public key. 108a public key.
108 109
110=item B<-engine id>
111
112specifying an engine (by it's unique B<id> string) will cause B<req>
113to attempt to obtain a functional reference to the specified engine,
114thus initialising it if needed. The engine will then be set as the default
115for all available algorithms.
116
109=back 117=back
110 118
111=head1 NOTES 119=head1 NOTES
diff --git a/src/lib/libssl/src/doc/apps/dsaparam.pod b/src/lib/libssl/src/doc/apps/dsaparam.pod
index 50c2f61242..b9b1b93b42 100644
--- a/src/lib/libssl/src/doc/apps/dsaparam.pod
+++ b/src/lib/libssl/src/doc/apps/dsaparam.pod
@@ -16,6 +16,7 @@ B<openssl dsaparam>
16[B<-C>] 16[B<-C>]
17[B<-rand file(s)>] 17[B<-rand file(s)>]
18[B<-genkey>] 18[B<-genkey>]
19[B<-engine id>]
19[B<numbits>] 20[B<numbits>]
20 21
21=head1 DESCRIPTION 22=head1 DESCRIPTION
@@ -82,6 +83,13 @@ this option specifies that a parameter set should be generated of size
82B<numbits>. It must be the last option. If this option is included then 83B<numbits>. It must be the last option. If this option is included then
83the input file (if any) is ignored. 84the input file (if any) is ignored.
84 85
86=item B<-engine id>
87
88specifying an engine (by it's unique B<id> string) will cause B<req>
89to attempt to obtain a functional reference to the specified engine,
90thus initialising it if needed. The engine will then be set as the default
91for all available algorithms.
92
85=back 93=back
86 94
87=head1 NOTES 95=head1 NOTES
diff --git a/src/lib/libssl/src/doc/apps/gendsa.pod b/src/lib/libssl/src/doc/apps/gendsa.pod
index 74318fe7fb..2c56cc7888 100644
--- a/src/lib/libssl/src/doc/apps/gendsa.pod
+++ b/src/lib/libssl/src/doc/apps/gendsa.pod
@@ -12,6 +12,7 @@ B<openssl> B<gendsa>
12[B<-des3>] 12[B<-des3>]
13[B<-idea>] 13[B<-idea>]
14[B<-rand file(s)>] 14[B<-rand file(s)>]
15[B<-engine id>]
15[B<paramfile>] 16[B<paramfile>]
16 17
17=head1 DESCRIPTION 18=head1 DESCRIPTION
@@ -37,6 +38,13 @@ Multiple files can be specified separated by a OS-dependent character.
37The separator is B<;> for MS-Windows, B<,> for OpenVMS, and B<:> for 38The separator is B<;> for MS-Windows, B<,> for OpenVMS, and B<:> for
38all others. 39all others.
39 40
41=item B<-engine id>
42
43specifying an engine (by it's unique B<id> string) will cause B<req>
44to attempt to obtain a functional reference to the specified engine,
45thus initialising it if needed. The engine will then be set as the default
46for all available algorithms.
47
40=item B<paramfile> 48=item B<paramfile>
41 49
42This option specifies the DSA parameter file to use. The parameters in this 50This option specifies the DSA parameter file to use. The parameters in this
diff --git a/src/lib/libssl/src/doc/apps/genrsa.pod b/src/lib/libssl/src/doc/apps/genrsa.pod
index cdcc03c123..25af4d1475 100644
--- a/src/lib/libssl/src/doc/apps/genrsa.pod
+++ b/src/lib/libssl/src/doc/apps/genrsa.pod
@@ -15,6 +15,7 @@ B<openssl> B<genrsa>
15[B<-f4>] 15[B<-f4>]
16[B<-3>] 16[B<-3>]
17[B<-rand file(s)>] 17[B<-rand file(s)>]
18[B<-engine id>]
18[B<numbits>] 19[B<numbits>]
19 20
20=head1 DESCRIPTION 21=head1 DESCRIPTION
@@ -54,6 +55,13 @@ Multiple files can be specified separated by a OS-dependent character.
54The separator is B<;> for MS-Windows, B<,> for OpenVMS, and B<:> for 55The separator is B<;> for MS-Windows, B<,> for OpenVMS, and B<:> for
55all others. 56all others.
56 57
58=item B<-engine id>
59
60specifying an engine (by it's unique B<id> string) will cause B<req>
61to attempt to obtain a functional reference to the specified engine,
62thus initialising it if needed. The engine will then be set as the default
63for all available algorithms.
64
57=item B<numbits> 65=item B<numbits>
58 66
59the size of the private key to generate in bits. This must be the last option 67the size of the private key to generate in bits. This must be the last option
diff --git a/src/lib/libssl/src/doc/apps/ocsp.pod b/src/lib/libssl/src/doc/apps/ocsp.pod
index da201b95e6..4f266058e5 100644
--- a/src/lib/libssl/src/doc/apps/ocsp.pod
+++ b/src/lib/libssl/src/doc/apps/ocsp.pod
@@ -11,6 +11,10 @@ B<openssl> B<ocsp>
11[B<-issuer file>] 11[B<-issuer file>]
12[B<-cert file>] 12[B<-cert file>]
13[B<-serial n>] 13[B<-serial n>]
14[B<-signer file>]
15[B<-signkey file>]
16[B<-sign_other file>]
17[B<-no_certs>]
14[B<-req_text>] 18[B<-req_text>]
15[B<-resp_text>] 19[B<-resp_text>]
16[B<-text>] 20[B<-text>]
@@ -20,27 +24,36 @@ B<openssl> B<ocsp>
20[B<-respin file>] 24[B<-respin file>]
21[B<-nonce>] 25[B<-nonce>]
22[B<-no_nonce>] 26[B<-no_nonce>]
23[B<-url responder_url>] 27[B<-url URL>]
24[B<-host host:n>] 28[B<-host host:n>]
25[B<-path>] 29[B<-path>]
26[B<-CApath file>] 30[B<-CApath dir>]
27[B<-CAfile file>] 31[B<-CAfile file>]
28[B<-VAfile file>] 32[B<-VAfile file>]
29[B<-verify_certs file>] 33[B<-validity_period n>]
34[B<-status_age n>]
30[B<-noverify>] 35[B<-noverify>]
36[B<-verify_other file>]
31[B<-trust_other>] 37[B<-trust_other>]
32[B<-no_intern>] 38[B<-no_intern>]
33[B<-no_sig_verify>] 39[B<-no_signature_verify>]
34[B<-no_cert_verify>] 40[B<-no_cert_verify>]
35[B<-no_chain>] 41[B<-no_chain>]
36[B<-no_cert_checks>] 42[B<-no_cert_checks>]
37[B<-validity_period nsec>] 43[B<-port num>]
38[B<-status_age nsec>] 44[B<-index file>]
45[B<-CA file>]
46[B<-rsigner file>]
47[B<-rkey file>]
48[B<-rother file>]
49[B<-resp_no_certs>]
50[B<-nmin n>]
51[B<-ndays n>]
52[B<-resp_key_id>]
53[B<-nrequest n>]
39 54
40=head1 DESCRIPTION 55=head1 DESCRIPTION
41 56
42B<WARNING: this documentation is preliminary and subject to change.>
43
44The Online Certificate Status Protocol (OCSP) enables applications to 57The Online Certificate Status Protocol (OCSP) enables applications to
45determine the (revocation) state of an identified certificate (RFC 2560). 58determine the (revocation) state of an identified certificate (RFC 2560).
46 59
@@ -83,6 +96,10 @@ the B<signkey> option is not present then the private key is read
83from the same file as the certificate. If neither option is specified then 96from the same file as the certificate. If neither option is specified then
84the OCSP request is not signed. 97the OCSP request is not signed.
85 98
99=item B<-sign_other filename>
100
101Additional certificates to include in the signed request.
102
86=item B<-nonce>, B<-no_nonce> 103=item B<-nonce>, B<-no_nonce>
87 104
88Add an OCSP nonce extension to a request or disable OCSP nonce addition. 105Add an OCSP nonce extension to a request or disable OCSP nonce addition.
@@ -120,7 +137,7 @@ or "/" by default.
120file or pathname containing trusted CA certificates. These are used to verify 137file or pathname containing trusted CA certificates. These are used to verify
121the signature on the OCSP response. 138the signature on the OCSP response.
122 139
123=item B<-verify_certs file> 140=item B<-verify_other file>
124 141
125file containing additional certificates to search when attempting to locate 142file containing additional certificates to search when attempting to locate
126the OCSP response signing certificate. Some responders omit the actual signer's 143the OCSP response signing certificate. Some responders omit the actual signer's
@@ -151,7 +168,7 @@ ignore certificates contained in the OCSP response when searching for the
151signers certificate. With this option the signers certificate must be specified 168signers certificate. With this option the signers certificate must be specified
152with either the B<-verify_certs> or B<-VAfile> options. 169with either the B<-verify_certs> or B<-VAfile> options.
153 170
154=item B<-no_sig_verify> 171=item B<-no_signature_verify>
155 172
156don't check the signature on the OCSP response. Since this option tolerates invalid 173don't check the signature on the OCSP response. Since this option tolerates invalid
157signatures on OCSP responses it will normally only be used for testing purposes. 174signatures on OCSP responses it will normally only be used for testing purposes.
diff --git a/src/lib/libssl/src/doc/apps/passwd.pod b/src/lib/libssl/src/doc/apps/passwd.pod
index 07d849c824..f44982549b 100644
--- a/src/lib/libssl/src/doc/apps/passwd.pod
+++ b/src/lib/libssl/src/doc/apps/passwd.pod
@@ -75,7 +75,7 @@ to each password hash.
75 75
76B<openssl passwd -crypt -salt xx password> prints B<xxj31ZMTZzkVA>. 76B<openssl passwd -crypt -salt xx password> prints B<xxj31ZMTZzkVA>.
77 77
78B<openssl passwd -1 -salt xxxxxxxx password> prints B<$1$xxxxxxxx$8XJIcl6ZXqBMCK0qFevqT1>. 78B<openssl passwd -1 -salt xxxxxxxx password> prints B<$1$xxxxxxxx$UYCIxa628.9qXjpQCjM4a.>.
79 79
80B<openssl passwd -apr1 -salt xxxxxxxx password> prints B<$apr1$xxxxxxxx$dxHfLAsjHkDRmG83UXe8K0>. 80B<openssl passwd -apr1 -salt xxxxxxxx password> prints B<$apr1$xxxxxxxx$dxHfLAsjHkDRmG83UXe8K0>.
81 81
diff --git a/src/lib/libssl/src/doc/apps/pkcs7.pod b/src/lib/libssl/src/doc/apps/pkcs7.pod
index 9871c0e0cd..a0a636328b 100644
--- a/src/lib/libssl/src/doc/apps/pkcs7.pod
+++ b/src/lib/libssl/src/doc/apps/pkcs7.pod
@@ -14,6 +14,7 @@ B<openssl> B<pkcs7>
14[B<-print_certs>] 14[B<-print_certs>]
15[B<-text>] 15[B<-text>]
16[B<-noout>] 16[B<-noout>]
17[B<-engine id>]
17 18
18=head1 DESCRIPTION 19=head1 DESCRIPTION
19 20
@@ -59,6 +60,13 @@ issuer names.
59don't output the encoded version of the PKCS#7 structure (or certificates 60don't output the encoded version of the PKCS#7 structure (or certificates
60is B<-print_certs> is set). 61is B<-print_certs> is set).
61 62
63=item B<-engine id>
64
65specifying an engine (by it's unique B<id> string) will cause B<req>
66to attempt to obtain a functional reference to the specified engine,
67thus initialising it if needed. The engine will then be set as the default
68for all available algorithms.
69
62=back 70=back
63 71
64=head1 EXAMPLES 72=head1 EXAMPLES
diff --git a/src/lib/libssl/src/doc/apps/pkcs8.pod b/src/lib/libssl/src/doc/apps/pkcs8.pod
index a56b2dd002..68ecd65b10 100644
--- a/src/lib/libssl/src/doc/apps/pkcs8.pod
+++ b/src/lib/libssl/src/doc/apps/pkcs8.pod
@@ -21,6 +21,7 @@ B<openssl> B<pkcs8>
21[B<-nsdb>] 21[B<-nsdb>]
22[B<-v2 alg>] 22[B<-v2 alg>]
23[B<-v1 alg>] 23[B<-v1 alg>]
24[B<-engine id>]
24 25
25=head1 DESCRIPTION 26=head1 DESCRIPTION
26 27
@@ -122,6 +123,13 @@ B<des>, B<des3> and B<rc2>. It is recommended that B<des3> is used.
122This option specifies a PKCS#5 v1.5 or PKCS#12 algorithm to use. A complete 123This option specifies a PKCS#5 v1.5 or PKCS#12 algorithm to use. A complete
123list of possible algorithms is included below. 124list of possible algorithms is included below.
124 125
126=item B<-engine id>
127
128specifying an engine (by it's unique B<id> string) will cause B<req>
129to attempt to obtain a functional reference to the specified engine,
130thus initialising it if needed. The engine will then be set as the default
131for all available algorithms.
132
125=back 133=back
126 134
127=head1 NOTES 135=head1 NOTES
diff --git a/src/lib/libssl/src/doc/apps/req.pod b/src/lib/libssl/src/doc/apps/req.pod
index 10e4e12a5c..e2b5d0d8ec 100644
--- a/src/lib/libssl/src/doc/apps/req.pod
+++ b/src/lib/libssl/src/doc/apps/req.pod
@@ -41,6 +41,7 @@ B<openssl> B<req>
41[B<-nameopt>] 41[B<-nameopt>]
42[B<-batch>] 42[B<-batch>]
43[B<-verbose>] 43[B<-verbose>]
44[B<-engine id>]
44 45
45=head1 DESCRIPTION 46=head1 DESCRIPTION
46 47
@@ -244,6 +245,13 @@ non-interactive mode.
244 245
245print extra details about the operations being performed. 246print extra details about the operations being performed.
246 247
248=item B<-engine id>
249
250specifying an engine (by it's unique B<id> string) will cause B<req>
251to attempt to obtain a functional reference to the specified engine,
252thus initialising it if needed. The engine will then be set as the default
253for all available algorithms.
254
247=back 255=back
248 256
249=head1 CONFIGURATION FILE FORMAT 257=head1 CONFIGURATION FILE FORMAT
@@ -406,7 +414,7 @@ be input by calling it "1.organizationName".
406The actual permitted field names are any object identifier short or 414The actual permitted field names are any object identifier short or
407long names. These are compiled into OpenSSL and include the usual 415long names. These are compiled into OpenSSL and include the usual
408values such as commonName, countryName, localityName, organizationName, 416values such as commonName, countryName, localityName, organizationName,
409organizationUnitName, stateOrPrivinceName. Additionally emailAddress 417organizationUnitName, stateOrProvinceName. Additionally emailAddress
410is include as well as name, surname, givenName initials and dnQualifier. 418is include as well as name, surname, givenName initials and dnQualifier.
411 419
412Additional object identifiers can be defined with the B<oid_file> or 420Additional object identifiers can be defined with the B<oid_file> or
@@ -512,13 +520,13 @@ Sample configuration containing all field values:
512 520
513The header and footer lines in the B<PEM> format are normally: 521The header and footer lines in the B<PEM> format are normally:
514 522
515 -----BEGIN CERTIFICATE REQUEST---- 523 -----BEGIN CERTIFICATE REQUEST-----
516 -----END CERTIFICATE REQUEST---- 524 -----END CERTIFICATE REQUEST-----
517 525
518some software (some versions of Netscape certificate server) instead needs: 526some software (some versions of Netscape certificate server) instead needs:
519 527
520 -----BEGIN NEW CERTIFICATE REQUEST---- 528 -----BEGIN NEW CERTIFICATE REQUEST-----
521 -----END NEW CERTIFICATE REQUEST---- 529 -----END NEW CERTIFICATE REQUEST-----
522 530
523which is produced with the B<-newhdr> option but is otherwise compatible. 531which is produced with the B<-newhdr> option but is otherwise compatible.
524Either form is accepted transparently on input. 532Either form is accepted transparently on input.
diff --git a/src/lib/libssl/src/doc/apps/rsa.pod b/src/lib/libssl/src/doc/apps/rsa.pod
index ef74f1adff..4d7640995e 100644
--- a/src/lib/libssl/src/doc/apps/rsa.pod
+++ b/src/lib/libssl/src/doc/apps/rsa.pod
@@ -24,6 +24,7 @@ B<openssl> B<rsa>
24[B<-check>] 24[B<-check>]
25[B<-pubin>] 25[B<-pubin>]
26[B<-pubout>] 26[B<-pubout>]
27[B<-engine id>]
27 28
28=head1 DESCRIPTION 29=head1 DESCRIPTION
29 30
@@ -117,6 +118,13 @@ by default a private key is output: with this option a public
117key will be output instead. This option is automatically set if 118key will be output instead. This option is automatically set if
118the input is a public key. 119the input is a public key.
119 120
121=item B<-engine id>
122
123specifying an engine (by it's unique B<id> string) will cause B<req>
124to attempt to obtain a functional reference to the specified engine,
125thus initialising it if needed. The engine will then be set as the default
126for all available algorithms.
127
120=back 128=back
121 129
122=head1 NOTES 130=head1 NOTES
diff --git a/src/lib/libssl/src/doc/apps/s_client.pod b/src/lib/libssl/src/doc/apps/s_client.pod
index 7fca9cbdbd..47dc93cb3f 100644
--- a/src/lib/libssl/src/doc/apps/s_client.pod
+++ b/src/lib/libssl/src/doc/apps/s_client.pod
@@ -33,6 +33,7 @@ B<openssl> B<s_client>
33[B<-no_tls1>] 33[B<-no_tls1>]
34[B<-bugs>] 34[B<-bugs>]
35[B<-cipher cipherlist>] 35[B<-cipher cipherlist>]
36[B<-starttls protocol>]
36[B<-engine id>] 37[B<-engine id>]
37[B<-rand file(s)>] 38[B<-rand file(s)>]
38 39
@@ -163,6 +164,12 @@ the server determines which cipher suite is used it should take the first
163supported cipher in the list sent by the client. See the B<ciphers> 164supported cipher in the list sent by the client. See the B<ciphers>
164command for more information. 165command for more information.
165 166
167=item B<-starttls protocol>
168
169send the protocol-specific message(s) to switch to TLS for communication.
170B<protocol> is a keyword for the intended protocol. Currently, the only
171supported keyword is "smtp".
172
166=item B<-engine id> 173=item B<-engine id>
167 174
168specifying an engine (by it's unique B<id> string) will cause B<s_client> 175specifying an engine (by it's unique B<id> string) will cause B<s_client>
diff --git a/src/lib/libssl/src/doc/apps/s_server.pod b/src/lib/libssl/src/doc/apps/s_server.pod
index 4b1e4260ef..1d21921e47 100644
--- a/src/lib/libssl/src/doc/apps/s_server.pod
+++ b/src/lib/libssl/src/doc/apps/s_server.pod
@@ -42,6 +42,7 @@ B<openssl> B<s_server>
42[B<-WWW>] 42[B<-WWW>]
43[B<-HTTP>] 43[B<-HTTP>]
44[B<-engine id>] 44[B<-engine id>]
45[B<-id_prefix arg>]
45[B<-rand file(s)>] 46[B<-rand file(s)>]
46 47
47=head1 DESCRIPTION 48=head1 DESCRIPTION
@@ -209,6 +210,13 @@ to attempt to obtain a functional reference to the specified engine,
209thus initialising it if needed. The engine will then be set as the default 210thus initialising it if needed. The engine will then be set as the default
210for all available algorithms. 211for all available algorithms.
211 212
213=item B<-id_prefix arg>
214
215generate SSL/TLS session IDs prefixed by B<arg>. This is mostly useful
216for testing any SSL/TLS code (eg. proxies) that wish to deal with multiple
217servers, when each of which might be generating a unique range of session
218IDs (eg. with a certain prefix).
219
212=item B<-rand file(s)> 220=item B<-rand file(s)>
213 221
214a file or files containing random data used to seed the random number 222a file or files containing random data used to seed the random number
diff --git a/src/lib/libssl/src/doc/apps/smime.pod b/src/lib/libssl/src/doc/apps/smime.pod
index fa5d23e8dc..2453dd2738 100644
--- a/src/lib/libssl/src/doc/apps/smime.pod
+++ b/src/lib/libssl/src/doc/apps/smime.pod
@@ -340,8 +340,8 @@ detached signature format. You can use this program to verify the
340signature by line wrapping the base64 encoded structure and surrounding 340signature by line wrapping the base64 encoded structure and surrounding
341it with: 341it with:
342 342
343 -----BEGIN PKCS7---- 343 -----BEGIN PKCS7-----
344 -----END PKCS7---- 344 -----END PKCS7-----
345 345
346and using the command, 346and using the command,
347 347
diff --git a/src/lib/libssl/src/doc/apps/speed.pod b/src/lib/libssl/src/doc/apps/speed.pod
index 8101851ec6..0dcdba873e 100644
--- a/src/lib/libssl/src/doc/apps/speed.pod
+++ b/src/lib/libssl/src/doc/apps/speed.pod
@@ -54,4 +54,6 @@ for all available algorithms.
54If any options are given, B<speed> tests those algorithms, otherwise all of 54If any options are given, B<speed> tests those algorithms, otherwise all of
55the above are tested. 55the above are tested.
56 56
57=back
58
57=cut 59=cut
diff --git a/src/lib/libssl/src/doc/apps/spkac.pod b/src/lib/libssl/src/doc/apps/spkac.pod
index bb84dfbe33..c3f1ff9c64 100644
--- a/src/lib/libssl/src/doc/apps/spkac.pod
+++ b/src/lib/libssl/src/doc/apps/spkac.pod
@@ -17,7 +17,7 @@ B<openssl> B<spkac>
17[B<-spksect section>] 17[B<-spksect section>]
18[B<-noout>] 18[B<-noout>]
19[B<-verify>] 19[B<-verify>]
20 20[B<-engine id>]
21 21
22=head1 DESCRIPTION 22=head1 DESCRIPTION
23 23
@@ -79,6 +79,12 @@ being created).
79 79
80verifies the digital signature on the supplied SPKAC. 80verifies the digital signature on the supplied SPKAC.
81 81
82=item B<-engine id>
83
84specifying an engine (by it's unique B<id> string) will cause B<req>
85to attempt to obtain a functional reference to the specified engine,
86thus initialising it if needed. The engine will then be set as the default
87for all available algorithms.
82 88
83=back 89=back
84 90
diff --git a/src/lib/libssl/src/doc/apps/x509.pod b/src/lib/libssl/src/doc/apps/x509.pod
index 4a17e338dd..50343cd685 100644
--- a/src/lib/libssl/src/doc/apps/x509.pod
+++ b/src/lib/libssl/src/doc/apps/x509.pod
@@ -50,6 +50,7 @@ B<openssl> B<x509>
50[B<-clrext>] 50[B<-clrext>]
51[B<-extfile filename>] 51[B<-extfile filename>]
52[B<-extensions section>] 52[B<-extensions section>]
53[B<-engine id>]
53 54
54=head1 DESCRIPTION 55=head1 DESCRIPTION
55 56
@@ -61,8 +62,9 @@ certificate trust settings.
61Since there are a large number of options they will split up into 62Since there are a large number of options they will split up into
62various sections. 63various sections.
63 64
65=head1 OPTIONS
64 66
65=head1 INPUT, OUTPUT AND GENERAL PURPOSE OPTIONS 67=head2 INPUT, OUTPUT AND GENERAL PURPOSE OPTIONS
66 68
67=over 4 69=over 4
68 70
@@ -97,13 +99,19 @@ digest, such as the B<-fingerprint>, B<-signkey> and B<-CA> options. If not
97specified then MD5 is used. If the key being used to sign with is a DSA key then 99specified then MD5 is used. If the key being used to sign with is a DSA key then
98this option has no effect: SHA1 is always used with DSA keys. 100this option has no effect: SHA1 is always used with DSA keys.
99 101
102=item B<-engine id>
103
104specifying an engine (by it's unique B<id> string) will cause B<req>
105to attempt to obtain a functional reference to the specified engine,
106thus initialising it if needed. The engine will then be set as the default
107for all available algorithms.
100 108
101=back 109=back
102 110
103=head1 DISPLAY OPTIONS 111=head2 DISPLAY OPTIONS
104 112
105Note: the B<-alias> and B<-purpose> options are also display options 113Note: the B<-alias> and B<-purpose> options are also display options
106but are described in the B<TRUST OPTIONS> section. 114but are described in the B<TRUST SETTINGS> section.
107 115
108=over 4 116=over 4
109 117
@@ -181,7 +189,7 @@ this outputs the certificate in the form of a C source file.
181 189
182=back 190=back
183 191
184=head1 TRUST SETTINGS 192=head2 TRUST SETTINGS
185 193
186Please note these options are currently experimental and may well change. 194Please note these options are currently experimental and may well change.
187 195
@@ -252,7 +260,7 @@ EXTENSIONS> section.
252 260
253=back 261=back
254 262
255=head1 SIGNING OPTIONS 263=head2 SIGNING OPTIONS
256 264
257The B<x509> utility can be used to sign certificates and requests: it 265The B<x509> utility can be used to sign certificates and requests: it
258can thus behave like a "mini CA". 266can thus behave like a "mini CA".
@@ -341,7 +349,7 @@ The default filename consists of the CA certificate file base name with
341".srl" appended. For example if the CA certificate file is called 349".srl" appended. For example if the CA certificate file is called
342"mycacert.pem" it expects to find a serial number file called "mycacert.srl". 350"mycacert.pem" it expects to find a serial number file called "mycacert.srl".
343 351
344=item B<-CAcreateserial filename> 352=item B<-CAcreateserial>
345 353
346with this option the CA serial number file is created if it does not exist: 354with this option the CA serial number file is created if it does not exist:
347it will contain the serial number "02" and the certificate being signed will 355it will contain the serial number "02" and the certificate being signed will
@@ -362,7 +370,7 @@ specified then the extensions should either be contained in the unnamed
362 370
363=back 371=back
364 372
365=head1 NAME OPTIONS 373=head2 NAME OPTIONS
366 374
367The B<nameopt> command line switch determines how the subject and issuer 375The B<nameopt> command line switch determines how the subject and issuer
368names are displayed. If no B<nameopt> switch is present the default "oneline" 376names are displayed. If no B<nameopt> switch is present the default "oneline"
@@ -499,7 +507,7 @@ name.
499 507
500=back 508=back
501 509
502=head1 TEXT OPTIONS 510=head2 TEXT OPTIONS
503 511
504As well as customising the name output format, it is also possible to 512As well as customising the name output format, it is also possible to
505customise the actual fields printed using the B<certopt> options when 513customise the actual fields printed using the B<certopt> options when
@@ -636,25 +644,25 @@ certificate extensions:
636Set a certificate to be trusted for SSL client use and change set its alias to 644Set a certificate to be trusted for SSL client use and change set its alias to
637"Steve's Class 1 CA" 645"Steve's Class 1 CA"
638 646
639 openssl x509 -in cert.pem -addtrust sslclient \ 647 openssl x509 -in cert.pem -addtrust clientAuth \
640 -alias "Steve's Class 1 CA" -out trust.pem 648 -setalias "Steve's Class 1 CA" -out trust.pem
641 649
642=head1 NOTES 650=head1 NOTES
643 651
644The PEM format uses the header and footer lines: 652The PEM format uses the header and footer lines:
645 653
646 -----BEGIN CERTIFICATE---- 654 -----BEGIN CERTIFICATE-----
647 -----END CERTIFICATE---- 655 -----END CERTIFICATE-----
648 656
649it will also handle files containing: 657it will also handle files containing:
650 658
651 -----BEGIN X509 CERTIFICATE---- 659 -----BEGIN X509 CERTIFICATE-----
652 -----END X509 CERTIFICATE---- 660 -----END X509 CERTIFICATE-----
653 661
654Trusted certificates have the lines 662Trusted certificates have the lines
655 663
656 -----BEGIN TRUSTED CERTIFICATE---- 664 -----BEGIN TRUSTED CERTIFICATE-----
657 -----END TRUSTED CERTIFICATE---- 665 -----END TRUSTED CERTIFICATE-----
658 666
659The conversion to UTF8 format used with the name options assumes that 667The conversion to UTF8 format used with the name options assumes that
660T61Strings use the ISO8859-1 character set. This is wrong but Netscape 668T61Strings use the ISO8859-1 character set. This is wrong but Netscape
diff --git a/src/lib/libssl/src/doc/c-indentation.el b/src/lib/libssl/src/doc/c-indentation.el
index 48ca3cf69b..cbf01cb172 100644
--- a/src/lib/libssl/src/doc/c-indentation.el
+++ b/src/lib/libssl/src/doc/c-indentation.el
@@ -13,12 +13,10 @@
13; 13;
14; Apparently statement blocks that are not introduced by a statement 14; Apparently statement blocks that are not introduced by a statement
15; such as "if" and that are not the body of a function cannot 15; such as "if" and that are not the body of a function cannot
16; be handled too well by CC mode with this indentation style. 16; be handled too well by CC mode with this indentation style,
17; The style defined below does not indent them at all. 17; so you have to indent them manually (you can use C-q tab).
18; To insert tabs manually, prefix them with ^Q (the "quoted-insert" 18;
19; command of Emacs). If you know a solution to this problem 19; For suggesting improvements, please send e-mail to bodo@openssl.org.
20; or find other problems with this indentation style definition,
21; please send e-mail to bodo@openssl.org.
22 20
23(c-add-style "eay" 21(c-add-style "eay"
24 '((c-basic-offset . 8) 22 '((c-basic-offset . 8)
diff --git a/src/lib/libssl/src/doc/crypto/ASN1_OBJECT_new.pod b/src/lib/libssl/src/doc/crypto/ASN1_OBJECT_new.pod
new file mode 100644
index 0000000000..51679bfcd9
--- /dev/null
+++ b/src/lib/libssl/src/doc/crypto/ASN1_OBJECT_new.pod
@@ -0,0 +1,43 @@
1=pod
2
3=head1 NAME
4
5ASN1_OBJECT_new, ASN1_OBJECT_free, - object allocation functions
6
7=head1 SYNOPSIS
8
9 ASN1_OBJECT *ASN1_OBJECT_new(void);
10 void ASN1_OBJECT_free(ASN1_OBJECT *a);
11
12=head1 DESCRIPTION
13
14The ASN1_OBJECT allocation routines, allocate and free an
15ASN1_OBJECT structure, which represents an ASN1 OBJECT IDENTIFIER.
16
17ASN1_OBJECT_new() allocates and initializes a ASN1_OBJECT structure.
18
19ASN1_OBJECT_free() frees up the B<ASN1_OBJECT> structure B<a>.
20
21=head1 NOTES
22
23Although ASN1_OBJECT_new() allocates a new ASN1_OBJECT structure it
24is almost never used in applications. The ASN1 object utility functions
25such as OBJ_nid2obj() are used instead.
26
27=head1 RETURN VALUES
28
29If the allocation fails, ASN1_OBJECT_new() returns B<NULL> and sets an error
30code that can be obtained by L<ERR_get_error(3)|ERR_get_error(3)>.
31Otherwise it returns a pointer to the newly allocated structure.
32
33ASN1_OBJECT_free() returns no value.
34
35=head1 SEE ALSO
36
37L<ERR_get_error(3)|ERR_get_error(3)>, L<d2i_ASN1_OBJECT(3)|d2i_ASN1_OBJECT(3)>
38
39=head1 HISTORY
40
41ASN1_OBJECT_new() and ASN1_OBJECT_free() are available in all versions of SSLeay and OpenSSL.
42
43=cut
diff --git a/src/lib/libssl/src/doc/crypto/ASN1_STRING_length.pod b/src/lib/libssl/src/doc/crypto/ASN1_STRING_length.pod
new file mode 100644
index 0000000000..c4ec693f17
--- /dev/null
+++ b/src/lib/libssl/src/doc/crypto/ASN1_STRING_length.pod
@@ -0,0 +1,81 @@
1=pod
2
3=head1 NAME
4
5ASN1_STRING_dup, ASN1_STRING_cmp, ASN1_STRING_set, ASN1_STRING_length,
6ASN1_STRING_length_set, ASN1_STRING_type, ASN1_STRING_data -
7ASN1_STRING utility functions
8
9=head1 SYNOPSIS
10
11 int ASN1_STRING_length(ASN1_STRING *x);
12 unsigned char * ASN1_STRING_data(ASN1_STRING *x);
13
14 ASN1_STRING * ASN1_STRING_dup(ASN1_STRING *a);
15
16 int ASN1_STRING_cmp(ASN1_STRING *a, ASN1_STRING *b);
17
18 int ASN1_STRING_set(ASN1_STRING *str, const void *data, int len);
19
20 int ASN1_STRING_type(ASN1_STRING *x);
21
22 int ASN1_STRING_to_UTF8(unsigned char **out, ASN1_STRING *in);
23
24=head1 DESCRIPTION
25
26These functions allow an B<ASN1_STRING> structure to be manipulated.
27
28ASN1_STRING_length() returns the length of the content of B<x>.
29
30ASN1_STRING_data() returns an internal pointer to the data of B<x>.
31Since this is an internal pointer it should B<not> be freed or
32modified in any way.
33
34ASN1_STRING_dup() returns a copy of the structure B<a>.
35
36ASN1_STRING_cmp() compares B<a> and B<b> returning 0 if the two
37are identical. The string types and content are compared.
38
39ASN1_STRING_set() sets the data of string B<str> to the buffer
40B<data> or length B<len>. The supplied data is copied. If B<len>
41is -1 then the length is determined by strlen(data).
42
43ASN1_STRING_type() returns the type of B<x>, using standard constants
44such as B<V_ASN1_OCTET_STRING>.
45
46ASN1_STRING_to_UTF8() converts the string B<in> to UTF8 format, the
47converted data is allocated in a buffer in B<*out>. The length of
48B<out> is returned or a negative error code. The buffer B<*out>
49should be free using OPENSSL_free().
50
51=head1 NOTES
52
53Almost all ASN1 types in OpenSSL are represented as an B<ASN1_STRING>
54structure. Other types such as B<ASN1_OCTET_STRING> are simply typedefed
55to B<ASN1_STRING> and the functions call the B<ASN1_STRING> equivalents.
56B<ASN1_STRING> is also used for some B<CHOICE> types which consist
57entirely of primitive string types such as B<DirectoryString> and
58B<Time>.
59
60These functions should B<not> be used to examine or modify B<ASN1_INTEGER>
61or B<ASN1_ENUMERATED> types: the relevant B<INTEGER> or B<ENUMERATED>
62utility functions should be used instead.
63
64In general it cannot be assumed that the data returned by ASN1_STRING_data()
65is null terminated or does not contain embedded nulls. The actual format
66of the data will depend on the actual string type itself: for example
67for and IA5String the data will be ASCII, for a BMPString two bytes per
68character in big endian format, UTF8String will be in UTF8 format.
69
70Similar care should be take to ensure the data is in the correct format
71when calling ASN1_STRING_set().
72
73=head1 RETURN VALUES
74
75=head1 SEE ALSO
76
77L<ERR_get_error(3)|ERR_get_error(3)>
78
79=head1 HISTORY
80
81=cut
diff --git a/src/lib/libssl/src/doc/crypto/ASN1_STRING_new.pod b/src/lib/libssl/src/doc/crypto/ASN1_STRING_new.pod
new file mode 100644
index 0000000000..5b1bbb7eb2
--- /dev/null
+++ b/src/lib/libssl/src/doc/crypto/ASN1_STRING_new.pod
@@ -0,0 +1,44 @@
1=pod
2
3=head1 NAME
4
5ASN1_STRING_new, ASN1_STRING_type_new, ASN1_STRING_free -
6ASN1_STRING allocation functions
7
8=head1 SYNOPSIS
9
10 ASN1_STRING * ASN1_STRING_new(void);
11 ASN1_STRING * ASN1_STRING_type_new(int type);
12 void ASN1_STRING_free(ASN1_STRING *a);
13
14=head1 DESCRIPTION
15
16ASN1_STRING_new() returns an allocated B<ASN1_STRING> structure. Its type
17is undefined.
18
19ASN1_STRING_type_new() returns an allocated B<ASN1_STRING> structure of
20type B<type>.
21
22ASN1_STRING_free() frees up B<a>.
23
24=head1 NOTES
25
26Other string types call the B<ASN1_STRING> functions. For example
27ASN1_OCTET_STRING_new() calls ASN1_STRING_type(V_ASN1_OCTET_STRING).
28
29=head1 RETURN VALUES
30
31ASN1_STRING_new() and ASN1_STRING_type_new() return a valid
32ASN1_STRING structure or B<NULL> if an error occurred.
33
34ASN1_STRING_free() does not return a value.
35
36=head1 SEE ALSO
37
38L<ERR_get_error(3)|ERR_get_error(3)>
39
40=head1 HISTORY
41
42TBA
43
44=cut
diff --git a/src/lib/libssl/src/doc/crypto/ASN1_STRING_print_ex.pod b/src/lib/libssl/src/doc/crypto/ASN1_STRING_print_ex.pod
new file mode 100644
index 0000000000..fbf9a1f141
--- /dev/null
+++ b/src/lib/libssl/src/doc/crypto/ASN1_STRING_print_ex.pod
@@ -0,0 +1,96 @@
1=pod
2
3=head1 NAME
4
5ASN1_STRING_print_ex, ASN1_STRING_print_ex_fp - ASN1_STRING output routines.
6
7=head1 SYNOPSIS
8
9 #include <openssl/asn1.h>
10
11 int ASN1_STRING_print_ex(BIO *out, ASN1_STRING *str, unsigned long flags);
12 int ASN1_STRING_print_ex_fp(FILE *fp, ASN1_STRING *str, unsigned long flags);
13 int ASN1_STRING_print(BIO *out, ASN1_STRING *str);
14
15
16=head1 DESCRIPTION
17
18These functions output an B<ASN1_STRING> structure. B<ASN1_STRING> is used to
19represent all the ASN1 string types.
20
21ASN1_STRING_print_ex() outputs B<str> to B<out>, the format is determined by
22the options B<flags>. ASN1_STRING_print_ex_fp() is identical except it outputs
23to B<fp> instead.
24
25ASN1_STRING_print() prints B<str> to B<out> but using a different format to
26ASN1_STRING_print_ex(). It replaces unprintable characters (other than CR, LF)
27with '.'.
28
29=head1 NOTES
30
31ASN1_STRING_print() is a legacy function which should be avoided in new applications.
32
33Although there are a large number of options frequently B<ASN1_STRFLAGS_RFC2253> is
34suitable, or on UTF8 terminals B<ASN1_STRFLAGS_RFC2253 & ~ASN1_STRFLAGS_ESC_MSB>.
35
36The complete set of supported options for B<flags> is listed below.
37
38Various characters can be escaped. If B<ASN1_STRFLGS_ESC_2253> is set the characters
39determined by RFC2253 are escaped. If B<ASN1_STRFLGS_ESC_CTRL> is set control
40characters are escaped. If B<ASN1_STRFLGS_ESC_MSB> is set characters with the
41MSB set are escaped: this option should B<not> be used if the terminal correctly
42interprets UTF8 sequences.
43
44Escaping takes several forms.
45
46If the character being escaped is a 16 bit character then the form "\WXXXX" is used
47using exactly four characters for the hex representation. If it is 32 bits then
48"\UXXXXXXXX" is used using eight characters of its hex representation. These forms
49will only be used if UTF8 conversion is not set (see below).
50
51Printable characters are normally escaped using the backslash '\' character. If
52B<ASN1_STRFLGS_ESC_QUOTE> is set then the whole string is instead surrounded by
53double quote characters: this is arguably more readable than the backslash
54notation. Other characters use the "\XX" using exactly two characters of the hex
55representation.
56
57If B<ASN1_STRFLGS_UTF8_CONVERT> is set then characters are converted to UTF8
58format first. If the terminal supports the display of UTF8 sequences then this
59option will correctly display multi byte characters.
60
61If B<ASN1_STRFLGS_IGNORE_TYPE> is set then the string type is not interpreted at
62all: everything is assumed to be one byte per character. This is primarily for
63debugging purposes and can result in confusing output in multi character strings.
64
65If B<ASN1_STRFLGS_SHOW_TYPE> is set then the string type itself is printed out
66before its value (for example "BMPSTRING"), this actually uses ASN1_tag2str().
67
68The content of a string instead of being interpreted can be "dumped": this just
69outputs the value of the string using the form #XXXX using hex format for each
70octet.
71
72If B<ASN1_STRFLGS_DUMP_ALL> is set then any type is dumped.
73
74Normally non character string types (such as OCTET STRING) are assumed to be
75one byte per character, if B<ASN1_STRFLAGS_DUMP_UNKNOWN> is set then they will
76be dumped instead.
77
78When a type is dumped normally just the content octets are printed, if
79B<ASN1_STRFLGS_DUMP_DER> is set then the complete encoding is dumped
80instead (including tag and length octets).
81
82B<ASN1_STRFLGS_RFC2253> includes all the flags required by RFC2253. It is
83equivalent to:
84 ASN1_STRFLGS_ESC_2253 | ASN1_STRFLGS_ESC_CTRL | ASN1_STRFLGS_ESC_MSB |
85 ASN1_STRFLGS_UTF8_CONVERT | ASN1_STRFLGS_DUMP_UNKNOWN ASN1_STRFLGS_DUMP_DER
86
87=head1 SEE ALSO
88
89L<X509_NAME_print_ex(3)|X509_NAME_print_ex(3)>,
90L<ASN1_tag2str(3)|ASN1_tag2str(3)>
91
92=head1 HISTORY
93
94TBA
95
96=cut
diff --git a/src/lib/libssl/src/doc/crypto/BIO_f_cipher.pod b/src/lib/libssl/src/doc/crypto/BIO_f_cipher.pod
index 4182f2c309..02439cea94 100644
--- a/src/lib/libssl/src/doc/crypto/BIO_f_cipher.pod
+++ b/src/lib/libssl/src/doc/crypto/BIO_f_cipher.pod
@@ -28,7 +28,7 @@ BIO_flush() on an encryption BIO that is being written through is
28used to signal that no more data is to be encrypted: this is used 28used to signal that no more data is to be encrypted: this is used
29to flush and possibly pad the final block through the BIO. 29to flush and possibly pad the final block through the BIO.
30 30
31BIO_set_cipher() sets the cipher of BIO <b> to B<cipher> using key B<key> 31BIO_set_cipher() sets the cipher of BIO B<b> to B<cipher> using key B<key>
32and IV B<iv>. B<enc> should be set to 1 for encryption and zero for 32and IV B<iv>. B<enc> should be set to 1 for encryption and zero for
33decryption. 33decryption.
34 34
diff --git a/src/lib/libssl/src/doc/crypto/BIO_s_accept.pod b/src/lib/libssl/src/doc/crypto/BIO_s_accept.pod
index 55e4b730b9..7b63e4621b 100644
--- a/src/lib/libssl/src/doc/crypto/BIO_s_accept.pod
+++ b/src/lib/libssl/src/doc/crypto/BIO_s_accept.pod
@@ -2,7 +2,7 @@
2 2
3=head1 NAME 3=head1 NAME
4 4
5BIO_s_accept, BIO_set_nbio, BIO_set_accept_port, BIO_get_accept_port, 5BIO_s_accept, BIO_set_accept_port, BIO_get_accept_port,
6BIO_set_nbio_accept, BIO_set_accept_bios, BIO_set_bind_mode, 6BIO_set_nbio_accept, BIO_set_accept_bios, BIO_set_bind_mode,
7BIO_get_bind_mode, BIO_do_accept - accept BIO 7BIO_get_bind_mode, BIO_do_accept - accept BIO
8 8
diff --git a/src/lib/libssl/src/doc/crypto/BIO_s_bio.pod b/src/lib/libssl/src/doc/crypto/BIO_s_bio.pod
index 95ae802e47..8d0a55a025 100644
--- a/src/lib/libssl/src/doc/crypto/BIO_s_bio.pod
+++ b/src/lib/libssl/src/doc/crypto/BIO_s_bio.pod
@@ -76,7 +76,9 @@ BIO_get_write_buf_size() returns the size of the write buffer.
76BIO_new_bio_pair() combines the calls to BIO_new(), BIO_make_bio_pair() and 76BIO_new_bio_pair() combines the calls to BIO_new(), BIO_make_bio_pair() and
77BIO_set_write_buf_size() to create a connected pair of BIOs B<bio1>, B<bio2> 77BIO_set_write_buf_size() to create a connected pair of BIOs B<bio1>, B<bio2>
78with write buffer sizes B<writebuf1> and B<writebuf2>. If either size is 78with write buffer sizes B<writebuf1> and B<writebuf2>. If either size is
79zero then the default size is used. 79zero then the default size is used. BIO_new_bio_pair() does not check whether
80B<bio1> or B<bio2> do point to some other BIO, the values are overwritten,
81BIO_free() is not called.
80 82
81BIO_get_write_guarantee() and BIO_ctrl_get_write_guarantee() return the maximum 83BIO_get_write_guarantee() and BIO_ctrl_get_write_guarantee() return the maximum
82length of data that can be currently written to the BIO. Writes larger than this 84length of data that can be currently written to the BIO. Writes larger than this
@@ -118,9 +120,59 @@ the application then waits for data to be available on the underlying transport
118before flushing the write buffer it will never succeed because the request was 120before flushing the write buffer it will never succeed because the request was
119never sent! 121never sent!
120 122
123=head1 RETURN VALUES
124
125BIO_new_bio_pair() returns 1 on success, with the new BIOs available in
126B<bio1> and B<bio2>, or 0 on failure, with NULL pointers stored into the
127locations for B<bio1> and B<bio2>. Check the error stack for more information.
128
129[XXXXX: More return values need to be added here]
130
121=head1 EXAMPLE 131=head1 EXAMPLE
122 132
123TBA 133The BIO pair can be used to have full control over the network access of an
134application. The application can call select() on the socket as required
135without having to go through the SSL-interface.
136
137 BIO *internal_bio, *network_bio;
138 ...
139 BIO_new_bio_pair(internal_bio, 0, network_bio, 0);
140 SSL_set_bio(ssl, internal_bio, internal_bio);
141 SSL_operations();
142 ...
143
144 application | TLS-engine
145 | |
146 +----------> SSL_operations()
147 | /\ ||
148 | || \/
149 | BIO-pair (internal_bio)
150 +----------< BIO-pair (network_bio)
151 | |
152 socket |
153
154 ...
155 SSL_free(ssl); /* implicitly frees internal_bio */
156 BIO_free(network_bio);
157 ...
158
159As the BIO pair will only buffer the data and never directly access the
160connection, it behaves non-blocking and will return as soon as the write
161buffer is full or the read buffer is drained. Then the application has to
162flush the write buffer and/or fill the read buffer.
163
164Use the BIO_ctrl_pending(), to find out whether data is buffered in the BIO
165and must be transfered to the network. Use BIO_ctrl_get_read_request() to
166find out, how many bytes must be written into the buffer before the
167SSL_operation() can successfully be continued.
168
169=head1 WARNING
170
171As the data is buffered, SSL_operation() may return with a ERROR_SSL_WANT_READ
172condition, but there is still data in the write buffer. An application must
173not rely on the error value of SSL_operation() but must assure that the
174write buffer is always flushed first. Otherwise a deadlock may occur as
175the peer might be waiting for the data before being able to continue.
124 176
125=head1 SEE ALSO 177=head1 SEE ALSO
126 178
diff --git a/src/lib/libssl/src/doc/crypto/BN_CTX_new.pod b/src/lib/libssl/src/doc/crypto/BN_CTX_new.pod
index c94d8c610d..ad8d07db89 100644
--- a/src/lib/libssl/src/doc/crypto/BN_CTX_new.pod
+++ b/src/lib/libssl/src/doc/crypto/BN_CTX_new.pod
@@ -42,7 +42,7 @@ BN_CTX_init() and BN_CTX_free() have no return values.
42 42
43=head1 SEE ALSO 43=head1 SEE ALSO
44 44
45L<bn(3)|bn(3)>, L<err(3)|err(3)>, L<BN_add(3)|BN_add(3)>, 45L<bn(3)|bn(3)>, L<ERR_get_error(3)|ERR_get_error(3)>, L<BN_add(3)|BN_add(3)>,
46L<BN_CTX_start(3)|BN_CTX_start(3)> 46L<BN_CTX_start(3)|BN_CTX_start(3)>
47 47
48=head1 HISTORY 48=head1 HISTORY
diff --git a/src/lib/libssl/src/doc/crypto/BN_add.pod b/src/lib/libssl/src/doc/crypto/BN_add.pod
index a99fe33808..88c7a799ee 100644
--- a/src/lib/libssl/src/doc/crypto/BN_add.pod
+++ b/src/lib/libssl/src/doc/crypto/BN_add.pod
@@ -111,7 +111,7 @@ The error codes can be obtained by L<ERR_get_error(3)|ERR_get_error(3)>.
111 111
112=head1 SEE ALSO 112=head1 SEE ALSO
113 113
114L<bn(3)|bn(3)>, L<err(3)|err(3)>, L<BN_CTX_new(3)|BN_CTX_new(3)>, 114L<bn(3)|bn(3)>, L<ERR_get_error(3)|ERR_get_error(3)>, L<BN_CTX_new(3)|BN_CTX_new(3)>,
115L<BN_add_word(3)|BN_add_word(3)>, L<BN_set_bit(3)|BN_set_bit(3)> 115L<BN_add_word(3)|BN_add_word(3)>, L<BN_set_bit(3)|BN_set_bit(3)>
116 116
117=head1 HISTORY 117=head1 HISTORY
diff --git a/src/lib/libssl/src/doc/crypto/BN_add_word.pod b/src/lib/libssl/src/doc/crypto/BN_add_word.pod
index 66bedfb924..94244adea4 100644
--- a/src/lib/libssl/src/doc/crypto/BN_add_word.pod
+++ b/src/lib/libssl/src/doc/crypto/BN_add_word.pod
@@ -46,7 +46,7 @@ BN_mod_word() and BN_div_word() return B<a>%B<w>.
46 46
47=head1 SEE ALSO 47=head1 SEE ALSO
48 48
49L<bn(3)|bn(3)>, L<err(3)|err(3)>, L<BN_add(3)|BN_add(3)> 49L<bn(3)|bn(3)>, L<ERR_get_error(3)|ERR_get_error(3)>, L<BN_add(3)|BN_add(3)>
50 50
51=head1 HISTORY 51=head1 HISTORY
52 52
diff --git a/src/lib/libssl/src/doc/crypto/BN_bn2bin.pod b/src/lib/libssl/src/doc/crypto/BN_bn2bin.pod
index b62d1af0ff..a4b17ca60a 100644
--- a/src/lib/libssl/src/doc/crypto/BN_bn2bin.pod
+++ b/src/lib/libssl/src/doc/crypto/BN_bn2bin.pod
@@ -80,7 +80,7 @@ The error codes can be obtained by L<ERR_get_error(3)|ERR_get_error(3)>.
80 80
81=head1 SEE ALSO 81=head1 SEE ALSO
82 82
83L<bn(3)|bn(3)>, L<err(3)|err(3)>, L<BN_zero(3)|BN_zero(3)>, 83L<bn(3)|bn(3)>, L<ERR_get_error(3)|ERR_get_error(3)>, L<BN_zero(3)|BN_zero(3)>,
84L<ASN1_INTEGER_to_BN(3)|ASN1_INTEGER_to_BN(3)>, 84L<ASN1_INTEGER_to_BN(3)|ASN1_INTEGER_to_BN(3)>,
85L<BN_num_bytes(3)|BN_num_bytes(3)> 85L<BN_num_bytes(3)|BN_num_bytes(3)>
86 86
diff --git a/src/lib/libssl/src/doc/crypto/BN_copy.pod b/src/lib/libssl/src/doc/crypto/BN_copy.pod
index 8ad25e7834..388dd7df26 100644
--- a/src/lib/libssl/src/doc/crypto/BN_copy.pod
+++ b/src/lib/libssl/src/doc/crypto/BN_copy.pod
@@ -25,7 +25,7 @@ by L<ERR_get_error(3)|ERR_get_error(3)>.
25 25
26=head1 SEE ALSO 26=head1 SEE ALSO
27 27
28L<bn(3)|bn(3)>, L<err(3)|err(3)> 28L<bn(3)|bn(3)>, L<ERR_get_error(3)|ERR_get_error(3)>
29 29
30=head1 HISTORY 30=head1 HISTORY
31 31
diff --git a/src/lib/libssl/src/doc/crypto/BN_generate_prime.pod b/src/lib/libssl/src/doc/crypto/BN_generate_prime.pod
index 638f6514ee..7dccacbc1e 100644
--- a/src/lib/libssl/src/doc/crypto/BN_generate_prime.pod
+++ b/src/lib/libssl/src/doc/crypto/BN_generate_prime.pod
@@ -70,7 +70,7 @@ If B<do_trial_division == 0>, this test is skipped.
70 70
71Both BN_is_prime() and BN_is_prime_fasttest() perform a Miller-Rabin 71Both BN_is_prime() and BN_is_prime_fasttest() perform a Miller-Rabin
72probabilistic primality test with B<checks> iterations. If 72probabilistic primality test with B<checks> iterations. If
73B<checks == BN_prime_check>, a number of iterations is used that 73B<checks == BN_prime_checks>, a number of iterations is used that
74yields a false positive rate of at most 2^-80 for random input. 74yields a false positive rate of at most 2^-80 for random input.
75 75
76If B<callback> is not B<NULL>, B<callback(1, j, cb_arg)> is called 76If B<callback> is not B<NULL>, B<callback(1, j, cb_arg)> is called
@@ -90,7 +90,7 @@ The error codes can be obtained by L<ERR_get_error(3)|ERR_get_error(3)>.
90 90
91=head1 SEE ALSO 91=head1 SEE ALSO
92 92
93L<bn(3)|bn(3)>, L<err(3)|err(3)>, L<rand(3)|rand(3)> 93L<bn(3)|bn(3)>, L<ERR_get_error(3)|ERR_get_error(3)>, L<rand(3)|rand(3)>
94 94
95=head1 HISTORY 95=head1 HISTORY
96 96
diff --git a/src/lib/libssl/src/doc/crypto/BN_mod_inverse.pod b/src/lib/libssl/src/doc/crypto/BN_mod_inverse.pod
index 49e62daf9f..3ea3975c74 100644
--- a/src/lib/libssl/src/doc/crypto/BN_mod_inverse.pod
+++ b/src/lib/libssl/src/doc/crypto/BN_mod_inverse.pod
@@ -27,7 +27,7 @@ NULL on error. The error codes can be obtained by L<ERR_get_error(3)|ERR_get_err
27 27
28=head1 SEE ALSO 28=head1 SEE ALSO
29 29
30L<bn(3)|bn(3)>, L<err(3)|err(3)>, L<BN_add(3)|BN_add(3)> 30L<bn(3)|bn(3)>, L<ERR_get_error(3)|ERR_get_error(3)>, L<BN_add(3)|BN_add(3)>
31 31
32=head1 HISTORY 32=head1 HISTORY
33 33
diff --git a/src/lib/libssl/src/doc/crypto/BN_mod_mul_montgomery.pod b/src/lib/libssl/src/doc/crypto/BN_mod_mul_montgomery.pod
index ed4af7a214..6b16351b92 100644
--- a/src/lib/libssl/src/doc/crypto/BN_mod_mul_montgomery.pod
+++ b/src/lib/libssl/src/doc/crypto/BN_mod_mul_montgomery.pod
@@ -87,7 +87,7 @@ outside the expected range.
87 87
88=head1 SEE ALSO 88=head1 SEE ALSO
89 89
90L<bn(3)|bn(3)>, L<err(3)|err(3)>, L<BN_add(3)|BN_add(3)>, 90L<bn(3)|bn(3)>, L<ERR_get_error(3)|ERR_get_error(3)>, L<BN_add(3)|BN_add(3)>,
91L<BN_CTX_new(3)|BN_CTX_new(3)> 91L<BN_CTX_new(3)|BN_CTX_new(3)>
92 92
93=head1 HISTORY 93=head1 HISTORY
diff --git a/src/lib/libssl/src/doc/crypto/BN_mod_mul_reciprocal.pod b/src/lib/libssl/src/doc/crypto/BN_mod_mul_reciprocal.pod
index a28925f8a9..74a216ddc2 100644
--- a/src/lib/libssl/src/doc/crypto/BN_mod_mul_reciprocal.pod
+++ b/src/lib/libssl/src/doc/crypto/BN_mod_mul_reciprocal.pod
@@ -69,7 +69,7 @@ The error codes can be obtained by L<ERR_get_error(3)|ERR_get_error(3)>.
69 69
70=head1 SEE ALSO 70=head1 SEE ALSO
71 71
72L<bn(3)|bn(3)>, L<err(3)|err(3)>, L<BN_add(3)|BN_add(3)>, 72L<bn(3)|bn(3)>, L<ERR_get_error(3)|ERR_get_error(3)>, L<BN_add(3)|BN_add(3)>,
73L<BN_CTX_new(3)|BN_CTX_new(3)> 73L<BN_CTX_new(3)|BN_CTX_new(3)>
74 74
75=head1 HISTORY 75=head1 HISTORY
diff --git a/src/lib/libssl/src/doc/crypto/BN_new.pod b/src/lib/libssl/src/doc/crypto/BN_new.pod
index c1394ff2a3..3033789c51 100644
--- a/src/lib/libssl/src/doc/crypto/BN_new.pod
+++ b/src/lib/libssl/src/doc/crypto/BN_new.pod
@@ -42,7 +42,7 @@ values.
42 42
43=head1 SEE ALSO 43=head1 SEE ALSO
44 44
45L<bn(3)|bn(3)>, L<err(3)|err(3)> 45L<bn(3)|bn(3)>, L<ERR_get_error(3)|ERR_get_error(3)>
46 46
47=head1 HISTORY 47=head1 HISTORY
48 48
diff --git a/src/lib/libssl/src/doc/crypto/BN_rand.pod b/src/lib/libssl/src/doc/crypto/BN_rand.pod
index 9cec238f9e..81f93c2eb3 100644
--- a/src/lib/libssl/src/doc/crypto/BN_rand.pod
+++ b/src/lib/libssl/src/doc/crypto/BN_rand.pod
@@ -45,7 +45,7 @@ The error codes can be obtained by L<ERR_get_error(3)|ERR_get_error(3)>.
45 45
46=head1 SEE ALSO 46=head1 SEE ALSO
47 47
48L<bn(3)|bn(3)>, L<err(3)|err(3)>, L<rand(3)|rand(3)>, 48L<bn(3)|bn(3)>, L<ERR_get_error(3)|ERR_get_error(3)>, L<rand(3)|rand(3)>,
49L<RAND_add(3)|RAND_add(3)>, L<RAND_bytes(3)|RAND_bytes(3)> 49L<RAND_add(3)|RAND_add(3)>, L<RAND_bytes(3)|RAND_bytes(3)>
50 50
51=head1 HISTORY 51=head1 HISTORY
diff --git a/src/lib/libssl/src/doc/crypto/DH_generate_key.pod b/src/lib/libssl/src/doc/crypto/DH_generate_key.pod
index 920995b2e5..81f09fdf45 100644
--- a/src/lib/libssl/src/doc/crypto/DH_generate_key.pod
+++ b/src/lib/libssl/src/doc/crypto/DH_generate_key.pod
@@ -40,7 +40,7 @@ The error codes can be obtained by L<ERR_get_error(3)|ERR_get_error(3)>.
40 40
41=head1 SEE ALSO 41=head1 SEE ALSO
42 42
43L<dh(3)|dh(3)>, L<err(3)|err(3)>, L<rand(3)|rand(3)>, L<DH_size(3)|DH_size(3)> 43L<dh(3)|dh(3)>, L<ERR_get_error(3)|ERR_get_error(3)>, L<rand(3)|rand(3)>, L<DH_size(3)|DH_size(3)>
44 44
45=head1 HISTORY 45=head1 HISTORY
46 46
diff --git a/src/lib/libssl/src/doc/crypto/DH_generate_parameters.pod b/src/lib/libssl/src/doc/crypto/DH_generate_parameters.pod
index a7d0c75f0c..9081e9ea7c 100644
--- a/src/lib/libssl/src/doc/crypto/DH_generate_parameters.pod
+++ b/src/lib/libssl/src/doc/crypto/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(3)|err(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/libssl/src/doc/crypto/DH_new.pod b/src/lib/libssl/src/doc/crypto/DH_new.pod
index 64624b9d15..60c930093e 100644
--- a/src/lib/libssl/src/doc/crypto/DH_new.pod
+++ b/src/lib/libssl/src/doc/crypto/DH_new.pod
@@ -29,7 +29,7 @@ DH_free() returns no value.
29 29
30=head1 SEE ALSO 30=head1 SEE ALSO
31 31
32L<dh(3)|dh(3)>, L<err(3)|err(3)>, 32L<dh(3)|dh(3)>, L<ERR_get_error(3)|ERR_get_error(3)>,
33L<DH_generate_parameters(3)|DH_generate_parameters(3)>, 33L<DH_generate_parameters(3)|DH_generate_parameters(3)>,
34L<DH_generate_key(3)|DH_generate_key(3)> 34L<DH_generate_key(3)|DH_generate_key(3)>
35 35
diff --git a/src/lib/libssl/src/doc/crypto/DSA_SIG_new.pod b/src/lib/libssl/src/doc/crypto/DSA_SIG_new.pod
index 671655554a..3ac6140038 100644
--- a/src/lib/libssl/src/doc/crypto/DSA_SIG_new.pod
+++ b/src/lib/libssl/src/doc/crypto/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(3)|err(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/libssl/src/doc/crypto/DSA_do_sign.pod b/src/lib/libssl/src/doc/crypto/DSA_do_sign.pod
index a24fd5714e..5dfc733b20 100644
--- a/src/lib/libssl/src/doc/crypto/DSA_do_sign.pod
+++ b/src/lib/libssl/src/doc/crypto/DSA_do_sign.pod
@@ -36,7 +36,7 @@ L<ERR_get_error(3)|ERR_get_error(3)>.
36 36
37=head1 SEE ALSO 37=head1 SEE ALSO
38 38
39L<dsa(3)|dsa(3)>, L<err(3)|err(3)>, L<rand(3)|rand(3)>, 39L<dsa(3)|dsa(3)>, L<ERR_get_error(3)|ERR_get_error(3)>, L<rand(3)|rand(3)>,
40L<DSA_SIG_new(3)|DSA_SIG_new(3)>, 40L<DSA_SIG_new(3)|DSA_SIG_new(3)>,
41L<DSA_sign(3)|DSA_sign(3)> 41L<DSA_sign(3)|DSA_sign(3)>
42 42
diff --git a/src/lib/libssl/src/doc/crypto/DSA_dup_DH.pod b/src/lib/libssl/src/doc/crypto/DSA_dup_DH.pod
index fdfe125ab0..7f6f0d1115 100644
--- a/src/lib/libssl/src/doc/crypto/DSA_dup_DH.pod
+++ b/src/lib/libssl/src/doc/crypto/DSA_dup_DH.pod
@@ -27,7 +27,7 @@ Be careful to avoid small subgroup attacks when using this.
27 27
28=head1 SEE ALSO 28=head1 SEE ALSO
29 29
30L<dh(3)|dh(3)>, L<dsa(3)|dsa(3)>, L<err(3)|err(3)> 30L<dh(3)|dh(3)>, L<dsa(3)|dsa(3)>, L<ERR_get_error(3)|ERR_get_error(3)>
31 31
32=head1 HISTORY 32=head1 HISTORY
33 33
diff --git a/src/lib/libssl/src/doc/crypto/DSA_generate_key.pod b/src/lib/libssl/src/doc/crypto/DSA_generate_key.pod
index 52890db5be..af83ccfaa1 100644
--- a/src/lib/libssl/src/doc/crypto/DSA_generate_key.pod
+++ b/src/lib/libssl/src/doc/crypto/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(3)|err(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/libssl/src/doc/crypto/DSA_generate_parameters.pod b/src/lib/libssl/src/doc/crypto/DSA_generate_parameters.pod
index 43f60b0eb9..be7c924ff8 100644
--- a/src/lib/libssl/src/doc/crypto/DSA_generate_parameters.pod
+++ b/src/lib/libssl/src/doc/crypto/DSA_generate_parameters.pod
@@ -90,7 +90,7 @@ Seed lengths E<gt> 20 are not supported.
90 90
91=head1 SEE ALSO 91=head1 SEE ALSO
92 92
93L<dsa(3)|dsa(3)>, L<err(3)|err(3)>, L<rand(3)|rand(3)>, 93L<dsa(3)|dsa(3)>, L<ERR_get_error(3)|ERR_get_error(3)>, L<rand(3)|rand(3)>,
94L<DSA_free(3)|DSA_free(3)> 94L<DSA_free(3)|DSA_free(3)>
95 95
96=head1 HISTORY 96=head1 HISTORY
diff --git a/src/lib/libssl/src/doc/crypto/DSA_new.pod b/src/lib/libssl/src/doc/crypto/DSA_new.pod
index 546146d9de..48e9b82a09 100644
--- a/src/lib/libssl/src/doc/crypto/DSA_new.pod
+++ b/src/lib/libssl/src/doc/crypto/DSA_new.pod
@@ -31,7 +31,7 @@ DSA_free() returns no value.
31 31
32=head1 SEE ALSO 32=head1 SEE ALSO
33 33
34L<dsa(3)|dsa(3)>, L<err(3)|err(3)>, 34L<dsa(3)|dsa(3)>, L<ERR_get_error(3)|ERR_get_error(3)>,
35L<DSA_generate_parameters(3)|DSA_generate_parameters(3)>, 35L<DSA_generate_parameters(3)|DSA_generate_parameters(3)>,
36L<DSA_generate_key(3)|DSA_generate_key(3)> 36L<DSA_generate_key(3)|DSA_generate_key(3)>
37 37
diff --git a/src/lib/libssl/src/doc/crypto/DSA_sign.pod b/src/lib/libssl/src/doc/crypto/DSA_sign.pod
index f6e60a8ca3..97389e8ec8 100644
--- a/src/lib/libssl/src/doc/crypto/DSA_sign.pod
+++ b/src/lib/libssl/src/doc/crypto/DSA_sign.pod
@@ -55,7 +55,7 @@ Standard, DSS), ANSI X9.30
55 55
56=head1 SEE ALSO 56=head1 SEE ALSO
57 57
58L<dsa(3)|dsa(3)>, L<err(3)|err(3)>, L<rand(3)|rand(3)>, 58L<dsa(3)|dsa(3)>, L<ERR_get_error(3)|ERR_get_error(3)>, L<rand(3)|rand(3)>,
59L<DSA_do_sign(3)|DSA_do_sign(3)> 59L<DSA_do_sign(3)|DSA_do_sign(3)>
60 60
61=head1 HISTORY 61=head1 HISTORY
diff --git a/src/lib/libssl/src/doc/crypto/ERR_get_error.pod b/src/lib/libssl/src/doc/crypto/ERR_get_error.pod
index 9fdedbcb91..34443045fc 100644
--- a/src/lib/libssl/src/doc/crypto/ERR_get_error.pod
+++ b/src/lib/libssl/src/doc/crypto/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/libssl/src/doc/crypto/EVP_EncryptInit.pod b/src/lib/libssl/src/doc/crypto/EVP_EncryptInit.pod
index 75cceb1ca2..daf57e5895 100644
--- a/src/lib/libssl/src/doc/crypto/EVP_EncryptInit.pod
+++ b/src/lib/libssl/src/doc/crypto/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/libssl/src/doc/crypto/EVP_PKEY_new.pod b/src/lib/libssl/src/doc/crypto/EVP_PKEY_new.pod
new file mode 100644
index 0000000000..10687e458d
--- /dev/null
+++ b/src/lib/libssl/src/doc/crypto/EVP_PKEY_new.pod
@@ -0,0 +1,47 @@
1=pod
2
3=head1 NAME
4
5EVP_PKEY_new, EVP_PKEY_free - private key allocation functions.
6
7=head1 SYNOPSIS
8
9 #include <openssl/evp.h>
10
11 EVP_PKEY *EVP_PKEY_new(void);
12 void EVP_PKEY_free(EVP_PKEY *key);
13
14
15=head1 DESCRIPTION
16
17The EVP_PKEY_new() function allocates an empty B<EVP_PKEY>
18structure which is used by OpenSSL to store private keys.
19
20EVP_PKEY_free() frees up the private key B<key>.
21
22=head1 NOTES
23
24The B<EVP_PKEY> structure is used by various OpenSSL functions
25which require a general private key without reference to any
26particular algorithm.
27
28The structure returned by EVP_PKEY_new() is empty. To add a
29private key to this empty structure the functions described in
30L<EVP_PKEY_set1_RSA(3)|EVP_PKEY_set1_RSA(3)> should be used.
31
32=head1 RETURN VALUES
33
34EVP_PKEY_new() returns either the newly allocated B<EVP_PKEY>
35structure of B<NULL> if an error occurred.
36
37EVP_PKEY_free() does not return a value.
38
39=head1 SEE ALSO
40
41L<EVP_PKEY_set1_RSA(3)|EVP_PKEY_set1_RSA(3)>
42
43=head1 HISTORY
44
45TBA
46
47=cut
diff --git a/src/lib/libssl/src/doc/crypto/EVP_PKEY_set1_RSA.pod b/src/lib/libssl/src/doc/crypto/EVP_PKEY_set1_RSA.pod
new file mode 100644
index 0000000000..2db692e271
--- /dev/null
+++ b/src/lib/libssl/src/doc/crypto/EVP_PKEY_set1_RSA.pod
@@ -0,0 +1,80 @@
1=pod
2
3=head1 NAME
4
5EVP_PKEY_set1_RSA, EVP_PKEY_set1_DSA, EVP_PKEY_set1_DH, EVP_PKEY_set1_EC_KEY,
6EVP_PKEY_get1_RSA, EVP_PKEY_get1_DSA, EVP_PKEY_get1_DH, EVP_PKEY_get1_EC_KEY,
7EVP_PKEY_assign_RSA, EVP_PKEY_assign_DSA, EVP_PKEY_assign_DH, EVP_PKEY_assign_EC_KEY,
8EVP_PKEY_type - EVP_PKEY assignment functions.
9
10=head1 SYNOPSIS
11
12 #include <openssl/evp.h>
13
14 int EVP_PKEY_set1_RSA(EVP_PKEY *pkey,RSA *key);
15 int EVP_PKEY_set1_DSA(EVP_PKEY *pkey,DSA *key);
16 int EVP_PKEY_set1_DH(EVP_PKEY *pkey,DH *key);
17 int EVP_PKEY_set1_EC_KEY(EVP_PKEY *pkey,EC_KEY *key);
18
19 RSA *EVP_PKEY_get1_RSA(EVP_PKEY *pkey);
20 DSA *EVP_PKEY_get1_DSA(EVP_PKEY *pkey);
21 DH *EVP_PKEY_get1_DH(EVP_PKEY *pkey);
22 EC_KEY *EVP_PKEY_get1_EC_KEY(EVP_PKEY *pkey);
23
24 int EVP_PKEY_assign_RSA(EVP_PKEY *pkey,RSA *key);
25 int EVP_PKEY_assign_DSA(EVP_PKEY *pkey,DSA *key);
26 int EVP_PKEY_assign_DH(EVP_PKEY *pkey,DH *key);
27 int EVP_PKEY_assign_EC_KEY(EVP_PKEY *pkey,EC_KEY *key);
28
29 int EVP_PKEY_type(int type);
30
31=head1 DESCRIPTION
32
33EVP_PKEY_set1_RSA(), EVP_PKEY_set1_DSA(), EVP_PKEY_set1_DH() and
34EVP_PKEY_set1_EC_KEY() set the key referenced by B<pkey> to B<key>.
35
36EVP_PKEY_get1_RSA(), EVP_PKEY_get1_DSA(), EVP_PKEY_get1_DH() and
37EVP_PKEY_get1_EC_KEY() return the referenced key in B<pkey> or
38B<NULL> if the key is not of the correct type.
39
40EVP_PKEY_assign_RSA() EVP_PKEY_assign_DSA(), EVP_PKEY_assign_DH()
41and EVP_PKEY_assign_EC_KEY() also set the referenced key to B<key>
42however these use the supplied B<key> internally and so B<key>
43will be freed when the parent B<pkey> is freed.
44
45EVP_PKEY_type() returns the type of key corresponding to the value
46B<type>. The type of a key can be obtained with
47EVP_PKEY_type(pkey->type). The return value will be EVP_PKEY_RSA,
48EVP_PKEY_DSA, EVP_PKEY_DH or EVP_PKEY_EC for the corresponding
49key types or NID_undef if the key type is unassigned.
50
51=head1 NOTES
52
53In accordance with the OpenSSL naming convention the key obtained
54from or assigned to the B<pkey> using the B<1> functions must be
55freed as well as B<pkey>.
56
57EVP_PKEY_assign_RSA() EVP_PKEY_assign_DSA(), EVP_PKEY_assign_DH()
58EVP_PKEY_assign_EC_KEY() are implemented as macros.
59
60=head1 RETURN VALUES
61
62EVP_PKEY_set1_RSA(), EVP_PKEY_set1_DSA(), EVP_PKEY_set1_DH() and
63EVP_PKEY_set1_EC_KEY() return 1 for success or 0 for failure.
64
65EVP_PKEY_get1_RSA(), EVP_PKEY_get1_DSA(), EVP_PKEY_get1_DH() and
66EVP_PKEY_get1_EC_KEY() return the referenced key or B<NULL> if
67an error occurred.
68
69EVP_PKEY_assign_RSA() EVP_PKEY_assign_DSA(), EVP_PKEY_assign_DH()
70and EVP_PKEY_assign_EC_KEY() return 1 for success and 0 for failure.
71
72=head1 SEE ALSO
73
74L<EVP_PKEY_new(3)|EVP_PKEY_new(3)>
75
76=head1 HISTORY
77
78TBA
79
80=cut
diff --git a/src/lib/libssl/src/doc/crypto/EVP_SealInit.pod b/src/lib/libssl/src/doc/crypto/EVP_SealInit.pod
index 25ef07f7c7..b5e477e294 100644
--- a/src/lib/libssl/src/doc/crypto/EVP_SealInit.pod
+++ b/src/lib/libssl/src/doc/crypto/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/libssl/src/doc/crypto/OBJ_nid2obj.pod b/src/lib/libssl/src/doc/crypto/OBJ_nid2obj.pod
new file mode 100644
index 0000000000..7dcc07923f
--- /dev/null
+++ b/src/lib/libssl/src/doc/crypto/OBJ_nid2obj.pod
@@ -0,0 +1,149 @@
1=pod
2
3=head1 NAME
4
5OBJ_nid2obj, OBJ_nid2ln, OBJ_nid2sn, OBJ_obj2nid, OBJ_txt2nid, OBJ_ln2nid, OBJ_sn2nid,
6OBJ_cmp, OBJ_dup, OBJ_txt2obj, OBJ_obj2txt, OBJ_create, OBJ_cleanup - ASN1 object utility
7functions
8
9=head1 SYNOPSIS
10
11 ASN1_OBJECT * OBJ_nid2obj(int n);
12 const char * OBJ_nid2ln(int n);
13 const char * OBJ_nid2sn(int n);
14
15 int OBJ_obj2nid(const ASN1_OBJECT *o);
16 int OBJ_ln2nid(const char *ln);
17 int OBJ_sn2nid(const char *sn);
18
19 int OBJ_txt2nid(const char *s);
20
21 ASN1_OBJECT * OBJ_txt2obj(const char *s, int no_name);
22 int OBJ_obj2txt(char *buf, int buf_len, const ASN1_OBJECT *a, int no_name);
23
24 int OBJ_cmp(const ASN1_OBJECT *a,const ASN1_OBJECT *b);
25 ASN1_OBJECT * OBJ_dup(const ASN1_OBJECT *o);
26
27 int OBJ_create(const char *oid,const char *sn,const char *ln);
28 void OBJ_cleanup(void);
29
30=head1 DESCRIPTION
31
32The ASN1 object utility functions process ASN1_OBJECT structures which are
33a representation of the ASN1 OBJECT IDENTIFIER (OID) type.
34
35OBJ_nid2obj(), OBJ_nid2ln() and OBJ_nid2sn() convert the NID B<n> to
36an ASN1_OBJECT structure, its long name and its short name respectively,
37or B<NULL> is an error occurred.
38
39OBJ_obj2nid(), OBJ_ln2nid(), OBJ_sn2nid() return the corresponding NID
40for the object B<o>, the long name <ln> or the short name <sn> respectively
41or NID_undef if an error occurred.
42
43OBJ_txt2nid() returns NID corresponding to text string <s>. B<s> can be
44a long name, a short name or the numerical respresentation of an object.
45
46OBJ_txt2obj() converts the text string B<s> into an ASN1_OBJECT structure.
47If B<no_name> is 0 then long names and short names will be interpreted
48as well as numerical forms. If B<no_name> is 1 only the numerical form
49is acceptable.
50
51OBJ_obj2txt() converts the B<ASN1_OBJECT> B<a> into a textual representation.
52The representation is written as a null terminated string to B<buf>
53at most B<buf_len> bytes are written, truncating the result if necessary.
54The total amount of space required is returned. If B<no_name> is 0 then
55if the object has a long or short name then that will be used, otherwise
56the numerical form will be used. If B<no_name> is 1 then the numerical
57form will always be used.
58
59OBJ_cmp() compares B<a> to B<b>. If the two are identical 0 is returned.
60
61OBJ_dup() returns a copy of B<o>.
62
63OBJ_create() adds a new object to the internal table. B<oid> is the
64numerical form of the object, B<sn> the short name and B<ln> the
65long name. A new NID is returned for the created object.
66
67OBJ_cleanup() cleans up OpenSSLs internal object table: this should
68be called before an application exits if any new objects were added
69using OBJ_create().
70
71=head1 NOTES
72
73Objects in OpenSSL can have a short name, a long name and a numerical
74identifier (NID) associated with them. A standard set of objects is
75represented in an internal table. The appropriate values are defined
76in the header file B<objects.h>.
77
78For example the OID for commonName has the following definitions:
79
80 #define SN_commonName "CN"
81 #define LN_commonName "commonName"
82 #define NID_commonName 13
83
84New objects can be added by calling OBJ_create().
85
86Table objects have certain advantages over other objects: for example
87their NIDs can be used in a C language switch statement. They are
88also static constant structures which are shared: that is there
89is only a single constant structure for each table object.
90
91Objects which are not in the table have the NID value NID_undef.
92
93Objects do not need to be in the internal tables to be processed,
94the functions OBJ_txt2obj() and OBJ_obj2txt() can process the numerical
95form of an OID.
96
97=head1 EXAMPLES
98
99Create an object for B<commonName>:
100
101 ASN1_OBJECT *o;
102 o = OBJ_nid2obj(NID_commonName);
103
104Check if an object is B<commonName>
105
106 if (OBJ_obj2nid(obj) == NID_commonName)
107 /* Do something */
108
109Create a new NID and initialize an object from it:
110
111 int new_nid;
112 ASN1_OBJECT *obj;
113 new_nid = OBJ_create("1.2.3.4", "NewOID", "New Object Identifier");
114
115 obj = OBJ_nid2obj(new_nid);
116
117Create a new object directly:
118
119 obj = OBJ_txt2obj("1.2.3.4", 1);
120
121=head1 BUGS
122
123OBJ_obj2txt() is awkward and messy to use: it doesn't follow the
124convention of other OpenSSL functions where the buffer can be set
125to B<NULL> to determine the amount of data that should be written.
126Instead B<buf> must point to a valid buffer and B<buf_len> should
127be set to a positive value. A buffer length of 80 should be more
128than enough to handle any OID encountered in practice.
129
130=head1 RETURN VALUES
131
132OBJ_nid2obj() returns an B<ASN1_OBJECT> structure or B<NULL> is an
133error occurred.
134
135OBJ_nid2ln() and OBJ_nid2sn() returns a valid string or B<NULL>
136on error.
137
138OBJ_obj2nid(), OBJ_ln2nid(), OBJ_sn2nid() and OBJ_txt2nid() return
139a NID or B<NID_undef> on error.
140
141=head1 SEE ALSO
142
143L<ERR_get_error(3)|ERR_get_error(3)>
144
145=head1 HISTORY
146
147TBA
148
149=cut
diff --git a/src/lib/libssl/src/doc/crypto/PKCS12_create.pod b/src/lib/libssl/src/doc/crypto/PKCS12_create.pod
new file mode 100644
index 0000000000..48f3bb8cb8
--- /dev/null
+++ b/src/lib/libssl/src/doc/crypto/PKCS12_create.pod
@@ -0,0 +1,57 @@
1=pod
2
3=head1 NAME
4
5PKCS12_create - create a PKCS#12 structure
6
7=head1 SYNOPSIS
8
9 #include <openssl/pkcs12.h>
10
11 PKCS12 *PKCS12_create(char *pass, char *name, EVP_PKEY *pkey, X509 *cert, STACK_OF(X509) *ca,
12 int nid_key, int nid_cert, int iter, int mac_iter, int keytype);
13
14=head1 DESCRIPTION
15
16PKCS12_create() creates a PKCS#12 structure.
17
18B<pass> is the passphrase to use. B<name> is the B<friendlyName> to use for
19the supplied certifictate and key. B<pkey> is the private key to include in
20the structure and B<cert> its corresponding certificates. B<ca>, if not B<NULL>
21is an optional set of certificates to also include in the structure.
22
23B<nid_key> and B<nid_cert> are the encryption algorithms that should be used
24for the key and certificate respectively. B<iter> is the encryption algorithm
25iteration count to use and B<mac_iter> is the MAC iteration count to use.
26B<keytype> is the type of key.
27
28=head1 NOTES
29
30The parameters B<nid_key>, B<nid_cert>, B<iter>, B<mac_iter> and B<keytype>
31can all be set to zero and sensible defaults will be used.
32
33These defaults are: 40 bit RC2 encryption for certificates, triple DES
34encryption for private keys, a key iteration count of PKCS12_DEFAULT_ITER
35(currently 2048) and a MAC iteration count of 1.
36
37The default MAC iteration count is 1 in order to retain compatibility with
38old software which did not interpret MAC iteration counts. If such compatibility
39is not required then B<mac_iter> should be set to PKCS12_DEFAULT_ITER.
40
41B<keytype> adds a flag to the store private key. This is a non standard extension
42that is only currently interpreted by MSIE. If set to zero the flag is omitted,
43if set to B<KEY_SIG> the key can be used for signing only, if set to B<KEY_EX>
44it can be used for signing and encryption. This option was useful for old
45export grade software which could use signing only keys of arbitrary size but
46had restrictions on the permissible sizes of keys which could be used for
47encryption.
48
49=head1 SEE ALSO
50
51L<d2i_PKCS12(3)|d2i_PKCS12(3)>
52
53=head1 HISTORY
54
55PKCS12_create was added in OpenSSL 0.9.3
56
57=cut
diff --git a/src/lib/libssl/src/doc/crypto/PKCS12_parse.pod b/src/lib/libssl/src/doc/crypto/PKCS12_parse.pod
new file mode 100644
index 0000000000..51344f883a
--- /dev/null
+++ b/src/lib/libssl/src/doc/crypto/PKCS12_parse.pod
@@ -0,0 +1,50 @@
1=pod
2
3=head1 NAME
4
5PKCS12_parse - parse a PKCS#12 structure
6
7=head1 SYNOPSIS
8
9 #include <openssl/pkcs12.h>
10
11int PKCS12_parse(PKCS12 *p12, const char *pass, EVP_PKEY **pkey, X509 **cert, STACK_OF(X509) **ca);
12
13=head1 DESCRIPTION
14
15PKCS12_parse() parses a PKCS12 structure.
16
17B<p12> is the B<PKCS12> structure to parse. B<pass> is the passphrase to use.
18If successful the private key will be written to B<*pkey>, the corresponding
19certificate to B<*cert> and any additional certificates to B<*ca>.
20
21=head1 NOTES
22
23The parameters B<pkey> and B<cert> cannot be B<NULL>. B<ca> can be <NULL>
24in which case additional certificates will be discarded. B<*ca> can also
25be a valid STACK in which case additional certificates are appended to
26B<*ca>. If B<*ca> is B<NULL> a new STACK will be allocated.
27
28The B<friendlyName> and B<localKeyID> attributes (if present) on each certificate
29will be stored in the B<alias> and B<keyid> attributes of the B<X509> structure.
30
31=head1 BUGS
32
33Only a single private key and corresponding certificate is returned by this function.
34More complex PKCS#12 files with multiple private keys will only return the first
35match.
36
37Only B<friendlyName> and B<localKeyID> attributes are currently stored in certificates.
38Other attributes are discarded.
39
40Attributes currently cannot be store in the private key B<EVP_PKEY> structure.
41
42=head1 SEE ALSO
43
44L<d2i_PKCS12(3)|d2i_PKCS12(3)>
45
46=head1 HISTORY
47
48PKCS12_parse was added in OpenSSL 0.9.3
49
50=cut
diff --git a/src/lib/libssl/src/doc/crypto/PKCS7_decrypt.pod b/src/lib/libssl/src/doc/crypto/PKCS7_decrypt.pod
new file mode 100644
index 0000000000..b0ca067b89
--- /dev/null
+++ b/src/lib/libssl/src/doc/crypto/PKCS7_decrypt.pod
@@ -0,0 +1,53 @@
1=pod
2
3=head1 NAME
4
5PKCS7_decrypt - decrypt content from a PKCS#7 envelopedData structure
6
7=head1 SYNOPSIS
8
9int PKCS7_decrypt(PKCS7 *p7, EVP_PKEY *pkey, X509 *cert, BIO *data, int flags);
10
11=head1 DESCRIPTION
12
13PKCS7_decrypt() extracts and decrypts the content from a PKCS#7 envelopedData
14structure. B<pkey> is the private key of the recipient, B<cert> is the
15recipients certificate, B<data> is a BIO to write the content to and
16B<flags> is an optional set of flags.
17
18=head1 NOTES
19
20OpenSSL_add_all_algorithms() (or equivalent) should be called before using this
21function or errors about unknown algorithms will occur.
22
23Although the recipients certificate is not needed to decrypt the data it is needed
24to locate the appropriate (of possible several) recipients in the PKCS#7 structure.
25
26The following flags can be passed in the B<flags> parameter.
27
28If the B<PKCS7_TEXT> flag is set MIME headers for type B<text/plain> are deleted
29from the content. If the content is not of type B<text/plain> then an error is
30returned.
31
32=head1 RETURN VALUES
33
34PKCS7_decrypt() returns either 1 for success or 0 for failure.
35The error can be obtained from ERR_get_error(3)
36
37=head1 BUGS
38
39PKCS7_decrypt() must be passed the correct recipient key and certificate. It would
40be better if it could look up the correct key and certificate from a database.
41
42The lack of single pass processing and need to hold all data in memory as
43mentioned in PKCS7_sign() also applies to PKCS7_verify().
44
45=head1 SEE ALSO
46
47L<ERR_get_error(3)|ERR_get_error(3)>, L<PKCS7_encrypt(3)|PKCS7_encrypt(3)>
48
49=head1 HISTORY
50
51PKCS7_decrypt() was added to OpenSSL 0.9.5
52
53=cut
diff --git a/src/lib/libssl/src/doc/crypto/PKCS7_encrypt.pod b/src/lib/libssl/src/doc/crypto/PKCS7_encrypt.pod
new file mode 100644
index 0000000000..1a507b22a2
--- /dev/null
+++ b/src/lib/libssl/src/doc/crypto/PKCS7_encrypt.pod
@@ -0,0 +1,65 @@
1=pod
2
3=head1 NAME
4
5PKCS7_encrypt - create a PKCS#7 envelopedData structure
6
7=head1 SYNOPSIS
8
9PKCS7 *PKCS7_encrypt(STACK_OF(X509) *certs, BIO *in, const EVP_CIPHER *cipher, int flags);
10
11=head1 DESCRIPTION
12
13PKCS7_encrypt() creates and returns a PKCS#7 envelopedData structure. B<certs>
14is a list of recipient certificates. B<in> is the content to be encrypted.
15B<cipher> is the symmetric cipher to use. B<flags> is an optional set of flags.
16
17=head1 NOTES
18
19Only RSA keys are supported in PKCS#7 and envelopedData so the recipient certificates
20supplied to this function must all contain RSA public keys, though they do not have to
21be signed using the RSA algorithm.
22
23EVP_des_ede3_cbc() (triple DES) is the algorithm of choice for S/MIME use because
24most clients will support it.
25
26Some old "export grade" clients may only support weak encryption using 40 or 64 bit
27RC2. These can be used by passing EVP_rc2_40_cbc() and EVP_rc2_64_cbc() respectively.
28
29The algorithm passed in the B<cipher> parameter must support ASN1 encoding of its
30parameters.
31
32Many browsers implement a "sign and encrypt" option which is simply an S/MIME
33envelopedData containing an S/MIME signed message. This can be readily produced
34by storing the S/MIME signed message in a memory BIO and passing it to
35PKCS7_encrypt().
36
37The following flags can be passed in the B<flags> parameter.
38
39If the B<PKCS7_TEXT> flag is set MIME headers for type B<text/plain> are prepended
40to the data.
41
42Normally the supplied content is translated into MIME canonical format (as required
43by the S/MIME specifications) if B<PKCS7_BINARY> is set no translation occurs. This
44option should be used if the supplied data is in binary format otherwise the translation
45will corrupt it. If B<PKCS7_BINARY> is set then B<PKCS7_TEXT> is ignored.
46
47=head1 RETURN VALUES
48
49PKCS7_encrypt() returns either a valid PKCS7 structure or NULL if an error occurred.
50The error can be obtained from ERR_get_error(3).
51
52=head1 BUGS
53
54The lack of single pass processing and need to hold all data in memory as
55mentioned in PKCS7_sign() also applies to PKCS7_verify().
56
57=head1 SEE ALSO
58
59L<ERR_get_error(3)|ERR_get_error(3)>, L<PKCS7_decrypt(3)|PKCS7_decrypt(3)>
60
61=head1 HISTORY
62
63PKCS7_decrypt() was added to OpenSSL 0.9.5
64
65=cut
diff --git a/src/lib/libssl/src/doc/crypto/PKCS7_sign.pod b/src/lib/libssl/src/doc/crypto/PKCS7_sign.pod
new file mode 100644
index 0000000000..fc7e649b34
--- /dev/null
+++ b/src/lib/libssl/src/doc/crypto/PKCS7_sign.pod
@@ -0,0 +1,85 @@
1=pod
2
3=head1 NAME
4
5PKCS7_sign - create a PKCS#7 signedData structure
6
7=head1 SYNOPSIS
8
9PKCS7 *PKCS7_sign(X509 *signcert, EVP_PKEY *pkey, STACK_OF(X509) *certs, BIO *data, int flags);
10
11=head1 DESCRIPTION
12
13PKCS7_sign() creates and returns a PKCS#7 signedData structure. B<signcert>
14is the certificate to sign with, B<pkey> is the corresponsding private key.
15B<certs> is an optional additional set of certificates to include in the
16PKCS#7 structure (for example any intermediate CAs in the chain).
17
18The data to be signed is read from BIO B<data>.
19
20B<flags> is an optional set of flags.
21
22=head1 NOTES
23
24Any of the following flags (ored together) can be passed in the B<flags> parameter.
25
26Many S/MIME clients expect the signed content to include valid MIME headers. If
27the B<PKCS7_TEXT> flag is set MIME headers for type B<text/plain> are prepended
28to the data.
29
30If B<PKCS7_NOCERTS> is set the signer's certificate will not be included in the
31PKCS7 structure, the signer's certificate must still be supplied in the B<signcert>
32parameter though. This can reduce the size of the signature if the signers certificate
33can be obtained by other means: for example a previously signed message.
34
35The data being signed is included in the PKCS7 structure, unless B<PKCS7_DETACHED>
36is set in which case it is omitted. This is used for PKCS7 detached signatures
37which are used in S/MIME plaintext signed messages for example.
38
39Normally the supplied content is translated into MIME canonical format (as required
40by the S/MIME specifications) if B<PKCS7_BINARY> is set no translation occurs. This
41option should be used if the supplied data is in binary format otherwise the translation
42will corrupt it.
43
44The signedData structure includes several PKCS#7 autenticatedAttributes including
45the signing time, the PKCS#7 content type and the supported list of ciphers in
46an SMIMECapabilities attribute. If B<PKCS7_NOATTR> is set then no authenticatedAttributes
47will be used. If B<PKCS7_NOSMIMECAP> is set then just the SMIMECapabilities are
48omitted.
49
50If present the SMIMECapabilities attribute indicates support for the following
51algorithms: triple DES, 128 bit RC2, 64 bit RC2, DES and 40 bit RC2. If any
52of these algorithms is disabled then it will not be included.
53
54=head1 BUGS
55
56PKCS7_sign() is somewhat limited. It does not support multiple signers, some
57advanced attributes such as counter signatures are not supported.
58
59The SHA1 digest algorithm is currently always used.
60
61When the signed data is not detached it will be stored in memory within the
62B<PKCS7> structure. This effectively limits the size of messages which can be
63signed due to memory restraints. There should be a way to sign data without
64having to hold it all in memory, this would however require fairly major
65revisions of the OpenSSL ASN1 code.
66
67Clear text signing does not store the content in memory but the way PKCS7_sign()
68operates means that two passes of the data must typically be made: one to compute
69the signatures and a second to output the data along with the signature. There
70should be a way to process the data with only a single pass.
71
72=head1 RETURN VALUES
73
74PKCS7_sign() returns either a valid PKCS7 structure or NULL if an error occurred.
75The error can be obtained from ERR_get_error(3).
76
77=head1 SEE ALSO
78
79L<ERR_get_error(3)|ERR_get_error(3)>, L<PKCS7_verify(3)|PKCS7_verify(3)>
80
81=head1 HISTORY
82
83PKCS7_sign() was added to OpenSSL 0.9.5
84
85=cut
diff --git a/src/lib/libssl/src/doc/crypto/PKCS7_verify.pod b/src/lib/libssl/src/doc/crypto/PKCS7_verify.pod
new file mode 100644
index 0000000000..07c9fdad40
--- /dev/null
+++ b/src/lib/libssl/src/doc/crypto/PKCS7_verify.pod
@@ -0,0 +1,116 @@
1=pod
2
3=head1 NAME
4
5PKCS7_verify - verify a PKCS#7 signedData structure
6
7=head1 SYNOPSIS
8
9int PKCS7_verify(PKCS7 *p7, STACK_OF(X509) *certs, X509_STORE *store, BIO *indata, BIO *out, int flags);
10
11int PKCS7_get0_signers(PKCS7 *p7, STACK_OF(X509) *certs, int flags);
12
13=head1 DESCRIPTION
14
15PKCS7_verify() verifies a PKCS#7 signedData structure. B<p7> is the PKCS7
16structure to verify. B<certs> is a set of certificates in which to search for
17the signer's certificate. B<store> is a trusted certficate store (used for
18chain verification). B<indata> is the signed data if the content is not
19present in B<p7> (that is it is detached). The content is written to B<out>
20if it is not NULL.
21
22B<flags> is an optional set of flags, which can be used to modify the verify
23operation.
24
25PKCS7_get0_signers() retrieves the signer's certificates from B<p7>, it does
26B<not> check their validity or whether any signatures are valid. The B<certs>
27and B<flags> parameters have the same meanings as in PKCS7_verify().
28
29=head1 VERIFY PROCESS
30
31Normally the verify process proceeds as follows.
32
33Initially some sanity checks are performed on B<p7>. The type of B<p7> must
34be signedData. There must be at least one signature on the data and if
35the content is detached B<indata> cannot be B<NULL>.
36
37An attempt is made to locate all the signer's certificates, first looking in
38the B<certs> parameter (if it is not B<NULL>) and then looking in any certificates
39contained in the B<p7> structure itself. If any signer's certificates cannot be
40located the operation fails.
41
42Each signer's certificate is chain verified using the B<smimesign> purpose and
43the supplied trusted certificate store. Any internal certificates in the message
44are used as untrusted CAs. If any chain verify fails an error code is returned.
45
46Finally the signed content is read (and written to B<out> is it is not NULL) and
47the signature's checked.
48
49If all signature's verify correctly then the function is successful.
50
51Any of the following flags (ored together) can be passed in the B<flags> parameter
52to change the default verify behaviour. Only the flag B<PKCS7_NOINTERN> is
53meaningful to PKCS7_get0_signers().
54
55If B<PKCS7_NOINTERN> is set the certificates in the message itself are not
56searched when locating the signer's certificate. This means that all the signers
57certificates must be in the B<certs> parameter.
58
59If the B<PKCS7_TEXT> flag is set MIME headers for type B<text/plain> are deleted
60from the content. If the content is not of type B<text/plain> then an error is
61returned.
62
63If B<PKCS7_NOVERIFY> is set the signer's certificates are not chain verified.
64
65If B<PKCS7_NOCHAIN> is set then the certificates contained in the message are
66not used as untrusted CAs. This means that the whole verify chain (apart from
67the signer's certificate) must be contained in the trusted store.
68
69If B<PKCS7_NOSIGS> is set then the signatures on the data are not checked.
70
71=head1 NOTES
72
73One application of B<PKCS7_NOINTERN> is to only accept messages signed by
74a small number of certificates. The acceptable certificates would be passed
75in the B<certs> parameter. In this case if the signer is not one of the
76certificates supplied in B<certs> then the verify will fail because the
77signer cannot be found.
78
79Care should be taken when modifying the default verify behaviour, for example
80setting B<PKCS7_NOVERIFY|PKCS7_NOSIGS> will totally disable all verification
81and any signed message will be considered valid. This combination is however
82useful if one merely wishes to write the content to B<out> and its validity
83is not considered important.
84
85Chain verification should arguably be performed using the signing time rather
86than the current time. However since the signing time is supplied by the
87signer it cannot be trusted without additional evidence (such as a trusted
88timestamp).
89
90=head1 RETURN VALUES
91
92PKCS7_verify() returns 1 for a successful verification and zero or a negative
93value if an error occurs.
94
95PKCS7_get0_signers() returns all signers or B<NULL> if an error occurred.
96
97The error can be obtained from L<ERR_get_error(3)|ERR_get_error(3)>
98
99=head1 BUGS
100
101The trusted certificate store is not searched for the signers certificate,
102this is primarily due to the inadequacies of the current B<X509_STORE>
103functionality.
104
105The lack of single pass processing and need to hold all data in memory as
106mentioned in PKCS7_sign() also applies to PKCS7_verify().
107
108=head1 SEE ALSO
109
110L<ERR_get_error(3)|ERR_get_error(3)>, L<PKCS7_sign(3)|PKCS7_sign(3)>
111
112=head1 HISTORY
113
114PKCS7_verify() was added to OpenSSL 0.9.5
115
116=cut
diff --git a/src/lib/libssl/src/doc/crypto/RAND_bytes.pod b/src/lib/libssl/src/doc/crypto/RAND_bytes.pod
index b6ebd50527..ce6329ce54 100644
--- a/src/lib/libssl/src/doc/crypto/RAND_bytes.pod
+++ b/src/lib/libssl/src/doc/crypto/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(3)|err(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/libssl/src/doc/crypto/RSA_check_key.pod b/src/lib/libssl/src/doc/crypto/RSA_check_key.pod
index 3d824a07f5..a5198f3db5 100644
--- a/src/lib/libssl/src/doc/crypto/RSA_check_key.pod
+++ b/src/lib/libssl/src/doc/crypto/RSA_check_key.pod
@@ -58,7 +58,7 @@ provide their own verifiers.
58 58
59=head1 SEE ALSO 59=head1 SEE ALSO
60 60
61L<rsa(3)|rsa(3)>, L<err(3)|err(3)> 61L<rsa(3)|rsa(3)>, L<ERR_get_error(3)|ERR_get_error(3)>
62 62
63=head1 HISTORY 63=head1 HISTORY
64 64
diff --git a/src/lib/libssl/src/doc/crypto/RSA_generate_key.pod b/src/lib/libssl/src/doc/crypto/RSA_generate_key.pod
index 8714f7179d..52dbb14a53 100644
--- a/src/lib/libssl/src/doc/crypto/RSA_generate_key.pod
+++ b/src/lib/libssl/src/doc/crypto/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(3)|err(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/libssl/src/doc/crypto/RSA_new.pod b/src/lib/libssl/src/doc/crypto/RSA_new.pod
index f0d996c40f..3d15b92824 100644
--- a/src/lib/libssl/src/doc/crypto/RSA_new.pod
+++ b/src/lib/libssl/src/doc/crypto/RSA_new.pod
@@ -30,7 +30,8 @@ RSA_free() returns no value.
30 30
31=head1 SEE ALSO 31=head1 SEE ALSO
32 32
33L<err(3)|err(3)>, L<rsa(3)|rsa(3)>, L<RSA_generate_key(3)|RSA_generate_key(3)>, 33L<ERR_get_error(3)|ERR_get_error(3)>, L<rsa(3)|rsa(3)>,
34L<RSA_generate_key(3)|RSA_generate_key(3)>,
34L<RSA_new_method(3)|RSA_new_method(3)> 35L<RSA_new_method(3)|RSA_new_method(3)>
35 36
36=head1 HISTORY 37=head1 HISTORY
diff --git a/src/lib/libssl/src/doc/crypto/RSA_print.pod b/src/lib/libssl/src/doc/crypto/RSA_print.pod
index 67876facc5..e28d107d1c 100644
--- a/src/lib/libssl/src/doc/crypto/RSA_print.pod
+++ b/src/lib/libssl/src/doc/crypto/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/libssl/src/doc/crypto/RSA_private_encrypt.pod b/src/lib/libssl/src/doc/crypto/RSA_private_encrypt.pod
index 6861a98a10..746a80c79e 100644
--- a/src/lib/libssl/src/doc/crypto/RSA_private_encrypt.pod
+++ b/src/lib/libssl/src/doc/crypto/RSA_private_encrypt.pod
@@ -59,7 +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(3)|err(3)>, L<rsa(3)|rsa(3)>, L<RSA_sign(3)|RSA_sign(3)>, L<RSA_verify(3)|RSA_verify(3)> 62L<ERR_get_error(3)|ERR_get_error(3)>, L<rsa(3)|rsa(3)>,
63L<RSA_sign(3)|RSA_sign(3)>, L<RSA_verify(3)|RSA_verify(3)>
63 64
64=head1 HISTORY 65=head1 HISTORY
65 66
diff --git a/src/lib/libssl/src/doc/crypto/RSA_public_encrypt.pod b/src/lib/libssl/src/doc/crypto/RSA_public_encrypt.pod
index e20dfcb551..d53e19d2b7 100644
--- a/src/lib/libssl/src/doc/crypto/RSA_public_encrypt.pod
+++ b/src/lib/libssl/src/doc/crypto/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(3)|err(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/libssl/src/doc/crypto/RSA_set_method.pod b/src/lib/libssl/src/doc/crypto/RSA_set_method.pod
index 0687c2242a..0a305f6b14 100644
--- a/src/lib/libssl/src/doc/crypto/RSA_set_method.pod
+++ b/src/lib/libssl/src/doc/crypto/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/libssl/src/doc/crypto/RSA_sign.pod b/src/lib/libssl/src/doc/crypto/RSA_sign.pod
index f0bf6eea1b..71688a665e 100644
--- a/src/lib/libssl/src/doc/crypto/RSA_sign.pod
+++ b/src/lib/libssl/src/doc/crypto/RSA_sign.pod
@@ -50,8 +50,8 @@ SSL, PKCS #1 v2.0
50 50
51=head1 SEE ALSO 51=head1 SEE ALSO
52 52
53L<err(3)|err(3)>, L<objects(3)|objects(3)>, L<rsa(3)|rsa(3)>, 53L<ERR_get_error(3)|ERR_get_error(3)>, L<objects(3)|objects(3)>,
54L<RSA_private_encrypt(3)|RSA_private_encrypt(3)>, 54L<rsa(3)|rsa(3)>, L<RSA_private_encrypt(3)|RSA_private_encrypt(3)>,
55L<RSA_public_decrypt(3)|RSA_public_decrypt(3)> 55L<RSA_public_decrypt(3)|RSA_public_decrypt(3)>
56 56
57=head1 HISTORY 57=head1 HISTORY
diff --git a/src/lib/libssl/src/doc/crypto/RSA_sign_ASN1_OCTET_STRING.pod b/src/lib/libssl/src/doc/crypto/RSA_sign_ASN1_OCTET_STRING.pod
index df9ceb339a..e70380bbfc 100644
--- a/src/lib/libssl/src/doc/crypto/RSA_sign_ASN1_OCTET_STRING.pod
+++ b/src/lib/libssl/src/doc/crypto/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(3)|err(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/libssl/src/doc/crypto/SMIME_read_PKCS7.pod b/src/lib/libssl/src/doc/crypto/SMIME_read_PKCS7.pod
new file mode 100644
index 0000000000..ffafa37887
--- /dev/null
+++ b/src/lib/libssl/src/doc/crypto/SMIME_read_PKCS7.pod
@@ -0,0 +1,71 @@
1=pod
2
3=head1 NAME
4
5SMIME_read_PKCS7 - parse S/MIME message.
6
7=head1 SYNOPSIS
8
9PKCS7 *SMIME_read_PKCS7(BIO *in, BIO **bcont);
10
11=head1 DESCRIPTION
12
13SMIME_read_PKCS7() parses a message in S/MIME format.
14
15B<in> is a BIO to read the message from.
16
17If cleartext signing is used then the content is saved in
18a memory bio which is written to B<*bcont>, otherwise
19B<*bcont> is set to B<NULL>.
20
21The parsed PKCS#7 structure is returned or B<NULL> if an
22error occurred.
23
24=head1 NOTES
25
26If B<*bcont> is not B<NULL> then the message is clear text
27signed. B<*bcont> can then be passed to PKCS7_verify() with
28the B<PKCS7_DETACHED> flag set.
29
30Otherwise the type of the returned structure can be determined
31using PKCS7_type().
32
33To support future functionality if B<bcont> is not B<NULL>
34B<*bcont> should be initialized to B<NULL>. For example:
35
36 BIO *cont = NULL;
37 PKCS7 *p7;
38
39 p7 = SMIME_read_PKCS7(in, &cont);
40
41=head1 BUGS
42
43The MIME parser used by SMIME_read_PKCS7() is somewhat primitive.
44While it will handle most S/MIME messages more complex compound
45formats may not work.
46
47The parser assumes that the PKCS7 structure is always base64
48encoded and will not handle the case where it is in binary format
49or uses quoted printable format.
50
51The use of a memory BIO to hold the signed content limits the size
52of message which can be processed due to memory restraints: a
53streaming single pass option should be available.
54
55=head1 RETURN VALUES
56
57SMIME_read_PKCS7() returns a valid B<PKCS7> structure or B<NULL>
58is an error occurred. The error can be obtained from ERR_get_error(3).
59
60=head1 SEE ALSO
61
62L<ERR_get_error(3)|ERR_get_error(3)>, L<PKCS7_type(3)|PKCS7_type(3)>
63L<SMIME_read_PKCS7(3)|SMIME_read_PKCS7(3)>, L<PKCS7_sign(3)|PKCS7_sign(3)>,
64L<PKCS7_verify(3)|PKCS7_verify(3)>, L<PKCS7_encrypt(3)|PKCS7_encrypt(3)>
65L<PKCS7_decrypt(3)|PKCS7_decrypt(3)>
66
67=head1 HISTORY
68
69SMIME_read_PKCS7() was added to OpenSSL 0.9.5
70
71=cut
diff --git a/src/lib/libssl/src/doc/crypto/SMIME_write_PKCS7.pod b/src/lib/libssl/src/doc/crypto/SMIME_write_PKCS7.pod
new file mode 100644
index 0000000000..2cfad2e049
--- /dev/null
+++ b/src/lib/libssl/src/doc/crypto/SMIME_write_PKCS7.pod
@@ -0,0 +1,59 @@
1=pod
2
3=head1 NAME
4
5SMIME_write_PKCS7 - convert PKCS#7 structure to S/MIME format.
6
7=head1 SYNOPSIS
8
9int SMIME_write_PKCS7(BIO *out, PKCS7 *p7, BIO *data, int flags);
10
11=head1 DESCRIPTION
12
13SMIME_write_PKCS7() adds the appropriate MIME headers to a PKCS#7
14structure to produce an S/MIME message.
15
16B<out> is the BIO to write the data to. B<p7> is the appropriate
17B<PKCS7> structure. If cleartext signing (B<multipart/signed>) is
18being used then the signed data must be supplied in the B<data>
19argument. B<flags> is an optional set of flags.
20
21=head1 NOTES
22
23The following flags can be passed in the B<flags> parameter.
24
25If B<PKCS7_DETACHED> is set then cleartext signing will be used,
26this option only makes sense for signedData where B<PKCS7_DETACHED>
27is also set when PKCS7_sign() is also called.
28
29If the B<PKCS7_TEXT> flag is set MIME headers for type B<text/plain>
30are added to the content, this only makes sense if B<PKCS7_DETACHED>
31is also set.
32
33If cleartext signing is being used then the data must be read twice:
34once to compute the signature in PKCS7_sign() and once to output the
35S/MIME message.
36
37=head1 BUGS
38
39SMIME_write_PKCS7() always base64 encodes PKCS#7 structures, there
40should be an option to disable this.
41
42There should really be a way to produce cleartext signing using only
43a single pass of the data.
44
45=head1 RETURN VALUES
46
47SMIME_write_PKCS7() returns 1 for success or 0 for failure.
48
49=head1 SEE ALSO
50
51L<ERR_get_error(3)|ERR_get_error(3)>, L<PKCS7_sign(3)|PKCS7_sign(3)>,
52L<PKCS7_verify(3)|PKCS7_verify(3)>, L<PKCS7_encrypt(3)|PKCS7_encrypt(3)>
53L<PKCS7_decrypt(3)|PKCS7_decrypt(3)>
54
55=head1 HISTORY
56
57SMIME_write_PKCS7() was added to OpenSSL 0.9.5
58
59=cut
diff --git a/src/lib/libssl/src/doc/crypto/X509_NAME_ENTRY_get_object.pod b/src/lib/libssl/src/doc/crypto/X509_NAME_ENTRY_get_object.pod
new file mode 100644
index 0000000000..d287c18564
--- /dev/null
+++ b/src/lib/libssl/src/doc/crypto/X509_NAME_ENTRY_get_object.pod
@@ -0,0 +1,72 @@
1=pod
2
3=head1 NAME
4
5X509_NAME_ENTRY_get_object, X509_NAME_ENTRY_get_data,
6X509_NAME_ENTRY_set_object, X509_NAME_ENTRY_set_data,
7X509_NAME_ENTRY_create_by_txt, X509_NAME_ENTRY_create_by_NID,
8X509_NAME_ENTRY_create_by_OBJ - X509_NAME_ENTRY utility functions
9
10=head1 SYNOPSIS
11
12ASN1_OBJECT * X509_NAME_ENTRY_get_object(X509_NAME_ENTRY *ne);
13ASN1_STRING * X509_NAME_ENTRY_get_data(X509_NAME_ENTRY *ne);
14
15int X509_NAME_ENTRY_set_object(X509_NAME_ENTRY *ne, ASN1_OBJECT *obj);
16int X509_NAME_ENTRY_set_data(X509_NAME_ENTRY *ne, int type, unsigned char *bytes, int len);
17
18X509_NAME_ENTRY *X509_NAME_ENTRY_create_by_txt(X509_NAME_ENTRY **ne, char *field, int type, unsigned char *bytes, int len);
19X509_NAME_ENTRY *X509_NAME_ENTRY_create_by_NID(X509_NAME_ENTRY **ne, int nid, int type,unsigned char *bytes, int len);
20X509_NAME_ENTRY *X509_NAME_ENTRY_create_by_OBJ(X509_NAME_ENTRY **ne, ASN1_OBJECT *obj, int type,unsigned char *bytes, int len);
21
22=head1 DESCRIPTION
23
24X509_NAME_ENTRY_get_object() retrieves the field name of B<ne> in
25and B<ASN1_OBJECT> structure.
26
27X509_NAME_ENTRY_get_data() retrieves the field value of B<ne> in
28and B<ASN1_STRING> structure.
29
30X509_NAME_ENTRY_set_object() sets the field name of B<ne> to B<obj>.
31
32X509_NAME_ENTRY_set_data() sets the field value of B<ne> to string type
33B<type> and value determined by B<bytes> and B<len>.
34
35X509_NAME_ENTRY_create_by_txt(), X509_NAME_ENTRY_create_by_NID()
36and X509_NAME_ENTRY_create_by_OBJ() create and return an
37B<X509_NAME_ENTRY> structure.
38
39=head1 NOTES
40
41X509_NAME_ENTRY_get_object() and X509_NAME_ENTRY_get_data() can be
42used to examine an B<X509_NAME_ENTRY> function as returned by
43X509_NAME_get_entry() for example.
44
45X509_NAME_ENTRY_create_by_txt(), X509_NAME_ENTRY_create_by_NID(),
46and X509_NAME_ENTRY_create_by_OBJ() create and return an
47
48X509_NAME_ENTRY_create_by_txt(), X509_NAME_ENTRY_create_by_OBJ(),
49X509_NAME_ENTRY_create_by_NID() and X509_NAME_ENTRY_set_data()
50are seldom used in practice because B<X509_NAME_ENTRY> structures
51are almost always part of B<X509_NAME> structures and the
52corresponding B<X509_NAME> functions are typically used to
53create and add new entries in a single operation.
54
55The arguments of these functions support similar options to the similarly
56named ones of the corresponding B<X509_NAME> functions such as
57X509_NAME_add_entry_by_txt(). So for example B<type> can be set to
58B<MBSTRING_ASC> but in the case of X509_set_data() the field name must be
59set first so the relevant field information can be looked up internally.
60
61=head1 RETURN VALUES
62
63=head1 SEE ALSO
64
65L<ERR_get_error(3)|ERR_get_error(3)>, L<d2i_X509_NAME(3)|d2i_X509_NAME(3)>,
66L<OBJ_nid2obj(3),OBJ_nid2obj(3)>
67
68=head1 HISTORY
69
70TBA
71
72=cut
diff --git a/src/lib/libssl/src/doc/crypto/X509_NAME_add_entry_by_txt.pod b/src/lib/libssl/src/doc/crypto/X509_NAME_add_entry_by_txt.pod
new file mode 100644
index 0000000000..4472a1c5cf
--- /dev/null
+++ b/src/lib/libssl/src/doc/crypto/X509_NAME_add_entry_by_txt.pod
@@ -0,0 +1,110 @@
1=pod
2
3=head1 NAME
4
5X509_NAME_add_entry_by_txt, X509_NAME_add_entry_by_OBJ, X509_NAME_add_entry_by_NID,
6X509_NAME_add_entry, X509_NAME_delete_entry - X509_NAME modification functions
7
8=head1 SYNOPSIS
9
10int X509_NAME_add_entry_by_txt(X509_NAME *name, char *field, int type, unsigned char *bytes, int len, int loc, int set);
11int X509_NAME_add_entry_by_OBJ(X509_NAME *name, ASN1_OBJECT *obj, int type, unsigned char *bytes, int len, int loc, int set);
12int X509_NAME_add_entry_by_NID(X509_NAME *name, int nid, int type, unsigned char *bytes, int len, int loc, int set);
13int X509_NAME_add_entry(X509_NAME *name,X509_NAME_ENTRY *ne, int loc, int set);
14X509_NAME_ENTRY *X509_NAME_delete_entry(X509_NAME *name, int loc);
15
16=head1 DESCRIPTION
17
18X509_NAME_add_entry_by_txt(), X509_NAME_add_entry_by_OBJ() and
19X509_NAME_add_entry_by_NID() add a field whose name is defined
20by a string B<field>, an object B<obj> or a NID B<nid> respectively.
21The field value to be added is in B<bytes> of length B<len>. If
22B<len> is -1 then the field length is calculated internally using
23strlen(bytes).
24
25The type of field is determined by B<type> which can either be a
26definition of the type of B<bytes> (such as B<MBSTRING_ASC>) or a
27standard ASN1 type (such as B<V_ASN1_IA5STRING>). The new entry is
28added to a position determined by B<loc> and B<set>.
29
30X509_NAME_add_entry() adds a copy of B<X509_NAME_ENTRY> structure B<ne>
31to B<name>. The new entry is added to a position determined by B<loc>
32and B<set>. Since a copy of B<ne> is added B<ne> must be freed up after
33the call.
34
35X509_NAME_delete_entry() deletes an entry from B<name> at position
36B<loc>. The deleted entry is returned and must be freed up.
37
38=head1 NOTES
39
40The use of string types such as B<MBSTRING_ASC> or B<MBSTRING_UTF8>
41is strongly recommened for the B<type> parameter. This allows the
42internal code to correctly determine the type of the field and to
43apply length checks according to the relevant standards. This is
44done using ASN1_STRING_set_by_NID().
45
46If instead an ASN1 type is used no checks are performed and the
47supplied data in B<bytes> is used directly.
48
49In X509_NAME_add_entry_by_txt() the B<field> string represents
50the field name using OBJ_txt2obj(field, 0).
51
52The B<loc> and B<set> parameters determine where a new entry should
53be added. For almost all applications B<loc> can be set to -1 and B<set>
54to 0. This adds a new entry to the end of B<name> as a single valued
55RelativeDistinguishedName (RDN).
56
57B<loc> actually determines the index where the new entry is inserted:
58if it is -1 it is appended.
59
60B<set> determines how the new type is added. If it is zero a
61new RDN is created.
62
63If B<set> is -1 or 1 it is added to the previous or next RDN
64structure respectively. This will then be a multivalued RDN:
65since multivalues RDNs are very seldom used B<set> is almost
66always set to zero.
67
68=head1 EXAMPLES
69
70Create an B<X509_NAME> structure:
71
72"C=UK, O=Disorganized Organization, CN=Joe Bloggs"
73
74 X509_NAME *nm;
75 nm = X509_NAME_new();
76 if (nm == NULL)
77 /* Some error */
78 if (!X509_NAME_add_entry_by_txt(nm, MBSTRING_ASC,
79 "C", "UK", -1, -1, 0))
80 /* Error */
81 if (!X509_NAME_add_entry_by_txt(nm, MBSTRING_ASC,
82 "O", "Disorganized Organization", -1, -1, 0))
83 /* Error */
84 if (!X509_NAME_add_entry_by_txt(nm, MBSTRING_ASC,
85 "CN", "Joe Bloggs", -1, -1, 0))
86 /* Error */
87
88=head1 RETURN VALUES
89
90X509_NAME_add_entry_by_txt(), X509_NAME_add_entry_by_OBJ(),
91X509_NAME_add_entry_by_NID() and X509_NAME_add_entry() return 1 for
92success of 0 if an error occurred.
93
94X509_NAME_delete_entry() returns either the deleted B<X509_NAME_ENTRY>
95structure of B<NULL> if an error occurred.
96
97=head1 BUGS
98
99B<type> can still be set to B<V_ASN1_APP_CHOOSE> to use a
100different algorithm to determine field types. Since this form does
101not understand multicharacter types, performs no length checks and
102can result in invalid field types its use is strongly discouraged.
103
104=head1 SEE ALSO
105
106L<ERR_get_error(3)|ERR_get_error(3)>, L<d2i_X509_NAME(3)|d2i_X509_NAME(3)>
107
108=head1 HISTORY
109
110=cut
diff --git a/src/lib/libssl/src/doc/crypto/X509_NAME_get_index_by_NID.pod b/src/lib/libssl/src/doc/crypto/X509_NAME_get_index_by_NID.pod
new file mode 100644
index 0000000000..333323d734
--- /dev/null
+++ b/src/lib/libssl/src/doc/crypto/X509_NAME_get_index_by_NID.pod
@@ -0,0 +1,106 @@
1=pod
2
3=head1 NAME
4
5X509_NAME_get_index_by_NID, X509_NAME_get_index_by_OBJ, X509_NAME_get_entry,
6X509_NAME_entry_count, X509_NAME_get_text_by_NID, X509_NAME_get_text_by_OBJ -
7X509_NAME lookup and enumeration functions
8
9=head1 SYNOPSIS
10
11int X509_NAME_get_index_by_NID(X509_NAME *name,int nid,int lastpos);
12int X509_NAME_get_index_by_OBJ(X509_NAME *name,ASN1_OBJECT *obj, int lastpos);
13
14int X509_NAME_entry_count(X509_NAME *name);
15X509_NAME_ENTRY *X509_NAME_get_entry(X509_NAME *name, int loc);
16
17int X509_NAME_get_text_by_NID(X509_NAME *name, int nid, char *buf,int len);
18int X509_NAME_get_text_by_OBJ(X509_NAME *name, ASN1_OBJECT *obj, char *buf,int len);
19
20=head1 DESCRIPTION
21
22These functions allow an B<X509_NAME> structure to be examined. The
23B<X509_NAME> structure is the same as the B<Name> type defined in
24RFC2459 (and elsewhere) and used for example in certificate subject
25and issuer names.
26
27X509_NAME_get_index_by_NID() and X509_NAME_get_index_by_OBJ() retrieve
28the next index matching B<nid> or B<obj> after B<lastpos>. B<lastpos>
29should initially be set to -1. If there are no more entries -1 is returned.
30
31X509_NAME_entry_count() returns the total number of entries in B<name>.
32
33X509_NAME_get_entry() retrieves the B<X509_NAME_ENTRY> from B<name>
34corresponding to index B<loc>. Acceptable values for B<loc> run from
350 to (X509_NAME_entry_count(name) - 1). The value returned is an
36internal pointer which must not be freed.
37
38X509_NAME_get_text_by_NID(), X509_NAME_get_text_by_OBJ() retrieve
39the "text" from the first entry in B<name> which matches B<nid> or
40B<obj>, if no such entry exists -1 is returned. At most B<len> bytes
41will be written and the text written to B<buf> will be null
42terminated. The length of the output string written is returned
43excluding the terminating null. If B<buf> is <NULL> then the amount
44of space needed in B<buf> (excluding the final null) is returned.
45
46=head1 NOTES
47
48X509_NAME_get_text_by_NID() and X509_NAME_get_text_by_OBJ() are
49legacy functions which have various limitations which make them
50of minimal use in practice. They can only find the first matching
51entry and will copy the contents of the field verbatim: this can
52be highly confusing if the target is a muticharacter string type
53like a BMPString or a UTF8String.
54
55For a more general solution X509_NAME_get_index_by_NID() or
56X509_NAME_get_index_by_OBJ() should be used followed by
57X509_NAME_get_entry() on any matching indices and then the
58various B<X509_NAME_ENTRY> utility functions on the result.
59
60=head1 EXAMPLES
61
62Process all entries:
63
64 int i;
65 X509_NAME_ENTRY *e;
66
67 for (i = 0; i < X509_NAME_entry_count(nm); i++)
68 {
69 e = X509_NAME_get_entry(nm, i);
70 /* Do something with e */
71 }
72
73Process all commonName entries:
74
75 int loc;
76 X509_NAME_ENTRY *e;
77
78 loc = -1;
79 for (;;)
80 {
81 lastpos = X509_NAME_get_index_by_NID(nm, NID_commonName, lastpos);
82 if (lastpos == -1)
83 break;
84 e = X509_NAME_get_entry(nm, lastpos);
85 /* Do something with e */
86 }
87
88=head1 RETURN VALUES
89
90X509_NAME_get_index_by_NID() and X509_NAME_get_index_by_OBJ()
91return the index of the next matching entry or -1 if not found.
92
93X509_NAME_entry_count() returns the total number of entries.
94
95X509_NAME_get_entry() returns an B<X509_NAME> pointer to the
96requested entry or B<NULL> if the index is invalid.
97
98=head1 SEE ALSO
99
100L<ERR_get_error(3)|ERR_get_error(3)>, L<d2i_X509_NAME(3)|d2i_X509_NAME(3)>
101
102=head1 HISTORY
103
104TBA
105
106=cut
diff --git a/src/lib/libssl/src/doc/crypto/X509_NAME_print_ex.pod b/src/lib/libssl/src/doc/crypto/X509_NAME_print_ex.pod
new file mode 100644
index 0000000000..907c04f684
--- /dev/null
+++ b/src/lib/libssl/src/doc/crypto/X509_NAME_print_ex.pod
@@ -0,0 +1,105 @@
1=pod
2
3=head1 NAME
4
5X509_NAME_print_ex, X509_NAME_print_ex_fp, X509_NAME_print,
6X509_NAME_oneline - X509_NAME printing routines.
7
8=head1 SYNOPSIS
9
10 #include <openssl/x509.h>
11
12 int X509_NAME_print_ex(BIO *out, X509_NAME *nm, int indent, unsigned long flags);
13 int X509_NAME_print_ex_fp(FILE *fp, X509_NAME *nm, int indent, unsigned long flags);
14 char * X509_NAME_oneline(X509_NAME *a,char *buf,int size);
15 int X509_NAME_print(BIO *bp, X509_NAME *name, int obase);
16
17=head1 DESCRIPTION
18
19X509_NAME_print_ex() prints a human readable version of B<nm> to BIO B<out>. Each
20line (for multiline formats) is indented by B<indent> spaces. The output format
21can be extensively customised by use of the B<flags> parameter.
22
23X509_NAME_print_ex_fp() is identical to X509_NAME_print_ex() except the output is
24written to FILE pointer B<fp>.
25
26X509_NAME_oneline() prints an ASCII version of B<a> to B<buf>. At most B<size>
27bytes will be written. If B<buf> is B<NULL> then a buffer is dynamically allocated
28and returned, otherwise B<buf> is returned.
29
30X509_NAME_print() prints out B<name> to B<bp> indenting each line by B<obase>
31characters. Multiple lines are used if the output (including indent) exceeds
3280 characters.
33
34=head1 NOTES
35
36The functions X509_NAME_oneline() and X509_NAME_print() are legacy functions which
37produce a non standard output form, they don't handle multi character fields and
38have various quirks and inconsistencies. Their use is strongly discouraged in new
39applications.
40
41Although there are a large number of possible flags for most purposes
42B<XN_FLAG_ONELINE>, B<XN_FLAG_MULTILINE> or B<XN_FLAG_RFC2253> will suffice.
43As noted on the L<ASN1_STRING_print_ex(3)|ASN1_STRING_print_ex(3)> manual page
44for UTF8 terminals the B<ASN1_STRFLAGS_ESC_MSB> should be unset: so for example
45B<XN_FLAG_ONELINE & ~ASN1_STRFLAGS_ESC_MSB> would be used.
46
47The complete set of the flags supported by X509_NAME_print_ex() is listed below.
48
49Several options can be ored together.
50
51The options B<XN_FLAG_SEP_COMMA_PLUS>, B<XN_FLAG_SEP_CPLUS_SPC>,
52B<XN_FLAG_SEP_SPLUS_SPC> and B<XN_FLAG_SEP_MULTILINE> determine the field separators
53to use. Two distinct separators are used between distinct RelativeDistinguishedName
54components and separate values in the same RDN for a multi-valued RDN. Multi-valued
55RDNs are currently very rare so the second separator will hardly ever be used.
56
57B<XN_FLAG_SEP_COMMA_PLUS> uses comma and plus as separators. B<XN_FLAG_SEP_CPLUS_SPC>
58uses comma and plus with spaces: this is more readable that plain comma and plus.
59B<XN_FLAG_SEP_SPLUS_SPC> uses spaced semicolon and plus. B<XN_FLAG_SEP_MULTILINE> uses
60spaced newline and plus respectively.
61
62If B<XN_FLAG_DN_REV> is set the whole DN is printed in reversed order.
63
64The fields B<XN_FLAG_FN_SN>, B<XN_FLAG_FN_LN>, B<XN_FLAG_FN_OID>,
65B<XN_FLAG_FN_NONE> determine how a field name is displayed. It will
66use the short name (e.g. CN) the long name (e.g. commonName) always
67use OID numerical form (normally OIDs are only used if the field name is not
68recognised) and no field name respectively.
69
70If B<XN_FLAG_SPC_EQ> is set then spaces will be placed around the '=' character
71separating field names and values.
72
73If B<XN_FLAG_DUMP_UNKNOWN_FIELDS> is set then the encoding of unknown fields is
74printed instead of the values.
75
76If B<XN_FLAG_FN_ALIGN> is set then field names are padded to 20 characters: this
77is only of use for multiline format.
78
79Additionally all the options supported by ASN1_STRING_print_ex() can be used to
80control how each field value is displayed.
81
82In addition a number options can be set for commonly used formats.
83
84B<XN_FLAG_RFC2253> sets options which produce an output compatible with RFC2253 it
85is equivalent to:
86 B<ASN1_STRFLGS_RFC2253 | XN_FLAG_SEP_COMMA_PLUS | XN_FLAG_DN_REV | XN_FLAG_FN_SN | XN_FLAG_DUMP_UNKNOWN_FIELDS>
87
88
89B<XN_FLAG_ONELINE> is a more readable one line format it is the same as:
90 B<ASN1_STRFLGS_RFC2253 | ASN1_STRFLGS_ESC_QUOTE | XN_FLAG_SEP_CPLUS_SPC | XN_FLAG_SPC_EQ | XN_FLAG_FN_SN>
91
92B<XN_FLAG_MULTILINE> is a multiline format is is the same as:
93 B<ASN1_STRFLGS_ESC_CTRL | ASN1_STRFLGS_ESC_MSB | XN_FLAG_SEP_MULTILINE | XN_FLAG_SPC_EQ | XN_FLAG_FN_LN | XN_FLAG_FN_ALIGN>
94
95B<XN_FLAG_COMPAT> uses a format identical to X509_NAME_print(): in fact it calls X509_NAME_print() internally.
96
97=head1 SEE ALSO
98
99L<ASN1_STRING_print_ex(3)|ASN1_STRING_print_ex(3)>
100
101=head1 HISTORY
102
103TBA
104
105=cut
diff --git a/src/lib/libssl/src/doc/crypto/X509_new.pod b/src/lib/libssl/src/doc/crypto/X509_new.pod
new file mode 100644
index 0000000000..fd5fc65ce1
--- /dev/null
+++ b/src/lib/libssl/src/doc/crypto/X509_new.pod
@@ -0,0 +1,37 @@
1=pod
2
3=head1 NAME
4
5X509_new, X509_free - X509 certificate ASN1 allocation functions
6
7=head1 SYNOPSIS
8
9 X509 *X509_new(void);
10 void X509_free(X509 *a);
11
12=head1 DESCRIPTION
13
14The X509 ASN1 allocation routines, allocate and free an
15X509 structure, which represents an X509 certificate.
16
17X509_new() allocates and initializes a X509 structure.
18
19X509_free() frees up the B<X509> structure B<a>.
20
21=head1 RETURN VALUES
22
23If the allocation fails, X509_new() returns B<NULL> and sets an error
24code that can be obtained by L<ERR_get_error(3)|ERR_get_error(3)>.
25Otherwise it returns a pointer to the newly allocated structure.
26
27X509_free() returns no value.
28
29=head1 SEE ALSO
30
31L<ERR_get_error(3)|ERR_get_error(3)>, L<d2i_X509(3)|d2i_X509(3)>
32
33=head1 HISTORY
34
35X509_new() and X509_free() are available in all versions of SSLeay and OpenSSL.
36
37=cut
diff --git a/src/lib/libssl/src/doc/crypto/crypto.pod b/src/lib/libssl/src/doc/crypto/crypto.pod
index c12eec1409..7a527992bb 100644
--- a/src/lib/libssl/src/doc/crypto/crypto.pod
+++ b/src/lib/libssl/src/doc/crypto/crypto.pod
@@ -62,6 +62,22 @@ L<txt_db(3)|txt_db(3)>
62 62
63=back 63=back
64 64
65=head1 NOTES
66
67Some of the newer functions follow a naming convention using the numbers
68B<0> and B<1>. For example the functions:
69
70 int X509_CRL_add0_revoked(X509_CRL *crl, X509_REVOKED *rev);
71 int X509_add1_trust_object(X509 *x, ASN1_OBJECT *obj);
72
73The B<0> version uses the supplied structure pointer directly
74in the parent and it will be freed up when the parent is freed.
75In the above example B<crl> would be freed but B<rev> would not.
76
77The B<1> function uses a copy of the supplied structure pointer
78(or in some cases increases its link count) in the parent and
79so both (B<x> and B<obj> above) should be freed up.
80
65=head1 SEE ALSO 81=head1 SEE ALSO
66 82
67L<openssl(1)|openssl(1)>, L<ssl(3)|ssl(3)> 83L<openssl(1)|openssl(1)>, L<ssl(3)|ssl(3)>
diff --git a/src/lib/libssl/src/doc/crypto/d2i_ASN1_OBJECT.pod b/src/lib/libssl/src/doc/crypto/d2i_ASN1_OBJECT.pod
new file mode 100644
index 0000000000..45bb18492c
--- /dev/null
+++ b/src/lib/libssl/src/doc/crypto/d2i_ASN1_OBJECT.pod
@@ -0,0 +1,29 @@
1=pod
2
3=head1 NAME
4
5d2i_ASN1_OBJECT, i2d_ASN1_OBJECT - ASN1 OBJECT IDENTIFIER functions
6
7=head1 SYNOPSIS
8
9 #include <openssl/objects.h>
10
11 ASN1_OBJECT *d2i_ASN1_OBJECT(ASN1_OBJECT **a, unsigned char **pp, long length);
12 int i2d_ASN1_OBJECT(ASN1_OBJECT *a, unsigned char **pp);
13
14=head1 DESCRIPTION
15
16These functions decode and encode an ASN1 OBJECT IDENTIFIER.
17
18Othewise these behave in a similar way to d2i_X509() and i2d_X509()
19described in the L<d2i_X509(3)|d2i_X509(3)> manual page.
20
21=head1 SEE ALSO
22
23L<d2i_X509(3)|d2i_X509(3)>
24
25=head1 HISTORY
26
27TBA
28
29=cut
diff --git a/src/lib/libssl/src/doc/crypto/d2i_DHparams.pod b/src/lib/libssl/src/doc/crypto/d2i_DHparams.pod
index a6d1743d39..1e98aebeca 100644
--- a/src/lib/libssl/src/doc/crypto/d2i_DHparams.pod
+++ b/src/lib/libssl/src/doc/crypto/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/libssl/src/doc/crypto/d2i_DSAPublicKey.pod b/src/lib/libssl/src/doc/crypto/d2i_DSAPublicKey.pod
new file mode 100644
index 0000000000..6ebd30427b
--- /dev/null
+++ b/src/lib/libssl/src/doc/crypto/d2i_DSAPublicKey.pod
@@ -0,0 +1,82 @@
1=pod
2
3=head1 NAME
4
5d2i_DSAPublicKey, i2d_DSAPublicKey, d2i_DSAPrivateKey, i2d_DSAPrivateKey,
6d2i_DSA_PUBKEY, i2d_DSA_PUBKEY, d2i_DSA_SIG, i2d_DSA_SIG - DSA key encoding
7and parsing functions.
8
9=head1 SYNOPSIS
10
11 #include <openssl/dsa.h>
12
13 DSA * d2i_DSAPublicKey(DSA **a, const unsigned char **pp, long length);
14
15 int i2d_DSAPublicKey(const DSA *a, unsigned char **pp);
16
17 DSA * d2i_DSA_PUBKEY(DSA **a, const unsigned char **pp, long length);
18
19 int i2d_DSA_PUBKEY(const DSA *a, unsigned char **pp);
20
21 DSA * d2i_DSAPrivateKey(DSA **a, const unsigned char **pp, long length);
22
23 int i2d_DSAPrivateKey(const DSA *a, unsigned char **pp);
24
25 DSA * d2i_DSAparams(DSA **a, const unsigned char **pp, long length);
26
27 int i2d_DSAparams(const DSA *a, unsigned char **pp);
28
29 DSA * d2i_DSA_SIG(DSA_SIG **a, const unsigned char **pp, long length);
30
31 int i2d_DSA_SIG(const DSA_SIG *a, unsigned char **pp);
32
33=head1 DESCRIPTION
34
35d2i_DSAPublicKey() and i2d_DSAPublicKey() decode and encode the DSA public key
36components structure.
37
38d2i_DSA_PUKEY() and i2d_DSA_PUKEY() decode and encode an DSA public key using a
39SubjectPublicKeyInfo (certificate public key) structure.
40
41d2i_DSAPrivateKey(), i2d_DSAPrivateKey() decode and encode the DSA private key
42components.
43
44d2i_DSAparams(), i2d_DSAparams() decode and encode the DSA parameters using
45a B<Dss-Parms> structure as defined in RFC2459.
46
47d2i_DSA_SIG(), i2d_DSA_SIG() decode and encode a DSA signature using a
48B<Dss-Sig-Value> structure as defined in RFC2459.
49
50The usage of all of these functions is similar to the d2i_X509() and
51i2d_X509() described in the L<d2i_X509(3)|d2i_X509(3)> manual page.
52
53=head1 NOTES
54
55The B<DSA> structure passed to the private key encoding functions should have
56all the private key components present.
57
58The data encoded by the private key functions is unencrypted and therefore
59offers no private key security.
60
61The B<DSA_PUBKEY> functions should be used in preference to the B<DSAPublicKey>
62functions when encoding public keys because they use a standard format.
63
64The B<DSAPublicKey> functions use an non standard format the actual data encoded
65depends on the value of the B<write_params> field of the B<a> key parameter.
66If B<write_params> is zero then only the B<pub_key> field is encoded as an
67B<INTEGER>. If B<write_params> is 1 then a B<SEQUENCE> consisting of the
68B<p>, B<q>, B<g> and B<pub_key> respectively fields are encoded.
69
70The B<DSAPrivateKey> functions also use a non standard structure consiting
71consisting of a SEQUENCE containing the B<p>, B<q>, B<g> and B<pub_key> and
72B<priv_key> fields respectively.
73
74=head1 SEE ALSO
75
76L<d2i_X509(3)|d2i_X509(3)>
77
78=head1 HISTORY
79
80TBA
81
82=cut
diff --git a/src/lib/libssl/src/doc/crypto/d2i_PKCS8PrivateKey.pod b/src/lib/libssl/src/doc/crypto/d2i_PKCS8PrivateKey.pod
new file mode 100644
index 0000000000..a54b779088
--- /dev/null
+++ b/src/lib/libssl/src/doc/crypto/d2i_PKCS8PrivateKey.pod
@@ -0,0 +1,56 @@
1=pod
2
3=head1 NAME
4
5d2i_PKCS8PrivateKey_bio, d2i_PKCS8PrivateKey_fp,
6i2d_PKCS8PrivateKey_bio, i2d_PKCS8PrivateKey_fp,
7i2d_PKCS8PrivateKey_nid_bio, i2d_PKCS8PrivateKey_nid_fp - PKCS#8 format private key functions
8
9=head1 SYNOPSIS
10
11 #include <openssl/evp.h>
12
13 EVP_PKEY *d2i_PKCS8PrivateKey_bio(BIO *bp, EVP_PKEY **x, pem_password_cb *cb, void *u);
14 EVP_PKEY *d2i_PKCS8PrivateKey_fp(FILE *fp, EVP_PKEY **x, pem_password_cb *cb, void *u);
15
16 int i2d_PKCS8PrivateKey_bio(BIO *bp, EVP_PKEY *x, const EVP_CIPHER *enc,
17 char *kstr, int klen,
18 pem_password_cb *cb, void *u);
19
20 int i2d_PKCS8PrivateKey_fp(FILE *fp, EVP_PKEY *x, const EVP_CIPHER *enc,
21 char *kstr, int klen,
22 pem_password_cb *cb, void *u);
23
24 int i2d_PKCS8PrivateKey_nid_bio(BIO *bp, EVP_PKEY *x, int nid,
25 char *kstr, int klen,
26 pem_password_cb *cb, void *u);
27
28 int i2d_PKCS8PrivateKey_nid_fp(FILE *fp, EVP_PKEY *x, int nid,
29 char *kstr, int klen,
30 pem_password_cb *cb, void *u);
31
32=head1 DESCRIPTION
33
34The PKCS#8 functions encode and decode private keys in PKCS#8 format using both
35PKCS#5 v1.5 and PKCS#5 v2.0 password based encryption algorithms.
36
37Other than the use of DER as opposed to PEM these functions are identical to the
38corresponding B<PEM> function as described in the L<pem(3)|pem(3)> manual page.
39
40=head1 NOTES
41
42Before using these functions L<OpenSSL_add_all_algorithms(3)|OpenSSL_add_all_algorithms(3)>
43should be called to initialize the internal algorithm lookup tables otherwise errors about
44unknown algorithms will occur if an attempt is made to decrypt a private key.
45
46These functions are currently the only way to store encrypted private keys using DER format.
47
48Currently all the functions use BIOs or FILE pointers, there are no functions which
49work directly on memory: this can be readily worked around by converting the buffers
50to memory BIOs, see L<BIO_s_mem(3)|BIO_s_mem(3)> for details.
51
52=head1 SEE ALSO
53
54L<pem(3)|pem(3)>
55
56=cut
diff --git a/src/lib/libssl/src/doc/crypto/d2i_RSAPublicKey.pod b/src/lib/libssl/src/doc/crypto/d2i_RSAPublicKey.pod
index ff4d0d57db..7c71bcbf3d 100644
--- a/src/lib/libssl/src/doc/crypto/d2i_RSAPublicKey.pod
+++ b/src/lib/libssl/src/doc/crypto/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/libssl/src/doc/crypto/d2i_X509.pod b/src/lib/libssl/src/doc/crypto/d2i_X509.pod
new file mode 100644
index 0000000000..5e3c3d0985
--- /dev/null
+++ b/src/lib/libssl/src/doc/crypto/d2i_X509.pod
@@ -0,0 +1,231 @@
1=pod
2
3=head1 NAME
4
5d2i_X509, i2d_X509, d2i_X509_bio, d2i_X509_fp, i2d_X509_bio,
6i2d_X509_fp - X509 encode and decode functions
7
8=head1 SYNOPSIS
9
10 #include <openssl/x509.h>
11
12 X509 *d2i_X509(X509 **px, unsigned char **in, int len);
13 int i2d_X509(X509 *x, unsigned char **out);
14
15 X509 *d2i_X509_bio(BIO *bp, X509 **x);
16 X509 *d2i_X509_fp(FILE *fp, X509 **x);
17
18 int i2d_X509_bio(X509 *x, BIO *bp);
19 int i2d_X509_fp(X509 *x, FILE *fp);
20
21=head1 DESCRIPTION
22
23The X509 encode and decode routines encode and parse an
24B<X509> structure, which represents an X509 certificate.
25
26d2i_X509() attempts to decode B<len> bytes at B<*out>. If
27successful a pointer to the B<X509> structure is returned. If an error
28occurred then B<NULL> is returned. If B<px> is not B<NULL> then the
29returned structure is written to B<*px>. If B<*px> is not B<NULL>
30then it is assumed that B<*px> contains a valid B<X509>
31structure and an attempt is made to reuse it. If the call is
32successful B<*out> is incremented to the byte following the
33parsed data.
34
35i2d_X509() encodes the structure pointed to by B<x> into DER format.
36If B<out> is not B<NULL> is writes the DER encoded data to the buffer
37at B<*out>, and increments it to point after the data just written.
38If the return value is negative an error occurred, otherwise it
39returns the length of the encoded data.
40
41For OpenSSL 0.9.7 and later if B<*out> is B<NULL> memory will be
42allocated for a buffer and the encoded data written to it. In this
43case B<*out> is not incremented and it points to the start of the
44data just written.
45
46d2i_X509_bio() is similar to d2i_X509() except it attempts
47to parse data from BIO B<bp>.
48
49d2i_X509_fp() is similar to d2i_X509() except it attempts
50to parse data from FILE pointer B<fp>.
51
52i2d_X509_bio() is similar to i2d_X509() except it writes
53the encoding of the structure B<x> to BIO B<bp> and it
54returns 1 for success and 0 for failure.
55
56i2d_X509_fp() is similar to i2d_X509() except it writes
57the encoding of the structure B<x> to BIO B<bp> and it
58returns 1 for success and 0 for failure.
59
60=head1 NOTES
61
62The letters B<i> and B<d> in for example B<i2d_X509> stand for
63"internal" (that is an internal C structure) and "DER". So that
64B<i2d_X509> converts from internal to DER.
65
66The functions can also understand B<BER> forms.
67
68The actual X509 structure passed to i2d_X509() must be a valid
69populated B<X509> structure it can B<not> simply be fed with an
70empty structure such as that returned by X509_new().
71
72The encoded data is in binary form and may contain embedded zeroes.
73Therefore any FILE pointers or BIOs should be opened in binary mode.
74Functions such as B<strlen()> will B<not> return the correct length
75of the encoded structure.
76
77The ways that B<*in> and B<*out> are incremented after the operation
78can trap the unwary. See the B<WARNINGS> section for some common
79errors.
80
81The reason for the auto increment behaviour is to reflect a typical
82usage of ASN1 functions: after one structure is encoded or decoded
83another will processed after it.
84
85=head1 EXAMPLES
86
87Allocate and encode the DER encoding of an X509 structure:
88
89 int len;
90 unsigned char *buf, *p;
91
92 len = i2d_X509(x, NULL);
93
94 buf = OPENSSL_malloc(len);
95
96 if (buf == NULL)
97 /* error */
98
99 p = buf;
100
101 i2d_X509(x, &p);
102
103If you are using OpenSSL 0.9.7 or later then this can be
104simplified to:
105
106
107 int len;
108 unsigned char *buf;
109
110 buf = NULL;
111
112 len = i2d_X509(x, &buf);
113
114 if (len < 0)
115 /* error */
116
117Attempt to decode a buffer:
118
119 X509 *x;
120
121 unsigned char *buf, *p;
122
123 int len;
124
125 /* Something to setup buf and len */
126
127 p = buf;
128
129 x = d2i_X509(NULL, &p, len);
130
131 if (x == NULL)
132 /* Some error */
133
134Alternative technique:
135
136 X509 *x;
137
138 unsigned char *buf, *p;
139
140 int len;
141
142 /* Something to setup buf and len */
143
144 p = buf;
145
146 x = NULL;
147
148 if(!d2i_X509(&x, &p, len))
149 /* Some error */
150
151
152=head1 WARNINGS
153
154The use of temporary variable is mandatory. A common
155mistake is to attempt to use a buffer directly as follows:
156
157 int len;
158 unsigned char *buf;
159
160 len = i2d_X509(x, NULL);
161
162 buf = OPENSSL_malloc(len);
163
164 if (buf == NULL)
165 /* error */
166
167 i2d_X509(x, &buf);
168
169 /* Other stuff ... */
170
171 OPENSSL_free(buf);
172
173This code will result in B<buf> apparently containing garbage because
174it was incremented after the call to point after the data just written.
175Also B<buf> will no longer contain the pointer allocated by B<OPENSSL_malloc()>
176and the subsequent call to B<OPENSSL_free()> may well crash.
177
178The auto allocation feature (setting buf to NULL) only works on OpenSSL
1790.9.7 and later. Attempts to use it on earlier versions will typically
180cause a segmentation violation.
181
182Another trap to avoid is misuse of the B<xp> argument to B<d2i_X509()>:
183
184 X509 *x;
185
186 if (!d2i_X509(&x, &p, len))
187 /* Some error */
188
189This will probably crash somewhere in B<d2i_X509()>. The reason for this
190is that the variable B<x> is uninitialized and an attempt will be made to
191interpret its (invalid) value as an B<X509> structure, typically causing
192a segmentation violation. If B<x> is set to NULL first then this will not
193happen.
194
195=head1 BUGS
196
197In some versions of OpenSSL the "reuse" behaviour of d2i_X509() when
198B<*px> is valid is broken and some parts of the reused structure may
199persist if they are not present in the new one. As a result the use
200of this "reuse" behaviour is strongly discouraged.
201
202i2d_X509() will not return an error in many versions of OpenSSL,
203if mandatory fields are not initialized due to a programming error
204then the encoded structure may contain invalid data or omit the
205fields entirely and will not be parsed by d2i_X509(). This may be
206fixed in future so code should not assume that i2d_X509() will
207always succeed.
208
209=head1 RETURN VALUES
210
211d2i_X509(), d2i_X509_bio() and d2i_X509_fp() return a valid B<X509> structure
212or B<NULL> if an error occurs. The error code that can be obtained by
213L<ERR_get_error(3)|ERR_get_error(3)>.
214
215i2d_X509(), i2d_X509_bio() and i2d_X509_fp() return a the number of bytes
216successfully encoded or a negative value if an error occurs. The error code
217can be obtained by L<ERR_get_error(3)|ERR_get_error(3)>.
218
219i2d_X509_bio() and i2d_X509_fp() returns 1 for success and 0 if an error
220occurs The error code can be obtained by L<ERR_get_error(3)|ERR_get_error(3)>.
221
222=head1 SEE ALSO
223
224L<ERR_get_error(3)|ERR_get_error(3)>
225
226=head1 HISTORY
227
228d2i_X509, i2d_X509, d2i_X509_bio, d2i_X509_fp, i2d_X509_bio and i2d_X509_fp
229are available in all versions of SSLeay and OpenSSL.
230
231=cut
diff --git a/src/lib/libssl/src/doc/crypto/d2i_X509_ALGOR.pod b/src/lib/libssl/src/doc/crypto/d2i_X509_ALGOR.pod
new file mode 100644
index 0000000000..9e5cd92ca7
--- /dev/null
+++ b/src/lib/libssl/src/doc/crypto/d2i_X509_ALGOR.pod
@@ -0,0 +1,30 @@
1=pod
2
3=head1 NAME
4
5d2i_X509_ALGOR, i2d_X509_ALGOR - AlgorithmIdentifier functions.
6
7=head1 SYNOPSIS
8
9 #include <openssl/x509.h>
10
11 X509_ALGOR *d2i_X509_ALGOR(X509_ALGOR **a, unsigned char **pp, long length);
12 int i2d_X509_ALGOR(X509_ALGOR *a, unsigned char **pp);
13
14=head1 DESCRIPTION
15
16These functions decode and encode an B<X509_ALGOR> structure which is
17equivalent to the B<AlgorithmIdentifier> structure.
18
19Othewise these behave in a similar way to d2i_X509() and i2d_X509()
20described in the L<d2i_X509(3)|d2i_X509(3)> manual page.
21
22=head1 SEE ALSO
23
24L<d2i_X509(3)|d2i_X509(3)>
25
26=head1 HISTORY
27
28TBA
29
30=cut
diff --git a/src/lib/libssl/src/doc/crypto/d2i_X509_CRL.pod b/src/lib/libssl/src/doc/crypto/d2i_X509_CRL.pod
new file mode 100644
index 0000000000..06c5b23c09
--- /dev/null
+++ b/src/lib/libssl/src/doc/crypto/d2i_X509_CRL.pod
@@ -0,0 +1,37 @@
1=pod
2
3=head1 NAME
4
5d2i_X509_CRL, i2d_X509_CRL, d2i_X509_CRL_bio, d2i_509_CRL_fp,
6i2d_X509_CRL_bio, i2d_X509_CRL_fp - PKCS#10 certificate request functions.
7
8=head1 SYNOPSIS
9
10 #include <openssl/x509.h>
11
12 X509_CRL *d2i_X509_CRL(X509_CRL **a, unsigned char **pp, long length);
13 int i2d_X509_CRL(X509_CRL *a, unsigned char **pp);
14
15 X509_CRL *d2i_X509_CRL_bio(BIO *bp, X509_CRL **x);
16 X509_CRL *d2i_X509_CRL_fp(FILE *fp, X509_CRL **x);
17
18 int i2d_X509_CRL_bio(X509_CRL *x, BIO *bp);
19 int i2d_X509_CRL_fp(X509_CRL *x, FILE *fp);
20
21=head1 DESCRIPTION
22
23These functions decode and encode an X509 CRL (certificate revocation
24list).
25
26Othewise the functions behave in a similar way to d2i_X509() and i2d_X509()
27described in the L<d2i_X509(3)|d2i_X509(3)> manual page.
28
29=head1 SEE ALSO
30
31L<d2i_X509(3)|d2i_X509(3)>
32
33=head1 HISTORY
34
35TBA
36
37=cut
diff --git a/src/lib/libssl/src/doc/crypto/d2i_X509_NAME.pod b/src/lib/libssl/src/doc/crypto/d2i_X509_NAME.pod
new file mode 100644
index 0000000000..343ffe1519
--- /dev/null
+++ b/src/lib/libssl/src/doc/crypto/d2i_X509_NAME.pod
@@ -0,0 +1,31 @@
1=pod
2
3=head1 NAME
4
5d2i_X509_NAME, i2d_X509_NAME - X509_NAME encoding functions
6
7=head1 SYNOPSIS
8
9 #include <openssl/x509.h>
10
11 X509_NAME *d2i_X509_NAME(X509_NAME **a, unsigned char **pp, long length);
12 int i2d_X509_NAME(X509_NAME *a, unsigned char **pp);
13
14=head1 DESCRIPTION
15
16These functions decode and encode an B<X509_NAME> structure which is the
17the same as the B<Name> type defined in RFC2459 (and elsewhere) and used
18for example in certificate subject and issuer names.
19
20Othewise the functions behave in a similar way to d2i_X509() and i2d_X509()
21described in the L<d2i_X509(3)|d2i_X509(3)> manual page.
22
23=head1 SEE ALSO
24
25L<d2i_X509(3)|d2i_X509(3)>
26
27=head1 HISTORY
28
29TBA
30
31=cut
diff --git a/src/lib/libssl/src/doc/crypto/d2i_X509_REQ.pod b/src/lib/libssl/src/doc/crypto/d2i_X509_REQ.pod
new file mode 100644
index 0000000000..be4ad68257
--- /dev/null
+++ b/src/lib/libssl/src/doc/crypto/d2i_X509_REQ.pod
@@ -0,0 +1,36 @@
1=pod
2
3=head1 NAME
4
5d2i_X509_REQ, i2d_X509_REQ, d2i_X509_REQ_bio, d2i_X509_REQ_fp,
6i2d_X509_REQ_bio, i2d_X509_REQ_fp - PKCS#10 certificate request functions.
7
8=head1 SYNOPSIS
9
10 #include <openssl/x509.h>
11
12 X509_REQ *d2i_X509_REQ(X509_REQ **a, unsigned char **pp, long length);
13 int i2d_X509_REQ(X509_REQ *a, unsigned char **pp);
14
15 X509_REQ *d2i_X509_REQ_bio(BIO *bp, X509_REQ **x);
16 X509_REQ *d2i_X509_REQ_fp(FILE *fp, X509_REQ **x);
17
18 int i2d_X509_REQ_bio(X509_REQ *x, BIO *bp);
19 int i2d_X509_REQ_fp(X509_REQ *x, FILE *fp);
20
21=head1 DESCRIPTION
22
23These functions decode and encode a PKCS#10 certificate request.
24
25Othewise these behave in a similar way to d2i_X509() and i2d_X509()
26described in the L<d2i_X509(3)|d2i_X509(3)> manual page.
27
28=head1 SEE ALSO
29
30L<d2i_X509(3)|d2i_X509(3)>
31
32=head1 HISTORY
33
34TBA
35
36=cut
diff --git a/src/lib/libssl/src/doc/crypto/d2i_X509_SIG.pod b/src/lib/libssl/src/doc/crypto/d2i_X509_SIG.pod
new file mode 100644
index 0000000000..e48fd79a51
--- /dev/null
+++ b/src/lib/libssl/src/doc/crypto/d2i_X509_SIG.pod
@@ -0,0 +1,30 @@
1=pod
2
3=head1 NAME
4
5d2i_X509_SIG, i2d_X509_SIG - DigestInfo functions.
6
7=head1 SYNOPSIS
8
9 #include <openssl/x509.h>
10
11 X509_SIG *d2i_X509_SIG(X509_SIG **a, unsigned char **pp, long length);
12 int i2d_X509_SIG(X509_SIG *a, unsigned char **pp);
13
14=head1 DESCRIPTION
15
16These functions decode and encode an X509_SIG structure which is
17equivalent to the B<DigestInfo> structure defined in PKCS#1 and PKCS#7.
18
19Othewise these behave in a similar way to d2i_X509() and i2d_X509()
20described in the L<d2i_X509(3)|d2i_X509(3)> manual page.
21
22=head1 SEE ALSO
23
24L<d2i_X509(3)|d2i_X509(3)>
25
26=head1 HISTORY
27
28TBA
29
30=cut
diff --git a/src/lib/libssl/src/doc/crypto/engine.pod b/src/lib/libssl/src/doc/crypto/engine.pod
index 61e0264bb7..c77dad5562 100644
--- a/src/lib/libssl/src/doc/crypto/engine.pod
+++ b/src/lib/libssl/src/doc/crypto/engine.pod
@@ -187,7 +187,7 @@ tell which one you are dealing with at any given point in time (after all
187they are both simply (ENGINE *) pointers, the difference is in the way they 187they are both simply (ENGINE *) pointers, the difference is in the way they
188are used). 188are used).
189 189
190=head3 Structural references 190I<Structural references>
191 191
192This basic type of reference is typically used for creating new ENGINEs 192This basic type of reference is typically used for creating new ENGINEs
193dynamically, iterating across OpenSSL's internal linked-list of loaded 193dynamically, iterating across OpenSSL's internal linked-list of loaded
@@ -224,7 +224,7 @@ To clarify a particular function's handling of references, one should
224always consult that function's documentation "man" page, or failing that 224always consult that function's documentation "man" page, or failing that
225the openssl/engine.h header file includes some hints. 225the openssl/engine.h header file includes some hints.
226 226
227=head3 Functional references 227I<Functional references>
228 228
229As mentioned, functional references exist when the cryptographic 229As mentioned, functional references exist when the cryptographic
230functionality of an ENGINE is required to be available. A functional 230functionality of an ENGINE is required to be available. A functional
@@ -386,7 +386,7 @@ things, so we will simply illustrate the consequences as they apply to a
386couple of simple cases and leave developers to consider these and the 386couple of simple cases and leave developers to consider these and the
387source code to openssl's builtin utilities as guides. 387source code to openssl's builtin utilities as guides.
388 388
389=head3 Using a specific ENGINE implementation 389I<Using a specific ENGINE implementation>
390 390
391Here we'll assume an application has been configured by its user or admin 391Here we'll assume an application has been configured by its user or admin
392to want to use the "ACME" ENGINE if it is available in the version of 392to want to use the "ACME" ENGINE if it is available in the version of
@@ -418,7 +418,7 @@ illustrates how to approach this;
418 /* Release the structural reference from ENGINE_by_id() */ 418 /* Release the structural reference from ENGINE_by_id() */
419 ENGINE_free(e); 419 ENGINE_free(e);
420 420
421=head3 Automatically using builtin ENGINE implementations 421I<Automatically using builtin ENGINE implementations>
422 422
423Here we'll assume we want to load and register all ENGINE implementations 423Here we'll assume we want to load and register all ENGINE implementations
424bundled with OpenSSL, such that for any cryptographic algorithm required by 424bundled with OpenSSL, such that for any cryptographic algorithm required by
@@ -469,7 +469,7 @@ in same cases both. ENGINE implementations should provide indications of
469this in the descriptions attached to builtin control commands and/or in 469this in the descriptions attached to builtin control commands and/or in
470external product documentation. 470external product documentation.
471 471
472=head3 Issuing control commands to an ENGINE 472I<Issuing control commands to an ENGINE>
473 473
474Let's illustrate by example; a function for which the caller supplies the 474Let's illustrate by example; a function for which the caller supplies the
475name of the ENGINE it wishes to use, a table of string-pairs for use before 475name of the ENGINE it wishes to use, a table of string-pairs for use before
@@ -526,7 +526,7 @@ return success without doing anything. In this case we assume the user is
526only supplying commands specific to the given ENGINE so we set this to 526only supplying commands specific to the given ENGINE so we set this to
527FALSE. 527FALSE.
528 528
529=head3 Discovering supported control commands 529I<Discovering supported control commands>
530 530
531It is possible to discover at run-time the names, numerical-ids, descriptions 531It is possible to discover at run-time the names, numerical-ids, descriptions
532and input parameters of the control commands supported from a structural 532and input parameters of the control commands supported from a structural
diff --git a/src/lib/libssl/src/doc/openssl-shared.txt b/src/lib/libssl/src/doc/openssl-shared.txt
new file mode 100644
index 0000000000..5cf84a054f
--- /dev/null
+++ b/src/lib/libssl/src/doc/openssl-shared.txt
@@ -0,0 +1,32 @@
1The OpenSSL shared libraries are often installed in a directory like
2/usr/local/ssl/lib.
3
4If this directory is not in a standard system path for dynamic/shared
5libraries, then you will have problems linking and executing
6applications that use OpenSSL libraries UNLESS:
7
8* you link with static (archive) libraries. If you are truly
9 paranoid about security, you should use static libraries.
10* you use the GNU libtool code during linking
11 (http://www.gnu.org/software/libtool/libtool.html)
12* you use pkg-config during linking (this requires that
13 PKG_CONFIG_PATH includes the path to the OpenSSL shared
14 library directory), and make use of -R or -rpath.
15 (http://www.freedesktop.org/software/pkgconfig/)
16* you specify the system-wide link path via a command such
17 as crle(1) on Solaris systems.
18* you add the OpenSSL shared library directory to /etc/ld.so.conf
19 and run ldconfig(8) on Linux systems.
20* you define the LD_LIBRARY_PATH, LIBPATH, SHLIB_PATH (HP),
21 DYLD_LIBRARY_PATH (MacOS X) or PATH (Cygwin and DJGPP)
22 environment variable and add the OpenSSL shared library
23 directory to it.
24
25One common tool to check the dynamic dependencies of an executable
26or dynamic library is ldd(1) on most UNIX systems.
27
28See any operating system documentation and manpages about shared
29libraries for your version of UNIX. The following manpages may be
30helpful: ld(1), ld.so(1), ld.so.1(1) [Solaris], dld.sl(1) [HP],
31ldd(1), crle(1) [Solaris], pldd(1) [Solaris], ldconfig(8) [Linux],
32chatr(1) [HP].
diff --git a/src/lib/libssl/src/doc/ssl/SSL_CTX_add_session.pod b/src/lib/libssl/src/doc/ssl/SSL_CTX_add_session.pod
index af326c2f73..82676b26b2 100644
--- a/src/lib/libssl/src/doc/ssl/SSL_CTX_add_session.pod
+++ b/src/lib/libssl/src/doc/ssl/SSL_CTX_add_session.pod
@@ -37,6 +37,14 @@ removed and replaced by the new session. If the session is actually
37identical (the SSL_SESSION object is identical), SSL_CTX_add_session() 37identical (the SSL_SESSION object is identical), SSL_CTX_add_session()
38is a no-op, and the return value is 0. 38is a no-op, and the return value is 0.
39 39
40If a server SSL_CTX is configured with the SSL_SESS_CACHE_NO_INTERNAL_STORE
41flag then the internal cache will not be populated automatically by new
42sessions negotiated by the SSL/TLS implementation, even though the internal
43cache will be searched automatically for session-resume requests (the
44latter can be surpressed by SSL_SESS_CACHE_NO_INTERNAL_LOOKUP). So the
45application can use SSL_CTX_add_session() directly to have full control
46over the sessions that can be resumed if desired.
47
40 48
41=head1 RETURN VALUES 49=head1 RETURN VALUES
42 50
diff --git a/src/lib/libssl/src/doc/ssl/SSL_CTX_free.pod b/src/lib/libssl/src/doc/ssl/SSL_CTX_free.pod
index 55e592f5f8..51d8676968 100644
--- a/src/lib/libssl/src/doc/ssl/SSL_CTX_free.pod
+++ b/src/lib/libssl/src/doc/ssl/SSL_CTX_free.pod
@@ -20,12 +20,22 @@ It also calls the free()ing procedures for indirectly affected items, if
20applicable: the session cache, the list of ciphers, the list of Client CAs, 20applicable: the session cache, the list of ciphers, the list of Client CAs,
21the certificates and keys. 21the certificates and keys.
22 22
23=head1 WARNINGS
24
25If a session-remove callback is set (SSL_CTX_sess_set_remove_cb()), this
26callback will be called for each session being freed from B<ctx>'s
27session cache. This implies, that all corresponding sessions from an
28external session cache are removed as well. If this is not desired, the user
29should explicitly unset the callback by calling
30SSL_CTX_sess_set_remove_cb(B<ctx>, NULL) prior to calling SSL_CTX_free().
31
23=head1 RETURN VALUES 32=head1 RETURN VALUES
24 33
25SSL_CTX_free() does not provide diagnostic information. 34SSL_CTX_free() does not provide diagnostic information.
26 35
27=head1 SEE ALSO 36=head1 SEE ALSO
28 37
29L<SSL_CTX_new(3)|SSL_CTX_new(3)>, L<ssl(3)|ssl(3)> 38L<SSL_CTX_new(3)|SSL_CTX_new(3)>, L<ssl(3)|ssl(3)>,
39L<SSL_CTX_sess_set_get_cb(3)|SSL_CTX_sess_set_get_cb(3)>
30 40
31=cut 41=cut
diff --git a/src/lib/libssl/src/doc/ssl/SSL_CTX_sess_set_get_cb.pod b/src/lib/libssl/src/doc/ssl/SSL_CTX_sess_set_get_cb.pod
index 7c0b2baf6c..b9d54a40a1 100644
--- a/src/lib/libssl/src/doc/ssl/SSL_CTX_sess_set_get_cb.pod
+++ b/src/lib/libssl/src/doc/ssl/SSL_CTX_sess_set_get_cb.pod
@@ -60,10 +60,11 @@ B<sess>. If the callback returns B<0>, the session will be immediately
60removed again. 60removed again.
61 61
62The remove_session_cb() is called, whenever the SSL engine removes a session 62The remove_session_cb() is called, whenever the SSL engine removes a session
63from the internal cache. This happens if the session is removed because 63from the internal cache. This happens when the session is removed because
64it is expired or when a connection was not shutdown cleanly. The 64it is expired or when a connection was not shutdown cleanly. It also happens
65remove_session_cb() is passed the B<ctx> and the ssl session B<sess>. 65for all sessions in the internal session cache when
66It does not provide any feedback. 66L<SSL_CTX_free(3)|SSL_CTX_free(3)> is called. The remove_session_cb() is passed
67the B<ctx> and the ssl session B<sess>. It does not provide any feedback.
67 68
68The get_session_cb() is only called on SSL/TLS servers with the session id 69The get_session_cb() is only called on SSL/TLS servers with the session id
69proposed by the client. The get_session_cb() is always called, also when 70proposed by the client. The get_session_cb() is always called, also when
@@ -80,6 +81,7 @@ L<SSL_SESSION_free(3)|SSL_SESSION_free(3)>.
80L<ssl(3)|ssl(3)>, L<d2i_SSL_SESSION(3)|d2i_SSL_SESSION(3)>, 81L<ssl(3)|ssl(3)>, L<d2i_SSL_SESSION(3)|d2i_SSL_SESSION(3)>,
81L<SSL_CTX_set_session_cache_mode(3)|SSL_CTX_set_session_cache_mode(3)>, 82L<SSL_CTX_set_session_cache_mode(3)|SSL_CTX_set_session_cache_mode(3)>,
82L<SSL_CTX_flush_sessions(3)|SSL_CTX_flush_sessions(3)>, 83L<SSL_CTX_flush_sessions(3)|SSL_CTX_flush_sessions(3)>,
83L<SSL_SESSION_free(3)|SSL_SESSION_free(3)> 84L<SSL_SESSION_free(3)|SSL_SESSION_free(3)>,
85L<SSL_CTX_free(3)|SSL_CTX_free(3)>
84 86
85=cut 87=cut
diff --git a/src/lib/libssl/src/doc/ssl/SSL_CTX_set_options.pod b/src/lib/libssl/src/doc/ssl/SSL_CTX_set_options.pod
index f5e2ec3555..766f0c9200 100644
--- a/src/lib/libssl/src/doc/ssl/SSL_CTX_set_options.pod
+++ b/src/lib/libssl/src/doc/ssl/SSL_CTX_set_options.pod
@@ -176,7 +176,7 @@ will send his list of preferences to the client and the client chooses.
176=item SSL_OP_NETSCAPE_CA_DN_BUG 176=item SSL_OP_NETSCAPE_CA_DN_BUG
177 177
178If we accept a netscape connection, demand a client cert, have a 178If we accept a netscape connection, demand a client cert, have a
179non-self-sighed CA which does not have it's CA in netscape, and the 179non-self-signed CA which does not have its CA in netscape, and the
180browser has a cert, it will crash/hang. Works for 3.x and 4.xbeta 180browser has a cert, it will crash/hang. Works for 3.x and 4.xbeta
181 181
182=item SSL_OP_NETSCAPE_DEMO_CIPHER_CHANGE_BUG 182=item SSL_OP_NETSCAPE_DEMO_CIPHER_CHANGE_BUG
diff --git a/src/lib/libssl/src/doc/ssl/SSL_CTX_set_session_cache_mode.pod b/src/lib/libssl/src/doc/ssl/SSL_CTX_set_session_cache_mode.pod
index 9aa6c6b2e3..c5d2f43dff 100644
--- a/src/lib/libssl/src/doc/ssl/SSL_CTX_set_session_cache_mode.pod
+++ b/src/lib/libssl/src/doc/ssl/SSL_CTX_set_session_cache_mode.pod
@@ -26,12 +26,14 @@ SSL_CTX object is being maintained, the sessions are unique for each SSL_CTX
26object. 26object.
27 27
28In order to reuse a session, a client must send the session's id to the 28In order to reuse a session, a client must send the session's id to the
29server. It can only send exactly one id. The server then decides whether it 29server. It can only send exactly one id. The server then either
30agrees in reusing the session or starts the handshake for a new session. 30agrees to reuse the session or it starts a full handshake (to create a new
31session).
31 32
32A server will lookup up the session in its internal session storage. If 33A server will lookup up the session in its internal session storage. If the
33the session is not found in internal storage or internal storage is 34session is not found in internal storage or lookups for the internal storage
34deactivated, the server will try the external storage if available. 35have been deactivated (SSL_SESS_CACHE_NO_INTERNAL_LOOKUP), the server will try
36the external storage if available.
35 37
36Since a client may try to reuse a session intended for use in a different 38Since a client may try to reuse a session intended for use in a different
37context, the session id context must be set by the server (see 39context, the session id context must be set by the server (see
@@ -57,9 +59,10 @@ function. This option is not activated by default.
57=item SSL_SESS_CACHE_SERVER 59=item SSL_SESS_CACHE_SERVER
58 60
59Server sessions are added to the session cache. When a client proposes a 61Server sessions are added to the session cache. When a client proposes a
60session to be reused, the session is looked up in the internal session cache. 62session to be reused, the server looks for the corresponding session in (first)
61If the session is found, the server will try to reuse the session. 63the internal session cache (unless SSL_SESS_CACHE_NO_INTERNAL_LOOKUP is set),
62This is the default. 64then (second) in the external cache if available. If the session is found, the
65server will try to reuse the session. This is the default.
63 66
64=item SSL_SESS_CACHE_BOTH 67=item SSL_SESS_CACHE_BOTH
65 68
@@ -77,12 +80,32 @@ explicitly by the application.
77 80
78=item SSL_SESS_CACHE_NO_INTERNAL_LOOKUP 81=item SSL_SESS_CACHE_NO_INTERNAL_LOOKUP
79 82
80By setting this flag sessions are cached in the internal storage but 83By setting this flag, session-resume operations in an SSL/TLS server will not
81they are not looked up automatically. If an external session cache 84automatically look up sessions in the internal cache, even if sessions are
82is enabled, sessions are looked up in the external cache. As automatic 85automatically stored there. If external session caching callbacks are in use,
83lookup only applies for SSL/TLS servers, the flag has no effect on 86this flag guarantees that all lookups are directed to the external cache.
87As automatic lookup only applies for SSL/TLS servers, the flag has no effect on
84clients. 88clients.
85 89
90=item SSL_SESS_CACHE_NO_INTERNAL_STORE
91
92Depending on the presence of SSL_SESS_CACHE_CLIENT and/or SSL_SESS_CACHE_SERVER,
93sessions negotiated in an SSL/TLS handshake may be cached for possible reuse.
94Normally a new session is added to the internal cache as well as any external
95session caching (callback) that is configured for the SSL_CTX. This flag will
96prevent sessions being stored in the internal cache (though the application can
97add them manually using L<SSL_CTX_add_session(3)|SSL_CTX_add_session(3)>). Note:
98in any SSL/TLS servers where external caching is configured, any successful
99session lookups in the external cache (ie. for session-resume requests) would
100normally be copied into the local cache before processing continues - this flag
101prevents these additions to the internal cache as well.
102
103=item SSL_SESS_CACHE_NO_INTERNAL
104
105Enable both SSL_SESS_CACHE_NO_INTERNAL_LOOKUP and
106SSL_SESS_CACHE_NO_INTERNAL_STORE at the same time.
107
108
86=back 109=back
87 110
88The default mode is SSL_SESS_CACHE_SERVER. 111The default mode is SSL_SESS_CACHE_SERVER.
@@ -98,6 +121,7 @@ SSL_CTX_get_session_cache_mode() returns the currently set cache mode.
98 121
99L<ssl(3)|ssl(3)>, L<SSL_set_session(3)|SSL_set_session(3)>, 122L<ssl(3)|ssl(3)>, L<SSL_set_session(3)|SSL_set_session(3)>,
100L<SSL_session_reused(3)|SSL_session_reused(3)>, 123L<SSL_session_reused(3)|SSL_session_reused(3)>,
124L<SSL_CTX_add_session(3)|SSL_CTX_add_session(3)>,
101L<SSL_CTX_sess_number(3)|SSL_CTX_sess_number(3)>, 125L<SSL_CTX_sess_number(3)|SSL_CTX_sess_number(3)>,
102L<SSL_CTX_sess_set_cache_size(3)|SSL_CTX_sess_set_cache_size(3)>, 126L<SSL_CTX_sess_set_cache_size(3)|SSL_CTX_sess_set_cache_size(3)>,
103L<SSL_CTX_sess_set_get_cb(3)|SSL_CTX_sess_set_get_cb(3)>, 127L<SSL_CTX_sess_set_get_cb(3)|SSL_CTX_sess_set_get_cb(3)>,
@@ -105,4 +129,9 @@ L<SSL_CTX_set_session_id_context(3)|SSL_CTX_set_session_id_context(3)>,
105L<SSL_CTX_set_timeout(3)|SSL_CTX_set_timeout(3)>, 129L<SSL_CTX_set_timeout(3)|SSL_CTX_set_timeout(3)>,
106L<SSL_CTX_flush_sessions(3)|SSL_CTX_flush_sessions(3)> 130L<SSL_CTX_flush_sessions(3)|SSL_CTX_flush_sessions(3)>
107 131
132=head1 HISTORY
133
134SSL_SESS_CACHE_NO_INTERNAL_STORE and SSL_SESS_CACHE_NO_INTERNAL
135were introduced in OpenSSL 0.9.6h.
136
108=cut 137=cut
diff --git a/src/lib/libssl/src/doc/ssl/SSL_CTX_set_verify.pod b/src/lib/libssl/src/doc/ssl/SSL_CTX_set_verify.pod
index 5bb21ca535..d15b2a3a1a 100644
--- a/src/lib/libssl/src/doc/ssl/SSL_CTX_set_verify.pod
+++ b/src/lib/libssl/src/doc/ssl/SSL_CTX_set_verify.pod
@@ -235,7 +235,7 @@ L<SSL_get_ex_data_X509_STORE_CTX_idx(3)|SSL_get_ex_data_X509_STORE_CTX_idx(3)>).
235 * At this point, err contains the last verification error. We can use 235 * At this point, err contains the last verification error. We can use
236 * it for something special 236 * it for something special
237 */ 237 */
238 if (!preverify_ok && (err == X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT) 238 if (!preverify_ok && (err == X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT))
239 { 239 {
240 X509_NAME_oneline(X509_get_issuer_name(ctx->current_cert), buf, 256); 240 X509_NAME_oneline(X509_get_issuer_name(ctx->current_cert), buf, 256);
241 printf("issuer= %s\n", buf); 241 printf("issuer= %s\n", buf);
diff --git a/src/lib/libssl/src/doc/ssl/ssl.pod b/src/lib/libssl/src/doc/ssl/ssl.pod
index 1471e0312e..3dc5358ef6 100644
--- a/src/lib/libssl/src/doc/ssl/ssl.pod
+++ b/src/lib/libssl/src/doc/ssl/ssl.pod
@@ -351,7 +351,7 @@ appropriate size (using ???) and return it.
351 351
352long B<SSL_set_tmp_rsa_callback>(SSL *ssl, RSA *(*cb)(SSL *ssl, int export, int keylength)); 352long B<SSL_set_tmp_rsa_callback>(SSL *ssl, RSA *(*cb)(SSL *ssl, int export, int keylength));
353 353
354The same as L<"SSL_CTX_set_tmp_rsa_callback">, except it operates on an SSL 354The same as B<SSL_CTX_set_tmp_rsa_callback>, except it operates on an SSL
355session instead of a context. 355session instead of a context.
356 356
357=item void B<SSL_CTX_set_verify>(SSL_CTX *ctx, int mode, int (*cb);(void)) 357=item void B<SSL_CTX_set_verify>(SSL_CTX *ctx, int mode, int (*cb);(void))
diff --git a/src/lib/libssl/src/doc/standards.txt b/src/lib/libssl/src/doc/standards.txt
index 596d9001e6..edbe2f3a57 100644
--- a/src/lib/libssl/src/doc/standards.txt
+++ b/src/lib/libssl/src/doc/standards.txt
@@ -42,20 +42,9 @@ whole or at least great parts) in OpenSSL.
422268 A Description of the RC2(r) Encryption Algorithm. R. Rivest. 422268 A Description of the RC2(r) Encryption Algorithm. R. Rivest.
43 January 1998. (Format: TXT=19048 bytes) (Status: INFORMATIONAL) 43 January 1998. (Format: TXT=19048 bytes) (Status: INFORMATIONAL)
44 44
452314 PKCS 10: Certification Request Syntax Version 1.5. B. Kaliski.
46 March 1998. (Format: TXT=15814 bytes) (Status: INFORMATIONAL)
47
482315 PKCS 7: Cryptographic Message Syntax Version 1.5. B. Kaliski. 452315 PKCS 7: Cryptographic Message Syntax Version 1.5. B. Kaliski.
49 March 1998. (Format: TXT=69679 bytes) (Status: INFORMATIONAL) 46 March 1998. (Format: TXT=69679 bytes) (Status: INFORMATIONAL)
50 47
512437 PKCS #1: RSA Cryptography Specifications Version 2.0. B. Kaliski,
52 J. Staddon. October 1998. (Format: TXT=73529 bytes) (Obsoletes
53 RFC2313) (Status: INFORMATIONAL)
54
552459 Internet X.509 Public Key Infrastructure Certificate and CRL
56 Profile. R. Housley, W. Ford, W. Polk, D. Solo. January 1999.
57 (Format: TXT=278438 bytes) (Status: PROPOSED STANDARD)
58
59PKCS#8: Private-Key Information Syntax Standard 48PKCS#8: Private-Key Information Syntax Standard
60 49
61PKCS#12: Personal Information Exchange Syntax Standard, version 1.0. 50PKCS#12: Personal Information Exchange Syntax Standard, version 1.0.
@@ -65,6 +54,40 @@ PKCS#12: Personal Information Exchange Syntax Standard, version 1.0.
65 C. Adams. June 1999. (Format: TXT=43243 bytes) (Status: PROPOSED 54 C. Adams. June 1999. (Format: TXT=43243 bytes) (Status: PROPOSED
66 STANDARD) 55 STANDARD)
67 56
572712 Addition of Kerberos Cipher Suites to Transport Layer Security
58 (TLS). A. Medvinsky, M. Hur. October 1999. (Format: TXT=13763 bytes)
59 (Status: PROPOSED STANDARD)
60
612898 PKCS #5: Password-Based Cryptography Specification Version 2.0.
62 B. Kaliski. September 2000. (Format: TXT=68692 bytes) (Status:
63 INFORMATIONAL)
64
652986 PKCS #10: Certification Request Syntax Specification Version 1.7.
66 M. Nystrom, B. Kaliski. November 2000. (Format: TXT=27794 bytes)
67 (Obsoletes RFC2314) (Status: INFORMATIONAL)
68
693174 US Secure Hash Algorithm 1 (SHA1). D. Eastlake 3rd, P. Jones.
70 September 2001. (Format: TXT=35525 bytes) (Status: INFORMATIONAL)
71
723268 Advanced Encryption Standard (AES) Ciphersuites for Transport
73 Layer Security (TLS). P. Chown. June 2002. (Format: TXT=13530 bytes)
74 (Status: PROPOSED STANDARD)
75
763279 Algorithms and Identifiers for the Internet X.509 Public Key
77 Infrastructure Certificate and Certificate Revocation List (CRL)
78 Profile. L. Bassham, W. Polk, R. Housley. April 2002. (Format:
79 TXT=53833 bytes) (Status: PROPOSED STANDARD)
80
813280 Internet X.509 Public Key Infrastructure Certificate and
82 Certificate Revocation List (CRL) Profile. R. Housley, W. Polk, W.
83 Ford, D. Solo. April 2002. (Format: TXT=295556 bytes) (Obsoletes
84 RFC2459) (Status: PROPOSED STANDARD)
85
863447 Public-Key Cryptography Standards (PKCS) #1: RSA Cryptography
87 Specifications Version 2.1. J. Jonsson, B. Kaliski. February 2003.
88 (Format: TXT=143173 bytes) (Obsoletes RFC2437) (Status:
89 INFORMATIONAL)
90
68 91
69Related: 92Related:
70-------- 93--------
@@ -90,23 +113,60 @@ STARTTLS documents.
90 Certification and Related Services. B. Kaliski. February 1993. 113 Certification and Related Services. B. Kaliski. February 1993.
91 (Format: TXT=17537 bytes) (Status: PROPOSED STANDARD) 114 (Format: TXT=17537 bytes) (Status: PROPOSED STANDARD)
92 115
932256 A Summary of the X.500(96) User Schema for use with LDAPv3. M. 1162025 The Simple Public-Key GSS-API Mechanism (SPKM). C. Adams. October
94 Wahl. December 1997. (Format: TXT=32377 bytes) (Status: PROPOSED 117 1996. (Format: TXT=101692 bytes) (Status: PROPOSED STANDARD)
95 STANDARD) 118
1192510 Internet X.509 Public Key Infrastructure Certificate Management
120 Protocols. C. Adams, S. Farrell. March 1999. (Format: TXT=158178
121 bytes) (Status: PROPOSED STANDARD)
122
1232511 Internet X.509 Certificate Request Message Format. M. Myers, C.
124 Adams, D. Solo, D. Kemp. March 1999. (Format: TXT=48278 bytes)
125 (Status: PROPOSED STANDARD)
126
1272527 Internet X.509 Public Key Infrastructure Certificate Policy and
128 Certification Practices Framework. S. Chokhani, W. Ford. March 1999.
129 (Format: TXT=91860 bytes) (Status: INFORMATIONAL)
96 130
972487 SMTP Service Extension for Secure SMTP over TLS. P. Hoffman. 1312538 Storing Certificates in the Domain Name System (DNS). D. Eastlake
98 January 1999. (Format: TXT=15120 bytes) (Status: PROPOSED STANDARD) 132 3rd, O. Gudmundsson. March 1999. (Format: TXT=19857 bytes) (Status:
133 PROPOSED STANDARD)
134
1352539 Storage of Diffie-Hellman Keys in the Domain Name System (DNS).
136 D. Eastlake 3rd. March 1999. (Format: TXT=21049 bytes) (Status:
137 PROPOSED STANDARD)
138
1392559 Internet X.509 Public Key Infrastructure Operational Protocols -
140 LDAPv2. S. Boeyen, T. Howes, P. Richard. April 1999. (Format:
141 TXT=22889 bytes) (Updates RFC1778) (Status: PROPOSED STANDARD)
99 142
1002585 Internet X.509 Public Key Infrastructure Operational Protocols: 1432585 Internet X.509 Public Key Infrastructure Operational Protocols:
101 FTP and HTTP. R. Housley, P. Hoffman. May 1999. (Format: TXT=14813 144 FTP and HTTP. R. Housley, P. Hoffman. May 1999. (Format: TXT=14813
102 bytes) (Status: PROPOSED STANDARD) 145 bytes) (Status: PROPOSED STANDARD)
103 146
1472587 Internet X.509 Public Key Infrastructure LDAPv2 Schema. S.
148 Boeyen, T. Howes, P. Richard. June 1999. (Format: TXT=15102 bytes)
149 (Status: PROPOSED STANDARD)
150
1042595 Using TLS with IMAP, POP3 and ACAP. C. Newman. June 1999. 1512595 Using TLS with IMAP, POP3 and ACAP. C. Newman. June 1999.
105 (Format: TXT=32440 bytes) (Status: PROPOSED STANDARD) 152 (Format: TXT=32440 bytes) (Status: PROPOSED STANDARD)
106 153
1072712 Addition of Kerberos Cipher Suites to Transport Layer Security 1542631 Diffie-Hellman Key Agreement Method. E. Rescorla. June 1999.
108 (TLS). A. Medvinsky, M. Hur. October 1999. (Format: TXT=13763 bytes) 155 (Format: TXT=25932 bytes) (Status: PROPOSED STANDARD)
109 (Status: PROPOSED STANDARD) 156
1572632 S/MIME Version 3 Certificate Handling. B. Ramsdell, Ed.. June
158 1999. (Format: TXT=27925 bytes) (Status: PROPOSED STANDARD)
159
1602716 PPP EAP TLS Authentication Protocol. B. Aboba, D. Simon. October
161 1999. (Format: TXT=50108 bytes) (Status: EXPERIMENTAL)
162
1632773 Encryption using KEA and SKIPJACK. R. Housley, P. Yee, W. Nace.
164 February 2000. (Format: TXT=20008 bytes) (Updates RFC0959) (Status:
165 EXPERIMENTAL)
166
1672797 Certificate Management Messages over CMS. M. Myers, X. Liu, J.
168 Schaad, J. Weinstein. April 2000. (Format: TXT=103357 bytes) (Status:
169 PROPOSED STANDARD)
110 170
1112817 Upgrading to TLS Within HTTP/1.1. R. Khare, S. Lawrence. May 1712817 Upgrading to TLS Within HTTP/1.1. R. Khare, S. Lawrence. May
112 2000. (Format: TXT=27598 bytes) (Updates RFC2616) (Status: PROPOSED 172 2000. (Format: TXT=27598 bytes) (Updates RFC2616) (Status: PROPOSED
@@ -115,6 +175,77 @@ STARTTLS documents.
1152818 HTTP Over TLS. E. Rescorla. May 2000. (Format: TXT=15170 bytes) 1752818 HTTP Over TLS. E. Rescorla. May 2000. (Format: TXT=15170 bytes)
116 (Status: INFORMATIONAL) 176 (Status: INFORMATIONAL)
117 177
1782876 Use of the KEA and SKIPJACK Algorithms in CMS. J. Pawling. July
179 2000. (Format: TXT=29265 bytes) (Status: INFORMATIONAL)
180
1812984 Use of the CAST-128 Encryption Algorithm in CMS. C. Adams.
182 October 2000. (Format: TXT=11591 bytes) (Status: PROPOSED STANDARD)
183
1842985 PKCS #9: Selected Object Classes and Attribute Types Version 2.0.
185 M. Nystrom, B. Kaliski. November 2000. (Format: TXT=70703 bytes)
186 (Status: INFORMATIONAL)
187
1883029 Internet X.509 Public Key Infrastructure Data Validation and
189 Certification Server Protocols. C. Adams, P. Sylvester, M. Zolotarev,
190 R. Zuccherato. February 2001. (Format: TXT=107347 bytes) (Status:
191 EXPERIMENTAL)
192
1933039 Internet X.509 Public Key Infrastructure Qualified Certificates
194 Profile. S. Santesson, W. Polk, P. Barzin, M. Nystrom. January 2001.
195 (Format: TXT=67619 bytes) (Status: PROPOSED STANDARD)
196
1973058 Use of the IDEA Encryption Algorithm in CMS. S. Teiwes, P.
198 Hartmann, D. Kuenzi. February 2001. (Format: TXT=17257 bytes)
199 (Status: INFORMATIONAL)
200
2013161 Internet X.509 Public Key Infrastructure Time-Stamp Protocol
202 (TSP). C. Adams, P. Cain, D. Pinkas, R. Zuccherato. August 2001.
203 (Format: TXT=54585 bytes) (Status: PROPOSED STANDARD)
204
2053185 Reuse of CMS Content Encryption Keys. S. Farrell, S. Turner.
206 October 2001. (Format: TXT=20404 bytes) (Status: PROPOSED STANDARD)
207
2083207 SMTP Service Extension for Secure SMTP over Transport Layer
209 Security. P. Hoffman. February 2002. (Format: TXT=18679 bytes)
210 (Obsoletes RFC2487) (Status: PROPOSED STANDARD)
211
2123217 Triple-DES and RC2 Key Wrapping. R. Housley. December 2001.
213 (Format: TXT=19855 bytes) (Status: INFORMATIONAL)
214
2153274 Compressed Data Content Type for Cryptographic Message Syntax
216 (CMS). P. Gutmann. June 2002. (Format: TXT=11276 bytes) (Status:
217 PROPOSED STANDARD)
218
2193278 Use of Elliptic Curve Cryptography (ECC) Algorithms in
220 Cryptographic Message Syntax (CMS). S. Blake-Wilson, D. Brown, P.
221 Lambert. April 2002. (Format: TXT=33779 bytes) (Status:
222 INFORMATIONAL)
223
2243281 An Internet Attribute Certificate Profile for Authorization. S.
225 Farrell, R. Housley. April 2002. (Format: TXT=90580 bytes) (Status:
226 PROPOSED STANDARD)
227
2283369 Cryptographic Message Syntax (CMS). R. Housley. August 2002.
229 (Format: TXT=113975 bytes) (Obsoletes RFC2630, RFC3211) (Status:
230 PROPOSED STANDARD)
231
2323370 Cryptographic Message Syntax (CMS) Algorithms. R. Housley. August
233 2002. (Format: TXT=51001 bytes) (Obsoletes RFC2630, RFC3211) (Status:
234 PROPOSED STANDARD)
235
2363377 Lightweight Directory Access Protocol (v3): Technical
237 Specification. J. Hodges, R. Morgan. September 2002. (Format:
238 TXT=9981 bytes) (Updates RFC2251, RFC2252, RFC2253, RFC2254, RFC2255,
239 RFC2256, RFC2829, RFC2830) (Status: PROPOSED STANDARD)
240
2413394 Advanced Encryption Standard (AES) Key Wrap Algorithm. J. Schaad,
242 R. Housley. September 2002. (Format: TXT=73072 bytes) (Status:
243 INFORMATIONAL)
244
2453436 Transport Layer Security over Stream Control Transmission
246 Protocol. A. Jungmaier, E. Rescorla, M. Tuexen. December 2002.
247 (Format: TXT=16333 bytes) (Status: PROPOSED STANDARD)
248
118 "Securing FTP with TLS", 01/27/2000, <draft-murray-auth-ftp-ssl-05.txt> 249 "Securing FTP with TLS", 01/27/2000, <draft-murray-auth-ftp-ssl-05.txt>
119 250
120 251
@@ -124,7 +255,3 @@ To be implemented:
124These are documents that describe things that are planed to be 255These are documents that describe things that are planed to be
125implemented in the hopefully short future. 256implemented in the hopefully short future.
126 257
1272712 Addition of Kerberos Cipher Suites to Transport Layer Security
128 (TLS). A. Medvinsky, M. Hur. October 1999. (Format: TXT=13763 bytes)
129 (Status: PROPOSED STANDARD)
130
diff --git a/src/lib/libssl/src/e_os.h b/src/lib/libssl/src/e_os.h
index 00edebe6d4..f7d09c5295 100644
--- a/src/lib/libssl/src/e_os.h
+++ b/src/lib/libssl/src/e_os.h
@@ -154,6 +154,13 @@ extern "C" {
154#define readsocket(s,b,n) recv((s),(b),(n),0) 154#define readsocket(s,b,n) recv((s),(b),(n),0)
155#define writesocket(s,b,n) send((s),(b),(n),0) 155#define writesocket(s,b,n) send((s),(b),(n),0)
156#define EADDRINUSE WSAEADDRINUSE 156#define EADDRINUSE WSAEADDRINUSE
157#elif defined(__DJGPP__)
158#define WATT32
159#define get_last_socket_error() errno
160#define clear_socket_error() errno=0
161#define closesocket(s) close_s(s)
162#define readsocket(s,b,n) read_s(s,b,n)
163#define writesocket(s,b,n) send(s,b,n,0)
157#elif defined(MAC_OS_pre_X) 164#elif defined(MAC_OS_pre_X)
158#define get_last_socket_error() errno 165#define get_last_socket_error() errno
159#define clear_socket_error() errno=0 166#define clear_socket_error() errno=0
@@ -194,6 +201,9 @@ extern "C" {
194# ifdef __DJGPP__ 201# ifdef __DJGPP__
195# include <unistd.h> 202# include <unistd.h>
196# include <sys/stat.h> 203# include <sys/stat.h>
204# include <sys/socket.h>
205# include <tcp.h>
206# include <netdb.h>
197# define _setmode setmode 207# define _setmode setmode
198# define _O_TEXT O_TEXT 208# define _O_TEXT O_TEXT
199# define _O_BINARY O_BINARY 209# define _O_BINARY O_BINARY
@@ -207,7 +217,7 @@ extern "C" {
207# define S_IFMT _S_IFMT 217# define S_IFMT _S_IFMT
208# endif 218# endif
209 219
210# if !defined(WINNT) 220# if !defined(WINNT) && !defined(__DJGPP__)
211# define NO_SYSLOG 221# define NO_SYSLOG
212# endif 222# endif
213# define NO_DIRENT 223# define NO_DIRENT
@@ -222,6 +232,10 @@ extern "C" {
222# include <io.h> 232# include <io.h>
223# include <fcntl.h> 233# include <fcntl.h>
224 234
235# ifdef OPENSSL_SYS_WINCE
236# include <winsock_extras.h>
237# endif
238
225# define ssize_t long 239# define ssize_t long
226 240
227# if defined (__BORLANDC__) 241# if defined (__BORLANDC__)
@@ -232,10 +246,11 @@ extern "C" {
232# define _kbhit kbhit 246# define _kbhit kbhit
233# endif 247# endif
234 248
235# if defined(WIN16) && !defined(MONOLITH) && defined(SSLEAY) && defined(_WINEXITNOPERSIST) 249# if defined(WIN16) && defined(SSLEAY) && defined(_WINEXITNOPERSIST)
236# define EXIT(n) { if (n == 0) _wsetexit(_WINEXITNOPERSIST); return(n); } 250# define EXIT(n) _wsetexit(_WINEXITNOPERSIST)
251# define OPENSSL_EXIT(n) do { if (n == 0) EXIT(n); return(n); } while(0)
237# else 252# else
238# define EXIT(n) return(n); 253# define EXIT(n) return(n)
239# endif 254# endif
240# define LIST_SEPARATOR_CHAR ';' 255# define LIST_SEPARATOR_CHAR ';'
241# ifndef X_OK 256# ifndef X_OK
@@ -251,7 +266,11 @@ extern "C" {
251# define SSLEAY_CONF OPENSSL_CONF 266# define SSLEAY_CONF OPENSSL_CONF
252# define NUL_DEV "nul" 267# define NUL_DEV "nul"
253# define RFILE ".rnd" 268# define RFILE ".rnd"
254# define DEFAULT_HOME "C:" 269# ifdef OPENSSL_SYS_WINCE
270# define DEFAULT_HOME ""
271# else
272# define DEFAULT_HOME "C:"
273# endif
255 274
256#else /* The non-microsoft world world */ 275#else /* The non-microsoft world world */
257 276
@@ -287,18 +306,13 @@ extern "C" {
287 the status is tagged as an error, which I believe is what is wanted here. 306 the status is tagged as an error, which I believe is what is wanted here.
288 -- Richard Levitte 307 -- Richard Levitte
289 */ 308 */
290# if !defined(MONOLITH) || defined(OPENSSL_C) 309# define EXIT(n) do { int __VMS_EXIT = n; \
291# define EXIT(n) do { int __VMS_EXIT = n; \
292 if (__VMS_EXIT == 0) \ 310 if (__VMS_EXIT == 0) \
293 __VMS_EXIT = 1; \ 311 __VMS_EXIT = 1; \
294 else \ 312 else \
295 __VMS_EXIT = (n << 3) | 2; \ 313 __VMS_EXIT = (n << 3) | 2; \
296 __VMS_EXIT |= 0x10000000; \ 314 __VMS_EXIT |= 0x10000000; \
297 exit(__VMS_EXIT); \ 315 exit(__VMS_EXIT); } while(0)
298 return(__VMS_EXIT); } while(0)
299# else
300# define EXIT(n) return(n)
301# endif
302# define NO_SYS_PARAM_H 316# define NO_SYS_PARAM_H
303# else 317# else
304 /* !defined VMS */ 318 /* !defined VMS */
@@ -329,11 +343,7 @@ extern "C" {
329# define RFILE ".rnd" 343# define RFILE ".rnd"
330# define LIST_SEPARATOR_CHAR ':' 344# define LIST_SEPARATOR_CHAR ':'
331# define NUL_DEV "/dev/null" 345# define NUL_DEV "/dev/null"
332# ifndef MONOLITH 346# define EXIT(n) exit(n)
333# define EXIT(n) exit(n); return(n)
334# else
335# define EXIT(n) return(n)
336# endif
337# endif 347# endif
338 348
339# define SSLeay_getpid() getpid() 349# define SSLeay_getpid() getpid()
@@ -344,7 +354,7 @@ extern "C" {
344/*************/ 354/*************/
345 355
346#ifdef USE_SOCKETS 356#ifdef USE_SOCKETS
347# if (defined(WINDOWS) || defined(MSDOS)) && !defined(__DJGPP__) 357# if defined(WINDOWS) || defined(MSDOS)
348 /* windows world */ 358 /* windows world */
349 359
350# ifdef OPENSSL_NO_SOCK 360# ifdef OPENSSL_NO_SOCK
@@ -352,13 +362,18 @@ extern "C" {
352# define SSLeay_Read(a,b,c) (-1) 362# define SSLeay_Read(a,b,c) (-1)
353# define SHUTDOWN(fd) close(fd) 363# define SHUTDOWN(fd) close(fd)
354# define SHUTDOWN2(fd) close(fd) 364# define SHUTDOWN2(fd) close(fd)
355# else 365# elif !defined(__DJGPP__)
356# include <winsock.h> 366# include <winsock.h>
357extern HINSTANCE _hInstance; 367extern HINSTANCE _hInstance;
358# define SSLeay_Write(a,b,c) send((a),(b),(c),0) 368# define SSLeay_Write(a,b,c) send((a),(b),(c),0)
359# define SSLeay_Read(a,b,c) recv((a),(b),(c),0) 369# define SSLeay_Read(a,b,c) recv((a),(b),(c),0)
360# define SHUTDOWN(fd) { shutdown((fd),0); closesocket(fd); } 370# define SHUTDOWN(fd) { shutdown((fd),0); closesocket(fd); }
361# define SHUTDOWN2(fd) { shutdown((fd),2); closesocket(fd); } 371# define SHUTDOWN2(fd) { shutdown((fd),2); closesocket(fd); }
372# else
373# define SSLeay_Write(a,b,c) write_s(a,b,c,0)
374# define SSLeay_Read(a,b,c) read_s(a,b,c)
375# define SHUTDOWN(fd) close_s(fd)
376# define SHUTDOWN2(fd) close_s(fd)
362# endif 377# endif
363 378
364# elif defined(MAC_OS_pre_X) 379# elif defined(MAC_OS_pre_X)
@@ -455,6 +470,14 @@ extern char *sys_errlist[]; extern int sys_nerr;
455 (((errnum)<0 || (errnum)>=sys_nerr) ? NULL : sys_errlist[errnum]) 470 (((errnum)<0 || (errnum)>=sys_nerr) ? NULL : sys_errlist[errnum])
456#endif 471#endif
457 472
473#ifndef OPENSSL_EXIT
474# if defined(MONOLITH) && !defined(OPENSSL_C)
475# define OPENSSL_EXIT(n) return(n)
476# else
477# define OPENSSL_EXIT(n) do { EXIT(n); return(n); } while(0)
478# endif
479#endif
480
458/***********************************************/ 481/***********************************************/
459 482
460/* do we need to do this for getenv. 483/* do we need to do this for getenv.
@@ -485,6 +508,36 @@ extern char *sys_errlist[]; extern int sys_nerr;
485# define strcasecmp stricmp 508# define strcasecmp stricmp
486#endif 509#endif
487 510
511/* vxworks */
512#if defined(OPENSSL_SYS_VXWORKS)
513#include <ioLib.h>
514#include <tickLib.h>
515#include <sysLib.h>
516
517#define TTY_STRUCT int
518
519#define sleep(a) taskDelay((a) * sysClkRateGet())
520#if defined(ioctlsocket)
521#undef ioctlsocket
522#endif
523#define ioctlsocket(a,b,c) ioctl((a),(b),*(c))
524
525#include <vxWorks.h>
526#include <sockLib.h>
527#include <taskLib.h>
528
529#define getpid taskIdSelf
530
531/* NOTE: these are implemented by helpers in database app!
532 * if the database is not linked, we need to implement them
533 * elswhere */
534struct hostent *gethostbyname(const char *name);
535struct hostent *gethostbyaddr(const char *addr, int length, int type);
536struct servent *getservbyname(const char *name, const char *proto);
537
538#endif
539/* end vxworks */
540
488#ifdef __cplusplus 541#ifdef __cplusplus
489} 542}
490#endif 543#endif
diff --git a/src/lib/libssl/src/e_os2.h b/src/lib/libssl/src/e_os2.h
index ff68d5b94a..81be3025f6 100644
--- a/src/lib/libssl/src/e_os2.h
+++ b/src/lib/libssl/src/e_os2.h
@@ -106,11 +106,15 @@ extern "C" {
106# undef OPENSSL_SYS_UNIX 106# undef OPENSSL_SYS_UNIX
107# define OPENSSL_SYS_WINNT 107# define OPENSSL_SYS_WINNT
108# endif 108# endif
109# if defined(OPENSSL_SYSNAME_WINCE)
110# undef OPENSSL_SYS_UNIX
111# define OPENSSL_SYS_WINCE
112# endif
109# endif 113# endif
110#endif 114#endif
111 115
112/* Anything that tries to look like Microsoft is "Windows" */ 116/* Anything that tries to look like Microsoft is "Windows" */
113#if defined(OPENSSL_SYS_WIN16) || defined(OPENSSL_SYS_WIN32) || defined(OPENSSL_SYS_WINNT) 117#if defined(OPENSSL_SYS_WIN16) || defined(OPENSSL_SYS_WIN32) || defined(OPENSSL_SYS_WINNT) || defined(OPENSSL_SYS_WINCE)
114# undef OPENSSL_SYS_UNIX 118# undef OPENSSL_SYS_UNIX
115# define OPENSSL_SYS_WINDOWS 119# define OPENSSL_SYS_WINDOWS
116# ifndef OPENSSL_SYS_MSDOS 120# ifndef OPENSSL_SYS_MSDOS
@@ -170,6 +174,13 @@ extern "C" {
170# ifdef OPENSSL_SYSNAME_MACOSX 174# ifdef OPENSSL_SYSNAME_MACOSX
171# define OPENSSL_SYS_MACOSX 175# define OPENSSL_SYS_MACOSX
172# endif 176# endif
177# ifdef OPENSSL_SYSNAME_MACOSX_RHAPSODY
178# define OPENSSL_SYS_MACOSX_RHAPSODY
179# define OPENSSL_SYS_MACOSX
180# endif
181# ifdef OPENSSL_SYSNAME_SUNOS
182# define OPENSSL_SYS_SUNOS
183#endif
173# if defined(_CRAY) || defined(OPENSSL_SYSNAME_CRAY) 184# if defined(_CRAY) || defined(OPENSSL_SYSNAME_CRAY)
174# define OPENSSL_SYS_CRAY 185# define OPENSSL_SYS_CRAY
175# endif 186# endif
@@ -178,6 +189,11 @@ extern "C" {
178# endif 189# endif
179#endif 190#endif
180 191
192/* ------------------------------- VxWorks --------------------------------- */
193#ifdef OPENSSL_SYSNAME_VXWORKS
194# define OPENSSL_SYS_VXWORKS
195#endif
196
181/** 197/**
182 * That's it for OS-specific stuff 198 * That's it for OS-specific stuff
183 *****************************************************************************/ 199 *****************************************************************************/
diff --git a/src/lib/libssl/src/makevms.com b/src/lib/libssl/src/makevms.com
index e5c1edbe0e..443f3c15c5 100644
--- a/src/lib/libssl/src/makevms.com
+++ b/src/lib/libssl/src/makevms.com
@@ -9,7 +9,7 @@ $!
9$! Changes by Richard Levitte <richard@levitte.org> 9$! Changes by Richard Levitte <richard@levitte.org>
10$! 10$!
11$! This procedure creates the SSL libraries of "[.xxx.EXE.CRYPTO]LIBCRYPTO.OLB" 11$! This procedure creates the SSL libraries of "[.xxx.EXE.CRYPTO]LIBCRYPTO.OLB"
12$! "[.xxx.EXE.SSL]LIBSSL.OLB" and if specified "[.xxx.EXE.RSAREF]LIBRSAGLUE.OLB". 12$! "[.xxx.EXE.SSL]LIBSSL.OLB"
13$! The "xxx" denotes the machine architecture of AXP or VAX. 13$! The "xxx" denotes the machine architecture of AXP or VAX.
14$! 14$!
15$! This procedures accepts two command line options listed below. 15$! This procedures accepts two command line options listed below.
@@ -21,7 +21,6 @@ $! CONFIG Just build the "[.CRYPTO]OPENSSLCONF.H" file.
21$! BUILDINF Just build the "[.CRYPTO]BUILDINF.H" file. 21$! BUILDINF Just build the "[.CRYPTO]BUILDINF.H" file.
22$! SOFTLINKS Just fix the Unix soft links. 22$! SOFTLINKS Just fix the Unix soft links.
23$! BUILDALL Same as ALL, except CONFIG, BUILDINF and SOFTILNKS aren't done. 23$! BUILDALL Same as ALL, except CONFIG, BUILDINF and SOFTILNKS aren't done.
24$! RSAREF Just build the "[.xxx.EXE.RSAREF]LIBRSAGLUE.OLB" library.
25$! CRYPTO Just build the "[.xxx.EXE.CRYPTO]LIBCRYPTO.OLB" library. 24$! CRYPTO Just build the "[.xxx.EXE.CRYPTO]LIBCRYPTO.OLB" library.
26$! CRYPTO/x Just build the x part of the 25$! CRYPTO/x Just build the x part of the
27$! "[.xxx.EXE.CRYPTO]LIBCRYPTO.OLB" library. 26$! "[.xxx.EXE.CRYPTO]LIBCRYPTO.OLB" library.
@@ -31,16 +30,8 @@ $! TEST Just build the "[.xxx.EXE.TEST]" test programs for OpenSSL.
31$! APPS Just build the "[.xxx.EXE.APPS]" application programs for OpenSSL. 30$! APPS Just build the "[.xxx.EXE.APPS]" application programs for OpenSSL.
32$! 31$!
33$! 32$!
34$! Specify RSAREF as P2 to compile using the RSAREF Library. 33$! P2 is ignored (it was used to denote if RSAref should be used or not,
35$! If you specify NORSAREF, it will compile without using RSAREF. 34$! and is simply kept so surrounding scripts don't get confused)
36$! (If in the United States, You Must Compile Using RSAREF).
37$!
38$! Note: The RSAREF libraries are NOT INCLUDED and you have to
39$! download it from "ftp://ftp.rsa.com/rsaref". You have to
40$! get the ".tar-Z" file as the ".zip" file dosen't have the
41$! directory structure stored. You have to extract the file
42$! into the [.RSAREF] directory as that is where the scripts
43$! will look for the files.
44$! 35$!
45$! Speficy DEBUG or NODEBUG as P3 to compile with or without debugging 36$! Speficy DEBUG or NODEBUG as P3 to compile with or without debugging
46$! information. 37$! information.
@@ -127,20 +118,6 @@ $!
127$ IF (BUILDCOMMAND.EQS."ALL".OR.BUILDCOMMAND.EQS."BUILDALL") 118$ IF (BUILDCOMMAND.EQS."ALL".OR.BUILDCOMMAND.EQS."BUILDALL")
128$ THEN 119$ THEN
129$! 120$!
130$! Check To See If We Are Going To Be Building The
131$! [.xxx.EXE.RSAREF]LIBRSAGLUE.OLB Library.
132$!
133$ IF (RSAREF.EQS."RSAREF")
134$ THEN
135$!
136$! Build The [.xxx.EXE.RSAREF]LIBRSAGLUE.OLB Library.
137$!
138$ GOSUB RSAREF
139$!
140$! End The RSAREF Check.
141$!
142$ ENDIF
143$!
144$! Build The [.xxx.EXE.CRYPTO]LIBCRYPTO.OLB Library. 121$! Build The [.xxx.EXE.CRYPTO]LIBCRYPTO.OLB Library.
145$! 122$!
146$ GOSUB CRYPTO 123$ GOSUB CRYPTO
@@ -498,11 +475,6 @@ $ ENDIF
498$ GOTO LOOP_SDIRS 475$ GOTO LOOP_SDIRS
499$ LOOP_SDIRS_END: 476$ LOOP_SDIRS_END:
500$! 477$!
501$! Copy All The ".H" Files From The [.RSAREF] Directory.
502$!
503$! EXHEADER := rsaref.h
504$! COPY SYS$DISK:[.RSAREF]'EXHEADER' SYS$DISK:[.INCLUDE.OPENSSL]
505$!
506$! Copy All The ".H" Files From The [.SSL] Directory. 478$! Copy All The ".H" Files From The [.SSL] Directory.
507$! 479$!
508$ EXHEADER := ssl.h,ssl2.h,ssl3.h,ssl23.h,tls1.h,kssl.h 480$ EXHEADER := ssl.h,ssl2.h,ssl3.h,ssl23.h,tls1.h,kssl.h
@@ -531,11 +503,11 @@ $ SET DEFAULT SYS$DISK:[.CRYPTO]
531$! 503$!
532$! Build The [.xxx.EXE.CRYPTO]LIBCRYPTO.OLB Library. 504$! Build The [.xxx.EXE.CRYPTO]LIBCRYPTO.OLB Library.
533$! 505$!
534$ @CRYPTO-LIB LIBRARY 'RSAREF' 'DEBUGGER' "''COMPILER'" "''TCPIP_TYPE'" "''ISSEVEN'" "''BUILDPART'" 506$ @CRYPTO-LIB LIBRARY 'DEBUGGER' "''COMPILER'" "''TCPIP_TYPE'" "''ISSEVEN'" "''BUILDPART'"
535$! 507$!
536$! Build The [.xxx.EXE.CRYPTO]*.EXE Test Applications. 508$! Build The [.xxx.EXE.CRYPTO]*.EXE Test Applications.
537$! 509$!
538$ @CRYPTO-LIB APPS 'RSAREF' 'DEBUGGER' "''COMPILER'" "''TCPIP_TYPE'" 'ISSEVEN' 510$ @CRYPTO-LIB APPS 'DEBUGGER' "''COMPILER'" "''TCPIP_TYPE'" 'ISSEVEN'
539$! 511$!
540$! Go Back To The Main Directory. 512$! Go Back To The Main Directory.
541$! 513$!
@@ -545,34 +517,6 @@ $! Time To RETURN.
545$! 517$!
546$ RETURN 518$ RETURN
547$! 519$!
548$! Build The [.xxx.EXE.RSAREF]LIBRSAGLUE Library.
549$!
550$ RSAREF:
551$ WRITE SYS$OUTPUT ""
552$ WRITE SYS$OUTPUT "RSAref glue library not built, since it's no longer needed"
553$ RETURN
554$!
555$! Tell The User What We Are Doing.
556$!
557$ WRITE SYS$OUTPUT ""
558$ WRITE SYS$OUTPUT "Building The [.",ARCH,".EXE.RSAREF]LIBRSAGLUE.OLB Library."
559$!
560$! Go To The [.RSAREF] Directory.
561$!
562$ SET DEFAULT SYS$DISK:[.RSAREF]
563$!
564$! Build The [.xxx.EXE.RSAREF]LIBRSAGLUE.OLB Library.
565$!
566$ @RSAREF-LIB LIBRARY 'DEBUGGER' "''COMPILER'" 'ISSEVEN'
567$!
568$! Go Back To The Main Directory.
569$!
570$ SET DEFAULT [-]
571$!
572$! Time To Return.
573$!
574$ RETURN
575$!
576$! Build The "[.xxx.EXE.SSL]LIBSSL.OLB" Library. 520$! Build The "[.xxx.EXE.SSL]LIBSSL.OLB" Library.
577$! 521$!
578$ SSL: 522$ SSL:
@@ -588,7 +532,7 @@ $ SET DEFAULT SYS$DISK:[.SSL]
588$! 532$!
589$! Build The [.xxx.EXE.SSL]LIBSSL.OLB Library. 533$! Build The [.xxx.EXE.SSL]LIBSSL.OLB Library.
590$! 534$!
591$ @SSL-LIB LIBRARY 'RSAREF' 'DEBUGGER' "''COMPILER'" "''TCPIP_TYPE'" 'ISSEVEN' 535$ @SSL-LIB LIBRARY 'DEBUGGER' "''COMPILER'" "''TCPIP_TYPE'" 'ISSEVEN'
592$! 536$!
593$! Go Back To The Main Directory. 537$! Go Back To The Main Directory.
594$! 538$!
@@ -613,7 +557,7 @@ $ SET DEFAULT SYS$DISK:[.SSL]
613$! 557$!
614$! Build The [.xxx.EXE.SSL]SSL_TASK.EXE 558$! Build The [.xxx.EXE.SSL]SSL_TASK.EXE
615$! 559$!
616$ @SSL-LIB SSL_TASK 'RSAREF' 'DEBUGGER' "''COMPILER'" "''TCPIP_TYPE'" 'ISSEVEN' 560$ @SSL-LIB SSL_TASK 'DEBUGGER' "''COMPILER'" "''TCPIP_TYPE'" 'ISSEVEN'
617$! 561$!
618$! Go Back To The Main Directory. 562$! Go Back To The Main Directory.
619$! 563$!
@@ -638,7 +582,7 @@ $ SET DEFAULT SYS$DISK:[.TEST]
638$! 582$!
639$! Build The Test Programs. 583$! Build The Test Programs.
640$! 584$!
641$ @MAKETESTS 'RSAREF' 'DEBUGGER' "''COMPILER'" "''TCPIP_TYPE'" 'ISSEVEN' 585$ @MAKETESTS 'DEBUGGER' "''COMPILER'" "''TCPIP_TYPE'" 'ISSEVEN'
642$! 586$!
643$! Go Back To The Main Directory. 587$! Go Back To The Main Directory.
644$! 588$!
@@ -663,7 +607,7 @@ $ SET DEFAULT SYS$DISK:[.APPS]
663$! 607$!
664$! Build The Application Programs. 608$! Build The Application Programs.
665$! 609$!
666$ @MAKEAPPS 'RSAREF' 'DEBUGGER' "''COMPILER'" "''TCPIP_TYPE'" 'ISSEVEN' 610$ @MAKEAPPS 'DEBUGGER' "''COMPILER'" "''TCPIP_TYPE'" 'ISSEVEN'
667$! 611$!
668$! Go Back To The Main Directory. 612$! Go Back To The Main Directory.
669$! 613$!
@@ -704,7 +648,7 @@ $! Else, Check To See If P1 Has A Valid Arguement.
704$! 648$!
705$ IF (P1.EQS."CONFIG").OR.(P1.EQS."BUILDINF").OR.(P1.EQS."SOFTLINKS") - 649$ IF (P1.EQS."CONFIG").OR.(P1.EQS."BUILDINF").OR.(P1.EQS."SOFTLINKS") -
706 .OR.(P1.EQS."BUILDALL") - 650 .OR.(P1.EQS."BUILDALL") -
707 .OR.(P1.EQS."CRYPTO").OR.(P1.EQS."SSL").OR.(P1.EQS."RSAREF") - 651 .OR.(P1.EQS."CRYPTO").OR.(P1.EQS."SSL") -
708 .OR.(P1.EQS."SSL_TASK").OR.(P1.EQS."TEST").OR.(P1.EQS."APPS") 652 .OR.(P1.EQS."SSL_TASK").OR.(P1.EQS."TEST").OR.(P1.EQS."APPS")
709$ THEN 653$ THEN
710$! 654$!
@@ -752,54 +696,6 @@ $! End The P1 Check.
752$! 696$!
753$ ENDIF 697$ ENDIF
754$! 698$!
755$! Check To See If P2 Is Blank.
756$!
757$ P2 = "NORSAREF"
758$ IF (P2.EQS."NORSAREF")
759$ THEN
760$!
761$! P2 Is NORSAREF, So Compile Without RSAREF.
762$!
763$ RSAREF = "NORSAREF"
764$!
765$! Else...
766$!
767$ ELSE
768$!
769$! Check To See If We Are To Compile Using The RSAREF Library.
770$!
771$ IF (P2.EQS."RSAREF")
772$ THEN
773$!
774$! Compile With RSAREF Library.
775$!
776$ RSAREF = "RSAREF"
777$!
778$! Else...
779$!
780$ ELSE
781$!
782$! Tell The User Entered An Invalid Option..
783$!
784$ WRITE SYS$OUTPUT ""
785$ WRITE SYS$OUTPUT "The Option ",P2," Is Invalid. The Valid Options Are:"
786$ WRITE SYS$OUTPUT ""
787$ WRITE SYS$OUTPUT " RSAREF : To Compile With The RSAREF Library."
788$ WRITE SYS$OUTPUT " NORSAREF : To Compile With The Regular RSA Library."
789$ WRITE SYS$OUTPUT ""
790$!
791$! Time To EXIT.
792$!
793$ EXIT
794$!
795$! End The Valid Arguemnt Check.
796$!
797$ ENDIF
798$!
799$! End The P2 Check.
800$!
801$ ENDIF
802$!
803$! Check To See If P3 Is Blank. 699$! Check To See If P3 Is Blank.
804$! 700$!
805$ IF (P3.EQS."NODEBUG") 701$ IF (P3.EQS."NODEBUG")
diff --git a/src/lib/libssl/src/ms/do_ms.bat b/src/lib/libssl/src/ms/do_ms.bat
index 5cbc6f7d5f..a8cf515bac 100644
--- a/src/lib/libssl/src/ms/do_ms.bat
+++ b/src/lib/libssl/src/ms/do_ms.bat
@@ -5,6 +5,8 @@ rem perl util\mk1mf.pl VC-W31-32 >ms\w31.mak
5perl util\mk1mf.pl dll VC-W31-32 >ms\w31dll.mak 5perl util\mk1mf.pl dll VC-W31-32 >ms\w31dll.mak
6perl util\mk1mf.pl no-asm VC-WIN32 >ms\nt.mak 6perl util\mk1mf.pl no-asm VC-WIN32 >ms\nt.mak
7perl util\mk1mf.pl dll no-asm VC-WIN32 >ms\ntdll.mak 7perl util\mk1mf.pl dll no-asm VC-WIN32 >ms\ntdll.mak
8perl util\mk1mf.pl no-asm VC-CE >ms\ce.mak
9perl util\mk1mf.pl dll no-asm VC-CE >ms\cedll.mak
8 10
9perl util\mkdef.pl 16 libeay > ms\libeay16.def 11perl util\mkdef.pl 16 libeay > ms\libeay16.def
10perl util\mkdef.pl 32 libeay > ms\libeay32.def 12perl util\mkdef.pl 32 libeay > ms\libeay32.def
diff --git a/src/lib/libssl/src/ms/mingw32.bat b/src/lib/libssl/src/ms/mingw32.bat
index 1968f4150b..8c7c63e0f2 100644
--- a/src/lib/libssl/src/ms/mingw32.bat
+++ b/src/lib/libssl/src/ms/mingw32.bat
@@ -1,7 +1,7 @@
1@rem OpenSSL with Mingw32+GNU as 1@rem OpenSSL with Mingw32+GNU as
2@rem --------------------------- 2@rem ---------------------------
3 3
4perl Configure Mingw32 %1 %2 %3 %4 %5 %6 %7 %8 4perl Configure mingw %1 %2 %3 %4 %5 %6 %7 %8
5 5
6@echo off 6@echo off
7 7
@@ -66,21 +66,16 @@ cd ..\..\..
66echo Generating makefile 66echo Generating makefile
67perl util\mkfiles.pl >MINFO 67perl util\mkfiles.pl >MINFO
68perl util\mk1mf.pl gaswin Mingw32 >ms\mingw32a.mak 68perl util\mk1mf.pl gaswin Mingw32 >ms\mingw32a.mak
69perl util\mk1mf.pl gaswin Mingw32-files >ms\mingw32f.mak
70echo Generating DLL definition files 69echo Generating DLL definition files
71perl util\mkdef.pl 32 libeay >ms\libeay32.def 70perl util\mkdef.pl 32 libeay >ms\libeay32.def
72if errorlevel 1 goto end 71if errorlevel 1 goto end
73perl util\mkdef.pl 32 ssleay >ms\ssleay32.def 72perl util\mkdef.pl 32 ssleay >ms\ssleay32.def
74if errorlevel 1 goto end 73if errorlevel 1 goto end
75 74
76rem Create files -- this can be skipped if using the GNU file utilities 75rem copy ms\tlhelp32.h outinc
77make -f ms/mingw32f.mak
78echo You can ignore the error messages above
79
80copy ms\tlhelp32.h outinc
81 76
82echo Building the libraries 77echo Building the libraries
83make -f ms/mingw32a.mak 78mingw32-make -f ms/mingw32a.mak
84if errorlevel 1 goto end 79if errorlevel 1 goto end
85 80
86echo Generating the DLLs and input libraries 81echo Generating the DLLs and input libraries
diff --git a/src/lib/libssl/src/ms/mw.bat b/src/lib/libssl/src/ms/mw.bat
index dc37913b71..c5ccd693e3 100644
--- a/src/lib/libssl/src/ms/mw.bat
+++ b/src/lib/libssl/src/ms/mw.bat
@@ -4,17 +4,12 @@
4@rem Makefile 4@rem Makefile
5perl util\mkfiles.pl >MINFO 5perl util\mkfiles.pl >MINFO
6perl util\mk1mf.pl Mingw32 >ms\mingw32.mak 6perl util\mk1mf.pl Mingw32 >ms\mingw32.mak
7perl util\mk1mf.pl Mingw32-files >ms\mingw32f.mak
8@rem DLL definition files 7@rem DLL definition files
9perl util\mkdef.pl 32 libeay >ms\libeay32.def 8perl util\mkdef.pl 32 libeay >ms\libeay32.def
10if errorlevel 1 goto end 9if errorlevel 1 goto end
11perl util\mkdef.pl 32 ssleay >ms\ssleay32.def 10perl util\mkdef.pl 32 ssleay >ms\ssleay32.def
12if errorlevel 1 goto end 11if errorlevel 1 goto end
13 12
14@rem Create files -- this can be skipped if using the GNU file utilities
15make -f ms/mingw32f.mak
16echo You can ignore the error messages above
17
18@rem Build the libraries 13@rem Build the libraries
19make -f ms/mingw32.mak 14make -f ms/mingw32.mak
20if errorlevel 1 goto end 15if errorlevel 1 goto end
diff --git a/src/lib/libssl/src/ms/tencce.bat b/src/lib/libssl/src/ms/tencce.bat
new file mode 100644
index 0000000000..6a944d7671
--- /dev/null
+++ b/src/lib/libssl/src/ms/tencce.bat
@@ -0,0 +1,19 @@
1rem called by testencce
2
3echo test %1 %2 %3 %4 %5 %6
4cecopy %input% CE:\OpenSSL
5cerun CE:\OpenSSL\%ssleay% %1 %2 %3 %4 %5 %6 -e -bufsize 113 -k test -in \OpenSSL\%input% -out \OpenSSL\%tmp1%
6cerun CE:\OpenSSL\%ssleay% %1 %2 %3 %4 %5 %6 -d -bufsize 157 -k test -in \OpenSSL\%tmp1% -out \OpenSSL\%out1%
7del %out1% >nul 2>&1
8cecopy CE:\OpenSSL\%out1% .
9%cmp% %input% %out1%
10if errorlevel 1 goto err
11
12echo test base64 %1 %2 %3 %4 %5 %6
13cerun CE:\OpenSSL\%ssleay% %1 %2 %3 %4 %5 %6 -a -e -bufsize 113 -k test -in \OpenSSL\%input% -out \OpenSSL\%tmp1%
14cerun CE:\OpenSSL\%ssleay% %1 %2 %3 %4 %5 %6 -a -d -bufsize 157 -k test -in \OpenSSL\%tmp1% -out \OpenSSL\%out1%
15del %out1% >nul 2>&1
16cecopy CE:\OpenSSL\%out1% .
17%cmp% %input% %out1%
18
19:err
diff --git a/src/lib/libssl/src/ms/test.bat b/src/lib/libssl/src/ms/test.bat
index 8f69194283..c3a1b0c28d 100644
--- a/src/lib/libssl/src/ms/test.bat
+++ b/src/lib/libssl/src/ms/test.bat
@@ -67,6 +67,10 @@ echo dsatest
67dsatest 67dsatest
68if errorlevel 1 goto done 68if errorlevel 1 goto done
69 69
70echo ectest
71ectest
72if errorlevel 1 goto done
73
70echo testenc 74echo testenc
71call %test%\testenc openssl 75call %test%\testenc openssl
72if errorlevel 1 goto done 76if errorlevel 1 goto done
diff --git a/src/lib/libssl/src/ms/testce.bat b/src/lib/libssl/src/ms/testce.bat
new file mode 100644
index 0000000000..2ab010be6a
--- /dev/null
+++ b/src/lib/libssl/src/ms/testce.bat
@@ -0,0 +1,234 @@
1@echo off
2
3cemkdir CE:\OpenSSL
4
5set test=..\ms
6set opath=%PATH%
7PATH=..\ms;%PATH%
8cecopy ..\apps\openssl.cnf CE:\OpenSSL
9set OPENSSL_CONF=\OpenSSL\openssl.cnf
10set HOME=\OpenSSL
11set CERUN_PASS_ENV=OPENSSL_CONF HOME
12
13rem run this from inside the bin directory
14
15rem Copy the DLL's (though they'll only exist if we're in out32dll)
16if exist libeay32.dll cecopy libeay32.dll CE:\OpenSSL
17if exist ssleay32.dll cecopy ssleay32.dll CE:\OpenSSL
18
19echo rsa_test
20call %test%\testce2 rsa_test
21if errorlevel 1 goto done
22
23echo destest
24call %test%\testce2 destest
25if errorlevel 1 goto done
26
27echo ideatest
28call %test%\testce2 ideatest
29if errorlevel 1 goto done
30
31echo bftest
32call %test%\testce2 bftest
33if errorlevel 1 goto done
34
35echo shatest
36call %test%\testce2 shatest
37if errorlevel 1 goto done
38
39echo sha1test
40call %test%\testce2 sha1test
41if errorlevel 1 goto done
42
43echo md5test
44call %test%\testce2 md5test
45if errorlevel 1 goto done
46
47echo md2test
48call %test%\testce2 md2test
49if errorlevel 1 goto done
50
51echo mdc2test
52call %test%\testce2 mdc2test
53if errorlevel 1 goto done
54
55echo rc2test
56call %test%\testce2 rc2test
57if errorlevel 1 goto done
58
59echo rc4test
60call %test%\testce2 rc4test
61if errorlevel 1 goto done
62
63echo randtest
64call %test%\testce2 randtest
65if errorlevel 1 goto done
66
67echo dhtest
68call %test%\testce2 dhtest
69if errorlevel 1 goto done
70
71echo exptest
72call %test%\testce2 exptest
73if errorlevel 1 goto done
74
75echo dsatest
76call %test%\testce2 dsatest
77if errorlevel 1 goto done
78
79echo testenc
80call %test%\testencce openssl.exe
81if errorlevel 1 goto done
82
83echo testpem
84call %test%\testpemce openssl.exe
85if errorlevel 1 goto done
86
87cecopy openssl.exe CE:\OpenSSL
88
89echo verify
90copy ..\certs\*.pem cert.tmp >nul
91cecopy cert.tmp CE:\OpenSSL
92cemkdir CE:\OpenSSL\certs
93rem cecopy ..\certs\*.pem CE:\OpenSSL\certs
94cecopy ..\certs\ca-cert.pem CE:\OpenSSL\certs
95cecopy ..\certs\dsa-ca.pem CE:\OpenSSL\certs
96cecopy ..\certs\dsa-pca.pem CE:\OpenSSL\certs
97cecopy ..\certs\factory.pem CE:\OpenSSL\certs
98cecopy ..\certs\ICE-CA.pem CE:\OpenSSL\certs
99cecopy ..\certs\ICE-root.pem CE:\OpenSSL\certs
100cecopy ..\certs\ICE-user.pem CE:\OpenSSL\certs
101cecopy ..\certs\nortelCA.pem CE:\OpenSSL\certs
102cecopy ..\certs\pca-cert.pem CE:\OpenSSL\certs
103cecopy ..\certs\RegTP-4R.pem CE:\OpenSSL\certs
104cecopy ..\certs\RegTP-5R.pem CE:\OpenSSL\certs
105cecopy ..\certs\RegTP-6R.pem CE:\OpenSSL\certs
106cecopy ..\certs\rsa-cca.pem CE:\OpenSSL\certs
107cecopy ..\certs\thawteCb.pem CE:\OpenSSL\certs
108cecopy ..\certs\thawteCp.pem CE:\OpenSSL\certs
109cecopy ..\certs\timCA.pem CE:\OpenSSL\certs
110cecopy ..\certs\tjhCA.pem CE:\OpenSSL\certs
111cecopy ..\certs\vsign1.pem CE:\OpenSSL\certs
112cecopy ..\certs\vsign2.pem CE:\OpenSSL\certs
113cecopy ..\certs\vsign3.pem CE:\OpenSSL\certs
114cecopy ..\certs\vsignss.pem CE:\OpenSSL\certs
115cecopy ..\certs\vsigntca.pem CE:\OpenSSL\certs
116cerun CE:\OpenSSL\openssl verify -CAfile \OpenSSL\cert.tmp \OpenSSL\certs\*.pem
117
118echo testss
119call %test%\testssce openssl.exe
120if errorlevel 1 goto done
121
122cecopy ssltest.exe CE:\OpenSSL
123cecopy ..\apps\server.pem CE:\OpenSSL
124cecopy ..\apps\client.pem CE:\OpenSSL
125
126echo test sslv2
127cerun CE:\OpenSSL\ssltest -ssl2
128if errorlevel 1 goto done
129
130echo test sslv2 with server authentication
131cerun CE:\OpenSSL\ssltest -ssl2 -server_auth -CAfile \OpenSSL\cert.tmp
132if errorlevel 1 goto done
133
134echo test sslv2 with client authentication
135cerun CE:\OpenSSL\ssltest -ssl2 -client_auth -CAfile \OpenSSL\cert.tmp
136if errorlevel 1 goto done
137
138echo test sslv2 with both client and server authentication
139cerun CE:\OpenSSL\ssltest -ssl2 -server_auth -client_auth -CAfile \OpenSSL\cert.tmp
140if errorlevel 1 goto done
141
142echo test sslv3
143cerun CE:\OpenSSL\ssltest -ssl3
144if errorlevel 1 goto done
145
146echo test sslv3 with server authentication
147cerun CE:\OpenSSL\ssltest -ssl3 -server_auth -CAfile \OpenSSL\cert.tmp
148if errorlevel 1 goto done
149
150echo test sslv3 with client authentication
151cerun CE:\OpenSSL\ssltest -ssl3 -client_auth -CAfile \OpenSSL\cert.tmp
152if errorlevel 1 goto done
153
154echo test sslv3 with both client and server authentication
155cerun CE:\OpenSSL\ssltest -ssl3 -server_auth -client_auth -CAfile \OpenSSL\cert.tmp
156if errorlevel 1 goto done
157
158echo test sslv2/sslv3
159cerun CE:\OpenSSL\ssltest
160if errorlevel 1 goto done
161
162echo test sslv2/sslv3 with server authentication
163cerun CE:\OpenSSL\ssltest -server_auth -CAfile \OpenSSL\cert.tmp
164if errorlevel 1 goto done
165
166echo test sslv2/sslv3 with client authentication
167cerun CE:\OpenSSL\ssltest -client_auth -CAfile \OpenSSL\cert.tmp
168if errorlevel 1 goto done
169
170echo test sslv2/sslv3 with both client and server authentication
171cerun CE:\OpenSSL\ssltest -server_auth -client_auth -CAfile \OpenSSL\cert.tmp
172if errorlevel 1 goto done
173
174echo test sslv2 via BIO pair
175cerun CE:\OpenSSL\ssltest -bio_pair -ssl2
176if errorlevel 1 goto done
177
178echo test sslv2/sslv3 with 1024 bit DHE via BIO pair
179cerun CE:\OpenSSL\ssltest -bio_pair -dhe1024dsa -v
180if errorlevel 1 goto done
181
182echo test sslv2 with server authentication via BIO pair
183cerun CE:\OpenSSL\ssltest -bio_pair -ssl2 -server_auth -CAfile \OpenSSL\cert.tmp
184if errorlevel 1 goto done
185
186echo test sslv2 with client authentication via BIO pair
187cerun CE:\OpenSSL\ssltest -bio_pair -ssl2 -client_auth -CAfile \OpenSSL\cert.tmp
188if errorlevel 1 goto done
189
190echo test sslv2 with both client and server authentication via BIO pair
191cerun CE:\OpenSSL\ssltest -bio_pair -ssl2 -server_auth -client_auth -CAfile \OpenSSL\cert.tmp
192if errorlevel 1 goto done
193
194echo test sslv3 via BIO pair
195cerun CE:\OpenSSL\ssltest -bio_pair -ssl3
196if errorlevel 1 goto done
197
198echo test sslv3 with server authentication via BIO pair
199cerun CE:\OpenSSL\ssltest -bio_pair -ssl3 -server_auth -CAfile \OpenSSL\cert.tmp
200if errorlevel 1 goto done
201
202echo test sslv3 with client authentication via BIO pair
203cerun CE:\OpenSSL\ssltest -bio_pair -ssl3 -client_auth -CAfile \OpenSSL\cert.tmp
204if errorlevel 1 goto done
205
206echo test sslv3 with both client and server authentication via BIO pair
207cerun CE:\OpenSSL\ssltest -bio_pair -ssl3 -server_auth -client_auth -CAfile \OpenSSL\cert.tmp
208if errorlevel 1 goto done
209
210echo test sslv2/sslv3 via BIO pair
211cerun CE:\OpenSSL\ssltest
212if errorlevel 1 goto done
213
214echo test sslv2/sslv3 with server authentication
215cerun CE:\OpenSSL\ssltest -bio_pair -server_auth -CAfile \OpenSSL\cert.tmp
216if errorlevel 1 goto done
217
218echo test sslv2/sslv3 with client authentication via BIO pair
219cerun CE:\OpenSSL\ssltest -bio_pair -client_auth -CAfile \OpenSSL\cert.tmp
220if errorlevel 1 goto done
221
222echo test sslv2/sslv3 with both client and server authentication via BIO pair
223cerun CE:\OpenSSL\ssltest -bio_pair -server_auth -client_auth -CAfile \OpenSSL\cert.tmp
224if errorlevel 1 goto done
225
226del cert.tmp
227
228echo passed all tests
229goto end
230:done
231echo problems.....
232:end
233PATH=%opath%
234
diff --git a/src/lib/libssl/src/ms/testce2.bat b/src/lib/libssl/src/ms/testce2.bat
new file mode 100644
index 0000000000..24265b948f
--- /dev/null
+++ b/src/lib/libssl/src/ms/testce2.bat
@@ -0,0 +1,2 @@
1cecopy %1.exe CE:\OpenSSL
2cerun CE:\OpenSSL\%1 %2 %3 %4 %5 %6 %7 %8 %9
diff --git a/src/lib/libssl/src/ms/testenc.bat b/src/lib/libssl/src/ms/testenc.bat
index e8917eeee2..4b99bd5895 100644
--- a/src/lib/libssl/src/ms/testenc.bat
+++ b/src/lib/libssl/src/ms/testenc.bat
@@ -1,6 +1,6 @@
1 1@echo off
2echo start testenc 2echo start testenc
3echo=off 3
4path=..\ms;%path% 4path=..\ms;%path%
5set ssleay=%1% 5set ssleay=%1%
6set input=..\ms\testenc.bat 6set input=..\ms\testenc.bat
diff --git a/src/lib/libssl/src/ms/testencce.bat b/src/lib/libssl/src/ms/testencce.bat
new file mode 100644
index 0000000000..04faa5d99b
--- /dev/null
+++ b/src/lib/libssl/src/ms/testencce.bat
@@ -0,0 +1,97 @@
1@echo off
2echo start testenc
3
4path=..\ms;%path%
5set ssleay=%1%
6copy ..\ms\testenc.bat >nul
7set input=testenc.bat
8set tmp1=cipher.out
9set out1=clear.out
10set cmp=perl ..\ms\cmp.pl
11
12cecopy %ssleay% CE:\OpenSSL
13
14cd
15call tencce.bat enc
16if errorlevel 1 goto err
17
18call tencce.bat rc4
19if errorlevel 1 goto err
20
21call tencce.bat des-cfb
22if errorlevel 1 goto err
23
24call tencce.bat des-ede-cfb
25if errorlevel 1 goto err
26
27call tencce.bat des-ede3-cfb
28if errorlevel 1 goto err
29
30call tencce.bat des-ofb
31if errorlevel 1 goto err
32
33call tencce.bat des-ede-ofb
34if errorlevel 1 goto err
35
36call tencce.bat des-ede3-ofb
37if errorlevel 1 goto err
38
39call tencce.bat des-ecb
40if errorlevel 1 goto err
41
42call tencce.bat des-ede
43if errorlevel 1 goto err
44
45call tencce.bat des-ede3
46if errorlevel 1 goto err
47
48call tencce.bat des-cbc
49if errorlevel 1 goto err
50
51call tencce.bat des-ede-cbc
52if errorlevel 1 goto err
53
54call tencce.bat des-ede3-cbc
55if errorlevel 1 goto err
56
57call tencce.bat idea-ecb
58if errorlevel 1 goto err
59
60call tencce.bat idea-cfb
61if errorlevel 1 goto err
62
63call tencce.bat idea-ofb
64if errorlevel 1 goto err
65
66call tencce.bat idea-cbc
67if errorlevel 1 goto err
68
69call tencce.bat rc2-ecb
70if errorlevel 1 goto err
71
72call tencce.bat rc2-cfb
73if errorlevel 1 goto err
74
75call tencce.bat rc2-ofb
76if errorlevel 1 goto err
77
78call tencce.bat rc2-cbc
79if errorlevel 1 goto err
80
81call tencce.bat bf-ecb
82if errorlevel 1 goto err
83
84call tencce.bat bf-cfb
85if errorlevel 1 goto err
86
87call tencce.bat bf-ofb
88if errorlevel 1 goto err
89
90call tencce.bat bf-cbc
91if errorlevel 1 goto err
92
93echo OK
94del %out1% >nul 2>&1
95del %tmp1% >nul 2>&1
96:err
97
diff --git a/src/lib/libssl/src/ms/testpem.bat b/src/lib/libssl/src/ms/testpem.bat
index 81e566b69b..005f13b67e 100644
--- a/src/lib/libssl/src/ms/testpem.bat
+++ b/src/lib/libssl/src/ms/testpem.bat
@@ -1,4 +1,4 @@
1echo=off 1@echo off
2set ssleay=%1% 2set ssleay=%1%
3set tmp1=pem.out 3set tmp1=pem.out
4set cmp=fc.exe 4set cmp=fc.exe
diff --git a/src/lib/libssl/src/ms/testpemce.bat b/src/lib/libssl/src/ms/testpemce.bat
new file mode 100644
index 0000000000..c793c3e514
--- /dev/null
+++ b/src/lib/libssl/src/ms/testpemce.bat
@@ -0,0 +1,42 @@
1@echo off
2set ssleay=%1%
3set tmp1=pem.out
4set cmp=fc.exe
5
6cecopy %ssleay% CE:\OpenSSL
7
8copy ..\test\testcrl.pem >nul
9call tpemce.bat crl testcrl.pem
10if errorlevel 1 goto err
11
12copy ..\test\testp7.pem >nul
13call tpemce.bat pkcs7 testp7.pem
14if errorlevel 1 goto err
15
16copy ..\test\testreq2.pem >nul
17call tpemce.bat req testreq2.pem
18if errorlevel 1 goto err
19
20copy ..\test\testrsa.pem >nul
21call tpemce.bat rsa testrsa.pem
22if errorlevel 1 goto err
23
24copy ..\test\testx509.pem >nul
25call tpemce.bat x509 testx509.pem
26if errorlevel 1 goto err
27
28copy ..\test\v3-cert1.pem >nul
29call tpemce.bat x509 v3-cert1.pem
30if errorlevel 1 goto err
31
32copy ..\test\v3-cert1.pem >nul
33call tpemce.bat x509 v3-cert1.pem
34if errorlevel 1 goto err
35
36copy ..\test\testsid.pem >nul
37call tpemce.bat sess_id testsid.pem
38if errorlevel 1 goto err
39
40echo OK
41del %tmp1% >nul 2>&1
42:err
diff --git a/src/lib/libssl/src/ms/testss.bat b/src/lib/libssl/src/ms/testss.bat
index d9ae625439..f7e58e2756 100644
--- a/src/lib/libssl/src/ms/testss.bat
+++ b/src/lib/libssl/src/ms/testss.bat
@@ -1,4 +1,4 @@
1echo on 1@echo off
2 2
3rem set ssleay=..\out\ssleay 3rem set ssleay=..\out\ssleay
4set ssleay=%1 4set ssleay=%1
diff --git a/src/lib/libssl/src/ms/testssce.bat b/src/lib/libssl/src/ms/testssce.bat
new file mode 100644
index 0000000000..dbb25abdb0
--- /dev/null
+++ b/src/lib/libssl/src/ms/testssce.bat
@@ -0,0 +1,104 @@
1rem set ssleay=..\out\ssleay
2set ssleay=%1
3
4set reqcmd=%ssleay% req
5set x509cmd=%ssleay% x509
6set verifycmd=%ssleay% verify
7
8set CAkey=\OpenSSL\keyCA.ss
9set CAcert=\OpenSSL\certCA.ss
10set CAserial=\OpenSSL\certCA.srl
11set CAreq=\OpenSSL\reqCA.ss
12cecopy ..\test\CAss.cnf CE:\OpenSSL
13set CAconf=\OpenSSL\CAss.cnf
14set CAreq2=\OpenSSL\req2CA.ss
15
16cecopy ..\test\Uss.cnf CE:\OpenSSL
17set Uconf=\OpenSSL\Uss.cnf
18set Ukey=\OpenSSL\keyU.ss
19set Ureq=\OpenSSL\reqU.ss
20set Ucert=\OpenSSL\certU.ss
21
22echo make a certificate request using 'req'
23cerun CE:\OpenSSL\%reqcmd% -config %CAconf% -out %CAreq% -keyout %CAkey% -new
24if errorlevel 1 goto e_req
25
26echo convert the certificate request into a self signed certificate using 'x509'
27cerun CE:\OpenSSL\%x509cmd% -CAcreateserial -in %CAreq% -days 30 -req -out %CAcert% -signkey %CAkey% "> \OpenSSL\err.ss"
28if errorlevel 1 goto e_x509
29
30echo --
31echo convert a certificate into a certificate request using 'x509'
32cerun CE:\OpenSSL\%x509cmd% -in %CAcert% -x509toreq -signkey %CAkey% -out %CAreq2% "> \OpenSSL\err.ss"
33if errorlevel 1 goto e_x509_2
34
35cerun CE:\OpenSSL\%reqcmd% -verify -in %CAreq% -noout
36if errorlevel 1 goto e_vrfy_1
37
38cerun CE:\OpenSSL\%reqcmd% -verify -in %CAreq2% -noout
39if errorlevel 1 goto e_vrfy_2
40
41cerun CE:\OpenSSL\%verifycmd% -CAfile %CAcert% %CAcert%
42if errorlevel 1 goto e_vrfy_3
43
44echo --
45echo make another certificate request using 'req'
46cerun CE:\OpenSSL\%reqcmd% -config %Uconf% -out %Ureq% -keyout %Ukey% -new "> \OpenSSL\err.ss"
47if errorlevel 1 goto e_req_gen
48
49echo --
50echo sign certificate request with the just created CA via 'x509'
51cerun CE:\OpenSSL\%x509cmd% -CAcreateserial -in %Ureq% -days 30 -req -out %Ucert% -CA %CAcert% -CAkey %CAkey% -CAserial %CAserial%
52if errorlevel 1 goto e_x_sign
53
54cerun CE:\OpenSSL\%verifycmd% -CAfile %CAcert% %Ucert%
55echo --
56echo Certificate details
57cerun CE:\OpenSSL\%x509cmd% -subject -issuer -startdate -enddate -noout -in %Ucert%
58
59cecopy CE:%CAcert% .
60cecopy CE:%CAkey% .
61cecopy CE:%CAserial% .
62cecopy CE:%Ucert% .
63cecopy CE:%Ukey% .
64
65echo Everything appeared to work
66echo --
67echo The generated CA certificate is %CAcert%
68echo The generated CA private key is %CAkey%
69echo The current CA signing serial number is in %CAserial%
70
71echo The generated user certificate is %Ucert%
72echo The generated user private key is %Ukey%
73echo --
74
75cedel CE:\OpenSSL\err.ss
76
77goto end
78
79:e_req
80echo error using 'req' to generate a certificate request
81goto end
82:e_x509
83echo error using 'x509' to self sign a certificate request
84goto end
85:e_x509_2
86echo error using 'x509' convert a certificate to a certificate request
87goto end
88:e_vrfy_1
89echo first generated request is invalid
90goto end
91:e_vrfy_2
92echo second generated request is invalid
93goto end
94:e_vrfy_3
95echo first generated cert is invalid
96goto end
97:e_req_gen
98echo error using 'req' to generate a certificate request
99goto end
100:e_x_sign
101echo error using 'x509' to sign a certificate request
102goto end
103
104:end
diff --git a/src/lib/libssl/src/ms/tpemce.bat b/src/lib/libssl/src/ms/tpemce.bat
new file mode 100644
index 0000000000..17b2acd390
--- /dev/null
+++ b/src/lib/libssl/src/ms/tpemce.bat
@@ -0,0 +1,8 @@
1rem called by testpemce
2
3echo test %1 %2
4cecopy %2 CE:\OpenSSL
5cerun CE:\OpenSSL\%ssleay% %1 -in \OpenSSL\%2 -out \OpenSSL\%tmp1%
6del %tmp1% >nul 2>&1
7cecopy CE:\OpenSSL\%tmp1% .
8%cmp% %2 %tmp1%
diff --git a/src/lib/libssl/src/openssl.spec b/src/lib/libssl/src/openssl.spec
index 4d68d705ae..9bd9c8375e 100644
--- a/src/lib/libssl/src/openssl.spec
+++ b/src/lib/libssl/src/openssl.spec
@@ -1,15 +1,15 @@
1%define libmaj 0 1%define libmaj 0
2%define libmin 9 2%define libmin 9
3%define librel 7 3%define librel 7
4#%define librev a 4%define librev b
5Release: 1 5Release: 1
6 6
7%define openssldir /var/ssl 7%define openssldir /var/ssl
8 8
9Summary: Secure Sockets Layer and cryptography libraries and tools 9Summary: Secure Sockets Layer and cryptography libraries and tools
10Name: openssl 10Name: openssl
11Version: %{libmaj}.%{libmin}.%{librel} 11#Version: %{libmaj}.%{libmin}.%{librel}
12#Version: %{libmaj}.%{libmin}.%{librel}%{librev} 12Version: %{libmaj}.%{libmin}.%{librel}%{librev}
13Source0: ftp://ftp.openssl.org/source/%{name}-%{version}.tar.gz 13Source0: ftp://ftp.openssl.org/source/%{name}-%{version}.tar.gz
14Copyright: Freely distributable 14Copyright: Freely distributable
15Group: System Environment/Libraries 15Group: System Environment/Libraries
diff --git a/src/lib/libssl/src/shlib/sco5-shared-gcc.sh b/src/lib/libssl/src/shlib/sco5-shared-gcc.sh
new file mode 100644
index 0000000000..fe4a457b52
--- /dev/null
+++ b/src/lib/libssl/src/shlib/sco5-shared-gcc.sh
@@ -0,0 +1,48 @@
1#!/bin/sh
2
3major="0"
4minor="9.7b"
5
6slib=libssl
7sh_slib=$slib.so.$major.$minor
8
9clib=libcrypto
10sh_clib=$clib.so.$major.$minor
11
12FLAGS="-O3 -fomit-frame-pointer"
13SHFLAGS="-DPIC -fPIC"
14
15touch $sh_clib
16touch $sh_slib
17
18echo collecting all object files for $clib.so
19OBJS=
20find . -name \*.o -print > allobjs
21for obj in `ar t libcrypto.a`
22do
23 OBJS="$OBJS `grep $obj allobjs`"
24done
25
26echo linking $clib.so
27gcc -G -o $sh_clib -h $sh_clib $OBJS -lnsl -lsocket
28
29rm -f $clib.so
30ln -s $sh_clib $clib.so
31
32echo collecting all object files for $slib.so
33OBJS=
34for obj in `ar t libssl.a`
35do
36 OBJS="$OBJS `grep $obj allobjs`"
37done
38
39echo linking $slib.so
40gcc -G -o $sh_slib -h $sh_slib $OBJS -L. -lcrypto
41
42rm -f $slib.so
43ln -s $sh_slib $slib.so
44
45mv libRSAglue.a libRSAglue.a.orig
46mv libcrypto.a libcrypto.a.orig
47mv libssl.a libssl.a.orig
48
diff --git a/src/lib/libssl/src/shlib/sco5-shared-installed b/src/lib/libssl/src/shlib/sco5-shared-installed
new file mode 100644
index 0000000000..509902833f
--- /dev/null
+++ b/src/lib/libssl/src/shlib/sco5-shared-installed
@@ -0,0 +1,28 @@
1#!/bin/sh
2
3major="0"
4minor="9.7b"
5
6slib=libssl
7sh_slib=$slib.so.$major.$minor
8
9clib=libcrypto
10sh_clib=$clib.so.$major.$minor
11
12# If you want them in /usr/local/lib then change INSTALLTOP to point there.
13#INSTALLTOP=/usr/local/ssl/lib
14INSTALLTOP=/usr/local/lib
15
16cp -p $sh_clib $INSTALLTOP
17cp -p $sh_slib $INSTALLTOP
18
19PWD=`pwd`
20cd $INSTALLTOP
21rm -f $INSTALLTOP/$clib.so
22ln -s $INSTALLTOP/$sh_clib $clib.so
23
24rm -f $INSTALLTOP/$slib.so
25ln -s $INSTALLTOP/$sh_slib $slib.so
26
27cd $PWD
28
diff --git a/src/lib/libssl/src/shlib/sco5-shared.sh b/src/lib/libssl/src/shlib/sco5-shared.sh
new file mode 100644
index 0000000000..b3365d9f51
--- /dev/null
+++ b/src/lib/libssl/src/shlib/sco5-shared.sh
@@ -0,0 +1,48 @@
1#!/bin/sh
2
3major="0"
4minor="9.7b"
5
6slib=libssl
7sh_slib=$slib.so.$major.$minor
8
9clib=libcrypto
10sh_clib=$clib.so.$major.$minor
11
12FLAGS="-O -DFILIO_H -Kalloca"
13SHFLAGS="-Kpic -DPIC"
14
15touch $sh_clib
16touch $sh_slib
17
18echo collecting all object files for $clib.so
19OBJS=
20find . -name \*.o -print > allobjs
21for obj in `ar t libcrypto.a`
22do
23 OBJS="$OBJS `grep $obj allobjs`"
24done
25
26echo linking $clib.so
27cc -G -o $sh_clib -h $sh_clib $OBJS -lnsl -lsocket
28
29rm -f $clib.so
30ln -s $sh_clib $clib.so
31
32echo collecting all object files for $slib.so
33OBJS=
34for obj in `ar t libssl.a`
35do
36 OBJS="$OBJS `grep $obj allobjs`"
37done
38
39echo linking $slib.so
40cc -G -o $sh_slib -h $sh_slib $OBJS -L. -lcrypto
41
42rm -f $slib.so
43ln -s $sh_slib $slib.so
44
45mv libRSAglue.a libRSAglue.a.orig
46mv libcrypto.a libcrypto.a.orig
47mv libssl.a libssl.a.orig
48
diff --git a/src/lib/libssl/src/shlib/svr5-shared-gcc.sh b/src/lib/libssl/src/shlib/svr5-shared-gcc.sh
index 76957df947..c5d0cc56ac 100644
--- a/src/lib/libssl/src/shlib/svr5-shared-gcc.sh
+++ b/src/lib/libssl/src/shlib/svr5-shared-gcc.sh
@@ -1,7 +1,7 @@
1#!/usr/bin/sh 1#!/usr/bin/sh
2 2
3major="0" 3major="0"
4minor="9.7" 4minor="9.7b"
5 5
6slib=libssl 6slib=libssl
7sh_slib=$slib.so.$major.$minor 7sh_slib=$slib.so.$major.$minor
diff --git a/src/lib/libssl/src/shlib/svr5-shared-installed b/src/lib/libssl/src/shlib/svr5-shared-installed
index 544f5a9417..b1def35d5c 100644
--- a/src/lib/libssl/src/shlib/svr5-shared-installed
+++ b/src/lib/libssl/src/shlib/svr5-shared-installed
@@ -1,7 +1,7 @@
1#!/usr/bin/sh 1#!/usr/bin/sh
2 2
3major="0" 3major="0"
4minor="9.7" 4minor="9.7b"
5 5
6slib=libssl 6slib=libssl
7sh_slib=$slib.so.$major.$minor 7sh_slib=$slib.so.$major.$minor
@@ -25,4 +25,3 @@ rm -f $INSTALLTOP/$slib.so
25ln -s $INSTALLTOP/$sh_slib $slib.so 25ln -s $INSTALLTOP/$sh_slib $slib.so
26 26
27cd $PWD 27cd $PWD
28
diff --git a/src/lib/libssl/src/shlib/svr5-shared.sh b/src/lib/libssl/src/shlib/svr5-shared.sh
index a70bb65baa..9edf26e9a7 100644
--- a/src/lib/libssl/src/shlib/svr5-shared.sh
+++ b/src/lib/libssl/src/shlib/svr5-shared.sh
@@ -1,7 +1,7 @@
1#!/usr/bin/sh 1#!/usr/bin/sh
2 2
3major="0" 3major="0"
4minor="9.7" 4minor="9.7b"
5 5
6slib=libssl 6slib=libssl
7sh_slib=$slib.so.$major.$minor 7sh_slib=$slib.so.$major.$minor
diff --git a/src/lib/libssl/src/ssl/bio_ssl.c b/src/lib/libssl/src/ssl/bio_ssl.c
index 467e149947..d683ee43e1 100644
--- a/src/lib/libssl/src/ssl/bio_ssl.c
+++ b/src/lib/libssl/src/ssl/bio_ssl.c
@@ -403,6 +403,10 @@ static long ssl_ctrl(BIO *b, int cmd, long num, void *ptr)
403 { 403 {
404 BIO_free_all(ssl->wbio); 404 BIO_free_all(ssl->wbio);
405 } 405 }
406 if (b->next_bio != NULL)
407 {
408 CRYPTO_add(&b->next_bio->references,1,CRYPTO_LOCK_BIO);
409 }
406 ssl->wbio=NULL; 410 ssl->wbio=NULL;
407 ssl->rbio=NULL; 411 ssl->rbio=NULL;
408 break; 412 break;
@@ -509,6 +513,7 @@ static int ssl_puts(BIO *bp, const char *str)
509 513
510BIO *BIO_new_buffer_ssl_connect(SSL_CTX *ctx) 514BIO *BIO_new_buffer_ssl_connect(SSL_CTX *ctx)
511 { 515 {
516#ifndef OPENSSL_NO_SOCK
512 BIO *ret=NULL,*buf=NULL,*ssl=NULL; 517 BIO *ret=NULL,*buf=NULL,*ssl=NULL;
513 518
514 if ((buf=BIO_new(BIO_f_buffer())) == NULL) 519 if ((buf=BIO_new(BIO_f_buffer())) == NULL)
@@ -521,6 +526,7 @@ BIO *BIO_new_buffer_ssl_connect(SSL_CTX *ctx)
521err: 526err:
522 if (buf != NULL) BIO_free(buf); 527 if (buf != NULL) BIO_free(buf);
523 if (ssl != NULL) BIO_free(ssl); 528 if (ssl != NULL) BIO_free(ssl);
529#endif
524 return(NULL); 530 return(NULL);
525 } 531 }
526 532
diff --git a/src/lib/libssl/src/ssl/kssl.c b/src/lib/libssl/src/ssl/kssl.c
index d3c7be7581..a80f5b2f74 100644
--- a/src/lib/libssl/src/ssl/kssl.c
+++ b/src/lib/libssl/src/ssl/kssl.c
@@ -70,6 +70,7 @@
70 70
71#define _XOPEN_SOURCE /* glibc2 needs this to declare strptime() */ 71#define _XOPEN_SOURCE /* glibc2 needs this to declare strptime() */
72#include <time.h> 72#include <time.h>
73#undef _XOPEN_SOURCE /* To avoid clashes with anything else... */
73#include <string.h> 74#include <string.h>
74 75
75#include <openssl/ssl.h> 76#include <openssl/ssl.h>
@@ -783,24 +784,6 @@ char
783 return ((string == NULL)? null: string); 784 return ((string == NULL)? null: string);
784 } 785 }
785 786
786#define MAXKNUM 255
787char
788*knumber(int len, krb5_octet *contents)
789 {
790 static char buf[MAXKNUM+1];
791 int i;
792
793 BIO_snprintf(buf, MAXKNUM, "[%d] ", len);
794
795 for (i=0; i < len && MAXKNUM > strlen(buf)+3; i++)
796 {
797 BIO_snprintf(&buf[strlen(buf)], 3, "%02x", contents[i]);
798 }
799
800 return (buf);
801 }
802
803
804/* Given KRB5 enctype (basically DES or 3DES), 787/* Given KRB5 enctype (basically DES or 3DES),
805** return closest match openssl EVP_ encryption algorithm. 788** return closest match openssl EVP_ encryption algorithm.
806** Return NULL for unknown or problematic (krb5_dk_encrypt) enctypes. 789** Return NULL for unknown or problematic (krb5_dk_encrypt) enctypes.
@@ -1568,7 +1551,7 @@ kssl_ctx_free(KSSL_CTX *kssl_ctx)
1568 { 1551 {
1569 if (kssl_ctx == NULL) return kssl_ctx; 1552 if (kssl_ctx == NULL) return kssl_ctx;
1570 1553
1571 if (kssl_ctx->key) memset(kssl_ctx->key, 0, 1554 if (kssl_ctx->key) OPENSSL_cleanse(kssl_ctx->key,
1572 kssl_ctx->length); 1555 kssl_ctx->length);
1573 if (kssl_ctx->key) free(kssl_ctx->key); 1556 if (kssl_ctx->key) free(kssl_ctx->key);
1574 if (kssl_ctx->client_princ) free(kssl_ctx->client_princ); 1557 if (kssl_ctx->client_princ) free(kssl_ctx->client_princ);
@@ -1672,7 +1655,7 @@ kssl_ctx_setkey(KSSL_CTX *kssl_ctx, krb5_keyblock *session)
1672 1655
1673 if (kssl_ctx->key) 1656 if (kssl_ctx->key)
1674 { 1657 {
1675 memset(kssl_ctx->key, 0, kssl_ctx->length); 1658 OPENSSL_cleanse(kssl_ctx->key, kssl_ctx->length);
1676 free(kssl_ctx->key); 1659 free(kssl_ctx->key);
1677 } 1660 }
1678 1661
@@ -1979,7 +1962,7 @@ krb5_error_code kssl_check_authent(
1979 const EVP_CIPHER *enc = NULL; 1962 const EVP_CIPHER *enc = NULL;
1980 unsigned char iv[EVP_MAX_IV_LENGTH]; 1963 unsigned char iv[EVP_MAX_IV_LENGTH];
1981 unsigned char *p, *unenc_authent; 1964 unsigned char *p, *unenc_authent;
1982 int padl, outl, unencbufsize; 1965 int outl, unencbufsize;
1983 struct tm tm_time, *tm_l, *tm_g; 1966 struct tm tm_time, *tm_l, *tm_g;
1984 time_t now, tl, tg, tr, tz_offset; 1967 time_t now, tl, tg, tr, tz_offset;
1985 1968
@@ -2037,7 +2020,7 @@ krb5_error_code kssl_check_authent(
2037 } 2020 }
2038#endif 2021#endif
2039 enc = kssl_map_enc(enctype); 2022 enc = kssl_map_enc(enctype);
2040 memset(iv, 0, EVP_MAX_IV_LENGTH); /* per RFC 1510 */ 2023 memset(iv, 0, sizeof iv); /* per RFC 1510 */
2041 2024
2042 if (enc == NULL) 2025 if (enc == NULL)
2043 { 2026 {
@@ -2047,44 +2030,23 @@ krb5_error_code kssl_check_authent(
2047 */ 2030 */
2048 goto err; 2031 goto err;
2049 } 2032 }
2050 if (!EVP_DecryptInit_ex(&ciph_ctx, enc, NULL, kssl_ctx->key, iv)) 2033
2051 { 2034 if (!EVP_CipherInit(&ciph_ctx,enc,kssl_ctx->key,iv,0))
2052 kssl_err_set(kssl_err, SSL_R_KRB5_S_INIT, 2035 {
2053 "EVP_DecryptInit_ex error decrypting authenticator.\n"); 2036 kssl_err_set(kssl_err, SSL_R_KRB5_S_INIT,
2054 krb5rc = KRB5KRB_AP_ERR_BAD_INTEGRITY; 2037 "EVP_CipherInit error decrypting authenticator.\n");
2055 goto err; 2038 krb5rc = KRB5KRB_AP_ERR_BAD_INTEGRITY;
2056 } 2039 goto err;
2057 if (!EVP_DecryptUpdate(&ciph_ctx, unenc_authent, &outl, 2040 }
2058 dec_authent->cipher->data, dec_authent->cipher->length)) 2041 outl = dec_authent->cipher->length;
2059 { 2042 if (!EVP_Cipher(&ciph_ctx,unenc_authent,dec_authent->cipher->data,outl))
2060 kssl_err_set(kssl_err, SSL_R_KRB5_S_INIT, 2043 {
2061 "EVP_DecryptUpdate error decrypting authenticator.\n"); 2044 kssl_err_set(kssl_err, SSL_R_KRB5_S_INIT,
2062 krb5rc = KRB5KRB_AP_ERR_BAD_INTEGRITY; 2045 "EVP_Cipher error decrypting authenticator.\n");
2063 goto err; 2046 krb5rc = KRB5KRB_AP_ERR_BAD_INTEGRITY;
2064 } 2047 goto err;
2065 if (outl > unencbufsize) 2048 }
2066 { 2049 EVP_CIPHER_CTX_cleanup(&ciph_ctx);
2067 kssl_err_set(kssl_err, SSL_R_KRB5_S_INIT,
2068 "Buffer overflow decrypting authenticator.\n");
2069 krb5rc = KRB5KRB_AP_ERR_BAD_INTEGRITY;
2070 goto err;
2071 }
2072 if (!EVP_DecryptFinal_ex(&ciph_ctx, &(unenc_authent[outl]), &padl))
2073 {
2074 kssl_err_set(kssl_err, SSL_R_KRB5_S_INIT,
2075 "EVP_DecryptFinal_ex error decrypting authenticator.\n");
2076 krb5rc = KRB5KRB_AP_ERR_BAD_INTEGRITY;
2077 goto err;
2078 }
2079 outl += padl;
2080 if (outl > unencbufsize)
2081 {
2082 kssl_err_set(kssl_err, SSL_R_KRB5_S_INIT,
2083 "Buffer overflow decrypting authenticator.\n");
2084 krb5rc = KRB5KRB_AP_ERR_BAD_INTEGRITY;
2085 goto err;
2086 }
2087 EVP_CIPHER_CTX_cleanup(&ciph_ctx);
2088 2050
2089#ifdef KSSL_DEBUG 2051#ifdef KSSL_DEBUG
2090 printf("kssl_check_authent: decrypted authenticator[%d] =\n", outl); 2052 printf("kssl_check_authent: decrypted authenticator[%d] =\n", outl);
@@ -2133,6 +2095,7 @@ krb5_error_code kssl_check_authent(
2133 if (auth) KRB5_AUTHENT_free((KRB5_AUTHENT *) auth); 2095 if (auth) KRB5_AUTHENT_free((KRB5_AUTHENT *) auth);
2134 if (dec_authent) KRB5_ENCDATA_free(dec_authent); 2096 if (dec_authent) KRB5_ENCDATA_free(dec_authent);
2135 if (unenc_authent) free(unenc_authent); 2097 if (unenc_authent) free(unenc_authent);
2098 EVP_CIPHER_CTX_cleanup(&ciph_ctx);
2136 return krb5rc; 2099 return krb5rc;
2137 } 2100 }
2138 2101
diff --git a/src/lib/libssl/src/ssl/s23_clnt.c b/src/lib/libssl/src/ssl/s23_clnt.c
index 019e9aecee..64ee4269ec 100644
--- a/src/lib/libssl/src/ssl/s23_clnt.c
+++ b/src/lib/libssl/src/ssl/s23_clnt.c
@@ -87,18 +87,25 @@ SSL_METHOD *SSLv23_client_method(void)
87 87
88 if (init) 88 if (init)
89 { 89 {
90 memcpy((char *)&SSLv23_client_data, 90 CRYPTO_w_lock(CRYPTO_LOCK_SSL_METHOD);
91 (char *)sslv23_base_method(),sizeof(SSL_METHOD)); 91
92 SSLv23_client_data.ssl_connect=ssl23_connect; 92 if (init)
93 SSLv23_client_data.get_ssl_method=ssl23_get_client_method; 93 {
94 init=0; 94 memcpy((char *)&SSLv23_client_data,
95 (char *)sslv23_base_method(),sizeof(SSL_METHOD));
96 SSLv23_client_data.ssl_connect=ssl23_connect;
97 SSLv23_client_data.get_ssl_method=ssl23_get_client_method;
98 init=0;
99 }
100
101 CRYPTO_w_unlock(CRYPTO_LOCK_SSL_METHOD);
95 } 102 }
96 return(&SSLv23_client_data); 103 return(&SSLv23_client_data);
97 } 104 }
98 105
99int ssl23_connect(SSL *s) 106int ssl23_connect(SSL *s)
100 { 107 {
101 BUF_MEM *buf; 108 BUF_MEM *buf=NULL;
102 unsigned long Time=time(NULL); 109 unsigned long Time=time(NULL);
103 void (*cb)(const SSL *ssl,int type,int val)=NULL; 110 void (*cb)(const SSL *ssl,int type,int val)=NULL;
104 int ret= -1; 111 int ret= -1;
@@ -152,6 +159,7 @@ int ssl23_connect(SSL *s)
152 goto end; 159 goto end;
153 } 160 }
154 s->init_buf=buf; 161 s->init_buf=buf;
162 buf=NULL;
155 } 163 }
156 164
157 if (!ssl3_setup_buffers(s)) { ret= -1; goto end; } 165 if (!ssl3_setup_buffers(s)) { ret= -1; goto end; }
@@ -200,6 +208,8 @@ int ssl23_connect(SSL *s)
200 } 208 }
201end: 209end:
202 s->in_handshake--; 210 s->in_handshake--;
211 if (buf != NULL)
212 BUF_MEM_free(buf);
203 if (cb != NULL) 213 if (cb != NULL)
204 cb(s,SSL_CB_CONNECT_EXIT,ret); 214 cb(s,SSL_CB_CONNECT_EXIT,ret);
205 return(ret); 215 return(ret);
@@ -363,7 +373,7 @@ static int ssl23_get_server_hello(SSL *s)
363 373
364 if (s->s3 != NULL) ssl3_free(s); 374 if (s->s3 != NULL) ssl3_free(s);
365 375
366 if (!BUF_MEM_grow(s->init_buf, 376 if (!BUF_MEM_grow_clean(s->init_buf,
367 SSL2_MAX_RECORD_LENGTH_3_BYTE_HEADER)) 377 SSL2_MAX_RECORD_LENGTH_3_BYTE_HEADER))
368 { 378 {
369 SSLerr(SSL_F_SSL23_GET_SERVER_HELLO,ERR_R_BUF_LIB); 379 SSLerr(SSL_F_SSL23_GET_SERVER_HELLO,ERR_R_BUF_LIB);
diff --git a/src/lib/libssl/src/ssl/s23_meth.c b/src/lib/libssl/src/ssl/s23_meth.c
index 40684311db..f207140835 100644
--- a/src/lib/libssl/src/ssl/s23_meth.c
+++ b/src/lib/libssl/src/ssl/s23_meth.c
@@ -80,12 +80,19 @@ SSL_METHOD *SSLv23_method(void)
80 80
81 if (init) 81 if (init)
82 { 82 {
83 memcpy((char *)&SSLv23_data,(char *)sslv23_base_method(), 83 CRYPTO_w_lock(CRYPTO_LOCK_SSL_METHOD);
84 sizeof(SSL_METHOD)); 84
85 SSLv23_data.ssl_connect=ssl23_connect; 85 if (init)
86 SSLv23_data.ssl_accept=ssl23_accept; 86 {
87 SSLv23_data.get_ssl_method=ssl23_get_method; 87 memcpy((char *)&SSLv23_data,(char *)sslv23_base_method(),
88 init=0; 88 sizeof(SSL_METHOD));
89 SSLv23_data.ssl_connect=ssl23_connect;
90 SSLv23_data.ssl_accept=ssl23_accept;
91 SSLv23_data.get_ssl_method=ssl23_get_method;
92 init=0;
93 }
94
95 CRYPTO_w_unlock(CRYPTO_LOCK_SSL_METHOD);
89 } 96 }
90 return(&SSLv23_data); 97 return(&SSLv23_data);
91 } 98 }
diff --git a/src/lib/libssl/src/ssl/s23_srvr.c b/src/lib/libssl/src/ssl/s23_srvr.c
index 8743b61cbb..c5404ca0bc 100644
--- a/src/lib/libssl/src/ssl/s23_srvr.c
+++ b/src/lib/libssl/src/ssl/s23_srvr.c
@@ -139,11 +139,18 @@ SSL_METHOD *SSLv23_server_method(void)
139 139
140 if (init) 140 if (init)
141 { 141 {
142 memcpy((char *)&SSLv23_server_data, 142 CRYPTO_w_lock(CRYPTO_LOCK_SSL_METHOD);
143 (char *)sslv23_base_method(),sizeof(SSL_METHOD)); 143
144 SSLv23_server_data.ssl_accept=ssl23_accept; 144 if (init)
145 SSLv23_server_data.get_ssl_method=ssl23_get_server_method; 145 {
146 init=0; 146 memcpy((char *)&SSLv23_server_data,
147 (char *)sslv23_base_method(),sizeof(SSL_METHOD));
148 SSLv23_server_data.ssl_accept=ssl23_accept;
149 SSLv23_server_data.get_ssl_method=ssl23_get_server_method;
150 init=0;
151 }
152
153 CRYPTO_w_unlock(CRYPTO_LOCK_SSL_METHOD);
147 } 154 }
148 return(&SSLv23_server_data); 155 return(&SSLv23_server_data);
149 } 156 }
@@ -505,7 +512,7 @@ int ssl23_get_client_hello(SSL *s)
505 512
506 if (s->s3 != NULL) ssl3_free(s); 513 if (s->s3 != NULL) ssl3_free(s);
507 514
508 if (!BUF_MEM_grow(s->init_buf, 515 if (!BUF_MEM_grow_clean(s->init_buf,
509 SSL2_MAX_RECORD_LENGTH_3_BYTE_HEADER)) 516 SSL2_MAX_RECORD_LENGTH_3_BYTE_HEADER))
510 { 517 {
511 goto err; 518 goto err;
diff --git a/src/lib/libssl/src/ssl/s2_clnt.c b/src/lib/libssl/src/ssl/s2_clnt.c
index 570d0664ed..1d24dedc91 100644
--- a/src/lib/libssl/src/ssl/s2_clnt.c
+++ b/src/lib/libssl/src/ssl/s2_clnt.c
@@ -145,11 +145,18 @@ SSL_METHOD *SSLv2_client_method(void)
145 145
146 if (init) 146 if (init)
147 { 147 {
148 memcpy((char *)&SSLv2_client_data,(char *)sslv2_base_method(), 148 CRYPTO_w_lock(CRYPTO_LOCK_SSL_METHOD);
149 sizeof(SSL_METHOD)); 149
150 SSLv2_client_data.ssl_connect=ssl2_connect; 150 if (init)
151 SSLv2_client_data.get_ssl_method=ssl2_get_client_method; 151 {
152 init=0; 152 memcpy((char *)&SSLv2_client_data,(char *)sslv2_base_method(),
153 sizeof(SSL_METHOD));
154 SSLv2_client_data.ssl_connect=ssl2_connect;
155 SSLv2_client_data.get_ssl_method=ssl2_get_client_method;
156 init=0;
157 }
158
159 CRYPTO_w_unlock(CRYPTO_LOCK_SSL_METHOD);
153 } 160 }
154 return(&SSLv2_client_data); 161 return(&SSLv2_client_data);
155 } 162 }
@@ -201,10 +208,13 @@ int ssl2_connect(SSL *s)
201 if (!BUF_MEM_grow(buf, 208 if (!BUF_MEM_grow(buf,
202 SSL2_MAX_RECORD_LENGTH_3_BYTE_HEADER)) 209 SSL2_MAX_RECORD_LENGTH_3_BYTE_HEADER))
203 { 210 {
211 if (buf == s->init_buf)
212 buf=NULL;
204 ret= -1; 213 ret= -1;
205 goto end; 214 goto end;
206 } 215 }
207 s->init_buf=buf; 216 s->init_buf=buf;
217 buf=NULL;
208 s->init_num=0; 218 s->init_num=0;
209 s->state=SSL2_ST_SEND_CLIENT_HELLO_A; 219 s->state=SSL2_ST_SEND_CLIENT_HELLO_A;
210 s->ctx->stats.sess_connect++; 220 s->ctx->stats.sess_connect++;
@@ -331,6 +341,8 @@ int ssl2_connect(SSL *s)
331 } 341 }
332end: 342end:
333 s->in_handshake--; 343 s->in_handshake--;
344 if (buf != NULL)
345 BUF_MEM_free(buf);
334 if (cb != NULL) 346 if (cb != NULL)
335 cb(s,SSL_CB_CONNECT_EXIT,ret); 347 cb(s,SSL_CB_CONNECT_EXIT,ret);
336 return(ret); 348 return(ret);
@@ -763,8 +775,8 @@ static int client_certificate(SSL *s)
763 if (s->state == SSL2_ST_SEND_CLIENT_CERTIFICATE_A) 775 if (s->state == SSL2_ST_SEND_CLIENT_CERTIFICATE_A)
764 { 776 {
765 i=ssl2_read(s,(char *)&(buf[s->init_num]), 777 i=ssl2_read(s,(char *)&(buf[s->init_num]),
766 SSL2_MAX_CERT_CHALLENGE_LENGTH+1-s->init_num); 778 SSL2_MAX_CERT_CHALLENGE_LENGTH+2-s->init_num);
767 if (i<(SSL2_MIN_CERT_CHALLENGE_LENGTH+1-s->init_num)) 779 if (i<(SSL2_MIN_CERT_CHALLENGE_LENGTH+2-s->init_num))
768 return(ssl2_part_read(s,SSL_F_CLIENT_CERTIFICATE,i)); 780 return(ssl2_part_read(s,SSL_F_CLIENT_CERTIFICATE,i));
769 s->init_num += i; 781 s->init_num += i;
770 if (s->msg_callback) 782 if (s->msg_callback)
@@ -864,7 +876,7 @@ static int client_certificate(SSL *s)
864 EVP_MD_CTX_init(&ctx); 876 EVP_MD_CTX_init(&ctx);
865 EVP_SignInit_ex(&ctx,s->ctx->rsa_md5, NULL); 877 EVP_SignInit_ex(&ctx,s->ctx->rsa_md5, NULL);
866 EVP_SignUpdate(&ctx,s->s2->key_material, 878 EVP_SignUpdate(&ctx,s->s2->key_material,
867 (unsigned int)s->s2->key_material_length); 879 s->s2->key_material_length);
868 EVP_SignUpdate(&ctx,cert_ch,(unsigned int)cert_ch_len); 880 EVP_SignUpdate(&ctx,cert_ch,(unsigned int)cert_ch_len);
869 n=i2d_X509(s->session->sess_cert->peer_key->x509,&p); 881 n=i2d_X509(s->session->sess_cert->peer_key->x509,&p);
870 EVP_SignUpdate(&ctx,buf,(unsigned int)n); 882 EVP_SignUpdate(&ctx,buf,(unsigned int)n);
@@ -938,7 +950,7 @@ static int get_server_verify(SSL *s)
938 s->msg_callback(0, s->version, 0, p, len, s, s->msg_callback_arg); /* SERVER-VERIFY */ 950 s->msg_callback(0, s->version, 0, p, len, s, s->msg_callback_arg); /* SERVER-VERIFY */
939 p += 1; 951 p += 1;
940 952
941 if (memcmp(p,s->s2->challenge,(unsigned int)s->s2->challenge_length) != 0) 953 if (memcmp(p,s->s2->challenge,s->s2->challenge_length) != 0)
942 { 954 {
943 ssl2_return_error(s,SSL2_PE_UNDEFINED_ERROR); 955 ssl2_return_error(s,SSL2_PE_UNDEFINED_ERROR);
944 SSLerr(SSL_F_GET_SERVER_VERIFY,SSL_R_CHALLENGE_IS_DIFFERENT); 956 SSLerr(SSL_F_GET_SERVER_VERIFY,SSL_R_CHALLENGE_IS_DIFFERENT);
@@ -1002,14 +1014,14 @@ static int get_server_finished(SSL *s)
1002 * or bad things can happen */ 1014 * or bad things can happen */
1003 /* ZZZZZZZZZZZZZ */ 1015 /* ZZZZZZZZZZZZZ */
1004 s->session->session_id_length=SSL2_SSL_SESSION_ID_LENGTH; 1016 s->session->session_id_length=SSL2_SSL_SESSION_ID_LENGTH;
1005 memcpy(s->session->session_id,p,SSL2_SSL_SESSION_ID_LENGTH); 1017 memcpy(s->session->session_id,p+1,SSL2_SSL_SESSION_ID_LENGTH);
1006 } 1018 }
1007 else 1019 else
1008 { 1020 {
1009 if (!(s->options & SSL_OP_MICROSOFT_SESS_ID_BUG)) 1021 if (!(s->options & SSL_OP_MICROSOFT_SESS_ID_BUG))
1010 { 1022 {
1011 if ((s->session->session_id_length > sizeof s->session->session_id) 1023 if ((s->session->session_id_length > sizeof s->session->session_id)
1012 || (0 != memcmp(buf, s->session->session_id, 1024 || (0 != memcmp(buf + 1, s->session->session_id,
1013 (unsigned int)s->session->session_id_length))) 1025 (unsigned int)s->session->session_id_length)))
1014 { 1026 {
1015 ssl2_return_error(s,SSL2_PE_UNDEFINED_ERROR); 1027 ssl2_return_error(s,SSL2_PE_UNDEFINED_ERROR);
diff --git a/src/lib/libssl/src/ssl/s2_enc.c b/src/lib/libssl/src/ssl/s2_enc.c
index 690252e3d3..d3b144f1c5 100644
--- a/src/lib/libssl/src/ssl/s2_enc.c
+++ b/src/lib/libssl/src/ssl/s2_enc.c
@@ -59,6 +59,7 @@
59#include "ssl_locl.h" 59#include "ssl_locl.h"
60#ifndef OPENSSL_NO_SSL2 60#ifndef OPENSSL_NO_SSL2
61#include <stdio.h> 61#include <stdio.h>
62#include "cryptlib.h"
62 63
63int ssl2_enc_init(SSL *s, int client) 64int ssl2_enc_init(SSL *s, int client)
64 { 65 {
@@ -95,10 +96,12 @@ int ssl2_enc_init(SSL *s, int client)
95 96
96 num=c->key_len; 97 num=c->key_len;
97 s->s2->key_material_length=num*2; 98 s->s2->key_material_length=num*2;
99 OPENSSL_assert(s->s2->key_material_length <= sizeof s->s2->key_material);
98 100
99 if (ssl2_generate_key_material(s) <= 0) 101 if (ssl2_generate_key_material(s) <= 0)
100 return 0; 102 return 0;
101 103
104 OPENSSL_assert(c->iv_len <= sizeof s->session->key_arg);
102 EVP_EncryptInit_ex(ws,c,NULL,&(s->s2->key_material[(client)?num:0]), 105 EVP_EncryptInit_ex(ws,c,NULL,&(s->s2->key_material[(client)?num:0]),
103 s->session->key_arg); 106 s->session->key_arg);
104 EVP_DecryptInit_ex(rs,c,NULL,&(s->s2->key_material[(client)?0:num]), 107 EVP_DecryptInit_ex(rs,c,NULL,&(s->s2->key_material[(client)?0:num]),
diff --git a/src/lib/libssl/src/ssl/s2_lib.c b/src/lib/libssl/src/ssl/s2_lib.c
index cc0dcfa956..910b9fe097 100644
--- a/src/lib/libssl/src/ssl/s2_lib.c
+++ b/src/lib/libssl/src/ssl/s2_lib.c
@@ -308,7 +308,7 @@ void ssl2_free(SSL *s)
308 s2=s->s2; 308 s2=s->s2;
309 if (s2->rbuf != NULL) OPENSSL_free(s2->rbuf); 309 if (s2->rbuf != NULL) OPENSSL_free(s2->rbuf);
310 if (s2->wbuf != NULL) OPENSSL_free(s2->wbuf); 310 if (s2->wbuf != NULL) OPENSSL_free(s2->wbuf);
311 memset(s2,0,sizeof *s2); 311 OPENSSL_cleanse(s2,sizeof *s2);
312 OPENSSL_free(s2); 312 OPENSSL_free(s2);
313 s->s2=NULL; 313 s->s2=NULL;
314 } 314 }
@@ -377,15 +377,19 @@ SSL_CIPHER *ssl2_get_cipher_by_char(const unsigned char *p)
377 { 377 {
378 CRYPTO_w_lock(CRYPTO_LOCK_SSL); 378 CRYPTO_w_lock(CRYPTO_LOCK_SSL);
379 379
380 for (i=0; i<SSL2_NUM_CIPHERS; i++) 380 if (init)
381 sorted[i]= &(ssl2_ciphers[i]); 381 {
382 for (i=0; i<SSL2_NUM_CIPHERS; i++)
383 sorted[i]= &(ssl2_ciphers[i]);
382 384
383 qsort( (char *)sorted, 385 qsort((char *)sorted,
384 SSL2_NUM_CIPHERS,sizeof(SSL_CIPHER *), 386 SSL2_NUM_CIPHERS,sizeof(SSL_CIPHER *),
385 FP_ICC ssl_cipher_ptr_id_cmp); 387 FP_ICC ssl_cipher_ptr_id_cmp);
386 388
389 init=0;
390 }
391
387 CRYPTO_w_unlock(CRYPTO_LOCK_SSL); 392 CRYPTO_w_unlock(CRYPTO_LOCK_SSL);
388 init=0;
389 } 393 }
390 394
391 id=0x02000000L|((unsigned long)p[0]<<16L)| 395 id=0x02000000L|((unsigned long)p[0]<<16L)|
@@ -450,6 +454,9 @@ int ssl2_generate_key_material(SSL *s)
450 454
451 EVP_DigestInit_ex(&ctx, md5, NULL); 455 EVP_DigestInit_ex(&ctx, md5, NULL);
452 456
457 OPENSSL_assert(s->session->master_key_length >= 0
458 && s->session->master_key_length
459 < sizeof s->session->master_key);
453 EVP_DigestUpdate(&ctx,s->session->master_key,s->session->master_key_length); 460 EVP_DigestUpdate(&ctx,s->session->master_key,s->session->master_key_length);
454 EVP_DigestUpdate(&ctx,&c,1); 461 EVP_DigestUpdate(&ctx,&c,1);
455 c++; 462 c++;
@@ -488,9 +495,7 @@ void ssl2_write_error(SSL *s)
488 495
489 error=s->error; /* number of bytes left to write */ 496 error=s->error; /* number of bytes left to write */
490 s->error=0; 497 s->error=0;
491 if (error < 0 || error > sizeof buf) /* can't happen */ 498 OPENSSL_assert(error >= 0 && error <= sizeof buf);
492 return;
493
494 i=ssl2_write(s,&(buf[3-error]),error); 499 i=ssl2_write(s,&(buf[3-error]),error);
495 500
496/* if (i == error) s->rwstate=state; */ 501/* if (i == error) s->rwstate=state; */
diff --git a/src/lib/libssl/src/ssl/s2_meth.c b/src/lib/libssl/src/ssl/s2_meth.c
index d30b7179f7..8b6cbd086e 100644
--- a/src/lib/libssl/src/ssl/s2_meth.c
+++ b/src/lib/libssl/src/ssl/s2_meth.c
@@ -77,12 +77,19 @@ SSL_METHOD *SSLv2_method(void)
77 77
78 if (init) 78 if (init)
79 { 79 {
80 memcpy((char *)&SSLv2_data,(char *)sslv2_base_method(), 80 CRYPTO_w_lock(CRYPTO_LOCK_SSL_METHOD);
81 sizeof(SSL_METHOD)); 81
82 SSLv2_data.ssl_connect=ssl2_connect; 82 if (init)
83 SSLv2_data.ssl_accept=ssl2_accept; 83 {
84 SSLv2_data.get_ssl_method=ssl2_get_method; 84 memcpy((char *)&SSLv2_data,(char *)sslv2_base_method(),
85 init=0; 85 sizeof(SSL_METHOD));
86 SSLv2_data.ssl_connect=ssl2_connect;
87 SSLv2_data.ssl_accept=ssl2_accept;
88 SSLv2_data.get_ssl_method=ssl2_get_method;
89 init=0;
90 }
91
92 CRYPTO_w_unlock(CRYPTO_LOCK_SSL_METHOD);
86 } 93 }
87 return(&SSLv2_data); 94 return(&SSLv2_data);
88 } 95 }
diff --git a/src/lib/libssl/src/ssl/s2_pkt.c b/src/lib/libssl/src/ssl/s2_pkt.c
index cf0aee2bd6..d82f137613 100644
--- a/src/lib/libssl/src/ssl/s2_pkt.c
+++ b/src/lib/libssl/src/ssl/s2_pkt.c
@@ -113,6 +113,7 @@
113#ifndef OPENSSL_NO_SSL2 113#ifndef OPENSSL_NO_SSL2
114#include <stdio.h> 114#include <stdio.h>
115#include <errno.h> 115#include <errno.h>
116#include "cryptlib.h"
116#define USE_SOCKETS 117#define USE_SOCKETS
117 118
118static int read_n(SSL *s,unsigned int n,unsigned int max,unsigned int extend); 119static int read_n(SSL *s,unsigned int n,unsigned int max,unsigned int extend);
@@ -247,6 +248,7 @@ static int ssl2_read_internal(SSL *s, void *buf, int len, int peek)
247 else 248 else
248 { 249 {
249 mac_size=EVP_MD_size(s->read_hash); 250 mac_size=EVP_MD_size(s->read_hash);
251 OPENSSL_assert(mac_size <= MAX_MAC_SIZE);
250 s->s2->mac_data=p; 252 s->s2->mac_data=p;
251 s->s2->ract_data= &p[mac_size]; 253 s->s2->ract_data= &p[mac_size];
252 if (s->s2->padding + mac_size > s->s2->rlength) 254 if (s->s2->padding + mac_size > s->s2->rlength)
diff --git a/src/lib/libssl/src/ssl/s2_srvr.c b/src/lib/libssl/src/ssl/s2_srvr.c
index 97dda2dde0..62859a2d95 100644
--- a/src/lib/libssl/src/ssl/s2_srvr.c
+++ b/src/lib/libssl/src/ssl/s2_srvr.c
@@ -145,11 +145,18 @@ SSL_METHOD *SSLv2_server_method(void)
145 145
146 if (init) 146 if (init)
147 { 147 {
148 memcpy((char *)&SSLv2_server_data,(char *)sslv2_base_method(), 148 CRYPTO_w_lock(CRYPTO_LOCK_SSL_METHOD);
149 sizeof(SSL_METHOD)); 149
150 SSLv2_server_data.ssl_accept=ssl2_accept; 150 if (init)
151 SSLv2_server_data.get_ssl_method=ssl2_get_server_method; 151 {
152 init=0; 152 memcpy((char *)&SSLv2_server_data,(char *)sslv2_base_method(),
153 sizeof(SSL_METHOD));
154 SSLv2_server_data.ssl_accept=ssl2_accept;
155 SSLv2_server_data.get_ssl_method=ssl2_get_server_method;
156 init=0;
157 }
158
159 CRYPTO_w_unlock(CRYPTO_LOCK_SSL_METHOD);
153 } 160 }
154 return(&SSLv2_server_data); 161 return(&SSLv2_server_data);
155 } 162 }
@@ -869,7 +876,7 @@ static int get_client_finished(SSL *s)
869 if (s->msg_callback) 876 if (s->msg_callback)
870 s->msg_callback(0, s->version, 0, p, len, s, s->msg_callback_arg); /* CLIENT-FINISHED */ 877 s->msg_callback(0, s->version, 0, p, len, s, s->msg_callback_arg); /* CLIENT-FINISHED */
871 p += 1; 878 p += 1;
872 if (memcmp(p,s->s2->conn_id,(unsigned int)s->s2->conn_id_length) != 0) 879 if (memcmp(p,s->s2->conn_id,s->s2->conn_id_length) != 0)
873 { 880 {
874 ssl2_return_error(s,SSL2_PE_UNDEFINED_ERROR); 881 ssl2_return_error(s,SSL2_PE_UNDEFINED_ERROR);
875 SSLerr(SSL_F_GET_CLIENT_FINISHED,SSL_R_CONNECTION_ID_IS_DIFFERENT); 882 SSLerr(SSL_F_GET_CLIENT_FINISHED,SSL_R_CONNECTION_ID_IS_DIFFERENT);
@@ -1069,7 +1076,7 @@ static int request_certificate(SSL *s)
1069 EVP_MD_CTX_init(&ctx); 1076 EVP_MD_CTX_init(&ctx);
1070 EVP_VerifyInit_ex(&ctx,s->ctx->rsa_md5, NULL); 1077 EVP_VerifyInit_ex(&ctx,s->ctx->rsa_md5, NULL);
1071 EVP_VerifyUpdate(&ctx,s->s2->key_material, 1078 EVP_VerifyUpdate(&ctx,s->s2->key_material,
1072 (unsigned int)s->s2->key_material_length); 1079 s->s2->key_material_length);
1073 EVP_VerifyUpdate(&ctx,ccd,SSL2_MIN_CERT_CHALLENGE_LENGTH); 1080 EVP_VerifyUpdate(&ctx,ccd,SSL2_MIN_CERT_CHALLENGE_LENGTH);
1074 1081
1075 i=i2d_X509(s->cert->pkeys[SSL_PKEY_RSA_ENC].x509,NULL); 1082 i=i2d_X509(s->cert->pkeys[SSL_PKEY_RSA_ENC].x509,NULL);
diff --git a/src/lib/libssl/src/ssl/s3_both.c b/src/lib/libssl/src/ssl/s3_both.c
index 8864366f59..64d317b7ac 100644
--- a/src/lib/libssl/src/ssl/s3_both.c
+++ b/src/lib/libssl/src/ssl/s3_both.c
@@ -268,16 +268,23 @@ unsigned long ssl3_output_cert_chain(SSL *s, X509 *x)
268 X509_STORE_CTX xs_ctx; 268 X509_STORE_CTX xs_ctx;
269 X509_OBJECT obj; 269 X509_OBJECT obj;
270 270
271 int no_chain;
272
273 if ((s->mode & SSL_MODE_NO_AUTO_CHAIN) || s->ctx->extra_certs)
274 no_chain = 1;
275 else
276 no_chain = 0;
277
271 /* TLSv1 sends a chain with nothing in it, instead of an alert */ 278 /* TLSv1 sends a chain with nothing in it, instead of an alert */
272 buf=s->init_buf; 279 buf=s->init_buf;
273 if (!BUF_MEM_grow(buf,(int)(10))) 280 if (!BUF_MEM_grow_clean(buf,10))
274 { 281 {
275 SSLerr(SSL_F_SSL3_OUTPUT_CERT_CHAIN,ERR_R_BUF_LIB); 282 SSLerr(SSL_F_SSL3_OUTPUT_CERT_CHAIN,ERR_R_BUF_LIB);
276 return(0); 283 return(0);
277 } 284 }
278 if (x != NULL) 285 if (x != NULL)
279 { 286 {
280 if(!X509_STORE_CTX_init(&xs_ctx,s->ctx->cert_store,NULL,NULL)) 287 if(!no_chain && !X509_STORE_CTX_init(&xs_ctx,s->ctx->cert_store,NULL,NULL))
281 { 288 {
282 SSLerr(SSL_F_SSL3_OUTPUT_CERT_CHAIN,ERR_R_X509_LIB); 289 SSLerr(SSL_F_SSL3_OUTPUT_CERT_CHAIN,ERR_R_X509_LIB);
283 return(0); 290 return(0);
@@ -286,7 +293,7 @@ unsigned long ssl3_output_cert_chain(SSL *s, X509 *x)
286 for (;;) 293 for (;;)
287 { 294 {
288 n=i2d_X509(x,NULL); 295 n=i2d_X509(x,NULL);
289 if (!BUF_MEM_grow(buf,(int)(n+l+3))) 296 if (!BUF_MEM_grow_clean(buf,(int)(n+l+3)))
290 { 297 {
291 SSLerr(SSL_F_SSL3_OUTPUT_CERT_CHAIN,ERR_R_BUF_LIB); 298 SSLerr(SSL_F_SSL3_OUTPUT_CERT_CHAIN,ERR_R_BUF_LIB);
292 return(0); 299 return(0);
@@ -295,6 +302,10 @@ unsigned long ssl3_output_cert_chain(SSL *s, X509 *x)
295 l2n3(n,p); 302 l2n3(n,p);
296 i2d_X509(x,&p); 303 i2d_X509(x,&p);
297 l+=n+3; 304 l+=n+3;
305
306 if (no_chain)
307 break;
308
298 if (X509_NAME_cmp(X509_get_subject_name(x), 309 if (X509_NAME_cmp(X509_get_subject_name(x),
299 X509_get_issuer_name(x)) == 0) break; 310 X509_get_issuer_name(x)) == 0) break;
300 311
@@ -306,8 +317,8 @@ unsigned long ssl3_output_cert_chain(SSL *s, X509 *x)
306 * ref count */ 317 * ref count */
307 X509_free(x); 318 X509_free(x);
308 } 319 }
309 320 if (!no_chain)
310 X509_STORE_CTX_cleanup(&xs_ctx); 321 X509_STORE_CTX_cleanup(&xs_ctx);
311 } 322 }
312 323
313 /* Thawte special :-) */ 324 /* Thawte special :-) */
@@ -316,7 +327,7 @@ unsigned long ssl3_output_cert_chain(SSL *s, X509 *x)
316 { 327 {
317 x=sk_X509_value(s->ctx->extra_certs,i); 328 x=sk_X509_value(s->ctx->extra_certs,i);
318 n=i2d_X509(x,NULL); 329 n=i2d_X509(x,NULL);
319 if (!BUF_MEM_grow(buf,(int)(n+l+3))) 330 if (!BUF_MEM_grow_clean(buf,(int)(n+l+3)))
320 { 331 {
321 SSLerr(SSL_F_SSL3_OUTPUT_CERT_CHAIN,ERR_R_BUF_LIB); 332 SSLerr(SSL_F_SSL3_OUTPUT_CERT_CHAIN,ERR_R_BUF_LIB);
322 return(0); 333 return(0);
@@ -439,7 +450,7 @@ long ssl3_get_message(SSL *s, int st1, int stn, int mt, long max, int *ok)
439 SSLerr(SSL_F_SSL3_GET_MESSAGE,SSL_R_EXCESSIVE_MESSAGE_SIZE); 450 SSLerr(SSL_F_SSL3_GET_MESSAGE,SSL_R_EXCESSIVE_MESSAGE_SIZE);
440 goto f_err; 451 goto f_err;
441 } 452 }
442 if (l && !BUF_MEM_grow(s->init_buf,(int)l+4)) 453 if (l && !BUF_MEM_grow_clean(s->init_buf,(int)l+4))
443 { 454 {
444 SSLerr(SSL_F_SSL3_GET_MESSAGE,ERR_R_BUF_LIB); 455 SSLerr(SSL_F_SSL3_GET_MESSAGE,ERR_R_BUF_LIB);
445 goto err; 456 goto err;
diff --git a/src/lib/libssl/src/ssl/s3_clnt.c b/src/lib/libssl/src/ssl/s3_clnt.c
index 2b58482484..fae8eadada 100644
--- a/src/lib/libssl/src/ssl/s3_clnt.c
+++ b/src/lib/libssl/src/ssl/s3_clnt.c
@@ -146,18 +146,25 @@ SSL_METHOD *SSLv3_client_method(void)
146 146
147 if (init) 147 if (init)
148 { 148 {
149 init=0; 149 CRYPTO_w_lock(CRYPTO_LOCK_SSL_METHOD);
150 memcpy((char *)&SSLv3_client_data,(char *)sslv3_base_method(), 150
151 sizeof(SSL_METHOD)); 151 if (init)
152 SSLv3_client_data.ssl_connect=ssl3_connect; 152 {
153 SSLv3_client_data.get_ssl_method=ssl3_get_client_method; 153 memcpy((char *)&SSLv3_client_data,(char *)sslv3_base_method(),
154 sizeof(SSL_METHOD));
155 SSLv3_client_data.ssl_connect=ssl3_connect;
156 SSLv3_client_data.get_ssl_method=ssl3_get_client_method;
157 init=0;
158 }
159
160 CRYPTO_w_unlock(CRYPTO_LOCK_SSL_METHOD);
154 } 161 }
155 return(&SSLv3_client_data); 162 return(&SSLv3_client_data);
156 } 163 }
157 164
158int ssl3_connect(SSL *s) 165int ssl3_connect(SSL *s)
159 { 166 {
160 BUF_MEM *buf; 167 BUF_MEM *buf=NULL;
161 unsigned long Time=time(NULL),l; 168 unsigned long Time=time(NULL),l;
162 long num1; 169 long num1;
163 void (*cb)(const SSL *ssl,int type,int val)=NULL; 170 void (*cb)(const SSL *ssl,int type,int val)=NULL;
@@ -218,6 +225,7 @@ int ssl3_connect(SSL *s)
218 goto end; 225 goto end;
219 } 226 }
220 s->init_buf=buf; 227 s->init_buf=buf;
228 buf=NULL;
221 } 229 }
222 230
223 if (!ssl3_setup_buffers(s)) { ret= -1; goto end; } 231 if (!ssl3_setup_buffers(s)) { ret= -1; goto end; }
@@ -496,6 +504,8 @@ int ssl3_connect(SSL *s)
496 } 504 }
497end: 505end:
498 s->in_handshake--; 506 s->in_handshake--;
507 if (buf != NULL)
508 BUF_MEM_free(buf);
499 if (cb != NULL) 509 if (cb != NULL)
500 cb(s,SSL_CB_CONNECT_EXIT,ret); 510 cb(s,SSL_CB_CONNECT_EXIT,ret);
501 return(ret); 511 return(ret);
@@ -632,30 +642,20 @@ static int ssl3_get_server_hello(SSL *s)
632 /* get the session-id */ 642 /* get the session-id */
633 j= *(p++); 643 j= *(p++);
634 644
635 if(j > sizeof s->session->session_id) 645 if ((j > sizeof s->session->session_id) || (j > SSL3_SESSION_ID_SIZE))
636 {
637 al=SSL_AD_ILLEGAL_PARAMETER;
638 SSLerr(SSL_F_SSL3_GET_SERVER_HELLO,
639 SSL_R_SSL3_SESSION_ID_TOO_LONG);
640 goto f_err;
641 }
642
643 if ((j != 0) && (j != SSL3_SESSION_ID_SIZE))
644 { 646 {
645 /* SSLref returns 16 :-( */ 647 al=SSL_AD_ILLEGAL_PARAMETER;
646 if (j < SSL2_SSL_SESSION_ID_LENGTH) 648 SSLerr(SSL_F_SSL3_GET_SERVER_HELLO,SSL_R_SSL3_SESSION_ID_TOO_LONG);
647 { 649 goto f_err;
648 al=SSL_AD_ILLEGAL_PARAMETER;
649 SSLerr(SSL_F_SSL3_GET_SERVER_HELLO,SSL_R_SSL3_SESSION_ID_TOO_SHORT);
650 goto f_err;
651 }
652 } 650 }
651
653 if (j != 0 && j == s->session->session_id_length 652 if (j != 0 && j == s->session->session_id_length
654 && memcmp(p,s->session->session_id,j) == 0) 653 && memcmp(p,s->session->session_id,j) == 0)
655 { 654 {
656 if(s->sid_ctx_length != s->session->sid_ctx_length 655 if(s->sid_ctx_length != s->session->sid_ctx_length
657 || memcmp(s->session->sid_ctx,s->sid_ctx,s->sid_ctx_length)) 656 || memcmp(s->session->sid_ctx,s->sid_ctx,s->sid_ctx_length))
658 { 657 {
658 /* actually a client application bug */
659 al=SSL_AD_ILLEGAL_PARAMETER; 659 al=SSL_AD_ILLEGAL_PARAMETER;
660 SSLerr(SSL_F_SSL3_GET_SERVER_HELLO,SSL_R_ATTEMPT_TO_REUSE_SESSION_IN_DIFFERENT_CONTEXT); 660 SSLerr(SSL_F_SSL3_GET_SERVER_HELLO,SSL_R_ATTEMPT_TO_REUSE_SESSION_IN_DIFFERENT_CONTEXT);
661 goto f_err; 661 goto f_err;
@@ -699,7 +699,12 @@ static int ssl3_get_server_hello(SSL *s)
699 goto f_err; 699 goto f_err;
700 } 700 }
701 701
702 if (s->hit && (s->session->cipher != c)) 702 /* Depending on the session caching (internal/external), the cipher
703 and/or cipher_id values may not be set. Make sure that
704 cipher_id is set and use it for comparison. */
705 if (s->session->cipher)
706 s->session->cipher_id = s->session->cipher->id;
707 if (s->hit && (s->session->cipher_id != c->id))
703 { 708 {
704 if (!(s->options & 709 if (!(s->options &
705 SSL_OP_NETSCAPE_REUSE_CIPHER_CHANGE_BUG)) 710 SSL_OP_NETSCAPE_REUSE_CIPHER_CHANGE_BUG))
@@ -1457,16 +1462,16 @@ static int ssl3_send_client_key_exchange(SSL *s)
1457 1462
1458 tmp_buf[0]=s->client_version>>8; 1463 tmp_buf[0]=s->client_version>>8;
1459 tmp_buf[1]=s->client_version&0xff; 1464 tmp_buf[1]=s->client_version&0xff;
1460 if (RAND_bytes(&(tmp_buf[2]),SSL_MAX_MASTER_KEY_LENGTH-2) <= 0) 1465 if (RAND_bytes(&(tmp_buf[2]),sizeof tmp_buf-2) <= 0)
1461 goto err; 1466 goto err;
1462 1467
1463 s->session->master_key_length=SSL_MAX_MASTER_KEY_LENGTH; 1468 s->session->master_key_length=sizeof tmp_buf;
1464 1469
1465 q=p; 1470 q=p;
1466 /* Fix buf for TLS and beyond */ 1471 /* Fix buf for TLS and beyond */
1467 if (s->version > SSL3_VERSION) 1472 if (s->version > SSL3_VERSION)
1468 p+=2; 1473 p+=2;
1469 n=RSA_public_encrypt(SSL_MAX_MASTER_KEY_LENGTH, 1474 n=RSA_public_encrypt(sizeof tmp_buf,
1470 tmp_buf,p,rsa,RSA_PKCS1_PADDING); 1475 tmp_buf,p,rsa,RSA_PKCS1_PADDING);
1471#ifdef PKCS1_CHECK 1476#ifdef PKCS1_CHECK
1472 if (s->options & SSL_OP_PKCS1_CHECK_1) p[1]++; 1477 if (s->options & SSL_OP_PKCS1_CHECK_1) p[1]++;
@@ -1488,8 +1493,8 @@ static int ssl3_send_client_key_exchange(SSL *s)
1488 s->session->master_key_length= 1493 s->session->master_key_length=
1489 s->method->ssl3_enc->generate_master_secret(s, 1494 s->method->ssl3_enc->generate_master_secret(s,
1490 s->session->master_key, 1495 s->session->master_key,
1491 tmp_buf,SSL_MAX_MASTER_KEY_LENGTH); 1496 tmp_buf,sizeof tmp_buf);
1492 memset(tmp_buf,0,SSL_MAX_MASTER_KEY_LENGTH); 1497 OPENSSL_cleanse(tmp_buf,sizeof tmp_buf);
1493 } 1498 }
1494#endif 1499#endif
1495#ifndef OPENSSL_NO_KRB5 1500#ifndef OPENSSL_NO_KRB5
@@ -1585,7 +1590,7 @@ static int ssl3_send_client_key_exchange(SSL *s)
1585 n+=2; 1590 n+=2;
1586 } 1591 }
1587 1592
1588 if (RAND_bytes(tmp_buf,SSL_MAX_MASTER_KEY_LENGTH) <= 0) 1593 if (RAND_bytes(tmp_buf,sizeof tmp_buf) <= 0)
1589 goto err; 1594 goto err;
1590 1595
1591 /* 20010420 VRS. Tried it this way; failed. 1596 /* 20010420 VRS. Tried it this way; failed.
@@ -1595,11 +1600,11 @@ static int ssl3_send_client_key_exchange(SSL *s)
1595 ** EVP_EncryptInit_ex(&ciph_ctx,NULL, key,iv); 1600 ** EVP_EncryptInit_ex(&ciph_ctx,NULL, key,iv);
1596 */ 1601 */
1597 1602
1598 memset(iv, 0, EVP_MAX_IV_LENGTH); /* per RFC 1510 */ 1603 memset(iv, 0, sizeof iv); /* per RFC 1510 */
1599 EVP_EncryptInit_ex(&ciph_ctx,enc, NULL, 1604 EVP_EncryptInit_ex(&ciph_ctx,enc, NULL,
1600 kssl_ctx->key,iv); 1605 kssl_ctx->key,iv);
1601 EVP_EncryptUpdate(&ciph_ctx,epms,&outl,tmp_buf, 1606 EVP_EncryptUpdate(&ciph_ctx,epms,&outl,tmp_buf,
1602 SSL_MAX_MASTER_KEY_LENGTH); 1607 sizeof tmp_buf);
1603 EVP_EncryptFinal_ex(&ciph_ctx,&(epms[outl]),&padl); 1608 EVP_EncryptFinal_ex(&ciph_ctx,&(epms[outl]),&padl);
1604 outl += padl; 1609 outl += padl;
1605 if (outl > sizeof epms) 1610 if (outl > sizeof epms)
@@ -1618,10 +1623,10 @@ static int ssl3_send_client_key_exchange(SSL *s)
1618 s->session->master_key_length= 1623 s->session->master_key_length=
1619 s->method->ssl3_enc->generate_master_secret(s, 1624 s->method->ssl3_enc->generate_master_secret(s,
1620 s->session->master_key, 1625 s->session->master_key,
1621 tmp_buf, SSL_MAX_MASTER_KEY_LENGTH); 1626 tmp_buf, sizeof tmp_buf);
1622 1627
1623 memset(tmp_buf, 0, SSL_MAX_MASTER_KEY_LENGTH); 1628 OPENSSL_cleanse(tmp_buf, sizeof tmp_buf);
1624 memset(epms, 0, outl); 1629 OPENSSL_cleanse(epms, outl);
1625 } 1630 }
1626#endif 1631#endif
1627#ifndef OPENSSL_NO_DH 1632#ifndef OPENSSL_NO_DH
diff --git a/src/lib/libssl/src/ssl/s3_enc.c b/src/lib/libssl/src/ssl/s3_enc.c
index 888a9a2868..559924d368 100644
--- a/src/lib/libssl/src/ssl/s3_enc.c
+++ b/src/lib/libssl/src/ssl/s3_enc.c
@@ -182,7 +182,7 @@ static int ssl3_generate_key_block(SSL *s, unsigned char *km, int num)
182 182
183 km+=MD5_DIGEST_LENGTH; 183 km+=MD5_DIGEST_LENGTH;
184 } 184 }
185 memset(smd,0,SHA_DIGEST_LENGTH); 185 OPENSSL_cleanse(smd,SHA_DIGEST_LENGTH);
186 EVP_MD_CTX_cleanup(&m5); 186 EVP_MD_CTX_cleanup(&m5);
187 EVP_MD_CTX_cleanup(&s1); 187 EVP_MD_CTX_cleanup(&s1);
188 return 1; 188 return 1;
@@ -192,7 +192,7 @@ int ssl3_change_cipher_state(SSL *s, int which)
192 { 192 {
193 unsigned char *p,*key_block,*mac_secret; 193 unsigned char *p,*key_block,*mac_secret;
194 unsigned char exp_key[EVP_MAX_KEY_LENGTH]; 194 unsigned char exp_key[EVP_MAX_KEY_LENGTH];
195 unsigned char exp_iv[EVP_MAX_KEY_LENGTH]; 195 unsigned char exp_iv[EVP_MAX_IV_LENGTH];
196 unsigned char *ms,*key,*iv,*er1,*er2; 196 unsigned char *ms,*key,*iv,*er1,*er2;
197 EVP_CIPHER_CTX *dd; 197 EVP_CIPHER_CTX *dd;
198 const EVP_CIPHER *c; 198 const EVP_CIPHER *c;
@@ -333,8 +333,8 @@ int ssl3_change_cipher_state(SSL *s, int which)
333 333
334 EVP_CipherInit_ex(dd,c,NULL,key,iv,(which & SSL3_CC_WRITE)); 334 EVP_CipherInit_ex(dd,c,NULL,key,iv,(which & SSL3_CC_WRITE));
335 335
336 memset(&(exp_key[0]),0,sizeof(exp_key)); 336 OPENSSL_cleanse(&(exp_key[0]),sizeof(exp_key));
337 memset(&(exp_iv[0]),0,sizeof(exp_iv)); 337 OPENSSL_cleanse(&(exp_iv[0]),sizeof(exp_iv));
338 EVP_MD_CTX_cleanup(&md); 338 EVP_MD_CTX_cleanup(&md);
339 return(1); 339 return(1);
340err: 340err:
@@ -408,7 +408,7 @@ void ssl3_cleanup_key_block(SSL *s)
408 { 408 {
409 if (s->s3->tmp.key_block != NULL) 409 if (s->s3->tmp.key_block != NULL)
410 { 410 {
411 memset(s->s3->tmp.key_block,0, 411 OPENSSL_cleanse(s->s3->tmp.key_block,
412 s->s3->tmp.key_block_length); 412 s->s3->tmp.key_block_length);
413 OPENSSL_free(s->s3->tmp.key_block); 413 OPENSSL_free(s->s3->tmp.key_block);
414 s->s3->tmp.key_block=NULL; 414 s->s3->tmp.key_block=NULL;
@@ -474,6 +474,7 @@ int ssl3_enc(SSL *s, int send)
474 ssl3_send_alert(s,SSL3_AL_FATAL,SSL_AD_DECRYPTION_FAILED); 474 ssl3_send_alert(s,SSL3_AL_FATAL,SSL_AD_DECRYPTION_FAILED);
475 return 0; 475 return 0;
476 } 476 }
477 /* otherwise, rec->length >= bs */
477 } 478 }
478 479
479 EVP_Cipher(ds,rec->data,rec->input,l); 480 EVP_Cipher(ds,rec->data,rec->input,l);
@@ -482,7 +483,7 @@ int ssl3_enc(SSL *s, int send)
482 { 483 {
483 i=rec->data[l-1]+1; 484 i=rec->data[l-1]+1;
484 /* SSL 3.0 bounds the number of padding bytes by the block size; 485 /* SSL 3.0 bounds the number of padding bytes by the block size;
485 * padding bytes (except that last) are arbitrary */ 486 * padding bytes (except the last one) are arbitrary */
486 if (i > bs) 487 if (i > bs)
487 { 488 {
488 /* Incorrect padding. SSLerr() and ssl3_alert are done 489 /* Incorrect padding. SSLerr() and ssl3_alert are done
@@ -491,6 +492,7 @@ int ssl3_enc(SSL *s, int send)
491 * (see http://www.openssl.org/~bodo/tls-cbc.txt) */ 492 * (see http://www.openssl.org/~bodo/tls-cbc.txt) */
492 return -1; 493 return -1;
493 } 494 }
495 /* now i <= bs <= rec->length */
494 rec->length-=i; 496 rec->length-=i;
495 } 497 }
496 } 498 }
diff --git a/src/lib/libssl/src/ssl/s3_lib.c b/src/lib/libssl/src/ssl/s3_lib.c
index 14b2f13ae2..896b12fc4f 100644
--- a/src/lib/libssl/src/ssl/s3_lib.c
+++ b/src/lib/libssl/src/ssl/s3_lib.c
@@ -512,6 +512,7 @@ OPENSSL_GLOBAL SSL_CIPHER ssl3_ciphers[]={
512 SSL_ALL_STRENGTHS, 512 SSL_ALL_STRENGTHS,
513 }, 513 },
514 514
515#if 0
515/* Cipher 1E */ 516/* Cipher 1E */
516 { 517 {
517 0, 518 0,
@@ -525,55 +526,70 @@ OPENSSL_GLOBAL SSL_CIPHER ssl3_ciphers[]={
525 SSL_ALL_CIPHERS, 526 SSL_ALL_CIPHERS,
526 SSL_ALL_STRENGTHS, 527 SSL_ALL_STRENGTHS,
527 }, 528 },
529#endif
528 530
529#ifndef OPENSSL_NO_KRB5 531#ifndef OPENSSL_NO_KRB5
530/* The Kerberos ciphers 532/* The Kerberos ciphers
531** 20000107 VRS: And the first shall be last, 533** 20000107 VRS: And the first shall be last,
532** in hopes of avoiding the lynx ssl renegotiation problem. 534** in hopes of avoiding the lynx ssl renegotiation problem.
533*/ 535*/
534/* Cipher 21 VRS */ 536/* Cipher 1E VRS */
535 { 537 {
536 1, 538 1,
537 SSL3_TXT_KRB5_DES_40_CBC_SHA, 539 SSL3_TXT_KRB5_DES_64_CBC_SHA,
538 SSL3_CK_KRB5_DES_40_CBC_SHA, 540 SSL3_CK_KRB5_DES_64_CBC_SHA,
539 SSL_kKRB5|SSL_aKRB5| SSL_DES|SSL_SHA1 |SSL_SSLV3, 541 SSL_kKRB5|SSL_aKRB5| SSL_DES|SSL_SHA1 |SSL_SSLV3,
540 SSL_EXPORT|SSL_EXP40, 542 SSL_NOT_EXP|SSL_LOW,
541 0, 543 0,
542 40, 544 56,
543 56, 545 56,
544 SSL_ALL_CIPHERS, 546 SSL_ALL_CIPHERS,
545 SSL_ALL_STRENGTHS, 547 SSL_ALL_STRENGTHS,
546 }, 548 },
547 549
548/* Cipher 22 VRS */ 550/* Cipher 1F VRS */
549 { 551 {
550 1, 552 1,
551 SSL3_TXT_KRB5_DES_40_CBC_MD5, 553 SSL3_TXT_KRB5_DES_192_CBC3_SHA,
552 SSL3_CK_KRB5_DES_40_CBC_MD5, 554 SSL3_CK_KRB5_DES_192_CBC3_SHA,
553 SSL_kKRB5|SSL_aKRB5| SSL_DES|SSL_MD5 |SSL_SSLV3, 555 SSL_kKRB5|SSL_aKRB5| SSL_3DES|SSL_SHA1 |SSL_SSLV3,
554 SSL_EXPORT|SSL_EXP40, 556 SSL_NOT_EXP|SSL_HIGH,
555 0, 557 0,
556 40, 558 112,
557 56, 559 168,
558 SSL_ALL_CIPHERS, 560 SSL_ALL_CIPHERS,
559 SSL_ALL_STRENGTHS, 561 SSL_ALL_STRENGTHS,
560 }, 562 },
561 563
562/* Cipher 23 VRS */ 564/* Cipher 20 VRS */
563 { 565 {
564 1, 566 1,
565 SSL3_TXT_KRB5_DES_64_CBC_SHA, 567 SSL3_TXT_KRB5_RC4_128_SHA,
566 SSL3_CK_KRB5_DES_64_CBC_SHA, 568 SSL3_CK_KRB5_RC4_128_SHA,
567 SSL_kKRB5|SSL_aKRB5| SSL_DES|SSL_SHA1 |SSL_SSLV3, 569 SSL_kKRB5|SSL_aKRB5| SSL_RC4|SSL_SHA1 |SSL_SSLV3,
568 SSL_NOT_EXP|SSL_LOW, 570 SSL_NOT_EXP|SSL_MEDIUM,
569 0, 571 0,
570 56, 572 128,
571 56, 573 128,
572 SSL_ALL_CIPHERS, 574 SSL_ALL_CIPHERS,
573 SSL_ALL_STRENGTHS, 575 SSL_ALL_STRENGTHS,
574 }, 576 },
575 577
576/* Cipher 24 VRS */ 578/* Cipher 21 VRS */
579 {
580 1,
581 SSL3_TXT_KRB5_IDEA_128_CBC_SHA,
582 SSL3_CK_KRB5_IDEA_128_CBC_SHA,
583 SSL_kKRB5|SSL_aKRB5| SSL_IDEA|SSL_SHA1 |SSL_SSLV3,
584 SSL_NOT_EXP|SSL_MEDIUM,
585 0,
586 128,
587 128,
588 SSL_ALL_CIPHERS,
589 SSL_ALL_STRENGTHS,
590 },
591
592/* Cipher 22 VRS */
577 { 593 {
578 1, 594 1,
579 SSL3_TXT_KRB5_DES_64_CBC_MD5, 595 SSL3_TXT_KRB5_DES_64_CBC_MD5,
@@ -587,12 +603,12 @@ OPENSSL_GLOBAL SSL_CIPHER ssl3_ciphers[]={
587 SSL_ALL_STRENGTHS, 603 SSL_ALL_STRENGTHS,
588 }, 604 },
589 605
590/* Cipher 25 VRS */ 606/* Cipher 23 VRS */
591 { 607 {
592 1, 608 1,
593 SSL3_TXT_KRB5_DES_192_CBC3_SHA, 609 SSL3_TXT_KRB5_DES_192_CBC3_MD5,
594 SSL3_CK_KRB5_DES_192_CBC3_SHA, 610 SSL3_CK_KRB5_DES_192_CBC3_MD5,
595 SSL_kKRB5|SSL_aKRB5| SSL_3DES|SSL_SHA1 |SSL_SSLV3, 611 SSL_kKRB5|SSL_aKRB5| SSL_3DES|SSL_MD5 |SSL_SSLV3,
596 SSL_NOT_EXP|SSL_HIGH, 612 SSL_NOT_EXP|SSL_HIGH,
597 0, 613 0,
598 112, 614 112,
@@ -601,16 +617,114 @@ OPENSSL_GLOBAL SSL_CIPHER ssl3_ciphers[]={
601 SSL_ALL_STRENGTHS, 617 SSL_ALL_STRENGTHS,
602 }, 618 },
603 619
620/* Cipher 24 VRS */
621 {
622 1,
623 SSL3_TXT_KRB5_RC4_128_MD5,
624 SSL3_CK_KRB5_RC4_128_MD5,
625 SSL_kKRB5|SSL_aKRB5| SSL_RC4|SSL_MD5 |SSL_SSLV3,
626 SSL_NOT_EXP|SSL_MEDIUM,
627 0,
628 128,
629 128,
630 SSL_ALL_CIPHERS,
631 SSL_ALL_STRENGTHS,
632 },
633
634/* Cipher 25 VRS */
635 {
636 1,
637 SSL3_TXT_KRB5_IDEA_128_CBC_MD5,
638 SSL3_CK_KRB5_IDEA_128_CBC_MD5,
639 SSL_kKRB5|SSL_aKRB5| SSL_IDEA|SSL_MD5 |SSL_SSLV3,
640 SSL_NOT_EXP|SSL_MEDIUM,
641 0,
642 128,
643 128,
644 SSL_ALL_CIPHERS,
645 SSL_ALL_STRENGTHS,
646 },
647
604/* Cipher 26 VRS */ 648/* Cipher 26 VRS */
605 { 649 {
606 1, 650 1,
607 SSL3_TXT_KRB5_DES_192_CBC3_MD5, 651 SSL3_TXT_KRB5_DES_40_CBC_SHA,
608 SSL3_CK_KRB5_DES_192_CBC3_MD5, 652 SSL3_CK_KRB5_DES_40_CBC_SHA,
609 SSL_kKRB5|SSL_aKRB5| SSL_3DES|SSL_MD5 |SSL_SSLV3, 653 SSL_kKRB5|SSL_aKRB5| SSL_DES|SSL_SHA1 |SSL_SSLV3,
610 SSL_NOT_EXP|SSL_HIGH, 654 SSL_EXPORT|SSL_EXP40,
611 0, 655 0,
612 112, 656 40,
613 168, 657 56,
658 SSL_ALL_CIPHERS,
659 SSL_ALL_STRENGTHS,
660 },
661
662/* Cipher 27 VRS */
663 {
664 1,
665 SSL3_TXT_KRB5_RC2_40_CBC_SHA,
666 SSL3_CK_KRB5_RC2_40_CBC_SHA,
667 SSL_kKRB5|SSL_aKRB5| SSL_RC2|SSL_SHA1 |SSL_SSLV3,
668 SSL_EXPORT|SSL_EXP40,
669 0,
670 40,
671 128,
672 SSL_ALL_CIPHERS,
673 SSL_ALL_STRENGTHS,
674 },
675
676/* Cipher 28 VRS */
677 {
678 1,
679 SSL3_TXT_KRB5_RC4_40_SHA,
680 SSL3_CK_KRB5_RC4_40_SHA,
681 SSL_kKRB5|SSL_aKRB5| SSL_RC4|SSL_SHA1 |SSL_SSLV3,
682 SSL_EXPORT|SSL_EXP40,
683 0,
684 128,
685 128,
686 SSL_ALL_CIPHERS,
687 SSL_ALL_STRENGTHS,
688 },
689
690/* Cipher 29 VRS */
691 {
692 1,
693 SSL3_TXT_KRB5_DES_40_CBC_MD5,
694 SSL3_CK_KRB5_DES_40_CBC_MD5,
695 SSL_kKRB5|SSL_aKRB5| SSL_DES|SSL_MD5 |SSL_SSLV3,
696 SSL_EXPORT|SSL_EXP40,
697 0,
698 40,
699 56,
700 SSL_ALL_CIPHERS,
701 SSL_ALL_STRENGTHS,
702 },
703
704/* Cipher 2A VRS */
705 {
706 1,
707 SSL3_TXT_KRB5_RC2_40_CBC_MD5,
708 SSL3_CK_KRB5_RC2_40_CBC_MD5,
709 SSL_kKRB5|SSL_aKRB5| SSL_RC2|SSL_MD5 |SSL_SSLV3,
710 SSL_EXPORT|SSL_EXP40,
711 0,
712 40,
713 128,
714 SSL_ALL_CIPHERS,
715 SSL_ALL_STRENGTHS,
716 },
717
718/* Cipher 2B VRS */
719 {
720 1,
721 SSL3_TXT_KRB5_RC4_40_MD5,
722 SSL3_CK_KRB5_RC4_40_MD5,
723 SSL_kKRB5|SSL_aKRB5| SSL_RC4|SSL_MD5 |SSL_SSLV3,
724 SSL_EXPORT|SSL_EXP40,
725 0,
726 128,
727 128,
614 SSL_ALL_CIPHERS, 728 SSL_ALL_CIPHERS,
615 SSL_ALL_STRENGTHS, 729 SSL_ALL_STRENGTHS,
616 }, 730 },
@@ -986,7 +1100,7 @@ void ssl3_free(SSL *s)
986 sk_X509_NAME_pop_free(s->s3->tmp.ca_names,X509_NAME_free); 1100 sk_X509_NAME_pop_free(s->s3->tmp.ca_names,X509_NAME_free);
987 EVP_MD_CTX_cleanup(&s->s3->finish_dgst1); 1101 EVP_MD_CTX_cleanup(&s->s3->finish_dgst1);
988 EVP_MD_CTX_cleanup(&s->s3->finish_dgst2); 1102 EVP_MD_CTX_cleanup(&s->s3->finish_dgst2);
989 memset(s->s3,0,sizeof *s->s3); 1103 OPENSSL_cleanse(s->s3,sizeof *s->s3);
990 OPENSSL_free(s->s3); 1104 OPENSSL_free(s->s3);
991 s->s3=NULL; 1105 s->s3=NULL;
992 } 1106 }
@@ -1341,16 +1455,19 @@ SSL_CIPHER *ssl3_get_cipher_by_char(const unsigned char *p)
1341 { 1455 {
1342 CRYPTO_w_lock(CRYPTO_LOCK_SSL); 1456 CRYPTO_w_lock(CRYPTO_LOCK_SSL);
1343 1457
1344 for (i=0; i<SSL3_NUM_CIPHERS; i++) 1458 if (init)
1345 sorted[i]= &(ssl3_ciphers[i]); 1459 {
1460 for (i=0; i<SSL3_NUM_CIPHERS; i++)
1461 sorted[i]= &(ssl3_ciphers[i]);
1346 1462
1347 qsort( (char *)sorted, 1463 qsort(sorted,
1348 SSL3_NUM_CIPHERS,sizeof(SSL_CIPHER *), 1464 SSL3_NUM_CIPHERS,sizeof(SSL_CIPHER *),
1349 FP_ICC ssl_cipher_ptr_id_cmp); 1465 FP_ICC ssl_cipher_ptr_id_cmp);
1350 1466
1467 init=0;
1468 }
1469
1351 CRYPTO_w_unlock(CRYPTO_LOCK_SSL); 1470 CRYPTO_w_unlock(CRYPTO_LOCK_SSL);
1352
1353 init=0;
1354 } 1471 }
1355 1472
1356 id=0x03000000L|((unsigned long)p[0]<<8L)|(unsigned long)p[1]; 1473 id=0x03000000L|((unsigned long)p[0]<<8L)|(unsigned long)p[1];
diff --git a/src/lib/libssl/src/ssl/s3_meth.c b/src/lib/libssl/src/ssl/s3_meth.c
index 81bcad89c5..1fd7a96f87 100644
--- a/src/lib/libssl/src/ssl/s3_meth.c
+++ b/src/lib/libssl/src/ssl/s3_meth.c
@@ -76,12 +76,19 @@ SSL_METHOD *SSLv3_method(void)
76 76
77 if (init) 77 if (init)
78 { 78 {
79 memcpy((char *)&SSLv3_data,(char *)sslv3_base_method(), 79 CRYPTO_w_lock(CRYPTO_LOCK_SSL_METHOD);
80 sizeof(SSL_METHOD)); 80
81 SSLv3_data.ssl_connect=ssl3_connect; 81 if (init)
82 SSLv3_data.ssl_accept=ssl3_accept; 82 {
83 SSLv3_data.get_ssl_method=ssl3_get_method; 83 memcpy((char *)&SSLv3_data,(char *)sslv3_base_method(),
84 init=0; 84 sizeof(SSL_METHOD));
85 SSLv3_data.ssl_connect=ssl3_connect;
86 SSLv3_data.ssl_accept=ssl3_accept;
87 SSLv3_data.get_ssl_method=ssl3_get_method;
88 init=0;
89 }
90
91 CRYPTO_w_unlock(CRYPTO_LOCK_SSL_METHOD);
85 } 92 }
86 return(&SSLv3_data); 93 return(&SSLv3_data);
87 } 94 }
diff --git a/src/lib/libssl/src/ssl/s3_pkt.c b/src/lib/libssl/src/ssl/s3_pkt.c
index 6ccea9aee5..3f88429e79 100644
--- a/src/lib/libssl/src/ssl/s3_pkt.c
+++ b/src/lib/libssl/src/ssl/s3_pkt.c
@@ -238,6 +238,8 @@ static int ssl3_get_record(SSL *s)
238 unsigned int mac_size; 238 unsigned int mac_size;
239 int clear=0; 239 int clear=0;
240 size_t extra; 240 size_t extra;
241 int decryption_failed_or_bad_record_mac = 0;
242 unsigned char *mac = NULL;
241 243
242 rr= &(s->s3->rrec); 244 rr= &(s->s3->rrec);
243 sess=s->session; 245 sess=s->session;
@@ -353,8 +355,11 @@ again:
353 /* SSLerr() and ssl3_send_alert() have been called */ 355 /* SSLerr() and ssl3_send_alert() have been called */
354 goto err; 356 goto err;
355 357
356 /* otherwise enc_err == -1 */ 358 /* Otherwise enc_err == -1, which indicates bad padding
357 goto decryption_failed_or_bad_record_mac; 359 * (rec->length has not been changed in this case).
360 * To minimize information leaked via timing, we will perform
361 * the MAC computation anyway. */
362 decryption_failed_or_bad_record_mac = 1;
358 } 363 }
359 364
360#ifdef TLS_DEBUG 365#ifdef TLS_DEBUG
@@ -380,28 +385,46 @@ printf("\n");
380 SSLerr(SSL_F_SSL3_GET_RECORD,SSL_R_PRE_MAC_LENGTH_TOO_LONG); 385 SSLerr(SSL_F_SSL3_GET_RECORD,SSL_R_PRE_MAC_LENGTH_TOO_LONG);
381 goto f_err; 386 goto f_err;
382#else 387#else
383 goto decryption_failed_or_bad_record_mac; 388 decryption_failed_or_bad_record_mac = 1;
384#endif 389#endif
385 } 390 }
386 /* check the MAC for rr->input (it's in mac_size bytes at the tail) */ 391 /* check the MAC for rr->input (it's in mac_size bytes at the tail) */
387 if (rr->length < mac_size) 392 if (rr->length >= mac_size)
388 { 393 {
394 rr->length -= mac_size;
395 mac = &rr->data[rr->length];
396 }
397 else
398 {
399 /* record (minus padding) is too short to contain a MAC */
389#if 0 /* OK only for stream ciphers */ 400#if 0 /* OK only for stream ciphers */
390 al=SSL_AD_DECODE_ERROR; 401 al=SSL_AD_DECODE_ERROR;
391 SSLerr(SSL_F_SSL3_GET_RECORD,SSL_R_LENGTH_TOO_SHORT); 402 SSLerr(SSL_F_SSL3_GET_RECORD,SSL_R_LENGTH_TOO_SHORT);
392 goto f_err; 403 goto f_err;
393#else 404#else
394 goto decryption_failed_or_bad_record_mac; 405 decryption_failed_or_bad_record_mac = 1;
406 rr->length = 0;
395#endif 407#endif
396 } 408 }
397 rr->length-=mac_size;
398 i=s->method->ssl3_enc->mac(s,md,0); 409 i=s->method->ssl3_enc->mac(s,md,0);
399 if (memcmp(md,&(rr->data[rr->length]),mac_size) != 0) 410 if (mac == NULL || memcmp(md, mac, mac_size) != 0)
400 { 411 {
401 goto decryption_failed_or_bad_record_mac; 412 decryption_failed_or_bad_record_mac = 1;
402 } 413 }
403 } 414 }
404 415
416 if (decryption_failed_or_bad_record_mac)
417 {
418 /* A separate 'decryption_failed' alert was introduced with TLS 1.0,
419 * SSL 3.0 only has 'bad_record_mac'. But unless a decryption
420 * failure is directly visible from the ciphertext anyway,
421 * we should not reveal which kind of error occured -- this
422 * might become visible to an attacker (e.g. via a logfile) */
423 al=SSL_AD_BAD_RECORD_MAC;
424 SSLerr(SSL_F_SSL3_GET_RECORD,SSL_R_DECRYPTION_FAILED_OR_BAD_RECORD_MAC);
425 goto f_err;
426 }
427
405 /* r->length is now just compressed */ 428 /* r->length is now just compressed */
406 if (s->expand != NULL) 429 if (s->expand != NULL)
407 { 430 {
@@ -443,14 +466,6 @@ printf("\n");
443 466
444 return(1); 467 return(1);
445 468
446decryption_failed_or_bad_record_mac:
447 /* Separate 'decryption_failed' alert was introduced with TLS 1.0,
448 * SSL 3.0 only has 'bad_record_mac'. But unless a decryption
449 * failure is directly visible from the ciphertext anyway,
450 * we should not reveal which kind of error occured -- this
451 * might become visible to an attacker (e.g. via logfile) */
452 al=SSL_AD_BAD_RECORD_MAC;
453 SSLerr(SSL_F_SSL3_GET_RECORD,SSL_R_DECRYPTION_FAILED_OR_BAD_RECORD_MAC);
454f_err: 469f_err:
455 ssl3_send_alert(s,SSL3_AL_FATAL,al); 470 ssl3_send_alert(s,SSL3_AL_FATAL,al);
456err: 471err:
diff --git a/src/lib/libssl/src/ssl/s3_srvr.c b/src/lib/libssl/src/ssl/s3_srvr.c
index 20d716fb1b..58cf774967 100644
--- a/src/lib/libssl/src/ssl/s3_srvr.c
+++ b/src/lib/libssl/src/ssl/s3_srvr.c
@@ -152,11 +152,18 @@ SSL_METHOD *SSLv3_server_method(void)
152 152
153 if (init) 153 if (init)
154 { 154 {
155 memcpy((char *)&SSLv3_server_data,(char *)sslv3_base_method(), 155 CRYPTO_w_lock(CRYPTO_LOCK_SSL_METHOD);
156 sizeof(SSL_METHOD)); 156
157 SSLv3_server_data.ssl_accept=ssl3_accept; 157 if (init)
158 SSLv3_server_data.get_ssl_method=ssl3_get_server_method; 158 {
159 init=0; 159 memcpy((char *)&SSLv3_server_data,(char *)sslv3_base_method(),
160 sizeof(SSL_METHOD));
161 SSLv3_server_data.ssl_accept=ssl3_accept;
162 SSLv3_server_data.get_ssl_method=ssl3_get_server_method;
163 init=0;
164 }
165
166 CRYPTO_w_unlock(CRYPTO_LOCK_SSL_METHOD);
160 } 167 }
161 return(&SSLv3_server_data); 168 return(&SSLv3_server_data);
162 } 169 }
@@ -1171,7 +1178,7 @@ static int ssl3_send_server_key_exchange(SSL *s)
1171 kn=0; 1178 kn=0;
1172 } 1179 }
1173 1180
1174 if (!BUF_MEM_grow(buf,n+4+kn)) 1181 if (!BUF_MEM_grow_clean(buf,n+4+kn))
1175 { 1182 {
1176 SSLerr(SSL_F_SSL3_SEND_SERVER_KEY_EXCHANGE,ERR_LIB_BUF); 1183 SSLerr(SSL_F_SSL3_SEND_SERVER_KEY_EXCHANGE,ERR_LIB_BUF);
1177 goto err; 1184 goto err;
@@ -1298,7 +1305,7 @@ static int ssl3_send_certificate_request(SSL *s)
1298 { 1305 {
1299 name=sk_X509_NAME_value(sk,i); 1306 name=sk_X509_NAME_value(sk,i);
1300 j=i2d_X509_NAME(name,NULL); 1307 j=i2d_X509_NAME(name,NULL);
1301 if (!BUF_MEM_grow(buf,4+n+j+2)) 1308 if (!BUF_MEM_grow_clean(buf,4+n+j+2))
1302 { 1309 {
1303 SSLerr(SSL_F_SSL3_SEND_CERTIFICATE_REQUEST,ERR_R_BUF_LIB); 1310 SSLerr(SSL_F_SSL3_SEND_CERTIFICATE_REQUEST,ERR_R_BUF_LIB);
1304 goto err; 1311 goto err;
@@ -1440,7 +1447,7 @@ static int ssl3_get_client_key_exchange(SSL *s)
1440 if (i != SSL_MAX_MASTER_KEY_LENGTH) 1447 if (i != SSL_MAX_MASTER_KEY_LENGTH)
1441 { 1448 {
1442 al=SSL_AD_DECODE_ERROR; 1449 al=SSL_AD_DECODE_ERROR;
1443 SSLerr(SSL_F_SSL3_GET_CLIENT_KEY_EXCHANGE,SSL_R_BAD_RSA_DECRYPT); 1450 /* SSLerr(SSL_F_SSL3_GET_CLIENT_KEY_EXCHANGE,SSL_R_BAD_RSA_DECRYPT); */
1444 } 1451 }
1445 1452
1446 if ((al == -1) && !((p[0] == (s->client_version>>8)) && (p[1] == (s->client_version & 0xff)))) 1453 if ((al == -1) && !((p[0] == (s->client_version>>8)) && (p[1] == (s->client_version & 0xff))))
@@ -1456,37 +1463,35 @@ static int ssl3_get_client_key_exchange(SSL *s)
1456 (p[0] == (s->version>>8)) && (p[1] == (s->version & 0xff)))) 1463 (p[0] == (s->version>>8)) && (p[1] == (s->version & 0xff))))
1457 { 1464 {
1458 al=SSL_AD_DECODE_ERROR; 1465 al=SSL_AD_DECODE_ERROR;
1459 SSLerr(SSL_F_SSL3_GET_CLIENT_KEY_EXCHANGE,SSL_R_BAD_PROTOCOL_VERSION_NUMBER); 1466 /* SSLerr(SSL_F_SSL3_GET_CLIENT_KEY_EXCHANGE,SSL_R_BAD_PROTOCOL_VERSION_NUMBER); */
1460 goto f_err; 1467
1468 /* The Klima-Pokorny-Rosa extension of Bleichenbacher's attack
1469 * (http://eprint.iacr.org/2003/052/) exploits the version
1470 * number check as a "bad version oracle" -- an alert would
1471 * reveal that the plaintext corresponding to some ciphertext
1472 * made up by the adversary is properly formatted except
1473 * that the version number is wrong. To avoid such attacks,
1474 * we should treat this just like any other decryption error. */
1461 } 1475 }
1462 } 1476 }
1463 1477
1464 if (al != -1) 1478 if (al != -1)
1465 { 1479 {
1466#if 0
1467 goto f_err;
1468#else
1469 /* Some decryption failure -- use random value instead as countermeasure 1480 /* Some decryption failure -- use random value instead as countermeasure
1470 * against Bleichenbacher's attack on PKCS #1 v1.5 RSA padding 1481 * against Bleichenbacher's attack on PKCS #1 v1.5 RSA padding
1471 * (see RFC 2246, section 7.4.7.1). 1482 * (see RFC 2246, section 7.4.7.1). */
1472 * But note that due to length and protocol version checking, the
1473 * attack is impractical anyway (see section 5 in D. Bleichenbacher:
1474 * "Chosen Ciphertext Attacks Against Protocols Based on the RSA
1475 * Encryption Standard PKCS #1", CRYPTO '98, LNCS 1462, pp. 1-12).
1476 */
1477 ERR_clear_error(); 1483 ERR_clear_error();
1478 i = SSL_MAX_MASTER_KEY_LENGTH; 1484 i = SSL_MAX_MASTER_KEY_LENGTH;
1479 p[0] = s->client_version >> 8; 1485 p[0] = s->client_version >> 8;
1480 p[1] = s->client_version & 0xff; 1486 p[1] = s->client_version & 0xff;
1481 RAND_pseudo_bytes(p+2, i-2); /* should be RAND_bytes, but we cannot work around a failure */ 1487 RAND_pseudo_bytes(p+2, i-2); /* should be RAND_bytes, but we cannot work around a failure */
1482#endif
1483 } 1488 }
1484 1489
1485 s->session->master_key_length= 1490 s->session->master_key_length=
1486 s->method->ssl3_enc->generate_master_secret(s, 1491 s->method->ssl3_enc->generate_master_secret(s,
1487 s->session->master_key, 1492 s->session->master_key,
1488 p,i); 1493 p,i);
1489 memset(p,0,i); 1494 OPENSSL_cleanse(p,i);
1490 } 1495 }
1491 else 1496 else
1492#endif 1497#endif
@@ -1549,7 +1554,7 @@ static int ssl3_get_client_key_exchange(SSL *s)
1549 s->session->master_key_length= 1554 s->session->master_key_length=
1550 s->method->ssl3_enc->generate_master_secret(s, 1555 s->method->ssl3_enc->generate_master_secret(s,
1551 s->session->master_key,p,i); 1556 s->session->master_key,p,i);
1552 memset(p,0,i); 1557 OPENSSL_cleanse(p,i);
1553 } 1558 }
1554 else 1559 else
1555#endif 1560#endif
@@ -1652,7 +1657,7 @@ static int ssl3_get_client_key_exchange(SSL *s)
1652 if (enc == NULL) 1657 if (enc == NULL)
1653 goto err; 1658 goto err;
1654 1659
1655 memset(iv, 0, EVP_MAX_IV_LENGTH); /* per RFC 1510 */ 1660 memset(iv, 0, sizeof iv); /* per RFC 1510 */
1656 1661
1657 if (!EVP_DecryptInit_ex(&ciph_ctx,enc,NULL,kssl_ctx->key,iv)) 1662 if (!EVP_DecryptInit_ex(&ciph_ctx,enc,NULL,kssl_ctx->key,iv))
1658 { 1663 {
@@ -1740,7 +1745,7 @@ static int ssl3_get_cert_verify(SSL *s)
1740 SSL3_ST_SR_CERT_VRFY_A, 1745 SSL3_ST_SR_CERT_VRFY_A,
1741 SSL3_ST_SR_CERT_VRFY_B, 1746 SSL3_ST_SR_CERT_VRFY_B,
1742 -1, 1747 -1,
1743 512, /* 512? */ 1748 514, /* 514? */
1744 &ok); 1749 &ok);
1745 1750
1746 if (!ok) return((int)n); 1751 if (!ok) return((int)n);
diff --git a/src/lib/libssl/src/ssl/ssl-lib.com b/src/lib/libssl/src/ssl/ssl-lib.com
index d6829a8d64..163ade9f7a 100644
--- a/src/lib/libssl/src/ssl/ssl-lib.com
+++ b/src/lib/libssl/src/ssl/ssl-lib.com
@@ -21,22 +21,10 @@ $!
21$! LIBRARY To just compile the [.xxx.EXE.SSL]LIBSSL.OLB Library. 21$! LIBRARY To just compile the [.xxx.EXE.SSL]LIBSSL.OLB Library.
22$! SSL_TASK To just compile the [.xxx.EXE.SSL]SSL_TASK.EXE 22$! SSL_TASK To just compile the [.xxx.EXE.SSL]SSL_TASK.EXE
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,14 +33,14 @@ $!
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$! 45$!
58$! Define A TCP/IP Library That We Will Need To Link To. 46$! Define A TCP/IP Library That We Will Need To Link To.
@@ -135,10 +123,6 @@ $! Define The CRYPTO-LIB We Are To Use.
135$! 123$!
136$ CRYPTO_LIB := SYS$DISK:[-.'ARCH'.EXE.CRYPTO]LIBCRYPTO.OLB 124$ CRYPTO_LIB := SYS$DISK:[-.'ARCH'.EXE.CRYPTO]LIBCRYPTO.OLB
137$! 125$!
138$! Define The RSAREF-LIB We Are To Use.
139$!
140$ RSAREF_LIB := SYS$DISK:[-.'ARCH'.EXE.RSAREF]LIBRSAGLUE.OLB
141$!
142$! Check To See What We Are To Do. 126$! Check To See What We Are To Do.
143$! 127$!
144$ IF (BUILDALL.EQS."TRUE") 128$ IF (BUILDALL.EQS."TRUE")
@@ -317,73 +301,31 @@ $!
317$ ON ERROR THEN GOTO SSL_TASK_END 301$ ON ERROR THEN GOTO SSL_TASK_END
318$ CC5/OBJECT='OBJ_DIR'SSL_TASK.OBJ SYS$DISK:[]SSL_TASK.C 302$ CC5/OBJECT='OBJ_DIR'SSL_TASK.OBJ SYS$DISK:[]SSL_TASK.C
319$! 303$!
320$! Link The Program, Check To See If We Need To Link With RSAREF Or Not. 304$! Link The Program.
305$! Check To See If We Are To Link With A Specific TCP/IP Library.
321$! 306$!
322$ IF (RSAREF.EQS."TRUE") 307$ IF (TCPIP_LIB.NES."")
323$ THEN 308$ THEN
324$! 309$!
325$! Check To See If We Are To Link With A Specific TCP/IP Library. 310$! Link With TCP/IP Library.
326$!
327$ IF (TCPIP_LIB.NES."")
328$ THEN
329$!
330$! Link With The RSAREF Library And A Specific TCP/IP Library.
331$!
332$ LINK/'DEBUGGER'/'TRACEBACK'/EXE='EXE_DIR'SSL_TASK.EXE -
333 'OBJ_DIR'SSL_TASK.OBJ, -
334 'SSL_LIB'/LIBRARY,'CRYPTO_LIB'/LIBRARY,'RSAREF_LIB'/LIBRARY, -
335 'TCPIP_LIB','OPT_FILE'/OPTION
336$! 311$!
337$! Else... 312$ LINK/'DEBUGGER'/'TRACEBACK'/EXE='EXE_DIR'SSL_TASK.EXE -
338$! 313 'OBJ_DIR'SSL_TASK.OBJ, -
339$ ELSE 314 'SSL_LIB'/LIBRARY,'CRYPTO_LIB'/LIBRARY, -
340$! 315 'TCPIP_LIB','OPT_FILE'/OPTION
341$! Link With The RSAREF Library And NO TCP/IP Library.
342$!
343$ LINK/'DEBUGGER'/'TRACEBACK'/EXE='EXE_DIR'SSL_TASK.EXE -
344 'OBJ_DIR'SSL_TASK.OBJ, -
345 'SSL_LIB'/LIBRARY,'CRYPTO_LIB'/LIBRARY,'RSAREF_LIB'/LIBRARY, -
346 'OPT_FILE'/OPTION
347$!
348$! End The TCP/IP Library Check.
349$!
350$ ENDIF
351$! 316$!
352$! Else... 317$! Else...
353$! 318$!
354$ ELSE 319$ ELSE
355$! 320$!
356$! Don't Link With The RSAREF Routines. 321$! Don't Link With TCP/IP Library.
357$! 322$!
323$ LINK/'DEBUGGER'/'TRACEBACK'/EXE='EXE_DIR'SSL_TASK.EXE -
324 'OBJ_DIR'SSL_TASK.OBJ,-
325 'SSL_LIB'/LIBRARY,'CRYPTO_LIB'/LIBRARY, -
326 'OPT_FILE'/OPTION
358$! 327$!
359$! Check To See If We Are To Link With A Specific TCP/IP Library. 328$! End The TCP/IP Library Check.
360$!
361$ IF (TCPIP_LIB.NES."")
362$ THEN
363$!
364$! Don't Link With The RSAREF Routines And TCP/IP Library.
365$!
366$ LINK/'DEBUGGER'/'TRACEBACK'/EXE='EXE_DIR'SSL_TASK.EXE -
367 'OBJ_DIR'SSL_TASK.OBJ, -
368 'SSL_LIB'/LIBRARY,'CRYPTO_LIB'/LIBRARY, -
369 'TCPIP_LIB','OPT_FILE'/OPTION
370$!
371$! Else...
372$!
373$ ELSE
374$!
375$! Don't Link With The RSAREF Routines And Link With A TCP/IP Library.
376$!
377$ LINK/'DEBUGGER'/'TRACEBACK'/EXE='EXE_DIR'SSL_TASK.EXE -
378 'OBJ_DIR'SSL_TASK.OBJ,-
379 'SSL_LIB'/LIBRARY,'CRYPTO_LIB'/LIBRARY, -
380 'OPT_FILE'/OPTION
381$!
382$! End The TCP/IP Library Check.
383$!
384$ ENDIF
385$!
386$! End The RSAREF Link Check.
387$! 329$!
388$ ENDIF 330$ ENDIF
389$! 331$!
@@ -558,35 +500,6 @@ $! End The LIBCRYPTO.OLB Library Check.
558$! 500$!
559$ ENDIF 501$ ENDIF
560$! 502$!
561$! Check To See If We Need The RSAREF Library.
562$!
563$ IF (RSAREF.EQS."TRUE")
564$ THEN
565$!
566$! Look For The Library LIBRSAGLUE.OLB.
567$!
568$ IF (F$SEARCH(RSAREF_LIB).EQS."")
569$ THEN
570$!
571$! Tell The User We Can't Find The LIBRSAGLUE.OLB Library.
572$!
573$ WRITE SYS$OUTPUT ""
574$ WRITE SYS$OUTPUT "Can't Find The Library ",RSAREF_LIB,"."
575$ WRITE SYS$OUTPUT "We Can't Link Without It."
576$ WRITE SYS$OUTPUT ""
577$!
578$! Since We Can't Link Without It, Exit.
579$!
580$ EXIT
581$!
582$! End The LIBRSAGLUE.OLB Library Check.
583$!
584$ ENDIF
585$!
586$! End The RSAREF Library Check.
587$!
588$ ENDIF
589$!
590$! Time To Return. 503$! Time To Return.
591$! 504$!
592$ RETURN 505$ RETURN
@@ -650,78 +563,10 @@ $ ENDIF
650$! 563$!
651$! Check To See If P2 Is Blank. 564$! Check To See If P2 Is Blank.
652$! 565$!
653$ p2 = "NORSAREF" 566$ IF (P2.EQS."NODEBUG")
654$ IF (P2.EQS."NORSAREF")
655$ THEN 567$ THEN
656$! 568$!
657$! P2 Is NORSAREF, So Compile With The Regular RSA Libraries. 569$! P2 Is NODEBUG, So Compile Without Debugger Information.
658$!
659$ RSAREF = "FALSE"
660$!
661$! Else...
662$!
663$ ELSE
664$!
665$! Check To See If We Are To Use The RSAREF Library.
666$!
667$ IF (P2.EQS."RSAREF")
668$ THEN
669$!
670$! Check To Make Sure We Have The RSAREF Source Code Directory.
671$!
672$ IF (F$SEARCH("SYS$DISK:[-.RSAREF]SOURCE.DIR").EQS."")
673$ THEN
674$!
675$! We Don't Have The RSAREF Souce Code Directory, So Tell The
676$! User This.
677$!
678$ WRITE SYS$OUTPUT ""
679$ WRITE SYS$OUTPUT "It appears that you don't have the RSAREF Souce Code."
680$ WRITE SYS$OUTPUT "You need to go to 'ftp://ftp.rsa.com/rsaref'. You have to"
681$ WRITE SYS$OUTPUT "get the '.tar-Z' file as the '.zip' file dosen't have the"
682$ WRITE SYS$OUTPUT "directory structure stored. You have to extract the file"
683$ WRITE SYS$OUTPUT "into the [.RSAREF] directory under the root directory"
684$ WRITE SYS$OUTPUT "as that is where the scripts will look for the files."
685$ WRITE SYS$OUTPUT ""
686$!
687$! Time To Exit.
688$!
689$ EXIT
690$!
691$! Else, Compile Using The RSAREF Library.
692$!
693$ ELSE
694$ RSAREF = "TRUE"
695$ ENDIF
696$ ELSE
697$!
698$! They Entered An Invalid Option..
699$!
700$ WRITE SYS$OUTPUT ""
701$ WRITE SYS$OUTPUT "The Option ",P2," Is Invalid. The Valid Options Are:"
702$ WRITE SYS$OUTPUT ""
703$ WRITE SYS$OUTPUT " RSAREF : Compile With The RSAREF Library."
704$ WRITE SYS$OUTPUT " NORSAREF : Compile With The Regular RSA Library."
705$ WRITE SYS$OUTPUT ""
706$!
707$! Time To EXIT.
708$!
709$ EXIT
710$!
711$! End The Valid Arguement Check.
712$!
713$ ENDIF
714$!
715$! End The P2 Check.
716$!
717$ ENDIF
718$!
719$! Check To See If P3 Is Blank.
720$!
721$ IF (P3.EQS."NODEBUG")
722$ THEN
723$!
724$! P3 Is NODEBUG, So Compile Without Debugger Information.
725$! 570$!
726$ DEBUGGER = "NODEBUG" 571$ DEBUGGER = "NODEBUG"
727$ TRACEBACK = "NOTRACEBACK" 572$ TRACEBACK = "NOTRACEBACK"
@@ -736,7 +581,7 @@ $ ELSE
736$! 581$!
737$! Check To See If We Are To Compile With Debugger Information. 582$! Check To See If We Are To Compile With Debugger Information.
738$! 583$!
739$ IF (P3.EQS."DEBUG") 584$ IF (P2.EQS."DEBUG")
740$ THEN 585$ THEN
741$! 586$!
742$! Compile With Debugger Information. 587$! Compile With Debugger Information.
@@ -752,7 +597,7 @@ $!
752$! Tell The User Entered An Invalid Option.. 597$! Tell The User Entered An Invalid Option..
753$! 598$!
754$ WRITE SYS$OUTPUT "" 599$ WRITE SYS$OUTPUT ""
755$ WRITE SYS$OUTPUT "The Option ",P3," Is Invalid. The Valid Options Are:" 600$ WRITE SYS$OUTPUT "The Option ",P2," Is Invalid. The Valid Options Are:"
756$ WRITE SYS$OUTPUT "" 601$ WRITE SYS$OUTPUT ""
757$ WRITE SYS$OUTPUT " DEBUG : Compile With The Debugger Information." 602$ WRITE SYS$OUTPUT " DEBUG : Compile With The Debugger Information."
758$ WRITE SYS$OUTPUT " NODEBUG : Compile Without The Debugger Information." 603$ WRITE SYS$OUTPUT " NODEBUG : Compile Without The Debugger Information."
@@ -766,7 +611,7 @@ $! End The Valid Arguement Check.
766$! 611$!
767$ ENDIF 612$ ENDIF
768$! 613$!
769$! End The P3 Check. 614$! End The P2 Check.
770$! 615$!
771$ ENDIF 616$ ENDIF
772$! 617$!
@@ -776,9 +621,9 @@ $! Written By: Richard Levitte
776$! richard@levitte.org 621$! richard@levitte.org
777$! 622$!
778$! 623$!
779$! Check To See If We Have A Option For P6. 624$! Check To See If We Have A Option For P5.
780$! 625$!
781$ IF (P6.EQS."") 626$ IF (P5.EQS."")
782$ THEN 627$ THEN
783$! 628$!
784$! Get The Version Of VMS We Are Using. 629$! Get The Version Of VMS We Are Using.
@@ -800,13 +645,13 @@ $! End The VMS Version Check.
800$! 645$!
801$ ENDIF 646$ ENDIF
802$! 647$!
803$! End The P6 Check. 648$! End The P5 Check.
804$! 649$!
805$ ENDIF 650$ ENDIF
806$! 651$!
807$! Check To See If P4 Is Blank. 652$! Check To See If P3 Is Blank.
808$! 653$!
809$ IF (P4.EQS."") 654$ IF (P3.EQS."")
810$ THEN 655$ THEN
811$! 656$!
812$! O.K., The User Didn't Specify A Compiler, Let's Try To 657$! O.K., The User Didn't Specify A Compiler, Let's Try To
@@ -819,7 +664,7 @@ $ THEN
819$! 664$!
820$! Looks Like GNUC, Set To Use GNUC. 665$! Looks Like GNUC, Set To Use GNUC.
821$! 666$!
822$ P4 = "GNUC" 667$ P3 = "GNUC"
823$! 668$!
824$! End The GNU C Compiler Check. 669$! End The GNU C Compiler Check.
825$! 670$!
@@ -832,7 +677,7 @@ $ THEN
832$! 677$!
833$! Looks Like DECC, Set To Use DECC. 678$! Looks Like DECC, Set To Use DECC.
834$! 679$!
835$ P4 = "DECC" 680$ P3 = "DECC"
836$! 681$!
837$! Else... 682$! Else...
838$! 683$!
@@ -840,7 +685,7 @@ $ ELSE
840$! 685$!
841$! Looks Like VAXC, Set To Use VAXC. 686$! Looks Like VAXC, Set To Use VAXC.
842$! 687$!
843$ P4 = "VAXC" 688$ P3 = "VAXC"
844$! 689$!
845$! End The VAXC Compiler Check. 690$! End The VAXC Compiler Check.
846$! 691$!
@@ -854,9 +699,9 @@ $! End The Compiler Check.
854$! 699$!
855$ ENDIF 700$ ENDIF
856$! 701$!
857$! Check To See If We Have A Option For P5. 702$! Check To See If We Have A Option For P4.
858$! 703$!
859$ IF (P5.EQS."") 704$ IF (P4.EQS."")
860$ THEN 705$ THEN
861$! 706$!
862$! Find out what socket library we have available 707$! Find out what socket library we have available
@@ -866,7 +711,7 @@ $ THEN
866$! 711$!
867$! We have SOCKETSHR, and it is my opinion that it's the best to use. 712$! We have SOCKETSHR, and it is my opinion that it's the best to use.
868$! 713$!
869$ P5 = "SOCKETSHR" 714$ P4 = "SOCKETSHR"
870$! 715$!
871$! Tell the user 716$! Tell the user
872$! 717$!
@@ -886,7 +731,7 @@ $ THEN
886$! 731$!
887$! Last resort: a UCX or UCX-compatible library 732$! Last resort: a UCX or UCX-compatible library
888$! 733$!
889$ P5 = "UCX" 734$ P4 = "UCX"
890$! 735$!
891$! Tell the user 736$! Tell the user
892$! 737$!
@@ -900,7 +745,7 @@ $ ENDIF
900$! 745$!
901$! Set Up Initial CC Definitions, Possibly With User Ones 746$! Set Up Initial CC Definitions, Possibly With User Ones
902$! 747$!
903$ CCDEFS = "TCPIP_TYPE_''P5'" 748$ CCDEFS = "TCPIP_TYPE_''P4'"
904$ IF F$TYPE(USER_CCDEFS) .NES. "" THEN CCDEFS = CCDEFS + "," + USER_CCDEFS 749$ IF F$TYPE(USER_CCDEFS) .NES. "" THEN CCDEFS = CCDEFS + "," + USER_CCDEFS
905$ CCEXTRAFLAGS = "" 750$ CCEXTRAFLAGS = ""
906$ IF F$TYPE(USER_CCFLAGS) .NES. "" THEN CCEXTRAFLAGS = USER_CCFLAGS 751$ IF F$TYPE(USER_CCFLAGS) .NES. "" THEN CCEXTRAFLAGS = USER_CCFLAGS
@@ -910,12 +755,12 @@ $ IF F$TYPE(USER_CCDISABLEWARNINGS) .NES. "" THEN -
910$! 755$!
911$! Check To See If The User Entered A Valid Paramter. 756$! Check To See If The User Entered A Valid Paramter.
912$! 757$!
913$ IF (P4.EQS."VAXC").OR.(P4.EQS."DECC").OR.(P4.EQS."GNUC") 758$ IF (P3.EQS."VAXC").OR.(P3.EQS."DECC").OR.(P3.EQS."GNUC")
914$ THEN 759$ THEN
915$! 760$!
916$! Check To See If The User Wanted DECC. 761$! Check To See If The User Wanted DECC.
917$! 762$!
918$ IF (P4.EQS."DECC") 763$ IF (P3.EQS."DECC")
919$ THEN 764$ THEN
920$! 765$!
921$! Looks Like DECC, Set To Use DECC. 766$! Looks Like DECC, Set To Use DECC.
@@ -945,7 +790,7 @@ $ ENDIF
945$! 790$!
946$! Check To See If We Are To Use VAXC. 791$! Check To See If We Are To Use VAXC.
947$! 792$!
948$ IF (P4.EQS."VAXC") 793$ IF (P3.EQS."VAXC")
949$ THEN 794$ THEN
950$! 795$!
951$! Looks Like VAXC, Set To Use VAXC. 796$! Looks Like VAXC, Set To Use VAXC.
@@ -983,7 +828,7 @@ $ ENDIF
983$! 828$!
984$! Check To See If We Are To Use GNU C. 829$! Check To See If We Are To Use GNU C.
985$! 830$!
986$ IF (P4.EQS."GNUC") 831$ IF (P3.EQS."GNUC")
987$ THEN 832$ THEN
988$! 833$!
989$! Looks Like GNUC, Set To Use GNUC. 834$! Looks Like GNUC, Set To Use GNUC.
@@ -1012,31 +857,6 @@ $! Set up default defines
1012$! 857$!
1013$ CCDEFS = """FLAT_INC=1""," + CCDEFS 858$ CCDEFS = """FLAT_INC=1""," + CCDEFS
1014$! 859$!
1015$! Check To See If We Are To Compile With RSAREF Routines.
1016$!
1017$ IF (RSAREF.EQS."TRUE")
1018$ THEN
1019$!
1020$! Compile With RSAREF.
1021$!
1022$ CCDEFS = CCDEFS + ",""RSAref=1"""
1023$!
1024$! Tell The User This.
1025$!
1026$ WRITE SYS$OUTPUT "Compiling With RSAREF Routines."
1027$!
1028$! Else, We Don't Care. Compile Without The RSAREF Library.
1029$!
1030$ ELSE
1031$!
1032$! Tell The User We Are Compile Without The RSAREF Routines.
1033$!
1034$ WRITE SYS$OUTPUT "Compiling Without The RSAREF Routines.
1035$!
1036$! End The RSAREF Check.
1037$!
1038$ ENDIF
1039$!
1040$! Finish up the definition of CC. 860$! Finish up the definition of CC.
1041$! 861$!
1042$ IF COMPILER .EQS. "DECC" 862$ IF COMPILER .EQS. "DECC"
@@ -1076,7 +896,7 @@ $!
1076$! Tell The User We Don't Know What They Want. 896$! Tell The User We Don't Know What They Want.
1077$! 897$!
1078$ WRITE SYS$OUTPUT "" 898$ WRITE SYS$OUTPUT ""
1079$ WRITE SYS$OUTPUT "The Option ",P4," Is Invalid. The Valid Options Are:" 899$ WRITE SYS$OUTPUT "The Option ",P3," Is Invalid. The Valid Options Are:"
1080$ WRITE SYS$OUTPUT "" 900$ WRITE SYS$OUTPUT ""
1081$ WRITE SYS$OUTPUT " VAXC : To Compile With VAX C." 901$ WRITE SYS$OUTPUT " VAXC : To Compile With VAX C."
1082$ WRITE SYS$OUTPUT " DECC : To Compile With DEC C." 902$ WRITE SYS$OUTPUT " DECC : To Compile With DEC C."
@@ -1090,13 +910,13 @@ $ ENDIF
1090$! 910$!
1091$! Time to check the contents, and to make sure we get the correct library. 911$! Time to check the contents, and to make sure we get the correct library.
1092$! 912$!
1093$ IF P5.EQS."SOCKETSHR" .OR. P5.EQS."MULTINET" .OR. P5.EQS."UCX" - 913$ IF P4.EQS."SOCKETSHR" .OR. P4.EQS."MULTINET" .OR. P4.EQS."UCX" -
1094 .OR. P5.EQS."TCPIP" .OR. P5.EQS."NONE" 914 .OR. P4.EQS."TCPIP" .OR. P4.EQS."NONE"
1095$ THEN 915$ THEN
1096$! 916$!
1097$! Check to see if SOCKETSHR was chosen 917$! Check to see if SOCKETSHR was chosen
1098$! 918$!
1099$ IF P5.EQS."SOCKETSHR" 919$ IF P4.EQS."SOCKETSHR"
1100$ THEN 920$ THEN
1101$! 921$!
1102$! Set the library to use SOCKETSHR 922$! Set the library to use SOCKETSHR
@@ -1109,12 +929,12 @@ $ ENDIF
1109$! 929$!
1110$! Check to see if MULTINET was chosen 930$! Check to see if MULTINET was chosen
1111$! 931$!
1112$ IF P5.EQS."MULTINET" 932$ IF P4.EQS."MULTINET"
1113$ THEN 933$ THEN
1114$! 934$!
1115$! Set the library to use UCX emulation. 935$! Set the library to use UCX emulation.
1116$! 936$!
1117$ P5 = "UCX" 937$ P4 = "UCX"
1118$! 938$!
1119$! Done with MULTINET 939$! Done with MULTINET
1120$! 940$!
@@ -1122,7 +942,7 @@ $ ENDIF
1122$! 942$!
1123$! Check to see if UCX was chosen 943$! Check to see if UCX was chosen
1124$! 944$!
1125$ IF P5.EQS."UCX" 945$ IF P4.EQS."UCX"
1126$ THEN 946$ THEN
1127$! 947$!
1128$! Set the library to use UCX. 948$! Set the library to use UCX.
@@ -1142,7 +962,7 @@ $ ENDIF
1142$! 962$!
1143$! Check to see if TCPIP was chosen 963$! Check to see if TCPIP was chosen
1144$! 964$!
1145$ IF P5.EQS."TCPIP" 965$ IF P4.EQS."TCPIP"
1146$ THEN 966$ THEN
1147$! 967$!
1148$! Set the library to use TCPIP (post UCX). 968$! Set the library to use TCPIP (post UCX).
@@ -1155,7 +975,7 @@ $ ENDIF
1155$! 975$!
1156$! Check to see if NONE was chosen 976$! Check to see if NONE was chosen
1157$! 977$!
1158$ IF P5.EQS."NONE" 978$ IF P4.EQS."NONE"
1159$ THEN 979$ THEN
1160$! 980$!
1161$! Do not use a TCPIP library. 981$! Do not use a TCPIP library.
@@ -1177,7 +997,7 @@ $!
1177$! Tell The User We Don't Know What They Want. 997$! Tell The User We Don't Know What They Want.
1178$! 998$!
1179$ WRITE SYS$OUTPUT "" 999$ WRITE SYS$OUTPUT ""
1180$ WRITE SYS$OUTPUT "The Option ",P5," Is Invalid. The Valid Options Are:" 1000$ WRITE SYS$OUTPUT "The Option ",P4," Is Invalid. The Valid Options Are:"
1181$ WRITE SYS$OUTPUT "" 1001$ WRITE SYS$OUTPUT ""
1182$ WRITE SYS$OUTPUT " SOCKETSHR : To link with SOCKETSHR TCP/IP library." 1002$ WRITE SYS$OUTPUT " SOCKETSHR : To link with SOCKETSHR TCP/IP library."
1183$ WRITE SYS$OUTPUT " UCX : To link with UCX TCP/IP library." 1003$ WRITE SYS$OUTPUT " UCX : To link with UCX TCP/IP library."
diff --git a/src/lib/libssl/src/ssl/ssl.h b/src/lib/libssl/src/ssl/ssl.h
index e9d1e896d7..4ae8458259 100644
--- a/src/lib/libssl/src/ssl/ssl.h
+++ b/src/lib/libssl/src/ssl/ssl.h
@@ -204,6 +204,22 @@ extern "C" {
204 204
205/* VRS Additional Kerberos5 entries 205/* VRS Additional Kerberos5 entries
206 */ 206 */
207#define SSL_TXT_KRB5_DES_64_CBC_SHA SSL3_TXT_KRB5_DES_64_CBC_SHA
208#define SSL_TXT_KRB5_DES_192_CBC3_SHA SSL3_TXT_KRB5_DES_192_CBC3_SHA
209#define SSL_TXT_KRB5_RC4_128_SHA SSL3_TXT_KRB5_RC4_128_SHA
210#define SSL_TXT_KRB5_IDEA_128_CBC_SHA SSL3_TXT_KRB5_IDEA_128_CBC_SHA
211#define SSL_TXT_KRB5_DES_64_CBC_MD5 SSL3_TXT_KRB5_DES_64_CBC_MD5
212#define SSL_TXT_KRB5_DES_192_CBC3_MD5 SSL3_TXT_KRB5_DES_192_CBC3_MD5
213#define SSL_TXT_KRB5_RC4_128_MD5 SSL3_TXT_KRB5_RC4_128_MD5
214#define SSL_TXT_KRB5_IDEA_128_CBC_MD5 SSL3_TXT_KRB5_IDEA_128_CBC_MD5
215
216#define SSL_TXT_KRB5_DES_40_CBC_SHA SSL3_TXT_KRB5_DES_40_CBC_SHA
217#define SSL_TXT_KRB5_RC2_40_CBC_SHA SSL3_TXT_KRB5_RC2_40_CBC_SHA
218#define SSL_TXT_KRB5_RC4_40_SHA SSL3_TXT_KRB5_RC4_40_SHA
219#define SSL_TXT_KRB5_DES_40_CBC_MD5 SSL3_TXT_KRB5_DES_40_CBC_MD5
220#define SSL_TXT_KRB5_RC2_40_CBC_MD5 SSL3_TXT_KRB5_RC2_40_CBC_MD5
221#define SSL_TXT_KRB5_RC4_40_MD5 SSL3_TXT_KRB5_RC4_40_MD5
222
207#define SSL_TXT_KRB5_DES_40_CBC_SHA SSL3_TXT_KRB5_DES_40_CBC_SHA 223#define SSL_TXT_KRB5_DES_40_CBC_SHA SSL3_TXT_KRB5_DES_40_CBC_SHA
208#define SSL_TXT_KRB5_DES_40_CBC_MD5 SSL3_TXT_KRB5_DES_40_CBC_MD5 224#define SSL_TXT_KRB5_DES_40_CBC_MD5 SSL3_TXT_KRB5_DES_40_CBC_MD5
209#define SSL_TXT_KRB5_DES_64_CBC_SHA SSL3_TXT_KRB5_DES_64_CBC_SHA 225#define SSL_TXT_KRB5_DES_64_CBC_SHA SSL3_TXT_KRB5_DES_64_CBC_SHA
@@ -299,9 +315,7 @@ extern "C" {
299#include <openssl/crypto.h> 315#include <openssl/crypto.h>
300#include <openssl/lhash.h> 316#include <openssl/lhash.h>
301#include <openssl/buffer.h> 317#include <openssl/buffer.h>
302#include <openssl/bio.h>
303#include <openssl/pem.h> 318#include <openssl/pem.h>
304#include <openssl/x509.h>
305 319
306#ifdef __cplusplus 320#ifdef __cplusplus
307extern "C" { 321extern "C" {
@@ -507,6 +521,8 @@ typedef struct ssl_session_st
507/* Never bother the application with retries if the transport 521/* Never bother the application with retries if the transport
508 * is blocking: */ 522 * is blocking: */
509#define SSL_MODE_AUTO_RETRY 0x00000004L 523#define SSL_MODE_AUTO_RETRY 0x00000004L
524/* Don't attempt to automatically build certificate chain */
525#define SSL_MODE_NO_AUTO_CHAIN 0x00000008L
510 526
511 527
512/* Note: SSL[_CTX]_set_{options,mode} use |= op on the previous value, 528/* Note: SSL[_CTX]_set_{options,mode} use |= op on the previous value,
@@ -704,10 +720,11 @@ struct ssl_ctx_st
704#define SSL_SESS_CACHE_SERVER 0x0002 720#define SSL_SESS_CACHE_SERVER 0x0002
705#define SSL_SESS_CACHE_BOTH (SSL_SESS_CACHE_CLIENT|SSL_SESS_CACHE_SERVER) 721#define SSL_SESS_CACHE_BOTH (SSL_SESS_CACHE_CLIENT|SSL_SESS_CACHE_SERVER)
706#define SSL_SESS_CACHE_NO_AUTO_CLEAR 0x0080 722#define SSL_SESS_CACHE_NO_AUTO_CLEAR 0x0080
707/* This one, when set, makes the server session-id lookup not look 723/* enough comments already ... see SSL_CTX_set_session_cache_mode(3) */
708 * in the cache. If there is an application get_session callback
709 * defined, this will still get called. */
710#define SSL_SESS_CACHE_NO_INTERNAL_LOOKUP 0x0100 724#define SSL_SESS_CACHE_NO_INTERNAL_LOOKUP 0x0100
725#define SSL_SESS_CACHE_NO_INTERNAL_STORE 0x0200
726#define SSL_SESS_CACHE_NO_INTERNAL \
727 (SSL_SESS_CACHE_NO_INTERNAL_LOOKUP|SSL_SESS_CACHE_NO_INTERNAL_STORE)
711 728
712 struct lhash_st *SSL_CTX_sessions(SSL_CTX *ctx); 729 struct lhash_st *SSL_CTX_sessions(SSL_CTX *ctx);
713#define SSL_CTX_sess_number(ctx) \ 730#define SSL_CTX_sess_number(ctx) \
@@ -1212,14 +1229,12 @@ int SSL_CTX_use_certificate_chain_file(SSL_CTX *ctx, const char *file); /* PEM t
1212STACK_OF(X509_NAME) *SSL_load_client_CA_file(const char *file); 1229STACK_OF(X509_NAME) *SSL_load_client_CA_file(const char *file);
1213int SSL_add_file_cert_subjects_to_stack(STACK_OF(X509_NAME) *stackCAs, 1230int SSL_add_file_cert_subjects_to_stack(STACK_OF(X509_NAME) *stackCAs,
1214 const char *file); 1231 const char *file);
1215#ifndef OPENSSL_SYS_WIN32
1216#ifndef OPENSSL_SYS_VMS 1232#ifndef OPENSSL_SYS_VMS
1217#ifndef OPENSSL_SYS_MACINTOSH_CLASSIC /* XXXXX: Better scheme needed! [was: #ifndef MAC_OS_pre_X] */ 1233#ifndef OPENSSL_SYS_MACINTOSH_CLASSIC /* XXXXX: Better scheme needed! [was: #ifndef MAC_OS_pre_X] */
1218int SSL_add_dir_cert_subjects_to_stack(STACK_OF(X509_NAME) *stackCAs, 1234int SSL_add_dir_cert_subjects_to_stack(STACK_OF(X509_NAME) *stackCAs,
1219 const char *dir); 1235 const char *dir);
1220#endif 1236#endif
1221#endif 1237#endif
1222#endif
1223 1238
1224#endif 1239#endif
1225 1240
@@ -1688,6 +1703,7 @@ void ERR_load_SSL_strings(void);
1688#define SSL_R_LENGTH_TOO_SHORT 160 1703#define SSL_R_LENGTH_TOO_SHORT 160
1689#define SSL_R_LIBRARY_BUG 274 1704#define SSL_R_LIBRARY_BUG 274
1690#define SSL_R_LIBRARY_HAS_NO_CIPHERS 161 1705#define SSL_R_LIBRARY_HAS_NO_CIPHERS 161
1706#define SSL_R_MASTER_KEY_TOO_LONG 1112
1691#define SSL_R_MESSAGE_TOO_LONG 1111 1707#define SSL_R_MESSAGE_TOO_LONG 1111
1692#define SSL_R_MISSING_DH_DSA_CERT 162 1708#define SSL_R_MISSING_DH_DSA_CERT 162
1693#define SSL_R_MISSING_DH_KEY 163 1709#define SSL_R_MISSING_DH_KEY 163
diff --git a/src/lib/libssl/src/ssl/ssl3.h b/src/lib/libssl/src/ssl/ssl3.h
index 8fd6951d77..1153aeda74 100644
--- a/src/lib/libssl/src/ssl/ssl3.h
+++ b/src/lib/libssl/src/ssl/ssl3.h
@@ -156,23 +156,29 @@ extern "C" {
156 156
157#define SSL3_CK_FZA_DMS_NULL_SHA 0x0300001C 157#define SSL3_CK_FZA_DMS_NULL_SHA 0x0300001C
158#define SSL3_CK_FZA_DMS_FZA_SHA 0x0300001D 158#define SSL3_CK_FZA_DMS_FZA_SHA 0x0300001D
159#if 0 /* Because it clashes with KRB5, is never used any more, and is safe
160 to remove according to David Hopwood <david.hopwood@zetnet.co.uk>
161 of the ietf-tls list */
159#define SSL3_CK_FZA_DMS_RC4_SHA 0x0300001E 162#define SSL3_CK_FZA_DMS_RC4_SHA 0x0300001E
163#endif
160 164
161/* VRS Additional Kerberos5 entries 165/* VRS Additional Kerberos5 entries
162 */ 166 */
163#define SSL3_CK_KRB5_DES_40_CBC_SHA 0x03000021 167#define SSL3_CK_KRB5_DES_64_CBC_SHA 0x0300001E
164#define SSL3_CK_KRB5_DES_40_CBC_MD5 0x03000022 168#define SSL3_CK_KRB5_DES_192_CBC3_SHA 0x0300001F
165#define SSL3_CK_KRB5_DES_64_CBC_SHA 0x03000023 169#define SSL3_CK_KRB5_RC4_128_SHA 0x03000020
166#define SSL3_CK_KRB5_DES_64_CBC_MD5 0x03000024 170#define SSL3_CK_KRB5_IDEA_128_CBC_SHA 0x03000021
167#define SSL3_CK_KRB5_DES_192_CBC3_SHA 0x03000025 171#define SSL3_CK_KRB5_DES_64_CBC_MD5 0x03000022
168#define SSL3_CK_KRB5_DES_192_CBC3_MD5 0x03000026 172#define SSL3_CK_KRB5_DES_192_CBC3_MD5 0x03000023
169 173#define SSL3_CK_KRB5_RC4_128_MD5 0x03000024
170#define SSL3_TXT_KRB5_DES_40_CBC_SHA "EXP-KRB5-DES-CBC-SHA" 174#define SSL3_CK_KRB5_IDEA_128_CBC_MD5 0x03000025
171#define SSL3_TXT_KRB5_DES_40_CBC_MD5 "EXP-KRB5-DES-CBC-MD5" 175
172#define SSL3_TXT_KRB5_DES_64_CBC_SHA "KRB5-DES-CBC-SHA" 176#define SSL3_CK_KRB5_DES_40_CBC_SHA 0x03000026
173#define SSL3_TXT_KRB5_DES_64_CBC_MD5 "KRB5-DES-CBC-MD5" 177#define SSL3_CK_KRB5_RC2_40_CBC_SHA 0x03000027
174#define SSL3_TXT_KRB5_DES_192_CBC3_SHA "KRB5-DES-CBC3-SHA" 178#define SSL3_CK_KRB5_RC4_40_SHA 0x03000028
175#define SSL3_TXT_KRB5_DES_192_CBC3_MD5 "KRB5-DES-CBC3-MD5" 179#define SSL3_CK_KRB5_DES_40_CBC_MD5 0x03000029
180#define SSL3_CK_KRB5_RC2_40_CBC_MD5 0x0300002A
181#define SSL3_CK_KRB5_RC4_40_MD5 0x0300002B
176 182
177#define SSL3_TXT_RSA_NULL_MD5 "NULL-MD5" 183#define SSL3_TXT_RSA_NULL_MD5 "NULL-MD5"
178#define SSL3_TXT_RSA_NULL_SHA "NULL-SHA" 184#define SSL3_TXT_RSA_NULL_SHA "NULL-SHA"
@@ -209,6 +215,22 @@ extern "C" {
209#define SSL3_TXT_FZA_DMS_FZA_SHA "FZA-FZA-CBC-SHA" 215#define SSL3_TXT_FZA_DMS_FZA_SHA "FZA-FZA-CBC-SHA"
210#define SSL3_TXT_FZA_DMS_RC4_SHA "FZA-RC4-SHA" 216#define SSL3_TXT_FZA_DMS_RC4_SHA "FZA-RC4-SHA"
211 217
218#define SSL3_TXT_KRB5_DES_64_CBC_SHA "KRB5-DES-CBC-SHA"
219#define SSL3_TXT_KRB5_DES_192_CBC3_SHA "KRB5-DES-CBC3-SHA"
220#define SSL3_TXT_KRB5_RC4_128_SHA "KRB5-RC4-SHA"
221#define SSL3_TXT_KRB5_IDEA_128_CBC_SHA "KRB5-IDEA-CBC-SHA"
222#define SSL3_TXT_KRB5_DES_64_CBC_MD5 "KRB5-DES-CBC-MD5"
223#define SSL3_TXT_KRB5_DES_192_CBC3_MD5 "KRB5-DES-CBC3-MD5"
224#define SSL3_TXT_KRB5_RC4_128_MD5 "KRB5-RC4-MD5"
225#define SSL3_TXT_KRB5_IDEA_128_CBC_MD5 "KRB5-IDEA-CBC-MD5"
226
227#define SSL3_TXT_KRB5_DES_40_CBC_SHA "EXP-KRB5-DES-CBC-SHA"
228#define SSL3_TXT_KRB5_RC2_40_CBC_SHA "EXP-KRB5-RC2-CBC-SHA"
229#define SSL3_TXT_KRB5_RC4_40_SHA "EXP-KRB5-RC4-SHA"
230#define SSL3_TXT_KRB5_DES_40_CBC_MD5 "EXP-KRB5-DES-CBC-MD5"
231#define SSL3_TXT_KRB5_RC2_40_CBC_MD5 "EXP-KRB5-RC2-CBC-MD5"
232#define SSL3_TXT_KRB5_RC4_40_MD5 "EXP-KRB5-RC4-MD5"
233
212#define SSL3_SSL_SESSION_ID_LENGTH 32 234#define SSL3_SSL_SESSION_ID_LENGTH 32
213#define SSL3_MAX_SSL_SESSION_ID_LENGTH 32 235#define SSL3_MAX_SSL_SESSION_ID_LENGTH 32
214 236
diff --git a/src/lib/libssl/src/ssl/ssl_asn1.c b/src/lib/libssl/src/ssl/ssl_asn1.c
index 3723fc2e37..16bc11b559 100644
--- a/src/lib/libssl/src/ssl/ssl_asn1.c
+++ b/src/lib/libssl/src/ssl/ssl_asn1.c
@@ -299,6 +299,7 @@ SSL_SESSION *d2i_SSL_SESSION(SSL_SESSION **a, unsigned char **pp,
299 os.length = sizeof ret->session_id; 299 os.length = sizeof ret->session_id;
300 300
301 ret->session_id_length=os.length; 301 ret->session_id_length=os.length;
302 OPENSSL_assert(os.length <= sizeof ret->session_id);
302 memcpy(ret->session_id,os.data,os.length); 303 memcpy(ret->session_id,os.data,os.length);
303 304
304 M_ASN1_D2I_get(osp,d2i_ASN1_OCTET_STRING); 305 M_ASN1_D2I_get(osp,d2i_ASN1_OCTET_STRING);
@@ -370,9 +371,15 @@ SSL_SESSION *d2i_SSL_SESSION(SSL_SESSION **a, unsigned char **pp,
370 if(os.data != NULL) 371 if(os.data != NULL)
371 { 372 {
372 if (os.length > SSL_MAX_SID_CTX_LENGTH) 373 if (os.length > SSL_MAX_SID_CTX_LENGTH)
374 {
375 ret->sid_ctx_length=os.length;
373 SSLerr(SSL_F_D2I_SSL_SESSION,SSL_R_BAD_LENGTH); 376 SSLerr(SSL_F_D2I_SSL_SESSION,SSL_R_BAD_LENGTH);
374 ret->sid_ctx_length=os.length; 377 }
375 memcpy(ret->sid_ctx,os.data,os.length); 378 else
379 {
380 ret->sid_ctx_length=os.length;
381 memcpy(ret->sid_ctx,os.data,os.length);
382 }
376 OPENSSL_free(os.data); os.data=NULL; os.length=0; 383 OPENSSL_free(os.data); os.data=NULL; os.length=0;
377 } 384 }
378 else 385 else
diff --git a/src/lib/libssl/src/ssl/ssl_cert.c b/src/lib/libssl/src/ssl/ssl_cert.c
index 3d31bbf05f..da90078a37 100644
--- a/src/lib/libssl/src/ssl/ssl_cert.c
+++ b/src/lib/libssl/src/ssl/ssl_cert.c
@@ -781,7 +781,7 @@ err:
781#endif 781#endif
782#endif 782#endif
783 783
784#else 784#else /* OPENSSL_SYS_WIN32 */
785 785
786int SSL_add_dir_cert_subjects_to_stack(STACK_OF(X509_NAME) *stack, 786int SSL_add_dir_cert_subjects_to_stack(STACK_OF(X509_NAME) *stack,
787 const char *dir) 787 const char *dir)
@@ -789,10 +789,30 @@ int SSL_add_dir_cert_subjects_to_stack(STACK_OF(X509_NAME) *stack,
789 WIN32_FIND_DATA FindFileData; 789 WIN32_FIND_DATA FindFileData;
790 HANDLE hFind; 790 HANDLE hFind;
791 int ret = 0; 791 int ret = 0;
792#ifdef OPENSSL_SYS_WINCE
793 WCHAR* wdir = NULL;
794#endif
792 795
793 CRYPTO_w_lock(CRYPTO_LOCK_READDIR); 796 CRYPTO_w_lock(CRYPTO_LOCK_READDIR);
794 797
798#ifdef OPENSSL_SYS_WINCE
799 /* convert strings to UNICODE */
800 {
801 BOOL result = FALSE;
802 int i;
803 wdir = malloc((strlen(dir)+1)*2);
804 if (wdir == NULL)
805 goto err_noclose;
806 for (i=0; i<(int)strlen(dir)+1; i++)
807 wdir[i] = (short)dir[i];
808 }
809#endif
810
811#ifdef OPENSSL_SYS_WINCE
812 hFind = FindFirstFile(wdir, &FindFileData);
813#else
795 hFind = FindFirstFile(dir, &FindFileData); 814 hFind = FindFirstFile(dir, &FindFileData);
815#endif
796 /* Note that a side effect is that the CAs will be sorted by name */ 816 /* Note that a side effect is that the CAs will be sorted by name */
797 if(hFind == INVALID_HANDLE_VALUE) 817 if(hFind == INVALID_HANDLE_VALUE)
798 { 818 {
@@ -807,7 +827,11 @@ int SSL_add_dir_cert_subjects_to_stack(STACK_OF(X509_NAME) *stack,
807 char buf[1024]; 827 char buf[1024];
808 int r; 828 int r;
809 829
830#ifdef OPENSSL_SYS_WINCE
831 if(strlen(dir)+_tcslen(FindFileData.cFileName)+2 > sizeof buf)
832#else
810 if(strlen(dir)+strlen(FindFileData.cFileName)+2 > sizeof buf) 833 if(strlen(dir)+strlen(FindFileData.cFileName)+2 > sizeof buf)
834#endif
811 { 835 {
812 SSLerr(SSL_F_SSL_ADD_DIR_CERT_SUBJECTS_TO_STACK,SSL_R_PATH_TOO_LONG); 836 SSLerr(SSL_F_SSL_ADD_DIR_CERT_SUBJECTS_TO_STACK,SSL_R_PATH_TOO_LONG);
813 goto err; 837 goto err;
@@ -825,6 +849,10 @@ int SSL_add_dir_cert_subjects_to_stack(STACK_OF(X509_NAME) *stack,
825err: 849err:
826 FindClose(hFind); 850 FindClose(hFind);
827err_noclose: 851err_noclose:
852#ifdef OPENSSL_SYS_WINCE
853 if (wdir != NULL)
854 free(wdir);
855#endif
828 CRYPTO_w_unlock(CRYPTO_LOCK_READDIR); 856 CRYPTO_w_unlock(CRYPTO_LOCK_READDIR);
829 return ret; 857 return ret;
830 } 858 }
diff --git a/src/lib/libssl/src/ssl/ssl_ciph.c b/src/lib/libssl/src/ssl/ssl_ciph.c
index 37f58886a6..888b667fa1 100644
--- a/src/lib/libssl/src/ssl/ssl_ciph.c
+++ b/src/lib/libssl/src/ssl/ssl_ciph.c
@@ -668,13 +668,14 @@ static int ssl_cipher_process_rulestr(const char *rule_str,
668 * So additionally check whether the cipher name found 668 * So additionally check whether the cipher name found
669 * has the correct length. We can save a strlen() call: 669 * has the correct length. We can save a strlen() call:
670 * just checking for the '\0' at the right place is 670 * just checking for the '\0' at the right place is
671 * sufficient, we have to strncmp() anyway. 671 * sufficient, we have to strncmp() anyway. (We cannot
672 * use strcmp(), because buf is not '\0' terminated.)
672 */ 673 */
673 j = found = 0; 674 j = found = 0;
674 while (ca_list[j]) 675 while (ca_list[j])
675 { 676 {
676 if ((ca_list[j]->name[buflen] == '\0') && 677 if (!strncmp(buf, ca_list[j]->name, buflen) &&
677 !strncmp(buf, ca_list[j]->name, buflen)) 678 (ca_list[j]->name[buflen] == '\0'))
678 { 679 {
679 found = 1; 680 found = 1;
680 break; 681 break;
@@ -751,7 +752,12 @@ STACK_OF(SSL_CIPHER) *ssl_create_cipher_list(const SSL_METHOD *ssl_method,
751 */ 752 */
752 if (rule_str == NULL) return(NULL); 753 if (rule_str == NULL) return(NULL);
753 754
754 if (init_ciphers) load_ciphers(); 755 if (init_ciphers)
756 {
757 CRYPTO_w_lock(CRYPTO_LOCK_SSL);
758 if (init_ciphers) load_ciphers();
759 CRYPTO_w_unlock(CRYPTO_LOCK_SSL);
760 }
755 761
756 /* 762 /*
757 * To reduce the work to do we only want to process the compiled 763 * To reduce the work to do we only want to process the compiled
diff --git a/src/lib/libssl/src/ssl/ssl_err.c b/src/lib/libssl/src/ssl/ssl_err.c
index 7067a745f3..d2cb181503 100644
--- a/src/lib/libssl/src/ssl/ssl_err.c
+++ b/src/lib/libssl/src/ssl/ssl_err.c
@@ -296,6 +296,7 @@ static ERR_STRING_DATA SSL_str_reasons[]=
296{SSL_R_LENGTH_TOO_SHORT ,"length too short"}, 296{SSL_R_LENGTH_TOO_SHORT ,"length too short"},
297{SSL_R_LIBRARY_BUG ,"library bug"}, 297{SSL_R_LIBRARY_BUG ,"library bug"},
298{SSL_R_LIBRARY_HAS_NO_CIPHERS ,"library has no ciphers"}, 298{SSL_R_LIBRARY_HAS_NO_CIPHERS ,"library has no ciphers"},
299{SSL_R_MASTER_KEY_TOO_LONG ,"master key too long"},
299{SSL_R_MESSAGE_TOO_LONG ,"message too long"}, 300{SSL_R_MESSAGE_TOO_LONG ,"message too long"},
300{SSL_R_MISSING_DH_DSA_CERT ,"missing dh dsa cert"}, 301{SSL_R_MISSING_DH_DSA_CERT ,"missing dh dsa cert"},
301{SSL_R_MISSING_DH_KEY ,"missing dh key"}, 302{SSL_R_MISSING_DH_KEY ,"missing dh key"},
diff --git a/src/lib/libssl/src/ssl/ssl_lib.c b/src/lib/libssl/src/ssl/ssl_lib.c
index 4bc4ce5b3a..ddd8114587 100644
--- a/src/lib/libssl/src/ssl/ssl_lib.c
+++ b/src/lib/libssl/src/ssl/ssl_lib.c
@@ -121,6 +121,7 @@
121#include <openssl/objects.h> 121#include <openssl/objects.h>
122#include <openssl/lhash.h> 122#include <openssl/lhash.h>
123#include <openssl/x509v3.h> 123#include <openssl/x509v3.h>
124#include "cryptlib.h"
124 125
125const char *SSL_version_str=OPENSSL_VERSION_TEXT; 126const char *SSL_version_str=OPENSSL_VERSION_TEXT;
126 127
@@ -273,6 +274,7 @@ SSL *SSL_new(SSL_CTX *ctx)
273 s->verify_mode=ctx->verify_mode; 274 s->verify_mode=ctx->verify_mode;
274 s->verify_depth=ctx->verify_depth; 275 s->verify_depth=ctx->verify_depth;
275 s->sid_ctx_length=ctx->sid_ctx_length; 276 s->sid_ctx_length=ctx->sid_ctx_length;
277 OPENSSL_assert(s->sid_ctx_length <= sizeof s->sid_ctx);
276 memcpy(&s->sid_ctx,&ctx->sid_ctx,sizeof(s->sid_ctx)); 278 memcpy(&s->sid_ctx,&ctx->sid_ctx,sizeof(s->sid_ctx));
277 s->verify_callback=ctx->default_verify_callback; 279 s->verify_callback=ctx->default_verify_callback;
278 s->generate_session_id=ctx->generate_session_id; 280 s->generate_session_id=ctx->generate_session_id;
@@ -314,7 +316,7 @@ err:
314int SSL_CTX_set_session_id_context(SSL_CTX *ctx,const unsigned char *sid_ctx, 316int SSL_CTX_set_session_id_context(SSL_CTX *ctx,const unsigned char *sid_ctx,
315 unsigned int sid_ctx_len) 317 unsigned int sid_ctx_len)
316 { 318 {
317 if(sid_ctx_len > SSL_MAX_SID_CTX_LENGTH) 319 if(sid_ctx_len > sizeof ctx->sid_ctx)
318 { 320 {
319 SSLerr(SSL_F_SSL_CTX_SET_SESSION_ID_CONTEXT,SSL_R_SSL_SESSION_ID_CONTEXT_TOO_LONG); 321 SSLerr(SSL_F_SSL_CTX_SET_SESSION_ID_CONTEXT,SSL_R_SSL_SESSION_ID_CONTEXT_TOO_LONG);
320 return 0; 322 return 0;
@@ -364,6 +366,10 @@ int SSL_has_matching_session_id(const SSL *ssl, const unsigned char *id,
364 * any new session built out of this id/id_len and the ssl_version in 366 * any new session built out of this id/id_len and the ssl_version in
365 * use by this SSL. */ 367 * use by this SSL. */
366 SSL_SESSION r, *p; 368 SSL_SESSION r, *p;
369
370 if(id_len > sizeof r.session_id)
371 return 0;
372
367 r.ssl_version = ssl->version; 373 r.ssl_version = ssl->version;
368 r.session_id_length = id_len; 374 r.session_id_length = id_len;
369 memcpy(r.session_id, id, id_len); 375 memcpy(r.session_id, id, id_len);
@@ -1063,14 +1069,17 @@ int ssl_cipher_ptr_id_cmp(const SSL_CIPHER * const *ap,
1063 * preference */ 1069 * preference */
1064STACK_OF(SSL_CIPHER) *SSL_get_ciphers(SSL *s) 1070STACK_OF(SSL_CIPHER) *SSL_get_ciphers(SSL *s)
1065 { 1071 {
1066 if ((s != NULL) && (s->cipher_list != NULL)) 1072 if (s != NULL)
1067 {
1068 return(s->cipher_list);
1069 }
1070 else if ((s->ctx != NULL) &&
1071 (s->ctx->cipher_list != NULL))
1072 { 1073 {
1073 return(s->ctx->cipher_list); 1074 if (s->cipher_list != NULL)
1075 {
1076 return(s->cipher_list);
1077 }
1078 else if ((s->ctx != NULL) &&
1079 (s->ctx->cipher_list != NULL))
1080 {
1081 return(s->ctx->cipher_list);
1082 }
1074 } 1083 }
1075 return(NULL); 1084 return(NULL);
1076 } 1085 }
@@ -1079,14 +1088,17 @@ STACK_OF(SSL_CIPHER) *SSL_get_ciphers(SSL *s)
1079 * algorithm id */ 1088 * algorithm id */
1080STACK_OF(SSL_CIPHER) *ssl_get_ciphers_by_id(SSL *s) 1089STACK_OF(SSL_CIPHER) *ssl_get_ciphers_by_id(SSL *s)
1081 { 1090 {
1082 if ((s != NULL) && (s->cipher_list_by_id != NULL)) 1091 if (s != NULL)
1083 {
1084 return(s->cipher_list_by_id);
1085 }
1086 else if ((s != NULL) && (s->ctx != NULL) &&
1087 (s->ctx->cipher_list_by_id != NULL))
1088 { 1092 {
1089 return(s->ctx->cipher_list_by_id); 1093 if (s->cipher_list_by_id != NULL)
1094 {
1095 return(s->cipher_list_by_id);
1096 }
1097 else if ((s->ctx != NULL) &&
1098 (s->ctx->cipher_list_by_id != NULL))
1099 {
1100 return(s->ctx->cipher_list_by_id);
1101 }
1090 } 1102 }
1091 return(NULL); 1103 return(NULL);
1092 } 1104 }
@@ -1652,7 +1664,7 @@ void ssl_update_cache(SSL *s,int mode)
1652 1664
1653 i=s->ctx->session_cache_mode; 1665 i=s->ctx->session_cache_mode;
1654 if ((i & mode) && (!s->hit) 1666 if ((i & mode) && (!s->hit)
1655 && ((i & SSL_SESS_CACHE_NO_INTERNAL_LOOKUP) 1667 && ((i & SSL_SESS_CACHE_NO_INTERNAL_STORE)
1656 || SSL_CTX_add_session(s->ctx,s->session)) 1668 || SSL_CTX_add_session(s->ctx,s->session))
1657 && (s->ctx->new_session_cb != NULL)) 1669 && (s->ctx->new_session_cb != NULL))
1658 { 1670 {
@@ -1884,6 +1896,7 @@ SSL *SSL_dup(SSL *s)
1884 * they should not both point to the same object, 1896 * they should not both point to the same object,
1885 * and thus we can't use SSL_copy_session_id. */ 1897 * and thus we can't use SSL_copy_session_id. */
1886 1898
1899 ret->method->ssl_free(ret);
1887 ret->method = s->method; 1900 ret->method = s->method;
1888 ret->method->ssl_new(ret); 1901 ret->method->ssl_new(ret);
1889 1902
diff --git a/src/lib/libssl/src/ssl/ssl_sess.c b/src/lib/libssl/src/ssl/ssl_sess.c
index ca1a7427be..fbc30b94e6 100644
--- a/src/lib/libssl/src/ssl/ssl_sess.c
+++ b/src/lib/libssl/src/ssl/ssl_sess.c
@@ -309,9 +309,12 @@ int ssl_get_prev_session(SSL *s, unsigned char *session_id, int len)
309 if (copy) 309 if (copy)
310 CRYPTO_add(&ret->references,1,CRYPTO_LOCK_SSL_SESSION); 310 CRYPTO_add(&ret->references,1,CRYPTO_LOCK_SSL_SESSION);
311 311
312 /* The following should not return 1, otherwise, 312 /* Add the externally cached session to the internal
313 * things are very strange */ 313 * cache as well if and only if we are supposed to. */
314 SSL_CTX_add_session(s->ctx,ret); 314 if(!(s->ctx->session_cache_mode & SSL_SESS_CACHE_NO_INTERNAL_STORE))
315 /* The following should not return 1, otherwise,
316 * things are very strange */
317 SSL_CTX_add_session(s->ctx,ret);
315 } 318 }
316 if (ret == NULL) 319 if (ret == NULL)
317 goto err; 320 goto err;
@@ -525,13 +528,13 @@ void SSL_SESSION_free(SSL_SESSION *ss)
525 528
526 CRYPTO_free_ex_data(CRYPTO_EX_INDEX_SSL_SESSION, ss, &ss->ex_data); 529 CRYPTO_free_ex_data(CRYPTO_EX_INDEX_SSL_SESSION, ss, &ss->ex_data);
527 530
528 memset(ss->key_arg,0,SSL_MAX_KEY_ARG_LENGTH); 531 OPENSSL_cleanse(ss->key_arg,sizeof ss->key_arg);
529 memset(ss->master_key,0,SSL_MAX_MASTER_KEY_LENGTH); 532 OPENSSL_cleanse(ss->master_key,sizeof ss->master_key);
530 memset(ss->session_id,0,SSL_MAX_SSL_SESSION_ID_LENGTH); 533 OPENSSL_cleanse(ss->session_id,sizeof ss->session_id);
531 if (ss->sess_cert != NULL) ssl_sess_cert_free(ss->sess_cert); 534 if (ss->sess_cert != NULL) ssl_sess_cert_free(ss->sess_cert);
532 if (ss->peer != NULL) X509_free(ss->peer); 535 if (ss->peer != NULL) X509_free(ss->peer);
533 if (ss->ciphers != NULL) sk_SSL_CIPHER_free(ss->ciphers); 536 if (ss->ciphers != NULL) sk_SSL_CIPHER_free(ss->ciphers);
534 memset(ss,0,sizeof(*ss)); 537 OPENSSL_cleanse(ss,sizeof(*ss));
535 OPENSSL_free(ss); 538 OPENSSL_free(ss);
536 } 539 }
537 540
diff --git a/src/lib/libssl/src/ssl/ssl_task.c b/src/lib/libssl/src/ssl/ssl_task.c
index e36af0eb94..b5ce44b47c 100644
--- a/src/lib/libssl/src/ssl/ssl_task.c
+++ b/src/lib/libssl/src/ssl/ssl_task.c
@@ -258,7 +258,7 @@ int doit(io_channel chan, SSL_CTX *s_ctx )
258{ 258{
259 int status, length, link_state; 259 int status, length, link_state;
260 struct rpc_msg msg; 260 struct rpc_msg msg;
261 static char cbuf[200],sbuf[200]; 261
262 SSL *s_ssl=NULL; 262 SSL *s_ssl=NULL;
263 BIO *c_to_s=NULL; 263 BIO *c_to_s=NULL;
264 BIO *s_to_c=NULL; 264 BIO *s_to_c=NULL;
diff --git a/src/lib/libssl/src/ssl/ssltest.c b/src/lib/libssl/src/ssl/ssltest.c
index 4f6379e160..47c383200a 100644
--- a/src/lib/libssl/src/ssl/ssltest.c
+++ b/src/lib/libssl/src/ssl/ssltest.c
@@ -109,11 +109,8 @@
109 * 109 *
110 */ 110 */
111 111
112#define _XOPEN_SOURCE 600 /* Or gethostname won't be declared properly 112#define _BSD_SOURCE 1 /* Or gethostname won't be declared properly
113 on Linux and GNU platforms. */ 113 on Linux and GNU platforms. */
114#define _XOPEN_SOURCE_EXTENDED 1 /* Or gethostname won't be declared properly
115 on Compaq platforms (at least with DEC C).
116 */
117 114
118#include <assert.h> 115#include <assert.h>
119#include <errno.h> 116#include <errno.h>
@@ -123,6 +120,7 @@
123#include <string.h> 120#include <string.h>
124#include <time.h> 121#include <time.h>
125 122
123#define USE_SOCKETS
126#include "e_os.h" 124#include "e_os.h"
127 125
128#include <openssl/bio.h> 126#include <openssl/bio.h>
@@ -130,12 +128,20 @@
130#include <openssl/evp.h> 128#include <openssl/evp.h>
131#include <openssl/x509.h> 129#include <openssl/x509.h>
132#include <openssl/ssl.h> 130#include <openssl/ssl.h>
131#ifndef OPENSSL_NO_ENGINE
133#include <openssl/engine.h> 132#include <openssl/engine.h>
133#endif
134#include <openssl/err.h> 134#include <openssl/err.h>
135#include <openssl/rand.h> 135#include <openssl/rand.h>
136
137#define _XOPEN_SOURCE_EXTENDED 1 /* Or gethostname won't be declared properly
138 on Compaq platforms (at least with DEC C).
139 Do not try to put it earlier, or IPv6 includes
140 get screwed...
141 */
142
136#ifdef OPENSSL_SYS_WINDOWS 143#ifdef OPENSSL_SYS_WINDOWS
137#include <winsock.h> 144#include <winsock.h>
138#include "../crypto/bio/bss_file.c"
139#else 145#else
140#include OPENSSL_UNISTD 146#include OPENSSL_UNISTD
141#endif 147#endif
@@ -143,6 +149,9 @@
143#ifdef OPENSSL_SYS_VMS 149#ifdef OPENSSL_SYS_VMS
144# define TEST_SERVER_CERT "SYS$DISK:[-.APPS]SERVER.PEM" 150# define TEST_SERVER_CERT "SYS$DISK:[-.APPS]SERVER.PEM"
145# define TEST_CLIENT_CERT "SYS$DISK:[-.APPS]CLIENT.PEM" 151# define TEST_CLIENT_CERT "SYS$DISK:[-.APPS]CLIENT.PEM"
152#elif defined(OPENSSL_SYS_WINCE)
153# define TEST_SERVER_CERT "\\OpenSSL\\server.pem"
154# define TEST_CLIENT_CERT "\\OpenSSL\\client.pem"
146#else 155#else
147# define TEST_SERVER_CERT "../apps/server.pem" 156# define TEST_SERVER_CERT "../apps/server.pem"
148# define TEST_CLIENT_CERT "../apps/client.pem" 157# define TEST_CLIENT_CERT "../apps/client.pem"
@@ -364,7 +373,9 @@ int main(int argc, char *argv[])
364 verbose = 0; 373 verbose = 0;
365 debug = 0; 374 debug = 0;
366 cipher = 0; 375 cipher = 0;
367 376
377 bio_err=BIO_new_fp(stderr,BIO_NOCLOSE);
378
368 CRYPTO_set_locking_callback(lock_dbg_cb); 379 CRYPTO_set_locking_callback(lock_dbg_cb);
369 380
370 /* enable memory leak checking unless explicitly disabled */ 381 /* enable memory leak checking unless explicitly disabled */
@@ -382,7 +393,6 @@ int main(int argc, char *argv[])
382 393
383 RAND_seed(rnd_seed, sizeof rnd_seed); 394 RAND_seed(rnd_seed, sizeof rnd_seed);
384 395
385 bio_err=BIO_new_fp(stderr,BIO_NOCLOSE);
386 bio_stdout=BIO_new_fp(stdout,BIO_NOCLOSE); 396 bio_stdout=BIO_new_fp(stdout,BIO_NOCLOSE);
387 397
388 argc--; 398 argc--;
@@ -405,7 +415,7 @@ int main(int argc, char *argv[])
405#ifndef OPENSSL_NO_DH 415#ifndef OPENSSL_NO_DH
406 dhe1024=1; 416 dhe1024=1;
407#else 417#else
408 fprintf(stderr,"ignoring -dhe1024, since I'm compiled without DH\n"; 418 fprintf(stderr,"ignoring -dhe1024, since I'm compiled without DH\n");
409#endif 419#endif
410 } 420 }
411 else if (strcmp(*argv,"-dhe1024dsa") == 0) 421 else if (strcmp(*argv,"-dhe1024dsa") == 0)
@@ -413,7 +423,7 @@ int main(int argc, char *argv[])
413#ifndef OPENSSL_NO_DH 423#ifndef OPENSSL_NO_DH
414 dhe1024dsa=1; 424 dhe1024dsa=1;
415#else 425#else
416 fprintf(stderr,"ignoring -dhe1024, since I'm compiled without DH\n"; 426 fprintf(stderr,"ignoring -dhe1024, since I'm compiled without DH\n");
417#endif 427#endif
418 } 428 }
419 else if (strcmp(*argv,"-no_dhe") == 0) 429 else if (strcmp(*argv,"-no_dhe") == 0)
@@ -530,7 +540,7 @@ bad:
530 "the test anyway (and\n-d to see what happens), " 540 "the test anyway (and\n-d to see what happens), "
531 "or add one of -ssl2, -ssl3, -tls1, -reuse\n" 541 "or add one of -ssl2, -ssl3, -tls1, -reuse\n"
532 "to avoid protocol mismatch.\n"); 542 "to avoid protocol mismatch.\n");
533 exit(1); 543 EXIT(1);
534 } 544 }
535 545
536 if (print_time) 546 if (print_time)
@@ -686,10 +696,16 @@ bad:
686#ifndef OPENSSL_NO_KRB5 696#ifndef OPENSSL_NO_KRB5
687 if (c_ssl && c_ssl->kssl_ctx) 697 if (c_ssl && c_ssl->kssl_ctx)
688 { 698 {
689 char localhost[257]; 699 char localhost[MAXHOSTNAMELEN+2];
690 700
691 if (gethostname(localhost, 256) == 0) 701 if (gethostname(localhost, sizeof localhost-1) == 0)
692 { 702 {
703 localhost[sizeof localhost-1]='\0';
704 if(strlen(localhost) == sizeof localhost-1)
705 {
706 BIO_printf(bio_err,"localhost name too long\n");
707 goto end;
708 }
693 kssl_ctx_setstring(c_ssl->kssl_ctx, KSSL_SERVER, 709 kssl_ctx_setstring(c_ssl->kssl_ctx, KSSL_SERVER,
694 localhost); 710 localhost);
695 } 711 }
@@ -745,7 +761,9 @@ end:
745#ifndef OPENSSL_NO_RSA 761#ifndef OPENSSL_NO_RSA
746 free_tmp_rsa(); 762 free_tmp_rsa();
747#endif 763#endif
764#ifndef OPENSSL_NO_ENGINE
748 ENGINE_cleanup(); 765 ENGINE_cleanup();
766#endif
749 CRYPTO_cleanup_all_ex_data(); 767 CRYPTO_cleanup_all_ex_data();
750 ERR_free_strings(); 768 ERR_free_strings();
751 ERR_remove_state(0); 769 ERR_remove_state(0);
@@ -835,6 +853,8 @@ int doit_biopair(SSL *s_ssl, SSL *c_ssl, long count,
835 int i, r; 853 int i, r;
836 clock_t c_clock = clock(); 854 clock_t c_clock = clock();
837 855
856 memset(cbuf, 0, sizeof(cbuf));
857
838 if (debug) 858 if (debug)
839 if (SSL_in_init(c_ssl)) 859 if (SSL_in_init(c_ssl))
840 printf("client waiting in SSL_connect - %s\n", 860 printf("client waiting in SSL_connect - %s\n",
@@ -919,6 +939,8 @@ int doit_biopair(SSL *s_ssl, SSL *c_ssl, long count,
919 int i, r; 939 int i, r;
920 clock_t s_clock = clock(); 940 clock_t s_clock = clock();
921 941
942 memset(sbuf, 0, sizeof(sbuf));
943
922 if (debug) 944 if (debug)
923 if (SSL_in_init(s_ssl)) 945 if (SSL_in_init(s_ssl))
924 printf("server waiting in SSL_accept - %s\n", 946 printf("server waiting in SSL_accept - %s\n",
@@ -1162,6 +1184,9 @@ int doit(SSL *s_ssl, SSL *c_ssl, long count)
1162 int c_write,s_write; 1184 int c_write,s_write;
1163 int do_server=0,do_client=0; 1185 int do_server=0,do_client=0;
1164 1186
1187 memset(cbuf,0,sizeof(cbuf));
1188 memset(sbuf,0,sizeof(sbuf));
1189
1165 c_to_s=BIO_new(BIO_s_mem()); 1190 c_to_s=BIO_new(BIO_s_mem());
1166 s_to_c=BIO_new(BIO_s_mem()); 1191 s_to_c=BIO_new(BIO_s_mem());
1167 if ((s_to_c == NULL) || (c_to_s == NULL)) 1192 if ((s_to_c == NULL) || (c_to_s == NULL))
@@ -1443,7 +1468,8 @@ static int MS_CALLBACK verify_callback(int ok, X509_STORE_CTX *ctx)
1443 { 1468 {
1444 char *s,buf[256]; 1469 char *s,buf[256];
1445 1470
1446 s=X509_NAME_oneline(X509_get_subject_name(ctx->current_cert),buf,256); 1471 s=X509_NAME_oneline(X509_get_subject_name(ctx->current_cert),buf,
1472 sizeof buf);
1447 if (s != NULL) 1473 if (s != NULL)
1448 { 1474 {
1449 if (ok) 1475 if (ok)
diff --git a/src/lib/libssl/src/ssl/t1_clnt.c b/src/lib/libssl/src/ssl/t1_clnt.c
index 9ad518f9f4..57205fb429 100644
--- a/src/lib/libssl/src/ssl/t1_clnt.c
+++ b/src/lib/libssl/src/ssl/t1_clnt.c
@@ -79,11 +79,18 @@ SSL_METHOD *TLSv1_client_method(void)
79 79
80 if (init) 80 if (init)
81 { 81 {
82 memcpy((char *)&TLSv1_client_data,(char *)tlsv1_base_method(), 82 CRYPTO_w_lock(CRYPTO_LOCK_SSL_METHOD);
83 sizeof(SSL_METHOD)); 83
84 TLSv1_client_data.ssl_connect=ssl3_connect; 84 if (init)
85 TLSv1_client_data.get_ssl_method=tls1_get_client_method; 85 {
86 init=0; 86 memcpy((char *)&TLSv1_client_data,(char *)tlsv1_base_method(),
87 sizeof(SSL_METHOD));
88 TLSv1_client_data.ssl_connect=ssl3_connect;
89 TLSv1_client_data.get_ssl_method=tls1_get_client_method;
90 init=0;
91 }
92
93 CRYPTO_w_unlock(CRYPTO_LOCK_SSL_METHOD);
87 } 94 }
88 return(&TLSv1_client_data); 95 return(&TLSv1_client_data);
89 } 96 }
diff --git a/src/lib/libssl/src/ssl/t1_enc.c b/src/lib/libssl/src/ssl/t1_enc.c
index 5290bf6665..271e247eea 100644
--- a/src/lib/libssl/src/ssl/t1_enc.c
+++ b/src/lib/libssl/src/ssl/t1_enc.c
@@ -124,7 +124,7 @@ static void tls1_P_hash(const EVP_MD *md, const unsigned char *sec,
124 unsigned int j; 124 unsigned int j;
125 HMAC_CTX ctx; 125 HMAC_CTX ctx;
126 HMAC_CTX ctx_tmp; 126 HMAC_CTX ctx_tmp;
127 unsigned char A1[HMAC_MAX_MD_CBLOCK]; 127 unsigned char A1[EVP_MAX_MD_SIZE];
128 unsigned int A1_len; 128 unsigned int A1_len;
129 129
130 chunk=EVP_MD_size(md); 130 chunk=EVP_MD_size(md);
@@ -161,7 +161,7 @@ static void tls1_P_hash(const EVP_MD *md, const unsigned char *sec,
161 } 161 }
162 HMAC_CTX_cleanup(&ctx); 162 HMAC_CTX_cleanup(&ctx);
163 HMAC_CTX_cleanup(&ctx_tmp); 163 HMAC_CTX_cleanup(&ctx_tmp);
164 memset(A1,0,sizeof(A1)); 164 OPENSSL_cleanse(A1,sizeof(A1));
165 } 165 }
166 166
167static void tls1_PRF(const EVP_MD *md5, const EVP_MD *sha1, 167static void tls1_PRF(const EVP_MD *md5, const EVP_MD *sha1,
@@ -418,10 +418,10 @@ printf("\niv=");
418printf("\n"); 418printf("\n");
419#endif 419#endif
420 420
421 memset(tmp1,0,sizeof(tmp1)); 421 OPENSSL_cleanse(tmp1,sizeof(tmp1));
422 memset(tmp2,0,sizeof(tmp1)); 422 OPENSSL_cleanse(tmp2,sizeof(tmp1));
423 memset(iv1,0,sizeof(iv1)); 423 OPENSSL_cleanse(iv1,sizeof(iv1));
424 memset(iv2,0,sizeof(iv2)); 424 OPENSSL_cleanse(iv2,sizeof(iv2));
425 return(1); 425 return(1);
426err: 426err:
427 SSLerr(SSL_F_TLS1_CHANGE_CIPHER_STATE,ERR_R_MALLOC_FAILURE); 427 SSLerr(SSL_F_TLS1_CHANGE_CIPHER_STATE,ERR_R_MALLOC_FAILURE);
@@ -476,7 +476,7 @@ printf("pre-master\n");
476{ int z; for (z=0; z<s->session->master_key_length; z++) printf("%02X%c",s->session->master_key[z],((z+1)%16)?' ':'\n'); } 476{ int z; for (z=0; z<s->session->master_key_length; z++) printf("%02X%c",s->session->master_key[z],((z+1)%16)?' ':'\n'); }
477#endif 477#endif
478 tls1_generate_key_block(s,p1,p2,num); 478 tls1_generate_key_block(s,p1,p2,num);
479 memset(p2,0,num); 479 OPENSSL_cleanse(p2,num);
480 OPENSSL_free(p2); 480 OPENSSL_free(p2);
481#ifdef TLS_DEBUG 481#ifdef TLS_DEBUG
482printf("\nkey block\n"); 482printf("\nkey block\n");
@@ -683,10 +683,10 @@ int tls1_final_finish_mac(SSL *s, EVP_MD_CTX *in1_ctx, EVP_MD_CTX *in2_ctx,
683 683
684 tls1_PRF(s->ctx->md5,s->ctx->sha1,buf,(int)(q-buf), 684 tls1_PRF(s->ctx->md5,s->ctx->sha1,buf,(int)(q-buf),
685 s->session->master_key,s->session->master_key_length, 685 s->session->master_key,s->session->master_key_length,
686 out,buf2,12); 686 out,buf2,sizeof buf2);
687 EVP_MD_CTX_cleanup(&ctx); 687 EVP_MD_CTX_cleanup(&ctx);
688 688
689 return((int)12); 689 return sizeof buf2;
690 } 690 }
691 691
692int tls1_mac(SSL *ssl, unsigned char *md, int send) 692int tls1_mac(SSL *ssl, unsigned char *md, int send)
@@ -773,7 +773,7 @@ int tls1_generate_master_secret(SSL *s, unsigned char *out, unsigned char *p,
773 s->s3->server_random,SSL3_RANDOM_SIZE); 773 s->s3->server_random,SSL3_RANDOM_SIZE);
774 tls1_PRF(s->ctx->md5,s->ctx->sha1, 774 tls1_PRF(s->ctx->md5,s->ctx->sha1,
775 buf,TLS_MD_MASTER_SECRET_CONST_SIZE+SSL3_RANDOM_SIZE*2,p,len, 775 buf,TLS_MD_MASTER_SECRET_CONST_SIZE+SSL3_RANDOM_SIZE*2,p,len,
776 s->session->master_key,buff,SSL3_MASTER_SECRET_SIZE); 776 s->session->master_key,buff,sizeof buff);
777#ifdef KSSL_DEBUG 777#ifdef KSSL_DEBUG
778 printf ("tls1_generate_master_secret() complete\n"); 778 printf ("tls1_generate_master_secret() complete\n");
779#endif /* KSSL_DEBUG */ 779#endif /* KSSL_DEBUG */
diff --git a/src/lib/libssl/src/ssl/t1_meth.c b/src/lib/libssl/src/ssl/t1_meth.c
index 9bb36a7d1c..fcc243f782 100644
--- a/src/lib/libssl/src/ssl/t1_meth.c
+++ b/src/lib/libssl/src/ssl/t1_meth.c
@@ -76,13 +76,21 @@ SSL_METHOD *TLSv1_method(void)
76 76
77 if (init) 77 if (init)
78 { 78 {
79 memcpy((char *)&TLSv1_data,(char *)tlsv1_base_method(), 79 CRYPTO_w_lock(CRYPTO_LOCK_SSL_METHOD);
80 sizeof(SSL_METHOD)); 80
81 TLSv1_data.ssl_connect=ssl3_connect; 81 if (init)
82 TLSv1_data.ssl_accept=ssl3_accept; 82 {
83 TLSv1_data.get_ssl_method=tls1_get_method; 83 memcpy((char *)&TLSv1_data,(char *)tlsv1_base_method(),
84 init=0; 84 sizeof(SSL_METHOD));
85 TLSv1_data.ssl_connect=ssl3_connect;
86 TLSv1_data.ssl_accept=ssl3_accept;
87 TLSv1_data.get_ssl_method=tls1_get_method;
88 init=0;
89 }
90
91 CRYPTO_w_unlock(CRYPTO_LOCK_SSL_METHOD);
85 } 92 }
93
86 return(&TLSv1_data); 94 return(&TLSv1_data);
87 } 95 }
88 96
diff --git a/src/lib/libssl/src/ssl/t1_srvr.c b/src/lib/libssl/src/ssl/t1_srvr.c
index 6e765e587f..1c1149e49f 100644
--- a/src/lib/libssl/src/ssl/t1_srvr.c
+++ b/src/lib/libssl/src/ssl/t1_srvr.c
@@ -80,11 +80,18 @@ SSL_METHOD *TLSv1_server_method(void)
80 80
81 if (init) 81 if (init)
82 { 82 {
83 memcpy((char *)&TLSv1_server_data,(char *)tlsv1_base_method(), 83 CRYPTO_w_lock(CRYPTO_LOCK_SSL_METHOD);
84 sizeof(SSL_METHOD)); 84
85 TLSv1_server_data.ssl_accept=ssl3_accept; 85 if (init)
86 TLSv1_server_data.get_ssl_method=tls1_get_server_method; 86 {
87 init=0; 87 memcpy((char *)&TLSv1_server_data,(char *)tlsv1_base_method(),
88 sizeof(SSL_METHOD));
89 TLSv1_server_data.ssl_accept=ssl3_accept;
90 TLSv1_server_data.get_ssl_method=tls1_get_server_method;
91 init=0;
92 }
93
94 CRYPTO_w_unlock(CRYPTO_LOCK_SSL_METHOD);
88 } 95 }
89 return(&TLSv1_server_data); 96 return(&TLSv1_server_data);
90 } 97 }
diff --git a/src/lib/libssl/src/test/evptests.txt b/src/lib/libssl/src/test/evptests.txt
new file mode 100644
index 0000000000..80bd9c7765
--- /dev/null
+++ b/src/lib/libssl/src/test/evptests.txt
@@ -0,0 +1,183 @@
1#cipher:key:iv:plaintext:ciphertext:0/1(decrypt/encrypt)
2#digest:::input:output
3
4# SHA(1) tests (from shatest.c)
5SHA1:::616263:a9993e364706816aba3e25717850c26c9cd0d89d
6
7# MD5 tests (from md5test.c)
8MD5::::d41d8cd98f00b204e9800998ecf8427e
9MD5:::61:0cc175b9c0f1b6a831c399e269772661
10MD5:::616263:900150983cd24fb0d6963f7d28e17f72
11MD5:::6d65737361676520646967657374:f96b697d7cb7938d525a2f31aaf161d0
12MD5:::6162636465666768696a6b6c6d6e6f707172737475767778797a:c3fcd3d76192e4007dfb496cca67e13b
13MD5:::4142434445464748494a4b4c4d4e4f505152535455565758595a6162636465666768696a6b6c6d6e6f707172737475767778797a30313233343536373839:d174ab98d277d9f5a5611c2c9f419d9f
14MD5:::3132333435363738393031323334353637383930313233343536373839303132333435363738393031323334353637383930313233343536373839303132333435363738393031323334353637383930:57edf4a22be3c955ac49da2e2107b67a
15
16# AES 128 ECB tests (from FIPS-197 test vectors, encrypt)
17
18AES-128-ECB:000102030405060708090A0B0C0D0E0F::00112233445566778899AABBCCDDEEFF:69C4E0D86A7B0430D8CDB78070B4C55A:1
19
20# AES 192 ECB tests (from FIPS-197 test vectors, encrypt)
21
22AES-192-ECB:000102030405060708090A0B0C0D0E0F1011121314151617::00112233445566778899AABBCCDDEEFF:DDA97CA4864CDFE06EAF70A0EC0D7191:1
23
24# AES 256 ECB tests (from FIPS-197 test vectors, encrypt)
25
26AES-256-ECB:000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F::00112233445566778899AABBCCDDEEFF:8EA2B7CA516745BFEAFC49904B496089:1
27
28# AES 128 ECB tests (from NIST test vectors, encrypt)
29
30#AES-128-ECB:00000000000000000000000000000000::00000000000000000000000000000000:C34C052CC0DA8D73451AFE5F03BE297F:1
31
32# AES 128 ECB tests (from NIST test vectors, decrypt)
33
34#AES-128-ECB:00000000000000000000000000000000::44416AC2D1F53C583303917E6BE9EBE0:00000000000000000000000000000000:0
35
36# AES 192 ECB tests (from NIST test vectors, decrypt)
37
38#AES-192-ECB:000000000000000000000000000000000000000000000000::48E31E9E256718F29229319C19F15BA4:00000000000000000000000000000000:0
39
40# AES 256 ECB tests (from NIST test vectors, decrypt)
41
42#AES-256-ECB:0000000000000000000000000000000000000000000000000000000000000000::058CCFFDBBCB382D1F6F56585D8A4ADE:00000000000000000000000000000000:0
43
44# AES 128 CBC tests (from NIST test vectors, encrypt)
45
46#AES-128-CBC:00000000000000000000000000000000:00000000000000000000000000000000:00000000000000000000000000000000:8A05FC5E095AF4848A08D328D3688E3D:1
47
48# AES 192 CBC tests (from NIST test vectors, encrypt)
49
50#AES-192-CBC:000000000000000000000000000000000000000000000000:00000000000000000000000000000000:00000000000000000000000000000000:7BD966D53AD8C1BB85D2ADFAE87BB104:1
51
52# AES 256 CBC tests (from NIST test vectors, encrypt)
53
54#AES-256-CBC:0000000000000000000000000000000000000000000000000000000000000000:00000000000000000000000000000000:00000000000000000000000000000000:FE3C53653E2F45B56FCD88B2CC898FF0:1
55
56# AES 128 CBC tests (from NIST test vectors, decrypt)
57
58#AES-128-CBC:00000000000000000000000000000000:00000000000000000000000000000000:FACA37E0B0C85373DF706E73F7C9AF86:00000000000000000000000000000000:0
59
60# AES tests from NIST document SP800-38A
61# For all ECB encrypts and decrypts, the transformed sequence is
62# AES-bits-ECB:key::plaintext:ciphertext:encdec
63# ECB-AES128.Encrypt and ECB-AES128.Decrypt
64AES-128-ECB:2B7E151628AED2A6ABF7158809CF4F3C::6BC1BEE22E409F96E93D7E117393172A:3AD77BB40D7A3660A89ECAF32466EF97
65AES-128-ECB:2B7E151628AED2A6ABF7158809CF4F3C::AE2D8A571E03AC9C9EB76FAC45AF8E51:F5D3D58503B9699DE785895A96FDBAAF
66AES-128-ECB:2B7E151628AED2A6ABF7158809CF4F3C::30C81C46A35CE411E5FBC1191A0A52EF:43B1CD7F598ECE23881B00E3ED030688
67AES-128-ECB:2B7E151628AED2A6ABF7158809CF4F3C::F69F2445DF4F9B17AD2B417BE66C3710:7B0C785E27E8AD3F8223207104725DD4
68# ECB-AES192.Encrypt and ECB-AES192.Decrypt
69AES-192-ECB:8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B::6BC1BEE22E409F96E93D7E117393172A:BD334F1D6E45F25FF712A214571FA5CC
70AES-192-ECB:8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B::AE2D8A571E03AC9C9EB76FAC45AF8E51:974104846D0AD3AD7734ECB3ECEE4EEF
71AES-192-ECB:8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B::30C81C46A35CE411E5FBC1191A0A52EF:EF7AFD2270E2E60ADCE0BA2FACE6444E
72AES-192-ECB:8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B::F69F2445DF4F9B17AD2B417BE66C3710:9A4B41BA738D6C72FB16691603C18E0E
73# ECB-AES256.Encrypt and ECB-AES256.Decrypt
74AES-256-ECB:603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4::6BC1BEE22E409F96E93D7E117393172A:F3EED1BDB5D2A03C064B5A7E3DB181F8
75AES-256-ECB:603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4::AE2D8A571E03AC9C9EB76FAC45AF8E51:591CCB10D410ED26DC5BA74A31362870
76AES-256-ECB:603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4::30C81C46A35CE411E5FBC1191A0A52EF:B6ED21B99CA6F4F9F153E7B1BEAFED1D
77AES-256-ECB:603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4::F69F2445DF4F9B17AD2B417BE66C3710:23304B7A39F9F3FF067D8D8F9E24ECC7
78# For all CBC encrypts and decrypts, the transformed sequence is
79# AES-bits-CBC:key:IV/ciphertext':plaintext:ciphertext:encdec
80# CBC-AES128.Encrypt and CBC-AES128.Decrypt
81AES-128-CBC:2B7E151628AED2A6ABF7158809CF4F3C:000102030405060708090A0B0C0D0E0F:6BC1BEE22E409F96E93D7E117393172A:7649ABAC8119B246CEE98E9B12E9197D
82AES-128-CBC:2B7E151628AED2A6ABF7158809CF4F3C:7649ABAC8119B246CEE98E9B12E9197D:AE2D8A571E03AC9C9EB76FAC45AF8E51:5086CB9B507219EE95DB113A917678B2
83AES-128-CBC:2B7E151628AED2A6ABF7158809CF4F3C:5086CB9B507219EE95DB113A917678B2:30C81C46A35CE411E5FBC1191A0A52EF:73BED6B8E3C1743B7116E69E22229516
84AES-128-CBC:2B7E151628AED2A6ABF7158809CF4F3C:73BED6B8E3C1743B7116E69E22229516:F69F2445DF4F9B17AD2B417BE66C3710:3FF1CAA1681FAC09120ECA307586E1A7
85# CBC-AES192.Encrypt and CBC-AES192.Decrypt
86AES-192-CBC:8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B:000102030405060708090A0B0C0D0E0F:6BC1BEE22E409F96E93D7E117393172A:4F021DB243BC633D7178183A9FA071E8
87AES-192-CBC:8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B:4F021DB243BC633D7178183A9FA071E8:AE2D8A571E03AC9C9EB76FAC45AF8E51:B4D9ADA9AD7DEDF4E5E738763F69145A
88AES-192-CBC:8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B:B4D9ADA9AD7DEDF4E5E738763F69145A:30C81C46A35CE411E5FBC1191A0A52EF:571B242012FB7AE07FA9BAAC3DF102E0
89AES-192-CBC:8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B:571B242012FB7AE07FA9BAAC3DF102E0:F69F2445DF4F9B17AD2B417BE66C3710:08B0E27988598881D920A9E64F5615CD
90# CBC-AES256.Encrypt and CBC-AES256.Decrypt
91AES-256-CBC:603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4:000102030405060708090A0B0C0D0E0F:6BC1BEE22E409F96E93D7E117393172A:F58C4C04D6E5F1BA779EABFB5F7BFBD6
92AES-256-CBC:603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4:F58C4C04D6E5F1BA779EABFB5F7BFBD6:AE2D8A571E03AC9C9EB76FAC45AF8E51:9CFC4E967EDB808D679F777BC6702C7D
93AES-256-CBC:603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4:9CFC4E967EDB808D679F777BC6702C7D:30C81C46A35CE411E5FBC1191A0A52EF:39F23369A9D9BACFA530E26304231461
94AES-256-CBC:603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4:39F23369A9D9BACFA530E26304231461:F69F2445DF4F9B17AD2B417BE66C3710:B2EB05E2C39BE9FCDA6C19078C6A9D1B
95# We don't support CFB{1,8}-AESxxx.{En,De}crypt
96# For all CFB128 encrypts and decrypts, the transformed sequence is
97# AES-bits-CFB:key:IV/ciphertext':plaintext:ciphertext:encdec
98# CFB128-AES128.Encrypt
99AES-128-CFB:2B7E151628AED2A6ABF7158809CF4F3C:000102030405060708090A0B0C0D0E0F:6BC1BEE22E409F96E93D7E117393172A:3B3FD92EB72DAD20333449F8E83CFB4A:1
100AES-128-CFB:2B7E151628AED2A6ABF7158809CF4F3C:3B3FD92EB72DAD20333449F8E83CFB4A:AE2D8A571E03AC9C9EB76FAC45AF8E51:C8A64537A0B3A93FCDE3CDAD9F1CE58B:1
101AES-128-CFB:2B7E151628AED2A6ABF7158809CF4F3C:C8A64537A0B3A93FCDE3CDAD9F1CE58B:30C81C46A35CE411E5FBC1191A0A52EF:26751F67A3CBB140B1808CF187A4F4DF:1
102AES-128-CFB:2B7E151628AED2A6ABF7158809CF4F3C:26751F67A3CBB140B1808CF187A4F4DF:F69F2445DF4F9B17AD2B417BE66C3710:C04B05357C5D1C0EEAC4C66F9FF7F2E6:1
103# CFB128-AES128.Decrypt
104AES-128-CFB:2B7E151628AED2A6ABF7158809CF4F3C:000102030405060708090A0B0C0D0E0F:6BC1BEE22E409F96E93D7E117393172A:3B3FD92EB72DAD20333449F8E83CFB4A:0
105AES-128-CFB:2B7E151628AED2A6ABF7158809CF4F3C:3B3FD92EB72DAD20333449F8E83CFB4A:AE2D8A571E03AC9C9EB76FAC45AF8E51:C8A64537A0B3A93FCDE3CDAD9F1CE58B:0
106AES-128-CFB:2B7E151628AED2A6ABF7158809CF4F3C:C8A64537A0B3A93FCDE3CDAD9F1CE58B:30C81C46A35CE411E5FBC1191A0A52EF:26751F67A3CBB140B1808CF187A4F4DF:0
107AES-128-CFB:2B7E151628AED2A6ABF7158809CF4F3C:26751F67A3CBB140B1808CF187A4F4DF:F69F2445DF4F9B17AD2B417BE66C3710:C04B05357C5D1C0EEAC4C66F9FF7F2E6:0
108# CFB128-AES192.Encrypt
109AES-192-CFB:8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B:000102030405060708090A0B0C0D0E0F:6BC1BEE22E409F96E93D7E117393172A:CDC80D6FDDF18CAB34C25909C99A4174:1
110AES-192-CFB:8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B:CDC80D6FDDF18CAB34C25909C99A4174:AE2D8A571E03AC9C9EB76FAC45AF8E51:67CE7F7F81173621961A2B70171D3D7A:1
111AES-192-CFB:8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B:67CE7F7F81173621961A2B70171D3D7A:30C81C46A35CE411E5FBC1191A0A52EF:2E1E8A1DD59B88B1C8E60FED1EFAC4C9:1
112AES-192-CFB:8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B:2E1E8A1DD59B88B1C8E60FED1EFAC4C9:F69F2445DF4F9B17AD2B417BE66C3710:C05F9F9CA9834FA042AE8FBA584B09FF:1
113# CFB128-AES192.Decrypt
114AES-192-CFB:8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B:000102030405060708090A0B0C0D0E0F:6BC1BEE22E409F96E93D7E117393172A:CDC80D6FDDF18CAB34C25909C99A4174:0
115AES-192-CFB:8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B:CDC80D6FDDF18CAB34C25909C99A4174:AE2D8A571E03AC9C9EB76FAC45AF8E51:67CE7F7F81173621961A2B70171D3D7A:0
116AES-192-CFB:8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B:67CE7F7F81173621961A2B70171D3D7A:30C81C46A35CE411E5FBC1191A0A52EF:2E1E8A1DD59B88B1C8E60FED1EFAC4C9:0
117AES-192-CFB:8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B:2E1E8A1DD59B88B1C8E60FED1EFAC4C9:F69F2445DF4F9B17AD2B417BE66C3710:C05F9F9CA9834FA042AE8FBA584B09FF:0
118# CFB128-AES256.Encrypt
119AES-256-CFB:603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4:000102030405060708090A0B0C0D0E0F:6BC1BEE22E409F96E93D7E117393172A:DC7E84BFDA79164B7ECD8486985D3860:1
120AES-256-CFB:603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4:DC7E84BFDA79164B7ECD8486985D3860:AE2D8A571E03AC9C9EB76FAC45AF8E51:39FFED143B28B1C832113C6331E5407B:1
121AES-256-CFB:603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4:39FFED143B28B1C832113C6331E5407B:30C81C46A35CE411E5FBC1191A0A52EF:DF10132415E54B92A13ED0A8267AE2F9:1
122AES-256-CFB:603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4:DF10132415E54B92A13ED0A8267AE2F9:F69F2445DF4F9B17AD2B417BE66C3710:75A385741AB9CEF82031623D55B1E471:1
123# CFB128-AES256.Decrypt
124AES-256-CFB:603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4:000102030405060708090A0B0C0D0E0F:6BC1BEE22E409F96E93D7E117393172A:DC7E84BFDA79164B7ECD8486985D3860:0
125AES-256-CFB:603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4:DC7E84BFDA79164B7ECD8486985D3860:AE2D8A571E03AC9C9EB76FAC45AF8E51:39FFED143B28B1C832113C6331E5407B:0
126AES-256-CFB:603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4:39FFED143B28B1C832113C6331E5407B:30C81C46A35CE411E5FBC1191A0A52EF:DF10132415E54B92A13ED0A8267AE2F9:0
127AES-256-CFB:603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4:DF10132415E54B92A13ED0A8267AE2F9:F69F2445DF4F9B17AD2B417BE66C3710:75A385741AB9CEF82031623D55B1E471:0
128# For all OFB encrypts and decrypts, the transformed sequence is
129# AES-bits-CFB:key:IV/output':plaintext:ciphertext:encdec
130# OFB-AES128.Encrypt
131AES-128-OFB:2B7E151628AED2A6ABF7158809CF4F3C:000102030405060708090A0B0C0D0E0F:6BC1BEE22E409F96E93D7E117393172A:3B3FD92EB72DAD20333449F8E83CFB4A:1
132AES-128-OFB:2B7E151628AED2A6ABF7158809CF4F3C:50FE67CC996D32B6DA0937E99BAFEC60:AE2D8A571E03AC9C9EB76FAC45AF8E51:7789508D16918F03F53C52DAC54ED825:1
133AES-128-OFB:2B7E151628AED2A6ABF7158809CF4F3C:D9A4DADA0892239F6B8B3D7680E15674:30C81C46A35CE411E5FBC1191A0A52EF:9740051E9C5FECF64344F7A82260EDCC:1
134AES-128-OFB:2B7E151628AED2A6ABF7158809CF4F3C:A78819583F0308E7A6BF36B1386ABF23:F69F2445DF4F9B17AD2B417BE66C3710:304C6528F659C77866A510D9C1D6AE5E:1
135# OFB-AES128.Decrypt
136AES-128-OFB:2B7E151628AED2A6ABF7158809CF4F3C:000102030405060708090A0B0C0D0E0F:6BC1BEE22E409F96E93D7E117393172A:3B3FD92EB72DAD20333449F8E83CFB4A:0
137AES-128-OFB:2B7E151628AED2A6ABF7158809CF4F3C:50FE67CC996D32B6DA0937E99BAFEC60:AE2D8A571E03AC9C9EB76FAC45AF8E51:7789508D16918F03F53C52DAC54ED825:0
138AES-128-OFB:2B7E151628AED2A6ABF7158809CF4F3C:D9A4DADA0892239F6B8B3D7680E15674:30C81C46A35CE411E5FBC1191A0A52EF:9740051E9C5FECF64344F7A82260EDCC:0
139AES-128-OFB:2B7E151628AED2A6ABF7158809CF4F3C:A78819583F0308E7A6BF36B1386ABF23:F69F2445DF4F9B17AD2B417BE66C3710:304C6528F659C77866A510D9C1D6AE5E:0
140# OFB-AES192.Encrypt
141AES-192-OFB:8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B:000102030405060708090A0B0C0D0E0F:6BC1BEE22E409F96E93D7E117393172A:CDC80D6FDDF18CAB34C25909C99A4174:1
142AES-192-OFB:8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B:A609B38DF3B1133DDDFF2718BA09565E:AE2D8A571E03AC9C9EB76FAC45AF8E51:FCC28B8D4C63837C09E81700C1100401:1
143AES-192-OFB:8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B:52EF01DA52602FE0975F78AC84BF8A50:30C81C46A35CE411E5FBC1191A0A52EF:8D9A9AEAC0F6596F559C6D4DAF59A5F2:1
144AES-192-OFB:8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B:BD5286AC63AABD7EB067AC54B553F71D:F69F2445DF4F9B17AD2B417BE66C3710:6D9F200857CA6C3E9CAC524BD9ACC92A:1
145# OFB-AES192.Decrypt
146AES-192-OFB:8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B:000102030405060708090A0B0C0D0E0F:6BC1BEE22E409F96E93D7E117393172A:CDC80D6FDDF18CAB34C25909C99A4174:0
147AES-192-OFB:8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B:A609B38DF3B1133DDDFF2718BA09565E:AE2D8A571E03AC9C9EB76FAC45AF8E51:FCC28B8D4C63837C09E81700C1100401:0
148AES-192-OFB:8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B:52EF01DA52602FE0975F78AC84BF8A50:30C81C46A35CE411E5FBC1191A0A52EF:8D9A9AEAC0F6596F559C6D4DAF59A5F2:0
149AES-192-OFB:8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B:BD5286AC63AABD7EB067AC54B553F71D:F69F2445DF4F9B17AD2B417BE66C3710:6D9F200857CA6C3E9CAC524BD9ACC92A:0
150# OFB-AES256.Encrypt
151AES-256-OFB:603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4:000102030405060708090A0B0C0D0E0F:6BC1BEE22E409F96E93D7E117393172A:DC7E84BFDA79164B7ECD8486985D3860:1
152AES-256-OFB:603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4:B7BF3A5DF43989DD97F0FA97EBCE2F4A:AE2D8A571E03AC9C9EB76FAC45AF8E51:4FEBDC6740D20B3AC88F6AD82A4FB08D:1
153AES-256-OFB:603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4:E1C656305ED1A7A6563805746FE03EDC:30C81C46A35CE411E5FBC1191A0A52EF:71AB47A086E86EEDF39D1C5BBA97C408:1
154AES-256-OFB:603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4:41635BE625B48AFC1666DD42A09D96E7:F69F2445DF4F9B17AD2B417BE66C3710:0126141D67F37BE8538F5A8BE740E484:1
155# OFB-AES256.Decrypt
156AES-256-OFB:603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4:000102030405060708090A0B0C0D0E0F:6BC1BEE22E409F96E93D7E117393172A:DC7E84BFDA79164B7ECD8486985D3860:0
157AES-256-OFB:603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4:B7BF3A5DF43989DD97F0FA97EBCE2F4A:AE2D8A571E03AC9C9EB76FAC45AF8E51:4FEBDC6740D20B3AC88F6AD82A4FB08D:0
158AES-256-OFB:603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4:E1C656305ED1A7A6563805746FE03EDC:30C81C46A35CE411E5FBC1191A0A52EF:71AB47A086E86EEDF39D1C5BBA97C408:0
159AES-256-OFB:603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4:41635BE625B48AFC1666DD42A09D96E7:F69F2445DF4F9B17AD2B417BE66C3710:0126141D67F37BE8538F5A8BE740E484:0
160
161# DES ECB tests (from destest)
162
163DES-ECB:0000000000000000::0000000000000000:8CA64DE9C1B123A7
164DES-ECB:FFFFFFFFFFFFFFFF::FFFFFFFFFFFFFFFF:7359B2163E4EDC58
165DES-ECB:3000000000000000::1000000000000001:958E6E627A05557B
166DES-ECB:1111111111111111::1111111111111111:F40379AB9E0EC533
167DES-ECB:0123456789ABCDEF::1111111111111111:17668DFC7292532D
168DES-ECB:1111111111111111::0123456789ABCDEF:8A5AE1F81AB8F2DD
169DES-ECB:FEDCBA9876543210::0123456789ABCDEF:ED39D950FA74BCC4
170
171# DESX-CBC tests (from destest)
172DESX-CBC:0123456789abcdeff1e0d3c2b5a49786fedcba9876543210:fedcba9876543210:37363534333231204E6F77206973207468652074696D6520666F722000000000:846B2914851E9A2954732F8AA0A611C115CDC2D7951B1053A63C5E03B21AA3C4
173
174# DES EDE3 CBC tests (from destest)
175DES-EDE3-CBC:0123456789abcdeff1e0d3c2b5a49786fedcba9876543210:fedcba9876543210:37363534333231204E6F77206973207468652074696D6520666F722000000000:3FE301C962AC01D02213763C1CBD4CDC799657C064ECF5D41C673812CFDE9675
176
177# RC4 tests (from rc4test)
178RC4:0123456789abcdef0123456789abcdef::0123456789abcdef:75b7878099e0c596
179RC4:0123456789abcdef0123456789abcdef::0000000000000000:7494c2e7104b0879
180RC4:00000000000000000000000000000000::0000000000000000:de188941a3375d3a
181RC4:ef012345ef012345ef012345ef012345::0000000000000000000000000000000000000000:d6a141a7ec3c38dfbd615a1162e1c7ba36b67858
182RC4:0123456789abcdef0123456789abcdef::123456789ABCDEF0123456789ABCDEF0123456789ABCDEF012345678:66a0949f8af7d6891f7f832ba833c00c892ebe30143ce28740011ecf
183RC4:ef012345ef012345ef012345ef012345::00000000000000000000:d6a141a7ec3c38dfbd61
diff --git a/src/lib/libssl/src/test/maketests.com b/src/lib/libssl/src/test/maketests.com
index 91e859deab..7c44e4545a 100644
--- a/src/lib/libssl/src/test/maketests.com
+++ b/src/lib/libssl/src/test/maketests.com
@@ -16,22 +16,10 @@ $! The test "executeables" will be placed in a directory called
16$! [.xxx.EXE.TEST] where "xxx" denotes AXP or VAX depending on your machines 16$! [.xxx.EXE.TEST] where "xxx" denotes AXP or VAX depending on your machines
17$! architecture. 17$! architecture.
18$! 18$!
19$! Specify RSAREF as P1 to compile with the RSAREF library instead of 19$! Specify DEBUG or NODEBUG P1 to compile with or without debugger
20$! the regular one. If you specify NORSAREF it will compile with the
21$! regular RSAREF routines. (Note: If you are in the United States
22$! you MUST compile with RSAREF unless you have a license from RSA).
23$!
24$! Note: The RSAREF libraries are NOT INCLUDED and you have to
25$! download it from "ftp://ftp.rsa.com/rsaref". You have to
26$! get the ".tar-Z" file as the ".zip" file dosen't have the
27$! directory structure stored. You have to extract the file
28$! into the [.RSAREF] directory under the root directory as that
29$! is where the scripts will look for the files.
30$!
31$! Specify DEBUG or NODEBUG P2 to compile with or without debugger
32$! information. 20$! information.
33$! 21$!
34$! Specify which compiler at P3 to try to compile under. 22$! Specify which compiler at P2 to try to compile under.
35$! 23$!
36$! VAXC For VAX C. 24$! VAXC For VAX C.
37$! DECC For DEC C. 25$! DECC For DEC C.
@@ -40,13 +28,13 @@ $!
40$! If you don't speficy a compiler, it will try to determine which 28$! If you don't speficy a compiler, it will try to determine which
41$! "C" compiler to use. 29$! "C" compiler to use.
42$! 30$!
43$! P4, if defined, sets a TCP/IP library to use, through one of the following 31$! P3, if defined, sets a TCP/IP library to use, through one of the following
44$! keywords: 32$! keywords:
45$! 33$!
46$! UCX for UCX 34$! UCX for UCX
47$! SOCKETSHR for SOCKETSHR+NETLIB 35$! SOCKETSHR for SOCKETSHR+NETLIB
48$! 36$!
49$! P5, if defined, sets a compiler thread NOT needed on OpenVMS 7.1 (and up) 37$! P4, if defined, sets a compiler thread NOT needed on OpenVMS 7.1 (and up)
50$! 38$!
51$! 39$!
52$! Define A TCP/IP Library That We Will Need To Link To. 40$! Define A TCP/IP Library That We Will Need To Link To.
@@ -91,10 +79,6 @@ $! Define The CRYPTO-LIB We Are To Use.
91$! 79$!
92$ CRYPTO_LIB := SYS$DISK:[-.'ARCH'.EXE.CRYPTO]LIBCRYPTO.OLB 80$ CRYPTO_LIB := SYS$DISK:[-.'ARCH'.EXE.CRYPTO]LIBCRYPTO.OLB
93$! 81$!
94$! Define The RSAREF-LIB We Are To Use.
95$!
96$ RSAREF_LIB := SYS$DISK:[-.'ARCH'.EXE.RSAREF]LIBRSAGLUE.OLB
97$!
98$! Define The SSL We Are To Use. 82$! Define The SSL We Are To Use.
99$! 83$!
100$ SSL_LIB := SYS$DISK:[-.'ARCH'.EXE.SSL]LIBSSL.OLB 84$ SSL_LIB := SYS$DISK:[-.'ARCH'.EXE.SSL]LIBSSL.OLB
@@ -227,74 +211,32 @@ $!
227$ ENDIF 211$ ENDIF
228$! 212$!
229$! Link The Program, Check To See If We Need To Link With RSAREF Or Not. 213$! Link The Program, Check To See If We Need To Link With RSAREF Or Not.
214$! Check To See If We Are To Link With A Specific TCP/IP Library.
230$! 215$!
231$ IF (RSAREF.EQS."TRUE") 216$ IF (TCPIP_LIB.NES."")
232$ THEN 217$ THEN
233$! 218$!
234$! Check To See If We Are To Link With A Specific TCP/IP Library. 219$! Don't Link With The RSAREF Routines And TCP/IP Library.
235$!
236$ IF (TCPIP_LIB.NES."")
237$ THEN
238$!
239$! Link With The RSAREF Library And A Specific TCP/IP Library.
240$!
241$ LINK/'DEBUGGER'/'TRACEBACK' /EXE='EXE_FILE' -
242 'OBJECT_FILE',-
243 'SSL_LIB'/LIBRARY,'CRYPTO_LIB'/LIBRARY,'RSAREF_LIB'/LIBRARY, -
244 'TCPIP_LIB','OPT_FILE'/OPTION
245$!
246$! Else...
247$!
248$ ELSE
249$!
250$! Link With The RSAREF Library And NO TCP/IP Library.
251$!
252$ LINK/'DEBUGGER'/'TRACEBACK' /EXE='EXE_FILE' -
253 'OBJECT_FILE', -
254 'SSL_LIB'/LIBRARY,'CRYPTO_LIB'/LIBRARY,'RSAREF_LIB'/LIBRARY, -
255 'OPT_FILE'/OPTION
256$!
257$! End The TCP/IP Library Check.
258$!
259$ ENDIF
260$!
261$! Else...
262$!
263$ ELSE
264$!
265$! Don't Link With The RSAREF Routines.
266$!
267$!
268$! Check To See If We Are To Link With A Specific TCP/IP Library.
269$!
270$ IF (TCPIP_LIB.NES."")
271$ THEN
272$!
273$! Don't Link With The RSAREF Routines And TCP/IP Library.
274$! 220$!
275$ LINK/'DEBUGGER'/'TRACEBACK' /EXE='EXE_FILE' - 221$ LINK/'DEBUGGER'/'TRACEBACK' /EXE='EXE_FILE' -
276 'OBJECT_FILE', - 222 'OBJECT_FILE', -
277 'SSL_LIB'/LIBRARY,'CRYPTO_LIB'/LIBRARY, - 223 'SSL_LIB'/LIBRARY,'CRYPTO_LIB'/LIBRARY, -
278 'TCPIP_LIB','OPT_FILE'/OPTION 224 'TCPIP_LIB','OPT_FILE'/OPTION
279$! 225$!
280$! Else... 226$! Else...
281$! 227$!
282$ ELSE 228$ ELSE
283$! 229$!
284$! Don't Link With The RSAREF Routines And Link With A TCP/IP Library. 230$! Don't Link With The RSAREF Routines And Link With A TCP/IP Library.
285$! 231$!
286$ LINK/'DEBUGGER'/'TRACEBACK' /EXE='EXE_FILE' - 232$ LINK/'DEBUGGER'/'TRACEBACK' /EXE='EXE_FILE' -
287 'OBJECT_FILE', - 233 'OBJECT_FILE', -
288 'SSL_LIB'/LIBRARY,'CRYPTO_LIB'/LIBRARY, - 234 'SSL_LIB'/LIBRARY,'CRYPTO_LIB'/LIBRARY, -
289 'OPT_FILE'/OPTION 235 'OPT_FILE'/OPTION
290$! 236$!
291$! End The TCP/IP Library Check. 237$! End The TCP/IP Library Check.
292$!
293$ ENDIF
294$!
295$! End The RSAREF Link Check.
296$! 238$!
297$ ENDIF 239$ ENDIF
298$! 240$!
299$! Go Back And Do It Again. 241$! Go Back And Do It Again.
300$! 242$!
@@ -459,32 +401,6 @@ $! End The Crypto Library Check.
459$! 401$!
460$ ENDIF 402$ ENDIF
461$! 403$!
462$! See If We Need The RSAREF Library...
463$!
464$ IF (RSAREF.EQS."TRUE")
465$ THEN
466$!
467$! Look For The Library LIBRSAGLUE.OLB.
468$!
469$ IF (F$SEARCH(RSAREF_LIB).EQS."")
470$ THEN
471$!
472$! Tell The User We Can't Find The LIBRSAGLUE.OLB Library.
473$!
474$ WRITE SYS$OUTPUT ""
475$ WRITE SYS$OUTPUT "Can't Find The Library ",RSAREF_LIB,"."
476$ WRITE SYS$OUTPUT "We Can't Link Without It."
477$ WRITE SYS$OUTPUT ""
478$!
479$! Since We Can't Link Without It, Exit.
480$!
481$ EXIT
482$ ENDIF
483$!
484$! End The RSAREF Library Check.
485$!
486$ ENDIF
487$!
488$! Look For The Library LIBSSL.OLB. 404$! Look For The Library LIBSSL.OLB.
489$! 405$!
490$ IF (F$SEARCH(SSL_LIB).EQS."") 406$ IF (F$SEARCH(SSL_LIB).EQS."")
@@ -515,75 +431,10 @@ $ CHECK_OPTIONS:
515$! 431$!
516$! Check To See If P1 Is Blank. 432$! Check To See If P1 Is Blank.
517$! 433$!
518$ P1 = "NORSAREF" 434$ IF (P1.EQS."NODEBUG")
519$ IF (P1.EQS."NORSAREF")
520$ THEN
521$!
522$! P1 Is NORSAREF, So Compile With The Regular RSA Libraries.
523$!
524$ RSAREF = "FALSE"
525$ ELSE
526$!
527$! Check To See If We Are To Use The RSAREF Library.
528$!
529$ IF (P1.EQS."RSAREF")
530$ THEN
531$!
532$! Check To Make Sure We Have The RSAREF Source Code Directory.
533$!
534$ IF (F$SEARCH("SYS$DISK:[-.RSAREF]SOURCE.DIR").EQS."")
535$ THEN
536$!
537$! We Don't Have The RSAREF Souce Code Directory, So Tell The
538$! User This.
539$!
540$ WRITE SYS$OUTPUT ""
541$ WRITE SYS$OUTPUT "It appears that you don't have the RSAREF Souce Code."
542$ WRITE SYS$OUTPUT "You need to go to 'ftp://ftp.rsa.com/rsaref'. You have to"
543$ WRITE SYS$OUTPUT "get the '.tar-Z' file as the '.zip' file dosen't have the"
544$ WRITE SYS$OUTPUT "directory structure stored. You have to extract the file"
545$ WRITE SYS$OUTPUT "into the [.RSAREF] directory under the root directory"
546$ WRITE SYS$OUTPUT "as that is where the scripts will look for the files."
547$ WRITE SYS$OUTPUT ""
548$!
549$! Time To Exit.
550$!
551$ EXIT
552$!
553$! Else, Compile Using The RSAREF Library.
554$!
555$ ELSE
556$ RSAREF = "TRUE"
557$ ENDIF
558$ ELSE
559$!
560$! They Entered An Invalid Option..
561$!
562$ WRITE SYS$OUTPUT ""
563$ WRITE SYS$OUTPUT "The Option ",P1," Is Invalid. The Valid Options Are:"
564$ WRITE SYS$OUTPUT ""
565$ WRITE SYS$OUTPUT " RSAREF : Compile With The RSAREF Library."
566$ WRITE SYS$OUTPUT " NORSAREF : Compile With The Regular RSA Library."
567$ WRITE SYS$OUTPUT ""
568$!
569$! Time To EXIT.
570$!
571$ EXIT
572$!
573$! End The Valid Arguement Check.
574$!
575$ ENDIF
576$!
577$! End The P1 Check.
578$!
579$ ENDIF
580$!
581$! Check To See If P2 Is Blank.
582$!
583$ IF (P2.EQS."NODEBUG")
584$ THEN 435$ THEN
585$! 436$!
586$! P2 Is NODEBUG, So Compile Without Debugger Information. 437$! P1 Is NODEBUG, So Compile Without Debugger Information.
587$! 438$!
588$ DEBUGGER = "NODEBUG" 439$ DEBUGGER = "NODEBUG"
589$ TRACEBACK = "NOTRACEBACK" 440$ TRACEBACK = "NOTRACEBACK"
@@ -598,7 +449,7 @@ $ ELSE
598$! 449$!
599$! Check To See If We Are To Compile With Debugger Information. 450$! Check To See If We Are To Compile With Debugger Information.
600$! 451$!
601$ IF (P2.EQS."DEBUG") 452$ IF (P1.EQS."DEBUG")
602$ THEN 453$ THEN
603$! 454$!
604$! Compile With Debugger Information. 455$! Compile With Debugger Information.
@@ -617,7 +468,7 @@ $!
617$! Tell The User Entered An Invalid Option.. 468$! Tell The User Entered An Invalid Option..
618$! 469$!
619$ WRITE SYS$OUTPUT "" 470$ WRITE SYS$OUTPUT ""
620$ WRITE SYS$OUTPUT "The Option ",P2," Is Invalid. The Valid Options Are:" 471$ WRITE SYS$OUTPUT "The Option ",P1," Is Invalid. The Valid Options Are:"
621$ WRITE SYS$OUTPUT "" 472$ WRITE SYS$OUTPUT ""
622$ WRITE SYS$OUTPUT " DEBUG : Compile With The Debugger Information." 473$ WRITE SYS$OUTPUT " DEBUG : Compile With The Debugger Information."
623$ WRITE SYS$OUTPUT " NODEBUG : Compile Without The Debugger Information." 474$ WRITE SYS$OUTPUT " NODEBUG : Compile Without The Debugger Information."
@@ -631,13 +482,13 @@ $! End The Valid Arguement Check.
631$! 482$!
632$ ENDIF 483$ ENDIF
633$! 484$!
634$! End The P3 Check. 485$! End The P2 Check.
635$! 486$!
636$ ENDIF 487$ ENDIF
637$! 488$!
638$! Check To See If P3 Is Blank. 489$! Check To See If P2 Is Blank.
639$! 490$!
640$ IF (P3.EQS."") 491$ IF (P2.EQS."")
641$ THEN 492$ THEN
642$! 493$!
643$! O.K., The User Didn't Specify A Compiler, Let's Try To 494$! O.K., The User Didn't Specify A Compiler, Let's Try To
@@ -650,7 +501,7 @@ $ THEN
650$! 501$!
651$! Looks Like GNUC, Set To Use GNUC. 502$! Looks Like GNUC, Set To Use GNUC.
652$! 503$!
653$ P3 = "GNUC" 504$ P2 = "GNUC"
654$! 505$!
655$! End The GNU C Compiler Check. 506$! End The GNU C Compiler Check.
656$! 507$!
@@ -663,7 +514,7 @@ $ THEN
663$! 514$!
664$! Looks Like DECC, Set To Use DECC. 515$! Looks Like DECC, Set To Use DECC.
665$! 516$!
666$ P3 = "DECC" 517$ P2 = "DECC"
667$! 518$!
668$! Else... 519$! Else...
669$! 520$!
@@ -671,7 +522,7 @@ $ ELSE
671$! 522$!
672$! Looks Like VAXC, Set To Use VAXC. 523$! Looks Like VAXC, Set To Use VAXC.
673$! 524$!
674$ P3 = "VAXC" 525$ P2 = "VAXC"
675$! 526$!
676$! End The VAXC Compiler Check. 527$! End The VAXC Compiler Check.
677$! 528$!
@@ -685,9 +536,9 @@ $! End The Compiler Check.
685$! 536$!
686$ ENDIF 537$ ENDIF
687$! 538$!
688$! Check To See If We Have A Option For P4. 539$! Check To See If We Have A Option For P3.
689$! 540$!
690$ IF (P4.EQS."") 541$ IF (P3.EQS."")
691$ THEN 542$ THEN
692$! 543$!
693$! Find out what socket library we have available 544$! Find out what socket library we have available
@@ -697,7 +548,7 @@ $ THEN
697$! 548$!
698$! We have SOCKETSHR, and it is my opinion that it's the best to use. 549$! We have SOCKETSHR, and it is my opinion that it's the best to use.
699$! 550$!
700$ P4 = "SOCKETSHR" 551$ P3 = "SOCKETSHR"
701$! 552$!
702$! Tell the user 553$! Tell the user
703$! 554$!
@@ -717,7 +568,7 @@ $ THEN
717$! 568$!
718$! Last resort: a UCX or UCX-compatible library 569$! Last resort: a UCX or UCX-compatible library
719$! 570$!
720$ P4 = "UCX" 571$ P3 = "UCX"
721$! 572$!
722$! Tell the user 573$! Tell the user
723$! 574$!
@@ -731,7 +582,7 @@ $ ENDIF
731$! 582$!
732$! Set Up Initial CC Definitions, Possibly With User Ones 583$! Set Up Initial CC Definitions, Possibly With User Ones
733$! 584$!
734$ CCDEFS = "TCPIP_TYPE_''P4'" 585$ CCDEFS = "TCPIP_TYPE_''P3'"
735$ IF F$TYPE(USER_CCDEFS) .NES. "" THEN CCDEFS = CCDEFS + "," + USER_CCDEFS 586$ IF F$TYPE(USER_CCDEFS) .NES. "" THEN CCDEFS = CCDEFS + "," + USER_CCDEFS
736$ CCEXTRAFLAGS = "" 587$ CCEXTRAFLAGS = ""
737$ IF F$TYPE(USER_CCFLAGS) .NES. "" THEN CCEXTRAFLAGS = USER_CCFLAGS 588$ IF F$TYPE(USER_CCFLAGS) .NES. "" THEN CCEXTRAFLAGS = USER_CCFLAGS
@@ -741,12 +592,12 @@ $ IF F$TYPE(USER_CCDISABLEWARNINGS) .NES. "" THEN -
741$! 592$!
742$! Check To See If The User Entered A Valid Paramter. 593$! Check To See If The User Entered A Valid Paramter.
743$! 594$!
744$ IF (P3.EQS."VAXC").OR.(P3.EQS."DECC").OR.(P3.EQS."GNUC") 595$ IF (P2.EQS."VAXC").OR.(P2.EQS."DECC").OR.(P2.EQS."GNUC")
745$ THEN 596$ THEN
746$! 597$!
747$! Check To See If The User Wanted DECC. 598$! Check To See If The User Wanted DECC.
748$! 599$!
749$ IF (P3.EQS."DECC") 600$ IF (P2.EQS."DECC")
750$ THEN 601$ THEN
751$! 602$!
752$! Looks Like DECC, Set To Use DECC. 603$! Looks Like DECC, Set To Use DECC.
@@ -776,7 +627,7 @@ $ ENDIF
776$! 627$!
777$! Check To See If We Are To Use VAXC. 628$! Check To See If We Are To Use VAXC.
778$! 629$!
779$ IF (P3.EQS."VAXC") 630$ IF (P2.EQS."VAXC")
780$ THEN 631$ THEN
781$! 632$!
782$! Looks Like VAXC, Set To Use VAXC. 633$! Looks Like VAXC, Set To Use VAXC.
@@ -814,7 +665,7 @@ $ ENDIF
814$! 665$!
815$! Check To See If We Are To Use GNU C. 666$! Check To See If We Are To Use GNU C.
816$! 667$!
817$ IF (P3.EQS."GNUC") 668$ IF (P2.EQS."GNUC")
818$ THEN 669$ THEN
819$! 670$!
820$! Looks Like GNUC, Set To Use GNUC. 671$! Looks Like GNUC, Set To Use GNUC.
@@ -842,31 +693,6 @@ $! Set up default defines
842$! 693$!
843$ CCDEFS = """FLAT_INC=1""," + CCDEFS 694$ CCDEFS = """FLAT_INC=1""," + CCDEFS
844$! 695$!
845$! Check To See If We Are To Compile With RSAREF Routines.
846$!
847$ IF (RSAREF.EQS."TRUE")
848$ THEN
849$!
850$! Compile With RSAREF.
851$!
852$ CCDEFS = CCDEFS + ",""RSAref=1"""
853$!
854$! Tell The User This.
855$!
856$ WRITE SYS$OUTPUT "Compiling With RSAREF Routines."
857$!
858$! Else, We Don't Care. Compile Without The RSAREF Library.
859$!
860$ ELSE
861$!
862$! Tell The User We Are Compile Without The RSAREF Routines.
863$!
864$ WRITE SYS$OUTPUT "Compiling Without The RSAREF Routines.
865$!
866$! End The RSAREF Check.
867$!
868$ ENDIF
869$!
870$! Finish up the definition of CC. 696$! Finish up the definition of CC.
871$! 697$!
872$ IF COMPILER .EQS. "DECC" 698$ IF COMPILER .EQS. "DECC"
@@ -896,7 +722,7 @@ $!
896$! Tell The User We Don't Know What They Want. 722$! Tell The User We Don't Know What They Want.
897$! 723$!
898$ WRITE SYS$OUTPUT "" 724$ WRITE SYS$OUTPUT ""
899$ WRITE SYS$OUTPUT "The Option ",P3," Is Invalid. The Valid Options Are:" 725$ WRITE SYS$OUTPUT "The Option ",P2," Is Invalid. The Valid Options Are:"
900$ WRITE SYS$OUTPUT "" 726$ WRITE SYS$OUTPUT ""
901$ WRITE SYS$OUTPUT " VAXC : To Compile With VAX C." 727$ WRITE SYS$OUTPUT " VAXC : To Compile With VAX C."
902$ WRITE SYS$OUTPUT " DECC : To Compile With DEC C." 728$ WRITE SYS$OUTPUT " DECC : To Compile With DEC C."
@@ -910,13 +736,13 @@ $ ENDIF
910$! 736$!
911$! Time to check the contents, and to make sure we get the correct library. 737$! Time to check the contents, and to make sure we get the correct library.
912$! 738$!
913$ IF P4.EQS."SOCKETSHR" .OR. P4.EQS."MULTINET" .OR. P4.EQS."UCX" - 739$ IF P3.EQS."SOCKETSHR" .OR. P3.EQS."MULTINET" .OR. P3.EQS."UCX" -
914 .OR. P4.EQS."TCPIP" .OR. P4.EQS."NONE" 740 .OR. P3.EQS."TCPIP" .OR. P3.EQS."NONE"
915$ THEN 741$ THEN
916$! 742$!
917$! Check to see if SOCKETSHR was chosen 743$! Check to see if SOCKETSHR was chosen
918$! 744$!
919$ IF P4.EQS."SOCKETSHR" 745$ IF P3.EQS."SOCKETSHR"
920$ THEN 746$ THEN
921$! 747$!
922$! Set the library to use SOCKETSHR 748$! Set the library to use SOCKETSHR
@@ -929,12 +755,12 @@ $ ENDIF
929$! 755$!
930$! Check to see if MULTINET was chosen 756$! Check to see if MULTINET was chosen
931$! 757$!
932$ IF P4.EQS."MULTINET" 758$ IF P3.EQS."MULTINET"
933$ THEN 759$ THEN
934$! 760$!
935$! Set the library to use UXC emulation. 761$! Set the library to use UXC emulation.
936$! 762$!
937$ P4 = "UCX" 763$ P3 = "UCX"
938$! 764$!
939$! Done with MULTINET 765$! Done with MULTINET
940$! 766$!
@@ -942,7 +768,7 @@ $ ENDIF
942$! 768$!
943$! Check to see if UCX was chosen 769$! Check to see if UCX was chosen
944$! 770$!
945$ IF P4.EQS."UCX" 771$ IF P3.EQS."UCX"
946$ THEN 772$ THEN
947$! 773$!
948$! Set the library to use UCX. 774$! Set the library to use UCX.
@@ -962,7 +788,7 @@ $ ENDIF
962$! 788$!
963$! Check to see if TCPIP was chosen 789$! Check to see if TCPIP was chosen
964$! 790$!
965$ IF P4.EQS."TCPIP" 791$ IF P3.EQS."TCPIP"
966$ THEN 792$ THEN
967$! 793$!
968$! Set the library to use TCPIP (post UCX). 794$! Set the library to use TCPIP (post UCX).
@@ -975,7 +801,7 @@ $ ENDIF
975$! 801$!
976$! Check to see if NONE was chosen 802$! Check to see if NONE was chosen
977$! 803$!
978$ IF P4.EQS."NONE" 804$ IF P3.EQS."NONE"
979$ THEN 805$ THEN
980$! 806$!
981$! Do not use a TCPIP library. 807$! Do not use a TCPIP library.
@@ -997,7 +823,7 @@ $!
997$! Tell The User We Don't Know What They Want. 823$! Tell The User We Don't Know What They Want.
998$! 824$!
999$ WRITE SYS$OUTPUT "" 825$ WRITE SYS$OUTPUT ""
1000$ WRITE SYS$OUTPUT "The Option ",P4," Is Invalid. The Valid Options Are:" 826$ WRITE SYS$OUTPUT "The Option ",P3," Is Invalid. The Valid Options Are:"
1001$ WRITE SYS$OUTPUT "" 827$ WRITE SYS$OUTPUT ""
1002$ WRITE SYS$OUTPUT " SOCKETSHR : To link with SOCKETSHR TCP/IP library." 828$ WRITE SYS$OUTPUT " SOCKETSHR : To link with SOCKETSHR TCP/IP library."
1003$ WRITE SYS$OUTPUT " UCX : To link with UCX TCP/IP library." 829$ WRITE SYS$OUTPUT " UCX : To link with UCX TCP/IP library."
@@ -1018,9 +844,9 @@ $! Written By: Richard Levitte
1018$! richard@levitte.org 844$! richard@levitte.org
1019$! 845$!
1020$! 846$!
1021$! Check To See If We Have A Option For P5. 847$! Check To See If We Have A Option For P4.
1022$! 848$!
1023$ IF (P5.EQS."") 849$ IF (P4.EQS."")
1024$ THEN 850$ THEN
1025$! 851$!
1026$! Get The Version Of VMS We Are Using. 852$! Get The Version Of VMS We Are Using.
@@ -1042,7 +868,7 @@ $! End The VMS Version Check.
1042$! 868$!
1043$ ENDIF 869$ ENDIF
1044$! 870$!
1045$! End The P5 Check. 871$! End The P4 Check.
1046$! 872$!
1047$ ENDIF 873$ ENDIF
1048$! 874$!
diff --git a/src/lib/libssl/src/test/methtest.c b/src/lib/libssl/src/test/methtest.c
index 06ccb3b310..005c2f4822 100644
--- a/src/lib/libssl/src/test/methtest.c
+++ b/src/lib/libssl/src/test/methtest.c
@@ -96,10 +96,10 @@ char *argv[];
96 METH_init(top); 96 METH_init(top);
97 METH_control(tmp1,METH_CONTROL_DUMP,stdout); 97 METH_control(tmp1,METH_CONTROL_DUMP,stdout);
98 METH_control(tmp2,METH_CONTROL_DUMP,stdout); 98 METH_control(tmp2,METH_CONTROL_DUMP,stdout);
99 exit(0); 99 EXIT(0);
100err: 100err:
101 ERR_load_crypto_strings(); 101 ERR_load_crypto_strings();
102 ERR_print_errors_fp(stderr); 102 ERR_print_errors_fp(stderr);
103 exit(1); 103 EXIT(1);
104 return(0); 104 return(0);
105 } 105 }
diff --git a/src/lib/libssl/src/test/testgen b/src/lib/libssl/src/test/testgen
index 55c496f4bc..3798543e04 100644
--- a/src/lib/libssl/src/test/testgen
+++ b/src/lib/libssl/src/test/testgen
@@ -27,6 +27,8 @@ fi
27 27
28echo "This could take some time." 28echo "This could take some time."
29 29
30rm -f testkey.pem testreq.pem
31
30../apps/openssl req -config test.cnf $req_new -out testreq.pem 32../apps/openssl req -config test.cnf $req_new -out testreq.pem
31if [ $? != 0 ]; then 33if [ $? != 0 ]; then
32echo problems creating request 34echo problems creating request
diff --git a/src/lib/libssl/src/test/testssl b/src/lib/libssl/src/test/testssl
index ba5e41c861..ca8e718022 100644
--- a/src/lib/libssl/src/test/testssl
+++ b/src/lib/libssl/src/test/testssl
@@ -121,8 +121,12 @@ $ssltest -bio_pair -server_auth -client_auth -app_verify $CA $extra || exit 1
121 121
122############################################################################# 122#############################################################################
123 123
124echo test tls1 with 1024bit anonymous DH, multiple handshakes 124if ../apps/openssl no-dh; then
125$ssltest -v -bio_pair -tls1 -cipher ADH -dhe1024dsa -num 10 -f -time $extra || exit 1 125 echo skipping anonymous DH tests
126else
127 echo test tls1 with 1024bit anonymous DH, multiple handshakes
128 $ssltest -v -bio_pair -tls1 -cipher ADH -dhe1024dsa -num 10 -f -time $extra || exit 1
129fi
126 130
127if ../apps/openssl no-rsa; then 131if ../apps/openssl no-rsa; then
128 echo skipping RSA tests 132 echo skipping RSA tests
@@ -130,8 +134,12 @@ else
130 echo test tls1 with 1024bit RSA, no DHE, multiple handshakes 134 echo test tls1 with 1024bit RSA, no DHE, multiple handshakes
131 ./ssltest -v -bio_pair -tls1 -cert ../apps/server2.pem -no_dhe -num 10 -f -time $extra || exit 1 135 ./ssltest -v -bio_pair -tls1 -cert ../apps/server2.pem -no_dhe -num 10 -f -time $extra || exit 1
132 136
133 echo test tls1 with 1024bit RSA, 1024bit DHE, multiple handshakes 137 if ../apps/openssl no-dh; then
134 ./ssltest -v -bio_pair -tls1 -cert ../apps/server2.pem -dhe1024dsa -num 10 -f -time $extra || exit 1 138 echo skipping RSA+DHE tests
139 else
140 echo test tls1 with 1024bit RSA, 1024bit DHE, multiple handshakes
141 ./ssltest -v -bio_pair -tls1 -cert ../apps/server2.pem -dhe1024dsa -num 10 -f -time $extra || exit 1
142 fi
135fi 143fi
136 144
137exit 0 145exit 0
diff --git a/src/lib/libssl/src/test/testssl.com b/src/lib/libssl/src/test/testssl.com
index 785f262f5a..26308f7715 100644
--- a/src/lib/libssl/src/test/testssl.com
+++ b/src/lib/libssl/src/test/testssl.com
@@ -159,16 +159,25 @@ $ if $severity .ne. 1 then goto exit3
159$ 159$
160$!########################################################################### 160$!###########################################################################
161$ 161$
162$ write sys$output "test tls1 with 1024bit anonymous DH, multiple handshakes"
163$ 'ssltest' -v -bio_pair -tls1 -cipher "ADH" -dhe1024dsa -num 10 -f -time
164$ if $severity .ne. 1 then goto exit3
165$
166$ set noon 162$ set noon
167$ define/user sys$output nla0: 163$ define/user sys$output nla0:
168$ mcr 'exe_dir'openssl no-rsa 164$ mcr 'exe_dir'openssl no-rsa
169$ save_severity=$SEVERITY 165$ no_rsa=$SEVERITY
166$ define/user sys$output nla0:
167$ mcr 'exe_dir'openssl no-dh
168$ no_dh=$SEVERITY
170$ set on 169$ set on
171$ if save_severity 170$
171$ if no_dh
172$ then
173$ write sys$output "skipping anonymous DH tests"
174$ else
175$ write sys$output "test tls1 with 1024bit anonymous DH, multiple handshakes"
176$ 'ssltest' -v -bio_pair -tls1 -cipher "ADH" -dhe1024dsa -num 10 -f -time
177$ if $severity .ne. 1 then goto exit3
178$ endif
179$
180$ if no_rsa
172$ then 181$ then
173$ write sys$output "skipping RSA tests" 182$ write sys$output "skipping RSA tests"
174$ else 183$ else
@@ -176,9 +185,14 @@ $ write sys$output "test tls1 with 1024bit RSA, no DHE, multiple handshakes"
176$ mcr 'texe_dir'ssltest -v -bio_pair -tls1 -cert [-.apps]server2.pem -no_dhe -num 10 -f -time 185$ mcr 'texe_dir'ssltest -v -bio_pair -tls1 -cert [-.apps]server2.pem -no_dhe -num 10 -f -time
177$ if $severity .ne. 1 then goto exit3 186$ if $severity .ne. 1 then goto exit3
178$ 187$
179$ write sys$output "test tls1 with 1024bit RSA, 1024bit DHE, multiple handshakes" 188$ if no_dh
180$ mcr 'texe_dir'ssltest -v -bio_pair -tls1 -cert [-.apps]server2.pem -dhe1024dsa -num 10 -f -time 189$ then
181$ if $severity .ne. 1 then goto exit3 190$ write sys$output "skipping RSA+DHE tests"
191$ else
192$ write sys$output "test tls1 with 1024bit RSA, 1024bit DHE, multiple handshakes"
193$ mcr 'texe_dir'ssltest -v -bio_pair -tls1 -cert [-.apps]server2.pem -dhe1024dsa -num 10 -f -time
194$ if $severity .ne. 1 then goto exit3
195$ endif
182$ endif 196$ endif
183$ 197$
184$ RET = 1 198$ RET = 1
diff --git a/src/lib/libssl/src/tools/c_rehash b/src/lib/libssl/src/tools/c_rehash
index e07dd3fca9..3e9ba1efe4 100644
--- a/src/lib/libssl/src/tools/c_rehash
+++ b/src/lib/libssl/src/tools/c_rehash
@@ -1,4 +1,4 @@
1#!/usr/local/bin/perl5 1#!/usr/local/bin/perl
2 2
3 3
4# Perl c_rehash script, scan all files in a directory 4# Perl c_rehash script, scan all files in a directory
@@ -100,7 +100,8 @@ sub check_file {
100 100
101sub link_hash_cert { 101sub link_hash_cert {
102 my $fname = $_[0]; 102 my $fname = $_[0];
103 my ($hash, $fprint) = `$openssl x509 -hash -fingerprint -noout -in "$fname"`; 103 $fname =~ s/'/'\\''/g;
104 my ($hash, $fprint) = `"$openssl" x509 -hash -fingerprint -noout -in '$fname'`;
104 chomp $hash; 105 chomp $hash;
105 chomp $fprint; 106 chomp $fprint;
106 $fprint =~ s/^.*=//; 107 $fprint =~ s/^.*=//;
@@ -130,7 +131,8 @@ sub link_hash_cert {
130 131
131sub link_hash_crl { 132sub link_hash_crl {
132 my $fname = $_[0]; 133 my $fname = $_[0];
133 my ($hash, $fprint) = `$openssl crl -hash -fingerprint -noout -in "$fname"`; 134 $fname =~ s/'/'\\''/g;
135 my ($hash, $fprint) = `"$openssl" crl -hash -fingerprint -noout -in '$fname'`;
134 chomp $hash; 136 chomp $hash;
135 chomp $fprint; 137 chomp $fprint;
136 $fprint =~ s/^.*=//; 138 $fprint =~ s/^.*=//;
diff --git a/src/lib/libssl/src/tools/c_rehash.in b/src/lib/libssl/src/tools/c_rehash.in
index 5b053406c2..4497cbd9f1 100644
--- a/src/lib/libssl/src/tools/c_rehash.in
+++ b/src/lib/libssl/src/tools/c_rehash.in
@@ -100,7 +100,8 @@ sub check_file {
100 100
101sub link_hash_cert { 101sub link_hash_cert {
102 my $fname = $_[0]; 102 my $fname = $_[0];
103 my ($hash, $fprint) = `$openssl x509 -hash -fingerprint -noout -in "$fname"`; 103 $fname =~ s/'/'\\''/g;
104 my ($hash, $fprint) = `"$openssl" x509 -hash -fingerprint -noout -in '$fname'`;
104 chomp $hash; 105 chomp $hash;
105 chomp $fprint; 106 chomp $fprint;
106 $fprint =~ s/^.*=//; 107 $fprint =~ s/^.*=//;
@@ -130,7 +131,8 @@ sub link_hash_cert {
130 131
131sub link_hash_crl { 132sub link_hash_crl {
132 my $fname = $_[0]; 133 my $fname = $_[0];
133 my ($hash, $fprint) = `$openssl crl -hash -fingerprint -noout -in "$fname"`; 134 $fname =~ s/'/'\\''/g;
135 my ($hash, $fprint) = `"$openssl" crl -hash -fingerprint -noout -in '$fname'`;
134 chomp $hash; 136 chomp $hash;
135 chomp $fprint; 137 chomp $fprint;
136 $fprint =~ s/^.*=//; 138 $fprint =~ s/^.*=//;
diff --git a/src/lib/libssl/src/util/bat.sh b/src/lib/libssl/src/util/bat.sh
index c6f48e8a7b..4d9a8287d0 100644
--- a/src/lib/libssl/src/util/bat.sh
+++ b/src/lib/libssl/src/util/bat.sh
@@ -62,6 +62,7 @@ sub var_add
62 local($dir,$val)=@_; 62 local($dir,$val)=@_;
63 local(@a,$_,$ret); 63 local(@a,$_,$ret);
64 64
65 return("") if $no_engine && $dir =~ /\/engine/;
65 return("") if $no_idea && $dir =~ /\/idea/; 66 return("") if $no_idea && $dir =~ /\/idea/;
66 return("") if $no_rc2 && $dir =~ /\/rc2/; 67 return("") if $no_rc2 && $dir =~ /\/rc2/;
67 return("") if $no_rc4 && $dir =~ /\/rc4/; 68 return("") if $no_rc4 && $dir =~ /\/rc4/;
@@ -116,6 +117,7 @@ sub var_add
116 @a=grep(!/(^sha1)|(_sha1$)|(m_dss1$)/,@a) if $no_sha1; 117 @a=grep(!/(^sha1)|(_sha1$)|(m_dss1$)/,@a) if $no_sha1;
117 @a=grep(!/_mdc2$/,@a) if $no_mdc2; 118 @a=grep(!/_mdc2$/,@a) if $no_mdc2;
118 119
120 @a=grep(!/^engine$/,@a) if $no_engine;
119 @a=grep(!/(^rsa$)|(^genrsa$)|(^req$)|(^ca$)/,@a) if $no_rsa; 121 @a=grep(!/(^rsa$)|(^genrsa$)|(^req$)|(^ca$)/,@a) if $no_rsa;
120 @a=grep(!/(^dsa$)|(^gendsa$)|(^dsaparam$)/,@a) if $no_dsa; 122 @a=grep(!/(^dsa$)|(^gendsa$)|(^dsaparam$)/,@a) if $no_dsa;
121 @a=grep(!/^gendsa$/,@a) if $no_sha1; 123 @a=grep(!/^gendsa$/,@a) if $no_sha1;
diff --git a/src/lib/libssl/src/util/cygwin.sh b/src/lib/libssl/src/util/cygwin.sh
index b607399b02..930f766b4f 100644
--- a/src/lib/libssl/src/util/cygwin.sh
+++ b/src/lib/libssl/src/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/libssl/src/util/domd b/src/lib/libssl/src/util/domd
index 8cbe383c16..49310bbdd1 100644
--- a/src/lib/libssl/src/util/domd
+++ b/src/lib/libssl/src/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/libssl/src/util/extract-names.pl b/src/lib/libssl/src/util/extract-names.pl
new file mode 100644
index 0000000000..d413a045cc
--- /dev/null
+++ b/src/lib/libssl/src/util/extract-names.pl
@@ -0,0 +1,22 @@
1#!/usr/bin/perl
2
3$/ = ""; # Eat a paragraph at once.
4while(<STDIN>) {
5 chop;
6 s/\n/ /gm;
7 if (/^=head1 /) {
8 $name = 0;
9 } elsif ($name) {
10 if (/ - /) {
11 s/ - .*//;
12 s/[ \t,]+/ /g;
13 push @words, split ' ';
14 }
15 }
16 if (/^=head1 *NAME *$/) {
17 $name = 1;
18 }
19}
20
21print join("\n", @words),"\n";
22
diff --git a/src/lib/libssl/src/util/libeay.num b/src/lib/libssl/src/util/libeay.num
index 7e5728495f..f5c8c0be8a 100644
--- a/src/lib/libssl/src/util/libeay.num
+++ b/src/lib/libssl/src/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/libssl/src/util/mk1mf.pl b/src/lib/libssl/src/util/mk1mf.pl
index c9271bbffe..c538f9dffb 100644
--- a/src/lib/libssl/src/util/mk1mf.pl
+++ b/src/lib/libssl/src/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/libssl/src/util/mkcerts.sh b/src/lib/libssl/src/util/mkcerts.sh
index 5f8a1dae73..0184fcb70e 100644
--- a/src/lib/libssl/src/util/mkcerts.sh
+++ b/src/lib/libssl/src/util/mkcerts.sh
@@ -1,4 +1,4 @@
1#!bin/sh 1#!/bin/sh
2 2
3# This script will re-make all the required certs. 3# This script will re-make all the required certs.
4# cd apps 4# cd apps
@@ -12,8 +12,8 @@
12# 12#
13 13
14CAbits=1024 14CAbits=1024
15SSLEAY="../apps/ssleay" 15SSLEAY="../apps/openssl"
16CONF="-config ../apps/ssleay.cnf" 16CONF="-config ../apps/openssl.cnf"
17 17
18# create pca request. 18# create pca request.
19echo creating $CAbits bit PCA cert request 19echo creating $CAbits bit PCA cert request
diff --git a/src/lib/libssl/src/util/mkdef.pl b/src/lib/libssl/src/util/mkdef.pl
index adfd447dd3..cdd2164c4e 100644
--- a/src/lib/libssl/src/util/mkdef.pl
+++ b/src/lib/libssl/src/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/libssl/src/util/mkerr.pl b/src/lib/libssl/src/util/mkerr.pl
index 4105047b21..1b2915c767 100644
--- a/src/lib/libssl/src/util/mkerr.pl
+++ b/src/lib/libssl/src/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/libssl/src/util/pl/BC-32.pl b/src/lib/libssl/src/util/pl/BC-32.pl
index bd7a9d9301..e83b336190 100644
--- a/src/lib/libssl/src/util/pl/BC-32.pl
+++ b/src/lib/libssl/src/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/libssl/src/util/pl/Mingw32.pl b/src/lib/libssl/src/util/pl/Mingw32.pl
index 45ab685974..043a3a53ee 100644
--- a/src/lib/libssl/src/util/pl/Mingw32.pl
+++ b/src/lib/libssl/src/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/libssl/src/util/pl/VC-32.pl b/src/lib/libssl/src/util/pl/VC-32.pl
index d6e3a11530..285990c589 100644
--- a/src/lib/libssl/src/util/pl/VC-32.pl
+++ b/src/lib/libssl/src/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/libssl/src/util/pl/VC-CE.pl b/src/lib/libssl/src/util/pl/VC-CE.pl
new file mode 100644
index 0000000000..1805ef9d97
--- /dev/null
+++ b/src/lib/libssl/src/util/pl/VC-CE.pl
@@ -0,0 +1,111 @@
1#!/usr/local/bin/perl
2# VC-CE.pl - the file for eMbedded Visual C++ 3.0 for windows CE, static libraries
3#
4
5$ssl= "ssleay32";
6$crypto="libeay32";
7$RSAref="RSAref32";
8
9$o='\\';
10$cp='copy nul+'; # Timestamps get stuffed otherwise
11$rm='del';
12
13# C compiler stuff
14$cc='$(CC)';
15$cflags=' /W3 /WX /Ox /O2 /Ob2 /Gs0 /GF /Gy /nologo $(WCETARGETDEFS) -DUNICODE -D_UNICODE -DWIN32 -DWIN32_LEAN_AND_MEAN -DL_ENDIAN -DDSO_WIN32 -DNO_CHMOD -I$(WCECOMPAT)/include';
16$lflags='/nologo /subsystem:windowsce,$(WCELDVERSION) /machine:$(WCELDMACHINE) /opt:ref';
17$mlflags='';
18
19$out_def='out32_$(TARGETCPU)';
20$tmp_def='tmp32_$(TARGETCPU)';
21$inc_def="inc32";
22
23if ($debug)
24 {
25 $cflags=" /MDd /W3 /WX /Zi /Yd /Od /nologo -DWIN32 -D_DEBUG -DL_ENDIAN -DWIN32_LEAN_AND_MEAN -DDEBUG -DDSO_WIN32";
26 $lflags.=" /debug";
27 $mlflags.=' /debug';
28 }
29
30$obj='.obj';
31$ofile="/Fo";
32
33# EXE linking stuff
34$link="link";
35$efile="/out:";
36$exep='.exe';
37if ($no_sock)
38 { $ex_libs=""; }
39else { $ex_libs='winsock.lib $(WCECOMPAT)/lib/wcecompatex.lib $(WCELDFLAGS)'; }
40
41# static library stuff
42$mklib='lib';
43$ranlib='';
44$plib="";
45$libp=".lib";
46$shlibp=($shlib)?".dll":".lib";
47$lfile='/out:';
48
49$shlib_ex_obj="";
50#$app_ex_obj="setargv.obj";
51$app_ex_obj="";
52
53$bn_asm_obj='';
54$bn_asm_src='';
55$des_enc_obj='';
56$des_enc_src='';
57$bf_enc_obj='';
58$bf_enc_src='';
59
60if ($shlib)
61 {
62 $mlflags.=" $lflags /dll";
63# $cflags =~ s| /MD| /MT|;
64 $lib_cflag=" -D_WINDLL -D_DLL";
65 $out_def='out32dll_$(TARGETCPU)';
66 $tmp_def='tmp32dll_$(TARGETCPU)';
67 }
68
69$cflags.=" /Fd$out_def";
70
71sub do_lib_rule
72 {
73 local($objs,$target,$name,$shlib)=@_;
74 local($ret,$Name);
75
76 $taget =~ s/\//$o/g if $o ne '/';
77 ($Name=$name) =~ tr/a-z/A-Z/;
78
79# $target="\$(LIB_D)$o$target";
80 $ret.="$target: $objs\n";
81 if (!$shlib)
82 {
83# $ret.="\t\$(RM) \$(O_$Name)\n";
84 $ex =' ';
85 $ret.="\t\$(MKLIB) $lfile$target @<<\n $objs $ex\n<<\n";
86 }
87 else
88 {
89 local($ex)=($target =~ /O_SSL/)?' $(L_CRYPTO)':'';
90# $ex.=' winsock.lib coredll.lib $(WCECOMPAT)/lib/wcecompatex.lib';
91 $ex.=' winsock.lib $(WCECOMPAT)/lib/wcecompatex.lib';
92 $ret.="\t\$(LINK) \$(MLFLAGS) $efile$target /def:ms/${Name}.def @<<\n \$(SHLIB_EX_OBJ) $objs $ex\n<<\n";
93 }
94 $ret.="\n";
95 return($ret);
96 }
97
98sub do_link_rule
99 {
100 local($target,$files,$dep_libs,$libs)=@_;
101 local($ret,$_);
102
103 $file =~ s/\//$o/g if $o ne '/';
104 $n=&bname($targer);
105 $ret.="$target: $files $dep_libs\n";
106 $ret.=" \$(LINK) \$(LFLAGS) $efile$target @<<\n";
107 $ret.=" \$(APP_EX_OBJ) $files $libs\n<<\n\n";
108 return($ret);
109 }
110
1111;
diff --git a/src/lib/libssl/src/util/ssleay.num b/src/lib/libssl/src/util/ssleay.num
index fdea47205d..46e38a131f 100644
--- a/src/lib/libssl/src/util/ssleay.num
+++ b/src/lib/libssl/src/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