summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libcrypto')
-rw-r--r--src/lib/libcrypto/Makefile.ssl218
-rw-r--r--src/lib/libcrypto/aes/Makefile.ssl103
-rw-r--r--src/lib/libcrypto/aes/aes.h28
-rw-r--r--src/lib/libcrypto/aes/aes_cbc.c82
-rw-r--r--src/lib/libcrypto/aes/aes_cfb.c160
-rw-r--r--src/lib/libcrypto/aes/aes_core.c209
-rw-r--r--src/lib/libcrypto/aes/aes_ctr.c90
-rw-r--r--src/lib/libcrypto/aes/aes_ofb.c94
-rw-r--r--src/lib/libcrypto/aes/asm/aes-586.pl2403
-rwxr-xr-xsrc/lib/libcrypto/aes/asm/aes-x86_64.pl2
-rw-r--r--src/lib/libcrypto/asn1/Makefile.ssl1152
-rw-r--r--src/lib/libcrypto/asn1/a_bitstr.c23
-rw-r--r--src/lib/libcrypto/asn1/a_dup.c2
-rw-r--r--src/lib/libcrypto/asn1/a_gentm.c23
-rw-r--r--src/lib/libcrypto/asn1/a_hdr.c119
-rw-r--r--src/lib/libcrypto/asn1/a_int.c10
-rw-r--r--src/lib/libcrypto/asn1/a_mbstr.c2
-rw-r--r--src/lib/libcrypto/asn1/a_meth.c84
-rw-r--r--src/lib/libcrypto/asn1/a_object.c35
-rw-r--r--src/lib/libcrypto/asn1/a_octet.c4
-rw-r--r--src/lib/libcrypto/asn1/a_set.c45
-rw-r--r--src/lib/libcrypto/asn1/a_sign.c78
-rw-r--r--src/lib/libcrypto/asn1/a_strnid.c18
-rw-r--r--src/lib/libcrypto/asn1/a_time.c40
-rw-r--r--src/lib/libcrypto/asn1/a_type.c53
-rw-r--r--src/lib/libcrypto/asn1/a_utctm.c21
-rw-r--r--src/lib/libcrypto/asn1/a_verify.c31
-rw-r--r--src/lib/libcrypto/asn1/asn1.h247
-rw-r--r--src/lib/libcrypto/asn1/asn1_err.c22
-rw-r--r--src/lib/libcrypto/asn1/asn1_lib.c36
-rw-r--r--src/lib/libcrypto/asn1/asn1_mac.h7
-rw-r--r--src/lib/libcrypto/asn1/asn1_par.c17
-rw-r--r--src/lib/libcrypto/asn1/asn1t.h71
-rw-r--r--src/lib/libcrypto/asn1/asn_mime.c88
-rw-r--r--src/lib/libcrypto/asn1/asn_pack.c8
-rw-r--r--src/lib/libcrypto/asn1/charmap.h2
-rw-r--r--src/lib/libcrypto/asn1/d2i_pr.c97
-rw-r--r--src/lib/libcrypto/asn1/d2i_pu.c10
-rw-r--r--src/lib/libcrypto/asn1/f.c80
-rw-r--r--src/lib/libcrypto/asn1/i2d_pr.c39
-rw-r--r--src/lib/libcrypto/asn1/nsseq.c5
-rw-r--r--src/lib/libcrypto/asn1/p5_pbe.c105
-rw-r--r--src/lib/libcrypto/asn1/p5_pbev2.c54
-rw-r--r--src/lib/libcrypto/asn1/p8_key.c131
-rw-r--r--src/lib/libcrypto/asn1/p8_pkey.c75
-rw-r--r--src/lib/libcrypto/asn1/t_pkey.c729
-rw-r--r--src/lib/libcrypto/asn1/t_req.c28
-rw-r--r--src/lib/libcrypto/asn1/t_spki.c31
-rw-r--r--src/lib/libcrypto/asn1/t_x509.c64
-rw-r--r--src/lib/libcrypto/asn1/tasn_dec.c24
-rw-r--r--src/lib/libcrypto/asn1/tasn_enc.c11
-rw-r--r--src/lib/libcrypto/asn1/tasn_fre.c8
-rw-r--r--src/lib/libcrypto/asn1/tasn_new.c23
-rw-r--r--src/lib/libcrypto/asn1/tasn_prn.c625
-rw-r--r--src/lib/libcrypto/asn1/tasn_typ.c11
-rw-r--r--src/lib/libcrypto/asn1/x_cinf.c201
-rw-r--r--src/lib/libcrypto/asn1/x_crl.c391
-rw-r--r--src/lib/libcrypto/asn1/x_long.c10
-rw-r--r--src/lib/libcrypto/asn1/x_name.c298
-rw-r--r--src/lib/libcrypto/asn1/x_pubkey.c304
-rw-r--r--src/lib/libcrypto/asn1/x_req.c3
-rw-r--r--src/lib/libcrypto/asn1/x_x509.c20
-rw-r--r--src/lib/libcrypto/bf/Makefile.ssl115
-rw-r--r--src/lib/libcrypto/bf/asm/bf-586.pl3
-rw-r--r--src/lib/libcrypto/bf/bf_skey.c7
-rw-r--r--src/lib/libcrypto/bf/blowfish.h6
-rw-r--r--src/lib/libcrypto/bio/Makefile.ssl216
-rw-r--r--src/lib/libcrypto/bio/b_print.c9
-rw-r--r--src/lib/libcrypto/bio/b_sock.c242
-rw-r--r--src/lib/libcrypto/bio/bio.h64
-rw-r--r--src/lib/libcrypto/bio/bio_cb.c24
-rw-r--r--src/lib/libcrypto/bio/bio_err.c2
-rw-r--r--src/lib/libcrypto/bio/bio_lib.c4
-rw-r--r--src/lib/libcrypto/bio/bss_acpt.c8
-rw-r--r--src/lib/libcrypto/bio/bss_dgram.c380
-rw-r--r--src/lib/libcrypto/bio/bss_fd.c27
-rw-r--r--src/lib/libcrypto/bio/bss_file.c67
-rw-r--r--src/lib/libcrypto/bio/bss_log.c55
-rw-r--r--src/lib/libcrypto/bio/bss_mem.c18
-rw-r--r--src/lib/libcrypto/bio/bss_sock.c13
-rw-r--r--src/lib/libcrypto/bn/Makefile79
-rw-r--r--src/lib/libcrypto/bn/Makefile.ssl326
-rw-r--r--src/lib/libcrypto/bn/asm/alpha.s3199
-rw-r--r--src/lib/libcrypto/bn/asm/alpha.s.works533
-rw-r--r--src/lib/libcrypto/bn/asm/alpha.works/add.pl119
-rw-r--r--src/lib/libcrypto/bn/asm/alpha.works/div.pl144
-rw-r--r--src/lib/libcrypto/bn/asm/alpha.works/mul.pl116
-rw-r--r--src/lib/libcrypto/bn/asm/alpha.works/mul_add.pl120
-rw-r--r--src/lib/libcrypto/bn/asm/alpha.works/mul_c4.pl213
-rw-r--r--src/lib/libcrypto/bn/asm/alpha.works/mul_c4.works.pl98
-rw-r--r--src/lib/libcrypto/bn/asm/alpha.works/mul_c8.pl177
-rw-r--r--src/lib/libcrypto/bn/asm/alpha.works/sqr.pl113
-rw-r--r--src/lib/libcrypto/bn/asm/alpha.works/sqr_c4.pl109
-rw-r--r--src/lib/libcrypto/bn/asm/alpha.works/sqr_c8.pl132
-rw-r--r--src/lib/libcrypto/bn/asm/alpha.works/sub.pl108
-rw-r--r--src/lib/libcrypto/bn/asm/alpha/add.pl118
-rw-r--r--src/lib/libcrypto/bn/asm/alpha/div.pl144
-rw-r--r--src/lib/libcrypto/bn/asm/alpha/mul.pl104
-rw-r--r--src/lib/libcrypto/bn/asm/alpha/mul_add.pl123
-rw-r--r--src/lib/libcrypto/bn/asm/alpha/mul_c4.pl215
-rw-r--r--src/lib/libcrypto/bn/asm/alpha/mul_c4.works.pl98
-rw-r--r--src/lib/libcrypto/bn/asm/alpha/mul_c8.pl177
-rw-r--r--src/lib/libcrypto/bn/asm/alpha/sqr.pl113
-rw-r--r--src/lib/libcrypto/bn/asm/alpha/sqr_c4.pl109
-rw-r--r--src/lib/libcrypto/bn/asm/alpha/sqr_c8.pl132
-rw-r--r--src/lib/libcrypto/bn/asm/alpha/sub.pl108
-rw-r--r--src/lib/libcrypto/bn/asm/bn-586.pl203
-rw-r--r--src/lib/libcrypto/bn/asm/bn-alpha.pl571
-rw-r--r--src/lib/libcrypto/bn/asm/ca.pl33
-rw-r--r--src/lib/libcrypto/bn/asm/co-586.pl3
-rw-r--r--src/lib/libcrypto/bn/asm/co-alpha.pl116
-rw-r--r--src/lib/libcrypto/bn/asm/mips1.s539
-rw-r--r--src/lib/libcrypto/bn/asm/mo-586.pl603
-rw-r--r--src/lib/libcrypto/bn/asm/pa-risc.s710
-rw-r--r--src/lib/libcrypto/bn/asm/r3000.s646
-rw-r--r--src/lib/libcrypto/bn/asm/sparcv8plus.S15
-rw-r--r--src/lib/libcrypto/bn/bn.h181
-rw-r--r--src/lib/libcrypto/bn/bn_asm.c322
-rw-r--r--src/lib/libcrypto/bn/bn_blind.c17
-rw-r--r--src/lib/libcrypto/bn/bn_ctx.c6
-rw-r--r--src/lib/libcrypto/bn/bn_div.c13
-rw-r--r--src/lib/libcrypto/bn/bn_exp.c3
-rw-r--r--src/lib/libcrypto/bn/bn_gf2m.c142
-rw-r--r--src/lib/libcrypto/bn/bn_lcl.h3
-rw-r--r--src/lib/libcrypto/bn/bn_lib.c29
-rw-r--r--src/lib/libcrypto/bn/bn_mont.c269
-rw-r--r--src/lib/libcrypto/bn/bn_mul.c10
-rw-r--r--src/lib/libcrypto/bn/bn_opt.c87
-rw-r--r--src/lib/libcrypto/bn/bn_print.c21
-rw-r--r--src/lib/libcrypto/bn/bn_x931p.c272
-rw-r--r--src/lib/libcrypto/bn/bntest.c38
-rw-r--r--src/lib/libcrypto/bn/exptest.c4
-rw-r--r--src/lib/libcrypto/buffer/Makefile.ssl94
-rw-r--r--src/lib/libcrypto/buffer/buf_err.c2
-rw-r--r--src/lib/libcrypto/buffer/buf_str.c116
-rw-r--r--src/lib/libcrypto/buffer/buffer.c89
-rw-r--r--src/lib/libcrypto/buffer/buffer.h9
-rw-r--r--src/lib/libcrypto/cast/Makefile.ssl120
-rw-r--r--src/lib/libcrypto/cast/asm/cast-586.pl3
-rw-r--r--src/lib/libcrypto/cast/c_cfb64.c3
-rw-r--r--src/lib/libcrypto/cast/c_ecb.c3
-rw-r--r--src/lib/libcrypto/cast/c_enc.c13
-rw-r--r--src/lib/libcrypto/cast/c_ofb64.c3
-rw-r--r--src/lib/libcrypto/cast/c_skey.c7
-rw-r--r--src/lib/libcrypto/cast/cast.h18
-rw-r--r--src/lib/libcrypto/cms/cms_smime.c22
-rw-r--r--src/lib/libcrypto/comp/Makefile.ssl114
-rw-r--r--src/lib/libcrypto/comp/c_zlib.c1
-rw-r--r--src/lib/libcrypto/comp/comp_err.c2
-rw-r--r--src/lib/libcrypto/conf/Makefile.ssl183
-rw-r--r--src/lib/libcrypto/conf/README47
-rw-r--r--src/lib/libcrypto/conf/conf.h35
-rw-r--r--src/lib/libcrypto/conf/conf_api.c134
-rw-r--r--src/lib/libcrypto/conf/conf_def.c11
-rw-r--r--src/lib/libcrypto/conf/conf_err.c4
-rw-r--r--src/lib/libcrypto/conf/conf_lib.c30
-rw-r--r--src/lib/libcrypto/conf/conf_mall.c2
-rw-r--r--src/lib/libcrypto/conf/conf_mod.c8
-rw-r--r--src/lib/libcrypto/cpt_err.c2
-rw-r--r--src/lib/libcrypto/cryptlib.c508
-rw-r--r--src/lib/libcrypto/crypto-lib.com184
-rw-r--r--src/lib/libcrypto/crypto.h104
-rw-r--r--src/lib/libcrypto/des/Makefile.ssl316
-rw-r--r--src/lib/libcrypto/des/asm/crypt586.pl5
-rw-r--r--src/lib/libcrypto/des/asm/des-586.pl282
-rw-r--r--src/lib/libcrypto/des/asm/des686.pl230
-rw-r--r--src/lib/libcrypto/des/des-lib.com66
-rw-r--r--src/lib/libcrypto/des/des_enc.c21
-rw-r--r--src/lib/libcrypto/des/des_lib.c106
-rw-r--r--src/lib/libcrypto/des/des_locl.h6
-rw-r--r--src/lib/libcrypto/des/ecb_enc.c48
-rw-r--r--src/lib/libcrypto/des/enc_read.c12
-rw-r--r--src/lib/libcrypto/des/enc_writ.c4
-rw-r--r--src/lib/libcrypto/des/fcrypt_b.c4
-rw-r--r--src/lib/libcrypto/des/rpc_des.h4
-rw-r--r--src/lib/libcrypto/des/set_key.c13
-rw-r--r--src/lib/libcrypto/des/times/aix.cc4
-rw-r--r--src/lib/libcrypto/des/xcbc_enc.c2
-rw-r--r--src/lib/libcrypto/dh/Makefile63
-rw-r--r--src/lib/libcrypto/dh/Makefile.ssl133
-rw-r--r--src/lib/libcrypto/dh/dh.h41
-rw-r--r--src/lib/libcrypto/dh/dh_asn1.c10
-rw-r--r--src/lib/libcrypto/dh/dh_check.c8
-rw-r--r--src/lib/libcrypto/dh/dh_err.c21
-rw-r--r--src/lib/libcrypto/dh/dh_gen.c4
-rw-r--r--src/lib/libcrypto/dh/dh_key.c4
-rw-r--r--src/lib/libcrypto/doc/DSA_get_ex_new_index.pod2
-rw-r--r--src/lib/libcrypto/doc/EVP_DigestInit.pod23
-rw-r--r--src/lib/libcrypto/doc/EVP_SignInit.pod9
-rw-r--r--src/lib/libcrypto/doc/EVP_VerifyInit.pod9
-rw-r--r--src/lib/libcrypto/doc/d2i_RSAPublicKey.pod8
-rw-r--r--src/lib/libcrypto/doc/evp.pod22
-rw-r--r--src/lib/libcrypto/dsa/Makefile133
-rw-r--r--src/lib/libcrypto/dsa/Makefile.ssl171
-rw-r--r--src/lib/libcrypto/dsa/dsa.h69
-rw-r--r--src/lib/libcrypto/dsa/dsa_asn1.c96
-rw-r--r--src/lib/libcrypto/dsa/dsa_err.c26
-rw-r--r--src/lib/libcrypto/dsa/dsa_gen.c124
-rw-r--r--src/lib/libcrypto/dsa/dsa_key.c4
-rw-r--r--src/lib/libcrypto/dsa/dsa_lib.c49
-rw-r--r--src/lib/libcrypto/dsa/dsa_ossl.c48
-rw-r--r--src/lib/libcrypto/dsa/dsa_sign.c35
-rw-r--r--src/lib/libcrypto/dsa/dsa_utl.c95
-rw-r--r--src/lib/libcrypto/dsa/dsa_vrf.c37
-rw-r--r--src/lib/libcrypto/dsa/dsatest.c3
-rw-r--r--src/lib/libcrypto/dso/Makefile.ssl142
-rw-r--r--src/lib/libcrypto/dso/dso.h43
-rw-r--r--src/lib/libcrypto/dso/dso_dl.c56
-rw-r--r--src/lib/libcrypto/dso/dso_dlfcn.c157
-rw-r--r--src/lib/libcrypto/dso/dso_err.c14
-rw-r--r--src/lib/libcrypto/dso/dso_lib.c35
-rw-r--r--src/lib/libcrypto/dso/dso_null.c4
-rw-r--r--src/lib/libcrypto/dso/dso_openssl.c2
-rw-r--r--src/lib/libcrypto/dso/dso_vms.c12
-rw-r--r--src/lib/libcrypto/dso/dso_win32.c228
-rw-r--r--src/lib/libcrypto/dyn_lck.c428
-rw-r--r--src/lib/libcrypto/ec/Makefile.ssl128
-rw-r--r--src/lib/libcrypto/ec/ec.h814
-rw-r--r--src/lib/libcrypto/ec/ec2_smpl.c112
-rw-r--r--src/lib/libcrypto/ec/ec2_smpt.c74
-rw-r--r--src/lib/libcrypto/ec/ec_err.c21
-rw-r--r--src/lib/libcrypto/ec/ec_lcl.h13
-rw-r--r--src/lib/libcrypto/ec/ec_lib.c4
-rw-r--r--src/lib/libcrypto/ec/ec_mult.c22
-rw-r--r--src/lib/libcrypto/ec/ecp_nist.c26
-rw-r--r--src/lib/libcrypto/ec/ecp_recp.c133
-rw-r--r--src/lib/libcrypto/ec/ectest.c14
-rw-r--r--src/lib/libcrypto/ecdh/Makefile33
-rw-r--r--src/lib/libcrypto/ecdsa/Makefile46
-rw-r--r--src/lib/libcrypto/engine/Makefile297
-rw-r--r--src/lib/libcrypto/engine/Makefile.ssl538
-rw-r--r--src/lib/libcrypto/engine/eng_all.c19
-rw-r--r--src/lib/libcrypto/engine/eng_cnf.c17
-rw-r--r--src/lib/libcrypto/engine/eng_cryptodev.c2
-rw-r--r--src/lib/libcrypto/engine/eng_ctrl.c8
-rw-r--r--src/lib/libcrypto/engine/eng_dyn.c14
-rw-r--r--src/lib/libcrypto/engine/eng_err.c6
-rw-r--r--src/lib/libcrypto/engine/eng_fat.c14
-rw-r--r--src/lib/libcrypto/engine/eng_int.h12
-rw-r--r--src/lib/libcrypto/engine/eng_lib.c3
-rw-r--r--src/lib/libcrypto/engine/eng_list.c2
-rw-r--r--src/lib/libcrypto/engine/eng_openssl.c2
-rw-r--r--src/lib/libcrypto/engine/eng_table.c72
-rw-r--r--src/lib/libcrypto/engine/engine.h55
-rw-r--r--src/lib/libcrypto/engine/enginetest.c2
-rw-r--r--src/lib/libcrypto/engine/hw.ec8
-rw-r--r--src/lib/libcrypto/engine/hw_4758_cca.c969
-rw-r--r--src/lib/libcrypto/engine/hw_4758_cca_err.c149
-rw-r--r--src/lib/libcrypto/engine/hw_4758_cca_err.h93
-rw-r--r--src/lib/libcrypto/engine/hw_aep.c1120
-rw-r--r--src/lib/libcrypto/engine/hw_aep_err.c157
-rw-r--r--src/lib/libcrypto/engine/hw_aep_err.h101
-rw-r--r--src/lib/libcrypto/engine/hw_atalla.c595
-rw-r--r--src/lib/libcrypto/engine/hw_atalla_err.c145
-rw-r--r--src/lib/libcrypto/engine/hw_atalla_err.h89
-rw-r--r--src/lib/libcrypto/engine/hw_cswift.c1109
-rw-r--r--src/lib/libcrypto/engine/hw_cswift_err.c149
-rw-r--r--src/lib/libcrypto/engine/hw_cswift_err.h93
-rw-r--r--src/lib/libcrypto/engine/hw_ncipher.c1388
-rw-r--r--src/lib/libcrypto/engine/hw_ncipher_err.c157
-rw-r--r--src/lib/libcrypto/engine/hw_ncipher_err.h101
-rw-r--r--src/lib/libcrypto/engine/hw_nuron.c418
-rw-r--r--src/lib/libcrypto/engine/hw_nuron_err.c142
-rw-r--r--src/lib/libcrypto/engine/hw_nuron_err.h86
-rw-r--r--src/lib/libcrypto/engine/hw_sureware.c1039
-rw-r--r--src/lib/libcrypto/engine/hw_sureware_err.c150
-rw-r--r--src/lib/libcrypto/engine/hw_sureware_err.h94
-rw-r--r--src/lib/libcrypto/engine/hw_ubsec.c1061
-rw-r--r--src/lib/libcrypto/engine/hw_ubsec_err.c151
-rw-r--r--src/lib/libcrypto/engine/hw_ubsec_err.h95
-rw-r--r--src/lib/libcrypto/engine/vendor_defns/aep.h178
-rw-r--r--src/lib/libcrypto/engine/vendor_defns/atalla.h48
-rw-r--r--src/lib/libcrypto/engine/vendor_defns/cswift.h234
-rw-r--r--src/lib/libcrypto/engine/vendor_defns/hw_4758_cca.h149
-rw-r--r--src/lib/libcrypto/engine/vendor_defns/hw_ubsec.h100
-rw-r--r--src/lib/libcrypto/engine/vendor_defns/hwcryptohook.h486
-rw-r--r--src/lib/libcrypto/engine/vendor_defns/sureware.h239
-rw-r--r--src/lib/libcrypto/err/Makefile.ssl119
-rw-r--r--src/lib/libcrypto/err/err.c789
-rw-r--r--src/lib/libcrypto/err/err.h77
-rw-r--r--src/lib/libcrypto/err/err_all.c13
-rw-r--r--src/lib/libcrypto/err/err_bio.c75
-rw-r--r--src/lib/libcrypto/err/err_def.c665
-rw-r--r--src/lib/libcrypto/err/err_prn.c77
-rw-r--r--src/lib/libcrypto/err/err_str.c295
-rw-r--r--src/lib/libcrypto/err/openssl.ec9
-rw-r--r--src/lib/libcrypto/evp/Makefile782
-rw-r--r--src/lib/libcrypto/evp/Makefile.ssl1059
-rw-r--r--src/lib/libcrypto/evp/bio_b64.c77
-rw-r--r--src/lib/libcrypto/evp/bio_enc.c6
-rw-r--r--src/lib/libcrypto/evp/bio_md.c16
-rw-r--r--src/lib/libcrypto/evp/c_all.c2
-rw-r--r--src/lib/libcrypto/evp/c_allc.c5
-rw-r--r--src/lib/libcrypto/evp/c_alld.c8
-rw-r--r--src/lib/libcrypto/evp/dig_eng.c180
-rw-r--r--src/lib/libcrypto/evp/digest.c211
-rw-r--r--src/lib/libcrypto/evp/e_aes.c35
-rw-r--r--src/lib/libcrypto/evp/e_des.c91
-rw-r--r--src/lib/libcrypto/evp/e_des3.c95
-rw-r--r--src/lib/libcrypto/evp/e_idea.c2
-rw-r--r--src/lib/libcrypto/evp/e_null.c8
-rw-r--r--src/lib/libcrypto/evp/e_rc2.c5
-rw-r--r--src/lib/libcrypto/evp/e_rc4.c5
-rw-r--r--src/lib/libcrypto/evp/e_xcbc_d.c19
-rw-r--r--src/lib/libcrypto/evp/enc_min.c390
-rw-r--r--src/lib/libcrypto/evp/encode.c4
-rw-r--r--src/lib/libcrypto/evp/evp.h539
-rw-r--r--src/lib/libcrypto/evp/evp_cnf.c125
-rw-r--r--src/lib/libcrypto/evp/evp_enc.c267
-rw-r--r--src/lib/libcrypto/evp/evp_err.c60
-rw-r--r--src/lib/libcrypto/evp/evp_key.c9
-rw-r--r--src/lib/libcrypto/evp/evp_lib.c44
-rw-r--r--src/lib/libcrypto/evp/evp_locl.h155
-rw-r--r--src/lib/libcrypto/evp/evp_pbe.c266
-rw-r--r--src/lib/libcrypto/evp/evp_pkey.c646
-rw-r--r--src/lib/libcrypto/evp/evp_test.c6
-rw-r--r--src/lib/libcrypto/evp/m_dss.c2
-rw-r--r--src/lib/libcrypto/evp/m_dss1.c5
-rw-r--r--src/lib/libcrypto/evp/m_md2.c1
-rw-r--r--src/lib/libcrypto/evp/m_md4.c1
-rw-r--r--src/lib/libcrypto/evp/m_md5.c1
-rw-r--r--src/lib/libcrypto/evp/m_mdc2.c3
-rw-r--r--src/lib/libcrypto/evp/m_sha.c1
-rw-r--r--src/lib/libcrypto/evp/m_sha1.c17
-rw-r--r--src/lib/libcrypto/evp/names.c87
-rw-r--r--src/lib/libcrypto/evp/p5_crpt.c39
-rw-r--r--src/lib/libcrypto/evp/p5_crpt2.c86
-rw-r--r--src/lib/libcrypto/evp/p_dec.c4
-rw-r--r--src/lib/libcrypto/evp/p_enc.c4
-rw-r--r--src/lib/libcrypto/evp/p_lib.c394
-rw-r--r--src/lib/libcrypto/evp/p_open.c2
-rw-r--r--src/lib/libcrypto/evp/p_seal.c2
-rw-r--r--src/lib/libcrypto/evp/p_sign.c47
-rw-r--r--src/lib/libcrypto/evp/p_verify.c44
-rw-r--r--src/lib/libcrypto/ex_data.c42
-rw-r--r--src/lib/libcrypto/fips_err.c7
-rw-r--r--src/lib/libcrypto/fips_err.h137
-rw-r--r--src/lib/libcrypto/hmac/Makefile.ssl101
-rw-r--r--src/lib/libcrypto/hmac/hmac.c90
-rw-r--r--src/lib/libcrypto/hmac/hmac.h9
-rw-r--r--src/lib/libcrypto/idea/Makefile.ssl91
-rw-r--r--src/lib/libcrypto/idea/idea.h5
-rw-r--r--src/lib/libcrypto/install.com70
-rw-r--r--src/lib/libcrypto/krb5/Makefile.ssl90
-rw-r--r--src/lib/libcrypto/lhash/Makefile.ssl93
-rw-r--r--src/lib/libcrypto/lhash/lh_stats.c12
-rw-r--r--src/lib/libcrypto/lhash/lhash.c41
-rw-r--r--src/lib/libcrypto/lhash/lhash.h131
-rw-r--r--src/lib/libcrypto/md2/Makefile.ssl93
-rw-r--r--src/lib/libcrypto/md2/md2.h3
-rw-r--r--src/lib/libcrypto/md2/md2_dgst.c9
-rw-r--r--src/lib/libcrypto/md32_common.h12
-rw-r--r--src/lib/libcrypto/md4/Makefile.ssl91
-rw-r--r--src/lib/libcrypto/md4/md4.h5
-rw-r--r--src/lib/libcrypto/md4/md4_dgst.c11
-rw-r--r--src/lib/libcrypto/md5/Makefile.ssl127
-rw-r--r--src/lib/libcrypto/md5/asm/md5-586.pl3
-rw-r--r--src/lib/libcrypto/md5/asm/md5-sparcv9.S1031
-rw-r--r--src/lib/libcrypto/md5/md5.h5
-rw-r--r--src/lib/libcrypto/md5/md5_dgst.c11
-rw-r--r--src/lib/libcrypto/md5/md5_locl.h2
-rw-r--r--src/lib/libcrypto/mdc2/Makefile2
-rw-r--r--src/lib/libcrypto/mdc2/Makefile.ssl98
-rw-r--r--src/lib/libcrypto/mdc2/mdc2.h4
-rw-r--r--src/lib/libcrypto/mem.c65
-rw-r--r--src/lib/libcrypto/mem_dbg.c258
-rw-r--r--src/lib/libcrypto/o_init.c86
-rw-r--r--src/lib/libcrypto/o_time.c153
-rw-r--r--src/lib/libcrypto/o_time.h1
-rw-r--r--src/lib/libcrypto/objects/Makefile.ssl123
-rw-r--r--src/lib/libcrypto/objects/o_names.c47
-rw-r--r--src/lib/libcrypto/objects/obj_dat.c180
-rw-r--r--src/lib/libcrypto/objects/obj_dat.pl20
-rw-r--r--src/lib/libcrypto/objects/obj_err.c2
-rw-r--r--src/lib/libcrypto/objects/obj_lib.c35
-rw-r--r--src/lib/libcrypto/objects/obj_mac.num34
-rw-r--r--src/lib/libcrypto/objects/objects.h97
-rw-r--r--src/lib/libcrypto/objects/objects.pl3
-rw-r--r--src/lib/libcrypto/objects/objects.txt44
-rw-r--r--src/lib/libcrypto/ocsp/Makefile.ssl293
-rw-r--r--src/lib/libcrypto/ocsp/ocsp.h22
-rw-r--r--src/lib/libcrypto/ocsp/ocsp_cl.c1
-rw-r--r--src/lib/libcrypto/ocsp/ocsp_err.c3
-rw-r--r--src/lib/libcrypto/ocsp/ocsp_ext.c47
-rw-r--r--src/lib/libcrypto/ocsp/ocsp_ht.c56
-rw-r--r--src/lib/libcrypto/ocsp/ocsp_lib.c3
-rw-r--r--src/lib/libcrypto/ocsp/ocsp_prn.c23
-rw-r--r--src/lib/libcrypto/ocsp/ocsp_vfy.c4
-rw-r--r--src/lib/libcrypto/opensslconf.h.in20
-rw-r--r--src/lib/libcrypto/opensslv.h10
-rw-r--r--src/lib/libcrypto/ossl_typ.h21
-rw-r--r--src/lib/libcrypto/pem/Makefile.ssl336
-rw-r--r--src/lib/libcrypto/pem/pem.h255
-rw-r--r--src/lib/libcrypto/pem/pem_all.c194
-rw-r--r--src/lib/libcrypto/pem/pem_err.c28
-rw-r--r--src/lib/libcrypto/pem/pem_info.c40
-rw-r--r--src/lib/libcrypto/pem/pem_lib.c100
-rw-r--r--src/lib/libcrypto/pem/pem_pkey.c109
-rw-r--r--src/lib/libcrypto/pem/pem_seal.c2
-rw-r--r--src/lib/libcrypto/pem/pem_x509.c1
-rw-r--r--src/lib/libcrypto/pem/pem_xaux.c1
-rw-r--r--src/lib/libcrypto/perlasm/alpha.pl434
-rwxr-xr-xsrc/lib/libcrypto/perlasm/x86_64-xlate.pl625
-rw-r--r--src/lib/libcrypto/perlasm/x86asm.pl333
-rw-r--r--src/lib/libcrypto/perlasm/x86gas.pl24
-rw-r--r--src/lib/libcrypto/perlasm/x86ms.pl472
-rw-r--r--src/lib/libcrypto/perlasm/x86nasm.pl559
-rw-r--r--src/lib/libcrypto/perlasm/x86unix.pl808
-rw-r--r--src/lib/libcrypto/pkcs12/Makefile.ssl417
-rw-r--r--src/lib/libcrypto/pkcs12/p12_add.c20
-rw-r--r--src/lib/libcrypto/pkcs12/p12_attr.c2
-rw-r--r--src/lib/libcrypto/pkcs12/p12_crpt.c20
-rw-r--r--src/lib/libcrypto/pkcs12/p12_crt.c11
-rw-r--r--src/lib/libcrypto/pkcs12/p12_key.c7
-rw-r--r--src/lib/libcrypto/pkcs12/p12_kiss.c163
-rw-r--r--src/lib/libcrypto/pkcs12/p12_mutl.c8
-rw-r--r--src/lib/libcrypto/pkcs12/p12_npas.c17
-rw-r--r--src/lib/libcrypto/pkcs12/p12_utl.c4
-rw-r--r--src/lib/libcrypto/pkcs12/pk12err.c2
-rw-r--r--src/lib/libcrypto/pkcs12/pkcs12.h6
-rw-r--r--src/lib/libcrypto/pkcs7/Makefile.ssl243
-rw-r--r--src/lib/libcrypto/pkcs7/pk7_asn1.c43
-rw-r--r--src/lib/libcrypto/pkcs7/pk7_attr.c66
-rw-r--r--src/lib/libcrypto/pkcs7/pk7_doit.c486
-rw-r--r--src/lib/libcrypto/pkcs7/pk7_lib.c192
-rw-r--r--src/lib/libcrypto/pkcs7/pk7_mime.c669
-rw-r--r--src/lib/libcrypto/pkcs7/pk7_smime.c263
-rw-r--r--src/lib/libcrypto/pkcs7/pkcs7.h59
-rw-r--r--src/lib/libcrypto/pkcs7/pkcs7err.c22
-rw-r--r--src/lib/libcrypto/pqueue/pq_compat.h152
-rw-r--r--src/lib/libcrypto/rand/Makefile71
-rw-r--r--src/lib/libcrypto/rand/Makefile.ssl196
-rw-r--r--src/lib/libcrypto/rand/md_rand.c46
-rw-r--r--src/lib/libcrypto/rand/rand.h29
-rw-r--r--src/lib/libcrypto/rand/rand_egd.c2
-rw-r--r--src/lib/libcrypto/rand/rand_eng.c152
-rw-r--r--src/lib/libcrypto/rand/rand_err.c20
-rw-r--r--src/lib/libcrypto/rand/rand_lcl.h11
-rw-r--r--src/lib/libcrypto/rand/rand_lib.c71
-rw-r--r--src/lib/libcrypto/rand/rand_os2.c6
-rw-r--r--src/lib/libcrypto/rand/rand_unix.c71
-rw-r--r--src/lib/libcrypto/rand/rand_win.c71
-rw-r--r--src/lib/libcrypto/rand/randfile.c33
-rw-r--r--src/lib/libcrypto/rc2/Makefile.ssl91
-rw-r--r--src/lib/libcrypto/rc2/rc2.h4
-rw-r--r--src/lib/libcrypto/rc2/rc2_skey.c19
-rw-r--r--src/lib/libcrypto/rc4/Makefile.ssl110
-rw-r--r--src/lib/libcrypto/rc4/asm/rc4-586.pl448
-rwxr-xr-xsrc/lib/libcrypto/rc4/asm/rc4-amd64.pl227
-rw-r--r--src/lib/libcrypto/rc4/asm/rc4-ia64.S159
-rwxr-xr-xsrc/lib/libcrypto/rc4/asm/rc4-x86_64.pl177
-rw-r--r--src/lib/libcrypto/rc4/rc4.h7
-rw-r--r--src/lib/libcrypto/rc4/rc4_enc.c16
-rw-r--r--src/lib/libcrypto/rc4/rc4_fblk.c75
-rw-r--r--src/lib/libcrypto/rc4/rc4_skey.c21
-rw-r--r--src/lib/libcrypto/rc4/rc4test.c16
-rw-r--r--src/lib/libcrypto/rc5/Makefile.ssl108
-rw-r--r--src/lib/libcrypto/rc5/rc5.h5
-rw-r--r--src/lib/libcrypto/ripemd/Makefile.ssl108
-rw-r--r--src/lib/libcrypto/ripemd/asm/rmd-586.pl3
-rw-r--r--src/lib/libcrypto/ripemd/ripemd.h6
-rw-r--r--src/lib/libcrypto/ripemd/rmd_dgst.c11
-rw-r--r--src/lib/libcrypto/ripemd/rmd_locl.h2
-rw-r--r--src/lib/libcrypto/rsa/Makefile123
-rw-r--r--src/lib/libcrypto/rsa/Makefile.ssl241
-rw-r--r--src/lib/libcrypto/rsa/rsa.h89
-rw-r--r--src/lib/libcrypto/rsa/rsa_asn1.c16
-rw-r--r--src/lib/libcrypto/rsa/rsa_eay.c28
-rw-r--r--src/lib/libcrypto/rsa/rsa_eng.c348
-rw-r--r--src/lib/libcrypto/rsa/rsa_err.c29
-rw-r--r--src/lib/libcrypto/rsa/rsa_gen.c3
-rw-r--r--src/lib/libcrypto/rsa/rsa_lib.c283
-rw-r--r--src/lib/libcrypto/rsa/rsa_oaep.c35
-rw-r--r--src/lib/libcrypto/rsa/rsa_sign.c88
-rw-r--r--src/lib/libcrypto/rsa/rsa_test.c2
-rw-r--r--src/lib/libcrypto/rsa/rsa_x931g.c255
-rw-r--r--src/lib/libcrypto/sha/Makefile.ssl116
-rw-r--r--src/lib/libcrypto/sha/asm/sha1-586.pl1
-rw-r--r--src/lib/libcrypto/sha/asm/sha512-sse2.pl404
-rw-r--r--src/lib/libcrypto/sha/sha.h5
-rw-r--r--src/lib/libcrypto/sha/sha1_one.c2
-rw-r--r--src/lib/libcrypto/sha/sha1dgst.c4
-rw-r--r--src/lib/libcrypto/sha/sha1s.cpp82
-rw-r--r--src/lib/libcrypto/sha/sha_dgst.c6
-rw-r--r--src/lib/libcrypto/sha/sha_locl.h11
-rw-r--r--src/lib/libcrypto/sha/shatest.c4
-rw-r--r--src/lib/libcrypto/stack/Makefile.ssl88
-rw-r--r--src/lib/libcrypto/stack/safestack.h1008
-rw-r--r--src/lib/libcrypto/stack/stack.c85
-rw-r--r--src/lib/libcrypto/stack/stack.h49
-rw-r--r--src/lib/libcrypto/symhacks.h106
-rw-r--r--src/lib/libcrypto/threads/mttest.c99
-rw-r--r--src/lib/libcrypto/threads/pthreads-vms.com9
-rw-r--r--src/lib/libcrypto/tmdiff.c260
-rw-r--r--src/lib/libcrypto/tmdiff.h93
-rw-r--r--src/lib/libcrypto/ts/ts_rsp_verify.c8
-rw-r--r--src/lib/libcrypto/txt_db/Makefile.ssl88
-rw-r--r--src/lib/libcrypto/txt_db/txt_db.c76
-rw-r--r--src/lib/libcrypto/txt_db/txt_db.h19
-rw-r--r--src/lib/libcrypto/ui/Makefile.ssl117
-rw-r--r--src/lib/libcrypto/ui/ui.h4
-rw-r--r--src/lib/libcrypto/ui/ui_err.c2
-rw-r--r--src/lib/libcrypto/ui/ui_lib.c19
-rw-r--r--src/lib/libcrypto/ui/ui_openssl.c14
-rw-r--r--src/lib/libcrypto/util/arx.pl15
-rw-r--r--src/lib/libcrypto/util/checkhash.pl222
-rw-r--r--src/lib/libcrypto/util/ck_errf.pl22
-rw-r--r--src/lib/libcrypto/util/clean-depend.pl1
-rw-r--r--src/lib/libcrypto/util/copy.pl11
-rw-r--r--src/lib/libcrypto/util/cygwin.sh4
-rw-r--r--src/lib/libcrypto/util/domd10
-rw-r--r--src/lib/libcrypto/util/fipslink.pl78
-rw-r--r--src/lib/libcrypto/util/libeay.num987
-rw-r--r--src/lib/libcrypto/util/mk1mf.pl561
-rw-r--r--src/lib/libcrypto/util/mkdef.pl76
-rw-r--r--src/lib/libcrypto/util/mkerr.pl113
-rw-r--r--src/lib/libcrypto/util/mkfiles.pl32
-rw-r--r--src/lib/libcrypto/util/mklink.pl13
-rw-r--r--src/lib/libcrypto/util/mksdef.pl87
-rw-r--r--src/lib/libcrypto/util/mkstack.pl74
-rw-r--r--src/lib/libcrypto/util/pl/BC-16.pl151
-rw-r--r--src/lib/libcrypto/util/pl/BC-32.pl2
-rw-r--r--src/lib/libcrypto/util/pl/Mingw32.pl6
-rw-r--r--src/lib/libcrypto/util/pl/VC-16.pl177
-rw-r--r--src/lib/libcrypto/util/pl/VC-32-GMAKE.pl222
-rw-r--r--src/lib/libcrypto/util/pl/VC-32.pl341
-rw-r--r--src/lib/libcrypto/util/pl/VC-CE.pl116
-rw-r--r--src/lib/libcrypto/util/pod2man.pl2
-rw-r--r--src/lib/libcrypto/util/point.sh2
-rw-r--r--src/lib/libcrypto/util/selftest.pl4
-rw-r--r--src/lib/libcrypto/util/ssleay.num27
-rw-r--r--src/lib/libcrypto/x509/Makefile.ssl594
-rw-r--r--src/lib/libcrypto/x509/by_dir.c226
-rw-r--r--src/lib/libcrypto/x509/by_file.c2
-rw-r--r--src/lib/libcrypto/x509/x509.h258
-rw-r--r--src/lib/libcrypto/x509/x509_cmp.c237
-rw-r--r--src/lib/libcrypto/x509/x509_err.c5
-rw-r--r--src/lib/libcrypto/x509/x509_lu.c215
-rw-r--r--src/lib/libcrypto/x509/x509_obj.c2
-rw-r--r--src/lib/libcrypto/x509/x509_req.c24
-rw-r--r--src/lib/libcrypto/x509/x509_set.c4
-rw-r--r--src/lib/libcrypto/x509/x509_trs.c3
-rw-r--r--src/lib/libcrypto/x509/x509_txt.c24
-rw-r--r--src/lib/libcrypto/x509/x509_vfy.c951
-rw-r--r--src/lib/libcrypto/x509/x509_vfy.h38
-rw-r--r--src/lib/libcrypto/x509/x509cset.c4
-rw-r--r--src/lib/libcrypto/x509/x509name.c2
-rw-r--r--src/lib/libcrypto/x509/x509type.c4
-rw-r--r--src/lib/libcrypto/x509/x_all.c7
-rw-r--r--src/lib/libcrypto/x509v3/Makefile.ssl603
-rw-r--r--src/lib/libcrypto/x509v3/ext_dat.h13
-rw-r--r--src/lib/libcrypto/x509v3/pcy_data.c12
-rw-r--r--src/lib/libcrypto/x509v3/pcy_tree.c235
-rw-r--r--src/lib/libcrypto/x509v3/v3_addr.c25
-rw-r--r--src/lib/libcrypto/x509v3/v3_alt.c140
-rw-r--r--src/lib/libcrypto/x509v3/v3_asid.c10
-rw-r--r--src/lib/libcrypto/x509v3/v3_conf.c51
-rw-r--r--src/lib/libcrypto/x509v3/v3_cpols.c5
-rw-r--r--src/lib/libcrypto/x509v3/v3_crld.c552
-rw-r--r--src/lib/libcrypto/x509v3/v3_enum.c19
-rw-r--r--src/lib/libcrypto/x509v3/v3_extku.c16
-rw-r--r--src/lib/libcrypto/x509v3/v3_genn.c153
-rw-r--r--src/lib/libcrypto/x509v3/v3_lib.c24
-rw-r--r--src/lib/libcrypto/x509v3/v3_ocsp.c62
-rw-r--r--src/lib/libcrypto/x509v3/v3_prn.c2
-rw-r--r--src/lib/libcrypto/x509v3/v3_purp.c194
-rw-r--r--src/lib/libcrypto/x509v3/v3_utl.c47
-rw-r--r--src/lib/libcrypto/x509v3/v3err.c13
-rw-r--r--src/lib/libcrypto/x509v3/x509v3.h173
-rw-r--r--src/lib/libcrypto/x86_64cpuid.pl256
570 files changed, 21771 insertions, 53852 deletions
diff --git a/src/lib/libcrypto/Makefile.ssl b/src/lib/libcrypto/Makefile.ssl
deleted file mode 100644
index b9951a4600..0000000000
--- a/src/lib/libcrypto/Makefile.ssl
+++ /dev/null
@@ -1,218 +0,0 @@
1#
2# SSLeay/crypto/Makefile
3#
4
5DIR= crypto
6TOP= ..
7CC= cc
8INCLUDE= -I. -I$(TOP) -I../include
9INCLUDES= -I.. -I../.. -I../../include
10CFLAG= -g
11INSTALL_PREFIX=
12OPENSSLDIR= /usr/local/ssl
13INSTALLTOP= /usr/local/ssl
14MAKE= make -f Makefile.ssl
15MAKEDEPPROG= makedepend
16MAKEDEPEND= $(TOP)/util/domd $(TOP) -MD $(MAKEDEPPROG)
17MAKEFILE= Makefile.ssl
18RM= rm -f
19AR= ar r
20
21PEX_LIBS=
22EX_LIBS=
23
24CFLAGS= $(INCLUDE) $(CFLAG)
25
26
27LIBS=
28
29SDIRS= md2 md5 sha mdc2 hmac ripemd \
30 des rc2 rc4 rc5 idea bf cast \
31 bn ec rsa dsa dh dso engine aes \
32 buffer bio stack lhash rand err objects \
33 evp asn1 pem x509 x509v3 conf txt_db pkcs7 pkcs12 comp ocsp ui krb5
34
35GENERAL=Makefile README crypto-lib.com install.com
36
37LIB= $(TOP)/libcrypto.a
38SHARED_LIB= libcrypto$(SHLIB_EXT)
39LIBSRC= cryptlib.c mem.c mem_clr.c mem_dbg.c cversion.c ex_data.c tmdiff.c cpt_err.c ebcdic.c uid.c o_time.c
40LIBOBJ= cryptlib.o mem.o mem_clr.o mem_dbg.o cversion.o ex_data.o tmdiff.o cpt_err.o ebcdic.o uid.o o_time.o
41
42SRC= $(LIBSRC)
43
44EXHEADER= crypto.h tmdiff.h opensslv.h opensslconf.h ebcdic.h symhacks.h \
45 ossl_typ.h
46HEADER= cryptlib.h buildinf.h md32_common.h o_time.h $(EXHEADER)
47
48ALL= $(GENERAL) $(SRC) $(HEADER)
49
50top:
51 @(cd ..; $(MAKE) DIRS=$(DIR) all)
52
53all: shared
54
55buildinf.h: ../Makefile.ssl
56 ( echo "#ifndef MK1MF_BUILD"; \
57 echo ' /* auto-generated by crypto/Makefile.ssl for crypto/cversion.c */'; \
58 echo ' #define CFLAGS "$(CC) $(CFLAG)"'; \
59 echo ' #define PLATFORM "$(PLATFORM)"'; \
60 echo " #define DATE \"`LC_ALL=C LC_TIME=C date`\""; \
61 echo '#endif' ) >buildinf.h
62
63testapps:
64 if echo ${SDIRS} | fgrep ' des '; \
65 then cd des && $(MAKE) CC='$(CC)' INCLUDES='${INCLUDES}' CFLAG='${CFLAG}' INSTALLTOP='${INSTALLTOP}' PEX_LIBS='${PEX_LIBS}' EX_LIBS='${EX_LIBS}' BN_ASM='${BN_ASM}' DES_ENC='${DES_ENC}' SHA1_ASM_OBJ='${SHA1_ASM_OBJ}' MD5_ASM_OBJ='${MD5_ASM_OBJ}' RMD160_ASM_OBJ='${RMD160_ASM_OBJ}' BF_ENC='${BF_ENC}' CAST_ENC='${CAST_ENC}' RC4_ENC='${RC4_ENC}' RC5_ENC='${RC5_ENC}' AR='${AR}' PROCESSOR='${PROCESSOR}' PERL='${PERL}' RANLIB='${RANLIB}' des; fi
66 cd pkcs7 && $(MAKE) CC='$(CC)' INCLUDES='${INCLUDES}' CFLAG='${CFLAG}' INSTALLTOP='${INSTALLTOP}' PEX_LIBS='${PEX_LIBS}' EX_LIBS='${EX_LIBS}' BN_ASM='${BN_ASM}' DES_ENC='${DES_ENC}' SHA1_ASM_OBJ='${SHA1_ASM_OBJ}' MD5_ASM_OBJ='${MD5_ASM_OBJ}' RMD160_ASM_OBJ='${RMD160_ASM_OBJ}' BF_ENC='${BF_ENC}' CAST_ENC='${CAST_ENC}' RC4_ENC='${RC4_ENC}' RC5_ENC='${RC5_ENC}' AR='${AR}' PROCESSOR='${PROCESSOR}' PERL='${PERL}' RANLIB='${RANLIB}' testapps
67
68subdirs:
69 @for i in $(SDIRS) ;\
70 do \
71 (cd $$i && echo "making all in crypto/$$i..." && \
72 $(MAKE) CC='$(CC)' INCLUDES='${INCLUDES}' CFLAG='${CFLAG}' INSTALLTOP='${INSTALLTOP}' PEX_LIBS='${PEX_LIBS}' EX_LIBS='${EX_LIBS}' BN_ASM='${BN_ASM}' DES_ENC='${DES_ENC}' SHA1_ASM_OBJ='${SHA1_ASM_OBJ}' MD5_ASM_OBJ='${MD5_ASM_OBJ}' RMD160_ASM_OBJ='${RMD160_ASM_OBJ}' BF_ENC='${BF_ENC}' CAST_ENC='${CAST_ENC}' RC4_ENC='${RC4_ENC}' RC5_ENC='${RC5_ENC}' AR='${AR}' PROCESSOR='${PROCESSOR}' PERL='${PERL}' RANLIB='${RANLIB}' all ) || exit 1; \
73 done;
74
75files:
76 $(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO
77 @for i in $(SDIRS) ;\
78 do \
79 (cd $$i && echo "making 'files' in crypto/$$i..." && \
80 $(MAKE) PERL='${PERL}' files ); \
81 done;
82
83links:
84 @sh $(TOP)/util/point.sh Makefile.ssl Makefile
85 @$(PERL) $(TOP)/util/mklink.pl ../include/openssl $(EXHEADER)
86 @$(PERL) $(TOP)/util/mklink.pl ../test $(TEST)
87 @$(PERL) $(TOP)/util/mklink.pl ../apps $(APPS)
88 @sh $(TOP)/util/point.sh Makefile.ssl Makefile
89 @for i in $(SDIRS); do \
90 (cd $$i && echo "making links in crypto/$$i..." && \
91 $(MAKE) CC='$(CC)' INCLUDES='${INCLUDES}' CFLAG='${CFLAG}' INSTALLTOP='${INSTALLTOP}' PEX_LIBS='${PEX_LIBS}' EX_LIBS='${EX_LIBS}' BN_ASM='${BN_ASM}' DES_ENC='${DES_ENC}' SHA1_ASM_OBJ='${SHA1_ASM_OBJ}' MD5_ASM_OBJ='${MD5_ASM_OBJ}' RMD160_ASM_OBJ='${RMD160_ASM_OBJ}' BF_ENC='${BF_ENC}' CAST_ENC='${CAST_ENC}' RC4_ENC='${RC4_ENC}' RC5_ENC='${RC5_ENC}' AR='${AR}' PERL='${PERL}' links ); \
92 done;
93
94lib: $(LIBOBJ)
95 $(AR) $(LIB) $(LIBOBJ)
96 $(RANLIB) $(LIB) || echo Never mind.
97 @touch lib
98
99shared: buildinf.h lib subdirs
100 if [ -n "$(SHARED_LIBS)" ]; then \
101 (cd ..; $(MAKE) $(SHARED_LIB)); \
102 fi
103
104libs:
105 @for i in $(SDIRS) ;\
106 do \
107 (cd $$i && echo "making libs in crypto/$$i..." && \
108 $(MAKE) CC='$(CC)' CFLAG='${CFLAG}' INSTALL_PREFIX='${INSTALL_PREFIX}' INSTALLTOP='${INSTALLTOP}' PEX_LIBS='${PEX_LIBS}' EX_LIBS='${EX_LIBS}' AR='${AR}' lib ); \
109 done;
110
111tests:
112 @for i in $(SDIRS) ;\
113 do \
114 (cd $$i && echo "making tests in crypto/$$i..." && \
115 $(MAKE) CC='$(CC)' CFLAG='${CFLAG}' INSTALLTOP='${INSTALLTOP}' PEX_LIBS='${PEX_LIBS}' EX_LIBS='${EX_LIBS}' AR='${AR}' tests ); \
116 done;
117
118install:
119 @for i in $(EXHEADER) ;\
120 do \
121 (cp $$i $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i; \
122 chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i ); \
123 done;
124 @for i in $(SDIRS) ;\
125 do \
126 (cd $$i && echo "making install in crypto/$$i..." && \
127 $(MAKE) CC='$(CC)' CFLAG='${CFLAG}' INSTALL_PREFIX='${INSTALL_PREFIX}' INSTALLTOP='${INSTALLTOP}' PEX_LIBS='${PEX_LIBS}' EX_LIBS='${EX_LIBS}' install ); \
128 done;
129
130lint:
131 @for i in $(SDIRS) ;\
132 do \
133 (cd $$i && echo "making lint in crypto/$$i..." && \
134 $(MAKE) CC='$(CC)' CFLAG='${CFLAG}' INSTALLTOP='${INSTALLTOP}' PEX_LIBS='${PEX_LIBS}' EX_LIBS='${EX_LIBS}' lint ); \
135 done;
136
137depend:
138 if [ ! -f buildinf.h ]; then touch buildinf.h; fi # fake buildinf.h if it does not exist
139 $(MAKEDEPEND) -- $(CFLAG) $(INCLUDE) $(DEPFLAG) -- $(PROGS) $(LIBSRC)
140 if [ ! -s buildinf.h ]; then rm buildinf.h; fi
141 @for i in $(SDIRS) ;\
142 do \
143 (cd $$i && echo "making depend in crypto/$$i..." && \
144 $(MAKE) MAKEFILE='${MAKEFILE}' INCLUDES='${INCLUDES}' CFLAG='${CFLAG}' DEPFLAG='${DEPFLAG}' MAKEDEPPROG='${MAKEDEPPROG}' KRB5_INCLUDES='${KRB5_INCLUDES}' PERL='${PERL}' depend ); \
145 done;
146
147clean:
148 rm -f buildinf.h *.o */*.o *.obj lib tags core .pure .nfs* *.old *.bak fluff
149 @for i in $(SDIRS) ;\
150 do \
151 (cd $$i && echo "making clean in crypto/$$i..." && \
152 $(MAKE) CC='$(CC)' CFLAG='${CFLAG}' INSTALLTOP='${INSTALLTOP}' PEX_LIBS='${PEX_LIBS}' EX_LIBS='${EX_LIBS}' clean ); \
153 done;
154
155dclean:
156 $(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
157 mv -f Makefile.new $(MAKEFILE)
158 @for i in $(SDIRS) ;\
159 do \
160 (cd $$i && echo "making dclean in crypto/$$i..." && \
161 $(MAKE) PERL='${PERL}' CC='$(CC)' CFLAG='${CFLAG}' INSTALLTOP='${INSTALLTOP}' PEX_LIBS='${PEX_LIBS}' EX_LIBS='${EX_LIBS}' dclean ); \
162 done;
163
164# DO NOT DELETE THIS LINE -- make depend depends on it.
165
166cpt_err.o: ../include/openssl/bio.h ../include/openssl/crypto.h
167cpt_err.o: ../include/openssl/e_os2.h ../include/openssl/err.h
168cpt_err.o: ../include/openssl/lhash.h ../include/openssl/opensslconf.h
169cpt_err.o: ../include/openssl/opensslv.h ../include/openssl/safestack.h
170cpt_err.o: ../include/openssl/stack.h ../include/openssl/symhacks.h cpt_err.c
171cryptlib.o: ../e_os.h ../include/openssl/bio.h ../include/openssl/buffer.h
172cryptlib.o: ../include/openssl/crypto.h ../include/openssl/e_os2.h
173cryptlib.o: ../include/openssl/err.h ../include/openssl/lhash.h
174cryptlib.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h
175cryptlib.o: ../include/openssl/safestack.h ../include/openssl/stack.h
176cryptlib.o: ../include/openssl/symhacks.h cryptlib.c cryptlib.h
177cversion.o: ../e_os.h ../include/openssl/bio.h ../include/openssl/buffer.h
178cversion.o: ../include/openssl/crypto.h ../include/openssl/e_os2.h
179cversion.o: ../include/openssl/err.h ../include/openssl/lhash.h
180cversion.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h
181cversion.o: ../include/openssl/safestack.h ../include/openssl/stack.h
182cversion.o: ../include/openssl/symhacks.h buildinf.h cryptlib.h cversion.c
183ebcdic.o: ../include/openssl/e_os2.h ../include/openssl/opensslconf.h ebcdic.c
184ex_data.o: ../e_os.h ../include/openssl/bio.h ../include/openssl/buffer.h
185ex_data.o: ../include/openssl/crypto.h ../include/openssl/e_os2.h
186ex_data.o: ../include/openssl/err.h ../include/openssl/lhash.h
187ex_data.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h
188ex_data.o: ../include/openssl/safestack.h ../include/openssl/stack.h
189ex_data.o: ../include/openssl/symhacks.h cryptlib.h ex_data.c
190mem.o: ../e_os.h ../include/openssl/bio.h ../include/openssl/buffer.h
191mem.o: ../include/openssl/crypto.h ../include/openssl/e_os2.h
192mem.o: ../include/openssl/err.h ../include/openssl/lhash.h
193mem.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h
194mem.o: ../include/openssl/safestack.h ../include/openssl/stack.h
195mem.o: ../include/openssl/symhacks.h cryptlib.h mem.c
196mem_clr.o: ../include/openssl/crypto.h ../include/openssl/e_os2.h
197mem_clr.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h
198mem_clr.o: ../include/openssl/safestack.h ../include/openssl/stack.h
199mem_clr.o: ../include/openssl/symhacks.h mem_clr.c
200mem_dbg.o: ../e_os.h ../include/openssl/bio.h ../include/openssl/buffer.h
201mem_dbg.o: ../include/openssl/crypto.h ../include/openssl/e_os2.h
202mem_dbg.o: ../include/openssl/err.h ../include/openssl/lhash.h
203mem_dbg.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h
204mem_dbg.o: ../include/openssl/safestack.h ../include/openssl/stack.h
205mem_dbg.o: ../include/openssl/symhacks.h cryptlib.h mem_dbg.c
206o_time.o: ../include/openssl/e_os2.h ../include/openssl/opensslconf.h o_time.c
207o_time.o: o_time.h
208tmdiff.o: ../e_os.h ../include/openssl/bio.h ../include/openssl/buffer.h
209tmdiff.o: ../include/openssl/crypto.h ../include/openssl/e_os2.h
210tmdiff.o: ../include/openssl/err.h ../include/openssl/lhash.h
211tmdiff.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h
212tmdiff.o: ../include/openssl/safestack.h ../include/openssl/stack.h
213tmdiff.o: ../include/openssl/symhacks.h ../include/openssl/tmdiff.h cryptlib.h
214tmdiff.o: tmdiff.c
215uid.o: ../include/openssl/crypto.h ../include/openssl/e_os2.h
216uid.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h
217uid.o: ../include/openssl/safestack.h ../include/openssl/stack.h
218uid.o: ../include/openssl/symhacks.h uid.c
diff --git a/src/lib/libcrypto/aes/Makefile.ssl b/src/lib/libcrypto/aes/Makefile.ssl
deleted file mode 100644
index f353aeb697..0000000000
--- a/src/lib/libcrypto/aes/Makefile.ssl
+++ /dev/null
@@ -1,103 +0,0 @@
1#
2# crypto/aes/Makefile
3#
4
5DIR= aes
6TOP= ../..
7CC= cc
8CPP= $(CC) -E
9INCLUDES=
10CFLAG=-g
11INSTALL_PREFIX=
12OPENSSLDIR= /usr/local/ssl
13INSTALLTOP= /usr/local/ssl
14MAKE= make -f Makefile.ssl
15MAKEDEPPROG= makedepend
16MAKEDEPEND= $(TOP)/util/domd $(TOP) -MD $(MAKEDEPPROG)
17MAKEFILE= Makefile.ssl
18AR= ar r
19
20# CFLAGS= -mpentiumpro $(INCLUDES) $(CFLAG) -O3 -fexpensive-optimizations -funroll-loops -fforce-addr
21CFLAGS= $(INCLUDES) $(CFLAG)
22
23GENERAL=Makefile
24#TEST=aestest.c
25TEST=
26APPS=
27
28LIB=$(TOP)/libcrypto.a
29LIBSRC=aes_core.c aes_misc.c aes_ecb.c aes_cbc.c aes_cfb.c aes_ofb.c aes_ctr.c
30LIBOBJ=aes_core.o aes_misc.o aes_ecb.o aes_cbc.o aes_cfb.o aes_ofb.o aes_ctr.o
31
32SRC= $(LIBSRC)
33
34EXHEADER= aes.h
35HEADER= aes_locl.h $(EXHEADER)
36
37ALL= $(GENERAL) $(SRC) $(HEADER)
38
39top:
40 (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all)
41
42all: lib
43
44lib: $(LIBOBJ)
45 $(AR) $(LIB) $(LIBOBJ)
46 $(RANLIB) $(LIB) || echo Never mind.
47 @touch lib
48
49$(LIBOBJ): $(LIBSRC)
50
51files:
52 $(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO
53
54links:
55 @sh $(TOP)/util/point.sh Makefile.ssl Makefile
56 @$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER)
57 @$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST)
58 @$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS)
59
60install: installs
61
62installs:
63 @for i in $(EXHEADER) ; \
64 do \
65 (cp $$i $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i; \
66 chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i ); \
67 done;
68
69tags:
70 ctags $(SRC)
71
72tests:
73
74lint:
75 lint -DLINT $(INCLUDES) $(SRC)>fluff
76
77depend:
78 $(MAKEDEPEND) -- $(CFLAG) $(INCLUDES) $(DEPFLAG) -- $(PROGS) $(LIBSRC)
79
80dclean:
81 $(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
82 mv -f Makefile.new $(MAKEFILE)
83
84clean:
85 rm -f *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff
86
87# DO NOT DELETE THIS LINE -- make depend depends on it.
88
89aes_cbc.o: ../../include/openssl/aes.h ../../include/openssl/e_os2.h
90aes_cbc.o: ../../include/openssl/opensslconf.h aes_cbc.c aes_locl.h
91aes_cfb.o: ../../include/openssl/aes.h ../../include/openssl/e_os2.h
92aes_cfb.o: ../../include/openssl/opensslconf.h aes_cfb.c aes_locl.h
93aes_core.o: ../../include/openssl/aes.h ../../include/openssl/e_os2.h
94aes_core.o: ../../include/openssl/opensslconf.h aes_core.c aes_locl.h
95aes_ctr.o: ../../include/openssl/aes.h ../../include/openssl/e_os2.h
96aes_ctr.o: ../../include/openssl/opensslconf.h aes_ctr.c aes_locl.h
97aes_ecb.o: ../../include/openssl/aes.h ../../include/openssl/e_os2.h
98aes_ecb.o: ../../include/openssl/opensslconf.h aes_ecb.c aes_locl.h
99aes_misc.o: ../../include/openssl/aes.h ../../include/openssl/e_os2.h
100aes_misc.o: ../../include/openssl/opensslconf.h
101aes_misc.o: ../../include/openssl/opensslv.h aes_locl.h aes_misc.c
102aes_ofb.o: ../../include/openssl/aes.h ../../include/openssl/e_os2.h
103aes_ofb.o: ../../include/openssl/opensslconf.h aes_locl.h aes_ofb.c
diff --git a/src/lib/libcrypto/aes/aes.h b/src/lib/libcrypto/aes/aes.h
index 450f2b4051..d2c99730fe 100644
--- a/src/lib/libcrypto/aes/aes.h
+++ b/src/lib/libcrypto/aes/aes.h
@@ -58,6 +58,8 @@
58#error AES is disabled. 58#error AES is disabled.
59#endif 59#endif
60 60
61#include <stddef.h>
62
61#define AES_ENCRYPT 1 63#define AES_ENCRYPT 1
62#define AES_DECRYPT 0 64#define AES_DECRYPT 0
63 65
@@ -66,10 +68,6 @@
66#define AES_MAXNR 14 68#define AES_MAXNR 14
67#define AES_BLOCK_SIZE 16 69#define AES_BLOCK_SIZE 16
68 70
69#ifdef OPENSSL_FIPS
70#define FIPS_AES_SIZE_T int
71#endif
72
73#ifdef __cplusplus 71#ifdef __cplusplus
74extern "C" { 72extern "C" {
75#endif 73#endif
@@ -100,37 +98,32 @@ void AES_decrypt(const unsigned char *in, unsigned char *out,
100void AES_ecb_encrypt(const unsigned char *in, unsigned char *out, 98void AES_ecb_encrypt(const unsigned char *in, unsigned char *out,
101 const AES_KEY *key, const int enc); 99 const AES_KEY *key, const int enc);
102void AES_cbc_encrypt(const unsigned char *in, unsigned char *out, 100void AES_cbc_encrypt(const unsigned char *in, unsigned char *out,
103 const unsigned long length, const AES_KEY *key, 101 size_t length, const AES_KEY *key,
104 unsigned char *ivec, const int enc); 102 unsigned char *ivec, const int enc);
105void AES_cfb128_encrypt(const unsigned char *in, unsigned char *out, 103void AES_cfb128_encrypt(const unsigned char *in, unsigned char *out,
106 const unsigned long length, const AES_KEY *key, 104 size_t length, const AES_KEY *key,
107 unsigned char *ivec, int *num, const int enc); 105 unsigned char *ivec, int *num, const int enc);
108void AES_cfb1_encrypt(const unsigned char *in, unsigned char *out, 106void AES_cfb1_encrypt(const unsigned char *in, unsigned char *out,
109 const unsigned long length, const AES_KEY *key, 107 size_t length, const AES_KEY *key,
110 unsigned char *ivec, int *num, const int enc); 108 unsigned char *ivec, int *num, const int enc);
111void AES_cfb8_encrypt(const unsigned char *in, unsigned char *out, 109void AES_cfb8_encrypt(const unsigned char *in, unsigned char *out,
112 const unsigned long length, const AES_KEY *key, 110 size_t length, const AES_KEY *key,
113 unsigned char *ivec, int *num, const int enc); 111 unsigned char *ivec, int *num, const int enc);
114void AES_cfbr_encrypt_block(const unsigned char *in,unsigned char *out,
115 const int nbits,const AES_KEY *key,
116 unsigned char *ivec,const int enc);
117void AES_ofb128_encrypt(const unsigned char *in, unsigned char *out, 112void AES_ofb128_encrypt(const unsigned char *in, unsigned char *out,
118 const unsigned long length, const AES_KEY *key, 113 size_t length, const AES_KEY *key,
119 unsigned char *ivec, int *num); 114 unsigned char *ivec, int *num);
120void AES_ctr128_encrypt(const unsigned char *in, unsigned char *out, 115void AES_ctr128_encrypt(const unsigned char *in, unsigned char *out,
121 const unsigned long length, const AES_KEY *key, 116 size_t length, const AES_KEY *key,
122 unsigned char ivec[AES_BLOCK_SIZE], 117 unsigned char ivec[AES_BLOCK_SIZE],
123 unsigned char ecount_buf[AES_BLOCK_SIZE], 118 unsigned char ecount_buf[AES_BLOCK_SIZE],
124 unsigned int *num); 119 unsigned int *num);
125
126/* For IGE, see also http://www.links.org/files/openssl-ige.pdf */
127/* NB: the IV is _two_ blocks long */ 120/* NB: the IV is _two_ blocks long */
128void AES_ige_encrypt(const unsigned char *in, unsigned char *out, 121void AES_ige_encrypt(const unsigned char *in, unsigned char *out,
129 const unsigned long length, const AES_KEY *key, 122 size_t length, const AES_KEY *key,
130 unsigned char *ivec, const int enc); 123 unsigned char *ivec, const int enc);
131/* NB: the IV is _four_ blocks long */ 124/* NB: the IV is _four_ blocks long */
132void AES_bi_ige_encrypt(const unsigned char *in, unsigned char *out, 125void AES_bi_ige_encrypt(const unsigned char *in, unsigned char *out,
133 const unsigned long length, const AES_KEY *key, 126 size_t length, const AES_KEY *key,
134 const AES_KEY *key2, const unsigned char *ivec, 127 const AES_KEY *key2, const unsigned char *ivec,
135 const int enc); 128 const int enc);
136 129
@@ -141,6 +134,7 @@ int AES_unwrap_key(AES_KEY *key, const unsigned char *iv,
141 unsigned char *out, 134 unsigned char *out,
142 const unsigned char *in, unsigned int inlen); 135 const unsigned char *in, unsigned int inlen);
143 136
137
144#ifdef __cplusplus 138#ifdef __cplusplus
145} 139}
146#endif 140#endif
diff --git a/src/lib/libcrypto/aes/aes_cbc.c b/src/lib/libcrypto/aes/aes_cbc.c
index 373864cd4b..227f75625d 100644
--- a/src/lib/libcrypto/aes/aes_cbc.c
+++ b/src/lib/libcrypto/aes/aes_cbc.c
@@ -49,85 +49,15 @@
49 * 49 *
50 */ 50 */
51 51
52#ifndef AES_DEBUG
53# ifndef NDEBUG
54# define NDEBUG
55# endif
56#endif
57#include <assert.h>
58
59#include <openssl/aes.h> 52#include <openssl/aes.h>
60#include "aes_locl.h" 53#include <openssl/modes.h>
61 54
62#if !defined(OPENSSL_FIPS_AES_ASM)
63void AES_cbc_encrypt(const unsigned char *in, unsigned char *out, 55void AES_cbc_encrypt(const unsigned char *in, unsigned char *out,
64 const unsigned long length, const AES_KEY *key, 56 size_t len, const AES_KEY *key,
65 unsigned char *ivec, const int enc) { 57 unsigned char *ivec, const int enc) {
66 58
67 unsigned long n; 59 if (enc)
68 unsigned long len = length; 60 CRYPTO_cbc128_encrypt(in,out,len,key,ivec,(block128_f)AES_encrypt);
69 unsigned char tmp[AES_BLOCK_SIZE]; 61 else
70 const unsigned char *iv = ivec; 62 CRYPTO_cbc128_decrypt(in,out,len,key,ivec,(block128_f)AES_decrypt);
71
72 assert(in && out && key && ivec);
73 assert((AES_ENCRYPT == enc)||(AES_DECRYPT == enc));
74
75 if (AES_ENCRYPT == enc) {
76 while (len >= AES_BLOCK_SIZE) {
77 for(n=0; n < AES_BLOCK_SIZE; ++n)
78 out[n] = in[n] ^ iv[n];
79 AES_encrypt(out, out, key);
80 iv = out;
81 len -= AES_BLOCK_SIZE;
82 in += AES_BLOCK_SIZE;
83 out += AES_BLOCK_SIZE;
84 }
85 if (len) {
86 for(n=0; n < len; ++n)
87 out[n] = in[n] ^ iv[n];
88 for(n=len; n < AES_BLOCK_SIZE; ++n)
89 out[n] = iv[n];
90 AES_encrypt(out, out, key);
91 iv = out;
92 }
93 memcpy(ivec,iv,AES_BLOCK_SIZE);
94 } else if (in != out) {
95 while (len >= AES_BLOCK_SIZE) {
96 AES_decrypt(in, out, key);
97 for(n=0; n < AES_BLOCK_SIZE; ++n)
98 out[n] ^= iv[n];
99 iv = in;
100 len -= AES_BLOCK_SIZE;
101 in += AES_BLOCK_SIZE;
102 out += AES_BLOCK_SIZE;
103 }
104 if (len) {
105 AES_decrypt(in,tmp,key);
106 for(n=0; n < len; ++n)
107 out[n] = tmp[n] ^ iv[n];
108 iv = in;
109 }
110 memcpy(ivec,iv,AES_BLOCK_SIZE);
111 } else {
112 while (len >= AES_BLOCK_SIZE) {
113 memcpy(tmp, in, AES_BLOCK_SIZE);
114 AES_decrypt(in, out, key);
115 for(n=0; n < AES_BLOCK_SIZE; ++n)
116 out[n] ^= ivec[n];
117 memcpy(ivec, tmp, AES_BLOCK_SIZE);
118 len -= AES_BLOCK_SIZE;
119 in += AES_BLOCK_SIZE;
120 out += AES_BLOCK_SIZE;
121 }
122 if (len) {
123 memcpy(tmp, in, AES_BLOCK_SIZE);
124 AES_decrypt(tmp, out, key);
125 for(n=0; n < len; ++n)
126 out[n] ^= ivec[n];
127 for(n=len; n < AES_BLOCK_SIZE; ++n)
128 out[n] = tmp[n];
129 memcpy(ivec, tmp, AES_BLOCK_SIZE);
130 }
131 }
132} 63}
133#endif
diff --git a/src/lib/libcrypto/aes/aes_cfb.c b/src/lib/libcrypto/aes/aes_cfb.c
index 49f0411010..0c6d058ce7 100644
--- a/src/lib/libcrypto/aes/aes_cfb.c
+++ b/src/lib/libcrypto/aes/aes_cfb.c
@@ -1,6 +1,6 @@
1/* crypto/aes/aes_cfb.c -*- mode:C; c-file-style: "eay" -*- */ 1/* crypto/aes/aes_cfb.c -*- mode:C; c-file-style: "eay" -*- */
2/* ==================================================================== 2/* ====================================================================
3 * Copyright (c) 1998-2002 The OpenSSL Project. All rights reserved. 3 * Copyright (c) 2002-2006 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
@@ -48,73 +48,9 @@
48 * ==================================================================== 48 * ====================================================================
49 * 49 *
50 */ 50 */
51/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
52 * All rights reserved.
53 *
54 * This package is an SSL implementation written
55 * by Eric Young (eay@cryptsoft.com).
56 * The implementation was written so as to conform with Netscapes SSL.
57 *
58 * This library is free for commercial and non-commercial use as long as
59 * the following conditions are aheared to. The following conditions
60 * apply to all code found in this distribution, be it the RC4, RSA,
61 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
62 * included with this distribution is covered by the same copyright terms
63 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
64 *
65 * Copyright remains Eric Young's, and as such any Copyright notices in
66 * the code are not to be removed.
67 * If this package is used in a product, Eric Young should be given attribution
68 * as the author of the parts of the library used.
69 * This can be in the form of a textual message at program startup or
70 * in documentation (online or textual) provided with the package.
71 *
72 * Redistribution and use in source and binary forms, with or without
73 * modification, are permitted provided that the following conditions
74 * are met:
75 * 1. Redistributions of source code must retain the copyright
76 * notice, this list of conditions and the following disclaimer.
77 * 2. Redistributions in binary form must reproduce the above copyright
78 * notice, this list of conditions and the following disclaimer in the
79 * documentation and/or other materials provided with the distribution.
80 * 3. All advertising materials mentioning features or use of this software
81 * must display the following acknowledgement:
82 * "This product includes cryptographic software written by
83 * Eric Young (eay@cryptsoft.com)"
84 * The word 'cryptographic' can be left out if the rouines from the library
85 * being used are not cryptographic related :-).
86 * 4. If you include any Windows specific code (or a derivative thereof) from
87 * the apps directory (application code) you must include an acknowledgement:
88 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
89 *
90 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
91 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
92 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
93 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
94 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
95 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
96 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
97 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
98 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
99 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
100 * SUCH DAMAGE.
101 *
102 * The licence and distribution terms for any publically available version or
103 * derivative of this code cannot be changed. i.e. this code cannot simply be
104 * copied and put under another distribution licence
105 * [including the GNU Public Licence.]
106 */
107
108#ifndef AES_DEBUG
109# ifndef NDEBUG
110# define NDEBUG
111# endif
112#endif
113#include <assert.h>
114 51
115#include <openssl/aes.h> 52#include <openssl/aes.h>
116#include "aes_locl.h" 53#include <openssl/modes.h>
117#include "e_os.h"
118 54
119/* The input and output encrypted as though 128bit cfb mode is being 55/* The input and output encrypted as though 128bit cfb mode is being
120 * used. The extra state information to record how much of the 56 * used. The extra state information to record how much of the
@@ -122,104 +58,24 @@
122 */ 58 */
123 59
124void AES_cfb128_encrypt(const unsigned char *in, unsigned char *out, 60void AES_cfb128_encrypt(const unsigned char *in, unsigned char *out,
125 const unsigned long length, const AES_KEY *key, 61 size_t length, const AES_KEY *key,
126 unsigned char *ivec, int *num, const int enc) { 62 unsigned char *ivec, int *num, const int enc) {
127 63
128 unsigned int n; 64 CRYPTO_cfb128_encrypt(in,out,length,key,ivec,num,enc,(block128_f)AES_encrypt);
129 unsigned long l = length;
130 unsigned char c;
131
132 assert(in && out && key && ivec && num);
133
134 n = *num;
135
136 if (enc) {
137 while (l--) {
138 if (n == 0) {
139 AES_encrypt(ivec, ivec, key);
140 }
141 ivec[n] = *(out++) = *(in++) ^ ivec[n];
142 n = (n+1) % AES_BLOCK_SIZE;
143 }
144 } else {
145 while (l--) {
146 if (n == 0) {
147 AES_encrypt(ivec, ivec, key);
148 }
149 c = *(in);
150 *(out++) = *(in++) ^ ivec[n];
151 ivec[n] = c;
152 n = (n+1) % AES_BLOCK_SIZE;
153 }
154 }
155
156 *num=n;
157} 65}
158 66
159/* This expects a single block of size nbits for both in and out. Note that
160 it corrupts any extra bits in the last byte of out */
161void AES_cfbr_encrypt_block(const unsigned char *in,unsigned char *out,
162 const int nbits,const AES_KEY *key,
163 unsigned char *ivec,const int enc)
164 {
165 int n,rem,num;
166 unsigned char ovec[AES_BLOCK_SIZE*2];
167
168 if (nbits<=0 || nbits>128) return;
169
170 /* fill in the first half of the new IV with the current IV */
171 memcpy(ovec,ivec,AES_BLOCK_SIZE);
172 /* construct the new IV */
173 AES_encrypt(ivec,ivec,key);
174 num = (nbits+7)/8;
175 if (enc) /* encrypt the input */
176 for(n=0 ; n < num ; ++n)
177 out[n] = (ovec[AES_BLOCK_SIZE+n] = in[n] ^ ivec[n]);
178 else /* decrypt the input */
179 for(n=0 ; n < num ; ++n)
180 out[n] = (ovec[AES_BLOCK_SIZE+n] = in[n]) ^ ivec[n];
181 /* shift ovec left... */
182 rem = nbits%8;
183 num = nbits/8;
184 if(rem==0)
185 memcpy(ivec,ovec+num,AES_BLOCK_SIZE);
186 else
187 for(n=0 ; n < AES_BLOCK_SIZE ; ++n)
188 ivec[n] = ovec[n+num]<<rem | ovec[n+num+1]>>(8-rem);
189
190 /* it is not necessary to cleanse ovec, since the IV is not secret */
191 }
192
193/* N.B. This expects the input to be packed, MS bit first */ 67/* N.B. This expects the input to be packed, MS bit first */
194void AES_cfb1_encrypt(const unsigned char *in, unsigned char *out, 68void AES_cfb1_encrypt(const unsigned char *in, unsigned char *out,
195 const unsigned long length, const AES_KEY *key, 69 size_t length, const AES_KEY *key,
196 unsigned char *ivec, int *num, const int enc) 70 unsigned char *ivec, int *num, const int enc)
197 { 71 {
198 unsigned int n; 72 CRYPTO_cfb128_1_encrypt(in,out,length,key,ivec,num,enc,(block128_f)AES_encrypt);
199 unsigned char c[1],d[1];
200
201 assert(in && out && key && ivec && num);
202 assert(*num == 0);
203
204 memset(out,0,(length+7)/8);
205 for(n=0 ; n < length ; ++n)
206 {
207 c[0]=(in[n/8]&(1 << (7-n%8))) ? 0x80 : 0;
208 AES_cfbr_encrypt_block(c,d,1,key,ivec,enc);
209 out[n/8]=(out[n/8]&~(1 << (7-n%8)))|((d[0]&0x80) >> (n%8));
210 }
211 } 73 }
212 74
213void AES_cfb8_encrypt(const unsigned char *in, unsigned char *out, 75void AES_cfb8_encrypt(const unsigned char *in, unsigned char *out,
214 const unsigned long length, const AES_KEY *key, 76 size_t length, const AES_KEY *key,
215 unsigned char *ivec, int *num, const int enc) 77 unsigned char *ivec, int *num, const int enc)
216 { 78 {
217 unsigned int n; 79 CRYPTO_cfb128_8_encrypt(in,out,length,key,ivec,num,enc,(block128_f)AES_encrypt);
218
219 assert(in && out && key && ivec && num);
220 assert(*num == 0);
221
222 for(n=0 ; n < length ; ++n)
223 AES_cfbr_encrypt_block(&in[n],&out[n],8,key,ivec,enc);
224 } 80 }
225 81
diff --git a/src/lib/libcrypto/aes/aes_core.c b/src/lib/libcrypto/aes/aes_core.c
index cffdd4daec..a7ec54f4da 100644
--- a/src/lib/libcrypto/aes/aes_core.c
+++ b/src/lib/libcrypto/aes/aes_core.c
@@ -37,12 +37,9 @@
37 37
38#include <stdlib.h> 38#include <stdlib.h>
39#include <openssl/aes.h> 39#include <openssl/aes.h>
40#ifdef OPENSSL_FIPS
41#include <openssl/fips.h>
42#endif
43
44#include "aes_locl.h" 40#include "aes_locl.h"
45 41
42#ifndef AES_ASM
46/* 43/*
47Te0[x] = S [x].[02, 01, 01, 03]; 44Te0[x] = S [x].[02, 01, 01, 03];
48Te1[x] = S [x].[03, 02, 01, 01]; 45Te1[x] = S [x].[03, 02, 01, 01];
@@ -635,10 +632,6 @@ int AES_set_encrypt_key(const unsigned char *userKey, const int bits,
635 int i = 0; 632 int i = 0;
636 u32 temp; 633 u32 temp;
637 634
638#ifdef OPENSSL_FIPS
639 FIPS_selftest_check();
640#endif
641
642 if (!userKey || !key) 635 if (!userKey || !key)
643 return -1; 636 return -1;
644 if (bits != 128 && bits != 192 && bits != 256) 637 if (bits != 128 && bits != 192 && bits != 256)
@@ -781,7 +774,6 @@ int AES_set_decrypt_key(const unsigned char *userKey, const int bits,
781 return 0; 774 return 0;
782} 775}
783 776
784#ifndef AES_ASM
785/* 777/*
786 * Encrypt a single block 778 * Encrypt a single block
787 * in and out can overlap 779 * in and out can overlap
@@ -1164,4 +1156,203 @@ void AES_decrypt(const unsigned char *in, unsigned char *out,
1164 PUTU32(out + 12, s3); 1156 PUTU32(out + 12, s3);
1165} 1157}
1166 1158
1159#else /* AES_ASM */
1160
1161static const u8 Te4[256] = {
1162 0x63U, 0x7cU, 0x77U, 0x7bU, 0xf2U, 0x6bU, 0x6fU, 0xc5U,
1163 0x30U, 0x01U, 0x67U, 0x2bU, 0xfeU, 0xd7U, 0xabU, 0x76U,
1164 0xcaU, 0x82U, 0xc9U, 0x7dU, 0xfaU, 0x59U, 0x47U, 0xf0U,
1165 0xadU, 0xd4U, 0xa2U, 0xafU, 0x9cU, 0xa4U, 0x72U, 0xc0U,
1166 0xb7U, 0xfdU, 0x93U, 0x26U, 0x36U, 0x3fU, 0xf7U, 0xccU,
1167 0x34U, 0xa5U, 0xe5U, 0xf1U, 0x71U, 0xd8U, 0x31U, 0x15U,
1168 0x04U, 0xc7U, 0x23U, 0xc3U, 0x18U, 0x96U, 0x05U, 0x9aU,
1169 0x07U, 0x12U, 0x80U, 0xe2U, 0xebU, 0x27U, 0xb2U, 0x75U,
1170 0x09U, 0x83U, 0x2cU, 0x1aU, 0x1bU, 0x6eU, 0x5aU, 0xa0U,
1171 0x52U, 0x3bU, 0xd6U, 0xb3U, 0x29U, 0xe3U, 0x2fU, 0x84U,
1172 0x53U, 0xd1U, 0x00U, 0xedU, 0x20U, 0xfcU, 0xb1U, 0x5bU,
1173 0x6aU, 0xcbU, 0xbeU, 0x39U, 0x4aU, 0x4cU, 0x58U, 0xcfU,
1174 0xd0U, 0xefU, 0xaaU, 0xfbU, 0x43U, 0x4dU, 0x33U, 0x85U,
1175 0x45U, 0xf9U, 0x02U, 0x7fU, 0x50U, 0x3cU, 0x9fU, 0xa8U,
1176 0x51U, 0xa3U, 0x40U, 0x8fU, 0x92U, 0x9dU, 0x38U, 0xf5U,
1177 0xbcU, 0xb6U, 0xdaU, 0x21U, 0x10U, 0xffU, 0xf3U, 0xd2U,
1178 0xcdU, 0x0cU, 0x13U, 0xecU, 0x5fU, 0x97U, 0x44U, 0x17U,
1179 0xc4U, 0xa7U, 0x7eU, 0x3dU, 0x64U, 0x5dU, 0x19U, 0x73U,
1180 0x60U, 0x81U, 0x4fU, 0xdcU, 0x22U, 0x2aU, 0x90U, 0x88U,
1181 0x46U, 0xeeU, 0xb8U, 0x14U, 0xdeU, 0x5eU, 0x0bU, 0xdbU,
1182 0xe0U, 0x32U, 0x3aU, 0x0aU, 0x49U, 0x06U, 0x24U, 0x5cU,
1183 0xc2U, 0xd3U, 0xacU, 0x62U, 0x91U, 0x95U, 0xe4U, 0x79U,
1184 0xe7U, 0xc8U, 0x37U, 0x6dU, 0x8dU, 0xd5U, 0x4eU, 0xa9U,
1185 0x6cU, 0x56U, 0xf4U, 0xeaU, 0x65U, 0x7aU, 0xaeU, 0x08U,
1186 0xbaU, 0x78U, 0x25U, 0x2eU, 0x1cU, 0xa6U, 0xb4U, 0xc6U,
1187 0xe8U, 0xddU, 0x74U, 0x1fU, 0x4bU, 0xbdU, 0x8bU, 0x8aU,
1188 0x70U, 0x3eU, 0xb5U, 0x66U, 0x48U, 0x03U, 0xf6U, 0x0eU,
1189 0x61U, 0x35U, 0x57U, 0xb9U, 0x86U, 0xc1U, 0x1dU, 0x9eU,
1190 0xe1U, 0xf8U, 0x98U, 0x11U, 0x69U, 0xd9U, 0x8eU, 0x94U,
1191 0x9bU, 0x1eU, 0x87U, 0xe9U, 0xceU, 0x55U, 0x28U, 0xdfU,
1192 0x8cU, 0xa1U, 0x89U, 0x0dU, 0xbfU, 0xe6U, 0x42U, 0x68U,
1193 0x41U, 0x99U, 0x2dU, 0x0fU, 0xb0U, 0x54U, 0xbbU, 0x16U
1194};
1195static const u32 rcon[] = {
1196 0x01000000, 0x02000000, 0x04000000, 0x08000000,
1197 0x10000000, 0x20000000, 0x40000000, 0x80000000,
1198 0x1B000000, 0x36000000, /* for 128-bit blocks, Rijndael never uses more than 10 rcon values */
1199};
1200
1201/**
1202 * Expand the cipher key into the encryption key schedule.
1203 */
1204int AES_set_encrypt_key(const unsigned char *userKey, const int bits,
1205 AES_KEY *key) {
1206 u32 *rk;
1207 int i = 0;
1208 u32 temp;
1209
1210 if (!userKey || !key)
1211 return -1;
1212 if (bits != 128 && bits != 192 && bits != 256)
1213 return -2;
1214
1215 rk = key->rd_key;
1216
1217 if (bits==128)
1218 key->rounds = 10;
1219 else if (bits==192)
1220 key->rounds = 12;
1221 else
1222 key->rounds = 14;
1223
1224 rk[0] = GETU32(userKey );
1225 rk[1] = GETU32(userKey + 4);
1226 rk[2] = GETU32(userKey + 8);
1227 rk[3] = GETU32(userKey + 12);
1228 if (bits == 128) {
1229 while (1) {
1230 temp = rk[3];
1231 rk[4] = rk[0] ^
1232 (Te4[(temp >> 16) & 0xff] << 24) ^
1233 (Te4[(temp >> 8) & 0xff] << 16) ^
1234 (Te4[(temp ) & 0xff] << 8) ^
1235 (Te4[(temp >> 24) ]) ^
1236 rcon[i];
1237 rk[5] = rk[1] ^ rk[4];
1238 rk[6] = rk[2] ^ rk[5];
1239 rk[7] = rk[3] ^ rk[6];
1240 if (++i == 10) {
1241 return 0;
1242 }
1243 rk += 4;
1244 }
1245 }
1246 rk[4] = GETU32(userKey + 16);
1247 rk[5] = GETU32(userKey + 20);
1248 if (bits == 192) {
1249 while (1) {
1250 temp = rk[ 5];
1251 rk[ 6] = rk[ 0] ^
1252 (Te4[(temp >> 16) & 0xff] << 24) ^
1253 (Te4[(temp >> 8) & 0xff] << 16) ^
1254 (Te4[(temp ) & 0xff] << 8) ^
1255 (Te4[(temp >> 24) ]) ^
1256 rcon[i];
1257 rk[ 7] = rk[ 1] ^ rk[ 6];
1258 rk[ 8] = rk[ 2] ^ rk[ 7];
1259 rk[ 9] = rk[ 3] ^ rk[ 8];
1260 if (++i == 8) {
1261 return 0;
1262 }
1263 rk[10] = rk[ 4] ^ rk[ 9];
1264 rk[11] = rk[ 5] ^ rk[10];
1265 rk += 6;
1266 }
1267 }
1268 rk[6] = GETU32(userKey + 24);
1269 rk[7] = GETU32(userKey + 28);
1270 if (bits == 256) {
1271 while (1) {
1272 temp = rk[ 7];
1273 rk[ 8] = rk[ 0] ^
1274 (Te4[(temp >> 16) & 0xff] << 24) ^
1275 (Te4[(temp >> 8) & 0xff] << 16) ^
1276 (Te4[(temp ) & 0xff] << 8) ^
1277 (Te4[(temp >> 24) ]) ^
1278 rcon[i];
1279 rk[ 9] = rk[ 1] ^ rk[ 8];
1280 rk[10] = rk[ 2] ^ rk[ 9];
1281 rk[11] = rk[ 3] ^ rk[10];
1282 if (++i == 7) {
1283 return 0;
1284 }
1285 temp = rk[11];
1286 rk[12] = rk[ 4] ^
1287 (Te4[(temp >> 24) ] << 24) ^
1288 (Te4[(temp >> 16) & 0xff] << 16) ^
1289 (Te4[(temp >> 8) & 0xff] << 8) ^
1290 (Te4[(temp ) & 0xff]);
1291 rk[13] = rk[ 5] ^ rk[12];
1292 rk[14] = rk[ 6] ^ rk[13];
1293 rk[15] = rk[ 7] ^ rk[14];
1294
1295 rk += 8;
1296 }
1297 }
1298 return 0;
1299}
1300
1301/**
1302 * Expand the cipher key into the decryption key schedule.
1303 */
1304int AES_set_decrypt_key(const unsigned char *userKey, const int bits,
1305 AES_KEY *key) {
1306
1307 u32 *rk;
1308 int i, j, status;
1309 u32 temp;
1310
1311 /* first, start with an encryption schedule */
1312 status = AES_set_encrypt_key(userKey, bits, key);
1313 if (status < 0)
1314 return status;
1315
1316 rk = key->rd_key;
1317
1318 /* invert the order of the round keys: */
1319 for (i = 0, j = 4*(key->rounds); i < j; i += 4, j -= 4) {
1320 temp = rk[i ]; rk[i ] = rk[j ]; rk[j ] = temp;
1321 temp = rk[i + 1]; rk[i + 1] = rk[j + 1]; rk[j + 1] = temp;
1322 temp = rk[i + 2]; rk[i + 2] = rk[j + 2]; rk[j + 2] = temp;
1323 temp = rk[i + 3]; rk[i + 3] = rk[j + 3]; rk[j + 3] = temp;
1324 }
1325 /* apply the inverse MixColumn transform to all round keys but the first and the last: */
1326 for (i = 1; i < (key->rounds); i++) {
1327 rk += 4;
1328 for (j = 0; j < 4; j++) {
1329 u32 tp1, tp2, tp4, tp8, tp9, tpb, tpd, tpe, m;
1330
1331 tp1 = rk[j];
1332 m = tp1 & 0x80808080;
1333 tp2 = ((tp1 & 0x7f7f7f7f) << 1) ^
1334 ((m - (m >> 7)) & 0x1b1b1b1b);
1335 m = tp2 & 0x80808080;
1336 tp4 = ((tp2 & 0x7f7f7f7f) << 1) ^
1337 ((m - (m >> 7)) & 0x1b1b1b1b);
1338 m = tp4 & 0x80808080;
1339 tp8 = ((tp4 & 0x7f7f7f7f) << 1) ^
1340 ((m - (m >> 7)) & 0x1b1b1b1b);
1341 tp9 = tp8 ^ tp1;
1342 tpb = tp9 ^ tp2;
1343 tpd = tp9 ^ tp4;
1344 tpe = tp8 ^ tp4 ^ tp2;
1345#if defined(ROTATE)
1346 rk[j] = tpe ^ ROTATE(tpd,16) ^
1347 ROTATE(tp9,24) ^ ROTATE(tpb,8);
1348#else
1349 rk[j] = tpe ^ (tpd >> 16) ^ (tpd << 16) ^
1350 (tp9 >> 8) ^ (tp9 << 24) ^
1351 (tpb >> 24) ^ (tpb << 8);
1352#endif
1353 }
1354 }
1355 return 0;
1356}
1357
1167#endif /* AES_ASM */ 1358#endif /* AES_ASM */
diff --git a/src/lib/libcrypto/aes/aes_ctr.c b/src/lib/libcrypto/aes/aes_ctr.c
index f36982be1e..7c9d165d8a 100644
--- a/src/lib/libcrypto/aes/aes_ctr.c
+++ b/src/lib/libcrypto/aes/aes_ctr.c
@@ -49,91 +49,13 @@
49 * 49 *
50 */ 50 */
51 51
52#ifndef AES_DEBUG
53# ifndef NDEBUG
54# define NDEBUG
55# endif
56#endif
57#include <assert.h>
58
59#include <openssl/aes.h> 52#include <openssl/aes.h>
60#include "aes_locl.h" 53#include <openssl/modes.h>
61
62/* NOTE: the IV/counter CTR mode is big-endian. The rest of the AES code
63 * is endian-neutral. */
64
65/* increment counter (128-bit int) by 1 */
66static void AES_ctr128_inc(unsigned char *counter) {
67 unsigned long c;
68
69 /* Grab bottom dword of counter and increment */
70 c = GETU32(counter + 12);
71 c++; c &= 0xFFFFFFFF;
72 PUTU32(counter + 12, c);
73
74 /* if no overflow, we're done */
75 if (c)
76 return;
77
78 /* Grab 1st dword of counter and increment */
79 c = GETU32(counter + 8);
80 c++; c &= 0xFFFFFFFF;
81 PUTU32(counter + 8, c);
82
83 /* if no overflow, we're done */
84 if (c)
85 return;
86
87 /* Grab 2nd dword of counter and increment */
88 c = GETU32(counter + 4);
89 c++; c &= 0xFFFFFFFF;
90 PUTU32(counter + 4, c);
91
92 /* if no overflow, we're done */
93 if (c)
94 return;
95 54
96 /* Grab top dword of counter and increment */
97 c = GETU32(counter + 0);
98 c++; c &= 0xFFFFFFFF;
99 PUTU32(counter + 0, c);
100}
101
102/* The input encrypted as though 128bit counter mode is being
103 * used. The extra state information to record how much of the
104 * 128bit block we have used is contained in *num, and the
105 * encrypted counter is kept in ecount_buf. Both *num and
106 * ecount_buf must be initialised with zeros before the first
107 * call to AES_ctr128_encrypt().
108 *
109 * This algorithm assumes that the counter is in the x lower bits
110 * of the IV (ivec), and that the application has full control over
111 * overflow and the rest of the IV. This implementation takes NO
112 * responsability for checking that the counter doesn't overflow
113 * into the rest of the IV when incremented.
114 */
115void AES_ctr128_encrypt(const unsigned char *in, unsigned char *out, 55void AES_ctr128_encrypt(const unsigned char *in, unsigned char *out,
116 const unsigned long length, const AES_KEY *key, 56 size_t length, const AES_KEY *key,
117 unsigned char ivec[AES_BLOCK_SIZE], 57 unsigned char ivec[AES_BLOCK_SIZE],
118 unsigned char ecount_buf[AES_BLOCK_SIZE], 58 unsigned char ecount_buf[AES_BLOCK_SIZE],
119 unsigned int *num) { 59 unsigned int *num) {
120 60 CRYPTO_ctr128_encrypt(in,out,length,key,ivec,ecount_buf,num,(block128_f)AES_encrypt);
121 unsigned int n;
122 unsigned long l=length;
123
124 assert(in && out && key && counter && num);
125 assert(*num < AES_BLOCK_SIZE);
126
127 n = *num;
128
129 while (l--) {
130 if (n == 0) {
131 AES_encrypt(ivec, ecount_buf, key);
132 AES_ctr128_inc(ivec);
133 }
134 *(out++) = *(in++) ^ ecount_buf[n];
135 n = (n+1) % AES_BLOCK_SIZE;
136 }
137
138 *num=n;
139} 61}
diff --git a/src/lib/libcrypto/aes/aes_ofb.c b/src/lib/libcrypto/aes/aes_ofb.c
index f358bb39e2..50bf0b8325 100644
--- a/src/lib/libcrypto/aes/aes_ofb.c
+++ b/src/lib/libcrypto/aes/aes_ofb.c
@@ -1,6 +1,6 @@
1/* crypto/aes/aes_ofb.c -*- mode:C; c-file-style: "eay" -*- */ 1/* crypto/aes/aes_ofb.c -*- mode:C; c-file-style: "eay" -*- */
2/* ==================================================================== 2/* ====================================================================
3 * Copyright (c) 1998-2002 The OpenSSL Project. All rights reserved. 3 * Copyright (c) 2002-2006 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
@@ -48,95 +48,13 @@
48 * ==================================================================== 48 * ====================================================================
49 * 49 *
50 */ 50 */
51/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
52 * All rights reserved.
53 *
54 * This package is an SSL implementation written
55 * by Eric Young (eay@cryptsoft.com).
56 * The implementation was written so as to conform with Netscapes SSL.
57 *
58 * This library is free for commercial and non-commercial use as long as
59 * the following conditions are aheared to. The following conditions
60 * apply to all code found in this distribution, be it the RC4, RSA,
61 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
62 * included with this distribution is covered by the same copyright terms
63 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
64 *
65 * Copyright remains Eric Young's, and as such any Copyright notices in
66 * the code are not to be removed.
67 * If this package is used in a product, Eric Young should be given attribution
68 * as the author of the parts of the library used.
69 * This can be in the form of a textual message at program startup or
70 * in documentation (online or textual) provided with the package.
71 *
72 * Redistribution and use in source and binary forms, with or without
73 * modification, are permitted provided that the following conditions
74 * are met:
75 * 1. Redistributions of source code must retain the copyright
76 * notice, this list of conditions and the following disclaimer.
77 * 2. Redistributions in binary form must reproduce the above copyright
78 * notice, this list of conditions and the following disclaimer in the
79 * documentation and/or other materials provided with the distribution.
80 * 3. All advertising materials mentioning features or use of this software
81 * must display the following acknowledgement:
82 * "This product includes cryptographic software written by
83 * Eric Young (eay@cryptsoft.com)"
84 * The word 'cryptographic' can be left out if the rouines from the library
85 * being used are not cryptographic related :-).
86 * 4. If you include any Windows specific code (or a derivative thereof) from
87 * the apps directory (application code) you must include an acknowledgement:
88 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
89 *
90 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
91 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
92 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
93 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
94 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
95 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
96 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
97 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
98 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
99 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
100 * SUCH DAMAGE.
101 *
102 * The licence and distribution terms for any publically available version or
103 * derivative of this code cannot be changed. i.e. this code cannot simply be
104 * copied and put under another distribution licence
105 * [including the GNU Public Licence.]
106 */
107
108#ifndef AES_DEBUG
109# ifndef NDEBUG
110# define NDEBUG
111# endif
112#endif
113#include <assert.h>
114 51
115#include <openssl/aes.h> 52#include <openssl/aes.h>
116#include "aes_locl.h" 53#include <openssl/modes.h>
117 54
118/* The input and output encrypted as though 128bit ofb mode is being
119 * used. The extra state information to record how much of the
120 * 128bit block we have used is contained in *num;
121 */
122void AES_ofb128_encrypt(const unsigned char *in, unsigned char *out, 55void AES_ofb128_encrypt(const unsigned char *in, unsigned char *out,
123 const unsigned long length, const AES_KEY *key, 56 size_t length, const AES_KEY *key,
124 unsigned char *ivec, int *num) { 57 unsigned char *ivec, int *num)
125 58{
126 unsigned int n; 59 CRYPTO_ofb128_encrypt(in,out,length,key,ivec,num,(block128_f)AES_encrypt);
127 unsigned long l=length;
128
129 assert(in && out && key && ivec && num);
130
131 n = *num;
132
133 while (l--) {
134 if (n == 0) {
135 AES_encrypt(ivec, ivec, key);
136 }
137 *(out++) = *(in++) ^ ivec[n];
138 n = (n+1) % AES_BLOCK_SIZE;
139 }
140
141 *num=n;
142} 60}
diff --git a/src/lib/libcrypto/aes/asm/aes-586.pl b/src/lib/libcrypto/aes/asm/aes-586.pl
index e771e83953..aab40e6f1c 100644
--- a/src/lib/libcrypto/aes/asm/aes-586.pl
+++ b/src/lib/libcrypto/aes/asm/aes-586.pl
@@ -2,11 +2,12 @@
2# 2#
3# ==================================================================== 3# ====================================================================
4# Written by Andy Polyakov <appro@fy.chalmers.se> for the OpenSSL 4# Written by Andy Polyakov <appro@fy.chalmers.se> for the OpenSSL
5# project. Rights for redistribution and usage in source and binary 5# project. The module is, however, dual licensed under OpenSSL and
6# forms are granted according to the OpenSSL license. 6# CRYPTOGAMS licenses depending on where you obtain it. For further
7# details see http://www.openssl.org/~appro/cryptogams/.
7# ==================================================================== 8# ====================================================================
8# 9#
9# Version 3.6. 10# Version 4.3.
10# 11#
11# You might fail to appreciate this module performance from the first 12# You might fail to appreciate this module performance from the first
12# try. If compared to "vanilla" linux-ia32-icc target, i.e. considered 13# try. If compared to "vanilla" linux-ia32-icc target, i.e. considered
@@ -81,11 +82,117 @@
81# AMD K8 20 19 82# AMD K8 20 19
82# PIII 25 23 83# PIII 25 23
83# Pentium 81 78 84# Pentium 81 78
84 85#
85push(@INC,"perlasm","../../perlasm"); 86# Version 3.7 reimplements outer rounds as "compact." Meaning that
87# first and last rounds reference compact 256 bytes S-box. This means
88# that first round consumes a lot more CPU cycles and that encrypt
89# and decrypt performance becomes asymmetric. Encrypt performance
90# drops by 10-12%, while decrypt - by 20-25%:-( 256 bytes S-box is
91# aggressively pre-fetched.
92#
93# Version 4.0 effectively rolls back to 3.6 and instead implements
94# additional set of functions, _[x86|sse]_AES_[en|de]crypt_compact,
95# which use exclusively 256 byte S-box. These functions are to be
96# called in modes not concealing plain text, such as ECB, or when
97# we're asked to process smaller amount of data [or unconditionally
98# on hyper-threading CPU]. Currently it's called unconditionally from
99# AES_[en|de]crypt, which affects all modes, but CBC. CBC routine
100# still needs to be modified to switch between slower and faster
101# mode when appropriate... But in either case benchmark landscape
102# changes dramatically and below numbers are CPU cycles per processed
103# byte for 128-bit key.
104#
105# ECB encrypt ECB decrypt CBC large chunk
106# P4 56[60] 84[100] 23
107# AMD K8 48[44] 70[79] 18
108# PIII 41[50] 61[91] 24
109# Core 2 32[38] 45[70] 18.5
110# Pentium 120 160 77
111#
112# Version 4.1 switches to compact S-box even in key schedule setup.
113#
114# Version 4.2 prefetches compact S-box in every SSE round or in other
115# words every cache-line is *guaranteed* to be accessed within ~50
116# cycles window. Why just SSE? Because it's needed on hyper-threading
117# CPU! Which is also why it's prefetched with 64 byte stride. Best
118# part is that it has no negative effect on performance:-)
119#
120# Version 4.3 implements switch between compact and non-compact block
121# functions in AES_cbc_encrypt depending on how much data was asked
122# to be processed in one stroke.
123#
124######################################################################
125# Timing attacks are classified in two classes: synchronous when
126# attacker consciously initiates cryptographic operation and collects
127# timing data of various character afterwards, and asynchronous when
128# malicious code is executed on same CPU simultaneously with AES,
129# instruments itself and performs statistical analysis of this data.
130#
131# As far as synchronous attacks go the root to the AES timing
132# vulnerability is twofold. Firstly, of 256 S-box elements at most 160
133# are referred to in single 128-bit block operation. Well, in C
134# implementation with 4 distinct tables it's actually as little as 40
135# references per 256 elements table, but anyway... Secondly, even
136# though S-box elements are clustered into smaller amount of cache-
137# lines, smaller than 160 and even 40, it turned out that for certain
138# plain-text pattern[s] or simply put chosen plain-text and given key
139# few cache-lines remain unaccessed during block operation. Now, if
140# attacker can figure out this access pattern, he can deduct the key
141# [or at least part of it]. The natural way to mitigate this kind of
142# attacks is to minimize the amount of cache-lines in S-box and/or
143# prefetch them to ensure that every one is accessed for more uniform
144# timing. But note that *if* plain-text was concealed in such way that
145# input to block function is distributed *uniformly*, then attack
146# wouldn't apply. Now note that some encryption modes, most notably
147# CBC, do mask the plain-text in this exact way [secure cipher output
148# is distributed uniformly]. Yes, one still might find input that
149# would reveal the information about given key, but if amount of
150# candidate inputs to be tried is larger than amount of possible key
151# combinations then attack becomes infeasible. This is why revised
152# AES_cbc_encrypt "dares" to switch to larger S-box when larger chunk
153# of data is to be processed in one stroke. The current size limit of
154# 512 bytes is chosen to provide same [diminishigly low] probability
155# for cache-line to remain untouched in large chunk operation with
156# large S-box as for single block operation with compact S-box and
157# surely needs more careful consideration...
158#
159# As for asynchronous attacks. There are two flavours: attacker code
160# being interleaved with AES on hyper-threading CPU at *instruction*
161# level, and two processes time sharing single core. As for latter.
162# Two vectors. 1. Given that attacker process has higher priority,
163# yield execution to process performing AES just before timer fires
164# off the scheduler, immediately regain control of CPU and analyze the
165# cache state. For this attack to be efficient attacker would have to
166# effectively slow down the operation by several *orders* of magnitute,
167# by ratio of time slice to duration of handful of AES rounds, which
168# unlikely to remain unnoticed. Not to mention that this also means
169# that he would spend correspondigly more time to collect enough
170# statistical data to mount the attack. It's probably appropriate to
171# say that if adeversary reckons that this attack is beneficial and
172# risks to be noticed, you probably have larger problems having him
173# mere opportunity. In other words suggested code design expects you
174# to preclude/mitigate this attack by overall system security design.
175# 2. Attacker manages to make his code interrupt driven. In order for
176# this kind of attack to be feasible, interrupt rate has to be high
177# enough, again comparable to duration of handful of AES rounds. But
178# is there interrupt source of such rate? Hardly, not even 1Gbps NIC
179# generates interrupts at such raging rate...
180#
181# And now back to the former, hyper-threading CPU or more specifically
182# Intel P4. Recall that asynchronous attack implies that malicious
183# code instruments itself. And naturally instrumentation granularity
184# has be noticeably lower than duration of codepath accessing S-box.
185# Given that all cache-lines are accessed during that time that is.
186# Current implementation accesses *all* cache-lines within ~50 cycles
187# window, which is actually *less* than RDTSC latency on Intel P4!
188
189$0 =~ m/(.*[\/\\])[^\/\\]+$/; $dir=$1;
190push(@INC,"${dir}","${dir}../../perlasm");
86require "x86asm.pl"; 191require "x86asm.pl";
87 192
88&asm_init($ARGV[0],"aes-586.pl",$ARGV[$#ARGV] eq "386"); 193&asm_init($ARGV[0],"aes-586.pl",$x86only = $ARGV[$#ARGV] eq "386");
194&static_label("AES_Te");
195&static_label("AES_Td");
89 196
90$s0="eax"; 197$s0="eax";
91$s1="ebx"; 198$s1="ebx";
@@ -93,21 +200,36 @@ $s2="ecx";
93$s3="edx"; 200$s3="edx";
94$key="edi"; 201$key="edi";
95$acc="esi"; 202$acc="esi";
203$tbl="ebp";
204
205# stack frame layout in _[x86|sse]_AES_* routines, frame is allocated
206# by caller
207$__ra=&DWP(0,"esp"); # return address
208$__s0=&DWP(4,"esp"); # s0 backing store
209$__s1=&DWP(8,"esp"); # s1 backing store
210$__s2=&DWP(12,"esp"); # s2 backing store
211$__s3=&DWP(16,"esp"); # s3 backing store
212$__key=&DWP(20,"esp"); # pointer to key schedule
213$__end=&DWP(24,"esp"); # pointer to end of key schedule
214$__tbl=&DWP(28,"esp"); # %ebp backing store
215
216# stack frame layout in AES_[en|crypt] routines, which differs from
217# above by 4 and overlaps by %ebp backing store
218$_tbl=&DWP(24,"esp");
219$_esp=&DWP(28,"esp");
96 220
97$compromise=0; # $compromise=128 abstains from copying key 221sub _data_word() { my $i; while(defined($i=shift)) { &data_word($i,$i); } }
98 # schedule to stack when encrypting inputs 222
99 # shorter than 128 bytes at the cost of 223$speed_limit=512; # chunks smaller than $speed_limit are
100 # risksing aliasing with S-boxes. In return 224 # processed with compact routine in CBC mode
101 # you get way better, up to +70%, small block
102 # performance.
103$small_footprint=1; # $small_footprint=1 code is ~5% slower [on 225$small_footprint=1; # $small_footprint=1 code is ~5% slower [on
104 # recent µ-archs], but ~5 times smaller! 226 # recent µ-archs], but ~5 times smaller!
105 # I favor compact code to minimize cache 227 # I favor compact code to minimize cache
106 # contention and in hope to "collect" 5% back 228 # contention and in hope to "collect" 5% back
107 # in real-life applications... 229 # in real-life applications...
230
108$vertical_spin=0; # shift "verticaly" defaults to 0, because of 231$vertical_spin=0; # shift "verticaly" defaults to 0, because of
109 # its proof-of-concept status... 232 # its proof-of-concept status...
110
111# Note that there is no decvert(), as well as last encryption round is 233# Note that there is no decvert(), as well as last encryption round is
112# performed with "horizontal" shifts. This is because this "vertical" 234# performed with "horizontal" shifts. This is because this "vertical"
113# implementation [one which groups shifts on a given $s[i] to form a 235# implementation [one which groups shifts on a given $s[i] to form a
@@ -170,17 +292,484 @@ sub encvert()
170 &movz ($v0,&HB($v1)); 292 &movz ($v0,&HB($v1));
171 &and ($v1,0xFF); 293 &and ($v1,0xFF);
172 &xor ($s[3],&DWP(2,$te,$v1,8)); # s1>>16 294 &xor ($s[3],&DWP(2,$te,$v1,8)); # s1>>16
173 &mov ($key,&DWP(12,"esp")); # reincarnate v1 as key 295 &mov ($key,$__key); # reincarnate v1 as key
174 &xor ($s[2],&DWP(1,$te,$v0,8)); # s1>>24 296 &xor ($s[2],&DWP(1,$te,$v0,8)); # s1>>24
175} 297}
176 298
299# Another experimental routine, which features "horizontal spin," but
300# eliminates one reference to stack. Strangely enough runs slower...
301sub enchoriz()
302{ my $v0 = $key, $v1 = $acc;
303
304 &movz ($v0,&LB($s0)); # 3, 2, 1, 0*
305 &rotr ($s2,8); # 8,11,10, 9
306 &mov ($v1,&DWP(0,$te,$v0,8)); # 0
307 &movz ($v0,&HB($s1)); # 7, 6, 5*, 4
308 &rotr ($s3,16); # 13,12,15,14
309 &xor ($v1,&DWP(3,$te,$v0,8)); # 5
310 &movz ($v0,&HB($s2)); # 8,11,10*, 9
311 &rotr ($s0,16); # 1, 0, 3, 2
312 &xor ($v1,&DWP(2,$te,$v0,8)); # 10
313 &movz ($v0,&HB($s3)); # 13,12,15*,14
314 &xor ($v1,&DWP(1,$te,$v0,8)); # 15, t[0] collected
315 &mov ($__s0,$v1); # t[0] saved
316
317 &movz ($v0,&LB($s1)); # 7, 6, 5, 4*
318 &shr ($s1,16); # -, -, 7, 6
319 &mov ($v1,&DWP(0,$te,$v0,8)); # 4
320 &movz ($v0,&LB($s3)); # 13,12,15,14*
321 &xor ($v1,&DWP(2,$te,$v0,8)); # 14
322 &movz ($v0,&HB($s0)); # 1, 0, 3*, 2
323 &and ($s3,0xffff0000); # 13,12, -, -
324 &xor ($v1,&DWP(1,$te,$v0,8)); # 3
325 &movz ($v0,&LB($s2)); # 8,11,10, 9*
326 &or ($s3,$s1); # 13,12, 7, 6
327 &xor ($v1,&DWP(3,$te,$v0,8)); # 9, t[1] collected
328 &mov ($s1,$v1); # s[1]=t[1]
329
330 &movz ($v0,&LB($s0)); # 1, 0, 3, 2*
331 &shr ($s2,16); # -, -, 8,11
332 &mov ($v1,&DWP(2,$te,$v0,8)); # 2
333 &movz ($v0,&HB($s3)); # 13,12, 7*, 6
334 &xor ($v1,&DWP(1,$te,$v0,8)); # 7
335 &movz ($v0,&HB($s2)); # -, -, 8*,11
336 &xor ($v1,&DWP(0,$te,$v0,8)); # 8
337 &mov ($v0,$s3);
338 &shr ($v0,24); # 13
339 &xor ($v1,&DWP(3,$te,$v0,8)); # 13, t[2] collected
340
341 &movz ($v0,&LB($s2)); # -, -, 8,11*
342 &shr ($s0,24); # 1*
343 &mov ($s2,&DWP(1,$te,$v0,8)); # 11
344 &xor ($s2,&DWP(3,$te,$s0,8)); # 1
345 &mov ($s0,$__s0); # s[0]=t[0]
346 &movz ($v0,&LB($s3)); # 13,12, 7, 6*
347 &shr ($s3,16); # , ,13,12
348 &xor ($s2,&DWP(2,$te,$v0,8)); # 6
349 &mov ($key,$__key); # reincarnate v0 as key
350 &and ($s3,0xff); # , ,13,12*
351 &mov ($s3,&DWP(0,$te,$s3,8)); # 12
352 &xor ($s3,$s2); # s[2]=t[3] collected
353 &mov ($s2,$v1); # s[2]=t[2]
354}
355
356# More experimental code... SSE one... Even though this one eliminates
357# *all* references to stack, it's not faster...
358sub sse_encbody()
359{
360 &movz ($acc,&LB("eax")); # 0
361 &mov ("ecx",&DWP(0,$tbl,$acc,8)); # 0
362 &pshufw ("mm2","mm0",0x0d); # 7, 6, 3, 2
363 &movz ("edx",&HB("eax")); # 1
364 &mov ("edx",&DWP(3,$tbl,"edx",8)); # 1
365 &shr ("eax",16); # 5, 4
366
367 &movz ($acc,&LB("ebx")); # 10
368 &xor ("ecx",&DWP(2,$tbl,$acc,8)); # 10
369 &pshufw ("mm6","mm4",0x08); # 13,12, 9, 8
370 &movz ($acc,&HB("ebx")); # 11
371 &xor ("edx",&DWP(1,$tbl,$acc,8)); # 11
372 &shr ("ebx",16); # 15,14
373
374 &movz ($acc,&HB("eax")); # 5
375 &xor ("ecx",&DWP(3,$tbl,$acc,8)); # 5
376 &movq ("mm3",QWP(16,$key));
377 &movz ($acc,&HB("ebx")); # 15
378 &xor ("ecx",&DWP(1,$tbl,$acc,8)); # 15
379 &movd ("mm0","ecx"); # t[0] collected
380
381 &movz ($acc,&LB("eax")); # 4
382 &mov ("ecx",&DWP(0,$tbl,$acc,8)); # 4
383 &movd ("eax","mm2"); # 7, 6, 3, 2
384 &movz ($acc,&LB("ebx")); # 14
385 &xor ("ecx",&DWP(2,$tbl,$acc,8)); # 14
386 &movd ("ebx","mm6"); # 13,12, 9, 8
387
388 &movz ($acc,&HB("eax")); # 3
389 &xor ("ecx",&DWP(1,$tbl,$acc,8)); # 3
390 &movz ($acc,&HB("ebx")); # 9
391 &xor ("ecx",&DWP(3,$tbl,$acc,8)); # 9
392 &movd ("mm1","ecx"); # t[1] collected
393
394 &movz ($acc,&LB("eax")); # 2
395 &mov ("ecx",&DWP(2,$tbl,$acc,8)); # 2
396 &shr ("eax",16); # 7, 6
397 &punpckldq ("mm0","mm1"); # t[0,1] collected
398 &movz ($acc,&LB("ebx")); # 8
399 &xor ("ecx",&DWP(0,$tbl,$acc,8)); # 8
400 &shr ("ebx",16); # 13,12
401
402 &movz ($acc,&HB("eax")); # 7
403 &xor ("ecx",&DWP(1,$tbl,$acc,8)); # 7
404 &pxor ("mm0","mm3");
405 &movz ("eax",&LB("eax")); # 6
406 &xor ("edx",&DWP(2,$tbl,"eax",8)); # 6
407 &pshufw ("mm1","mm0",0x08); # 5, 4, 1, 0
408 &movz ($acc,&HB("ebx")); # 13
409 &xor ("ecx",&DWP(3,$tbl,$acc,8)); # 13
410 &xor ("ecx",&DWP(24,$key)); # t[2]
411 &movd ("mm4","ecx"); # t[2] collected
412 &movz ("ebx",&LB("ebx")); # 12
413 &xor ("edx",&DWP(0,$tbl,"ebx",8)); # 12
414 &shr ("ecx",16);
415 &movd ("eax","mm1"); # 5, 4, 1, 0
416 &mov ("ebx",&DWP(28,$key)); # t[3]
417 &xor ("ebx","edx");
418 &movd ("mm5","ebx"); # t[3] collected
419 &and ("ebx",0xffff0000);
420 &or ("ebx","ecx");
421
422 &punpckldq ("mm4","mm5"); # t[2,3] collected
423}
424
425######################################################################
426# "Compact" block function
427######################################################################
428
429sub enccompact()
430{ my $Fn = mov;
431 while ($#_>5) { pop(@_); $Fn=sub{}; }
432 my ($i,$te,@s)=@_;
433 my $tmp = $key;
434 my $out = $i==3?$s[0]:$acc;
435
436 # $Fn is used in first compact round and its purpose is to
437 # void restoration of some values from stack, so that after
438 # 4xenccompact with extra argument $key value is left there...
439 if ($i==3) { &$Fn ($key,$__key); }##%edx
440 else { &mov ($out,$s[0]); }
441 &and ($out,0xFF);
442 if ($i==1) { &shr ($s[0],16); }#%ebx[1]
443 if ($i==2) { &shr ($s[0],24); }#%ecx[2]
444 &movz ($out,&BP(-128,$te,$out,1));
445
446 if ($i==3) { $tmp=$s[1]; }##%eax
447 &movz ($tmp,&HB($s[1]));
448 &movz ($tmp,&BP(-128,$te,$tmp,1));
449 &shl ($tmp,8);
450 &xor ($out,$tmp);
451
452 if ($i==3) { $tmp=$s[2]; &mov ($s[1],$__s0); }##%ebx
453 else { &mov ($tmp,$s[2]);
454 &shr ($tmp,16); }
455 if ($i==2) { &and ($s[1],0xFF); }#%edx[2]
456 &and ($tmp,0xFF);
457 &movz ($tmp,&BP(-128,$te,$tmp,1));
458 &shl ($tmp,16);
459 &xor ($out,$tmp);
460
461 if ($i==3) { $tmp=$s[3]; &mov ($s[2],$__s1); }##%ecx
462 elsif($i==2){ &movz ($tmp,&HB($s[3])); }#%ebx[2]
463 else { &mov ($tmp,$s[3]);
464 &shr ($tmp,24); }
465 &movz ($tmp,&BP(-128,$te,$tmp,1));
466 &shl ($tmp,24);
467 &xor ($out,$tmp);
468 if ($i<2) { &mov (&DWP(4+4*$i,"esp"),$out); }
469 if ($i==3) { &mov ($s[3],$acc); }
470 &comment();
471}
472
473sub enctransform()
474{ my @s = ($s0,$s1,$s2,$s3);
475 my $i = shift;
476 my $tmp = $tbl;
477 my $r2 = $key ;
478
479 &mov ($acc,$s[$i]);
480 &and ($acc,0x80808080);
481 &mov ($tmp,$acc);
482 &shr ($tmp,7);
483 &lea ($r2,&DWP(0,$s[$i],$s[$i]));
484 &sub ($acc,$tmp);
485 &and ($r2,0xfefefefe);
486 &and ($acc,0x1b1b1b1b);
487 &mov ($tmp,$s[$i]);
488 &xor ($acc,$r2); # r2
489
490 &xor ($s[$i],$acc); # r0 ^ r2
491 &rotl ($s[$i],24);
492 &xor ($s[$i],$acc) # ROTATE(r2^r0,24) ^ r2
493 &rotr ($tmp,16);
494 &xor ($s[$i],$tmp);
495 &rotr ($tmp,8);
496 &xor ($s[$i],$tmp);
497}
498
499&function_begin_B("_x86_AES_encrypt_compact");
500 # note that caller is expected to allocate stack frame for me!
501 &mov ($__key,$key); # save key
502
503 &xor ($s0,&DWP(0,$key)); # xor with key
504 &xor ($s1,&DWP(4,$key));
505 &xor ($s2,&DWP(8,$key));
506 &xor ($s3,&DWP(12,$key));
507
508 &mov ($acc,&DWP(240,$key)); # load key->rounds
509 &lea ($acc,&DWP(-2,$acc,$acc));
510 &lea ($acc,&DWP(0,$key,$acc,8));
511 &mov ($__end,$acc); # end of key schedule
512
513 # prefetch Te4
514 &mov ($key,&DWP(0-128,$tbl));
515 &mov ($acc,&DWP(32-128,$tbl));
516 &mov ($key,&DWP(64-128,$tbl));
517 &mov ($acc,&DWP(96-128,$tbl));
518 &mov ($key,&DWP(128-128,$tbl));
519 &mov ($acc,&DWP(160-128,$tbl));
520 &mov ($key,&DWP(192-128,$tbl));
521 &mov ($acc,&DWP(224-128,$tbl));
522
523 &set_label("loop",16);
524
525 &enccompact(0,$tbl,$s0,$s1,$s2,$s3,1);
526 &enccompact(1,$tbl,$s1,$s2,$s3,$s0,1);
527 &enccompact(2,$tbl,$s2,$s3,$s0,$s1,1);
528 &enccompact(3,$tbl,$s3,$s0,$s1,$s2,1);
529 &enctransform(2);
530 &enctransform(3);
531 &enctransform(0);
532 &enctransform(1);
533 &mov ($key,$__key);
534 &mov ($tbl,$__tbl);
535 &add ($key,16); # advance rd_key
536 &xor ($s0,&DWP(0,$key));
537 &xor ($s1,&DWP(4,$key));
538 &xor ($s2,&DWP(8,$key));
539 &xor ($s3,&DWP(12,$key));
540
541 &cmp ($key,$__end);
542 &mov ($__key,$key);
543 &jb (&label("loop"));
544
545 &enccompact(0,$tbl,$s0,$s1,$s2,$s3);
546 &enccompact(1,$tbl,$s1,$s2,$s3,$s0);
547 &enccompact(2,$tbl,$s2,$s3,$s0,$s1);
548 &enccompact(3,$tbl,$s3,$s0,$s1,$s2);
549
550 &xor ($s0,&DWP(16,$key));
551 &xor ($s1,&DWP(20,$key));
552 &xor ($s2,&DWP(24,$key));
553 &xor ($s3,&DWP(28,$key));
554
555 &ret ();
556&function_end_B("_x86_AES_encrypt_compact");
557
558######################################################################
559# "Compact" SSE block function.
560######################################################################
561#
562# Performance is not actually extraordinary in comparison to pure
563# x86 code. In particular encrypt performance is virtually the same.
564# Decrypt performance on the other hand is 15-20% better on newer
565# µ-archs [but we're thankful for *any* improvement here], and ~50%
566# better on PIII:-) And additionally on the pros side this code
567# eliminates redundant references to stack and thus relieves/
568# minimizes the pressure on the memory bus.
569#
570# MMX register layout lsb
571# +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
572# | mm4 | mm0 |
573# +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
574# | s3 | s2 | s1 | s0 |
575# +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
576# |15|14|13|12|11|10| 9| 8| 7| 6| 5| 4| 3| 2| 1| 0|
577# +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
578#
579# Indexes translate as s[N/4]>>(8*(N%4)), e.g. 5 means s1>>8.
580# In this terms encryption and decryption "compact" permutation
581# matrices can be depicted as following:
582#
583# encryption lsb # decryption lsb
584# +----++----+----+----+----+ # +----++----+----+----+----+
585# | t0 || 15 | 10 | 5 | 0 | # | t0 || 7 | 10 | 13 | 0 |
586# +----++----+----+----+----+ # +----++----+----+----+----+
587# | t1 || 3 | 14 | 9 | 4 | # | t1 || 11 | 14 | 1 | 4 |
588# +----++----+----+----+----+ # +----++----+----+----+----+
589# | t2 || 7 | 2 | 13 | 8 | # | t2 || 15 | 2 | 5 | 8 |
590# +----++----+----+----+----+ # +----++----+----+----+----+
591# | t3 || 11 | 6 | 1 | 12 | # | t3 || 3 | 6 | 9 | 12 |
592# +----++----+----+----+----+ # +----++----+----+----+----+
593#
594######################################################################
595# Why not xmm registers? Short answer. It was actually tested and
596# was not any faster, but *contrary*, most notably on Intel CPUs.
597# Longer answer. Main advantage of using mm registers is that movd
598# latency is lower, especially on Intel P4. While arithmetic
599# instructions are twice as many, they can be scheduled every cycle
600# and not every second one when they are operating on xmm register,
601# so that "arithmetic throughput" remains virtually the same. And
602# finally the code can be executed even on elder SSE-only CPUs:-)
603
604sub sse_enccompact()
605{
606 &pshufw ("mm1","mm0",0x08); # 5, 4, 1, 0
607 &pshufw ("mm5","mm4",0x0d); # 15,14,11,10
608 &movd ("eax","mm1"); # 5, 4, 1, 0
609 &movd ("ebx","mm5"); # 15,14,11,10
610
611 &movz ($acc,&LB("eax")); # 0
612 &movz ("ecx",&BP(-128,$tbl,$acc,1)); # 0
613 &pshufw ("mm2","mm0",0x0d); # 7, 6, 3, 2
614 &movz ("edx",&HB("eax")); # 1
615 &movz ("edx",&BP(-128,$tbl,"edx",1)); # 1
616 &shl ("edx",8); # 1
617 &shr ("eax",16); # 5, 4
618
619 &movz ($acc,&LB("ebx")); # 10
620 &movz ($acc,&BP(-128,$tbl,$acc,1)); # 10
621 &shl ($acc,16); # 10
622 &or ("ecx",$acc); # 10
623 &pshufw ("mm6","mm4",0x08); # 13,12, 9, 8
624 &movz ($acc,&HB("ebx")); # 11
625 &movz ($acc,&BP(-128,$tbl,$acc,1)); # 11
626 &shl ($acc,24); # 11
627 &or ("edx",$acc); # 11
628 &shr ("ebx",16); # 15,14
629
630 &movz ($acc,&HB("eax")); # 5
631 &movz ($acc,&BP(-128,$tbl,$acc,1)); # 5
632 &shl ($acc,8); # 5
633 &or ("ecx",$acc); # 5
634 &movz ($acc,&HB("ebx")); # 15
635 &movz ($acc,&BP(-128,$tbl,$acc,1)); # 15
636 &shl ($acc,24); # 15
637 &or ("ecx",$acc); # 15
638 &movd ("mm0","ecx"); # t[0] collected
639
640 &movz ($acc,&LB("eax")); # 4
641 &movz ("ecx",&BP(-128,$tbl,$acc,1)); # 4
642 &movd ("eax","mm2"); # 7, 6, 3, 2
643 &movz ($acc,&LB("ebx")); # 14
644 &movz ($acc,&BP(-128,$tbl,$acc,1)); # 14
645 &shl ($acc,16); # 14
646 &or ("ecx",$acc); # 14
647
648 &movd ("ebx","mm6"); # 13,12, 9, 8
649 &movz ($acc,&HB("eax")); # 3
650 &movz ($acc,&BP(-128,$tbl,$acc,1)); # 3
651 &shl ($acc,24); # 3
652 &or ("ecx",$acc); # 3
653 &movz ($acc,&HB("ebx")); # 9
654 &movz ($acc,&BP(-128,$tbl,$acc,1)); # 9
655 &shl ($acc,8); # 9
656 &or ("ecx",$acc); # 9
657 &movd ("mm1","ecx"); # t[1] collected
658
659 &movz ($acc,&LB("ebx")); # 8
660 &movz ("ecx",&BP(-128,$tbl,$acc,1)); # 8
661 &shr ("ebx",16); # 13,12
662 &movz ($acc,&LB("eax")); # 2
663 &movz ($acc,&BP(-128,$tbl,$acc,1)); # 2
664 &shl ($acc,16); # 2
665 &or ("ecx",$acc); # 2
666 &shr ("eax",16); # 7, 6
667
668 &punpckldq ("mm0","mm1"); # t[0,1] collected
669
670 &movz ($acc,&HB("eax")); # 7
671 &movz ($acc,&BP(-128,$tbl,$acc,1)); # 7
672 &shl ($acc,24); # 7
673 &or ("ecx",$acc); # 7
674 &and ("eax",0xff); # 6
675 &movz ("eax",&BP(-128,$tbl,"eax",1)); # 6
676 &shl ("eax",16); # 6
677 &or ("edx","eax"); # 6
678 &movz ($acc,&HB("ebx")); # 13
679 &movz ($acc,&BP(-128,$tbl,$acc,1)); # 13
680 &shl ($acc,8); # 13
681 &or ("ecx",$acc); # 13
682 &movd ("mm4","ecx"); # t[2] collected
683 &and ("ebx",0xff); # 12
684 &movz ("ebx",&BP(-128,$tbl,"ebx",1)); # 12
685 &or ("edx","ebx"); # 12
686 &movd ("mm5","edx"); # t[3] collected
687
688 &punpckldq ("mm4","mm5"); # t[2,3] collected
689}
690
691 if (!$x86only) {
692&function_begin_B("_sse_AES_encrypt_compact");
693 &pxor ("mm0",&QWP(0,$key)); # 7, 6, 5, 4, 3, 2, 1, 0
694 &pxor ("mm4",&QWP(8,$key)); # 15,14,13,12,11,10, 9, 8
695
696 # note that caller is expected to allocate stack frame for me!
697 &mov ($acc,&DWP(240,$key)); # load key->rounds
698 &lea ($acc,&DWP(-2,$acc,$acc));
699 &lea ($acc,&DWP(0,$key,$acc,8));
700 &mov ($__end,$acc); # end of key schedule
701
702 &mov ($s0,0x1b1b1b1b); # magic constant
703 &mov (&DWP(8,"esp"),$s0);
704 &mov (&DWP(12,"esp"),$s0);
705
706 # prefetch Te4
707 &mov ($s0,&DWP(0-128,$tbl));
708 &mov ($s1,&DWP(32-128,$tbl));
709 &mov ($s2,&DWP(64-128,$tbl));
710 &mov ($s3,&DWP(96-128,$tbl));
711 &mov ($s0,&DWP(128-128,$tbl));
712 &mov ($s1,&DWP(160-128,$tbl));
713 &mov ($s2,&DWP(192-128,$tbl));
714 &mov ($s3,&DWP(224-128,$tbl));
715
716 &set_label("loop",16);
717 &sse_enccompact();
718 &add ($key,16);
719 &cmp ($key,$__end);
720 &ja (&label("out"));
721
722 &movq ("mm2",&QWP(8,"esp"));
723 &pxor ("mm3","mm3"); &pxor ("mm7","mm7");
724 &movq ("mm1","mm0"); &movq ("mm5","mm4"); # r0
725 &pcmpgtb("mm3","mm0"); &pcmpgtb("mm7","mm4");
726 &pand ("mm3","mm2"); &pand ("mm7","mm2");
727 &pshufw ("mm2","mm0",0xb1); &pshufw ("mm6","mm4",0xb1);# ROTATE(r0,16)
728 &paddb ("mm0","mm0"); &paddb ("mm4","mm4");
729 &pxor ("mm0","mm3"); &pxor ("mm4","mm7"); # = r2
730 &pshufw ("mm3","mm2",0xb1); &pshufw ("mm7","mm6",0xb1);# r0
731 &pxor ("mm1","mm0"); &pxor ("mm5","mm4"); # r0^r2
732 &pxor ("mm0","mm2"); &pxor ("mm4","mm6"); # ^= ROTATE(r0,16)
733
734 &movq ("mm2","mm3"); &movq ("mm6","mm7");
735 &pslld ("mm3",8); &pslld ("mm7",8);
736 &psrld ("mm2",24); &psrld ("mm6",24);
737 &pxor ("mm0","mm3"); &pxor ("mm4","mm7"); # ^= r0<<8
738 &pxor ("mm0","mm2"); &pxor ("mm4","mm6"); # ^= r0>>24
739
740 &movq ("mm3","mm1"); &movq ("mm7","mm5");
741 &movq ("mm2",&QWP(0,$key)); &movq ("mm6",&QWP(8,$key));
742 &psrld ("mm1",8); &psrld ("mm5",8);
743 &mov ($s0,&DWP(0-128,$tbl));
744 &pslld ("mm3",24); &pslld ("mm7",24);
745 &mov ($s1,&DWP(64-128,$tbl));
746 &pxor ("mm0","mm1"); &pxor ("mm4","mm5"); # ^= (r2^r0)<<8
747 &mov ($s2,&DWP(128-128,$tbl));
748 &pxor ("mm0","mm3"); &pxor ("mm4","mm7"); # ^= (r2^r0)>>24
749 &mov ($s3,&DWP(192-128,$tbl));
750
751 &pxor ("mm0","mm2"); &pxor ("mm4","mm6");
752 &jmp (&label("loop"));
753
754 &set_label("out",16);
755 &pxor ("mm0",&QWP(0,$key));
756 &pxor ("mm4",&QWP(8,$key));
757
758 &ret ();
759&function_end_B("_sse_AES_encrypt_compact");
760 }
761
762######################################################################
763# Vanilla block function.
764######################################################################
765
177sub encstep() 766sub encstep()
178{ my ($i,$te,@s) = @_; 767{ my ($i,$te,@s) = @_;
179 my $tmp = $key; 768 my $tmp = $key;
180 my $out = $i==3?$s[0]:$acc; 769 my $out = $i==3?$s[0]:$acc;
181 770
182 # lines marked with #%e?x[i] denote "reordered" instructions... 771 # lines marked with #%e?x[i] denote "reordered" instructions...
183 if ($i==3) { &mov ($key,&DWP(12,"esp")); }##%edx 772 if ($i==3) { &mov ($key,$__key); }##%edx
184 else { &mov ($out,$s[0]); 773 else { &mov ($out,$s[0]);
185 &and ($out,0xFF); } 774 &and ($out,0xFF); }
186 if ($i==1) { &shr ($s[0],16); }#%ebx[1] 775 if ($i==1) { &shr ($s[0],16); }#%ebx[1]
@@ -191,14 +780,14 @@ sub encstep()
191 &movz ($tmp,&HB($s[1])); 780 &movz ($tmp,&HB($s[1]));
192 &xor ($out,&DWP(3,$te,$tmp,8)); 781 &xor ($out,&DWP(3,$te,$tmp,8));
193 782
194 if ($i==3) { $tmp=$s[2]; &mov ($s[1],&DWP(4,"esp")); }##%ebx 783 if ($i==3) { $tmp=$s[2]; &mov ($s[1],$__s0); }##%ebx
195 else { &mov ($tmp,$s[2]); 784 else { &mov ($tmp,$s[2]);
196 &shr ($tmp,16); } 785 &shr ($tmp,16); }
197 if ($i==2) { &and ($s[1],0xFF); }#%edx[2] 786 if ($i==2) { &and ($s[1],0xFF); }#%edx[2]
198 &and ($tmp,0xFF); 787 &and ($tmp,0xFF);
199 &xor ($out,&DWP(2,$te,$tmp,8)); 788 &xor ($out,&DWP(2,$te,$tmp,8));
200 789
201 if ($i==3) { $tmp=$s[3]; &mov ($s[2],&DWP(8,"esp")); }##%ecx 790 if ($i==3) { $tmp=$s[3]; &mov ($s[2],$__s1); }##%ecx
202 elsif($i==2){ &movz ($tmp,&HB($s[3])); }#%ebx[2] 791 elsif($i==2){ &movz ($tmp,&HB($s[3])); }#%ebx[2]
203 else { &mov ($tmp,$s[3]); 792 else { &mov ($tmp,$s[3]);
204 &shr ($tmp,24) } 793 &shr ($tmp,24) }
@@ -213,7 +802,7 @@ sub enclast()
213 my $tmp = $key; 802 my $tmp = $key;
214 my $out = $i==3?$s[0]:$acc; 803 my $out = $i==3?$s[0]:$acc;
215 804
216 if ($i==3) { &mov ($key,&DWP(12,"esp")); }##%edx 805 if ($i==3) { &mov ($key,$__key); }##%edx
217 else { &mov ($out,$s[0]); } 806 else { &mov ($out,$s[0]); }
218 &and ($out,0xFF); 807 &and ($out,0xFF);
219 if ($i==1) { &shr ($s[0],16); }#%ebx[1] 808 if ($i==1) { &shr ($s[0],16); }#%ebx[1]
@@ -227,8 +816,8 @@ sub enclast()
227 &and ($tmp,0x0000ff00); 816 &and ($tmp,0x0000ff00);
228 &xor ($out,$tmp); 817 &xor ($out,$tmp);
229 818
230 if ($i==3) { $tmp=$s[2]; &mov ($s[1],&DWP(4,"esp")); }##%ebx 819 if ($i==3) { $tmp=$s[2]; &mov ($s[1],$__s0); }##%ebx
231 else { mov ($tmp,$s[2]); 820 else { &mov ($tmp,$s[2]);
232 &shr ($tmp,16); } 821 &shr ($tmp,16); }
233 if ($i==2) { &and ($s[1],0xFF); }#%edx[2] 822 if ($i==2) { &and ($s[1],0xFF); }#%edx[2]
234 &and ($tmp,0xFF); 823 &and ($tmp,0xFF);
@@ -236,7 +825,7 @@ sub enclast()
236 &and ($tmp,0x00ff0000); 825 &and ($tmp,0x00ff0000);
237 &xor ($out,$tmp); 826 &xor ($out,$tmp);
238 827
239 if ($i==3) { $tmp=$s[3]; &mov ($s[2],&DWP(8,"esp")); }##%ecx 828 if ($i==3) { $tmp=$s[3]; &mov ($s[2],$__s1); }##%ecx
240 elsif($i==2){ &movz ($tmp,&HB($s[3])); }#%ebx[2] 829 elsif($i==2){ &movz ($tmp,&HB($s[3])); }#%ebx[2]
241 else { &mov ($tmp,$s[3]); 830 else { &mov ($tmp,$s[3]);
242 &shr ($tmp,24); } 831 &shr ($tmp,24); }
@@ -247,10 +836,7 @@ sub enclast()
247 if ($i==3) { &mov ($s[3],$acc); } 836 if ($i==3) { &mov ($s[3],$acc); }
248} 837}
249 838
250sub _data_word() { my $i; while(defined($i=shift)) { &data_word($i,$i); } } 839&function_begin_B("_x86_AES_encrypt");
251
252&public_label("AES_Te");
253&function_begin_C("_x86_AES_encrypt");
254 if ($vertical_spin) { 840 if ($vertical_spin) {
255 # I need high parts of volatile registers to be accessible... 841 # I need high parts of volatile registers to be accessible...
256 &exch ($s1="edi",$key="ebx"); 842 &exch ($s1="edi",$key="ebx");
@@ -258,7 +844,7 @@ sub _data_word() { my $i; while(defined($i=shift)) { &data_word($i,$i); } }
258 } 844 }
259 845
260 # note that caller is expected to allocate stack frame for me! 846 # note that caller is expected to allocate stack frame for me!
261 &mov (&DWP(12,"esp"),$key); # save key 847 &mov ($__key,$key); # save key
262 848
263 &xor ($s0,&DWP(0,$key)); # xor with key 849 &xor ($s0,&DWP(0,$key)); # xor with key
264 &xor ($s1,&DWP(4,$key)); 850 &xor ($s1,&DWP(4,$key));
@@ -270,24 +856,24 @@ sub _data_word() { my $i; while(defined($i=shift)) { &data_word($i,$i); } }
270 if ($small_footprint) { 856 if ($small_footprint) {
271 &lea ($acc,&DWP(-2,$acc,$acc)); 857 &lea ($acc,&DWP(-2,$acc,$acc));
272 &lea ($acc,&DWP(0,$key,$acc,8)); 858 &lea ($acc,&DWP(0,$key,$acc,8));
273 &mov (&DWP(16,"esp"),$acc); # end of key schedule 859 &mov ($__end,$acc); # end of key schedule
274 &align (4); 860
275 &set_label("loop"); 861 &set_label("loop",16);
276 if ($vertical_spin) { 862 if ($vertical_spin) {
277 &encvert("ebp",$s0,$s1,$s2,$s3); 863 &encvert($tbl,$s0,$s1,$s2,$s3);
278 } else { 864 } else {
279 &encstep(0,"ebp",$s0,$s1,$s2,$s3); 865 &encstep(0,$tbl,$s0,$s1,$s2,$s3);
280 &encstep(1,"ebp",$s1,$s2,$s3,$s0); 866 &encstep(1,$tbl,$s1,$s2,$s3,$s0);
281 &encstep(2,"ebp",$s2,$s3,$s0,$s1); 867 &encstep(2,$tbl,$s2,$s3,$s0,$s1);
282 &encstep(3,"ebp",$s3,$s0,$s1,$s2); 868 &encstep(3,$tbl,$s3,$s0,$s1,$s2);
283 } 869 }
284 &add ($key,16); # advance rd_key 870 &add ($key,16); # advance rd_key
285 &xor ($s0,&DWP(0,$key)); 871 &xor ($s0,&DWP(0,$key));
286 &xor ($s1,&DWP(4,$key)); 872 &xor ($s1,&DWP(4,$key));
287 &xor ($s2,&DWP(8,$key)); 873 &xor ($s2,&DWP(8,$key));
288 &xor ($s3,&DWP(12,$key)); 874 &xor ($s3,&DWP(12,$key));
289 &cmp ($key,&DWP(16,"esp")); 875 &cmp ($key,$__end);
290 &mov (&DWP(12,"esp"),$key); 876 &mov ($__key,$key);
291 &jb (&label("loop")); 877 &jb (&label("loop"));
292 } 878 }
293 else { 879 else {
@@ -296,15 +882,15 @@ sub _data_word() { my $i; while(defined($i=shift)) { &data_word($i,$i); } }
296 &cmp ($acc,12); 882 &cmp ($acc,12);
297 &jle (&label("12rounds")); 883 &jle (&label("12rounds"));
298 884
299 &set_label("14rounds"); 885 &set_label("14rounds",4);
300 for ($i=1;$i<3;$i++) { 886 for ($i=1;$i<3;$i++) {
301 if ($vertical_spin) { 887 if ($vertical_spin) {
302 &encvert("ebp",$s0,$s1,$s2,$s3); 888 &encvert($tbl,$s0,$s1,$s2,$s3);
303 } else { 889 } else {
304 &encstep(0,"ebp",$s0,$s1,$s2,$s3); 890 &encstep(0,$tbl,$s0,$s1,$s2,$s3);
305 &encstep(1,"ebp",$s1,$s2,$s3,$s0); 891 &encstep(1,$tbl,$s1,$s2,$s3,$s0);
306 &encstep(2,"ebp",$s2,$s3,$s0,$s1); 892 &encstep(2,$tbl,$s2,$s3,$s0,$s1);
307 &encstep(3,"ebp",$s3,$s0,$s1,$s2); 893 &encstep(3,$tbl,$s3,$s0,$s1,$s2);
308 } 894 }
309 &xor ($s0,&DWP(16*$i+0,$key)); 895 &xor ($s0,&DWP(16*$i+0,$key));
310 &xor ($s1,&DWP(16*$i+4,$key)); 896 &xor ($s1,&DWP(16*$i+4,$key));
@@ -312,16 +898,16 @@ sub _data_word() { my $i; while(defined($i=shift)) { &data_word($i,$i); } }
312 &xor ($s3,&DWP(16*$i+12,$key)); 898 &xor ($s3,&DWP(16*$i+12,$key));
313 } 899 }
314 &add ($key,32); 900 &add ($key,32);
315 &mov (&DWP(12,"esp"),$key); # advance rd_key 901 &mov ($__key,$key); # advance rd_key
316 &set_label("12rounds"); 902 &set_label("12rounds",4);
317 for ($i=1;$i<3;$i++) { 903 for ($i=1;$i<3;$i++) {
318 if ($vertical_spin) { 904 if ($vertical_spin) {
319 &encvert("ebp",$s0,$s1,$s2,$s3); 905 &encvert($tbl,$s0,$s1,$s2,$s3);
320 } else { 906 } else {
321 &encstep(0,"ebp",$s0,$s1,$s2,$s3); 907 &encstep(0,$tbl,$s0,$s1,$s2,$s3);
322 &encstep(1,"ebp",$s1,$s2,$s3,$s0); 908 &encstep(1,$tbl,$s1,$s2,$s3,$s0);
323 &encstep(2,"ebp",$s2,$s3,$s0,$s1); 909 &encstep(2,$tbl,$s2,$s3,$s0,$s1);
324 &encstep(3,"ebp",$s3,$s0,$s1,$s2); 910 &encstep(3,$tbl,$s3,$s0,$s1,$s2);
325 } 911 }
326 &xor ($s0,&DWP(16*$i+0,$key)); 912 &xor ($s0,&DWP(16*$i+0,$key));
327 &xor ($s1,&DWP(16*$i+4,$key)); 913 &xor ($s1,&DWP(16*$i+4,$key));
@@ -329,16 +915,16 @@ sub _data_word() { my $i; while(defined($i=shift)) { &data_word($i,$i); } }
329 &xor ($s3,&DWP(16*$i+12,$key)); 915 &xor ($s3,&DWP(16*$i+12,$key));
330 } 916 }
331 &add ($key,32); 917 &add ($key,32);
332 &mov (&DWP(12,"esp"),$key); # advance rd_key 918 &mov ($__key,$key); # advance rd_key
333 &set_label("10rounds"); 919 &set_label("10rounds",4);
334 for ($i=1;$i<10;$i++) { 920 for ($i=1;$i<10;$i++) {
335 if ($vertical_spin) { 921 if ($vertical_spin) {
336 &encvert("ebp",$s0,$s1,$s2,$s3); 922 &encvert($tbl,$s0,$s1,$s2,$s3);
337 } else { 923 } else {
338 &encstep(0,"ebp",$s0,$s1,$s2,$s3); 924 &encstep(0,$tbl,$s0,$s1,$s2,$s3);
339 &encstep(1,"ebp",$s1,$s2,$s3,$s0); 925 &encstep(1,$tbl,$s1,$s2,$s3,$s0);
340 &encstep(2,"ebp",$s2,$s3,$s0,$s1); 926 &encstep(2,$tbl,$s2,$s3,$s0,$s1);
341 &encstep(3,"ebp",$s3,$s0,$s1,$s2); 927 &encstep(3,$tbl,$s3,$s0,$s1,$s2);
342 } 928 }
343 &xor ($s0,&DWP(16*$i+0,$key)); 929 &xor ($s0,&DWP(16*$i+0,$key));
344 &xor ($s1,&DWP(16*$i+4,$key)); 930 &xor ($s1,&DWP(16*$i+4,$key));
@@ -352,10 +938,10 @@ sub _data_word() { my $i; while(defined($i=shift)) { &data_word($i,$i); } }
352 &mov ($s1="ebx",$key="edi"); 938 &mov ($s1="ebx",$key="edi");
353 &mov ($s2="ecx",$acc="esi"); 939 &mov ($s2="ecx",$acc="esi");
354 } 940 }
355 &enclast(0,"ebp",$s0,$s1,$s2,$s3); 941 &enclast(0,$tbl,$s0,$s1,$s2,$s3);
356 &enclast(1,"ebp",$s1,$s2,$s3,$s0); 942 &enclast(1,$tbl,$s1,$s2,$s3,$s0);
357 &enclast(2,"ebp",$s2,$s3,$s0,$s1); 943 &enclast(2,$tbl,$s2,$s3,$s0,$s1);
358 &enclast(3,"ebp",$s3,$s0,$s1,$s2); 944 &enclast(3,$tbl,$s3,$s0,$s1,$s2);
359 945
360 &add ($key,$small_footprint?16:160); 946 &add ($key,$small_footprint?16:160);
361 &xor ($s0,&DWP(0,$key)); 947 &xor ($s0,&DWP(0,$key));
@@ -430,38 +1016,198 @@ sub _data_word() { my $i; while(defined($i=shift)) { &data_word($i,$i); } }
430 &_data_word(0xdabfbf65, 0x31e6e6d7, 0xc6424284, 0xb86868d0); 1016 &_data_word(0xdabfbf65, 0x31e6e6d7, 0xc6424284, 0xb86868d0);
431 &_data_word(0xc3414182, 0xb0999929, 0x772d2d5a, 0x110f0f1e); 1017 &_data_word(0xc3414182, 0xb0999929, 0x772d2d5a, 0x110f0f1e);
432 &_data_word(0xcbb0b07b, 0xfc5454a8, 0xd6bbbb6d, 0x3a16162c); 1018 &_data_word(0xcbb0b07b, 0xfc5454a8, 0xd6bbbb6d, 0x3a16162c);
1019
1020#Te4 # four copies of Te4 to choose from to avoid L1 aliasing
1021 &data_byte(0x63, 0x7c, 0x77, 0x7b, 0xf2, 0x6b, 0x6f, 0xc5);
1022 &data_byte(0x30, 0x01, 0x67, 0x2b, 0xfe, 0xd7, 0xab, 0x76);
1023 &data_byte(0xca, 0x82, 0xc9, 0x7d, 0xfa, 0x59, 0x47, 0xf0);
1024 &data_byte(0xad, 0xd4, 0xa2, 0xaf, 0x9c, 0xa4, 0x72, 0xc0);
1025 &data_byte(0xb7, 0xfd, 0x93, 0x26, 0x36, 0x3f, 0xf7, 0xcc);
1026 &data_byte(0x34, 0xa5, 0xe5, 0xf1, 0x71, 0xd8, 0x31, 0x15);
1027 &data_byte(0x04, 0xc7, 0x23, 0xc3, 0x18, 0x96, 0x05, 0x9a);
1028 &data_byte(0x07, 0x12, 0x80, 0xe2, 0xeb, 0x27, 0xb2, 0x75);
1029 &data_byte(0x09, 0x83, 0x2c, 0x1a, 0x1b, 0x6e, 0x5a, 0xa0);
1030 &data_byte(0x52, 0x3b, 0xd6, 0xb3, 0x29, 0xe3, 0x2f, 0x84);
1031 &data_byte(0x53, 0xd1, 0x00, 0xed, 0x20, 0xfc, 0xb1, 0x5b);
1032 &data_byte(0x6a, 0xcb, 0xbe, 0x39, 0x4a, 0x4c, 0x58, 0xcf);
1033 &data_byte(0xd0, 0xef, 0xaa, 0xfb, 0x43, 0x4d, 0x33, 0x85);
1034 &data_byte(0x45, 0xf9, 0x02, 0x7f, 0x50, 0x3c, 0x9f, 0xa8);
1035 &data_byte(0x51, 0xa3, 0x40, 0x8f, 0x92, 0x9d, 0x38, 0xf5);
1036 &data_byte(0xbc, 0xb6, 0xda, 0x21, 0x10, 0xff, 0xf3, 0xd2);
1037 &data_byte(0xcd, 0x0c, 0x13, 0xec, 0x5f, 0x97, 0x44, 0x17);
1038 &data_byte(0xc4, 0xa7, 0x7e, 0x3d, 0x64, 0x5d, 0x19, 0x73);
1039 &data_byte(0x60, 0x81, 0x4f, 0xdc, 0x22, 0x2a, 0x90, 0x88);
1040 &data_byte(0x46, 0xee, 0xb8, 0x14, 0xde, 0x5e, 0x0b, 0xdb);
1041 &data_byte(0xe0, 0x32, 0x3a, 0x0a, 0x49, 0x06, 0x24, 0x5c);
1042 &data_byte(0xc2, 0xd3, 0xac, 0x62, 0x91, 0x95, 0xe4, 0x79);
1043 &data_byte(0xe7, 0xc8, 0x37, 0x6d, 0x8d, 0xd5, 0x4e, 0xa9);
1044 &data_byte(0x6c, 0x56, 0xf4, 0xea, 0x65, 0x7a, 0xae, 0x08);
1045 &data_byte(0xba, 0x78, 0x25, 0x2e, 0x1c, 0xa6, 0xb4, 0xc6);
1046 &data_byte(0xe8, 0xdd, 0x74, 0x1f, 0x4b, 0xbd, 0x8b, 0x8a);
1047 &data_byte(0x70, 0x3e, 0xb5, 0x66, 0x48, 0x03, 0xf6, 0x0e);
1048 &data_byte(0x61, 0x35, 0x57, 0xb9, 0x86, 0xc1, 0x1d, 0x9e);
1049 &data_byte(0xe1, 0xf8, 0x98, 0x11, 0x69, 0xd9, 0x8e, 0x94);
1050 &data_byte(0x9b, 0x1e, 0x87, 0xe9, 0xce, 0x55, 0x28, 0xdf);
1051 &data_byte(0x8c, 0xa1, 0x89, 0x0d, 0xbf, 0xe6, 0x42, 0x68);
1052 &data_byte(0x41, 0x99, 0x2d, 0x0f, 0xb0, 0x54, 0xbb, 0x16);
1053
1054 &data_byte(0x63, 0x7c, 0x77, 0x7b, 0xf2, 0x6b, 0x6f, 0xc5);
1055 &data_byte(0x30, 0x01, 0x67, 0x2b, 0xfe, 0xd7, 0xab, 0x76);
1056 &data_byte(0xca, 0x82, 0xc9, 0x7d, 0xfa, 0x59, 0x47, 0xf0);
1057 &data_byte(0xad, 0xd4, 0xa2, 0xaf, 0x9c, 0xa4, 0x72, 0xc0);
1058 &data_byte(0xb7, 0xfd, 0x93, 0x26, 0x36, 0x3f, 0xf7, 0xcc);
1059 &data_byte(0x34, 0xa5, 0xe5, 0xf1, 0x71, 0xd8, 0x31, 0x15);
1060 &data_byte(0x04, 0xc7, 0x23, 0xc3, 0x18, 0x96, 0x05, 0x9a);
1061 &data_byte(0x07, 0x12, 0x80, 0xe2, 0xeb, 0x27, 0xb2, 0x75);
1062 &data_byte(0x09, 0x83, 0x2c, 0x1a, 0x1b, 0x6e, 0x5a, 0xa0);
1063 &data_byte(0x52, 0x3b, 0xd6, 0xb3, 0x29, 0xe3, 0x2f, 0x84);
1064 &data_byte(0x53, 0xd1, 0x00, 0xed, 0x20, 0xfc, 0xb1, 0x5b);
1065 &data_byte(0x6a, 0xcb, 0xbe, 0x39, 0x4a, 0x4c, 0x58, 0xcf);
1066 &data_byte(0xd0, 0xef, 0xaa, 0xfb, 0x43, 0x4d, 0x33, 0x85);
1067 &data_byte(0x45, 0xf9, 0x02, 0x7f, 0x50, 0x3c, 0x9f, 0xa8);
1068 &data_byte(0x51, 0xa3, 0x40, 0x8f, 0x92, 0x9d, 0x38, 0xf5);
1069 &data_byte(0xbc, 0xb6, 0xda, 0x21, 0x10, 0xff, 0xf3, 0xd2);
1070 &data_byte(0xcd, 0x0c, 0x13, 0xec, 0x5f, 0x97, 0x44, 0x17);
1071 &data_byte(0xc4, 0xa7, 0x7e, 0x3d, 0x64, 0x5d, 0x19, 0x73);
1072 &data_byte(0x60, 0x81, 0x4f, 0xdc, 0x22, 0x2a, 0x90, 0x88);
1073 &data_byte(0x46, 0xee, 0xb8, 0x14, 0xde, 0x5e, 0x0b, 0xdb);
1074 &data_byte(0xe0, 0x32, 0x3a, 0x0a, 0x49, 0x06, 0x24, 0x5c);
1075 &data_byte(0xc2, 0xd3, 0xac, 0x62, 0x91, 0x95, 0xe4, 0x79);
1076 &data_byte(0xe7, 0xc8, 0x37, 0x6d, 0x8d, 0xd5, 0x4e, 0xa9);
1077 &data_byte(0x6c, 0x56, 0xf4, 0xea, 0x65, 0x7a, 0xae, 0x08);
1078 &data_byte(0xba, 0x78, 0x25, 0x2e, 0x1c, 0xa6, 0xb4, 0xc6);
1079 &data_byte(0xe8, 0xdd, 0x74, 0x1f, 0x4b, 0xbd, 0x8b, 0x8a);
1080 &data_byte(0x70, 0x3e, 0xb5, 0x66, 0x48, 0x03, 0xf6, 0x0e);
1081 &data_byte(0x61, 0x35, 0x57, 0xb9, 0x86, 0xc1, 0x1d, 0x9e);
1082 &data_byte(0xe1, 0xf8, 0x98, 0x11, 0x69, 0xd9, 0x8e, 0x94);
1083 &data_byte(0x9b, 0x1e, 0x87, 0xe9, 0xce, 0x55, 0x28, 0xdf);
1084 &data_byte(0x8c, 0xa1, 0x89, 0x0d, 0xbf, 0xe6, 0x42, 0x68);
1085 &data_byte(0x41, 0x99, 0x2d, 0x0f, 0xb0, 0x54, 0xbb, 0x16);
1086
1087 &data_byte(0x63, 0x7c, 0x77, 0x7b, 0xf2, 0x6b, 0x6f, 0xc5);
1088 &data_byte(0x30, 0x01, 0x67, 0x2b, 0xfe, 0xd7, 0xab, 0x76);
1089 &data_byte(0xca, 0x82, 0xc9, 0x7d, 0xfa, 0x59, 0x47, 0xf0);
1090 &data_byte(0xad, 0xd4, 0xa2, 0xaf, 0x9c, 0xa4, 0x72, 0xc0);
1091 &data_byte(0xb7, 0xfd, 0x93, 0x26, 0x36, 0x3f, 0xf7, 0xcc);
1092 &data_byte(0x34, 0xa5, 0xe5, 0xf1, 0x71, 0xd8, 0x31, 0x15);
1093 &data_byte(0x04, 0xc7, 0x23, 0xc3, 0x18, 0x96, 0x05, 0x9a);
1094 &data_byte(0x07, 0x12, 0x80, 0xe2, 0xeb, 0x27, 0xb2, 0x75);
1095 &data_byte(0x09, 0x83, 0x2c, 0x1a, 0x1b, 0x6e, 0x5a, 0xa0);
1096 &data_byte(0x52, 0x3b, 0xd6, 0xb3, 0x29, 0xe3, 0x2f, 0x84);
1097 &data_byte(0x53, 0xd1, 0x00, 0xed, 0x20, 0xfc, 0xb1, 0x5b);
1098 &data_byte(0x6a, 0xcb, 0xbe, 0x39, 0x4a, 0x4c, 0x58, 0xcf);
1099 &data_byte(0xd0, 0xef, 0xaa, 0xfb, 0x43, 0x4d, 0x33, 0x85);
1100 &data_byte(0x45, 0xf9, 0x02, 0x7f, 0x50, 0x3c, 0x9f, 0xa8);
1101 &data_byte(0x51, 0xa3, 0x40, 0x8f, 0x92, 0x9d, 0x38, 0xf5);
1102 &data_byte(0xbc, 0xb6, 0xda, 0x21, 0x10, 0xff, 0xf3, 0xd2);
1103 &data_byte(0xcd, 0x0c, 0x13, 0xec, 0x5f, 0x97, 0x44, 0x17);
1104 &data_byte(0xc4, 0xa7, 0x7e, 0x3d, 0x64, 0x5d, 0x19, 0x73);
1105 &data_byte(0x60, 0x81, 0x4f, 0xdc, 0x22, 0x2a, 0x90, 0x88);
1106 &data_byte(0x46, 0xee, 0xb8, 0x14, 0xde, 0x5e, 0x0b, 0xdb);
1107 &data_byte(0xe0, 0x32, 0x3a, 0x0a, 0x49, 0x06, 0x24, 0x5c);
1108 &data_byte(0xc2, 0xd3, 0xac, 0x62, 0x91, 0x95, 0xe4, 0x79);
1109 &data_byte(0xe7, 0xc8, 0x37, 0x6d, 0x8d, 0xd5, 0x4e, 0xa9);
1110 &data_byte(0x6c, 0x56, 0xf4, 0xea, 0x65, 0x7a, 0xae, 0x08);
1111 &data_byte(0xba, 0x78, 0x25, 0x2e, 0x1c, 0xa6, 0xb4, 0xc6);
1112 &data_byte(0xe8, 0xdd, 0x74, 0x1f, 0x4b, 0xbd, 0x8b, 0x8a);
1113 &data_byte(0x70, 0x3e, 0xb5, 0x66, 0x48, 0x03, 0xf6, 0x0e);
1114 &data_byte(0x61, 0x35, 0x57, 0xb9, 0x86, 0xc1, 0x1d, 0x9e);
1115 &data_byte(0xe1, 0xf8, 0x98, 0x11, 0x69, 0xd9, 0x8e, 0x94);
1116 &data_byte(0x9b, 0x1e, 0x87, 0xe9, 0xce, 0x55, 0x28, 0xdf);
1117 &data_byte(0x8c, 0xa1, 0x89, 0x0d, 0xbf, 0xe6, 0x42, 0x68);
1118 &data_byte(0x41, 0x99, 0x2d, 0x0f, 0xb0, 0x54, 0xbb, 0x16);
1119
1120 &data_byte(0x63, 0x7c, 0x77, 0x7b, 0xf2, 0x6b, 0x6f, 0xc5);
1121 &data_byte(0x30, 0x01, 0x67, 0x2b, 0xfe, 0xd7, 0xab, 0x76);
1122 &data_byte(0xca, 0x82, 0xc9, 0x7d, 0xfa, 0x59, 0x47, 0xf0);
1123 &data_byte(0xad, 0xd4, 0xa2, 0xaf, 0x9c, 0xa4, 0x72, 0xc0);
1124 &data_byte(0xb7, 0xfd, 0x93, 0x26, 0x36, 0x3f, 0xf7, 0xcc);
1125 &data_byte(0x34, 0xa5, 0xe5, 0xf1, 0x71, 0xd8, 0x31, 0x15);
1126 &data_byte(0x04, 0xc7, 0x23, 0xc3, 0x18, 0x96, 0x05, 0x9a);
1127 &data_byte(0x07, 0x12, 0x80, 0xe2, 0xeb, 0x27, 0xb2, 0x75);
1128 &data_byte(0x09, 0x83, 0x2c, 0x1a, 0x1b, 0x6e, 0x5a, 0xa0);
1129 &data_byte(0x52, 0x3b, 0xd6, 0xb3, 0x29, 0xe3, 0x2f, 0x84);
1130 &data_byte(0x53, 0xd1, 0x00, 0xed, 0x20, 0xfc, 0xb1, 0x5b);
1131 &data_byte(0x6a, 0xcb, 0xbe, 0x39, 0x4a, 0x4c, 0x58, 0xcf);
1132 &data_byte(0xd0, 0xef, 0xaa, 0xfb, 0x43, 0x4d, 0x33, 0x85);
1133 &data_byte(0x45, 0xf9, 0x02, 0x7f, 0x50, 0x3c, 0x9f, 0xa8);
1134 &data_byte(0x51, 0xa3, 0x40, 0x8f, 0x92, 0x9d, 0x38, 0xf5);
1135 &data_byte(0xbc, 0xb6, 0xda, 0x21, 0x10, 0xff, 0xf3, 0xd2);
1136 &data_byte(0xcd, 0x0c, 0x13, 0xec, 0x5f, 0x97, 0x44, 0x17);
1137 &data_byte(0xc4, 0xa7, 0x7e, 0x3d, 0x64, 0x5d, 0x19, 0x73);
1138 &data_byte(0x60, 0x81, 0x4f, 0xdc, 0x22, 0x2a, 0x90, 0x88);
1139 &data_byte(0x46, 0xee, 0xb8, 0x14, 0xde, 0x5e, 0x0b, 0xdb);
1140 &data_byte(0xe0, 0x32, 0x3a, 0x0a, 0x49, 0x06, 0x24, 0x5c);
1141 &data_byte(0xc2, 0xd3, 0xac, 0x62, 0x91, 0x95, 0xe4, 0x79);
1142 &data_byte(0xe7, 0xc8, 0x37, 0x6d, 0x8d, 0xd5, 0x4e, 0xa9);
1143 &data_byte(0x6c, 0x56, 0xf4, 0xea, 0x65, 0x7a, 0xae, 0x08);
1144 &data_byte(0xba, 0x78, 0x25, 0x2e, 0x1c, 0xa6, 0xb4, 0xc6);
1145 &data_byte(0xe8, 0xdd, 0x74, 0x1f, 0x4b, 0xbd, 0x8b, 0x8a);
1146 &data_byte(0x70, 0x3e, 0xb5, 0x66, 0x48, 0x03, 0xf6, 0x0e);
1147 &data_byte(0x61, 0x35, 0x57, 0xb9, 0x86, 0xc1, 0x1d, 0x9e);
1148 &data_byte(0xe1, 0xf8, 0x98, 0x11, 0x69, 0xd9, 0x8e, 0x94);
1149 &data_byte(0x9b, 0x1e, 0x87, 0xe9, 0xce, 0x55, 0x28, 0xdf);
1150 &data_byte(0x8c, 0xa1, 0x89, 0x0d, 0xbf, 0xe6, 0x42, 0x68);
1151 &data_byte(0x41, 0x99, 0x2d, 0x0f, 0xb0, 0x54, 0xbb, 0x16);
433#rcon: 1152#rcon:
434 &data_word(0x00000001, 0x00000002, 0x00000004, 0x00000008); 1153 &data_word(0x00000001, 0x00000002, 0x00000004, 0x00000008);
435 &data_word(0x00000010, 0x00000020, 0x00000040, 0x00000080); 1154 &data_word(0x00000010, 0x00000020, 0x00000040, 0x00000080);
436 &data_word(0x0000001b, 0x00000036, 0, 0, 0, 0, 0, 0); 1155 &data_word(0x0000001b, 0x00000036, 0x00000000, 0x00000000);
1156 &data_word(0x00000000, 0x00000000, 0x00000000, 0x00000000);
437&function_end_B("_x86_AES_encrypt"); 1157&function_end_B("_x86_AES_encrypt");
438 1158
439# void AES_encrypt (const void *inp,void *out,const AES_KEY *key); 1159# void AES_encrypt (const void *inp,void *out,const AES_KEY *key);
440&public_label("AES_Te");
441&function_begin("AES_encrypt"); 1160&function_begin("AES_encrypt");
442 &mov ($acc,&wparam(0)); # load inp 1161 &mov ($acc,&wparam(0)); # load inp
443 &mov ($key,&wparam(2)); # load key 1162 &mov ($key,&wparam(2)); # load key
444 1163
445 &mov ($s0,"esp"); 1164 &mov ($s0,"esp");
446 &sub ("esp",24); 1165 &sub ("esp",36);
447 &and ("esp",-64); 1166 &and ("esp",-64); # align to cache-line
448 &add ("esp",4); 1167
449 &mov (&DWP(16,"esp"),$s0); 1168 # place stack frame just "above" the key schedule
1169 &lea ($s1,&DWP(-64-63,$key));
1170 &sub ($s1,"esp");
1171 &neg ($s1);
1172 &and ($s1,0x3C0); # modulo 1024, but aligned to cache-line
1173 &sub ("esp",$s1);
1174 &add ("esp",4); # 4 is reserved for caller's return address
1175 &mov ($_esp,$s0); # save stack pointer
450 1176
451 &call (&label("pic_point")); # make it PIC! 1177 &call (&label("pic_point")); # make it PIC!
452 &set_label("pic_point"); 1178 &set_label("pic_point");
453 &blindpop("ebp"); 1179 &blindpop($tbl);
454 &lea ("ebp",&DWP(&label("AES_Te")."-".&label("pic_point"),"ebp")); 1180 &picmeup($s0,"OPENSSL_ia32cap_P",$tbl,&label("pic_point")) if (!$x86only);
455 1181 &lea ($tbl,&DWP(&label("AES_Te")."-".&label("pic_point"),$tbl));
1182
1183 # pick Te4 copy which can't "overlap" with stack frame or key schedule
1184 &lea ($s1,&DWP(768-4,"esp"));
1185 &sub ($s1,$tbl);
1186 &and ($s1,0x300);
1187 &lea ($tbl,&DWP(2048+128,$tbl,$s1));
1188
1189 if (!$x86only) {
1190 &bt (&DWP(0,$s0),25); # check for SSE bit
1191 &jnc (&label("x86"));
1192
1193 &movq ("mm0",&QWP(0,$acc));
1194 &movq ("mm4",&QWP(8,$acc));
1195 &call ("_sse_AES_encrypt_compact");
1196 &mov ("esp",$_esp); # restore stack pointer
1197 &mov ($acc,&wparam(1)); # load out
1198 &movq (&QWP(0,$acc),"mm0"); # write output data
1199 &movq (&QWP(8,$acc),"mm4");
1200 &emms ();
1201 &function_end_A();
1202 }
1203 &set_label("x86",16);
1204 &mov ($_tbl,$tbl);
456 &mov ($s0,&DWP(0,$acc)); # load input data 1205 &mov ($s0,&DWP(0,$acc)); # load input data
457 &mov ($s1,&DWP(4,$acc)); 1206 &mov ($s1,&DWP(4,$acc));
458 &mov ($s2,&DWP(8,$acc)); 1207 &mov ($s2,&DWP(8,$acc));
459 &mov ($s3,&DWP(12,$acc)); 1208 &mov ($s3,&DWP(12,$acc));
460 1209 &call ("_x86_AES_encrypt_compact");
461 &call ("_x86_AES_encrypt"); 1210 &mov ("esp",$_esp); # restore stack pointer
462
463 &mov ("esp",&DWP(16,"esp"));
464
465 &mov ($acc,&wparam(1)); # load out 1211 &mov ($acc,&wparam(1)); # load out
466 &mov (&DWP(0,$acc),$s0); # write output data 1212 &mov (&DWP(0,$acc),$s0); # write output data
467 &mov (&DWP(4,$acc),$s1); 1213 &mov (&DWP(4,$acc),$s1);
@@ -469,7 +1215,370 @@ sub _data_word() { my $i; while(defined($i=shift)) { &data_word($i,$i); } }
469 &mov (&DWP(12,$acc),$s3); 1215 &mov (&DWP(12,$acc),$s3);
470&function_end("AES_encrypt"); 1216&function_end("AES_encrypt");
471 1217
472#------------------------------------------------------------------# 1218#--------------------------------------------------------------------#
1219
1220######################################################################
1221# "Compact" block function
1222######################################################################
1223
1224sub deccompact()
1225{ my $Fn = mov;
1226 while ($#_>5) { pop(@_); $Fn=sub{}; }
1227 my ($i,$td,@s)=@_;
1228 my $tmp = $key;
1229 my $out = $i==3?$s[0]:$acc;
1230
1231 # $Fn is used in first compact round and its purpose is to
1232 # void restoration of some values from stack, so that after
1233 # 4xdeccompact with extra argument $key, $s0 and $s1 values
1234 # are left there...
1235 if($i==3) { &$Fn ($key,$__key); }
1236 else { &mov ($out,$s[0]); }
1237 &and ($out,0xFF);
1238 &movz ($out,&BP(-128,$td,$out,1));
1239
1240 if ($i==3) { $tmp=$s[1]; }
1241 &movz ($tmp,&HB($s[1]));
1242 &movz ($tmp,&BP(-128,$td,$tmp,1));
1243 &shl ($tmp,8);
1244 &xor ($out,$tmp);
1245
1246 if ($i==3) { $tmp=$s[2]; &mov ($s[1],$acc); }
1247 else { mov ($tmp,$s[2]); }
1248 &shr ($tmp,16);
1249 &and ($tmp,0xFF);
1250 &movz ($tmp,&BP(-128,$td,$tmp,1));
1251 &shl ($tmp,16);
1252 &xor ($out,$tmp);
1253
1254 if ($i==3) { $tmp=$s[3]; &$Fn ($s[2],$__s1); }
1255 else { &mov ($tmp,$s[3]); }
1256 &shr ($tmp,24);
1257 &movz ($tmp,&BP(-128,$td,$tmp,1));
1258 &shl ($tmp,24);
1259 &xor ($out,$tmp);
1260 if ($i<2) { &mov (&DWP(4+4*$i,"esp"),$out); }
1261 if ($i==3) { &$Fn ($s[3],$__s0); }
1262}
1263
1264# must be called with 2,3,0,1 as argument sequence!!!
1265sub dectransform()
1266{ my @s = ($s0,$s1,$s2,$s3);
1267 my $i = shift;
1268 my $tmp = $key;
1269 my $tp2 = @s[($i+2)%4]; $tp2 = @s[2] if ($i==1);
1270 my $tp4 = @s[($i+3)%4]; $tp4 = @s[3] if ($i==1);
1271 my $tp8 = $tbl;
1272
1273 &mov ($acc,$s[$i]);
1274 &and ($acc,0x80808080);
1275 &mov ($tmp,$acc);
1276 &shr ($tmp,7);
1277 &lea ($tp2,&DWP(0,$s[$i],$s[$i]));
1278 &sub ($acc,$tmp);
1279 &and ($tp2,0xfefefefe);
1280 &and ($acc,0x1b1b1b1b);
1281 &xor ($acc,$tp2);
1282 &mov ($tp2,$acc);
1283
1284 &and ($acc,0x80808080);
1285 &mov ($tmp,$acc);
1286 &shr ($tmp,7);
1287 &lea ($tp4,&DWP(0,$tp2,$tp2));
1288 &sub ($acc,$tmp);
1289 &and ($tp4,0xfefefefe);
1290 &and ($acc,0x1b1b1b1b);
1291 &xor ($tp2,$s[$i]); # tp2^tp1
1292 &xor ($acc,$tp4);
1293 &mov ($tp4,$acc);
1294
1295 &and ($acc,0x80808080);
1296 &mov ($tmp,$acc);
1297 &shr ($tmp,7);
1298 &lea ($tp8,&DWP(0,$tp4,$tp4));
1299 &sub ($acc,$tmp);
1300 &and ($tp8,0xfefefefe);
1301 &and ($acc,0x1b1b1b1b);
1302 &xor ($tp4,$s[$i]); # tp4^tp1
1303 &rotl ($s[$i],8); # = ROTATE(tp1,8)
1304 &xor ($tp8,$acc);
1305
1306 &xor ($s[$i],$tp2);
1307 &xor ($tp2,$tp8);
1308 &rotl ($tp2,24);
1309 &xor ($s[$i],$tp4);
1310 &xor ($tp4,$tp8);
1311 &rotl ($tp4,16);
1312 &xor ($s[$i],$tp8); # ^= tp8^(tp4^tp1)^(tp2^tp1)
1313 &rotl ($tp8,8);
1314 &xor ($s[$i],$tp2); # ^= ROTATE(tp8^tp2^tp1,24)
1315 &xor ($s[$i],$tp4); # ^= ROTATE(tp8^tp4^tp1,16)
1316 &mov ($s[0],$__s0) if($i==2); #prefetch $s0
1317 &mov ($s[1],$__s1) if($i==3); #prefetch $s1
1318 &mov ($s[2],$__s2) if($i==1);
1319 &xor ($s[$i],$tp8); # ^= ROTATE(tp8,8)
1320
1321 &mov ($s[3],$__s3) if($i==1);
1322 &mov (&DWP(4+4*$i,"esp"),$s[$i]) if($i>=2);
1323}
1324
1325&function_begin_B("_x86_AES_decrypt_compact");
1326 # note that caller is expected to allocate stack frame for me!
1327 &mov ($__key,$key); # save key
1328
1329 &xor ($s0,&DWP(0,$key)); # xor with key
1330 &xor ($s1,&DWP(4,$key));
1331 &xor ($s2,&DWP(8,$key));
1332 &xor ($s3,&DWP(12,$key));
1333
1334 &mov ($acc,&DWP(240,$key)); # load key->rounds
1335
1336 &lea ($acc,&DWP(-2,$acc,$acc));
1337 &lea ($acc,&DWP(0,$key,$acc,8));
1338 &mov ($__end,$acc); # end of key schedule
1339
1340 # prefetch Td4
1341 &mov ($key,&DWP(0-128,$tbl));
1342 &mov ($acc,&DWP(32-128,$tbl));
1343 &mov ($key,&DWP(64-128,$tbl));
1344 &mov ($acc,&DWP(96-128,$tbl));
1345 &mov ($key,&DWP(128-128,$tbl));
1346 &mov ($acc,&DWP(160-128,$tbl));
1347 &mov ($key,&DWP(192-128,$tbl));
1348 &mov ($acc,&DWP(224-128,$tbl));
1349
1350 &set_label("loop",16);
1351
1352 &deccompact(0,$tbl,$s0,$s3,$s2,$s1,1);
1353 &deccompact(1,$tbl,$s1,$s0,$s3,$s2,1);
1354 &deccompact(2,$tbl,$s2,$s1,$s0,$s3,1);
1355 &deccompact(3,$tbl,$s3,$s2,$s1,$s0,1);
1356 &dectransform(2);
1357 &dectransform(3);
1358 &dectransform(0);
1359 &dectransform(1);
1360 &mov ($key,$__key);
1361 &mov ($tbl,$__tbl);
1362 &add ($key,16); # advance rd_key
1363 &xor ($s0,&DWP(0,$key));
1364 &xor ($s1,&DWP(4,$key));
1365 &xor ($s2,&DWP(8,$key));
1366 &xor ($s3,&DWP(12,$key));
1367
1368 &cmp ($key,$__end);
1369 &mov ($__key,$key);
1370 &jb (&label("loop"));
1371
1372 &deccompact(0,$tbl,$s0,$s3,$s2,$s1);
1373 &deccompact(1,$tbl,$s1,$s0,$s3,$s2);
1374 &deccompact(2,$tbl,$s2,$s1,$s0,$s3);
1375 &deccompact(3,$tbl,$s3,$s2,$s1,$s0);
1376
1377 &xor ($s0,&DWP(16,$key));
1378 &xor ($s1,&DWP(20,$key));
1379 &xor ($s2,&DWP(24,$key));
1380 &xor ($s3,&DWP(28,$key));
1381
1382 &ret ();
1383&function_end_B("_x86_AES_decrypt_compact");
1384
1385######################################################################
1386# "Compact" SSE block function.
1387######################################################################
1388
1389sub sse_deccompact()
1390{
1391 &pshufw ("mm1","mm0",0x0c); # 7, 6, 1, 0
1392 &movd ("eax","mm1"); # 7, 6, 1, 0
1393
1394 &pshufw ("mm5","mm4",0x09); # 13,12,11,10
1395 &movz ($acc,&LB("eax")); # 0
1396 &movz ("ecx",&BP(-128,$tbl,$acc,1)); # 0
1397 &movd ("ebx","mm5"); # 13,12,11,10
1398 &movz ("edx",&HB("eax")); # 1
1399 &movz ("edx",&BP(-128,$tbl,"edx",1)); # 1
1400 &shl ("edx",8); # 1
1401
1402 &pshufw ("mm2","mm0",0x06); # 3, 2, 5, 4
1403 &movz ($acc,&LB("ebx")); # 10
1404 &movz ($acc,&BP(-128,$tbl,$acc,1)); # 10
1405 &shl ($acc,16); # 10
1406 &or ("ecx",$acc); # 10
1407 &shr ("eax",16); # 7, 6
1408 &movz ($acc,&HB("ebx")); # 11
1409 &movz ($acc,&BP(-128,$tbl,$acc,1)); # 11
1410 &shl ($acc,24); # 11
1411 &or ("edx",$acc); # 11
1412 &shr ("ebx",16); # 13,12
1413
1414 &pshufw ("mm6","mm4",0x03); # 9, 8,15,14
1415 &movz ($acc,&HB("eax")); # 7
1416 &movz ($acc,&BP(-128,$tbl,$acc,1)); # 7
1417 &shl ($acc,24); # 7
1418 &or ("ecx",$acc); # 7
1419 &movz ($acc,&HB("ebx")); # 13
1420 &movz ($acc,&BP(-128,$tbl,$acc,1)); # 13
1421 &shl ($acc,8); # 13
1422 &or ("ecx",$acc); # 13
1423 &movd ("mm0","ecx"); # t[0] collected
1424
1425 &movz ($acc,&LB("eax")); # 6
1426 &movd ("eax","mm2"); # 3, 2, 5, 4
1427 &movz ("ecx",&BP(-128,$tbl,$acc,1)); # 6
1428 &shl ("ecx",16); # 6
1429 &movz ($acc,&LB("ebx")); # 12
1430 &movd ("ebx","mm6"); # 9, 8,15,14
1431 &movz ($acc,&BP(-128,$tbl,$acc,1)); # 12
1432 &or ("ecx",$acc); # 12
1433
1434 &movz ($acc,&LB("eax")); # 4
1435 &movz ($acc,&BP(-128,$tbl,$acc,1)); # 4
1436 &or ("edx",$acc); # 4
1437 &movz ($acc,&LB("ebx")); # 14
1438 &movz ($acc,&BP(-128,$tbl,$acc,1)); # 14
1439 &shl ($acc,16); # 14
1440 &or ("edx",$acc); # 14
1441 &movd ("mm1","edx"); # t[1] collected
1442
1443 &movz ($acc,&HB("eax")); # 5
1444 &movz ("edx",&BP(-128,$tbl,$acc,1)); # 5
1445 &shl ("edx",8); # 5
1446 &movz ($acc,&HB("ebx")); # 15
1447 &shr ("eax",16); # 3, 2
1448 &movz ($acc,&BP(-128,$tbl,$acc,1)); # 15
1449 &shl ($acc,24); # 15
1450 &or ("edx",$acc); # 15
1451 &shr ("ebx",16); # 9, 8
1452
1453 &punpckldq ("mm0","mm1"); # t[0,1] collected
1454
1455 &movz ($acc,&HB("ebx")); # 9
1456 &movz ($acc,&BP(-128,$tbl,$acc,1)); # 9
1457 &shl ($acc,8); # 9
1458 &or ("ecx",$acc); # 9
1459 &and ("ebx",0xff); # 8
1460 &movz ("ebx",&BP(-128,$tbl,"ebx",1)); # 8
1461 &or ("edx","ebx"); # 8
1462 &movz ($acc,&LB("eax")); # 2
1463 &movz ($acc,&BP(-128,$tbl,$acc,1)); # 2
1464 &shl ($acc,16); # 2
1465 &or ("edx",$acc); # 2
1466 &movd ("mm4","edx"); # t[2] collected
1467 &movz ("eax",&HB("eax")); # 3
1468 &movz ("eax",&BP(-128,$tbl,"eax",1)); # 3
1469 &shl ("eax",24); # 3
1470 &or ("ecx","eax"); # 3
1471 &movd ("mm5","ecx"); # t[3] collected
1472
1473 &punpckldq ("mm4","mm5"); # t[2,3] collected
1474}
1475
1476 if (!$x86only) {
1477&function_begin_B("_sse_AES_decrypt_compact");
1478 &pxor ("mm0",&QWP(0,$key)); # 7, 6, 5, 4, 3, 2, 1, 0
1479 &pxor ("mm4",&QWP(8,$key)); # 15,14,13,12,11,10, 9, 8
1480
1481 # note that caller is expected to allocate stack frame for me!
1482 &mov ($acc,&DWP(240,$key)); # load key->rounds
1483 &lea ($acc,&DWP(-2,$acc,$acc));
1484 &lea ($acc,&DWP(0,$key,$acc,8));
1485 &mov ($__end,$acc); # end of key schedule
1486
1487 &mov ($s0,0x1b1b1b1b); # magic constant
1488 &mov (&DWP(8,"esp"),$s0);
1489 &mov (&DWP(12,"esp"),$s0);
1490
1491 # prefetch Td4
1492 &mov ($s0,&DWP(0-128,$tbl));
1493 &mov ($s1,&DWP(32-128,$tbl));
1494 &mov ($s2,&DWP(64-128,$tbl));
1495 &mov ($s3,&DWP(96-128,$tbl));
1496 &mov ($s0,&DWP(128-128,$tbl));
1497 &mov ($s1,&DWP(160-128,$tbl));
1498 &mov ($s2,&DWP(192-128,$tbl));
1499 &mov ($s3,&DWP(224-128,$tbl));
1500
1501 &set_label("loop",16);
1502 &sse_deccompact();
1503 &add ($key,16);
1504 &cmp ($key,$__end);
1505 &ja (&label("out"));
1506
1507 # ROTATE(x^y,N) == ROTATE(x,N)^ROTATE(y,N)
1508 &movq ("mm3","mm0"); &movq ("mm7","mm4");
1509 &movq ("mm2","mm0",1); &movq ("mm6","mm4",1);
1510 &movq ("mm1","mm0"); &movq ("mm5","mm4");
1511 &pshufw ("mm0","mm0",0xb1); &pshufw ("mm4","mm4",0xb1);# = ROTATE(tp0,16)
1512 &pslld ("mm2",8); &pslld ("mm6",8);
1513 &psrld ("mm3",8); &psrld ("mm7",8);
1514 &pxor ("mm0","mm2"); &pxor ("mm4","mm6"); # ^= tp0<<8
1515 &pxor ("mm0","mm3"); &pxor ("mm4","mm7"); # ^= tp0>>8
1516 &pslld ("mm2",16); &pslld ("mm6",16);
1517 &psrld ("mm3",16); &psrld ("mm7",16);
1518 &pxor ("mm0","mm2"); &pxor ("mm4","mm6"); # ^= tp0<<24
1519 &pxor ("mm0","mm3"); &pxor ("mm4","mm7"); # ^= tp0>>24
1520
1521 &movq ("mm3",&QWP(8,"esp"));
1522 &pxor ("mm2","mm2"); &pxor ("mm6","mm6");
1523 &pcmpgtb("mm2","mm1"); &pcmpgtb("mm6","mm5");
1524 &pand ("mm2","mm3"); &pand ("mm6","mm3");
1525 &paddb ("mm1","mm1"); &paddb ("mm5","mm5");
1526 &pxor ("mm1","mm2"); &pxor ("mm5","mm6"); # tp2
1527 &movq ("mm3","mm1"); &movq ("mm7","mm5");
1528 &movq ("mm2","mm1"); &movq ("mm6","mm5");
1529 &pxor ("mm0","mm1"); &pxor ("mm4","mm5"); # ^= tp2
1530 &pslld ("mm3",24); &pslld ("mm7",24);
1531 &psrld ("mm2",8); &psrld ("mm6",8);
1532 &pxor ("mm0","mm3"); &pxor ("mm4","mm7"); # ^= tp2<<24
1533 &pxor ("mm0","mm2"); &pxor ("mm4","mm6"); # ^= tp2>>8
1534
1535 &movq ("mm2",&QWP(8,"esp"));
1536 &pxor ("mm3","mm3"); &pxor ("mm7","mm7");
1537 &pcmpgtb("mm3","mm1"); &pcmpgtb("mm7","mm5");
1538 &pand ("mm3","mm2"); &pand ("mm7","mm2");
1539 &paddb ("mm1","mm1"); &paddb ("mm5","mm5");
1540 &pxor ("mm1","mm3"); &pxor ("mm5","mm7"); # tp4
1541 &pshufw ("mm3","mm1",0xb1); &pshufw ("mm7","mm5",0xb1);
1542 &pxor ("mm0","mm1"); &pxor ("mm4","mm5"); # ^= tp4
1543 &pxor ("mm0","mm3"); &pxor ("mm4","mm7"); # ^= ROTATE(tp4,16)
1544
1545 &pxor ("mm3","mm3"); &pxor ("mm7","mm7");
1546 &pcmpgtb("mm3","mm1"); &pcmpgtb("mm7","mm5");
1547 &pand ("mm3","mm2"); &pand ("mm7","mm2");
1548 &paddb ("mm1","mm1"); &paddb ("mm5","mm5");
1549 &pxor ("mm1","mm3"); &pxor ("mm5","mm7"); # tp8
1550 &pxor ("mm0","mm1"); &pxor ("mm4","mm5"); # ^= tp8
1551 &movq ("mm3","mm1"); &movq ("mm7","mm5");
1552 &pshufw ("mm2","mm1",0xb1); &pshufw ("mm6","mm5",0xb1);
1553 &pxor ("mm0","mm2"); &pxor ("mm4","mm6"); # ^= ROTATE(tp8,16)
1554 &pslld ("mm1",8); &pslld ("mm5",8);
1555 &psrld ("mm3",8); &psrld ("mm7",8);
1556 &movq ("mm2",&QWP(0,$key)); &movq ("mm6",&QWP(8,$key));
1557 &pxor ("mm0","mm1"); &pxor ("mm4","mm5"); # ^= tp8<<8
1558 &pxor ("mm0","mm3"); &pxor ("mm4","mm7"); # ^= tp8>>8
1559 &mov ($s0,&DWP(0-128,$tbl));
1560 &pslld ("mm1",16); &pslld ("mm5",16);
1561 &mov ($s1,&DWP(64-128,$tbl));
1562 &psrld ("mm3",16); &psrld ("mm7",16);
1563 &mov ($s2,&DWP(128-128,$tbl));
1564 &pxor ("mm0","mm1"); &pxor ("mm4","mm5"); # ^= tp8<<24
1565 &mov ($s3,&DWP(192-128,$tbl));
1566 &pxor ("mm0","mm3"); &pxor ("mm4","mm7"); # ^= tp8>>24
1567
1568 &pxor ("mm0","mm2"); &pxor ("mm4","mm6");
1569 &jmp (&label("loop"));
1570
1571 &set_label("out",16);
1572 &pxor ("mm0",&QWP(0,$key));
1573 &pxor ("mm4",&QWP(8,$key));
1574
1575 &ret ();
1576&function_end_B("_sse_AES_decrypt_compact");
1577 }
1578
1579######################################################################
1580# Vanilla block function.
1581######################################################################
473 1582
474sub decstep() 1583sub decstep()
475{ my ($i,$td,@s) = @_; 1584{ my ($i,$td,@s) = @_;
@@ -480,7 +1589,7 @@ sub decstep()
480 # optimal... or rather that all attempts to reorder didn't 1589 # optimal... or rather that all attempts to reorder didn't
481 # result in better performance [which by the way is not a 1590 # result in better performance [which by the way is not a
482 # bit lower than ecryption]. 1591 # bit lower than ecryption].
483 if($i==3) { &mov ($key,&DWP(12,"esp")); } 1592 if($i==3) { &mov ($key,$__key); }
484 else { &mov ($out,$s[0]); } 1593 else { &mov ($out,$s[0]); }
485 &and ($out,0xFF); 1594 &and ($out,0xFF);
486 &mov ($out,&DWP(0,$td,$out,8)); 1595 &mov ($out,&DWP(0,$td,$out,8));
@@ -495,12 +1604,12 @@ sub decstep()
495 &and ($tmp,0xFF); 1604 &and ($tmp,0xFF);
496 &xor ($out,&DWP(2,$td,$tmp,8)); 1605 &xor ($out,&DWP(2,$td,$tmp,8));
497 1606
498 if ($i==3) { $tmp=$s[3]; &mov ($s[2],&DWP(8,"esp")); } 1607 if ($i==3) { $tmp=$s[3]; &mov ($s[2],$__s1); }
499 else { &mov ($tmp,$s[3]); } 1608 else { &mov ($tmp,$s[3]); }
500 &shr ($tmp,24); 1609 &shr ($tmp,24);
501 &xor ($out,&DWP(1,$td,$tmp,8)); 1610 &xor ($out,&DWP(1,$td,$tmp,8));
502 if ($i<2) { &mov (&DWP(4+4*$i,"esp"),$out); } 1611 if ($i<2) { &mov (&DWP(4+4*$i,"esp"),$out); }
503 if ($i==3) { &mov ($s[3],&DWP(4,"esp")); } 1612 if ($i==3) { &mov ($s[3],$__s0); }
504 &comment(); 1613 &comment();
505} 1614}
506 1615
@@ -509,14 +1618,24 @@ sub declast()
509 my $tmp = $key; 1618 my $tmp = $key;
510 my $out = $i==3?$s[0]:$acc; 1619 my $out = $i==3?$s[0]:$acc;
511 1620
512 if($i==3) { &mov ($key,&DWP(12,"esp")); } 1621 if($i==0) { &lea ($td,&DWP(2048+128,$td));
1622 &mov ($tmp,&DWP(0-128,$td));
1623 &mov ($acc,&DWP(32-128,$td));
1624 &mov ($tmp,&DWP(64-128,$td));
1625 &mov ($acc,&DWP(96-128,$td));
1626 &mov ($tmp,&DWP(128-128,$td));
1627 &mov ($acc,&DWP(160-128,$td));
1628 &mov ($tmp,&DWP(192-128,$td));
1629 &mov ($acc,&DWP(224-128,$td));
1630 &lea ($td,&DWP(-128,$td)); }
1631 if($i==3) { &mov ($key,$__key); }
513 else { &mov ($out,$s[0]); } 1632 else { &mov ($out,$s[0]); }
514 &and ($out,0xFF); 1633 &and ($out,0xFF);
515 &movz ($out,&BP(2048,$td,$out,1)); 1634 &movz ($out,&BP(0,$td,$out,1));
516 1635
517 if ($i==3) { $tmp=$s[1]; } 1636 if ($i==3) { $tmp=$s[1]; }
518 &movz ($tmp,&HB($s[1])); 1637 &movz ($tmp,&HB($s[1]));
519 &movz ($tmp,&BP(2048,$td,$tmp,1)); 1638 &movz ($tmp,&BP(0,$td,$tmp,1));
520 &shl ($tmp,8); 1639 &shl ($tmp,8);
521 &xor ($out,$tmp); 1640 &xor ($out,$tmp);
522 1641
@@ -524,24 +1643,24 @@ sub declast()
524 else { mov ($tmp,$s[2]); } 1643 else { mov ($tmp,$s[2]); }
525 &shr ($tmp,16); 1644 &shr ($tmp,16);
526 &and ($tmp,0xFF); 1645 &and ($tmp,0xFF);
527 &movz ($tmp,&BP(2048,$td,$tmp,1)); 1646 &movz ($tmp,&BP(0,$td,$tmp,1));
528 &shl ($tmp,16); 1647 &shl ($tmp,16);
529 &xor ($out,$tmp); 1648 &xor ($out,$tmp);
530 1649
531 if ($i==3) { $tmp=$s[3]; &mov ($s[2],&DWP(8,"esp")); } 1650 if ($i==3) { $tmp=$s[3]; &mov ($s[2],$__s1); }
532 else { &mov ($tmp,$s[3]); } 1651 else { &mov ($tmp,$s[3]); }
533 &shr ($tmp,24); 1652 &shr ($tmp,24);
534 &movz ($tmp,&BP(2048,$td,$tmp,1)); 1653 &movz ($tmp,&BP(0,$td,$tmp,1));
535 &shl ($tmp,24); 1654 &shl ($tmp,24);
536 &xor ($out,$tmp); 1655 &xor ($out,$tmp);
537 if ($i<2) { &mov (&DWP(4+4*$i,"esp"),$out); } 1656 if ($i<2) { &mov (&DWP(4+4*$i,"esp"),$out); }
538 if ($i==3) { &mov ($s[3],&DWP(4,"esp")); } 1657 if ($i==3) { &mov ($s[3],$__s0);
1658 &lea ($td,&DWP(-2048,$td)); }
539} 1659}
540 1660
541&public_label("AES_Td"); 1661&function_begin_B("_x86_AES_decrypt");
542&function_begin_C("_x86_AES_decrypt");
543 # note that caller is expected to allocate stack frame for me! 1662 # note that caller is expected to allocate stack frame for me!
544 &mov (&DWP(12,"esp"),$key); # save key 1663 &mov ($__key,$key); # save key
545 1664
546 &xor ($s0,&DWP(0,$key)); # xor with key 1665 &xor ($s0,&DWP(0,$key)); # xor with key
547 &xor ($s1,&DWP(4,$key)); 1666 &xor ($s1,&DWP(4,$key));
@@ -553,20 +1672,19 @@ sub declast()
553 if ($small_footprint) { 1672 if ($small_footprint) {
554 &lea ($acc,&DWP(-2,$acc,$acc)); 1673 &lea ($acc,&DWP(-2,$acc,$acc));
555 &lea ($acc,&DWP(0,$key,$acc,8)); 1674 &lea ($acc,&DWP(0,$key,$acc,8));
556 &mov (&DWP(16,"esp"),$acc); # end of key schedule 1675 &mov ($__end,$acc); # end of key schedule
557 &align (4); 1676 &set_label("loop",16);
558 &set_label("loop"); 1677 &decstep(0,$tbl,$s0,$s3,$s2,$s1);
559 &decstep(0,"ebp",$s0,$s3,$s2,$s1); 1678 &decstep(1,$tbl,$s1,$s0,$s3,$s2);
560 &decstep(1,"ebp",$s1,$s0,$s3,$s2); 1679 &decstep(2,$tbl,$s2,$s1,$s0,$s3);
561 &decstep(2,"ebp",$s2,$s1,$s0,$s3); 1680 &decstep(3,$tbl,$s3,$s2,$s1,$s0);
562 &decstep(3,"ebp",$s3,$s2,$s1,$s0);
563 &add ($key,16); # advance rd_key 1681 &add ($key,16); # advance rd_key
564 &xor ($s0,&DWP(0,$key)); 1682 &xor ($s0,&DWP(0,$key));
565 &xor ($s1,&DWP(4,$key)); 1683 &xor ($s1,&DWP(4,$key));
566 &xor ($s2,&DWP(8,$key)); 1684 &xor ($s2,&DWP(8,$key));
567 &xor ($s3,&DWP(12,$key)); 1685 &xor ($s3,&DWP(12,$key));
568 &cmp ($key,&DWP(16,"esp")); 1686 &cmp ($key,$__end);
569 &mov (&DWP(12,"esp"),$key); 1687 &mov ($__key,$key);
570 &jb (&label("loop")); 1688 &jb (&label("loop"));
571 } 1689 }
572 else { 1690 else {
@@ -575,38 +1693,38 @@ sub declast()
575 &cmp ($acc,12); 1693 &cmp ($acc,12);
576 &jle (&label("12rounds")); 1694 &jle (&label("12rounds"));
577 1695
578 &set_label("14rounds"); 1696 &set_label("14rounds",4);
579 for ($i=1;$i<3;$i++) { 1697 for ($i=1;$i<3;$i++) {
580 &decstep(0,"ebp",$s0,$s3,$s2,$s1); 1698 &decstep(0,$tbl,$s0,$s3,$s2,$s1);
581 &decstep(1,"ebp",$s1,$s0,$s3,$s2); 1699 &decstep(1,$tbl,$s1,$s0,$s3,$s2);
582 &decstep(2,"ebp",$s2,$s1,$s0,$s3); 1700 &decstep(2,$tbl,$s2,$s1,$s0,$s3);
583 &decstep(3,"ebp",$s3,$s2,$s1,$s0); 1701 &decstep(3,$tbl,$s3,$s2,$s1,$s0);
584 &xor ($s0,&DWP(16*$i+0,$key)); 1702 &xor ($s0,&DWP(16*$i+0,$key));
585 &xor ($s1,&DWP(16*$i+4,$key)); 1703 &xor ($s1,&DWP(16*$i+4,$key));
586 &xor ($s2,&DWP(16*$i+8,$key)); 1704 &xor ($s2,&DWP(16*$i+8,$key));
587 &xor ($s3,&DWP(16*$i+12,$key)); 1705 &xor ($s3,&DWP(16*$i+12,$key));
588 } 1706 }
589 &add ($key,32); 1707 &add ($key,32);
590 &mov (&DWP(12,"esp"),$key); # advance rd_key 1708 &mov ($__key,$key); # advance rd_key
591 &set_label("12rounds"); 1709 &set_label("12rounds",4);
592 for ($i=1;$i<3;$i++) { 1710 for ($i=1;$i<3;$i++) {
593 &decstep(0,"ebp",$s0,$s3,$s2,$s1); 1711 &decstep(0,$tbl,$s0,$s3,$s2,$s1);
594 &decstep(1,"ebp",$s1,$s0,$s3,$s2); 1712 &decstep(1,$tbl,$s1,$s0,$s3,$s2);
595 &decstep(2,"ebp",$s2,$s1,$s0,$s3); 1713 &decstep(2,$tbl,$s2,$s1,$s0,$s3);
596 &decstep(3,"ebp",$s3,$s2,$s1,$s0); 1714 &decstep(3,$tbl,$s3,$s2,$s1,$s0);
597 &xor ($s0,&DWP(16*$i+0,$key)); 1715 &xor ($s0,&DWP(16*$i+0,$key));
598 &xor ($s1,&DWP(16*$i+4,$key)); 1716 &xor ($s1,&DWP(16*$i+4,$key));
599 &xor ($s2,&DWP(16*$i+8,$key)); 1717 &xor ($s2,&DWP(16*$i+8,$key));
600 &xor ($s3,&DWP(16*$i+12,$key)); 1718 &xor ($s3,&DWP(16*$i+12,$key));
601 } 1719 }
602 &add ($key,32); 1720 &add ($key,32);
603 &mov (&DWP(12,"esp"),$key); # advance rd_key 1721 &mov ($__key,$key); # advance rd_key
604 &set_label("10rounds"); 1722 &set_label("10rounds",4);
605 for ($i=1;$i<10;$i++) { 1723 for ($i=1;$i<10;$i++) {
606 &decstep(0,"ebp",$s0,$s3,$s2,$s1); 1724 &decstep(0,$tbl,$s0,$s3,$s2,$s1);
607 &decstep(1,"ebp",$s1,$s0,$s3,$s2); 1725 &decstep(1,$tbl,$s1,$s0,$s3,$s2);
608 &decstep(2,"ebp",$s2,$s1,$s0,$s3); 1726 &decstep(2,$tbl,$s2,$s1,$s0,$s3);
609 &decstep(3,"ebp",$s3,$s2,$s1,$s0); 1727 &decstep(3,$tbl,$s3,$s2,$s1,$s0);
610 &xor ($s0,&DWP(16*$i+0,$key)); 1728 &xor ($s0,&DWP(16*$i+0,$key));
611 &xor ($s1,&DWP(16*$i+4,$key)); 1729 &xor ($s1,&DWP(16*$i+4,$key));
612 &xor ($s2,&DWP(16*$i+8,$key)); 1730 &xor ($s2,&DWP(16*$i+8,$key));
@@ -614,10 +1732,10 @@ sub declast()
614 } 1732 }
615 } 1733 }
616 1734
617 &declast(0,"ebp",$s0,$s3,$s2,$s1); 1735 &declast(0,$tbl,$s0,$s3,$s2,$s1);
618 &declast(1,"ebp",$s1,$s0,$s3,$s2); 1736 &declast(1,$tbl,$s1,$s0,$s3,$s2);
619 &declast(2,"ebp",$s2,$s1,$s0,$s3); 1737 &declast(2,$tbl,$s2,$s1,$s0,$s3);
620 &declast(3,"ebp",$s3,$s2,$s1,$s0); 1738 &declast(3,$tbl,$s3,$s2,$s1,$s0);
621 1739
622 &add ($key,$small_footprint?16:160); 1740 &add ($key,$small_footprint?16:160);
623 &xor ($s0,&DWP(0,$key)); 1741 &xor ($s0,&DWP(0,$key));
@@ -692,7 +1810,107 @@ sub declast()
692 &_data_word(0x72c31d16, 0x0c25e2bc, 0x8b493c28, 0x41950dff); 1810 &_data_word(0x72c31d16, 0x0c25e2bc, 0x8b493c28, 0x41950dff);
693 &_data_word(0x7101a839, 0xdeb30c08, 0x9ce4b4d8, 0x90c15664); 1811 &_data_word(0x7101a839, 0xdeb30c08, 0x9ce4b4d8, 0x90c15664);
694 &_data_word(0x6184cb7b, 0x70b632d5, 0x745c6c48, 0x4257b8d0); 1812 &_data_word(0x6184cb7b, 0x70b632d5, 0x745c6c48, 0x4257b8d0);
695#Td4: 1813
1814#Td4: # four copies of Td4 to choose from to avoid L1 aliasing
1815 &data_byte(0x52, 0x09, 0x6a, 0xd5, 0x30, 0x36, 0xa5, 0x38);
1816 &data_byte(0xbf, 0x40, 0xa3, 0x9e, 0x81, 0xf3, 0xd7, 0xfb);
1817 &data_byte(0x7c, 0xe3, 0x39, 0x82, 0x9b, 0x2f, 0xff, 0x87);
1818 &data_byte(0x34, 0x8e, 0x43, 0x44, 0xc4, 0xde, 0xe9, 0xcb);
1819 &data_byte(0x54, 0x7b, 0x94, 0x32, 0xa6, 0xc2, 0x23, 0x3d);
1820 &data_byte(0xee, 0x4c, 0x95, 0x0b, 0x42, 0xfa, 0xc3, 0x4e);
1821 &data_byte(0x08, 0x2e, 0xa1, 0x66, 0x28, 0xd9, 0x24, 0xb2);
1822 &data_byte(0x76, 0x5b, 0xa2, 0x49, 0x6d, 0x8b, 0xd1, 0x25);
1823 &data_byte(0x72, 0xf8, 0xf6, 0x64, 0x86, 0x68, 0x98, 0x16);
1824 &data_byte(0xd4, 0xa4, 0x5c, 0xcc, 0x5d, 0x65, 0xb6, 0x92);
1825 &data_byte(0x6c, 0x70, 0x48, 0x50, 0xfd, 0xed, 0xb9, 0xda);
1826 &data_byte(0x5e, 0x15, 0x46, 0x57, 0xa7, 0x8d, 0x9d, 0x84);
1827 &data_byte(0x90, 0xd8, 0xab, 0x00, 0x8c, 0xbc, 0xd3, 0x0a);
1828 &data_byte(0xf7, 0xe4, 0x58, 0x05, 0xb8, 0xb3, 0x45, 0x06);
1829 &data_byte(0xd0, 0x2c, 0x1e, 0x8f, 0xca, 0x3f, 0x0f, 0x02);
1830 &data_byte(0xc1, 0xaf, 0xbd, 0x03, 0x01, 0x13, 0x8a, 0x6b);
1831 &data_byte(0x3a, 0x91, 0x11, 0x41, 0x4f, 0x67, 0xdc, 0xea);
1832 &data_byte(0x97, 0xf2, 0xcf, 0xce, 0xf0, 0xb4, 0xe6, 0x73);
1833 &data_byte(0x96, 0xac, 0x74, 0x22, 0xe7, 0xad, 0x35, 0x85);
1834 &data_byte(0xe2, 0xf9, 0x37, 0xe8, 0x1c, 0x75, 0xdf, 0x6e);
1835 &data_byte(0x47, 0xf1, 0x1a, 0x71, 0x1d, 0x29, 0xc5, 0x89);
1836 &data_byte(0x6f, 0xb7, 0x62, 0x0e, 0xaa, 0x18, 0xbe, 0x1b);
1837 &data_byte(0xfc, 0x56, 0x3e, 0x4b, 0xc6, 0xd2, 0x79, 0x20);
1838 &data_byte(0x9a, 0xdb, 0xc0, 0xfe, 0x78, 0xcd, 0x5a, 0xf4);
1839 &data_byte(0x1f, 0xdd, 0xa8, 0x33, 0x88, 0x07, 0xc7, 0x31);
1840 &data_byte(0xb1, 0x12, 0x10, 0x59, 0x27, 0x80, 0xec, 0x5f);
1841 &data_byte(0x60, 0x51, 0x7f, 0xa9, 0x19, 0xb5, 0x4a, 0x0d);
1842 &data_byte(0x2d, 0xe5, 0x7a, 0x9f, 0x93, 0xc9, 0x9c, 0xef);
1843 &data_byte(0xa0, 0xe0, 0x3b, 0x4d, 0xae, 0x2a, 0xf5, 0xb0);
1844 &data_byte(0xc8, 0xeb, 0xbb, 0x3c, 0x83, 0x53, 0x99, 0x61);
1845 &data_byte(0x17, 0x2b, 0x04, 0x7e, 0xba, 0x77, 0xd6, 0x26);
1846 &data_byte(0xe1, 0x69, 0x14, 0x63, 0x55, 0x21, 0x0c, 0x7d);
1847
1848 &data_byte(0x52, 0x09, 0x6a, 0xd5, 0x30, 0x36, 0xa5, 0x38);
1849 &data_byte(0xbf, 0x40, 0xa3, 0x9e, 0x81, 0xf3, 0xd7, 0xfb);
1850 &data_byte(0x7c, 0xe3, 0x39, 0x82, 0x9b, 0x2f, 0xff, 0x87);
1851 &data_byte(0x34, 0x8e, 0x43, 0x44, 0xc4, 0xde, 0xe9, 0xcb);
1852 &data_byte(0x54, 0x7b, 0x94, 0x32, 0xa6, 0xc2, 0x23, 0x3d);
1853 &data_byte(0xee, 0x4c, 0x95, 0x0b, 0x42, 0xfa, 0xc3, 0x4e);
1854 &data_byte(0x08, 0x2e, 0xa1, 0x66, 0x28, 0xd9, 0x24, 0xb2);
1855 &data_byte(0x76, 0x5b, 0xa2, 0x49, 0x6d, 0x8b, 0xd1, 0x25);
1856 &data_byte(0x72, 0xf8, 0xf6, 0x64, 0x86, 0x68, 0x98, 0x16);
1857 &data_byte(0xd4, 0xa4, 0x5c, 0xcc, 0x5d, 0x65, 0xb6, 0x92);
1858 &data_byte(0x6c, 0x70, 0x48, 0x50, 0xfd, 0xed, 0xb9, 0xda);
1859 &data_byte(0x5e, 0x15, 0x46, 0x57, 0xa7, 0x8d, 0x9d, 0x84);
1860 &data_byte(0x90, 0xd8, 0xab, 0x00, 0x8c, 0xbc, 0xd3, 0x0a);
1861 &data_byte(0xf7, 0xe4, 0x58, 0x05, 0xb8, 0xb3, 0x45, 0x06);
1862 &data_byte(0xd0, 0x2c, 0x1e, 0x8f, 0xca, 0x3f, 0x0f, 0x02);
1863 &data_byte(0xc1, 0xaf, 0xbd, 0x03, 0x01, 0x13, 0x8a, 0x6b);
1864 &data_byte(0x3a, 0x91, 0x11, 0x41, 0x4f, 0x67, 0xdc, 0xea);
1865 &data_byte(0x97, 0xf2, 0xcf, 0xce, 0xf0, 0xb4, 0xe6, 0x73);
1866 &data_byte(0x96, 0xac, 0x74, 0x22, 0xe7, 0xad, 0x35, 0x85);
1867 &data_byte(0xe2, 0xf9, 0x37, 0xe8, 0x1c, 0x75, 0xdf, 0x6e);
1868 &data_byte(0x47, 0xf1, 0x1a, 0x71, 0x1d, 0x29, 0xc5, 0x89);
1869 &data_byte(0x6f, 0xb7, 0x62, 0x0e, 0xaa, 0x18, 0xbe, 0x1b);
1870 &data_byte(0xfc, 0x56, 0x3e, 0x4b, 0xc6, 0xd2, 0x79, 0x20);
1871 &data_byte(0x9a, 0xdb, 0xc0, 0xfe, 0x78, 0xcd, 0x5a, 0xf4);
1872 &data_byte(0x1f, 0xdd, 0xa8, 0x33, 0x88, 0x07, 0xc7, 0x31);
1873 &data_byte(0xb1, 0x12, 0x10, 0x59, 0x27, 0x80, 0xec, 0x5f);
1874 &data_byte(0x60, 0x51, 0x7f, 0xa9, 0x19, 0xb5, 0x4a, 0x0d);
1875 &data_byte(0x2d, 0xe5, 0x7a, 0x9f, 0x93, 0xc9, 0x9c, 0xef);
1876 &data_byte(0xa0, 0xe0, 0x3b, 0x4d, 0xae, 0x2a, 0xf5, 0xb0);
1877 &data_byte(0xc8, 0xeb, 0xbb, 0x3c, 0x83, 0x53, 0x99, 0x61);
1878 &data_byte(0x17, 0x2b, 0x04, 0x7e, 0xba, 0x77, 0xd6, 0x26);
1879 &data_byte(0xe1, 0x69, 0x14, 0x63, 0x55, 0x21, 0x0c, 0x7d);
1880
1881 &data_byte(0x52, 0x09, 0x6a, 0xd5, 0x30, 0x36, 0xa5, 0x38);
1882 &data_byte(0xbf, 0x40, 0xa3, 0x9e, 0x81, 0xf3, 0xd7, 0xfb);
1883 &data_byte(0x7c, 0xe3, 0x39, 0x82, 0x9b, 0x2f, 0xff, 0x87);
1884 &data_byte(0x34, 0x8e, 0x43, 0x44, 0xc4, 0xde, 0xe9, 0xcb);
1885 &data_byte(0x54, 0x7b, 0x94, 0x32, 0xa6, 0xc2, 0x23, 0x3d);
1886 &data_byte(0xee, 0x4c, 0x95, 0x0b, 0x42, 0xfa, 0xc3, 0x4e);
1887 &data_byte(0x08, 0x2e, 0xa1, 0x66, 0x28, 0xd9, 0x24, 0xb2);
1888 &data_byte(0x76, 0x5b, 0xa2, 0x49, 0x6d, 0x8b, 0xd1, 0x25);
1889 &data_byte(0x72, 0xf8, 0xf6, 0x64, 0x86, 0x68, 0x98, 0x16);
1890 &data_byte(0xd4, 0xa4, 0x5c, 0xcc, 0x5d, 0x65, 0xb6, 0x92);
1891 &data_byte(0x6c, 0x70, 0x48, 0x50, 0xfd, 0xed, 0xb9, 0xda);
1892 &data_byte(0x5e, 0x15, 0x46, 0x57, 0xa7, 0x8d, 0x9d, 0x84);
1893 &data_byte(0x90, 0xd8, 0xab, 0x00, 0x8c, 0xbc, 0xd3, 0x0a);
1894 &data_byte(0xf7, 0xe4, 0x58, 0x05, 0xb8, 0xb3, 0x45, 0x06);
1895 &data_byte(0xd0, 0x2c, 0x1e, 0x8f, 0xca, 0x3f, 0x0f, 0x02);
1896 &data_byte(0xc1, 0xaf, 0xbd, 0x03, 0x01, 0x13, 0x8a, 0x6b);
1897 &data_byte(0x3a, 0x91, 0x11, 0x41, 0x4f, 0x67, 0xdc, 0xea);
1898 &data_byte(0x97, 0xf2, 0xcf, 0xce, 0xf0, 0xb4, 0xe6, 0x73);
1899 &data_byte(0x96, 0xac, 0x74, 0x22, 0xe7, 0xad, 0x35, 0x85);
1900 &data_byte(0xe2, 0xf9, 0x37, 0xe8, 0x1c, 0x75, 0xdf, 0x6e);
1901 &data_byte(0x47, 0xf1, 0x1a, 0x71, 0x1d, 0x29, 0xc5, 0x89);
1902 &data_byte(0x6f, 0xb7, 0x62, 0x0e, 0xaa, 0x18, 0xbe, 0x1b);
1903 &data_byte(0xfc, 0x56, 0x3e, 0x4b, 0xc6, 0xd2, 0x79, 0x20);
1904 &data_byte(0x9a, 0xdb, 0xc0, 0xfe, 0x78, 0xcd, 0x5a, 0xf4);
1905 &data_byte(0x1f, 0xdd, 0xa8, 0x33, 0x88, 0x07, 0xc7, 0x31);
1906 &data_byte(0xb1, 0x12, 0x10, 0x59, 0x27, 0x80, 0xec, 0x5f);
1907 &data_byte(0x60, 0x51, 0x7f, 0xa9, 0x19, 0xb5, 0x4a, 0x0d);
1908 &data_byte(0x2d, 0xe5, 0x7a, 0x9f, 0x93, 0xc9, 0x9c, 0xef);
1909 &data_byte(0xa0, 0xe0, 0x3b, 0x4d, 0xae, 0x2a, 0xf5, 0xb0);
1910 &data_byte(0xc8, 0xeb, 0xbb, 0x3c, 0x83, 0x53, 0x99, 0x61);
1911 &data_byte(0x17, 0x2b, 0x04, 0x7e, 0xba, 0x77, 0xd6, 0x26);
1912 &data_byte(0xe1, 0x69, 0x14, 0x63, 0x55, 0x21, 0x0c, 0x7d);
1913
696 &data_byte(0x52, 0x09, 0x6a, 0xd5, 0x30, 0x36, 0xa5, 0x38); 1914 &data_byte(0x52, 0x09, 0x6a, 0xd5, 0x30, 0x36, 0xa5, 0x38);
697 &data_byte(0xbf, 0x40, 0xa3, 0x9e, 0x81, 0xf3, 0xd7, 0xfb); 1915 &data_byte(0xbf, 0x40, 0xa3, 0x9e, 0x81, 0xf3, 0xd7, 0xfb);
698 &data_byte(0x7c, 0xe3, 0x39, 0x82, 0x9b, 0x2f, 0xff, 0x87); 1916 &data_byte(0x7c, 0xe3, 0x39, 0x82, 0x9b, 0x2f, 0xff, 0x87);
@@ -728,43 +1946,57 @@ sub declast()
728&function_end_B("_x86_AES_decrypt"); 1946&function_end_B("_x86_AES_decrypt");
729 1947
730# void AES_decrypt (const void *inp,void *out,const AES_KEY *key); 1948# void AES_decrypt (const void *inp,void *out,const AES_KEY *key);
731&public_label("AES_Td");
732&function_begin("AES_decrypt"); 1949&function_begin("AES_decrypt");
733 &mov ($acc,&wparam(0)); # load inp 1950 &mov ($acc,&wparam(0)); # load inp
734 &mov ($key,&wparam(2)); # load key 1951 &mov ($key,&wparam(2)); # load key
735 1952
736 &mov ($s0,"esp"); 1953 &mov ($s0,"esp");
737 &sub ("esp",24); 1954 &sub ("esp",36);
738 &and ("esp",-64); 1955 &and ("esp",-64); # align to cache-line
739 &add ("esp",4); 1956
740 &mov (&DWP(16,"esp"),$s0); 1957 # place stack frame just "above" the key schedule
1958 &lea ($s1,&DWP(-64-63,$key));
1959 &sub ($s1,"esp");
1960 &neg ($s1);
1961 &and ($s1,0x3C0); # modulo 1024, but aligned to cache-line
1962 &sub ("esp",$s1);
1963 &add ("esp",4); # 4 is reserved for caller's return address
1964 &mov ($_esp,$s0); # save stack pointer
741 1965
742 &call (&label("pic_point")); # make it PIC! 1966 &call (&label("pic_point")); # make it PIC!
743 &set_label("pic_point"); 1967 &set_label("pic_point");
744 &blindpop("ebp"); 1968 &blindpop($tbl);
745 &lea ("ebp",&DWP(&label("AES_Td")."-".&label("pic_point"),"ebp")); 1969 &picmeup($s0,"OPENSSL_ia32cap_P",$tbl,&label("pic_point")) if(!$x86only);
746 1970 &lea ($tbl,&DWP(&label("AES_Td")."-".&label("pic_point"),$tbl));
747 # prefetch Td4 1971
748 &lea ("ebp",&DWP(2048+128,"ebp")); 1972 # pick Td4 copy which can't "overlap" with stack frame or key schedule
749 &mov ($s0,&DWP(0-128,"ebp")); 1973 &lea ($s1,&DWP(768-4,"esp"));
750 &mov ($s1,&DWP(32-128,"ebp")); 1974 &sub ($s1,$tbl);
751 &mov ($s2,&DWP(64-128,"ebp")); 1975 &and ($s1,0x300);
752 &mov ($s3,&DWP(96-128,"ebp")); 1976 &lea ($tbl,&DWP(2048+128,$tbl,$s1));
753 &mov ($s0,&DWP(128-128,"ebp")); 1977
754 &mov ($s1,&DWP(160-128,"ebp")); 1978 if (!$x86only) {
755 &mov ($s2,&DWP(192-128,"ebp")); 1979 &bt (&DWP(0,$s0),25); # check for SSE bit
756 &mov ($s3,&DWP(224-128,"ebp")); 1980 &jnc (&label("x86"));
757 &lea ("ebp",&DWP(-2048-128,"ebp")); 1981
758 1982 &movq ("mm0",&QWP(0,$acc));
1983 &movq ("mm4",&QWP(8,$acc));
1984 &call ("_sse_AES_decrypt_compact");
1985 &mov ("esp",$_esp); # restore stack pointer
1986 &mov ($acc,&wparam(1)); # load out
1987 &movq (&QWP(0,$acc),"mm0"); # write output data
1988 &movq (&QWP(8,$acc),"mm4");
1989 &emms ();
1990 &function_end_A();
1991 }
1992 &set_label("x86",16);
1993 &mov ($_tbl,$tbl);
759 &mov ($s0,&DWP(0,$acc)); # load input data 1994 &mov ($s0,&DWP(0,$acc)); # load input data
760 &mov ($s1,&DWP(4,$acc)); 1995 &mov ($s1,&DWP(4,$acc));
761 &mov ($s2,&DWP(8,$acc)); 1996 &mov ($s2,&DWP(8,$acc));
762 &mov ($s3,&DWP(12,$acc)); 1997 &mov ($s3,&DWP(12,$acc));
763 1998 &call ("_x86_AES_decrypt_compact");
764 &call ("_x86_AES_decrypt"); 1999 &mov ("esp",$_esp); # restore stack pointer
765
766 &mov ("esp",&DWP(16,"esp"));
767
768 &mov ($acc,&wparam(1)); # load out 2000 &mov ($acc,&wparam(1)); # load out
769 &mov (&DWP(0,$acc),$s0); # write output data 2001 &mov (&DWP(0,$acc),$s0); # write output data
770 &mov (&DWP(4,$acc),$s1); 2002 &mov (&DWP(4,$acc),$s1);
@@ -777,126 +2009,136 @@ sub declast()
777# unsigned char *ivp,const int enc); 2009# unsigned char *ivp,const int enc);
778{ 2010{
779# stack frame layout 2011# stack frame layout
780# -4(%esp) 0(%esp) return address 2012# -4(%esp) # return address 0(%esp)
781# 0(%esp) 4(%esp) tmp1 2013# 0(%esp) # s0 backing store 4(%esp)
782# 4(%esp) 8(%esp) tmp2 2014# 4(%esp) # s1 backing store 8(%esp)
783# 8(%esp) 12(%esp) key 2015# 8(%esp) # s2 backing store 12(%esp)
784# 12(%esp) 16(%esp) end of key schedule 2016# 12(%esp) # s3 backing store 16(%esp)
785my $_esp=&DWP(16,"esp"); #saved %esp 2017# 16(%esp) # key backup 20(%esp)
786my $_inp=&DWP(20,"esp"); #copy of wparam(0) 2018# 20(%esp) # end of key schedule 24(%esp)
787my $_out=&DWP(24,"esp"); #copy of wparam(1) 2019# 24(%esp) # %ebp backup 28(%esp)
788my $_len=&DWP(28,"esp"); #copy of wparam(2) 2020# 28(%esp) # %esp backup
789my $_key=&DWP(32,"esp"); #copy of wparam(3) 2021my $_inp=&DWP(32,"esp"); # copy of wparam(0)
790my $_ivp=&DWP(36,"esp"); #copy of wparam(4) 2022my $_out=&DWP(36,"esp"); # copy of wparam(1)
791my $_tmp=&DWP(40,"esp"); #volatile variable 2023my $_len=&DWP(40,"esp"); # copy of wparam(2)
792my $ivec=&DWP(44,"esp"); #ivec[16] 2024my $_key=&DWP(44,"esp"); # copy of wparam(3)
793my $aes_key=&DWP(60,"esp"); #copy of aes_key 2025my $_ivp=&DWP(48,"esp"); # copy of wparam(4)
794my $mark=&DWP(60+240,"esp"); #copy of aes_key->rounds 2026my $_tmp=&DWP(52,"esp"); # volatile variable
795 2027#
796&public_label("AES_Te"); 2028my $ivec=&DWP(60,"esp"); # ivec[16]
797&public_label("AES_Td"); 2029my $aes_key=&DWP(76,"esp"); # copy of aes_key
2030my $mark=&DWP(76+240,"esp"); # copy of aes_key->rounds
2031
798&function_begin("AES_cbc_encrypt"); 2032&function_begin("AES_cbc_encrypt");
799 &mov ($s2 eq "ecx"? $s2 : "",&wparam(2)); # load len 2033 &mov ($s2 eq "ecx"? $s2 : "",&wparam(2)); # load len
800 &cmp ($s2,0); 2034 &cmp ($s2,0);
801 &je (&label("enc_out")); 2035 &je (&label("drop_out"));
802 2036
803 &call (&label("pic_point")); # make it PIC! 2037 &call (&label("pic_point")); # make it PIC!
804 &set_label("pic_point"); 2038 &set_label("pic_point");
805 &blindpop("ebp"); 2039 &blindpop($tbl);
806 2040 &picmeup($s0,"OPENSSL_ia32cap_P",$tbl,&label("pic_point")) if(!$x86only);
807 &pushf ();
808 &cld ();
809 2041
810 &cmp (&wparam(5),0); 2042 &cmp (&wparam(5),0);
811 &je (&label("DECRYPT")); 2043 &lea ($tbl,&DWP(&label("AES_Te")."-".&label("pic_point"),$tbl));
2044 &jne (&label("picked_te"));
2045 &lea ($tbl,&DWP(&label("AES_Td")."-".&label("AES_Te"),$tbl));
2046 &set_label("picked_te");
812 2047
813 &lea ("ebp",&DWP(&label("AES_Te")."-".&label("pic_point"),"ebp")); 2048 # one can argue if this is required
814 2049 &pushf ();
815 # allocate aligned stack frame... 2050 &cld ();
816 &lea ($key,&DWP(-64-244,"esp"));
817 &and ($key,-64);
818 2051
819 # ... and make sure it doesn't alias with AES_Te modulo 4096 2052 &cmp ($s2,$speed_limit);
820 &mov ($s0,"ebp"); 2053 &jb (&label("slow_way"));
821 &lea ($s1,&DWP(2048,"ebp")); 2054 &test ($s2,15);
822 &mov ($s3,$key); 2055 &jnz (&label("slow_way"));
2056 if (!$x86only) {
2057 &bt (&DWP(0,$s0),28); # check for hyper-threading bit
2058 &jc (&label("slow_way"));
2059 }
2060 # pre-allocate aligned stack frame...
2061 &lea ($acc,&DWP(-80-244,"esp"));
2062 &and ($acc,-64);
2063
2064 # ... and make sure it doesn't alias with $tbl modulo 4096
2065 &mov ($s0,$tbl);
2066 &lea ($s1,&DWP(2048+256,$tbl));
2067 &mov ($s3,$acc);
823 &and ($s0,0xfff); # s = %ebp&0xfff 2068 &and ($s0,0xfff); # s = %ebp&0xfff
824 &and ($s1,0xfff); # e = (%ebp+2048)&0xfff 2069 &and ($s1,0xfff); # e = (%ebp+2048+256)&0xfff
825 &and ($s3,0xfff); # p = %esp&0xfff 2070 &and ($s3,0xfff); # p = %esp&0xfff
826 2071
827 &cmp ($s3,$s1); # if (p>=e) %esp =- (p-e); 2072 &cmp ($s3,$s1); # if (p>=e) %esp =- (p-e);
828 &jb (&label("te_break_out")); 2073 &jb (&label("tbl_break_out"));
829 &sub ($s3,$s1); 2074 &sub ($s3,$s1);
830 &sub ($key,$s3); 2075 &sub ($acc,$s3);
831 &jmp (&label("te_ok")); 2076 &jmp (&label("tbl_ok"));
832 &set_label("te_break_out"); # else %esp -= (p-s)&0xfff + framesz; 2077 &set_label("tbl_break_out",4); # else %esp -= (p-s)&0xfff + framesz;
833 &sub ($s3,$s0); 2078 &sub ($s3,$s0);
834 &and ($s3,0xfff); 2079 &and ($s3,0xfff);
835 &add ($s3,64+256); 2080 &add ($s3,384);
836 &sub ($key,$s3); 2081 &sub ($acc,$s3);
837 &align (4); 2082 &set_label("tbl_ok",4);
838 &set_label("te_ok");
839 2083
840 &mov ($s0,&wparam(0)); # load inp 2084 &lea ($s3,&wparam(0)); # obtain pointer to parameter block
841 &mov ($s1,&wparam(1)); # load out 2085 &exch ("esp",$acc); # allocate stack frame
842 &mov ($s3,&wparam(3)); # load key
843 &mov ($acc,&wparam(4)); # load ivp
844
845 &exch ("esp",$key);
846 &add ("esp",4); # reserve for return address! 2086 &add ("esp",4); # reserve for return address!
847 &mov ($_esp,$key); # save %esp 2087 &mov ($_tbl,$tbl); # save %ebp
2088 &mov ($_esp,$acc); # save %esp
2089
2090 &mov ($s0,&DWP(0,$s3)); # load inp
2091 &mov ($s1,&DWP(4,$s3)); # load out
2092 #&mov ($s2,&DWP(8,$s3)); # load len
2093 &mov ($key,&DWP(12,$s3)); # load key
2094 &mov ($acc,&DWP(16,$s3)); # load ivp
2095 &mov ($s3,&DWP(20,$s3)); # load enc flag
848 2096
849 &mov ($_inp,$s0); # save copy of inp 2097 &mov ($_inp,$s0); # save copy of inp
850 &mov ($_out,$s1); # save copy of out 2098 &mov ($_out,$s1); # save copy of out
851 &mov ($_len,$s2); # save copy of len 2099 &mov ($_len,$s2); # save copy of len
852 &mov ($_key,$s3); # save copy of key 2100 &mov ($_key,$key); # save copy of key
853 &mov ($_ivp,$acc); # save copy of ivp 2101 &mov ($_ivp,$acc); # save copy of ivp
854 2102
855 &mov ($mark,0); # copy of aes_key->rounds = 0; 2103 &mov ($mark,0); # copy of aes_key->rounds = 0;
856 if ($compromise) {
857 &cmp ($s2,$compromise);
858 &jb (&label("skip_ecopy"));
859 }
860 # do we copy key schedule to stack? 2104 # do we copy key schedule to stack?
861 &mov ($s1 eq "ebx" ? $s1 : "",$s3); 2105 &mov ($s1 eq "ebx" ? $s1 : "",$key);
862 &mov ($s2 eq "ecx" ? $s2 : "",244/4); 2106 &mov ($s2 eq "ecx" ? $s2 : "",244/4);
863 &sub ($s1,"ebp"); 2107 &sub ($s1,$tbl);
864 &mov ("esi",$s3); 2108 &mov ("esi",$key);
865 &and ($s1,0xfff); 2109 &and ($s1,0xfff);
866 &lea ("edi",$aes_key); 2110 &lea ("edi",$aes_key);
867 &cmp ($s1,2048); 2111 &cmp ($s1,2048+256);
868 &jb (&label("do_ecopy")); 2112 &jb (&label("do_copy"));
869 &cmp ($s1,4096-244); 2113 &cmp ($s1,4096-244);
870 &jb (&label("skip_ecopy")); 2114 &jb (&label("skip_copy"));
871 &align (4); 2115 &set_label("do_copy",4);
872 &set_label("do_ecopy");
873 &mov ($_key,"edi"); 2116 &mov ($_key,"edi");
874 &data_word(0xA5F3F689); # rep movsd 2117 &data_word(0xA5F3F689); # rep movsd
875 &set_label("skip_ecopy"); 2118 &set_label("skip_copy");
876 2119
877 &mov ($acc,$s0);
878 &mov ($key,16); 2120 &mov ($key,16);
879 &align (4); 2121 &set_label("prefetch_tbl",4);
880 &set_label("prefetch_te"); 2122 &mov ($s0,&DWP(0,$tbl));
881 &mov ($s0,&DWP(0,"ebp")); 2123 &mov ($s1,&DWP(32,$tbl));
882 &mov ($s1,&DWP(32,"ebp")); 2124 &mov ($s2,&DWP(64,$tbl));
883 &mov ($s2,&DWP(64,"ebp")); 2125 &mov ($acc,&DWP(96,$tbl));
884 &mov ($s3,&DWP(96,"ebp")); 2126 &lea ($tbl,&DWP(128,$tbl));
885 &lea ("ebp",&DWP(128,"ebp")); 2127 &sub ($key,1);
886 &dec ($key); 2128 &jnz (&label("prefetch_tbl"));
887 &jnz (&label("prefetch_te")); 2129 &sub ($tbl,2048);
888 &sub ("ebp",2048); 2130
889 2131 &mov ($acc,$_inp);
890 &mov ($s2,$_len);
891 &mov ($key,$_ivp); 2132 &mov ($key,$_ivp);
892 &test ($s2,0xFFFFFFF0);
893 &jz (&label("enc_tail")); # short input...
894 2133
2134 &cmp ($s3,0);
2135 &je (&label("fast_decrypt"));
2136
2137#----------------------------- ENCRYPT -----------------------------#
895 &mov ($s0,&DWP(0,$key)); # load iv 2138 &mov ($s0,&DWP(0,$key)); # load iv
896 &mov ($s1,&DWP(4,$key)); 2139 &mov ($s1,&DWP(4,$key));
897 2140
898 &align (4); 2141 &set_label("fast_enc_loop",16);
899 &set_label("enc_loop");
900 &mov ($s2,&DWP(8,$key)); 2142 &mov ($s2,&DWP(8,$key));
901 &mov ($s3,&DWP(12,$key)); 2143 &mov ($s3,&DWP(12,$key));
902 2144
@@ -916,22 +2158,16 @@ my $mark=&DWP(60+240,"esp"); #copy of aes_key->rounds
916 &mov (&DWP(8,$key),$s2); 2158 &mov (&DWP(8,$key),$s2);
917 &mov (&DWP(12,$key),$s3); 2159 &mov (&DWP(12,$key),$s3);
918 2160
2161 &lea ($acc,&DWP(16,$acc)); # advance inp
919 &mov ($s2,$_len); # load len 2162 &mov ($s2,$_len); # load len
920
921 &lea ($acc,&DWP(16,$acc));
922 &mov ($_inp,$acc); # save inp 2163 &mov ($_inp,$acc); # save inp
923 2164 &lea ($s3,&DWP(16,$key)); # advance out
924 &lea ($s3,&DWP(16,$key));
925 &mov ($_out,$s3); # save out 2165 &mov ($_out,$s3); # save out
926 2166 &sub ($s2,16); # decrease len
927 &sub ($s2,16);
928 &test ($s2,0xFFFFFFF0);
929 &mov ($_len,$s2); # save len 2167 &mov ($_len,$s2); # save len
930 &jnz (&label("enc_loop")); 2168 &jnz (&label("fast_enc_loop"));
931 &test ($s2,15);
932 &jnz (&label("enc_tail"));
933 &mov ($acc,$_ivp); # load ivp 2169 &mov ($acc,$_ivp); # load ivp
934 &mov ($s2,&DWP(8,$key)); # restore last dwords 2170 &mov ($s2,&DWP(8,$key)); # restore last 2 dwords
935 &mov ($s3,&DWP(12,$key)); 2171 &mov ($s3,&DWP(12,$key));
936 &mov (&DWP(0,$acc),$s0); # save ivec 2172 &mov (&DWP(0,$acc),$s0); # save ivec
937 &mov (&DWP(4,$acc),$s1); 2173 &mov (&DWP(4,$acc),$s1);
@@ -949,125 +2185,20 @@ my $mark=&DWP(60+240,"esp"); #copy of aes_key->rounds
949 &set_label("skip_ezero") 2185 &set_label("skip_ezero")
950 &mov ("esp",$_esp); 2186 &mov ("esp",$_esp);
951 &popf (); 2187 &popf ();
952 &set_label("enc_out"); 2188 &set_label("drop_out");
953 &function_end_A(); 2189 &function_end_A();
954 &pushf (); # kludge, never executed 2190 &pushf (); # kludge, never executed
955 2191
956 &align (4);
957 &set_label("enc_tail");
958 &mov ($s0,$key eq "edi" ? $key : "");
959 &mov ($key,$_out); # load out
960 &push ($s0); # push ivp
961 &mov ($s1,16);
962 &sub ($s1,$s2);
963 &cmp ($key,$acc); # compare with inp
964 &je (&label("enc_in_place"));
965 &align (4);
966 &data_word(0xA4F3F689); # rep movsb # copy input
967 &jmp (&label("enc_skip_in_place"));
968 &set_label("enc_in_place");
969 &lea ($key,&DWP(0,$key,$s2));
970 &set_label("enc_skip_in_place");
971 &mov ($s2,$s1);
972 &xor ($s0,$s0);
973 &align (4);
974 &data_word(0xAAF3F689); # rep stosb # zero tail
975 &pop ($key); # pop ivp
976
977 &mov ($acc,$_out); # output as input
978 &mov ($s0,&DWP(0,$key));
979 &mov ($s1,&DWP(4,$key));
980 &mov ($_len,16); # len=16
981 &jmp (&label("enc_loop")); # one more spin...
982
983#----------------------------- DECRYPT -----------------------------# 2192#----------------------------- DECRYPT -----------------------------#
984&align (4); 2193&set_label("fast_decrypt",16);
985&set_label("DECRYPT");
986 &lea ("ebp",&DWP(&label("AES_Td")."-".&label("pic_point"),"ebp"));
987
988 # allocate aligned stack frame...
989 &lea ($key,&DWP(-64-244,"esp"));
990 &and ($key,-64);
991
992 # ... and make sure it doesn't alias with AES_Td modulo 4096
993 &mov ($s0,"ebp");
994 &lea ($s1,&DWP(2048+256,"ebp"));
995 &mov ($s3,$key);
996 &and ($s0,0xfff); # s = %ebp&0xfff
997 &and ($s1,0xfff); # e = (%ebp+2048+256)&0xfff
998 &and ($s3,0xfff); # p = %esp&0xfff
999
1000 &cmp ($s3,$s1); # if (p>=e) %esp =- (p-e);
1001 &jb (&label("td_break_out"));
1002 &sub ($s3,$s1);
1003 &sub ($key,$s3);
1004 &jmp (&label("td_ok"));
1005 &set_label("td_break_out"); # else %esp -= (p-s)&0xfff + framesz;
1006 &sub ($s3,$s0);
1007 &and ($s3,0xfff);
1008 &add ($s3,64+256);
1009 &sub ($key,$s3);
1010 &align (4);
1011 &set_label("td_ok");
1012
1013 &mov ($s0,&wparam(0)); # load inp
1014 &mov ($s1,&wparam(1)); # load out
1015 &mov ($s3,&wparam(3)); # load key
1016 &mov ($acc,&wparam(4)); # load ivp
1017
1018 &exch ("esp",$key);
1019 &add ("esp",4); # reserve for return address!
1020 &mov ($_esp,$key); # save %esp
1021
1022 &mov ($_inp,$s0); # save copy of inp
1023 &mov ($_out,$s1); # save copy of out
1024 &mov ($_len,$s2); # save copy of len
1025 &mov ($_key,$s3); # save copy of key
1026 &mov ($_ivp,$acc); # save copy of ivp
1027
1028 &mov ($mark,0); # copy of aes_key->rounds = 0;
1029 if ($compromise) {
1030 &cmp ($s2,$compromise);
1031 &jb (&label("skip_dcopy"));
1032 }
1033 # do we copy key schedule to stack?
1034 &mov ($s1 eq "ebx" ? $s1 : "",$s3);
1035 &mov ($s2 eq "ecx" ? $s2 : "",244/4);
1036 &sub ($s1,"ebp");
1037 &mov ("esi",$s3);
1038 &and ($s1,0xfff);
1039 &lea ("edi",$aes_key);
1040 &cmp ($s1,2048+256);
1041 &jb (&label("do_dcopy"));
1042 &cmp ($s1,4096-244);
1043 &jb (&label("skip_dcopy"));
1044 &align (4);
1045 &set_label("do_dcopy");
1046 &mov ($_key,"edi");
1047 &data_word(0xA5F3F689); # rep movsd
1048 &set_label("skip_dcopy");
1049
1050 &mov ($acc,$s0);
1051 &mov ($key,18);
1052 &align (4);
1053 &set_label("prefetch_td");
1054 &mov ($s0,&DWP(0,"ebp"));
1055 &mov ($s1,&DWP(32,"ebp"));
1056 &mov ($s2,&DWP(64,"ebp"));
1057 &mov ($s3,&DWP(96,"ebp"));
1058 &lea ("ebp",&DWP(128,"ebp"));
1059 &dec ($key);
1060 &jnz (&label("prefetch_td"));
1061 &sub ("ebp",2048+256);
1062 2194
1063 &cmp ($acc,$_out); 2195 &cmp ($acc,$_out);
1064 &je (&label("dec_in_place")); # in-place processing... 2196 &je (&label("fast_dec_in_place")); # in-place processing...
1065 2197
1066 &mov ($key,$_ivp); # load ivp
1067 &mov ($_tmp,$key); 2198 &mov ($_tmp,$key);
1068 2199
1069 &align (4); 2200 &align (4);
1070 &set_label("dec_loop"); 2201 &set_label("fast_dec_loop",16);
1071 &mov ($s0,&DWP(0,$acc)); # read input 2202 &mov ($s0,&DWP(0,$acc)); # read input
1072 &mov ($s1,&DWP(4,$acc)); 2203 &mov ($s1,&DWP(4,$acc));
1073 &mov ($s2,&DWP(8,$acc)); 2204 &mov ($s2,&DWP(8,$acc));
@@ -1083,27 +2214,24 @@ my $mark=&DWP(60+240,"esp"); #copy of aes_key->rounds
1083 &xor ($s2,&DWP(8,$key)); 2214 &xor ($s2,&DWP(8,$key));
1084 &xor ($s3,&DWP(12,$key)); 2215 &xor ($s3,&DWP(12,$key));
1085 2216
1086 &sub ($acc,16);
1087 &jc (&label("dec_partial"));
1088 &mov ($_len,$acc); # save len
1089 &mov ($acc,$_inp); # load inp
1090 &mov ($key,$_out); # load out 2217 &mov ($key,$_out); # load out
2218 &mov ($acc,$_inp); # load inp
1091 2219
1092 &mov (&DWP(0,$key),$s0); # write output 2220 &mov (&DWP(0,$key),$s0); # write output
1093 &mov (&DWP(4,$key),$s1); 2221 &mov (&DWP(4,$key),$s1);
1094 &mov (&DWP(8,$key),$s2); 2222 &mov (&DWP(8,$key),$s2);
1095 &mov (&DWP(12,$key),$s3); 2223 &mov (&DWP(12,$key),$s3);
1096 2224
2225 &mov ($s2,$_len); # load len
1097 &mov ($_tmp,$acc); # save ivp 2226 &mov ($_tmp,$acc); # save ivp
1098 &lea ($acc,&DWP(16,$acc)); 2227 &lea ($acc,&DWP(16,$acc)); # advance inp
1099 &mov ($_inp,$acc); # save inp 2228 &mov ($_inp,$acc); # save inp
1100 2229 &lea ($key,&DWP(16,$key)); # advance out
1101 &lea ($key,&DWP(16,$key));
1102 &mov ($_out,$key); # save out 2230 &mov ($_out,$key); # save out
1103 2231 &sub ($s2,16); # decrease len
1104 &jnz (&label("dec_loop")); 2232 &mov ($_len,$s2); # save len
2233 &jnz (&label("fast_dec_loop"));
1105 &mov ($key,$_tmp); # load temp ivp 2234 &mov ($key,$_tmp); # load temp ivp
1106 &set_label("dec_end");
1107 &mov ($acc,$_ivp); # load user ivp 2235 &mov ($acc,$_ivp); # load user ivp
1108 &mov ($s0,&DWP(0,$key)); # load iv 2236 &mov ($s0,&DWP(0,$key)); # load iv
1109 &mov ($s1,&DWP(4,$key)); 2237 &mov ($s1,&DWP(4,$key));
@@ -1113,31 +2241,16 @@ my $mark=&DWP(60+240,"esp"); #copy of aes_key->rounds
1113 &mov (&DWP(4,$acc),$s1); 2241 &mov (&DWP(4,$acc),$s1);
1114 &mov (&DWP(8,$acc),$s2); 2242 &mov (&DWP(8,$acc),$s2);
1115 &mov (&DWP(12,$acc),$s3); 2243 &mov (&DWP(12,$acc),$s3);
1116 &jmp (&label("dec_out")); 2244 &jmp (&label("fast_dec_out"));
1117 2245
1118 &align (4); 2246 &set_label("fast_dec_in_place",16);
1119 &set_label("dec_partial"); 2247 &set_label("fast_dec_in_place_loop");
1120 &lea ($key,$ivec);
1121 &mov (&DWP(0,$key),$s0); # dump output to stack
1122 &mov (&DWP(4,$key),$s1);
1123 &mov (&DWP(8,$key),$s2);
1124 &mov (&DWP(12,$key),$s3);
1125 &lea ($s2 eq "ecx" ? $s2 : "",&DWP(16,$acc));
1126 &mov ($acc eq "esi" ? $acc : "",$key);
1127 &mov ($key eq "edi" ? $key : "",$_out); # load out
1128 &data_word(0xA4F3F689); # rep movsb # copy output
1129 &mov ($key,$_inp); # use inp as temp ivp
1130 &jmp (&label("dec_end"));
1131
1132 &align (4);
1133 &set_label("dec_in_place");
1134 &set_label("dec_in_place_loop");
1135 &lea ($key,$ivec);
1136 &mov ($s0,&DWP(0,$acc)); # read input 2248 &mov ($s0,&DWP(0,$acc)); # read input
1137 &mov ($s1,&DWP(4,$acc)); 2249 &mov ($s1,&DWP(4,$acc));
1138 &mov ($s2,&DWP(8,$acc)); 2250 &mov ($s2,&DWP(8,$acc));
1139 &mov ($s3,&DWP(12,$acc)); 2251 &mov ($s3,&DWP(12,$acc));
1140 2252
2253 &lea ($key,$ivec);
1141 &mov (&DWP(0,$key),$s0); # copy to temp 2254 &mov (&DWP(0,$key),$s0); # copy to temp
1142 &mov (&DWP(4,$key),$s1); 2255 &mov (&DWP(4,$key),$s1);
1143 &mov (&DWP(8,$key),$s2); 2256 &mov (&DWP(8,$key),$s2);
@@ -1158,7 +2271,7 @@ my $mark=&DWP(60+240,"esp"); #copy of aes_key->rounds
1158 &mov (&DWP(8,$acc),$s2); 2271 &mov (&DWP(8,$acc),$s2);
1159 &mov (&DWP(12,$acc),$s3); 2272 &mov (&DWP(12,$acc),$s3);
1160 2273
1161 &lea ($acc,&DWP(16,$acc)); 2274 &lea ($acc,&DWP(16,$acc)); # advance out
1162 &mov ($_out,$acc); # save out 2275 &mov ($_out,$acc); # save out
1163 2276
1164 &lea ($acc,$ivec); 2277 &lea ($acc,$ivec);
@@ -1173,40 +2286,340 @@ my $mark=&DWP(60+240,"esp"); #copy of aes_key->rounds
1173 &mov (&DWP(12,$key),$s3); 2286 &mov (&DWP(12,$key),$s3);
1174 2287
1175 &mov ($acc,$_inp); # load inp 2288 &mov ($acc,$_inp); # load inp
2289 &mov ($s2,$_len); # load len
2290 &lea ($acc,&DWP(16,$acc)); # advance inp
2291 &mov ($_inp,$acc); # save inp
2292 &sub ($s2,16); # decrease len
2293 &mov ($_len,$s2); # save len
2294 &jnz (&label("fast_dec_in_place_loop"));
2295
2296 &set_label("fast_dec_out",4);
2297 &cmp ($mark,0); # was the key schedule copied?
2298 &mov ("edi",$_key);
2299 &je (&label("skip_dzero"));
2300 # zero copy of key schedule
2301 &mov ("ecx",240/4);
2302 &xor ("eax","eax");
2303 &align (4);
2304 &data_word(0xABF3F689); # rep stosd
2305 &set_label("skip_dzero")
2306 &mov ("esp",$_esp);
2307 &popf ();
2308 &function_end_A();
2309 &pushf (); # kludge, never executed
2310
2311#--------------------------- SLOW ROUTINE ---------------------------#
2312&set_label("slow_way",16);
2313
2314 &mov ($s0,&DWP(0,$s0)) if (!$x86only);# load OPENSSL_ia32cap
2315 &mov ($key,&wparam(3)); # load key
2316
2317 # pre-allocate aligned stack frame...
2318 &lea ($acc,&DWP(-80,"esp"));
2319 &and ($acc,-64);
2320
2321 # ... and make sure it doesn't alias with $key modulo 1024
2322 &lea ($s1,&DWP(-80-63,$key));
2323 &sub ($s1,$acc);
2324 &neg ($s1);
2325 &and ($s1,0x3C0); # modulo 1024, but aligned to cache-line
2326 &sub ($acc,$s1);
2327
2328 # pick S-box copy which can't overlap with stack frame or $key
2329 &lea ($s1,&DWP(768,$acc));
2330 &sub ($s1,$tbl);
2331 &and ($s1,0x300);
2332 &lea ($tbl,&DWP(2048+128,$tbl,$s1));
2333
2334 &lea ($s3,&wparam(0)); # pointer to parameter block
2335
2336 &exch ("esp",$acc);
2337 &add ("esp",4); # reserve for return address!
2338 &mov ($_tbl,$tbl); # save %ebp
2339 &mov ($_esp,$acc); # save %esp
2340 &mov ($_tmp,$s0); # save OPENSSL_ia32cap
2341
2342 &mov ($s0,&DWP(0,$s3)); # load inp
2343 &mov ($s1,&DWP(4,$s3)); # load out
2344 #&mov ($s2,&DWP(8,$s3)); # load len
2345 #&mov ($key,&DWP(12,$s3)); # load key
2346 &mov ($acc,&DWP(16,$s3)); # load ivp
2347 &mov ($s3,&DWP(20,$s3)); # load enc flag
2348
2349 &mov ($_inp,$s0); # save copy of inp
2350 &mov ($_out,$s1); # save copy of out
2351 &mov ($_len,$s2); # save copy of len
2352 &mov ($_key,$key); # save copy of key
2353 &mov ($_ivp,$acc); # save copy of ivp
2354
2355 &mov ($key,$acc);
2356 &mov ($acc,$s0);
2357
2358 &cmp ($s3,0);
2359 &je (&label("slow_decrypt"));
2360
2361#--------------------------- SLOW ENCRYPT ---------------------------#
2362 &cmp ($s2,16);
2363 &mov ($s3,$s1);
2364 &jb (&label("slow_enc_tail"));
2365
2366 if (!$x86only) {
2367 &bt ($_tmp,25); # check for SSE bit
2368 &jnc (&label("slow_enc_x86"));
2369
2370 &movq ("mm0",&QWP(0,$key)); # load iv
2371 &movq ("mm4",&QWP(8,$key));
1176 2372
1177 &lea ($acc,&DWP(16,$acc)); 2373 &set_label("slow_enc_loop_sse",16);
2374 &pxor ("mm0",&QWP(0,$acc)); # xor input data
2375 &pxor ("mm4",&QWP(8,$acc));
2376
2377 &mov ($key,$_key);
2378 &call ("_sse_AES_encrypt_compact");
2379
2380 &mov ($acc,$_inp); # load inp
2381 &mov ($key,$_out); # load out
2382 &mov ($s2,$_len); # load len
2383
2384 &movq (&QWP(0,$key),"mm0"); # save output data
2385 &movq (&QWP(8,$key),"mm4");
2386
2387 &lea ($acc,&DWP(16,$acc)); # advance inp
1178 &mov ($_inp,$acc); # save inp 2388 &mov ($_inp,$acc); # save inp
2389 &lea ($s3,&DWP(16,$key)); # advance out
2390 &mov ($_out,$s3); # save out
2391 &sub ($s2,16); # decrease len
2392 &cmp ($s2,16);
2393 &mov ($_len,$s2); # save len
2394 &jae (&label("slow_enc_loop_sse"));
2395 &test ($s2,15);
2396 &jnz (&label("slow_enc_tail"));
2397 &mov ($acc,$_ivp); # load ivp
2398 &movq (&QWP(0,$acc),"mm0"); # save ivec
2399 &movq (&QWP(8,$acc),"mm4");
2400 &emms ();
2401 &mov ("esp",$_esp);
2402 &popf ();
2403 &function_end_A();
2404 &pushf (); # kludge, never executed
2405 }
2406 &set_label("slow_enc_x86",16);
2407 &mov ($s0,&DWP(0,$key)); # load iv
2408 &mov ($s1,&DWP(4,$key));
2409
2410 &set_label("slow_enc_loop_x86",4);
2411 &mov ($s2,&DWP(8,$key));
2412 &mov ($s3,&DWP(12,$key));
2413
2414 &xor ($s0,&DWP(0,$acc)); # xor input data
2415 &xor ($s1,&DWP(4,$acc));
2416 &xor ($s2,&DWP(8,$acc));
2417 &xor ($s3,&DWP(12,$acc));
2418
2419 &mov ($key,$_key); # load key
2420 &call ("_x86_AES_encrypt_compact");
2421
2422 &mov ($acc,$_inp); # load inp
2423 &mov ($key,$_out); # load out
2424
2425 &mov (&DWP(0,$key),$s0); # save output data
2426 &mov (&DWP(4,$key),$s1);
2427 &mov (&DWP(8,$key),$s2);
2428 &mov (&DWP(12,$key),$s3);
1179 2429
1180 &mov ($s2,$_len); # load len 2430 &mov ($s2,$_len); # load len
1181 &sub ($s2,16); 2431 &lea ($acc,&DWP(16,$acc)); # advance inp
1182 &jc (&label("dec_in_place_partial")); 2432 &mov ($_inp,$acc); # save inp
2433 &lea ($s3,&DWP(16,$key)); # advance out
2434 &mov ($_out,$s3); # save out
2435 &sub ($s2,16); # decrease len
2436 &cmp ($s2,16);
1183 &mov ($_len,$s2); # save len 2437 &mov ($_len,$s2); # save len
1184 &jnz (&label("dec_in_place_loop")); 2438 &jae (&label("slow_enc_loop_x86"));
1185 &jmp (&label("dec_out")); 2439 &test ($s2,15);
1186 2440 &jnz (&label("slow_enc_tail"));
1187 &align (4); 2441 &mov ($acc,$_ivp); # load ivp
1188 &set_label("dec_in_place_partial"); 2442 &mov ($s2,&DWP(8,$key)); # restore last dwords
1189 # one can argue if this is actually required... 2443 &mov ($s3,&DWP(12,$key));
1190 &mov ($key eq "edi" ? $key : "",$_out); 2444 &mov (&DWP(0,$acc),$s0); # save ivec
1191 &lea ($acc eq "esi" ? $acc : "",$ivec); 2445 &mov (&DWP(4,$acc),$s1);
2446 &mov (&DWP(8,$acc),$s2);
2447 &mov (&DWP(12,$acc),$s3);
2448
2449 &mov ("esp",$_esp);
2450 &popf ();
2451 &function_end_A();
2452 &pushf (); # kludge, never executed
2453
2454 &set_label("slow_enc_tail",16);
2455 &emms () if (!$x86only);
2456 &mov ($key eq "edi"? $key:"",$s3); # load out to edi
2457 &mov ($s1,16);
2458 &sub ($s1,$s2);
2459 &cmp ($key,$acc eq "esi"? $acc:""); # compare with inp
2460 &je (&label("enc_in_place"));
2461 &align (4);
2462 &data_word(0xA4F3F689); # rep movsb # copy input
2463 &jmp (&label("enc_skip_in_place"));
2464 &set_label("enc_in_place");
1192 &lea ($key,&DWP(0,$key,$s2)); 2465 &lea ($key,&DWP(0,$key,$s2));
1193 &lea ($acc,&DWP(16,$acc,$s2)); 2466 &set_label("enc_skip_in_place");
1194 &neg ($s2 eq "ecx" ? $s2 : ""); 2467 &mov ($s2,$s1);
1195 &data_word(0xA4F3F689); # rep movsb # restore tail 2468 &xor ($s0,$s0);
1196 2469 &align (4);
1197 &align (4); 2470 &data_word(0xAAF3F689); # rep stosb # zero tail
1198 &set_label("dec_out"); 2471
1199 &cmp ($mark,0); # was the key schedule copied? 2472 &mov ($key,$_ivp); # restore ivp
1200 &mov ("edi",$_key); 2473 &mov ($acc,$s3); # output as input
1201 &je (&label("skip_dzero")); 2474 &mov ($s0,&DWP(0,$key));
1202 # zero copy of key schedule 2475 &mov ($s1,&DWP(4,$key));
1203 &mov ("ecx",240/4); 2476 &mov ($_len,16); # len=16
1204 &xor ("eax","eax"); 2477 &jmp (&label("slow_enc_loop_x86")); # one more spin...
1205 &align (4); 2478
1206 &data_word(0xABF3F689); # rep stosd 2479#--------------------------- SLOW DECRYPT ---------------------------#
1207 &set_label("skip_dzero") 2480&set_label("slow_decrypt",16);
1208 &mov ("esp",$_esp); 2481 if (!$x86only) {
1209 &popf (); 2482 &bt ($_tmp,25); # check for SSE bit
2483 &jnc (&label("slow_dec_loop_x86"));
2484
2485 &set_label("slow_dec_loop_sse",4);
2486 &movq ("mm0",&QWP(0,$acc)); # read input
2487 &movq ("mm4",&QWP(8,$acc));
2488
2489 &mov ($key,$_key);
2490 &call ("_sse_AES_decrypt_compact");
2491
2492 &mov ($acc,$_inp); # load inp
2493 &lea ($s0,$ivec);
2494 &mov ($s1,$_out); # load out
2495 &mov ($s2,$_len); # load len
2496 &mov ($key,$_ivp); # load ivp
2497
2498 &movq ("mm1",&QWP(0,$acc)); # re-read input
2499 &movq ("mm5",&QWP(8,$acc));
2500
2501 &pxor ("mm0",&QWP(0,$key)); # xor iv
2502 &pxor ("mm4",&QWP(8,$key));
2503
2504 &movq (&QWP(0,$key),"mm1"); # copy input to iv
2505 &movq (&QWP(8,$key),"mm5");
2506
2507 &sub ($s2,16); # decrease len
2508 &jc (&label("slow_dec_partial_sse"));
2509
2510 &movq (&QWP(0,$s1),"mm0"); # write output
2511 &movq (&QWP(8,$s1),"mm4");
2512
2513 &lea ($s1,&DWP(16,$s1)); # advance out
2514 &mov ($_out,$s1); # save out
2515 &lea ($acc,&DWP(16,$acc)); # advance inp
2516 &mov ($_inp,$acc); # save inp
2517 &mov ($_len,$s2); # save len
2518 &jnz (&label("slow_dec_loop_sse"));
2519 &emms ();
2520 &mov ("esp",$_esp);
2521 &popf ();
2522 &function_end_A();
2523 &pushf (); # kludge, never executed
2524
2525 &set_label("slow_dec_partial_sse",16);
2526 &movq (&QWP(0,$s0),"mm0"); # save output to temp
2527 &movq (&QWP(8,$s0),"mm4");
2528 &emms ();
2529
2530 &add ($s2 eq "ecx" ? "ecx":"",16);
2531 &mov ("edi",$s1); # out
2532 &mov ("esi",$s0); # temp
2533 &align (4);
2534 &data_word(0xA4F3F689); # rep movsb # copy partial output
2535
2536 &mov ("esp",$_esp);
2537 &popf ();
2538 &function_end_A();
2539 &pushf (); # kludge, never executed
2540 }
2541 &set_label("slow_dec_loop_x86",16);
2542 &mov ($s0,&DWP(0,$acc)); # read input
2543 &mov ($s1,&DWP(4,$acc));
2544 &mov ($s2,&DWP(8,$acc));
2545 &mov ($s3,&DWP(12,$acc));
2546
2547 &lea ($key,$ivec);
2548 &mov (&DWP(0,$key),$s0); # copy to temp
2549 &mov (&DWP(4,$key),$s1);
2550 &mov (&DWP(8,$key),$s2);
2551 &mov (&DWP(12,$key),$s3);
2552
2553 &mov ($key,$_key); # load key
2554 &call ("_x86_AES_decrypt_compact");
2555
2556 &mov ($key,$_ivp); # load ivp
2557 &mov ($acc,$_len); # load len
2558 &xor ($s0,&DWP(0,$key)); # xor iv
2559 &xor ($s1,&DWP(4,$key));
2560 &xor ($s2,&DWP(8,$key));
2561 &xor ($s3,&DWP(12,$key));
2562
2563 &sub ($acc,16);
2564 &jc (&label("slow_dec_partial_x86"));
2565
2566 &mov ($_len,$acc); # save len
2567 &mov ($acc,$_out); # load out
2568
2569 &mov (&DWP(0,$acc),$s0); # write output
2570 &mov (&DWP(4,$acc),$s1);
2571 &mov (&DWP(8,$acc),$s2);
2572 &mov (&DWP(12,$acc),$s3);
2573
2574 &lea ($acc,&DWP(16,$acc)); # advance out
2575 &mov ($_out,$acc); # save out
2576
2577 &lea ($acc,$ivec);
2578 &mov ($s0,&DWP(0,$acc)); # read temp
2579 &mov ($s1,&DWP(4,$acc));
2580 &mov ($s2,&DWP(8,$acc));
2581 &mov ($s3,&DWP(12,$acc));
2582
2583 &mov (&DWP(0,$key),$s0); # copy it to iv
2584 &mov (&DWP(4,$key),$s1);
2585 &mov (&DWP(8,$key),$s2);
2586 &mov (&DWP(12,$key),$s3);
2587
2588 &mov ($acc,$_inp); # load inp
2589 &lea ($acc,&DWP(16,$acc)); # advance inp
2590 &mov ($_inp,$acc); # save inp
2591 &jnz (&label("slow_dec_loop_x86"));
2592 &mov ("esp",$_esp);
2593 &popf ();
2594 &function_end_A();
2595 &pushf (); # kludge, never executed
2596
2597 &set_label("slow_dec_partial_x86",16);
2598 &lea ($acc,$ivec);
2599 &mov (&DWP(0,$acc),$s0); # save output to temp
2600 &mov (&DWP(4,$acc),$s1);
2601 &mov (&DWP(8,$acc),$s2);
2602 &mov (&DWP(12,$acc),$s3);
2603
2604 &mov ($acc,$_inp);
2605 &mov ($s0,&DWP(0,$acc)); # re-read input
2606 &mov ($s1,&DWP(4,$acc));
2607 &mov ($s2,&DWP(8,$acc));
2608 &mov ($s3,&DWP(12,$acc));
2609
2610 &mov (&DWP(0,$key),$s0); # copy it to iv
2611 &mov (&DWP(4,$key),$s1);
2612 &mov (&DWP(8,$key),$s2);
2613 &mov (&DWP(12,$key),$s3);
2614
2615 &mov ("ecx",$_len);
2616 &mov ("edi",$_out);
2617 &lea ("esi",$ivec);
2618 &align (4);
2619 &data_word(0xA4F3F689); # rep movsb # copy partial output
2620
2621 &mov ("esp",$_esp);
2622 &popf ();
1210&function_end("AES_cbc_encrypt"); 2623&function_end("AES_cbc_encrypt");
1211} 2624}
1212 2625
@@ -1215,35 +2628,31 @@ my $mark=&DWP(60+240,"esp"); #copy of aes_key->rounds
1215sub enckey() 2628sub enckey()
1216{ 2629{
1217 &movz ("esi",&LB("edx")); # rk[i]>>0 2630 &movz ("esi",&LB("edx")); # rk[i]>>0
1218 &mov ("ebx",&DWP(2,"ebp","esi",8)); 2631 &movz ("ebx",&BP(-128,$tbl,"esi",1));
1219 &movz ("esi",&HB("edx")); # rk[i]>>8 2632 &movz ("esi",&HB("edx")); # rk[i]>>8
1220 &and ("ebx",0xFF000000); 2633 &shl ("ebx",24);
1221 &xor ("eax","ebx"); 2634 &xor ("eax","ebx");
1222 2635
1223 &mov ("ebx",&DWP(2,"ebp","esi",8)); 2636 &movz ("ebx",&BP(-128,$tbl,"esi",1));
1224 &shr ("edx",16); 2637 &shr ("edx",16);
1225 &and ("ebx",0x000000FF);
1226 &movz ("esi",&LB("edx")); # rk[i]>>16 2638 &movz ("esi",&LB("edx")); # rk[i]>>16
1227 &xor ("eax","ebx"); 2639 &xor ("eax","ebx");
1228 2640
1229 &mov ("ebx",&DWP(0,"ebp","esi",8)); 2641 &movz ("ebx",&BP(-128,$tbl,"esi",1));
1230 &movz ("esi",&HB("edx")); # rk[i]>>24 2642 &movz ("esi",&HB("edx")); # rk[i]>>24
1231 &and ("ebx",0x0000FF00); 2643 &shl ("ebx",8);
1232 &xor ("eax","ebx"); 2644 &xor ("eax","ebx");
1233 2645
1234 &mov ("ebx",&DWP(0,"ebp","esi",8)); 2646 &movz ("ebx",&BP(-128,$tbl,"esi",1));
1235 &and ("ebx",0x00FF0000); 2647 &shl ("ebx",16);
1236 &xor ("eax","ebx"); 2648 &xor ("eax","ebx");
1237 2649
1238 &xor ("eax",&DWP(2048,"ebp","ecx",4)); # rcon 2650 &xor ("eax",&DWP(1024-128,$tbl,"ecx",4)); # rcon
1239} 2651}
1240 2652
1241# int AES_set_encrypt_key(const unsigned char *userKey, const int bits, 2653&function_begin("_x86_AES_set_encrypt_key");
1242# AES_KEY *key) 2654 &mov ("esi",&wparam(1)); # user supplied key
1243&public_label("AES_Te"); 2655 &mov ("edi",&wparam(3)); # private key schedule
1244&function_begin("AES_set_encrypt_key", "", "_x86_AES_set_encrypt_key");
1245 &mov ("esi",&wparam(0)); # user supplied key
1246 &mov ("edi",&wparam(2)); # private key schedule
1247 2656
1248 &test ("esi",-1); 2657 &test ("esi",-1);
1249 &jz (&label("badpointer")); 2658 &jz (&label("badpointer"));
@@ -1252,10 +2661,21 @@ sub enckey()
1252 2661
1253 &call (&label("pic_point")); 2662 &call (&label("pic_point"));
1254 &set_label("pic_point"); 2663 &set_label("pic_point");
1255 &blindpop("ebp"); 2664 &blindpop($tbl);
1256 &lea ("ebp",&DWP(&label("AES_Te")."-".&label("pic_point"),"ebp")); 2665 &lea ($tbl,&DWP(&label("AES_Te")."-".&label("pic_point"),$tbl));
1257 2666 &lea ($tbl,&DWP(2048+128,$tbl));
1258 &mov ("ecx",&wparam(1)); # number of bits in key 2667
2668 # prefetch Te4
2669 &mov ("eax",&DWP(0-128,$tbl));
2670 &mov ("ebx",&DWP(32-128,$tbl));
2671 &mov ("ecx",&DWP(64-128,$tbl));
2672 &mov ("edx",&DWP(96-128,$tbl));
2673 &mov ("eax",&DWP(128-128,$tbl));
2674 &mov ("ebx",&DWP(160-128,$tbl));
2675 &mov ("ecx",&DWP(192-128,$tbl));
2676 &mov ("edx",&DWP(224-128,$tbl));
2677
2678 &mov ("ecx",&wparam(2)); # number of bits in key
1259 &cmp ("ecx",128); 2679 &cmp ("ecx",128);
1260 &je (&label("10rounds")); 2680 &je (&label("10rounds"));
1261 &cmp ("ecx",192); 2681 &cmp ("ecx",192);
@@ -1394,24 +2814,23 @@ sub enckey()
1394 &mov ("edx","eax"); 2814 &mov ("edx","eax");
1395 &mov ("eax",&DWP(16,"edi")); # rk[4] 2815 &mov ("eax",&DWP(16,"edi")); # rk[4]
1396 &movz ("esi",&LB("edx")); # rk[11]>>0 2816 &movz ("esi",&LB("edx")); # rk[11]>>0
1397 &mov ("ebx",&DWP(2,"ebp","esi",8)); 2817 &movz ("ebx",&BP(-128,$tbl,"esi",1));
1398 &movz ("esi",&HB("edx")); # rk[11]>>8 2818 &movz ("esi",&HB("edx")); # rk[11]>>8
1399 &and ("ebx",0x000000FF);
1400 &xor ("eax","ebx"); 2819 &xor ("eax","ebx");
1401 2820
1402 &mov ("ebx",&DWP(0,"ebp","esi",8)); 2821 &movz ("ebx",&BP(-128,$tbl,"esi",1));
1403 &shr ("edx",16); 2822 &shr ("edx",16);
1404 &and ("ebx",0x0000FF00); 2823 &shl ("ebx",8);
1405 &movz ("esi",&LB("edx")); # rk[11]>>16 2824 &movz ("esi",&LB("edx")); # rk[11]>>16
1406 &xor ("eax","ebx"); 2825 &xor ("eax","ebx");
1407 2826
1408 &mov ("ebx",&DWP(0,"ebp","esi",8)); 2827 &movz ("ebx",&BP(-128,$tbl,"esi",1));
1409 &movz ("esi",&HB("edx")); # rk[11]>>24 2828 &movz ("esi",&HB("edx")); # rk[11]>>24
1410 &and ("ebx",0x00FF0000); 2829 &shl ("ebx",16);
1411 &xor ("eax","ebx"); 2830 &xor ("eax","ebx");
1412 2831
1413 &mov ("ebx",&DWP(2,"ebp","esi",8)); 2832 &movz ("ebx",&BP(-128,$tbl,"esi",1));
1414 &and ("ebx",0xFF000000); 2833 &shl ("ebx",24);
1415 &xor ("eax","ebx"); 2834 &xor ("eax","ebx");
1416 2835
1417 &mov (&DWP(48,"edi"),"eax"); # rk[12] 2836 &mov (&DWP(48,"edi"),"eax"); # rk[12]
@@ -1433,43 +2852,74 @@ sub enckey()
1433 &set_label("badpointer"); 2852 &set_label("badpointer");
1434 &mov ("eax",-1); 2853 &mov ("eax",-1);
1435 &set_label("exit"); 2854 &set_label("exit");
1436&function_end("AES_set_encrypt_key"); 2855&function_end("_x86_AES_set_encrypt_key");
1437 2856
1438sub deckey() 2857# int AES_set_encrypt_key(const unsigned char *userKey, const int bits,
1439{ my ($i,$ptr,$te,$td) = @_; 2858# AES_KEY *key)
2859&function_begin_B("AES_set_encrypt_key");
2860 &call ("_x86_AES_set_encrypt_key");
2861 &ret ();
2862&function_end_B("AES_set_encrypt_key");
1440 2863
1441 &mov ("eax",&DWP($i,$ptr)); 2864sub deckey()
1442 &mov ("edx","eax"); 2865{ my ($i,$key,$tp1,$tp2,$tp4,$tp8) = @_;
1443 &movz ("ebx",&HB("eax")); 2866 my $tmp = $tbl;
1444 &shr ("edx",16); 2867
1445 &and ("eax",0xFF); 2868 &mov ($acc,$tp1);
1446 &movz ("eax",&BP(2,$te,"eax",8)); 2869 &and ($acc,0x80808080);
1447 &movz ("ebx",&BP(2,$te,"ebx",8)); 2870 &mov ($tmp,$acc);
1448 &mov ("eax",&DWP(0,$td,"eax",8)); 2871 &shr ($tmp,7);
1449 &xor ("eax",&DWP(3,$td,"ebx",8)); 2872 &lea ($tp2,&DWP(0,$tp1,$tp1));
1450 &movz ("ebx",&HB("edx")); 2873 &sub ($acc,$tmp);
1451 &and ("edx",0xFF); 2874 &and ($tp2,0xfefefefe);
1452 &movz ("edx",&BP(2,$te,"edx",8)); 2875 &and ($acc,0x1b1b1b1b);
1453 &movz ("ebx",&BP(2,$te,"ebx",8)); 2876 &xor ($acc,$tp2);
1454 &xor ("eax",&DWP(2,$td,"edx",8)); 2877 &mov ($tp2,$acc);
1455 &xor ("eax",&DWP(1,$td,"ebx",8)); 2878
1456 &mov (&DWP($i,$ptr),"eax"); 2879 &and ($acc,0x80808080);
2880 &mov ($tmp,$acc);
2881 &shr ($tmp,7);
2882 &lea ($tp4,&DWP(0,$tp2,$tp2));
2883 &sub ($acc,$tmp);
2884 &and ($tp4,0xfefefefe);
2885 &and ($acc,0x1b1b1b1b);
2886 &xor ($tp2,$tp1); # tp2^tp1
2887 &xor ($acc,$tp4);
2888 &mov ($tp4,$acc);
2889
2890 &and ($acc,0x80808080);
2891 &mov ($tmp,$acc);
2892 &shr ($tmp,7);
2893 &lea ($tp8,&DWP(0,$tp4,$tp4));
2894 &xor ($tp4,$tp1); # tp4^tp1
2895 &sub ($acc,$tmp);
2896 &and ($tp8,0xfefefefe);
2897 &and ($acc,0x1b1b1b1b);
2898 &rotl ($tp1,8); # = ROTATE(tp1,8)
2899 &xor ($tp8,$acc);
2900
2901 &mov ($tmp,&DWP(4*($i+1),$key)); # modulo-scheduled load
2902
2903 &xor ($tp1,$tp2);
2904 &xor ($tp2,$tp8);
2905 &xor ($tp1,$tp4);
2906 &rotl ($tp2,24);
2907 &xor ($tp4,$tp8);
2908 &xor ($tp1,$tp8); # ^= tp8^(tp4^tp1)^(tp2^tp1)
2909 &rotl ($tp4,16);
2910 &xor ($tp1,$tp2); # ^= ROTATE(tp8^tp2^tp1,24)
2911 &rotl ($tp8,8);
2912 &xor ($tp1,$tp4); # ^= ROTATE(tp8^tp4^tp1,16)
2913 &mov ($tp2,$tmp);
2914 &xor ($tp1,$tp8); # ^= ROTATE(tp8,8)
2915
2916 &mov (&DWP(4*$i,$key),$tp1);
1457} 2917}
1458 2918
1459# int AES_set_decrypt_key(const unsigned char *userKey, const int bits, 2919# int AES_set_decrypt_key(const unsigned char *userKey, const int bits,
1460# AES_KEY *key) 2920# AES_KEY *key)
1461&public_label("AES_Td");
1462&public_label("AES_Te");
1463&function_begin_B("AES_set_decrypt_key"); 2921&function_begin_B("AES_set_decrypt_key");
1464 &mov ("eax",&wparam(0));
1465 &mov ("ecx",&wparam(1));
1466 &mov ("edx",&wparam(2));
1467 &sub ("esp",12);
1468 &mov (&DWP(0,"esp"),"eax");
1469 &mov (&DWP(4,"esp"),"ecx");
1470 &mov (&DWP(8,"esp"),"edx");
1471 &call ("_x86_AES_set_encrypt_key"); 2922 &call ("_x86_AES_set_encrypt_key");
1472 &add ("esp",12);
1473 &cmp ("eax",0); 2923 &cmp ("eax",0);
1474 &je (&label("proceed")); 2924 &je (&label("proceed"));
1475 &ret (); 2925 &ret ();
@@ -1485,8 +2935,7 @@ sub deckey()
1485 &lea ("ecx",&DWP(0,"","ecx",4)); 2935 &lea ("ecx",&DWP(0,"","ecx",4));
1486 &lea ("edi",&DWP(0,"esi","ecx",4)); # pointer to last chunk 2936 &lea ("edi",&DWP(0,"esi","ecx",4)); # pointer to last chunk
1487 2937
1488 &align (4); 2938 &set_label("invert",4); # invert order of chunks
1489 &set_label("invert"); # invert order of chunks
1490 &mov ("eax",&DWP(0,"esi")); 2939 &mov ("eax",&DWP(0,"esi"));
1491 &mov ("ebx",&DWP(4,"esi")); 2940 &mov ("ebx",&DWP(4,"esi"));
1492 &mov ("ecx",&DWP(0,"edi")); 2941 &mov ("ecx",&DWP(0,"edi"));
@@ -1508,26 +2957,24 @@ sub deckey()
1508 &cmp ("esi","edi"); 2957 &cmp ("esi","edi");
1509 &jne (&label("invert")); 2958 &jne (&label("invert"));
1510 2959
1511 &call (&label("pic_point")); 2960 &mov ($key,&wparam(2));
1512 &set_label("pic_point"); 2961 &mov ($acc,&DWP(240,$key)); # pull number of rounds
1513 blindpop("ebp"); 2962 &lea ($acc,&DWP(-2,$acc,$acc));
1514 &lea ("edi",&DWP(&label("AES_Td")."-".&label("pic_point"),"ebp")); 2963 &lea ($acc,&DWP(0,$key,$acc,8));
1515 &lea ("ebp",&DWP(&label("AES_Te")."-".&label("pic_point"),"ebp")); 2964 &mov (&wparam(2),$acc);
1516 2965
1517 &mov ("esi",&wparam(2)); 2966 &mov ($s0,&DWP(16,$key)); # modulo-scheduled load
1518 &mov ("ecx",&DWP(240,"esi")); # pull number of rounds 2967 &set_label("permute",4); # permute the key schedule
1519 &dec ("ecx"); 2968 &add ($key,16);
1520 &align (4); 2969 &deckey (0,$key,$s0,$s1,$s2,$s3);
1521 &set_label("permute"); # permute the key schedule 2970 &deckey (1,$key,$s1,$s2,$s3,$s0);
1522 &add ("esi",16); 2971 &deckey (2,$key,$s2,$s3,$s0,$s1);
1523 &deckey (0,"esi","ebp","edi"); 2972 &deckey (3,$key,$s3,$s0,$s1,$s2);
1524 &deckey (4,"esi","ebp","edi"); 2973 &cmp ($key,&wparam(2));
1525 &deckey (8,"esi","ebp","edi"); 2974 &jb (&label("permute"));
1526 &deckey (12,"esi","ebp","edi");
1527 &dec ("ecx");
1528 &jnz (&label("permute"));
1529 2975
1530 &xor ("eax","eax"); # return success 2976 &xor ("eax","eax"); # return success
1531&function_end("AES_set_decrypt_key"); 2977&function_end("AES_set_decrypt_key");
2978&asciz("AES for x86, CRYPTOGAMS by <appro\@openssl.org>");
1532 2979
1533&asm_finish(); 2980&asm_finish();
diff --git a/src/lib/libcrypto/aes/asm/aes-x86_64.pl b/src/lib/libcrypto/aes/asm/aes-x86_64.pl
index a545e892ae..53e4ef85fd 100755
--- a/src/lib/libcrypto/aes/asm/aes-x86_64.pl
+++ b/src/lib/libcrypto/aes/asm/aes-x86_64.pl
@@ -1669,7 +1669,7 @@ AES_cbc_encrypt:
1669 lea .LAES_Td(%rip),$sbox 1669 lea .LAES_Td(%rip),$sbox
1670.Lcbc_picked_te: 1670.Lcbc_picked_te:
1671 1671
1672 mov OPENSSL_ia32cap_P(%rip),%r10d 1672 mov PIC_GOT(OPENSSL_ia32cap_P),%r10d
1673 cmp \$$speed_limit,%rdx 1673 cmp \$$speed_limit,%rdx
1674 jb .Lcbc_slow_prologue 1674 jb .Lcbc_slow_prologue
1675 test \$15,%rdx 1675 test \$15,%rdx
diff --git a/src/lib/libcrypto/asn1/Makefile.ssl b/src/lib/libcrypto/asn1/Makefile.ssl
deleted file mode 100644
index cb45194d48..0000000000
--- a/src/lib/libcrypto/asn1/Makefile.ssl
+++ /dev/null
@@ -1,1152 +0,0 @@
1#
2# SSLeay/crypto/asn1/Makefile
3#
4
5DIR= asn1
6TOP= ../..
7CC= cc
8INCLUDES= -I.. -I$(TOP) -I../../include
9CFLAG=-g
10INSTALL_PREFIX=
11OPENSSLDIR= /usr/local/ssl
12INSTALLTOP=/usr/local/ssl
13MAKE= make -f Makefile.ssl
14MAKEDEPPROG= makedepend
15MAKEDEPEND= $(TOP)/util/domd $(TOP) -MD $(MAKEDEPPROG)
16MAKEFILE= Makefile.ssl
17AR= ar r
18
19CFLAGS= $(INCLUDES) $(CFLAG)
20
21GENERAL=Makefile README
22TEST=
23APPS=
24
25LIB=$(TOP)/libcrypto.a
26LIBSRC= a_object.c a_bitstr.c a_utctm.c a_gentm.c a_time.c a_int.c a_octet.c \
27 a_print.c a_type.c a_set.c a_dup.c a_d2i_fp.c a_i2d_fp.c \
28 a_enum.c a_utf8.c a_sign.c a_digest.c a_verify.c a_mbstr.c a_strex.c \
29 x_algor.c x_val.c x_pubkey.c x_sig.c x_req.c x_attrib.c x_bignum.c \
30 x_long.c x_name.c x_x509.c x_x509a.c x_crl.c x_info.c x_spki.c nsseq.c \
31 d2i_pu.c d2i_pr.c i2d_pu.c i2d_pr.c\
32 t_req.c t_x509.c t_x509a.c t_crl.c t_pkey.c t_spki.c t_bitst.c \
33 tasn_new.c tasn_fre.c tasn_enc.c tasn_dec.c tasn_utl.c tasn_typ.c \
34 f_int.c f_string.c n_pkey.c \
35 f_enum.c a_hdr.c x_pkey.c a_bool.c x_exten.c \
36 asn1_par.c asn1_lib.c asn1_err.c a_meth.c a_bytes.c a_strnid.c \
37 evp_asn1.c asn_pack.c p5_pbe.c p5_pbev2.c p8_pkey.c asn_moid.c
38LIBOBJ= a_object.o a_bitstr.o a_utctm.o a_gentm.o a_time.o a_int.o a_octet.o \
39 a_print.o a_type.o a_set.o a_dup.o a_d2i_fp.o a_i2d_fp.o \
40 a_enum.o a_utf8.o a_sign.o a_digest.o a_verify.o a_mbstr.o a_strex.o \
41 x_algor.o x_val.o x_pubkey.o x_sig.o x_req.o x_attrib.o x_bignum.o \
42 x_long.o x_name.o x_x509.o x_x509a.o x_crl.o x_info.o x_spki.o nsseq.o \
43 d2i_pu.o d2i_pr.o i2d_pu.o i2d_pr.o \
44 t_req.o t_x509.o t_x509a.o t_crl.o t_pkey.o t_spki.o t_bitst.o \
45 tasn_new.o tasn_fre.o tasn_enc.o tasn_dec.o tasn_utl.o tasn_typ.o \
46 f_int.o f_string.o n_pkey.o \
47 f_enum.o a_hdr.o x_pkey.o a_bool.o x_exten.o \
48 asn1_par.o asn1_lib.o asn1_err.o a_meth.o a_bytes.o a_strnid.o \
49 evp_asn1.o asn_pack.o p5_pbe.o p5_pbev2.o p8_pkey.o asn_moid.o
50
51SRC= $(LIBSRC)
52
53EXHEADER= asn1.h asn1_mac.h asn1t.h
54HEADER= $(EXHEADER)
55
56ALL= $(GENERAL) $(SRC) $(HEADER)
57
58top:
59 (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all)
60
61test: test.c
62 cc -g -I../../include -c test.c
63 cc -g -I../../include -o test test.o -L../.. -lcrypto
64
65pk: pk.c
66 cc -g -I../../include -c pk.c
67 cc -g -I../../include -o pk pk.o -L../.. -lcrypto
68
69all: lib
70
71lib: $(LIBOBJ)
72 $(AR) $(LIB) $(LIBOBJ)
73 $(RANLIB) $(LIB) || echo Never mind.
74 @touch lib
75
76files:
77 $(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO
78
79links:
80 @sh $(TOP)/util/point.sh Makefile.ssl Makefile
81 @$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER)
82 @$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST)
83 @$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS)
84
85install:
86 @for i in $(EXHEADER) ; \
87 do \
88 (cp $$i $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i; \
89 chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i ); \
90 done;
91
92tags:
93 ctags $(SRC)
94
95tests:
96
97lint:
98 lint -DLINT $(INCLUDES) $(SRC)>fluff
99
100depend:
101 $(MAKEDEPEND) -- $(CFLAG) $(INCLUDES) $(DEPFLAG) -- $(PROGS) $(LIBSRC)
102
103dclean:
104 $(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
105 mv -f Makefile.new $(MAKEFILE)
106
107clean:
108 rm -f *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff
109
110
111# DO NOT DELETE THIS LINE -- make depend depends on it.
112
113a_bitstr.o: ../../e_os.h ../../include/openssl/asn1.h
114a_bitstr.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
115a_bitstr.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
116a_bitstr.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
117a_bitstr.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
118a_bitstr.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
119a_bitstr.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
120a_bitstr.o: ../../include/openssl/symhacks.h ../cryptlib.h a_bitstr.c
121a_bool.o: ../../e_os.h ../../include/openssl/asn1.h
122a_bool.o: ../../include/openssl/asn1t.h ../../include/openssl/bio.h
123a_bool.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
124a_bool.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
125a_bool.o: ../../include/openssl/err.h ../../include/openssl/lhash.h
126a_bool.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
127a_bool.o: ../../include/openssl/ossl_typ.h ../../include/openssl/safestack.h
128a_bool.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
129a_bool.o: ../cryptlib.h a_bool.c
130a_bytes.o: ../../e_os.h ../../include/openssl/asn1.h
131a_bytes.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
132a_bytes.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
133a_bytes.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
134a_bytes.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
135a_bytes.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
136a_bytes.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
137a_bytes.o: ../../include/openssl/symhacks.h ../cryptlib.h a_bytes.c
138a_d2i_fp.o: ../../e_os.h ../../include/openssl/asn1.h
139a_d2i_fp.o: ../../include/openssl/asn1_mac.h ../../include/openssl/bio.h
140a_d2i_fp.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
141a_d2i_fp.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
142a_d2i_fp.o: ../../include/openssl/err.h ../../include/openssl/lhash.h
143a_d2i_fp.o: ../../include/openssl/opensslconf.h
144a_d2i_fp.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
145a_d2i_fp.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
146a_d2i_fp.o: ../../include/openssl/symhacks.h ../cryptlib.h a_d2i_fp.c
147a_digest.o: ../../e_os.h ../../include/openssl/aes.h
148a_digest.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
149a_digest.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
150a_digest.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
151a_digest.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
152a_digest.o: ../../include/openssl/des_old.h ../../include/openssl/dh.h
153a_digest.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
154a_digest.o: ../../include/openssl/err.h ../../include/openssl/evp.h
155a_digest.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h
156a_digest.o: ../../include/openssl/md2.h ../../include/openssl/md4.h
157a_digest.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
158a_digest.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
159a_digest.o: ../../include/openssl/opensslconf.h
160a_digest.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
161a_digest.o: ../../include/openssl/pkcs7.h ../../include/openssl/rc2.h
162a_digest.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
163a_digest.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
164a_digest.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
165a_digest.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
166a_digest.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
167a_digest.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
168a_digest.o: ../cryptlib.h a_digest.c
169a_dup.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h
170a_dup.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
171a_dup.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
172a_dup.o: ../../include/openssl/err.h ../../include/openssl/lhash.h
173a_dup.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
174a_dup.o: ../../include/openssl/ossl_typ.h ../../include/openssl/safestack.h
175a_dup.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
176a_dup.o: ../cryptlib.h a_dup.c
177a_enum.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h
178a_enum.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
179a_enum.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
180a_enum.o: ../../include/openssl/err.h ../../include/openssl/lhash.h
181a_enum.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
182a_enum.o: ../../include/openssl/ossl_typ.h ../../include/openssl/safestack.h
183a_enum.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
184a_enum.o: ../cryptlib.h a_enum.c
185a_gentm.o: ../../e_os.h ../../include/openssl/asn1.h
186a_gentm.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
187a_gentm.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
188a_gentm.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
189a_gentm.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
190a_gentm.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
191a_gentm.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
192a_gentm.o: ../../include/openssl/symhacks.h ../cryptlib.h ../o_time.h a_gentm.c
193a_hdr.o: ../../e_os.h ../../include/openssl/asn1.h
194a_hdr.o: ../../include/openssl/asn1_mac.h ../../include/openssl/bio.h
195a_hdr.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
196a_hdr.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
197a_hdr.o: ../../include/openssl/err.h ../../include/openssl/lhash.h
198a_hdr.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
199a_hdr.o: ../../include/openssl/ossl_typ.h ../../include/openssl/safestack.h
200a_hdr.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
201a_hdr.o: ../cryptlib.h a_hdr.c
202a_i2d_fp.o: ../../e_os.h ../../include/openssl/asn1.h
203a_i2d_fp.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
204a_i2d_fp.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
205a_i2d_fp.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
206a_i2d_fp.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
207a_i2d_fp.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
208a_i2d_fp.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
209a_i2d_fp.o: ../../include/openssl/symhacks.h ../cryptlib.h a_i2d_fp.c
210a_int.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h
211a_int.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
212a_int.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
213a_int.o: ../../include/openssl/err.h ../../include/openssl/lhash.h
214a_int.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
215a_int.o: ../../include/openssl/ossl_typ.h ../../include/openssl/safestack.h
216a_int.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
217a_int.o: ../cryptlib.h a_int.c
218a_mbstr.o: ../../e_os.h ../../include/openssl/asn1.h
219a_mbstr.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
220a_mbstr.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
221a_mbstr.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
222a_mbstr.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
223a_mbstr.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
224a_mbstr.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
225a_mbstr.o: ../../include/openssl/symhacks.h ../cryptlib.h a_mbstr.c
226a_meth.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h
227a_meth.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
228a_meth.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
229a_meth.o: ../../include/openssl/err.h ../../include/openssl/lhash.h
230a_meth.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
231a_meth.o: ../../include/openssl/ossl_typ.h ../../include/openssl/safestack.h
232a_meth.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
233a_meth.o: ../cryptlib.h a_meth.c
234a_object.o: ../../e_os.h ../../include/openssl/asn1.h
235a_object.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
236a_object.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
237a_object.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
238a_object.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
239a_object.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
240a_object.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
241a_object.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
242a_object.o: ../../include/openssl/symhacks.h ../cryptlib.h a_object.c
243a_octet.o: ../../e_os.h ../../include/openssl/asn1.h
244a_octet.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
245a_octet.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
246a_octet.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
247a_octet.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
248a_octet.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
249a_octet.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
250a_octet.o: ../../include/openssl/symhacks.h ../cryptlib.h a_octet.c
251a_print.o: ../../e_os.h ../../include/openssl/asn1.h
252a_print.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
253a_print.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
254a_print.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
255a_print.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
256a_print.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
257a_print.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
258a_print.o: ../../include/openssl/symhacks.h ../cryptlib.h a_print.c
259a_set.o: ../../e_os.h ../../include/openssl/asn1.h
260a_set.o: ../../include/openssl/asn1_mac.h ../../include/openssl/bio.h
261a_set.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
262a_set.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
263a_set.o: ../../include/openssl/err.h ../../include/openssl/lhash.h
264a_set.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
265a_set.o: ../../include/openssl/ossl_typ.h ../../include/openssl/safestack.h
266a_set.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
267a_set.o: ../cryptlib.h a_set.c
268a_sign.o: ../../e_os.h ../../include/openssl/aes.h ../../include/openssl/asn1.h
269a_sign.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h
270a_sign.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
271a_sign.o: ../../include/openssl/cast.h ../../include/openssl/crypto.h
272a_sign.o: ../../include/openssl/des.h ../../include/openssl/des_old.h
273a_sign.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
274a_sign.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
275a_sign.o: ../../include/openssl/evp.h ../../include/openssl/idea.h
276a_sign.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h
277a_sign.o: ../../include/openssl/md4.h ../../include/openssl/md5.h
278a_sign.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h
279a_sign.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
280a_sign.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
281a_sign.o: ../../include/openssl/pkcs7.h ../../include/openssl/rc2.h
282a_sign.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
283a_sign.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
284a_sign.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
285a_sign.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
286a_sign.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
287a_sign.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
288a_sign.o: ../cryptlib.h a_sign.c
289a_strex.o: ../../e_os.h ../../include/openssl/aes.h
290a_strex.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
291a_strex.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
292a_strex.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
293a_strex.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
294a_strex.o: ../../include/openssl/des_old.h ../../include/openssl/dh.h
295a_strex.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
296a_strex.o: ../../include/openssl/err.h ../../include/openssl/evp.h
297a_strex.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h
298a_strex.o: ../../include/openssl/md2.h ../../include/openssl/md4.h
299a_strex.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
300a_strex.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
301a_strex.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
302a_strex.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h
303a_strex.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h
304a_strex.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h
305a_strex.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
306a_strex.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
307a_strex.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
308a_strex.o: ../../include/openssl/ui_compat.h ../../include/openssl/x509.h
309a_strex.o: ../../include/openssl/x509_vfy.h ../cryptlib.h a_strex.c charmap.h
310a_strnid.o: ../../e_os.h ../../include/openssl/asn1.h
311a_strnid.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
312a_strnid.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
313a_strnid.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
314a_strnid.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
315a_strnid.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
316a_strnid.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
317a_strnid.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
318a_strnid.o: ../../include/openssl/symhacks.h ../cryptlib.h a_strnid.c
319a_time.o: ../../e_os.h ../../include/openssl/asn1.h
320a_time.o: ../../include/openssl/asn1t.h ../../include/openssl/bio.h
321a_time.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
322a_time.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
323a_time.o: ../../include/openssl/err.h ../../include/openssl/lhash.h
324a_time.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
325a_time.o: ../../include/openssl/ossl_typ.h ../../include/openssl/safestack.h
326a_time.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
327a_time.o: ../cryptlib.h ../o_time.h a_time.c
328a_type.o: ../../e_os.h ../../include/openssl/asn1.h
329a_type.o: ../../include/openssl/asn1t.h ../../include/openssl/bio.h
330a_type.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
331a_type.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
332a_type.o: ../../include/openssl/err.h ../../include/openssl/lhash.h
333a_type.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
334a_type.o: ../../include/openssl/ossl_typ.h ../../include/openssl/safestack.h
335a_type.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
336a_type.o: ../cryptlib.h a_type.c
337a_utctm.o: ../../e_os.h ../../include/openssl/asn1.h
338a_utctm.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
339a_utctm.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
340a_utctm.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
341a_utctm.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
342a_utctm.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
343a_utctm.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
344a_utctm.o: ../../include/openssl/symhacks.h ../cryptlib.h ../o_time.h a_utctm.c
345a_utf8.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h
346a_utf8.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
347a_utf8.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
348a_utf8.o: ../../include/openssl/err.h ../../include/openssl/lhash.h
349a_utf8.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
350a_utf8.o: ../../include/openssl/ossl_typ.h ../../include/openssl/safestack.h
351a_utf8.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
352a_utf8.o: ../cryptlib.h a_utf8.c
353a_verify.o: ../../e_os.h ../../include/openssl/aes.h
354a_verify.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
355a_verify.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
356a_verify.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
357a_verify.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
358a_verify.o: ../../include/openssl/des_old.h ../../include/openssl/dh.h
359a_verify.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
360a_verify.o: ../../include/openssl/err.h ../../include/openssl/evp.h
361a_verify.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h
362a_verify.o: ../../include/openssl/md2.h ../../include/openssl/md4.h
363a_verify.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
364a_verify.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
365a_verify.o: ../../include/openssl/opensslconf.h
366a_verify.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
367a_verify.o: ../../include/openssl/pkcs7.h ../../include/openssl/rc2.h
368a_verify.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
369a_verify.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
370a_verify.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
371a_verify.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
372a_verify.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
373a_verify.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
374a_verify.o: ../cryptlib.h a_verify.c
375asn1_err.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
376asn1_err.o: ../../include/openssl/bn.h ../../include/openssl/crypto.h
377asn1_err.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
378asn1_err.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
379asn1_err.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
380asn1_err.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
381asn1_err.o: ../../include/openssl/symhacks.h asn1_err.c
382asn1_lib.o: ../../e_os.h ../../include/openssl/asn1.h
383asn1_lib.o: ../../include/openssl/asn1_mac.h ../../include/openssl/bio.h
384asn1_lib.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
385asn1_lib.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
386asn1_lib.o: ../../include/openssl/err.h ../../include/openssl/lhash.h
387asn1_lib.o: ../../include/openssl/opensslconf.h
388asn1_lib.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
389asn1_lib.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
390asn1_lib.o: ../../include/openssl/symhacks.h ../cryptlib.h asn1_lib.c
391asn1_par.o: ../../e_os.h ../../include/openssl/asn1.h
392asn1_par.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
393asn1_par.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
394asn1_par.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
395asn1_par.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
396asn1_par.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
397asn1_par.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
398asn1_par.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
399asn1_par.o: ../../include/openssl/symhacks.h ../cryptlib.h asn1_par.c
400asn_moid.o: ../../e_os.h ../../include/openssl/aes.h
401asn_moid.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
402asn_moid.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
403asn_moid.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
404asn_moid.o: ../../include/openssl/conf.h ../../include/openssl/crypto.h
405asn_moid.o: ../../include/openssl/des.h ../../include/openssl/des_old.h
406asn_moid.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
407asn_moid.o: ../../include/openssl/dso.h ../../include/openssl/e_os2.h
408asn_moid.o: ../../include/openssl/err.h ../../include/openssl/evp.h
409asn_moid.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h
410asn_moid.o: ../../include/openssl/md2.h ../../include/openssl/md4.h
411asn_moid.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
412asn_moid.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
413asn_moid.o: ../../include/openssl/opensslconf.h
414asn_moid.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
415asn_moid.o: ../../include/openssl/pkcs7.h ../../include/openssl/rc2.h
416asn_moid.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
417asn_moid.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
418asn_moid.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
419asn_moid.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
420asn_moid.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
421asn_moid.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
422asn_moid.o: ../cryptlib.h asn_moid.c
423asn_pack.o: ../../e_os.h ../../include/openssl/asn1.h
424asn_pack.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
425asn_pack.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
426asn_pack.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
427asn_pack.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
428asn_pack.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
429asn_pack.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
430asn_pack.o: ../../include/openssl/symhacks.h ../cryptlib.h asn_pack.c
431d2i_pr.o: ../../e_os.h ../../include/openssl/aes.h ../../include/openssl/asn1.h
432d2i_pr.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h
433d2i_pr.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
434d2i_pr.o: ../../include/openssl/cast.h ../../include/openssl/crypto.h
435d2i_pr.o: ../../include/openssl/des.h ../../include/openssl/des_old.h
436d2i_pr.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
437d2i_pr.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
438d2i_pr.o: ../../include/openssl/evp.h ../../include/openssl/idea.h
439d2i_pr.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h
440d2i_pr.o: ../../include/openssl/md4.h ../../include/openssl/md5.h
441d2i_pr.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h
442d2i_pr.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
443d2i_pr.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
444d2i_pr.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h
445d2i_pr.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h
446d2i_pr.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
447d2i_pr.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
448d2i_pr.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
449d2i_pr.o: ../../include/openssl/ui_compat.h ../cryptlib.h d2i_pr.c
450d2i_pu.o: ../../e_os.h ../../include/openssl/aes.h ../../include/openssl/asn1.h
451d2i_pu.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h
452d2i_pu.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
453d2i_pu.o: ../../include/openssl/cast.h ../../include/openssl/crypto.h
454d2i_pu.o: ../../include/openssl/des.h ../../include/openssl/des_old.h
455d2i_pu.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
456d2i_pu.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
457d2i_pu.o: ../../include/openssl/evp.h ../../include/openssl/idea.h
458d2i_pu.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h
459d2i_pu.o: ../../include/openssl/md4.h ../../include/openssl/md5.h
460d2i_pu.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h
461d2i_pu.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
462d2i_pu.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
463d2i_pu.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h
464d2i_pu.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h
465d2i_pu.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
466d2i_pu.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
467d2i_pu.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
468d2i_pu.o: ../../include/openssl/ui_compat.h ../cryptlib.h d2i_pu.c
469evp_asn1.o: ../../e_os.h ../../include/openssl/asn1.h
470evp_asn1.o: ../../include/openssl/asn1_mac.h ../../include/openssl/bio.h
471evp_asn1.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
472evp_asn1.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
473evp_asn1.o: ../../include/openssl/err.h ../../include/openssl/lhash.h
474evp_asn1.o: ../../include/openssl/opensslconf.h
475evp_asn1.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
476evp_asn1.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
477evp_asn1.o: ../../include/openssl/symhacks.h ../cryptlib.h evp_asn1.c
478f_enum.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h
479f_enum.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
480f_enum.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
481f_enum.o: ../../include/openssl/err.h ../../include/openssl/lhash.h
482f_enum.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
483f_enum.o: ../../include/openssl/ossl_typ.h ../../include/openssl/safestack.h
484f_enum.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
485f_enum.o: ../cryptlib.h f_enum.c
486f_int.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h
487f_int.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
488f_int.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
489f_int.o: ../../include/openssl/err.h ../../include/openssl/lhash.h
490f_int.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
491f_int.o: ../../include/openssl/ossl_typ.h ../../include/openssl/safestack.h
492f_int.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
493f_int.o: ../cryptlib.h f_int.c
494f_string.o: ../../e_os.h ../../include/openssl/asn1.h
495f_string.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
496f_string.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
497f_string.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
498f_string.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
499f_string.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
500f_string.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
501f_string.o: ../../include/openssl/symhacks.h ../cryptlib.h f_string.c
502i2d_pr.o: ../../e_os.h ../../include/openssl/aes.h ../../include/openssl/asn1.h
503i2d_pr.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h
504i2d_pr.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
505i2d_pr.o: ../../include/openssl/cast.h ../../include/openssl/crypto.h
506i2d_pr.o: ../../include/openssl/des.h ../../include/openssl/des_old.h
507i2d_pr.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
508i2d_pr.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
509i2d_pr.o: ../../include/openssl/evp.h ../../include/openssl/idea.h
510i2d_pr.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h
511i2d_pr.o: ../../include/openssl/md4.h ../../include/openssl/md5.h
512i2d_pr.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h
513i2d_pr.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
514i2d_pr.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
515i2d_pr.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h
516i2d_pr.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h
517i2d_pr.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
518i2d_pr.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
519i2d_pr.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
520i2d_pr.o: ../../include/openssl/ui_compat.h ../cryptlib.h i2d_pr.c
521i2d_pu.o: ../../e_os.h ../../include/openssl/aes.h ../../include/openssl/asn1.h
522i2d_pu.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h
523i2d_pu.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
524i2d_pu.o: ../../include/openssl/cast.h ../../include/openssl/crypto.h
525i2d_pu.o: ../../include/openssl/des.h ../../include/openssl/des_old.h
526i2d_pu.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
527i2d_pu.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
528i2d_pu.o: ../../include/openssl/evp.h ../../include/openssl/idea.h
529i2d_pu.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h
530i2d_pu.o: ../../include/openssl/md4.h ../../include/openssl/md5.h
531i2d_pu.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h
532i2d_pu.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
533i2d_pu.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
534i2d_pu.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h
535i2d_pu.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h
536i2d_pu.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
537i2d_pu.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
538i2d_pu.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
539i2d_pu.o: ../../include/openssl/ui_compat.h ../cryptlib.h i2d_pu.c
540n_pkey.o: ../../e_os.h ../../include/openssl/aes.h ../../include/openssl/asn1.h
541n_pkey.o: ../../include/openssl/asn1_mac.h ../../include/openssl/asn1t.h
542n_pkey.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h
543n_pkey.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
544n_pkey.o: ../../include/openssl/cast.h ../../include/openssl/crypto.h
545n_pkey.o: ../../include/openssl/des.h ../../include/openssl/des_old.h
546n_pkey.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
547n_pkey.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
548n_pkey.o: ../../include/openssl/evp.h ../../include/openssl/idea.h
549n_pkey.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h
550n_pkey.o: ../../include/openssl/md4.h ../../include/openssl/md5.h
551n_pkey.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h
552n_pkey.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
553n_pkey.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
554n_pkey.o: ../../include/openssl/pkcs7.h ../../include/openssl/rc2.h
555n_pkey.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
556n_pkey.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
557n_pkey.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
558n_pkey.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
559n_pkey.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
560n_pkey.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
561n_pkey.o: ../cryptlib.h n_pkey.c
562nsseq.o: ../../include/openssl/aes.h ../../include/openssl/asn1.h
563nsseq.o: ../../include/openssl/asn1t.h ../../include/openssl/bio.h
564nsseq.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
565nsseq.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
566nsseq.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
567nsseq.o: ../../include/openssl/des_old.h ../../include/openssl/dh.h
568nsseq.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
569nsseq.o: ../../include/openssl/evp.h ../../include/openssl/idea.h
570nsseq.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h
571nsseq.o: ../../include/openssl/md4.h ../../include/openssl/md5.h
572nsseq.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h
573nsseq.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
574nsseq.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
575nsseq.o: ../../include/openssl/pkcs7.h ../../include/openssl/rc2.h
576nsseq.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
577nsseq.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
578nsseq.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
579nsseq.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
580nsseq.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
581nsseq.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h nsseq.c
582p5_pbe.o: ../../e_os.h ../../include/openssl/aes.h ../../include/openssl/asn1.h
583p5_pbe.o: ../../include/openssl/asn1t.h ../../include/openssl/bio.h
584p5_pbe.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
585p5_pbe.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
586p5_pbe.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
587p5_pbe.o: ../../include/openssl/des_old.h ../../include/openssl/dh.h
588p5_pbe.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
589p5_pbe.o: ../../include/openssl/err.h ../../include/openssl/evp.h
590p5_pbe.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h
591p5_pbe.o: ../../include/openssl/md2.h ../../include/openssl/md4.h
592p5_pbe.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
593p5_pbe.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
594p5_pbe.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
595p5_pbe.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h
596p5_pbe.o: ../../include/openssl/rand.h ../../include/openssl/rc2.h
597p5_pbe.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
598p5_pbe.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
599p5_pbe.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
600p5_pbe.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
601p5_pbe.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
602p5_pbe.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
603p5_pbe.o: ../cryptlib.h p5_pbe.c
604p5_pbev2.o: ../../e_os.h ../../include/openssl/aes.h
605p5_pbev2.o: ../../include/openssl/asn1.h ../../include/openssl/asn1t.h
606p5_pbev2.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h
607p5_pbev2.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
608p5_pbev2.o: ../../include/openssl/cast.h ../../include/openssl/crypto.h
609p5_pbev2.o: ../../include/openssl/des.h ../../include/openssl/des_old.h
610p5_pbev2.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
611p5_pbev2.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
612p5_pbev2.o: ../../include/openssl/evp.h ../../include/openssl/idea.h
613p5_pbev2.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h
614p5_pbev2.o: ../../include/openssl/md4.h ../../include/openssl/md5.h
615p5_pbev2.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h
616p5_pbev2.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
617p5_pbev2.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
618p5_pbev2.o: ../../include/openssl/pkcs7.h ../../include/openssl/rand.h
619p5_pbev2.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h
620p5_pbev2.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h
621p5_pbev2.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
622p5_pbev2.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
623p5_pbev2.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
624p5_pbev2.o: ../../include/openssl/ui_compat.h ../../include/openssl/x509.h
625p5_pbev2.o: ../../include/openssl/x509_vfy.h ../cryptlib.h p5_pbev2.c
626p8_pkey.o: ../../e_os.h ../../include/openssl/aes.h
627p8_pkey.o: ../../include/openssl/asn1.h ../../include/openssl/asn1t.h
628p8_pkey.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h
629p8_pkey.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
630p8_pkey.o: ../../include/openssl/cast.h ../../include/openssl/crypto.h
631p8_pkey.o: ../../include/openssl/des.h ../../include/openssl/des_old.h
632p8_pkey.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
633p8_pkey.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
634p8_pkey.o: ../../include/openssl/evp.h ../../include/openssl/idea.h
635p8_pkey.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h
636p8_pkey.o: ../../include/openssl/md4.h ../../include/openssl/md5.h
637p8_pkey.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h
638p8_pkey.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
639p8_pkey.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
640p8_pkey.o: ../../include/openssl/pkcs7.h ../../include/openssl/rc2.h
641p8_pkey.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
642p8_pkey.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
643p8_pkey.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
644p8_pkey.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
645p8_pkey.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
646p8_pkey.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
647p8_pkey.o: ../cryptlib.h p8_pkey.c
648t_bitst.o: ../../e_os.h ../../include/openssl/aes.h
649t_bitst.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
650t_bitst.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
651t_bitst.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
652t_bitst.o: ../../include/openssl/conf.h ../../include/openssl/crypto.h
653t_bitst.o: ../../include/openssl/des.h ../../include/openssl/des_old.h
654t_bitst.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
655t_bitst.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
656t_bitst.o: ../../include/openssl/evp.h ../../include/openssl/idea.h
657t_bitst.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h
658t_bitst.o: ../../include/openssl/md4.h ../../include/openssl/md5.h
659t_bitst.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h
660t_bitst.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
661t_bitst.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
662t_bitst.o: ../../include/openssl/pkcs7.h ../../include/openssl/rc2.h
663t_bitst.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
664t_bitst.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
665t_bitst.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
666t_bitst.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
667t_bitst.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
668t_bitst.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
669t_bitst.o: ../../include/openssl/x509v3.h ../cryptlib.h t_bitst.c
670t_crl.o: ../../e_os.h ../../include/openssl/aes.h ../../include/openssl/asn1.h
671t_crl.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h
672t_crl.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
673t_crl.o: ../../include/openssl/cast.h ../../include/openssl/conf.h
674t_crl.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
675t_crl.o: ../../include/openssl/des_old.h ../../include/openssl/dh.h
676t_crl.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
677t_crl.o: ../../include/openssl/err.h ../../include/openssl/evp.h
678t_crl.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h
679t_crl.o: ../../include/openssl/md2.h ../../include/openssl/md4.h
680t_crl.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
681t_crl.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
682t_crl.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
683t_crl.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h
684t_crl.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h
685t_crl.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h
686t_crl.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
687t_crl.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
688t_crl.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
689t_crl.o: ../../include/openssl/ui_compat.h ../../include/openssl/x509.h
690t_crl.o: ../../include/openssl/x509_vfy.h ../../include/openssl/x509v3.h
691t_crl.o: ../cryptlib.h t_crl.c
692t_pkey.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h
693t_pkey.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
694t_pkey.o: ../../include/openssl/crypto.h ../../include/openssl/dh.h
695t_pkey.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
696t_pkey.o: ../../include/openssl/err.h ../../include/openssl/lhash.h
697t_pkey.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
698t_pkey.o: ../../include/openssl/ossl_typ.h ../../include/openssl/rsa.h
699t_pkey.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
700t_pkey.o: ../../include/openssl/symhacks.h ../cryptlib.h t_pkey.c
701t_req.o: ../../e_os.h ../../include/openssl/aes.h ../../include/openssl/asn1.h
702t_req.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h
703t_req.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
704t_req.o: ../../include/openssl/cast.h ../../include/openssl/conf.h
705t_req.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
706t_req.o: ../../include/openssl/des_old.h ../../include/openssl/dh.h
707t_req.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
708t_req.o: ../../include/openssl/err.h ../../include/openssl/evp.h
709t_req.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h
710t_req.o: ../../include/openssl/md2.h ../../include/openssl/md4.h
711t_req.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
712t_req.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
713t_req.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
714t_req.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h
715t_req.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h
716t_req.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h
717t_req.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
718t_req.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
719t_req.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
720t_req.o: ../../include/openssl/ui_compat.h ../../include/openssl/x509.h
721t_req.o: ../../include/openssl/x509_vfy.h ../../include/openssl/x509v3.h
722t_req.o: ../cryptlib.h t_req.c
723t_spki.o: ../../e_os.h ../../include/openssl/aes.h ../../include/openssl/asn1.h
724t_spki.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h
725t_spki.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
726t_spki.o: ../../include/openssl/cast.h ../../include/openssl/crypto.h
727t_spki.o: ../../include/openssl/des.h ../../include/openssl/des_old.h
728t_spki.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
729t_spki.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
730t_spki.o: ../../include/openssl/evp.h ../../include/openssl/idea.h
731t_spki.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h
732t_spki.o: ../../include/openssl/md4.h ../../include/openssl/md5.h
733t_spki.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h
734t_spki.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
735t_spki.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
736t_spki.o: ../../include/openssl/pkcs7.h ../../include/openssl/rc2.h
737t_spki.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
738t_spki.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
739t_spki.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
740t_spki.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
741t_spki.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
742t_spki.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
743t_spki.o: ../cryptlib.h t_spki.c
744t_x509.o: ../../e_os.h ../../include/openssl/aes.h ../../include/openssl/asn1.h
745t_x509.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h
746t_x509.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
747t_x509.o: ../../include/openssl/cast.h ../../include/openssl/conf.h
748t_x509.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
749t_x509.o: ../../include/openssl/des_old.h ../../include/openssl/dh.h
750t_x509.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
751t_x509.o: ../../include/openssl/err.h ../../include/openssl/evp.h
752t_x509.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h
753t_x509.o: ../../include/openssl/md2.h ../../include/openssl/md4.h
754t_x509.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
755t_x509.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
756t_x509.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
757t_x509.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h
758t_x509.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h
759t_x509.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h
760t_x509.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
761t_x509.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
762t_x509.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
763t_x509.o: ../../include/openssl/ui_compat.h ../../include/openssl/x509.h
764t_x509.o: ../../include/openssl/x509_vfy.h ../../include/openssl/x509v3.h
765t_x509.o: ../cryptlib.h t_x509.c
766t_x509a.o: ../../e_os.h ../../include/openssl/aes.h
767t_x509a.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
768t_x509a.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
769t_x509a.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
770t_x509a.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
771t_x509a.o: ../../include/openssl/des_old.h ../../include/openssl/dh.h
772t_x509a.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
773t_x509a.o: ../../include/openssl/err.h ../../include/openssl/evp.h
774t_x509a.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h
775t_x509a.o: ../../include/openssl/md2.h ../../include/openssl/md4.h
776t_x509a.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
777t_x509a.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
778t_x509a.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
779t_x509a.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h
780t_x509a.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h
781t_x509a.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h
782t_x509a.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
783t_x509a.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
784t_x509a.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
785t_x509a.o: ../../include/openssl/ui_compat.h ../../include/openssl/x509.h
786t_x509a.o: ../../include/openssl/x509_vfy.h ../cryptlib.h t_x509a.c
787tasn_dec.o: ../../include/openssl/asn1.h ../../include/openssl/asn1t.h
788tasn_dec.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
789tasn_dec.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
790tasn_dec.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
791tasn_dec.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
792tasn_dec.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
793tasn_dec.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
794tasn_dec.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
795tasn_dec.o: ../../include/openssl/symhacks.h tasn_dec.c
796tasn_enc.o: ../../include/openssl/asn1.h ../../include/openssl/asn1t.h
797tasn_enc.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
798tasn_enc.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
799tasn_enc.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
800tasn_enc.o: ../../include/openssl/opensslconf.h
801tasn_enc.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
802tasn_enc.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
803tasn_enc.o: ../../include/openssl/symhacks.h tasn_enc.c
804tasn_fre.o: ../../include/openssl/asn1.h ../../include/openssl/asn1t.h
805tasn_fre.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
806tasn_fre.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
807tasn_fre.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
808tasn_fre.o: ../../include/openssl/opensslconf.h
809tasn_fre.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
810tasn_fre.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
811tasn_fre.o: ../../include/openssl/symhacks.h tasn_fre.c
812tasn_new.o: ../../include/openssl/asn1.h ../../include/openssl/asn1t.h
813tasn_new.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
814tasn_new.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
815tasn_new.o: ../../include/openssl/err.h ../../include/openssl/lhash.h
816tasn_new.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
817tasn_new.o: ../../include/openssl/opensslconf.h
818tasn_new.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
819tasn_new.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
820tasn_new.o: ../../include/openssl/symhacks.h tasn_new.c
821tasn_typ.o: ../../include/openssl/asn1.h ../../include/openssl/asn1t.h
822tasn_typ.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
823tasn_typ.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
824tasn_typ.o: ../../include/openssl/opensslconf.h
825tasn_typ.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
826tasn_typ.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
827tasn_typ.o: ../../include/openssl/symhacks.h tasn_typ.c
828tasn_utl.o: ../../include/openssl/asn1.h ../../include/openssl/asn1t.h
829tasn_utl.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
830tasn_utl.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
831tasn_utl.o: ../../include/openssl/err.h ../../include/openssl/lhash.h
832tasn_utl.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
833tasn_utl.o: ../../include/openssl/opensslconf.h
834tasn_utl.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
835tasn_utl.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
836tasn_utl.o: ../../include/openssl/symhacks.h tasn_utl.c
837x_algor.o: ../../include/openssl/aes.h ../../include/openssl/asn1.h
838x_algor.o: ../../include/openssl/asn1t.h ../../include/openssl/bio.h
839x_algor.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
840x_algor.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
841x_algor.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
842x_algor.o: ../../include/openssl/des_old.h ../../include/openssl/dh.h
843x_algor.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
844x_algor.o: ../../include/openssl/evp.h ../../include/openssl/idea.h
845x_algor.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h
846x_algor.o: ../../include/openssl/md4.h ../../include/openssl/md5.h
847x_algor.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h
848x_algor.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
849x_algor.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
850x_algor.o: ../../include/openssl/pkcs7.h ../../include/openssl/rc2.h
851x_algor.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
852x_algor.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
853x_algor.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
854x_algor.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
855x_algor.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
856x_algor.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
857x_algor.o: x_algor.c
858x_attrib.o: ../../e_os.h ../../include/openssl/aes.h
859x_attrib.o: ../../include/openssl/asn1.h ../../include/openssl/asn1t.h
860x_attrib.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h
861x_attrib.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
862x_attrib.o: ../../include/openssl/cast.h ../../include/openssl/crypto.h
863x_attrib.o: ../../include/openssl/des.h ../../include/openssl/des_old.h
864x_attrib.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
865x_attrib.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
866x_attrib.o: ../../include/openssl/evp.h ../../include/openssl/idea.h
867x_attrib.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h
868x_attrib.o: ../../include/openssl/md4.h ../../include/openssl/md5.h
869x_attrib.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h
870x_attrib.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
871x_attrib.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
872x_attrib.o: ../../include/openssl/pkcs7.h ../../include/openssl/rc2.h
873x_attrib.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
874x_attrib.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
875x_attrib.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
876x_attrib.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
877x_attrib.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
878x_attrib.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
879x_attrib.o: ../cryptlib.h x_attrib.c
880x_bignum.o: ../../e_os.h ../../include/openssl/asn1.h
881x_bignum.o: ../../include/openssl/asn1t.h ../../include/openssl/bio.h
882x_bignum.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
883x_bignum.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
884x_bignum.o: ../../include/openssl/err.h ../../include/openssl/lhash.h
885x_bignum.o: ../../include/openssl/opensslconf.h
886x_bignum.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
887x_bignum.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
888x_bignum.o: ../../include/openssl/symhacks.h ../cryptlib.h x_bignum.c
889x_crl.o: ../../e_os.h ../../include/openssl/aes.h ../../include/openssl/asn1.h
890x_crl.o: ../../include/openssl/asn1t.h ../../include/openssl/bio.h
891x_crl.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
892x_crl.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
893x_crl.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
894x_crl.o: ../../include/openssl/des_old.h ../../include/openssl/dh.h
895x_crl.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
896x_crl.o: ../../include/openssl/err.h ../../include/openssl/evp.h
897x_crl.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h
898x_crl.o: ../../include/openssl/md2.h ../../include/openssl/md4.h
899x_crl.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
900x_crl.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
901x_crl.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
902x_crl.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h
903x_crl.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h
904x_crl.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h
905x_crl.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
906x_crl.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
907x_crl.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
908x_crl.o: ../../include/openssl/ui_compat.h ../../include/openssl/x509.h
909x_crl.o: ../../include/openssl/x509_vfy.h ../cryptlib.h x_crl.c
910x_exten.o: ../../include/openssl/aes.h ../../include/openssl/asn1.h
911x_exten.o: ../../include/openssl/asn1t.h ../../include/openssl/bio.h
912x_exten.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
913x_exten.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
914x_exten.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
915x_exten.o: ../../include/openssl/des_old.h ../../include/openssl/dh.h
916x_exten.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
917x_exten.o: ../../include/openssl/evp.h ../../include/openssl/idea.h
918x_exten.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h
919x_exten.o: ../../include/openssl/md4.h ../../include/openssl/md5.h
920x_exten.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h
921x_exten.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
922x_exten.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
923x_exten.o: ../../include/openssl/pkcs7.h ../../include/openssl/rc2.h
924x_exten.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
925x_exten.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
926x_exten.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
927x_exten.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
928x_exten.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
929x_exten.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
930x_exten.o: x_exten.c
931x_info.o: ../../e_os.h ../../include/openssl/aes.h ../../include/openssl/asn1.h
932x_info.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h
933x_info.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
934x_info.o: ../../include/openssl/cast.h ../../include/openssl/crypto.h
935x_info.o: ../../include/openssl/des.h ../../include/openssl/des_old.h
936x_info.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
937x_info.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
938x_info.o: ../../include/openssl/evp.h ../../include/openssl/idea.h
939x_info.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h
940x_info.o: ../../include/openssl/md4.h ../../include/openssl/md5.h
941x_info.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h
942x_info.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
943x_info.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
944x_info.o: ../../include/openssl/pkcs7.h ../../include/openssl/rc2.h
945x_info.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
946x_info.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
947x_info.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
948x_info.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
949x_info.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
950x_info.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
951x_info.o: ../cryptlib.h x_info.c
952x_long.o: ../../e_os.h ../../include/openssl/asn1.h
953x_long.o: ../../include/openssl/asn1t.h ../../include/openssl/bio.h
954x_long.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
955x_long.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
956x_long.o: ../../include/openssl/err.h ../../include/openssl/lhash.h
957x_long.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
958x_long.o: ../../include/openssl/ossl_typ.h ../../include/openssl/safestack.h
959x_long.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
960x_long.o: ../cryptlib.h x_long.c
961x_name.o: ../../e_os.h ../../include/openssl/aes.h ../../include/openssl/asn1.h
962x_name.o: ../../include/openssl/asn1t.h ../../include/openssl/bio.h
963x_name.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
964x_name.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
965x_name.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
966x_name.o: ../../include/openssl/des_old.h ../../include/openssl/dh.h
967x_name.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
968x_name.o: ../../include/openssl/err.h ../../include/openssl/evp.h
969x_name.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h
970x_name.o: ../../include/openssl/md2.h ../../include/openssl/md4.h
971x_name.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
972x_name.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
973x_name.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
974x_name.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h
975x_name.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h
976x_name.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h
977x_name.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
978x_name.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
979x_name.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
980x_name.o: ../../include/openssl/ui_compat.h ../../include/openssl/x509.h
981x_name.o: ../../include/openssl/x509_vfy.h ../cryptlib.h x_name.c
982x_pkey.o: ../../e_os.h ../../include/openssl/aes.h ../../include/openssl/asn1.h
983x_pkey.o: ../../include/openssl/asn1_mac.h ../../include/openssl/bio.h
984x_pkey.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
985x_pkey.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
986x_pkey.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
987x_pkey.o: ../../include/openssl/des_old.h ../../include/openssl/dh.h
988x_pkey.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
989x_pkey.o: ../../include/openssl/err.h ../../include/openssl/evp.h
990x_pkey.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h
991x_pkey.o: ../../include/openssl/md2.h ../../include/openssl/md4.h
992x_pkey.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
993x_pkey.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
994x_pkey.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
995x_pkey.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h
996x_pkey.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h
997x_pkey.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h
998x_pkey.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
999x_pkey.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
1000x_pkey.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
1001x_pkey.o: ../../include/openssl/ui_compat.h ../../include/openssl/x509.h
1002x_pkey.o: ../../include/openssl/x509_vfy.h ../cryptlib.h x_pkey.c
1003x_pubkey.o: ../../e_os.h ../../include/openssl/aes.h
1004x_pubkey.o: ../../include/openssl/asn1.h ../../include/openssl/asn1t.h
1005x_pubkey.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h
1006x_pubkey.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
1007x_pubkey.o: ../../include/openssl/cast.h ../../include/openssl/crypto.h
1008x_pubkey.o: ../../include/openssl/des.h ../../include/openssl/des_old.h
1009x_pubkey.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
1010x_pubkey.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
1011x_pubkey.o: ../../include/openssl/evp.h ../../include/openssl/idea.h
1012x_pubkey.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h
1013x_pubkey.o: ../../include/openssl/md4.h ../../include/openssl/md5.h
1014x_pubkey.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h
1015x_pubkey.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
1016x_pubkey.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
1017x_pubkey.o: ../../include/openssl/pkcs7.h ../../include/openssl/rc2.h
1018x_pubkey.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
1019x_pubkey.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
1020x_pubkey.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
1021x_pubkey.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
1022x_pubkey.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
1023x_pubkey.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
1024x_pubkey.o: ../cryptlib.h x_pubkey.c
1025x_req.o: ../../e_os.h ../../include/openssl/aes.h ../../include/openssl/asn1.h
1026x_req.o: ../../include/openssl/asn1t.h ../../include/openssl/bio.h
1027x_req.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
1028x_req.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
1029x_req.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
1030x_req.o: ../../include/openssl/des_old.h ../../include/openssl/dh.h
1031x_req.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
1032x_req.o: ../../include/openssl/err.h ../../include/openssl/evp.h
1033x_req.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h
1034x_req.o: ../../include/openssl/md2.h ../../include/openssl/md4.h
1035x_req.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
1036x_req.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
1037x_req.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
1038x_req.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h
1039x_req.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h
1040x_req.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h
1041x_req.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
1042x_req.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
1043x_req.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
1044x_req.o: ../../include/openssl/ui_compat.h ../../include/openssl/x509.h
1045x_req.o: ../../include/openssl/x509_vfy.h ../cryptlib.h x_req.c
1046x_sig.o: ../../e_os.h ../../include/openssl/aes.h ../../include/openssl/asn1.h
1047x_sig.o: ../../include/openssl/asn1t.h ../../include/openssl/bio.h
1048x_sig.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
1049x_sig.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
1050x_sig.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
1051x_sig.o: ../../include/openssl/des_old.h ../../include/openssl/dh.h
1052x_sig.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
1053x_sig.o: ../../include/openssl/err.h ../../include/openssl/evp.h
1054x_sig.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h
1055x_sig.o: ../../include/openssl/md2.h ../../include/openssl/md4.h
1056x_sig.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
1057x_sig.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
1058x_sig.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
1059x_sig.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h
1060x_sig.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h
1061x_sig.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h
1062x_sig.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
1063x_sig.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
1064x_sig.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
1065x_sig.o: ../../include/openssl/ui_compat.h ../../include/openssl/x509.h
1066x_sig.o: ../../include/openssl/x509_vfy.h ../cryptlib.h x_sig.c
1067x_spki.o: ../../e_os.h ../../include/openssl/aes.h ../../include/openssl/asn1.h
1068x_spki.o: ../../include/openssl/asn1t.h ../../include/openssl/bio.h
1069x_spki.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
1070x_spki.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
1071x_spki.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
1072x_spki.o: ../../include/openssl/des_old.h ../../include/openssl/dh.h
1073x_spki.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
1074x_spki.o: ../../include/openssl/err.h ../../include/openssl/evp.h
1075x_spki.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h
1076x_spki.o: ../../include/openssl/md2.h ../../include/openssl/md4.h
1077x_spki.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
1078x_spki.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
1079x_spki.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
1080x_spki.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h
1081x_spki.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h
1082x_spki.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h
1083x_spki.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
1084x_spki.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
1085x_spki.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
1086x_spki.o: ../../include/openssl/ui_compat.h ../../include/openssl/x509.h
1087x_spki.o: ../../include/openssl/x509_vfy.h ../cryptlib.h x_spki.c
1088x_val.o: ../../e_os.h ../../include/openssl/aes.h ../../include/openssl/asn1.h
1089x_val.o: ../../include/openssl/asn1t.h ../../include/openssl/bio.h
1090x_val.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
1091x_val.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
1092x_val.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
1093x_val.o: ../../include/openssl/des_old.h ../../include/openssl/dh.h
1094x_val.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
1095x_val.o: ../../include/openssl/err.h ../../include/openssl/evp.h
1096x_val.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h
1097x_val.o: ../../include/openssl/md2.h ../../include/openssl/md4.h
1098x_val.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
1099x_val.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
1100x_val.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
1101x_val.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h
1102x_val.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h
1103x_val.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h
1104x_val.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
1105x_val.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
1106x_val.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
1107x_val.o: ../../include/openssl/ui_compat.h ../../include/openssl/x509.h
1108x_val.o: ../../include/openssl/x509_vfy.h ../cryptlib.h x_val.c
1109x_x509.o: ../../e_os.h ../../include/openssl/aes.h ../../include/openssl/asn1.h
1110x_x509.o: ../../include/openssl/asn1t.h ../../include/openssl/bio.h
1111x_x509.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
1112x_x509.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
1113x_x509.o: ../../include/openssl/conf.h ../../include/openssl/crypto.h
1114x_x509.o: ../../include/openssl/des.h ../../include/openssl/des_old.h
1115x_x509.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
1116x_x509.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
1117x_x509.o: ../../include/openssl/evp.h ../../include/openssl/idea.h
1118x_x509.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h
1119x_x509.o: ../../include/openssl/md4.h ../../include/openssl/md5.h
1120x_x509.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h
1121x_x509.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
1122x_x509.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
1123x_x509.o: ../../include/openssl/pkcs7.h ../../include/openssl/rc2.h
1124x_x509.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
1125x_x509.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
1126x_x509.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
1127x_x509.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
1128x_x509.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
1129x_x509.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
1130x_x509.o: ../../include/openssl/x509v3.h ../cryptlib.h x_x509.c
1131x_x509a.o: ../../e_os.h ../../include/openssl/aes.h
1132x_x509a.o: ../../include/openssl/asn1.h ../../include/openssl/asn1t.h
1133x_x509a.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h
1134x_x509a.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
1135x_x509a.o: ../../include/openssl/cast.h ../../include/openssl/crypto.h
1136x_x509a.o: ../../include/openssl/des.h ../../include/openssl/des_old.h
1137x_x509a.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
1138x_x509a.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
1139x_x509a.o: ../../include/openssl/evp.h ../../include/openssl/idea.h
1140x_x509a.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h
1141x_x509a.o: ../../include/openssl/md4.h ../../include/openssl/md5.h
1142x_x509a.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h
1143x_x509a.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
1144x_x509a.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
1145x_x509a.o: ../../include/openssl/pkcs7.h ../../include/openssl/rc2.h
1146x_x509a.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
1147x_x509a.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
1148x_x509a.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
1149x_x509a.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
1150x_x509a.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
1151x_x509a.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
1152x_x509a.o: ../cryptlib.h x_x509a.c
diff --git a/src/lib/libcrypto/asn1/a_bitstr.c b/src/lib/libcrypto/asn1/a_bitstr.c
index 0fb9ce0c2a..34179960b8 100644
--- a/src/lib/libcrypto/asn1/a_bitstr.c
+++ b/src/lib/libcrypto/asn1/a_bitstr.c
@@ -223,3 +223,26 @@ int ASN1_BIT_STRING_get_bit(ASN1_BIT_STRING *a, int n)
223 return((a->data[w]&v) != 0); 223 return((a->data[w]&v) != 0);
224 } 224 }
225 225
226/*
227 * Checks if the given bit string contains only bits specified by
228 * the flags vector. Returns 0 if there is at least one bit set in 'a'
229 * which is not specified in 'flags', 1 otherwise.
230 * 'len' is the length of 'flags'.
231 */
232int ASN1_BIT_STRING_check(ASN1_BIT_STRING *a,
233 unsigned char *flags, int flags_len)
234 {
235 int i, ok;
236 /* Check if there is one bit set at all. */
237 if (!a || !a->data) return 1;
238
239 /* Check each byte of the internal representation of the bit string. */
240 ok = 1;
241 for (i = 0; i < a->length && ok; ++i)
242 {
243 unsigned char mask = i < flags_len ? ~flags[i] : 0xff;
244 /* We are done if there is an unneeded bit set. */
245 ok = (a->data[i] & mask) == 0;
246 }
247 return ok;
248 }
diff --git a/src/lib/libcrypto/asn1/a_dup.c b/src/lib/libcrypto/asn1/a_dup.c
index 199d50f521..d98992548a 100644
--- a/src/lib/libcrypto/asn1/a_dup.c
+++ b/src/lib/libcrypto/asn1/a_dup.c
@@ -62,7 +62,7 @@
62 62
63#ifndef NO_OLD_ASN1 63#ifndef NO_OLD_ASN1
64 64
65void *ASN1_dup(i2d_of_void *i2d, d2i_of_void *d2i, char *x) 65void *ASN1_dup(i2d_of_void *i2d, d2i_of_void *d2i, void *x)
66 { 66 {
67 unsigned char *b,*p; 67 unsigned char *b,*p;
68 const unsigned char *p2; 68 const unsigned char *p2;
diff --git a/src/lib/libcrypto/asn1/a_gentm.c b/src/lib/libcrypto/asn1/a_gentm.c
index def79062a5..c79c6f538c 100644
--- a/src/lib/libcrypto/asn1/a_gentm.c
+++ b/src/lib/libcrypto/asn1/a_gentm.c
@@ -117,8 +117,8 @@ err:
117 117
118int ASN1_GENERALIZEDTIME_check(ASN1_GENERALIZEDTIME *d) 118int ASN1_GENERALIZEDTIME_check(ASN1_GENERALIZEDTIME *d)
119 { 119 {
120 static int min[9]={ 0, 0, 1, 1, 0, 0, 0, 0, 0}; 120 static const int min[9]={ 0, 0, 1, 1, 0, 0, 0, 0, 0};
121 static int max[9]={99, 99,12,31,23,59,59,12,59}; 121 static const int max[9]={99, 99,12,31,23,59,59,12,59};
122 char *a; 122 char *a;
123 int n,i,l,o; 123 int n,i,l,o;
124 124
@@ -176,6 +176,11 @@ int ASN1_GENERALIZEDTIME_check(ASN1_GENERALIZEDTIME *d)
176 o++; 176 o++;
177 } 177 }
178 } 178 }
179 else
180 {
181 /* Missing time zone information. */
182 goto err;
183 }
179 return(o == l); 184 return(o == l);
180err: 185err:
181 return(0); 186 return(0);
@@ -206,6 +211,12 @@ int ASN1_GENERALIZEDTIME_set_string(ASN1_GENERALIZEDTIME *s, const char *str)
206ASN1_GENERALIZEDTIME *ASN1_GENERALIZEDTIME_set(ASN1_GENERALIZEDTIME *s, 211ASN1_GENERALIZEDTIME *ASN1_GENERALIZEDTIME_set(ASN1_GENERALIZEDTIME *s,
207 time_t t) 212 time_t t)
208 { 213 {
214 return ASN1_GENERALIZEDTIME_adj(s, t, 0, 0);
215 }
216
217ASN1_GENERALIZEDTIME *ASN1_GENERALIZEDTIME_adj(ASN1_GENERALIZEDTIME *s,
218 time_t t, int offset_day, long offset_sec)
219 {
209 char *p; 220 char *p;
210 struct tm *ts; 221 struct tm *ts;
211 struct tm data; 222 struct tm data;
@@ -220,13 +231,19 @@ ASN1_GENERALIZEDTIME *ASN1_GENERALIZEDTIME_set(ASN1_GENERALIZEDTIME *s,
220 if (ts == NULL) 231 if (ts == NULL)
221 return(NULL); 232 return(NULL);
222 233
234 if (offset_day || offset_sec)
235 {
236 if (!OPENSSL_gmtime_adj(ts, offset_day, offset_sec))
237 return NULL;
238 }
239
223 p=(char *)s->data; 240 p=(char *)s->data;
224 if ((p == NULL) || ((size_t)s->length < len)) 241 if ((p == NULL) || ((size_t)s->length < len))
225 { 242 {
226 p=OPENSSL_malloc(len); 243 p=OPENSSL_malloc(len);
227 if (p == NULL) 244 if (p == NULL)
228 { 245 {
229 ASN1err(ASN1_F_ASN1_GENERALIZEDTIME_SET, 246 ASN1err(ASN1_F_ASN1_GENERALIZEDTIME_ADJ,
230 ERR_R_MALLOC_FAILURE); 247 ERR_R_MALLOC_FAILURE);
231 return(NULL); 248 return(NULL);
232 } 249 }
diff --git a/src/lib/libcrypto/asn1/a_hdr.c b/src/lib/libcrypto/asn1/a_hdr.c
deleted file mode 100644
index d1c2a7b9e3..0000000000
--- a/src/lib/libcrypto/asn1/a_hdr.c
+++ /dev/null
@@ -1,119 +0,0 @@
1/* crypto/asn1/a_hdr.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 "cryptlib.h"
61#include <openssl/asn1_mac.h>
62#include <openssl/asn1.h>
63
64int i2d_ASN1_HEADER(ASN1_HEADER *a, unsigned char **pp)
65 {
66 M_ASN1_I2D_vars(a);
67
68 M_ASN1_I2D_len(a->header, i2d_ASN1_OCTET_STRING);
69 M_ASN1_I2D_len(a->data, a->meth->i2d);
70
71 M_ASN1_I2D_seq_total();
72
73 M_ASN1_I2D_put(a->header, i2d_ASN1_OCTET_STRING);
74 M_ASN1_I2D_put(a->data, a->meth->i2d);
75
76 M_ASN1_I2D_finish();
77 }
78
79ASN1_HEADER *d2i_ASN1_HEADER(ASN1_HEADER **a, const unsigned char **pp,
80 long length)
81 {
82 M_ASN1_D2I_vars(a,ASN1_HEADER *,ASN1_HEADER_new);
83
84 M_ASN1_D2I_Init();
85 M_ASN1_D2I_start_sequence();
86 M_ASN1_D2I_get_x(ASN1_OCTET_STRING,ret->header,d2i_ASN1_OCTET_STRING);
87 if (ret->meth != NULL)
88 {
89 M_ASN1_D2I_get_x(void,ret->data,ret->meth->d2i);
90 }
91 else
92 {
93 if (a != NULL) (*a)=ret;
94 return(ret);
95 }
96 M_ASN1_D2I_Finish(a,ASN1_HEADER_free,ASN1_F_D2I_ASN1_HEADER);
97 }
98
99ASN1_HEADER *ASN1_HEADER_new(void)
100 {
101 ASN1_HEADER *ret=NULL;
102 ASN1_CTX c;
103
104 M_ASN1_New_Malloc(ret,ASN1_HEADER);
105 M_ASN1_New(ret->header,M_ASN1_OCTET_STRING_new);
106 ret->meth=NULL;
107 ret->data=NULL;
108 return(ret);
109 M_ASN1_New_Error(ASN1_F_ASN1_HEADER_NEW);
110 }
111
112void ASN1_HEADER_free(ASN1_HEADER *a)
113 {
114 if (a == NULL) return;
115 M_ASN1_OCTET_STRING_free(a->header);
116 if (a->meth != NULL)
117 a->meth->destroy(a->data);
118 OPENSSL_free(a);
119 }
diff --git a/src/lib/libcrypto/asn1/a_int.c b/src/lib/libcrypto/asn1/a_int.c
index f8d198efb1..c6fd204ae3 100644
--- a/src/lib/libcrypto/asn1/a_int.c
+++ b/src/lib/libcrypto/asn1/a_int.c
@@ -61,10 +61,10 @@
61#include <openssl/asn1.h> 61#include <openssl/asn1.h>
62#include <openssl/bn.h> 62#include <openssl/bn.h>
63 63
64ASN1_INTEGER *ASN1_INTEGER_dup(ASN1_INTEGER *x) 64ASN1_INTEGER *ASN1_INTEGER_dup(const ASN1_INTEGER *x)
65{ return M_ASN1_INTEGER_dup(x);} 65{ return M_ASN1_INTEGER_dup(x);}
66 66
67int ASN1_INTEGER_cmp(ASN1_INTEGER *x, ASN1_INTEGER *y) 67int ASN1_INTEGER_cmp(const ASN1_INTEGER *x, const ASN1_INTEGER *y)
68 { 68 {
69 int neg, ret; 69 int neg, ret;
70 /* Compare signs */ 70 /* Compare signs */
@@ -373,7 +373,7 @@ int ASN1_INTEGER_set(ASN1_INTEGER *a, long v)
373 return(1); 373 return(1);
374 } 374 }
375 375
376long ASN1_INTEGER_get(ASN1_INTEGER *a) 376long ASN1_INTEGER_get(const ASN1_INTEGER *a)
377 { 377 {
378 int neg=0,i; 378 int neg=0,i;
379 long r=0; 379 long r=0;
@@ -402,7 +402,7 @@ long ASN1_INTEGER_get(ASN1_INTEGER *a)
402 return(r); 402 return(r);
403 } 403 }
404 404
405ASN1_INTEGER *BN_to_ASN1_INTEGER(BIGNUM *bn, ASN1_INTEGER *ai) 405ASN1_INTEGER *BN_to_ASN1_INTEGER(const BIGNUM *bn, ASN1_INTEGER *ai)
406 { 406 {
407 ASN1_INTEGER *ret; 407 ASN1_INTEGER *ret;
408 int len,j; 408 int len,j;
@@ -444,7 +444,7 @@ err:
444 return(NULL); 444 return(NULL);
445 } 445 }
446 446
447BIGNUM *ASN1_INTEGER_to_BN(ASN1_INTEGER *ai, BIGNUM *bn) 447BIGNUM *ASN1_INTEGER_to_BN(const ASN1_INTEGER *ai, BIGNUM *bn)
448 { 448 {
449 BIGNUM *ret; 449 BIGNUM *ret;
450 450
diff --git a/src/lib/libcrypto/asn1/a_mbstr.c b/src/lib/libcrypto/asn1/a_mbstr.c
index 1bcd046893..1538e0a4fc 100644
--- a/src/lib/libcrypto/asn1/a_mbstr.c
+++ b/src/lib/libcrypto/asn1/a_mbstr.c
@@ -93,7 +93,7 @@ int ASN1_mbstring_ncopy(ASN1_STRING **out, const unsigned char *in, int len,
93 int str_type; 93 int str_type;
94 int ret; 94 int ret;
95 char free_out; 95 char free_out;
96 int outform, outlen; 96 int outform, outlen = 0;
97 ASN1_STRING *dest; 97 ASN1_STRING *dest;
98 unsigned char *p; 98 unsigned char *p;
99 int nchar; 99 int nchar;
diff --git a/src/lib/libcrypto/asn1/a_meth.c b/src/lib/libcrypto/asn1/a_meth.c
deleted file mode 100644
index 50bea917e3..0000000000
--- a/src/lib/libcrypto/asn1/a_meth.c
+++ /dev/null
@@ -1,84 +0,0 @@
1/* crypto/asn1/a_meth.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 "cryptlib.h"
61#include <openssl/buffer.h>
62#include <openssl/asn1.h>
63
64static ASN1_METHOD ia5string_meth={
65 (I2D_OF(void)) i2d_ASN1_IA5STRING,
66 (D2I_OF(void)) d2i_ASN1_IA5STRING,
67 (void *(*)(void))ASN1_STRING_new,
68 (void (*)(void *))ASN1_STRING_free};
69
70static ASN1_METHOD bit_string_meth={
71 (I2D_OF(void)) i2d_ASN1_BIT_STRING,
72 (D2I_OF(void)) d2i_ASN1_BIT_STRING,
73 (void *(*)(void))ASN1_STRING_new,
74 (void (*)(void *))ASN1_STRING_free};
75
76ASN1_METHOD *ASN1_IA5STRING_asn1_meth(void)
77 {
78 return(&ia5string_meth);
79 }
80
81ASN1_METHOD *ASN1_BIT_STRING_asn1_meth(void)
82 {
83 return(&bit_string_meth);
84 }
diff --git a/src/lib/libcrypto/asn1/a_object.c b/src/lib/libcrypto/asn1/a_object.c
index dc980421d0..e5fbe7cbb1 100644
--- a/src/lib/libcrypto/asn1/a_object.c
+++ b/src/lib/libcrypto/asn1/a_object.c
@@ -281,8 +281,6 @@ ASN1_OBJECT *d2i_ASN1_OBJECT(ASN1_OBJECT **a, const unsigned char **pp,
281 return ret; 281 return ret;
282err: 282err:
283 ASN1err(ASN1_F_D2I_ASN1_OBJECT,i); 283 ASN1err(ASN1_F_D2I_ASN1_OBJECT,i);
284 if ((ret != NULL) && ((a == NULL) || (*a != ret)))
285 ASN1_OBJECT_free(ret);
286 return(NULL); 284 return(NULL);
287} 285}
288ASN1_OBJECT *c2i_ASN1_OBJECT(ASN1_OBJECT **a, const unsigned char **pp, 286ASN1_OBJECT *c2i_ASN1_OBJECT(ASN1_OBJECT **a, const unsigned char **pp,
@@ -290,7 +288,19 @@ ASN1_OBJECT *c2i_ASN1_OBJECT(ASN1_OBJECT **a, const unsigned char **pp,
290 { 288 {
291 ASN1_OBJECT *ret=NULL; 289 ASN1_OBJECT *ret=NULL;
292 const unsigned char *p; 290 const unsigned char *p;
291 unsigned char *data;
293 int i; 292 int i;
293 /* Sanity check OID encoding: can't have leading 0x80 in
294 * subidentifiers, see: X.690 8.19.2
295 */
296 for (i = 0, p = *pp + 1; i < len - 1; i++, p++)
297 {
298 if (*p == 0x80 && (!i || !(p[-1] & 0x80)))
299 {
300 ASN1err(ASN1_F_C2I_ASN1_OBJECT,ASN1_R_INVALID_OBJECT_ENCODING);
301 return NULL;
302 }
303 }
294 304
295 /* only the ASN1_OBJECTs from the 'table' will have values 305 /* only the ASN1_OBJECTs from the 'table' will have values
296 * for ->sn or ->ln */ 306 * for ->sn or ->ln */
@@ -302,15 +312,22 @@ ASN1_OBJECT *c2i_ASN1_OBJECT(ASN1_OBJECT **a, const unsigned char **pp,
302 else ret=(*a); 312 else ret=(*a);
303 313
304 p= *pp; 314 p= *pp;
305 if ((ret->data == NULL) || (ret->length < len)) 315 /* detach data from object */
316 data = (unsigned char *)ret->data;
317 ret->data = NULL;
318 /* once detached we can change it */
319 if ((data == NULL) || (ret->length < len))
306 { 320 {
307 if (ret->data != NULL) OPENSSL_free(ret->data); 321 ret->length=0;
308 ret->data=(unsigned char *)OPENSSL_malloc(len ? (int)len : 1); 322 if (data != NULL) OPENSSL_free(data);
309 ret->flags|=ASN1_OBJECT_FLAG_DYNAMIC_DATA; 323 data=(unsigned char *)OPENSSL_malloc(len ? (int)len : 1);
310 if (ret->data == NULL) 324 if (data == NULL)
311 { i=ERR_R_MALLOC_FAILURE; goto err; } 325 { i=ERR_R_MALLOC_FAILURE; goto err; }
326 ret->flags|=ASN1_OBJECT_FLAG_DYNAMIC_DATA;
312 } 327 }
313 memcpy(ret->data,p,(int)len); 328 memcpy(data,p,(int)len);
329 /* reattach data to object, after which it remains const */
330 ret->data =data;
314 ret->length=(int)len; 331 ret->length=(int)len;
315 ret->sn=NULL; 332 ret->sn=NULL;
316 ret->ln=NULL; 333 ret->ln=NULL;
@@ -359,7 +376,7 @@ void ASN1_OBJECT_free(ASN1_OBJECT *a)
359 } 376 }
360 if (a->flags & ASN1_OBJECT_FLAG_DYNAMIC_DATA) 377 if (a->flags & ASN1_OBJECT_FLAG_DYNAMIC_DATA)
361 { 378 {
362 if (a->data != NULL) OPENSSL_free(a->data); 379 if (a->data != NULL) OPENSSL_free((void *)a->data);
363 a->data=NULL; 380 a->data=NULL;
364 a->length=0; 381 a->length=0;
365 } 382 }
diff --git a/src/lib/libcrypto/asn1/a_octet.c b/src/lib/libcrypto/asn1/a_octet.c
index 24fd0f8e5a..e8725e44f1 100644
--- a/src/lib/libcrypto/asn1/a_octet.c
+++ b/src/lib/libcrypto/asn1/a_octet.c
@@ -60,10 +60,10 @@
60#include "cryptlib.h" 60#include "cryptlib.h"
61#include <openssl/asn1.h> 61#include <openssl/asn1.h>
62 62
63ASN1_OCTET_STRING *ASN1_OCTET_STRING_dup(ASN1_OCTET_STRING *x) 63ASN1_OCTET_STRING *ASN1_OCTET_STRING_dup(const ASN1_OCTET_STRING *x)
64{ return M_ASN1_OCTET_STRING_dup(x); } 64{ return M_ASN1_OCTET_STRING_dup(x); }
65 65
66int ASN1_OCTET_STRING_cmp(ASN1_OCTET_STRING *a, ASN1_OCTET_STRING *b) 66int ASN1_OCTET_STRING_cmp(const ASN1_OCTET_STRING *a, const ASN1_OCTET_STRING *b)
67{ return M_ASN1_OCTET_STRING_cmp(a, b); } 67{ return M_ASN1_OCTET_STRING_cmp(a, b); }
68 68
69int ASN1_OCTET_STRING_set(ASN1_OCTET_STRING *x, const unsigned char *d, int len) 69int ASN1_OCTET_STRING_set(ASN1_OCTET_STRING *x, const unsigned char *d, int len)
diff --git a/src/lib/libcrypto/asn1/a_set.c b/src/lib/libcrypto/asn1/a_set.c
index 958558c204..d726c8d3a8 100644
--- a/src/lib/libcrypto/asn1/a_set.c
+++ b/src/lib/libcrypto/asn1/a_set.c
@@ -85,8 +85,9 @@ static int SetBlobCmp(const void *elem1, const void *elem2 )
85 } 85 }
86 86
87/* int is_set: if TRUE, then sort the contents (i.e. it isn't a SEQUENCE) */ 87/* int is_set: if TRUE, then sort the contents (i.e. it isn't a SEQUENCE) */
88int i2d_ASN1_SET(STACK *a, unsigned char **pp, i2d_of_void *i2d, int ex_tag, 88int i2d_ASN1_SET(STACK_OF(OPENSSL_BLOCK) *a, unsigned char **pp,
89 int ex_class, int is_set) 89 i2d_of_void *i2d, int ex_tag, int ex_class,
90 int is_set)
90 { 91 {
91 int ret=0,r; 92 int ret=0,r;
92 int i; 93 int i;
@@ -96,8 +97,8 @@ int i2d_ASN1_SET(STACK *a, unsigned char **pp, i2d_of_void *i2d, int ex_tag,
96 int totSize; 97 int totSize;
97 98
98 if (a == NULL) return(0); 99 if (a == NULL) return(0);
99 for (i=sk_num(a)-1; i>=0; i--) 100 for (i=sk_OPENSSL_BLOCK_num(a)-1; i>=0; i--)
100 ret+=i2d(sk_value(a,i),NULL); 101 ret+=i2d(sk_OPENSSL_BLOCK_value(a,i),NULL);
101 r=ASN1_object_size(1,ret,ex_tag); 102 r=ASN1_object_size(1,ret,ex_tag);
102 if (pp == NULL) return(r); 103 if (pp == NULL) return(r);
103 104
@@ -108,10 +109,10 @@ int i2d_ASN1_SET(STACK *a, unsigned char **pp, i2d_of_void *i2d, int ex_tag,
108 /* And then again by Ben */ 109 /* And then again by Ben */
109 /* And again by Steve */ 110 /* And again by Steve */
110 111
111 if(!is_set || (sk_num(a) < 2)) 112 if(!is_set || (sk_OPENSSL_BLOCK_num(a) < 2))
112 { 113 {
113 for (i=0; i<sk_num(a); i++) 114 for (i=0; i<sk_OPENSSL_BLOCK_num(a); i++)
114 i2d(sk_value(a,i),&p); 115 i2d(sk_OPENSSL_BLOCK_value(a,i),&p);
115 116
116 *pp=p; 117 *pp=p;
117 return(r); 118 return(r);
@@ -119,17 +120,17 @@ int i2d_ASN1_SET(STACK *a, unsigned char **pp, i2d_of_void *i2d, int ex_tag,
119 120
120 pStart = p; /* Catch the beg of Setblobs*/ 121 pStart = p; /* Catch the beg of Setblobs*/
121 /* In this array we will store the SET blobs */ 122 /* In this array we will store the SET blobs */
122 rgSetBlob = (MYBLOB *)OPENSSL_malloc(sk_num(a) * sizeof(MYBLOB)); 123 rgSetBlob = OPENSSL_malloc(sk_OPENSSL_BLOCK_num(a) * sizeof(MYBLOB));
123 if (rgSetBlob == NULL) 124 if (rgSetBlob == NULL)
124 { 125 {
125 ASN1err(ASN1_F_I2D_ASN1_SET,ERR_R_MALLOC_FAILURE); 126 ASN1err(ASN1_F_I2D_ASN1_SET,ERR_R_MALLOC_FAILURE);
126 return(0); 127 return(0);
127 } 128 }
128 129
129 for (i=0; i<sk_num(a); i++) 130 for (i=0; i<sk_OPENSSL_BLOCK_num(a); i++)
130 { 131 {
131 rgSetBlob[i].pbData = p; /* catch each set encode blob */ 132 rgSetBlob[i].pbData = p; /* catch each set encode blob */
132 i2d(sk_value(a,i),&p); 133 i2d(sk_OPENSSL_BLOCK_value(a,i),&p);
133 rgSetBlob[i].cbData = p - rgSetBlob[i].pbData; /* Length of this 134 rgSetBlob[i].cbData = p - rgSetBlob[i].pbData; /* Length of this
134SetBlob 135SetBlob
135*/ 136*/
@@ -139,7 +140,7 @@ SetBlob
139 140
140 /* Now we have to sort the blobs. I am using a simple algo. 141 /* Now we have to sort the blobs. I am using a simple algo.
141 *Sort ptrs *Copy to temp-mem *Copy from temp-mem to user-mem*/ 142 *Sort ptrs *Copy to temp-mem *Copy from temp-mem to user-mem*/
142 qsort( rgSetBlob, sk_num(a), sizeof(MYBLOB), SetBlobCmp); 143 qsort( rgSetBlob, sk_OPENSSL_BLOCK_num(a), sizeof(MYBLOB), SetBlobCmp);
143 if (!(pTempMem = OPENSSL_malloc(totSize))) 144 if (!(pTempMem = OPENSSL_malloc(totSize)))
144 { 145 {
145 ASN1err(ASN1_F_I2D_ASN1_SET,ERR_R_MALLOC_FAILURE); 146 ASN1err(ASN1_F_I2D_ASN1_SET,ERR_R_MALLOC_FAILURE);
@@ -148,7 +149,7 @@ SetBlob
148 149
149/* Copy to temp mem */ 150/* Copy to temp mem */
150 p = pTempMem; 151 p = pTempMem;
151 for(i=0; i<sk_num(a); ++i) 152 for(i=0; i<sk_OPENSSL_BLOCK_num(a); ++i)
152 { 153 {
153 memcpy(p, rgSetBlob[i].pbData, rgSetBlob[i].cbData); 154 memcpy(p, rgSetBlob[i].pbData, rgSetBlob[i].cbData);
154 p += rgSetBlob[i].cbData; 155 p += rgSetBlob[i].cbData;
@@ -162,16 +163,18 @@ SetBlob
162 return(r); 163 return(r);
163 } 164 }
164 165
165STACK *d2i_ASN1_SET(STACK **a, const unsigned char **pp, long length, 166STACK_OF(OPENSSL_BLOCK) *d2i_ASN1_SET(STACK_OF(OPENSSL_BLOCK) **a,
166 d2i_of_void *d2i, void (*free_func)(void *), int ex_tag, 167 const unsigned char **pp,
167 int ex_class) 168 long length, d2i_of_void *d2i,
169 void (*free_func)(OPENSSL_BLOCK), int ex_tag,
170 int ex_class)
168 { 171 {
169 ASN1_const_CTX c; 172 ASN1_const_CTX c;
170 STACK *ret=NULL; 173 STACK_OF(OPENSSL_BLOCK) *ret=NULL;
171 174
172 if ((a == NULL) || ((*a) == NULL)) 175 if ((a == NULL) || ((*a) == NULL))
173 { 176 {
174 if ((ret=sk_new_null()) == NULL) 177 if ((ret=sk_OPENSSL_BLOCK_new_null()) == NULL)
175 { 178 {
176 ASN1err(ASN1_F_D2I_ASN1_SET,ERR_R_MALLOC_FAILURE); 179 ASN1err(ASN1_F_D2I_ASN1_SET,ERR_R_MALLOC_FAILURE);
177 goto err; 180 goto err;
@@ -216,10 +219,10 @@ STACK *d2i_ASN1_SET(STACK **a, const unsigned char **pp, long length,
216 if ((s=d2i(NULL,&c.p,c.slen)) == NULL) 219 if ((s=d2i(NULL,&c.p,c.slen)) == NULL)
217 { 220 {
218 ASN1err(ASN1_F_D2I_ASN1_SET,ASN1_R_ERROR_PARSING_SET_ELEMENT); 221 ASN1err(ASN1_F_D2I_ASN1_SET,ASN1_R_ERROR_PARSING_SET_ELEMENT);
219 asn1_add_error(*pp,(int)(c.q- *pp)); 222 asn1_add_error(*pp,(int)(c.p- *pp));
220 goto err; 223 goto err;
221 } 224 }
222 if (!sk_push(ret,s)) goto err; 225 if (!sk_OPENSSL_BLOCK_push(ret,s)) goto err;
223 } 226 }
224 if (a != NULL) (*a)=ret; 227 if (a != NULL) (*a)=ret;
225 *pp=c.p; 228 *pp=c.p;
@@ -228,9 +231,9 @@ err:
228 if ((ret != NULL) && ((a == NULL) || (*a != ret))) 231 if ((ret != NULL) && ((a == NULL) || (*a != ret)))
229 { 232 {
230 if (free_func != NULL) 233 if (free_func != NULL)
231 sk_pop_free(ret,free_func); 234 sk_OPENSSL_BLOCK_pop_free(ret,free_func);
232 else 235 else
233 sk_free(ret); 236 sk_OPENSSL_BLOCK_free(ret);
234 } 237 }
235 return(NULL); 238 return(NULL);
236 } 239 }
diff --git a/src/lib/libcrypto/asn1/a_sign.c b/src/lib/libcrypto/asn1/a_sign.c
index 4dee45fbb8..ff63bfc7be 100644
--- a/src/lib/libcrypto/asn1/a_sign.c
+++ b/src/lib/libcrypto/asn1/a_sign.c
@@ -123,6 +123,7 @@
123#include <openssl/x509.h> 123#include <openssl/x509.h>
124#include <openssl/objects.h> 124#include <openssl/objects.h>
125#include <openssl/buffer.h> 125#include <openssl/buffer.h>
126#include "asn1_locl.h"
126 127
127#ifndef NO_ASN1_OLD 128#ifndef NO_ASN1_OLD
128 129
@@ -218,45 +219,47 @@ int ASN1_item_sign(const ASN1_ITEM *it, X509_ALGOR *algor1, X509_ALGOR *algor2,
218 { 219 {
219 EVP_MD_CTX ctx; 220 EVP_MD_CTX ctx;
220 unsigned char *buf_in=NULL,*buf_out=NULL; 221 unsigned char *buf_in=NULL,*buf_out=NULL;
221 int i,inl=0,outl=0,outll=0; 222 int inl=0,outl=0,outll=0;
222 X509_ALGOR *a; 223 int signid, paramtype;
223 224
224 EVP_MD_CTX_init(&ctx); 225 if (type == NULL)
225 for (i=0; i<2; i++)
226 { 226 {
227 if (i == 0) 227 int def_nid;
228 a=algor1; 228 if (EVP_PKEY_get_default_digest_nid(pkey, &def_nid) > 0)
229 else 229 type = EVP_get_digestbynid(def_nid);
230 a=algor2; 230 }
231 if (a == NULL) continue; 231
232 if (type->pkey_type == NID_dsaWithSHA1 || 232 if (type == NULL)
233 type->pkey_type == NID_ecdsa_with_SHA1) 233 {
234 { 234 ASN1err(ASN1_F_ASN1_ITEM_SIGN, ASN1_R_NO_DEFAULT_DIGEST);
235 /* special case: RFC 3279 tells us to omit 'parameters' 235 return 0;
236 * with id-dsa-with-sha1 and ecdsa-with-SHA1 */ 236 }
237 ASN1_TYPE_free(a->parameter); 237
238 a->parameter = NULL; 238 if (type->flags & EVP_MD_FLAG_PKEY_METHOD_SIGNATURE)
239 } 239 {
240 else if ((a->parameter == NULL) || 240 if (!pkey->ameth ||
241 (a->parameter->type != V_ASN1_NULL)) 241 !OBJ_find_sigid_by_algs(&signid, EVP_MD_nid(type),
242 { 242 pkey->ameth->pkey_id))
243 ASN1_TYPE_free(a->parameter);
244 if ((a->parameter=ASN1_TYPE_new()) == NULL) goto err;
245 a->parameter->type=V_ASN1_NULL;
246 }
247 ASN1_OBJECT_free(a->algorithm);
248 a->algorithm=OBJ_nid2obj(type->pkey_type);
249 if (a->algorithm == NULL)
250 {
251 ASN1err(ASN1_F_ASN1_ITEM_SIGN,ASN1_R_UNKNOWN_OBJECT_TYPE);
252 goto err;
253 }
254 if (a->algorithm->length == 0)
255 { 243 {
256 ASN1err(ASN1_F_ASN1_ITEM_SIGN,ASN1_R_THE_ASN1_OBJECT_IDENTIFIER_IS_NOT_KNOWN_FOR_THIS_MD); 244 ASN1err(ASN1_F_ASN1_ITEM_SIGN,
257 goto err; 245 ASN1_R_DIGEST_AND_KEY_TYPE_NOT_SUPPORTED);
246 return 0;
258 } 247 }
259 } 248 }
249 else
250 signid = type->pkey_type;
251
252 if (pkey->ameth->pkey_flags & ASN1_PKEY_SIGPARAM_NULL)
253 paramtype = V_ASN1_NULL;
254 else
255 paramtype = V_ASN1_UNDEF;
256
257 if (algor1)
258 X509_ALGOR_set0(algor1, OBJ_nid2obj(signid), paramtype, NULL);
259 if (algor2)
260 X509_ALGOR_set0(algor2, OBJ_nid2obj(signid), paramtype, NULL);
261
262 EVP_MD_CTX_init(&ctx);
260 inl=ASN1_item_i2d(asn,&buf_in, it); 263 inl=ASN1_item_i2d(asn,&buf_in, it);
261 outll=outl=EVP_PKEY_size(pkey); 264 outll=outl=EVP_PKEY_size(pkey);
262 buf_out=(unsigned char *)OPENSSL_malloc((unsigned int)outl); 265 buf_out=(unsigned char *)OPENSSL_malloc((unsigned int)outl);
@@ -267,12 +270,7 @@ int ASN1_item_sign(const ASN1_ITEM *it, X509_ALGOR *algor1, X509_ALGOR *algor2,
267 goto err; 270 goto err;
268 } 271 }
269 272
270 if (!EVP_SignInit_ex(&ctx,type, NULL)) 273 EVP_SignInit_ex(&ctx,type, NULL);
271 {
272 outl=0;
273 ASN1err(ASN1_F_ASN1_ITEM_SIGN,ERR_R_EVP_LIB);
274 goto err;
275 }
276 EVP_SignUpdate(&ctx,(unsigned char *)buf_in,inl); 274 EVP_SignUpdate(&ctx,(unsigned char *)buf_in,inl);
277 if (!EVP_SignFinal(&ctx,(unsigned char *)buf_out, 275 if (!EVP_SignFinal(&ctx,(unsigned char *)buf_out,
278 (unsigned int *)&outl,pkey)) 276 (unsigned int *)&outl,pkey))
diff --git a/src/lib/libcrypto/asn1/a_strnid.c b/src/lib/libcrypto/asn1/a_strnid.c
index fe515b52ba..753021a7a2 100644
--- a/src/lib/libcrypto/asn1/a_strnid.c
+++ b/src/lib/libcrypto/asn1/a_strnid.c
@@ -67,7 +67,6 @@ static STACK_OF(ASN1_STRING_TABLE) *stable = NULL;
67static void st_free(ASN1_STRING_TABLE *tbl); 67static void st_free(ASN1_STRING_TABLE *tbl);
68static int sk_table_cmp(const ASN1_STRING_TABLE * const *a, 68static int sk_table_cmp(const ASN1_STRING_TABLE * const *a,
69 const ASN1_STRING_TABLE * const *b); 69 const ASN1_STRING_TABLE * const *b);
70static int table_cmp(const void *a, const void *b);
71 70
72 71
73/* This is the global mask for the mbstring functions: this is use to 72/* This is the global mask for the mbstring functions: this is use to
@@ -158,7 +157,7 @@ ASN1_STRING *ASN1_STRING_set_by_NID(ASN1_STRING **out, const unsigned char *in,
158 157
159/* This table must be kept in NID order */ 158/* This table must be kept in NID order */
160 159
161static ASN1_STRING_TABLE tbl_standard[] = { 160static const ASN1_STRING_TABLE tbl_standard[] = {
162{NID_commonName, 1, ub_common_name, DIRSTRING_TYPE, 0}, 161{NID_commonName, 1, ub_common_name, DIRSTRING_TYPE, 0},
163{NID_countryName, 2, 2, B_ASN1_PRINTABLESTRING, STABLE_NO_MASK}, 162{NID_countryName, 2, 2, B_ASN1_PRINTABLESTRING, STABLE_NO_MASK},
164{NID_localityName, 1, ub_locality_name, DIRSTRING_TYPE, 0}, 163{NID_localityName, 1, ub_locality_name, DIRSTRING_TYPE, 0},
@@ -186,22 +185,23 @@ static int sk_table_cmp(const ASN1_STRING_TABLE * const *a,
186 return (*a)->nid - (*b)->nid; 185 return (*a)->nid - (*b)->nid;
187} 186}
188 187
189static int table_cmp(const void *a, const void *b) 188DECLARE_OBJ_BSEARCH_CMP_FN(ASN1_STRING_TABLE, ASN1_STRING_TABLE, table);
189
190static int table_cmp(const ASN1_STRING_TABLE *a, const ASN1_STRING_TABLE *b)
190{ 191{
191 const ASN1_STRING_TABLE *sa = a, *sb = b; 192 return a->nid - b->nid;
192 return sa->nid - sb->nid;
193} 193}
194 194
195IMPLEMENT_OBJ_BSEARCH_CMP_FN(ASN1_STRING_TABLE, ASN1_STRING_TABLE, table);
196
195ASN1_STRING_TABLE *ASN1_STRING_TABLE_get(int nid) 197ASN1_STRING_TABLE *ASN1_STRING_TABLE_get(int nid)
196{ 198{
197 int idx; 199 int idx;
198 ASN1_STRING_TABLE *ttmp; 200 ASN1_STRING_TABLE *ttmp;
199 ASN1_STRING_TABLE fnd; 201 ASN1_STRING_TABLE fnd;
200 fnd.nid = nid; 202 fnd.nid = nid;
201 ttmp = (ASN1_STRING_TABLE *) OBJ_bsearch((char *)&fnd, 203 ttmp = OBJ_bsearch_table(&fnd, tbl_standard,
202 (char *)tbl_standard, 204 sizeof(tbl_standard)/sizeof(ASN1_STRING_TABLE));
203 sizeof(tbl_standard)/sizeof(ASN1_STRING_TABLE),
204 sizeof(ASN1_STRING_TABLE), table_cmp);
205 if(ttmp) return ttmp; 205 if(ttmp) return ttmp;
206 if(!stable) return NULL; 206 if(!stable) return NULL;
207 idx = sk_ASN1_STRING_TABLE_find(stable, &fnd); 207 idx = sk_ASN1_STRING_TABLE_find(stable, &fnd);
diff --git a/src/lib/libcrypto/asn1/a_time.c b/src/lib/libcrypto/asn1/a_time.c
index 159681fbcb..e2eb9b243e 100644
--- a/src/lib/libcrypto/asn1/a_time.c
+++ b/src/lib/libcrypto/asn1/a_time.c
@@ -100,18 +100,29 @@ int i2d_ASN1_TIME(ASN1_TIME *a, unsigned char **pp)
100 100
101ASN1_TIME *ASN1_TIME_set(ASN1_TIME *s, time_t t) 101ASN1_TIME *ASN1_TIME_set(ASN1_TIME *s, time_t t)
102 { 102 {
103 return ASN1_TIME_adj(s, t, 0, 0);
104 }
105
106ASN1_TIME *ASN1_TIME_adj(ASN1_TIME *s, time_t t,
107 int offset_day, long offset_sec)
108 {
103 struct tm *ts; 109 struct tm *ts;
104 struct tm data; 110 struct tm data;
105 111
106 ts=OPENSSL_gmtime(&t,&data); 112 ts=OPENSSL_gmtime(&t,&data);
107 if (ts == NULL) 113 if (ts == NULL)
108 { 114 {
109 ASN1err(ASN1_F_ASN1_TIME_SET, ASN1_R_ERROR_GETTING_TIME); 115 ASN1err(ASN1_F_ASN1_TIME_ADJ, ASN1_R_ERROR_GETTING_TIME);
110 return NULL; 116 return NULL;
111 } 117 }
118 if (offset_day || offset_sec)
119 {
120 if (!OPENSSL_gmtime_adj(ts, offset_day, offset_sec))
121 return NULL;
122 }
112 if((ts->tm_year >= 50) && (ts->tm_year < 150)) 123 if((ts->tm_year >= 50) && (ts->tm_year < 150))
113 return ASN1_UTCTIME_set(s, t); 124 return ASN1_UTCTIME_adj(s, t, offset_day, offset_sec);
114 return ASN1_GENERALIZEDTIME_set(s,t); 125 return ASN1_GENERALIZEDTIME_adj(s, t, offset_day, offset_sec);
115 } 126 }
116 127
117int ASN1_TIME_check(ASN1_TIME *t) 128int ASN1_TIME_check(ASN1_TIME *t)
@@ -162,3 +173,26 @@ ASN1_GENERALIZEDTIME *ASN1_TIME_to_generalizedtime(ASN1_TIME *t, ASN1_GENERALIZE
162 173
163 return ret; 174 return ret;
164 } 175 }
176
177int ASN1_TIME_set_string(ASN1_TIME *s, const char *str)
178 {
179 ASN1_TIME t;
180
181 t.length = strlen(str);
182 t.data = (unsigned char *)str;
183 t.flags = 0;
184
185 t.type = V_ASN1_UTCTIME;
186
187 if (!ASN1_TIME_check(&t))
188 {
189 t.type = V_ASN1_GENERALIZEDTIME;
190 if (!ASN1_TIME_check(&t))
191 return 0;
192 }
193
194 if (s && !ASN1_STRING_copy((ASN1_STRING *)s, (ASN1_STRING *)&t))
195 return 0;
196
197 return 1;
198 }
diff --git a/src/lib/libcrypto/asn1/a_type.c b/src/lib/libcrypto/asn1/a_type.c
index 36beceacdb..a45d2f9d12 100644
--- a/src/lib/libcrypto/asn1/a_type.c
+++ b/src/lib/libcrypto/asn1/a_type.c
@@ -77,7 +77,10 @@ void ASN1_TYPE_set(ASN1_TYPE *a, int type, void *value)
77 ASN1_primitive_free((ASN1_VALUE **)tmp_a, NULL); 77 ASN1_primitive_free((ASN1_VALUE **)tmp_a, NULL);
78 } 78 }
79 a->type=type; 79 a->type=type;
80 a->value.ptr=value; 80 if (type == V_ASN1_BOOLEAN)
81 a->value.boolean = value ? 0xff : 0;
82 else
83 a->value.ptr=value;
81 } 84 }
82 85
83int ASN1_TYPE_set1(ASN1_TYPE *a, int type, const void *value) 86int ASN1_TYPE_set1(ASN1_TYPE *a, int type, const void *value)
@@ -98,7 +101,7 @@ int ASN1_TYPE_set1(ASN1_TYPE *a, int type, const void *value)
98 else 101 else
99 { 102 {
100 ASN1_STRING *sdup; 103 ASN1_STRING *sdup;
101 sdup = ASN1_STRING_dup((ASN1_STRING *)value); 104 sdup = ASN1_STRING_dup(value);
102 if (!sdup) 105 if (!sdup)
103 return 0; 106 return 0;
104 ASN1_TYPE_set(a, type, sdup); 107 ASN1_TYPE_set(a, type, sdup);
@@ -108,3 +111,49 @@ int ASN1_TYPE_set1(ASN1_TYPE *a, int type, const void *value)
108 111
109IMPLEMENT_STACK_OF(ASN1_TYPE) 112IMPLEMENT_STACK_OF(ASN1_TYPE)
110IMPLEMENT_ASN1_SET_OF(ASN1_TYPE) 113IMPLEMENT_ASN1_SET_OF(ASN1_TYPE)
114
115/* Returns 0 if they are equal, != 0 otherwise. */
116int ASN1_TYPE_cmp(ASN1_TYPE *a, ASN1_TYPE *b)
117 {
118 int result = -1;
119
120 if (!a || !b || a->type != b->type) return -1;
121
122 switch (a->type)
123 {
124 case V_ASN1_OBJECT:
125 result = OBJ_cmp(a->value.object, b->value.object);
126 break;
127 case V_ASN1_NULL:
128 result = 0; /* They do not have content. */
129 break;
130 case V_ASN1_INTEGER:
131 case V_ASN1_NEG_INTEGER:
132 case V_ASN1_ENUMERATED:
133 case V_ASN1_NEG_ENUMERATED:
134 case V_ASN1_BIT_STRING:
135 case V_ASN1_OCTET_STRING:
136 case V_ASN1_SEQUENCE:
137 case V_ASN1_SET:
138 case V_ASN1_NUMERICSTRING:
139 case V_ASN1_PRINTABLESTRING:
140 case V_ASN1_T61STRING:
141 case V_ASN1_VIDEOTEXSTRING:
142 case V_ASN1_IA5STRING:
143 case V_ASN1_UTCTIME:
144 case V_ASN1_GENERALIZEDTIME:
145 case V_ASN1_GRAPHICSTRING:
146 case V_ASN1_VISIBLESTRING:
147 case V_ASN1_GENERALSTRING:
148 case V_ASN1_UNIVERSALSTRING:
149 case V_ASN1_BMPSTRING:
150 case V_ASN1_UTF8STRING:
151 case V_ASN1_OTHER:
152 default:
153 result = ASN1_STRING_cmp((ASN1_STRING *) a->value.ptr,
154 (ASN1_STRING *) b->value.ptr);
155 break;
156 }
157
158 return result;
159 }
diff --git a/src/lib/libcrypto/asn1/a_utctm.c b/src/lib/libcrypto/asn1/a_utctm.c
index d31c028193..072e236592 100644
--- a/src/lib/libcrypto/asn1/a_utctm.c
+++ b/src/lib/libcrypto/asn1/a_utctm.c
@@ -114,8 +114,8 @@ err:
114 114
115int ASN1_UTCTIME_check(ASN1_UTCTIME *d) 115int ASN1_UTCTIME_check(ASN1_UTCTIME *d)
116 { 116 {
117 static int min[8]={ 0, 1, 1, 0, 0, 0, 0, 0}; 117 static const int min[8]={ 0, 1, 1, 0, 0, 0, 0, 0};
118 static int max[8]={99,12,31,23,59,59,12,59}; 118 static const int max[8]={99,12,31,23,59,59,12,59};
119 char *a; 119 char *a;
120 int n,i,l,o; 120 int n,i,l,o;
121 121
@@ -186,6 +186,12 @@ int ASN1_UTCTIME_set_string(ASN1_UTCTIME *s, const char *str)
186 186
187ASN1_UTCTIME *ASN1_UTCTIME_set(ASN1_UTCTIME *s, time_t t) 187ASN1_UTCTIME *ASN1_UTCTIME_set(ASN1_UTCTIME *s, time_t t)
188 { 188 {
189 return ASN1_UTCTIME_adj(s, t, 0, 0);
190 }
191
192ASN1_UTCTIME *ASN1_UTCTIME_adj(ASN1_UTCTIME *s, time_t t,
193 int offset_day, long offset_sec)
194 {
189 char *p; 195 char *p;
190 struct tm *ts; 196 struct tm *ts;
191 struct tm data; 197 struct tm data;
@@ -200,13 +206,22 @@ ASN1_UTCTIME *ASN1_UTCTIME_set(ASN1_UTCTIME *s, time_t t)
200 if (ts == NULL) 206 if (ts == NULL)
201 return(NULL); 207 return(NULL);
202 208
209 if (offset_day || offset_sec)
210 {
211 if (!OPENSSL_gmtime_adj(ts, offset_day, offset_sec))
212 return NULL;
213 }
214
215 if((ts->tm_year < 50) || (ts->tm_year >= 150))
216 return NULL;
217
203 p=(char *)s->data; 218 p=(char *)s->data;
204 if ((p == NULL) || ((size_t)s->length < len)) 219 if ((p == NULL) || ((size_t)s->length < len))
205 { 220 {
206 p=OPENSSL_malloc(len); 221 p=OPENSSL_malloc(len);
207 if (p == NULL) 222 if (p == NULL)
208 { 223 {
209 ASN1err(ASN1_F_ASN1_UTCTIME_SET,ERR_R_MALLOC_FAILURE); 224 ASN1err(ASN1_F_ASN1_UTCTIME_ADJ,ERR_R_MALLOC_FAILURE);
210 return(NULL); 225 return(NULL);
211 } 226 }
212 if (s->data != NULL) 227 if (s->data != NULL)
diff --git a/src/lib/libcrypto/asn1/a_verify.c b/src/lib/libcrypto/asn1/a_verify.c
index da3efaaf8d..cecdb13c70 100644
--- a/src/lib/libcrypto/asn1/a_verify.c
+++ b/src/lib/libcrypto/asn1/a_verify.c
@@ -60,6 +60,7 @@
60#include <time.h> 60#include <time.h>
61 61
62#include "cryptlib.h" 62#include "cryptlib.h"
63#include "asn1_locl.h"
63 64
64#ifndef NO_SYS_TYPES_H 65#ifndef NO_SYS_TYPES_H
65# include <sys/types.h> 66# include <sys/types.h>
@@ -100,12 +101,7 @@ int ASN1_verify(i2d_of_void *i2d, X509_ALGOR *a, ASN1_BIT_STRING *signature,
100 p=buf_in; 101 p=buf_in;
101 102
102 i2d(data,&p); 103 i2d(data,&p);
103 if (!EVP_VerifyInit_ex(&ctx,type, NULL)) 104 EVP_VerifyInit_ex(&ctx,type, NULL);
104 {
105 ASN1err(ASN1_F_ASN1_VERIFY,ERR_R_EVP_LIB);
106 ret=0;
107 goto err;
108 }
109 EVP_VerifyUpdate(&ctx,(unsigned char *)buf_in,inl); 105 EVP_VerifyUpdate(&ctx,(unsigned char *)buf_in,inl);
110 106
111 OPENSSL_cleanse(buf_in,(unsigned int)inl); 107 OPENSSL_cleanse(buf_in,(unsigned int)inl);
@@ -134,19 +130,34 @@ int ASN1_item_verify(const ASN1_ITEM *it, X509_ALGOR *a, ASN1_BIT_STRING *signat
134 void *asn, EVP_PKEY *pkey) 130 void *asn, EVP_PKEY *pkey)
135 { 131 {
136 EVP_MD_CTX ctx; 132 EVP_MD_CTX ctx;
137 const EVP_MD *type; 133 const EVP_MD *type = NULL;
138 unsigned char *buf_in=NULL; 134 unsigned char *buf_in=NULL;
139 int ret= -1,i,inl; 135 int ret= -1,inl;
136
137 int mdnid, pknid;
140 138
141 EVP_MD_CTX_init(&ctx); 139 EVP_MD_CTX_init(&ctx);
142 i=OBJ_obj2nid(a->algorithm); 140
143 type=EVP_get_digestbyname(OBJ_nid2sn(i)); 141 /* Convert signature OID into digest and public key OIDs */
142 if (!OBJ_find_sigid_algs(OBJ_obj2nid(a->algorithm), &mdnid, &pknid))
143 {
144 ASN1err(ASN1_F_ASN1_ITEM_VERIFY,ASN1_R_UNKNOWN_SIGNATURE_ALGORITHM);
145 goto err;
146 }
147 type=EVP_get_digestbynid(mdnid);
144 if (type == NULL) 148 if (type == NULL)
145 { 149 {
146 ASN1err(ASN1_F_ASN1_ITEM_VERIFY,ASN1_R_UNKNOWN_MESSAGE_DIGEST_ALGORITHM); 150 ASN1err(ASN1_F_ASN1_ITEM_VERIFY,ASN1_R_UNKNOWN_MESSAGE_DIGEST_ALGORITHM);
147 goto err; 151 goto err;
148 } 152 }
149 153
154 /* Check public key OID matches public key type */
155 if (EVP_PKEY_type(pknid) != pkey->ameth->pkey_id)
156 {
157 ASN1err(ASN1_F_ASN1_ITEM_VERIFY,ASN1_R_WRONG_PUBLIC_KEY_TYPE);
158 goto err;
159 }
160
150 if (!EVP_VerifyInit_ex(&ctx,type, NULL)) 161 if (!EVP_VerifyInit_ex(&ctx,type, NULL))
151 { 162 {
152 ASN1err(ASN1_F_ASN1_ITEM_VERIFY,ERR_R_EVP_LIB); 163 ASN1err(ASN1_F_ASN1_ITEM_VERIFY,ERR_R_EVP_LIB);
diff --git a/src/lib/libcrypto/asn1/asn1.h b/src/lib/libcrypto/asn1/asn1.h
index e3385226d4..f7718b5a94 100644
--- a/src/lib/libcrypto/asn1/asn1.h
+++ b/src/lib/libcrypto/asn1/asn1.h
@@ -213,7 +213,7 @@ typedef struct asn1_object_st
213 const char *sn,*ln; 213 const char *sn,*ln;
214 int nid; 214 int nid;
215 int length; 215 int length;
216 unsigned char *data; 216 const unsigned char *data; /* data remains const after init */
217 int flags; /* Should we free this one */ 217 int flags; /* Should we free this one */
218 } ASN1_OBJECT; 218 } ASN1_OBJECT;
219 219
@@ -228,8 +228,12 @@ typedef struct asn1_object_st
228 * complete and is a place holder for content when it had all been 228 * complete and is a place holder for content when it had all been
229 * accessed. The flag will be reset when content has been written to it. 229 * accessed. The flag will be reset when content has been written to it.
230 */ 230 */
231#define ASN1_STRING_FLAG_CONT 0x020
232 231
232#define ASN1_STRING_FLAG_CONT 0x020
233/* This flag is used by ASN1 code to indicate an ASN1_STRING is an MSTRING
234 * type.
235 */
236#define ASN1_STRING_FLAG_MSTRING 0x040
233/* This is the base type that holds just about everything :-) */ 237/* This is the base type that holds just about everything :-) */
234typedef struct asn1_string_st 238typedef struct asn1_string_st
235 { 239 {
@@ -330,6 +334,13 @@ typedef struct ASN1_VALUE_st ASN1_VALUE;
330 type *name##_new(void); \ 334 type *name##_new(void); \
331 void name##_free(type *a); 335 void name##_free(type *a);
332 336
337#define DECLARE_ASN1_PRINT_FUNCTION(stname) \
338 DECLARE_ASN1_PRINT_FUNCTION_fname(stname, stname)
339
340#define DECLARE_ASN1_PRINT_FUNCTION_fname(stname, fname) \
341 int fname##_print_ctx(BIO *out, stname *x, int indent, \
342 const ASN1_PCTX *pctx);
343
333#define D2I_OF(type) type *(*)(type **,const unsigned char **,long) 344#define D2I_OF(type) type *(*)(type **,const unsigned char **,long)
334#define I2D_OF(type) int (*)(type *,unsigned char **) 345#define I2D_OF(type) int (*)(type *,unsigned char **)
335#define I2D_OF_const(type) int (*)(const type *,unsigned char **) 346#define I2D_OF_const(type) int (*)(const type *,unsigned char **)
@@ -534,28 +545,23 @@ typedef struct asn1_type_st
534 * contain the set or sequence bytes */ 545 * contain the set or sequence bytes */
535 ASN1_STRING * set; 546 ASN1_STRING * set;
536 ASN1_STRING * sequence; 547 ASN1_STRING * sequence;
537 ASN1_VALUE * asn1_value; 548 ASN1_VALUE * asn1_value;
538 } value; 549 } value;
539 } ASN1_TYPE; 550 } ASN1_TYPE;
540 551
541DECLARE_STACK_OF(ASN1_TYPE) 552DECLARE_STACK_OF(ASN1_TYPE)
542DECLARE_ASN1_SET_OF(ASN1_TYPE) 553DECLARE_ASN1_SET_OF(ASN1_TYPE)
543 554
544typedef struct asn1_method_st 555typedef STACK_OF(ASN1_TYPE) ASN1_SEQUENCE_ANY;
545 { 556
546 i2d_of_void *i2d; 557DECLARE_ASN1_ENCODE_FUNCTIONS_const(ASN1_SEQUENCE_ANY, ASN1_SEQUENCE_ANY)
547 d2i_of_void *d2i; 558DECLARE_ASN1_ENCODE_FUNCTIONS_const(ASN1_SEQUENCE_ANY, ASN1_SET_ANY)
548 void *(*create)(void); 559
549 void (*destroy)(void *); 560typedef struct NETSCAPE_X509_st
550 } ASN1_METHOD;
551
552/* This is used when parsing some Netscape objects */
553typedef struct asn1_header_st
554 { 561 {
555 ASN1_OCTET_STRING *header; 562 ASN1_OCTET_STRING *header;
556 void *data; 563 X509 *cert;
557 ASN1_METHOD *meth; 564 } NETSCAPE_X509;
558 } ASN1_HEADER;
559 565
560/* This is used to contain a list of bit names */ 566/* This is used to contain a list of bit names */
561typedef struct BIT_STRING_BITNAME_st { 567typedef struct BIT_STRING_BITNAME_st {
@@ -575,32 +581,34 @@ typedef struct BIT_STRING_BITNAME_st {
575 ASN1_STRING_type_new(V_ASN1_BIT_STRING) 581 ASN1_STRING_type_new(V_ASN1_BIT_STRING)
576#define M_ASN1_BIT_STRING_free(a) ASN1_STRING_free((ASN1_STRING *)a) 582#define M_ASN1_BIT_STRING_free(a) ASN1_STRING_free((ASN1_STRING *)a)
577#define M_ASN1_BIT_STRING_dup(a) (ASN1_BIT_STRING *)\ 583#define M_ASN1_BIT_STRING_dup(a) (ASN1_BIT_STRING *)\
578 ASN1_STRING_dup((ASN1_STRING *)a) 584 ASN1_STRING_dup((const ASN1_STRING *)a)
579#define M_ASN1_BIT_STRING_cmp(a,b) ASN1_STRING_cmp(\ 585#define M_ASN1_BIT_STRING_cmp(a,b) ASN1_STRING_cmp(\
580 (ASN1_STRING *)a,(ASN1_STRING *)b) 586 (const ASN1_STRING *)a,(const ASN1_STRING *)b)
581#define M_ASN1_BIT_STRING_set(a,b,c) ASN1_STRING_set((ASN1_STRING *)a,b,c) 587#define M_ASN1_BIT_STRING_set(a,b,c) ASN1_STRING_set((ASN1_STRING *)a,b,c)
582 588
583#define M_ASN1_INTEGER_new() (ASN1_INTEGER *)\ 589#define M_ASN1_INTEGER_new() (ASN1_INTEGER *)\
584 ASN1_STRING_type_new(V_ASN1_INTEGER) 590 ASN1_STRING_type_new(V_ASN1_INTEGER)
585#define M_ASN1_INTEGER_free(a) ASN1_STRING_free((ASN1_STRING *)a) 591#define M_ASN1_INTEGER_free(a) ASN1_STRING_free((ASN1_STRING *)a)
586#define M_ASN1_INTEGER_dup(a) (ASN1_INTEGER *)ASN1_STRING_dup((ASN1_STRING *)a) 592#define M_ASN1_INTEGER_dup(a) (ASN1_INTEGER *)\
593 ASN1_STRING_dup((const ASN1_STRING *)a)
587#define M_ASN1_INTEGER_cmp(a,b) ASN1_STRING_cmp(\ 594#define M_ASN1_INTEGER_cmp(a,b) ASN1_STRING_cmp(\
588 (ASN1_STRING *)a,(ASN1_STRING *)b) 595 (const ASN1_STRING *)a,(const ASN1_STRING *)b)
589 596
590#define M_ASN1_ENUMERATED_new() (ASN1_ENUMERATED *)\ 597#define M_ASN1_ENUMERATED_new() (ASN1_ENUMERATED *)\
591 ASN1_STRING_type_new(V_ASN1_ENUMERATED) 598 ASN1_STRING_type_new(V_ASN1_ENUMERATED)
592#define M_ASN1_ENUMERATED_free(a) ASN1_STRING_free((ASN1_STRING *)a) 599#define M_ASN1_ENUMERATED_free(a) ASN1_STRING_free((ASN1_STRING *)a)
593#define M_ASN1_ENUMERATED_dup(a) (ASN1_ENUMERATED *)ASN1_STRING_dup((ASN1_STRING *)a) 600#define M_ASN1_ENUMERATED_dup(a) (ASN1_ENUMERATED *)\
601 ASN1_STRING_dup((const ASN1_STRING *)a)
594#define M_ASN1_ENUMERATED_cmp(a,b) ASN1_STRING_cmp(\ 602#define M_ASN1_ENUMERATED_cmp(a,b) ASN1_STRING_cmp(\
595 (ASN1_STRING *)a,(ASN1_STRING *)b) 603 (const ASN1_STRING *)a,(const ASN1_STRING *)b)
596 604
597#define M_ASN1_OCTET_STRING_new() (ASN1_OCTET_STRING *)\ 605#define M_ASN1_OCTET_STRING_new() (ASN1_OCTET_STRING *)\
598 ASN1_STRING_type_new(V_ASN1_OCTET_STRING) 606 ASN1_STRING_type_new(V_ASN1_OCTET_STRING)
599#define M_ASN1_OCTET_STRING_free(a) ASN1_STRING_free((ASN1_STRING *)a) 607#define M_ASN1_OCTET_STRING_free(a) ASN1_STRING_free((ASN1_STRING *)a)
600#define M_ASN1_OCTET_STRING_dup(a) (ASN1_OCTET_STRING *)\ 608#define M_ASN1_OCTET_STRING_dup(a) (ASN1_OCTET_STRING *)\
601 ASN1_STRING_dup((ASN1_STRING *)a) 609 ASN1_STRING_dup((const ASN1_STRING *)a)
602#define M_ASN1_OCTET_STRING_cmp(a,b) ASN1_STRING_cmp(\ 610#define M_ASN1_OCTET_STRING_cmp(a,b) ASN1_STRING_cmp(\
603 (ASN1_STRING *)a,(ASN1_STRING *)b) 611 (const ASN1_STRING *)a,(const ASN1_STRING *)b)
604#define M_ASN1_OCTET_STRING_set(a,b,c) ASN1_STRING_set((ASN1_STRING *)a,b,c) 612#define M_ASN1_OCTET_STRING_set(a,b,c) ASN1_STRING_set((ASN1_STRING *)a,b,c)
605#define M_ASN1_OCTET_STRING_print(a,b) ASN1_STRING_print(a,(ASN1_STRING *)b) 613#define M_ASN1_OCTET_STRING_print(a,b) ASN1_STRING_print(a,(ASN1_STRING *)b)
606#define M_i2d_ASN1_OCTET_STRING(a,pp) \ 614#define M_i2d_ASN1_OCTET_STRING(a,pp) \
@@ -684,7 +692,7 @@ typedef struct BIT_STRING_BITNAME_st {
684 ASN1_STRING_type_new(V_ASN1_IA5STRING) 692 ASN1_STRING_type_new(V_ASN1_IA5STRING)
685#define M_ASN1_IA5STRING_free(a) ASN1_STRING_free((ASN1_STRING *)a) 693#define M_ASN1_IA5STRING_free(a) ASN1_STRING_free((ASN1_STRING *)a)
686#define M_ASN1_IA5STRING_dup(a) \ 694#define M_ASN1_IA5STRING_dup(a) \
687 (ASN1_IA5STRING *)ASN1_STRING_dup((ASN1_STRING *)a) 695 (ASN1_IA5STRING *)ASN1_STRING_dup((const ASN1_STRING *)a)
688#define M_i2d_ASN1_IA5STRING(a,pp) \ 696#define M_i2d_ASN1_IA5STRING(a,pp) \
689 i2d_ASN1_bytes((ASN1_STRING *)a,pp,V_ASN1_IA5STRING,\ 697 i2d_ASN1_bytes((ASN1_STRING *)a,pp,V_ASN1_IA5STRING,\
690 V_ASN1_UNIVERSAL) 698 V_ASN1_UNIVERSAL)
@@ -695,18 +703,20 @@ typedef struct BIT_STRING_BITNAME_st {
695#define M_ASN1_UTCTIME_new() (ASN1_UTCTIME *)\ 703#define M_ASN1_UTCTIME_new() (ASN1_UTCTIME *)\
696 ASN1_STRING_type_new(V_ASN1_UTCTIME) 704 ASN1_STRING_type_new(V_ASN1_UTCTIME)
697#define M_ASN1_UTCTIME_free(a) ASN1_STRING_free((ASN1_STRING *)a) 705#define M_ASN1_UTCTIME_free(a) ASN1_STRING_free((ASN1_STRING *)a)
698#define M_ASN1_UTCTIME_dup(a) (ASN1_UTCTIME *)ASN1_STRING_dup((ASN1_STRING *)a) 706#define M_ASN1_UTCTIME_dup(a) (ASN1_UTCTIME *)\
707 ASN1_STRING_dup((const ASN1_STRING *)a)
699 708
700#define M_ASN1_GENERALIZEDTIME_new() (ASN1_GENERALIZEDTIME *)\ 709#define M_ASN1_GENERALIZEDTIME_new() (ASN1_GENERALIZEDTIME *)\
701 ASN1_STRING_type_new(V_ASN1_GENERALIZEDTIME) 710 ASN1_STRING_type_new(V_ASN1_GENERALIZEDTIME)
702#define M_ASN1_GENERALIZEDTIME_free(a) ASN1_STRING_free((ASN1_STRING *)a) 711#define M_ASN1_GENERALIZEDTIME_free(a) ASN1_STRING_free((ASN1_STRING *)a)
703#define M_ASN1_GENERALIZEDTIME_dup(a) (ASN1_GENERALIZEDTIME *)ASN1_STRING_dup(\ 712#define M_ASN1_GENERALIZEDTIME_dup(a) (ASN1_GENERALIZEDTIME *)ASN1_STRING_dup(\
704 (ASN1_STRING *)a) 713 (const ASN1_STRING *)a)
705 714
706#define M_ASN1_TIME_new() (ASN1_TIME *)\ 715#define M_ASN1_TIME_new() (ASN1_TIME *)\
707 ASN1_STRING_type_new(V_ASN1_UTCTIME) 716 ASN1_STRING_type_new(V_ASN1_UTCTIME)
708#define M_ASN1_TIME_free(a) ASN1_STRING_free((ASN1_STRING *)a) 717#define M_ASN1_TIME_free(a) ASN1_STRING_free((ASN1_STRING *)a)
709#define M_ASN1_TIME_dup(a) (ASN1_TIME *)ASN1_STRING_dup((ASN1_STRING *)a) 718#define M_ASN1_TIME_dup(a) (ASN1_TIME *)\
719 ASN1_STRING_dup((const ASN1_STRING *)a)
710 720
711#define M_ASN1_GENERALSTRING_new() (ASN1_GENERALSTRING *)\ 721#define M_ASN1_GENERALSTRING_new() (ASN1_GENERALSTRING *)\
712 ASN1_STRING_type_new(V_ASN1_GENERALSTRING) 722 ASN1_STRING_type_new(V_ASN1_GENERALSTRING)
@@ -767,6 +777,7 @@ DECLARE_ASN1_FUNCTIONS_fname(ASN1_TYPE, ASN1_ANY, ASN1_TYPE)
767int ASN1_TYPE_get(ASN1_TYPE *a); 777int ASN1_TYPE_get(ASN1_TYPE *a);
768void ASN1_TYPE_set(ASN1_TYPE *a, int type, void *value); 778void ASN1_TYPE_set(ASN1_TYPE *a, int type, void *value);
769int ASN1_TYPE_set1(ASN1_TYPE *a, int type, const void *value); 779int ASN1_TYPE_set1(ASN1_TYPE *a, int type, const void *value);
780int ASN1_TYPE_cmp(ASN1_TYPE *a, ASN1_TYPE *b);
770 781
771ASN1_OBJECT * ASN1_OBJECT_new(void ); 782ASN1_OBJECT * ASN1_OBJECT_new(void );
772void ASN1_OBJECT_free(ASN1_OBJECT *a); 783void ASN1_OBJECT_free(ASN1_OBJECT *a);
@@ -783,14 +794,15 @@ DECLARE_ASN1_SET_OF(ASN1_OBJECT)
783 794
784ASN1_STRING * ASN1_STRING_new(void); 795ASN1_STRING * ASN1_STRING_new(void);
785void ASN1_STRING_free(ASN1_STRING *a); 796void ASN1_STRING_free(ASN1_STRING *a);
786ASN1_STRING * ASN1_STRING_dup(ASN1_STRING *a); 797int ASN1_STRING_copy(ASN1_STRING *dst, const ASN1_STRING *str);
798ASN1_STRING * ASN1_STRING_dup(const ASN1_STRING *a);
787ASN1_STRING * ASN1_STRING_type_new(int type ); 799ASN1_STRING * ASN1_STRING_type_new(int type );
788int ASN1_STRING_cmp(ASN1_STRING *a, ASN1_STRING *b); 800int ASN1_STRING_cmp(const ASN1_STRING *a, const ASN1_STRING *b);
789 /* Since this is used to store all sorts of things, via macros, for now, make 801 /* Since this is used to store all sorts of things, via macros, for now, make
790 its data void * */ 802 its data void * */
791int ASN1_STRING_set(ASN1_STRING *str, const void *data, int len); 803int ASN1_STRING_set(ASN1_STRING *str, const void *data, int len);
792void ASN1_STRING_set0(ASN1_STRING *str, void *data, int len); 804void ASN1_STRING_set0(ASN1_STRING *str, void *data, int len);
793int ASN1_STRING_length(ASN1_STRING *x); 805int ASN1_STRING_length(const ASN1_STRING *x);
794void ASN1_STRING_length_set(ASN1_STRING *x, int n); 806void ASN1_STRING_length_set(ASN1_STRING *x, int n);
795int ASN1_STRING_type(ASN1_STRING *x); 807int ASN1_STRING_type(ASN1_STRING *x);
796unsigned char * ASN1_STRING_data(ASN1_STRING *x); 808unsigned char * ASN1_STRING_data(ASN1_STRING *x);
@@ -803,6 +815,8 @@ int ASN1_BIT_STRING_set(ASN1_BIT_STRING *a, unsigned char *d,
803 int length ); 815 int length );
804int ASN1_BIT_STRING_set_bit(ASN1_BIT_STRING *a, int n, int value); 816int ASN1_BIT_STRING_set_bit(ASN1_BIT_STRING *a, int n, int value);
805int ASN1_BIT_STRING_get_bit(ASN1_BIT_STRING *a, int n); 817int ASN1_BIT_STRING_get_bit(ASN1_BIT_STRING *a, int n);
818int ASN1_BIT_STRING_check(ASN1_BIT_STRING *a,
819 unsigned char *flags, int flags_len);
806 820
807#ifndef OPENSSL_NO_BIO 821#ifndef OPENSSL_NO_BIO
808int ASN1_BIT_STRING_name_print(BIO *out, ASN1_BIT_STRING *bs, 822int ASN1_BIT_STRING_name_print(BIO *out, ASN1_BIT_STRING *bs,
@@ -821,13 +835,15 @@ ASN1_INTEGER *c2i_ASN1_INTEGER(ASN1_INTEGER **a,const unsigned char **pp,
821 long length); 835 long length);
822ASN1_INTEGER *d2i_ASN1_UINTEGER(ASN1_INTEGER **a,const unsigned char **pp, 836ASN1_INTEGER *d2i_ASN1_UINTEGER(ASN1_INTEGER **a,const unsigned char **pp,
823 long length); 837 long length);
824ASN1_INTEGER * ASN1_INTEGER_dup(ASN1_INTEGER *x); 838ASN1_INTEGER * ASN1_INTEGER_dup(const ASN1_INTEGER *x);
825int ASN1_INTEGER_cmp(ASN1_INTEGER *x, ASN1_INTEGER *y); 839int ASN1_INTEGER_cmp(const ASN1_INTEGER *x, const ASN1_INTEGER *y);
826 840
827DECLARE_ASN1_FUNCTIONS(ASN1_ENUMERATED) 841DECLARE_ASN1_FUNCTIONS(ASN1_ENUMERATED)
828 842
829int ASN1_UTCTIME_check(ASN1_UTCTIME *a); 843int ASN1_UTCTIME_check(ASN1_UTCTIME *a);
830ASN1_UTCTIME *ASN1_UTCTIME_set(ASN1_UTCTIME *s,time_t t); 844ASN1_UTCTIME *ASN1_UTCTIME_set(ASN1_UTCTIME *s,time_t t);
845ASN1_UTCTIME *ASN1_UTCTIME_adj(ASN1_UTCTIME *s, time_t t,
846 int offset_day, long offset_sec);
831int ASN1_UTCTIME_set_string(ASN1_UTCTIME *s, const char *str); 847int ASN1_UTCTIME_set_string(ASN1_UTCTIME *s, const char *str);
832int ASN1_UTCTIME_cmp_time_t(const ASN1_UTCTIME *s, time_t t); 848int ASN1_UTCTIME_cmp_time_t(const ASN1_UTCTIME *s, time_t t);
833#if 0 849#if 0
@@ -836,11 +852,13 @@ time_t ASN1_UTCTIME_get(const ASN1_UTCTIME *s);
836 852
837int ASN1_GENERALIZEDTIME_check(ASN1_GENERALIZEDTIME *a); 853int ASN1_GENERALIZEDTIME_check(ASN1_GENERALIZEDTIME *a);
838ASN1_GENERALIZEDTIME *ASN1_GENERALIZEDTIME_set(ASN1_GENERALIZEDTIME *s,time_t t); 854ASN1_GENERALIZEDTIME *ASN1_GENERALIZEDTIME_set(ASN1_GENERALIZEDTIME *s,time_t t);
855ASN1_GENERALIZEDTIME *ASN1_GENERALIZEDTIME_adj(ASN1_GENERALIZEDTIME *s,
856 time_t t, int offset_day, long offset_sec);
839int ASN1_GENERALIZEDTIME_set_string(ASN1_GENERALIZEDTIME *s, const char *str); 857int ASN1_GENERALIZEDTIME_set_string(ASN1_GENERALIZEDTIME *s, const char *str);
840 858
841DECLARE_ASN1_FUNCTIONS(ASN1_OCTET_STRING) 859DECLARE_ASN1_FUNCTIONS(ASN1_OCTET_STRING)
842ASN1_OCTET_STRING * ASN1_OCTET_STRING_dup(ASN1_OCTET_STRING *a); 860ASN1_OCTET_STRING * ASN1_OCTET_STRING_dup(const ASN1_OCTET_STRING *a);
843int ASN1_OCTET_STRING_cmp(ASN1_OCTET_STRING *a, ASN1_OCTET_STRING *b); 861int ASN1_OCTET_STRING_cmp(const ASN1_OCTET_STRING *a, const ASN1_OCTET_STRING *b);
844int ASN1_OCTET_STRING_set(ASN1_OCTET_STRING *str, const unsigned char *data, int len); 862int ASN1_OCTET_STRING_set(ASN1_OCTET_STRING *str, const unsigned char *data, int len);
845 863
846DECLARE_ASN1_FUNCTIONS(ASN1_VISIBLESTRING) 864DECLARE_ASN1_FUNCTIONS(ASN1_VISIBLESTRING)
@@ -867,14 +885,20 @@ DECLARE_ASN1_FUNCTIONS(ASN1_TIME)
867DECLARE_ASN1_ITEM(ASN1_OCTET_STRING_NDEF) 885DECLARE_ASN1_ITEM(ASN1_OCTET_STRING_NDEF)
868 886
869ASN1_TIME *ASN1_TIME_set(ASN1_TIME *s,time_t t); 887ASN1_TIME *ASN1_TIME_set(ASN1_TIME *s,time_t t);
888ASN1_TIME *ASN1_TIME_adj(ASN1_TIME *s,time_t t,
889 int offset_day, long offset_sec);
870int ASN1_TIME_check(ASN1_TIME *t); 890int ASN1_TIME_check(ASN1_TIME *t);
871ASN1_GENERALIZEDTIME *ASN1_TIME_to_generalizedtime(ASN1_TIME *t, ASN1_GENERALIZEDTIME **out); 891ASN1_GENERALIZEDTIME *ASN1_TIME_to_generalizedtime(ASN1_TIME *t, ASN1_GENERALIZEDTIME **out);
892int ASN1_TIME_set_string(ASN1_TIME *s, const char *str);
872 893
873int i2d_ASN1_SET(STACK *a, unsigned char **pp, 894int i2d_ASN1_SET(STACK_OF(OPENSSL_BLOCK) *a, unsigned char **pp,
874 i2d_of_void *i2d, int ex_tag, int ex_class, int is_set); 895 i2d_of_void *i2d, int ex_tag, int ex_class,
875STACK * d2i_ASN1_SET(STACK **a, const unsigned char **pp, long length, 896 int is_set);
876 d2i_of_void *d2i, void (*free_func)(void *), 897STACK_OF(OPENSSL_BLOCK) *d2i_ASN1_SET(STACK_OF(OPENSSL_BLOCK) **a,
877 int ex_tag, int ex_class); 898 const unsigned char **pp,
899 long length, d2i_of_void *d2i,
900 void (*free_func)(OPENSSL_BLOCK), int ex_tag,
901 int ex_class);
878 902
879#ifndef OPENSSL_NO_BIO 903#ifndef OPENSSL_NO_BIO
880int i2a_ASN1_INTEGER(BIO *bp, ASN1_INTEGER *a); 904int i2a_ASN1_INTEGER(BIO *bp, ASN1_INTEGER *a);
@@ -892,9 +916,9 @@ ASN1_OBJECT *ASN1_OBJECT_create(int nid, unsigned char *data,int len,
892 const char *sn, const char *ln); 916 const char *sn, const char *ln);
893 917
894int ASN1_INTEGER_set(ASN1_INTEGER *a, long v); 918int ASN1_INTEGER_set(ASN1_INTEGER *a, long v);
895long ASN1_INTEGER_get(ASN1_INTEGER *a); 919long ASN1_INTEGER_get(const ASN1_INTEGER *a);
896ASN1_INTEGER *BN_to_ASN1_INTEGER(BIGNUM *bn, ASN1_INTEGER *ai); 920ASN1_INTEGER *BN_to_ASN1_INTEGER(const BIGNUM *bn, ASN1_INTEGER *ai);
897BIGNUM *ASN1_INTEGER_to_BN(ASN1_INTEGER *ai,BIGNUM *bn); 921BIGNUM *ASN1_INTEGER_to_BN(const ASN1_INTEGER *ai,BIGNUM *bn);
898 922
899int ASN1_ENUMERATED_set(ASN1_ENUMERATED *a, long v); 923int ASN1_ENUMERATED_set(ASN1_ENUMERATED *a, long v);
900long ASN1_ENUMERATED_get(ASN1_ENUMERATED *a); 924long ASN1_ENUMERATED_get(ASN1_ENUMERATED *a);
@@ -928,7 +952,7 @@ int ASN1_put_eoc(unsigned char **pp);
928int ASN1_object_size(int constructed, int length, int tag); 952int ASN1_object_size(int constructed, int length, int tag);
929 953
930/* Used to implement other functions */ 954/* Used to implement other functions */
931void *ASN1_dup(i2d_of_void *i2d, d2i_of_void *d2i, char *x); 955void *ASN1_dup(i2d_of_void *i2d, d2i_of_void *d2i, void *x);
932 956
933#define ASN1_dup_of(type,i2d,d2i,x) \ 957#define ASN1_dup_of(type,i2d,d2i,x) \
934 ((type*)ASN1_dup(CHECKED_I2D_OF(type, i2d), \ 958 ((type*)ASN1_dup(CHECKED_I2D_OF(type, i2d), \
@@ -999,29 +1023,23 @@ int ASN1_i2d_bio(i2d_of_void *i2d,BIO *out, unsigned char *x);
999 CHECKED_PTR_OF(const type, x))) 1023 CHECKED_PTR_OF(const type, x)))
1000 1024
1001int ASN1_item_i2d_bio(const ASN1_ITEM *it, BIO *out, void *x); 1025int ASN1_item_i2d_bio(const ASN1_ITEM *it, BIO *out, void *x);
1002int ASN1_UTCTIME_print(BIO *fp,ASN1_UTCTIME *a); 1026int ASN1_UTCTIME_print(BIO *fp, const ASN1_UTCTIME *a);
1003int ASN1_GENERALIZEDTIME_print(BIO *fp,ASN1_GENERALIZEDTIME *a); 1027int ASN1_GENERALIZEDTIME_print(BIO *fp, const ASN1_GENERALIZEDTIME *a);
1004int ASN1_TIME_print(BIO *fp,ASN1_TIME *a); 1028int ASN1_TIME_print(BIO *fp, const ASN1_TIME *a);
1005int ASN1_STRING_print(BIO *bp,ASN1_STRING *v); 1029int ASN1_STRING_print(BIO *bp, const ASN1_STRING *v);
1006int ASN1_STRING_print_ex(BIO *out, ASN1_STRING *str, unsigned long flags); 1030int ASN1_STRING_print_ex(BIO *out, ASN1_STRING *str, unsigned long flags);
1031int ASN1_bn_print(BIO *bp, const char *number, const BIGNUM *num,
1032 unsigned char *buf, int off);
1007int ASN1_parse(BIO *bp,const unsigned char *pp,long len,int indent); 1033int ASN1_parse(BIO *bp,const unsigned char *pp,long len,int indent);
1008int ASN1_parse_dump(BIO *bp,const unsigned char *pp,long len,int indent,int dump); 1034int ASN1_parse_dump(BIO *bp,const unsigned char *pp,long len,int indent,int dump);
1009#endif 1035#endif
1010const char *ASN1_tag2str(int tag); 1036const char *ASN1_tag2str(int tag);
1011 1037
1012/* Used to load and write netscape format cert/key */ 1038/* Used to load and write netscape format cert */
1013int i2d_ASN1_HEADER(ASN1_HEADER *a,unsigned char **pp);
1014ASN1_HEADER *d2i_ASN1_HEADER(ASN1_HEADER **a,const unsigned char **pp, long length);
1015ASN1_HEADER *ASN1_HEADER_new(void );
1016void ASN1_HEADER_free(ASN1_HEADER *a);
1017 1039
1018int ASN1_UNIVERSALSTRING_to_string(ASN1_UNIVERSALSTRING *s); 1040DECLARE_ASN1_FUNCTIONS(NETSCAPE_X509)
1019 1041
1020/* Not used that much at this point, except for the first two */ 1042int ASN1_UNIVERSALSTRING_to_string(ASN1_UNIVERSALSTRING *s);
1021ASN1_METHOD *X509_asn1_meth(void);
1022ASN1_METHOD *RSAPrivateKey_asn1_meth(void);
1023ASN1_METHOD *ASN1_IA5STRING_asn1_meth(void);
1024ASN1_METHOD *ASN1_BIT_STRING_asn1_meth(void);
1025 1043
1026int ASN1_TYPE_set_octetstring(ASN1_TYPE *a, 1044int ASN1_TYPE_set_octetstring(ASN1_TYPE *a,
1027 unsigned char *data, int len); 1045 unsigned char *data, int len);
@@ -1032,9 +1050,9 @@ int ASN1_TYPE_set_int_octetstring(ASN1_TYPE *a, long num,
1032int ASN1_TYPE_get_int_octetstring(ASN1_TYPE *a,long *num, 1050int ASN1_TYPE_get_int_octetstring(ASN1_TYPE *a,long *num,
1033 unsigned char *data, int max_len); 1051 unsigned char *data, int max_len);
1034 1052
1035STACK *ASN1_seq_unpack(const unsigned char *buf, int len, 1053STACK_OF(OPENSSL_BLOCK) *ASN1_seq_unpack(const unsigned char *buf, int len,
1036 d2i_of_void *d2i, void (*free_func)(void *)); 1054 d2i_of_void *d2i, void (*free_func)(OPENSSL_BLOCK));
1037unsigned char *ASN1_seq_pack(STACK *safes, i2d_of_void *i2d, 1055unsigned char *ASN1_seq_pack(STACK_OF(OPENSSL_BLOCK) *safes, i2d_of_void *i2d,
1038 unsigned char **buf, int *len ); 1056 unsigned char **buf, int *len );
1039void *ASN1_unpack_string(ASN1_STRING *oct, d2i_of_void *d2i); 1057void *ASN1_unpack_string(ASN1_STRING *oct, d2i_of_void *d2i);
1040void *ASN1_item_unpack(ASN1_STRING *oct, const ASN1_ITEM *it); 1058void *ASN1_item_unpack(ASN1_STRING *oct, const ASN1_ITEM *it);
@@ -1077,15 +1095,58 @@ void ASN1_add_oid_module(void);
1077ASN1_TYPE *ASN1_generate_nconf(char *str, CONF *nconf); 1095ASN1_TYPE *ASN1_generate_nconf(char *str, CONF *nconf);
1078ASN1_TYPE *ASN1_generate_v3(char *str, X509V3_CTX *cnf); 1096ASN1_TYPE *ASN1_generate_v3(char *str, X509V3_CTX *cnf);
1079 1097
1080typedef int asn1_output_data_fn(BIO *out, BIO *data, ASN1_VALUE *val, int flags, 1098/* ASN1 Print flags */
1081 const ASN1_ITEM *it); 1099
1082 1100/* Indicate missing OPTIONAL fields */
1083int int_smime_write_ASN1(BIO *bio, ASN1_VALUE *val, BIO *data, int flags, 1101#define ASN1_PCTX_FLAGS_SHOW_ABSENT 0x001
1102/* Mark start and end of SEQUENCE */
1103#define ASN1_PCTX_FLAGS_SHOW_SEQUENCE 0x002
1104/* Mark start and end of SEQUENCE/SET OF */
1105#define ASN1_PCTX_FLAGS_SHOW_SSOF 0x004
1106/* Show the ASN1 type of primitives */
1107#define ASN1_PCTX_FLAGS_SHOW_TYPE 0x008
1108/* Don't show ASN1 type of ANY */
1109#define ASN1_PCTX_FLAGS_NO_ANY_TYPE 0x010
1110/* Don't show ASN1 type of MSTRINGs */
1111#define ASN1_PCTX_FLAGS_NO_MSTRING_TYPE 0x020
1112/* Don't show field names in SEQUENCE */
1113#define ASN1_PCTX_FLAGS_NO_FIELD_NAME 0x040
1114/* Show structure names of each SEQUENCE field */
1115#define ASN1_PCTX_FLAGS_SHOW_FIELD_STRUCT_NAME 0x080
1116/* Don't show structure name even at top level */
1117#define ASN1_PCTX_FLAGS_NO_STRUCT_NAME 0x100
1118
1119int ASN1_item_print(BIO *out, ASN1_VALUE *ifld, int indent,
1120 const ASN1_ITEM *it, const ASN1_PCTX *pctx);
1121ASN1_PCTX *ASN1_PCTX_new(void);
1122void ASN1_PCTX_free(ASN1_PCTX *p);
1123unsigned long ASN1_PCTX_get_flags(ASN1_PCTX *p);
1124void ASN1_PCTX_set_flags(ASN1_PCTX *p, unsigned long flags);
1125unsigned long ASN1_PCTX_get_nm_flags(ASN1_PCTX *p);
1126void ASN1_PCTX_set_nm_flags(ASN1_PCTX *p, unsigned long flags);
1127unsigned long ASN1_PCTX_get_cert_flags(ASN1_PCTX *p);
1128void ASN1_PCTX_set_cert_flags(ASN1_PCTX *p, unsigned long flags);
1129unsigned long ASN1_PCTX_get_oid_flags(ASN1_PCTX *p);
1130void ASN1_PCTX_set_oid_flags(ASN1_PCTX *p, unsigned long flags);
1131unsigned long ASN1_PCTX_get_str_flags(ASN1_PCTX *p);
1132void ASN1_PCTX_set_str_flags(ASN1_PCTX *p, unsigned long flags);
1133
1134BIO_METHOD *BIO_f_asn1(void);
1135
1136BIO *BIO_new_NDEF(BIO *out, ASN1_VALUE *val, const ASN1_ITEM *it);
1137
1138int i2d_ASN1_bio_stream(BIO *out, ASN1_VALUE *val, BIO *in, int flags,
1139 const ASN1_ITEM *it);
1140int PEM_write_bio_ASN1_stream(BIO *out, ASN1_VALUE *val, BIO *in, int flags,
1141 const char *hdr,
1142 const ASN1_ITEM *it);
1143int SMIME_write_ASN1(BIO *bio, ASN1_VALUE *val, BIO *data, int flags,
1084 int ctype_nid, int econt_nid, 1144 int ctype_nid, int econt_nid,
1085 STACK_OF(X509_ALGOR) *mdalgs, 1145 STACK_OF(X509_ALGOR) *mdalgs,
1086 asn1_output_data_fn *data_fn,
1087 const ASN1_ITEM *it); 1146 const ASN1_ITEM *it);
1088ASN1_VALUE *SMIME_read_ASN1(BIO *bio, BIO **bcont, const ASN1_ITEM *it); 1147ASN1_VALUE *SMIME_read_ASN1(BIO *bio, BIO **bcont, const ASN1_ITEM *it);
1148int SMIME_crlf_copy(BIO *in, BIO *out, int flags);
1149int SMIME_text(BIO *in, BIO *out);
1089 1150
1090/* BEGIN ERROR CODES */ 1151/* BEGIN ERROR CODES */
1091/* The following lines are auto generated by the script mkerr.pl. Any changes 1152/* The following lines are auto generated by the script mkerr.pl. Any changes
@@ -1116,6 +1177,7 @@ void ERR_load_ASN1_strings(void);
1116#define ASN1_F_ASN1_ENUMERATED_TO_BN 113 1177#define ASN1_F_ASN1_ENUMERATED_TO_BN 113
1117#define ASN1_F_ASN1_EX_C2I 204 1178#define ASN1_F_ASN1_EX_C2I 204
1118#define ASN1_F_ASN1_FIND_END 190 1179#define ASN1_F_ASN1_FIND_END 190
1180#define ASN1_F_ASN1_GENERALIZEDTIME_ADJ 216
1119#define ASN1_F_ASN1_GENERALIZEDTIME_SET 185 1181#define ASN1_F_ASN1_GENERALIZEDTIME_SET 185
1120#define ASN1_F_ASN1_GENERATE_V3 178 1182#define ASN1_F_ASN1_GENERATE_V3 178
1121#define ASN1_F_ASN1_GET_OBJECT 114 1183#define ASN1_F_ASN1_GET_OBJECT 114
@@ -1136,7 +1198,7 @@ void ERR_load_ASN1_strings(void);
1136#define ASN1_F_ASN1_ITEM_VERIFY 197 1198#define ASN1_F_ASN1_ITEM_VERIFY 197
1137#define ASN1_F_ASN1_MBSTRING_NCOPY 122 1199#define ASN1_F_ASN1_MBSTRING_NCOPY 122
1138#define ASN1_F_ASN1_OBJECT_NEW 123 1200#define ASN1_F_ASN1_OBJECT_NEW 123
1139#define ASN1_F_ASN1_OUTPUT_DATA 207 1201#define ASN1_F_ASN1_OUTPUT_DATA 214
1140#define ASN1_F_ASN1_PACK_STRING 124 1202#define ASN1_F_ASN1_PACK_STRING 124
1141#define ASN1_F_ASN1_PCTX_NEW 205 1203#define ASN1_F_ASN1_PCTX_NEW 205
1142#define ASN1_F_ASN1_PKCS5_PBE_SET 125 1204#define ASN1_F_ASN1_PKCS5_PBE_SET 125
@@ -1150,14 +1212,17 @@ void ERR_load_ASN1_strings(void);
1150#define ASN1_F_ASN1_TEMPLATE_EX_D2I 132 1212#define ASN1_F_ASN1_TEMPLATE_EX_D2I 132
1151#define ASN1_F_ASN1_TEMPLATE_NEW 133 1213#define ASN1_F_ASN1_TEMPLATE_NEW 133
1152#define ASN1_F_ASN1_TEMPLATE_NOEXP_D2I 131 1214#define ASN1_F_ASN1_TEMPLATE_NOEXP_D2I 131
1215#define ASN1_F_ASN1_TIME_ADJ 217
1153#define ASN1_F_ASN1_TIME_SET 175 1216#define ASN1_F_ASN1_TIME_SET 175
1154#define ASN1_F_ASN1_TYPE_GET_INT_OCTETSTRING 134 1217#define ASN1_F_ASN1_TYPE_GET_INT_OCTETSTRING 134
1155#define ASN1_F_ASN1_TYPE_GET_OCTETSTRING 135 1218#define ASN1_F_ASN1_TYPE_GET_OCTETSTRING 135
1156#define ASN1_F_ASN1_UNPACK_STRING 136 1219#define ASN1_F_ASN1_UNPACK_STRING 136
1220#define ASN1_F_ASN1_UTCTIME_ADJ 218
1157#define ASN1_F_ASN1_UTCTIME_SET 187 1221#define ASN1_F_ASN1_UTCTIME_SET 187
1158#define ASN1_F_ASN1_VERIFY 137 1222#define ASN1_F_ASN1_VERIFY 137
1159#define ASN1_F_B64_READ_ASN1 208 1223#define ASN1_F_B64_READ_ASN1 209
1160#define ASN1_F_B64_WRITE_ASN1 209 1224#define ASN1_F_B64_WRITE_ASN1 210
1225#define ASN1_F_BIO_NEW_NDEF 208
1161#define ASN1_F_BITSTR_CB 180 1226#define ASN1_F_BITSTR_CB 180
1162#define ASN1_F_BN_TO_ASN1_ENUMERATED 138 1227#define ASN1_F_BN_TO_ASN1_ENUMERATED 138
1163#define ASN1_F_BN_TO_ASN1_INTEGER 139 1228#define ASN1_F_BN_TO_ASN1_INTEGER 139
@@ -1176,6 +1241,7 @@ void ERR_load_ASN1_strings(void);
1176#define ASN1_F_D2I_ASN1_TYPE_BYTES 149 1241#define ASN1_F_D2I_ASN1_TYPE_BYTES 149
1177#define ASN1_F_D2I_ASN1_UINTEGER 150 1242#define ASN1_F_D2I_ASN1_UINTEGER 150
1178#define ASN1_F_D2I_ASN1_UTCTIME 151 1243#define ASN1_F_D2I_ASN1_UTCTIME 151
1244#define ASN1_F_D2I_AUTOPRIVATEKEY 207
1179#define ASN1_F_D2I_NETSCAPE_RSA 152 1245#define ASN1_F_D2I_NETSCAPE_RSA 152
1180#define ASN1_F_D2I_NETSCAPE_RSA_2 153 1246#define ASN1_F_D2I_NETSCAPE_RSA_2 153
1181#define ASN1_F_D2I_PRIVATEKEY 154 1247#define ASN1_F_D2I_PRIVATEKEY 154
@@ -1185,6 +1251,7 @@ void ERR_load_ASN1_strings(void);
1185#define ASN1_F_D2I_X509 156 1251#define ASN1_F_D2I_X509 156
1186#define ASN1_F_D2I_X509_CINF 157 1252#define ASN1_F_D2I_X509_CINF 157
1187#define ASN1_F_D2I_X509_PKEY 159 1253#define ASN1_F_D2I_X509_PKEY 159
1254#define ASN1_F_I2D_ASN1_BIO_STREAM 211
1188#define ASN1_F_I2D_ASN1_SET 188 1255#define ASN1_F_I2D_ASN1_SET 188
1189#define ASN1_F_I2D_ASN1_TIME 160 1256#define ASN1_F_I2D_ASN1_TIME 160
1190#define ASN1_F_I2D_DSA_PUBKEY 161 1257#define ASN1_F_I2D_DSA_PUBKEY 161
@@ -1196,10 +1263,11 @@ void ERR_load_ASN1_strings(void);
1196#define ASN1_F_LONG_C2I 166 1263#define ASN1_F_LONG_C2I 166
1197#define ASN1_F_OID_MODULE_INIT 174 1264#define ASN1_F_OID_MODULE_INIT 174
1198#define ASN1_F_PARSE_TAGGING 182 1265#define ASN1_F_PARSE_TAGGING 182
1199#define ASN1_F_PKCS5_PBE2_SET 167 1266#define ASN1_F_PKCS5_PBE2_SET_IV 167
1200#define ASN1_F_PKCS5_PBE_SET 202 1267#define ASN1_F_PKCS5_PBE_SET 202
1201#define ASN1_F_SMIME_READ_ASN1 210 1268#define ASN1_F_PKCS5_PBE_SET0_ALGOR 215
1202#define ASN1_F_SMIME_TEXT 211 1269#define ASN1_F_SMIME_READ_ASN1 212
1270#define ASN1_F_SMIME_TEXT 213
1203#define ASN1_F_X509_CINF_NEW 168 1271#define ASN1_F_X509_CINF_NEW 168
1204#define ASN1_F_X509_CRL_ADD0_REVOKED 169 1272#define ASN1_F_X509_CRL_ADD0_REVOKED 169
1205#define ASN1_F_X509_INFO_NEW 170 1273#define ASN1_F_X509_INFO_NEW 170
@@ -1211,14 +1279,14 @@ void ERR_load_ASN1_strings(void);
1211 1279
1212/* Reason codes. */ 1280/* Reason codes. */
1213#define ASN1_R_ADDING_OBJECT 171 1281#define ASN1_R_ADDING_OBJECT 171
1214#define ASN1_R_ASN1_PARSE_ERROR 198 1282#define ASN1_R_ASN1_PARSE_ERROR 203
1215#define ASN1_R_ASN1_SIG_PARSE_ERROR 199 1283#define ASN1_R_ASN1_SIG_PARSE_ERROR 204
1216#define ASN1_R_AUX_ERROR 100 1284#define ASN1_R_AUX_ERROR 100
1217#define ASN1_R_BAD_CLASS 101 1285#define ASN1_R_BAD_CLASS 101
1218#define ASN1_R_BAD_OBJECT_HEADER 102 1286#define ASN1_R_BAD_OBJECT_HEADER 102
1219#define ASN1_R_BAD_PASSWORD_READ 103 1287#define ASN1_R_BAD_PASSWORD_READ 103
1220#define ASN1_R_BAD_TAG 104 1288#define ASN1_R_BAD_TAG 104
1221#define ASN1_R_BMPSTRING_IS_WRONG_LENGTH 210 1289#define ASN1_R_BMPSTRING_IS_WRONG_LENGTH 214
1222#define ASN1_R_BN_LIB 105 1290#define ASN1_R_BN_LIB 105
1223#define ASN1_R_BOOLEAN_IS_WRONG_LENGTH 106 1291#define ASN1_R_BOOLEAN_IS_WRONG_LENGTH 106
1224#define ASN1_R_BUFFER_TOO_SMALL 107 1292#define ASN1_R_BUFFER_TOO_SMALL 107
@@ -1227,6 +1295,7 @@ void ERR_load_ASN1_strings(void);
1227#define ASN1_R_DECODE_ERROR 110 1295#define ASN1_R_DECODE_ERROR 110
1228#define ASN1_R_DECODING_ERROR 111 1296#define ASN1_R_DECODING_ERROR 111
1229#define ASN1_R_DEPTH_EXCEEDED 174 1297#define ASN1_R_DEPTH_EXCEEDED 174
1298#define ASN1_R_DIGEST_AND_KEY_TYPE_NOT_SUPPORTED 198
1230#define ASN1_R_ENCODE_ERROR 112 1299#define ASN1_R_ENCODE_ERROR 112
1231#define ASN1_R_ERROR_GETTING_TIME 173 1300#define ASN1_R_ERROR_GETTING_TIME 173
1232#define ASN1_R_ERROR_LOADING_SECTION 172 1301#define ASN1_R_ERROR_LOADING_SECTION 172
@@ -1260,9 +1329,10 @@ void ERR_load_ASN1_strings(void);
1260#define ASN1_R_INTEGER_TOO_LARGE_FOR_LONG 128 1329#define ASN1_R_INTEGER_TOO_LARGE_FOR_LONG 128
1261#define ASN1_R_INVALID_BMPSTRING_LENGTH 129 1330#define ASN1_R_INVALID_BMPSTRING_LENGTH 129
1262#define ASN1_R_INVALID_DIGIT 130 1331#define ASN1_R_INVALID_DIGIT 130
1263#define ASN1_R_INVALID_MIME_TYPE 200 1332#define ASN1_R_INVALID_MIME_TYPE 205
1264#define ASN1_R_INVALID_MODIFIER 186 1333#define ASN1_R_INVALID_MODIFIER 186
1265#define ASN1_R_INVALID_NUMBER 187 1334#define ASN1_R_INVALID_NUMBER 187
1335#define ASN1_R_INVALID_OBJECT_ENCODING 216
1266#define ASN1_R_INVALID_SEPARATOR 131 1336#define ASN1_R_INVALID_SEPARATOR 131
1267#define ASN1_R_INVALID_TIME_FORMAT 132 1337#define ASN1_R_INVALID_TIME_FORMAT 132
1268#define ASN1_R_INVALID_UNIVERSALSTRING_LENGTH 133 1338#define ASN1_R_INVALID_UNIVERSALSTRING_LENGTH 133
@@ -1270,9 +1340,9 @@ void ERR_load_ASN1_strings(void);
1270#define ASN1_R_IV_TOO_LARGE 135 1340#define ASN1_R_IV_TOO_LARGE 135
1271#define ASN1_R_LENGTH_ERROR 136 1341#define ASN1_R_LENGTH_ERROR 136
1272#define ASN1_R_LIST_ERROR 188 1342#define ASN1_R_LIST_ERROR 188
1273#define ASN1_R_MIME_NO_CONTENT_TYPE 201 1343#define ASN1_R_MIME_NO_CONTENT_TYPE 206
1274#define ASN1_R_MIME_PARSE_ERROR 202 1344#define ASN1_R_MIME_PARSE_ERROR 207
1275#define ASN1_R_MIME_SIG_PARSE_ERROR 203 1345#define ASN1_R_MIME_SIG_PARSE_ERROR 208
1276#define ASN1_R_MISSING_EOC 137 1346#define ASN1_R_MISSING_EOC 137
1277#define ASN1_R_MISSING_SECOND_NUMBER 138 1347#define ASN1_R_MISSING_SECOND_NUMBER 138
1278#define ASN1_R_MISSING_VALUE 189 1348#define ASN1_R_MISSING_VALUE 189
@@ -1282,11 +1352,12 @@ void ERR_load_ASN1_strings(void);
1282#define ASN1_R_NON_HEX_CHARACTERS 141 1352#define ASN1_R_NON_HEX_CHARACTERS 141
1283#define ASN1_R_NOT_ASCII_FORMAT 190 1353#define ASN1_R_NOT_ASCII_FORMAT 190
1284#define ASN1_R_NOT_ENOUGH_DATA 142 1354#define ASN1_R_NOT_ENOUGH_DATA 142
1285#define ASN1_R_NO_CONTENT_TYPE 204 1355#define ASN1_R_NO_CONTENT_TYPE 209
1356#define ASN1_R_NO_DEFAULT_DIGEST 201
1286#define ASN1_R_NO_MATCHING_CHOICE_TYPE 143 1357#define ASN1_R_NO_MATCHING_CHOICE_TYPE 143
1287#define ASN1_R_NO_MULTIPART_BODY_FAILURE 205 1358#define ASN1_R_NO_MULTIPART_BODY_FAILURE 210
1288#define ASN1_R_NO_MULTIPART_BOUNDARY 206 1359#define ASN1_R_NO_MULTIPART_BOUNDARY 211
1289#define ASN1_R_NO_SIG_CONTENT_TYPE 207 1360#define ASN1_R_NO_SIG_CONTENT_TYPE 212
1290#define ASN1_R_NULL_IS_WRONG_LENGTH 144 1361#define ASN1_R_NULL_IS_WRONG_LENGTH 144
1291#define ASN1_R_OBJECT_NOT_ASCII_FORMAT 191 1362#define ASN1_R_OBJECT_NOT_ASCII_FORMAT 191
1292#define ASN1_R_ODD_NUMBER_OF_CHARS 145 1363#define ASN1_R_ODD_NUMBER_OF_CHARS 145
@@ -1296,8 +1367,8 @@ void ERR_load_ASN1_strings(void);
1296#define ASN1_R_SEQUENCE_NOT_CONSTRUCTED 149 1367#define ASN1_R_SEQUENCE_NOT_CONSTRUCTED 149
1297#define ASN1_R_SEQUENCE_OR_SET_NEEDS_CONFIG 192 1368#define ASN1_R_SEQUENCE_OR_SET_NEEDS_CONFIG 192
1298#define ASN1_R_SHORT_LINE 150 1369#define ASN1_R_SHORT_LINE 150
1299#define ASN1_R_SIG_INVALID_MIME_TYPE 208 1370#define ASN1_R_SIG_INVALID_MIME_TYPE 213
1300#define ASN1_R_STREAMING_NOT_SUPPORTED 209 1371#define ASN1_R_STREAMING_NOT_SUPPORTED 202
1301#define ASN1_R_STRING_TOO_LONG 151 1372#define ASN1_R_STRING_TOO_LONG 151
1302#define ASN1_R_STRING_TOO_SHORT 152 1373#define ASN1_R_STRING_TOO_SHORT 152
1303#define ASN1_R_TAG_VALUE_TOO_HIGH 153 1374#define ASN1_R_TAG_VALUE_TOO_HIGH 153
@@ -1308,11 +1379,12 @@ void ERR_load_ASN1_strings(void);
1308#define ASN1_R_UNABLE_TO_DECODE_RSA_KEY 157 1379#define ASN1_R_UNABLE_TO_DECODE_RSA_KEY 157
1309#define ASN1_R_UNABLE_TO_DECODE_RSA_PRIVATE_KEY 158 1380#define ASN1_R_UNABLE_TO_DECODE_RSA_PRIVATE_KEY 158
1310#define ASN1_R_UNEXPECTED_EOC 159 1381#define ASN1_R_UNEXPECTED_EOC 159
1311#define ASN1_R_UNIVERSALSTRING_IS_WRONG_LENGTH 211 1382#define ASN1_R_UNIVERSALSTRING_IS_WRONG_LENGTH 215
1312#define ASN1_R_UNKNOWN_FORMAT 160 1383#define ASN1_R_UNKNOWN_FORMAT 160
1313#define ASN1_R_UNKNOWN_MESSAGE_DIGEST_ALGORITHM 161 1384#define ASN1_R_UNKNOWN_MESSAGE_DIGEST_ALGORITHM 161
1314#define ASN1_R_UNKNOWN_OBJECT_TYPE 162 1385#define ASN1_R_UNKNOWN_OBJECT_TYPE 162
1315#define ASN1_R_UNKNOWN_PUBLIC_KEY_TYPE 163 1386#define ASN1_R_UNKNOWN_PUBLIC_KEY_TYPE 163
1387#define ASN1_R_UNKNOWN_SIGNATURE_ALGORITHM 199
1316#define ASN1_R_UNKNOWN_TAG 194 1388#define ASN1_R_UNKNOWN_TAG 194
1317#define ASN1_R_UNKOWN_FORMAT 195 1389#define ASN1_R_UNKOWN_FORMAT 195
1318#define ASN1_R_UNSUPPORTED_ANY_DEFINED_BY_TYPE 164 1390#define ASN1_R_UNSUPPORTED_ANY_DEFINED_BY_TYPE 164
@@ -1320,6 +1392,7 @@ void ERR_load_ASN1_strings(void);
1320#define ASN1_R_UNSUPPORTED_ENCRYPTION_ALGORITHM 166 1392#define ASN1_R_UNSUPPORTED_ENCRYPTION_ALGORITHM 166
1321#define ASN1_R_UNSUPPORTED_PUBLIC_KEY_TYPE 167 1393#define ASN1_R_UNSUPPORTED_PUBLIC_KEY_TYPE 167
1322#define ASN1_R_UNSUPPORTED_TYPE 196 1394#define ASN1_R_UNSUPPORTED_TYPE 196
1395#define ASN1_R_WRONG_PUBLIC_KEY_TYPE 200
1323#define ASN1_R_WRONG_TAG 168 1396#define ASN1_R_WRONG_TAG 168
1324#define ASN1_R_WRONG_TYPE 169 1397#define ASN1_R_WRONG_TYPE 169
1325 1398
diff --git a/src/lib/libcrypto/asn1/asn1_err.c b/src/lib/libcrypto/asn1/asn1_err.c
index 5f5de98eed..6e04d08f31 100644
--- a/src/lib/libcrypto/asn1/asn1_err.c
+++ b/src/lib/libcrypto/asn1/asn1_err.c
@@ -1,6 +1,6 @@
1/* crypto/asn1/asn1_err.c */ 1/* crypto/asn1/asn1_err.c */
2/* ==================================================================== 2/* ====================================================================
3 * Copyright (c) 1999-2008 The OpenSSL Project. All rights reserved. 3 * Copyright (c) 1999-2009 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
@@ -90,10 +90,11 @@ static ERR_STRING_DATA ASN1_str_functs[]=
90{ERR_FUNC(ASN1_F_ASN1_ENUMERATED_TO_BN), "ASN1_ENUMERATED_to_BN"}, 90{ERR_FUNC(ASN1_F_ASN1_ENUMERATED_TO_BN), "ASN1_ENUMERATED_to_BN"},
91{ERR_FUNC(ASN1_F_ASN1_EX_C2I), "ASN1_EX_C2I"}, 91{ERR_FUNC(ASN1_F_ASN1_EX_C2I), "ASN1_EX_C2I"},
92{ERR_FUNC(ASN1_F_ASN1_FIND_END), "ASN1_FIND_END"}, 92{ERR_FUNC(ASN1_F_ASN1_FIND_END), "ASN1_FIND_END"},
93{ERR_FUNC(ASN1_F_ASN1_GENERALIZEDTIME_ADJ), "ASN1_GENERALIZEDTIME_adj"},
93{ERR_FUNC(ASN1_F_ASN1_GENERALIZEDTIME_SET), "ASN1_GENERALIZEDTIME_set"}, 94{ERR_FUNC(ASN1_F_ASN1_GENERALIZEDTIME_SET), "ASN1_GENERALIZEDTIME_set"},
94{ERR_FUNC(ASN1_F_ASN1_GENERATE_V3), "ASN1_generate_v3"}, 95{ERR_FUNC(ASN1_F_ASN1_GENERATE_V3), "ASN1_generate_v3"},
95{ERR_FUNC(ASN1_F_ASN1_GET_OBJECT), "ASN1_get_object"}, 96{ERR_FUNC(ASN1_F_ASN1_GET_OBJECT), "ASN1_get_object"},
96{ERR_FUNC(ASN1_F_ASN1_HEADER_NEW), "ASN1_HEADER_new"}, 97{ERR_FUNC(ASN1_F_ASN1_HEADER_NEW), "ASN1_HEADER_NEW"},
97{ERR_FUNC(ASN1_F_ASN1_I2D_BIO), "ASN1_i2d_bio"}, 98{ERR_FUNC(ASN1_F_ASN1_I2D_BIO), "ASN1_i2d_bio"},
98{ERR_FUNC(ASN1_F_ASN1_I2D_FP), "ASN1_i2d_fp"}, 99{ERR_FUNC(ASN1_F_ASN1_I2D_FP), "ASN1_i2d_fp"},
99{ERR_FUNC(ASN1_F_ASN1_INTEGER_SET), "ASN1_INTEGER_set"}, 100{ERR_FUNC(ASN1_F_ASN1_INTEGER_SET), "ASN1_INTEGER_set"},
@@ -112,7 +113,7 @@ static ERR_STRING_DATA ASN1_str_functs[]=
112{ERR_FUNC(ASN1_F_ASN1_OBJECT_NEW), "ASN1_OBJECT_new"}, 113{ERR_FUNC(ASN1_F_ASN1_OBJECT_NEW), "ASN1_OBJECT_new"},
113{ERR_FUNC(ASN1_F_ASN1_OUTPUT_DATA), "ASN1_OUTPUT_DATA"}, 114{ERR_FUNC(ASN1_F_ASN1_OUTPUT_DATA), "ASN1_OUTPUT_DATA"},
114{ERR_FUNC(ASN1_F_ASN1_PACK_STRING), "ASN1_pack_string"}, 115{ERR_FUNC(ASN1_F_ASN1_PACK_STRING), "ASN1_pack_string"},
115{ERR_FUNC(ASN1_F_ASN1_PCTX_NEW), "ASN1_PCTX_NEW"}, 116{ERR_FUNC(ASN1_F_ASN1_PCTX_NEW), "ASN1_PCTX_new"},
116{ERR_FUNC(ASN1_F_ASN1_PKCS5_PBE_SET), "ASN1_PKCS5_PBE_SET"}, 117{ERR_FUNC(ASN1_F_ASN1_PKCS5_PBE_SET), "ASN1_PKCS5_PBE_SET"},
117{ERR_FUNC(ASN1_F_ASN1_SEQ_PACK), "ASN1_seq_pack"}, 118{ERR_FUNC(ASN1_F_ASN1_SEQ_PACK), "ASN1_seq_pack"},
118{ERR_FUNC(ASN1_F_ASN1_SEQ_UNPACK), "ASN1_seq_unpack"}, 119{ERR_FUNC(ASN1_F_ASN1_SEQ_UNPACK), "ASN1_seq_unpack"},
@@ -124,14 +125,17 @@ static ERR_STRING_DATA ASN1_str_functs[]=
124{ERR_FUNC(ASN1_F_ASN1_TEMPLATE_EX_D2I), "ASN1_TEMPLATE_EX_D2I"}, 125{ERR_FUNC(ASN1_F_ASN1_TEMPLATE_EX_D2I), "ASN1_TEMPLATE_EX_D2I"},
125{ERR_FUNC(ASN1_F_ASN1_TEMPLATE_NEW), "ASN1_TEMPLATE_NEW"}, 126{ERR_FUNC(ASN1_F_ASN1_TEMPLATE_NEW), "ASN1_TEMPLATE_NEW"},
126{ERR_FUNC(ASN1_F_ASN1_TEMPLATE_NOEXP_D2I), "ASN1_TEMPLATE_NOEXP_D2I"}, 127{ERR_FUNC(ASN1_F_ASN1_TEMPLATE_NOEXP_D2I), "ASN1_TEMPLATE_NOEXP_D2I"},
128{ERR_FUNC(ASN1_F_ASN1_TIME_ADJ), "ASN1_TIME_adj"},
127{ERR_FUNC(ASN1_F_ASN1_TIME_SET), "ASN1_TIME_set"}, 129{ERR_FUNC(ASN1_F_ASN1_TIME_SET), "ASN1_TIME_set"},
128{ERR_FUNC(ASN1_F_ASN1_TYPE_GET_INT_OCTETSTRING), "ASN1_TYPE_get_int_octetstring"}, 130{ERR_FUNC(ASN1_F_ASN1_TYPE_GET_INT_OCTETSTRING), "ASN1_TYPE_get_int_octetstring"},
129{ERR_FUNC(ASN1_F_ASN1_TYPE_GET_OCTETSTRING), "ASN1_TYPE_get_octetstring"}, 131{ERR_FUNC(ASN1_F_ASN1_TYPE_GET_OCTETSTRING), "ASN1_TYPE_get_octetstring"},
130{ERR_FUNC(ASN1_F_ASN1_UNPACK_STRING), "ASN1_unpack_string"}, 132{ERR_FUNC(ASN1_F_ASN1_UNPACK_STRING), "ASN1_unpack_string"},
133{ERR_FUNC(ASN1_F_ASN1_UTCTIME_ADJ), "ASN1_UTCTIME_adj"},
131{ERR_FUNC(ASN1_F_ASN1_UTCTIME_SET), "ASN1_UTCTIME_set"}, 134{ERR_FUNC(ASN1_F_ASN1_UTCTIME_SET), "ASN1_UTCTIME_set"},
132{ERR_FUNC(ASN1_F_ASN1_VERIFY), "ASN1_verify"}, 135{ERR_FUNC(ASN1_F_ASN1_VERIFY), "ASN1_verify"},
133{ERR_FUNC(ASN1_F_B64_READ_ASN1), "B64_READ_ASN1"}, 136{ERR_FUNC(ASN1_F_B64_READ_ASN1), "B64_READ_ASN1"},
134{ERR_FUNC(ASN1_F_B64_WRITE_ASN1), "B64_WRITE_ASN1"}, 137{ERR_FUNC(ASN1_F_B64_WRITE_ASN1), "B64_WRITE_ASN1"},
138{ERR_FUNC(ASN1_F_BIO_NEW_NDEF), "BIO_new_NDEF"},
135{ERR_FUNC(ASN1_F_BITSTR_CB), "BITSTR_CB"}, 139{ERR_FUNC(ASN1_F_BITSTR_CB), "BITSTR_CB"},
136{ERR_FUNC(ASN1_F_BN_TO_ASN1_ENUMERATED), "BN_to_ASN1_ENUMERATED"}, 140{ERR_FUNC(ASN1_F_BN_TO_ASN1_ENUMERATED), "BN_to_ASN1_ENUMERATED"},
137{ERR_FUNC(ASN1_F_BN_TO_ASN1_INTEGER), "BN_to_ASN1_INTEGER"}, 141{ERR_FUNC(ASN1_F_BN_TO_ASN1_INTEGER), "BN_to_ASN1_INTEGER"},
@@ -143,13 +147,14 @@ static ERR_STRING_DATA ASN1_str_functs[]=
143{ERR_FUNC(ASN1_F_D2I_ASN1_BOOLEAN), "d2i_ASN1_BOOLEAN"}, 147{ERR_FUNC(ASN1_F_D2I_ASN1_BOOLEAN), "d2i_ASN1_BOOLEAN"},
144{ERR_FUNC(ASN1_F_D2I_ASN1_BYTES), "d2i_ASN1_bytes"}, 148{ERR_FUNC(ASN1_F_D2I_ASN1_BYTES), "d2i_ASN1_bytes"},
145{ERR_FUNC(ASN1_F_D2I_ASN1_GENERALIZEDTIME), "D2I_ASN1_GENERALIZEDTIME"}, 149{ERR_FUNC(ASN1_F_D2I_ASN1_GENERALIZEDTIME), "D2I_ASN1_GENERALIZEDTIME"},
146{ERR_FUNC(ASN1_F_D2I_ASN1_HEADER), "d2i_ASN1_HEADER"}, 150{ERR_FUNC(ASN1_F_D2I_ASN1_HEADER), "D2I_ASN1_HEADER"},
147{ERR_FUNC(ASN1_F_D2I_ASN1_INTEGER), "D2I_ASN1_INTEGER"}, 151{ERR_FUNC(ASN1_F_D2I_ASN1_INTEGER), "D2I_ASN1_INTEGER"},
148{ERR_FUNC(ASN1_F_D2I_ASN1_OBJECT), "d2i_ASN1_OBJECT"}, 152{ERR_FUNC(ASN1_F_D2I_ASN1_OBJECT), "d2i_ASN1_OBJECT"},
149{ERR_FUNC(ASN1_F_D2I_ASN1_SET), "d2i_ASN1_SET"}, 153{ERR_FUNC(ASN1_F_D2I_ASN1_SET), "d2i_ASN1_SET"},
150{ERR_FUNC(ASN1_F_D2I_ASN1_TYPE_BYTES), "d2i_ASN1_type_bytes"}, 154{ERR_FUNC(ASN1_F_D2I_ASN1_TYPE_BYTES), "d2i_ASN1_type_bytes"},
151{ERR_FUNC(ASN1_F_D2I_ASN1_UINTEGER), "d2i_ASN1_UINTEGER"}, 155{ERR_FUNC(ASN1_F_D2I_ASN1_UINTEGER), "d2i_ASN1_UINTEGER"},
152{ERR_FUNC(ASN1_F_D2I_ASN1_UTCTIME), "D2I_ASN1_UTCTIME"}, 156{ERR_FUNC(ASN1_F_D2I_ASN1_UTCTIME), "D2I_ASN1_UTCTIME"},
157{ERR_FUNC(ASN1_F_D2I_AUTOPRIVATEKEY), "d2i_AutoPrivateKey"},
153{ERR_FUNC(ASN1_F_D2I_NETSCAPE_RSA), "d2i_Netscape_RSA"}, 158{ERR_FUNC(ASN1_F_D2I_NETSCAPE_RSA), "d2i_Netscape_RSA"},
154{ERR_FUNC(ASN1_F_D2I_NETSCAPE_RSA_2), "D2I_NETSCAPE_RSA_2"}, 159{ERR_FUNC(ASN1_F_D2I_NETSCAPE_RSA_2), "D2I_NETSCAPE_RSA_2"},
155{ERR_FUNC(ASN1_F_D2I_PRIVATEKEY), "d2i_PrivateKey"}, 160{ERR_FUNC(ASN1_F_D2I_PRIVATEKEY), "d2i_PrivateKey"},
@@ -159,6 +164,7 @@ static ERR_STRING_DATA ASN1_str_functs[]=
159{ERR_FUNC(ASN1_F_D2I_X509), "D2I_X509"}, 164{ERR_FUNC(ASN1_F_D2I_X509), "D2I_X509"},
160{ERR_FUNC(ASN1_F_D2I_X509_CINF), "D2I_X509_CINF"}, 165{ERR_FUNC(ASN1_F_D2I_X509_CINF), "D2I_X509_CINF"},
161{ERR_FUNC(ASN1_F_D2I_X509_PKEY), "d2i_X509_PKEY"}, 166{ERR_FUNC(ASN1_F_D2I_X509_PKEY), "d2i_X509_PKEY"},
167{ERR_FUNC(ASN1_F_I2D_ASN1_BIO_STREAM), "i2d_ASN1_bio_stream"},
162{ERR_FUNC(ASN1_F_I2D_ASN1_SET), "i2d_ASN1_SET"}, 168{ERR_FUNC(ASN1_F_I2D_ASN1_SET), "i2d_ASN1_SET"},
163{ERR_FUNC(ASN1_F_I2D_ASN1_TIME), "I2D_ASN1_TIME"}, 169{ERR_FUNC(ASN1_F_I2D_ASN1_TIME), "I2D_ASN1_TIME"},
164{ERR_FUNC(ASN1_F_I2D_DSA_PUBKEY), "i2d_DSA_PUBKEY"}, 170{ERR_FUNC(ASN1_F_I2D_DSA_PUBKEY), "i2d_DSA_PUBKEY"},
@@ -170,8 +176,9 @@ static ERR_STRING_DATA ASN1_str_functs[]=
170{ERR_FUNC(ASN1_F_LONG_C2I), "LONG_C2I"}, 176{ERR_FUNC(ASN1_F_LONG_C2I), "LONG_C2I"},
171{ERR_FUNC(ASN1_F_OID_MODULE_INIT), "OID_MODULE_INIT"}, 177{ERR_FUNC(ASN1_F_OID_MODULE_INIT), "OID_MODULE_INIT"},
172{ERR_FUNC(ASN1_F_PARSE_TAGGING), "PARSE_TAGGING"}, 178{ERR_FUNC(ASN1_F_PARSE_TAGGING), "PARSE_TAGGING"},
173{ERR_FUNC(ASN1_F_PKCS5_PBE2_SET), "PKCS5_pbe2_set"}, 179{ERR_FUNC(ASN1_F_PKCS5_PBE2_SET_IV), "PKCS5_pbe2_set_iv"},
174{ERR_FUNC(ASN1_F_PKCS5_PBE_SET), "PKCS5_pbe_set"}, 180{ERR_FUNC(ASN1_F_PKCS5_PBE_SET), "PKCS5_pbe_set"},
181{ERR_FUNC(ASN1_F_PKCS5_PBE_SET0_ALGOR), "PKCS5_pbe_set0_algor"},
175{ERR_FUNC(ASN1_F_SMIME_READ_ASN1), "SMIME_read_ASN1"}, 182{ERR_FUNC(ASN1_F_SMIME_READ_ASN1), "SMIME_read_ASN1"},
176{ERR_FUNC(ASN1_F_SMIME_TEXT), "SMIME_text"}, 183{ERR_FUNC(ASN1_F_SMIME_TEXT), "SMIME_text"},
177{ERR_FUNC(ASN1_F_X509_CINF_NEW), "X509_CINF_NEW"}, 184{ERR_FUNC(ASN1_F_X509_CINF_NEW), "X509_CINF_NEW"},
@@ -204,6 +211,7 @@ static ERR_STRING_DATA ASN1_str_reasons[]=
204{ERR_REASON(ASN1_R_DECODE_ERROR) ,"decode error"}, 211{ERR_REASON(ASN1_R_DECODE_ERROR) ,"decode error"},
205{ERR_REASON(ASN1_R_DECODING_ERROR) ,"decoding error"}, 212{ERR_REASON(ASN1_R_DECODING_ERROR) ,"decoding error"},
206{ERR_REASON(ASN1_R_DEPTH_EXCEEDED) ,"depth exceeded"}, 213{ERR_REASON(ASN1_R_DEPTH_EXCEEDED) ,"depth exceeded"},
214{ERR_REASON(ASN1_R_DIGEST_AND_KEY_TYPE_NOT_SUPPORTED),"digest and key type not supported"},
207{ERR_REASON(ASN1_R_ENCODE_ERROR) ,"encode error"}, 215{ERR_REASON(ASN1_R_ENCODE_ERROR) ,"encode error"},
208{ERR_REASON(ASN1_R_ERROR_GETTING_TIME) ,"error getting time"}, 216{ERR_REASON(ASN1_R_ERROR_GETTING_TIME) ,"error getting time"},
209{ERR_REASON(ASN1_R_ERROR_LOADING_SECTION),"error loading section"}, 217{ERR_REASON(ASN1_R_ERROR_LOADING_SECTION),"error loading section"},
@@ -240,6 +248,7 @@ static ERR_STRING_DATA ASN1_str_reasons[]=
240{ERR_REASON(ASN1_R_INVALID_MIME_TYPE) ,"invalid mime type"}, 248{ERR_REASON(ASN1_R_INVALID_MIME_TYPE) ,"invalid mime type"},
241{ERR_REASON(ASN1_R_INVALID_MODIFIER) ,"invalid modifier"}, 249{ERR_REASON(ASN1_R_INVALID_MODIFIER) ,"invalid modifier"},
242{ERR_REASON(ASN1_R_INVALID_NUMBER) ,"invalid number"}, 250{ERR_REASON(ASN1_R_INVALID_NUMBER) ,"invalid number"},
251{ERR_REASON(ASN1_R_INVALID_OBJECT_ENCODING),"invalid object encoding"},
243{ERR_REASON(ASN1_R_INVALID_SEPARATOR) ,"invalid separator"}, 252{ERR_REASON(ASN1_R_INVALID_SEPARATOR) ,"invalid separator"},
244{ERR_REASON(ASN1_R_INVALID_TIME_FORMAT) ,"invalid time format"}, 253{ERR_REASON(ASN1_R_INVALID_TIME_FORMAT) ,"invalid time format"},
245{ERR_REASON(ASN1_R_INVALID_UNIVERSALSTRING_LENGTH),"invalid universalstring length"}, 254{ERR_REASON(ASN1_R_INVALID_UNIVERSALSTRING_LENGTH),"invalid universalstring length"},
@@ -260,6 +269,7 @@ static ERR_STRING_DATA ASN1_str_reasons[]=
260{ERR_REASON(ASN1_R_NOT_ASCII_FORMAT) ,"not ascii format"}, 269{ERR_REASON(ASN1_R_NOT_ASCII_FORMAT) ,"not ascii format"},
261{ERR_REASON(ASN1_R_NOT_ENOUGH_DATA) ,"not enough data"}, 270{ERR_REASON(ASN1_R_NOT_ENOUGH_DATA) ,"not enough data"},
262{ERR_REASON(ASN1_R_NO_CONTENT_TYPE) ,"no content type"}, 271{ERR_REASON(ASN1_R_NO_CONTENT_TYPE) ,"no content type"},
272{ERR_REASON(ASN1_R_NO_DEFAULT_DIGEST) ,"no default digest"},
263{ERR_REASON(ASN1_R_NO_MATCHING_CHOICE_TYPE),"no matching choice type"}, 273{ERR_REASON(ASN1_R_NO_MATCHING_CHOICE_TYPE),"no matching choice type"},
264{ERR_REASON(ASN1_R_NO_MULTIPART_BODY_FAILURE),"no multipart body failure"}, 274{ERR_REASON(ASN1_R_NO_MULTIPART_BODY_FAILURE),"no multipart body failure"},
265{ERR_REASON(ASN1_R_NO_MULTIPART_BOUNDARY),"no multipart boundary"}, 275{ERR_REASON(ASN1_R_NO_MULTIPART_BOUNDARY),"no multipart boundary"},
@@ -290,6 +300,7 @@ static ERR_STRING_DATA ASN1_str_reasons[]=
290{ERR_REASON(ASN1_R_UNKNOWN_MESSAGE_DIGEST_ALGORITHM),"unknown message digest algorithm"}, 300{ERR_REASON(ASN1_R_UNKNOWN_MESSAGE_DIGEST_ALGORITHM),"unknown message digest algorithm"},
291{ERR_REASON(ASN1_R_UNKNOWN_OBJECT_TYPE) ,"unknown object type"}, 301{ERR_REASON(ASN1_R_UNKNOWN_OBJECT_TYPE) ,"unknown object type"},
292{ERR_REASON(ASN1_R_UNKNOWN_PUBLIC_KEY_TYPE),"unknown public key type"}, 302{ERR_REASON(ASN1_R_UNKNOWN_PUBLIC_KEY_TYPE),"unknown public key type"},
303{ERR_REASON(ASN1_R_UNKNOWN_SIGNATURE_ALGORITHM),"unknown signature algorithm"},
293{ERR_REASON(ASN1_R_UNKNOWN_TAG) ,"unknown tag"}, 304{ERR_REASON(ASN1_R_UNKNOWN_TAG) ,"unknown tag"},
294{ERR_REASON(ASN1_R_UNKOWN_FORMAT) ,"unkown format"}, 305{ERR_REASON(ASN1_R_UNKOWN_FORMAT) ,"unkown format"},
295{ERR_REASON(ASN1_R_UNSUPPORTED_ANY_DEFINED_BY_TYPE),"unsupported any defined by type"}, 306{ERR_REASON(ASN1_R_UNSUPPORTED_ANY_DEFINED_BY_TYPE),"unsupported any defined by type"},
@@ -297,6 +308,7 @@ static ERR_STRING_DATA ASN1_str_reasons[]=
297{ERR_REASON(ASN1_R_UNSUPPORTED_ENCRYPTION_ALGORITHM),"unsupported encryption algorithm"}, 308{ERR_REASON(ASN1_R_UNSUPPORTED_ENCRYPTION_ALGORITHM),"unsupported encryption algorithm"},
298{ERR_REASON(ASN1_R_UNSUPPORTED_PUBLIC_KEY_TYPE),"unsupported public key type"}, 309{ERR_REASON(ASN1_R_UNSUPPORTED_PUBLIC_KEY_TYPE),"unsupported public key type"},
299{ERR_REASON(ASN1_R_UNSUPPORTED_TYPE) ,"unsupported type"}, 310{ERR_REASON(ASN1_R_UNSUPPORTED_TYPE) ,"unsupported type"},
311{ERR_REASON(ASN1_R_WRONG_PUBLIC_KEY_TYPE),"wrong public key type"},
300{ERR_REASON(ASN1_R_WRONG_TAG) ,"wrong tag"}, 312{ERR_REASON(ASN1_R_WRONG_TAG) ,"wrong tag"},
301{ERR_REASON(ASN1_R_WRONG_TYPE) ,"wrong type"}, 313{ERR_REASON(ASN1_R_WRONG_TYPE) ,"wrong type"},
302{0,NULL} 314{0,NULL}
diff --git a/src/lib/libcrypto/asn1/asn1_lib.c b/src/lib/libcrypto/asn1/asn1_lib.c
index 5af559ef8d..1bcb44aee2 100644
--- a/src/lib/libcrypto/asn1/asn1_lib.c
+++ b/src/lib/libcrypto/asn1/asn1_lib.c
@@ -340,20 +340,31 @@ int asn1_GetSequence(ASN1_const_CTX *c, long *length)
340 return(1); 340 return(1);
341 } 341 }
342 342
343ASN1_STRING *ASN1_STRING_dup(ASN1_STRING *str) 343int ASN1_STRING_copy(ASN1_STRING *dst, const ASN1_STRING *str)
344 { 344 {
345 ASN1_STRING *ret; 345 if (str == NULL)
346 return 0;
347 dst->type = str->type;
348 if (!ASN1_STRING_set(dst,str->data,str->length))
349 return 0;
350 dst->flags = str->flags;
351 return 1;
352 }
346 353
347 if (str == NULL) return(NULL); 354ASN1_STRING *ASN1_STRING_dup(const ASN1_STRING *str)
348 if ((ret=ASN1_STRING_type_new(str->type)) == NULL) 355 {
349 return(NULL); 356 ASN1_STRING *ret;
350 if (!ASN1_STRING_set(ret,str->data,str->length)) 357 if (!str)
358 return NULL;
359 ret=ASN1_STRING_new();
360 if (!ret)
361 return NULL;
362 if (!ASN1_STRING_copy(ret,str))
351 { 363 {
352 ASN1_STRING_free(ret); 364 ASN1_STRING_free(ret);
353 return(NULL); 365 return NULL;
354 } 366 }
355 ret->flags = str->flags; 367 return ret;
356 return(ret);
357 } 368 }
358 369
359int ASN1_STRING_set(ASN1_STRING *str, const void *_data, int len) 370int ASN1_STRING_set(ASN1_STRING *str, const void *_data, int len)
@@ -427,11 +438,12 @@ ASN1_STRING *ASN1_STRING_type_new(int type)
427void ASN1_STRING_free(ASN1_STRING *a) 438void ASN1_STRING_free(ASN1_STRING *a)
428 { 439 {
429 if (a == NULL) return; 440 if (a == NULL) return;
430 if (a->data != NULL) OPENSSL_free(a->data); 441 if (a->data && !(a->flags & ASN1_STRING_FLAG_NDEF))
442 OPENSSL_free(a->data);
431 OPENSSL_free(a); 443 OPENSSL_free(a);
432 } 444 }
433 445
434int ASN1_STRING_cmp(ASN1_STRING *a, ASN1_STRING *b) 446int ASN1_STRING_cmp(const ASN1_STRING *a, const ASN1_STRING *b)
435 { 447 {
436 int i; 448 int i;
437 449
@@ -457,7 +469,7 @@ void asn1_add_error(const unsigned char *address, int offset)
457 ERR_add_error_data(4,"address=",buf1," offset=",buf2); 469 ERR_add_error_data(4,"address=",buf1," offset=",buf2);
458 } 470 }
459 471
460int ASN1_STRING_length(ASN1_STRING *x) 472int ASN1_STRING_length(const ASN1_STRING *x)
461{ return M_ASN1_STRING_length(x); } 473{ return M_ASN1_STRING_length(x); }
462 474
463void ASN1_STRING_length_set(ASN1_STRING *x, int len) 475void ASN1_STRING_length_set(ASN1_STRING *x, int len)
diff --git a/src/lib/libcrypto/asn1/asn1_mac.h b/src/lib/libcrypto/asn1/asn1_mac.h
index d958ca60d9..87bd0e9e1d 100644
--- a/src/lib/libcrypto/asn1/asn1_mac.h
+++ b/src/lib/libcrypto/asn1/asn1_mac.h
@@ -153,6 +153,13 @@ err:\
153 M_ASN1_D2I_get(b,func); \ 153 M_ASN1_D2I_get(b,func); \
154 } 154 }
155 155
156#define M_ASN1_D2I_get_int_opt(b,func,type) \
157 if ((c.slen != 0) && ((M_ASN1_next & (~V_ASN1_CONSTRUCTED)) \
158 == (V_ASN1_UNIVERSAL|(type)))) \
159 { \
160 M_ASN1_D2I_get_int(b,func); \
161 }
162
156#define M_ASN1_D2I_get_imp(b,func, type) \ 163#define M_ASN1_D2I_get_imp(b,func, type) \
157 M_ASN1_next=(_tmp& V_ASN1_CONSTRUCTED)|type; \ 164 M_ASN1_next=(_tmp& V_ASN1_CONSTRUCTED)|type; \
158 c.q=c.p; \ 165 c.q=c.p; \
diff --git a/src/lib/libcrypto/asn1/asn1_par.c b/src/lib/libcrypto/asn1/asn1_par.c
index 8657f73d66..aaca69aebd 100644
--- a/src/lib/libcrypto/asn1/asn1_par.c
+++ b/src/lib/libcrypto/asn1/asn1_par.c
@@ -70,9 +70,8 @@ static int asn1_print_info(BIO *bp, int tag, int xclass, int constructed,
70 int indent) 70 int indent)
71 { 71 {
72 static const char fmt[]="%-18s"; 72 static const char fmt[]="%-18s";
73 static const char fmt2[]="%2d %-15s";
74 char str[128]; 73 char str[128];
75 const char *p,*p2=NULL; 74 const char *p;
76 75
77 if (constructed & V_ASN1_CONSTRUCTED) 76 if (constructed & V_ASN1_CONSTRUCTED)
78 p="cons: "; 77 p="cons: ";
@@ -93,14 +92,8 @@ static int asn1_print_info(BIO *bp, int tag, int xclass, int constructed,
93 else 92 else
94 p = ASN1_tag2str(tag); 93 p = ASN1_tag2str(tag);
95 94
96 if (p2 != NULL) 95 if (BIO_printf(bp,fmt,p) <= 0)
97 { 96 goto err;
98 if (BIO_printf(bp,fmt2,tag,p2) <= 0) goto err;
99 }
100 else
101 {
102 if (BIO_printf(bp,fmt,p) <= 0) goto err;
103 }
104 return(1); 97 return(1);
105err: 98err:
106 return(0); 99 return(0);
@@ -246,7 +239,7 @@ static int asn1_parse2(BIO *bp, const unsigned char **pp, long length, int offse
246 ii=d2i_ASN1_BOOLEAN(NULL,&opp,len+hl); 239 ii=d2i_ASN1_BOOLEAN(NULL,&opp,len+hl);
247 if (ii < 0) 240 if (ii < 0)
248 { 241 {
249 if (BIO_write(bp,"Bad boolean\n",12)) 242 if (BIO_write(bp,"Bad boolean\n",12) <= 0)
250 goto end; 243 goto end;
251 } 244 }
252 BIO_printf(bp,":%d",ii); 245 BIO_printf(bp,":%d",ii);
@@ -424,7 +417,7 @@ end:
424 417
425const char *ASN1_tag2str(int tag) 418const char *ASN1_tag2str(int tag)
426{ 419{
427 static const char *tag2str[] = { 420 static const char * const tag2str[] = {
428 "EOC", "BOOLEAN", "INTEGER", "BIT STRING", "OCTET STRING", /* 0-4 */ 421 "EOC", "BOOLEAN", "INTEGER", "BIT STRING", "OCTET STRING", /* 0-4 */
429 "NULL", "OBJECT", "OBJECT DESCRIPTOR", "EXTERNAL", "REAL", /* 5-9 */ 422 "NULL", "OBJECT", "OBJECT DESCRIPTOR", "EXTERNAL", "REAL", /* 5-9 */
430 "ENUMERATED", "<ASN1 11>", "UTF8STRING", "<ASN1 13>", /* 10-13 */ 423 "ENUMERATED", "<ASN1 11>", "UTF8STRING", "<ASN1 13>", /* 10-13 */
diff --git a/src/lib/libcrypto/asn1/asn1t.h b/src/lib/libcrypto/asn1/asn1t.h
index ac14f9415b..d230e4bf70 100644
--- a/src/lib/libcrypto/asn1/asn1t.h
+++ b/src/lib/libcrypto/asn1/asn1t.h
@@ -3,7 +3,7 @@
3 * project 2000. 3 * project 2000.
4 */ 4 */
5/* ==================================================================== 5/* ====================================================================
6 * Copyright (c) 2000 The OpenSSL Project. All rights reserved. 6 * Copyright (c) 2000-2005 The OpenSSL Project. All rights reserved.
7 * 7 *
8 * Redistribution and use in source and binary forms, with or without 8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions 9 * modification, are permitted provided that the following conditions
@@ -218,6 +218,18 @@ extern "C" {
218 #stname \ 218 #stname \
219 ASN1_ITEM_end(tname) 219 ASN1_ITEM_end(tname)
220 220
221#define ASN1_NDEF_SEQUENCE_END_cb(stname, tname) \
222 ;\
223 ASN1_ITEM_start(tname) \
224 ASN1_ITYPE_NDEF_SEQUENCE,\
225 V_ASN1_SEQUENCE,\
226 tname##_seq_tt,\
227 sizeof(tname##_seq_tt) / sizeof(ASN1_TEMPLATE),\
228 &tname##_aux,\
229 sizeof(stname),\
230 #stname \
231 ASN1_ITEM_end(tname)
232
221 233
222/* This pair helps declare a CHOICE type. We can do: 234/* This pair helps declare a CHOICE type. We can do:
223 * 235 *
@@ -651,8 +663,13 @@ typedef int ASN1_ex_i2d(ASN1_VALUE **pval, unsigned char **out, const ASN1_ITEM
651typedef int ASN1_ex_new_func(ASN1_VALUE **pval, const ASN1_ITEM *it); 663typedef int ASN1_ex_new_func(ASN1_VALUE **pval, const ASN1_ITEM *it);
652typedef void ASN1_ex_free_func(ASN1_VALUE **pval, const ASN1_ITEM *it); 664typedef void ASN1_ex_free_func(ASN1_VALUE **pval, const ASN1_ITEM *it);
653 665
666typedef int ASN1_ex_print_func(BIO *out, ASN1_VALUE **pval,
667 int indent, const char *fname,
668 const ASN1_PCTX *pctx);
669
654typedef int ASN1_primitive_i2c(ASN1_VALUE **pval, unsigned char *cont, int *putype, const ASN1_ITEM *it); 670typedef int ASN1_primitive_i2c(ASN1_VALUE **pval, unsigned char *cont, int *putype, const ASN1_ITEM *it);
655typedef int ASN1_primitive_c2i(ASN1_VALUE **pval, const unsigned char *cont, int len, int utype, char *free_cont, const ASN1_ITEM *it); 671typedef int ASN1_primitive_c2i(ASN1_VALUE **pval, const unsigned char *cont, int len, int utype, char *free_cont, const ASN1_ITEM *it);
672typedef int ASN1_primitive_print(BIO *out, ASN1_VALUE **pval, const ASN1_ITEM *it, int indent, const ASN1_PCTX *pctx);
656 673
657typedef struct ASN1_COMPAT_FUNCS_st { 674typedef struct ASN1_COMPAT_FUNCS_st {
658 ASN1_new_func *asn1_new; 675 ASN1_new_func *asn1_new;
@@ -668,6 +685,7 @@ typedef struct ASN1_EXTERN_FUNCS_st {
668 ASN1_ex_free_func *asn1_ex_clear; 685 ASN1_ex_free_func *asn1_ex_clear;
669 ASN1_ex_d2i *asn1_ex_d2i; 686 ASN1_ex_d2i *asn1_ex_d2i;
670 ASN1_ex_i2d *asn1_ex_i2d; 687 ASN1_ex_i2d *asn1_ex_i2d;
688 ASN1_ex_print_func *asn1_ex_print;
671} ASN1_EXTERN_FUNCS; 689} ASN1_EXTERN_FUNCS;
672 690
673typedef struct ASN1_PRIMITIVE_FUNCS_st { 691typedef struct ASN1_PRIMITIVE_FUNCS_st {
@@ -678,6 +696,7 @@ typedef struct ASN1_PRIMITIVE_FUNCS_st {
678 ASN1_ex_free_func *prim_clear; 696 ASN1_ex_free_func *prim_clear;
679 ASN1_primitive_c2i *prim_c2i; 697 ASN1_primitive_c2i *prim_c2i;
680 ASN1_primitive_i2c *prim_i2c; 698 ASN1_primitive_i2c *prim_i2c;
699 ASN1_primitive_print *prim_print;
681} ASN1_PRIMITIVE_FUNCS; 700} ASN1_PRIMITIVE_FUNCS;
682 701
683/* This is the ASN1_AUX structure: it handles various 702/* This is the ASN1_AUX structure: it handles various
@@ -697,7 +716,8 @@ typedef struct ASN1_PRIMITIVE_FUNCS_st {
697 * then an external type is more appropriate. 716 * then an external type is more appropriate.
698 */ 717 */
699 718
700typedef int ASN1_aux_cb(int operation, ASN1_VALUE **in, const ASN1_ITEM *it); 719typedef int ASN1_aux_cb(int operation, ASN1_VALUE **in, const ASN1_ITEM *it,
720 void *exarg);
701 721
702typedef struct ASN1_AUX_st { 722typedef struct ASN1_AUX_st {
703 void *app_data; 723 void *app_data;
@@ -708,6 +728,23 @@ typedef struct ASN1_AUX_st {
708 int enc_offset; /* Offset of ASN1_ENCODING structure */ 728 int enc_offset; /* Offset of ASN1_ENCODING structure */
709} ASN1_AUX; 729} ASN1_AUX;
710 730
731/* For print related callbacks exarg points to this structure */
732typedef struct ASN1_PRINT_ARG_st {
733 BIO *out;
734 int indent;
735 const ASN1_PCTX *pctx;
736} ASN1_PRINT_ARG;
737
738/* For streaming related callbacks exarg points to this structure */
739typedef struct ASN1_STREAM_ARG_st {
740 /* BIO to stream through */
741 BIO *out;
742 /* BIO with filters appended */
743 BIO *ndef_bio;
744 /* Streaming I/O boundary */
745 unsigned char **boundary;
746} ASN1_STREAM_ARG;
747
711/* Flags in ASN1_AUX */ 748/* Flags in ASN1_AUX */
712 749
713/* Use a reference count */ 750/* Use a reference count */
@@ -727,6 +764,12 @@ typedef struct ASN1_AUX_st {
727#define ASN1_OP_D2I_POST 5 764#define ASN1_OP_D2I_POST 5
728#define ASN1_OP_I2D_PRE 6 765#define ASN1_OP_I2D_PRE 6
729#define ASN1_OP_I2D_POST 7 766#define ASN1_OP_I2D_POST 7
767#define ASN1_OP_PRINT_PRE 8
768#define ASN1_OP_PRINT_POST 9
769#define ASN1_OP_STREAM_PRE 10
770#define ASN1_OP_STREAM_POST 11
771#define ASN1_OP_DETACHED_PRE 12
772#define ASN1_OP_DETACHED_POST 13
730 773
731/* Macro to implement a primitive type */ 774/* Macro to implement a primitive type */
732#define IMPLEMENT_ASN1_TYPE(stname) IMPLEMENT_ASN1_TYPE_ex(stname, stname, 0) 775#define IMPLEMENT_ASN1_TYPE(stname) IMPLEMENT_ASN1_TYPE_ex(stname, stname, 0)
@@ -782,9 +825,22 @@ typedef struct ASN1_AUX_st {
782#define IMPLEMENT_ASN1_FUNCTIONS_ENCODE_name(stname, itname) \ 825#define IMPLEMENT_ASN1_FUNCTIONS_ENCODE_name(stname, itname) \
783 IMPLEMENT_ASN1_FUNCTIONS_ENCODE_fname(stname, itname, itname) 826 IMPLEMENT_ASN1_FUNCTIONS_ENCODE_fname(stname, itname, itname)
784 827
828#define IMPLEMENT_STATIC_ASN1_ALLOC_FUNCTIONS(stname) \
829 IMPLEMENT_ASN1_ALLOC_FUNCTIONS_pfname(static, stname, stname, stname)
830
785#define IMPLEMENT_ASN1_ALLOC_FUNCTIONS(stname) \ 831#define IMPLEMENT_ASN1_ALLOC_FUNCTIONS(stname) \
786 IMPLEMENT_ASN1_ALLOC_FUNCTIONS_fname(stname, stname, stname) 832 IMPLEMENT_ASN1_ALLOC_FUNCTIONS_fname(stname, stname, stname)
787 833
834#define IMPLEMENT_ASN1_ALLOC_FUNCTIONS_pfname(pre, stname, itname, fname) \
835 pre stname *fname##_new(void) \
836 { \
837 return (stname *)ASN1_item_new(ASN1_ITEM_rptr(itname)); \
838 } \
839 pre void fname##_free(stname *a) \
840 { \
841 ASN1_item_free((ASN1_VALUE *)a, ASN1_ITEM_rptr(itname)); \
842 }
843
788#define IMPLEMENT_ASN1_ALLOC_FUNCTIONS_fname(stname, itname, fname) \ 844#define IMPLEMENT_ASN1_ALLOC_FUNCTIONS_fname(stname, itname, fname) \
789 stname *fname##_new(void) \ 845 stname *fname##_new(void) \
790 { \ 846 { \
@@ -834,6 +890,17 @@ typedef struct ASN1_AUX_st {
834 return ASN1_item_dup(ASN1_ITEM_rptr(stname), x); \ 890 return ASN1_item_dup(ASN1_ITEM_rptr(stname), x); \
835 } 891 }
836 892
893#define IMPLEMENT_ASN1_PRINT_FUNCTION(stname) \
894 IMPLEMENT_ASN1_PRINT_FUNCTION_fname(stname, stname, stname)
895
896#define IMPLEMENT_ASN1_PRINT_FUNCTION_fname(stname, itname, fname) \
897 int fname##_print_ctx(BIO *out, stname *x, int indent, \
898 const ASN1_PCTX *pctx) \
899 { \
900 return ASN1_item_print(out, (ASN1_VALUE *)x, indent, \
901 ASN1_ITEM_rptr(itname), pctx); \
902 }
903
837#define IMPLEMENT_ASN1_FUNCTIONS_const(name) \ 904#define IMPLEMENT_ASN1_FUNCTIONS_const(name) \
838 IMPLEMENT_ASN1_FUNCTIONS_const_fname(name, name, name) 905 IMPLEMENT_ASN1_FUNCTIONS_const_fname(name, name, name)
839 906
diff --git a/src/lib/libcrypto/asn1/asn_mime.c b/src/lib/libcrypto/asn1/asn_mime.c
index d8d9e76cc0..c1d1b12291 100644
--- a/src/lib/libcrypto/asn1/asn_mime.c
+++ b/src/lib/libcrypto/asn1/asn_mime.c
@@ -59,6 +59,7 @@
59#include <openssl/x509.h> 59#include <openssl/x509.h>
60#include <openssl/asn1.h> 60#include <openssl/asn1.h>
61#include <openssl/asn1t.h> 61#include <openssl/asn1t.h>
62#include "asn1_locl.h"
62 63
63/* Generalised MIME like utilities for streaming ASN1. Although many 64/* Generalised MIME like utilities for streaming ASN1. Although many
64 * have a PKCS7/CMS like flavour others are more general purpose. 65 * have a PKCS7/CMS like flavour others are more general purpose.
@@ -86,6 +87,8 @@ STACK_OF(MIME_PARAM) *params; /* Zero or more parameters */
86DECLARE_STACK_OF(MIME_HEADER) 87DECLARE_STACK_OF(MIME_HEADER)
87IMPLEMENT_STACK_OF(MIME_HEADER) 88IMPLEMENT_STACK_OF(MIME_HEADER)
88 89
90static int asn1_output_data(BIO *out, BIO *data, ASN1_VALUE *val, int flags,
91 const ASN1_ITEM *it);
89static char * strip_ends(char *name); 92static char * strip_ends(char *name);
90static char * strip_start(char *name); 93static char * strip_start(char *name);
91static char * strip_end(char *name); 94static char * strip_end(char *name);
@@ -107,6 +110,39 @@ static void mime_hdr_free(MIME_HEADER *hdr);
107#define MAX_SMLEN 1024 110#define MAX_SMLEN 1024
108#define mime_debug(x) /* x */ 111#define mime_debug(x) /* x */
109 112
113/* Output an ASN1 structure in BER format streaming if necessary */
114
115int i2d_ASN1_bio_stream(BIO *out, ASN1_VALUE *val, BIO *in, int flags,
116 const ASN1_ITEM *it)
117 {
118 /* If streaming create stream BIO and copy all content through it */
119 if (flags & SMIME_STREAM)
120 {
121 BIO *bio, *tbio;
122 bio = BIO_new_NDEF(out, val, it);
123 if (!bio)
124 {
125 ASN1err(ASN1_F_I2D_ASN1_BIO_STREAM,ERR_R_MALLOC_FAILURE);
126 return 0;
127 }
128 SMIME_crlf_copy(in, bio, flags);
129 (void)BIO_flush(bio);
130 /* Free up successive BIOs until we hit the old output BIO */
131 do
132 {
133 tbio = BIO_pop(bio);
134 BIO_free(bio);
135 bio = tbio;
136 } while (bio != out);
137 }
138 /* else just write out ASN1 structure which will have all content
139 * stored internally
140 */
141 else
142 ASN1_item_i2d_bio(it, out, val);
143 return 1;
144 }
145
110/* Base 64 read and write of ASN1 structure */ 146/* Base 64 read and write of ASN1 structure */
111 147
112static int B64_write_ASN1(BIO *out, ASN1_VALUE *val, BIO *in, int flags, 148static int B64_write_ASN1(BIO *out, ASN1_VALUE *val, BIO *in, int flags,
@@ -123,13 +159,26 @@ static int B64_write_ASN1(BIO *out, ASN1_VALUE *val, BIO *in, int flags,
123 /* prepend the b64 BIO so all data is base64 encoded. 159 /* prepend the b64 BIO so all data is base64 encoded.
124 */ 160 */
125 out = BIO_push(b64, out); 161 out = BIO_push(b64, out);
126 r = ASN1_item_i2d_bio(it, out, val); 162 r = i2d_ASN1_bio_stream(out, val, in, flags, it);
127 (void)BIO_flush(out); 163 (void)BIO_flush(out);
128 BIO_pop(out); 164 BIO_pop(out);
129 BIO_free(b64); 165 BIO_free(b64);
130 return r; 166 return r;
131 } 167 }
132 168
169/* Streaming ASN1 PEM write */
170
171int PEM_write_bio_ASN1_stream(BIO *out, ASN1_VALUE *val, BIO *in, int flags,
172 const char *hdr,
173 const ASN1_ITEM *it)
174 {
175 int r;
176 BIO_printf(out, "-----BEGIN %s-----\n", hdr);
177 r = B64_write_ASN1(out, val, in, flags, it);
178 BIO_printf(out, "-----END %s-----\n", hdr);
179 return r;
180 }
181
133static ASN1_VALUE *b64_read_asn1(BIO *bio, const ASN1_ITEM *it) 182static ASN1_VALUE *b64_read_asn1(BIO *bio, const ASN1_ITEM *it)
134{ 183{
135 BIO *b64; 184 BIO *b64;
@@ -152,7 +201,8 @@ static ASN1_VALUE *b64_read_asn1(BIO *bio, const ASN1_ITEM *it)
152 201
153static int asn1_write_micalg(BIO *out, STACK_OF(X509_ALGOR) *mdalgs) 202static int asn1_write_micalg(BIO *out, STACK_OF(X509_ALGOR) *mdalgs)
154 { 203 {
155 int i, have_unknown = 0, write_comma, md_nid; 204 const EVP_MD *md;
205 int i, have_unknown = 0, write_comma, ret = 0, md_nid;
156 have_unknown = 0; 206 have_unknown = 0;
157 write_comma = 0; 207 write_comma = 0;
158 for (i = 0; i < sk_X509_ALGOR_num(mdalgs); i++) 208 for (i = 0; i < sk_X509_ALGOR_num(mdalgs); i++)
@@ -161,6 +211,21 @@ static int asn1_write_micalg(BIO *out, STACK_OF(X509_ALGOR) *mdalgs)
161 BIO_write(out, ",", 1); 211 BIO_write(out, ",", 1);
162 write_comma = 1; 212 write_comma = 1;
163 md_nid = OBJ_obj2nid(sk_X509_ALGOR_value(mdalgs, i)->algorithm); 213 md_nid = OBJ_obj2nid(sk_X509_ALGOR_value(mdalgs, i)->algorithm);
214 md = EVP_get_digestbynid(md_nid);
215 if (md && md->md_ctrl)
216 {
217 int rv;
218 char *micstr;
219 rv = md->md_ctrl(NULL, EVP_MD_CTRL_MICALG, 0, &micstr);
220 if (rv > 0)
221 {
222 BIO_puts(out, micstr);
223 OPENSSL_free(micstr);
224 continue;
225 }
226 if (rv != -2)
227 goto err;
228 }
164 switch(md_nid) 229 switch(md_nid)
165 { 230 {
166 case NID_sha1: 231 case NID_sha1:
@@ -183,6 +248,11 @@ static int asn1_write_micalg(BIO *out, STACK_OF(X509_ALGOR) *mdalgs)
183 BIO_puts(out, "sha-512"); 248 BIO_puts(out, "sha-512");
184 break; 249 break;
185 250
251 case NID_id_GostR3411_94:
252 BIO_puts(out, "gostr3411-94");
253 goto err;
254 break;
255
186 default: 256 default:
187 if (have_unknown) 257 if (have_unknown)
188 write_comma = 0; 258 write_comma = 0;
@@ -196,16 +266,18 @@ static int asn1_write_micalg(BIO *out, STACK_OF(X509_ALGOR) *mdalgs)
196 } 266 }
197 } 267 }
198 268
199 return 1; 269 ret = 1;
270 err:
271
272 return ret;
200 273
201 } 274 }
202 275
203/* SMIME sender */ 276/* SMIME sender */
204 277
205int int_smime_write_ASN1(BIO *bio, ASN1_VALUE *val, BIO *data, int flags, 278int SMIME_write_ASN1(BIO *bio, ASN1_VALUE *val, BIO *data, int flags,
206 int ctype_nid, int econt_nid, 279 int ctype_nid, int econt_nid,
207 STACK_OF(X509_ALGOR) *mdalgs, 280 STACK_OF(X509_ALGOR) *mdalgs,
208 asn1_output_data_fn *data_fn,
209 const ASN1_ITEM *it) 281 const ASN1_ITEM *it)
210{ 282{
211 char bound[33], c; 283 char bound[33], c;
@@ -243,7 +315,7 @@ int int_smime_write_ASN1(BIO *bio, ASN1_VALUE *val, BIO *data, int flags,
243 mime_eol, mime_eol); 315 mime_eol, mime_eol);
244 /* Now write out the first part */ 316 /* Now write out the first part */
245 BIO_printf(bio, "------%s%s", bound, mime_eol); 317 BIO_printf(bio, "------%s%s", bound, mime_eol);
246 if (!data_fn(bio, data, val, flags, it)) 318 if (!asn1_output_data(bio, data, val, flags, it))
247 return 0; 319 return 0;
248 BIO_printf(bio, "%s------%s%s", mime_eol, bound, mime_eol); 320 BIO_printf(bio, "%s------%s%s", mime_eol, bound, mime_eol);
249 321
@@ -296,8 +368,6 @@ int int_smime_write_ASN1(BIO *bio, ASN1_VALUE *val, BIO *data, int flags,
296 return 1; 368 return 1;
297} 369}
298 370
299#if 0
300
301/* Handle output of ASN1 data */ 371/* Handle output of ASN1 data */
302 372
303 373
@@ -350,8 +420,6 @@ static int asn1_output_data(BIO *out, BIO *data, ASN1_VALUE *val, int flags,
350 420
351 } 421 }
352 422
353#endif
354
355/* SMIME reader: handle multipart/signed and opaque signing. 423/* SMIME reader: handle multipart/signed and opaque signing.
356 * in multipart case the content is placed in a memory BIO 424 * in multipart case the content is placed in a memory BIO
357 * pointed to by "bcont". In opaque this is set to NULL 425 * pointed to by "bcont". In opaque this is set to NULL
diff --git a/src/lib/libcrypto/asn1/asn_pack.c b/src/lib/libcrypto/asn1/asn_pack.c
index f1a5a05632..ad738217d7 100644
--- a/src/lib/libcrypto/asn1/asn_pack.c
+++ b/src/lib/libcrypto/asn1/asn_pack.c
@@ -66,10 +66,10 @@
66 66
67/* Turn an ASN1 encoded SEQUENCE OF into a STACK of structures */ 67/* Turn an ASN1 encoded SEQUENCE OF into a STACK of structures */
68 68
69STACK *ASN1_seq_unpack(const unsigned char *buf, int len, 69STACK_OF(OPENSSL_BLOCK) *ASN1_seq_unpack(const unsigned char *buf, int len,
70 d2i_of_void *d2i,void (*free_func)(void *)) 70 d2i_of_void *d2i, void (*free_func)(OPENSSL_BLOCK))
71{ 71{
72 STACK *sk; 72 STACK_OF(OPENSSL_BLOCK) *sk;
73 const unsigned char *pbuf; 73 const unsigned char *pbuf;
74 pbuf = buf; 74 pbuf = buf;
75 if (!(sk = d2i_ASN1_SET(NULL, &pbuf, len, d2i, free_func, 75 if (!(sk = d2i_ASN1_SET(NULL, &pbuf, len, d2i, free_func,
@@ -82,7 +82,7 @@ STACK *ASN1_seq_unpack(const unsigned char *buf, int len,
82 * OPENSSL_malloc'ed buffer 82 * OPENSSL_malloc'ed buffer
83 */ 83 */
84 84
85unsigned char *ASN1_seq_pack(STACK *safes, i2d_of_void *i2d, 85unsigned char *ASN1_seq_pack(STACK_OF(OPENSSL_BLOCK) *safes, i2d_of_void *i2d,
86 unsigned char **buf, int *len) 86 unsigned char **buf, int *len)
87{ 87{
88 int safelen; 88 int safelen;
diff --git a/src/lib/libcrypto/asn1/charmap.h b/src/lib/libcrypto/asn1/charmap.h
index bd020a9562..b55e638725 100644
--- a/src/lib/libcrypto/asn1/charmap.h
+++ b/src/lib/libcrypto/asn1/charmap.h
@@ -2,7 +2,7 @@
2 * Mask of various character properties 2 * Mask of various character properties
3 */ 3 */
4 4
5static unsigned char char_type[] = { 5static const unsigned char char_type[] = {
6 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 6 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
7 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 7 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
8120, 0, 1,40, 0, 0, 0,16,16,16, 0,25,25,16,16,16, 8120, 0, 1,40, 0, 0, 0,16,16,16, 0,25,25,16,16,16,
diff --git a/src/lib/libcrypto/asn1/d2i_pr.c b/src/lib/libcrypto/asn1/d2i_pr.c
index 207ccda5ac..2828944777 100644
--- a/src/lib/libcrypto/asn1/d2i_pr.c
+++ b/src/lib/libcrypto/asn1/d2i_pr.c
@@ -61,16 +61,12 @@
61#include <openssl/bn.h> 61#include <openssl/bn.h>
62#include <openssl/evp.h> 62#include <openssl/evp.h>
63#include <openssl/objects.h> 63#include <openssl/objects.h>
64#include <openssl/asn1.h> 64#ifndef OPENSSL_NO_ENGINE
65#ifndef OPENSSL_NO_RSA 65#include <openssl/engine.h>
66#include <openssl/rsa.h>
67#endif
68#ifndef OPENSSL_NO_DSA
69#include <openssl/dsa.h>
70#endif
71#ifndef OPENSSL_NO_EC
72#include <openssl/ec.h>
73#endif 66#endif
67#include <openssl/x509.h>
68#include <openssl/asn1.h>
69#include "asn1_locl.h"
74 70
75EVP_PKEY *d2i_PrivateKey(int type, EVP_PKEY **a, const unsigned char **pp, 71EVP_PKEY *d2i_PrivateKey(int type, EVP_PKEY **a, const unsigned char **pp,
76 long length) 72 long length)
@@ -85,47 +81,43 @@ EVP_PKEY *d2i_PrivateKey(int type, EVP_PKEY **a, const unsigned char **pp,
85 return(NULL); 81 return(NULL);
86 } 82 }
87 } 83 }
88 else ret= *a; 84 else
89
90 ret->save_type=type;
91 ret->type=EVP_PKEY_type(type);
92 switch (ret->type)
93 { 85 {
94#ifndef OPENSSL_NO_RSA 86 ret= *a;
95 case EVP_PKEY_RSA: 87#ifndef OPENSSL_NO_ENGINE
96 if ((ret->pkey.rsa=d2i_RSAPrivateKey(NULL, 88 if (ret->engine)
97 (const unsigned char **)pp,length)) == NULL) /* TMP UGLY CAST */
98 { 89 {
99 ASN1err(ASN1_F_D2I_PRIVATEKEY,ERR_R_ASN1_LIB); 90 ENGINE_finish(ret->engine);
100 goto err; 91 ret->engine = NULL;
101 } 92 }
102 break;
103#endif 93#endif
104#ifndef OPENSSL_NO_DSA 94 }
105 case EVP_PKEY_DSA: 95
106 if ((ret->pkey.dsa=d2i_DSAPrivateKey(NULL, 96 if (!EVP_PKEY_set_type(ret, type))
107 (const unsigned char **)pp,length)) == NULL) /* TMP UGLY CAST */ 97 {
98 ASN1err(ASN1_F_D2I_PRIVATEKEY,ASN1_R_UNKNOWN_PUBLIC_KEY_TYPE);
99 goto err;
100 }
101
102 if (!ret->ameth->old_priv_decode ||
103 !ret->ameth->old_priv_decode(ret, pp, length))
104 {
105 if (ret->ameth->priv_decode)
108 { 106 {
109 ASN1err(ASN1_F_D2I_PRIVATEKEY,ERR_R_ASN1_LIB); 107 PKCS8_PRIV_KEY_INFO *p8=NULL;
110 goto err; 108 p8=d2i_PKCS8_PRIV_KEY_INFO(NULL,pp,length);
111 } 109 if (!p8) goto err;
112 break; 110 EVP_PKEY_free(ret);
113#endif 111 ret = EVP_PKCS82PKEY(p8);
114#ifndef OPENSSL_NO_EC 112 PKCS8_PRIV_KEY_INFO_free(p8);
115 case EVP_PKEY_EC: 113
116 if ((ret->pkey.ec = d2i_ECPrivateKey(NULL, 114 }
117 (const unsigned char **)pp, length)) == NULL) 115 else
118 { 116 {
119 ASN1err(ASN1_F_D2I_PRIVATEKEY, ERR_R_ASN1_LIB); 117 ASN1err(ASN1_F_D2I_PRIVATEKEY,ERR_R_ASN1_LIB);
120 goto err; 118 goto err;
121 } 119 }
122 break; 120 }
123#endif
124 default:
125 ASN1err(ASN1_F_D2I_PRIVATEKEY,ASN1_R_UNKNOWN_PUBLIC_KEY_TYPE);
126 goto err;
127 /* break; */
128 }
129 if (a != NULL) (*a)=ret; 121 if (a != NULL) (*a)=ret;
130 return(ret); 122 return(ret);
131err: 123err:
@@ -146,8 +138,7 @@ EVP_PKEY *d2i_AutoPrivateKey(EVP_PKEY **a, const unsigned char **pp,
146 * by analyzing it we can determine the passed structure: this 138 * by analyzing it we can determine the passed structure: this
147 * assumes the input is surrounded by an ASN1 SEQUENCE. 139 * assumes the input is surrounded by an ASN1 SEQUENCE.
148 */ 140 */
149 inkey = d2i_ASN1_SET_OF_ASN1_TYPE(NULL, &p, length, d2i_ASN1_TYPE, 141 inkey = d2i_ASN1_SEQUENCE_ANY(NULL, &p, length);
150 ASN1_TYPE_free, V_ASN1_SEQUENCE, V_ASN1_UNIVERSAL);
151 /* Since we only need to discern "traditional format" RSA and DSA 142 /* Since we only need to discern "traditional format" RSA and DSA
152 * keys we can just count the elements. 143 * keys we can just count the elements.
153 */ 144 */
@@ -155,6 +146,24 @@ EVP_PKEY *d2i_AutoPrivateKey(EVP_PKEY **a, const unsigned char **pp,
155 keytype = EVP_PKEY_DSA; 146 keytype = EVP_PKEY_DSA;
156 else if (sk_ASN1_TYPE_num(inkey) == 4) 147 else if (sk_ASN1_TYPE_num(inkey) == 4)
157 keytype = EVP_PKEY_EC; 148 keytype = EVP_PKEY_EC;
149 else if (sk_ASN1_TYPE_num(inkey) == 3)
150 { /* This seems to be PKCS8, not traditional format */
151 PKCS8_PRIV_KEY_INFO *p8 = d2i_PKCS8_PRIV_KEY_INFO(NULL,pp,length);
152 EVP_PKEY *ret;
153
154 sk_ASN1_TYPE_pop_free(inkey, ASN1_TYPE_free);
155 if (!p8)
156 {
157 ASN1err(ASN1_F_D2I_AUTOPRIVATEKEY,ASN1_R_UNSUPPORTED_PUBLIC_KEY_TYPE);
158 return NULL;
159 }
160 ret = EVP_PKCS82PKEY(p8);
161 PKCS8_PRIV_KEY_INFO_free(p8);
162 if (a) {
163 *a = ret;
164 }
165 return ret;
166 }
158 else keytype = EVP_PKEY_RSA; 167 else keytype = EVP_PKEY_RSA;
159 sk_ASN1_TYPE_pop_free(inkey, ASN1_TYPE_free); 168 sk_ASN1_TYPE_pop_free(inkey, ASN1_TYPE_free);
160 return d2i_PrivateKey(keytype, a, pp, length); 169 return d2i_PrivateKey(keytype, a, pp, length);
diff --git a/src/lib/libcrypto/asn1/d2i_pu.c b/src/lib/libcrypto/asn1/d2i_pu.c
index 3694f51a8c..c8f39ceb03 100644
--- a/src/lib/libcrypto/asn1/d2i_pu.c
+++ b/src/lib/libcrypto/asn1/d2i_pu.c
@@ -87,9 +87,13 @@ EVP_PKEY *d2i_PublicKey(int type, EVP_PKEY **a, const unsigned char **pp,
87 } 87 }
88 else ret= *a; 88 else ret= *a;
89 89
90 ret->save_type=type; 90 if (!EVP_PKEY_set_type(ret, type))
91 ret->type=EVP_PKEY_type(type); 91 {
92 switch (ret->type) 92 ASN1err(ASN1_F_D2I_PUBLICKEY,ERR_R_EVP_LIB);
93 goto err;
94 }
95
96 switch (EVP_PKEY_id(ret))
93 { 97 {
94#ifndef OPENSSL_NO_RSA 98#ifndef OPENSSL_NO_RSA
95 case EVP_PKEY_RSA: 99 case EVP_PKEY_RSA:
diff --git a/src/lib/libcrypto/asn1/f.c b/src/lib/libcrypto/asn1/f.c
deleted file mode 100644
index 82bccdfd51..0000000000
--- a/src/lib/libcrypto/asn1/f.c
+++ /dev/null
@@ -1,80 +0,0 @@
1/* crypto/asn1/f.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#include <stdio.h>
59#include <openssl/asn1.h>
60#include <openssl/err.h>
61
62main()
63 {
64 ASN1_TYPE *at;
65 char buf[512];
66 int n;
67 long l;
68
69 at=ASN1_TYPE_new();
70
71 n=ASN1_TYPE_set_int_octetstring(at,98736,"01234567",8);
72 printf("%d\n",n);
73 n=ASN1_TYPE_get_int_octetstring(at,&l,buf,8);
74 buf[8]='\0';
75 printf("%ld %d %d\n",l,n,buf[8]);
76 buf[8]='\0';
77 printf("%s\n",buf);
78 ERR_load_crypto_strings();
79 ERR_print_errors_fp(stderr);
80 }
diff --git a/src/lib/libcrypto/asn1/i2d_pr.c b/src/lib/libcrypto/asn1/i2d_pr.c
index 0be52c5b76..e398b62666 100644
--- a/src/lib/libcrypto/asn1/i2d_pr.c
+++ b/src/lib/libcrypto/asn1/i2d_pr.c
@@ -58,41 +58,22 @@
58 58
59#include <stdio.h> 59#include <stdio.h>
60#include "cryptlib.h" 60#include "cryptlib.h"
61#include <openssl/bn.h>
62#include <openssl/evp.h> 61#include <openssl/evp.h>
63#include <openssl/objects.h> 62#include <openssl/x509.h>
64#ifndef OPENSSL_NO_RSA 63#include "asn1_locl.h"
65#include <openssl/rsa.h>
66#endif
67#ifndef OPENSSL_NO_DSA
68#include <openssl/dsa.h>
69#endif
70#ifndef OPENSSL_NO_EC
71#include <openssl/ec.h>
72#endif
73 64
74int i2d_PrivateKey(EVP_PKEY *a, unsigned char **pp) 65int i2d_PrivateKey(EVP_PKEY *a, unsigned char **pp)
75 { 66 {
76#ifndef OPENSSL_NO_RSA 67 if (a->ameth && a->ameth->old_priv_encode)
77 if (a->type == EVP_PKEY_RSA)
78 { 68 {
79 return(i2d_RSAPrivateKey(a->pkey.rsa,pp)); 69 return a->ameth->old_priv_encode(a, pp);
80 } 70 }
81 else 71 if (a->ameth && a->ameth->priv_encode) {
82#endif 72 PKCS8_PRIV_KEY_INFO *p8 = EVP_PKEY2PKCS8(a);
83#ifndef OPENSSL_NO_DSA 73 int ret = i2d_PKCS8_PRIV_KEY_INFO(p8,pp);
84 if (a->type == EVP_PKEY_DSA) 74 PKCS8_PRIV_KEY_INFO_free(p8);
85 { 75 return ret;
86 return(i2d_DSAPrivateKey(a->pkey.dsa,pp)); 76 }
87 }
88#endif
89#ifndef OPENSSL_NO_EC
90 if (a->type == EVP_PKEY_EC)
91 {
92 return(i2d_ECPrivateKey(a->pkey.ec, pp));
93 }
94#endif
95
96 ASN1err(ASN1_F_I2D_PRIVATEKEY,ASN1_R_UNSUPPORTED_PUBLIC_KEY_TYPE); 77 ASN1err(ASN1_F_I2D_PRIVATEKEY,ASN1_R_UNSUPPORTED_PUBLIC_KEY_TYPE);
97 return(-1); 78 return(-1);
98 } 79 }
diff --git a/src/lib/libcrypto/asn1/nsseq.c b/src/lib/libcrypto/asn1/nsseq.c
index e551c57d59..b8c4202230 100644
--- a/src/lib/libcrypto/asn1/nsseq.c
+++ b/src/lib/libcrypto/asn1/nsseq.c
@@ -3,7 +3,7 @@
3 * project 1999. 3 * project 1999.
4 */ 4 */
5/* ==================================================================== 5/* ====================================================================
6 * Copyright (c) 1999 The OpenSSL Project. All rights reserved. 6 * Copyright (c) 1999-2005 The OpenSSL Project. All rights reserved.
7 * 7 *
8 * Redistribution and use in source and binary forms, with or without 8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions 9 * modification, are permitted provided that the following conditions
@@ -62,7 +62,8 @@
62#include <openssl/x509.h> 62#include <openssl/x509.h>
63#include <openssl/objects.h> 63#include <openssl/objects.h>
64 64
65static int nsseq_cb(int operation, ASN1_VALUE **pval, const ASN1_ITEM *it) 65static int nsseq_cb(int operation, ASN1_VALUE **pval, const ASN1_ITEM *it,
66 void *exarg)
66{ 67{
67 if(operation == ASN1_OP_NEW_POST) { 68 if(operation == ASN1_OP_NEW_POST) {
68 NETSCAPE_CERT_SEQUENCE *nsseq; 69 NETSCAPE_CERT_SEQUENCE *nsseq;
diff --git a/src/lib/libcrypto/asn1/p5_pbe.c b/src/lib/libcrypto/asn1/p5_pbe.c
index c4582f8041..94bc38b99f 100644
--- a/src/lib/libcrypto/asn1/p5_pbe.c
+++ b/src/lib/libcrypto/asn1/p5_pbe.c
@@ -71,61 +71,78 @@ ASN1_SEQUENCE(PBEPARAM) = {
71 71
72IMPLEMENT_ASN1_FUNCTIONS(PBEPARAM) 72IMPLEMENT_ASN1_FUNCTIONS(PBEPARAM)
73 73
74/* Return an algorithm identifier for a PKCS#5 PBE algorithm */
75 74
76X509_ALGOR *PKCS5_pbe_set(int alg, int iter, unsigned char *salt, 75/* Set an algorithm identifier for a PKCS#5 PBE algorithm */
77 int saltlen) 76
78{ 77int PKCS5_pbe_set0_algor(X509_ALGOR *algor, int alg, int iter,
78 const unsigned char *salt, int saltlen)
79 {
79 PBEPARAM *pbe=NULL; 80 PBEPARAM *pbe=NULL;
80 ASN1_OBJECT *al; 81 ASN1_STRING *pbe_str=NULL;
81 X509_ALGOR *algor; 82 unsigned char *sstr;
82 ASN1_TYPE *astype=NULL;
83 83
84 if (!(pbe = PBEPARAM_new ())) { 84 pbe = PBEPARAM_new();
85 ASN1err(ASN1_F_PKCS5_PBE_SET,ERR_R_MALLOC_FAILURE); 85 if (!pbe)
86 {
87 ASN1err(ASN1_F_PKCS5_PBE_SET0_ALGOR,ERR_R_MALLOC_FAILURE);
86 goto err; 88 goto err;
87 } 89 }
88 if(iter <= 0) iter = PKCS5_DEFAULT_ITER; 90 if(iter <= 0)
89 if (!ASN1_INTEGER_set(pbe->iter, iter)) { 91 iter = PKCS5_DEFAULT_ITER;
90 ASN1err(ASN1_F_PKCS5_PBE_SET,ERR_R_MALLOC_FAILURE); 92 if (!ASN1_INTEGER_set(pbe->iter, iter))
93 {
94 ASN1err(ASN1_F_PKCS5_PBE_SET0_ALGOR,ERR_R_MALLOC_FAILURE);
91 goto err; 95 goto err;
92 } 96 }
93 if (!saltlen) saltlen = PKCS5_SALT_LEN; 97 if (!saltlen)
94 if (!(pbe->salt->data = OPENSSL_malloc (saltlen))) { 98 saltlen = PKCS5_SALT_LEN;
95 ASN1err(ASN1_F_PKCS5_PBE_SET,ERR_R_MALLOC_FAILURE); 99 if (!ASN1_STRING_set(pbe->salt, NULL, saltlen))
100 {
101 ASN1err(ASN1_F_PKCS5_PBE_SET0_ALGOR,ERR_R_MALLOC_FAILURE);
96 goto err; 102 goto err;
97 } 103 }
98 pbe->salt->length = saltlen; 104 sstr = ASN1_STRING_data(pbe->salt);
99 if (salt) memcpy (pbe->salt->data, salt, saltlen); 105 if (salt)
100 else if (RAND_pseudo_bytes (pbe->salt->data, saltlen) < 0) 106 memcpy(sstr, salt, saltlen);
107 else if (RAND_pseudo_bytes(sstr, saltlen) < 0)
101 goto err; 108 goto err;
102 109
103 if (!(astype = ASN1_TYPE_new())) { 110 if(!ASN1_item_pack(pbe, ASN1_ITEM_rptr(PBEPARAM), &pbe_str))
104 ASN1err(ASN1_F_PKCS5_PBE_SET,ERR_R_MALLOC_FAILURE); 111 {
112 ASN1err(ASN1_F_PKCS5_PBE_SET0_ALGOR,ERR_R_MALLOC_FAILURE);
105 goto err; 113 goto err;
106 } 114 }
107 115
108 astype->type = V_ASN1_SEQUENCE; 116 PBEPARAM_free(pbe);
109 if(!ASN1_pack_string_of(PBEPARAM, pbe, i2d_PBEPARAM,
110 &astype->value.sequence)) {
111 ASN1err(ASN1_F_PKCS5_PBE_SET,ERR_R_MALLOC_FAILURE);
112 goto err;
113 }
114 PBEPARAM_free (pbe);
115 pbe = NULL; 117 pbe = NULL;
116
117 al = OBJ_nid2obj(alg); /* never need to free al */
118 if (!(algor = X509_ALGOR_new())) {
119 ASN1err(ASN1_F_PKCS5_PBE_SET,ERR_R_MALLOC_FAILURE);
120 goto err;
121 }
122 ASN1_OBJECT_free(algor->algorithm);
123 algor->algorithm = al;
124 algor->parameter = astype;
125 118
126 return (algor); 119 if (X509_ALGOR_set0(algor, OBJ_nid2obj(alg), V_ASN1_SEQUENCE, pbe_str))
120 return 1;
121
127err: 122err:
128 if (pbe != NULL) PBEPARAM_free(pbe); 123 if (pbe != NULL)
129 if (astype != NULL) ASN1_TYPE_free(astype); 124 PBEPARAM_free(pbe);
125 if (pbe_str != NULL)
126 ASN1_STRING_free(pbe_str);
127 return 0;
128 }
129
130/* Return an algorithm identifier for a PKCS#5 PBE algorithm */
131
132X509_ALGOR *PKCS5_pbe_set(int alg, int iter,
133 const unsigned char *salt, int saltlen)
134 {
135 X509_ALGOR *ret;
136 ret = X509_ALGOR_new();
137 if (!ret)
138 {
139 ASN1err(ASN1_F_PKCS5_PBE_SET,ERR_R_MALLOC_FAILURE);
140 return NULL;
141 }
142
143 if (PKCS5_pbe_set0_algor(ret, alg, iter, salt, saltlen))
144 return ret;
145
146 X509_ALGOR_free(ret);
130 return NULL; 147 return NULL;
131} 148 }
diff --git a/src/lib/libcrypto/asn1/p5_pbev2.c b/src/lib/libcrypto/asn1/p5_pbev2.c
index 2b0516afee..cb49b6651d 100644
--- a/src/lib/libcrypto/asn1/p5_pbev2.c
+++ b/src/lib/libcrypto/asn1/p5_pbev2.c
@@ -82,10 +82,13 @@ IMPLEMENT_ASN1_FUNCTIONS(PBKDF2PARAM)
82 82
83/* Return an algorithm identifier for a PKCS#5 v2.0 PBE algorithm: 83/* Return an algorithm identifier for a PKCS#5 v2.0 PBE algorithm:
84 * yes I know this is horrible! 84 * yes I know this is horrible!
85 *
86 * Extended version to allow application supplied PRF NID and IV.
85 */ 87 */
86 88
87X509_ALGOR *PKCS5_pbe2_set(const EVP_CIPHER *cipher, int iter, 89X509_ALGOR *PKCS5_pbe2_set_iv(const EVP_CIPHER *cipher, int iter,
88 unsigned char *salt, int saltlen) 90 unsigned char *salt, int saltlen,
91 unsigned char *aiv, int prf_nid)
89{ 92{
90 X509_ALGOR *scheme = NULL, *kalg = NULL, *ret = NULL; 93 X509_ALGOR *scheme = NULL, *kalg = NULL, *ret = NULL;
91 int alg_nid; 94 int alg_nid;
@@ -98,7 +101,7 @@ X509_ALGOR *PKCS5_pbe2_set(const EVP_CIPHER *cipher, int iter,
98 101
99 alg_nid = EVP_CIPHER_type(cipher); 102 alg_nid = EVP_CIPHER_type(cipher);
100 if(alg_nid == NID_undef) { 103 if(alg_nid == NID_undef) {
101 ASN1err(ASN1_F_PKCS5_PBE2_SET, 104 ASN1err(ASN1_F_PKCS5_PBE2_SET_IV,
102 ASN1_R_CIPHER_HAS_NO_OBJECT_IDENTIFIER); 105 ASN1_R_CIPHER_HAS_NO_OBJECT_IDENTIFIER);
103 goto err; 106 goto err;
104 } 107 }
@@ -113,20 +116,33 @@ X509_ALGOR *PKCS5_pbe2_set(const EVP_CIPHER *cipher, int iter,
113 if(!(scheme->parameter = ASN1_TYPE_new())) goto merr; 116 if(!(scheme->parameter = ASN1_TYPE_new())) goto merr;
114 117
115 /* Create random IV */ 118 /* Create random IV */
116 if (EVP_CIPHER_iv_length(cipher) && 119 if (EVP_CIPHER_iv_length(cipher))
117 RAND_pseudo_bytes(iv, EVP_CIPHER_iv_length(cipher)) < 0) 120 {
118 goto err; 121 if (aiv)
122 memcpy(iv, aiv, EVP_CIPHER_iv_length(cipher));
123 else if (RAND_pseudo_bytes(iv, EVP_CIPHER_iv_length(cipher)) < 0)
124 goto err;
125 }
119 126
120 EVP_CIPHER_CTX_init(&ctx); 127 EVP_CIPHER_CTX_init(&ctx);
121 128
122 /* Dummy cipherinit to just setup the IV */ 129 /* Dummy cipherinit to just setup the IV, and PRF */
123 EVP_CipherInit_ex(&ctx, cipher, NULL, NULL, iv, 0); 130 EVP_CipherInit_ex(&ctx, cipher, NULL, NULL, iv, 0);
124 if(EVP_CIPHER_param_to_asn1(&ctx, scheme->parameter) < 0) { 131 if(EVP_CIPHER_param_to_asn1(&ctx, scheme->parameter) < 0) {
125 ASN1err(ASN1_F_PKCS5_PBE2_SET, 132 ASN1err(ASN1_F_PKCS5_PBE2_SET_IV,
126 ASN1_R_ERROR_SETTING_CIPHER_PARAMS); 133 ASN1_R_ERROR_SETTING_CIPHER_PARAMS);
127 EVP_CIPHER_CTX_cleanup(&ctx); 134 EVP_CIPHER_CTX_cleanup(&ctx);
128 goto err; 135 goto err;
129 } 136 }
137 /* If prf NID unspecified see if cipher has a preference.
138 * An error is OK here: just means use default PRF.
139 */
140 if ((prf_nid == -1) &&
141 EVP_CIPHER_CTX_ctrl(&ctx, EVP_CTRL_PBE_PRF_NID, 0, &prf_nid) <= 0)
142 {
143 ERR_clear_error();
144 prf_nid = NID_hmacWithSHA1;
145 }
130 EVP_CIPHER_CTX_cleanup(&ctx); 146 EVP_CIPHER_CTX_cleanup(&ctx);
131 147
132 if(!(kdf = PBKDF2PARAM_new())) goto merr; 148 if(!(kdf = PBKDF2PARAM_new())) goto merr;
@@ -154,7 +170,15 @@ X509_ALGOR *PKCS5_pbe2_set(const EVP_CIPHER *cipher, int iter,
154 EVP_CIPHER_key_length(cipher))) goto merr; 170 EVP_CIPHER_key_length(cipher))) goto merr;
155 } 171 }
156 172
157 /* prf can stay NULL because we are using hmacWithSHA1 */ 173 /* prf can stay NULL if we are using hmacWithSHA1 */
174 if (prf_nid != NID_hmacWithSHA1)
175 {
176 kdf->prf = X509_ALGOR_new();
177 if (!kdf->prf)
178 goto merr;
179 X509_ALGOR_set0(kdf->prf, OBJ_nid2obj(prf_nid),
180 V_ASN1_NULL, NULL);
181 }
158 182
159 /* Now setup the PBE2PARAM keyfunc structure */ 183 /* Now setup the PBE2PARAM keyfunc structure */
160 184
@@ -164,7 +188,7 @@ X509_ALGOR *PKCS5_pbe2_set(const EVP_CIPHER *cipher, int iter,
164 188
165 if(!(pbe2->keyfunc->parameter = ASN1_TYPE_new())) goto merr; 189 if(!(pbe2->keyfunc->parameter = ASN1_TYPE_new())) goto merr;
166 190
167 if(!ASN1_pack_string_of(PBKDF2PARAM, kdf, i2d_PBKDF2PARAM, 191 if(!ASN1_item_pack(kdf, ASN1_ITEM_rptr(PBKDF2PARAM),
168 &pbe2->keyfunc->parameter->value.sequence)) goto merr; 192 &pbe2->keyfunc->parameter->value.sequence)) goto merr;
169 pbe2->keyfunc->parameter->type = V_ASN1_SEQUENCE; 193 pbe2->keyfunc->parameter->type = V_ASN1_SEQUENCE;
170 194
@@ -180,7 +204,7 @@ X509_ALGOR *PKCS5_pbe2_set(const EVP_CIPHER *cipher, int iter,
180 204
181 /* Encode PBE2PARAM into parameter */ 205 /* Encode PBE2PARAM into parameter */
182 206
183 if(!ASN1_pack_string_of(PBE2PARAM, pbe2, i2d_PBE2PARAM, 207 if(!ASN1_item_pack(pbe2, ASN1_ITEM_rptr(PBE2PARAM),
184 &ret->parameter->value.sequence)) goto merr; 208 &ret->parameter->value.sequence)) goto merr;
185 ret->parameter->type = V_ASN1_SEQUENCE; 209 ret->parameter->type = V_ASN1_SEQUENCE;
186 210
@@ -190,7 +214,7 @@ X509_ALGOR *PKCS5_pbe2_set(const EVP_CIPHER *cipher, int iter,
190 return ret; 214 return ret;
191 215
192 merr: 216 merr:
193 ASN1err(ASN1_F_PKCS5_PBE2_SET,ERR_R_MALLOC_FAILURE); 217 ASN1err(ASN1_F_PKCS5_PBE2_SET_IV,ERR_R_MALLOC_FAILURE);
194 218
195 err: 219 err:
196 PBE2PARAM_free(pbe2); 220 PBE2PARAM_free(pbe2);
@@ -203,3 +227,9 @@ X509_ALGOR *PKCS5_pbe2_set(const EVP_CIPHER *cipher, int iter,
203 return NULL; 227 return NULL;
204 228
205} 229}
230
231X509_ALGOR *PKCS5_pbe2_set(const EVP_CIPHER *cipher, int iter,
232 unsigned char *salt, int saltlen)
233 {
234 return PKCS5_pbe2_set_iv(cipher, iter, salt, saltlen, NULL, -1);
235 }
diff --git a/src/lib/libcrypto/asn1/p8_key.c b/src/lib/libcrypto/asn1/p8_key.c
deleted file mode 100644
index 3a31248e14..0000000000
--- a/src/lib/libcrypto/asn1/p8_key.c
+++ /dev/null
@@ -1,131 +0,0 @@
1/* crypto/asn1/p8_key.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 "cryptlib.h"
61#include <openssl/asn1_mac.h>
62#include <openssl/objects.h>
63
64int i2d_X509_KEY(X509 *a, unsigned char **pp)
65 {
66 M_ASN1_I2D_vars(a);
67
68 M_ASN1_I2D_len(a->cert_info, i2d_X509_CINF);
69 M_ASN1_I2D_len(a->sig_alg, i2d_X509_ALGOR);
70 M_ASN1_I2D_len(a->signature, i2d_ASN1_BIT_STRING);
71
72 M_ASN1_I2D_seq_total();
73
74 M_ASN1_I2D_put(a->cert_info, i2d_X509_CINF);
75 M_ASN1_I2D_put(a->sig_alg, i2d_X509_ALGOR);
76 M_ASN1_I2D_put(a->signature, i2d_ASN1_BIT_STRING);
77
78 M_ASN1_I2D_finish();
79 }
80
81X509 *d2i_X509_KEY(X509 **a, unsigned char **pp, long length)
82 {
83 M_ASN1_D2I_vars(a,X509 *,X509_new);
84
85 M_ASN1_D2I_Init();
86 M_ASN1_D2I_start_sequence();
87 M_ASN1_D2I_get(ret->cert_info,d2i_X509_CINF);
88 M_ASN1_D2I_get(ret->sig_alg,d2i_X509_ALGOR);
89 M_ASN1_D2I_get(ret->signature,d2i_ASN1_BIT_STRING);
90 M_ASN1_D2I_Finish(a,X509_free,ASN1_F_D2I_X509);
91 }
92
93X509 *X509_KEY_new(void)
94 {
95 X509_KEY *ret=NULL;
96
97 M_ASN1_New_OPENSSL_malloc(ret,X509_KEY);
98 ret->references=1;
99 ret->type=NID
100 M_ASN1_New(ret->cert_info,X509_CINF_new);
101 M_ASN1_New(ret->sig_alg,X509_ALGOR_new);
102 M_ASN1_New(ret->signature,ASN1_BIT_STRING_new);
103 return(ret);
104 M_ASN1_New_Error(ASN1_F_X509_NEW);
105 }
106
107void X509_KEY_free(X509 *a)
108 {
109 int i;
110
111 if (a == NULL) return;
112
113 i=CRYPTO_add_lock(&a->references,-1,CRYPTO_LOCK_X509_KEY);
114#ifdef REF_PRINT
115 REF_PRINT("X509_KEY",a);
116#endif
117 if (i > 0) return;
118#ifdef REF_CHECK
119 if (i < 0)
120 {
121 fprintf(stderr,"X509_KEY_free, bad reference count\n");
122 abort();
123 }
124#endif
125
126 X509_CINF_free(a->cert_info);
127 X509_ALGOR_free(a->sig_alg);
128 ASN1_BIT_STRING_free(a->signature);
129 OPENSSL_free(a);
130 }
131
diff --git a/src/lib/libcrypto/asn1/p8_pkey.c b/src/lib/libcrypto/asn1/p8_pkey.c
index 0a1957556e..17b68d386d 100644
--- a/src/lib/libcrypto/asn1/p8_pkey.c
+++ b/src/lib/libcrypto/asn1/p8_pkey.c
@@ -3,7 +3,7 @@
3 * project 1999. 3 * project 1999.
4 */ 4 */
5/* ==================================================================== 5/* ====================================================================
6 * Copyright (c) 1999 The OpenSSL Project. All rights reserved. 6 * Copyright (c) 1999-2005 The OpenSSL Project. All rights reserved.
7 * 7 *
8 * Redistribution and use in source and binary forms, with or without 8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions 9 * modification, are permitted provided that the following conditions
@@ -62,7 +62,8 @@
62#include <openssl/x509.h> 62#include <openssl/x509.h>
63 63
64/* Minor tweak to operation: zero private key data */ 64/* Minor tweak to operation: zero private key data */
65static int pkey_cb(int operation, ASN1_VALUE **pval, const ASN1_ITEM *it) 65static int pkey_cb(int operation, ASN1_VALUE **pval, const ASN1_ITEM *it,
66 void *exarg)
66{ 67{
67 /* Since the structure must still be valid use ASN1_OP_FREE_PRE */ 68 /* Since the structure must still be valid use ASN1_OP_FREE_PRE */
68 if(operation == ASN1_OP_FREE_PRE) { 69 if(operation == ASN1_OP_FREE_PRE) {
@@ -82,3 +83,73 @@ ASN1_SEQUENCE_cb(PKCS8_PRIV_KEY_INFO, pkey_cb) = {
82} ASN1_SEQUENCE_END_cb(PKCS8_PRIV_KEY_INFO, PKCS8_PRIV_KEY_INFO) 83} ASN1_SEQUENCE_END_cb(PKCS8_PRIV_KEY_INFO, PKCS8_PRIV_KEY_INFO)
83 84
84IMPLEMENT_ASN1_FUNCTIONS(PKCS8_PRIV_KEY_INFO) 85IMPLEMENT_ASN1_FUNCTIONS(PKCS8_PRIV_KEY_INFO)
86
87int PKCS8_pkey_set0(PKCS8_PRIV_KEY_INFO *priv, ASN1_OBJECT *aobj,
88 int version,
89 int ptype, void *pval,
90 unsigned char *penc, int penclen)
91 {
92 unsigned char **ppenc = NULL;
93 if (version >= 0)
94 {
95 if (!ASN1_INTEGER_set(priv->version, version))
96 return 0;
97 }
98 if (penc)
99 {
100 int pmtype;
101 ASN1_OCTET_STRING *oct;
102 oct = ASN1_OCTET_STRING_new();
103 if (!oct)
104 return 0;
105 oct->data = penc;
106 ppenc = &oct->data;
107 oct->length = penclen;
108 if (priv->broken == PKCS8_NO_OCTET)
109 pmtype = V_ASN1_SEQUENCE;
110 else
111 pmtype = V_ASN1_OCTET_STRING;
112 ASN1_TYPE_set(priv->pkey, pmtype, oct);
113 }
114 if (!X509_ALGOR_set0(priv->pkeyalg, aobj, ptype, pval))
115 {
116 /* If call fails do not swallow 'enc' */
117 if (ppenc)
118 *ppenc = NULL;
119 return 0;
120 }
121 return 1;
122 }
123
124int PKCS8_pkey_get0(ASN1_OBJECT **ppkalg,
125 const unsigned char **pk, int *ppklen,
126 X509_ALGOR **pa,
127 PKCS8_PRIV_KEY_INFO *p8)
128 {
129 if (ppkalg)
130 *ppkalg = p8->pkeyalg->algorithm;
131 if(p8->pkey->type == V_ASN1_OCTET_STRING)
132 {
133 p8->broken = PKCS8_OK;
134 if (pk)
135 {
136 *pk = p8->pkey->value.octet_string->data;
137 *ppklen = p8->pkey->value.octet_string->length;
138 }
139 }
140 else if (p8->pkey->type == V_ASN1_SEQUENCE)
141 {
142 p8->broken = PKCS8_NO_OCTET;
143 if (pk)
144 {
145 *pk = p8->pkey->value.sequence->data;
146 *ppklen = p8->pkey->value.sequence->length;
147 }
148 }
149 else
150 return 0;
151 if (pa)
152 *pa = p8->pkeyalg;
153 return 1;
154 }
155
diff --git a/src/lib/libcrypto/asn1/t_pkey.c b/src/lib/libcrypto/asn1/t_pkey.c
index afb95d6712..9dd18f6579 100644
--- a/src/lib/libcrypto/asn1/t_pkey.c
+++ b/src/lib/libcrypto/asn1/t_pkey.c
@@ -55,520 +55,15 @@
55 * copied and put under another distribution licence 55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.] 56 * [including the GNU Public Licence.]
57 */ 57 */
58/* ====================================================================
59 * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED.
60 * Binary polynomial ECC support in OpenSSL originally developed by
61 * SUN MICROSYSTEMS, INC., and contributed to the OpenSSL project.
62 */
63 58
64#include <stdio.h> 59#include <stdio.h>
65#include "cryptlib.h" 60#include "cryptlib.h"
66#include <openssl/objects.h> 61#include <openssl/objects.h>
67#include <openssl/buffer.h> 62#include <openssl/buffer.h>
68#include <openssl/bn.h> 63#include <openssl/bn.h>
69#ifndef OPENSSL_NO_RSA
70#include <openssl/rsa.h>
71#endif
72#ifndef OPENSSL_NO_DH
73#include <openssl/dh.h>
74#endif
75#ifndef OPENSSL_NO_DSA
76#include <openssl/dsa.h>
77#endif
78#ifndef OPENSSL_NO_EC
79#include <openssl/ec.h>
80#endif
81
82static int print(BIO *fp,const char *str, const BIGNUM *num,
83 unsigned char *buf,int off);
84#ifndef OPENSSL_NO_EC
85static int print_bin(BIO *fp, const char *str, const unsigned char *num,
86 size_t len, int off);
87#endif
88#ifndef OPENSSL_NO_RSA
89#ifndef OPENSSL_NO_FP_API
90int RSA_print_fp(FILE *fp, const RSA *x, int off)
91 {
92 BIO *b;
93 int ret;
94
95 if ((b=BIO_new(BIO_s_file())) == NULL)
96 {
97 RSAerr(RSA_F_RSA_PRINT_FP,ERR_R_BUF_LIB);
98 return(0);
99 }
100 BIO_set_fp(b,fp,BIO_NOCLOSE);
101 ret=RSA_print(b,x,off);
102 BIO_free(b);
103 return(ret);
104 }
105#endif
106
107int RSA_print(BIO *bp, const RSA *x, int off)
108 {
109 char str[128];
110 const char *s;
111 unsigned char *m=NULL;
112 int ret=0, mod_len = 0;
113 size_t buf_len=0, i;
114
115 if (x->n)
116 buf_len = (size_t)BN_num_bytes(x->n);
117 if (x->e)
118 if (buf_len < (i = (size_t)BN_num_bytes(x->e)))
119 buf_len = i;
120 if (x->d)
121 if (buf_len < (i = (size_t)BN_num_bytes(x->d)))
122 buf_len = i;
123 if (x->p)
124 if (buf_len < (i = (size_t)BN_num_bytes(x->p)))
125 buf_len = i;
126 if (x->q)
127 if (buf_len < (i = (size_t)BN_num_bytes(x->q)))
128 buf_len = i;
129 if (x->dmp1)
130 if (buf_len < (i = (size_t)BN_num_bytes(x->dmp1)))
131 buf_len = i;
132 if (x->dmq1)
133 if (buf_len < (i = (size_t)BN_num_bytes(x->dmq1)))
134 buf_len = i;
135 if (x->iqmp)
136 if (buf_len < (i = (size_t)BN_num_bytes(x->iqmp)))
137 buf_len = i;
138
139 m=(unsigned char *)OPENSSL_malloc(buf_len+10);
140 if (m == NULL)
141 {
142 RSAerr(RSA_F_RSA_PRINT,ERR_R_MALLOC_FAILURE);
143 goto err;
144 }
145
146 if (x->n != NULL)
147 mod_len = BN_num_bits(x->n);
148
149 if (x->d != NULL)
150 {
151 if(!BIO_indent(bp,off,128))
152 goto err;
153 if (BIO_printf(bp,"Private-Key: (%d bit)\n", mod_len)
154 <= 0) goto err;
155 }
156
157 if (x->d == NULL)
158 BIO_snprintf(str,sizeof str,"Modulus (%d bit):", mod_len);
159 else
160 BUF_strlcpy(str,"modulus:",sizeof str);
161 if (!print(bp,str,x->n,m,off)) goto err;
162 s=(x->d == NULL)?"Exponent:":"publicExponent:";
163 if ((x->e != NULL) && !print(bp,s,x->e,m,off))
164 goto err;
165 if ((x->d != NULL) && !print(bp,"privateExponent:",x->d,m,off))
166 goto err;
167 if ((x->p != NULL) && !print(bp,"prime1:",x->p,m,off))
168 goto err;
169 if ((x->q != NULL) && !print(bp,"prime2:",x->q,m,off))
170 goto err;
171 if ((x->dmp1 != NULL) && !print(bp,"exponent1:",x->dmp1,m,off))
172 goto err;
173 if ((x->dmq1 != NULL) && !print(bp,"exponent2:",x->dmq1,m,off))
174 goto err;
175 if ((x->iqmp != NULL) && !print(bp,"coefficient:",x->iqmp,m,off))
176 goto err;
177 ret=1;
178err:
179 if (m != NULL) OPENSSL_free(m);
180 return(ret);
181 }
182#endif /* OPENSSL_NO_RSA */
183
184#ifndef OPENSSL_NO_DSA
185#ifndef OPENSSL_NO_FP_API
186int DSA_print_fp(FILE *fp, const DSA *x, int off)
187 {
188 BIO *b;
189 int ret;
190
191 if ((b=BIO_new(BIO_s_file())) == NULL)
192 {
193 DSAerr(DSA_F_DSA_PRINT_FP,ERR_R_BUF_LIB);
194 return(0);
195 }
196 BIO_set_fp(b,fp,BIO_NOCLOSE);
197 ret=DSA_print(b,x,off);
198 BIO_free(b);
199 return(ret);
200 }
201#endif
202
203int DSA_print(BIO *bp, const DSA *x, int off)
204 {
205 unsigned char *m=NULL;
206 int ret=0;
207 size_t buf_len=0,i;
208
209 if (x->p)
210 buf_len = (size_t)BN_num_bytes(x->p);
211 else
212 {
213 DSAerr(DSA_F_DSA_PRINT,DSA_R_MISSING_PARAMETERS);
214 goto err;
215 }
216 if (x->q)
217 if (buf_len < (i = (size_t)BN_num_bytes(x->q)))
218 buf_len = i;
219 if (x->g)
220 if (buf_len < (i = (size_t)BN_num_bytes(x->g)))
221 buf_len = i;
222 if (x->priv_key)
223 if (buf_len < (i = (size_t)BN_num_bytes(x->priv_key)))
224 buf_len = i;
225 if (x->pub_key)
226 if (buf_len < (i = (size_t)BN_num_bytes(x->pub_key)))
227 buf_len = i;
228
229 m=(unsigned char *)OPENSSL_malloc(buf_len+10);
230 if (m == NULL)
231 {
232 DSAerr(DSA_F_DSA_PRINT,ERR_R_MALLOC_FAILURE);
233 goto err;
234 }
235
236 if (x->priv_key != NULL)
237 {
238 if(!BIO_indent(bp,off,128))
239 goto err;
240 if (BIO_printf(bp,"Private-Key: (%d bit)\n",BN_num_bits(x->p))
241 <= 0) goto err;
242 }
243
244 if ((x->priv_key != NULL) && !print(bp,"priv:",x->priv_key,m,off))
245 goto err;
246 if ((x->pub_key != NULL) && !print(bp,"pub: ",x->pub_key,m,off))
247 goto err;
248 if ((x->p != NULL) && !print(bp,"P: ",x->p,m,off)) goto err;
249 if ((x->q != NULL) && !print(bp,"Q: ",x->q,m,off)) goto err;
250 if ((x->g != NULL) && !print(bp,"G: ",x->g,m,off)) goto err;
251 ret=1;
252err:
253 if (m != NULL) OPENSSL_free(m);
254 return(ret);
255 }
256#endif /* !OPENSSL_NO_DSA */
257
258#ifndef OPENSSL_NO_EC
259#ifndef OPENSSL_NO_FP_API
260int ECPKParameters_print_fp(FILE *fp, const EC_GROUP *x, int off)
261 {
262 BIO *b;
263 int ret;
264
265 if ((b=BIO_new(BIO_s_file())) == NULL)
266 {
267 ECerr(EC_F_ECPKPARAMETERS_PRINT_FP,ERR_R_BUF_LIB);
268 return(0);
269 }
270 BIO_set_fp(b, fp, BIO_NOCLOSE);
271 ret = ECPKParameters_print(b, x, off);
272 BIO_free(b);
273 return(ret);
274 }
275
276int EC_KEY_print_fp(FILE *fp, const EC_KEY *x, int off)
277 {
278 BIO *b;
279 int ret;
280
281 if ((b=BIO_new(BIO_s_file())) == NULL)
282 {
283 ECerr(EC_F_EC_KEY_PRINT_FP, ERR_R_BIO_LIB);
284 return(0);
285 }
286 BIO_set_fp(b, fp, BIO_NOCLOSE);
287 ret = EC_KEY_print(b, x, off);
288 BIO_free(b);
289 return(ret);
290 }
291#endif
292
293int ECPKParameters_print(BIO *bp, const EC_GROUP *x, int off)
294 {
295 unsigned char *buffer=NULL;
296 size_t buf_len=0, i;
297 int ret=0, reason=ERR_R_BIO_LIB;
298 BN_CTX *ctx=NULL;
299 const EC_POINT *point=NULL;
300 BIGNUM *p=NULL, *a=NULL, *b=NULL, *gen=NULL,
301 *order=NULL, *cofactor=NULL;
302 const unsigned char *seed;
303 size_t seed_len=0;
304
305 static const char *gen_compressed = "Generator (compressed):";
306 static const char *gen_uncompressed = "Generator (uncompressed):";
307 static const char *gen_hybrid = "Generator (hybrid):";
308
309 if (!x)
310 {
311 reason = ERR_R_PASSED_NULL_PARAMETER;
312 goto err;
313 }
314
315 if (EC_GROUP_get_asn1_flag(x))
316 {
317 /* the curve parameter are given by an asn1 OID */
318 int nid;
319
320 if (!BIO_indent(bp, off, 128))
321 goto err;
322
323 nid = EC_GROUP_get_curve_name(x);
324 if (nid == 0)
325 goto err;
326
327 if (BIO_printf(bp, "ASN1 OID: %s", OBJ_nid2sn(nid)) <= 0)
328 goto err;
329 if (BIO_printf(bp, "\n") <= 0)
330 goto err;
331 }
332 else
333 {
334 /* explicit parameters */
335 int is_char_two = 0;
336 point_conversion_form_t form;
337 int tmp_nid = EC_METHOD_get_field_type(EC_GROUP_method_of(x));
338
339 if (tmp_nid == NID_X9_62_characteristic_two_field)
340 is_char_two = 1;
341
342 if ((p = BN_new()) == NULL || (a = BN_new()) == NULL ||
343 (b = BN_new()) == NULL || (order = BN_new()) == NULL ||
344 (cofactor = BN_new()) == NULL)
345 {
346 reason = ERR_R_MALLOC_FAILURE;
347 goto err;
348 }
349
350 if (is_char_two)
351 {
352 if (!EC_GROUP_get_curve_GF2m(x, p, a, b, ctx))
353 {
354 reason = ERR_R_EC_LIB;
355 goto err;
356 }
357 }
358 else /* prime field */
359 {
360 if (!EC_GROUP_get_curve_GFp(x, p, a, b, ctx))
361 {
362 reason = ERR_R_EC_LIB;
363 goto err;
364 }
365 }
366
367 if ((point = EC_GROUP_get0_generator(x)) == NULL)
368 {
369 reason = ERR_R_EC_LIB;
370 goto err;
371 }
372 if (!EC_GROUP_get_order(x, order, NULL) ||
373 !EC_GROUP_get_cofactor(x, cofactor, NULL))
374 {
375 reason = ERR_R_EC_LIB;
376 goto err;
377 }
378
379 form = EC_GROUP_get_point_conversion_form(x);
380
381 if ((gen = EC_POINT_point2bn(x, point,
382 form, NULL, ctx)) == NULL)
383 {
384 reason = ERR_R_EC_LIB;
385 goto err;
386 }
387
388 buf_len = (size_t)BN_num_bytes(p);
389 if (buf_len < (i = (size_t)BN_num_bytes(a)))
390 buf_len = i;
391 if (buf_len < (i = (size_t)BN_num_bytes(b)))
392 buf_len = i;
393 if (buf_len < (i = (size_t)BN_num_bytes(gen)))
394 buf_len = i;
395 if (buf_len < (i = (size_t)BN_num_bytes(order)))
396 buf_len = i;
397 if (buf_len < (i = (size_t)BN_num_bytes(cofactor)))
398 buf_len = i;
399
400 if ((seed = EC_GROUP_get0_seed(x)) != NULL)
401 seed_len = EC_GROUP_get_seed_len(x);
402
403 buf_len += 10;
404 if ((buffer = OPENSSL_malloc(buf_len)) == NULL)
405 {
406 reason = ERR_R_MALLOC_FAILURE;
407 goto err;
408 }
409
410 if (!BIO_indent(bp, off, 128))
411 goto err;
412
413 /* print the 'short name' of the field type */
414 if (BIO_printf(bp, "Field Type: %s\n", OBJ_nid2sn(tmp_nid))
415 <= 0)
416 goto err;
417
418 if (is_char_two)
419 {
420 /* print the 'short name' of the base type OID */
421 int basis_type = EC_GROUP_get_basis_type(x);
422 if (basis_type == 0)
423 goto err;
424
425 if (!BIO_indent(bp, off, 128))
426 goto err;
427
428 if (BIO_printf(bp, "Basis Type: %s\n",
429 OBJ_nid2sn(basis_type)) <= 0)
430 goto err;
431
432 /* print the polynomial */
433 if ((p != NULL) && !print(bp, "Polynomial:", p, buffer,
434 off))
435 goto err;
436 }
437 else
438 {
439 if ((p != NULL) && !print(bp, "Prime:", p, buffer,off))
440 goto err;
441 }
442 if ((a != NULL) && !print(bp, "A: ", a, buffer, off))
443 goto err;
444 if ((b != NULL) && !print(bp, "B: ", b, buffer, off))
445 goto err;
446 if (form == POINT_CONVERSION_COMPRESSED)
447 {
448 if ((gen != NULL) && !print(bp, gen_compressed, gen,
449 buffer, off))
450 goto err;
451 }
452 else if (form == POINT_CONVERSION_UNCOMPRESSED)
453 {
454 if ((gen != NULL) && !print(bp, gen_uncompressed, gen,
455 buffer, off))
456 goto err;
457 }
458 else /* form == POINT_CONVERSION_HYBRID */
459 {
460 if ((gen != NULL) && !print(bp, gen_hybrid, gen,
461 buffer, off))
462 goto err;
463 }
464 if ((order != NULL) && !print(bp, "Order: ", order,
465 buffer, off)) goto err;
466 if ((cofactor != NULL) && !print(bp, "Cofactor: ", cofactor,
467 buffer, off)) goto err;
468 if (seed && !print_bin(bp, "Seed:", seed, seed_len, off))
469 goto err;
470 }
471 ret=1;
472err:
473 if (!ret)
474 ECerr(EC_F_ECPKPARAMETERS_PRINT, reason);
475 if (p)
476 BN_free(p);
477 if (a)
478 BN_free(a);
479 if (b)
480 BN_free(b);
481 if (gen)
482 BN_free(gen);
483 if (order)
484 BN_free(order);
485 if (cofactor)
486 BN_free(cofactor);
487 if (ctx)
488 BN_CTX_free(ctx);
489 if (buffer != NULL)
490 OPENSSL_free(buffer);
491 return(ret);
492 }
493 64
494int EC_KEY_print(BIO *bp, const EC_KEY *x, int off) 65int ASN1_bn_print(BIO *bp, const char *number, const BIGNUM *num,
495 { 66 unsigned char *buf, int off)
496 unsigned char *buffer=NULL;
497 size_t buf_len=0, i;
498 int ret=0, reason=ERR_R_BIO_LIB;
499 BIGNUM *pub_key=NULL, *order=NULL;
500 BN_CTX *ctx=NULL;
501 const EC_GROUP *group;
502 const EC_POINT *public_key;
503 const BIGNUM *priv_key;
504
505 if (x == NULL || (group = EC_KEY_get0_group(x)) == NULL)
506 {
507 reason = ERR_R_PASSED_NULL_PARAMETER;
508 goto err;
509 }
510
511 public_key = EC_KEY_get0_public_key(x);
512 if ((pub_key = EC_POINT_point2bn(group, public_key,
513 EC_KEY_get_conv_form(x), NULL, ctx)) == NULL)
514 {
515 reason = ERR_R_EC_LIB;
516 goto err;
517 }
518
519 buf_len = (size_t)BN_num_bytes(pub_key);
520 priv_key = EC_KEY_get0_private_key(x);
521 if (priv_key != NULL)
522 {
523 if ((i = (size_t)BN_num_bytes(priv_key)) > buf_len)
524 buf_len = i;
525 }
526
527 buf_len += 10;
528 if ((buffer = OPENSSL_malloc(buf_len)) == NULL)
529 {
530 reason = ERR_R_MALLOC_FAILURE;
531 goto err;
532 }
533
534 if (priv_key != NULL)
535 {
536 if (!BIO_indent(bp, off, 128))
537 goto err;
538 if ((order = BN_new()) == NULL)
539 goto err;
540 if (!EC_GROUP_get_order(group, order, NULL))
541 goto err;
542 if (BIO_printf(bp, "Private-Key: (%d bit)\n",
543 BN_num_bits(order)) <= 0) goto err;
544 }
545
546 if ((priv_key != NULL) && !print(bp, "priv:", priv_key,
547 buffer, off))
548 goto err;
549 if ((pub_key != NULL) && !print(bp, "pub: ", pub_key,
550 buffer, off))
551 goto err;
552 if (!ECPKParameters_print(bp, group, off))
553 goto err;
554 ret=1;
555err:
556 if (!ret)
557 ECerr(EC_F_EC_KEY_PRINT, reason);
558 if (pub_key)
559 BN_free(pub_key);
560 if (order)
561 BN_free(order);
562 if (ctx)
563 BN_CTX_free(ctx);
564 if (buffer != NULL)
565 OPENSSL_free(buffer);
566 return(ret);
567 }
568#endif /* OPENSSL_NO_EC */
569
570static int print(BIO *bp, const char *number, const BIGNUM *num, unsigned char *buf,
571 int off)
572 { 67 {
573 int n,i; 68 int n,i;
574 const char *neg; 69 const char *neg;
@@ -617,223 +112,3 @@ static int print(BIO *bp, const char *number, const BIGNUM *num, unsigned char *
617 } 112 }
618 return(1); 113 return(1);
619 } 114 }
620
621#ifndef OPENSSL_NO_EC
622static int print_bin(BIO *fp, const char *name, const unsigned char *buf,
623 size_t len, int off)
624 {
625 size_t i;
626 char str[128];
627
628 if (buf == NULL)
629 return 1;
630 if (off)
631 {
632 if (off > 128)
633 off=128;
634 memset(str,' ',off);
635 if (BIO_write(fp, str, off) <= 0)
636 return 0;
637 }
638
639 if (BIO_printf(fp,"%s", name) <= 0)
640 return 0;
641
642 for (i=0; i<len; i++)
643 {
644 if ((i%15) == 0)
645 {
646 str[0]='\n';
647 memset(&(str[1]),' ',off+4);
648 if (BIO_write(fp, str, off+1+4) <= 0)
649 return 0;
650 }
651 if (BIO_printf(fp,"%02x%s",buf[i],((i+1) == len)?"":":") <= 0)
652 return 0;
653 }
654 if (BIO_write(fp,"\n",1) <= 0)
655 return 0;
656
657 return 1;
658 }
659#endif
660
661#ifndef OPENSSL_NO_DH
662#ifndef OPENSSL_NO_FP_API
663int DHparams_print_fp(FILE *fp, const DH *x)
664 {
665 BIO *b;
666 int ret;
667
668 if ((b=BIO_new(BIO_s_file())) == NULL)
669 {
670 DHerr(DH_F_DHPARAMS_PRINT_FP,ERR_R_BUF_LIB);
671 return(0);
672 }
673 BIO_set_fp(b,fp,BIO_NOCLOSE);
674 ret=DHparams_print(b, x);
675 BIO_free(b);
676 return(ret);
677 }
678#endif
679
680int DHparams_print(BIO *bp, const DH *x)
681 {
682 unsigned char *m=NULL;
683 int reason=ERR_R_BUF_LIB,ret=0;
684 size_t buf_len=0, i;
685
686 if (x->p)
687 buf_len = (size_t)BN_num_bytes(x->p);
688 else
689 {
690 reason = ERR_R_PASSED_NULL_PARAMETER;
691 goto err;
692 }
693 if (x->g)
694 if (buf_len < (i = (size_t)BN_num_bytes(x->g)))
695 buf_len = i;
696 m=(unsigned char *)OPENSSL_malloc(buf_len+10);
697 if (m == NULL)
698 {
699 reason=ERR_R_MALLOC_FAILURE;
700 goto err;
701 }
702
703 if (BIO_printf(bp,"Diffie-Hellman-Parameters: (%d bit)\n",
704 BN_num_bits(x->p)) <= 0)
705 goto err;
706 if (!print(bp,"prime:",x->p,m,4)) goto err;
707 if (!print(bp,"generator:",x->g,m,4)) goto err;
708 if (x->length != 0)
709 {
710 if (BIO_printf(bp," recommended-private-length: %d bits\n",
711 (int)x->length) <= 0) goto err;
712 }
713 ret=1;
714 if (0)
715 {
716err:
717 DHerr(DH_F_DHPARAMS_PRINT,reason);
718 }
719 if (m != NULL) OPENSSL_free(m);
720 return(ret);
721 }
722#endif
723
724#ifndef OPENSSL_NO_DSA
725#ifndef OPENSSL_NO_FP_API
726int DSAparams_print_fp(FILE *fp, const DSA *x)
727 {
728 BIO *b;
729 int ret;
730
731 if ((b=BIO_new(BIO_s_file())) == NULL)
732 {
733 DSAerr(DSA_F_DSAPARAMS_PRINT_FP,ERR_R_BUF_LIB);
734 return(0);
735 }
736 BIO_set_fp(b,fp,BIO_NOCLOSE);
737 ret=DSAparams_print(b, x);
738 BIO_free(b);
739 return(ret);
740 }
741#endif
742
743int DSAparams_print(BIO *bp, const DSA *x)
744 {
745 unsigned char *m=NULL;
746 int ret=0;
747 size_t buf_len=0,i;
748
749 if (x->p)
750 buf_len = (size_t)BN_num_bytes(x->p);
751 else
752 {
753 DSAerr(DSA_F_DSAPARAMS_PRINT,DSA_R_MISSING_PARAMETERS);
754 goto err;
755 }
756 if (x->q)
757 if (buf_len < (i = (size_t)BN_num_bytes(x->q)))
758 buf_len = i;
759 if (x->g)
760 if (buf_len < (i = (size_t)BN_num_bytes(x->g)))
761 buf_len = i;
762 m=(unsigned char *)OPENSSL_malloc(buf_len+10);
763 if (m == NULL)
764 {
765 DSAerr(DSA_F_DSAPARAMS_PRINT,ERR_R_MALLOC_FAILURE);
766 goto err;
767 }
768
769 if (BIO_printf(bp,"DSA-Parameters: (%d bit)\n",
770 BN_num_bits(x->p)) <= 0)
771 goto err;
772 if (!print(bp,"p:",x->p,m,4)) goto err;
773 if ((x->q != NULL) && !print(bp,"q:",x->q,m,4)) goto err;
774 if ((x->g != NULL) && !print(bp,"g:",x->g,m,4)) goto err;
775 ret=1;
776err:
777 if (m != NULL) OPENSSL_free(m);
778 return(ret);
779 }
780
781#endif /* !OPENSSL_NO_DSA */
782
783#ifndef OPENSSL_NO_EC
784#ifndef OPENSSL_NO_FP_API
785int ECParameters_print_fp(FILE *fp, const EC_KEY *x)
786 {
787 BIO *b;
788 int ret;
789
790 if ((b=BIO_new(BIO_s_file())) == NULL)
791 {
792 ECerr(EC_F_ECPARAMETERS_PRINT_FP, ERR_R_BIO_LIB);
793 return(0);
794 }
795 BIO_set_fp(b, fp, BIO_NOCLOSE);
796 ret = ECParameters_print(b, x);
797 BIO_free(b);
798 return(ret);
799 }
800#endif
801
802int ECParameters_print(BIO *bp, const EC_KEY *x)
803 {
804 int reason=ERR_R_EC_LIB, ret=0;
805 BIGNUM *order=NULL;
806 const EC_GROUP *group;
807
808 if (x == NULL || (group = EC_KEY_get0_group(x)) == NULL)
809 {
810 reason = ERR_R_PASSED_NULL_PARAMETER;;
811 goto err;
812 }
813
814 if ((order = BN_new()) == NULL)
815 {
816 reason = ERR_R_MALLOC_FAILURE;
817 goto err;
818 }
819
820 if (!EC_GROUP_get_order(group, order, NULL))
821 {
822 reason = ERR_R_EC_LIB;
823 goto err;
824 }
825
826 if (BIO_printf(bp, "ECDSA-Parameters: (%d bit)\n",
827 BN_num_bits(order)) <= 0)
828 goto err;
829 if (!ECPKParameters_print(bp, group, 4))
830 goto err;
831 ret=1;
832err:
833 if (order)
834 BN_free(order);
835 ECerr(EC_F_ECPARAMETERS_PRINT, reason);
836 return(ret);
837 }
838
839#endif
diff --git a/src/lib/libcrypto/asn1/t_req.c b/src/lib/libcrypto/asn1/t_req.c
index 5557e06584..ea1794e3e0 100644
--- a/src/lib/libcrypto/asn1/t_req.c
+++ b/src/lib/libcrypto/asn1/t_req.c
@@ -149,34 +149,10 @@ int X509_REQ_print_ex(BIO *bp, X509_REQ *x, unsigned long nmflags, unsigned long
149 ERR_print_errors(bp); 149 ERR_print_errors(bp);
150 } 150 }
151 else 151 else
152#ifndef OPENSSL_NO_RSA
153 if (pkey->type == EVP_PKEY_RSA)
154 {
155 BIO_printf(bp,"%12sRSA Public Key: (%d bit)\n","",
156 BN_num_bits(pkey->pkey.rsa->n));
157 RSA_print(bp,pkey->pkey.rsa,16);
158 }
159 else
160#endif
161#ifndef OPENSSL_NO_DSA
162 if (pkey->type == EVP_PKEY_DSA)
163 { 152 {
164 BIO_printf(bp,"%12sDSA Public Key:\n",""); 153 EVP_PKEY_print_public(bp, pkey, 16, NULL);
165 DSA_print(bp,pkey->pkey.dsa,16); 154 EVP_PKEY_free(pkey);
166 } 155 }
167 else
168#endif
169#ifndef OPENSSL_NO_EC
170 if (pkey->type == EVP_PKEY_EC)
171 {
172 BIO_printf(bp, "%12sEC Public Key: \n","");
173 EC_KEY_print(bp, pkey->pkey.ec, 16);
174 }
175 else
176#endif
177 BIO_printf(bp,"%12sUnknown Public Key:\n","");
178
179 EVP_PKEY_free(pkey);
180 } 156 }
181 157
182 if(!(cflag & X509_FLAG_NO_ATTRIBUTES)) 158 if(!(cflag & X509_FLAG_NO_ATTRIBUTES))
diff --git a/src/lib/libcrypto/asn1/t_spki.c b/src/lib/libcrypto/asn1/t_spki.c
index a73369b949..079c081a81 100644
--- a/src/lib/libcrypto/asn1/t_spki.c
+++ b/src/lib/libcrypto/asn1/t_spki.c
@@ -82,36 +82,11 @@ int NETSCAPE_SPKI_print(BIO *out, NETSCAPE_SPKI *spki)
82 (i == NID_undef)?"UNKNOWN":OBJ_nid2ln(i)); 82 (i == NID_undef)?"UNKNOWN":OBJ_nid2ln(i));
83 pkey = X509_PUBKEY_get(spki->spkac->pubkey); 83 pkey = X509_PUBKEY_get(spki->spkac->pubkey);
84 if(!pkey) BIO_printf(out, " Unable to load public key\n"); 84 if(!pkey) BIO_printf(out, " Unable to load public key\n");
85 else { 85 else
86#ifndef OPENSSL_NO_RSA
87 if (pkey->type == EVP_PKEY_RSA)
88 {
89 BIO_printf(out," RSA Public Key: (%d bit)\n",
90 BN_num_bits(pkey->pkey.rsa->n));
91 RSA_print(out,pkey->pkey.rsa,2);
92 }
93 else
94#endif
95#ifndef OPENSSL_NO_DSA
96 if (pkey->type == EVP_PKEY_DSA)
97 {
98 BIO_printf(out," DSA Public Key:\n");
99 DSA_print(out,pkey->pkey.dsa,2);
100 }
101 else
102#endif
103#ifndef OPENSSL_NO_EC
104 if (pkey->type == EVP_PKEY_EC)
105 { 86 {
106 BIO_printf(out, " EC Public Key:\n"); 87 EVP_PKEY_print_public(out, pkey, 4, NULL);
107 EC_KEY_print(out, pkey->pkey.ec,2);
108 }
109 else
110#endif
111
112 BIO_printf(out," Unknown Public Key:\n");
113 EVP_PKEY_free(pkey); 88 EVP_PKEY_free(pkey);
114 } 89 }
115 chal = spki->spkac->challenge; 90 chal = spki->spkac->challenge;
116 if(chal->length) 91 if(chal->length)
117 BIO_printf(out, " Challenge String: %s\n", chal->data); 92 BIO_printf(out, " Challenge String: %s\n", chal->data);
diff --git a/src/lib/libcrypto/asn1/t_x509.c b/src/lib/libcrypto/asn1/t_x509.c
index 8f746f9c05..e061f2ffad 100644
--- a/src/lib/libcrypto/asn1/t_x509.c
+++ b/src/lib/libcrypto/asn1/t_x509.c
@@ -111,7 +111,6 @@ int X509_print_ex(BIO *bp, X509 *x, unsigned long nmflags, unsigned long cflag)
111 ASN1_INTEGER *bs; 111 ASN1_INTEGER *bs;
112 EVP_PKEY *pkey=NULL; 112 EVP_PKEY *pkey=NULL;
113 const char *neg; 113 const char *neg;
114 ASN1_STRING *str=NULL;
115 114
116 if((nmflags & XN_FLAG_SEP_MASK) == XN_FLAG_SEP_MULTILINE) { 115 if((nmflags & XN_FLAG_SEP_MASK) == XN_FLAG_SEP_MULTILINE) {
117 mlch = '\n'; 116 mlch = '\n';
@@ -215,34 +214,10 @@ int X509_print_ex(BIO *bp, X509 *x, unsigned long nmflags, unsigned long cflag)
215 ERR_print_errors(bp); 214 ERR_print_errors(bp);
216 } 215 }
217 else 216 else
218#ifndef OPENSSL_NO_RSA
219 if (pkey->type == EVP_PKEY_RSA)
220 {
221 BIO_printf(bp,"%12sRSA Public Key: (%d bit)\n","",
222 BN_num_bits(pkey->pkey.rsa->n));
223 RSA_print(bp,pkey->pkey.rsa,16);
224 }
225 else
226#endif
227#ifndef OPENSSL_NO_DSA
228 if (pkey->type == EVP_PKEY_DSA)
229 {
230 BIO_printf(bp,"%12sDSA Public Key:\n","");
231 DSA_print(bp,pkey->pkey.dsa,16);
232 }
233 else
234#endif
235#ifndef OPENSSL_NO_EC
236 if (pkey->type == EVP_PKEY_EC)
237 { 217 {
238 BIO_printf(bp, "%12sEC Public Key:\n",""); 218 EVP_PKEY_print_public(bp, pkey, 16, NULL);
239 EC_KEY_print(bp, pkey->pkey.ec, 16); 219 EVP_PKEY_free(pkey);
240 } 220 }
241 else
242#endif
243 BIO_printf(bp,"%12sUnknown Public Key:\n","");
244
245 EVP_PKEY_free(pkey);
246 } 221 }
247 222
248 if (!(cflag & X509_FLAG_NO_EXTENSIONS)) 223 if (!(cflag & X509_FLAG_NO_EXTENSIONS))
@@ -259,7 +234,6 @@ int X509_print_ex(BIO *bp, X509 *x, unsigned long nmflags, unsigned long cflag)
259 } 234 }
260 ret=1; 235 ret=1;
261err: 236err:
262 if (str != NULL) ASN1_STRING_free(str);
263 if (m != NULL) OPENSSL_free(m); 237 if (m != NULL) OPENSSL_free(m);
264 return(ret); 238 return(ret);
265 } 239 }
@@ -329,14 +303,15 @@ int X509_signature_print(BIO *bp, X509_ALGOR *sigalg, ASN1_STRING *sig)
329 return 1; 303 return 1;
330} 304}
331 305
332int ASN1_STRING_print(BIO *bp, ASN1_STRING *v) 306int ASN1_STRING_print(BIO *bp, const ASN1_STRING *v)
333 { 307 {
334 int i,n; 308 int i,n;
335 char buf[80],*p; 309 char buf[80];
310 const char *p;
336 311
337 if (v == NULL) return(0); 312 if (v == NULL) return(0);
338 n=0; 313 n=0;
339 p=(char *)v->data; 314 p=(const char *)v->data;
340 for (i=0; i<v->length; i++) 315 for (i=0; i<v->length; i++)
341 { 316 {
342 if ((p[i] > '~') || ((p[i] < ' ') && 317 if ((p[i] > '~') || ((p[i] < ' ') &&
@@ -358,7 +333,7 @@ int ASN1_STRING_print(BIO *bp, ASN1_STRING *v)
358 return(1); 333 return(1);
359 } 334 }
360 335
361int ASN1_TIME_print(BIO *bp, ASN1_TIME *tm) 336int ASN1_TIME_print(BIO *bp, const ASN1_TIME *tm)
362{ 337{
363 if(tm->type == V_ASN1_UTCTIME) return ASN1_UTCTIME_print(bp, tm); 338 if(tm->type == V_ASN1_UTCTIME) return ASN1_UTCTIME_print(bp, tm);
364 if(tm->type == V_ASN1_GENERALIZEDTIME) 339 if(tm->type == V_ASN1_GENERALIZEDTIME)
@@ -373,12 +348,14 @@ static const char *mon[12]=
373 "Jul","Aug","Sep","Oct","Nov","Dec" 348 "Jul","Aug","Sep","Oct","Nov","Dec"
374 }; 349 };
375 350
376int ASN1_GENERALIZEDTIME_print(BIO *bp, ASN1_GENERALIZEDTIME *tm) 351int ASN1_GENERALIZEDTIME_print(BIO *bp, const ASN1_GENERALIZEDTIME *tm)
377 { 352 {
378 char *v; 353 char *v;
379 int gmt=0; 354 int gmt=0;
380 int i; 355 int i;
381 int y=0,M=0,d=0,h=0,m=0,s=0; 356 int y=0,M=0,d=0,h=0,m=0,s=0;
357 char *f = NULL;
358 int f_len = 0;
382 359
383 i=tm->length; 360 i=tm->length;
384 v=(char *)tm->data; 361 v=(char *)tm->data;
@@ -396,10 +373,21 @@ int ASN1_GENERALIZEDTIME_print(BIO *bp, ASN1_GENERALIZEDTIME *tm)
396 if (tm->length >= 14 && 373 if (tm->length >= 14 &&
397 (v[12] >= '0') && (v[12] <= '9') && 374 (v[12] >= '0') && (v[12] <= '9') &&
398 (v[13] >= '0') && (v[13] <= '9')) 375 (v[13] >= '0') && (v[13] <= '9'))
376 {
399 s= (v[12]-'0')*10+(v[13]-'0'); 377 s= (v[12]-'0')*10+(v[13]-'0');
378 /* Check for fractions of seconds. */
379 if (tm->length >= 15 && v[14] == '.')
380 {
381 int l = tm->length;
382 f = &v[14]; /* The decimal point. */
383 f_len = 1;
384 while (14 + f_len < l && f[f_len] >= '0' && f[f_len] <= '9')
385 ++f_len;
386 }
387 }
400 388
401 if (BIO_printf(bp,"%s %2d %02d:%02d:%02d %d%s", 389 if (BIO_printf(bp,"%s %2d %02d:%02d:%02d%.*s %d%s",
402 mon[M-1],d,h,m,s,y,(gmt)?" GMT":"") <= 0) 390 mon[M-1],d,h,m,s,f_len,f,y,(gmt)?" GMT":"") <= 0)
403 return(0); 391 return(0);
404 else 392 else
405 return(1); 393 return(1);
@@ -408,15 +396,15 @@ err:
408 return(0); 396 return(0);
409 } 397 }
410 398
411int ASN1_UTCTIME_print(BIO *bp, ASN1_UTCTIME *tm) 399int ASN1_UTCTIME_print(BIO *bp, const ASN1_UTCTIME *tm)
412 { 400 {
413 char *v; 401 const char *v;
414 int gmt=0; 402 int gmt=0;
415 int i; 403 int i;
416 int y=0,M=0,d=0,h=0,m=0,s=0; 404 int y=0,M=0,d=0,h=0,m=0,s=0;
417 405
418 i=tm->length; 406 i=tm->length;
419 v=(char *)tm->data; 407 v=(const char *)tm->data;
420 408
421 if (i < 10) goto err; 409 if (i < 10) goto err;
422 if (v[i-1] == 'Z') gmt=1; 410 if (v[i-1] == 'Z') gmt=1;
diff --git a/src/lib/libcrypto/asn1/tasn_dec.c b/src/lib/libcrypto/asn1/tasn_dec.c
index 48bc1c0d4d..3bee439968 100644
--- a/src/lib/libcrypto/asn1/tasn_dec.c
+++ b/src/lib/libcrypto/asn1/tasn_dec.c
@@ -114,6 +114,8 @@ unsigned long ASN1_tag2bit(int tag)
114/* Macro to initialize and invalidate the cache */ 114/* Macro to initialize and invalidate the cache */
115 115
116#define asn1_tlc_clear(c) if (c) (c)->valid = 0 116#define asn1_tlc_clear(c) if (c) (c)->valid = 0
117/* Version to avoid compiler warning about 'c' always non-NULL */
118#define asn1_tlc_clear_nc(c) (c)->valid = 0
117 119
118/* Decode an ASN1 item, this currently behaves just 120/* Decode an ASN1 item, this currently behaves just
119 * like a standard 'd2i' function. 'in' points to 121 * like a standard 'd2i' function. 'in' points to
@@ -130,7 +132,7 @@ ASN1_VALUE *ASN1_item_d2i(ASN1_VALUE **pval,
130 ASN1_VALUE *ptmpval = NULL; 132 ASN1_VALUE *ptmpval = NULL;
131 if (!pval) 133 if (!pval)
132 pval = &ptmpval; 134 pval = &ptmpval;
133 c.valid = 0; 135 asn1_tlc_clear_nc(&c);
134 if (ASN1_item_ex_d2i(pval, in, len, it, -1, 0, 0, &c) > 0) 136 if (ASN1_item_ex_d2i(pval, in, len, it, -1, 0, 0, &c) > 0)
135 return *pval; 137 return *pval;
136 return NULL; 138 return NULL;
@@ -140,7 +142,7 @@ int ASN1_template_d2i(ASN1_VALUE **pval,
140 const unsigned char **in, long len, const ASN1_TEMPLATE *tt) 142 const unsigned char **in, long len, const ASN1_TEMPLATE *tt)
141 { 143 {
142 ASN1_TLC c; 144 ASN1_TLC c;
143 c.valid = 0; 145 asn1_tlc_clear_nc(&c);
144 return asn1_template_ex_d2i(pval, in, len, tt, 0, &c); 146 return asn1_template_ex_d2i(pval, in, len, tt, 0, &c);
145 } 147 }
146 148
@@ -306,7 +308,7 @@ int ASN1_item_ex_d2i(ASN1_VALUE **pval, const unsigned char **in, long len,
306 308
307 309
308 case ASN1_ITYPE_CHOICE: 310 case ASN1_ITYPE_CHOICE:
309 if (asn1_cb && !asn1_cb(ASN1_OP_D2I_PRE, pval, it)) 311 if (asn1_cb && !asn1_cb(ASN1_OP_D2I_PRE, pval, it, NULL))
310 goto auxerr; 312 goto auxerr;
311 313
312 /* Allocate structure */ 314 /* Allocate structure */
@@ -356,7 +358,7 @@ int ASN1_item_ex_d2i(ASN1_VALUE **pval, const unsigned char **in, long len,
356 358
357 asn1_set_choice_selector(pval, i, it); 359 asn1_set_choice_selector(pval, i, it);
358 *in = p; 360 *in = p;
359 if (asn1_cb && !asn1_cb(ASN1_OP_D2I_POST, pval, it)) 361 if (asn1_cb && !asn1_cb(ASN1_OP_D2I_POST, pval, it, NULL))
360 goto auxerr; 362 goto auxerr;
361 return 1; 363 return 1;
362 364
@@ -403,7 +405,7 @@ int ASN1_item_ex_d2i(ASN1_VALUE **pval, const unsigned char **in, long len,
403 goto err; 405 goto err;
404 } 406 }
405 407
406 if (asn1_cb && !asn1_cb(ASN1_OP_D2I_PRE, pval, it)) 408 if (asn1_cb && !asn1_cb(ASN1_OP_D2I_PRE, pval, it, NULL))
407 goto auxerr; 409 goto auxerr;
408 410
409 /* Get each field entry */ 411 /* Get each field entry */
@@ -505,7 +507,7 @@ int ASN1_item_ex_d2i(ASN1_VALUE **pval, const unsigned char **in, long len,
505 if (!asn1_enc_save(pval, *in, p - *in, it)) 507 if (!asn1_enc_save(pval, *in, p - *in, it))
506 goto auxerr; 508 goto auxerr;
507 *in = p; 509 *in = p;
508 if (asn1_cb && !asn1_cb(ASN1_OP_D2I_POST, pval, it)) 510 if (asn1_cb && !asn1_cb(ASN1_OP_D2I_POST, pval, it, NULL))
509 goto auxerr; 511 goto auxerr;
510 return 1; 512 return 1;
511 513
@@ -665,11 +667,12 @@ static int asn1_template_noexp_d2i(ASN1_VALUE **val,
665 else 667 else
666 { 668 {
667 /* We've got a valid STACK: free up any items present */ 669 /* We've got a valid STACK: free up any items present */
668 STACK *sktmp = (STACK *)*val; 670 STACK_OF(ASN1_VALUE) *sktmp
671 = (STACK_OF(ASN1_VALUE) *)*val;
669 ASN1_VALUE *vtmp; 672 ASN1_VALUE *vtmp;
670 while(sk_num(sktmp) > 0) 673 while(sk_ASN1_VALUE_num(sktmp) > 0)
671 { 674 {
672 vtmp = (ASN1_VALUE *)sk_pop(sktmp); 675 vtmp = sk_ASN1_VALUE_pop(sktmp);
673 ASN1_item_ex_free(&vtmp, 676 ASN1_item_ex_free(&vtmp,
674 ASN1_ITEM_ptr(tt->item)); 677 ASN1_ITEM_ptr(tt->item));
675 } 678 }
@@ -710,7 +713,8 @@ static int asn1_template_noexp_d2i(ASN1_VALUE **val,
710 goto err; 713 goto err;
711 } 714 }
712 len -= p - q; 715 len -= p - q;
713 if (!sk_push((STACK *)*val, (char *)skfield)) 716 if (!sk_ASN1_VALUE_push((STACK_OF(ASN1_VALUE) *)*val,
717 skfield))
714 { 718 {
715 ASN1err(ASN1_F_ASN1_TEMPLATE_NOEXP_D2I, 719 ASN1err(ASN1_F_ASN1_TEMPLATE_NOEXP_D2I,
716 ERR_R_MALLOC_FAILURE); 720 ERR_R_MALLOC_FAILURE);
diff --git a/src/lib/libcrypto/asn1/tasn_enc.c b/src/lib/libcrypto/asn1/tasn_enc.c
index 2721f904a6..936ad1f767 100644
--- a/src/lib/libcrypto/asn1/tasn_enc.c
+++ b/src/lib/libcrypto/asn1/tasn_enc.c
@@ -158,7 +158,7 @@ int ASN1_item_ex_i2d(ASN1_VALUE **pval, unsigned char **out,
158 return asn1_i2d_ex_primitive(pval, out, it, -1, aclass); 158 return asn1_i2d_ex_primitive(pval, out, it, -1, aclass);
159 159
160 case ASN1_ITYPE_CHOICE: 160 case ASN1_ITYPE_CHOICE:
161 if (asn1_cb && !asn1_cb(ASN1_OP_I2D_PRE, pval, it)) 161 if (asn1_cb && !asn1_cb(ASN1_OP_I2D_PRE, pval, it, NULL))
162 return 0; 162 return 0;
163 i = asn1_get_choice_selector(pval, it); 163 i = asn1_get_choice_selector(pval, it);
164 if ((i >= 0) && (i < it->tcount)) 164 if ((i >= 0) && (i < it->tcount))
@@ -171,7 +171,7 @@ int ASN1_item_ex_i2d(ASN1_VALUE **pval, unsigned char **out,
171 -1, aclass); 171 -1, aclass);
172 } 172 }
173 /* Fixme: error condition if selector out of range */ 173 /* Fixme: error condition if selector out of range */
174 if (asn1_cb && !asn1_cb(ASN1_OP_I2D_POST, pval, it)) 174 if (asn1_cb && !asn1_cb(ASN1_OP_I2D_POST, pval, it, NULL))
175 return 0; 175 return 0;
176 break; 176 break;
177 177
@@ -216,7 +216,7 @@ int ASN1_item_ex_i2d(ASN1_VALUE **pval, unsigned char **out,
216 aclass = (aclass & ~ASN1_TFLG_TAG_CLASS) 216 aclass = (aclass & ~ASN1_TFLG_TAG_CLASS)
217 | V_ASN1_UNIVERSAL; 217 | V_ASN1_UNIVERSAL;
218 } 218 }
219 if (asn1_cb && !asn1_cb(ASN1_OP_I2D_PRE, pval, it)) 219 if (asn1_cb && !asn1_cb(ASN1_OP_I2D_PRE, pval, it, NULL))
220 return 0; 220 return 0;
221 /* First work out sequence content length */ 221 /* First work out sequence content length */
222 for (i = 0, tt = it->templates; i < it->tcount; tt++, i++) 222 for (i = 0, tt = it->templates; i < it->tcount; tt++, i++)
@@ -250,7 +250,7 @@ int ASN1_item_ex_i2d(ASN1_VALUE **pval, unsigned char **out,
250 } 250 }
251 if (ndef == 2) 251 if (ndef == 2)
252 ASN1_put_eoc(out); 252 ASN1_put_eoc(out);
253 if (asn1_cb && !asn1_cb(ASN1_OP_I2D_POST, pval, it)) 253 if (asn1_cb && !asn1_cb(ASN1_OP_I2D_POST, pval, it, NULL))
254 return 0; 254 return 0;
255 return seqlen; 255 return seqlen;
256 256
@@ -569,7 +569,8 @@ int asn1_ex_i2c(ASN1_VALUE **pval, unsigned char *cout, int *putype,
569 ASN1_STRING *strtmp; 569 ASN1_STRING *strtmp;
570 ASN1_OBJECT *otmp; 570 ASN1_OBJECT *otmp;
571 int utype; 571 int utype;
572 unsigned char *cont, c; 572 const unsigned char *cont;
573 unsigned char c;
573 int len; 574 int len;
574 const ASN1_PRIMITIVE_FUNCS *pf; 575 const ASN1_PRIMITIVE_FUNCS *pf;
575 pf = it->funcs; 576 pf = it->funcs;
diff --git a/src/lib/libcrypto/asn1/tasn_fre.c b/src/lib/libcrypto/asn1/tasn_fre.c
index d7c017fa1d..77d3092d31 100644
--- a/src/lib/libcrypto/asn1/tasn_fre.c
+++ b/src/lib/libcrypto/asn1/tasn_fre.c
@@ -110,7 +110,7 @@ static void asn1_item_combine_free(ASN1_VALUE **pval, const ASN1_ITEM *it, int c
110 case ASN1_ITYPE_CHOICE: 110 case ASN1_ITYPE_CHOICE:
111 if (asn1_cb) 111 if (asn1_cb)
112 { 112 {
113 i = asn1_cb(ASN1_OP_FREE_PRE, pval, it); 113 i = asn1_cb(ASN1_OP_FREE_PRE, pval, it, NULL);
114 if (i == 2) 114 if (i == 2)
115 return; 115 return;
116 } 116 }
@@ -123,7 +123,7 @@ static void asn1_item_combine_free(ASN1_VALUE **pval, const ASN1_ITEM *it, int c
123 ASN1_template_free(pchval, tt); 123 ASN1_template_free(pchval, tt);
124 } 124 }
125 if (asn1_cb) 125 if (asn1_cb)
126 asn1_cb(ASN1_OP_FREE_POST, pval, it); 126 asn1_cb(ASN1_OP_FREE_POST, pval, it, NULL);
127 if (!combine) 127 if (!combine)
128 { 128 {
129 OPENSSL_free(*pval); 129 OPENSSL_free(*pval);
@@ -149,7 +149,7 @@ static void asn1_item_combine_free(ASN1_VALUE **pval, const ASN1_ITEM *it, int c
149 return; 149 return;
150 if (asn1_cb) 150 if (asn1_cb)
151 { 151 {
152 i = asn1_cb(ASN1_OP_FREE_PRE, pval, it); 152 i = asn1_cb(ASN1_OP_FREE_PRE, pval, it, NULL);
153 if (i == 2) 153 if (i == 2)
154 return; 154 return;
155 } 155 }
@@ -170,7 +170,7 @@ static void asn1_item_combine_free(ASN1_VALUE **pval, const ASN1_ITEM *it, int c
170 ASN1_template_free(pseqval, seqtt); 170 ASN1_template_free(pseqval, seqtt);
171 } 171 }
172 if (asn1_cb) 172 if (asn1_cb)
173 asn1_cb(ASN1_OP_FREE_POST, pval, it); 173 asn1_cb(ASN1_OP_FREE_POST, pval, it, NULL);
174 if (!combine) 174 if (!combine)
175 { 175 {
176 OPENSSL_free(*pval); 176 OPENSSL_free(*pval);
diff --git a/src/lib/libcrypto/asn1/tasn_new.c b/src/lib/libcrypto/asn1/tasn_new.c
index 5c6a2ebd4d..0d9e78cc7c 100644
--- a/src/lib/libcrypto/asn1/tasn_new.c
+++ b/src/lib/libcrypto/asn1/tasn_new.c
@@ -68,7 +68,7 @@ static int asn1_item_ex_combine_new(ASN1_VALUE **pval, const ASN1_ITEM *it,
68 int combine); 68 int combine);
69static void asn1_item_clear(ASN1_VALUE **pval, const ASN1_ITEM *it); 69static void asn1_item_clear(ASN1_VALUE **pval, const ASN1_ITEM *it);
70static void asn1_template_clear(ASN1_VALUE **pval, const ASN1_TEMPLATE *tt); 70static void asn1_template_clear(ASN1_VALUE **pval, const ASN1_TEMPLATE *tt);
71void asn1_primitive_clear(ASN1_VALUE **pval, const ASN1_ITEM *it); 71static void asn1_primitive_clear(ASN1_VALUE **pval, const ASN1_ITEM *it);
72 72
73ASN1_VALUE *ASN1_item_new(const ASN1_ITEM *it) 73ASN1_VALUE *ASN1_item_new(const ASN1_ITEM *it)
74 { 74 {
@@ -146,7 +146,7 @@ static int asn1_item_ex_combine_new(ASN1_VALUE **pval, const ASN1_ITEM *it,
146 case ASN1_ITYPE_CHOICE: 146 case ASN1_ITYPE_CHOICE:
147 if (asn1_cb) 147 if (asn1_cb)
148 { 148 {
149 i = asn1_cb(ASN1_OP_NEW_PRE, pval, it); 149 i = asn1_cb(ASN1_OP_NEW_PRE, pval, it, NULL);
150 if (!i) 150 if (!i)
151 goto auxerr; 151 goto auxerr;
152 if (i==2) 152 if (i==2)
@@ -166,7 +166,7 @@ static int asn1_item_ex_combine_new(ASN1_VALUE **pval, const ASN1_ITEM *it,
166 memset(*pval, 0, it->size); 166 memset(*pval, 0, it->size);
167 } 167 }
168 asn1_set_choice_selector(pval, -1, it); 168 asn1_set_choice_selector(pval, -1, it);
169 if (asn1_cb && !asn1_cb(ASN1_OP_NEW_POST, pval, it)) 169 if (asn1_cb && !asn1_cb(ASN1_OP_NEW_POST, pval, it, NULL))
170 goto auxerr; 170 goto auxerr;
171 break; 171 break;
172 172
@@ -174,7 +174,7 @@ static int asn1_item_ex_combine_new(ASN1_VALUE **pval, const ASN1_ITEM *it,
174 case ASN1_ITYPE_SEQUENCE: 174 case ASN1_ITYPE_SEQUENCE:
175 if (asn1_cb) 175 if (asn1_cb)
176 { 176 {
177 i = asn1_cb(ASN1_OP_NEW_PRE, pval, it); 177 i = asn1_cb(ASN1_OP_NEW_PRE, pval, it, NULL);
178 if (!i) 178 if (!i)
179 goto auxerr; 179 goto auxerr;
180 if (i==2) 180 if (i==2)
@@ -201,7 +201,7 @@ static int asn1_item_ex_combine_new(ASN1_VALUE **pval, const ASN1_ITEM *it,
201 if (!ASN1_template_new(pseqval, tt)) 201 if (!ASN1_template_new(pseqval, tt))
202 goto memerr; 202 goto memerr;
203 } 203 }
204 if (asn1_cb && !asn1_cb(ASN1_OP_NEW_POST, pval, it)) 204 if (asn1_cb && !asn1_cb(ASN1_OP_NEW_POST, pval, it, NULL))
205 goto auxerr; 205 goto auxerr;
206 break; 206 break;
207 } 207 }
@@ -325,6 +325,7 @@ static void asn1_template_clear(ASN1_VALUE **pval, const ASN1_TEMPLATE *tt)
325int ASN1_primitive_new(ASN1_VALUE **pval, const ASN1_ITEM *it) 325int ASN1_primitive_new(ASN1_VALUE **pval, const ASN1_ITEM *it)
326 { 326 {
327 ASN1_TYPE *typ; 327 ASN1_TYPE *typ;
328 ASN1_STRING *str;
328 int utype; 329 int utype;
329 330
330 if (it && it->funcs) 331 if (it && it->funcs)
@@ -345,10 +346,7 @@ int ASN1_primitive_new(ASN1_VALUE **pval, const ASN1_ITEM *it)
345 return 1; 346 return 1;
346 347
347 case V_ASN1_BOOLEAN: 348 case V_ASN1_BOOLEAN:
348 if (it) 349 *(ASN1_BOOLEAN *)pval = it->size;
349 *(ASN1_BOOLEAN *)pval = it->size;
350 else
351 *(ASN1_BOOLEAN *)pval = -1;
352 return 1; 350 return 1;
353 351
354 case V_ASN1_NULL: 352 case V_ASN1_NULL:
@@ -365,7 +363,10 @@ int ASN1_primitive_new(ASN1_VALUE **pval, const ASN1_ITEM *it)
365 break; 363 break;
366 364
367 default: 365 default:
368 *pval = (ASN1_VALUE *)ASN1_STRING_type_new(utype); 366 str = ASN1_STRING_type_new(utype);
367 if (it->itype == ASN1_ITYPE_MSTRING && str)
368 str->flags |= ASN1_STRING_FLAG_MSTRING;
369 *pval = (ASN1_VALUE *)str;
369 break; 370 break;
370 } 371 }
371 if (*pval) 372 if (*pval)
@@ -373,7 +374,7 @@ int ASN1_primitive_new(ASN1_VALUE **pval, const ASN1_ITEM *it)
373 return 0; 374 return 0;
374 } 375 }
375 376
376void asn1_primitive_clear(ASN1_VALUE **pval, const ASN1_ITEM *it) 377static void asn1_primitive_clear(ASN1_VALUE **pval, const ASN1_ITEM *it)
377 { 378 {
378 int utype; 379 int utype;
379 if (it && it->funcs) 380 if (it && it->funcs)
diff --git a/src/lib/libcrypto/asn1/tasn_prn.c b/src/lib/libcrypto/asn1/tasn_prn.c
index b9c96a6dbe..453698012d 100644
--- a/src/lib/libcrypto/asn1/tasn_prn.c
+++ b/src/lib/libcrypto/asn1/tasn_prn.c
@@ -3,7 +3,7 @@
3 * project 2000. 3 * project 2000.
4 */ 4 */
5/* ==================================================================== 5/* ====================================================================
6 * Copyright (c) 2000 The OpenSSL Project. All rights reserved. 6 * Copyright (c) 2000,2005 The OpenSSL Project. All rights reserved.
7 * 7 *
8 * Redistribution and use in source and binary forms, with or without 8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions 9 * modification, are permitted provided that the following conditions
@@ -58,141 +58,570 @@
58 58
59 59
60#include <stddef.h> 60#include <stddef.h>
61#include "cryptlib.h"
61#include <openssl/asn1.h> 62#include <openssl/asn1.h>
63#include <openssl/asn1t.h>
62#include <openssl/objects.h> 64#include <openssl/objects.h>
63#include <openssl/buffer.h> 65#include <openssl/buffer.h>
64#include <openssl/err.h> 66#include <openssl/err.h>
65#include <openssl/nasn.h> 67#include <openssl/x509v3.h>
68#include "asn1_locl.h"
66 69
67/* Print routines. Print out a whole structure from a template. 70/* Print routines.
68 */ 71 */
69 72
70static int asn1_item_print_nm(BIO *out, void *fld, int indent, const ASN1_ITEM *it, const char *name); 73/* ASN1_PCTX routines */
71 74
72int ASN1_item_print(BIO *out, void *fld, int indent, const ASN1_ITEM *it) 75ASN1_PCTX default_pctx =
73{ 76 {
74 return asn1_item_print_nm(out, fld, indent, it, it->sname); 77 ASN1_PCTX_FLAGS_SHOW_ABSENT, /* flags */
75} 78 0, /* nm_flags */
79 0, /* cert_flags */
80 0, /* oid_flags */
81 0 /* str_flags */
82 };
83
76 84
77static int asn1_item_print_nm(BIO *out, void *fld, int indent, const ASN1_ITEM *it, const char *name) 85ASN1_PCTX *ASN1_PCTX_new(void)
78{ 86 {
79 ASN1_STRING *str; 87 ASN1_PCTX *ret;
88 ret = OPENSSL_malloc(sizeof(ASN1_PCTX));
89 if (ret == NULL)
90 {
91 ASN1err(ASN1_F_ASN1_PCTX_NEW, ERR_R_MALLOC_FAILURE);
92 return NULL;
93 }
94 ret->flags = 0;
95 ret->nm_flags = 0;
96 ret->cert_flags = 0;
97 ret->oid_flags = 0;
98 ret->str_flags = 0;
99 return ret;
100 }
101
102void ASN1_PCTX_free(ASN1_PCTX *p)
103 {
104 OPENSSL_free(p);
105 }
106
107unsigned long ASN1_PCTX_get_flags(ASN1_PCTX *p)
108 {
109 return p->flags;
110 }
111
112void ASN1_PCTX_set_flags(ASN1_PCTX *p, unsigned long flags)
113 {
114 p->flags = flags;
115 }
116
117unsigned long ASN1_PCTX_get_nm_flags(ASN1_PCTX *p)
118 {
119 return p->nm_flags;
120 }
121
122void ASN1_PCTX_set_nm_flags(ASN1_PCTX *p, unsigned long flags)
123 {
124 p->nm_flags = flags;
125 }
126
127unsigned long ASN1_PCTX_get_cert_flags(ASN1_PCTX *p)
128 {
129 return p->cert_flags;
130 }
131
132void ASN1_PCTX_set_cert_flags(ASN1_PCTX *p, unsigned long flags)
133 {
134 p->cert_flags = flags;
135 }
136
137unsigned long ASN1_PCTX_get_oid_flags(ASN1_PCTX *p)
138 {
139 return p->oid_flags;
140 }
141
142void ASN1_PCTX_set_oid_flags(ASN1_PCTX *p, unsigned long flags)
143 {
144 p->oid_flags = flags;
145 }
146
147unsigned long ASN1_PCTX_get_str_flags(ASN1_PCTX *p)
148 {
149 return p->str_flags;
150 }
151
152void ASN1_PCTX_set_str_flags(ASN1_PCTX *p, unsigned long flags)
153 {
154 p->str_flags = flags;
155 }
156
157/* Main print routines */
158
159static int asn1_item_print_ctx(BIO *out, ASN1_VALUE **fld, int indent,
160 const ASN1_ITEM *it,
161 const char *fname, const char *sname,
162 int nohdr, const ASN1_PCTX *pctx);
163
164int asn1_template_print_ctx(BIO *out, ASN1_VALUE **fld, int indent,
165 const ASN1_TEMPLATE *tt, const ASN1_PCTX *pctx);
166
167static int asn1_primitive_print(BIO *out, ASN1_VALUE **fld,
168 const ASN1_ITEM *it, int indent,
169 const char *fname, const char *sname,
170 const ASN1_PCTX *pctx);
171
172static int asn1_print_fsname(BIO *out, int indent,
173 const char *fname, const char *sname,
174 const ASN1_PCTX *pctx);
175
176int ASN1_item_print(BIO *out, ASN1_VALUE *ifld, int indent,
177 const ASN1_ITEM *it, const ASN1_PCTX *pctx)
178 {
179 const char *sname;
180 if (pctx == NULL)
181 pctx = &default_pctx;
182 if (pctx->flags & ASN1_PCTX_FLAGS_NO_STRUCT_NAME)
183 sname = NULL;
184 else
185 sname = it->sname;
186 return asn1_item_print_ctx(out, &ifld, indent, it,
187 NULL, sname, 0, pctx);
188 }
189
190static int asn1_item_print_ctx(BIO *out, ASN1_VALUE **fld, int indent,
191 const ASN1_ITEM *it,
192 const char *fname, const char *sname,
193 int nohdr, const ASN1_PCTX *pctx)
194 {
80 const ASN1_TEMPLATE *tt; 195 const ASN1_TEMPLATE *tt;
81 void *tmpfld; 196 const ASN1_EXTERN_FUNCS *ef;
197 ASN1_VALUE **tmpfld;
198 const ASN1_AUX *aux = it->funcs;
199 ASN1_aux_cb *asn1_cb;
200 ASN1_PRINT_ARG parg;
82 int i; 201 int i;
83 if(!fld) { 202 if (aux && aux->asn1_cb)
84 BIO_printf(out, "%*s%s ABSENT\n", indent, "", name); 203 {
204 parg.out = out;
205 parg.indent = indent;
206 parg.pctx = pctx;
207 asn1_cb = aux->asn1_cb;
208 }
209 else asn1_cb = 0;
210
211 if(*fld == NULL)
212 {
213 if (pctx->flags & ASN1_PCTX_FLAGS_SHOW_ABSENT)
214 {
215 if (!nohdr && !asn1_print_fsname(out, indent,
216 fname, sname, pctx))
217 return 0;
218 if (BIO_puts(out, "<ABSENT>\n") <= 0)
219 return 0;
220 }
85 return 1; 221 return 1;
86 } 222 }
87 switch(it->itype) {
88 223
224 switch(it->itype)
225 {
89 case ASN1_ITYPE_PRIMITIVE: 226 case ASN1_ITYPE_PRIMITIVE:
90 if(it->templates) 227 if(it->templates)
91 return ASN1_template_print(out, fld, indent, it->templates); 228 {
92 return asn1_primitive_print(out, fld, it->utype, indent, name); 229 if (!asn1_template_print_ctx(out, fld, indent,
93 break; 230 it->templates, pctx))
94 231 return 0;
232 }
233 /* fall thru */
95 case ASN1_ITYPE_MSTRING: 234 case ASN1_ITYPE_MSTRING:
96 str = fld; 235 if (!asn1_primitive_print(out, fld, it,
97 return asn1_primitive_print(out, fld, str->type, indent, name); 236 indent, fname, sname,pctx))
237 return 0;
238 break;
98 239
99 case ASN1_ITYPE_EXTERN: 240 case ASN1_ITYPE_EXTERN:
100 BIO_printf(out, "%*s%s:EXTERNAL TYPE %s %s\n", indent, "", name, it->sname, fld ? "" : "ABSENT"); 241 if (!nohdr && !asn1_print_fsname(out, indent, fname, sname, pctx))
101 return 1; 242 return 0;
102 case ASN1_ITYPE_COMPAT: 243 /* Use new style print routine if possible */
103 BIO_printf(out, "%*s%s:COMPATIBLE TYPE %s %s\n", indent, "", name, it->sname, fld ? "" : "ABSENT"); 244 ef = it->funcs;
104 return 1; 245 if (ef && ef->asn1_ex_print)
105 246 {
247 i = ef->asn1_ex_print(out, fld, indent, "", pctx);
248 if (!i)
249 return 0;
250 if ((i == 2) && (BIO_puts(out, "\n") <= 0))
251 return 0;
252 return 1;
253 }
254 else if (sname &&
255 BIO_printf(out, ":EXTERNAL TYPE %s\n", sname) <= 0)
256 return 0;
257 break;
106 258
107 case ASN1_ITYPE_CHOICE: 259 case ASN1_ITYPE_CHOICE:
260#if 0
261 if (!nohdr && !asn1_print_fsname(out, indent, fname, sname, pctx))
262 return 0;
263#endif
108 /* CHOICE type, get selector */ 264 /* CHOICE type, get selector */
109 i = asn1_get_choice_selector(fld, it); 265 i = asn1_get_choice_selector(fld, it);
110 /* This should never happen... */ 266 /* This should never happen... */
111 if((i < 0) || (i >= it->tcount)) { 267 if((i < 0) || (i >= it->tcount))
112 BIO_printf(out, "%s selector [%d] out of range\n", it->sname, i); 268 {
269 if (BIO_printf(out,
270 "ERROR: selector [%d] invalid\n", i) <= 0)
271 return 0;
113 return 1; 272 return 1;
114 } 273 }
115 tt = it->templates + i; 274 tt = it->templates + i;
116 tmpfld = asn1_get_field(fld, tt); 275 tmpfld = asn1_get_field_ptr(fld, tt);
117 return ASN1_template_print(out, tmpfld, indent, tt); 276 if (!asn1_template_print_ctx(out, tmpfld, indent, tt, pctx))
277 return 0;
278 break;
118 279
119 case ASN1_ITYPE_SEQUENCE: 280 case ASN1_ITYPE_SEQUENCE:
120 BIO_printf(out, "%*s%s {\n", indent, "", name); 281 case ASN1_ITYPE_NDEF_SEQUENCE:
121 /* Get each field entry */ 282 if (!nohdr && !asn1_print_fsname(out, indent, fname, sname, pctx))
122 for(i = 0, tt = it->templates; i < it->tcount; i++, tt++) { 283 return 0;
123 tmpfld = asn1_get_field(fld, tt); 284 if (fname || sname)
124 ASN1_template_print(out, tmpfld, indent + 2, tt); 285 {
125 } 286 if (pctx->flags & ASN1_PCTX_FLAGS_SHOW_SEQUENCE)
126 BIO_printf(out, "%*s}\n", indent, ""); 287 {
127 return 1; 288 if (BIO_puts(out, " {\n") <= 0)
289 return 0;
290 }
291 else
292 {
293 if (BIO_puts(out, "\n") <= 0)
294 return 0;
295 }
296 }
297
298 if (asn1_cb)
299 {
300 i = asn1_cb(ASN1_OP_PRINT_PRE, fld, it, &parg);
301 if (i == 0)
302 return 0;
303 if (i == 2)
304 return 1;
305 }
306
307 /* Print each field entry */
308 for(i = 0, tt = it->templates; i < it->tcount; i++, tt++)
309 {
310 const ASN1_TEMPLATE *seqtt;
311 seqtt = asn1_do_adb(fld, tt, 1);
312 tmpfld = asn1_get_field_ptr(fld, seqtt);
313 if (!asn1_template_print_ctx(out, tmpfld,
314 indent + 2, seqtt, pctx))
315 return 0;
316 }
317 if (pctx->flags & ASN1_PCTX_FLAGS_SHOW_SEQUENCE)
318 {
319 if (BIO_printf(out, "%*s}\n", indent, "") < 0)
320 return 0;
321 }
322
323 if (asn1_cb)
324 {
325 i = asn1_cb(ASN1_OP_PRINT_POST, fld, it, &parg);
326 if (i == 0)
327 return 0;
328 }
329 break;
128 330
129 default: 331 default:
332 BIO_printf(out, "Unprocessed type %d\n", it->itype);
130 return 0; 333 return 0;
334 }
335
336 return 1;
131 } 337 }
132}
133 338
134int ASN1_template_print(BIO *out, void *fld, int indent, const ASN1_TEMPLATE *tt) 339int asn1_template_print_ctx(BIO *out, ASN1_VALUE **fld, int indent,
135{ 340 const ASN1_TEMPLATE *tt, const ASN1_PCTX *pctx)
341 {
136 int i, flags; 342 int i, flags;
137#if 0 343 const char *sname, *fname;
138 if(!fld) return 0;
139#endif
140 flags = tt->flags; 344 flags = tt->flags;
141 if(flags & ASN1_TFLG_SK_MASK) { 345 if(pctx->flags & ASN1_PCTX_FLAGS_SHOW_FIELD_STRUCT_NAME)
346 sname = ASN1_ITEM_ptr(tt->item)->sname;
347 else
348 sname = NULL;
349 if(pctx->flags & ASN1_PCTX_FLAGS_NO_FIELD_NAME)
350 fname = NULL;
351 else
352 fname = tt->field_name;
353 if(flags & ASN1_TFLG_SK_MASK)
354 {
142 char *tname; 355 char *tname;
143 void *skitem; 356 ASN1_VALUE *skitem;
357 STACK_OF(ASN1_VALUE) *stack;
358
144 /* SET OF, SEQUENCE OF */ 359 /* SET OF, SEQUENCE OF */
145 if(flags & ASN1_TFLG_SET_OF) tname = "SET"; 360 if (fname)
146 else tname = "SEQUENCE"; 361 {
147 if(fld) { 362 if(pctx->flags & ASN1_PCTX_FLAGS_SHOW_SSOF)
148 BIO_printf(out, "%*s%s OF %s {\n", indent, "", tname, tt->field_name); 363 {
149 for(i = 0; i < sk_num(fld); i++) { 364 if(flags & ASN1_TFLG_SET_OF)
150 skitem = sk_value(fld, i); 365 tname = "SET";
151 asn1_item_print_nm(out, skitem, indent + 2, tt->item, ""); 366 else
367 tname = "SEQUENCE";
368 if (BIO_printf(out, "%*s%s OF %s {\n",
369 indent, "", tname, tt->field_name) <= 0)
370 return 0;
371 }
372 else if (BIO_printf(out, "%*s%s:\n", indent, "",
373 fname) <= 0)
374 return 0;
375 }
376 stack = (STACK_OF(ASN1_VALUE) *)*fld;
377 for(i = 0; i < sk_ASN1_VALUE_num(stack); i++)
378 {
379 if ((i > 0) && (BIO_puts(out, "\n") <= 0))
380 return 0;
381
382 skitem = sk_ASN1_VALUE_value(stack, i);
383 if (!asn1_item_print_ctx(out, &skitem, indent + 2,
384 ASN1_ITEM_ptr(tt->item), NULL, NULL, 1, pctx))
385 return 0;
386 }
387 if (!i && BIO_printf(out, "%*s<EMPTY>\n", indent + 2, "") <= 0)
388 return 0;
389 if(pctx->flags & ASN1_PCTX_FLAGS_SHOW_SEQUENCE)
390 {
391 if (BIO_printf(out, "%*s}\n", indent, "") <= 0)
392 return 0;
152 } 393 }
153 BIO_printf(out, "%*s}\n", indent, "");
154 } else
155 BIO_printf(out, "%*s%s OF %s ABSENT\n", indent, "", tname, tt->field_name);
156 return 1; 394 return 1;
395 }
396 return asn1_item_print_ctx(out, fld, indent, ASN1_ITEM_ptr(tt->item),
397 fname, sname, 0, pctx);
157 } 398 }
158 return asn1_item_print_nm(out, fld, indent, tt->item, tt->field_name); 399
159} 400static int asn1_print_fsname(BIO *out, int indent,
160 401 const char *fname, const char *sname,
161static int asn1_primitive_print(BIO *out, void *fld, long utype, int indent, const char *name) 402 const ASN1_PCTX *pctx)
162{ 403 {
163 ASN1_STRING *str = fld; 404 static char spaces[] = " ";
164 if(fld) { 405 const int nspaces = sizeof(spaces) - 1;
165 if(utype == V_ASN1_BOOLEAN) { 406
166 int *bool = fld; 407#if 0
167if(*bool == -1) printf("BOOL MISSING\n"); 408 if (!sname && !fname)
168 BIO_printf(out, "%*s%s:%s", indent, "", "BOOLEAN", *bool ? "TRUE" : "FALSE"); 409 return 1;
169 } else if((utype == V_ASN1_INTEGER) 410#endif
170 || (utype == V_ASN1_ENUMERATED)) { 411
171 char *s, *nm; 412 while (indent > nspaces)
172 s = i2s_ASN1_INTEGER(NULL, fld); 413 {
173 if(utype == V_ASN1_INTEGER) nm = "INTEGER"; 414 if (BIO_write(out, spaces, nspaces) != nspaces)
174 else nm = "ENUMERATED"; 415 return 0;
175 BIO_printf(out, "%*s%s:%s", indent, "", nm, s); 416 indent -= nspaces;
176 OPENSSL_free(s); 417 }
177 } else if(utype == V_ASN1_NULL) { 418 if (BIO_write(out, spaces, indent) != indent)
178 BIO_printf(out, "%*s%s", indent, "", "NULL"); 419 return 0;
179 } else if(utype == V_ASN1_UTCTIME) { 420 if (pctx->flags & ASN1_PCTX_FLAGS_NO_STRUCT_NAME)
180 BIO_printf(out, "%*s%s:%s:", indent, "", name, "UTCTIME"); 421 sname = NULL;
181 ASN1_UTCTIME_print(out, str); 422 if (pctx->flags & ASN1_PCTX_FLAGS_NO_FIELD_NAME)
182 } else if(utype == V_ASN1_GENERALIZEDTIME) { 423 fname = NULL;
183 BIO_printf(out, "%*s%s:%s:", indent, "", name, "GENERALIZEDTIME"); 424 if (!sname && !fname)
184 ASN1_GENERALIZEDTIME_print(out, str); 425 return 1;
185 } else if(utype == V_ASN1_OBJECT) { 426 if (fname)
186 char objbuf[80], *ln; 427 {
187 ln = OBJ_nid2ln(OBJ_obj2nid(fld)); 428 if (BIO_puts(out, fname) <= 0)
188 if(!ln) ln = ""; 429 return 0;
189 OBJ_obj2txt(objbuf, sizeof objbuf, fld, 1);
190 BIO_printf(out, "%*s%s:%s (%s)", indent, "", "OBJECT", ln, objbuf);
191 } else {
192 BIO_printf(out, "%*s%s:", indent, "", name);
193 ASN1_STRING_print_ex(out, str, ASN1_STRFLGS_DUMP_UNKNOWN|ASN1_STRFLGS_SHOW_TYPE);
194 } 430 }
195 BIO_printf(out, "\n"); 431 if (sname)
196 } else BIO_printf(out, "%*s%s [ABSENT]\n", indent, "", name); 432 {
433 if (fname)
434 {
435 if (BIO_printf(out, " (%s)", sname) <= 0)
436 return 0;
437 }
438 else
439 {
440 if (BIO_puts(out, sname) <= 0)
441 return 0;
442 }
443 }
444 if (BIO_write(out, ": ", 2) != 2)
445 return 0;
197 return 1; 446 return 1;
198} 447 }
448
449static int asn1_print_boolean_ctx(BIO *out, const int bool,
450 const ASN1_PCTX *pctx)
451 {
452 const char *str;
453 switch (bool)
454 {
455 case -1:
456 str = "BOOL ABSENT";
457 break;
458
459 case 0:
460 str = "FALSE";
461 break;
462
463 default:
464 str = "TRUE";
465 break;
466
467 }
468
469 if (BIO_puts(out, str) <= 0)
470 return 0;
471 return 1;
472
473 }
474
475static int asn1_print_integer_ctx(BIO *out, ASN1_INTEGER *str,
476 const ASN1_PCTX *pctx)
477 {
478 char *s;
479 int ret = 1;
480 s = i2s_ASN1_INTEGER(NULL, str);
481 if (BIO_puts(out, s) <= 0)
482 ret = 0;
483 OPENSSL_free(s);
484 return ret;
485 }
486
487static int asn1_print_oid_ctx(BIO *out, const ASN1_OBJECT *oid,
488 const ASN1_PCTX *pctx)
489 {
490 char objbuf[80];
491 const char *ln;
492 ln = OBJ_nid2ln(OBJ_obj2nid(oid));
493 if(!ln)
494 ln = "";
495 OBJ_obj2txt(objbuf, sizeof objbuf, oid, 1);
496 if (BIO_printf(out, "%s (%s)", ln, objbuf) <= 0)
497 return 0;
498 return 1;
499 }
500
501static int asn1_print_obstring_ctx(BIO *out, ASN1_STRING *str, int indent,
502 const ASN1_PCTX *pctx)
503 {
504 if (str->type == V_ASN1_BIT_STRING)
505 {
506 if (BIO_printf(out, " (%ld unused bits)\n",
507 str->flags & 0x7) <= 0)
508 return 0;
509 }
510 else if (BIO_puts(out, "\n") <= 0)
511 return 0;
512 if ((str->length > 0)
513 && BIO_dump_indent(out, (char *)str->data, str->length,
514 indent + 2) <= 0)
515 return 0;
516 return 1;
517 }
518
519static int asn1_primitive_print(BIO *out, ASN1_VALUE **fld,
520 const ASN1_ITEM *it, int indent,
521 const char *fname, const char *sname,
522 const ASN1_PCTX *pctx)
523 {
524 long utype;
525 ASN1_STRING *str;
526 int ret = 1, needlf = 1;
527 const char *pname;
528 const ASN1_PRIMITIVE_FUNCS *pf;
529 pf = it->funcs;
530 if (!asn1_print_fsname(out, indent, fname, sname, pctx))
531 return 0;
532 if (pf && pf->prim_print)
533 return pf->prim_print(out, fld, it, indent, pctx);
534 str = (ASN1_STRING *)*fld;
535 if (it->itype == ASN1_ITYPE_MSTRING)
536 utype = str->type & ~V_ASN1_NEG;
537 else
538 utype = it->utype;
539 if (utype == V_ASN1_ANY)
540 {
541 ASN1_TYPE *atype = (ASN1_TYPE *)*fld;
542 utype = atype->type;
543 fld = &atype->value.asn1_value;
544 str = (ASN1_STRING *)*fld;
545 if (pctx->flags & ASN1_PCTX_FLAGS_NO_ANY_TYPE)
546 pname = NULL;
547 else
548 pname = ASN1_tag2str(utype);
549 }
550 else
551 {
552 if (pctx->flags & ASN1_PCTX_FLAGS_SHOW_TYPE)
553 pname = ASN1_tag2str(utype);
554 else
555 pname = NULL;
556 }
557
558 if (utype == V_ASN1_NULL)
559 {
560 if (BIO_puts(out, "NULL\n") <= 0)
561 return 0;
562 return 1;
563 }
564
565 if (pname)
566 {
567 if (BIO_puts(out, pname) <= 0)
568 return 0;
569 if (BIO_puts(out, ":") <= 0)
570 return 0;
571 }
572
573 switch (utype)
574 {
575 case V_ASN1_BOOLEAN:
576 {
577 int bool = *(int *)fld;
578 if (bool == -1)
579 bool = it->size;
580 ret = asn1_print_boolean_ctx(out, bool, pctx);
581 }
582 break;
583
584 case V_ASN1_INTEGER:
585 case V_ASN1_ENUMERATED:
586 ret = asn1_print_integer_ctx(out, str, pctx);
587 break;
588
589 case V_ASN1_UTCTIME:
590 ret = ASN1_UTCTIME_print(out, str);
591 break;
592
593 case V_ASN1_GENERALIZEDTIME:
594 ret = ASN1_GENERALIZEDTIME_print(out, str);
595 break;
596
597 case V_ASN1_OBJECT:
598 ret = asn1_print_oid_ctx(out, (const ASN1_OBJECT *)*fld, pctx);
599 break;
600
601 case V_ASN1_OCTET_STRING:
602 case V_ASN1_BIT_STRING:
603 ret = asn1_print_obstring_ctx(out, str, indent, pctx);
604 needlf = 0;
605 break;
606
607 case V_ASN1_SEQUENCE:
608 case V_ASN1_SET:
609 case V_ASN1_OTHER:
610 if (BIO_puts(out, "\n") <= 0)
611 return 0;
612 if (ASN1_parse_dump(out, str->data, str->length,
613 indent, 0) <= 0)
614 ret = 0;
615 needlf = 0;
616 break;
617
618 default:
619 ret = ASN1_STRING_print_ex(out, str, pctx->str_flags);
620
621 }
622 if (!ret)
623 return 0;
624 if (needlf && BIO_puts(out, "\n") <= 0)
625 return 0;
626 return 1;
627 }
diff --git a/src/lib/libcrypto/asn1/tasn_typ.c b/src/lib/libcrypto/asn1/tasn_typ.c
index 6252213d15..6fb1c372da 100644
--- a/src/lib/libcrypto/asn1/tasn_typ.c
+++ b/src/lib/libcrypto/asn1/tasn_typ.c
@@ -135,3 +135,14 @@ IMPLEMENT_ASN1_TYPE_ex(ASN1_FBOOLEAN, ASN1_BOOLEAN, 0)
135/* Special, OCTET STRING with indefinite length constructed support */ 135/* Special, OCTET STRING with indefinite length constructed support */
136 136
137IMPLEMENT_ASN1_TYPE_ex(ASN1_OCTET_STRING_NDEF, ASN1_OCTET_STRING, ASN1_TFLG_NDEF) 137IMPLEMENT_ASN1_TYPE_ex(ASN1_OCTET_STRING_NDEF, ASN1_OCTET_STRING, ASN1_TFLG_NDEF)
138
139ASN1_ITEM_TEMPLATE(ASN1_SEQUENCE_ANY) =
140 ASN1_EX_TEMPLATE_TYPE(ASN1_TFLG_SEQUENCE_OF, 0, ASN1_SEQUENCE_ANY, ASN1_ANY)
141ASN1_ITEM_TEMPLATE_END(ASN1_SEQUENCE_ANY)
142
143ASN1_ITEM_TEMPLATE(ASN1_SET_ANY) =
144 ASN1_EX_TEMPLATE_TYPE(ASN1_TFLG_SET_OF, 0, ASN1_SET_ANY, ASN1_ANY)
145ASN1_ITEM_TEMPLATE_END(ASN1_SET_ANY)
146
147IMPLEMENT_ASN1_ENCODE_FUNCTIONS_const_fname(ASN1_SEQUENCE_ANY, ASN1_SEQUENCE_ANY, ASN1_SEQUENCE_ANY)
148IMPLEMENT_ASN1_ENCODE_FUNCTIONS_const_fname(ASN1_SEQUENCE_ANY, ASN1_SET_ANY, ASN1_SET_ANY)
diff --git a/src/lib/libcrypto/asn1/x_cinf.c b/src/lib/libcrypto/asn1/x_cinf.c
deleted file mode 100644
index 339a110eef..0000000000
--- a/src/lib/libcrypto/asn1/x_cinf.c
+++ /dev/null
@@ -1,201 +0,0 @@
1/* crypto/asn1/x_cinf.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 "cryptlib.h"
61#include <openssl/asn1_mac.h>
62#include <openssl/x509.h>
63
64int i2d_X509_CINF(X509_CINF *a, unsigned char **pp)
65 {
66 int v1=0,v2=0;
67 M_ASN1_I2D_vars(a);
68
69 M_ASN1_I2D_len_EXP_opt(a->version,i2d_ASN1_INTEGER,0,v1);
70 M_ASN1_I2D_len(a->serialNumber, i2d_ASN1_INTEGER);
71 M_ASN1_I2D_len(a->signature, i2d_X509_ALGOR);
72 M_ASN1_I2D_len(a->issuer, i2d_X509_NAME);
73 M_ASN1_I2D_len(a->validity, i2d_X509_VAL);
74 M_ASN1_I2D_len(a->subject, i2d_X509_NAME);
75 M_ASN1_I2D_len(a->key, i2d_X509_PUBKEY);
76 M_ASN1_I2D_len_IMP_opt(a->issuerUID, i2d_ASN1_BIT_STRING);
77 M_ASN1_I2D_len_IMP_opt(a->subjectUID, i2d_ASN1_BIT_STRING);
78 M_ASN1_I2D_len_EXP_SEQUENCE_opt_type(X509_EXTENSION,a->extensions,
79 i2d_X509_EXTENSION,3,
80 V_ASN1_SEQUENCE,v2);
81
82 M_ASN1_I2D_seq_total();
83
84 M_ASN1_I2D_put_EXP_opt(a->version,i2d_ASN1_INTEGER,0,v1);
85 M_ASN1_I2D_put(a->serialNumber, i2d_ASN1_INTEGER);
86 M_ASN1_I2D_put(a->signature, i2d_X509_ALGOR);
87 M_ASN1_I2D_put(a->issuer, i2d_X509_NAME);
88 M_ASN1_I2D_put(a->validity, i2d_X509_VAL);
89 M_ASN1_I2D_put(a->subject, i2d_X509_NAME);
90 M_ASN1_I2D_put(a->key, i2d_X509_PUBKEY);
91 M_ASN1_I2D_put_IMP_opt(a->issuerUID, i2d_ASN1_BIT_STRING,1);
92 M_ASN1_I2D_put_IMP_opt(a->subjectUID, i2d_ASN1_BIT_STRING,2);
93 M_ASN1_I2D_put_EXP_SEQUENCE_opt_type(X509_EXTENSION,a->extensions,
94 i2d_X509_EXTENSION,3,
95 V_ASN1_SEQUENCE,v2);
96
97 M_ASN1_I2D_finish();
98 }
99
100X509_CINF *d2i_X509_CINF(X509_CINF **a, unsigned char **pp, long length)
101 {
102 int ver=0;
103 M_ASN1_D2I_vars(a,X509_CINF *,X509_CINF_new);
104
105 M_ASN1_D2I_Init();
106 M_ASN1_D2I_start_sequence();
107 /* we have the optional version field */
108 if (M_ASN1_next == (V_ASN1_CONTEXT_SPECIFIC | V_ASN1_CONSTRUCTED | 0))
109 {
110 M_ASN1_D2I_get_EXP_opt(ret->version,d2i_ASN1_INTEGER,0);
111 if (ret->version->data != NULL)
112 ver=ret->version->data[0];
113 }
114 else
115 {
116 if (ret->version != NULL)
117 {
118 M_ASN1_INTEGER_free(ret->version);
119 ret->version=NULL;
120 }
121 }
122 M_ASN1_D2I_get(ret->serialNumber,d2i_ASN1_INTEGER);
123 M_ASN1_D2I_get(ret->signature,d2i_X509_ALGOR);
124 M_ASN1_D2I_get(ret->issuer,d2i_X509_NAME);
125 M_ASN1_D2I_get(ret->validity,d2i_X509_VAL);
126 M_ASN1_D2I_get(ret->subject,d2i_X509_NAME);
127 M_ASN1_D2I_get(ret->key,d2i_X509_PUBKEY);
128 if (ver >= 1) /* version 2 extensions */
129 {
130 if (ret->issuerUID != NULL)
131 {
132 M_ASN1_BIT_STRING_free(ret->issuerUID);
133 ret->issuerUID=NULL;
134 }
135 if (ret->subjectUID != NULL)
136 {
137 M_ASN1_BIT_STRING_free(ret->subjectUID);
138 ret->subjectUID=NULL;
139 }
140 M_ASN1_D2I_get_IMP_opt(ret->issuerUID,d2i_ASN1_BIT_STRING, 1,
141 V_ASN1_BIT_STRING);
142 M_ASN1_D2I_get_IMP_opt(ret->subjectUID,d2i_ASN1_BIT_STRING, 2,
143 V_ASN1_BIT_STRING);
144 }
145/* Note: some broken certificates include extensions but don't set
146 * the version number properly. By bypassing this check they can
147 * be parsed.
148 */
149
150#ifdef VERSION_EXT_CHECK
151 if (ver >= 2) /* version 3 extensions */
152#endif
153 {
154 if (ret->extensions != NULL)
155 while (sk_X509_EXTENSION_num(ret->extensions))
156 X509_EXTENSION_free(
157 sk_X509_EXTENSION_pop(ret->extensions));
158 M_ASN1_D2I_get_EXP_set_opt_type(X509_EXTENSION,ret->extensions,
159 d2i_X509_EXTENSION,
160 X509_EXTENSION_free,3,
161 V_ASN1_SEQUENCE);
162 }
163 M_ASN1_D2I_Finish(a,X509_CINF_free,ASN1_F_D2I_X509_CINF);
164 }
165
166X509_CINF *X509_CINF_new(void)
167 {
168 X509_CINF *ret=NULL;
169 ASN1_CTX c;
170
171 M_ASN1_New_Malloc(ret,X509_CINF);
172 ret->version=NULL;
173 M_ASN1_New(ret->serialNumber,M_ASN1_INTEGER_new);
174 M_ASN1_New(ret->signature,X509_ALGOR_new);
175 M_ASN1_New(ret->issuer,X509_NAME_new);
176 M_ASN1_New(ret->validity,X509_VAL_new);
177 M_ASN1_New(ret->subject,X509_NAME_new);
178 M_ASN1_New(ret->key,X509_PUBKEY_new);
179 ret->issuerUID=NULL;
180 ret->subjectUID=NULL;
181 ret->extensions=NULL;
182 return(ret);
183 M_ASN1_New_Error(ASN1_F_X509_CINF_NEW);
184 }
185
186void X509_CINF_free(X509_CINF *a)
187 {
188 if (a == NULL) return;
189 M_ASN1_INTEGER_free(a->version);
190 M_ASN1_INTEGER_free(a->serialNumber);
191 X509_ALGOR_free(a->signature);
192 X509_NAME_free(a->issuer);
193 X509_VAL_free(a->validity);
194 X509_NAME_free(a->subject);
195 X509_PUBKEY_free(a->key);
196 M_ASN1_BIT_STRING_free(a->issuerUID);
197 M_ASN1_BIT_STRING_free(a->subjectUID);
198 sk_X509_EXTENSION_pop_free(a->extensions,X509_EXTENSION_free);
199 OPENSSL_free(a);
200 }
201
diff --git a/src/lib/libcrypto/asn1/x_crl.c b/src/lib/libcrypto/asn1/x_crl.c
index 70d56a67f2..c51c690ba9 100644
--- a/src/lib/libcrypto/asn1/x_crl.c
+++ b/src/lib/libcrypto/asn1/x_crl.c
@@ -58,11 +58,14 @@
58 58
59#include <stdio.h> 59#include <stdio.h>
60#include "cryptlib.h" 60#include "cryptlib.h"
61#include "asn1_locl.h"
61#include <openssl/asn1t.h> 62#include <openssl/asn1t.h>
62#include <openssl/x509.h> 63#include <openssl/x509.h>
64#include <openssl/x509v3.h>
63 65
64static int X509_REVOKED_cmp(const X509_REVOKED * const *a, 66static int X509_REVOKED_cmp(const X509_REVOKED * const *a,
65 const X509_REVOKED * const *b); 67 const X509_REVOKED * const *b);
68static void setup_idp(X509_CRL *crl, ISSUING_DIST_POINT *idp);
66 69
67ASN1_SEQUENCE(X509_REVOKED) = { 70ASN1_SEQUENCE(X509_REVOKED) = {
68 ASN1_SIMPLE(X509_REVOKED,serialNumber, ASN1_INTEGER), 71 ASN1_SIMPLE(X509_REVOKED,serialNumber, ASN1_INTEGER),
@@ -70,11 +73,26 @@ ASN1_SEQUENCE(X509_REVOKED) = {
70 ASN1_SEQUENCE_OF_OPT(X509_REVOKED,extensions, X509_EXTENSION) 73 ASN1_SEQUENCE_OF_OPT(X509_REVOKED,extensions, X509_EXTENSION)
71} ASN1_SEQUENCE_END(X509_REVOKED) 74} ASN1_SEQUENCE_END(X509_REVOKED)
72 75
76static int def_crl_verify(X509_CRL *crl, EVP_PKEY *r);
77static int def_crl_lookup(X509_CRL *crl,
78 X509_REVOKED **ret, ASN1_INTEGER *serial, X509_NAME *issuer);
79
80static X509_CRL_METHOD int_crl_meth =
81 {
82 0,
83 0,0,
84 def_crl_lookup,
85 def_crl_verify
86 };
87
88static const X509_CRL_METHOD *default_crl_method = &int_crl_meth;
89
73/* The X509_CRL_INFO structure needs a bit of customisation. 90/* The X509_CRL_INFO structure needs a bit of customisation.
74 * Since we cache the original encoding the signature wont be affected by 91 * Since we cache the original encoding the signature wont be affected by
75 * reordering of the revoked field. 92 * reordering of the revoked field.
76 */ 93 */
77static int crl_inf_cb(int operation, ASN1_VALUE **pval, const ASN1_ITEM *it) 94static int crl_inf_cb(int operation, ASN1_VALUE **pval, const ASN1_ITEM *it,
95 void *exarg)
78{ 96{
79 X509_CRL_INFO *a = (X509_CRL_INFO *)*pval; 97 X509_CRL_INFO *a = (X509_CRL_INFO *)*pval;
80 98
@@ -101,7 +119,237 @@ ASN1_SEQUENCE_enc(X509_CRL_INFO, enc, crl_inf_cb) = {
101 ASN1_EXP_SEQUENCE_OF_OPT(X509_CRL_INFO, extensions, X509_EXTENSION, 0) 119 ASN1_EXP_SEQUENCE_OF_OPT(X509_CRL_INFO, extensions, X509_EXTENSION, 0)
102} ASN1_SEQUENCE_END_enc(X509_CRL_INFO, X509_CRL_INFO) 120} ASN1_SEQUENCE_END_enc(X509_CRL_INFO, X509_CRL_INFO)
103 121
104ASN1_SEQUENCE_ref(X509_CRL, 0, CRYPTO_LOCK_X509_CRL) = { 122/* Set CRL entry issuer according to CRL certificate issuer extension.
123 * Check for unhandled critical CRL entry extensions.
124 */
125
126static int crl_set_issuers(X509_CRL *crl)
127 {
128
129 int i, j;
130 GENERAL_NAMES *gens, *gtmp;
131 STACK_OF(X509_REVOKED) *revoked;
132
133 revoked = X509_CRL_get_REVOKED(crl);
134
135 gens = NULL;
136 for (i = 0; i < sk_X509_REVOKED_num(revoked); i++)
137 {
138 X509_REVOKED *rev = sk_X509_REVOKED_value(revoked, i);
139 STACK_OF(X509_EXTENSION) *exts;
140 ASN1_ENUMERATED *reason;
141 X509_EXTENSION *ext;
142 gtmp = X509_REVOKED_get_ext_d2i(rev,
143 NID_certificate_issuer,
144 &j, NULL);
145 if (!gtmp && (j != -1))
146 {
147 crl->flags |= EXFLAG_INVALID;
148 return 1;
149 }
150
151 if (gtmp)
152 {
153 gens = gtmp;
154 if (!crl->issuers)
155 {
156 crl->issuers = sk_GENERAL_NAMES_new_null();
157 if (!crl->issuers)
158 return 0;
159 }
160 if (!sk_GENERAL_NAMES_push(crl->issuers, gtmp))
161 return 0;
162 }
163 rev->issuer = gens;
164
165 reason = X509_REVOKED_get_ext_d2i(rev, NID_crl_reason,
166 &j, NULL);
167 if (!reason && (j != -1))
168 {
169 crl->flags |= EXFLAG_INVALID;
170 return 1;
171 }
172
173 if (reason)
174 {
175 rev->reason = ASN1_ENUMERATED_get(reason);
176 ASN1_ENUMERATED_free(reason);
177 }
178 else
179 rev->reason = CRL_REASON_NONE;
180
181 /* Check for critical CRL entry extensions */
182
183 exts = rev->extensions;
184
185 for (j = 0; j < sk_X509_EXTENSION_num(exts); j++)
186 {
187 ext = sk_X509_EXTENSION_value(exts, j);
188 if (ext->critical > 0)
189 {
190 if (OBJ_obj2nid(ext->object) ==
191 NID_certificate_issuer)
192 continue;
193 crl->flags |= EXFLAG_CRITICAL;
194 break;
195 }
196 }
197
198
199 }
200
201 return 1;
202
203 }
204
205/* The X509_CRL structure needs a bit of customisation. Cache some extensions
206 * and hash of the whole CRL.
207 */
208static int crl_cb(int operation, ASN1_VALUE **pval, const ASN1_ITEM *it,
209 void *exarg)
210 {
211 X509_CRL *crl = (X509_CRL *)*pval;
212 STACK_OF(X509_EXTENSION) *exts;
213 X509_EXTENSION *ext;
214 int idx;
215
216 switch(operation)
217 {
218 case ASN1_OP_NEW_POST:
219 crl->idp = NULL;
220 crl->akid = NULL;
221 crl->flags = 0;
222 crl->idp_flags = 0;
223 crl->idp_reasons = CRLDP_ALL_REASONS;
224 crl->meth = default_crl_method;
225 crl->meth_data = NULL;
226 crl->issuers = NULL;
227 crl->crl_number = NULL;
228 crl->base_crl_number = NULL;
229 break;
230
231 case ASN1_OP_D2I_POST:
232#ifndef OPENSSL_NO_SHA
233 X509_CRL_digest(crl, EVP_sha1(), crl->sha1_hash, NULL);
234#endif
235 crl->idp = X509_CRL_get_ext_d2i(crl,
236 NID_issuing_distribution_point, NULL, NULL);
237 if (crl->idp)
238 setup_idp(crl, crl->idp);
239
240 crl->akid = X509_CRL_get_ext_d2i(crl,
241 NID_authority_key_identifier, NULL, NULL);
242
243 crl->crl_number = X509_CRL_get_ext_d2i(crl,
244 NID_crl_number, NULL, NULL);
245
246 crl->base_crl_number = X509_CRL_get_ext_d2i(crl,
247 NID_delta_crl, NULL, NULL);
248 /* Delta CRLs must have CRL number */
249 if (crl->base_crl_number && !crl->crl_number)
250 crl->flags |= EXFLAG_INVALID;
251
252 /* See if we have any unhandled critical CRL extensions and
253 * indicate this in a flag. We only currently handle IDP so
254 * anything else critical sets the flag.
255 *
256 * This code accesses the X509_CRL structure directly:
257 * applications shouldn't do this.
258 */
259
260 exts = crl->crl->extensions;
261
262 for (idx = 0; idx < sk_X509_EXTENSION_num(exts); idx++)
263 {
264 int nid;
265 ext = sk_X509_EXTENSION_value(exts, idx);
266 nid = OBJ_obj2nid(ext->object);
267 if (nid == NID_freshest_crl)
268 crl->flags |= EXFLAG_FRESHEST;
269 if (ext->critical > 0)
270 {
271 /* We handle IDP and deltas */
272 if ((nid == NID_issuing_distribution_point)
273 || (nid == NID_delta_crl))
274 break;;
275 crl->flags |= EXFLAG_CRITICAL;
276 break;
277 }
278 }
279
280
281 if (!crl_set_issuers(crl))
282 return 0;
283
284 if (crl->meth->crl_init)
285 {
286 if (crl->meth->crl_init(crl) == 0)
287 return 0;
288 }
289 break;
290
291 case ASN1_OP_FREE_POST:
292 if (crl->meth->crl_free)
293 {
294 if (!crl->meth->crl_free(crl))
295 return 0;
296 }
297 if (crl->akid)
298 AUTHORITY_KEYID_free(crl->akid);
299 if (crl->idp)
300 ISSUING_DIST_POINT_free(crl->idp);
301 ASN1_INTEGER_free(crl->crl_number);
302 ASN1_INTEGER_free(crl->base_crl_number);
303 sk_GENERAL_NAMES_pop_free(crl->issuers, GENERAL_NAMES_free);
304 break;
305 }
306 return 1;
307 }
308
309/* Convert IDP into a more convenient form */
310
311static void setup_idp(X509_CRL *crl, ISSUING_DIST_POINT *idp)
312 {
313 int idp_only = 0;
314 /* Set various flags according to IDP */
315 crl->idp_flags |= IDP_PRESENT;
316 if (idp->onlyuser > 0)
317 {
318 idp_only++;
319 crl->idp_flags |= IDP_ONLYUSER;
320 }
321 if (idp->onlyCA > 0)
322 {
323 idp_only++;
324 crl->idp_flags |= IDP_ONLYCA;
325 }
326 if (idp->onlyattr > 0)
327 {
328 idp_only++;
329 crl->idp_flags |= IDP_ONLYATTR;
330 }
331
332 if (idp_only > 1)
333 crl->idp_flags |= IDP_INVALID;
334
335 if (idp->indirectCRL > 0)
336 crl->idp_flags |= IDP_INDIRECT;
337
338 if (idp->onlysomereasons)
339 {
340 crl->idp_flags |= IDP_REASONS;
341 if (idp->onlysomereasons->length > 0)
342 crl->idp_reasons = idp->onlysomereasons->data[0];
343 if (idp->onlysomereasons->length > 1)
344 crl->idp_reasons |=
345 (idp->onlysomereasons->data[1] << 8);
346 crl->idp_reasons &= CRLDP_ALL_REASONS;
347 }
348
349 DIST_POINT_set_dpname(idp->distpoint, X509_CRL_get_issuer(crl));
350 }
351
352ASN1_SEQUENCE_ref(X509_CRL, crl_cb, CRYPTO_LOCK_X509_CRL) = {
105 ASN1_SIMPLE(X509_CRL, crl, X509_CRL_INFO), 353 ASN1_SIMPLE(X509_CRL, crl, X509_CRL_INFO),
106 ASN1_SIMPLE(X509_CRL, sig_alg, X509_ALGOR), 354 ASN1_SIMPLE(X509_CRL, sig_alg, X509_ALGOR),
107 ASN1_SIMPLE(X509_CRL, signature, ASN1_BIT_STRING) 355 ASN1_SIMPLE(X509_CRL, signature, ASN1_BIT_STRING)
@@ -134,6 +382,145 @@ int X509_CRL_add0_revoked(X509_CRL *crl, X509_REVOKED *rev)
134 return 1; 382 return 1;
135} 383}
136 384
385int X509_CRL_verify(X509_CRL *crl, EVP_PKEY *r)
386 {
387 if (crl->meth->crl_verify)
388 return crl->meth->crl_verify(crl, r);
389 return 0;
390 }
391
392int X509_CRL_get0_by_serial(X509_CRL *crl,
393 X509_REVOKED **ret, ASN1_INTEGER *serial)
394 {
395 if (crl->meth->crl_lookup)
396 return crl->meth->crl_lookup(crl, ret, serial, NULL);
397 return 0;
398 }
399
400int X509_CRL_get0_by_cert(X509_CRL *crl, X509_REVOKED **ret, X509 *x)
401 {
402 if (crl->meth->crl_lookup)
403 return crl->meth->crl_lookup(crl, ret,
404 X509_get_serialNumber(x),
405 X509_get_issuer_name(x));
406 return 0;
407 }
408
409static int def_crl_verify(X509_CRL *crl, EVP_PKEY *r)
410 {
411 return(ASN1_item_verify(ASN1_ITEM_rptr(X509_CRL_INFO),
412 crl->sig_alg, crl->signature,crl->crl,r));
413 }
414
415static int crl_revoked_issuer_match(X509_CRL *crl, X509_NAME *nm,
416 X509_REVOKED *rev)
417 {
418 int i;
419
420 if (!rev->issuer)
421 {
422 if (!nm)
423 return 1;
424 if (!X509_NAME_cmp(nm, X509_CRL_get_issuer(crl)))
425 return 1;
426 return 0;
427 }
428
429 if (!nm)
430 nm = X509_CRL_get_issuer(crl);
431
432 for (i = 0; i < sk_GENERAL_NAME_num(rev->issuer); i++)
433 {
434 GENERAL_NAME *gen = sk_GENERAL_NAME_value(rev->issuer, i);
435 if (gen->type != GEN_DIRNAME)
436 continue;
437 if (!X509_NAME_cmp(nm, gen->d.directoryName))
438 return 1;
439 }
440 return 0;
441
442 }
443
444static int def_crl_lookup(X509_CRL *crl,
445 X509_REVOKED **ret, ASN1_INTEGER *serial, X509_NAME *issuer)
446 {
447 X509_REVOKED rtmp, *rev;
448 int idx;
449 rtmp.serialNumber = serial;
450 /* Sort revoked into serial number order if not already sorted.
451 * Do this under a lock to avoid race condition.
452 */
453 if (!sk_X509_REVOKED_is_sorted(crl->crl->revoked))
454 {
455 CRYPTO_w_lock(CRYPTO_LOCK_X509_CRL);
456 sk_X509_REVOKED_sort(crl->crl->revoked);
457 CRYPTO_w_unlock(CRYPTO_LOCK_X509_CRL);
458 }
459 idx = sk_X509_REVOKED_find(crl->crl->revoked, &rtmp);
460 if(idx < 0)
461 return 0;
462 /* Need to look for matching name */
463 for(;idx < sk_X509_REVOKED_num(crl->crl->revoked); idx++)
464 {
465 rev = sk_X509_REVOKED_value(crl->crl->revoked, idx);
466 if (ASN1_INTEGER_cmp(rev->serialNumber, serial))
467 return 0;
468 if (crl_revoked_issuer_match(crl, issuer, rev))
469 {
470 if (ret)
471 *ret = rev;
472 if (rev->reason == CRL_REASON_REMOVE_FROM_CRL)
473 return 2;
474 return 1;
475 }
476 }
477 return 0;
478 }
479
480void X509_CRL_set_default_method(const X509_CRL_METHOD *meth)
481 {
482 if (meth == NULL)
483 default_crl_method = &int_crl_meth;
484 else
485 default_crl_method = meth;
486 }
487
488X509_CRL_METHOD *X509_CRL_METHOD_new(
489 int (*crl_init)(X509_CRL *crl),
490 int (*crl_free)(X509_CRL *crl),
491 int (*crl_lookup)(X509_CRL *crl, X509_REVOKED **ret,
492 ASN1_INTEGER *ser, X509_NAME *issuer),
493 int (*crl_verify)(X509_CRL *crl, EVP_PKEY *pk))
494 {
495 X509_CRL_METHOD *m;
496 m = OPENSSL_malloc(sizeof(X509_CRL_METHOD));
497 if (!m)
498 return NULL;
499 m->crl_init = crl_init;
500 m->crl_free = crl_free;
501 m->crl_lookup = crl_lookup;
502 m->crl_verify = crl_verify;
503 m->flags = X509_CRL_METHOD_DYNAMIC;
504 return m;
505 }
506
507void X509_CRL_METHOD_free(X509_CRL_METHOD *m)
508 {
509 if (!(m->flags & X509_CRL_METHOD_DYNAMIC))
510 return;
511 OPENSSL_free(m);
512 }
513
514void X509_CRL_set_meth_data(X509_CRL *crl, void *dat)
515 {
516 crl->meth_data = dat;
517 }
518
519void *X509_CRL_get_meth_data(X509_CRL *crl)
520 {
521 return crl->meth_data;
522 }
523
137IMPLEMENT_STACK_OF(X509_REVOKED) 524IMPLEMENT_STACK_OF(X509_REVOKED)
138IMPLEMENT_ASN1_SET_OF(X509_REVOKED) 525IMPLEMENT_ASN1_SET_OF(X509_REVOKED)
139IMPLEMENT_STACK_OF(X509_CRL) 526IMPLEMENT_STACK_OF(X509_CRL)
diff --git a/src/lib/libcrypto/asn1/x_long.c b/src/lib/libcrypto/asn1/x_long.c
index bf35457c1f..75317418e1 100644
--- a/src/lib/libcrypto/asn1/x_long.c
+++ b/src/lib/libcrypto/asn1/x_long.c
@@ -71,6 +71,7 @@ static void long_free(ASN1_VALUE **pval, const ASN1_ITEM *it);
71 71
72static int long_i2c(ASN1_VALUE **pval, unsigned char *cont, int *putype, const ASN1_ITEM *it); 72static int long_i2c(ASN1_VALUE **pval, unsigned char *cont, int *putype, const ASN1_ITEM *it);
73static int long_c2i(ASN1_VALUE **pval, const unsigned char *cont, int len, int utype, char *free_cont, const ASN1_ITEM *it); 73static int long_c2i(ASN1_VALUE **pval, const unsigned char *cont, int len, int utype, char *free_cont, const ASN1_ITEM *it);
74static int long_print(BIO *out, ASN1_VALUE **pval, const ASN1_ITEM *it, int indent, const ASN1_PCTX *pctx);
74 75
75static ASN1_PRIMITIVE_FUNCS long_pf = { 76static ASN1_PRIMITIVE_FUNCS long_pf = {
76 NULL, 0, 77 NULL, 0,
@@ -78,7 +79,8 @@ static ASN1_PRIMITIVE_FUNCS long_pf = {
78 long_free, 79 long_free,
79 long_free, /* Clear should set to initial value */ 80 long_free, /* Clear should set to initial value */
80 long_c2i, 81 long_c2i,
81 long_i2c 82 long_i2c,
83 long_print
82}; 84};
83 85
84ASN1_ITEM_start(LONG) 86ASN1_ITEM_start(LONG)
@@ -169,3 +171,9 @@ static int long_c2i(ASN1_VALUE **pval, const unsigned char *cont, int len,
169 memcpy(cp, &ltmp, sizeof(long)); 171 memcpy(cp, &ltmp, sizeof(long));
170 return 1; 172 return 1;
171} 173}
174
175static int long_print(BIO *out, ASN1_VALUE **pval, const ASN1_ITEM *it,
176 int indent, const ASN1_PCTX *pctx)
177 {
178 return BIO_printf(out, "%ld\n", *(long *)pval);
179 }
diff --git a/src/lib/libcrypto/asn1/x_name.c b/src/lib/libcrypto/asn1/x_name.c
index 04380abc3f..caa4409feb 100644
--- a/src/lib/libcrypto/asn1/x_name.c
+++ b/src/lib/libcrypto/asn1/x_name.c
@@ -57,18 +57,36 @@
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/asn1t.h> 62#include <openssl/asn1t.h>
62#include <openssl/x509.h> 63#include <openssl/x509.h>
64#include "asn1_locl.h"
63 65
64static int x509_name_ex_d2i(ASN1_VALUE **val, const unsigned char **in, long len, const ASN1_ITEM *it, 66typedef STACK_OF(X509_NAME_ENTRY) STACK_OF_X509_NAME_ENTRY;
65 int tag, int aclass, char opt, ASN1_TLC *ctx); 67DECLARE_STACK_OF(STACK_OF_X509_NAME_ENTRY)
66 68
67static int x509_name_ex_i2d(ASN1_VALUE **val, unsigned char **out, const ASN1_ITEM *it, int tag, int aclass); 69static int x509_name_ex_d2i(ASN1_VALUE **val,
70 const unsigned char **in, long len,
71 const ASN1_ITEM *it,
72 int tag, int aclass, char opt, ASN1_TLC *ctx);
73
74static int x509_name_ex_i2d(ASN1_VALUE **val, unsigned char **out,
75 const ASN1_ITEM *it, int tag, int aclass);
68static int x509_name_ex_new(ASN1_VALUE **val, const ASN1_ITEM *it); 76static int x509_name_ex_new(ASN1_VALUE **val, const ASN1_ITEM *it);
69static void x509_name_ex_free(ASN1_VALUE **val, const ASN1_ITEM *it); 77static void x509_name_ex_free(ASN1_VALUE **val, const ASN1_ITEM *it);
70 78
71static int x509_name_encode(X509_NAME *a); 79static int x509_name_encode(X509_NAME *a);
80static int x509_name_canon(X509_NAME *a);
81static int asn1_string_canon(ASN1_STRING *out, ASN1_STRING *in);
82static int i2d_name_canon(STACK_OF(STACK_OF_X509_NAME_ENTRY) *intname,
83 unsigned char **in);
84
85
86static int x509_name_ex_print(BIO *out, ASN1_VALUE **pval,
87 int indent,
88 const char *fname,
89 const ASN1_PCTX *pctx);
72 90
73ASN1_SEQUENCE(X509_NAME_ENTRY) = { 91ASN1_SEQUENCE(X509_NAME_ENTRY) = {
74 ASN1_SIMPLE(X509_NAME_ENTRY, object, ASN1_OBJECT), 92 ASN1_SIMPLE(X509_NAME_ENTRY, object, ASN1_OBJECT),
@@ -102,7 +120,8 @@ const ASN1_EXTERN_FUNCS x509_name_ff = {
102 x509_name_ex_free, 120 x509_name_ex_free,
103 0, /* Default clear behaviour is OK */ 121 0, /* Default clear behaviour is OK */
104 x509_name_ex_d2i, 122 x509_name_ex_d2i,
105 x509_name_ex_i2d 123 x509_name_ex_i2d,
124 x509_name_ex_print
106}; 125};
107 126
108IMPLEMENT_EXTERN_ASN1(X509_NAME, V_ASN1_SEQUENCE, x509_name_ff) 127IMPLEMENT_EXTERN_ASN1(X509_NAME, V_ASN1_SEQUENCE, x509_name_ff)
@@ -118,6 +137,8 @@ static int x509_name_ex_new(ASN1_VALUE **val, const ASN1_ITEM *it)
118 if ((ret->entries=sk_X509_NAME_ENTRY_new_null()) == NULL) 137 if ((ret->entries=sk_X509_NAME_ENTRY_new_null()) == NULL)
119 goto memerr; 138 goto memerr;
120 if((ret->bytes = BUF_MEM_new()) == NULL) goto memerr; 139 if((ret->bytes = BUF_MEM_new()) == NULL) goto memerr;
140 ret->canon_enc = NULL;
141 ret->canon_enclen = 0;
121 ret->modified=1; 142 ret->modified=1;
122 *val = (ASN1_VALUE *)ret; 143 *val = (ASN1_VALUE *)ret;
123 return 1; 144 return 1;
@@ -142,25 +163,19 @@ static void x509_name_ex_free(ASN1_VALUE **pval, const ASN1_ITEM *it)
142 163
143 BUF_MEM_free(a->bytes); 164 BUF_MEM_free(a->bytes);
144 sk_X509_NAME_ENTRY_pop_free(a->entries,X509_NAME_ENTRY_free); 165 sk_X509_NAME_ENTRY_pop_free(a->entries,X509_NAME_ENTRY_free);
166 if (a->canon_enc)
167 OPENSSL_free(a->canon_enc);
145 OPENSSL_free(a); 168 OPENSSL_free(a);
146 *pval = NULL; 169 *pval = NULL;
147} 170}
148 171
149/* Used with sk_pop_free() to free up the internal representation. 172static int x509_name_ex_d2i(ASN1_VALUE **val,
150 * NB: we only free the STACK and not its contents because it is 173 const unsigned char **in, long len, const ASN1_ITEM *it,
151 * already present in the X509_NAME structure. 174 int tag, int aclass, char opt, ASN1_TLC *ctx)
152 */
153
154static void sk_internal_free(void *a)
155{
156 sk_free(a);
157}
158
159static int x509_name_ex_d2i(ASN1_VALUE **val, const unsigned char **in, long len, const ASN1_ITEM *it,
160 int tag, int aclass, char opt, ASN1_TLC *ctx)
161{ 175{
162 const unsigned char *p = *in, *q; 176 const unsigned char *p = *in, *q;
163 union { STACK *s; ASN1_VALUE *a; } intname = {NULL}; 177 union { STACK_OF(STACK_OF_X509_NAME_ENTRY) *s;
178 ASN1_VALUE *a; } intname = {NULL};
164 union { X509_NAME *x; ASN1_VALUE *a; } nm = {NULL}; 179 union { X509_NAME *x; ASN1_VALUE *a; } nm = {NULL};
165 int i, j, ret; 180 int i, j, ret;
166 STACK_OF(X509_NAME_ENTRY) *entries; 181 STACK_OF(X509_NAME_ENTRY) *entries;
@@ -181,8 +196,8 @@ static int x509_name_ex_d2i(ASN1_VALUE **val, const unsigned char **in, long len
181 memcpy(nm.x->bytes->data, q, p - q); 196 memcpy(nm.x->bytes->data, q, p - q);
182 197
183 /* Convert internal representation to X509_NAME structure */ 198 /* Convert internal representation to X509_NAME structure */
184 for(i = 0; i < sk_num(intname.s); i++) { 199 for(i = 0; i < sk_STACK_OF_X509_NAME_ENTRY_num(intname.s); i++) {
185 entries = (STACK_OF(X509_NAME_ENTRY) *)sk_value(intname.s, i); 200 entries = sk_STACK_OF_X509_NAME_ENTRY_value(intname.s, i);
186 for(j = 0; j < sk_X509_NAME_ENTRY_num(entries); j++) { 201 for(j = 0; j < sk_X509_NAME_ENTRY_num(entries); j++) {
187 entry = sk_X509_NAME_ENTRY_value(entries, j); 202 entry = sk_X509_NAME_ENTRY_value(entries, j);
188 entry->set = i; 203 entry->set = i;
@@ -191,7 +206,10 @@ static int x509_name_ex_d2i(ASN1_VALUE **val, const unsigned char **in, long len
191 } 206 }
192 sk_X509_NAME_ENTRY_free(entries); 207 sk_X509_NAME_ENTRY_free(entries);
193 } 208 }
194 sk_free(intname.s); 209 sk_STACK_OF_X509_NAME_ENTRY_free(intname.s);
210 ret = x509_name_canon(nm.x);
211 if (!ret)
212 goto err;
195 nm.x->modified = 0; 213 nm.x->modified = 0;
196 *val = nm.a; 214 *val = nm.a;
197 *in = p; 215 *in = p;
@@ -206,8 +224,12 @@ static int x509_name_ex_i2d(ASN1_VALUE **val, unsigned char **out, const ASN1_IT
206 int ret; 224 int ret;
207 X509_NAME *a = (X509_NAME *)*val; 225 X509_NAME *a = (X509_NAME *)*val;
208 if(a->modified) { 226 if(a->modified) {
209 ret = x509_name_encode((X509_NAME *)a); 227 ret = x509_name_encode(a);
210 if(ret < 0) return ret; 228 if(ret < 0)
229 return ret;
230 ret = x509_name_canon(a);
231 if(ret < 0)
232 return ret;
211 } 233 }
212 ret = a->bytes->length; 234 ret = a->bytes->length;
213 if(out != NULL) { 235 if(out != NULL) {
@@ -217,22 +239,35 @@ static int x509_name_ex_i2d(ASN1_VALUE **val, unsigned char **out, const ASN1_IT
217 return ret; 239 return ret;
218} 240}
219 241
242static void local_sk_X509_NAME_ENTRY_free(STACK_OF(X509_NAME_ENTRY) *ne)
243 {
244 sk_X509_NAME_ENTRY_free(ne);
245 }
246
247static void local_sk_X509_NAME_ENTRY_pop_free(STACK_OF(X509_NAME_ENTRY) *ne)
248 {
249 sk_X509_NAME_ENTRY_pop_free(ne, X509_NAME_ENTRY_free);
250 }
251
220static int x509_name_encode(X509_NAME *a) 252static int x509_name_encode(X509_NAME *a)
221{ 253{
222 union { STACK *s; ASN1_VALUE *a; } intname = {NULL}; 254 union { STACK_OF(STACK_OF_X509_NAME_ENTRY) *s;
255 ASN1_VALUE *a; } intname = {NULL};
223 int len; 256 int len;
224 unsigned char *p; 257 unsigned char *p;
225 STACK_OF(X509_NAME_ENTRY) *entries = NULL; 258 STACK_OF(X509_NAME_ENTRY) *entries = NULL;
226 X509_NAME_ENTRY *entry; 259 X509_NAME_ENTRY *entry;
227 int i, set = -1; 260 int i, set = -1;
228 intname.s = sk_new_null(); 261 intname.s = sk_STACK_OF_X509_NAME_ENTRY_new_null();
229 if(!intname.s) goto memerr; 262 if(!intname.s) goto memerr;
230 for(i = 0; i < sk_X509_NAME_ENTRY_num(a->entries); i++) { 263 for(i = 0; i < sk_X509_NAME_ENTRY_num(a->entries); i++) {
231 entry = sk_X509_NAME_ENTRY_value(a->entries, i); 264 entry = sk_X509_NAME_ENTRY_value(a->entries, i);
232 if(entry->set != set) { 265 if(entry->set != set) {
233 entries = sk_X509_NAME_ENTRY_new_null(); 266 entries = sk_X509_NAME_ENTRY_new_null();
234 if(!entries) goto memerr; 267 if(!entries) goto memerr;
235 if(!sk_push(intname.s, (char *)entries)) goto memerr; 268 if(!sk_STACK_OF_X509_NAME_ENTRY_push(intname.s,
269 entries))
270 goto memerr;
236 set = entry->set; 271 set = entry->set;
237 } 272 }
238 if(!sk_X509_NAME_ENTRY_push(entries, entry)) goto memerr; 273 if(!sk_X509_NAME_ENTRY_push(entries, entry)) goto memerr;
@@ -243,15 +278,222 @@ static int x509_name_encode(X509_NAME *a)
243 p=(unsigned char *)a->bytes->data; 278 p=(unsigned char *)a->bytes->data;
244 ASN1_item_ex_i2d(&intname.a, 279 ASN1_item_ex_i2d(&intname.a,
245 &p, ASN1_ITEM_rptr(X509_NAME_INTERNAL), -1, -1); 280 &p, ASN1_ITEM_rptr(X509_NAME_INTERNAL), -1, -1);
246 sk_pop_free(intname.s, sk_internal_free); 281 sk_STACK_OF_X509_NAME_ENTRY_pop_free(intname.s,
282 local_sk_X509_NAME_ENTRY_free);
247 a->modified = 0; 283 a->modified = 0;
248 return len; 284 return len;
249 memerr: 285memerr:
250 sk_pop_free(intname.s, sk_internal_free); 286 sk_STACK_OF_X509_NAME_ENTRY_pop_free(intname.s,
287 local_sk_X509_NAME_ENTRY_free);
251 ASN1err(ASN1_F_X509_NAME_ENCODE, ERR_R_MALLOC_FAILURE); 288 ASN1err(ASN1_F_X509_NAME_ENCODE, ERR_R_MALLOC_FAILURE);
252 return -1; 289 return -1;
253} 290}
254 291
292static int x509_name_ex_print(BIO *out, ASN1_VALUE **pval,
293 int indent,
294 const char *fname,
295 const ASN1_PCTX *pctx)
296 {
297 if (X509_NAME_print_ex(out, (X509_NAME *)*pval,
298 indent, pctx->nm_flags) <= 0)
299 return 0;
300 return 2;
301 }
302
303/* This function generates the canonical encoding of the Name structure.
304 * In it all strings are converted to UTF8, leading, trailing and
305 * multiple spaces collapsed, converted to lower case and the leading
306 * SEQUENCE header removed.
307 *
308 * In future we could also normalize the UTF8 too.
309 *
310 * By doing this comparison of Name structures can be rapidly
311 * perfomed by just using memcmp() of the canonical encoding.
312 * By omitting the leading SEQUENCE name constraints of type
313 * dirName can also be checked with a simple memcmp().
314 */
315
316static int x509_name_canon(X509_NAME *a)
317 {
318 unsigned char *p;
319 STACK_OF(STACK_OF_X509_NAME_ENTRY) *intname = NULL;
320 STACK_OF(X509_NAME_ENTRY) *entries = NULL;
321 X509_NAME_ENTRY *entry, *tmpentry = NULL;
322 int i, set = -1, ret = 0;
323
324 if (a->canon_enc)
325 {
326 OPENSSL_free(a->canon_enc);
327 a->canon_enc = NULL;
328 }
329 /* Special case: empty X509_NAME => null encoding */
330 if (sk_X509_NAME_ENTRY_num(a->entries) == 0)
331 {
332 a->canon_enclen = 0;
333 return 1;
334 }
335 intname = sk_STACK_OF_X509_NAME_ENTRY_new_null();
336 if(!intname)
337 goto err;
338 for(i = 0; i < sk_X509_NAME_ENTRY_num(a->entries); i++)
339 {
340 entry = sk_X509_NAME_ENTRY_value(a->entries, i);
341 if(entry->set != set)
342 {
343 entries = sk_X509_NAME_ENTRY_new_null();
344 if(!entries)
345 goto err;
346 if(!sk_STACK_OF_X509_NAME_ENTRY_push(intname, entries))
347 goto err;
348 set = entry->set;
349 }
350 tmpentry = X509_NAME_ENTRY_new();
351 tmpentry->object = OBJ_dup(entry->object);
352 if (!asn1_string_canon(tmpentry->value, entry->value))
353 goto err;
354 if(!sk_X509_NAME_ENTRY_push(entries, tmpentry))
355 goto err;
356 tmpentry = NULL;
357 }
358
359 /* Finally generate encoding */
360
361 a->canon_enclen = i2d_name_canon(intname, NULL);
362
363 p = OPENSSL_malloc(a->canon_enclen);
364
365 if (!p)
366 goto err;
367
368 a->canon_enc = p;
369
370 i2d_name_canon(intname, &p);
371
372 ret = 1;
373
374 err:
375
376 if (tmpentry)
377 X509_NAME_ENTRY_free(tmpentry);
378 if (intname)
379 sk_STACK_OF_X509_NAME_ENTRY_pop_free(intname,
380 local_sk_X509_NAME_ENTRY_pop_free);
381 return ret;
382 }
383
384/* Bitmap of all the types of string that will be canonicalized. */
385
386#define ASN1_MASK_CANON \
387 (B_ASN1_UTF8STRING | B_ASN1_BMPSTRING | B_ASN1_UNIVERSALSTRING \
388 | B_ASN1_PRINTABLESTRING | B_ASN1_T61STRING | B_ASN1_IA5STRING \
389 | B_ASN1_VISIBLESTRING)
390
391
392static int asn1_string_canon(ASN1_STRING *out, ASN1_STRING *in)
393 {
394 unsigned char *to, *from;
395 int len, i;
396
397 /* If type not in bitmask just copy string across */
398 if (!(ASN1_tag2bit(in->type) & ASN1_MASK_CANON))
399 {
400 out->type = in->type;
401 if (!ASN1_STRING_set(out, in->data, in->length))
402 return 0;
403 return 1;
404 }
405
406 out->type = V_ASN1_UTF8STRING;
407 out->length = ASN1_STRING_to_UTF8(&out->data, in);
408 if (out->length == -1)
409 return 0;
410
411 to = out->data;
412 from = to;
413
414 len = out->length;
415
416 /* Convert string in place to canonical form.
417 * Ultimately we may need to handle a wider range of characters
418 * but for now ignore anything with MSB set and rely on the
419 * isspace() and tolower() functions.
420 */
421
422 /* Ignore leading spaces */
423 while((len > 0) && !(*from & 0x80) && isspace(*from))
424 {
425 from++;
426 len--;
427 }
428
429 to = from + len - 1;
430
431 /* Ignore trailing spaces */
432 while ((len > 0) && !(*to & 0x80) && isspace(*to))
433 {
434 to--;
435 len--;
436 }
437
438 to = out->data;
439
440 i = 0;
441 while(i < len)
442 {
443 /* If MSB set just copy across */
444 if (*from & 0x80)
445 {
446 *to++ = *from++;
447 i++;
448 }
449 /* Collapse multiple spaces */
450 else if (isspace(*from))
451 {
452 /* Copy one space across */
453 *to++ = ' ';
454 /* Ignore subsequent spaces. Note: don't need to
455 * check len here because we know the last
456 * character is a non-space so we can't overflow.
457 */
458 do
459 {
460 from++;
461 i++;
462 }
463 while(!(*from & 0x80) && isspace(*from));
464 }
465 else
466 {
467 *to++ = tolower(*from++);
468 i++;
469 }
470 }
471
472 out->length = to - out->data;
473
474 return 1;
475
476 }
477
478static int i2d_name_canon(STACK_OF(STACK_OF_X509_NAME_ENTRY) *_intname,
479 unsigned char **in)
480 {
481 int i, len, ltmp;
482 ASN1_VALUE *v;
483 STACK_OF(ASN1_VALUE) *intname = (STACK_OF(ASN1_VALUE) *)_intname;
484
485 len = 0;
486 for (i = 0; i < sk_ASN1_VALUE_num(intname); i++)
487 {
488 v = sk_ASN1_VALUE_value(intname, i);
489 ltmp = ASN1_item_ex_i2d(&v, in,
490 ASN1_ITEM_rptr(X509_NAME_ENTRIES), -1, -1);
491 if (ltmp < 0)
492 return ltmp;
493 len += ltmp;
494 }
495 return len;
496 }
255 497
256int X509_NAME_set(X509_NAME **xn, X509_NAME *name) 498int X509_NAME_set(X509_NAME **xn, X509_NAME *name)
257 { 499 {
diff --git a/src/lib/libcrypto/asn1/x_pubkey.c b/src/lib/libcrypto/asn1/x_pubkey.c
index 91c2756116..d42b6a2c54 100644
--- a/src/lib/libcrypto/asn1/x_pubkey.c
+++ b/src/lib/libcrypto/asn1/x_pubkey.c
@@ -60,6 +60,7 @@
60#include "cryptlib.h" 60#include "cryptlib.h"
61#include <openssl/asn1t.h> 61#include <openssl/asn1t.h>
62#include <openssl/x509.h> 62#include <openssl/x509.h>
63#include "asn1_locl.h"
63#ifndef OPENSSL_NO_RSA 64#ifndef OPENSSL_NO_RSA
64#include <openssl/rsa.h> 65#include <openssl/rsa.h>
65#endif 66#endif
@@ -68,7 +69,8 @@
68#endif 69#endif
69 70
70/* Minor tweak to operation: free up EVP_PKEY */ 71/* Minor tweak to operation: free up EVP_PKEY */
71static int pubkey_cb(int operation, ASN1_VALUE **pval, const ASN1_ITEM *it) 72static int pubkey_cb(int operation, ASN1_VALUE **pval, const ASN1_ITEM *it,
73 void *exarg)
72 { 74 {
73 if (operation == ASN1_OP_FREE_POST) 75 if (operation == ASN1_OP_FREE_POST)
74 { 76 {
@@ -88,169 +90,42 @@ IMPLEMENT_ASN1_FUNCTIONS(X509_PUBKEY)
88int X509_PUBKEY_set(X509_PUBKEY **x, EVP_PKEY *pkey) 90int X509_PUBKEY_set(X509_PUBKEY **x, EVP_PKEY *pkey)
89 { 91 {
90 X509_PUBKEY *pk=NULL; 92 X509_PUBKEY *pk=NULL;
91 X509_ALGOR *a;
92 ASN1_OBJECT *o;
93 unsigned char *s,*p = NULL;
94 int i;
95 93
96 if (x == NULL) return(0); 94 if (x == NULL) return(0);
97 95
98 if ((pk=X509_PUBKEY_new()) == NULL) goto err; 96 if ((pk=X509_PUBKEY_new()) == NULL) goto error;
99 a=pk->algor;
100 97
101 /* set the algorithm id */ 98 if (pkey->ameth)
102 if ((o=OBJ_nid2obj(pkey->type)) == NULL) goto err;
103 ASN1_OBJECT_free(a->algorithm);
104 a->algorithm=o;
105
106 /* Set the parameter list */
107 if (!pkey->save_parameters || (pkey->type == EVP_PKEY_RSA))
108 { 99 {
109 if ((a->parameter == NULL) || 100 if (pkey->ameth->pub_encode)
110 (a->parameter->type != V_ASN1_NULL))
111 { 101 {
112 ASN1_TYPE_free(a->parameter); 102 if (!pkey->ameth->pub_encode(pk, pkey))
113 if (!(a->parameter=ASN1_TYPE_new()))
114 { 103 {
115 X509err(X509_F_X509_PUBKEY_SET,ERR_R_MALLOC_FAILURE); 104 X509err(X509_F_X509_PUBKEY_SET,
116 goto err; 105 X509_R_PUBLIC_KEY_ENCODE_ERROR);
106 goto error;
117 } 107 }
118 a->parameter->type=V_ASN1_NULL;
119 }
120 }
121#ifndef OPENSSL_NO_DSA
122 else if (pkey->type == EVP_PKEY_DSA)
123 {
124 unsigned char *pp;
125 DSA *dsa;
126
127 dsa=pkey->pkey.dsa;
128 dsa->write_params=0;
129 ASN1_TYPE_free(a->parameter);
130 if ((i=i2d_DSAparams(dsa,NULL)) <= 0)
131 goto err;
132 if (!(p=(unsigned char *)OPENSSL_malloc(i)))
133 {
134 X509err(X509_F_X509_PUBKEY_SET,ERR_R_MALLOC_FAILURE);
135 goto err;
136 }
137 pp=p;
138 i2d_DSAparams(dsa,&pp);
139 if (!(a->parameter=ASN1_TYPE_new()))
140 {
141 OPENSSL_free(p);
142 X509err(X509_F_X509_PUBKEY_SET,ERR_R_MALLOC_FAILURE);
143 goto err;
144 }
145 a->parameter->type=V_ASN1_SEQUENCE;
146 if (!(a->parameter->value.sequence=ASN1_STRING_new()))
147 {
148 OPENSSL_free(p);
149 X509err(X509_F_X509_PUBKEY_SET,ERR_R_MALLOC_FAILURE);
150 goto err;
151 } 108 }
152 if (!ASN1_STRING_set(a->parameter->value.sequence,p,i)) 109 else
153 { 110 {
154 OPENSSL_free(p); 111 X509err(X509_F_X509_PUBKEY_SET,
155 X509err(X509_F_X509_PUBKEY_SET,ERR_R_MALLOC_FAILURE); 112 X509_R_METHOD_NOT_SUPPORTED);
156 goto err; 113 goto error;
157 } 114 }
158 OPENSSL_free(p);
159 } 115 }
160#endif 116 else
161#ifndef OPENSSL_NO_EC
162 else if (pkey->type == EVP_PKEY_EC)
163 {
164 int nid=0;
165 unsigned char *pp;
166 EC_KEY *ec_key;
167 const EC_GROUP *group;
168
169 ec_key = pkey->pkey.ec;
170 ASN1_TYPE_free(a->parameter);
171
172 if ((a->parameter = ASN1_TYPE_new()) == NULL)
173 {
174 X509err(X509_F_X509_PUBKEY_SET, ERR_R_ASN1_LIB);
175 goto err;
176 }
177
178 group = EC_KEY_get0_group(ec_key);
179 if (EC_GROUP_get_asn1_flag(group)
180 && (nid = EC_GROUP_get_curve_name(group)))
181 {
182 /* just set the OID */
183 a->parameter->type = V_ASN1_OBJECT;
184 a->parameter->value.object = OBJ_nid2obj(nid);
185 }
186 else /* explicit parameters */
187 {
188 if ((i = i2d_ECParameters(ec_key, NULL)) == 0)
189 {
190 X509err(X509_F_X509_PUBKEY_SET, ERR_R_EC_LIB);
191 goto err;
192 }
193 if ((p = (unsigned char *) OPENSSL_malloc(i)) == NULL)
194 {
195 X509err(X509_F_X509_PUBKEY_SET, ERR_R_MALLOC_FAILURE);
196 goto err;
197 }
198 pp = p;
199 if (!i2d_ECParameters(ec_key, &pp))
200 {
201 X509err(X509_F_X509_PUBKEY_SET, ERR_R_EC_LIB);
202 OPENSSL_free(p);
203 goto err;
204 }
205 a->parameter->type = V_ASN1_SEQUENCE;
206 if ((a->parameter->value.sequence = ASN1_STRING_new()) == NULL)
207 {
208 X509err(X509_F_X509_PUBKEY_SET, ERR_R_ASN1_LIB);
209 OPENSSL_free(p);
210 goto err;
211 }
212 ASN1_STRING_set(a->parameter->value.sequence, p, i);
213 OPENSSL_free(p);
214 }
215 }
216#endif
217 else if (1)
218 { 117 {
219 X509err(X509_F_X509_PUBKEY_SET,X509_R_UNSUPPORTED_ALGORITHM); 118 X509err(X509_F_X509_PUBKEY_SET,X509_R_UNSUPPORTED_ALGORITHM);
220 goto err; 119 goto error;
221 } 120 }
222 121
223 if ((i=i2d_PublicKey(pkey,NULL)) <= 0) goto err;
224 if ((s=(unsigned char *)OPENSSL_malloc(i+1)) == NULL)
225 {
226 X509err(X509_F_X509_PUBKEY_SET,ERR_R_MALLOC_FAILURE);
227 goto err;
228 }
229 p=s;
230 i2d_PublicKey(pkey,&p);
231 if (!M_ASN1_BIT_STRING_set(pk->public_key,s,i))
232 {
233 X509err(X509_F_X509_PUBKEY_SET,ERR_R_MALLOC_FAILURE);
234 goto err;
235 }
236 /* Set number of unused bits to zero */
237 pk->public_key->flags&= ~(ASN1_STRING_FLAG_BITS_LEFT|0x07);
238 pk->public_key->flags|=ASN1_STRING_FLAG_BITS_LEFT;
239
240 OPENSSL_free(s);
241
242#if 0
243 CRYPTO_add(&pkey->references,1,CRYPTO_LOCK_EVP_PKEY);
244 pk->pkey=pkey;
245#endif
246
247 if (*x != NULL) 122 if (*x != NULL)
248 X509_PUBKEY_free(*x); 123 X509_PUBKEY_free(*x);
249 124
250 *x=pk; 125 *x=pk;
251 126
252 return 1; 127 return 1;
253err: 128error:
254 if (pk != NULL) X509_PUBKEY_free(pk); 129 if (pk != NULL) X509_PUBKEY_free(pk);
255 return 0; 130 return 0;
256 } 131 }
@@ -258,119 +133,50 @@ err:
258EVP_PKEY *X509_PUBKEY_get(X509_PUBKEY *key) 133EVP_PKEY *X509_PUBKEY_get(X509_PUBKEY *key)
259 { 134 {
260 EVP_PKEY *ret=NULL; 135 EVP_PKEY *ret=NULL;
261 long j;
262 int type;
263 const unsigned char *p;
264#if !defined(OPENSSL_NO_DSA) || !defined(OPENSSL_NO_ECDSA)
265 const unsigned char *cp;
266 X509_ALGOR *a;
267#endif
268 136
269 if (key == NULL) goto err; 137 if (key == NULL) goto error;
270 138
271 if (key->pkey != NULL) 139 if (key->pkey != NULL)
272 { 140 {
273 CRYPTO_add(&key->pkey->references, 1, CRYPTO_LOCK_EVP_PKEY); 141 CRYPTO_add(&key->pkey->references, 1, CRYPTO_LOCK_EVP_PKEY);
274 return(key->pkey); 142 return key->pkey;
275 } 143 }
276 144
277 if (key->public_key == NULL) goto err; 145 if (key->public_key == NULL) goto error;
278 146
279 type=OBJ_obj2nid(key->algor->algorithm);
280 if ((ret = EVP_PKEY_new()) == NULL) 147 if ((ret = EVP_PKEY_new()) == NULL)
281 { 148 {
282 X509err(X509_F_X509_PUBKEY_GET, ERR_R_MALLOC_FAILURE); 149 X509err(X509_F_X509_PUBKEY_GET, ERR_R_MALLOC_FAILURE);
283 goto err; 150 goto error;
284 } 151 }
285 ret->type = EVP_PKEY_type(type);
286
287 /* the parameters must be extracted before the public key (ECDSA!) */
288
289#if !defined(OPENSSL_NO_DSA) || !defined(OPENSSL_NO_ECDSA)
290 a=key->algor;
291#endif
292 152
293 if (0) 153 if (!EVP_PKEY_set_type(ret, OBJ_obj2nid(key->algor->algorithm)))
294 ;
295#ifndef OPENSSL_NO_DSA
296 else if (ret->type == EVP_PKEY_DSA)
297 { 154 {
298 if (a->parameter && (a->parameter->type == V_ASN1_SEQUENCE)) 155 X509err(X509_F_X509_PUBKEY_GET,X509_R_UNSUPPORTED_ALGORITHM);
299 { 156 goto error;
300 if ((ret->pkey.dsa = DSA_new()) == NULL)
301 {
302 X509err(X509_F_X509_PUBKEY_GET, ERR_R_MALLOC_FAILURE);
303 goto err;
304 }
305 ret->pkey.dsa->write_params=0;
306 cp=p=a->parameter->value.sequence->data;
307 j=a->parameter->value.sequence->length;
308 if (!d2i_DSAparams(&ret->pkey.dsa, &cp, (long)j))
309 goto err;
310 }
311 ret->save_parameters=1;
312 } 157 }
313#endif 158
314#ifndef OPENSSL_NO_EC 159 if (ret->ameth->pub_decode)
315 else if (ret->type == EVP_PKEY_EC)
316 { 160 {
317 if (a->parameter && (a->parameter->type == V_ASN1_SEQUENCE)) 161 if (!ret->ameth->pub_decode(ret, key))
318 { 162 {
319 /* type == V_ASN1_SEQUENCE => we have explicit parameters 163 X509err(X509_F_X509_PUBKEY_GET,
320 * (e.g. parameters in the X9_62_EC_PARAMETERS-structure ) 164 X509_R_PUBLIC_KEY_DECODE_ERROR);
321 */ 165 goto error;
322 if ((ret->pkey.ec= EC_KEY_new()) == NULL)
323 {
324 X509err(X509_F_X509_PUBKEY_GET,
325 ERR_R_MALLOC_FAILURE);
326 goto err;
327 }
328 cp = p = a->parameter->value.sequence->data;
329 j = a->parameter->value.sequence->length;
330 if (!d2i_ECParameters(&ret->pkey.ec, &cp, (long)j))
331 {
332 X509err(X509_F_X509_PUBKEY_GET, ERR_R_EC_LIB);
333 goto err;
334 }
335 }
336 else if (a->parameter && (a->parameter->type == V_ASN1_OBJECT))
337 {
338 /* type == V_ASN1_OBJECT => the parameters are given
339 * by an asn1 OID
340 */
341 EC_KEY *ec_key;
342 EC_GROUP *group;
343
344 if (ret->pkey.ec == NULL)
345 ret->pkey.ec = EC_KEY_new();
346 ec_key = ret->pkey.ec;
347 if (ec_key == NULL)
348 goto err;
349 group = EC_GROUP_new_by_curve_name(OBJ_obj2nid(a->parameter->value.object));
350 if (group == NULL)
351 goto err;
352 EC_GROUP_set_asn1_flag(group, OPENSSL_EC_NAMED_CURVE);
353 if (EC_KEY_set_group(ec_key, group) == 0)
354 goto err;
355 EC_GROUP_free(group);
356 } 166 }
357 /* the case implicitlyCA is currently not implemented */
358 ret->save_parameters = 1;
359 } 167 }
360#endif 168 else
361
362 p=key->public_key->data;
363 j=key->public_key->length;
364 if (!d2i_PublicKey(type, &ret, &p, (long)j))
365 { 169 {
366 X509err(X509_F_X509_PUBKEY_GET, X509_R_ERR_ASN1_LIB); 170 X509err(X509_F_X509_PUBKEY_GET, X509_R_METHOD_NOT_SUPPORTED);
367 goto err; 171 goto error;
368 } 172 }
369 173
370 key->pkey = ret; 174 key->pkey = ret;
371 CRYPTO_add(&ret->references, 1, CRYPTO_LOCK_EVP_PKEY); 175 CRYPTO_add(&ret->references, 1, CRYPTO_LOCK_EVP_PKEY);
372 return(ret); 176
373err: 177 return ret;
178
179 error:
374 if (ret != NULL) 180 if (ret != NULL)
375 EVP_PKEY_free(ret); 181 EVP_PKEY_free(ret);
376 return(NULL); 182 return(NULL);
@@ -529,3 +335,39 @@ int i2d_EC_PUBKEY(EC_KEY *a, unsigned char **pp)
529 return(ret); 335 return(ret);
530 } 336 }
531#endif 337#endif
338
339int X509_PUBKEY_set0_param(X509_PUBKEY *pub, ASN1_OBJECT *aobj,
340 int ptype, void *pval,
341 unsigned char *penc, int penclen)
342 {
343 if (!X509_ALGOR_set0(pub->algor, aobj, ptype, pval))
344 return 0;
345 if (penc)
346 {
347 if (pub->public_key->data)
348 OPENSSL_free(pub->public_key->data);
349 pub->public_key->data = penc;
350 pub->public_key->length = penclen;
351 /* Set number of unused bits to zero */
352 pub->public_key->flags&= ~(ASN1_STRING_FLAG_BITS_LEFT|0x07);
353 pub->public_key->flags|=ASN1_STRING_FLAG_BITS_LEFT;
354 }
355 return 1;
356 }
357
358int X509_PUBKEY_get0_param(ASN1_OBJECT **ppkalg,
359 const unsigned char **pk, int *ppklen,
360 X509_ALGOR **pa,
361 X509_PUBKEY *pub)
362 {
363 if (ppkalg)
364 *ppkalg = pub->algor->algorithm;
365 if (pk)
366 {
367 *pk = pub->public_key->data;
368 *ppklen = pub->public_key->length;
369 }
370 if (pa)
371 *pa = pub->algor;
372 return 1;
373 }
diff --git a/src/lib/libcrypto/asn1/x_req.c b/src/lib/libcrypto/asn1/x_req.c
index 59ca8ce329..d57555827c 100644
--- a/src/lib/libcrypto/asn1/x_req.c
+++ b/src/lib/libcrypto/asn1/x_req.c
@@ -79,7 +79,8 @@
79 * 79 *
80 */ 80 */
81 81
82static int rinf_cb(int operation, ASN1_VALUE **pval, const ASN1_ITEM *it) 82static int rinf_cb(int operation, ASN1_VALUE **pval, const ASN1_ITEM *it,
83 void *exarg)
83{ 84{
84 X509_REQ_INFO *rinf = (X509_REQ_INFO *)*pval; 85 X509_REQ_INFO *rinf = (X509_REQ_INFO *)*pval;
85 86
diff --git a/src/lib/libcrypto/asn1/x_x509.c b/src/lib/libcrypto/asn1/x_x509.c
index e118696625..dafd3cc921 100644
--- a/src/lib/libcrypto/asn1/x_x509.c
+++ b/src/lib/libcrypto/asn1/x_x509.c
@@ -81,7 +81,8 @@ IMPLEMENT_ASN1_FUNCTIONS(X509_CINF)
81 81
82extern void policy_cache_free(X509_POLICY_CACHE *cache); 82extern void policy_cache_free(X509_POLICY_CACHE *cache);
83 83
84static int x509_cb(int operation, ASN1_VALUE **pval, const ASN1_ITEM *it) 84static int x509_cb(int operation, ASN1_VALUE **pval, const ASN1_ITEM *it,
85 void *exarg)
85{ 86{
86 X509 *ret = (X509 *)*pval; 87 X509 *ret = (X509 *)*pval;
87 88
@@ -99,6 +100,7 @@ static int x509_cb(int operation, ASN1_VALUE **pval, const ASN1_ITEM *it)
99 ret->rfc3779_asid = NULL; 100 ret->rfc3779_asid = NULL;
100#endif 101#endif
101 ret->aux = NULL; 102 ret->aux = NULL;
103 ret->crldp = NULL;
102 CRYPTO_new_ex_data(CRYPTO_EX_INDEX_X509, ret, &ret->ex_data); 104 CRYPTO_new_ex_data(CRYPTO_EX_INDEX_X509, ret, &ret->ex_data);
103 break; 105 break;
104 106
@@ -112,7 +114,10 @@ static int x509_cb(int operation, ASN1_VALUE **pval, const ASN1_ITEM *it)
112 X509_CERT_AUX_free(ret->aux); 114 X509_CERT_AUX_free(ret->aux);
113 ASN1_OCTET_STRING_free(ret->skid); 115 ASN1_OCTET_STRING_free(ret->skid);
114 AUTHORITY_KEYID_free(ret->akid); 116 AUTHORITY_KEYID_free(ret->akid);
117 CRL_DIST_POINTS_free(ret->crldp);
115 policy_cache_free(ret->policy_cache); 118 policy_cache_free(ret->policy_cache);
119 GENERAL_NAMES_free(ret->altname);
120 NAME_CONSTRAINTS_free(ret->nc);
116#ifndef OPENSSL_NO_RFC3779 121#ifndef OPENSSL_NO_RFC3779
117 sk_IPAddressFamily_pop_free(ret->rfc3779_addr, IPAddressFamily_free); 122 sk_IPAddressFamily_pop_free(ret->rfc3779_addr, IPAddressFamily_free);
118 ASIdentifiers_free(ret->rfc3779_asid); 123 ASIdentifiers_free(ret->rfc3779_asid);
@@ -136,19 +141,6 @@ ASN1_SEQUENCE_ref(X509, x509_cb, CRYPTO_LOCK_X509) = {
136IMPLEMENT_ASN1_FUNCTIONS(X509) 141IMPLEMENT_ASN1_FUNCTIONS(X509)
137IMPLEMENT_ASN1_DUP_FUNCTION(X509) 142IMPLEMENT_ASN1_DUP_FUNCTION(X509)
138 143
139static ASN1_METHOD meth=
140 {
141 (I2D_OF(void)) i2d_X509,
142 (D2I_OF(void)) d2i_X509,
143 (void *(*)(void))X509_new,
144 (void (*)(void *)) X509_free
145 };
146
147ASN1_METHOD *X509_asn1_meth(void)
148 {
149 return(&meth);
150 }
151
152int X509_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func, 144int X509_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func,
153 CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func) 145 CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func)
154 { 146 {
diff --git a/src/lib/libcrypto/bf/Makefile.ssl b/src/lib/libcrypto/bf/Makefile.ssl
deleted file mode 100644
index be3ad77a05..0000000000
--- a/src/lib/libcrypto/bf/Makefile.ssl
+++ /dev/null
@@ -1,115 +0,0 @@
1#
2# SSLeay/crypto/blowfish/Makefile
3#
4
5DIR= bf
6TOP= ../..
7CC= cc
8CPP= $(CC) -E
9INCLUDES=
10CFLAG=-g
11INSTALL_PREFIX=
12OPENSSLDIR= /usr/local/ssl
13INSTALLTOP=/usr/local/ssl
14MAKE= make -f Makefile.ssl
15MAKEDEPPROG= makedepend
16MAKEDEPEND= $(TOP)/util/domd $(TOP) -MD $(MAKEDEPPROG)
17MAKEFILE= Makefile.ssl
18AR= ar r
19
20BF_ENC= bf_enc.o
21# or use
22#DES_ENC= bx86-elf.o
23
24CFLAGS= $(INCLUDES) $(CFLAG)
25ASFLAGS= $(INCLUDES) $(ASFLAG)
26
27GENERAL=Makefile
28TEST=bftest.c
29APPS=
30
31LIB=$(TOP)/libcrypto.a
32LIBSRC=bf_skey.c bf_ecb.c bf_enc.c bf_cfb64.c bf_ofb64.c
33LIBOBJ=bf_skey.o bf_ecb.o $(BF_ENC) bf_cfb64.o bf_ofb64.o
34
35SRC= $(LIBSRC)
36
37EXHEADER= blowfish.h
38HEADER= bf_pi.h bf_locl.h $(EXHEADER)
39
40ALL= $(GENERAL) $(SRC) $(HEADER)
41
42top:
43 (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all)
44
45all: lib
46
47lib: $(LIBOBJ)
48 $(AR) $(LIB) $(LIBOBJ)
49 $(RANLIB) $(LIB) || echo Never mind.
50 @touch lib
51
52# elf
53asm/bx86-elf.s: asm/bf-586.pl ../perlasm/x86asm.pl ../perlasm/cbc.pl
54 (cd asm; $(PERL) bf-586.pl elf $(CFLAGS) $(PROCESSOR) > bx86-elf.s)
55
56# a.out
57asm/bx86-out.o: asm/bx86unix.cpp
58 $(CPP) -DOUT asm/bx86unix.cpp | as -o asm/bx86-out.o
59
60# bsdi
61asm/bx86bsdi.o: asm/bx86unix.cpp
62 $(CPP) -DBSDI asm/bx86unix.cpp | sed 's/ :/:/' | as -o asm/bx86bsdi.o
63
64asm/bx86unix.cpp: asm/bf-586.pl ../perlasm/x86asm.pl ../perlasm/cbc.pl
65 (cd asm; $(PERL) bf-586.pl cpp $(PROCESSOR) >bx86unix.cpp)
66
67files:
68 $(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO
69
70links:
71 @sh $(TOP)/util/point.sh Makefile.ssl Makefile
72 @$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER)
73 @$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST)
74 @$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS)
75
76install: installs
77
78installs:
79 @for i in $(EXHEADER) ; \
80 do \
81 (cp $$i $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i; \
82 chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i ); \
83 done;
84
85tags:
86 ctags $(SRC)
87
88tests:
89
90lint:
91 lint -DLINT $(INCLUDES) $(SRC)>fluff
92
93depend:
94 $(MAKEDEPEND) -- $(CFLAG) $(INCLUDES) $(DEPFLAG) -- $(PROGS) $(LIBSRC)
95
96dclean:
97 $(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
98 mv -f Makefile.new $(MAKEFILE)
99
100clean:
101 rm -f asm/bx86unix.cpp asm/*-elf.* *.o asm/*.o *.obj lib tags core .pure .nfs* *.old *.bak fluff
102
103# DO NOT DELETE THIS LINE -- make depend depends on it.
104
105bf_cfb64.o: ../../include/openssl/blowfish.h ../../include/openssl/e_os2.h
106bf_cfb64.o: ../../include/openssl/opensslconf.h bf_cfb64.c bf_locl.h
107bf_ecb.o: ../../include/openssl/blowfish.h ../../include/openssl/e_os2.h
108bf_ecb.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
109bf_ecb.o: bf_ecb.c bf_locl.h
110bf_enc.o: ../../include/openssl/blowfish.h ../../include/openssl/e_os2.h
111bf_enc.o: ../../include/openssl/opensslconf.h bf_enc.c bf_locl.h
112bf_ofb64.o: ../../include/openssl/blowfish.h ../../include/openssl/e_os2.h
113bf_ofb64.o: ../../include/openssl/opensslconf.h bf_locl.h bf_ofb64.c
114bf_skey.o: ../../include/openssl/blowfish.h ../../include/openssl/e_os2.h
115bf_skey.o: ../../include/openssl/opensslconf.h bf_locl.h bf_pi.h bf_skey.c
diff --git a/src/lib/libcrypto/bf/asm/bf-586.pl b/src/lib/libcrypto/bf/asm/bf-586.pl
index b5a4760d09..1f9b345aee 100644
--- a/src/lib/libcrypto/bf/asm/bf-586.pl
+++ b/src/lib/libcrypto/bf/asm/bf-586.pl
@@ -1,6 +1,7 @@
1#!/usr/local/bin/perl 1#!/usr/local/bin/perl
2 2
3push(@INC,"perlasm","../../perlasm"); 3$0 =~ m/(.*[\/\\])[^\/\\]+$/; $dir=$1;
4push(@INC,"${dir}","${dir}../../perlasm");
4require "x86asm.pl"; 5require "x86asm.pl";
5require "cbc.pl"; 6require "cbc.pl";
6 7
diff --git a/src/lib/libcrypto/bf/bf_skey.c b/src/lib/libcrypto/bf/bf_skey.c
index 6ac2aeb279..3673cdee6e 100644
--- a/src/lib/libcrypto/bf/bf_skey.c
+++ b/src/lib/libcrypto/bf/bf_skey.c
@@ -59,15 +59,10 @@
59#include <stdio.h> 59#include <stdio.h>
60#include <string.h> 60#include <string.h>
61#include <openssl/blowfish.h> 61#include <openssl/blowfish.h>
62#include <openssl/crypto.h>
63#ifdef OPENSSL_FIPS
64#include <openssl/fips.h>
65#endif
66
67#include "bf_locl.h" 62#include "bf_locl.h"
68#include "bf_pi.h" 63#include "bf_pi.h"
69 64
70FIPS_NON_FIPS_VCIPHER_Init(BF) 65void BF_set_key(BF_KEY *key, int len, const unsigned char *data)
71 { 66 {
72 int i; 67 int i;
73 BF_LONG *p,ri,in[2]; 68 BF_LONG *p,ri,in[2];
diff --git a/src/lib/libcrypto/bf/blowfish.h b/src/lib/libcrypto/bf/blowfish.h
index d24ffccb65..b97e76f9a3 100644
--- a/src/lib/libcrypto/bf/blowfish.h
+++ b/src/lib/libcrypto/bf/blowfish.h
@@ -79,7 +79,7 @@ extern "C" {
79 * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 79 * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
80 */ 80 */
81 81
82#if defined(OPENSSL_SYS_WIN16) || defined(__LP32__) 82#if defined(__LP32__)
83#define BF_LONG unsigned long 83#define BF_LONG unsigned long
84#elif defined(OPENSSL_SYS_CRAY) || defined(__ILP64__) 84#elif defined(OPENSSL_SYS_CRAY) || defined(__ILP64__)
85#define BF_LONG unsigned long 85#define BF_LONG unsigned long
@@ -104,9 +104,7 @@ typedef struct bf_key_st
104 BF_LONG S[4*256]; 104 BF_LONG S[4*256];
105 } BF_KEY; 105 } BF_KEY;
106 106
107#ifdef OPENSSL_FIPS 107
108void private_BF_set_key(BF_KEY *key, int len, const unsigned char *data);
109#endif
110void BF_set_key(BF_KEY *key, int len, const unsigned char *data); 108void BF_set_key(BF_KEY *key, int len, const unsigned char *data);
111 109
112void BF_encrypt(BF_LONG *data,const BF_KEY *key); 110void BF_encrypt(BF_LONG *data,const BF_KEY *key);
diff --git a/src/lib/libcrypto/bio/Makefile.ssl b/src/lib/libcrypto/bio/Makefile.ssl
deleted file mode 100644
index d0b9e297b0..0000000000
--- a/src/lib/libcrypto/bio/Makefile.ssl
+++ /dev/null
@@ -1,216 +0,0 @@
1#
2# SSLeay/crypto/bio/Makefile
3#
4
5DIR= bio
6TOP= ../..
7CC= cc
8INCLUDES= -I.. -I$(TOP) -I../../include
9CFLAG=-g
10INSTALL_PREFIX=
11OPENSSLDIR= /usr/local/ssl
12INSTALLTOP=/usr/local/ssl
13MAKE= make -f Makefile.ssl
14MAKEDEPPROG= makedepend
15MAKEDEPEND= $(TOP)/util/domd $(TOP) -MD $(MAKEDEPPROG)
16MAKEFILE= Makefile.ssl
17AR= ar r
18
19CFLAGS= $(INCLUDES) $(CFLAG)
20
21GENERAL=Makefile
22TEST=
23APPS=
24
25LIB=$(TOP)/libcrypto.a
26LIBSRC= bio_lib.c bio_cb.c bio_err.c \
27 bss_mem.c bss_null.c bss_fd.c \
28 bss_file.c bss_sock.c bss_conn.c \
29 bf_null.c bf_buff.c b_print.c b_dump.c \
30 b_sock.c bss_acpt.c bf_nbio.c bss_log.c bss_bio.c
31# bf_lbuf.c
32LIBOBJ= bio_lib.o bio_cb.o bio_err.o \
33 bss_mem.o bss_null.o bss_fd.o \
34 bss_file.o bss_sock.o bss_conn.o \
35 bf_null.o bf_buff.o b_print.o b_dump.o \
36 b_sock.o bss_acpt.o bf_nbio.o bss_log.o bss_bio.o
37# bf_lbuf.o
38
39SRC= $(LIBSRC)
40
41EXHEADER= bio.h
42HEADER= bss_file.c $(EXHEADER)
43
44ALL= $(GENERAL) $(SRC) $(HEADER)
45
46top:
47 (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all)
48
49all: lib
50
51lib: $(LIBOBJ)
52 $(AR) $(LIB) $(LIBOBJ)
53 $(RANLIB) $(LIB) || echo Never mind.
54 @touch lib
55
56files:
57 $(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO
58
59links:
60 @sh $(TOP)/util/point.sh Makefile.ssl Makefile
61 @$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER)
62 @$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST)
63 @$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS)
64
65install:
66 @for i in $(EXHEADER); \
67 do \
68 (cp $$i $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i; \
69 chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i ); \
70 done;
71
72tags:
73 ctags $(SRC)
74
75tests:
76
77lint:
78 lint -DLINT $(INCLUDES) $(SRC)>fluff
79
80depend:
81 $(MAKEDEPEND) -- $(CFLAG) $(INCLUDES) $(DEPFLAG) -- $(PROGS) $(LIBSRC)
82
83dclean:
84 $(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
85 mv -f Makefile.new $(MAKEFILE)
86
87clean:
88 rm -f *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff
89
90# DO NOT DELETE THIS LINE -- make depend depends on it.
91
92b_dump.o: ../../e_os.h ../../include/openssl/bio.h
93b_dump.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
94b_dump.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
95b_dump.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
96b_dump.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
97b_dump.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
98b_dump.o: ../cryptlib.h b_dump.c
99b_print.o: ../../e_os.h ../../include/openssl/bio.h ../../include/openssl/bn.h
100b_print.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
101b_print.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
102b_print.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
103b_print.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
104b_print.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
105b_print.o: ../cryptlib.h b_print.c
106b_sock.o: ../../e_os.h ../../include/openssl/bio.h
107b_sock.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
108b_sock.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
109b_sock.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
110b_sock.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
111b_sock.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
112b_sock.o: ../cryptlib.h b_sock.c
113bf_buff.o: ../../e_os.h ../../include/openssl/bio.h
114bf_buff.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
115bf_buff.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
116bf_buff.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
117bf_buff.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
118bf_buff.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
119bf_buff.o: ../cryptlib.h bf_buff.c
120bf_nbio.o: ../../e_os.h ../../include/openssl/bio.h
121bf_nbio.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
122bf_nbio.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
123bf_nbio.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
124bf_nbio.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
125bf_nbio.o: ../../include/openssl/rand.h ../../include/openssl/safestack.h
126bf_nbio.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
127bf_nbio.o: ../cryptlib.h bf_nbio.c
128bf_null.o: ../../e_os.h ../../include/openssl/bio.h
129bf_null.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
130bf_null.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
131bf_null.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
132bf_null.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
133bf_null.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
134bf_null.o: ../cryptlib.h bf_null.c
135bio_cb.o: ../../e_os.h ../../include/openssl/bio.h
136bio_cb.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
137bio_cb.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
138bio_cb.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
139bio_cb.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
140bio_cb.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
141bio_cb.o: ../cryptlib.h bio_cb.c
142bio_err.o: ../../include/openssl/bio.h ../../include/openssl/crypto.h
143bio_err.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
144bio_err.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
145bio_err.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
146bio_err.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
147bio_err.o: bio_err.c
148bio_lib.o: ../../e_os.h ../../include/openssl/bio.h
149bio_lib.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
150bio_lib.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
151bio_lib.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
152bio_lib.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
153bio_lib.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
154bio_lib.o: ../cryptlib.h bio_lib.c
155bss_acpt.o: ../../e_os.h ../../include/openssl/bio.h
156bss_acpt.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
157bss_acpt.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
158bss_acpt.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
159bss_acpt.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
160bss_acpt.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
161bss_acpt.o: ../cryptlib.h bss_acpt.c
162bss_bio.o: ../../e_os.h ../../include/openssl/bio.h
163bss_bio.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
164bss_bio.o: ../../include/openssl/err.h ../../include/openssl/lhash.h
165bss_bio.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
166bss_bio.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
167bss_bio.o: ../../include/openssl/symhacks.h bss_bio.c
168bss_conn.o: ../../e_os.h ../../include/openssl/bio.h
169bss_conn.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
170bss_conn.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
171bss_conn.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
172bss_conn.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
173bss_conn.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
174bss_conn.o: ../cryptlib.h bss_conn.c
175bss_fd.o: ../../e_os.h ../../include/openssl/bio.h
176bss_fd.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
177bss_fd.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
178bss_fd.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
179bss_fd.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
180bss_fd.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
181bss_fd.o: ../cryptlib.h bss_fd.c
182bss_file.o: ../../e_os.h ../../include/openssl/bio.h
183bss_file.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
184bss_file.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
185bss_file.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
186bss_file.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
187bss_file.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
188bss_file.o: ../cryptlib.h bss_file.c
189bss_log.o: ../../e_os.h ../../include/openssl/bio.h
190bss_log.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
191bss_log.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
192bss_log.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
193bss_log.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
194bss_log.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
195bss_log.o: ../cryptlib.h bss_log.c
196bss_mem.o: ../../e_os.h ../../include/openssl/bio.h
197bss_mem.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
198bss_mem.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
199bss_mem.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
200bss_mem.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
201bss_mem.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
202bss_mem.o: ../cryptlib.h bss_mem.c
203bss_null.o: ../../e_os.h ../../include/openssl/bio.h
204bss_null.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
205bss_null.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
206bss_null.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
207bss_null.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
208bss_null.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
209bss_null.o: ../cryptlib.h bss_null.c
210bss_sock.o: ../../e_os.h ../../include/openssl/bio.h
211bss_sock.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
212bss_sock.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
213bss_sock.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
214bss_sock.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
215bss_sock.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
216bss_sock.o: ../cryptlib.h bss_sock.c
diff --git a/src/lib/libcrypto/bio/b_print.c b/src/lib/libcrypto/bio/b_print.c
index 2fffcfc025..143a7cfefa 100644
--- a/src/lib/libcrypto/bio/b_print.c
+++ b/src/lib/libcrypto/bio/b_print.c
@@ -115,8 +115,8 @@
115#define LDOUBLE double 115#define LDOUBLE double
116#endif 116#endif
117 117
118#if HAVE_LONG_LONG 118#ifdef HAVE_LONG_LONG
119# if defined(OPENSSL_SYS_WIN32) && !defined(__GNUC__) 119# if defined(_WIN32) && !defined(__GNUC__)
120# define LLONG __int64 120# define LLONG __int64
121# else 121# else
122# define LLONG long long 122# define LLONG long long
@@ -808,7 +808,6 @@ int BIO_vprintf (BIO *bio, const char *format, va_list args)
808 } 808 }
809 809
810/* As snprintf is not available everywhere, we provide our own implementation. 810/* As snprintf is not available everywhere, we provide our own implementation.
811 * In case of overflow or error, this returns -1.
812 * This function has nothing to do with BIOs, but it's closely related 811 * This function has nothing to do with BIOs, but it's closely related
813 * to BIO_printf, and we need *some* name prefix ... 812 * to BIO_printf, and we need *some* name prefix ...
814 * (XXX the function should be renamed, but to what?) */ 813 * (XXX the function should be renamed, but to what?) */
@@ -833,10 +832,10 @@ int BIO_vsnprintf(char *buf, size_t n, const char *format, va_list args)
833 _dopr(&buf, NULL, &n, &retlen, &truncated, format, args); 832 _dopr(&buf, NULL, &n, &retlen, &truncated, format, args);
834 833
835 if (truncated) 834 if (truncated)
836 /* In case of truncation, return -1 unlike traditional snprintf. 835 /* In case of truncation, return -1 like traditional snprintf.
837 * (Current drafts for ISO/IEC 9899 say snprintf should return 836 * (Current drafts for ISO/IEC 9899 say snprintf should return
838 * the number of characters that would have been written, 837 * the number of characters that would have been written,
839 * had the buffer been large enough, as it did historically.) */ 838 * had the buffer been large enough.) */
840 return -1; 839 return -1;
841 else 840 else
842 return (retlen <= INT_MAX) ? (int)retlen : -1; 841 return (retlen <= INT_MAX) ? (int)retlen : -1;
diff --git a/src/lib/libcrypto/bio/b_sock.c b/src/lib/libcrypto/bio/b_sock.c
index ead477d8a2..12b0a53a81 100644
--- a/src/lib/libcrypto/bio/b_sock.c
+++ b/src/lib/libcrypto/bio/b_sock.c
@@ -72,11 +72,9 @@ NETDB_DEFINE_CONTEXT
72 72
73#ifndef OPENSSL_NO_SOCK 73#ifndef OPENSSL_NO_SOCK
74 74
75#ifdef OPENSSL_SYS_WIN16 75#include <openssl/dso.h>
76#define SOCKET_PROTOCOL 0 /* more microsoft stupidity */ 76
77#else
78#define SOCKET_PROTOCOL IPPROTO_TCP 77#define SOCKET_PROTOCOL IPPROTO_TCP
79#endif
80 78
81#ifdef SO_MAXCONN 79#ifdef SO_MAXCONN
82#define MAX_LISTEN SO_MAXCONN 80#define MAX_LISTEN SO_MAXCONN
@@ -90,6 +88,17 @@ NETDB_DEFINE_CONTEXT
90static int wsa_init_done=0; 88static int wsa_init_done=0;
91#endif 89#endif
92 90
91/*
92 * WSAAPI specifier is required to make indirect calls to run-time
93 * linked WinSock 2 functions used in this module, to be specific
94 * [get|free]addrinfo and getnameinfo. This is because WinSock uses
95 * uses non-C calling convention, __stdcall vs. __cdecl, on x86
96 * Windows. On non-WinSock platforms WSAAPI needs to be void.
97 */
98#ifndef WSAAPI
99#define WSAAPI
100#endif
101
93#if 0 102#if 0
94static unsigned long BIO_ghbn_hits=0L; 103static unsigned long BIO_ghbn_hits=0L;
95static unsigned long BIO_ghbn_miss=0L; 104static unsigned long BIO_ghbn_miss=0L;
@@ -226,6 +235,10 @@ int BIO_sock_error(int sock)
226 int j,i; 235 int j,i;
227 int size; 236 int size;
228 237
238#if defined(OPENSSL_SYS_BEOS_R5)
239 return 0;
240#endif
241
229 size=sizeof(int); 242 size=sizeof(int);
230 /* Note: under Windows the third parameter is of type (char *) 243 /* Note: under Windows the third parameter is of type (char *)
231 * whereas under other systems it is (void *) if you don't have 244 * whereas under other systems it is (void *) if you don't have
@@ -466,7 +479,12 @@ int BIO_sock_init(void)
466 479
467 wsa_init_done=1; 480 wsa_init_done=1;
468 memset(&wsa_state,0,sizeof(wsa_state)); 481 memset(&wsa_state,0,sizeof(wsa_state));
469 if (WSAStartup(0x0101,&wsa_state)!=0) 482 /* Not making wsa_state available to the rest of the
483 * code is formally wrong. But the structures we use
484 * are [beleived to be] invariable among Winsock DLLs,
485 * while API availability is [expected to be] probed
486 * at run-time with DSO_global_lookup. */
487 if (WSAStartup(0x0202,&wsa_state)!=0)
470 { 488 {
471 err=WSAGetLastError(); 489 err=WSAGetLastError();
472 SYSerr(SYS_F_WSASTARTUP,err); 490 SYSerr(SYS_F_WSASTARTUP,err);
@@ -510,8 +528,8 @@ void BIO_sock_cleanup(void)
510 if (wsa_init_done) 528 if (wsa_init_done)
511 { 529 {
512 wsa_init_done=0; 530 wsa_init_done=0;
513#ifndef OPENSSL_SYS_WINCE 531#if 0 /* this call is claimed to be non-present in Winsock2 */
514 WSACancelBlockingCall(); /* Winsock 1.1 specific */ 532 WSACancelBlockingCall();
515#endif 533#endif
516 WSACleanup(); 534 WSACleanup();
517 } 535 }
@@ -581,12 +599,18 @@ static int get_ip(const char *str, unsigned char ip[4])
581int BIO_get_accept_socket(char *host, int bind_mode) 599int BIO_get_accept_socket(char *host, int bind_mode)
582 { 600 {
583 int ret=0; 601 int ret=0;
584 struct sockaddr_in server,client; 602 union {
585 int s=INVALID_SOCKET,cs; 603 struct sockaddr sa;
604 struct sockaddr_in sa_in;
605#if OPENSSL_USE_IPV6
606 struct sockaddr_in6 sa_in6;
607#endif
608 } server,client;
609 int s=INVALID_SOCKET,cs,addrlen;
586 unsigned char ip[4]; 610 unsigned char ip[4];
587 unsigned short port; 611 unsigned short port;
588 char *str=NULL,*e; 612 char *str=NULL,*e;
589 const char *h,*p; 613 char *h,*p;
590 unsigned long l; 614 unsigned long l;
591 int err_num; 615 int err_num;
592 616
@@ -600,8 +624,7 @@ int BIO_get_accept_socket(char *host, int bind_mode)
600 { 624 {
601 if (*e == ':') 625 if (*e == ':')
602 { 626 {
603 p= &(e[1]); 627 p=e;
604 *e='\0';
605 } 628 }
606 else if (*e == '/') 629 else if (*e == '/')
607 { 630 {
@@ -609,21 +632,70 @@ int BIO_get_accept_socket(char *host, int bind_mode)
609 break; 632 break;
610 } 633 }
611 } 634 }
612 635 if (p) *p++='\0'; /* points at last ':', '::port' is special [see below] */
613 if (p == NULL) 636 else p=h,h=NULL;
637
638#ifdef EAI_FAMILY
639 do {
640 static union { void *p;
641 int (WSAAPI *f)(const char *,const char *,
642 const struct addrinfo *,
643 struct addrinfo **);
644 } p_getaddrinfo = {NULL};
645 static union { void *p;
646 void (WSAAPI *f)(struct addrinfo *);
647 } p_freeaddrinfo = {NULL};
648 struct addrinfo *res,hint;
649
650 if (p_getaddrinfo.p==NULL)
651 {
652 if ((p_getaddrinfo.p=DSO_global_lookup("getaddrinfo"))==NULL ||
653 (p_freeaddrinfo.p=DSO_global_lookup("freeaddrinfo"))==NULL)
654 p_getaddrinfo.p=(void*)-1;
655 }
656 if (p_getaddrinfo.p==(void *)-1) break;
657
658 /* '::port' enforces IPv6 wildcard listener. Some OSes,
659 * e.g. Solaris, default to IPv6 without any hint. Also
660 * note that commonly IPv6 wildchard socket can service
661 * IPv4 connections just as well... */
662 memset(&hint,0,sizeof(hint));
663 if (h)
614 { 664 {
615 p=h; 665 if (strchr(h,':'))
616 h="*"; 666 {
667 if (h[1]=='\0') h=NULL;
668#if OPENSSL_USE_IPV6
669 hint.ai_family = AF_INET6;
670#else
671 h=NULL;
672#endif
673 }
674 else if (h[0]=='*' && h[1]=='\0')
675 h=NULL;
617 } 676 }
618 677
678 if ((*p_getaddrinfo.f)(h,p,&hint,&res)) break;
679
680 addrlen = res->ai_addrlen<=sizeof(server) ?
681 res->ai_addrlen :
682 sizeof(server);
683 memcpy(&server, res->ai_addr, addrlen);
684
685 (*p_freeaddrinfo.f)(res);
686 goto again;
687 } while (0);
688#endif
689
619 if (!BIO_get_port(p,&port)) goto err; 690 if (!BIO_get_port(p,&port)) goto err;
620 691
621 memset((char *)&server,0,sizeof(server)); 692 memset((char *)&server,0,sizeof(server));
622 server.sin_family=AF_INET; 693 server.sa_in.sin_family=AF_INET;
623 server.sin_port=htons(port); 694 server.sa_in.sin_port=htons(port);
695 addrlen = sizeof(server.sa_in);
624 696
625 if (strcmp(h,"*") == 0) 697 if (h == NULL || strcmp(h,"*") == 0)
626 server.sin_addr.s_addr=INADDR_ANY; 698 server.sa_in.sin_addr.s_addr=INADDR_ANY;
627 else 699 else
628 { 700 {
629 if (!BIO_get_host_ip(h,&(ip[0]))) goto err; 701 if (!BIO_get_host_ip(h,&(ip[0]))) goto err;
@@ -632,11 +704,11 @@ int BIO_get_accept_socket(char *host, int bind_mode)
632 ((unsigned long)ip[1]<<16L)| 704 ((unsigned long)ip[1]<<16L)|
633 ((unsigned long)ip[2]<< 8L)| 705 ((unsigned long)ip[2]<< 8L)|
634 ((unsigned long)ip[3]); 706 ((unsigned long)ip[3]);
635 server.sin_addr.s_addr=htonl(l); 707 server.sa_in.sin_addr.s_addr=htonl(l);
636 } 708 }
637 709
638again: 710again:
639 s=socket(AF_INET,SOCK_STREAM,SOCKET_PROTOCOL); 711 s=socket(server.sa.sa_family,SOCK_STREAM,SOCKET_PROTOCOL);
640 if (s == INVALID_SOCKET) 712 if (s == INVALID_SOCKET)
641 { 713 {
642 SYSerr(SYS_F_SOCKET,get_last_socket_error()); 714 SYSerr(SYS_F_SOCKET,get_last_socket_error());
@@ -654,22 +726,42 @@ again:
654 bind_mode=BIO_BIND_NORMAL; 726 bind_mode=BIO_BIND_NORMAL;
655 } 727 }
656#endif 728#endif
657 if (bind(s,(struct sockaddr *)&server,sizeof(server)) == -1) 729 if (bind(s,&server.sa,addrlen) == -1)
658 { 730 {
659#ifdef SO_REUSEADDR 731#ifdef SO_REUSEADDR
660 err_num=get_last_socket_error(); 732 err_num=get_last_socket_error();
661 if ((bind_mode == BIO_BIND_REUSEADDR_IF_UNUSED) && 733 if ((bind_mode == BIO_BIND_REUSEADDR_IF_UNUSED) &&
734#ifdef OPENSSL_SYS_WINDOWS
735 /* Some versions of Windows define EADDRINUSE to
736 * a dummy value.
737 */
738 (err_num == WSAEADDRINUSE))
739#else
662 (err_num == EADDRINUSE)) 740 (err_num == EADDRINUSE))
741#endif
663 { 742 {
664 memcpy((char *)&client,(char *)&server,sizeof(server)); 743 client = server;
665 if (strcmp(h,"*") == 0) 744 if (h == NULL || strcmp(h,"*") == 0)
666 client.sin_addr.s_addr=htonl(0x7F000001); 745 {
667 cs=socket(AF_INET,SOCK_STREAM,SOCKET_PROTOCOL); 746#if OPENSSL_USE_IPV6
747 if (client.sa.sa_family == AF_INET6)
748 {
749 memset(&client.sa_in6.sin6_addr,0,sizeof(client.sa_in6.sin6_addr));
750 client.sa_in6.sin6_addr.s6_addr[15]=1;
751 }
752 else
753#endif
754 if (client.sa.sa_family == AF_INET)
755 {
756 client.sa_in.sin_addr.s_addr=htonl(0x7F000001);
757 }
758 else goto err;
759 }
760 cs=socket(client.sa.sa_family,SOCK_STREAM,SOCKET_PROTOCOL);
668 if (cs != INVALID_SOCKET) 761 if (cs != INVALID_SOCKET)
669 { 762 {
670 int ii; 763 int ii;
671 ii=connect(cs,(struct sockaddr *)&client, 764 ii=connect(cs,&client.sa,addrlen);
672 sizeof(client));
673 closesocket(cs); 765 closesocket(cs);
674 if (ii == INVALID_SOCKET) 766 if (ii == INVALID_SOCKET)
675 { 767 {
@@ -708,20 +800,52 @@ err:
708int BIO_accept(int sock, char **addr) 800int BIO_accept(int sock, char **addr)
709 { 801 {
710 int ret=INVALID_SOCKET; 802 int ret=INVALID_SOCKET;
711 static struct sockaddr_in from;
712 unsigned long l; 803 unsigned long l;
713 unsigned short port; 804 unsigned short port;
714 int len;
715 char *p; 805 char *p;
716 806
717 memset((char *)&from,0,sizeof(from)); 807 struct {
718 len=sizeof(from); 808 /*
719 /* Note: under VMS with SOCKETSHR the fourth parameter is currently 809 * As for following union. Trouble is that there are platforms
720 * of type (int *) whereas under other systems it is (void *) if 810 * that have socklen_t and there are platforms that don't, on
721 * you don't have a cast it will choke the compiler: if you do 811 * some platforms socklen_t is int and on some size_t. So what
722 * have a cast then you can either go for (int *) or (void *). 812 * one can do? One can cook #ifdef spaghetti, which is nothing
813 * but masochistic. Or one can do union between int and size_t.
814 * One naturally does it primarily for 64-bit platforms where
815 * sizeof(int) != sizeof(size_t). But would it work? Note that
816 * if size_t member is initialized to 0, then later int member
817 * assignment naturally does the job on little-endian platforms
818 * regardless accept's expectations! What about big-endians?
819 * If accept expects int*, then it works, and if size_t*, then
820 * length value would appear as unreasonably large. But this
821 * won't prevent it from filling in the address structure. The
822 * trouble of course would be if accept returns more data than
823 * actual buffer can accomodate and overwrite stack... That's
824 * where early OPENSSL_assert comes into picture. Besides, the
825 * only 64-bit big-endian platform found so far that expects
826 * size_t* is HP-UX, where stack grows towards higher address.
827 * <appro>
723 */ 828 */
724 ret=accept(sock,(struct sockaddr *)&from,(void *)&len); 829 union { size_t s; int i; } len;
830 union {
831 struct sockaddr sa;
832 struct sockaddr_in sa_in;
833#if OPENSSL_USE_IPV6
834 struct sockaddr_in6 sa_in6;
835#endif
836 } from;
837 } sa;
838
839 sa.len.s=0;
840 sa.len.i=sizeof(sa.from);
841 memset(&sa.from,0,sizeof(sa.from));
842 ret=accept(sock,&sa.from.sa,(void *)&sa.len);
843 if (sizeof(sa.len.i)!=sizeof(sa.len.s) && sa.len.i==0)
844 {
845 OPENSSL_assert(sa.len.s<=sizeof(sa.from));
846 sa.len.i = (int)sa.len.s;
847 /* use sa.len.i from this point */
848 }
725 if (ret == INVALID_SOCKET) 849 if (ret == INVALID_SOCKET)
726 { 850 {
727 if(BIO_sock_should_retry(ret)) return -2; 851 if(BIO_sock_should_retry(ret)) return -2;
@@ -732,8 +856,46 @@ int BIO_accept(int sock, char **addr)
732 856
733 if (addr == NULL) goto end; 857 if (addr == NULL) goto end;
734 858
735 l=ntohl(from.sin_addr.s_addr); 859#ifdef EAI_FAMILY
736 port=ntohs(from.sin_port); 860 do {
861 char h[NI_MAXHOST],s[NI_MAXSERV];
862 size_t nl;
863 static union { void *p;
864 int (WSAAPI *f)(const struct sockaddr *,size_t/*socklen_t*/,
865 char *,size_t,char *,size_t,int);
866 } p_getnameinfo = {NULL};
867 /* 2nd argument to getnameinfo is specified to
868 * be socklen_t. Unfortunately there is a number
869 * of environments where socklen_t is not defined.
870 * As it's passed by value, it's safe to pass it
871 * as size_t... <appro> */
872
873 if (p_getnameinfo.p==NULL)
874 {
875 if ((p_getnameinfo.p=DSO_global_lookup("getnameinfo"))==NULL)
876 p_getnameinfo.p=(void*)-1;
877 }
878 if (p_getnameinfo.p==(void *)-1) break;
879
880 if ((*p_getnameinfo.f)(&sa.from.sa,sa.len.i,h,sizeof(h),s,sizeof(s),
881 NI_NUMERICHOST|NI_NUMERICSERV)) break;
882 nl = strlen(h)+strlen(s)+2;
883 p = *addr;
884 if (p) { *p = '\0'; p = OPENSSL_realloc(p,nl); }
885 else { p = OPENSSL_malloc(nl); }
886 if (p==NULL)
887 {
888 BIOerr(BIO_F_BIO_ACCEPT,ERR_R_MALLOC_FAILURE);
889 goto end;
890 }
891 *addr = p;
892 BIO_snprintf(*addr,nl,"%s:%s",h,s);
893 goto end;
894 } while(0);
895#endif
896 if (sa.from.sa.sa_family != AF_INET) goto end;
897 l=ntohl(sa.from.sa_in.sin_addr.s_addr);
898 port=ntohs(sa.from.sa_in.sin_port);
737 if (*addr == NULL) 899 if (*addr == NULL)
738 { 900 {
739 if ((p=OPENSSL_malloc(24)) == NULL) 901 if ((p=OPENSSL_malloc(24)) == NULL)
diff --git a/src/lib/libcrypto/bio/bio.h b/src/lib/libcrypto/bio/bio.h
index cecb6a7207..152802fbdf 100644
--- a/src/lib/libcrypto/bio/bio.h
+++ b/src/lib/libcrypto/bio/bio.h
@@ -95,6 +95,7 @@ extern "C" {
95#define BIO_TYPE_BIO (19|0x0400) /* (half a) BIO pair */ 95#define BIO_TYPE_BIO (19|0x0400) /* (half a) BIO pair */
96#define BIO_TYPE_LINEBUFFER (20|0x0200) /* filter */ 96#define BIO_TYPE_LINEBUFFER (20|0x0200) /* filter */
97#define BIO_TYPE_DGRAM (21|0x0400|0x0100) 97#define BIO_TYPE_DGRAM (21|0x0400|0x0100)
98#define BIO_TYPE_ASN1 (22|0x0200) /* filter */
98#define BIO_TYPE_COMP (23|0x0200) /* filter */ 99#define BIO_TYPE_COMP (23|0x0200) /* filter */
99 100
100#define BIO_TYPE_DESCRIPTOR 0x0100 /* socket, fd, connect or accept */ 101#define BIO_TYPE_DESCRIPTOR 0x0100 /* socket, fd, connect or accept */
@@ -156,8 +157,11 @@ extern "C" {
156 * previous write 157 * previous write
157 * operation */ 158 * operation */
158 159
160#define BIO_CTRL_DGRAM_GET_PEER 46
159#define BIO_CTRL_DGRAM_SET_PEER 44 /* Destination for the data */ 161#define BIO_CTRL_DGRAM_SET_PEER 44 /* Destination for the data */
160 162
163#define BIO_CTRL_DGRAM_SET_NEXT_TIMEOUT 45 /* Next DTLS handshake timeout to
164 * adjust socket timeouts */
161 165
162/* modifiers */ 166/* modifiers */
163#define BIO_FP_READ 0x02 167#define BIO_FP_READ 0x02
@@ -262,7 +266,6 @@ int BIO_method_type(const BIO *b);
262 266
263typedef void bio_info_cb(struct bio_st *, int, const char *, int, long, long); 267typedef void bio_info_cb(struct bio_st *, int, const char *, int, long, long);
264 268
265#ifndef OPENSSL_SYS_WIN16
266typedef struct bio_method_st 269typedef struct bio_method_st
267 { 270 {
268 int type; 271 int type;
@@ -276,21 +279,6 @@ typedef struct bio_method_st
276 int (*destroy)(BIO *); 279 int (*destroy)(BIO *);
277 long (*callback_ctrl)(BIO *, int, bio_info_cb *); 280 long (*callback_ctrl)(BIO *, int, bio_info_cb *);
278 } BIO_METHOD; 281 } BIO_METHOD;
279#else
280typedef struct bio_method_st
281 {
282 int type;
283 const char *name;
284 int (_far *bwrite)();
285 int (_far *bread)();
286 int (_far *bputs)();
287 int (_far *bgets)();
288 long (_far *ctrl)();
289 int (_far *create)();
290 int (_far *destroy)();
291 long (_far *callback_ctrl)();
292 } BIO_METHOD;
293#endif
294 282
295struct bio_st 283struct bio_st
296 { 284 {
@@ -331,6 +319,9 @@ typedef struct bio_f_buffer_ctx_struct
331 int obuf_off; /* write/read offset */ 319 int obuf_off; /* write/read offset */
332 } BIO_F_BUFFER_CTX; 320 } BIO_F_BUFFER_CTX;
333 321
322/* Prefix and suffix callback in ASN1 BIO */
323typedef int asn1_ps_func(BIO *b, unsigned char **pbuf, int *plen, void *parg);
324
334/* connect BIO stuff */ 325/* connect BIO stuff */
335#define BIO_CONN_S_BEFORE 1 326#define BIO_CONN_S_BEFORE 1
336#define BIO_CONN_S_GET_IP 2 327#define BIO_CONN_S_GET_IP 2
@@ -393,6 +384,13 @@ typedef struct bio_f_buffer_ctx_struct
393#define BIO_C_RESET_READ_REQUEST 147 384#define BIO_C_RESET_READ_REQUEST 147
394#define BIO_C_SET_MD_CTX 148 385#define BIO_C_SET_MD_CTX 148
395 386
387#define BIO_C_SET_PREFIX 149
388#define BIO_C_GET_PREFIX 150
389#define BIO_C_SET_SUFFIX 151
390#define BIO_C_GET_SUFFIX 152
391
392#define BIO_C_SET_EX_ARG 153
393#define BIO_C_GET_EX_ARG 154
396 394
397#define BIO_set_app_data(s,arg) BIO_set_ex_data(s,0,arg) 395#define BIO_set_app_data(s,arg) BIO_set_ex_data(s,0,arg)
398#define BIO_get_app_data(s) BIO_get_ex_data(s,0) 396#define BIO_get_app_data(s) BIO_get_ex_data(s,0)
@@ -405,7 +403,7 @@ typedef struct bio_f_buffer_ctx_struct
405#define BIO_get_conn_hostname(b) BIO_ptr_ctrl(b,BIO_C_GET_CONNECT,0) 403#define BIO_get_conn_hostname(b) BIO_ptr_ctrl(b,BIO_C_GET_CONNECT,0)
406#define BIO_get_conn_port(b) BIO_ptr_ctrl(b,BIO_C_GET_CONNECT,1) 404#define BIO_get_conn_port(b) BIO_ptr_ctrl(b,BIO_C_GET_CONNECT,1)
407#define BIO_get_conn_ip(b) BIO_ptr_ctrl(b,BIO_C_GET_CONNECT,2) 405#define BIO_get_conn_ip(b) BIO_ptr_ctrl(b,BIO_C_GET_CONNECT,2)
408#define BIO_get_conn_int_port(b) BIO_int_ctrl(b,BIO_C_GET_CONNECT,3) 406#define BIO_get_conn_int_port(b) BIO_int_ctrl(b,BIO_C_GET_CONNECT,3,0)
409 407
410 408
411#define BIO_set_nbio(b,n) BIO_ctrl(b,BIO_C_SET_NBIO,(n),NULL) 409#define BIO_set_nbio(b,n) BIO_ctrl(b,BIO_C_SET_NBIO,(n),NULL)
@@ -414,7 +412,7 @@ typedef struct bio_f_buffer_ctx_struct
414#define BIO_set_accept_port(b,name) BIO_ctrl(b,BIO_C_SET_ACCEPT,0,(char *)name) 412#define BIO_set_accept_port(b,name) BIO_ctrl(b,BIO_C_SET_ACCEPT,0,(char *)name)
415#define BIO_get_accept_port(b) BIO_ptr_ctrl(b,BIO_C_GET_ACCEPT,0) 413#define BIO_get_accept_port(b) BIO_ptr_ctrl(b,BIO_C_GET_ACCEPT,0)
416/* #define BIO_set_nbio(b,n) BIO_ctrl(b,BIO_C_SET_NBIO,(n),NULL) */ 414/* #define BIO_set_nbio(b,n) BIO_ctrl(b,BIO_C_SET_NBIO,(n),NULL) */
417#define BIO_set_nbio_accept(b,n) BIO_ctrl(b,BIO_C_SET_ACCEPT,1,(n)?"a":NULL) 415#define BIO_set_nbio_accept(b,n) BIO_ctrl(b,BIO_C_SET_ACCEPT,1,(n)?(void *)"a":NULL)
418#define BIO_set_accept_bios(b,bio) BIO_ctrl(b,BIO_C_SET_ACCEPT,2,(char *)bio) 416#define BIO_set_accept_bios(b,bio) BIO_ctrl(b,BIO_C_SET_ACCEPT,2,(char *)bio)
419 417
420#define BIO_BIND_NORMAL 0 418#define BIO_BIND_NORMAL 0
@@ -541,6 +539,8 @@ int BIO_ctrl_reset_read_request(BIO *b);
541 (int)BIO_ctrl(b, BIO_CTRL_DGRAM_GET_RECV_TIMER_EXP, 0, NULL) 539 (int)BIO_ctrl(b, BIO_CTRL_DGRAM_GET_RECV_TIMER_EXP, 0, NULL)
542#define BIO_dgram_send_timedout(b) \ 540#define BIO_dgram_send_timedout(b) \
543 (int)BIO_ctrl(b, BIO_CTRL_DGRAM_GET_SEND_TIMER_EXP, 0, NULL) 541 (int)BIO_ctrl(b, BIO_CTRL_DGRAM_GET_SEND_TIMER_EXP, 0, NULL)
542#define BIO_dgram_get_peer(b,peer) \
543 (int)BIO_ctrl(b, BIO_CTRL_DGRAM_GET_PEER, 0, (char *)peer)
544#define BIO_dgram_set_peer(b,peer) \ 544#define BIO_dgram_set_peer(b,peer) \
545 (int)BIO_ctrl(b, BIO_CTRL_DGRAM_SET_PEER, 0, (char *)peer) 545 (int)BIO_ctrl(b, BIO_CTRL_DGRAM_SET_PEER, 0, (char *)peer)
546 546
@@ -554,22 +554,21 @@ int BIO_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func,
554unsigned long BIO_number_read(BIO *bio); 554unsigned long BIO_number_read(BIO *bio);
555unsigned long BIO_number_written(BIO *bio); 555unsigned long BIO_number_written(BIO *bio);
556 556
557/* For BIO_f_asn1() */
558int BIO_asn1_set_prefix(BIO *b, asn1_ps_func *prefix,
559 asn1_ps_func *prefix_free);
560int BIO_asn1_get_prefix(BIO *b, asn1_ps_func **pprefix,
561 asn1_ps_func **pprefix_free);
562int BIO_asn1_set_suffix(BIO *b, asn1_ps_func *suffix,
563 asn1_ps_func *suffix_free);
564int BIO_asn1_get_suffix(BIO *b, asn1_ps_func **psuffix,
565 asn1_ps_func **psuffix_free);
566
557# ifndef OPENSSL_NO_FP_API 567# ifndef OPENSSL_NO_FP_API
558# if defined(OPENSSL_SYS_WIN16) && defined(_WINDLL)
559BIO_METHOD *BIO_s_file_internal(void);
560BIO *BIO_new_file_internal(char *filename, char *mode);
561BIO *BIO_new_fp_internal(FILE *stream, int close_flag);
562# define BIO_s_file BIO_s_file_internal
563# define BIO_new_file BIO_new_file_internal
564# define BIO_new_fp BIO_new_fp_internal
565# else /* FP_API */
566BIO_METHOD *BIO_s_file(void ); 568BIO_METHOD *BIO_s_file(void );
567BIO *BIO_new_file(const char *filename, const char *mode); 569BIO *BIO_new_file(const char *filename, const char *mode);
568BIO *BIO_new_fp(FILE *stream, int close_flag); 570BIO *BIO_new_fp(FILE *stream, int close_flag);
569# define BIO_s_file_internal BIO_s_file 571# define BIO_s_file_internal BIO_s_file
570# define BIO_new_file_internal BIO_new_file
571# define BIO_new_fp_internal BIO_s_file
572# endif /* FP_API */
573# endif 572# endif
574BIO * BIO_new(BIO_METHOD *type); 573BIO * BIO_new(BIO_METHOD *type);
575int BIO_set(BIO *a,BIO_METHOD *type); 574int BIO_set(BIO *a,BIO_METHOD *type);
@@ -598,13 +597,8 @@ int BIO_nread(BIO *bio, char **buf, int num);
598int BIO_nwrite0(BIO *bio, char **buf); 597int BIO_nwrite0(BIO *bio, char **buf);
599int BIO_nwrite(BIO *bio, char **buf, int num); 598int BIO_nwrite(BIO *bio, char **buf, int num);
600 599
601#ifndef OPENSSL_SYS_WIN16
602long BIO_debug_callback(BIO *bio,int cmd,const char *argp,int argi, 600long BIO_debug_callback(BIO *bio,int cmd,const char *argp,int argi,
603 long argl,long ret); 601 long argl,long ret);
604#else
605long _far _loadds BIO_debug_callback(BIO *bio,int cmd,const char *argp,int argi,
606 long argl,long ret);
607#endif
608 602
609BIO_METHOD *BIO_s_mem(void); 603BIO_METHOD *BIO_s_mem(void);
610BIO *BIO_new_mem_buf(void *buf, int len); 604BIO *BIO_new_mem_buf(void *buf, int len);
diff --git a/src/lib/libcrypto/bio/bio_cb.c b/src/lib/libcrypto/bio/bio_cb.c
index 6f4254a114..9bcbc321d9 100644
--- a/src/lib/libcrypto/bio/bio_cb.c
+++ b/src/lib/libcrypto/bio/bio_cb.c
@@ -85,28 +85,32 @@ long MS_CALLBACK BIO_debug_callback(BIO *bio, int cmd, const char *argp,
85 break; 85 break;
86 case BIO_CB_READ: 86 case BIO_CB_READ:
87 if (bio->method->type & BIO_TYPE_DESCRIPTOR) 87 if (bio->method->type & BIO_TYPE_DESCRIPTOR)
88 BIO_snprintf(p,p_maxlen,"read(%d,%d) - %s fd=%d\n", 88 BIO_snprintf(p,p_maxlen,"read(%d,%lu) - %s fd=%d\n",
89 bio->num,argi,bio->method->name,bio->num); 89 bio->num,(unsigned long)argi,
90 bio->method->name,bio->num);
90 else 91 else
91 BIO_snprintf(p,p_maxlen,"read(%d,%d) - %s\n", 92 BIO_snprintf(p,p_maxlen,"read(%d,%lu) - %s\n",
92 bio->num,argi,bio->method->name); 93 bio->num,(unsigned long)argi,
94 bio->method->name);
93 break; 95 break;
94 case BIO_CB_WRITE: 96 case BIO_CB_WRITE:
95 if (bio->method->type & BIO_TYPE_DESCRIPTOR) 97 if (bio->method->type & BIO_TYPE_DESCRIPTOR)
96 BIO_snprintf(p,p_maxlen,"write(%d,%d) - %s fd=%d\n", 98 BIO_snprintf(p,p_maxlen,"write(%d,%lu) - %s fd=%d\n",
97 bio->num,argi,bio->method->name,bio->num); 99 bio->num,(unsigned long)argi,
100 bio->method->name,bio->num);
98 else 101 else
99 BIO_snprintf(p,p_maxlen,"write(%d,%d) - %s\n", 102 BIO_snprintf(p,p_maxlen,"write(%d,%lu) - %s\n",
100 bio->num,argi,bio->method->name); 103 bio->num,(unsigned long)argi,
104 bio->method->name);
101 break; 105 break;
102 case BIO_CB_PUTS: 106 case BIO_CB_PUTS:
103 BIO_snprintf(p,p_maxlen,"puts() - %s\n",bio->method->name); 107 BIO_snprintf(p,p_maxlen,"puts() - %s\n",bio->method->name);
104 break; 108 break;
105 case BIO_CB_GETS: 109 case BIO_CB_GETS:
106 BIO_snprintf(p,p_maxlen,"gets(%d) - %s\n",argi,bio->method->name); 110 BIO_snprintf(p,p_maxlen,"gets(%lu) - %s\n",(unsigned long)argi,bio->method->name);
107 break; 111 break;
108 case BIO_CB_CTRL: 112 case BIO_CB_CTRL:
109 BIO_snprintf(p,p_maxlen,"ctrl(%d) - %s\n",argi,bio->method->name); 113 BIO_snprintf(p,p_maxlen,"ctrl(%lu) - %s\n",(unsigned long)argi,bio->method->name);
110 break; 114 break;
111 case BIO_CB_RETURN|BIO_CB_READ: 115 case BIO_CB_RETURN|BIO_CB_READ:
112 BIO_snprintf(p,p_maxlen,"read return %ld\n",ret); 116 BIO_snprintf(p,p_maxlen,"read return %ld\n",ret);
diff --git a/src/lib/libcrypto/bio/bio_err.c b/src/lib/libcrypto/bio/bio_err.c
index 6603f1c74d..a224edd5a0 100644
--- a/src/lib/libcrypto/bio/bio_err.c
+++ b/src/lib/libcrypto/bio/bio_err.c
@@ -1,6 +1,6 @@
1/* crypto/bio/bio_err.c */ 1/* crypto/bio/bio_err.c */
2/* ==================================================================== 2/* ====================================================================
3 * Copyright (c) 1999-2005 The OpenSSL Project. All rights reserved. 3 * Copyright (c) 1999-2006 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
diff --git a/src/lib/libcrypto/bio/bio_lib.c b/src/lib/libcrypto/bio/bio_lib.c
index 3f52ae953c..77f4de9c32 100644
--- a/src/lib/libcrypto/bio/bio_lib.c
+++ b/src/lib/libcrypto/bio/bio_lib.c
@@ -429,7 +429,7 @@ BIO *BIO_push(BIO *b, BIO *bio)
429 if (bio != NULL) 429 if (bio != NULL)
430 bio->prev_bio=lb; 430 bio->prev_bio=lb;
431 /* called to do internal processing */ 431 /* called to do internal processing */
432 BIO_ctrl(b,BIO_CTRL_PUSH,0,NULL); 432 BIO_ctrl(b,BIO_CTRL_PUSH,0,lb);
433 return(b); 433 return(b);
434 } 434 }
435 435
@@ -441,7 +441,7 @@ BIO *BIO_pop(BIO *b)
441 if (b == NULL) return(NULL); 441 if (b == NULL) return(NULL);
442 ret=b->next_bio; 442 ret=b->next_bio;
443 443
444 BIO_ctrl(b,BIO_CTRL_POP,0,NULL); 444 BIO_ctrl(b,BIO_CTRL_POP,0,b);
445 445
446 if (b->prev_bio != NULL) 446 if (b->prev_bio != NULL)
447 b->prev_bio->next_bio=b->next_bio; 447 b->prev_bio->next_bio=b->next_bio;
diff --git a/src/lib/libcrypto/bio/bss_acpt.c b/src/lib/libcrypto/bio/bss_acpt.c
index d090b7272f..826f761143 100644
--- a/src/lib/libcrypto/bio/bss_acpt.c
+++ b/src/lib/libcrypto/bio/bss_acpt.c
@@ -100,8 +100,8 @@ static int acpt_new(BIO *h);
100static int acpt_free(BIO *data); 100static int acpt_free(BIO *data);
101static int acpt_state(BIO *b, BIO_ACCEPT *c); 101static int acpt_state(BIO *b, BIO_ACCEPT *c);
102static void acpt_close_socket(BIO *data); 102static void acpt_close_socket(BIO *data);
103BIO_ACCEPT *BIO_ACCEPT_new(void ); 103static BIO_ACCEPT *BIO_ACCEPT_new(void );
104void BIO_ACCEPT_free(BIO_ACCEPT *a); 104static void BIO_ACCEPT_free(BIO_ACCEPT *a);
105 105
106#define ACPT_S_BEFORE 1 106#define ACPT_S_BEFORE 1
107#define ACPT_S_GET_ACCEPT_SOCKET 2 107#define ACPT_S_GET_ACCEPT_SOCKET 2
@@ -141,7 +141,7 @@ static int acpt_new(BIO *bi)
141 return(1); 141 return(1);
142 } 142 }
143 143
144BIO_ACCEPT *BIO_ACCEPT_new(void) 144static BIO_ACCEPT *BIO_ACCEPT_new(void)
145 { 145 {
146 BIO_ACCEPT *ret; 146 BIO_ACCEPT *ret;
147 147
@@ -154,7 +154,7 @@ BIO_ACCEPT *BIO_ACCEPT_new(void)
154 return(ret); 154 return(ret);
155 } 155 }
156 156
157void BIO_ACCEPT_free(BIO_ACCEPT *a) 157static void BIO_ACCEPT_free(BIO_ACCEPT *a)
158 { 158 {
159 if(a == NULL) 159 if(a == NULL)
160 return; 160 return;
diff --git a/src/lib/libcrypto/bio/bss_dgram.c b/src/lib/libcrypto/bio/bss_dgram.c
index c3da6dc82f..eb7e365467 100644
--- a/src/lib/libcrypto/bio/bss_dgram.c
+++ b/src/lib/libcrypto/bio/bss_dgram.c
@@ -66,7 +66,13 @@
66 66
67#include <openssl/bio.h> 67#include <openssl/bio.h>
68 68
69#if defined(OPENSSL_SYS_WIN32) || defined(OPENSSL_SYS_VMS)
70#include <sys/timeb.h>
71#endif
72
73#ifdef OPENSSL_SYS_LINUX
69#define IP_MTU 14 /* linux is lame */ 74#define IP_MTU 14 /* linux is lame */
75#endif
70 76
71#ifdef WATT32 77#ifdef WATT32
72#define sock_write SockWrite /* Watt-32 uses same names */ 78#define sock_write SockWrite /* Watt-32 uses same names */
@@ -84,6 +90,8 @@ static int dgram_clear(BIO *bio);
84 90
85static int BIO_dgram_should_retry(int s); 91static int BIO_dgram_should_retry(int s);
86 92
93static void get_current_time(struct timeval *t);
94
87static BIO_METHOD methods_dgramp= 95static BIO_METHOD methods_dgramp=
88 { 96 {
89 BIO_TYPE_DGRAM, 97 BIO_TYPE_DGRAM,
@@ -100,10 +108,18 @@ static BIO_METHOD methods_dgramp=
100 108
101typedef struct bio_dgram_data_st 109typedef struct bio_dgram_data_st
102 { 110 {
103 struct sockaddr peer; 111 union {
112 struct sockaddr sa;
113 struct sockaddr_in sa_in;
114#if OPENSSL_USE_IPV6
115 struct sockaddr_in6 sa_in6;
116#endif
117 } peer;
104 unsigned int connected; 118 unsigned int connected;
105 unsigned int _errno; 119 unsigned int _errno;
106 unsigned int mtu; 120 unsigned int mtu;
121 struct timeval next_timeout;
122 struct timeval socket_timeout;
107 } bio_dgram_data; 123 } bio_dgram_data;
108 124
109BIO_METHOD *BIO_s_datagram(void) 125BIO_METHOD *BIO_s_datagram(void)
@@ -165,31 +181,140 @@ static int dgram_clear(BIO *a)
165 } 181 }
166 return(1); 182 return(1);
167 } 183 }
168 184
185static void dgram_adjust_rcv_timeout(BIO *b)
186 {
187#if defined(SO_RCVTIMEO)
188 bio_dgram_data *data = (bio_dgram_data *)b->ptr;
189 int sz = sizeof(int);
190
191 /* Is a timer active? */
192 if (data->next_timeout.tv_sec > 0 || data->next_timeout.tv_usec > 0)
193 {
194 struct timeval timenow, timeleft;
195
196 /* Read current socket timeout */
197#ifdef OPENSSL_SYS_WINDOWS
198 int timeout;
199 if (getsockopt(b->num, SOL_SOCKET, SO_RCVTIMEO,
200 (void*)&timeout, &sz) < 0)
201 { perror("getsockopt"); }
202 else
203 {
204 data->socket_timeout.tv_sec = timeout / 1000;
205 data->socket_timeout.tv_usec = (timeout % 1000) * 1000;
206 }
207#else
208 if ( getsockopt(b->num, SOL_SOCKET, SO_RCVTIMEO,
209 &(data->socket_timeout), (void *)&sz) < 0)
210 { perror("getsockopt"); }
211#endif
212
213 /* Get current time */
214 get_current_time(&timenow);
215
216 /* Calculate time left until timer expires */
217 memcpy(&timeleft, &(data->next_timeout), sizeof(struct timeval));
218 timeleft.tv_sec -= timenow.tv_sec;
219 timeleft.tv_usec -= timenow.tv_usec;
220 if (timeleft.tv_usec < 0)
221 {
222 timeleft.tv_sec--;
223 timeleft.tv_usec += 1000000;
224 }
225
226 if (timeleft.tv_sec < 0)
227 {
228 timeleft.tv_sec = 0;
229 timeleft.tv_usec = 1;
230 }
231
232 /* Adjust socket timeout if next handhake message timer
233 * will expire earlier.
234 */
235 if ((data->socket_timeout.tv_sec == 0 && data->socket_timeout.tv_usec == 0) ||
236 (data->socket_timeout.tv_sec > timeleft.tv_sec) ||
237 (data->socket_timeout.tv_sec == timeleft.tv_sec &&
238 data->socket_timeout.tv_usec >= timeleft.tv_usec))
239 {
240#ifdef OPENSSL_SYS_WINDOWS
241 timeout = timeleft.tv_sec * 1000 + timeleft.tv_usec / 1000;
242 if (setsockopt(b->num, SOL_SOCKET, SO_RCVTIMEO,
243 (void*)&timeout, sizeof(timeout)) < 0)
244 { perror("setsockopt"); }
245#else
246 if ( setsockopt(b->num, SOL_SOCKET, SO_RCVTIMEO, &timeleft,
247 sizeof(struct timeval)) < 0)
248 { perror("setsockopt"); }
249#endif
250 }
251 }
252#endif
253 }
254
255static void dgram_reset_rcv_timeout(BIO *b)
256 {
257#if defined(SO_RCVTIMEO)
258 bio_dgram_data *data = (bio_dgram_data *)b->ptr;
259
260 /* Is a timer active? */
261 if (data->next_timeout.tv_sec > 0 || data->next_timeout.tv_usec > 0)
262 {
263#ifdef OPENSSL_SYS_WINDOWS
264 int timeout = data->socket_timeout.tv_sec * 1000 +
265 data->socket_timeout.tv_usec / 1000;
266 if (setsockopt(b->num, SOL_SOCKET, SO_RCVTIMEO,
267 (void*)&timeout, sizeof(timeout)) < 0)
268 { perror("setsockopt"); }
269#else
270 if ( setsockopt(b->num, SOL_SOCKET, SO_RCVTIMEO, &(data->socket_timeout),
271 sizeof(struct timeval)) < 0)
272 { perror("setsockopt"); }
273#endif
274 }
275#endif
276 }
277
169static int dgram_read(BIO *b, char *out, int outl) 278static int dgram_read(BIO *b, char *out, int outl)
170 { 279 {
171 int ret=0; 280 int ret=0;
172 bio_dgram_data *data = (bio_dgram_data *)b->ptr; 281 bio_dgram_data *data = (bio_dgram_data *)b->ptr;
173 282
174 struct sockaddr peer; 283 struct {
175 int peerlen = sizeof(peer); 284 /*
285 * See commentary in b_sock.c. <appro>
286 */
287 union { size_t s; int i; } len;
288 union {
289 struct sockaddr sa;
290 struct sockaddr_in sa_in;
291#if OPENSSL_USE_IPV6
292 struct sockaddr_in6 sa_in6;
293#endif
294 } peer;
295 } sa;
296
297 sa.len.s=0;
298 sa.len.i=sizeof(sa.peer);
176 299
177 if (out != NULL) 300 if (out != NULL)
178 { 301 {
179 clear_socket_error(); 302 clear_socket_error();
180 memset(&peer, 0x00, peerlen); 303 memset(&sa.peer, 0x00, sizeof(sa.peer));
181 /* Last arg in recvfrom is signed on some platforms and 304 dgram_adjust_rcv_timeout(b);
182 * unsigned on others. It is of type socklen_t on some 305 ret=recvfrom(b->num,out,outl,0,&sa.peer.sa,(void *)&sa.len);
183 * but this is not universal. Cast to (void *) to avoid 306 if (sizeof(sa.len.i)!=sizeof(sa.len.s) && sa.len.i==0)
184 * compiler warnings. 307 {
185 */ 308 OPENSSL_assert(sa.len.s<=sizeof(sa.peer));
186 ret=recvfrom(b->num,out,outl,0,&peer,(void *)&peerlen); 309 sa.len.i = (int)sa.len.s;
310 }
311 dgram_reset_rcv_timeout(b);
187 312
188 if ( ! data->connected && ret > 0) 313 if ( ! data->connected && ret >= 0)
189 BIO_ctrl(b, BIO_CTRL_DGRAM_CONNECT, 0, &peer); 314 BIO_ctrl(b, BIO_CTRL_DGRAM_SET_PEER, 0, &sa.peer);
190 315
191 BIO_clear_retry_flags(b); 316 BIO_clear_retry_flags(b);
192 if (ret <= 0) 317 if (ret < 0)
193 { 318 {
194 if (BIO_dgram_should_retry(ret)) 319 if (BIO_dgram_should_retry(ret))
195 { 320 {
@@ -207,19 +332,29 @@ static int dgram_write(BIO *b, const char *in, int inl)
207 bio_dgram_data *data = (bio_dgram_data *)b->ptr; 332 bio_dgram_data *data = (bio_dgram_data *)b->ptr;
208 clear_socket_error(); 333 clear_socket_error();
209 334
210 if ( data->connected ) 335 if ( data->connected )
211 ret=writesocket(b->num,in,inl); 336 ret=writesocket(b->num,in,inl);
212 else 337 else
338 {
339 int peerlen = sizeof(data->peer);
340
341 if (data->peer.sa.sa_family == AF_INET)
342 peerlen = sizeof(data->peer.sa_in);
343#if OPENSSL_USE_IVP6
344 else if (data->peer.sa.sa_family == AF_INET6)
345 peerlen = sizeof(data->peer.sa_in6);
346#endif
213#if defined(NETWARE_CLIB) && defined(NETWARE_BSDSOCK) 347#if defined(NETWARE_CLIB) && defined(NETWARE_BSDSOCK)
214 ret=sendto(b->num, (char *)in, inl, 0, &data->peer, sizeof(data->peer)); 348 ret=sendto(b->num, (char *)in, inl, 0, &data->peer.sa, peerlen);
215#else 349#else
216 ret=sendto(b->num, in, inl, 0, &data->peer, sizeof(data->peer)); 350 ret=sendto(b->num, in, inl, 0, &data->peer.sa, peerlen);
217#endif 351#endif
352 }
218 353
219 BIO_clear_retry_flags(b); 354 BIO_clear_retry_flags(b);
220 if (ret <= 0) 355 if (ret <= 0)
221 { 356 {
222 if (BIO_sock_should_retry(ret)) 357 if (BIO_dgram_should_retry(ret))
223 { 358 {
224 BIO_set_retry_write(b); 359 BIO_set_retry_write(b);
225 data->_errno = get_last_socket_error(); 360 data->_errno = get_last_socket_error();
@@ -240,8 +375,20 @@ static long dgram_ctrl(BIO *b, int cmd, long num, void *ptr)
240 int *ip; 375 int *ip;
241 struct sockaddr *to = NULL; 376 struct sockaddr *to = NULL;
242 bio_dgram_data *data = NULL; 377 bio_dgram_data *data = NULL;
378#if defined(IP_MTU_DISCOVER) || defined(IP_MTU)
243 long sockopt_val = 0; 379 long sockopt_val = 0;
244 unsigned int sockopt_len = 0; 380 unsigned int sockopt_len = 0;
381#endif
382#ifdef OPENSSL_SYS_LINUX
383 socklen_t addr_len;
384 union {
385 struct sockaddr sa;
386 struct sockaddr_in s4;
387#if OPENSSL_USE_IPV6
388 struct sockaddr_in6 s6;
389#endif
390 } addr;
391#endif
245 392
246 data = (bio_dgram_data *)b->ptr; 393 data = (bio_dgram_data *)b->ptr;
247 394
@@ -294,30 +441,110 @@ static long dgram_ctrl(BIO *b, int cmd, long num, void *ptr)
294 else 441 else
295 { 442 {
296#endif 443#endif
297 memcpy(&(data->peer),to, sizeof(struct sockaddr)); 444 switch (to->sa_family)
445 {
446 case AF_INET:
447 memcpy(&data->peer,to,sizeof(data->peer.sa_in));
448 break;
449#if OPENSSL_USE_IPV6
450 case AF_INET6:
451 memcpy(&data->peer,to,sizeof(data->peer.sa_in6));
452 break;
453#endif
454 default:
455 memcpy(&data->peer,to,sizeof(data->peer.sa));
456 break;
457 }
298#if 0 458#if 0
299 } 459 }
300#endif 460#endif
301 break; 461 break;
302 /* (Linux)kernel sets DF bit on outgoing IP packets */ 462 /* (Linux)kernel sets DF bit on outgoing IP packets */
303#ifdef IP_MTU_DISCOVER
304 case BIO_CTRL_DGRAM_MTU_DISCOVER: 463 case BIO_CTRL_DGRAM_MTU_DISCOVER:
305 sockopt_val = IP_PMTUDISC_DO; 464#ifdef OPENSSL_SYS_LINUX
306 if ((ret = setsockopt(b->num, IPPROTO_IP, IP_MTU_DISCOVER, 465 addr_len = (socklen_t)sizeof(addr);
307 &sockopt_val, sizeof(sockopt_val))) < 0) 466 memset((void *)&addr, 0, sizeof(addr));
308 perror("setsockopt"); 467 if (getsockname(b->num, &addr.sa, &addr_len) < 0)
468 {
469 ret = 0;
470 break;
471 }
472 sockopt_len = sizeof(sockopt_val);
473 switch (addr.sa.sa_family)
474 {
475 case AF_INET:
476 sockopt_val = IP_PMTUDISC_DO;
477 if ((ret = setsockopt(b->num, IPPROTO_IP, IP_MTU_DISCOVER,
478 &sockopt_val, sizeof(sockopt_val))) < 0)
479 perror("setsockopt");
480 break;
481#if OPENSSL_USE_IPV6 && defined(IPV6_MTU_DISCOVER)
482 case AF_INET6:
483 sockopt_val = IPV6_PMTUDISC_DO;
484 if ((ret = setsockopt(b->num, IPPROTO_IPV6, IPV6_MTU_DISCOVER,
485 &sockopt_val, sizeof(sockopt_val))) < 0)
486 perror("setsockopt");
487 break;
488#endif
489 default:
490 ret = -1;
491 break;
492 }
493 ret = -1;
494#else
309 break; 495 break;
310#endif 496#endif
311 case BIO_CTRL_DGRAM_QUERY_MTU: 497 case BIO_CTRL_DGRAM_QUERY_MTU:
312 sockopt_len = sizeof(sockopt_val); 498#ifdef OPENSSL_SYS_LINUX
313 if ((ret = getsockopt(b->num, IPPROTO_IP, IP_MTU, (void *)&sockopt_val, 499 addr_len = (socklen_t)sizeof(addr);
314 &sockopt_len)) < 0 || sockopt_val < 0) 500 memset((void *)&addr, 0, sizeof(addr));
315 { ret = 0; } 501 if (getsockname(b->num, &addr.sa, &addr_len) < 0)
316 else 502 {
503 ret = 0;
504 break;
505 }
506 sockopt_len = sizeof(sockopt_val);
507 switch (addr.sa.sa_family)
317 { 508 {
318 data->mtu = sockopt_val; 509 case AF_INET:
319 ret = data->mtu; 510 if ((ret = getsockopt(b->num, IPPROTO_IP, IP_MTU, (void *)&sockopt_val,
511 &sockopt_len)) < 0 || sockopt_val < 0)
512 {
513 ret = 0;
514 }
515 else
516 {
517 /* we assume that the transport protocol is UDP and no
518 * IP options are used.
519 */
520 data->mtu = sockopt_val - 8 - 20;
521 ret = data->mtu;
522 }
523 break;
524#if OPENSSL_USE_IPV6 && defined(IPV6_MTU)
525 case AF_INET6:
526 if ((ret = getsockopt(b->num, IPPROTO_IPV6, IPV6_MTU, (void *)&sockopt_val,
527 &sockopt_len)) < 0 || sockopt_val < 0)
528 {
529 ret = 0;
530 }
531 else
532 {
533 /* we assume that the transport protocol is UDP and no
534 * IPV6 options are used.
535 */
536 data->mtu = sockopt_val - 8 - 40;
537 ret = data->mtu;
538 }
539 break;
540#endif
541 default:
542 ret = 0;
543 break;
320 } 544 }
545#else
546 ret = 0;
547#endif
321 break; 548 break;
322 case BIO_CTRL_DGRAM_GET_MTU: 549 case BIO_CTRL_DGRAM_GET_MTU:
323 return data->mtu; 550 return data->mtu;
@@ -332,19 +559,66 @@ static long dgram_ctrl(BIO *b, int cmd, long num, void *ptr)
332 if ( to != NULL) 559 if ( to != NULL)
333 { 560 {
334 data->connected = 1; 561 data->connected = 1;
335 memcpy(&(data->peer),to, sizeof(struct sockaddr)); 562 switch (to->sa_family)
563 {
564 case AF_INET:
565 memcpy(&data->peer,to,sizeof(data->peer.sa_in));
566 break;
567#if OPENSSL_USE_IPV6
568 case AF_INET6:
569 memcpy(&data->peer,to,sizeof(data->peer.sa_in6));
570 break;
571#endif
572 default:
573 memcpy(&data->peer,to,sizeof(data->peer.sa));
574 break;
575 }
336 } 576 }
337 else 577 else
338 { 578 {
339 data->connected = 0; 579 data->connected = 0;
340 memset(&(data->peer), 0x00, sizeof(struct sockaddr)); 580 memset(&(data->peer), 0x00, sizeof(data->peer));
341 } 581 }
342 break; 582 break;
343 case BIO_CTRL_DGRAM_SET_PEER: 583 case BIO_CTRL_DGRAM_GET_PEER:
344 to = (struct sockaddr *) ptr; 584 switch (data->peer.sa.sa_family)
345 585 {
346 memcpy(&(data->peer), to, sizeof(struct sockaddr)); 586 case AF_INET:
347 break; 587 ret=sizeof(data->peer.sa_in);
588 break;
589#if OPENSSL_USE_IPV6
590 case AF_INET6:
591 ret=sizeof(data->peer.sa_in6);
592 break;
593#endif
594 default:
595 ret=sizeof(data->peer.sa);
596 break;
597 }
598 if (num==0 || num>ret)
599 num=ret;
600 memcpy(ptr,&data->peer,(ret=num));
601 break;
602 case BIO_CTRL_DGRAM_SET_PEER:
603 to = (struct sockaddr *) ptr;
604 switch (to->sa_family)
605 {
606 case AF_INET:
607 memcpy(&data->peer,to,sizeof(data->peer.sa_in));
608 break;
609#if OPENSSL_USE_IPV6
610 case AF_INET6:
611 memcpy(&data->peer,to,sizeof(data->peer.sa_in6));
612 break;
613#endif
614 default:
615 memcpy(&data->peer,to,sizeof(data->peer.sa));
616 break;
617 }
618 break;
619 case BIO_CTRL_DGRAM_SET_NEXT_TIMEOUT:
620 memcpy(&(data->next_timeout), ptr, sizeof(struct timeval));
621 break;
348#if defined(SO_RCVTIMEO) 622#if defined(SO_RCVTIMEO)
349 case BIO_CTRL_DGRAM_SET_RECV_TIMEOUT: 623 case BIO_CTRL_DGRAM_SET_RECV_TIMEOUT:
350#ifdef OPENSSL_SYS_WINDOWS 624#ifdef OPENSSL_SYS_WINDOWS
@@ -507,10 +781,6 @@ int BIO_dgram_non_fatal_error(int err)
507# endif 781# endif
508#endif 782#endif
509 783
510#if defined(ENOTCONN)
511 case ENOTCONN:
512#endif
513
514#ifdef EINTR 784#ifdef EINTR
515 case EINTR: 785 case EINTR:
516#endif 786#endif
@@ -533,11 +803,6 @@ int BIO_dgram_non_fatal_error(int err)
533 case EALREADY: 803 case EALREADY:
534#endif 804#endif
535 805
536/* DF bit set, and packet larger than MTU */
537#ifdef EMSGSIZE
538 case EMSGSIZE:
539#endif
540
541 return(1); 806 return(1);
542 /* break; */ 807 /* break; */
543 default: 808 default:
@@ -546,3 +811,20 @@ int BIO_dgram_non_fatal_error(int err)
546 return(0); 811 return(0);
547 } 812 }
548#endif 813#endif
814
815static void get_current_time(struct timeval *t)
816 {
817#ifdef OPENSSL_SYS_WIN32
818 struct _timeb tb;
819 _ftime(&tb);
820 t->tv_sec = (long)tb.time;
821 t->tv_usec = (long)tb.millitm * 1000;
822#elif defined(OPENSSL_SYS_VMS)
823 struct timeb tb;
824 ftime(&tb);
825 t->tv_sec = (long)tb.time;
826 t->tv_usec = (long)tb.millitm * 1000;
827#else
828 gettimeofday(t, NULL);
829#endif
830 }
diff --git a/src/lib/libcrypto/bio/bss_fd.c b/src/lib/libcrypto/bio/bss_fd.c
index 4c229bf641..d1bf85aae1 100644
--- a/src/lib/libcrypto/bio/bss_fd.c
+++ b/src/lib/libcrypto/bio/bss_fd.c
@@ -60,6 +60,13 @@
60#include <errno.h> 60#include <errno.h>
61#define USE_SOCKETS 61#define USE_SOCKETS
62#include "cryptlib.h" 62#include "cryptlib.h"
63
64#if defined(OPENSSL_NO_POSIX_IO)
65/*
66 * One can argue that one should implement dummy placeholder for
67 * BIO_s_fd here...
68 */
69#else
63/* 70/*
64 * As for unconditional usage of "UPLINK" interface in this module. 71 * As for unconditional usage of "UPLINK" interface in this module.
65 * Trouble is that unlike Unix file descriptors [which are indexes 72 * Trouble is that unlike Unix file descriptors [which are indexes
@@ -77,6 +84,7 @@
77static int fd_write(BIO *h, const char *buf, int num); 84static int fd_write(BIO *h, const char *buf, int num);
78static int fd_read(BIO *h, char *buf, int size); 85static int fd_read(BIO *h, char *buf, int size);
79static int fd_puts(BIO *h, const char *str); 86static int fd_puts(BIO *h, const char *str);
87static int fd_gets(BIO *h, char *buf, int size);
80static long fd_ctrl(BIO *h, int cmd, long arg1, void *arg2); 88static long fd_ctrl(BIO *h, int cmd, long arg1, void *arg2);
81static int fd_new(BIO *h); 89static int fd_new(BIO *h);
82static int fd_free(BIO *data); 90static int fd_free(BIO *data);
@@ -88,7 +96,7 @@ static BIO_METHOD methods_fdp=
88 fd_write, 96 fd_write,
89 fd_read, 97 fd_read,
90 fd_puts, 98 fd_puts,
91 NULL, /* fd_gets, */ 99 fd_gets,
92 fd_ctrl, 100 fd_ctrl,
93 fd_new, 101 fd_new,
94 fd_free, 102 fd_free,
@@ -227,6 +235,22 @@ static int fd_puts(BIO *bp, const char *str)
227 return(ret); 235 return(ret);
228 } 236 }
229 237
238static int fd_gets(BIO *bp, char *buf, int size)
239 {
240 int ret=0;
241 char *ptr=buf;
242 char *end=buf+size-1;
243
244 while ( (ptr < end) && (fd_read(bp, ptr, 1) > 0) && (ptr[0] != '\n') )
245 ptr++;
246
247 ptr[0]='\0';
248
249 if (buf[0] != '\0')
250 ret=strlen(buf);
251 return(ret);
252 }
253
230int BIO_fd_should_retry(int i) 254int BIO_fd_should_retry(int i)
231 { 255 {
232 int err; 256 int err;
@@ -292,3 +316,4 @@ int BIO_fd_non_fatal_error(int err)
292 } 316 }
293 return(0); 317 return(0);
294 } 318 }
319#endif
diff --git a/src/lib/libcrypto/bio/bss_file.c b/src/lib/libcrypto/bio/bss_file.c
index e692a08e58..8bfa0bcd97 100644
--- a/src/lib/libcrypto/bio/bss_file.c
+++ b/src/lib/libcrypto/bio/bss_file.c
@@ -118,10 +118,47 @@ static BIO_METHOD methods_filep=
118 118
119BIO *BIO_new_file(const char *filename, const char *mode) 119BIO *BIO_new_file(const char *filename, const char *mode)
120 { 120 {
121 BIO *ret; 121 BIO *ret;
122 FILE *file; 122 FILE *file=NULL;
123
124#if defined(_WIN32) && defined(CP_UTF8)
125 int sz, len_0 = (int)strlen(filename)+1;
123 126
124 if ((file=fopen(filename,mode)) == NULL) 127 /*
128 * Basically there are three cases to cover: a) filename is
129 * pure ASCII string; b) actual UTF-8 encoded string and
130 * c) locale-ized string, i.e. one containing 8-bit
131 * characters that are meaningful in current system locale.
132 * If filename is pure ASCII or real UTF-8 encoded string,
133 * MultiByteToWideChar succeeds and _wfopen works. If
134 * filename is locale-ized string, chances are that
135 * MultiByteToWideChar fails reporting
136 * ERROR_NO_UNICODE_TRANSLATION, in which case we fall
137 * back to fopen...
138 */
139 if ((sz=MultiByteToWideChar(CP_UTF8,MB_ERR_INVALID_CHARS,
140 filename,len_0,NULL,0))>0)
141 {
142 WCHAR wmode[8];
143 WCHAR *wfilename = _alloca(sz*sizeof(WCHAR));
144
145 if (MultiByteToWideChar(CP_UTF8,MB_ERR_INVALID_CHARS,
146 filename,len_0,wfilename,sz) &&
147 MultiByteToWideChar(CP_UTF8,0,mode,strlen(mode)+1,
148 wmode,sizeof(wmode)/sizeof(wmode[0])) &&
149 (file=_wfopen(wfilename,wmode))==NULL && errno==ENOENT
150 ) /* UTF-8 decode succeeded, but no file, filename
151 * could still have been locale-ized... */
152 file = fopen(filename,mode);
153 }
154 else if (GetLastError()==ERROR_NO_UNICODE_TRANSLATION)
155 {
156 file = fopen(filename,mode);
157 }
158#else
159 file=fopen(filename,mode);
160#endif
161 if (file == NULL)
125 { 162 {
126 SYSerr(SYS_F_FOPEN,get_last_sys_error()); 163 SYSerr(SYS_F_FOPEN,get_last_sys_error());
127 ERR_add_error_data(5,"fopen('",filename,"','",mode,"')"); 164 ERR_add_error_data(5,"fopen('",filename,"','",mode,"')");
@@ -131,7 +168,7 @@ BIO *BIO_new_file(const char *filename, const char *mode)
131 BIOerr(BIO_F_BIO_NEW_FILE,ERR_R_SYS_LIB); 168 BIOerr(BIO_F_BIO_NEW_FILE,ERR_R_SYS_LIB);
132 return(NULL); 169 return(NULL);
133 } 170 }
134 if ((ret=BIO_new(BIO_s_file_internal())) == NULL) 171 if ((ret=BIO_new(BIO_s_file())) == NULL)
135 { 172 {
136 fclose(file); 173 fclose(file);
137 return(NULL); 174 return(NULL);
@@ -241,7 +278,7 @@ static long MS_CALLBACK file_ctrl(BIO *b, int cmd, long num, void *ptr)
241 if (b->flags&BIO_FLAGS_UPLINK) 278 if (b->flags&BIO_FLAGS_UPLINK)
242 ret=(long)UP_fseek(b->ptr,num,0); 279 ret=(long)UP_fseek(b->ptr,num,0);
243 else 280 else
244 ret=(long)fseek(fp,num,SEEK_SET); 281 ret=(long)fseek(fp,num,0);
245 break; 282 break;
246 case BIO_CTRL_EOF: 283 case BIO_CTRL_EOF:
247 if (b->flags&BIO_FLAGS_UPLINK) 284 if (b->flags&BIO_FLAGS_UPLINK)
@@ -272,9 +309,9 @@ static long MS_CALLBACK file_ctrl(BIO *b, int cmd, long num, void *ptr)
272 BIO_clear_flags(b,BIO_FLAGS_UPLINK); 309 BIO_clear_flags(b,BIO_FLAGS_UPLINK);
273#endif 310#endif
274#endif 311#endif
275#ifdef UP_fsetmode 312#ifdef UP_fsetmod
276 if (b->flags&BIO_FLAGS_UPLINK) 313 if (b->flags&BIO_FLAGS_UPLINK)
277 UP_fsetmode(b->ptr,num&BIO_FP_TEXT?'t':'b'); 314 UP_fsetmod(b->ptr,(char)((num&BIO_FP_TEXT)?'t':'b'));
278 else 315 else
279#endif 316#endif
280 { 317 {
@@ -286,8 +323,7 @@ static long MS_CALLBACK file_ctrl(BIO *b, int cmd, long num, void *ptr)
286 _setmode(fd,_O_BINARY); 323 _setmode(fd,_O_BINARY);
287#elif defined(OPENSSL_SYS_NETWARE) && defined(NETWARE_CLIB) 324#elif defined(OPENSSL_SYS_NETWARE) && defined(NETWARE_CLIB)
288 int fd = fileno((FILE*)ptr); 325 int fd = fileno((FILE*)ptr);
289 /* Under CLib there are differences in file modes 326 /* Under CLib there are differences in file modes */
290 */
291 if (num & BIO_FP_TEXT) 327 if (num & BIO_FP_TEXT)
292 setmode(fd,O_TEXT); 328 setmode(fd,O_TEXT);
293 else 329 else
@@ -308,7 +344,7 @@ static long MS_CALLBACK file_ctrl(BIO *b, int cmd, long num, void *ptr)
308 else 344 else
309 _setmode(fd,_O_BINARY); 345 _setmode(fd,_O_BINARY);
310 } 346 }
311#elif defined(OPENSSL_SYS_OS2) 347#elif defined(OPENSSL_SYS_OS2) || defined(OPENSSL_SYS_WIN32_CYGWIN)
312 int fd = fileno((FILE*)ptr); 348 int fd = fileno((FILE*)ptr);
313 if (num & BIO_FP_TEXT) 349 if (num & BIO_FP_TEXT)
314 setmode(fd, O_TEXT); 350 setmode(fd, O_TEXT);
@@ -404,11 +440,18 @@ static int MS_CALLBACK file_gets(BIO *bp, char *buf, int size)
404 440
405 buf[0]='\0'; 441 buf[0]='\0';
406 if (bp->flags&BIO_FLAGS_UPLINK) 442 if (bp->flags&BIO_FLAGS_UPLINK)
407 UP_fgets(buf,size,bp->ptr); 443 {
444 if (!UP_fgets(buf,size,bp->ptr))
445 goto err;
446 }
408 else 447 else
409 fgets(buf,size,(FILE *)bp->ptr); 448 {
449 if (!fgets(buf,size,(FILE *)bp->ptr))
450 goto err;
451 }
410 if (buf[0] != '\0') 452 if (buf[0] != '\0')
411 ret=strlen(buf); 453 ret=strlen(buf);
454 err:
412 return(ret); 455 return(ret);
413 } 456 }
414 457
diff --git a/src/lib/libcrypto/bio/bss_log.c b/src/lib/libcrypto/bio/bss_log.c
index 6360dbc820..7ead044b37 100644
--- a/src/lib/libcrypto/bio/bss_log.c
+++ b/src/lib/libcrypto/bio/bss_log.c
@@ -70,7 +70,6 @@
70 70
71#if defined(OPENSSL_SYS_WINCE) 71#if defined(OPENSSL_SYS_WINCE)
72#elif defined(OPENSSL_SYS_WIN32) 72#elif defined(OPENSSL_SYS_WIN32)
73# include <process.h>
74#elif defined(OPENSSL_SYS_VMS) 73#elif defined(OPENSSL_SYS_VMS)
75# include <opcdef.h> 74# include <opcdef.h>
76# include <descrip.h> 75# include <descrip.h>
@@ -122,18 +121,6 @@ static int MS_CALLBACK slg_free(BIO *data);
122static void xopenlog(BIO* bp, char* name, int level); 121static void xopenlog(BIO* bp, char* name, int level);
123static void xsyslog(BIO* bp, int priority, const char* string); 122static void xsyslog(BIO* bp, int priority, const char* string);
124static void xcloselog(BIO* bp); 123static void xcloselog(BIO* bp);
125#ifdef OPENSSL_SYS_WIN32
126LONG (WINAPI *go_for_advapi)() = RegOpenKeyEx;
127HANDLE (WINAPI *register_event_source)() = NULL;
128BOOL (WINAPI *deregister_event_source)() = NULL;
129BOOL (WINAPI *report_event)() = NULL;
130#define DL_PROC(m,f) (GetProcAddress( m, f ))
131#ifdef UNICODE
132#define DL_PROC_X(m,f) DL_PROC( m, f "W" )
133#else
134#define DL_PROC_X(m,f) DL_PROC( m, f "A" )
135#endif
136#endif
137 124
138static BIO_METHOD methods_slg= 125static BIO_METHOD methods_slg=
139 { 126 {
@@ -175,7 +162,7 @@ static int MS_CALLBACK slg_write(BIO *b, const char *in, int inl)
175 char* buf; 162 char* buf;
176 char* pp; 163 char* pp;
177 int priority, i; 164 int priority, i;
178 static struct 165 static const struct
179 { 166 {
180 int strl; 167 int strl;
181 char str[10]; 168 char str[10];
@@ -249,35 +236,20 @@ static int MS_CALLBACK slg_puts(BIO *bp, const char *str)
249 236
250static void xopenlog(BIO* bp, char* name, int level) 237static void xopenlog(BIO* bp, char* name, int level)
251{ 238{
252 if ( !register_event_source ) 239 if (GetVersion() < 0x80000000)
253 { 240 bp->ptr = RegisterEventSourceA(NULL,name);
254 HANDLE advapi; 241 else
255 if ( !(advapi = GetModuleHandle("advapi32")) ) 242 bp->ptr = NULL;
256 return;
257 register_event_source = (HANDLE (WINAPI *)())DL_PROC_X(advapi,
258 "RegisterEventSource" );
259 deregister_event_source = (BOOL (WINAPI *)())DL_PROC(advapi,
260 "DeregisterEventSource");
261 report_event = (BOOL (WINAPI *)())DL_PROC_X(advapi,
262 "ReportEvent" );
263 if ( !(register_event_source && deregister_event_source &&
264 report_event) )
265 {
266 register_event_source = NULL;
267 deregister_event_source = NULL;
268 report_event = NULL;
269 return;
270 }
271 }
272 bp->ptr= (char *)register_event_source(NULL, name);
273} 243}
274 244
275static void xsyslog(BIO *bp, int priority, const char *string) 245static void xsyslog(BIO *bp, int priority, const char *string)
276{ 246{
277 LPCSTR lpszStrings[2]; 247 LPCSTR lpszStrings[2];
278 WORD evtype= EVENTLOG_ERROR_TYPE; 248 WORD evtype= EVENTLOG_ERROR_TYPE;
279 int pid = _getpid(); 249 char pidbuf[DECIMAL_SIZE(DWORD)+4];
280 char pidbuf[DECIMAL_SIZE(pid)+4]; 250
251 if (bp->ptr == NULL)
252 return;
281 253
282 switch (priority) 254 switch (priority)
283 { 255 {
@@ -301,19 +273,18 @@ static void xsyslog(BIO *bp, int priority, const char *string)
301 break; 273 break;
302 } 274 }
303 275
304 sprintf(pidbuf, "[%d] ", pid); 276 sprintf(pidbuf, "[%u] ", GetCurrentProcessId());
305 lpszStrings[0] = pidbuf; 277 lpszStrings[0] = pidbuf;
306 lpszStrings[1] = string; 278 lpszStrings[1] = string;
307 279
308 if(report_event && bp->ptr) 280 ReportEventA(bp->ptr, evtype, 0, 1024, NULL, 2, 0,
309 report_event(bp->ptr, evtype, 0, 1024, NULL, 2, 0,
310 lpszStrings, NULL); 281 lpszStrings, NULL);
311} 282}
312 283
313static void xcloselog(BIO* bp) 284static void xcloselog(BIO* bp)
314{ 285{
315 if(deregister_event_source && bp->ptr) 286 if(bp->ptr)
316 deregister_event_source((HANDLE)(bp->ptr)); 287 DeregisterEventSource((HANDLE)(bp->ptr));
317 bp->ptr= NULL; 288 bp->ptr= NULL;
318} 289}
319 290
diff --git a/src/lib/libcrypto/bio/bss_mem.c b/src/lib/libcrypto/bio/bss_mem.c
index e7ab9cb3a3..37d4194e4b 100644
--- a/src/lib/libcrypto/bio/bss_mem.c
+++ b/src/lib/libcrypto/bio/bss_mem.c
@@ -94,16 +94,18 @@ BIO *BIO_new_mem_buf(void *buf, int len)
94{ 94{
95 BIO *ret; 95 BIO *ret;
96 BUF_MEM *b; 96 BUF_MEM *b;
97 size_t sz;
98
97 if (!buf) { 99 if (!buf) {
98 BIOerr(BIO_F_BIO_NEW_MEM_BUF,BIO_R_NULL_PARAMETER); 100 BIOerr(BIO_F_BIO_NEW_MEM_BUF,BIO_R_NULL_PARAMETER);
99 return NULL; 101 return NULL;
100 } 102 }
101 if(len == -1) len = strlen(buf); 103 sz = (len<0) ? strlen(buf) : (size_t)len;
102 if(!(ret = BIO_new(BIO_s_mem())) ) return NULL; 104 if(!(ret = BIO_new(BIO_s_mem())) ) return NULL;
103 b = (BUF_MEM *)ret->ptr; 105 b = (BUF_MEM *)ret->ptr;
104 b->data = buf; 106 b->data = buf;
105 b->length = len; 107 b->length = sz;
106 b->max = len; 108 b->max = sz;
107 ret->flags |= BIO_FLAGS_MEM_RDONLY; 109 ret->flags |= BIO_FLAGS_MEM_RDONLY;
108 /* Since this is static data retrying wont help */ 110 /* Since this is static data retrying wont help */
109 ret->num = 0; 111 ret->num = 0;
@@ -144,22 +146,16 @@ static int mem_read(BIO *b, char *out, int outl)
144 { 146 {
145 int ret= -1; 147 int ret= -1;
146 BUF_MEM *bm; 148 BUF_MEM *bm;
147 int i;
148 char *from,*to;
149 149
150 bm=(BUF_MEM *)b->ptr; 150 bm=(BUF_MEM *)b->ptr;
151 BIO_clear_retry_flags(b); 151 BIO_clear_retry_flags(b);
152 ret=(outl > bm->length)?bm->length:outl; 152 ret=(outl >=0 && (size_t)outl > bm->length)?(int)bm->length:outl;
153 if ((out != NULL) && (ret > 0)) { 153 if ((out != NULL) && (ret > 0)) {
154 memcpy(out,bm->data,ret); 154 memcpy(out,bm->data,ret);
155 bm->length-=ret; 155 bm->length-=ret;
156 /* memmove(&(bm->data[0]),&(bm->data[ret]), bm->length); */
157 if(b->flags & BIO_FLAGS_MEM_RDONLY) bm->data += ret; 156 if(b->flags & BIO_FLAGS_MEM_RDONLY) bm->data += ret;
158 else { 157 else {
159 from=(char *)&(bm->data[ret]); 158 memmove(&(bm->data[0]),&(bm->data[ret]),bm->length);
160 to=(char *)&(bm->data[0]);
161 for (i=0; i<bm->length; i++)
162 to[i]=from[i];
163 } 159 }
164 } else if (bm->length == 0) 160 } else if (bm->length == 0)
165 { 161 {
diff --git a/src/lib/libcrypto/bio/bss_sock.c b/src/lib/libcrypto/bio/bss_sock.c
index 30c3ceab46..3df31938c1 100644
--- a/src/lib/libcrypto/bio/bss_sock.c
+++ b/src/lib/libcrypto/bio/bss_sock.c
@@ -172,15 +172,6 @@ static long sock_ctrl(BIO *b, int cmd, long num, void *ptr)
172 172
173 switch (cmd) 173 switch (cmd)
174 { 174 {
175 case BIO_CTRL_RESET:
176 num=0;
177 case BIO_C_FILE_SEEK:
178 ret=0;
179 break;
180 case BIO_C_FILE_TELL:
181 case BIO_CTRL_INFO:
182 ret=0;
183 break;
184 case BIO_C_SET_FD: 175 case BIO_C_SET_FD:
185 sock_free(b); 176 sock_free(b);
186 b->num= *((int *)ptr); 177 b->num= *((int *)ptr);
@@ -203,10 +194,6 @@ static long sock_ctrl(BIO *b, int cmd, long num, void *ptr)
203 case BIO_CTRL_SET_CLOSE: 194 case BIO_CTRL_SET_CLOSE:
204 b->shutdown=(int)num; 195 b->shutdown=(int)num;
205 break; 196 break;
206 case BIO_CTRL_PENDING:
207 case BIO_CTRL_WPENDING:
208 ret=0;
209 break;
210 case BIO_CTRL_DUP: 197 case BIO_CTRL_DUP:
211 case BIO_CTRL_FLUSH: 198 case BIO_CTRL_FLUSH:
212 ret=1; 199 ret=1;
diff --git a/src/lib/libcrypto/bn/Makefile b/src/lib/libcrypto/bn/Makefile
index f5e8f65a46..aabc4f56b8 100644
--- a/src/lib/libcrypto/bn/Makefile
+++ b/src/lib/libcrypto/bn/Makefile
@@ -12,8 +12,6 @@ MAKEFILE= Makefile
12AR= ar r 12AR= ar r
13 13
14BN_ASM= bn_asm.o 14BN_ASM= bn_asm.o
15# or use
16#BN_ASM= bn86-elf.o
17 15
18CFLAGS= $(INCLUDES) $(CFLAG) 16CFLAGS= $(INCLUDES) $(CFLAG)
19ASFLAGS= $(INCLUDES) $(ASFLAG) 17ASFLAGS= $(INCLUDES) $(ASFLAG)
@@ -28,13 +26,13 @@ LIBSRC= bn_add.c bn_div.c bn_exp.c bn_lib.c bn_ctx.c bn_mul.c bn_mod.c \
28 bn_print.c bn_rand.c bn_shift.c bn_word.c bn_blind.c \ 26 bn_print.c bn_rand.c bn_shift.c bn_word.c bn_blind.c \
29 bn_kron.c bn_sqrt.c bn_gcd.c bn_prime.c bn_err.c bn_sqr.c bn_asm.c \ 27 bn_kron.c bn_sqrt.c bn_gcd.c bn_prime.c bn_err.c bn_sqr.c bn_asm.c \
30 bn_recp.c bn_mont.c bn_mpi.c bn_exp2.c bn_gf2m.c bn_nist.c \ 28 bn_recp.c bn_mont.c bn_mpi.c bn_exp2.c bn_gf2m.c bn_nist.c \
31 bn_depr.c bn_x931p.c bn_const.c bn_opt.c 29 bn_depr.c bn_const.c
32 30
33LIBOBJ= bn_add.o bn_div.o bn_exp.o bn_lib.o bn_ctx.o bn_mul.o bn_mod.o \ 31LIBOBJ= bn_add.o bn_div.o bn_exp.o bn_lib.o bn_ctx.o bn_mul.o bn_mod.o \
34 bn_print.o bn_rand.o bn_shift.o bn_word.o bn_blind.o \ 32 bn_print.o bn_rand.o bn_shift.o bn_word.o bn_blind.o \
35 bn_kron.o bn_sqrt.o bn_gcd.o bn_prime.o bn_err.o bn_sqr.o $(BN_ASM) \ 33 bn_kron.o bn_sqrt.o bn_gcd.o bn_prime.o bn_err.o bn_sqr.o $(BN_ASM) \
36 bn_recp.o bn_mont.o bn_mpi.o bn_exp2.o bn_gf2m.o bn_nist.o \ 34 bn_recp.o bn_mont.o bn_mpi.o bn_exp2.o bn_gf2m.o bn_nist.o \
37 bn_depr.o bn_x931p.o bn_const.o bn_opt.o 35 bn_depr.o bn_const.o
38 36
39SRC= $(LIBSRC) 37SRC= $(LIBSRC)
40 38
@@ -58,36 +56,25 @@ bnbug: bnbug.c ../../libcrypto.a top
58 cc -g -I../../include bnbug.c -o bnbug ../../libcrypto.a 56 cc -g -I../../include bnbug.c -o bnbug ../../libcrypto.a
59 57
60lib: $(LIBOBJ) 58lib: $(LIBOBJ)
61 $(ARX) $(LIB) $(LIBOBJ) 59 $(AR) $(LIB) $(LIBOBJ)
62 $(RANLIB) $(LIB) || echo Never mind. 60 $(RANLIB) $(LIB) || echo Never mind.
63 @touch lib 61 @touch lib
64 62
65# ELF 63bn-586.s: asm/bn-586.pl ../perlasm/x86asm.pl
66bn86-elf.s: asm/bn-586.pl ../perlasm/x86asm.pl 64 $(PERL) asm/bn-586.pl $(PERLASM_SCHEME) $(CFLAGS) $(PROCESSOR) > $@
67 (cd asm; $(PERL) bn-586.pl elf $(CFLAGS) > ../$@) 65co-586.s: asm/co-586.pl ../perlasm/x86asm.pl
68co86-elf.s: asm/co-586.pl ../perlasm/x86asm.pl 66 $(PERL) asm/co-586.pl $(PERLASM_SCHEME) $(CFLAGS) $(PROCESSOR) > $@
69 (cd asm; $(PERL) co-586.pl elf $(CFLAGS) > ../$@) 67x86-mont.s: asm/x86-mont.pl ../perlasm/x86asm.pl
70mo86-elf.s: asm/mo-586.pl ../perlasm/x86asm.pl 68 $(PERL) asm/x86-mont.pl $(PERLASM_SCHEME) $(CFLAGS) $(PROCESSOR) > $@
71 (cd asm; $(PERL) mo-586.pl elf $(CFLAGS) > ../$@)
72# COFF
73bn86-cof.s: asm/bn-586.pl ../perlasm/x86asm.pl
74 (cd asm; $(PERL) bn-586.pl coff $(CFLAGS) > ../$@)
75co86-cof.s: asm/co-586.pl ../perlasm/x86asm.pl
76 (cd asm; $(PERL) co-586.pl coff $(CFLAGS) > ../$@)
77mo86-cof.s: asm/mo-586.pl ../perlasm/x86asm.pl
78 (cd asm; $(PERL) mo-586.pl coff $(CFLAGS) > ../$@)
79# a.out
80bn86-out.s: asm/bn-586.pl ../perlasm/x86asm.pl
81 (cd asm; $(PERL) bn-586.pl a.out $(CFLAGS) > ../$@)
82co86-out.s: asm/co-586.pl ../perlasm/x86asm.pl
83 (cd asm; $(PERL) co-586.pl a.out $(CFLAGS) > ../$@)
84mo86-out.s: asm/mo-586.pl ../perlasm/x86asm.pl
85 (cd asm; $(PERL) mo-586.pl a.out $(CFLAGS) > ../$@)
86 69
87sparcv8.o: asm/sparcv8.S 70sparcv8.o: asm/sparcv8.S
88 $(CC) $(CFLAGS) -c asm/sparcv8.S 71 $(CC) $(CFLAGS) -c asm/sparcv8.S
89sparcv8plus.o: asm/sparcv8plus.S 72bn-sparcv9.o: asm/sparcv8plus.S
90 $(CC) $(CFLAGS) -c asm/sparcv8plus.S 73 $(CC) $(CFLAGS) -c -o $@ asm/sparcv8plus.S
74sparcv9a-mont.s: asm/sparcv9a-mont.pl
75 $(PERL) asm/sparcv9a-mont.pl $(CFLAGS) > $@
76sparcv9-mont.s: asm/sparcv9-mont.pl
77 $(PERL) asm/sparcv9-mont.pl $(CFLAGS) > $@
91 78
92bn-mips3.o: asm/mips3.s 79bn-mips3.o: asm/mips3.s
93 @if [ "$(CC)" = "gcc" ]; then \ 80 @if [ "$(CC)" = "gcc" ]; then \
@@ -95,10 +82,13 @@ bn-mips3.o: asm/mips3.s
95 as -$$ABI -O -o $@ asm/mips3.s; \ 82 as -$$ABI -O -o $@ asm/mips3.s; \
96 else $(CC) -c $(CFLAGS) -o $@ asm/mips3.s; fi 83 else $(CC) -c $(CFLAGS) -o $@ asm/mips3.s; fi
97 84
85bn-s390x.o: asm/s390x.S
86 $(CC) $(CFLAGS) -c -o $@ asm/s390x.S
87
98x86_64-gcc.o: asm/x86_64-gcc.c 88x86_64-gcc.o: asm/x86_64-gcc.c
99 $(CC) $(CFLAGS) -c -o $@ asm/x86_64-gcc.c 89 $(CC) $(CFLAGS) -c -o $@ asm/x86_64-gcc.c
100x86_64-mont.s: asm/x86_64-mont.pl 90x86_64-mont.s: asm/x86_64-mont.pl
101 $(PERL) asm/x86_64-mont.pl $@ 91 $(PERL) asm/x86_64-mont.pl $(PERLASM_SCHEME) > $@
102 92
103bn-ia64.s: asm/ia64.S 93bn-ia64.s: asm/ia64.S
104 $(CC) $(CFLAGS) -E asm/ia64.S > $@ 94 $(CC) $(CFLAGS) -E asm/ia64.S > $@
@@ -111,12 +101,14 @@ pa-risc2.o: asm/pa-risc2.s
111 /usr/ccs/bin/as -o pa-risc2.o asm/pa-risc2.s 101 /usr/ccs/bin/as -o pa-risc2.o asm/pa-risc2.s
112 102
113# ppc - AIX, Linux, MacOS X... 103# ppc - AIX, Linux, MacOS X...
114linux_ppc32.s: asm/ppc.pl; $(PERL) $< $@ 104bn-ppc.s: asm/ppc.pl; $(PERL) asm/ppc.pl $(PERLASM_SCHEME) $@
115linux_ppc64.s: asm/ppc.pl; $(PERL) $< $@ 105ppc-mont.s: asm/ppc-mont.pl;$(PERL) asm/ppc-mont.pl $(PERLASM_SCHEME) $@
116aix_ppc32.s: asm/ppc.pl; $(PERL) asm/ppc.pl $@ 106
117aix_ppc64.s: asm/ppc.pl; $(PERL) asm/ppc.pl $@ 107alpha-mont.s: asm/alpha-mont.pl
118osx_ppc32.s: asm/ppc.pl; $(PERL) $< $@ 108 $(PERL) $< | $(CC) -E - | tee $@ > /dev/null
119osx_ppc64.s: asm/ppc.pl; $(PERL) $< $@ 109
110# GNU make "catch all"
111%-mont.s: asm/%-mont.pl; $(PERL) $< $(CFLAGS) > $@
120 112
121files: 113files:
122 $(PERL) $(TOP)/util/files.pl Makefile >> $(TOP)/MINFO 114 $(PERL) $(TOP)/util/files.pl Makefile >> $(TOP)/MINFO
@@ -184,8 +176,11 @@ bn_blind.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
184bn_blind.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h 176bn_blind.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
185bn_blind.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h 177bn_blind.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
186bn_blind.o: ../../include/openssl/symhacks.h ../cryptlib.h bn_blind.c bn_lcl.h 178bn_blind.o: ../../include/openssl/symhacks.h ../cryptlib.h bn_blind.c bn_lcl.h
187bn_const.o: ../../include/openssl/e_os2.h ../../include/openssl/opensslconf.h 179bn_const.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
188bn_const.o: ../../include/openssl/ossl_typ.h bn.h bn_const.c 180bn_const.o: ../../include/openssl/opensslconf.h
181bn_const.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
182bn_const.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
183bn_const.o: ../../include/openssl/symhacks.h bn.h bn_const.c
189bn_ctx.o: ../../e_os.h ../../include/openssl/bio.h ../../include/openssl/bn.h 184bn_ctx.o: ../../e_os.h ../../include/openssl/bio.h ../../include/openssl/bn.h
190bn_ctx.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 185bn_ctx.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
191bn_ctx.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h 186bn_ctx.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
@@ -292,13 +287,6 @@ bn_nist.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
292bn_nist.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h 287bn_nist.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
293bn_nist.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h 288bn_nist.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
294bn_nist.o: ../../include/openssl/symhacks.h ../cryptlib.h bn_lcl.h bn_nist.c 289bn_nist.o: ../../include/openssl/symhacks.h ../cryptlib.h bn_lcl.h bn_nist.c
295bn_opt.o: ../../e_os.h ../../include/openssl/bio.h ../../include/openssl/bn.h
296bn_opt.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
297bn_opt.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
298bn_opt.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
299bn_opt.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
300bn_opt.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
301bn_opt.o: ../../include/openssl/symhacks.h ../cryptlib.h bn_lcl.h bn_opt.c
302bn_prime.o: ../../e_os.h ../../include/openssl/bio.h ../../include/openssl/bn.h 290bn_prime.o: ../../e_os.h ../../include/openssl/bio.h ../../include/openssl/bn.h
303bn_prime.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 291bn_prime.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
304bn_prime.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h 292bn_prime.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
@@ -357,6 +345,3 @@ bn_word.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
357bn_word.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h 345bn_word.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
358bn_word.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h 346bn_word.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
359bn_word.o: ../../include/openssl/symhacks.h ../cryptlib.h bn_lcl.h bn_word.c 347bn_word.o: ../../include/openssl/symhacks.h ../cryptlib.h bn_lcl.h bn_word.c
360bn_x931p.o: ../../include/openssl/bn.h ../../include/openssl/e_os2.h
361bn_x931p.o: ../../include/openssl/opensslconf.h
362bn_x931p.o: ../../include/openssl/ossl_typ.h bn_x931p.c
diff --git a/src/lib/libcrypto/bn/Makefile.ssl b/src/lib/libcrypto/bn/Makefile.ssl
deleted file mode 100644
index 50892ef44c..0000000000
--- a/src/lib/libcrypto/bn/Makefile.ssl
+++ /dev/null
@@ -1,326 +0,0 @@
1#
2# SSLeay/crypto/bn/Makefile
3#
4
5DIR= bn
6TOP= ../..
7CC= cc
8CPP= $(CC) -E
9INCLUDES= -I.. -I$(TOP) -I../../include
10CFLAG=-g
11INSTALL_PREFIX=
12OPENSSLDIR= /usr/local/ssl
13INSTALLTOP=/usr/local/ssl
14MAKE= make -f Makefile.ssl
15MAKEDEPPROG= makedepend
16MAKEDEPEND= $(TOP)/util/domd $(TOP) -MD $(MAKEDEPPROG)
17MAKEFILE= Makefile.ssl
18AR= ar r
19
20BN_ASM= bn_asm.o
21# or use
22#BN_ASM= bn86-elf.o
23
24CFLAGS= $(INCLUDES) $(CFLAG)
25ASFLAGS= $(INCLUDES) $(ASFLAG)
26
27GENERAL=Makefile
28TEST=bntest.c exptest.c
29APPS=
30
31LIB=$(TOP)/libcrypto.a
32LIBSRC= bn_add.c bn_div.c bn_exp.c bn_lib.c bn_ctx.c bn_mul.c bn_mod.c \
33 bn_print.c bn_rand.c bn_shift.c bn_word.c bn_blind.c \
34 bn_kron.c bn_sqrt.c bn_gcd.c bn_prime.c bn_err.c bn_sqr.c bn_asm.c \
35 bn_recp.c bn_mont.c bn_mpi.c bn_exp2.c
36
37LIBOBJ= bn_add.o bn_div.o bn_exp.o bn_lib.o bn_ctx.o bn_mul.o bn_mod.o \
38 bn_print.o bn_rand.o bn_shift.o bn_word.o bn_blind.o \
39 bn_kron.o bn_sqrt.o bn_gcd.o bn_prime.o bn_err.o bn_sqr.o $(BN_ASM) \
40 bn_recp.o bn_mont.o bn_mpi.o bn_exp2.o
41
42SRC= $(LIBSRC)
43
44EXHEADER= bn.h
45HEADER= bn_lcl.h bn_prime.h $(EXHEADER)
46
47ALL= $(GENERAL) $(SRC) $(HEADER)
48
49top:
50 (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all)
51
52all: lib
53
54bn_prime.h: bn_prime.pl
55 $(PERL) bn_prime.pl >bn_prime.h
56
57divtest: divtest.c ../../libcrypto.a
58 cc -I../../include divtest.c -o divtest ../../libcrypto.a
59
60bnbug: bnbug.c ../../libcrypto.a top
61 cc -g -I../../include bnbug.c -o bnbug ../../libcrypto.a
62
63lib: $(LIBOBJ)
64 $(AR) $(LIB) $(LIBOBJ)
65 $(RANLIB) $(LIB) || echo Never mind.
66 @touch lib
67
68# elf
69asm/bn86-elf.s: asm/bn-586.pl ../perlasm/x86asm.pl
70 (cd asm; $(PERL) bn-586.pl elf $(CFLAGS) > bn86-elf.s)
71
72asm/co86-elf.s: asm/co-586.pl ../perlasm/x86asm.pl
73 (cd asm; $(PERL) co-586.pl elf $(CFLAGS) > co86-elf.s)
74
75# a.out
76asm/bn86-out.o: asm/bn86unix.cpp
77 $(CPP) -DOUT asm/bn86unix.cpp | as -o asm/bn86-out.o
78
79asm/co86-out.o: asm/co86unix.cpp
80 $(CPP) -DOUT asm/co86unix.cpp | as -o asm/co86-out.o
81
82# bsdi
83asm/bn86bsdi.o: asm/bn86unix.cpp
84 $(CPP) -DBSDI asm/bn86unix.cpp | sed 's/ :/:/' | as -o asm/bn86bsdi.o
85
86asm/co86bsdi.o: asm/co86unix.cpp
87 $(CPP) -DBSDI asm/co86unix.cpp | sed 's/ :/:/' | as -o asm/co86bsdi.o
88
89asm/bn86unix.cpp: asm/bn-586.pl ../perlasm/x86asm.pl
90 (cd asm; $(PERL) bn-586.pl cpp >bn86unix.cpp )
91
92asm/co86unix.cpp: asm/co-586.pl ../perlasm/x86asm.pl
93 (cd asm; $(PERL) co-586.pl cpp >co86unix.cpp )
94
95asm/sparcv8.o: asm/sparcv8.S
96
97asm/sparcv8plus.o: asm/sparcv8plus.S
98
99# Old GNU assembler doesn't understand V9 instructions, so we
100# hire /usr/ccs/bin/as to do the job. Note that option is called
101# *-gcc27, but even gcc 2>=8 users may experience similar problem
102# if they didn't bother to upgrade GNU assembler. Such users should
103# not choose this option, but be adviced to *remove* GNU assembler
104# or upgrade it.
105asm/sparcv8plus-gcc27.o: asm/sparcv8plus.S
106 $(CC) $(ASFLAGS) -E asm/sparcv8plus.S | \
107 /usr/ccs/bin/as -xarch=v8plus - -o asm/sparcv8plus-gcc27.o
108
109
110asm/ia64.o: asm/ia64.S
111
112# Some compiler drivers (most notably HP-UX and Intel C++) don't
113# understand .S extension:-( I wish I could pipe output from cc -E,
114# but it's too compiler driver/ABI dependent to cover with a single
115# rule... <appro@fy.chalmers.se>
116asm/ia64-cpp.o: asm/ia64.S
117 $(CC) $(ASFLAGS) -E asm/ia64.S > /tmp/ia64.$$$$.s && \
118 $(CC) $(ASFLAGS) -c -o asm/ia64-cpp.o /tmp/ia64.$$$$.s; \
119 rm -f /tmp/ia64.$$$$.s
120
121asm/x86_64-gcc.o: asm/x86_64-gcc.c
122
123asm/pa-risc2W.o: asm/pa-risc2W.s
124 /usr/ccs/bin/as -o asm/pa-rics2W.o asm/pa-risc2W.s
125
126files:
127 $(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO
128
129links:
130 @sh $(TOP)/util/point.sh Makefile.ssl Makefile
131 @$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER)
132 @$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST)
133 @$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS)
134
135install:
136 @for i in $(EXHEADER) ; \
137 do \
138 (cp $$i $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i; \
139 chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i ); \
140 done;
141
142exptest:
143 rm -f exptest
144 gcc -I../../include -g2 -ggdb -o exptest exptest.c ../../libcrypto.a
145
146div:
147 rm -f a.out
148 gcc -I.. -g div.c ../../libcrypto.a
149
150tags:
151 ctags $(SRC)
152
153tests:
154
155lint:
156 lint -DLINT $(INCLUDES) $(SRC)>fluff
157
158depend:
159 $(MAKEDEPEND) -- $(CFLAG) $(INCLUDES) $(DEPFLAG) -- $(PROGS) $(LIBSRC)
160
161dclean:
162 $(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
163 mv -f Makefile.new $(MAKEFILE)
164
165clean:
166 rm -f asm/co86unix.cpp asm/bn86unix.cpp asm/*-elf.* *.o */*.o *.obj lib tags core .pure .nfs* *.old *.bak fluff bn_asm.s
167
168# DO NOT DELETE THIS LINE -- make depend depends on it.
169
170bn_add.o: ../../e_os.h ../../include/openssl/bio.h ../../include/openssl/bn.h
171bn_add.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
172bn_add.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
173bn_add.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
174bn_add.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
175bn_add.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
176bn_add.o: ../cryptlib.h bn_add.c bn_lcl.h
177bn_asm.o: ../../e_os.h ../../include/openssl/bio.h ../../include/openssl/bn.h
178bn_asm.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
179bn_asm.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
180bn_asm.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
181bn_asm.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
182bn_asm.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
183bn_asm.o: ../cryptlib.h bn_asm.c bn_lcl.h
184bn_blind.o: ../../e_os.h ../../include/openssl/bio.h ../../include/openssl/bn.h
185bn_blind.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
186bn_blind.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
187bn_blind.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
188bn_blind.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
189bn_blind.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
190bn_blind.o: ../cryptlib.h bn_blind.c bn_lcl.h
191bn_ctx.o: ../../e_os.h ../../include/openssl/bio.h ../../include/openssl/bn.h
192bn_ctx.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
193bn_ctx.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
194bn_ctx.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
195bn_ctx.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
196bn_ctx.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
197bn_ctx.o: ../cryptlib.h bn_ctx.c bn_lcl.h
198bn_div.o: ../../e_os.h ../../include/openssl/bio.h ../../include/openssl/bn.h
199bn_div.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
200bn_div.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
201bn_div.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
202bn_div.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
203bn_div.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
204bn_div.o: ../cryptlib.h bn_div.c bn_lcl.h
205bn_err.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
206bn_err.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
207bn_err.o: ../../include/openssl/err.h ../../include/openssl/lhash.h
208bn_err.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
209bn_err.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
210bn_err.o: ../../include/openssl/symhacks.h bn_err.c
211bn_exp.o: ../../e_os.h ../../include/openssl/bio.h ../../include/openssl/bn.h
212bn_exp.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
213bn_exp.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
214bn_exp.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
215bn_exp.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
216bn_exp.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
217bn_exp.o: ../cryptlib.h bn_exp.c bn_lcl.h
218bn_exp2.o: ../../e_os.h ../../include/openssl/bio.h ../../include/openssl/bn.h
219bn_exp2.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
220bn_exp2.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
221bn_exp2.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
222bn_exp2.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
223bn_exp2.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
224bn_exp2.o: ../cryptlib.h bn_exp2.c bn_lcl.h
225bn_gcd.o: ../../e_os.h ../../include/openssl/bio.h ../../include/openssl/bn.h
226bn_gcd.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
227bn_gcd.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
228bn_gcd.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
229bn_gcd.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
230bn_gcd.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
231bn_gcd.o: ../cryptlib.h bn_gcd.c bn_lcl.h
232bn_kron.o: ../../include/openssl/bn.h ../../include/openssl/e_os2.h
233bn_kron.o: ../../include/openssl/opensslconf.h bn_kron.c bn_lcl.h
234bn_lib.o: ../../e_os.h ../../include/openssl/bio.h ../../include/openssl/bn.h
235bn_lib.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
236bn_lib.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
237bn_lib.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
238bn_lib.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
239bn_lib.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
240bn_lib.o: ../cryptlib.h bn_lcl.h bn_lib.c
241bn_mod.o: ../../e_os.h ../../include/openssl/bio.h ../../include/openssl/bn.h
242bn_mod.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
243bn_mod.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
244bn_mod.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
245bn_mod.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
246bn_mod.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
247bn_mod.o: ../cryptlib.h bn_lcl.h bn_mod.c
248bn_mont.o: ../../e_os.h ../../include/openssl/bio.h ../../include/openssl/bn.h
249bn_mont.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
250bn_mont.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
251bn_mont.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
252bn_mont.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
253bn_mont.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
254bn_mont.o: ../cryptlib.h bn_lcl.h bn_mont.c
255bn_mpi.o: ../../e_os.h ../../include/openssl/bio.h ../../include/openssl/bn.h
256bn_mpi.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
257bn_mpi.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
258bn_mpi.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
259bn_mpi.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
260bn_mpi.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
261bn_mpi.o: ../cryptlib.h bn_lcl.h bn_mpi.c
262bn_mul.o: ../../e_os.h ../../include/openssl/bio.h ../../include/openssl/bn.h
263bn_mul.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
264bn_mul.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
265bn_mul.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
266bn_mul.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
267bn_mul.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
268bn_mul.o: ../cryptlib.h bn_lcl.h bn_mul.c
269bn_prime.o: ../../e_os.h ../../include/openssl/bio.h ../../include/openssl/bn.h
270bn_prime.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
271bn_prime.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
272bn_prime.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
273bn_prime.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
274bn_prime.o: ../../include/openssl/rand.h ../../include/openssl/safestack.h
275bn_prime.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
276bn_prime.o: ../cryptlib.h bn_lcl.h bn_prime.c bn_prime.h
277bn_print.o: ../../e_os.h ../../include/openssl/bio.h ../../include/openssl/bn.h
278bn_print.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
279bn_print.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
280bn_print.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
281bn_print.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
282bn_print.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
283bn_print.o: ../cryptlib.h bn_lcl.h bn_print.c
284bn_rand.o: ../../e_os.h ../../include/openssl/bio.h ../../include/openssl/bn.h
285bn_rand.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
286bn_rand.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
287bn_rand.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
288bn_rand.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
289bn_rand.o: ../../include/openssl/rand.h ../../include/openssl/safestack.h
290bn_rand.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
291bn_rand.o: ../cryptlib.h bn_lcl.h bn_rand.c
292bn_recp.o: ../../e_os.h ../../include/openssl/bio.h ../../include/openssl/bn.h
293bn_recp.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
294bn_recp.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
295bn_recp.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
296bn_recp.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
297bn_recp.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
298bn_recp.o: ../cryptlib.h bn_lcl.h bn_recp.c
299bn_shift.o: ../../e_os.h ../../include/openssl/bio.h ../../include/openssl/bn.h
300bn_shift.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
301bn_shift.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
302bn_shift.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
303bn_shift.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
304bn_shift.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
305bn_shift.o: ../cryptlib.h bn_lcl.h bn_shift.c
306bn_sqr.o: ../../e_os.h ../../include/openssl/bio.h ../../include/openssl/bn.h
307bn_sqr.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
308bn_sqr.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
309bn_sqr.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
310bn_sqr.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
311bn_sqr.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
312bn_sqr.o: ../cryptlib.h bn_lcl.h bn_sqr.c
313bn_sqrt.o: ../../e_os.h ../../include/openssl/bio.h ../../include/openssl/bn.h
314bn_sqrt.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
315bn_sqrt.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
316bn_sqrt.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
317bn_sqrt.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
318bn_sqrt.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
319bn_sqrt.o: ../cryptlib.h bn_lcl.h bn_sqrt.c
320bn_word.o: ../../e_os.h ../../include/openssl/bio.h ../../include/openssl/bn.h
321bn_word.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
322bn_word.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
323bn_word.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
324bn_word.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
325bn_word.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
326bn_word.o: ../cryptlib.h bn_lcl.h bn_word.c
diff --git a/src/lib/libcrypto/bn/asm/alpha.s b/src/lib/libcrypto/bn/asm/alpha.s
deleted file mode 100644
index 555ff0b92d..0000000000
--- a/src/lib/libcrypto/bn/asm/alpha.s
+++ /dev/null
@@ -1,3199 +0,0 @@
1 # DEC Alpha assember
2 # The bn_div_words is actually gcc output but the other parts are hand done.
3 # Thanks to tzeruch@ceddec.com for sending me the gcc output for
4 # bn_div_words.
5 # I've gone back and re-done most of routines.
6 # The key thing to remeber for the 164 CPU is that while a
7 # multiply operation takes 8 cycles, another one can only be issued
8 # after 4 cycles have elapsed. I've done modification to help
9 # improve this. Also, normally, a ld instruction will not be available
10 # for about 3 cycles.
11 .file 1 "bn_asm.c"
12 .set noat
13gcc2_compiled.:
14__gnu_compiled_c:
15 .text
16 .align 3
17 .globl bn_mul_add_words
18 .ent bn_mul_add_words
19bn_mul_add_words:
20bn_mul_add_words..ng:
21 .frame $30,0,$26,0
22 .prologue 0
23 .align 5
24 subq $18,4,$18
25 bis $31,$31,$0
26 blt $18,$43 # if we are -1, -2, -3 or -4 goto tail code
27 ldq $20,0($17) # 1 1
28 ldq $1,0($16) # 1 1
29 .align 3
30$42:
31 mulq $20,$19,$5 # 1 2 1 ######
32 ldq $21,8($17) # 2 1
33 ldq $2,8($16) # 2 1
34 umulh $20,$19,$20 # 1 2 ######
35 ldq $27,16($17) # 3 1
36 ldq $3,16($16) # 3 1
37 mulq $21,$19,$6 # 2 2 1 ######
38 ldq $28,24($17) # 4 1
39 addq $1,$5,$1 # 1 2 2
40 ldq $4,24($16) # 4 1
41 umulh $21,$19,$21 # 2 2 ######
42 cmpult $1,$5,$22 # 1 2 3 1
43 addq $20,$22,$20 # 1 3 1
44 addq $1,$0,$1 # 1 2 3 1
45 mulq $27,$19,$7 # 3 2 1 ######
46 cmpult $1,$0,$0 # 1 2 3 2
47 addq $2,$6,$2 # 2 2 2
48 addq $20,$0,$0 # 1 3 2
49 cmpult $2,$6,$23 # 2 2 3 1
50 addq $21,$23,$21 # 2 3 1
51 umulh $27,$19,$27 # 3 2 ######
52 addq $2,$0,$2 # 2 2 3 1
53 cmpult $2,$0,$0 # 2 2 3 2
54 subq $18,4,$18
55 mulq $28,$19,$8 # 4 2 1 ######
56 addq $21,$0,$0 # 2 3 2
57 addq $3,$7,$3 # 3 2 2
58 addq $16,32,$16
59 cmpult $3,$7,$24 # 3 2 3 1
60 stq $1,-32($16) # 1 2 4
61 umulh $28,$19,$28 # 4 2 ######
62 addq $27,$24,$27 # 3 3 1
63 addq $3,$0,$3 # 3 2 3 1
64 stq $2,-24($16) # 2 2 4
65 cmpult $3,$0,$0 # 3 2 3 2
66 stq $3,-16($16) # 3 2 4
67 addq $4,$8,$4 # 4 2 2
68 addq $27,$0,$0 # 3 3 2
69 cmpult $4,$8,$25 # 4 2 3 1
70 addq $17,32,$17
71 addq $28,$25,$28 # 4 3 1
72 addq $4,$0,$4 # 4 2 3 1
73 cmpult $4,$0,$0 # 4 2 3 2
74 stq $4,-8($16) # 4 2 4
75 addq $28,$0,$0 # 4 3 2
76 blt $18,$43
77
78 ldq $20,0($17) # 1 1
79 ldq $1,0($16) # 1 1
80
81 br $42
82
83 .align 4
84$45:
85 ldq $20,0($17) # 4 1
86 ldq $1,0($16) # 4 1
87 mulq $20,$19,$5 # 4 2 1
88 subq $18,1,$18
89 addq $16,8,$16
90 addq $17,8,$17
91 umulh $20,$19,$20 # 4 2
92 addq $1,$5,$1 # 4 2 2
93 cmpult $1,$5,$22 # 4 2 3 1
94 addq $20,$22,$20 # 4 3 1
95 addq $1,$0,$1 # 4 2 3 1
96 cmpult $1,$0,$0 # 4 2 3 2
97 addq $20,$0,$0 # 4 3 2
98 stq $1,-8($16) # 4 2 4
99 bgt $18,$45
100 ret $31,($26),1 # else exit
101
102 .align 4
103$43:
104 addq $18,4,$18
105 bgt $18,$45 # goto tail code
106 ret $31,($26),1 # else exit
107
108 .end bn_mul_add_words
109 .align 3
110 .globl bn_mul_words
111 .ent bn_mul_words
112bn_mul_words:
113bn_mul_words..ng:
114 .frame $30,0,$26,0
115 .prologue 0
116 .align 5
117 subq $18,4,$18
118 bis $31,$31,$0
119 blt $18,$143 # if we are -1, -2, -3 or -4 goto tail code
120 ldq $20,0($17) # 1 1
121 .align 3
122$142:
123
124 mulq $20,$19,$5 # 1 2 1 #####
125 ldq $21,8($17) # 2 1
126 ldq $27,16($17) # 3 1
127 umulh $20,$19,$20 # 1 2 #####
128 ldq $28,24($17) # 4 1
129 mulq $21,$19,$6 # 2 2 1 #####
130 addq $5,$0,$5 # 1 2 3 1
131 subq $18,4,$18
132 cmpult $5,$0,$0 # 1 2 3 2
133 umulh $21,$19,$21 # 2 2 #####
134 addq $20,$0,$0 # 1 3 2
135 addq $17,32,$17
136 addq $6,$0,$6 # 2 2 3 1
137 mulq $27,$19,$7 # 3 2 1 #####
138 cmpult $6,$0,$0 # 2 2 3 2
139 addq $21,$0,$0 # 2 3 2
140 addq $16,32,$16
141 umulh $27,$19,$27 # 3 2 #####
142 stq $5,-32($16) # 1 2 4
143 mulq $28,$19,$8 # 4 2 1 #####
144 addq $7,$0,$7 # 3 2 3 1
145 stq $6,-24($16) # 2 2 4
146 cmpult $7,$0,$0 # 3 2 3 2
147 umulh $28,$19,$28 # 4 2 #####
148 addq $27,$0,$0 # 3 3 2
149 stq $7,-16($16) # 3 2 4
150 addq $8,$0,$8 # 4 2 3 1
151 cmpult $8,$0,$0 # 4 2 3 2
152
153 addq $28,$0,$0 # 4 3 2
154
155 stq $8,-8($16) # 4 2 4
156
157 blt $18,$143
158
159 ldq $20,0($17) # 1 1
160
161 br $142
162
163 .align 4
164$145:
165 ldq $20,0($17) # 4 1
166 mulq $20,$19,$5 # 4 2 1
167 subq $18,1,$18
168 umulh $20,$19,$20 # 4 2
169 addq $5,$0,$5 # 4 2 3 1
170 addq $16,8,$16
171 cmpult $5,$0,$0 # 4 2 3 2
172 addq $17,8,$17
173 addq $20,$0,$0 # 4 3 2
174 stq $5,-8($16) # 4 2 4
175
176 bgt $18,$145
177 ret $31,($26),1 # else exit
178
179 .align 4
180$143:
181 addq $18,4,$18
182 bgt $18,$145 # goto tail code
183 ret $31,($26),1 # else exit
184
185 .end bn_mul_words
186 .align 3
187 .globl bn_sqr_words
188 .ent bn_sqr_words
189bn_sqr_words:
190bn_sqr_words..ng:
191 .frame $30,0,$26,0
192 .prologue 0
193
194 subq $18,4,$18
195 blt $18,$543 # if we are -1, -2, -3 or -4 goto tail code
196 ldq $20,0($17) # 1 1
197 .align 3
198$542:
199 mulq $20,$20,$5 ######
200 ldq $21,8($17) # 1 1
201 subq $18,4
202 umulh $20,$20,$1 ######
203 ldq $27,16($17) # 1 1
204 mulq $21,$21,$6 ######
205 ldq $28,24($17) # 1 1
206 stq $5,0($16) # r[0]
207 umulh $21,$21,$2 ######
208 stq $1,8($16) # r[1]
209 mulq $27,$27,$7 ######
210 stq $6,16($16) # r[0]
211 umulh $27,$27,$3 ######
212 stq $2,24($16) # r[1]
213 mulq $28,$28,$8 ######
214 stq $7,32($16) # r[0]
215 umulh $28,$28,$4 ######
216 stq $3,40($16) # r[1]
217
218 addq $16,64,$16
219 addq $17,32,$17
220 stq $8,-16($16) # r[0]
221 stq $4,-8($16) # r[1]
222
223 blt $18,$543
224 ldq $20,0($17) # 1 1
225 br $542
226
227$442:
228 ldq $20,0($17) # a[0]
229 mulq $20,$20,$5 # a[0]*w low part r2
230 addq $16,16,$16
231 addq $17,8,$17
232 subq $18,1,$18
233 umulh $20,$20,$1 # a[0]*w high part r3
234 stq $5,-16($16) # r[0]
235 stq $1,-8($16) # r[1]
236
237 bgt $18,$442
238 ret $31,($26),1 # else exit
239
240 .align 4
241$543:
242 addq $18,4,$18
243 bgt $18,$442 # goto tail code
244 ret $31,($26),1 # else exit
245 .end bn_sqr_words
246
247 .align 3
248 .globl bn_add_words
249 .ent bn_add_words
250bn_add_words:
251bn_add_words..ng:
252 .frame $30,0,$26,0
253 .prologue 0
254
255 subq $19,4,$19
256 bis $31,$31,$0 # carry = 0
257 blt $19,$900
258 ldq $5,0($17) # a[0]
259 ldq $1,0($18) # b[1]
260 .align 3
261$901:
262 addq $1,$5,$1 # r=a+b;
263 ldq $6,8($17) # a[1]
264 cmpult $1,$5,$22 # did we overflow?
265 ldq $2,8($18) # b[1]
266 addq $1,$0,$1 # c+= overflow
267 ldq $7,16($17) # a[2]
268 cmpult $1,$0,$0 # overflow?
269 ldq $3,16($18) # b[2]
270 addq $0,$22,$0
271 ldq $8,24($17) # a[3]
272 addq $2,$6,$2 # r=a+b;
273 ldq $4,24($18) # b[3]
274 cmpult $2,$6,$23 # did we overflow?
275 addq $3,$7,$3 # r=a+b;
276 addq $2,$0,$2 # c+= overflow
277 cmpult $3,$7,$24 # did we overflow?
278 cmpult $2,$0,$0 # overflow?
279 addq $4,$8,$4 # r=a+b;
280 addq $0,$23,$0
281 cmpult $4,$8,$25 # did we overflow?
282 addq $3,$0,$3 # c+= overflow
283 stq $1,0($16) # r[0]=c
284 cmpult $3,$0,$0 # overflow?
285 stq $2,8($16) # r[1]=c
286 addq $0,$24,$0
287 stq $3,16($16) # r[2]=c
288 addq $4,$0,$4 # c+= overflow
289 subq $19,4,$19 # loop--
290 cmpult $4,$0,$0 # overflow?
291 addq $17,32,$17 # a++
292 addq $0,$25,$0
293 stq $4,24($16) # r[3]=c
294 addq $18,32,$18 # b++
295 addq $16,32,$16 # r++
296
297 blt $19,$900
298 ldq $5,0($17) # a[0]
299 ldq $1,0($18) # b[1]
300 br $901
301 .align 4
302$945:
303 ldq $5,0($17) # a[0]
304 ldq $1,0($18) # b[1]
305 addq $1,$5,$1 # r=a+b;
306 subq $19,1,$19 # loop--
307 addq $1,$0,$1 # c+= overflow
308 addq $17,8,$17 # a++
309 cmpult $1,$5,$22 # did we overflow?
310 cmpult $1,$0,$0 # overflow?
311 addq $18,8,$18 # b++
312 stq $1,0($16) # r[0]=c
313 addq $0,$22,$0
314 addq $16,8,$16 # r++
315
316 bgt $19,$945
317 ret $31,($26),1 # else exit
318
319$900:
320 addq $19,4,$19
321 bgt $19,$945 # goto tail code
322 ret $31,($26),1 # else exit
323 .end bn_add_words
324
325 #
326 # What follows was taken directly from the C compiler with a few
327 # hacks to redo the lables.
328 #
329.text
330 .align 3
331 .globl bn_div_words
332 .ent bn_div_words
333bn_div_words:
334 ldgp $29,0($27)
335bn_div_words..ng:
336 lda $30,-48($30)
337 .frame $30,48,$26,0
338 stq $26,0($30)
339 stq $9,8($30)
340 stq $10,16($30)
341 stq $11,24($30)
342 stq $12,32($30)
343 stq $13,40($30)
344 .mask 0x4003e00,-48
345 .prologue 1
346 bis $16,$16,$9
347 bis $17,$17,$10
348 bis $18,$18,$11
349 bis $31,$31,$13
350 bis $31,2,$12
351 bne $11,$119
352 lda $0,-1
353 br $31,$136
354 .align 4
355$119:
356 bis $11,$11,$16
357 jsr $26,BN_num_bits_word
358 ldgp $29,0($26)
359 subq $0,64,$1
360 beq $1,$120
361 bis $31,1,$1
362 sll $1,$0,$1
363 cmpule $9,$1,$1
364 bne $1,$120
365 # lda $16,_IO_stderr_
366 # lda $17,$C32
367 # bis $0,$0,$18
368 # jsr $26,fprintf
369 # ldgp $29,0($26)
370 jsr $26,abort
371 ldgp $29,0($26)
372 .align 4
373$120:
374 bis $31,64,$3
375 cmpult $9,$11,$2
376 subq $3,$0,$1
377 addl $1,$31,$0
378 subq $9,$11,$1
379 cmoveq $2,$1,$9
380 beq $0,$122
381 zapnot $0,15,$2
382 subq $3,$0,$1
383 sll $11,$2,$11
384 sll $9,$2,$3
385 srl $10,$1,$1
386 sll $10,$2,$10
387 bis $3,$1,$9
388$122:
389 srl $11,32,$5
390 zapnot $11,15,$6
391 lda $7,-1
392 .align 5
393$123:
394 srl $9,32,$1
395 subq $1,$5,$1
396 bne $1,$126
397 zapnot $7,15,$27
398 br $31,$127
399 .align 4
400$126:
401 bis $9,$9,$24
402 bis $5,$5,$25
403 divqu $24,$25,$27
404$127:
405 srl $10,32,$4
406 .align 5
407$128:
408 mulq $27,$5,$1
409 subq $9,$1,$3
410 zapnot $3,240,$1
411 bne $1,$129
412 mulq $6,$27,$2
413 sll $3,32,$1
414 addq $1,$4,$1
415 cmpule $2,$1,$2
416 bne $2,$129
417 subq $27,1,$27
418 br $31,$128
419 .align 4
420$129:
421 mulq $27,$6,$1
422 mulq $27,$5,$4
423 srl $1,32,$3
424 sll $1,32,$1
425 addq $4,$3,$4
426 cmpult $10,$1,$2
427 subq $10,$1,$10
428 addq $2,$4,$2
429 cmpult $9,$2,$1
430 bis $2,$2,$4
431 beq $1,$134
432 addq $9,$11,$9
433 subq $27,1,$27
434$134:
435 subl $12,1,$12
436 subq $9,$4,$9
437 beq $12,$124
438 sll $27,32,$13
439 sll $9,32,$2
440 srl $10,32,$1
441 sll $10,32,$10
442 bis $2,$1,$9
443 br $31,$123
444 .align 4
445$124:
446 bis $13,$27,$0
447$136:
448 ldq $26,0($30)
449 ldq $9,8($30)
450 ldq $10,16($30)
451 ldq $11,24($30)
452 ldq $12,32($30)
453 ldq $13,40($30)
454 addq $30,48,$30
455 ret $31,($26),1
456 .end bn_div_words
457
458 .set noat
459 .text
460 .align 3
461 .globl bn_sub_words
462 .ent bn_sub_words
463bn_sub_words:
464bn_sub_words..ng:
465 .frame $30,0,$26,0
466 .prologue 0
467
468 subq $19, 4, $19
469 bis $31, $31, $0
470 blt $19, $100
471 ldq $1, 0($17)
472 ldq $2, 0($18)
473$101:
474 ldq $3, 8($17)
475 cmpult $1, $2, $4
476 ldq $5, 8($18)
477 subq $1, $2, $1
478 ldq $6, 16($17)
479 cmpult $1, $0, $2
480 ldq $7, 16($18)
481 subq $1, $0, $23
482 ldq $8, 24($17)
483 addq $2, $4, $0
484 cmpult $3, $5, $24
485 subq $3, $5, $3
486 ldq $22, 24($18)
487 cmpult $3, $0, $5
488 subq $3, $0, $25
489 addq $5, $24, $0
490 cmpult $6, $7, $27
491 subq $6, $7, $6
492 stq $23, 0($16)
493 cmpult $6, $0, $7
494 subq $6, $0, $28
495 addq $7, $27, $0
496 cmpult $8, $22, $21
497 subq $8, $22, $8
498 stq $25, 8($16)
499 cmpult $8, $0, $22
500 subq $8, $0, $20
501 addq $22, $21, $0
502 stq $28, 16($16)
503 subq $19, 4, $19
504 stq $20, 24($16)
505 addq $17, 32, $17
506 addq $18, 32, $18
507 addq $16, 32, $16
508 blt $19, $100
509 ldq $1, 0($17)
510 ldq $2, 0($18)
511 br $101
512$102:
513 ldq $1, 0($17)
514 ldq $2, 0($18)
515 cmpult $1, $2, $27
516 subq $1, $2, $1
517 cmpult $1, $0, $2
518 subq $1, $0, $1
519 stq $1, 0($16)
520 addq $2, $27, $0
521 addq $17, 8, $17
522 addq $18, 8, $18
523 addq $16, 8, $16
524 subq $19, 1, $19
525 bgt $19, $102
526 ret $31,($26),1
527$100:
528 addq $19, 4, $19
529 bgt $19, $102
530$103:
531 ret $31,($26),1
532 .end bn_sub_words
533 .text
534 .align 3
535 .globl bn_mul_comba4
536 .ent bn_mul_comba4
537bn_mul_comba4:
538bn_mul_comba4..ng:
539 .frame $30,0,$26,0
540 .prologue 0
541
542 ldq $0, 0($17)
543 ldq $1, 0($18)
544 ldq $2, 8($17)
545 ldq $3, 8($18)
546 ldq $4, 16($17)
547 ldq $5, 16($18)
548 ldq $6, 24($17)
549 ldq $7, 24($18)
550 bis $31, $31, $23
551 mulq $0, $1, $8
552 umulh $0, $1, $22
553 stq $8, 0($16)
554 bis $31, $31, $8
555 mulq $0, $3, $24
556 umulh $0, $3, $25
557 addq $22, $24, $22
558 cmpult $22, $24, $27
559 addq $27, $25, $25
560 addq $23, $25, $23
561 cmpult $23, $25, $28
562 addq $8, $28, $8
563 mulq $2, $1, $21
564 umulh $2, $1, $20
565 addq $22, $21, $22
566 cmpult $22, $21, $19
567 addq $19, $20, $20
568 addq $23, $20, $23
569 cmpult $23, $20, $17
570 addq $8, $17, $8
571 stq $22, 8($16)
572 bis $31, $31, $22
573 mulq $2, $3, $18
574 umulh $2, $3, $24
575 addq $23, $18, $23
576 cmpult $23, $18, $27
577 addq $27, $24, $24
578 addq $8, $24, $8
579 cmpult $8, $24, $25
580 addq $22, $25, $22
581 mulq $0, $5, $28
582 umulh $0, $5, $21
583 addq $23, $28, $23
584 cmpult $23, $28, $19
585 addq $19, $21, $21
586 addq $8, $21, $8
587 cmpult $8, $21, $20
588 addq $22, $20, $22
589 mulq $4, $1, $17
590 umulh $4, $1, $18
591 addq $23, $17, $23
592 cmpult $23, $17, $27
593 addq $27, $18, $18
594 addq $8, $18, $8
595 cmpult $8, $18, $24
596 addq $22, $24, $22
597 stq $23, 16($16)
598 bis $31, $31, $23
599 mulq $0, $7, $25
600 umulh $0, $7, $28
601 addq $8, $25, $8
602 cmpult $8, $25, $19
603 addq $19, $28, $28
604 addq $22, $28, $22
605 cmpult $22, $28, $21
606 addq $23, $21, $23
607 mulq $2, $5, $20
608 umulh $2, $5, $17
609 addq $8, $20, $8
610 cmpult $8, $20, $27
611 addq $27, $17, $17
612 addq $22, $17, $22
613 cmpult $22, $17, $18
614 addq $23, $18, $23
615 mulq $4, $3, $24
616 umulh $4, $3, $25
617 addq $8, $24, $8
618 cmpult $8, $24, $19
619 addq $19, $25, $25
620 addq $22, $25, $22
621 cmpult $22, $25, $28
622 addq $23, $28, $23
623 mulq $6, $1, $21
624 umulh $6, $1, $0
625 addq $8, $21, $8
626 cmpult $8, $21, $20
627 addq $20, $0, $0
628 addq $22, $0, $22
629 cmpult $22, $0, $27
630 addq $23, $27, $23
631 stq $8, 24($16)
632 bis $31, $31, $8
633 mulq $2, $7, $17
634 umulh $2, $7, $18
635 addq $22, $17, $22
636 cmpult $22, $17, $24
637 addq $24, $18, $18
638 addq $23, $18, $23
639 cmpult $23, $18, $19
640 addq $8, $19, $8
641 mulq $4, $5, $25
642 umulh $4, $5, $28
643 addq $22, $25, $22
644 cmpult $22, $25, $21
645 addq $21, $28, $28
646 addq $23, $28, $23
647 cmpult $23, $28, $20
648 addq $8, $20, $8
649 mulq $6, $3, $0
650 umulh $6, $3, $27
651 addq $22, $0, $22
652 cmpult $22, $0, $1
653 addq $1, $27, $27
654 addq $23, $27, $23
655 cmpult $23, $27, $17
656 addq $8, $17, $8
657 stq $22, 32($16)
658 bis $31, $31, $22
659 mulq $4, $7, $24
660 umulh $4, $7, $18
661 addq $23, $24, $23
662 cmpult $23, $24, $19
663 addq $19, $18, $18
664 addq $8, $18, $8
665 cmpult $8, $18, $2
666 addq $22, $2, $22
667 mulq $6, $5, $25
668 umulh $6, $5, $21
669 addq $23, $25, $23
670 cmpult $23, $25, $28
671 addq $28, $21, $21
672 addq $8, $21, $8
673 cmpult $8, $21, $20
674 addq $22, $20, $22
675 stq $23, 40($16)
676 bis $31, $31, $23
677 mulq $6, $7, $0
678 umulh $6, $7, $1
679 addq $8, $0, $8
680 cmpult $8, $0, $27
681 addq $27, $1, $1
682 addq $22, $1, $22
683 cmpult $22, $1, $17
684 addq $23, $17, $23
685 stq $8, 48($16)
686 stq $22, 56($16)
687 ret $31,($26),1
688 .end bn_mul_comba4
689 .text
690 .align 3
691 .globl bn_mul_comba8
692 .ent bn_mul_comba8
693bn_mul_comba8:
694bn_mul_comba8..ng:
695 .frame $30,0,$26,0
696 .prologue 0
697 ldq $1, 0($17)
698 ldq $2, 0($18)
699 zapnot $1, 15, $7
700 srl $2, 32, $8
701 mulq $8, $7, $22
702 srl $1, 32, $6
703 zapnot $2, 15, $5
704 mulq $5, $6, $4
705 mulq $7, $5, $24
706 addq $22, $4, $22
707 cmpult $22, $4, $1
708 mulq $6, $8, $3
709 beq $1, $173
710 bis $31, 1, $1
711 sll $1, 32, $1
712 addq $3, $1, $3
713$173:
714 sll $22, 32, $4
715 addq $24, $4, $24
716 stq $24, 0($16)
717 ldq $2, 0($17)
718 ldq $1, 8($18)
719 zapnot $2, 15, $7
720 srl $1, 32, $8
721 mulq $8, $7, $25
722 zapnot $1, 15, $5
723 mulq $7, $5, $0
724 srl $2, 32, $6
725 mulq $5, $6, $23
726 mulq $6, $8, $6
727 srl $22, 32, $1
728 cmpult $24, $4, $2
729 addq $3, $1, $3
730 addq $2, $3, $22
731 addq $25, $23, $25
732 cmpult $25, $23, $1
733 bis $31, 1, $2
734 beq $1, $177
735 sll $2, 32, $1
736 addq $6, $1, $6
737$177:
738 sll $25, 32, $23
739 ldq $1, 0($18)
740 addq $0, $23, $0
741 bis $0, $0, $7
742 ldq $3, 8($17)
743 addq $22, $7, $22
744 srl $1, 32, $8
745 cmpult $22, $7, $4
746 zapnot $3, 15, $7
747 mulq $8, $7, $28
748 zapnot $1, 15, $5
749 mulq $7, $5, $21
750 srl $25, 32, $1
751 cmpult $0, $23, $2
752 addq $6, $1, $6
753 addq $2, $6, $6
754 addq $4, $6, $24
755 srl $3, 32, $6
756 mulq $5, $6, $2
757 mulq $6, $8, $6
758 addq $28, $2, $28
759 cmpult $28, $2, $1
760 bis $31, 1, $2
761 beq $1, $181
762 sll $2, 32, $1
763 addq $6, $1, $6
764$181:
765 sll $28, 32, $2
766 addq $21, $2, $21
767 bis $21, $21, $7
768 addq $22, $7, $22
769 stq $22, 8($16)
770 ldq $3, 16($17)
771 ldq $1, 0($18)
772 cmpult $22, $7, $4
773 zapnot $3, 15, $7
774 srl $1, 32, $8
775 mulq $8, $7, $22
776 zapnot $1, 15, $5
777 mulq $7, $5, $20
778 srl $28, 32, $1
779 cmpult $21, $2, $2
780 addq $6, $1, $6
781 addq $2, $6, $6
782 addq $4, $6, $6
783 addq $24, $6, $24
784 cmpult $24, $6, $23
785 srl $3, 32, $6
786 mulq $5, $6, $2
787 mulq $6, $8, $6
788 addq $22, $2, $22
789 cmpult $22, $2, $1
790 bis $31, 1, $2
791 beq $1, $185
792 sll $2, 32, $1
793 addq $6, $1, $6
794$185:
795 sll $22, 32, $2
796 ldq $1, 8($18)
797 addq $20, $2, $20
798 bis $20, $20, $7
799 ldq $4, 8($17)
800 addq $24, $7, $24
801 srl $1, 32, $8
802 cmpult $24, $7, $3
803 zapnot $4, 15, $7
804 mulq $8, $7, $25
805 zapnot $1, 15, $5
806 mulq $7, $5, $0
807 srl $22, 32, $1
808 cmpult $20, $2, $2
809 addq $6, $1, $6
810 addq $2, $6, $6
811 addq $3, $6, $6
812 addq $23, $6, $23
813 cmpult $23, $6, $22
814 srl $4, 32, $6
815 mulq $5, $6, $5
816 bis $31, 1, $21
817 addq $25, $5, $25
818 cmpult $25, $5, $1
819 mulq $6, $8, $6
820 beq $1, $189
821 sll $21, 32, $1
822 addq $6, $1, $6
823$189:
824 sll $25, 32, $5
825 ldq $2, 16($18)
826 addq $0, $5, $0
827 bis $0, $0, $7
828 ldq $4, 0($17)
829 addq $24, $7, $24
830 srl $2, 32, $8
831 cmpult $24, $7, $3
832 zapnot $4, 15, $7
833 mulq $8, $7, $28
834 srl $25, 32, $1
835 addq $6, $1, $6
836 cmpult $0, $5, $1
837 zapnot $2, 15, $5
838 addq $1, $6, $6
839 addq $3, $6, $6
840 addq $23, $6, $23
841 cmpult $23, $6, $1
842 srl $4, 32, $6
843 mulq $5, $6, $25
844 mulq $7, $5, $2
845 addq $1, $22, $22
846 addq $28, $25, $28
847 cmpult $28, $25, $1
848 mulq $6, $8, $6
849 beq $1, $193
850 sll $21, 32, $1
851 addq $6, $1, $6
852$193:
853 sll $28, 32, $25
854 addq $2, $25, $2
855 bis $2, $2, $7
856 addq $24, $7, $24
857 stq $24, 16($16)
858 ldq $4, 0($17)
859 ldq $5, 24($18)
860 cmpult $24, $7, $3
861 zapnot $4, 15, $7
862 srl $5, 32, $8
863 mulq $8, $7, $0
864 srl $28, 32, $1
865 cmpult $2, $25, $2
866 addq $6, $1, $6
867 addq $2, $6, $6
868 addq $3, $6, $6
869 addq $23, $6, $23
870 cmpult $23, $6, $1
871 srl $4, 32, $6
872 zapnot $5, 15, $5
873 mulq $5, $6, $24
874 mulq $7, $5, $2
875 addq $1, $22, $22
876 addq $0, $24, $0
877 cmpult $0, $24, $1
878 mulq $6, $8, $6
879 beq $1, $197
880 sll $21, 32, $1
881 addq $6, $1, $6
882$197:
883 sll $0, 32, $24
884 ldq $1, 16($18)
885 addq $2, $24, $2
886 bis $2, $2, $7
887 ldq $4, 8($17)
888 addq $23, $7, $23
889 srl $1, 32, $8
890 cmpult $23, $7, $3
891 zapnot $4, 15, $7
892 mulq $8, $7, $25
893 zapnot $1, 15, $5
894 mulq $7, $5, $21
895 srl $0, 32, $1
896 cmpult $2, $24, $2
897 addq $6, $1, $6
898 addq $2, $6, $6
899 addq $3, $6, $6
900 addq $22, $6, $22
901 cmpult $22, $6, $24
902 srl $4, 32, $6
903 mulq $5, $6, $5
904 bis $31, 1, $20
905 addq $25, $5, $25
906 cmpult $25, $5, $1
907 mulq $6, $8, $6
908 beq $1, $201
909 sll $20, 32, $1
910 addq $6, $1, $6
911$201:
912 sll $25, 32, $5
913 ldq $2, 8($18)
914 addq $21, $5, $21
915 bis $21, $21, $7
916 ldq $4, 16($17)
917 addq $23, $7, $23
918 srl $2, 32, $8
919 cmpult $23, $7, $3
920 zapnot $4, 15, $7
921 mulq $8, $7, $28
922 srl $25, 32, $1
923 addq $6, $1, $6
924 cmpult $21, $5, $1
925 zapnot $2, 15, $5
926 addq $1, $6, $6
927 addq $3, $6, $6
928 addq $22, $6, $22
929 cmpult $22, $6, $1
930 srl $4, 32, $6
931 mulq $5, $6, $25
932 mulq $7, $5, $5
933 addq $1, $24, $24
934 addq $28, $25, $28
935 cmpult $28, $25, $1
936 mulq $6, $8, $6
937 beq $1, $205
938 sll $20, 32, $1
939 addq $6, $1, $6
940$205:
941 sll $28, 32, $25
942 ldq $2, 0($18)
943 addq $5, $25, $5
944 bis $5, $5, $7
945 ldq $4, 24($17)
946 addq $23, $7, $23
947 srl $2, 32, $8
948 cmpult $23, $7, $3
949 zapnot $4, 15, $7
950 mulq $8, $7, $0
951 srl $28, 32, $1
952 addq $6, $1, $6
953 cmpult $5, $25, $1
954 zapnot $2, 15, $5
955 addq $1, $6, $6
956 addq $3, $6, $6
957 addq $22, $6, $22
958 cmpult $22, $6, $1
959 srl $4, 32, $6
960 mulq $5, $6, $25
961 mulq $7, $5, $2
962 addq $1, $24, $24
963 addq $0, $25, $0
964 cmpult $0, $25, $1
965 mulq $6, $8, $6
966 beq $1, $209
967 sll $20, 32, $1
968 addq $6, $1, $6
969$209:
970 sll $0, 32, $25
971 addq $2, $25, $2
972 bis $2, $2, $7
973 addq $23, $7, $23
974 stq $23, 24($16)
975 ldq $4, 32($17)
976 ldq $5, 0($18)
977 cmpult $23, $7, $3
978 zapnot $4, 15, $7
979 srl $5, 32, $8
980 mulq $8, $7, $28
981 srl $0, 32, $1
982 cmpult $2, $25, $2
983 addq $6, $1, $6
984 addq $2, $6, $6
985 addq $3, $6, $6
986 addq $22, $6, $22
987 cmpult $22, $6, $1
988 srl $4, 32, $6
989 zapnot $5, 15, $5
990 mulq $5, $6, $23
991 mulq $7, $5, $2
992 addq $1, $24, $24
993 addq $28, $23, $28
994 cmpult $28, $23, $1
995 mulq $6, $8, $6
996 beq $1, $213
997 sll $20, 32, $1
998 addq $6, $1, $6
999$213:
1000 sll $28, 32, $23
1001 ldq $1, 8($18)
1002 addq $2, $23, $2
1003 bis $2, $2, $7
1004 ldq $4, 24($17)
1005 addq $22, $7, $22
1006 srl $1, 32, $8
1007 cmpult $22, $7, $3
1008 zapnot $4, 15, $7
1009 mulq $8, $7, $25
1010 zapnot $1, 15, $5
1011 mulq $7, $5, $0
1012 srl $28, 32, $1
1013 cmpult $2, $23, $2
1014 addq $6, $1, $6
1015 addq $2, $6, $6
1016 addq $3, $6, $6
1017 addq $24, $6, $24
1018 cmpult $24, $6, $23
1019 srl $4, 32, $6
1020 mulq $5, $6, $5
1021 bis $31, 1, $21
1022 addq $25, $5, $25
1023 cmpult $25, $5, $1
1024 mulq $6, $8, $6
1025 beq $1, $217
1026 sll $21, 32, $1
1027 addq $6, $1, $6
1028$217:
1029 sll $25, 32, $5
1030 ldq $2, 16($18)
1031 addq $0, $5, $0
1032 bis $0, $0, $7
1033 ldq $4, 16($17)
1034 addq $22, $7, $22
1035 srl $2, 32, $8
1036 cmpult $22, $7, $3
1037 zapnot $4, 15, $7
1038 mulq $8, $7, $28
1039 srl $25, 32, $1
1040 addq $6, $1, $6
1041 cmpult $0, $5, $1
1042 zapnot $2, 15, $5
1043 addq $1, $6, $6
1044 addq $3, $6, $6
1045 addq $24, $6, $24
1046 cmpult $24, $6, $1
1047 srl $4, 32, $6
1048 mulq $5, $6, $25
1049 mulq $7, $5, $5
1050 addq $1, $23, $23
1051 addq $28, $25, $28
1052 cmpult $28, $25, $1
1053 mulq $6, $8, $6
1054 beq $1, $221
1055 sll $21, 32, $1
1056 addq $6, $1, $6
1057$221:
1058 sll $28, 32, $25
1059 ldq $2, 24($18)
1060 addq $5, $25, $5
1061 bis $5, $5, $7
1062 ldq $4, 8($17)
1063 addq $22, $7, $22
1064 srl $2, 32, $8
1065 cmpult $22, $7, $3
1066 zapnot $4, 15, $7
1067 mulq $8, $7, $0
1068 srl $28, 32, $1
1069 addq $6, $1, $6
1070 cmpult $5, $25, $1
1071 zapnot $2, 15, $5
1072 addq $1, $6, $6
1073 addq $3, $6, $6
1074 addq $24, $6, $24
1075 cmpult $24, $6, $1
1076 srl $4, 32, $6
1077 mulq $5, $6, $25
1078 mulq $7, $5, $5
1079 addq $1, $23, $23
1080 addq $0, $25, $0
1081 cmpult $0, $25, $1
1082 mulq $6, $8, $6
1083 beq $1, $225
1084 sll $21, 32, $1
1085 addq $6, $1, $6
1086$225:
1087 sll $0, 32, $25
1088 ldq $2, 32($18)
1089 addq $5, $25, $5
1090 bis $5, $5, $7
1091 ldq $4, 0($17)
1092 addq $22, $7, $22
1093 srl $2, 32, $8
1094 cmpult $22, $7, $3
1095 zapnot $4, 15, $7
1096 mulq $8, $7, $28
1097 srl $0, 32, $1
1098 addq $6, $1, $6
1099 cmpult $5, $25, $1
1100 zapnot $2, 15, $5
1101 addq $1, $6, $6
1102 addq $3, $6, $6
1103 addq $24, $6, $24
1104 cmpult $24, $6, $1
1105 srl $4, 32, $6
1106 mulq $5, $6, $25
1107 mulq $7, $5, $2
1108 addq $1, $23, $23
1109 addq $28, $25, $28
1110 cmpult $28, $25, $1
1111 mulq $6, $8, $6
1112 beq $1, $229
1113 sll $21, 32, $1
1114 addq $6, $1, $6
1115$229:
1116 sll $28, 32, $25
1117 addq $2, $25, $2
1118 bis $2, $2, $7
1119 addq $22, $7, $22
1120 stq $22, 32($16)
1121 ldq $4, 0($17)
1122 ldq $5, 40($18)
1123 cmpult $22, $7, $3
1124 zapnot $4, 15, $7
1125 srl $5, 32, $8
1126 mulq $8, $7, $0
1127 srl $28, 32, $1
1128 cmpult $2, $25, $2
1129 addq $6, $1, $6
1130 addq $2, $6, $6
1131 addq $3, $6, $6
1132 addq $24, $6, $24
1133 cmpult $24, $6, $1
1134 srl $4, 32, $6
1135 zapnot $5, 15, $5
1136 mulq $5, $6, $22
1137 mulq $7, $5, $2
1138 addq $1, $23, $23
1139 addq $0, $22, $0
1140 cmpult $0, $22, $1
1141 mulq $6, $8, $6
1142 beq $1, $233
1143 sll $21, 32, $1
1144 addq $6, $1, $6
1145$233:
1146 sll $0, 32, $22
1147 ldq $1, 32($18)
1148 addq $2, $22, $2
1149 bis $2, $2, $7
1150 ldq $4, 8($17)
1151 addq $24, $7, $24
1152 srl $1, 32, $8
1153 cmpult $24, $7, $3
1154 zapnot $4, 15, $7
1155 mulq $8, $7, $25
1156 zapnot $1, 15, $5
1157 mulq $7, $5, $21
1158 srl $0, 32, $1
1159 cmpult $2, $22, $2
1160 addq $6, $1, $6
1161 addq $2, $6, $6
1162 addq $3, $6, $6
1163 addq $23, $6, $23
1164 cmpult $23, $6, $22
1165 srl $4, 32, $6
1166 mulq $5, $6, $5
1167 bis $31, 1, $20
1168 addq $25, $5, $25
1169 cmpult $25, $5, $1
1170 mulq $6, $8, $6
1171 beq $1, $237
1172 sll $20, 32, $1
1173 addq $6, $1, $6
1174$237:
1175 sll $25, 32, $5
1176 ldq $2, 24($18)
1177 addq $21, $5, $21
1178 bis $21, $21, $7
1179 ldq $4, 16($17)
1180 addq $24, $7, $24
1181 srl $2, 32, $8
1182 cmpult $24, $7, $3
1183 zapnot $4, 15, $7
1184 mulq $8, $7, $28
1185 srl $25, 32, $1
1186 addq $6, $1, $6
1187 cmpult $21, $5, $1
1188 zapnot $2, 15, $5
1189 addq $1, $6, $6
1190 addq $3, $6, $6
1191 addq $23, $6, $23
1192 cmpult $23, $6, $1
1193 srl $4, 32, $6
1194 mulq $5, $6, $25
1195 mulq $7, $5, $5
1196 addq $1, $22, $22
1197 addq $28, $25, $28
1198 cmpult $28, $25, $1
1199 mulq $6, $8, $6
1200 beq $1, $241
1201 sll $20, 32, $1
1202 addq $6, $1, $6
1203$241:
1204 sll $28, 32, $25
1205 ldq $2, 16($18)
1206 addq $5, $25, $5
1207 bis $5, $5, $7
1208 ldq $4, 24($17)
1209 addq $24, $7, $24
1210 srl $2, 32, $8
1211 cmpult $24, $7, $3
1212 zapnot $4, 15, $7
1213 mulq $8, $7, $0
1214 srl $28, 32, $1
1215 addq $6, $1, $6
1216 cmpult $5, $25, $1
1217 zapnot $2, 15, $5
1218 addq $1, $6, $6
1219 addq $3, $6, $6
1220 addq $23, $6, $23
1221 cmpult $23, $6, $1
1222 srl $4, 32, $6
1223 mulq $5, $6, $25
1224 mulq $7, $5, $5
1225 addq $1, $22, $22
1226 addq $0, $25, $0
1227 cmpult $0, $25, $1
1228 mulq $6, $8, $6
1229 beq $1, $245
1230 sll $20, 32, $1
1231 addq $6, $1, $6
1232$245:
1233 sll $0, 32, $25
1234 ldq $2, 8($18)
1235 addq $5, $25, $5
1236 bis $5, $5, $7
1237 ldq $4, 32($17)
1238 addq $24, $7, $24
1239 srl $2, 32, $8
1240 cmpult $24, $7, $3
1241 zapnot $4, 15, $7
1242 mulq $8, $7, $28
1243 srl $0, 32, $1
1244 addq $6, $1, $6
1245 cmpult $5, $25, $1
1246 zapnot $2, 15, $5
1247 addq $1, $6, $6
1248 addq $3, $6, $6
1249 addq $23, $6, $23
1250 cmpult $23, $6, $1
1251 srl $4, 32, $6
1252 mulq $5, $6, $25
1253 mulq $7, $5, $5
1254 addq $1, $22, $22
1255 addq $28, $25, $28
1256 cmpult $28, $25, $1
1257 mulq $6, $8, $6
1258 beq $1, $249
1259 sll $20, 32, $1
1260 addq $6, $1, $6
1261$249:
1262 sll $28, 32, $25
1263 ldq $2, 0($18)
1264 addq $5, $25, $5
1265 bis $5, $5, $7
1266 ldq $4, 40($17)
1267 addq $24, $7, $24
1268 srl $2, 32, $8
1269 cmpult $24, $7, $3
1270 zapnot $4, 15, $7
1271 mulq $8, $7, $0
1272 srl $28, 32, $1
1273 addq $6, $1, $6
1274 cmpult $5, $25, $1
1275 zapnot $2, 15, $5
1276 addq $1, $6, $6
1277 addq $3, $6, $6
1278 addq $23, $6, $23
1279 cmpult $23, $6, $1
1280 srl $4, 32, $6
1281 mulq $5, $6, $25
1282 mulq $7, $5, $2
1283 addq $1, $22, $22
1284 addq $0, $25, $0
1285 cmpult $0, $25, $1
1286 mulq $6, $8, $6
1287 beq $1, $253
1288 sll $20, 32, $1
1289 addq $6, $1, $6
1290$253:
1291 sll $0, 32, $25
1292 addq $2, $25, $2
1293 bis $2, $2, $7
1294 addq $24, $7, $24
1295 stq $24, 40($16)
1296 ldq $4, 48($17)
1297 ldq $5, 0($18)
1298 cmpult $24, $7, $3
1299 zapnot $4, 15, $7
1300 srl $5, 32, $8
1301 mulq $8, $7, $28
1302 srl $0, 32, $1
1303 cmpult $2, $25, $2
1304 addq $6, $1, $6
1305 addq $2, $6, $6
1306 addq $3, $6, $6
1307 addq $23, $6, $23
1308 cmpult $23, $6, $1
1309 srl $4, 32, $6
1310 zapnot $5, 15, $5
1311 mulq $5, $6, $24
1312 mulq $7, $5, $2
1313 addq $1, $22, $22
1314 addq $28, $24, $28
1315 cmpult $28, $24, $1
1316 mulq $6, $8, $6
1317 beq $1, $257
1318 sll $20, 32, $1
1319 addq $6, $1, $6
1320$257:
1321 sll $28, 32, $24
1322 ldq $1, 8($18)
1323 addq $2, $24, $2
1324 bis $2, $2, $7
1325 ldq $4, 40($17)
1326 addq $23, $7, $23
1327 srl $1, 32, $8
1328 cmpult $23, $7, $3
1329 zapnot $4, 15, $7
1330 mulq $8, $7, $25
1331 zapnot $1, 15, $5
1332 mulq $7, $5, $0
1333 srl $28, 32, $1
1334 cmpult $2, $24, $2
1335 addq $6, $1, $6
1336 addq $2, $6, $6
1337 addq $3, $6, $6
1338 addq $22, $6, $22
1339 cmpult $22, $6, $24
1340 srl $4, 32, $6
1341 mulq $5, $6, $5
1342 bis $31, 1, $21
1343 addq $25, $5, $25
1344 cmpult $25, $5, $1
1345 mulq $6, $8, $6
1346 beq $1, $261
1347 sll $21, 32, $1
1348 addq $6, $1, $6
1349$261:
1350 sll $25, 32, $5
1351 ldq $2, 16($18)
1352 addq $0, $5, $0
1353 bis $0, $0, $7
1354 ldq $4, 32($17)
1355 addq $23, $7, $23
1356 srl $2, 32, $8
1357 cmpult $23, $7, $3
1358 zapnot $4, 15, $7
1359 mulq $8, $7, $28
1360 srl $25, 32, $1
1361 addq $6, $1, $6
1362 cmpult $0, $5, $1
1363 zapnot $2, 15, $5
1364 addq $1, $6, $6
1365 addq $3, $6, $6
1366 addq $22, $6, $22
1367 cmpult $22, $6, $1
1368 srl $4, 32, $6
1369 mulq $5, $6, $25
1370 mulq $7, $5, $5
1371 addq $1, $24, $24
1372 addq $28, $25, $28
1373 cmpult $28, $25, $1
1374 mulq $6, $8, $6
1375 beq $1, $265
1376 sll $21, 32, $1
1377 addq $6, $1, $6
1378$265:
1379 sll $28, 32, $25
1380 ldq $2, 24($18)
1381 addq $5, $25, $5
1382 bis $5, $5, $7
1383 ldq $4, 24($17)
1384 addq $23, $7, $23
1385 srl $2, 32, $8
1386 cmpult $23, $7, $3
1387 zapnot $4, 15, $7
1388 mulq $8, $7, $0
1389 srl $28, 32, $1
1390 addq $6, $1, $6
1391 cmpult $5, $25, $1
1392 zapnot $2, 15, $5
1393 addq $1, $6, $6
1394 addq $3, $6, $6
1395 addq $22, $6, $22
1396 cmpult $22, $6, $1
1397 srl $4, 32, $6
1398 mulq $5, $6, $25
1399 mulq $7, $5, $5
1400 addq $1, $24, $24
1401 addq $0, $25, $0
1402 cmpult $0, $25, $1
1403 mulq $6, $8, $6
1404 beq $1, $269
1405 sll $21, 32, $1
1406 addq $6, $1, $6
1407$269:
1408 sll $0, 32, $25
1409 ldq $2, 32($18)
1410 addq $5, $25, $5
1411 bis $5, $5, $7
1412 ldq $4, 16($17)
1413 addq $23, $7, $23
1414 srl $2, 32, $8
1415 cmpult $23, $7, $3
1416 zapnot $4, 15, $7
1417 mulq $8, $7, $28
1418 srl $0, 32, $1
1419 addq $6, $1, $6
1420 cmpult $5, $25, $1
1421 zapnot $2, 15, $5
1422 addq $1, $6, $6
1423 addq $3, $6, $6
1424 addq $22, $6, $22
1425 cmpult $22, $6, $1
1426 srl $4, 32, $6
1427 mulq $5, $6, $25
1428 mulq $7, $5, $5
1429 addq $1, $24, $24
1430 addq $28, $25, $28
1431 cmpult $28, $25, $1
1432 mulq $6, $8, $6
1433 beq $1, $273
1434 sll $21, 32, $1
1435 addq $6, $1, $6
1436$273:
1437 sll $28, 32, $25
1438 ldq $2, 40($18)
1439 addq $5, $25, $5
1440 bis $5, $5, $7
1441 ldq $4, 8($17)
1442 addq $23, $7, $23
1443 srl $2, 32, $8
1444 cmpult $23, $7, $3
1445 zapnot $4, 15, $7
1446 mulq $8, $7, $0
1447 srl $28, 32, $1
1448 addq $6, $1, $6
1449 cmpult $5, $25, $1
1450 zapnot $2, 15, $5
1451 addq $1, $6, $6
1452 addq $3, $6, $6
1453 addq $22, $6, $22
1454 cmpult $22, $6, $1
1455 srl $4, 32, $6
1456 mulq $5, $6, $25
1457 mulq $7, $5, $5
1458 addq $1, $24, $24
1459 addq $0, $25, $0
1460 cmpult $0, $25, $1
1461 mulq $6, $8, $6
1462 beq $1, $277
1463 sll $21, 32, $1
1464 addq $6, $1, $6
1465$277:
1466 sll $0, 32, $25
1467 ldq $2, 48($18)
1468 addq $5, $25, $5
1469 bis $5, $5, $7
1470 ldq $4, 0($17)
1471 addq $23, $7, $23
1472 srl $2, 32, $8
1473 cmpult $23, $7, $3
1474 zapnot $4, 15, $7
1475 mulq $8, $7, $28
1476 srl $0, 32, $1
1477 addq $6, $1, $6
1478 cmpult $5, $25, $1
1479 zapnot $2, 15, $5
1480 addq $1, $6, $6
1481 addq $3, $6, $6
1482 addq $22, $6, $22
1483 cmpult $22, $6, $1
1484 srl $4, 32, $6
1485 mulq $5, $6, $25
1486 mulq $7, $5, $2
1487 addq $1, $24, $24
1488 addq $28, $25, $28
1489 cmpult $28, $25, $1
1490 mulq $6, $8, $6
1491 beq $1, $281
1492 sll $21, 32, $1
1493 addq $6, $1, $6
1494$281:
1495 sll $28, 32, $25
1496 addq $2, $25, $2
1497 bis $2, $2, $7
1498 addq $23, $7, $23
1499 stq $23, 48($16)
1500 ldq $4, 0($17)
1501 ldq $5, 56($18)
1502 cmpult $23, $7, $3
1503 zapnot $4, 15, $7
1504 srl $5, 32, $8
1505 mulq $8, $7, $0
1506 srl $28, 32, $1
1507 cmpult $2, $25, $2
1508 addq $6, $1, $6
1509 addq $2, $6, $6
1510 addq $3, $6, $6
1511 addq $22, $6, $22
1512 cmpult $22, $6, $1
1513 srl $4, 32, $6
1514 zapnot $5, 15, $5
1515 mulq $5, $6, $23
1516 mulq $7, $5, $2
1517 addq $1, $24, $24
1518 addq $0, $23, $0
1519 cmpult $0, $23, $1
1520 mulq $6, $8, $6
1521 beq $1, $285
1522 sll $21, 32, $1
1523 addq $6, $1, $6
1524$285:
1525 sll $0, 32, $23
1526 ldq $1, 48($18)
1527 addq $2, $23, $2
1528 bis $2, $2, $7
1529 ldq $4, 8($17)
1530 addq $22, $7, $22
1531 srl $1, 32, $8
1532 cmpult $22, $7, $3
1533 zapnot $4, 15, $7
1534 mulq $8, $7, $25
1535 zapnot $1, 15, $5
1536 mulq $7, $5, $21
1537 srl $0, 32, $1
1538 cmpult $2, $23, $2
1539 addq $6, $1, $6
1540 addq $2, $6, $6
1541 addq $3, $6, $6
1542 addq $24, $6, $24
1543 cmpult $24, $6, $23
1544 srl $4, 32, $6
1545 mulq $5, $6, $5
1546 bis $31, 1, $20
1547 addq $25, $5, $25
1548 cmpult $25, $5, $1
1549 mulq $6, $8, $6
1550 beq $1, $289
1551 sll $20, 32, $1
1552 addq $6, $1, $6
1553$289:
1554 sll $25, 32, $5
1555 ldq $2, 40($18)
1556 addq $21, $5, $21
1557 bis $21, $21, $7
1558 ldq $4, 16($17)
1559 addq $22, $7, $22
1560 srl $2, 32, $8
1561 cmpult $22, $7, $3
1562 zapnot $4, 15, $7
1563 mulq $8, $7, $28
1564 srl $25, 32, $1
1565 addq $6, $1, $6
1566 cmpult $21, $5, $1
1567 zapnot $2, 15, $5
1568 addq $1, $6, $6
1569 addq $3, $6, $6
1570 addq $24, $6, $24
1571 cmpult $24, $6, $1
1572 srl $4, 32, $6
1573 mulq $5, $6, $25
1574 mulq $7, $5, $5
1575 addq $1, $23, $23
1576 addq $28, $25, $28
1577 cmpult $28, $25, $1
1578 mulq $6, $8, $6
1579 beq $1, $293
1580 sll $20, 32, $1
1581 addq $6, $1, $6
1582$293:
1583 sll $28, 32, $25
1584 ldq $2, 32($18)
1585 addq $5, $25, $5
1586 bis $5, $5, $7
1587 ldq $4, 24($17)
1588 addq $22, $7, $22
1589 srl $2, 32, $8
1590 cmpult $22, $7, $3
1591 zapnot $4, 15, $7
1592 mulq $8, $7, $0
1593 srl $28, 32, $1
1594 addq $6, $1, $6
1595 cmpult $5, $25, $1
1596 zapnot $2, 15, $5
1597 addq $1, $6, $6
1598 addq $3, $6, $6
1599 addq $24, $6, $24
1600 cmpult $24, $6, $1
1601 srl $4, 32, $6
1602 mulq $5, $6, $25
1603 mulq $7, $5, $5
1604 addq $1, $23, $23
1605 addq $0, $25, $0
1606 cmpult $0, $25, $1
1607 mulq $6, $8, $6
1608 beq $1, $297
1609 sll $20, 32, $1
1610 addq $6, $1, $6
1611$297:
1612 sll $0, 32, $25
1613 ldq $2, 24($18)
1614 addq $5, $25, $5
1615 bis $5, $5, $7
1616 ldq $4, 32($17)
1617 addq $22, $7, $22
1618 srl $2, 32, $8
1619 cmpult $22, $7, $3
1620 zapnot $4, 15, $7
1621 mulq $8, $7, $28
1622 srl $0, 32, $1
1623 addq $6, $1, $6
1624 cmpult $5, $25, $1
1625 zapnot $2, 15, $5
1626 addq $1, $6, $6
1627 addq $3, $6, $6
1628 addq $24, $6, $24
1629 cmpult $24, $6, $1
1630 srl $4, 32, $6
1631 mulq $5, $6, $25
1632 mulq $7, $5, $5
1633 addq $1, $23, $23
1634 addq $28, $25, $28
1635 cmpult $28, $25, $1
1636 mulq $6, $8, $6
1637 beq $1, $301
1638 sll $20, 32, $1
1639 addq $6, $1, $6
1640$301:
1641 sll $28, 32, $25
1642 ldq $2, 16($18)
1643 addq $5, $25, $5
1644 bis $5, $5, $7
1645 ldq $4, 40($17)
1646 addq $22, $7, $22
1647 srl $2, 32, $8
1648 cmpult $22, $7, $3
1649 zapnot $4, 15, $7
1650 mulq $8, $7, $0
1651 srl $28, 32, $1
1652 addq $6, $1, $6
1653 cmpult $5, $25, $1
1654 zapnot $2, 15, $5
1655 addq $1, $6, $6
1656 addq $3, $6, $6
1657 addq $24, $6, $24
1658 cmpult $24, $6, $1
1659 srl $4, 32, $6
1660 mulq $5, $6, $25
1661 mulq $7, $5, $5
1662 addq $1, $23, $23
1663 addq $0, $25, $0
1664 cmpult $0, $25, $1
1665 mulq $6, $8, $6
1666 beq $1, $305
1667 sll $20, 32, $1
1668 addq $6, $1, $6
1669$305:
1670 sll $0, 32, $25
1671 ldq $2, 8($18)
1672 addq $5, $25, $5
1673 bis $5, $5, $7
1674 ldq $4, 48($17)
1675 addq $22, $7, $22
1676 srl $2, 32, $8
1677 cmpult $22, $7, $3
1678 zapnot $4, 15, $7
1679 mulq $8, $7, $28
1680 srl $0, 32, $1
1681 addq $6, $1, $6
1682 cmpult $5, $25, $1
1683 zapnot $2, 15, $5
1684 addq $1, $6, $6
1685 addq $3, $6, $6
1686 addq $24, $6, $24
1687 cmpult $24, $6, $1
1688 srl $4, 32, $6
1689 mulq $5, $6, $25
1690 mulq $7, $5, $5
1691 addq $1, $23, $23
1692 addq $28, $25, $28
1693 cmpult $28, $25, $1
1694 mulq $6, $8, $6
1695 beq $1, $309
1696 sll $20, 32, $1
1697 addq $6, $1, $6
1698$309:
1699 sll $28, 32, $25
1700 ldq $2, 0($18)
1701 addq $5, $25, $5
1702 bis $5, $5, $7
1703 ldq $4, 56($17)
1704 addq $22, $7, $22
1705 srl $2, 32, $8
1706 cmpult $22, $7, $3
1707 zapnot $4, 15, $7
1708 mulq $8, $7, $0
1709 srl $28, 32, $1
1710 addq $6, $1, $6
1711 cmpult $5, $25, $1
1712 zapnot $2, 15, $5
1713 addq $1, $6, $6
1714 addq $3, $6, $6
1715 addq $24, $6, $24
1716 cmpult $24, $6, $1
1717 srl $4, 32, $6
1718 mulq $5, $6, $25
1719 mulq $7, $5, $2
1720 addq $1, $23, $23
1721 addq $0, $25, $0
1722 cmpult $0, $25, $1
1723 mulq $6, $8, $6
1724 beq $1, $313
1725 sll $20, 32, $1
1726 addq $6, $1, $6
1727$313:
1728 sll $0, 32, $25
1729 addq $2, $25, $2
1730 bis $2, $2, $7
1731 addq $22, $7, $22
1732 stq $22, 56($16)
1733 ldq $4, 56($17)
1734 ldq $5, 8($18)
1735 cmpult $22, $7, $3
1736 zapnot $4, 15, $7
1737 srl $5, 32, $8
1738 mulq $8, $7, $28
1739 srl $0, 32, $1
1740 cmpult $2, $25, $2
1741 addq $6, $1, $6
1742 addq $2, $6, $6
1743 addq $3, $6, $6
1744 addq $24, $6, $24
1745 cmpult $24, $6, $1
1746 srl $4, 32, $6
1747 zapnot $5, 15, $5
1748 mulq $5, $6, $22
1749 mulq $7, $5, $2
1750 addq $1, $23, $23
1751 addq $28, $22, $28
1752 cmpult $28, $22, $1
1753 mulq $6, $8, $6
1754 beq $1, $317
1755 sll $20, 32, $1
1756 addq $6, $1, $6
1757$317:
1758 sll $28, 32, $22
1759 ldq $1, 16($18)
1760 addq $2, $22, $2
1761 bis $2, $2, $7
1762 ldq $4, 48($17)
1763 addq $24, $7, $24
1764 srl $1, 32, $8
1765 cmpult $24, $7, $3
1766 zapnot $4, 15, $7
1767 mulq $8, $7, $25
1768 zapnot $1, 15, $5
1769 mulq $7, $5, $0
1770 srl $28, 32, $1
1771 cmpult $2, $22, $2
1772 addq $6, $1, $6
1773 addq $2, $6, $6
1774 addq $3, $6, $6
1775 addq $23, $6, $23
1776 cmpult $23, $6, $22
1777 srl $4, 32, $6
1778 mulq $5, $6, $5
1779 bis $31, 1, $21
1780 addq $25, $5, $25
1781 cmpult $25, $5, $1
1782 mulq $6, $8, $6
1783 beq $1, $321
1784 sll $21, 32, $1
1785 addq $6, $1, $6
1786$321:
1787 sll $25, 32, $5
1788 ldq $2, 24($18)
1789 addq $0, $5, $0
1790 bis $0, $0, $7
1791 ldq $4, 40($17)
1792 addq $24, $7, $24
1793 srl $2, 32, $8
1794 cmpult $24, $7, $3
1795 zapnot $4, 15, $7
1796 mulq $8, $7, $28
1797 srl $25, 32, $1
1798 addq $6, $1, $6
1799 cmpult $0, $5, $1
1800 zapnot $2, 15, $5
1801 addq $1, $6, $6
1802 addq $3, $6, $6
1803 addq $23, $6, $23
1804 cmpult $23, $6, $1
1805 srl $4, 32, $6
1806 mulq $5, $6, $25
1807 mulq $7, $5, $5
1808 addq $1, $22, $22
1809 addq $28, $25, $28
1810 cmpult $28, $25, $1
1811 mulq $6, $8, $6
1812 beq $1, $325
1813 sll $21, 32, $1
1814 addq $6, $1, $6
1815$325:
1816 sll $28, 32, $25
1817 ldq $2, 32($18)
1818 addq $5, $25, $5
1819 bis $5, $5, $7
1820 ldq $4, 32($17)
1821 addq $24, $7, $24
1822 srl $2, 32, $8
1823 cmpult $24, $7, $3
1824 zapnot $4, 15, $7
1825 mulq $8, $7, $0
1826 srl $28, 32, $1
1827 addq $6, $1, $6
1828 cmpult $5, $25, $1
1829 zapnot $2, 15, $5
1830 addq $1, $6, $6
1831 addq $3, $6, $6
1832 addq $23, $6, $23
1833 cmpult $23, $6, $1
1834 srl $4, 32, $6
1835 mulq $5, $6, $25
1836 mulq $7, $5, $5
1837 addq $1, $22, $22
1838 addq $0, $25, $0
1839 cmpult $0, $25, $1
1840 mulq $6, $8, $6
1841 beq $1, $329
1842 sll $21, 32, $1
1843 addq $6, $1, $6
1844$329:
1845 sll $0, 32, $25
1846 ldq $2, 40($18)
1847 addq $5, $25, $5
1848 bis $5, $5, $7
1849 ldq $4, 24($17)
1850 addq $24, $7, $24
1851 srl $2, 32, $8
1852 cmpult $24, $7, $3
1853 zapnot $4, 15, $7
1854 mulq $8, $7, $28
1855 srl $0, 32, $1
1856 addq $6, $1, $6
1857 cmpult $5, $25, $1
1858 zapnot $2, 15, $5
1859 addq $1, $6, $6
1860 addq $3, $6, $6
1861 addq $23, $6, $23
1862 cmpult $23, $6, $1
1863 srl $4, 32, $6
1864 mulq $5, $6, $25
1865 mulq $7, $5, $5
1866 addq $1, $22, $22
1867 addq $28, $25, $28
1868 cmpult $28, $25, $1
1869 mulq $6, $8, $6
1870 beq $1, $333
1871 sll $21, 32, $1
1872 addq $6, $1, $6
1873$333:
1874 sll $28, 32, $25
1875 ldq $2, 48($18)
1876 addq $5, $25, $5
1877 bis $5, $5, $7
1878 ldq $4, 16($17)
1879 addq $24, $7, $24
1880 srl $2, 32, $8
1881 cmpult $24, $7, $3
1882 zapnot $4, 15, $7
1883 mulq $8, $7, $0
1884 srl $28, 32, $1
1885 addq $6, $1, $6
1886 cmpult $5, $25, $1
1887 zapnot $2, 15, $5
1888 addq $1, $6, $6
1889 addq $3, $6, $6
1890 addq $23, $6, $23
1891 cmpult $23, $6, $1
1892 srl $4, 32, $6
1893 mulq $5, $6, $25
1894 mulq $7, $5, $5
1895 addq $1, $22, $22
1896 addq $0, $25, $0
1897 cmpult $0, $25, $1
1898 mulq $6, $8, $6
1899 beq $1, $337
1900 sll $21, 32, $1
1901 addq $6, $1, $6
1902$337:
1903 sll $0, 32, $25
1904 ldq $2, 56($18)
1905 addq $5, $25, $5
1906 bis $5, $5, $7
1907 ldq $4, 8($17)
1908 addq $24, $7, $24
1909 srl $2, 32, $8
1910 cmpult $24, $7, $3
1911 zapnot $4, 15, $7
1912 mulq $8, $7, $28
1913 srl $0, 32, $1
1914 addq $6, $1, $6
1915 cmpult $5, $25, $1
1916 zapnot $2, 15, $5
1917 addq $1, $6, $6
1918 addq $3, $6, $6
1919 addq $23, $6, $23
1920 cmpult $23, $6, $1
1921 srl $4, 32, $6
1922 mulq $5, $6, $25
1923 mulq $7, $5, $2
1924 addq $1, $22, $22
1925 addq $28, $25, $28
1926 cmpult $28, $25, $1
1927 mulq $6, $8, $6
1928 beq $1, $341
1929 sll $21, 32, $1
1930 addq $6, $1, $6
1931$341:
1932 sll $28, 32, $25
1933 addq $2, $25, $2
1934 bis $2, $2, $7
1935 addq $24, $7, $24
1936 stq $24, 64($16)
1937 ldq $4, 16($17)
1938 ldq $5, 56($18)
1939 cmpult $24, $7, $3
1940 zapnot $4, 15, $7
1941 srl $5, 32, $8
1942 mulq $8, $7, $0
1943 srl $28, 32, $1
1944 cmpult $2, $25, $2
1945 addq $6, $1, $6
1946 addq $2, $6, $6
1947 addq $3, $6, $6
1948 addq $23, $6, $23
1949 cmpult $23, $6, $1
1950 srl $4, 32, $6
1951 zapnot $5, 15, $5
1952 mulq $5, $6, $24
1953 mulq $7, $5, $2
1954 addq $1, $22, $22
1955 addq $0, $24, $0
1956 cmpult $0, $24, $1
1957 mulq $6, $8, $6
1958 beq $1, $345
1959 sll $21, 32, $1
1960 addq $6, $1, $6
1961$345:
1962 sll $0, 32, $24
1963 ldq $1, 48($18)
1964 addq $2, $24, $2
1965 bis $2, $2, $7
1966 ldq $4, 24($17)
1967 addq $23, $7, $23
1968 srl $1, 32, $8
1969 cmpult $23, $7, $3
1970 zapnot $4, 15, $7
1971 mulq $8, $7, $25
1972 zapnot $1, 15, $5
1973 mulq $7, $5, $21
1974 srl $0, 32, $1
1975 cmpult $2, $24, $2
1976 addq $6, $1, $6
1977 addq $2, $6, $6
1978 addq $3, $6, $6
1979 addq $22, $6, $22
1980 cmpult $22, $6, $24
1981 srl $4, 32, $6
1982 mulq $5, $6, $5
1983 bis $31, 1, $20
1984 addq $25, $5, $25
1985 cmpult $25, $5, $1
1986 mulq $6, $8, $6
1987 beq $1, $349
1988 sll $20, 32, $1
1989 addq $6, $1, $6
1990$349:
1991 sll $25, 32, $5
1992 ldq $2, 40($18)
1993 addq $21, $5, $21
1994 bis $21, $21, $7
1995 ldq $4, 32($17)
1996 addq $23, $7, $23
1997 srl $2, 32, $8
1998 cmpult $23, $7, $3
1999 zapnot $4, 15, $7
2000 mulq $8, $7, $28
2001 srl $25, 32, $1
2002 addq $6, $1, $6
2003 cmpult $21, $5, $1
2004 zapnot $2, 15, $5
2005 addq $1, $6, $6
2006 addq $3, $6, $6
2007 addq $22, $6, $22
2008 cmpult $22, $6, $1
2009 srl $4, 32, $6
2010 mulq $5, $6, $25
2011 mulq $7, $5, $5
2012 addq $1, $24, $24
2013 addq $28, $25, $28
2014 cmpult $28, $25, $1
2015 mulq $6, $8, $6
2016 beq $1, $353
2017 sll $20, 32, $1
2018 addq $6, $1, $6
2019$353:
2020 sll $28, 32, $25
2021 ldq $2, 32($18)
2022 addq $5, $25, $5
2023 bis $5, $5, $7
2024 ldq $4, 40($17)
2025 addq $23, $7, $23
2026 srl $2, 32, $8
2027 cmpult $23, $7, $3
2028 zapnot $4, 15, $7
2029 mulq $8, $7, $0
2030 srl $28, 32, $1
2031 addq $6, $1, $6
2032 cmpult $5, $25, $1
2033 zapnot $2, 15, $5
2034 addq $1, $6, $6
2035 addq $3, $6, $6
2036 addq $22, $6, $22
2037 cmpult $22, $6, $1
2038 srl $4, 32, $6
2039 mulq $5, $6, $25
2040 mulq $7, $5, $5
2041 addq $1, $24, $24
2042 addq $0, $25, $0
2043 cmpult $0, $25, $1
2044 mulq $6, $8, $6
2045 beq $1, $357
2046 sll $20, 32, $1
2047 addq $6, $1, $6
2048$357:
2049 sll $0, 32, $25
2050 ldq $2, 24($18)
2051 addq $5, $25, $5
2052 bis $5, $5, $7
2053 ldq $4, 48($17)
2054 addq $23, $7, $23
2055 srl $2, 32, $8
2056 cmpult $23, $7, $3
2057 zapnot $4, 15, $7
2058 mulq $8, $7, $28
2059 srl $0, 32, $1
2060 addq $6, $1, $6
2061 cmpult $5, $25, $1
2062 zapnot $2, 15, $5
2063 addq $1, $6, $6
2064 addq $3, $6, $6
2065 addq $22, $6, $22
2066 cmpult $22, $6, $1
2067 srl $4, 32, $6
2068 mulq $5, $6, $25
2069 mulq $7, $5, $5
2070 addq $1, $24, $24
2071 addq $28, $25, $28
2072 cmpult $28, $25, $1
2073 mulq $6, $8, $6
2074 beq $1, $361
2075 sll $20, 32, $1
2076 addq $6, $1, $6
2077$361:
2078 sll $28, 32, $25
2079 ldq $2, 16($18)
2080 addq $5, $25, $5
2081 bis $5, $5, $7
2082 ldq $4, 56($17)
2083 addq $23, $7, $23
2084 srl $2, 32, $8
2085 cmpult $23, $7, $3
2086 zapnot $4, 15, $7
2087 mulq $8, $7, $0
2088 srl $28, 32, $1
2089 addq $6, $1, $6
2090 cmpult $5, $25, $1
2091 zapnot $2, 15, $5
2092 addq $1, $6, $6
2093 addq $3, $6, $6
2094 addq $22, $6, $22
2095 cmpult $22, $6, $1
2096 srl $4, 32, $6
2097 mulq $5, $6, $25
2098 mulq $7, $5, $2
2099 addq $1, $24, $24
2100 addq $0, $25, $0
2101 cmpult $0, $25, $1
2102 mulq $6, $8, $6
2103 beq $1, $365
2104 sll $20, 32, $1
2105 addq $6, $1, $6
2106$365:
2107 sll $0, 32, $25
2108 addq $2, $25, $2
2109 bis $2, $2, $7
2110 addq $23, $7, $23
2111 stq $23, 72($16)
2112 ldq $4, 56($17)
2113 ldq $5, 24($18)
2114 cmpult $23, $7, $3
2115 zapnot $4, 15, $7
2116 srl $5, 32, $8
2117 mulq $8, $7, $28
2118 srl $0, 32, $1
2119 cmpult $2, $25, $2
2120 addq $6, $1, $6
2121 addq $2, $6, $6
2122 addq $3, $6, $6
2123 addq $22, $6, $22
2124 cmpult $22, $6, $1
2125 srl $4, 32, $6
2126 zapnot $5, 15, $5
2127 mulq $5, $6, $23
2128 mulq $7, $5, $2
2129 addq $1, $24, $24
2130 addq $28, $23, $28
2131 cmpult $28, $23, $1
2132 mulq $6, $8, $6
2133 beq $1, $369
2134 sll $20, 32, $1
2135 addq $6, $1, $6
2136$369:
2137 sll $28, 32, $23
2138 ldq $1, 32($18)
2139 addq $2, $23, $2
2140 bis $2, $2, $7
2141 ldq $4, 48($17)
2142 addq $22, $7, $22
2143 srl $1, 32, $8
2144 cmpult $22, $7, $3
2145 zapnot $4, 15, $7
2146 mulq $8, $7, $25
2147 zapnot $1, 15, $5
2148 mulq $7, $5, $0
2149 srl $28, 32, $1
2150 cmpult $2, $23, $2
2151 addq $6, $1, $6
2152 addq $2, $6, $6
2153 addq $3, $6, $6
2154 addq $24, $6, $24
2155 cmpult $24, $6, $23
2156 srl $4, 32, $6
2157 mulq $5, $6, $5
2158 bis $31, 1, $21
2159 addq $25, $5, $25
2160 cmpult $25, $5, $1
2161 mulq $6, $8, $6
2162 beq $1, $373
2163 sll $21, 32, $1
2164 addq $6, $1, $6
2165$373:
2166 sll $25, 32, $5
2167 ldq $2, 40($18)
2168 addq $0, $5, $0
2169 bis $0, $0, $7
2170 ldq $4, 40($17)
2171 addq $22, $7, $22
2172 srl $2, 32, $8
2173 cmpult $22, $7, $3
2174 zapnot $4, 15, $7
2175 mulq $8, $7, $28
2176 srl $25, 32, $1
2177 addq $6, $1, $6
2178 cmpult $0, $5, $1
2179 zapnot $2, 15, $5
2180 addq $1, $6, $6
2181 addq $3, $6, $6
2182 addq $24, $6, $24
2183 cmpult $24, $6, $1
2184 srl $4, 32, $6
2185 mulq $5, $6, $25
2186 mulq $7, $5, $5
2187 addq $1, $23, $23
2188 addq $28, $25, $28
2189 cmpult $28, $25, $1
2190 mulq $6, $8, $6
2191 beq $1, $377
2192 sll $21, 32, $1
2193 addq $6, $1, $6
2194$377:
2195 sll $28, 32, $25
2196 ldq $2, 48($18)
2197 addq $5, $25, $5
2198 bis $5, $5, $7
2199 ldq $4, 32($17)
2200 addq $22, $7, $22
2201 srl $2, 32, $8
2202 cmpult $22, $7, $3
2203 zapnot $4, 15, $7
2204 mulq $8, $7, $0
2205 srl $28, 32, $1
2206 addq $6, $1, $6
2207 cmpult $5, $25, $1
2208 zapnot $2, 15, $5
2209 addq $1, $6, $6
2210 addq $3, $6, $6
2211 addq $24, $6, $24
2212 cmpult $24, $6, $1
2213 srl $4, 32, $6
2214 mulq $5, $6, $25
2215 mulq $7, $5, $5
2216 addq $1, $23, $23
2217 addq $0, $25, $0
2218 cmpult $0, $25, $1
2219 mulq $6, $8, $6
2220 beq $1, $381
2221 sll $21, 32, $1
2222 addq $6, $1, $6
2223$381:
2224 sll $0, 32, $25
2225 ldq $2, 56($18)
2226 addq $5, $25, $5
2227 bis $5, $5, $7
2228 ldq $4, 24($17)
2229 addq $22, $7, $22
2230 srl $2, 32, $8
2231 cmpult $22, $7, $3
2232 zapnot $4, 15, $7
2233 mulq $8, $7, $28
2234 srl $0, 32, $1
2235 addq $6, $1, $6
2236 cmpult $5, $25, $1
2237 zapnot $2, 15, $5
2238 addq $1, $6, $6
2239 addq $3, $6, $6
2240 addq $24, $6, $24
2241 cmpult $24, $6, $1
2242 srl $4, 32, $6
2243 mulq $5, $6, $25
2244 mulq $7, $5, $2
2245 addq $1, $23, $23
2246 addq $28, $25, $28
2247 cmpult $28, $25, $1
2248 mulq $6, $8, $6
2249 beq $1, $385
2250 sll $21, 32, $1
2251 addq $6, $1, $6
2252$385:
2253 sll $28, 32, $25
2254 addq $2, $25, $2
2255 bis $2, $2, $7
2256 addq $22, $7, $22
2257 stq $22, 80($16)
2258 ldq $4, 32($17)
2259 ldq $5, 56($18)
2260 cmpult $22, $7, $3
2261 zapnot $4, 15, $7
2262 srl $5, 32, $8
2263 mulq $8, $7, $0
2264 srl $28, 32, $1
2265 cmpult $2, $25, $2
2266 addq $6, $1, $6
2267 addq $2, $6, $6
2268 addq $3, $6, $6
2269 addq $24, $6, $24
2270 cmpult $24, $6, $1
2271 srl $4, 32, $6
2272 zapnot $5, 15, $5
2273 mulq $5, $6, $22
2274 mulq $7, $5, $2
2275 addq $1, $23, $23
2276 addq $0, $22, $0
2277 cmpult $0, $22, $1
2278 mulq $6, $8, $6
2279 beq $1, $389
2280 sll $21, 32, $1
2281 addq $6, $1, $6
2282$389:
2283 sll $0, 32, $22
2284 ldq $1, 48($18)
2285 addq $2, $22, $2
2286 bis $2, $2, $7
2287 ldq $4, 40($17)
2288 addq $24, $7, $24
2289 srl $1, 32, $8
2290 cmpult $24, $7, $3
2291 zapnot $4, 15, $7
2292 mulq $8, $7, $25
2293 zapnot $1, 15, $5
2294 mulq $7, $5, $21
2295 srl $0, 32, $1
2296 cmpult $2, $22, $2
2297 addq $6, $1, $6
2298 addq $2, $6, $6
2299 addq $3, $6, $6
2300 addq $23, $6, $23
2301 cmpult $23, $6, $22
2302 srl $4, 32, $6
2303 mulq $5, $6, $5
2304 bis $31, 1, $20
2305 addq $25, $5, $25
2306 cmpult $25, $5, $1
2307 mulq $6, $8, $6
2308 beq $1, $393
2309 sll $20, 32, $1
2310 addq $6, $1, $6
2311$393:
2312 sll $25, 32, $5
2313 ldq $2, 40($18)
2314 addq $21, $5, $21
2315 bis $21, $21, $7
2316 ldq $4, 48($17)
2317 addq $24, $7, $24
2318 srl $2, 32, $8
2319 cmpult $24, $7, $3
2320 zapnot $4, 15, $7
2321 mulq $8, $7, $28
2322 srl $25, 32, $1
2323 addq $6, $1, $6
2324 cmpult $21, $5, $1
2325 zapnot $2, 15, $5
2326 addq $1, $6, $6
2327 addq $3, $6, $6
2328 addq $23, $6, $23
2329 cmpult $23, $6, $1
2330 srl $4, 32, $6
2331 mulq $5, $6, $25
2332 mulq $7, $5, $5
2333 addq $1, $22, $22
2334 addq $28, $25, $28
2335 cmpult $28, $25, $1
2336 mulq $6, $8, $6
2337 beq $1, $397
2338 sll $20, 32, $1
2339 addq $6, $1, $6
2340$397:
2341 sll $28, 32, $25
2342 ldq $2, 32($18)
2343 addq $5, $25, $5
2344 bis $5, $5, $7
2345 ldq $4, 56($17)
2346 addq $24, $7, $24
2347 srl $2, 32, $8
2348 cmpult $24, $7, $3
2349 zapnot $4, 15, $7
2350 mulq $8, $7, $21
2351 srl $28, 32, $1
2352 addq $6, $1, $6
2353 cmpult $5, $25, $1
2354 zapnot $2, 15, $5
2355 addq $1, $6, $6
2356 addq $3, $6, $6
2357 addq $23, $6, $23
2358 cmpult $23, $6, $1
2359 srl $4, 32, $6
2360 mulq $5, $6, $25
2361 mulq $7, $5, $2
2362 addq $1, $22, $22
2363 addq $21, $25, $21
2364 cmpult $21, $25, $1
2365 mulq $6, $8, $6
2366 beq $1, $401
2367 sll $20, 32, $1
2368 addq $6, $1, $6
2369$401:
2370 sll $21, 32, $25
2371 addq $2, $25, $2
2372 bis $2, $2, $7
2373 addq $24, $7, $24
2374 stq $24, 88($16)
2375 ldq $4, 56($17)
2376 ldq $5, 40($18)
2377 cmpult $24, $7, $3
2378 zapnot $4, 15, $7
2379 srl $5, 32, $8
2380 mulq $8, $7, $0
2381 srl $21, 32, $1
2382 cmpult $2, $25, $2
2383 addq $6, $1, $6
2384 addq $2, $6, $6
2385 addq $3, $6, $6
2386 addq $23, $6, $23
2387 cmpult $23, $6, $1
2388 srl $4, 32, $6
2389 zapnot $5, 15, $5
2390 mulq $5, $6, $24
2391 mulq $7, $5, $5
2392 addq $1, $22, $22
2393 addq $0, $24, $0
2394 cmpult $0, $24, $1
2395 mulq $6, $8, $6
2396 beq $1, $405
2397 sll $20, 32, $1
2398 addq $6, $1, $6
2399$405:
2400 sll $0, 32, $24
2401 ldq $2, 48($18)
2402 addq $5, $24, $5
2403 bis $5, $5, $7
2404 ldq $4, 48($17)
2405 addq $23, $7, $23
2406 srl $2, 32, $8
2407 cmpult $23, $7, $3
2408 zapnot $4, 15, $7
2409 mulq $8, $7, $28
2410 srl $0, 32, $1
2411 addq $6, $1, $6
2412 cmpult $5, $24, $1
2413 zapnot $2, 15, $5
2414 addq $1, $6, $6
2415 addq $3, $6, $6
2416 addq $22, $6, $22
2417 cmpult $22, $6, $24
2418 srl $4, 32, $6
2419 mulq $5, $6, $25
2420 mulq $7, $5, $5
2421 addq $28, $25, $28
2422 cmpult $28, $25, $1
2423 mulq $6, $8, $6
2424 beq $1, $409
2425 sll $20, 32, $1
2426 addq $6, $1, $6
2427$409:
2428 sll $28, 32, $25
2429 ldq $2, 56($18)
2430 addq $5, $25, $5
2431 bis $5, $5, $7
2432 ldq $4, 40($17)
2433 addq $23, $7, $23
2434 srl $2, 32, $8
2435 cmpult $23, $7, $3
2436 zapnot $4, 15, $7
2437 mulq $8, $7, $0
2438 srl $28, 32, $1
2439 addq $6, $1, $6
2440 cmpult $5, $25, $1
2441 zapnot $2, 15, $5
2442 addq $1, $6, $6
2443 addq $3, $6, $6
2444 addq $22, $6, $22
2445 cmpult $22, $6, $1
2446 srl $4, 32, $6
2447 mulq $5, $6, $25
2448 mulq $7, $5, $2
2449 addq $1, $24, $24
2450 addq $0, $25, $0
2451 cmpult $0, $25, $1
2452 mulq $6, $8, $6
2453 beq $1, $413
2454 sll $20, 32, $1
2455 addq $6, $1, $6
2456$413:
2457 sll $0, 32, $25
2458 addq $2, $25, $2
2459 bis $2, $2, $7
2460 addq $23, $7, $23
2461 stq $23, 96($16)
2462 ldq $4, 48($17)
2463 ldq $5, 56($18)
2464 cmpult $23, $7, $3
2465 zapnot $4, 15, $7
2466 srl $5, 32, $8
2467 mulq $8, $7, $28
2468 srl $0, 32, $1
2469 cmpult $2, $25, $2
2470 addq $6, $1, $6
2471 addq $2, $6, $6
2472 addq $3, $6, $6
2473 addq $22, $6, $22
2474 cmpult $22, $6, $1
2475 srl $4, 32, $6
2476 zapnot $5, 15, $5
2477 mulq $5, $6, $23
2478 mulq $7, $5, $5
2479 addq $1, $24, $24
2480 addq $28, $23, $28
2481 cmpult $28, $23, $1
2482 mulq $6, $8, $6
2483 beq $1, $417
2484 sll $20, 32, $1
2485 addq $6, $1, $6
2486$417:
2487 sll $28, 32, $23
2488 ldq $2, 48($18)
2489 addq $5, $23, $5
2490 bis $5, $5, $7
2491 ldq $4, 56($17)
2492 addq $22, $7, $22
2493 srl $2, 32, $8
2494 cmpult $22, $7, $3
2495 zapnot $4, 15, $7
2496 mulq $8, $7, $0
2497 srl $28, 32, $1
2498 addq $6, $1, $6
2499 cmpult $5, $23, $1
2500 zapnot $2, 15, $5
2501 addq $1, $6, $6
2502 addq $3, $6, $6
2503 addq $24, $6, $24
2504 cmpult $24, $6, $23
2505 srl $4, 32, $6
2506 mulq $5, $6, $25
2507 mulq $7, $5, $2
2508 addq $0, $25, $0
2509 cmpult $0, $25, $1
2510 mulq $6, $8, $6
2511 beq $1, $421
2512 sll $20, 32, $1
2513 addq $6, $1, $6
2514$421:
2515 sll $0, 32, $25
2516 addq $2, $25, $2
2517 bis $2, $2, $7
2518 addq $22, $7, $22
2519 stq $22, 104($16)
2520 ldq $4, 56($17)
2521 ldq $5, 56($18)
2522 cmpult $22, $7, $3
2523 zapnot $4, 15, $7
2524 srl $5, 32, $8
2525 mulq $8, $7, $28
2526 srl $0, 32, $1
2527 cmpult $2, $25, $2
2528 addq $6, $1, $6
2529 addq $2, $6, $6
2530 addq $3, $6, $6
2531 addq $24, $6, $24
2532 cmpult $24, $6, $1
2533 srl $4, 32, $6
2534 zapnot $5, 15, $5
2535 mulq $5, $6, $22
2536 mulq $7, $5, $2
2537 addq $1, $23, $23
2538 addq $28, $22, $28
2539 cmpult $28, $22, $1
2540 mulq $6, $8, $3
2541 beq $1, $425
2542 sll $20, 32, $1
2543 addq $3, $1, $3
2544$425:
2545 sll $28, 32, $22
2546 srl $28, 32, $1
2547 addq $2, $22, $2
2548 addq $3, $1, $3
2549 bis $2, $2, $7
2550 addq $24, $7, $24
2551 cmpult $7, $22, $1
2552 cmpult $24, $7, $2
2553 addq $1, $3, $6
2554 addq $2, $6, $6
2555 stq $24, 112($16)
2556 addq $23, $6, $23
2557 stq $23, 120($16)
2558 ret $31, ($26), 1
2559 .end bn_mul_comba8
2560 .text
2561 .align 3
2562 .globl bn_sqr_comba4
2563 .ent bn_sqr_comba4
2564bn_sqr_comba4:
2565bn_sqr_comba4..ng:
2566 .frame $30,0,$26,0
2567 .prologue 0
2568
2569 ldq $0, 0($17)
2570 ldq $1, 8($17)
2571 ldq $2, 16($17)
2572 ldq $3, 24($17)
2573 bis $31, $31, $6
2574 mulq $0, $0, $4
2575 umulh $0, $0, $5
2576 stq $4, 0($16)
2577 bis $31, $31, $4
2578 mulq $0, $1, $7
2579 umulh $0, $1, $8
2580 cmplt $7, $31, $22
2581 cmplt $8, $31, $23
2582 addq $7, $7, $7
2583 addq $8, $8, $8
2584 addq $8, $22, $8
2585 addq $4, $23, $4
2586 addq $5, $7, $5
2587 addq $6, $8, $6
2588 cmpult $5, $7, $24
2589 cmpult $6, $8, $25
2590 addq $6, $24, $6
2591 addq $4, $25, $4
2592 stq $5, 8($16)
2593 bis $31, $31, $5
2594 mulq $1, $1, $27
2595 umulh $1, $1, $28
2596 addq $6, $27, $6
2597 addq $4, $28, $4
2598 cmpult $6, $27, $21
2599 cmpult $4, $28, $20
2600 addq $4, $21, $4
2601 addq $5, $20, $5
2602 mulq $2, $0, $19
2603 umulh $2, $0, $18
2604 cmplt $19, $31, $17
2605 cmplt $18, $31, $22
2606 addq $19, $19, $19
2607 addq $18, $18, $18
2608 addq $18, $17, $18
2609 addq $5, $22, $5
2610 addq $6, $19, $6
2611 addq $4, $18, $4
2612 cmpult $6, $19, $23
2613 cmpult $4, $18, $7
2614 addq $4, $23, $4
2615 addq $5, $7, $5
2616 stq $6, 16($16)
2617 bis $31, $31, $6
2618 mulq $3, $0, $8
2619 umulh $3, $0, $24
2620 cmplt $8, $31, $25
2621 cmplt $24, $31, $27
2622 addq $8, $8, $8
2623 addq $24, $24, $24
2624 addq $24, $25, $24
2625 addq $6, $27, $6
2626 addq $4, $8, $4
2627 addq $5, $24, $5
2628 cmpult $4, $8, $28
2629 cmpult $5, $24, $21
2630 addq $5, $28, $5
2631 addq $6, $21, $6
2632 mulq $2, $1, $20
2633 umulh $2, $1, $17
2634 cmplt $20, $31, $22
2635 cmplt $17, $31, $19
2636 addq $20, $20, $20
2637 addq $17, $17, $17
2638 addq $17, $22, $17
2639 addq $6, $19, $6
2640 addq $4, $20, $4
2641 addq $5, $17, $5
2642 cmpult $4, $20, $18
2643 cmpult $5, $17, $23
2644 addq $5, $18, $5
2645 addq $6, $23, $6
2646 stq $4, 24($16)
2647 bis $31, $31, $4
2648 mulq $2, $2, $7
2649 umulh $2, $2, $25
2650 addq $5, $7, $5
2651 addq $6, $25, $6
2652 cmpult $5, $7, $27
2653 cmpult $6, $25, $8
2654 addq $6, $27, $6
2655 addq $4, $8, $4
2656 mulq $3, $1, $24
2657 umulh $3, $1, $28
2658 cmplt $24, $31, $21
2659 cmplt $28, $31, $22
2660 addq $24, $24, $24
2661 addq $28, $28, $28
2662 addq $28, $21, $28
2663 addq $4, $22, $4
2664 addq $5, $24, $5
2665 addq $6, $28, $6
2666 cmpult $5, $24, $19
2667 cmpult $6, $28, $20
2668 addq $6, $19, $6
2669 addq $4, $20, $4
2670 stq $5, 32($16)
2671 bis $31, $31, $5
2672 mulq $3, $2, $17
2673 umulh $3, $2, $18
2674 cmplt $17, $31, $23
2675 cmplt $18, $31, $7
2676 addq $17, $17, $17
2677 addq $18, $18, $18
2678 addq $18, $23, $18
2679 addq $5, $7, $5
2680 addq $6, $17, $6
2681 addq $4, $18, $4
2682 cmpult $6, $17, $25
2683 cmpult $4, $18, $27
2684 addq $4, $25, $4
2685 addq $5, $27, $5
2686 stq $6, 40($16)
2687 bis $31, $31, $6
2688 mulq $3, $3, $8
2689 umulh $3, $3, $21
2690 addq $4, $8, $4
2691 addq $5, $21, $5
2692 cmpult $4, $8, $22
2693 cmpult $5, $21, $24
2694 addq $5, $22, $5
2695 addq $6, $24, $6
2696 stq $4, 48($16)
2697 stq $5, 56($16)
2698 ret $31,($26),1
2699 .end bn_sqr_comba4
2700 .text
2701 .align 3
2702 .globl bn_sqr_comba8
2703 .ent bn_sqr_comba8
2704bn_sqr_comba8:
2705bn_sqr_comba8..ng:
2706 .frame $30,0,$26,0
2707 .prologue 0
2708
2709 ldq $0, 0($17)
2710 ldq $1, 8($17)
2711 ldq $2, 16($17)
2712 ldq $3, 24($17)
2713 ldq $4, 32($17)
2714 ldq $5, 40($17)
2715 ldq $6, 48($17)
2716 ldq $7, 56($17)
2717 bis $31, $31, $23
2718 mulq $0, $0, $8
2719 umulh $0, $0, $22
2720 stq $8, 0($16)
2721 bis $31, $31, $8
2722 mulq $1, $0, $24
2723 umulh $1, $0, $25
2724 cmplt $24, $31, $27
2725 cmplt $25, $31, $28
2726 addq $24, $24, $24
2727 addq $25, $25, $25
2728 addq $25, $27, $25
2729 addq $8, $28, $8
2730 addq $22, $24, $22
2731 addq $23, $25, $23
2732 cmpult $22, $24, $21
2733 cmpult $23, $25, $20
2734 addq $23, $21, $23
2735 addq $8, $20, $8
2736 stq $22, 8($16)
2737 bis $31, $31, $22
2738 mulq $1, $1, $19
2739 umulh $1, $1, $18
2740 addq $23, $19, $23
2741 addq $8, $18, $8
2742 cmpult $23, $19, $17
2743 cmpult $8, $18, $27
2744 addq $8, $17, $8
2745 addq $22, $27, $22
2746 mulq $2, $0, $28
2747 umulh $2, $0, $24
2748 cmplt $28, $31, $25
2749 cmplt $24, $31, $21
2750 addq $28, $28, $28
2751 addq $24, $24, $24
2752 addq $24, $25, $24
2753 addq $22, $21, $22
2754 addq $23, $28, $23
2755 addq $8, $24, $8
2756 cmpult $23, $28, $20
2757 cmpult $8, $24, $19
2758 addq $8, $20, $8
2759 addq $22, $19, $22
2760 stq $23, 16($16)
2761 bis $31, $31, $23
2762 mulq $2, $1, $18
2763 umulh $2, $1, $17
2764 cmplt $18, $31, $27
2765 cmplt $17, $31, $25
2766 addq $18, $18, $18
2767 addq $17, $17, $17
2768 addq $17, $27, $17
2769 addq $23, $25, $23
2770 addq $8, $18, $8
2771 addq $22, $17, $22
2772 cmpult $8, $18, $21
2773 cmpult $22, $17, $28
2774 addq $22, $21, $22
2775 addq $23, $28, $23
2776 mulq $3, $0, $24
2777 umulh $3, $0, $20
2778 cmplt $24, $31, $19
2779 cmplt $20, $31, $27
2780 addq $24, $24, $24
2781 addq $20, $20, $20
2782 addq $20, $19, $20
2783 addq $23, $27, $23
2784 addq $8, $24, $8
2785 addq $22, $20, $22
2786 cmpult $8, $24, $25
2787 cmpult $22, $20, $18
2788 addq $22, $25, $22
2789 addq $23, $18, $23
2790 stq $8, 24($16)
2791 bis $31, $31, $8
2792 mulq $2, $2, $17
2793 umulh $2, $2, $21
2794 addq $22, $17, $22
2795 addq $23, $21, $23
2796 cmpult $22, $17, $28
2797 cmpult $23, $21, $19
2798 addq $23, $28, $23
2799 addq $8, $19, $8
2800 mulq $3, $1, $27
2801 umulh $3, $1, $24
2802 cmplt $27, $31, $20
2803 cmplt $24, $31, $25
2804 addq $27, $27, $27
2805 addq $24, $24, $24
2806 addq $24, $20, $24
2807 addq $8, $25, $8
2808 addq $22, $27, $22
2809 addq $23, $24, $23
2810 cmpult $22, $27, $18
2811 cmpult $23, $24, $17
2812 addq $23, $18, $23
2813 addq $8, $17, $8
2814 mulq $4, $0, $21
2815 umulh $4, $0, $28
2816 cmplt $21, $31, $19
2817 cmplt $28, $31, $20
2818 addq $21, $21, $21
2819 addq $28, $28, $28
2820 addq $28, $19, $28
2821 addq $8, $20, $8
2822 addq $22, $21, $22
2823 addq $23, $28, $23
2824 cmpult $22, $21, $25
2825 cmpult $23, $28, $27
2826 addq $23, $25, $23
2827 addq $8, $27, $8
2828 stq $22, 32($16)
2829 bis $31, $31, $22
2830 mulq $3, $2, $24
2831 umulh $3, $2, $18
2832 cmplt $24, $31, $17
2833 cmplt $18, $31, $19
2834 addq $24, $24, $24
2835 addq $18, $18, $18
2836 addq $18, $17, $18
2837 addq $22, $19, $22
2838 addq $23, $24, $23
2839 addq $8, $18, $8
2840 cmpult $23, $24, $20
2841 cmpult $8, $18, $21
2842 addq $8, $20, $8
2843 addq $22, $21, $22
2844 mulq $4, $1, $28
2845 umulh $4, $1, $25
2846 cmplt $28, $31, $27
2847 cmplt $25, $31, $17
2848 addq $28, $28, $28
2849 addq $25, $25, $25
2850 addq $25, $27, $25
2851 addq $22, $17, $22
2852 addq $23, $28, $23
2853 addq $8, $25, $8
2854 cmpult $23, $28, $19
2855 cmpult $8, $25, $24
2856 addq $8, $19, $8
2857 addq $22, $24, $22
2858 mulq $5, $0, $18
2859 umulh $5, $0, $20
2860 cmplt $18, $31, $21
2861 cmplt $20, $31, $27
2862 addq $18, $18, $18
2863 addq $20, $20, $20
2864 addq $20, $21, $20
2865 addq $22, $27, $22
2866 addq $23, $18, $23
2867 addq $8, $20, $8
2868 cmpult $23, $18, $17
2869 cmpult $8, $20, $28
2870 addq $8, $17, $8
2871 addq $22, $28, $22
2872 stq $23, 40($16)
2873 bis $31, $31, $23
2874 mulq $3, $3, $25
2875 umulh $3, $3, $19
2876 addq $8, $25, $8
2877 addq $22, $19, $22
2878 cmpult $8, $25, $24
2879 cmpult $22, $19, $21
2880 addq $22, $24, $22
2881 addq $23, $21, $23
2882 mulq $4, $2, $27
2883 umulh $4, $2, $18
2884 cmplt $27, $31, $20
2885 cmplt $18, $31, $17
2886 addq $27, $27, $27
2887 addq $18, $18, $18
2888 addq $18, $20, $18
2889 addq $23, $17, $23
2890 addq $8, $27, $8
2891 addq $22, $18, $22
2892 cmpult $8, $27, $28
2893 cmpult $22, $18, $25
2894 addq $22, $28, $22
2895 addq $23, $25, $23
2896 mulq $5, $1, $19
2897 umulh $5, $1, $24
2898 cmplt $19, $31, $21
2899 cmplt $24, $31, $20
2900 addq $19, $19, $19
2901 addq $24, $24, $24
2902 addq $24, $21, $24
2903 addq $23, $20, $23
2904 addq $8, $19, $8
2905 addq $22, $24, $22
2906 cmpult $8, $19, $17
2907 cmpult $22, $24, $27
2908 addq $22, $17, $22
2909 addq $23, $27, $23
2910 mulq $6, $0, $18
2911 umulh $6, $0, $28
2912 cmplt $18, $31, $25
2913 cmplt $28, $31, $21
2914 addq $18, $18, $18
2915 addq $28, $28, $28
2916 addq $28, $25, $28
2917 addq $23, $21, $23
2918 addq $8, $18, $8
2919 addq $22, $28, $22
2920 cmpult $8, $18, $20
2921 cmpult $22, $28, $19
2922 addq $22, $20, $22
2923 addq $23, $19, $23
2924 stq $8, 48($16)
2925 bis $31, $31, $8
2926 mulq $4, $3, $24
2927 umulh $4, $3, $17
2928 cmplt $24, $31, $27
2929 cmplt $17, $31, $25
2930 addq $24, $24, $24
2931 addq $17, $17, $17
2932 addq $17, $27, $17
2933 addq $8, $25, $8
2934 addq $22, $24, $22
2935 addq $23, $17, $23
2936 cmpult $22, $24, $21
2937 cmpult $23, $17, $18
2938 addq $23, $21, $23
2939 addq $8, $18, $8
2940 mulq $5, $2, $28
2941 umulh $5, $2, $20
2942 cmplt $28, $31, $19
2943 cmplt $20, $31, $27
2944 addq $28, $28, $28
2945 addq $20, $20, $20
2946 addq $20, $19, $20
2947 addq $8, $27, $8
2948 addq $22, $28, $22
2949 addq $23, $20, $23
2950 cmpult $22, $28, $25
2951 cmpult $23, $20, $24
2952 addq $23, $25, $23
2953 addq $8, $24, $8
2954 mulq $6, $1, $17
2955 umulh $6, $1, $21
2956 cmplt $17, $31, $18
2957 cmplt $21, $31, $19
2958 addq $17, $17, $17
2959 addq $21, $21, $21
2960 addq $21, $18, $21
2961 addq $8, $19, $8
2962 addq $22, $17, $22
2963 addq $23, $21, $23
2964 cmpult $22, $17, $27
2965 cmpult $23, $21, $28
2966 addq $23, $27, $23
2967 addq $8, $28, $8
2968 mulq $7, $0, $20
2969 umulh $7, $0, $25
2970 cmplt $20, $31, $24
2971 cmplt $25, $31, $18
2972 addq $20, $20, $20
2973 addq $25, $25, $25
2974 addq $25, $24, $25
2975 addq $8, $18, $8
2976 addq $22, $20, $22
2977 addq $23, $25, $23
2978 cmpult $22, $20, $19
2979 cmpult $23, $25, $17
2980 addq $23, $19, $23
2981 addq $8, $17, $8
2982 stq $22, 56($16)
2983 bis $31, $31, $22
2984 mulq $4, $4, $21
2985 umulh $4, $4, $27
2986 addq $23, $21, $23
2987 addq $8, $27, $8
2988 cmpult $23, $21, $28
2989 cmpult $8, $27, $24
2990 addq $8, $28, $8
2991 addq $22, $24, $22
2992 mulq $5, $3, $18
2993 umulh $5, $3, $20
2994 cmplt $18, $31, $25
2995 cmplt $20, $31, $19
2996 addq $18, $18, $18
2997 addq $20, $20, $20
2998 addq $20, $25, $20
2999 addq $22, $19, $22
3000 addq $23, $18, $23
3001 addq $8, $20, $8
3002 cmpult $23, $18, $17
3003 cmpult $8, $20, $21
3004 addq $8, $17, $8
3005 addq $22, $21, $22
3006 mulq $6, $2, $27
3007 umulh $6, $2, $28
3008 cmplt $27, $31, $24
3009 cmplt $28, $31, $25
3010 addq $27, $27, $27
3011 addq $28, $28, $28
3012 addq $28, $24, $28
3013 addq $22, $25, $22
3014 addq $23, $27, $23
3015 addq $8, $28, $8
3016 cmpult $23, $27, $19
3017 cmpult $8, $28, $18
3018 addq $8, $19, $8
3019 addq $22, $18, $22
3020 mulq $7, $1, $20
3021 umulh $7, $1, $17
3022 cmplt $20, $31, $21
3023 cmplt $17, $31, $24
3024 addq $20, $20, $20
3025 addq $17, $17, $17
3026 addq $17, $21, $17
3027 addq $22, $24, $22
3028 addq $23, $20, $23
3029 addq $8, $17, $8
3030 cmpult $23, $20, $25
3031 cmpult $8, $17, $27
3032 addq $8, $25, $8
3033 addq $22, $27, $22
3034 stq $23, 64($16)
3035 bis $31, $31, $23
3036 mulq $5, $4, $28
3037 umulh $5, $4, $19
3038 cmplt $28, $31, $18
3039 cmplt $19, $31, $21
3040 addq $28, $28, $28
3041 addq $19, $19, $19
3042 addq $19, $18, $19
3043 addq $23, $21, $23
3044 addq $8, $28, $8
3045 addq $22, $19, $22
3046 cmpult $8, $28, $24
3047 cmpult $22, $19, $20
3048 addq $22, $24, $22
3049 addq $23, $20, $23
3050 mulq $6, $3, $17
3051 umulh $6, $3, $25
3052 cmplt $17, $31, $27
3053 cmplt $25, $31, $18
3054 addq $17, $17, $17
3055 addq $25, $25, $25
3056 addq $25, $27, $25
3057 addq $23, $18, $23
3058 addq $8, $17, $8
3059 addq $22, $25, $22
3060 cmpult $8, $17, $21
3061 cmpult $22, $25, $28
3062 addq $22, $21, $22
3063 addq $23, $28, $23
3064 mulq $7, $2, $19
3065 umulh $7, $2, $24
3066 cmplt $19, $31, $20
3067 cmplt $24, $31, $27
3068 addq $19, $19, $19
3069 addq $24, $24, $24
3070 addq $24, $20, $24
3071 addq $23, $27, $23
3072 addq $8, $19, $8
3073 addq $22, $24, $22
3074 cmpult $8, $19, $18
3075 cmpult $22, $24, $17
3076 addq $22, $18, $22
3077 addq $23, $17, $23
3078 stq $8, 72($16)
3079 bis $31, $31, $8
3080 mulq $5, $5, $25
3081 umulh $5, $5, $21
3082 addq $22, $25, $22
3083 addq $23, $21, $23
3084 cmpult $22, $25, $28
3085 cmpult $23, $21, $20
3086 addq $23, $28, $23
3087 addq $8, $20, $8
3088 mulq $6, $4, $27
3089 umulh $6, $4, $19
3090 cmplt $27, $31, $24
3091 cmplt $19, $31, $18
3092 addq $27, $27, $27
3093 addq $19, $19, $19
3094 addq $19, $24, $19
3095 addq $8, $18, $8
3096 addq $22, $27, $22
3097 addq $23, $19, $23
3098 cmpult $22, $27, $17
3099 cmpult $23, $19, $25
3100 addq $23, $17, $23
3101 addq $8, $25, $8
3102 mulq $7, $3, $21
3103 umulh $7, $3, $28
3104 cmplt $21, $31, $20
3105 cmplt $28, $31, $24
3106 addq $21, $21, $21
3107 addq $28, $28, $28
3108 addq $28, $20, $28
3109 addq $8, $24, $8
3110 addq $22, $21, $22
3111 addq $23, $28, $23
3112 cmpult $22, $21, $18
3113 cmpult $23, $28, $27
3114 addq $23, $18, $23
3115 addq $8, $27, $8
3116 stq $22, 80($16)
3117 bis $31, $31, $22
3118 mulq $6, $5, $19
3119 umulh $6, $5, $17
3120 cmplt $19, $31, $25
3121 cmplt $17, $31, $20
3122 addq $19, $19, $19
3123 addq $17, $17, $17
3124 addq $17, $25, $17
3125 addq $22, $20, $22
3126 addq $23, $19, $23
3127 addq $8, $17, $8
3128 cmpult $23, $19, $24
3129 cmpult $8, $17, $21
3130 addq $8, $24, $8
3131 addq $22, $21, $22
3132 mulq $7, $4, $28
3133 umulh $7, $4, $18
3134 cmplt $28, $31, $27
3135 cmplt $18, $31, $25
3136 addq $28, $28, $28
3137 addq $18, $18, $18
3138 addq $18, $27, $18
3139 addq $22, $25, $22
3140 addq $23, $28, $23
3141 addq $8, $18, $8
3142 cmpult $23, $28, $20
3143 cmpult $8, $18, $19
3144 addq $8, $20, $8
3145 addq $22, $19, $22
3146 stq $23, 88($16)
3147 bis $31, $31, $23
3148 mulq $6, $6, $17
3149 umulh $6, $6, $24
3150 addq $8, $17, $8
3151 addq $22, $24, $22
3152 cmpult $8, $17, $21
3153 cmpult $22, $24, $27
3154 addq $22, $21, $22
3155 addq $23, $27, $23
3156 mulq $7, $5, $25
3157 umulh $7, $5, $28
3158 cmplt $25, $31, $18
3159 cmplt $28, $31, $20
3160 addq $25, $25, $25
3161 addq $28, $28, $28
3162 addq $28, $18, $28
3163 addq $23, $20, $23
3164 addq $8, $25, $8
3165 addq $22, $28, $22
3166 cmpult $8, $25, $19
3167 cmpult $22, $28, $17
3168 addq $22, $19, $22
3169 addq $23, $17, $23
3170 stq $8, 96($16)
3171 bis $31, $31, $8
3172 mulq $7, $6, $24
3173 umulh $7, $6, $21
3174 cmplt $24, $31, $27
3175 cmplt $21, $31, $18
3176 addq $24, $24, $24
3177 addq $21, $21, $21
3178 addq $21, $27, $21
3179 addq $8, $18, $8
3180 addq $22, $24, $22
3181 addq $23, $21, $23
3182 cmpult $22, $24, $20
3183 cmpult $23, $21, $25
3184 addq $23, $20, $23
3185 addq $8, $25, $8
3186 stq $22, 104($16)
3187 bis $31, $31, $22
3188 mulq $7, $7, $28
3189 umulh $7, $7, $19
3190 addq $23, $28, $23
3191 addq $8, $19, $8
3192 cmpult $23, $28, $17
3193 cmpult $8, $19, $27
3194 addq $8, $17, $8
3195 addq $22, $27, $22
3196 stq $23, 112($16)
3197 stq $8, 120($16)
3198 ret $31,($26),1
3199 .end bn_sqr_comba8
diff --git a/src/lib/libcrypto/bn/asm/alpha.s.works b/src/lib/libcrypto/bn/asm/alpha.s.works
deleted file mode 100644
index ee6c587809..0000000000
--- a/src/lib/libcrypto/bn/asm/alpha.s.works
+++ /dev/null
@@ -1,533 +0,0 @@
1
2 # DEC Alpha assember
3 # The bn_div64 is actually gcc output but the other parts are hand done.
4 # Thanks to tzeruch@ceddec.com for sending me the gcc output for
5 # bn_div64.
6 # I've gone back and re-done most of routines.
7 # The key thing to remeber for the 164 CPU is that while a
8 # multiply operation takes 8 cycles, another one can only be issued
9 # after 4 cycles have elapsed. I've done modification to help
10 # improve this. Also, normally, a ld instruction will not be available
11 # for about 3 cycles.
12 .file 1 "bn_asm.c"
13 .set noat
14gcc2_compiled.:
15__gnu_compiled_c:
16 .text
17 .align 3
18 .globl bn_mul_add_words
19 .ent bn_mul_add_words
20bn_mul_add_words:
21bn_mul_add_words..ng:
22 .frame $30,0,$26,0
23 .prologue 0
24 .align 5
25 subq $18,4,$18
26 bis $31,$31,$0
27 blt $18,$43 # if we are -1, -2, -3 or -4 goto tail code
28 ldq $20,0($17) # 1 1
29 ldq $1,0($16) # 1 1
30 .align 3
31$42:
32 mulq $20,$19,$5 # 1 2 1 ######
33 ldq $21,8($17) # 2 1
34 ldq $2,8($16) # 2 1
35 umulh $20,$19,$20 # 1 2 ######
36 ldq $27,16($17) # 3 1
37 ldq $3,16($16) # 3 1
38 mulq $21,$19,$6 # 2 2 1 ######
39 ldq $28,24($17) # 4 1
40 addq $1,$5,$1 # 1 2 2
41 ldq $4,24($16) # 4 1
42 umulh $21,$19,$21 # 2 2 ######
43 cmpult $1,$5,$22 # 1 2 3 1
44 addq $20,$22,$20 # 1 3 1
45 addq $1,$0,$1 # 1 2 3 1
46 mulq $27,$19,$7 # 3 2 1 ######
47 cmpult $1,$0,$0 # 1 2 3 2
48 addq $2,$6,$2 # 2 2 2
49 addq $20,$0,$0 # 1 3 2
50 cmpult $2,$6,$23 # 2 2 3 1
51 addq $21,$23,$21 # 2 3 1
52 umulh $27,$19,$27 # 3 2 ######
53 addq $2,$0,$2 # 2 2 3 1
54 cmpult $2,$0,$0 # 2 2 3 2
55 subq $18,4,$18
56 mulq $28,$19,$8 # 4 2 1 ######
57 addq $21,$0,$0 # 2 3 2
58 addq $3,$7,$3 # 3 2 2
59 addq $16,32,$16
60 cmpult $3,$7,$24 # 3 2 3 1
61 stq $1,-32($16) # 1 2 4
62 umulh $28,$19,$28 # 4 2 ######
63 addq $27,$24,$27 # 3 3 1
64 addq $3,$0,$3 # 3 2 3 1
65 stq $2,-24($16) # 2 2 4
66 cmpult $3,$0,$0 # 3 2 3 2
67 stq $3,-16($16) # 3 2 4
68 addq $4,$8,$4 # 4 2 2
69 addq $27,$0,$0 # 3 3 2
70 cmpult $4,$8,$25 # 4 2 3 1
71 addq $17,32,$17
72 addq $28,$25,$28 # 4 3 1
73 addq $4,$0,$4 # 4 2 3 1
74 cmpult $4,$0,$0 # 4 2 3 2
75 stq $4,-8($16) # 4 2 4
76 addq $28,$0,$0 # 4 3 2
77 blt $18,$43
78
79 ldq $20,0($17) # 1 1
80 ldq $1,0($16) # 1 1
81
82 br $42
83
84 .align 4
85$45:
86 ldq $20,0($17) # 4 1
87 ldq $1,0($16) # 4 1
88 mulq $20,$19,$5 # 4 2 1
89 subq $18,1,$18
90 addq $16,8,$16
91 addq $17,8,$17
92 umulh $20,$19,$20 # 4 2
93 addq $1,$5,$1 # 4 2 2
94 cmpult $1,$5,$22 # 4 2 3 1
95 addq $20,$22,$20 # 4 3 1
96 addq $1,$0,$1 # 4 2 3 1
97 cmpult $1,$0,$0 # 4 2 3 2
98 addq $20,$0,$0 # 4 3 2
99 stq $1,-8($16) # 4 2 4
100 bgt $18,$45
101 ret $31,($26),1 # else exit
102
103 .align 4
104$43:
105 addq $18,4,$18
106 bgt $18,$45 # goto tail code
107 ret $31,($26),1 # else exit
108
109 .end bn_mul_add_words
110 .align 3
111 .globl bn_mul_words
112 .ent bn_mul_words
113bn_mul_words:
114bn_mul_words..ng:
115 .frame $30,0,$26,0
116 .prologue 0
117 .align 5
118 subq $18,4,$18
119 bis $31,$31,$0
120 blt $18,$143 # if we are -1, -2, -3 or -4 goto tail code
121 ldq $20,0($17) # 1 1
122 .align 3
123$142:
124
125 mulq $20,$19,$5 # 1 2 1 #####
126 ldq $21,8($17) # 2 1
127 ldq $27,16($17) # 3 1
128 umulh $20,$19,$20 # 1 2 #####
129 ldq $28,24($17) # 4 1
130 mulq $21,$19,$6 # 2 2 1 #####
131 addq $5,$0,$5 # 1 2 3 1
132 subq $18,4,$18
133 cmpult $5,$0,$0 # 1 2 3 2
134 umulh $21,$19,$21 # 2 2 #####
135 addq $20,$0,$0 # 1 3 2
136 addq $17,32,$17
137 addq $6,$0,$6 # 2 2 3 1
138 mulq $27,$19,$7 # 3 2 1 #####
139 cmpult $6,$0,$0 # 2 2 3 2
140 addq $21,$0,$0 # 2 3 2
141 addq $16,32,$16
142 umulh $27,$19,$27 # 3 2 #####
143 stq $5,-32($16) # 1 2 4
144 mulq $28,$19,$8 # 4 2 1 #####
145 addq $7,$0,$7 # 3 2 3 1
146 stq $6,-24($16) # 2 2 4
147 cmpult $7,$0,$0 # 3 2 3 2
148 umulh $28,$19,$28 # 4 2 #####
149 addq $27,$0,$0 # 3 3 2
150 stq $7,-16($16) # 3 2 4
151 addq $8,$0,$8 # 4 2 3 1
152 cmpult $8,$0,$0 # 4 2 3 2
153
154 addq $28,$0,$0 # 4 3 2
155
156 stq $8,-8($16) # 4 2 4
157
158 blt $18,$143
159
160 ldq $20,0($17) # 1 1
161
162 br $142
163
164 .align 4
165$145:
166 ldq $20,0($17) # 4 1
167 mulq $20,$19,$5 # 4 2 1
168 subq $18,1,$18
169 umulh $20,$19,$20 # 4 2
170 addq $5,$0,$5 # 4 2 3 1
171 addq $16,8,$16
172 cmpult $5,$0,$0 # 4 2 3 2
173 addq $17,8,$17
174 addq $20,$0,$0 # 4 3 2
175 stq $5,-8($16) # 4 2 4
176
177 bgt $18,$145
178 ret $31,($26),1 # else exit
179
180 .align 4
181$143:
182 addq $18,4,$18
183 bgt $18,$145 # goto tail code
184 ret $31,($26),1 # else exit
185
186 .end bn_mul_words
187 .align 3
188 .globl bn_sqr_words
189 .ent bn_sqr_words
190bn_sqr_words:
191bn_sqr_words..ng:
192 .frame $30,0,$26,0
193 .prologue 0
194
195 subq $18,4,$18
196 blt $18,$543 # if we are -1, -2, -3 or -4 goto tail code
197 ldq $20,0($17) # 1 1
198 .align 3
199$542:
200 mulq $20,$20,$5 ######
201 ldq $21,8($17) # 1 1
202 subq $18,4
203 umulh $20,$20,$1 ######
204 ldq $27,16($17) # 1 1
205 mulq $21,$21,$6 ######
206 ldq $28,24($17) # 1 1
207 stq $5,0($16) # r[0]
208 umulh $21,$21,$2 ######
209 stq $1,8($16) # r[1]
210 mulq $27,$27,$7 ######
211 stq $6,16($16) # r[0]
212 umulh $27,$27,$3 ######
213 stq $2,24($16) # r[1]
214 mulq $28,$28,$8 ######
215 stq $7,32($16) # r[0]
216 umulh $28,$28,$4 ######
217 stq $3,40($16) # r[1]
218
219 addq $16,64,$16
220 addq $17,32,$17
221 stq $8,-16($16) # r[0]
222 stq $4,-8($16) # r[1]
223
224 blt $18,$543
225 ldq $20,0($17) # 1 1
226 br $542
227
228$442:
229 ldq $20,0($17) # a[0]
230 mulq $20,$20,$5 # a[0]*w low part r2
231 addq $16,16,$16
232 addq $17,8,$17
233 subq $18,1,$18
234 umulh $20,$20,$1 # a[0]*w high part r3
235 stq $5,-16($16) # r[0]
236 stq $1,-8($16) # r[1]
237
238 bgt $18,$442
239 ret $31,($26),1 # else exit
240
241 .align 4
242$543:
243 addq $18,4,$18
244 bgt $18,$442 # goto tail code
245 ret $31,($26),1 # else exit
246 .end bn_sqr_words
247
248 .align 3
249 .globl bn_add_words
250 .ent bn_add_words
251bn_add_words:
252bn_add_words..ng:
253 .frame $30,0,$26,0
254 .prologue 0
255
256 subq $19,4,$19
257 bis $31,$31,$0 # carry = 0
258 blt $19,$900
259 ldq $5,0($17) # a[0]
260 ldq $1,0($18) # b[1]
261 .align 3
262$901:
263 addq $1,$5,$1 # r=a+b;
264 ldq $6,8($17) # a[1]
265 cmpult $1,$5,$22 # did we overflow?
266 ldq $2,8($18) # b[1]
267 addq $1,$0,$1 # c+= overflow
268 ldq $7,16($17) # a[2]
269 cmpult $1,$0,$0 # overflow?
270 ldq $3,16($18) # b[2]
271 addq $0,$22,$0
272 ldq $8,24($17) # a[3]
273 addq $2,$6,$2 # r=a+b;
274 ldq $4,24($18) # b[3]
275 cmpult $2,$6,$23 # did we overflow?
276 addq $3,$7,$3 # r=a+b;
277 addq $2,$0,$2 # c+= overflow
278 cmpult $3,$7,$24 # did we overflow?
279 cmpult $2,$0,$0 # overflow?
280 addq $4,$8,$4 # r=a+b;
281 addq $0,$23,$0
282 cmpult $4,$8,$25 # did we overflow?
283 addq $3,$0,$3 # c+= overflow
284 stq $1,0($16) # r[0]=c
285 cmpult $3,$0,$0 # overflow?
286 stq $2,8($16) # r[1]=c
287 addq $0,$24,$0
288 stq $3,16($16) # r[2]=c
289 addq $4,$0,$4 # c+= overflow
290 subq $19,4,$19 # loop--
291 cmpult $4,$0,$0 # overflow?
292 addq $17,32,$17 # a++
293 addq $0,$25,$0
294 stq $4,24($16) # r[3]=c
295 addq $18,32,$18 # b++
296 addq $16,32,$16 # r++
297
298 blt $19,$900
299 ldq $5,0($17) # a[0]
300 ldq $1,0($18) # b[1]
301 br $901
302 .align 4
303$945:
304 ldq $5,0($17) # a[0]
305 ldq $1,0($18) # b[1]
306 addq $1,$5,$1 # r=a+b;
307 subq $19,1,$19 # loop--
308 addq $1,$0,$1 # c+= overflow
309 addq $17,8,$17 # a++
310 cmpult $1,$5,$22 # did we overflow?
311 cmpult $1,$0,$0 # overflow?
312 addq $18,8,$18 # b++
313 stq $1,0($16) # r[0]=c
314 addq $0,$22,$0
315 addq $16,8,$16 # r++
316
317 bgt $19,$945
318 ret $31,($26),1 # else exit
319
320$900:
321 addq $19,4,$19
322 bgt $19,$945 # goto tail code
323 ret $31,($26),1 # else exit
324 .end bn_add_words
325
326 #
327 # What follows was taken directly from the C compiler with a few
328 # hacks to redo the lables.
329 #
330.text
331 .align 3
332 .globl bn_div64
333 .ent bn_div64
334bn_div64:
335 ldgp $29,0($27)
336bn_div64..ng:
337 lda $30,-48($30)
338 .frame $30,48,$26,0
339 stq $26,0($30)
340 stq $9,8($30)
341 stq $10,16($30)
342 stq $11,24($30)
343 stq $12,32($30)
344 stq $13,40($30)
345 .mask 0x4003e00,-48
346 .prologue 1
347 bis $16,$16,$9
348 bis $17,$17,$10
349 bis $18,$18,$11
350 bis $31,$31,$13
351 bis $31,2,$12
352 bne $11,$119
353 lda $0,-1
354 br $31,$136
355 .align 4
356$119:
357 bis $11,$11,$16
358 jsr $26,BN_num_bits_word
359 ldgp $29,0($26)
360 subq $0,64,$1
361 beq $1,$120
362 bis $31,1,$1
363 sll $1,$0,$1
364 cmpule $9,$1,$1
365 bne $1,$120
366 # lda $16,_IO_stderr_
367 # lda $17,$C32
368 # bis $0,$0,$18
369 # jsr $26,fprintf
370 # ldgp $29,0($26)
371 jsr $26,abort
372 ldgp $29,0($26)
373 .align 4
374$120:
375 bis $31,64,$3
376 cmpult $9,$11,$2
377 subq $3,$0,$1
378 addl $1,$31,$0
379 subq $9,$11,$1
380 cmoveq $2,$1,$9
381 beq $0,$122
382 zapnot $0,15,$2
383 subq $3,$0,$1
384 sll $11,$2,$11
385 sll $9,$2,$3
386 srl $10,$1,$1
387 sll $10,$2,$10
388 bis $3,$1,$9
389$122:
390 srl $11,32,$5
391 zapnot $11,15,$6
392 lda $7,-1
393 .align 5
394$123:
395 srl $9,32,$1
396 subq $1,$5,$1
397 bne $1,$126
398 zapnot $7,15,$27
399 br $31,$127
400 .align 4
401$126:
402 bis $9,$9,$24
403 bis $5,$5,$25
404 divqu $24,$25,$27
405$127:
406 srl $10,32,$4
407 .align 5
408$128:
409 mulq $27,$5,$1
410 subq $9,$1,$3
411 zapnot $3,240,$1
412 bne $1,$129
413 mulq $6,$27,$2
414 sll $3,32,$1
415 addq $1,$4,$1
416 cmpule $2,$1,$2
417 bne $2,$129
418 subq $27,1,$27
419 br $31,$128
420 .align 4
421$129:
422 mulq $27,$6,$1
423 mulq $27,$5,$4
424 srl $1,32,$3
425 sll $1,32,$1
426 addq $4,$3,$4
427 cmpult $10,$1,$2
428 subq $10,$1,$10
429 addq $2,$4,$2
430 cmpult $9,$2,$1
431 bis $2,$2,$4
432 beq $1,$134
433 addq $9,$11,$9
434 subq $27,1,$27
435$134:
436 subl $12,1,$12
437 subq $9,$4,$9
438 beq $12,$124
439 sll $27,32,$13
440 sll $9,32,$2
441 srl $10,32,$1
442 sll $10,32,$10
443 bis $2,$1,$9
444 br $31,$123
445 .align 4
446$124:
447 bis $13,$27,$0
448$136:
449 ldq $26,0($30)
450 ldq $9,8($30)
451 ldq $10,16($30)
452 ldq $11,24($30)
453 ldq $12,32($30)
454 ldq $13,40($30)
455 addq $30,48,$30
456 ret $31,($26),1
457 .end bn_div64
458
459 .set noat
460 .text
461 .align 3
462 .globl bn_sub_words
463 .ent bn_sub_words
464bn_sub_words:
465bn_sub_words..ng:
466 .frame $30,0,$26,0
467 .prologue 0
468
469 subq $19, 4, $19
470 bis $31, $31, $0
471 blt $19, $100
472 ldq $1, 0($17)
473 ldq $2, 0($18)
474$101:
475 ldq $3, 8($17)
476 cmpult $1, $2, $4
477 ldq $5, 8($18)
478 subq $1, $2, $1
479 ldq $6, 16($17)
480 cmpult $1, $0, $2
481 ldq $7, 16($18)
482 subq $1, $0, $23
483 ldq $8, 24($17)
484 addq $2, $4, $0
485 cmpult $3, $5, $24
486 subq $3, $5, $3
487 ldq $22, 24($18)
488 cmpult $3, $0, $5
489 subq $3, $0, $25
490 addq $5, $24, $0
491 cmpult $6, $7, $27
492 subq $6, $7, $6
493 stq $23, 0($16)
494 cmpult $6, $0, $7
495 subq $6, $0, $28
496 addq $7, $27, $0
497 cmpult $8, $22, $21
498 subq $8, $22, $8
499 stq $25, 8($16)
500 cmpult $8, $0, $22
501 subq $8, $0, $20
502 addq $22, $21, $0
503 stq $28, 16($16)
504 subq $19, 4, $19
505 stq $20, 24($16)
506 addq $17, 32, $17
507 addq $18, 32, $18
508 addq $16, 32, $16
509 blt $19, $100
510 ldq $1, 0($17)
511 ldq $2, 0($18)
512 br $101
513$102:
514 ldq $1, 0($17)
515 ldq $2, 0($18)
516 cmpult $1, $2, $27
517 subq $1, $2, $1
518 cmpult $1, $0, $2
519 subq $1, $0, $1
520 stq $1, 0($16)
521 addq $2, $27, $0
522 addq $17, 8, $17
523 addq $18, 8, $18
524 addq $16, 8, $16
525 subq $19, 1, $19
526 bgt $19, $102
527 ret $31,($26),1
528$100:
529 addq $19, 4, $19
530 bgt $19, $102
531$103:
532 ret $31,($26),1
533 .end bn_sub_words
diff --git a/src/lib/libcrypto/bn/asm/alpha.works/add.pl b/src/lib/libcrypto/bn/asm/alpha.works/add.pl
deleted file mode 100644
index 4dc76e6b69..0000000000
--- a/src/lib/libcrypto/bn/asm/alpha.works/add.pl
+++ /dev/null
@@ -1,119 +0,0 @@
1#!/usr/local/bin/perl
2# alpha assember
3
4sub bn_add_words
5 {
6 local($name)=@_;
7 local($cc,$a,$b,$r);
8
9 &init_pool(4);
10 ($cc)=GR("r0");
11
12 $rp=&wparam(0);
13 $ap=&wparam(1);
14 $bp=&wparam(2);
15 $count=&wparam(3);
16
17 &function_begin($name,"");
18
19 &comment("");
20 &sub($count,4,$count);
21 &mov("zero",$cc);
22 &br(&label("finish"));
23 &blt($count,&label("finish"));
24
25 ($a0,$b0)=&NR(2);
26 &ld($a0,&QWPw(0,$ap));
27 &ld($b0,&QWPw(0,$bp));
28
29##########################################################
30 &set_label("loop");
31
32 ($a1)=&NR(1); &ld($a1,&QWPw(1,$ap));
33 ($b1)=&NR(1); &ld($b1,&QWPw(1,$bp));
34 ($a2)=&NR(1); &ld($a2,&QWPw(2,$ap));
35 ($b2)=&NR(1); &ld($b2,&QWPw(2,$bp));
36 ($a3)=&NR(1); &ld($a3,&QWPw(3,$ap));
37 ($b3)=&NR(1); &ld($b3,&QWPw(3,$bp));
38
39 ($o0,$t0)=&NR(2);
40 &add($a0,$b0,$o0);
41 &cmpult($o0,$b0,$t0);
42 &add($o0,$cc,$o0);
43 &cmpult($o0,$cc,$cc);
44 &add($cc,$t0,$cc); &FR($t0);
45
46 ($t1,$o1)=&NR(2);
47
48 &add($a1,$b1,$o1); &FR($a1);
49 &cmpult($o1,$b1,$t1); &FR($b1);
50 &add($o1,$cc,$o1);
51 &cmpult($o1,$cc,$cc);
52 &add($cc,$t1,$cc); &FR($t1);
53
54 ($t2,$o2)=&NR(2);
55
56 &add($a2,$b2,$o2); &FR($a2);
57 &cmpult($o2,$b2,$t2); &FR($b2);
58 &add($o2,$cc,$o2);
59 &cmpult($o2,$cc,$cc);
60 &add($cc,$t2,$cc); &FR($t2);
61
62 ($t3,$o3)=&NR(2);
63
64 &add($a3,$b3,$o3); &FR($a3);
65 &cmpult($o3,$b3,$t3); &FR($b3);
66 &add($o3,$cc,$o3);
67 &cmpult($o3,$cc,$cc);
68 &add($cc,$t3,$cc); &FR($t3);
69
70 &st($o0,&QWPw(0,$rp)); &FR($o0);
71 &st($o1,&QWPw(0,$rp)); &FR($o1);
72 &st($o2,&QWPw(0,$rp)); &FR($o2);
73 &st($o3,&QWPw(0,$rp)); &FR($o3);
74
75 &sub($count,4,$count); # count-=4
76 &add($ap,4*$QWS,$ap); # count+=4
77 &add($bp,4*$QWS,$bp); # count+=4
78 &add($rp,4*$QWS,$rp); # count+=4
79
80 &blt($count,&label("finish"));
81 &ld($a0,&QWPw(0,$ap));
82 &ld($b0,&QWPw(0,$bp));
83 &br(&label("loop"));
84##################################################
85 # Do the last 0..3 words
86
87 ($t0,$o0)=&NR(2);
88 &set_label("last_loop");
89
90 &ld($a0,&QWPw(0,$ap)); # get a
91 &ld($b0,&QWPw(0,$bp)); # get b
92
93 &add($a0,$b0,$o0);
94 &cmpult($o0,$b0,$t0); # will we borrow?
95 &add($o0,$cc,$o0); # will we borrow?
96 &cmpult($o0,$cc,$cc); # will we borrow?
97 &add($cc,$t0,$cc); # add the borrows
98 &st($o0,&QWPw(0,$rp)); # save
99
100 &add($ap,$QWS,$ap);
101 &add($bp,$QWS,$bp);
102 &add($rp,$QWS,$rp);
103 &sub($count,1,$count);
104 &bgt($count,&label("last_loop"));
105 &function_end_A($name);
106
107######################################################
108 &set_label("finish");
109 &add($count,4,$count);
110 &bgt($count,&label("last_loop"));
111
112 &FR($o0,$t0,$a0,$b0);
113 &set_label("end");
114 &function_end($name);
115
116 &fin_pool;
117 }
118
1191;
diff --git a/src/lib/libcrypto/bn/asm/alpha.works/div.pl b/src/lib/libcrypto/bn/asm/alpha.works/div.pl
deleted file mode 100644
index 7ec144377f..0000000000
--- a/src/lib/libcrypto/bn/asm/alpha.works/div.pl
+++ /dev/null
@@ -1,144 +0,0 @@
1#!/usr/local/bin/perl
2
3sub bn_div64
4 {
5 local($data)=<<'EOF';
6 #
7 # What follows was taken directly from the C compiler with a few
8 # hacks to redo the lables.
9 #
10.text
11 .set noreorder
12 .set volatile
13 .align 3
14 .globl bn_div64
15 .ent bn_div64
16bn_div64:
17 ldgp $29,0($27)
18bn_div64..ng:
19 lda $30,-48($30)
20 .frame $30,48,$26,0
21 stq $26,0($30)
22 stq $9,8($30)
23 stq $10,16($30)
24 stq $11,24($30)
25 stq $12,32($30)
26 stq $13,40($30)
27 .mask 0x4003e00,-48
28 .prologue 1
29 bis $16,$16,$9
30 bis $17,$17,$10
31 bis $18,$18,$11
32 bis $31,$31,$13
33 bis $31,2,$12
34 bne $11,$9119
35 lda $0,-1
36 br $31,$9136
37 .align 4
38$9119:
39 bis $11,$11,$16
40 jsr $26,BN_num_bits_word
41 ldgp $29,0($26)
42 subq $0,64,$1
43 beq $1,$9120
44 bis $31,1,$1
45 sll $1,$0,$1
46 cmpule $9,$1,$1
47 bne $1,$9120
48 # lda $16,_IO_stderr_
49 # lda $17,$C32
50 # bis $0,$0,$18
51 # jsr $26,fprintf
52 # ldgp $29,0($26)
53 jsr $26,abort
54 ldgp $29,0($26)
55 .align 4
56$9120:
57 bis $31,64,$3
58 cmpult $9,$11,$2
59 subq $3,$0,$1
60 addl $1,$31,$0
61 subq $9,$11,$1
62 cmoveq $2,$1,$9
63 beq $0,$9122
64 zapnot $0,15,$2
65 subq $3,$0,$1
66 sll $11,$2,$11
67 sll $9,$2,$3
68 srl $10,$1,$1
69 sll $10,$2,$10
70 bis $3,$1,$9
71$9122:
72 srl $11,32,$5
73 zapnot $11,15,$6
74 lda $7,-1
75 .align 5
76$9123:
77 srl $9,32,$1
78 subq $1,$5,$1
79 bne $1,$9126
80 zapnot $7,15,$27
81 br $31,$9127
82 .align 4
83$9126:
84 bis $9,$9,$24
85 bis $5,$5,$25
86 divqu $24,$25,$27
87$9127:
88 srl $10,32,$4
89 .align 5
90$9128:
91 mulq $27,$5,$1
92 subq $9,$1,$3
93 zapnot $3,240,$1
94 bne $1,$9129
95 mulq $6,$27,$2
96 sll $3,32,$1
97 addq $1,$4,$1
98 cmpule $2,$1,$2
99 bne $2,$9129
100 subq $27,1,$27
101 br $31,$9128
102 .align 4
103$9129:
104 mulq $27,$6,$1
105 mulq $27,$5,$4
106 srl $1,32,$3
107 sll $1,32,$1
108 addq $4,$3,$4
109 cmpult $10,$1,$2
110 subq $10,$1,$10
111 addq $2,$4,$2
112 cmpult $9,$2,$1
113 bis $2,$2,$4
114 beq $1,$9134
115 addq $9,$11,$9
116 subq $27,1,$27
117$9134:
118 subl $12,1,$12
119 subq $9,$4,$9
120 beq $12,$9124
121 sll $27,32,$13
122 sll $9,32,$2
123 srl $10,32,$1
124 sll $10,32,$10
125 bis $2,$1,$9
126 br $31,$9123
127 .align 4
128$9124:
129 bis $13,$27,$0
130$9136:
131 ldq $26,0($30)
132 ldq $9,8($30)
133 ldq $10,16($30)
134 ldq $11,24($30)
135 ldq $12,32($30)
136 ldq $13,40($30)
137 addq $30,48,$30
138 ret $31,($26),1
139 .end bn_div64
140EOF
141 &asm_add($data);
142 }
143
1441;
diff --git a/src/lib/libcrypto/bn/asm/alpha.works/mul.pl b/src/lib/libcrypto/bn/asm/alpha.works/mul.pl
deleted file mode 100644
index b182bae452..0000000000
--- a/src/lib/libcrypto/bn/asm/alpha.works/mul.pl
+++ /dev/null
@@ -1,116 +0,0 @@
1#!/usr/local/bin/perl
2# alpha assember
3
4sub bn_mul_words
5 {
6 local($name)=@_;
7 local($cc,$a,$b,$r,$couny);
8
9 &init_pool(4);
10 ($cc)=GR("r0");
11
12 $rp=&wparam(0);
13 $ap=&wparam(1);
14 $count=&wparam(2);
15 $word=&wparam(3);
16
17 &function_begin($name,"");
18
19 &comment("");
20 &sub($count,4,$count);
21 &mov("zero",$cc);
22 &br(&label("finish"));
23 &blt($count,&label("finish"));
24
25 ($a0,$r0)=&NR(2);
26 &ld($a0,&QWPw(0,$ap));
27 &ld($r0,&QWPw(0,$rp));
28
29$a=<<'EOF';
30##########################################################
31 &set_label("loop");
32
33 ($a1)=&NR(1); &ld($a1,&QWPw(1,$ap));
34 ($b1)=&NR(1); &ld($b1,&QWPw(1,$bp));
35 ($a2)=&NR(1); &ld($a2,&QWPw(2,$ap));
36 ($b2)=&NR(1); &ld($b2,&QWPw(2,$bp));
37 ($a3)=&NR(1); &ld($a3,&QWPw(3,$ap));
38 ($b3)=&NR(1); &ld($b3,&QWPw(3,$bp));
39
40 ($o0,$t0)=&NR(2);
41 &add($a0,$b0,$o0);
42 &cmpult($o0,$b0,$t0);
43 &add($o0,$cc,$o0);
44 &cmpult($o0,$cc,$cc);
45 &add($cc,$t0,$cc); &FR($t0);
46
47 ($t1,$o1)=&NR(2);
48
49 &add($a1,$b1,$o1); &FR($a1);
50 &cmpult($o1,$b1,$t1); &FR($b1);
51 &add($o1,$cc,$o1);
52 &cmpult($o1,$cc,$cc);
53 &add($cc,$t1,$cc); &FR($t1);
54
55 ($t2,$o2)=&NR(2);
56
57 &add($a2,$b2,$o2); &FR($a2);
58 &cmpult($o2,$b2,$t2); &FR($b2);
59 &add($o2,$cc,$o2);
60 &cmpult($o2,$cc,$cc);
61 &add($cc,$t2,$cc); &FR($t2);
62
63 ($t3,$o3)=&NR(2);
64
65 &add($a3,$b3,$o3); &FR($a3);
66 &cmpult($o3,$b3,$t3); &FR($b3);
67 &add($o3,$cc,$o3);
68 &cmpult($o3,$cc,$cc);
69 &add($cc,$t3,$cc); &FR($t3);
70
71 &st($o0,&QWPw(0,$rp)); &FR($o0);
72 &st($o1,&QWPw(0,$rp)); &FR($o1);
73 &st($o2,&QWPw(0,$rp)); &FR($o2);
74 &st($o3,&QWPw(0,$rp)); &FR($o3);
75
76 &sub($count,4,$count); # count-=4
77 &add($ap,4*$QWS,$ap); # count+=4
78 &add($bp,4*$QWS,$bp); # count+=4
79 &add($rp,4*$QWS,$rp); # count+=4
80
81 &blt($count,&label("finish"));
82 &ld($a0,&QWPw(0,$ap));
83 &ld($b0,&QWPw(0,$bp));
84 &br(&label("loop"));
85EOF
86##################################################
87 # Do the last 0..3 words
88
89 &set_label("last_loop");
90
91 &ld(($a0)=&NR(1),&QWPw(0,$ap)); # get a
92 &mul($a0,$word,($l0)=&NR(1));
93 &add($ap,$QWS,$ap);
94 &muh($a0,$word,($h0)=&NR(1)); &FR($a0);
95 &add($l0,$cc,$l0);
96 &add($rp,$QWS,$rp);
97 &sub($count,1,$count);
98 &cmpult($l0,$cc,$cc);
99 &st($l0,&QWPw(-1,$rp)); &FR($l0);
100 &add($h0,$cc,$cc); &FR($h0);
101
102 &bgt($count,&label("last_loop"));
103 &function_end_A($name);
104
105######################################################
106 &set_label("finish");
107 &add($count,4,$count);
108 &bgt($count,&label("last_loop"));
109
110 &set_label("end");
111 &function_end($name);
112
113 &fin_pool;
114 }
115
1161;
diff --git a/src/lib/libcrypto/bn/asm/alpha.works/mul_add.pl b/src/lib/libcrypto/bn/asm/alpha.works/mul_add.pl
deleted file mode 100644
index e37f6315fb..0000000000
--- a/src/lib/libcrypto/bn/asm/alpha.works/mul_add.pl
+++ /dev/null
@@ -1,120 +0,0 @@
1#!/usr/local/bin/perl
2# alpha assember
3
4sub bn_mul_add_words
5 {
6 local($name)=@_;
7 local($cc,$a,$b,$r,$couny);
8
9 &init_pool(4);
10 ($cc)=GR("r0");
11
12 $rp=&wparam(0);
13 $ap=&wparam(1);
14 $count=&wparam(2);
15 $word=&wparam(3);
16
17 &function_begin($name,"");
18
19 &comment("");
20 &sub($count,4,$count);
21 &mov("zero",$cc);
22 &br(&label("finish"));
23 &blt($count,&label("finish"));
24
25 ($a0,$r0)=&NR(2);
26 &ld($a0,&QWPw(0,$ap));
27 &ld($r0,&QWPw(0,$rp));
28
29$a=<<'EOF';
30##########################################################
31 &set_label("loop");
32
33 ($a1)=&NR(1); &ld($a1,&QWPw(1,$ap));
34 ($b1)=&NR(1); &ld($b1,&QWPw(1,$bp));
35 ($a2)=&NR(1); &ld($a2,&QWPw(2,$ap));
36 ($b2)=&NR(1); &ld($b2,&QWPw(2,$bp));
37 ($a3)=&NR(1); &ld($a3,&QWPw(3,$ap));
38 ($b3)=&NR(1); &ld($b3,&QWPw(3,$bp));
39
40 ($o0,$t0)=&NR(2);
41 &add($a0,$b0,$o0);
42 &cmpult($o0,$b0,$t0);
43 &add($o0,$cc,$o0);
44 &cmpult($o0,$cc,$cc);
45 &add($cc,$t0,$cc); &FR($t0);
46
47 ($t1,$o1)=&NR(2);
48
49 &add($a1,$b1,$o1); &FR($a1);
50 &cmpult($o1,$b1,$t1); &FR($b1);
51 &add($o1,$cc,$o1);
52 &cmpult($o1,$cc,$cc);
53 &add($cc,$t1,$cc); &FR($t1);
54
55 ($t2,$o2)=&NR(2);
56
57 &add($a2,$b2,$o2); &FR($a2);
58 &cmpult($o2,$b2,$t2); &FR($b2);
59 &add($o2,$cc,$o2);
60 &cmpult($o2,$cc,$cc);
61 &add($cc,$t2,$cc); &FR($t2);
62
63 ($t3,$o3)=&NR(2);
64
65 &add($a3,$b3,$o3); &FR($a3);
66 &cmpult($o3,$b3,$t3); &FR($b3);
67 &add($o3,$cc,$o3);
68 &cmpult($o3,$cc,$cc);
69 &add($cc,$t3,$cc); &FR($t3);
70
71 &st($o0,&QWPw(0,$rp)); &FR($o0);
72 &st($o1,&QWPw(0,$rp)); &FR($o1);
73 &st($o2,&QWPw(0,$rp)); &FR($o2);
74 &st($o3,&QWPw(0,$rp)); &FR($o3);
75
76 &sub($count,4,$count); # count-=4
77 &add($ap,4*$QWS,$ap); # count+=4
78 &add($bp,4*$QWS,$bp); # count+=4
79 &add($rp,4*$QWS,$rp); # count+=4
80
81 &blt($count,&label("finish"));
82 &ld($a0,&QWPw(0,$ap));
83 &ld($b0,&QWPw(0,$bp));
84 &br(&label("loop"));
85EOF
86##################################################
87 # Do the last 0..3 words
88
89 &set_label("last_loop");
90
91 &ld(($a0)=&NR(1),&QWPw(0,$ap)); # get a
92 &ld(($r0)=&NR(1),&QWPw(0,$rp)); # get b
93 &mul($a0,$word,($l0)=&NR(1));
94 &sub($count,1,$count);
95 &add($ap,$QWS,$ap);
96 &muh($a0,$word,($h0)=&NR(1)); &FR($a0);
97 &add($r0,$l0,$r0);
98 &add($rp,$QWS,$rp);
99 &cmpult($r0,$l0,($t0)=&NR(1)); &FR($l0);
100 &add($r0,$cc,$r0);
101 &add($h0,$t0,$h0); &FR($t0);
102 &cmpult($r0,$cc,$cc);
103 &st($r0,&QWPw(-1,$rp)); &FR($r0);
104 &add($h0,$cc,$cc); &FR($h0);
105
106 &bgt($count,&label("last_loop"));
107 &function_end_A($name);
108
109######################################################
110 &set_label("finish");
111 &add($count,4,$count);
112 &bgt($count,&label("last_loop"));
113
114 &set_label("end");
115 &function_end($name);
116
117 &fin_pool;
118 }
119
1201;
diff --git a/src/lib/libcrypto/bn/asm/alpha.works/mul_c4.pl b/src/lib/libcrypto/bn/asm/alpha.works/mul_c4.pl
deleted file mode 100644
index 5efd201281..0000000000
--- a/src/lib/libcrypto/bn/asm/alpha.works/mul_c4.pl
+++ /dev/null
@@ -1,213 +0,0 @@
1#!/usr/local/bin/perl
2# alpha assember
3
4sub mul_add_c
5 {
6 local($a,$b,$c0,$c1,$c2)=@_;
7 local($l1,$h1,$t1,$t2);
8
9 &mul($a,$b,($l1)=&NR(1));
10 &muh($a,$b,($h1)=&NR(1));
11 &add($c0,$l1,$c0);
12 &cmpult($c0,$l1,($t1)=&NR(1)); &FR($l1);
13 &add($t1,$h1,$h1); &FR($t1);
14 &add($c1,$h1,$c1);
15 &cmpult($c1,$h1,($t2)=&NR(1)); &FR($h1);
16 &add($c2,$t2,$c2); &FR($t2);
17 }
18
19sub bn_mul_comba4
20 {
21 local($name)=@_;
22 local(@a,@b,$r,$c0,$c1,$c2);
23
24 $cnt=1;
25 &init_pool(3);
26
27 $rp=&wparam(0);
28 $ap=&wparam(1);
29 $bp=&wparam(2);
30
31 &function_begin($name,"");
32
33 &comment("");
34
35 &ld(($a[0])=&NR(1),&QWPw(0,$ap));
36 &ld(($b[0])=&NR(1),&QWPw(0,$bp));
37 &ld(($a[1])=&NR(1),&QWPw(1,$ap));
38 &ld(($b[1])=&NR(1),&QWPw(1,$bp));
39 &mul($a[0],$b[0],($r00)=&NR(1));
40 &ld(($a[2])=&NR(1),&QWPw(2,$ap));
41 &ld(($b[2])=&NR(1),&QWPw(2,$bp));
42 &muh($a[0],$b[0],($r01)=&NR(1));
43 &FR($ap); &ld(($a[3])=&NR(1),&QWPw(3,$ap));
44 &FR($bp); &ld(($b[3])=&NR(1),&QWPw(3,$bp));
45 &mul($a[0],$b[1],($r02)=&NR(1));
46
47 ($R,$H1,$H2)=&NR(3);
48
49 &st($r00,&QWPw(0,$rp)); &FR($r00);
50
51 &mov("zero",$R);
52 &mul($a[1],$b[0],($r03)=&NR(1));
53
54 &mov("zero",$H1);
55 &mov("zero",$H0);
56 &add($R,$r01,$R);
57 &muh($a[0],$b[1],($r04)=&NR(1));
58 &cmpult($R,$r01,($t01)=&NR(1)); &FR($r01);
59 &add($R,$r02,$R);
60 &add($H1,$t01,$H1) &FR($t01);
61 &muh($a[1],$b[0],($r05)=&NR(1));
62 &cmpult($R,$r02,($t02)=&NR(1)); &FR($r02);
63 &add($R,$r03,$R);
64 &add($H2,$t02,$H2) &FR($t02);
65 &mul($a[0],$b[2],($r06)=&NR(1));
66 &cmpult($R,$r03,($t03)=&NR(1)); &FR($r03);
67 &add($H1,$t03,$H1) &FR($t03);
68 &st($R,&QWPw(1,$rp));
69 &add($H1,$H2,$R);
70
71 &mov("zero",$H1);
72 &add($R,$r04,$R);
73 &mov("zero",$H2);
74 &mul($a[1],$b[1],($r07)=&NR(1));
75 &cmpult($R,$r04,($t04)=&NR(1)); &FR($r04);
76 &add($R,$r05,$R);
77 &add($H1,$t04,$H1) &FR($t04);
78 &mul($a[2],$b[0],($r08)=&NR(1));
79 &cmpult($R,$r05,($t05)=&NR(1)); &FR($r05);
80 &add($R,$r01,$R);
81 &add($H2,$t05,$H2) &FR($t05);
82 &muh($a[0],$b[2],($r09)=&NR(1));
83 &cmpult($R,$r06,($t06)=&NR(1)); &FR($r06);
84 &add($R,$r07,$R);
85 &add($H1,$t06,$H1) &FR($t06);
86 &muh($a[1],$b[1],($r10)=&NR(1));
87 &cmpult($R,$r07,($t07)=&NR(1)); &FR($r07);
88 &add($R,$r08,$R);
89 &add($H2,$t07,$H2) &FR($t07);
90 &muh($a[2],$b[0],($r11)=&NR(1));
91 &cmpult($R,$r08,($t08)=&NR(1)); &FR($r08);
92 &add($H1,$t08,$H1) &FR($t08);
93 &st($R,&QWPw(2,$rp));
94 &add($H1,$H2,$R);
95
96 &mov("zero",$H1);
97 &add($R,$r09,$R);
98 &mov("zero",$H2);
99 &mul($a[0],$b[3],($r12)=&NR(1));
100 &cmpult($R,$r09,($t09)=&NR(1)); &FR($r09);
101 &add($R,$r10,$R);
102 &add($H1,$t09,$H1) &FR($t09);
103 &mul($a[1],$b[2],($r13)=&NR(1));
104 &cmpult($R,$r10,($t10)=&NR(1)); &FR($r10);
105 &add($R,$r11,$R);
106 &add($H1,$t10,$H1) &FR($t10);
107 &mul($a[2],$b[1],($r14)=&NR(1));
108 &cmpult($R,$r11,($t11)=&NR(1)); &FR($r11);
109 &add($R,$r12,$R);
110 &add($H1,$t11,$H1) &FR($t11);
111 &mul($a[3],$b[0],($r15)=&NR(1));
112 &cmpult($R,$r12,($t12)=&NR(1)); &FR($r12);
113 &add($R,$r13,$R);
114 &add($H1,$t12,$H1) &FR($t12);
115 &muh($a[0],$b[3],($r16)=&NR(1));
116 &cmpult($R,$r13,($t13)=&NR(1)); &FR($r13);
117 &add($R,$r14,$R);
118 &add($H1,$t13,$H1) &FR($t13);
119 &muh($a[1],$b[2],($r17)=&NR(1));
120 &cmpult($R,$r14,($t14)=&NR(1)); &FR($r14);
121 &add($R,$r15,$R);
122 &add($H1,$t14,$H1) &FR($t14);
123 &muh($a[2],$b[1],($r18)=&NR(1));
124 &cmpult($R,$r15,($t15)=&NR(1)); &FR($r15);
125 &add($H1,$t15,$H1) &FR($t15);
126 &st($R,&QWPw(3,$rp));
127 &add($H1,$H2,$R);
128
129 &mov("zero",$H1);
130 &add($R,$r16,$R);
131 &mov("zero",$H2);
132 &muh($a[3],$b[0],($r19)=&NR(1));
133 &cmpult($R,$r16,($t16)=&NR(1)); &FR($r16);
134 &add($R,$r17,$R);
135 &add($H1,$t16,$H1) &FR($t16);
136 &mul($a[1],$b[3],($r20)=&NR(1));
137 &cmpult($R,$r17,($t17)=&NR(1)); &FR($r17);
138 &add($R,$r18,$R);
139 &add($H1,$t17,$H1) &FR($t17);
140 &mul($a[2],$b[2],($r21)=&NR(1));
141 &cmpult($R,$r18,($t18)=&NR(1)); &FR($r18);
142 &add($R,$r19,$R);
143 &add($H1,$t18,$H1) &FR($t18);
144 &mul($a[3],$b[1],($r22)=&NR(1));
145 &cmpult($R,$r19,($t19)=&NR(1)); &FR($r19);
146 &add($R,$r20,$R);
147 &add($H1,$t19,$H1) &FR($t19);
148 &muh($a[1],$b[3],($r23)=&NR(1));
149 &cmpult($R,$r20,($t20)=&NR(1)); &FR($r20);
150 &add($R,$r21,$R);
151 &add($H1,$t20,$H1) &FR($t20);
152 &muh($a[2],$b[2],($r24)=&NR(1));
153 &cmpult($R,$r21,($t21)=&NR(1)); &FR($r21);
154 &add($R,$r22,$R);
155 &add($H1,$t21,$H1) &FR($t21);
156 &muh($a[3],$b[1],($r25)=&NR(1));
157 &cmpult($R,$r22,($t22)=&NR(1)); &FR($r22);
158 &add($H1,$t22,$H1) &FR($t22);
159 &st($R,&QWPw(4,$rp));
160 &add($H1,$H2,$R);
161
162 &mov("zero",$H1);
163 &add($R,$r23,$R);
164 &mov("zero",$H2);
165 &mul($a[2],$b[3],($r26)=&NR(1));
166 &cmpult($R,$r23,($t23)=&NR(1)); &FR($r23);
167 &add($R,$r24,$R);
168 &add($H1,$t23,$H1) &FR($t23);
169 &mul($a[3],$b[2],($r27)=&NR(1));
170 &cmpult($R,$r24,($t24)=&NR(1)); &FR($r24);
171 &add($R,$r25,$R);
172 &add($H1,$t24,$H1) &FR($t24);
173 &muh($a[2],$b[3],($r28)=&NR(1));
174 &cmpult($R,$r25,($t25)=&NR(1)); &FR($r25);
175 &add($R,$r26,$R);
176 &add($H1,$t25,$H1) &FR($t25);
177 &muh($a[3],$b[2],($r29)=&NR(1));
178 &cmpult($R,$r26,($t26)=&NR(1)); &FR($r26);
179 &add($R,$r27,$R);
180 &add($H1,$t26,$H1) &FR($t26);
181 &mul($a[3],$b[3],($r30)=&NR(1));
182 &cmpult($R,$r27,($t27)=&NR(1)); &FR($r27);
183 &add($H1,$t27,$H1) &FR($t27);
184 &st($R,&QWPw(5,$rp));
185 &add($H1,$H2,$R);
186
187 &mov("zero",$H1);
188 &add($R,$r28,$R);
189 &mov("zero",$H2);
190 &muh($a[3],$b[3],($r31)=&NR(1));
191 &cmpult($R,$r28,($t28)=&NR(1)); &FR($r28);
192 &add($R,$r29,$R);
193 &add($H1,$t28,$H1) &FR($t28);
194 ############
195 &cmpult($R,$r29,($t29)=&NR(1)); &FR($r29);
196 &add($R,$r30,$R);
197 &add($H1,$t29,$H1) &FR($t29);
198 ############
199 &cmpult($R,$r30,($t30)=&NR(1)); &FR($r30);
200 &add($H1,$t30,$H1) &FR($t30);
201 &st($R,&QWPw(6,$rp));
202 &add($H1,$H2,$R);
203
204 &add($R,$r31,$R); &FR($r31);
205 &st($R,&QWPw(7,$rp));
206
207 &FR($R,$H1,$H2);
208 &function_end($name);
209
210 &fin_pool;
211 }
212
2131;
diff --git a/src/lib/libcrypto/bn/asm/alpha.works/mul_c4.works.pl b/src/lib/libcrypto/bn/asm/alpha.works/mul_c4.works.pl
deleted file mode 100644
index 79d86dd25c..0000000000
--- a/src/lib/libcrypto/bn/asm/alpha.works/mul_c4.works.pl
+++ /dev/null
@@ -1,98 +0,0 @@
1#!/usr/local/bin/perl
2# alpha assember
3
4sub mul_add_c
5 {
6 local($a,$b,$c0,$c1,$c2)=@_;
7 local($l1,$h1,$t1,$t2);
8
9print STDERR "count=$cnt\n"; $cnt++;
10 &mul($a,$b,($l1)=&NR(1));
11 &muh($a,$b,($h1)=&NR(1));
12 &add($c0,$l1,$c0);
13 &cmpult($c0,$l1,($t1)=&NR(1)); &FR($l1);
14 &add($t1,$h1,$h1); &FR($t1);
15 &add($c1,$h1,$c1);
16 &cmpult($c1,$h1,($t2)=&NR(1)); &FR($h1);
17 &add($c2,$t2,$c2); &FR($t2);
18 }
19
20sub bn_mul_comba4
21 {
22 local($name)=@_;
23 local(@a,@b,$r,$c0,$c1,$c2);
24
25 $cnt=1;
26 &init_pool(3);
27
28 $rp=&wparam(0);
29 $ap=&wparam(1);
30 $bp=&wparam(2);
31
32 &function_begin($name,"");
33
34 &comment("");
35
36 &ld(($a[0])=&NR(1),&QWPw(0,$ap));
37 &ld(($b[0])=&NR(1),&QWPw(0,$bp));
38 &ld(($a[1])=&NR(1),&QWPw(1,$ap));
39 &ld(($b[1])=&NR(1),&QWPw(1,$bp));
40 &ld(($a[2])=&NR(1),&QWPw(2,$ap));
41 &ld(($b[2])=&NR(1),&QWPw(2,$bp));
42 &ld(($a[3])=&NR(1),&QWPw(3,$ap)); &FR($ap);
43 &ld(($b[3])=&NR(1),&QWPw(3,$bp)); &FR($bp);
44
45 ($c0,$c1,$c2)=&NR(3);
46 &mov("zero",$c2);
47 &mul($a[0],$b[0],$c0);
48 &muh($a[0],$b[0],$c1);
49 &st($c0,&QWPw(0,$rp)); &FR($c0); ($c0)=&NR($c0);
50 ($c0,$c1,$c2)=($c1,$c2,$c0);
51 &mov("zero",$c2);
52
53 &mul_add_c($a[0],$b[1],$c0,$c1,$c2);
54 &mul_add_c($a[1],$b[0],$c0,$c1,$c2);
55 &st($c0,&QWPw(1,$rp)); &FR($c0); ($c0)=&NR($c0);
56 ($c0,$c1,$c2)=($c1,$c2,$c0);
57 &mov("zero",$c2);
58
59 &mul_add_c($a[1],$b[1],$c0,$c1,$c2);
60 &mul_add_c($a[0],$b[2],$c0,$c1,$c2);
61 &mul_add_c($a[2],$b[0],$c0,$c1,$c2);
62 &st($c0,&QWPw(2,$rp)); &FR($c0); ($c0)=&NR($c0);
63 ($c0,$c1,$c2)=($c1,$c2,$c0);
64 &mov("zero",$c2);
65
66 &mul_add_c($a[0],$b[3],$c0,$c1,$c2); &FR($a[0]);
67 &mul_add_c($a[1],$b[2],$c0,$c1,$c2);
68 &mul_add_c($a[2],$b[1],$c0,$c1,$c2);
69 &mul_add_c($a[3],$b[0],$c0,$c1,$c2); &FR($b[0]);
70 &st($c0,&QWPw(3,$rp)); &FR($c0); ($c0)=&NR($c0);
71 ($c0,$c1,$c2)=($c1,$c2,$c0);
72 &mov("zero",$c2);
73
74 &mul_add_c($a[1],$b[3],$c0,$c1,$c2); &FR($a[1]);
75 &mul_add_c($a[2],$b[2],$c0,$c1,$c2);
76 &mul_add_c($a[3],$b[1],$c0,$c1,$c2); &FR($b[1]);
77 &st($c0,&QWPw(4,$rp)); &FR($c0); ($c0)=&NR($c0);
78 ($c0,$c1,$c2)=($c1,$c2,$c0);
79 &mov("zero",$c2);
80
81 &mul_add_c($a[2],$b[3],$c0,$c1,$c2); &FR($a[2]);
82 &mul_add_c($a[3],$b[2],$c0,$c1,$c2); &FR($b[2]);
83 &st($c0,&QWPw(5,$rp)); &FR($c0); ($c0)=&NR($c0);
84 ($c0,$c1,$c2)=($c1,$c2,$c0);
85 &mov("zero",$c2);
86
87 &mul_add_c($a[3],$b[3],$c0,$c1,$c2); &FR($a[3],$b[3]);
88 &st($c0,&QWPw(6,$rp));
89 &st($c1,&QWPw(7,$rp));
90
91 &FR($c0,$c1,$c2);
92
93 &function_end($name);
94
95 &fin_pool;
96 }
97
981;
diff --git a/src/lib/libcrypto/bn/asm/alpha.works/mul_c8.pl b/src/lib/libcrypto/bn/asm/alpha.works/mul_c8.pl
deleted file mode 100644
index 525ca7494b..0000000000
--- a/src/lib/libcrypto/bn/asm/alpha.works/mul_c8.pl
+++ /dev/null
@@ -1,177 +0,0 @@
1#!/usr/local/bin/perl
2# alpha assember
3
4sub bn_mul_comba8
5 {
6 local($name)=@_;
7 local(@a,@b,$r,$c0,$c1,$c2);
8
9 $cnt=1;
10 &init_pool(3);
11
12 $rp=&wparam(0);
13 $ap=&wparam(1);
14 $bp=&wparam(2);
15
16 &function_begin($name,"");
17
18 &comment("");
19
20 &stack_push(2);
21 &ld(($a[0])=&NR(1),&QWPw(0,$ap));
22 &ld(($b[0])=&NR(1),&QWPw(0,$bp));
23 &st($reg_s0,&swtmp(0)); &FR($reg_s0);
24 &st($reg_s1,&swtmp(1)); &FR($reg_s1);
25 &ld(($a[1])=&NR(1),&QWPw(1,$ap));
26 &ld(($b[1])=&NR(1),&QWPw(1,$bp));
27 &ld(($a[2])=&NR(1),&QWPw(2,$ap));
28 &ld(($b[2])=&NR(1),&QWPw(2,$bp));
29 &ld(($a[3])=&NR(1),&QWPw(3,$ap));
30 &ld(($b[3])=&NR(1),&QWPw(3,$bp));
31 &ld(($a[4])=&NR(1),&QWPw(1,$ap));
32 &ld(($b[4])=&NR(1),&QWPw(1,$bp));
33 &ld(($a[5])=&NR(1),&QWPw(1,$ap));
34 &ld(($b[5])=&NR(1),&QWPw(1,$bp));
35 &ld(($a[6])=&NR(1),&QWPw(1,$ap));
36 &ld(($b[6])=&NR(1),&QWPw(1,$bp));
37 &ld(($a[7])=&NR(1),&QWPw(1,$ap)); &FR($ap);
38 &ld(($b[7])=&NR(1),&QWPw(1,$bp)); &FR($bp);
39
40 ($c0,$c1,$c2)=&NR(3);
41 &mov("zero",$c2);
42 &mul($a[0],$b[0],$c0);
43 &muh($a[0],$b[0],$c1);
44 &st($c0,&QWPw(0,$rp)); &FR($c0); ($c0)=&NR(1);
45 ($c0,$c1,$c2)=($c1,$c2,$c0);
46 &mov("zero",$c2);
47
48 &mul_add_c($a[0],$b[1],$c0,$c1,$c2);
49 &mul_add_c($a[1],$b[0],$c0,$c1,$c2);
50 &st($c0,&QWPw(1,$rp)); &FR($c0); ($c0)=&NR(1);
51 ($c0,$c1,$c2)=($c1,$c2,$c0);
52 &mov("zero",$c2);
53
54 &mul_add_c($a[0],$b[2],$c0,$c1,$c2);
55 &mul_add_c($a[1],$b[1],$c0,$c1,$c2);
56 &mul_add_c($a[2],$b[0],$c0,$c1,$c2);
57 &st($c0,&QWPw(2,$rp)); &FR($c0); ($c0)=&NR(1);
58 ($c0,$c1,$c2)=($c1,$c2,$c0);
59 &mov("zero",$c2);
60
61 &mul_add_c($a[0],$b[3],$c0,$c1,$c2);
62 &mul_add_c($a[1],$b[2],$c0,$c1,$c2);
63 &mul_add_c($a[2],$b[1],$c0,$c1,$c2);
64 &mul_add_c($a[3],$b[0],$c0,$c1,$c2);
65 &st($c0,&QWPw(3,$rp)); &FR($c0); ($c0)=&NR(1);
66 ($c0,$c1,$c2)=($c1,$c2,$c0);
67 &mov("zero",$c2);
68
69 &mul_add_c($a[0],$b[4],$c0,$c1,$c2);
70 &mul_add_c($a[1],$b[3],$c0,$c1,$c2);
71 &mul_add_c($a[2],$b[2],$c0,$c1,$c2);
72 &mul_add_c($a[3],$b[1],$c0,$c1,$c2);
73 &mul_add_c($a[4],$b[0],$c0,$c1,$c2);
74 &st($c0,&QWPw(4,$rp)); &FR($c0); ($c0)=&NR(1);
75 ($c0,$c1,$c2)=($c1,$c2,$c0);
76 &mov("zero",$c2);
77
78 &mul_add_c($a[0],$b[5],$c0,$c1,$c2);
79 &mul_add_c($a[1],$b[4],$c0,$c1,$c2);
80 &mul_add_c($a[2],$b[3],$c0,$c1,$c2);
81 &mul_add_c($a[3],$b[2],$c0,$c1,$c2);
82 &mul_add_c($a[4],$b[1],$c0,$c1,$c2);
83 &mul_add_c($a[5],$b[0],$c0,$c1,$c2);
84 &st($c0,&QWPw(5,$rp)); &FR($c0); ($c0)=&NR(1);
85 ($c0,$c1,$c2)=($c1,$c2,$c0);
86 &mov("zero",$c2);
87
88 &mul_add_c($a[0],$b[6],$c0,$c1,$c2);
89 &mul_add_c($a[1],$b[5],$c0,$c1,$c2);
90 &mul_add_c($a[2],$b[4],$c0,$c1,$c2);
91 &mul_add_c($a[3],$b[3],$c0,$c1,$c2);
92 &mul_add_c($a[4],$b[2],$c0,$c1,$c2);
93 &mul_add_c($a[5],$b[1],$c0,$c1,$c2);
94 &mul_add_c($a[6],$b[0],$c0,$c1,$c2);
95 &st($c0,&QWPw(6,$rp)); &FR($c0); ($c0)=&NR(1);
96 ($c0,$c1,$c2)=($c1,$c2,$c0);
97 &mov("zero",$c2);
98
99 &mul_add_c($a[0],$b[7],$c0,$c1,$c2); &FR($a[0]);
100 &mul_add_c($a[1],$b[6],$c0,$c1,$c2);
101 &mul_add_c($a[2],$b[5],$c0,$c1,$c2);
102 &mul_add_c($a[3],$b[4],$c0,$c1,$c2);
103 &mul_add_c($a[4],$b[3],$c0,$c1,$c2);
104 &mul_add_c($a[5],$b[2],$c0,$c1,$c2);
105 &mul_add_c($a[6],$b[1],$c0,$c1,$c2);
106 &mul_add_c($a[7],$b[0],$c0,$c1,$c2); &FR($b[0]);
107 &st($c0,&QWPw(7,$rp)); &FR($c0); ($c0)=&NR(1);
108 ($c0,$c1,$c2)=($c1,$c2,$c0);
109 &mov("zero",$c2);
110
111 &mul_add_c($a[1],$b[7],$c0,$c1,$c2); &FR($a[1]);
112 &mul_add_c($a[2],$b[6],$c0,$c1,$c2);
113 &mul_add_c($a[3],$b[5],$c0,$c1,$c2);
114 &mul_add_c($a[4],$b[4],$c0,$c1,$c2);
115 &mul_add_c($a[5],$b[3],$c0,$c1,$c2);
116 &mul_add_c($a[6],$b[2],$c0,$c1,$c2);
117 &mul_add_c($a[7],$b[1],$c0,$c1,$c2); &FR($b[1]);
118 &st($c0,&QWPw(8,$rp)); &FR($c0); ($c0)=&NR(1);
119 ($c0,$c1,$c2)=($c1,$c2,$c0);
120 &mov("zero",$c2);
121
122 &mul_add_c($a[2],$b[7],$c0,$c1,$c2); &FR($a[2]);
123 &mul_add_c($a[3],$b[6],$c0,$c1,$c2);
124 &mul_add_c($a[4],$b[5],$c0,$c1,$c2);
125 &mul_add_c($a[5],$b[4],$c0,$c1,$c2);
126 &mul_add_c($a[6],$b[3],$c0,$c1,$c2);
127 &mul_add_c($a[7],$b[2],$c0,$c1,$c2); &FR($b[2]);
128 &st($c0,&QWPw(9,$rp)); &FR($c0); ($c0)=&NR(1);
129 ($c0,$c1,$c2)=($c1,$c2,$c0);
130 &mov("zero",$c2);
131
132 &mul_add_c($a[3],$b[7],$c0,$c1,$c2); &FR($a[3]);
133 &mul_add_c($a[4],$b[6],$c0,$c1,$c2);
134 &mul_add_c($a[5],$b[5],$c0,$c1,$c2);
135 &mul_add_c($a[6],$b[4],$c0,$c1,$c2);
136 &mul_add_c($a[7],$b[3],$c0,$c1,$c2); &FR($b[3]);
137 &st($c0,&QWPw(10,$rp)); &FR($c0); ($c0)=&NR(1);
138 ($c0,$c1,$c2)=($c1,$c2,$c0);
139 &mov("zero",$c2);
140
141 &mul_add_c($a[4],$b[7],$c0,$c1,$c2); &FR($a[4]);
142 &mul_add_c($a[5],$b[6],$c0,$c1,$c2);
143 &mul_add_c($a[6],$b[5],$c0,$c1,$c2);
144 &mul_add_c($a[7],$b[4],$c0,$c1,$c2); &FR($b[4]);
145 &st($c0,&QWPw(11,$rp)); &FR($c0); ($c0)=&NR(1);
146 ($c0,$c1,$c2)=($c1,$c2,$c0);
147 &mov("zero",$c2);
148
149 &mul_add_c($a[5],$b[7],$c0,$c1,$c2); &FR($a[5]);
150 &mul_add_c($a[6],$b[6],$c0,$c1,$c2);
151 &mul_add_c($a[7],$b[5],$c0,$c1,$c2); &FR($b[5]);
152 &st($c0,&QWPw(12,$rp)); &FR($c0); ($c0)=&NR(1);
153 ($c0,$c1,$c2)=($c1,$c2,$c0);
154 &mov("zero",$c2);
155
156 &mul_add_c($a[6],$b[7],$c0,$c1,$c2); &FR($a[6]);
157 &mul_add_c($a[7],$b[6],$c0,$c1,$c2); &FR($b[6]);
158 &st($c0,&QWPw(13,$rp)); &FR($c0); ($c0)=&NR(1);
159 ($c0,$c1,$c2)=($c1,$c2,$c0);
160 &mov("zero",$c2);
161
162 &mul_add_c($a[7],$b[7],$c0,$c1,$c2); &FR($a[7],$b[7]);
163 &st($c0,&QWPw(14,$rp));
164 &st($c1,&QWPw(15,$rp));
165
166 &FR($c0,$c1,$c2);
167
168 &ld($reg_s0,&swtmp(0));
169 &ld($reg_s1,&swtmp(1));
170 &stack_pop(2);
171
172 &function_end($name);
173
174 &fin_pool;
175 }
176
1771;
diff --git a/src/lib/libcrypto/bn/asm/alpha.works/sqr.pl b/src/lib/libcrypto/bn/asm/alpha.works/sqr.pl
deleted file mode 100644
index a55b696906..0000000000
--- a/src/lib/libcrypto/bn/asm/alpha.works/sqr.pl
+++ /dev/null
@@ -1,113 +0,0 @@
1#!/usr/local/bin/perl
2# alpha assember
3
4sub bn_sqr_words
5 {
6 local($name)=@_;
7 local($cc,$a,$b,$r,$couny);
8
9 &init_pool(3);
10 ($cc)=GR("r0");
11
12 $rp=&wparam(0);
13 $ap=&wparam(1);
14 $count=&wparam(2);
15
16 &function_begin($name,"");
17
18 &comment("");
19 &sub($count,4,$count);
20 &mov("zero",$cc);
21 &br(&label("finish"));
22 &blt($count,&label("finish"));
23
24 ($a0,$r0)=&NR(2);
25 &ld($a0,&QWPw(0,$ap));
26 &ld($r0,&QWPw(0,$rp));
27
28$a=<<'EOF';
29##########################################################
30 &set_label("loop");
31
32 ($a1)=&NR(1); &ld($a1,&QWPw(1,$ap));
33 ($b1)=&NR(1); &ld($b1,&QWPw(1,$bp));
34 ($a2)=&NR(1); &ld($a2,&QWPw(2,$ap));
35 ($b2)=&NR(1); &ld($b2,&QWPw(2,$bp));
36 ($a3)=&NR(1); &ld($a3,&QWPw(3,$ap));
37 ($b3)=&NR(1); &ld($b3,&QWPw(3,$bp));
38
39 ($o0,$t0)=&NR(2);
40 &add($a0,$b0,$o0);
41 &cmpult($o0,$b0,$t0);
42 &add($o0,$cc,$o0);
43 &cmpult($o0,$cc,$cc);
44 &add($cc,$t0,$cc); &FR($t0);
45
46 ($t1,$o1)=&NR(2);
47
48 &add($a1,$b1,$o1); &FR($a1);
49 &cmpult($o1,$b1,$t1); &FR($b1);
50 &add($o1,$cc,$o1);
51 &cmpult($o1,$cc,$cc);
52 &add($cc,$t1,$cc); &FR($t1);
53
54 ($t2,$o2)=&NR(2);
55
56 &add($a2,$b2,$o2); &FR($a2);
57 &cmpult($o2,$b2,$t2); &FR($b2);
58 &add($o2,$cc,$o2);
59 &cmpult($o2,$cc,$cc);
60 &add($cc,$t2,$cc); &FR($t2);
61
62 ($t3,$o3)=&NR(2);
63
64 &add($a3,$b3,$o3); &FR($a3);
65 &cmpult($o3,$b3,$t3); &FR($b3);
66 &add($o3,$cc,$o3);
67 &cmpult($o3,$cc,$cc);
68 &add($cc,$t3,$cc); &FR($t3);
69
70 &st($o0,&QWPw(0,$rp)); &FR($o0);
71 &st($o1,&QWPw(0,$rp)); &FR($o1);
72 &st($o2,&QWPw(0,$rp)); &FR($o2);
73 &st($o3,&QWPw(0,$rp)); &FR($o3);
74
75 &sub($count,4,$count); # count-=4
76 &add($ap,4*$QWS,$ap); # count+=4
77 &add($bp,4*$QWS,$bp); # count+=4
78 &add($rp,4*$QWS,$rp); # count+=4
79
80 &blt($count,&label("finish"));
81 &ld($a0,&QWPw(0,$ap));
82 &ld($b0,&QWPw(0,$bp));
83 &br(&label("loop"));
84EOF
85##################################################
86 # Do the last 0..3 words
87
88 &set_label("last_loop");
89
90 &ld(($a0)=&NR(1),&QWPw(0,$ap)); # get a
91 &mul($a0,$a0,($l0)=&NR(1));
92 &add($ap,$QWS,$ap);
93 &add($rp,2*$QWS,$rp);
94 &sub($count,1,$count);
95 &muh($a0,$a0,($h0)=&NR(1)); &FR($a0);
96 &st($l0,&QWPw(-2,$rp)); &FR($l0);
97 &st($h0,&QWPw(-1,$rp)); &FR($h0);
98
99 &bgt($count,&label("last_loop"));
100 &function_end_A($name);
101
102######################################################
103 &set_label("finish");
104 &add($count,4,$count);
105 &bgt($count,&label("last_loop"));
106
107 &set_label("end");
108 &function_end($name);
109
110 &fin_pool;
111 }
112
1131;
diff --git a/src/lib/libcrypto/bn/asm/alpha.works/sqr_c4.pl b/src/lib/libcrypto/bn/asm/alpha.works/sqr_c4.pl
deleted file mode 100644
index bf33f5b503..0000000000
--- a/src/lib/libcrypto/bn/asm/alpha.works/sqr_c4.pl
+++ /dev/null
@@ -1,109 +0,0 @@
1#!/usr/local/bin/perl
2# alpha assember
3
4sub sqr_add_c
5 {
6 local($a,$c0,$c1,$c2)=@_;
7 local($l1,$h1,$t1,$t2);
8
9 &mul($a,$a,($l1)=&NR(1));
10 &muh($a,$a,($h1)=&NR(1));
11 &add($c0,$l1,$c0);
12 &add($c1,$h1,$c1);
13 &cmpult($c0,$l1,($t1)=&NR(1)); &FR($l1);
14 &cmpult($c1,$h1,($t2)=&NR(1)); &FR($h1);
15 &add($c1,$t1,$c1); &FR($t1);
16 &add($c2,$t2,$c2); &FR($t2);
17 }
18
19sub sqr_add_c2
20 {
21 local($a,$b,$c0,$c1,$c2)=@_;
22 local($l1,$h1,$t1,$t2);
23
24 &mul($a,$b,($l1)=&NR(1));
25 &muh($a,$b,($h1)=&NR(1));
26 &cmplt($l1,"zero",($lc1)=&NR(1));
27 &cmplt($h1,"zero",($hc1)=&NR(1));
28 &add($l1,$l1,$l1);
29 &add($h1,$h1,$h1);
30 &add($h1,$lc1,$h1); &FR($lc1);
31 &add($c2,$hc1,$c2); &FR($hc1);
32
33 &add($c0,$l1,$c0);
34 &add($c1,$h1,$c1);
35 &cmpult($c0,$l1,($lc1)=&NR(1)); &FR($l1);
36 &cmpult($c1,$h1,($hc1)=&NR(1)); &FR($h1);
37
38 &add($c1,$lc1,$c1); &FR($lc1);
39 &add($c2,$hc1,$c2); &FR($hc1);
40 }
41
42
43sub bn_sqr_comba4
44 {
45 local($name)=@_;
46 local(@a,@b,$r,$c0,$c1,$c2);
47
48 $cnt=1;
49 &init_pool(2);
50
51 $rp=&wparam(0);
52 $ap=&wparam(1);
53
54 &function_begin($name,"");
55
56 &comment("");
57
58 &ld(($a[0])=&NR(1),&QWPw(0,$ap));
59 &ld(($a[1])=&NR(1),&QWPw(1,$ap));
60 &ld(($a[2])=&NR(1),&QWPw(2,$ap));
61 &ld(($a[3])=&NR(1),&QWPw(3,$ap)); &FR($ap);
62
63 ($c0,$c1,$c2)=&NR(3);
64
65 &mov("zero",$c2);
66 &mul($a[0],$a[0],$c0);
67 &muh($a[0],$a[0],$c1);
68 &st($c0,&QWPw(0,$rp));
69 ($c0,$c1,$c2)=($c1,$c2,$c0);
70 &mov("zero",$c2);
71
72 &sqr_add_c2($a[0],$a[1],$c0,$c1,$c2);
73 &st($c0,&QWPw(1,$rp));
74 ($c0,$c1,$c2)=($c1,$c2,$c0);
75 &mov("zero",$c2);
76
77 &sqr_add_c($a[1],$c0,$c1,$c2);
78 &sqr_add_c2($a[2],$a[0],$c0,$c1,$c2);
79 &st($c0,&QWPw(2,$rp));
80 ($c0,$c1,$c2)=($c1,$c2,$c0);
81 &mov("zero",$c2);
82
83 &sqr_add_c2($a[3],$a[0],$c0,$c1,$c2);
84 &sqr_add_c2($a[2],$a[1],$c0,$c1,$c2);
85 &st($c0,&QWPw(3,$rp));
86 ($c0,$c1,$c2)=($c1,$c2,$c0);
87 &mov("zero",$c2);
88
89 &sqr_add_c($a[2],$c0,$c1,$c2);
90 &sqr_add_c2($a[3],$a[1],$c0,$c1,$c2);
91 &st($c0,&QWPw(4,$rp));
92 ($c0,$c1,$c2)=($c1,$c2,$c0);
93 &mov("zero",$c2);
94
95 &sqr_add_c2($a[3],$a[2],$c0,$c1,$c2);
96 &st($c0,&QWPw(5,$rp));
97 ($c0,$c1,$c2)=($c1,$c2,$c0);
98 &mov("zero",$c2);
99
100 &sqr_add_c($a[3],$c0,$c1,$c2);
101 &st($c0,&QWPw(6,$rp));
102 &st($c1,&QWPw(7,$rp));
103
104 &function_end($name);
105
106 &fin_pool;
107 }
108
1091;
diff --git a/src/lib/libcrypto/bn/asm/alpha.works/sqr_c8.pl b/src/lib/libcrypto/bn/asm/alpha.works/sqr_c8.pl
deleted file mode 100644
index b4afe085f1..0000000000
--- a/src/lib/libcrypto/bn/asm/alpha.works/sqr_c8.pl
+++ /dev/null
@@ -1,132 +0,0 @@
1#!/usr/local/bin/perl
2# alpha assember
3
4sub bn_sqr_comba8
5 {
6 local($name)=@_;
7 local(@a,@b,$r,$c0,$c1,$c2);
8
9 $cnt=1;
10 &init_pool(2);
11
12 $rp=&wparam(0);
13 $ap=&wparam(1);
14
15 &function_begin($name,"");
16
17 &comment("");
18
19 &ld(($a[0])=&NR(1),&QWPw(0,$ap));
20 &ld(($a[1])=&NR(1),&QWPw(1,$ap));
21 &ld(($a[2])=&NR(1),&QWPw(2,$ap));
22 &ld(($a[3])=&NR(1),&QWPw(3,$ap));
23 &ld(($a[4])=&NR(1),&QWPw(4,$ap));
24 &ld(($a[5])=&NR(1),&QWPw(5,$ap));
25 &ld(($a[6])=&NR(1),&QWPw(6,$ap));
26 &ld(($a[7])=&NR(1),&QWPw(7,$ap)); &FR($ap);
27
28 ($c0,$c1,$c2)=&NR(3);
29
30 &mov("zero",$c2);
31 &mul($a[0],$a[0],$c0);
32 &muh($a[0],$a[0],$c1);
33 &st($c0,&QWPw(0,$rp));
34 ($c0,$c1,$c2)=($c1,$c2,$c0);
35 &mov("zero",$c2);
36
37 &sqr_add_c2($a[1],$a[0],$c0,$c1,$c2);
38 &st($c0,&QWPw(1,$rp));
39 ($c0,$c1,$c2)=($c1,$c2,$c0);
40 &mov("zero",$c2);
41
42 &sqr_add_c($a[1],$c0,$c1,$c2);
43 &sqr_add_c2($a[2],$a[0],$c0,$c1,$c2);
44 &st($c0,&QWPw(2,$rp));
45 ($c0,$c1,$c2)=($c1,$c2,$c0);
46 &mov("zero",$c2);
47
48 &sqr_add_c2($a[2],$a[1],$c0,$c1,$c2);
49 &sqr_add_c2($a[3],$a[0],$c0,$c1,$c2);
50 &st($c0,&QWPw(3,$rp));
51 ($c0,$c1,$c2)=($c1,$c2,$c0);
52 &mov("zero",$c2);
53
54 &sqr_add_c($a[2],$c0,$c1,$c2);
55 &sqr_add_c2($a[3],$a[1],$c0,$c1,$c2);
56 &sqr_add_c2($a[4],$a[0],$c0,$c1,$c2);
57 &st($c0,&QWPw(4,$rp));
58 ($c0,$c1,$c2)=($c1,$c2,$c0);
59 &mov("zero",$c2);
60
61 &sqr_add_c2($a[3],$a[2],$c0,$c1,$c2);
62 &sqr_add_c2($a[4],$a[1],$c0,$c1,$c2);
63 &sqr_add_c2($a[5],$a[0],$c0,$c1,$c2);
64 &st($c0,&QWPw(5,$rp));
65 ($c0,$c1,$c2)=($c1,$c2,$c0);
66 &mov("zero",$c2);
67
68 &sqr_add_c($a[3],$c0,$c1,$c2);
69 &sqr_add_c2($a[4],$a[2],$c0,$c1,$c2);
70 &sqr_add_c2($a[5],$a[1],$c0,$c1,$c2);
71 &sqr_add_c2($a[6],$a[0],$c0,$c1,$c2);
72 &st($c0,&QWPw(6,$rp));
73 ($c0,$c1,$c2)=($c1,$c2,$c0);
74 &mov("zero",$c2);
75
76 &sqr_add_c2($a[4],$a[3],$c0,$c1,$c2);
77 &sqr_add_c2($a[5],$a[2],$c0,$c1,$c2);
78 &sqr_add_c2($a[6],$a[1],$c0,$c1,$c2);
79 &sqr_add_c2($a[7],$a[0],$c0,$c1,$c2);
80 &st($c0,&QWPw(7,$rp));
81 ($c0,$c1,$c2)=($c1,$c2,$c0);
82 &mov("zero",$c2);
83
84 &sqr_add_c($a[4],$c0,$c1,$c2);
85 &sqr_add_c2($a[5],$a[3],$c0,$c1,$c2);
86 &sqr_add_c2($a[6],$a[2],$c0,$c1,$c2);
87 &sqr_add_c2($a[7],$a[1],$c0,$c1,$c2);
88 &st($c0,&QWPw(8,$rp));
89 ($c0,$c1,$c2)=($c1,$c2,$c0);
90 &mov("zero",$c2);
91
92 &sqr_add_c2($a[5],$a[4],$c0,$c1,$c2);
93 &sqr_add_c2($a[6],$a[3],$c0,$c1,$c2);
94 &sqr_add_c2($a[7],$a[2],$c0,$c1,$c2);
95 &st($c0,&QWPw(9,$rp));
96 ($c0,$c1,$c2)=($c1,$c2,$c0);
97 &mov("zero",$c2);
98
99 &sqr_add_c($a[5],$c0,$c1,$c2);
100 &sqr_add_c2($a[6],$a[4],$c0,$c1,$c2);
101 &sqr_add_c2($a[7],$a[3],$c0,$c1,$c2);
102 &st($c0,&QWPw(10,$rp));
103 ($c0,$c1,$c2)=($c1,$c2,$c0);
104 &mov("zero",$c2);
105
106 &sqr_add_c2($a[6],$a[5],$c0,$c1,$c2);
107 &sqr_add_c2($a[7],$a[4],$c0,$c1,$c2);
108 &st($c0,&QWPw(11,$rp));
109 ($c0,$c1,$c2)=($c1,$c2,$c0);
110 &mov("zero",$c2);
111
112 &sqr_add_c($a[6],$c0,$c1,$c2);
113 &sqr_add_c2($a[7],$a[5],$c0,$c1,$c2);
114 &st($c0,&QWPw(12,$rp));
115 ($c0,$c1,$c2)=($c1,$c2,$c0);
116 &mov("zero",$c2);
117
118 &sqr_add_c2($a[7],$a[6],$c0,$c1,$c2);
119 &st($c0,&QWPw(13,$rp));
120 ($c0,$c1,$c2)=($c1,$c2,$c0);
121 &mov("zero",$c2);
122
123 &sqr_add_c($a[7],$c0,$c1,$c2);
124 &st($c0,&QWPw(14,$rp));
125 &st($c1,&QWPw(15,$rp));
126
127 &function_end($name);
128
129 &fin_pool;
130 }
131
1321;
diff --git a/src/lib/libcrypto/bn/asm/alpha.works/sub.pl b/src/lib/libcrypto/bn/asm/alpha.works/sub.pl
deleted file mode 100644
index d998da5c21..0000000000
--- a/src/lib/libcrypto/bn/asm/alpha.works/sub.pl
+++ /dev/null
@@ -1,108 +0,0 @@
1#!/usr/local/bin/perl
2# alpha assember
3
4sub bn_sub_words
5 {
6 local($name)=@_;
7 local($cc,$a,$b,$r);
8
9 &init_pool(4);
10 ($cc)=GR("r0");
11
12 $rp=&wparam(0);
13 $ap=&wparam(1);
14 $bp=&wparam(2);
15 $count=&wparam(3);
16
17 &function_begin($name,"");
18
19 &comment("");
20 &sub($count,4,$count);
21 &mov("zero",$cc);
22 &blt($count,&label("finish"));
23
24 ($a0,$b0)=&NR(2);
25 &ld($a0,&QWPw(0,$ap));
26 &ld($b0,&QWPw(0,$bp));
27
28##########################################################
29 &set_label("loop");
30
31 ($a1,$tmp,$b1,$a2,$b2,$a3,$b3,$o0)=&NR(8);
32 &ld($a1,&QWPw(1,$ap));
33 &cmpult($a0,$b0,$tmp); # will we borrow?
34 &ld($b1,&QWPw(1,$bp));
35 &sub($a0,$b0,$a0); # do the subtract
36 &ld($a2,&QWPw(2,$ap));
37 &cmpult($a0,$cc,$b0); # will we borrow?
38 &ld($b2,&QWPw(2,$bp));
39 &sub($a0,$cc,$o0); # will we borrow?
40 &ld($a3,&QWPw(3,$ap));
41 &add($b0,$tmp,$cc); ($t1,$o1)=&NR(2); &FR($tmp);
42
43 &cmpult($a1,$b1,$t1); # will we borrow?
44 &sub($a1,$b1,$a1); # do the subtract
45 &ld($b3,&QWPw(3,$bp));
46 &cmpult($a1,$cc,$b1); # will we borrow?
47 &sub($a1,$cc,$o1); # will we borrow?
48 &add($b1,$t1,$cc); ($tmp,$o2)=&NR(2); &FR($t1,$a1,$b1);
49
50 &cmpult($a2,$b2,$tmp); # will we borrow?
51 &sub($a2,$b2,$a2); # do the subtract
52 &st($o0,&QWPw(0,$rp)); &FR($o0); # save
53 &cmpult($a2,$cc,$b2); # will we borrow?
54 &sub($a2,$cc,$o2); # will we borrow?
55 &add($b2,$tmp,$cc); ($t3,$o3)=&NR(2); &FR($tmp,$a2,$b2);
56
57 &cmpult($a3,$b3,$t3); # will we borrow?
58 &sub($a3,$b3,$a3); # do the subtract
59 &st($o1,&QWPw(1,$rp)); &FR($o1);
60 &cmpult($a3,$cc,$b3); # will we borrow?
61 &sub($a3,$cc,$o3); # will we borrow?
62 &add($b3,$t3,$cc); &FR($t3,$a3,$b3);
63
64 &st($o2,&QWPw(2,$rp)); &FR($o2);
65 &sub($count,4,$count); # count-=4
66 &st($o3,&QWPw(3,$rp)); &FR($o3);
67 &add($ap,4*$QWS,$ap); # count+=4
68 &add($bp,4*$QWS,$bp); # count+=4
69 &add($rp,4*$QWS,$rp); # count+=4
70
71 &blt($count,&label("finish"));
72 &ld($a0,&QWPw(0,$ap));
73 &ld($b0,&QWPw(0,$bp));
74 &br(&label("loop"));
75##################################################
76 # Do the last 0..3 words
77
78 &set_label("last_loop");
79
80 &ld($a0,&QWPw(0,$ap)); # get a
81 &ld($b0,&QWPw(0,$bp)); # get b
82 &cmpult($a0,$b0,$tmp); # will we borrow?
83 &sub($a0,$b0,$a0); # do the subtract
84 &cmpult($a0,$cc,$b0); # will we borrow?
85 &sub($a0,$cc,$a0); # will we borrow?
86 &st($a0,&QWPw(0,$rp)); # save
87 &add($b0,$tmp,$cc); # add the borrows
88
89 &add($ap,$QWS,$ap);
90 &add($bp,$QWS,$bp);
91 &add($rp,$QWS,$rp);
92 &sub($count,1,$count);
93 &bgt($count,&label("last_loop"));
94 &function_end_A($name);
95
96######################################################
97 &set_label("finish");
98 &add($count,4,$count);
99 &bgt($count,&label("last_loop"));
100
101 &FR($a0,$b0);
102 &set_label("end");
103 &function_end($name);
104
105 &fin_pool;
106 }
107
1081;
diff --git a/src/lib/libcrypto/bn/asm/alpha/add.pl b/src/lib/libcrypto/bn/asm/alpha/add.pl
deleted file mode 100644
index 13bf516428..0000000000
--- a/src/lib/libcrypto/bn/asm/alpha/add.pl
+++ /dev/null
@@ -1,118 +0,0 @@
1#!/usr/local/bin/perl
2# alpha assember
3
4sub bn_add_words
5 {
6 local($name)=@_;
7 local($cc,$a,$b,$r);
8
9 &init_pool(4);
10 ($cc)=GR("r0");
11
12 $rp=&wparam(0);
13 $ap=&wparam(1);
14 $bp=&wparam(2);
15 $count=&wparam(3);
16
17 &function_begin($name,"");
18
19 &comment("");
20 &sub($count,4,$count);
21 &mov("zero",$cc);
22 &blt($count,&label("finish"));
23
24 ($a0,$b0)=&NR(2);
25
26##########################################################
27 &set_label("loop");
28
29 &ld(($a0)=&NR(1),&QWPw(0,$ap));
30 &ld(($b0)=&NR(1),&QWPw(0,$bp));
31 &ld(($a1)=&NR(1),&QWPw(1,$ap));
32 &ld(($b1)=&NR(1),&QWPw(1,$bp));
33
34 ($o0,$t0)=&NR(2);
35 &add($a0,$b0,$o0);
36 &ld(($a2)=&NR(1),&QWPw(2,$ap));
37 &cmpult($o0,$b0,$t0);
38 &add($o0,$cc,$o0);
39 &cmpult($o0,$cc,$cc);
40 &ld(($b2)=&NR(1),&QWPw(2,$bp));
41 &add($cc,$t0,$cc); &FR($t0);
42
43 ($t1,$o1)=&NR(2);
44
45 &add($a1,$b1,$o1); &FR($a1);
46 &cmpult($o1,$b1,$t1); &FR($b1);
47 &add($o1,$cc,$o1);
48 &cmpult($o1,$cc,$cc);
49 &ld(($a3)=&NR(1),&QWPw(3,$ap));
50 &add($cc,$t1,$cc); &FR($t1);
51
52 ($t2,$o2)=&NR(2);
53
54 &add($a2,$b2,$o2); &FR($a2);
55 &cmpult($o2,$b2,$t2); &FR($b2);
56 &add($o2,$cc,$o2);
57 &cmpult($o2,$cc,$cc);
58 &ld(($b3)=&NR(1),&QWPw(3,$bp));
59 &st($o0,&QWPw(0,$rp)); &FR($o0);
60 &add($cc,$t2,$cc); &FR($t2);
61
62 ($t3,$o3)=&NR(2);
63
64 &st($o1,&QWPw(0,$rp)); &FR($o1);
65 &add($a3,$b3,$o3); &FR($a3);
66 &cmpult($o3,$b3,$t3); &FR($b3);
67 &add($o3,$cc,$o3);
68 &st($o2,&QWPw(0,$rp)); &FR($o2);
69 &cmpult($o3,$cc,$cc);
70 &st($o3,&QWPw(0,$rp)); &FR($o3);
71 &add($cc,$t3,$cc); &FR($t3);
72
73
74 &sub($count,4,$count); # count-=4
75 &add($ap,4*$QWS,$ap); # count+=4
76 &add($bp,4*$QWS,$bp); # count+=4
77 &add($rp,4*$QWS,$rp); # count+=4
78
79 ###
80 &bge($count,&label("loop"));
81 ###
82 &br(&label("finish"));
83##################################################
84 # Do the last 0..3 words
85
86 ($t0,$o0)=&NR(2);
87 &set_label("last_loop");
88
89 &ld($a0,&QWPw(0,$ap)); # get a
90 &ld($b0,&QWPw(0,$bp)); # get b
91 &add($ap,$QWS,$ap);
92 &add($bp,$QWS,$bp);
93 &add($a0,$b0,$o0);
94 &sub($count,1,$count);
95 &cmpult($o0,$b0,$t0); # will we borrow?
96 &add($o0,$cc,$o0); # will we borrow?
97 &cmpult($o0,$cc,$cc); # will we borrow?
98 &add($rp,$QWS,$rp);
99 &st($o0,&QWPw(-1,$rp)); # save
100 &add($cc,$t0,$cc); # add the borrows
101
102 ###
103 &bgt($count,&label("last_loop"));
104 &function_end_A($name);
105
106######################################################
107 &set_label("finish");
108 &add($count,4,$count);
109 &bgt($count,&label("last_loop"));
110
111 &FR($o0,$t0,$a0,$b0);
112 &set_label("end");
113 &function_end($name);
114
115 &fin_pool;
116 }
117
1181;
diff --git a/src/lib/libcrypto/bn/asm/alpha/div.pl b/src/lib/libcrypto/bn/asm/alpha/div.pl
deleted file mode 100644
index e9e680897a..0000000000
--- a/src/lib/libcrypto/bn/asm/alpha/div.pl
+++ /dev/null
@@ -1,144 +0,0 @@
1#!/usr/local/bin/perl
2
3sub bn_div_words
4 {
5 local($data)=<<'EOF';
6 #
7 # What follows was taken directly from the C compiler with a few
8 # hacks to redo the lables.
9 #
10.text
11 .set noreorder
12 .set volatile
13 .align 3
14 .globl bn_div_words
15 .ent bn_div_words
16bn_div_words
17 ldgp $29,0($27)
18bn_div_words.ng:
19 lda $30,-48($30)
20 .frame $30,48,$26,0
21 stq $26,0($30)
22 stq $9,8($30)
23 stq $10,16($30)
24 stq $11,24($30)
25 stq $12,32($30)
26 stq $13,40($30)
27 .mask 0x4003e00,-48
28 .prologue 1
29 bis $16,$16,$9
30 bis $17,$17,$10
31 bis $18,$18,$11
32 bis $31,$31,$13
33 bis $31,2,$12
34 bne $11,$9119
35 lda $0,-1
36 br $31,$9136
37 .align 4
38$9119:
39 bis $11,$11,$16
40 jsr $26,BN_num_bits_word
41 ldgp $29,0($26)
42 subq $0,64,$1
43 beq $1,$9120
44 bis $31,1,$1
45 sll $1,$0,$1
46 cmpule $9,$1,$1
47 bne $1,$9120
48 # lda $16,_IO_stderr_
49 # lda $17,$C32
50 # bis $0,$0,$18
51 # jsr $26,fprintf
52 # ldgp $29,0($26)
53 jsr $26,abort
54 ldgp $29,0($26)
55 .align 4
56$9120:
57 bis $31,64,$3
58 cmpult $9,$11,$2
59 subq $3,$0,$1
60 addl $1,$31,$0
61 subq $9,$11,$1
62 cmoveq $2,$1,$9
63 beq $0,$9122
64 zapnot $0,15,$2
65 subq $3,$0,$1
66 sll $11,$2,$11
67 sll $9,$2,$3
68 srl $10,$1,$1
69 sll $10,$2,$10
70 bis $3,$1,$9
71$9122:
72 srl $11,32,$5
73 zapnot $11,15,$6
74 lda $7,-1
75 .align 5
76$9123:
77 srl $9,32,$1
78 subq $1,$5,$1
79 bne $1,$9126
80 zapnot $7,15,$27
81 br $31,$9127
82 .align 4
83$9126:
84 bis $9,$9,$24
85 bis $5,$5,$25
86 divqu $24,$25,$27
87$9127:
88 srl $10,32,$4
89 .align 5
90$9128:
91 mulq $27,$5,$1
92 subq $9,$1,$3
93 zapnot $3,240,$1
94 bne $1,$9129
95 mulq $6,$27,$2
96 sll $3,32,$1
97 addq $1,$4,$1
98 cmpule $2,$1,$2
99 bne $2,$9129
100 subq $27,1,$27
101 br $31,$9128
102 .align 4
103$9129:
104 mulq $27,$6,$1
105 mulq $27,$5,$4
106 srl $1,32,$3
107 sll $1,32,$1
108 addq $4,$3,$4
109 cmpult $10,$1,$2
110 subq $10,$1,$10
111 addq $2,$4,$2
112 cmpult $9,$2,$1
113 bis $2,$2,$4
114 beq $1,$9134
115 addq $9,$11,$9
116 subq $27,1,$27
117$9134:
118 subl $12,1,$12
119 subq $9,$4,$9
120 beq $12,$9124
121 sll $27,32,$13
122 sll $9,32,$2
123 srl $10,32,$1
124 sll $10,32,$10
125 bis $2,$1,$9
126 br $31,$9123
127 .align 4
128$9124:
129 bis $13,$27,$0
130$9136:
131 ldq $26,0($30)
132 ldq $9,8($30)
133 ldq $10,16($30)
134 ldq $11,24($30)
135 ldq $12,32($30)
136 ldq $13,40($30)
137 addq $30,48,$30
138 ret $31,($26),1
139 .end bn_div_words
140EOF
141 &asm_add($data);
142 }
143
1441;
diff --git a/src/lib/libcrypto/bn/asm/alpha/mul.pl b/src/lib/libcrypto/bn/asm/alpha/mul.pl
deleted file mode 100644
index 76c926566c..0000000000
--- a/src/lib/libcrypto/bn/asm/alpha/mul.pl
+++ /dev/null
@@ -1,104 +0,0 @@
1#!/usr/local/bin/perl
2# alpha assember
3
4sub bn_mul_words
5 {
6 local($name)=@_;
7 local($cc,$a,$b,$r,$couny);
8
9 &init_pool(4);
10 ($cc)=GR("r0");
11
12 $rp=&wparam(0);
13 $ap=&wparam(1);
14 $count=&wparam(2);
15 $word=&wparam(3);
16
17 &function_begin($name,"");
18
19 &comment("");
20 &sub($count,4,$count);
21 &mov("zero",$cc);
22 ###
23 &blt($count,&label("finish"));
24
25 ($a0)=&NR(1); &ld($a0,&QWPw(0,$ap));
26
27 &set_label("loop");
28
29 ($a1)=&NR(1); &ld($a1,&QWPw(1,$ap));
30 ($a2)=&NR(1); &ld($a2,&QWPw(2,$ap));
31
32 &muh($a0,$word,($h0)=&NR(1)); &FR($a0);
33 ($a3)=&NR(1); &ld($a3,&QWPw(3,$ap));
34 ### wait 8
35 &mul($a0,$word,($l0)=&NR(1)); &FR($a0);
36 ### wait 8
37 &muh($a1,$word,($h1)=&NR(1)); &FR($a1);
38 &add($l0,$cc,$l0); ### wait 8
39 &mul($a1,$word,($l1)=&NR(1)); &FR($a1);
40 &cmpult($l0,$cc,$cc); ### wait 8
41 &muh($a2,$word,($h2)=&NR(1)); &FR($a2);
42 &add($h0,$cc,$cc); &FR($h0); ### wait 8
43 &mul($a2,$word,($l2)=&NR(1)); &FR($a2);
44 &add($l1,$cc,$l1); ### wait 8
45 &st($l0,&QWPw(0,$rp)); &FR($l0);
46 &cmpult($l1,$cc,$cc); ### wait 8
47 &muh($a3,$word,($h3)=&NR(1)); &FR($a3);
48 &add($h1,$cc,$cc); &FR($h1);
49 &mul($a3,$word,($l3)=&NR(1)); &FR($a3);
50 &add($l2,$cc,$l2);
51 &st($l1,&QWPw(1,$rp)); &FR($l1);
52 &cmpult($l2,$cc,$cc);
53 &add($h2,$cc,$cc); &FR($h2);
54 &sub($count,4,$count); # count-=4
55 &st($l2,&QWPw(2,$rp)); &FR($l2);
56 &add($l3,$cc,$l3);
57 &cmpult($l3,$cc,$cc);
58 &add($bp,4*$QWS,$bp); # count+=4
59 &add($h3,$cc,$cc); &FR($h3);
60 &add($ap,4*$QWS,$ap); # count+=4
61 &st($l3,&QWPw(3,$rp)); &FR($l3);
62 &add($rp,4*$QWS,$rp); # count+=4
63 ###
64 &blt($count,&label("finish"));
65 ($a0)=&NR(1); &ld($a0,&QWPw(0,$ap));
66 &br(&label("finish"));
67##################################################
68
69##################################################
70 # Do the last 0..3 words
71
72 &set_label("last_loop");
73
74 &ld(($a0)=&NR(1),&QWPw(0,$ap)); # get a
75 ###
76 ###
77 ###
78 &muh($a0,$word,($h0)=&NR(1));
79 ### Wait 8 for next mul issue
80 &mul($a0,$word,($l0)=&NR(1)); &FR($a0)
81 &add($ap,$QWS,$ap);
82 ### Loose 12 until result is available
83 &add($rp,$QWS,$rp);
84 &sub($count,1,$count);
85 &add($l0,$cc,$l0);
86 ###
87 &st($l0,&QWPw(-1,$rp)); &FR($l0);
88 &cmpult($l0,$cc,$cc);
89 &add($h0,$cc,$cc); &FR($h0);
90 &bgt($count,&label("last_loop"));
91 &function_end_A($name);
92
93######################################################
94 &set_label("finish");
95 &add($count,4,$count);
96 &bgt($count,&label("last_loop"));
97
98 &set_label("end");
99 &function_end($name);
100
101 &fin_pool;
102 }
103
1041;
diff --git a/src/lib/libcrypto/bn/asm/alpha/mul_add.pl b/src/lib/libcrypto/bn/asm/alpha/mul_add.pl
deleted file mode 100644
index 0d6df69bc4..0000000000
--- a/src/lib/libcrypto/bn/asm/alpha/mul_add.pl
+++ /dev/null
@@ -1,123 +0,0 @@
1#!/usr/local/bin/perl
2# alpha assember
3
4sub bn_mul_add_words
5 {
6 local($name)=@_;
7 local($cc,$a,$b,$r,$couny);
8
9 &init_pool(4);
10 ($cc)=GR("r0");
11
12 $rp=&wparam(0);
13 $ap=&wparam(1);
14 $count=&wparam(2);
15 $word=&wparam(3);
16
17 &function_begin($name,"");
18
19 &comment("");
20 &sub($count,4,$count);
21 &mov("zero",$cc);
22 ###
23 &blt($count,&label("finish"));
24
25 &ld(($a0)=&NR(1),&QWPw(0,$ap));
26
27$a=<<'EOF';
28##########################################################
29 &set_label("loop");
30
31 &ld(($r0)=&NR(1),&QWPw(0,$rp));
32 &ld(($a1)=&NR(1),&QWPw(1,$ap));
33 &muh($a0,$word,($h0)=&NR(1));
34 &ld(($r1)=&NR(1),&QWPw(1,$rp));
35 &ld(($a2)=&NR(1),&QWPw(2,$ap));
36 ###
37 &mul($a0,$word,($l0)=&NR(1)); &FR($a0);
38 &ld(($r2)=&NR(1),&QWPw(2,$rp));
39 &muh($a1,$word,($h1)=&NR(1));
40 &ld(($a3)=&NR(1),&QWPw(3,$ap));
41 &mul($a1,$word,($l1)=&NR(1)); &FR($a1);
42 &ld(($r3)=&NR(1),&QWPw(3,$rp));
43 &add($r0,$l0,$r0);
44 &add($r1,$l1,$r1);
45 &cmpult($r0,$l0,($t0)=&NR(1)); &FR($l0);
46 &cmpult($r1,$l1,($t1)=&NR(1)); &FR($l1);
47 &muh($a2,$word,($h2)=&NR(1));
48 &add($r0,$cc,$r0);
49 &add($h0,$t0,$h0); &FR($t0);
50 &cmpult($r0,$cc,$cc);
51 &add($h1,$t1,$h1); &FR($t1);
52 &add($h0,$cc,$cc); &FR($h0);
53 &mul($a2,$word,($l2)=&NR(1)); &FR($a2);
54 &add($r1,$cc,$r1);
55 &cmpult($r1,$cc,$cc);
56 &add($r2,$l2,$r2);
57 &add($h1,$cc,$cc); &FR($h1);
58 &cmpult($r2,$l2,($t2)=&NR(1)); &FR($l2);
59 &muh($a3,$word,($h3)=&NR(1));
60 &add($r2,$cc,$r2);
61 &st($r0,&QWPw(0,$rp)); &FR($r0);
62 &add($h2,$t2,$h2); &FR($t2);
63 &st($r1,&QWPw(1,$rp)); &FR($r1);
64 &cmpult($r2,$cc,$cc);
65 &mul($a3,$word,($l3)=&NR(1)); &FR($a3);
66 &add($h2,$cc,$cc); &FR($h2);
67 &st($r2,&QWPw(2,$rp)); &FR($r2);
68 &sub($count,4,$count); # count-=4
69 &add($rp,4*$QWS,$rp); # count+=4
70 &add($r3,$l3,$r3);
71 &add($ap,4*$QWS,$ap); # count+=4
72 &cmpult($r3,$l3,($t3)=&NR(1)); &FR($l3);
73 &add($r3,$cc,$r3);
74 &add($h3,$t3,$h3); &FR($t3);
75 &cmpult($r3,$cc,$cc);
76 &st($r3,&QWPw(-1,$rp)); &FR($r3);
77 &add($h3,$cc,$cc); &FR($h3);
78
79 ###
80 &blt($count,&label("finish"));
81 &ld(($a0)=&NR(1),&QWPw(0,$ap));
82 &br(&label("loop"));
83EOF
84##################################################
85 # Do the last 0..3 words
86
87 &set_label("last_loop");
88
89 &ld(($a0)=&NR(1),&QWPw(0,$ap)); # get a
90 &ld(($r0)=&NR(1),&QWPw(0,$rp)); # get b
91 ###
92 ###
93 &muh($a0,$word,($h0)=&NR(1)); &FR($a0);
94 ### wait 8
95 &mul($a0,$word,($l0)=&NR(1)); &FR($a0);
96 &add($rp,$QWS,$rp);
97 &add($ap,$QWS,$ap);
98 &sub($count,1,$count);
99 ### wait 3 until l0 is available
100 &add($r0,$l0,$r0);
101 ###
102 &cmpult($r0,$l0,($t0)=&NR(1)); &FR($l0);
103 &add($r0,$cc,$r0);
104 &add($h0,$t0,$h0); &FR($t0);
105 &cmpult($r0,$cc,$cc);
106 &add($h0,$cc,$cc); &FR($h0);
107
108 &st($r0,&QWPw(-1,$rp)); &FR($r0);
109 &bgt($count,&label("last_loop"));
110 &function_end_A($name);
111
112######################################################
113 &set_label("finish");
114 &add($count,4,$count);
115 &bgt($count,&label("last_loop"));
116
117 &set_label("end");
118 &function_end($name);
119
120 &fin_pool;
121 }
122
1231;
diff --git a/src/lib/libcrypto/bn/asm/alpha/mul_c4.pl b/src/lib/libcrypto/bn/asm/alpha/mul_c4.pl
deleted file mode 100644
index 9cc876ded4..0000000000
--- a/src/lib/libcrypto/bn/asm/alpha/mul_c4.pl
+++ /dev/null
@@ -1,215 +0,0 @@
1#!/usr/local/bin/perl
2# alpha assember
3
4# upto
5
6sub mul_add_c
7 {
8 local($a,$b,$c0,$c1,$c2)=@_;
9 local($l1,$h1,$t1,$t2);
10
11 &mul($a,$b,($l1)=&NR(1));
12 &muh($a,$b,($h1)=&NR(1));
13 &add($c0,$l1,$c0);
14 &cmpult($c0,$l1,($t1)=&NR(1)); &FR($l1);
15 &add($t1,$h1,$h1); &FR($t1);
16 &add($c1,$h1,$c1);
17 &cmpult($c1,$h1,($t2)=&NR(1)); &FR($h1);
18 &add($c2,$t2,$c2); &FR($t2);
19 }
20
21sub bn_mul_comba4
22 {
23 local($name)=@_;
24 local(@a,@b,$r,$c0,$c1,$c2);
25
26 $cnt=1;
27 &init_pool(3);
28
29 $rp=&wparam(0);
30 $ap=&wparam(1);
31 $bp=&wparam(2);
32
33 &function_begin($name,"");
34
35 &comment("");
36
37 &ld(($a[0])=&NR(1),&QWPw(0,$ap));
38 &ld(($b[0])=&NR(1),&QWPw(0,$bp));
39 &ld(($a[1])=&NR(1),&QWPw(1,$ap));
40 &ld(($b[1])=&NR(1),&QWPw(1,$bp));
41 &mul($a[0],$b[0],($r00)=&NR(1));
42 &ld(($a[2])=&NR(1),&QWPw(2,$ap));
43 &ld(($b[2])=&NR(1),&QWPw(2,$bp));
44 &muh($a[0],$b[0],($r01)=&NR(1));
45 &FR($ap); &ld(($a[3])=&NR(1),&QWPw(3,$ap));
46 &FR($bp); &ld(($b[3])=&NR(1),&QWPw(3,$bp));
47 &mul($a[0],$b[1],($r02)=&NR(1));
48
49 ($R,$H1,$H2)=&NR(3);
50
51 &st($r00,&QWPw(0,$rp)); &FR($r00);
52
53 &mov("zero",$R);
54 &mul($a[1],$b[0],($r03)=&NR(1));
55
56 &mov("zero",$H1);
57 &mov("zero",$H0);
58 &add($R,$r01,$R);
59 &muh($a[0],$b[1],($r04)=&NR(1));
60 &cmpult($R,$r01,($t01)=&NR(1)); &FR($r01);
61 &add($R,$r02,$R);
62 &add($H1,$t01,$H1) &FR($t01);
63 &muh($a[1],$b[0],($r05)=&NR(1));
64 &cmpult($R,$r02,($t02)=&NR(1)); &FR($r02);
65 &add($R,$r03,$R);
66 &add($H2,$t02,$H2) &FR($t02);
67 &mul($a[0],$b[2],($r06)=&NR(1));
68 &cmpult($R,$r03,($t03)=&NR(1)); &FR($r03);
69 &add($H1,$t03,$H1) &FR($t03);
70 &st($R,&QWPw(1,$rp));
71 &add($H1,$H2,$R);
72
73 &mov("zero",$H1);
74 &add($R,$r04,$R);
75 &mov("zero",$H2);
76 &mul($a[1],$b[1],($r07)=&NR(1));
77 &cmpult($R,$r04,($t04)=&NR(1)); &FR($r04);
78 &add($R,$r05,$R);
79 &add($H1,$t04,$H1) &FR($t04);
80 &mul($a[2],$b[0],($r08)=&NR(1));
81 &cmpult($R,$r05,($t05)=&NR(1)); &FR($r05);
82 &add($R,$r01,$R);
83 &add($H2,$t05,$H2) &FR($t05);
84 &muh($a[0],$b[2],($r09)=&NR(1));
85 &cmpult($R,$r06,($t06)=&NR(1)); &FR($r06);
86 &add($R,$r07,$R);
87 &add($H1,$t06,$H1) &FR($t06);
88 &muh($a[1],$b[1],($r10)=&NR(1));
89 &cmpult($R,$r07,($t07)=&NR(1)); &FR($r07);
90 &add($R,$r08,$R);
91 &add($H2,$t07,$H2) &FR($t07);
92 &muh($a[2],$b[0],($r11)=&NR(1));
93 &cmpult($R,$r08,($t08)=&NR(1)); &FR($r08);
94 &add($H1,$t08,$H1) &FR($t08);
95 &st($R,&QWPw(2,$rp));
96 &add($H1,$H2,$R);
97
98 &mov("zero",$H1);
99 &add($R,$r09,$R);
100 &mov("zero",$H2);
101 &mul($a[0],$b[3],($r12)=&NR(1));
102 &cmpult($R,$r09,($t09)=&NR(1)); &FR($r09);
103 &add($R,$r10,$R);
104 &add($H1,$t09,$H1) &FR($t09);
105 &mul($a[1],$b[2],($r13)=&NR(1));
106 &cmpult($R,$r10,($t10)=&NR(1)); &FR($r10);
107 &add($R,$r11,$R);
108 &add($H1,$t10,$H1) &FR($t10);
109 &mul($a[2],$b[1],($r14)=&NR(1));
110 &cmpult($R,$r11,($t11)=&NR(1)); &FR($r11);
111 &add($R,$r12,$R);
112 &add($H1,$t11,$H1) &FR($t11);
113 &mul($a[3],$b[0],($r15)=&NR(1));
114 &cmpult($R,$r12,($t12)=&NR(1)); &FR($r12);
115 &add($R,$r13,$R);
116 &add($H1,$t12,$H1) &FR($t12);
117 &muh($a[0],$b[3],($r16)=&NR(1));
118 &cmpult($R,$r13,($t13)=&NR(1)); &FR($r13);
119 &add($R,$r14,$R);
120 &add($H1,$t13,$H1) &FR($t13);
121 &muh($a[1],$b[2],($r17)=&NR(1));
122 &cmpult($R,$r14,($t14)=&NR(1)); &FR($r14);
123 &add($R,$r15,$R);
124 &add($H1,$t14,$H1) &FR($t14);
125 &muh($a[2],$b[1],($r18)=&NR(1));
126 &cmpult($R,$r15,($t15)=&NR(1)); &FR($r15);
127 &add($H1,$t15,$H1) &FR($t15);
128 &st($R,&QWPw(3,$rp));
129 &add($H1,$H2,$R);
130
131 &mov("zero",$H1);
132 &add($R,$r16,$R);
133 &mov("zero",$H2);
134 &muh($a[3],$b[0],($r19)=&NR(1));
135 &cmpult($R,$r16,($t16)=&NR(1)); &FR($r16);
136 &add($R,$r17,$R);
137 &add($H1,$t16,$H1) &FR($t16);
138 &mul($a[1],$b[3],($r20)=&NR(1));
139 &cmpult($R,$r17,($t17)=&NR(1)); &FR($r17);
140 &add($R,$r18,$R);
141 &add($H1,$t17,$H1) &FR($t17);
142 &mul($a[2],$b[2],($r21)=&NR(1));
143 &cmpult($R,$r18,($t18)=&NR(1)); &FR($r18);
144 &add($R,$r19,$R);
145 &add($H1,$t18,$H1) &FR($t18);
146 &mul($a[3],$b[1],($r22)=&NR(1));
147 &cmpult($R,$r19,($t19)=&NR(1)); &FR($r19);
148 &add($R,$r20,$R);
149 &add($H1,$t19,$H1) &FR($t19);
150 &muh($a[1],$b[3],($r23)=&NR(1));
151 &cmpult($R,$r20,($t20)=&NR(1)); &FR($r20);
152 &add($R,$r21,$R);
153 &add($H1,$t20,$H1) &FR($t20);
154 &muh($a[2],$b[2],($r24)=&NR(1));
155 &cmpult($R,$r21,($t21)=&NR(1)); &FR($r21);
156 &add($R,$r22,$R);
157 &add($H1,$t21,$H1) &FR($t21);
158 &muh($a[3],$b[1],($r25)=&NR(1));
159 &cmpult($R,$r22,($t22)=&NR(1)); &FR($r22);
160 &add($H1,$t22,$H1) &FR($t22);
161 &st($R,&QWPw(4,$rp));
162 &add($H1,$H2,$R);
163
164 &mov("zero",$H1);
165 &add($R,$r23,$R);
166 &mov("zero",$H2);
167 &mul($a[2],$b[3],($r26)=&NR(1));
168 &cmpult($R,$r23,($t23)=&NR(1)); &FR($r23);
169 &add($R,$r24,$R);
170 &add($H1,$t23,$H1) &FR($t23);
171 &mul($a[3],$b[2],($r27)=&NR(1));
172 &cmpult($R,$r24,($t24)=&NR(1)); &FR($r24);
173 &add($R,$r25,$R);
174 &add($H1,$t24,$H1) &FR($t24);
175 &muh($a[2],$b[3],($r28)=&NR(1));
176 &cmpult($R,$r25,($t25)=&NR(1)); &FR($r25);
177 &add($R,$r26,$R);
178 &add($H1,$t25,$H1) &FR($t25);
179 &muh($a[3],$b[2],($r29)=&NR(1));
180 &cmpult($R,$r26,($t26)=&NR(1)); &FR($r26);
181 &add($R,$r27,$R);
182 &add($H1,$t26,$H1) &FR($t26);
183 &mul($a[3],$b[3],($r30)=&NR(1));
184 &cmpult($R,$r27,($t27)=&NR(1)); &FR($r27);
185 &add($H1,$t27,$H1) &FR($t27);
186 &st($R,&QWPw(5,$rp));
187 &add($H1,$H2,$R);
188
189 &mov("zero",$H1);
190 &add($R,$r28,$R);
191 &mov("zero",$H2);
192 &muh($a[3],$b[3],($r31)=&NR(1));
193 &cmpult($R,$r28,($t28)=&NR(1)); &FR($r28);
194 &add($R,$r29,$R);
195 &add($H1,$t28,$H1) &FR($t28);
196 ############
197 &cmpult($R,$r29,($t29)=&NR(1)); &FR($r29);
198 &add($R,$r30,$R);
199 &add($H1,$t29,$H1) &FR($t29);
200 ############
201 &cmpult($R,$r30,($t30)=&NR(1)); &FR($r30);
202 &add($H1,$t30,$H1) &FR($t30);
203 &st($R,&QWPw(6,$rp));
204 &add($H1,$H2,$R);
205
206 &add($R,$r31,$R); &FR($r31);
207 &st($R,&QWPw(7,$rp));
208
209 &FR($R,$H1,$H2);
210 &function_end($name);
211
212 &fin_pool;
213 }
214
2151;
diff --git a/src/lib/libcrypto/bn/asm/alpha/mul_c4.works.pl b/src/lib/libcrypto/bn/asm/alpha/mul_c4.works.pl
deleted file mode 100644
index 79d86dd25c..0000000000
--- a/src/lib/libcrypto/bn/asm/alpha/mul_c4.works.pl
+++ /dev/null
@@ -1,98 +0,0 @@
1#!/usr/local/bin/perl
2# alpha assember
3
4sub mul_add_c
5 {
6 local($a,$b,$c0,$c1,$c2)=@_;
7 local($l1,$h1,$t1,$t2);
8
9print STDERR "count=$cnt\n"; $cnt++;
10 &mul($a,$b,($l1)=&NR(1));
11 &muh($a,$b,($h1)=&NR(1));
12 &add($c0,$l1,$c0);
13 &cmpult($c0,$l1,($t1)=&NR(1)); &FR($l1);
14 &add($t1,$h1,$h1); &FR($t1);
15 &add($c1,$h1,$c1);
16 &cmpult($c1,$h1,($t2)=&NR(1)); &FR($h1);
17 &add($c2,$t2,$c2); &FR($t2);
18 }
19
20sub bn_mul_comba4
21 {
22 local($name)=@_;
23 local(@a,@b,$r,$c0,$c1,$c2);
24
25 $cnt=1;
26 &init_pool(3);
27
28 $rp=&wparam(0);
29 $ap=&wparam(1);
30 $bp=&wparam(2);
31
32 &function_begin($name,"");
33
34 &comment("");
35
36 &ld(($a[0])=&NR(1),&QWPw(0,$ap));
37 &ld(($b[0])=&NR(1),&QWPw(0,$bp));
38 &ld(($a[1])=&NR(1),&QWPw(1,$ap));
39 &ld(($b[1])=&NR(1),&QWPw(1,$bp));
40 &ld(($a[2])=&NR(1),&QWPw(2,$ap));
41 &ld(($b[2])=&NR(1),&QWPw(2,$bp));
42 &ld(($a[3])=&NR(1),&QWPw(3,$ap)); &FR($ap);
43 &ld(($b[3])=&NR(1),&QWPw(3,$bp)); &FR($bp);
44
45 ($c0,$c1,$c2)=&NR(3);
46 &mov("zero",$c2);
47 &mul($a[0],$b[0],$c0);
48 &muh($a[0],$b[0],$c1);
49 &st($c0,&QWPw(0,$rp)); &FR($c0); ($c0)=&NR($c0);
50 ($c0,$c1,$c2)=($c1,$c2,$c0);
51 &mov("zero",$c2);
52
53 &mul_add_c($a[0],$b[1],$c0,$c1,$c2);
54 &mul_add_c($a[1],$b[0],$c0,$c1,$c2);
55 &st($c0,&QWPw(1,$rp)); &FR($c0); ($c0)=&NR($c0);
56 ($c0,$c1,$c2)=($c1,$c2,$c0);
57 &mov("zero",$c2);
58
59 &mul_add_c($a[1],$b[1],$c0,$c1,$c2);
60 &mul_add_c($a[0],$b[2],$c0,$c1,$c2);
61 &mul_add_c($a[2],$b[0],$c0,$c1,$c2);
62 &st($c0,&QWPw(2,$rp)); &FR($c0); ($c0)=&NR($c0);
63 ($c0,$c1,$c2)=($c1,$c2,$c0);
64 &mov("zero",$c2);
65
66 &mul_add_c($a[0],$b[3],$c0,$c1,$c2); &FR($a[0]);
67 &mul_add_c($a[1],$b[2],$c0,$c1,$c2);
68 &mul_add_c($a[2],$b[1],$c0,$c1,$c2);
69 &mul_add_c($a[3],$b[0],$c0,$c1,$c2); &FR($b[0]);
70 &st($c0,&QWPw(3,$rp)); &FR($c0); ($c0)=&NR($c0);
71 ($c0,$c1,$c2)=($c1,$c2,$c0);
72 &mov("zero",$c2);
73
74 &mul_add_c($a[1],$b[3],$c0,$c1,$c2); &FR($a[1]);
75 &mul_add_c($a[2],$b[2],$c0,$c1,$c2);
76 &mul_add_c($a[3],$b[1],$c0,$c1,$c2); &FR($b[1]);
77 &st($c0,&QWPw(4,$rp)); &FR($c0); ($c0)=&NR($c0);
78 ($c0,$c1,$c2)=($c1,$c2,$c0);
79 &mov("zero",$c2);
80
81 &mul_add_c($a[2],$b[3],$c0,$c1,$c2); &FR($a[2]);
82 &mul_add_c($a[3],$b[2],$c0,$c1,$c2); &FR($b[2]);
83 &st($c0,&QWPw(5,$rp)); &FR($c0); ($c0)=&NR($c0);
84 ($c0,$c1,$c2)=($c1,$c2,$c0);
85 &mov("zero",$c2);
86
87 &mul_add_c($a[3],$b[3],$c0,$c1,$c2); &FR($a[3],$b[3]);
88 &st($c0,&QWPw(6,$rp));
89 &st($c1,&QWPw(7,$rp));
90
91 &FR($c0,$c1,$c2);
92
93 &function_end($name);
94
95 &fin_pool;
96 }
97
981;
diff --git a/src/lib/libcrypto/bn/asm/alpha/mul_c8.pl b/src/lib/libcrypto/bn/asm/alpha/mul_c8.pl
deleted file mode 100644
index 525ca7494b..0000000000
--- a/src/lib/libcrypto/bn/asm/alpha/mul_c8.pl
+++ /dev/null
@@ -1,177 +0,0 @@
1#!/usr/local/bin/perl
2# alpha assember
3
4sub bn_mul_comba8
5 {
6 local($name)=@_;
7 local(@a,@b,$r,$c0,$c1,$c2);
8
9 $cnt=1;
10 &init_pool(3);
11
12 $rp=&wparam(0);
13 $ap=&wparam(1);
14 $bp=&wparam(2);
15
16 &function_begin($name,"");
17
18 &comment("");
19
20 &stack_push(2);
21 &ld(($a[0])=&NR(1),&QWPw(0,$ap));
22 &ld(($b[0])=&NR(1),&QWPw(0,$bp));
23 &st($reg_s0,&swtmp(0)); &FR($reg_s0);
24 &st($reg_s1,&swtmp(1)); &FR($reg_s1);
25 &ld(($a[1])=&NR(1),&QWPw(1,$ap));
26 &ld(($b[1])=&NR(1),&QWPw(1,$bp));
27 &ld(($a[2])=&NR(1),&QWPw(2,$ap));
28 &ld(($b[2])=&NR(1),&QWPw(2,$bp));
29 &ld(($a[3])=&NR(1),&QWPw(3,$ap));
30 &ld(($b[3])=&NR(1),&QWPw(3,$bp));
31 &ld(($a[4])=&NR(1),&QWPw(1,$ap));
32 &ld(($b[4])=&NR(1),&QWPw(1,$bp));
33 &ld(($a[5])=&NR(1),&QWPw(1,$ap));
34 &ld(($b[5])=&NR(1),&QWPw(1,$bp));
35 &ld(($a[6])=&NR(1),&QWPw(1,$ap));
36 &ld(($b[6])=&NR(1),&QWPw(1,$bp));
37 &ld(($a[7])=&NR(1),&QWPw(1,$ap)); &FR($ap);
38 &ld(($b[7])=&NR(1),&QWPw(1,$bp)); &FR($bp);
39
40 ($c0,$c1,$c2)=&NR(3);
41 &mov("zero",$c2);
42 &mul($a[0],$b[0],$c0);
43 &muh($a[0],$b[0],$c1);
44 &st($c0,&QWPw(0,$rp)); &FR($c0); ($c0)=&NR(1);
45 ($c0,$c1,$c2)=($c1,$c2,$c0);
46 &mov("zero",$c2);
47
48 &mul_add_c($a[0],$b[1],$c0,$c1,$c2);
49 &mul_add_c($a[1],$b[0],$c0,$c1,$c2);
50 &st($c0,&QWPw(1,$rp)); &FR($c0); ($c0)=&NR(1);
51 ($c0,$c1,$c2)=($c1,$c2,$c0);
52 &mov("zero",$c2);
53
54 &mul_add_c($a[0],$b[2],$c0,$c1,$c2);
55 &mul_add_c($a[1],$b[1],$c0,$c1,$c2);
56 &mul_add_c($a[2],$b[0],$c0,$c1,$c2);
57 &st($c0,&QWPw(2,$rp)); &FR($c0); ($c0)=&NR(1);
58 ($c0,$c1,$c2)=($c1,$c2,$c0);
59 &mov("zero",$c2);
60
61 &mul_add_c($a[0],$b[3],$c0,$c1,$c2);
62 &mul_add_c($a[1],$b[2],$c0,$c1,$c2);
63 &mul_add_c($a[2],$b[1],$c0,$c1,$c2);
64 &mul_add_c($a[3],$b[0],$c0,$c1,$c2);
65 &st($c0,&QWPw(3,$rp)); &FR($c0); ($c0)=&NR(1);
66 ($c0,$c1,$c2)=($c1,$c2,$c0);
67 &mov("zero",$c2);
68
69 &mul_add_c($a[0],$b[4],$c0,$c1,$c2);
70 &mul_add_c($a[1],$b[3],$c0,$c1,$c2);
71 &mul_add_c($a[2],$b[2],$c0,$c1,$c2);
72 &mul_add_c($a[3],$b[1],$c0,$c1,$c2);
73 &mul_add_c($a[4],$b[0],$c0,$c1,$c2);
74 &st($c0,&QWPw(4,$rp)); &FR($c0); ($c0)=&NR(1);
75 ($c0,$c1,$c2)=($c1,$c2,$c0);
76 &mov("zero",$c2);
77
78 &mul_add_c($a[0],$b[5],$c0,$c1,$c2);
79 &mul_add_c($a[1],$b[4],$c0,$c1,$c2);
80 &mul_add_c($a[2],$b[3],$c0,$c1,$c2);
81 &mul_add_c($a[3],$b[2],$c0,$c1,$c2);
82 &mul_add_c($a[4],$b[1],$c0,$c1,$c2);
83 &mul_add_c($a[5],$b[0],$c0,$c1,$c2);
84 &st($c0,&QWPw(5,$rp)); &FR($c0); ($c0)=&NR(1);
85 ($c0,$c1,$c2)=($c1,$c2,$c0);
86 &mov("zero",$c2);
87
88 &mul_add_c($a[0],$b[6],$c0,$c1,$c2);
89 &mul_add_c($a[1],$b[5],$c0,$c1,$c2);
90 &mul_add_c($a[2],$b[4],$c0,$c1,$c2);
91 &mul_add_c($a[3],$b[3],$c0,$c1,$c2);
92 &mul_add_c($a[4],$b[2],$c0,$c1,$c2);
93 &mul_add_c($a[5],$b[1],$c0,$c1,$c2);
94 &mul_add_c($a[6],$b[0],$c0,$c1,$c2);
95 &st($c0,&QWPw(6,$rp)); &FR($c0); ($c0)=&NR(1);
96 ($c0,$c1,$c2)=($c1,$c2,$c0);
97 &mov("zero",$c2);
98
99 &mul_add_c($a[0],$b[7],$c0,$c1,$c2); &FR($a[0]);
100 &mul_add_c($a[1],$b[6],$c0,$c1,$c2);
101 &mul_add_c($a[2],$b[5],$c0,$c1,$c2);
102 &mul_add_c($a[3],$b[4],$c0,$c1,$c2);
103 &mul_add_c($a[4],$b[3],$c0,$c1,$c2);
104 &mul_add_c($a[5],$b[2],$c0,$c1,$c2);
105 &mul_add_c($a[6],$b[1],$c0,$c1,$c2);
106 &mul_add_c($a[7],$b[0],$c0,$c1,$c2); &FR($b[0]);
107 &st($c0,&QWPw(7,$rp)); &FR($c0); ($c0)=&NR(1);
108 ($c0,$c1,$c2)=($c1,$c2,$c0);
109 &mov("zero",$c2);
110
111 &mul_add_c($a[1],$b[7],$c0,$c1,$c2); &FR($a[1]);
112 &mul_add_c($a[2],$b[6],$c0,$c1,$c2);
113 &mul_add_c($a[3],$b[5],$c0,$c1,$c2);
114 &mul_add_c($a[4],$b[4],$c0,$c1,$c2);
115 &mul_add_c($a[5],$b[3],$c0,$c1,$c2);
116 &mul_add_c($a[6],$b[2],$c0,$c1,$c2);
117 &mul_add_c($a[7],$b[1],$c0,$c1,$c2); &FR($b[1]);
118 &st($c0,&QWPw(8,$rp)); &FR($c0); ($c0)=&NR(1);
119 ($c0,$c1,$c2)=($c1,$c2,$c0);
120 &mov("zero",$c2);
121
122 &mul_add_c($a[2],$b[7],$c0,$c1,$c2); &FR($a[2]);
123 &mul_add_c($a[3],$b[6],$c0,$c1,$c2);
124 &mul_add_c($a[4],$b[5],$c0,$c1,$c2);
125 &mul_add_c($a[5],$b[4],$c0,$c1,$c2);
126 &mul_add_c($a[6],$b[3],$c0,$c1,$c2);
127 &mul_add_c($a[7],$b[2],$c0,$c1,$c2); &FR($b[2]);
128 &st($c0,&QWPw(9,$rp)); &FR($c0); ($c0)=&NR(1);
129 ($c0,$c1,$c2)=($c1,$c2,$c0);
130 &mov("zero",$c2);
131
132 &mul_add_c($a[3],$b[7],$c0,$c1,$c2); &FR($a[3]);
133 &mul_add_c($a[4],$b[6],$c0,$c1,$c2);
134 &mul_add_c($a[5],$b[5],$c0,$c1,$c2);
135 &mul_add_c($a[6],$b[4],$c0,$c1,$c2);
136 &mul_add_c($a[7],$b[3],$c0,$c1,$c2); &FR($b[3]);
137 &st($c0,&QWPw(10,$rp)); &FR($c0); ($c0)=&NR(1);
138 ($c0,$c1,$c2)=($c1,$c2,$c0);
139 &mov("zero",$c2);
140
141 &mul_add_c($a[4],$b[7],$c0,$c1,$c2); &FR($a[4]);
142 &mul_add_c($a[5],$b[6],$c0,$c1,$c2);
143 &mul_add_c($a[6],$b[5],$c0,$c1,$c2);
144 &mul_add_c($a[7],$b[4],$c0,$c1,$c2); &FR($b[4]);
145 &st($c0,&QWPw(11,$rp)); &FR($c0); ($c0)=&NR(1);
146 ($c0,$c1,$c2)=($c1,$c2,$c0);
147 &mov("zero",$c2);
148
149 &mul_add_c($a[5],$b[7],$c0,$c1,$c2); &FR($a[5]);
150 &mul_add_c($a[6],$b[6],$c0,$c1,$c2);
151 &mul_add_c($a[7],$b[5],$c0,$c1,$c2); &FR($b[5]);
152 &st($c0,&QWPw(12,$rp)); &FR($c0); ($c0)=&NR(1);
153 ($c0,$c1,$c2)=($c1,$c2,$c0);
154 &mov("zero",$c2);
155
156 &mul_add_c($a[6],$b[7],$c0,$c1,$c2); &FR($a[6]);
157 &mul_add_c($a[7],$b[6],$c0,$c1,$c2); &FR($b[6]);
158 &st($c0,&QWPw(13,$rp)); &FR($c0); ($c0)=&NR(1);
159 ($c0,$c1,$c2)=($c1,$c2,$c0);
160 &mov("zero",$c2);
161
162 &mul_add_c($a[7],$b[7],$c0,$c1,$c2); &FR($a[7],$b[7]);
163 &st($c0,&QWPw(14,$rp));
164 &st($c1,&QWPw(15,$rp));
165
166 &FR($c0,$c1,$c2);
167
168 &ld($reg_s0,&swtmp(0));
169 &ld($reg_s1,&swtmp(1));
170 &stack_pop(2);
171
172 &function_end($name);
173
174 &fin_pool;
175 }
176
1771;
diff --git a/src/lib/libcrypto/bn/asm/alpha/sqr.pl b/src/lib/libcrypto/bn/asm/alpha/sqr.pl
deleted file mode 100644
index a55b696906..0000000000
--- a/src/lib/libcrypto/bn/asm/alpha/sqr.pl
+++ /dev/null
@@ -1,113 +0,0 @@
1#!/usr/local/bin/perl
2# alpha assember
3
4sub bn_sqr_words
5 {
6 local($name)=@_;
7 local($cc,$a,$b,$r,$couny);
8
9 &init_pool(3);
10 ($cc)=GR("r0");
11
12 $rp=&wparam(0);
13 $ap=&wparam(1);
14 $count=&wparam(2);
15
16 &function_begin($name,"");
17
18 &comment("");
19 &sub($count,4,$count);
20 &mov("zero",$cc);
21 &br(&label("finish"));
22 &blt($count,&label("finish"));
23
24 ($a0,$r0)=&NR(2);
25 &ld($a0,&QWPw(0,$ap));
26 &ld($r0,&QWPw(0,$rp));
27
28$a=<<'EOF';
29##########################################################
30 &set_label("loop");
31
32 ($a1)=&NR(1); &ld($a1,&QWPw(1,$ap));
33 ($b1)=&NR(1); &ld($b1,&QWPw(1,$bp));
34 ($a2)=&NR(1); &ld($a2,&QWPw(2,$ap));
35 ($b2)=&NR(1); &ld($b2,&QWPw(2,$bp));
36 ($a3)=&NR(1); &ld($a3,&QWPw(3,$ap));
37 ($b3)=&NR(1); &ld($b3,&QWPw(3,$bp));
38
39 ($o0,$t0)=&NR(2);
40 &add($a0,$b0,$o0);
41 &cmpult($o0,$b0,$t0);
42 &add($o0,$cc,$o0);
43 &cmpult($o0,$cc,$cc);
44 &add($cc,$t0,$cc); &FR($t0);
45
46 ($t1,$o1)=&NR(2);
47
48 &add($a1,$b1,$o1); &FR($a1);
49 &cmpult($o1,$b1,$t1); &FR($b1);
50 &add($o1,$cc,$o1);
51 &cmpult($o1,$cc,$cc);
52 &add($cc,$t1,$cc); &FR($t1);
53
54 ($t2,$o2)=&NR(2);
55
56 &add($a2,$b2,$o2); &FR($a2);
57 &cmpult($o2,$b2,$t2); &FR($b2);
58 &add($o2,$cc,$o2);
59 &cmpult($o2,$cc,$cc);
60 &add($cc,$t2,$cc); &FR($t2);
61
62 ($t3,$o3)=&NR(2);
63
64 &add($a3,$b3,$o3); &FR($a3);
65 &cmpult($o3,$b3,$t3); &FR($b3);
66 &add($o3,$cc,$o3);
67 &cmpult($o3,$cc,$cc);
68 &add($cc,$t3,$cc); &FR($t3);
69
70 &st($o0,&QWPw(0,$rp)); &FR($o0);
71 &st($o1,&QWPw(0,$rp)); &FR($o1);
72 &st($o2,&QWPw(0,$rp)); &FR($o2);
73 &st($o3,&QWPw(0,$rp)); &FR($o3);
74
75 &sub($count,4,$count); # count-=4
76 &add($ap,4*$QWS,$ap); # count+=4
77 &add($bp,4*$QWS,$bp); # count+=4
78 &add($rp,4*$QWS,$rp); # count+=4
79
80 &blt($count,&label("finish"));
81 &ld($a0,&QWPw(0,$ap));
82 &ld($b0,&QWPw(0,$bp));
83 &br(&label("loop"));
84EOF
85##################################################
86 # Do the last 0..3 words
87
88 &set_label("last_loop");
89
90 &ld(($a0)=&NR(1),&QWPw(0,$ap)); # get a
91 &mul($a0,$a0,($l0)=&NR(1));
92 &add($ap,$QWS,$ap);
93 &add($rp,2*$QWS,$rp);
94 &sub($count,1,$count);
95 &muh($a0,$a0,($h0)=&NR(1)); &FR($a0);
96 &st($l0,&QWPw(-2,$rp)); &FR($l0);
97 &st($h0,&QWPw(-1,$rp)); &FR($h0);
98
99 &bgt($count,&label("last_loop"));
100 &function_end_A($name);
101
102######################################################
103 &set_label("finish");
104 &add($count,4,$count);
105 &bgt($count,&label("last_loop"));
106
107 &set_label("end");
108 &function_end($name);
109
110 &fin_pool;
111 }
112
1131;
diff --git a/src/lib/libcrypto/bn/asm/alpha/sqr_c4.pl b/src/lib/libcrypto/bn/asm/alpha/sqr_c4.pl
deleted file mode 100644
index bf33f5b503..0000000000
--- a/src/lib/libcrypto/bn/asm/alpha/sqr_c4.pl
+++ /dev/null
@@ -1,109 +0,0 @@
1#!/usr/local/bin/perl
2# alpha assember
3
4sub sqr_add_c
5 {
6 local($a,$c0,$c1,$c2)=@_;
7 local($l1,$h1,$t1,$t2);
8
9 &mul($a,$a,($l1)=&NR(1));
10 &muh($a,$a,($h1)=&NR(1));
11 &add($c0,$l1,$c0);
12 &add($c1,$h1,$c1);
13 &cmpult($c0,$l1,($t1)=&NR(1)); &FR($l1);
14 &cmpult($c1,$h1,($t2)=&NR(1)); &FR($h1);
15 &add($c1,$t1,$c1); &FR($t1);
16 &add($c2,$t2,$c2); &FR($t2);
17 }
18
19sub sqr_add_c2
20 {
21 local($a,$b,$c0,$c1,$c2)=@_;
22 local($l1,$h1,$t1,$t2);
23
24 &mul($a,$b,($l1)=&NR(1));
25 &muh($a,$b,($h1)=&NR(1));
26 &cmplt($l1,"zero",($lc1)=&NR(1));
27 &cmplt($h1,"zero",($hc1)=&NR(1));
28 &add($l1,$l1,$l1);
29 &add($h1,$h1,$h1);
30 &add($h1,$lc1,$h1); &FR($lc1);
31 &add($c2,$hc1,$c2); &FR($hc1);
32
33 &add($c0,$l1,$c0);
34 &add($c1,$h1,$c1);
35 &cmpult($c0,$l1,($lc1)=&NR(1)); &FR($l1);
36 &cmpult($c1,$h1,($hc1)=&NR(1)); &FR($h1);
37
38 &add($c1,$lc1,$c1); &FR($lc1);
39 &add($c2,$hc1,$c2); &FR($hc1);
40 }
41
42
43sub bn_sqr_comba4
44 {
45 local($name)=@_;
46 local(@a,@b,$r,$c0,$c1,$c2);
47
48 $cnt=1;
49 &init_pool(2);
50
51 $rp=&wparam(0);
52 $ap=&wparam(1);
53
54 &function_begin($name,"");
55
56 &comment("");
57
58 &ld(($a[0])=&NR(1),&QWPw(0,$ap));
59 &ld(($a[1])=&NR(1),&QWPw(1,$ap));
60 &ld(($a[2])=&NR(1),&QWPw(2,$ap));
61 &ld(($a[3])=&NR(1),&QWPw(3,$ap)); &FR($ap);
62
63 ($c0,$c1,$c2)=&NR(3);
64
65 &mov("zero",$c2);
66 &mul($a[0],$a[0],$c0);
67 &muh($a[0],$a[0],$c1);
68 &st($c0,&QWPw(0,$rp));
69 ($c0,$c1,$c2)=($c1,$c2,$c0);
70 &mov("zero",$c2);
71
72 &sqr_add_c2($a[0],$a[1],$c0,$c1,$c2);
73 &st($c0,&QWPw(1,$rp));
74 ($c0,$c1,$c2)=($c1,$c2,$c0);
75 &mov("zero",$c2);
76
77 &sqr_add_c($a[1],$c0,$c1,$c2);
78 &sqr_add_c2($a[2],$a[0],$c0,$c1,$c2);
79 &st($c0,&QWPw(2,$rp));
80 ($c0,$c1,$c2)=($c1,$c2,$c0);
81 &mov("zero",$c2);
82
83 &sqr_add_c2($a[3],$a[0],$c0,$c1,$c2);
84 &sqr_add_c2($a[2],$a[1],$c0,$c1,$c2);
85 &st($c0,&QWPw(3,$rp));
86 ($c0,$c1,$c2)=($c1,$c2,$c0);
87 &mov("zero",$c2);
88
89 &sqr_add_c($a[2],$c0,$c1,$c2);
90 &sqr_add_c2($a[3],$a[1],$c0,$c1,$c2);
91 &st($c0,&QWPw(4,$rp));
92 ($c0,$c1,$c2)=($c1,$c2,$c0);
93 &mov("zero",$c2);
94
95 &sqr_add_c2($a[3],$a[2],$c0,$c1,$c2);
96 &st($c0,&QWPw(5,$rp));
97 ($c0,$c1,$c2)=($c1,$c2,$c0);
98 &mov("zero",$c2);
99
100 &sqr_add_c($a[3],$c0,$c1,$c2);
101 &st($c0,&QWPw(6,$rp));
102 &st($c1,&QWPw(7,$rp));
103
104 &function_end($name);
105
106 &fin_pool;
107 }
108
1091;
diff --git a/src/lib/libcrypto/bn/asm/alpha/sqr_c8.pl b/src/lib/libcrypto/bn/asm/alpha/sqr_c8.pl
deleted file mode 100644
index b4afe085f1..0000000000
--- a/src/lib/libcrypto/bn/asm/alpha/sqr_c8.pl
+++ /dev/null
@@ -1,132 +0,0 @@
1#!/usr/local/bin/perl
2# alpha assember
3
4sub bn_sqr_comba8
5 {
6 local($name)=@_;
7 local(@a,@b,$r,$c0,$c1,$c2);
8
9 $cnt=1;
10 &init_pool(2);
11
12 $rp=&wparam(0);
13 $ap=&wparam(1);
14
15 &function_begin($name,"");
16
17 &comment("");
18
19 &ld(($a[0])=&NR(1),&QWPw(0,$ap));
20 &ld(($a[1])=&NR(1),&QWPw(1,$ap));
21 &ld(($a[2])=&NR(1),&QWPw(2,$ap));
22 &ld(($a[3])=&NR(1),&QWPw(3,$ap));
23 &ld(($a[4])=&NR(1),&QWPw(4,$ap));
24 &ld(($a[5])=&NR(1),&QWPw(5,$ap));
25 &ld(($a[6])=&NR(1),&QWPw(6,$ap));
26 &ld(($a[7])=&NR(1),&QWPw(7,$ap)); &FR($ap);
27
28 ($c0,$c1,$c2)=&NR(3);
29
30 &mov("zero",$c2);
31 &mul($a[0],$a[0],$c0);
32 &muh($a[0],$a[0],$c1);
33 &st($c0,&QWPw(0,$rp));
34 ($c0,$c1,$c2)=($c1,$c2,$c0);
35 &mov("zero",$c2);
36
37 &sqr_add_c2($a[1],$a[0],$c0,$c1,$c2);
38 &st($c0,&QWPw(1,$rp));
39 ($c0,$c1,$c2)=($c1,$c2,$c0);
40 &mov("zero",$c2);
41
42 &sqr_add_c($a[1],$c0,$c1,$c2);
43 &sqr_add_c2($a[2],$a[0],$c0,$c1,$c2);
44 &st($c0,&QWPw(2,$rp));
45 ($c0,$c1,$c2)=($c1,$c2,$c0);
46 &mov("zero",$c2);
47
48 &sqr_add_c2($a[2],$a[1],$c0,$c1,$c2);
49 &sqr_add_c2($a[3],$a[0],$c0,$c1,$c2);
50 &st($c0,&QWPw(3,$rp));
51 ($c0,$c1,$c2)=($c1,$c2,$c0);
52 &mov("zero",$c2);
53
54 &sqr_add_c($a[2],$c0,$c1,$c2);
55 &sqr_add_c2($a[3],$a[1],$c0,$c1,$c2);
56 &sqr_add_c2($a[4],$a[0],$c0,$c1,$c2);
57 &st($c0,&QWPw(4,$rp));
58 ($c0,$c1,$c2)=($c1,$c2,$c0);
59 &mov("zero",$c2);
60
61 &sqr_add_c2($a[3],$a[2],$c0,$c1,$c2);
62 &sqr_add_c2($a[4],$a[1],$c0,$c1,$c2);
63 &sqr_add_c2($a[5],$a[0],$c0,$c1,$c2);
64 &st($c0,&QWPw(5,$rp));
65 ($c0,$c1,$c2)=($c1,$c2,$c0);
66 &mov("zero",$c2);
67
68 &sqr_add_c($a[3],$c0,$c1,$c2);
69 &sqr_add_c2($a[4],$a[2],$c0,$c1,$c2);
70 &sqr_add_c2($a[5],$a[1],$c0,$c1,$c2);
71 &sqr_add_c2($a[6],$a[0],$c0,$c1,$c2);
72 &st($c0,&QWPw(6,$rp));
73 ($c0,$c1,$c2)=($c1,$c2,$c0);
74 &mov("zero",$c2);
75
76 &sqr_add_c2($a[4],$a[3],$c0,$c1,$c2);
77 &sqr_add_c2($a[5],$a[2],$c0,$c1,$c2);
78 &sqr_add_c2($a[6],$a[1],$c0,$c1,$c2);
79 &sqr_add_c2($a[7],$a[0],$c0,$c1,$c2);
80 &st($c0,&QWPw(7,$rp));
81 ($c0,$c1,$c2)=($c1,$c2,$c0);
82 &mov("zero",$c2);
83
84 &sqr_add_c($a[4],$c0,$c1,$c2);
85 &sqr_add_c2($a[5],$a[3],$c0,$c1,$c2);
86 &sqr_add_c2($a[6],$a[2],$c0,$c1,$c2);
87 &sqr_add_c2($a[7],$a[1],$c0,$c1,$c2);
88 &st($c0,&QWPw(8,$rp));
89 ($c0,$c1,$c2)=($c1,$c2,$c0);
90 &mov("zero",$c2);
91
92 &sqr_add_c2($a[5],$a[4],$c0,$c1,$c2);
93 &sqr_add_c2($a[6],$a[3],$c0,$c1,$c2);
94 &sqr_add_c2($a[7],$a[2],$c0,$c1,$c2);
95 &st($c0,&QWPw(9,$rp));
96 ($c0,$c1,$c2)=($c1,$c2,$c0);
97 &mov("zero",$c2);
98
99 &sqr_add_c($a[5],$c0,$c1,$c2);
100 &sqr_add_c2($a[6],$a[4],$c0,$c1,$c2);
101 &sqr_add_c2($a[7],$a[3],$c0,$c1,$c2);
102 &st($c0,&QWPw(10,$rp));
103 ($c0,$c1,$c2)=($c1,$c2,$c0);
104 &mov("zero",$c2);
105
106 &sqr_add_c2($a[6],$a[5],$c0,$c1,$c2);
107 &sqr_add_c2($a[7],$a[4],$c0,$c1,$c2);
108 &st($c0,&QWPw(11,$rp));
109 ($c0,$c1,$c2)=($c1,$c2,$c0);
110 &mov("zero",$c2);
111
112 &sqr_add_c($a[6],$c0,$c1,$c2);
113 &sqr_add_c2($a[7],$a[5],$c0,$c1,$c2);
114 &st($c0,&QWPw(12,$rp));
115 ($c0,$c1,$c2)=($c1,$c2,$c0);
116 &mov("zero",$c2);
117
118 &sqr_add_c2($a[7],$a[6],$c0,$c1,$c2);
119 &st($c0,&QWPw(13,$rp));
120 ($c0,$c1,$c2)=($c1,$c2,$c0);
121 &mov("zero",$c2);
122
123 &sqr_add_c($a[7],$c0,$c1,$c2);
124 &st($c0,&QWPw(14,$rp));
125 &st($c1,&QWPw(15,$rp));
126
127 &function_end($name);
128
129 &fin_pool;
130 }
131
1321;
diff --git a/src/lib/libcrypto/bn/asm/alpha/sub.pl b/src/lib/libcrypto/bn/asm/alpha/sub.pl
deleted file mode 100644
index d998da5c21..0000000000
--- a/src/lib/libcrypto/bn/asm/alpha/sub.pl
+++ /dev/null
@@ -1,108 +0,0 @@
1#!/usr/local/bin/perl
2# alpha assember
3
4sub bn_sub_words
5 {
6 local($name)=@_;
7 local($cc,$a,$b,$r);
8
9 &init_pool(4);
10 ($cc)=GR("r0");
11
12 $rp=&wparam(0);
13 $ap=&wparam(1);
14 $bp=&wparam(2);
15 $count=&wparam(3);
16
17 &function_begin($name,"");
18
19 &comment("");
20 &sub($count,4,$count);
21 &mov("zero",$cc);
22 &blt($count,&label("finish"));
23
24 ($a0,$b0)=&NR(2);
25 &ld($a0,&QWPw(0,$ap));
26 &ld($b0,&QWPw(0,$bp));
27
28##########################################################
29 &set_label("loop");
30
31 ($a1,$tmp,$b1,$a2,$b2,$a3,$b3,$o0)=&NR(8);
32 &ld($a1,&QWPw(1,$ap));
33 &cmpult($a0,$b0,$tmp); # will we borrow?
34 &ld($b1,&QWPw(1,$bp));
35 &sub($a0,$b0,$a0); # do the subtract
36 &ld($a2,&QWPw(2,$ap));
37 &cmpult($a0,$cc,$b0); # will we borrow?
38 &ld($b2,&QWPw(2,$bp));
39 &sub($a0,$cc,$o0); # will we borrow?
40 &ld($a3,&QWPw(3,$ap));
41 &add($b0,$tmp,$cc); ($t1,$o1)=&NR(2); &FR($tmp);
42
43 &cmpult($a1,$b1,$t1); # will we borrow?
44 &sub($a1,$b1,$a1); # do the subtract
45 &ld($b3,&QWPw(3,$bp));
46 &cmpult($a1,$cc,$b1); # will we borrow?
47 &sub($a1,$cc,$o1); # will we borrow?
48 &add($b1,$t1,$cc); ($tmp,$o2)=&NR(2); &FR($t1,$a1,$b1);
49
50 &cmpult($a2,$b2,$tmp); # will we borrow?
51 &sub($a2,$b2,$a2); # do the subtract
52 &st($o0,&QWPw(0,$rp)); &FR($o0); # save
53 &cmpult($a2,$cc,$b2); # will we borrow?
54 &sub($a2,$cc,$o2); # will we borrow?
55 &add($b2,$tmp,$cc); ($t3,$o3)=&NR(2); &FR($tmp,$a2,$b2);
56
57 &cmpult($a3,$b3,$t3); # will we borrow?
58 &sub($a3,$b3,$a3); # do the subtract
59 &st($o1,&QWPw(1,$rp)); &FR($o1);
60 &cmpult($a3,$cc,$b3); # will we borrow?
61 &sub($a3,$cc,$o3); # will we borrow?
62 &add($b3,$t3,$cc); &FR($t3,$a3,$b3);
63
64 &st($o2,&QWPw(2,$rp)); &FR($o2);
65 &sub($count,4,$count); # count-=4
66 &st($o3,&QWPw(3,$rp)); &FR($o3);
67 &add($ap,4*$QWS,$ap); # count+=4
68 &add($bp,4*$QWS,$bp); # count+=4
69 &add($rp,4*$QWS,$rp); # count+=4
70
71 &blt($count,&label("finish"));
72 &ld($a0,&QWPw(0,$ap));
73 &ld($b0,&QWPw(0,$bp));
74 &br(&label("loop"));
75##################################################
76 # Do the last 0..3 words
77
78 &set_label("last_loop");
79
80 &ld($a0,&QWPw(0,$ap)); # get a
81 &ld($b0,&QWPw(0,$bp)); # get b
82 &cmpult($a0,$b0,$tmp); # will we borrow?
83 &sub($a0,$b0,$a0); # do the subtract
84 &cmpult($a0,$cc,$b0); # will we borrow?
85 &sub($a0,$cc,$a0); # will we borrow?
86 &st($a0,&QWPw(0,$rp)); # save
87 &add($b0,$tmp,$cc); # add the borrows
88
89 &add($ap,$QWS,$ap);
90 &add($bp,$QWS,$bp);
91 &add($rp,$QWS,$rp);
92 &sub($count,1,$count);
93 &bgt($count,&label("last_loop"));
94 &function_end_A($name);
95
96######################################################
97 &set_label("finish");
98 &add($count,4,$count);
99 &bgt($count,&label("last_loop"));
100
101 &FR($a0,$b0);
102 &set_label("end");
103 &function_end($name);
104
105 &fin_pool;
106 }
107
1081;
diff --git a/src/lib/libcrypto/bn/asm/bn-586.pl b/src/lib/libcrypto/bn/asm/bn-586.pl
index 26c2685a72..332ef3e91d 100644
--- a/src/lib/libcrypto/bn/asm/bn-586.pl
+++ b/src/lib/libcrypto/bn/asm/bn-586.pl
@@ -1,6 +1,7 @@
1#!/usr/local/bin/perl 1#!/usr/local/bin/perl
2 2
3push(@INC,"perlasm","../../perlasm"); 3$0 =~ m/(.*[\/\\])[^\/\\]+$/; $dir=$1;
4push(@INC,"${dir}","${dir}../../perlasm");
4require "x86asm.pl"; 5require "x86asm.pl";
5 6
6&asm_init($ARGV[0],$0); 7&asm_init($ARGV[0],$0);
@@ -24,38 +25,25 @@ sub bn_mul_add_words
24 { 25 {
25 local($name)=@_; 26 local($name)=@_;
26 27
27 &function_begin($name,$sse2?"EXTRN\t_OPENSSL_ia32cap_P:DWORD":""); 28 &function_begin_B($name,$sse2?"EXTRN\t_OPENSSL_ia32cap_P:DWORD":"");
28 29
29 &comment(""); 30 $r="eax";
30 $Low="eax"; 31 $a="edx";
31 $High="edx"; 32 $c="ecx";
32 $a="ebx";
33 $w="ebp";
34 $r="edi";
35 $c="esi";
36
37 &xor($c,$c); # clear carry
38 &mov($r,&wparam(0)); #
39
40 &mov("ecx",&wparam(2)); #
41 &mov($a,&wparam(1)); #
42
43 &and("ecx",0xfffffff8); # num / 8
44 &mov($w,&wparam(3)); #
45
46 &push("ecx"); # Up the stack for a tmp variable
47
48 &jz(&label("maw_finish"));
49 33
50 if ($sse2) { 34 if ($sse2) {
51 &picmeup("eax","OPENSSL_ia32cap_P"); 35 &picmeup("eax","OPENSSL_ia32cap_P");
52 &bt(&DWP(0,"eax"),26); 36 &bt(&DWP(0,"eax"),26);
53 &jnc(&label("maw_loop")); 37 &jnc(&label("maw_non_sse2"));
54 38
55 &movd("mm0",$w); # mm0 = w 39 &mov($r,&wparam(0));
40 &mov($a,&wparam(1));
41 &mov($c,&wparam(2));
42 &movd("mm0",&wparam(3)); # mm0 = w
56 &pxor("mm1","mm1"); # mm1 = carry_in 43 &pxor("mm1","mm1"); # mm1 = carry_in
57 44 &jmp(&label("maw_sse2_entry"));
58 &set_label("maw_sse2_loop",0); 45
46 &set_label("maw_sse2_unrolled",16);
59 &movd("mm3",&DWP(0,$r,"",0)); # mm3 = r[0] 47 &movd("mm3",&DWP(0,$r,"",0)); # mm3 = r[0]
60 &paddq("mm1","mm3"); # mm1 = carry_in + r[0] 48 &paddq("mm1","mm3"); # mm1 = carry_in + r[0]
61 &movd("mm2",&DWP(0,$a,"",0)); # mm2 = a[0] 49 &movd("mm2",&DWP(0,$a,"",0)); # mm2 = a[0]
@@ -112,42 +100,82 @@ sub bn_mul_add_words
112 &psrlq("mm1",32); # mm1 = carry6 100 &psrlq("mm1",32); # mm1 = carry6
113 &paddq("mm1","mm3"); # mm1 = carry6 + r[7] + w*a[7] 101 &paddq("mm1","mm3"); # mm1 = carry6 + r[7] + w*a[7]
114 &movd(&DWP(28,$r,"",0),"mm1"); 102 &movd(&DWP(28,$r,"",0),"mm1");
115 &add($r,32); 103 &lea($r,&DWP(32,$r));
116 &psrlq("mm1",32); # mm1 = carry_out 104 &psrlq("mm1",32); # mm1 = carry_out
117 105
118 &sub("ecx",8); 106 &sub($c,8);
107 &jz(&label("maw_sse2_exit"));
108 &set_label("maw_sse2_entry");
109 &test($c,0xfffffff8);
110 &jnz(&label("maw_sse2_unrolled"));
111
112 &set_label("maw_sse2_loop",4);
113 &movd("mm2",&DWP(0,$a)); # mm2 = a[i]
114 &movd("mm3",&DWP(0,$r)); # mm3 = r[i]
115 &pmuludq("mm2","mm0"); # a[i] *= w
116 &lea($a,&DWP(4,$a));
117 &paddq("mm1","mm3"); # carry += r[i]
118 &paddq("mm1","mm2"); # carry += a[i]*w
119 &movd(&DWP(0,$r),"mm1"); # r[i] = carry_low
120 &sub($c,1);
121 &psrlq("mm1",32); # carry = carry_high
122 &lea($r,&DWP(4,$r));
119 &jnz(&label("maw_sse2_loop")); 123 &jnz(&label("maw_sse2_loop"));
120 124 &set_label("maw_sse2_exit");
121 &movd($c,"mm1"); # c = carry_out 125 &movd("eax","mm1"); # c = carry_out
122 &emms(); 126 &emms();
127 &ret();
123 128
124 &jmp(&label("maw_finish")); 129 &set_label("maw_non_sse2",16);
125 } 130 }
126 131
127 &set_label("maw_loop",0); 132 # function_begin prologue
133 &push("ebp");
134 &push("ebx");
135 &push("esi");
136 &push("edi");
137
138 &comment("");
139 $Low="eax";
140 $High="edx";
141 $a="ebx";
142 $w="ebp";
143 $r="edi";
144 $c="esi";
145
146 &xor($c,$c); # clear carry
147 &mov($r,&wparam(0)); #
148
149 &mov("ecx",&wparam(2)); #
150 &mov($a,&wparam(1)); #
151
152 &and("ecx",0xfffffff8); # num / 8
153 &mov($w,&wparam(3)); #
128 154
129 &mov(&swtmp(0),"ecx"); # 155 &push("ecx"); # Up the stack for a tmp variable
156
157 &jz(&label("maw_finish"));
158
159 &set_label("maw_loop",16);
130 160
131 for ($i=0; $i<32; $i+=4) 161 for ($i=0; $i<32; $i+=4)
132 { 162 {
133 &comment("Round $i"); 163 &comment("Round $i");
134 164
135 &mov("eax",&DWP($i,$a,"",0)); # *a 165 &mov("eax",&DWP($i,$a)); # *a
136 &mul($w); # *a * w 166 &mul($w); # *a * w
137 &add("eax",$c); # L(t)+= *r 167 &add("eax",$c); # L(t)+= c
138 &mov($c,&DWP($i,$r,"",0)); # L(t)+= *r
139 &adc("edx",0); # H(t)+=carry 168 &adc("edx",0); # H(t)+=carry
140 &add("eax",$c); # L(t)+=c 169 &add("eax",&DWP($i,$r)); # L(t)+= *r
141 &adc("edx",0); # H(t)+=carry 170 &adc("edx",0); # H(t)+=carry
142 &mov(&DWP($i,$r,"",0),"eax"); # *r= L(t); 171 &mov(&DWP($i,$r),"eax"); # *r= L(t);
143 &mov($c,"edx"); # c= H(t); 172 &mov($c,"edx"); # c= H(t);
144 } 173 }
145 174
146 &comment(""); 175 &comment("");
147 &mov("ecx",&swtmp(0)); #
148 &add($a,32);
149 &add($r,32);
150 &sub("ecx",8); 176 &sub("ecx",8);
177 &lea($a,&DWP(32,$a));
178 &lea($r,&DWP(32,$r));
151 &jnz(&label("maw_loop")); 179 &jnz(&label("maw_loop"));
152 180
153 &set_label("maw_finish",0); 181 &set_label("maw_finish",0);
@@ -160,16 +188,15 @@ sub bn_mul_add_words
160 for ($i=0; $i<7; $i++) 188 for ($i=0; $i<7; $i++)
161 { 189 {
162 &comment("Tail Round $i"); 190 &comment("Tail Round $i");
163 &mov("eax",&DWP($i*4,$a,"",0));# *a 191 &mov("eax",&DWP($i*4,$a)); # *a
164 &mul($w); # *a * w 192 &mul($w); # *a * w
165 &add("eax",$c); # L(t)+=c 193 &add("eax",$c); # L(t)+=c
166 &mov($c,&DWP($i*4,$r,"",0)); # L(t)+= *r
167 &adc("edx",0); # H(t)+=carry 194 &adc("edx",0); # H(t)+=carry
168 &add("eax",$c); 195 &add("eax",&DWP($i*4,$r)); # L(t)+= *r
169 &adc("edx",0); # H(t)+=carry 196 &adc("edx",0); # H(t)+=carry
170 &dec("ecx") if ($i != 7-1); 197 &dec("ecx") if ($i != 7-1);
171 &mov(&DWP($i*4,$r,"",0),"eax"); # *r= L(t); 198 &mov(&DWP($i*4,$r),"eax"); # *r= L(t);
172 &mov($c,"edx"); # c= H(t); 199 &mov($c,"edx"); # c= H(t);
173 &jz(&label("maw_end")) if ($i != 7-1); 200 &jz(&label("maw_end")) if ($i != 7-1);
174 } 201 }
175 &set_label("maw_end",0); 202 &set_label("maw_end",0);
@@ -184,7 +211,45 @@ sub bn_mul_words
184 { 211 {
185 local($name)=@_; 212 local($name)=@_;
186 213
187 &function_begin($name,""); 214 &function_begin_B($name,$sse2?"EXTRN\t_OPENSSL_ia32cap_P:DWORD":"");
215
216 $r="eax";
217 $a="edx";
218 $c="ecx";
219
220 if ($sse2) {
221 &picmeup("eax","OPENSSL_ia32cap_P");
222 &bt(&DWP(0,"eax"),26);
223 &jnc(&label("mw_non_sse2"));
224
225 &mov($r,&wparam(0));
226 &mov($a,&wparam(1));
227 &mov($c,&wparam(2));
228 &movd("mm0",&wparam(3)); # mm0 = w
229 &pxor("mm1","mm1"); # mm1 = carry = 0
230
231 &set_label("mw_sse2_loop",16);
232 &movd("mm2",&DWP(0,$a)); # mm2 = a[i]
233 &pmuludq("mm2","mm0"); # a[i] *= w
234 &lea($a,&DWP(4,$a));
235 &paddq("mm1","mm2"); # carry += a[i]*w
236 &movd(&DWP(0,$r),"mm1"); # r[i] = carry_low
237 &sub($c,1);
238 &psrlq("mm1",32); # carry = carry_high
239 &lea($r,&DWP(4,$r));
240 &jnz(&label("mw_sse2_loop"));
241
242 &movd("eax","mm1"); # return carry
243 &emms();
244 &ret();
245 &set_label("mw_non_sse2",16);
246 }
247
248 # function_begin prologue
249 &push("ebp");
250 &push("ebx");
251 &push("esi");
252 &push("edi");
188 253
189 &comment(""); 254 &comment("");
190 $Low="eax"; 255 $Low="eax";
@@ -257,7 +322,40 @@ sub bn_sqr_words
257 { 322 {
258 local($name)=@_; 323 local($name)=@_;
259 324
260 &function_begin($name,""); 325 &function_begin_B($name,$sse2?"EXTRN\t_OPENSSL_ia32cap_P:DWORD":"");
326
327 $r="eax";
328 $a="edx";
329 $c="ecx";
330
331 if ($sse2) {
332 &picmeup("eax","OPENSSL_ia32cap_P");
333 &bt(&DWP(0,"eax"),26);
334 &jnc(&label("sqr_non_sse2"));
335
336 &mov($r,&wparam(0));
337 &mov($a,&wparam(1));
338 &mov($c,&wparam(2));
339
340 &set_label("sqr_sse2_loop",16);
341 &movd("mm0",&DWP(0,$a)); # mm0 = a[i]
342 &pmuludq("mm0","mm0"); # a[i] *= a[i]
343 &lea($a,&DWP(4,$a)); # a++
344 &movq(&QWP(0,$r),"mm0"); # r[i] = a[i]*a[i]
345 &sub($c,1);
346 &lea($r,&DWP(8,$r)); # r += 2
347 &jnz(&label("sqr_sse2_loop"));
348
349 &emms();
350 &ret();
351 &set_label("sqr_non_sse2",16);
352 }
353
354 # function_begin prologue
355 &push("ebp");
356 &push("ebx");
357 &push("esi");
358 &push("edi");
261 359
262 &comment(""); 360 &comment("");
263 $r="esi"; 361 $r="esi";
@@ -313,12 +411,13 @@ sub bn_div_words
313 { 411 {
314 local($name)=@_; 412 local($name)=@_;
315 413
316 &function_begin($name,""); 414 &function_begin_B($name,"");
317 &mov("edx",&wparam(0)); # 415 &mov("edx",&wparam(0)); #
318 &mov("eax",&wparam(1)); # 416 &mov("eax",&wparam(1)); #
319 &mov("ebx",&wparam(2)); # 417 &mov("ecx",&wparam(2)); #
320 &div("ebx"); 418 &div("ecx");
321 &function_end($name); 419 &ret();
420 &function_end_B($name);
322 } 421 }
323 422
324sub bn_add_words 423sub bn_add_words
diff --git a/src/lib/libcrypto/bn/asm/bn-alpha.pl b/src/lib/libcrypto/bn/asm/bn-alpha.pl
deleted file mode 100644
index 302edf2376..0000000000
--- a/src/lib/libcrypto/bn/asm/bn-alpha.pl
+++ /dev/null
@@ -1,571 +0,0 @@
1#!/usr/local/bin/perl
2# I have this in perl so I can use more usefull register names and then convert
3# them into alpha registers.
4#
5
6$d=&data();
7$d =~ s/CC/0/g;
8$d =~ s/R1/1/g;
9$d =~ s/R2/2/g;
10$d =~ s/R3/3/g;
11$d =~ s/R4/4/g;
12$d =~ s/L1/5/g;
13$d =~ s/L2/6/g;
14$d =~ s/L3/7/g;
15$d =~ s/L4/8/g;
16$d =~ s/O1/22/g;
17$d =~ s/O2/23/g;
18$d =~ s/O3/24/g;
19$d =~ s/O4/25/g;
20$d =~ s/A1/20/g;
21$d =~ s/A2/21/g;
22$d =~ s/A3/27/g;
23$d =~ s/A4/28/g;
24if (0){
25}
26
27print $d;
28
29sub data
30 {
31 local($data)=<<'EOF';
32
33 # DEC Alpha assember
34 # The bn_div_words is actually gcc output but the other parts are hand done.
35 # Thanks to tzeruch@ceddec.com for sending me the gcc output for
36 # bn_div_words.
37 # I've gone back and re-done most of routines.
38 # The key thing to remeber for the 164 CPU is that while a
39 # multiply operation takes 8 cycles, another one can only be issued
40 # after 4 cycles have elapsed. I've done modification to help
41 # improve this. Also, normally, a ld instruction will not be available
42 # for about 3 cycles.
43 .file 1 "bn_asm.c"
44 .set noat
45gcc2_compiled.:
46__gnu_compiled_c:
47 .text
48 .align 3
49 .globl bn_mul_add_words
50 .ent bn_mul_add_words
51bn_mul_add_words:
52bn_mul_add_words..ng:
53 .frame $30,0,$26,0
54 .prologue 0
55 .align 5
56 subq $18,4,$18
57 bis $31,$31,$CC
58 blt $18,$43 # if we are -1, -2, -3 or -4 goto tail code
59 ldq $A1,0($17) # 1 1
60 ldq $R1,0($16) # 1 1
61 .align 3
62$42:
63 mulq $A1,$19,$L1 # 1 2 1 ######
64 ldq $A2,8($17) # 2 1
65 ldq $R2,8($16) # 2 1
66 umulh $A1,$19,$A1 # 1 2 ######
67 ldq $A3,16($17) # 3 1
68 ldq $R3,16($16) # 3 1
69 mulq $A2,$19,$L2 # 2 2 1 ######
70 ldq $A4,24($17) # 4 1
71 addq $R1,$L1,$R1 # 1 2 2
72 ldq $R4,24($16) # 4 1
73 umulh $A2,$19,$A2 # 2 2 ######
74 cmpult $R1,$L1,$O1 # 1 2 3 1
75 addq $A1,$O1,$A1 # 1 3 1
76 addq $R1,$CC,$R1 # 1 2 3 1
77 mulq $A3,$19,$L3 # 3 2 1 ######
78 cmpult $R1,$CC,$CC # 1 2 3 2
79 addq $R2,$L2,$R2 # 2 2 2
80 addq $A1,$CC,$CC # 1 3 2
81 cmpult $R2,$L2,$O2 # 2 2 3 1
82 addq $A2,$O2,$A2 # 2 3 1
83 umulh $A3,$19,$A3 # 3 2 ######
84 addq $R2,$CC,$R2 # 2 2 3 1
85 cmpult $R2,$CC,$CC # 2 2 3 2
86 subq $18,4,$18
87 mulq $A4,$19,$L4 # 4 2 1 ######
88 addq $A2,$CC,$CC # 2 3 2
89 addq $R3,$L3,$R3 # 3 2 2
90 addq $16,32,$16
91 cmpult $R3,$L3,$O3 # 3 2 3 1
92 stq $R1,-32($16) # 1 2 4
93 umulh $A4,$19,$A4 # 4 2 ######
94 addq $A3,$O3,$A3 # 3 3 1
95 addq $R3,$CC,$R3 # 3 2 3 1
96 stq $R2,-24($16) # 2 2 4
97 cmpult $R3,$CC,$CC # 3 2 3 2
98 stq $R3,-16($16) # 3 2 4
99 addq $R4,$L4,$R4 # 4 2 2
100 addq $A3,$CC,$CC # 3 3 2
101 cmpult $R4,$L4,$O4 # 4 2 3 1
102 addq $17,32,$17
103 addq $A4,$O4,$A4 # 4 3 1
104 addq $R4,$CC,$R4 # 4 2 3 1
105 cmpult $R4,$CC,$CC # 4 2 3 2
106 stq $R4,-8($16) # 4 2 4
107 addq $A4,$CC,$CC # 4 3 2
108 blt $18,$43
109
110 ldq $A1,0($17) # 1 1
111 ldq $R1,0($16) # 1 1
112
113 br $42
114
115 .align 4
116$45:
117 ldq $A1,0($17) # 4 1
118 ldq $R1,0($16) # 4 1
119 mulq $A1,$19,$L1 # 4 2 1
120 subq $18,1,$18
121 addq $16,8,$16
122 addq $17,8,$17
123 umulh $A1,$19,$A1 # 4 2
124 addq $R1,$L1,$R1 # 4 2 2
125 cmpult $R1,$L1,$O1 # 4 2 3 1
126 addq $A1,$O1,$A1 # 4 3 1
127 addq $R1,$CC,$R1 # 4 2 3 1
128 cmpult $R1,$CC,$CC # 4 2 3 2
129 addq $A1,$CC,$CC # 4 3 2
130 stq $R1,-8($16) # 4 2 4
131 bgt $18,$45
132 ret $31,($26),1 # else exit
133
134 .align 4
135$43:
136 addq $18,4,$18
137 bgt $18,$45 # goto tail code
138 ret $31,($26),1 # else exit
139
140 .end bn_mul_add_words
141 .align 3
142 .globl bn_mul_words
143 .ent bn_mul_words
144bn_mul_words:
145bn_mul_words..ng:
146 .frame $30,0,$26,0
147 .prologue 0
148 .align 5
149 subq $18,4,$18
150 bis $31,$31,$CC
151 blt $18,$143 # if we are -1, -2, -3 or -4 goto tail code
152 ldq $A1,0($17) # 1 1
153 .align 3
154$142:
155
156 mulq $A1,$19,$L1 # 1 2 1 #####
157 ldq $A2,8($17) # 2 1
158 ldq $A3,16($17) # 3 1
159 umulh $A1,$19,$A1 # 1 2 #####
160 ldq $A4,24($17) # 4 1
161 mulq $A2,$19,$L2 # 2 2 1 #####
162 addq $L1,$CC,$L1 # 1 2 3 1
163 subq $18,4,$18
164 cmpult $L1,$CC,$CC # 1 2 3 2
165 umulh $A2,$19,$A2 # 2 2 #####
166 addq $A1,$CC,$CC # 1 3 2
167 addq $17,32,$17
168 addq $L2,$CC,$L2 # 2 2 3 1
169 mulq $A3,$19,$L3 # 3 2 1 #####
170 cmpult $L2,$CC,$CC # 2 2 3 2
171 addq $A2,$CC,$CC # 2 3 2
172 addq $16,32,$16
173 umulh $A3,$19,$A3 # 3 2 #####
174 stq $L1,-32($16) # 1 2 4
175 mulq $A4,$19,$L4 # 4 2 1 #####
176 addq $L3,$CC,$L3 # 3 2 3 1
177 stq $L2,-24($16) # 2 2 4
178 cmpult $L3,$CC,$CC # 3 2 3 2
179 umulh $A4,$19,$A4 # 4 2 #####
180 addq $A3,$CC,$CC # 3 3 2
181 stq $L3,-16($16) # 3 2 4
182 addq $L4,$CC,$L4 # 4 2 3 1
183 cmpult $L4,$CC,$CC # 4 2 3 2
184
185 addq $A4,$CC,$CC # 4 3 2
186
187 stq $L4,-8($16) # 4 2 4
188
189 blt $18,$143
190
191 ldq $A1,0($17) # 1 1
192
193 br $142
194
195 .align 4
196$145:
197 ldq $A1,0($17) # 4 1
198 mulq $A1,$19,$L1 # 4 2 1
199 subq $18,1,$18
200 umulh $A1,$19,$A1 # 4 2
201 addq $L1,$CC,$L1 # 4 2 3 1
202 addq $16,8,$16
203 cmpult $L1,$CC,$CC # 4 2 3 2
204 addq $17,8,$17
205 addq $A1,$CC,$CC # 4 3 2
206 stq $L1,-8($16) # 4 2 4
207
208 bgt $18,$145
209 ret $31,($26),1 # else exit
210
211 .align 4
212$143:
213 addq $18,4,$18
214 bgt $18,$145 # goto tail code
215 ret $31,($26),1 # else exit
216
217 .end bn_mul_words
218 .align 3
219 .globl bn_sqr_words
220 .ent bn_sqr_words
221bn_sqr_words:
222bn_sqr_words..ng:
223 .frame $30,0,$26,0
224 .prologue 0
225
226 subq $18,4,$18
227 blt $18,$543 # if we are -1, -2, -3 or -4 goto tail code
228 ldq $A1,0($17) # 1 1
229 .align 3
230$542:
231 mulq $A1,$A1,$L1 ######
232 ldq $A2,8($17) # 1 1
233 subq $18,4
234 umulh $A1,$A1,$R1 ######
235 ldq $A3,16($17) # 1 1
236 mulq $A2,$A2,$L2 ######
237 ldq $A4,24($17) # 1 1
238 stq $L1,0($16) # r[0]
239 umulh $A2,$A2,$R2 ######
240 stq $R1,8($16) # r[1]
241 mulq $A3,$A3,$L3 ######
242 stq $L2,16($16) # r[0]
243 umulh $A3,$A3,$R3 ######
244 stq $R2,24($16) # r[1]
245 mulq $A4,$A4,$L4 ######
246 stq $L3,32($16) # r[0]
247 umulh $A4,$A4,$R4 ######
248 stq $R3,40($16) # r[1]
249
250 addq $16,64,$16
251 addq $17,32,$17
252 stq $L4,-16($16) # r[0]
253 stq $R4,-8($16) # r[1]
254
255 blt $18,$543
256 ldq $A1,0($17) # 1 1
257 br $542
258
259$442:
260 ldq $A1,0($17) # a[0]
261 mulq $A1,$A1,$L1 # a[0]*w low part r2
262 addq $16,16,$16
263 addq $17,8,$17
264 subq $18,1,$18
265 umulh $A1,$A1,$R1 # a[0]*w high part r3
266 stq $L1,-16($16) # r[0]
267 stq $R1,-8($16) # r[1]
268
269 bgt $18,$442
270 ret $31,($26),1 # else exit
271
272 .align 4
273$543:
274 addq $18,4,$18
275 bgt $18,$442 # goto tail code
276 ret $31,($26),1 # else exit
277 .end bn_sqr_words
278
279 .align 3
280 .globl bn_add_words
281 .ent bn_add_words
282bn_add_words:
283bn_add_words..ng:
284 .frame $30,0,$26,0
285 .prologue 0
286
287 subq $19,4,$19
288 bis $31,$31,$CC # carry = 0
289 blt $19,$900
290 ldq $L1,0($17) # a[0]
291 ldq $R1,0($18) # b[1]
292 .align 3
293$901:
294 addq $R1,$L1,$R1 # r=a+b;
295 ldq $L2,8($17) # a[1]
296 cmpult $R1,$L1,$O1 # did we overflow?
297 ldq $R2,8($18) # b[1]
298 addq $R1,$CC,$R1 # c+= overflow
299 ldq $L3,16($17) # a[2]
300 cmpult $R1,$CC,$CC # overflow?
301 ldq $R3,16($18) # b[2]
302 addq $CC,$O1,$CC
303 ldq $L4,24($17) # a[3]
304 addq $R2,$L2,$R2 # r=a+b;
305 ldq $R4,24($18) # b[3]
306 cmpult $R2,$L2,$O2 # did we overflow?
307 addq $R3,$L3,$R3 # r=a+b;
308 addq $R2,$CC,$R2 # c+= overflow
309 cmpult $R3,$L3,$O3 # did we overflow?
310 cmpult $R2,$CC,$CC # overflow?
311 addq $R4,$L4,$R4 # r=a+b;
312 addq $CC,$O2,$CC
313 cmpult $R4,$L4,$O4 # did we overflow?
314 addq $R3,$CC,$R3 # c+= overflow
315 stq $R1,0($16) # r[0]=c
316 cmpult $R3,$CC,$CC # overflow?
317 stq $R2,8($16) # r[1]=c
318 addq $CC,$O3,$CC
319 stq $R3,16($16) # r[2]=c
320 addq $R4,$CC,$R4 # c+= overflow
321 subq $19,4,$19 # loop--
322 cmpult $R4,$CC,$CC # overflow?
323 addq $17,32,$17 # a++
324 addq $CC,$O4,$CC
325 stq $R4,24($16) # r[3]=c
326 addq $18,32,$18 # b++
327 addq $16,32,$16 # r++
328
329 blt $19,$900
330 ldq $L1,0($17) # a[0]
331 ldq $R1,0($18) # b[1]
332 br $901
333 .align 4
334$945:
335 ldq $L1,0($17) # a[0]
336 ldq $R1,0($18) # b[1]
337 addq $R1,$L1,$R1 # r=a+b;
338 subq $19,1,$19 # loop--
339 addq $R1,$CC,$R1 # c+= overflow
340 addq $17,8,$17 # a++
341 cmpult $R1,$L1,$O1 # did we overflow?
342 cmpult $R1,$CC,$CC # overflow?
343 addq $18,8,$18 # b++
344 stq $R1,0($16) # r[0]=c
345 addq $CC,$O1,$CC
346 addq $16,8,$16 # r++
347
348 bgt $19,$945
349 ret $31,($26),1 # else exit
350
351$900:
352 addq $19,4,$19
353 bgt $19,$945 # goto tail code
354 ret $31,($26),1 # else exit
355 .end bn_add_words
356
357 .align 3
358 .globl bn_sub_words
359 .ent bn_sub_words
360bn_sub_words:
361bn_sub_words..ng:
362 .frame $30,0,$26,0
363 .prologue 0
364
365 subq $19,4,$19
366 bis $31,$31,$CC # carry = 0
367 br $800
368 blt $19,$800
369 ldq $L1,0($17) # a[0]
370 ldq $R1,0($18) # b[1]
371 .align 3
372$801:
373 addq $R1,$L1,$R1 # r=a+b;
374 ldq $L2,8($17) # a[1]
375 cmpult $R1,$L1,$O1 # did we overflow?
376 ldq $R2,8($18) # b[1]
377 addq $R1,$CC,$R1 # c+= overflow
378 ldq $L3,16($17) # a[2]
379 cmpult $R1,$CC,$CC # overflow?
380 ldq $R3,16($18) # b[2]
381 addq $CC,$O1,$CC
382 ldq $L4,24($17) # a[3]
383 addq $R2,$L2,$R2 # r=a+b;
384 ldq $R4,24($18) # b[3]
385 cmpult $R2,$L2,$O2 # did we overflow?
386 addq $R3,$L3,$R3 # r=a+b;
387 addq $R2,$CC,$R2 # c+= overflow
388 cmpult $R3,$L3,$O3 # did we overflow?
389 cmpult $R2,$CC,$CC # overflow?
390 addq $R4,$L4,$R4 # r=a+b;
391 addq $CC,$O2,$CC
392 cmpult $R4,$L4,$O4 # did we overflow?
393 addq $R3,$CC,$R3 # c+= overflow
394 stq $R1,0($16) # r[0]=c
395 cmpult $R3,$CC,$CC # overflow?
396 stq $R2,8($16) # r[1]=c
397 addq $CC,$O3,$CC
398 stq $R3,16($16) # r[2]=c
399 addq $R4,$CC,$R4 # c+= overflow
400 subq $19,4,$19 # loop--
401 cmpult $R4,$CC,$CC # overflow?
402 addq $17,32,$17 # a++
403 addq $CC,$O4,$CC
404 stq $R4,24($16) # r[3]=c
405 addq $18,32,$18 # b++
406 addq $16,32,$16 # r++
407
408 blt $19,$800
409 ldq $L1,0($17) # a[0]
410 ldq $R1,0($18) # b[1]
411 br $801
412 .align 4
413$845:
414 ldq $L1,0($17) # a[0]
415 ldq $R1,0($18) # b[1]
416 cmpult $L1,$R1,$O1 # will we borrow?
417 subq $L1,$R1,$R1 # r=a-b;
418 subq $19,1,$19 # loop--
419 cmpult $R1,$CC,$O2 # will we borrow?
420 subq $R1,$CC,$R1 # c+= overflow
421 addq $17,8,$17 # a++
422 addq $18,8,$18 # b++
423 stq $R1,0($16) # r[0]=c
424 addq $O2,$O1,$CC
425 addq $16,8,$16 # r++
426
427 bgt $19,$845
428 ret $31,($26),1 # else exit
429
430$800:
431 addq $19,4,$19
432 bgt $19,$845 # goto tail code
433 ret $31,($26),1 # else exit
434 .end bn_sub_words
435
436 #
437 # What follows was taken directly from the C compiler with a few
438 # hacks to redo the lables.
439 #
440.text
441 .align 3
442 .globl bn_div_words
443 .ent bn_div_words
444bn_div_words:
445 ldgp $29,0($27)
446bn_div_words..ng:
447 lda $30,-48($30)
448 .frame $30,48,$26,0
449 stq $26,0($30)
450 stq $9,8($30)
451 stq $10,16($30)
452 stq $11,24($30)
453 stq $12,32($30)
454 stq $13,40($30)
455 .mask 0x4003e00,-48
456 .prologue 1
457 bis $16,$16,$9
458 bis $17,$17,$10
459 bis $18,$18,$11
460 bis $31,$31,$13
461 bis $31,2,$12
462 bne $11,$119
463 lda $0,-1
464 br $31,$136
465 .align 4
466$119:
467 bis $11,$11,$16
468 jsr $26,BN_num_bits_word
469 ldgp $29,0($26)
470 subq $0,64,$1
471 beq $1,$120
472 bis $31,1,$1
473 sll $1,$0,$1
474 cmpule $9,$1,$1
475 bne $1,$120
476 # lda $16,_IO_stderr_
477 # lda $17,$C32
478 # bis $0,$0,$18
479 # jsr $26,fprintf
480 # ldgp $29,0($26)
481 jsr $26,abort
482 ldgp $29,0($26)
483 .align 4
484$120:
485 bis $31,64,$3
486 cmpult $9,$11,$2
487 subq $3,$0,$1
488 addl $1,$31,$0
489 subq $9,$11,$1
490 cmoveq $2,$1,$9
491 beq $0,$122
492 zapnot $0,15,$2
493 subq $3,$0,$1
494 sll $11,$2,$11
495 sll $9,$2,$3
496 srl $10,$1,$1
497 sll $10,$2,$10
498 bis $3,$1,$9
499$122:
500 srl $11,32,$5
501 zapnot $11,15,$6
502 lda $7,-1
503 .align 5
504$123:
505 srl $9,32,$1
506 subq $1,$5,$1
507 bne $1,$126
508 zapnot $7,15,$27
509 br $31,$127
510 .align 4
511$126:
512 bis $9,$9,$24
513 bis $5,$5,$25
514 divqu $24,$25,$27
515$127:
516 srl $10,32,$4
517 .align 5
518$128:
519 mulq $27,$5,$1
520 subq $9,$1,$3
521 zapnot $3,240,$1
522 bne $1,$129
523 mulq $6,$27,$2
524 sll $3,32,$1
525 addq $1,$4,$1
526 cmpule $2,$1,$2
527 bne $2,$129
528 subq $27,1,$27
529 br $31,$128
530 .align 4
531$129:
532 mulq $27,$6,$1
533 mulq $27,$5,$4
534 srl $1,32,$3
535 sll $1,32,$1
536 addq $4,$3,$4
537 cmpult $10,$1,$2
538 subq $10,$1,$10
539 addq $2,$4,$2
540 cmpult $9,$2,$1
541 bis $2,$2,$4
542 beq $1,$134
543 addq $9,$11,$9
544 subq $27,1,$27
545$134:
546 subl $12,1,$12
547 subq $9,$4,$9
548 beq $12,$124
549 sll $27,32,$13
550 sll $9,32,$2
551 srl $10,32,$1
552 sll $10,32,$10
553 bis $2,$1,$9
554 br $31,$123
555 .align 4
556$124:
557 bis $13,$27,$0
558$136:
559 ldq $26,0($30)
560 ldq $9,8($30)
561 ldq $10,16($30)
562 ldq $11,24($30)
563 ldq $12,32($30)
564 ldq $13,40($30)
565 addq $30,48,$30
566 ret $31,($26),1
567 .end bn_div_words
568EOF
569 return($data);
570 }
571
diff --git a/src/lib/libcrypto/bn/asm/ca.pl b/src/lib/libcrypto/bn/asm/ca.pl
deleted file mode 100644
index c1ce67a6b4..0000000000
--- a/src/lib/libcrypto/bn/asm/ca.pl
+++ /dev/null
@@ -1,33 +0,0 @@
1#!/usr/local/bin/perl
2# I have this in perl so I can use more usefull register names and then convert
3# them into alpha registers.
4#
5
6push(@INC,"perlasm","../../perlasm");
7require "alpha.pl";
8require "alpha/mul_add.pl";
9require "alpha/mul.pl";
10require "alpha/sqr.pl";
11require "alpha/add.pl";
12require "alpha/sub.pl";
13require "alpha/mul_c8.pl";
14require "alpha/mul_c4.pl";
15require "alpha/sqr_c4.pl";
16require "alpha/sqr_c8.pl";
17require "alpha/div.pl";
18
19&asm_init($ARGV[0],$0);
20
21&bn_mul_words("bn_mul_words");
22&bn_sqr_words("bn_sqr_words");
23&bn_mul_add_words("bn_mul_add_words");
24&bn_add_words("bn_add_words");
25&bn_sub_words("bn_sub_words");
26&bn_div_words("bn_div_words");
27&bn_mul_comba8("bn_mul_comba8");
28&bn_mul_comba4("bn_mul_comba4");
29&bn_sqr_comba4("bn_sqr_comba4");
30&bn_sqr_comba8("bn_sqr_comba8");
31
32&asm_finish();
33
diff --git a/src/lib/libcrypto/bn/asm/co-586.pl b/src/lib/libcrypto/bn/asm/co-586.pl
index 5d962cb957..57101a6bd7 100644
--- a/src/lib/libcrypto/bn/asm/co-586.pl
+++ b/src/lib/libcrypto/bn/asm/co-586.pl
@@ -1,6 +1,7 @@
1#!/usr/local/bin/perl 1#!/usr/local/bin/perl
2 2
3push(@INC,"perlasm","../../perlasm"); 3$0 =~ m/(.*[\/\\])[^\/\\]+$/; $dir=$1;
4push(@INC,"${dir}","${dir}../../perlasm");
4require "x86asm.pl"; 5require "x86asm.pl";
5 6
6&asm_init($ARGV[0],$0); 7&asm_init($ARGV[0],$0);
diff --git a/src/lib/libcrypto/bn/asm/co-alpha.pl b/src/lib/libcrypto/bn/asm/co-alpha.pl
deleted file mode 100644
index 67dad3e3d5..0000000000
--- a/src/lib/libcrypto/bn/asm/co-alpha.pl
+++ /dev/null
@@ -1,116 +0,0 @@
1#!/usr/local/bin/perl
2# I have this in perl so I can use more usefull register names and then convert
3# them into alpha registers.
4#
5
6push(@INC,"perlasm","../../perlasm");
7require "alpha.pl";
8
9&asm_init($ARGV[0],$0);
10
11print &bn_sub_words("bn_sub_words");
12
13&asm_finish();
14
15sub bn_sub_words
16 {
17 local($name)=@_;
18 local($cc,$a,$b,$r);
19
20 $cc="r0";
21 $a0="r1"; $b0="r5"; $r0="r9"; $tmp="r13";
22 $a1="r2"; $b1="r6"; $r1="r10"; $t1="r14";
23 $a2="r3"; $b2="r7"; $r2="r11";
24 $a3="r4"; $b3="r8"; $r3="r12"; $t3="r15";
25
26 $rp=&wparam(0);
27 $ap=&wparam(1);
28 $bp=&wparam(2);
29 $count=&wparam(3);
30
31 &function_begin($name,"");
32
33 &comment("");
34 &sub($count,4,$count);
35 &mov("zero",$cc);
36 &blt($count,&label("finish"));
37
38 &ld($a0,&QWPw(0,$ap));
39 &ld($b0,&QWPw(0,$bp));
40
41##########################################################
42 &set_label("loop");
43
44 &ld($a1,&QWPw(1,$ap));
45 &cmpult($a0,$b0,$tmp); # will we borrow?
46 &ld($b1,&QWPw(1,$bp));
47 &sub($a0,$b0,$a0); # do the subtract
48 &ld($a2,&QWPw(2,$ap));
49 &cmpult($a0,$cc,$b0); # will we borrow?
50 &ld($b2,&QWPw(2,$bp));
51 &sub($a0,$cc,$a0); # will we borrow?
52 &ld($a3,&QWPw(3,$ap));
53 &add($b0,$tmp,$cc); # add the borrows
54
55 &cmpult($a1,$b1,$t1); # will we borrow?
56 &sub($a1,$b1,$a1); # do the subtract
57 &ld($b3,&QWPw(3,$bp));
58 &cmpult($a1,$cc,$b1); # will we borrow?
59 &sub($a1,$cc,$a1); # will we borrow?
60 &add($b1,$t1,$cc); # add the borrows
61
62 &cmpult($a2,$b2,$tmp); # will we borrow?
63 &sub($a2,$b2,$a2); # do the subtract
64 &st($a0,&QWPw(0,$rp)); # save
65 &cmpult($a2,$cc,$b2); # will we borrow?
66 &sub($a2,$cc,$a2); # will we borrow?
67 &add($b2,$tmp,$cc); # add the borrows
68
69 &cmpult($a3,$b3,$t3); # will we borrow?
70 &sub($a3,$b3,$a3); # do the subtract
71 &st($a1,&QWPw(1,$rp)); # save
72 &cmpult($a3,$cc,$b3); # will we borrow?
73 &sub($a3,$cc,$a3); # will we borrow?
74 &add($b3,$t3,$cc); # add the borrows
75
76 &st($a2,&QWPw(2,$rp)); # save
77 &sub($count,4,$count); # count-=4
78 &st($a3,&QWPw(3,$rp)); # save
79 &add($ap,4*$QWS,$ap); # count+=4
80 &add($bp,4*$QWS,$bp); # count+=4
81 &add($rp,4*$QWS,$rp); # count+=4
82
83 &blt($count,&label("finish"));
84 &ld($a0,&QWPw(0,$ap));
85 &ld($b0,&QWPw(0,$bp));
86 &br(&label("loop"));
87##################################################
88 # Do the last 0..3 words
89
90 &set_label("last_loop");
91
92 &ld($a0,&QWPw(0,$ap)); # get a
93 &ld($b0,&QWPw(0,$bp)); # get b
94 &cmpult($a0,$b0,$tmp); # will we borrow?
95 &sub($a0,$b0,$a0); # do the subtract
96 &cmpult($a0,$cc,$b0); # will we borrow?
97 &sub($a0,$cc,$a0); # will we borrow?
98 &st($a0,&QWPw(0,$rp)); # save
99 &add($b0,$tmp,$cc); # add the borrows
100
101 &add($ap,$QWS,$ap);
102 &add($bp,$QWS,$bp);
103 &add($rp,$QWS,$rp);
104 &sub($count,1,$count);
105 &bgt($count,&label("last_loop"));
106 &function_end_A($name);
107
108######################################################
109 &set_label("finish");
110 &add($count,4,$count);
111 &bgt($count,&label("last_loop"));
112
113 &set_label("end");
114 &function_end($name);
115 }
116
diff --git a/src/lib/libcrypto/bn/asm/mips1.s b/src/lib/libcrypto/bn/asm/mips1.s
deleted file mode 100644
index 44fa1254c7..0000000000
--- a/src/lib/libcrypto/bn/asm/mips1.s
+++ /dev/null
@@ -1,539 +0,0 @@
1/* This assember is for R2000/R3000 machines, or higher ones that do
2 * no want to do any 64 bit arithmatic.
3 * Make sure that the SSLeay bignum library is compiled with
4 * THIRTY_TWO_BIT set.
5 * This must either be compiled with the system CC, or, if you use GNU gas,
6 * cc -E mips1.s|gas -o mips1.o
7 */
8 .set reorder
9 .set noat
10
11#define R1 $1
12#define CC $2
13#define R2 $3
14#define R3 $8
15#define R4 $9
16#define L1 $10
17#define L2 $11
18#define L3 $12
19#define L4 $13
20#define H1 $14
21#define H2 $15
22#define H3 $24
23#define H4 $25
24
25#define P1 $4
26#define P2 $5
27#define P3 $6
28#define P4 $7
29
30 .align 2
31 .ent bn_mul_add_words
32 .globl bn_mul_add_words
33.text
34bn_mul_add_words:
35 .frame $sp,0,$31
36 .mask 0x00000000,0
37 .fmask 0x00000000,0
38
39 #blt P3,4,$lab34
40
41 subu R1,P3,4
42 move CC,$0
43 bltz R1,$lab34
44$lab2:
45 lw R1,0(P1)
46 lw L1,0(P2)
47 lw R2,4(P1)
48 lw L2,4(P2)
49 lw R3,8(P1)
50 lw L3,8(P2)
51 lw R4,12(P1)
52 lw L4,12(P2)
53 multu L1,P4
54 addu R1,R1,CC
55 mflo L1
56 sltu CC,R1,CC
57 addu R1,R1,L1
58 mfhi H1
59 sltu L1,R1,L1
60 sw R1,0(P1)
61 addu CC,CC,L1
62 multu L2,P4
63 addu CC,H1,CC
64 mflo L2
65 addu R2,R2,CC
66 sltu CC,R2,CC
67 mfhi H2
68 addu R2,R2,L2
69 addu P2,P2,16
70 sltu L2,R2,L2
71 sw R2,4(P1)
72 addu CC,CC,L2
73 multu L3,P4
74 addu CC,H2,CC
75 mflo L3
76 addu R3,R3,CC
77 sltu CC,R3,CC
78 mfhi H3
79 addu R3,R3,L3
80 addu P1,P1,16
81 sltu L3,R3,L3
82 sw R3,-8(P1)
83 addu CC,CC,L3
84 multu L4,P4
85 addu CC,H3,CC
86 mflo L4
87 addu R4,R4,CC
88 sltu CC,R4,CC
89 mfhi H4
90 addu R4,R4,L4
91 subu P3,P3,4
92 sltu L4,R4,L4
93 addu CC,CC,L4
94 addu CC,H4,CC
95
96 subu R1,P3,4
97 sw R4,-4(P1) # delay slot
98 bgez R1,$lab2
99
100 bleu P3,0,$lab3
101 .align 2
102$lab33:
103 lw L1,0(P2)
104 lw R1,0(P1)
105 multu L1,P4
106 addu R1,R1,CC
107 sltu CC,R1,CC
108 addu P1,P1,4
109 mflo L1
110 mfhi H1
111 addu R1,R1,L1
112 addu P2,P2,4
113 sltu L1,R1,L1
114 subu P3,P3,1
115 addu CC,CC,L1
116 sw R1,-4(P1)
117 addu CC,H1,CC
118 bgtz P3,$lab33
119 j $31
120 .align 2
121$lab3:
122 j $31
123 .align 2
124$lab34:
125 bgt P3,0,$lab33
126 j $31
127 .end bn_mul_add_words
128
129 .align 2
130 # Program Unit: bn_mul_words
131 .ent bn_mul_words
132 .globl bn_mul_words
133.text
134bn_mul_words:
135 .frame $sp,0,$31
136 .mask 0x00000000,0
137 .fmask 0x00000000,0
138
139 subu P3,P3,4
140 move CC,$0
141 bltz P3,$lab45
142$lab44:
143 lw L1,0(P2)
144 lw L2,4(P2)
145 lw L3,8(P2)
146 lw L4,12(P2)
147 multu L1,P4
148 subu P3,P3,4
149 mflo L1
150 mfhi H1
151 addu L1,L1,CC
152 multu L2,P4
153 sltu CC,L1,CC
154 sw L1,0(P1)
155 addu CC,H1,CC
156 mflo L2
157 mfhi H2
158 addu L2,L2,CC
159 multu L3,P4
160 sltu CC,L2,CC
161 sw L2,4(P1)
162 addu CC,H2,CC
163 mflo L3
164 mfhi H3
165 addu L3,L3,CC
166 multu L4,P4
167 sltu CC,L3,CC
168 sw L3,8(P1)
169 addu CC,H3,CC
170 mflo L4
171 mfhi H4
172 addu L4,L4,CC
173 addu P1,P1,16
174 sltu CC,L4,CC
175 addu P2,P2,16
176 addu CC,H4,CC
177 sw L4,-4(P1)
178
179 bgez P3,$lab44
180 b $lab45
181$lab46:
182 lw L1,0(P2)
183 addu P1,P1,4
184 multu L1,P4
185 addu P2,P2,4
186 mflo L1
187 mfhi H1
188 addu L1,L1,CC
189 subu P3,P3,1
190 sltu CC,L1,CC
191 sw L1,-4(P1)
192 addu CC,H1,CC
193 bgtz P3,$lab46
194 j $31
195$lab45:
196 addu P3,P3,4
197 bgtz P3,$lab46
198 j $31
199 .align 2
200 .end bn_mul_words
201
202 # Program Unit: bn_sqr_words
203 .ent bn_sqr_words
204 .globl bn_sqr_words
205.text
206bn_sqr_words:
207 .frame $sp,0,$31
208 .mask 0x00000000,0
209 .fmask 0x00000000,0
210
211 subu P3,P3,4
212 bltz P3,$lab55
213$lab54:
214 lw L1,0(P2)
215 lw L2,4(P2)
216 lw L3,8(P2)
217 lw L4,12(P2)
218
219 multu L1,L1
220 subu P3,P3,4
221 mflo L1
222 mfhi H1
223 sw L1,0(P1)
224 sw H1,4(P1)
225
226 multu L2,L2
227 addu P1,P1,32
228 mflo L2
229 mfhi H2
230 sw L2,-24(P1)
231 sw H2,-20(P1)
232
233 multu L3,L3
234 addu P2,P2,16
235 mflo L3
236 mfhi H3
237 sw L3,-16(P1)
238 sw H3,-12(P1)
239
240 multu L4,L4
241
242 mflo L4
243 mfhi H4
244 sw L4,-8(P1)
245 sw H4,-4(P1)
246
247 bgtz P3,$lab54
248 b $lab55
249$lab56:
250 lw L1,0(P2)
251 addu P1,P1,8
252 multu L1,L1
253 addu P2,P2,4
254 subu P3,P3,1
255 mflo L1
256 mfhi H1
257 sw L1,-8(P1)
258 sw H1,-4(P1)
259
260 bgtz P3,$lab56
261 j $31
262$lab55:
263 addu P3,P3,4
264 bgtz P3,$lab56
265 j $31
266 .align 2
267 .end bn_sqr_words
268
269 # Program Unit: bn_add_words
270 .ent bn_add_words
271 .globl bn_add_words
272.text
273bn_add_words: # 0x590
274 .frame $sp,0,$31
275 .mask 0x00000000,0
276 .fmask 0x00000000,0
277
278 subu P4,P4,4
279 move CC,$0
280 bltz P4,$lab65
281$lab64:
282 lw L1,0(P2)
283 lw R1,0(P3)
284 lw L2,4(P2)
285 lw R2,4(P3)
286
287 addu L1,L1,CC
288 lw L3,8(P2)
289 sltu CC,L1,CC
290 addu L1,L1,R1
291 sltu R1,L1,R1
292 lw R3,8(P3)
293 addu CC,CC,R1
294 lw L4,12(P2)
295
296 addu L2,L2,CC
297 lw R4,12(P3)
298 sltu CC,L2,CC
299 addu L2,L2,R2
300 sltu R2,L2,R2
301 sw L1,0(P1)
302 addu CC,CC,R2
303 addu P1,P1,16
304 addu L3,L3,CC
305 sw L2,-12(P1)
306
307 sltu CC,L3,CC
308 addu L3,L3,R3
309 sltu R3,L3,R3
310 addu P2,P2,16
311 addu CC,CC,R3
312
313 addu L4,L4,CC
314 addu P3,P3,16
315 sltu CC,L4,CC
316 addu L4,L4,R4
317 subu P4,P4,4
318 sltu R4,L4,R4
319 sw L3,-8(P1)
320 addu CC,CC,R4
321 sw L4,-4(P1)
322
323 bgtz P4,$lab64
324 b $lab65
325$lab66:
326 lw L1,0(P2)
327 lw R1,0(P3)
328 addu L1,L1,CC
329 addu P1,P1,4
330 sltu CC,L1,CC
331 addu P2,P2,4
332 addu P3,P3,4
333 addu L1,L1,R1
334 subu P4,P4,1
335 sltu R1,L1,R1
336 sw L1,-4(P1)
337 addu CC,CC,R1
338
339 bgtz P4,$lab66
340 j $31
341$lab65:
342 addu P4,P4,4
343 bgtz P4,$lab66
344 j $31
345 .end bn_add_words
346
347 # Program Unit: bn_div64
348 .set at
349 .set reorder
350 .text
351 .align 2
352 .globl bn_div64
353 # 321 {
354 .ent bn_div64 2
355bn_div64:
356 subu $sp, 64
357 sw $31, 56($sp)
358 sw $16, 48($sp)
359 .mask 0x80010000, -56
360 .frame $sp, 64, $31
361 move $9, $4
362 move $12, $5
363 move $16, $6
364 # 322 BN_ULONG dh,dl,q,ret=0,th,tl,t;
365 move $31, $0
366 # 323 int i,count=2;
367 li $13, 2
368 # 324
369 # 325 if (d == 0) return(BN_MASK2);
370 bne $16, 0, $80
371 li $2, -1
372 b $93
373$80:
374 # 326
375 # 327 i=BN_num_bits_word(d);
376 move $4, $16
377 sw $31, 16($sp)
378 sw $9, 24($sp)
379 sw $12, 32($sp)
380 sw $13, 40($sp)
381 .livereg 0x800ff0e,0xfff
382 jal BN_num_bits_word
383 li $4, 32
384 lw $31, 16($sp)
385 lw $9, 24($sp)
386 lw $12, 32($sp)
387 lw $13, 40($sp)
388 move $3, $2
389 # 328 if ((i != BN_BITS2) && (h > (BN_ULONG)1<<i))
390 beq $2, $4, $81
391 li $14, 1
392 sll $15, $14, $2
393 bleu $9, $15, $81
394 # 329 {
395 # 330 #if !defined(NO_STDIO) && !defined(WIN16)
396 # 331 fprintf(stderr,"Division would overflow (%d)\n",i);
397 # 332 #endif
398 # 333 abort();
399 sw $3, 8($sp)
400 sw $9, 24($sp)
401 sw $12, 32($sp)
402 sw $13, 40($sp)
403 sw $31, 26($sp)
404 .livereg 0xff0e,0xfff
405 jal abort
406 lw $3, 8($sp)
407 li $4, 32
408 lw $9, 24($sp)
409 lw $12, 32($sp)
410 lw $13, 40($sp)
411 lw $31, 26($sp)
412 # 334 }
413$81:
414 # 335 i=BN_BITS2-i;
415 subu $3, $4, $3
416 # 336 if (h >= d) h-=d;
417 bltu $9, $16, $82
418 subu $9, $9, $16
419$82:
420 # 337
421 # 338 if (i)
422 beq $3, 0, $83
423 # 339 {
424 # 340 d<<=i;
425 sll $16, $16, $3
426 # 341 h=(h<<i)|(l>>(BN_BITS2-i));
427 sll $24, $9, $3
428 subu $25, $4, $3
429 srl $14, $12, $25
430 or $9, $24, $14
431 # 342 l<<=i;
432 sll $12, $12, $3
433 # 343 }
434$83:
435 # 344 dh=(d&BN_MASK2h)>>BN_BITS4;
436 # 345 dl=(d&BN_MASK2l);
437 and $8, $16, -65536
438 srl $8, $8, 16
439 and $10, $16, 65535
440 li $6, -65536
441$84:
442 # 346 for (;;)
443 # 347 {
444 # 348 if ((h>>BN_BITS4) == dh)
445 srl $15, $9, 16
446 bne $8, $15, $85
447 # 349 q=BN_MASK2l;
448 li $5, 65535
449 b $86
450$85:
451 # 350 else
452 # 351 q=h/dh;
453 divu $5, $9, $8
454$86:
455 # 352
456 # 353 for (;;)
457 # 354 {
458 # 355 t=(h-q*dh);
459 mul $4, $5, $8
460 subu $2, $9, $4
461 move $3, $2
462 # 356 if ((t&BN_MASK2h) ||
463 # 357 ((dl*q) <= (
464 # 358 (t<<BN_BITS4)+
465 # 359 ((l&BN_MASK2h)>>BN_BITS4))))
466 and $25, $2, $6
467 bne $25, $0, $87
468 mul $24, $10, $5
469 sll $14, $3, 16
470 and $15, $12, $6
471 srl $25, $15, 16
472 addu $15, $14, $25
473 bgtu $24, $15, $88
474$87:
475 # 360 break;
476 mul $3, $10, $5
477 b $89
478$88:
479 # 361 q--;
480 addu $5, $5, -1
481 # 362 }
482 b $86
483$89:
484 # 363 th=q*dh;
485 # 364 tl=q*dl;
486 # 365 t=(tl>>BN_BITS4);
487 # 366 tl=(tl<<BN_BITS4)&BN_MASK2h;
488 sll $14, $3, 16
489 and $2, $14, $6
490 move $11, $2
491 # 367 th+=t;
492 srl $25, $3, 16
493 addu $7, $4, $25
494 # 368
495 # 369 if (l < tl) th++;
496 bgeu $12, $2, $90
497 addu $7, $7, 1
498$90:
499 # 370 l-=tl;
500 subu $12, $12, $11
501 # 371 if (h < th)
502 bgeu $9, $7, $91
503 # 372 {
504 # 373 h+=d;
505 addu $9, $9, $16
506 # 374 q--;
507 addu $5, $5, -1
508 # 375 }
509$91:
510 # 376 h-=th;
511 subu $9, $9, $7
512 # 377
513 # 378 if (--count == 0) break;
514 addu $13, $13, -1
515 beq $13, 0, $92
516 # 379
517 # 380 ret=q<<BN_BITS4;
518 sll $31, $5, 16
519 # 381 h=((h<<BN_BITS4)|(l>>BN_BITS4))&BN_MASK2;
520 sll $24, $9, 16
521 srl $15, $12, 16
522 or $9, $24, $15
523 # 382 l=(l&BN_MASK2l)<<BN_BITS4;
524 and $12, $12, 65535
525 sll $12, $12, 16
526 # 383 }
527 b $84
528$92:
529 # 384 ret|=q;
530 or $31, $31, $5
531 # 385 return(ret);
532 move $2, $31
533$93:
534 lw $16, 48($sp)
535 lw $31, 56($sp)
536 addu $sp, 64
537 j $31
538 .end bn_div64
539
diff --git a/src/lib/libcrypto/bn/asm/mo-586.pl b/src/lib/libcrypto/bn/asm/mo-586.pl
deleted file mode 100644
index 0982293094..0000000000
--- a/src/lib/libcrypto/bn/asm/mo-586.pl
+++ /dev/null
@@ -1,603 +0,0 @@
1#!/usr/bin/env perl
2
3# This is crypto/bn/asm/x86-mont.pl (with asciz from crypto/perlasm/x86asm.pl)
4# from OpenSSL 0.9.9-dev
5
6sub ::asciz
7{ my @str=unpack("C*",shift);
8 push @str,0;
9 while ($#str>15) {
10 &data_byte(@str[0..15]);
11 foreach (0..15) { shift @str; }
12 }
13 &data_byte(@str) if (@str);
14}
15
16# ====================================================================
17# Written by Andy Polyakov <appro@fy.chalmers.se> for the OpenSSL
18# project. The module is, however, dual licensed under OpenSSL and
19# CRYPTOGAMS licenses depending on where you obtain it. For further
20# details see http://www.openssl.org/~appro/cryptogams/.
21# ====================================================================
22
23# October 2005
24#
25# This is a "teaser" code, as it can be improved in several ways...
26# First of all non-SSE2 path should be implemented (yes, for now it
27# performs Montgomery multiplication/convolution only on SSE2-capable
28# CPUs such as P4, others fall down to original code). Then inner loop
29# can be unrolled and modulo-scheduled to improve ILP and possibly
30# moved to 128-bit XMM register bank (though it would require input
31# rearrangement and/or increase bus bandwidth utilization). Dedicated
32# squaring procedure should give further performance improvement...
33# Yet, for being draft, the code improves rsa512 *sign* benchmark by
34# 110%(!), rsa1024 one - by 70% and rsa4096 - by 20%:-)
35
36# December 2006
37#
38# Modulo-scheduling SSE2 loops results in further 15-20% improvement.
39# Integer-only code [being equipped with dedicated squaring procedure]
40# gives ~40% on rsa512 sign benchmark...
41
42push(@INC,"perlasm","../../perlasm");
43require "x86asm.pl";
44
45&asm_init($ARGV[0],$0);
46
47$sse2=0;
48for (@ARGV) { $sse2=1 if (/-DOPENSSL_IA32_SSE2/); }
49
50&external_label("OPENSSL_ia32cap_P") if ($sse2);
51
52&function_begin("bn_mul_mont");
53
54$i="edx";
55$j="ecx";
56$ap="esi"; $tp="esi"; # overlapping variables!!!
57$rp="edi"; $bp="edi"; # overlapping variables!!!
58$np="ebp";
59$num="ebx";
60
61$_num=&DWP(4*0,"esp"); # stack top layout
62$_rp=&DWP(4*1,"esp");
63$_ap=&DWP(4*2,"esp");
64$_bp=&DWP(4*3,"esp");
65$_np=&DWP(4*4,"esp");
66$_n0=&DWP(4*5,"esp"); $_n0q=&QWP(4*5,"esp");
67$_sp=&DWP(4*6,"esp");
68$_bpend=&DWP(4*7,"esp");
69$frame=32; # size of above frame rounded up to 16n
70
71 &xor ("eax","eax");
72 &mov ("edi",&wparam(5)); # int num
73 &cmp ("edi",4);
74 &jl (&label("just_leave"));
75
76 &lea ("esi",&wparam(0)); # put aside pointer to argument block
77 &lea ("edx",&wparam(1)); # load ap
78 &mov ("ebp","esp"); # saved stack pointer!
79 &add ("edi",2); # extra two words on top of tp
80 &neg ("edi");
81 &lea ("esp",&DWP(-$frame,"esp","edi",4)); # alloca($frame+4*(num+2))
82 &neg ("edi");
83
84 # minimize cache contention by arraning 2K window between stack
85 # pointer and ap argument [np is also position sensitive vector,
86 # but it's assumed to be near ap, as it's allocated at ~same
87 # time].
88 &mov ("eax","esp");
89 &sub ("eax","edx");
90 &and ("eax",2047);
91 &sub ("esp","eax"); # this aligns sp and ap modulo 2048
92
93 &xor ("edx","esp");
94 &and ("edx",2048);
95 &xor ("edx",2048);
96 &sub ("esp","edx"); # this splits them apart modulo 4096
97
98 &and ("esp",-64); # align to cache line
99
100 ################################# load argument block...
101 &mov ("eax",&DWP(0*4,"esi"));# BN_ULONG *rp
102 &mov ("ebx",&DWP(1*4,"esi"));# const BN_ULONG *ap
103 &mov ("ecx",&DWP(2*4,"esi"));# const BN_ULONG *bp
104 &mov ("edx",&DWP(3*4,"esi"));# const BN_ULONG *np
105 &mov ("esi",&DWP(4*4,"esi"));# const BN_ULONG *n0
106 #&mov ("edi",&DWP(5*4,"esi"));# int num
107
108 &mov ("esi",&DWP(0,"esi")); # pull n0[0]
109 &mov ($_rp,"eax"); # ... save a copy of argument block
110 &mov ($_ap,"ebx");
111 &mov ($_bp,"ecx");
112 &mov ($_np,"edx");
113 &mov ($_n0,"esi");
114 &lea ($num,&DWP(-3,"edi")); # num=num-1 to assist modulo-scheduling
115 #&mov ($_num,$num); # redundant as $num is not reused
116 &mov ($_sp,"ebp"); # saved stack pointer!
117
118if($sse2) {
119$acc0="mm0"; # mmx register bank layout
120$acc1="mm1";
121$car0="mm2";
122$car1="mm3";
123$mul0="mm4";
124$mul1="mm5";
125$temp="mm6";
126$mask="mm7";
127
128 &picmeup("eax","OPENSSL_ia32cap_P");
129 &bt (&DWP(0,"eax"),26);
130 &jnc (&label("non_sse2"));
131
132 &mov ("eax",-1);
133 &movd ($mask,"eax"); # mask 32 lower bits
134
135 &mov ($ap,$_ap); # load input pointers
136 &mov ($bp,$_bp);
137 &mov ($np,$_np);
138
139 &xor ($i,$i); # i=0
140 &xor ($j,$j); # j=0
141
142 &movd ($mul0,&DWP(0,$bp)); # bp[0]
143 &movd ($mul1,&DWP(0,$ap)); # ap[0]
144 &movd ($car1,&DWP(0,$np)); # np[0]
145
146 &pmuludq($mul1,$mul0); # ap[0]*bp[0]
147 &movq ($car0,$mul1);
148 &movq ($acc0,$mul1); # I wish movd worked for
149 &pand ($acc0,$mask); # inter-register transfers
150
151 &pmuludq($mul1,$_n0q); # *=n0
152
153 &pmuludq($car1,$mul1); # "t[0]"*np[0]*n0
154 &paddq ($car1,$acc0);
155
156 &movd ($acc1,&DWP(4,$np)); # np[1]
157 &movd ($acc0,&DWP(4,$ap)); # ap[1]
158
159 &psrlq ($car0,32);
160 &psrlq ($car1,32);
161
162 &inc ($j); # j++
163&set_label("1st",16);
164 &pmuludq($acc0,$mul0); # ap[j]*bp[0]
165 &pmuludq($acc1,$mul1); # np[j]*m1
166 &paddq ($car0,$acc0); # +=c0
167 &paddq ($car1,$acc1); # +=c1
168
169 &movq ($acc0,$car0);
170 &pand ($acc0,$mask);
171 &movd ($acc1,&DWP(4,$np,$j,4)); # np[j+1]
172 &paddq ($car1,$acc0); # +=ap[j]*bp[0];
173 &movd ($acc0,&DWP(4,$ap,$j,4)); # ap[j+1]
174 &psrlq ($car0,32);
175 &movd (&DWP($frame-4,"esp",$j,4),$car1); # tp[j-1]=
176 &psrlq ($car1,32);
177
178 &lea ($j,&DWP(1,$j));
179 &cmp ($j,$num);
180 &jl (&label("1st"));
181
182 &pmuludq($acc0,$mul0); # ap[num-1]*bp[0]
183 &pmuludq($acc1,$mul1); # np[num-1]*m1
184 &paddq ($car0,$acc0); # +=c0
185 &paddq ($car1,$acc1); # +=c1
186
187 &movq ($acc0,$car0);
188 &pand ($acc0,$mask);
189 &paddq ($car1,$acc0); # +=ap[num-1]*bp[0];
190 &movd (&DWP($frame-4,"esp",$j,4),$car1); # tp[num-2]=
191
192 &psrlq ($car0,32);
193 &psrlq ($car1,32);
194
195 &paddq ($car1,$car0);
196 &movq (&QWP($frame,"esp",$num,4),$car1); # tp[num].tp[num-1]
197
198 &inc ($i); # i++
199&set_label("outer");
200 &xor ($j,$j); # j=0
201
202 &movd ($mul0,&DWP(0,$bp,$i,4)); # bp[i]
203 &movd ($mul1,&DWP(0,$ap)); # ap[0]
204 &movd ($temp,&DWP($frame,"esp")); # tp[0]
205 &movd ($car1,&DWP(0,$np)); # np[0]
206 &pmuludq($mul1,$mul0); # ap[0]*bp[i]
207
208 &paddq ($mul1,$temp); # +=tp[0]
209 &movq ($acc0,$mul1);
210 &movq ($car0,$mul1);
211 &pand ($acc0,$mask);
212
213 &pmuludq($mul1,$_n0q); # *=n0
214
215 &pmuludq($car1,$mul1);
216 &paddq ($car1,$acc0);
217
218 &movd ($temp,&DWP($frame+4,"esp")); # tp[1]
219 &movd ($acc1,&DWP(4,$np)); # np[1]
220 &movd ($acc0,&DWP(4,$ap)); # ap[1]
221
222 &psrlq ($car0,32);
223 &psrlq ($car1,32);
224 &paddq ($car0,$temp); # +=tp[1]
225
226 &inc ($j); # j++
227 &dec ($num);
228&set_label("inner");
229 &pmuludq($acc0,$mul0); # ap[j]*bp[i]
230 &pmuludq($acc1,$mul1); # np[j]*m1
231 &paddq ($car0,$acc0); # +=c0
232 &paddq ($car1,$acc1); # +=c1
233
234 &movq ($acc0,$car0);
235 &movd ($temp,&DWP($frame+4,"esp",$j,4));# tp[j+1]
236 &pand ($acc0,$mask);
237 &movd ($acc1,&DWP(4,$np,$j,4)); # np[j+1]
238 &paddq ($car1,$acc0); # +=ap[j]*bp[i]+tp[j]
239 &movd ($acc0,&DWP(4,$ap,$j,4)); # ap[j+1]
240 &psrlq ($car0,32);
241 &movd (&DWP($frame-4,"esp",$j,4),$car1);# tp[j-1]=
242 &psrlq ($car1,32);
243 &paddq ($car0,$temp); # +=tp[j+1]
244
245 &dec ($num);
246 &lea ($j,&DWP(1,$j)); # j++
247 &jnz (&label("inner"));
248
249 &mov ($num,$j);
250 &pmuludq($acc0,$mul0); # ap[num-1]*bp[i]
251 &pmuludq($acc1,$mul1); # np[num-1]*m1
252 &paddq ($car0,$acc0); # +=c0
253 &paddq ($car1,$acc1); # +=c1
254
255 &movq ($acc0,$car0);
256 &pand ($acc0,$mask);
257 &paddq ($car1,$acc0); # +=ap[num-1]*bp[i]+tp[num-1]
258 &movd (&DWP($frame-4,"esp",$j,4),$car1); # tp[num-2]=
259 &psrlq ($car0,32);
260 &psrlq ($car1,32);
261
262 &movd ($temp,&DWP($frame+4,"esp",$num,4)); # += tp[num]
263 &paddq ($car1,$car0);
264 &paddq ($car1,$temp);
265 &movq (&QWP($frame,"esp",$num,4),$car1); # tp[num].tp[num-1]
266
267 &lea ($i,&DWP(1,$i)); # i++
268 &cmp ($i,$num);
269 &jle (&label("outer"));
270
271 &emms (); # done with mmx bank
272 &jmp (&label("common_tail"));
273
274&set_label("non_sse2",16);
275}
276
277if (0) {
278 &mov ("esp",$_sp);
279 &xor ("eax","eax"); # signal "not fast enough [yet]"
280 &jmp (&label("just_leave"));
281 # While the below code provides competitive performance for
282 # all key lengthes on modern Intel cores, it's still more
283 # than 10% slower for 4096-bit key elsewhere:-( "Competitive"
284 # means compared to the original integer-only assembler.
285 # 512-bit RSA sign is better by ~40%, but that's about all
286 # one can say about all CPUs...
287} else {
288$inp="esi"; # integer path uses these registers differently
289$word="edi";
290$carry="ebp";
291
292 &mov ($inp,$_ap);
293 &lea ($carry,&DWP(1,$num));
294 &mov ($word,$_bp);
295 &xor ($j,$j); # j=0
296 &mov ("edx",$inp);
297 &and ($carry,1); # see if num is even
298 &sub ("edx",$word); # see if ap==bp
299 &lea ("eax",&DWP(4,$word,$num,4)); # &bp[num]
300 &or ($carry,"edx");
301 &mov ($word,&DWP(0,$word)); # bp[0]
302 &jz (&label("bn_sqr_mont"));
303 &mov ($_bpend,"eax");
304 &mov ("eax",&DWP(0,$inp));
305 &xor ("edx","edx");
306
307&set_label("mull",16);
308 &mov ($carry,"edx");
309 &mul ($word); # ap[j]*bp[0]
310 &add ($carry,"eax");
311 &lea ($j,&DWP(1,$j));
312 &adc ("edx",0);
313 &mov ("eax",&DWP(0,$inp,$j,4)); # ap[j+1]
314 &cmp ($j,$num);
315 &mov (&DWP($frame-4,"esp",$j,4),$carry); # tp[j]=
316 &jl (&label("mull"));
317
318 &mov ($carry,"edx");
319 &mul ($word); # ap[num-1]*bp[0]
320 &mov ($word,$_n0);
321 &add ("eax",$carry);
322 &mov ($inp,$_np);
323 &adc ("edx",0);
324 &imul ($word,&DWP($frame,"esp")); # n0*tp[0]
325
326 &mov (&DWP($frame,"esp",$num,4),"eax"); # tp[num-1]=
327 &xor ($j,$j);
328 &mov (&DWP($frame+4,"esp",$num,4),"edx"); # tp[num]=
329 &mov (&DWP($frame+8,"esp",$num,4),$j); # tp[num+1]=
330
331 &mov ("eax",&DWP(0,$inp)); # np[0]
332 &mul ($word); # np[0]*m
333 &add ("eax",&DWP($frame,"esp")); # +=tp[0]
334 &mov ("eax",&DWP(4,$inp)); # np[1]
335 &adc ("edx",0);
336 &inc ($j);
337
338 &jmp (&label("2ndmadd"));
339
340&set_label("1stmadd",16);
341 &mov ($carry,"edx");
342 &mul ($word); # ap[j]*bp[i]
343 &add ($carry,&DWP($frame,"esp",$j,4)); # +=tp[j]
344 &lea ($j,&DWP(1,$j));
345 &adc ("edx",0);
346 &add ($carry,"eax");
347 &mov ("eax",&DWP(0,$inp,$j,4)); # ap[j+1]
348 &adc ("edx",0);
349 &cmp ($j,$num);
350 &mov (&DWP($frame-4,"esp",$j,4),$carry); # tp[j]=
351 &jl (&label("1stmadd"));
352
353 &mov ($carry,"edx");
354 &mul ($word); # ap[num-1]*bp[i]
355 &add ("eax",&DWP($frame,"esp",$num,4)); # +=tp[num-1]
356 &mov ($word,$_n0);
357 &adc ("edx",0);
358 &mov ($inp,$_np);
359 &add ($carry,"eax");
360 &adc ("edx",0);
361 &imul ($word,&DWP($frame,"esp")); # n0*tp[0]
362
363 &xor ($j,$j);
364 &add ("edx",&DWP($frame+4,"esp",$num,4)); # carry+=tp[num]
365 &mov (&DWP($frame,"esp",$num,4),$carry); # tp[num-1]=
366 &adc ($j,0);
367 &mov ("eax",&DWP(0,$inp)); # np[0]
368 &mov (&DWP($frame+4,"esp",$num,4),"edx"); # tp[num]=
369 &mov (&DWP($frame+8,"esp",$num,4),$j); # tp[num+1]=
370
371 &mul ($word); # np[0]*m
372 &add ("eax",&DWP($frame,"esp")); # +=tp[0]
373 &mov ("eax",&DWP(4,$inp)); # np[1]
374 &adc ("edx",0);
375 &mov ($j,1);
376
377&set_label("2ndmadd",16);
378 &mov ($carry,"edx");
379 &mul ($word); # np[j]*m
380 &add ($carry,&DWP($frame,"esp",$j,4)); # +=tp[j]
381 &lea ($j,&DWP(1,$j));
382 &adc ("edx",0);
383 &add ($carry,"eax");
384 &mov ("eax",&DWP(0,$inp,$j,4)); # np[j+1]
385 &adc ("edx",0);
386 &cmp ($j,$num);
387 &mov (&DWP($frame-8,"esp",$j,4),$carry); # tp[j-1]=
388 &jl (&label("2ndmadd"));
389
390 &mov ($carry,"edx");
391 &mul ($word); # np[j]*m
392 &add ($carry,&DWP($frame,"esp",$num,4)); # +=tp[num-1]
393 &adc ("edx",0);
394 &add ($carry,"eax");
395 &adc ("edx",0);
396 &mov (&DWP($frame-4,"esp",$num,4),$carry); # tp[num-2]=
397
398 &xor ("eax","eax");
399 &mov ($j,$_bp); # &bp[i]
400 &add ("edx",&DWP($frame+4,"esp",$num,4)); # carry+=tp[num]
401 &adc ("eax",&DWP($frame+8,"esp",$num,4)); # +=tp[num+1]
402 &lea ($j,&DWP(4,$j));
403 &mov (&DWP($frame,"esp",$num,4),"edx"); # tp[num-1]=
404 &cmp ($j,$_bpend);
405 &mov (&DWP($frame+4,"esp",$num,4),"eax"); # tp[num]=
406 &je (&label("common_tail"));
407
408 &mov ($word,&DWP(0,$j)); # bp[i+1]
409 &mov ($inp,$_ap);
410 &mov ($_bp,$j); # &bp[++i]
411 &xor ($j,$j);
412 &xor ("edx","edx");
413 &mov ("eax",&DWP(0,$inp));
414 &jmp (&label("1stmadd"));
415
416&set_label("bn_sqr_mont",16);
417$sbit=$num;
418 &mov ($_num,$num);
419 &mov ($_bp,$j); # i=0
420
421 &mov ("eax",$word); # ap[0]
422 &mul ($word); # ap[0]*ap[0]
423 &mov (&DWP($frame,"esp"),"eax"); # tp[0]=
424 &mov ($sbit,"edx");
425 &shr ("edx",1);
426 &and ($sbit,1);
427 &inc ($j);
428&set_label("sqr",16);
429 &mov ("eax",&DWP(0,$inp,$j,4)); # ap[j]
430 &mov ($carry,"edx");
431 &mul ($word); # ap[j]*ap[0]
432 &add ("eax",$carry);
433 &lea ($j,&DWP(1,$j));
434 &adc ("edx",0);
435 &lea ($carry,&DWP(0,$sbit,"eax",2));
436 &shr ("eax",31);
437 &cmp ($j,$_num);
438 &mov ($sbit,"eax");
439 &mov (&DWP($frame-4,"esp",$j,4),$carry); # tp[j]=
440 &jl (&label("sqr"));
441
442 &mov ("eax",&DWP(0,$inp,$j,4)); # ap[num-1]
443 &mov ($carry,"edx");
444 &mul ($word); # ap[num-1]*ap[0]
445 &add ("eax",$carry);
446 &mov ($word,$_n0);
447 &adc ("edx",0);
448 &mov ($inp,$_np);
449 &lea ($carry,&DWP(0,$sbit,"eax",2));
450 &imul ($word,&DWP($frame,"esp")); # n0*tp[0]
451 &shr ("eax",31);
452 &mov (&DWP($frame,"esp",$j,4),$carry); # tp[num-1]=
453
454 &lea ($carry,&DWP(0,"eax","edx",2));
455 &mov ("eax",&DWP(0,$inp)); # np[0]
456 &shr ("edx",31);
457 &mov (&DWP($frame+4,"esp",$j,4),$carry); # tp[num]=
458 &mov (&DWP($frame+8,"esp",$j,4),"edx"); # tp[num+1]=
459
460 &mul ($word); # np[0]*m
461 &add ("eax",&DWP($frame,"esp")); # +=tp[0]
462 &mov ($num,$j);
463 &adc ("edx",0);
464 &mov ("eax",&DWP(4,$inp)); # np[1]
465 &mov ($j,1);
466
467&set_label("3rdmadd",16);
468 &mov ($carry,"edx");
469 &mul ($word); # np[j]*m
470 &add ($carry,&DWP($frame,"esp",$j,4)); # +=tp[j]
471 &adc ("edx",0);
472 &add ($carry,"eax");
473 &mov ("eax",&DWP(4,$inp,$j,4)); # np[j+1]
474 &adc ("edx",0);
475 &mov (&DWP($frame-4,"esp",$j,4),$carry); # tp[j-1]=
476
477 &mov ($carry,"edx");
478 &mul ($word); # np[j+1]*m
479 &add ($carry,&DWP($frame+4,"esp",$j,4)); # +=tp[j+1]
480 &lea ($j,&DWP(2,$j));
481 &adc ("edx",0);
482 &add ($carry,"eax");
483 &mov ("eax",&DWP(0,$inp,$j,4)); # np[j+2]
484 &adc ("edx",0);
485 &cmp ($j,$num);
486 &mov (&DWP($frame-8,"esp",$j,4),$carry); # tp[j]=
487 &jl (&label("3rdmadd"));
488
489 &mov ($carry,"edx");
490 &mul ($word); # np[j]*m
491 &add ($carry,&DWP($frame,"esp",$num,4)); # +=tp[num-1]
492 &adc ("edx",0);
493 &add ($carry,"eax");
494 &adc ("edx",0);
495 &mov (&DWP($frame-4,"esp",$num,4),$carry); # tp[num-2]=
496
497 &mov ($j,$_bp); # i
498 &xor ("eax","eax");
499 &mov ($inp,$_ap);
500 &add ("edx",&DWP($frame+4,"esp",$num,4)); # carry+=tp[num]
501 &adc ("eax",&DWP($frame+8,"esp",$num,4)); # +=tp[num+1]
502 &mov (&DWP($frame,"esp",$num,4),"edx"); # tp[num-1]=
503 &cmp ($j,$num);
504 &mov (&DWP($frame+4,"esp",$num,4),"eax"); # tp[num]=
505 &je (&label("common_tail"));
506
507 &mov ($word,&DWP(4,$inp,$j,4)); # ap[i]
508 &lea ($j,&DWP(1,$j));
509 &mov ("eax",$word);
510 &mov ($_bp,$j); # ++i
511 &mul ($word); # ap[i]*ap[i]
512 &add ("eax",&DWP($frame,"esp",$j,4)); # +=tp[i]
513 &adc ("edx",0);
514 &mov (&DWP($frame,"esp",$j,4),"eax"); # tp[i]=
515 &xor ($carry,$carry);
516 &cmp ($j,$num);
517 &lea ($j,&DWP(1,$j));
518 &je (&label("sqrlast"));
519
520 &mov ($sbit,"edx"); # zaps $num
521 &shr ("edx",1);
522 &and ($sbit,1);
523&set_label("sqradd",16);
524 &mov ("eax",&DWP(0,$inp,$j,4)); # ap[j]
525 &mov ($carry,"edx");
526 &mul ($word); # ap[j]*ap[i]
527 &add ("eax",$carry);
528 &lea ($carry,&DWP(0,"eax","eax"));
529 &adc ("edx",0);
530 &shr ("eax",31);
531 &add ($carry,&DWP($frame,"esp",$j,4)); # +=tp[j]
532 &lea ($j,&DWP(1,$j));
533 &adc ("eax",0);
534 &add ($carry,$sbit);
535 &adc ("eax",0);
536 &cmp ($j,$_num);
537 &mov (&DWP($frame-4,"esp",$j,4),$carry); # tp[j]=
538 &mov ($sbit,"eax");
539 &jle (&label("sqradd"));
540
541 &mov ($carry,"edx");
542 &lea ("edx",&DWP(0,$sbit,"edx",2));
543 &shr ($carry,31);
544&set_label("sqrlast");
545 &mov ($word,$_n0);
546 &mov ($inp,$_np);
547 &imul ($word,&DWP($frame,"esp")); # n0*tp[0]
548
549 &add ("edx",&DWP($frame,"esp",$j,4)); # +=tp[num]
550 &mov ("eax",&DWP(0,$inp)); # np[0]
551 &adc ($carry,0);
552 &mov (&DWP($frame,"esp",$j,4),"edx"); # tp[num]=
553 &mov (&DWP($frame+4,"esp",$j,4),$carry); # tp[num+1]=
554
555 &mul ($word); # np[0]*m
556 &add ("eax",&DWP($frame,"esp")); # +=tp[0]
557 &lea ($num,&DWP(-1,$j));
558 &adc ("edx",0);
559 &mov ($j,1);
560 &mov ("eax",&DWP(4,$inp)); # np[1]
561
562 &jmp (&label("3rdmadd"));
563}
564
565&set_label("common_tail",16);
566 &mov ($np,$_np); # load modulus pointer
567 &mov ($rp,$_rp); # load result pointer
568 &lea ($tp,&DWP($frame,"esp")); # [$ap and $bp are zapped]
569
570 &mov ("eax",&DWP(0,$tp)); # tp[0]
571 &mov ($j,$num); # j=num-1
572 &xor ($i,$i); # i=0 and clear CF!
573
574&set_label("sub",16);
575 &sbb ("eax",&DWP(0,$np,$i,4));
576 &mov (&DWP(0,$rp,$i,4),"eax"); # rp[i]=tp[i]-np[i]
577 &dec ($j); # doesn't affect CF!
578 &mov ("eax",&DWP(4,$tp,$i,4)); # tp[i+1]
579 &lea ($i,&DWP(1,$i)); # i++
580 &jge (&label("sub"));
581
582 &sbb ("eax",0); # handle upmost overflow bit
583 &and ($tp,"eax");
584 &not ("eax");
585 &mov ($np,$rp);
586 &and ($np,"eax");
587 &or ($tp,$np); # tp=carry?tp:rp
588
589&set_label("copy",16); # copy or in-place refresh
590 &mov ("eax",&DWP(0,$tp,$num,4));
591 &mov (&DWP(0,$rp,$num,4),"eax"); # rp[i]=tp[i]
592 &mov (&DWP($frame,"esp",$num,4),$j); # zap temporary vector
593 &dec ($num);
594 &jge (&label("copy"));
595
596 &mov ("esp",$_sp); # pull saved stack pointer
597 &mov ("eax",1);
598&set_label("just_leave");
599&function_end("bn_mul_mont");
600
601&asciz("Montgomery Multiplication for x86, CRYPTOGAMS by <appro\@openssl.org>");
602
603&asm_finish();
diff --git a/src/lib/libcrypto/bn/asm/pa-risc.s b/src/lib/libcrypto/bn/asm/pa-risc.s
deleted file mode 100644
index 775130a191..0000000000
--- a/src/lib/libcrypto/bn/asm/pa-risc.s
+++ /dev/null
@@ -1,710 +0,0 @@
1 .SPACE $PRIVATE$
2 .SUBSPA $DATA$,QUAD=1,ALIGN=8,ACCESS=31
3 .SUBSPA $BSS$,QUAD=1,ALIGN=8,ACCESS=31,ZERO,SORT=82
4 .SPACE $TEXT$
5 .SUBSPA $LIT$,QUAD=0,ALIGN=8,ACCESS=44
6 .SUBSPA $CODE$,QUAD=0,ALIGN=8,ACCESS=44,CODE_ONLY
7 .IMPORT $global$,DATA
8 .IMPORT $$dyncall,MILLICODE
9; gcc_compiled.:
10 .SPACE $TEXT$
11 .SUBSPA $CODE$
12
13 .align 4
14 .EXPORT bn_mul_add_words,ENTRY,PRIV_LEV=3,ARGW0=GR,ARGW1=GR,ARGW2=GR,ARGW3=GR,RTNVAL=GR
15bn_mul_add_words
16 .PROC
17 .CALLINFO FRAME=0,CALLS,SAVE_RP
18 .ENTRY
19 stw %r2,-20(0,%r30)
20 ldi 0,%r28
21 extru %r23,31,16,%r2
22 stw %r2,-16(0,%r30)
23 extru %r23,15,16,%r23
24 ldil L'65536,%r31
25 fldws -16(0,%r30),%fr11R
26 stw %r23,-16(0,%r30)
27 ldo 12(%r25),%r29
28 ldo 12(%r26),%r23
29 fldws -16(0,%r30),%fr11L
30L$0002
31 ldw 0(0,%r25),%r19
32 extru %r19,31,16,%r20
33 stw %r20,-16(0,%r30)
34 extru %r19,15,16,%r19
35 fldws -16(0,%r30),%fr22L
36 stw %r19,-16(0,%r30)
37 xmpyu %fr22L,%fr11R,%fr8
38 fldws -16(0,%r30),%fr22L
39 fstws %fr8R,-16(0,%r30)
40 xmpyu %fr11R,%fr22L,%fr10
41 ldw -16(0,%r30),%r2
42 stw %r20,-16(0,%r30)
43 xmpyu %fr22L,%fr11L,%fr9
44 fldws -16(0,%r30),%fr22L
45 fstws %fr10R,-16(0,%r30)
46 copy %r2,%r22
47 ldw -16(0,%r30),%r2
48 fstws %fr9R,-16(0,%r30)
49 xmpyu %fr11L,%fr22L,%fr8
50 copy %r2,%r19
51 ldw -16(0,%r30),%r2
52 fstws %fr8R,-16(0,%r30)
53 copy %r2,%r20
54 ldw -16(0,%r30),%r2
55 addl %r2,%r19,%r21
56 comclr,<<= %r19,%r21,0
57 addl %r20,%r31,%r20
58L$0005
59 extru %r21,15,16,%r19
60 addl %r20,%r19,%r20
61 zdep %r21,15,16,%r19
62 addl %r22,%r19,%r22
63 comclr,<<= %r19,%r22,0
64 addi,tr 1,%r20,%r19
65 copy %r20,%r19
66 addl %r22,%r28,%r20
67 comclr,<<= %r28,%r20,0
68 addi 1,%r19,%r19
69 ldw 0(0,%r26),%r28
70 addl %r20,%r28,%r20
71 comclr,<<= %r28,%r20,0
72 addi,tr 1,%r19,%r28
73 copy %r19,%r28
74 addib,= -1,%r24,L$0003
75 stw %r20,0(0,%r26)
76 ldw -8(0,%r29),%r19
77 extru %r19,31,16,%r20
78 stw %r20,-16(0,%r30)
79 extru %r19,15,16,%r19
80 fldws -16(0,%r30),%fr22L
81 stw %r19,-16(0,%r30)
82 xmpyu %fr22L,%fr11R,%fr8
83 fldws -16(0,%r30),%fr22L
84 fstws %fr8R,-16(0,%r30)
85 xmpyu %fr11R,%fr22L,%fr10
86 ldw -16(0,%r30),%r2
87 stw %r20,-16(0,%r30)
88 xmpyu %fr22L,%fr11L,%fr9
89 fldws -16(0,%r30),%fr22L
90 fstws %fr10R,-16(0,%r30)
91 copy %r2,%r22
92 ldw -16(0,%r30),%r2
93 fstws %fr9R,-16(0,%r30)
94 xmpyu %fr11L,%fr22L,%fr8
95 copy %r2,%r19
96 ldw -16(0,%r30),%r2
97 fstws %fr8R,-16(0,%r30)
98 copy %r2,%r20
99 ldw -16(0,%r30),%r2
100 addl %r2,%r19,%r21
101 comclr,<<= %r19,%r21,0
102 addl %r20,%r31,%r20
103L$0010
104 extru %r21,15,16,%r19
105 addl %r20,%r19,%r20
106 zdep %r21,15,16,%r19
107 addl %r22,%r19,%r22
108 comclr,<<= %r19,%r22,0
109 addi,tr 1,%r20,%r19
110 copy %r20,%r19
111 addl %r22,%r28,%r20
112 comclr,<<= %r28,%r20,0
113 addi 1,%r19,%r19
114 ldw -8(0,%r23),%r28
115 addl %r20,%r28,%r20
116 comclr,<<= %r28,%r20,0
117 addi,tr 1,%r19,%r28
118 copy %r19,%r28
119 addib,= -1,%r24,L$0003
120 stw %r20,-8(0,%r23)
121 ldw -4(0,%r29),%r19
122 extru %r19,31,16,%r20
123 stw %r20,-16(0,%r30)
124 extru %r19,15,16,%r19
125 fldws -16(0,%r30),%fr22L
126 stw %r19,-16(0,%r30)
127 xmpyu %fr22L,%fr11R,%fr8
128 fldws -16(0,%r30),%fr22L
129 fstws %fr8R,-16(0,%r30)
130 xmpyu %fr11R,%fr22L,%fr10
131 ldw -16(0,%r30),%r2
132 stw %r20,-16(0,%r30)
133 xmpyu %fr22L,%fr11L,%fr9
134 fldws -16(0,%r30),%fr22L
135 fstws %fr10R,-16(0,%r30)
136 copy %r2,%r22
137 ldw -16(0,%r30),%r2
138 fstws %fr9R,-16(0,%r30)
139 xmpyu %fr11L,%fr22L,%fr8
140 copy %r2,%r19
141 ldw -16(0,%r30),%r2
142 fstws %fr8R,-16(0,%r30)
143 copy %r2,%r20
144 ldw -16(0,%r30),%r2
145 addl %r2,%r19,%r21
146 comclr,<<= %r19,%r21,0
147 addl %r20,%r31,%r20
148L$0015
149 extru %r21,15,16,%r19
150 addl %r20,%r19,%r20
151 zdep %r21,15,16,%r19
152 addl %r22,%r19,%r22
153 comclr,<<= %r19,%r22,0
154 addi,tr 1,%r20,%r19
155 copy %r20,%r19
156 addl %r22,%r28,%r20
157 comclr,<<= %r28,%r20,0
158 addi 1,%r19,%r19
159 ldw -4(0,%r23),%r28
160 addl %r20,%r28,%r20
161 comclr,<<= %r28,%r20,0
162 addi,tr 1,%r19,%r28
163 copy %r19,%r28
164 addib,= -1,%r24,L$0003
165 stw %r20,-4(0,%r23)
166 ldw 0(0,%r29),%r19
167 extru %r19,31,16,%r20
168 stw %r20,-16(0,%r30)
169 extru %r19,15,16,%r19
170 fldws -16(0,%r30),%fr22L
171 stw %r19,-16(0,%r30)
172 xmpyu %fr22L,%fr11R,%fr8
173 fldws -16(0,%r30),%fr22L
174 fstws %fr8R,-16(0,%r30)
175 xmpyu %fr11R,%fr22L,%fr10
176 ldw -16(0,%r30),%r2
177 stw %r20,-16(0,%r30)
178 xmpyu %fr22L,%fr11L,%fr9
179 fldws -16(0,%r30),%fr22L
180 fstws %fr10R,-16(0,%r30)
181 copy %r2,%r22
182 ldw -16(0,%r30),%r2
183 fstws %fr9R,-16(0,%r30)
184 xmpyu %fr11L,%fr22L,%fr8
185 copy %r2,%r19
186 ldw -16(0,%r30),%r2
187 fstws %fr8R,-16(0,%r30)
188 copy %r2,%r20
189 ldw -16(0,%r30),%r2
190 addl %r2,%r19,%r21
191 comclr,<<= %r19,%r21,0
192 addl %r20,%r31,%r20
193L$0020
194 extru %r21,15,16,%r19
195 addl %r20,%r19,%r20
196 zdep %r21,15,16,%r19
197 addl %r22,%r19,%r22
198 comclr,<<= %r19,%r22,0
199 addi,tr 1,%r20,%r19
200 copy %r20,%r19
201 addl %r22,%r28,%r20
202 comclr,<<= %r28,%r20,0
203 addi 1,%r19,%r19
204 ldw 0(0,%r23),%r28
205 addl %r20,%r28,%r20
206 comclr,<<= %r28,%r20,0
207 addi,tr 1,%r19,%r28
208 copy %r19,%r28
209 addib,= -1,%r24,L$0003
210 stw %r20,0(0,%r23)
211 ldo 16(%r29),%r29
212 ldo 16(%r25),%r25
213 ldo 16(%r23),%r23
214 bl L$0002,0
215 ldo 16(%r26),%r26
216L$0003
217 ldw -20(0,%r30),%r2
218 bv,n 0(%r2)
219 .EXIT
220 .PROCEND
221 .align 4
222 .EXPORT bn_mul_words,ENTRY,PRIV_LEV=3,ARGW0=GR,ARGW1=GR,ARGW2=GR,ARGW3=GR,RTNVAL=GR
223bn_mul_words
224 .PROC
225 .CALLINFO FRAME=0,CALLS,SAVE_RP
226 .ENTRY
227 stw %r2,-20(0,%r30)
228 ldi 0,%r28
229 extru %r23,31,16,%r2
230 stw %r2,-16(0,%r30)
231 extru %r23,15,16,%r23
232 ldil L'65536,%r31
233 fldws -16(0,%r30),%fr11R
234 stw %r23,-16(0,%r30)
235 ldo 12(%r26),%r29
236 ldo 12(%r25),%r23
237 fldws -16(0,%r30),%fr11L
238L$0026
239 ldw 0(0,%r25),%r19
240 extru %r19,31,16,%r20
241 stw %r20,-16(0,%r30)
242 extru %r19,15,16,%r19
243 fldws -16(0,%r30),%fr22L
244 stw %r19,-16(0,%r30)
245 xmpyu %fr22L,%fr11R,%fr8
246 fldws -16(0,%r30),%fr22L
247 fstws %fr8R,-16(0,%r30)
248 xmpyu %fr11R,%fr22L,%fr10
249 ldw -16(0,%r30),%r2
250 stw %r20,-16(0,%r30)
251 xmpyu %fr22L,%fr11L,%fr9
252 fldws -16(0,%r30),%fr22L
253 fstws %fr10R,-16(0,%r30)
254 copy %r2,%r22
255 ldw -16(0,%r30),%r2
256 fstws %fr9R,-16(0,%r30)
257 xmpyu %fr11L,%fr22L,%fr8
258 copy %r2,%r19
259 ldw -16(0,%r30),%r2
260 fstws %fr8R,-16(0,%r30)
261 copy %r2,%r20
262 ldw -16(0,%r30),%r2
263 addl %r2,%r19,%r21
264 comclr,<<= %r19,%r21,0
265 addl %r20,%r31,%r20
266L$0029
267 extru %r21,15,16,%r19
268 addl %r20,%r19,%r20
269 zdep %r21,15,16,%r19
270 addl %r22,%r19,%r22
271 comclr,<<= %r19,%r22,0
272 addi,tr 1,%r20,%r19
273 copy %r20,%r19
274 addl %r22,%r28,%r20
275 comclr,<<= %r28,%r20,0
276 addi,tr 1,%r19,%r28
277 copy %r19,%r28
278 addib,= -1,%r24,L$0027
279 stw %r20,0(0,%r26)
280 ldw -8(0,%r23),%r19
281 extru %r19,31,16,%r20
282 stw %r20,-16(0,%r30)
283 extru %r19,15,16,%r19
284 fldws -16(0,%r30),%fr22L
285 stw %r19,-16(0,%r30)
286 xmpyu %fr22L,%fr11R,%fr8
287 fldws -16(0,%r30),%fr22L
288 fstws %fr8R,-16(0,%r30)
289 xmpyu %fr11R,%fr22L,%fr10
290 ldw -16(0,%r30),%r2
291 stw %r20,-16(0,%r30)
292 xmpyu %fr22L,%fr11L,%fr9
293 fldws -16(0,%r30),%fr22L
294 fstws %fr10R,-16(0,%r30)
295 copy %r2,%r22
296 ldw -16(0,%r30),%r2
297 fstws %fr9R,-16(0,%r30)
298 xmpyu %fr11L,%fr22L,%fr8
299 copy %r2,%r19
300 ldw -16(0,%r30),%r2
301 fstws %fr8R,-16(0,%r30)
302 copy %r2,%r20
303 ldw -16(0,%r30),%r2
304 addl %r2,%r19,%r21
305 comclr,<<= %r19,%r21,0
306 addl %r20,%r31,%r20
307L$0033
308 extru %r21,15,16,%r19
309 addl %r20,%r19,%r20
310 zdep %r21,15,16,%r19
311 addl %r22,%r19,%r22
312 comclr,<<= %r19,%r22,0
313 addi,tr 1,%r20,%r19
314 copy %r20,%r19
315 addl %r22,%r28,%r20
316 comclr,<<= %r28,%r20,0
317 addi,tr 1,%r19,%r28
318 copy %r19,%r28
319 addib,= -1,%r24,L$0027
320 stw %r20,-8(0,%r29)
321 ldw -4(0,%r23),%r19
322 extru %r19,31,16,%r20
323 stw %r20,-16(0,%r30)
324 extru %r19,15,16,%r19
325 fldws -16(0,%r30),%fr22L
326 stw %r19,-16(0,%r30)
327 xmpyu %fr22L,%fr11R,%fr8
328 fldws -16(0,%r30),%fr22L
329 fstws %fr8R,-16(0,%r30)
330 xmpyu %fr11R,%fr22L,%fr10
331 ldw -16(0,%r30),%r2
332 stw %r20,-16(0,%r30)
333 xmpyu %fr22L,%fr11L,%fr9
334 fldws -16(0,%r30),%fr22L
335 fstws %fr10R,-16(0,%r30)
336 copy %r2,%r22
337 ldw -16(0,%r30),%r2
338 fstws %fr9R,-16(0,%r30)
339 xmpyu %fr11L,%fr22L,%fr8
340 copy %r2,%r19
341 ldw -16(0,%r30),%r2
342 fstws %fr8R,-16(0,%r30)
343 copy %r2,%r20
344 ldw -16(0,%r30),%r2
345 addl %r2,%r19,%r21
346 comclr,<<= %r19,%r21,0
347 addl %r20,%r31,%r20
348L$0037
349 extru %r21,15,16,%r19
350 addl %r20,%r19,%r20
351 zdep %r21,15,16,%r19
352 addl %r22,%r19,%r22
353 comclr,<<= %r19,%r22,0
354 addi,tr 1,%r20,%r19
355 copy %r20,%r19
356 addl %r22,%r28,%r20
357 comclr,<<= %r28,%r20,0
358 addi,tr 1,%r19,%r28
359 copy %r19,%r28
360 addib,= -1,%r24,L$0027
361 stw %r20,-4(0,%r29)
362 ldw 0(0,%r23),%r19
363 extru %r19,31,16,%r20
364 stw %r20,-16(0,%r30)
365 extru %r19,15,16,%r19
366 fldws -16(0,%r30),%fr22L
367 stw %r19,-16(0,%r30)
368 xmpyu %fr22L,%fr11R,%fr8
369 fldws -16(0,%r30),%fr22L
370 fstws %fr8R,-16(0,%r30)
371 xmpyu %fr11R,%fr22L,%fr10
372 ldw -16(0,%r30),%r2
373 stw %r20,-16(0,%r30)
374 xmpyu %fr22L,%fr11L,%fr9
375 fldws -16(0,%r30),%fr22L
376 fstws %fr10R,-16(0,%r30)
377 copy %r2,%r22
378 ldw -16(0,%r30),%r2
379 fstws %fr9R,-16(0,%r30)
380 xmpyu %fr11L,%fr22L,%fr8
381 copy %r2,%r19
382 ldw -16(0,%r30),%r2
383 fstws %fr8R,-16(0,%r30)
384 copy %r2,%r20
385 ldw -16(0,%r30),%r2
386 addl %r2,%r19,%r21
387 comclr,<<= %r19,%r21,0
388 addl %r20,%r31,%r20
389L$0041
390 extru %r21,15,16,%r19
391 addl %r20,%r19,%r20
392 zdep %r21,15,16,%r19
393 addl %r22,%r19,%r22
394 comclr,<<= %r19,%r22,0
395 addi,tr 1,%r20,%r19
396 copy %r20,%r19
397 addl %r22,%r28,%r20
398 comclr,<<= %r28,%r20,0
399 addi,tr 1,%r19,%r28
400 copy %r19,%r28
401 addib,= -1,%r24,L$0027
402 stw %r20,0(0,%r29)
403 ldo 16(%r23),%r23
404 ldo 16(%r25),%r25
405 ldo 16(%r29),%r29
406 bl L$0026,0
407 ldo 16(%r26),%r26
408L$0027
409 ldw -20(0,%r30),%r2
410 bv,n 0(%r2)
411 .EXIT
412 .PROCEND
413 .align 4
414 .EXPORT bn_sqr_words,ENTRY,PRIV_LEV=3,ARGW0=GR,ARGW1=GR,ARGW2=GR
415bn_sqr_words
416 .PROC
417 .CALLINFO FRAME=0,NO_CALLS
418 .ENTRY
419 ldo 28(%r26),%r23
420 ldo 12(%r25),%r28
421L$0046
422 ldw 0(0,%r25),%r21
423 extru %r21,31,16,%r22
424 stw %r22,-16(0,%r30)
425 extru %r21,15,16,%r21
426 fldws -16(0,%r30),%fr10L
427 stw %r21,-16(0,%r30)
428 fldws -16(0,%r30),%fr10R
429 xmpyu %fr10L,%fr10R,%fr8
430 fstws %fr8R,-16(0,%r30)
431 ldw -16(0,%r30),%r29
432 stw %r22,-16(0,%r30)
433 fldws -16(0,%r30),%fr10R
434 stw %r21,-16(0,%r30)
435 copy %r29,%r19
436 xmpyu %fr10L,%fr10R,%fr8
437 fldws -16(0,%r30),%fr10L
438 stw %r21,-16(0,%r30)
439 fldws -16(0,%r30),%fr10R
440 fstws %fr8R,-16(0,%r30)
441 extru %r19,16,17,%r20
442 zdep %r19,14,15,%r19
443 ldw -16(0,%r30),%r29
444 xmpyu %fr10L,%fr10R,%fr9
445 addl %r29,%r19,%r22
446 stw %r22,0(0,%r26)
447 fstws %fr9R,-16(0,%r30)
448 ldw -16(0,%r30),%r29
449 addl %r29,%r20,%r21
450 comclr,<<= %r19,%r22,0
451 addi 1,%r21,%r21
452 addib,= -1,%r24,L$0057
453 stw %r21,-24(0,%r23)
454 ldw -8(0,%r28),%r21
455 extru %r21,31,16,%r22
456 stw %r22,-16(0,%r30)
457 extru %r21,15,16,%r21
458 fldws -16(0,%r30),%fr10L
459 stw %r21,-16(0,%r30)
460 fldws -16(0,%r30),%fr10R
461 xmpyu %fr10L,%fr10R,%fr8
462 fstws %fr8R,-16(0,%r30)
463 ldw -16(0,%r30),%r29
464 stw %r22,-16(0,%r30)
465 fldws -16(0,%r30),%fr10R
466 stw %r21,-16(0,%r30)
467 copy %r29,%r19
468 xmpyu %fr10L,%fr10R,%fr8
469 fldws -16(0,%r30),%fr10L
470 stw %r21,-16(0,%r30)
471 fldws -16(0,%r30),%fr10R
472 fstws %fr8R,-16(0,%r30)
473 extru %r19,16,17,%r20
474 zdep %r19,14,15,%r19
475 ldw -16(0,%r30),%r29
476 xmpyu %fr10L,%fr10R,%fr9
477 addl %r29,%r19,%r22
478 stw %r22,-20(0,%r23)
479 fstws %fr9R,-16(0,%r30)
480 ldw -16(0,%r30),%r29
481 addl %r29,%r20,%r21
482 comclr,<<= %r19,%r22,0
483 addi 1,%r21,%r21
484 addib,= -1,%r24,L$0057
485 stw %r21,-16(0,%r23)
486 ldw -4(0,%r28),%r21
487 extru %r21,31,16,%r22
488 stw %r22,-16(0,%r30)
489 extru %r21,15,16,%r21
490 fldws -16(0,%r30),%fr10L
491 stw %r21,-16(0,%r30)
492 fldws -16(0,%r30),%fr10R
493 xmpyu %fr10L,%fr10R,%fr8
494 fstws %fr8R,-16(0,%r30)
495 ldw -16(0,%r30),%r29
496 stw %r22,-16(0,%r30)
497 fldws -16(0,%r30),%fr10R
498 stw %r21,-16(0,%r30)
499 copy %r29,%r19
500 xmpyu %fr10L,%fr10R,%fr8
501 fldws -16(0,%r30),%fr10L
502 stw %r21,-16(0,%r30)
503 fldws -16(0,%r30),%fr10R
504 fstws %fr8R,-16(0,%r30)
505 extru %r19,16,17,%r20
506 zdep %r19,14,15,%r19
507 ldw -16(0,%r30),%r29
508 xmpyu %fr10L,%fr10R,%fr9
509 addl %r29,%r19,%r22
510 stw %r22,-12(0,%r23)
511 fstws %fr9R,-16(0,%r30)
512 ldw -16(0,%r30),%r29
513 addl %r29,%r20,%r21
514 comclr,<<= %r19,%r22,0
515 addi 1,%r21,%r21
516 addib,= -1,%r24,L$0057
517 stw %r21,-8(0,%r23)
518 ldw 0(0,%r28),%r21
519 extru %r21,31,16,%r22
520 stw %r22,-16(0,%r30)
521 extru %r21,15,16,%r21
522 fldws -16(0,%r30),%fr10L
523 stw %r21,-16(0,%r30)
524 fldws -16(0,%r30),%fr10R
525 xmpyu %fr10L,%fr10R,%fr8
526 fstws %fr8R,-16(0,%r30)
527 ldw -16(0,%r30),%r29
528 stw %r22,-16(0,%r30)
529 fldws -16(0,%r30),%fr10R
530 stw %r21,-16(0,%r30)
531 copy %r29,%r19
532 xmpyu %fr10L,%fr10R,%fr8
533 fldws -16(0,%r30),%fr10L
534 stw %r21,-16(0,%r30)
535 fldws -16(0,%r30),%fr10R
536 fstws %fr8R,-16(0,%r30)
537 extru %r19,16,17,%r20
538 zdep %r19,14,15,%r19
539 ldw -16(0,%r30),%r29
540 xmpyu %fr10L,%fr10R,%fr9
541 addl %r29,%r19,%r22
542 stw %r22,-4(0,%r23)
543 fstws %fr9R,-16(0,%r30)
544 ldw -16(0,%r30),%r29
545 addl %r29,%r20,%r21
546 comclr,<<= %r19,%r22,0
547 addi 1,%r21,%r21
548 addib,= -1,%r24,L$0057
549 stw %r21,0(0,%r23)
550 ldo 16(%r28),%r28
551 ldo 16(%r25),%r25
552 ldo 32(%r23),%r23
553 bl L$0046,0
554 ldo 32(%r26),%r26
555L$0057
556 bv,n 0(%r2)
557 .EXIT
558 .PROCEND
559 .IMPORT BN_num_bits_word,CODE
560 .IMPORT fprintf,CODE
561 .IMPORT __iob,DATA
562 .SPACE $TEXT$
563 .SUBSPA $LIT$
564
565 .align 4
566L$C0000
567 .STRING "Division would overflow\x0a\x00"
568 .IMPORT abort,CODE
569 .SPACE $TEXT$
570 .SUBSPA $CODE$
571
572 .align 4
573 .EXPORT bn_div64,ENTRY,PRIV_LEV=3,ARGW0=GR,ARGW1=GR,ARGW2=GR,RTNVAL=GR
574bn_div64
575 .PROC
576 .CALLINFO FRAME=128,CALLS,SAVE_RP,ENTRY_GR=8
577 .ENTRY
578 stw %r2,-20(0,%r30)
579 stwm %r8,128(0,%r30)
580 stw %r7,-124(0,%r30)
581 stw %r4,-112(0,%r30)
582 stw %r3,-108(0,%r30)
583 copy %r26,%r3
584 copy %r25,%r4
585 stw %r6,-120(0,%r30)
586 ldi 0,%r7
587 stw %r5,-116(0,%r30)
588 movb,<> %r24,%r5,L$0059
589 ldi 2,%r6
590 bl L$0076,0
591 ldi -1,%r28
592L$0059
593 .CALL ARGW0=GR
594 bl BN_num_bits_word,%r2
595 copy %r5,%r26
596 ldi 32,%r19
597 comb,= %r19,%r28,L$0060
598 subi 31,%r28,%r19
599 mtsar %r19
600 zvdepi 1,32,%r19
601 comb,>>= %r19,%r3,L$0060
602 addil LR'__iob-$global$+32,%r27
603 ldo RR'__iob-$global$+32(%r1),%r26
604 ldil LR'L$C0000,%r25
605 .CALL ARGW0=GR,ARGW1=GR
606 bl fprintf,%r2
607 ldo RR'L$C0000(%r25),%r25
608 .CALL
609 bl abort,%r2
610 nop
611L$0060
612 comb,>> %r5,%r3,L$0061
613 subi 32,%r28,%r28
614 sub %r3,%r5,%r3
615L$0061
616 comib,= 0,%r28,L$0062
617 subi 31,%r28,%r19
618 mtsar %r19
619 zvdep %r5,32,%r5
620 zvdep %r3,32,%r21
621 subi 32,%r28,%r20
622 mtsar %r20
623 vshd 0,%r4,%r20
624 or %r21,%r20,%r3
625 mtsar %r19
626 zvdep %r4,32,%r4
627L$0062
628 extru %r5,15,16,%r23
629 extru %r5,31,16,%r28
630L$0063
631 extru %r3,15,16,%r19
632 comb,<> %r23,%r19,L$0066
633 copy %r3,%r26
634 bl L$0067,0
635 zdepi -1,31,16,%r29
636L$0066
637 .IMPORT $$divU,MILLICODE
638 bl $$divU,%r31
639 copy %r23,%r25
640L$0067
641 stw %r29,-16(0,%r30)
642 fldws -16(0,%r30),%fr10L
643 stw %r28,-16(0,%r30)
644 fldws -16(0,%r30),%fr10R
645 stw %r23,-16(0,%r30)
646 xmpyu %fr10L,%fr10R,%fr8
647 fldws -16(0,%r30),%fr10R
648 fstws %fr8R,-16(0,%r30)
649 xmpyu %fr10L,%fr10R,%fr9
650 ldw -16(0,%r30),%r8
651 fstws %fr9R,-16(0,%r30)
652 copy %r8,%r22
653 ldw -16(0,%r30),%r8
654 extru %r4,15,16,%r24
655 copy %r8,%r21
656L$0068
657 sub %r3,%r21,%r20
658 copy %r20,%r19
659 depi 0,31,16,%r19
660 comib,<> 0,%r19,L$0069
661 zdep %r20,15,16,%r19
662 addl %r19,%r24,%r19
663 comb,>>= %r19,%r22,L$0069
664 sub %r22,%r28,%r22
665 sub %r21,%r23,%r21
666 bl L$0068,0
667 ldo -1(%r29),%r29
668L$0069
669 stw %r29,-16(0,%r30)
670 fldws -16(0,%r30),%fr10L
671 stw %r28,-16(0,%r30)
672 fldws -16(0,%r30),%fr10R
673 xmpyu %fr10L,%fr10R,%fr8
674 fstws %fr8R,-16(0,%r30)
675 ldw -16(0,%r30),%r8
676 stw %r23,-16(0,%r30)
677 fldws -16(0,%r30),%fr10R
678 copy %r8,%r19
679 xmpyu %fr10L,%fr10R,%fr8
680 fstws %fr8R,-16(0,%r30)
681 extru %r19,15,16,%r20
682 ldw -16(0,%r30),%r8
683 zdep %r19,15,16,%r19
684 addl %r8,%r20,%r20
685 comclr,<<= %r19,%r4,0
686 addi 1,%r20,%r20
687 comb,<<= %r20,%r3,L$0074
688 sub %r4,%r19,%r4
689 addl %r3,%r5,%r3
690 ldo -1(%r29),%r29
691L$0074
692 addib,= -1,%r6,L$0064
693 sub %r3,%r20,%r3
694 zdep %r29,15,16,%r7
695 shd %r3,%r4,16,%r3
696 bl L$0063,0
697 zdep %r4,15,16,%r4
698L$0064
699 or %r7,%r29,%r28
700L$0076
701 ldw -148(0,%r30),%r2
702 ldw -124(0,%r30),%r7
703 ldw -120(0,%r30),%r6
704 ldw -116(0,%r30),%r5
705 ldw -112(0,%r30),%r4
706 ldw -108(0,%r30),%r3
707 bv 0(%r2)
708 ldwm -128(0,%r30),%r8
709 .EXIT
710 .PROCEND
diff --git a/src/lib/libcrypto/bn/asm/r3000.s b/src/lib/libcrypto/bn/asm/r3000.s
deleted file mode 100644
index e95269afa3..0000000000
--- a/src/lib/libcrypto/bn/asm/r3000.s
+++ /dev/null
@@ -1,646 +0,0 @@
1 .file 1 "../bn_mulw.c"
2 .set nobopt
3 .option pic2
4
5 # GNU C 2.6.3 [AL 1.1, MM 40] SGI running IRIX 5.0 compiled by GNU C
6
7 # Cc1 defaults:
8 # -mabicalls
9
10 # Cc1 arguments (-G value = 0, Cpu = 3000, ISA = 1):
11 # -quiet -dumpbase -O2 -o
12
13gcc2_compiled.:
14__gnu_compiled_c:
15 .rdata
16
17 .byte 0x24,0x52,0x65,0x76,0x69,0x73,0x69,0x6f
18 .byte 0x6e,0x3a,0x20,0x31,0x2e,0x34,0x39,0x20
19 .byte 0x24,0x0
20
21 .byte 0x24,0x52,0x65,0x76,0x69,0x73,0x69,0x6f
22 .byte 0x6e,0x3a,0x20,0x31,0x2e,0x33,0x34,0x20
23 .byte 0x24,0x0
24
25 .byte 0x24,0x52,0x65,0x76,0x69,0x73,0x69,0x6f
26 .byte 0x6e,0x3a,0x20,0x31,0x2e,0x35,0x20,0x24
27 .byte 0x0
28
29 .byte 0x24,0x52,0x65,0x76,0x69,0x73,0x69,0x6f
30 .byte 0x6e,0x3a,0x20,0x31,0x2e,0x38,0x20,0x24
31 .byte 0x0
32
33 .byte 0x24,0x52,0x65,0x76,0x69,0x73,0x69,0x6f
34 .byte 0x6e,0x3a,0x20,0x31,0x2e,0x32,0x33,0x20
35 .byte 0x24,0x0
36
37 .byte 0x24,0x52,0x65,0x76,0x69,0x73,0x69,0x6f
38 .byte 0x6e,0x3a,0x20,0x31,0x2e,0x37,0x38,0x20
39 .byte 0x24,0x0
40
41 .byte 0x24,0x52,0x65,0x76,0x69,0x73,0x69,0x6f
42 .byte 0x6e,0x3a,0x20,0x33,0x2e,0x37,0x30,0x20
43 .byte 0x24,0x0
44
45 .byte 0x24,0x52,0x65,0x76,0x69,0x73,0x69,0x6f
46 .byte 0x6e,0x3a,0x20,0x31,0x2e,0x32,0x20,0x24
47 .byte 0x0
48
49 .byte 0x24,0x52,0x65,0x76,0x69,0x73,0x69,0x6f
50 .byte 0x6e,0x3a,0x20,0x31,0x2e,0x34,0x20,0x24
51 .byte 0x0
52
53 .byte 0x24,0x52,0x65,0x76,0x69,0x73,0x69,0x6f
54 .byte 0x6e,0x3a,0x20,0x31,0x2e,0x38,0x20,0x24
55 .byte 0x0
56 .text
57 .align 2
58 .globl bn_mul_add_words
59 .ent bn_mul_add_words
60bn_mul_add_words:
61 .frame $sp,0,$31 # vars= 0, regs= 0/0, args= 0, extra= 0
62 .mask 0x00000000,0
63 .fmask 0x00000000,0
64 .set noreorder
65 .cpload $25
66 .set reorder
67 move $12,$4
68 move $14,$5
69 move $9,$6
70 move $13,$7
71 move $8,$0
72 addu $10,$12,12
73 addu $11,$14,12
74$L2:
75 lw $6,0($14)
76 #nop
77 multu $13,$6
78 mfhi $6
79 mflo $7
80 #nop
81 move $5,$8
82 move $4,$0
83 lw $3,0($12)
84 addu $9,$9,-1
85 move $2,$0
86 addu $7,$7,$3
87 sltu $8,$7,$3
88 addu $6,$6,$2
89 addu $6,$6,$8
90 addu $7,$7,$5
91 sltu $2,$7,$5
92 addu $6,$6,$4
93 addu $6,$6,$2
94 srl $3,$6,0
95 move $2,$0
96 move $8,$3
97 .set noreorder
98 .set nomacro
99 beq $9,$0,$L3
100 sw $7,0($12)
101 .set macro
102 .set reorder
103
104 lw $6,-8($11)
105 #nop
106 multu $13,$6
107 mfhi $6
108 mflo $7
109 #nop
110 move $5,$8
111 move $4,$0
112 lw $3,-8($10)
113 addu $9,$9,-1
114 move $2,$0
115 addu $7,$7,$3
116 sltu $8,$7,$3
117 addu $6,$6,$2
118 addu $6,$6,$8
119 addu $7,$7,$5
120 sltu $2,$7,$5
121 addu $6,$6,$4
122 addu $6,$6,$2
123 srl $3,$6,0
124 move $2,$0
125 move $8,$3
126 .set noreorder
127 .set nomacro
128 beq $9,$0,$L3
129 sw $7,-8($10)
130 .set macro
131 .set reorder
132
133 lw $6,-4($11)
134 #nop
135 multu $13,$6
136 mfhi $6
137 mflo $7
138 #nop
139 move $5,$8
140 move $4,$0
141 lw $3,-4($10)
142 addu $9,$9,-1
143 move $2,$0
144 addu $7,$7,$3
145 sltu $8,$7,$3
146 addu $6,$6,$2
147 addu $6,$6,$8
148 addu $7,$7,$5
149 sltu $2,$7,$5
150 addu $6,$6,$4
151 addu $6,$6,$2
152 srl $3,$6,0
153 move $2,$0
154 move $8,$3
155 .set noreorder
156 .set nomacro
157 beq $9,$0,$L3
158 sw $7,-4($10)
159 .set macro
160 .set reorder
161
162 lw $6,0($11)
163 #nop
164 multu $13,$6
165 mfhi $6
166 mflo $7
167 #nop
168 move $5,$8
169 move $4,$0
170 lw $3,0($10)
171 addu $9,$9,-1
172 move $2,$0
173 addu $7,$7,$3
174 sltu $8,$7,$3
175 addu $6,$6,$2
176 addu $6,$6,$8
177 addu $7,$7,$5
178 sltu $2,$7,$5
179 addu $6,$6,$4
180 addu $6,$6,$2
181 srl $3,$6,0
182 move $2,$0
183 move $8,$3
184 .set noreorder
185 .set nomacro
186 beq $9,$0,$L3
187 sw $7,0($10)
188 .set macro
189 .set reorder
190
191 addu $11,$11,16
192 addu $14,$14,16
193 addu $10,$10,16
194 .set noreorder
195 .set nomacro
196 j $L2
197 addu $12,$12,16
198 .set macro
199 .set reorder
200
201$L3:
202 .set noreorder
203 .set nomacro
204 j $31
205 move $2,$8
206 .set macro
207 .set reorder
208
209 .end bn_mul_add_words
210 .align 2
211 .globl bn_mul_words
212 .ent bn_mul_words
213bn_mul_words:
214 .frame $sp,0,$31 # vars= 0, regs= 0/0, args= 0, extra= 0
215 .mask 0x00000000,0
216 .fmask 0x00000000,0
217 .set noreorder
218 .cpload $25
219 .set reorder
220 move $11,$4
221 move $12,$5
222 move $8,$6
223 move $6,$0
224 addu $10,$11,12
225 addu $9,$12,12
226$L10:
227 lw $4,0($12)
228 #nop
229 multu $7,$4
230 mfhi $4
231 mflo $5
232 #nop
233 move $3,$6
234 move $2,$0
235 addu $8,$8,-1
236 addu $5,$5,$3
237 sltu $6,$5,$3
238 addu $4,$4,$2
239 addu $4,$4,$6
240 srl $3,$4,0
241 move $2,$0
242 move $6,$3
243 .set noreorder
244 .set nomacro
245 beq $8,$0,$L11
246 sw $5,0($11)
247 .set macro
248 .set reorder
249
250 lw $4,-8($9)
251 #nop
252 multu $7,$4
253 mfhi $4
254 mflo $5
255 #nop
256 move $3,$6
257 move $2,$0
258 addu $8,$8,-1
259 addu $5,$5,$3
260 sltu $6,$5,$3
261 addu $4,$4,$2
262 addu $4,$4,$6
263 srl $3,$4,0
264 move $2,$0
265 move $6,$3
266 .set noreorder
267 .set nomacro
268 beq $8,$0,$L11
269 sw $5,-8($10)
270 .set macro
271 .set reorder
272
273 lw $4,-4($9)
274 #nop
275 multu $7,$4
276 mfhi $4
277 mflo $5
278 #nop
279 move $3,$6
280 move $2,$0
281 addu $8,$8,-1
282 addu $5,$5,$3
283 sltu $6,$5,$3
284 addu $4,$4,$2
285 addu $4,$4,$6
286 srl $3,$4,0
287 move $2,$0
288 move $6,$3
289 .set noreorder
290 .set nomacro
291 beq $8,$0,$L11
292 sw $5,-4($10)
293 .set macro
294 .set reorder
295
296 lw $4,0($9)
297 #nop
298 multu $7,$4
299 mfhi $4
300 mflo $5
301 #nop
302 move $3,$6
303 move $2,$0
304 addu $8,$8,-1
305 addu $5,$5,$3
306 sltu $6,$5,$3
307 addu $4,$4,$2
308 addu $4,$4,$6
309 srl $3,$4,0
310 move $2,$0
311 move $6,$3
312 .set noreorder
313 .set nomacro
314 beq $8,$0,$L11
315 sw $5,0($10)
316 .set macro
317 .set reorder
318
319 addu $9,$9,16
320 addu $12,$12,16
321 addu $10,$10,16
322 .set noreorder
323 .set nomacro
324 j $L10
325 addu $11,$11,16
326 .set macro
327 .set reorder
328
329$L11:
330 .set noreorder
331 .set nomacro
332 j $31
333 move $2,$6
334 .set macro
335 .set reorder
336
337 .end bn_mul_words
338 .align 2
339 .globl bn_sqr_words
340 .ent bn_sqr_words
341bn_sqr_words:
342 .frame $sp,0,$31 # vars= 0, regs= 0/0, args= 0, extra= 0
343 .mask 0x00000000,0
344 .fmask 0x00000000,0
345 .set noreorder
346 .cpload $25
347 .set reorder
348 move $9,$4
349 addu $7,$9,28
350 addu $8,$5,12
351$L18:
352 lw $2,0($5)
353 #nop
354 multu $2,$2
355 mfhi $2
356 mflo $3
357 #nop
358 addu $6,$6,-1
359 sw $3,0($9)
360 srl $3,$2,0
361 move $2,$0
362 .set noreorder
363 .set nomacro
364 beq $6,$0,$L19
365 sw $3,-24($7)
366 .set macro
367 .set reorder
368
369 lw $2,-8($8)
370 #nop
371 multu $2,$2
372 mfhi $2
373 mflo $3
374 #nop
375 addu $6,$6,-1
376 sw $3,-20($7)
377 srl $3,$2,0
378 move $2,$0
379 .set noreorder
380 .set nomacro
381 beq $6,$0,$L19
382 sw $3,-16($7)
383 .set macro
384 .set reorder
385
386 lw $2,-4($8)
387 #nop
388 multu $2,$2
389 mfhi $2
390 mflo $3
391 #nop
392 addu $6,$6,-1
393 sw $3,-12($7)
394 srl $3,$2,0
395 move $2,$0
396 .set noreorder
397 .set nomacro
398 beq $6,$0,$L19
399 sw $3,-8($7)
400 .set macro
401 .set reorder
402
403 lw $2,0($8)
404 #nop
405 multu $2,$2
406 mfhi $2
407 mflo $3
408 #nop
409 addu $6,$6,-1
410 sw $3,-4($7)
411 srl $3,$2,0
412 move $2,$0
413 .set noreorder
414 .set nomacro
415 beq $6,$0,$L19
416 sw $3,0($7)
417 .set macro
418 .set reorder
419
420 addu $8,$8,16
421 addu $5,$5,16
422 addu $7,$7,32
423 .set noreorder
424 .set nomacro
425 j $L18
426 addu $9,$9,32
427 .set macro
428 .set reorder
429
430$L19:
431 j $31
432 .end bn_sqr_words
433 .rdata
434 .align 2
435$LC0:
436
437 .byte 0x44,0x69,0x76,0x69,0x73,0x69,0x6f,0x6e
438 .byte 0x20,0x77,0x6f,0x75,0x6c,0x64,0x20,0x6f
439 .byte 0x76,0x65,0x72,0x66,0x6c,0x6f,0x77,0xa
440 .byte 0x0
441 .text
442 .align 2
443 .globl bn_div64
444 .ent bn_div64
445bn_div64:
446 .frame $sp,56,$31 # vars= 0, regs= 7/0, args= 16, extra= 8
447 .mask 0x901f0000,-8
448 .fmask 0x00000000,0
449 .set noreorder
450 .cpload $25
451 .set reorder
452 subu $sp,$sp,56
453 .cprestore 16
454 sw $16,24($sp)
455 move $16,$4
456 sw $17,28($sp)
457 move $17,$5
458 sw $18,32($sp)
459 move $18,$6
460 sw $20,40($sp)
461 move $20,$0
462 sw $19,36($sp)
463 li $19,0x00000002 # 2
464 sw $31,48($sp)
465 .set noreorder
466 .set nomacro
467 bne $18,$0,$L26
468 sw $28,44($sp)
469 .set macro
470 .set reorder
471
472 .set noreorder
473 .set nomacro
474 j $L43
475 li $2,-1 # 0xffffffff
476 .set macro
477 .set reorder
478
479$L26:
480 move $4,$18
481 jal BN_num_bits_word
482 move $4,$2
483 li $2,0x00000020 # 32
484 .set noreorder
485 .set nomacro
486 beq $4,$2,$L27
487 li $2,0x00000001 # 1
488 .set macro
489 .set reorder
490
491 sll $2,$2,$4
492 sltu $2,$2,$16
493 .set noreorder
494 .set nomacro
495 beq $2,$0,$L44
496 li $5,0x00000020 # 32
497 .set macro
498 .set reorder
499
500 la $4,__iob+32
501 la $5,$LC0
502 jal fprintf
503 jal abort
504$L27:
505 li $5,0x00000020 # 32
506$L44:
507 sltu $2,$16,$18
508 .set noreorder
509 .set nomacro
510 bne $2,$0,$L28
511 subu $4,$5,$4
512 .set macro
513 .set reorder
514
515 subu $16,$16,$18
516$L28:
517 .set noreorder
518 .set nomacro
519 beq $4,$0,$L29
520 li $10,-65536 # 0xffff0000
521 .set macro
522 .set reorder
523
524 sll $18,$18,$4
525 sll $3,$16,$4
526 subu $2,$5,$4
527 srl $2,$17,$2
528 or $16,$3,$2
529 sll $17,$17,$4
530$L29:
531 srl $7,$18,16
532 andi $9,$18,0xffff
533$L30:
534 srl $2,$16,16
535 .set noreorder
536 .set nomacro
537 beq $2,$7,$L34
538 li $6,0x0000ffff # 65535
539 .set macro
540 .set reorder
541
542 divu $6,$16,$7
543$L34:
544 mult $6,$9
545 mflo $5
546 #nop
547 #nop
548 mult $6,$7
549 and $2,$17,$10
550 srl $8,$2,16
551 mflo $4
552$L35:
553 subu $3,$16,$4
554 and $2,$3,$10
555 .set noreorder
556 .set nomacro
557 bne $2,$0,$L36
558 sll $2,$3,16
559 .set macro
560 .set reorder
561
562 addu $2,$2,$8
563 sltu $2,$2,$5
564 .set noreorder
565 .set nomacro
566 beq $2,$0,$L36
567 subu $5,$5,$9
568 .set macro
569 .set reorder
570
571 subu $4,$4,$7
572 .set noreorder
573 .set nomacro
574 j $L35
575 addu $6,$6,-1
576 .set macro
577 .set reorder
578
579$L36:
580 mult $6,$7
581 mflo $5
582 #nop
583 #nop
584 mult $6,$9
585 mflo $4
586 #nop
587 #nop
588 srl $3,$4,16
589 sll $2,$4,16
590 and $4,$2,$10
591 sltu $2,$17,$4
592 .set noreorder
593 .set nomacro
594 beq $2,$0,$L40
595 addu $5,$5,$3
596 .set macro
597 .set reorder
598
599 addu $5,$5,1
600$L40:
601 sltu $2,$16,$5
602 .set noreorder
603 .set nomacro
604 beq $2,$0,$L41
605 subu $17,$17,$4
606 .set macro
607 .set reorder
608
609 addu $16,$16,$18
610 addu $6,$6,-1
611$L41:
612 addu $19,$19,-1
613 .set noreorder
614 .set nomacro
615 beq $19,$0,$L31
616 subu $16,$16,$5
617 .set macro
618 .set reorder
619
620 sll $20,$6,16
621 sll $3,$16,16
622 srl $2,$17,16
623 or $16,$3,$2
624 .set noreorder
625 .set nomacro
626 j $L30
627 sll $17,$17,16
628 .set macro
629 .set reorder
630
631$L31:
632 or $2,$20,$6
633$L43:
634 lw $31,48($sp)
635 lw $20,40($sp)
636 lw $19,36($sp)
637 lw $18,32($sp)
638 lw $17,28($sp)
639 lw $16,24($sp)
640 addu $sp,$sp,56
641 j $31
642 .end bn_div64
643
644 .globl abort .text
645 .globl fprintf .text
646 .globl BN_num_bits_word .text
diff --git a/src/lib/libcrypto/bn/asm/sparcv8plus.S b/src/lib/libcrypto/bn/asm/sparcv8plus.S
index 8c56e2e7e7..63de1860f2 100644
--- a/src/lib/libcrypto/bn/asm/sparcv8plus.S
+++ b/src/lib/libcrypto/bn/asm/sparcv8plus.S
@@ -144,6 +144,19 @@
144 * } 144 * }
145 */ 145 */
146 146
147#if defined(__SUNPRO_C) && defined(__sparcv9)
148 /* They've said -xarch=v9 at command line */
149 .register %g2,#scratch
150 .register %g3,#scratch
151# define FRAME_SIZE -192
152#elif defined(__GNUC__) && defined(__arch64__)
153 /* They've said -m64 at command line */
154 .register %g2,#scratch
155 .register %g3,#scratch
156# define FRAME_SIZE -192
157#else
158# define FRAME_SIZE -96
159#endif
147/* 160/*
148 * GNU assembler can't stand stuw:-( 161 * GNU assembler can't stand stuw:-(
149 */ 162 */
@@ -619,8 +632,6 @@ bn_sub_words:
619 * Andy. 632 * Andy.
620 */ 633 */
621 634
622#define FRAME_SIZE -96
623
624/* 635/*
625 * Here is register usage map for *all* routines below. 636 * Here is register usage map for *all* routines below.
626 */ 637 */
diff --git a/src/lib/libcrypto/bn/bn.h b/src/lib/libcrypto/bn/bn.h
index f1719a5877..e484b7fc11 100644
--- a/src/lib/libcrypto/bn/bn.h
+++ b/src/lib/libcrypto/bn/bn.h
@@ -56,6 +56,59 @@
56 * [including the GNU Public Licence.] 56 * [including the GNU Public Licence.]
57 */ 57 */
58/* ==================================================================== 58/* ====================================================================
59 * Copyright (c) 1998-2006 The OpenSSL Project. All rights reserved.
60 *
61 * Redistribution and use in source and binary forms, with or without
62 * modification, are permitted provided that the following conditions
63 * are met:
64 *
65 * 1. Redistributions of source code must retain the above copyright
66 * notice, this list of conditions and the following disclaimer.
67 *
68 * 2. Redistributions in binary form must reproduce the above copyright
69 * notice, this list of conditions and the following disclaimer in
70 * the documentation and/or other materials provided with the
71 * distribution.
72 *
73 * 3. All advertising materials mentioning features or use of this
74 * software must display the following acknowledgment:
75 * "This product includes software developed by the OpenSSL Project
76 * for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
77 *
78 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
79 * endorse or promote products derived from this software without
80 * prior written permission. For written permission, please contact
81 * openssl-core@openssl.org.
82 *
83 * 5. Products derived from this software may not be called "OpenSSL"
84 * nor may "OpenSSL" appear in their names without prior written
85 * permission of the OpenSSL Project.
86 *
87 * 6. Redistributions of any form whatsoever must retain the following
88 * acknowledgment:
89 * "This product includes software developed by the OpenSSL Project
90 * for use in the OpenSSL Toolkit (http://www.openssl.org/)"
91 *
92 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
93 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
94 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
95 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
96 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
97 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
98 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
99 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
100 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
101 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
102 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
103 * OF THE POSSIBILITY OF SUCH DAMAGE.
104 * ====================================================================
105 *
106 * This product includes cryptographic software written by Eric Young
107 * (eay@cryptsoft.com). This product includes software written by Tim
108 * Hudson (tjh@cryptsoft.com).
109 *
110 */
111/* ====================================================================
59 * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. 112 * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED.
60 * 113 *
61 * Portions of the attached software ("Contribution") are developed by 114 * Portions of the attached software ("Contribution") are developed by
@@ -77,6 +130,7 @@
77#include <stdio.h> /* FILE */ 130#include <stdio.h> /* FILE */
78#endif 131#endif
79#include <openssl/ossl_typ.h> 132#include <openssl/ossl_typ.h>
133#include <openssl/crypto.h>
80 134
81#ifdef __cplusplus 135#ifdef __cplusplus
82extern "C" { 136extern "C" {
@@ -94,9 +148,11 @@ extern "C" {
94/* #define BN_DEBUG */ 148/* #define BN_DEBUG */
95/* #define BN_DEBUG_RAND */ 149/* #define BN_DEBUG_RAND */
96 150
151#ifndef OPENSSL_SMALL_FOOTPRINT
97#define BN_MUL_COMBA 152#define BN_MUL_COMBA
98#define BN_SQR_COMBA 153#define BN_SQR_COMBA
99#define BN_RECURSION 154#define BN_RECURSION
155#endif
100 156
101/* This next option uses the C libraries (2 word)/(1 word) function. 157/* This next option uses the C libraries (2 word)/(1 word) function.
102 * If it is not defined, I use my C version (which is slower). 158 * If it is not defined, I use my C version (which is slower).
@@ -137,6 +193,8 @@ extern "C" {
137#define BN_DEC_FMT1 "%lu" 193#define BN_DEC_FMT1 "%lu"
138#define BN_DEC_FMT2 "%019lu" 194#define BN_DEC_FMT2 "%019lu"
139#define BN_DEC_NUM 19 195#define BN_DEC_NUM 19
196#define BN_HEX_FMT1 "%lX"
197#define BN_HEX_FMT2 "%016lX"
140#endif 198#endif
141 199
142/* This is where the long long data type is 64 bits, but long is 32. 200/* This is where the long long data type is 64 bits, but long is 32.
@@ -162,83 +220,37 @@ extern "C" {
162#define BN_DEC_FMT1 "%llu" 220#define BN_DEC_FMT1 "%llu"
163#define BN_DEC_FMT2 "%019llu" 221#define BN_DEC_FMT2 "%019llu"
164#define BN_DEC_NUM 19 222#define BN_DEC_NUM 19
223#define BN_HEX_FMT1 "%llX"
224#define BN_HEX_FMT2 "%016llX"
165#endif 225#endif
166 226
167#ifdef THIRTY_TWO_BIT 227#ifdef THIRTY_TWO_BIT
168#ifdef BN_LLONG 228#ifdef BN_LLONG
169# if defined(OPENSSL_SYS_WIN32) && !defined(__GNUC__) 229# if defined(_WIN32) && !defined(__GNUC__)
170# define BN_ULLONG unsigned __int64 230# define BN_ULLONG unsigned __int64
231# define BN_MASK (0xffffffffffffffffI64)
171# else 232# else
172# define BN_ULLONG unsigned long long 233# define BN_ULLONG unsigned long long
234# define BN_MASK (0xffffffffffffffffLL)
173# endif 235# endif
174#endif 236#endif
175#define BN_ULONG unsigned long 237#define BN_ULONG unsigned int
176#define BN_LONG long 238#define BN_LONG int
177#define BN_BITS 64 239#define BN_BITS 64
178#define BN_BYTES 4 240#define BN_BYTES 4
179#define BN_BITS2 32 241#define BN_BITS2 32
180#define BN_BITS4 16 242#define BN_BITS4 16
181#ifdef OPENSSL_SYS_WIN32
182/* VC++ doesn't like the LL suffix */
183#define BN_MASK (0xffffffffffffffffL)
184#else
185#define BN_MASK (0xffffffffffffffffLL)
186#endif
187#define BN_MASK2 (0xffffffffL) 243#define BN_MASK2 (0xffffffffL)
188#define BN_MASK2l (0xffff) 244#define BN_MASK2l (0xffff)
189#define BN_MASK2h1 (0xffff8000L) 245#define BN_MASK2h1 (0xffff8000L)
190#define BN_MASK2h (0xffff0000L) 246#define BN_MASK2h (0xffff0000L)
191#define BN_TBIT (0x80000000L) 247#define BN_TBIT (0x80000000L)
192#define BN_DEC_CONV (1000000000L) 248#define BN_DEC_CONV (1000000000L)
193#define BN_DEC_FMT1 "%lu"
194#define BN_DEC_FMT2 "%09lu"
195#define BN_DEC_NUM 9
196#endif
197
198#ifdef SIXTEEN_BIT
199#ifndef BN_DIV2W
200#define BN_DIV2W
201#endif
202#define BN_ULLONG unsigned long
203#define BN_ULONG unsigned short
204#define BN_LONG short
205#define BN_BITS 32
206#define BN_BYTES 2
207#define BN_BITS2 16
208#define BN_BITS4 8
209#define BN_MASK (0xffffffff)
210#define BN_MASK2 (0xffff)
211#define BN_MASK2l (0xff)
212#define BN_MASK2h1 (0xff80)
213#define BN_MASK2h (0xff00)
214#define BN_TBIT (0x8000)
215#define BN_DEC_CONV (100000)
216#define BN_DEC_FMT1 "%u" 249#define BN_DEC_FMT1 "%u"
217#define BN_DEC_FMT2 "%05u" 250#define BN_DEC_FMT2 "%09u"
218#define BN_DEC_NUM 5 251#define BN_DEC_NUM 9
219#endif 252#define BN_HEX_FMT1 "%X"
220 253#define BN_HEX_FMT2 "%08X"
221#ifdef EIGHT_BIT
222#ifndef BN_DIV2W
223#define BN_DIV2W
224#endif
225#define BN_ULLONG unsigned short
226#define BN_ULONG unsigned char
227#define BN_LONG char
228#define BN_BITS 16
229#define BN_BYTES 1
230#define BN_BITS2 8
231#define BN_BITS4 4
232#define BN_MASK (0xffff)
233#define BN_MASK2 (0xff)
234#define BN_MASK2l (0xf)
235#define BN_MASK2h1 (0xf8)
236#define BN_MASK2h (0xf0)
237#define BN_TBIT (0x80)
238#define BN_DEC_CONV (100)
239#define BN_DEC_FMT1 "%u"
240#define BN_DEC_FMT2 "%02u"
241#define BN_DEC_NUM 2
242#endif 254#endif
243 255
244#define BN_DEFAULT_BITS 1280 256#define BN_DEFAULT_BITS 1280
@@ -303,12 +315,8 @@ struct bn_mont_ctx_st
303 BIGNUM N; /* The modulus */ 315 BIGNUM N; /* The modulus */
304 BIGNUM Ni; /* R*(1/R mod N) - N*Ni = 1 316 BIGNUM Ni; /* R*(1/R mod N) - N*Ni = 1
305 * (Ni is only stored for bignum algorithm) */ 317 * (Ni is only stored for bignum algorithm) */
306#if 0 318 BN_ULONG n0[2];/* least significant word(s) of Ni;
307 /* OpenSSL 0.9.9 preview: */ 319 (type changed with 0.9.9, was "BN_ULONG n0;" before) */
308 BN_ULONG n0[2];/* least significant word(s) of Ni */
309#else
310 BN_ULONG n0; /* least significant word of Ni */
311#endif
312 int flags; 320 int flags;
313 }; 321 };
314 322
@@ -504,6 +512,7 @@ char * BN_bn2hex(const BIGNUM *a);
504char * BN_bn2dec(const BIGNUM *a); 512char * BN_bn2dec(const BIGNUM *a);
505int BN_hex2bn(BIGNUM **a, const char *str); 513int BN_hex2bn(BIGNUM **a, const char *str);
506int BN_dec2bn(BIGNUM **a, const char *str); 514int BN_dec2bn(BIGNUM **a, const char *str);
515int BN_asc2bn(BIGNUM **a, const char *str);
507int BN_gcd(BIGNUM *r,const BIGNUM *a,const BIGNUM *b,BN_CTX *ctx); 516int BN_gcd(BIGNUM *r,const BIGNUM *a,const BIGNUM *b,BN_CTX *ctx);
508int BN_kronecker(const BIGNUM *a,const BIGNUM *b,BN_CTX *ctx); /* returns -2 for error */ 517int BN_kronecker(const BIGNUM *a,const BIGNUM *b,BN_CTX *ctx); /* returns -2 for error */
509BIGNUM *BN_mod_inverse(BIGNUM *ret, 518BIGNUM *BN_mod_inverse(BIGNUM *ret,
@@ -531,17 +540,6 @@ int BN_is_prime_ex(const BIGNUM *p,int nchecks, BN_CTX *ctx, BN_GENCB *cb);
531int BN_is_prime_fasttest_ex(const BIGNUM *p,int nchecks, BN_CTX *ctx, 540int BN_is_prime_fasttest_ex(const BIGNUM *p,int nchecks, BN_CTX *ctx,
532 int do_trial_division, BN_GENCB *cb); 541 int do_trial_division, BN_GENCB *cb);
533 542
534int BN_X931_generate_Xpq(BIGNUM *Xp, BIGNUM *Xq, int nbits, BN_CTX *ctx);
535
536int BN_X931_derive_prime_ex(BIGNUM *p, BIGNUM *p1, BIGNUM *p2,
537 const BIGNUM *Xp, const BIGNUM *Xp1, const BIGNUM *Xp2,
538 const BIGNUM *e, BN_CTX *ctx, BN_GENCB *cb);
539int BN_X931_generate_prime_ex(BIGNUM *p, BIGNUM *p1, BIGNUM *p2,
540 BIGNUM *Xp1, BIGNUM *Xp2,
541 const BIGNUM *Xp,
542 const BIGNUM *e, BN_CTX *ctx,
543 BN_GENCB *cb);
544
545BN_MONT_CTX *BN_MONT_CTX_new(void ); 543BN_MONT_CTX *BN_MONT_CTX_new(void );
546void BN_MONT_CTX_init(BN_MONT_CTX *ctx); 544void BN_MONT_CTX_init(BN_MONT_CTX *ctx);
547int BN_mod_mul_montgomery(BIGNUM *r,const BIGNUM *a,const BIGNUM *b, 545int BN_mod_mul_montgomery(BIGNUM *r,const BIGNUM *a,const BIGNUM *b,
@@ -560,19 +558,22 @@ BN_MONT_CTX *BN_MONT_CTX_set_locked(BN_MONT_CTX **pmont, int lock,
560#define BN_BLINDING_NO_UPDATE 0x00000001 558#define BN_BLINDING_NO_UPDATE 0x00000001
561#define BN_BLINDING_NO_RECREATE 0x00000002 559#define BN_BLINDING_NO_RECREATE 0x00000002
562 560
563BN_BLINDING *BN_BLINDING_new(const BIGNUM *A, const BIGNUM *Ai, /* const */ BIGNUM *mod); 561BN_BLINDING *BN_BLINDING_new(const BIGNUM *A, const BIGNUM *Ai, BIGNUM *mod);
564void BN_BLINDING_free(BN_BLINDING *b); 562void BN_BLINDING_free(BN_BLINDING *b);
565int BN_BLINDING_update(BN_BLINDING *b,BN_CTX *ctx); 563int BN_BLINDING_update(BN_BLINDING *b,BN_CTX *ctx);
566int BN_BLINDING_convert(BIGNUM *n, BN_BLINDING *b, BN_CTX *ctx); 564int BN_BLINDING_convert(BIGNUM *n, BN_BLINDING *b, BN_CTX *ctx);
567int BN_BLINDING_invert(BIGNUM *n, BN_BLINDING *b, BN_CTX *ctx); 565int BN_BLINDING_invert(BIGNUM *n, BN_BLINDING *b, BN_CTX *ctx);
568int BN_BLINDING_convert_ex(BIGNUM *n, BIGNUM *r, BN_BLINDING *b, BN_CTX *); 566int BN_BLINDING_convert_ex(BIGNUM *n, BIGNUM *r, BN_BLINDING *b, BN_CTX *);
569int BN_BLINDING_invert_ex(BIGNUM *n, const BIGNUM *r, BN_BLINDING *b, BN_CTX *); 567int BN_BLINDING_invert_ex(BIGNUM *n, const BIGNUM *r, BN_BLINDING *b, BN_CTX *);
568#ifndef OPENSSL_NO_DEPRECATED
570unsigned long BN_BLINDING_get_thread_id(const BN_BLINDING *); 569unsigned long BN_BLINDING_get_thread_id(const BN_BLINDING *);
571void BN_BLINDING_set_thread_id(BN_BLINDING *, unsigned long); 570void BN_BLINDING_set_thread_id(BN_BLINDING *, unsigned long);
571#endif
572CRYPTO_THREADID *BN_BLINDING_thread_id(BN_BLINDING *);
572unsigned long BN_BLINDING_get_flags(const BN_BLINDING *); 573unsigned long BN_BLINDING_get_flags(const BN_BLINDING *);
573void BN_BLINDING_set_flags(BN_BLINDING *, unsigned long); 574void BN_BLINDING_set_flags(BN_BLINDING *, unsigned long);
574BN_BLINDING *BN_BLINDING_create_param(BN_BLINDING *b, 575BN_BLINDING *BN_BLINDING_create_param(BN_BLINDING *b,
575 const BIGNUM *e, /* const */ BIGNUM *m, BN_CTX *ctx, 576 const BIGNUM *e, BIGNUM *m, BN_CTX *ctx,
576 int (*bn_mod_exp)(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, 577 int (*bn_mod_exp)(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
577 const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx), 578 const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx),
578 BN_MONT_CTX *m_ctx); 579 BN_MONT_CTX *m_ctx);
@@ -625,24 +626,24 @@ int BN_GF2m_mod_solve_quad(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
625 * t^p[0] + t^p[1] + ... + t^p[k] 626 * t^p[0] + t^p[1] + ... + t^p[k]
626 * where m = p[0] > p[1] > ... > p[k] = 0. 627 * where m = p[0] > p[1] > ... > p[k] = 0.
627 */ 628 */
628int BN_GF2m_mod_arr(BIGNUM *r, const BIGNUM *a, const unsigned int p[]); 629int BN_GF2m_mod_arr(BIGNUM *r, const BIGNUM *a, const int p[]);
629 /* r = a mod p */ 630 /* r = a mod p */
630int BN_GF2m_mod_mul_arr(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, 631int BN_GF2m_mod_mul_arr(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,
631 const unsigned int p[], BN_CTX *ctx); /* r = (a * b) mod p */ 632 const int p[], BN_CTX *ctx); /* r = (a * b) mod p */
632int BN_GF2m_mod_sqr_arr(BIGNUM *r, const BIGNUM *a, const unsigned int p[], 633int BN_GF2m_mod_sqr_arr(BIGNUM *r, const BIGNUM *a, const int p[],
633 BN_CTX *ctx); /* r = (a * a) mod p */ 634 BN_CTX *ctx); /* r = (a * a) mod p */
634int BN_GF2m_mod_inv_arr(BIGNUM *r, const BIGNUM *b, const unsigned int p[], 635int BN_GF2m_mod_inv_arr(BIGNUM *r, const BIGNUM *b, const int p[],
635 BN_CTX *ctx); /* r = (1 / b) mod p */ 636 BN_CTX *ctx); /* r = (1 / b) mod p */
636int BN_GF2m_mod_div_arr(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, 637int BN_GF2m_mod_div_arr(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,
637 const unsigned int p[], BN_CTX *ctx); /* r = (a / b) mod p */ 638 const int p[], BN_CTX *ctx); /* r = (a / b) mod p */
638int BN_GF2m_mod_exp_arr(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, 639int BN_GF2m_mod_exp_arr(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,
639 const unsigned int p[], BN_CTX *ctx); /* r = (a ^ b) mod p */ 640 const int p[], BN_CTX *ctx); /* r = (a ^ b) mod p */
640int BN_GF2m_mod_sqrt_arr(BIGNUM *r, const BIGNUM *a, 641int BN_GF2m_mod_sqrt_arr(BIGNUM *r, const BIGNUM *a,
641 const unsigned int p[], BN_CTX *ctx); /* r = sqrt(a) mod p */ 642 const int p[], BN_CTX *ctx); /* r = sqrt(a) mod p */
642int BN_GF2m_mod_solve_quad_arr(BIGNUM *r, const BIGNUM *a, 643int BN_GF2m_mod_solve_quad_arr(BIGNUM *r, const BIGNUM *a,
643 const unsigned int p[], BN_CTX *ctx); /* r^2 + r = a mod p */ 644 const int p[], BN_CTX *ctx); /* r^2 + r = a mod p */
644int BN_GF2m_poly2arr(const BIGNUM *a, unsigned int p[], int max); 645int BN_GF2m_poly2arr(const BIGNUM *a, int p[], int max);
645int BN_GF2m_arr2poly(const unsigned int p[], BIGNUM *a); 646int BN_GF2m_arr2poly(const int p[], BIGNUM *a);
646 647
647/* faster mod functions for the 'NIST primes' 648/* faster mod functions for the 'NIST primes'
648 * 0 <= a < p^2 */ 649 * 0 <= a < p^2 */
@@ -751,10 +752,12 @@ int RAND_pseudo_bytes(unsigned char *buf,int num);
751#define bn_correct_top(a) \ 752#define bn_correct_top(a) \
752 { \ 753 { \
753 BN_ULONG *ftl; \ 754 BN_ULONG *ftl; \
754 if ((a)->top > 0) \ 755 int tmp_top = (a)->top; \
756 if (tmp_top > 0) \
755 { \ 757 { \
756 for (ftl= &((a)->d[(a)->top-1]); (a)->top > 0; (a)->top--) \ 758 for (ftl= &((a)->d[tmp_top-1]); tmp_top > 0; tmp_top--) \
757 if (*(ftl--)) break; \ 759 if (*(ftl--)) break; \
760 (a)->top = tmp_top; \
758 } \ 761 } \
759 bn_pollute(a); \ 762 bn_pollute(a); \
760 } 763 }
diff --git a/src/lib/libcrypto/bn/bn_asm.c b/src/lib/libcrypto/bn/bn_asm.c
index 99bc2de491..c43c91cc09 100644
--- a/src/lib/libcrypto/bn/bn_asm.c
+++ b/src/lib/libcrypto/bn/bn_asm.c
@@ -75,6 +75,7 @@ BN_ULONG bn_mul_add_words(BN_ULONG *rp, const BN_ULONG *ap, int num, BN_ULONG w)
75 assert(num >= 0); 75 assert(num >= 0);
76 if (num <= 0) return(c1); 76 if (num <= 0) return(c1);
77 77
78#ifndef OPENSSL_SMALL_FOOTPRINT
78 while (num&~3) 79 while (num&~3)
79 { 80 {
80 mul_add(rp[0],ap[0],w,c1); 81 mul_add(rp[0],ap[0],w,c1);
@@ -83,11 +84,11 @@ BN_ULONG bn_mul_add_words(BN_ULONG *rp, const BN_ULONG *ap, int num, BN_ULONG w)
83 mul_add(rp[3],ap[3],w,c1); 84 mul_add(rp[3],ap[3],w,c1);
84 ap+=4; rp+=4; num-=4; 85 ap+=4; rp+=4; num-=4;
85 } 86 }
86 if (num) 87#endif
88 while (num)
87 { 89 {
88 mul_add(rp[0],ap[0],w,c1); if (--num==0) return c1; 90 mul_add(rp[0],ap[0],w,c1);
89 mul_add(rp[1],ap[1],w,c1); if (--num==0) return c1; 91 ap++; rp++; num--;
90 mul_add(rp[2],ap[2],w,c1); return c1;
91 } 92 }
92 93
93 return(c1); 94 return(c1);
@@ -100,6 +101,7 @@ BN_ULONG bn_mul_words(BN_ULONG *rp, const BN_ULONG *ap, int num, BN_ULONG w)
100 assert(num >= 0); 101 assert(num >= 0);
101 if (num <= 0) return(c1); 102 if (num <= 0) return(c1);
102 103
104#ifndef OPENSSL_SMALL_FOOTPRINT
103 while (num&~3) 105 while (num&~3)
104 { 106 {
105 mul(rp[0],ap[0],w,c1); 107 mul(rp[0],ap[0],w,c1);
@@ -108,11 +110,11 @@ BN_ULONG bn_mul_words(BN_ULONG *rp, const BN_ULONG *ap, int num, BN_ULONG w)
108 mul(rp[3],ap[3],w,c1); 110 mul(rp[3],ap[3],w,c1);
109 ap+=4; rp+=4; num-=4; 111 ap+=4; rp+=4; num-=4;
110 } 112 }
111 if (num) 113#endif
114 while (num)
112 { 115 {
113 mul(rp[0],ap[0],w,c1); if (--num == 0) return c1; 116 mul(rp[0],ap[0],w,c1);
114 mul(rp[1],ap[1],w,c1); if (--num == 0) return c1; 117 ap++; rp++; num--;
115 mul(rp[2],ap[2],w,c1);
116 } 118 }
117 return(c1); 119 return(c1);
118 } 120 }
@@ -121,6 +123,8 @@ void bn_sqr_words(BN_ULONG *r, const BN_ULONG *a, int n)
121 { 123 {
122 assert(n >= 0); 124 assert(n >= 0);
123 if (n <= 0) return; 125 if (n <= 0) return;
126
127#ifndef OPENSSL_SMALL_FOOTPRINT
124 while (n&~3) 128 while (n&~3)
125 { 129 {
126 sqr(r[0],r[1],a[0]); 130 sqr(r[0],r[1],a[0]);
@@ -129,11 +133,11 @@ void bn_sqr_words(BN_ULONG *r, const BN_ULONG *a, int n)
129 sqr(r[6],r[7],a[3]); 133 sqr(r[6],r[7],a[3]);
130 a+=4; r+=8; n-=4; 134 a+=4; r+=8; n-=4;
131 } 135 }
132 if (n) 136#endif
137 while (n)
133 { 138 {
134 sqr(r[0],r[1],a[0]); if (--n == 0) return; 139 sqr(r[0],r[1],a[0]);
135 sqr(r[2],r[3],a[1]); if (--n == 0) return; 140 a++; r+=2; n--;
136 sqr(r[4],r[5],a[2]);
137 } 141 }
138 } 142 }
139 143
@@ -150,18 +154,20 @@ BN_ULONG bn_mul_add_words(BN_ULONG *rp, const BN_ULONG *ap, int num, BN_ULONG w)
150 bl=LBITS(w); 154 bl=LBITS(w);
151 bh=HBITS(w); 155 bh=HBITS(w);
152 156
153 for (;;) 157#ifndef OPENSSL_SMALL_FOOTPRINT
158 while (num&~3)
154 { 159 {
155 mul_add(rp[0],ap[0],bl,bh,c); 160 mul_add(rp[0],ap[0],bl,bh,c);
156 if (--num == 0) break;
157 mul_add(rp[1],ap[1],bl,bh,c); 161 mul_add(rp[1],ap[1],bl,bh,c);
158 if (--num == 0) break;
159 mul_add(rp[2],ap[2],bl,bh,c); 162 mul_add(rp[2],ap[2],bl,bh,c);
160 if (--num == 0) break;
161 mul_add(rp[3],ap[3],bl,bh,c); 163 mul_add(rp[3],ap[3],bl,bh,c);
162 if (--num == 0) break; 164 ap+=4; rp+=4; num-=4;
163 ap+=4; 165 }
164 rp+=4; 166#endif
167 while (num)
168 {
169 mul_add(rp[0],ap[0],bl,bh,c);
170 ap++; rp++; num--;
165 } 171 }
166 return(c); 172 return(c);
167 } 173 }
@@ -177,18 +183,20 @@ BN_ULONG bn_mul_words(BN_ULONG *rp, const BN_ULONG *ap, int num, BN_ULONG w)
177 bl=LBITS(w); 183 bl=LBITS(w);
178 bh=HBITS(w); 184 bh=HBITS(w);
179 185
180 for (;;) 186#ifndef OPENSSL_SMALL_FOOTPRINT
187 while (num&~3)
181 { 188 {
182 mul(rp[0],ap[0],bl,bh,carry); 189 mul(rp[0],ap[0],bl,bh,carry);
183 if (--num == 0) break;
184 mul(rp[1],ap[1],bl,bh,carry); 190 mul(rp[1],ap[1],bl,bh,carry);
185 if (--num == 0) break;
186 mul(rp[2],ap[2],bl,bh,carry); 191 mul(rp[2],ap[2],bl,bh,carry);
187 if (--num == 0) break;
188 mul(rp[3],ap[3],bl,bh,carry); 192 mul(rp[3],ap[3],bl,bh,carry);
189 if (--num == 0) break; 193 ap+=4; rp+=4; num-=4;
190 ap+=4; 194 }
191 rp+=4; 195#endif
196 while (num)
197 {
198 mul(rp[0],ap[0],bl,bh,carry);
199 ap++; rp++; num--;
192 } 200 }
193 return(carry); 201 return(carry);
194 } 202 }
@@ -197,22 +205,21 @@ void bn_sqr_words(BN_ULONG *r, const BN_ULONG *a, int n)
197 { 205 {
198 assert(n >= 0); 206 assert(n >= 0);
199 if (n <= 0) return; 207 if (n <= 0) return;
200 for (;;) 208
209#ifndef OPENSSL_SMALL_FOOTPRINT
210 while (n&~3)
201 { 211 {
202 sqr64(r[0],r[1],a[0]); 212 sqr64(r[0],r[1],a[0]);
203 if (--n == 0) break;
204
205 sqr64(r[2],r[3],a[1]); 213 sqr64(r[2],r[3],a[1]);
206 if (--n == 0) break;
207
208 sqr64(r[4],r[5],a[2]); 214 sqr64(r[4],r[5],a[2]);
209 if (--n == 0) break;
210
211 sqr64(r[6],r[7],a[3]); 215 sqr64(r[6],r[7],a[3]);
212 if (--n == 0) break; 216 a+=4; r+=8; n-=4;
213 217 }
214 a+=4; 218#endif
215 r+=8; 219 while (n)
220 {
221 sqr64(r[0],r[1],a[0]);
222 a++; r+=2; n--;
216 } 223 }
217 } 224 }
218 225
@@ -303,31 +310,30 @@ BN_ULONG bn_add_words(BN_ULONG *r, const BN_ULONG *a, const BN_ULONG *b, int n)
303 assert(n >= 0); 310 assert(n >= 0);
304 if (n <= 0) return((BN_ULONG)0); 311 if (n <= 0) return((BN_ULONG)0);
305 312
306 for (;;) 313#ifndef OPENSSL_SMALL_FOOTPRINT
314 while (n&~3)
307 { 315 {
308 ll+=(BN_ULLONG)a[0]+b[0]; 316 ll+=(BN_ULLONG)a[0]+b[0];
309 r[0]=(BN_ULONG)ll&BN_MASK2; 317 r[0]=(BN_ULONG)ll&BN_MASK2;
310 ll>>=BN_BITS2; 318 ll>>=BN_BITS2;
311 if (--n <= 0) break;
312
313 ll+=(BN_ULLONG)a[1]+b[1]; 319 ll+=(BN_ULLONG)a[1]+b[1];
314 r[1]=(BN_ULONG)ll&BN_MASK2; 320 r[1]=(BN_ULONG)ll&BN_MASK2;
315 ll>>=BN_BITS2; 321 ll>>=BN_BITS2;
316 if (--n <= 0) break;
317
318 ll+=(BN_ULLONG)a[2]+b[2]; 322 ll+=(BN_ULLONG)a[2]+b[2];
319 r[2]=(BN_ULONG)ll&BN_MASK2; 323 r[2]=(BN_ULONG)ll&BN_MASK2;
320 ll>>=BN_BITS2; 324 ll>>=BN_BITS2;
321 if (--n <= 0) break;
322
323 ll+=(BN_ULLONG)a[3]+b[3]; 325 ll+=(BN_ULLONG)a[3]+b[3];
324 r[3]=(BN_ULONG)ll&BN_MASK2; 326 r[3]=(BN_ULONG)ll&BN_MASK2;
325 ll>>=BN_BITS2; 327 ll>>=BN_BITS2;
326 if (--n <= 0) break; 328 a+=4; b+=4; r+=4; n-=4;
327 329 }
328 a+=4; 330#endif
329 b+=4; 331 while (n)
330 r+=4; 332 {
333 ll+=(BN_ULLONG)a[0]+b[0];
334 r[0]=(BN_ULONG)ll&BN_MASK2;
335 ll>>=BN_BITS2;
336 a++; b++; r++; n--;
331 } 337 }
332 return((BN_ULONG)ll); 338 return((BN_ULONG)ll);
333 } 339 }
@@ -340,7 +346,8 @@ BN_ULONG bn_add_words(BN_ULONG *r, const BN_ULONG *a, const BN_ULONG *b, int n)
340 if (n <= 0) return((BN_ULONG)0); 346 if (n <= 0) return((BN_ULONG)0);
341 347
342 c=0; 348 c=0;
343 for (;;) 349#ifndef OPENSSL_SMALL_FOOTPRINT
350 while (n&~3)
344 { 351 {
345 t=a[0]; 352 t=a[0];
346 t=(t+c)&BN_MASK2; 353 t=(t+c)&BN_MASK2;
@@ -348,35 +355,36 @@ BN_ULONG bn_add_words(BN_ULONG *r, const BN_ULONG *a, const BN_ULONG *b, int n)
348 l=(t+b[0])&BN_MASK2; 355 l=(t+b[0])&BN_MASK2;
349 c+=(l < t); 356 c+=(l < t);
350 r[0]=l; 357 r[0]=l;
351 if (--n <= 0) break;
352
353 t=a[1]; 358 t=a[1];
354 t=(t+c)&BN_MASK2; 359 t=(t+c)&BN_MASK2;
355 c=(t < c); 360 c=(t < c);
356 l=(t+b[1])&BN_MASK2; 361 l=(t+b[1])&BN_MASK2;
357 c+=(l < t); 362 c+=(l < t);
358 r[1]=l; 363 r[1]=l;
359 if (--n <= 0) break;
360
361 t=a[2]; 364 t=a[2];
362 t=(t+c)&BN_MASK2; 365 t=(t+c)&BN_MASK2;
363 c=(t < c); 366 c=(t < c);
364 l=(t+b[2])&BN_MASK2; 367 l=(t+b[2])&BN_MASK2;
365 c+=(l < t); 368 c+=(l < t);
366 r[2]=l; 369 r[2]=l;
367 if (--n <= 0) break;
368
369 t=a[3]; 370 t=a[3];
370 t=(t+c)&BN_MASK2; 371 t=(t+c)&BN_MASK2;
371 c=(t < c); 372 c=(t < c);
372 l=(t+b[3])&BN_MASK2; 373 l=(t+b[3])&BN_MASK2;
373 c+=(l < t); 374 c+=(l < t);
374 r[3]=l; 375 r[3]=l;
375 if (--n <= 0) break; 376 a+=4; b+=4; r+=4; n-=4;
376 377 }
377 a+=4; 378#endif
378 b+=4; 379 while(n)
379 r+=4; 380 {
381 t=a[0];
382 t=(t+c)&BN_MASK2;
383 c=(t < c);
384 l=(t+b[0])&BN_MASK2;
385 c+=(l < t);
386 r[0]=l;
387 a++; b++; r++; n--;
380 } 388 }
381 return((BN_ULONG)c); 389 return((BN_ULONG)c);
382 } 390 }
@@ -390,36 +398,35 @@ BN_ULONG bn_sub_words(BN_ULONG *r, const BN_ULONG *a, const BN_ULONG *b, int n)
390 assert(n >= 0); 398 assert(n >= 0);
391 if (n <= 0) return((BN_ULONG)0); 399 if (n <= 0) return((BN_ULONG)0);
392 400
393 for (;;) 401#ifndef OPENSSL_SMALL_FOOTPRINT
402 while (n&~3)
394 { 403 {
395 t1=a[0]; t2=b[0]; 404 t1=a[0]; t2=b[0];
396 r[0]=(t1-t2-c)&BN_MASK2; 405 r[0]=(t1-t2-c)&BN_MASK2;
397 if (t1 != t2) c=(t1 < t2); 406 if (t1 != t2) c=(t1 < t2);
398 if (--n <= 0) break;
399
400 t1=a[1]; t2=b[1]; 407 t1=a[1]; t2=b[1];
401 r[1]=(t1-t2-c)&BN_MASK2; 408 r[1]=(t1-t2-c)&BN_MASK2;
402 if (t1 != t2) c=(t1 < t2); 409 if (t1 != t2) c=(t1 < t2);
403 if (--n <= 0) break;
404
405 t1=a[2]; t2=b[2]; 410 t1=a[2]; t2=b[2];
406 r[2]=(t1-t2-c)&BN_MASK2; 411 r[2]=(t1-t2-c)&BN_MASK2;
407 if (t1 != t2) c=(t1 < t2); 412 if (t1 != t2) c=(t1 < t2);
408 if (--n <= 0) break;
409
410 t1=a[3]; t2=b[3]; 413 t1=a[3]; t2=b[3];
411 r[3]=(t1-t2-c)&BN_MASK2; 414 r[3]=(t1-t2-c)&BN_MASK2;
412 if (t1 != t2) c=(t1 < t2); 415 if (t1 != t2) c=(t1 < t2);
413 if (--n <= 0) break; 416 a+=4; b+=4; r+=4; n-=4;
414 417 }
415 a+=4; 418#endif
416 b+=4; 419 while (n)
417 r+=4; 420 {
421 t1=a[0]; t2=b[0];
422 r[0]=(t1-t2-c)&BN_MASK2;
423 if (t1 != t2) c=(t1 < t2);
424 a++; b++; r++; n--;
418 } 425 }
419 return(c); 426 return(c);
420 } 427 }
421 428
422#ifdef BN_MUL_COMBA 429#if defined(BN_MUL_COMBA) && !defined(OPENSSL_SMALL_FOOTPRINT)
423 430
424#undef bn_mul_comba8 431#undef bn_mul_comba8
425#undef bn_mul_comba4 432#undef bn_mul_comba4
@@ -820,18 +827,134 @@ void bn_sqr_comba4(BN_ULONG *r, const BN_ULONG *a)
820 r[6]=c1; 827 r[6]=c1;
821 r[7]=c2; 828 r[7]=c2;
822 } 829 }
830
831#ifdef OPENSSL_NO_ASM
832#ifdef OPENSSL_BN_ASM_MONT
833#include <alloca.h>
834/*
835 * This is essentially reference implementation, which may or may not
836 * result in performance improvement. E.g. on IA-32 this routine was
837 * observed to give 40% faster rsa1024 private key operations and 10%
838 * faster rsa4096 ones, while on AMD64 it improves rsa1024 sign only
839 * by 10% and *worsens* rsa4096 sign by 15%. Once again, it's a
840 * reference implementation, one to be used as starting point for
841 * platform-specific assembler. Mentioned numbers apply to compiler
842 * generated code compiled with and without -DOPENSSL_BN_ASM_MONT and
843 * can vary not only from platform to platform, but even for compiler
844 * versions. Assembler vs. assembler improvement coefficients can
845 * [and are known to] differ and are to be documented elsewhere.
846 */
847int bn_mul_mont(BN_ULONG *rp, const BN_ULONG *ap, const BN_ULONG *bp, const BN_ULONG *np,const BN_ULONG *n0p, int num)
848 {
849 BN_ULONG c0,c1,ml,*tp,n0;
850#ifdef mul64
851 BN_ULONG mh;
852#endif
853 volatile BN_ULONG *vp;
854 int i=0,j;
855
856#if 0 /* template for platform-specific implementation */
857 if (ap==bp) return bn_sqr_mont(rp,ap,np,n0p,num);
858#endif
859 vp = tp = alloca((num+2)*sizeof(BN_ULONG));
860
861 n0 = *n0p;
862
863 c0 = 0;
864 ml = bp[0];
865#ifdef mul64
866 mh = HBITS(ml);
867 ml = LBITS(ml);
868 for (j=0;j<num;++j)
869 mul(tp[j],ap[j],ml,mh,c0);
870#else
871 for (j=0;j<num;++j)
872 mul(tp[j],ap[j],ml,c0);
873#endif
874
875 tp[num] = c0;
876 tp[num+1] = 0;
877 goto enter;
878
879 for(i=0;i<num;i++)
880 {
881 c0 = 0;
882 ml = bp[i];
883#ifdef mul64
884 mh = HBITS(ml);
885 ml = LBITS(ml);
886 for (j=0;j<num;++j)
887 mul_add(tp[j],ap[j],ml,mh,c0);
888#else
889 for (j=0;j<num;++j)
890 mul_add(tp[j],ap[j],ml,c0);
891#endif
892 c1 = (tp[num] + c0)&BN_MASK2;
893 tp[num] = c1;
894 tp[num+1] = (c1<c0?1:0);
895 enter:
896 c1 = tp[0];
897 ml = (c1*n0)&BN_MASK2;
898 c0 = 0;
899#ifdef mul64
900 mh = HBITS(ml);
901 ml = LBITS(ml);
902 mul_add(c1,np[0],ml,mh,c0);
903#else
904 mul_add(c1,ml,np[0],c0);
905#endif
906 for(j=1;j<num;j++)
907 {
908 c1 = tp[j];
909#ifdef mul64
910 mul_add(c1,np[j],ml,mh,c0);
911#else
912 mul_add(c1,ml,np[j],c0);
913#endif
914 tp[j-1] = c1&BN_MASK2;
915 }
916 c1 = (tp[num] + c0)&BN_MASK2;
917 tp[num-1] = c1;
918 tp[num] = tp[num+1] + (c1<c0?1:0);
919 }
920
921 if (tp[num]!=0 || tp[num-1]>=np[num-1])
922 {
923 c0 = bn_sub_words(rp,tp,np,num);
924 if (tp[num]!=0 || c0==0)
925 {
926 for(i=0;i<num+2;i++) vp[i] = 0;
927 return 1;
928 }
929 }
930 for(i=0;i<num;i++) rp[i] = tp[i], vp[i] = 0;
931 vp[num] = 0;
932 vp[num+1] = 0;
933 return 1;
934 }
935#else
936/*
937 * Return value of 0 indicates that multiplication/convolution was not
938 * performed to signal the caller to fall down to alternative/original
939 * code-path.
940 */
941int bn_mul_mont(BN_ULONG *rp, const BN_ULONG *ap, const BN_ULONG *bp, const BN_ULONG *np,const BN_ULONG *n0, int num)
942{ return 0; }
943#endif /* OPENSSL_BN_ASM_MONT */
944#endif
945
823#else /* !BN_MUL_COMBA */ 946#else /* !BN_MUL_COMBA */
824 947
825/* hmm... is it faster just to do a multiply? */ 948/* hmm... is it faster just to do a multiply? */
826#undef bn_sqr_comba4 949#undef bn_sqr_comba4
827void bn_sqr_comba4(BN_ULONG *r, BN_ULONG *a) 950void bn_sqr_comba4(BN_ULONG *r, const BN_ULONG *a)
828 { 951 {
829 BN_ULONG t[8]; 952 BN_ULONG t[8];
830 bn_sqr_normal(r,a,4,t); 953 bn_sqr_normal(r,a,4,t);
831 } 954 }
832 955
833#undef bn_sqr_comba8 956#undef bn_sqr_comba8
834void bn_sqr_comba8(BN_ULONG *r, BN_ULONG *a) 957void bn_sqr_comba8(BN_ULONG *r, const BN_ULONG *a)
835 { 958 {
836 BN_ULONG t[16]; 959 BN_ULONG t[16];
837 bn_sqr_normal(r,a,8,t); 960 bn_sqr_normal(r,a,8,t);
@@ -857,4 +980,51 @@ void bn_mul_comba8(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b)
857 r[15]=bn_mul_add_words(&(r[7]),a,8,b[7]); 980 r[15]=bn_mul_add_words(&(r[7]),a,8,b[7]);
858 } 981 }
859 982
983#ifdef OPENSSL_NO_ASM
984#ifdef OPENSSL_BN_ASM_MONT
985#include <alloca.h>
986int bn_mul_mont(BN_ULONG *rp, const BN_ULONG *ap, const BN_ULONG *bp, const BN_ULONG *np,const BN_ULONG *n0p, int num)
987 {
988 BN_ULONG c0,c1,*tp,n0=*n0p;
989 volatile BN_ULONG *vp;
990 int i=0,j;
991
992 vp = tp = alloca((num+2)*sizeof(BN_ULONG));
993
994 for(i=0;i<=num;i++) tp[i]=0;
995
996 for(i=0;i<num;i++)
997 {
998 c0 = bn_mul_add_words(tp,ap,num,bp[i]);
999 c1 = (tp[num] + c0)&BN_MASK2;
1000 tp[num] = c1;
1001 tp[num+1] = (c1<c0?1:0);
1002
1003 c0 = bn_mul_add_words(tp,np,num,tp[0]*n0);
1004 c1 = (tp[num] + c0)&BN_MASK2;
1005 tp[num] = c1;
1006 tp[num+1] += (c1<c0?1:0);
1007 for(j=0;j<=num;j++) tp[j]=tp[j+1];
1008 }
1009
1010 if (tp[num]!=0 || tp[num-1]>=np[num-1])
1011 {
1012 c0 = bn_sub_words(rp,tp,np,num);
1013 if (tp[num]!=0 || c0==0)
1014 {
1015 for(i=0;i<num+2;i++) vp[i] = 0;
1016 return 1;
1017 }
1018 }
1019 for(i=0;i<num;i++) rp[i] = tp[i], vp[i] = 0;
1020 vp[num] = 0;
1021 vp[num+1] = 0;
1022 return 1;
1023 }
1024#else
1025int bn_mul_mont(BN_ULONG *rp, const BN_ULONG *ap, const BN_ULONG *bp, const BN_ULONG *np,const BN_ULONG *n0, int num)
1026{ return 0; }
1027#endif /* OPENSSL_BN_ASM_MONT */
1028#endif
1029
860#endif /* !BN_MUL_COMBA */ 1030#endif /* !BN_MUL_COMBA */
diff --git a/src/lib/libcrypto/bn/bn_blind.c b/src/lib/libcrypto/bn/bn_blind.c
index c11fb4ccc2..e060592fdc 100644
--- a/src/lib/libcrypto/bn/bn_blind.c
+++ b/src/lib/libcrypto/bn/bn_blind.c
@@ -1,6 +1,6 @@
1/* crypto/bn/bn_blind.c */ 1/* crypto/bn/bn_blind.c */
2/* ==================================================================== 2/* ====================================================================
3 * Copyright (c) 1998-2005 The OpenSSL Project. All rights reserved. 3 * Copyright (c) 1998-2006 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
@@ -121,8 +121,11 @@ struct bn_blinding_st
121 BIGNUM *Ai; 121 BIGNUM *Ai;
122 BIGNUM *e; 122 BIGNUM *e;
123 BIGNUM *mod; /* just a reference */ 123 BIGNUM *mod; /* just a reference */
124#ifndef OPENSSL_NO_DEPRECATED
124 unsigned long thread_id; /* added in OpenSSL 0.9.6j and 0.9.7b; 125 unsigned long thread_id; /* added in OpenSSL 0.9.6j and 0.9.7b;
125 * used only by crypto/rsa/rsa_eay.c, rsa_lib.c */ 126 * used only by crypto/rsa/rsa_eay.c, rsa_lib.c */
127#endif
128 CRYPTO_THREADID tid;
126 unsigned int counter; 129 unsigned int counter;
127 unsigned long flags; 130 unsigned long flags;
128 BN_MONT_CTX *m_ctx; 131 BN_MONT_CTX *m_ctx;
@@ -131,7 +134,7 @@ struct bn_blinding_st
131 BN_MONT_CTX *m_ctx); 134 BN_MONT_CTX *m_ctx);
132 }; 135 };
133 136
134BN_BLINDING *BN_BLINDING_new(const BIGNUM *A, const BIGNUM *Ai, /* const */ BIGNUM *mod) 137BN_BLINDING *BN_BLINDING_new(const BIGNUM *A, const BIGNUM *Ai, BIGNUM *mod)
135 { 138 {
136 BN_BLINDING *ret=NULL; 139 BN_BLINDING *ret=NULL;
137 140
@@ -158,6 +161,7 @@ BN_BLINDING *BN_BLINDING_new(const BIGNUM *A, const BIGNUM *Ai, /* const */ BIGN
158 BN_set_flags(ret->mod, BN_FLG_CONSTTIME); 161 BN_set_flags(ret->mod, BN_FLG_CONSTTIME);
159 162
160 ret->counter = BN_BLINDING_COUNTER; 163 ret->counter = BN_BLINDING_COUNTER;
164 CRYPTO_THREADID_current(&ret->tid);
161 return(ret); 165 return(ret);
162err: 166err:
163 if (ret != NULL) BN_BLINDING_free(ret); 167 if (ret != NULL) BN_BLINDING_free(ret);
@@ -263,6 +267,7 @@ int BN_BLINDING_invert_ex(BIGNUM *n, const BIGNUM *r, BN_BLINDING *b, BN_CTX *ct
263 return(ret); 267 return(ret);
264 } 268 }
265 269
270#ifndef OPENSSL_NO_DEPRECATED
266unsigned long BN_BLINDING_get_thread_id(const BN_BLINDING *b) 271unsigned long BN_BLINDING_get_thread_id(const BN_BLINDING *b)
267 { 272 {
268 return b->thread_id; 273 return b->thread_id;
@@ -272,6 +277,12 @@ void BN_BLINDING_set_thread_id(BN_BLINDING *b, unsigned long n)
272 { 277 {
273 b->thread_id = n; 278 b->thread_id = n;
274 } 279 }
280#endif
281
282CRYPTO_THREADID *BN_BLINDING_thread_id(BN_BLINDING *b)
283 {
284 return &b->tid;
285 }
275 286
276unsigned long BN_BLINDING_get_flags(const BN_BLINDING *b) 287unsigned long BN_BLINDING_get_flags(const BN_BLINDING *b)
277 { 288 {
@@ -284,7 +295,7 @@ void BN_BLINDING_set_flags(BN_BLINDING *b, unsigned long flags)
284 } 295 }
285 296
286BN_BLINDING *BN_BLINDING_create_param(BN_BLINDING *b, 297BN_BLINDING *BN_BLINDING_create_param(BN_BLINDING *b,
287 const BIGNUM *e, /* const */ BIGNUM *m, BN_CTX *ctx, 298 const BIGNUM *e, BIGNUM *m, BN_CTX *ctx,
288 int (*bn_mod_exp)(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, 299 int (*bn_mod_exp)(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
289 const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx), 300 const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx),
290 BN_MONT_CTX *m_ctx) 301 BN_MONT_CTX *m_ctx)
diff --git a/src/lib/libcrypto/bn/bn_ctx.c b/src/lib/libcrypto/bn/bn_ctx.c
index b3452f1a91..3f2256f675 100644
--- a/src/lib/libcrypto/bn/bn_ctx.c
+++ b/src/lib/libcrypto/bn/bn_ctx.c
@@ -161,7 +161,7 @@ static void ctxdbg(BN_CTX *ctx)
161 fprintf(stderr,"(%08x): ", (unsigned int)ctx); 161 fprintf(stderr,"(%08x): ", (unsigned int)ctx);
162 while(bnidx < ctx->used) 162 while(bnidx < ctx->used)
163 { 163 {
164 fprintf(stderr,"%02x ", item->vals[bnidx++ % BN_CTX_POOL_SIZE].dmax); 164 fprintf(stderr,"%03x ", item->vals[bnidx++ % BN_CTX_POOL_SIZE].dmax);
165 if(!(bnidx % BN_CTX_POOL_SIZE)) 165 if(!(bnidx % BN_CTX_POOL_SIZE))
166 item = item->next; 166 item = item->next;
167 } 167 }
@@ -171,8 +171,8 @@ static void ctxdbg(BN_CTX *ctx)
171 while(fpidx < stack->depth) 171 while(fpidx < stack->depth)
172 { 172 {
173 while(bnidx++ < stack->indexes[fpidx]) 173 while(bnidx++ < stack->indexes[fpidx])
174 fprintf(stderr," "); 174 fprintf(stderr," ");
175 fprintf(stderr,"^^ "); 175 fprintf(stderr,"^^^ ");
176 bnidx++; 176 bnidx++;
177 fpidx++; 177 fpidx++;
178 } 178 }
diff --git a/src/lib/libcrypto/bn/bn_div.c b/src/lib/libcrypto/bn/bn_div.c
index d6ddc9cbe3..802a43d642 100644
--- a/src/lib/libcrypto/bn/bn_div.c
+++ b/src/lib/libcrypto/bn/bn_div.c
@@ -229,7 +229,8 @@ int BN_div(BIGNUM *dv, BIGNUM *rm, const BIGNUM *num, const BIGNUM *divisor,
229 if (dv == NULL) 229 if (dv == NULL)
230 res=BN_CTX_get(ctx); 230 res=BN_CTX_get(ctx);
231 else res=dv; 231 else res=dv;
232 if (sdiv == NULL || res == NULL) goto err; 232 if (sdiv == NULL || res == NULL || tmp == NULL || snum == NULL)
233 goto err;
233 234
234 /* First we normalise the numbers */ 235 /* First we normalise the numbers */
235 norm_shift=BN_BITS2-((BN_num_bits(divisor))%BN_BITS2); 236 norm_shift=BN_BITS2-((BN_num_bits(divisor))%BN_BITS2);
@@ -336,7 +337,7 @@ X) -> 0x%08X\n",
336 t2 -= d1; 337 t2 -= d1;
337 } 338 }
338#else /* !BN_LLONG */ 339#else /* !BN_LLONG */
339 BN_ULONG t2l,t2h,ql,qh; 340 BN_ULONG t2l,t2h;
340 341
341 q=bn_div_words(n0,n1,d0); 342 q=bn_div_words(n0,n1,d0);
342#ifdef BN_DEBUG_LEVITTE 343#ifdef BN_DEBUG_LEVITTE
@@ -354,9 +355,12 @@ X) -> 0x%08X\n",
354 t2l = d1 * q; 355 t2l = d1 * q;
355 t2h = BN_UMULT_HIGH(d1,q); 356 t2h = BN_UMULT_HIGH(d1,q);
356#else 357#else
358 {
359 BN_ULONG ql, qh;
357 t2l=LBITS(d1); t2h=HBITS(d1); 360 t2l=LBITS(d1); t2h=HBITS(d1);
358 ql =LBITS(q); qh =HBITS(q); 361 ql =LBITS(q); qh =HBITS(q);
359 mul64(t2l,t2h,ql,qh); /* t2=(BN_ULLONG)d1*q; */ 362 mul64(t2l,t2h,ql,qh); /* t2=(BN_ULLONG)d1*q; */
363 }
360#endif 364#endif
361 365
362 for (;;) 366 for (;;)
@@ -560,7 +564,7 @@ X) -> 0x%08X\n",
560 t2 -= d1; 564 t2 -= d1;
561 } 565 }
562#else /* !BN_LLONG */ 566#else /* !BN_LLONG */
563 BN_ULONG t2l,t2h,ql,qh; 567 BN_ULONG t2l,t2h;
564 568
565 q=bn_div_words(n0,n1,d0); 569 q=bn_div_words(n0,n1,d0);
566#ifdef BN_DEBUG_LEVITTE 570#ifdef BN_DEBUG_LEVITTE
@@ -578,9 +582,12 @@ X) -> 0x%08X\n",
578 t2l = d1 * q; 582 t2l = d1 * q;
579 t2h = BN_UMULT_HIGH(d1,q); 583 t2h = BN_UMULT_HIGH(d1,q);
580#else 584#else
585 {
586 BN_ULONG ql, qh;
581 t2l=LBITS(d1); t2h=HBITS(d1); 587 t2l=LBITS(d1); t2h=HBITS(d1);
582 ql =LBITS(q); qh =HBITS(q); 588 ql =LBITS(q); qh =HBITS(q);
583 mul64(t2l,t2h,ql,qh); /* t2=(BN_ULLONG)d1*q; */ 589 mul64(t2l,t2h,ql,qh); /* t2=(BN_ULLONG)d1*q; */
590 }
584#endif 591#endif
585 592
586 for (;;) 593 for (;;)
diff --git a/src/lib/libcrypto/bn/bn_exp.c b/src/lib/libcrypto/bn/bn_exp.c
index 70a33f0d93..d9b6c737fc 100644
--- a/src/lib/libcrypto/bn/bn_exp.c
+++ b/src/lib/libcrypto/bn/bn_exp.c
@@ -134,7 +134,8 @@ int BN_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx)
134 rr = BN_CTX_get(ctx); 134 rr = BN_CTX_get(ctx);
135 else 135 else
136 rr = r; 136 rr = r;
137 if ((v = BN_CTX_get(ctx)) == NULL) goto err; 137 v = BN_CTX_get(ctx);
138 if (rr == NULL || v == NULL) goto err;
138 139
139 if (BN_copy(v,a) == NULL) goto err; 140 if (BN_copy(v,a) == NULL) goto err;
140 bits=BN_num_bits(p); 141 bits=BN_num_bits(p);
diff --git a/src/lib/libcrypto/bn/bn_gf2m.c b/src/lib/libcrypto/bn/bn_gf2m.c
index ae642ccb39..527b0fa15b 100644
--- a/src/lib/libcrypto/bn/bn_gf2m.c
+++ b/src/lib/libcrypto/bn/bn_gf2m.c
@@ -121,74 +121,12 @@ static const BN_ULONG SQR_tb[16] =
121 SQR_tb[(w) >> 12 & 0xF] << 24 | SQR_tb[(w) >> 8 & 0xF] << 16 | \ 121 SQR_tb[(w) >> 12 & 0xF] << 24 | SQR_tb[(w) >> 8 & 0xF] << 16 | \
122 SQR_tb[(w) >> 4 & 0xF] << 8 | SQR_tb[(w) & 0xF] 122 SQR_tb[(w) >> 4 & 0xF] << 8 | SQR_tb[(w) & 0xF]
123#endif 123#endif
124#ifdef SIXTEEN_BIT
125#define SQR1(w) \
126 SQR_tb[(w) >> 12 & 0xF] << 8 | SQR_tb[(w) >> 8 & 0xF]
127#define SQR0(w) \
128 SQR_tb[(w) >> 4 & 0xF] << 8 | SQR_tb[(w) & 0xF]
129#endif
130#ifdef EIGHT_BIT
131#define SQR1(w) \
132 SQR_tb[(w) >> 4 & 0xF]
133#define SQR0(w) \
134 SQR_tb[(w) & 15]
135#endif
136 124
137/* Product of two polynomials a, b each with degree < BN_BITS2 - 1, 125/* Product of two polynomials a, b each with degree < BN_BITS2 - 1,
138 * result is a polynomial r with degree < 2 * BN_BITS - 1 126 * result is a polynomial r with degree < 2 * BN_BITS - 1
139 * The caller MUST ensure that the variables have the right amount 127 * The caller MUST ensure that the variables have the right amount
140 * of space allocated. 128 * of space allocated.
141 */ 129 */
142#ifdef EIGHT_BIT
143static void bn_GF2m_mul_1x1(BN_ULONG *r1, BN_ULONG *r0, const BN_ULONG a, const BN_ULONG b)
144 {
145 register BN_ULONG h, l, s;
146 BN_ULONG tab[4], top1b = a >> 7;
147 register BN_ULONG a1, a2;
148
149 a1 = a & (0x7F); a2 = a1 << 1;
150
151 tab[0] = 0; tab[1] = a1; tab[2] = a2; tab[3] = a1^a2;
152
153 s = tab[b & 0x3]; l = s;
154 s = tab[b >> 2 & 0x3]; l ^= s << 2; h = s >> 6;
155 s = tab[b >> 4 & 0x3]; l ^= s << 4; h ^= s >> 4;
156 s = tab[b >> 6 ]; l ^= s << 6; h ^= s >> 2;
157
158 /* compensate for the top bit of a */
159
160 if (top1b & 01) { l ^= b << 7; h ^= b >> 1; }
161
162 *r1 = h; *r0 = l;
163 }
164#endif
165#ifdef SIXTEEN_BIT
166static void bn_GF2m_mul_1x1(BN_ULONG *r1, BN_ULONG *r0, const BN_ULONG a, const BN_ULONG b)
167 {
168 register BN_ULONG h, l, s;
169 BN_ULONG tab[4], top1b = a >> 15;
170 register BN_ULONG a1, a2;
171
172 a1 = a & (0x7FFF); a2 = a1 << 1;
173
174 tab[0] = 0; tab[1] = a1; tab[2] = a2; tab[3] = a1^a2;
175
176 s = tab[b & 0x3]; l = s;
177 s = tab[b >> 2 & 0x3]; l ^= s << 2; h = s >> 14;
178 s = tab[b >> 4 & 0x3]; l ^= s << 4; h ^= s >> 12;
179 s = tab[b >> 6 & 0x3]; l ^= s << 6; h ^= s >> 10;
180 s = tab[b >> 8 & 0x3]; l ^= s << 8; h ^= s >> 8;
181 s = tab[b >>10 & 0x3]; l ^= s << 10; h ^= s >> 6;
182 s = tab[b >>12 & 0x3]; l ^= s << 12; h ^= s >> 4;
183 s = tab[b >>14 ]; l ^= s << 14; h ^= s >> 2;
184
185 /* compensate for the top bit of a */
186
187 if (top1b & 01) { l ^= b << 15; h ^= b >> 1; }
188
189 *r1 = h; *r0 = l;
190 }
191#endif
192#ifdef THIRTY_TWO_BIT 130#ifdef THIRTY_TWO_BIT
193static void bn_GF2m_mul_1x1(BN_ULONG *r1, BN_ULONG *r0, const BN_ULONG a, const BN_ULONG b) 131static void bn_GF2m_mul_1x1(BN_ULONG *r1, BN_ULONG *r0, const BN_ULONG a, const BN_ULONG b)
194 { 132 {
@@ -321,7 +259,7 @@ int BN_GF2m_add(BIGNUM *r, const BIGNUM *a, const BIGNUM *b)
321 259
322 260
323/* Performs modular reduction of a and store result in r. r could be a. */ 261/* Performs modular reduction of a and store result in r. r could be a. */
324int BN_GF2m_mod_arr(BIGNUM *r, const BIGNUM *a, const unsigned int p[]) 262int BN_GF2m_mod_arr(BIGNUM *r, const BIGNUM *a, const int p[])
325 { 263 {
326 int j, k; 264 int j, k;
327 int n, dN, d0, d1; 265 int n, dN, d0, d1;
@@ -422,11 +360,11 @@ int BN_GF2m_mod_arr(BIGNUM *r, const BIGNUM *a, const unsigned int p[])
422int BN_GF2m_mod(BIGNUM *r, const BIGNUM *a, const BIGNUM *p) 360int BN_GF2m_mod(BIGNUM *r, const BIGNUM *a, const BIGNUM *p)
423 { 361 {
424 int ret = 0; 362 int ret = 0;
425 const int max = BN_num_bits(p); 363 const int max = BN_num_bits(p) + 1;
426 unsigned int *arr=NULL; 364 int *arr=NULL;
427 bn_check_top(a); 365 bn_check_top(a);
428 bn_check_top(p); 366 bn_check_top(p);
429 if ((arr = (unsigned int *)OPENSSL_malloc(sizeof(unsigned int) * max)) == NULL) goto err; 367 if ((arr = (int *)OPENSSL_malloc(sizeof(int) * max)) == NULL) goto err;
430 ret = BN_GF2m_poly2arr(p, arr, max); 368 ret = BN_GF2m_poly2arr(p, arr, max);
431 if (!ret || ret > max) 369 if (!ret || ret > max)
432 { 370 {
@@ -444,7 +382,7 @@ err:
444/* Compute the product of two polynomials a and b, reduce modulo p, and store 382/* Compute the product of two polynomials a and b, reduce modulo p, and store
445 * the result in r. r could be a or b; a could be b. 383 * the result in r. r could be a or b; a could be b.
446 */ 384 */
447int BN_GF2m_mod_mul_arr(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const unsigned int p[], BN_CTX *ctx) 385int BN_GF2m_mod_mul_arr(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const int p[], BN_CTX *ctx)
448 { 386 {
449 int zlen, i, j, k, ret = 0; 387 int zlen, i, j, k, ret = 0;
450 BIGNUM *s; 388 BIGNUM *s;
@@ -500,12 +438,12 @@ err:
500int BN_GF2m_mod_mul(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *p, BN_CTX *ctx) 438int BN_GF2m_mod_mul(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *p, BN_CTX *ctx)
501 { 439 {
502 int ret = 0; 440 int ret = 0;
503 const int max = BN_num_bits(p); 441 const int max = BN_num_bits(p) + 1;
504 unsigned int *arr=NULL; 442 int *arr=NULL;
505 bn_check_top(a); 443 bn_check_top(a);
506 bn_check_top(b); 444 bn_check_top(b);
507 bn_check_top(p); 445 bn_check_top(p);
508 if ((arr = (unsigned int *)OPENSSL_malloc(sizeof(unsigned int) * max)) == NULL) goto err; 446 if ((arr = (int *)OPENSSL_malloc(sizeof(int) * max)) == NULL) goto err;
509 ret = BN_GF2m_poly2arr(p, arr, max); 447 ret = BN_GF2m_poly2arr(p, arr, max);
510 if (!ret || ret > max) 448 if (!ret || ret > max)
511 { 449 {
@@ -521,7 +459,7 @@ err:
521 459
522 460
523/* Square a, reduce the result mod p, and store it in a. r could be a. */ 461/* Square a, reduce the result mod p, and store it in a. r could be a. */
524int BN_GF2m_mod_sqr_arr(BIGNUM *r, const BIGNUM *a, const unsigned int p[], BN_CTX *ctx) 462int BN_GF2m_mod_sqr_arr(BIGNUM *r, const BIGNUM *a, const int p[], BN_CTX *ctx)
525 { 463 {
526 int i, ret = 0; 464 int i, ret = 0;
527 BIGNUM *s; 465 BIGNUM *s;
@@ -556,12 +494,12 @@ err:
556int BN_GF2m_mod_sqr(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx) 494int BN_GF2m_mod_sqr(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx)
557 { 495 {
558 int ret = 0; 496 int ret = 0;
559 const int max = BN_num_bits(p); 497 const int max = BN_num_bits(p) + 1;
560 unsigned int *arr=NULL; 498 int *arr=NULL;
561 499
562 bn_check_top(a); 500 bn_check_top(a);
563 bn_check_top(p); 501 bn_check_top(p);
564 if ((arr = (unsigned int *)OPENSSL_malloc(sizeof(unsigned int) * max)) == NULL) goto err; 502 if ((arr = (int *)OPENSSL_malloc(sizeof(int) * max)) == NULL) goto err;
565 ret = BN_GF2m_poly2arr(p, arr, max); 503 ret = BN_GF2m_poly2arr(p, arr, max);
566 if (!ret || ret > max) 504 if (!ret || ret > max)
567 { 505 {
@@ -643,7 +581,7 @@ err:
643 * function is only provided for convenience; for best performance, use the 581 * function is only provided for convenience; for best performance, use the
644 * BN_GF2m_mod_inv function. 582 * BN_GF2m_mod_inv function.
645 */ 583 */
646int BN_GF2m_mod_inv_arr(BIGNUM *r, const BIGNUM *xx, const unsigned int p[], BN_CTX *ctx) 584int BN_GF2m_mod_inv_arr(BIGNUM *r, const BIGNUM *xx, const int p[], BN_CTX *ctx)
647 { 585 {
648 BIGNUM *field; 586 BIGNUM *field;
649 int ret = 0; 587 int ret = 0;
@@ -769,7 +707,7 @@ err:
769 * function is only provided for convenience; for best performance, use the 707 * function is only provided for convenience; for best performance, use the
770 * BN_GF2m_mod_div function. 708 * BN_GF2m_mod_div function.
771 */ 709 */
772int BN_GF2m_mod_div_arr(BIGNUM *r, const BIGNUM *yy, const BIGNUM *xx, const unsigned int p[], BN_CTX *ctx) 710int BN_GF2m_mod_div_arr(BIGNUM *r, const BIGNUM *yy, const BIGNUM *xx, const int p[], BN_CTX *ctx)
773 { 711 {
774 BIGNUM *field; 712 BIGNUM *field;
775 int ret = 0; 713 int ret = 0;
@@ -794,7 +732,7 @@ err:
794 * the result in r. r could be a. 732 * the result in r. r could be a.
795 * Uses simple square-and-multiply algorithm A.5.1 from IEEE P1363. 733 * Uses simple square-and-multiply algorithm A.5.1 from IEEE P1363.
796 */ 734 */
797int BN_GF2m_mod_exp_arr(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const unsigned int p[], BN_CTX *ctx) 735int BN_GF2m_mod_exp_arr(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const int p[], BN_CTX *ctx)
798 { 736 {
799 int ret = 0, i, n; 737 int ret = 0, i, n;
800 BIGNUM *u; 738 BIGNUM *u;
@@ -840,12 +778,12 @@ err:
840int BN_GF2m_mod_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *p, BN_CTX *ctx) 778int BN_GF2m_mod_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *p, BN_CTX *ctx)
841 { 779 {
842 int ret = 0; 780 int ret = 0;
843 const int max = BN_num_bits(p); 781 const int max = BN_num_bits(p) + 1;
844 unsigned int *arr=NULL; 782 int *arr=NULL;
845 bn_check_top(a); 783 bn_check_top(a);
846 bn_check_top(b); 784 bn_check_top(b);
847 bn_check_top(p); 785 bn_check_top(p);
848 if ((arr = (unsigned int *)OPENSSL_malloc(sizeof(unsigned int) * max)) == NULL) goto err; 786 if ((arr = (int *)OPENSSL_malloc(sizeof(int) * max)) == NULL) goto err;
849 ret = BN_GF2m_poly2arr(p, arr, max); 787 ret = BN_GF2m_poly2arr(p, arr, max);
850 if (!ret || ret > max) 788 if (!ret || ret > max)
851 { 789 {
@@ -863,7 +801,7 @@ err:
863 * the result in r. r could be a. 801 * the result in r. r could be a.
864 * Uses exponentiation as in algorithm A.4.1 from IEEE P1363. 802 * Uses exponentiation as in algorithm A.4.1 from IEEE P1363.
865 */ 803 */
866int BN_GF2m_mod_sqrt_arr(BIGNUM *r, const BIGNUM *a, const unsigned int p[], BN_CTX *ctx) 804int BN_GF2m_mod_sqrt_arr(BIGNUM *r, const BIGNUM *a, const int p[], BN_CTX *ctx)
867 { 805 {
868 int ret = 0; 806 int ret = 0;
869 BIGNUM *u; 807 BIGNUM *u;
@@ -899,11 +837,11 @@ err:
899int BN_GF2m_mod_sqrt(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx) 837int BN_GF2m_mod_sqrt(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx)
900 { 838 {
901 int ret = 0; 839 int ret = 0;
902 const int max = BN_num_bits(p); 840 const int max = BN_num_bits(p) + 1;
903 unsigned int *arr=NULL; 841 int *arr=NULL;
904 bn_check_top(a); 842 bn_check_top(a);
905 bn_check_top(p); 843 bn_check_top(p);
906 if ((arr = (unsigned int *)OPENSSL_malloc(sizeof(unsigned int) * max)) == NULL) goto err; 844 if ((arr = (int *)OPENSSL_malloc(sizeof(int) * max)) == NULL) goto err;
907 ret = BN_GF2m_poly2arr(p, arr, max); 845 ret = BN_GF2m_poly2arr(p, arr, max);
908 if (!ret || ret > max) 846 if (!ret || ret > max)
909 { 847 {
@@ -920,10 +858,9 @@ err:
920/* Find r such that r^2 + r = a mod p. r could be a. If no r exists returns 0. 858/* Find r such that r^2 + r = a mod p. r could be a. If no r exists returns 0.
921 * Uses algorithms A.4.7 and A.4.6 from IEEE P1363. 859 * Uses algorithms A.4.7 and A.4.6 from IEEE P1363.
922 */ 860 */
923int BN_GF2m_mod_solve_quad_arr(BIGNUM *r, const BIGNUM *a_, const unsigned int p[], BN_CTX *ctx) 861int BN_GF2m_mod_solve_quad_arr(BIGNUM *r, const BIGNUM *a_, const int p[], BN_CTX *ctx)
924 { 862 {
925 int ret = 0, count = 0; 863 int ret = 0, count = 0, j;
926 unsigned int j;
927 BIGNUM *a, *z, *rho, *w, *w2, *tmp; 864 BIGNUM *a, *z, *rho, *w, *w2, *tmp;
928 865
929 bn_check_top(a_); 866 bn_check_top(a_);
@@ -1018,11 +955,11 @@ err:
1018int BN_GF2m_mod_solve_quad(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx) 955int BN_GF2m_mod_solve_quad(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx)
1019 { 956 {
1020 int ret = 0; 957 int ret = 0;
1021 const int max = BN_num_bits(p); 958 const int max = BN_num_bits(p) + 1;
1022 unsigned int *arr=NULL; 959 int *arr=NULL;
1023 bn_check_top(a); 960 bn_check_top(a);
1024 bn_check_top(p); 961 bn_check_top(p);
1025 if ((arr = (unsigned int *)OPENSSL_malloc(sizeof(unsigned int) * 962 if ((arr = (int *)OPENSSL_malloc(sizeof(int) *
1026 max)) == NULL) goto err; 963 max)) == NULL) goto err;
1027 ret = BN_GF2m_poly2arr(p, arr, max); 964 ret = BN_GF2m_poly2arr(p, arr, max);
1028 if (!ret || ret > max) 965 if (!ret || ret > max)
@@ -1038,20 +975,17 @@ err:
1038 } 975 }
1039 976
1040/* Convert the bit-string representation of a polynomial 977/* Convert the bit-string representation of a polynomial
1041 * ( \sum_{i=0}^n a_i * x^i , where a_0 is *not* zero) into an array 978 * ( \sum_{i=0}^n a_i * x^i) into an array of integers corresponding
1042 * of integers corresponding to the bits with non-zero coefficient. 979 * to the bits with non-zero coefficient. Array is terminated with -1.
1043 * Up to max elements of the array will be filled. Return value is total 980 * Up to max elements of the array will be filled. Return value is total
1044 * number of coefficients that would be extracted if array was large enough. 981 * number of array elements that would be filled if array was large enough.
1045 */ 982 */
1046int BN_GF2m_poly2arr(const BIGNUM *a, unsigned int p[], int max) 983int BN_GF2m_poly2arr(const BIGNUM *a, int p[], int max)
1047 { 984 {
1048 int i, j, k = 0; 985 int i, j, k = 0;
1049 BN_ULONG mask; 986 BN_ULONG mask;
1050 987
1051 if (BN_is_zero(a) || !BN_is_bit_set(a, 0)) 988 if (BN_is_zero(a))
1052 /* a_0 == 0 => return error (the unsigned int array
1053 * must be terminated by 0)
1054 */
1055 return 0; 989 return 0;
1056 990
1057 for (i = a->top - 1; i >= 0; i--) 991 for (i = a->top - 1; i >= 0; i--)
@@ -1071,24 +1005,28 @@ int BN_GF2m_poly2arr(const BIGNUM *a, unsigned int p[], int max)
1071 } 1005 }
1072 } 1006 }
1073 1007
1008 if (k < max) {
1009 p[k] = -1;
1010 k++;
1011 }
1012
1074 return k; 1013 return k;
1075 } 1014 }
1076 1015
1077/* Convert the coefficient array representation of a polynomial to a 1016/* Convert the coefficient array representation of a polynomial to a
1078 * bit-string. The array must be terminated by 0. 1017 * bit-string. The array must be terminated by -1.
1079 */ 1018 */
1080int BN_GF2m_arr2poly(const unsigned int p[], BIGNUM *a) 1019int BN_GF2m_arr2poly(const int p[], BIGNUM *a)
1081 { 1020 {
1082 int i; 1021 int i;
1083 1022
1084 bn_check_top(a); 1023 bn_check_top(a);
1085 BN_zero(a); 1024 BN_zero(a);
1086 for (i = 0; p[i] != 0; i++) 1025 for (i = 0; p[i] != -1; i++)
1087 { 1026 {
1088 if (BN_set_bit(a, p[i]) == 0) 1027 if (BN_set_bit(a, p[i]) == 0)
1089 return 0; 1028 return 0;
1090 } 1029 }
1091 BN_set_bit(a, 0);
1092 bn_check_top(a); 1030 bn_check_top(a);
1093 1031
1094 return 1; 1032 return 1;
diff --git a/src/lib/libcrypto/bn/bn_lcl.h b/src/lib/libcrypto/bn/bn_lcl.h
index 27ac4397a1..8e5e98e3f2 100644
--- a/src/lib/libcrypto/bn/bn_lcl.h
+++ b/src/lib/libcrypto/bn/bn_lcl.h
@@ -255,7 +255,8 @@ extern "C" {
255 : "r"(a), "r"(b)); \ 255 : "r"(a), "r"(b)); \
256 ret; }) 256 ret; })
257# endif /* compiler */ 257# endif /* compiler */
258# elif defined(__x86_64) && defined(SIXTY_FOUR_BIT_LONG) 258# elif (defined(__x86_64) || defined(__x86_64__)) && \
259 (defined(SIXTY_FOUR_BIT_LONG) || defined(SIXTY_FOUR_BIT))
259# if defined(__GNUC__) 260# if defined(__GNUC__)
260# define BN_UMULT_HIGH(a,b) ({ \ 261# define BN_UMULT_HIGH(a,b) ({ \
261 register BN_ULONG ret,discard; \ 262 register BN_ULONG ret,discard; \
diff --git a/src/lib/libcrypto/bn/bn_lib.c b/src/lib/libcrypto/bn/bn_lib.c
index 32a8fbaf51..5470fbe6ef 100644
--- a/src/lib/libcrypto/bn/bn_lib.c
+++ b/src/lib/libcrypto/bn/bn_lib.c
@@ -133,15 +133,34 @@ int BN_get_params(int which)
133 133
134const BIGNUM *BN_value_one(void) 134const BIGNUM *BN_value_one(void)
135 { 135 {
136 static BN_ULONG data_one=1L; 136 static const BN_ULONG data_one=1L;
137 static BIGNUM const_one={&data_one,1,1,0,BN_FLG_STATIC_DATA}; 137 static const BIGNUM const_one={(BN_ULONG *)&data_one,1,1,0,BN_FLG_STATIC_DATA};
138 138
139 return(&const_one); 139 return(&const_one);
140 } 140 }
141 141
142char *BN_options(void)
143 {
144 static int init=0;
145 static char data[16];
146
147 if (!init)
148 {
149 init++;
150#ifdef BN_LLONG
151 BIO_snprintf(data,sizeof data,"bn(%d,%d)",
152 (int)sizeof(BN_ULLONG)*8,(int)sizeof(BN_ULONG)*8);
153#else
154 BIO_snprintf(data,sizeof data,"bn(%d,%d)",
155 (int)sizeof(BN_ULONG)*8,(int)sizeof(BN_ULONG)*8);
156#endif
157 }
158 return(data);
159 }
160
142int BN_num_bits_word(BN_ULONG l) 161int BN_num_bits_word(BN_ULONG l)
143 { 162 {
144 static const char bits[256]={ 163 static const unsigned char bits[256]={
145 0,1,2,2,3,3,3,3,4,4,4,4,4,4,4,4, 164 0,1,2,2,3,3,3,3,4,4,4,4,4,4,4,4,
146 5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5, 165 5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,
147 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6, 166 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,
@@ -216,7 +235,7 @@ int BN_num_bits_word(BN_ULONG l)
216 else 235 else
217#endif 236#endif
218 { 237 {
219#if defined(SIXTEEN_BIT) || defined(THIRTY_TWO_BIT) || defined(SIXTY_FOUR_BIT) || defined(SIXTY_FOUR_BIT_LONG) 238#if defined(THIRTY_TWO_BIT) || defined(SIXTY_FOUR_BIT) || defined(SIXTY_FOUR_BIT_LONG)
220 if (l & 0xff00L) 239 if (l & 0xff00L)
221 return(bits[(int)(l>>8)]+8); 240 return(bits[(int)(l>>8)]+8);
222 else 241 else
@@ -744,7 +763,7 @@ int BN_is_bit_set(const BIGNUM *a, int n)
744 i=n/BN_BITS2; 763 i=n/BN_BITS2;
745 j=n%BN_BITS2; 764 j=n%BN_BITS2;
746 if (a->top <= i) return 0; 765 if (a->top <= i) return 0;
747 return(((a->d[i])>>j)&((BN_ULONG)1)); 766 return (int)(((a->d[i])>>j)&((BN_ULONG)1));
748 } 767 }
749 768
750int BN_mask_bits(BIGNUM *a, int n) 769int BN_mask_bits(BIGNUM *a, int n)
diff --git a/src/lib/libcrypto/bn/bn_mont.c b/src/lib/libcrypto/bn/bn_mont.c
index 4799b152dd..7224637ab3 100644
--- a/src/lib/libcrypto/bn/bn_mont.c
+++ b/src/lib/libcrypto/bn/bn_mont.c
@@ -122,26 +122,10 @@
122 122
123#define MONT_WORD /* use the faster word-based algorithm */ 123#define MONT_WORD /* use the faster word-based algorithm */
124 124
125#if defined(MONT_WORD) && defined(OPENSSL_BN_ASM_MONT) && (BN_BITS2<=32) 125#ifdef MONT_WORD
126/* This condition means we have a specific non-default build:
127 * In the 0.9.8 branch, OPENSSL_BN_ASM_MONT is normally not set for any
128 * BN_BITS2<=32 platform; an explicit "enable-montasm" is required.
129 * I.e., if we are here, the user intentionally deviates from the
130 * normal stable build to get better Montgomery performance from
131 * the 0.9.9-dev backport.
132 *
133 * In this case only, we also enable BN_from_montgomery_word()
134 * (another non-stable feature from 0.9.9-dev).
135 */
136#define MONT_FROM_WORD___NON_DEFAULT_0_9_8_BUILD
137#endif
138
139#ifdef MONT_FROM_WORD___NON_DEFAULT_0_9_8_BUILD
140static int BN_from_montgomery_word(BIGNUM *ret, BIGNUM *r, BN_MONT_CTX *mont); 126static int BN_from_montgomery_word(BIGNUM *ret, BIGNUM *r, BN_MONT_CTX *mont);
141#endif 127#endif
142 128
143
144
145int BN_mod_mul_montgomery(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, 129int BN_mod_mul_montgomery(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,
146 BN_MONT_CTX *mont, BN_CTX *ctx) 130 BN_MONT_CTX *mont, BN_CTX *ctx)
147 { 131 {
@@ -153,11 +137,7 @@ int BN_mod_mul_montgomery(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,
153 if (num>1 && a->top==num && b->top==num) 137 if (num>1 && a->top==num && b->top==num)
154 { 138 {
155 if (bn_wexpand(r,num) == NULL) return(0); 139 if (bn_wexpand(r,num) == NULL) return(0);
156#if 0 /* for OpenSSL 0.9.9 mont->n0 */
157 if (bn_mul_mont(r->d,a->d,b->d,mont->N.d,mont->n0,num)) 140 if (bn_mul_mont(r->d,a->d,b->d,mont->N.d,mont->n0,num))
158#else
159 if (bn_mul_mont(r->d,a->d,b->d,mont->N.d,&mont->n0,num))
160#endif
161 { 141 {
162 r->neg = a->neg^b->neg; 142 r->neg = a->neg^b->neg;
163 r->top = num; 143 r->top = num;
@@ -181,7 +161,7 @@ int BN_mod_mul_montgomery(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,
181 if (!BN_mul(tmp,a,b,ctx)) goto err; 161 if (!BN_mul(tmp,a,b,ctx)) goto err;
182 } 162 }
183 /* reduce from aRR to aR */ 163 /* reduce from aRR to aR */
184#ifdef MONT_FROM_WORD___NON_DEFAULT_0_9_8_BUILD 164#ifdef MONT_WORD
185 if (!BN_from_montgomery_word(r,tmp,mont)) goto err; 165 if (!BN_from_montgomery_word(r,tmp,mont)) goto err;
186#else 166#else
187 if (!BN_from_montgomery(r,tmp,mont,ctx)) goto err; 167 if (!BN_from_montgomery(r,tmp,mont,ctx)) goto err;
@@ -193,7 +173,7 @@ err:
193 return(ret); 173 return(ret);
194 } 174 }
195 175
196#ifdef MONT_FROM_WORD___NON_DEFAULT_0_9_8_BUILD 176#ifdef MONT_WORD
197static int BN_from_montgomery_word(BIGNUM *ret, BIGNUM *r, BN_MONT_CTX *mont) 177static int BN_from_montgomery_word(BIGNUM *ret, BIGNUM *r, BN_MONT_CTX *mont)
198 { 178 {
199 BIGNUM *n; 179 BIGNUM *n;
@@ -217,15 +197,15 @@ static int BN_from_montgomery_word(BIGNUM *ret, BIGNUM *r, BN_MONT_CTX *mont)
217 nrp= &(r->d[nl]); 197 nrp= &(r->d[nl]);
218 198
219 /* clear the top words of T */ 199 /* clear the top words of T */
200#if 1
220 for (i=r->top; i<max; i++) /* memset? XXX */ 201 for (i=r->top; i<max; i++) /* memset? XXX */
221 r->d[i]=0; 202 r->d[i]=0;
203#else
204 memset(&(r->d[r->top]),0,(max-r->top)*sizeof(BN_ULONG));
205#endif
222 206
223 r->top=max; 207 r->top=max;
224#if 0 /* for OpenSSL 0.9.9 mont->n0 */
225 n0=mont->n0[0]; 208 n0=mont->n0[0];
226#else
227 n0=mont->n0;
228#endif
229 209
230#ifdef BN_COUNT 210#ifdef BN_COUNT
231 fprintf(stderr,"word BN_from_montgomery_word %d * %d\n",nl,nl); 211 fprintf(stderr,"word BN_from_montgomery_word %d * %d\n",nl,nl);
@@ -270,6 +250,8 @@ static int BN_from_montgomery_word(BIGNUM *ret, BIGNUM *r, BN_MONT_CTX *mont)
270 } 250 }
271 al=r->top-ri; 251 al=r->top-ri;
272 252
253#define BRANCH_FREE 1
254#if BRANCH_FREE
273 if (bn_wexpand(ret,ri) == NULL) return(0); 255 if (bn_wexpand(ret,ri) == NULL) return(0);
274 x=0-(((al-ri)>>(sizeof(al)*8-1))&1); 256 x=0-(((al-ri)>>(sizeof(al)*8-1))&1);
275 ret->top=x=(ri&~x)|(al&x); /* min(ri,al) */ 257 ret->top=x=(ri&~x)|(al&x); /* min(ri,al) */
@@ -317,164 +299,8 @@ static int BN_from_montgomery_word(BIGNUM *ret, BIGNUM *r, BN_MONT_CTX *mont)
317 rp[i]=nrp[i], ap[i]=0; 299 rp[i]=nrp[i], ap[i]=0;
318 bn_correct_top(r); 300 bn_correct_top(r);
319 bn_correct_top(ret); 301 bn_correct_top(ret);
320 bn_check_top(ret);
321
322 return(1);
323 }
324
325int BN_from_montgomery(BIGNUM *ret, const BIGNUM *a, BN_MONT_CTX *mont,
326 BN_CTX *ctx)
327 {
328 int retn=0;
329 BIGNUM *t;
330
331 BN_CTX_start(ctx);
332 if ((t = BN_CTX_get(ctx)) && BN_copy(t,a))
333 retn = BN_from_montgomery_word(ret,t,mont);
334 BN_CTX_end(ctx);
335 return retn;
336 }
337
338#else /* !MONT_FROM_WORD___NON_DEFAULT_0_9_8_BUILD */
339
340int BN_from_montgomery(BIGNUM *ret, const BIGNUM *a, BN_MONT_CTX *mont,
341 BN_CTX *ctx)
342 {
343 int retn=0;
344
345#ifdef MONT_WORD
346 BIGNUM *n,*r;
347 BN_ULONG *ap,*np,*rp,n0,v,*nrp;
348 int al,nl,max,i,x,ri;
349
350 BN_CTX_start(ctx);
351 if ((r = BN_CTX_get(ctx)) == NULL) goto err;
352
353 if (!BN_copy(r,a)) goto err;
354 n= &(mont->N);
355
356 ap=a->d;
357 /* mont->ri is the size of mont->N in bits (rounded up
358 to the word size) */
359 al=ri=mont->ri/BN_BITS2;
360
361 nl=n->top;
362 if ((al == 0) || (nl == 0)) { r->top=0; return(1); }
363
364 max=(nl+al+1); /* allow for overflow (no?) XXX */
365 if (bn_wexpand(r,max) == NULL) goto err;
366
367 r->neg=a->neg^n->neg;
368 np=n->d;
369 rp=r->d;
370 nrp= &(r->d[nl]);
371
372 /* clear the top words of T */
373#if 1
374 for (i=r->top; i<max; i++) /* memset? XXX */
375 r->d[i]=0;
376#else 302#else
377 memset(&(r->d[r->top]),0,(max-r->top)*sizeof(BN_ULONG)); 303 if (bn_wexpand(ret,al) == NULL) return(0);
378#endif
379
380 r->top=max;
381 n0=mont->n0;
382
383#ifdef BN_COUNT
384 fprintf(stderr,"word BN_from_montgomery %d * %d\n",nl,nl);
385#endif
386 for (i=0; i<nl; i++)
387 {
388#ifdef __TANDEM
389 {
390 long long t1;
391 long long t2;
392 long long t3;
393 t1 = rp[0] * (n0 & 0177777);
394 t2 = 037777600000l;
395 t2 = n0 & t2;
396 t3 = rp[0] & 0177777;
397 t2 = (t3 * t2) & BN_MASK2;
398 t1 = t1 + t2;
399 v=bn_mul_add_words(rp,np,nl,(BN_ULONG) t1);
400 }
401#else
402 v=bn_mul_add_words(rp,np,nl,(rp[0]*n0)&BN_MASK2);
403#endif
404 nrp++;
405 rp++;
406 if (((nrp[-1]+=v)&BN_MASK2) >= v)
407 continue;
408 else
409 {
410 if (((++nrp[0])&BN_MASK2) != 0) continue;
411 if (((++nrp[1])&BN_MASK2) != 0) continue;
412 for (x=2; (((++nrp[x])&BN_MASK2) == 0); x++) ;
413 }
414 }
415 bn_correct_top(r);
416
417 /* mont->ri will be a multiple of the word size and below code
418 * is kind of BN_rshift(ret,r,mont->ri) equivalent */
419 if (r->top <= ri)
420 {
421 ret->top=0;
422 retn=1;
423 goto err;
424 }
425 al=r->top-ri;
426
427# define BRANCH_FREE 1
428# if BRANCH_FREE
429 if (bn_wexpand(ret,ri) == NULL) goto err;
430 x=0-(((al-ri)>>(sizeof(al)*8-1))&1);
431 ret->top=x=(ri&~x)|(al&x); /* min(ri,al) */
432 ret->neg=r->neg;
433
434 rp=ret->d;
435 ap=&(r->d[ri]);
436
437 {
438 size_t m1,m2;
439
440 v=bn_sub_words(rp,ap,np,ri);
441 /* this ----------------^^ works even in al<ri case
442 * thanks to zealous zeroing of top of the vector in the
443 * beginning. */
444
445 /* if (al==ri && !v) || al>ri) nrp=rp; else nrp=ap; */
446 /* in other words if subtraction result is real, then
447 * trick unconditional memcpy below to perform in-place
448 * "refresh" instead of actual copy. */
449 m1=0-(size_t)(((al-ri)>>(sizeof(al)*8-1))&1); /* al<ri */
450 m2=0-(size_t)(((ri-al)>>(sizeof(al)*8-1))&1); /* al>ri */
451 m1|=m2; /* (al!=ri) */
452 m1|=(0-(size_t)v); /* (al!=ri || v) */
453 m1&=~m2; /* (al!=ri || v) && !al>ri */
454 nrp=(BN_ULONG *)(((size_t)rp&~m1)|((size_t)ap&m1));
455 }
456
457 /* 'i<ri' is chosen to eliminate dependency on input data, even
458 * though it results in redundant copy in al<ri case. */
459 for (i=0,ri-=4; i<ri; i+=4)
460 {
461 BN_ULONG t1,t2,t3,t4;
462
463 t1=nrp[i+0];
464 t2=nrp[i+1];
465 t3=nrp[i+2]; ap[i+0]=0;
466 t4=nrp[i+3]; ap[i+1]=0;
467 rp[i+0]=t1; ap[i+2]=0;
468 rp[i+1]=t2; ap[i+3]=0;
469 rp[i+2]=t3;
470 rp[i+3]=t4;
471 }
472 for (ri+=4; i<ri; i++)
473 rp[i]=nrp[i], ap[i]=0;
474 bn_correct_top(r);
475 bn_correct_top(ret);
476# else
477 if (bn_wexpand(ret,al) == NULL) goto err;
478 ret->top=al; 304 ret->top=al;
479 ret->neg=r->neg; 305 ret->neg=r->neg;
480 306
@@ -497,8 +323,30 @@ int BN_from_montgomery(BIGNUM *ret, const BIGNUM *a, BN_MONT_CTX *mont,
497 al+=4; 323 al+=4;
498 for (; i<al; i++) 324 for (; i<al; i++)
499 rp[i]=ap[i]; 325 rp[i]=ap[i];
500# endif 326
501#else /* !MONT_WORD */ 327 if (BN_ucmp(ret, &(mont->N)) >= 0)
328 {
329 if (!BN_usub(ret,ret,&(mont->N))) return(0);
330 }
331#endif
332 bn_check_top(ret);
333
334 return(1);
335 }
336#endif /* MONT_WORD */
337
338int BN_from_montgomery(BIGNUM *ret, const BIGNUM *a, BN_MONT_CTX *mont,
339 BN_CTX *ctx)
340 {
341 int retn=0;
342#ifdef MONT_WORD
343 BIGNUM *t;
344
345 BN_CTX_start(ctx);
346 if ((t = BN_CTX_get(ctx)) && BN_copy(t,a))
347 retn = BN_from_montgomery_word(ret,t,mont);
348 BN_CTX_end(ctx);
349#else /* !MONT_WORD */
502 BIGNUM *t1,*t2; 350 BIGNUM *t1,*t2;
503 351
504 BN_CTX_start(ctx); 352 BN_CTX_start(ctx);
@@ -515,21 +363,18 @@ int BN_from_montgomery(BIGNUM *ret, const BIGNUM *a, BN_MONT_CTX *mont,
515 if (!BN_mul(t1,t2,&mont->N,ctx)) goto err; 363 if (!BN_mul(t1,t2,&mont->N,ctx)) goto err;
516 if (!BN_add(t2,a,t1)) goto err; 364 if (!BN_add(t2,a,t1)) goto err;
517 if (!BN_rshift(ret,t2,mont->ri)) goto err; 365 if (!BN_rshift(ret,t2,mont->ri)) goto err;
518#endif /* MONT_WORD */
519 366
520#if !defined(BRANCH_FREE) || BRANCH_FREE==0
521 if (BN_ucmp(ret, &(mont->N)) >= 0) 367 if (BN_ucmp(ret, &(mont->N)) >= 0)
522 { 368 {
523 if (!BN_usub(ret,ret,&(mont->N))) goto err; 369 if (!BN_usub(ret,ret,&(mont->N))) goto err;
524 } 370 }
525#endif
526 retn=1; 371 retn=1;
527 bn_check_top(ret); 372 bn_check_top(ret);
528 err: 373 err:
529 BN_CTX_end(ctx); 374 BN_CTX_end(ctx);
375#endif /* MONT_WORD */
530 return(retn); 376 return(retn);
531 } 377 }
532#endif /* MONT_FROM_WORD___NON_DEFAULT_0_9_8_BUILD */
533 378
534BN_MONT_CTX *BN_MONT_CTX_new(void) 379BN_MONT_CTX *BN_MONT_CTX_new(void)
535 { 380 {
@@ -549,11 +394,7 @@ void BN_MONT_CTX_init(BN_MONT_CTX *ctx)
549 BN_init(&(ctx->RR)); 394 BN_init(&(ctx->RR));
550 BN_init(&(ctx->N)); 395 BN_init(&(ctx->N));
551 BN_init(&(ctx->Ni)); 396 BN_init(&(ctx->Ni));
552#if 0 /* for OpenSSL 0.9.9 mont->n0 */
553 ctx->n0[0] = ctx->n0[1] = 0; 397 ctx->n0[0] = ctx->n0[1] = 0;
554#else
555 ctx->n0 = 0;
556#endif
557 ctx->flags=0; 398 ctx->flags=0;
558 } 399 }
559 400
@@ -585,26 +426,22 @@ int BN_MONT_CTX_set(BN_MONT_CTX *mont, const BIGNUM *mod, BN_CTX *ctx)
585 BIGNUM tmod; 426 BIGNUM tmod;
586 BN_ULONG buf[2]; 427 BN_ULONG buf[2];
587 428
588 mont->ri=(BN_num_bits(mod)+(BN_BITS2-1))/BN_BITS2*BN_BITS2;
589 BN_zero(R);
590#if 0 /* for OpenSSL 0.9.9 mont->n0, would be "#if defined(OPENSSL_BN_ASM_MONT) && (BN_BITS2<=32)",
591 only certain BN_BITS2<=32 platforms actually need this */
592 if (!(BN_set_bit(R,2*BN_BITS2))) goto err; /* R */
593#else
594 if (!(BN_set_bit(R,BN_BITS2))) goto err; /* R */
595#endif
596
597 buf[0]=mod->d[0]; /* tmod = N mod word size */
598 buf[1]=0;
599
600 BN_init(&tmod); 429 BN_init(&tmod);
601 tmod.d=buf; 430 tmod.d=buf;
602 tmod.top = buf[0] != 0 ? 1 : 0;
603 tmod.dmax=2; 431 tmod.dmax=2;
604 tmod.neg=0; 432 tmod.neg=0;
605 433
606#if 0 /* for OpenSSL 0.9.9 mont->n0, would be "#if defined(OPENSSL_BN_ASM_MONT) && (BN_BITS2<=32)"; 434 mont->ri=(BN_num_bits(mod)+(BN_BITS2-1))/BN_BITS2*BN_BITS2;
607 only certain BN_BITS2<=32 platforms actually need this */ 435
436#if defined(OPENSSL_BN_ASM_MONT) && (BN_BITS2<=32)
437 /* Only certain BN_BITS2<=32 platforms actually make use of
438 * n0[1], and we could use the #else case (with a shorter R
439 * value) for the others. However, currently only the assembler
440 * files do know which is which. */
441
442 BN_zero(R);
443 if (!(BN_set_bit(R,2*BN_BITS2))) goto err;
444
608 tmod.top=0; 445 tmod.top=0;
609 if ((buf[0] = mod->d[0])) tmod.top=1; 446 if ((buf[0] = mod->d[0])) tmod.top=1;
610 if ((buf[1] = mod->top>1 ? mod->d[1] : 0)) tmod.top=2; 447 if ((buf[1] = mod->top>1 ? mod->d[1] : 0)) tmod.top=2;
@@ -632,6 +469,12 @@ int BN_MONT_CTX_set(BN_MONT_CTX *mont, const BIGNUM *mod, BN_CTX *ctx)
632 mont->n0[0] = (Ri->top > 0) ? Ri->d[0] : 0; 469 mont->n0[0] = (Ri->top > 0) ? Ri->d[0] : 0;
633 mont->n0[1] = (Ri->top > 1) ? Ri->d[1] : 0; 470 mont->n0[1] = (Ri->top > 1) ? Ri->d[1] : 0;
634#else 471#else
472 BN_zero(R);
473 if (!(BN_set_bit(R,BN_BITS2))) goto err; /* R */
474
475 buf[0]=mod->d[0]; /* tmod = N mod word size */
476 buf[1]=0;
477 tmod.top = buf[0] != 0 ? 1 : 0;
635 /* Ri = R^-1 mod N*/ 478 /* Ri = R^-1 mod N*/
636 if ((BN_mod_inverse(Ri,R,&tmod,ctx)) == NULL) 479 if ((BN_mod_inverse(Ri,R,&tmod,ctx)) == NULL)
637 goto err; 480 goto err;
@@ -647,12 +490,8 @@ int BN_MONT_CTX_set(BN_MONT_CTX *mont, const BIGNUM *mod, BN_CTX *ctx)
647 if (!BN_div(Ri,NULL,Ri,&tmod,ctx)) goto err; 490 if (!BN_div(Ri,NULL,Ri,&tmod,ctx)) goto err;
648 /* Ni = (R*Ri-1)/N, 491 /* Ni = (R*Ri-1)/N,
649 * keep only least significant word: */ 492 * keep only least significant word: */
650# if 0 /* for OpenSSL 0.9.9 mont->n0 */
651 mont->n0[0] = (Ri->top > 0) ? Ri->d[0] : 0; 493 mont->n0[0] = (Ri->top > 0) ? Ri->d[0] : 0;
652 mont->n0[1] = 0; 494 mont->n0[1] = 0;
653# else
654 mont->n0 = (Ri->top > 0) ? Ri->d[0] : 0;
655# endif
656#endif 495#endif
657 } 496 }
658#else /* !MONT_WORD */ 497#else /* !MONT_WORD */
@@ -689,12 +528,8 @@ BN_MONT_CTX *BN_MONT_CTX_copy(BN_MONT_CTX *to, BN_MONT_CTX *from)
689 if (!BN_copy(&(to->N),&(from->N))) return NULL; 528 if (!BN_copy(&(to->N),&(from->N))) return NULL;
690 if (!BN_copy(&(to->Ni),&(from->Ni))) return NULL; 529 if (!BN_copy(&(to->Ni),&(from->Ni))) return NULL;
691 to->ri=from->ri; 530 to->ri=from->ri;
692#if 0 /* for OpenSSL 0.9.9 mont->n0 */
693 to->n0[0]=from->n0[0]; 531 to->n0[0]=from->n0[0];
694 to->n0[1]=from->n0[1]; 532 to->n0[1]=from->n0[1];
695#else
696 to->n0=from->n0;
697#endif
698 return(to); 533 return(to);
699 } 534 }
700 535
diff --git a/src/lib/libcrypto/bn/bn_mul.c b/src/lib/libcrypto/bn/bn_mul.c
index b848c8cc60..a0e9ec3b46 100644
--- a/src/lib/libcrypto/bn/bn_mul.c
+++ b/src/lib/libcrypto/bn/bn_mul.c
@@ -1028,17 +1028,19 @@ int BN_mul(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx)
1028 assert(j <= al || j <= bl); 1028 assert(j <= al || j <= bl);
1029 k = j+j; 1029 k = j+j;
1030 t = BN_CTX_get(ctx); 1030 t = BN_CTX_get(ctx);
1031 if (t == NULL)
1032 goto err;
1031 if (al > j || bl > j) 1033 if (al > j || bl > j)
1032 { 1034 {
1033 bn_wexpand(t,k*4); 1035 if (bn_wexpand(t,k*4) == NULL) goto err;
1034 bn_wexpand(rr,k*4); 1036 if (bn_wexpand(rr,k*4) == NULL) goto err;
1035 bn_mul_part_recursive(rr->d,a->d,b->d, 1037 bn_mul_part_recursive(rr->d,a->d,b->d,
1036 j,al-j,bl-j,t->d); 1038 j,al-j,bl-j,t->d);
1037 } 1039 }
1038 else /* al <= j || bl <= j */ 1040 else /* al <= j || bl <= j */
1039 { 1041 {
1040 bn_wexpand(t,k*2); 1042 if (bn_wexpand(t,k*2) == NULL) goto err;
1041 bn_wexpand(rr,k*2); 1043 if (bn_wexpand(rr,k*2) == NULL) goto err;
1042 bn_mul_recursive(rr->d,a->d,b->d, 1044 bn_mul_recursive(rr->d,a->d,b->d,
1043 j,al-j,bl-j,t->d); 1045 j,al-j,bl-j,t->d);
1044 } 1046 }
diff --git a/src/lib/libcrypto/bn/bn_opt.c b/src/lib/libcrypto/bn/bn_opt.c
deleted file mode 100644
index 21cbb38f62..0000000000
--- a/src/lib/libcrypto/bn/bn_opt.c
+++ /dev/null
@@ -1,87 +0,0 @@
1/* crypto/bn/bn_opt.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#ifndef BN_DEBUG
60# undef NDEBUG /* avoid conflicting definitions */
61# define NDEBUG
62#endif
63
64#include <assert.h>
65#include <limits.h>
66#include <stdio.h>
67#include "cryptlib.h"
68#include "bn_lcl.h"
69
70char *BN_options(void)
71 {
72 static int init=0;
73 static char data[16];
74
75 if (!init)
76 {
77 init++;
78#ifdef BN_LLONG
79 BIO_snprintf(data,sizeof data,"bn(%d,%d)",
80 (int)sizeof(BN_ULLONG)*8,(int)sizeof(BN_ULONG)*8);
81#else
82 BIO_snprintf(data,sizeof data,"bn(%d,%d)",
83 (int)sizeof(BN_ULONG)*8,(int)sizeof(BN_ULONG)*8);
84#endif
85 }
86 return(data);
87 }
diff --git a/src/lib/libcrypto/bn/bn_print.c b/src/lib/libcrypto/bn/bn_print.c
index 810dde34e1..bebb466d08 100644
--- a/src/lib/libcrypto/bn/bn_print.c
+++ b/src/lib/libcrypto/bn/bn_print.c
@@ -294,6 +294,27 @@ err:
294 return(0); 294 return(0);
295 } 295 }
296 296
297int BN_asc2bn(BIGNUM **bn, const char *a)
298 {
299 const char *p = a;
300 if (*p == '-')
301 p++;
302
303 if (p[0] == '0' && (p[1] == 'X' || p[1] == 'x'))
304 {
305 if (!BN_hex2bn(bn, p + 2))
306 return 0;
307 }
308 else
309 {
310 if (!BN_dec2bn(bn, p))
311 return 0;
312 }
313 if (*a == '-')
314 (*bn)->neg = 1;
315 return 1;
316 }
317
297#ifndef OPENSSL_NO_BIO 318#ifndef OPENSSL_NO_BIO
298#ifndef OPENSSL_NO_FP_API 319#ifndef OPENSSL_NO_FP_API
299int BN_print_fp(FILE *fp, const BIGNUM *a) 320int BN_print_fp(FILE *fp, const BIGNUM *a)
diff --git a/src/lib/libcrypto/bn/bn_x931p.c b/src/lib/libcrypto/bn/bn_x931p.c
deleted file mode 100644
index 04c5c874ec..0000000000
--- a/src/lib/libcrypto/bn/bn_x931p.c
+++ /dev/null
@@ -1,272 +0,0 @@
1/* bn_x931p.c */
2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 2005.
4 */
5/* ====================================================================
6 * Copyright (c) 2005 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 * licensing@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 <stdio.h>
60#include <openssl/bn.h>
61
62/* X9.31 routines for prime derivation */
63
64/* X9.31 prime derivation. This is used to generate the primes pi
65 * (p1, p2, q1, q2) from a parameter Xpi by checking successive odd
66 * integers.
67 */
68
69static int bn_x931_derive_pi(BIGNUM *pi, const BIGNUM *Xpi, BN_CTX *ctx,
70 BN_GENCB *cb)
71 {
72 int i = 0;
73 if (!BN_copy(pi, Xpi))
74 return 0;
75 if (!BN_is_odd(pi) && !BN_add_word(pi, 1))
76 return 0;
77 for(;;)
78 {
79 i++;
80 BN_GENCB_call(cb, 0, i);
81 /* NB 27 MR is specificed in X9.31 */
82 if (BN_is_prime_fasttest_ex(pi, 27, ctx, 1, cb))
83 break;
84 if (!BN_add_word(pi, 2))
85 return 0;
86 }
87 BN_GENCB_call(cb, 2, i);
88 return 1;
89 }
90
91/* This is the main X9.31 prime derivation function. From parameters
92 * Xp1, Xp2 and Xp derive the prime p. If the parameters p1 or p2 are
93 * not NULL they will be returned too: this is needed for testing.
94 */
95
96int BN_X931_derive_prime_ex(BIGNUM *p, BIGNUM *p1, BIGNUM *p2,
97 const BIGNUM *Xp, const BIGNUM *Xp1, const BIGNUM *Xp2,
98 const BIGNUM *e, BN_CTX *ctx, BN_GENCB *cb)
99 {
100 int ret = 0;
101
102 BIGNUM *t, *p1p2, *pm1;
103
104 /* Only even e supported */
105 if (!BN_is_odd(e))
106 return 0;
107
108 BN_CTX_start(ctx);
109 if (!p1)
110 p1 = BN_CTX_get(ctx);
111
112 if (!p2)
113 p2 = BN_CTX_get(ctx);
114
115 t = BN_CTX_get(ctx);
116
117 p1p2 = BN_CTX_get(ctx);
118
119 pm1 = BN_CTX_get(ctx);
120
121 if (!bn_x931_derive_pi(p1, Xp1, ctx, cb))
122 goto err;
123
124 if (!bn_x931_derive_pi(p2, Xp2, ctx, cb))
125 goto err;
126
127 if (!BN_mul(p1p2, p1, p2, ctx))
128 goto err;
129
130 /* First set p to value of Rp */
131
132 if (!BN_mod_inverse(p, p2, p1, ctx))
133 goto err;
134
135 if (!BN_mul(p, p, p2, ctx))
136 goto err;
137
138 if (!BN_mod_inverse(t, p1, p2, ctx))
139 goto err;
140
141 if (!BN_mul(t, t, p1, ctx))
142 goto err;
143
144 if (!BN_sub(p, p, t))
145 goto err;
146
147 if (p->neg && !BN_add(p, p, p1p2))
148 goto err;
149
150 /* p now equals Rp */
151
152 if (!BN_mod_sub(p, p, Xp, p1p2, ctx))
153 goto err;
154
155 if (!BN_add(p, p, Xp))
156 goto err;
157
158 /* p now equals Yp0 */
159
160 for (;;)
161 {
162 int i = 1;
163 BN_GENCB_call(cb, 0, i++);
164 if (!BN_copy(pm1, p))
165 goto err;
166 if (!BN_sub_word(pm1, 1))
167 goto err;
168 if (!BN_gcd(t, pm1, e, ctx))
169 goto err;
170 if (BN_is_one(t)
171 /* X9.31 specifies 8 MR and 1 Lucas test or any prime test
172 * offering similar or better guarantees 50 MR is considerably
173 * better.
174 */
175 && BN_is_prime_fasttest_ex(p, 50, ctx, 1, cb))
176 break;
177 if (!BN_add(p, p, p1p2))
178 goto err;
179 }
180
181 BN_GENCB_call(cb, 3, 0);
182
183 ret = 1;
184
185 err:
186
187 BN_CTX_end(ctx);
188
189 return ret;
190 }
191
192/* Generate pair of paramters Xp, Xq for X9.31 prime generation.
193 * Note: nbits paramter is sum of number of bits in both.
194 */
195
196int BN_X931_generate_Xpq(BIGNUM *Xp, BIGNUM *Xq, int nbits, BN_CTX *ctx)
197 {
198 BIGNUM *t;
199 int i;
200 /* Number of bits for each prime is of the form
201 * 512+128s for s = 0, 1, ...
202 */
203 if ((nbits < 1024) || (nbits & 0xff))
204 return 0;
205 nbits >>= 1;
206 /* The random value Xp must be between sqrt(2) * 2^(nbits-1) and
207 * 2^nbits - 1. By setting the top two bits we ensure that the lower
208 * bound is exceeded.
209 */
210 if (!BN_rand(Xp, nbits, 1, 0))
211 return 0;
212
213 BN_CTX_start(ctx);
214 t = BN_CTX_get(ctx);
215
216 for (i = 0; i < 1000; i++)
217 {
218 if (!BN_rand(Xq, nbits, 1, 0))
219 return 0;
220 /* Check that |Xp - Xq| > 2^(nbits - 100) */
221 BN_sub(t, Xp, Xq);
222 if (BN_num_bits(t) > (nbits - 100))
223 break;
224 }
225
226 BN_CTX_end(ctx);
227
228 if (i < 1000)
229 return 1;
230
231 return 0;
232
233 }
234
235/* Generate primes using X9.31 algorithm. Of the values p, p1, p2, Xp1
236 * and Xp2 only 'p' needs to be non-NULL. If any of the others are not NULL
237 * the relevant parameter will be stored in it.
238 *
239 * Due to the fact that |Xp - Xq| > 2^(nbits - 100) must be satisfied Xp and Xq
240 * are generated using the previous function and supplied as input.
241 */
242
243int BN_X931_generate_prime_ex(BIGNUM *p, BIGNUM *p1, BIGNUM *p2,
244 BIGNUM *Xp1, BIGNUM *Xp2,
245 const BIGNUM *Xp,
246 const BIGNUM *e, BN_CTX *ctx,
247 BN_GENCB *cb)
248 {
249 int ret = 0;
250
251 BN_CTX_start(ctx);
252 if (!Xp1)
253 Xp1 = BN_CTX_get(ctx);
254 if (!Xp2)
255 Xp2 = BN_CTX_get(ctx);
256
257 if (!BN_rand(Xp1, 101, 0, 0))
258 goto error;
259 if (!BN_rand(Xp2, 101, 0, 0))
260 goto error;
261 if (!BN_X931_derive_prime_ex(p, p1, p2, Xp, Xp1, Xp2, e, ctx, cb))
262 goto error;
263
264 ret = 1;
265
266 error:
267 BN_CTX_end(ctx);
268
269 return ret;
270
271 }
272
diff --git a/src/lib/libcrypto/bn/bntest.c b/src/lib/libcrypto/bn/bntest.c
index cf190380f5..0cd99c5b4b 100644
--- a/src/lib/libcrypto/bn/bntest.c
+++ b/src/lib/libcrypto/bn/bntest.c
@@ -486,7 +486,7 @@ static void print_word(BIO *bp,BN_ULONG w)
486 return; 486 return;
487 } 487 }
488#endif 488#endif
489 BIO_printf(bp,"%lX",w); 489 BIO_printf(bp,BN_HEX_FMT1,w);
490 } 490 }
491 491
492int test_div_word(BIO *bp) 492int test_div_word(BIO *bp)
@@ -732,6 +732,8 @@ int test_mont(BIO *bp, BN_CTX *ctx)
732 BN_init(&n); 732 BN_init(&n);
733 733
734 mont=BN_MONT_CTX_new(); 734 mont=BN_MONT_CTX_new();
735 if (mont == NULL)
736 return 0;
735 737
736 BN_bntest_rand(&a,100,0,0); /**/ 738 BN_bntest_rand(&a,100,0,0); /**/
737 BN_bntest_rand(&b,100,0,0); /**/ 739 BN_bntest_rand(&b,100,0,0); /**/
@@ -1027,7 +1029,7 @@ int test_exp(BIO *bp, BN_CTX *ctx)
1027 BN_bntest_rand(a,20+i*5,0,0); /**/ 1029 BN_bntest_rand(a,20+i*5,0,0); /**/
1028 BN_bntest_rand(b,2+i,0,0); /**/ 1030 BN_bntest_rand(b,2+i,0,0); /**/
1029 1031
1030 if (!BN_exp(d,a,b,ctx)) 1032 if (BN_exp(d,a,b,ctx) <= 0)
1031 return(0); 1033 return(0);
1032 1034
1033 if (bp != NULL) 1035 if (bp != NULL)
@@ -1116,8 +1118,8 @@ int test_gf2m_mod(BIO *bp)
1116 { 1118 {
1117 BIGNUM *a,*b[2],*c,*d,*e; 1119 BIGNUM *a,*b[2],*c,*d,*e;
1118 int i, j, ret = 0; 1120 int i, j, ret = 0;
1119 unsigned int p0[] = {163,7,6,3,0}; 1121 int p0[] = {163,7,6,3,0,-1};
1120 unsigned int p1[] = {193,15,0}; 1122 int p1[] = {193,15,0,-1};
1121 1123
1122 a=BN_new(); 1124 a=BN_new();
1123 b[0]=BN_new(); 1125 b[0]=BN_new();
@@ -1174,8 +1176,8 @@ int test_gf2m_mod_mul(BIO *bp,BN_CTX *ctx)
1174 { 1176 {
1175 BIGNUM *a,*b[2],*c,*d,*e,*f,*g,*h; 1177 BIGNUM *a,*b[2],*c,*d,*e,*f,*g,*h;
1176 int i, j, ret = 0; 1178 int i, j, ret = 0;
1177 unsigned int p0[] = {163,7,6,3,0}; 1179 int p0[] = {163,7,6,3,0,-1};
1178 unsigned int p1[] = {193,15,0}; 1180 int p1[] = {193,15,0,-1};
1179 1181
1180 a=BN_new(); 1182 a=BN_new();
1181 b[0]=BN_new(); 1183 b[0]=BN_new();
@@ -1245,8 +1247,8 @@ int test_gf2m_mod_sqr(BIO *bp,BN_CTX *ctx)
1245 { 1247 {
1246 BIGNUM *a,*b[2],*c,*d; 1248 BIGNUM *a,*b[2],*c,*d;
1247 int i, j, ret = 0; 1249 int i, j, ret = 0;
1248 unsigned int p0[] = {163,7,6,3,0}; 1250 int p0[] = {163,7,6,3,0,-1};
1249 unsigned int p1[] = {193,15,0}; 1251 int p1[] = {193,15,0,-1};
1250 1252
1251 a=BN_new(); 1253 a=BN_new();
1252 b[0]=BN_new(); 1254 b[0]=BN_new();
@@ -1304,8 +1306,8 @@ int test_gf2m_mod_inv(BIO *bp,BN_CTX *ctx)
1304 { 1306 {
1305 BIGNUM *a,*b[2],*c,*d; 1307 BIGNUM *a,*b[2],*c,*d;
1306 int i, j, ret = 0; 1308 int i, j, ret = 0;
1307 unsigned int p0[] = {163,7,6,3,0}; 1309 int p0[] = {163,7,6,3,0,-1};
1308 unsigned int p1[] = {193,15,0}; 1310 int p1[] = {193,15,0,-1};
1309 1311
1310 a=BN_new(); 1312 a=BN_new();
1311 b[0]=BN_new(); 1313 b[0]=BN_new();
@@ -1359,8 +1361,8 @@ int test_gf2m_mod_div(BIO *bp,BN_CTX *ctx)
1359 { 1361 {
1360 BIGNUM *a,*b[2],*c,*d,*e,*f; 1362 BIGNUM *a,*b[2],*c,*d,*e,*f;
1361 int i, j, ret = 0; 1363 int i, j, ret = 0;
1362 unsigned int p0[] = {163,7,6,3,0}; 1364 int p0[] = {163,7,6,3,0,-1};
1363 unsigned int p1[] = {193,15,0}; 1365 int p1[] = {193,15,0,-1};
1364 1366
1365 a=BN_new(); 1367 a=BN_new();
1366 b[0]=BN_new(); 1368 b[0]=BN_new();
@@ -1422,8 +1424,8 @@ int test_gf2m_mod_exp(BIO *bp,BN_CTX *ctx)
1422 { 1424 {
1423 BIGNUM *a,*b[2],*c,*d,*e,*f; 1425 BIGNUM *a,*b[2],*c,*d,*e,*f;
1424 int i, j, ret = 0; 1426 int i, j, ret = 0;
1425 unsigned int p0[] = {163,7,6,3,0}; 1427 int p0[] = {163,7,6,3,0,-1};
1426 unsigned int p1[] = {193,15,0}; 1428 int p1[] = {193,15,0,-1};
1427 1429
1428 a=BN_new(); 1430 a=BN_new();
1429 b[0]=BN_new(); 1431 b[0]=BN_new();
@@ -1493,8 +1495,8 @@ int test_gf2m_mod_sqrt(BIO *bp,BN_CTX *ctx)
1493 { 1495 {
1494 BIGNUM *a,*b[2],*c,*d,*e,*f; 1496 BIGNUM *a,*b[2],*c,*d,*e,*f;
1495 int i, j, ret = 0; 1497 int i, j, ret = 0;
1496 unsigned int p0[] = {163,7,6,3,0}; 1498 int p0[] = {163,7,6,3,0,-1};
1497 unsigned int p1[] = {193,15,0}; 1499 int p1[] = {193,15,0,-1};
1498 1500
1499 a=BN_new(); 1501 a=BN_new();
1500 b[0]=BN_new(); 1502 b[0]=BN_new();
@@ -1552,8 +1554,8 @@ int test_gf2m_mod_solve_quad(BIO *bp,BN_CTX *ctx)
1552 { 1554 {
1553 BIGNUM *a,*b[2],*c,*d,*e; 1555 BIGNUM *a,*b[2],*c,*d,*e;
1554 int i, j, s = 0, t, ret = 0; 1556 int i, j, s = 0, t, ret = 0;
1555 unsigned int p0[] = {163,7,6,3,0}; 1557 int p0[] = {163,7,6,3,0,-1};
1556 unsigned int p1[] = {193,15,0}; 1558 int p1[] = {193,15,0,-1};
1557 1559
1558 a=BN_new(); 1560 a=BN_new();
1559 b[0]=BN_new(); 1561 b[0]=BN_new();
diff --git a/src/lib/libcrypto/bn/exptest.c b/src/lib/libcrypto/bn/exptest.c
index f598a07cf5..074a8e882a 100644
--- a/src/lib/libcrypto/bn/exptest.c
+++ b/src/lib/libcrypto/bn/exptest.c
@@ -163,7 +163,7 @@ int main(int argc, char *argv[])
163 { 163 {
164 if (BN_cmp(r_simple,r_mont) != 0) 164 if (BN_cmp(r_simple,r_mont) != 0)
165 printf("\nsimple and mont results differ\n"); 165 printf("\nsimple and mont results differ\n");
166 if (BN_cmp(r_simple,r_mont) != 0) 166 if (BN_cmp(r_simple,r_mont_const) != 0)
167 printf("\nsimple and mont const time results differ\n"); 167 printf("\nsimple and mont const time results differ\n");
168 if (BN_cmp(r_simple,r_recp) != 0) 168 if (BN_cmp(r_simple,r_recp) != 0)
169 printf("\nsimple and recp results differ\n"); 169 printf("\nsimple and recp results differ\n");
@@ -187,7 +187,7 @@ int main(int argc, char *argv[])
187 BN_free(b); 187 BN_free(b);
188 BN_free(m); 188 BN_free(m);
189 BN_CTX_free(ctx); 189 BN_CTX_free(ctx);
190 ERR_remove_state(0); 190 ERR_remove_thread_state(NULL);
191 CRYPTO_mem_leaks(out); 191 CRYPTO_mem_leaks(out);
192 BIO_free(out); 192 BIO_free(out);
193 printf(" done\n"); 193 printf(" done\n");
diff --git a/src/lib/libcrypto/buffer/Makefile.ssl b/src/lib/libcrypto/buffer/Makefile.ssl
deleted file mode 100644
index b131ca3078..0000000000
--- a/src/lib/libcrypto/buffer/Makefile.ssl
+++ /dev/null
@@ -1,94 +0,0 @@
1#
2# SSLeay/crypto/buffer/Makefile
3#
4
5DIR= buffer
6TOP= ../..
7CC= cc
8INCLUDES= -I.. -I$(TOP) -I../../include
9CFLAG=-g
10INSTALL_PREFIX=
11OPENSSLDIR= /usr/local/ssl
12INSTALLTOP=/usr/local/ssl
13MAKE= make -f Makefile.ssl
14MAKEDEPPROG= makedepend
15MAKEDEPEND= $(TOP)/util/domd $(TOP) -MD $(MAKEDEPPROG)
16MAKEFILE= Makefile.ssl
17AR= ar r
18
19CFLAGS= $(INCLUDES) $(CFLAG)
20
21GENERAL=Makefile
22TEST=
23APPS=
24
25LIB=$(TOP)/libcrypto.a
26LIBSRC= buffer.c buf_err.c
27LIBOBJ= buffer.o buf_err.o
28
29SRC= $(LIBSRC)
30
31EXHEADER= buffer.h
32HEADER= $(EXHEADER)
33
34ALL= $(GENERAL) $(SRC) $(HEADER)
35
36top:
37 (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all)
38
39all: lib
40
41lib: $(LIBOBJ)
42 $(AR) $(LIB) $(LIBOBJ)
43 $(RANLIB) $(LIB) || echo Never mind.
44 @touch lib
45
46files:
47 $(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO
48
49links:
50 @sh $(TOP)/util/point.sh Makefile.ssl Makefile
51 @$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER)
52 @$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST)
53 @$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS)
54
55install:
56 @for i in $(EXHEADER) ; \
57 do \
58 (cp $$i $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i; \
59 chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i ); \
60 done;
61
62tags:
63 ctags $(SRC)
64
65tests:
66
67lint:
68 lint -DLINT $(INCLUDES) $(SRC)>fluff
69
70depend:
71 $(MAKEDEPEND) -- $(CFLAG) $(INCLUDES) $(DEPFLAG) -- $(PROGS) $(LIBSRC)
72
73dclean:
74 $(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
75 mv -f Makefile.new $(MAKEFILE)
76
77clean:
78 rm -f *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff
79
80# DO NOT DELETE THIS LINE -- make depend depends on it.
81
82buf_err.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
83buf_err.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
84buf_err.o: ../../include/openssl/err.h ../../include/openssl/lhash.h
85buf_err.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
86buf_err.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
87buf_err.o: ../../include/openssl/symhacks.h buf_err.c
88buffer.o: ../../e_os.h ../../include/openssl/bio.h
89buffer.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
90buffer.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
91buffer.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
92buffer.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
93buffer.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
94buffer.o: ../cryptlib.h buffer.c
diff --git a/src/lib/libcrypto/buffer/buf_err.c b/src/lib/libcrypto/buffer/buf_err.c
index 3e25bbe879..8f1de6192b 100644
--- a/src/lib/libcrypto/buffer/buf_err.c
+++ b/src/lib/libcrypto/buffer/buf_err.c
@@ -1,6 +1,6 @@
1/* crypto/buffer/buf_err.c */ 1/* crypto/buffer/buf_err.c */
2/* ==================================================================== 2/* ====================================================================
3 * Copyright (c) 1999-2005 The OpenSSL Project. All rights reserved. 3 * Copyright (c) 1999-2006 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
diff --git a/src/lib/libcrypto/buffer/buf_str.c b/src/lib/libcrypto/buffer/buf_str.c
deleted file mode 100644
index 28dd1e401e..0000000000
--- a/src/lib/libcrypto/buffer/buf_str.c
+++ /dev/null
@@ -1,116 +0,0 @@
1/* crypto/buffer/buf_str.c */
2/* ====================================================================
3 * Copyright (c) 2007 The OpenSSL Project. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 *
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in
14 * the documentation and/or other materials provided with the
15 * distribution.
16 *
17 * 3. All advertising materials mentioning features or use of this
18 * software must display the following acknowledgment:
19 * "This product includes software developed by the OpenSSL Project
20 * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
21 *
22 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
23 * endorse or promote products derived from this software without
24 * prior written permission. For written permission, please contact
25 * licensing@OpenSSL.org.
26 *
27 * 5. Products derived from this software may not be called "OpenSSL"
28 * nor may "OpenSSL" appear in their names without prior written
29 * permission of the OpenSSL Project.
30 *
31 * 6. Redistributions of any form whatsoever must retain the following
32 * acknowledgment:
33 * "This product includes software developed by the OpenSSL Project
34 * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
35 *
36 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
37 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
38 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
39 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
40 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
41 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
42 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
43 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
44 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
45 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
46 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
47 * OF THE POSSIBILITY OF SUCH DAMAGE.
48 * ====================================================================
49 *
50 * This product includes cryptographic software written by Eric Young
51 * (eay@cryptsoft.com). This product includes software written by Tim
52 * Hudson (tjh@cryptsoft.com).
53 *
54 */
55
56#include <stdio.h>
57#include "cryptlib.h"
58#include <openssl/buffer.h>
59
60char *BUF_strdup(const char *str)
61 {
62 if (str == NULL) return(NULL);
63 return BUF_strndup(str, strlen(str));
64 }
65
66char *BUF_strndup(const char *str, size_t siz)
67 {
68 char *ret;
69
70 if (str == NULL) return(NULL);
71
72 ret=OPENSSL_malloc(siz+1);
73 if (ret == NULL)
74 {
75 BUFerr(BUF_F_BUF_STRNDUP,ERR_R_MALLOC_FAILURE);
76 return(NULL);
77 }
78 BUF_strlcpy(ret,str,siz+1);
79 return(ret);
80 }
81
82void *BUF_memdup(const void *data, size_t siz)
83 {
84 void *ret;
85
86 if (data == NULL) return(NULL);
87
88 ret=OPENSSL_malloc(siz);
89 if (ret == NULL)
90 {
91 BUFerr(BUF_F_BUF_MEMDUP,ERR_R_MALLOC_FAILURE);
92 return(NULL);
93 }
94 return memcpy(ret, data, siz);
95 }
96
97size_t BUF_strlcpy(char *dst, const char *src, size_t size)
98 {
99 size_t l = 0;
100 for(; size > 1 && *src; size--)
101 {
102 *dst++ = *src++;
103 l++;
104 }
105 if (size)
106 *dst = '\0';
107 return l + strlen(src);
108 }
109
110size_t BUF_strlcat(char *dst, const char *src, size_t size)
111 {
112 size_t l = 0;
113 for(; size > 0 && *dst; size--, dst++)
114 l++;
115 return l + BUF_strlcpy(dst, src, size);
116 }
diff --git a/src/lib/libcrypto/buffer/buffer.c b/src/lib/libcrypto/buffer/buffer.c
index b3e947771d..620ea8d536 100644
--- a/src/lib/libcrypto/buffer/buffer.c
+++ b/src/lib/libcrypto/buffer/buffer.c
@@ -89,10 +89,10 @@ void BUF_MEM_free(BUF_MEM *a)
89 OPENSSL_free(a); 89 OPENSSL_free(a);
90 } 90 }
91 91
92int BUF_MEM_grow(BUF_MEM *str, int len) 92int BUF_MEM_grow(BUF_MEM *str, size_t len)
93 { 93 {
94 char *ret; 94 char *ret;
95 unsigned int n; 95 size_t n;
96 96
97 if (str->length >= len) 97 if (str->length >= len)
98 { 98 {
@@ -125,10 +125,10 @@ 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) 128int BUF_MEM_grow_clean(BUF_MEM *str, size_t len)
129 { 129 {
130 char *ret; 130 char *ret;
131 unsigned int n; 131 size_t n;
132 132
133 if (str->length >= len) 133 if (str->length >= len)
134 { 134 {
@@ -161,3 +161,84 @@ int BUF_MEM_grow_clean(BUF_MEM *str, int len)
161 } 161 }
162 return(len); 162 return(len);
163 } 163 }
164
165char *BUF_strdup(const char *str)
166 {
167 if (str == NULL) return(NULL);
168 return BUF_strndup(str, strlen(str));
169 }
170
171char *BUF_strndup(const char *str, size_t siz)
172 {
173 char *ret;
174
175 if (str == NULL) return(NULL);
176
177 ret=OPENSSL_malloc(siz+1);
178 if (ret == NULL)
179 {
180 BUFerr(BUF_F_BUF_STRNDUP,ERR_R_MALLOC_FAILURE);
181 return(NULL);
182 }
183 BUF_strlcpy(ret,str,siz+1);
184 return(ret);
185 }
186
187void *BUF_memdup(const void *data, size_t siz)
188 {
189 void *ret;
190
191 if (data == NULL) return(NULL);
192
193 ret=OPENSSL_malloc(siz);
194 if (ret == NULL)
195 {
196 BUFerr(BUF_F_BUF_MEMDUP,ERR_R_MALLOC_FAILURE);
197 return(NULL);
198 }
199 return memcpy(ret, data, siz);
200 }
201
202size_t BUF_strlcpy(char *dst, const char *src, size_t size)
203 {
204 size_t l = 0;
205 for(; size > 1 && *src; size--)
206 {
207 *dst++ = *src++;
208 l++;
209 }
210 if (size)
211 *dst = '\0';
212 return l + strlen(src);
213 }
214
215size_t BUF_strlcat(char *dst, const char *src, size_t size)
216 {
217 size_t l = 0;
218 for(; size > 0 && *dst; size--, dst++)
219 l++;
220 return l + BUF_strlcpy(dst, src, size);
221 }
222
223void BUF_reverse(unsigned char *out, unsigned char *in, size_t size)
224 {
225 size_t i;
226 if (in)
227 {
228 out += size - 1;
229 for (i = 0; i < size; i++)
230 *in++ = *out--;
231 }
232 else
233 {
234 unsigned char *q;
235 char c;
236 q = out + size - 1;
237 for (i = 0; i < size/2; i++)
238 {
239 c = *q;
240 *q-- = *out;
241 *out++ = c;
242 }
243 }
244 }
diff --git a/src/lib/libcrypto/buffer/buffer.h b/src/lib/libcrypto/buffer/buffer.h
index 1db9607450..178e418282 100644
--- a/src/lib/libcrypto/buffer/buffer.h
+++ b/src/lib/libcrypto/buffer/buffer.h
@@ -76,18 +76,19 @@ extern "C" {
76 76
77struct buf_mem_st 77struct buf_mem_st
78 { 78 {
79 int length; /* current number of bytes */ 79 size_t length; /* current number of bytes */
80 char *data; 80 char *data;
81 int max; /* size of buffer */ 81 size_t max; /* size of buffer */
82 }; 82 };
83 83
84BUF_MEM *BUF_MEM_new(void); 84BUF_MEM *BUF_MEM_new(void);
85void BUF_MEM_free(BUF_MEM *a); 85void BUF_MEM_free(BUF_MEM *a);
86int BUF_MEM_grow(BUF_MEM *str, int len); 86int BUF_MEM_grow(BUF_MEM *str, size_t len);
87int BUF_MEM_grow_clean(BUF_MEM *str, int len); 87int BUF_MEM_grow_clean(BUF_MEM *str, size_t len);
88char * BUF_strdup(const char *str); 88char * BUF_strdup(const char *str);
89char * BUF_strndup(const char *str, size_t siz); 89char * BUF_strndup(const char *str, size_t siz);
90void * BUF_memdup(const void *data, size_t siz); 90void * BUF_memdup(const void *data, size_t siz);
91void BUF_reverse(unsigned char *out, unsigned char *in, size_t siz);
91 92
92/* safe string functions */ 93/* safe string functions */
93size_t BUF_strlcpy(char *dst,const char *src,size_t siz); 94size_t BUF_strlcpy(char *dst,const char *src,size_t siz);
diff --git a/src/lib/libcrypto/cast/Makefile.ssl b/src/lib/libcrypto/cast/Makefile.ssl
deleted file mode 100644
index 98393a37ba..0000000000
--- a/src/lib/libcrypto/cast/Makefile.ssl
+++ /dev/null
@@ -1,120 +0,0 @@
1#
2# SSLeay/crypto/cast/Makefile
3#
4
5DIR= cast
6TOP= ../..
7CC= cc
8CPP= $(CC) -E
9INCLUDES=
10CFLAG=-g
11INSTALL_PREFIX=
12OPENSSLDIR= /usr/local/ssl
13INSTALLTOP=/usr/local/ssl
14MAKE= make -f Makefile.ssl
15MAKEDEPPROG= makedepend
16MAKEDEPEND= $(TOP)/util/domd $(TOP) -MD $(MAKEDEPPROG)
17MAKEFILE= Makefile.ssl
18AR= ar r
19
20CAST_ENC=c_enc.o
21# or use
22#CAST_ENC=asm/cx86-elf.o
23#CAST_ENC=asm/cx86-out.o
24#CAST_ENC=asm/cx86-sol.o
25#CAST_ENC=asm/cx86bdsi.o
26
27CFLAGS= $(INCLUDES) $(CFLAG)
28ASFLAGS= $(INCLUDES) $(ASFLAG)
29
30GENERAL=Makefile
31TEST=casttest.c
32APPS=
33
34LIB=$(TOP)/libcrypto.a
35LIBSRC=c_skey.c c_ecb.c c_enc.c c_cfb64.c c_ofb64.c
36LIBOBJ=c_skey.o c_ecb.o $(CAST_ENC) c_cfb64.o c_ofb64.o
37
38SRC= $(LIBSRC)
39
40EXHEADER= cast.h
41HEADER= cast_s.h cast_lcl.h $(EXHEADER)
42
43ALL= $(GENERAL) $(SRC) $(HEADER)
44
45top:
46 (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all)
47
48all: lib
49
50lib: $(LIBOBJ)
51 $(AR) $(LIB) $(LIBOBJ)
52 $(RANLIB) $(LIB) || echo Never mind.
53 @touch lib
54
55# elf
56asm/cx86-elf.s: asm/cast-586.pl ../perlasm/x86asm.pl ../perlasm/cbc.pl
57 (cd asm; $(PERL) cast-586.pl elf $(CLAGS) $(PROCESSOR) > cx86-elf.s)
58
59# a.out
60asm/cx86-out.o: asm/cx86unix.cpp
61 $(CPP) -DOUT asm/cx86unix.cpp | as -o asm/cx86-out.o
62
63# bsdi
64asm/cx86bsdi.o: asm/cx86unix.cpp
65 $(CPP) -DBSDI asm/cx86unix.cpp | sed 's/ :/:/' | as -o asm/cx86bsdi.o
66
67asm/cx86unix.cpp: asm/cast-586.pl ../perlasm/x86asm.pl ../perlasm/cbc.pl
68 (cd asm; $(PERL) cast-586.pl cpp $(PROCESSOR) >cx86unix.cpp)
69
70files:
71 $(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO
72
73links:
74 @sh $(TOP)/util/point.sh Makefile.ssl Makefile
75 @$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER)
76 @$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST)
77 @$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS)
78
79install:
80 @for i in $(EXHEADER) ; \
81 do \
82 (cp $$i $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i; \
83 chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i ); \
84 done;
85
86tags:
87 ctags $(SRC)
88
89tests:
90
91lint:
92 lint -DLINT $(INCLUDES) $(SRC)>fluff
93
94depend:
95 $(MAKEDEPEND) -- $(CFLAG) $(INCLUDES) $(DEPFLAG) -- $(PROGS) $(LIBSRC)
96
97dclean:
98 $(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
99 mv -f Makefile.new $(MAKEFILE)
100
101clean:
102 rm -f asm/cx86unix.cpp asm/*-elf.* *.o asm/*.o *.obj lib tags core .pure .nfs* *.old *.bak fluff
103
104# DO NOT DELETE THIS LINE -- make depend depends on it.
105
106c_cfb64.o: ../../e_os.h ../../include/openssl/cast.h
107c_cfb64.o: ../../include/openssl/e_os2.h ../../include/openssl/opensslconf.h
108c_cfb64.o: c_cfb64.c cast_lcl.h
109c_ecb.o: ../../e_os.h ../../include/openssl/cast.h
110c_ecb.o: ../../include/openssl/e_os2.h ../../include/openssl/opensslconf.h
111c_ecb.o: ../../include/openssl/opensslv.h c_ecb.c cast_lcl.h
112c_enc.o: ../../e_os.h ../../include/openssl/cast.h
113c_enc.o: ../../include/openssl/e_os2.h ../../include/openssl/opensslconf.h
114c_enc.o: c_enc.c cast_lcl.h
115c_ofb64.o: ../../e_os.h ../../include/openssl/cast.h
116c_ofb64.o: ../../include/openssl/e_os2.h ../../include/openssl/opensslconf.h
117c_ofb64.o: c_ofb64.c cast_lcl.h
118c_skey.o: ../../e_os.h ../../include/openssl/cast.h
119c_skey.o: ../../include/openssl/e_os2.h ../../include/openssl/opensslconf.h
120c_skey.o: c_skey.c cast_lcl.h cast_s.h
diff --git a/src/lib/libcrypto/cast/asm/cast-586.pl b/src/lib/libcrypto/cast/asm/cast-586.pl
index 0ed55d1905..7a0083ecb8 100644
--- a/src/lib/libcrypto/cast/asm/cast-586.pl
+++ b/src/lib/libcrypto/cast/asm/cast-586.pl
@@ -3,7 +3,8 @@
3# define for pentium pro friendly version 3# define for pentium pro friendly version
4$ppro=1; 4$ppro=1;
5 5
6push(@INC,"perlasm","../../perlasm"); 6$0 =~ m/(.*[\/\\])[^\/\\]+$/; $dir=$1;
7push(@INC,"${dir}","${dir}../../perlasm");
7require "x86asm.pl"; 8require "x86asm.pl";
8require "cbc.pl"; 9require "cbc.pl";
9 10
diff --git a/src/lib/libcrypto/cast/c_cfb64.c b/src/lib/libcrypto/cast/c_cfb64.c
index 514c005c32..dcec13a201 100644
--- a/src/lib/libcrypto/cast/c_cfb64.c
+++ b/src/lib/libcrypto/cast/c_cfb64.c
@@ -65,7 +65,7 @@
65 */ 65 */
66 66
67void CAST_cfb64_encrypt(const unsigned char *in, unsigned char *out, 67void CAST_cfb64_encrypt(const unsigned char *in, unsigned char *out,
68 long length, CAST_KEY *schedule, unsigned char *ivec, 68 long length, const CAST_KEY *schedule, unsigned char *ivec,
69 int *num, int enc) 69 int *num, int enc)
70 { 70 {
71 register CAST_LONG v0,v1,t; 71 register CAST_LONG v0,v1,t;
@@ -119,4 +119,3 @@ void CAST_cfb64_encrypt(const unsigned char *in, unsigned char *out,
119 v0=v1=ti[0]=ti[1]=t=c=cc=0; 119 v0=v1=ti[0]=ti[1]=t=c=cc=0;
120 *num=n; 120 *num=n;
121 } 121 }
122
diff --git a/src/lib/libcrypto/cast/c_ecb.c b/src/lib/libcrypto/cast/c_ecb.c
index f2dc606226..b6a3b1fff9 100644
--- a/src/lib/libcrypto/cast/c_ecb.c
+++ b/src/lib/libcrypto/cast/c_ecb.c
@@ -63,7 +63,7 @@
63const char CAST_version[]="CAST" OPENSSL_VERSION_PTEXT; 63const char CAST_version[]="CAST" OPENSSL_VERSION_PTEXT;
64 64
65void CAST_ecb_encrypt(const unsigned char *in, unsigned char *out, 65void CAST_ecb_encrypt(const unsigned char *in, unsigned char *out,
66 CAST_KEY *ks, int enc) 66 const CAST_KEY *ks, int enc)
67 { 67 {
68 CAST_LONG l,d[2]; 68 CAST_LONG l,d[2];
69 69
@@ -77,4 +77,3 @@ void CAST_ecb_encrypt(const unsigned char *in, unsigned char *out,
77 l=d[1]; l2n(l,out); 77 l=d[1]; l2n(l,out);
78 l=d[0]=d[1]=0; 78 l=d[0]=d[1]=0;
79 } 79 }
80
diff --git a/src/lib/libcrypto/cast/c_enc.c b/src/lib/libcrypto/cast/c_enc.c
index e80f65b698..2ae54f5cfb 100644
--- a/src/lib/libcrypto/cast/c_enc.c
+++ b/src/lib/libcrypto/cast/c_enc.c
@@ -60,9 +60,10 @@
60#include "cast_lcl.h" 60#include "cast_lcl.h"
61 61
62#ifndef OPENBSD_CAST_ASM 62#ifndef OPENBSD_CAST_ASM
63void CAST_encrypt(CAST_LONG *data, CAST_KEY *key) 63void CAST_encrypt(CAST_LONG *data, const CAST_KEY *key)
64 { 64 {
65 register CAST_LONG l,r,*k,t; 65 register CAST_LONG l,r,t;
66 const register CAST_LONG *k;
66 67
67 k= &(key->data[0]); 68 k= &(key->data[0]);
68 l=data[0]; 69 l=data[0];
@@ -92,9 +93,10 @@ void CAST_encrypt(CAST_LONG *data, CAST_KEY *key)
92 data[0]=r&0xffffffffL; 93 data[0]=r&0xffffffffL;
93 } 94 }
94 95
95void CAST_decrypt(CAST_LONG *data, CAST_KEY *key) 96void CAST_decrypt(CAST_LONG *data, const CAST_KEY *key)
96 { 97 {
97 register CAST_LONG l,r,*k,t; 98 register CAST_LONG l,r,t;
99 const register CAST_LONG *k;
98 100
99 k= &(key->data[0]); 101 k= &(key->data[0]);
100 l=data[0]; 102 l=data[0];
@@ -126,7 +128,7 @@ void CAST_decrypt(CAST_LONG *data, CAST_KEY *key)
126#endif 128#endif
127 129
128void CAST_cbc_encrypt(const unsigned char *in, unsigned char *out, long length, 130void CAST_cbc_encrypt(const unsigned char *in, unsigned char *out, long length,
129 CAST_KEY *ks, unsigned char *iv, int enc) 131 const CAST_KEY *ks, unsigned char *iv, int enc)
130 { 132 {
131 register CAST_LONG tin0,tin1; 133 register CAST_LONG tin0,tin1;
132 register CAST_LONG tout0,tout1,xor0,xor1; 134 register CAST_LONG tout0,tout1,xor0,xor1;
@@ -206,4 +208,3 @@ void CAST_cbc_encrypt(const unsigned char *in, unsigned char *out, long length,
206 tin0=tin1=tout0=tout1=xor0=xor1=0; 208 tin0=tin1=tout0=tout1=xor0=xor1=0;
207 tin[0]=tin[1]=0; 209 tin[0]=tin[1]=0;
208 } 210 }
209
diff --git a/src/lib/libcrypto/cast/c_ofb64.c b/src/lib/libcrypto/cast/c_ofb64.c
index fd0469a62f..cb3222456c 100644
--- a/src/lib/libcrypto/cast/c_ofb64.c
+++ b/src/lib/libcrypto/cast/c_ofb64.c
@@ -64,7 +64,7 @@
64 * 64bit block we have used is contained in *num; 64 * 64bit block we have used is contained in *num;
65 */ 65 */
66void CAST_ofb64_encrypt(const unsigned char *in, unsigned char *out, 66void CAST_ofb64_encrypt(const unsigned char *in, unsigned char *out,
67 long length, CAST_KEY *schedule, unsigned char *ivec, 67 long length, const CAST_KEY *schedule, unsigned char *ivec,
68 int *num) 68 int *num)
69 { 69 {
70 register CAST_LONG v0,v1,t; 70 register CAST_LONG v0,v1,t;
@@ -108,4 +108,3 @@ void CAST_ofb64_encrypt(const unsigned char *in, unsigned char *out,
108 t=v0=v1=ti[0]=ti[1]=0; 108 t=v0=v1=ti[0]=ti[1]=0;
109 *num=n; 109 *num=n;
110 } 110 }
111
diff --git a/src/lib/libcrypto/cast/c_skey.c b/src/lib/libcrypto/cast/c_skey.c
index 68e690a60c..76e40005c9 100644
--- a/src/lib/libcrypto/cast/c_skey.c
+++ b/src/lib/libcrypto/cast/c_skey.c
@@ -57,11 +57,6 @@
57 */ 57 */
58 58
59#include <openssl/cast.h> 59#include <openssl/cast.h>
60#include <openssl/crypto.h>
61#ifdef OPENSSL_FIPS
62#include <openssl/fips.h>
63#endif
64
65#include "cast_lcl.h" 60#include "cast_lcl.h"
66#include "cast_s.h" 61#include "cast_s.h"
67 62
@@ -77,7 +72,7 @@
77#define S6 CAST_S_table6 72#define S6 CAST_S_table6
78#define S7 CAST_S_table7 73#define S7 CAST_S_table7
79 74
80FIPS_NON_FIPS_VCIPHER_Init(CAST) 75void CAST_set_key(CAST_KEY *key, int len, const unsigned char *data)
81 { 76 {
82 CAST_LONG x[16]; 77 CAST_LONG x[16];
83 CAST_LONG z[16]; 78 CAST_LONG z[16];
diff --git a/src/lib/libcrypto/cast/cast.h b/src/lib/libcrypto/cast/cast.h
index 1faf5806aa..1a264f8143 100644
--- a/src/lib/libcrypto/cast/cast.h
+++ b/src/lib/libcrypto/cast/cast.h
@@ -72,7 +72,7 @@ extern "C" {
72#define CAST_ENCRYPT 1 72#define CAST_ENCRYPT 1
73#define CAST_DECRYPT 0 73#define CAST_DECRYPT 0
74 74
75#define CAST_LONG unsigned long 75#define CAST_LONG unsigned int
76 76
77#define CAST_BLOCK 8 77#define CAST_BLOCK 8
78#define CAST_KEY_LENGTH 16 78#define CAST_KEY_LENGTH 16
@@ -83,21 +83,19 @@ typedef struct cast_key_st
83 int short_key; /* Use reduced rounds for short key */ 83 int short_key; /* Use reduced rounds for short key */
84 } CAST_KEY; 84 } CAST_KEY;
85 85
86#ifdef OPENSSL_FIPS 86
87void private_CAST_set_key(CAST_KEY *key, int len, const unsigned char *data);
88#endif
89void CAST_set_key(CAST_KEY *key, int len, const unsigned char *data); 87void CAST_set_key(CAST_KEY *key, int len, const unsigned char *data);
90void CAST_ecb_encrypt(const unsigned char *in,unsigned char *out,CAST_KEY *key, 88void CAST_ecb_encrypt(const unsigned char *in, unsigned char *out, const CAST_KEY *key,
91 int enc); 89 int enc);
92void CAST_encrypt(CAST_LONG *data,CAST_KEY *key); 90void CAST_encrypt(CAST_LONG *data, const CAST_KEY *key);
93void CAST_decrypt(CAST_LONG *data,CAST_KEY *key); 91void CAST_decrypt(CAST_LONG *data, const CAST_KEY *key);
94void CAST_cbc_encrypt(const unsigned char *in, unsigned char *out, long length, 92void CAST_cbc_encrypt(const unsigned char *in, unsigned char *out, long length,
95 CAST_KEY *ks, unsigned char *iv, int enc); 93 const CAST_KEY *ks, unsigned char *iv, int enc);
96void CAST_cfb64_encrypt(const unsigned char *in, unsigned char *out, 94void CAST_cfb64_encrypt(const unsigned char *in, unsigned char *out,
97 long length, CAST_KEY *schedule, unsigned char *ivec, 95 long length, const CAST_KEY *schedule, unsigned char *ivec,
98 int *num, int enc); 96 int *num, int enc);
99void CAST_ofb64_encrypt(const unsigned char *in, unsigned char *out, 97void CAST_ofb64_encrypt(const unsigned char *in, unsigned char *out,
100 long length, CAST_KEY *schedule, unsigned char *ivec, 98 long length, const CAST_KEY *schedule, unsigned char *ivec,
101 int *num); 99 int *num);
102 100
103#ifdef __cplusplus 101#ifdef __cplusplus
diff --git a/src/lib/libcrypto/cms/cms_smime.c b/src/lib/libcrypto/cms/cms_smime.c
index f35883aa22..4a799eb897 100644
--- a/src/lib/libcrypto/cms/cms_smime.c
+++ b/src/lib/libcrypto/cms/cms_smime.c
@@ -171,7 +171,7 @@ CMS_ContentInfo *CMS_data_create(BIO *in, unsigned int flags)
171 if (!cms) 171 if (!cms)
172 return NULL; 172 return NULL;
173 173
174 if (CMS_final(cms, in, NULL, flags)) 174 if ((flags & CMS_STREAM) || CMS_final(cms, in, NULL, flags))
175 return cms; 175 return cms;
176 176
177 CMS_ContentInfo_free(cms); 177 CMS_ContentInfo_free(cms);
@@ -214,10 +214,7 @@ CMS_ContentInfo *CMS_digest_create(BIO *in, const EVP_MD *md,
214 return NULL; 214 return NULL;
215 215
216 if(!(flags & CMS_DETACHED)) 216 if(!(flags & CMS_DETACHED))
217 {
218 flags &= ~CMS_STREAM;
219 CMS_set_detached(cms, 0); 217 CMS_set_detached(cms, 0);
220 }
221 218
222 if ((flags & CMS_STREAM) || CMS_final(cms, in, NULL, flags)) 219 if ((flags & CMS_STREAM) || CMS_final(cms, in, NULL, flags))
223 return cms; 220 return cms;
@@ -269,10 +266,7 @@ CMS_ContentInfo *CMS_EncryptedData_encrypt(BIO *in, const EVP_CIPHER *cipher,
269 return NULL; 266 return NULL;
270 267
271 if(!(flags & CMS_DETACHED)) 268 if(!(flags & CMS_DETACHED))
272 {
273 flags &= ~CMS_STREAM;
274 CMS_set_detached(cms, 0); 269 CMS_set_detached(cms, 0);
275 }
276 270
277 if ((flags & (CMS_STREAM|CMS_PARTIAL)) 271 if ((flags & (CMS_STREAM|CMS_PARTIAL))
278 || CMS_final(cms, in, NULL, flags)) 272 || CMS_final(cms, in, NULL, flags))
@@ -456,6 +450,7 @@ int CMS_verify_receipt(CMS_ContentInfo *rcms, CMS_ContentInfo *ocms,
456 X509_STORE *store, unsigned int flags) 450 X509_STORE *store, unsigned int flags)
457 { 451 {
458 int r; 452 int r;
453 flags &= ~(CMS_DETACHED|CMS_TEXT);
459 r = CMS_verify(rcms, certs, store, NULL, NULL, flags); 454 r = CMS_verify(rcms, certs, store, NULL, NULL, flags);
460 if (r <= 0) 455 if (r <= 0)
461 return r; 456 return r;
@@ -486,10 +481,7 @@ CMS_ContentInfo *CMS_sign(X509 *signcert, EVP_PKEY *pkey, STACK_OF(X509) *certs,
486 } 481 }
487 482
488 if(!(flags & CMS_DETACHED)) 483 if(!(flags & CMS_DETACHED))
489 {
490 flags &= ~CMS_STREAM;
491 CMS_set_detached(cms, 0); 484 CMS_set_detached(cms, 0);
492 }
493 485
494 if ((flags & (CMS_STREAM|CMS_PARTIAL)) 486 if ((flags & (CMS_STREAM|CMS_PARTIAL))
495 || CMS_final(cms, data, NULL, flags)) 487 || CMS_final(cms, data, NULL, flags))
@@ -517,7 +509,7 @@ CMS_ContentInfo *CMS_sign_receipt(CMS_SignerInfo *si,
517 BIO *rct_cont = NULL; 509 BIO *rct_cont = NULL;
518 int r = 0; 510 int r = 0;
519 511
520 flags &= ~CMS_STREAM; 512 flags &= ~(CMS_STREAM|CMS_TEXT);
521 /* Not really detached but avoids content being allocated */ 513 /* Not really detached but avoids content being allocated */
522 flags |= CMS_PARTIAL|CMS_BINARY|CMS_DETACHED; 514 flags |= CMS_PARTIAL|CMS_BINARY|CMS_DETACHED;
523 if (!pkey || !signcert) 515 if (!pkey || !signcert)
@@ -598,10 +590,7 @@ CMS_ContentInfo *CMS_encrypt(STACK_OF(X509) *certs, BIO *data,
598 } 590 }
599 591
600 if(!(flags & CMS_DETACHED)) 592 if(!(flags & CMS_DETACHED))
601 {
602 flags &= ~CMS_STREAM;
603 CMS_set_detached(cms, 0); 593 CMS_set_detached(cms, 0);
604 }
605 594
606 if ((flags & (CMS_STREAM|CMS_PARTIAL)) 595 if ((flags & (CMS_STREAM|CMS_PARTIAL))
607 || CMS_final(cms, data, NULL, flags)) 596 || CMS_final(cms, data, NULL, flags))
@@ -781,12 +770,9 @@ CMS_ContentInfo *CMS_compress(BIO *in, int comp_nid, unsigned int flags)
781 return NULL; 770 return NULL;
782 771
783 if(!(flags & CMS_DETACHED)) 772 if(!(flags & CMS_DETACHED))
784 {
785 flags &= ~CMS_STREAM;
786 CMS_set_detached(cms, 0); 773 CMS_set_detached(cms, 0);
787 }
788 774
789 if (CMS_final(cms, in, NULL, flags)) 775 if ((flags & CMS_STREAM) || CMS_final(cms, in, NULL, flags))
790 return cms; 776 return cms;
791 777
792 CMS_ContentInfo_free(cms); 778 CMS_ContentInfo_free(cms);
diff --git a/src/lib/libcrypto/comp/Makefile.ssl b/src/lib/libcrypto/comp/Makefile.ssl
deleted file mode 100644
index f70ba1b285..0000000000
--- a/src/lib/libcrypto/comp/Makefile.ssl
+++ /dev/null
@@ -1,114 +0,0 @@
1#
2# SSLeay/crypto/comp/Makefile
3#
4
5DIR= comp
6TOP= ../..
7CC= cc
8INCLUDES= -I.. -I$(TOP) -I../../include
9CFLAG=-g
10INSTALL_PREFIX=
11OPENSSLDIR= /usr/local/ssl
12INSTALLTOP=/usr/local/ssl
13MAKE= make -f Makefile.ssl
14MAKEDEPPROG= makedepend
15MAKEDEPEND= $(TOP)/util/domd $(TOP) -MD $(MAKEDEPPROG)
16MAKEFILE= Makefile.ssl
17AR= ar r
18
19CFLAGS= $(INCLUDES) $(CFLAG)
20
21GENERAL=Makefile
22TEST=
23APPS=
24
25LIB=$(TOP)/libcrypto.a
26LIBSRC= comp_lib.c comp_err.c \
27 c_rle.c c_zlib.c
28
29LIBOBJ= comp_lib.o comp_err.o \
30 c_rle.o c_zlib.o
31
32SRC= $(LIBSRC)
33
34EXHEADER= comp.h
35HEADER= $(EXHEADER)
36
37ALL= $(GENERAL) $(SRC) $(HEADER)
38
39top:
40 (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all)
41
42all: lib
43
44lib: $(LIBOBJ)
45 $(AR) $(LIB) $(LIBOBJ)
46 $(RANLIB) $(LIB) || echo Never mind.
47 @touch lib
48
49files:
50 $(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO
51
52links:
53 @sh $(TOP)/util/point.sh Makefile.ssl Makefile
54 @$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER)
55 @$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST)
56 @$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS)
57
58install:
59 @for i in $(EXHEADER) ; \
60 do \
61 (cp $$i $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i; \
62 chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i ); \
63 done;
64
65tags:
66 ctags $(SRC)
67
68tests:
69
70lint:
71 lint -DLINT $(INCLUDES) $(SRC)>fluff
72
73depend:
74 $(MAKEDEPEND) -- $(CFLAG) $(INCLUDES) $(DEPFLAG) -- $(LIBSRC)
75
76dclean:
77 $(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
78 mv -f Makefile.new $(MAKEFILE)
79
80clean:
81 rm -f *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff
82
83# DO NOT DELETE THIS LINE -- make depend depends on it.
84
85c_rle.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
86c_rle.o: ../../include/openssl/bn.h ../../include/openssl/comp.h
87c_rle.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
88c_rle.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
89c_rle.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
90c_rle.o: ../../include/openssl/ossl_typ.h ../../include/openssl/safestack.h
91c_rle.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h c_rle.c
92c_zlib.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
93c_zlib.o: ../../include/openssl/bn.h ../../include/openssl/comp.h
94c_zlib.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
95c_zlib.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
96c_zlib.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
97c_zlib.o: ../../include/openssl/ossl_typ.h ../../include/openssl/safestack.h
98c_zlib.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
99c_zlib.o: c_zlib.c
100comp_err.o: ../../include/openssl/bio.h ../../include/openssl/comp.h
101comp_err.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
102comp_err.o: ../../include/openssl/err.h ../../include/openssl/lhash.h
103comp_err.o: ../../include/openssl/opensslconf.h
104comp_err.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
105comp_err.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
106comp_err.o: comp_err.c
107comp_lib.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
108comp_lib.o: ../../include/openssl/bn.h ../../include/openssl/comp.h
109comp_lib.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
110comp_lib.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
111comp_lib.o: ../../include/openssl/opensslconf.h
112comp_lib.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
113comp_lib.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
114comp_lib.o: ../../include/openssl/symhacks.h comp_lib.c
diff --git a/src/lib/libcrypto/comp/c_zlib.c b/src/lib/libcrypto/comp/c_zlib.c
index 8df7792c50..8adf35f3fc 100644
--- a/src/lib/libcrypto/comp/c_zlib.c
+++ b/src/lib/libcrypto/comp/c_zlib.c
@@ -781,6 +781,7 @@ static long bio_zlib_ctrl(BIO *b, int cmd, long num, void *ptr)
781 default: 781 default:
782 ret = BIO_ctrl(b->next_bio, cmd, num, ptr); 782 ret = BIO_ctrl(b->next_bio, cmd, num, ptr);
783 break; 783 break;
784
784 } 785 }
785 786
786 return ret; 787 return ret;
diff --git a/src/lib/libcrypto/comp/comp_err.c b/src/lib/libcrypto/comp/comp_err.c
index 187d68b725..661c94c3a4 100644
--- a/src/lib/libcrypto/comp/comp_err.c
+++ b/src/lib/libcrypto/comp/comp_err.c
@@ -1,6 +1,6 @@
1/* crypto/comp/comp_err.c */ 1/* crypto/comp/comp_err.c */
2/* ==================================================================== 2/* ====================================================================
3 * Copyright (c) 1999-2008 The OpenSSL Project. All rights reserved. 3 * Copyright (c) 1999-2007 The OpenSSL Project. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
diff --git a/src/lib/libcrypto/conf/Makefile.ssl b/src/lib/libcrypto/conf/Makefile.ssl
deleted file mode 100644
index c5873bc6e7..0000000000
--- a/src/lib/libcrypto/conf/Makefile.ssl
+++ /dev/null
@@ -1,183 +0,0 @@
1#
2# SSLeay/crypto/conf/Makefile
3#
4
5DIR= conf
6TOP= ../..
7CC= cc
8INCLUDES= -I.. -I$(TOP) -I../../include
9CFLAG=-g
10INSTALL_PREFIX=
11OPENSSLDIR= /usr/local/ssl
12INSTALLTOP=/usr/local/ssl
13MAKE= make -f Makefile.ssl
14MAKEDEPPROG= makedepend
15MAKEDEPEND= $(TOP)/util/domd $(TOP) -MD $(MAKEDEPPROG)
16MAKEFILE= Makefile.ssl
17AR= ar r
18
19CFLAGS= $(INCLUDES) $(CFLAG)
20
21GENERAL=Makefile
22TEST=
23APPS=
24
25LIB=$(TOP)/libcrypto.a
26LIBSRC= conf_err.c conf_lib.c conf_api.c conf_def.c conf_mod.c \
27 conf_mall.c conf_sap.c
28
29LIBOBJ= conf_err.o conf_lib.o conf_api.o conf_def.o conf_mod.o \
30 conf_mall.o conf_sap.o
31
32SRC= $(LIBSRC)
33
34EXHEADER= conf.h conf_api.h
35HEADER= conf_def.h $(EXHEADER)
36
37ALL= $(GENERAL) $(SRC) $(HEADER)
38
39top:
40 (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all)
41
42all: lib
43
44lib: $(LIBOBJ)
45 $(AR) $(LIB) $(LIBOBJ)
46 $(RANLIB) $(LIB) || echo Never mind.
47 @touch lib
48
49files:
50 $(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO
51
52links:
53 @sh $(TOP)/util/point.sh Makefile.ssl Makefile
54 @$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER)
55 @$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST)
56 @$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS)
57
58install:
59 @for i in $(EXHEADER) ; \
60 do \
61 (cp $$i $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i; \
62 chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i ); \
63 done;
64
65tags:
66 ctags $(SRC)
67
68tests:
69
70lint:
71 lint -DLINT $(INCLUDES) $(SRC)>fluff
72
73depend:
74 $(MAKEDEPEND) -- $(CFLAG) $(INCLUDES) $(DEPFLAG) -- $(LIBSRC)
75
76dclean:
77 $(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
78 mv -f Makefile.new $(MAKEFILE)
79
80clean:
81 rm -f *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff
82
83# DO NOT DELETE THIS LINE -- make depend depends on it.
84
85conf_api.o: ../../e_os.h ../../include/openssl/bio.h
86conf_api.o: ../../include/openssl/conf.h ../../include/openssl/conf_api.h
87conf_api.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
88conf_api.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
89conf_api.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
90conf_api.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
91conf_api.o: conf_api.c
92conf_def.o: ../../e_os.h ../../include/openssl/bio.h
93conf_def.o: ../../include/openssl/buffer.h ../../include/openssl/conf.h
94conf_def.o: ../../include/openssl/conf_api.h ../../include/openssl/crypto.h
95conf_def.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
96conf_def.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
97conf_def.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
98conf_def.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
99conf_def.o: ../cryptlib.h conf_def.c conf_def.h
100conf_err.o: ../../include/openssl/bio.h ../../include/openssl/conf.h
101conf_err.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
102conf_err.o: ../../include/openssl/err.h ../../include/openssl/lhash.h
103conf_err.o: ../../include/openssl/opensslconf.h
104conf_err.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
105conf_err.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
106conf_err.o: conf_err.c
107conf_lib.o: ../../include/openssl/bio.h ../../include/openssl/conf.h
108conf_lib.o: ../../include/openssl/conf_api.h ../../include/openssl/crypto.h
109conf_lib.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
110conf_lib.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
111conf_lib.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
112conf_lib.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
113conf_lib.o: conf_lib.c
114conf_mall.o: ../../e_os.h ../../include/openssl/aes.h
115conf_mall.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
116conf_mall.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
117conf_mall.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
118conf_mall.o: ../../include/openssl/conf.h ../../include/openssl/crypto.h
119conf_mall.o: ../../include/openssl/des.h ../../include/openssl/des_old.h
120conf_mall.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
121conf_mall.o: ../../include/openssl/dso.h ../../include/openssl/e_os2.h
122conf_mall.o: ../../include/openssl/engine.h ../../include/openssl/err.h
123conf_mall.o: ../../include/openssl/evp.h ../../include/openssl/idea.h
124conf_mall.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h
125conf_mall.o: ../../include/openssl/md4.h ../../include/openssl/md5.h
126conf_mall.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h
127conf_mall.o: ../../include/openssl/objects.h
128conf_mall.o: ../../include/openssl/opensslconf.h
129conf_mall.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
130conf_mall.o: ../../include/openssl/pkcs7.h ../../include/openssl/rand.h
131conf_mall.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h
132conf_mall.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h
133conf_mall.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
134conf_mall.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
135conf_mall.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
136conf_mall.o: ../../include/openssl/ui_compat.h ../../include/openssl/x509.h
137conf_mall.o: ../../include/openssl/x509_vfy.h ../cryptlib.h conf_mall.c
138conf_mod.o: ../../e_os.h ../../include/openssl/aes.h
139conf_mod.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
140conf_mod.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
141conf_mod.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
142conf_mod.o: ../../include/openssl/conf.h ../../include/openssl/crypto.h
143conf_mod.o: ../../include/openssl/des.h ../../include/openssl/des_old.h
144conf_mod.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
145conf_mod.o: ../../include/openssl/dso.h ../../include/openssl/e_os2.h
146conf_mod.o: ../../include/openssl/err.h ../../include/openssl/evp.h
147conf_mod.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h
148conf_mod.o: ../../include/openssl/md2.h ../../include/openssl/md4.h
149conf_mod.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
150conf_mod.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
151conf_mod.o: ../../include/openssl/opensslconf.h
152conf_mod.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
153conf_mod.o: ../../include/openssl/pkcs7.h ../../include/openssl/rc2.h
154conf_mod.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
155conf_mod.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
156conf_mod.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
157conf_mod.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
158conf_mod.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
159conf_mod.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
160conf_mod.o: ../cryptlib.h conf_mod.c
161conf_sap.o: ../../e_os.h ../../include/openssl/aes.h
162conf_sap.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
163conf_sap.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
164conf_sap.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
165conf_sap.o: ../../include/openssl/conf.h ../../include/openssl/crypto.h
166conf_sap.o: ../../include/openssl/des.h ../../include/openssl/des_old.h
167conf_sap.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
168conf_sap.o: ../../include/openssl/dso.h ../../include/openssl/e_os2.h
169conf_sap.o: ../../include/openssl/engine.h ../../include/openssl/err.h
170conf_sap.o: ../../include/openssl/evp.h ../../include/openssl/idea.h
171conf_sap.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h
172conf_sap.o: ../../include/openssl/md4.h ../../include/openssl/md5.h
173conf_sap.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h
174conf_sap.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
175conf_sap.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
176conf_sap.o: ../../include/openssl/pkcs7.h ../../include/openssl/rand.h
177conf_sap.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h
178conf_sap.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h
179conf_sap.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
180conf_sap.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
181conf_sap.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
182conf_sap.o: ../../include/openssl/ui_compat.h ../../include/openssl/x509.h
183conf_sap.o: ../../include/openssl/x509_vfy.h ../cryptlib.h conf_sap.c
diff --git a/src/lib/libcrypto/conf/README b/src/lib/libcrypto/conf/README
index ca58d0240f..96e53b34ed 100644
--- a/src/lib/libcrypto/conf/README
+++ b/src/lib/libcrypto/conf/README
@@ -1,8 +1,3 @@
1WARNING WARNING WARNING!!!
2
3This stuff is experimental, may change radically or be deleted altogether
4before OpenSSL 0.9.7 release. You have been warned!
5
6Configuration modules. These are a set of modules which can perform 1Configuration modules. These are a set of modules which can perform
7various configuration functions. 2various configuration functions.
8 3
@@ -13,7 +8,7 @@ The routines read a configuration file set up like this:
13 8
14----- 9-----
15#default section 10#default section
16openssl_init=init_section 11openssl_conf=init_section
17 12
18[init_section] 13[init_section]
19 14
@@ -30,29 +25,27 @@ path=/some/path/to/some/dso.so
30other_stuff=other_value 25other_stuff=other_value
31---- 26----
32 27
33When this file is loaded a configuration module with the specified 28When this file is loaded a configuration module with the specified string
34string (module* in the above example) is looked up and its init 29(module* in the above example) is looked up and its init function called as:
35function called as:
36 30
37int conf_init_func(CONF_IMODULE *md, CONF *cnf); 31int conf_init_func(CONF_IMODULE *md, CONF *cnf);
38 32
39The function can then take whatever action is appropriate, for example 33The function can then take whatever action is appropriate, for example further
40further lookups based on the value. Multiple instances of the same 34lookups based on the value. Multiple instances of the same config module can be
41config module can be loaded. 35loaded.
42 36
43When the application closes down the modules are cleaned up by calling 37When the application closes down the modules are cleaned up by calling an
44an optional finish function: 38optional finish function:
45 39
46void conf_finish_func(CONF_IMODULE *md); 40void conf_finish_func(CONF_IMODULE *md);
47 41
48The finish functions are called in reverse order: that is the last module 42The finish functions are called in reverse order: that is the last module
49loaded is the first one cleaned up. 43loaded is the first one cleaned up.
50 44
51If no module exists with a given name then an attempt is made to load 45If no module exists with a given name then an attempt is made to load a DSO
52a DSO with the supplied name. This might mean that "module3" attempts 46with the supplied name. This might mean that "module3" attempts to load a DSO
53to load a DSO called libmodule3.so or module3.dll for example. An explicit 47called libmodule3.so or module3.dll for example. An explicit DSO name can be
54DSO name can be given by including a separate section as in the module4 example 48given by including a separate section as in the module4 example above.
55above.
56 49
57The DSO is expected to at least contain an initialization function: 50The DSO is expected to at least contain an initialization function:
58 51
@@ -64,15 +57,17 @@ void OPENSSL_finish(CONF_IMODULE *md);
64 57
65Static modules can also be added using, 58Static modules can also be added using,
66 59
67int CONF_module_add(char *name, dso_mod_init_func *ifunc, dso_mod_finish_func *ffunc); 60int CONF_module_add(char *name, dso_mod_init_func *ifunc, dso_mod_finish_func
61*ffunc);
68 62
69where "name" is the name in the configuration file this function corresponds to. 63where "name" is the name in the configuration file this function corresponds
64to.
70 65
71A set of builtin modules (currently only an ASN1 non functional test module) can be 66A set of builtin modules (currently only an ASN1 non functional test module)
72added by calling OPENSSL_load_builtin_modules(). 67can be added by calling OPENSSL_load_builtin_modules().
73 68
74The function OPENSSL_config() is intended as a simple configuration function that 69The function OPENSSL_config() is intended as a simple configuration function
75any application can call to perform various default configuration tasks. It uses the 70that any application can call to perform various default configuration tasks.
76file openssl.cnf in the usual locations. 71It uses the file openssl.cnf in the usual locations.
77 72
78 73
diff --git a/src/lib/libcrypto/conf/conf.h b/src/lib/libcrypto/conf/conf.h
index 8aa06bc5ec..c2199978a3 100644
--- a/src/lib/libcrypto/conf/conf.h
+++ b/src/lib/libcrypto/conf/conf.h
@@ -79,8 +79,7 @@ typedef struct
79 } CONF_VALUE; 79 } CONF_VALUE;
80 80
81DECLARE_STACK_OF(CONF_VALUE) 81DECLARE_STACK_OF(CONF_VALUE)
82DECLARE_STACK_OF(CONF_MODULE) 82DECLARE_LHASH_OF(CONF_VALUE);
83DECLARE_STACK_OF(CONF_IMODULE)
84 83
85struct conf_st; 84struct conf_st;
86struct conf_method_st; 85struct conf_method_st;
@@ -105,6 +104,9 @@ struct conf_method_st
105typedef struct conf_imodule_st CONF_IMODULE; 104typedef struct conf_imodule_st CONF_IMODULE;
106typedef struct conf_module_st CONF_MODULE; 105typedef struct conf_module_st CONF_MODULE;
107 106
107DECLARE_STACK_OF(CONF_MODULE)
108DECLARE_STACK_OF(CONF_IMODULE)
109
108/* DSO module function typedefs */ 110/* DSO module function typedefs */
109typedef int conf_init_func(CONF_IMODULE *md, const CONF *cnf); 111typedef int conf_init_func(CONF_IMODULE *md, const CONF *cnf);
110typedef void conf_finish_func(CONF_IMODULE *md); 112typedef void conf_finish_func(CONF_IMODULE *md);
@@ -117,18 +119,23 @@ typedef void conf_finish_func(CONF_IMODULE *md);
117#define CONF_MFLAGS_DEFAULT_SECTION 0x20 119#define CONF_MFLAGS_DEFAULT_SECTION 0x20
118 120
119int CONF_set_default_method(CONF_METHOD *meth); 121int CONF_set_default_method(CONF_METHOD *meth);
120void CONF_set_nconf(CONF *conf,LHASH *hash); 122void CONF_set_nconf(CONF *conf,LHASH_OF(CONF_VALUE) *hash);
121LHASH *CONF_load(LHASH *conf,const char *file,long *eline); 123LHASH_OF(CONF_VALUE) *CONF_load(LHASH_OF(CONF_VALUE) *conf,const char *file,
124 long *eline);
122#ifndef OPENSSL_NO_FP_API 125#ifndef OPENSSL_NO_FP_API
123LHASH *CONF_load_fp(LHASH *conf, FILE *fp,long *eline); 126LHASH_OF(CONF_VALUE) *CONF_load_fp(LHASH_OF(CONF_VALUE) *conf, FILE *fp,
127 long *eline);
124#endif 128#endif
125LHASH *CONF_load_bio(LHASH *conf, BIO *bp,long *eline); 129LHASH_OF(CONF_VALUE) *CONF_load_bio(LHASH_OF(CONF_VALUE) *conf, BIO *bp,long *eline);
126STACK_OF(CONF_VALUE) *CONF_get_section(LHASH *conf,const char *section); 130STACK_OF(CONF_VALUE) *CONF_get_section(LHASH_OF(CONF_VALUE) *conf,
127char *CONF_get_string(LHASH *conf,const char *group,const char *name); 131 const char *section);
128long CONF_get_number(LHASH *conf,const char *group,const char *name); 132char *CONF_get_string(LHASH_OF(CONF_VALUE) *conf,const char *group,
129void CONF_free(LHASH *conf); 133 const char *name);
130int CONF_dump_fp(LHASH *conf, FILE *out); 134long CONF_get_number(LHASH_OF(CONF_VALUE) *conf,const char *group,
131int CONF_dump_bio(LHASH *conf, BIO *out); 135 const char *name);
136void CONF_free(LHASH_OF(CONF_VALUE) *conf);
137int CONF_dump_fp(LHASH_OF(CONF_VALUE) *conf, FILE *out);
138int CONF_dump_bio(LHASH_OF(CONF_VALUE) *conf, BIO *out);
132 139
133void OPENSSL_config(const char *config_name); 140void OPENSSL_config(const char *config_name);
134void OPENSSL_no_config(void); 141void OPENSSL_no_config(void);
@@ -140,7 +147,7 @@ struct conf_st
140 { 147 {
141 CONF_METHOD *meth; 148 CONF_METHOD *meth;
142 void *meth_data; 149 void *meth_data;
143 LHASH *data; 150 LHASH_OF(CONF_VALUE) *data;
144 }; 151 };
145 152
146CONF *NCONF_new(CONF_METHOD *meth); 153CONF *NCONF_new(CONF_METHOD *meth);
@@ -214,6 +221,7 @@ void ERR_load_CONF_strings(void);
214#define CONF_F_CONF_LOAD_BIO 102 221#define CONF_F_CONF_LOAD_BIO 102
215#define CONF_F_CONF_LOAD_FP 103 222#define CONF_F_CONF_LOAD_FP 103
216#define CONF_F_CONF_MODULES_LOAD 116 223#define CONF_F_CONF_MODULES_LOAD 116
224#define CONF_F_CONF_PARSE_LIST 119
217#define CONF_F_DEF_LOAD 120 225#define CONF_F_DEF_LOAD 120
218#define CONF_F_DEF_LOAD_BIO 121 226#define CONF_F_DEF_LOAD_BIO 121
219#define CONF_F_MODULE_INIT 115 227#define CONF_F_MODULE_INIT 115
@@ -233,6 +241,7 @@ void ERR_load_CONF_strings(void);
233 241
234/* Reason codes. */ 242/* Reason codes. */
235#define CONF_R_ERROR_LOADING_DSO 110 243#define CONF_R_ERROR_LOADING_DSO 110
244#define CONF_R_LIST_CANNOT_BE_NULL 115
236#define CONF_R_MISSING_CLOSE_SQUARE_BRACKET 100 245#define CONF_R_MISSING_CLOSE_SQUARE_BRACKET 100
237#define CONF_R_MISSING_EQUAL_SIGN 101 246#define CONF_R_MISSING_EQUAL_SIGN 101
238#define CONF_R_MISSING_FINISH_FUNCTION 111 247#define CONF_R_MISSING_FINISH_FUNCTION 111
diff --git a/src/lib/libcrypto/conf/conf_api.c b/src/lib/libcrypto/conf/conf_api.c
index 909d72b4b8..22617e5fa1 100644
--- a/src/lib/libcrypto/conf/conf_api.c
+++ b/src/lib/libcrypto/conf/conf_api.c
@@ -69,16 +69,12 @@
69#include <openssl/conf_api.h> 69#include <openssl/conf_api.h>
70#include "e_os.h" 70#include "e_os.h"
71 71
72static void value_free_hash(CONF_VALUE *a, LHASH *conf); 72static void value_free_hash_doall_arg(CONF_VALUE *a,
73static void value_free_stack(CONF_VALUE *a,LHASH *conf); 73 LHASH_OF(CONF_VALUE) *conf);
74static IMPLEMENT_LHASH_DOALL_ARG_FN(value_free_hash, CONF_VALUE *, LHASH *) 74static void value_free_stack_doall(CONF_VALUE *a);
75static IMPLEMENT_LHASH_DOALL_ARG_FN(value_free_stack, CONF_VALUE *, LHASH *) 75static IMPLEMENT_LHASH_DOALL_ARG_FN(value_free_hash, CONF_VALUE,
76/* We don't use function pointer casting or wrapper functions - but cast each 76 LHASH_OF(CONF_VALUE))
77 * callback parameter inside the callback functions. */ 77static IMPLEMENT_LHASH_DOALL_FN(value_free_stack, CONF_VALUE)
78/* static unsigned long hash(CONF_VALUE *v); */
79static unsigned long hash(const void *v_void);
80/* static int cmp_conf(CONF_VALUE *a,CONF_VALUE *b); */
81static int cmp_conf(const void *a_void,const void *b_void);
82 78
83/* Up until OpenSSL 0.9.5a, this was get_section */ 79/* Up until OpenSSL 0.9.5a, this was get_section */
84CONF_VALUE *_CONF_get_section(const CONF *conf, const char *section) 80CONF_VALUE *_CONF_get_section(const CONF *conf, const char *section)
@@ -88,7 +84,7 @@ CONF_VALUE *_CONF_get_section(const CONF *conf, const char *section)
88 if ((conf == NULL) || (section == NULL)) return(NULL); 84 if ((conf == NULL) || (section == NULL)) return(NULL);
89 vv.name=NULL; 85 vv.name=NULL;
90 vv.section=(char *)section; 86 vv.section=(char *)section;
91 v=(CONF_VALUE *)lh_retrieve(conf->data,&vv); 87 v=lh_CONF_VALUE_retrieve(conf->data,&vv);
92 return(v); 88 return(v);
93 } 89 }
94 90
@@ -118,7 +114,7 @@ int _CONF_add_string(CONF *conf, CONF_VALUE *section, CONF_VALUE *value)
118 return 0; 114 return 0;
119 } 115 }
120 116
121 v = (CONF_VALUE *)lh_insert(conf->data, value); 117 v = lh_CONF_VALUE_insert(conf->data, value);
122 if (v != NULL) 118 if (v != NULL)
123 { 119 {
124 (void)sk_CONF_VALUE_delete_ptr(ts,v); 120 (void)sk_CONF_VALUE_delete_ptr(ts,v);
@@ -141,24 +137,24 @@ char *_CONF_get_string(const CONF *conf, const char *section, const char *name)
141 { 137 {
142 vv.name=(char *)name; 138 vv.name=(char *)name;
143 vv.section=(char *)section; 139 vv.section=(char *)section;
144 v=(CONF_VALUE *)lh_retrieve(conf->data,&vv); 140 v=lh_CONF_VALUE_retrieve(conf->data,&vv);
145 if (v != NULL) return(v->value); 141 if (v != NULL) return(v->value);
146 if (strcmp(section,"ENV") == 0) 142 if (strcmp(section,"ENV") == 0)
147 { 143 {
148 p=Getenv(name); 144 p=getenv(name);
149 if (p != NULL) return(p); 145 if (p != NULL) return(p);
150 } 146 }
151 } 147 }
152 vv.section="default"; 148 vv.section="default";
153 vv.name=(char *)name; 149 vv.name=(char *)name;
154 v=(CONF_VALUE *)lh_retrieve(conf->data,&vv); 150 v=lh_CONF_VALUE_retrieve(conf->data,&vv);
155 if (v != NULL) 151 if (v != NULL)
156 return(v->value); 152 return(v->value);
157 else 153 else
158 return(NULL); 154 return(NULL);
159 } 155 }
160 else 156 else
161 return(Getenv(name)); 157 return(getenv(name));
162 } 158 }
163 159
164#if 0 /* There's no way to provide error checking with this function, so 160#if 0 /* There's no way to provide error checking with this function, so
@@ -182,6 +178,34 @@ long _CONF_get_number(CONF *conf, char *section, char *name)
182 } 178 }
183#endif 179#endif
184 180
181static unsigned long conf_value_hash(const CONF_VALUE *v)
182 {
183 return (lh_strhash(v->section)<<2)^lh_strhash(v->name);
184 }
185static IMPLEMENT_LHASH_HASH_FN(conf_value, CONF_VALUE)
186
187static int conf_value_cmp(const CONF_VALUE *a, const CONF_VALUE *b)
188 {
189 int i;
190
191 if (a->section != b->section)
192 {
193 i=strcmp(a->section,b->section);
194 if (i) return(i);
195 }
196
197 if ((a->name != NULL) && (b->name != NULL))
198 {
199 i=strcmp(a->name,b->name);
200 return(i);
201 }
202 else if (a->name == b->name)
203 return(0);
204 else
205 return((a->name == NULL)?-1:1);
206 }
207static IMPLEMENT_LHASH_COMP_FN(conf_value, CONF_VALUE)
208
185int _CONF_new_data(CONF *conf) 209int _CONF_new_data(CONF *conf)
186 { 210 {
187 if (conf == NULL) 211 if (conf == NULL)
@@ -189,7 +213,7 @@ int _CONF_new_data(CONF *conf)
189 return 0; 213 return 0;
190 } 214 }
191 if (conf->data == NULL) 215 if (conf->data == NULL)
192 if ((conf->data = lh_new(hash, cmp_conf)) == NULL) 216 if ((conf->data = lh_CONF_VALUE_new()) == NULL)
193 { 217 {
194 return 0; 218 return 0;
195 } 219 }
@@ -200,105 +224,73 @@ void _CONF_free_data(CONF *conf)
200 { 224 {
201 if (conf == NULL || conf->data == NULL) return; 225 if (conf == NULL || conf->data == NULL) return;
202 226
203 conf->data->down_load=0; /* evil thing to make sure the 'OPENSSL_free()' 227 lh_CONF_VALUE_down_load(conf->data)=0; /* evil thing to make
204 * works as expected */ 228 * sure the 'OPENSSL_free()' works as
205 lh_doall_arg(conf->data, LHASH_DOALL_ARG_FN(value_free_hash), 229 * expected */
206 conf->data); 230 lh_CONF_VALUE_doall_arg(conf->data,
231 LHASH_DOALL_ARG_FN(value_free_hash),
232 LHASH_OF(CONF_VALUE), conf->data);
207 233
208 /* We now have only 'section' entries in the hash table. 234 /* We now have only 'section' entries in the hash table.
209 * Due to problems with */ 235 * Due to problems with */
210 236
211 lh_doall_arg(conf->data, LHASH_DOALL_ARG_FN(value_free_stack), 237 lh_CONF_VALUE_doall(conf->data, LHASH_DOALL_FN(value_free_stack));
212 conf->data); 238 lh_CONF_VALUE_free(conf->data);
213 lh_free(conf->data);
214 } 239 }
215 240
216static void value_free_hash(CONF_VALUE *a, LHASH *conf) 241static void value_free_hash_doall_arg(CONF_VALUE *a, LHASH_OF(CONF_VALUE) *conf)
217 { 242 {
218 if (a->name != NULL) 243 if (a->name != NULL)
219 { 244 (void)lh_CONF_VALUE_delete(conf,a);
220 a=(CONF_VALUE *)lh_delete(conf,a);
221 }
222 } 245 }
223 246
224static void value_free_stack(CONF_VALUE *a, LHASH *conf) 247static void value_free_stack_doall(CONF_VALUE *a)
225 { 248 {
226 CONF_VALUE *vv; 249 CONF_VALUE *vv;
227 STACK *sk; 250 STACK_OF(CONF_VALUE) *sk;
228 int i; 251 int i;
229 252
230 if (a->name != NULL) return; 253 if (a->name != NULL) return;
231 254
232 sk=(STACK *)a->value; 255 sk=(STACK_OF(CONF_VALUE) *)a->value;
233 for (i=sk_num(sk)-1; i>=0; i--) 256 for (i=sk_CONF_VALUE_num(sk)-1; i>=0; i--)
234 { 257 {
235 vv=(CONF_VALUE *)sk_value(sk,i); 258 vv=sk_CONF_VALUE_value(sk,i);
236 OPENSSL_free(vv->value); 259 OPENSSL_free(vv->value);
237 OPENSSL_free(vv->name); 260 OPENSSL_free(vv->name);
238 OPENSSL_free(vv); 261 OPENSSL_free(vv);
239 } 262 }
240 if (sk != NULL) sk_free(sk); 263 if (sk != NULL) sk_CONF_VALUE_free(sk);
241 OPENSSL_free(a->section); 264 OPENSSL_free(a->section);
242 OPENSSL_free(a); 265 OPENSSL_free(a);
243 } 266 }
244 267
245/* static unsigned long hash(CONF_VALUE *v) */
246static unsigned long hash(const void *v_void)
247 {
248 CONF_VALUE *v = (CONF_VALUE *)v_void;
249 return((lh_strhash(v->section)<<2)^lh_strhash(v->name));
250 }
251
252/* static int cmp_conf(CONF_VALUE *a, CONF_VALUE *b) */
253static int cmp_conf(const void *a_void,const void *b_void)
254 {
255 int i;
256 CONF_VALUE *a = (CONF_VALUE *)a_void;
257 CONF_VALUE *b = (CONF_VALUE *)b_void;
258
259 if (a->section != b->section)
260 {
261 i=strcmp(a->section,b->section);
262 if (i) return(i);
263 }
264
265 if ((a->name != NULL) && (b->name != NULL))
266 {
267 i=strcmp(a->name,b->name);
268 return(i);
269 }
270 else if (a->name == b->name)
271 return(0);
272 else
273 return((a->name == NULL)?-1:1);
274 }
275
276/* Up until OpenSSL 0.9.5a, this was new_section */ 268/* Up until OpenSSL 0.9.5a, this was new_section */
277CONF_VALUE *_CONF_new_section(CONF *conf, const char *section) 269CONF_VALUE *_CONF_new_section(CONF *conf, const char *section)
278 { 270 {
279 STACK *sk=NULL; 271 STACK_OF(CONF_VALUE) *sk=NULL;
280 int ok=0,i; 272 int ok=0,i;
281 CONF_VALUE *v=NULL,*vv; 273 CONF_VALUE *v=NULL,*vv;
282 274
283 if ((sk=sk_new_null()) == NULL) 275 if ((sk=sk_CONF_VALUE_new_null()) == NULL)
284 goto err; 276 goto err;
285 if ((v=(CONF_VALUE *)OPENSSL_malloc(sizeof(CONF_VALUE))) == NULL) 277 if ((v=OPENSSL_malloc(sizeof(CONF_VALUE))) == NULL)
286 goto err; 278 goto err;
287 i=strlen(section)+1; 279 i=strlen(section)+1;
288 if ((v->section=(char *)OPENSSL_malloc(i)) == NULL) 280 if ((v->section=OPENSSL_malloc(i)) == NULL)
289 goto err; 281 goto err;
290 282
291 memcpy(v->section,section,i); 283 memcpy(v->section,section,i);
292 v->name=NULL; 284 v->name=NULL;
293 v->value=(char *)sk; 285 v->value=(char *)sk;
294 286
295 vv=(CONF_VALUE *)lh_insert(conf->data,v); 287 vv=lh_CONF_VALUE_insert(conf->data,v);
296 assert(vv == NULL); 288 assert(vv == NULL);
297 ok=1; 289 ok=1;
298err: 290err:
299 if (!ok) 291 if (!ok)
300 { 292 {
301 if (sk != NULL) sk_free(sk); 293 if (sk != NULL) sk_CONF_VALUE_free(sk);
302 if (v != NULL) OPENSSL_free(v); 294 if (v != NULL) OPENSSL_free(v);
303 v=NULL; 295 v=NULL;
304 } 296 }
diff --git a/src/lib/libcrypto/conf/conf_def.c b/src/lib/libcrypto/conf/conf_def.c
index d8bce8732a..0b571b0394 100644
--- a/src/lib/libcrypto/conf/conf_def.c
+++ b/src/lib/libcrypto/conf/conf_def.c
@@ -129,7 +129,7 @@ static CONF *def_create(CONF_METHOD *meth)
129 { 129 {
130 CONF *ret; 130 CONF *ret;
131 131
132 ret = (CONF *)OPENSSL_malloc(sizeof(CONF) + sizeof(unsigned short *)); 132 ret = OPENSSL_malloc(sizeof(CONF) + sizeof(unsigned short *));
133 if (ret) 133 if (ret)
134 if (meth->init(ret) == 0) 134 if (meth->init(ret) == 0)
135 { 135 {
@@ -145,7 +145,7 @@ static int def_init_default(CONF *conf)
145 return 0; 145 return 0;
146 146
147 conf->meth = &default_method; 147 conf->meth = &default_method;
148 conf->meth_data = (void *)CONF_type_default; 148 conf->meth_data = CONF_type_default;
149 conf->data = NULL; 149 conf->data = NULL;
150 150
151 return 1; 151 return 1;
@@ -722,7 +722,7 @@ static char *scan_dquote(CONF *conf, char *p)
722 return(p); 722 return(p);
723 } 723 }
724 724
725static void dump_value(CONF_VALUE *a, BIO *out) 725static void dump_value_doall_arg(CONF_VALUE *a, BIO *out)
726 { 726 {
727 if (a->name) 727 if (a->name)
728 BIO_printf(out, "[%s] %s=%s\n", a->section, a->name, a->value); 728 BIO_printf(out, "[%s] %s=%s\n", a->section, a->name, a->value);
@@ -730,11 +730,12 @@ static void dump_value(CONF_VALUE *a, BIO *out)
730 BIO_printf(out, "[[%s]]\n", a->section); 730 BIO_printf(out, "[[%s]]\n", a->section);
731 } 731 }
732 732
733static IMPLEMENT_LHASH_DOALL_ARG_FN(dump_value, CONF_VALUE *, BIO *) 733static IMPLEMENT_LHASH_DOALL_ARG_FN(dump_value, CONF_VALUE, BIO)
734 734
735static int def_dump(const CONF *conf, BIO *out) 735static int def_dump(const CONF *conf, BIO *out)
736 { 736 {
737 lh_doall_arg(conf->data, LHASH_DOALL_ARG_FN(dump_value), out); 737 lh_CONF_VALUE_doall_arg(conf->data, LHASH_DOALL_ARG_FN(dump_value),
738 BIO, out);
738 return 1; 739 return 1;
739 } 740 }
740 741
diff --git a/src/lib/libcrypto/conf/conf_err.c b/src/lib/libcrypto/conf/conf_err.c
index a16a5e0bd4..25bb5dc9aa 100644
--- a/src/lib/libcrypto/conf/conf_err.c
+++ b/src/lib/libcrypto/conf/conf_err.c
@@ -1,6 +1,6 @@
1/* crypto/conf/conf_err.c */ 1/* crypto/conf/conf_err.c */
2/* ==================================================================== 2/* ====================================================================
3 * Copyright (c) 1999-2005 The OpenSSL Project. All rights reserved. 3 * Copyright (c) 1999-2007 The OpenSSL Project. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
@@ -75,6 +75,7 @@ static ERR_STRING_DATA CONF_str_functs[]=
75{ERR_FUNC(CONF_F_CONF_LOAD_BIO), "CONF_load_bio"}, 75{ERR_FUNC(CONF_F_CONF_LOAD_BIO), "CONF_load_bio"},
76{ERR_FUNC(CONF_F_CONF_LOAD_FP), "CONF_load_fp"}, 76{ERR_FUNC(CONF_F_CONF_LOAD_FP), "CONF_load_fp"},
77{ERR_FUNC(CONF_F_CONF_MODULES_LOAD), "CONF_modules_load"}, 77{ERR_FUNC(CONF_F_CONF_MODULES_LOAD), "CONF_modules_load"},
78{ERR_FUNC(CONF_F_CONF_PARSE_LIST), "CONF_parse_list"},
78{ERR_FUNC(CONF_F_DEF_LOAD), "DEF_LOAD"}, 79{ERR_FUNC(CONF_F_DEF_LOAD), "DEF_LOAD"},
79{ERR_FUNC(CONF_F_DEF_LOAD_BIO), "DEF_LOAD_BIO"}, 80{ERR_FUNC(CONF_F_DEF_LOAD_BIO), "DEF_LOAD_BIO"},
80{ERR_FUNC(CONF_F_MODULE_INIT), "MODULE_INIT"}, 81{ERR_FUNC(CONF_F_MODULE_INIT), "MODULE_INIT"},
@@ -97,6 +98,7 @@ static ERR_STRING_DATA CONF_str_functs[]=
97static ERR_STRING_DATA CONF_str_reasons[]= 98static ERR_STRING_DATA CONF_str_reasons[]=
98 { 99 {
99{ERR_REASON(CONF_R_ERROR_LOADING_DSO) ,"error loading dso"}, 100{ERR_REASON(CONF_R_ERROR_LOADING_DSO) ,"error loading dso"},
101{ERR_REASON(CONF_R_LIST_CANNOT_BE_NULL) ,"list cannot be null"},
100{ERR_REASON(CONF_R_MISSING_CLOSE_SQUARE_BRACKET),"missing close square bracket"}, 102{ERR_REASON(CONF_R_MISSING_CLOSE_SQUARE_BRACKET),"missing close square bracket"},
101{ERR_REASON(CONF_R_MISSING_EQUAL_SIGN) ,"missing equal sign"}, 103{ERR_REASON(CONF_R_MISSING_EQUAL_SIGN) ,"missing equal sign"},
102{ERR_REASON(CONF_R_MISSING_FINISH_FUNCTION),"missing finish function"}, 104{ERR_REASON(CONF_R_MISSING_FINISH_FUNCTION),"missing finish function"},
diff --git a/src/lib/libcrypto/conf/conf_lib.c b/src/lib/libcrypto/conf/conf_lib.c
index 2a3399d269..54046defca 100644
--- a/src/lib/libcrypto/conf/conf_lib.c
+++ b/src/lib/libcrypto/conf/conf_lib.c
@@ -69,7 +69,7 @@ static CONF_METHOD *default_CONF_method=NULL;
69 69
70/* Init a 'CONF' structure from an old LHASH */ 70/* Init a 'CONF' structure from an old LHASH */
71 71
72void CONF_set_nconf(CONF *conf, LHASH *hash) 72void CONF_set_nconf(CONF *conf, LHASH_OF(CONF_VALUE) *hash)
73 { 73 {
74 if (default_CONF_method == NULL) 74 if (default_CONF_method == NULL)
75 default_CONF_method = NCONF_default(); 75 default_CONF_method = NCONF_default();
@@ -87,9 +87,10 @@ int CONF_set_default_method(CONF_METHOD *meth)
87 return 1; 87 return 1;
88 } 88 }
89 89
90LHASH *CONF_load(LHASH *conf, const char *file, long *eline) 90LHASH_OF(CONF_VALUE) *CONF_load(LHASH_OF(CONF_VALUE) *conf, const char *file,
91 long *eline)
91 { 92 {
92 LHASH *ltmp; 93 LHASH_OF(CONF_VALUE) *ltmp;
93 BIO *in=NULL; 94 BIO *in=NULL;
94 95
95#ifdef OPENSSL_SYS_VMS 96#ifdef OPENSSL_SYS_VMS
@@ -110,10 +111,11 @@ LHASH *CONF_load(LHASH *conf, const char *file, long *eline)
110 } 111 }
111 112
112#ifndef OPENSSL_NO_FP_API 113#ifndef OPENSSL_NO_FP_API
113LHASH *CONF_load_fp(LHASH *conf, FILE *fp,long *eline) 114LHASH_OF(CONF_VALUE) *CONF_load_fp(LHASH_OF(CONF_VALUE) *conf, FILE *fp,
115 long *eline)
114 { 116 {
115 BIO *btmp; 117 BIO *btmp;
116 LHASH *ltmp; 118 LHASH_OF(CONF_VALUE) *ltmp;
117 if(!(btmp = BIO_new_fp(fp, BIO_NOCLOSE))) { 119 if(!(btmp = BIO_new_fp(fp, BIO_NOCLOSE))) {
118 CONFerr(CONF_F_CONF_LOAD_FP,ERR_R_BUF_LIB); 120 CONFerr(CONF_F_CONF_LOAD_FP,ERR_R_BUF_LIB);
119 return NULL; 121 return NULL;
@@ -124,7 +126,8 @@ LHASH *CONF_load_fp(LHASH *conf, FILE *fp,long *eline)
124 } 126 }
125#endif 127#endif
126 128
127LHASH *CONF_load_bio(LHASH *conf, BIO *bp,long *eline) 129LHASH_OF(CONF_VALUE) *CONF_load_bio(LHASH_OF(CONF_VALUE) *conf, BIO *bp,
130 long *eline)
128 { 131 {
129 CONF ctmp; 132 CONF ctmp;
130 int ret; 133 int ret;
@@ -137,7 +140,8 @@ LHASH *CONF_load_bio(LHASH *conf, BIO *bp,long *eline)
137 return NULL; 140 return NULL;
138 } 141 }
139 142
140STACK_OF(CONF_VALUE) *CONF_get_section(LHASH *conf,const char *section) 143STACK_OF(CONF_VALUE) *CONF_get_section(LHASH_OF(CONF_VALUE) *conf,
144 const char *section)
141 { 145 {
142 if (conf == NULL) 146 if (conf == NULL)
143 { 147 {
@@ -151,7 +155,8 @@ STACK_OF(CONF_VALUE) *CONF_get_section(LHASH *conf,const char *section)
151 } 155 }
152 } 156 }
153 157
154char *CONF_get_string(LHASH *conf,const char *group,const char *name) 158char *CONF_get_string(LHASH_OF(CONF_VALUE) *conf,const char *group,
159 const char *name)
155 { 160 {
156 if (conf == NULL) 161 if (conf == NULL)
157 { 162 {
@@ -165,7 +170,8 @@ char *CONF_get_string(LHASH *conf,const char *group,const char *name)
165 } 170 }
166 } 171 }
167 172
168long CONF_get_number(LHASH *conf,const char *group,const char *name) 173long CONF_get_number(LHASH_OF(CONF_VALUE) *conf,const char *group,
174 const char *name)
169 { 175 {
170 int status; 176 int status;
171 long result = 0; 177 long result = 0;
@@ -189,7 +195,7 @@ long CONF_get_number(LHASH *conf,const char *group,const char *name)
189 return result; 195 return result;
190 } 196 }
191 197
192void CONF_free(LHASH *conf) 198void CONF_free(LHASH_OF(CONF_VALUE) *conf)
193 { 199 {
194 CONF ctmp; 200 CONF ctmp;
195 CONF_set_nconf(&ctmp, conf); 201 CONF_set_nconf(&ctmp, conf);
@@ -197,7 +203,7 @@ void CONF_free(LHASH *conf)
197 } 203 }
198 204
199#ifndef OPENSSL_NO_FP_API 205#ifndef OPENSSL_NO_FP_API
200int CONF_dump_fp(LHASH *conf, FILE *out) 206int CONF_dump_fp(LHASH_OF(CONF_VALUE) *conf, FILE *out)
201 { 207 {
202 BIO *btmp; 208 BIO *btmp;
203 int ret; 209 int ret;
@@ -212,7 +218,7 @@ int CONF_dump_fp(LHASH *conf, FILE *out)
212 } 218 }
213#endif 219#endif
214 220
215int CONF_dump_bio(LHASH *conf, BIO *out) 221int CONF_dump_bio(LHASH_OF(CONF_VALUE) *conf, BIO *out)
216 { 222 {
217 CONF ctmp; 223 CONF ctmp;
218 CONF_set_nconf(&ctmp, conf); 224 CONF_set_nconf(&ctmp, conf);
diff --git a/src/lib/libcrypto/conf/conf_mall.c b/src/lib/libcrypto/conf/conf_mall.c
index 1cc1fd5534..c6f4cb2d55 100644
--- a/src/lib/libcrypto/conf/conf_mall.c
+++ b/src/lib/libcrypto/conf/conf_mall.c
@@ -63,7 +63,6 @@
63#include <openssl/dso.h> 63#include <openssl/dso.h>
64#include <openssl/x509.h> 64#include <openssl/x509.h>
65#include <openssl/asn1.h> 65#include <openssl/asn1.h>
66#include <openssl/evp.h>
67#ifndef OPENSSL_NO_ENGINE 66#ifndef OPENSSL_NO_ENGINE
68#include <openssl/engine.h> 67#include <openssl/engine.h>
69#endif 68#endif
@@ -77,6 +76,5 @@ void OPENSSL_load_builtin_modules(void)
77#ifndef OPENSSL_NO_ENGINE 76#ifndef OPENSSL_NO_ENGINE
78 ENGINE_add_conf_module(); 77 ENGINE_add_conf_module();
79#endif 78#endif
80 EVP_add_alg_module();
81 } 79 }
82 80
diff --git a/src/lib/libcrypto/conf/conf_mod.c b/src/lib/libcrypto/conf/conf_mod.c
index ee9c677d9b..df1642a0a5 100644
--- a/src/lib/libcrypto/conf/conf_mod.c
+++ b/src/lib/libcrypto/conf/conf_mod.c
@@ -582,8 +582,14 @@ int CONF_parse_list(const char *list_, int sep, int nospc,
582 { 582 {
583 int ret; 583 int ret;
584 const char *lstart, *tmpend, *p; 584 const char *lstart, *tmpend, *p;
585 lstart = list_;
586 585
586 if(list_ == NULL)
587 {
588 CONFerr(CONF_F_CONF_PARSE_LIST, CONF_R_LIST_CANNOT_BE_NULL);
589 return 0;
590 }
591
592 lstart = list_;
587 for(;;) 593 for(;;)
588 { 594 {
589 if (nospc) 595 if (nospc)
diff --git a/src/lib/libcrypto/cpt_err.c b/src/lib/libcrypto/cpt_err.c
index 9fd41fff8c..139b9284e4 100644
--- a/src/lib/libcrypto/cpt_err.c
+++ b/src/lib/libcrypto/cpt_err.c
@@ -1,6 +1,6 @@
1/* crypto/cpt_err.c */ 1/* crypto/cpt_err.c */
2/* ==================================================================== 2/* ====================================================================
3 * Copyright (c) 1999-2005 The OpenSSL Project. All rights reserved. 3 * Copyright (c) 1999-2006 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
diff --git a/src/lib/libcrypto/cryptlib.c b/src/lib/libcrypto/cryptlib.c
index 8f9e88e403..b4449b86d6 100644
--- a/src/lib/libcrypto/cryptlib.c
+++ b/src/lib/libcrypto/cryptlib.c
@@ -1,6 +1,6 @@
1/* crypto/cryptlib.c */ 1/* crypto/cryptlib.c */
2/* ==================================================================== 2/* ====================================================================
3 * Copyright (c) 1998-2003 The OpenSSL Project. All rights reserved. 3 * Copyright (c) 1998-2006 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
@@ -121,17 +121,279 @@
121static double SSLeay_MSVC5_hack=0.0; /* and for VC1.5 */ 121static double SSLeay_MSVC5_hack=0.0; /* and for VC1.5 */
122#endif 122#endif
123 123
124DECLARE_STACK_OF(CRYPTO_dynlock)
125
126/* real #defines in crypto.h, keep these upto date */
127static const char* const lock_names[CRYPTO_NUM_LOCKS] =
128 {
129 "<<ERROR>>",
130 "err",
131 "ex_data",
132 "x509",
133 "x509_info",
134 "x509_pkey",
135 "x509_crl",
136 "x509_req",
137 "dsa",
138 "rsa",
139 "evp_pkey",
140 "x509_store",
141 "ssl_ctx",
142 "ssl_cert",
143 "ssl_session",
144 "ssl_sess_cert",
145 "ssl",
146 "ssl_method",
147 "rand",
148 "rand2",
149 "debug_malloc",
150 "BIO",
151 "gethostbyname",
152 "getservbyname",
153 "readdir",
154 "RSA_blinding",
155 "dh",
156 "debug_malloc2",
157 "dso",
158 "dynlock",
159 "engine",
160 "ui",
161 "ecdsa",
162 "ec",
163 "ecdh",
164 "bn",
165 "ec_pre_comp",
166 "store",
167 "comp",
168 "fips",
169 "fips2",
170#if CRYPTO_NUM_LOCKS != 41
171# error "Inconsistency between crypto.h and cryptlib.c"
172#endif
173 };
174
175/* This is for applications to allocate new type names in the non-dynamic
176 array of lock names. These are numbered with positive numbers. */
177static STACK_OF(OPENSSL_STRING) *app_locks=NULL;
178
179/* For applications that want a more dynamic way of handling threads, the
180 following stack is used. These are externally numbered with negative
181 numbers. */
182static STACK_OF(CRYPTO_dynlock) *dyn_locks=NULL;
183
184
124static void (MS_FAR *locking_callback)(int mode,int type, 185static void (MS_FAR *locking_callback)(int mode,int type,
125 const char *file,int line)=NULL; 186 const char *file,int line)=0;
126static int (MS_FAR *add_lock_callback)(int *pointer,int amount, 187static int (MS_FAR *add_lock_callback)(int *pointer,int amount,
127 int type,const char *file,int line)=NULL; 188 int type,const char *file,int line)=0;
128static unsigned long (MS_FAR *id_callback)(void)=NULL; 189#ifndef OPENSSL_NO_DEPRECATED
190static unsigned long (MS_FAR *id_callback)(void)=0;
191#endif
192static void (MS_FAR *threadid_callback)(CRYPTO_THREADID *)=0;
193static struct CRYPTO_dynlock_value *(MS_FAR *dynlock_create_callback)
194 (const char *file,int line)=0;
195static void (MS_FAR *dynlock_lock_callback)(int mode,
196 struct CRYPTO_dynlock_value *l, const char *file,int line)=0;
197static void (MS_FAR *dynlock_destroy_callback)(struct CRYPTO_dynlock_value *l,
198 const char *file,int line)=0;
199
200int CRYPTO_get_new_lockid(char *name)
201 {
202 char *str;
203 int i;
204
205#if defined(OPENSSL_SYS_WIN32) || defined(OPENSSL_SYS_WIN16)
206 /* A hack to make Visual C++ 5.0 work correctly when linking as
207 * a DLL using /MT. Without this, the application cannot use
208 * any floating point printf's.
209 * It also seems to be needed for Visual C 1.5 (win16) */
210 SSLeay_MSVC5_hack=(double)name[0]*(double)name[1];
211#endif
212
213 if ((app_locks == NULL) && ((app_locks=sk_OPENSSL_STRING_new_null()) == NULL))
214 {
215 CRYPTOerr(CRYPTO_F_CRYPTO_GET_NEW_LOCKID,ERR_R_MALLOC_FAILURE);
216 return(0);
217 }
218 if ((str=BUF_strdup(name)) == NULL)
219 {
220 CRYPTOerr(CRYPTO_F_CRYPTO_GET_NEW_LOCKID,ERR_R_MALLOC_FAILURE);
221 return(0);
222 }
223 i=sk_OPENSSL_STRING_push(app_locks,str);
224 if (!i)
225 OPENSSL_free(str);
226 else
227 i+=CRYPTO_NUM_LOCKS; /* gap of one :-) */
228 return(i);
229 }
129 230
130int CRYPTO_num_locks(void) 231int CRYPTO_num_locks(void)
131 { 232 {
132 return CRYPTO_NUM_LOCKS; 233 return CRYPTO_NUM_LOCKS;
133 } 234 }
134 235
236int CRYPTO_get_new_dynlockid(void)
237 {
238 int i = 0;
239 CRYPTO_dynlock *pointer = NULL;
240
241 if (dynlock_create_callback == NULL)
242 {
243 CRYPTOerr(CRYPTO_F_CRYPTO_GET_NEW_DYNLOCKID,CRYPTO_R_NO_DYNLOCK_CREATE_CALLBACK);
244 return(0);
245 }
246 CRYPTO_w_lock(CRYPTO_LOCK_DYNLOCK);
247 if ((dyn_locks == NULL)
248 && ((dyn_locks=sk_CRYPTO_dynlock_new_null()) == NULL))
249 {
250 CRYPTO_w_unlock(CRYPTO_LOCK_DYNLOCK);
251 CRYPTOerr(CRYPTO_F_CRYPTO_GET_NEW_DYNLOCKID,ERR_R_MALLOC_FAILURE);
252 return(0);
253 }
254 CRYPTO_w_unlock(CRYPTO_LOCK_DYNLOCK);
255
256 pointer = (CRYPTO_dynlock *)OPENSSL_malloc(sizeof(CRYPTO_dynlock));
257 if (pointer == NULL)
258 {
259 CRYPTOerr(CRYPTO_F_CRYPTO_GET_NEW_DYNLOCKID,ERR_R_MALLOC_FAILURE);
260 return(0);
261 }
262 pointer->references = 1;
263 pointer->data = dynlock_create_callback(__FILE__,__LINE__);
264 if (pointer->data == NULL)
265 {
266 OPENSSL_free(pointer);
267 CRYPTOerr(CRYPTO_F_CRYPTO_GET_NEW_DYNLOCKID,ERR_R_MALLOC_FAILURE);
268 return(0);
269 }
270
271 CRYPTO_w_lock(CRYPTO_LOCK_DYNLOCK);
272 /* First, try to find an existing empty slot */
273 i=sk_CRYPTO_dynlock_find(dyn_locks,NULL);
274 /* If there was none, push, thereby creating a new one */
275 if (i == -1)
276 /* Since sk_push() returns the number of items on the
277 stack, not the location of the pushed item, we need
278 to transform the returned number into a position,
279 by decreasing it. */
280 i=sk_CRYPTO_dynlock_push(dyn_locks,pointer) - 1;
281 else
282 /* If we found a place with a NULL pointer, put our pointer
283 in it. */
284 (void)sk_CRYPTO_dynlock_set(dyn_locks,i,pointer);
285 CRYPTO_w_unlock(CRYPTO_LOCK_DYNLOCK);
286
287 if (i == -1)
288 {
289 dynlock_destroy_callback(pointer->data,__FILE__,__LINE__);
290 OPENSSL_free(pointer);
291 }
292 else
293 i += 1; /* to avoid 0 */
294 return -i;
295 }
296
297void CRYPTO_destroy_dynlockid(int i)
298 {
299 CRYPTO_dynlock *pointer = NULL;
300 if (i)
301 i = -i-1;
302 if (dynlock_destroy_callback == NULL)
303 return;
304
305 CRYPTO_w_lock(CRYPTO_LOCK_DYNLOCK);
306
307 if (dyn_locks == NULL || i >= sk_CRYPTO_dynlock_num(dyn_locks))
308 {
309 CRYPTO_w_unlock(CRYPTO_LOCK_DYNLOCK);
310 return;
311 }
312 pointer = sk_CRYPTO_dynlock_value(dyn_locks, i);
313 if (pointer != NULL)
314 {
315 --pointer->references;
316#ifdef REF_CHECK
317 if (pointer->references < 0)
318 {
319 fprintf(stderr,"CRYPTO_destroy_dynlockid, bad reference count\n");
320 abort();
321 }
322 else
323#endif
324 if (pointer->references <= 0)
325 {
326 (void)sk_CRYPTO_dynlock_set(dyn_locks, i, NULL);
327 }
328 else
329 pointer = NULL;
330 }
331 CRYPTO_w_unlock(CRYPTO_LOCK_DYNLOCK);
332
333 if (pointer)
334 {
335 dynlock_destroy_callback(pointer->data,__FILE__,__LINE__);
336 OPENSSL_free(pointer);
337 }
338 }
339
340struct CRYPTO_dynlock_value *CRYPTO_get_dynlock_value(int i)
341 {
342 CRYPTO_dynlock *pointer = NULL;
343 if (i)
344 i = -i-1;
345
346 CRYPTO_w_lock(CRYPTO_LOCK_DYNLOCK);
347
348 if (dyn_locks != NULL && i < sk_CRYPTO_dynlock_num(dyn_locks))
349 pointer = sk_CRYPTO_dynlock_value(dyn_locks, i);
350 if (pointer)
351 pointer->references++;
352
353 CRYPTO_w_unlock(CRYPTO_LOCK_DYNLOCK);
354
355 if (pointer)
356 return pointer->data;
357 return NULL;
358 }
359
360struct CRYPTO_dynlock_value *(*CRYPTO_get_dynlock_create_callback(void))
361 (const char *file,int line)
362 {
363 return(dynlock_create_callback);
364 }
365
366void (*CRYPTO_get_dynlock_lock_callback(void))(int mode,
367 struct CRYPTO_dynlock_value *l, const char *file,int line)
368 {
369 return(dynlock_lock_callback);
370 }
371
372void (*CRYPTO_get_dynlock_destroy_callback(void))
373 (struct CRYPTO_dynlock_value *l, const char *file,int line)
374 {
375 return(dynlock_destroy_callback);
376 }
377
378void CRYPTO_set_dynlock_create_callback(struct CRYPTO_dynlock_value *(*func)
379 (const char *file, int line))
380 {
381 dynlock_create_callback=func;
382 }
383
384void CRYPTO_set_dynlock_lock_callback(void (*func)(int mode,
385 struct CRYPTO_dynlock_value *l, const char *file, int line))
386 {
387 dynlock_lock_callback=func;
388 }
389
390void CRYPTO_set_dynlock_destroy_callback(void (*func)
391 (struct CRYPTO_dynlock_value *l, const char *file, int line))
392 {
393 dynlock_destroy_callback=func;
394 }
395
396
135void (*CRYPTO_get_locking_callback(void))(int mode,int type,const char *file, 397void (*CRYPTO_get_locking_callback(void))(int mode,int type,const char *file,
136 int line) 398 int line)
137 { 399 {
@@ -156,6 +418,108 @@ void CRYPTO_set_add_lock_callback(int (*func)(int *num,int mount,int type,
156 add_lock_callback=func; 418 add_lock_callback=func;
157 } 419 }
158 420
421/* the memset() here and in set_pointer() seem overkill, but for the sake of
422 * CRYPTO_THREADID_cmp() this avoids any platform silliness that might cause two
423 * "equal" THREADID structs to not be memcmp()-identical. */
424void CRYPTO_THREADID_set_numeric(CRYPTO_THREADID *id, unsigned long val)
425 {
426 memset(id, 0, sizeof(*id));
427 id->val = val;
428 }
429
430static const unsigned char hash_coeffs[] = { 3, 5, 7, 11, 13, 17, 19, 23 };
431void CRYPTO_THREADID_set_pointer(CRYPTO_THREADID *id, void *ptr)
432 {
433 unsigned char *dest = (void *)&id->val;
434 unsigned int accum = 0;
435 unsigned char dnum = sizeof(id->val);
436
437 memset(id, 0, sizeof(*id));
438 id->ptr = ptr;
439 if (sizeof(id->val) >= sizeof(id->ptr))
440 {
441 /* 'ptr' can be embedded in 'val' without loss of uniqueness */
442 id->val = (unsigned long)id->ptr;
443 return;
444 }
445 /* hash ptr ==> val. Each byte of 'val' gets the mod-256 total of a
446 * linear function over the bytes in 'ptr', the co-efficients of which
447 * are a sequence of low-primes (hash_coeffs is an 8-element cycle) -
448 * the starting prime for the sequence varies for each byte of 'val'
449 * (unique polynomials unless pointers are >64-bit). For added spice,
450 * the totals accumulate rather than restarting from zero, and the index
451 * of the 'val' byte is added each time (position dependence). If I was
452 * a black-belt, I'd scan big-endian pointers in reverse to give
453 * low-order bits more play, but this isn't crypto and I'd prefer nobody
454 * mistake it as such. Plus I'm lazy. */
455 while (dnum--)
456 {
457 const unsigned char *src = (void *)&id->ptr;
458 unsigned char snum = sizeof(id->ptr);
459 while (snum--)
460 accum += *(src++) * hash_coeffs[(snum + dnum) & 7];
461 accum += dnum;
462 *(dest++) = accum & 255;
463 }
464 }
465
466int CRYPTO_THREADID_set_callback(void (*func)(CRYPTO_THREADID *))
467 {
468 if (threadid_callback)
469 return 0;
470 threadid_callback = func;
471 return 1;
472 }
473
474void (*CRYPTO_THREADID_get_callback(void))(CRYPTO_THREADID *)
475 {
476 return threadid_callback;
477 }
478
479void CRYPTO_THREADID_current(CRYPTO_THREADID *id)
480 {
481 if (threadid_callback)
482 {
483 threadid_callback(id);
484 return;
485 }
486#ifndef OPENSSL_NO_DEPRECATED
487 /* If the deprecated callback was set, fall back to that */
488 if (id_callback)
489 {
490 CRYPTO_THREADID_set_numeric(id, id_callback());
491 return;
492 }
493#endif
494 /* Else pick a backup */
495#ifdef OPENSSL_SYS_WIN16
496 CRYPTO_THREADID_set_numeric(id, (unsigned long)GetCurrentTask());
497#elif defined(OPENSSL_SYS_WIN32)
498 CRYPTO_THREADID_set_numeric(id, (unsigned long)GetCurrentThreadId());
499#elif defined(OPENSSL_SYS_BEOS)
500 CRYPTO_THREADID_set_numeric(id, (unsigned long)find_thread(NULL));
501#else
502 /* For everything else, default to using the address of 'errno' */
503 CRYPTO_THREADID_set_pointer(id, &errno);
504#endif
505 }
506
507int CRYPTO_THREADID_cmp(const CRYPTO_THREADID *a, const CRYPTO_THREADID *b)
508 {
509 return memcmp(a, b, sizeof(*a));
510 }
511
512void CRYPTO_THREADID_cpy(CRYPTO_THREADID *dest, const CRYPTO_THREADID *src)
513 {
514 memcpy(dest, src, sizeof(*src));
515 }
516
517unsigned long CRYPTO_THREADID_hash(const CRYPTO_THREADID *id)
518 {
519 return id->val;
520 }
521
522#ifndef OPENSSL_NO_DEPRECATED
159unsigned long (*CRYPTO_get_id_callback(void))(void) 523unsigned long (*CRYPTO_get_id_callback(void))(void)
160 { 524 {
161 return(id_callback); 525 return(id_callback);
@@ -178,6 +542,8 @@ unsigned long CRYPTO_thread_id(void)
178 ret=(unsigned long)GetCurrentThreadId(); 542 ret=(unsigned long)GetCurrentThreadId();
179#elif defined(GETPID_IS_MEANINGLESS) 543#elif defined(GETPID_IS_MEANINGLESS)
180 ret=1L; 544 ret=1L;
545#elif defined(OPENSSL_SYS_BEOS)
546 ret=(unsigned long)find_thread(NULL);
181#else 547#else
182 ret=(unsigned long)getpid(); 548 ret=(unsigned long)getpid();
183#endif 549#endif
@@ -186,19 +552,13 @@ unsigned long CRYPTO_thread_id(void)
186 ret=id_callback(); 552 ret=id_callback();
187 return(ret); 553 return(ret);
188 } 554 }
189 555#endif
190static void (*do_dynlock_cb)(int mode, int type, const char *file, int line);
191
192void int_CRYPTO_set_do_dynlock_callback(
193 void (*dyn_cb)(int mode, int type, const char *file, int line))
194 {
195 do_dynlock_cb = dyn_cb;
196 }
197 556
198void CRYPTO_lock(int mode, int type, const char *file, int line) 557void CRYPTO_lock(int mode, int type, const char *file, int line)
199 { 558 {
200#ifdef LOCK_DEBUG 559#ifdef LOCK_DEBUG
201 { 560 {
561 CRYPTO_THREADID id;
202 char *rw_text,*operation_text; 562 char *rw_text,*operation_text;
203 563
204 if (mode & CRYPTO_LOCK) 564 if (mode & CRYPTO_LOCK)
@@ -215,15 +575,25 @@ void CRYPTO_lock(int mode, int type, const char *file, int line)
215 else 575 else
216 rw_text="ERROR"; 576 rw_text="ERROR";
217 577
578 CRYPTO_THREADID_current(&id);
218 fprintf(stderr,"lock:%08lx:(%s)%s %-18s %s:%d\n", 579 fprintf(stderr,"lock:%08lx:(%s)%s %-18s %s:%d\n",
219 CRYPTO_thread_id(), rw_text, operation_text, 580 CRYPTO_THREADID_hash(&id), rw_text, operation_text,
220 CRYPTO_get_lock_name(type), file, line); 581 CRYPTO_get_lock_name(type), file, line);
221 } 582 }
222#endif 583#endif
223 if (type < 0) 584 if (type < 0)
224 { 585 {
225 if (do_dynlock_cb) 586 if (dynlock_lock_callback != NULL)
226 do_dynlock_cb(mode, type, file, line); 587 {
588 struct CRYPTO_dynlock_value *pointer
589 = CRYPTO_get_dynlock_value(type);
590
591 OPENSSL_assert(pointer != NULL);
592
593 dynlock_lock_callback(mode, pointer, file, line);
594
595 CRYPTO_destroy_dynlockid(type);
596 }
227 } 597 }
228 else 598 else
229 if (locking_callback != NULL) 599 if (locking_callback != NULL)
@@ -243,11 +613,14 @@ int CRYPTO_add_lock(int *pointer, int amount, int type, const char *file,
243 613
244 ret=add_lock_callback(pointer,amount,type,file,line); 614 ret=add_lock_callback(pointer,amount,type,file,line);
245#ifdef LOCK_DEBUG 615#ifdef LOCK_DEBUG
616 {
617 CRYPTO_THREADID id;
618 CRYPTO_THREADID_current(&id);
246 fprintf(stderr,"ladd:%08lx:%2d+%2d->%2d %-18s %s:%d\n", 619 fprintf(stderr,"ladd:%08lx:%2d+%2d->%2d %-18s %s:%d\n",
247 CRYPTO_thread_id(), 620 CRYPTO_THREADID_hash(&id), before,amount,ret,
248 before,amount,ret,
249 CRYPTO_get_lock_name(type), 621 CRYPTO_get_lock_name(type),
250 file,line); 622 file,line);
623 }
251#endif 624#endif
252 } 625 }
253 else 626 else
@@ -256,11 +629,15 @@ int CRYPTO_add_lock(int *pointer, int amount, int type, const char *file,
256 629
257 ret= *pointer+amount; 630 ret= *pointer+amount;
258#ifdef LOCK_DEBUG 631#ifdef LOCK_DEBUG
632 {
633 CRYPTO_THREADID id;
634 CRYPTO_THREADID_current(&id);
259 fprintf(stderr,"ladd:%08lx:%2d+%2d->%2d %-18s %s:%d\n", 635 fprintf(stderr,"ladd:%08lx:%2d+%2d->%2d %-18s %s:%d\n",
260 CRYPTO_thread_id(), 636 CRYPTO_THREADID_hash(&id),
261 *pointer,amount,ret, 637 *pointer,amount,ret,
262 CRYPTO_get_lock_name(type), 638 CRYPTO_get_lock_name(type),
263 file,line); 639 file,line);
640 }
264#endif 641#endif
265 *pointer=ret; 642 *pointer=ret;
266 CRYPTO_lock(CRYPTO_UNLOCK|CRYPTO_WRITE,type,file,line); 643 CRYPTO_lock(CRYPTO_UNLOCK|CRYPTO_WRITE,type,file,line);
@@ -268,6 +645,18 @@ int CRYPTO_add_lock(int *pointer, int amount, int type, const char *file,
268 return(ret); 645 return(ret);
269 } 646 }
270 647
648const char *CRYPTO_get_lock_name(int type)
649 {
650 if (type < 0)
651 return("dynamic");
652 else if (type < CRYPTO_NUM_LOCKS)
653 return(lock_names[type]);
654 else if (type-CRYPTO_NUM_LOCKS > sk_OPENSSL_STRING_num(app_locks))
655 return("ERROR");
656 else
657 return(sk_OPENSSL_STRING_value(app_locks,type-CRYPTO_NUM_LOCKS));
658 }
659
271#if defined(__i386) || defined(__i386__) || defined(_M_IX86) || \ 660#if defined(__i386) || defined(__i386__) || defined(_M_IX86) || \
272 defined(__INTEL__) || \ 661 defined(__INTEL__) || \
273 defined(__x86_64) || defined(__x86_64__) || defined(_M_AMD64) || defined(_M_X64) 662 defined(__x86_64) || defined(__x86_64__) || defined(_M_AMD64) || defined(_M_X64)
@@ -301,70 +690,16 @@ void OPENSSL_cpuid_setup(void)
301unsigned long *OPENSSL_ia32cap_loc(void) { return NULL; } 690unsigned long *OPENSSL_ia32cap_loc(void) { return NULL; }
302#endif 691#endif
303int OPENSSL_NONPIC_relocated = 0; 692int OPENSSL_NONPIC_relocated = 0;
304#if !defined(OPENSSL_CPUID_SETUP) 693#if !defined(OPENSSL_CPUID_SETUP) && !defined(OPENSSL_CPUID_OBJ)
305void OPENSSL_cpuid_setup(void) {} 694void OPENSSL_cpuid_setup(void) {}
306#endif 695#endif
307 696
308#if (defined(_WIN32) || defined(__CYGWIN__)) && defined(_WINDLL) 697#if (defined(_WIN32) || defined(__CYGWIN__)) && defined(_WINDLL)
309
310#ifdef OPENSSL_FIPS
311
312#include <tlhelp32.h>
313#if defined(__GNUC__) && __GNUC__>=2
314static int DllInit(void) __attribute__((constructor));
315#elif defined(_MSC_VER)
316static int DllInit(void);
317# ifdef _WIN64
318# pragma section(".CRT$XCU",read)
319 __declspec(allocate(".CRT$XCU"))
320# else
321# pragma data_seg(".CRT$XCU")
322# endif
323 static int (*p)(void) = DllInit;
324# pragma data_seg()
325#endif
326
327static int DllInit(void)
328{
329#if defined(_WIN32_WINNT)
330 union { int(*f)(void); BYTE *p; } t = { DllInit };
331 HANDLE hModuleSnap = INVALID_HANDLE_VALUE;
332 IMAGE_DOS_HEADER *dos_header;
333 IMAGE_NT_HEADERS *nt_headers;
334 MODULEENTRY32 me32 = {sizeof(me32)};
335
336 hModuleSnap = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE,0);
337 if (hModuleSnap != INVALID_HANDLE_VALUE &&
338 Module32First(hModuleSnap,&me32)) do
339 {
340 if (t.p >= me32.modBaseAddr &&
341 t.p < me32.modBaseAddr+me32.modBaseSize)
342 {
343 dos_header=(IMAGE_DOS_HEADER *)me32.modBaseAddr;
344 if (dos_header->e_magic==IMAGE_DOS_SIGNATURE)
345 {
346 nt_headers=(IMAGE_NT_HEADERS *)
347 ((BYTE *)dos_header+dos_header->e_lfanew);
348 if (nt_headers->Signature==IMAGE_NT_SIGNATURE &&
349 me32.modBaseAddr!=(BYTE*)nt_headers->OptionalHeader.ImageBase)
350 OPENSSL_NONPIC_relocated=1;
351 }
352 break;
353 }
354 } while (Module32Next(hModuleSnap,&me32));
355
356 if (hModuleSnap != INVALID_HANDLE_VALUE)
357 CloseHandle(hModuleSnap);
358#endif
359 OPENSSL_cpuid_setup();
360 return 0;
361}
362
363#else
364
365#ifdef __CYGWIN__ 698#ifdef __CYGWIN__
366/* pick DLL_[PROCESS|THREAD]_[ATTACH|DETACH] definitions */ 699/* pick DLL_[PROCESS|THREAD]_[ATTACH|DETACH] definitions */
367#include <windows.h> 700#include <windows.h>
701/* this has side-effect of _WIN32 getting defined, which otherwise
702 * is mutually exclusive with __CYGWIN__... */
368#endif 703#endif
369 704
370/* All we really need to do is remove the 'error' state when a thread 705/* All we really need to do is remove the 'error' state when a thread
@@ -405,16 +740,27 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason,
405 } 740 }
406#endif 741#endif
407 742
408#endif
409
410#if defined(_WIN32) && !defined(__CYGWIN__) 743#if defined(_WIN32) && !defined(__CYGWIN__)
411#include <tchar.h> 744#include <tchar.h>
745#include <signal.h>
412 746
413#if defined(_WIN32_WINNT) && _WIN32_WINNT>=0x0333 747#if defined(_WIN32_WINNT) && _WIN32_WINNT>=0x0333
414int OPENSSL_isservice(void) 748int OPENSSL_isservice(void)
415{ HWINSTA h; 749{ HWINSTA h;
416 DWORD len; 750 DWORD len;
417 WCHAR *name; 751 WCHAR *name;
752 static union { void *p; int (*f)(void); } _OPENSSL_isservice = { NULL };
753
754 if (_OPENSSL_isservice.p == NULL) {
755 HANDLE h = GetModuleHandle(NULL);
756 if (h != NULL)
757 _OPENSSL_isservice.p = GetProcAddress(h,"_OPENSSL_isservice");
758 if (_OPENSSL_isservice.p == NULL)
759 _OPENSSL_isservice.p = (void *)-1;
760 }
761
762 if (_OPENSSL_isservice.p != (void *)-1)
763 return (*_OPENSSL_isservice.f)();
418 764
419 (void)GetDesktopWindow(); /* return value is ignored */ 765 (void)GetDesktopWindow(); /* return value is ignored */
420 766
@@ -513,7 +859,7 @@ void OPENSSL_showfatal (const char *fmta,...)
513 859
514#if defined(_WIN32_WINNT) && _WIN32_WINNT>=0x0333 860#if defined(_WIN32_WINNT) && _WIN32_WINNT>=0x0333
515 /* this -------------v--- guards NT-specific calls */ 861 /* this -------------v--- guards NT-specific calls */
516 if (GetVersion() < 0x80000000 && OPENSSL_isservice()) 862 if (GetVersion() < 0x80000000 && OPENSSL_isservice() > 0)
517 { HANDLE h = RegisterEventSource(0,_T("OPENSSL")); 863 { HANDLE h = RegisterEventSource(0,_T("OPENSSL"));
518 const TCHAR *pmsg=buf; 864 const TCHAR *pmsg=buf;
519 ReportEvent(h,EVENTLOG_ERROR_TYPE,0,0,0,1,0,&pmsg,0); 865 ReportEvent(h,EVENTLOG_ERROR_TYPE,0,0,0,1,0,&pmsg,0);
@@ -539,7 +885,13 @@ void OpenSSLDie(const char *file,int line,const char *assertion)
539 OPENSSL_showfatal( 885 OPENSSL_showfatal(
540 "%s(%d): OpenSSL internal error, assertion failed: %s\n", 886 "%s(%d): OpenSSL internal error, assertion failed: %s\n",
541 file,line,assertion); 887 file,line,assertion);
888#if !defined(_WIN32) || defined(__CYGWIN__)
542 abort(); 889 abort();
890#else
891 /* Win32 abort() customarily shows a dialog, but we just did that... */
892 raise(SIGABRT);
893 _exit(3);
894#endif
543 } 895 }
544 896
545void *OPENSSL_stderr(void) { return stderr; } 897void *OPENSSL_stderr(void) { return stderr; }
diff --git a/src/lib/libcrypto/crypto-lib.com b/src/lib/libcrypto/crypto-lib.com
index 8f1c1d5a80..a4b6635091 100644
--- a/src/lib/libcrypto/crypto-lib.com
+++ b/src/lib/libcrypto/crypto-lib.com
@@ -6,10 +6,11 @@ $! A-Com Computing, Inc.
6$! byer@mail.all-net.net 6$! byer@mail.all-net.net
7$! 7$!
8$! Changes by Richard Levitte <richard@levitte.org> 8$! Changes by Richard Levitte <richard@levitte.org>
9$! Zoltan Arpadffy <arpadffy@polarhome.com>
9$! 10$!
10$! This command files compiles and creates the "[.xxx.EXE.CRYPTO]LIBCRYPTO.OLB" 11$! This command files compiles and creates the "[.xxx.EXE.CRYPTO]LIBCRYPTO.OLB"
11$! library for OpenSSL. The "xxx" denotes the machine architecture of AXP 12$! library for OpenSSL. The "xxx" denotes the machine architecture, ALPHA,
12$! or VAX. 13$! IA64 or VAX.
13$! 14$!
14$! It was re-written so it would try to determine what "C" compiler to use 15$! It was re-written so it would try to determine what "C" compiler to use
15$! or you can specify which "C" compiler to use. 16$! or you can specify which "C" compiler to use.
@@ -17,28 +18,28 @@ $!
17$! Specify the following as P1 to build just that part or ALL to just 18$! Specify the following as P1 to build just that part or ALL to just
18$! build everything. 19$! build everything.
19$! 20$!
20$! LIBRARY To just compile the [.xxx.EXE.CRYPTO]LIBCRYPTO.OLB Library. 21$! LIBRARY To just compile the [.xxx.EXE.CRYPTO]LIBCRYPTO.OLB Library.
21$! APPS To just compile the [.xxx.EXE.CRYPTO]*.EXE 22$! APPS To just compile the [.xxx.EXE.CRYPTO]*.EXE
22$! ALL To do both LIBRARY and APPS 23$! ALL To do both LIBRARY and APPS
23$! 24$!
24$! Specify DEBUG or NODEBUG as P2 to compile with or without debugger 25$! Specify DEBUG or NODEBUG as P2 to compile with or without debugger
25$! information. 26$! information.
26$! 27$!
27$! Specify which compiler at P3 to try to compile under. 28$! Specify which compiler at P3 to try to compile under.
28$! 29$!
29$! VAXC For VAX C. 30$! VAXC For VAX C.
30$! DECC For DEC C. 31$! DECC For DEC C.
31$! GNUC For GNU C. 32$! GNUC For GNU C.
32$! 33$!
33$! If you don't speficy a compiler, it will try to determine which 34$! If you don't specify a compiler, it will try to determine which
34$! "C" compiler to use. 35$! "C" compiler to use.
35$! 36$!
36$! P4, if defined, sets a TCP/IP library to use, through one of the following 37$! P4, if defined, sets a TCP/IP library to use, through one of the following
37$! keywords: 38$! keywords:
38$! 39$!
39$! UCX for UCX 40$! UCX For UCX
40$! TCPIP for TCPIP (post UCX) 41$! TCPIP For TCPIP (post UCX)
41$! SOCKETSHR for SOCKETSHR+NETLIB 42$! SOCKETSHR For SOCKETSHR+NETLIB
42$! 43$!
43$! P5, if defined, sets a compiler thread NOT needed on OpenVMS 7.1 (and up) 44$! P5, if defined, sets a compiler thread NOT needed on OpenVMS 7.1 (and up)
44$! 45$!
@@ -54,36 +55,49 @@ $ TCPIP_LIB = ""
54$! 55$!
55$! Check Which Architecture We Are Using. 56$! Check Which Architecture We Are Using.
56$! 57$!
57$ IF (F$GETSYI("CPU").GE.128) 58$ IF (F$GETSYI("CPU").LT.128)
58$ THEN 59$ THEN
59$! 60$!
60$! The Architecture Is AXP 61$! The Architecture Is VAX
61$! 62$!
62$ ARCH := AXP 63$ ARCH = "VAX"
63$! 64$!
64$! Else... 65$! Else...
65$! 66$!
66$ ELSE 67$ ELSE
67$! 68$!
68$! The Architecture Is VAX. 69$! The Architecture Is Alpha, IA64 or whatever comes in the future.
69$! 70$!
70$ ARCH := VAX 71$ ARCH = F$EDIT( F$GETSYI( "ARCH_NAME"), "UPCASE")
72$ IF (ARCH .EQS. "") THEN ARCH = "UNK"
71$! 73$!
72$! End The Architecture Check. 74$! End The Architecture Check.
73$! 75$!
74$ ENDIF 76$ ENDIF
75$! 77$!
76$! Define The Different Encryption Types. 78$! Define The Different Encryption Types.
79$! NOTE: Some might think this list ugly. However, it's made this way to
80$! reflect the SDIRS variable in [-]Makefile.org as closely as possible,
81$! thereby making it fairly easy to verify that the lists are the same.
77$! 82$!
83$ ET_WHIRLPOOL = "WHRLPOOL"
84$ IF ARCH .EQS. "VAX" THEN ET_WHIRLPOOL = ""
78$ ENCRYPT_TYPES = "Basic,"+ - 85$ ENCRYPT_TYPES = "Basic,"+ -
79 "OBJECTS,"+ - 86 "OBJECTS,"+ -
80 "MD2,MD4,MD5,SHA,MDC2,HMAC,RIPEMD,"+ - 87 "MD2,MD4,MD5,SHA,MDC2,HMAC,RIPEMD,"+ET_WHIRLPOOL+","+ -
81 "DES,RC2,RC4,RC5,IDEA,BF,CAST,CAMELLIA,SEED,"+ - 88 "DES,AES,RC2,RC4,RC5,IDEA,BF,CAST,CAMELLIA,SEED,MODES,"+ -
82 "BN,EC,RSA,DSA,ECDSA,DH,ECDH,DSO,ENGINE,AES,"+ - 89 "BN,EC,RSA,DSA,ECDSA,DH,ECDH,DSO,ENGINE,"+ -
83 "BUFFER,BIO,STACK,LHASH,RAND,ERR,"+ - 90 "BUFFER,BIO,STACK,LHASH,RAND,ERR,"+ -
84 "EVP,EVP_2,ASN1,ASN1_2,PEM,X509,X509V3,"+ - 91 "EVP,EVP_2,EVP_3,ASN1,ASN1_2,PEM,X509,X509V3,"+ -
85 "CONF,TXT_DB,PKCS7,PKCS12,COMP,OCSP,UI,KRB5,"+ - 92 "CONF,TXT_DB,PKCS7,PKCS12,COMP,OCSP,UI,KRB5,"+ -
86 "STORE,CMS,PQUEUE,JPAKE" 93 "STORE,CMS,PQUEUE,TS,JPAKE"
94$! Define The OBJ Directory.
95$!
96$ OBJ_DIR := SYS$DISK:[-.'ARCH'.OBJ.CRYPTO]
97$!
98$! Define The EXE Directory.
99$!
100$ EXE_DIR := SYS$DISK:[-.'ARCH'.EXE.CRYPTO]
87$! 101$!
88$! Check To Make Sure We Have Valid Command Line Parameters. 102$! Check To Make Sure We Have Valid Command Line Parameters.
89$! 103$!
@@ -97,9 +111,6 @@ $! Tell The User What Kind of Machine We Run On.
97$! 111$!
98$ WRITE SYS$OUTPUT "Compiling On A ",ARCH," Machine." 112$ WRITE SYS$OUTPUT "Compiling On A ",ARCH," Machine."
99$! 113$!
100$! Define The OBJ Directory.
101$!
102$ OBJ_DIR := SYS$DISK:[-.'ARCH'.OBJ.CRYPTO]
103$! 114$!
104$! Check To See If The Architecture Specific OBJ Directory Exists. 115$! Check To See If The Architecture Specific OBJ Directory Exists.
105$! 116$!
@@ -114,10 +125,6 @@ $! End The Architecture Specific OBJ Directory Check.
114$! 125$!
115$ ENDIF 126$ ENDIF
116$! 127$!
117$! Define The EXE Directory.
118$!
119$ EXE_DIR := SYS$DISK:[-.'ARCH'.EXE.CRYPTO]
120$!
121$! Check To See If The Architecture Specific Directory Exists. 128$! Check To See If The Architecture Specific Directory Exists.
122$! 129$!
123$ IF (F$PARSE(EXE_DIR).EQS."") 130$ IF (F$PARSE(EXE_DIR).EQS."")
@@ -161,15 +168,16 @@ $!
161$ APPS_DES = "DES/DES,CBC3_ENC" 168$ APPS_DES = "DES/DES,CBC3_ENC"
162$ APPS_PKCS7 = "ENC/ENC;DEC/DEC;SIGN/SIGN;VERIFY/VERIFY,EXAMPLE" 169$ APPS_PKCS7 = "ENC/ENC;DEC/DEC;SIGN/SIGN;VERIFY/VERIFY,EXAMPLE"
163$ 170$
164$ LIB_ = "cryptlib,dyn_lck,mem,mem_clr,mem_dbg,cversion,ex_data,tmdiff,cpt_err,ebcdic,uid,o_time,o_str,o_dir,o_init,fips_err" 171$ LIB_ = "cryptlib,mem,mem_clr,mem_dbg,cversion,ex_data,cpt_err,ebcdic,uid,o_time,o_str,o_dir"
165$ LIB_MD2 = "md2_dgst,md2_one" 172$ LIB_MD2 = "md2_dgst,md2_one"
166$ LIB_MD4 = "md4_dgst,md4_one" 173$ LIB_MD4 = "md4_dgst,md4_one"
167$ LIB_MD5 = "md5_dgst,md5_one" 174$ LIB_MD5 = "md5_dgst,md5_one"
168$ LIB_SHA = "sha_dgst,sha1dgst,sha_one,sha1_one,sha256,sha512" 175$ LIB_SHA = "sha_dgst,sha1dgst,sha_one,sha1_one,sha256,sha512"
169$ LIB_MDC2 = "mdc2dgst,mdc2_one" 176$ LIB_MDC2 = "mdc2dgst,mdc2_one"
170$ LIB_HMAC = "hmac" 177$ LIB_HMAC = "hmac,hm_ameth,hm_pmeth"
171$ LIB_RIPEMD = "rmd_dgst,rmd_one" 178$ LIB_RIPEMD = "rmd_dgst,rmd_one"
172$ LIB_DES = "des_lib,set_key,ecb_enc,cbc_enc,"+ - 179$ LIB_WHRLPOOL = "wp_dgst,wp_block"
180$ LIB_DES = "set_key,ecb_enc,cbc_enc,"+ -
173 "ecb3_enc,cfb64enc,cfb64ede,cfb_enc,ofb64ede,"+ - 181 "ecb3_enc,cfb64enc,cfb64ede,cfb_enc,ofb64ede,"+ -
174 "enc_read,enc_writ,ofb64enc,"+ - 182 "enc_read,enc_writ,ofb64enc,"+ -
175 "ofb_enc,str2key,pcbc_enc,qud_cksm,rand_key,"+ - 183 "ofb_enc,str2key,pcbc_enc,qud_cksm,rand_key,"+ -
@@ -184,36 +192,39 @@ $ LIB_BF = "bf_skey,bf_ecb,bf_enc,bf_cfb64,bf_ofb64"
184$ LIB_CAST = "c_skey,c_ecb,c_enc,c_cfb64,c_ofb64" 192$ LIB_CAST = "c_skey,c_ecb,c_enc,c_cfb64,c_ofb64"
185$ LIB_CAMELLIA = "camellia,cmll_misc,cmll_ecb,cmll_cbc,cmll_ofb,"+ - 193$ LIB_CAMELLIA = "camellia,cmll_misc,cmll_ecb,cmll_cbc,cmll_ofb,"+ -
186 "cmll_cfb,cmll_ctr" 194 "cmll_cfb,cmll_ctr"
187$ LIB_SEED = "seed,seed_cbc,seed_ecb,seed_cfb,seed_ofb" 195$ LIB_SEED = "seed,seed_ecb,seed_cbc,seed_cfb,seed_ofb"
196$ LIB_MODES = "cbc128,ctr128,cfb128,ofb128"
188$ LIB_BN_ASM = "[.asm]vms.mar,vms-helper" 197$ LIB_BN_ASM = "[.asm]vms.mar,vms-helper"
189$ IF F$TRNLNM("OPENSSL_NO_ASM").OR.ARCH.EQS."AXP" THEN LIB_BN_ASM = "bn_asm" 198$ IF F$TRNLNM("OPENSSL_NO_ASM") .OR. ARCH .NES. "VAX" THEN -
199 LIB_BN_ASM = "bn_asm"
190$ LIB_BN = "bn_add,bn_div,bn_exp,bn_lib,bn_ctx,bn_mul,bn_mod,"+ - 200$ LIB_BN = "bn_add,bn_div,bn_exp,bn_lib,bn_ctx,bn_mul,bn_mod,"+ -
191 "bn_print,bn_rand,bn_shift,bn_word,bn_blind,"+ - 201 "bn_print,bn_rand,bn_shift,bn_word,bn_blind,"+ -
192 "bn_kron,bn_sqrt,bn_gcd,bn_prime,bn_err,bn_sqr,"+LIB_BN_ASM+","+ - 202 "bn_kron,bn_sqrt,bn_gcd,bn_prime,bn_err,bn_sqr,"+LIB_BN_ASM+","+ -
193 "bn_recp,bn_mont,bn_mpi,bn_exp2,bn_gf2m,bn_nist,"+ - 203 "bn_recp,bn_mont,bn_mpi,bn_exp2,bn_gf2m,bn_nist,"+ -
194 "bn_depr,bn_x931p,bn_const,bn_opt" 204 "bn_depr,bn_const"
195$ LIB_EC = "ec_lib,ecp_smpl,ecp_mont,ecp_nist,ec_cvt,ec_mult,"+ - 205$ LIB_EC = "ec_lib,ecp_smpl,ecp_mont,ecp_nist,ec_cvt,ec_mult,"+ -
196 "ec_err,ec_curve,ec_check,ec_print,ec_asn1,ec_key,"+ - 206 "ec_err,ec_curve,ec_check,ec_print,ec_asn1,ec_key,"+ -
197 "ec2_smpl,ec2_mult" 207 "ec2_smpl,ec2_mult,ec_ameth,ec_pmeth,eck_prn"
198$ LIB_RSA = "rsa_eay,rsa_gen,rsa_lib,rsa_sign,rsa_saos,rsa_err,"+ - 208$ LIB_RSA = "rsa_eay,rsa_gen,rsa_lib,rsa_sign,rsa_saos,rsa_err,"+ -
199 "rsa_pk1,rsa_ssl,rsa_none,rsa_oaep,rsa_chk,rsa_null,"+ - 209 "rsa_pk1,rsa_ssl,rsa_none,rsa_oaep,rsa_chk,rsa_null,"+ -
200 "rsa_pss,rsa_x931,rsa_x931g,rsa_asn1,rsa_depr,rsa_eng" 210 "rsa_pss,rsa_x931,rsa_asn1,rsa_depr,rsa_ameth,rsa_prn,"+ -
211 "rsa_pmeth"
201$ LIB_DSA = "dsa_gen,dsa_key,dsa_lib,dsa_asn1,dsa_vrf,dsa_sign,"+ - 212$ LIB_DSA = "dsa_gen,dsa_key,dsa_lib,dsa_asn1,dsa_vrf,dsa_sign,"+ -
202 "dsa_err,dsa_ossl,dsa_depr,dsa_utl" 213 "dsa_err,dsa_ossl,dsa_depr,dsa_ameth,dsa_pmeth,dsa_prn"
203$ LIB_ECDSA = "ecs_lib,ecs_asn1,ecs_ossl,ecs_sign,ecs_vrf,ecs_err" 214$ LIB_ECDSA = "ecs_lib,ecs_asn1,ecs_ossl,ecs_sign,ecs_vrf,ecs_err"
204$ LIB_DH = "dh_asn1,dh_gen,dh_key,dh_lib,dh_check,dh_err,dh_depr" 215$ LIB_DH = "dh_asn1,dh_gen,dh_key,dh_lib,dh_check,dh_err,dh_depr,"+ -
216 "dh_ameth,dh_pmeth,dh_prn"
205$ LIB_ECDH = "ech_lib,ech_ossl,ech_key,ech_err" 217$ LIB_ECDH = "ech_lib,ech_ossl,ech_key,ech_err"
206$ LIB_DSO = "dso_dl,dso_dlfcn,dso_err,dso_lib,dso_null,"+ - 218$ LIB_DSO = "dso_dl,dso_dlfcn,dso_err,dso_lib,dso_null,"+ -
207 "dso_openssl,dso_win32,dso_vms" 219 "dso_openssl,dso_win32,dso_vms,dso_beos"
208$ LIB_ENGINE = "eng_err,eng_lib,eng_list,eng_init,eng_ctrl,"+ - 220$ LIB_ENGINE = "eng_err,eng_lib,eng_list,eng_init,eng_ctrl,"+ -
209 "eng_table,eng_pkey,eng_fat,eng_all,"+ - 221 "eng_table,eng_pkey,eng_fat,eng_all,"+ -
210 "tb_rsa,tb_dsa,tb_ecdsa,tb_dh,tb_ecdh,tb_rand,tb_store,"+ - 222 "tb_rsa,tb_dsa,tb_ecdsa,tb_dh,tb_ecdh,tb_rand,tb_store,"+ -
211 "tb_cipher,tb_digest,"+ - 223 "tb_cipher,tb_digest,tb_pkmeth,tb_asnmth,"+ -
212 "eng_openssl,eng_dyn,eng_cnf,eng_cryptodev,eng_padlock"+ - 224 "eng_openssl,eng_dyn,eng_cnf,eng_cryptodev"
213 "eng_aesni" 225$ LIB_AES = "aes_core,aes_misc,aes_ecb,aes_cbc,aes_cfb,aes_ofb,aes_ctr,"+ -
214$ LIB_AES = "aes_core,aes_misc,aes_ecb,aes_cbc,aes_cfb,aes_ofb,"+ - 226 "aes_ige,aes_wrap"
215 "aes_ctr,aes_ige,aes_wrap" 227$ LIB_BUFFER = "buffer,buf_err"
216$ LIB_BUFFER = "buffer,buf_str,buf_err"
217$ LIB_BIO = "bio_lib,bio_cb,bio_err,"+ - 228$ LIB_BIO = "bio_lib,bio_cb,bio_err,"+ -
218 "bss_mem,bss_null,bss_fd,"+ - 229 "bss_mem,bss_null,bss_fd,"+ -
219 "bss_file,bss_sock,bss_conn,"+ - 230 "bss_file,bss_sock,bss_conn,"+ -
@@ -225,33 +236,34 @@ $ LIB_STACK = "stack"
225$ LIB_LHASH = "lhash,lh_stats" 236$ LIB_LHASH = "lhash,lh_stats"
226$ LIB_RAND = "md_rand,randfile,rand_lib,rand_err,rand_egd,"+ - 237$ LIB_RAND = "md_rand,randfile,rand_lib,rand_err,rand_egd,"+ -
227 "rand_vms" 238 "rand_vms"
228$ LIB_ERR = "err,err_def,err_all,err_prn,err_str,err_bio" 239$ LIB_ERR = "err,err_all,err_prn"
229$ LIB_OBJECTS = "o_names,obj_dat,obj_lib,obj_err" 240$ LIB_OBJECTS = "o_names,obj_dat,obj_lib,obj_err,obj_xref"
230$ LIB_EVP = "encode,digest,dig_eng,evp_enc,evp_key,evp_acnf,evp_cnf,"+ - 241$ LIB_EVP = "encode,digest,evp_enc,evp_key,evp_acnf,"+ -
231 "e_des,e_bf,e_idea,e_des3,e_camellia,"+ - 242 "e_des,e_bf,e_idea,e_des3,e_camellia,"+ -
232 "e_rc4,e_aes,names,e_seed,"+ - 243 "e_rc4,e_aes,names,e_seed,"+ -
233 "e_xcbc_d,e_rc2,e_cast,e_rc5,enc_min" 244 "e_xcbc_d,e_rc2,e_cast,e_rc5"
234$ LIB_EVP_2 = "m_null,m_md2,m_md4,m_md5,m_sha,m_sha1," + - 245$ LIB_EVP_2 = "m_null,m_md2,m_md4,m_md5,m_sha,m_sha1,m_wp," + -
235 "m_dss,m_dss1,m_mdc2,m_ripemd,m_ecdsa,"+ - 246 "m_dss,m_dss1,m_mdc2,m_ripemd,m_ecdsa,"+ -
236 "p_open,p_seal,p_sign,p_verify,p_lib,p_enc,p_dec,"+ - 247 "p_open,p_seal,p_sign,p_verify,p_lib,p_enc,p_dec,"+ -
237 "bio_md,bio_b64,bio_enc,evp_err,e_null,"+ - 248 "bio_md,bio_b64,bio_enc,evp_err,e_null,"+ -
238 "c_all,c_allc,c_alld,evp_lib,bio_ok,"+- 249 "c_all,c_allc,c_alld,evp_lib,bio_ok,"+-
239 "evp_pkey,evp_pbe,p5_crpt,p5_crpt2" 250 "evp_pkey,evp_pbe,p5_crpt,p5_crpt2"
240$ LIB_EVP_3 = "e_old" 251$ LIB_EVP_3 = "e_old,pmeth_lib,pmeth_fn,pmeth_gn,m_sigver"
241$ LIB_ASN1 = "a_object,a_bitstr,a_utctm,a_gentm,a_time,a_int,a_octet,"+ - 252$ LIB_ASN1 = "a_object,a_bitstr,a_utctm,a_gentm,a_time,a_int,a_octet,"+ -
242 "a_print,a_type,a_set,a_dup,a_d2i_fp,a_i2d_fp,"+ - 253 "a_print,a_type,a_set,a_dup,a_d2i_fp,a_i2d_fp,"+ -
243 "a_enum,a_utf8,a_sign,a_digest,a_verify,a_mbstr,a_strex,"+ - 254 "a_enum,a_utf8,a_sign,a_digest,a_verify,a_mbstr,a_strex,"+ -
244 "x_algor,x_val,x_pubkey,x_sig,x_req,x_attrib,x_bignum,"+ - 255 "x_algor,x_val,x_pubkey,x_sig,x_req,x_attrib,x_bignum,"+ -
245 "x_long,x_name,x_x509,x_x509a,x_crl,x_info,x_spki,nsseq,"+ - 256 "x_long,x_name,x_x509,x_x509a,x_crl,x_info,x_spki,nsseq,"+ -
246 "d2i_pu,d2i_pr,i2d_pu,i2d_pr" 257 "x_nx509,d2i_pu,d2i_pr,i2d_pu,i2d_pr"
247$ LIB_ASN1_2 = "t_req,t_x509,t_x509a,t_crl,t_pkey,t_spki,t_bitst,"+ - 258$ LIB_ASN1_2 = "t_req,t_x509,t_x509a,t_crl,t_pkey,t_spki,t_bitst,"+ -
248 "tasn_new,tasn_fre,tasn_enc,tasn_dec,tasn_utl,tasn_typ,"+ - 259 "tasn_new,tasn_fre,tasn_enc,tasn_dec,tasn_utl,tasn_typ,"+ -
260 "tasn_prn,ameth_lib,"+ -
249 "f_int,f_string,n_pkey,"+ - 261 "f_int,f_string,n_pkey,"+ -
250 "f_enum,a_hdr,x_pkey,a_bool,x_exten,asn_mime,"+ - 262 "f_enum,x_pkey,a_bool,x_exten,bio_asn1,bio_ndef,asn_mime,"+ -
251 "asn1_gen,asn1_par,asn1_lib,asn1_err,a_meth,a_bytes,a_strnid,"+ - 263 "asn1_gen,asn1_par,asn1_lib,asn1_err,a_bytes,a_strnid,"+ -
252 "evp_asn1,asn_pack,p5_pbe,p5_pbev2,p8_pkey,asn_moid" 264 "evp_asn1,asn_pack,p5_pbe,p5_pbev2,p8_pkey,asn_moid"
253$ LIB_PEM = "pem_sign,pem_seal,pem_info,pem_lib,pem_all,pem_err,"+ - 265$ LIB_PEM = "pem_sign,pem_seal,pem_info,pem_lib,pem_all,pem_err,"+ -
254 "pem_x509,pem_xaux,pem_oth,pem_pk8,pem_pkey" 266 "pem_x509,pem_xaux,pem_oth,pem_pk8,pem_pkey,pvkfmt"
255$ LIB_X509 = "x509_def,x509_d2,x509_r2x,x509_cmp,"+ - 267$ LIB_X509 = "x509_def,x509_d2,x509_r2x,x509_cmp,"+ -
256 "x509_obj,x509_req,x509spki,x509_vfy,"+ - 268 "x509_obj,x509_req,x509spki,x509_vfy,"+ -
257 "x509_set,x509cset,x509rset,x509_err,"+ - 269 "x509_set,x509cset,x509rset,x509_err,"+ -
@@ -267,7 +279,7 @@ $ LIB_X509V3 = "v3_bcons,v3_bitst,v3_conf,v3_extku,v3_ia5,v3_lib,"+ -
267$ LIB_CONF = "conf_err,conf_lib,conf_api,conf_def,conf_mod,conf_mall,conf_sap" 279$ LIB_CONF = "conf_err,conf_lib,conf_api,conf_def,conf_mod,conf_mall,conf_sap"
268$ LIB_TXT_DB = "txt_db" 280$ LIB_TXT_DB = "txt_db"
269$ LIB_PKCS7 = "pk7_asn1,pk7_lib,pkcs7err,pk7_doit,pk7_smime,pk7_attr,"+ - 281$ LIB_PKCS7 = "pk7_asn1,pk7_lib,pkcs7err,pk7_doit,pk7_smime,pk7_attr,"+ -
270 "pk7_mime" 282 "pk7_mime,bio_pk7"
271$ LIB_PKCS12 = "p12_add,p12_asn,p12_attr,p12_crpt,p12_crt,p12_decr,"+ - 283$ LIB_PKCS12 = "p12_add,p12_asn,p12_attr,p12_crpt,p12_crt,p12_decr,"+ -
272 "p12_init,p12_key,p12_kiss,p12_mutl,"+ - 284 "p12_init,p12_key,p12_kiss,p12_mutl,"+ -
273 "p12_utl,p12_npas,pk12err,p12_p8d,p12_p8e" 285 "p12_utl,p12_npas,pk12err,p12_p8d,p12_p8e"
@@ -282,6 +294,9 @@ $ LIB_STORE = "str_err,str_lib,str_meth,str_mem"
282$ LIB_CMS = "cms_lib,cms_asn1,cms_att,cms_io,cms_smime,cms_err,"+ - 294$ LIB_CMS = "cms_lib,cms_asn1,cms_att,cms_io,cms_smime,cms_err,"+ -
283 "cms_sd,cms_dd,cms_cd,cms_env,cms_enc,cms_ess" 295 "cms_sd,cms_dd,cms_cd,cms_env,cms_enc,cms_ess"
284$ LIB_PQUEUE = "pqueue" 296$ LIB_PQUEUE = "pqueue"
297$ LIB_TS = "ts_err,ts_req_utils,ts_req_print,ts_rsp_utils,ts_rsp_print,"+ -
298 "ts_rsp_sign,ts_rsp_verify,ts_verify_ctx,ts_lib,ts_conf,"+ -
299 "ts_asn1"
285$ LIB_JPAKE = "jpake,jpake_err" 300$ LIB_JPAKE = "jpake,jpake_err"
286$! 301$!
287$! Setup exceptional compilations 302$! Setup exceptional compilations
@@ -292,7 +307,7 @@ $ ! Disable the DOLLARID warning
292$ COMPILEWITH_CC4 = ",a_utctm,bss_log,o_time,o_dir" 307$ COMPILEWITH_CC4 = ",a_utctm,bss_log,o_time,o_dir"
293$ ! Disable disjoint optimization 308$ ! Disable disjoint optimization
294$ COMPILEWITH_CC5 = ",md2_dgst,md4_dgst,md5_dgst,mdc2dgst," + - 309$ COMPILEWITH_CC5 = ",md2_dgst,md4_dgst,md5_dgst,mdc2dgst," + -
295 "sha_dgst,sha1dgst,rmd_dgst,bf_enc," 310 "seed,sha_dgst,sha1dgst,rmd_dgst,bf_enc,"
296$ ! Disable the MIXLINKAGE warning 311$ ! Disable the MIXLINKAGE warning
297$ COMPILEWITH_CC6 = ",enc_read,set_key," 312$ COMPILEWITH_CC6 = ",enc_read,set_key,"
298$! 313$!
@@ -335,11 +350,11 @@ $! Create The Library and Apps Module Names.
335$! 350$!
336$ LIB_MODULE = "LIB_" + MODULE_NAME 351$ LIB_MODULE = "LIB_" + MODULE_NAME
337$ APPS_MODULE = "APPS_" + MODULE_NAME 352$ APPS_MODULE = "APPS_" + MODULE_NAME
338$ IF (MODULE_NAME.EQS."ASN1_2") 353$ IF (F$EXTRACT(0,5,MODULE_NAME).EQS."ASN1_")
339$ THEN 354$ THEN
340$ MODULE_NAME = "ASN1" 355$ MODULE_NAME = "ASN1"
341$ ENDIF 356$ ENDIF
342$ IF (MODULE_NAME.EQS."EVP_2") 357$ IF (F$EXTRACT(0,4,MODULE_NAME).EQS."EVP_")
343$ THEN 358$ THEN
344$ MODULE_NAME = "EVP" 359$ MODULE_NAME = "EVP"
345$ ENDIF 360$ ENDIF
@@ -354,7 +369,7 @@ $!
354$ IF F$TYPE('LIB_MODULE') .EQS. "" 369$ IF F$TYPE('LIB_MODULE') .EQS. ""
355$ THEN 370$ THEN
356$ WRITE SYS$ERROR "" 371$ WRITE SYS$ERROR ""
357$ WRITE SYS$ERROR "The module ",MODULE_NAME," does not exist. Continuing..." 372$ WRITE SYS$ERROR "The module ",MODULE_NAME1," does not exist. Continuing..."
358$ WRITE SYS$ERROR "" 373$ WRITE SYS$ERROR ""
359$ GOTO MODULE_NEXT 374$ GOTO MODULE_NEXT
360$ ENDIF 375$ ENDIF
@@ -695,7 +710,7 @@ $!
695$ IF (F$SEARCH(OPT_FILE).EQS."") 710$ IF (F$SEARCH(OPT_FILE).EQS."")
696$ THEN 711$ THEN
697$! 712$!
698$! Figure Out If We Need An AXP Or A VAX Linker Option File. 713$! Figure Out If We Need A non-VAX Or A VAX Linker Option File.
699$! 714$!
700$ IF ARCH .EQS. "VAX" 715$ IF ARCH .EQS. "VAX"
701$ THEN 716$ THEN
@@ -715,19 +730,19 @@ $! Else...
715$! 730$!
716$ ELSE 731$ ELSE
717$! 732$!
718$! Create The AXP Linker Option File. 733$! Create The non-VAX Linker Option File.
719$! 734$!
720$ CREATE 'OPT_FILE' 735$ CREATE 'OPT_FILE'
721$DECK 736$DECK
722! 737!
723! Default System Options File For AXP To Link Agianst 738! Default System Options File For non-VAX To Link Agianst
724! The Sharable C Runtime Library. 739! The Sharable C Runtime Library.
725! 740!
726SYS$SHARE:CMA$OPEN_LIB_SHR/SHARE 741SYS$SHARE:CMA$OPEN_LIB_SHR/SHARE
727SYS$SHARE:CMA$OPEN_RTL/SHARE 742SYS$SHARE:CMA$OPEN_RTL/SHARE
728$EOD 743$EOD
729$! 744$!
730$! End The VAX/AXP DEC C Option File Check. 745$! End The DEC C Option File Check.
731$! 746$!
732$ ENDIF 747$ ENDIF
733$! 748$!
@@ -764,12 +779,12 @@ $! Else...
764$! 779$!
765$ ELSE 780$ ELSE
766$! 781$!
767$! Else, Check To See If P1 Has A Valid Arguement. 782$! Else, Check To See If P1 Has A Valid Argument.
768$! 783$!
769$ IF (P1.EQS."LIBRARY").OR.(P1.EQS."APPS") 784$ IF (P1.EQS."LIBRARY").OR.(P1.EQS."APPS")
770$ THEN 785$ THEN
771$! 786$!
772$! A Valid Arguement. 787$! A Valid Argument.
773$! 788$!
774$ BUILDALL = P1 789$ BUILDALL = P1
775$! 790$!
@@ -788,15 +803,16 @@ $ WRITE SYS$OUTPUT " APPS : To Compile Just The [.xxx.EXE.CRYPTO]*.E
788$ WRITE SYS$OUTPUT "" 803$ WRITE SYS$OUTPUT ""
789$ WRITE SYS$OUTPUT " Where 'xxx' Stands For:" 804$ WRITE SYS$OUTPUT " Where 'xxx' Stands For:"
790$ WRITE SYS$OUTPUT "" 805$ WRITE SYS$OUTPUT ""
791$ WRITE SYS$OUTPUT " AXP : Alpha Architecture." 806$ WRITE SYS$OUTPUT " ALPHA : Alpha Architecture."
792$ WRITE SYS$OUTPUT " VAX : VAX Architecture." 807$ WRITE SYS$OUTPUT " IA64 : IA64 Architecture."
808$ WRITE SYS$OUTPUT " VAX : VAX Architecture."
793$ WRITE SYS$OUTPUT "" 809$ WRITE SYS$OUTPUT ""
794$! 810$!
795$! Time To EXIT. 811$! Time To EXIT.
796$! 812$!
797$ EXIT 813$ EXIT
798$! 814$!
799$! End The Valid Arguement Check. 815$! End The Valid Argument Check.
800$! 816$!
801$ ENDIF 817$ ENDIF
802$! 818$!
@@ -849,7 +865,7 @@ $! Time To EXIT.
849$! 865$!
850$ EXIT 866$ EXIT
851$! 867$!
852$! End The Valid Arguement Check. 868$! End The Valid Argument Check.
853$! 869$!
854$ ENDIF 870$ ENDIF
855$! 871$!
@@ -914,7 +930,7 @@ $ ELSE
914$! 930$!
915$! Check To See If We Have VAXC Or DECC. 931$! Check To See If We Have VAXC Or DECC.
916$! 932$!
917$ IF (ARCH.EQS."AXP").OR.(F$TRNLNM("DECC$CC_DEFAULT").NES."") 933$ IF (ARCH.NES."VAX").OR.(F$TRNLNM("DECC$CC_DEFAULT").NES."")
918$ THEN 934$ THEN
919$! 935$!
920$! Looks Like DECC, Set To Use DECC. 936$! Looks Like DECC, Set To Use DECC.
@@ -1020,12 +1036,12 @@ $ IF ARCH.EQS."VAX" .AND. F$TRNLNM("DECC$CC_DEFAULT").NES."/DECC" -
1020 THEN CC = "CC/DECC" 1036 THEN CC = "CC/DECC"
1021$ CC = CC + "/''CC_OPTIMIZE'/''DEBUGGER'/STANDARD=ANSI89" + - 1037$ CC = CC + "/''CC_OPTIMIZE'/''DEBUGGER'/STANDARD=ANSI89" + -
1022 "/NOLIST/PREFIX=ALL" + - 1038 "/NOLIST/PREFIX=ALL" + -
1023 "/INCLUDE=(SYS$DISK:[],SYS$DISK:[-],SYS$DISK:[.ENGINE.VENDOR_DEFNS],SYS$DISK:[.EVP])" + - 1039 "/INCLUDE=(SYS$DISK:[],SYS$DISK:[._''ARCH'],SYS$DISK:[-],SYS$DISK:[.ENGINE.VENDOR_DEFNS],SYS$DISK:[.EVP],SYS$DISK:[.ASN1])" + -
1024 CCEXTRAFLAGS 1040 CCEXTRAFLAGS
1025$! 1041$!
1026$! Define The Linker Options File Name. 1042$! Define The Linker Options File Name.
1027$! 1043$!
1028$ OPT_FILE = "SYS$DISK:[]VAX_DECC_OPTIONS.OPT" 1044$ OPT_FILE = "''EXE_DIR'VAX_DECC_OPTIONS.OPT"
1029$! 1045$!
1030$! End DECC Check. 1046$! End DECC Check.
1031$! 1047$!
@@ -1047,14 +1063,14 @@ $!
1047$! Compile Using VAXC. 1063$! Compile Using VAXC.
1048$! 1064$!
1049$ CC = "CC" 1065$ CC = "CC"
1050$ IF ARCH.EQS."AXP" 1066$ IF ARCH.NES."VAX"
1051$ THEN 1067$ THEN
1052$ WRITE SYS$OUTPUT "There is no VAX C on Alpha!" 1068$ WRITE SYS$OUTPUT "There is no VAX C on ''ARCH'!"
1053$ EXIT 1069$ EXIT
1054$ ENDIF 1070$ ENDIF
1055$ IF F$TRNLNM("DECC$CC_DEFAULT").EQS."/DECC" THEN CC = "CC/VAXC" 1071$ IF F$TRNLNM("DECC$CC_DEFAULT").EQS."/DECC" THEN CC = "CC/VAXC"
1056$ CC = CC + "/''CC_OPTIMIZE'/''DEBUGGER'/NOLIST" + - 1072$ CC = CC + "/''CC_OPTIMIZE'/''DEBUGGER'/NOLIST" + -
1057 "/INCLUDE=(SYS$DISK:[],SYS$DISK:[-],SYS$DISK:[.ENGINE.VENDOR_DEFNS])" + - 1073 "/INCLUDE=(SYS$DISK:[],SYS$DISK:[._''ARCH'],SYS$DISK:[-],SYS$DISK:[.ENGINE.VENDOR_DEFNS],SYS$DISK:[.EVP],SYS$DISK:[.ASN1])" + -
1058 CCEXTRAFLAGS 1074 CCEXTRAFLAGS
1059$ CCDEFS = """VAXC""," + CCDEFS 1075$ CCDEFS = """VAXC""," + CCDEFS
1060$! 1076$!
@@ -1064,7 +1080,7 @@ $ DEFINE/NOLOG SYS SYS$COMMON:[SYSLIB]
1064$! 1080$!
1065$! Define The Linker Options File Name. 1081$! Define The Linker Options File Name.
1066$! 1082$!
1067$ OPT_FILE = "SYS$DISK:[]VAX_VAXC_OPTIONS.OPT" 1083$ OPT_FILE = "''EXE_DIR'VAX_VAXC_OPTIONS.OPT"
1068$! 1084$!
1069$! End VAXC Check 1085$! End VAXC Check
1070$! 1086$!
@@ -1086,12 +1102,12 @@ $!
1086$! Use GNU C... 1102$! Use GNU C...
1087$! 1103$!
1088$ CC = "GCC/NOCASE_HACK/''GCC_OPTIMIZE'/''DEBUGGER'/NOLIST" + - 1104$ CC = "GCC/NOCASE_HACK/''GCC_OPTIMIZE'/''DEBUGGER'/NOLIST" + -
1089 "/INCLUDE=(SYS$DISK:[],SYS$DISK:[-],SYS$DISK:[.ENGINE.VENDOR_DEFNS])" + - 1105 "/INCLUDE=(SYS$DISK:[],SYS$DISK:[._''ARCH'],SYS$DISK:[-],SYS$DISK:[.ENGINE.VENDOR_DEFNS],SYS$DISK:[.EVP],SYS$DISK:[.ASN1])" + -
1090 CCEXTRAFLAGS 1106 CCEXTRAFLAGS
1091$! 1107$!
1092$! Define The Linker Options File Name. 1108$! Define The Linker Options File Name.
1093$! 1109$!
1094$ OPT_FILE = "SYS$DISK:[]VAX_GNUC_OPTIONS.OPT" 1110$ OPT_FILE = "''EXE_DIR'VAX_GNUC_OPTIONS.OPT"
1095$! 1111$!
1096$! End The GNU C Check. 1112$! End The GNU C Check.
1097$! 1113$!
@@ -1136,7 +1152,7 @@ $! Show user the result
1136$! 1152$!
1137$ WRITE/SYMBOL SYS$OUTPUT "Main C Compiling Command: ",CC 1153$ WRITE/SYMBOL SYS$OUTPUT "Main C Compiling Command: ",CC
1138$! 1154$!
1139$! Else The User Entered An Invalid Arguement. 1155$! Else The User Entered An Invalid Argument.
1140$! 1156$!
1141$ ELSE 1157$ ELSE
1142$! 1158$!
@@ -1154,14 +1170,14 @@ $! Time To EXIT.
1154$! 1170$!
1155$ EXIT 1171$ EXIT
1156$! 1172$!
1157$! End The Valid Arguement Check. 1173$! End The Valid Argument Check.
1158$! 1174$!
1159$ ENDIF 1175$ ENDIF
1160$! 1176$!
1161$! Build a MACRO command for the architecture at hand 1177$! Build a MACRO command for the architecture at hand
1162$! 1178$!
1163$ IF ARCH .EQS. "VAX" THEN MACRO = "MACRO/''DEBUGGER'" 1179$ IF ARCH .EQS. "VAX" THEN MACRO = "MACRO/''DEBUGGER'"
1164$ IF ARCH .EQS. "AXP" THEN MACRO = "MACRO/MIGRATION/''DEBUGGER'/''MACRO_OPTIMIZE'" 1180$ IF ARCH .NES. "VAX" THEN MACRO = "MACRO/MIGRATION/''DEBUGGER'/''MACRO_OPTIMIZE'"
1165$! 1181$!
1166$! Show user the result 1182$! Show user the result
1167$! 1183$!
@@ -1249,7 +1265,7 @@ $! Print info
1249$! 1265$!
1250$ WRITE SYS$OUTPUT "TCP/IP library spec: ", TCPIP_LIB 1266$ WRITE SYS$OUTPUT "TCP/IP library spec: ", TCPIP_LIB
1251$! 1267$!
1252$! Else The User Entered An Invalid Arguement. 1268$! Else The User Entered An Invalid Argument.
1253$! 1269$!
1254$ ELSE 1270$ ELSE
1255$! 1271$!
diff --git a/src/lib/libcrypto/crypto.h b/src/lib/libcrypto/crypto.h
index 0e4fb0723c..b0360cec51 100644
--- a/src/lib/libcrypto/crypto.h
+++ b/src/lib/libcrypto/crypto.h
@@ -1,6 +1,6 @@
1/* crypto/crypto.h */ 1/* crypto/crypto.h */
2/* ==================================================================== 2/* ====================================================================
3 * Copyright (c) 1998-2003 The OpenSSL Project. All rights reserved. 3 * Copyright (c) 1998-2006 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
@@ -219,13 +219,9 @@ typedef struct openssl_item_st
219#define CRYPTO_LOCK_EC_PRE_COMP 36 219#define CRYPTO_LOCK_EC_PRE_COMP 36
220#define CRYPTO_LOCK_STORE 37 220#define CRYPTO_LOCK_STORE 37
221#define CRYPTO_LOCK_COMP 38 221#define CRYPTO_LOCK_COMP 38
222#ifndef OPENSSL_FIPS
223#define CRYPTO_NUM_LOCKS 39
224#else
225#define CRYPTO_LOCK_FIPS 39 222#define CRYPTO_LOCK_FIPS 39
226#define CRYPTO_LOCK_FIPS2 40 223#define CRYPTO_LOCK_FIPS2 40
227#define CRYPTO_NUM_LOCKS 41 224#define CRYPTO_NUM_LOCKS 41
228#endif
229 225
230#define CRYPTO_LOCK 1 226#define CRYPTO_LOCK 1
231#define CRYPTO_UNLOCK 2 227#define CRYPTO_UNLOCK 2
@@ -288,9 +284,10 @@ typedef struct bio_st BIO_dummy;
288 284
289struct crypto_ex_data_st 285struct crypto_ex_data_st
290 { 286 {
291 STACK *sk; 287 STACK_OF(void) *sk;
292 int dummy; /* gcc is screwing up this data structure :-( */ 288 int dummy; /* gcc is screwing up this data structure :-( */
293 }; 289 };
290DECLARE_STACK_OF(void)
294 291
295/* This stuff is basically class callback functions 292/* This stuff is basically class callback functions
296 * The current classes are SSL_CTX, SSL, SSL_SESSION, and a few more */ 293 * The current classes are SSL_CTX, SSL, SSL_SESSION, and a few more */
@@ -347,7 +344,14 @@ DECLARE_STACK_OF(CRYPTO_EX_DATA_FUNCS)
347 344
348/* Set standard debugging functions (not done by default 345/* Set standard debugging functions (not done by default
349 * unless CRYPTO_MDEBUG is defined) */ 346 * unless CRYPTO_MDEBUG is defined) */
350void CRYPTO_malloc_debug_init(void); 347#define CRYPTO_malloc_debug_init() do {\
348 CRYPTO_set_mem_debug_functions(\
349 CRYPTO_dbg_malloc,\
350 CRYPTO_dbg_realloc,\
351 CRYPTO_dbg_free,\
352 CRYPTO_dbg_set_options,\
353 CRYPTO_dbg_get_options);\
354 } while(0)
351 355
352int CRYPTO_mem_ctrl(int mode); 356int CRYPTO_mem_ctrl(int mode);
353int CRYPTO_is_mem_check_on(void); 357int CRYPTO_is_mem_check_on(void);
@@ -420,16 +424,32 @@ void CRYPTO_set_add_lock_callback(int (*func)(int *num,int mount,int type,
420 const char *file, int line)); 424 const char *file, int line));
421int (*CRYPTO_get_add_lock_callback(void))(int *num,int mount,int type, 425int (*CRYPTO_get_add_lock_callback(void))(int *num,int mount,int type,
422 const char *file,int line); 426 const char *file,int line);
427
428/* Don't use this structure directly. */
429typedef struct crypto_threadid_st
430 {
431 void *ptr;
432 unsigned long val;
433 } CRYPTO_THREADID;
434/* Only use CRYPTO_THREADID_set_[numeric|pointer]() within callbacks */
435void CRYPTO_THREADID_set_numeric(CRYPTO_THREADID *id, unsigned long val);
436void CRYPTO_THREADID_set_pointer(CRYPTO_THREADID *id, void *ptr);
437int CRYPTO_THREADID_set_callback(void (*threadid_func)(CRYPTO_THREADID *));
438void (*CRYPTO_THREADID_get_callback(void))(CRYPTO_THREADID *);
439void CRYPTO_THREADID_current(CRYPTO_THREADID *id);
440int CRYPTO_THREADID_cmp(const CRYPTO_THREADID *a, const CRYPTO_THREADID *b);
441void CRYPTO_THREADID_cpy(CRYPTO_THREADID *dest, const CRYPTO_THREADID *src);
442unsigned long CRYPTO_THREADID_hash(const CRYPTO_THREADID *id);
443#ifndef OPENSSL_NO_DEPRECATED
423void CRYPTO_set_id_callback(unsigned long (*func)(void)); 444void CRYPTO_set_id_callback(unsigned long (*func)(void));
424unsigned long (*CRYPTO_get_id_callback(void))(void); 445unsigned long (*CRYPTO_get_id_callback(void))(void);
425unsigned long CRYPTO_thread_id(void); 446unsigned long CRYPTO_thread_id(void);
447#endif
448
426const char *CRYPTO_get_lock_name(int type); 449const char *CRYPTO_get_lock_name(int type);
427int CRYPTO_add_lock(int *pointer,int amount,int type, const char *file, 450int CRYPTO_add_lock(int *pointer,int amount,int type, const char *file,
428 int line); 451 int line);
429 452
430void int_CRYPTO_set_do_dynlock_callback(
431 void (*do_dynlock_cb)(int mode, int type, const char *file, int line));
432
433int CRYPTO_get_new_dynlockid(void); 453int CRYPTO_get_new_dynlockid(void);
434void CRYPTO_destroy_dynlockid(int i); 454void CRYPTO_destroy_dynlockid(int i);
435struct CRYPTO_dynlock_value *CRYPTO_get_dynlock_value(int i); 455struct CRYPTO_dynlock_value *CRYPTO_get_dynlock_value(int i);
@@ -454,10 +474,6 @@ int CRYPTO_set_mem_debug_functions(void (*m)(void *,int,const char *,int,int),
454 void (*f)(void *,int), 474 void (*f)(void *,int),
455 void (*so)(long), 475 void (*so)(long),
456 long (*go)(void)); 476 long (*go)(void));
457void CRYPTO_set_mem_info_functions(
458 int (*push_info_fn)(const char *info, const char *file, int line),
459 int (*pop_info_fn)(void),
460 int (*remove_all_info_fn)(void));
461void CRYPTO_get_mem_functions(void *(**m)(size_t),void *(**r)(void *, size_t), void (**f)(void *)); 477void CRYPTO_get_mem_functions(void *(**m)(size_t),void *(**r)(void *, size_t), void (**f)(void *));
462void CRYPTO_get_locked_mem_functions(void *(**m)(size_t), void (**f)(void *)); 478void CRYPTO_get_locked_mem_functions(void *(**m)(size_t), void (**f)(void *));
463void CRYPTO_get_mem_ex_functions(void *(**m)(size_t,const char *,int), 479void CRYPTO_get_mem_ex_functions(void *(**m)(size_t,const char *,int),
@@ -514,9 +530,6 @@ void CRYPTO_dbg_free(void *addr,int before_p);
514void CRYPTO_dbg_set_options(long bits); 530void CRYPTO_dbg_set_options(long bits);
515long CRYPTO_dbg_get_options(void); 531long CRYPTO_dbg_get_options(void);
516 532
517int CRYPTO_dbg_push_info(const char *info, const char *file, int line);
518int CRYPTO_dbg_pop_info(void);
519int CRYPTO_dbg_remove_all_info(void);
520 533
521#ifndef OPENSSL_NO_FP_API 534#ifndef OPENSSL_NO_FP_API
522void CRYPTO_mem_leaks_fp(FILE *); 535void CRYPTO_mem_leaks_fp(FILE *);
@@ -534,69 +547,12 @@ unsigned long *OPENSSL_ia32cap_loc(void);
534#define OPENSSL_ia32cap (*(OPENSSL_ia32cap_loc())) 547#define OPENSSL_ia32cap (*(OPENSSL_ia32cap_loc()))
535int OPENSSL_isservice(void); 548int OPENSSL_isservice(void);
536 549
537#ifdef OPENSSL_FIPS
538#define FIPS_ERROR_IGNORED(alg) OpenSSLDie(__FILE__, __LINE__, \
539 alg " previous FIPS forbidden algorithm error ignored");
540
541#define FIPS_BAD_ABORT(alg) OpenSSLDie(__FILE__, __LINE__, \
542 #alg " Algorithm forbidden in FIPS mode");
543
544#ifdef OPENSSL_FIPS_STRICT
545#define FIPS_BAD_ALGORITHM(alg) FIPS_BAD_ABORT(alg)
546#else
547#define FIPS_BAD_ALGORITHM(alg) \
548 { \
549 FIPSerr(FIPS_F_HASH_FINAL,FIPS_R_NON_FIPS_METHOD); \
550 ERR_add_error_data(2, "Algorithm=", #alg); \
551 return 0; \
552 }
553#endif
554
555/* Low level digest API blocking macro */
556
557#define FIPS_NON_FIPS_MD_Init(alg) \
558 int alg##_Init(alg##_CTX *c) \
559 { \
560 if (FIPS_mode()) \
561 FIPS_BAD_ALGORITHM(alg) \
562 return private_##alg##_Init(c); \
563 } \
564 int private_##alg##_Init(alg##_CTX *c)
565
566/* For ciphers the API often varies from cipher to cipher and each needs to
567 * be treated as a special case. Variable key length ciphers (Blowfish, RC4,
568 * CAST) however are very similar and can use a blocking macro.
569 */
570
571#define FIPS_NON_FIPS_VCIPHER_Init(alg) \
572 void alg##_set_key(alg##_KEY *key, int len, const unsigned char *data) \
573 { \
574 if (FIPS_mode()) \
575 FIPS_BAD_ABORT(alg) \
576 private_##alg##_set_key(key, len, data); \
577 } \
578 void private_##alg##_set_key(alg##_KEY *key, int len, \
579 const unsigned char *data)
580
581#else
582
583#define FIPS_NON_FIPS_VCIPHER_Init(alg) \
584 void alg##_set_key(alg##_KEY *key, int len, const unsigned char *data)
585
586#define FIPS_NON_FIPS_MD_Init(alg) \
587 int alg##_Init(alg##_CTX *c)
588
589#endif /* def OPENSSL_FIPS */
590
591/* BEGIN ERROR CODES */ 550/* BEGIN ERROR CODES */
592/* The following lines are auto generated by the script mkerr.pl. Any changes 551/* The following lines are auto generated by the script mkerr.pl. Any changes
593 * made after this point may be overwritten when the script is next run. 552 * made after this point may be overwritten when the script is next run.
594 */ 553 */
595void ERR_load_CRYPTO_strings(void); 554void ERR_load_CRYPTO_strings(void);
596 555
597#define OPENSSL_HAVE_INIT 1
598void OPENSSL_init(void);
599
600/* Error codes for the CRYPTO functions. */ 556/* Error codes for the CRYPTO functions. */
601 557
602/* Function codes. */ 558/* Function codes. */
diff --git a/src/lib/libcrypto/des/Makefile.ssl b/src/lib/libcrypto/des/Makefile.ssl
deleted file mode 100644
index 0d9ba2b42f..0000000000
--- a/src/lib/libcrypto/des/Makefile.ssl
+++ /dev/null
@@ -1,316 +0,0 @@
1#
2# SSLeay/crypto/des/Makefile
3#
4
5DIR= des
6TOP= ../..
7CC= cc
8CPP= $(CC) -E
9INCLUDES=-I$(TOP) -I../../include
10CFLAG=-g
11INSTALL_PREFIX=
12OPENSSLDIR= /usr/local/ssl
13INSTALLTOP=/usr/local/ssl
14MAKE= make -f Makefile.ssl
15MAKEDEPPROG= makedepend
16MAKEDEPEND= $(TOP)/util/domd $(TOP) -MD $(MAKEDEPPROG)
17MAKEFILE= Makefile.ssl
18AR= ar r
19RANLIB= ranlib
20DES_ENC= des_enc.o fcrypt_b.o
21# or use
22#DES_ENC= dx86-elf.o yx86-elf.o
23
24CFLAGS= $(INCLUDES) $(CFLAG)
25ASFLAGS= $(INCLUDES) $(ASFLAG)
26
27GENERAL=Makefile
28TEST=destest.c
29APPS=
30
31LIB=$(TOP)/libcrypto.a
32LIBSRC= cbc_cksm.c cbc_enc.c cfb64enc.c cfb_enc.c \
33 ecb3_enc.c ecb_enc.c enc_read.c enc_writ.c \
34 fcrypt.c ofb64enc.c ofb_enc.c pcbc_enc.c \
35 qud_cksm.c rand_key.c rpc_enc.c set_key.c \
36 des_enc.c fcrypt_b.c \
37 xcbc_enc.c \
38 str2key.c cfb64ede.c ofb64ede.c ede_cbcm_enc.c des_old.c des_old2.c \
39 read2pwd.c
40
41LIBOBJ= set_key.o ecb_enc.o cbc_enc.o \
42 ecb3_enc.o cfb64enc.o cfb64ede.o cfb_enc.o ofb64ede.o \
43 enc_read.o enc_writ.o ofb64enc.o \
44 ofb_enc.o str2key.o pcbc_enc.o qud_cksm.o rand_key.o \
45 ${DES_ENC} \
46 fcrypt.o xcbc_enc.o rpc_enc.o cbc_cksm.o \
47 ede_cbcm_enc.o des_old.o des_old2.o read2pwd.o
48
49SRC= $(LIBSRC)
50
51EXHEADER= des.h des_old.h
52HEADER= des_locl.h rpc_des.h spr.h des_ver.h $(EXHEADER)
53
54ALL= $(GENERAL) $(SRC) $(HEADER)
55
56top:
57 (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all)
58
59all: lib
60
61lib: $(LIBOBJ)
62 $(AR) $(LIB) $(LIBOBJ)
63 $(RANLIB) $(LIB) || echo Never mind.
64 @touch lib
65
66des: des.o cbc3_enc.o lib
67 $(CC) $(CFLAGS) -o des des.o cbc3_enc.o $(LIB)
68
69# elf
70asm/dx86-elf.s: asm/des-586.pl ../perlasm/x86asm.pl ../perlasm/cbc.pl
71 (cd asm; $(PERL) des-586.pl elf $(CFLAGS) > dx86-elf.s)
72
73asm/yx86-elf.s: asm/crypt586.pl ../perlasm/x86asm.pl ../perlasm/cbc.pl
74 (cd asm; $(PERL) crypt586.pl elf $(CFLAGS) > yx86-elf.s)
75
76# a.out
77asm/dx86-out.o: asm/dx86unix.cpp
78 $(CPP) -DOUT asm/dx86unix.cpp | as -o asm/dx86-out.o
79
80asm/yx86-out.o: asm/yx86unix.cpp
81 $(CPP) -DOUT asm/yx86unix.cpp | as -o asm/yx86-out.o
82
83# bsdi
84asm/dx86bsdi.o: asm/dx86unix.cpp
85 $(CPP) -DBSDI asm/dx86unix.cpp | sed 's/ :/:/' | as -o asm/dx86bsdi.o
86
87asm/yx86bsdi.o: asm/yx86unix.cpp
88 $(CPP) -DBSDI asm/yx86unix.cpp | sed 's/ :/:/' | as -o asm/yx86bsdi.o
89
90asm/dx86unix.cpp: asm/des-586.pl ../perlasm/x86asm.pl ../perlasm/cbc.pl
91 (cd asm; $(PERL) des-586.pl cpp >dx86unix.cpp)
92
93asm/yx86unix.cpp: asm/crypt586.pl ../perlasm/x86asm.pl
94 (cd asm; $(PERL) crypt586.pl cpp >yx86unix.cpp)
95
96files:
97 $(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO
98
99links:
100 @sh $(TOP)/util/point.sh Makefile.ssl Makefile
101 @$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER)
102 @$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST)
103 @$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS)
104
105install: installs
106
107installs:
108 @for i in $(EXHEADER) ; \
109 do \
110 (cp $$i $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i; \
111 chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i ); \
112 done;
113
114tags:
115 ctags $(SRC)
116
117tests:
118
119lint:
120 lint -DLINT $(INCLUDES) $(SRC)>fluff
121
122depend:
123 $(MAKEDEPEND) -- $(CFLAG) $(INCLUDES) $(DEPFLAG) -- $(PROGS) $(LIBSRC)
124
125dclean:
126 $(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
127 mv -f Makefile.new $(MAKEFILE)
128
129clean:
130 rm -f asm/dx86unix.cpp asm/yx86unix.cpp asm/*-elf.* *.o asm/*.o *.obj des lib tags core .pure .nfs* *.old *.bak fluff
131
132# DO NOT DELETE THIS LINE -- make depend depends on it.
133
134cbc_cksm.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
135cbc_cksm.o: ../../include/openssl/des_old.h ../../include/openssl/e_os2.h
136cbc_cksm.o: ../../include/openssl/opensslconf.h
137cbc_cksm.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
138cbc_cksm.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
139cbc_cksm.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
140cbc_cksm.o: cbc_cksm.c des_locl.h
141cbc_enc.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
142cbc_enc.o: ../../include/openssl/des_old.h ../../include/openssl/e_os2.h
143cbc_enc.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
144cbc_enc.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
145cbc_enc.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
146cbc_enc.o: ../../include/openssl/ui_compat.h cbc_enc.c des_locl.h ncbc_enc.c
147cfb64ede.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
148cfb64ede.o: ../../include/openssl/des_old.h ../../include/openssl/e_os2.h
149cfb64ede.o: ../../include/openssl/opensslconf.h
150cfb64ede.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
151cfb64ede.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
152cfb64ede.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
153cfb64ede.o: cfb64ede.c des_locl.h
154cfb64enc.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
155cfb64enc.o: ../../include/openssl/des_old.h ../../include/openssl/e_os2.h
156cfb64enc.o: ../../include/openssl/opensslconf.h
157cfb64enc.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
158cfb64enc.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
159cfb64enc.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
160cfb64enc.o: cfb64enc.c des_locl.h
161cfb_enc.o: ../../e_os.h ../../include/openssl/crypto.h
162cfb_enc.o: ../../include/openssl/des.h ../../include/openssl/des_old.h
163cfb_enc.o: ../../include/openssl/e_os2.h ../../include/openssl/opensslconf.h
164cfb_enc.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
165cfb_enc.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
166cfb_enc.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
167cfb_enc.o: cfb_enc.c des_locl.h
168des_enc.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
169des_enc.o: ../../include/openssl/des_old.h ../../include/openssl/e_os2.h
170des_enc.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
171des_enc.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
172des_enc.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
173des_enc.o: ../../include/openssl/ui_compat.h des_enc.c des_locl.h ncbc_enc.c
174des_old.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
175des_old.o: ../../include/openssl/des_old.h ../../include/openssl/e_os2.h
176des_old.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
177des_old.o: ../../include/openssl/ossl_typ.h ../../include/openssl/rand.h
178des_old.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
179des_old.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
180des_old.o: ../../include/openssl/ui_compat.h des_old.c
181des_old2.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
182des_old2.o: ../../include/openssl/des_old.h ../../include/openssl/e_os2.h
183des_old2.o: ../../include/openssl/opensslconf.h
184des_old2.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
185des_old2.o: ../../include/openssl/rand.h ../../include/openssl/safestack.h
186des_old2.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
187des_old2.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
188des_old2.o: des_old2.c
189ecb3_enc.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
190ecb3_enc.o: ../../include/openssl/des_old.h ../../include/openssl/e_os2.h
191ecb3_enc.o: ../../include/openssl/opensslconf.h
192ecb3_enc.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
193ecb3_enc.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
194ecb3_enc.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
195ecb3_enc.o: des_locl.h ecb3_enc.c
196ecb_enc.o: ../../include/openssl/bio.h ../../include/openssl/crypto.h
197ecb_enc.o: ../../include/openssl/des.h ../../include/openssl/des_old.h
198ecb_enc.o: ../../include/openssl/e_os2.h ../../include/openssl/opensslconf.h
199ecb_enc.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
200ecb_enc.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
201ecb_enc.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
202ecb_enc.o: des_locl.h des_ver.h ecb_enc.c spr.h
203ede_cbcm_enc.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
204ede_cbcm_enc.o: ../../include/openssl/des_old.h ../../include/openssl/e_os2.h
205ede_cbcm_enc.o: ../../include/openssl/opensslconf.h
206ede_cbcm_enc.o: ../../include/openssl/opensslv.h
207ede_cbcm_enc.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
208ede_cbcm_enc.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
209ede_cbcm_enc.o: ../../include/openssl/ui_compat.h des_locl.h ede_cbcm_enc.c
210enc_read.o: ../../e_os.h ../../include/openssl/bio.h
211enc_read.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
212enc_read.o: ../../include/openssl/des.h ../../include/openssl/des_old.h
213enc_read.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
214enc_read.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
215enc_read.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
216enc_read.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
217enc_read.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
218enc_read.o: ../cryptlib.h des_locl.h enc_read.c
219enc_writ.o: ../../e_os.h ../../include/openssl/bio.h
220enc_writ.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
221enc_writ.o: ../../include/openssl/des.h ../../include/openssl/des_old.h
222enc_writ.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
223enc_writ.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
224enc_writ.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
225enc_writ.o: ../../include/openssl/rand.h ../../include/openssl/safestack.h
226enc_writ.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
227enc_writ.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
228enc_writ.o: ../cryptlib.h des_locl.h enc_writ.c
229fcrypt.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
230fcrypt.o: ../../include/openssl/des_old.h ../../include/openssl/e_os2.h
231fcrypt.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
232fcrypt.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
233fcrypt.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
234fcrypt.o: ../../include/openssl/ui_compat.h des_locl.h fcrypt.c
235fcrypt_b.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
236fcrypt_b.o: ../../include/openssl/des_old.h ../../include/openssl/e_os2.h
237fcrypt_b.o: ../../include/openssl/opensslconf.h
238fcrypt_b.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
239fcrypt_b.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
240fcrypt_b.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
241fcrypt_b.o: des_locl.h fcrypt_b.c
242ofb64ede.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
243ofb64ede.o: ../../include/openssl/des_old.h ../../include/openssl/e_os2.h
244ofb64ede.o: ../../include/openssl/opensslconf.h
245ofb64ede.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
246ofb64ede.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
247ofb64ede.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
248ofb64ede.o: des_locl.h ofb64ede.c
249ofb64enc.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
250ofb64enc.o: ../../include/openssl/des_old.h ../../include/openssl/e_os2.h
251ofb64enc.o: ../../include/openssl/opensslconf.h
252ofb64enc.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
253ofb64enc.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
254ofb64enc.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
255ofb64enc.o: des_locl.h ofb64enc.c
256ofb_enc.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
257ofb_enc.o: ../../include/openssl/des_old.h ../../include/openssl/e_os2.h
258ofb_enc.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
259ofb_enc.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
260ofb_enc.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
261ofb_enc.o: ../../include/openssl/ui_compat.h des_locl.h ofb_enc.c
262pcbc_enc.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
263pcbc_enc.o: ../../include/openssl/des_old.h ../../include/openssl/e_os2.h
264pcbc_enc.o: ../../include/openssl/opensslconf.h
265pcbc_enc.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
266pcbc_enc.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
267pcbc_enc.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
268pcbc_enc.o: des_locl.h pcbc_enc.c
269qud_cksm.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
270qud_cksm.o: ../../include/openssl/des_old.h ../../include/openssl/e_os2.h
271qud_cksm.o: ../../include/openssl/opensslconf.h
272qud_cksm.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
273qud_cksm.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
274qud_cksm.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
275qud_cksm.o: des_locl.h qud_cksm.c
276rand_key.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
277rand_key.o: ../../include/openssl/des_old.h ../../include/openssl/e_os2.h
278rand_key.o: ../../include/openssl/opensslconf.h
279rand_key.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
280rand_key.o: ../../include/openssl/rand.h ../../include/openssl/safestack.h
281rand_key.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
282rand_key.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
283rand_key.o: rand_key.c
284read2pwd.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
285read2pwd.o: ../../include/openssl/des_old.h ../../include/openssl/e_os2.h
286read2pwd.o: ../../include/openssl/opensslconf.h
287read2pwd.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
288read2pwd.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
289read2pwd.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
290read2pwd.o: read2pwd.c
291rpc_enc.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
292rpc_enc.o: ../../include/openssl/des_old.h ../../include/openssl/e_os2.h
293rpc_enc.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
294rpc_enc.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
295rpc_enc.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
296rpc_enc.o: ../../include/openssl/ui_compat.h des_locl.h des_ver.h rpc_des.h
297rpc_enc.o: rpc_enc.c
298set_key.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
299set_key.o: ../../include/openssl/des_old.h ../../include/openssl/e_os2.h
300set_key.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
301set_key.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
302set_key.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
303set_key.o: ../../include/openssl/ui_compat.h des_locl.h set_key.c
304str2key.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
305str2key.o: ../../include/openssl/des_old.h ../../include/openssl/e_os2.h
306str2key.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
307str2key.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
308str2key.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
309str2key.o: ../../include/openssl/ui_compat.h des_locl.h str2key.c
310xcbc_enc.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
311xcbc_enc.o: ../../include/openssl/des_old.h ../../include/openssl/e_os2.h
312xcbc_enc.o: ../../include/openssl/opensslconf.h
313xcbc_enc.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
314xcbc_enc.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
315xcbc_enc.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
316xcbc_enc.o: des_locl.h xcbc_enc.c
diff --git a/src/lib/libcrypto/des/asm/crypt586.pl b/src/lib/libcrypto/des/asm/crypt586.pl
index 1d04ed6def..e36f7d44bd 100644
--- a/src/lib/libcrypto/des/asm/crypt586.pl
+++ b/src/lib/libcrypto/des/asm/crypt586.pl
@@ -6,7 +6,8 @@
6# things perfect. 6# things perfect.
7# 7#
8 8
9push(@INC,"perlasm","../../perlasm"); 9$0 =~ m/(.*[\/\\])[^\/\\]+$/; $dir=$1;
10push(@INC,"${dir}","${dir}../../perlasm");
10require "x86asm.pl"; 11require "x86asm.pl";
11 12
12&asm_init($ARGV[0],"crypt586.pl"); 13&asm_init($ARGV[0],"crypt586.pl");
@@ -22,7 +23,7 @@ sub fcrypt_body
22 { 23 {
23 local($name,$do_ip)=@_; 24 local($name,$do_ip)=@_;
24 25
25 &function_begin($name,"EXTRN _DES_SPtrans:DWORD"); 26 &function_begin($name);
26 27
27 &comment(""); 28 &comment("");
28 &comment("Load the 2 words"); 29 &comment("Load the 2 words");
diff --git a/src/lib/libcrypto/des/asm/des-586.pl b/src/lib/libcrypto/des/asm/des-586.pl
index 60d577cc8d..5b5f39cebd 100644
--- a/src/lib/libcrypto/des/asm/des-586.pl
+++ b/src/lib/libcrypto/des/asm/des-586.pl
@@ -4,7 +4,8 @@
4# Svend Olaf Mikkelsen <svolaf@inet.uni-c.dk> 4# Svend Olaf Mikkelsen <svolaf@inet.uni-c.dk>
5# 5#
6 6
7push(@INC,"perlasm","../../perlasm"); 7$0 =~ m/(.*[\/\\])[^\/\\]+$/; $dir=$1;
8push(@INC,"${dir}","${dir}../../perlasm");
8require "x86asm.pl"; 9require "x86asm.pl";
9require "cbc.pl"; 10require "cbc.pl";
10require "desboth.pl"; 11require "desboth.pl";
@@ -18,33 +19,110 @@ require "desboth.pl";
18 19
19$L="edi"; 20$L="edi";
20$R="esi"; 21$R="esi";
22$trans="ebp";
23$small_footprint=1 if (grep(/\-DOPENSSL_SMALL_FOOTPRINT/,@ARGV));
24# one can discuss setting this variable to 1 unconditionally, as
25# the folded loop is only 3% slower than unrolled, but >7 times smaller
21 26
22&external_label("DES_SPtrans"); 27&public_label("DES_SPtrans");
28
29&DES_encrypt_internal();
30&DES_decrypt_internal();
23&DES_encrypt("DES_encrypt1",1); 31&DES_encrypt("DES_encrypt1",1);
24&DES_encrypt("DES_encrypt2",0); 32&DES_encrypt("DES_encrypt2",0);
33&DES_encrypt3("DES_encrypt3",1);
34&DES_encrypt3("DES_decrypt3",0);
35&cbc("DES_ncbc_encrypt","DES_encrypt1","DES_encrypt1",0,4,5,3,5,-1);
36&cbc("DES_ede3_cbc_encrypt","DES_encrypt3","DES_decrypt3",0,6,7,3,4,5);
37&DES_SPtrans();
38
39&asm_finish();
25 40
26if (!$main'openbsd) 41sub DES_encrypt_internal()
27 { 42 {
28 &DES_encrypt3("DES_encrypt3",1); 43 &function_begin_B("_x86_DES_encrypt");
29 &DES_encrypt3("DES_decrypt3",0); 44
30 &cbc("DES_ncbc_encrypt","DES_encrypt1","DES_encrypt1",0,4,5,3,5,-1); 45 if ($small_footprint)
31 &cbc("DES_ede3_cbc_encrypt","DES_encrypt3","DES_decrypt3",0,6,7,3,4,5); 46 {
47 &lea("edx",&DWP(128,"ecx"));
48 &push("edx");
49 &push("ecx");
50 &set_label("eloop");
51 &D_ENCRYPT(0,$L,$R,0,$trans,"eax","ebx","ecx","edx",&swtmp(0));
52 &comment("");
53 &D_ENCRYPT(1,$R,$L,2,$trans,"eax","ebx","ecx","edx",&swtmp(0));
54 &comment("");
55 &add("ecx",16);
56 &cmp("ecx",&swtmp(1));
57 &mov(&swtmp(0),"ecx");
58 &jb(&label("eloop"));
59 &add("esp",8);
60 }
61 else
62 {
63 &push("ecx");
64 for ($i=0; $i<16; $i+=2)
65 {
66 &comment("Round $i");
67 &D_ENCRYPT($i,$L,$R,$i*2,$trans,"eax","ebx","ecx","edx",&swtmp(0));
68 &comment("Round ".sprintf("%d",$i+1));
69 &D_ENCRYPT($i+1,$R,$L,($i+1)*2,$trans,"eax","ebx","ecx","edx",&swtmp(0));
70 }
71 &add("esp",4);
32 } 72 }
73 &ret();
33 74
34&asm_finish(); 75 &function_end_B("_x86_DES_encrypt");
76 }
77
78sub DES_decrypt_internal()
79 {
80 &function_begin_B("_x86_DES_decrypt");
81
82 if ($small_footprint)
83 {
84 &push("ecx");
85 &lea("ecx",&DWP(128,"ecx"));
86 &push("ecx");
87 &set_label("dloop");
88 &D_ENCRYPT(0,$L,$R,-2,$trans,"eax","ebx","ecx","edx",&swtmp(0));
89 &comment("");
90 &D_ENCRYPT(1,$R,$L,-4,$trans,"eax","ebx","ecx","edx",&swtmp(0));
91 &comment("");
92 &sub("ecx",16);
93 &cmp("ecx",&swtmp(1));
94 &mov(&swtmp(0),"ecx");
95 &ja(&label("dloop"));
96 &add("esp",8);
97 }
98 else
99 {
100 &push("ecx");
101 for ($i=15; $i>0; $i-=2)
102 {
103 &comment("Round $i");
104 &D_ENCRYPT(15-$i,$L,$R,$i*2,$trans,"eax","ebx","ecx","edx",&swtmp(0));
105 &comment("Round ".sprintf("%d",$i-1));
106 &D_ENCRYPT(15-$i+1,$R,$L,($i-1)*2,$trans,"eax","ebx","ecx","edx",&swtmp(0));
107 }
108 &add("esp",4);
109 }
110 &ret();
35 111
112 &function_end_B("_x86_DES_decrypt");
113 }
114
36sub DES_encrypt 115sub DES_encrypt
37 { 116 {
38 local($name,$do_ip)=@_; 117 local($name,$do_ip)=@_;
39 118
40 &function_begin_B($name,"EXTRN _DES_SPtrans:DWORD"); 119 &function_begin_B($name);
41 120
42 &push("esi"); 121 &push("esi");
43 &push("edi"); 122 &push("edi");
44 123
45 &comment(""); 124 &comment("");
46 &comment("Load the 2 words"); 125 &comment("Load the 2 words");
47 $trans="ebp";
48 126
49 if ($do_ip) 127 if ($do_ip)
50 { 128 {
@@ -77,39 +155,20 @@ sub DES_encrypt
77 } 155 }
78 156
79 # PIC-ification:-) 157 # PIC-ification:-)
80 &picmeup($trans,"DES_SPtrans"); 158 &call (&label("pic_point"));
81 #if ($cpp) { &picmeup($trans,"DES_SPtrans"); } 159 &set_label("pic_point");
82 #else { &lea($trans,&DWP("DES_SPtrans")); } 160 &blindpop($trans);
161 &lea ($trans,&DWP(&label("DES_SPtrans")."-".&label("pic_point"),$trans));
83 162
84 &mov( "ecx", &wparam(1) ); 163 &mov( "ecx", &wparam(1) );
85 &cmp("ebx","0");
86 &je(&label("start_decrypt"));
87
88 for ($i=0; $i<16; $i+=2)
89 {
90 &comment("");
91 &comment("Round $i");
92 &D_ENCRYPT($i,$L,$R,$i*2,$trans,"eax","ebx","ecx","edx");
93
94 &comment("");
95 &comment("Round ".sprintf("%d",$i+1));
96 &D_ENCRYPT($i+1,$R,$L,($i+1)*2,$trans,"eax","ebx","ecx","edx");
97 }
98 &jmp(&label("end"));
99 164
100 &set_label("start_decrypt"); 165 &cmp("ebx","0");
101 166 &je(&label("decrypt"));
102 for ($i=15; $i>0; $i-=2) 167 &call("_x86_DES_encrypt");
103 { 168 &jmp(&label("done"));
104 &comment(""); 169 &set_label("decrypt");
105 &comment("Round $i"); 170 &call("_x86_DES_decrypt");
106 &D_ENCRYPT(15-$i,$L,$R,$i*2,$trans,"eax","ebx","ecx","edx"); 171 &set_label("done");
107 &comment("");
108 &comment("Round ".sprintf("%d",$i-1));
109 &D_ENCRYPT(15-$i+1,$R,$L,($i-1)*2,$trans,"eax","ebx","ecx","edx");
110 }
111
112 &set_label("end");
113 172
114 if ($do_ip) 173 if ($do_ip)
115 { 174 {
@@ -143,7 +202,7 @@ sub DES_encrypt
143 202
144sub D_ENCRYPT 203sub D_ENCRYPT
145 { 204 {
146 local($r,$L,$R,$S,$trans,$u,$tmp1,$tmp2,$t)=@_; 205 local($r,$L,$R,$S,$trans,$u,$tmp1,$tmp2,$t,$wp1)=@_;
147 206
148 &mov( $u, &DWP(&n2a($S*4),$tmp2,"",0)); 207 &mov( $u, &DWP(&n2a($S*4),$tmp2,"",0));
149 &xor( $tmp1, $tmp1); 208 &xor( $tmp1, $tmp1);
@@ -170,7 +229,7 @@ sub D_ENCRYPT
170 &and( $t, "0xff" ); 229 &and( $t, "0xff" );
171 &xor( $L, &DWP("0x600",$trans,$tmp1,0)); 230 &xor( $L, &DWP("0x600",$trans,$tmp1,0));
172 &xor( $L, &DWP("0x700",$trans,$tmp2,0)); 231 &xor( $L, &DWP("0x700",$trans,$tmp2,0));
173 &mov( $tmp2, &wparam(1) ); 232 &mov( $tmp2, $wp1 );
174 &xor( $L, &DWP("0x400",$trans,$u,0)); 233 &xor( $L, &DWP("0x400",$trans,$u,0));
175 &xor( $L, &DWP("0x500",$trans,$t,0)); 234 &xor( $L, &DWP("0x500",$trans,$t,0));
176 } 235 }
@@ -253,3 +312,142 @@ sub FP_new
253 &rotr($tt , 4); 312 &rotr($tt , 4);
254 } 313 }
255 314
315sub DES_SPtrans
316 {
317 &set_label("DES_SPtrans",64);
318 &data_word(0x02080800, 0x00080000, 0x02000002, 0x02080802);
319 &data_word(0x02000000, 0x00080802, 0x00080002, 0x02000002);
320 &data_word(0x00080802, 0x02080800, 0x02080000, 0x00000802);
321 &data_word(0x02000802, 0x02000000, 0x00000000, 0x00080002);
322 &data_word(0x00080000, 0x00000002, 0x02000800, 0x00080800);
323 &data_word(0x02080802, 0x02080000, 0x00000802, 0x02000800);
324 &data_word(0x00000002, 0x00000800, 0x00080800, 0x02080002);
325 &data_word(0x00000800, 0x02000802, 0x02080002, 0x00000000);
326 &data_word(0x00000000, 0x02080802, 0x02000800, 0x00080002);
327 &data_word(0x02080800, 0x00080000, 0x00000802, 0x02000800);
328 &data_word(0x02080002, 0x00000800, 0x00080800, 0x02000002);
329 &data_word(0x00080802, 0x00000002, 0x02000002, 0x02080000);
330 &data_word(0x02080802, 0x00080800, 0x02080000, 0x02000802);
331 &data_word(0x02000000, 0x00000802, 0x00080002, 0x00000000);
332 &data_word(0x00080000, 0x02000000, 0x02000802, 0x02080800);
333 &data_word(0x00000002, 0x02080002, 0x00000800, 0x00080802);
334 # nibble 1
335 &data_word(0x40108010, 0x00000000, 0x00108000, 0x40100000);
336 &data_word(0x40000010, 0x00008010, 0x40008000, 0x00108000);
337 &data_word(0x00008000, 0x40100010, 0x00000010, 0x40008000);
338 &data_word(0x00100010, 0x40108000, 0x40100000, 0x00000010);
339 &data_word(0x00100000, 0x40008010, 0x40100010, 0x00008000);
340 &data_word(0x00108010, 0x40000000, 0x00000000, 0x00100010);
341 &data_word(0x40008010, 0x00108010, 0x40108000, 0x40000010);
342 &data_word(0x40000000, 0x00100000, 0x00008010, 0x40108010);
343 &data_word(0x00100010, 0x40108000, 0x40008000, 0x00108010);
344 &data_word(0x40108010, 0x00100010, 0x40000010, 0x00000000);
345 &data_word(0x40000000, 0x00008010, 0x00100000, 0x40100010);
346 &data_word(0x00008000, 0x40000000, 0x00108010, 0x40008010);
347 &data_word(0x40108000, 0x00008000, 0x00000000, 0x40000010);
348 &data_word(0x00000010, 0x40108010, 0x00108000, 0x40100000);
349 &data_word(0x40100010, 0x00100000, 0x00008010, 0x40008000);
350 &data_word(0x40008010, 0x00000010, 0x40100000, 0x00108000);
351 # nibble 2
352 &data_word(0x04000001, 0x04040100, 0x00000100, 0x04000101);
353 &data_word(0x00040001, 0x04000000, 0x04000101, 0x00040100);
354 &data_word(0x04000100, 0x00040000, 0x04040000, 0x00000001);
355 &data_word(0x04040101, 0x00000101, 0x00000001, 0x04040001);
356 &data_word(0x00000000, 0x00040001, 0x04040100, 0x00000100);
357 &data_word(0x00000101, 0x04040101, 0x00040000, 0x04000001);
358 &data_word(0x04040001, 0x04000100, 0x00040101, 0x04040000);
359 &data_word(0x00040100, 0x00000000, 0x04000000, 0x00040101);
360 &data_word(0x04040100, 0x00000100, 0x00000001, 0x00040000);
361 &data_word(0x00000101, 0x00040001, 0x04040000, 0x04000101);
362 &data_word(0x00000000, 0x04040100, 0x00040100, 0x04040001);
363 &data_word(0x00040001, 0x04000000, 0x04040101, 0x00000001);
364 &data_word(0x00040101, 0x04000001, 0x04000000, 0x04040101);
365 &data_word(0x00040000, 0x04000100, 0x04000101, 0x00040100);
366 &data_word(0x04000100, 0x00000000, 0x04040001, 0x00000101);
367 &data_word(0x04000001, 0x00040101, 0x00000100, 0x04040000);
368 # nibble 3
369 &data_word(0x00401008, 0x10001000, 0x00000008, 0x10401008);
370 &data_word(0x00000000, 0x10400000, 0x10001008, 0x00400008);
371 &data_word(0x10401000, 0x10000008, 0x10000000, 0x00001008);
372 &data_word(0x10000008, 0x00401008, 0x00400000, 0x10000000);
373 &data_word(0x10400008, 0x00401000, 0x00001000, 0x00000008);
374 &data_word(0x00401000, 0x10001008, 0x10400000, 0x00001000);
375 &data_word(0x00001008, 0x00000000, 0x00400008, 0x10401000);
376 &data_word(0x10001000, 0x10400008, 0x10401008, 0x00400000);
377 &data_word(0x10400008, 0x00001008, 0x00400000, 0x10000008);
378 &data_word(0x00401000, 0x10001000, 0x00000008, 0x10400000);
379 &data_word(0x10001008, 0x00000000, 0x00001000, 0x00400008);
380 &data_word(0x00000000, 0x10400008, 0x10401000, 0x00001000);
381 &data_word(0x10000000, 0x10401008, 0x00401008, 0x00400000);
382 &data_word(0x10401008, 0x00000008, 0x10001000, 0x00401008);
383 &data_word(0x00400008, 0x00401000, 0x10400000, 0x10001008);
384 &data_word(0x00001008, 0x10000000, 0x10000008, 0x10401000);
385 # nibble 4
386 &data_word(0x08000000, 0x00010000, 0x00000400, 0x08010420);
387 &data_word(0x08010020, 0x08000400, 0x00010420, 0x08010000);
388 &data_word(0x00010000, 0x00000020, 0x08000020, 0x00010400);
389 &data_word(0x08000420, 0x08010020, 0x08010400, 0x00000000);
390 &data_word(0x00010400, 0x08000000, 0x00010020, 0x00000420);
391 &data_word(0x08000400, 0x00010420, 0x00000000, 0x08000020);
392 &data_word(0x00000020, 0x08000420, 0x08010420, 0x00010020);
393 &data_word(0x08010000, 0x00000400, 0x00000420, 0x08010400);
394 &data_word(0x08010400, 0x08000420, 0x00010020, 0x08010000);
395 &data_word(0x00010000, 0x00000020, 0x08000020, 0x08000400);
396 &data_word(0x08000000, 0x00010400, 0x08010420, 0x00000000);
397 &data_word(0x00010420, 0x08000000, 0x00000400, 0x00010020);
398 &data_word(0x08000420, 0x00000400, 0x00000000, 0x08010420);
399 &data_word(0x08010020, 0x08010400, 0x00000420, 0x00010000);
400 &data_word(0x00010400, 0x08010020, 0x08000400, 0x00000420);
401 &data_word(0x00000020, 0x00010420, 0x08010000, 0x08000020);
402 # nibble 5
403 &data_word(0x80000040, 0x00200040, 0x00000000, 0x80202000);
404 &data_word(0x00200040, 0x00002000, 0x80002040, 0x00200000);
405 &data_word(0x00002040, 0x80202040, 0x00202000, 0x80000000);
406 &data_word(0x80002000, 0x80000040, 0x80200000, 0x00202040);
407 &data_word(0x00200000, 0x80002040, 0x80200040, 0x00000000);
408 &data_word(0x00002000, 0x00000040, 0x80202000, 0x80200040);
409 &data_word(0x80202040, 0x80200000, 0x80000000, 0x00002040);
410 &data_word(0x00000040, 0x00202000, 0x00202040, 0x80002000);
411 &data_word(0x00002040, 0x80000000, 0x80002000, 0x00202040);
412 &data_word(0x80202000, 0x00200040, 0x00000000, 0x80002000);
413 &data_word(0x80000000, 0x00002000, 0x80200040, 0x00200000);
414 &data_word(0x00200040, 0x80202040, 0x00202000, 0x00000040);
415 &data_word(0x80202040, 0x00202000, 0x00200000, 0x80002040);
416 &data_word(0x80000040, 0x80200000, 0x00202040, 0x00000000);
417 &data_word(0x00002000, 0x80000040, 0x80002040, 0x80202000);
418 &data_word(0x80200000, 0x00002040, 0x00000040, 0x80200040);
419 # nibble 6
420 &data_word(0x00004000, 0x00000200, 0x01000200, 0x01000004);
421 &data_word(0x01004204, 0x00004004, 0x00004200, 0x00000000);
422 &data_word(0x01000000, 0x01000204, 0x00000204, 0x01004000);
423 &data_word(0x00000004, 0x01004200, 0x01004000, 0x00000204);
424 &data_word(0x01000204, 0x00004000, 0x00004004, 0x01004204);
425 &data_word(0x00000000, 0x01000200, 0x01000004, 0x00004200);
426 &data_word(0x01004004, 0x00004204, 0x01004200, 0x00000004);
427 &data_word(0x00004204, 0x01004004, 0x00000200, 0x01000000);
428 &data_word(0x00004204, 0x01004000, 0x01004004, 0x00000204);
429 &data_word(0x00004000, 0x00000200, 0x01000000, 0x01004004);
430 &data_word(0x01000204, 0x00004204, 0x00004200, 0x00000000);
431 &data_word(0x00000200, 0x01000004, 0x00000004, 0x01000200);
432 &data_word(0x00000000, 0x01000204, 0x01000200, 0x00004200);
433 &data_word(0x00000204, 0x00004000, 0x01004204, 0x01000000);
434 &data_word(0x01004200, 0x00000004, 0x00004004, 0x01004204);
435 &data_word(0x01000004, 0x01004200, 0x01004000, 0x00004004);
436 # nibble 7
437 &data_word(0x20800080, 0x20820000, 0x00020080, 0x00000000);
438 &data_word(0x20020000, 0x00800080, 0x20800000, 0x20820080);
439 &data_word(0x00000080, 0x20000000, 0x00820000, 0x00020080);
440 &data_word(0x00820080, 0x20020080, 0x20000080, 0x20800000);
441 &data_word(0x00020000, 0x00820080, 0x00800080, 0x20020000);
442 &data_word(0x20820080, 0x20000080, 0x00000000, 0x00820000);
443 &data_word(0x20000000, 0x00800000, 0x20020080, 0x20800080);
444 &data_word(0x00800000, 0x00020000, 0x20820000, 0x00000080);
445 &data_word(0x00800000, 0x00020000, 0x20000080, 0x20820080);
446 &data_word(0x00020080, 0x20000000, 0x00000000, 0x00820000);
447 &data_word(0x20800080, 0x20020080, 0x20020000, 0x00800080);
448 &data_word(0x20820000, 0x00000080, 0x00800080, 0x20020000);
449 &data_word(0x20820080, 0x00800000, 0x20800000, 0x20000080);
450 &data_word(0x00820000, 0x00020080, 0x20020080, 0x20800000);
451 &data_word(0x00000080, 0x20820000, 0x00820080, 0x00000000);
452 &data_word(0x20000000, 0x20800080, 0x00020000, 0x00820080);
453 }
diff --git a/src/lib/libcrypto/des/asm/des686.pl b/src/lib/libcrypto/des/asm/des686.pl
deleted file mode 100644
index d3ad5d5edd..0000000000
--- a/src/lib/libcrypto/des/asm/des686.pl
+++ /dev/null
@@ -1,230 +0,0 @@
1#!/usr/local/bin/perl
2
3$prog="des686.pl";
4
5# base code is in microsft
6# op dest, source
7# format.
8#
9
10# WILL NOT WORK ANYMORE WITH desboth.pl
11require "desboth.pl";
12
13if ( ($ARGV[0] eq "elf"))
14 { require "x86unix.pl"; }
15elsif ( ($ARGV[0] eq "a.out"))
16 { $aout=1; require "x86unix.pl"; }
17elsif ( ($ARGV[0] eq "sol"))
18 { $sol=1; require "x86unix.pl"; }
19elsif ( ($ARGV[0] eq "cpp"))
20 { $cpp=1; require "x86unix.pl"; }
21elsif ( ($ARGV[0] eq "win32"))
22 { require "x86ms.pl"; }
23else
24 {
25 print STDERR <<"EOF";
26Pick one target type from
27 elf - linux, FreeBSD etc
28 a.out - old linux
29 sol - x86 solaris
30 cpp - format so x86unix.cpp can be used
31 win32 - Windows 95/Windows NT
32EOF
33 exit(1);
34 }
35
36&comment("Don't even think of reading this code");
37&comment("It was automatically generated by $prog");
38&comment("Which is a perl program used to generate the x86 assember for");
39&comment("any of elf, a.out, Win32, or Solaris");
40&comment("It can be found in SSLeay 0.6.5+ or in libdes 3.26+");
41&comment("eric <eay\@cryptsoft.com>");
42&comment("");
43
44&file("dx86xxxx");
45
46$L="edi";
47$R="esi";
48
49&DES_encrypt("DES_encrypt1",1);
50&DES_encrypt("DES_encrypt2",0);
51
52&DES_encrypt3("DES_encrypt3",1);
53&DES_encrypt3("DES_decrypt3",0);
54
55&file_end();
56
57sub DES_encrypt
58 {
59 local($name,$do_ip)=@_;
60
61 &function_begin($name,"EXTRN _DES_SPtrans:DWORD");
62
63 &comment("");
64 &comment("Load the 2 words");
65 &mov("eax",&wparam(0));
66 &mov($L,&DWP(0,"eax","",0));
67 &mov($R,&DWP(4,"eax","",0));
68
69 $ksp=&wparam(1);
70
71 if ($do_ip)
72 {
73 &comment("");
74 &comment("IP");
75 &IP_new($L,$R,"eax");
76 }
77
78 &comment("");
79 &comment("fixup rotate");
80 &rotl($R,3);
81 &rotl($L,3);
82 &exch($L,$R);
83
84 &comment("");
85 &comment("load counter, key_schedule and enc flag");
86 &mov("eax",&wparam(2)); # get encrypt flag
87 &mov("ebp",&wparam(1)); # get ks
88 &cmp("eax","0");
89 &je(&label("start_decrypt"));
90
91 # encrypting part
92
93 for ($i=0; $i<16; $i+=2)
94 {
95 &comment("");
96 &comment("Round $i");
97 &D_ENCRYPT($L,$R,$i*2,"ebp","DES_SPtrans","ecx","edx","eax","ebx");
98
99 &comment("");
100 &comment("Round ".sprintf("%d",$i+1));
101 &D_ENCRYPT($R,$L,($i+1)*2,"ebp","DES_SPtrans","ecx","edx","eax","ebx");
102 }
103 &jmp(&label("end"));
104
105 &set_label("start_decrypt");
106
107 for ($i=15; $i>0; $i-=2)
108 {
109 &comment("");
110 &comment("Round $i");
111 &D_ENCRYPT($L,$R,$i*2,"ebp","DES_SPtrans","ecx","edx","eax","ebx");
112 &comment("");
113 &comment("Round ".sprintf("%d",$i-1));
114 &D_ENCRYPT($R,$L,($i-1)*2,"ebp","DES_SPtrans","ecx","edx","eax","ebx");
115 }
116
117 &set_label("end");
118
119 &comment("");
120 &comment("Fixup");
121 &rotr($L,3); # r
122 &rotr($R,3); # l
123
124 if ($do_ip)
125 {
126 &comment("");
127 &comment("FP");
128 &FP_new($R,$L,"eax");
129 }
130
131 &mov("eax",&wparam(0));
132 &mov(&DWP(0,"eax","",0),$L);
133 &mov(&DWP(4,"eax","",0),$R);
134
135 &function_end($name);
136 }
137
138
139# The logic is to load R into 2 registers and operate on both at the same time.
140# We also load the 2 R's into 2 more registers so we can do the 'move word down a byte'
141# while also masking the other copy and doing a lookup. We then also accumulate the
142# L value in 2 registers then combine them at the end.
143sub D_ENCRYPT
144 {
145 local($L,$R,$S,$ks,$desSP,$u,$t,$tmp1,$tmp2,$tmp3)=@_;
146
147 &mov( $u, &DWP(&n2a($S*4),$ks,"",0));
148 &mov( $t, &DWP(&n2a(($S+1)*4),$ks,"",0));
149 &xor( $u, $R );
150 &xor( $t, $R );
151 &rotr( $t, 4 );
152
153 # the numbers at the end of the line are origional instruction order
154 &mov( $tmp2, $u ); # 1 2
155 &mov( $tmp1, $t ); # 1 1
156 &and( $tmp2, "0xfc" ); # 1 4
157 &and( $tmp1, "0xfc" ); # 1 3
158 &shr( $t, 8 ); # 1 5
159 &xor( $L, &DWP("0x100+$desSP",$tmp1,"",0)); # 1 7
160 &shr( $u, 8 ); # 1 6
161 &mov( $tmp1, &DWP(" $desSP",$tmp2,"",0)); # 1 8
162
163 &mov( $tmp2, $u ); # 2 2
164 &xor( $L, $tmp1 ); # 1 9
165 &and( $tmp2, "0xfc" ); # 2 4
166 &mov( $tmp1, $t ); # 2 1
167 &and( $tmp1, "0xfc" ); # 2 3
168 &shr( $t, 8 ); # 2 5
169 &xor( $L, &DWP("0x300+$desSP",$tmp1,"",0)); # 2 7
170 &shr( $u, 8 ); # 2 6
171 &mov( $tmp1, &DWP("0x200+$desSP",$tmp2,"",0)); # 2 8
172 &mov( $tmp2, $u ); # 3 2
173
174 &xor( $L, $tmp1 ); # 2 9
175 &and( $tmp2, "0xfc" ); # 3 4
176
177 &mov( $tmp1, $t ); # 3 1
178 &shr( $u, 8 ); # 3 6
179 &and( $tmp1, "0xfc" ); # 3 3
180 &shr( $t, 8 ); # 3 5
181 &xor( $L, &DWP("0x500+$desSP",$tmp1,"",0)); # 3 7
182 &mov( $tmp1, &DWP("0x400+$desSP",$tmp2,"",0)); # 3 8
183
184 &and( $t, "0xfc" ); # 4 1
185 &xor( $L, $tmp1 ); # 3 9
186
187 &and( $u, "0xfc" ); # 4 2
188 &xor( $L, &DWP("0x700+$desSP",$t,"",0)); # 4 3
189 &xor( $L, &DWP("0x600+$desSP",$u,"",0)); # 4 4
190 }
191
192sub PERM_OP
193 {
194 local($a,$b,$tt,$shift,$mask)=@_;
195
196 &mov( $tt, $a );
197 &shr( $tt, $shift );
198 &xor( $tt, $b );
199 &and( $tt, $mask );
200 &xor( $b, $tt );
201 &shl( $tt, $shift );
202 &xor( $a, $tt );
203 }
204
205sub IP_new
206 {
207 local($l,$r,$tt)=@_;
208
209 &PERM_OP($r,$l,$tt, 4,"0x0f0f0f0f");
210 &PERM_OP($l,$r,$tt,16,"0x0000ffff");
211 &PERM_OP($r,$l,$tt, 2,"0x33333333");
212 &PERM_OP($l,$r,$tt, 8,"0x00ff00ff");
213 &PERM_OP($r,$l,$tt, 1,"0x55555555");
214 }
215
216sub FP_new
217 {
218 local($l,$r,$tt)=@_;
219
220 &PERM_OP($l,$r,$tt, 1,"0x55555555");
221 &PERM_OP($r,$l,$tt, 8,"0x00ff00ff");
222 &PERM_OP($l,$r,$tt, 2,"0x33333333");
223 &PERM_OP($r,$l,$tt,16,"0x0000ffff");
224 &PERM_OP($l,$r,$tt, 4,"0x0f0f0f0f");
225 }
226
227sub n2a
228 {
229 sprintf("%d",$_[0]);
230 }
diff --git a/src/lib/libcrypto/des/des-lib.com b/src/lib/libcrypto/des/des-lib.com
index fc2c35a1ce..348f1c0470 100644
--- a/src/lib/libcrypto/des/des-lib.com
+++ b/src/lib/libcrypto/des/des-lib.com
@@ -9,7 +9,7 @@ $! Changes by Richard Levitte <richard@levitte.org>
9$! 9$!
10$! This command files compiles and creates the 10$! This command files compiles and creates the
11$! "[.xxx.EXE.CRYPTO.DES]LIBDES.OLB" library. The "xxx" denotes the machine 11$! "[.xxx.EXE.CRYPTO.DES]LIBDES.OLB" library. The "xxx" denotes the machine
12$! architecture of AXP or VAX. 12$! architecture of ALPHA, IA64 or VAX.
13$! 13$!
14$! It was re-written to try to determine which "C" compiler to try to use 14$! It was re-written to try to determine which "C" compiler to try to use
15$! or the user can specify a compiler in P3. 15$! or the user can specify a compiler in P3.
@@ -45,25 +45,34 @@ $!
45$! 45$!
46$! Check Which Architecture We Are Using. 46$! Check Which Architecture We Are Using.
47$! 47$!
48$ IF (F$GETSYI("CPU").GE.128) 48$ IF (F$GETSYI("CPU").LT.128)
49$ THEN 49$ THEN
50$! 50$!
51$! The Architecture Is AXP. 51$! The Architecture Is VAX
52$! 52$!
53$ ARCH := AXP 53$ ARCH := VAX
54$! 54$!
55$! Else... 55$! Else...
56$! 56$!
57$ ELSE 57$ ELSE
58$! 58$!
59$! The Architecture Is VAX. 59$! The Architecture Is Alpha, IA64 or whatever comes in the future.
60$! 60$!
61$ ARCH := VAX 61$ ARCH = F$EDIT( F$GETSYI( "ARCH_NAME"), "UPCASE")
62$ IF (ARCH .EQS. "") THEN ARCH = "UNK"
62$! 63$!
63$! End The Architecture Check. 64$! End The Architecture Check.
64$! 65$!
65$ ENDIF 66$ ENDIF
66$! 67$!
68$! Define The OBJ Directory Name.
69$!
70$ OBJ_DIR := SYS$DISK:[--.'ARCH'.OBJ.CRYPTO.DES]
71$!
72$! Define The EXE Directory Name.
73$!
74$ EXE_DIR :== SYS$DISK:[--.'ARCH'.EXE.CRYPTO.DES]
75$!
67$! Check To Make Sure We Have Valid Command Line Parameters. 76$! Check To Make Sure We Have Valid Command Line Parameters.
68$! 77$!
69$ GOSUB CHECK_OPTIONS 78$ GOSUB CHECK_OPTIONS
@@ -72,10 +81,6 @@ $! Tell The User What Kind of Machine We Run On.
72$! 81$!
73$ WRITE SYS$OUTPUT "Compiling On A ",ARCH," Machine." 82$ WRITE SYS$OUTPUT "Compiling On A ",ARCH," Machine."
74$! 83$!
75$! Define The OBJ Directory Name.
76$!
77$ OBJ_DIR := SYS$DISK:[--.'ARCH'.OBJ.CRYPTO.DES]
78$!
79$! Check To See If The Architecture Specific OBJ Directory Exists. 84$! Check To See If The Architecture Specific OBJ Directory Exists.
80$! 85$!
81$ IF (F$PARSE(OBJ_DIR).EQS."") 86$ IF (F$PARSE(OBJ_DIR).EQS."")
@@ -89,10 +94,6 @@ $! End The Architecture Specific OBJ Directory Check.
89$! 94$!
90$ ENDIF 95$ ENDIF
91$! 96$!
92$! Define The EXE Directory Name.
93$!
94$ EXE_DIR :== SYS$DISK:[--.'ARCH'.EXE.CRYPTO.DES]
95$!
96$! Check To See If The Architecture Specific Directory Exists. 97$! Check To See If The Architecture Specific Directory Exists.
97$! 98$!
98$ IF (F$PARSE(EXE_DIR).EQS."") 99$ IF (F$PARSE(EXE_DIR).EQS."")
@@ -564,7 +565,7 @@ $!
564$ IF (F$SEARCH(OPT_FILE).EQS."") 565$ IF (F$SEARCH(OPT_FILE).EQS."")
565$ THEN 566$ THEN
566$! 567$!
567$! Figure Out If We Need An AXP Or A VAX Linker Option File. 568$! Figure Out If We Need An non-VAX Or A VAX Linker Option File.
568$! 569$!
569$ IF (F$GETSYI("CPU").LT.128) 570$ IF (F$GETSYI("CPU").LT.128)
570$ THEN 571$ THEN
@@ -584,19 +585,19 @@ $! Else...
584$! 585$!
585$ ELSE 586$ ELSE
586$! 587$!
587$! Create The AXP Linker Option File. 588$! Create The non-VAX Linker Option File.
588$! 589$!
589$ CREATE 'OPT_FILE' 590$ CREATE 'OPT_FILE'
590$DECK 591$DECK
591! 592!
592! Default System Options File For AXP To Link Agianst 593! Default System Options File For non-VAX To Link Agianst
593! The Sharable C Runtime Library. 594! The Sharable C Runtime Library.
594! 595!
595SYS$SHARE:CMA$OPEN_LIB_SHR/SHARE 596SYS$SHARE:CMA$OPEN_LIB_SHR/SHARE
596SYS$SHARE:CMA$OPEN_RTL/SHARE 597SYS$SHARE:CMA$OPEN_RTL/SHARE
597$EOD 598$EOD
598$! 599$!
599$! End The VAX/AXP DEC C Option File Check. 600$! End The DEC C Option File Check.
600$! 601$!
601$ ENDIF 602$ ENDIF
602$! 603$!
@@ -658,13 +659,13 @@ $! Else...
658$! 659$!
659$ ELSE 660$ ELSE
660$! 661$!
661$! Else, Check To See If P1 Has A Valid Arguement. 662$! Else, Check To See If P1 Has A Valid Argument.
662$! 663$!
663$ IF (P1.EQS."LIBRARY").OR.(P1.EQS."DESTEST").OR.(P1.EQS."SPEED") - 664$ IF (P1.EQS."LIBRARY").OR.(P1.EQS."DESTEST").OR.(P1.EQS."SPEED") -
664 .OR.(P1.EQS."RPW").OR.(P1.EQS."DES").OR.(P1.EQS."DES_OPTS") 665 .OR.(P1.EQS."RPW").OR.(P1.EQS."DES").OR.(P1.EQS."DES_OPTS")
665$ THEN 666$ THEN
666$! 667$!
667$! A Valid Arguement. 668$! A Valid Argument.
668$! 669$!
669$ BUILDALL = P1 670$ BUILDALL = P1
670$! 671$!
@@ -677,7 +678,7 @@ $!
677$ WRITE SYS$OUTPUT "" 678$ WRITE SYS$OUTPUT ""
678$ WRITE SYS$OUTPUT "The Option ",P1," Is Invalid. The Valid Options Are:" 679$ WRITE SYS$OUTPUT "The Option ",P1," Is Invalid. The Valid Options Are:"
679$ WRITE SYS$OUTPUT "" 680$ WRITE SYS$OUTPUT ""
680$ WRITE SYS$OUTPUT " ALL : Just Build Everything. 681$ WRITE SYS$OUTPUT " ALL : Just Build Everything."
681$ WRITE SYS$OUTPUT " LIBRARY : To Compile Just The [.xxx.EXE.CRYPTO.DES]LIBDES.OLB Library." 682$ WRITE SYS$OUTPUT " LIBRARY : To Compile Just The [.xxx.EXE.CRYPTO.DES]LIBDES.OLB Library."
682$ WRITE SYS$OUTPUT " DESTEST : To Compile Just The [.xxx.EXE.CRYPTO.DES]DESTEST.EXE Program." 683$ WRITE SYS$OUTPUT " DESTEST : To Compile Just The [.xxx.EXE.CRYPTO.DES]DESTEST.EXE Program."
683$ WRITE SYS$OUTPUT " SPEED : To Compile Just The [.xxx.EXE.CRYPTO.DES]SPEED.EXE Program." 684$ WRITE SYS$OUTPUT " SPEED : To Compile Just The [.xxx.EXE.CRYPTO.DES]SPEED.EXE Program."
@@ -687,15 +688,16 @@ $ WRITE SYS$OUTPUT " DES_OPTS : To Compile Just The [.xxx.EXE.CRYTPO.DES
687$ WRITE SYS$OUTPUT "" 688$ WRITE SYS$OUTPUT ""
688$ WRITE SYS$OUTPUT " Where 'xxx' Stands For: " 689$ WRITE SYS$OUTPUT " Where 'xxx' Stands For: "
689$ WRITE SYS$OUTPUT "" 690$ WRITE SYS$OUTPUT ""
690$ WRITE SYS$OUTPUT " AXP : Alpha Architecture." 691$ WRITE SYS$OUTPUT " ALPHA : Alpha Architecture."
691$ WRITE SYS$OUTPUT " VAX : VAX Architecture." 692$ WRITE SYS$OUTPUT " IA64 : IA64 Architecture."
693$ WRITE SYS$OUTPUT " VAX : VAX Architecture."
692$ WRITE SYS$OUTPUT "" 694$ WRITE SYS$OUTPUT ""
693$! 695$!
694$! Time To EXIT. 696$! Time To EXIT.
695$! 697$!
696$ EXIT 698$ EXIT
697$! 699$!
698$! End The Valid Arguement Check. 700$! End The Valid Argument Check.
699$! 701$!
700$ ENDIF 702$ ENDIF
701$! 703$!
@@ -752,7 +754,7 @@ $! Time To EXIT.
752$! 754$!
753$ EXIT 755$ EXIT
754$! 756$!
755$! End The Valid Arguement Check. 757$! End The Valid Argument Check.
756$! 758$!
757$ ENDIF 759$ ENDIF
758$! 760$!
@@ -817,7 +819,7 @@ $ ELSE
817$! 819$!
818$! Check To See If We Have VAXC Or DECC. 820$! Check To See If We Have VAXC Or DECC.
819$! 821$!
820$ IF (ARCH.EQS."AXP").OR.(F$TRNLNM("DECC$CC_DEFAULT").NES."") 822$ IF (ARCH.NES."VAX").OR.(F$TRNLNM("DECC$CC_DEFAULT").NES."")
821$ THEN 823$ THEN
822$! 824$!
823$! Looks Like DECC, Set To Use DECC. 825$! Looks Like DECC, Set To Use DECC.
@@ -882,7 +884,7 @@ $ CC = CC + "/''CC_OPTIMIZE'/''DEBUGGER'/STANDARD=ANSI89" + -
882$! 884$!
883$! Define The Linker Options File Name. 885$! Define The Linker Options File Name.
884$! 886$!
885$ OPT_FILE = "SYS$DISK:[]VAX_DECC_OPTIONS.OPT" 887$ OPT_FILE = "''EXE_DIR'VAX_DECC_OPTIONS.OPT"
886$! 888$!
887$! End DECC Check. 889$! End DECC Check.
888$! 890$!
@@ -904,9 +906,9 @@ $!
904$! Compile Using VAXC. 906$! Compile Using VAXC.
905$! 907$!
906$ CC = "CC" 908$ CC = "CC"
907$ IF ARCH.EQS."AXP" 909$ IF ARCH.NES."VAX"
908$ THEN 910$ THEN
909$ WRITE SYS$OUTPUT "There is no VAX C on Alpha!" 911$ WRITE SYS$OUTPUT "There is no VAX C on ''ARCH'!"
910$ EXIT 912$ EXIT
911$ ENDIF 913$ ENDIF
912$ IF F$TRNLNM("DECC$CC_DEFAULT").EQS."/DECC" THEN CC = "CC/VAXC" 914$ IF F$TRNLNM("DECC$CC_DEFAULT").EQS."/DECC" THEN CC = "CC/VAXC"
@@ -919,7 +921,7 @@ $ DEFINE/NOLOG SYS SYS$COMMON:[SYSLIB]
919$! 921$!
920$! Define The Linker Options File Name. 922$! Define The Linker Options File Name.
921$! 923$!
922$ OPT_FILE = "SYS$DISK:[]VAX_VAXC_OPTIONS.OPT" 924$ OPT_FILE = "''EXE_DIR'VAX_VAXC_OPTIONS.OPT"
923$! 925$!
924$! End VAXC Check 926$! End VAXC Check
925$! 927$!
@@ -944,7 +946,7 @@ $ CC = "GCC/NOCASE_HACK/''GCC_OPTIMIZE'/''DEBUGGER'/NOLIST" + CCEXTRAFLAGS
944$! 946$!
945$! Define The Linker Options File Name. 947$! Define The Linker Options File Name.
946$! 948$!
947$ OPT_FILE = "SYS$DISK:[]VAX_GNUC_OPTIONS.OPT" 949$ OPT_FILE = "''EXE_DIR'VAX_GNUC_OPTIONS.OPT"
948$! 950$!
949$! End The GNU C Check. 951$! End The GNU C Check.
950$! 952$!
@@ -976,7 +978,7 @@ $! Show user the result
976$! 978$!
977$ WRITE SYS$OUTPUT "Main Compiling Command: ",CC 979$ WRITE SYS$OUTPUT "Main Compiling Command: ",CC
978$! 980$!
979$! Else The User Entered An Invalid Arguement. 981$! Else The User Entered An Invalid Argument.
980$! 982$!
981$ ELSE 983$ ELSE
982$! 984$!
diff --git a/src/lib/libcrypto/des/des_enc.c b/src/lib/libcrypto/des/des_enc.c
index 22701e0669..5c47553a5a 100644
--- a/src/lib/libcrypto/des/des_enc.c
+++ b/src/lib/libcrypto/des/des_enc.c
@@ -57,6 +57,7 @@
57 */ 57 */
58 58
59#include "des_locl.h" 59#include "des_locl.h"
60#include "spr.h"
60 61
61#ifndef OPENBSD_DES_ASM 62#ifndef OPENBSD_DES_ASM
62 63
@@ -109,12 +110,10 @@ void DES_encrypt1(DES_LONG *data, DES_key_schedule *ks, int enc)
109 D_ENCRYPT(l,r,28); /* 15 */ 110 D_ENCRYPT(l,r,28); /* 15 */
110 D_ENCRYPT(r,l,30); /* 16 */ 111 D_ENCRYPT(r,l,30); /* 16 */
111#else 112#else
112 for (i=0; i<32; i+=8) 113 for (i=0; i<32; i+=4)
113 { 114 {
114 D_ENCRYPT(l,r,i+0); /* 1 */ 115 D_ENCRYPT(l,r,i+0); /* 1 */
115 D_ENCRYPT(r,l,i+2); /* 2 */ 116 D_ENCRYPT(r,l,i+2); /* 2 */
116 D_ENCRYPT(l,r,i+4); /* 3 */
117 D_ENCRYPT(r,l,i+6); /* 4 */
118 } 117 }
119#endif 118#endif
120 } 119 }
@@ -138,12 +137,10 @@ void DES_encrypt1(DES_LONG *data, DES_key_schedule *ks, int enc)
138 D_ENCRYPT(l,r, 2); /* 2 */ 137 D_ENCRYPT(l,r, 2); /* 2 */
139 D_ENCRYPT(r,l, 0); /* 1 */ 138 D_ENCRYPT(r,l, 0); /* 1 */
140#else 139#else
141 for (i=30; i>0; i-=8) 140 for (i=30; i>0; i-=4)
142 { 141 {
143 D_ENCRYPT(l,r,i-0); /* 16 */ 142 D_ENCRYPT(l,r,i-0); /* 16 */
144 D_ENCRYPT(r,l,i-2); /* 15 */ 143 D_ENCRYPT(r,l,i-2); /* 15 */
145 D_ENCRYPT(l,r,i-4); /* 14 */
146 D_ENCRYPT(r,l,i-6); /* 13 */
147 } 144 }
148#endif 145#endif
149 } 146 }
@@ -205,12 +202,10 @@ void DES_encrypt2(DES_LONG *data, DES_key_schedule *ks, int enc)
205 D_ENCRYPT(l,r,28); /* 15 */ 202 D_ENCRYPT(l,r,28); /* 15 */
206 D_ENCRYPT(r,l,30); /* 16 */ 203 D_ENCRYPT(r,l,30); /* 16 */
207#else 204#else
208 for (i=0; i<32; i+=8) 205 for (i=0; i<32; i+=4)
209 { 206 {
210 D_ENCRYPT(l,r,i+0); /* 1 */ 207 D_ENCRYPT(l,r,i+0); /* 1 */
211 D_ENCRYPT(r,l,i+2); /* 2 */ 208 D_ENCRYPT(r,l,i+2); /* 2 */
212 D_ENCRYPT(l,r,i+4); /* 3 */
213 D_ENCRYPT(r,l,i+6); /* 4 */
214 } 209 }
215#endif 210#endif
216 } 211 }
@@ -234,12 +229,10 @@ void DES_encrypt2(DES_LONG *data, DES_key_schedule *ks, int enc)
234 D_ENCRYPT(l,r, 2); /* 2 */ 229 D_ENCRYPT(l,r, 2); /* 2 */
235 D_ENCRYPT(r,l, 0); /* 1 */ 230 D_ENCRYPT(r,l, 0); /* 1 */
236#else 231#else
237 for (i=30; i>0; i-=8) 232 for (i=30; i>0; i-=4)
238 { 233 {
239 D_ENCRYPT(l,r,i-0); /* 16 */ 234 D_ENCRYPT(l,r,i-0); /* 16 */
240 D_ENCRYPT(r,l,i-2); /* 15 */ 235 D_ENCRYPT(r,l,i-2); /* 15 */
241 D_ENCRYPT(l,r,i-4); /* 14 */
242 D_ENCRYPT(r,l,i-6); /* 13 */
243 } 236 }
244#endif 237#endif
245 } 238 }
@@ -293,8 +286,6 @@ void DES_decrypt3(DES_LONG *data, DES_key_schedule *ks1,
293 286
294#ifndef DES_DEFAULT_OPTIONS 287#ifndef DES_DEFAULT_OPTIONS
295 288
296#if !defined(OPENSSL_FIPS_DES_ASM)
297
298#undef CBC_ENC_C__DONT_UPDATE_IV 289#undef CBC_ENC_C__DONT_UPDATE_IV
299#include "ncbc_enc.c" /* DES_ncbc_encrypt */ 290#include "ncbc_enc.c" /* DES_ncbc_encrypt */
300 291
@@ -410,6 +401,4 @@ void DES_ede3_cbc_encrypt(const unsigned char *input, unsigned char *output,
410 tin[0]=tin[1]=0; 401 tin[0]=tin[1]=0;
411 } 402 }
412 403
413#endif
414
415#endif /* DES_DEFAULT_OPTIONS */ 404#endif /* DES_DEFAULT_OPTIONS */
diff --git a/src/lib/libcrypto/des/des_lib.c b/src/lib/libcrypto/des/des_lib.c
deleted file mode 100644
index d4b3047932..0000000000
--- a/src/lib/libcrypto/des/des_lib.c
+++ /dev/null
@@ -1,106 +0,0 @@
1/* crypto/des/ecb_enc.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 "des_locl.h"
60#include "des_ver.h"
61#include <openssl/opensslv.h>
62#include <openssl/bio.h>
63
64OPENSSL_GLOBAL const char libdes_version[]="libdes" OPENSSL_VERSION_PTEXT;
65OPENSSL_GLOBAL const char DES_version[]="DES" OPENSSL_VERSION_PTEXT;
66
67const char *DES_options(void)
68 {
69 static int init=1;
70 static char buf[32];
71
72 if (init)
73 {
74 const char *ptr,*unroll,*risc,*size;
75
76#ifdef DES_PTR
77 ptr="ptr";
78#else
79 ptr="idx";
80#endif
81#if defined(DES_RISC1) || defined(DES_RISC2)
82#ifdef DES_RISC1
83 risc="risc1";
84#endif
85#ifdef DES_RISC2
86 risc="risc2";
87#endif
88#else
89 risc="cisc";
90#endif
91#ifdef DES_UNROLL
92 unroll="16";
93#else
94 unroll="4";
95#endif
96 if (sizeof(DES_LONG) != sizeof(long))
97 size="int";
98 else
99 size="long";
100 BIO_snprintf(buf,sizeof buf,"des(%s,%s,%s,%s)",ptr,risc,unroll,
101 size);
102 init=0;
103 }
104 return(buf);
105 }
106
diff --git a/src/lib/libcrypto/des/des_locl.h b/src/lib/libcrypto/des/des_locl.h
index 4b9ecff233..a3b512e9b0 100644
--- a/src/lib/libcrypto/des/des_locl.h
+++ b/src/lib/libcrypto/des/des_locl.h
@@ -61,7 +61,7 @@
61 61
62#include <openssl/e_os2.h> 62#include <openssl/e_os2.h>
63 63
64#if defined(OPENSSL_SYS_WIN32) || defined(OPENSSL_SYS_WIN16) 64#if defined(OPENSSL_SYS_WIN32)
65#ifndef OPENSSL_SYS_MSDOS 65#ifndef OPENSSL_SYS_MSDOS
66#define OPENSSL_SYS_MSDOS 66#define OPENSSL_SYS_MSDOS
67#endif 67#endif
@@ -425,4 +425,8 @@ extern const DES_LONG DES_SPtrans[8][64];
425 425
426void fcrypt_body(DES_LONG *out,DES_key_schedule *ks, 426void fcrypt_body(DES_LONG *out,DES_key_schedule *ks,
427 DES_LONG Eswap0, DES_LONG Eswap1); 427 DES_LONG Eswap0, DES_LONG Eswap1);
428
429#ifdef OPENSSL_SMALL_FOOTPRINT
430#undef DES_UNROLL
431#endif
428#endif 432#endif
diff --git a/src/lib/libcrypto/des/ecb_enc.c b/src/lib/libcrypto/des/ecb_enc.c
index 75ae6cf8bb..0684e769b3 100644
--- a/src/lib/libcrypto/des/ecb_enc.c
+++ b/src/lib/libcrypto/des/ecb_enc.c
@@ -57,7 +57,53 @@
57 */ 57 */
58 58
59#include "des_locl.h" 59#include "des_locl.h"
60#include "spr.h" 60#include "des_ver.h"
61#include <openssl/opensslv.h>
62#include <openssl/bio.h>
63
64OPENSSL_GLOBAL const char libdes_version[]="libdes" OPENSSL_VERSION_PTEXT;
65OPENSSL_GLOBAL const char DES_version[]="DES" OPENSSL_VERSION_PTEXT;
66
67const char *DES_options(void)
68 {
69 static int init=1;
70 static char buf[32];
71
72 if (init)
73 {
74 const char *ptr,*unroll,*risc,*size;
75
76#ifdef DES_PTR
77 ptr="ptr";
78#else
79 ptr="idx";
80#endif
81#if defined(DES_RISC1) || defined(DES_RISC2)
82#ifdef DES_RISC1
83 risc="risc1";
84#endif
85#ifdef DES_RISC2
86 risc="risc2";
87#endif
88#else
89 risc="cisc";
90#endif
91#ifdef DES_UNROLL
92 unroll="16";
93#else
94 unroll="2";
95#endif
96 if (sizeof(DES_LONG) != sizeof(long))
97 size="int";
98 else
99 size="long";
100 BIO_snprintf(buf,sizeof buf,"des(%s,%s,%s,%s)",ptr,risc,unroll,
101 size);
102 init=0;
103 }
104 return(buf);
105 }
106
61 107
62void DES_ecb_encrypt(const_DES_cblock *input, DES_cblock *output, 108void DES_ecb_encrypt(const_DES_cblock *input, DES_cblock *output,
63 DES_key_schedule *ks, int enc) 109 DES_key_schedule *ks, int enc)
diff --git a/src/lib/libcrypto/des/enc_read.c b/src/lib/libcrypto/des/enc_read.c
index e7da2ec66b..edb6620d08 100644
--- a/src/lib/libcrypto/des/enc_read.c
+++ b/src/lib/libcrypto/des/enc_read.c
@@ -63,7 +63,7 @@
63 63
64/* This has some uglies in it but it works - even over sockets. */ 64/* This has some uglies in it but it works - even over sockets. */
65/*extern int errno;*/ 65/*extern int errno;*/
66OPENSSL_IMPLEMENT_GLOBAL(int,DES_rw_mode)=DES_PCBC_MODE; 66OPENSSL_IMPLEMENT_GLOBAL(int,DES_rw_mode,DES_PCBC_MODE)
67 67
68 68
69/* 69/*
@@ -87,6 +87,9 @@ OPENSSL_IMPLEMENT_GLOBAL(int,DES_rw_mode)=DES_PCBC_MODE;
87int DES_enc_read(int fd, void *buf, int len, DES_key_schedule *sched, 87int DES_enc_read(int fd, void *buf, int len, DES_key_schedule *sched,
88 DES_cblock *iv) 88 DES_cblock *iv)
89 { 89 {
90#if defined(OPENSSL_NO_POSIX_IO)
91 return(0);
92#else
90 /* data to be unencrypted */ 93 /* data to be unencrypted */
91 int net_num=0; 94 int net_num=0;
92 static unsigned char *net=NULL; 95 static unsigned char *net=NULL;
@@ -147,7 +150,7 @@ int DES_enc_read(int fd, void *buf, int len, DES_key_schedule *sched,
147 /* first - get the length */ 150 /* first - get the length */
148 while (net_num < HDRSIZE) 151 while (net_num < HDRSIZE)
149 { 152 {
150#ifndef _WIN32 153#ifndef OPENSSL_SYS_WIN32
151 i=read(fd,(void *)&(net[net_num]),HDRSIZE-net_num); 154 i=read(fd,(void *)&(net[net_num]),HDRSIZE-net_num);
152#else 155#else
153 i=_read(fd,(void *)&(net[net_num]),HDRSIZE-net_num); 156 i=_read(fd,(void *)&(net[net_num]),HDRSIZE-net_num);
@@ -173,7 +176,11 @@ int DES_enc_read(int fd, void *buf, int len, DES_key_schedule *sched,
173 net_num=0; 176 net_num=0;
174 while (net_num < rnum) 177 while (net_num < rnum)
175 { 178 {
179#ifndef OPENSSL_SYS_WIN32
176 i=read(fd,(void *)&(net[net_num]),rnum-net_num); 180 i=read(fd,(void *)&(net[net_num]),rnum-net_num);
181#else
182 i=_read(fd,(void *)&(net[net_num]),rnum-net_num);
183#endif
177#ifdef EINTR 184#ifdef EINTR
178 if ((i == -1) && (errno == EINTR)) continue; 185 if ((i == -1) && (errno == EINTR)) continue;
179#endif 186#endif
@@ -228,5 +235,6 @@ int DES_enc_read(int fd, void *buf, int len, DES_key_schedule *sched,
228 } 235 }
229 } 236 }
230 return num; 237 return num;
238#endif /* OPENSSL_NO_POSIX_IO */
231 } 239 }
232 240
diff --git a/src/lib/libcrypto/des/enc_writ.c b/src/lib/libcrypto/des/enc_writ.c
index c2f032c9a6..2353ac1e89 100644
--- a/src/lib/libcrypto/des/enc_writ.c
+++ b/src/lib/libcrypto/des/enc_writ.c
@@ -80,6 +80,9 @@
80int DES_enc_write(int fd, const void *_buf, int len, 80int DES_enc_write(int fd, const void *_buf, int len,
81 DES_key_schedule *sched, DES_cblock *iv) 81 DES_key_schedule *sched, DES_cblock *iv)
82 { 82 {
83#if defined(OPENSSL_NO_POSIX_IO)
84 return (-1);
85#else
83#ifdef _LIBC 86#ifdef _LIBC
84 extern unsigned long time(); 87 extern unsigned long time();
85 extern int write(); 88 extern int write();
@@ -172,4 +175,5 @@ int DES_enc_write(int fd, const void *_buf, int len,
172 } 175 }
173 176
174 return(len); 177 return(len);
178#endif /* OPENSSL_NO_POSIX_IO */
175 } 179 }
diff --git a/src/lib/libcrypto/des/fcrypt_b.c b/src/lib/libcrypto/des/fcrypt_b.c
index c56b461e91..87fc71eb26 100644
--- a/src/lib/libcrypto/des/fcrypt_b.c
+++ b/src/lib/libcrypto/des/fcrypt_b.c
@@ -102,12 +102,10 @@ void fcrypt_body(DES_LONG *out, DES_key_schedule *ks, DES_LONG Eswap0,
102#ifndef DES_UNROLL 102#ifndef DES_UNROLL
103 register int i; 103 register int i;
104 104
105 for (i=0; i<32; i+=8) 105 for (i=0; i<32; i+=4)
106 { 106 {
107 D_ENCRYPT(l,r,i+0); /* 1 */ 107 D_ENCRYPT(l,r,i+0); /* 1 */
108 D_ENCRYPT(r,l,i+2); /* 2 */ 108 D_ENCRYPT(r,l,i+2); /* 2 */
109 D_ENCRYPT(l,r,i+4); /* 1 */
110 D_ENCRYPT(r,l,i+6); /* 2 */
111 } 109 }
112#else 110#else
113 D_ENCRYPT(l,r, 0); /* 1 */ 111 D_ENCRYPT(l,r, 0); /* 1 */
diff --git a/src/lib/libcrypto/des/rpc_des.h b/src/lib/libcrypto/des/rpc_des.h
index efc474f00e..8263c512ab 100644
--- a/src/lib/libcrypto/des/rpc_des.h
+++ b/src/lib/libcrypto/des/rpc_des.h
@@ -124,10 +124,10 @@ struct desparams {
124/* 124/*
125 * Encrypt an arbitrary sized buffer 125 * Encrypt an arbitrary sized buffer
126 */ 126 */
127#define DESIOCBLOCK _IOWR(d, 6, struct desparams) 127#define DESIOCBLOCK _IOWR('d', 6, struct desparams)
128 128
129/* 129/*
130 * Encrypt of small amount of data, quickly 130 * Encrypt of small amount of data, quickly
131 */ 131 */
132#define DESIOCQUICK _IOWR(d, 7, struct desparams) 132#define DESIOCQUICK _IOWR('d', 7, struct desparams)
133 133
diff --git a/src/lib/libcrypto/des/set_key.c b/src/lib/libcrypto/des/set_key.c
index c0806d593c..3004cc3ab3 100644
--- a/src/lib/libcrypto/des/set_key.c
+++ b/src/lib/libcrypto/des/set_key.c
@@ -64,12 +64,8 @@
64 * 1.0 First working version 64 * 1.0 First working version
65 */ 65 */
66#include "des_locl.h" 66#include "des_locl.h"
67#ifdef OPENSSL_FIPS
68#include <openssl/fips.h>
69#endif
70
71 67
72OPENSSL_IMPLEMENT_GLOBAL(int,DES_check_key); /* defaults to false */ 68OPENSSL_IMPLEMENT_GLOBAL(int,DES_check_key,0) /* defaults to false */
73 69
74static const unsigned char odd_parity[256]={ 70static const unsigned char odd_parity[256]={
75 1, 1, 2, 2, 4, 4, 7, 7, 8, 8, 11, 11, 13, 13, 14, 14, 71 1, 1, 2, 2, 4, 4, 7, 7, 8, 8, 11, 11, 13, 13, 14, 14,
@@ -340,7 +336,7 @@ int DES_set_key_checked(const_DES_cblock *key, DES_key_schedule *schedule)
340 336
341void DES_set_key_unchecked(const_DES_cblock *key, DES_key_schedule *schedule) 337void DES_set_key_unchecked(const_DES_cblock *key, DES_key_schedule *schedule)
342 { 338 {
343 static int shifts2[16]={0,0,1,1,1,1,1,1,0,1,1,1,1,1,1,0}; 339 static const int shifts2[16]={0,0,1,1,1,1,1,1,0,1,1,1,1,1,1,0};
344 register DES_LONG c,d,t,s,t2; 340 register DES_LONG c,d,t,s,t2;
345 register const unsigned char *in; 341 register const unsigned char *in;
346 register DES_LONG *k; 342 register DES_LONG *k;
@@ -353,10 +349,6 @@ void DES_set_key_unchecked(const_DES_cblock *key, DES_key_schedule *schedule)
353 k = &schedule->ks->deslong[0]; 349 k = &schedule->ks->deslong[0];
354 in = &(*key)[0]; 350 in = &(*key)[0];
355 351
356#ifdef OPENSSL_FIPS
357 FIPS_selftest_check();
358#endif
359
360 c2l(in,c); 352 c2l(in,c);
361 c2l(in,d); 353 c2l(in,d);
362 354
@@ -413,4 +405,3 @@ void des_fixup_key_parity(des_cblock *key)
413 des_set_odd_parity(key); 405 des_set_odd_parity(key);
414 } 406 }
415*/ 407*/
416
diff --git a/src/lib/libcrypto/des/times/aix.cc b/src/lib/libcrypto/des/times/aix.cc
index e9b2e45751..d96b74e2ce 100644
--- a/src/lib/libcrypto/des/times/aix.cc
+++ b/src/lib/libcrypto/des/times/aix.cc
@@ -2,10 +2,10 @@ From: Paco Garcia <pgarcia@cam.es>
2 2
3This machine is a Bull Estrella Minitower Model MT604-100 3This machine is a Bull Estrella Minitower Model MT604-100
4Processor : PPC604 4Processor : PPC604
5P.Speed : 100MHz 5P.Speed : 100Mhz
6Data/Instr Cache : 16 K 6Data/Instr Cache : 16 K
7L2 Cache : 256 K 7L2 Cache : 256 K
8PCI BUS Speed : 33 MHz 8PCI BUS Speed : 33 Mhz
9TransfRate PCI : 132 MB/s 9TransfRate PCI : 132 MB/s
10Memory : 96 MB 10Memory : 96 MB
11 11
diff --git a/src/lib/libcrypto/des/xcbc_enc.c b/src/lib/libcrypto/des/xcbc_enc.c
index dc0c761b71..058cab6bce 100644
--- a/src/lib/libcrypto/des/xcbc_enc.c
+++ b/src/lib/libcrypto/des/xcbc_enc.c
@@ -61,7 +61,7 @@
61/* RSA's DESX */ 61/* RSA's DESX */
62 62
63#if 0 /* broken code, preserved just in case anyone specifically looks for this */ 63#if 0 /* broken code, preserved just in case anyone specifically looks for this */
64static unsigned char desx_white_in2out[256]={ 64static const unsigned char desx_white_in2out[256]={
650xBD,0x56,0xEA,0xF2,0xA2,0xF1,0xAC,0x2A,0xB0,0x93,0xD1,0x9C,0x1B,0x33,0xFD,0xD0, 650xBD,0x56,0xEA,0xF2,0xA2,0xF1,0xAC,0x2A,0xB0,0x93,0xD1,0x9C,0x1B,0x33,0xFD,0xD0,
660x30,0x04,0xB6,0xDC,0x7D,0xDF,0x32,0x4B,0xF7,0xCB,0x45,0x9B,0x31,0xBB,0x21,0x5A, 660x30,0x04,0xB6,0xDC,0x7D,0xDF,0x32,0x4B,0xF7,0xCB,0x45,0x9B,0x31,0xBB,0x21,0x5A,
670x41,0x9F,0xE1,0xD9,0x4A,0x4D,0x9E,0xDA,0xA0,0x68,0x2C,0xC3,0x27,0x5F,0x80,0x36, 670x41,0x9F,0xE1,0xD9,0x4A,0x4D,0x9E,0xDA,0xA0,0x68,0x2C,0xC3,0x27,0x5F,0x80,0x36,
diff --git a/src/lib/libcrypto/dh/Makefile b/src/lib/libcrypto/dh/Makefile
index d01fa960eb..f23b4f7fde 100644
--- a/src/lib/libcrypto/dh/Makefile
+++ b/src/lib/libcrypto/dh/Makefile
@@ -17,8 +17,10 @@ TEST= dhtest.c
17APPS= 17APPS=
18 18
19LIB=$(TOP)/libcrypto.a 19LIB=$(TOP)/libcrypto.a
20LIBSRC= dh_asn1.c dh_gen.c dh_key.c dh_lib.c dh_check.c dh_err.c dh_depr.c 20LIBSRC= dh_asn1.c dh_gen.c dh_key.c dh_lib.c dh_check.c dh_err.c dh_depr.c \
21LIBOBJ= dh_asn1.o dh_gen.o dh_key.o dh_lib.o dh_check.o dh_err.o dh_depr.o 21 dh_ameth.c dh_pmeth.c dh_prn.c
22LIBOBJ= dh_asn1.o dh_gen.o dh_key.o dh_lib.o dh_check.o dh_err.o dh_depr.o \
23 dh_ameth.o dh_pmeth.o dh_prn.o
22 24
23SRC= $(LIBSRC) 25SRC= $(LIBSRC)
24 26
@@ -33,7 +35,7 @@ top:
33all: lib 35all: lib
34 36
35lib: $(LIBOBJ) 37lib: $(LIBOBJ)
36 $(ARX) $(LIB) $(LIBOBJ) 38 $(AR) $(LIB) $(LIBOBJ)
37 $(RANLIB) $(LIB) || echo Never mind. 39 $(RANLIB) $(LIB) || echo Never mind.
38 @touch lib 40 @touch lib
39 41
@@ -74,6 +76,21 @@ clean:
74 76
75# DO NOT DELETE THIS LINE -- make depend depends on it. 77# DO NOT DELETE THIS LINE -- make depend depends on it.
76 78
79dh_ameth.o: ../../e_os.h ../../include/openssl/asn1.h
80dh_ameth.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
81dh_ameth.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
82dh_ameth.o: ../../include/openssl/dh.h ../../include/openssl/e_os2.h
83dh_ameth.o: ../../include/openssl/ec.h ../../include/openssl/ecdh.h
84dh_ameth.o: ../../include/openssl/ecdsa.h ../../include/openssl/err.h
85dh_ameth.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h
86dh_ameth.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
87dh_ameth.o: ../../include/openssl/opensslconf.h
88dh_ameth.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
89dh_ameth.o: ../../include/openssl/pkcs7.h ../../include/openssl/safestack.h
90dh_ameth.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
91dh_ameth.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h
92dh_ameth.o: ../../include/openssl/x509_vfy.h ../asn1/asn1_locl.h ../cryptlib.h
93dh_ameth.o: dh_ameth.c
77dh_asn1.o: ../../e_os.h ../../include/openssl/asn1.h 94dh_asn1.o: ../../e_os.h ../../include/openssl/asn1.h
78dh_asn1.o: ../../include/openssl/asn1t.h ../../include/openssl/bio.h 95dh_asn1.o: ../../include/openssl/asn1t.h ../../include/openssl/bio.h
79dh_asn1.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h 96dh_asn1.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
@@ -129,11 +146,35 @@ dh_lib.o: ../../include/openssl/crypto.h ../../include/openssl/dh.h
129dh_lib.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h 146dh_lib.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h
130dh_lib.o: ../../include/openssl/ecdh.h ../../include/openssl/ecdsa.h 147dh_lib.o: ../../include/openssl/ecdh.h ../../include/openssl/ecdsa.h
131dh_lib.o: ../../include/openssl/engine.h ../../include/openssl/err.h 148dh_lib.o: ../../include/openssl/engine.h ../../include/openssl/err.h
132dh_lib.o: ../../include/openssl/evp.h ../../include/openssl/fips.h 149dh_lib.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h
133dh_lib.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h 150dh_lib.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
134dh_lib.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h 151dh_lib.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
135dh_lib.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h 152dh_lib.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h
136dh_lib.o: ../../include/openssl/pkcs7.h ../../include/openssl/safestack.h 153dh_lib.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
137dh_lib.o: ../../include/openssl/sha.h ../../include/openssl/stack.h 154dh_lib.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
138dh_lib.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h 155dh_lib.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
139dh_lib.o: ../../include/openssl/x509_vfy.h ../cryptlib.h dh_lib.c 156dh_lib.o: ../cryptlib.h dh_lib.c
157dh_pmeth.o: ../../e_os.h ../../include/openssl/asn1.h
158dh_pmeth.o: ../../include/openssl/asn1t.h ../../include/openssl/bio.h
159dh_pmeth.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
160dh_pmeth.o: ../../include/openssl/crypto.h ../../include/openssl/dh.h
161dh_pmeth.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h
162dh_pmeth.o: ../../include/openssl/ecdh.h ../../include/openssl/ecdsa.h
163dh_pmeth.o: ../../include/openssl/err.h ../../include/openssl/evp.h
164dh_pmeth.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
165dh_pmeth.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
166dh_pmeth.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
167dh_pmeth.o: ../../include/openssl/pkcs7.h ../../include/openssl/safestack.h
168dh_pmeth.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
169dh_pmeth.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h
170dh_pmeth.o: ../../include/openssl/x509_vfy.h ../cryptlib.h ../evp/evp_locl.h
171dh_pmeth.o: dh_pmeth.c
172dh_prn.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h
173dh_prn.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
174dh_prn.o: ../../include/openssl/dh.h ../../include/openssl/e_os2.h
175dh_prn.o: ../../include/openssl/err.h ../../include/openssl/evp.h
176dh_prn.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
177dh_prn.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
178dh_prn.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
179dh_prn.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
180dh_prn.o: ../../include/openssl/symhacks.h ../cryptlib.h dh_prn.c
diff --git a/src/lib/libcrypto/dh/Makefile.ssl b/src/lib/libcrypto/dh/Makefile.ssl
deleted file mode 100644
index e05fc01a12..0000000000
--- a/src/lib/libcrypto/dh/Makefile.ssl
+++ /dev/null
@@ -1,133 +0,0 @@
1#
2# SSLeay/crypto/dh/Makefile
3#
4
5DIR= dh
6TOP= ../..
7CC= cc
8INCLUDES= -I.. -I$(TOP) -I../../include
9CFLAG=-g
10INSTALL_PREFIX=
11OPENSSLDIR= /usr/local/ssl
12INSTALLTOP=/usr/local/ssl
13MAKE= make -f Makefile.ssl
14MAKEDEPPROG= makedepend
15MAKEDEPEND= $(TOP)/util/domd $(TOP) -MD $(MAKEDEPPROG)
16MAKEFILE= Makefile.ssl
17AR= ar r
18
19CFLAGS= $(INCLUDES) $(CFLAG)
20
21GENERAL=Makefile
22TEST= dhtest.c
23APPS=
24
25LIB=$(TOP)/libcrypto.a
26LIBSRC= dh_asn1.c dh_gen.c dh_key.c dh_lib.c dh_check.c dh_err.c
27LIBOBJ= dh_asn1.o dh_gen.o dh_key.o dh_lib.o dh_check.o dh_err.o
28
29SRC= $(LIBSRC)
30
31EXHEADER= dh.h
32HEADER= $(EXHEADER)
33
34ALL= $(GENERAL) $(SRC) $(HEADER)
35
36top:
37 (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all)
38
39all: lib
40
41lib: $(LIBOBJ)
42 $(AR) $(LIB) $(LIBOBJ)
43 $(RANLIB) $(LIB) || echo Never mind.
44 @touch lib
45
46files:
47 $(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO
48
49links:
50 @sh $(TOP)/util/point.sh Makefile.ssl Makefile
51 @$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER)
52 @$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST)
53 @$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS)
54
55install:
56 @for i in $(EXHEADER) ; \
57 do \
58 (cp $$i $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i; \
59 chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i ); \
60 done;
61
62tags:
63 ctags $(SRC)
64
65tests:
66
67lint:
68 lint -DLINT $(INCLUDES) $(SRC)>fluff
69
70depend:
71 $(MAKEDEPEND) -- $(CFLAG) $(INCLUDES) $(DEPFLAG) -- $(PROGS) $(LIBSRC)
72
73dclean:
74 $(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
75 mv -f Makefile.new $(MAKEFILE)
76
77clean:
78 rm -f *.o */*.o *.obj lib tags core .pure .nfs* *.old *.bak fluff
79
80# DO NOT DELETE THIS LINE -- make depend depends on it.
81
82dh_asn1.o: ../../e_os.h ../../include/openssl/asn1.h
83dh_asn1.o: ../../include/openssl/asn1t.h ../../include/openssl/bio.h
84dh_asn1.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
85dh_asn1.o: ../../include/openssl/crypto.h ../../include/openssl/dh.h
86dh_asn1.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
87dh_asn1.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
88dh_asn1.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
89dh_asn1.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
90dh_asn1.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
91dh_asn1.o: ../../include/openssl/symhacks.h ../cryptlib.h dh_asn1.c
92dh_check.o: ../../e_os.h ../../include/openssl/bio.h ../../include/openssl/bn.h
93dh_check.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
94dh_check.o: ../../include/openssl/dh.h ../../include/openssl/e_os2.h
95dh_check.o: ../../include/openssl/err.h ../../include/openssl/lhash.h
96dh_check.o: ../../include/openssl/opensslconf.h
97dh_check.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
98dh_check.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
99dh_check.o: ../../include/openssl/symhacks.h ../cryptlib.h dh_check.c
100dh_err.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
101dh_err.o: ../../include/openssl/crypto.h ../../include/openssl/dh.h
102dh_err.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
103dh_err.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
104dh_err.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
105dh_err.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
106dh_err.o: ../../include/openssl/symhacks.h dh_err.c
107dh_gen.o: ../../e_os.h ../../include/openssl/bio.h ../../include/openssl/bn.h
108dh_gen.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
109dh_gen.o: ../../include/openssl/dh.h ../../include/openssl/e_os2.h
110dh_gen.o: ../../include/openssl/err.h ../../include/openssl/lhash.h
111dh_gen.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
112dh_gen.o: ../../include/openssl/ossl_typ.h ../../include/openssl/safestack.h
113dh_gen.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
114dh_gen.o: ../cryptlib.h dh_gen.c
115dh_key.o: ../../e_os.h ../../include/openssl/bio.h ../../include/openssl/bn.h
116dh_key.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
117dh_key.o: ../../include/openssl/dh.h ../../include/openssl/e_os2.h
118dh_key.o: ../../include/openssl/err.h ../../include/openssl/lhash.h
119dh_key.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
120dh_key.o: ../../include/openssl/ossl_typ.h ../../include/openssl/rand.h
121dh_key.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
122dh_key.o: ../../include/openssl/symhacks.h ../cryptlib.h dh_key.c
123dh_lib.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h
124dh_lib.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
125dh_lib.o: ../../include/openssl/crypto.h ../../include/openssl/dh.h
126dh_lib.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
127dh_lib.o: ../../include/openssl/engine.h ../../include/openssl/err.h
128dh_lib.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
129dh_lib.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
130dh_lib.o: ../../include/openssl/rand.h ../../include/openssl/rsa.h
131dh_lib.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
132dh_lib.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
133dh_lib.o: ../cryptlib.h dh_lib.c
diff --git a/src/lib/libcrypto/dh/dh.h b/src/lib/libcrypto/dh/dh.h
index 10475ac4b3..849309a489 100644
--- a/src/lib/libcrypto/dh/dh.h
+++ b/src/lib/libcrypto/dh/dh.h
@@ -77,8 +77,6 @@
77# define OPENSSL_DH_MAX_MODULUS_BITS 10000 77# define OPENSSL_DH_MAX_MODULUS_BITS 10000
78#endif 78#endif
79 79
80#define OPENSSL_DH_FIPS_MIN_MODULUS_BITS 1024
81
82#define DH_FLAG_CACHE_MONT_P 0x01 80#define DH_FLAG_CACHE_MONT_P 0x01
83#define DH_FLAG_NO_EXP_CONSTTIME 0x02 /* new with 0.9.7h; the built-in DH 81#define DH_FLAG_NO_EXP_CONSTTIME 0x02 /* new with 0.9.7h; the built-in DH
84 * implementation now uses constant time 82 * implementation now uses constant time
@@ -159,7 +157,6 @@ struct dh_st
159 this for backward compatibility: */ 157 this for backward compatibility: */
160#define DH_CHECK_P_NOT_STRONG_PRIME DH_CHECK_P_NOT_SAFE_PRIME 158#define DH_CHECK_P_NOT_STRONG_PRIME DH_CHECK_P_NOT_SAFE_PRIME
161 159
162#define DHparams_dup(x) ASN1_dup_of_const(DH,i2d_DHparams,d2i_DHparams,x)
163#define d2i_DHparams_fp(fp,x) (DH *)ASN1_d2i_fp((char *(*)())DH_new, \ 160#define d2i_DHparams_fp(fp,x) (DH *)ASN1_d2i_fp((char *(*)())DH_new, \
164 (char *(*)())d2i_DHparams,(fp),(unsigned char **)(x)) 161 (char *(*)())d2i_DHparams,(fp),(unsigned char **)(x))
165#define i2d_DHparams_fp(fp,x) ASN1_i2d_fp(i2d_DHparams,(fp), \ 162#define i2d_DHparams_fp(fp,x) ASN1_i2d_fp(i2d_DHparams,(fp), \
@@ -167,12 +164,9 @@ struct dh_st
167#define d2i_DHparams_bio(bp,x) ASN1_d2i_bio_of(DH,DH_new,d2i_DHparams,bp,x) 164#define d2i_DHparams_bio(bp,x) ASN1_d2i_bio_of(DH,DH_new,d2i_DHparams,bp,x)
168#define i2d_DHparams_bio(bp,x) ASN1_i2d_bio_of_const(DH,i2d_DHparams,bp,x) 165#define i2d_DHparams_bio(bp,x) ASN1_i2d_bio_of_const(DH,i2d_DHparams,bp,x)
169 166
170const DH_METHOD *DH_OpenSSL(void); 167DH *DHparams_dup(DH *);
171 168
172#ifdef OPENSSL_FIPS 169const DH_METHOD *DH_OpenSSL(void);
173DH * FIPS_dh_new(void);
174void FIPS_dh_free(DH *dh);
175#endif
176 170
177void DH_set_default_method(const DH_METHOD *meth); 171void DH_set_default_method(const DH_METHOD *meth);
178const DH_METHOD *DH_get_default_method(void); 172const DH_METHOD *DH_get_default_method(void);
@@ -212,6 +206,18 @@ int DHparams_print(BIO *bp, const DH *x);
212int DHparams_print(char *bp, const DH *x); 206int DHparams_print(char *bp, const DH *x);
213#endif 207#endif
214 208
209#define EVP_PKEY_CTX_set_dh_paramgen_prime_len(ctx, len) \
210 EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DH, EVP_PKEY_OP_PARAMGEN, \
211 EVP_PKEY_CTRL_DH_PARAMGEN_PRIME_LEN, len, NULL)
212
213#define EVP_PKEY_CTX_set_dh_paramgen_generator(ctx, gen) \
214 EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DH, EVP_PKEY_OP_PARAMGEN, \
215 EVP_PKEY_CTRL_DH_PARAMGEN_GENERATOR, gen, NULL)
216
217#define EVP_PKEY_CTRL_DH_PARAMGEN_PRIME_LEN (EVP_PKEY_ALG_CTRL + 1)
218#define EVP_PKEY_CTRL_DH_PARAMGEN_GENERATOR (EVP_PKEY_ALG_CTRL + 2)
219
220
215/* BEGIN ERROR CODES */ 221/* BEGIN ERROR CODES */
216/* The following lines are auto generated by the script mkerr.pl. Any changes 222/* The following lines are auto generated by the script mkerr.pl. Any changes
217 * made after this point may be overwritten when the script is next run. 223 * made after this point may be overwritten when the script is next run.
@@ -222,22 +228,31 @@ void ERR_load_DH_strings(void);
222 228
223/* Function codes. */ 229/* Function codes. */
224#define DH_F_COMPUTE_KEY 102 230#define DH_F_COMPUTE_KEY 102
225#define DH_F_DHPARAMS_PRINT 100
226#define DH_F_DHPARAMS_PRINT_FP 101 231#define DH_F_DHPARAMS_PRINT_FP 101
227#define DH_F_DH_BUILTIN_GENPARAMS 106 232#define DH_F_DH_BUILTIN_GENPARAMS 106
228#define DH_F_DH_COMPUTE_KEY 107
229#define DH_F_DH_GENERATE_KEY 108
230#define DH_F_DH_GENERATE_PARAMETERS 109
231#define DH_F_DH_NEW_METHOD 105 233#define DH_F_DH_NEW_METHOD 105
234#define DH_F_DH_PARAM_DECODE 107
235#define DH_F_DH_PRIV_DECODE 110
236#define DH_F_DH_PRIV_ENCODE 111
237#define DH_F_DH_PUB_DECODE 108
238#define DH_F_DH_PUB_ENCODE 109
239#define DH_F_DO_DH_PRINT 100
232#define DH_F_GENERATE_KEY 103 240#define DH_F_GENERATE_KEY 103
233#define DH_F_GENERATE_PARAMETERS 104 241#define DH_F_GENERATE_PARAMETERS 104
242#define DH_F_PKEY_DH_DERIVE 112
243#define DH_F_PKEY_DH_KEYGEN 113
234 244
235/* Reason codes. */ 245/* Reason codes. */
236#define DH_R_BAD_GENERATOR 101 246#define DH_R_BAD_GENERATOR 101
247#define DH_R_BN_DECODE_ERROR 109
248#define DH_R_BN_ERROR 106
249#define DH_R_DECODE_ERROR 104
237#define DH_R_INVALID_PUBKEY 102 250#define DH_R_INVALID_PUBKEY 102
238#define DH_R_KEY_SIZE_TOO_SMALL 104 251#define DH_R_KEYS_NOT_SET 108
239#define DH_R_MODULUS_TOO_LARGE 103 252#define DH_R_MODULUS_TOO_LARGE 103
253#define DH_R_NO_PARAMETERS_SET 107
240#define DH_R_NO_PRIVATE_VALUE 100 254#define DH_R_NO_PRIVATE_VALUE 100
255#define DH_R_PARAMETER_ENCODING_ERROR 105
241 256
242#ifdef __cplusplus 257#ifdef __cplusplus
243} 258}
diff --git a/src/lib/libcrypto/dh/dh_asn1.c b/src/lib/libcrypto/dh/dh_asn1.c
index 76740af2bd..0b4357d605 100644
--- a/src/lib/libcrypto/dh/dh_asn1.c
+++ b/src/lib/libcrypto/dh/dh_asn1.c
@@ -3,7 +3,7 @@
3 * project 2000. 3 * project 2000.
4 */ 4 */
5/* ==================================================================== 5/* ====================================================================
6 * Copyright (c) 2000 The OpenSSL Project. All rights reserved. 6 * Copyright (c) 2000-2005 The OpenSSL Project. All rights reserved.
7 * 7 *
8 * Redistribution and use in source and binary forms, with or without 8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions 9 * modification, are permitted provided that the following conditions
@@ -64,7 +64,8 @@
64#include <openssl/asn1t.h> 64#include <openssl/asn1t.h>
65 65
66/* Override the default free and new methods */ 66/* Override the default free and new methods */
67static int dh_cb(int operation, ASN1_VALUE **pval, const ASN1_ITEM *it) 67static int dh_cb(int operation, ASN1_VALUE **pval, const ASN1_ITEM *it,
68 void *exarg)
68{ 69{
69 if(operation == ASN1_OP_NEW_PRE) { 70 if(operation == ASN1_OP_NEW_PRE) {
70 *pval = (ASN1_VALUE *)DH_new(); 71 *pval = (ASN1_VALUE *)DH_new();
@@ -85,3 +86,8 @@ ASN1_SEQUENCE_cb(DHparams, dh_cb) = {
85} ASN1_SEQUENCE_END_cb(DH, DHparams) 86} ASN1_SEQUENCE_END_cb(DH, DHparams)
86 87
87IMPLEMENT_ASN1_ENCODE_FUNCTIONS_const_fname(DH, DHparams, DHparams) 88IMPLEMENT_ASN1_ENCODE_FUNCTIONS_const_fname(DH, DHparams, DHparams)
89
90DH *DHparams_dup(DH *dh)
91 {
92 return ASN1_item_dup(ASN1_ITEM_rptr(DHparams), dh);
93 }
diff --git a/src/lib/libcrypto/dh/dh_check.c b/src/lib/libcrypto/dh/dh_check.c
index 316cb9221d..066898174e 100644
--- a/src/lib/libcrypto/dh/dh_check.c
+++ b/src/lib/libcrypto/dh/dh_check.c
@@ -70,8 +70,6 @@
70 * should hold. 70 * should hold.
71 */ 71 */
72 72
73#ifndef OPENSSL_FIPS
74
75int DH_check(const DH *dh, int *ret) 73int DH_check(const DH *dh, int *ret)
76 { 74 {
77 int ok=0; 75 int ok=0;
@@ -130,11 +128,11 @@ int DH_check_pub_key(const DH *dh, const BIGNUM *pub_key, int *ret)
130 q=BN_new(); 128 q=BN_new();
131 if (q == NULL) goto err; 129 if (q == NULL) goto err;
132 BN_set_word(q,1); 130 BN_set_word(q,1);
133 if (BN_cmp(pub_key,q) <= 0) 131 if (BN_cmp(pub_key,q)<=0)
134 *ret|=DH_CHECK_PUBKEY_TOO_SMALL; 132 *ret|=DH_CHECK_PUBKEY_TOO_SMALL;
135 BN_copy(q,dh->p); 133 BN_copy(q,dh->p);
136 BN_sub_word(q,1); 134 BN_sub_word(q,1);
137 if (BN_cmp(pub_key,q) >= 0) 135 if (BN_cmp(pub_key,q)>=0)
138 *ret|=DH_CHECK_PUBKEY_TOO_LARGE; 136 *ret|=DH_CHECK_PUBKEY_TOO_LARGE;
139 137
140 ok = 1; 138 ok = 1;
@@ -142,5 +140,3 @@ err:
142 if (q != NULL) BN_free(q); 140 if (q != NULL) BN_free(q);
143 return(ok); 141 return(ok);
144 } 142 }
145
146#endif
diff --git a/src/lib/libcrypto/dh/dh_err.c b/src/lib/libcrypto/dh/dh_err.c
index 13263c81c1..d5cf0c22a3 100644
--- a/src/lib/libcrypto/dh/dh_err.c
+++ b/src/lib/libcrypto/dh/dh_err.c
@@ -1,6 +1,6 @@
1/* crypto/dh/dh_err.c */ 1/* crypto/dh/dh_err.c */
2/* ==================================================================== 2/* ====================================================================
3 * Copyright (c) 1999-2007 The OpenSSL Project. All rights reserved. 3 * Copyright (c) 1999-2006 The OpenSSL Project. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
@@ -71,25 +71,34 @@
71static ERR_STRING_DATA DH_str_functs[]= 71static ERR_STRING_DATA DH_str_functs[]=
72 { 72 {
73{ERR_FUNC(DH_F_COMPUTE_KEY), "COMPUTE_KEY"}, 73{ERR_FUNC(DH_F_COMPUTE_KEY), "COMPUTE_KEY"},
74{ERR_FUNC(DH_F_DHPARAMS_PRINT), "DHparams_print"},
75{ERR_FUNC(DH_F_DHPARAMS_PRINT_FP), "DHparams_print_fp"}, 74{ERR_FUNC(DH_F_DHPARAMS_PRINT_FP), "DHparams_print_fp"},
76{ERR_FUNC(DH_F_DH_BUILTIN_GENPARAMS), "DH_BUILTIN_GENPARAMS"}, 75{ERR_FUNC(DH_F_DH_BUILTIN_GENPARAMS), "DH_BUILTIN_GENPARAMS"},
77{ERR_FUNC(DH_F_DH_COMPUTE_KEY), "DH_compute_key"},
78{ERR_FUNC(DH_F_DH_GENERATE_KEY), "DH_generate_key"},
79{ERR_FUNC(DH_F_DH_GENERATE_PARAMETERS), "DH_generate_parameters"},
80{ERR_FUNC(DH_F_DH_NEW_METHOD), "DH_new_method"}, 76{ERR_FUNC(DH_F_DH_NEW_METHOD), "DH_new_method"},
77{ERR_FUNC(DH_F_DH_PARAM_DECODE), "DH_PARAM_DECODE"},
78{ERR_FUNC(DH_F_DH_PRIV_DECODE), "DH_PRIV_DECODE"},
79{ERR_FUNC(DH_F_DH_PRIV_ENCODE), "DH_PRIV_ENCODE"},
80{ERR_FUNC(DH_F_DH_PUB_DECODE), "DH_PUB_DECODE"},
81{ERR_FUNC(DH_F_DH_PUB_ENCODE), "DH_PUB_ENCODE"},
82{ERR_FUNC(DH_F_DO_DH_PRINT), "DO_DH_PRINT"},
81{ERR_FUNC(DH_F_GENERATE_KEY), "GENERATE_KEY"}, 83{ERR_FUNC(DH_F_GENERATE_KEY), "GENERATE_KEY"},
82{ERR_FUNC(DH_F_GENERATE_PARAMETERS), "GENERATE_PARAMETERS"}, 84{ERR_FUNC(DH_F_GENERATE_PARAMETERS), "GENERATE_PARAMETERS"},
85{ERR_FUNC(DH_F_PKEY_DH_DERIVE), "PKEY_DH_DERIVE"},
86{ERR_FUNC(DH_F_PKEY_DH_KEYGEN), "PKEY_DH_KEYGEN"},
83{0,NULL} 87{0,NULL}
84 }; 88 };
85 89
86static ERR_STRING_DATA DH_str_reasons[]= 90static ERR_STRING_DATA DH_str_reasons[]=
87 { 91 {
88{ERR_REASON(DH_R_BAD_GENERATOR) ,"bad generator"}, 92{ERR_REASON(DH_R_BAD_GENERATOR) ,"bad generator"},
93{ERR_REASON(DH_R_BN_DECODE_ERROR) ,"bn decode error"},
94{ERR_REASON(DH_R_BN_ERROR) ,"bn error"},
95{ERR_REASON(DH_R_DECODE_ERROR) ,"decode error"},
89{ERR_REASON(DH_R_INVALID_PUBKEY) ,"invalid public key"}, 96{ERR_REASON(DH_R_INVALID_PUBKEY) ,"invalid public key"},
90{ERR_REASON(DH_R_KEY_SIZE_TOO_SMALL) ,"key size too small"}, 97{ERR_REASON(DH_R_KEYS_NOT_SET) ,"keys not set"},
91{ERR_REASON(DH_R_MODULUS_TOO_LARGE) ,"modulus too large"}, 98{ERR_REASON(DH_R_MODULUS_TOO_LARGE) ,"modulus too large"},
99{ERR_REASON(DH_R_NO_PARAMETERS_SET) ,"no parameters set"},
92{ERR_REASON(DH_R_NO_PRIVATE_VALUE) ,"no private value"}, 100{ERR_REASON(DH_R_NO_PRIVATE_VALUE) ,"no private value"},
101{ERR_REASON(DH_R_PARAMETER_ENCODING_ERROR),"parameter encoding error"},
93{0,NULL} 102{0,NULL}
94 }; 103 };
95 104
diff --git a/src/lib/libcrypto/dh/dh_gen.c b/src/lib/libcrypto/dh/dh_gen.c
index 999e1deb40..cfd5b11868 100644
--- a/src/lib/libcrypto/dh/dh_gen.c
+++ b/src/lib/libcrypto/dh/dh_gen.c
@@ -66,8 +66,6 @@
66#include <openssl/bn.h> 66#include <openssl/bn.h>
67#include <openssl/dh.h> 67#include <openssl/dh.h>
68 68
69#ifndef OPENSSL_FIPS
70
71static int dh_builtin_genparams(DH *ret, int prime_len, int generator, BN_GENCB *cb); 69static int dh_builtin_genparams(DH *ret, int prime_len, int generator, BN_GENCB *cb);
72 70
73int DH_generate_parameters_ex(DH *ret, int prime_len, int generator, BN_GENCB *cb) 71int DH_generate_parameters_ex(DH *ret, int prime_len, int generator, BN_GENCB *cb)
@@ -175,5 +173,3 @@ err:
175 } 173 }
176 return ok; 174 return ok;
177 } 175 }
178
179#endif
diff --git a/src/lib/libcrypto/dh/dh_key.c b/src/lib/libcrypto/dh/dh_key.c
index 79dd331863..e7db440342 100644
--- a/src/lib/libcrypto/dh/dh_key.c
+++ b/src/lib/libcrypto/dh/dh_key.c
@@ -62,8 +62,6 @@
62#include <openssl/rand.h> 62#include <openssl/rand.h>
63#include <openssl/dh.h> 63#include <openssl/dh.h>
64 64
65#ifndef OPENSSL_FIPS
66
67static int generate_key(DH *dh); 65static int generate_key(DH *dh);
68static 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);
69static int dh_bn_mod_exp(const DH *dh, BIGNUM *r, 67static int dh_bn_mod_exp(const DH *dh, BIGNUM *r,
@@ -263,5 +261,3 @@ static int dh_finish(DH *dh)
263 BN_MONT_CTX_free(dh->method_mont_p); 261 BN_MONT_CTX_free(dh->method_mont_p);
264 return(1); 262 return(1);
265 } 263 }
266
267#endif
diff --git a/src/lib/libcrypto/doc/DSA_get_ex_new_index.pod b/src/lib/libcrypto/doc/DSA_get_ex_new_index.pod
index 4612e708ec..fb6efc1182 100644
--- a/src/lib/libcrypto/doc/DSA_get_ex_new_index.pod
+++ b/src/lib/libcrypto/doc/DSA_get_ex_new_index.pod
@@ -6,7 +6,7 @@ DSA_get_ex_new_index, DSA_set_ex_data, DSA_get_ex_data - add application specifi
6 6
7=head1 SYNOPSIS 7=head1 SYNOPSIS
8 8
9 #include <openssl/DSA.h> 9 #include <openssl/dsa.h>
10 10
11 int DSA_get_ex_new_index(long argl, void *argp, 11 int DSA_get_ex_new_index(long argl, void *argp,
12 CRYPTO_EX_new *new_func, 12 CRYPTO_EX_new *new_func,
diff --git a/src/lib/libcrypto/doc/EVP_DigestInit.pod b/src/lib/libcrypto/doc/EVP_DigestInit.pod
index 236e2fa8d1..37a751b1c5 100644
--- a/src/lib/libcrypto/doc/EVP_DigestInit.pod
+++ b/src/lib/libcrypto/doc/EVP_DigestInit.pod
@@ -64,9 +64,9 @@ EVP digest routines
64 64
65The EVP digest routines are a high level interface to message digests. 65The EVP digest routines are a high level interface to message digests.
66 66
67EVP_MD_CTX_init() initializes digest contet B<ctx>. 67EVP_MD_CTX_init() initializes digest context B<ctx>.
68 68
69EVP_MD_CTX_create() allocates, initializes and returns a digest contet. 69EVP_MD_CTX_create() allocates, initializes and returns a digest context.
70 70
71EVP_DigestInit_ex() sets up digest context B<ctx> to use a digest 71EVP_DigestInit_ex() sets up digest context B<ctx> to use a digest
72B<type> from ENGINE B<impl>. B<ctx> must be initialized before calling this 72B<type> from ENGINE B<impl>. B<ctx> must be initialized before calling this
@@ -102,7 +102,7 @@ the passed context B<ctx> does not have to be initialized, and it always
102uses the default digest implementation. 102uses the default digest implementation.
103 103
104EVP_DigestFinal() is similar to EVP_DigestFinal_ex() except the digest 104EVP_DigestFinal() is similar to EVP_DigestFinal_ex() except the digest
105contet B<ctx> is automatically cleaned up. 105context B<ctx> is automatically cleaned up.
106 106
107EVP_MD_CTX_copy() is similar to EVP_MD_CTX_copy_ex() except the destination 107EVP_MD_CTX_copy() is similar to EVP_MD_CTX_copy_ex() except the destination
108B<out> does not have to be initialized. 108B<out> does not have to be initialized.
@@ -132,7 +132,9 @@ return B<EVP_MD> structures for the MD2, MD5, SHA, SHA1, MDC2 and RIPEMD160 dige
132algorithms respectively. The associated signature algorithm is RSA in each case. 132algorithms respectively. The associated signature algorithm is RSA in each case.
133 133
134EVP_dss() and EVP_dss1() return B<EVP_MD> structures for SHA and SHA1 digest 134EVP_dss() and EVP_dss1() return B<EVP_MD> structures for SHA and SHA1 digest
135algorithms but using DSS (DSA) for the signature algorithm. 135algorithms but using DSS (DSA) for the signature algorithm. Note: there is
136no need to use these pseudo-digests in OpenSSL 1.0.0 and later, they are
137however retained for compatibility.
136 138
137EVP_md_null() is a "null" message digest that does nothing: i.e. the hash it 139EVP_md_null() is a "null" message digest that does nothing: i.e. the hash it
138returns is of zero length. 140returns is of zero length.
@@ -228,12 +230,6 @@ digest name passed on the command line.
228 printf("\n"); 230 printf("\n");
229 } 231 }
230 232
231=head1 BUGS
232
233The link between digests and signing algorithms results in a situation where
234EVP_sha1() must be used with RSA and EVP_dss1() must be used with DSS
235even though they are identical digests.
236
237=head1 SEE ALSO 233=head1 SEE ALSO
238 234
239L<evp(3)|evp(3)>, L<HMAC(3)|HMAC(3)>, L<MD2(3)|MD2(3)>, 235L<evp(3)|evp(3)>, L<HMAC(3)|HMAC(3)>, L<MD2(3)|MD2(3)>,
@@ -253,4 +249,11 @@ EVP_md_null(), EVP_md2(), EVP_md5(), EVP_sha(), EVP_sha1(),
253EVP_dss(), EVP_dss1(), EVP_mdc2() and EVP_ripemd160() were 249EVP_dss(), EVP_dss1(), EVP_mdc2() and EVP_ripemd160() were
254changed to return truely const EVP_MD * in OpenSSL 0.9.7. 250changed to return truely const EVP_MD * in OpenSSL 0.9.7.
255 251
252The link between digests and signing algorithms was fixed in OpenSSL 1.0 and
253later, so now EVP_sha1() can be used with RSA and DSA, there is no need to
254use EVP_dss1() any more.
255
256OpenSSL 1.0 and later does not include the MD2 digest algorithm in the
257default configuration due to its security weaknesses.
258
256=cut 259=cut
diff --git a/src/lib/libcrypto/doc/EVP_SignInit.pod b/src/lib/libcrypto/doc/EVP_SignInit.pod
index 0bace24938..781d43e401 100644
--- a/src/lib/libcrypto/doc/EVP_SignInit.pod
+++ b/src/lib/libcrypto/doc/EVP_SignInit.pod
@@ -77,6 +77,15 @@ will occur.
77Older versions of this documentation wrongly stated that calls to 77Older versions of this documentation wrongly stated that calls to
78EVP_SignUpdate() could not be made after calling EVP_SignFinal(). 78EVP_SignUpdate() could not be made after calling EVP_SignFinal().
79 79
80Since the private key is passed in the call to EVP_SignFinal() any error
81relating to the private key (for example an unsuitable key and digest
82combination) will not be indicated until after potentially large amounts of
83data have been passed through EVP_SignUpdate().
84
85It is not possible to change the signing parameters using these function.
86
87The previous two bugs are fixed in the newer EVP_SignDigest*() function.
88
80=head1 SEE ALSO 89=head1 SEE ALSO
81 90
82L<EVP_VerifyInit(3)|EVP_VerifyInit(3)>, 91L<EVP_VerifyInit(3)|EVP_VerifyInit(3)>,
diff --git a/src/lib/libcrypto/doc/EVP_VerifyInit.pod b/src/lib/libcrypto/doc/EVP_VerifyInit.pod
index b6afaedee5..9097f09410 100644
--- a/src/lib/libcrypto/doc/EVP_VerifyInit.pod
+++ b/src/lib/libcrypto/doc/EVP_VerifyInit.pod
@@ -67,6 +67,15 @@ will occur.
67Older versions of this documentation wrongly stated that calls to 67Older versions of this documentation wrongly stated that calls to
68EVP_VerifyUpdate() could not be made after calling EVP_VerifyFinal(). 68EVP_VerifyUpdate() could not be made after calling EVP_VerifyFinal().
69 69
70Since the public key is passed in the call to EVP_SignFinal() any error
71relating to the private key (for example an unsuitable key and digest
72combination) will not be indicated until after potentially large amounts of
73data have been passed through EVP_SignUpdate().
74
75It is not possible to change the signing parameters using these function.
76
77The previous two bugs are fixed in the newer EVP_VerifyDigest*() function.
78
70=head1 SEE ALSO 79=head1 SEE ALSO
71 80
72L<evp(3)|evp(3)>, 81L<evp(3)|evp(3)>,
diff --git a/src/lib/libcrypto/doc/d2i_RSAPublicKey.pod b/src/lib/libcrypto/doc/d2i_RSAPublicKey.pod
index 279b29c873..aa6078bcf6 100644
--- a/src/lib/libcrypto/doc/d2i_RSAPublicKey.pod
+++ b/src/lib/libcrypto/doc/d2i_RSAPublicKey.pod
@@ -11,21 +11,21 @@ d2i_Netscape_RSA - RSA public and private key encoding functions.
11 #include <openssl/rsa.h> 11 #include <openssl/rsa.h>
12 #include <openssl/x509.h> 12 #include <openssl/x509.h>
13 13
14 RSA * d2i_RSAPublicKey(RSA **a, unsigned char **pp, long length); 14 RSA * d2i_RSAPublicKey(RSA **a, const unsigned char **pp, long length);
15 15
16 int i2d_RSAPublicKey(RSA *a, unsigned char **pp); 16 int i2d_RSAPublicKey(RSA *a, unsigned char **pp);
17 17
18 RSA * d2i_RSA_PUBKEY(RSA **a, unsigned char **pp, long length); 18 RSA * d2i_RSA_PUBKEY(RSA **a, const unsigned char **pp, long length);
19 19
20 int i2d_RSA_PUBKEY(RSA *a, unsigned char **pp); 20 int i2d_RSA_PUBKEY(RSA *a, unsigned char **pp);
21 21
22 RSA * d2i_RSAPrivateKey(RSA **a, unsigned char **pp, long length); 22 RSA * d2i_RSAPrivateKey(RSA **a, const unsigned char **pp, long length);
23 23
24 int i2d_RSAPrivateKey(RSA *a, unsigned char **pp); 24 int i2d_RSAPrivateKey(RSA *a, unsigned char **pp);
25 25
26 int i2d_Netscape_RSA(RSA *a, unsigned char **pp, int (*cb)()); 26 int i2d_Netscape_RSA(RSA *a, unsigned char **pp, int (*cb)());
27 27
28 RSA * d2i_Netscape_RSA(RSA **a, unsigned char **pp, long length, int (*cb)()); 28 RSA * d2i_Netscape_RSA(RSA **a, const unsigned char **pp, long length, int (*cb)());
29 29
30=head1 DESCRIPTION 30=head1 DESCRIPTION
31 31
diff --git a/src/lib/libcrypto/doc/evp.pod b/src/lib/libcrypto/doc/evp.pod
index b3ca14314f..9faa349243 100644
--- a/src/lib/libcrypto/doc/evp.pod
+++ b/src/lib/libcrypto/doc/evp.pod
@@ -22,14 +22,24 @@ digital signatures.
22Symmetric encryption is available with the B<EVP_Encrypt>I<...> 22Symmetric encryption is available with the B<EVP_Encrypt>I<...>
23functions. The B<EVP_Digest>I<...> functions provide message digests. 23functions. The B<EVP_Digest>I<...> functions provide message digests.
24 24
25The B<EVP_PKEY>I<...> functions provide a high level interface to
26asymmetric algorithms.
27
25Algorithms are loaded with OpenSSL_add_all_algorithms(3). 28Algorithms are loaded with OpenSSL_add_all_algorithms(3).
26 29
27All the symmetric algorithms (ciphers) and digests can be replaced by ENGINE 30All the symmetric algorithms (ciphers), digests and asymmetric algorithms
28modules providing alternative implementations. If ENGINE implementations of 31(public key algorithms) can be replaced by ENGINE modules providing alternative
29ciphers or digests are registered as defaults, then the various EVP functions 32implementations. If ENGINE implementations of ciphers or digests are registered
30will automatically use those implementations automatically in preference to 33as defaults, then the various EVP functions will automatically use those
31built in software implementations. For more information, consult the engine(3) 34implementations automatically in preference to built in software
32man page. 35implementations. For more information, consult the engine(3) man page.
36
37Although low level algorithm specific functions exist for many algorithms
38their use is discouraged. They cannot be used with an ENGINE and ENGINE
39versions of new algorithms cannot be accessed using the low level functions.
40Also makes code harder to adapt to new algorithms and some options are not
41cleanly supported at the low level and some operations are more efficient
42using the high level interface.
33 43
34=head1 SEE ALSO 44=head1 SEE ALSO
35 45
diff --git a/src/lib/libcrypto/dsa/Makefile b/src/lib/libcrypto/dsa/Makefile
index 2cc45cdc62..8073c4ecfe 100644
--- a/src/lib/libcrypto/dsa/Makefile
+++ b/src/lib/libcrypto/dsa/Makefile
@@ -18,14 +18,14 @@ APPS=
18 18
19LIB=$(TOP)/libcrypto.a 19LIB=$(TOP)/libcrypto.a
20LIBSRC= dsa_gen.c dsa_key.c dsa_lib.c dsa_asn1.c dsa_vrf.c dsa_sign.c \ 20LIBSRC= dsa_gen.c dsa_key.c dsa_lib.c dsa_asn1.c dsa_vrf.c dsa_sign.c \
21 dsa_err.c dsa_ossl.c dsa_depr.c dsa_utl.c 21 dsa_err.c dsa_ossl.c dsa_depr.c dsa_ameth.c dsa_pmeth.c dsa_prn.c
22LIBOBJ= dsa_gen.o dsa_key.o dsa_lib.o dsa_asn1.o dsa_vrf.o dsa_sign.o \ 22LIBOBJ= dsa_gen.o dsa_key.o dsa_lib.o dsa_asn1.o dsa_vrf.o dsa_sign.o \
23 dsa_err.o dsa_ossl.o dsa_depr.o dsa_utl.o 23 dsa_err.o dsa_ossl.o dsa_depr.o dsa_ameth.o dsa_pmeth.o dsa_prn.o
24 24
25SRC= $(LIBSRC) 25SRC= $(LIBSRC)
26 26
27EXHEADER= dsa.h 27EXHEADER= dsa.h
28HEADER= $(EXHEADER) 28HEADER= dsa_locl.h $(EXHEADER)
29 29
30ALL= $(GENERAL) $(SRC) $(HEADER) 30ALL= $(GENERAL) $(SRC) $(HEADER)
31 31
@@ -35,7 +35,7 @@ top:
35all: lib 35all: lib
36 36
37lib: $(LIBOBJ) 37lib: $(LIBOBJ)
38 $(ARX) $(LIB) $(LIBOBJ) 38 $(AR) $(LIB) $(LIBOBJ)
39 $(RANLIB) $(LIB) || echo Never mind. 39 $(RANLIB) $(LIB) || echo Never mind.
40 @touch lib 40 @touch lib
41 41
@@ -76,12 +76,27 @@ clean:
76 76
77# DO NOT DELETE THIS LINE -- make depend depends on it. 77# DO NOT DELETE THIS LINE -- make depend depends on it.
78 78
79dsa_ameth.o: ../../e_os.h ../../include/openssl/asn1.h
80dsa_ameth.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
81dsa_ameth.o: ../../include/openssl/buffer.h ../../include/openssl/cms.h
82dsa_ameth.o: ../../include/openssl/crypto.h ../../include/openssl/dsa.h
83dsa_ameth.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h
84dsa_ameth.o: ../../include/openssl/ecdh.h ../../include/openssl/ecdsa.h
85dsa_ameth.o: ../../include/openssl/err.h ../../include/openssl/evp.h
86dsa_ameth.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
87dsa_ameth.o: ../../include/openssl/objects.h
88dsa_ameth.o: ../../include/openssl/opensslconf.h
89dsa_ameth.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
90dsa_ameth.o: ../../include/openssl/pkcs7.h ../../include/openssl/safestack.h
91dsa_ameth.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
92dsa_ameth.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h
93dsa_ameth.o: ../../include/openssl/x509_vfy.h ../asn1/asn1_locl.h ../cryptlib.h
94dsa_ameth.o: dsa_ameth.c
79dsa_asn1.o: ../../e_os.h ../../include/openssl/asn1.h 95dsa_asn1.o: ../../e_os.h ../../include/openssl/asn1.h
80dsa_asn1.o: ../../include/openssl/asn1t.h ../../include/openssl/bio.h 96dsa_asn1.o: ../../include/openssl/asn1t.h ../../include/openssl/bio.h
81dsa_asn1.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h 97dsa_asn1.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
82dsa_asn1.o: ../../include/openssl/crypto.h ../../include/openssl/dsa.h 98dsa_asn1.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
83dsa_asn1.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h 99dsa_asn1.o: ../../include/openssl/err.h ../../include/openssl/lhash.h
84dsa_asn1.o: ../../include/openssl/fips.h ../../include/openssl/lhash.h
85dsa_asn1.o: ../../include/openssl/opensslconf.h 100dsa_asn1.o: ../../include/openssl/opensslconf.h
86dsa_asn1.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h 101dsa_asn1.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
87dsa_asn1.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h 102dsa_asn1.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
@@ -91,9 +106,8 @@ dsa_depr.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
91dsa_depr.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 106dsa_depr.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
92dsa_depr.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h 107dsa_depr.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
93dsa_depr.o: ../../include/openssl/err.h ../../include/openssl/evp.h 108dsa_depr.o: ../../include/openssl/err.h ../../include/openssl/evp.h
94dsa_depr.o: ../../include/openssl/fips.h ../../include/openssl/lhash.h 109dsa_depr.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
95dsa_depr.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h 110dsa_depr.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
96dsa_depr.o: ../../include/openssl/opensslconf.h
97dsa_depr.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h 111dsa_depr.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
98dsa_depr.o: ../../include/openssl/rand.h ../../include/openssl/safestack.h 112dsa_depr.o: ../../include/openssl/rand.h ../../include/openssl/safestack.h
99dsa_depr.o: ../../include/openssl/sha.h ../../include/openssl/stack.h 113dsa_depr.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
@@ -110,13 +124,12 @@ dsa_gen.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
110dsa_gen.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 124dsa_gen.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
111dsa_gen.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h 125dsa_gen.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
112dsa_gen.o: ../../include/openssl/err.h ../../include/openssl/evp.h 126dsa_gen.o: ../../include/openssl/err.h ../../include/openssl/evp.h
113dsa_gen.o: ../../include/openssl/fips.h ../../include/openssl/lhash.h 127dsa_gen.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
114dsa_gen.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h 128dsa_gen.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
115dsa_gen.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h 129dsa_gen.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
116dsa_gen.o: ../../include/openssl/ossl_typ.h ../../include/openssl/rand.h 130dsa_gen.o: ../../include/openssl/rand.h ../../include/openssl/safestack.h
117dsa_gen.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h 131dsa_gen.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
118dsa_gen.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 132dsa_gen.o: ../../include/openssl/symhacks.h ../cryptlib.h dsa_gen.c dsa_locl.h
119dsa_gen.o: ../cryptlib.h dsa_gen.c
120dsa_key.o: ../../e_os.h ../../include/openssl/bio.h ../../include/openssl/bn.h 133dsa_key.o: ../../e_os.h ../../include/openssl/bio.h ../../include/openssl/bn.h
121dsa_key.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 134dsa_key.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
122dsa_key.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h 135dsa_key.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
@@ -132,14 +145,14 @@ dsa_lib.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
132dsa_lib.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h 145dsa_lib.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h
133dsa_lib.o: ../../include/openssl/ecdh.h ../../include/openssl/ecdsa.h 146dsa_lib.o: ../../include/openssl/ecdh.h ../../include/openssl/ecdsa.h
134dsa_lib.o: ../../include/openssl/engine.h ../../include/openssl/err.h 147dsa_lib.o: ../../include/openssl/engine.h ../../include/openssl/err.h
135dsa_lib.o: ../../include/openssl/evp.h ../../include/openssl/fips.h 148dsa_lib.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h
136dsa_lib.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h 149dsa_lib.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
137dsa_lib.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h 150dsa_lib.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
138dsa_lib.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h 151dsa_lib.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h
139dsa_lib.o: ../../include/openssl/pkcs7.h ../../include/openssl/safestack.h 152dsa_lib.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
140dsa_lib.o: ../../include/openssl/sha.h ../../include/openssl/stack.h 153dsa_lib.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
141dsa_lib.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h 154dsa_lib.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
142dsa_lib.o: ../../include/openssl/x509_vfy.h ../cryptlib.h dsa_lib.c 155dsa_lib.o: ../cryptlib.h dsa_lib.c
143dsa_ossl.o: ../../e_os.h ../../include/openssl/asn1.h 156dsa_ossl.o: ../../e_os.h ../../include/openssl/asn1.h
144dsa_ossl.o: ../../include/openssl/bio.h ../../include/openssl/bn.h 157dsa_ossl.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
145dsa_ossl.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 158dsa_ossl.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
@@ -148,40 +161,48 @@ dsa_ossl.o: ../../include/openssl/err.h ../../include/openssl/lhash.h
148dsa_ossl.o: ../../include/openssl/opensslconf.h 161dsa_ossl.o: ../../include/openssl/opensslconf.h
149dsa_ossl.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h 162dsa_ossl.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
150dsa_ossl.o: ../../include/openssl/rand.h ../../include/openssl/safestack.h 163dsa_ossl.o: ../../include/openssl/rand.h ../../include/openssl/safestack.h
151dsa_ossl.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 164dsa_ossl.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
152dsa_ossl.o: ../cryptlib.h dsa_ossl.c 165dsa_ossl.o: ../../include/openssl/symhacks.h ../cryptlib.h dsa_ossl.c
153dsa_sign.o: ../../e_os.h ../../include/openssl/asn1.h 166dsa_pmeth.o: ../../e_os.h ../../include/openssl/asn1.h
154dsa_sign.o: ../../include/openssl/bio.h ../../include/openssl/bn.h 167dsa_pmeth.o: ../../include/openssl/asn1t.h ../../include/openssl/bio.h
168dsa_pmeth.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
169dsa_pmeth.o: ../../include/openssl/crypto.h ../../include/openssl/dsa.h
170dsa_pmeth.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h
171dsa_pmeth.o: ../../include/openssl/ecdh.h ../../include/openssl/ecdsa.h
172dsa_pmeth.o: ../../include/openssl/err.h ../../include/openssl/evp.h
173dsa_pmeth.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
174dsa_pmeth.o: ../../include/openssl/objects.h
175dsa_pmeth.o: ../../include/openssl/opensslconf.h
176dsa_pmeth.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
177dsa_pmeth.o: ../../include/openssl/pkcs7.h ../../include/openssl/safestack.h
178dsa_pmeth.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
179dsa_pmeth.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h
180dsa_pmeth.o: ../../include/openssl/x509_vfy.h ../cryptlib.h ../evp/evp_locl.h
181dsa_pmeth.o: dsa_locl.h dsa_pmeth.c
182dsa_prn.o: ../../e_os.h ../../include/openssl/asn1.h
183dsa_prn.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
184dsa_prn.o: ../../include/openssl/crypto.h ../../include/openssl/dsa.h
185dsa_prn.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
186dsa_prn.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h
187dsa_prn.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
188dsa_prn.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
189dsa_prn.o: ../../include/openssl/ossl_typ.h ../../include/openssl/safestack.h
190dsa_prn.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
191dsa_prn.o: ../cryptlib.h dsa_prn.c
192dsa_sign.o: ../../e_os.h ../../include/openssl/bio.h
155dsa_sign.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 193dsa_sign.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
156dsa_sign.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h 194dsa_sign.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
157dsa_sign.o: ../../include/openssl/err.h ../../include/openssl/fips.h 195dsa_sign.o: ../../include/openssl/err.h ../../include/openssl/lhash.h
158dsa_sign.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h 196dsa_sign.o: ../../include/openssl/opensslconf.h
159dsa_sign.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h 197dsa_sign.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
160dsa_sign.o: ../../include/openssl/rand.h ../../include/openssl/safestack.h 198dsa_sign.o: ../../include/openssl/rand.h ../../include/openssl/safestack.h
161dsa_sign.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 199dsa_sign.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
162dsa_sign.o: ../cryptlib.h dsa_sign.c 200dsa_sign.o: ../cryptlib.h dsa_sign.c
163dsa_utl.o: ../../e_os.h ../../include/openssl/asn1.h 201dsa_vrf.o: ../../e_os.h ../../include/openssl/bio.h
164dsa_utl.o: ../../include/openssl/bio.h ../../include/openssl/bn.h 202dsa_vrf.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
165dsa_utl.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 203dsa_vrf.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
166dsa_utl.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h 204dsa_vrf.o: ../../include/openssl/err.h ../../include/openssl/lhash.h
167dsa_utl.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h
168dsa_utl.o: ../../include/openssl/ecdh.h ../../include/openssl/ecdsa.h
169dsa_utl.o: ../../include/openssl/engine.h ../../include/openssl/err.h
170dsa_utl.o: ../../include/openssl/evp.h ../../include/openssl/fips.h
171dsa_utl.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
172dsa_utl.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
173dsa_utl.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
174dsa_utl.o: ../../include/openssl/pkcs7.h ../../include/openssl/safestack.h
175dsa_utl.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
176dsa_utl.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h
177dsa_utl.o: ../../include/openssl/x509_vfy.h ../cryptlib.h dsa_utl.c
178dsa_vrf.o: ../../e_os.h ../../include/openssl/asn1.h
179dsa_vrf.o: ../../include/openssl/asn1_mac.h ../../include/openssl/bio.h
180dsa_vrf.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
181dsa_vrf.o: ../../include/openssl/crypto.h ../../include/openssl/dsa.h
182dsa_vrf.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
183dsa_vrf.o: ../../include/openssl/fips.h ../../include/openssl/lhash.h
184dsa_vrf.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h 205dsa_vrf.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
185dsa_vrf.o: ../../include/openssl/ossl_typ.h ../../include/openssl/rand.h 206dsa_vrf.o: ../../include/openssl/ossl_typ.h ../../include/openssl/safestack.h
186dsa_vrf.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h 207dsa_vrf.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
187dsa_vrf.o: ../../include/openssl/symhacks.h ../cryptlib.h dsa_vrf.c 208dsa_vrf.o: ../cryptlib.h dsa_vrf.c
diff --git a/src/lib/libcrypto/dsa/Makefile.ssl b/src/lib/libcrypto/dsa/Makefile.ssl
deleted file mode 100644
index e5f8a8cf51..0000000000
--- a/src/lib/libcrypto/dsa/Makefile.ssl
+++ /dev/null
@@ -1,171 +0,0 @@
1#
2# SSLeay/crypto/dsa/Makefile
3#
4
5DIR= dsa
6TOP= ../..
7CC= cc
8INCLUDES= -I.. -I$(TOP) -I../../include
9CFLAG=-g
10INSTALL_PREFIX=
11OPENSSLDIR= /usr/local/ssl
12INSTALLTOP=/usr/local/ssl
13MAKE= make -f Makefile.ssl
14MAKEDEPPROG= makedepend
15MAKEDEPEND= $(TOP)/util/domd $(TOP) -MD $(MAKEDEPPROG)
16MAKEFILE= Makefile.ssl
17AR= ar r
18
19CFLAGS= $(INCLUDES) $(CFLAG)
20
21GENERAL=Makefile
22TEST=dsatest.c
23APPS=
24
25LIB=$(TOP)/libcrypto.a
26LIBSRC= dsa_gen.c dsa_key.c dsa_lib.c dsa_asn1.c dsa_vrf.c dsa_sign.c \
27 dsa_err.c dsa_ossl.c
28LIBOBJ= dsa_gen.o dsa_key.o dsa_lib.o dsa_asn1.o dsa_vrf.o dsa_sign.o \
29 dsa_err.o dsa_ossl.o
30
31SRC= $(LIBSRC)
32
33EXHEADER= dsa.h
34HEADER= $(EXHEADER)
35
36ALL= $(GENERAL) $(SRC) $(HEADER)
37
38top:
39 (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all)
40
41all: lib
42
43lib: $(LIBOBJ)
44 $(AR) $(LIB) $(LIBOBJ)
45 $(RANLIB) $(LIB) || echo Never mind.
46 @touch lib
47
48files:
49 $(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO
50
51links:
52 @sh $(TOP)/util/point.sh Makefile.ssl Makefile
53 @$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER)
54 @$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST)
55 @$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS)
56
57install:
58 @for i in $(EXHEADER) ; \
59 do \
60 (cp $$i $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i; \
61 chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i ); \
62 done;
63
64tags:
65 ctags $(SRC)
66
67tests:
68
69lint:
70 lint -DLINT $(INCLUDES) $(SRC)>fluff
71
72depend:
73 $(MAKEDEPEND) -- $(CFLAG) $(INCLUDES) $(DEPFLAG) -- $(PROGS) $(LIBSRC)
74
75dclean:
76 $(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
77 mv -f Makefile.new $(MAKEFILE)
78
79clean:
80 rm -f *.o */*.o *.obj lib tags core .pure .nfs* *.old *.bak fluff
81
82# DO NOT DELETE THIS LINE -- make depend depends on it.
83
84dsa_asn1.o: ../../e_os.h ../../include/openssl/asn1.h
85dsa_asn1.o: ../../include/openssl/asn1t.h ../../include/openssl/bio.h
86dsa_asn1.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
87dsa_asn1.o: ../../include/openssl/crypto.h ../../include/openssl/dh.h
88dsa_asn1.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
89dsa_asn1.o: ../../include/openssl/err.h ../../include/openssl/lhash.h
90dsa_asn1.o: ../../include/openssl/opensslconf.h
91dsa_asn1.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
92dsa_asn1.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
93dsa_asn1.o: ../../include/openssl/symhacks.h ../cryptlib.h dsa_asn1.c
94dsa_err.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
95dsa_err.o: ../../include/openssl/crypto.h ../../include/openssl/dh.h
96dsa_err.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
97dsa_err.o: ../../include/openssl/err.h ../../include/openssl/lhash.h
98dsa_err.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
99dsa_err.o: ../../include/openssl/ossl_typ.h ../../include/openssl/safestack.h
100dsa_err.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
101dsa_err.o: dsa_err.c
102dsa_gen.o: ../../e_os.h ../../include/openssl/aes.h
103dsa_gen.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
104dsa_gen.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
105dsa_gen.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
106dsa_gen.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
107dsa_gen.o: ../../include/openssl/des_old.h ../../include/openssl/dh.h
108dsa_gen.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
109dsa_gen.o: ../../include/openssl/err.h ../../include/openssl/evp.h
110dsa_gen.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h
111dsa_gen.o: ../../include/openssl/md2.h ../../include/openssl/md4.h
112dsa_gen.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
113dsa_gen.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
114dsa_gen.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
115dsa_gen.o: ../../include/openssl/ossl_typ.h ../../include/openssl/rand.h
116dsa_gen.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h
117dsa_gen.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h
118dsa_gen.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
119dsa_gen.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
120dsa_gen.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
121dsa_gen.o: ../../include/openssl/ui_compat.h ../cryptlib.h dsa_gen.c
122dsa_key.o: ../../e_os.h ../../include/openssl/bio.h ../../include/openssl/bn.h
123dsa_key.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
124dsa_key.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
125dsa_key.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
126dsa_key.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
127dsa_key.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
128dsa_key.o: ../../include/openssl/rand.h ../../include/openssl/safestack.h
129dsa_key.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
130dsa_key.o: ../cryptlib.h dsa_key.c
131dsa_lib.o: ../../e_os.h ../../include/openssl/asn1.h
132dsa_lib.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
133dsa_lib.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
134dsa_lib.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
135dsa_lib.o: ../../include/openssl/e_os2.h ../../include/openssl/engine.h
136dsa_lib.o: ../../include/openssl/err.h ../../include/openssl/lhash.h
137dsa_lib.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
138dsa_lib.o: ../../include/openssl/ossl_typ.h ../../include/openssl/rand.h
139dsa_lib.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
140dsa_lib.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
141dsa_lib.o: ../../include/openssl/ui.h ../cryptlib.h dsa_lib.c
142dsa_ossl.o: ../../e_os.h ../../include/openssl/asn1.h
143dsa_ossl.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
144dsa_ossl.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
145dsa_ossl.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
146dsa_ossl.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
147dsa_ossl.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
148dsa_ossl.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
149dsa_ossl.o: ../../include/openssl/rand.h ../../include/openssl/safestack.h
150dsa_ossl.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
151dsa_ossl.o: ../cryptlib.h dsa_ossl.c
152dsa_sign.o: ../../e_os.h ../../include/openssl/asn1.h
153dsa_sign.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
154dsa_sign.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
155dsa_sign.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
156dsa_sign.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
157dsa_sign.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
158dsa_sign.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
159dsa_sign.o: ../../include/openssl/rand.h ../../include/openssl/safestack.h
160dsa_sign.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
161dsa_sign.o: ../cryptlib.h dsa_sign.c
162dsa_vrf.o: ../../e_os.h ../../include/openssl/asn1.h
163dsa_vrf.o: ../../include/openssl/asn1_mac.h ../../include/openssl/bio.h
164dsa_vrf.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
165dsa_vrf.o: ../../include/openssl/crypto.h ../../include/openssl/dh.h
166dsa_vrf.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
167dsa_vrf.o: ../../include/openssl/err.h ../../include/openssl/lhash.h
168dsa_vrf.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
169dsa_vrf.o: ../../include/openssl/ossl_typ.h ../../include/openssl/rand.h
170dsa_vrf.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
171dsa_vrf.o: ../../include/openssl/symhacks.h ../cryptlib.h dsa_vrf.c
diff --git a/src/lib/libcrypto/dsa/dsa.h b/src/lib/libcrypto/dsa/dsa.h
index 702c50d6dc..ac50a5c846 100644
--- a/src/lib/libcrypto/dsa/dsa.h
+++ b/src/lib/libcrypto/dsa/dsa.h
@@ -88,8 +88,6 @@
88# define OPENSSL_DSA_MAX_MODULUS_BITS 10000 88# define OPENSSL_DSA_MAX_MODULUS_BITS 10000
89#endif 89#endif
90 90
91#define OPENSSL_DSA_FIPS_MIN_MODULUS_BITS 1024
92
93#define DSA_FLAG_CACHE_MONT_P 0x01 91#define DSA_FLAG_CACHE_MONT_P 0x01
94#define DSA_FLAG_NO_EXP_CONSTTIME 0x02 /* new with 0.9.7h; the built-in DSA 92#define DSA_FLAG_NO_EXP_CONSTTIME 0x02 /* new with 0.9.7h; the built-in DSA
95 * implementation now uses constant time 93 * implementation now uses constant time
@@ -99,25 +97,6 @@
99 * be used for all exponents. 97 * be used for all exponents.
100 */ 98 */
101 99
102/* If this flag is set the DSA method is FIPS compliant and can be used
103 * in FIPS mode. This is set in the validated module method. If an
104 * application sets this flag in its own methods it is its reposibility
105 * to ensure the result is compliant.
106 */
107
108#define DSA_FLAG_FIPS_METHOD 0x0400
109
110/* If this flag is set the operations normally disabled in FIPS mode are
111 * permitted it is then the applications responsibility to ensure that the
112 * usage is compliant.
113 */
114
115#define DSA_FLAG_NON_FIPS_ALLOW 0x0400
116
117#ifdef OPENSSL_FIPS
118#define FIPS_DSA_SIZE_T int
119#endif
120
121#ifdef __cplusplus 100#ifdef __cplusplus
122extern "C" { 101extern "C" {
123#endif 102#endif
@@ -139,7 +118,7 @@ struct dsa_method
139 int (*dsa_sign_setup)(DSA *dsa, BN_CTX *ctx_in, BIGNUM **kinvp, 118 int (*dsa_sign_setup)(DSA *dsa, BN_CTX *ctx_in, BIGNUM **kinvp,
140 BIGNUM **rp); 119 BIGNUM **rp);
141 int (*dsa_do_verify)(const unsigned char *dgst, int dgst_len, 120 int (*dsa_do_verify)(const unsigned char *dgst, int dgst_len,
142 DSA_SIG *sig, DSA *dsa); 121 DSA_SIG *sig, DSA *dsa);
143 int (*dsa_mod_exp)(DSA *dsa, BIGNUM *rr, BIGNUM *a1, BIGNUM *p1, 122 int (*dsa_mod_exp)(DSA *dsa, BIGNUM *rr, BIGNUM *a1, BIGNUM *p1,
144 BIGNUM *a2, BIGNUM *p2, BIGNUM *m, BN_CTX *ctx, 123 BIGNUM *a2, BIGNUM *p2, BIGNUM *m, BN_CTX *ctx,
145 BN_MONT_CTX *in_mont); 124 BN_MONT_CTX *in_mont);
@@ -152,7 +131,7 @@ struct dsa_method
152 char *app_data; 131 char *app_data;
153 /* If this is non-NULL, it is used to generate DSA parameters */ 132 /* If this is non-NULL, it is used to generate DSA parameters */
154 int (*dsa_paramgen)(DSA *dsa, int bits, 133 int (*dsa_paramgen)(DSA *dsa, int bits,
155 unsigned char *seed, int seed_len, 134 const unsigned char *seed, int seed_len,
156 int *counter_ret, unsigned long *h_ret, 135 int *counter_ret, unsigned long *h_ret,
157 BN_GENCB *cb); 136 BN_GENCB *cb);
158 /* If this is non-NULL, it is used to generate DSA keys */ 137 /* If this is non-NULL, it is used to generate DSA keys */
@@ -186,7 +165,6 @@ struct dsa_st
186 ENGINE *engine; 165 ENGINE *engine;
187 }; 166 };
188 167
189#define DSAparams_dup(x) ASN1_dup_of_const(DSA,i2d_DSAparams,d2i_DSAparams,x)
190#define d2i_DSAparams_fp(fp,x) (DSA *)ASN1_d2i_fp((char *(*)())DSA_new, \ 168#define d2i_DSAparams_fp(fp,x) (DSA *)ASN1_d2i_fp((char *(*)())DSA_new, \
191 (char *(*)())d2i_DSAparams,(fp),(unsigned char **)(x)) 169 (char *(*)())d2i_DSAparams,(fp),(unsigned char **)(x))
192#define i2d_DSAparams_fp(fp,x) ASN1_i2d_fp(i2d_DSAparams,(fp), \ 170#define i2d_DSAparams_fp(fp,x) ASN1_i2d_fp(i2d_DSAparams,(fp), \
@@ -195,6 +173,7 @@ struct dsa_st
195#define i2d_DSAparams_bio(bp,x) ASN1_i2d_bio_of_const(DSA,i2d_DSAparams,bp,x) 173#define i2d_DSAparams_bio(bp,x) ASN1_i2d_bio_of_const(DSA,i2d_DSAparams,bp,x)
196 174
197 175
176DSA *DSAparams_dup(DSA *x);
198DSA_SIG * DSA_SIG_new(void); 177DSA_SIG * DSA_SIG_new(void);
199void DSA_SIG_free(DSA_SIG *a); 178void DSA_SIG_free(DSA_SIG *a);
200int i2d_DSA_SIG(const DSA_SIG *a, unsigned char **pp); 179int i2d_DSA_SIG(const DSA_SIG *a, unsigned char **pp);
@@ -210,11 +189,6 @@ void DSA_set_default_method(const DSA_METHOD *);
210const DSA_METHOD *DSA_get_default_method(void); 189const DSA_METHOD *DSA_get_default_method(void);
211int DSA_set_method(DSA *dsa, const DSA_METHOD *); 190int DSA_set_method(DSA *dsa, const DSA_METHOD *);
212 191
213#ifdef OPENSSL_FIPS
214DSA * FIPS_dsa_new(void);
215void FIPS_dsa_free (DSA *r);
216#endif
217
218DSA * DSA_new(void); 192DSA * DSA_new(void);
219DSA * DSA_new_method(ENGINE *engine); 193DSA * DSA_new_method(ENGINE *engine);
220void DSA_free (DSA *r); 194void DSA_free (DSA *r);
@@ -246,7 +220,7 @@ DSA * DSA_generate_parameters(int bits,
246 220
247/* New version */ 221/* New version */
248int DSA_generate_parameters_ex(DSA *dsa, int bits, 222int DSA_generate_parameters_ex(DSA *dsa, int bits,
249 unsigned char *seed,int seed_len, 223 const unsigned char *seed,int seed_len,
250 int *counter_ret, unsigned long *h_ret, BN_GENCB *cb); 224 int *counter_ret, unsigned long *h_ret, BN_GENCB *cb);
251 225
252int DSA_generate_key(DSA *a); 226int DSA_generate_key(DSA *a);
@@ -275,10 +249,13 @@ int DSA_print_fp(FILE *bp, const DSA *x, int off);
275DH *DSA_dup_DH(const DSA *r); 249DH *DSA_dup_DH(const DSA *r);
276#endif 250#endif
277 251
278#ifdef OPENSSL_FIPS 252#define EVP_PKEY_CTX_set_dsa_paramgen_bits(ctx, nbits) \
279int FIPS_dsa_sig_encode(unsigned char *out, DSA_SIG *sig); 253 EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DSA, EVP_PKEY_OP_PARAMGEN, \
280int FIPS_dsa_sig_decode(DSA_SIG *sig, const unsigned char *in, int inlen); 254 EVP_PKEY_CTRL_DSA_PARAMGEN_BITS, nbits, NULL)
281#endif 255
256#define EVP_PKEY_CTRL_DSA_PARAMGEN_BITS (EVP_PKEY_ALG_CTRL + 1)
257#define EVP_PKEY_CTRL_DSA_PARAMGEN_Q_BITS (EVP_PKEY_ALG_CTRL + 2)
258#define EVP_PKEY_CTRL_DSA_PARAMGEN_MD (EVP_PKEY_ALG_CTRL + 3)
282 259
283/* BEGIN ERROR CODES */ 260/* BEGIN ERROR CODES */
284/* The following lines are auto generated by the script mkerr.pl. Any changes 261/* The following lines are auto generated by the script mkerr.pl. Any changes
@@ -290,33 +267,39 @@ void ERR_load_DSA_strings(void);
290 267
291/* Function codes. */ 268/* Function codes. */
292#define DSA_F_D2I_DSA_SIG 110 269#define DSA_F_D2I_DSA_SIG 110
270#define DSA_F_DO_DSA_PRINT 104
293#define DSA_F_DSAPARAMS_PRINT 100 271#define DSA_F_DSAPARAMS_PRINT 100
294#define DSA_F_DSAPARAMS_PRINT_FP 101 272#define DSA_F_DSAPARAMS_PRINT_FP 101
295#define DSA_F_DSA_BUILTIN_KEYGEN 119
296#define DSA_F_DSA_BUILTIN_PARAMGEN 118
297#define DSA_F_DSA_DO_SIGN 112 273#define DSA_F_DSA_DO_SIGN 112
298#define DSA_F_DSA_DO_VERIFY 113 274#define DSA_F_DSA_DO_VERIFY 113
299#define DSA_F_DSA_GENERATE_PARAMETERS 117
300#define DSA_F_DSA_NEW_METHOD 103 275#define DSA_F_DSA_NEW_METHOD 103
301#define DSA_F_DSA_PRINT 104 276#define DSA_F_DSA_PARAM_DECODE 119
302#define DSA_F_DSA_PRINT_FP 105 277#define DSA_F_DSA_PRINT_FP 105
303#define DSA_F_DSA_SET_DEFAULT_METHOD 115 278#define DSA_F_DSA_PRIV_DECODE 115
304#define DSA_F_DSA_SET_METHOD 116 279#define DSA_F_DSA_PRIV_ENCODE 116
280#define DSA_F_DSA_PUB_DECODE 117
281#define DSA_F_DSA_PUB_ENCODE 118
305#define DSA_F_DSA_SIGN 106 282#define DSA_F_DSA_SIGN 106
306#define DSA_F_DSA_SIGN_SETUP 107 283#define DSA_F_DSA_SIGN_SETUP 107
307#define DSA_F_DSA_SIG_NEW 109 284#define DSA_F_DSA_SIG_NEW 109
308#define DSA_F_DSA_VERIFY 108 285#define DSA_F_DSA_VERIFY 108
309#define DSA_F_I2D_DSA_SIG 111 286#define DSA_F_I2D_DSA_SIG 111
287#define DSA_F_OLD_DSA_PRIV_DECODE 122
288#define DSA_F_PKEY_DSA_CTRL 120
289#define DSA_F_PKEY_DSA_KEYGEN 121
310#define DSA_F_SIG_CB 114 290#define DSA_F_SIG_CB 114
311 291
312/* Reason codes. */ 292/* Reason codes. */
313#define DSA_R_BAD_Q_VALUE 102 293#define DSA_R_BAD_Q_VALUE 102
294#define DSA_R_BN_DECODE_ERROR 108
295#define DSA_R_BN_ERROR 109
314#define DSA_R_DATA_TOO_LARGE_FOR_KEY_SIZE 100 296#define DSA_R_DATA_TOO_LARGE_FOR_KEY_SIZE 100
315#define DSA_R_KEY_SIZE_TOO_SMALL 106 297#define DSA_R_DECODE_ERROR 104
298#define DSA_R_INVALID_DIGEST_TYPE 106
316#define DSA_R_MISSING_PARAMETERS 101 299#define DSA_R_MISSING_PARAMETERS 101
317#define DSA_R_MODULUS_TOO_LARGE 103 300#define DSA_R_MODULUS_TOO_LARGE 103
318#define DSA_R_NON_FIPS_METHOD 104 301#define DSA_R_NO_PARAMETERS_SET 107
319#define DSA_R_OPERATION_NOT_ALLOWED_IN_FIPS_MODE 105 302#define DSA_R_PARAMETER_ENCODING_ERROR 105
320 303
321#ifdef __cplusplus 304#ifdef __cplusplus
322} 305}
diff --git a/src/lib/libcrypto/dsa/dsa_asn1.c b/src/lib/libcrypto/dsa/dsa_asn1.c
index 0645facb4b..c37460b2d6 100644
--- a/src/lib/libcrypto/dsa/dsa_asn1.c
+++ b/src/lib/libcrypto/dsa/dsa_asn1.c
@@ -3,7 +3,7 @@
3 * project 2000. 3 * project 2000.
4 */ 4 */
5/* ==================================================================== 5/* ====================================================================
6 * Copyright (c) 2000 The OpenSSL Project. All rights reserved. 6 * Copyright (c) 2000-2005 The OpenSSL Project. All rights reserved.
7 * 7 *
8 * Redistribution and use in source and binary forms, with or without 8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions 9 * modification, are permitted provided that the following conditions
@@ -61,24 +61,23 @@
61#include <openssl/dsa.h> 61#include <openssl/dsa.h>
62#include <openssl/asn1.h> 62#include <openssl/asn1.h>
63#include <openssl/asn1t.h> 63#include <openssl/asn1t.h>
64#include <openssl/bn.h>
65#ifdef OPENSSL_FIPS
66#include <openssl/fips.h>
67#endif
68
69 64
70/* Override the default new methods */ 65/* Override the default new methods */
71static int sig_cb(int operation, ASN1_VALUE **pval, const ASN1_ITEM *it) 66static int sig_cb(int operation, ASN1_VALUE **pval, const ASN1_ITEM *it,
67 void *exarg)
72{ 68{
73 if(operation == ASN1_OP_NEW_PRE) { 69 if(operation == ASN1_OP_NEW_PRE) {
74 DSA_SIG *sig; 70 DSA_SIG *sig;
75 sig = OPENSSL_malloc(sizeof(DSA_SIG)); 71 sig = OPENSSL_malloc(sizeof(DSA_SIG));
72 if (!sig)
73 {
74 DSAerr(DSA_F_SIG_CB, ERR_R_MALLOC_FAILURE);
75 return 0;
76 }
76 sig->r = NULL; 77 sig->r = NULL;
77 sig->s = NULL; 78 sig->s = NULL;
78 *pval = (ASN1_VALUE *)sig; 79 *pval = (ASN1_VALUE *)sig;
79 if(sig) return 2; 80 return 2;
80 DSAerr(DSA_F_SIG_CB, ERR_R_MALLOC_FAILURE);
81 return 0;
82 } 81 }
83 return 1; 82 return 1;
84} 83}
@@ -88,10 +87,11 @@ ASN1_SEQUENCE_cb(DSA_SIG, sig_cb) = {
88 ASN1_SIMPLE(DSA_SIG, s, CBIGNUM) 87 ASN1_SIMPLE(DSA_SIG, s, CBIGNUM)
89} ASN1_SEQUENCE_END_cb(DSA_SIG, DSA_SIG) 88} ASN1_SEQUENCE_END_cb(DSA_SIG, DSA_SIG)
90 89
91IMPLEMENT_ASN1_ENCODE_FUNCTIONS_const_fname(DSA_SIG,DSA_SIG,DSA_SIG) 90IMPLEMENT_ASN1_FUNCTIONS_const(DSA_SIG)
92 91
93/* Override the default free and new methods */ 92/* Override the default free and new methods */
94static int dsa_cb(int operation, ASN1_VALUE **pval, const ASN1_ITEM *it) 93static int dsa_cb(int operation, ASN1_VALUE **pval, const ASN1_ITEM *it,
94 void *exarg)
95{ 95{
96 if(operation == ASN1_OP_NEW_PRE) { 96 if(operation == ASN1_OP_NEW_PRE) {
97 *pval = (ASN1_VALUE *)DSA_new(); 97 *pval = (ASN1_VALUE *)DSA_new();
@@ -144,75 +144,7 @@ ASN1_CHOICE_cb(DSAPublicKey, dsa_cb) = {
144 144
145IMPLEMENT_ASN1_ENCODE_FUNCTIONS_const_fname(DSA, DSAPublicKey, DSAPublicKey) 145IMPLEMENT_ASN1_ENCODE_FUNCTIONS_const_fname(DSA, DSAPublicKey, DSAPublicKey)
146 146
147int DSA_sign(int type, const unsigned char *dgst, int dlen, unsigned char *sig, 147DSA *DSAparams_dup(DSA *dsa)
148 unsigned int *siglen, DSA *dsa)
149 {
150 DSA_SIG *s;
151#ifdef OPENSSL_FIPS
152 if(FIPS_mode() && !(dsa->flags & DSA_FLAG_NON_FIPS_ALLOW))
153 {
154 DSAerr(DSA_F_DSA_SIGN, DSA_R_OPERATION_NOT_ALLOWED_IN_FIPS_MODE);
155 return 0;
156 }
157#endif
158 s=DSA_do_sign(dgst,dlen,dsa);
159 if (s == NULL)
160 {
161 *siglen=0;
162 return(0);
163 }
164 *siglen=i2d_DSA_SIG(s,&sig);
165 DSA_SIG_free(s);
166 return(1);
167 }
168
169int DSA_size(const DSA *r)
170 {
171 int ret,i;
172 ASN1_INTEGER bs;
173 unsigned char buf[4]; /* 4 bytes looks really small.
174 However, i2d_ASN1_INTEGER() will not look
175 beyond the first byte, as long as the second
176 parameter is NULL. */
177
178 i=BN_num_bits(r->q);
179 bs.length=(i+7)/8;
180 bs.data=buf;
181 bs.type=V_ASN1_INTEGER;
182 /* If the top bit is set the asn1 encoding is 1 larger. */
183 buf[0]=0xff;
184
185 i=i2d_ASN1_INTEGER(&bs,NULL);
186 i+=i; /* r and s */
187 ret=ASN1_object_size(1,i,V_ASN1_SEQUENCE);
188 return(ret);
189 }
190
191/* data has already been hashed (probably with SHA or SHA-1). */
192/* returns
193 * 1: correct signature
194 * 0: incorrect signature
195 * -1: error
196 */
197int DSA_verify(int type, const unsigned char *dgst, int dgst_len,
198 const unsigned char *sigbuf, int siglen, DSA *dsa)
199 { 148 {
200 DSA_SIG *s; 149 return ASN1_item_dup(ASN1_ITEM_rptr(DSAparams), dsa);
201 int ret=-1;
202#ifdef OPENSSL_FIPS
203 if(FIPS_mode() && !(dsa->flags & DSA_FLAG_NON_FIPS_ALLOW))
204 {
205 DSAerr(DSA_F_DSA_VERIFY, DSA_R_OPERATION_NOT_ALLOWED_IN_FIPS_MODE);
206 return 0;
207 }
208#endif
209
210 s = DSA_SIG_new();
211 if (s == NULL) return(ret);
212 if (d2i_DSA_SIG(&s,&sigbuf,siglen) == NULL) goto err;
213 ret=DSA_do_verify(dgst,dgst_len,s,dsa);
214err:
215 DSA_SIG_free(s);
216 return(ret);
217 } 150 }
218
diff --git a/src/lib/libcrypto/dsa/dsa_err.c b/src/lib/libcrypto/dsa/dsa_err.c
index 872839af94..bba984e92e 100644
--- a/src/lib/libcrypto/dsa/dsa_err.c
+++ b/src/lib/libcrypto/dsa/dsa_err.c
@@ -1,6 +1,6 @@
1/* crypto/dsa/dsa_err.c */ 1/* crypto/dsa/dsa_err.c */
2/* ==================================================================== 2/* ====================================================================
3 * Copyright (c) 1999-2007 The OpenSSL Project. All rights reserved. 3 * Copyright (c) 1999-2006 The OpenSSL Project. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
@@ -71,23 +71,26 @@
71static ERR_STRING_DATA DSA_str_functs[]= 71static ERR_STRING_DATA DSA_str_functs[]=
72 { 72 {
73{ERR_FUNC(DSA_F_D2I_DSA_SIG), "d2i_DSA_SIG"}, 73{ERR_FUNC(DSA_F_D2I_DSA_SIG), "d2i_DSA_SIG"},
74{ERR_FUNC(DSA_F_DO_DSA_PRINT), "DO_DSA_PRINT"},
74{ERR_FUNC(DSA_F_DSAPARAMS_PRINT), "DSAparams_print"}, 75{ERR_FUNC(DSA_F_DSAPARAMS_PRINT), "DSAparams_print"},
75{ERR_FUNC(DSA_F_DSAPARAMS_PRINT_FP), "DSAparams_print_fp"}, 76{ERR_FUNC(DSA_F_DSAPARAMS_PRINT_FP), "DSAparams_print_fp"},
76{ERR_FUNC(DSA_F_DSA_BUILTIN_KEYGEN), "DSA_BUILTIN_KEYGEN"},
77{ERR_FUNC(DSA_F_DSA_BUILTIN_PARAMGEN), "DSA_BUILTIN_PARAMGEN"},
78{ERR_FUNC(DSA_F_DSA_DO_SIGN), "DSA_do_sign"}, 77{ERR_FUNC(DSA_F_DSA_DO_SIGN), "DSA_do_sign"},
79{ERR_FUNC(DSA_F_DSA_DO_VERIFY), "DSA_do_verify"}, 78{ERR_FUNC(DSA_F_DSA_DO_VERIFY), "DSA_do_verify"},
80{ERR_FUNC(DSA_F_DSA_GENERATE_PARAMETERS), "DSA_generate_parameters"},
81{ERR_FUNC(DSA_F_DSA_NEW_METHOD), "DSA_new_method"}, 79{ERR_FUNC(DSA_F_DSA_NEW_METHOD), "DSA_new_method"},
82{ERR_FUNC(DSA_F_DSA_PRINT), "DSA_print"}, 80{ERR_FUNC(DSA_F_DSA_PARAM_DECODE), "DSA_PARAM_DECODE"},
83{ERR_FUNC(DSA_F_DSA_PRINT_FP), "DSA_print_fp"}, 81{ERR_FUNC(DSA_F_DSA_PRINT_FP), "DSA_print_fp"},
84{ERR_FUNC(DSA_F_DSA_SET_DEFAULT_METHOD), "DSA_set_default_method"}, 82{ERR_FUNC(DSA_F_DSA_PRIV_DECODE), "DSA_PRIV_DECODE"},
85{ERR_FUNC(DSA_F_DSA_SET_METHOD), "DSA_set_method"}, 83{ERR_FUNC(DSA_F_DSA_PRIV_ENCODE), "DSA_PRIV_ENCODE"},
84{ERR_FUNC(DSA_F_DSA_PUB_DECODE), "DSA_PUB_DECODE"},
85{ERR_FUNC(DSA_F_DSA_PUB_ENCODE), "DSA_PUB_ENCODE"},
86{ERR_FUNC(DSA_F_DSA_SIGN), "DSA_sign"}, 86{ERR_FUNC(DSA_F_DSA_SIGN), "DSA_sign"},
87{ERR_FUNC(DSA_F_DSA_SIGN_SETUP), "DSA_sign_setup"}, 87{ERR_FUNC(DSA_F_DSA_SIGN_SETUP), "DSA_sign_setup"},
88{ERR_FUNC(DSA_F_DSA_SIG_NEW), "DSA_SIG_new"}, 88{ERR_FUNC(DSA_F_DSA_SIG_NEW), "DSA_SIG_new"},
89{ERR_FUNC(DSA_F_DSA_VERIFY), "DSA_verify"}, 89{ERR_FUNC(DSA_F_DSA_VERIFY), "DSA_verify"},
90{ERR_FUNC(DSA_F_I2D_DSA_SIG), "i2d_DSA_SIG"}, 90{ERR_FUNC(DSA_F_I2D_DSA_SIG), "i2d_DSA_SIG"},
91{ERR_FUNC(DSA_F_OLD_DSA_PRIV_DECODE), "OLD_DSA_PRIV_DECODE"},
92{ERR_FUNC(DSA_F_PKEY_DSA_CTRL), "PKEY_DSA_CTRL"},
93{ERR_FUNC(DSA_F_PKEY_DSA_KEYGEN), "PKEY_DSA_KEYGEN"},
91{ERR_FUNC(DSA_F_SIG_CB), "SIG_CB"}, 94{ERR_FUNC(DSA_F_SIG_CB), "SIG_CB"},
92{0,NULL} 95{0,NULL}
93 }; 96 };
@@ -95,12 +98,15 @@ static ERR_STRING_DATA DSA_str_functs[]=
95static ERR_STRING_DATA DSA_str_reasons[]= 98static ERR_STRING_DATA DSA_str_reasons[]=
96 { 99 {
97{ERR_REASON(DSA_R_BAD_Q_VALUE) ,"bad q value"}, 100{ERR_REASON(DSA_R_BAD_Q_VALUE) ,"bad q value"},
101{ERR_REASON(DSA_R_BN_DECODE_ERROR) ,"bn decode error"},
102{ERR_REASON(DSA_R_BN_ERROR) ,"bn error"},
98{ERR_REASON(DSA_R_DATA_TOO_LARGE_FOR_KEY_SIZE),"data too large for key size"}, 103{ERR_REASON(DSA_R_DATA_TOO_LARGE_FOR_KEY_SIZE),"data too large for key size"},
99{ERR_REASON(DSA_R_KEY_SIZE_TOO_SMALL) ,"key size too small"}, 104{ERR_REASON(DSA_R_DECODE_ERROR) ,"decode error"},
105{ERR_REASON(DSA_R_INVALID_DIGEST_TYPE) ,"invalid digest type"},
100{ERR_REASON(DSA_R_MISSING_PARAMETERS) ,"missing parameters"}, 106{ERR_REASON(DSA_R_MISSING_PARAMETERS) ,"missing parameters"},
101{ERR_REASON(DSA_R_MODULUS_TOO_LARGE) ,"modulus too large"}, 107{ERR_REASON(DSA_R_MODULUS_TOO_LARGE) ,"modulus too large"},
102{ERR_REASON(DSA_R_NON_FIPS_METHOD) ,"non fips method"}, 108{ERR_REASON(DSA_R_NO_PARAMETERS_SET) ,"no parameters set"},
103{ERR_REASON(DSA_R_OPERATION_NOT_ALLOWED_IN_FIPS_MODE),"operation not allowed in fips mode"}, 109{ERR_REASON(DSA_R_PARAMETER_ENCODING_ERROR),"parameter encoding error"},
104{0,NULL} 110{0,NULL}
105 }; 111 };
106 112
diff --git a/src/lib/libcrypto/dsa/dsa_gen.c b/src/lib/libcrypto/dsa/dsa_gen.c
index 6f1728e3cf..0fcd25f8b0 100644
--- a/src/lib/libcrypto/dsa/dsa_gen.c
+++ b/src/lib/libcrypto/dsa/dsa_gen.c
@@ -74,69 +74,88 @@
74#ifndef OPENSSL_NO_SHA 74#ifndef OPENSSL_NO_SHA
75 75
76#include <stdio.h> 76#include <stdio.h>
77#include <time.h>
78#include "cryptlib.h" 77#include "cryptlib.h"
79#include <openssl/evp.h> 78#include <openssl/evp.h>
80#include <openssl/bn.h> 79#include <openssl/bn.h>
81#include <openssl/dsa.h>
82#include <openssl/rand.h> 80#include <openssl/rand.h>
83#include <openssl/sha.h> 81#include <openssl/sha.h>
84 82#include "dsa_locl.h"
85#ifndef OPENSSL_FIPS
86
87static int dsa_builtin_paramgen(DSA *ret, int bits,
88 unsigned char *seed_in, int seed_len,
89 int *counter_ret, unsigned long *h_ret, BN_GENCB *cb);
90 83
91int DSA_generate_parameters_ex(DSA *ret, int bits, 84int DSA_generate_parameters_ex(DSA *ret, int bits,
92 unsigned char *seed_in, int seed_len, 85 const unsigned char *seed_in, int seed_len,
93 int *counter_ret, unsigned long *h_ret, BN_GENCB *cb) 86 int *counter_ret, unsigned long *h_ret, BN_GENCB *cb)
94 { 87 {
95 if(ret->meth->dsa_paramgen) 88 if(ret->meth->dsa_paramgen)
96 return ret->meth->dsa_paramgen(ret, bits, seed_in, seed_len, 89 return ret->meth->dsa_paramgen(ret, bits, seed_in, seed_len,
97 counter_ret, h_ret, cb); 90 counter_ret, h_ret, cb);
98 return dsa_builtin_paramgen(ret, bits, seed_in, seed_len, 91 else
99 counter_ret, h_ret, cb); 92 {
93 const EVP_MD *evpmd;
94 size_t qbits = bits >= 2048 ? 256 : 160;
95
96 if (bits >= 2048)
97 {
98 qbits = 256;
99 evpmd = EVP_sha256();
100 }
101 else
102 {
103 qbits = 160;
104 evpmd = EVP_sha1();
105 }
106
107 return dsa_builtin_paramgen(ret, bits, qbits, evpmd,
108 seed_in, seed_len, counter_ret, h_ret, cb);
109 }
100 } 110 }
101 111
102static int dsa_builtin_paramgen(DSA *ret, int bits, 112int dsa_builtin_paramgen(DSA *ret, size_t bits, size_t qbits,
103 unsigned char *seed_in, int seed_len, 113 const EVP_MD *evpmd, const unsigned char *seed_in, size_t seed_len,
104 int *counter_ret, unsigned long *h_ret, BN_GENCB *cb) 114 int *counter_ret, unsigned long *h_ret, BN_GENCB *cb)
105 { 115 {
106 int ok=0; 116 int ok=0;
107 unsigned char seed[SHA_DIGEST_LENGTH]; 117 unsigned char seed[SHA256_DIGEST_LENGTH];
108 unsigned char md[SHA_DIGEST_LENGTH]; 118 unsigned char md[SHA256_DIGEST_LENGTH];
109 unsigned char buf[SHA_DIGEST_LENGTH],buf2[SHA_DIGEST_LENGTH]; 119 unsigned char buf[SHA256_DIGEST_LENGTH],buf2[SHA256_DIGEST_LENGTH];
110 BIGNUM *r0,*W,*X,*c,*test; 120 BIGNUM *r0,*W,*X,*c,*test;
111 BIGNUM *g=NULL,*q=NULL,*p=NULL; 121 BIGNUM *g=NULL,*q=NULL,*p=NULL;
112 BN_MONT_CTX *mont=NULL; 122 BN_MONT_CTX *mont=NULL;
113 int k,n=0,i,b,m=0; 123 int i, k,n=0,b,m=0, qsize = qbits >> 3;
114 int counter=0; 124 int counter=0;
115 int r=0; 125 int r=0;
116 BN_CTX *ctx=NULL; 126 BN_CTX *ctx=NULL;
117 unsigned int h=2; 127 unsigned int h=2;
118 128
119 if (bits < 512) bits=512; 129 if (qsize != SHA_DIGEST_LENGTH && qsize != SHA224_DIGEST_LENGTH &&
120 bits=(bits+63)/64*64; 130 qsize != SHA256_DIGEST_LENGTH)
131 /* invalid q size */
132 return 0;
133
134 if (evpmd == NULL)
135 /* use SHA1 as default */
136 evpmd = EVP_sha1();
137
138 if (bits < 512)
139 bits = 512;
140
141 bits = (bits+63)/64*64;
121 142
122 /* NB: seed_len == 0 is special case: copy generated seed to 143 /* NB: seed_len == 0 is special case: copy generated seed to
123 * seed_in if it is not NULL. 144 * seed_in if it is not NULL.
124 */ 145 */
125 if (seed_len && (seed_len < 20)) 146 if (seed_len && (seed_len < (size_t)qsize))
126 seed_in = NULL; /* seed buffer too small -- ignore */ 147 seed_in = NULL; /* seed buffer too small -- ignore */
127 if (seed_len > 20) 148 if (seed_len > (size_t)qsize)
128 seed_len = 20; /* App. 2.2 of FIPS PUB 186 allows larger SEED, 149 seed_len = qsize; /* App. 2.2 of FIPS PUB 186 allows larger SEED,
129 * but our internal buffers are restricted to 160 bits*/ 150 * but our internal buffers are restricted to 160 bits*/
130 if ((seed_in != NULL) && (seed_len == 20)) 151 if (seed_in != NULL)
131 { 152 memcpy(seed, seed_in, seed_len);
132 memcpy(seed,seed_in,seed_len); 153
133 /* set seed_in to NULL to avoid it being copied back */ 154 if ((ctx=BN_CTX_new()) == NULL)
134 seed_in = NULL; 155 goto err;
135 }
136
137 if ((ctx=BN_CTX_new()) == NULL) goto err;
138 156
139 if ((mont=BN_MONT_CTX_new()) == NULL) goto err; 157 if ((mont=BN_MONT_CTX_new()) == NULL)
158 goto err;
140 159
141 BN_CTX_start(ctx); 160 BN_CTX_start(ctx);
142 r0 = BN_CTX_get(ctx); 161 r0 = BN_CTX_get(ctx);
@@ -163,7 +182,7 @@ static int dsa_builtin_paramgen(DSA *ret, int bits,
163 182
164 if (!seed_len) 183 if (!seed_len)
165 { 184 {
166 RAND_pseudo_bytes(seed,SHA_DIGEST_LENGTH); 185 RAND_pseudo_bytes(seed, qsize);
167 seed_is_random = 1; 186 seed_is_random = 1;
168 } 187 }
169 else 188 else
@@ -171,25 +190,27 @@ static int dsa_builtin_paramgen(DSA *ret, int bits,
171 seed_is_random = 0; 190 seed_is_random = 0;
172 seed_len=0; /* use random seed if 'seed_in' turns out to be bad*/ 191 seed_len=0; /* use random seed if 'seed_in' turns out to be bad*/
173 } 192 }
174 memcpy(buf,seed,SHA_DIGEST_LENGTH); 193 memcpy(buf , seed, qsize);
175 memcpy(buf2,seed,SHA_DIGEST_LENGTH); 194 memcpy(buf2, seed, qsize);
176 /* precompute "SEED + 1" for step 7: */ 195 /* precompute "SEED + 1" for step 7: */
177 for (i=SHA_DIGEST_LENGTH-1; i >= 0; i--) 196 for (i = qsize-1; i >= 0; i--)
178 { 197 {
179 buf[i]++; 198 buf[i]++;
180 if (buf[i] != 0) break; 199 if (buf[i] != 0)
200 break;
181 } 201 }
182 202
183 /* step 2 */ 203 /* step 2 */
184 EVP_Digest(seed,SHA_DIGEST_LENGTH,md,NULL,HASH, NULL); 204 EVP_Digest(seed, qsize, md, NULL, evpmd, NULL);
185 EVP_Digest(buf,SHA_DIGEST_LENGTH,buf2,NULL,HASH, NULL); 205 EVP_Digest(buf, qsize, buf2, NULL, evpmd, NULL);
186 for (i=0; i<SHA_DIGEST_LENGTH; i++) 206 for (i = 0; i < qsize; i++)
187 md[i]^=buf2[i]; 207 md[i]^=buf2[i];
188 208
189 /* step 3 */ 209 /* step 3 */
190 md[0]|=0x80; 210 md[0] |= 0x80;
191 md[SHA_DIGEST_LENGTH-1]|=0x01; 211 md[qsize-1] |= 0x01;
192 if (!BN_bin2bn(md,SHA_DIGEST_LENGTH,q)) goto err; 212 if (!BN_bin2bn(md, qsize, q))
213 goto err;
193 214
194 /* step 4 */ 215 /* step 4 */
195 r = BN_is_prime_fasttest_ex(q, DSS_prime_checks, ctx, 216 r = BN_is_prime_fasttest_ex(q, DSS_prime_checks, ctx,
@@ -224,18 +245,19 @@ static int dsa_builtin_paramgen(DSA *ret, int bits,
224 for (k=0; k<=n; k++) 245 for (k=0; k<=n; k++)
225 { 246 {
226 /* obtain "SEED + offset + k" by incrementing: */ 247 /* obtain "SEED + offset + k" by incrementing: */
227 for (i=SHA_DIGEST_LENGTH-1; i >= 0; i--) 248 for (i = qsize-1; i >= 0; i--)
228 { 249 {
229 buf[i]++; 250 buf[i]++;
230 if (buf[i] != 0) break; 251 if (buf[i] != 0)
252 break;
231 } 253 }
232 254
233 EVP_Digest(buf,SHA_DIGEST_LENGTH,md,NULL,HASH, NULL); 255 EVP_Digest(buf, qsize, md ,NULL, evpmd, NULL);
234 256
235 /* step 8 */ 257 /* step 8 */
236 if (!BN_bin2bn(md,SHA_DIGEST_LENGTH,r0)) 258 if (!BN_bin2bn(md, qsize, r0))
237 goto err; 259 goto err;
238 if (!BN_lshift(r0,r0,160*k)) goto err; 260 if (!BN_lshift(r0,r0,(qsize << 3)*k)) goto err;
239 if (!BN_add(W,W,r0)) goto err; 261 if (!BN_add(W,W,r0)) goto err;
240 } 262 }
241 263
@@ -309,7 +331,6 @@ err:
309 ok=0; 331 ok=0;
310 goto err; 332 goto err;
311 } 333 }
312 if (seed_in != NULL) memcpy(seed_in,seed,20);
313 if (counter_ret != NULL) *counter_ret=counter; 334 if (counter_ret != NULL) *counter_ret=counter;
314 if (h_ret != NULL) *h_ret=h; 335 if (h_ret != NULL) *h_ret=h;
315 } 336 }
@@ -322,4 +343,3 @@ err:
322 return ok; 343 return ok;
323 } 344 }
324#endif 345#endif
325#endif
diff --git a/src/lib/libcrypto/dsa/dsa_key.c b/src/lib/libcrypto/dsa/dsa_key.c
index 5e39124230..c4aa86bc6d 100644
--- a/src/lib/libcrypto/dsa/dsa_key.c
+++ b/src/lib/libcrypto/dsa/dsa_key.c
@@ -64,8 +64,6 @@
64#include <openssl/dsa.h> 64#include <openssl/dsa.h>
65#include <openssl/rand.h> 65#include <openssl/rand.h>
66 66
67#ifndef OPENSSL_FIPS
68
69static int dsa_builtin_keygen(DSA *dsa); 67static int dsa_builtin_keygen(DSA *dsa);
70 68
71int DSA_generate_key(DSA *dsa) 69int DSA_generate_key(DSA *dsa)
@@ -128,5 +126,3 @@ err:
128 return(ok); 126 return(ok);
129 } 127 }
130#endif 128#endif
131
132#endif
diff --git a/src/lib/libcrypto/dsa/dsa_lib.c b/src/lib/libcrypto/dsa/dsa_lib.c
index 7ac9dc8c89..e9b75902db 100644
--- a/src/lib/libcrypto/dsa/dsa_lib.c
+++ b/src/lib/libcrypto/dsa/dsa_lib.c
@@ -76,14 +76,6 @@ static const DSA_METHOD *default_DSA_method = NULL;
76 76
77void DSA_set_default_method(const DSA_METHOD *meth) 77void DSA_set_default_method(const DSA_METHOD *meth)
78 { 78 {
79#ifdef OPENSSL_FIPS
80 if (FIPS_mode() && !(meth->flags & DSA_FLAG_FIPS_METHOD))
81 {
82 DSAerr(DSA_F_DSA_SET_DEFAULT_METHOD, DSA_R_NON_FIPS_METHOD);
83 return;
84 }
85#endif
86
87 default_DSA_method = meth; 79 default_DSA_method = meth;
88 } 80 }
89 81
@@ -104,13 +96,6 @@ int DSA_set_method(DSA *dsa, const DSA_METHOD *meth)
104 /* NB: The caller is specifically setting a method, so it's not up to us 96 /* NB: The caller is specifically setting a method, so it's not up to us
105 * to deal with which ENGINE it comes from. */ 97 * to deal with which ENGINE it comes from. */
106 const DSA_METHOD *mtmp; 98 const DSA_METHOD *mtmp;
107#ifdef OPENSSL_FIPS
108 if (FIPS_mode() && !(meth->flags & DSA_FLAG_FIPS_METHOD))
109 {
110 DSAerr(DSA_F_DSA_SET_METHOD, DSA_R_NON_FIPS_METHOD);
111 return 0;
112 }
113#endif
114 mtmp = dsa->meth; 99 mtmp = dsa->meth;
115 if (mtmp->finish) mtmp->finish(dsa); 100 if (mtmp->finish) mtmp->finish(dsa);
116#ifndef OPENSSL_NO_ENGINE 101#ifndef OPENSSL_NO_ENGINE
@@ -162,18 +147,6 @@ DSA *DSA_new_method(ENGINE *engine)
162 } 147 }
163 } 148 }
164#endif 149#endif
165#ifdef OPENSSL_FIPS
166 if (FIPS_mode() && !(ret->meth->flags & DSA_FLAG_FIPS_METHOD))
167 {
168 DSAerr(DSA_F_DSA_NEW_METHOD, DSA_R_NON_FIPS_METHOD);
169#ifndef OPENSSL_NO_ENGINE
170 if (ret->engine)
171 ENGINE_finish(ret->engine);
172#endif
173 OPENSSL_free(ret);
174 return NULL;
175 }
176#endif
177 150
178 ret->pad=0; 151 ret->pad=0;
179 ret->version=0; 152 ret->version=0;
@@ -260,6 +233,28 @@ int DSA_up_ref(DSA *r)
260 return ((i > 1) ? 1 : 0); 233 return ((i > 1) ? 1 : 0);
261 } 234 }
262 235
236int DSA_size(const DSA *r)
237 {
238 int ret,i;
239 ASN1_INTEGER bs;
240 unsigned char buf[4]; /* 4 bytes looks really small.
241 However, i2d_ASN1_INTEGER() will not look
242 beyond the first byte, as long as the second
243 parameter is NULL. */
244
245 i=BN_num_bits(r->q);
246 bs.length=(i+7)/8;
247 bs.data=buf;
248 bs.type=V_ASN1_INTEGER;
249 /* If the top bit is set the asn1 encoding is 1 larger. */
250 buf[0]=0xff;
251
252 i=i2d_ASN1_INTEGER(&bs,NULL);
253 i+=i; /* r and s */
254 ret=ASN1_object_size(1,i,V_ASN1_SEQUENCE);
255 return(ret);
256 }
257
263int DSA_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func, 258int DSA_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func,
264 CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func) 259 CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func)
265 { 260 {
diff --git a/src/lib/libcrypto/dsa/dsa_ossl.c b/src/lib/libcrypto/dsa/dsa_ossl.c
index 412cf1d88b..4fead07e80 100644
--- a/src/lib/libcrypto/dsa/dsa_ossl.c
+++ b/src/lib/libcrypto/dsa/dsa_ossl.c
@@ -61,16 +61,15 @@
61#include <stdio.h> 61#include <stdio.h>
62#include "cryptlib.h" 62#include "cryptlib.h"
63#include <openssl/bn.h> 63#include <openssl/bn.h>
64#include <openssl/sha.h>
64#include <openssl/dsa.h> 65#include <openssl/dsa.h>
65#include <openssl/rand.h> 66#include <openssl/rand.h>
66#include <openssl/asn1.h> 67#include <openssl/asn1.h>
67 68
68#ifndef OPENSSL_FIPS
69
70static DSA_SIG *dsa_do_sign(const unsigned char *dgst, int dlen, DSA *dsa); 69static DSA_SIG *dsa_do_sign(const unsigned char *dgst, int dlen, DSA *dsa);
71static int dsa_sign_setup(DSA *dsa, BN_CTX *ctx_in, BIGNUM **kinvp, BIGNUM **rp); 70static int dsa_sign_setup(DSA *dsa, BN_CTX *ctx_in, BIGNUM **kinvp, BIGNUM **rp);
72static int dsa_do_verify(const unsigned char *dgst, int dgst_len, DSA_SIG *sig, 71static int dsa_do_verify(const unsigned char *dgst, int dgst_len, DSA_SIG *sig,
73 DSA *dsa); 72 DSA *dsa);
74static int dsa_init(DSA *dsa); 73static int dsa_init(DSA *dsa);
75static int dsa_finish(DSA *dsa); 74static int dsa_finish(DSA *dsa);
76 75
@@ -135,7 +134,7 @@ static DSA_SIG *dsa_do_sign(const unsigned char *dgst, int dlen, DSA *dsa)
135 BIGNUM m; 134 BIGNUM m;
136 BIGNUM xr; 135 BIGNUM xr;
137 BN_CTX *ctx=NULL; 136 BN_CTX *ctx=NULL;
138 int i,reason=ERR_R_BN_LIB; 137 int reason=ERR_R_BN_LIB;
139 DSA_SIG *ret=NULL; 138 DSA_SIG *ret=NULL;
140 139
141 BN_init(&m); 140 BN_init(&m);
@@ -150,8 +149,9 @@ static DSA_SIG *dsa_do_sign(const unsigned char *dgst, int dlen, DSA *dsa)
150 s=BN_new(); 149 s=BN_new();
151 if (s == NULL) goto err; 150 if (s == NULL) goto err;
152 151
153 i=BN_num_bytes(dsa->q); /* should be 20 */ 152 /* reject a excessive digest length (currently at most
154 if ((dlen > i) || (dlen > 50)) 153 * dsa-with-SHA256 is supported) */
154 if (dlen > SHA256_DIGEST_LENGTH)
155 { 155 {
156 reason=DSA_R_DATA_TOO_LARGE_FOR_KEY_SIZE; 156 reason=DSA_R_DATA_TOO_LARGE_FOR_KEY_SIZE;
157 goto err; 157 goto err;
@@ -172,7 +172,14 @@ static DSA_SIG *dsa_do_sign(const unsigned char *dgst, int dlen, DSA *dsa)
172 dsa->r=NULL; 172 dsa->r=NULL;
173 } 173 }
174 174
175 if (BN_bin2bn(dgst,dlen,&m) == NULL) goto err; 175
176 if (dlen > BN_num_bytes(dsa->q))
177 /* if the digest length is greater than the size of q use the
178 * BN_num_bits(dsa->q) leftmost bits of the digest, see
179 * fips 186-3, 4.2 */
180 dlen = BN_num_bytes(dsa->q);
181 if (BN_bin2bn(dgst,dlen,&m) == NULL)
182 goto err;
176 183
177 /* Compute s = inv(k) (m + xr) mod q */ 184 /* Compute s = inv(k) (m + xr) mod q */
178 if (!BN_mod_mul(&xr,dsa->priv_key,r,dsa->q,ctx)) goto err;/* s = xr */ 185 if (!BN_mod_mul(&xr,dsa->priv_key,r,dsa->q,ctx)) goto err;/* s = xr */
@@ -283,30 +290,31 @@ err:
283 if (!ret) 290 if (!ret)
284 { 291 {
285 DSAerr(DSA_F_DSA_SIGN_SETUP,ERR_R_BN_LIB); 292 DSAerr(DSA_F_DSA_SIGN_SETUP,ERR_R_BN_LIB);
286 if (kinv != NULL) BN_clear_free(kinv); 293 if (r != NULL)
287 if (r != NULL) BN_clear_free(r); 294 BN_clear_free(r);
288 } 295 }
289 if (ctx_in == NULL) BN_CTX_free(ctx); 296 if (ctx_in == NULL) BN_CTX_free(ctx);
290 if (kinv != NULL) BN_clear_free(kinv);
291 BN_clear_free(&k); 297 BN_clear_free(&k);
292 BN_clear_free(&kq); 298 BN_clear_free(&kq);
293 return(ret); 299 return(ret);
294 } 300 }
295 301
296static int dsa_do_verify(const unsigned char *dgst, int dgst_len, DSA_SIG *sig, 302static int dsa_do_verify(const unsigned char *dgst, int dgst_len, DSA_SIG *sig,
297 DSA *dsa) 303 DSA *dsa)
298 { 304 {
299 BN_CTX *ctx; 305 BN_CTX *ctx;
300 BIGNUM u1,u2,t1; 306 BIGNUM u1,u2,t1;
301 BN_MONT_CTX *mont=NULL; 307 BN_MONT_CTX *mont=NULL;
302 int ret = -1; 308 int ret = -1, i;
303 if (!dsa->p || !dsa->q || !dsa->g) 309 if (!dsa->p || !dsa->q || !dsa->g)
304 { 310 {
305 DSAerr(DSA_F_DSA_DO_VERIFY,DSA_R_MISSING_PARAMETERS); 311 DSAerr(DSA_F_DSA_DO_VERIFY,DSA_R_MISSING_PARAMETERS);
306 return -1; 312 return -1;
307 } 313 }
308 314
309 if (BN_num_bits(dsa->q) != 160) 315 i = BN_num_bits(dsa->q);
316 /* fips 186-3 allows only different sizes for q */
317 if (i != 160 && i != 224 && i != 256)
310 { 318 {
311 DSAerr(DSA_F_DSA_DO_VERIFY,DSA_R_BAD_Q_VALUE); 319 DSAerr(DSA_F_DSA_DO_VERIFY,DSA_R_BAD_Q_VALUE);
312 return -1; 320 return -1;
@@ -318,6 +326,14 @@ static int dsa_do_verify(const unsigned char *dgst, int dgst_len, DSA_SIG *sig,
318 return -1; 326 return -1;
319 } 327 }
320 328
329 /* reject a excessive digest length (currently at most
330 * dsa-with-SHA256 is supported) */
331 if (dgst_len > SHA256_DIGEST_LENGTH)
332 {
333 DSAerr(DSA_F_DSA_DO_VERIFY,DSA_R_DATA_TOO_LARGE_FOR_KEY_SIZE);
334 return -1;
335 }
336
321 BN_init(&u1); 337 BN_init(&u1);
322 BN_init(&u2); 338 BN_init(&u2);
323 BN_init(&t1); 339 BN_init(&t1);
@@ -342,6 +358,11 @@ static int dsa_do_verify(const unsigned char *dgst, int dgst_len, DSA_SIG *sig,
342 if ((BN_mod_inverse(&u2,sig->s,dsa->q,ctx)) == NULL) goto err; 358 if ((BN_mod_inverse(&u2,sig->s,dsa->q,ctx)) == NULL) goto err;
343 359
344 /* save M in u1 */ 360 /* save M in u1 */
361 if (dgst_len > (i >> 3))
362 /* if the digest length is greater than the size of q use the
363 * BN_num_bits(dsa->q) leftmost bits of the digest, see
364 * fips 186-3, 4.2 */
365 dgst_len = (i >> 3);
345 if (BN_bin2bn(dgst,dgst_len,&u1) == NULL) goto err; 366 if (BN_bin2bn(dgst,dgst_len,&u1) == NULL) goto err;
346 367
347 /* u1 = M * w mod q */ 368 /* u1 = M * w mod q */
@@ -393,4 +414,3 @@ static int dsa_finish(DSA *dsa)
393 return(1); 414 return(1);
394} 415}
395 416
396#endif
diff --git a/src/lib/libcrypto/dsa/dsa_sign.c b/src/lib/libcrypto/dsa/dsa_sign.c
index 4cfbbe57a8..17555e5892 100644
--- a/src/lib/libcrypto/dsa/dsa_sign.c
+++ b/src/lib/libcrypto/dsa/dsa_sign.c
@@ -58,38 +58,33 @@
58 58
59/* Original version from Steven Schoch <schoch@sheba.arc.nasa.gov> */ 59/* Original version from Steven Schoch <schoch@sheba.arc.nasa.gov> */
60 60
61#include <stdio.h>
62#include "cryptlib.h" 61#include "cryptlib.h"
63#include <openssl/bn.h>
64#include <openssl/dsa.h> 62#include <openssl/dsa.h>
65#include <openssl/rand.h> 63#include <openssl/rand.h>
66#include <openssl/asn1.h>
67#ifdef OPENSSL_FIPS
68#include <openssl/fips.h>
69#endif
70
71 64
72DSA_SIG * DSA_do_sign(const unsigned char *dgst, int dlen, DSA *dsa) 65DSA_SIG * DSA_do_sign(const unsigned char *dgst, int dlen, DSA *dsa)
73 { 66 {
74#ifdef OPENSSL_FIPS
75 if(FIPS_mode() && !(dsa->flags & DSA_FLAG_NON_FIPS_ALLOW))
76 {
77 DSAerr(DSA_F_DSA_DO_SIGN, DSA_R_OPERATION_NOT_ALLOWED_IN_FIPS_MODE);
78 return NULL;
79 }
80#endif
81 return dsa->meth->dsa_do_sign(dgst, dlen, dsa); 67 return dsa->meth->dsa_do_sign(dgst, dlen, dsa);
82 } 68 }
83 69
84int DSA_sign_setup(DSA *dsa, BN_CTX *ctx_in, BIGNUM **kinvp, BIGNUM **rp) 70int DSA_sign(int type, const unsigned char *dgst, int dlen, unsigned char *sig,
71 unsigned int *siglen, DSA *dsa)
85 { 72 {
86#ifdef OPENSSL_FIPS 73 DSA_SIG *s;
87 if(FIPS_mode() && !(dsa->flags & DSA_FLAG_NON_FIPS_ALLOW)) 74 RAND_seed(dgst, dlen);
75 s=DSA_do_sign(dgst,dlen,dsa);
76 if (s == NULL)
88 { 77 {
89 DSAerr(DSA_F_DSA_SIGN_SETUP, DSA_R_OPERATION_NOT_ALLOWED_IN_FIPS_MODE); 78 *siglen=0;
90 return 0; 79 return(0);
91 } 80 }
92#endif 81 *siglen=i2d_DSA_SIG(s,&sig);
82 DSA_SIG_free(s);
83 return(1);
84 }
85
86int DSA_sign_setup(DSA *dsa, BN_CTX *ctx_in, BIGNUM **kinvp, BIGNUM **rp)
87 {
93 return dsa->meth->dsa_sign_setup(dsa, ctx_in, kinvp, rp); 88 return dsa->meth->dsa_sign_setup(dsa, ctx_in, kinvp, rp);
94 } 89 }
95 90
diff --git a/src/lib/libcrypto/dsa/dsa_utl.c b/src/lib/libcrypto/dsa/dsa_utl.c
deleted file mode 100644
index 24c021d120..0000000000
--- a/src/lib/libcrypto/dsa/dsa_utl.c
+++ /dev/null
@@ -1,95 +0,0 @@
1/* crypto/dsa/dsa_lib.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/* Original version from Steven Schoch <schoch@sheba.arc.nasa.gov> */
60
61#include <stdio.h>
62#include "cryptlib.h"
63#include <openssl/bn.h>
64#include <openssl/dsa.h>
65#include <openssl/asn1.h>
66#ifndef OPENSSL_NO_ENGINE
67#include <openssl/engine.h>
68#endif
69#ifndef OPENSSL_NO_DH
70#include <openssl/dh.h>
71#endif
72
73DSA_SIG *DSA_SIG_new(void)
74 {
75 DSA_SIG *sig;
76 sig = OPENSSL_malloc(sizeof(DSA_SIG));
77 if (!sig)
78 return NULL;
79 sig->r = NULL;
80 sig->s = NULL;
81 return sig;
82 }
83
84void DSA_SIG_free(DSA_SIG *sig)
85 {
86 if (sig)
87 {
88 if (sig->r)
89 BN_free(sig->r);
90 if (sig->s)
91 BN_free(sig->s);
92 OPENSSL_free(sig);
93 }
94 }
95
diff --git a/src/lib/libcrypto/dsa/dsa_vrf.c b/src/lib/libcrypto/dsa/dsa_vrf.c
index c75e423048..226a75ff3f 100644
--- a/src/lib/libcrypto/dsa/dsa_vrf.c
+++ b/src/lib/libcrypto/dsa/dsa_vrf.c
@@ -58,27 +58,32 @@
58 58
59/* Original version from Steven Schoch <schoch@sheba.arc.nasa.gov> */ 59/* Original version from Steven Schoch <schoch@sheba.arc.nasa.gov> */
60 60
61#include <stdio.h>
62#include "cryptlib.h" 61#include "cryptlib.h"
63#include <openssl/bn.h>
64#include <openssl/dsa.h> 62#include <openssl/dsa.h>
65#include <openssl/rand.h>
66#include <openssl/asn1.h>
67#ifdef OPENSSL_FIPS
68#include <openssl/fips.h>
69#endif
70
71#include <openssl/asn1_mac.h>
72 63
73int DSA_do_verify(const unsigned char *dgst, int dgst_len, DSA_SIG *sig, 64int DSA_do_verify(const unsigned char *dgst, int dgst_len, DSA_SIG *sig,
74 DSA *dsa) 65 DSA *dsa)
75 { 66 {
76#ifdef OPENSSL_FIPS
77 if(FIPS_mode() && !(dsa->flags & DSA_FLAG_NON_FIPS_ALLOW))
78 {
79 DSAerr(DSA_F_DSA_DO_VERIFY, DSA_R_OPERATION_NOT_ALLOWED_IN_FIPS_MODE);
80 return 0;
81 }
82#endif
83 return dsa->meth->dsa_do_verify(dgst, dgst_len, sig, dsa); 67 return dsa->meth->dsa_do_verify(dgst, dgst_len, sig, dsa);
84 } 68 }
69
70/* data has already been hashed (probably with SHA or SHA-1). */
71/* returns
72 * 1: correct signature
73 * 0: incorrect signature
74 * -1: error
75 */
76int DSA_verify(int type, const unsigned char *dgst, int dgst_len,
77 const unsigned char *sigbuf, int siglen, DSA *dsa)
78 {
79 DSA_SIG *s;
80 int ret=-1;
81
82 s = DSA_SIG_new();
83 if (s == NULL) return(ret);
84 if (d2i_DSA_SIG(&s,&sigbuf,siglen) == NULL) goto err;
85 ret=DSA_do_verify(dgst,dgst_len,s,dsa);
86err:
87 DSA_SIG_free(s);
88 return(ret);
89 }
diff --git a/src/lib/libcrypto/dsa/dsatest.c b/src/lib/libcrypto/dsa/dsatest.c
index 912317bb44..edffd24e6b 100644
--- a/src/lib/libcrypto/dsa/dsatest.c
+++ b/src/lib/libcrypto/dsa/dsatest.c
@@ -169,7 +169,6 @@ int main(int argc, char **argv)
169 } 169 }
170 BIO_printf(bio_err,"\ncounter=%d h=%ld\n",counter,h); 170 BIO_printf(bio_err,"\ncounter=%d h=%ld\n",counter,h);
171 171
172 if (dsa == NULL) goto end;
173 DSA_print(bio_err,dsa,0); 172 DSA_print(bio_err,dsa,0);
174 if (counter != 105) 173 if (counter != 105)
175 { 174 {
@@ -223,7 +222,7 @@ end:
223 ERR_print_errors(bio_err); 222 ERR_print_errors(bio_err);
224 if (dsa != NULL) DSA_free(dsa); 223 if (dsa != NULL) DSA_free(dsa);
225 CRYPTO_cleanup_all_ex_data(); 224 CRYPTO_cleanup_all_ex_data();
226 ERR_remove_state(0); 225 ERR_remove_thread_state(NULL);
227 ERR_free_strings(); 226 ERR_free_strings();
228 CRYPTO_mem_leaks(bio_err); 227 CRYPTO_mem_leaks(bio_err);
229 if (bio_err != NULL) 228 if (bio_err != NULL)
diff --git a/src/lib/libcrypto/dso/Makefile.ssl b/src/lib/libcrypto/dso/Makefile.ssl
deleted file mode 100644
index c0449d184e..0000000000
--- a/src/lib/libcrypto/dso/Makefile.ssl
+++ /dev/null
@@ -1,142 +0,0 @@
1#
2# SSLeay/crypto/dso/Makefile
3#
4
5DIR= dso
6TOP= ../..
7CC= cc
8INCLUDES= -I.. -I$(TOP) -I../../include
9CFLAG=-g
10INSTALL_PREFIX=
11OPENSSLDIR= /usr/local/ssl
12INSTALLTOP=/usr/local/ssl
13MAKE= make -f Makefile.ssl
14MAKEDEPPROG= makedepend
15MAKEDEPEND= $(TOP)/util/domd $(TOP) -MD $(MAKEDEPPROG)
16MAKEFILE= Makefile.ssl
17AR= ar r
18
19CFLAGS= $(INCLUDES) $(CFLAG)
20
21GENERAL=Makefile
22TEST=
23APPS=
24
25LIB=$(TOP)/libcrypto.a
26LIBSRC= dso_dl.c dso_dlfcn.c dso_err.c dso_lib.c dso_null.c \
27 dso_openssl.c dso_win32.c dso_vms.c
28LIBOBJ= dso_dl.o dso_dlfcn.o dso_err.o dso_lib.o dso_null.o \
29 dso_openssl.o dso_win32.o dso_vms.o
30
31SRC= $(LIBSRC)
32
33EXHEADER= dso.h
34HEADER= $(EXHEADER)
35
36ALL= $(GENERAL) $(SRC) $(HEADER)
37
38top:
39 (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all)
40
41all: lib
42
43lib: $(LIBOBJ)
44 $(AR) $(LIB) $(LIBOBJ)
45 $(RANLIB) $(LIB) || echo Never mind.
46 @touch lib
47
48files:
49 $(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO
50
51links:
52 @sh $(TOP)/util/point.sh Makefile.ssl Makefile
53 @$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER)
54 @$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST)
55 @$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS)
56
57install:
58 @for i in $(EXHEADER) ; \
59 do \
60 (cp $$i $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i; \
61 chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i ); \
62 done;
63
64tags:
65 ctags $(SRC)
66
67tests:
68
69lint:
70 lint -DLINT $(INCLUDES) $(SRC)>fluff
71
72depend:
73 $(MAKEDEPEND) -- $(CFLAG) $(INCLUDES) $(DEPFLAG) -- $(PROGS) $(LIBSRC)
74
75dclean:
76 $(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
77 mv -f Makefile.new $(MAKEFILE)
78
79clean:
80 rm -f *.o */*.o *.obj lib tags core .pure .nfs* *.old *.bak fluff
81
82# DO NOT DELETE THIS LINE -- make depend depends on it.
83
84dso_dl.o: ../../e_os.h ../../include/openssl/bio.h
85dso_dl.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
86dso_dl.o: ../../include/openssl/dso.h ../../include/openssl/e_os2.h
87dso_dl.o: ../../include/openssl/err.h ../../include/openssl/lhash.h
88dso_dl.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
89dso_dl.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
90dso_dl.o: ../../include/openssl/symhacks.h ../cryptlib.h dso_dl.c
91dso_dlfcn.o: ../../e_os.h ../../include/openssl/bio.h
92dso_dlfcn.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
93dso_dlfcn.o: ../../include/openssl/dso.h ../../include/openssl/e_os2.h
94dso_dlfcn.o: ../../include/openssl/err.h ../../include/openssl/lhash.h
95dso_dlfcn.o: ../../include/openssl/opensslconf.h
96dso_dlfcn.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
97dso_dlfcn.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
98dso_dlfcn.o: ../cryptlib.h dso_dlfcn.c
99dso_err.o: ../../include/openssl/bio.h ../../include/openssl/crypto.h
100dso_err.o: ../../include/openssl/dso.h ../../include/openssl/e_os2.h
101dso_err.o: ../../include/openssl/err.h ../../include/openssl/lhash.h
102dso_err.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
103dso_err.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
104dso_err.o: ../../include/openssl/symhacks.h dso_err.c
105dso_lib.o: ../../e_os.h ../../include/openssl/bio.h
106dso_lib.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
107dso_lib.o: ../../include/openssl/dso.h ../../include/openssl/e_os2.h
108dso_lib.o: ../../include/openssl/err.h ../../include/openssl/lhash.h
109dso_lib.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
110dso_lib.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
111dso_lib.o: ../../include/openssl/symhacks.h ../cryptlib.h dso_lib.c
112dso_null.o: ../../e_os.h ../../include/openssl/bio.h
113dso_null.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
114dso_null.o: ../../include/openssl/dso.h ../../include/openssl/e_os2.h
115dso_null.o: ../../include/openssl/err.h ../../include/openssl/lhash.h
116dso_null.o: ../../include/openssl/opensslconf.h
117dso_null.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
118dso_null.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
119dso_null.o: ../cryptlib.h dso_null.c
120dso_openssl.o: ../../e_os.h ../../include/openssl/bio.h
121dso_openssl.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
122dso_openssl.o: ../../include/openssl/dso.h ../../include/openssl/e_os2.h
123dso_openssl.o: ../../include/openssl/err.h ../../include/openssl/lhash.h
124dso_openssl.o: ../../include/openssl/opensslconf.h
125dso_openssl.o: ../../include/openssl/opensslv.h
126dso_openssl.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
127dso_openssl.o: ../../include/openssl/symhacks.h ../cryptlib.h dso_openssl.c
128dso_vms.o: ../../e_os.h ../../include/openssl/bio.h
129dso_vms.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
130dso_vms.o: ../../include/openssl/dso.h ../../include/openssl/e_os2.h
131dso_vms.o: ../../include/openssl/err.h ../../include/openssl/lhash.h
132dso_vms.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
133dso_vms.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
134dso_vms.o: ../../include/openssl/symhacks.h ../cryptlib.h dso_vms.c
135dso_win32.o: ../../e_os.h ../../include/openssl/bio.h
136dso_win32.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
137dso_win32.o: ../../include/openssl/dso.h ../../include/openssl/e_os2.h
138dso_win32.o: ../../include/openssl/err.h ../../include/openssl/lhash.h
139dso_win32.o: ../../include/openssl/opensslconf.h
140dso_win32.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
141dso_win32.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
142dso_win32.o: ../cryptlib.h dso_win32.c
diff --git a/src/lib/libcrypto/dso/dso.h b/src/lib/libcrypto/dso/dso.h
index 3e51913a72..839f2e0617 100644
--- a/src/lib/libcrypto/dso/dso.h
+++ b/src/lib/libcrypto/dso/dso.h
@@ -170,6 +170,11 @@ typedef struct dso_meth_st
170 /* [De]Initialisation handlers. */ 170 /* [De]Initialisation handlers. */
171 int (*init)(DSO *dso); 171 int (*init)(DSO *dso);
172 int (*finish)(DSO *dso); 172 int (*finish)(DSO *dso);
173
174 /* Return pathname of the module containing location */
175 int (*pathbyaddr)(void *addr,char *path,int sz);
176 /* Perform global symbol lookup, i.e. among *all* modules */
177 void *(*globallookup)(const char *symname);
173 } DSO_METHOD; 178 } DSO_METHOD;
174 179
175/**********************************************************************/ 180/**********************************************************************/
@@ -183,7 +188,7 @@ struct dso_st
183 * for use in the dso_bind handler. All in all, let each 188 * for use in the dso_bind handler. All in all, let each
184 * method control its own destiny. "Handles" and such go in 189 * method control its own destiny. "Handles" and such go in
185 * a STACK. */ 190 * a STACK. */
186 STACK *meth_data; 191 STACK_OF(void) *meth_data;
187 int references; 192 int references;
188 int flags; 193 int flags;
189 /* For use by applications etc ... use this for your bits'n'pieces, 194 /* For use by applications etc ... use this for your bits'n'pieces,
@@ -296,6 +301,30 @@ DSO_METHOD *DSO_METHOD_win32(void);
296/* If VMS is defined, use shared images. If not, return NULL. */ 301/* If VMS is defined, use shared images. If not, return NULL. */
297DSO_METHOD *DSO_METHOD_vms(void); 302DSO_METHOD *DSO_METHOD_vms(void);
298 303
304/* This function writes null-terminated pathname of DSO module
305 * containing 'addr' into 'sz' large caller-provided 'path' and
306 * returns the number of characters [including trailing zero]
307 * written to it. If 'sz' is 0 or negative, 'path' is ignored and
308 * required amount of charachers [including trailing zero] to
309 * accomodate pathname is returned. If 'addr' is NULL, then
310 * pathname of cryptolib itself is returned. Negative or zero
311 * return value denotes error.
312 */
313int DSO_pathbyaddr(void *addr,char *path,int sz);
314
315/* This function should be used with caution! It looks up symbols in
316 * *all* loaded modules and if module gets unloaded by somebody else
317 * attempt to dereference the pointer is doomed to have fatal
318 * consequences. Primary usage for this function is to probe *core*
319 * system functionality, e.g. check if getnameinfo(3) is available
320 * at run-time without bothering about OS-specific details such as
321 * libc.so.versioning or where does it actually reside: in libc
322 * itself or libsocket. */
323void *DSO_global_lookup(const char *name);
324
325/* If BeOS is defined, use shared images. If not, return NULL. */
326DSO_METHOD *DSO_METHOD_beos(void);
327
299/* BEGIN ERROR CODES */ 328/* BEGIN ERROR CODES */
300/* The following lines are auto generated by the script mkerr.pl. Any changes 329/* The following lines are auto generated by the script mkerr.pl. Any changes
301 * made after this point may be overwritten when the script is next run. 330 * made after this point may be overwritten when the script is next run.
@@ -305,6 +334,11 @@ void ERR_load_DSO_strings(void);
305/* Error codes for the DSO functions. */ 334/* Error codes for the DSO functions. */
306 335
307/* Function codes. */ 336/* Function codes. */
337#define DSO_F_BEOS_BIND_FUNC 144
338#define DSO_F_BEOS_BIND_VAR 145
339#define DSO_F_BEOS_LOAD 146
340#define DSO_F_BEOS_NAME_CONVERTER 147
341#define DSO_F_BEOS_UNLOAD 148
308#define DSO_F_DLFCN_BIND_FUNC 100 342#define DSO_F_DLFCN_BIND_FUNC 100
309#define DSO_F_DLFCN_BIND_VAR 101 343#define DSO_F_DLFCN_BIND_VAR 101
310#define DSO_F_DLFCN_LOAD 102 344#define DSO_F_DLFCN_LOAD 102
@@ -324,22 +358,29 @@ void ERR_load_DSO_strings(void);
324#define DSO_F_DSO_FREE 111 358#define DSO_F_DSO_FREE 111
325#define DSO_F_DSO_GET_FILENAME 127 359#define DSO_F_DSO_GET_FILENAME 127
326#define DSO_F_DSO_GET_LOADED_FILENAME 128 360#define DSO_F_DSO_GET_LOADED_FILENAME 128
361#define DSO_F_DSO_GLOBAL_LOOKUP 139
327#define DSO_F_DSO_LOAD 112 362#define DSO_F_DSO_LOAD 112
328#define DSO_F_DSO_MERGE 132 363#define DSO_F_DSO_MERGE 132
329#define DSO_F_DSO_NEW_METHOD 113 364#define DSO_F_DSO_NEW_METHOD 113
365#define DSO_F_DSO_PATHBYADDR 140
330#define DSO_F_DSO_SET_FILENAME 129 366#define DSO_F_DSO_SET_FILENAME 129
331#define DSO_F_DSO_SET_NAME_CONVERTER 122 367#define DSO_F_DSO_SET_NAME_CONVERTER 122
332#define DSO_F_DSO_UP_REF 114 368#define DSO_F_DSO_UP_REF 114
369#define DSO_F_GLOBAL_LOOKUP_FUNC 138
370#define DSO_F_PATHBYADDR 137
333#define DSO_F_VMS_BIND_SYM 115 371#define DSO_F_VMS_BIND_SYM 115
334#define DSO_F_VMS_LOAD 116 372#define DSO_F_VMS_LOAD 116
335#define DSO_F_VMS_MERGER 133 373#define DSO_F_VMS_MERGER 133
336#define DSO_F_VMS_UNLOAD 117 374#define DSO_F_VMS_UNLOAD 117
337#define DSO_F_WIN32_BIND_FUNC 118 375#define DSO_F_WIN32_BIND_FUNC 118
338#define DSO_F_WIN32_BIND_VAR 119 376#define DSO_F_WIN32_BIND_VAR 119
377#define DSO_F_WIN32_GLOBALLOOKUP 142
378#define DSO_F_WIN32_GLOBALLOOKUP_FUNC 143
339#define DSO_F_WIN32_JOINER 135 379#define DSO_F_WIN32_JOINER 135
340#define DSO_F_WIN32_LOAD 120 380#define DSO_F_WIN32_LOAD 120
341#define DSO_F_WIN32_MERGER 134 381#define DSO_F_WIN32_MERGER 134
342#define DSO_F_WIN32_NAME_CONVERTER 125 382#define DSO_F_WIN32_NAME_CONVERTER 125
383#define DSO_F_WIN32_PATHBYADDR 141
343#define DSO_F_WIN32_SPLITTER 136 384#define DSO_F_WIN32_SPLITTER 136
344#define DSO_F_WIN32_UNLOAD 121 385#define DSO_F_WIN32_UNLOAD 121
345 386
diff --git a/src/lib/libcrypto/dso/dso_dl.c b/src/lib/libcrypto/dso/dso_dl.c
index 417abb6ea9..c3b4f6cf45 100644
--- a/src/lib/libcrypto/dso/dso_dl.c
+++ b/src/lib/libcrypto/dso/dso_dl.c
@@ -85,6 +85,8 @@ static int dl_ctrl(DSO *dso, int cmd, long larg, void *parg);
85#endif 85#endif
86static char *dl_name_converter(DSO *dso, const char *filename); 86static char *dl_name_converter(DSO *dso, const char *filename);
87static char *dl_merger(DSO *dso, const char *filespec1, const char *filespec2); 87static char *dl_merger(DSO *dso, const char *filespec1, const char *filespec2);
88static int dl_pathbyaddr(void *addr,char *path,int sz);
89static void *dl_globallookup(const char *name);
88 90
89static DSO_METHOD dso_meth_dl = { 91static DSO_METHOD dso_meth_dl = {
90 "OpenSSL 'dl' shared library method", 92 "OpenSSL 'dl' shared library method",
@@ -101,7 +103,9 @@ static DSO_METHOD dso_meth_dl = {
101 dl_name_converter, 103 dl_name_converter,
102 dl_merger, 104 dl_merger,
103 NULL, /* init */ 105 NULL, /* init */
104 NULL /* finish */ 106 NULL, /* finish */
107 dl_pathbyaddr,
108 dl_globallookup
105 }; 109 };
106 110
107DSO_METHOD *DSO_METHOD_dl(void) 111DSO_METHOD *DSO_METHOD_dl(void)
@@ -255,18 +259,20 @@ static char *dl_merger(DSO *dso, const char *filespec1, const char *filespec2)
255 same goes if the second file specification is missing. */ 259 same goes if the second file specification is missing. */
256 if (!filespec2 || filespec1[0] == '/') 260 if (!filespec2 || filespec1[0] == '/')
257 { 261 {
258 merged = OPENSSL_malloc(strlen(filespec1) + 1); 262 size_t len = strlen(filespec1) + 1;
263 merged = OPENSSL_malloc(len);
259 if(!merged) 264 if(!merged)
260 { 265 {
261 DSOerr(DSO_F_DL_MERGER, 266 DSOerr(DSO_F_DL_MERGER,
262 ERR_R_MALLOC_FAILURE); 267 ERR_R_MALLOC_FAILURE);
263 return(NULL); 268 return(NULL);
264 } 269 }
265 strcpy(merged, filespec1); 270 memcpy(merged, filespec1, len);
266 } 271 }
267 /* If the first file specification is missing, the second one rules. */ 272 /* If the first file specification is missing, the second one rules. */
268 else if (!filespec1) 273 else if (!filespec1)
269 { 274 {
275 size_t len = strlen(filespec2) + 1;
270 merged = OPENSSL_malloc(strlen(filespec2) + 1); 276 merged = OPENSSL_malloc(strlen(filespec2) + 1);
271 if(!merged) 277 if(!merged)
272 { 278 {
@@ -274,7 +280,7 @@ static char *dl_merger(DSO *dso, const char *filespec1, const char *filespec2)
274 ERR_R_MALLOC_FAILURE); 280 ERR_R_MALLOC_FAILURE);
275 return(NULL); 281 return(NULL);
276 } 282 }
277 strcpy(merged, filespec2); 283 memcpy(merged, filespec2, len);
278 } 284 }
279 else 285 else
280 /* This part isn't as trivial as it looks. It assumes that 286 /* This part isn't as trivial as it looks. It assumes that
@@ -283,7 +289,7 @@ static char *dl_merger(DSO *dso, const char *filespec1, const char *filespec2)
283 the concatenation of filespec2 followed by a slash followed 289 the concatenation of filespec2 followed by a slash followed
284 by filespec1. */ 290 by filespec1. */
285 { 291 {
286 int spec2len, len; 292 size_t spec2len, len;
287 293
288 spec2len = (filespec2 ? strlen(filespec2) : 0); 294 spec2len = (filespec2 ? strlen(filespec2) : 0);
289 len = spec2len + (filespec1 ? strlen(filespec1) : 0); 295 len = spec2len + (filespec1 ? strlen(filespec1) : 0);
@@ -300,9 +306,9 @@ static char *dl_merger(DSO *dso, const char *filespec1, const char *filespec2)
300 ERR_R_MALLOC_FAILURE); 306 ERR_R_MALLOC_FAILURE);
301 return(NULL); 307 return(NULL);
302 } 308 }
303 strcpy(merged, filespec2); 309 strlcpy(merged, filespec2, len + 2);
304 merged[spec2len] = '/'; 310 merged[spec2len] = '/';
305 strcpy(&merged[spec2len + 1], filespec1); 311 strlcpy(&merged[spec2len + 1], filespec1, 1 + len - spec2len);
306 } 312 }
307 return(merged); 313 return(merged);
308 } 314 }
@@ -350,4 +356,40 @@ static char *dl_name_converter(DSO *dso, const char *filename)
350 return(translated); 356 return(translated);
351 } 357 }
352 358
359static int dl_pathbyaddr(void *addr,char *path,int sz)
360 {
361 struct shl_descriptor inf;
362 int i,len;
363
364 if (addr == NULL)
365 {
366 union { int(*f)(void*,char*,int); void *p; } t =
367 { dl_pathbyaddr };
368 addr = t.p;
369 }
370
371 for (i=-1;shl_get_r(i,&inf)==0;i++)
372 {
373 if (((size_t)addr >= inf.tstart && (size_t)addr < inf.tend) ||
374 ((size_t)addr >= inf.dstart && (size_t)addr < inf.dend))
375 {
376 len = (int)strlen(inf.filename);
377 if (sz <= 0) return len+1;
378 if (len >= sz) len=sz-1;
379 memcpy(path,inf.filename,len);
380 path[len++] = 0;
381 return len;
382 }
383 }
384
385 return -1;
386 }
387
388static void *dl_globallookup(const char *name)
389 {
390 void *ret;
391 shl_t h = NULL;
392
393 return shl_findsym(&h,name,TYPE_UNDEFINED,&ret) ? NULL : ret;
394 }
353#endif /* DSO_DL */ 395#endif /* DSO_DL */
diff --git a/src/lib/libcrypto/dso/dso_dlfcn.c b/src/lib/libcrypto/dso/dso_dlfcn.c
index 656cd496f8..5dceaf7b00 100644
--- a/src/lib/libcrypto/dso/dso_dlfcn.c
+++ b/src/lib/libcrypto/dso/dso_dlfcn.c
@@ -56,6 +56,16 @@
56 * 56 *
57 */ 57 */
58 58
59/* We need to do this early, because stdio.h includes the header files
60 that handle _GNU_SOURCE and other similar macros. Defining it later
61 is simply too late, because those headers are protected from re-
62 inclusion. */
63#ifdef __linux
64# ifndef _GNU_SOURCE
65# define _GNU_SOURCE /* make sure dladdr is declared */
66# endif
67#endif
68
59#include <stdio.h> 69#include <stdio.h>
60#include "cryptlib.h" 70#include "cryptlib.h"
61#include <openssl/dso.h> 71#include <openssl/dso.h>
@@ -68,7 +78,16 @@ DSO_METHOD *DSO_METHOD_dlfcn(void)
68#else 78#else
69 79
70#ifdef HAVE_DLFCN_H 80#ifdef HAVE_DLFCN_H
71#include <dlfcn.h> 81# ifdef __osf__
82# define __EXTENSIONS__
83# endif
84# include <dlfcn.h>
85# define HAVE_DLINFO 1
86# if defined(_AIX) || defined(__CYGWIN__) || \
87 defined(__SCO_VERSION__) || defined(_SCO_ELF) || \
88 (defined(__OpenBSD__) && !defined(RTLD_SELF))
89# undef HAVE_DLINFO
90# endif
72#endif 91#endif
73 92
74/* Part of the hack in "dlfcn_load" ... */ 93/* Part of the hack in "dlfcn_load" ... */
@@ -87,6 +106,8 @@ static long dlfcn_ctrl(DSO *dso, int cmd, long larg, void *parg);
87static char *dlfcn_name_converter(DSO *dso, const char *filename); 106static char *dlfcn_name_converter(DSO *dso, const char *filename);
88static char *dlfcn_merger(DSO *dso, const char *filespec1, 107static char *dlfcn_merger(DSO *dso, const char *filespec1,
89 const char *filespec2); 108 const char *filespec2);
109static int dlfcn_pathbyaddr(void *addr,char *path,int sz);
110static void *dlfcn_globallookup(const char *name);
90 111
91static DSO_METHOD dso_meth_dlfcn = { 112static DSO_METHOD dso_meth_dlfcn = {
92 "OpenSSL 'dlfcn' shared library method", 113 "OpenSSL 'dlfcn' shared library method",
@@ -103,7 +124,9 @@ static DSO_METHOD dso_meth_dlfcn = {
103 dlfcn_name_converter, 124 dlfcn_name_converter,
104 dlfcn_merger, 125 dlfcn_merger,
105 NULL, /* init */ 126 NULL, /* init */
106 NULL /* finish */ 127 NULL, /* finish */
128 dlfcn_pathbyaddr,
129 dlfcn_globallookup
107 }; 130 };
108 131
109DSO_METHOD *DSO_METHOD_dlfcn(void) 132DSO_METHOD *DSO_METHOD_dlfcn(void)
@@ -163,7 +186,7 @@ static int dlfcn_load(DSO *dso)
163 ERR_add_error_data(4, "filename(", filename, "): ", dlerror()); 186 ERR_add_error_data(4, "filename(", filename, "): ", dlerror());
164 goto err; 187 goto err;
165 } 188 }
166 if(!sk_push(dso->meth_data, (char *)ptr)) 189 if(!sk_void_push(dso->meth_data, (char *)ptr))
167 { 190 {
168 DSOerr(DSO_F_DLFCN_LOAD,DSO_R_STACK_ERROR); 191 DSOerr(DSO_F_DLFCN_LOAD,DSO_R_STACK_ERROR);
169 goto err; 192 goto err;
@@ -188,15 +211,15 @@ static int dlfcn_unload(DSO *dso)
188 DSOerr(DSO_F_DLFCN_UNLOAD,ERR_R_PASSED_NULL_PARAMETER); 211 DSOerr(DSO_F_DLFCN_UNLOAD,ERR_R_PASSED_NULL_PARAMETER);
189 return(0); 212 return(0);
190 } 213 }
191 if(sk_num(dso->meth_data) < 1) 214 if(sk_void_num(dso->meth_data) < 1)
192 return(1); 215 return(1);
193 ptr = (void *)sk_pop(dso->meth_data); 216 ptr = sk_void_pop(dso->meth_data);
194 if(ptr == NULL) 217 if(ptr == NULL)
195 { 218 {
196 DSOerr(DSO_F_DLFCN_UNLOAD,DSO_R_NULL_HANDLE); 219 DSOerr(DSO_F_DLFCN_UNLOAD,DSO_R_NULL_HANDLE);
197 /* Should push the value back onto the stack in 220 /* Should push the value back onto the stack in
198 * case of a retry. */ 221 * case of a retry. */
199 sk_push(dso->meth_data, (char *)ptr); 222 sk_void_push(dso->meth_data, ptr);
200 return(0); 223 return(0);
201 } 224 }
202 /* For now I'm not aware of any errors associated with dlclose() */ 225 /* For now I'm not aware of any errors associated with dlclose() */
@@ -213,12 +236,12 @@ static void *dlfcn_bind_var(DSO *dso, const char *symname)
213 DSOerr(DSO_F_DLFCN_BIND_VAR,ERR_R_PASSED_NULL_PARAMETER); 236 DSOerr(DSO_F_DLFCN_BIND_VAR,ERR_R_PASSED_NULL_PARAMETER);
214 return(NULL); 237 return(NULL);
215 } 238 }
216 if(sk_num(dso->meth_data) < 1) 239 if(sk_void_num(dso->meth_data) < 1)
217 { 240 {
218 DSOerr(DSO_F_DLFCN_BIND_VAR,DSO_R_STACK_ERROR); 241 DSOerr(DSO_F_DLFCN_BIND_VAR,DSO_R_STACK_ERROR);
219 return(NULL); 242 return(NULL);
220 } 243 }
221 ptr = (void *)sk_value(dso->meth_data, sk_num(dso->meth_data) - 1); 244 ptr = sk_void_value(dso->meth_data, sk_void_num(dso->meth_data) - 1);
222 if(ptr == NULL) 245 if(ptr == NULL)
223 { 246 {
224 DSOerr(DSO_F_DLFCN_BIND_VAR,DSO_R_NULL_HANDLE); 247 DSOerr(DSO_F_DLFCN_BIND_VAR,DSO_R_NULL_HANDLE);
@@ -237,32 +260,35 @@ static void *dlfcn_bind_var(DSO *dso, const char *symname)
237static DSO_FUNC_TYPE dlfcn_bind_func(DSO *dso, const char *symname) 260static DSO_FUNC_TYPE dlfcn_bind_func(DSO *dso, const char *symname)
238 { 261 {
239 void *ptr; 262 void *ptr;
240 DSO_FUNC_TYPE sym, *tsym = &sym; 263 union {
264 DSO_FUNC_TYPE sym;
265 void *dlret;
266 } u;
241 267
242 if((dso == NULL) || (symname == NULL)) 268 if((dso == NULL) || (symname == NULL))
243 { 269 {
244 DSOerr(DSO_F_DLFCN_BIND_FUNC,ERR_R_PASSED_NULL_PARAMETER); 270 DSOerr(DSO_F_DLFCN_BIND_FUNC,ERR_R_PASSED_NULL_PARAMETER);
245 return(NULL); 271 return(NULL);
246 } 272 }
247 if(sk_num(dso->meth_data) < 1) 273 if(sk_void_num(dso->meth_data) < 1)
248 { 274 {
249 DSOerr(DSO_F_DLFCN_BIND_FUNC,DSO_R_STACK_ERROR); 275 DSOerr(DSO_F_DLFCN_BIND_FUNC,DSO_R_STACK_ERROR);
250 return(NULL); 276 return(NULL);
251 } 277 }
252 ptr = (void *)sk_value(dso->meth_data, sk_num(dso->meth_data) - 1); 278 ptr = sk_void_value(dso->meth_data, sk_void_num(dso->meth_data) - 1);
253 if(ptr == NULL) 279 if(ptr == NULL)
254 { 280 {
255 DSOerr(DSO_F_DLFCN_BIND_FUNC,DSO_R_NULL_HANDLE); 281 DSOerr(DSO_F_DLFCN_BIND_FUNC,DSO_R_NULL_HANDLE);
256 return(NULL); 282 return(NULL);
257 } 283 }
258 *(void **)(tsym) = dlsym(ptr, symname); 284 u.dlret = dlsym(ptr, symname);
259 if(sym == NULL) 285 if(u.dlret == NULL)
260 { 286 {
261 DSOerr(DSO_F_DLFCN_BIND_FUNC,DSO_R_SYM_FAILURE); 287 DSOerr(DSO_F_DLFCN_BIND_FUNC,DSO_R_SYM_FAILURE);
262 ERR_add_error_data(4, "symname(", symname, "): ", dlerror()); 288 ERR_add_error_data(4, "symname(", symname, "): ", dlerror());
263 return(NULL); 289 return(NULL);
264 } 290 }
265 return(sym); 291 return u.sym;
266 } 292 }
267 293
268static char *dlfcn_merger(DSO *dso, const char *filespec1, 294static char *dlfcn_merger(DSO *dso, const char *filespec1,
@@ -279,14 +305,13 @@ static char *dlfcn_merger(DSO *dso, const char *filespec1,
279 } 305 }
280 /* If the first file specification is a rooted path, it rules. 306 /* If the first file specification is a rooted path, it rules.
281 same goes if the second file specification is missing. */ 307 same goes if the second file specification is missing. */
282 if (!filespec2 || filespec1[0] == '/') 308 if (!filespec2 || (filespec1 != NULL && filespec1[0] == '/'))
283 { 309 {
284 len = strlen(filespec1) + 1; 310 len = strlen(filespec1) + 1;
285 merged = OPENSSL_malloc(len); 311 merged = OPENSSL_malloc(len);
286 if(!merged) 312 if(!merged)
287 { 313 {
288 DSOerr(DSO_F_DLFCN_MERGER, 314 DSOerr(DSO_F_DLFCN_MERGER, ERR_R_MALLOC_FAILURE);
289 ERR_R_MALLOC_FAILURE);
290 return(NULL); 315 return(NULL);
291 } 316 }
292 strlcpy(merged, filespec1, len); 317 strlcpy(merged, filespec1, len);
@@ -313,7 +338,7 @@ static char *dlfcn_merger(DSO *dso, const char *filespec1,
313 { 338 {
314 int spec2len, len; 339 int spec2len, len;
315 340
316 spec2len = (filespec2 ? strlen(filespec2) : 0); 341 spec2len = strlen(filespec2);
317 len = spec2len + (filespec1 ? strlen(filespec1) : 0); 342 len = spec2len + (filespec1 ? strlen(filespec1) : 0);
318 343
319 if(filespec2 && filespec2[spec2len - 1] == '/') 344 if(filespec2 && filespec2[spec2len - 1] == '/')
@@ -335,6 +360,15 @@ static char *dlfcn_merger(DSO *dso, const char *filespec1,
335 return(merged); 360 return(merged);
336 } 361 }
337 362
363#ifdef OPENSSL_SYS_MACOSX
364#define DSO_ext ".dylib"
365#define DSO_extlen 6
366#else
367#define DSO_ext ".so"
368#define DSO_extlen 3
369#endif
370
371
338static char *dlfcn_name_converter(DSO *dso, const char *filename) 372static char *dlfcn_name_converter(DSO *dso, const char *filename)
339 { 373 {
340 char *translated; 374 char *translated;
@@ -345,8 +379,8 @@ static char *dlfcn_name_converter(DSO *dso, const char *filename)
345 transform = (strstr(filename, "/") == NULL); 379 transform = (strstr(filename, "/") == NULL);
346 if(transform) 380 if(transform)
347 { 381 {
348 /* We will convert this to "%s.so" or "lib%s.so" */ 382 /* We will convert this to "%s.so" or "lib%s.so" etc */
349 rsize += 3; /* The length of ".so" */ 383 rsize += DSO_extlen; /* The length of ".so" */
350 if ((DSO_flags(dso) & DSO_FLAG_NAME_TRANSLATION_EXT_ONLY) == 0) 384 if ((DSO_flags(dso) & DSO_FLAG_NAME_TRANSLATION_EXT_ONLY) == 0)
351 rsize += 3; /* The length of "lib" */ 385 rsize += 3; /* The length of "lib" */
352 } 386 }
@@ -360,13 +394,92 @@ static char *dlfcn_name_converter(DSO *dso, const char *filename)
360 if(transform) 394 if(transform)
361 { 395 {
362 if ((DSO_flags(dso) & DSO_FLAG_NAME_TRANSLATION_EXT_ONLY) == 0) 396 if ((DSO_flags(dso) & DSO_FLAG_NAME_TRANSLATION_EXT_ONLY) == 0)
363 snprintf(translated, rsize, "lib%s.so", filename); 397 snprintf(translated, rsize, "lib%s" DSO_ext, filename);
364 else 398 else
365 snprintf(translated, rsize, "%s.so", filename); 399 snprintf(translated, rsize, "%s" DSO_ext, filename);
366 } 400 }
367 else 401 else
368 snprintf(translated, rsize, "%s", filename); 402 snprintf(translated, rsize, "%s", filename);
369 return(translated); 403 return(translated);
370 } 404 }
371 405
406#if defined(__sgi) && !defined(__OpenBSD__)
407/*
408This is a quote from IRIX manual for dladdr(3c):
409
410 <dlfcn.h> does not contain a prototype for dladdr or definition of
411 Dl_info. The #include <dlfcn.h> in the SYNOPSIS line is traditional,
412 but contains no dladdr prototype and no IRIX library contains an
413 implementation. Write your own declaration based on the code below.
414
415 The following code is dependent on internal interfaces that are not
416 part of the IRIX compatibility guarantee; however, there is no future
417 intention to change this interface, so on a practical level, the code
418 below is safe to use on IRIX.
419*/
420#include <rld_interface.h>
421#ifndef _RLD_INTERFACE_DLFCN_H_DLADDR
422#define _RLD_INTERFACE_DLFCN_H_DLADDR
423typedef struct Dl_info {
424 const char * dli_fname;
425 void * dli_fbase;
426 const char * dli_sname;
427 void * dli_saddr;
428 int dli_version;
429 int dli_reserved1;
430 long dli_reserved[4];
431} Dl_info;
432#else
433typedef struct Dl_info Dl_info;
434#endif
435#define _RLD_DLADDR 14
436
437static int dladdr(void *address, Dl_info *dl)
438{
439 void *v;
440 v = _rld_new_interface(_RLD_DLADDR,address,dl);
441 return (int)v;
442}
443#endif /* __sgi */
444
445static int dlfcn_pathbyaddr(void *addr,char *path,int sz)
446 {
447#ifdef HAVE_DLINFO
448 Dl_info dli;
449 int len;
450
451 if (addr == NULL)
452 {
453 union { int(*f)(void*,char*,int); void *p; } t =
454 { dlfcn_pathbyaddr };
455 addr = t.p;
456 }
457
458 if (dladdr(addr,&dli))
459 {
460 len = (int)strlen(dli.dli_fname);
461 if (sz <= 0) return len+1;
462 if (len >= sz) len=sz-1;
463 memcpy(path,dli.dli_fname,len);
464 path[len++]=0;
465 return len;
466 }
467
468 ERR_add_error_data(4, "dlfcn_pathbyaddr(): ", dlerror());
469#endif
470 return -1;
471 }
472
473static void *dlfcn_globallookup(const char *name)
474 {
475 void *ret = NULL,*handle = dlopen(NULL,RTLD_LAZY);
476
477 if (handle)
478 {
479 ret = dlsym(handle,name);
480 dlclose(handle);
481 }
482
483 return ret;
484 }
372#endif /* DSO_DLFCN */ 485#endif /* DSO_DLFCN */
diff --git a/src/lib/libcrypto/dso/dso_err.c b/src/lib/libcrypto/dso/dso_err.c
index a8b0a210de..2bb07c2514 100644
--- a/src/lib/libcrypto/dso/dso_err.c
+++ b/src/lib/libcrypto/dso/dso_err.c
@@ -1,6 +1,6 @@
1/* crypto/dso/dso_err.c */ 1/* crypto/dso/dso_err.c */
2/* ==================================================================== 2/* ====================================================================
3 * Copyright (c) 1999-2005 The OpenSSL Project. All rights reserved. 3 * Copyright (c) 1999-2006 The OpenSSL Project. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
@@ -70,6 +70,11 @@
70 70
71static ERR_STRING_DATA DSO_str_functs[]= 71static ERR_STRING_DATA DSO_str_functs[]=
72 { 72 {
73{ERR_FUNC(DSO_F_BEOS_BIND_FUNC), "BEOS_BIND_FUNC"},
74{ERR_FUNC(DSO_F_BEOS_BIND_VAR), "BEOS_BIND_VAR"},
75{ERR_FUNC(DSO_F_BEOS_LOAD), "BEOS_LOAD"},
76{ERR_FUNC(DSO_F_BEOS_NAME_CONVERTER), "BEOS_NAME_CONVERTER"},
77{ERR_FUNC(DSO_F_BEOS_UNLOAD), "BEOS_UNLOAD"},
73{ERR_FUNC(DSO_F_DLFCN_BIND_FUNC), "DLFCN_BIND_FUNC"}, 78{ERR_FUNC(DSO_F_DLFCN_BIND_FUNC), "DLFCN_BIND_FUNC"},
74{ERR_FUNC(DSO_F_DLFCN_BIND_VAR), "DLFCN_BIND_VAR"}, 79{ERR_FUNC(DSO_F_DLFCN_BIND_VAR), "DLFCN_BIND_VAR"},
75{ERR_FUNC(DSO_F_DLFCN_LOAD), "DLFCN_LOAD"}, 80{ERR_FUNC(DSO_F_DLFCN_LOAD), "DLFCN_LOAD"},
@@ -89,22 +94,29 @@ static ERR_STRING_DATA DSO_str_functs[]=
89{ERR_FUNC(DSO_F_DSO_FREE), "DSO_free"}, 94{ERR_FUNC(DSO_F_DSO_FREE), "DSO_free"},
90{ERR_FUNC(DSO_F_DSO_GET_FILENAME), "DSO_get_filename"}, 95{ERR_FUNC(DSO_F_DSO_GET_FILENAME), "DSO_get_filename"},
91{ERR_FUNC(DSO_F_DSO_GET_LOADED_FILENAME), "DSO_get_loaded_filename"}, 96{ERR_FUNC(DSO_F_DSO_GET_LOADED_FILENAME), "DSO_get_loaded_filename"},
97{ERR_FUNC(DSO_F_DSO_GLOBAL_LOOKUP), "DSO_global_lookup"},
92{ERR_FUNC(DSO_F_DSO_LOAD), "DSO_load"}, 98{ERR_FUNC(DSO_F_DSO_LOAD), "DSO_load"},
93{ERR_FUNC(DSO_F_DSO_MERGE), "DSO_merge"}, 99{ERR_FUNC(DSO_F_DSO_MERGE), "DSO_merge"},
94{ERR_FUNC(DSO_F_DSO_NEW_METHOD), "DSO_new_method"}, 100{ERR_FUNC(DSO_F_DSO_NEW_METHOD), "DSO_new_method"},
101{ERR_FUNC(DSO_F_DSO_PATHBYADDR), "DSO_pathbyaddr"},
95{ERR_FUNC(DSO_F_DSO_SET_FILENAME), "DSO_set_filename"}, 102{ERR_FUNC(DSO_F_DSO_SET_FILENAME), "DSO_set_filename"},
96{ERR_FUNC(DSO_F_DSO_SET_NAME_CONVERTER), "DSO_set_name_converter"}, 103{ERR_FUNC(DSO_F_DSO_SET_NAME_CONVERTER), "DSO_set_name_converter"},
97{ERR_FUNC(DSO_F_DSO_UP_REF), "DSO_up_ref"}, 104{ERR_FUNC(DSO_F_DSO_UP_REF), "DSO_up_ref"},
105{ERR_FUNC(DSO_F_GLOBAL_LOOKUP_FUNC), "GLOBAL_LOOKUP_FUNC"},
106{ERR_FUNC(DSO_F_PATHBYADDR), "PATHBYADDR"},
98{ERR_FUNC(DSO_F_VMS_BIND_SYM), "VMS_BIND_SYM"}, 107{ERR_FUNC(DSO_F_VMS_BIND_SYM), "VMS_BIND_SYM"},
99{ERR_FUNC(DSO_F_VMS_LOAD), "VMS_LOAD"}, 108{ERR_FUNC(DSO_F_VMS_LOAD), "VMS_LOAD"},
100{ERR_FUNC(DSO_F_VMS_MERGER), "VMS_MERGER"}, 109{ERR_FUNC(DSO_F_VMS_MERGER), "VMS_MERGER"},
101{ERR_FUNC(DSO_F_VMS_UNLOAD), "VMS_UNLOAD"}, 110{ERR_FUNC(DSO_F_VMS_UNLOAD), "VMS_UNLOAD"},
102{ERR_FUNC(DSO_F_WIN32_BIND_FUNC), "WIN32_BIND_FUNC"}, 111{ERR_FUNC(DSO_F_WIN32_BIND_FUNC), "WIN32_BIND_FUNC"},
103{ERR_FUNC(DSO_F_WIN32_BIND_VAR), "WIN32_BIND_VAR"}, 112{ERR_FUNC(DSO_F_WIN32_BIND_VAR), "WIN32_BIND_VAR"},
113{ERR_FUNC(DSO_F_WIN32_GLOBALLOOKUP), "WIN32_GLOBALLOOKUP"},
114{ERR_FUNC(DSO_F_WIN32_GLOBALLOOKUP_FUNC), "WIN32_GLOBALLOOKUP_FUNC"},
104{ERR_FUNC(DSO_F_WIN32_JOINER), "WIN32_JOINER"}, 115{ERR_FUNC(DSO_F_WIN32_JOINER), "WIN32_JOINER"},
105{ERR_FUNC(DSO_F_WIN32_LOAD), "WIN32_LOAD"}, 116{ERR_FUNC(DSO_F_WIN32_LOAD), "WIN32_LOAD"},
106{ERR_FUNC(DSO_F_WIN32_MERGER), "WIN32_MERGER"}, 117{ERR_FUNC(DSO_F_WIN32_MERGER), "WIN32_MERGER"},
107{ERR_FUNC(DSO_F_WIN32_NAME_CONVERTER), "WIN32_NAME_CONVERTER"}, 118{ERR_FUNC(DSO_F_WIN32_NAME_CONVERTER), "WIN32_NAME_CONVERTER"},
119{ERR_FUNC(DSO_F_WIN32_PATHBYADDR), "WIN32_PATHBYADDR"},
108{ERR_FUNC(DSO_F_WIN32_SPLITTER), "WIN32_SPLITTER"}, 120{ERR_FUNC(DSO_F_WIN32_SPLITTER), "WIN32_SPLITTER"},
109{ERR_FUNC(DSO_F_WIN32_UNLOAD), "WIN32_UNLOAD"}, 121{ERR_FUNC(DSO_F_WIN32_UNLOAD), "WIN32_UNLOAD"},
110{0,NULL} 122{0,NULL}
diff --git a/src/lib/libcrypto/dso/dso_lib.c b/src/lib/libcrypto/dso/dso_lib.c
index 49bdd71309..8a15b794ab 100644
--- a/src/lib/libcrypto/dso/dso_lib.c
+++ b/src/lib/libcrypto/dso/dso_lib.c
@@ -107,7 +107,7 @@ DSO *DSO_new_method(DSO_METHOD *meth)
107 return(NULL); 107 return(NULL);
108 } 108 }
109 memset(ret, 0, sizeof(DSO)); 109 memset(ret, 0, sizeof(DSO));
110 ret->meth_data = sk_new_null(); 110 ret->meth_data = sk_void_new_null();
111 if(ret->meth_data == NULL) 111 if(ret->meth_data == NULL)
112 { 112 {
113 /* sk_new doesn't generate any errors so we do */ 113 /* sk_new doesn't generate any errors so we do */
@@ -163,7 +163,7 @@ int DSO_free(DSO *dso)
163 return(0); 163 return(0);
164 } 164 }
165 165
166 sk_free(dso->meth_data); 166 sk_void_free(dso->meth_data);
167 if(dso->filename != NULL) 167 if(dso->filename != NULL)
168 OPENSSL_free(dso->filename); 168 OPENSSL_free(dso->filename);
169 if(dso->loaded_filename != NULL) 169 if(dso->loaded_filename != NULL)
@@ -399,13 +399,6 @@ char *DSO_merge(DSO *dso, const char *filespec1, const char *filespec2)
399 DSOerr(DSO_F_DSO_MERGE,ERR_R_PASSED_NULL_PARAMETER); 399 DSOerr(DSO_F_DSO_MERGE,ERR_R_PASSED_NULL_PARAMETER);
400 return(NULL); 400 return(NULL);
401 } 401 }
402 if(filespec1 == NULL)
403 filespec1 = dso->filename;
404 if(filespec1 == NULL)
405 {
406 DSOerr(DSO_F_DSO_MERGE,DSO_R_NO_FILE_SPECIFICATION);
407 return(NULL);
408 }
409 if((dso->flags & DSO_FLAG_NO_NAME_TRANSLATION) == 0) 402 if((dso->flags & DSO_FLAG_NO_NAME_TRANSLATION) == 0)
410 { 403 {
411 if(dso->merger != NULL) 404 if(dso->merger != NULL)
@@ -464,3 +457,27 @@ const char *DSO_get_loaded_filename(DSO *dso)
464 } 457 }
465 return(dso->loaded_filename); 458 return(dso->loaded_filename);
466 } 459 }
460
461int DSO_pathbyaddr(void *addr,char *path,int sz)
462 {
463 DSO_METHOD *meth = default_DSO_meth;
464 if (meth == NULL) meth = DSO_METHOD_openssl();
465 if (meth->pathbyaddr == NULL)
466 {
467 DSOerr(DSO_F_DSO_PATHBYADDR,DSO_R_UNSUPPORTED);
468 return -1;
469 }
470 return (*meth->pathbyaddr)(addr,path,sz);
471 }
472
473void *DSO_global_lookup(const char *name)
474 {
475 DSO_METHOD *meth = default_DSO_meth;
476 if (meth == NULL) meth = DSO_METHOD_openssl();
477 if (meth->globallookup == NULL)
478 {
479 DSOerr(DSO_F_DSO_GLOBAL_LOOKUP,DSO_R_UNSUPPORTED);
480 return NULL;
481 }
482 return (*meth->globallookup)(name);
483 }
diff --git a/src/lib/libcrypto/dso/dso_null.c b/src/lib/libcrypto/dso/dso_null.c
index 4972984651..49d842d1f5 100644
--- a/src/lib/libcrypto/dso/dso_null.c
+++ b/src/lib/libcrypto/dso/dso_null.c
@@ -78,7 +78,9 @@ static DSO_METHOD dso_meth_null = {
78 NULL, /* dso_name_converter */ 78 NULL, /* dso_name_converter */
79 NULL, /* dso_merger */ 79 NULL, /* dso_merger */
80 NULL, /* init */ 80 NULL, /* init */
81 NULL /* finish */ 81 NULL, /* finish */
82 NULL, /* pathbyaddr */
83 NULL /* globallookup */
82 }; 84 };
83 85
84DSO_METHOD *DSO_METHOD_null(void) 86DSO_METHOD *DSO_METHOD_null(void)
diff --git a/src/lib/libcrypto/dso/dso_openssl.c b/src/lib/libcrypto/dso/dso_openssl.c
index a4395ebffe..b17e8e8e9e 100644
--- a/src/lib/libcrypto/dso/dso_openssl.c
+++ b/src/lib/libcrypto/dso/dso_openssl.c
@@ -74,6 +74,8 @@ DSO_METHOD *DSO_METHOD_openssl(void)
74 return(DSO_METHOD_win32()); 74 return(DSO_METHOD_win32());
75#elif defined(DSO_VMS) 75#elif defined(DSO_VMS)
76 return(DSO_METHOD_vms()); 76 return(DSO_METHOD_vms());
77#elif defined(DSO_BEOS)
78 return(DSO_METHOD_beos());
77#else 79#else
78 return(DSO_METHOD_null()); 80 return(DSO_METHOD_null());
79#endif 81#endif
diff --git a/src/lib/libcrypto/dso/dso_vms.c b/src/lib/libcrypto/dso/dso_vms.c
index 2c434ee8a6..321512772a 100644
--- a/src/lib/libcrypto/dso/dso_vms.c
+++ b/src/lib/libcrypto/dso/dso_vms.c
@@ -215,7 +215,7 @@ static int vms_load(DSO *dso)
215 p->imagename_dsc.dsc$b_class = DSC$K_CLASS_S; 215 p->imagename_dsc.dsc$b_class = DSC$K_CLASS_S;
216 p->imagename_dsc.dsc$a_pointer = p->imagename; 216 p->imagename_dsc.dsc$a_pointer = p->imagename;
217 217
218 if(!sk_push(dso->meth_data, (char *)p)) 218 if(!sk_void_push(dso->meth_data, (char *)p))
219 { 219 {
220 DSOerr(DSO_F_VMS_LOAD,DSO_R_STACK_ERROR); 220 DSOerr(DSO_F_VMS_LOAD,DSO_R_STACK_ERROR);
221 goto err; 221 goto err;
@@ -245,9 +245,9 @@ static int vms_unload(DSO *dso)
245 DSOerr(DSO_F_VMS_UNLOAD,ERR_R_PASSED_NULL_PARAMETER); 245 DSOerr(DSO_F_VMS_UNLOAD,ERR_R_PASSED_NULL_PARAMETER);
246 return(0); 246 return(0);
247 } 247 }
248 if(sk_num(dso->meth_data) < 1) 248 if(sk_void_num(dso->meth_data) < 1)
249 return(1); 249 return(1);
250 p = (DSO_VMS_INTERNAL *)sk_pop(dso->meth_data); 250 p = (DSO_VMS_INTERNAL *)sk_void_pop(dso->meth_data);
251 if(p == NULL) 251 if(p == NULL)
252 { 252 {
253 DSOerr(DSO_F_VMS_UNLOAD,DSO_R_NULL_HANDLE); 253 DSOerr(DSO_F_VMS_UNLOAD,DSO_R_NULL_HANDLE);
@@ -302,13 +302,13 @@ void vms_bind_sym(DSO *dso, const char *symname, void **sym)
302 DSOerr(DSO_F_VMS_BIND_SYM,ERR_R_PASSED_NULL_PARAMETER); 302 DSOerr(DSO_F_VMS_BIND_SYM,ERR_R_PASSED_NULL_PARAMETER);
303 return; 303 return;
304 } 304 }
305 if(sk_num(dso->meth_data) < 1) 305 if(sk_void_num(dso->meth_data) < 1)
306 { 306 {
307 DSOerr(DSO_F_VMS_BIND_SYM,DSO_R_STACK_ERROR); 307 DSOerr(DSO_F_VMS_BIND_SYM,DSO_R_STACK_ERROR);
308 return; 308 return;
309 } 309 }
310 ptr = (DSO_VMS_INTERNAL *)sk_value(dso->meth_data, 310 ptr = (DSO_VMS_INTERNAL *)sk_void_value(dso->meth_data,
311 sk_num(dso->meth_data) - 1); 311 sk_void_num(dso->meth_data) - 1);
312 if(ptr == NULL) 312 if(ptr == NULL)
313 { 313 {
314 DSOerr(DSO_F_VMS_BIND_SYM,DSO_R_NULL_HANDLE); 314 DSOerr(DSO_F_VMS_BIND_SYM,DSO_R_NULL_HANDLE);
diff --git a/src/lib/libcrypto/dso/dso_win32.c b/src/lib/libcrypto/dso/dso_win32.c
index fd3dd6a7fe..6fb6c54181 100644
--- a/src/lib/libcrypto/dso/dso_win32.c
+++ b/src/lib/libcrypto/dso/dso_win32.c
@@ -96,7 +96,11 @@ static HINSTANCE LoadLibraryA(LPCSTR lpLibFileName)
96#else 96#else
97 fnamw = (WCHAR *)alloca (len_0*sizeof(WCHAR)); 97 fnamw = (WCHAR *)alloca (len_0*sizeof(WCHAR));
98#endif 98#endif
99 if (fnamw == NULL) return NULL; 99 if (fnamw == NULL)
100 {
101 SetLastError(ERROR_NOT_ENOUGH_MEMORY);
102 return NULL;
103 }
100 104
101#if defined(_WIN32_WCE) && _WIN32_WCE>=101 105#if defined(_WIN32_WCE) && _WIN32_WCE>=101
102 if (!MultiByteToWideChar(CP_ACP,0,lpLibFileName,len_0,fnamw,len_0)) 106 if (!MultiByteToWideChar(CP_ACP,0,lpLibFileName,len_0,fnamw,len_0))
@@ -124,6 +128,8 @@ static long win32_ctrl(DSO *dso, int cmd, long larg, void *parg);
124static char *win32_name_converter(DSO *dso, const char *filename); 128static char *win32_name_converter(DSO *dso, const char *filename);
125static char *win32_merger(DSO *dso, const char *filespec1, 129static char *win32_merger(DSO *dso, const char *filespec1,
126 const char *filespec2); 130 const char *filespec2);
131static int win32_pathbyaddr(void *addr,char *path,int sz);
132static void *win32_globallookup(const char *name);
127 133
128static const char *openssl_strnchr(const char *string, int c, size_t len); 134static const char *openssl_strnchr(const char *string, int c, size_t len);
129 135
@@ -142,7 +148,9 @@ static DSO_METHOD dso_meth_win32 = {
142 win32_name_converter, 148 win32_name_converter,
143 win32_merger, 149 win32_merger,
144 NULL, /* init */ 150 NULL, /* init */
145 NULL /* finish */ 151 NULL, /* finish */
152 win32_pathbyaddr,
153 win32_globallookup
146 }; 154 };
147 155
148DSO_METHOD *DSO_METHOD_win32(void) 156DSO_METHOD *DSO_METHOD_win32(void)
@@ -180,7 +188,7 @@ static int win32_load(DSO *dso)
180 goto err; 188 goto err;
181 } 189 }
182 *p = h; 190 *p = h;
183 if(!sk_push(dso->meth_data, (char *)p)) 191 if(!sk_void_push(dso->meth_data, p))
184 { 192 {
185 DSOerr(DSO_F_WIN32_LOAD,DSO_R_STACK_ERROR); 193 DSOerr(DSO_F_WIN32_LOAD,DSO_R_STACK_ERROR);
186 goto err; 194 goto err;
@@ -207,9 +215,9 @@ static int win32_unload(DSO *dso)
207 DSOerr(DSO_F_WIN32_UNLOAD,ERR_R_PASSED_NULL_PARAMETER); 215 DSOerr(DSO_F_WIN32_UNLOAD,ERR_R_PASSED_NULL_PARAMETER);
208 return(0); 216 return(0);
209 } 217 }
210 if(sk_num(dso->meth_data) < 1) 218 if(sk_void_num(dso->meth_data) < 1)
211 return(1); 219 return(1);
212 p = (HINSTANCE *)sk_pop(dso->meth_data); 220 p = sk_void_pop(dso->meth_data);
213 if(p == NULL) 221 if(p == NULL)
214 { 222 {
215 DSOerr(DSO_F_WIN32_UNLOAD,DSO_R_NULL_HANDLE); 223 DSOerr(DSO_F_WIN32_UNLOAD,DSO_R_NULL_HANDLE);
@@ -220,7 +228,7 @@ static int win32_unload(DSO *dso)
220 DSOerr(DSO_F_WIN32_UNLOAD,DSO_R_UNLOAD_FAILED); 228 DSOerr(DSO_F_WIN32_UNLOAD,DSO_R_UNLOAD_FAILED);
221 /* We should push the value back onto the stack in 229 /* We should push the value back onto the stack in
222 * case of a retry. */ 230 * case of a retry. */
223 sk_push(dso->meth_data, (char *)p); 231 sk_void_push(dso->meth_data, p);
224 return(0); 232 return(0);
225 } 233 }
226 /* Cleanup */ 234 /* Cleanup */
@@ -240,12 +248,12 @@ static void *win32_bind_var(DSO *dso, const char *symname)
240 DSOerr(DSO_F_WIN32_BIND_VAR,ERR_R_PASSED_NULL_PARAMETER); 248 DSOerr(DSO_F_WIN32_BIND_VAR,ERR_R_PASSED_NULL_PARAMETER);
241 return(NULL); 249 return(NULL);
242 } 250 }
243 if(sk_num(dso->meth_data) < 1) 251 if(sk_void_num(dso->meth_data) < 1)
244 { 252 {
245 DSOerr(DSO_F_WIN32_BIND_VAR,DSO_R_STACK_ERROR); 253 DSOerr(DSO_F_WIN32_BIND_VAR,DSO_R_STACK_ERROR);
246 return(NULL); 254 return(NULL);
247 } 255 }
248 ptr = (HINSTANCE *)sk_value(dso->meth_data, sk_num(dso->meth_data) - 1); 256 ptr = sk_void_value(dso->meth_data, sk_void_num(dso->meth_data) - 1);
249 if(ptr == NULL) 257 if(ptr == NULL)
250 { 258 {
251 DSOerr(DSO_F_WIN32_BIND_VAR,DSO_R_NULL_HANDLE); 259 DSOerr(DSO_F_WIN32_BIND_VAR,DSO_R_NULL_HANDLE);
@@ -271,12 +279,12 @@ static DSO_FUNC_TYPE win32_bind_func(DSO *dso, const char *symname)
271 DSOerr(DSO_F_WIN32_BIND_FUNC,ERR_R_PASSED_NULL_PARAMETER); 279 DSOerr(DSO_F_WIN32_BIND_FUNC,ERR_R_PASSED_NULL_PARAMETER);
272 return(NULL); 280 return(NULL);
273 } 281 }
274 if(sk_num(dso->meth_data) < 1) 282 if(sk_void_num(dso->meth_data) < 1)
275 { 283 {
276 DSOerr(DSO_F_WIN32_BIND_FUNC,DSO_R_STACK_ERROR); 284 DSOerr(DSO_F_WIN32_BIND_FUNC,DSO_R_STACK_ERROR);
277 return(NULL); 285 return(NULL);
278 } 286 }
279 ptr = (HINSTANCE *)sk_value(dso->meth_data, sk_num(dso->meth_data) - 1); 287 ptr = sk_void_value(dso->meth_data, sk_void_num(dso->meth_data) - 1);
280 if(ptr == NULL) 288 if(ptr == NULL)
281 { 289 {
282 DSOerr(DSO_F_WIN32_BIND_FUNC,DSO_R_NULL_HANDLE); 290 DSOerr(DSO_F_WIN32_BIND_FUNC,DSO_R_NULL_HANDLE);
@@ -327,8 +335,8 @@ static struct file_st *win32_splitter(DSO *dso, const char *filename,
327 memset(result, 0, sizeof(struct file_st)); 335 memset(result, 0, sizeof(struct file_st));
328 position = IN_DEVICE; 336 position = IN_DEVICE;
329 337
330 if(filename[0] == '\\' && filename[1] == '\\' 338 if((filename[0] == '\\' && filename[1] == '\\')
331 || filename[0] == '/' && filename[1] == '/') 339 || (filename[0] == '/' && filename[1] == '/'))
332 { 340 {
333 position = IN_NODE; 341 position = IN_NODE;
334 filename += 2; 342 filename += 2;
@@ -347,10 +355,11 @@ static struct file_st *win32_splitter(DSO *dso, const char *filename,
347 DSOerr(DSO_F_WIN32_SPLITTER, 355 DSOerr(DSO_F_WIN32_SPLITTER,
348 DSO_R_INCORRECT_FILE_SYNTAX); 356 DSO_R_INCORRECT_FILE_SYNTAX);
349 /*goto err;*/ 357 /*goto err;*/
358 OPENSSL_free(result);
350 return(NULL); 359 return(NULL);
351 } 360 }
352 result->device = start; 361 result->device = start;
353 result->devicelen = filename - start; 362 result->devicelen = (int)(filename - start);
354 position = IN_FILE; 363 position = IN_FILE;
355 start = ++filename; 364 start = ++filename;
356 result->dir = start; 365 result->dir = start;
@@ -359,7 +368,7 @@ static struct file_st *win32_splitter(DSO *dso, const char *filename,
359 case '/': 368 case '/':
360 if(position == IN_NODE) 369 if(position == IN_NODE)
361 { 370 {
362 result->nodelen = filename - start; 371 result->nodelen = (int)(filename - start);
363 position = IN_FILE; 372 position = IN_FILE;
364 start = ++filename; 373 start = ++filename;
365 result->dir = start; 374 result->dir = start;
@@ -369,20 +378,20 @@ static struct file_st *win32_splitter(DSO *dso, const char *filename,
369 position = IN_FILE; 378 position = IN_FILE;
370 filename++; 379 filename++;
371 result->dir = start; 380 result->dir = start;
372 result->dirlen = filename - start; 381 result->dirlen = (int)(filename - start);
373 start = filename; 382 start = filename;
374 } 383 }
375 else 384 else
376 { 385 {
377 filename++; 386 filename++;
378 result->dirlen += filename - start; 387 result->dirlen += (int)(filename - start);
379 start = filename; 388 start = filename;
380 } 389 }
381 break; 390 break;
382 case '\0': 391 case '\0':
383 if(position == IN_NODE) 392 if(position == IN_NODE)
384 { 393 {
385 result->nodelen = filename - start; 394 result->nodelen = (int)(filename - start);
386 } 395 }
387 else 396 else
388 { 397 {
@@ -396,13 +405,13 @@ static struct file_st *win32_splitter(DSO *dso, const char *filename,
396 result->dirlen = 0; 405 result->dirlen = 0;
397 } 406 }
398 result->dirlen += 407 result->dirlen +=
399 filename - start; 408 (int)(filename - start);
400 } 409 }
401 else 410 else
402 { 411 {
403 result->file = start; 412 result->file = start;
404 result->filelen = 413 result->filelen =
405 filename - start; 414 (int)(filename - start);
406 } 415 }
407 } 416 }
408 } 417 }
@@ -496,7 +505,7 @@ static char *win32_joiner(DSO *dso, const struct file_st *file_split)
496 + file_split->predirlen 505 + file_split->predirlen
497 - (start - file_split->predir); 506 - (start - file_split->predir);
498 strncpy(&result[offset], start, 507 strncpy(&result[offset], start,
499 end - start); offset += end - start; 508 end - start); offset += (int)(end - start);
500 result[offset] = '\\'; offset++; 509 result[offset] = '\\'; offset++;
501 start = end + 1; 510 start = end + 1;
502 } 511 }
@@ -517,7 +526,7 @@ static char *win32_joiner(DSO *dso, const struct file_st *file_split)
517 + file_split->dirlen 526 + file_split->dirlen
518 - (start - file_split->dir); 527 - (start - file_split->dir);
519 strncpy(&result[offset], start, 528 strncpy(&result[offset], start,
520 end - start); offset += end - start; 529 end - start); offset += (int)(end - start);
521 result[offset] = '\\'; offset++; 530 result[offset] = '\\'; offset++;
522 start = end + 1; 531 start = end + 1;
523 } 532 }
@@ -613,6 +622,8 @@ static char *win32_merger(DSO *dso, const char *filespec1, const char *filespec2
613 622
614 merged = win32_joiner(dso, filespec1_split); 623 merged = win32_joiner(dso, filespec1_split);
615 } 624 }
625 OPENSSL_free(filespec1_split);
626 OPENSSL_free(filespec2_split);
616 return(merged); 627 return(merged);
617 } 628 }
618 629
@@ -656,5 +667,178 @@ static const char *openssl_strnchr(const char *string, int c, size_t len)
656 return NULL; 667 return NULL;
657 } 668 }
658 669
670#include <tlhelp32.h>
671#ifdef _WIN32_WCE
672# define DLLNAME "TOOLHELP.DLL"
673#else
674# ifdef MODULEENTRY32
675# undef MODULEENTRY32 /* unmask the ASCII version! */
676# endif
677# define DLLNAME "KERNEL32.DLL"
678#endif
679
680typedef HANDLE (WINAPI *CREATETOOLHELP32SNAPSHOT)(DWORD, DWORD);
681typedef BOOL (WINAPI *CLOSETOOLHELP32SNAPSHOT)(HANDLE);
682typedef BOOL (WINAPI *MODULE32)(HANDLE, MODULEENTRY32 *);
659 683
660#endif /* OPENSSL_SYS_WIN32 */ 684static int win32_pathbyaddr(void *addr,char *path,int sz)
685 {
686 HMODULE dll;
687 HANDLE hModuleSnap = INVALID_HANDLE_VALUE;
688 MODULEENTRY32 me32;
689 CREATETOOLHELP32SNAPSHOT create_snap;
690 CLOSETOOLHELP32SNAPSHOT close_snap;
691 MODULE32 module_first, module_next;
692 int len;
693
694 if (addr == NULL)
695 {
696 union { int(*f)(void*,char*,int); void *p; } t =
697 { win32_pathbyaddr };
698 addr = t.p;
699 }
700
701 dll = LoadLibrary(TEXT(DLLNAME));
702 if (dll == NULL)
703 {
704 DSOerr(DSO_F_WIN32_PATHBYADDR,DSO_R_UNSUPPORTED);
705 return -1;
706 }
707
708 create_snap = (CREATETOOLHELP32SNAPSHOT)
709 GetProcAddress(dll,"CreateToolhelp32Snapshot");
710 if (create_snap == NULL)
711 {
712 FreeLibrary(dll);
713 DSOerr(DSO_F_WIN32_PATHBYADDR,DSO_R_UNSUPPORTED);
714 return -1;
715 }
716 /* We take the rest for granted... */
717#ifdef _WIN32_WCE
718 close_snap = (CLOSETOOLHELP32SNAPSHOT)
719 GetProcAddress(dll,"CloseToolhelp32Snapshot");
720#else
721 close_snap = (CLOSETOOLHELP32SNAPSHOT)CloseHandle;
722#endif
723 module_first = (MODULE32)GetProcAddress(dll,"Module32First");
724 module_next = (MODULE32)GetProcAddress(dll,"Module32Next");
725
726 hModuleSnap = (*create_snap)(TH32CS_SNAPMODULE,0);
727 if( hModuleSnap == INVALID_HANDLE_VALUE )
728 {
729 FreeLibrary(dll);
730 DSOerr(DSO_F_WIN32_PATHBYADDR,DSO_R_UNSUPPORTED);
731 return -1;
732 }
733
734 me32.dwSize = sizeof(me32);
735
736 if(!(*module_first)(hModuleSnap,&me32))
737 {
738 (*close_snap)(hModuleSnap);
739 FreeLibrary(dll);
740 DSOerr(DSO_F_WIN32_PATHBYADDR,DSO_R_FAILURE);
741 return -1;
742 }
743
744 do {
745 if ((BYTE *)addr >= me32.modBaseAddr &&
746 (BYTE *)addr < me32.modBaseAddr+me32.modBaseSize)
747 {
748 (*close_snap)(hModuleSnap);
749 FreeLibrary(dll);
750#ifdef _WIN32_WCE
751# if _WIN32_WCE >= 101
752 return WideCharToMultiByte(CP_ACP,0,me32.szExePath,-1,
753 path,sz,NULL,NULL);
754# else
755 len = (int)wcslen(me32.szExePath);
756 if (sz <= 0) return len+1;
757 if (len >= sz) len=sz-1;
758 for(i=0;i<len;i++)
759 path[i] = (char)me32.szExePath[i];
760 path[len++] = 0;
761 return len;
762# endif
763#else
764 len = (int)strlen(me32.szExePath);
765 if (sz <= 0) return len+1;
766 if (len >= sz) len=sz-1;
767 memcpy(path,me32.szExePath,len);
768 path[len++] = 0;
769 return len;
770#endif
771 }
772 } while((*module_next)(hModuleSnap, &me32));
773
774 (*close_snap)(hModuleSnap);
775 FreeLibrary(dll);
776 return 0;
777 }
778
779static void *win32_globallookup(const char *name)
780 {
781 HMODULE dll;
782 HANDLE hModuleSnap = INVALID_HANDLE_VALUE;
783 MODULEENTRY32 me32;
784 CREATETOOLHELP32SNAPSHOT create_snap;
785 CLOSETOOLHELP32SNAPSHOT close_snap;
786 MODULE32 module_first, module_next;
787 FARPROC ret=NULL;
788
789 dll = LoadLibrary(TEXT(DLLNAME));
790 if (dll == NULL)
791 {
792 DSOerr(DSO_F_WIN32_GLOBALLOOKUP,DSO_R_UNSUPPORTED);
793 return NULL;
794 }
795
796 create_snap = (CREATETOOLHELP32SNAPSHOT)
797 GetProcAddress(dll,"CreateToolhelp32Snapshot");
798 if (create_snap == NULL)
799 {
800 FreeLibrary(dll);
801 DSOerr(DSO_F_WIN32_GLOBALLOOKUP,DSO_R_UNSUPPORTED);
802 return NULL;
803 }
804 /* We take the rest for granted... */
805#ifdef _WIN32_WCE
806 close_snap = (CLOSETOOLHELP32SNAPSHOT)
807 GetProcAddress(dll,"CloseToolhelp32Snapshot");
808#else
809 close_snap = (CLOSETOOLHELP32SNAPSHOT)CloseHandle;
810#endif
811 module_first = (MODULE32)GetProcAddress(dll,"Module32First");
812 module_next = (MODULE32)GetProcAddress(dll,"Module32Next");
813
814 hModuleSnap = (*create_snap)(TH32CS_SNAPMODULE,0);
815 if( hModuleSnap == INVALID_HANDLE_VALUE )
816 {
817 FreeLibrary(dll);
818 DSOerr(DSO_F_WIN32_GLOBALLOOKUP,DSO_R_UNSUPPORTED);
819 return NULL;
820 }
821
822 me32.dwSize = sizeof(me32);
823
824 if (!(*module_first)(hModuleSnap,&me32))
825 {
826 (*close_snap)(hModuleSnap);
827 FreeLibrary(dll);
828 return NULL;
829 }
830
831 do {
832 if ((ret = GetProcAddress(me32.hModule,name)))
833 {
834 (*close_snap)(hModuleSnap);
835 FreeLibrary(dll);
836 return ret;
837 }
838 } while((*module_next)(hModuleSnap,&me32));
839
840 (*close_snap)(hModuleSnap);
841 FreeLibrary(dll);
842 return NULL;
843 }
844#endif /* DSO_WIN32 */
diff --git a/src/lib/libcrypto/dyn_lck.c b/src/lib/libcrypto/dyn_lck.c
deleted file mode 100644
index 7f82c41264..0000000000
--- a/src/lib/libcrypto/dyn_lck.c
+++ /dev/null
@@ -1,428 +0,0 @@
1/* crypto/cryptlib.c */
2/* ====================================================================
3 * Copyright (c) 1998-2003 The OpenSSL Project. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 *
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in
14 * the documentation and/or other materials provided with the
15 * distribution.
16 *
17 * 3. All advertising materials mentioning features or use of this
18 * software must display the following acknowledgment:
19 * "This product includes software developed by the OpenSSL Project
20 * for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
21 *
22 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
23 * endorse or promote products derived from this software without
24 * prior written permission. For written permission, please contact
25 * openssl-core@openssl.org.
26 *
27 * 5. Products derived from this software may not be called "OpenSSL"
28 * nor may "OpenSSL" appear in their names without prior written
29 * permission of the OpenSSL Project.
30 *
31 * 6. Redistributions of any form whatsoever must retain the following
32 * acknowledgment:
33 * "This product includes software developed by the OpenSSL Project
34 * for use in the OpenSSL Toolkit (http://www.openssl.org/)"
35 *
36 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
37 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
38 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
39 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
40 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
41 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
42 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
43 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
44 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
45 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
46 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
47 * OF THE POSSIBILITY OF SUCH DAMAGE.
48 * ====================================================================
49 *
50 * This product includes cryptographic software written by Eric Young
51 * (eay@cryptsoft.com). This product includes software written by Tim
52 * Hudson (tjh@cryptsoft.com).
53 *
54 */
55/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
56 * All rights reserved.
57 *
58 * This package is an SSL implementation written
59 * by Eric Young (eay@cryptsoft.com).
60 * The implementation was written so as to conform with Netscapes SSL.
61 *
62 * This library is free for commercial and non-commercial use as long as
63 * the following conditions are aheared to. The following conditions
64 * apply to all code found in this distribution, be it the RC4, RSA,
65 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
66 * included with this distribution is covered by the same copyright terms
67 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
68 *
69 * Copyright remains Eric Young's, and as such any Copyright notices in
70 * the code are not to be removed.
71 * If this package is used in a product, Eric Young should be given attribution
72 * as the author of the parts of the library used.
73 * This can be in the form of a textual message at program startup or
74 * in documentation (online or textual) provided with the package.
75 *
76 * Redistribution and use in source and binary forms, with or without
77 * modification, are permitted provided that the following conditions
78 * are met:
79 * 1. Redistributions of source code must retain the copyright
80 * notice, this list of conditions and the following disclaimer.
81 * 2. Redistributions in binary form must reproduce the above copyright
82 * notice, this list of conditions and the following disclaimer in the
83 * documentation and/or other materials provided with the distribution.
84 * 3. All advertising materials mentioning features or use of this software
85 * must display the following acknowledgement:
86 * "This product includes cryptographic software written by
87 * Eric Young (eay@cryptsoft.com)"
88 * The word 'cryptographic' can be left out if the rouines from the library
89 * being used are not cryptographic related :-).
90 * 4. If you include any Windows specific code (or a derivative thereof) from
91 * the apps directory (application code) you must include an acknowledgement:
92 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
93 *
94 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
95 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
96 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
97 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
98 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
99 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
100 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
101 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
102 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
103 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
104 * SUCH DAMAGE.
105 *
106 * The licence and distribution terms for any publically available version or
107 * derivative of this code cannot be changed. i.e. this code cannot simply be
108 * copied and put under another distribution licence
109 * [including the GNU Public Licence.]
110 */
111/* ====================================================================
112 * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED.
113 * ECDH support in OpenSSL originally developed by
114 * SUN MICROSYSTEMS, INC., and contributed to the OpenSSL project.
115 */
116
117#include "cryptlib.h"
118#include <openssl/safestack.h>
119
120#if defined(OPENSSL_SYS_WIN32) || defined(OPENSSL_SYS_WIN16)
121static double SSLeay_MSVC5_hack=0.0; /* and for VC1.5 */
122#endif
123
124DECLARE_STACK_OF(CRYPTO_dynlock)
125IMPLEMENT_STACK_OF(CRYPTO_dynlock)
126
127/* real #defines in crypto.h, keep these upto date */
128static const char* const lock_names[CRYPTO_NUM_LOCKS] =
129 {
130 "<<ERROR>>",
131 "err",
132 "ex_data",
133 "x509",
134 "x509_info",
135 "x509_pkey",
136 "x509_crl",
137 "x509_req",
138 "dsa",
139 "rsa",
140 "evp_pkey",
141 "x509_store",
142 "ssl_ctx",
143 "ssl_cert",
144 "ssl_session",
145 "ssl_sess_cert",
146 "ssl",
147 "ssl_method",
148 "rand",
149 "rand2",
150 "debug_malloc",
151 "BIO",
152 "gethostbyname",
153 "getservbyname",
154 "readdir",
155 "RSA_blinding",
156 "dh",
157 "debug_malloc2",
158 "dso",
159 "dynlock",
160 "engine",
161 "ui",
162 "ecdsa",
163 "ec",
164 "ecdh",
165 "bn",
166 "ec_pre_comp",
167 "store",
168 "comp",
169#ifndef OPENSSL_FIPS
170# if CRYPTO_NUM_LOCKS != 39
171# error "Inconsistency between crypto.h and cryptlib.c"
172# endif
173#else
174 "fips",
175 "fips2",
176# if CRYPTO_NUM_LOCKS != 41
177# error "Inconsistency between crypto.h and cryptlib.c"
178# endif
179#endif
180 };
181
182/* This is for applications to allocate new type names in the non-dynamic
183 array of lock names. These are numbered with positive numbers. */
184static STACK *app_locks=NULL;
185
186/* For applications that want a more dynamic way of handling threads, the
187 following stack is used. These are externally numbered with negative
188 numbers. */
189static STACK_OF(CRYPTO_dynlock) *dyn_locks=NULL;
190
191
192static struct CRYPTO_dynlock_value *(MS_FAR *dynlock_create_callback)
193 (const char *file,int line)=NULL;
194static void (MS_FAR *dynlock_lock_callback)(int mode,
195 struct CRYPTO_dynlock_value *l, const char *file,int line)=NULL;
196static void (MS_FAR *dynlock_destroy_callback)(struct CRYPTO_dynlock_value *l,
197 const char *file,int line)=NULL;
198
199int CRYPTO_get_new_lockid(char *name)
200 {
201 char *str;
202 int i;
203
204#if defined(OPENSSL_SYS_WIN32) || defined(OPENSSL_SYS_WIN16)
205 /* A hack to make Visual C++ 5.0 work correctly when linking as
206 * a DLL using /MT. Without this, the application cannot use
207 * and floating point printf's.
208 * It also seems to be needed for Visual C 1.5 (win16) */
209 SSLeay_MSVC5_hack=(double)name[0]*(double)name[1];
210#endif
211
212 if ((app_locks == NULL) && ((app_locks=sk_new_null()) == NULL))
213 {
214 CRYPTOerr(CRYPTO_F_CRYPTO_GET_NEW_LOCKID,ERR_R_MALLOC_FAILURE);
215 return(0);
216 }
217 if ((str=BUF_strdup(name)) == NULL)
218 {
219 CRYPTOerr(CRYPTO_F_CRYPTO_GET_NEW_LOCKID,ERR_R_MALLOC_FAILURE);
220 return(0);
221 }
222 i=sk_push(app_locks,str);
223 if (!i)
224 OPENSSL_free(str);
225 else
226 i+=CRYPTO_NUM_LOCKS; /* gap of one :-) */
227 return(i);
228 }
229
230int CRYPTO_get_new_dynlockid(void)
231 {
232 int i = 0;
233 CRYPTO_dynlock *pointer = NULL;
234
235 if (dynlock_create_callback == NULL)
236 {
237 CRYPTOerr(CRYPTO_F_CRYPTO_GET_NEW_DYNLOCKID,CRYPTO_R_NO_DYNLOCK_CREATE_CALLBACK);
238 return(0);
239 }
240 CRYPTO_w_lock(CRYPTO_LOCK_DYNLOCK);
241 if ((dyn_locks == NULL)
242 && ((dyn_locks=sk_CRYPTO_dynlock_new_null()) == NULL))
243 {
244 CRYPTO_w_unlock(CRYPTO_LOCK_DYNLOCK);
245 CRYPTOerr(CRYPTO_F_CRYPTO_GET_NEW_DYNLOCKID,ERR_R_MALLOC_FAILURE);
246 return(0);
247 }
248 CRYPTO_w_unlock(CRYPTO_LOCK_DYNLOCK);
249
250 pointer = (CRYPTO_dynlock *)OPENSSL_malloc(sizeof(CRYPTO_dynlock));
251 if (pointer == NULL)
252 {
253 CRYPTOerr(CRYPTO_F_CRYPTO_GET_NEW_DYNLOCKID,ERR_R_MALLOC_FAILURE);
254 return(0);
255 }
256 pointer->references = 1;
257 pointer->data = dynlock_create_callback(__FILE__,__LINE__);
258 if (pointer->data == NULL)
259 {
260 OPENSSL_free(pointer);
261 CRYPTOerr(CRYPTO_F_CRYPTO_GET_NEW_DYNLOCKID,ERR_R_MALLOC_FAILURE);
262 return(0);
263 }
264
265 CRYPTO_w_lock(CRYPTO_LOCK_DYNLOCK);
266 /* First, try to find an existing empty slot */
267 i=sk_CRYPTO_dynlock_find(dyn_locks,NULL);
268 /* If there was none, push, thereby creating a new one */
269 if (i == -1)
270 /* Since sk_push() returns the number of items on the
271 stack, not the location of the pushed item, we need
272 to transform the returned number into a position,
273 by decreasing it. */
274 i=sk_CRYPTO_dynlock_push(dyn_locks,pointer) - 1;
275 else
276 /* If we found a place with a NULL pointer, put our pointer
277 in it. */
278 (void)sk_CRYPTO_dynlock_set(dyn_locks,i,pointer);
279 CRYPTO_w_unlock(CRYPTO_LOCK_DYNLOCK);
280
281 if (i == -1)
282 {
283 dynlock_destroy_callback(pointer->data,__FILE__,__LINE__);
284 OPENSSL_free(pointer);
285 }
286 else
287 i += 1; /* to avoid 0 */
288 return -i;
289 }
290
291void CRYPTO_destroy_dynlockid(int i)
292 {
293 CRYPTO_dynlock *pointer = NULL;
294 if (i)
295 i = -i-1;
296 if (dynlock_destroy_callback == NULL)
297 return;
298
299 CRYPTO_w_lock(CRYPTO_LOCK_DYNLOCK);
300
301 if (dyn_locks == NULL || i >= sk_CRYPTO_dynlock_num(dyn_locks))
302 {
303 CRYPTO_w_unlock(CRYPTO_LOCK_DYNLOCK);
304 return;
305 }
306 pointer = sk_CRYPTO_dynlock_value(dyn_locks, i);
307 if (pointer != NULL)
308 {
309 --pointer->references;
310#ifdef REF_CHECK
311 if (pointer->references < 0)
312 {
313 fprintf(stderr,"CRYPTO_destroy_dynlockid, bad reference count\n");
314 abort();
315 }
316 else
317#endif
318 if (pointer->references <= 0)
319 {
320 (void)sk_CRYPTO_dynlock_set(dyn_locks, i, NULL);
321 }
322 else
323 pointer = NULL;
324 }
325 CRYPTO_w_unlock(CRYPTO_LOCK_DYNLOCK);
326
327 if (pointer)
328 {
329 dynlock_destroy_callback(pointer->data,__FILE__,__LINE__);
330 OPENSSL_free(pointer);
331 }
332 }
333
334struct CRYPTO_dynlock_value *CRYPTO_get_dynlock_value(int i)
335 {
336 CRYPTO_dynlock *pointer = NULL;
337 if (i)
338 i = -i-1;
339
340 CRYPTO_w_lock(CRYPTO_LOCK_DYNLOCK);
341
342 if (dyn_locks != NULL && i < sk_CRYPTO_dynlock_num(dyn_locks))
343 pointer = sk_CRYPTO_dynlock_value(dyn_locks, i);
344 if (pointer)
345 pointer->references++;
346
347 CRYPTO_w_unlock(CRYPTO_LOCK_DYNLOCK);
348
349 if (pointer)
350 return pointer->data;
351 return NULL;
352 }
353
354struct CRYPTO_dynlock_value *(*CRYPTO_get_dynlock_create_callback(void))
355 (const char *file,int line)
356 {
357 return(dynlock_create_callback);
358 }
359
360void (*CRYPTO_get_dynlock_lock_callback(void))(int mode,
361 struct CRYPTO_dynlock_value *l, const char *file,int line)
362 {
363 return(dynlock_lock_callback);
364 }
365
366void (*CRYPTO_get_dynlock_destroy_callback(void))
367 (struct CRYPTO_dynlock_value *l, const char *file,int line)
368 {
369 return(dynlock_destroy_callback);
370 }
371
372void CRYPTO_set_dynlock_create_callback(struct CRYPTO_dynlock_value *(*func)
373 (const char *file, int line))
374 {
375 dynlock_create_callback=func;
376 }
377
378static void do_dynlock(int mode, int type, const char *file, int line)
379 {
380 if (dynlock_lock_callback != NULL)
381 {
382 struct CRYPTO_dynlock_value *pointer
383 = CRYPTO_get_dynlock_value(type);
384
385 OPENSSL_assert(pointer != NULL);
386
387 dynlock_lock_callback(mode, pointer, file, line);
388
389 CRYPTO_destroy_dynlockid(type);
390 }
391 }
392
393void CRYPTO_set_dynlock_lock_callback(void (*func)(int mode,
394 struct CRYPTO_dynlock_value *l, const char *file, int line))
395 {
396 /* Set callback so CRYPTO_lock() can now handle dynamic locks.
397 * This is OK because at this point and application shouldn't be using
398 * OpenSSL from multiple threads because it is setting up the locking
399 * callbacks.
400 */
401 static int done = 0;
402 if (!done)
403 {
404 int_CRYPTO_set_do_dynlock_callback(do_dynlock);
405 done = 1;
406 }
407
408 dynlock_lock_callback=func;
409 }
410
411void CRYPTO_set_dynlock_destroy_callback(void (*func)
412 (struct CRYPTO_dynlock_value *l, const char *file, int line))
413 {
414 dynlock_destroy_callback=func;
415 }
416
417const char *CRYPTO_get_lock_name(int type)
418 {
419 if (type < 0)
420 return("dynamic");
421 else if (type < CRYPTO_NUM_LOCKS)
422 return(lock_names[type]);
423 else if (type-CRYPTO_NUM_LOCKS > sk_num(app_locks))
424 return("ERROR");
425 else
426 return(sk_value(app_locks,type-CRYPTO_NUM_LOCKS));
427 }
428
diff --git a/src/lib/libcrypto/ec/Makefile.ssl b/src/lib/libcrypto/ec/Makefile.ssl
deleted file mode 100644
index a2805c47a2..0000000000
--- a/src/lib/libcrypto/ec/Makefile.ssl
+++ /dev/null
@@ -1,128 +0,0 @@
1#
2# crypto/ec/Makefile
3#
4
5DIR= ec
6TOP= ../..
7CC= cc
8INCLUDES= -I.. -I$(TOP) -I../../include
9CFLAG=-g
10INSTALL_PREFIX=
11OPENSSLDIR= /usr/local/ssl
12INSTALLTOP=/usr/local/ssl
13MAKE= make -f Makefile.ssl
14MAKEDEPPROG= makedepend
15MAKEDEPEND= $(TOP)/util/domd $(TOP) -MD $(MAKEDEPPROG)
16MAKEFILE= Makefile.ssl
17AR= ar r
18
19CFLAGS= $(INCLUDES) $(CFLAG)
20
21GENERAL=Makefile
22TEST=ectest.c
23APPS=
24
25LIB=$(TOP)/libcrypto.a
26LIBSRC= ec_lib.c ecp_smpl.c ecp_mont.c ecp_recp.c ecp_nist.c ec_cvt.c ec_mult.c \
27 ec_err.c
28
29LIBOBJ= ec_lib.o ecp_smpl.o ecp_mont.o ecp_recp.o ecp_nist.o ec_cvt.o ec_mult.o \
30 ec_err.o
31
32SRC= $(LIBSRC)
33
34EXHEADER= ec.h
35HEADER= ec_lcl.h $(EXHEADER)
36
37ALL= $(GENERAL) $(SRC) $(HEADER)
38
39top:
40 (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all)
41
42all: lib
43
44lib: $(LIBOBJ)
45 $(AR) $(LIB) $(LIBOBJ)
46 $(RANLIB) $(LIB) || echo Never mind.
47 @touch lib
48
49files:
50 $(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO
51
52links:
53 @sh $(TOP)/util/point.sh Makefile.ssl Makefile
54 @$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER)
55 @$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST)
56 @$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS)
57
58install:
59 @for i in $(EXHEADER) ; \
60 do \
61 (cp $$i $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i; \
62 chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i ); \
63 done;
64
65tags:
66 ctags $(SRC)
67
68tests:
69
70lint:
71 lint -DLINT $(INCLUDES) $(SRC)>fluff
72
73depend:
74 $(MAKEDEPEND) -- $(CFLAG) $(INCLUDES) $(DEPFLAG) -- $(PROGS) $(LIBSRC)
75
76dclean:
77 $(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
78 mv -f Makefile.new $(MAKEFILE)
79
80clean:
81 rm -f *.o */*.o *.obj lib tags core .pure .nfs* *.old *.bak fluff
82
83# DO NOT DELETE THIS LINE -- make depend depends on it.
84
85ec_cvt.o: ../../include/openssl/bn.h ../../include/openssl/e_os2.h
86ec_cvt.o: ../../include/openssl/ec.h ../../include/openssl/opensslconf.h
87ec_cvt.o: ../../include/openssl/symhacks.h ec_cvt.c ec_lcl.h
88ec_err.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
89ec_err.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
90ec_err.o: ../../include/openssl/ec.h ../../include/openssl/err.h
91ec_err.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
92ec_err.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
93ec_err.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
94ec_err.o: ec_err.c
95ec_lib.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
96ec_lib.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
97ec_lib.o: ../../include/openssl/ec.h ../../include/openssl/err.h
98ec_lib.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
99ec_lib.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
100ec_lib.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
101ec_lib.o: ec_lcl.h ec_lib.c
102ec_mult.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
103ec_mult.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
104ec_mult.o: ../../include/openssl/ec.h ../../include/openssl/err.h
105ec_mult.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
106ec_mult.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
107ec_mult.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
108ec_mult.o: ec_lcl.h ec_mult.c
109ecp_mont.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
110ecp_mont.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
111ecp_mont.o: ../../include/openssl/ec.h ../../include/openssl/err.h
112ecp_mont.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
113ecp_mont.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
114ecp_mont.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
115ecp_mont.o: ec_lcl.h ecp_mont.c
116ecp_nist.o: ../../include/openssl/bn.h ../../include/openssl/e_os2.h
117ecp_nist.o: ../../include/openssl/ec.h ../../include/openssl/opensslconf.h
118ecp_nist.o: ../../include/openssl/symhacks.h ec_lcl.h ecp_nist.c
119ecp_recp.o: ../../include/openssl/bn.h ../../include/openssl/e_os2.h
120ecp_recp.o: ../../include/openssl/ec.h ../../include/openssl/opensslconf.h
121ecp_recp.o: ../../include/openssl/symhacks.h ec_lcl.h ecp_recp.c
122ecp_smpl.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
123ecp_smpl.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
124ecp_smpl.o: ../../include/openssl/ec.h ../../include/openssl/err.h
125ecp_smpl.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
126ecp_smpl.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
127ecp_smpl.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
128ecp_smpl.o: ec_lcl.h ecp_smpl.c
diff --git a/src/lib/libcrypto/ec/ec.h b/src/lib/libcrypto/ec/ec.h
index 8bc2a235b1..ee7078130c 100644
--- a/src/lib/libcrypto/ec/ec.h
+++ b/src/lib/libcrypto/ec/ec.h
@@ -2,8 +2,12 @@
2/* 2/*
3 * Originally written by Bodo Moeller for the OpenSSL project. 3 * Originally written by Bodo Moeller for the OpenSSL project.
4 */ 4 */
5/**
6 * \file crypto/ec/ec.h Include file for the OpenSSL EC functions
7 * \author Originally written by Bodo Moeller for the OpenSSL project
8 */
5/* ==================================================================== 9/* ====================================================================
6 * Copyright (c) 1998-2003 The OpenSSL Project. All rights reserved. 10 * Copyright (c) 1998-2005 The OpenSSL Project. All rights reserved.
7 * 11 *
8 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions 13 * modification, are permitted provided that the following conditions
@@ -92,15 +96,21 @@ extern "C" {
92# endif 96# endif
93#endif 97#endif
94 98
95 99
96#ifndef OPENSSL_ECC_MAX_FIELD_BITS 100#ifndef OPENSSL_ECC_MAX_FIELD_BITS
97# define OPENSSL_ECC_MAX_FIELD_BITS 661 101# define OPENSSL_ECC_MAX_FIELD_BITS 661
98#endif 102#endif
99 103
104/** Enum for the point conversion form as defined in X9.62 (ECDSA)
105 * for the encoding of a elliptic curve point (x,y) */
100typedef enum { 106typedef enum {
101 /* values as defined in X9.62 (ECDSA) and elsewhere */ 107 /** the point is encoded as z||x, where the octet z specifies
108 * which solution of the quadratic equation y is */
102 POINT_CONVERSION_COMPRESSED = 2, 109 POINT_CONVERSION_COMPRESSED = 2,
110 /** the point is encoded as z||x||y, where z is the octet 0x02 */
103 POINT_CONVERSION_UNCOMPRESSED = 4, 111 POINT_CONVERSION_UNCOMPRESSED = 4,
112 /** the point is encoded as z||x||y, where the octet z specifies
113 * which solution of the quadratic equation y is */
104 POINT_CONVERSION_HYBRID = 6 114 POINT_CONVERSION_HYBRID = 6
105} point_conversion_form_t; 115} point_conversion_form_t;
106 116
@@ -121,37 +131,129 @@ typedef struct ec_group_st
121typedef struct ec_point_st EC_POINT; 131typedef struct ec_point_st EC_POINT;
122 132
123 133
124/* EC_METHODs for curves over GF(p). 134/********************************************************************/
125 * EC_GFp_simple_method provides the basis for the optimized methods. 135/* EC_METHODs for curves over GF(p) */
136/********************************************************************/
137
138/** Returns the basic GFp ec methods which provides the basis for the
139 * optimized methods.
140 * \return EC_METHOD object
126 */ 141 */
127const EC_METHOD *EC_GFp_simple_method(void); 142const EC_METHOD *EC_GFp_simple_method(void);
143
144/** Returns GFp methods using montgomery multiplication.
145 * \return EC_METHOD object
146 */
128const EC_METHOD *EC_GFp_mont_method(void); 147const EC_METHOD *EC_GFp_mont_method(void);
148
149/** Returns GFp methods using optimized methods for NIST recommended curves
150 * \return EC_METHOD object
151 */
129const EC_METHOD *EC_GFp_nist_method(void); 152const EC_METHOD *EC_GFp_nist_method(void);
130 153
131/* EC_METHOD for curves over GF(2^m). 154
155/********************************************************************/
156/* EC_METHOD for curves over GF(2^m) */
157/********************************************************************/
158
159/** Returns the basic GF2m ec method
160 * \return EC_METHOD object
132 */ 161 */
133const EC_METHOD *EC_GF2m_simple_method(void); 162const EC_METHOD *EC_GF2m_simple_method(void);
134 163
135 164
136EC_GROUP *EC_GROUP_new(const EC_METHOD *); 165/********************************************************************/
137void EC_GROUP_free(EC_GROUP *); 166/* EC_GROUP functions */
138void EC_GROUP_clear_free(EC_GROUP *); 167/********************************************************************/
139int EC_GROUP_copy(EC_GROUP *, const EC_GROUP *);
140EC_GROUP *EC_GROUP_dup(const EC_GROUP *);
141 168
142const EC_METHOD *EC_GROUP_method_of(const EC_GROUP *); 169/** Creates a new EC_GROUP object
143int EC_METHOD_get_field_type(const EC_METHOD *); 170 * \param meth EC_METHOD to use
171 * \return newly created EC_GROUP object or NULL in case of an error.
172 */
173EC_GROUP *EC_GROUP_new(const EC_METHOD *meth);
144 174
145int EC_GROUP_set_generator(EC_GROUP *, const EC_POINT *generator, const BIGNUM *order, const BIGNUM *cofactor); 175/** Frees a EC_GROUP object
146const EC_POINT *EC_GROUP_get0_generator(const EC_GROUP *); 176 * \param group EC_GROUP object to be freed.
147int EC_GROUP_get_order(const EC_GROUP *, BIGNUM *order, BN_CTX *); 177 */
148int EC_GROUP_get_cofactor(const EC_GROUP *, BIGNUM *cofactor, BN_CTX *); 178void EC_GROUP_free(EC_GROUP *group);
149 179
150void EC_GROUP_set_curve_name(EC_GROUP *, int nid); 180/** Clears and frees a EC_GROUP object
151int EC_GROUP_get_curve_name(const EC_GROUP *); 181 * \param group EC_GROUP object to be cleared and freed.
182 */
183void EC_GROUP_clear_free(EC_GROUP *group);
152 184
153void EC_GROUP_set_asn1_flag(EC_GROUP *, int flag); 185/** Copies EC_GROUP objects. Note: both EC_GROUPs must use the same EC_METHOD.
154int EC_GROUP_get_asn1_flag(const EC_GROUP *); 186 * \param dst destination EC_GROUP object
187 * \param src source EC_GROUP object
188 * \return 1 on success and 0 if an error occurred.
189 */
190int EC_GROUP_copy(EC_GROUP *dst, const EC_GROUP *src);
191
192/** Creates a new EC_GROUP object and copies the copies the content
193 * form src to the newly created EC_KEY object
194 * \param src source EC_GROUP object
195 * \return newly created EC_GROUP object or NULL in case of an error.
196 */
197EC_GROUP *EC_GROUP_dup(const EC_GROUP *src);
198
199/** Returns the EC_METHOD of the EC_GROUP object.
200 * \param group EC_GROUP object
201 * \return EC_METHOD used in this EC_GROUP object.
202 */
203const EC_METHOD *EC_GROUP_method_of(const EC_GROUP *group);
204
205/** Returns the field type of the EC_METHOD.
206 * \param meth EC_METHOD object
207 * \return NID of the underlying field type OID.
208 */
209int EC_METHOD_get_field_type(const EC_METHOD *meth);
210
211/** Sets the generator and it's order/cofactor of a EC_GROUP object.
212 * \param group EC_GROUP object
213 * \param generator EC_POINT object with the generator.
214 * \param order the order of the group generated by the generator.
215 * \param cofactor the index of the sub-group generated by the generator
216 * in the group of all points on the elliptic curve.
217 * \return 1 on success and 0 if an error occured
218 */
219int EC_GROUP_set_generator(EC_GROUP *group, const EC_POINT *generator, const BIGNUM *order, const BIGNUM *cofactor);
220
221/** Returns the generator of a EC_GROUP object.
222 * \param group EC_GROUP object
223 * \return the currently used generator (possibly NULL).
224 */
225const EC_POINT *EC_GROUP_get0_generator(const EC_GROUP *group);
226
227/** Gets the order of a EC_GROUP
228 * \param group EC_GROUP object
229 * \param order BIGNUM to which the order is copied
230 * \param ctx BN_CTX object (optional)
231 * \return 1 on success and 0 if an error occured
232 */
233int EC_GROUP_get_order(const EC_GROUP *group, BIGNUM *order, BN_CTX *ctx);
234
235/** Gets the cofactor of a EC_GROUP
236 * \param group EC_GROUP object
237 * \param cofactor BIGNUM to which the cofactor is copied
238 * \param ctx BN_CTX object (optional)
239 * \return 1 on success and 0 if an error occured
240 */
241int EC_GROUP_get_cofactor(const EC_GROUP *group, BIGNUM *cofactor, BN_CTX *ctx);
242
243/** Sets the name of a EC_GROUP object
244 * \param group EC_GROUP object
245 * \param nid NID of the curve name OID
246 */
247void EC_GROUP_set_curve_name(EC_GROUP *group, int nid);
248
249/** Returns the curve name of a EC_GROUP object
250 * \param group EC_GROUP object
251 * \return NID of the curve name OID or 0 if not set.
252 */
253int EC_GROUP_get_curve_name(const EC_GROUP *group);
254
255void EC_GROUP_set_asn1_flag(EC_GROUP *group, int flag);
256int EC_GROUP_get_asn1_flag(const EC_GROUP *group);
155 257
156void EC_GROUP_set_point_conversion_form(EC_GROUP *, point_conversion_form_t); 258void EC_GROUP_set_point_conversion_form(EC_GROUP *, point_conversion_form_t);
157point_conversion_form_t EC_GROUP_get_point_conversion_form(const EC_GROUP *); 259point_conversion_form_t EC_GROUP_get_point_conversion_form(const EC_GROUP *);
@@ -160,36 +262,114 @@ unsigned char *EC_GROUP_get0_seed(const EC_GROUP *);
160size_t EC_GROUP_get_seed_len(const EC_GROUP *); 262size_t EC_GROUP_get_seed_len(const EC_GROUP *);
161size_t EC_GROUP_set_seed(EC_GROUP *, const unsigned char *, size_t len); 263size_t EC_GROUP_set_seed(EC_GROUP *, const unsigned char *, size_t len);
162 264
163int EC_GROUP_set_curve_GFp(EC_GROUP *, const BIGNUM *p, const BIGNUM *a, const BIGNUM *b, BN_CTX *); 265/** Sets the parameter of a ec over GFp defined by y^2 = x^3 + a*x + b
164int EC_GROUP_get_curve_GFp(const EC_GROUP *, BIGNUM *p, BIGNUM *a, BIGNUM *b, BN_CTX *); 266 * \param group EC_GROUP object
165int EC_GROUP_set_curve_GF2m(EC_GROUP *, const BIGNUM *p, const BIGNUM *a, const BIGNUM *b, BN_CTX *); 267 * \param p BIGNUM with the prime number
166int EC_GROUP_get_curve_GF2m(const EC_GROUP *, BIGNUM *p, BIGNUM *a, BIGNUM *b, BN_CTX *); 268 * \param a BIGNUM with parameter a of the equation
269 * \param b BIGNUM with parameter b of the equation
270 * \param ctx BN_CTX object (optional)
271 * \return 1 on success and 0 if an error occured
272 */
273int EC_GROUP_set_curve_GFp(EC_GROUP *group, const BIGNUM *p, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx);
274
275/** Gets the parameter of the ec over GFp defined by y^2 = x^3 + a*x + b
276 * \param group EC_GROUP object
277 * \param p BIGNUM for the prime number
278 * \param a BIGNUM for parameter a of the equation
279 * \param b BIGNUM for parameter b of the equation
280 * \param ctx BN_CTX object (optional)
281 * \return 1 on success and 0 if an error occured
282 */
283int EC_GROUP_get_curve_GFp(const EC_GROUP *group, BIGNUM *p, BIGNUM *a, BIGNUM *b, BN_CTX *ctx);
284
285/** Sets the parameter of a ec over GF2m defined by y^2 + x*y = x^3 + a*x^2 + b
286 * \param group EC_GROUP object
287 * \param p BIGNUM with the polynomial defining the underlying field
288 * \param a BIGNUM with parameter a of the equation
289 * \param b BIGNUM with parameter b of the equation
290 * \param ctx BN_CTX object (optional)
291 * \return 1 on success and 0 if an error occured
292 */
293int EC_GROUP_set_curve_GF2m(EC_GROUP *group, const BIGNUM *p, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx);
294
295/** Gets the parameter of the ec over GF2m defined by y^2 + x*y = x^3 + a*x^2 + b
296 * \param group EC_GROUP object
297 * \param p BIGNUM for the polynomial defining the underlying field
298 * \param a BIGNUM for parameter a of the equation
299 * \param b BIGNUM for parameter b of the equation
300 * \param ctx BN_CTX object (optional)
301 * \return 1 on success and 0 if an error occured
302 */
303int EC_GROUP_get_curve_GF2m(const EC_GROUP *group, BIGNUM *p, BIGNUM *a, BIGNUM *b, BN_CTX *ctx);
167 304
168/* returns the number of bits needed to represent a field element */ 305/** Returns the number of bits needed to represent a field element
169int EC_GROUP_get_degree(const EC_GROUP *); 306 * \param group EC_GROUP object
307 * \return number of bits needed to represent a field element
308 */
309int EC_GROUP_get_degree(const EC_GROUP *group);
170 310
171/* EC_GROUP_check() returns 1 if 'group' defines a valid group, 0 otherwise */ 311/** Checks whether the parameter in the EC_GROUP define a valid ec group
312 * \param group EC_GROUP object
313 * \param ctx BN_CTX object (optional)
314 * \return 1 if group is a valid ec group and 0 otherwise
315 */
172int EC_GROUP_check(const EC_GROUP *group, BN_CTX *ctx); 316int EC_GROUP_check(const EC_GROUP *group, BN_CTX *ctx);
173/* EC_GROUP_check_discriminant() returns 1 if the discriminant of the
174 * elliptic curve is not zero, 0 otherwise */
175int EC_GROUP_check_discriminant(const EC_GROUP *, BN_CTX *);
176 317
177/* EC_GROUP_cmp() returns 0 if both groups are equal and 1 otherwise */ 318/** Checks whether the discriminant of the elliptic curve is zero or not
178int EC_GROUP_cmp(const EC_GROUP *, const EC_GROUP *, BN_CTX *); 319 * \param group EC_GROUP object
320 * \param ctx BN_CTX object (optional)
321 * \return 1 if the discriminant is not zero and 0 otherwise
322 */
323int EC_GROUP_check_discriminant(const EC_GROUP *group, BN_CTX *ctx);
324
325/** Compares two EC_GROUP objects
326 * \param a first EC_GROUP object
327 * \param b second EC_GROUP object
328 * \param ctx BN_CTX object (optional)
329 * \return 0 if both groups are equal and 1 otherwise
330 */
331int EC_GROUP_cmp(const EC_GROUP *a, const EC_GROUP *b, BN_CTX *ctx);
179 332
180/* EC_GROUP_new_GF*() calls EC_GROUP_new() and EC_GROUP_set_GF*() 333/* EC_GROUP_new_GF*() calls EC_GROUP_new() and EC_GROUP_set_GF*()
181 * after choosing an appropriate EC_METHOD */ 334 * after choosing an appropriate EC_METHOD */
182EC_GROUP *EC_GROUP_new_curve_GFp(const BIGNUM *p, const BIGNUM *a, const BIGNUM *b, BN_CTX *);
183EC_GROUP *EC_GROUP_new_curve_GF2m(const BIGNUM *p, const BIGNUM *a, const BIGNUM *b, BN_CTX *);
184 335
185/* EC_GROUP_new_by_curve_name() creates a EC_GROUP structure 336/** Creates a new EC_GROUP object with the specified parameters defined
186 * specified by a curve name (in form of a NID) */ 337 * over GFp (defined by the equation y^2 = x^3 + a*x + b)
338 * \param p BIGNUM with the prime number
339 * \param a BIGNUM with the parameter a of the equation
340 * \param b BIGNUM with the parameter b of the equation
341 * \param ctx BN_CTX object (optional)
342 * \return newly created EC_GROUP object with the specified parameters
343 */
344EC_GROUP *EC_GROUP_new_curve_GFp(const BIGNUM *p, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx);
345
346/** Creates a new EC_GROUP object with the specified parameters defined
347 * over GF2m (defined by the equation y^2 + x*y = x^3 + a*x^2 + b)
348 * \param p BIGNUM with the polynomial defining the underlying field
349 * \param a BIGNUM with the parameter a of the equation
350 * \param b BIGNUM with the parameter b of the equation
351 * \param ctx BN_CTX object (optional)
352 * \return newly created EC_GROUP object with the specified parameters
353 */
354EC_GROUP *EC_GROUP_new_curve_GF2m(const BIGNUM *p, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx);
355
356/** Creates a EC_GROUP object with a curve specified by a NID
357 * \param nid NID of the OID of the curve name
358 * \return newly created EC_GROUP object with specified curve or NULL
359 * if an error occurred
360 */
187EC_GROUP *EC_GROUP_new_by_curve_name(int nid); 361EC_GROUP *EC_GROUP_new_by_curve_name(int nid);
188/* handling of internal curves */ 362
363
364/********************************************************************/
365/* handling of internal curves */
366/********************************************************************/
367
189typedef struct { 368typedef struct {
190 int nid; 369 int nid;
191 const char *comment; 370 const char *comment;
192 } EC_builtin_curve; 371 } EC_builtin_curve;
372
193/* EC_builtin_curves(EC_builtin_curve *r, size_t size) returns number 373/* EC_builtin_curves(EC_builtin_curve *r, size_t size) returns number
194 * of all available curves or zero if a error occurred. 374 * of all available curves or zero if a error occurred.
195 * In case r ist not zero nitems EC_builtin_curve structures 375 * In case r ist not zero nitems EC_builtin_curve structures
@@ -197,39 +377,168 @@ typedef struct {
197size_t EC_get_builtin_curves(EC_builtin_curve *r, size_t nitems); 377size_t EC_get_builtin_curves(EC_builtin_curve *r, size_t nitems);
198 378
199 379
200/* EC_POINT functions */ 380/********************************************************************/
381/* EC_POINT functions */
382/********************************************************************/
383
384/** Creates a new EC_POINT object for the specified EC_GROUP
385 * \param group EC_GROUP the underlying EC_GROUP object
386 * \return newly created EC_POINT object or NULL if an error occurred
387 */
388EC_POINT *EC_POINT_new(const EC_GROUP *group);
389
390/** Frees a EC_POINT object
391 * \param point EC_POINT object to be freed
392 */
393void EC_POINT_free(EC_POINT *point);
394
395/** Clears and frees a EC_POINT object
396 * \param point EC_POINT object to be cleared and freed
397 */
398void EC_POINT_clear_free(EC_POINT *point);
399
400/** Copies EC_POINT object
401 * \param dst destination EC_POINT object
402 * \param src source EC_POINT object
403 * \return 1 on success and 0 if an error occured
404 */
405int EC_POINT_copy(EC_POINT *dst, const EC_POINT *src);
201 406
202EC_POINT *EC_POINT_new(const EC_GROUP *); 407/** Creates a new EC_POINT object and copies the content of the supplied
203void EC_POINT_free(EC_POINT *); 408 * EC_POINT
204void EC_POINT_clear_free(EC_POINT *); 409 * \param src source EC_POINT object
205int EC_POINT_copy(EC_POINT *, const EC_POINT *); 410 * \param group underlying the EC_GROUP object
206EC_POINT *EC_POINT_dup(const EC_POINT *, const EC_GROUP *); 411 * \return newly created EC_POINT object or NULL if an error occurred
412 */
413EC_POINT *EC_POINT_dup(const EC_POINT *src, const EC_GROUP *group);
207 414
208const EC_METHOD *EC_POINT_method_of(const EC_POINT *); 415/** Returns the EC_METHOD used in EC_POINT object
209 416 * \param point EC_POINT object
210int EC_POINT_set_to_infinity(const EC_GROUP *, EC_POINT *); 417 * \return the EC_METHOD used
211int EC_POINT_set_Jprojective_coordinates_GFp(const EC_GROUP *, EC_POINT *, 418 */
212 const BIGNUM *x, const BIGNUM *y, const BIGNUM *z, BN_CTX *); 419const EC_METHOD *EC_POINT_method_of(const EC_POINT *point);
213int EC_POINT_get_Jprojective_coordinates_GFp(const EC_GROUP *, const EC_POINT *, 420
214 BIGNUM *x, BIGNUM *y, BIGNUM *z, BN_CTX *); 421/** Sets a point to infinity (neutral element)
215int EC_POINT_set_affine_coordinates_GFp(const EC_GROUP *, EC_POINT *, 422 * \param group underlying EC_GROUP object
216 const BIGNUM *x, const BIGNUM *y, BN_CTX *); 423 * \param point EC_POINT to set to infinity
217int EC_POINT_get_affine_coordinates_GFp(const EC_GROUP *, const EC_POINT *, 424 * \return 1 on success and 0 if an error occured
218 BIGNUM *x, BIGNUM *y, BN_CTX *); 425 */
219int EC_POINT_set_compressed_coordinates_GFp(const EC_GROUP *, EC_POINT *, 426int EC_POINT_set_to_infinity(const EC_GROUP *group, EC_POINT *point);
220 const BIGNUM *x, int y_bit, BN_CTX *); 427
221 428/** Sets the jacobian projective coordinates of a EC_POINT over GFp
222int EC_POINT_set_affine_coordinates_GF2m(const EC_GROUP *, EC_POINT *, 429 * \param group underlying EC_GROUP object
223 const BIGNUM *x, const BIGNUM *y, BN_CTX *); 430 * \param p EC_POINT object
224int EC_POINT_get_affine_coordinates_GF2m(const EC_GROUP *, const EC_POINT *, 431 * \param x BIGNUM with the x-coordinate
225 BIGNUM *x, BIGNUM *y, BN_CTX *); 432 * \param y BIGNUM with the y-coordinate
226int EC_POINT_set_compressed_coordinates_GF2m(const EC_GROUP *, EC_POINT *, 433 * \param z BIGNUM with the z-coordinate
227 const BIGNUM *x, int y_bit, BN_CTX *); 434 * \param ctx BN_CTX object (optional)
228 435 * \return 1 on success and 0 if an error occured
229size_t EC_POINT_point2oct(const EC_GROUP *, const EC_POINT *, point_conversion_form_t form, 436 */
230 unsigned char *buf, size_t len, BN_CTX *); 437int EC_POINT_set_Jprojective_coordinates_GFp(const EC_GROUP *group, EC_POINT *p,
231int EC_POINT_oct2point(const EC_GROUP *, EC_POINT *, 438 const BIGNUM *x, const BIGNUM *y, const BIGNUM *z, BN_CTX *ctx);
232 const unsigned char *buf, size_t len, BN_CTX *); 439
440/** Gets the jacobian projective coordinates of a EC_POINT over GFp
441 * \param group underlying EC_GROUP object
442 * \param p EC_POINT object
443 * \param x BIGNUM for the x-coordinate
444 * \param y BIGNUM for the y-coordinate
445 * \param z BIGNUM for the z-coordinate
446 * \param ctx BN_CTX object (optional)
447 * \return 1 on success and 0 if an error occured
448 */
449int EC_POINT_get_Jprojective_coordinates_GFp(const EC_GROUP *group,
450 const EC_POINT *p, BIGNUM *x, BIGNUM *y, BIGNUM *z, BN_CTX *ctx);
451
452/** Sets the affine coordinates of a EC_POINT over GFp
453 * \param group underlying EC_GROUP object
454 * \param p EC_POINT object
455 * \param x BIGNUM with the x-coordinate
456 * \param y BIGNUM with the y-coordinate
457 * \param ctx BN_CTX object (optional)
458 * \return 1 on success and 0 if an error occured
459 */
460int EC_POINT_set_affine_coordinates_GFp(const EC_GROUP *group, EC_POINT *p,
461 const BIGNUM *x, const BIGNUM *y, BN_CTX *ctx);
462
463/** Gets the affine coordinates of a EC_POINT over GFp
464 * \param group underlying EC_GROUP object
465 * \param p EC_POINT object
466 * \param x BIGNUM for the x-coordinate
467 * \param y BIGNUM for the y-coordinate
468 * \param ctx BN_CTX object (optional)
469 * \return 1 on success and 0 if an error occured
470 */
471int EC_POINT_get_affine_coordinates_GFp(const EC_GROUP *group,
472 const EC_POINT *p, BIGNUM *x, BIGNUM *y, BN_CTX *ctx);
473
474/** Sets the x9.62 compressed coordinates of a EC_POINT over GFp
475 * \param group underlying EC_GROUP object
476 * \param p EC_POINT object
477 * \param x BIGNUM with x-coordinate
478 * \param y_bit integer with the y-Bit (either 0 or 1)
479 * \param ctx BN_CTX object (optional)
480 * \return 1 on success and 0 if an error occured
481 */
482int EC_POINT_set_compressed_coordinates_GFp(const EC_GROUP *group, EC_POINT *p,
483 const BIGNUM *x, int y_bit, BN_CTX *ctx);
484
485/** Sets the affine coordinates of a EC_POINT over GF2m
486 * \param group underlying EC_GROUP object
487 * \param p EC_POINT object
488 * \param x BIGNUM with the x-coordinate
489 * \param y BIGNUM with the y-coordinate
490 * \param ctx BN_CTX object (optional)
491 * \return 1 on success and 0 if an error occured
492 */
493int EC_POINT_set_affine_coordinates_GF2m(const EC_GROUP *group, EC_POINT *p,
494 const BIGNUM *x, const BIGNUM *y, BN_CTX *ctx);
495
496/** Gets the affine coordinates of a EC_POINT over GF2m
497 * \param group underlying EC_GROUP object
498 * \param p EC_POINT object
499 * \param x BIGNUM for the x-coordinate
500 * \param y BIGNUM for the y-coordinate
501 * \param ctx BN_CTX object (optional)
502 * \return 1 on success and 0 if an error occured
503 */
504int EC_POINT_get_affine_coordinates_GF2m(const EC_GROUP *group,
505 const EC_POINT *p, BIGNUM *x, BIGNUM *y, BN_CTX *ctx);
506
507/** Sets the x9.62 compressed coordinates of a EC_POINT over GF2m
508 * \param group underlying EC_GROUP object
509 * \param p EC_POINT object
510 * \param x BIGNUM with x-coordinate
511 * \param y_bit integer with the y-Bit (either 0 or 1)
512 * \param ctx BN_CTX object (optional)
513 * \return 1 on success and 0 if an error occured
514 */
515int EC_POINT_set_compressed_coordinates_GF2m(const EC_GROUP *group, EC_POINT *p,
516 const BIGNUM *x, int y_bit, BN_CTX *ctx);
517
518/** Encodes a EC_POINT object to a octet string
519 * \param group underlying EC_GROUP object
520 * \param p EC_POINT object
521 * \param form point conversion form
522 * \param buf memory buffer for the result. If NULL the function returns
523 * required buffer size.
524 * \param len length of the memory buffer
525 * \param ctx BN_CTX object (optional)
526 * \return the length of the encoded octet string or 0 if an error occurred
527 */
528size_t EC_POINT_point2oct(const EC_GROUP *group, const EC_POINT *p,
529 point_conversion_form_t form,
530 unsigned char *buf, size_t len, BN_CTX *ctx);
531
532/** Decodes a EC_POINT from a octet string
533 * \param group underlying EC_GROUP object
534 * \param p EC_POINT object
535 * \param buf memory buffer with the encoded ec point
536 * \param len length of the encoded ec point
537 * \param ctx BN_CTX object (optional)
538 * \return 1 on success and 0 if an error occured
539 */
540int EC_POINT_oct2point(const EC_GROUP *group, EC_POINT *p,
541 const unsigned char *buf, size_t len, BN_CTX *ctx);
233 542
234/* other interfaces to point2oct/oct2point: */ 543/* other interfaces to point2oct/oct2point: */
235BIGNUM *EC_POINT_point2bn(const EC_GROUP *, const EC_POINT *, 544BIGNUM *EC_POINT_point2bn(const EC_GROUP *, const EC_POINT *,
@@ -241,29 +550,105 @@ char *EC_POINT_point2hex(const EC_GROUP *, const EC_POINT *,
241EC_POINT *EC_POINT_hex2point(const EC_GROUP *, const char *, 550EC_POINT *EC_POINT_hex2point(const EC_GROUP *, const char *,
242 EC_POINT *, BN_CTX *); 551 EC_POINT *, BN_CTX *);
243 552
244int EC_POINT_add(const EC_GROUP *, EC_POINT *r, const EC_POINT *a, const EC_POINT *b, BN_CTX *);
245int EC_POINT_dbl(const EC_GROUP *, EC_POINT *r, const EC_POINT *a, BN_CTX *);
246int EC_POINT_invert(const EC_GROUP *, EC_POINT *, BN_CTX *);
247 553
248int EC_POINT_is_at_infinity(const EC_GROUP *, const EC_POINT *); 554/********************************************************************/
249int EC_POINT_is_on_curve(const EC_GROUP *, const EC_POINT *, BN_CTX *); 555/* functions for doing EC_POINT arithmetic */
250int EC_POINT_cmp(const EC_GROUP *, const EC_POINT *a, const EC_POINT *b, BN_CTX *); 556/********************************************************************/
557
558/** Computes the sum of two EC_POINT
559 * \param group underlying EC_GROUP object
560 * \param r EC_POINT object for the result (r = a + b)
561 * \param a EC_POINT object with the first summand
562 * \param b EC_POINT object with the second summand
563 * \param ctx BN_CTX object (optional)
564 * \return 1 on success and 0 if an error occured
565 */
566int EC_POINT_add(const EC_GROUP *group, EC_POINT *r, const EC_POINT *a, const EC_POINT *b, BN_CTX *ctx);
567
568/** Computes the double of a EC_POINT
569 * \param group underlying EC_GROUP object
570 * \param r EC_POINT object for the result (r = 2 * a)
571 * \param a EC_POINT object
572 * \param ctx BN_CTX object (optional)
573 * \return 1 on success and 0 if an error occured
574 */
575int EC_POINT_dbl(const EC_GROUP *group, EC_POINT *r, const EC_POINT *a, BN_CTX *ctx);
576
577/** Computes the inverse of a EC_POINT
578 * \param group underlying EC_GROUP object
579 * \param a EC_POINT object to be inverted (it's used for the result as well)
580 * \param ctx BN_CTX object (optional)
581 * \return 1 on success and 0 if an error occured
582 */
583int EC_POINT_invert(const EC_GROUP *group, EC_POINT *a, BN_CTX *ctx);
584
585/** Checks whether the point is the neutral element of the group
586 * \param group the underlying EC_GROUP object
587 * \param p EC_POINT object
588 * \return 1 if the point is the neutral element and 0 otherwise
589 */
590int EC_POINT_is_at_infinity(const EC_GROUP *group, const EC_POINT *p);
591
592/** Checks whether the point is on the curve
593 * \param group underlying EC_GROUP object
594 * \param point EC_POINT object to check
595 * \param ctx BN_CTX object (optional)
596 * \return 1 if point if on the curve and 0 otherwise
597 */
598int EC_POINT_is_on_curve(const EC_GROUP *group, const EC_POINT *point, BN_CTX *ctx);
599
600/** Compares two EC_POINTs
601 * \param group underlying EC_GROUP object
602 * \param a first EC_POINT object
603 * \param b second EC_POINT object
604 * \param ctx BN_CTX object (optional)
605 * \return 0 if both points are equal and a value != 0 otherwise
606 */
607int EC_POINT_cmp(const EC_GROUP *group, const EC_POINT *a, const EC_POINT *b, BN_CTX *ctx);
251 608
252int EC_POINT_make_affine(const EC_GROUP *, EC_POINT *, BN_CTX *); 609int EC_POINT_make_affine(const EC_GROUP *, EC_POINT *, BN_CTX *);
253int EC_POINTs_make_affine(const EC_GROUP *, size_t num, EC_POINT *[], BN_CTX *); 610int EC_POINTs_make_affine(const EC_GROUP *, size_t num, EC_POINT *[], BN_CTX *);
254 611
612/** Computes r = generator * n sum_{i=0}^num p[i] * m[i]
613 * \param group underlying EC_GROUP object
614 * \param r EC_POINT object for the result
615 * \param n BIGNUM with the multiplier for the group generator (optional)
616 * \param num number futher summands
617 * \param p array of size num of EC_POINT objects
618 * \param m array of size num of BIGNUM objects
619 * \param ctx BN_CTX object (optional)
620 * \return 1 on success and 0 if an error occured
621 */
622int EC_POINTs_mul(const EC_GROUP *group, EC_POINT *r, const BIGNUM *n, size_t num, const EC_POINT *p[], const BIGNUM *m[], BN_CTX *ctx);
623
624/** Computes r = generator * n + q * m
625 * \param group underlying EC_GROUP object
626 * \param r EC_POINT object for the result
627 * \param n BIGNUM with the multiplier for the group generator (optional)
628 * \param q EC_POINT object with the first factor of the second summand
629 * \param m BIGNUM with the second factor of the second summand
630 * \param ctx BN_CTX object (optional)
631 * \return 1 on success and 0 if an error occured
632 */
633int EC_POINT_mul(const EC_GROUP *group, EC_POINT *r, const BIGNUM *n, const EC_POINT *q, const BIGNUM *m, BN_CTX *ctx);
255 634
256int EC_POINTs_mul(const EC_GROUP *, EC_POINT *r, const BIGNUM *, size_t num, const EC_POINT *[], const BIGNUM *[], BN_CTX *); 635/** Stores multiples of generator for faster point multiplication
257int EC_POINT_mul(const EC_GROUP *, EC_POINT *r, const BIGNUM *, const EC_POINT *, const BIGNUM *, BN_CTX *); 636 * \param group EC_GROUP object
258 637 * \param ctx BN_CTX object (optional)
259/* EC_GROUP_precompute_mult() stores multiples of generator for faster point multiplication */ 638 * \return 1 on success and 0 if an error occured
260int EC_GROUP_precompute_mult(EC_GROUP *, BN_CTX *); 639 */
261/* EC_GROUP_have_precompute_mult() reports whether such precomputation has been done */ 640int EC_GROUP_precompute_mult(EC_GROUP *group, BN_CTX *ctx);
262int EC_GROUP_have_precompute_mult(const EC_GROUP *);
263 641
642/** Reports whether a precomputation has been done
643 * \param group EC_GROUP object
644 * \return 1 if a pre-computation has been done and 0 otherwise
645 */
646int EC_GROUP_have_precompute_mult(const EC_GROUP *group);
264 647
265 648
266/* ASN1 stuff */ 649/********************************************************************/
650/* ASN1 stuff */
651/********************************************************************/
267 652
268/* EC_GROUP_get_basis_type() returns the NID of the basis type 653/* EC_GROUP_get_basis_type() returns the NID of the basis type
269 * used to represent the field elements */ 654 * used to represent the field elements */
@@ -293,28 +678,96 @@ int ECPKParameters_print(BIO *bp, const EC_GROUP *x, int off);
293int ECPKParameters_print_fp(FILE *fp, const EC_GROUP *x, int off); 678int ECPKParameters_print_fp(FILE *fp, const EC_GROUP *x, int off);
294#endif 679#endif
295 680
296/* the EC_KEY stuff */ 681
682/********************************************************************/
683/* EC_KEY functions */
684/********************************************************************/
685
297typedef struct ec_key_st EC_KEY; 686typedef struct ec_key_st EC_KEY;
298 687
299/* some values for the encoding_flag */ 688/* some values for the encoding_flag */
300#define EC_PKEY_NO_PARAMETERS 0x001 689#define EC_PKEY_NO_PARAMETERS 0x001
301#define EC_PKEY_NO_PUBKEY 0x002 690#define EC_PKEY_NO_PUBKEY 0x002
302 691
692/** Creates a new EC_KEY object.
693 * \return EC_KEY object or NULL if an error occurred.
694 */
303EC_KEY *EC_KEY_new(void); 695EC_KEY *EC_KEY_new(void);
696
697/** Creates a new EC_KEY object using a named curve as underlying
698 * EC_GROUP object.
699 * \param nid NID of the named curve.
700 * \return EC_KEY object or NULL if an error occurred.
701 */
304EC_KEY *EC_KEY_new_by_curve_name(int nid); 702EC_KEY *EC_KEY_new_by_curve_name(int nid);
305void EC_KEY_free(EC_KEY *); 703
306EC_KEY *EC_KEY_copy(EC_KEY *, const EC_KEY *); 704/** Frees a EC_KEY object.
307EC_KEY *EC_KEY_dup(const EC_KEY *); 705 * \param key EC_KEY object to be freed.
308 706 */
309int EC_KEY_up_ref(EC_KEY *); 707void EC_KEY_free(EC_KEY *key);
310 708
311const EC_GROUP *EC_KEY_get0_group(const EC_KEY *); 709/** Copies a EC_KEY object.
312int EC_KEY_set_group(EC_KEY *, const EC_GROUP *); 710 * \param dst destination EC_KEY object
313const BIGNUM *EC_KEY_get0_private_key(const EC_KEY *); 711 * \param src src EC_KEY object
314int EC_KEY_set_private_key(EC_KEY *, const BIGNUM *); 712 * \return dst or NULL if an error occurred.
315const EC_POINT *EC_KEY_get0_public_key(const EC_KEY *); 713 */
316int EC_KEY_set_public_key(EC_KEY *, const EC_POINT *); 714EC_KEY *EC_KEY_copy(EC_KEY *dst, const EC_KEY *src);
317unsigned EC_KEY_get_enc_flags(const EC_KEY *); 715
716/** Creates a new EC_KEY object and copies the content from src to it.
717 * \param src the source EC_KEY object
718 * \return newly created EC_KEY object or NULL if an error occurred.
719 */
720EC_KEY *EC_KEY_dup(const EC_KEY *src);
721
722/** Increases the internal reference count of a EC_KEY object.
723 * \param key EC_KEY object
724 * \return 1 on success and 0 if an error occurred.
725 */
726int EC_KEY_up_ref(EC_KEY *key);
727
728/** Returns the EC_GROUP object of a EC_KEY object
729 * \param key EC_KEY object
730 * \return the EC_GROUP object (possibly NULL).
731 */
732const EC_GROUP *EC_KEY_get0_group(const EC_KEY *key);
733
734/** Sets the EC_GROUP of a EC_KEY object.
735 * \param key EC_KEY object
736 * \param group EC_GROUP to use in the EC_KEY object (note: the EC_KEY
737 * object will use an own copy of the EC_GROUP).
738 * \return 1 on success and 0 if an error occurred.
739 */
740int EC_KEY_set_group(EC_KEY *key, const EC_GROUP *group);
741
742/** Returns the private key of a EC_KEY object.
743 * \param key EC_KEY object
744 * \return a BIGNUM with the private key (possibly NULL).
745 */
746const BIGNUM *EC_KEY_get0_private_key(const EC_KEY *key);
747
748/** Sets the private key of a EC_KEY object.
749 * \param key EC_KEY object
750 * \param prv BIGNUM with the private key (note: the EC_KEY object
751 * will use an own copy of the BIGNUM).
752 * \return 1 on success and 0 if an error occurred.
753 */
754int EC_KEY_set_private_key(EC_KEY *key, const BIGNUM *prv);
755
756/** Returns the public key of a EC_KEY object.
757 * \param key the EC_KEY object
758 * \return a EC_POINT object with the public key (possibly NULL)
759 */
760const EC_POINT *EC_KEY_get0_public_key(const EC_KEY *key);
761
762/** Sets the public key of a EC_KEY object.
763 * \param key EC_KEY object
764 * \param pub EC_POINT object with the public key (note: the EC_KEY object
765 * will use an own copy of the EC_POINT object).
766 * \return 1 on success and 0 if an error occurred.
767 */
768int EC_KEY_set_public_key(EC_KEY *key, const EC_POINT *pub);
769
770unsigned EC_KEY_get_enc_flags(const EC_KEY *key);
318void EC_KEY_set_enc_flags(EC_KEY *, unsigned int); 771void EC_KEY_set_enc_flags(EC_KEY *, unsigned int);
319point_conversion_form_t EC_KEY_get_conv_form(const EC_KEY *); 772point_conversion_form_t EC_KEY_get_conv_form(const EC_KEY *);
320void EC_KEY_set_conv_form(EC_KEY *, point_conversion_form_t); 773void EC_KEY_set_conv_form(EC_KEY *, point_conversion_form_t);
@@ -325,31 +778,126 @@ void EC_KEY_insert_key_method_data(EC_KEY *, void *data,
325 void *(*dup_func)(void *), void (*free_func)(void *), void (*clear_free_func)(void *)); 778 void *(*dup_func)(void *), void (*free_func)(void *), void (*clear_free_func)(void *));
326/* wrapper functions for the underlying EC_GROUP object */ 779/* wrapper functions for the underlying EC_GROUP object */
327void EC_KEY_set_asn1_flag(EC_KEY *, int); 780void EC_KEY_set_asn1_flag(EC_KEY *, int);
328int EC_KEY_precompute_mult(EC_KEY *, BN_CTX *ctx); 781
329 782/** Creates a table of pre-computed multiples of the generator to
330/* EC_KEY_generate_key() creates a ec private (public) key */ 783 * accelerate further EC_KEY operations.
331int EC_KEY_generate_key(EC_KEY *); 784 * \param key EC_KEY object
332/* EC_KEY_check_key() */ 785 * \param ctx BN_CTX object (optional)
333int EC_KEY_check_key(const EC_KEY *); 786 * \return 1 on success and 0 if an error occurred.
334 787 */
335/* de- and encoding functions for SEC1 ECPrivateKey */ 788int EC_KEY_precompute_mult(EC_KEY *key, BN_CTX *ctx);
336EC_KEY *d2i_ECPrivateKey(EC_KEY **a, const unsigned char **in, long len); 789
337int i2d_ECPrivateKey(EC_KEY *a, unsigned char **out); 790/** Creates a new ec private (and optional a new public) key.
338/* de- and encoding functions for EC parameters */ 791 * \param key EC_KEY object
339EC_KEY *d2i_ECParameters(EC_KEY **a, const unsigned char **in, long len); 792 * \return 1 on success and 0 if an error occurred.
340int i2d_ECParameters(EC_KEY *a, unsigned char **out); 793 */
341/* de- and encoding functions for EC public key 794int EC_KEY_generate_key(EC_KEY *key);
342 * (octet string, not DER -- hence 'o2i' and 'i2o') */ 795
343EC_KEY *o2i_ECPublicKey(EC_KEY **a, const unsigned char **in, long len); 796/** Verifies that a private and/or public key is valid.
344int i2o_ECPublicKey(EC_KEY *a, unsigned char **out); 797 * \param key the EC_KEY object
798 * \return 1 on success and 0 otherwise.
799 */
800int EC_KEY_check_key(const EC_KEY *key);
801
802
803/********************************************************************/
804/* de- and encoding functions for SEC1 ECPrivateKey */
805/********************************************************************/
806
807/** Decodes a private key from a memory buffer.
808 * \param key a pointer to a EC_KEY object which should be used (or NULL)
809 * \param in pointer to memory with the DER encoded private key
810 * \param len length of the DER encoded private key
811 * \return the decoded private key or NULL if an error occurred.
812 */
813EC_KEY *d2i_ECPrivateKey(EC_KEY **key, const unsigned char **in, long len);
814
815/** Encodes a private key object and stores the result in a buffer.
816 * \param key the EC_KEY object to encode
817 * \param out the buffer for the result (if NULL the function returns number
818 * of bytes needed).
819 * \return 1 on success and 0 if an error occurred.
820 */
821int i2d_ECPrivateKey(EC_KEY *key, unsigned char **out);
822
823
824/********************************************************************/
825/* de- and encoding functions for EC parameters */
826/********************************************************************/
827
828/** Decodes ec parameter from a memory buffer.
829 * \param key a pointer to a EC_KEY object which should be used (or NULL)
830 * \param in pointer to memory with the DER encoded ec parameters
831 * \param len length of the DER encoded ec parameters
832 * \return a EC_KEY object with the decoded parameters or NULL if an error
833 * occurred.
834 */
835EC_KEY *d2i_ECParameters(EC_KEY **key, const unsigned char **in, long len);
836
837/** Encodes ec parameter and stores the result in a buffer.
838 * \param key the EC_KEY object with ec paramters to encode
839 * \param out the buffer for the result (if NULL the function returns number
840 * of bytes needed).
841 * \return 1 on success and 0 if an error occurred.
842 */
843int i2d_ECParameters(EC_KEY *key, unsigned char **out);
844
845
846/********************************************************************/
847/* de- and encoding functions for EC public key */
848/* (octet string, not DER -- hence 'o2i' and 'i2o') */
849/********************************************************************/
850
851/** Decodes a ec public key from a octet string.
852 * \param key a pointer to a EC_KEY object which should be used
853 * \param in memory buffer with the encoded public key
854 * \param len length of the encoded public key
855 * \return EC_KEY object with decoded public key or NULL if an error
856 * occurred.
857 */
858EC_KEY *o2i_ECPublicKey(EC_KEY **key, const unsigned char **in, long len);
859
860/** Encodes a ec public key in an octet string.
861 * \param key the EC_KEY object with the public key
862 * \param out the buffer for the result (if NULL the function returns number
863 * of bytes needed).
864 * \return 1 on success and 0 if an error occurred
865 */
866int i2o_ECPublicKey(EC_KEY *key, unsigned char **out);
345 867
346#ifndef OPENSSL_NO_BIO 868#ifndef OPENSSL_NO_BIO
347int ECParameters_print(BIO *bp, const EC_KEY *x); 869/** Prints out the ec parameters on human readable form.
348int EC_KEY_print(BIO *bp, const EC_KEY *x, int off); 870 * \param bp BIO object to which the information is printed
871 * \param key EC_KEY object
872 * \return 1 on success and 0 if an error occurred
873 */
874int ECParameters_print(BIO *bp, const EC_KEY *key);
875
876/** Prints out the contents of a EC_KEY object
877 * \param bp BIO object to which the information is printed
878 * \param key EC_KEY object
879 * \param off line offset
880 * \return 1 on success and 0 if an error occurred
881 */
882int EC_KEY_print(BIO *bp, const EC_KEY *key, int off);
883
349#endif 884#endif
350#ifndef OPENSSL_NO_FP_API 885#ifndef OPENSSL_NO_FP_API
351int ECParameters_print_fp(FILE *fp, const EC_KEY *x); 886/** Prints out the ec parameters on human readable form.
352int EC_KEY_print_fp(FILE *fp, const EC_KEY *x, int off); 887 * \param fp file descriptor to which the information is printed
888 * \param key EC_KEY object
889 * \return 1 on success and 0 if an error occurred
890 */
891int ECParameters_print_fp(FILE *fp, const EC_KEY *key);
892
893/** Prints out the contents of a EC_KEY object
894 * \param fp file descriptor to which the information is printed
895 * \param key EC_KEY object
896 * \param off line offset
897 * \return 1 on success and 0 if an error occurred
898 */
899int EC_KEY_print_fp(FILE *fp, const EC_KEY *key, int off);
900
353#endif 901#endif
354 902
355#define ECParameters_dup(x) ASN1_dup_of(EC_KEY,i2d_ECParameters,d2i_ECParameters,x) 903#define ECParameters_dup(x) ASN1_dup_of(EC_KEY,i2d_ECParameters,d2i_ECParameters,x)
@@ -362,6 +910,13 @@ int EC_KEY_print_fp(FILE *fp, const EC_KEY *x, int off);
362# endif 910# endif
363#endif 911#endif
364 912
913#define EVP_PKEY_CTX_set_ec_paramgen_curve_nid(ctx, nid) \
914 EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_EC, EVP_PKEY_OP_PARAMGEN, \
915 EVP_PKEY_CTRL_EC_PARAMGEN_CURVE_NID, nid, NULL)
916
917
918#define EVP_PKEY_CTRL_EC_PARAMGEN_CURVE_NID (EVP_PKEY_ALG_CTRL + 1)
919
365/* BEGIN ERROR CODES */ 920/* BEGIN ERROR CODES */
366/* The following lines are auto generated by the script mkerr.pl. Any changes 921/* The following lines are auto generated by the script mkerr.pl. Any changes
367 * made after this point may be overwritten when the script is next run. 922 * made after this point may be overwritten when the script is next run.
@@ -375,6 +930,14 @@ void ERR_load_EC_strings(void);
375#define EC_F_D2I_ECPARAMETERS 144 930#define EC_F_D2I_ECPARAMETERS 144
376#define EC_F_D2I_ECPKPARAMETERS 145 931#define EC_F_D2I_ECPKPARAMETERS 145
377#define EC_F_D2I_ECPRIVATEKEY 146 932#define EC_F_D2I_ECPRIVATEKEY 146
933#define EC_F_DO_EC_KEY_PRINT 221
934#define EC_F_ECKEY_PARAM2TYPE 223
935#define EC_F_ECKEY_PARAM_DECODE 212
936#define EC_F_ECKEY_PRIV_DECODE 213
937#define EC_F_ECKEY_PRIV_ENCODE 214
938#define EC_F_ECKEY_PUB_DECODE 215
939#define EC_F_ECKEY_PUB_ENCODE 216
940#define EC_F_ECKEY_TYPE2PARAM 220
378#define EC_F_ECPARAMETERS_PRINT 147 941#define EC_F_ECPARAMETERS_PRINT 147
379#define EC_F_ECPARAMETERS_PRINT_FP 148 942#define EC_F_ECPARAMETERS_PRINT_FP 148
380#define EC_F_ECPKPARAMETERS_PRINT 149 943#define EC_F_ECPKPARAMETERS_PRINT 149
@@ -448,7 +1011,6 @@ void ERR_load_EC_strings(void);
448#define EC_F_EC_KEY_PRINT 180 1011#define EC_F_EC_KEY_PRINT 180
449#define EC_F_EC_KEY_PRINT_FP 181 1012#define EC_F_EC_KEY_PRINT_FP 181
450#define EC_F_EC_POINTS_MAKE_AFFINE 136 1013#define EC_F_EC_POINTS_MAKE_AFFINE 136
451#define EC_F_EC_POINTS_MUL 138
452#define EC_F_EC_POINT_ADD 112 1014#define EC_F_EC_POINT_ADD 112
453#define EC_F_EC_POINT_CMP 113 1015#define EC_F_EC_POINT_CMP 113
454#define EC_F_EC_POINT_COPY 114 1016#define EC_F_EC_POINT_COPY 114
@@ -479,21 +1041,31 @@ void ERR_load_EC_strings(void);
479#define EC_F_I2D_ECPRIVATEKEY 192 1041#define EC_F_I2D_ECPRIVATEKEY 192
480#define EC_F_I2O_ECPUBLICKEY 151 1042#define EC_F_I2O_ECPUBLICKEY 151
481#define EC_F_O2I_ECPUBLICKEY 152 1043#define EC_F_O2I_ECPUBLICKEY 152
1044#define EC_F_OLD_EC_PRIV_DECODE 222
1045#define EC_F_PKEY_EC_CTRL 197
1046#define EC_F_PKEY_EC_CTRL_STR 198
1047#define EC_F_PKEY_EC_DERIVE 217
1048#define EC_F_PKEY_EC_KEYGEN 199
1049#define EC_F_PKEY_EC_PARAMGEN 219
1050#define EC_F_PKEY_EC_SIGN 218
482 1051
483/* Reason codes. */ 1052/* Reason codes. */
484#define EC_R_ASN1_ERROR 115 1053#define EC_R_ASN1_ERROR 115
485#define EC_R_ASN1_UNKNOWN_FIELD 116 1054#define EC_R_ASN1_UNKNOWN_FIELD 116
486#define EC_R_BUFFER_TOO_SMALL 100 1055#define EC_R_BUFFER_TOO_SMALL 100
487#define EC_R_D2I_ECPKPARAMETERS_FAILURE 117 1056#define EC_R_D2I_ECPKPARAMETERS_FAILURE 117
1057#define EC_R_DECODE_ERROR 142
488#define EC_R_DISCRIMINANT_IS_ZERO 118 1058#define EC_R_DISCRIMINANT_IS_ZERO 118
489#define EC_R_EC_GROUP_NEW_BY_NAME_FAILURE 119 1059#define EC_R_EC_GROUP_NEW_BY_NAME_FAILURE 119
490#define EC_R_FIELD_TOO_LARGE 138 1060#define EC_R_FIELD_TOO_LARGE 143
491#define EC_R_GROUP2PKPARAMETERS_FAILURE 120 1061#define EC_R_GROUP2PKPARAMETERS_FAILURE 120
492#define EC_R_I2D_ECPKPARAMETERS_FAILURE 121 1062#define EC_R_I2D_ECPKPARAMETERS_FAILURE 121
493#define EC_R_INCOMPATIBLE_OBJECTS 101 1063#define EC_R_INCOMPATIBLE_OBJECTS 101
494#define EC_R_INVALID_ARGUMENT 112 1064#define EC_R_INVALID_ARGUMENT 112
495#define EC_R_INVALID_COMPRESSED_POINT 110 1065#define EC_R_INVALID_COMPRESSED_POINT 110
496#define EC_R_INVALID_COMPRESSION_BIT 109 1066#define EC_R_INVALID_COMPRESSION_BIT 109
1067#define EC_R_INVALID_CURVE 141
1068#define EC_R_INVALID_DIGEST_TYPE 138
497#define EC_R_INVALID_ENCODING 102 1069#define EC_R_INVALID_ENCODING 102
498#define EC_R_INVALID_FIELD 103 1070#define EC_R_INVALID_FIELD 103
499#define EC_R_INVALID_FORM 104 1071#define EC_R_INVALID_FORM 104
@@ -501,6 +1073,7 @@ void ERR_load_EC_strings(void);
501#define EC_R_INVALID_PENTANOMIAL_BASIS 132 1073#define EC_R_INVALID_PENTANOMIAL_BASIS 132
502#define EC_R_INVALID_PRIVATE_KEY 123 1074#define EC_R_INVALID_PRIVATE_KEY 123
503#define EC_R_INVALID_TRINOMIAL_BASIS 137 1075#define EC_R_INVALID_TRINOMIAL_BASIS 137
1076#define EC_R_KEYS_NOT_SET 140
504#define EC_R_MISSING_PARAMETERS 124 1077#define EC_R_MISSING_PARAMETERS 124
505#define EC_R_MISSING_PRIVATE_KEY 125 1078#define EC_R_MISSING_PRIVATE_KEY 125
506#define EC_R_NOT_A_NIST_PRIME 135 1079#define EC_R_NOT_A_NIST_PRIME 135
@@ -508,6 +1081,7 @@ void ERR_load_EC_strings(void);
508#define EC_R_NOT_IMPLEMENTED 126 1081#define EC_R_NOT_IMPLEMENTED 126
509#define EC_R_NOT_INITIALIZED 111 1082#define EC_R_NOT_INITIALIZED 111
510#define EC_R_NO_FIELD_MOD 133 1083#define EC_R_NO_FIELD_MOD 133
1084#define EC_R_NO_PARAMETERS_SET 139
511#define EC_R_PASSED_NULL_PARAMETER 134 1085#define EC_R_PASSED_NULL_PARAMETER 134
512#define EC_R_PKPARAMETERS2GROUP_FAILURE 127 1086#define EC_R_PKPARAMETERS2GROUP_FAILURE 127
513#define EC_R_POINT_AT_INFINITY 106 1087#define EC_R_POINT_AT_INFINITY 106
diff --git a/src/lib/libcrypto/ec/ec2_smpl.c b/src/lib/libcrypto/ec/ec2_smpl.c
index 522d036ca1..cf357b462a 100644
--- a/src/lib/libcrypto/ec/ec2_smpl.c
+++ b/src/lib/libcrypto/ec/ec2_smpl.c
@@ -14,7 +14,7 @@
14 * 14 *
15 */ 15 */
16/* ==================================================================== 16/* ====================================================================
17 * Copyright (c) 1998-2003 The OpenSSL Project. All rights reserved. 17 * Copyright (c) 1998-2005 The OpenSSL Project. All rights reserved.
18 * 18 *
19 * Redistribution and use in source and binary forms, with or without 19 * Redistribution and use in source and binary forms, with or without
20 * modification, are permitted provided that the following conditions 20 * modification, are permitted provided that the following conditions
@@ -157,6 +157,7 @@ void ec_GF2m_simple_group_clear_finish(EC_GROUP *group)
157 group->poly[2] = 0; 157 group->poly[2] = 0;
158 group->poly[3] = 0; 158 group->poly[3] = 0;
159 group->poly[4] = 0; 159 group->poly[4] = 0;
160 group->poly[5] = -1;
160 } 161 }
161 162
162 163
@@ -174,10 +175,9 @@ int ec_GF2m_simple_group_copy(EC_GROUP *dest, const EC_GROUP *src)
174 dest->poly[2] = src->poly[2]; 175 dest->poly[2] = src->poly[2];
175 dest->poly[3] = src->poly[3]; 176 dest->poly[3] = src->poly[3];
176 dest->poly[4] = src->poly[4]; 177 dest->poly[4] = src->poly[4];
177 if(bn_wexpand(&dest->a, (int)(dest->poly[0] + BN_BITS2 - 1) / BN_BITS2) == NULL) 178 dest->poly[5] = src->poly[5];
178 return 0; 179 if (bn_wexpand(&dest->a, (int)(dest->poly[0] + BN_BITS2 - 1) / BN_BITS2) == NULL) return 0;
179 if(bn_wexpand(&dest->b, (int)(dest->poly[0] + BN_BITS2 - 1) / BN_BITS2) == NULL) 180 if (bn_wexpand(&dest->b, (int)(dest->poly[0] + BN_BITS2 - 1) / BN_BITS2) == NULL) return 0;
180 return 0;
181 for (i = dest->a.top; i < dest->a.dmax; i++) dest->a.d[i] = 0; 181 for (i = dest->a.top; i < dest->a.dmax; i++) dest->a.d[i] = 0;
182 for (i = dest->b.top; i < dest->b.dmax; i++) dest->b.d[i] = 0; 182 for (i = dest->b.top; i < dest->b.dmax; i++) dest->b.d[i] = 0;
183 return 1; 183 return 1;
@@ -192,7 +192,7 @@ int ec_GF2m_simple_group_set_curve(EC_GROUP *group,
192 192
193 /* group->field */ 193 /* group->field */
194 if (!BN_copy(&group->field, p)) goto err; 194 if (!BN_copy(&group->field, p)) goto err;
195 i = BN_GF2m_poly2arr(&group->field, group->poly, 5); 195 i = BN_GF2m_poly2arr(&group->field, group->poly, 6) - 1;
196 if ((i != 5) && (i != 3)) 196 if ((i != 5) && (i != 3))
197 { 197 {
198 ECerr(EC_F_EC_GF2M_SIMPLE_GROUP_SET_CURVE, EC_R_UNSUPPORTED_FIELD); 198 ECerr(EC_F_EC_GF2M_SIMPLE_GROUP_SET_CURVE, EC_R_UNSUPPORTED_FIELD);
@@ -406,18 +406,94 @@ int ec_GF2m_simple_point_get_affine_coordinates(const EC_GROUP *group, const EC_
406 } 406 }
407 407
408 408
409/* Include patented algorithms. */ 409/* Calculates and sets the affine coordinates of an EC_POINT from the given
410#include "ec2_smpt.c" 410 * compressed coordinates. Uses algorithm 2.3.4 of SEC 1.
411 * Note that the simple implementation only uses affine coordinates.
412 *
413 * The method is from the following publication:
414 *
415 * Harper, Menezes, Vanstone:
416 * "Public-Key Cryptosystems with Very Small Key Lengths",
417 * EUROCRYPT '92, Springer-Verlag LNCS 658,
418 * published February 1993
419 *
420 * US Patents 6,141,420 and 6,618,483 (Vanstone, Mullin, Agnew) describe
421 * the same method, but claim no priority date earlier than July 29, 1994
422 * (and additionally fail to cite the EUROCRYPT '92 publication as prior art).
423 */
424int ec_GF2m_simple_set_compressed_coordinates(const EC_GROUP *group, EC_POINT *point,
425 const BIGNUM *x_, int y_bit, BN_CTX *ctx)
426 {
427 BN_CTX *new_ctx = NULL;
428 BIGNUM *tmp, *x, *y, *z;
429 int ret = 0, z0;
430
431 /* clear error queue */
432 ERR_clear_error();
433
434 if (ctx == NULL)
435 {
436 ctx = new_ctx = BN_CTX_new();
437 if (ctx == NULL)
438 return 0;
439 }
440
441 y_bit = (y_bit != 0) ? 1 : 0;
442
443 BN_CTX_start(ctx);
444 tmp = BN_CTX_get(ctx);
445 x = BN_CTX_get(ctx);
446 y = BN_CTX_get(ctx);
447 z = BN_CTX_get(ctx);
448 if (z == NULL) goto err;
449
450 if (!BN_GF2m_mod_arr(x, x_, group->poly)) goto err;
451 if (BN_is_zero(x))
452 {
453 if (!BN_GF2m_mod_sqrt_arr(y, &group->b, group->poly, ctx)) goto err;
454 }
455 else
456 {
457 if (!group->meth->field_sqr(group, tmp, x, ctx)) goto err;
458 if (!group->meth->field_div(group, tmp, &group->b, tmp, ctx)) goto err;
459 if (!BN_GF2m_add(tmp, &group->a, tmp)) goto err;
460 if (!BN_GF2m_add(tmp, x, tmp)) goto err;
461 if (!BN_GF2m_mod_solve_quad_arr(z, tmp, group->poly, ctx))
462 {
463 unsigned long err = ERR_peek_last_error();
464
465 if (ERR_GET_LIB(err) == ERR_LIB_BN && ERR_GET_REASON(err) == BN_R_NO_SOLUTION)
466 {
467 ERR_clear_error();
468 ECerr(EC_F_EC_GF2M_SIMPLE_SET_COMPRESSED_COORDINATES, EC_R_INVALID_COMPRESSED_POINT);
469 }
470 else
471 ECerr(EC_F_EC_GF2M_SIMPLE_SET_COMPRESSED_COORDINATES, ERR_R_BN_LIB);
472 goto err;
473 }
474 z0 = (BN_is_odd(z)) ? 1 : 0;
475 if (!group->meth->field_mul(group, y, x, z, ctx)) goto err;
476 if (z0 != y_bit)
477 {
478 if (!BN_GF2m_add(y, y, x)) goto err;
479 }
480 }
481
482 if (!EC_POINT_set_affine_coordinates_GF2m(group, point, x, y, ctx)) goto err;
483
484 ret = 1;
485
486 err:
487 BN_CTX_end(ctx);
488 if (new_ctx != NULL)
489 BN_CTX_free(new_ctx);
490 return ret;
491 }
411 492
412 493
413/* Converts an EC_POINT to an octet string. 494/* Converts an EC_POINT to an octet string.
414 * If buf is NULL, the encoded length will be returned. 495 * If buf is NULL, the encoded length will be returned.
415 * If the length len of buf is smaller than required an error will be returned. 496 * If the length len of buf is smaller than required an error will be returned.
416 *
417 * The point compression section of this function is patented by Certicom Corp.
418 * under US Patent 6,141,420. Point compression is disabled by default and can
419 * be enabled by defining the preprocessor macro OPENSSL_EC_BIN_PT_COMP at
420 * Configure-time.
421 */ 497 */
422size_t ec_GF2m_simple_point2oct(const EC_GROUP *group, const EC_POINT *point, point_conversion_form_t form, 498size_t ec_GF2m_simple_point2oct(const EC_GROUP *group, const EC_POINT *point, point_conversion_form_t form,
423 unsigned char *buf, size_t len, BN_CTX *ctx) 499 unsigned char *buf, size_t len, BN_CTX *ctx)
@@ -428,14 +504,6 @@ size_t ec_GF2m_simple_point2oct(const EC_GROUP *group, const EC_POINT *point, po
428 BIGNUM *x, *y, *yxi; 504 BIGNUM *x, *y, *yxi;
429 size_t field_len, i, skip; 505 size_t field_len, i, skip;
430 506
431#ifndef OPENSSL_EC_BIN_PT_COMP
432 if ((form == POINT_CONVERSION_COMPRESSED) || (form == POINT_CONVERSION_HYBRID))
433 {
434 ECerr(EC_F_EC_GF2M_SIMPLE_POINT2OCT, ERR_R_DISABLED);
435 goto err;
436 }
437#endif
438
439 if ((form != POINT_CONVERSION_COMPRESSED) 507 if ((form != POINT_CONVERSION_COMPRESSED)
440 && (form != POINT_CONVERSION_UNCOMPRESSED) 508 && (form != POINT_CONVERSION_UNCOMPRESSED)
441 && (form != POINT_CONVERSION_HYBRID)) 509 && (form != POINT_CONVERSION_HYBRID))
@@ -490,13 +558,11 @@ size_t ec_GF2m_simple_point2oct(const EC_GROUP *group, const EC_POINT *point, po
490 if (!EC_POINT_get_affine_coordinates_GF2m(group, point, x, y, ctx)) goto err; 558 if (!EC_POINT_get_affine_coordinates_GF2m(group, point, x, y, ctx)) goto err;
491 559
492 buf[0] = form; 560 buf[0] = form;
493#ifdef OPENSSL_EC_BIN_PT_COMP
494 if ((form != POINT_CONVERSION_UNCOMPRESSED) && !BN_is_zero(x)) 561 if ((form != POINT_CONVERSION_UNCOMPRESSED) && !BN_is_zero(x))
495 { 562 {
496 if (!group->meth->field_div(group, yxi, y, x, ctx)) goto err; 563 if (!group->meth->field_div(group, yxi, y, x, ctx)) goto err;
497 if (BN_is_odd(yxi)) buf[0]++; 564 if (BN_is_odd(yxi)) buf[0]++;
498 } 565 }
499#endif
500 566
501 i = 1; 567 i = 1;
502 568
diff --git a/src/lib/libcrypto/ec/ec2_smpt.c b/src/lib/libcrypto/ec/ec2_smpt.c
deleted file mode 100644
index 59d52bf663..0000000000
--- a/src/lib/libcrypto/ec/ec2_smpt.c
+++ /dev/null
@@ -1,74 +0,0 @@
1/* crypto/ec/ec2_smpt.c */
2/* This code was originally written by Douglas Stebila
3 * <dstebila@student.math.uwaterloo.ca> for the OpenSSL project.
4 */
5/* ====================================================================
6 * Copyright (c) 1998-2002 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
60/* Calaculates and sets the affine coordinates of an EC_POINT from the given
61 * compressed coordinates. Uses algorithm 2.3.4 of SEC 1.
62 * Note that the simple implementation only uses affine coordinates.
63 *
64 * This algorithm is patented by Certicom Corp. under US Patent 6,141,420
65 * (for licensing information, contact licensing@certicom.com).
66 * This function is disabled by default and can be enabled by defining the
67 * preprocessor macro OPENSSL_EC_BIN_PT_COMP at Configure-time.
68 */
69int ec_GF2m_simple_set_compressed_coordinates(const EC_GROUP *group, EC_POINT *point,
70 const BIGNUM *x_, int y_bit, BN_CTX *ctx)
71 {
72 ECerr(EC_F_EC_GF2M_SIMPLE_SET_COMPRESSED_COORDINATES, ERR_R_DISABLED);
73 return 0;
74 }
diff --git a/src/lib/libcrypto/ec/ec_err.c b/src/lib/libcrypto/ec/ec_err.c
index d04c895560..84b4833371 100644
--- a/src/lib/libcrypto/ec/ec_err.c
+++ b/src/lib/libcrypto/ec/ec_err.c
@@ -74,6 +74,14 @@ static ERR_STRING_DATA EC_str_functs[]=
74{ERR_FUNC(EC_F_D2I_ECPARAMETERS), "d2i_ECParameters"}, 74{ERR_FUNC(EC_F_D2I_ECPARAMETERS), "d2i_ECParameters"},
75{ERR_FUNC(EC_F_D2I_ECPKPARAMETERS), "d2i_ECPKParameters"}, 75{ERR_FUNC(EC_F_D2I_ECPKPARAMETERS), "d2i_ECPKParameters"},
76{ERR_FUNC(EC_F_D2I_ECPRIVATEKEY), "d2i_ECPrivateKey"}, 76{ERR_FUNC(EC_F_D2I_ECPRIVATEKEY), "d2i_ECPrivateKey"},
77{ERR_FUNC(EC_F_DO_EC_KEY_PRINT), "DO_EC_KEY_PRINT"},
78{ERR_FUNC(EC_F_ECKEY_PARAM2TYPE), "ECKEY_PARAM2TYPE"},
79{ERR_FUNC(EC_F_ECKEY_PARAM_DECODE), "ECKEY_PARAM_DECODE"},
80{ERR_FUNC(EC_F_ECKEY_PRIV_DECODE), "ECKEY_PRIV_DECODE"},
81{ERR_FUNC(EC_F_ECKEY_PRIV_ENCODE), "ECKEY_PRIV_ENCODE"},
82{ERR_FUNC(EC_F_ECKEY_PUB_DECODE), "ECKEY_PUB_DECODE"},
83{ERR_FUNC(EC_F_ECKEY_PUB_ENCODE), "ECKEY_PUB_ENCODE"},
84{ERR_FUNC(EC_F_ECKEY_TYPE2PARAM), "ECKEY_TYPE2PARAM"},
77{ERR_FUNC(EC_F_ECPARAMETERS_PRINT), "ECParameters_print"}, 85{ERR_FUNC(EC_F_ECPARAMETERS_PRINT), "ECParameters_print"},
78{ERR_FUNC(EC_F_ECPARAMETERS_PRINT_FP), "ECParameters_print_fp"}, 86{ERR_FUNC(EC_F_ECPARAMETERS_PRINT_FP), "ECParameters_print_fp"},
79{ERR_FUNC(EC_F_ECPKPARAMETERS_PRINT), "ECPKParameters_print"}, 87{ERR_FUNC(EC_F_ECPKPARAMETERS_PRINT), "ECPKParameters_print"},
@@ -147,7 +155,6 @@ static ERR_STRING_DATA EC_str_functs[]=
147{ERR_FUNC(EC_F_EC_KEY_PRINT), "EC_KEY_print"}, 155{ERR_FUNC(EC_F_EC_KEY_PRINT), "EC_KEY_print"},
148{ERR_FUNC(EC_F_EC_KEY_PRINT_FP), "EC_KEY_print_fp"}, 156{ERR_FUNC(EC_F_EC_KEY_PRINT_FP), "EC_KEY_print_fp"},
149{ERR_FUNC(EC_F_EC_POINTS_MAKE_AFFINE), "EC_POINTs_make_affine"}, 157{ERR_FUNC(EC_F_EC_POINTS_MAKE_AFFINE), "EC_POINTs_make_affine"},
150{ERR_FUNC(EC_F_EC_POINTS_MUL), "EC_POINTs_mul"},
151{ERR_FUNC(EC_F_EC_POINT_ADD), "EC_POINT_add"}, 158{ERR_FUNC(EC_F_EC_POINT_ADD), "EC_POINT_add"},
152{ERR_FUNC(EC_F_EC_POINT_CMP), "EC_POINT_cmp"}, 159{ERR_FUNC(EC_F_EC_POINT_CMP), "EC_POINT_cmp"},
153{ERR_FUNC(EC_F_EC_POINT_COPY), "EC_POINT_copy"}, 160{ERR_FUNC(EC_F_EC_POINT_COPY), "EC_POINT_copy"},
@@ -178,6 +185,13 @@ static ERR_STRING_DATA EC_str_functs[]=
178{ERR_FUNC(EC_F_I2D_ECPRIVATEKEY), "i2d_ECPrivateKey"}, 185{ERR_FUNC(EC_F_I2D_ECPRIVATEKEY), "i2d_ECPrivateKey"},
179{ERR_FUNC(EC_F_I2O_ECPUBLICKEY), "i2o_ECPublicKey"}, 186{ERR_FUNC(EC_F_I2O_ECPUBLICKEY), "i2o_ECPublicKey"},
180{ERR_FUNC(EC_F_O2I_ECPUBLICKEY), "o2i_ECPublicKey"}, 187{ERR_FUNC(EC_F_O2I_ECPUBLICKEY), "o2i_ECPublicKey"},
188{ERR_FUNC(EC_F_OLD_EC_PRIV_DECODE), "OLD_EC_PRIV_DECODE"},
189{ERR_FUNC(EC_F_PKEY_EC_CTRL), "PKEY_EC_CTRL"},
190{ERR_FUNC(EC_F_PKEY_EC_CTRL_STR), "PKEY_EC_CTRL_STR"},
191{ERR_FUNC(EC_F_PKEY_EC_DERIVE), "PKEY_EC_DERIVE"},
192{ERR_FUNC(EC_F_PKEY_EC_KEYGEN), "PKEY_EC_KEYGEN"},
193{ERR_FUNC(EC_F_PKEY_EC_PARAMGEN), "PKEY_EC_PARAMGEN"},
194{ERR_FUNC(EC_F_PKEY_EC_SIGN), "PKEY_EC_SIGN"},
181{0,NULL} 195{0,NULL}
182 }; 196 };
183 197
@@ -187,6 +201,7 @@ static ERR_STRING_DATA EC_str_reasons[]=
187{ERR_REASON(EC_R_ASN1_UNKNOWN_FIELD) ,"asn1 unknown field"}, 201{ERR_REASON(EC_R_ASN1_UNKNOWN_FIELD) ,"asn1 unknown field"},
188{ERR_REASON(EC_R_BUFFER_TOO_SMALL) ,"buffer too small"}, 202{ERR_REASON(EC_R_BUFFER_TOO_SMALL) ,"buffer too small"},
189{ERR_REASON(EC_R_D2I_ECPKPARAMETERS_FAILURE),"d2i ecpkparameters failure"}, 203{ERR_REASON(EC_R_D2I_ECPKPARAMETERS_FAILURE),"d2i ecpkparameters failure"},
204{ERR_REASON(EC_R_DECODE_ERROR) ,"decode error"},
190{ERR_REASON(EC_R_DISCRIMINANT_IS_ZERO) ,"discriminant is zero"}, 205{ERR_REASON(EC_R_DISCRIMINANT_IS_ZERO) ,"discriminant is zero"},
191{ERR_REASON(EC_R_EC_GROUP_NEW_BY_NAME_FAILURE),"ec group new by name failure"}, 206{ERR_REASON(EC_R_EC_GROUP_NEW_BY_NAME_FAILURE),"ec group new by name failure"},
192{ERR_REASON(EC_R_FIELD_TOO_LARGE) ,"field too large"}, 207{ERR_REASON(EC_R_FIELD_TOO_LARGE) ,"field too large"},
@@ -196,6 +211,8 @@ static ERR_STRING_DATA EC_str_reasons[]=
196{ERR_REASON(EC_R_INVALID_ARGUMENT) ,"invalid argument"}, 211{ERR_REASON(EC_R_INVALID_ARGUMENT) ,"invalid argument"},
197{ERR_REASON(EC_R_INVALID_COMPRESSED_POINT),"invalid compressed point"}, 212{ERR_REASON(EC_R_INVALID_COMPRESSED_POINT),"invalid compressed point"},
198{ERR_REASON(EC_R_INVALID_COMPRESSION_BIT),"invalid compression bit"}, 213{ERR_REASON(EC_R_INVALID_COMPRESSION_BIT),"invalid compression bit"},
214{ERR_REASON(EC_R_INVALID_CURVE) ,"invalid curve"},
215{ERR_REASON(EC_R_INVALID_DIGEST_TYPE) ,"invalid digest type"},
199{ERR_REASON(EC_R_INVALID_ENCODING) ,"invalid encoding"}, 216{ERR_REASON(EC_R_INVALID_ENCODING) ,"invalid encoding"},
200{ERR_REASON(EC_R_INVALID_FIELD) ,"invalid field"}, 217{ERR_REASON(EC_R_INVALID_FIELD) ,"invalid field"},
201{ERR_REASON(EC_R_INVALID_FORM) ,"invalid form"}, 218{ERR_REASON(EC_R_INVALID_FORM) ,"invalid form"},
@@ -203,6 +220,7 @@ static ERR_STRING_DATA EC_str_reasons[]=
203{ERR_REASON(EC_R_INVALID_PENTANOMIAL_BASIS),"invalid pentanomial basis"}, 220{ERR_REASON(EC_R_INVALID_PENTANOMIAL_BASIS),"invalid pentanomial basis"},
204{ERR_REASON(EC_R_INVALID_PRIVATE_KEY) ,"invalid private key"}, 221{ERR_REASON(EC_R_INVALID_PRIVATE_KEY) ,"invalid private key"},
205{ERR_REASON(EC_R_INVALID_TRINOMIAL_BASIS),"invalid trinomial basis"}, 222{ERR_REASON(EC_R_INVALID_TRINOMIAL_BASIS),"invalid trinomial basis"},
223{ERR_REASON(EC_R_KEYS_NOT_SET) ,"keys not set"},
206{ERR_REASON(EC_R_MISSING_PARAMETERS) ,"missing parameters"}, 224{ERR_REASON(EC_R_MISSING_PARAMETERS) ,"missing parameters"},
207{ERR_REASON(EC_R_MISSING_PRIVATE_KEY) ,"missing private key"}, 225{ERR_REASON(EC_R_MISSING_PRIVATE_KEY) ,"missing private key"},
208{ERR_REASON(EC_R_NOT_A_NIST_PRIME) ,"not a NIST prime"}, 226{ERR_REASON(EC_R_NOT_A_NIST_PRIME) ,"not a NIST prime"},
@@ -210,6 +228,7 @@ static ERR_STRING_DATA EC_str_reasons[]=
210{ERR_REASON(EC_R_NOT_IMPLEMENTED) ,"not implemented"}, 228{ERR_REASON(EC_R_NOT_IMPLEMENTED) ,"not implemented"},
211{ERR_REASON(EC_R_NOT_INITIALIZED) ,"not initialized"}, 229{ERR_REASON(EC_R_NOT_INITIALIZED) ,"not initialized"},
212{ERR_REASON(EC_R_NO_FIELD_MOD) ,"no field mod"}, 230{ERR_REASON(EC_R_NO_FIELD_MOD) ,"no field mod"},
231{ERR_REASON(EC_R_NO_PARAMETERS_SET) ,"no parameters set"},
213{ERR_REASON(EC_R_PASSED_NULL_PARAMETER) ,"passed null parameter"}, 232{ERR_REASON(EC_R_PASSED_NULL_PARAMETER) ,"passed null parameter"},
214{ERR_REASON(EC_R_PKPARAMETERS2GROUP_FAILURE),"pkparameters2group failure"}, 233{ERR_REASON(EC_R_PKPARAMETERS2GROUP_FAILURE),"pkparameters2group failure"},
215{ERR_REASON(EC_R_POINT_AT_INFINITY) ,"point at infinity"}, 234{ERR_REASON(EC_R_POINT_AT_INFINITY) ,"point at infinity"},
diff --git a/src/lib/libcrypto/ec/ec_lcl.h b/src/lib/libcrypto/ec/ec_lcl.h
index fdd7aa2755..3e2c34b0bc 100644
--- a/src/lib/libcrypto/ec/ec_lcl.h
+++ b/src/lib/libcrypto/ec/ec_lcl.h
@@ -205,11 +205,14 @@ struct ec_group_st {
205 * irreducible polynomial defining the field. 205 * irreducible polynomial defining the field.
206 */ 206 */
207 207
208 unsigned int poly[5]; /* Field specification for curves over GF(2^m). 208 int poly[6]; /* Field specification for curves over GF(2^m).
209 * The irreducible f(t) is then of the form: 209 * The irreducible f(t) is then of the form:
210 * t^poly[0] + t^poly[1] + ... + t^poly[k] 210 * t^poly[0] + t^poly[1] + ... + t^poly[k]
211 * where m = poly[0] > poly[1] > ... > poly[k] = 0. 211 * where m = poly[0] > poly[1] > ... > poly[k] = 0.
212 */ 212 * The array is terminated with poly[k+1]=-1.
213 * All elliptic curve irreducibles have at most 5
214 * non-zero terms.
215 */
213 216
214 BIGNUM a, b; /* Curve coefficients. 217 BIGNUM a, b; /* Curve coefficients.
215 * (Here the assumption is that BIGNUMs can be used 218 * (Here the assumption is that BIGNUMs can be used
diff --git a/src/lib/libcrypto/ec/ec_lib.c b/src/lib/libcrypto/ec/ec_lib.c
index 5af84376c6..dd7da0fcf9 100644
--- a/src/lib/libcrypto/ec/ec_lib.c
+++ b/src/lib/libcrypto/ec/ec_lib.c
@@ -79,7 +79,7 @@ EC_GROUP *EC_GROUP_new(const EC_METHOD *meth)
79 79
80 if (meth == NULL) 80 if (meth == NULL)
81 { 81 {
82 ECerr(EC_F_EC_GROUP_NEW, ERR_R_PASSED_NULL_PARAMETER); 82 ECerr(EC_F_EC_GROUP_NEW, EC_R_SLOT_FULL);
83 return NULL; 83 return NULL;
84 } 84 }
85 if (meth->group_init == 0) 85 if (meth->group_init == 0)
@@ -740,7 +740,7 @@ void EC_POINT_clear_free(EC_POINT *point)
740 740
741 if (point->meth->point_clear_finish != 0) 741 if (point->meth->point_clear_finish != 0)
742 point->meth->point_clear_finish(point); 742 point->meth->point_clear_finish(point);
743 else if (point->meth != NULL && point->meth->point_finish != 0) 743 else if (point->meth->point_finish != 0)
744 point->meth->point_finish(point); 744 point->meth->point_finish(point);
745 OPENSSL_cleanse(point, sizeof *point); 745 OPENSSL_cleanse(point, sizeof *point);
746 OPENSSL_free(point); 746 OPENSSL_free(point);
diff --git a/src/lib/libcrypto/ec/ec_mult.c b/src/lib/libcrypto/ec/ec_mult.c
index 2ba173ef36..f05df5332e 100644
--- a/src/lib/libcrypto/ec/ec_mult.c
+++ b/src/lib/libcrypto/ec/ec_mult.c
@@ -224,6 +224,12 @@ static signed char *compute_wNAF(const BIGNUM *scalar, int w, size_t *ret_len)
224 sign = -1; 224 sign = -1;
225 } 225 }
226 226
227 if (scalar->d == NULL || scalar->top == 0)
228 {
229 ECerr(EC_F_COMPUTE_WNAF, ERR_R_INTERNAL_ERROR);
230 goto err;
231 }
232
227 len = BN_num_bits(scalar); 233 len = BN_num_bits(scalar);
228 r = OPENSSL_malloc(len + 1); /* modified wNAF may be one digit longer than binary representation 234 r = OPENSSL_malloc(len + 1); /* modified wNAF may be one digit longer than binary representation
229 * (*ret_len will be set to the actual length, i.e. at most 235 * (*ret_len will be set to the actual length, i.e. at most
@@ -233,12 +239,6 @@ static signed char *compute_wNAF(const BIGNUM *scalar, int w, size_t *ret_len)
233 ECerr(EC_F_COMPUTE_WNAF, ERR_R_MALLOC_FAILURE); 239 ECerr(EC_F_COMPUTE_WNAF, ERR_R_MALLOC_FAILURE);
234 goto err; 240 goto err;
235 } 241 }
236
237 if (scalar->d == NULL || scalar->top == 0)
238 {
239 ECerr(EC_F_COMPUTE_WNAF, ERR_R_INTERNAL_ERROR);
240 goto err;
241 }
242 window_val = scalar->d[0] & mask; 242 window_val = scalar->d[0] & mask;
243 j = 0; 243 j = 0;
244 while ((window_val != 0) || (j + w + 1 < len)) /* if j+w+1 >= len, window_val will not increase */ 244 while ((window_val != 0) || (j + w + 1 < len)) /* if j+w+1 >= len, window_val will not increase */
@@ -419,7 +419,7 @@ int ec_wNAF_mul(const EC_GROUP *group, EC_POINT *r, const BIGNUM *scalar,
419 if (numblocks > pre_comp->numblocks) 419 if (numblocks > pre_comp->numblocks)
420 numblocks = pre_comp->numblocks; 420 numblocks = pre_comp->numblocks;
421 421
422 pre_points_per_block = 1u << (pre_comp->w - 1); 422 pre_points_per_block = (size_t)1 << (pre_comp->w - 1);
423 423
424 /* check that pre_comp looks sane */ 424 /* check that pre_comp looks sane */
425 if (pre_comp->num != (pre_comp->numblocks * pre_points_per_block)) 425 if (pre_comp->num != (pre_comp->numblocks * pre_points_per_block))
@@ -461,7 +461,7 @@ int ec_wNAF_mul(const EC_GROUP *group, EC_POINT *r, const BIGNUM *scalar,
461 461
462 bits = i < num ? BN_num_bits(scalars[i]) : BN_num_bits(scalar); 462 bits = i < num ? BN_num_bits(scalars[i]) : BN_num_bits(scalar);
463 wsize[i] = EC_window_bits_for_scalar_size(bits); 463 wsize[i] = EC_window_bits_for_scalar_size(bits);
464 num_val += 1u << (wsize[i] - 1); 464 num_val += (size_t)1 << (wsize[i] - 1);
465 wNAF[i + 1] = NULL; /* make sure we always have a pivot */ 465 wNAF[i + 1] = NULL; /* make sure we always have a pivot */
466 wNAF[i] = compute_wNAF((i < num ? scalars[i] : scalar), wsize[i], &wNAF_len[i]); 466 wNAF[i] = compute_wNAF((i < num ? scalars[i] : scalar), wsize[i], &wNAF_len[i]);
467 if (wNAF[i] == NULL) 467 if (wNAF[i] == NULL)
@@ -600,7 +600,7 @@ int ec_wNAF_mul(const EC_GROUP *group, EC_POINT *r, const BIGNUM *scalar,
600 for (i = 0; i < num + num_scalar; i++) 600 for (i = 0; i < num + num_scalar; i++)
601 { 601 {
602 val_sub[i] = v; 602 val_sub[i] = v;
603 for (j = 0; j < (1u << (wsize[i] - 1)); j++) 603 for (j = 0; j < ((size_t)1 << (wsize[i] - 1)); j++)
604 { 604 {
605 *v = EC_POINT_new(group); 605 *v = EC_POINT_new(group);
606 if (*v == NULL) goto err; 606 if (*v == NULL) goto err;
@@ -636,7 +636,7 @@ int ec_wNAF_mul(const EC_GROUP *group, EC_POINT *r, const BIGNUM *scalar,
636 if (wsize[i] > 1) 636 if (wsize[i] > 1)
637 { 637 {
638 if (!EC_POINT_dbl(group, tmp, val_sub[i][0], ctx)) goto err; 638 if (!EC_POINT_dbl(group, tmp, val_sub[i][0], ctx)) goto err;
639 for (j = 1; j < (1u << (wsize[i] - 1)); j++) 639 for (j = 1; j < ((size_t)1 << (wsize[i] - 1)); j++)
640 { 640 {
641 if (!EC_POINT_add(group, val_sub[i][j], val_sub[i][j - 1], tmp, ctx)) goto err; 641 if (!EC_POINT_add(group, val_sub[i][j], val_sub[i][j - 1], tmp, ctx)) goto err;
642 } 642 }
@@ -820,7 +820,7 @@ int ec_wNAF_precompute_mult(EC_GROUP *group, BN_CTX *ctx)
820 820
821 numblocks = (bits + blocksize - 1) / blocksize; /* max. number of blocks to use for wNAF splitting */ 821 numblocks = (bits + blocksize - 1) / blocksize; /* max. number of blocks to use for wNAF splitting */
822 822
823 pre_points_per_block = 1u << (w - 1); 823 pre_points_per_block = (size_t)1 << (w - 1);
824 num = pre_points_per_block * numblocks; /* number of points to compute and store */ 824 num = pre_points_per_block * numblocks; /* number of points to compute and store */
825 825
826 points = OPENSSL_malloc(sizeof (EC_POINT*)*(num + 1)); 826 points = OPENSSL_malloc(sizeof (EC_POINT*)*(num + 1));
diff --git a/src/lib/libcrypto/ec/ecp_nist.c b/src/lib/libcrypto/ec/ecp_nist.c
index 71893d5eab..2a5682ea41 100644
--- a/src/lib/libcrypto/ec/ecp_nist.c
+++ b/src/lib/libcrypto/ec/ecp_nist.c
@@ -112,10 +112,6 @@ const EC_METHOD *EC_GFp_nist_method(void)
112 return &ret; 112 return &ret;
113 } 113 }
114 114
115#if BN_BITS2 == 64
116#define NO_32_BIT_TYPE
117#endif
118
119int ec_GFp_nist_group_copy(EC_GROUP *dest, const EC_GROUP *src) 115int ec_GFp_nist_group_copy(EC_GROUP *dest, const EC_GROUP *src)
120 { 116 {
121 dest->field_mod_func = src->field_mod_func; 117 dest->field_mod_func = src->field_mod_func;
@@ -139,34 +135,12 @@ int ec_GFp_nist_group_set_curve(EC_GROUP *group, const BIGNUM *p,
139 if (BN_ucmp(BN_get0_nist_prime_192(), p) == 0) 135 if (BN_ucmp(BN_get0_nist_prime_192(), p) == 0)
140 group->field_mod_func = BN_nist_mod_192; 136 group->field_mod_func = BN_nist_mod_192;
141 else if (BN_ucmp(BN_get0_nist_prime_224(), p) == 0) 137 else if (BN_ucmp(BN_get0_nist_prime_224(), p) == 0)
142 {
143#ifndef NO_32_BIT_TYPE
144 group->field_mod_func = BN_nist_mod_224; 138 group->field_mod_func = BN_nist_mod_224;
145#else
146 ECerr(EC_F_EC_GFP_NIST_GROUP_SET_CURVE, EC_R_NOT_A_SUPPORTED_NIST_PRIME);
147 goto err;
148#endif
149 }
150 else if (BN_ucmp(BN_get0_nist_prime_256(), p) == 0) 139 else if (BN_ucmp(BN_get0_nist_prime_256(), p) == 0)
151 {
152#ifndef NO_32_BIT_TYPE
153 group->field_mod_func = BN_nist_mod_256; 140 group->field_mod_func = BN_nist_mod_256;
154#else
155 ECerr(EC_F_EC_GFP_NIST_GROUP_SET_CURVE, EC_R_NOT_A_SUPPORTED_NIST_PRIME);
156 goto err;
157#endif
158 }
159 else if (BN_ucmp(BN_get0_nist_prime_384(), p) == 0) 141 else if (BN_ucmp(BN_get0_nist_prime_384(), p) == 0)
160 {
161#ifndef NO_32_BIT_TYPE
162 group->field_mod_func = BN_nist_mod_384; 142 group->field_mod_func = BN_nist_mod_384;
163#else
164 ECerr(EC_F_EC_GFP_NIST_GROUP_SET_CURVE, EC_R_NOT_A_SUPPORTED_NIST_PRIME);
165 goto err;
166#endif
167 }
168 else if (BN_ucmp(BN_get0_nist_prime_521(), p) == 0) 143 else if (BN_ucmp(BN_get0_nist_prime_521(), p) == 0)
169 /* this one works in the NO_32_BIT_TYPE case */
170 group->field_mod_func = BN_nist_mod_521; 144 group->field_mod_func = BN_nist_mod_521;
171 else 145 else
172 { 146 {
diff --git a/src/lib/libcrypto/ec/ecp_recp.c b/src/lib/libcrypto/ec/ecp_recp.c
deleted file mode 100644
index fec843b5c8..0000000000
--- a/src/lib/libcrypto/ec/ecp_recp.c
+++ /dev/null
@@ -1,133 +0,0 @@
1/* crypto/ec/ecp_recp.c */
2/* ====================================================================
3 * Copyright (c) 1998-2001 The OpenSSL Project. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 *
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in
14 * the documentation and/or other materials provided with the
15 * distribution.
16 *
17 * 3. All advertising materials mentioning features or use of this
18 * software must display the following acknowledgment:
19 * "This product includes software developed by the OpenSSL Project
20 * for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
21 *
22 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
23 * endorse or promote products derived from this software without
24 * prior written permission. For written permission, please contact
25 * openssl-core@openssl.org.
26 *
27 * 5. Products derived from this software may not be called "OpenSSL"
28 * nor may "OpenSSL" appear in their names without prior written
29 * permission of the OpenSSL Project.
30 *
31 * 6. Redistributions of any form whatsoever must retain the following
32 * acknowledgment:
33 * "This product includes software developed by the OpenSSL Project
34 * for use in the OpenSSL Toolkit (http://www.openssl.org/)"
35 *
36 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
37 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
38 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
39 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
40 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
41 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
42 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
43 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
44 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
45 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
46 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
47 * OF THE POSSIBILITY OF SUCH DAMAGE.
48 * ====================================================================
49 *
50 * This product includes cryptographic software written by Eric Young
51 * (eay@cryptsoft.com). This product includes software written by Tim
52 * Hudson (tjh@cryptsoft.com).
53 *
54 */
55
56#include "ec_lcl.h"
57
58#if 0
59const EC_METHOD *EC_GFp_recp_method(void)
60 {
61 static const EC_METHOD ret = {
62 ec_GFp_recp_group_init,
63 ec_GFp_recp_group_finish,
64 ec_GFp_recp_group_clear_finish,
65 ec_GFp_recp_group_copy,
66 ec_GFp_recp_group_set_curve_GFp,
67 ec_GFp_simple_group_get_curve_GFp,
68 ec_GFp_simple_group_set_generator,
69 ec_GFp_simple_group_get0_generator,
70 ec_GFp_simple_group_get_order,
71 ec_GFp_simple_group_get_cofactor,
72 ec_GFp_simple_point_init,
73 ec_GFp_simple_point_finish,
74 ec_GFp_simple_point_clear_finish,
75 ec_GFp_simple_point_copy,
76 ec_GFp_simple_point_set_to_infinity,
77 ec_GFp_simple_set_Jprojective_coordinates_GFp,
78 ec_GFp_simple_get_Jprojective_coordinates_GFp,
79 ec_GFp_simple_point_set_affine_coordinates_GFp,
80 ec_GFp_simple_point_get_affine_coordinates_GFp,
81 ec_GFp_simple_set_compressed_coordinates_GFp,
82 ec_GFp_simple_point2oct,
83 ec_GFp_simple_oct2point,
84 ec_GFp_simple_add,
85 ec_GFp_simple_dbl,
86 ec_GFp_simple_invert,
87 ec_GFp_simple_is_at_infinity,
88 ec_GFp_simple_is_on_curve,
89 ec_GFp_simple_cmp,
90 ec_GFp_simple_make_affine,
91 ec_GFp_simple_points_make_affine,
92 ec_GFp_recp_field_mul,
93 ec_GFp_recp_field_sqr,
94 0 /* field_encode */,
95 0 /* field_decode */,
96 0 /* field_set_to_one */ };
97
98 return &ret;
99 }
100#endif
101
102int ec_GFp_recp_group_init(EC_GROUP *group)
103 {
104 int ok;
105
106 ok = ec_GFp_simple_group_init(group);
107 group->field_data1 = NULL;
108 return ok;
109 }
110
111
112int ec_GFp_recp_group_set_curve_GFp(EC_GROUP *group, const BIGNUM *p, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx);
113/* TODO */
114
115
116void ec_GFp_recp_group_finish(EC_GROUP *group);
117/* TODO */
118
119
120void ec_GFp_recp_group_clear_finish(EC_GROUP *group);
121/* TODO */
122
123
124int ec_GFp_recp_group_copy(EC_GROUP *dest, const EC_GROUP *src);
125/* TODO */
126
127
128int ec_GFp_recp_field_mul(const EC_GROUP *group, BIGNUM *r, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx);
129/* TODO */
130
131
132int ec_GFp_recp_field_sqr(const EC_GROUP *group, BIGNUM *r, const BIGNUM *a, BN_CTX *ctx);
133/* TODO */
diff --git a/src/lib/libcrypto/ec/ectest.c b/src/lib/libcrypto/ec/ectest.c
index 6148d553f9..7509cb9c7c 100644
--- a/src/lib/libcrypto/ec/ectest.c
+++ b/src/lib/libcrypto/ec/ectest.c
@@ -432,9 +432,7 @@ void prime_field_tests()
432 if (!EC_POINT_is_at_infinity(group, Q)) ABORT; 432 if (!EC_POINT_is_at_infinity(group, Q)) ABORT;
433 fprintf(stdout, "."); 433 fprintf(stdout, ".");
434 fflush(stdout); 434 fflush(stdout);
435#if 0
436 if (!EC_GROUP_precompute_mult(group, ctx)) ABORT; 435 if (!EC_GROUP_precompute_mult(group, ctx)) ABORT;
437#endif
438 if (!EC_POINT_mul(group, Q, z, NULL, NULL, ctx)) ABORT; 436 if (!EC_POINT_mul(group, Q, z, NULL, NULL, ctx)) ABORT;
439 if (!EC_POINT_is_at_infinity(group, Q)) ABORT; 437 if (!EC_POINT_is_at_infinity(group, Q)) ABORT;
440 fprintf(stdout, " ok\n"); 438 fprintf(stdout, " ok\n");
@@ -478,9 +476,7 @@ void prime_field_tests()
478 if (!EC_POINT_is_at_infinity(group, Q)) ABORT; 476 if (!EC_POINT_is_at_infinity(group, Q)) ABORT;
479 fprintf(stdout, "."); 477 fprintf(stdout, ".");
480 fflush(stdout); 478 fflush(stdout);
481#if 0
482 if (!EC_GROUP_precompute_mult(group, ctx)) ABORT; 479 if (!EC_GROUP_precompute_mult(group, ctx)) ABORT;
483#endif
484 if (!EC_POINT_mul(group, Q, z, NULL, NULL, ctx)) ABORT; 480 if (!EC_POINT_mul(group, Q, z, NULL, NULL, ctx)) ABORT;
485 if (!EC_POINT_is_at_infinity(group, Q)) ABORT; 481 if (!EC_POINT_is_at_infinity(group, Q)) ABORT;
486 fprintf(stdout, " ok\n"); 482 fprintf(stdout, " ok\n");
@@ -525,9 +521,7 @@ void prime_field_tests()
525 if (!EC_POINT_is_at_infinity(group, Q)) ABORT; 521 if (!EC_POINT_is_at_infinity(group, Q)) ABORT;
526 fprintf(stdout, "."); 522 fprintf(stdout, ".");
527 fflush(stdout); 523 fflush(stdout);
528#if 0
529 if (!EC_GROUP_precompute_mult(group, ctx)) ABORT; 524 if (!EC_GROUP_precompute_mult(group, ctx)) ABORT;
530#endif
531 if (!EC_POINT_mul(group, Q, z, NULL, NULL, ctx)) ABORT; 525 if (!EC_POINT_mul(group, Q, z, NULL, NULL, ctx)) ABORT;
532 if (!EC_POINT_is_at_infinity(group, Q)) ABORT; 526 if (!EC_POINT_is_at_infinity(group, Q)) ABORT;
533 fprintf(stdout, " ok\n"); 527 fprintf(stdout, " ok\n");
@@ -577,9 +571,7 @@ void prime_field_tests()
577 if (!EC_POINT_is_at_infinity(group, Q)) ABORT; 571 if (!EC_POINT_is_at_infinity(group, Q)) ABORT;
578 fprintf(stdout, "."); 572 fprintf(stdout, ".");
579 fflush(stdout); 573 fflush(stdout);
580#if 0
581 if (!EC_GROUP_precompute_mult(group, ctx)) ABORT; 574 if (!EC_GROUP_precompute_mult(group, ctx)) ABORT;
582#endif
583 if (!EC_POINT_mul(group, Q, z, NULL, NULL, ctx)) ABORT; 575 if (!EC_POINT_mul(group, Q, z, NULL, NULL, ctx)) ABORT;
584 if (!EC_POINT_is_at_infinity(group, Q)) ABORT; 576 if (!EC_POINT_is_at_infinity(group, Q)) ABORT;
585 fprintf(stdout, " ok\n"); 577 fprintf(stdout, " ok\n");
@@ -635,9 +627,7 @@ void prime_field_tests()
635 if (!EC_POINT_is_at_infinity(group, Q)) ABORT; 627 if (!EC_POINT_is_at_infinity(group, Q)) ABORT;
636 fprintf(stdout, "."); 628 fprintf(stdout, ".");
637 fflush(stdout); 629 fflush(stdout);
638#if 0
639 if (!EC_GROUP_precompute_mult(group, ctx)) ABORT; 630 if (!EC_GROUP_precompute_mult(group, ctx)) ABORT;
640#endif
641 if (!EC_POINT_mul(group, Q, z, NULL, NULL, ctx)) ABORT; 631 if (!EC_POINT_mul(group, Q, z, NULL, NULL, ctx)) ABORT;
642 if (!EC_POINT_is_at_infinity(group, Q)) ABORT; 632 if (!EC_POINT_is_at_infinity(group, Q)) ABORT;
643 fprintf(stdout, " ok\n"); 633 fprintf(stdout, " ok\n");
@@ -809,7 +799,7 @@ void prime_field_tests()
809 if (!EC_POINT_is_at_infinity(group, Q)) ABORT; \ 799 if (!EC_POINT_is_at_infinity(group, Q)) ABORT; \
810 fprintf(stdout, "."); \ 800 fprintf(stdout, "."); \
811 fflush(stdout); \ 801 fflush(stdout); \
812 /* if (!EC_GROUP_precompute_mult(group, ctx)) ABORT; */ \ 802 if (!EC_GROUP_precompute_mult(group, ctx)) ABORT; \
813 if (!EC_POINT_mul(group, Q, z, NULL, NULL, ctx)) ABORT; \ 803 if (!EC_POINT_mul(group, Q, z, NULL, NULL, ctx)) ABORT; \
814 if (!EC_POINT_is_at_infinity(group, Q)) ABORT; \ 804 if (!EC_POINT_is_at_infinity(group, Q)) ABORT; \
815 fprintf(stdout, " ok\n"); \ 805 fprintf(stdout, " ok\n"); \
@@ -1336,7 +1326,7 @@ int main(int argc, char *argv[])
1336#endif 1326#endif
1337 CRYPTO_cleanup_all_ex_data(); 1327 CRYPTO_cleanup_all_ex_data();
1338 ERR_free_strings(); 1328 ERR_free_strings();
1339 ERR_remove_state(0); 1329 ERR_remove_thread_state(NULL);
1340 CRYPTO_mem_leaks_fp(stderr); 1330 CRYPTO_mem_leaks_fp(stderr);
1341 1331
1342 return 0; 1332 return 0;
diff --git a/src/lib/libcrypto/ecdh/Makefile b/src/lib/libcrypto/ecdh/Makefile
index 7a7b618eeb..65d8904ee8 100644
--- a/src/lib/libcrypto/ecdh/Makefile
+++ b/src/lib/libcrypto/ecdh/Makefile
@@ -34,7 +34,7 @@ top:
34all: lib 34all: lib
35 35
36lib: $(LIBOBJ) 36lib: $(LIBOBJ)
37 $(ARX) $(LIB) $(LIBOBJ) 37 $(AR) $(LIB) $(LIBOBJ)
38 $(RANLIB) $(LIB) || echo Never mind. 38 $(RANLIB) $(LIB) || echo Never mind.
39 @touch lib 39 @touch lib
40 40
@@ -88,27 +88,26 @@ ech_key.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
88ech_key.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h 88ech_key.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h
89ech_key.o: ../../include/openssl/ecdh.h ../../include/openssl/ecdsa.h 89ech_key.o: ../../include/openssl/ecdh.h ../../include/openssl/ecdsa.h
90ech_key.o: ../../include/openssl/engine.h ../../include/openssl/evp.h 90ech_key.o: ../../include/openssl/engine.h ../../include/openssl/evp.h
91ech_key.o: ../../include/openssl/fips.h ../../include/openssl/lhash.h 91ech_key.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
92ech_key.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h 92ech_key.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
93ech_key.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h 93ech_key.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
94ech_key.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h 94ech_key.o: ../../include/openssl/pkcs7.h ../../include/openssl/safestack.h
95ech_key.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h 95ech_key.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
96ech_key.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 96ech_key.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h
97ech_key.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h 97ech_key.o: ../../include/openssl/x509_vfy.h ech_key.c ech_locl.h
98ech_key.o: ech_key.c ech_locl.h
99ech_lib.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h 98ech_lib.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
100ech_lib.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 99ech_lib.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
101ech_lib.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h 100ech_lib.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h
102ech_lib.o: ../../include/openssl/ecdh.h ../../include/openssl/ecdsa.h 101ech_lib.o: ../../include/openssl/ecdh.h ../../include/openssl/ecdsa.h
103ech_lib.o: ../../include/openssl/engine.h ../../include/openssl/err.h 102ech_lib.o: ../../include/openssl/engine.h ../../include/openssl/err.h
104ech_lib.o: ../../include/openssl/evp.h ../../include/openssl/fips.h 103ech_lib.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h
105ech_lib.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h 104ech_lib.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
106ech_lib.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h 105ech_lib.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
107ech_lib.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h 106ech_lib.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h
108ech_lib.o: ../../include/openssl/pkcs7.h ../../include/openssl/safestack.h 107ech_lib.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
109ech_lib.o: ../../include/openssl/sha.h ../../include/openssl/stack.h 108ech_lib.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
110ech_lib.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h 109ech_lib.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
111ech_lib.o: ../../include/openssl/x509_vfy.h ech_lib.c ech_locl.h 110ech_lib.o: ech_lib.c ech_locl.h
112ech_ossl.o: ../../e_os.h ../../include/openssl/asn1.h 111ech_ossl.o: ../../e_os.h ../../include/openssl/asn1.h
113ech_ossl.o: ../../include/openssl/bio.h ../../include/openssl/bn.h 112ech_ossl.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
114ech_ossl.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 113ech_ossl.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
diff --git a/src/lib/libcrypto/ecdsa/Makefile b/src/lib/libcrypto/ecdsa/Makefile
index 4865f3c8d6..e89e0c010c 100644
--- a/src/lib/libcrypto/ecdsa/Makefile
+++ b/src/lib/libcrypto/ecdsa/Makefile
@@ -34,7 +34,7 @@ top:
34all: lib 34all: lib
35 35
36lib: $(LIBOBJ) 36lib: $(LIBOBJ)
37 $(ARX) $(LIB) $(LIBOBJ) 37 $(AR) $(LIB) $(LIBOBJ)
38 $(RANLIB) $(LIB) || echo Never mind. 38 $(RANLIB) $(LIB) || echo Never mind.
39 @touch lib 39 @touch lib
40 40
@@ -97,14 +97,13 @@ ecs_lib.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
97ecs_lib.o: ../../include/openssl/ec.h ../../include/openssl/ecdh.h 97ecs_lib.o: ../../include/openssl/ec.h ../../include/openssl/ecdh.h
98ecs_lib.o: ../../include/openssl/ecdsa.h ../../include/openssl/engine.h 98ecs_lib.o: ../../include/openssl/ecdsa.h ../../include/openssl/engine.h
99ecs_lib.o: ../../include/openssl/err.h ../../include/openssl/evp.h 99ecs_lib.o: ../../include/openssl/err.h ../../include/openssl/evp.h
100ecs_lib.o: ../../include/openssl/fips.h ../../include/openssl/lhash.h 100ecs_lib.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
101ecs_lib.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h 101ecs_lib.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
102ecs_lib.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h 102ecs_lib.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
103ecs_lib.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h 103ecs_lib.o: ../../include/openssl/pkcs7.h ../../include/openssl/safestack.h
104ecs_lib.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h 104ecs_lib.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
105ecs_lib.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 105ecs_lib.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h
106ecs_lib.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h 106ecs_lib.o: ../../include/openssl/x509_vfy.h ecs_lib.c ecs_locl.h
107ecs_lib.o: ecs_lib.c ecs_locl.h
108ecs_ossl.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h 107ecs_ossl.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
109ecs_ossl.o: ../../include/openssl/bn.h ../../include/openssl/crypto.h 108ecs_ossl.o: ../../include/openssl/bn.h ../../include/openssl/crypto.h
110ecs_ossl.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h 109ecs_ossl.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h
@@ -119,24 +118,23 @@ ecs_sign.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
119ecs_sign.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h 118ecs_sign.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h
120ecs_sign.o: ../../include/openssl/ecdh.h ../../include/openssl/ecdsa.h 119ecs_sign.o: ../../include/openssl/ecdh.h ../../include/openssl/ecdsa.h
121ecs_sign.o: ../../include/openssl/engine.h ../../include/openssl/evp.h 120ecs_sign.o: ../../include/openssl/engine.h ../../include/openssl/evp.h
122ecs_sign.o: ../../include/openssl/fips.h ../../include/openssl/lhash.h 121ecs_sign.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
123ecs_sign.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h 122ecs_sign.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
124ecs_sign.o: ../../include/openssl/opensslconf.h
125ecs_sign.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h 123ecs_sign.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
126ecs_sign.o: ../../include/openssl/pkcs7.h ../../include/openssl/safestack.h 124ecs_sign.o: ../../include/openssl/pkcs7.h ../../include/openssl/rand.h
127ecs_sign.o: ../../include/openssl/sha.h ../../include/openssl/stack.h 125ecs_sign.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
128ecs_sign.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h 126ecs_sign.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
129ecs_sign.o: ../../include/openssl/x509_vfy.h ecs_locl.h ecs_sign.c 127ecs_sign.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
128ecs_sign.o: ecs_locl.h ecs_sign.c
130ecs_vrf.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h 129ecs_vrf.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
131ecs_vrf.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 130ecs_vrf.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
132ecs_vrf.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h 131ecs_vrf.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h
133ecs_vrf.o: ../../include/openssl/ecdh.h ../../include/openssl/ecdsa.h 132ecs_vrf.o: ../../include/openssl/ecdh.h ../../include/openssl/ecdsa.h
134ecs_vrf.o: ../../include/openssl/engine.h ../../include/openssl/evp.h 133ecs_vrf.o: ../../include/openssl/engine.h ../../include/openssl/evp.h
135ecs_vrf.o: ../../include/openssl/fips.h ../../include/openssl/lhash.h 134ecs_vrf.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
136ecs_vrf.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h 135ecs_vrf.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
137ecs_vrf.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h 136ecs_vrf.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
138ecs_vrf.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h 137ecs_vrf.o: ../../include/openssl/pkcs7.h ../../include/openssl/safestack.h
139ecs_vrf.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h 138ecs_vrf.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
140ecs_vrf.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 139ecs_vrf.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h
141ecs_vrf.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h 140ecs_vrf.o: ../../include/openssl/x509_vfy.h ecs_locl.h ecs_vrf.c
142ecs_vrf.o: ecs_locl.h ecs_vrf.c
diff --git a/src/lib/libcrypto/engine/Makefile b/src/lib/libcrypto/engine/Makefile
index 0736153075..9c214824eb 100644
--- a/src/lib/libcrypto/engine/Makefile
+++ b/src/lib/libcrypto/engine/Makefile
@@ -20,15 +20,13 @@ LIB=$(TOP)/libcrypto.a
20LIBSRC= eng_err.c eng_lib.c eng_list.c eng_init.c eng_ctrl.c \ 20LIBSRC= eng_err.c eng_lib.c eng_list.c eng_init.c eng_ctrl.c \
21 eng_table.c eng_pkey.c eng_fat.c eng_all.c \ 21 eng_table.c eng_pkey.c eng_fat.c eng_all.c \
22 tb_rsa.c tb_dsa.c tb_ecdsa.c tb_dh.c tb_ecdh.c tb_rand.c tb_store.c \ 22 tb_rsa.c tb_dsa.c tb_ecdsa.c tb_dh.c tb_ecdh.c tb_rand.c tb_store.c \
23 tb_cipher.c tb_digest.c \ 23 tb_cipher.c tb_digest.c tb_pkmeth.c tb_asnmth.c \
24 eng_openssl.c eng_cnf.c eng_dyn.c eng_cryptodev.c eng_padlock.c \ 24 eng_openssl.c eng_cnf.c eng_dyn.c eng_cryptodev.c
25 eng_aesni.c
26LIBOBJ= eng_err.o eng_lib.o eng_list.o eng_init.o eng_ctrl.o \ 25LIBOBJ= eng_err.o eng_lib.o eng_list.o eng_init.o eng_ctrl.o \
27 eng_table.o eng_pkey.o eng_fat.o eng_all.o \ 26 eng_table.o eng_pkey.o eng_fat.o eng_all.o \
28 tb_rsa.o tb_dsa.o tb_ecdsa.o tb_dh.o tb_ecdh.o tb_rand.o tb_store.o \ 27 tb_rsa.o tb_dsa.o tb_ecdsa.o tb_dh.o tb_ecdh.o tb_rand.o tb_store.o \
29 tb_cipher.o tb_digest.o \ 28 tb_cipher.o tb_digest.o tb_pkmeth.o tb_asnmth.o \
30 eng_openssl.o eng_cnf.o eng_dyn.o eng_cryptodev.o eng_padlock.o \ 29 eng_openssl.o eng_cnf.o eng_dyn.o eng_cryptodev.o
31 eng_aesni.o
32 30
33SRC= $(LIBSRC) 31SRC= $(LIBSRC)
34 32
@@ -43,7 +41,7 @@ top:
43all: lib 41all: lib
44 42
45lib: $(LIBOBJ) 43lib: $(LIBOBJ)
46 $(ARX) $(LIB) $(LIBOBJ) 44 $(AR) $(LIB) $(LIBOBJ)
47 $(RANLIB) $(LIB) || echo Never mind. 45 $(RANLIB) $(LIB) || echo Never mind.
48 @touch lib 46 @touch lib
49 47
@@ -84,56 +82,40 @@ clean:
84 82
85# DO NOT DELETE THIS LINE -- make depend depends on it. 83# DO NOT DELETE THIS LINE -- make depend depends on it.
86 84
87eng_aesni.o: ../../e_os.h ../../include/openssl/aes.h
88eng_aesni.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
89eng_aesni.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
90eng_aesni.o: ../../include/openssl/dso.h ../../include/openssl/e_os2.h
91eng_aesni.o: ../../include/openssl/ec.h ../../include/openssl/ecdh.h
92eng_aesni.o: ../../include/openssl/ecdsa.h ../../include/openssl/engine.h
93eng_aesni.o: ../../include/openssl/err.h ../../include/openssl/evp.h
94eng_aesni.o: ../../include/openssl/lhash.h ../../include/openssl/modes.h
95eng_aesni.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
96eng_aesni.o: ../../include/openssl/opensslconf.h
97eng_aesni.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
98eng_aesni.o: ../../include/openssl/pkcs7.h ../../include/openssl/safestack.h
99eng_aesni.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
100eng_aesni.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h
101eng_aesni.o: ../../include/openssl/x509_vfy.h ../cryptlib.h eng_aesni.c
102eng_all.o: ../../e_os.h ../../include/openssl/asn1.h 85eng_all.o: ../../e_os.h ../../include/openssl/asn1.h
103eng_all.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h 86eng_all.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
104eng_all.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h 87eng_all.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
105eng_all.o: ../../include/openssl/ec.h ../../include/openssl/ecdh.h 88eng_all.o: ../../include/openssl/ec.h ../../include/openssl/ecdh.h
106eng_all.o: ../../include/openssl/ecdsa.h ../../include/openssl/engine.h 89eng_all.o: ../../include/openssl/ecdsa.h ../../include/openssl/engine.h
107eng_all.o: ../../include/openssl/err.h ../../include/openssl/evp.h 90eng_all.o: ../../include/openssl/err.h ../../include/openssl/evp.h
108eng_all.o: ../../include/openssl/fips.h ../../include/openssl/lhash.h 91eng_all.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
109eng_all.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h 92eng_all.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
110eng_all.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h 93eng_all.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
111eng_all.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h 94eng_all.o: ../../include/openssl/pkcs7.h ../../include/openssl/safestack.h
112eng_all.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h 95eng_all.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
113eng_all.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 96eng_all.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h
114eng_all.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h 97eng_all.o: ../../include/openssl/x509_vfy.h ../cryptlib.h eng_all.c eng_int.h
115eng_all.o: ../cryptlib.h eng_all.c eng_int.h
116eng_cnf.o: ../../e_os.h ../../include/openssl/asn1.h 98eng_cnf.o: ../../e_os.h ../../include/openssl/asn1.h
117eng_cnf.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h 99eng_cnf.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
118eng_cnf.o: ../../include/openssl/conf.h ../../include/openssl/crypto.h 100eng_cnf.o: ../../include/openssl/conf.h ../../include/openssl/crypto.h
119eng_cnf.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h 101eng_cnf.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h
120eng_cnf.o: ../../include/openssl/ecdh.h ../../include/openssl/ecdsa.h 102eng_cnf.o: ../../include/openssl/ecdh.h ../../include/openssl/ecdsa.h
121eng_cnf.o: ../../include/openssl/engine.h ../../include/openssl/err.h 103eng_cnf.o: ../../include/openssl/engine.h ../../include/openssl/err.h
122eng_cnf.o: ../../include/openssl/evp.h ../../include/openssl/fips.h 104eng_cnf.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h
123eng_cnf.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h 105eng_cnf.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
124eng_cnf.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h 106eng_cnf.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
125eng_cnf.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h 107eng_cnf.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h
126eng_cnf.o: ../../include/openssl/pkcs7.h ../../include/openssl/safestack.h 108eng_cnf.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
127eng_cnf.o: ../../include/openssl/sha.h ../../include/openssl/stack.h 109eng_cnf.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
128eng_cnf.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h 110eng_cnf.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
129eng_cnf.o: ../../include/openssl/x509_vfy.h ../cryptlib.h eng_cnf.c eng_int.h 111eng_cnf.o: ../cryptlib.h eng_cnf.c eng_int.h
130eng_cryptodev.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h 112eng_cryptodev.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
131eng_cryptodev.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h 113eng_cryptodev.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
132eng_cryptodev.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h 114eng_cryptodev.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
133eng_cryptodev.o: ../../include/openssl/ec.h ../../include/openssl/ecdh.h 115eng_cryptodev.o: ../../include/openssl/ec.h ../../include/openssl/ecdh.h
134eng_cryptodev.o: ../../include/openssl/ecdsa.h ../../include/openssl/engine.h 116eng_cryptodev.o: ../../include/openssl/ecdsa.h ../../include/openssl/engine.h
135eng_cryptodev.o: ../../include/openssl/evp.h ../../include/openssl/fips.h 117eng_cryptodev.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h
136eng_cryptodev.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h 118eng_cryptodev.o: ../../include/openssl/obj_mac.h
137eng_cryptodev.o: ../../include/openssl/objects.h 119eng_cryptodev.o: ../../include/openssl/objects.h
138eng_cryptodev.o: ../../include/openssl/opensslconf.h 120eng_cryptodev.o: ../../include/openssl/opensslconf.h
139eng_cryptodev.o: ../../include/openssl/opensslv.h 121eng_cryptodev.o: ../../include/openssl/opensslv.h
@@ -148,9 +130,8 @@ eng_ctrl.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
148eng_ctrl.o: ../../include/openssl/ec.h ../../include/openssl/ecdh.h 130eng_ctrl.o: ../../include/openssl/ec.h ../../include/openssl/ecdh.h
149eng_ctrl.o: ../../include/openssl/ecdsa.h ../../include/openssl/engine.h 131eng_ctrl.o: ../../include/openssl/ecdsa.h ../../include/openssl/engine.h
150eng_ctrl.o: ../../include/openssl/err.h ../../include/openssl/evp.h 132eng_ctrl.o: ../../include/openssl/err.h ../../include/openssl/evp.h
151eng_ctrl.o: ../../include/openssl/fips.h ../../include/openssl/lhash.h 133eng_ctrl.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
152eng_ctrl.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h 134eng_ctrl.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
153eng_ctrl.o: ../../include/openssl/opensslconf.h
154eng_ctrl.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h 135eng_ctrl.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
155eng_ctrl.o: ../../include/openssl/pkcs7.h ../../include/openssl/safestack.h 136eng_ctrl.o: ../../include/openssl/pkcs7.h ../../include/openssl/safestack.h
156eng_ctrl.o: ../../include/openssl/sha.h ../../include/openssl/stack.h 137eng_ctrl.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
@@ -162,50 +143,49 @@ eng_dyn.o: ../../include/openssl/crypto.h ../../include/openssl/dso.h
162eng_dyn.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h 143eng_dyn.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h
163eng_dyn.o: ../../include/openssl/ecdh.h ../../include/openssl/ecdsa.h 144eng_dyn.o: ../../include/openssl/ecdh.h ../../include/openssl/ecdsa.h
164eng_dyn.o: ../../include/openssl/engine.h ../../include/openssl/err.h 145eng_dyn.o: ../../include/openssl/engine.h ../../include/openssl/err.h
165eng_dyn.o: ../../include/openssl/evp.h ../../include/openssl/fips.h 146eng_dyn.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h
166eng_dyn.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h 147eng_dyn.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
167eng_dyn.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h 148eng_dyn.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
168eng_dyn.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h 149eng_dyn.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h
169eng_dyn.o: ../../include/openssl/pkcs7.h ../../include/openssl/safestack.h 150eng_dyn.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
170eng_dyn.o: ../../include/openssl/sha.h ../../include/openssl/stack.h 151eng_dyn.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
171eng_dyn.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h 152eng_dyn.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
172eng_dyn.o: ../../include/openssl/x509_vfy.h ../cryptlib.h eng_dyn.c eng_int.h 153eng_dyn.o: ../cryptlib.h eng_dyn.c eng_int.h
173eng_err.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h 154eng_err.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
174eng_err.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 155eng_err.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
175eng_err.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h 156eng_err.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h
176eng_err.o: ../../include/openssl/ecdh.h ../../include/openssl/ecdsa.h 157eng_err.o: ../../include/openssl/ecdh.h ../../include/openssl/ecdsa.h
177eng_err.o: ../../include/openssl/engine.h ../../include/openssl/err.h 158eng_err.o: ../../include/openssl/engine.h ../../include/openssl/err.h
178eng_err.o: ../../include/openssl/evp.h ../../include/openssl/fips.h 159eng_err.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h
179eng_err.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h 160eng_err.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
180eng_err.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h 161eng_err.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
181eng_err.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h 162eng_err.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h
182eng_err.o: ../../include/openssl/pkcs7.h ../../include/openssl/safestack.h 163eng_err.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
183eng_err.o: ../../include/openssl/sha.h ../../include/openssl/stack.h 164eng_err.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
184eng_err.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h 165eng_err.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
185eng_err.o: ../../include/openssl/x509_vfy.h eng_err.c 166eng_err.o: eng_err.c
186eng_fat.o: ../../e_os.h ../../include/openssl/asn1.h 167eng_fat.o: ../../e_os.h ../../include/openssl/asn1.h
187eng_fat.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h 168eng_fat.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
188eng_fat.o: ../../include/openssl/conf.h ../../include/openssl/crypto.h 169eng_fat.o: ../../include/openssl/conf.h ../../include/openssl/crypto.h
189eng_fat.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h 170eng_fat.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h
190eng_fat.o: ../../include/openssl/ecdh.h ../../include/openssl/ecdsa.h 171eng_fat.o: ../../include/openssl/ecdh.h ../../include/openssl/ecdsa.h
191eng_fat.o: ../../include/openssl/engine.h ../../include/openssl/err.h 172eng_fat.o: ../../include/openssl/engine.h ../../include/openssl/err.h
192eng_fat.o: ../../include/openssl/evp.h ../../include/openssl/fips.h 173eng_fat.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h
193eng_fat.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h 174eng_fat.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
194eng_fat.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h 175eng_fat.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
195eng_fat.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h 176eng_fat.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h
196eng_fat.o: ../../include/openssl/pkcs7.h ../../include/openssl/safestack.h 177eng_fat.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
197eng_fat.o: ../../include/openssl/sha.h ../../include/openssl/stack.h 178eng_fat.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
198eng_fat.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h 179eng_fat.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
199eng_fat.o: ../../include/openssl/x509_vfy.h ../cryptlib.h eng_fat.c eng_int.h 180eng_fat.o: ../cryptlib.h eng_fat.c eng_int.h
200eng_init.o: ../../e_os.h ../../include/openssl/asn1.h 181eng_init.o: ../../e_os.h ../../include/openssl/asn1.h
201eng_init.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h 182eng_init.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
202eng_init.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h 183eng_init.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
203eng_init.o: ../../include/openssl/ec.h ../../include/openssl/ecdh.h 184eng_init.o: ../../include/openssl/ec.h ../../include/openssl/ecdh.h
204eng_init.o: ../../include/openssl/ecdsa.h ../../include/openssl/engine.h 185eng_init.o: ../../include/openssl/ecdsa.h ../../include/openssl/engine.h
205eng_init.o: ../../include/openssl/err.h ../../include/openssl/evp.h 186eng_init.o: ../../include/openssl/err.h ../../include/openssl/evp.h
206eng_init.o: ../../include/openssl/fips.h ../../include/openssl/lhash.h 187eng_init.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
207eng_init.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h 188eng_init.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
208eng_init.o: ../../include/openssl/opensslconf.h
209eng_init.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h 189eng_init.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
210eng_init.o: ../../include/openssl/pkcs7.h ../../include/openssl/safestack.h 190eng_init.o: ../../include/openssl/pkcs7.h ../../include/openssl/safestack.h
211eng_init.o: ../../include/openssl/sha.h ../../include/openssl/stack.h 191eng_init.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
@@ -217,23 +197,22 @@ eng_lib.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
217eng_lib.o: ../../include/openssl/ec.h ../../include/openssl/ecdh.h 197eng_lib.o: ../../include/openssl/ec.h ../../include/openssl/ecdh.h
218eng_lib.o: ../../include/openssl/ecdsa.h ../../include/openssl/engine.h 198eng_lib.o: ../../include/openssl/ecdsa.h ../../include/openssl/engine.h
219eng_lib.o: ../../include/openssl/err.h ../../include/openssl/evp.h 199eng_lib.o: ../../include/openssl/err.h ../../include/openssl/evp.h
220eng_lib.o: ../../include/openssl/fips.h ../../include/openssl/lhash.h 200eng_lib.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
221eng_lib.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h 201eng_lib.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
222eng_lib.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h 202eng_lib.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
223eng_lib.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h 203eng_lib.o: ../../include/openssl/pkcs7.h ../../include/openssl/rand.h
224eng_lib.o: ../../include/openssl/rand.h ../../include/openssl/safestack.h 204eng_lib.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
225eng_lib.o: ../../include/openssl/sha.h ../../include/openssl/stack.h 205eng_lib.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
226eng_lib.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h 206eng_lib.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
227eng_lib.o: ../../include/openssl/x509_vfy.h ../cryptlib.h eng_int.h eng_lib.c 207eng_lib.o: ../cryptlib.h eng_int.h eng_lib.c
228eng_list.o: ../../e_os.h ../../include/openssl/asn1.h 208eng_list.o: ../../e_os.h ../../include/openssl/asn1.h
229eng_list.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h 209eng_list.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
230eng_list.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h 210eng_list.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
231eng_list.o: ../../include/openssl/ec.h ../../include/openssl/ecdh.h 211eng_list.o: ../../include/openssl/ec.h ../../include/openssl/ecdh.h
232eng_list.o: ../../include/openssl/ecdsa.h ../../include/openssl/engine.h 212eng_list.o: ../../include/openssl/ecdsa.h ../../include/openssl/engine.h
233eng_list.o: ../../include/openssl/err.h ../../include/openssl/evp.h 213eng_list.o: ../../include/openssl/err.h ../../include/openssl/evp.h
234eng_list.o: ../../include/openssl/fips.h ../../include/openssl/lhash.h 214eng_list.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
235eng_list.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h 215eng_list.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
236eng_list.o: ../../include/openssl/opensslconf.h
237eng_list.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h 216eng_list.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
238eng_list.o: ../../include/openssl/pkcs7.h ../../include/openssl/safestack.h 217eng_list.o: ../../include/openssl/pkcs7.h ../../include/openssl/safestack.h
239eng_list.o: ../../include/openssl/sha.h ../../include/openssl/stack.h 218eng_list.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
@@ -246,9 +225,8 @@ eng_openssl.o: ../../include/openssl/dsa.h ../../include/openssl/dso.h
246eng_openssl.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h 225eng_openssl.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h
247eng_openssl.o: ../../include/openssl/ecdh.h ../../include/openssl/ecdsa.h 226eng_openssl.o: ../../include/openssl/ecdh.h ../../include/openssl/ecdsa.h
248eng_openssl.o: ../../include/openssl/engine.h ../../include/openssl/err.h 227eng_openssl.o: ../../include/openssl/engine.h ../../include/openssl/err.h
249eng_openssl.o: ../../include/openssl/evp.h ../../include/openssl/fips.h 228eng_openssl.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h
250eng_openssl.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h 229eng_openssl.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
251eng_openssl.o: ../../include/openssl/objects.h
252eng_openssl.o: ../../include/openssl/opensslconf.h 230eng_openssl.o: ../../include/openssl/opensslconf.h
253eng_openssl.o: ../../include/openssl/opensslv.h 231eng_openssl.o: ../../include/openssl/opensslv.h
254eng_openssl.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pem.h 232eng_openssl.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pem.h
@@ -258,31 +236,14 @@ eng_openssl.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
258eng_openssl.o: ../../include/openssl/sha.h ../../include/openssl/stack.h 236eng_openssl.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
259eng_openssl.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h 237eng_openssl.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h
260eng_openssl.o: ../../include/openssl/x509_vfy.h ../cryptlib.h eng_openssl.c 238eng_openssl.o: ../../include/openssl/x509_vfy.h ../cryptlib.h eng_openssl.c
261eng_padlock.o: ../../include/openssl/aes.h ../../include/openssl/asn1.h
262eng_padlock.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
263eng_padlock.o: ../../include/openssl/crypto.h ../../include/openssl/dso.h
264eng_padlock.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h
265eng_padlock.o: ../../include/openssl/ecdh.h ../../include/openssl/ecdsa.h
266eng_padlock.o: ../../include/openssl/engine.h ../../include/openssl/err.h
267eng_padlock.o: ../../include/openssl/evp.h ../../include/openssl/fips.h
268eng_padlock.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
269eng_padlock.o: ../../include/openssl/objects.h
270eng_padlock.o: ../../include/openssl/opensslconf.h
271eng_padlock.o: ../../include/openssl/opensslv.h
272eng_padlock.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h
273eng_padlock.o: ../../include/openssl/rand.h ../../include/openssl/safestack.h
274eng_padlock.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
275eng_padlock.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h
276eng_padlock.o: ../../include/openssl/x509_vfy.h eng_padlock.c
277eng_pkey.o: ../../e_os.h ../../include/openssl/asn1.h 239eng_pkey.o: ../../e_os.h ../../include/openssl/asn1.h
278eng_pkey.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h 240eng_pkey.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
279eng_pkey.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h 241eng_pkey.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
280eng_pkey.o: ../../include/openssl/ec.h ../../include/openssl/ecdh.h 242eng_pkey.o: ../../include/openssl/ec.h ../../include/openssl/ecdh.h
281eng_pkey.o: ../../include/openssl/ecdsa.h ../../include/openssl/engine.h 243eng_pkey.o: ../../include/openssl/ecdsa.h ../../include/openssl/engine.h
282eng_pkey.o: ../../include/openssl/err.h ../../include/openssl/evp.h 244eng_pkey.o: ../../include/openssl/err.h ../../include/openssl/evp.h
283eng_pkey.o: ../../include/openssl/fips.h ../../include/openssl/lhash.h 245eng_pkey.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
284eng_pkey.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h 246eng_pkey.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
285eng_pkey.o: ../../include/openssl/opensslconf.h
286eng_pkey.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h 247eng_pkey.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
287eng_pkey.o: ../../include/openssl/pkcs7.h ../../include/openssl/safestack.h 248eng_pkey.o: ../../include/openssl/pkcs7.h ../../include/openssl/safestack.h
288eng_pkey.o: ../../include/openssl/sha.h ../../include/openssl/stack.h 249eng_pkey.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
@@ -294,8 +255,8 @@ eng_table.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
294eng_table.o: ../../include/openssl/ec.h ../../include/openssl/ecdh.h 255eng_table.o: ../../include/openssl/ec.h ../../include/openssl/ecdh.h
295eng_table.o: ../../include/openssl/ecdsa.h ../../include/openssl/engine.h 256eng_table.o: ../../include/openssl/ecdsa.h ../../include/openssl/engine.h
296eng_table.o: ../../include/openssl/err.h ../../include/openssl/evp.h 257eng_table.o: ../../include/openssl/err.h ../../include/openssl/evp.h
297eng_table.o: ../../include/openssl/fips.h ../../include/openssl/lhash.h 258eng_table.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
298eng_table.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h 259eng_table.o: ../../include/openssl/objects.h
299eng_table.o: ../../include/openssl/opensslconf.h 260eng_table.o: ../../include/openssl/opensslconf.h
300eng_table.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h 261eng_table.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
301eng_table.o: ../../include/openssl/pkcs7.h ../../include/openssl/safestack.h 262eng_table.o: ../../include/openssl/pkcs7.h ../../include/openssl/safestack.h
@@ -303,14 +264,29 @@ eng_table.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
303eng_table.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h 264eng_table.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h
304eng_table.o: ../../include/openssl/x509_vfy.h ../cryptlib.h eng_int.h 265eng_table.o: ../../include/openssl/x509_vfy.h ../cryptlib.h eng_int.h
305eng_table.o: eng_table.c 266eng_table.o: eng_table.c
267tb_asnmth.o: ../../e_os.h ../../include/openssl/asn1.h
268tb_asnmth.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
269tb_asnmth.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
270tb_asnmth.o: ../../include/openssl/ec.h ../../include/openssl/ecdh.h
271tb_asnmth.o: ../../include/openssl/ecdsa.h ../../include/openssl/engine.h
272tb_asnmth.o: ../../include/openssl/err.h ../../include/openssl/evp.h
273tb_asnmth.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
274tb_asnmth.o: ../../include/openssl/objects.h
275tb_asnmth.o: ../../include/openssl/opensslconf.h
276tb_asnmth.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
277tb_asnmth.o: ../../include/openssl/pkcs7.h ../../include/openssl/safestack.h
278tb_asnmth.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
279tb_asnmth.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h
280tb_asnmth.o: ../../include/openssl/x509_vfy.h ../asn1/asn1_locl.h ../cryptlib.h
281tb_asnmth.o: eng_int.h tb_asnmth.c
306tb_cipher.o: ../../e_os.h ../../include/openssl/asn1.h 282tb_cipher.o: ../../e_os.h ../../include/openssl/asn1.h
307tb_cipher.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h 283tb_cipher.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
308tb_cipher.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h 284tb_cipher.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
309tb_cipher.o: ../../include/openssl/ec.h ../../include/openssl/ecdh.h 285tb_cipher.o: ../../include/openssl/ec.h ../../include/openssl/ecdh.h
310tb_cipher.o: ../../include/openssl/ecdsa.h ../../include/openssl/engine.h 286tb_cipher.o: ../../include/openssl/ecdsa.h ../../include/openssl/engine.h
311tb_cipher.o: ../../include/openssl/err.h ../../include/openssl/evp.h 287tb_cipher.o: ../../include/openssl/err.h ../../include/openssl/evp.h
312tb_cipher.o: ../../include/openssl/fips.h ../../include/openssl/lhash.h 288tb_cipher.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
313tb_cipher.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h 289tb_cipher.o: ../../include/openssl/objects.h
314tb_cipher.o: ../../include/openssl/opensslconf.h 290tb_cipher.o: ../../include/openssl/opensslconf.h
315tb_cipher.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h 291tb_cipher.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
316tb_cipher.o: ../../include/openssl/pkcs7.h ../../include/openssl/safestack.h 292tb_cipher.o: ../../include/openssl/pkcs7.h ../../include/openssl/safestack.h
@@ -323,22 +299,22 @@ tb_dh.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
323tb_dh.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h 299tb_dh.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h
324tb_dh.o: ../../include/openssl/ecdh.h ../../include/openssl/ecdsa.h 300tb_dh.o: ../../include/openssl/ecdh.h ../../include/openssl/ecdsa.h
325tb_dh.o: ../../include/openssl/engine.h ../../include/openssl/err.h 301tb_dh.o: ../../include/openssl/engine.h ../../include/openssl/err.h
326tb_dh.o: ../../include/openssl/evp.h ../../include/openssl/fips.h 302tb_dh.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h
327tb_dh.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h 303tb_dh.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
328tb_dh.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h 304tb_dh.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
329tb_dh.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h 305tb_dh.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h
330tb_dh.o: ../../include/openssl/pkcs7.h ../../include/openssl/safestack.h 306tb_dh.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
331tb_dh.o: ../../include/openssl/sha.h ../../include/openssl/stack.h 307tb_dh.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
332tb_dh.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h 308tb_dh.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
333tb_dh.o: ../../include/openssl/x509_vfy.h ../cryptlib.h eng_int.h tb_dh.c 309tb_dh.o: ../cryptlib.h eng_int.h tb_dh.c
334tb_digest.o: ../../e_os.h ../../include/openssl/asn1.h 310tb_digest.o: ../../e_os.h ../../include/openssl/asn1.h
335tb_digest.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h 311tb_digest.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
336tb_digest.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h 312tb_digest.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
337tb_digest.o: ../../include/openssl/ec.h ../../include/openssl/ecdh.h 313tb_digest.o: ../../include/openssl/ec.h ../../include/openssl/ecdh.h
338tb_digest.o: ../../include/openssl/ecdsa.h ../../include/openssl/engine.h 314tb_digest.o: ../../include/openssl/ecdsa.h ../../include/openssl/engine.h
339tb_digest.o: ../../include/openssl/err.h ../../include/openssl/evp.h 315tb_digest.o: ../../include/openssl/err.h ../../include/openssl/evp.h
340tb_digest.o: ../../include/openssl/fips.h ../../include/openssl/lhash.h 316tb_digest.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
341tb_digest.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h 317tb_digest.o: ../../include/openssl/objects.h
342tb_digest.o: ../../include/openssl/opensslconf.h 318tb_digest.o: ../../include/openssl/opensslconf.h
343tb_digest.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h 319tb_digest.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
344tb_digest.o: ../../include/openssl/pkcs7.h ../../include/openssl/safestack.h 320tb_digest.o: ../../include/openssl/pkcs7.h ../../include/openssl/safestack.h
@@ -351,78 +327,89 @@ tb_dsa.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
351tb_dsa.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h 327tb_dsa.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h
352tb_dsa.o: ../../include/openssl/ecdh.h ../../include/openssl/ecdsa.h 328tb_dsa.o: ../../include/openssl/ecdh.h ../../include/openssl/ecdsa.h
353tb_dsa.o: ../../include/openssl/engine.h ../../include/openssl/err.h 329tb_dsa.o: ../../include/openssl/engine.h ../../include/openssl/err.h
354tb_dsa.o: ../../include/openssl/evp.h ../../include/openssl/fips.h 330tb_dsa.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h
355tb_dsa.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h 331tb_dsa.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
356tb_dsa.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h 332tb_dsa.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
357tb_dsa.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h 333tb_dsa.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h
358tb_dsa.o: ../../include/openssl/pkcs7.h ../../include/openssl/safestack.h 334tb_dsa.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
359tb_dsa.o: ../../include/openssl/sha.h ../../include/openssl/stack.h 335tb_dsa.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
360tb_dsa.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h 336tb_dsa.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
361tb_dsa.o: ../../include/openssl/x509_vfy.h ../cryptlib.h eng_int.h tb_dsa.c 337tb_dsa.o: ../cryptlib.h eng_int.h tb_dsa.c
362tb_ecdh.o: ../../e_os.h ../../include/openssl/asn1.h 338tb_ecdh.o: ../../e_os.h ../../include/openssl/asn1.h
363tb_ecdh.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h 339tb_ecdh.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
364tb_ecdh.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h 340tb_ecdh.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
365tb_ecdh.o: ../../include/openssl/ec.h ../../include/openssl/ecdh.h 341tb_ecdh.o: ../../include/openssl/ec.h ../../include/openssl/ecdh.h
366tb_ecdh.o: ../../include/openssl/ecdsa.h ../../include/openssl/engine.h 342tb_ecdh.o: ../../include/openssl/ecdsa.h ../../include/openssl/engine.h
367tb_ecdh.o: ../../include/openssl/err.h ../../include/openssl/evp.h 343tb_ecdh.o: ../../include/openssl/err.h ../../include/openssl/evp.h
368tb_ecdh.o: ../../include/openssl/fips.h ../../include/openssl/lhash.h 344tb_ecdh.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
369tb_ecdh.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h 345tb_ecdh.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
370tb_ecdh.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h 346tb_ecdh.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
371tb_ecdh.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h 347tb_ecdh.o: ../../include/openssl/pkcs7.h ../../include/openssl/safestack.h
372tb_ecdh.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h 348tb_ecdh.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
373tb_ecdh.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 349tb_ecdh.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h
374tb_ecdh.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h 350tb_ecdh.o: ../../include/openssl/x509_vfy.h ../cryptlib.h eng_int.h tb_ecdh.c
375tb_ecdh.o: ../cryptlib.h eng_int.h tb_ecdh.c
376tb_ecdsa.o: ../../e_os.h ../../include/openssl/asn1.h 351tb_ecdsa.o: ../../e_os.h ../../include/openssl/asn1.h
377tb_ecdsa.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h 352tb_ecdsa.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
378tb_ecdsa.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h 353tb_ecdsa.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
379tb_ecdsa.o: ../../include/openssl/ec.h ../../include/openssl/ecdh.h 354tb_ecdsa.o: ../../include/openssl/ec.h ../../include/openssl/ecdh.h
380tb_ecdsa.o: ../../include/openssl/ecdsa.h ../../include/openssl/engine.h 355tb_ecdsa.o: ../../include/openssl/ecdsa.h ../../include/openssl/engine.h
381tb_ecdsa.o: ../../include/openssl/err.h ../../include/openssl/evp.h 356tb_ecdsa.o: ../../include/openssl/err.h ../../include/openssl/evp.h
382tb_ecdsa.o: ../../include/openssl/fips.h ../../include/openssl/lhash.h 357tb_ecdsa.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
383tb_ecdsa.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h 358tb_ecdsa.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
384tb_ecdsa.o: ../../include/openssl/opensslconf.h
385tb_ecdsa.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h 359tb_ecdsa.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
386tb_ecdsa.o: ../../include/openssl/pkcs7.h ../../include/openssl/safestack.h 360tb_ecdsa.o: ../../include/openssl/pkcs7.h ../../include/openssl/safestack.h
387tb_ecdsa.o: ../../include/openssl/sha.h ../../include/openssl/stack.h 361tb_ecdsa.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
388tb_ecdsa.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h 362tb_ecdsa.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h
389tb_ecdsa.o: ../../include/openssl/x509_vfy.h ../cryptlib.h eng_int.h tb_ecdsa.c 363tb_ecdsa.o: ../../include/openssl/x509_vfy.h ../cryptlib.h eng_int.h tb_ecdsa.c
364tb_pkmeth.o: ../../e_os.h ../../include/openssl/asn1.h
365tb_pkmeth.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
366tb_pkmeth.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
367tb_pkmeth.o: ../../include/openssl/ec.h ../../include/openssl/ecdh.h
368tb_pkmeth.o: ../../include/openssl/ecdsa.h ../../include/openssl/engine.h
369tb_pkmeth.o: ../../include/openssl/err.h ../../include/openssl/evp.h
370tb_pkmeth.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
371tb_pkmeth.o: ../../include/openssl/objects.h
372tb_pkmeth.o: ../../include/openssl/opensslconf.h
373tb_pkmeth.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
374tb_pkmeth.o: ../../include/openssl/pkcs7.h ../../include/openssl/safestack.h
375tb_pkmeth.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
376tb_pkmeth.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h
377tb_pkmeth.o: ../../include/openssl/x509_vfy.h ../cryptlib.h eng_int.h
378tb_pkmeth.o: tb_pkmeth.c
390tb_rand.o: ../../e_os.h ../../include/openssl/asn1.h 379tb_rand.o: ../../e_os.h ../../include/openssl/asn1.h
391tb_rand.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h 380tb_rand.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
392tb_rand.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h 381tb_rand.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
393tb_rand.o: ../../include/openssl/ec.h ../../include/openssl/ecdh.h 382tb_rand.o: ../../include/openssl/ec.h ../../include/openssl/ecdh.h
394tb_rand.o: ../../include/openssl/ecdsa.h ../../include/openssl/engine.h 383tb_rand.o: ../../include/openssl/ecdsa.h ../../include/openssl/engine.h
395tb_rand.o: ../../include/openssl/err.h ../../include/openssl/evp.h 384tb_rand.o: ../../include/openssl/err.h ../../include/openssl/evp.h
396tb_rand.o: ../../include/openssl/fips.h ../../include/openssl/lhash.h 385tb_rand.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
397tb_rand.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h 386tb_rand.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
398tb_rand.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h 387tb_rand.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
399tb_rand.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h 388tb_rand.o: ../../include/openssl/pkcs7.h ../../include/openssl/safestack.h
400tb_rand.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h 389tb_rand.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
401tb_rand.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 390tb_rand.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h
402tb_rand.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h 391tb_rand.o: ../../include/openssl/x509_vfy.h ../cryptlib.h eng_int.h tb_rand.c
403tb_rand.o: ../cryptlib.h eng_int.h tb_rand.c
404tb_rsa.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h 392tb_rsa.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h
405tb_rsa.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 393tb_rsa.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
406tb_rsa.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h 394tb_rsa.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h
407tb_rsa.o: ../../include/openssl/ecdh.h ../../include/openssl/ecdsa.h 395tb_rsa.o: ../../include/openssl/ecdh.h ../../include/openssl/ecdsa.h
408tb_rsa.o: ../../include/openssl/engine.h ../../include/openssl/err.h 396tb_rsa.o: ../../include/openssl/engine.h ../../include/openssl/err.h
409tb_rsa.o: ../../include/openssl/evp.h ../../include/openssl/fips.h 397tb_rsa.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h
410tb_rsa.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h 398tb_rsa.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
411tb_rsa.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h 399tb_rsa.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
412tb_rsa.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h 400tb_rsa.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h
413tb_rsa.o: ../../include/openssl/pkcs7.h ../../include/openssl/safestack.h 401tb_rsa.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
414tb_rsa.o: ../../include/openssl/sha.h ../../include/openssl/stack.h 402tb_rsa.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
415tb_rsa.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h 403tb_rsa.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
416tb_rsa.o: ../../include/openssl/x509_vfy.h ../cryptlib.h eng_int.h tb_rsa.c 404tb_rsa.o: ../cryptlib.h eng_int.h tb_rsa.c
417tb_store.o: ../../e_os.h ../../include/openssl/asn1.h 405tb_store.o: ../../e_os.h ../../include/openssl/asn1.h
418tb_store.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h 406tb_store.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
419tb_store.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h 407tb_store.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
420tb_store.o: ../../include/openssl/ec.h ../../include/openssl/ecdh.h 408tb_store.o: ../../include/openssl/ec.h ../../include/openssl/ecdh.h
421tb_store.o: ../../include/openssl/ecdsa.h ../../include/openssl/engine.h 409tb_store.o: ../../include/openssl/ecdsa.h ../../include/openssl/engine.h
422tb_store.o: ../../include/openssl/err.h ../../include/openssl/evp.h 410tb_store.o: ../../include/openssl/err.h ../../include/openssl/evp.h
423tb_store.o: ../../include/openssl/fips.h ../../include/openssl/lhash.h 411tb_store.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
424tb_store.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h 412tb_store.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
425tb_store.o: ../../include/openssl/opensslconf.h
426tb_store.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h 413tb_store.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
427tb_store.o: ../../include/openssl/pkcs7.h ../../include/openssl/safestack.h 414tb_store.o: ../../include/openssl/pkcs7.h ../../include/openssl/safestack.h
428tb_store.o: ../../include/openssl/sha.h ../../include/openssl/stack.h 415tb_store.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
diff --git a/src/lib/libcrypto/engine/Makefile.ssl b/src/lib/libcrypto/engine/Makefile.ssl
deleted file mode 100644
index 30a4446ff9..0000000000
--- a/src/lib/libcrypto/engine/Makefile.ssl
+++ /dev/null
@@ -1,538 +0,0 @@
1#
2# OpenSSL/crypto/engine/Makefile
3#
4
5DIR= engine
6TOP= ../..
7CC= cc
8INCLUDES= -I.. -I$(TOP) -I../../include
9CFLAG=-g
10INSTALL_PREFIX=
11OPENSSLDIR= /usr/local/ssl
12INSTALLTOP=/usr/local/ssl
13MAKE= make -f Makefile.ssl
14MAKEDEPPROG= makedepend
15MAKEDEPEND= $(TOP)/util/domd $(TOP) -MD $(MAKEDEPPROG)
16MAKEFILE= Makefile.ssl
17AR= ar r
18
19CFLAGS= $(INCLUDES) $(CFLAG)
20
21GENERAL=Makefile
22TEST= enginetest.c
23APPS=
24
25LIB=$(TOP)/libcrypto.a
26LIBSRC= eng_err.c eng_lib.c eng_list.c eng_init.c eng_ctrl.c \
27 eng_table.c eng_pkey.c eng_fat.c eng_all.c \
28 tb_rsa.c tb_dsa.c tb_dh.c tb_rand.c tb_cipher.c tb_digest.c \
29 eng_openssl.c eng_dyn.c eng_cnf.c \
30 hw_atalla.c hw_cswift.c hw_ncipher.c hw_nuron.c hw_ubsec.c \
31 hw_cryptodev.c hw_aep.c hw_sureware.c hw_4758_cca.c
32LIBOBJ= eng_err.o eng_lib.o eng_list.o eng_init.o eng_ctrl.o \
33 eng_table.o eng_pkey.o eng_fat.o eng_all.o \
34 tb_rsa.o tb_dsa.o tb_dh.o tb_rand.o tb_cipher.o tb_digest.o \
35 eng_openssl.o eng_dyn.o eng_cnf.o \
36 hw_atalla.o hw_cswift.o hw_ncipher.o hw_nuron.o hw_ubsec.o \
37 hw_cryptodev.o hw_aep.o hw_sureware.o hw_4758_cca.o
38
39SRC= $(LIBSRC)
40
41EXHEADER= engine.h
42HEADER= $(EXHEADER)
43
44ALL= $(GENERAL) $(SRC) $(HEADER)
45
46top:
47 (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all)
48
49all: lib
50
51lib: $(LIBOBJ)
52 $(AR) $(LIB) $(LIBOBJ)
53 $(RANLIB) $(LIB) || echo Never mind.
54 @touch lib
55
56files:
57 $(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO
58
59links:
60 @sh $(TOP)/util/point.sh Makefile.ssl Makefile
61 @$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER)
62 @$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST)
63 @$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS)
64
65install:
66 @for i in $(EXHEADER) ; \
67 do \
68 (cp $$i $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i; \
69 chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i ); \
70 done;
71
72tags:
73 ctags $(SRC)
74
75errors:
76 $(PERL) $(TOP)/util/mkerr.pl -conf hw.ec \
77 -nostatic -staticloader -write hw_*.c
78
79tests:
80
81lint:
82 lint -DLINT $(INCLUDES) $(SRC)>fluff
83
84depend:
85 $(MAKEDEPEND) -- $(CFLAG) $(INCLUDES) $(DEPFLAG) -- $(PROGS) $(LIBSRC)
86
87dclean:
88 $(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
89 mv -f Makefile.new $(MAKEFILE)
90
91clean:
92 rm -f *.o */*.o *.obj lib tags core .pure .nfs* *.old *.bak fluff
93
94# DO NOT DELETE THIS LINE -- make depend depends on it.
95
96eng_all.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
97eng_all.o: ../../include/openssl/bn.h ../../include/openssl/crypto.h
98eng_all.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
99eng_all.o: ../../include/openssl/e_os2.h ../../include/openssl/engine.h
100eng_all.o: ../../include/openssl/err.h ../../include/openssl/lhash.h
101eng_all.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
102eng_all.o: ../../include/openssl/ossl_typ.h ../../include/openssl/rand.h
103eng_all.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
104eng_all.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
105eng_all.o: ../../include/openssl/ui.h eng_all.c eng_int.h
106eng_cnf.o: ../../e_os.h ../../include/openssl/asn1.h
107eng_cnf.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
108eng_cnf.o: ../../include/openssl/buffer.h ../../include/openssl/conf.h
109eng_cnf.o: ../../include/openssl/crypto.h ../../include/openssl/dh.h
110eng_cnf.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
111eng_cnf.o: ../../include/openssl/engine.h ../../include/openssl/err.h
112eng_cnf.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
113eng_cnf.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
114eng_cnf.o: ../../include/openssl/rand.h ../../include/openssl/rsa.h
115eng_cnf.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
116eng_cnf.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
117eng_cnf.o: ../cryptlib.h eng_cnf.c
118eng_ctrl.o: ../../e_os.h ../../include/openssl/asn1.h
119eng_ctrl.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
120eng_ctrl.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
121eng_ctrl.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
122eng_ctrl.o: ../../include/openssl/e_os2.h ../../include/openssl/engine.h
123eng_ctrl.o: ../../include/openssl/err.h ../../include/openssl/lhash.h
124eng_ctrl.o: ../../include/openssl/opensslconf.h
125eng_ctrl.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
126eng_ctrl.o: ../../include/openssl/rand.h ../../include/openssl/rsa.h
127eng_ctrl.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
128eng_ctrl.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
129eng_ctrl.o: ../cryptlib.h eng_ctrl.c eng_int.h
130eng_dyn.o: ../../e_os.h ../../include/openssl/asn1.h
131eng_dyn.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
132eng_dyn.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
133eng_dyn.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
134eng_dyn.o: ../../include/openssl/dso.h ../../include/openssl/e_os2.h
135eng_dyn.o: ../../include/openssl/engine.h ../../include/openssl/err.h
136eng_dyn.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
137eng_dyn.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
138eng_dyn.o: ../../include/openssl/rand.h ../../include/openssl/rsa.h
139eng_dyn.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
140eng_dyn.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
141eng_dyn.o: ../cryptlib.h eng_dyn.c eng_int.h
142eng_err.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
143eng_err.o: ../../include/openssl/bn.h ../../include/openssl/crypto.h
144eng_err.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
145eng_err.o: ../../include/openssl/e_os2.h ../../include/openssl/engine.h
146eng_err.o: ../../include/openssl/err.h ../../include/openssl/lhash.h
147eng_err.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
148eng_err.o: ../../include/openssl/ossl_typ.h ../../include/openssl/rand.h
149eng_err.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
150eng_err.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
151eng_err.o: ../../include/openssl/ui.h eng_err.c
152eng_fat.o: ../../e_os.h ../../include/openssl/asn1.h
153eng_fat.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
154eng_fat.o: ../../include/openssl/buffer.h ../../include/openssl/conf.h
155eng_fat.o: ../../include/openssl/crypto.h ../../include/openssl/dh.h
156eng_fat.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
157eng_fat.o: ../../include/openssl/engine.h ../../include/openssl/err.h
158eng_fat.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
159eng_fat.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
160eng_fat.o: ../../include/openssl/rand.h ../../include/openssl/rsa.h
161eng_fat.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
162eng_fat.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
163eng_fat.o: ../cryptlib.h eng_fat.c eng_int.h
164eng_init.o: ../../e_os.h ../../include/openssl/asn1.h
165eng_init.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
166eng_init.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
167eng_init.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
168eng_init.o: ../../include/openssl/e_os2.h ../../include/openssl/engine.h
169eng_init.o: ../../include/openssl/err.h ../../include/openssl/lhash.h
170eng_init.o: ../../include/openssl/opensslconf.h
171eng_init.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
172eng_init.o: ../../include/openssl/rand.h ../../include/openssl/rsa.h
173eng_init.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
174eng_init.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
175eng_init.o: ../cryptlib.h eng_init.c eng_int.h
176eng_lib.o: ../../e_os.h ../../include/openssl/asn1.h
177eng_lib.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
178eng_lib.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
179eng_lib.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
180eng_lib.o: ../../include/openssl/e_os2.h ../../include/openssl/engine.h
181eng_lib.o: ../../include/openssl/err.h ../../include/openssl/lhash.h
182eng_lib.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
183eng_lib.o: ../../include/openssl/ossl_typ.h ../../include/openssl/rand.h
184eng_lib.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
185eng_lib.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
186eng_lib.o: ../../include/openssl/ui.h ../cryptlib.h eng_int.h eng_lib.c
187eng_list.o: ../../e_os.h ../../include/openssl/asn1.h
188eng_list.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
189eng_list.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
190eng_list.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
191eng_list.o: ../../include/openssl/e_os2.h ../../include/openssl/engine.h
192eng_list.o: ../../include/openssl/err.h ../../include/openssl/lhash.h
193eng_list.o: ../../include/openssl/opensslconf.h
194eng_list.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
195eng_list.o: ../../include/openssl/rand.h ../../include/openssl/rsa.h
196eng_list.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
197eng_list.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
198eng_list.o: ../cryptlib.h eng_int.h eng_list.c
199eng_openssl.o: ../../e_os.h ../../include/openssl/aes.h
200eng_openssl.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
201eng_openssl.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
202eng_openssl.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
203eng_openssl.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
204eng_openssl.o: ../../include/openssl/des_old.h ../../include/openssl/dh.h
205eng_openssl.o: ../../include/openssl/dsa.h ../../include/openssl/dso.h
206eng_openssl.o: ../../include/openssl/e_os2.h ../../include/openssl/engine.h
207eng_openssl.o: ../../include/openssl/err.h ../../include/openssl/evp.h
208eng_openssl.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h
209eng_openssl.o: ../../include/openssl/md2.h ../../include/openssl/md4.h
210eng_openssl.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
211eng_openssl.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
212eng_openssl.o: ../../include/openssl/opensslconf.h
213eng_openssl.o: ../../include/openssl/opensslv.h
214eng_openssl.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pem.h
215eng_openssl.o: ../../include/openssl/pem2.h ../../include/openssl/pkcs7.h
216eng_openssl.o: ../../include/openssl/rand.h ../../include/openssl/rc2.h
217eng_openssl.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
218eng_openssl.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
219eng_openssl.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
220eng_openssl.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
221eng_openssl.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
222eng_openssl.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
223eng_openssl.o: ../cryptlib.h eng_openssl.c
224eng_pkey.o: ../../e_os.h ../../include/openssl/asn1.h
225eng_pkey.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
226eng_pkey.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
227eng_pkey.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
228eng_pkey.o: ../../include/openssl/e_os2.h ../../include/openssl/engine.h
229eng_pkey.o: ../../include/openssl/err.h ../../include/openssl/lhash.h
230eng_pkey.o: ../../include/openssl/opensslconf.h
231eng_pkey.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
232eng_pkey.o: ../../include/openssl/rand.h ../../include/openssl/rsa.h
233eng_pkey.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
234eng_pkey.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
235eng_pkey.o: ../cryptlib.h eng_int.h eng_pkey.c
236eng_table.o: ../../include/openssl/aes.h ../../include/openssl/asn1.h
237eng_table.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h
238eng_table.o: ../../include/openssl/bn.h ../../include/openssl/cast.h
239eng_table.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
240eng_table.o: ../../include/openssl/des_old.h ../../include/openssl/dh.h
241eng_table.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
242eng_table.o: ../../include/openssl/engine.h ../../include/openssl/err.h
243eng_table.o: ../../include/openssl/evp.h ../../include/openssl/idea.h
244eng_table.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h
245eng_table.o: ../../include/openssl/md4.h ../../include/openssl/md5.h
246eng_table.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h
247eng_table.o: ../../include/openssl/objects.h
248eng_table.o: ../../include/openssl/opensslconf.h
249eng_table.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
250eng_table.o: ../../include/openssl/rand.h ../../include/openssl/rc2.h
251eng_table.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
252eng_table.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
253eng_table.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
254eng_table.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
255eng_table.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
256eng_table.o: eng_int.h eng_table.c
257hw_4758_cca.o: ../../e_os.h ../../include/openssl/aes.h
258hw_4758_cca.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
259hw_4758_cca.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
260hw_4758_cca.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
261hw_4758_cca.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
262hw_4758_cca.o: ../../include/openssl/des_old.h ../../include/openssl/dh.h
263hw_4758_cca.o: ../../include/openssl/dsa.h ../../include/openssl/dso.h
264hw_4758_cca.o: ../../include/openssl/e_os2.h ../../include/openssl/engine.h
265hw_4758_cca.o: ../../include/openssl/err.h ../../include/openssl/evp.h
266hw_4758_cca.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h
267hw_4758_cca.o: ../../include/openssl/md2.h ../../include/openssl/md4.h
268hw_4758_cca.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
269hw_4758_cca.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
270hw_4758_cca.o: ../../include/openssl/opensslconf.h
271hw_4758_cca.o: ../../include/openssl/opensslv.h
272hw_4758_cca.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h
273hw_4758_cca.o: ../../include/openssl/rand.h ../../include/openssl/rc2.h
274hw_4758_cca.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
275hw_4758_cca.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
276hw_4758_cca.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
277hw_4758_cca.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
278hw_4758_cca.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
279hw_4758_cca.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
280hw_4758_cca.o: ../cryptlib.h hw_4758_cca.c hw_4758_cca_err.c hw_4758_cca_err.h
281hw_4758_cca.o: vendor_defns/hw_4758_cca.h
282hw_aep.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
283hw_aep.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
284hw_aep.o: ../../include/openssl/crypto.h ../../include/openssl/dh.h
285hw_aep.o: ../../include/openssl/dsa.h ../../include/openssl/dso.h
286hw_aep.o: ../../include/openssl/e_os2.h ../../include/openssl/engine.h
287hw_aep.o: ../../include/openssl/err.h ../../include/openssl/lhash.h
288hw_aep.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
289hw_aep.o: ../../include/openssl/ossl_typ.h ../../include/openssl/rand.h
290hw_aep.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
291hw_aep.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
292hw_aep.o: ../../include/openssl/ui.h hw_aep.c hw_aep_err.c hw_aep_err.h
293hw_aep.o: vendor_defns/aep.h
294hw_atalla.o: ../../e_os.h ../../include/openssl/asn1.h
295hw_atalla.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
296hw_atalla.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
297hw_atalla.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
298hw_atalla.o: ../../include/openssl/dso.h ../../include/openssl/e_os2.h
299hw_atalla.o: ../../include/openssl/engine.h ../../include/openssl/err.h
300hw_atalla.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
301hw_atalla.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
302hw_atalla.o: ../../include/openssl/rand.h ../../include/openssl/rsa.h
303hw_atalla.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
304hw_atalla.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
305hw_atalla.o: ../cryptlib.h hw_atalla.c hw_atalla_err.c hw_atalla_err.h
306hw_atalla.o: vendor_defns/atalla.h
307hw_cryptodev.o: ../../include/openssl/aes.h ../../include/openssl/asn1.h
308hw_cryptodev.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h
309hw_cryptodev.o: ../../include/openssl/bn.h ../../include/openssl/cast.h
310hw_cryptodev.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
311hw_cryptodev.o: ../../include/openssl/des_old.h ../../include/openssl/dh.h
312hw_cryptodev.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
313hw_cryptodev.o: ../../include/openssl/engine.h ../../include/openssl/err.h
314hw_cryptodev.o: ../../include/openssl/evp.h ../../include/openssl/idea.h
315hw_cryptodev.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h
316hw_cryptodev.o: ../../include/openssl/md4.h ../../include/openssl/md5.h
317hw_cryptodev.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h
318hw_cryptodev.o: ../../include/openssl/objects.h
319hw_cryptodev.o: ../../include/openssl/opensslconf.h
320hw_cryptodev.o: ../../include/openssl/opensslv.h
321hw_cryptodev.o: ../../include/openssl/ossl_typ.h ../../include/openssl/rand.h
322hw_cryptodev.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h
323hw_cryptodev.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h
324hw_cryptodev.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
325hw_cryptodev.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
326hw_cryptodev.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
327hw_cryptodev.o: ../../include/openssl/ui_compat.h hw_cryptodev.c
328hw_cswift.o: ../../e_os.h ../../include/openssl/asn1.h
329hw_cswift.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
330hw_cswift.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
331hw_cswift.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
332hw_cswift.o: ../../include/openssl/dso.h ../../include/openssl/e_os2.h
333hw_cswift.o: ../../include/openssl/engine.h ../../include/openssl/err.h
334hw_cswift.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
335hw_cswift.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
336hw_cswift.o: ../../include/openssl/rand.h ../../include/openssl/rsa.h
337hw_cswift.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
338hw_cswift.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
339hw_cswift.o: ../cryptlib.h hw_cswift.c hw_cswift_err.c hw_cswift_err.h
340hw_cswift.o: vendor_defns/cswift.h
341hw_ncipher.o: ../../e_os.h ../../include/openssl/aes.h
342hw_ncipher.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
343hw_ncipher.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
344hw_ncipher.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
345hw_ncipher.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
346hw_ncipher.o: ../../include/openssl/des_old.h ../../include/openssl/dh.h
347hw_ncipher.o: ../../include/openssl/dsa.h ../../include/openssl/dso.h
348hw_ncipher.o: ../../include/openssl/e_os2.h ../../include/openssl/engine.h
349hw_ncipher.o: ../../include/openssl/err.h ../../include/openssl/evp.h
350hw_ncipher.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h
351hw_ncipher.o: ../../include/openssl/md2.h ../../include/openssl/md4.h
352hw_ncipher.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
353hw_ncipher.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
354hw_ncipher.o: ../../include/openssl/opensslconf.h
355hw_ncipher.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
356hw_ncipher.o: ../../include/openssl/pem.h ../../include/openssl/pem2.h
357hw_ncipher.o: ../../include/openssl/pkcs7.h ../../include/openssl/rand.h
358hw_ncipher.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h
359hw_ncipher.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h
360hw_ncipher.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
361hw_ncipher.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
362hw_ncipher.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
363hw_ncipher.o: ../../include/openssl/ui_compat.h ../../include/openssl/x509.h
364hw_ncipher.o: ../../include/openssl/x509_vfy.h ../cryptlib.h hw_ncipher.c
365hw_ncipher.o: hw_ncipher_err.c hw_ncipher_err.h vendor_defns/hwcryptohook.h
366hw_nuron.o: ../../e_os.h ../../include/openssl/asn1.h
367hw_nuron.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
368hw_nuron.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
369hw_nuron.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
370hw_nuron.o: ../../include/openssl/dso.h ../../include/openssl/e_os2.h
371hw_nuron.o: ../../include/openssl/engine.h ../../include/openssl/err.h
372hw_nuron.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
373hw_nuron.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
374hw_nuron.o: ../../include/openssl/rand.h ../../include/openssl/rsa.h
375hw_nuron.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
376hw_nuron.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
377hw_nuron.o: ../cryptlib.h hw_nuron.c hw_nuron_err.c hw_nuron_err.h
378hw_sureware.o: ../../e_os.h ../../include/openssl/aes.h
379hw_sureware.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
380hw_sureware.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
381hw_sureware.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
382hw_sureware.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
383hw_sureware.o: ../../include/openssl/des_old.h ../../include/openssl/dh.h
384hw_sureware.o: ../../include/openssl/dsa.h ../../include/openssl/dso.h
385hw_sureware.o: ../../include/openssl/e_os2.h ../../include/openssl/engine.h
386hw_sureware.o: ../../include/openssl/err.h ../../include/openssl/evp.h
387hw_sureware.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h
388hw_sureware.o: ../../include/openssl/md2.h ../../include/openssl/md4.h
389hw_sureware.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
390hw_sureware.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
391hw_sureware.o: ../../include/openssl/opensslconf.h
392hw_sureware.o: ../../include/openssl/opensslv.h
393hw_sureware.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pem.h
394hw_sureware.o: ../../include/openssl/pem2.h ../../include/openssl/pkcs7.h
395hw_sureware.o: ../../include/openssl/rand.h ../../include/openssl/rc2.h
396hw_sureware.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
397hw_sureware.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
398hw_sureware.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
399hw_sureware.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
400hw_sureware.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
401hw_sureware.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
402hw_sureware.o: ../cryptlib.h eng_int.h engine.h hw_sureware.c hw_sureware_err.c
403hw_sureware.o: hw_sureware_err.h vendor_defns/sureware.h
404hw_ubsec.o: ../../e_os.h ../../include/openssl/asn1.h
405hw_ubsec.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
406hw_ubsec.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
407hw_ubsec.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
408hw_ubsec.o: ../../include/openssl/dso.h ../../include/openssl/e_os2.h
409hw_ubsec.o: ../../include/openssl/engine.h ../../include/openssl/err.h
410hw_ubsec.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
411hw_ubsec.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
412hw_ubsec.o: ../../include/openssl/rand.h ../../include/openssl/rsa.h
413hw_ubsec.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
414hw_ubsec.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
415hw_ubsec.o: ../cryptlib.h hw_ubsec.c hw_ubsec_err.c hw_ubsec_err.h
416hw_ubsec.o: vendor_defns/hw_ubsec.h
417tb_cipher.o: ../../include/openssl/aes.h ../../include/openssl/asn1.h
418tb_cipher.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h
419tb_cipher.o: ../../include/openssl/bn.h ../../include/openssl/cast.h
420tb_cipher.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
421tb_cipher.o: ../../include/openssl/des_old.h ../../include/openssl/dh.h
422tb_cipher.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
423tb_cipher.o: ../../include/openssl/engine.h ../../include/openssl/err.h
424tb_cipher.o: ../../include/openssl/evp.h ../../include/openssl/idea.h
425tb_cipher.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h
426tb_cipher.o: ../../include/openssl/md4.h ../../include/openssl/md5.h
427tb_cipher.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h
428tb_cipher.o: ../../include/openssl/objects.h
429tb_cipher.o: ../../include/openssl/opensslconf.h
430tb_cipher.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
431tb_cipher.o: ../../include/openssl/rand.h ../../include/openssl/rc2.h
432tb_cipher.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
433tb_cipher.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
434tb_cipher.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
435tb_cipher.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
436tb_cipher.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
437tb_cipher.o: eng_int.h tb_cipher.c
438tb_dh.o: ../../include/openssl/aes.h ../../include/openssl/asn1.h
439tb_dh.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h
440tb_dh.o: ../../include/openssl/bn.h ../../include/openssl/cast.h
441tb_dh.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
442tb_dh.o: ../../include/openssl/des_old.h ../../include/openssl/dh.h
443tb_dh.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
444tb_dh.o: ../../include/openssl/engine.h ../../include/openssl/err.h
445tb_dh.o: ../../include/openssl/evp.h ../../include/openssl/idea.h
446tb_dh.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h
447tb_dh.o: ../../include/openssl/md4.h ../../include/openssl/md5.h
448tb_dh.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h
449tb_dh.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
450tb_dh.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
451tb_dh.o: ../../include/openssl/rand.h ../../include/openssl/rc2.h
452tb_dh.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
453tb_dh.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
454tb_dh.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
455tb_dh.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
456tb_dh.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h eng_int.h
457tb_dh.o: tb_dh.c
458tb_digest.o: ../../include/openssl/aes.h ../../include/openssl/asn1.h
459tb_digest.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h
460tb_digest.o: ../../include/openssl/bn.h ../../include/openssl/cast.h
461tb_digest.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
462tb_digest.o: ../../include/openssl/des_old.h ../../include/openssl/dh.h
463tb_digest.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
464tb_digest.o: ../../include/openssl/engine.h ../../include/openssl/err.h
465tb_digest.o: ../../include/openssl/evp.h ../../include/openssl/idea.h
466tb_digest.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h
467tb_digest.o: ../../include/openssl/md4.h ../../include/openssl/md5.h
468tb_digest.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h
469tb_digest.o: ../../include/openssl/objects.h
470tb_digest.o: ../../include/openssl/opensslconf.h
471tb_digest.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
472tb_digest.o: ../../include/openssl/rand.h ../../include/openssl/rc2.h
473tb_digest.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
474tb_digest.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
475tb_digest.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
476tb_digest.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
477tb_digest.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
478tb_digest.o: eng_int.h tb_digest.c
479tb_dsa.o: ../../include/openssl/aes.h ../../include/openssl/asn1.h
480tb_dsa.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h
481tb_dsa.o: ../../include/openssl/bn.h ../../include/openssl/cast.h
482tb_dsa.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
483tb_dsa.o: ../../include/openssl/des_old.h ../../include/openssl/dh.h
484tb_dsa.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
485tb_dsa.o: ../../include/openssl/engine.h ../../include/openssl/err.h
486tb_dsa.o: ../../include/openssl/evp.h ../../include/openssl/idea.h
487tb_dsa.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h
488tb_dsa.o: ../../include/openssl/md4.h ../../include/openssl/md5.h
489tb_dsa.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h
490tb_dsa.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
491tb_dsa.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
492tb_dsa.o: ../../include/openssl/rand.h ../../include/openssl/rc2.h
493tb_dsa.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
494tb_dsa.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
495tb_dsa.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
496tb_dsa.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
497tb_dsa.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
498tb_dsa.o: eng_int.h tb_dsa.c
499tb_rand.o: ../../include/openssl/aes.h ../../include/openssl/asn1.h
500tb_rand.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h
501tb_rand.o: ../../include/openssl/bn.h ../../include/openssl/cast.h
502tb_rand.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
503tb_rand.o: ../../include/openssl/des_old.h ../../include/openssl/dh.h
504tb_rand.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
505tb_rand.o: ../../include/openssl/engine.h ../../include/openssl/err.h
506tb_rand.o: ../../include/openssl/evp.h ../../include/openssl/idea.h
507tb_rand.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h
508tb_rand.o: ../../include/openssl/md4.h ../../include/openssl/md5.h
509tb_rand.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h
510tb_rand.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
511tb_rand.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
512tb_rand.o: ../../include/openssl/rand.h ../../include/openssl/rc2.h
513tb_rand.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
514tb_rand.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
515tb_rand.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
516tb_rand.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
517tb_rand.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
518tb_rand.o: eng_int.h tb_rand.c
519tb_rsa.o: ../../include/openssl/aes.h ../../include/openssl/asn1.h
520tb_rsa.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h
521tb_rsa.o: ../../include/openssl/bn.h ../../include/openssl/cast.h
522tb_rsa.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
523tb_rsa.o: ../../include/openssl/des_old.h ../../include/openssl/dh.h
524tb_rsa.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
525tb_rsa.o: ../../include/openssl/engine.h ../../include/openssl/err.h
526tb_rsa.o: ../../include/openssl/evp.h ../../include/openssl/idea.h
527tb_rsa.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h
528tb_rsa.o: ../../include/openssl/md4.h ../../include/openssl/md5.h
529tb_rsa.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h
530tb_rsa.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
531tb_rsa.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
532tb_rsa.o: ../../include/openssl/rand.h ../../include/openssl/rc2.h
533tb_rsa.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
534tb_rsa.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
535tb_rsa.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
536tb_rsa.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
537tb_rsa.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
538tb_rsa.o: eng_int.h tb_rsa.c
diff --git a/src/lib/libcrypto/engine/eng_all.c b/src/lib/libcrypto/engine/eng_all.c
index 69e54f461e..79d1f2beff 100644
--- a/src/lib/libcrypto/engine/eng_all.c
+++ b/src/lib/libcrypto/engine/eng_all.c
@@ -61,15 +61,15 @@
61 61
62void ENGINE_load_builtin_engines(void) 62void ENGINE_load_builtin_engines(void)
63 { 63 {
64#if 0
64 /* There's no longer any need for an "openssl" ENGINE unless, one day, 65 /* There's no longer any need for an "openssl" ENGINE unless, one day,
65 * it is the *only* way for standard builtin implementations to be be 66 * it is the *only* way for standard builtin implementations to be be
66 * accessed (ie. it would be possible to statically link binaries with 67 * accessed (ie. it would be possible to statically link binaries with
67 * *no* builtin implementations). */ 68 * *no* builtin implementations). */
68#if 0
69 ENGINE_load_openssl(); 69 ENGINE_load_openssl();
70#endif 70#endif
71#if !defined(OPENSSL_NO_HW) && !defined(OPENSSL_NO_HW_PADLOCK) 71#if !defined(OPENSSL_NO_HW) && (defined(__OpenBSD__) || defined(__FreeBSD__) || defined(HAVE_CRYPTODEV))
72 ENGINE_load_padlock(); 72 ENGINE_load_cryptodev();
73#endif 73#endif
74 74
75#if !defined(OPENSSL_NO_HW) && !defined(OPENSSL_NO_HW_AESNI) 75#if !defined(OPENSSL_NO_HW) && !defined(OPENSSL_NO_HW_AESNI)
@@ -103,14 +103,15 @@ void ENGINE_load_builtin_engines(void)
103#ifndef OPENSSL_NO_HW_UBSEC 103#ifndef OPENSSL_NO_HW_UBSEC
104 ENGINE_load_ubsec(); 104 ENGINE_load_ubsec();
105#endif 105#endif
106#ifndef OPENSSL_NO_HW_PADLOCK
107 ENGINE_load_padlock();
106#endif 108#endif
107#if !defined(OPENSSL_NO_GMP) && !defined(OPENSSL_NO_HW_GMP)
108 ENGINE_load_gmp();
109#endif 109#endif
110#ifndef OPENSSL_NO_GOST
111 ENGINE_load_gost();
110#endif 112#endif
111#ifndef OPENSSL_NO_HW 113#ifndef OPENSSL_NO_GMP
112#if defined(__OpenBSD__) || defined(__FreeBSD__) 114 ENGINE_load_gmp();
113 ENGINE_load_cryptodev();
114#endif 115#endif
115#if defined(OPENSSL_SYS_WIN32) && !defined(OPENSSL_NO_CAPIENG) 116#if defined(OPENSSL_SYS_WIN32) && !defined(OPENSSL_NO_CAPIENG)
116 ENGINE_load_capi(); 117 ENGINE_load_capi();
@@ -118,7 +119,7 @@ void ENGINE_load_builtin_engines(void)
118#endif 119#endif
119 } 120 }
120 121
121#if defined(__OpenBSD__) || defined(__FreeBSD__) 122#if defined(__OpenBSD__) || defined(__FreeBSD__) || defined(HAVE_CRYPTODEV)
122void ENGINE_setup_bsd_cryptodev(void) { 123void ENGINE_setup_bsd_cryptodev(void) {
123 static int bsd_cryptodev_default_loaded = 0; 124 static int bsd_cryptodev_default_loaded = 0;
124 if (!bsd_cryptodev_default_loaded) { 125 if (!bsd_cryptodev_default_loaded) {
diff --git a/src/lib/libcrypto/engine/eng_cnf.c b/src/lib/libcrypto/engine/eng_cnf.c
index 08066cea59..95c4070015 100644
--- a/src/lib/libcrypto/engine/eng_cnf.c
+++ b/src/lib/libcrypto/engine/eng_cnf.c
@@ -95,7 +95,7 @@ static int int_engine_configure(char *name, char *value, const CONF *cnf)
95 int ret = 0; 95 int ret = 0;
96 long do_init = -1; 96 long do_init = -1;
97 STACK_OF(CONF_VALUE) *ecmds; 97 STACK_OF(CONF_VALUE) *ecmds;
98 CONF_VALUE *ecmd; 98 CONF_VALUE *ecmd = NULL;
99 char *ctrlname, *ctrlvalue; 99 char *ctrlname, *ctrlvalue;
100 ENGINE *e = NULL; 100 ENGINE *e = NULL;
101 int soft = 0; 101 int soft = 0;
@@ -157,7 +157,7 @@ static int int_engine_configure(char *name, char *value, const CONF *cnf)
157 return 1; 157 return 1;
158 } 158 }
159 if (!e) 159 if (!e)
160 return 0; 160 goto err;
161 } 161 }
162 /* Allow "EMPTY" to mean no value: this allows a valid 162 /* Allow "EMPTY" to mean no value: this allows a valid
163 * "value" to be passed to ctrls of type NO_INPUT 163 * "value" to be passed to ctrls of type NO_INPUT
@@ -186,16 +186,27 @@ static int int_engine_configure(char *name, char *value, const CONF *cnf)
186 } 186 }
187 else if (!ENGINE_ctrl_cmd_string(e, 187 else if (!ENGINE_ctrl_cmd_string(e,
188 ctrlname, ctrlvalue, 0)) 188 ctrlname, ctrlvalue, 0))
189 return 0; 189 goto err;
190 } 190 }
191 191
192 192
193 193
194 } 194 }
195 if (e && (do_init == -1) && !int_engine_init(e)) 195 if (e && (do_init == -1) && !int_engine_init(e))
196 {
197 ecmd = NULL;
196 goto err; 198 goto err;
199 }
197 ret = 1; 200 ret = 1;
198 err: 201 err:
202 if (ret != 1)
203 {
204 ENGINEerr(ENGINE_F_INT_ENGINE_CONFIGURE, ENGINE_R_ENGINE_CONFIGURATION_ERROR);
205 if (ecmd)
206 ERR_add_error_data(6, "section=", ecmd->section,
207 ", name=", ecmd->name,
208 ", value=", ecmd->value);
209 }
199 if (e) 210 if (e)
200 ENGINE_free(e); 211 ENGINE_free(e);
201 return ret; 212 return ret;
diff --git a/src/lib/libcrypto/engine/eng_cryptodev.c b/src/lib/libcrypto/engine/eng_cryptodev.c
index 52f4ca3901..f04c79151b 100644
--- a/src/lib/libcrypto/engine/eng_cryptodev.c
+++ b/src/lib/libcrypto/engine/eng_cryptodev.c
@@ -32,7 +32,7 @@
32#include <openssl/bn.h> 32#include <openssl/bn.h>
33 33
34#if (defined(__unix__) || defined(unix)) && !defined(USG) && \ 34#if (defined(__unix__) || defined(unix)) && !defined(USG) && \
35 (defined(OpenBSD) || defined(__FreeBSD__)) 35 (defined(__OpenBSD__) || defined(__FreeBSD__))
36#include <sys/param.h> 36#include <sys/param.h>
37# if (OpenBSD >= 200112) || ((__FreeBSD_version >= 470101 && __FreeBSD_version < 500000) || __FreeBSD_version >= 500041) 37# if (OpenBSD >= 200112) || ((__FreeBSD_version >= 470101 && __FreeBSD_version < 500000) || __FreeBSD_version >= 500041)
38# define HAVE_CRYPTODEV 38# define HAVE_CRYPTODEV
diff --git a/src/lib/libcrypto/engine/eng_ctrl.c b/src/lib/libcrypto/engine/eng_ctrl.c
index 95b6b455aa..5ce25d92ec 100644
--- a/src/lib/libcrypto/engine/eng_ctrl.c
+++ b/src/lib/libcrypto/engine/eng_ctrl.c
@@ -280,7 +280,7 @@ int ENGINE_ctrl_cmd(ENGINE *e, const char *cmd_name,
280 } 280 }
281 /* Force the result of the control command to 0 or 1, for the reasons 281 /* Force the result of the control command to 0 or 1, for the reasons
282 * mentioned before. */ 282 * mentioned before. */
283 if (ENGINE_ctrl(e, num, i, p, f)) 283 if (ENGINE_ctrl(e, num, i, p, f) > 0)
284 return 1; 284 return 1;
285 return 0; 285 return 0;
286 } 286 }
@@ -345,7 +345,7 @@ int ENGINE_ctrl_cmd_string(ENGINE *e, const char *cmd_name, const char *arg,
345 * usage of these commands is consistent across applications and 345 * usage of these commands is consistent across applications and
346 * that certain applications don't understand it one way, and 346 * that certain applications don't understand it one way, and
347 * others another. */ 347 * others another. */
348 if(ENGINE_ctrl(e, num, 0, (void *)arg, NULL)) 348 if(ENGINE_ctrl(e, num, 0, (void *)arg, NULL) > 0)
349 return 1; 349 return 1;
350 return 0; 350 return 0;
351 } 351 }
@@ -360,7 +360,7 @@ int ENGINE_ctrl_cmd_string(ENGINE *e, const char *cmd_name, const char *arg,
360 if(flags & ENGINE_CMD_FLAG_STRING) 360 if(flags & ENGINE_CMD_FLAG_STRING)
361 { 361 {
362 /* Same explanation as above */ 362 /* Same explanation as above */
363 if(ENGINE_ctrl(e, num, 0, (void *)arg, NULL)) 363 if(ENGINE_ctrl(e, num, 0, (void *)arg, NULL) > 0)
364 return 1; 364 return 1;
365 return 0; 365 return 0;
366 } 366 }
@@ -383,7 +383,7 @@ int ENGINE_ctrl_cmd_string(ENGINE *e, const char *cmd_name, const char *arg,
383 } 383 }
384 /* Force the result of the control command to 0 or 1, for the reasons 384 /* Force the result of the control command to 0 or 1, for the reasons
385 * mentioned before. */ 385 * mentioned before. */
386 if(ENGINE_ctrl(e, num, l, NULL, NULL)) 386 if(ENGINE_ctrl(e, num, l, NULL, NULL) > 0)
387 return 1; 387 return 1;
388 return 0; 388 return 0;
389 } 389 }
diff --git a/src/lib/libcrypto/engine/eng_dyn.c b/src/lib/libcrypto/engine/eng_dyn.c
index acb30c34d8..807da7a5eb 100644
--- a/src/lib/libcrypto/engine/eng_dyn.c
+++ b/src/lib/libcrypto/engine/eng_dyn.c
@@ -146,14 +146,14 @@ struct st_dynamic_data_ctx
146 * 'dirs' for loading. Default is to use 'dirs' as a fallback. */ 146 * 'dirs' for loading. Default is to use 'dirs' as a fallback. */
147 int dir_load; 147 int dir_load;
148 /* A stack of directories from which ENGINEs could be loaded */ 148 /* A stack of directories from which ENGINEs could be loaded */
149 STACK *dirs; 149 STACK_OF(OPENSSL_STRING) *dirs;
150 }; 150 };
151 151
152/* This is the "ex_data" index we obtain and reserve for use with our context 152/* This is the "ex_data" index we obtain and reserve for use with our context
153 * structure. */ 153 * structure. */
154static int dynamic_ex_data_idx = -1; 154static int dynamic_ex_data_idx = -1;
155 155
156static void int_free_str(void *s) { OPENSSL_free(s); } 156static void int_free_str(char *s) { OPENSSL_free(s); }
157/* Because our ex_data element may or may not get allocated depending on whether 157/* Because our ex_data element may or may not get allocated depending on whether
158 * a "first-use" occurs before the ENGINE is freed, we have a memory leak 158 * a "first-use" occurs before the ENGINE is freed, we have a memory leak
159 * problem to solve. We can't declare a "new" handler for the ex_data as we 159 * problem to solve. We can't declare a "new" handler for the ex_data as we
@@ -174,7 +174,7 @@ static void dynamic_data_ctx_free_func(void *parent, void *ptr,
174 if(ctx->engine_id) 174 if(ctx->engine_id)
175 OPENSSL_free((void*)ctx->engine_id); 175 OPENSSL_free((void*)ctx->engine_id);
176 if(ctx->dirs) 176 if(ctx->dirs)
177 sk_pop_free(ctx->dirs, int_free_str); 177 sk_OPENSSL_STRING_pop_free(ctx->dirs, int_free_str);
178 OPENSSL_free(ctx); 178 OPENSSL_free(ctx);
179 } 179 }
180 } 180 }
@@ -203,7 +203,7 @@ static int dynamic_set_data_ctx(ENGINE *e, dynamic_data_ctx **ctx)
203 c->DYNAMIC_F1 = "v_check"; 203 c->DYNAMIC_F1 = "v_check";
204 c->DYNAMIC_F2 = "bind_engine"; 204 c->DYNAMIC_F2 = "bind_engine";
205 c->dir_load = 1; 205 c->dir_load = 1;
206 c->dirs = sk_new_null(); 206 c->dirs = sk_OPENSSL_STRING_new_null();
207 if(!c->dirs) 207 if(!c->dirs)
208 { 208 {
209 ENGINEerr(ENGINE_F_DYNAMIC_SET_DATA_CTX,ERR_R_MALLOC_FAILURE); 209 ENGINEerr(ENGINE_F_DYNAMIC_SET_DATA_CTX,ERR_R_MALLOC_FAILURE);
@@ -393,7 +393,7 @@ static int dynamic_ctrl(ENGINE *e, int cmd, long i, void *p, void (*f)(void))
393 ERR_R_MALLOC_FAILURE); 393 ERR_R_MALLOC_FAILURE);
394 return 0; 394 return 0;
395 } 395 }
396 sk_insert(ctx->dirs, tmp_str, -1); 396 sk_OPENSSL_STRING_insert(ctx->dirs, tmp_str, -1);
397 } 397 }
398 return 1; 398 return 1;
399 default: 399 default:
@@ -411,11 +411,11 @@ static int int_load(dynamic_data_ctx *ctx)
411 ctx->DYNAMIC_LIBNAME, NULL, 0)) != NULL) 411 ctx->DYNAMIC_LIBNAME, NULL, 0)) != NULL)
412 return 1; 412 return 1;
413 /* If we're not allowed to use 'dirs' or we have none, fail */ 413 /* If we're not allowed to use 'dirs' or we have none, fail */
414 if(!ctx->dir_load || ((num = sk_num(ctx->dirs)) < 1)) 414 if(!ctx->dir_load || (num = sk_OPENSSL_STRING_num(ctx->dirs)) < 1)
415 return 0; 415 return 0;
416 for(loop = 0; loop < num; loop++) 416 for(loop = 0; loop < num; loop++)
417 { 417 {
418 const char *s = sk_value(ctx->dirs, loop); 418 const char *s = sk_OPENSSL_STRING_value(ctx->dirs, loop);
419 char *merge = DSO_merge(ctx->dynamic_dso, ctx->DYNAMIC_LIBNAME, s); 419 char *merge = DSO_merge(ctx->dynamic_dso, ctx->DYNAMIC_LIBNAME, s);
420 if(!merge) 420 if(!merge)
421 return 0; 421 return 0;
diff --git a/src/lib/libcrypto/engine/eng_err.c b/src/lib/libcrypto/engine/eng_err.c
index 574ffbb5c0..81c70acfa8 100644
--- a/src/lib/libcrypto/engine/eng_err.c
+++ b/src/lib/libcrypto/engine/eng_err.c
@@ -1,6 +1,6 @@
1/* crypto/engine/eng_err.c */ 1/* crypto/engine/eng_err.c */
2/* ==================================================================== 2/* ====================================================================
3 * Copyright (c) 1999-2008 The OpenSSL Project. All rights reserved. 3 * Copyright (c) 1999-2010 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,8 @@ static ERR_STRING_DATA ENGINE_str_functs[]=
86{ERR_FUNC(ENGINE_F_ENGINE_GET_DEFAULT_TYPE), "ENGINE_GET_DEFAULT_TYPE"}, 86{ERR_FUNC(ENGINE_F_ENGINE_GET_DEFAULT_TYPE), "ENGINE_GET_DEFAULT_TYPE"},
87{ERR_FUNC(ENGINE_F_ENGINE_GET_DIGEST), "ENGINE_get_digest"}, 87{ERR_FUNC(ENGINE_F_ENGINE_GET_DIGEST), "ENGINE_get_digest"},
88{ERR_FUNC(ENGINE_F_ENGINE_GET_NEXT), "ENGINE_get_next"}, 88{ERR_FUNC(ENGINE_F_ENGINE_GET_NEXT), "ENGINE_get_next"},
89{ERR_FUNC(ENGINE_F_ENGINE_GET_PKEY_ASN1_METH), "ENGINE_get_pkey_asn1_meth"},
90{ERR_FUNC(ENGINE_F_ENGINE_GET_PKEY_METH), "ENGINE_get_pkey_meth"},
89{ERR_FUNC(ENGINE_F_ENGINE_GET_PREV), "ENGINE_get_prev"}, 91{ERR_FUNC(ENGINE_F_ENGINE_GET_PREV), "ENGINE_get_prev"},
90{ERR_FUNC(ENGINE_F_ENGINE_INIT), "ENGINE_init"}, 92{ERR_FUNC(ENGINE_F_ENGINE_INIT), "ENGINE_init"},
91{ERR_FUNC(ENGINE_F_ENGINE_LIST_ADD), "ENGINE_LIST_ADD"}, 93{ERR_FUNC(ENGINE_F_ENGINE_LIST_ADD), "ENGINE_LIST_ADD"},
@@ -124,6 +126,7 @@ static ERR_STRING_DATA ENGINE_str_reasons[]=
124{ERR_REASON(ENGINE_R_DSO_FAILURE) ,"DSO failure"}, 126{ERR_REASON(ENGINE_R_DSO_FAILURE) ,"DSO failure"},
125{ERR_REASON(ENGINE_R_DSO_NOT_FOUND) ,"dso not found"}, 127{ERR_REASON(ENGINE_R_DSO_NOT_FOUND) ,"dso not found"},
126{ERR_REASON(ENGINE_R_ENGINES_SECTION_ERROR),"engines section error"}, 128{ERR_REASON(ENGINE_R_ENGINES_SECTION_ERROR),"engines section error"},
129{ERR_REASON(ENGINE_R_ENGINE_CONFIGURATION_ERROR),"engine configuration error"},
127{ERR_REASON(ENGINE_R_ENGINE_IS_NOT_IN_LIST),"engine is not in the list"}, 130{ERR_REASON(ENGINE_R_ENGINE_IS_NOT_IN_LIST),"engine is not in the list"},
128{ERR_REASON(ENGINE_R_ENGINE_SECTION_ERROR),"engine section error"}, 131{ERR_REASON(ENGINE_R_ENGINE_SECTION_ERROR),"engine section error"},
129{ERR_REASON(ENGINE_R_FAILED_LOADING_PRIVATE_KEY),"failed loading private key"}, 132{ERR_REASON(ENGINE_R_FAILED_LOADING_PRIVATE_KEY),"failed loading private key"},
@@ -150,6 +153,7 @@ static ERR_STRING_DATA ENGINE_str_reasons[]=
150{ERR_REASON(ENGINE_R_RSA_NOT_IMPLEMENTED),"rsa not implemented"}, 153{ERR_REASON(ENGINE_R_RSA_NOT_IMPLEMENTED),"rsa not implemented"},
151{ERR_REASON(ENGINE_R_UNIMPLEMENTED_CIPHER),"unimplemented cipher"}, 154{ERR_REASON(ENGINE_R_UNIMPLEMENTED_CIPHER),"unimplemented cipher"},
152{ERR_REASON(ENGINE_R_UNIMPLEMENTED_DIGEST),"unimplemented digest"}, 155{ERR_REASON(ENGINE_R_UNIMPLEMENTED_DIGEST),"unimplemented digest"},
156{ERR_REASON(ENGINE_R_UNIMPLEMENTED_PUBLIC_KEY_METHOD),"unimplemented public key method"},
153{ERR_REASON(ENGINE_R_VERSION_INCOMPATIBILITY),"version incompatibility"}, 157{ERR_REASON(ENGINE_R_VERSION_INCOMPATIBILITY),"version incompatibility"},
154{0,NULL} 158{0,NULL}
155 }; 159 };
diff --git a/src/lib/libcrypto/engine/eng_fat.c b/src/lib/libcrypto/engine/eng_fat.c
index 27c1662f62..db66e62350 100644
--- a/src/lib/libcrypto/engine/eng_fat.c
+++ b/src/lib/libcrypto/engine/eng_fat.c
@@ -89,6 +89,12 @@ int ENGINE_set_default(ENGINE *e, unsigned int flags)
89#endif 89#endif
90 if((flags & ENGINE_METHOD_RAND) && !ENGINE_set_default_RAND(e)) 90 if((flags & ENGINE_METHOD_RAND) && !ENGINE_set_default_RAND(e))
91 return 0; 91 return 0;
92 if((flags & ENGINE_METHOD_PKEY_METHS)
93 && !ENGINE_set_default_pkey_meths(e))
94 return 0;
95 if((flags & ENGINE_METHOD_PKEY_ASN1_METHS)
96 && !ENGINE_set_default_pkey_asn1_meths(e))
97 return 0;
92 return 1; 98 return 1;
93 } 99 }
94 100
@@ -115,6 +121,13 @@ static int int_def_cb(const char *alg, int len, void *arg)
115 *pflags |= ENGINE_METHOD_CIPHERS; 121 *pflags |= ENGINE_METHOD_CIPHERS;
116 else if (!strncmp(alg, "DIGESTS", len)) 122 else if (!strncmp(alg, "DIGESTS", len))
117 *pflags |= ENGINE_METHOD_DIGESTS; 123 *pflags |= ENGINE_METHOD_DIGESTS;
124 else if (!strncmp(alg, "PKEY", len))
125 *pflags |=
126 ENGINE_METHOD_PKEY_METHS|ENGINE_METHOD_PKEY_ASN1_METHS;
127 else if (!strncmp(alg, "PKEY_CRYPTO", len))
128 *pflags |= ENGINE_METHOD_PKEY_METHS;
129 else if (!strncmp(alg, "PKEY_ASN1", len))
130 *pflags |= ENGINE_METHOD_PKEY_ASN1_METHS;
118 else 131 else
119 return 0; 132 return 0;
120 return 1; 133 return 1;
@@ -154,6 +167,7 @@ int ENGINE_register_complete(ENGINE *e)
154 ENGINE_register_ECDSA(e); 167 ENGINE_register_ECDSA(e);
155#endif 168#endif
156 ENGINE_register_RAND(e); 169 ENGINE_register_RAND(e);
170 ENGINE_register_pkey_meths(e);
157 return 1; 171 return 1;
158 } 172 }
159 173
diff --git a/src/lib/libcrypto/engine/eng_int.h b/src/lib/libcrypto/engine/eng_int.h
index a66f107a44..451ef8feb8 100644
--- a/src/lib/libcrypto/engine/eng_int.h
+++ b/src/lib/libcrypto/engine/eng_int.h
@@ -127,6 +127,8 @@ ENGINE *engine_table_select(ENGINE_TABLE **table, int nid);
127ENGINE *engine_table_select_tmp(ENGINE_TABLE **table, int nid, const char *f, int l); 127ENGINE *engine_table_select_tmp(ENGINE_TABLE **table, int nid, const char *f, int l);
128#define engine_table_select(t,n) engine_table_select_tmp(t,n,__FILE__,__LINE__) 128#define engine_table_select(t,n) engine_table_select_tmp(t,n,__FILE__,__LINE__)
129#endif 129#endif
130typedef void (engine_table_doall_cb)(int nid, STACK_OF(ENGINE) *sk, ENGINE *def, void *arg);
131void engine_table_doall(ENGINE_TABLE *table, engine_table_doall_cb *cb, void *arg);
130 132
131/* Internal versions of API functions that have control over locking. These are 133/* Internal versions of API functions that have control over locking. These are
132 * used between C files when functionality needs to be shared but the caller may 134 * used between C files when functionality needs to be shared but the caller may
@@ -143,6 +145,11 @@ void engine_set_all_null(ENGINE *e);
143/* NB: Bitwise OR-able values for the "flags" variable in ENGINE are now exposed 145/* NB: Bitwise OR-able values for the "flags" variable in ENGINE are now exposed
144 * in engine.h. */ 146 * in engine.h. */
145 147
148/* Free up dynamically allocated public key methods associated with ENGINE */
149
150void engine_pkey_meths_free(ENGINE *e);
151void engine_pkey_asn1_meths_free(ENGINE *e);
152
146/* This is a structure for storing implementations of various crypto 153/* This is a structure for storing implementations of various crypto
147 * algorithms and functions. */ 154 * algorithms and functions. */
148struct engine_st 155struct engine_st
@@ -160,7 +167,10 @@ struct engine_st
160 ENGINE_CIPHERS_PTR ciphers; 167 ENGINE_CIPHERS_PTR ciphers;
161 /* Digest handling is via this callback */ 168 /* Digest handling is via this callback */
162 ENGINE_DIGESTS_PTR digests; 169 ENGINE_DIGESTS_PTR digests;
163 170 /* Public key handling via this callback */
171 ENGINE_PKEY_METHS_PTR pkey_meths;
172 /* ASN1 public key handling via this callback */
173 ENGINE_PKEY_ASN1_METHS_PTR pkey_asn1_meths;
164 174
165 ENGINE_GEN_INT_FUNC_PTR destroy; 175 ENGINE_GEN_INT_FUNC_PTR destroy;
166 176
diff --git a/src/lib/libcrypto/engine/eng_lib.c b/src/lib/libcrypto/engine/eng_lib.c
index 5815b867f4..18a6664645 100644
--- a/src/lib/libcrypto/engine/eng_lib.c
+++ b/src/lib/libcrypto/engine/eng_lib.c
@@ -125,6 +125,9 @@ int engine_free_util(ENGINE *e, int locked)
125 abort(); 125 abort();
126 } 126 }
127#endif 127#endif
128 /* Free up any dynamically allocated public key methods */
129 engine_pkey_meths_free(e);
130 engine_pkey_asn1_meths_free(e);
128 /* Give the ENGINE a chance to do any structural cleanup corresponding 131 /* Give the ENGINE a chance to do any structural cleanup corresponding
129 * to allocation it did in its constructor (eg. unload error strings) */ 132 * to allocation it did in its constructor (eg. unload error strings) */
130 if(e->destroy) 133 if(e->destroy)
diff --git a/src/lib/libcrypto/engine/eng_list.c b/src/lib/libcrypto/engine/eng_list.c
index bd511944ba..27846edb1e 100644
--- a/src/lib/libcrypto/engine/eng_list.c
+++ b/src/lib/libcrypto/engine/eng_list.c
@@ -336,6 +336,7 @@ static void engine_cpy(ENGINE *dest, const ENGINE *src)
336 dest->store_meth = src->store_meth; 336 dest->store_meth = src->store_meth;
337 dest->ciphers = src->ciphers; 337 dest->ciphers = src->ciphers;
338 dest->digests = src->digests; 338 dest->digests = src->digests;
339 dest->pkey_meths = src->pkey_meths;
339 dest->destroy = src->destroy; 340 dest->destroy = src->destroy;
340 dest->init = src->init; 341 dest->init = src->init;
341 dest->finish = src->finish; 342 dest->finish = src->finish;
@@ -412,6 +413,7 @@ ENGINE *ENGINE_by_id(const char *id)
412 return iterator; 413 return iterator;
413 } 414 }
414notfound: 415notfound:
416 ENGINE_free(iterator);
415 ENGINEerr(ENGINE_F_ENGINE_BY_ID,ENGINE_R_NO_SUCH_ENGINE); 417 ENGINEerr(ENGINE_F_ENGINE_BY_ID,ENGINE_R_NO_SUCH_ENGINE);
416 ERR_add_error_data(2, "id=", id); 418 ERR_add_error_data(2, "id=", id);
417 return NULL; 419 return NULL;
diff --git a/src/lib/libcrypto/engine/eng_openssl.c b/src/lib/libcrypto/engine/eng_openssl.c
index 7c139ae2ef..9abb95cc22 100644
--- a/src/lib/libcrypto/engine/eng_openssl.c
+++ b/src/lib/libcrypto/engine/eng_openssl.c
@@ -238,7 +238,7 @@ static int test_rc4_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key,
238 return 1; 238 return 1;
239 } 239 }
240static int test_rc4_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, 240static int test_rc4_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
241 const unsigned char *in, unsigned int inl) 241 const unsigned char *in, size_t inl)
242 { 242 {
243#ifdef TEST_ENG_OPENSSL_RC4_P_CIPHER 243#ifdef TEST_ENG_OPENSSL_RC4_P_CIPHER
244 fprintf(stderr, "(TEST_ENG_OPENSSL_RC4) test_cipher() called\n"); 244 fprintf(stderr, "(TEST_ENG_OPENSSL_RC4) test_cipher() called\n");
diff --git a/src/lib/libcrypto/engine/eng_table.c b/src/lib/libcrypto/engine/eng_table.c
index 8879a267d1..4fde948185 100644
--- a/src/lib/libcrypto/engine/eng_table.c
+++ b/src/lib/libcrypto/engine/eng_table.c
@@ -70,12 +70,22 @@ typedef struct st_engine_pile
70 int uptodate; 70 int uptodate;
71 } ENGINE_PILE; 71 } ENGINE_PILE;
72 72
73DECLARE_LHASH_OF(ENGINE_PILE);
74
73/* The type exposed in eng_int.h */ 75/* The type exposed in eng_int.h */
74struct st_engine_table 76struct st_engine_table
75 { 77 {
76 LHASH piles; 78 LHASH_OF(ENGINE_PILE) piles;
77 }; /* ENGINE_TABLE */ 79 }; /* ENGINE_TABLE */
78 80
81
82typedef struct st_engine_pile_doall
83 {
84 engine_table_doall_cb *cb;
85 void *arg;
86 } ENGINE_PILE_DOALL;
87
88
79/* Global flags (ENGINE_TABLE_FLAG_***). */ 89/* Global flags (ENGINE_TABLE_FLAG_***). */
80static unsigned int table_flags = 0; 90static unsigned int table_flags = 0;
81 91
@@ -84,6 +94,7 @@ unsigned int ENGINE_get_table_flags(void)
84 { 94 {
85 return table_flags; 95 return table_flags;
86 } 96 }
97
87void ENGINE_set_table_flags(unsigned int flags) 98void ENGINE_set_table_flags(unsigned int flags)
88 { 99 {
89 table_flags = flags; 100 table_flags = flags;
@@ -94,19 +105,21 @@ static unsigned long engine_pile_hash(const ENGINE_PILE *c)
94 { 105 {
95 return c->nid; 106 return c->nid;
96 } 107 }
108
97static int engine_pile_cmp(const ENGINE_PILE *a, const ENGINE_PILE *b) 109static int engine_pile_cmp(const ENGINE_PILE *a, const ENGINE_PILE *b)
98 { 110 {
99 return a->nid - b->nid; 111 return a->nid - b->nid;
100 } 112 }
101static IMPLEMENT_LHASH_HASH_FN(engine_pile_hash, const ENGINE_PILE *) 113static IMPLEMENT_LHASH_HASH_FN(engine_pile, ENGINE_PILE)
102static IMPLEMENT_LHASH_COMP_FN(engine_pile_cmp, const ENGINE_PILE *) 114static IMPLEMENT_LHASH_COMP_FN(engine_pile, ENGINE_PILE)
115
103static int int_table_check(ENGINE_TABLE **t, int create) 116static int int_table_check(ENGINE_TABLE **t, int create)
104 { 117 {
105 LHASH *lh; 118 LHASH_OF(ENGINE_PILE) *lh;
119
106 if(*t) return 1; 120 if(*t) return 1;
107 if(!create) return 0; 121 if(!create) return 0;
108 if((lh = lh_new(LHASH_HASH_FN(engine_pile_hash), 122 if((lh = lh_ENGINE_PILE_new()) == NULL)
109 LHASH_COMP_FN(engine_pile_cmp))) == NULL)
110 return 0; 123 return 0;
111 *t = (ENGINE_TABLE *)lh; 124 *t = (ENGINE_TABLE *)lh;
112 return 1; 125 return 1;
@@ -130,7 +143,7 @@ int engine_table_register(ENGINE_TABLE **table, ENGINE_CLEANUP_CB *cleanup,
130 while(num_nids--) 143 while(num_nids--)
131 { 144 {
132 tmplate.nid = *nids; 145 tmplate.nid = *nids;
133 fnd = lh_retrieve(&(*table)->piles, &tmplate); 146 fnd = lh_ENGINE_PILE_retrieve(&(*table)->piles, &tmplate);
134 if(!fnd) 147 if(!fnd)
135 { 148 {
136 fnd = OPENSSL_malloc(sizeof(ENGINE_PILE)); 149 fnd = OPENSSL_malloc(sizeof(ENGINE_PILE));
@@ -144,7 +157,7 @@ int engine_table_register(ENGINE_TABLE **table, ENGINE_CLEANUP_CB *cleanup,
144 goto end; 157 goto end;
145 } 158 }
146 fnd->funct = NULL; 159 fnd->funct = NULL;
147 lh_insert(&(*table)->piles, fnd); 160 (void)lh_ENGINE_PILE_insert(&(*table)->piles, fnd);
148 } 161 }
149 /* A registration shouldn't add duplciate entries */ 162 /* A registration shouldn't add duplciate entries */
150 (void)sk_ENGINE_delete_ptr(fnd->sk, e); 163 (void)sk_ENGINE_delete_ptr(fnd->sk, e);
@@ -173,7 +186,7 @@ end:
173 CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE); 186 CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE);
174 return ret; 187 return ret;
175 } 188 }
176static void int_unregister_cb(ENGINE_PILE *pile, ENGINE *e) 189static void int_unregister_cb_doall_arg(ENGINE_PILE *pile, ENGINE *e)
177 { 190 {
178 int n; 191 int n;
179 /* Iterate the 'c->sk' stack removing any occurance of 'e' */ 192 /* Iterate the 'c->sk' stack removing any occurance of 'e' */
@@ -188,31 +201,35 @@ static void int_unregister_cb(ENGINE_PILE *pile, ENGINE *e)
188 pile->funct = NULL; 201 pile->funct = NULL;
189 } 202 }
190 } 203 }
191static IMPLEMENT_LHASH_DOALL_ARG_FN(int_unregister_cb,ENGINE_PILE *,ENGINE *) 204static IMPLEMENT_LHASH_DOALL_ARG_FN(int_unregister_cb, ENGINE_PILE, ENGINE)
205
192void engine_table_unregister(ENGINE_TABLE **table, ENGINE *e) 206void engine_table_unregister(ENGINE_TABLE **table, ENGINE *e)
193 { 207 {
194 CRYPTO_w_lock(CRYPTO_LOCK_ENGINE); 208 CRYPTO_w_lock(CRYPTO_LOCK_ENGINE);
195 if(int_table_check(table, 0)) 209 if(int_table_check(table, 0))
196 lh_doall_arg(&(*table)->piles, 210 lh_ENGINE_PILE_doall_arg(&(*table)->piles,
197 LHASH_DOALL_ARG_FN(int_unregister_cb), e); 211 LHASH_DOALL_ARG_FN(int_unregister_cb),
212 ENGINE, e);
198 CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE); 213 CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE);
199 } 214 }
200 215
201static void int_cleanup_cb(ENGINE_PILE *p) 216static void int_cleanup_cb_doall(ENGINE_PILE *p)
202 { 217 {
203 sk_ENGINE_free(p->sk); 218 sk_ENGINE_free(p->sk);
204 if(p->funct) 219 if(p->funct)
205 engine_unlocked_finish(p->funct, 0); 220 engine_unlocked_finish(p->funct, 0);
206 OPENSSL_free(p); 221 OPENSSL_free(p);
207 } 222 }
208static IMPLEMENT_LHASH_DOALL_FN(int_cleanup_cb,ENGINE_PILE *) 223static IMPLEMENT_LHASH_DOALL_FN(int_cleanup_cb, ENGINE_PILE)
224
209void engine_table_cleanup(ENGINE_TABLE **table) 225void engine_table_cleanup(ENGINE_TABLE **table)
210 { 226 {
211 CRYPTO_w_lock(CRYPTO_LOCK_ENGINE); 227 CRYPTO_w_lock(CRYPTO_LOCK_ENGINE);
212 if(*table) 228 if(*table)
213 { 229 {
214 lh_doall(&(*table)->piles, LHASH_DOALL_FN(int_cleanup_cb)); 230 lh_ENGINE_PILE_doall(&(*table)->piles,
215 lh_free(&(*table)->piles); 231 LHASH_DOALL_FN(int_cleanup_cb));
232 lh_ENGINE_PILE_free(&(*table)->piles);
216 *table = NULL; 233 *table = NULL;
217 } 234 }
218 CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE); 235 CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE);
@@ -237,12 +254,13 @@ ENGINE *engine_table_select_tmp(ENGINE_TABLE **table, int nid, const char *f, in
237#endif 254#endif
238 return NULL; 255 return NULL;
239 } 256 }
257 ERR_set_mark();
240 CRYPTO_w_lock(CRYPTO_LOCK_ENGINE); 258 CRYPTO_w_lock(CRYPTO_LOCK_ENGINE);
241 /* Check again inside the lock otherwise we could race against cleanup 259 /* Check again inside the lock otherwise we could race against cleanup
242 * operations. But don't worry about a fprintf(stderr). */ 260 * operations. But don't worry about a fprintf(stderr). */
243 if(!int_table_check(table, 0)) goto end; 261 if(!int_table_check(table, 0)) goto end;
244 tmplate.nid = nid; 262 tmplate.nid = nid;
245 fnd = lh_retrieve(&(*table)->piles, &tmplate); 263 fnd = lh_ENGINE_PILE_retrieve(&(*table)->piles, &tmplate);
246 if(!fnd) goto end; 264 if(!fnd) goto end;
247 if(fnd->funct && engine_unlocked_init(fnd->funct)) 265 if(fnd->funct && engine_unlocked_init(fnd->funct))
248 { 266 {
@@ -310,6 +328,24 @@ end:
310 CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE); 328 CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE);
311 /* Whatever happened, any failed init()s are not failures in this 329 /* Whatever happened, any failed init()s are not failures in this
312 * context, so clear our error state. */ 330 * context, so clear our error state. */
313 ERR_clear_error(); 331 ERR_pop_to_mark();
314 return ret; 332 return ret;
315 } 333 }
334
335/* Table enumeration */
336
337static void int_cb_doall_arg(ENGINE_PILE *pile, ENGINE_PILE_DOALL *dall)
338 {
339 dall->cb(pile->nid, pile->sk, pile->funct, dall->arg);
340 }
341static IMPLEMENT_LHASH_DOALL_ARG_FN(int_cb, ENGINE_PILE,ENGINE_PILE_DOALL)
342
343void engine_table_doall(ENGINE_TABLE *table, engine_table_doall_cb *cb,
344 void *arg)
345 {
346 ENGINE_PILE_DOALL dall;
347 dall.cb = cb;
348 dall.arg = arg;
349 lh_ENGINE_PILE_doall_arg(&table->piles, LHASH_DOALL_ARG_FN(int_cb),
350 ENGINE_PILE_DOALL, &dall);
351 }
diff --git a/src/lib/libcrypto/engine/engine.h b/src/lib/libcrypto/engine/engine.h
index ecab9453ba..8ad11b15d7 100644
--- a/src/lib/libcrypto/engine/engine.h
+++ b/src/lib/libcrypto/engine/engine.h
@@ -88,16 +88,15 @@
88#include <openssl/ecdsa.h> 88#include <openssl/ecdsa.h>
89#endif 89#endif
90#include <openssl/rand.h> 90#include <openssl/rand.h>
91#include <openssl/store.h>
92#include <openssl/ui.h> 91#include <openssl/ui.h>
93#include <openssl/err.h> 92#include <openssl/err.h>
94#endif 93#endif
95 94
96#include <openssl/x509.h>
97
98#include <openssl/ossl_typ.h> 95#include <openssl/ossl_typ.h>
99#include <openssl/symhacks.h> 96#include <openssl/symhacks.h>
100 97
98#include <openssl/x509.h>
99
101#ifdef __cplusplus 100#ifdef __cplusplus
102extern "C" { 101extern "C" {
103#endif 102#endif
@@ -113,6 +112,8 @@ extern "C" {
113#define ENGINE_METHOD_CIPHERS (unsigned int)0x0040 112#define ENGINE_METHOD_CIPHERS (unsigned int)0x0040
114#define ENGINE_METHOD_DIGESTS (unsigned int)0x0080 113#define ENGINE_METHOD_DIGESTS (unsigned int)0x0080
115#define ENGINE_METHOD_STORE (unsigned int)0x0100 114#define ENGINE_METHOD_STORE (unsigned int)0x0100
115#define ENGINE_METHOD_PKEY_METHS (unsigned int)0x0200
116#define ENGINE_METHOD_PKEY_ASN1_METHS (unsigned int)0x0400
116/* Obvious all-or-nothing cases. */ 117/* Obvious all-or-nothing cases. */
117#define ENGINE_METHOD_ALL (unsigned int)0xFFFF 118#define ENGINE_METHOD_ALL (unsigned int)0xFFFF
118#define ENGINE_METHOD_NONE (unsigned int)0x0000 119#define ENGINE_METHOD_NONE (unsigned int)0x0000
@@ -297,7 +298,8 @@ typedef int (*ENGINE_SSL_CLIENT_CERT_PTR)(ENGINE *, SSL *ssl,
297 * parameter is non-NULL it is set to the size of the returned array. */ 298 * parameter is non-NULL it is set to the size of the returned array. */
298typedef int (*ENGINE_CIPHERS_PTR)(ENGINE *, const EVP_CIPHER **, const int **, int); 299typedef int (*ENGINE_CIPHERS_PTR)(ENGINE *, const EVP_CIPHER **, const int **, int);
299typedef int (*ENGINE_DIGESTS_PTR)(ENGINE *, const EVP_MD **, const int **, int); 300typedef int (*ENGINE_DIGESTS_PTR)(ENGINE *, const EVP_MD **, const int **, int);
300 301typedef int (*ENGINE_PKEY_METHS_PTR)(ENGINE *, EVP_PKEY_METHOD **, const int **, int);
302typedef int (*ENGINE_PKEY_ASN1_METHS_PTR)(ENGINE *, EVP_PKEY_ASN1_METHOD **, const int **, int);
301/* STRUCTURE functions ... all of these functions deal with pointers to ENGINE 303/* STRUCTURE functions ... all of these functions deal with pointers to ENGINE
302 * structures where the pointers have a "structural reference". This means that 304 * structures where the pointers have a "structural reference". This means that
303 * their reference is to allowed access to the structure but it does not imply 305 * their reference is to allowed access to the structure but it does not imply
@@ -329,20 +331,21 @@ void ENGINE_load_aep(void);
329void ENGINE_load_atalla(void); 331void ENGINE_load_atalla(void);
330void ENGINE_load_chil(void); 332void ENGINE_load_chil(void);
331void ENGINE_load_cswift(void); 333void ENGINE_load_cswift(void);
332#ifndef OPENSSL_NO_GMP
333void ENGINE_load_gmp(void);
334#endif
335void ENGINE_load_nuron(void); 334void ENGINE_load_nuron(void);
336void ENGINE_load_sureware(void); 335void ENGINE_load_sureware(void);
337void ENGINE_load_ubsec(void); 336void ENGINE_load_ubsec(void);
337void ENGINE_load_padlock(void);
338void ENGINE_load_capi(void);
339#ifndef OPENSSL_NO_GMP
340void ENGINE_load_gmp(void);
341#endif
342#ifndef OPENSSL_NO_GOST
343void ENGINE_load_gost(void);
344#endif
338#endif 345#endif
339void ENGINE_load_cryptodev(void); 346void ENGINE_load_cryptodev(void);
340void ENGINE_load_aesni(void); 347void ENGINE_load_aesni(void);
341void ENGINE_load_padlock(void);
342void ENGINE_load_builtin_engines(void); 348void ENGINE_load_builtin_engines(void);
343#ifndef OPENSSL_NO_CAPIENG
344void ENGINE_load_capi(void);
345#endif
346 349
347/* Get and set global flags (ENGINE_TABLE_FLAG_***) for the implementation 350/* Get and set global flags (ENGINE_TABLE_FLAG_***) for the implementation
348 * "registry" handling. */ 351 * "registry" handling. */
@@ -393,6 +396,14 @@ int ENGINE_register_digests(ENGINE *e);
393void ENGINE_unregister_digests(ENGINE *e); 396void ENGINE_unregister_digests(ENGINE *e);
394void ENGINE_register_all_digests(void); 397void ENGINE_register_all_digests(void);
395 398
399int ENGINE_register_pkey_meths(ENGINE *e);
400void ENGINE_unregister_pkey_meths(ENGINE *e);
401void ENGINE_register_all_pkey_meths(void);
402
403int ENGINE_register_pkey_asn1_meths(ENGINE *e);
404void ENGINE_unregister_pkey_asn1_meths(ENGINE *e);
405void ENGINE_register_all_pkey_asn1_meths(void);
406
396/* These functions register all support from the above categories. Note, use of 407/* These functions register all support from the above categories. Note, use of
397 * these functions can result in static linkage of code your application may not 408 * these functions can result in static linkage of code your application may not
398 * need. If you only need a subset of functionality, consider using more 409 * need. If you only need a subset of functionality, consider using more
@@ -472,6 +483,8 @@ int ENGINE_set_load_ssl_client_cert_function(ENGINE *e,
472 ENGINE_SSL_CLIENT_CERT_PTR loadssl_f); 483 ENGINE_SSL_CLIENT_CERT_PTR loadssl_f);
473int ENGINE_set_ciphers(ENGINE *e, ENGINE_CIPHERS_PTR f); 484int ENGINE_set_ciphers(ENGINE *e, ENGINE_CIPHERS_PTR f);
474int ENGINE_set_digests(ENGINE *e, ENGINE_DIGESTS_PTR f); 485int ENGINE_set_digests(ENGINE *e, ENGINE_DIGESTS_PTR f);
486int ENGINE_set_pkey_meths(ENGINE *e, ENGINE_PKEY_METHS_PTR f);
487int ENGINE_set_pkey_asn1_meths(ENGINE *e, ENGINE_PKEY_ASN1_METHS_PTR f);
475int ENGINE_set_flags(ENGINE *e, int flags); 488int ENGINE_set_flags(ENGINE *e, int flags);
476int ENGINE_set_cmd_defns(ENGINE *e, const ENGINE_CMD_DEFN *defns); 489int ENGINE_set_cmd_defns(ENGINE *e, const ENGINE_CMD_DEFN *defns);
477/* These functions allow control over any per-structure ENGINE data. */ 490/* These functions allow control over any per-structure ENGINE data. */
@@ -508,8 +521,16 @@ ENGINE_LOAD_KEY_PTR ENGINE_get_load_pubkey_function(const ENGINE *e);
508ENGINE_SSL_CLIENT_CERT_PTR ENGINE_get_ssl_client_cert_function(const ENGINE *e); 521ENGINE_SSL_CLIENT_CERT_PTR ENGINE_get_ssl_client_cert_function(const ENGINE *e);
509ENGINE_CIPHERS_PTR ENGINE_get_ciphers(const ENGINE *e); 522ENGINE_CIPHERS_PTR ENGINE_get_ciphers(const ENGINE *e);
510ENGINE_DIGESTS_PTR ENGINE_get_digests(const ENGINE *e); 523ENGINE_DIGESTS_PTR ENGINE_get_digests(const ENGINE *e);
524ENGINE_PKEY_METHS_PTR ENGINE_get_pkey_meths(const ENGINE *e);
525ENGINE_PKEY_ASN1_METHS_PTR ENGINE_get_pkey_asn1_meths(const ENGINE *e);
511const EVP_CIPHER *ENGINE_get_cipher(ENGINE *e, int nid); 526const EVP_CIPHER *ENGINE_get_cipher(ENGINE *e, int nid);
512const EVP_MD *ENGINE_get_digest(ENGINE *e, int nid); 527const EVP_MD *ENGINE_get_digest(ENGINE *e, int nid);
528const EVP_PKEY_METHOD *ENGINE_get_pkey_meth(ENGINE *e, int nid);
529const EVP_PKEY_ASN1_METHOD *ENGINE_get_pkey_asn1_meth(ENGINE *e, int nid);
530const EVP_PKEY_ASN1_METHOD *ENGINE_get_pkey_asn1_meth_str(ENGINE *e,
531 const char *str, int len);
532const EVP_PKEY_ASN1_METHOD *ENGINE_pkey_asn1_find_str(ENGINE **pe,
533 const char *str, int len);
513const ENGINE_CMD_DEFN *ENGINE_get_cmd_defns(const ENGINE *e); 534const ENGINE_CMD_DEFN *ENGINE_get_cmd_defns(const ENGINE *e);
514int ENGINE_get_flags(const ENGINE *e); 535int ENGINE_get_flags(const ENGINE *e);
515 536
@@ -561,6 +582,8 @@ ENGINE *ENGINE_get_default_RAND(void);
561 * ciphering or digesting corresponding to "nid". */ 582 * ciphering or digesting corresponding to "nid". */
562ENGINE *ENGINE_get_cipher_engine(int nid); 583ENGINE *ENGINE_get_cipher_engine(int nid);
563ENGINE *ENGINE_get_digest_engine(int nid); 584ENGINE *ENGINE_get_digest_engine(int nid);
585ENGINE *ENGINE_get_pkey_meth_engine(int nid);
586ENGINE *ENGINE_get_pkey_asn1_meth_engine(int nid);
564 587
565/* This sets a new default ENGINE structure for performing RSA 588/* This sets a new default ENGINE structure for performing RSA
566 * operations. If the result is non-zero (success) then the ENGINE 589 * operations. If the result is non-zero (success) then the ENGINE
@@ -576,6 +599,8 @@ int ENGINE_set_default_DH(ENGINE *e);
576int ENGINE_set_default_RAND(ENGINE *e); 599int ENGINE_set_default_RAND(ENGINE *e);
577int ENGINE_set_default_ciphers(ENGINE *e); 600int ENGINE_set_default_ciphers(ENGINE *e);
578int ENGINE_set_default_digests(ENGINE *e); 601int ENGINE_set_default_digests(ENGINE *e);
602int ENGINE_set_default_pkey_meths(ENGINE *e);
603int ENGINE_set_default_pkey_asn1_meths(ENGINE *e);
579 604
580/* The combination "set" - the flags are bitwise "OR"d from the 605/* The combination "set" - the flags are bitwise "OR"d from the
581 * ENGINE_METHOD_*** defines above. As with the "ENGINE_register_complete()" 606 * ENGINE_METHOD_*** defines above. As with the "ENGINE_register_complete()"
@@ -704,7 +729,7 @@ typedef int (*dynamic_bind_engine)(ENGINE *e, const char *id,
704 * values. */ 729 * values. */
705void *ENGINE_get_static_state(void); 730void *ENGINE_get_static_state(void);
706 731
707#if defined(__OpenBSD__) || defined(__FreeBSD__) 732#if defined(__OpenBSD__) || defined(__FreeBSD__) || defined(HAVE_CRYPTODEV)
708void ENGINE_setup_bsd_cryptodev(void); 733void ENGINE_setup_bsd_cryptodev(void);
709#endif 734#endif
710 735
@@ -733,13 +758,15 @@ void ERR_load_ENGINE_strings(void);
733#define ENGINE_F_ENGINE_GET_DEFAULT_TYPE 177 758#define ENGINE_F_ENGINE_GET_DEFAULT_TYPE 177
734#define ENGINE_F_ENGINE_GET_DIGEST 186 759#define ENGINE_F_ENGINE_GET_DIGEST 186
735#define ENGINE_F_ENGINE_GET_NEXT 115 760#define ENGINE_F_ENGINE_GET_NEXT 115
761#define ENGINE_F_ENGINE_GET_PKEY_ASN1_METH 193
762#define ENGINE_F_ENGINE_GET_PKEY_METH 192
736#define ENGINE_F_ENGINE_GET_PREV 116 763#define ENGINE_F_ENGINE_GET_PREV 116
737#define ENGINE_F_ENGINE_INIT 119 764#define ENGINE_F_ENGINE_INIT 119
738#define ENGINE_F_ENGINE_LIST_ADD 120 765#define ENGINE_F_ENGINE_LIST_ADD 120
739#define ENGINE_F_ENGINE_LIST_REMOVE 121 766#define ENGINE_F_ENGINE_LIST_REMOVE 121
740#define ENGINE_F_ENGINE_LOAD_PRIVATE_KEY 150 767#define ENGINE_F_ENGINE_LOAD_PRIVATE_KEY 150
741#define ENGINE_F_ENGINE_LOAD_PUBLIC_KEY 151 768#define ENGINE_F_ENGINE_LOAD_PUBLIC_KEY 151
742#define ENGINE_F_ENGINE_LOAD_SSL_CLIENT_CERT 192 769#define ENGINE_F_ENGINE_LOAD_SSL_CLIENT_CERT 194
743#define ENGINE_F_ENGINE_NEW 122 770#define ENGINE_F_ENGINE_NEW 122
744#define ENGINE_F_ENGINE_REMOVE 123 771#define ENGINE_F_ENGINE_REMOVE 123
745#define ENGINE_F_ENGINE_SET_DEFAULT_STRING 189 772#define ENGINE_F_ENGINE_SET_DEFAULT_STRING 189
@@ -768,6 +795,7 @@ void ERR_load_ENGINE_strings(void);
768#define ENGINE_R_DSO_FAILURE 104 795#define ENGINE_R_DSO_FAILURE 104
769#define ENGINE_R_DSO_NOT_FOUND 132 796#define ENGINE_R_DSO_NOT_FOUND 132
770#define ENGINE_R_ENGINES_SECTION_ERROR 148 797#define ENGINE_R_ENGINES_SECTION_ERROR 148
798#define ENGINE_R_ENGINE_CONFIGURATION_ERROR 102
771#define ENGINE_R_ENGINE_IS_NOT_IN_LIST 105 799#define ENGINE_R_ENGINE_IS_NOT_IN_LIST 105
772#define ENGINE_R_ENGINE_SECTION_ERROR 149 800#define ENGINE_R_ENGINE_SECTION_ERROR 149
773#define ENGINE_R_FAILED_LOADING_PRIVATE_KEY 128 801#define ENGINE_R_FAILED_LOADING_PRIVATE_KEY 128
@@ -794,6 +822,7 @@ void ERR_load_ENGINE_strings(void);
794#define ENGINE_R_RSA_NOT_IMPLEMENTED 141 822#define ENGINE_R_RSA_NOT_IMPLEMENTED 141
795#define ENGINE_R_UNIMPLEMENTED_CIPHER 146 823#define ENGINE_R_UNIMPLEMENTED_CIPHER 146
796#define ENGINE_R_UNIMPLEMENTED_DIGEST 147 824#define ENGINE_R_UNIMPLEMENTED_DIGEST 147
825#define ENGINE_R_UNIMPLEMENTED_PUBLIC_KEY_METHOD 101
797#define ENGINE_R_VERSION_INCOMPATIBILITY 145 826#define ENGINE_R_VERSION_INCOMPATIBILITY 145
798 827
799#ifdef __cplusplus 828#ifdef __cplusplus
diff --git a/src/lib/libcrypto/engine/enginetest.c b/src/lib/libcrypto/engine/enginetest.c
index e3834611db..f4d70e7e0a 100644
--- a/src/lib/libcrypto/engine/enginetest.c
+++ b/src/lib/libcrypto/engine/enginetest.c
@@ -276,7 +276,7 @@ end:
276 ENGINE_cleanup(); 276 ENGINE_cleanup();
277 CRYPTO_cleanup_all_ex_data(); 277 CRYPTO_cleanup_all_ex_data();
278 ERR_free_strings(); 278 ERR_free_strings();
279 ERR_remove_state(0); 279 ERR_remove_thread_state(NULL);
280 CRYPTO_mem_leaks_fp(stderr); 280 CRYPTO_mem_leaks_fp(stderr);
281 return to_return; 281 return to_return;
282 } 282 }
diff --git a/src/lib/libcrypto/engine/hw.ec b/src/lib/libcrypto/engine/hw.ec
deleted file mode 100644
index 5481a43918..0000000000
--- a/src/lib/libcrypto/engine/hw.ec
+++ /dev/null
@@ -1,8 +0,0 @@
1L AEPHK hw_aep_err.h hw_aep_err.c
2L ATALLA hw_atalla_err.h hw_atalla_err.c
3L CSWIFT hw_cswift_err.h hw_cswift_err.c
4L HWCRHK hw_ncipher_err.h hw_ncipher_err.c
5L NURON hw_nuron_err.h hw_nuron_err.c
6L SUREWARE hw_sureware_err.h hw_sureware_err.c
7L UBSEC hw_ubsec_err.h hw_ubsec_err.c
8L CCA4758 hw_4758_cca_err.h hw_4758_cca_err.c
diff --git a/src/lib/libcrypto/engine/hw_4758_cca.c b/src/lib/libcrypto/engine/hw_4758_cca.c
deleted file mode 100644
index 4f5ae8a46d..0000000000
--- a/src/lib/libcrypto/engine/hw_4758_cca.c
+++ /dev/null
@@ -1,969 +0,0 @@
1/* Author: Maurice Gittens <maurice@gittens.nl> */
2/* ====================================================================
3 * Copyright (c) 1999 The OpenSSL Project. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 *
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in
14 * the documentation and/or other materials provided with the
15 * distribution.
16 *
17 * 3. All advertising materials mentioning features or use of this
18 * software must display the following acknowledgment:
19 * "This product includes software developed by the OpenSSL Project
20 * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
21 *
22 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
23 * endorse or promote products derived from this software without
24 * prior written permission. For written permission, please contact
25 * licensing@OpenSSL.org.
26 *
27 * 5. Products derived from this software may not be called "OpenSSL"
28 * nor may "OpenSSL" appear in their names without prior written
29 * permission of the OpenSSL Project.
30 *
31 * 6. Redistributions of any form whatsoever must retain the following
32 * acknowledgment:
33 * "This product includes software developed by the OpenSSL Project
34 * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
35 *
36 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
37 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
38 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
39 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
40 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
41 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
42 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
43 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
44 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
45 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
46 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
47 * OF THE POSSIBILITY OF SUCH DAMAGE.
48 * ====================================================================
49 *
50 * This product includes cryptographic software written by Eric Young
51 * (eay@cryptsoft.com). This product includes software written by Tim
52 * Hudson (tjh@cryptsoft.com).
53 *
54 */
55
56#include <stdio.h>
57#include <openssl/crypto.h>
58/* #include <openssl/pem.h> */
59#include "cryptlib.h"
60#include <openssl/dso.h>
61#include <openssl/x509.h>
62#include <openssl/objects.h>
63#include <openssl/engine.h>
64
65#ifndef OPENSSL_NO_HW
66#ifndef OPENSSL_NO_HW_4758_CCA
67
68#ifdef FLAT_INC
69#include "hw_4758_cca.h"
70#else
71#include "vendor_defns/hw_4758_cca.h"
72#endif
73
74#include "hw_4758_cca_err.c"
75
76static int ibm_4758_cca_destroy(ENGINE *e);
77static int ibm_4758_cca_init(ENGINE *e);
78static int ibm_4758_cca_finish(ENGINE *e);
79static int ibm_4758_cca_ctrl(ENGINE *e, int cmd, long i, void *p, void (*f)());
80
81/* rsa functions */
82/*---------------*/
83#ifndef OPENSSL_NO_RSA
84static int cca_rsa_pub_enc(int flen, const unsigned char *from,
85 unsigned char *to, RSA *rsa,int padding);
86static int cca_rsa_priv_dec(int flen, const unsigned char *from,
87 unsigned char *to, RSA *rsa,int padding);
88static int cca_rsa_sign(int type, const unsigned char *m, unsigned int m_len,
89 unsigned char *sigret, unsigned int *siglen, const RSA *rsa);
90static int cca_rsa_verify(int dtype, const unsigned char *m, unsigned int m_len,
91 unsigned char *sigbuf, unsigned int siglen, const RSA *rsa);
92
93/* utility functions */
94/*-----------------------*/
95static EVP_PKEY *ibm_4758_load_privkey(ENGINE*, const char*,
96 UI_METHOD *ui_method, void *callback_data);
97static EVP_PKEY *ibm_4758_load_pubkey(ENGINE*, const char*,
98 UI_METHOD *ui_method, void *callback_data);
99
100static int getModulusAndExponent(const unsigned char *token, long *exponentLength,
101 unsigned char *exponent, long *modulusLength,
102 long *modulusFieldLength, unsigned char *modulus);
103#endif
104
105/* RAND number functions */
106/*-----------------------*/
107static int cca_get_random_bytes(unsigned char*, int );
108static int cca_random_status(void);
109
110static void cca_ex_free(void *obj, void *item, CRYPTO_EX_DATA *ad,
111 int idx,long argl, void *argp);
112
113/* Function pointers for CCA verbs */
114/*---------------------------------*/
115#ifndef OPENSSL_NO_RSA
116static F_KEYRECORDREAD keyRecordRead;
117static F_DIGITALSIGNATUREGENERATE digitalSignatureGenerate;
118static F_DIGITALSIGNATUREVERIFY digitalSignatureVerify;
119static F_PUBLICKEYEXTRACT publicKeyExtract;
120static F_PKAENCRYPT pkaEncrypt;
121static F_PKADECRYPT pkaDecrypt;
122#endif
123static F_RANDOMNUMBERGENERATE randomNumberGenerate;
124
125/* static variables */
126/*------------------*/
127static const char *CCA4758_LIB_NAME = NULL;
128static const char *get_CCA4758_LIB_NAME(void)
129 {
130 if(CCA4758_LIB_NAME)
131 return CCA4758_LIB_NAME;
132 return CCA_LIB_NAME;
133 }
134static void free_CCA4758_LIB_NAME(void)
135 {
136 if(CCA4758_LIB_NAME)
137 OPENSSL_free((void*)CCA4758_LIB_NAME);
138 CCA4758_LIB_NAME = NULL;
139 }
140static long set_CCA4758_LIB_NAME(const char *name)
141 {
142 free_CCA4758_LIB_NAME();
143 return (((CCA4758_LIB_NAME = BUF_strdup(name)) != NULL) ? 1 : 0);
144 }
145#ifndef OPENSSL_NO_RSA
146static const char* n_keyRecordRead = CSNDKRR;
147static const char* n_digitalSignatureGenerate = CSNDDSG;
148static const char* n_digitalSignatureVerify = CSNDDSV;
149static const char* n_publicKeyExtract = CSNDPKX;
150static const char* n_pkaEncrypt = CSNDPKE;
151static const char* n_pkaDecrypt = CSNDPKD;
152#endif
153static const char* n_randomNumberGenerate = CSNBRNG;
154
155static int hndidx = -1;
156static DSO *dso = NULL;
157
158/* openssl engine initialization structures */
159/*------------------------------------------*/
160
161#define CCA4758_CMD_SO_PATH ENGINE_CMD_BASE
162static const ENGINE_CMD_DEFN cca4758_cmd_defns[] = {
163 {CCA4758_CMD_SO_PATH,
164 "SO_PATH",
165 "Specifies the path to the '4758cca' shared library",
166 ENGINE_CMD_FLAG_STRING},
167 {0, NULL, NULL, 0}
168 };
169
170#ifndef OPENSSL_NO_RSA
171static RSA_METHOD ibm_4758_cca_rsa =
172 {
173 "IBM 4758 CCA RSA method",
174 cca_rsa_pub_enc,
175 NULL,
176 NULL,
177 cca_rsa_priv_dec,
178 NULL, /*rsa_mod_exp,*/
179 NULL, /*mod_exp_mont,*/
180 NULL, /* init */
181 NULL, /* finish */
182 RSA_FLAG_SIGN_VER, /* flags */
183 NULL, /* app_data */
184 cca_rsa_sign, /* rsa_sign */
185 cca_rsa_verify /* rsa_verify */
186 };
187#endif
188
189static RAND_METHOD ibm_4758_cca_rand =
190 {
191 /* "IBM 4758 RAND method", */
192 NULL, /* seed */
193 cca_get_random_bytes, /* get random bytes from the card */
194 NULL, /* cleanup */
195 NULL, /* add */
196 cca_get_random_bytes, /* pseudo rand */
197 cca_random_status, /* status */
198 };
199
200static const char *engine_4758_cca_id = "4758cca";
201static const char *engine_4758_cca_name = "IBM 4758 CCA hardware engine support";
202
203/* engine implementation */
204/*-----------------------*/
205static int bind_helper(ENGINE *e)
206 {
207 if(!ENGINE_set_id(e, engine_4758_cca_id) ||
208 !ENGINE_set_name(e, engine_4758_cca_name) ||
209#ifndef OPENSSL_NO_RSA
210 !ENGINE_set_RSA(e, &ibm_4758_cca_rsa) ||
211#endif
212 !ENGINE_set_RAND(e, &ibm_4758_cca_rand) ||
213 !ENGINE_set_destroy_function(e, ibm_4758_cca_destroy) ||
214 !ENGINE_set_init_function(e, ibm_4758_cca_init) ||
215 !ENGINE_set_finish_function(e, ibm_4758_cca_finish) ||
216 !ENGINE_set_ctrl_function(e, ibm_4758_cca_ctrl) ||
217 !ENGINE_set_load_privkey_function(e, ibm_4758_load_privkey) ||
218 !ENGINE_set_load_pubkey_function(e, ibm_4758_load_pubkey) ||
219 !ENGINE_set_cmd_defns(e, cca4758_cmd_defns))
220 return 0;
221 /* Ensure the error handling is set up */
222 ERR_load_CCA4758_strings();
223 return 1;
224 }
225
226#ifndef ENGINE_DYNAMIC_SUPPORT
227static ENGINE *engine_4758_cca(void)
228 {
229 ENGINE *ret = ENGINE_new();
230 if(!ret)
231 return NULL;
232 if(!bind_helper(ret))
233 {
234 ENGINE_free(ret);
235 return NULL;
236 }
237 return ret;
238 }
239
240void ENGINE_load_4758cca(void)
241 {
242 ENGINE *e_4758 = engine_4758_cca();
243 if (!e_4758) return;
244 ENGINE_add(e_4758);
245 ENGINE_free(e_4758);
246 ERR_clear_error();
247 }
248#endif
249
250static int ibm_4758_cca_destroy(ENGINE *e)
251 {
252 ERR_unload_CCA4758_strings();
253 free_CCA4758_LIB_NAME();
254 return 1;
255 }
256
257static int ibm_4758_cca_init(ENGINE *e)
258 {
259 if(dso)
260 {
261 CCA4758err(CCA4758_F_IBM_4758_CCA_INIT,CCA4758_R_ALREADY_LOADED);
262 goto err;
263 }
264
265 dso = DSO_load(NULL, get_CCA4758_LIB_NAME(), NULL, 0);
266 if(!dso)
267 {
268 CCA4758err(CCA4758_F_IBM_4758_CCA_INIT,CCA4758_R_DSO_FAILURE);
269 goto err;
270 }
271
272#ifndef OPENSSL_NO_RSA
273 if(!(keyRecordRead = (F_KEYRECORDREAD)
274 DSO_bind_func(dso, n_keyRecordRead)) ||
275 !(randomNumberGenerate = (F_RANDOMNUMBERGENERATE)
276 DSO_bind_func(dso, n_randomNumberGenerate)) ||
277 !(digitalSignatureGenerate = (F_DIGITALSIGNATUREGENERATE)
278 DSO_bind_func(dso, n_digitalSignatureGenerate)) ||
279 !(digitalSignatureVerify = (F_DIGITALSIGNATUREVERIFY)
280 DSO_bind_func(dso, n_digitalSignatureVerify)) ||
281 !(publicKeyExtract = (F_PUBLICKEYEXTRACT)
282 DSO_bind_func(dso, n_publicKeyExtract)) ||
283 !(pkaEncrypt = (F_PKAENCRYPT)
284 DSO_bind_func(dso, n_pkaEncrypt)) ||
285 !(pkaDecrypt = (F_PKADECRYPT)
286 DSO_bind_func(dso, n_pkaDecrypt)))
287 {
288 CCA4758err(CCA4758_F_IBM_4758_CCA_INIT,CCA4758_R_DSO_FAILURE);
289 goto err;
290 }
291#else
292 if(!(randomNumberGenerate = (F_RANDOMNUMBERGENERATE)
293 DSO_bind_func(dso, n_randomNumberGenerate)))
294 {
295 CCA4758err(CCA4758_F_IBM_4758_CCA_INIT,CCA4758_R_DSO_FAILURE);
296 goto err;
297 }
298#endif
299
300 hndidx = RSA_get_ex_new_index(0, "IBM 4758 CCA RSA key handle",
301 NULL, NULL, cca_ex_free);
302
303 return 1;
304err:
305 if(dso)
306 DSO_free(dso);
307 dso = NULL;
308
309 keyRecordRead = (F_KEYRECORDREAD)0;
310 randomNumberGenerate = (F_RANDOMNUMBERGENERATE)0;
311 digitalSignatureGenerate = (F_DIGITALSIGNATUREGENERATE)0;
312 digitalSignatureVerify = (F_DIGITALSIGNATUREVERIFY)0;
313 publicKeyExtract = (F_PUBLICKEYEXTRACT)0;
314 pkaEncrypt = (F_PKAENCRYPT)0;
315 pkaDecrypt = (F_PKADECRYPT)0;
316 return 0;
317 }
318
319static int ibm_4758_cca_finish(ENGINE *e)
320 {
321 free_CCA4758_LIB_NAME();
322 if(!dso)
323 {
324 CCA4758err(CCA4758_F_IBM_4758_CCA_FINISH,
325 CCA4758_R_NOT_LOADED);
326 return 0;
327 }
328 if(!DSO_free(dso))
329 {
330 CCA4758err(CCA4758_F_IBM_4758_CCA_FINISH,
331 CCA4758_R_UNIT_FAILURE);
332 return 0;
333 }
334 dso = NULL;
335 keyRecordRead = (F_KEYRECORDREAD)0;
336 randomNumberGenerate = (F_RANDOMNUMBERGENERATE)0;
337 digitalSignatureGenerate = (F_DIGITALSIGNATUREGENERATE)0;
338 digitalSignatureVerify = (F_DIGITALSIGNATUREVERIFY)0;
339 publicKeyExtract = (F_PUBLICKEYEXTRACT)0;
340 pkaEncrypt = (F_PKAENCRYPT)0;
341 pkaDecrypt = (F_PKADECRYPT)0;
342 return 1;
343 }
344
345static int ibm_4758_cca_ctrl(ENGINE *e, int cmd, long i, void *p, void (*f)())
346 {
347 int initialised = ((dso == NULL) ? 0 : 1);
348 switch(cmd)
349 {
350 case CCA4758_CMD_SO_PATH:
351 if(p == NULL)
352 {
353 CCA4758err(CCA4758_F_IBM_4758_CCA_CTRL,
354 ERR_R_PASSED_NULL_PARAMETER);
355 return 0;
356 }
357 if(initialised)
358 {
359 CCA4758err(CCA4758_F_IBM_4758_CCA_CTRL,
360 CCA4758_R_ALREADY_LOADED);
361 return 0;
362 }
363 return set_CCA4758_LIB_NAME((const char *)p);
364 default:
365 break;
366 }
367 CCA4758err(CCA4758_F_IBM_4758_CCA_CTRL,
368 CCA4758_R_COMMAND_NOT_IMPLEMENTED);
369 return 0;
370 }
371
372#ifndef OPENSSL_NO_RSA
373
374#define MAX_CCA_PKA_TOKEN_SIZE 2500
375
376static EVP_PKEY *ibm_4758_load_privkey(ENGINE* e, const char* key_id,
377 UI_METHOD *ui_method, void *callback_data)
378 {
379 RSA *rtmp = NULL;
380 EVP_PKEY *res = NULL;
381 unsigned char* keyToken = NULL;
382 unsigned char pubKeyToken[MAX_CCA_PKA_TOKEN_SIZE];
383 long pubKeyTokenLength = MAX_CCA_PKA_TOKEN_SIZE;
384 long keyTokenLength = MAX_CCA_PKA_TOKEN_SIZE;
385 long returnCode;
386 long reasonCode;
387 long exitDataLength = 0;
388 long ruleArrayLength = 0;
389 unsigned char exitData[8];
390 unsigned char ruleArray[8];
391 unsigned char keyLabel[64];
392 long keyLabelLength = strlen(key_id);
393 unsigned char modulus[256];
394 long modulusFieldLength = sizeof(modulus);
395 long modulusLength = 0;
396 unsigned char exponent[256];
397 long exponentLength = sizeof(exponent);
398
399 if (keyLabelLength > sizeof(keyLabel))
400 {
401 CCA4758err(CCA4758_F_IBM_4758_CCA_LOAD_PRIVKEY,
402 CCA4758_R_SIZE_TOO_LARGE_OR_TOO_SMALL);
403 return NULL;
404 }
405
406 memset(keyLabel,' ', sizeof(keyLabel));
407 memcpy(keyLabel, key_id, keyLabelLength);
408
409 keyToken = OPENSSL_malloc(MAX_CCA_PKA_TOKEN_SIZE + sizeof(long));
410 if (!keyToken)
411 {
412 CCA4758err(CCA4758_F_IBM_4758_CCA_LOAD_PRIVKEY,
413 ERR_R_MALLOC_FAILURE);
414 goto err;
415 }
416
417 keyRecordRead(&returnCode, &reasonCode, &exitDataLength,
418 exitData, &ruleArrayLength, ruleArray, keyLabel,
419 &keyTokenLength, keyToken+sizeof(long));
420
421 if (returnCode)
422 {
423 CCA4758err(CCA4758_F_IBM_4758_CCA_LOAD_PRIVKEY,
424 CCA4758_R_FAILED_LOADING_PRIVATE_KEY);
425 goto err;
426 }
427
428 publicKeyExtract(&returnCode, &reasonCode, &exitDataLength,
429 exitData, &ruleArrayLength, ruleArray, &keyTokenLength,
430 keyToken+sizeof(long), &pubKeyTokenLength, pubKeyToken);
431
432 if (returnCode)
433 {
434 CCA4758err(CCA4758_F_IBM_4758_CCA_LOAD_PRIVKEY,
435 CCA4758_R_FAILED_LOADING_PRIVATE_KEY);
436 goto err;
437 }
438
439 if (!getModulusAndExponent(pubKeyToken, &exponentLength,
440 exponent, &modulusLength, &modulusFieldLength,
441 modulus))
442 {
443 CCA4758err(CCA4758_F_IBM_4758_CCA_LOAD_PRIVKEY,
444 CCA4758_R_FAILED_LOADING_PRIVATE_KEY);
445 goto err;
446 }
447
448 (*(long*)keyToken) = keyTokenLength;
449 rtmp = RSA_new_method(e);
450 RSA_set_ex_data(rtmp, hndidx, (char *)keyToken);
451
452 rtmp->e = BN_bin2bn(exponent, exponentLength, NULL);
453 rtmp->n = BN_bin2bn(modulus, modulusFieldLength, NULL);
454 rtmp->flags |= RSA_FLAG_EXT_PKEY;
455
456 res = EVP_PKEY_new();
457 EVP_PKEY_assign_RSA(res, rtmp);
458
459 return res;
460err:
461 if (keyToken)
462 OPENSSL_free(keyToken);
463 if (res)
464 EVP_PKEY_free(res);
465 if (rtmp)
466 RSA_free(rtmp);
467 return NULL;
468 }
469
470static EVP_PKEY *ibm_4758_load_pubkey(ENGINE* e, const char* key_id,
471 UI_METHOD *ui_method, void *callback_data)
472 {
473 RSA *rtmp = NULL;
474 EVP_PKEY *res = NULL;
475 unsigned char* keyToken = NULL;
476 long keyTokenLength = MAX_CCA_PKA_TOKEN_SIZE;
477 long returnCode;
478 long reasonCode;
479 long exitDataLength = 0;
480 long ruleArrayLength = 0;
481 unsigned char exitData[8];
482 unsigned char ruleArray[8];
483 unsigned char keyLabel[64];
484 long keyLabelLength = strlen(key_id);
485 unsigned char modulus[512];
486 long modulusFieldLength = sizeof(modulus);
487 long modulusLength = 0;
488 unsigned char exponent[512];
489 long exponentLength = sizeof(exponent);
490
491 if (keyLabelLength > sizeof(keyLabel))
492 {
493 CCA4758err(CCA4758_F_IBM_4758_CCA_LOAD_PRIVKEY,
494 CCA4758_R_SIZE_TOO_LARGE_OR_TOO_SMALL);
495 return NULL;
496 }
497
498 memset(keyLabel,' ', sizeof(keyLabel));
499 memcpy(keyLabel, key_id, keyLabelLength);
500
501 keyToken = OPENSSL_malloc(MAX_CCA_PKA_TOKEN_SIZE + sizeof(long));
502 if (!keyToken)
503 {
504 CCA4758err(CCA4758_F_IBM_4758_CCA_LOAD_PUBKEY,
505 ERR_R_MALLOC_FAILURE);
506 goto err;
507 }
508
509 keyRecordRead(&returnCode, &reasonCode, &exitDataLength, exitData,
510 &ruleArrayLength, ruleArray, keyLabel, &keyTokenLength,
511 keyToken+sizeof(long));
512
513 if (returnCode)
514 {
515 CCA4758err(CCA4758_F_IBM_4758_CCA_LOAD_PRIVKEY,
516 ERR_R_MALLOC_FAILURE);
517 goto err;
518 }
519
520 if (!getModulusAndExponent(keyToken+sizeof(long), &exponentLength,
521 exponent, &modulusLength, &modulusFieldLength, modulus))
522 {
523 CCA4758err(CCA4758_F_IBM_4758_CCA_LOAD_PRIVKEY,
524 CCA4758_R_FAILED_LOADING_PUBLIC_KEY);
525 goto err;
526 }
527
528 (*(long*)keyToken) = keyTokenLength;
529 rtmp = RSA_new_method(e);
530 RSA_set_ex_data(rtmp, hndidx, (char *)keyToken);
531 rtmp->e = BN_bin2bn(exponent, exponentLength, NULL);
532 rtmp->n = BN_bin2bn(modulus, modulusFieldLength, NULL);
533 rtmp->flags |= RSA_FLAG_EXT_PKEY;
534 res = EVP_PKEY_new();
535 EVP_PKEY_assign_RSA(res, rtmp);
536
537 return res;
538err:
539 if (keyToken)
540 OPENSSL_free(keyToken);
541 if (res)
542 EVP_PKEY_free(res);
543 if (rtmp)
544 RSA_free(rtmp);
545 return NULL;
546 }
547
548static int cca_rsa_pub_enc(int flen, const unsigned char *from,
549 unsigned char *to, RSA *rsa,int padding)
550 {
551 long returnCode;
552 long reasonCode;
553 long lflen = flen;
554 long exitDataLength = 0;
555 unsigned char exitData[8];
556 long ruleArrayLength = 1;
557 unsigned char ruleArray[8] = "PKCS-1.2";
558 long dataStructureLength = 0;
559 unsigned char dataStructure[8];
560 long outputLength = RSA_size(rsa);
561 long keyTokenLength;
562 unsigned char* keyToken = (unsigned char*)RSA_get_ex_data(rsa, hndidx);
563
564 keyTokenLength = *(long*)keyToken;
565 keyToken+=sizeof(long);
566
567 pkaEncrypt(&returnCode, &reasonCode, &exitDataLength, exitData,
568 &ruleArrayLength, ruleArray, &lflen, (unsigned char*)from,
569 &dataStructureLength, dataStructure, &keyTokenLength,
570 keyToken, &outputLength, to);
571
572 if (returnCode || reasonCode)
573 return -(returnCode << 16 | reasonCode);
574 return outputLength;
575 }
576
577static int cca_rsa_priv_dec(int flen, const unsigned char *from,
578 unsigned char *to, RSA *rsa,int padding)
579 {
580 long returnCode;
581 long reasonCode;
582 long lflen = flen;
583 long exitDataLength = 0;
584 unsigned char exitData[8];
585 long ruleArrayLength = 1;
586 unsigned char ruleArray[8] = "PKCS-1.2";
587 long dataStructureLength = 0;
588 unsigned char dataStructure[8];
589 long outputLength = RSA_size(rsa);
590 long keyTokenLength;
591 unsigned char* keyToken = (unsigned char*)RSA_get_ex_data(rsa, hndidx);
592
593 keyTokenLength = *(long*)keyToken;
594 keyToken+=sizeof(long);
595
596 pkaDecrypt(&returnCode, &reasonCode, &exitDataLength, exitData,
597 &ruleArrayLength, ruleArray, &lflen, (unsigned char*)from,
598 &dataStructureLength, dataStructure, &keyTokenLength,
599 keyToken, &outputLength, to);
600
601 return (returnCode | reasonCode) ? 0 : 1;
602 }
603
604#define SSL_SIG_LEN 36
605
606static int cca_rsa_verify(int type, const unsigned char *m, unsigned int m_len,
607 unsigned char *sigbuf, unsigned int siglen, const RSA *rsa)
608 {
609 long returnCode;
610 long reasonCode;
611 long lsiglen = siglen;
612 long exitDataLength = 0;
613 unsigned char exitData[8];
614 long ruleArrayLength = 1;
615 unsigned char ruleArray[8] = "PKCS-1.1";
616 long keyTokenLength;
617 unsigned char* keyToken = (unsigned char*)RSA_get_ex_data(rsa, hndidx);
618 long length = SSL_SIG_LEN;
619 long keyLength ;
620 unsigned char *hashBuffer = NULL;
621 X509_SIG sig;
622 ASN1_TYPE parameter;
623 X509_ALGOR algorithm;
624 ASN1_OCTET_STRING digest;
625
626 keyTokenLength = *(long*)keyToken;
627 keyToken+=sizeof(long);
628
629 if (type == NID_md5 || type == NID_sha1)
630 {
631 sig.algor = &algorithm;
632 algorithm.algorithm = OBJ_nid2obj(type);
633
634 if (!algorithm.algorithm)
635 {
636 CCA4758err(CCA4758_F_IBM_4758_CCA_VERIFY,
637 CCA4758_R_UNKNOWN_ALGORITHM_TYPE);
638 return 0;
639 }
640
641 if (!algorithm.algorithm->length)
642 {
643 CCA4758err(CCA4758_F_IBM_4758_CCA_VERIFY,
644 CCA4758_R_ASN1_OID_UNKNOWN_FOR_MD);
645 return 0;
646 }
647
648 parameter.type = V_ASN1_NULL;
649 parameter.value.ptr = NULL;
650 algorithm.parameter = &parameter;
651
652 sig.digest = &digest;
653 sig.digest->data = (unsigned char*)m;
654 sig.digest->length = m_len;
655
656 length = i2d_X509_SIG(&sig, NULL);
657 }
658
659 keyLength = RSA_size(rsa);
660
661 if (length - RSA_PKCS1_PADDING > keyLength)
662 {
663 CCA4758err(CCA4758_F_IBM_4758_CCA_VERIFY,
664 CCA4758_R_SIZE_TOO_LARGE_OR_TOO_SMALL);
665 return 0;
666 }
667
668 switch (type)
669 {
670 case NID_md5_sha1 :
671 if (m_len != SSL_SIG_LEN)
672 {
673 CCA4758err(CCA4758_F_IBM_4758_CCA_VERIFY,
674 CCA4758_R_SIZE_TOO_LARGE_OR_TOO_SMALL);
675 return 0;
676 }
677
678 hashBuffer = (unsigned char *)m;
679 length = m_len;
680 break;
681 case NID_md5 :
682 {
683 unsigned char *ptr;
684 ptr = hashBuffer = OPENSSL_malloc(
685 (unsigned int)keyLength+1);
686 if (!hashBuffer)
687 {
688 CCA4758err(CCA4758_F_IBM_4758_CCA_VERIFY,
689 ERR_R_MALLOC_FAILURE);
690 return 0;
691 }
692
693 i2d_X509_SIG(&sig, &ptr);
694 }
695 break;
696 case NID_sha1 :
697 {
698 unsigned char *ptr;
699 ptr = hashBuffer = OPENSSL_malloc(
700 (unsigned int)keyLength+1);
701 if (!hashBuffer)
702 {
703 CCA4758err(CCA4758_F_IBM_4758_CCA_VERIFY,
704 ERR_R_MALLOC_FAILURE);
705 return 0;
706 }
707 i2d_X509_SIG(&sig, &ptr);
708 }
709 break;
710 default:
711 return 0;
712 }
713
714 digitalSignatureVerify(&returnCode, &reasonCode, &exitDataLength,
715 exitData, &ruleArrayLength, ruleArray, &keyTokenLength,
716 keyToken, &length, hashBuffer, &lsiglen, sigbuf);
717
718 if (type == NID_sha1 || type == NID_md5)
719 {
720 OPENSSL_cleanse(hashBuffer, keyLength+1);
721 OPENSSL_free(hashBuffer);
722 }
723
724 return ((returnCode || reasonCode) ? 0 : 1);
725 }
726
727#define SSL_SIG_LEN 36
728
729static int cca_rsa_sign(int type, const unsigned char *m, unsigned int m_len,
730 unsigned char *sigret, unsigned int *siglen, const RSA *rsa)
731 {
732 long returnCode;
733 long reasonCode;
734 long exitDataLength = 0;
735 unsigned char exitData[8];
736 long ruleArrayLength = 1;
737 unsigned char ruleArray[8] = "PKCS-1.1";
738 long outputLength=256;
739 long outputBitLength;
740 long keyTokenLength;
741 unsigned char *hashBuffer = NULL;
742 unsigned char* keyToken = (unsigned char*)RSA_get_ex_data(rsa, hndidx);
743 long length = SSL_SIG_LEN;
744 long keyLength ;
745 X509_SIG sig;
746 ASN1_TYPE parameter;
747 X509_ALGOR algorithm;
748 ASN1_OCTET_STRING digest;
749
750 keyTokenLength = *(long*)keyToken;
751 keyToken+=sizeof(long);
752
753 if (type == NID_md5 || type == NID_sha1)
754 {
755 sig.algor = &algorithm;
756 algorithm.algorithm = OBJ_nid2obj(type);
757
758 if (!algorithm.algorithm)
759 {
760 CCA4758err(CCA4758_F_IBM_4758_CCA_SIGN,
761 CCA4758_R_UNKNOWN_ALGORITHM_TYPE);
762 return 0;
763 }
764
765 if (!algorithm.algorithm->length)
766 {
767 CCA4758err(CCA4758_F_IBM_4758_CCA_SIGN,
768 CCA4758_R_ASN1_OID_UNKNOWN_FOR_MD);
769 return 0;
770 }
771
772 parameter.type = V_ASN1_NULL;
773 parameter.value.ptr = NULL;
774 algorithm.parameter = &parameter;
775
776 sig.digest = &digest;
777 sig.digest->data = (unsigned char*)m;
778 sig.digest->length = m_len;
779
780 length = i2d_X509_SIG(&sig, NULL);
781 }
782
783 keyLength = RSA_size(rsa);
784
785 if (length - RSA_PKCS1_PADDING > keyLength)
786 {
787 CCA4758err(CCA4758_F_IBM_4758_CCA_SIGN,
788 CCA4758_R_SIZE_TOO_LARGE_OR_TOO_SMALL);
789 return 0;
790 }
791
792 switch (type)
793 {
794 case NID_md5_sha1 :
795 if (m_len != SSL_SIG_LEN)
796 {
797 CCA4758err(CCA4758_F_IBM_4758_CCA_SIGN,
798 CCA4758_R_SIZE_TOO_LARGE_OR_TOO_SMALL);
799 return 0;
800 }
801 hashBuffer = (unsigned char*)m;
802 length = m_len;
803 break;
804 case NID_md5 :
805 {
806 unsigned char *ptr;
807 ptr = hashBuffer = OPENSSL_malloc(
808 (unsigned int)keyLength+1);
809 if (!hashBuffer)
810 {
811 CCA4758err(CCA4758_F_IBM_4758_CCA_VERIFY,
812 ERR_R_MALLOC_FAILURE);
813 return 0;
814 }
815 i2d_X509_SIG(&sig, &ptr);
816 }
817 break;
818 case NID_sha1 :
819 {
820 unsigned char *ptr;
821 ptr = hashBuffer = OPENSSL_malloc(
822 (unsigned int)keyLength+1);
823 if (!hashBuffer)
824 {
825 CCA4758err(CCA4758_F_IBM_4758_CCA_VERIFY,
826 ERR_R_MALLOC_FAILURE);
827 return 0;
828 }
829 i2d_X509_SIG(&sig, &ptr);
830 }
831 break;
832 default:
833 return 0;
834 }
835
836 digitalSignatureGenerate(&returnCode, &reasonCode, &exitDataLength,
837 exitData, &ruleArrayLength, ruleArray, &keyTokenLength,
838 keyToken, &length, hashBuffer, &outputLength, &outputBitLength,
839 sigret);
840
841 if (type == NID_sha1 || type == NID_md5)
842 {
843 OPENSSL_cleanse(hashBuffer, keyLength+1);
844 OPENSSL_free(hashBuffer);
845 }
846
847 *siglen = outputLength;
848
849 return ((returnCode || reasonCode) ? 0 : 1);
850 }
851
852static int getModulusAndExponent(const unsigned char*token, long *exponentLength,
853 unsigned char *exponent, long *modulusLength, long *modulusFieldLength,
854 unsigned char *modulus)
855 {
856 unsigned long len;
857
858 if (*token++ != (char)0x1E) /* internal PKA token? */
859 return 0;
860
861 if (*token++) /* token version must be zero */
862 return 0;
863
864 len = *token++;
865 len = len << 8;
866 len |= (unsigned char)*token++;
867
868 token += 4; /* skip reserved bytes */
869
870 if (*token++ == (char)0x04)
871 {
872 if (*token++) /* token version must be zero */
873 return 0;
874
875 len = *token++;
876 len = len << 8;
877 len |= (unsigned char)*token++;
878
879 token+=2; /* skip reserved section */
880
881 len = *token++;
882 len = len << 8;
883 len |= (unsigned char)*token++;
884
885 *exponentLength = len;
886
887 len = *token++;
888 len = len << 8;
889 len |= (unsigned char)*token++;
890
891 *modulusLength = len;
892
893 len = *token++;
894 len = len << 8;
895 len |= (unsigned char)*token++;
896
897 *modulusFieldLength = len;
898
899 memcpy(exponent, token, *exponentLength);
900 token+= *exponentLength;
901
902 memcpy(modulus, token, *modulusFieldLength);
903 return 1;
904 }
905 return 0;
906 }
907
908#endif /* OPENSSL_NO_RSA */
909
910static int cca_random_status(void)
911 {
912 return 1;
913 }
914
915static int cca_get_random_bytes(unsigned char* buf, int num)
916 {
917 long ret_code;
918 long reason_code;
919 long exit_data_length;
920 unsigned char exit_data[4];
921 unsigned char form[] = "RANDOM ";
922 unsigned char rand_buf[8];
923
924 while(num >= sizeof(rand_buf))
925 {
926 randomNumberGenerate(&ret_code, &reason_code, &exit_data_length,
927 exit_data, form, rand_buf);
928 if (ret_code)
929 return 0;
930 num -= sizeof(rand_buf);
931 memcpy(buf, rand_buf, sizeof(rand_buf));
932 buf += sizeof(rand_buf);
933 }
934
935 if (num)
936 {
937 randomNumberGenerate(&ret_code, &reason_code, NULL, NULL,
938 form, rand_buf);
939 if (ret_code)
940 return 0;
941 memcpy(buf, rand_buf, num);
942 }
943
944 return 1;
945 }
946
947static void cca_ex_free(void *obj, void *item, CRYPTO_EX_DATA *ad, int idx,
948 long argl, void *argp)
949 {
950 if (item)
951 OPENSSL_free(item);
952 }
953
954/* Goo to handle building as a dynamic engine */
955#ifdef ENGINE_DYNAMIC_SUPPORT
956static int bind_fn(ENGINE *e, const char *id)
957 {
958 if(id && (strcmp(id, engine_4758_cca_id) != 0))
959 return 0;
960 if(!bind_helper(e))
961 return 0;
962 return 1;
963 }
964IMPLEMENT_DYNAMIC_CHECK_FN()
965IMPLEMENT_DYNAMIC_BIND_FN(bind_fn)
966#endif /* ENGINE_DYNAMIC_SUPPORT */
967
968#endif /* !OPENSSL_NO_HW_4758_CCA */
969#endif /* !OPENSSL_NO_HW */
diff --git a/src/lib/libcrypto/engine/hw_4758_cca_err.c b/src/lib/libcrypto/engine/hw_4758_cca_err.c
deleted file mode 100644
index 7ea5c63707..0000000000
--- a/src/lib/libcrypto/engine/hw_4758_cca_err.c
+++ /dev/null
@@ -1,149 +0,0 @@
1/* hw_4758_cca_err.c */
2/* ====================================================================
3 * Copyright (c) 1999-2002 The OpenSSL Project. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 *
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in
14 * the documentation and/or other materials provided with the
15 * distribution.
16 *
17 * 3. All advertising materials mentioning features or use of this
18 * software must display the following acknowledgment:
19 * "This product includes software developed by the OpenSSL Project
20 * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
21 *
22 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
23 * endorse or promote products derived from this software without
24 * prior written permission. For written permission, please contact
25 * openssl-core@OpenSSL.org.
26 *
27 * 5. Products derived from this software may not be called "OpenSSL"
28 * nor may "OpenSSL" appear in their names without prior written
29 * permission of the OpenSSL Project.
30 *
31 * 6. Redistributions of any form whatsoever must retain the following
32 * acknowledgment:
33 * "This product includes software developed by the OpenSSL Project
34 * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
35 *
36 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
37 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
38 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
39 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
40 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
41 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
42 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
43 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
44 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
45 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
46 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
47 * OF THE POSSIBILITY OF SUCH DAMAGE.
48 * ====================================================================
49 *
50 * This product includes cryptographic software written by Eric Young
51 * (eay@cryptsoft.com). This product includes software written by Tim
52 * Hudson (tjh@cryptsoft.com).
53 *
54 */
55
56/* NOTE: this file was auto generated by the mkerr.pl script: any changes
57 * made to it will be overwritten when the script next updates this file,
58 * only reason strings will be preserved.
59 */
60
61#include <stdio.h>
62#include <openssl/err.h>
63#include "hw_4758_cca_err.h"
64
65/* BEGIN ERROR CODES */
66#ifndef OPENSSL_NO_ERR
67static ERR_STRING_DATA CCA4758_str_functs[]=
68 {
69{ERR_PACK(0,CCA4758_F_IBM_4758_CCA_CTRL,0), "IBM_4758_CCA_CTRL"},
70{ERR_PACK(0,CCA4758_F_IBM_4758_CCA_FINISH,0), "IBM_4758_CCA_FINISH"},
71{ERR_PACK(0,CCA4758_F_IBM_4758_CCA_INIT,0), "IBM_4758_CCA_INIT"},
72{ERR_PACK(0,CCA4758_F_IBM_4758_CCA_LOAD_PRIVKEY,0), "IBM_4758_CCA_LOAD_PRIVKEY"},
73{ERR_PACK(0,CCA4758_F_IBM_4758_CCA_LOAD_PUBKEY,0), "IBM_4758_CCA_LOAD_PUBKEY"},
74{ERR_PACK(0,CCA4758_F_IBM_4758_CCA_SIGN,0), "IBM_4758_CCA_SIGN"},
75{ERR_PACK(0,CCA4758_F_IBM_4758_CCA_VERIFY,0), "IBM_4758_CCA_VERIFY"},
76{0,NULL}
77 };
78
79static ERR_STRING_DATA CCA4758_str_reasons[]=
80 {
81{CCA4758_R_ALREADY_LOADED ,"already loaded"},
82{CCA4758_R_ASN1_OID_UNKNOWN_FOR_MD ,"asn1 oid unknown for md"},
83{CCA4758_R_COMMAND_NOT_IMPLEMENTED ,"command not implemented"},
84{CCA4758_R_DSO_FAILURE ,"dso failure"},
85{CCA4758_R_FAILED_LOADING_PRIVATE_KEY ,"failed loading private key"},
86{CCA4758_R_FAILED_LOADING_PUBLIC_KEY ,"failed loading public key"},
87{CCA4758_R_NOT_LOADED ,"not loaded"},
88{CCA4758_R_SIZE_TOO_LARGE_OR_TOO_SMALL ,"size too large or too small"},
89{CCA4758_R_UNIT_FAILURE ,"unit failure"},
90{CCA4758_R_UNKNOWN_ALGORITHM_TYPE ,"unknown algorithm type"},
91{0,NULL}
92 };
93
94#endif
95
96#ifdef CCA4758_LIB_NAME
97static ERR_STRING_DATA CCA4758_lib_name[]=
98 {
99{0 ,CCA4758_LIB_NAME},
100{0,NULL}
101 };
102#endif
103
104
105static int CCA4758_lib_error_code=0;
106static int CCA4758_error_init=1;
107
108static void ERR_load_CCA4758_strings(void)
109 {
110 if (CCA4758_lib_error_code == 0)
111 CCA4758_lib_error_code=ERR_get_next_error_library();
112
113 if (CCA4758_error_init)
114 {
115 CCA4758_error_init=0;
116#ifndef OPENSSL_NO_ERR
117 ERR_load_strings(CCA4758_lib_error_code,CCA4758_str_functs);
118 ERR_load_strings(CCA4758_lib_error_code,CCA4758_str_reasons);
119#endif
120
121#ifdef CCA4758_LIB_NAME
122 CCA4758_lib_name->error = ERR_PACK(CCA4758_lib_error_code,0,0);
123 ERR_load_strings(0,CCA4758_lib_name);
124#endif
125 }
126 }
127
128static void ERR_unload_CCA4758_strings(void)
129 {
130 if (CCA4758_error_init == 0)
131 {
132#ifndef OPENSSL_NO_ERR
133 ERR_unload_strings(CCA4758_lib_error_code,CCA4758_str_functs);
134 ERR_unload_strings(CCA4758_lib_error_code,CCA4758_str_reasons);
135#endif
136
137#ifdef CCA4758_LIB_NAME
138 ERR_unload_strings(0,CCA4758_lib_name);
139#endif
140 CCA4758_error_init=1;
141 }
142 }
143
144static void ERR_CCA4758_error(int function, int reason, char *file, int line)
145 {
146 if (CCA4758_lib_error_code == 0)
147 CCA4758_lib_error_code=ERR_get_next_error_library();
148 ERR_PUT_error(CCA4758_lib_error_code,function,reason,file,line);
149 }
diff --git a/src/lib/libcrypto/engine/hw_4758_cca_err.h b/src/lib/libcrypto/engine/hw_4758_cca_err.h
deleted file mode 100644
index 2fc563ab11..0000000000
--- a/src/lib/libcrypto/engine/hw_4758_cca_err.h
+++ /dev/null
@@ -1,93 +0,0 @@
1/* ====================================================================
2 * Copyright (c) 2001 The OpenSSL Project. All rights reserved.
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 * openssl-core@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 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
36 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
37 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
38 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
39 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
40 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
41 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
42 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
43 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
44 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
45 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
46 * OF THE POSSIBILITY OF SUCH DAMAGE.
47 * ====================================================================
48 *
49 * This product includes cryptographic software written by Eric Young
50 * (eay@cryptsoft.com). This product includes software written by Tim
51 * Hudson (tjh@cryptsoft.com).
52 *
53 */
54
55#ifndef HEADER_CCA4758_ERR_H
56#define HEADER_CCA4758_ERR_H
57
58/* BEGIN ERROR CODES */
59/* The following lines are auto generated by the script mkerr.pl. Any changes
60 * made after this point may be overwritten when the script is next run.
61 */
62static void ERR_load_CCA4758_strings(void);
63static void ERR_unload_CCA4758_strings(void);
64static void ERR_CCA4758_error(int function, int reason, char *file, int line);
65#define CCA4758err(f,r) ERR_CCA4758_error((f),(r),__FILE__,__LINE__)
66
67/* Error codes for the CCA4758 functions. */
68
69/* Function codes. */
70#define CCA4758_F_IBM_4758_CCA_CTRL 100
71#define CCA4758_F_IBM_4758_CCA_FINISH 101
72#define CCA4758_F_IBM_4758_CCA_INIT 102
73#define CCA4758_F_IBM_4758_CCA_LOAD_PRIVKEY 103
74#define CCA4758_F_IBM_4758_CCA_LOAD_PUBKEY 104
75#define CCA4758_F_IBM_4758_CCA_SIGN 105
76#define CCA4758_F_IBM_4758_CCA_VERIFY 106
77
78/* Reason codes. */
79#define CCA4758_R_ALREADY_LOADED 100
80#define CCA4758_R_ASN1_OID_UNKNOWN_FOR_MD 101
81#define CCA4758_R_COMMAND_NOT_IMPLEMENTED 102
82#define CCA4758_R_DSO_FAILURE 103
83#define CCA4758_R_FAILED_LOADING_PRIVATE_KEY 104
84#define CCA4758_R_FAILED_LOADING_PUBLIC_KEY 105
85#define CCA4758_R_NOT_LOADED 106
86#define CCA4758_R_SIZE_TOO_LARGE_OR_TOO_SMALL 107
87#define CCA4758_R_UNIT_FAILURE 108
88#define CCA4758_R_UNKNOWN_ALGORITHM_TYPE 109
89
90#ifdef __cplusplus
91}
92#endif
93#endif
diff --git a/src/lib/libcrypto/engine/hw_aep.c b/src/lib/libcrypto/engine/hw_aep.c
deleted file mode 100644
index 5f1772ea99..0000000000
--- a/src/lib/libcrypto/engine/hw_aep.c
+++ /dev/null
@@ -1,1120 +0,0 @@
1/* crypto/engine/hw_aep.c */
2/*
3 */
4/* ====================================================================
5 * Copyright (c) 1999 The OpenSSL Project. All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 *
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 *
14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in
16 * the documentation and/or other materials provided with the
17 * distribution.
18 *
19 * 3. All advertising materials mentioning features or use of this
20 * software must display the following acknowledgment:
21 * "This product includes software developed by the OpenSSL Project
22 * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
23 *
24 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
25 * endorse or promote products derived from this software without
26 * prior written permission. For written permission, please contact
27 * licensing@OpenSSL.org.
28 *
29 * 5. Products derived from this software may not be called "OpenSSL"
30 * nor may "OpenSSL" appear in their names without prior written
31 * permission of the OpenSSL Project.
32 *
33 * 6. Redistributions of any form whatsoever must retain the following
34 * acknowledgment:
35 * "This product includes software developed by the OpenSSL Project
36 * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
37 *
38 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
39 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
40 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
41 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
42 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
43 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
44 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
45 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
46 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
47 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
48 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49 * OF THE POSSIBILITY OF SUCH DAMAGE.
50 * ====================================================================
51 *
52 * This product includes cryptographic software written by Eric Young
53 * (eay@cryptsoft.com). This product includes software written by Tim
54 * Hudson (tjh@cryptsoft.com).
55 *
56 */
57
58#include <stdio.h>
59#include <openssl/bn.h>
60#include <string.h>
61
62#include <openssl/e_os2.h>
63#if !defined(OPENSSL_SYS_MSDOS) || defined(__DJGPP__)
64#include <sys/types.h>
65#include <unistd.h>
66#else
67#include <process.h>
68typedef int pid_t;
69#endif
70
71#include <openssl/crypto.h>
72#include <openssl/dso.h>
73#include <openssl/engine.h>
74#include <openssl/buffer.h>
75
76#ifndef OPENSSL_NO_HW
77#ifndef OPENSSL_NO_HW_AEP
78#ifdef FLAT_INC
79#include "aep.h"
80#else
81#include "vendor_defns/aep.h"
82#endif
83
84#define AEP_LIB_NAME "aep engine"
85#define FAIL_TO_SW 0x10101010
86
87#include "hw_aep_err.c"
88
89static int aep_init(ENGINE *e);
90static int aep_finish(ENGINE *e);
91static int aep_ctrl(ENGINE *e, int cmd, long i, void *p, void (*f)());
92static int aep_destroy(ENGINE *e);
93
94static AEP_RV aep_get_connection(AEP_CONNECTION_HNDL_PTR hConnection);
95static AEP_RV aep_return_connection(AEP_CONNECTION_HNDL hConnection);
96static AEP_RV aep_close_connection(AEP_CONNECTION_HNDL hConnection);
97static AEP_RV aep_close_all_connections(int use_engine_lock, int *in_use);
98
99/* BIGNUM stuff */
100static int aep_mod_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
101 const BIGNUM *m, BN_CTX *ctx);
102
103static AEP_RV aep_mod_exp_crt(BIGNUM *r,const BIGNUM *a, const BIGNUM *p,
104 const BIGNUM *q, const BIGNUM *dmp1,const BIGNUM *dmq1,
105 const BIGNUM *iqmp, BN_CTX *ctx);
106
107/* RSA stuff */
108#ifndef OPENSSL_NO_RSA
109static int aep_rsa_mod_exp(BIGNUM *r0, const BIGNUM *I, RSA *rsa);
110#endif
111
112/* This function is aliased to mod_exp (with the mont stuff dropped). */
113static int aep_mod_exp_mont(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
114 const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx);
115
116/* DSA stuff */
117#ifndef OPENSSL_NO_DSA
118static int aep_dsa_mod_exp(DSA *dsa, BIGNUM *rr, BIGNUM *a1,
119 BIGNUM *p1, BIGNUM *a2, BIGNUM *p2, BIGNUM *m,
120 BN_CTX *ctx, BN_MONT_CTX *in_mont);
121
122static int aep_mod_exp_dsa(DSA *dsa, BIGNUM *r, BIGNUM *a,
123 const BIGNUM *p, const BIGNUM *m, BN_CTX *ctx,
124 BN_MONT_CTX *m_ctx);
125#endif
126
127/* DH stuff */
128/* This function is aliased to mod_exp (with the DH and mont dropped). */
129#ifndef OPENSSL_NO_DH
130static int aep_mod_exp_dh(const DH *dh, BIGNUM *r, const BIGNUM *a,
131 const BIGNUM *p, const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx);
132#endif
133
134/* rand stuff */
135#ifdef AEPRAND
136static int aep_rand(unsigned char *buf, int num);
137static int aep_rand_status(void);
138#endif
139
140/* Bignum conversion stuff */
141static AEP_RV GetBigNumSize(AEP_VOID_PTR ArbBigNum, AEP_U32* BigNumSize);
142static AEP_RV MakeAEPBigNum(AEP_VOID_PTR ArbBigNum, AEP_U32 BigNumSize,
143 unsigned char* AEP_BigNum);
144static AEP_RV ConvertAEPBigNum(void* ArbBigNum, AEP_U32 BigNumSize,
145 unsigned char* AEP_BigNum);
146
147/* The definitions for control commands specific to this engine */
148#define AEP_CMD_SO_PATH ENGINE_CMD_BASE
149static const ENGINE_CMD_DEFN aep_cmd_defns[] =
150 {
151 { AEP_CMD_SO_PATH,
152 "SO_PATH",
153 "Specifies the path to the 'aep' shared library",
154 ENGINE_CMD_FLAG_STRING
155 },
156 {0, NULL, NULL, 0}
157 };
158
159#ifndef OPENSSL_NO_RSA
160/* Our internal RSA_METHOD that we provide pointers to */
161static RSA_METHOD aep_rsa =
162 {
163 "Aep RSA method",
164 NULL, /*rsa_pub_encrypt*/
165 NULL, /*rsa_pub_decrypt*/
166 NULL, /*rsa_priv_encrypt*/
167 NULL, /*rsa_priv_encrypt*/
168 aep_rsa_mod_exp, /*rsa_mod_exp*/
169 aep_mod_exp_mont, /*bn_mod_exp*/
170 NULL, /*init*/
171 NULL, /*finish*/
172 0, /*flags*/
173 NULL, /*app_data*/
174 NULL, /*rsa_sign*/
175 NULL /*rsa_verify*/
176 };
177#endif
178
179#ifndef OPENSSL_NO_DSA
180/* Our internal DSA_METHOD that we provide pointers to */
181static DSA_METHOD aep_dsa =
182 {
183 "Aep DSA method",
184 NULL, /* dsa_do_sign */
185 NULL, /* dsa_sign_setup */
186 NULL, /* dsa_do_verify */
187 aep_dsa_mod_exp, /* dsa_mod_exp */
188 aep_mod_exp_dsa, /* bn_mod_exp */
189 NULL, /* init */
190 NULL, /* finish */
191 0, /* flags */
192 NULL /* app_data */
193 };
194#endif
195
196#ifndef OPENSSL_NO_DH
197/* Our internal DH_METHOD that we provide pointers to */
198static DH_METHOD aep_dh =
199 {
200 "Aep DH method",
201 NULL,
202 NULL,
203 aep_mod_exp_dh,
204 NULL,
205 NULL,
206 0,
207 NULL
208 };
209#endif
210
211#ifdef AEPRAND
212/* our internal RAND_method that we provide pointers to */
213static RAND_METHOD aep_random =
214 {
215 /*"AEP RAND method", */
216 NULL,
217 aep_rand,
218 NULL,
219 NULL,
220 aep_rand,
221 aep_rand_status,
222 };
223#endif
224
225/*Define an array of structures to hold connections*/
226static AEP_CONNECTION_ENTRY aep_app_conn_table[MAX_PROCESS_CONNECTIONS];
227
228/*Used to determine if this is a new process*/
229static pid_t recorded_pid = 0;
230
231#ifdef AEPRAND
232static AEP_U8 rand_block[RAND_BLK_SIZE];
233static AEP_U32 rand_block_bytes = 0;
234#endif
235
236/* Constants used when creating the ENGINE */
237static const char *engine_aep_id = "aep";
238static const char *engine_aep_name = "Aep hardware engine support";
239
240static int max_key_len = 2176;
241
242
243/* This internal function is used by ENGINE_aep() and possibly by the
244 * "dynamic" ENGINE support too */
245static int bind_aep(ENGINE *e)
246 {
247#ifndef OPENSSL_NO_RSA
248 const RSA_METHOD *meth1;
249#endif
250#ifndef OPENSSL_NO_DSA
251 const DSA_METHOD *meth2;
252#endif
253#ifndef OPENSSL_NO_DH
254 const DH_METHOD *meth3;
255#endif
256
257 if(!ENGINE_set_id(e, engine_aep_id) ||
258 !ENGINE_set_name(e, engine_aep_name) ||
259#ifndef OPENSSL_NO_RSA
260 !ENGINE_set_RSA(e, &aep_rsa) ||
261#endif
262#ifndef OPENSSL_NO_DSA
263 !ENGINE_set_DSA(e, &aep_dsa) ||
264#endif
265#ifndef OPENSSL_NO_DH
266 !ENGINE_set_DH(e, &aep_dh) ||
267#endif
268#ifdef AEPRAND
269 !ENGINE_set_RAND(e, &aep_random) ||
270#endif
271 !ENGINE_set_init_function(e, aep_init) ||
272 !ENGINE_set_destroy_function(e, aep_destroy) ||
273 !ENGINE_set_finish_function(e, aep_finish) ||
274 !ENGINE_set_ctrl_function(e, aep_ctrl) ||
275 !ENGINE_set_cmd_defns(e, aep_cmd_defns))
276 return 0;
277
278#ifndef OPENSSL_NO_RSA
279 /* We know that the "PKCS1_SSLeay()" functions hook properly
280 * to the aep-specific mod_exp and mod_exp_crt so we use
281 * those functions. NB: We don't use ENGINE_openssl() or
282 * anything "more generic" because something like the RSAref
283 * code may not hook properly, and if you own one of these
284 * cards then you have the right to do RSA operations on it
285 * anyway! */
286 meth1 = RSA_PKCS1_SSLeay();
287 aep_rsa.rsa_pub_enc = meth1->rsa_pub_enc;
288 aep_rsa.rsa_pub_dec = meth1->rsa_pub_dec;
289 aep_rsa.rsa_priv_enc = meth1->rsa_priv_enc;
290 aep_rsa.rsa_priv_dec = meth1->rsa_priv_dec;
291#endif
292
293
294#ifndef OPENSSL_NO_DSA
295 /* Use the DSA_OpenSSL() method and just hook the mod_exp-ish
296 * bits. */
297 meth2 = DSA_OpenSSL();
298 aep_dsa.dsa_do_sign = meth2->dsa_do_sign;
299 aep_dsa.dsa_sign_setup = meth2->dsa_sign_setup;
300 aep_dsa.dsa_do_verify = meth2->dsa_do_verify;
301
302 aep_dsa = *DSA_get_default_method();
303 aep_dsa.dsa_mod_exp = aep_dsa_mod_exp;
304 aep_dsa.bn_mod_exp = aep_mod_exp_dsa;
305#endif
306
307#ifndef OPENSSL_NO_DH
308 /* Much the same for Diffie-Hellman */
309 meth3 = DH_OpenSSL();
310 aep_dh.generate_key = meth3->generate_key;
311 aep_dh.compute_key = meth3->compute_key;
312 aep_dh.bn_mod_exp = meth3->bn_mod_exp;
313#endif
314
315 /* Ensure the aep error handling is set up */
316 ERR_load_AEPHK_strings();
317
318 return 1;
319}
320
321#ifdef ENGINE_DYNAMIC_SUPPORT
322static int bind_helper(ENGINE *e, const char *id)
323 {
324 if(id && (strcmp(id, engine_aep_id) != 0))
325 return 0;
326 if(!bind_aep(e))
327 return 0;
328 return 1;
329 }
330IMPLEMENT_DYNAMIC_CHECK_FN()
331IMPLEMENT_DYNAMIC_BIND_FN(bind_helper)
332#else
333static ENGINE *engine_aep(void)
334 {
335 ENGINE *ret = ENGINE_new();
336 if(!ret)
337 return NULL;
338 if(!bind_aep(ret))
339 {
340 ENGINE_free(ret);
341 return NULL;
342 }
343 return ret;
344 }
345
346void ENGINE_load_aep(void)
347 {
348 /* Copied from eng_[openssl|dyn].c */
349 ENGINE *toadd = engine_aep();
350 if(!toadd) return;
351 ENGINE_add(toadd);
352 ENGINE_free(toadd);
353 ERR_clear_error();
354 }
355#endif
356
357/* This is a process-global DSO handle used for loading and unloading
358 * the Aep library. NB: This is only set (or unset) during an
359 * init() or finish() call (reference counts permitting) and they're
360 * operating with global locks, so this should be thread-safe
361 * implicitly. */
362static DSO *aep_dso = NULL;
363
364/* These are the static string constants for the DSO file name and the function
365 * symbol names to bind to.
366*/
367static const char *AEP_LIBNAME = NULL;
368static const char *get_AEP_LIBNAME(void)
369 {
370 if(AEP_LIBNAME)
371 return AEP_LIBNAME;
372 return "aep";
373 }
374static void free_AEP_LIBNAME(void)
375 {
376 if(AEP_LIBNAME)
377 OPENSSL_free((void*)AEP_LIBNAME);
378 AEP_LIBNAME = NULL;
379 }
380static long set_AEP_LIBNAME(const char *name)
381 {
382 free_AEP_LIBNAME();
383 return ((AEP_LIBNAME = BUF_strdup(name)) != NULL ? 1 : 0);
384 }
385
386static const char *AEP_F1 = "AEP_ModExp";
387static const char *AEP_F2 = "AEP_ModExpCrt";
388#ifdef AEPRAND
389static const char *AEP_F3 = "AEP_GenRandom";
390#endif
391static const char *AEP_F4 = "AEP_Finalize";
392static const char *AEP_F5 = "AEP_Initialize";
393static const char *AEP_F6 = "AEP_OpenConnection";
394static const char *AEP_F7 = "AEP_SetBNCallBacks";
395static const char *AEP_F8 = "AEP_CloseConnection";
396
397/* These are the function pointers that are (un)set when the library has
398 * successfully (un)loaded. */
399static t_AEP_OpenConnection *p_AEP_OpenConnection = NULL;
400static t_AEP_CloseConnection *p_AEP_CloseConnection = NULL;
401static t_AEP_ModExp *p_AEP_ModExp = NULL;
402static t_AEP_ModExpCrt *p_AEP_ModExpCrt = NULL;
403#ifdef AEPRAND
404static t_AEP_GenRandom *p_AEP_GenRandom = NULL;
405#endif
406static t_AEP_Initialize *p_AEP_Initialize = NULL;
407static t_AEP_Finalize *p_AEP_Finalize = NULL;
408static t_AEP_SetBNCallBacks *p_AEP_SetBNCallBacks = NULL;
409
410/* (de)initialisation functions. */
411static int aep_init(ENGINE *e)
412 {
413 t_AEP_ModExp *p1;
414 t_AEP_ModExpCrt *p2;
415#ifdef AEPRAND
416 t_AEP_GenRandom *p3;
417#endif
418 t_AEP_Finalize *p4;
419 t_AEP_Initialize *p5;
420 t_AEP_OpenConnection *p6;
421 t_AEP_SetBNCallBacks *p7;
422 t_AEP_CloseConnection *p8;
423
424 int to_return = 0;
425
426 if(aep_dso != NULL)
427 {
428 AEPHKerr(AEPHK_F_AEP_INIT,AEPHK_R_ALREADY_LOADED);
429 goto err;
430 }
431 /* Attempt to load libaep.so. */
432
433 aep_dso = DSO_load(NULL, get_AEP_LIBNAME(), NULL, 0);
434
435 if(aep_dso == NULL)
436 {
437 AEPHKerr(AEPHK_F_AEP_INIT,AEPHK_R_NOT_LOADED);
438 goto err;
439 }
440
441 if( !(p1 = (t_AEP_ModExp *) DSO_bind_func( aep_dso,AEP_F1)) ||
442 !(p2 = (t_AEP_ModExpCrt*) DSO_bind_func( aep_dso,AEP_F2)) ||
443#ifdef AEPRAND
444 !(p3 = (t_AEP_GenRandom*) DSO_bind_func( aep_dso,AEP_F3)) ||
445#endif
446 !(p4 = (t_AEP_Finalize*) DSO_bind_func( aep_dso,AEP_F4)) ||
447 !(p5 = (t_AEP_Initialize*) DSO_bind_func( aep_dso,AEP_F5)) ||
448 !(p6 = (t_AEP_OpenConnection*) DSO_bind_func( aep_dso,AEP_F6)) ||
449 !(p7 = (t_AEP_SetBNCallBacks*) DSO_bind_func( aep_dso,AEP_F7)) ||
450 !(p8 = (t_AEP_CloseConnection*) DSO_bind_func( aep_dso,AEP_F8)))
451 {
452 AEPHKerr(AEPHK_F_AEP_INIT,AEPHK_R_NOT_LOADED);
453 goto err;
454 }
455
456 /* Copy the pointers */
457
458 p_AEP_ModExp = p1;
459 p_AEP_ModExpCrt = p2;
460#ifdef AEPRAND
461 p_AEP_GenRandom = p3;
462#endif
463 p_AEP_Finalize = p4;
464 p_AEP_Initialize = p5;
465 p_AEP_OpenConnection = p6;
466 p_AEP_SetBNCallBacks = p7;
467 p_AEP_CloseConnection = p8;
468
469 to_return = 1;
470
471 return to_return;
472
473 err:
474
475 if(aep_dso)
476 DSO_free(aep_dso);
477 aep_dso = NULL;
478
479 p_AEP_OpenConnection = NULL;
480 p_AEP_ModExp = NULL;
481 p_AEP_ModExpCrt = NULL;
482#ifdef AEPRAND
483 p_AEP_GenRandom = NULL;
484#endif
485 p_AEP_Initialize = NULL;
486 p_AEP_Finalize = NULL;
487 p_AEP_SetBNCallBacks = NULL;
488 p_AEP_CloseConnection = NULL;
489
490 return to_return;
491 }
492
493/* Destructor (complements the "ENGINE_aep()" constructor) */
494static int aep_destroy(ENGINE *e)
495 {
496 free_AEP_LIBNAME();
497 ERR_unload_AEPHK_strings();
498 return 1;
499 }
500
501static int aep_finish(ENGINE *e)
502 {
503 int to_return = 0, in_use;
504 AEP_RV rv;
505
506 if(aep_dso == NULL)
507 {
508 AEPHKerr(AEPHK_F_AEP_FINISH,AEPHK_R_NOT_LOADED);
509 goto err;
510 }
511
512 rv = aep_close_all_connections(0, &in_use);
513 if (rv != AEP_R_OK)
514 {
515 AEPHKerr(AEPHK_F_AEP_FINISH,AEPHK_R_CLOSE_HANDLES_FAILED);
516 goto err;
517 }
518 if (in_use)
519 {
520 AEPHKerr(AEPHK_F_AEP_FINISH,AEPHK_R_CONNECTIONS_IN_USE);
521 goto err;
522 }
523
524 rv = p_AEP_Finalize();
525 if (rv != AEP_R_OK)
526 {
527 AEPHKerr(AEPHK_F_AEP_FINISH,AEPHK_R_FINALIZE_FAILED);
528 goto err;
529 }
530
531 if(!DSO_free(aep_dso))
532 {
533 AEPHKerr(AEPHK_F_AEP_FINISH,AEPHK_R_UNIT_FAILURE);
534 goto err;
535 }
536
537 aep_dso = NULL;
538 p_AEP_CloseConnection = NULL;
539 p_AEP_OpenConnection = NULL;
540 p_AEP_ModExp = NULL;
541 p_AEP_ModExpCrt = NULL;
542#ifdef AEPRAND
543 p_AEP_GenRandom = NULL;
544#endif
545 p_AEP_Initialize = NULL;
546 p_AEP_Finalize = NULL;
547 p_AEP_SetBNCallBacks = NULL;
548
549 to_return = 1;
550 err:
551 return to_return;
552 }
553
554static int aep_ctrl(ENGINE *e, int cmd, long i, void *p, void (*f)())
555 {
556 int initialised = ((aep_dso == NULL) ? 0 : 1);
557 switch(cmd)
558 {
559 case AEP_CMD_SO_PATH:
560 if(p == NULL)
561 {
562 AEPHKerr(AEPHK_F_AEP_CTRL,
563 ERR_R_PASSED_NULL_PARAMETER);
564 return 0;
565 }
566 if(initialised)
567 {
568 AEPHKerr(AEPHK_F_AEP_CTRL,
569 AEPHK_R_ALREADY_LOADED);
570 return 0;
571 }
572 return set_AEP_LIBNAME((const char*)p);
573 default:
574 break;
575 }
576 AEPHKerr(AEPHK_F_AEP_CTRL,AEPHK_R_CTRL_COMMAND_NOT_IMPLEMENTED);
577 return 0;
578 }
579
580static int aep_mod_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
581 const BIGNUM *m, BN_CTX *ctx)
582 {
583 int to_return = 0;
584 int r_len = 0;
585 AEP_CONNECTION_HNDL hConnection;
586 AEP_RV rv;
587
588 r_len = BN_num_bits(m);
589
590 /* Perform in software if modulus is too large for hardware. */
591
592 if (r_len > max_key_len){
593 AEPHKerr(AEPHK_F_AEP_MOD_EXP, AEPHK_R_SIZE_TOO_LARGE_OR_TOO_SMALL);
594 return BN_mod_exp(r, a, p, m, ctx);
595 }
596
597 /*Grab a connection from the pool*/
598 rv = aep_get_connection(&hConnection);
599 if (rv != AEP_R_OK)
600 {
601 AEPHKerr(AEPHK_F_AEP_MOD_EXP,AEPHK_R_GET_HANDLE_FAILED);
602 return BN_mod_exp(r, a, p, m, ctx);
603 }
604
605 /*To the card with the mod exp*/
606 rv = p_AEP_ModExp(hConnection,(void*)a, (void*)p,(void*)m, (void*)r,NULL);
607
608 if (rv != AEP_R_OK)
609 {
610 AEPHKerr(AEPHK_F_AEP_MOD_EXP,AEPHK_R_MOD_EXP_FAILED);
611 rv = aep_close_connection(hConnection);
612 return BN_mod_exp(r, a, p, m, ctx);
613 }
614
615 /*Return the connection to the pool*/
616 rv = aep_return_connection(hConnection);
617 if (rv != AEP_R_OK)
618 {
619 AEPHKerr(AEPHK_F_AEP_RAND,AEPHK_R_RETURN_CONNECTION_FAILED);
620 goto err;
621 }
622
623 to_return = 1;
624 err:
625 return to_return;
626 }
627
628static AEP_RV aep_mod_exp_crt(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
629 const BIGNUM *q, const BIGNUM *dmp1,
630 const BIGNUM *dmq1,const BIGNUM *iqmp, BN_CTX *ctx)
631 {
632 AEP_RV rv = AEP_R_OK;
633 AEP_CONNECTION_HNDL hConnection;
634
635 /*Grab a connection from the pool*/
636 rv = aep_get_connection(&hConnection);
637 if (rv != AEP_R_OK)
638 {
639 AEPHKerr(AEPHK_F_AEP_MOD_EXP_CRT,AEPHK_R_GET_HANDLE_FAILED);
640 return FAIL_TO_SW;
641 }
642
643 /*To the card with the mod exp*/
644 rv = p_AEP_ModExpCrt(hConnection,(void*)a, (void*)p, (void*)q, (void*)dmp1,(void*)dmq1,
645 (void*)iqmp,(void*)r,NULL);
646 if (rv != AEP_R_OK)
647 {
648 AEPHKerr(AEPHK_F_AEP_MOD_EXP_CRT,AEPHK_R_MOD_EXP_CRT_FAILED);
649 rv = aep_close_connection(hConnection);
650 return FAIL_TO_SW;
651 }
652
653 /*Return the connection to the pool*/
654 rv = aep_return_connection(hConnection);
655 if (rv != AEP_R_OK)
656 {
657 AEPHKerr(AEPHK_F_AEP_RAND,AEPHK_R_RETURN_CONNECTION_FAILED);
658 goto err;
659 }
660
661 err:
662 return rv;
663 }
664
665
666#ifdef AEPRAND
667static int aep_rand(unsigned char *buf,int len )
668 {
669 AEP_RV rv = AEP_R_OK;
670 AEP_CONNECTION_HNDL hConnection;
671
672 CRYPTO_w_lock(CRYPTO_LOCK_RAND);
673
674 /*Can the request be serviced with what's already in the buffer?*/
675 if (len <= rand_block_bytes)
676 {
677 memcpy(buf, &rand_block[RAND_BLK_SIZE - rand_block_bytes], len);
678 rand_block_bytes -= len;
679 CRYPTO_w_unlock(CRYPTO_LOCK_RAND);
680 }
681 else
682 /*If not the get another block of random bytes*/
683 {
684 CRYPTO_w_unlock(CRYPTO_LOCK_RAND);
685
686 rv = aep_get_connection(&hConnection);
687 if (rv != AEP_R_OK)
688 {
689 AEPHKerr(AEPHK_F_AEP_RAND,AEPHK_R_GET_HANDLE_FAILED);
690 goto err_nounlock;
691 }
692
693 if (len > RAND_BLK_SIZE)
694 {
695 rv = p_AEP_GenRandom(hConnection, len, 2, buf, NULL);
696 if (rv != AEP_R_OK)
697 {
698 AEPHKerr(AEPHK_F_AEP_RAND,AEPHK_R_GET_RANDOM_FAILED);
699 goto err_nounlock;
700 }
701 }
702 else
703 {
704 CRYPTO_w_lock(CRYPTO_LOCK_RAND);
705
706 rv = p_AEP_GenRandom(hConnection, RAND_BLK_SIZE, 2, &rand_block[0], NULL);
707 if (rv != AEP_R_OK)
708 {
709 AEPHKerr(AEPHK_F_AEP_RAND,AEPHK_R_GET_RANDOM_FAILED);
710
711 goto err;
712 }
713
714 rand_block_bytes = RAND_BLK_SIZE;
715
716 memcpy(buf, &rand_block[RAND_BLK_SIZE - rand_block_bytes], len);
717 rand_block_bytes -= len;
718
719 CRYPTO_w_unlock(CRYPTO_LOCK_RAND);
720 }
721
722 rv = aep_return_connection(hConnection);
723 if (rv != AEP_R_OK)
724 {
725 AEPHKerr(AEPHK_F_AEP_RAND,AEPHK_R_RETURN_CONNECTION_FAILED);
726
727 goto err_nounlock;
728 }
729 }
730
731 return 1;
732 err:
733 CRYPTO_w_unlock(CRYPTO_LOCK_RAND);
734 err_nounlock:
735 return 0;
736 }
737
738static int aep_rand_status(void)
739{
740 return 1;
741}
742#endif
743
744#ifndef OPENSSL_NO_RSA
745static int aep_rsa_mod_exp(BIGNUM *r0, const BIGNUM *I, RSA *rsa)
746 {
747 BN_CTX *ctx = NULL;
748 int to_return = 0;
749 AEP_RV rv = AEP_R_OK;
750
751 if ((ctx = BN_CTX_new()) == NULL)
752 goto err;
753
754 if (!aep_dso)
755 {
756 AEPHKerr(AEPHK_F_AEP_RSA_MOD_EXP,AEPHK_R_NOT_LOADED);
757 goto err;
758 }
759
760 /*See if we have all the necessary bits for a crt*/
761 if (rsa->q && rsa->dmp1 && rsa->dmq1 && rsa->iqmp)
762 {
763 rv = aep_mod_exp_crt(r0,I,rsa->p,rsa->q, rsa->dmp1,rsa->dmq1,rsa->iqmp,ctx);
764
765 if (rv == FAIL_TO_SW){
766 const RSA_METHOD *meth = RSA_PKCS1_SSLeay();
767 to_return = (*meth->rsa_mod_exp)(r0, I, rsa);
768 goto err;
769 }
770 else if (rv != AEP_R_OK)
771 goto err;
772 }
773 else
774 {
775 if (!rsa->d || !rsa->n)
776 {
777 AEPHKerr(AEPHK_F_AEP_RSA_MOD_EXP,AEPHK_R_MISSING_KEY_COMPONENTS);
778 goto err;
779 }
780
781 rv = aep_mod_exp(r0,I,rsa->d,rsa->n,ctx);
782 if (rv != AEP_R_OK)
783 goto err;
784
785 }
786
787 to_return = 1;
788
789 err:
790 if(ctx)
791 BN_CTX_free(ctx);
792 return to_return;
793}
794#endif
795
796#ifndef OPENSSL_NO_DSA
797static int aep_dsa_mod_exp(DSA *dsa, BIGNUM *rr, BIGNUM *a1,
798 BIGNUM *p1, BIGNUM *a2, BIGNUM *p2, BIGNUM *m,
799 BN_CTX *ctx, BN_MONT_CTX *in_mont)
800 {
801 BIGNUM t;
802 int to_return = 0;
803 BN_init(&t);
804
805 /* let rr = a1 ^ p1 mod m */
806 if (!aep_mod_exp(rr,a1,p1,m,ctx)) goto end;
807 /* let t = a2 ^ p2 mod m */
808 if (!aep_mod_exp(&t,a2,p2,m,ctx)) goto end;
809 /* let rr = rr * t mod m */
810 if (!BN_mod_mul(rr,rr,&t,m,ctx)) goto end;
811 to_return = 1;
812 end:
813 BN_free(&t);
814 return to_return;
815 }
816
817static int aep_mod_exp_dsa(DSA *dsa, BIGNUM *r, BIGNUM *a,
818 const BIGNUM *p, const BIGNUM *m, BN_CTX *ctx,
819 BN_MONT_CTX *m_ctx)
820 {
821 return aep_mod_exp(r, a, p, m, ctx);
822 }
823#endif
824
825/* This function is aliased to mod_exp (with the mont stuff dropped). */
826static int aep_mod_exp_mont(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
827 const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx)
828 {
829 return aep_mod_exp(r, a, p, m, ctx);
830 }
831
832#ifndef OPENSSL_NO_DH
833/* This function is aliased to mod_exp (with the dh and mont dropped). */
834static int aep_mod_exp_dh(const DH *dh, BIGNUM *r, const BIGNUM *a,
835 const BIGNUM *p, const BIGNUM *m, BN_CTX *ctx,
836 BN_MONT_CTX *m_ctx)
837 {
838 return aep_mod_exp(r, a, p, m, ctx);
839 }
840#endif
841
842static AEP_RV aep_get_connection(AEP_CONNECTION_HNDL_PTR phConnection)
843 {
844 int count;
845 AEP_RV rv = AEP_R_OK;
846
847 /*Get the current process id*/
848 pid_t curr_pid;
849
850 CRYPTO_w_lock(CRYPTO_LOCK_ENGINE);
851
852 curr_pid = getpid();
853
854 /*Check if this is the first time this is being called from the current
855 process*/
856 if (recorded_pid != curr_pid)
857 {
858 /*Remember our pid so we can check if we're in a new process*/
859 recorded_pid = curr_pid;
860
861 /*Call Finalize to make sure we have not inherited some data
862 from a parent process*/
863 p_AEP_Finalize();
864
865 /*Initialise the AEP API*/
866 rv = p_AEP_Initialize(NULL);
867
868 if (rv != AEP_R_OK)
869 {
870 AEPHKerr(AEPHK_F_AEP_GET_CONNECTION,AEPHK_R_INIT_FAILURE);
871 recorded_pid = 0;
872 goto end;
873 }
874
875 /*Set the AEP big num call back functions*/
876 rv = p_AEP_SetBNCallBacks(&GetBigNumSize, &MakeAEPBigNum,
877 &ConvertAEPBigNum);
878
879 if (rv != AEP_R_OK)
880 {
881 AEPHKerr(AEPHK_F_AEP_GET_CONNECTION,AEPHK_R_SETBNCALLBACK_FAILURE);
882 recorded_pid = 0;
883 goto end;
884 }
885
886#ifdef AEPRAND
887 /*Reset the rand byte count*/
888 rand_block_bytes = 0;
889#endif
890
891 /*Init the structures*/
892 for (count = 0;count < MAX_PROCESS_CONNECTIONS;count ++)
893 {
894 aep_app_conn_table[count].conn_state = NotConnected;
895 aep_app_conn_table[count].conn_hndl = 0;
896 }
897
898 /*Open a connection*/
899 rv = p_AEP_OpenConnection(phConnection);
900
901 if (rv != AEP_R_OK)
902 {
903 AEPHKerr(AEPHK_F_AEP_GET_CONNECTION,AEPHK_R_UNIT_FAILURE);
904 recorded_pid = 0;
905 goto end;
906 }
907
908 aep_app_conn_table[0].conn_state = InUse;
909 aep_app_conn_table[0].conn_hndl = *phConnection;
910 goto end;
911 }
912 /*Check the existing connections to see if we can find a free one*/
913 for (count = 0;count < MAX_PROCESS_CONNECTIONS;count ++)
914 {
915 if (aep_app_conn_table[count].conn_state == Connected)
916 {
917 aep_app_conn_table[count].conn_state = InUse;
918 *phConnection = aep_app_conn_table[count].conn_hndl;
919 goto end;
920 }
921 }
922 /*If no connections available, we're going to have to try
923 to open a new one*/
924 for (count = 0;count < MAX_PROCESS_CONNECTIONS;count ++)
925 {
926 if (aep_app_conn_table[count].conn_state == NotConnected)
927 {
928 /*Open a connection*/
929 rv = p_AEP_OpenConnection(phConnection);
930
931 if (rv != AEP_R_OK)
932 {
933 AEPHKerr(AEPHK_F_AEP_GET_CONNECTION,AEPHK_R_UNIT_FAILURE);
934 goto end;
935 }
936
937 aep_app_conn_table[count].conn_state = InUse;
938 aep_app_conn_table[count].conn_hndl = *phConnection;
939 goto end;
940 }
941 }
942 rv = AEP_R_GENERAL_ERROR;
943 end:
944 CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE);
945 return rv;
946 }
947
948
949static AEP_RV aep_return_connection(AEP_CONNECTION_HNDL hConnection)
950 {
951 int count;
952
953 CRYPTO_w_lock(CRYPTO_LOCK_ENGINE);
954
955 /*Find the connection item that matches this connection handle*/
956 for(count = 0;count < MAX_PROCESS_CONNECTIONS;count ++)
957 {
958 if (aep_app_conn_table[count].conn_hndl == hConnection)
959 {
960 aep_app_conn_table[count].conn_state = Connected;
961 break;
962 }
963 }
964
965 CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE);
966
967 return AEP_R_OK;
968 }
969
970static AEP_RV aep_close_connection(AEP_CONNECTION_HNDL hConnection)
971 {
972 int count;
973 AEP_RV rv = AEP_R_OK;
974
975 CRYPTO_w_lock(CRYPTO_LOCK_ENGINE);
976
977 /*Find the connection item that matches this connection handle*/
978 for(count = 0;count < MAX_PROCESS_CONNECTIONS;count ++)
979 {
980 if (aep_app_conn_table[count].conn_hndl == hConnection)
981 {
982 rv = p_AEP_CloseConnection(aep_app_conn_table[count].conn_hndl);
983 if (rv != AEP_R_OK)
984 goto end;
985 aep_app_conn_table[count].conn_state = NotConnected;
986 aep_app_conn_table[count].conn_hndl = 0;
987 break;
988 }
989 }
990
991 end:
992 CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE);
993 return rv;
994 }
995
996static AEP_RV aep_close_all_connections(int use_engine_lock, int *in_use)
997 {
998 int count;
999 AEP_RV rv = AEP_R_OK;
1000
1001 *in_use = 0;
1002 if (use_engine_lock) CRYPTO_w_lock(CRYPTO_LOCK_ENGINE);
1003 for (count = 0;count < MAX_PROCESS_CONNECTIONS;count ++)
1004 {
1005 switch (aep_app_conn_table[count].conn_state)
1006 {
1007 case Connected:
1008 rv = p_AEP_CloseConnection(aep_app_conn_table[count].conn_hndl);
1009 if (rv != AEP_R_OK)
1010 goto end;
1011 aep_app_conn_table[count].conn_state = NotConnected;
1012 aep_app_conn_table[count].conn_hndl = 0;
1013 break;
1014 case InUse:
1015 (*in_use)++;
1016 break;
1017 case NotConnected:
1018 break;
1019 }
1020 }
1021 end:
1022 if (use_engine_lock) CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE);
1023 return rv;
1024 }
1025
1026/*BigNum call back functions, used to convert OpenSSL bignums into AEP bignums.
1027 Note only 32bit Openssl build support*/
1028
1029static AEP_RV GetBigNumSize(AEP_VOID_PTR ArbBigNum, AEP_U32* BigNumSize)
1030 {
1031 BIGNUM* bn;
1032
1033 /*Cast the ArbBigNum pointer to our BIGNUM struct*/
1034 bn = (BIGNUM*) ArbBigNum;
1035
1036#ifdef SIXTY_FOUR_BIT_LONG
1037 *BigNumSize = bn->top << 3;
1038#else
1039 /*Size of the bignum in bytes is equal to the bn->top (no of 32 bit
1040 words) multiplies by 4*/
1041 *BigNumSize = bn->top << 2;
1042#endif
1043
1044 return AEP_R_OK;
1045 }
1046
1047static AEP_RV MakeAEPBigNum(AEP_VOID_PTR ArbBigNum, AEP_U32 BigNumSize,
1048 unsigned char* AEP_BigNum)
1049 {
1050 BIGNUM* bn;
1051
1052#ifndef SIXTY_FOUR_BIT_LONG
1053 unsigned char* buf;
1054 int i;
1055#endif
1056
1057 /*Cast the ArbBigNum pointer to our BIGNUM struct*/
1058 bn = (BIGNUM*) ArbBigNum;
1059
1060#ifdef SIXTY_FOUR_BIT_LONG
1061 memcpy(AEP_BigNum, bn->d, BigNumSize);
1062#else
1063 /*Must copy data into a (monotone) least significant byte first format
1064 performing endian conversion if necessary*/
1065 for(i=0;i<bn->top;i++)
1066 {
1067 buf = (unsigned char*)&bn->d[i];
1068
1069 *((AEP_U32*)AEP_BigNum) = (AEP_U32)
1070 ((unsigned) buf[1] << 8 | buf[0]) |
1071 ((unsigned) buf[3] << 8 | buf[2]) << 16;
1072
1073 AEP_BigNum += 4;
1074 }
1075#endif
1076
1077 return AEP_R_OK;
1078 }
1079
1080/*Turn an AEP Big Num back to a user big num*/
1081static AEP_RV ConvertAEPBigNum(void* ArbBigNum, AEP_U32 BigNumSize,
1082 unsigned char* AEP_BigNum)
1083 {
1084 BIGNUM* bn;
1085#ifndef SIXTY_FOUR_BIT_LONG
1086 int i;
1087#endif
1088
1089 bn = (BIGNUM*)ArbBigNum;
1090
1091 /*Expand the result bn so that it can hold our big num.
1092 Size is in bits*/
1093 bn_expand(bn, (int)(BigNumSize << 3));
1094
1095#ifdef SIXTY_FOUR_BIT_LONG
1096 bn->top = BigNumSize >> 3;
1097
1098 if((BigNumSize & 7) != 0)
1099 bn->top++;
1100
1101 memset(bn->d, 0, bn->top << 3);
1102
1103 memcpy(bn->d, AEP_BigNum, BigNumSize);
1104#else
1105 bn->top = BigNumSize >> 2;
1106
1107 for(i=0;i<bn->top;i++)
1108 {
1109 bn->d[i] = (AEP_U32)
1110 ((unsigned) AEP_BigNum[3] << 8 | AEP_BigNum[2]) << 16 |
1111 ((unsigned) AEP_BigNum[1] << 8 | AEP_BigNum[0]);
1112 AEP_BigNum += 4;
1113 }
1114#endif
1115
1116 return AEP_R_OK;
1117}
1118
1119#endif /* !OPENSSL_NO_HW_AEP */
1120#endif /* !OPENSSL_NO_HW */
diff --git a/src/lib/libcrypto/engine/hw_aep_err.c b/src/lib/libcrypto/engine/hw_aep_err.c
deleted file mode 100644
index 092f532946..0000000000
--- a/src/lib/libcrypto/engine/hw_aep_err.c
+++ /dev/null
@@ -1,157 +0,0 @@
1/* hw_aep_err.c */
2/* ====================================================================
3 * Copyright (c) 1999 The OpenSSL Project. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 *
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in
14 * the documentation and/or other materials provided with the
15 * distribution.
16 *
17 * 3. All advertising materials mentioning features or use of this
18 * software must display the following acknowledgment:
19 * "This product includes software developed by the OpenSSL Project
20 * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
21 *
22 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
23 * endorse or promote products derived from this software without
24 * prior written permission. For written permission, please contact
25 * openssl-core@OpenSSL.org.
26 *
27 * 5. Products derived from this software may not be called "OpenSSL"
28 * nor may "OpenSSL" appear in their names without prior written
29 * permission of the OpenSSL Project.
30 *
31 * 6. Redistributions of any form whatsoever must retain the following
32 * acknowledgment:
33 * "This product includes software developed by the OpenSSL Project
34 * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
35 *
36 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
37 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
38 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
39 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
40 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
41 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
42 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
43 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
44 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
45 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
46 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
47 * OF THE POSSIBILITY OF SUCH DAMAGE.
48 * ====================================================================
49 *
50 * This product includes cryptographic software written by Eric Young
51 * (eay@cryptsoft.com). This product includes software written by Tim
52 * Hudson (tjh@cryptsoft.com).
53 *
54 */
55
56/* NOTE: this file was auto generated by the mkerr.pl script: any changes
57 * made to it will be overwritten when the script next updates this file,
58 * only reason strings will be preserved.
59 */
60
61#include <stdio.h>
62#include <openssl/err.h>
63#include "hw_aep_err.h"
64
65/* BEGIN ERROR CODES */
66#ifndef OPENSSL_NO_ERR
67static ERR_STRING_DATA AEPHK_str_functs[]=
68 {
69{ERR_PACK(0,AEPHK_F_AEP_CTRL,0), "AEP_CTRL"},
70{ERR_PACK(0,AEPHK_F_AEP_FINISH,0), "AEP_FINISH"},
71{ERR_PACK(0,AEPHK_F_AEP_GET_CONNECTION,0), "AEP_GET_CONNECTION"},
72{ERR_PACK(0,AEPHK_F_AEP_INIT,0), "AEP_INIT"},
73{ERR_PACK(0,AEPHK_F_AEP_MOD_EXP,0), "AEP_MOD_EXP"},
74{ERR_PACK(0,AEPHK_F_AEP_MOD_EXP_CRT,0), "AEP_MOD_EXP_CRT"},
75{ERR_PACK(0,AEPHK_F_AEP_RAND,0), "AEP_RAND"},
76{ERR_PACK(0,AEPHK_F_AEP_RSA_MOD_EXP,0), "AEP_RSA_MOD_EXP"},
77{0,NULL}
78 };
79
80static ERR_STRING_DATA AEPHK_str_reasons[]=
81 {
82{AEPHK_R_ALREADY_LOADED ,"already loaded"},
83{AEPHK_R_CLOSE_HANDLES_FAILED ,"close handles failed"},
84{AEPHK_R_CONNECTIONS_IN_USE ,"connections in use"},
85{AEPHK_R_CTRL_COMMAND_NOT_IMPLEMENTED ,"ctrl command not implemented"},
86{AEPHK_R_FINALIZE_FAILED ,"finalize failed"},
87{AEPHK_R_GET_HANDLE_FAILED ,"get handle failed"},
88{AEPHK_R_GET_RANDOM_FAILED ,"get random failed"},
89{AEPHK_R_INIT_FAILURE ,"init failure"},
90{AEPHK_R_MISSING_KEY_COMPONENTS ,"missing key components"},
91{AEPHK_R_MOD_EXP_CRT_FAILED ,"mod exp crt failed"},
92{AEPHK_R_MOD_EXP_FAILED ,"mod exp failed"},
93{AEPHK_R_NOT_LOADED ,"not loaded"},
94{AEPHK_R_OK ,"ok"},
95{AEPHK_R_RETURN_CONNECTION_FAILED ,"return connection failed"},
96{AEPHK_R_SETBNCALLBACK_FAILURE ,"setbncallback failure"},
97{AEPHK_R_SIZE_TOO_LARGE_OR_TOO_SMALL ,"size too large or too small"},
98{AEPHK_R_UNIT_FAILURE ,"unit failure"},
99{0,NULL}
100 };
101
102#endif
103
104#ifdef AEPHK_LIB_NAME
105static ERR_STRING_DATA AEPHK_lib_name[]=
106 {
107{0 ,AEPHK_LIB_NAME},
108{0,NULL}
109 };
110#endif
111
112
113static int AEPHK_lib_error_code=0;
114static int AEPHK_error_init=1;
115
116static void ERR_load_AEPHK_strings(void)
117 {
118 if (AEPHK_lib_error_code == 0)
119 AEPHK_lib_error_code=ERR_get_next_error_library();
120
121 if (AEPHK_error_init)
122 {
123 AEPHK_error_init=0;
124#ifndef OPENSSL_NO_ERR
125 ERR_load_strings(AEPHK_lib_error_code,AEPHK_str_functs);
126 ERR_load_strings(AEPHK_lib_error_code,AEPHK_str_reasons);
127#endif
128
129#ifdef AEPHK_LIB_NAME
130 AEPHK_lib_name->error = ERR_PACK(AEPHK_lib_error_code,0,0);
131 ERR_load_strings(0,AEPHK_lib_name);
132#endif
133 }
134 }
135
136static void ERR_unload_AEPHK_strings(void)
137 {
138 if (AEPHK_error_init == 0)
139 {
140#ifndef OPENSSL_NO_ERR
141 ERR_unload_strings(AEPHK_lib_error_code,AEPHK_str_functs);
142 ERR_unload_strings(AEPHK_lib_error_code,AEPHK_str_reasons);
143#endif
144
145#ifdef AEPHK_LIB_NAME
146 ERR_unload_strings(0,AEPHK_lib_name);
147#endif
148 AEPHK_error_init=1;
149 }
150 }
151
152static void ERR_AEPHK_error(int function, int reason, char *file, int line)
153 {
154 if (AEPHK_lib_error_code == 0)
155 AEPHK_lib_error_code=ERR_get_next_error_library();
156 ERR_PUT_error(AEPHK_lib_error_code,function,reason,file,line);
157 }
diff --git a/src/lib/libcrypto/engine/hw_aep_err.h b/src/lib/libcrypto/engine/hw_aep_err.h
deleted file mode 100644
index 8fe4cf921f..0000000000
--- a/src/lib/libcrypto/engine/hw_aep_err.h
+++ /dev/null
@@ -1,101 +0,0 @@
1/* ====================================================================
2 * Copyright (c) 2001 The OpenSSL Project. All rights reserved.
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 * openssl-core@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 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
36 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
37 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
38 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
39 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
40 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
41 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
42 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
43 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
44 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
45 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
46 * OF THE POSSIBILITY OF SUCH DAMAGE.
47 * ====================================================================
48 *
49 * This product includes cryptographic software written by Eric Young
50 * (eay@cryptsoft.com). This product includes software written by Tim
51 * Hudson (tjh@cryptsoft.com).
52 *
53 */
54
55#ifndef HEADER_AEPHK_ERR_H
56#define HEADER_AEPHK_ERR_H
57
58/* BEGIN ERROR CODES */
59/* The following lines are auto generated by the script mkerr.pl. Any changes
60 * made after this point may be overwritten when the script is next run.
61 */
62static void ERR_load_AEPHK_strings(void);
63static void ERR_unload_AEPHK_strings(void);
64static void ERR_AEPHK_error(int function, int reason, char *file, int line);
65#define AEPHKerr(f,r) ERR_AEPHK_error((f),(r),__FILE__,__LINE__)
66
67/* Error codes for the AEPHK functions. */
68
69/* Function codes. */
70#define AEPHK_F_AEP_CTRL 100
71#define AEPHK_F_AEP_FINISH 101
72#define AEPHK_F_AEP_GET_CONNECTION 102
73#define AEPHK_F_AEP_INIT 103
74#define AEPHK_F_AEP_MOD_EXP 104
75#define AEPHK_F_AEP_MOD_EXP_CRT 105
76#define AEPHK_F_AEP_RAND 106
77#define AEPHK_F_AEP_RSA_MOD_EXP 107
78
79/* Reason codes. */
80#define AEPHK_R_ALREADY_LOADED 100
81#define AEPHK_R_CLOSE_HANDLES_FAILED 101
82#define AEPHK_R_CONNECTIONS_IN_USE 102
83#define AEPHK_R_CTRL_COMMAND_NOT_IMPLEMENTED 103
84#define AEPHK_R_FINALIZE_FAILED 104
85#define AEPHK_R_GET_HANDLE_FAILED 105
86#define AEPHK_R_GET_RANDOM_FAILED 106
87#define AEPHK_R_INIT_FAILURE 107
88#define AEPHK_R_MISSING_KEY_COMPONENTS 108
89#define AEPHK_R_MOD_EXP_CRT_FAILED 109
90#define AEPHK_R_MOD_EXP_FAILED 110
91#define AEPHK_R_NOT_LOADED 111
92#define AEPHK_R_OK 112
93#define AEPHK_R_RETURN_CONNECTION_FAILED 113
94#define AEPHK_R_SETBNCALLBACK_FAILURE 114
95#define AEPHK_R_SIZE_TOO_LARGE_OR_TOO_SMALL 116
96#define AEPHK_R_UNIT_FAILURE 115
97
98#ifdef __cplusplus
99}
100#endif
101#endif
diff --git a/src/lib/libcrypto/engine/hw_atalla.c b/src/lib/libcrypto/engine/hw_atalla.c
deleted file mode 100644
index 2b8342bbdd..0000000000
--- a/src/lib/libcrypto/engine/hw_atalla.c
+++ /dev/null
@@ -1,595 +0,0 @@
1/* crypto/engine/hw_atalla.c */
2/* Written by Geoff Thorpe (geoff@geoffthorpe.net) for the OpenSSL
3 * project 2000.
4 */
5/* ====================================================================
6 * Copyright (c) 1999-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 * licensing@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 <stdio.h>
60#include <openssl/crypto.h>
61#include "cryptlib.h"
62#include <openssl/dso.h>
63#include <openssl/engine.h>
64
65#ifndef OPENSSL_NO_HW
66#ifndef OPENSSL_NO_HW_ATALLA
67
68#ifdef FLAT_INC
69#include "atalla.h"
70#else
71#include "vendor_defns/atalla.h"
72#endif
73
74#define ATALLA_LIB_NAME "atalla engine"
75#include "hw_atalla_err.c"
76
77static int atalla_destroy(ENGINE *e);
78static int atalla_init(ENGINE *e);
79static int atalla_finish(ENGINE *e);
80static int atalla_ctrl(ENGINE *e, int cmd, long i, void *p, void (*f)());
81
82/* BIGNUM stuff */
83static int atalla_mod_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
84 const BIGNUM *m, BN_CTX *ctx);
85
86#ifndef OPENSSL_NO_RSA
87/* RSA stuff */
88static int atalla_rsa_mod_exp(BIGNUM *r0, const BIGNUM *I, RSA *rsa);
89#endif
90/* This function is aliased to mod_exp (with the mont stuff dropped). */
91static int atalla_mod_exp_mont(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
92 const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx);
93
94#ifndef OPENSSL_NO_DSA
95/* DSA stuff */
96static int atalla_dsa_mod_exp(DSA *dsa, BIGNUM *rr, BIGNUM *a1,
97 BIGNUM *p1, BIGNUM *a2, BIGNUM *p2, BIGNUM *m,
98 BN_CTX *ctx, BN_MONT_CTX *in_mont);
99static int atalla_mod_exp_dsa(DSA *dsa, BIGNUM *r, BIGNUM *a,
100 const BIGNUM *p, const BIGNUM *m, BN_CTX *ctx,
101 BN_MONT_CTX *m_ctx);
102#endif
103
104#ifndef OPENSSL_NO_DH
105/* DH stuff */
106/* This function is alised to mod_exp (with the DH and mont dropped). */
107static int atalla_mod_exp_dh(const DH *dh, BIGNUM *r,
108 const BIGNUM *a, const BIGNUM *p,
109 const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx);
110#endif
111
112/* The definitions for control commands specific to this engine */
113#define ATALLA_CMD_SO_PATH ENGINE_CMD_BASE
114static const ENGINE_CMD_DEFN atalla_cmd_defns[] = {
115 {ATALLA_CMD_SO_PATH,
116 "SO_PATH",
117 "Specifies the path to the 'atasi' shared library",
118 ENGINE_CMD_FLAG_STRING},
119 {0, NULL, NULL, 0}
120 };
121
122#ifndef OPENSSL_NO_RSA
123/* Our internal RSA_METHOD that we provide pointers to */
124static RSA_METHOD atalla_rsa =
125 {
126 "Atalla RSA method",
127 NULL,
128 NULL,
129 NULL,
130 NULL,
131 atalla_rsa_mod_exp,
132 atalla_mod_exp_mont,
133 NULL,
134 NULL,
135 0,
136 NULL,
137 NULL,
138 NULL
139 };
140#endif
141
142#ifndef OPENSSL_NO_DSA
143/* Our internal DSA_METHOD that we provide pointers to */
144static DSA_METHOD atalla_dsa =
145 {
146 "Atalla DSA method",
147 NULL, /* dsa_do_sign */
148 NULL, /* dsa_sign_setup */
149 NULL, /* dsa_do_verify */
150 atalla_dsa_mod_exp, /* dsa_mod_exp */
151 atalla_mod_exp_dsa, /* bn_mod_exp */
152 NULL, /* init */
153 NULL, /* finish */
154 0, /* flags */
155 NULL /* app_data */
156 };
157#endif
158
159#ifndef OPENSSL_NO_DH
160/* Our internal DH_METHOD that we provide pointers to */
161static DH_METHOD atalla_dh =
162 {
163 "Atalla DH method",
164 NULL,
165 NULL,
166 atalla_mod_exp_dh,
167 NULL,
168 NULL,
169 0,
170 NULL
171 };
172#endif
173
174/* Constants used when creating the ENGINE */
175static const char *engine_atalla_id = "atalla";
176static const char *engine_atalla_name = "Atalla hardware engine support";
177
178/* This internal function is used by ENGINE_atalla() and possibly by the
179 * "dynamic" ENGINE support too */
180static int bind_helper(ENGINE *e)
181 {
182#ifndef OPENSSL_NO_RSA
183 const RSA_METHOD *meth1;
184#endif
185#ifndef OPENSSL_NO_DSA
186 const DSA_METHOD *meth2;
187#endif
188#ifndef OPENSSL_NO_DH
189 const DH_METHOD *meth3;
190#endif
191 if(!ENGINE_set_id(e, engine_atalla_id) ||
192 !ENGINE_set_name(e, engine_atalla_name) ||
193#ifndef OPENSSL_NO_RSA
194 !ENGINE_set_RSA(e, &atalla_rsa) ||
195#endif
196#ifndef OPENSSL_NO_DSA
197 !ENGINE_set_DSA(e, &atalla_dsa) ||
198#endif
199#ifndef OPENSSL_NO_DH
200 !ENGINE_set_DH(e, &atalla_dh) ||
201#endif
202 !ENGINE_set_destroy_function(e, atalla_destroy) ||
203 !ENGINE_set_init_function(e, atalla_init) ||
204 !ENGINE_set_finish_function(e, atalla_finish) ||
205 !ENGINE_set_ctrl_function(e, atalla_ctrl) ||
206 !ENGINE_set_cmd_defns(e, atalla_cmd_defns))
207 return 0;
208
209#ifndef OPENSSL_NO_RSA
210 /* We know that the "PKCS1_SSLeay()" functions hook properly
211 * to the atalla-specific mod_exp and mod_exp_crt so we use
212 * those functions. NB: We don't use ENGINE_openssl() or
213 * anything "more generic" because something like the RSAref
214 * code may not hook properly, and if you own one of these
215 * cards then you have the right to do RSA operations on it
216 * anyway! */
217 meth1 = RSA_PKCS1_SSLeay();
218 atalla_rsa.rsa_pub_enc = meth1->rsa_pub_enc;
219 atalla_rsa.rsa_pub_dec = meth1->rsa_pub_dec;
220 atalla_rsa.rsa_priv_enc = meth1->rsa_priv_enc;
221 atalla_rsa.rsa_priv_dec = meth1->rsa_priv_dec;
222#endif
223
224#ifndef OPENSSL_NO_DSA
225 /* Use the DSA_OpenSSL() method and just hook the mod_exp-ish
226 * bits. */
227 meth2 = DSA_OpenSSL();
228 atalla_dsa.dsa_do_sign = meth2->dsa_do_sign;
229 atalla_dsa.dsa_sign_setup = meth2->dsa_sign_setup;
230 atalla_dsa.dsa_do_verify = meth2->dsa_do_verify;
231#endif
232
233#ifndef OPENSSL_NO_DH
234 /* Much the same for Diffie-Hellman */
235 meth3 = DH_OpenSSL();
236 atalla_dh.generate_key = meth3->generate_key;
237 atalla_dh.compute_key = meth3->compute_key;
238#endif
239
240 /* Ensure the atalla error handling is set up */
241 ERR_load_ATALLA_strings();
242 return 1;
243 }
244
245#ifndef ENGINE_DYNAMIC_SUPPORT
246static ENGINE *engine_atalla(void)
247 {
248 ENGINE *ret = ENGINE_new();
249 if(!ret)
250 return NULL;
251 if(!bind_helper(ret))
252 {
253 ENGINE_free(ret);
254 return NULL;
255 }
256 return ret;
257 }
258
259void ENGINE_load_atalla(void)
260 {
261 /* Copied from eng_[openssl|dyn].c */
262 ENGINE *toadd = engine_atalla();
263 if(!toadd) return;
264 ENGINE_add(toadd);
265 ENGINE_free(toadd);
266 ERR_clear_error();
267 }
268#endif
269
270/* This is a process-global DSO handle used for loading and unloading
271 * the Atalla library. NB: This is only set (or unset) during an
272 * init() or finish() call (reference counts permitting) and they're
273 * operating with global locks, so this should be thread-safe
274 * implicitly. */
275static DSO *atalla_dso = NULL;
276
277/* These are the function pointers that are (un)set when the library has
278 * successfully (un)loaded. */
279static tfnASI_GetHardwareConfig *p_Atalla_GetHardwareConfig = NULL;
280static tfnASI_RSAPrivateKeyOpFn *p_Atalla_RSAPrivateKeyOpFn = NULL;
281static tfnASI_GetPerformanceStatistics *p_Atalla_GetPerformanceStatistics = NULL;
282
283/* These are the static string constants for the DSO file name and the function
284 * symbol names to bind to. Regrettably, the DSO name on *nix appears to be
285 * "atasi.so" rather than something more consistent like "libatasi.so". At the
286 * time of writing, I'm not sure what the file name on win32 is but clearly
287 * native name translation is not possible (eg libatasi.so on *nix, and
288 * atasi.dll on win32). For the purposes of testing, I have created a symbollic
289 * link called "libatasi.so" so that we can use native name-translation - a
290 * better solution will be needed. */
291static const char *ATALLA_LIBNAME = NULL;
292static const char *get_ATALLA_LIBNAME(void)
293 {
294 if(ATALLA_LIBNAME)
295 return ATALLA_LIBNAME;
296 return "atasi";
297 }
298static void free_ATALLA_LIBNAME(void)
299 {
300 if(ATALLA_LIBNAME)
301 OPENSSL_free((void*)ATALLA_LIBNAME);
302 ATALLA_LIBNAME = NULL;
303 }
304static long set_ATALLA_LIBNAME(const char *name)
305 {
306 free_ATALLA_LIBNAME();
307 return (((ATALLA_LIBNAME = BUF_strdup(name)) != NULL) ? 1 : 0);
308 }
309static const char *ATALLA_F1 = "ASI_GetHardwareConfig";
310static const char *ATALLA_F2 = "ASI_RSAPrivateKeyOpFn";
311static const char *ATALLA_F3 = "ASI_GetPerformanceStatistics";
312
313/* Destructor (complements the "ENGINE_atalla()" constructor) */
314static int atalla_destroy(ENGINE *e)
315 {
316 free_ATALLA_LIBNAME();
317 /* Unload the atalla error strings so any error state including our
318 * functs or reasons won't lead to a segfault (they simply get displayed
319 * without corresponding string data because none will be found). */
320 ERR_unload_ATALLA_strings();
321 return 1;
322 }
323
324/* (de)initialisation functions. */
325static int atalla_init(ENGINE *e)
326 {
327 tfnASI_GetHardwareConfig *p1;
328 tfnASI_RSAPrivateKeyOpFn *p2;
329 tfnASI_GetPerformanceStatistics *p3;
330 /* Not sure of the origin of this magic value, but Ben's code had it
331 * and it seemed to have been working for a few people. :-) */
332 unsigned int config_buf[1024];
333
334 if(atalla_dso != NULL)
335 {
336 ATALLAerr(ATALLA_F_ATALLA_INIT,ATALLA_R_ALREADY_LOADED);
337 goto err;
338 }
339 /* Attempt to load libatasi.so/atasi.dll/whatever. Needs to be
340 * changed unfortunately because the Atalla drivers don't have
341 * standard library names that can be platform-translated well. */
342 /* TODO: Work out how to actually map to the names the Atalla
343 * drivers really use - for now a symbollic link needs to be
344 * created on the host system from libatasi.so to atasi.so on
345 * unix variants. */
346 atalla_dso = DSO_load(NULL, get_ATALLA_LIBNAME(), NULL, 0);
347 if(atalla_dso == NULL)
348 {
349 ATALLAerr(ATALLA_F_ATALLA_INIT,ATALLA_R_NOT_LOADED);
350 goto err;
351 }
352 if(!(p1 = (tfnASI_GetHardwareConfig *)DSO_bind_func(
353 atalla_dso, ATALLA_F1)) ||
354 !(p2 = (tfnASI_RSAPrivateKeyOpFn *)DSO_bind_func(
355 atalla_dso, ATALLA_F2)) ||
356 !(p3 = (tfnASI_GetPerformanceStatistics *)DSO_bind_func(
357 atalla_dso, ATALLA_F3)))
358 {
359 ATALLAerr(ATALLA_F_ATALLA_INIT,ATALLA_R_NOT_LOADED);
360 goto err;
361 }
362 /* Copy the pointers */
363 p_Atalla_GetHardwareConfig = p1;
364 p_Atalla_RSAPrivateKeyOpFn = p2;
365 p_Atalla_GetPerformanceStatistics = p3;
366 /* Perform a basic test to see if there's actually any unit
367 * running. */
368 if(p1(0L, config_buf) != 0)
369 {
370 ATALLAerr(ATALLA_F_ATALLA_INIT,ATALLA_R_UNIT_FAILURE);
371 goto err;
372 }
373 /* Everything's fine. */
374 return 1;
375err:
376 if(atalla_dso)
377 DSO_free(atalla_dso);
378 atalla_dso = NULL;
379 p_Atalla_GetHardwareConfig = NULL;
380 p_Atalla_RSAPrivateKeyOpFn = NULL;
381 p_Atalla_GetPerformanceStatistics = NULL;
382 return 0;
383 }
384
385static int atalla_finish(ENGINE *e)
386 {
387 free_ATALLA_LIBNAME();
388 if(atalla_dso == NULL)
389 {
390 ATALLAerr(ATALLA_F_ATALLA_FINISH,ATALLA_R_NOT_LOADED);
391 return 0;
392 }
393 if(!DSO_free(atalla_dso))
394 {
395 ATALLAerr(ATALLA_F_ATALLA_FINISH,ATALLA_R_UNIT_FAILURE);
396 return 0;
397 }
398 atalla_dso = NULL;
399 p_Atalla_GetHardwareConfig = NULL;
400 p_Atalla_RSAPrivateKeyOpFn = NULL;
401 p_Atalla_GetPerformanceStatistics = NULL;
402 return 1;
403 }
404
405static int atalla_ctrl(ENGINE *e, int cmd, long i, void *p, void (*f)())
406 {
407 int initialised = ((atalla_dso == NULL) ? 0 : 1);
408 switch(cmd)
409 {
410 case ATALLA_CMD_SO_PATH:
411 if(p == NULL)
412 {
413 ATALLAerr(ATALLA_F_ATALLA_CTRL,ERR_R_PASSED_NULL_PARAMETER);
414 return 0;
415 }
416 if(initialised)
417 {
418 ATALLAerr(ATALLA_F_ATALLA_CTRL,ATALLA_R_ALREADY_LOADED);
419 return 0;
420 }
421 return set_ATALLA_LIBNAME((const char *)p);
422 default:
423 break;
424 }
425 ATALLAerr(ATALLA_F_ATALLA_CTRL,ATALLA_R_CTRL_COMMAND_NOT_IMPLEMENTED);
426 return 0;
427 }
428
429static int atalla_mod_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
430 const BIGNUM *m, BN_CTX *ctx)
431 {
432 /* I need somewhere to store temporary serialised values for
433 * use with the Atalla API calls. A neat cheat - I'll use
434 * BIGNUMs from the BN_CTX but access their arrays directly as
435 * byte arrays <grin>. This way I don't have to clean anything
436 * up. */
437 BIGNUM *modulus;
438 BIGNUM *exponent;
439 BIGNUM *argument;
440 BIGNUM *result;
441 RSAPrivateKey keydata;
442 int to_return, numbytes;
443
444 modulus = exponent = argument = result = NULL;
445 to_return = 0; /* expect failure */
446
447 if(!atalla_dso)
448 {
449 ATALLAerr(ATALLA_F_ATALLA_MOD_EXP,ATALLA_R_NOT_LOADED);
450 goto err;
451 }
452 /* Prepare the params */
453 BN_CTX_start(ctx);
454 modulus = BN_CTX_get(ctx);
455 exponent = BN_CTX_get(ctx);
456 argument = BN_CTX_get(ctx);
457 result = BN_CTX_get(ctx);
458 if (!result)
459 {
460 ATALLAerr(ATALLA_F_ATALLA_MOD_EXP,ATALLA_R_BN_CTX_FULL);
461 goto err;
462 }
463 if(!bn_wexpand(modulus, m->top) || !bn_wexpand(exponent, m->top) ||
464 !bn_wexpand(argument, m->top) || !bn_wexpand(result, m->top))
465 {
466 ATALLAerr(ATALLA_F_ATALLA_MOD_EXP,ATALLA_R_BN_EXPAND_FAIL);
467 goto err;
468 }
469 /* Prepare the key-data */
470 memset(&keydata, 0,sizeof keydata);
471 numbytes = BN_num_bytes(m);
472 memset(exponent->d, 0, numbytes);
473 memset(modulus->d, 0, numbytes);
474 BN_bn2bin(p, (unsigned char *)exponent->d + numbytes - BN_num_bytes(p));
475 BN_bn2bin(m, (unsigned char *)modulus->d + numbytes - BN_num_bytes(m));
476 keydata.privateExponent.data = (unsigned char *)exponent->d;
477 keydata.privateExponent.len = numbytes;
478 keydata.modulus.data = (unsigned char *)modulus->d;
479 keydata.modulus.len = numbytes;
480 /* Prepare the argument */
481 memset(argument->d, 0, numbytes);
482 memset(result->d, 0, numbytes);
483 BN_bn2bin(a, (unsigned char *)argument->d + numbytes - BN_num_bytes(a));
484 /* Perform the operation */
485 if(p_Atalla_RSAPrivateKeyOpFn(&keydata, (unsigned char *)result->d,
486 (unsigned char *)argument->d,
487 keydata.modulus.len) != 0)
488 {
489 ATALLAerr(ATALLA_F_ATALLA_MOD_EXP,ATALLA_R_REQUEST_FAILED);
490 goto err;
491 }
492 /* Convert the response */
493 BN_bin2bn((unsigned char *)result->d, numbytes, r);
494 to_return = 1;
495err:
496 BN_CTX_end(ctx);
497 return to_return;
498 }
499
500#ifndef OPENSSL_NO_RSA
501static int atalla_rsa_mod_exp(BIGNUM *r0, const BIGNUM *I, RSA *rsa)
502 {
503 BN_CTX *ctx = NULL;
504 int to_return = 0;
505
506 if(!atalla_dso)
507 {
508 ATALLAerr(ATALLA_F_ATALLA_RSA_MOD_EXP,ATALLA_R_NOT_LOADED);
509 goto err;
510 }
511 if((ctx = BN_CTX_new()) == NULL)
512 goto err;
513 if(!rsa->d || !rsa->n)
514 {
515 ATALLAerr(ATALLA_F_ATALLA_RSA_MOD_EXP,ATALLA_R_MISSING_KEY_COMPONENTS);
516 goto err;
517 }
518 to_return = atalla_mod_exp(r0, I, rsa->d, rsa->n, ctx);
519err:
520 if(ctx)
521 BN_CTX_free(ctx);
522 return to_return;
523 }
524#endif
525
526#ifndef OPENSSL_NO_DSA
527/* This code was liberated and adapted from the commented-out code in
528 * dsa_ossl.c. Because of the unoptimised form of the Atalla acceleration
529 * (it doesn't have a CRT form for RSA), this function means that an
530 * Atalla system running with a DSA server certificate can handshake
531 * around 5 or 6 times faster/more than an equivalent system running with
532 * RSA. Just check out the "signs" statistics from the RSA and DSA parts
533 * of "openssl speed -engine atalla dsa1024 rsa1024". */
534static int atalla_dsa_mod_exp(DSA *dsa, BIGNUM *rr, BIGNUM *a1,
535 BIGNUM *p1, BIGNUM *a2, BIGNUM *p2, BIGNUM *m,
536 BN_CTX *ctx, BN_MONT_CTX *in_mont)
537 {
538 BIGNUM t;
539 int to_return = 0;
540
541 BN_init(&t);
542 /* let rr = a1 ^ p1 mod m */
543 if (!atalla_mod_exp(rr,a1,p1,m,ctx)) goto end;
544 /* let t = a2 ^ p2 mod m */
545 if (!atalla_mod_exp(&t,a2,p2,m,ctx)) goto end;
546 /* let rr = rr * t mod m */
547 if (!BN_mod_mul(rr,rr,&t,m,ctx)) goto end;
548 to_return = 1;
549end:
550 BN_free(&t);
551 return to_return;
552 }
553
554static int atalla_mod_exp_dsa(DSA *dsa, BIGNUM *r, BIGNUM *a,
555 const BIGNUM *p, const BIGNUM *m, BN_CTX *ctx,
556 BN_MONT_CTX *m_ctx)
557 {
558 return atalla_mod_exp(r, a, p, m, ctx);
559 }
560#endif
561
562/* This function is aliased to mod_exp (with the mont stuff dropped). */
563static int atalla_mod_exp_mont(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
564 const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx)
565 {
566 return atalla_mod_exp(r, a, p, m, ctx);
567 }
568
569#ifndef OPENSSL_NO_DH
570/* This function is aliased to mod_exp (with the dh and mont dropped). */
571static int atalla_mod_exp_dh(const DH *dh, BIGNUM *r,
572 const BIGNUM *a, const BIGNUM *p,
573 const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx)
574 {
575 return atalla_mod_exp(r, a, p, m, ctx);
576 }
577#endif
578
579/* This stuff is needed if this ENGINE is being compiled into a self-contained
580 * shared-library. */
581#ifdef ENGINE_DYNAMIC_SUPPORT
582static int bind_fn(ENGINE *e, const char *id)
583 {
584 if(id && (strcmp(id, engine_atalla_id) != 0))
585 return 0;
586 if(!bind_helper(e))
587 return 0;
588 return 1;
589 }
590IMPLEMENT_DYNAMIC_CHECK_FN()
591IMPLEMENT_DYNAMIC_BIND_FN(bind_fn)
592#endif /* ENGINE_DYNAMIC_SUPPORT */
593
594#endif /* !OPENSSL_NO_HW_ATALLA */
595#endif /* !OPENSSL_NO_HW */
diff --git a/src/lib/libcrypto/engine/hw_atalla_err.c b/src/lib/libcrypto/engine/hw_atalla_err.c
deleted file mode 100644
index 1df9c4570c..0000000000
--- a/src/lib/libcrypto/engine/hw_atalla_err.c
+++ /dev/null
@@ -1,145 +0,0 @@
1/* hw_atalla_err.c */
2/* ====================================================================
3 * Copyright (c) 1999 The OpenSSL Project. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 *
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in
14 * the documentation and/or other materials provided with the
15 * distribution.
16 *
17 * 3. All advertising materials mentioning features or use of this
18 * software must display the following acknowledgment:
19 * "This product includes software developed by the OpenSSL Project
20 * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
21 *
22 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
23 * endorse or promote products derived from this software without
24 * prior written permission. For written permission, please contact
25 * openssl-core@OpenSSL.org.
26 *
27 * 5. Products derived from this software may not be called "OpenSSL"
28 * nor may "OpenSSL" appear in their names without prior written
29 * permission of the OpenSSL Project.
30 *
31 * 6. Redistributions of any form whatsoever must retain the following
32 * acknowledgment:
33 * "This product includes software developed by the OpenSSL Project
34 * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
35 *
36 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
37 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
38 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
39 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
40 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
41 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
42 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
43 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
44 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
45 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
46 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
47 * OF THE POSSIBILITY OF SUCH DAMAGE.
48 * ====================================================================
49 *
50 * This product includes cryptographic software written by Eric Young
51 * (eay@cryptsoft.com). This product includes software written by Tim
52 * Hudson (tjh@cryptsoft.com).
53 *
54 */
55
56/* NOTE: this file was auto generated by the mkerr.pl script: any changes
57 * made to it will be overwritten when the script next updates this file,
58 * only reason strings will be preserved.
59 */
60
61#include <stdio.h>
62#include <openssl/err.h>
63#include "hw_atalla_err.h"
64
65/* BEGIN ERROR CODES */
66#ifndef OPENSSL_NO_ERR
67static ERR_STRING_DATA ATALLA_str_functs[]=
68 {
69{ERR_PACK(0,ATALLA_F_ATALLA_CTRL,0), "ATALLA_CTRL"},
70{ERR_PACK(0,ATALLA_F_ATALLA_FINISH,0), "ATALLA_FINISH"},
71{ERR_PACK(0,ATALLA_F_ATALLA_INIT,0), "ATALLA_INIT"},
72{ERR_PACK(0,ATALLA_F_ATALLA_MOD_EXP,0), "ATALLA_MOD_EXP"},
73{ERR_PACK(0,ATALLA_F_ATALLA_RSA_MOD_EXP,0), "ATALLA_RSA_MOD_EXP"},
74{0,NULL}
75 };
76
77static ERR_STRING_DATA ATALLA_str_reasons[]=
78 {
79{ATALLA_R_ALREADY_LOADED ,"already loaded"},
80{ATALLA_R_BN_CTX_FULL ,"bn ctx full"},
81{ATALLA_R_BN_EXPAND_FAIL ,"bn expand fail"},
82{ATALLA_R_CTRL_COMMAND_NOT_IMPLEMENTED ,"ctrl command not implemented"},
83{ATALLA_R_MISSING_KEY_COMPONENTS ,"missing key components"},
84{ATALLA_R_NOT_LOADED ,"not loaded"},
85{ATALLA_R_REQUEST_FAILED ,"request failed"},
86{ATALLA_R_UNIT_FAILURE ,"unit failure"},
87{0,NULL}
88 };
89
90#endif
91
92#ifdef ATALLA_LIB_NAME
93static ERR_STRING_DATA ATALLA_lib_name[]=
94 {
95{0 ,ATALLA_LIB_NAME},
96{0,NULL}
97 };
98#endif
99
100
101static int ATALLA_lib_error_code=0;
102static int ATALLA_error_init=1;
103
104static void ERR_load_ATALLA_strings(void)
105 {
106 if (ATALLA_lib_error_code == 0)
107 ATALLA_lib_error_code=ERR_get_next_error_library();
108
109 if (ATALLA_error_init)
110 {
111 ATALLA_error_init=0;
112#ifndef OPENSSL_NO_ERR
113 ERR_load_strings(ATALLA_lib_error_code,ATALLA_str_functs);
114 ERR_load_strings(ATALLA_lib_error_code,ATALLA_str_reasons);
115#endif
116
117#ifdef ATALLA_LIB_NAME
118 ATALLA_lib_name->error = ERR_PACK(ATALLA_lib_error_code,0,0);
119 ERR_load_strings(0,ATALLA_lib_name);
120#endif
121 }
122 }
123
124static void ERR_unload_ATALLA_strings(void)
125 {
126 if (ATALLA_error_init == 0)
127 {
128#ifndef OPENSSL_NO_ERR
129 ERR_unload_strings(ATALLA_lib_error_code,ATALLA_str_functs);
130 ERR_unload_strings(ATALLA_lib_error_code,ATALLA_str_reasons);
131#endif
132
133#ifdef ATALLA_LIB_NAME
134 ERR_unload_strings(0,ATALLA_lib_name);
135#endif
136 ATALLA_error_init=1;
137 }
138 }
139
140static void ERR_ATALLA_error(int function, int reason, char *file, int line)
141 {
142 if (ATALLA_lib_error_code == 0)
143 ATALLA_lib_error_code=ERR_get_next_error_library();
144 ERR_PUT_error(ATALLA_lib_error_code,function,reason,file,line);
145 }
diff --git a/src/lib/libcrypto/engine/hw_atalla_err.h b/src/lib/libcrypto/engine/hw_atalla_err.h
deleted file mode 100644
index cdac052d8c..0000000000
--- a/src/lib/libcrypto/engine/hw_atalla_err.h
+++ /dev/null
@@ -1,89 +0,0 @@
1/* ====================================================================
2 * Copyright (c) 2001 The OpenSSL Project. All rights reserved.
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 * openssl-core@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 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
36 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
37 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
38 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
39 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
40 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
41 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
42 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
43 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
44 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
45 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
46 * OF THE POSSIBILITY OF SUCH DAMAGE.
47 * ====================================================================
48 *
49 * This product includes cryptographic software written by Eric Young
50 * (eay@cryptsoft.com). This product includes software written by Tim
51 * Hudson (tjh@cryptsoft.com).
52 *
53 */
54
55#ifndef HEADER_ATALLA_ERR_H
56#define HEADER_ATALLA_ERR_H
57
58/* BEGIN ERROR CODES */
59/* The following lines are auto generated by the script mkerr.pl. Any changes
60 * made after this point may be overwritten when the script is next run.
61 */
62static void ERR_load_ATALLA_strings(void);
63static void ERR_unload_ATALLA_strings(void);
64static void ERR_ATALLA_error(int function, int reason, char *file, int line);
65#define ATALLAerr(f,r) ERR_ATALLA_error((f),(r),__FILE__,__LINE__)
66
67/* Error codes for the ATALLA functions. */
68
69/* Function codes. */
70#define ATALLA_F_ATALLA_CTRL 100
71#define ATALLA_F_ATALLA_FINISH 101
72#define ATALLA_F_ATALLA_INIT 102
73#define ATALLA_F_ATALLA_MOD_EXP 103
74#define ATALLA_F_ATALLA_RSA_MOD_EXP 104
75
76/* Reason codes. */
77#define ATALLA_R_ALREADY_LOADED 100
78#define ATALLA_R_BN_CTX_FULL 101
79#define ATALLA_R_BN_EXPAND_FAIL 102
80#define ATALLA_R_CTRL_COMMAND_NOT_IMPLEMENTED 103
81#define ATALLA_R_MISSING_KEY_COMPONENTS 104
82#define ATALLA_R_NOT_LOADED 105
83#define ATALLA_R_REQUEST_FAILED 106
84#define ATALLA_R_UNIT_FAILURE 107
85
86#ifdef __cplusplus
87}
88#endif
89#endif
diff --git a/src/lib/libcrypto/engine/hw_cswift.c b/src/lib/libcrypto/engine/hw_cswift.c
deleted file mode 100644
index 1411fd8333..0000000000
--- a/src/lib/libcrypto/engine/hw_cswift.c
+++ /dev/null
@@ -1,1109 +0,0 @@
1/* crypto/engine/hw_cswift.c */
2/* Written by Geoff Thorpe (geoff@geoffthorpe.net) for the OpenSSL
3 * project 2000.
4 */
5/* ====================================================================
6 * Copyright (c) 1999-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 * licensing@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 <stdio.h>
60#include <openssl/crypto.h>
61#include "cryptlib.h"
62#include <openssl/dso.h>
63#include <openssl/engine.h>
64
65#ifndef OPENSSL_NO_HW
66#ifndef OPENSSL_NO_HW_CSWIFT
67
68/* Attribution notice: Rainbow have generously allowed me to reproduce
69 * the necessary definitions here from their API. This means the support
70 * can build independently of whether application builders have the
71 * API or hardware. This will allow developers to easily produce software
72 * that has latent hardware support for any users that have accelerators
73 * installed, without the developers themselves needing anything extra.
74 *
75 * I have only clipped the parts from the CryptoSwift header files that
76 * are (or seem) relevant to the CryptoSwift support code. This is
77 * simply to keep the file sizes reasonable.
78 * [Geoff]
79 */
80#ifdef FLAT_INC
81#include "cswift.h"
82#else
83#include "vendor_defns/cswift.h"
84#endif
85
86#define CSWIFT_LIB_NAME "cswift engine"
87#include "hw_cswift_err.c"
88
89static int cswift_destroy(ENGINE *e);
90static int cswift_init(ENGINE *e);
91static int cswift_finish(ENGINE *e);
92static int cswift_ctrl(ENGINE *e, int cmd, long i, void *p, void (*f)());
93static int cswift_bn_32copy(SW_LARGENUMBER * out, const BIGNUM * in);
94
95/* BIGNUM stuff */
96static int cswift_mod_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
97 const BIGNUM *m, BN_CTX *ctx);
98static int cswift_mod_exp_crt(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
99 const BIGNUM *q, const BIGNUM *dmp1, const BIGNUM *dmq1,
100 const BIGNUM *iqmp, BN_CTX *ctx);
101
102#ifndef OPENSSL_NO_RSA
103/* RSA stuff */
104static int cswift_rsa_mod_exp(BIGNUM *r0, const BIGNUM *I, RSA *rsa);
105#endif
106/* This function is aliased to mod_exp (with the mont stuff dropped). */
107static int cswift_mod_exp_mont(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
108 const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx);
109
110#ifndef OPENSSL_NO_DSA
111/* DSA stuff */
112static DSA_SIG *cswift_dsa_sign(const unsigned char *dgst, int dlen, DSA *dsa);
113static int cswift_dsa_verify(const unsigned char *dgst, int dgst_len,
114 DSA_SIG *sig, DSA *dsa);
115#endif
116
117#ifndef OPENSSL_NO_DH
118/* DH stuff */
119/* This function is alised to mod_exp (with the DH and mont dropped). */
120static int cswift_mod_exp_dh(const DH *dh, BIGNUM *r,
121 const BIGNUM *a, const BIGNUM *p,
122 const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx);
123#endif
124
125/* RAND stuff */
126static int cswift_rand_bytes(unsigned char *buf, int num);
127static int cswift_rand_status(void);
128
129/* The definitions for control commands specific to this engine */
130#define CSWIFT_CMD_SO_PATH ENGINE_CMD_BASE
131static const ENGINE_CMD_DEFN cswift_cmd_defns[] = {
132 {CSWIFT_CMD_SO_PATH,
133 "SO_PATH",
134 "Specifies the path to the 'cswift' shared library",
135 ENGINE_CMD_FLAG_STRING},
136 {0, NULL, NULL, 0}
137 };
138
139#ifndef OPENSSL_NO_RSA
140/* Our internal RSA_METHOD that we provide pointers to */
141static RSA_METHOD cswift_rsa =
142 {
143 "CryptoSwift RSA method",
144 NULL,
145 NULL,
146 NULL,
147 NULL,
148 cswift_rsa_mod_exp,
149 cswift_mod_exp_mont,
150 NULL,
151 NULL,
152 0,
153 NULL,
154 NULL,
155 NULL
156 };
157#endif
158
159#ifndef OPENSSL_NO_DSA
160/* Our internal DSA_METHOD that we provide pointers to */
161static DSA_METHOD cswift_dsa =
162 {
163 "CryptoSwift DSA method",
164 cswift_dsa_sign,
165 NULL, /* dsa_sign_setup */
166 cswift_dsa_verify,
167 NULL, /* dsa_mod_exp */
168 NULL, /* bn_mod_exp */
169 NULL, /* init */
170 NULL, /* finish */
171 0, /* flags */
172 NULL /* app_data */
173 };
174#endif
175
176#ifndef OPENSSL_NO_DH
177/* Our internal DH_METHOD that we provide pointers to */
178static DH_METHOD cswift_dh =
179 {
180 "CryptoSwift DH method",
181 NULL,
182 NULL,
183 cswift_mod_exp_dh,
184 NULL,
185 NULL,
186 0,
187 NULL
188 };
189#endif
190
191static RAND_METHOD cswift_random =
192 {
193 /* "CryptoSwift RAND method", */
194 NULL,
195 cswift_rand_bytes,
196 NULL,
197 NULL,
198 cswift_rand_bytes,
199 cswift_rand_status,
200 };
201
202
203/* Constants used when creating the ENGINE */
204static const char *engine_cswift_id = "cswift";
205static const char *engine_cswift_name = "CryptoSwift hardware engine support";
206
207/* This internal function is used by ENGINE_cswift() and possibly by the
208 * "dynamic" ENGINE support too */
209static int bind_helper(ENGINE *e)
210 {
211#ifndef OPENSSL_NO_RSA
212 const RSA_METHOD *meth1;
213#endif
214#ifndef OPENSSL_NO_DH
215 const DH_METHOD *meth2;
216#endif
217 if(!ENGINE_set_id(e, engine_cswift_id) ||
218 !ENGINE_set_name(e, engine_cswift_name) ||
219#ifndef OPENSSL_NO_RSA
220 !ENGINE_set_RSA(e, &cswift_rsa) ||
221#endif
222#ifndef OPENSSL_NO_DSA
223 !ENGINE_set_DSA(e, &cswift_dsa) ||
224#endif
225#ifndef OPENSSL_NO_DH
226 !ENGINE_set_DH(e, &cswift_dh) ||
227#endif
228 !ENGINE_set_RAND(e, &cswift_random) ||
229 !ENGINE_set_destroy_function(e, cswift_destroy) ||
230 !ENGINE_set_init_function(e, cswift_init) ||
231 !ENGINE_set_finish_function(e, cswift_finish) ||
232 !ENGINE_set_ctrl_function(e, cswift_ctrl) ||
233 !ENGINE_set_cmd_defns(e, cswift_cmd_defns))
234 return 0;
235
236#ifndef OPENSSL_NO_RSA
237 /* We know that the "PKCS1_SSLeay()" functions hook properly
238 * to the cswift-specific mod_exp and mod_exp_crt so we use
239 * those functions. NB: We don't use ENGINE_openssl() or
240 * anything "more generic" because something like the RSAref
241 * code may not hook properly, and if you own one of these
242 * cards then you have the right to do RSA operations on it
243 * anyway! */
244 meth1 = RSA_PKCS1_SSLeay();
245 cswift_rsa.rsa_pub_enc = meth1->rsa_pub_enc;
246 cswift_rsa.rsa_pub_dec = meth1->rsa_pub_dec;
247 cswift_rsa.rsa_priv_enc = meth1->rsa_priv_enc;
248 cswift_rsa.rsa_priv_dec = meth1->rsa_priv_dec;
249#endif
250
251#ifndef OPENSSL_NO_DH
252 /* Much the same for Diffie-Hellman */
253 meth2 = DH_OpenSSL();
254 cswift_dh.generate_key = meth2->generate_key;
255 cswift_dh.compute_key = meth2->compute_key;
256#endif
257
258 /* Ensure the cswift error handling is set up */
259 ERR_load_CSWIFT_strings();
260 return 1;
261 }
262
263#ifndef ENGINE_DYNAMIC_SUPPORT
264static ENGINE *engine_cswift(void)
265 {
266 ENGINE *ret = ENGINE_new();
267 if(!ret)
268 return NULL;
269 if(!bind_helper(ret))
270 {
271 ENGINE_free(ret);
272 return NULL;
273 }
274 return ret;
275 }
276
277void ENGINE_load_cswift(void)
278 {
279 /* Copied from eng_[openssl|dyn].c */
280 ENGINE *toadd = engine_cswift();
281 if(!toadd) return;
282 ENGINE_add(toadd);
283 ENGINE_free(toadd);
284 ERR_clear_error();
285 }
286#endif
287
288/* This is a process-global DSO handle used for loading and unloading
289 * the CryptoSwift library. NB: This is only set (or unset) during an
290 * init() or finish() call (reference counts permitting) and they're
291 * operating with global locks, so this should be thread-safe
292 * implicitly. */
293static DSO *cswift_dso = NULL;
294
295/* These are the function pointers that are (un)set when the library has
296 * successfully (un)loaded. */
297t_swAcquireAccContext *p_CSwift_AcquireAccContext = NULL;
298t_swAttachKeyParam *p_CSwift_AttachKeyParam = NULL;
299t_swSimpleRequest *p_CSwift_SimpleRequest = NULL;
300t_swReleaseAccContext *p_CSwift_ReleaseAccContext = NULL;
301
302/* Used in the DSO operations. */
303static const char *CSWIFT_LIBNAME = NULL;
304static const char *get_CSWIFT_LIBNAME(void)
305 {
306 if(CSWIFT_LIBNAME)
307 return CSWIFT_LIBNAME;
308 return "swift";
309 }
310static void free_CSWIFT_LIBNAME(void)
311 {
312 if(CSWIFT_LIBNAME)
313 OPENSSL_free((void*)CSWIFT_LIBNAME);
314 CSWIFT_LIBNAME = NULL;
315 }
316static long set_CSWIFT_LIBNAME(const char *name)
317 {
318 free_CSWIFT_LIBNAME();
319 return (((CSWIFT_LIBNAME = BUF_strdup(name)) != NULL) ? 1 : 0);
320 }
321static const char *CSWIFT_F1 = "swAcquireAccContext";
322static const char *CSWIFT_F2 = "swAttachKeyParam";
323static const char *CSWIFT_F3 = "swSimpleRequest";
324static const char *CSWIFT_F4 = "swReleaseAccContext";
325
326
327/* CryptoSwift library functions and mechanics - these are used by the
328 * higher-level functions further down. NB: As and where there's no
329 * error checking, take a look lower down where these functions are
330 * called, the checking and error handling is probably down there. */
331
332/* utility function to obtain a context */
333static int get_context(SW_CONTEXT_HANDLE *hac)
334 {
335 SW_STATUS status;
336
337 status = p_CSwift_AcquireAccContext(hac);
338 if(status != SW_OK)
339 return 0;
340 return 1;
341 }
342
343/* similarly to release one. */
344static void release_context(SW_CONTEXT_HANDLE hac)
345 {
346 p_CSwift_ReleaseAccContext(hac);
347 }
348
349/* Destructor (complements the "ENGINE_cswift()" constructor) */
350static int cswift_destroy(ENGINE *e)
351 {
352 free_CSWIFT_LIBNAME();
353 ERR_unload_CSWIFT_strings();
354 return 1;
355 }
356
357/* (de)initialisation functions. */
358static int cswift_init(ENGINE *e)
359 {
360 SW_CONTEXT_HANDLE hac;
361 t_swAcquireAccContext *p1;
362 t_swAttachKeyParam *p2;
363 t_swSimpleRequest *p3;
364 t_swReleaseAccContext *p4;
365
366 if(cswift_dso != NULL)
367 {
368 CSWIFTerr(CSWIFT_F_CSWIFT_INIT,CSWIFT_R_ALREADY_LOADED);
369 goto err;
370 }
371 /* Attempt to load libswift.so/swift.dll/whatever. */
372 cswift_dso = DSO_load(NULL, get_CSWIFT_LIBNAME(), NULL, 0);
373 if(cswift_dso == NULL)
374 {
375 CSWIFTerr(CSWIFT_F_CSWIFT_INIT,CSWIFT_R_NOT_LOADED);
376 goto err;
377 }
378 if(!(p1 = (t_swAcquireAccContext *)
379 DSO_bind_func(cswift_dso, CSWIFT_F1)) ||
380 !(p2 = (t_swAttachKeyParam *)
381 DSO_bind_func(cswift_dso, CSWIFT_F2)) ||
382 !(p3 = (t_swSimpleRequest *)
383 DSO_bind_func(cswift_dso, CSWIFT_F3)) ||
384 !(p4 = (t_swReleaseAccContext *)
385 DSO_bind_func(cswift_dso, CSWIFT_F4)))
386 {
387 CSWIFTerr(CSWIFT_F_CSWIFT_INIT,CSWIFT_R_NOT_LOADED);
388 goto err;
389 }
390 /* Copy the pointers */
391 p_CSwift_AcquireAccContext = p1;
392 p_CSwift_AttachKeyParam = p2;
393 p_CSwift_SimpleRequest = p3;
394 p_CSwift_ReleaseAccContext = p4;
395 /* Try and get a context - if not, we may have a DSO but no
396 * accelerator! */
397 if(!get_context(&hac))
398 {
399 CSWIFTerr(CSWIFT_F_CSWIFT_INIT,CSWIFT_R_UNIT_FAILURE);
400 goto err;
401 }
402 release_context(hac);
403 /* Everything's fine. */
404 return 1;
405err:
406 if(cswift_dso)
407 {
408 DSO_free(cswift_dso);
409 cswift_dso = NULL;
410 }
411 p_CSwift_AcquireAccContext = NULL;
412 p_CSwift_AttachKeyParam = NULL;
413 p_CSwift_SimpleRequest = NULL;
414 p_CSwift_ReleaseAccContext = NULL;
415 return 0;
416 }
417
418static int cswift_finish(ENGINE *e)
419 {
420 free_CSWIFT_LIBNAME();
421 if(cswift_dso == NULL)
422 {
423 CSWIFTerr(CSWIFT_F_CSWIFT_FINISH,CSWIFT_R_NOT_LOADED);
424 return 0;
425 }
426 if(!DSO_free(cswift_dso))
427 {
428 CSWIFTerr(CSWIFT_F_CSWIFT_FINISH,CSWIFT_R_UNIT_FAILURE);
429 return 0;
430 }
431 cswift_dso = NULL;
432 p_CSwift_AcquireAccContext = NULL;
433 p_CSwift_AttachKeyParam = NULL;
434 p_CSwift_SimpleRequest = NULL;
435 p_CSwift_ReleaseAccContext = NULL;
436 return 1;
437 }
438
439static int cswift_ctrl(ENGINE *e, int cmd, long i, void *p, void (*f)())
440 {
441 int initialised = ((cswift_dso == NULL) ? 0 : 1);
442 switch(cmd)
443 {
444 case CSWIFT_CMD_SO_PATH:
445 if(p == NULL)
446 {
447 CSWIFTerr(CSWIFT_F_CSWIFT_CTRL,ERR_R_PASSED_NULL_PARAMETER);
448 return 0;
449 }
450 if(initialised)
451 {
452 CSWIFTerr(CSWIFT_F_CSWIFT_CTRL,CSWIFT_R_ALREADY_LOADED);
453 return 0;
454 }
455 return set_CSWIFT_LIBNAME((const char *)p);
456 default:
457 break;
458 }
459 CSWIFTerr(CSWIFT_F_CSWIFT_CTRL,CSWIFT_R_CTRL_COMMAND_NOT_IMPLEMENTED);
460 return 0;
461 }
462
463/* Un petit mod_exp */
464static int cswift_mod_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
465 const BIGNUM *m, BN_CTX *ctx)
466 {
467 /* I need somewhere to store temporary serialised values for
468 * use with the CryptoSwift API calls. A neat cheat - I'll use
469 * BIGNUMs from the BN_CTX but access their arrays directly as
470 * byte arrays <grin>. This way I don't have to clean anything
471 * up. */
472 BIGNUM *modulus;
473 BIGNUM *exponent;
474 BIGNUM *argument;
475 BIGNUM *result;
476 SW_STATUS sw_status;
477 SW_LARGENUMBER arg, res;
478 SW_PARAM sw_param;
479 SW_CONTEXT_HANDLE hac;
480 int to_return, acquired;
481
482 modulus = exponent = argument = result = NULL;
483 to_return = 0; /* expect failure */
484 acquired = 0;
485
486 if(!get_context(&hac))
487 {
488 CSWIFTerr(CSWIFT_F_CSWIFT_MOD_EXP,CSWIFT_R_UNIT_FAILURE);
489 goto err;
490 }
491 acquired = 1;
492 /* Prepare the params */
493 BN_CTX_start(ctx);
494 modulus = BN_CTX_get(ctx);
495 exponent = BN_CTX_get(ctx);
496 argument = BN_CTX_get(ctx);
497 result = BN_CTX_get(ctx);
498 if(!result)
499 {
500 CSWIFTerr(CSWIFT_F_CSWIFT_MOD_EXP,CSWIFT_R_BN_CTX_FULL);
501 goto err;
502 }
503 if(!bn_wexpand(modulus, m->top) || !bn_wexpand(exponent, p->top) ||
504 !bn_wexpand(argument, a->top) || !bn_wexpand(result, m->top))
505 {
506 CSWIFTerr(CSWIFT_F_CSWIFT_MOD_EXP,CSWIFT_R_BN_EXPAND_FAIL);
507 goto err;
508 }
509 sw_param.type = SW_ALG_EXP;
510 sw_param.up.exp.modulus.nbytes = BN_bn2bin(m,
511 (unsigned char *)modulus->d);
512 sw_param.up.exp.modulus.value = (unsigned char *)modulus->d;
513 sw_param.up.exp.exponent.nbytes = BN_bn2bin(p,
514 (unsigned char *)exponent->d);
515 sw_param.up.exp.exponent.value = (unsigned char *)exponent->d;
516 /* Attach the key params */
517 sw_status = p_CSwift_AttachKeyParam(hac, &sw_param);
518 switch(sw_status)
519 {
520 case SW_OK:
521 break;
522 case SW_ERR_INPUT_SIZE:
523 CSWIFTerr(CSWIFT_F_CSWIFT_MOD_EXP,CSWIFT_R_BAD_KEY_SIZE);
524 goto err;
525 default:
526 {
527 char tmpbuf[DECIMAL_SIZE(sw_status)+1];
528 CSWIFTerr(CSWIFT_F_CSWIFT_MOD_EXP,CSWIFT_R_REQUEST_FAILED);
529 sprintf(tmpbuf, "%ld", sw_status);
530 ERR_add_error_data(2, "CryptoSwift error number is ",tmpbuf);
531 }
532 goto err;
533 }
534 /* Prepare the argument and response */
535 arg.nbytes = BN_bn2bin(a, (unsigned char *)argument->d);
536 arg.value = (unsigned char *)argument->d;
537 res.nbytes = BN_num_bytes(m);
538 memset(result->d, 0, res.nbytes);
539 res.value = (unsigned char *)result->d;
540 /* Perform the operation */
541 if((sw_status = p_CSwift_SimpleRequest(hac, SW_CMD_MODEXP, &arg, 1,
542 &res, 1)) != SW_OK)
543 {
544 char tmpbuf[DECIMAL_SIZE(sw_status)+1];
545 CSWIFTerr(CSWIFT_F_CSWIFT_MOD_EXP,CSWIFT_R_REQUEST_FAILED);
546 sprintf(tmpbuf, "%ld", sw_status);
547 ERR_add_error_data(2, "CryptoSwift error number is ",tmpbuf);
548 goto err;
549 }
550 /* Convert the response */
551 BN_bin2bn((unsigned char *)result->d, res.nbytes, r);
552 to_return = 1;
553err:
554 if(acquired)
555 release_context(hac);
556 BN_CTX_end(ctx);
557 return to_return;
558 }
559
560
561int cswift_bn_32copy(SW_LARGENUMBER * out, const BIGNUM * in)
562{
563 int mod;
564 int numbytes = BN_num_bytes(in);
565
566 mod = 0;
567 while( ((out->nbytes = (numbytes+mod)) % 32) )
568 {
569 mod++;
570 }
571 out->value = (unsigned char*)OPENSSL_malloc(out->nbytes);
572 if(!out->value)
573 {
574 return 0;
575 }
576 BN_bn2bin(in, &out->value[mod]);
577 if(mod)
578 memset(out->value, 0, mod);
579
580 return 1;
581}
582
583/* Un petit mod_exp chinois */
584static int cswift_mod_exp_crt(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
585 const BIGNUM *q, const BIGNUM *dmp1,
586 const BIGNUM *dmq1, const BIGNUM *iqmp, BN_CTX *ctx)
587 {
588 SW_STATUS sw_status;
589 SW_LARGENUMBER arg, res;
590 SW_PARAM sw_param;
591 SW_CONTEXT_HANDLE hac;
592 BIGNUM *result = NULL;
593 BIGNUM *argument = NULL;
594 int to_return = 0; /* expect failure */
595 int acquired = 0;
596
597 sw_param.up.crt.p.value = NULL;
598 sw_param.up.crt.q.value = NULL;
599 sw_param.up.crt.dmp1.value = NULL;
600 sw_param.up.crt.dmq1.value = NULL;
601 sw_param.up.crt.iqmp.value = NULL;
602
603 if(!get_context(&hac))
604 {
605 CSWIFTerr(CSWIFT_F_CSWIFT_MOD_EXP_CRT,CSWIFT_R_UNIT_FAILURE);
606 goto err;
607 }
608 acquired = 1;
609
610 /* Prepare the params */
611 argument = BN_new();
612 result = BN_new();
613 if(!result || !argument)
614 {
615 CSWIFTerr(CSWIFT_F_CSWIFT_MOD_EXP_CRT,CSWIFT_R_BN_CTX_FULL);
616 goto err;
617 }
618
619
620 sw_param.type = SW_ALG_CRT;
621 /************************************************************************/
622 /* 04/02/2003 */
623 /* Modified by Frederic Giudicelli (deny-all.com) to overcome the */
624 /* limitation of cswift with values not a multiple of 32 */
625 /************************************************************************/
626 if(!cswift_bn_32copy(&sw_param.up.crt.p, p))
627 {
628 CSWIFTerr(CSWIFT_F_CSWIFT_MOD_EXP_CRT,CSWIFT_R_BN_EXPAND_FAIL);
629 goto err;
630 }
631 if(!cswift_bn_32copy(&sw_param.up.crt.q, q))
632 {
633 CSWIFTerr(CSWIFT_F_CSWIFT_MOD_EXP_CRT,CSWIFT_R_BN_EXPAND_FAIL);
634 goto err;
635 }
636 if(!cswift_bn_32copy(&sw_param.up.crt.dmp1, dmp1))
637 {
638 CSWIFTerr(CSWIFT_F_CSWIFT_MOD_EXP_CRT,CSWIFT_R_BN_EXPAND_FAIL);
639 goto err;
640 }
641 if(!cswift_bn_32copy(&sw_param.up.crt.dmq1, dmq1))
642 {
643 CSWIFTerr(CSWIFT_F_CSWIFT_MOD_EXP_CRT,CSWIFT_R_BN_EXPAND_FAIL);
644 goto err;
645 }
646 if(!cswift_bn_32copy(&sw_param.up.crt.iqmp, iqmp))
647 {
648 CSWIFTerr(CSWIFT_F_CSWIFT_MOD_EXP_CRT,CSWIFT_R_BN_EXPAND_FAIL);
649 goto err;
650 }
651 if( !bn_wexpand(argument, a->top) ||
652 !bn_wexpand(result, p->top + q->top))
653 {
654 CSWIFTerr(CSWIFT_F_CSWIFT_MOD_EXP_CRT,CSWIFT_R_BN_EXPAND_FAIL);
655 goto err;
656 }
657
658 /* Attach the key params */
659 sw_status = p_CSwift_AttachKeyParam(hac, &sw_param);
660 switch(sw_status)
661 {
662 case SW_OK:
663 break;
664 case SW_ERR_INPUT_SIZE:
665 CSWIFTerr(CSWIFT_F_CSWIFT_MOD_EXP_CRT,CSWIFT_R_BAD_KEY_SIZE);
666 goto err;
667 default:
668 {
669 char tmpbuf[DECIMAL_SIZE(sw_status)+1];
670 CSWIFTerr(CSWIFT_F_CSWIFT_MOD_EXP_CRT,CSWIFT_R_REQUEST_FAILED);
671 sprintf(tmpbuf, "%ld", sw_status);
672 ERR_add_error_data(2, "CryptoSwift error number is ",tmpbuf);
673 }
674 goto err;
675 }
676 /* Prepare the argument and response */
677 arg.nbytes = BN_bn2bin(a, (unsigned char *)argument->d);
678 arg.value = (unsigned char *)argument->d;
679 res.nbytes = 2 * BN_num_bytes(p);
680 memset(result->d, 0, res.nbytes);
681 res.value = (unsigned char *)result->d;
682 /* Perform the operation */
683 if((sw_status = p_CSwift_SimpleRequest(hac, SW_CMD_MODEXP_CRT, &arg, 1,
684 &res, 1)) != SW_OK)
685 {
686 char tmpbuf[DECIMAL_SIZE(sw_status)+1];
687 CSWIFTerr(CSWIFT_F_CSWIFT_MOD_EXP_CRT,CSWIFT_R_REQUEST_FAILED);
688 sprintf(tmpbuf, "%ld", sw_status);
689 ERR_add_error_data(2, "CryptoSwift error number is ",tmpbuf);
690 goto err;
691 }
692 /* Convert the response */
693 BN_bin2bn((unsigned char *)result->d, res.nbytes, r);
694 to_return = 1;
695err:
696 if(sw_param.up.crt.p.value)
697 OPENSSL_free(sw_param.up.crt.p.value);
698 if(sw_param.up.crt.q.value)
699 OPENSSL_free(sw_param.up.crt.q.value);
700 if(sw_param.up.crt.dmp1.value)
701 OPENSSL_free(sw_param.up.crt.dmp1.value);
702 if(sw_param.up.crt.dmq1.value)
703 OPENSSL_free(sw_param.up.crt.dmq1.value);
704 if(sw_param.up.crt.iqmp.value)
705 OPENSSL_free(sw_param.up.crt.iqmp.value);
706 if(result)
707 BN_free(result);
708 if(argument)
709 BN_free(argument);
710 if(acquired)
711 release_context(hac);
712 return to_return;
713 }
714
715#ifndef OPENSSL_NO_RSA
716static int cswift_rsa_mod_exp(BIGNUM *r0, const BIGNUM *I, RSA *rsa)
717 {
718 BN_CTX *ctx;
719 int to_return = 0;
720 const RSA_METHOD * def_rsa_method;
721
722 /* Try the limits of RSA (2048 bits) */
723 if(BN_num_bytes(rsa->p) > 128 ||
724 BN_num_bytes(rsa->q) > 128 ||
725 BN_num_bytes(rsa->dmp1) > 128 ||
726 BN_num_bytes(rsa->dmq1) > 128 ||
727 BN_num_bytes(rsa->iqmp) > 128)
728 {
729#ifdef RSA_NULL
730 def_rsa_method=RSA_null_method();
731#else
732#if 0
733 def_rsa_method=RSA_PKCS1_RSAref();
734#else
735 def_rsa_method=RSA_PKCS1_SSLeay();
736#endif
737#endif
738 if(def_rsa_method)
739 return def_rsa_method->rsa_mod_exp(r0, I, rsa);
740 }
741
742 if((ctx = BN_CTX_new()) == NULL)
743 goto err;
744 if(!rsa->p || !rsa->q || !rsa->dmp1 || !rsa->dmq1 || !rsa->iqmp)
745 {
746 CSWIFTerr(CSWIFT_F_CSWIFT_RSA_MOD_EXP,CSWIFT_R_MISSING_KEY_COMPONENTS);
747 goto err;
748 }
749 to_return = cswift_mod_exp_crt(r0, I, rsa->p, rsa->q, rsa->dmp1,
750 rsa->dmq1, rsa->iqmp, ctx);
751err:
752 if(ctx)
753 BN_CTX_free(ctx);
754 return to_return;
755 }
756#endif
757
758/* This function is aliased to mod_exp (with the mont stuff dropped). */
759static int cswift_mod_exp_mont(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
760 const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx)
761 {
762 const RSA_METHOD * def_rsa_method;
763
764 /* Try the limits of RSA (2048 bits) */
765 if(BN_num_bytes(r) > 256 ||
766 BN_num_bytes(a) > 256 ||
767 BN_num_bytes(m) > 256)
768 {
769#ifdef RSA_NULL
770 def_rsa_method=RSA_null_method();
771#else
772#if 0
773 def_rsa_method=RSA_PKCS1_RSAref();
774#else
775 def_rsa_method=RSA_PKCS1_SSLeay();
776#endif
777#endif
778 if(def_rsa_method)
779 return def_rsa_method->bn_mod_exp(r, a, p, m, ctx, m_ctx);
780 }
781
782 return cswift_mod_exp(r, a, p, m, ctx);
783 }
784
785#ifndef OPENSSL_NO_DSA
786static DSA_SIG *cswift_dsa_sign(const unsigned char *dgst, int dlen, DSA *dsa)
787 {
788 SW_CONTEXT_HANDLE hac;
789 SW_PARAM sw_param;
790 SW_STATUS sw_status;
791 SW_LARGENUMBER arg, res;
792 unsigned char *ptr;
793 BN_CTX *ctx;
794 BIGNUM *dsa_p = NULL;
795 BIGNUM *dsa_q = NULL;
796 BIGNUM *dsa_g = NULL;
797 BIGNUM *dsa_key = NULL;
798 BIGNUM *result = NULL;
799 DSA_SIG *to_return = NULL;
800 int acquired = 0;
801
802 if((ctx = BN_CTX_new()) == NULL)
803 goto err;
804 if(!get_context(&hac))
805 {
806 CSWIFTerr(CSWIFT_F_CSWIFT_DSA_SIGN,CSWIFT_R_UNIT_FAILURE);
807 goto err;
808 }
809 acquired = 1;
810 /* Prepare the params */
811 BN_CTX_start(ctx);
812 dsa_p = BN_CTX_get(ctx);
813 dsa_q = BN_CTX_get(ctx);
814 dsa_g = BN_CTX_get(ctx);
815 dsa_key = BN_CTX_get(ctx);
816 result = BN_CTX_get(ctx);
817 if(!result)
818 {
819 CSWIFTerr(CSWIFT_F_CSWIFT_DSA_SIGN,CSWIFT_R_BN_CTX_FULL);
820 goto err;
821 }
822 if(!bn_wexpand(dsa_p, dsa->p->top) ||
823 !bn_wexpand(dsa_q, dsa->q->top) ||
824 !bn_wexpand(dsa_g, dsa->g->top) ||
825 !bn_wexpand(dsa_key, dsa->priv_key->top) ||
826 !bn_wexpand(result, dsa->p->top))
827 {
828 CSWIFTerr(CSWIFT_F_CSWIFT_DSA_SIGN,CSWIFT_R_BN_EXPAND_FAIL);
829 goto err;
830 }
831 sw_param.type = SW_ALG_DSA;
832 sw_param.up.dsa.p.nbytes = BN_bn2bin(dsa->p,
833 (unsigned char *)dsa_p->d);
834 sw_param.up.dsa.p.value = (unsigned char *)dsa_p->d;
835 sw_param.up.dsa.q.nbytes = BN_bn2bin(dsa->q,
836 (unsigned char *)dsa_q->d);
837 sw_param.up.dsa.q.value = (unsigned char *)dsa_q->d;
838 sw_param.up.dsa.g.nbytes = BN_bn2bin(dsa->g,
839 (unsigned char *)dsa_g->d);
840 sw_param.up.dsa.g.value = (unsigned char *)dsa_g->d;
841 sw_param.up.dsa.key.nbytes = BN_bn2bin(dsa->priv_key,
842 (unsigned char *)dsa_key->d);
843 sw_param.up.dsa.key.value = (unsigned char *)dsa_key->d;
844 /* Attach the key params */
845 sw_status = p_CSwift_AttachKeyParam(hac, &sw_param);
846 switch(sw_status)
847 {
848 case SW_OK:
849 break;
850 case SW_ERR_INPUT_SIZE:
851 CSWIFTerr(CSWIFT_F_CSWIFT_DSA_SIGN,CSWIFT_R_BAD_KEY_SIZE);
852 goto err;
853 default:
854 {
855 char tmpbuf[DECIMAL_SIZE(sw_status)+1];
856 CSWIFTerr(CSWIFT_F_CSWIFT_DSA_SIGN,CSWIFT_R_REQUEST_FAILED);
857 sprintf(tmpbuf, "%ld", sw_status);
858 ERR_add_error_data(2, "CryptoSwift error number is ",tmpbuf);
859 }
860 goto err;
861 }
862 /* Prepare the argument and response */
863 arg.nbytes = dlen;
864 arg.value = (unsigned char *)dgst;
865 res.nbytes = BN_num_bytes(dsa->p);
866 memset(result->d, 0, res.nbytes);
867 res.value = (unsigned char *)result->d;
868 /* Perform the operation */
869 sw_status = p_CSwift_SimpleRequest(hac, SW_CMD_DSS_SIGN, &arg, 1,
870 &res, 1);
871 if(sw_status != SW_OK)
872 {
873 char tmpbuf[DECIMAL_SIZE(sw_status)+1];
874 CSWIFTerr(CSWIFT_F_CSWIFT_DSA_SIGN,CSWIFT_R_REQUEST_FAILED);
875 sprintf(tmpbuf, "%ld", sw_status);
876 ERR_add_error_data(2, "CryptoSwift error number is ",tmpbuf);
877 goto err;
878 }
879 /* Convert the response */
880 ptr = (unsigned char *)result->d;
881 if((to_return = DSA_SIG_new()) == NULL)
882 goto err;
883 to_return->r = BN_bin2bn((unsigned char *)result->d, 20, NULL);
884 to_return->s = BN_bin2bn((unsigned char *)result->d + 20, 20, NULL);
885
886err:
887 if(acquired)
888 release_context(hac);
889 if(ctx)
890 {
891 BN_CTX_end(ctx);
892 BN_CTX_free(ctx);
893 }
894 return to_return;
895 }
896
897static int cswift_dsa_verify(const unsigned char *dgst, int dgst_len,
898 DSA_SIG *sig, DSA *dsa)
899 {
900 SW_CONTEXT_HANDLE hac;
901 SW_PARAM sw_param;
902 SW_STATUS sw_status;
903 SW_LARGENUMBER arg[2], res;
904 unsigned long sig_result;
905 BN_CTX *ctx;
906 BIGNUM *dsa_p = NULL;
907 BIGNUM *dsa_q = NULL;
908 BIGNUM *dsa_g = NULL;
909 BIGNUM *dsa_key = NULL;
910 BIGNUM *argument = NULL;
911 int to_return = -1;
912 int acquired = 0;
913
914 if((ctx = BN_CTX_new()) == NULL)
915 goto err;
916 if(!get_context(&hac))
917 {
918 CSWIFTerr(CSWIFT_F_CSWIFT_DSA_VERIFY,CSWIFT_R_UNIT_FAILURE);
919 goto err;
920 }
921 acquired = 1;
922 /* Prepare the params */
923 BN_CTX_start(ctx);
924 dsa_p = BN_CTX_get(ctx);
925 dsa_q = BN_CTX_get(ctx);
926 dsa_g = BN_CTX_get(ctx);
927 dsa_key = BN_CTX_get(ctx);
928 argument = BN_CTX_get(ctx);
929 if(!argument)
930 {
931 CSWIFTerr(CSWIFT_F_CSWIFT_DSA_VERIFY,CSWIFT_R_BN_CTX_FULL);
932 goto err;
933 }
934 if(!bn_wexpand(dsa_p, dsa->p->top) ||
935 !bn_wexpand(dsa_q, dsa->q->top) ||
936 !bn_wexpand(dsa_g, dsa->g->top) ||
937 !bn_wexpand(dsa_key, dsa->pub_key->top) ||
938 !bn_wexpand(argument, 40))
939 {
940 CSWIFTerr(CSWIFT_F_CSWIFT_DSA_VERIFY,CSWIFT_R_BN_EXPAND_FAIL);
941 goto err;
942 }
943 sw_param.type = SW_ALG_DSA;
944 sw_param.up.dsa.p.nbytes = BN_bn2bin(dsa->p,
945 (unsigned char *)dsa_p->d);
946 sw_param.up.dsa.p.value = (unsigned char *)dsa_p->d;
947 sw_param.up.dsa.q.nbytes = BN_bn2bin(dsa->q,
948 (unsigned char *)dsa_q->d);
949 sw_param.up.dsa.q.value = (unsigned char *)dsa_q->d;
950 sw_param.up.dsa.g.nbytes = BN_bn2bin(dsa->g,
951 (unsigned char *)dsa_g->d);
952 sw_param.up.dsa.g.value = (unsigned char *)dsa_g->d;
953 sw_param.up.dsa.key.nbytes = BN_bn2bin(dsa->pub_key,
954 (unsigned char *)dsa_key->d);
955 sw_param.up.dsa.key.value = (unsigned char *)dsa_key->d;
956 /* Attach the key params */
957 sw_status = p_CSwift_AttachKeyParam(hac, &sw_param);
958 switch(sw_status)
959 {
960 case SW_OK:
961 break;
962 case SW_ERR_INPUT_SIZE:
963 CSWIFTerr(CSWIFT_F_CSWIFT_DSA_VERIFY,CSWIFT_R_BAD_KEY_SIZE);
964 goto err;
965 default:
966 {
967 char tmpbuf[DECIMAL_SIZE(sw_status)+1];
968 CSWIFTerr(CSWIFT_F_CSWIFT_DSA_VERIFY,CSWIFT_R_REQUEST_FAILED);
969 sprintf(tmpbuf, "%ld", sw_status);
970 ERR_add_error_data(2, "CryptoSwift error number is ",tmpbuf);
971 }
972 goto err;
973 }
974 /* Prepare the argument and response */
975 arg[0].nbytes = dgst_len;
976 arg[0].value = (unsigned char *)dgst;
977 arg[1].nbytes = 40;
978 arg[1].value = (unsigned char *)argument->d;
979 memset(arg[1].value, 0, 40);
980 BN_bn2bin(sig->r, arg[1].value + 20 - BN_num_bytes(sig->r));
981 BN_bn2bin(sig->s, arg[1].value + 40 - BN_num_bytes(sig->s));
982 res.nbytes = 4; /* unsigned long */
983 res.value = (unsigned char *)(&sig_result);
984 /* Perform the operation */
985 sw_status = p_CSwift_SimpleRequest(hac, SW_CMD_DSS_VERIFY, arg, 2,
986 &res, 1);
987 if(sw_status != SW_OK)
988 {
989 char tmpbuf[DECIMAL_SIZE(sw_status)+1];
990 CSWIFTerr(CSWIFT_F_CSWIFT_DSA_VERIFY,CSWIFT_R_REQUEST_FAILED);
991 sprintf(tmpbuf, "%ld", sw_status);
992 ERR_add_error_data(2, "CryptoSwift error number is ",tmpbuf);
993 goto err;
994 }
995 /* Convert the response */
996 to_return = ((sig_result == 0) ? 0 : 1);
997
998err:
999 if(acquired)
1000 release_context(hac);
1001 if(ctx)
1002 {
1003 BN_CTX_end(ctx);
1004 BN_CTX_free(ctx);
1005 }
1006 return to_return;
1007 }
1008#endif
1009
1010#ifndef OPENSSL_NO_DH
1011/* This function is aliased to mod_exp (with the dh and mont dropped). */
1012static int cswift_mod_exp_dh(const DH *dh, BIGNUM *r,
1013 const BIGNUM *a, const BIGNUM *p,
1014 const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx)
1015 {
1016 return cswift_mod_exp(r, a, p, m, ctx);
1017 }
1018#endif
1019
1020/* Random bytes are good */
1021static int cswift_rand_bytes(unsigned char *buf, int num)
1022{
1023 SW_CONTEXT_HANDLE hac;
1024 SW_STATUS swrc;
1025 SW_LARGENUMBER largenum;
1026 int acquired = 0;
1027 int to_return = 0; /* assume failure */
1028 unsigned char buf32[1024];
1029
1030
1031 if (!get_context(&hac))
1032 {
1033 CSWIFTerr(CSWIFT_F_CSWIFT_CTRL, CSWIFT_R_UNIT_FAILURE);
1034 goto err;
1035 }
1036 acquired = 1;
1037
1038 /************************************************************************/
1039 /* 04/02/2003 */
1040 /* Modified by Frederic Giudicelli (deny-all.com) to overcome the */
1041 /* limitation of cswift with values not a multiple of 32 */
1042 /************************************************************************/
1043
1044 while(num >= sizeof(buf32))
1045 {
1046 largenum.value = buf;
1047 largenum.nbytes = sizeof(buf32);
1048 /* tell CryptoSwift how many bytes we want and where we want it.
1049 * Note: - CryptoSwift cannot do more than 4096 bytes at a time.
1050 * - CryptoSwift can only do multiple of 32-bits. */
1051 swrc = p_CSwift_SimpleRequest(hac, SW_CMD_RAND, NULL, 0, &largenum, 1);
1052 if (swrc != SW_OK)
1053 {
1054 char tmpbuf[20];
1055 CSWIFTerr(CSWIFT_F_CSWIFT_CTRL, CSWIFT_R_REQUEST_FAILED);
1056 sprintf(tmpbuf, "%ld", swrc);
1057 ERR_add_error_data(2, "CryptoSwift error number is ", tmpbuf);
1058 goto err;
1059 }
1060 buf += sizeof(buf32);
1061 num -= sizeof(buf32);
1062 }
1063 if(num)
1064 {
1065 largenum.nbytes = sizeof(buf32);
1066 largenum.value = buf32;
1067 swrc = p_CSwift_SimpleRequest(hac, SW_CMD_RAND, NULL, 0, &largenum, 1);
1068 if (swrc != SW_OK)
1069 {
1070 char tmpbuf[20];
1071 CSWIFTerr(CSWIFT_F_CSWIFT_CTRL, CSWIFT_R_REQUEST_FAILED);
1072 sprintf(tmpbuf, "%ld", swrc);
1073 ERR_add_error_data(2, "CryptoSwift error number is ", tmpbuf);
1074 goto err;
1075 }
1076 memcpy(buf, largenum.value, num);
1077 }
1078
1079 to_return = 1; /* success */
1080err:
1081 if (acquired)
1082 release_context(hac);
1083
1084 return to_return;
1085}
1086
1087static int cswift_rand_status(void)
1088{
1089 return 1;
1090}
1091
1092
1093/* This stuff is needed if this ENGINE is being compiled into a self-contained
1094 * shared-library. */
1095#ifdef ENGINE_DYNAMIC_SUPPORT
1096static int bind_fn(ENGINE *e, const char *id)
1097 {
1098 if(id && (strcmp(id, engine_cswift_id) != 0))
1099 return 0;
1100 if(!bind_helper(e))
1101 return 0;
1102 return 1;
1103 }
1104IMPLEMENT_DYNAMIC_CHECK_FN()
1105IMPLEMENT_DYNAMIC_BIND_FN(bind_fn)
1106#endif /* ENGINE_DYNAMIC_SUPPORT */
1107
1108#endif /* !OPENSSL_NO_HW_CSWIFT */
1109#endif /* !OPENSSL_NO_HW */
diff --git a/src/lib/libcrypto/engine/hw_cswift_err.c b/src/lib/libcrypto/engine/hw_cswift_err.c
deleted file mode 100644
index 684f53bf27..0000000000
--- a/src/lib/libcrypto/engine/hw_cswift_err.c
+++ /dev/null
@@ -1,149 +0,0 @@
1/* hw_cswift_err.c */
2/* ====================================================================
3 * Copyright (c) 1999 The OpenSSL Project. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 *
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in
14 * the documentation and/or other materials provided with the
15 * distribution.
16 *
17 * 3. All advertising materials mentioning features or use of this
18 * software must display the following acknowledgment:
19 * "This product includes software developed by the OpenSSL Project
20 * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
21 *
22 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
23 * endorse or promote products derived from this software without
24 * prior written permission. For written permission, please contact
25 * openssl-core@OpenSSL.org.
26 *
27 * 5. Products derived from this software may not be called "OpenSSL"
28 * nor may "OpenSSL" appear in their names without prior written
29 * permission of the OpenSSL Project.
30 *
31 * 6. Redistributions of any form whatsoever must retain the following
32 * acknowledgment:
33 * "This product includes software developed by the OpenSSL Project
34 * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
35 *
36 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
37 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
38 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
39 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
40 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
41 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
42 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
43 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
44 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
45 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
46 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
47 * OF THE POSSIBILITY OF SUCH DAMAGE.
48 * ====================================================================
49 *
50 * This product includes cryptographic software written by Eric Young
51 * (eay@cryptsoft.com). This product includes software written by Tim
52 * Hudson (tjh@cryptsoft.com).
53 *
54 */
55
56/* NOTE: this file was auto generated by the mkerr.pl script: any changes
57 * made to it will be overwritten when the script next updates this file,
58 * only reason strings will be preserved.
59 */
60
61#include <stdio.h>
62#include <openssl/err.h>
63#include "hw_cswift_err.h"
64
65/* BEGIN ERROR CODES */
66#ifndef OPENSSL_NO_ERR
67static ERR_STRING_DATA CSWIFT_str_functs[]=
68 {
69{ERR_PACK(0,CSWIFT_F_CSWIFT_CTRL,0), "CSWIFT_CTRL"},
70{ERR_PACK(0,CSWIFT_F_CSWIFT_DSA_SIGN,0), "CSWIFT_DSA_SIGN"},
71{ERR_PACK(0,CSWIFT_F_CSWIFT_DSA_VERIFY,0), "CSWIFT_DSA_VERIFY"},
72{ERR_PACK(0,CSWIFT_F_CSWIFT_FINISH,0), "CSWIFT_FINISH"},
73{ERR_PACK(0,CSWIFT_F_CSWIFT_INIT,0), "CSWIFT_INIT"},
74{ERR_PACK(0,CSWIFT_F_CSWIFT_MOD_EXP,0), "CSWIFT_MOD_EXP"},
75{ERR_PACK(0,CSWIFT_F_CSWIFT_MOD_EXP_CRT,0), "CSWIFT_MOD_EXP_CRT"},
76{ERR_PACK(0,CSWIFT_F_CSWIFT_RSA_MOD_EXP,0), "CSWIFT_RSA_MOD_EXP"},
77{0,NULL}
78 };
79
80static ERR_STRING_DATA CSWIFT_str_reasons[]=
81 {
82{CSWIFT_R_ALREADY_LOADED ,"already loaded"},
83{CSWIFT_R_BAD_KEY_SIZE ,"bad key size"},
84{CSWIFT_R_BN_CTX_FULL ,"bn ctx full"},
85{CSWIFT_R_BN_EXPAND_FAIL ,"bn expand fail"},
86{CSWIFT_R_CTRL_COMMAND_NOT_IMPLEMENTED ,"ctrl command not implemented"},
87{CSWIFT_R_MISSING_KEY_COMPONENTS ,"missing key components"},
88{CSWIFT_R_NOT_LOADED ,"not loaded"},
89{CSWIFT_R_REQUEST_FAILED ,"request failed"},
90{CSWIFT_R_UNIT_FAILURE ,"unit failure"},
91{0,NULL}
92 };
93
94#endif
95
96#ifdef CSWIFT_LIB_NAME
97static ERR_STRING_DATA CSWIFT_lib_name[]=
98 {
99{0 ,CSWIFT_LIB_NAME},
100{0,NULL}
101 };
102#endif
103
104
105static int CSWIFT_lib_error_code=0;
106static int CSWIFT_error_init=1;
107
108static void ERR_load_CSWIFT_strings(void)
109 {
110 if (CSWIFT_lib_error_code == 0)
111 CSWIFT_lib_error_code=ERR_get_next_error_library();
112
113 if (CSWIFT_error_init)
114 {
115 CSWIFT_error_init=0;
116#ifndef OPENSSL_NO_ERR
117 ERR_load_strings(CSWIFT_lib_error_code,CSWIFT_str_functs);
118 ERR_load_strings(CSWIFT_lib_error_code,CSWIFT_str_reasons);
119#endif
120
121#ifdef CSWIFT_LIB_NAME
122 CSWIFT_lib_name->error = ERR_PACK(CSWIFT_lib_error_code,0,0);
123 ERR_load_strings(0,CSWIFT_lib_name);
124#endif
125 }
126 }
127
128static void ERR_unload_CSWIFT_strings(void)
129 {
130 if (CSWIFT_error_init == 0)
131 {
132#ifndef OPENSSL_NO_ERR
133 ERR_unload_strings(CSWIFT_lib_error_code,CSWIFT_str_functs);
134 ERR_unload_strings(CSWIFT_lib_error_code,CSWIFT_str_reasons);
135#endif
136
137#ifdef CSWIFT_LIB_NAME
138 ERR_unload_strings(0,CSWIFT_lib_name);
139#endif
140 CSWIFT_error_init=1;
141 }
142 }
143
144static void ERR_CSWIFT_error(int function, int reason, char *file, int line)
145 {
146 if (CSWIFT_lib_error_code == 0)
147 CSWIFT_lib_error_code=ERR_get_next_error_library();
148 ERR_PUT_error(CSWIFT_lib_error_code,function,reason,file,line);
149 }
diff --git a/src/lib/libcrypto/engine/hw_cswift_err.h b/src/lib/libcrypto/engine/hw_cswift_err.h
deleted file mode 100644
index 7120c3216f..0000000000
--- a/src/lib/libcrypto/engine/hw_cswift_err.h
+++ /dev/null
@@ -1,93 +0,0 @@
1/* ====================================================================
2 * Copyright (c) 2001 The OpenSSL Project. All rights reserved.
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 * openssl-core@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 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
36 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
37 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
38 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
39 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
40 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
41 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
42 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
43 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
44 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
45 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
46 * OF THE POSSIBILITY OF SUCH DAMAGE.
47 * ====================================================================
48 *
49 * This product includes cryptographic software written by Eric Young
50 * (eay@cryptsoft.com). This product includes software written by Tim
51 * Hudson (tjh@cryptsoft.com).
52 *
53 */
54
55#ifndef HEADER_CSWIFT_ERR_H
56#define HEADER_CSWIFT_ERR_H
57
58/* BEGIN ERROR CODES */
59/* The following lines are auto generated by the script mkerr.pl. Any changes
60 * made after this point may be overwritten when the script is next run.
61 */
62static void ERR_load_CSWIFT_strings(void);
63static void ERR_unload_CSWIFT_strings(void);
64static void ERR_CSWIFT_error(int function, int reason, char *file, int line);
65#define CSWIFTerr(f,r) ERR_CSWIFT_error((f),(r),__FILE__,__LINE__)
66
67/* Error codes for the CSWIFT functions. */
68
69/* Function codes. */
70#define CSWIFT_F_CSWIFT_CTRL 100
71#define CSWIFT_F_CSWIFT_DSA_SIGN 101
72#define CSWIFT_F_CSWIFT_DSA_VERIFY 102
73#define CSWIFT_F_CSWIFT_FINISH 103
74#define CSWIFT_F_CSWIFT_INIT 104
75#define CSWIFT_F_CSWIFT_MOD_EXP 105
76#define CSWIFT_F_CSWIFT_MOD_EXP_CRT 106
77#define CSWIFT_F_CSWIFT_RSA_MOD_EXP 107
78
79/* Reason codes. */
80#define CSWIFT_R_ALREADY_LOADED 100
81#define CSWIFT_R_BAD_KEY_SIZE 101
82#define CSWIFT_R_BN_CTX_FULL 102
83#define CSWIFT_R_BN_EXPAND_FAIL 103
84#define CSWIFT_R_CTRL_COMMAND_NOT_IMPLEMENTED 104
85#define CSWIFT_R_MISSING_KEY_COMPONENTS 105
86#define CSWIFT_R_NOT_LOADED 106
87#define CSWIFT_R_REQUEST_FAILED 107
88#define CSWIFT_R_UNIT_FAILURE 108
89
90#ifdef __cplusplus
91}
92#endif
93#endif
diff --git a/src/lib/libcrypto/engine/hw_ncipher.c b/src/lib/libcrypto/engine/hw_ncipher.c
deleted file mode 100644
index 0d1c6b8df0..0000000000
--- a/src/lib/libcrypto/engine/hw_ncipher.c
+++ /dev/null
@@ -1,1388 +0,0 @@
1/* crypto/engine/hw_ncipher.c -*- mode: C; c-file-style: "eay" -*- */
2/* Written by Richard Levitte (richard@levitte.org), Geoff Thorpe
3 * (geoff@geoffthorpe.net) and Dr Stephen N Henson (shenson@bigfoot.com)
4 * for the OpenSSL project 2000.
5 */
6/* ====================================================================
7 * Copyright (c) 1999-2001 The OpenSSL Project. All rights reserved.
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
11 * are met:
12 *
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 *
16 * 2. Redistributions in binary form must reproduce the above copyright
17 * notice, this list of conditions and the following disclaimer in
18 * the documentation and/or other materials provided with the
19 * distribution.
20 *
21 * 3. All advertising materials mentioning features or use of this
22 * software must display the following acknowledgment:
23 * "This product includes software developed by the OpenSSL Project
24 * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
25 *
26 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
27 * endorse or promote products derived from this software without
28 * prior written permission. For written permission, please contact
29 * licensing@OpenSSL.org.
30 *
31 * 5. Products derived from this software may not be called "OpenSSL"
32 * nor may "OpenSSL" appear in their names without prior written
33 * permission of the OpenSSL Project.
34 *
35 * 6. Redistributions of any form whatsoever must retain the following
36 * acknowledgment:
37 * "This product includes software developed by the OpenSSL Project
38 * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
39 *
40 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
41 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
42 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
43 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
44 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
45 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
46 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
47 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
49 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
50 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
51 * OF THE POSSIBILITY OF SUCH DAMAGE.
52 * ====================================================================
53 *
54 * This product includes cryptographic software written by Eric Young
55 * (eay@cryptsoft.com). This product includes software written by Tim
56 * Hudson (tjh@cryptsoft.com).
57 *
58 */
59
60#include <stdio.h>
61#include <string.h>
62#include "cryptlib.h"
63#include <openssl/crypto.h>
64#include <openssl/pem.h>
65#include <openssl/dso.h>
66#include <openssl/engine.h>
67#include <openssl/ui.h>
68
69#ifndef OPENSSL_NO_HW
70#ifndef OPENSSL_NO_HW_NCIPHER
71
72/* Attribution notice: nCipher have said several times that it's OK for
73 * us to implement a general interface to their boxes, and recently declared
74 * their HWCryptoHook to be public, and therefore available for us to use.
75 * Thanks, nCipher.
76 *
77 * The hwcryptohook.h included here is from May 2000.
78 * [Richard Levitte]
79 */
80#ifdef FLAT_INC
81#include "hwcryptohook.h"
82#else
83#include "vendor_defns/hwcryptohook.h"
84#endif
85
86#define HWCRHK_LIB_NAME "hwcrhk engine"
87#include "hw_ncipher_err.c"
88
89static int hwcrhk_destroy(ENGINE *e);
90static int hwcrhk_init(ENGINE *e);
91static int hwcrhk_finish(ENGINE *e);
92static int hwcrhk_ctrl(ENGINE *e, int cmd, long i, void *p, void (*f)());
93
94/* Functions to handle mutexes if have dynamic locks */
95static int hwcrhk_mutex_init(HWCryptoHook_Mutex*, HWCryptoHook_CallerContext*);
96static int hwcrhk_mutex_lock(HWCryptoHook_Mutex*);
97static void hwcrhk_mutex_unlock(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
107
108/* BIGNUM stuff */
109static int hwcrhk_mod_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
110 const BIGNUM *m, BN_CTX *ctx);
111
112#ifndef OPENSSL_NO_RSA
113/* RSA stuff */
114static int hwcrhk_rsa_mod_exp(BIGNUM *r, const BIGNUM *I, RSA *rsa);
115#endif
116/* This function is aliased to mod_exp (with the mont stuff dropped). */
117static int hwcrhk_mod_exp_mont(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
118 const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx);
119
120#ifndef OPENSSL_NO_DH
121/* DH stuff */
122/* This function is alised to mod_exp (with the DH and mont dropped). */
123static int hwcrhk_mod_exp_dh(const DH *dh, BIGNUM *r,
124 const BIGNUM *a, const BIGNUM *p,
125 const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx);
126#endif
127
128/* RAND stuff */
129static int hwcrhk_rand_bytes(unsigned char *buf, int num);
130static int hwcrhk_rand_status(void);
131
132/* KM stuff */
133static EVP_PKEY *hwcrhk_load_privkey(ENGINE *eng, const char *key_id,
134 UI_METHOD *ui_method, void *callback_data);
135static EVP_PKEY *hwcrhk_load_pubkey(ENGINE *eng, const char *key_id,
136 UI_METHOD *ui_method, void *callback_data);
137static void hwcrhk_ex_free(void *obj, void *item, CRYPTO_EX_DATA *ad,
138 int ind,long argl, void *argp);
139
140/* Interaction stuff */
141static int hwcrhk_insert_card(const char *prompt_info,
142 const char *wrong_info,
143 HWCryptoHook_PassphraseContext *ppctx,
144 HWCryptoHook_CallerContext *cactx);
145static int hwcrhk_get_pass(const char *prompt_info,
146 int *len_io, char *buf,
147 HWCryptoHook_PassphraseContext *ppctx,
148 HWCryptoHook_CallerContext *cactx);
149static void hwcrhk_log_message(void *logstr, const char *message);
150
151/* The definitions for control commands specific to this engine */
152#define HWCRHK_CMD_SO_PATH ENGINE_CMD_BASE
153#define HWCRHK_CMD_FORK_CHECK (ENGINE_CMD_BASE + 1)
154#define HWCRHK_CMD_THREAD_LOCKING (ENGINE_CMD_BASE + 2)
155#define HWCRHK_CMD_SET_USER_INTERFACE (ENGINE_CMD_BASE + 3)
156#define HWCRHK_CMD_SET_CALLBACK_DATA (ENGINE_CMD_BASE + 4)
157static const ENGINE_CMD_DEFN hwcrhk_cmd_defns[] = {
158 {HWCRHK_CMD_SO_PATH,
159 "SO_PATH",
160 "Specifies the path to the 'hwcrhk' shared library",
161 ENGINE_CMD_FLAG_STRING},
162 {HWCRHK_CMD_FORK_CHECK,
163 "FORK_CHECK",
164 "Turns fork() checking on or off (boolean)",
165 ENGINE_CMD_FLAG_NUMERIC},
166 {HWCRHK_CMD_THREAD_LOCKING,
167 "THREAD_LOCKING",
168 "Turns thread-safe locking on or off (boolean)",
169 ENGINE_CMD_FLAG_NUMERIC},
170 {HWCRHK_CMD_SET_USER_INTERFACE,
171 "SET_USER_INTERFACE",
172 "Set the global user interface (internal)",
173 ENGINE_CMD_FLAG_INTERNAL},
174 {HWCRHK_CMD_SET_CALLBACK_DATA,
175 "SET_CALLBACK_DATA",
176 "Set the global user interface extra data (internal)",
177 ENGINE_CMD_FLAG_INTERNAL},
178 {0, NULL, NULL, 0}
179 };
180
181#ifndef OPENSSL_NO_RSA
182/* Our internal RSA_METHOD that we provide pointers to */
183static RSA_METHOD hwcrhk_rsa =
184 {
185 "nCipher RSA method",
186 NULL,
187 NULL,
188 NULL,
189 NULL,
190 hwcrhk_rsa_mod_exp,
191 hwcrhk_mod_exp_mont,
192 NULL,
193 NULL,
194 0,
195 NULL,
196 NULL,
197 NULL
198 };
199#endif
200
201#ifndef OPENSSL_NO_DH
202/* Our internal DH_METHOD that we provide pointers to */
203static DH_METHOD hwcrhk_dh =
204 {
205 "nCipher DH method",
206 NULL,
207 NULL,
208 hwcrhk_mod_exp_dh,
209 NULL,
210 NULL,
211 0,
212 NULL
213 };
214#endif
215
216static RAND_METHOD hwcrhk_rand =
217 {
218 /* "nCipher RAND method", */
219 NULL,
220 hwcrhk_rand_bytes,
221 NULL,
222 NULL,
223 hwcrhk_rand_bytes,
224 hwcrhk_rand_status,
225 };
226
227/* Constants used when creating the ENGINE */
228static const char *engine_hwcrhk_id = "chil";
229static const char *engine_hwcrhk_name = "nCipher hardware engine support";
230
231/* Internal stuff for HWCryptoHook */
232
233/* Some structures needed for proper use of thread locks */
234/* hwcryptohook.h has some typedefs that turn struct HWCryptoHook_MutexValue
235 into HWCryptoHook_Mutex */
236struct HWCryptoHook_MutexValue
237 {
238 int lockid;
239 };
240
241/* hwcryptohook.h has some typedefs that turn
242 struct HWCryptoHook_PassphraseContextValue
243 into HWCryptoHook_PassphraseContext */
244struct HWCryptoHook_PassphraseContextValue
245 {
246 UI_METHOD *ui_method;
247 void *callback_data;
248 };
249
250/* hwcryptohook.h has some typedefs that turn
251 struct HWCryptoHook_CallerContextValue
252 into HWCryptoHook_CallerContext */
253struct HWCryptoHook_CallerContextValue
254 {
255 pem_password_cb *password_callback; /* Deprecated! Only present for
256 backward compatibility! */
257 UI_METHOD *ui_method;
258 void *callback_data;
259 };
260
261/* The MPI structure in HWCryptoHook is pretty compatible with OpenSSL
262 BIGNUM's, so lets define a couple of conversion macros */
263#define BN2MPI(mp, bn) \
264 {mp.size = bn->top * sizeof(BN_ULONG); mp.buf = (unsigned char *)bn->d;}
265#define MPI2BN(bn, mp) \
266 {mp.size = bn->dmax * sizeof(BN_ULONG); mp.buf = (unsigned char *)bn->d;}
267
268static BIO *logstream = NULL;
269static int disable_mutex_callbacks = 0;
270
271/* One might wonder why these are needed, since one can pass down at least
272 a UI_METHOD and a pointer to callback data to the key-loading functions.
273 The thing is that the ModExp and RSAImmed functions can load keys as well,
274 if the data they get is in a special, nCipher-defined format (hint: if you
275 look at the private exponent of the RSA data as a string, you'll see this
276 string: "nCipher KM tool key id", followed by some bytes, followed a key
277 identity string, followed by more bytes. This happens when you use "embed"
278 keys instead of "hwcrhk" keys). Unfortunately, those functions do not take
279 any passphrase or caller context, and our functions can't really take any
280 callback data either. Still, the "insert_card" and "get_passphrase"
281 callbacks may be called down the line, and will need to know what user
282 interface callbacks to call, and having callback data from the application
283 may be a nice thing as well, so we need to keep track of that globally. */
284static HWCryptoHook_CallerContext password_context = { NULL, NULL, NULL };
285
286/* Stuff to pass to the HWCryptoHook library */
287static HWCryptoHook_InitInfo hwcrhk_globals = {
288 HWCryptoHook_InitFlags_SimpleForkCheck, /* Flags */
289 &logstream, /* logstream */
290 sizeof(BN_ULONG), /* limbsize */
291 0, /* mslimb first: false for BNs */
292 -1, /* msbyte first: use native */
293 0, /* Max mutexes, 0 = no small limit */
294 0, /* Max simultaneous, 0 = default */
295
296 /* The next few are mutex stuff: we write wrapper functions
297 around the OS mutex functions. We initialise them to 0
298 here, and change that to actual function pointers in hwcrhk_init()
299 if dynamic locks are supported (that is, if the application
300 programmer has made sure of setting up callbacks bafore starting
301 this engine) *and* if disable_mutex_callbacks hasn't been set by
302 a call to ENGINE_ctrl(ENGINE_CTRL_CHIL_NO_LOCKING). */
303 sizeof(HWCryptoHook_Mutex),
304 0,
305 0,
306 0,
307 0,
308
309 /* The next few are condvar stuff: we write wrapper functions
310 round the OS functions. Currently not implemented and not
311 and absolute necessity even in threaded programs, therefore
312 0'ed. Will hopefully be implemented some day, since it
313 enhances the efficiency of HWCryptoHook. */
314 0, /* sizeof(HWCryptoHook_CondVar), */
315 0, /* hwcrhk_cv_init, */
316 0, /* hwcrhk_cv_wait, */
317 0, /* hwcrhk_cv_signal, */
318 0, /* hwcrhk_cv_broadcast, */
319 0, /* hwcrhk_cv_destroy, */
320
321 hwcrhk_get_pass, /* pass phrase */
322 hwcrhk_insert_card, /* insert a card */
323 hwcrhk_log_message /* Log message */
324};
325
326
327/* Now, to our own code */
328
329/* This internal function is used by ENGINE_ncipher() and possibly by the
330 * "dynamic" ENGINE support too */
331static int bind_helper(ENGINE *e)
332 {
333#ifndef OPENSSL_NO_RSA
334 const RSA_METHOD *meth1;
335#endif
336#ifndef OPENSSL_NO_DH
337 const DH_METHOD *meth2;
338#endif
339 if(!ENGINE_set_id(e, engine_hwcrhk_id) ||
340 !ENGINE_set_name(e, engine_hwcrhk_name) ||
341#ifndef OPENSSL_NO_RSA
342 !ENGINE_set_RSA(e, &hwcrhk_rsa) ||
343#endif
344#ifndef OPENSSL_NO_DH
345 !ENGINE_set_DH(e, &hwcrhk_dh) ||
346#endif
347 !ENGINE_set_RAND(e, &hwcrhk_rand) ||
348 !ENGINE_set_destroy_function(e, hwcrhk_destroy) ||
349 !ENGINE_set_init_function(e, hwcrhk_init) ||
350 !ENGINE_set_finish_function(e, hwcrhk_finish) ||
351 !ENGINE_set_ctrl_function(e, hwcrhk_ctrl) ||
352 !ENGINE_set_load_privkey_function(e, hwcrhk_load_privkey) ||
353 !ENGINE_set_load_pubkey_function(e, hwcrhk_load_pubkey) ||
354 !ENGINE_set_cmd_defns(e, hwcrhk_cmd_defns))
355 return 0;
356
357#ifndef OPENSSL_NO_RSA
358 /* We know that the "PKCS1_SSLeay()" functions hook properly
359 * to the cswift-specific mod_exp and mod_exp_crt so we use
360 * those functions. NB: We don't use ENGINE_openssl() or
361 * anything "more generic" because something like the RSAref
362 * code may not hook properly, and if you own one of these
363 * cards then you have the right to do RSA operations on it
364 * anyway! */
365 meth1 = RSA_PKCS1_SSLeay();
366 hwcrhk_rsa.rsa_pub_enc = meth1->rsa_pub_enc;
367 hwcrhk_rsa.rsa_pub_dec = meth1->rsa_pub_dec;
368 hwcrhk_rsa.rsa_priv_enc = meth1->rsa_priv_enc;
369 hwcrhk_rsa.rsa_priv_dec = meth1->rsa_priv_dec;
370#endif
371
372#ifndef OPENSSL_NO_DH
373 /* Much the same for Diffie-Hellman */
374 meth2 = DH_OpenSSL();
375 hwcrhk_dh.generate_key = meth2->generate_key;
376 hwcrhk_dh.compute_key = meth2->compute_key;
377#endif
378
379 /* Ensure the hwcrhk error handling is set up */
380 ERR_load_HWCRHK_strings();
381 return 1;
382 }
383
384#ifndef ENGINE_DYNAMIC_SUPPORT
385static ENGINE *engine_ncipher(void)
386 {
387 ENGINE *ret = ENGINE_new();
388 if(!ret)
389 return NULL;
390 if(!bind_helper(ret))
391 {
392 ENGINE_free(ret);
393 return NULL;
394 }
395 return ret;
396 }
397
398void ENGINE_load_chil(void)
399 {
400 /* Copied from eng_[openssl|dyn].c */
401 ENGINE *toadd = engine_ncipher();
402 if(!toadd) return;
403 ENGINE_add(toadd);
404 ENGINE_free(toadd);
405 ERR_clear_error();
406 }
407#endif
408
409/* This is a process-global DSO handle used for loading and unloading
410 * the HWCryptoHook library. NB: This is only set (or unset) during an
411 * init() or finish() call (reference counts permitting) and they're
412 * operating with global locks, so this should be thread-safe
413 * implicitly. */
414static DSO *hwcrhk_dso = NULL;
415static HWCryptoHook_ContextHandle hwcrhk_context = 0;
416#ifndef OPENSSL_NO_RSA
417static int hndidx_rsa = -1; /* Index for KM handle. Not really used yet. */
418#endif
419
420/* These are the function pointers that are (un)set when the library has
421 * successfully (un)loaded. */
422static HWCryptoHook_Init_t *p_hwcrhk_Init = NULL;
423static HWCryptoHook_Finish_t *p_hwcrhk_Finish = NULL;
424static HWCryptoHook_ModExp_t *p_hwcrhk_ModExp = NULL;
425#ifndef OPENSSL_NO_RSA
426static HWCryptoHook_RSA_t *p_hwcrhk_RSA = NULL;
427#endif
428static HWCryptoHook_RandomBytes_t *p_hwcrhk_RandomBytes = NULL;
429#ifndef OPENSSL_NO_RSA
430static HWCryptoHook_RSALoadKey_t *p_hwcrhk_RSALoadKey = NULL;
431static HWCryptoHook_RSAGetPublicKey_t *p_hwcrhk_RSAGetPublicKey = NULL;
432static HWCryptoHook_RSAUnloadKey_t *p_hwcrhk_RSAUnloadKey = NULL;
433#endif
434static HWCryptoHook_ModExpCRT_t *p_hwcrhk_ModExpCRT = NULL;
435
436/* Used in the DSO operations. */
437static const char *HWCRHK_LIBNAME = NULL;
438static void free_HWCRHK_LIBNAME(void)
439 {
440 if(HWCRHK_LIBNAME)
441 OPENSSL_free((void*)HWCRHK_LIBNAME);
442 HWCRHK_LIBNAME = NULL;
443 }
444static const char *get_HWCRHK_LIBNAME(void)
445 {
446 if(HWCRHK_LIBNAME)
447 return HWCRHK_LIBNAME;
448 return "nfhwcrhk";
449 }
450static long set_HWCRHK_LIBNAME(const char *name)
451 {
452 free_HWCRHK_LIBNAME();
453 return (((HWCRHK_LIBNAME = BUF_strdup(name)) != NULL) ? 1 : 0);
454 }
455static const char *n_hwcrhk_Init = "HWCryptoHook_Init";
456static const char *n_hwcrhk_Finish = "HWCryptoHook_Finish";
457static const char *n_hwcrhk_ModExp = "HWCryptoHook_ModExp";
458#ifndef OPENSSL_NO_RSA
459static const char *n_hwcrhk_RSA = "HWCryptoHook_RSA";
460#endif
461static const char *n_hwcrhk_RandomBytes = "HWCryptoHook_RandomBytes";
462#ifndef OPENSSL_NO_RSA
463static const char *n_hwcrhk_RSALoadKey = "HWCryptoHook_RSALoadKey";
464static const char *n_hwcrhk_RSAGetPublicKey = "HWCryptoHook_RSAGetPublicKey";
465static const char *n_hwcrhk_RSAUnloadKey = "HWCryptoHook_RSAUnloadKey";
466#endif
467static const char *n_hwcrhk_ModExpCRT = "HWCryptoHook_ModExpCRT";
468
469/* HWCryptoHook library functions and mechanics - these are used by the
470 * higher-level functions further down. NB: As and where there's no
471 * error checking, take a look lower down where these functions are
472 * called, the checking and error handling is probably down there. */
473
474/* utility function to obtain a context */
475static int get_context(HWCryptoHook_ContextHandle *hac,
476 HWCryptoHook_CallerContext *cac)
477 {
478 char tempbuf[1024];
479 HWCryptoHook_ErrMsgBuf rmsg;
480
481 rmsg.buf = tempbuf;
482 rmsg.size = sizeof(tempbuf);
483
484 *hac = p_hwcrhk_Init(&hwcrhk_globals, sizeof(hwcrhk_globals), &rmsg,
485 cac);
486 if (!*hac)
487 return 0;
488 return 1;
489 }
490
491/* similarly to release one. */
492static void release_context(HWCryptoHook_ContextHandle hac)
493 {
494 p_hwcrhk_Finish(hac);
495 }
496
497/* Destructor (complements the "ENGINE_ncipher()" constructor) */
498static int hwcrhk_destroy(ENGINE *e)
499 {
500 free_HWCRHK_LIBNAME();
501 ERR_unload_HWCRHK_strings();
502 return 1;
503 }
504
505/* (de)initialisation functions. */
506static int hwcrhk_init(ENGINE *e)
507 {
508 HWCryptoHook_Init_t *p1;
509 HWCryptoHook_Finish_t *p2;
510 HWCryptoHook_ModExp_t *p3;
511#ifndef OPENSSL_NO_RSA
512 HWCryptoHook_RSA_t *p4;
513 HWCryptoHook_RSALoadKey_t *p5;
514 HWCryptoHook_RSAGetPublicKey_t *p6;
515 HWCryptoHook_RSAUnloadKey_t *p7;
516#endif
517 HWCryptoHook_RandomBytes_t *p8;
518 HWCryptoHook_ModExpCRT_t *p9;
519
520 if(hwcrhk_dso != NULL)
521 {
522 HWCRHKerr(HWCRHK_F_HWCRHK_INIT,HWCRHK_R_ALREADY_LOADED);
523 goto err;
524 }
525 /* Attempt to load libnfhwcrhk.so/nfhwcrhk.dll/whatever. */
526 hwcrhk_dso = DSO_load(NULL, get_HWCRHK_LIBNAME(), NULL, 0);
527 if(hwcrhk_dso == NULL)
528 {
529 HWCRHKerr(HWCRHK_F_HWCRHK_INIT,HWCRHK_R_DSO_FAILURE);
530 goto err;
531 }
532 if(!(p1 = (HWCryptoHook_Init_t *)
533 DSO_bind_func(hwcrhk_dso, n_hwcrhk_Init)) ||
534 !(p2 = (HWCryptoHook_Finish_t *)
535 DSO_bind_func(hwcrhk_dso, n_hwcrhk_Finish)) ||
536 !(p3 = (HWCryptoHook_ModExp_t *)
537 DSO_bind_func(hwcrhk_dso, n_hwcrhk_ModExp)) ||
538#ifndef OPENSSL_NO_RSA
539 !(p4 = (HWCryptoHook_RSA_t *)
540 DSO_bind_func(hwcrhk_dso, n_hwcrhk_RSA)) ||
541 !(p5 = (HWCryptoHook_RSALoadKey_t *)
542 DSO_bind_func(hwcrhk_dso, n_hwcrhk_RSALoadKey)) ||
543 !(p6 = (HWCryptoHook_RSAGetPublicKey_t *)
544 DSO_bind_func(hwcrhk_dso, n_hwcrhk_RSAGetPublicKey)) ||
545 !(p7 = (HWCryptoHook_RSAUnloadKey_t *)
546 DSO_bind_func(hwcrhk_dso, n_hwcrhk_RSAUnloadKey)) ||
547#endif
548 !(p8 = (HWCryptoHook_RandomBytes_t *)
549 DSO_bind_func(hwcrhk_dso, n_hwcrhk_RandomBytes)) ||
550 !(p9 = (HWCryptoHook_ModExpCRT_t *)
551 DSO_bind_func(hwcrhk_dso, n_hwcrhk_ModExpCRT)))
552 {
553 HWCRHKerr(HWCRHK_F_HWCRHK_INIT,HWCRHK_R_DSO_FAILURE);
554 goto err;
555 }
556 /* Copy the pointers */
557 p_hwcrhk_Init = p1;
558 p_hwcrhk_Finish = p2;
559 p_hwcrhk_ModExp = p3;
560#ifndef OPENSSL_NO_RSA
561 p_hwcrhk_RSA = p4;
562 p_hwcrhk_RSALoadKey = p5;
563 p_hwcrhk_RSAGetPublicKey = p6;
564 p_hwcrhk_RSAUnloadKey = p7;
565#endif
566 p_hwcrhk_RandomBytes = p8;
567 p_hwcrhk_ModExpCRT = p9;
568
569 /* Check if the application decided to support dynamic locks,
570 and if it does, use them. */
571 if (disable_mutex_callbacks == 0)
572 {
573 if (CRYPTO_get_dynlock_create_callback() != NULL &&
574 CRYPTO_get_dynlock_lock_callback() != NULL &&
575 CRYPTO_get_dynlock_destroy_callback() != NULL)
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 }
596 }
597
598 /* Try and get a context - if not, we may have a DSO but no
599 * accelerator! */
600 if(!get_context(&hwcrhk_context, &password_context))
601 {
602 HWCRHKerr(HWCRHK_F_HWCRHK_INIT,HWCRHK_R_UNIT_FAILURE);
603 goto err;
604 }
605 /* Everything's fine. */
606#ifndef OPENSSL_NO_RSA
607 if (hndidx_rsa == -1)
608 hndidx_rsa = RSA_get_ex_new_index(0,
609 "nFast HWCryptoHook RSA key handle",
610 NULL, NULL, hwcrhk_ex_free);
611#endif
612 return 1;
613err:
614 if(hwcrhk_dso)
615 DSO_free(hwcrhk_dso);
616 hwcrhk_dso = NULL;
617 p_hwcrhk_Init = NULL;
618 p_hwcrhk_Finish = NULL;
619 p_hwcrhk_ModExp = NULL;
620#ifndef OPENSSL_NO_RSA
621 p_hwcrhk_RSA = NULL;
622 p_hwcrhk_RSALoadKey = NULL;
623 p_hwcrhk_RSAGetPublicKey = NULL;
624 p_hwcrhk_RSAUnloadKey = NULL;
625#endif
626 p_hwcrhk_ModExpCRT = NULL;
627 p_hwcrhk_RandomBytes = NULL;
628 return 0;
629 }
630
631static int hwcrhk_finish(ENGINE *e)
632 {
633 int to_return = 1;
634 free_HWCRHK_LIBNAME();
635 if(hwcrhk_dso == NULL)
636 {
637 HWCRHKerr(HWCRHK_F_HWCRHK_FINISH,HWCRHK_R_NOT_LOADED);
638 to_return = 0;
639 goto err;
640 }
641 release_context(hwcrhk_context);
642 if(!DSO_free(hwcrhk_dso))
643 {
644 HWCRHKerr(HWCRHK_F_HWCRHK_FINISH,HWCRHK_R_DSO_FAILURE);
645 to_return = 0;
646 goto err;
647 }
648 err:
649 if (logstream)
650 BIO_free(logstream);
651 hwcrhk_dso = NULL;
652 p_hwcrhk_Init = NULL;
653 p_hwcrhk_Finish = NULL;
654 p_hwcrhk_ModExp = NULL;
655#ifndef OPENSSL_NO_RSA
656 p_hwcrhk_RSA = NULL;
657 p_hwcrhk_RSALoadKey = NULL;
658 p_hwcrhk_RSAGetPublicKey = NULL;
659 p_hwcrhk_RSAUnloadKey = NULL;
660#endif
661 p_hwcrhk_ModExpCRT = NULL;
662 p_hwcrhk_RandomBytes = NULL;
663 return to_return;
664 }
665
666static int hwcrhk_ctrl(ENGINE *e, int cmd, long i, void *p, void (*f)())
667 {
668 int to_return = 1;
669
670 switch(cmd)
671 {
672 case HWCRHK_CMD_SO_PATH:
673 if(hwcrhk_dso)
674 {
675 HWCRHKerr(HWCRHK_F_HWCRHK_CTRL,HWCRHK_R_ALREADY_LOADED);
676 return 0;
677 }
678 if(p == NULL)
679 {
680 HWCRHKerr(HWCRHK_F_HWCRHK_CTRL,ERR_R_PASSED_NULL_PARAMETER);
681 return 0;
682 }
683 return set_HWCRHK_LIBNAME((const char *)p);
684 case ENGINE_CTRL_SET_LOGSTREAM:
685 {
686 BIO *bio = (BIO *)p;
687
688 CRYPTO_w_lock(CRYPTO_LOCK_ENGINE);
689 if (logstream)
690 {
691 BIO_free(logstream);
692 logstream = NULL;
693 }
694 if (CRYPTO_add(&bio->references,1,CRYPTO_LOCK_BIO) > 1)
695 logstream = bio;
696 else
697 HWCRHKerr(HWCRHK_F_HWCRHK_CTRL,HWCRHK_R_BIO_WAS_FREED);
698 }
699 CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE);
700 break;
701 case ENGINE_CTRL_SET_PASSWORD_CALLBACK:
702 CRYPTO_w_lock(CRYPTO_LOCK_ENGINE);
703 password_context.password_callback = (pem_password_cb *)f;
704 CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE);
705 break;
706 case ENGINE_CTRL_SET_USER_INTERFACE:
707 case HWCRHK_CMD_SET_USER_INTERFACE:
708 CRYPTO_w_lock(CRYPTO_LOCK_ENGINE);
709 password_context.ui_method = (UI_METHOD *)p;
710 CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE);
711 break;
712 case ENGINE_CTRL_SET_CALLBACK_DATA:
713 case HWCRHK_CMD_SET_CALLBACK_DATA:
714 CRYPTO_w_lock(CRYPTO_LOCK_ENGINE);
715 password_context.callback_data = p;
716 CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE);
717 break;
718 /* this enables or disables the "SimpleForkCheck" flag used in the
719 * initialisation structure. */
720 case ENGINE_CTRL_CHIL_SET_FORKCHECK:
721 case HWCRHK_CMD_FORK_CHECK:
722 CRYPTO_w_lock(CRYPTO_LOCK_ENGINE);
723 if(i)
724 hwcrhk_globals.flags |=
725 HWCryptoHook_InitFlags_SimpleForkCheck;
726 else
727 hwcrhk_globals.flags &=
728 ~HWCryptoHook_InitFlags_SimpleForkCheck;
729 CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE);
730 break;
731 /* This will prevent the initialisation function from "installing"
732 * the mutex-handling callbacks, even if they are available from
733 * within the library (or were provided to the library from the
734 * calling application). This is to remove any baggage for
735 * applications not using multithreading. */
736 case ENGINE_CTRL_CHIL_NO_LOCKING:
737 CRYPTO_w_lock(CRYPTO_LOCK_ENGINE);
738 disable_mutex_callbacks = 1;
739 CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE);
740 break;
741 case HWCRHK_CMD_THREAD_LOCKING:
742 CRYPTO_w_lock(CRYPTO_LOCK_ENGINE);
743 disable_mutex_callbacks = ((i == 0) ? 0 : 1);
744 CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE);
745 break;
746
747 /* The command isn't understood by this engine */
748 default:
749 HWCRHKerr(HWCRHK_F_HWCRHK_CTRL,
750 HWCRHK_R_CTRL_COMMAND_NOT_IMPLEMENTED);
751 to_return = 0;
752 break;
753 }
754
755 return to_return;
756 }
757
758static EVP_PKEY *hwcrhk_load_privkey(ENGINE *eng, const char *key_id,
759 UI_METHOD *ui_method, void *callback_data)
760 {
761#ifndef OPENSSL_NO_RSA
762 RSA *rtmp = NULL;
763#endif
764 EVP_PKEY *res = NULL;
765#ifndef OPENSSL_NO_RSA
766 HWCryptoHook_MPI e, n;
767 HWCryptoHook_RSAKeyHandle *hptr;
768#endif
769#if !defined(OPENSSL_NO_RSA)
770 char tempbuf[1024];
771 HWCryptoHook_ErrMsgBuf rmsg;
772#endif
773 HWCryptoHook_PassphraseContext ppctx;
774
775#if !defined(OPENSSL_NO_RSA)
776 rmsg.buf = tempbuf;
777 rmsg.size = sizeof(tempbuf);
778#endif
779
780 if(!hwcrhk_context)
781 {
782 HWCRHKerr(HWCRHK_F_HWCRHK_LOAD_PRIVKEY,
783 HWCRHK_R_NOT_INITIALISED);
784 goto err;
785 }
786#ifndef OPENSSL_NO_RSA
787 hptr = OPENSSL_malloc(sizeof(HWCryptoHook_RSAKeyHandle));
788 if (!hptr)
789 {
790 HWCRHKerr(HWCRHK_F_HWCRHK_LOAD_PRIVKEY,
791 ERR_R_MALLOC_FAILURE);
792 goto err;
793 }
794 ppctx.ui_method = ui_method;
795 ppctx.callback_data = callback_data;
796 if (p_hwcrhk_RSALoadKey(hwcrhk_context, key_id, hptr,
797 &rmsg, &ppctx))
798 {
799 HWCRHKerr(HWCRHK_F_HWCRHK_LOAD_PRIVKEY,
800 HWCRHK_R_CHIL_ERROR);
801 ERR_add_error_data(1,rmsg.buf);
802 goto err;
803 }
804 if (!*hptr)
805 {
806 HWCRHKerr(HWCRHK_F_HWCRHK_LOAD_PRIVKEY,
807 HWCRHK_R_NO_KEY);
808 goto err;
809 }
810#endif
811#ifndef OPENSSL_NO_RSA
812 rtmp = RSA_new_method(eng);
813 RSA_set_ex_data(rtmp, hndidx_rsa, (char *)hptr);
814 rtmp->e = BN_new();
815 rtmp->n = BN_new();
816 rtmp->flags |= RSA_FLAG_EXT_PKEY;
817 MPI2BN(rtmp->e, e);
818 MPI2BN(rtmp->n, n);
819 if (p_hwcrhk_RSAGetPublicKey(*hptr, &n, &e, &rmsg)
820 != HWCRYPTOHOOK_ERROR_MPISIZE)
821 {
822 HWCRHKerr(HWCRHK_F_HWCRHK_LOAD_PUBKEY,HWCRHK_R_CHIL_ERROR);
823 ERR_add_error_data(1,rmsg.buf);
824 goto err;
825 }
826
827 bn_expand2(rtmp->e, e.size/sizeof(BN_ULONG));
828 bn_expand2(rtmp->n, n.size/sizeof(BN_ULONG));
829 MPI2BN(rtmp->e, e);
830 MPI2BN(rtmp->n, n);
831
832 if (p_hwcrhk_RSAGetPublicKey(*hptr, &n, &e, &rmsg))
833 {
834 HWCRHKerr(HWCRHK_F_HWCRHK_LOAD_PUBKEY,
835 HWCRHK_R_CHIL_ERROR);
836 ERR_add_error_data(1,rmsg.buf);
837 goto err;
838 }
839 rtmp->e->top = e.size / sizeof(BN_ULONG);
840 bn_fix_top(rtmp->e);
841 rtmp->n->top = n.size / sizeof(BN_ULONG);
842 bn_fix_top(rtmp->n);
843
844 res = EVP_PKEY_new();
845 EVP_PKEY_assign_RSA(res, rtmp);
846#endif
847
848 if (!res)
849 HWCRHKerr(HWCRHK_F_HWCRHK_LOAD_PUBKEY,
850 HWCRHK_R_PRIVATE_KEY_ALGORITHMS_DISABLED);
851
852 return res;
853 err:
854 if (res)
855 EVP_PKEY_free(res);
856#ifndef OPENSSL_NO_RSA
857 if (rtmp)
858 RSA_free(rtmp);
859#endif
860 return NULL;
861 }
862
863static EVP_PKEY *hwcrhk_load_pubkey(ENGINE *eng, const char *key_id,
864 UI_METHOD *ui_method, void *callback_data)
865 {
866 EVP_PKEY *res = NULL;
867
868#ifndef OPENSSL_NO_RSA
869 res = hwcrhk_load_privkey(eng, key_id,
870 ui_method, callback_data);
871#endif
872
873 if (res)
874 switch(res->type)
875 {
876#ifndef OPENSSL_NO_RSA
877 case EVP_PKEY_RSA:
878 {
879 RSA *rsa = NULL;
880
881 CRYPTO_w_lock(CRYPTO_LOCK_EVP_PKEY);
882 rsa = res->pkey.rsa;
883 res->pkey.rsa = RSA_new();
884 res->pkey.rsa->n = rsa->n;
885 res->pkey.rsa->e = rsa->e;
886 rsa->n = NULL;
887 rsa->e = NULL;
888 CRYPTO_w_unlock(CRYPTO_LOCK_EVP_PKEY);
889 RSA_free(rsa);
890 }
891 break;
892#endif
893 default:
894 HWCRHKerr(HWCRHK_F_HWCRHK_LOAD_PUBKEY,
895 HWCRHK_R_CTRL_COMMAND_NOT_IMPLEMENTED);
896 goto err;
897 }
898
899 return res;
900 err:
901 if (res)
902 EVP_PKEY_free(res);
903 return NULL;
904 }
905
906/* A little mod_exp */
907static int hwcrhk_mod_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
908 const BIGNUM *m, BN_CTX *ctx)
909 {
910 char tempbuf[1024];
911 HWCryptoHook_ErrMsgBuf rmsg;
912 /* Since HWCryptoHook_MPI is pretty compatible with BIGNUM's,
913 we use them directly, plus a little macro magic. We only
914 thing we need to make sure of is that enough space is allocated. */
915 HWCryptoHook_MPI m_a, m_p, m_n, m_r;
916 int to_return, ret;
917
918 to_return = 0; /* expect failure */
919 rmsg.buf = tempbuf;
920 rmsg.size = sizeof(tempbuf);
921
922 if(!hwcrhk_context)
923 {
924 HWCRHKerr(HWCRHK_F_HWCRHK_MOD_EXP,HWCRHK_R_NOT_INITIALISED);
925 goto err;
926 }
927 /* Prepare the params */
928 bn_expand2(r, m->top); /* Check for error !! */
929 BN2MPI(m_a, a);
930 BN2MPI(m_p, p);
931 BN2MPI(m_n, m);
932 MPI2BN(r, m_r);
933
934 /* Perform the operation */
935 ret = p_hwcrhk_ModExp(hwcrhk_context, m_a, m_p, m_n, &m_r, &rmsg);
936
937 /* Convert the response */
938 r->top = m_r.size / sizeof(BN_ULONG);
939 bn_fix_top(r);
940
941 if (ret < 0)
942 {
943 /* FIXME: When this error is returned, HWCryptoHook is
944 telling us that falling back to software computation
945 might be a good thing. */
946 if(ret == HWCRYPTOHOOK_ERROR_FALLBACK)
947 {
948 HWCRHKerr(HWCRHK_F_HWCRHK_MOD_EXP,HWCRHK_R_REQUEST_FALLBACK);
949 }
950 else
951 {
952 HWCRHKerr(HWCRHK_F_HWCRHK_MOD_EXP,HWCRHK_R_REQUEST_FAILED);
953 }
954 ERR_add_error_data(1,rmsg.buf);
955 goto err;
956 }
957
958 to_return = 1;
959err:
960 return to_return;
961 }
962
963#ifndef OPENSSL_NO_RSA
964static int hwcrhk_rsa_mod_exp(BIGNUM *r, const BIGNUM *I, RSA *rsa)
965 {
966 char tempbuf[1024];
967 HWCryptoHook_ErrMsgBuf rmsg;
968 HWCryptoHook_RSAKeyHandle *hptr;
969 int to_return = 0, ret;
970
971 rmsg.buf = tempbuf;
972 rmsg.size = sizeof(tempbuf);
973
974 if(!hwcrhk_context)
975 {
976 HWCRHKerr(HWCRHK_F_HWCRHK_MOD_EXP,HWCRHK_R_NOT_INITIALISED);
977 goto err;
978 }
979
980 /* This provides support for nForce keys. Since that's opaque data
981 all we do is provide a handle to the proper key and let HWCryptoHook
982 take care of the rest. */
983 if ((hptr = (HWCryptoHook_RSAKeyHandle *) RSA_get_ex_data(rsa, hndidx_rsa))
984 != NULL)
985 {
986 HWCryptoHook_MPI m_a, m_r;
987
988 if(!rsa->n)
989 {
990 HWCRHKerr(HWCRHK_F_HWCRHK_RSA_MOD_EXP,
991 HWCRHK_R_MISSING_KEY_COMPONENTS);
992 goto err;
993 }
994
995 /* Prepare the params */
996 bn_expand2(r, rsa->n->top); /* Check for error !! */
997 BN2MPI(m_a, I);
998 MPI2BN(r, m_r);
999
1000 /* Perform the operation */
1001 ret = p_hwcrhk_RSA(m_a, *hptr, &m_r, &rmsg);
1002
1003 /* Convert the response */
1004 r->top = m_r.size / sizeof(BN_ULONG);
1005 bn_fix_top(r);
1006
1007 if (ret < 0)
1008 {
1009 /* FIXME: When this error is returned, HWCryptoHook is
1010 telling us that falling back to software computation
1011 might be a good thing. */
1012 if(ret == HWCRYPTOHOOK_ERROR_FALLBACK)
1013 {
1014 HWCRHKerr(HWCRHK_F_HWCRHK_RSA_MOD_EXP,
1015 HWCRHK_R_REQUEST_FALLBACK);
1016 }
1017 else
1018 {
1019 HWCRHKerr(HWCRHK_F_HWCRHK_RSA_MOD_EXP,
1020 HWCRHK_R_REQUEST_FAILED);
1021 }
1022 ERR_add_error_data(1,rmsg.buf);
1023 goto err;
1024 }
1025 }
1026 else
1027 {
1028 HWCryptoHook_MPI m_a, m_p, m_q, m_dmp1, m_dmq1, m_iqmp, m_r;
1029
1030 if(!rsa->p || !rsa->q || !rsa->dmp1 || !rsa->dmq1 || !rsa->iqmp)
1031 {
1032 HWCRHKerr(HWCRHK_F_HWCRHK_RSA_MOD_EXP,
1033 HWCRHK_R_MISSING_KEY_COMPONENTS);
1034 goto err;
1035 }
1036
1037 /* Prepare the params */
1038 bn_expand2(r, rsa->n->top); /* Check for error !! */
1039 BN2MPI(m_a, I);
1040 BN2MPI(m_p, rsa->p);
1041 BN2MPI(m_q, rsa->q);
1042 BN2MPI(m_dmp1, rsa->dmp1);
1043 BN2MPI(m_dmq1, rsa->dmq1);
1044 BN2MPI(m_iqmp, rsa->iqmp);
1045 MPI2BN(r, m_r);
1046
1047 /* Perform the operation */
1048 ret = p_hwcrhk_ModExpCRT(hwcrhk_context, m_a, m_p, m_q,
1049 m_dmp1, m_dmq1, m_iqmp, &m_r, &rmsg);
1050
1051 /* Convert the response */
1052 r->top = m_r.size / sizeof(BN_ULONG);
1053 bn_fix_top(r);
1054
1055 if (ret < 0)
1056 {
1057 /* FIXME: When this error is returned, HWCryptoHook is
1058 telling us that falling back to software computation
1059 might be a good thing. */
1060 if(ret == HWCRYPTOHOOK_ERROR_FALLBACK)
1061 {
1062 HWCRHKerr(HWCRHK_F_HWCRHK_RSA_MOD_EXP,
1063 HWCRHK_R_REQUEST_FALLBACK);
1064 }
1065 else
1066 {
1067 HWCRHKerr(HWCRHK_F_HWCRHK_RSA_MOD_EXP,
1068 HWCRHK_R_REQUEST_FAILED);
1069 }
1070 ERR_add_error_data(1,rmsg.buf);
1071 goto err;
1072 }
1073 }
1074 /* If we're here, we must be here with some semblance of success :-) */
1075 to_return = 1;
1076err:
1077 return to_return;
1078 }
1079#endif
1080
1081/* This function is aliased to mod_exp (with the mont stuff dropped). */
1082static int hwcrhk_mod_exp_mont(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
1083 const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx)
1084 {
1085 return hwcrhk_mod_exp(r, a, p, m, ctx);
1086 }
1087
1088#ifndef OPENSSL_NO_DH
1089/* This function is aliased to mod_exp (with the dh and mont dropped). */
1090static int hwcrhk_mod_exp_dh(const DH *dh, BIGNUM *r,
1091 const BIGNUM *a, const BIGNUM *p,
1092 const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx)
1093 {
1094 return hwcrhk_mod_exp(r, a, p, m, ctx);
1095 }
1096#endif
1097
1098/* Random bytes are good */
1099static int hwcrhk_rand_bytes(unsigned char *buf, int num)
1100 {
1101 char tempbuf[1024];
1102 HWCryptoHook_ErrMsgBuf rmsg;
1103 int to_return = 0; /* assume failure */
1104 int ret;
1105
1106 rmsg.buf = tempbuf;
1107 rmsg.size = sizeof(tempbuf);
1108
1109 if(!hwcrhk_context)
1110 {
1111 HWCRHKerr(HWCRHK_F_HWCRHK_RAND_BYTES,HWCRHK_R_NOT_INITIALISED);
1112 goto err;
1113 }
1114
1115 ret = p_hwcrhk_RandomBytes(hwcrhk_context, buf, num, &rmsg);
1116 if (ret < 0)
1117 {
1118 /* FIXME: When this error is returned, HWCryptoHook is
1119 telling us that falling back to software computation
1120 might be a good thing. */
1121 if(ret == HWCRYPTOHOOK_ERROR_FALLBACK)
1122 {
1123 HWCRHKerr(HWCRHK_F_HWCRHK_RAND_BYTES,
1124 HWCRHK_R_REQUEST_FALLBACK);
1125 }
1126 else
1127 {
1128 HWCRHKerr(HWCRHK_F_HWCRHK_RAND_BYTES,
1129 HWCRHK_R_REQUEST_FAILED);
1130 }
1131 ERR_add_error_data(1,rmsg.buf);
1132 goto err;
1133 }
1134 to_return = 1;
1135 err:
1136 return to_return;
1137 }
1138
1139static int hwcrhk_rand_status(void)
1140 {
1141 return 1;
1142 }
1143
1144/* This cleans up an RSA KM key, called when ex_data is freed */
1145
1146static void hwcrhk_ex_free(void *obj, void *item, CRYPTO_EX_DATA *ad,
1147 int ind,long argl, void *argp)
1148{
1149 char tempbuf[1024];
1150 HWCryptoHook_ErrMsgBuf rmsg;
1151#ifndef OPENSSL_NO_RSA
1152 HWCryptoHook_RSAKeyHandle *hptr;
1153#endif
1154#if !defined(OPENSSL_NO_RSA)
1155 int ret;
1156#endif
1157
1158 rmsg.buf = tempbuf;
1159 rmsg.size = sizeof(tempbuf);
1160
1161#ifndef OPENSSL_NO_RSA
1162 hptr = (HWCryptoHook_RSAKeyHandle *) item;
1163 if(hptr)
1164 {
1165 ret = p_hwcrhk_RSAUnloadKey(*hptr, NULL);
1166 OPENSSL_free(hptr);
1167 }
1168#endif
1169}
1170
1171/* Mutex calls: since the HWCryptoHook model closely follows the POSIX model
1172 * these just wrap the POSIX functions and add some logging.
1173 */
1174
1175static int hwcrhk_mutex_init(HWCryptoHook_Mutex* mt,
1176 HWCryptoHook_CallerContext *cactx)
1177 {
1178 mt->lockid = CRYPTO_get_new_dynlockid();
1179 if (mt->lockid == 0)
1180 return 1; /* failure */
1181 return 0; /* success */
1182 }
1183
1184static int hwcrhk_mutex_lock(HWCryptoHook_Mutex *mt)
1185 {
1186 CRYPTO_w_lock(mt->lockid);
1187 return 0;
1188 }
1189
1190static void hwcrhk_mutex_unlock(HWCryptoHook_Mutex * mt)
1191 {
1192 CRYPTO_w_unlock(mt->lockid);
1193 }
1194
1195static void hwcrhk_mutex_destroy(HWCryptoHook_Mutex *mt)
1196 {
1197 CRYPTO_destroy_dynlockid(mt->lockid);
1198 }
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
1220static int hwcrhk_get_pass(const char *prompt_info,
1221 int *len_io, char *buf,
1222 HWCryptoHook_PassphraseContext *ppctx,
1223 HWCryptoHook_CallerContext *cactx)
1224 {
1225 pem_password_cb *callback = NULL;
1226 void *callback_data = NULL;
1227 UI_METHOD *ui_method = NULL;
1228
1229 if (cactx)
1230 {
1231 if (cactx->ui_method)
1232 ui_method = cactx->ui_method;
1233 if (cactx->password_callback)
1234 callback = cactx->password_callback;
1235 if (cactx->callback_data)
1236 callback_data = cactx->callback_data;
1237 }
1238 if (ppctx)
1239 {
1240 if (ppctx->ui_method)
1241 {
1242 ui_method = ppctx->ui_method;
1243 callback = NULL;
1244 }
1245 if (ppctx->callback_data)
1246 callback_data = ppctx->callback_data;
1247 }
1248 if (callback == NULL && ui_method == NULL)
1249 {
1250 HWCRHKerr(HWCRHK_F_HWCRHK_GET_PASS,HWCRHK_R_NO_CALLBACK);
1251 return -1;
1252 }
1253
1254 if (ui_method)
1255 {
1256 UI *ui = UI_new_method(ui_method);
1257 if (ui)
1258 {
1259 int ok;
1260 char *prompt = UI_construct_prompt(ui,
1261 "pass phrase", prompt_info);
1262
1263 ok = UI_add_input_string(ui,prompt,
1264 UI_INPUT_FLAG_DEFAULT_PWD,
1265 buf,0,(*len_io) - 1);
1266 UI_add_user_data(ui, callback_data);
1267 UI_ctrl(ui, UI_CTRL_PRINT_ERRORS, 1, 0, 0);
1268
1269 if (ok >= 0)
1270 do
1271 {
1272 ok=UI_process(ui);
1273 }
1274 while (ok < 0 && UI_ctrl(ui, UI_CTRL_IS_REDOABLE, 0, 0, 0));
1275
1276 if (ok >= 0)
1277 *len_io = strlen(buf);
1278
1279 UI_free(ui);
1280 OPENSSL_free(prompt);
1281 }
1282 }
1283 else
1284 {
1285 *len_io = callback(buf, *len_io, 0, callback_data);
1286 }
1287 if(!*len_io)
1288 return -1;
1289 return 0;
1290 }
1291
1292static int hwcrhk_insert_card(const char *prompt_info,
1293 const char *wrong_info,
1294 HWCryptoHook_PassphraseContext *ppctx,
1295 HWCryptoHook_CallerContext *cactx)
1296 {
1297 int ok = -1;
1298 UI *ui;
1299 void *callback_data = NULL;
1300 UI_METHOD *ui_method = NULL;
1301
1302 if (cactx)
1303 {
1304 if (cactx->ui_method)
1305 ui_method = cactx->ui_method;
1306 if (cactx->callback_data)
1307 callback_data = cactx->callback_data;
1308 }
1309 if (ppctx)
1310 {
1311 if (ppctx->ui_method)
1312 ui_method = ppctx->ui_method;
1313 if (ppctx->callback_data)
1314 callback_data = ppctx->callback_data;
1315 }
1316 if (ui_method == NULL)
1317 {
1318 HWCRHKerr(HWCRHK_F_HWCRHK_INSERT_CARD,
1319 HWCRHK_R_NO_CALLBACK);
1320 return -1;
1321 }
1322
1323 ui = UI_new_method(ui_method);
1324
1325 if (ui)
1326 {
1327 char answer;
1328 char buf[BUFSIZ];
1329
1330 if (wrong_info)
1331 BIO_snprintf(buf, sizeof(buf)-1,
1332 "Current card: \"%s\"\n", wrong_info);
1333 ok = UI_dup_info_string(ui, buf);
1334 if (ok >= 0 && prompt_info)
1335 {
1336 BIO_snprintf(buf, sizeof(buf)-1,
1337 "Insert card \"%s\"", prompt_info);
1338 ok = UI_dup_input_boolean(ui, buf,
1339 "\n then hit <enter> or C<enter> to cancel\n",
1340 "\r\n", "Cc", UI_INPUT_FLAG_ECHO, &answer);
1341 }
1342 UI_add_user_data(ui, callback_data);
1343
1344 if (ok >= 0)
1345 ok = UI_process(ui);
1346 UI_free(ui);
1347
1348 if (ok == -2 || (ok >= 0 && answer == 'C'))
1349 ok = 1;
1350 else if (ok < 0)
1351 ok = -1;
1352 else
1353 ok = 0;
1354 }
1355 return ok;
1356 }
1357
1358static void hwcrhk_log_message(void *logstr, const char *message)
1359 {
1360 BIO *lstream = NULL;
1361
1362 CRYPTO_w_lock(CRYPTO_LOCK_BIO);
1363 if (logstr)
1364 lstream=*(BIO **)logstr;
1365 if (lstream)
1366 {
1367 BIO_printf(lstream, "%s\n", message);
1368 }
1369 CRYPTO_w_unlock(CRYPTO_LOCK_BIO);
1370 }
1371
1372/* This stuff is needed if this ENGINE is being compiled into a self-contained
1373 * shared-library. */
1374#ifdef ENGINE_DYNAMIC_SUPPORT
1375static int bind_fn(ENGINE *e, const char *id)
1376 {
1377 if(id && (strcmp(id, engine_hwcrhk_id) != 0))
1378 return 0;
1379 if(!bind_helper(e))
1380 return 0;
1381 return 1;
1382 }
1383IMPLEMENT_DYNAMIC_CHECK_FN()
1384IMPLEMENT_DYNAMIC_BIND_FN(bind_fn)
1385#endif /* ENGINE_DYNAMIC_SUPPORT */
1386
1387#endif /* !OPENSSL_NO_HW_NCIPHER */
1388#endif /* !OPENSSL_NO_HW */
diff --git a/src/lib/libcrypto/engine/hw_ncipher_err.c b/src/lib/libcrypto/engine/hw_ncipher_err.c
deleted file mode 100644
index 5bc94581b7..0000000000
--- a/src/lib/libcrypto/engine/hw_ncipher_err.c
+++ /dev/null
@@ -1,157 +0,0 @@
1/* hw_ncipher_err.c */
2/* ====================================================================
3 * Copyright (c) 1999-2002 The OpenSSL Project. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 *
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in
14 * the documentation and/or other materials provided with the
15 * distribution.
16 *
17 * 3. All advertising materials mentioning features or use of this
18 * software must display the following acknowledgment:
19 * "This product includes software developed by the OpenSSL Project
20 * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
21 *
22 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
23 * endorse or promote products derived from this software without
24 * prior written permission. For written permission, please contact
25 * openssl-core@OpenSSL.org.
26 *
27 * 5. Products derived from this software may not be called "OpenSSL"
28 * nor may "OpenSSL" appear in their names without prior written
29 * permission of the OpenSSL Project.
30 *
31 * 6. Redistributions of any form whatsoever must retain the following
32 * acknowledgment:
33 * "This product includes software developed by the OpenSSL Project
34 * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
35 *
36 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
37 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
38 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
39 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
40 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
41 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
42 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
43 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
44 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
45 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
46 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
47 * OF THE POSSIBILITY OF SUCH DAMAGE.
48 * ====================================================================
49 *
50 * This product includes cryptographic software written by Eric Young
51 * (eay@cryptsoft.com). This product includes software written by Tim
52 * Hudson (tjh@cryptsoft.com).
53 *
54 */
55
56/* NOTE: this file was auto generated by the mkerr.pl script: any changes
57 * made to it will be overwritten when the script next updates this file,
58 * only reason strings will be preserved.
59 */
60
61#include <stdio.h>
62#include <openssl/err.h>
63#include "hw_ncipher_err.h"
64
65/* BEGIN ERROR CODES */
66#ifndef OPENSSL_NO_ERR
67static ERR_STRING_DATA HWCRHK_str_functs[]=
68 {
69{ERR_PACK(0,HWCRHK_F_HWCRHK_CTRL,0), "HWCRHK_CTRL"},
70{ERR_PACK(0,HWCRHK_F_HWCRHK_FINISH,0), "HWCRHK_FINISH"},
71{ERR_PACK(0,HWCRHK_F_HWCRHK_GET_PASS,0), "HWCRHK_GET_PASS"},
72{ERR_PACK(0,HWCRHK_F_HWCRHK_INIT,0), "HWCRHK_INIT"},
73{ERR_PACK(0,HWCRHK_F_HWCRHK_INSERT_CARD,0), "HWCRHK_INSERT_CARD"},
74{ERR_PACK(0,HWCRHK_F_HWCRHK_LOAD_PRIVKEY,0), "HWCRHK_LOAD_PRIVKEY"},
75{ERR_PACK(0,HWCRHK_F_HWCRHK_LOAD_PUBKEY,0), "HWCRHK_LOAD_PUBKEY"},
76{ERR_PACK(0,HWCRHK_F_HWCRHK_MOD_EXP,0), "HWCRHK_MOD_EXP"},
77{ERR_PACK(0,HWCRHK_F_HWCRHK_RAND_BYTES,0), "HWCRHK_RAND_BYTES"},
78{ERR_PACK(0,HWCRHK_F_HWCRHK_RSA_MOD_EXP,0), "HWCRHK_RSA_MOD_EXP"},
79{0,NULL}
80 };
81
82static ERR_STRING_DATA HWCRHK_str_reasons[]=
83 {
84{HWCRHK_R_ALREADY_LOADED ,"already loaded"},
85{HWCRHK_R_BIO_WAS_FREED ,"bio was freed"},
86{HWCRHK_R_CHIL_ERROR ,"chil error"},
87{HWCRHK_R_CTRL_COMMAND_NOT_IMPLEMENTED ,"ctrl command not implemented"},
88{HWCRHK_R_DSO_FAILURE ,"dso failure"},
89{HWCRHK_R_DYNAMIC_LOCKING_MISSING ,"dynamic locking missing"},
90{HWCRHK_R_MISSING_KEY_COMPONENTS ,"missing key components"},
91{HWCRHK_R_NOT_INITIALISED ,"not initialised"},
92{HWCRHK_R_NOT_LOADED ,"not loaded"},
93{HWCRHK_R_NO_CALLBACK ,"no callback"},
94{HWCRHK_R_NO_KEY ,"no key"},
95{HWCRHK_R_PRIVATE_KEY_ALGORITHMS_DISABLED,"private key algorithms disabled"},
96{HWCRHK_R_REQUEST_FAILED ,"request failed"},
97{HWCRHK_R_REQUEST_FALLBACK ,"request fallback"},
98{HWCRHK_R_UNIT_FAILURE ,"unit failure"},
99{0,NULL}
100 };
101
102#endif
103
104#ifdef HWCRHK_LIB_NAME
105static ERR_STRING_DATA HWCRHK_lib_name[]=
106 {
107{0 ,HWCRHK_LIB_NAME},
108{0,NULL}
109 };
110#endif
111
112
113static int HWCRHK_lib_error_code=0;
114static int HWCRHK_error_init=1;
115
116static void ERR_load_HWCRHK_strings(void)
117 {
118 if (HWCRHK_lib_error_code == 0)
119 HWCRHK_lib_error_code=ERR_get_next_error_library();
120
121 if (HWCRHK_error_init)
122 {
123 HWCRHK_error_init=0;
124#ifndef OPENSSL_NO_ERR
125 ERR_load_strings(HWCRHK_lib_error_code,HWCRHK_str_functs);
126 ERR_load_strings(HWCRHK_lib_error_code,HWCRHK_str_reasons);
127#endif
128
129#ifdef HWCRHK_LIB_NAME
130 HWCRHK_lib_name->error = ERR_PACK(HWCRHK_lib_error_code,0,0);
131 ERR_load_strings(0,HWCRHK_lib_name);
132#endif
133 }
134 }
135
136static void ERR_unload_HWCRHK_strings(void)
137 {
138 if (HWCRHK_error_init == 0)
139 {
140#ifndef OPENSSL_NO_ERR
141 ERR_unload_strings(HWCRHK_lib_error_code,HWCRHK_str_functs);
142 ERR_unload_strings(HWCRHK_lib_error_code,HWCRHK_str_reasons);
143#endif
144
145#ifdef HWCRHK_LIB_NAME
146 ERR_unload_strings(0,HWCRHK_lib_name);
147#endif
148 HWCRHK_error_init=1;
149 }
150 }
151
152static void ERR_HWCRHK_error(int function, int reason, char *file, int line)
153 {
154 if (HWCRHK_lib_error_code == 0)
155 HWCRHK_lib_error_code=ERR_get_next_error_library();
156 ERR_PUT_error(HWCRHK_lib_error_code,function,reason,file,line);
157 }
diff --git a/src/lib/libcrypto/engine/hw_ncipher_err.h b/src/lib/libcrypto/engine/hw_ncipher_err.h
deleted file mode 100644
index d232d02319..0000000000
--- a/src/lib/libcrypto/engine/hw_ncipher_err.h
+++ /dev/null
@@ -1,101 +0,0 @@
1/* ====================================================================
2 * Copyright (c) 2001 The OpenSSL Project. All rights reserved.
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 * openssl-core@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 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
36 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
37 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
38 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
39 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
40 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
41 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
42 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
43 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
44 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
45 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
46 * OF THE POSSIBILITY OF SUCH DAMAGE.
47 * ====================================================================
48 *
49 * This product includes cryptographic software written by Eric Young
50 * (eay@cryptsoft.com). This product includes software written by Tim
51 * Hudson (tjh@cryptsoft.com).
52 *
53 */
54
55#ifndef HEADER_HWCRHK_ERR_H
56#define HEADER_HWCRHK_ERR_H
57
58/* BEGIN ERROR CODES */
59/* The following lines are auto generated by the script mkerr.pl. Any changes
60 * made after this point may be overwritten when the script is next run.
61 */
62static void ERR_load_HWCRHK_strings(void);
63static void ERR_unload_HWCRHK_strings(void);
64static void ERR_HWCRHK_error(int function, int reason, char *file, int line);
65#define HWCRHKerr(f,r) ERR_HWCRHK_error((f),(r),__FILE__,__LINE__)
66
67/* Error codes for the HWCRHK functions. */
68
69/* Function codes. */
70#define HWCRHK_F_HWCRHK_CTRL 100
71#define HWCRHK_F_HWCRHK_FINISH 101
72#define HWCRHK_F_HWCRHK_GET_PASS 102
73#define HWCRHK_F_HWCRHK_INIT 103
74#define HWCRHK_F_HWCRHK_INSERT_CARD 104
75#define HWCRHK_F_HWCRHK_LOAD_PRIVKEY 105
76#define HWCRHK_F_HWCRHK_LOAD_PUBKEY 106
77#define HWCRHK_F_HWCRHK_MOD_EXP 107
78#define HWCRHK_F_HWCRHK_RAND_BYTES 108
79#define HWCRHK_F_HWCRHK_RSA_MOD_EXP 109
80
81/* Reason codes. */
82#define HWCRHK_R_ALREADY_LOADED 100
83#define HWCRHK_R_BIO_WAS_FREED 101
84#define HWCRHK_R_CHIL_ERROR 102
85#define HWCRHK_R_CTRL_COMMAND_NOT_IMPLEMENTED 103
86#define HWCRHK_R_DSO_FAILURE 104
87#define HWCRHK_R_DYNAMIC_LOCKING_MISSING 114
88#define HWCRHK_R_MISSING_KEY_COMPONENTS 105
89#define HWCRHK_R_NOT_INITIALISED 106
90#define HWCRHK_R_NOT_LOADED 107
91#define HWCRHK_R_NO_CALLBACK 108
92#define HWCRHK_R_NO_KEY 109
93#define HWCRHK_R_PRIVATE_KEY_ALGORITHMS_DISABLED 110
94#define HWCRHK_R_REQUEST_FAILED 111
95#define HWCRHK_R_REQUEST_FALLBACK 112
96#define HWCRHK_R_UNIT_FAILURE 113
97
98#ifdef __cplusplus
99}
100#endif
101#endif
diff --git a/src/lib/libcrypto/engine/hw_nuron.c b/src/lib/libcrypto/engine/hw_nuron.c
deleted file mode 100644
index fb9188bfe5..0000000000
--- a/src/lib/libcrypto/engine/hw_nuron.c
+++ /dev/null
@@ -1,418 +0,0 @@
1/* crypto/engine/hw_nuron.c */
2/* Written by Ben Laurie for the OpenSSL Project, leaning heavily on Geoff
3 * Thorpe's Atalla implementation.
4 */
5/* ====================================================================
6 * Copyright (c) 2000-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 * licensing@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 <stdio.h>
60#include <openssl/crypto.h>
61#include "cryptlib.h"
62#include <openssl/dso.h>
63#include <openssl/engine.h>
64
65
66#ifndef OPENSSL_NO_HW
67#ifndef OPENSSL_NO_HW_NURON
68
69#define NURON_LIB_NAME "nuron engine"
70#include "hw_nuron_err.c"
71
72static const char *NURON_LIBNAME = NULL;
73static const char *get_NURON_LIBNAME(void)
74 {
75 if(NURON_LIBNAME)
76 return NURON_LIBNAME;
77 return "nuronssl";
78 }
79static void free_NURON_LIBNAME(void)
80 {
81 if(NURON_LIBNAME)
82 OPENSSL_free((void*)NURON_LIBNAME);
83 NURON_LIBNAME = NULL;
84 }
85static long set_NURON_LIBNAME(const char *name)
86 {
87 free_NURON_LIBNAME();
88 return (((NURON_LIBNAME = BUF_strdup(name)) != NULL) ? 1 : 0);
89 }
90static const char *NURON_F1 = "nuron_mod_exp";
91
92/* The definitions for control commands specific to this engine */
93#define NURON_CMD_SO_PATH ENGINE_CMD_BASE
94static const ENGINE_CMD_DEFN nuron_cmd_defns[] = {
95 {NURON_CMD_SO_PATH,
96 "SO_PATH",
97 "Specifies the path to the 'nuronssl' shared library",
98 ENGINE_CMD_FLAG_STRING},
99 {0, NULL, NULL, 0}
100 };
101
102typedef int tfnModExp(BIGNUM *r,const BIGNUM *a,const BIGNUM *p,const BIGNUM *m);
103static tfnModExp *pfnModExp = NULL;
104
105static DSO *pvDSOHandle = NULL;
106
107static int nuron_destroy(ENGINE *e)
108 {
109 free_NURON_LIBNAME();
110 ERR_unload_NURON_strings();
111 return 1;
112 }
113
114static int nuron_init(ENGINE *e)
115 {
116 if(pvDSOHandle != NULL)
117 {
118 NURONerr(NURON_F_NURON_INIT,NURON_R_ALREADY_LOADED);
119 return 0;
120 }
121
122 pvDSOHandle = DSO_load(NULL, get_NURON_LIBNAME(), NULL,
123 DSO_FLAG_NAME_TRANSLATION_EXT_ONLY);
124 if(!pvDSOHandle)
125 {
126 NURONerr(NURON_F_NURON_INIT,NURON_R_DSO_NOT_FOUND);
127 return 0;
128 }
129
130 pfnModExp = (tfnModExp *)DSO_bind_func(pvDSOHandle, NURON_F1);
131 if(!pfnModExp)
132 {
133 NURONerr(NURON_F_NURON_INIT,NURON_R_DSO_FUNCTION_NOT_FOUND);
134 return 0;
135 }
136
137 return 1;
138 }
139
140static int nuron_finish(ENGINE *e)
141 {
142 free_NURON_LIBNAME();
143 if(pvDSOHandle == NULL)
144 {
145 NURONerr(NURON_F_NURON_FINISH,NURON_R_NOT_LOADED);
146 return 0;
147 }
148 if(!DSO_free(pvDSOHandle))
149 {
150 NURONerr(NURON_F_NURON_FINISH,NURON_R_DSO_FAILURE);
151 return 0;
152 }
153 pvDSOHandle=NULL;
154 pfnModExp=NULL;
155 return 1;
156 }
157
158static int nuron_ctrl(ENGINE *e, int cmd, long i, void *p, void (*f)())
159 {
160 int initialised = ((pvDSOHandle == NULL) ? 0 : 1);
161 switch(cmd)
162 {
163 case NURON_CMD_SO_PATH:
164 if(p == NULL)
165 {
166 NURONerr(NURON_F_NURON_CTRL,ERR_R_PASSED_NULL_PARAMETER);
167 return 0;
168 }
169 if(initialised)
170 {
171 NURONerr(NURON_F_NURON_CTRL,NURON_R_ALREADY_LOADED);
172 return 0;
173 }
174 return set_NURON_LIBNAME((const char *)p);
175 default:
176 break;
177 }
178 NURONerr(NURON_F_NURON_CTRL,NURON_R_CTRL_COMMAND_NOT_IMPLEMENTED);
179 return 0;
180}
181
182static int nuron_mod_exp(BIGNUM *r,const BIGNUM *a,const BIGNUM *p,
183 const BIGNUM *m,BN_CTX *ctx)
184 {
185 if(!pvDSOHandle)
186 {
187 NURONerr(NURON_F_NURON_MOD_EXP,NURON_R_NOT_LOADED);
188 return 0;
189 }
190 return pfnModExp(r,a,p,m);
191 }
192
193#ifndef OPENSSL_NO_RSA
194static int nuron_rsa_mod_exp(BIGNUM *r0, const BIGNUM *I, RSA *rsa)
195 {
196 return nuron_mod_exp(r0,I,rsa->d,rsa->n,NULL);
197 }
198#endif
199
200#ifndef OPENSSL_NO_DSA
201/* This code was liberated and adapted from the commented-out code in
202 * dsa_ossl.c. Because of the unoptimised form of the Atalla acceleration
203 * (it doesn't have a CRT form for RSA), this function means that an
204 * Atalla system running with a DSA server certificate can handshake
205 * around 5 or 6 times faster/more than an equivalent system running with
206 * RSA. Just check out the "signs" statistics from the RSA and DSA parts
207 * of "openssl speed -engine atalla dsa1024 rsa1024". */
208static int nuron_dsa_mod_exp(DSA *dsa, BIGNUM *rr, BIGNUM *a1,
209 BIGNUM *p1, BIGNUM *a2, BIGNUM *p2, BIGNUM *m,
210 BN_CTX *ctx, BN_MONT_CTX *in_mont)
211 {
212 BIGNUM t;
213 int to_return = 0;
214
215 BN_init(&t);
216 /* let rr = a1 ^ p1 mod m */
217 if (!nuron_mod_exp(rr,a1,p1,m,ctx))
218 goto end;
219 /* let t = a2 ^ p2 mod m */
220 if (!nuron_mod_exp(&t,a2,p2,m,ctx))
221 goto end;
222 /* let rr = rr * t mod m */
223 if (!BN_mod_mul(rr,rr,&t,m,ctx))
224 goto end;
225 to_return = 1;
226end:
227 BN_free(&t);
228 return to_return;
229 }
230
231
232static int nuron_mod_exp_dsa(DSA *dsa, BIGNUM *r, BIGNUM *a,
233 const BIGNUM *p, const BIGNUM *m, BN_CTX *ctx,
234 BN_MONT_CTX *m_ctx)
235 {
236 return nuron_mod_exp(r, a, p, m, ctx);
237 }
238#endif
239
240/* This function is aliased to mod_exp (with the mont stuff dropped). */
241static int nuron_mod_exp_mont(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
242 const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx)
243 {
244 return nuron_mod_exp(r, a, p, m, ctx);
245 }
246
247#ifndef OPENSSL_NO_DH
248/* This function is aliased to mod_exp (with the dh and mont dropped). */
249static int nuron_mod_exp_dh(const DH *dh, BIGNUM *r,
250 const BIGNUM *a, const BIGNUM *p,
251 const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx)
252 {
253 return nuron_mod_exp(r, a, p, m, ctx);
254 }
255#endif
256
257#ifndef OPENSSL_NO_RSA
258static RSA_METHOD nuron_rsa =
259 {
260 "Nuron RSA method",
261 NULL,
262 NULL,
263 NULL,
264 NULL,
265 nuron_rsa_mod_exp,
266 nuron_mod_exp_mont,
267 NULL,
268 NULL,
269 0,
270 NULL,
271 NULL,
272 NULL
273 };
274#endif
275
276#ifndef OPENSSL_NO_DSA
277static DSA_METHOD nuron_dsa =
278 {
279 "Nuron DSA method",
280 NULL, /* dsa_do_sign */
281 NULL, /* dsa_sign_setup */
282 NULL, /* dsa_do_verify */
283 nuron_dsa_mod_exp, /* dsa_mod_exp */
284 nuron_mod_exp_dsa, /* bn_mod_exp */
285 NULL, /* init */
286 NULL, /* finish */
287 0, /* flags */
288 NULL /* app_data */
289 };
290#endif
291
292#ifndef OPENSSL_NO_DH
293static DH_METHOD nuron_dh =
294 {
295 "Nuron DH method",
296 NULL,
297 NULL,
298 nuron_mod_exp_dh,
299 NULL,
300 NULL,
301 0,
302 NULL
303 };
304#endif
305
306/* Constants used when creating the ENGINE */
307static const char *engine_nuron_id = "nuron";
308static const char *engine_nuron_name = "Nuron hardware engine support";
309
310/* This internal function is used by ENGINE_nuron() and possibly by the
311 * "dynamic" ENGINE support too */
312static int bind_helper(ENGINE *e)
313 {
314#ifndef OPENSSL_NO_RSA
315 const RSA_METHOD *meth1;
316#endif
317#ifndef OPENSSL_NO_DSA
318 const DSA_METHOD *meth2;
319#endif
320#ifndef OPENSSL_NO_DH
321 const DH_METHOD *meth3;
322#endif
323 if(!ENGINE_set_id(e, engine_nuron_id) ||
324 !ENGINE_set_name(e, engine_nuron_name) ||
325#ifndef OPENSSL_NO_RSA
326 !ENGINE_set_RSA(e, &nuron_rsa) ||
327#endif
328#ifndef OPENSSL_NO_DSA
329 !ENGINE_set_DSA(e, &nuron_dsa) ||
330#endif
331#ifndef OPENSSL_NO_DH
332 !ENGINE_set_DH(e, &nuron_dh) ||
333#endif
334 !ENGINE_set_destroy_function(e, nuron_destroy) ||
335 !ENGINE_set_init_function(e, nuron_init) ||
336 !ENGINE_set_finish_function(e, nuron_finish) ||
337 !ENGINE_set_ctrl_function(e, nuron_ctrl) ||
338 !ENGINE_set_cmd_defns(e, nuron_cmd_defns))
339 return 0;
340
341#ifndef OPENSSL_NO_RSA
342 /* We know that the "PKCS1_SSLeay()" functions hook properly
343 * to the nuron-specific mod_exp and mod_exp_crt so we use
344 * those functions. NB: We don't use ENGINE_openssl() or
345 * anything "more generic" because something like the RSAref
346 * code may not hook properly, and if you own one of these
347 * cards then you have the right to do RSA operations on it
348 * anyway! */
349 meth1=RSA_PKCS1_SSLeay();
350 nuron_rsa.rsa_pub_enc=meth1->rsa_pub_enc;
351 nuron_rsa.rsa_pub_dec=meth1->rsa_pub_dec;
352 nuron_rsa.rsa_priv_enc=meth1->rsa_priv_enc;
353 nuron_rsa.rsa_priv_dec=meth1->rsa_priv_dec;
354#endif
355
356#ifndef OPENSSL_NO_DSA
357 /* Use the DSA_OpenSSL() method and just hook the mod_exp-ish
358 * bits. */
359 meth2=DSA_OpenSSL();
360 nuron_dsa.dsa_do_sign=meth2->dsa_do_sign;
361 nuron_dsa.dsa_sign_setup=meth2->dsa_sign_setup;
362 nuron_dsa.dsa_do_verify=meth2->dsa_do_verify;
363#endif
364
365#ifndef OPENSSL_NO_DH
366 /* Much the same for Diffie-Hellman */
367 meth3=DH_OpenSSL();
368 nuron_dh.generate_key=meth3->generate_key;
369 nuron_dh.compute_key=meth3->compute_key;
370#endif
371
372 /* Ensure the nuron error handling is set up */
373 ERR_load_NURON_strings();
374 return 1;
375 }
376
377#ifndef ENGINE_DYNAMIC_SUPPORT
378static ENGINE *engine_nuron(void)
379 {
380 ENGINE *ret = ENGINE_new();
381 if(!ret)
382 return NULL;
383 if(!bind_helper(ret))
384 {
385 ENGINE_free(ret);
386 return NULL;
387 }
388 return ret;
389 }
390
391void ENGINE_load_nuron(void)
392 {
393 /* Copied from eng_[openssl|dyn].c */
394 ENGINE *toadd = engine_nuron();
395 if(!toadd) return;
396 ENGINE_add(toadd);
397 ENGINE_free(toadd);
398 ERR_clear_error();
399 }
400#endif
401
402/* This stuff is needed if this ENGINE is being compiled into a self-contained
403 * shared-library. */
404#ifdef ENGINE_DYNAMIC_SUPPORT
405static int bind_fn(ENGINE *e, const char *id)
406 {
407 if(id && (strcmp(id, engine_nuron_id) != 0))
408 return 0;
409 if(!bind_helper(e))
410 return 0;
411 return 1;
412 }
413IMPLEMENT_DYNAMIC_CHECK_FN()
414IMPLEMENT_DYNAMIC_BIND_FN(bind_fn)
415#endif /* ENGINE_DYNAMIC_SUPPORT */
416
417#endif /* !OPENSSL_NO_HW_NURON */
418#endif /* !OPENSSL_NO_HW */
diff --git a/src/lib/libcrypto/engine/hw_nuron_err.c b/src/lib/libcrypto/engine/hw_nuron_err.c
deleted file mode 100644
index df9d7bde76..0000000000
--- a/src/lib/libcrypto/engine/hw_nuron_err.c
+++ /dev/null
@@ -1,142 +0,0 @@
1/* hw_nuron_err.c */
2/* ====================================================================
3 * Copyright (c) 1999 The OpenSSL Project. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 *
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in
14 * the documentation and/or other materials provided with the
15 * distribution.
16 *
17 * 3. All advertising materials mentioning features or use of this
18 * software must display the following acknowledgment:
19 * "This product includes software developed by the OpenSSL Project
20 * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
21 *
22 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
23 * endorse or promote products derived from this software without
24 * prior written permission. For written permission, please contact
25 * openssl-core@OpenSSL.org.
26 *
27 * 5. Products derived from this software may not be called "OpenSSL"
28 * nor may "OpenSSL" appear in their names without prior written
29 * permission of the OpenSSL Project.
30 *
31 * 6. Redistributions of any form whatsoever must retain the following
32 * acknowledgment:
33 * "This product includes software developed by the OpenSSL Project
34 * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
35 *
36 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
37 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
38 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
39 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
40 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
41 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
42 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
43 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
44 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
45 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
46 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
47 * OF THE POSSIBILITY OF SUCH DAMAGE.
48 * ====================================================================
49 *
50 * This product includes cryptographic software written by Eric Young
51 * (eay@cryptsoft.com). This product includes software written by Tim
52 * Hudson (tjh@cryptsoft.com).
53 *
54 */
55
56/* NOTE: this file was auto generated by the mkerr.pl script: any changes
57 * made to it will be overwritten when the script next updates this file,
58 * only reason strings will be preserved.
59 */
60
61#include <stdio.h>
62#include <openssl/err.h>
63#include "hw_nuron_err.h"
64
65/* BEGIN ERROR CODES */
66#ifndef OPENSSL_NO_ERR
67static ERR_STRING_DATA NURON_str_functs[]=
68 {
69{ERR_PACK(0,NURON_F_NURON_CTRL,0), "NURON_CTRL"},
70{ERR_PACK(0,NURON_F_NURON_FINISH,0), "NURON_FINISH"},
71{ERR_PACK(0,NURON_F_NURON_INIT,0), "NURON_INIT"},
72{ERR_PACK(0,NURON_F_NURON_MOD_EXP,0), "NURON_MOD_EXP"},
73{0,NULL}
74 };
75
76static ERR_STRING_DATA NURON_str_reasons[]=
77 {
78{NURON_R_ALREADY_LOADED ,"already loaded"},
79{NURON_R_CTRL_COMMAND_NOT_IMPLEMENTED ,"ctrl command not implemented"},
80{NURON_R_DSO_FAILURE ,"dso failure"},
81{NURON_R_DSO_FUNCTION_NOT_FOUND ,"dso function not found"},
82{NURON_R_DSO_NOT_FOUND ,"dso not found"},
83{NURON_R_NOT_LOADED ,"not loaded"},
84{0,NULL}
85 };
86
87#endif
88
89#ifdef NURON_LIB_NAME
90static ERR_STRING_DATA NURON_lib_name[]=
91 {
92{0 ,NURON_LIB_NAME},
93{0,NULL}
94 };
95#endif
96
97
98static int NURON_lib_error_code=0;
99static int NURON_error_init=1;
100
101static void ERR_load_NURON_strings(void)
102 {
103 if (NURON_lib_error_code == 0)
104 NURON_lib_error_code=ERR_get_next_error_library();
105
106 if (NURON_error_init)
107 {
108 NURON_error_init=0;
109#ifndef OPENSSL_NO_ERR
110 ERR_load_strings(NURON_lib_error_code,NURON_str_functs);
111 ERR_load_strings(NURON_lib_error_code,NURON_str_reasons);
112#endif
113
114#ifdef NURON_LIB_NAME
115 NURON_lib_name->error = ERR_PACK(NURON_lib_error_code,0,0);
116 ERR_load_strings(0,NURON_lib_name);
117#endif
118 }
119 }
120
121static void ERR_unload_NURON_strings(void)
122 {
123 if (NURON_error_init == 0)
124 {
125#ifndef OPENSSL_NO_ERR
126 ERR_unload_strings(NURON_lib_error_code,NURON_str_functs);
127 ERR_unload_strings(NURON_lib_error_code,NURON_str_reasons);
128#endif
129
130#ifdef NURON_LIB_NAME
131 ERR_unload_strings(0,NURON_lib_name);
132#endif
133 NURON_error_init=1;
134 }
135 }
136
137static void ERR_NURON_error(int function, int reason, char *file, int line)
138 {
139 if (NURON_lib_error_code == 0)
140 NURON_lib_error_code=ERR_get_next_error_library();
141 ERR_PUT_error(NURON_lib_error_code,function,reason,file,line);
142 }
diff --git a/src/lib/libcrypto/engine/hw_nuron_err.h b/src/lib/libcrypto/engine/hw_nuron_err.h
deleted file mode 100644
index a56bfdf303..0000000000
--- a/src/lib/libcrypto/engine/hw_nuron_err.h
+++ /dev/null
@@ -1,86 +0,0 @@
1/* ====================================================================
2 * Copyright (c) 2001 The OpenSSL Project. All rights reserved.
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 * openssl-core@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 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
36 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
37 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
38 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
39 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
40 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
41 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
42 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
43 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
44 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
45 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
46 * OF THE POSSIBILITY OF SUCH DAMAGE.
47 * ====================================================================
48 *
49 * This product includes cryptographic software written by Eric Young
50 * (eay@cryptsoft.com). This product includes software written by Tim
51 * Hudson (tjh@cryptsoft.com).
52 *
53 */
54
55#ifndef HEADER_NURON_ERR_H
56#define HEADER_NURON_ERR_H
57
58/* BEGIN ERROR CODES */
59/* The following lines are auto generated by the script mkerr.pl. Any changes
60 * made after this point may be overwritten when the script is next run.
61 */
62static void ERR_load_NURON_strings(void);
63static void ERR_unload_NURON_strings(void);
64static void ERR_NURON_error(int function, int reason, char *file, int line);
65#define NURONerr(f,r) ERR_NURON_error((f),(r),__FILE__,__LINE__)
66
67/* Error codes for the NURON functions. */
68
69/* Function codes. */
70#define NURON_F_NURON_CTRL 100
71#define NURON_F_NURON_FINISH 101
72#define NURON_F_NURON_INIT 102
73#define NURON_F_NURON_MOD_EXP 103
74
75/* Reason codes. */
76#define NURON_R_ALREADY_LOADED 100
77#define NURON_R_CTRL_COMMAND_NOT_IMPLEMENTED 101
78#define NURON_R_DSO_FAILURE 102
79#define NURON_R_DSO_FUNCTION_NOT_FOUND 103
80#define NURON_R_DSO_NOT_FOUND 104
81#define NURON_R_NOT_LOADED 105
82
83#ifdef __cplusplus
84}
85#endif
86#endif
diff --git a/src/lib/libcrypto/engine/hw_sureware.c b/src/lib/libcrypto/engine/hw_sureware.c
deleted file mode 100644
index fca467e690..0000000000
--- a/src/lib/libcrypto/engine/hw_sureware.c
+++ /dev/null
@@ -1,1039 +0,0 @@
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/libcrypto/engine/hw_sureware_err.c b/src/lib/libcrypto/engine/hw_sureware_err.c
deleted file mode 100644
index 69955dadbb..0000000000
--- a/src/lib/libcrypto/engine/hw_sureware_err.c
+++ /dev/null
@@ -1,150 +0,0 @@
1/* hw_sureware_err.c */
2/* ====================================================================
3 * Copyright (c) 1999 The OpenSSL Project. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 *
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in
14 * the documentation and/or other materials provided with the
15 * distribution.
16 *
17 * 3. All advertising materials mentioning features or use of this
18 * software must display the following acknowledgment:
19 * "This product includes software developed by the OpenSSL Project
20 * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
21 *
22 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
23 * endorse or promote products derived from this software without
24 * prior written permission. For written permission, please contact
25 * openssl-core@OpenSSL.org.
26 *
27 * 5. Products derived from this software may not be called "OpenSSL"
28 * nor may "OpenSSL" appear in their names without prior written
29 * permission of the OpenSSL Project.
30 *
31 * 6. Redistributions of any form whatsoever must retain the following
32 * acknowledgment:
33 * "This product includes software developed by the OpenSSL Project
34 * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
35 *
36 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
37 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
38 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
39 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
40 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
41 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
42 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
43 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
44 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
45 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
46 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
47 * OF THE POSSIBILITY OF SUCH DAMAGE.
48 * ====================================================================
49 *
50 * This product includes cryptographic software written by Eric Young
51 * (eay@cryptsoft.com). This product includes software written by Tim
52 * Hudson (tjh@cryptsoft.com).
53 *
54 */
55
56/* NOTE: this file was auto generated by the mkerr.pl script: any changes
57 * made to it will be overwritten when the script next updates this file,
58 * only reason strings will be preserved.
59 */
60
61#include <stdio.h>
62#include <openssl/err.h>
63#include "hw_sureware_err.h"
64
65/* BEGIN ERROR CODES */
66#ifndef OPENSSL_NO_ERR
67static ERR_STRING_DATA SUREWARE_str_functs[]=
68 {
69{ERR_PACK(0,SUREWARE_F_SUREWAREHK_CTRL,0), "SUREWAREHK_CTRL"},
70{ERR_PACK(0,SUREWARE_F_SUREWAREHK_DSA_DO_SIGN,0), "SUREWAREHK_DSA_DO_SIGN"},
71{ERR_PACK(0,SUREWARE_F_SUREWAREHK_EX_FREE,0), "SUREWAREHK_EX_FREE"},
72{ERR_PACK(0,SUREWARE_F_SUREWAREHK_FINISH,0), "SUREWAREHK_FINISH"},
73{ERR_PACK(0,SUREWARE_F_SUREWAREHK_INIT,0), "SUREWAREHK_INIT"},
74{ERR_PACK(0,SUREWARE_F_SUREWAREHK_LOAD_PRIVATE_KEY,0), "SUREWAREHK_LOAD_PRIVATE_KEY"},
75{ERR_PACK(0,SUREWARE_F_SUREWAREHK_LOAD_PUBLIC_KEY,0), "SUREWAREHK_LOAD_PUBLIC_KEY"},
76{ERR_PACK(0,SUREWARE_F_SUREWAREHK_MOD_EXP,0), "SUREWAREHK_MOD_EXP"},
77{ERR_PACK(0,SUREWARE_F_SUREWAREHK_RAND_BYTES,0), "SUREWAREHK_RAND_BYTES"},
78{ERR_PACK(0,SUREWARE_F_SUREWAREHK_RAND_SEED,0), "SUREWAREHK_RAND_SEED"},
79{ERR_PACK(0,SUREWARE_F_SUREWAREHK_RSA_PRIV_DEC,0), "SUREWAREHK_RSA_PRIV_DEC"},
80{ERR_PACK(0,SUREWARE_F_SUREWAREHK_RSA_PRIV_ENC,0), "SUREWAREHK_RSA_PRIV_ENC"},
81{0,NULL}
82 };
83
84static ERR_STRING_DATA SUREWARE_str_reasons[]=
85 {
86{SUREWARE_R_BIO_WAS_FREED ,"bio was freed"},
87{SUREWARE_R_MISSING_KEY_COMPONENTS ,"missing key components"},
88{SUREWARE_R_REQUEST_FAILED ,"request failed"},
89{SUREWARE_R_REQUEST_FALLBACK ,"request fallback"},
90{SUREWARE_R_SIZE_TOO_LARGE_OR_TOO_SMALL ,"size too large or too small"},
91{SUREWARE_R_UNIT_FAILURE ,"unit failure"},
92{0,NULL}
93 };
94
95#endif
96
97#ifdef SUREWARE_LIB_NAME
98static ERR_STRING_DATA SUREWARE_lib_name[]=
99 {
100{0 ,SUREWARE_LIB_NAME},
101{0,NULL}
102 };
103#endif
104
105
106static int SUREWARE_lib_error_code=0;
107static int SUREWARE_error_init=1;
108
109static void ERR_load_SUREWARE_strings(void)
110 {
111 if (SUREWARE_lib_error_code == 0)
112 SUREWARE_lib_error_code=ERR_get_next_error_library();
113
114 if (SUREWARE_error_init)
115 {
116 SUREWARE_error_init=0;
117#ifndef OPENSSL_NO_ERR
118 ERR_load_strings(SUREWARE_lib_error_code,SUREWARE_str_functs);
119 ERR_load_strings(SUREWARE_lib_error_code,SUREWARE_str_reasons);
120#endif
121
122#ifdef SUREWARE_LIB_NAME
123 SUREWARE_lib_name->error = ERR_PACK(SUREWARE_lib_error_code,0,0);
124 ERR_load_strings(0,SUREWARE_lib_name);
125#endif
126 }
127 }
128
129static void ERR_unload_SUREWARE_strings(void)
130 {
131 if (SUREWARE_error_init == 0)
132 {
133#ifndef OPENSSL_NO_ERR
134 ERR_unload_strings(SUREWARE_lib_error_code,SUREWARE_str_functs);
135 ERR_unload_strings(SUREWARE_lib_error_code,SUREWARE_str_reasons);
136#endif
137
138#ifdef SUREWARE_LIB_NAME
139 ERR_unload_strings(0,SUREWARE_lib_name);
140#endif
141 SUREWARE_error_init=1;
142 }
143 }
144
145static void ERR_SUREWARE_error(int function, int reason, char *file, int line)
146 {
147 if (SUREWARE_lib_error_code == 0)
148 SUREWARE_lib_error_code=ERR_get_next_error_library();
149 ERR_PUT_error(SUREWARE_lib_error_code,function,reason,file,line);
150 }
diff --git a/src/lib/libcrypto/engine/hw_sureware_err.h b/src/lib/libcrypto/engine/hw_sureware_err.h
deleted file mode 100644
index bc52af5e05..0000000000
--- a/src/lib/libcrypto/engine/hw_sureware_err.h
+++ /dev/null
@@ -1,94 +0,0 @@
1/* ====================================================================
2 * Copyright (c) 2001 The OpenSSL Project. All rights reserved.
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 * openssl-core@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 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
36 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
37 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
38 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
39 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
40 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
41 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
42 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
43 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
44 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
45 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
46 * OF THE POSSIBILITY OF SUCH DAMAGE.
47 * ====================================================================
48 *
49 * This product includes cryptographic software written by Eric Young
50 * (eay@cryptsoft.com). This product includes software written by Tim
51 * Hudson (tjh@cryptsoft.com).
52 *
53 */
54
55#ifndef HEADER_SUREWARE_ERR_H
56#define HEADER_SUREWARE_ERR_H
57
58/* BEGIN ERROR CODES */
59/* The following lines are auto generated by the script mkerr.pl. Any changes
60 * made after this point may be overwritten when the script is next run.
61 */
62static void ERR_load_SUREWARE_strings(void);
63static void ERR_unload_SUREWARE_strings(void);
64static void ERR_SUREWARE_error(int function, int reason, char *file, int line);
65#define SUREWAREerr(f,r) ERR_SUREWARE_error((f),(r),__FILE__,__LINE__)
66
67/* Error codes for the SUREWARE functions. */
68
69/* Function codes. */
70#define SUREWARE_F_SUREWAREHK_CTRL 100
71#define SUREWARE_F_SUREWAREHK_DSA_DO_SIGN 101
72#define SUREWARE_F_SUREWAREHK_EX_FREE 102
73#define SUREWARE_F_SUREWAREHK_FINISH 103
74#define SUREWARE_F_SUREWAREHK_INIT 104
75#define SUREWARE_F_SUREWAREHK_LOAD_PRIVATE_KEY 105
76#define SUREWARE_F_SUREWAREHK_LOAD_PUBLIC_KEY 106
77#define SUREWARE_F_SUREWAREHK_MOD_EXP 107
78#define SUREWARE_F_SUREWAREHK_RAND_BYTES 108
79#define SUREWARE_F_SUREWAREHK_RAND_SEED 109
80#define SUREWARE_F_SUREWAREHK_RSA_PRIV_DEC 110
81#define SUREWARE_F_SUREWAREHK_RSA_PRIV_ENC 111
82
83/* Reason codes. */
84#define SUREWARE_R_BIO_WAS_FREED 100
85#define SUREWARE_R_MISSING_KEY_COMPONENTS 105
86#define SUREWARE_R_REQUEST_FAILED 101
87#define SUREWARE_R_REQUEST_FALLBACK 102
88#define SUREWARE_R_SIZE_TOO_LARGE_OR_TOO_SMALL 103
89#define SUREWARE_R_UNIT_FAILURE 104
90
91#ifdef __cplusplus
92}
93#endif
94#endif
diff --git a/src/lib/libcrypto/engine/hw_ubsec.c b/src/lib/libcrypto/engine/hw_ubsec.c
deleted file mode 100644
index 8fb834af31..0000000000
--- a/src/lib/libcrypto/engine/hw_ubsec.c
+++ /dev/null
@@ -1,1061 +0,0 @@
1/* crypto/engine/hw_ubsec.c */
2/* Written by Geoff Thorpe (geoff@geoffthorpe.net) for the OpenSSL
3 * project 2000.
4 *
5 * Cloned shamelessly by Joe Tardo.
6 */
7/* ====================================================================
8 * Copyright (c) 1999-2001 The OpenSSL Project. All rights reserved.
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
13 *
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions and the following disclaimer.
16 *
17 * 2. Redistributions in binary form must reproduce the above copyright
18 * notice, this list of conditions and the following disclaimer in
19 * the documentation and/or other materials provided with the
20 * distribution.
21 *
22 * 3. All advertising materials mentioning features or use of this
23 * software must display the following acknowledgment:
24 * "This product includes software developed by the OpenSSL Project
25 * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
26 *
27 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
28 * endorse or promote products derived from this software without
29 * prior written permission. For written permission, please contact
30 * licensing@OpenSSL.org.
31 *
32 * 5. Products derived from this software may not be called "OpenSSL"
33 * nor may "OpenSSL" appear in their names without prior written
34 * permission of the OpenSSL Project.
35 *
36 * 6. Redistributions of any form whatsoever must retain the following
37 * acknowledgment:
38 * "This product includes software developed by the OpenSSL Project
39 * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
42 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
44 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
45 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
46 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
47 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
48 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
49 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
50 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
51 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
52 * OF THE POSSIBILITY OF SUCH DAMAGE.
53 * ====================================================================
54 *
55 * This product includes cryptographic software written by Eric Young
56 * (eay@cryptsoft.com). This product includes software written by Tim
57 * Hudson (tjh@cryptsoft.com).
58 *
59 */
60
61#include <stdio.h>
62#include <openssl/crypto.h>
63#include "cryptlib.h"
64#include <openssl/dso.h>
65#include <openssl/engine.h>
66
67#ifndef OPENSSL_NO_HW
68#ifndef OPENSSL_NO_HW_UBSEC
69
70#ifdef FLAT_INC
71#include "hw_ubsec.h"
72#else
73#include "vendor_defns/hw_ubsec.h"
74#endif
75
76#define UBSEC_LIB_NAME "ubsec engine"
77#include "hw_ubsec_err.c"
78
79#define FAIL_TO_SOFTWARE -15
80
81static int ubsec_destroy(ENGINE *e);
82static int ubsec_init(ENGINE *e);
83static int ubsec_finish(ENGINE *e);
84static int ubsec_ctrl(ENGINE *e, int cmd, long i, void *p, void (*f)());
85static int ubsec_mod_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
86 const BIGNUM *m, BN_CTX *ctx);
87static int ubsec_mod_exp_crt(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
88 const BIGNUM *q, const BIGNUM *dp,
89 const BIGNUM *dq, const BIGNUM *qinv, BN_CTX *ctx);
90#ifndef OPENSSL_NO_RSA
91static int ubsec_rsa_mod_exp(BIGNUM *r0, const BIGNUM *I, RSA *rsa);
92#endif
93static int ubsec_mod_exp_mont(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
94 const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx);
95#ifndef OPENSSL_NO_DSA
96#ifdef NOT_USED
97static int ubsec_dsa_mod_exp(DSA *dsa, BIGNUM *rr, BIGNUM *a1,
98 BIGNUM *p1, BIGNUM *a2, BIGNUM *p2, BIGNUM *m,
99 BN_CTX *ctx, BN_MONT_CTX *in_mont);
100static int ubsec_mod_exp_dsa(DSA *dsa, BIGNUM *r, BIGNUM *a,
101 const BIGNUM *p, const BIGNUM *m, BN_CTX *ctx,
102 BN_MONT_CTX *m_ctx);
103#endif
104static DSA_SIG *ubsec_dsa_do_sign(const unsigned char *dgst, int dlen, DSA *dsa);
105static int ubsec_dsa_verify(const unsigned char *dgst, int dgst_len,
106 DSA_SIG *sig, DSA *dsa);
107#endif
108#ifndef OPENSSL_NO_DH
109static int ubsec_mod_exp_dh(const DH *dh, BIGNUM *r, const BIGNUM *a,
110 const BIGNUM *p, const BIGNUM *m, BN_CTX *ctx,
111 BN_MONT_CTX *m_ctx);
112static int ubsec_dh_compute_key(unsigned char *key,const BIGNUM *pub_key,DH *dh);
113static int ubsec_dh_generate_key(DH *dh);
114#endif
115
116#ifdef NOT_USED
117static int ubsec_rand_bytes(unsigned char *buf, int num);
118static int ubsec_rand_status(void);
119#endif
120
121#define UBSEC_CMD_SO_PATH ENGINE_CMD_BASE
122static const ENGINE_CMD_DEFN ubsec_cmd_defns[] = {
123 {UBSEC_CMD_SO_PATH,
124 "SO_PATH",
125 "Specifies the path to the 'ubsec' shared library",
126 ENGINE_CMD_FLAG_STRING},
127 {0, NULL, NULL, 0}
128 };
129
130#ifndef OPENSSL_NO_RSA
131/* Our internal RSA_METHOD that we provide pointers to */
132static RSA_METHOD ubsec_rsa =
133 {
134 "UBSEC RSA method",
135 NULL,
136 NULL,
137 NULL,
138 NULL,
139 ubsec_rsa_mod_exp,
140 ubsec_mod_exp_mont,
141 NULL,
142 NULL,
143 0,
144 NULL,
145 NULL,
146 NULL
147 };
148#endif
149
150#ifndef OPENSSL_NO_DSA
151/* Our internal DSA_METHOD that we provide pointers to */
152static DSA_METHOD ubsec_dsa =
153 {
154 "UBSEC DSA method",
155 ubsec_dsa_do_sign, /* dsa_do_sign */
156 NULL, /* dsa_sign_setup */
157 ubsec_dsa_verify, /* dsa_do_verify */
158 NULL, /* ubsec_dsa_mod_exp */ /* dsa_mod_exp */
159 NULL, /* ubsec_mod_exp_dsa */ /* bn_mod_exp */
160 NULL, /* init */
161 NULL, /* finish */
162 0, /* flags */
163 NULL /* app_data */
164 };
165#endif
166
167#ifndef OPENSSL_NO_DH
168/* Our internal DH_METHOD that we provide pointers to */
169static DH_METHOD ubsec_dh =
170 {
171 "UBSEC DH method",
172 ubsec_dh_generate_key,
173 ubsec_dh_compute_key,
174 ubsec_mod_exp_dh,
175 NULL,
176 NULL,
177 0,
178 NULL
179 };
180#endif
181
182/* Constants used when creating the ENGINE */
183static const char *engine_ubsec_id = "ubsec";
184static const char *engine_ubsec_name = "UBSEC hardware engine support";
185
186/* This internal function is used by ENGINE_ubsec() and possibly by the
187 * "dynamic" ENGINE support too */
188static int bind_helper(ENGINE *e)
189 {
190#ifndef OPENSSL_NO_RSA
191 const RSA_METHOD *meth1;
192#endif
193#ifndef OPENSSL_NO_DH
194#ifndef HAVE_UBSEC_DH
195 const DH_METHOD *meth3;
196#endif /* HAVE_UBSEC_DH */
197#endif
198 if(!ENGINE_set_id(e, engine_ubsec_id) ||
199 !ENGINE_set_name(e, engine_ubsec_name) ||
200#ifndef OPENSSL_NO_RSA
201 !ENGINE_set_RSA(e, &ubsec_rsa) ||
202#endif
203#ifndef OPENSSL_NO_DSA
204 !ENGINE_set_DSA(e, &ubsec_dsa) ||
205#endif
206#ifndef OPENSSL_NO_DH
207 !ENGINE_set_DH(e, &ubsec_dh) ||
208#endif
209 !ENGINE_set_destroy_function(e, ubsec_destroy) ||
210 !ENGINE_set_init_function(e, ubsec_init) ||
211 !ENGINE_set_finish_function(e, ubsec_finish) ||
212 !ENGINE_set_ctrl_function(e, ubsec_ctrl) ||
213 !ENGINE_set_cmd_defns(e, ubsec_cmd_defns))
214 return 0;
215
216#ifndef OPENSSL_NO_RSA
217 /* We know that the "PKCS1_SSLeay()" functions hook properly
218 * to the Broadcom-specific mod_exp and mod_exp_crt so we use
219 * those functions. NB: We don't use ENGINE_openssl() or
220 * anything "more generic" because something like the RSAref
221 * code may not hook properly, and if you own one of these
222 * cards then you have the right to do RSA operations on it
223 * anyway! */
224 meth1 = RSA_PKCS1_SSLeay();
225 ubsec_rsa.rsa_pub_enc = meth1->rsa_pub_enc;
226 ubsec_rsa.rsa_pub_dec = meth1->rsa_pub_dec;
227 ubsec_rsa.rsa_priv_enc = meth1->rsa_priv_enc;
228 ubsec_rsa.rsa_priv_dec = meth1->rsa_priv_dec;
229#endif
230
231#ifndef OPENSSL_NO_DH
232#ifndef HAVE_UBSEC_DH
233 /* Much the same for Diffie-Hellman */
234 meth3 = DH_OpenSSL();
235 ubsec_dh.generate_key = meth3->generate_key;
236 ubsec_dh.compute_key = meth3->compute_key;
237#endif /* HAVE_UBSEC_DH */
238#endif
239
240 /* Ensure the ubsec error handling is set up */
241 ERR_load_UBSEC_strings();
242 return 1;
243 }
244
245#ifndef ENGINE_DYNAMIC_SUPPORT
246static ENGINE *engine_ubsec(void)
247 {
248 ENGINE *ret = ENGINE_new();
249 if(!ret)
250 return NULL;
251 if(!bind_helper(ret))
252 {
253 ENGINE_free(ret);
254 return NULL;
255 }
256 return ret;
257 }
258
259void ENGINE_load_ubsec(void)
260 {
261 /* Copied from eng_[openssl|dyn].c */
262 ENGINE *toadd = engine_ubsec();
263 if(!toadd) return;
264 ENGINE_add(toadd);
265 ENGINE_free(toadd);
266 ERR_clear_error();
267 }
268#endif
269
270/* This is a process-global DSO handle used for loading and unloading
271 * the UBSEC library. NB: This is only set (or unset) during an
272 * init() or finish() call (reference counts permitting) and they're
273 * operating with global locks, so this should be thread-safe
274 * implicitly. */
275
276static DSO *ubsec_dso = NULL;
277
278/* These are the function pointers that are (un)set when the library has
279 * successfully (un)loaded. */
280
281static t_UBSEC_ubsec_bytes_to_bits *p_UBSEC_ubsec_bytes_to_bits = NULL;
282static t_UBSEC_ubsec_bits_to_bytes *p_UBSEC_ubsec_bits_to_bytes = NULL;
283static t_UBSEC_ubsec_open *p_UBSEC_ubsec_open = NULL;
284static t_UBSEC_ubsec_close *p_UBSEC_ubsec_close = NULL;
285#ifndef OPENSSL_NO_DH
286static t_UBSEC_diffie_hellman_generate_ioctl
287 *p_UBSEC_diffie_hellman_generate_ioctl = NULL;
288static t_UBSEC_diffie_hellman_agree_ioctl *p_UBSEC_diffie_hellman_agree_ioctl = NULL;
289#endif
290/* #ifndef OPENSSL_NO_RSA */
291static t_UBSEC_rsa_mod_exp_ioctl *p_UBSEC_rsa_mod_exp_ioctl = NULL;
292static t_UBSEC_rsa_mod_exp_crt_ioctl *p_UBSEC_rsa_mod_exp_crt_ioctl = NULL;
293/* #endif */
294#ifndef OPENSSL_NO_DSA
295static t_UBSEC_dsa_sign_ioctl *p_UBSEC_dsa_sign_ioctl = NULL;
296static t_UBSEC_dsa_verify_ioctl *p_UBSEC_dsa_verify_ioctl = NULL;
297#endif
298static t_UBSEC_math_accelerate_ioctl *p_UBSEC_math_accelerate_ioctl = NULL;
299static t_UBSEC_rng_ioctl *p_UBSEC_rng_ioctl = NULL;
300static t_UBSEC_max_key_len_ioctl *p_UBSEC_max_key_len_ioctl = NULL;
301
302static int max_key_len = 1024; /* ??? */
303
304/*
305 * These are the static string constants for the DSO file name and the function
306 * symbol names to bind to.
307 */
308
309static const char *UBSEC_LIBNAME = NULL;
310static const char *get_UBSEC_LIBNAME(void)
311 {
312 if(UBSEC_LIBNAME)
313 return UBSEC_LIBNAME;
314 return "ubsec";
315 }
316static void free_UBSEC_LIBNAME(void)
317 {
318 if(UBSEC_LIBNAME)
319 OPENSSL_free((void*)UBSEC_LIBNAME);
320 UBSEC_LIBNAME = NULL;
321 }
322static long set_UBSEC_LIBNAME(const char *name)
323 {
324 free_UBSEC_LIBNAME();
325 return (((UBSEC_LIBNAME = BUF_strdup(name)) != NULL) ? 1 : 0);
326 }
327static const char *UBSEC_F1 = "ubsec_bytes_to_bits";
328static const char *UBSEC_F2 = "ubsec_bits_to_bytes";
329static const char *UBSEC_F3 = "ubsec_open";
330static const char *UBSEC_F4 = "ubsec_close";
331#ifndef OPENSSL_NO_DH
332static const char *UBSEC_F5 = "diffie_hellman_generate_ioctl";
333static const char *UBSEC_F6 = "diffie_hellman_agree_ioctl";
334#endif
335/* #ifndef OPENSSL_NO_RSA */
336static const char *UBSEC_F7 = "rsa_mod_exp_ioctl";
337static const char *UBSEC_F8 = "rsa_mod_exp_crt_ioctl";
338/* #endif */
339#ifndef OPENSSL_NO_DSA
340static const char *UBSEC_F9 = "dsa_sign_ioctl";
341static const char *UBSEC_F10 = "dsa_verify_ioctl";
342#endif
343static const char *UBSEC_F11 = "math_accelerate_ioctl";
344static const char *UBSEC_F12 = "rng_ioctl";
345static const char *UBSEC_F13 = "ubsec_max_key_len_ioctl";
346
347/* Destructor (complements the "ENGINE_ubsec()" constructor) */
348static int ubsec_destroy(ENGINE *e)
349 {
350 free_UBSEC_LIBNAME();
351 ERR_unload_UBSEC_strings();
352 return 1;
353 }
354
355/* (de)initialisation functions. */
356static int ubsec_init(ENGINE *e)
357 {
358 t_UBSEC_ubsec_bytes_to_bits *p1;
359 t_UBSEC_ubsec_bits_to_bytes *p2;
360 t_UBSEC_ubsec_open *p3;
361 t_UBSEC_ubsec_close *p4;
362#ifndef OPENSSL_NO_DH
363 t_UBSEC_diffie_hellman_generate_ioctl *p5;
364 t_UBSEC_diffie_hellman_agree_ioctl *p6;
365#endif
366/* #ifndef OPENSSL_NO_RSA */
367 t_UBSEC_rsa_mod_exp_ioctl *p7;
368 t_UBSEC_rsa_mod_exp_crt_ioctl *p8;
369/* #endif */
370#ifndef OPENSSL_NO_DSA
371 t_UBSEC_dsa_sign_ioctl *p9;
372 t_UBSEC_dsa_verify_ioctl *p10;
373#endif
374 t_UBSEC_math_accelerate_ioctl *p11;
375 t_UBSEC_rng_ioctl *p12;
376 t_UBSEC_max_key_len_ioctl *p13;
377 int fd = 0;
378
379 if(ubsec_dso != NULL)
380 {
381 UBSECerr(UBSEC_F_UBSEC_INIT, UBSEC_R_ALREADY_LOADED);
382 goto err;
383 }
384 /*
385 * Attempt to load libubsec.so/ubsec.dll/whatever.
386 */
387 ubsec_dso = DSO_load(NULL, get_UBSEC_LIBNAME(), NULL, 0);
388 if(ubsec_dso == NULL)
389 {
390 UBSECerr(UBSEC_F_UBSEC_INIT, UBSEC_R_DSO_FAILURE);
391 goto err;
392 }
393
394 if (
395 !(p1 = (t_UBSEC_ubsec_bytes_to_bits *) DSO_bind_func(ubsec_dso, UBSEC_F1)) ||
396 !(p2 = (t_UBSEC_ubsec_bits_to_bytes *) DSO_bind_func(ubsec_dso, UBSEC_F2)) ||
397 !(p3 = (t_UBSEC_ubsec_open *) DSO_bind_func(ubsec_dso, UBSEC_F3)) ||
398 !(p4 = (t_UBSEC_ubsec_close *) DSO_bind_func(ubsec_dso, UBSEC_F4)) ||
399#ifndef OPENSSL_NO_DH
400 !(p5 = (t_UBSEC_diffie_hellman_generate_ioctl *)
401 DSO_bind_func(ubsec_dso, UBSEC_F5)) ||
402 !(p6 = (t_UBSEC_diffie_hellman_agree_ioctl *)
403 DSO_bind_func(ubsec_dso, UBSEC_F6)) ||
404#endif
405/* #ifndef OPENSSL_NO_RSA */
406 !(p7 = (t_UBSEC_rsa_mod_exp_ioctl *) DSO_bind_func(ubsec_dso, UBSEC_F7)) ||
407 !(p8 = (t_UBSEC_rsa_mod_exp_crt_ioctl *) DSO_bind_func(ubsec_dso, UBSEC_F8)) ||
408/* #endif */
409#ifndef OPENSSL_NO_DSA
410 !(p9 = (t_UBSEC_dsa_sign_ioctl *) DSO_bind_func(ubsec_dso, UBSEC_F9)) ||
411 !(p10 = (t_UBSEC_dsa_verify_ioctl *) DSO_bind_func(ubsec_dso, UBSEC_F10)) ||
412#endif
413 !(p11 = (t_UBSEC_math_accelerate_ioctl *)
414 DSO_bind_func(ubsec_dso, UBSEC_F11)) ||
415 !(p12 = (t_UBSEC_rng_ioctl *) DSO_bind_func(ubsec_dso, UBSEC_F12)) ||
416 !(p13 = (t_UBSEC_max_key_len_ioctl *) DSO_bind_func(ubsec_dso, UBSEC_F13)))
417 {
418 UBSECerr(UBSEC_F_UBSEC_INIT, UBSEC_R_DSO_FAILURE);
419 goto err;
420 }
421
422 /* Copy the pointers */
423 p_UBSEC_ubsec_bytes_to_bits = p1;
424 p_UBSEC_ubsec_bits_to_bytes = p2;
425 p_UBSEC_ubsec_open = p3;
426 p_UBSEC_ubsec_close = p4;
427#ifndef OPENSSL_NO_DH
428 p_UBSEC_diffie_hellman_generate_ioctl = p5;
429 p_UBSEC_diffie_hellman_agree_ioctl = p6;
430#endif
431#ifndef OPENSSL_NO_RSA
432 p_UBSEC_rsa_mod_exp_ioctl = p7;
433 p_UBSEC_rsa_mod_exp_crt_ioctl = p8;
434#endif
435#ifndef OPENSSL_NO_DSA
436 p_UBSEC_dsa_sign_ioctl = p9;
437 p_UBSEC_dsa_verify_ioctl = p10;
438#endif
439 p_UBSEC_math_accelerate_ioctl = p11;
440 p_UBSEC_rng_ioctl = p12;
441 p_UBSEC_max_key_len_ioctl = p13;
442
443 /* Perform an open to see if there's actually any unit running. */
444 if (((fd = p_UBSEC_ubsec_open(UBSEC_KEY_DEVICE_NAME)) > 0) && (p_UBSEC_max_key_len_ioctl(fd, &max_key_len) == 0))
445 {
446 p_UBSEC_ubsec_close(fd);
447 return 1;
448 }
449 else
450 {
451 UBSECerr(UBSEC_F_UBSEC_INIT, UBSEC_R_UNIT_FAILURE);
452 }
453
454err:
455 if(ubsec_dso)
456 DSO_free(ubsec_dso);
457 ubsec_dso = NULL;
458 p_UBSEC_ubsec_bytes_to_bits = NULL;
459 p_UBSEC_ubsec_bits_to_bytes = NULL;
460 p_UBSEC_ubsec_open = NULL;
461 p_UBSEC_ubsec_close = NULL;
462#ifndef OPENSSL_NO_DH
463 p_UBSEC_diffie_hellman_generate_ioctl = NULL;
464 p_UBSEC_diffie_hellman_agree_ioctl = NULL;
465#endif
466#ifndef OPENSSL_NO_RSA
467 p_UBSEC_rsa_mod_exp_ioctl = NULL;
468 p_UBSEC_rsa_mod_exp_crt_ioctl = NULL;
469#endif
470#ifndef OPENSSL_NO_DSA
471 p_UBSEC_dsa_sign_ioctl = NULL;
472 p_UBSEC_dsa_verify_ioctl = NULL;
473#endif
474 p_UBSEC_math_accelerate_ioctl = NULL;
475 p_UBSEC_rng_ioctl = NULL;
476 p_UBSEC_max_key_len_ioctl = NULL;
477
478 return 0;
479 }
480
481static int ubsec_finish(ENGINE *e)
482 {
483 free_UBSEC_LIBNAME();
484 if(ubsec_dso == NULL)
485 {
486 UBSECerr(UBSEC_F_UBSEC_FINISH, UBSEC_R_NOT_LOADED);
487 return 0;
488 }
489 if(!DSO_free(ubsec_dso))
490 {
491 UBSECerr(UBSEC_F_UBSEC_FINISH, UBSEC_R_DSO_FAILURE);
492 return 0;
493 }
494 ubsec_dso = NULL;
495 p_UBSEC_ubsec_bytes_to_bits = NULL;
496 p_UBSEC_ubsec_bits_to_bytes = NULL;
497 p_UBSEC_ubsec_open = NULL;
498 p_UBSEC_ubsec_close = NULL;
499#ifndef OPENSSL_NO_DH
500 p_UBSEC_diffie_hellman_generate_ioctl = NULL;
501 p_UBSEC_diffie_hellman_agree_ioctl = NULL;
502#endif
503#ifndef OPENSSL_NO_RSA
504 p_UBSEC_rsa_mod_exp_ioctl = NULL;
505 p_UBSEC_rsa_mod_exp_crt_ioctl = NULL;
506#endif
507#ifndef OPENSSL_NO_DSA
508 p_UBSEC_dsa_sign_ioctl = NULL;
509 p_UBSEC_dsa_verify_ioctl = NULL;
510#endif
511 p_UBSEC_math_accelerate_ioctl = NULL;
512 p_UBSEC_rng_ioctl = NULL;
513 p_UBSEC_max_key_len_ioctl = NULL;
514 return 1;
515 }
516
517static int ubsec_ctrl(ENGINE *e, int cmd, long i, void *p, void (*f)())
518 {
519 int initialised = ((ubsec_dso == NULL) ? 0 : 1);
520 switch(cmd)
521 {
522 case UBSEC_CMD_SO_PATH:
523 if(p == NULL)
524 {
525 UBSECerr(UBSEC_F_UBSEC_CTRL,ERR_R_PASSED_NULL_PARAMETER);
526 return 0;
527 }
528 if(initialised)
529 {
530 UBSECerr(UBSEC_F_UBSEC_CTRL,UBSEC_R_ALREADY_LOADED);
531 return 0;
532 }
533 return set_UBSEC_LIBNAME((const char *)p);
534 default:
535 break;
536 }
537 UBSECerr(UBSEC_F_UBSEC_CTRL,UBSEC_R_CTRL_COMMAND_NOT_IMPLEMENTED);
538 return 0;
539 }
540
541static int ubsec_mod_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
542 const BIGNUM *m, BN_CTX *ctx)
543 {
544 int y_len = 0;
545 int fd;
546
547 if(ubsec_dso == NULL)
548 {
549 UBSECerr(UBSEC_F_UBSEC_MOD_EXP, UBSEC_R_NOT_LOADED);
550 return 0;
551 }
552
553 /* Check if hardware can't handle this argument. */
554 y_len = BN_num_bits(m);
555 if (y_len > max_key_len) {
556 UBSECerr(UBSEC_F_UBSEC_MOD_EXP, UBSEC_R_SIZE_TOO_LARGE_OR_TOO_SMALL);
557 return BN_mod_exp(r, a, p, m, ctx);
558 }
559
560 if(!bn_wexpand(r, m->top))
561 {
562 UBSECerr(UBSEC_F_UBSEC_MOD_EXP, UBSEC_R_BN_EXPAND_FAIL);
563 return 0;
564 }
565
566 if ((fd = p_UBSEC_ubsec_open(UBSEC_KEY_DEVICE_NAME)) <= 0) {
567 fd = 0;
568 UBSECerr(UBSEC_F_UBSEC_INIT, UBSEC_R_UNIT_FAILURE);
569 return BN_mod_exp(r, a, p, m, ctx);
570 }
571
572 if (p_UBSEC_rsa_mod_exp_ioctl(fd, (unsigned char *)a->d, BN_num_bits(a),
573 (unsigned char *)m->d, BN_num_bits(m), (unsigned char *)p->d,
574 BN_num_bits(p), (unsigned char *)r->d, &y_len) != 0)
575 {
576 UBSECerr(UBSEC_F_UBSEC_MOD_EXP, UBSEC_R_REQUEST_FAILED);
577 p_UBSEC_ubsec_close(fd);
578
579 return BN_mod_exp(r, a, p, m, ctx);
580 }
581
582 p_UBSEC_ubsec_close(fd);
583
584 r->top = (BN_num_bits(m)+BN_BITS2-1)/BN_BITS2;
585 return 1;
586 }
587
588#ifndef OPENSSL_NO_RSA
589static int ubsec_rsa_mod_exp(BIGNUM *r0, const BIGNUM *I, RSA *rsa)
590 {
591 BN_CTX *ctx;
592 int to_return = 0;
593
594 if((ctx = BN_CTX_new()) == NULL)
595 goto err;
596
597 if(!rsa->p || !rsa->q || !rsa->dmp1 || !rsa->dmq1 || !rsa->iqmp)
598 {
599 UBSECerr(UBSEC_F_UBSEC_RSA_MOD_EXP, UBSEC_R_MISSING_KEY_COMPONENTS);
600 goto err;
601 }
602
603 to_return = ubsec_mod_exp_crt(r0, I, rsa->p, rsa->q, rsa->dmp1,
604 rsa->dmq1, rsa->iqmp, ctx);
605 if (to_return == FAIL_TO_SOFTWARE)
606 {
607 /*
608 * Do in software as hardware failed.
609 */
610 const RSA_METHOD *meth = RSA_PKCS1_SSLeay();
611 to_return = (*meth->rsa_mod_exp)(r0, I, rsa);
612 }
613err:
614 if(ctx)
615 BN_CTX_free(ctx);
616 return to_return;
617 }
618#endif
619
620static int ubsec_mod_exp_crt(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
621 const BIGNUM *q, const BIGNUM *dp,
622 const BIGNUM *dq, const BIGNUM *qinv, BN_CTX *ctx)
623 {
624 int y_len,
625 m_len,
626 fd;
627
628 m_len = BN_num_bytes(p) + BN_num_bytes(q) + 1;
629 y_len = BN_num_bits(p) + BN_num_bits(q);
630
631 /* Check if hardware can't handle this argument. */
632 if (y_len > max_key_len) {
633 UBSECerr(UBSEC_F_UBSEC_MOD_EXP, UBSEC_R_SIZE_TOO_LARGE_OR_TOO_SMALL);
634 return FAIL_TO_SOFTWARE;
635 }
636
637 if (!bn_wexpand(r, p->top + q->top + 1)) {
638 UBSECerr(UBSEC_F_UBSEC_RSA_MOD_EXP_CRT, UBSEC_R_BN_EXPAND_FAIL);
639 return 0;
640 }
641
642 if ((fd = p_UBSEC_ubsec_open(UBSEC_KEY_DEVICE_NAME)) <= 0) {
643 fd = 0;
644 UBSECerr(UBSEC_F_UBSEC_INIT, UBSEC_R_UNIT_FAILURE);
645 return FAIL_TO_SOFTWARE;
646 }
647
648 if (p_UBSEC_rsa_mod_exp_crt_ioctl(fd,
649 (unsigned char *)a->d, BN_num_bits(a),
650 (unsigned char *)qinv->d, BN_num_bits(qinv),
651 (unsigned char *)dp->d, BN_num_bits(dp),
652 (unsigned char *)p->d, BN_num_bits(p),
653 (unsigned char *)dq->d, BN_num_bits(dq),
654 (unsigned char *)q->d, BN_num_bits(q),
655 (unsigned char *)r->d, &y_len) != 0) {
656 UBSECerr(UBSEC_F_UBSEC_MOD_EXP, UBSEC_R_REQUEST_FAILED);
657 p_UBSEC_ubsec_close(fd);
658 return FAIL_TO_SOFTWARE;
659 }
660
661 p_UBSEC_ubsec_close(fd);
662
663 r->top = (BN_num_bits(p) + BN_num_bits(q) + BN_BITS2 - 1)/BN_BITS2;
664 return 1;
665}
666
667#ifndef OPENSSL_NO_DSA
668#ifdef NOT_USED
669static int ubsec_dsa_mod_exp(DSA *dsa, BIGNUM *rr, BIGNUM *a1,
670 BIGNUM *p1, BIGNUM *a2, BIGNUM *p2, BIGNUM *m,
671 BN_CTX *ctx, BN_MONT_CTX *in_mont)
672 {
673 BIGNUM t;
674 int to_return = 0;
675
676 BN_init(&t);
677 /* let rr = a1 ^ p1 mod m */
678 if (!ubsec_mod_exp(rr,a1,p1,m,ctx)) goto end;
679 /* let t = a2 ^ p2 mod m */
680 if (!ubsec_mod_exp(&t,a2,p2,m,ctx)) goto end;
681 /* let rr = rr * t mod m */
682 if (!BN_mod_mul(rr,rr,&t,m,ctx)) goto end;
683 to_return = 1;
684end:
685 BN_free(&t);
686 return to_return;
687 }
688
689static int ubsec_mod_exp_dsa(DSA *dsa, BIGNUM *r, BIGNUM *a,
690 const BIGNUM *p, const BIGNUM *m, BN_CTX *ctx,
691 BN_MONT_CTX *m_ctx)
692 {
693 return ubsec_mod_exp(r, a, p, m, ctx);
694 }
695#endif
696#endif
697
698/*
699 * This function is aliased to mod_exp (with the mont stuff dropped).
700 */
701static int ubsec_mod_exp_mont(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
702 const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx)
703 {
704 int ret = 0;
705
706#ifndef OPENSSL_NO_RSA
707 /* Do in software if the key is too large for the hardware. */
708 if (BN_num_bits(m) > max_key_len)
709 {
710 const RSA_METHOD *meth = RSA_PKCS1_SSLeay();
711 ret = (*meth->bn_mod_exp)(r, a, p, m, ctx, m_ctx);
712 }
713 else
714#endif
715 {
716 ret = ubsec_mod_exp(r, a, p, m, ctx);
717 }
718
719 return ret;
720 }
721
722#ifndef OPENSSL_NO_DH
723/* This function is aliased to mod_exp (with the dh and mont dropped). */
724static int ubsec_mod_exp_dh(const DH *dh, BIGNUM *r, const BIGNUM *a,
725 const BIGNUM *p, const BIGNUM *m, BN_CTX *ctx,
726 BN_MONT_CTX *m_ctx)
727 {
728 return ubsec_mod_exp(r, a, p, m, ctx);
729 }
730#endif
731
732#ifndef OPENSSL_NO_DSA
733static DSA_SIG *ubsec_dsa_do_sign(const unsigned char *dgst, int dlen, DSA *dsa)
734 {
735 DSA_SIG *to_return = NULL;
736 int s_len = 160, r_len = 160, d_len, fd;
737 BIGNUM m, *r=NULL, *s=NULL;
738
739 BN_init(&m);
740
741 s = BN_new();
742 r = BN_new();
743 if ((s == NULL) || (r==NULL))
744 goto err;
745
746 d_len = p_UBSEC_ubsec_bytes_to_bits((unsigned char *)dgst, dlen);
747
748 if(!bn_wexpand(r, (160+BN_BITS2-1)/BN_BITS2) ||
749 (!bn_wexpand(s, (160+BN_BITS2-1)/BN_BITS2))) {
750 UBSECerr(UBSEC_F_UBSEC_DSA_SIGN, UBSEC_R_BN_EXPAND_FAIL);
751 goto err;
752 }
753
754 if (BN_bin2bn(dgst,dlen,&m) == NULL) {
755 UBSECerr(UBSEC_F_UBSEC_DSA_SIGN, UBSEC_R_BN_EXPAND_FAIL);
756 goto err;
757 }
758
759 if ((fd = p_UBSEC_ubsec_open(UBSEC_KEY_DEVICE_NAME)) <= 0) {
760 const DSA_METHOD *meth;
761 fd = 0;
762 UBSECerr(UBSEC_F_UBSEC_INIT, UBSEC_R_UNIT_FAILURE);
763 meth = DSA_OpenSSL();
764 to_return = meth->dsa_do_sign(dgst, dlen, dsa);
765 goto err;
766 }
767
768 if (p_UBSEC_dsa_sign_ioctl(fd, 0, /* compute hash before signing */
769 (unsigned char *)dgst, d_len,
770 NULL, 0, /* compute random value */
771 (unsigned char *)dsa->p->d, BN_num_bits(dsa->p),
772 (unsigned char *)dsa->q->d, BN_num_bits(dsa->q),
773 (unsigned char *)dsa->g->d, BN_num_bits(dsa->g),
774 (unsigned char *)dsa->priv_key->d, BN_num_bits(dsa->priv_key),
775 (unsigned char *)r->d, &r_len,
776 (unsigned char *)s->d, &s_len ) != 0) {
777 const DSA_METHOD *meth;
778
779 UBSECerr(UBSEC_F_UBSEC_DSA_SIGN, UBSEC_R_REQUEST_FAILED);
780 p_UBSEC_ubsec_close(fd);
781 meth = DSA_OpenSSL();
782 to_return = meth->dsa_do_sign(dgst, dlen, dsa);
783
784 goto err;
785 }
786
787 p_UBSEC_ubsec_close(fd);
788
789 r->top = (160+BN_BITS2-1)/BN_BITS2;
790 s->top = (160+BN_BITS2-1)/BN_BITS2;
791
792 to_return = DSA_SIG_new();
793 if(to_return == NULL) {
794 UBSECerr(UBSEC_F_UBSEC_DSA_SIGN, UBSEC_R_BN_EXPAND_FAIL);
795 goto err;
796 }
797
798 to_return->r = r;
799 to_return->s = s;
800
801err:
802 if (!to_return) {
803 if (r) BN_free(r);
804 if (s) BN_free(s);
805 }
806 BN_clear_free(&m);
807 return to_return;
808}
809
810static int ubsec_dsa_verify(const unsigned char *dgst, int dgst_len,
811 DSA_SIG *sig, DSA *dsa)
812 {
813 int v_len, d_len;
814 int to_return = 0;
815 int fd;
816 BIGNUM v;
817
818 BN_init(&v);
819
820 if(!bn_wexpand(&v, dsa->p->top)) {
821 UBSECerr(UBSEC_F_UBSEC_DSA_VERIFY ,UBSEC_R_BN_EXPAND_FAIL);
822 goto err;
823 }
824
825 v_len = BN_num_bits(dsa->p);
826
827 d_len = p_UBSEC_ubsec_bytes_to_bits((unsigned char *)dgst, dgst_len);
828
829 if ((fd = p_UBSEC_ubsec_open(UBSEC_KEY_DEVICE_NAME)) <= 0) {
830 const DSA_METHOD *meth;
831 fd = 0;
832 UBSECerr(UBSEC_F_UBSEC_INIT, UBSEC_R_UNIT_FAILURE);
833 meth = DSA_OpenSSL();
834 to_return = meth->dsa_do_verify(dgst, dgst_len, sig, dsa);
835 goto err;
836 }
837
838 if (p_UBSEC_dsa_verify_ioctl(fd, 0, /* compute hash before signing */
839 (unsigned char *)dgst, d_len,
840 (unsigned char *)dsa->p->d, BN_num_bits(dsa->p),
841 (unsigned char *)dsa->q->d, BN_num_bits(dsa->q),
842 (unsigned char *)dsa->g->d, BN_num_bits(dsa->g),
843 (unsigned char *)dsa->pub_key->d, BN_num_bits(dsa->pub_key),
844 (unsigned char *)sig->r->d, BN_num_bits(sig->r),
845 (unsigned char *)sig->s->d, BN_num_bits(sig->s),
846 (unsigned char *)v.d, &v_len) != 0) {
847 const DSA_METHOD *meth;
848 UBSECerr(UBSEC_F_UBSEC_DSA_VERIFY , UBSEC_R_REQUEST_FAILED);
849 p_UBSEC_ubsec_close(fd);
850
851 meth = DSA_OpenSSL();
852 to_return = meth->dsa_do_verify(dgst, dgst_len, sig, dsa);
853
854 goto err;
855 }
856
857 p_UBSEC_ubsec_close(fd);
858
859 to_return = 1;
860err:
861 BN_clear_free(&v);
862 return to_return;
863 }
864#endif
865
866#ifndef OPENSSL_NO_DH
867static int ubsec_dh_compute_key (unsigned char *key,const BIGNUM *pub_key,DH *dh)
868 {
869 int ret = -1,
870 k_len,
871 fd;
872
873 k_len = BN_num_bits(dh->p);
874
875 if ((fd = p_UBSEC_ubsec_open(UBSEC_KEY_DEVICE_NAME)) <= 0)
876 {
877 const DH_METHOD *meth;
878 ENGINEerr(UBSEC_F_UBSEC_INIT, UBSEC_R_UNIT_FAILURE);
879 meth = DH_OpenSSL();
880 ret = meth->compute_key(key, pub_key, dh);
881 goto err;
882 }
883
884 if (p_UBSEC_diffie_hellman_agree_ioctl(fd,
885 (unsigned char *)dh->priv_key->d, BN_num_bits(dh->priv_key),
886 (unsigned char *)pub_key->d, BN_num_bits(pub_key),
887 (unsigned char *)dh->p->d, BN_num_bits(dh->p),
888 key, &k_len) != 0)
889 {
890 /* Hardware's a no go, failover to software */
891 const DH_METHOD *meth;
892 ENGINEerr(UBSEC_F_UBSEC_DH_COMPUTE_KEY, UBSEC_R_REQUEST_FAILED);
893 p_UBSEC_ubsec_close(fd);
894
895 meth = DH_OpenSSL();
896 ret = meth->compute_key(key, pub_key, dh);
897
898 goto err;
899 }
900
901 p_UBSEC_ubsec_close(fd);
902
903 ret = p_UBSEC_ubsec_bits_to_bytes(k_len);
904err:
905 return ret;
906 }
907
908static int ubsec_dh_generate_key (DH *dh)
909 {
910 int ret = 0,
911 random_bits = 0,
912 pub_key_len = 0,
913 priv_key_len = 0,
914 fd;
915 BIGNUM *pub_key = NULL;
916 BIGNUM *priv_key = NULL;
917
918 /*
919 * How many bits should Random x be? dh_key.c
920 * sets the range from 0 to num_bits(modulus) ???
921 */
922
923 if (dh->priv_key == NULL)
924 {
925 priv_key = BN_new();
926 if (priv_key == NULL) goto err;
927 priv_key_len = BN_num_bits(dh->p);
928 bn_wexpand(priv_key, dh->p->top);
929 do
930 if (!BN_rand_range(priv_key, dh->p)) goto err;
931 while (BN_is_zero(priv_key));
932 random_bits = BN_num_bits(priv_key);
933 }
934 else
935 {
936 priv_key = dh->priv_key;
937 }
938
939 if (dh->pub_key == NULL)
940 {
941 pub_key = BN_new();
942 pub_key_len = BN_num_bits(dh->p);
943 bn_wexpand(pub_key, dh->p->top);
944 if(pub_key == NULL) goto err;
945 }
946 else
947 {
948 pub_key = dh->pub_key;
949 }
950
951 if ((fd = p_UBSEC_ubsec_open(UBSEC_KEY_DEVICE_NAME)) <= 0)
952 {
953 const DH_METHOD *meth;
954 ENGINEerr(UBSEC_F_UBSEC_INIT, UBSEC_R_UNIT_FAILURE);
955 meth = DH_OpenSSL();
956 ret = meth->generate_key(dh);
957 goto err;
958 }
959
960 if (p_UBSEC_diffie_hellman_generate_ioctl(fd,
961 (unsigned char *)priv_key->d, &priv_key_len,
962 (unsigned char *)pub_key->d, &pub_key_len,
963 (unsigned char *)dh->g->d, BN_num_bits(dh->g),
964 (unsigned char *)dh->p->d, BN_num_bits(dh->p),
965 0, 0, random_bits) != 0)
966 {
967 /* Hardware's a no go, failover to software */
968 const DH_METHOD *meth;
969
970 ENGINEerr(UBSEC_F_UBSEC_DH_COMPUTE_KEY, UBSEC_R_REQUEST_FAILED);
971 p_UBSEC_ubsec_close(fd);
972
973 meth = DH_OpenSSL();
974 ret = meth->generate_key(dh);
975
976 goto err;
977 }
978
979 p_UBSEC_ubsec_close(fd);
980
981 dh->pub_key = pub_key;
982 dh->pub_key->top = (pub_key_len + BN_BITS2-1) / BN_BITS2;
983 dh->priv_key = priv_key;
984 dh->priv_key->top = (priv_key_len + BN_BITS2-1) / BN_BITS2;
985
986 ret = 1;
987err:
988 return ret;
989 }
990#endif
991
992#ifdef NOT_USED
993static int ubsec_rand_bytes(unsigned char * buf,
994 int num)
995 {
996 int ret = 0,
997 fd;
998
999 if ((fd = p_UBSEC_ubsec_open(UBSEC_KEY_DEVICE_NAME)) <= 0)
1000 {
1001 const RAND_METHOD *meth;
1002 ENGINEerr(UBSEC_F_UBSEC_INIT, UBSEC_R_UNIT_FAILURE);
1003 num = p_UBSEC_ubsec_bits_to_bytes(num);
1004 meth = RAND_SSLeay();
1005 meth->seed(buf, num);
1006 ret = meth->bytes(buf, num);
1007 goto err;
1008 }
1009
1010 num *= 8; /* bytes to bits */
1011
1012 if (p_UBSEC_rng_ioctl(fd,
1013 UBSEC_RNG_DIRECT,
1014 buf,
1015 &num) != 0)
1016 {
1017 /* Hardware's a no go, failover to software */
1018 const RAND_METHOD *meth;
1019
1020 ENGINEerr(UBSEC_F_UBSEC_RNG_BYTES, UBSEC_R_REQUEST_FAILED);
1021 p_UBSEC_ubsec_close(fd);
1022
1023 num = p_UBSEC_ubsec_bits_to_bytes(num);
1024 meth = RAND_SSLeay();
1025 meth->seed(buf, num);
1026 ret = meth->bytes(buf, num);
1027
1028 goto err;
1029 }
1030
1031 p_UBSEC_ubsec_close(fd);
1032
1033 ret = 1;
1034err:
1035 return(ret);
1036 }
1037
1038
1039static int ubsec_rand_status(void)
1040 {
1041 return 0;
1042 }
1043#endif
1044
1045/* This stuff is needed if this ENGINE is being compiled into a self-contained
1046 * shared-library. */
1047#ifdef ENGINE_DYNAMIC_SUPPORT
1048static int bind_fn(ENGINE *e, const char *id)
1049 {
1050 if(id && (strcmp(id, engine_ubsec_id) != 0))
1051 return 0;
1052 if(!bind_helper(e))
1053 return 0;
1054 return 1;
1055 }
1056IMPLEMENT_DYNAMIC_CHECK_FN()
1057IMPLEMENT_DYNAMIC_BIND_FN(bind_fn)
1058#endif /* ENGINE_DYNAMIC_SUPPORT */
1059
1060#endif /* !OPENSSL_NO_HW_UBSEC */
1061#endif /* !OPENSSL_NO_HW */
diff --git a/src/lib/libcrypto/engine/hw_ubsec_err.c b/src/lib/libcrypto/engine/hw_ubsec_err.c
deleted file mode 100644
index d707331fc2..0000000000
--- a/src/lib/libcrypto/engine/hw_ubsec_err.c
+++ /dev/null
@@ -1,151 +0,0 @@
1/* hw_ubsec_err.c */
2/* ====================================================================
3 * Copyright (c) 1999 The OpenSSL Project. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 *
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in
14 * the documentation and/or other materials provided with the
15 * distribution.
16 *
17 * 3. All advertising materials mentioning features or use of this
18 * software must display the following acknowledgment:
19 * "This product includes software developed by the OpenSSL Project
20 * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
21 *
22 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
23 * endorse or promote products derived from this software without
24 * prior written permission. For written permission, please contact
25 * openssl-core@OpenSSL.org.
26 *
27 * 5. Products derived from this software may not be called "OpenSSL"
28 * nor may "OpenSSL" appear in their names without prior written
29 * permission of the OpenSSL Project.
30 *
31 * 6. Redistributions of any form whatsoever must retain the following
32 * acknowledgment:
33 * "This product includes software developed by the OpenSSL Project
34 * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
35 *
36 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
37 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
38 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
39 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
40 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
41 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
42 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
43 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
44 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
45 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
46 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
47 * OF THE POSSIBILITY OF SUCH DAMAGE.
48 * ====================================================================
49 *
50 * This product includes cryptographic software written by Eric Young
51 * (eay@cryptsoft.com). This product includes software written by Tim
52 * Hudson (tjh@cryptsoft.com).
53 *
54 */
55
56/* NOTE: this file was auto generated by the mkerr.pl script: any changes
57 * made to it will be overwritten when the script next updates this file,
58 * only reason strings will be preserved.
59 */
60
61#include <stdio.h>
62#include <openssl/err.h>
63#include "hw_ubsec_err.h"
64
65/* BEGIN ERROR CODES */
66#ifndef OPENSSL_NO_ERR
67static ERR_STRING_DATA UBSEC_str_functs[]=
68 {
69{ERR_PACK(0,UBSEC_F_UBSEC_CTRL,0), "UBSEC_CTRL"},
70{ERR_PACK(0,UBSEC_F_UBSEC_DH_COMPUTE_KEY,0), "UBSEC_DH_COMPUTE_KEY"},
71{ERR_PACK(0,UBSEC_F_UBSEC_DSA_SIGN,0), "UBSEC_DSA_SIGN"},
72{ERR_PACK(0,UBSEC_F_UBSEC_DSA_VERIFY,0), "UBSEC_DSA_VERIFY"},
73{ERR_PACK(0,UBSEC_F_UBSEC_FINISH,0), "UBSEC_FINISH"},
74{ERR_PACK(0,UBSEC_F_UBSEC_INIT,0), "UBSEC_INIT"},
75{ERR_PACK(0,UBSEC_F_UBSEC_MOD_EXP,0), "UBSEC_MOD_EXP"},
76{ERR_PACK(0,UBSEC_F_UBSEC_RNG_BYTES,0), "UBSEC_RNG_BYTES"},
77{ERR_PACK(0,UBSEC_F_UBSEC_RSA_MOD_EXP,0), "UBSEC_RSA_MOD_EXP"},
78{ERR_PACK(0,UBSEC_F_UBSEC_RSA_MOD_EXP_CRT,0), "UBSEC_RSA_MOD_EXP_CRT"},
79{0,NULL}
80 };
81
82static ERR_STRING_DATA UBSEC_str_reasons[]=
83 {
84{UBSEC_R_ALREADY_LOADED ,"already loaded"},
85{UBSEC_R_BN_EXPAND_FAIL ,"bn expand fail"},
86{UBSEC_R_CTRL_COMMAND_NOT_IMPLEMENTED ,"ctrl command not implemented"},
87{UBSEC_R_DSO_FAILURE ,"dso failure"},
88{UBSEC_R_MISSING_KEY_COMPONENTS ,"missing key components"},
89{UBSEC_R_NOT_LOADED ,"not loaded"},
90{UBSEC_R_REQUEST_FAILED ,"request failed"},
91{UBSEC_R_SIZE_TOO_LARGE_OR_TOO_SMALL ,"size too large or too small"},
92{UBSEC_R_UNIT_FAILURE ,"unit failure"},
93{0,NULL}
94 };
95
96#endif
97
98#ifdef UBSEC_LIB_NAME
99static ERR_STRING_DATA UBSEC_lib_name[]=
100 {
101{0 ,UBSEC_LIB_NAME},
102{0,NULL}
103 };
104#endif
105
106
107static int UBSEC_lib_error_code=0;
108static int UBSEC_error_init=1;
109
110static void ERR_load_UBSEC_strings(void)
111 {
112 if (UBSEC_lib_error_code == 0)
113 UBSEC_lib_error_code=ERR_get_next_error_library();
114
115 if (UBSEC_error_init)
116 {
117 UBSEC_error_init=0;
118#ifndef OPENSSL_NO_ERR
119 ERR_load_strings(UBSEC_lib_error_code,UBSEC_str_functs);
120 ERR_load_strings(UBSEC_lib_error_code,UBSEC_str_reasons);
121#endif
122
123#ifdef UBSEC_LIB_NAME
124 UBSEC_lib_name->error = ERR_PACK(UBSEC_lib_error_code,0,0);
125 ERR_load_strings(0,UBSEC_lib_name);
126#endif
127 }
128 }
129
130static void ERR_unload_UBSEC_strings(void)
131 {
132 if (UBSEC_error_init == 0)
133 {
134#ifndef OPENSSL_NO_ERR
135 ERR_unload_strings(UBSEC_lib_error_code,UBSEC_str_functs);
136 ERR_unload_strings(UBSEC_lib_error_code,UBSEC_str_reasons);
137#endif
138
139#ifdef UBSEC_LIB_NAME
140 ERR_unload_strings(0,UBSEC_lib_name);
141#endif
142 UBSEC_error_init=1;
143 }
144 }
145
146static void ERR_UBSEC_error(int function, int reason, char *file, int line)
147 {
148 if (UBSEC_lib_error_code == 0)
149 UBSEC_lib_error_code=ERR_get_next_error_library();
150 ERR_PUT_error(UBSEC_lib_error_code,function,reason,file,line);
151 }
diff --git a/src/lib/libcrypto/engine/hw_ubsec_err.h b/src/lib/libcrypto/engine/hw_ubsec_err.h
deleted file mode 100644
index 023d3be771..0000000000
--- a/src/lib/libcrypto/engine/hw_ubsec_err.h
+++ /dev/null
@@ -1,95 +0,0 @@
1/* ====================================================================
2 * Copyright (c) 2001 The OpenSSL Project. All rights reserved.
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 * openssl-core@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 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
36 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
37 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
38 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
39 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
40 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
41 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
42 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
43 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
44 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
45 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
46 * OF THE POSSIBILITY OF SUCH DAMAGE.
47 * ====================================================================
48 *
49 * This product includes cryptographic software written by Eric Young
50 * (eay@cryptsoft.com). This product includes software written by Tim
51 * Hudson (tjh@cryptsoft.com).
52 *
53 */
54
55#ifndef HEADER_UBSEC_ERR_H
56#define HEADER_UBSEC_ERR_H
57
58/* BEGIN ERROR CODES */
59/* The following lines are auto generated by the script mkerr.pl. Any changes
60 * made after this point may be overwritten when the script is next run.
61 */
62static void ERR_load_UBSEC_strings(void);
63static void ERR_unload_UBSEC_strings(void);
64static void ERR_UBSEC_error(int function, int reason, char *file, int line);
65#define UBSECerr(f,r) ERR_UBSEC_error((f),(r),__FILE__,__LINE__)
66
67/* Error codes for the UBSEC functions. */
68
69/* Function codes. */
70#define UBSEC_F_UBSEC_CTRL 100
71#define UBSEC_F_UBSEC_DH_COMPUTE_KEY 101
72#define UBSEC_F_UBSEC_DSA_SIGN 102
73#define UBSEC_F_UBSEC_DSA_VERIFY 103
74#define UBSEC_F_UBSEC_FINISH 104
75#define UBSEC_F_UBSEC_INIT 105
76#define UBSEC_F_UBSEC_MOD_EXP 106
77#define UBSEC_F_UBSEC_RNG_BYTES 107
78#define UBSEC_F_UBSEC_RSA_MOD_EXP 108
79#define UBSEC_F_UBSEC_RSA_MOD_EXP_CRT 109
80
81/* Reason codes. */
82#define UBSEC_R_ALREADY_LOADED 100
83#define UBSEC_R_BN_EXPAND_FAIL 101
84#define UBSEC_R_CTRL_COMMAND_NOT_IMPLEMENTED 102
85#define UBSEC_R_DSO_FAILURE 103
86#define UBSEC_R_MISSING_KEY_COMPONENTS 104
87#define UBSEC_R_NOT_LOADED 105
88#define UBSEC_R_REQUEST_FAILED 106
89#define UBSEC_R_SIZE_TOO_LARGE_OR_TOO_SMALL 107
90#define UBSEC_R_UNIT_FAILURE 108
91
92#ifdef __cplusplus
93}
94#endif
95#endif
diff --git a/src/lib/libcrypto/engine/vendor_defns/aep.h b/src/lib/libcrypto/engine/vendor_defns/aep.h
deleted file mode 100644
index 2b2792d2d6..0000000000
--- a/src/lib/libcrypto/engine/vendor_defns/aep.h
+++ /dev/null
@@ -1,178 +0,0 @@
1/* This header declares the necessary definitions for using the exponentiation
2 * acceleration capabilities, and rnd number generation of the AEP card.
3 *
4 */
5
6/*
7 *
8 * Some AEP defines
9 *
10 */
11
12/*Successful return value*/
13#define AEP_R_OK 0x00000000
14
15/*Miscelleanous unsuccessful return value*/
16#define AEP_R_GENERAL_ERROR 0x10000001
17
18/*Insufficient host memory*/
19#define AEP_R_HOST_MEMORY 0x10000002
20
21#define AEP_R_FUNCTION_FAILED 0x10000006
22
23/*Invalid arguments in function call*/
24#define AEP_R_ARGUMENTS_BAD 0x10020000
25
26#define AEP_R_NO_TARGET_RESOURCES 0x10030000
27
28/*Error occuring on socket operation*/
29#define AEP_R_SOCKERROR 0x10000010
30
31/*Socket has been closed from the other end*/
32#define AEP_R_SOCKEOF 0x10000011
33
34/*Invalid handles*/
35#define AEP_R_CONNECTION_HANDLE_INVALID 0x100000B3
36
37#define AEP_R_TRANSACTION_HANDLE_INVALID 0x10040000
38
39/*Transaction has not yet returned from accelerator*/
40#define AEP_R_TRANSACTION_NOT_READY 0x00010000
41
42/*There is already a thread waiting on this transaction*/
43#define AEP_R_TRANSACTION_CLAIMED 0x10050000
44
45/*The transaction timed out*/
46#define AEP_R_TIMED_OUT 0x10060000
47
48#define AEP_R_FXN_NOT_IMPLEMENTED 0x10070000
49
50#define AEP_R_TARGET_ERROR 0x10080000
51
52/*Error in the AEP daemon process*/
53#define AEP_R_DAEMON_ERROR 0x10090000
54
55/*Invalid ctx id*/
56#define AEP_R_INVALID_CTX_ID 0x10009000
57
58#define AEP_R_NO_KEY_MANAGER 0x1000a000
59
60/*Error obtaining a mutex*/
61#define AEP_R_MUTEX_BAD 0x000001A0
62
63/*Fxn call before AEP_Initialise ot after AEP_Finialise*/
64#define AEP_R_AEPAPI_NOT_INITIALIZED 0x10000190
65
66/*AEP_Initialise has already been called*/
67#define AEP_R_AEPAPI_ALREADY_INITIALIZED 0x10000191
68
69/*Maximum number of connections to daemon reached*/
70#define AEP_R_NO_MORE_CONNECTION_HNDLS 0x10000200
71
72/*
73 *
74 * Some AEP Type definitions
75 *
76 */
77
78/* an unsigned 8-bit value */
79typedef unsigned char AEP_U8;
80
81/* an unsigned 8-bit character */
82typedef char AEP_CHAR;
83
84/* a BYTE-sized Boolean flag */
85typedef AEP_U8 AEP_BBOOL;
86
87/*Unsigned value, at least 16 bits long*/
88typedef unsigned short AEP_U16;
89
90/* an unsigned value, at least 32 bits long */
91#ifdef SIXTY_FOUR_BIT_LONG
92typedef unsigned int AEP_U32;
93#else
94typedef unsigned long AEP_U32;
95#endif
96
97#ifdef SIXTY_FOUR_BIT_LONG
98typedef unsigned long AEP_U64;
99#else
100typedef struct { unsigned long l1, l2; } AEP_U64;
101#endif
102
103/* at least 32 bits; each bit is a Boolean flag */
104typedef AEP_U32 AEP_FLAGS;
105
106typedef AEP_U8 *AEP_U8_PTR;
107typedef AEP_CHAR *AEP_CHAR_PTR;
108typedef AEP_U32 *AEP_U32_PTR;
109typedef AEP_U64 *AEP_U64_PTR;
110typedef void *AEP_VOID_PTR;
111
112/* Pointer to a AEP_VOID_PTR-- i.e., pointer to pointer to void */
113typedef AEP_VOID_PTR *AEP_VOID_PTR_PTR;
114
115/*Used to identify an AEP connection handle*/
116typedef AEP_U32 AEP_CONNECTION_HNDL;
117
118/*Pointer to an AEP connection handle*/
119typedef AEP_CONNECTION_HNDL *AEP_CONNECTION_HNDL_PTR;
120
121/*Used by an application (in conjunction with the apps process id) to
122identify an individual transaction*/
123typedef AEP_U32 AEP_TRANSACTION_ID;
124
125/*Pointer to an applications transaction identifier*/
126typedef AEP_TRANSACTION_ID *AEP_TRANSACTION_ID_PTR;
127
128/*Return value type*/
129typedef AEP_U32 AEP_RV;
130
131#define MAX_PROCESS_CONNECTIONS 256
132
133#define RAND_BLK_SIZE 1024
134
135typedef enum{
136 NotConnected= 0,
137 Connected= 1,
138 InUse= 2
139} AEP_CONNECTION_STATE;
140
141
142typedef struct AEP_CONNECTION_ENTRY{
143 AEP_CONNECTION_STATE conn_state;
144 AEP_CONNECTION_HNDL conn_hndl;
145} AEP_CONNECTION_ENTRY;
146
147
148typedef AEP_RV t_AEP_OpenConnection(AEP_CONNECTION_HNDL_PTR phConnection);
149typedef AEP_RV t_AEP_CloseConnection(AEP_CONNECTION_HNDL hConnection);
150
151typedef AEP_RV t_AEP_ModExp(AEP_CONNECTION_HNDL hConnection,
152 AEP_VOID_PTR pA, AEP_VOID_PTR pP,
153 AEP_VOID_PTR pN,
154 AEP_VOID_PTR pResult,
155 AEP_TRANSACTION_ID* pidTransID);
156
157typedef AEP_RV t_AEP_ModExpCrt(AEP_CONNECTION_HNDL hConnection,
158 AEP_VOID_PTR pA, AEP_VOID_PTR pP,
159 AEP_VOID_PTR pQ,
160 AEP_VOID_PTR pDmp1, AEP_VOID_PTR pDmq1,
161 AEP_VOID_PTR pIqmp,
162 AEP_VOID_PTR pResult,
163 AEP_TRANSACTION_ID* pidTransID);
164
165#ifdef AEPRAND
166typedef AEP_RV t_AEP_GenRandom(AEP_CONNECTION_HNDL hConnection,
167 AEP_U32 Len,
168 AEP_U32 Type,
169 AEP_VOID_PTR pResult,
170 AEP_TRANSACTION_ID* pidTransID);
171#endif
172
173typedef AEP_RV t_AEP_Initialize(AEP_VOID_PTR pInitArgs);
174typedef AEP_RV t_AEP_Finalize();
175typedef AEP_RV t_AEP_SetBNCallBacks(AEP_RV (*GetBigNumSizeFunc)(),
176 AEP_RV (*MakeAEPBigNumFunc)(),
177 AEP_RV (*ConverAEPBigNumFunc)());
178
diff --git a/src/lib/libcrypto/engine/vendor_defns/atalla.h b/src/lib/libcrypto/engine/vendor_defns/atalla.h
deleted file mode 100644
index 149970d441..0000000000
--- a/src/lib/libcrypto/engine/vendor_defns/atalla.h
+++ /dev/null
@@ -1,48 +0,0 @@
1/* This header declares the necessary definitions for using the exponentiation
2 * acceleration capabilities of Atalla cards. The only cryptographic operation
3 * is performed by "ASI_RSAPrivateKeyOpFn" and this takes a structure that
4 * defines an "RSA private key". However, it is really only performing a
5 * regular mod_exp using the supplied modulus and exponent - no CRT form is
6 * being used. Hence, it is a generic mod_exp function in disguise, and we use
7 * it as such.
8 *
9 * Thanks to the people at Atalla for letting me know these definitions are
10 * fine and that they can be reproduced here.
11 *
12 * Geoff.
13 */
14
15typedef struct ItemStr
16 {
17 unsigned char *data;
18 int len;
19 } Item;
20
21typedef struct RSAPrivateKeyStr
22 {
23 void *reserved;
24 Item version;
25 Item modulus;
26 Item publicExponent;
27 Item privateExponent;
28 Item prime[2];
29 Item exponent[2];
30 Item coefficient;
31 } RSAPrivateKey;
32
33/* Predeclare the function pointer types that we dynamically load from the DSO.
34 * These use the same names and form that Ben's original support code had (in
35 * crypto/bn/bn_exp.c) unless of course I've inadvertently changed the style
36 * somewhere along the way!
37 */
38
39typedef int tfnASI_GetPerformanceStatistics(int reset_flag,
40 unsigned int *ret_buf);
41
42typedef int tfnASI_GetHardwareConfig(long card_num, unsigned int *ret_buf);
43
44typedef int tfnASI_RSAPrivateKeyOpFn(RSAPrivateKey * rsaKey,
45 unsigned char *output,
46 unsigned char *input,
47 unsigned int modulus_len);
48
diff --git a/src/lib/libcrypto/engine/vendor_defns/cswift.h b/src/lib/libcrypto/engine/vendor_defns/cswift.h
deleted file mode 100644
index 60079326bb..0000000000
--- a/src/lib/libcrypto/engine/vendor_defns/cswift.h
+++ /dev/null
@@ -1,234 +0,0 @@
1/* Attribution notice: Rainbow have generously allowed me to reproduce
2 * the necessary definitions here from their API. This means the support
3 * can build independently of whether application builders have the
4 * API or hardware. This will allow developers to easily produce software
5 * that has latent hardware support for any users that have accelertors
6 * installed, without the developers themselves needing anything extra.
7 *
8 * I have only clipped the parts from the CryptoSwift header files that
9 * are (or seem) relevant to the CryptoSwift support code. This is
10 * simply to keep the file sizes reasonable.
11 * [Geoff]
12 */
13
14
15/* NB: These type widths do *not* seem right in general, in particular
16 * they're not terribly friendly to 64-bit architectures (unsigned long)
17 * will be 64-bit on IA-64 for a start. I'm leaving these alone as they
18 * agree with Rainbow's API and this will only be called into question
19 * on platforms with Rainbow support anyway! ;-) */
20
21#ifdef __cplusplus
22extern "C" {
23#endif /* __cplusplus */
24
25typedef long SW_STATUS; /* status */
26typedef unsigned char SW_BYTE; /* 8 bit byte */
27typedef unsigned short SW_U16; /* 16 bit number */
28#if defined(_IRIX)
29#include <sgidefs.h>
30typedef __uint32_t SW_U32;
31#else
32typedef unsigned long SW_U32; /* 32 bit integer */
33#endif
34
35#if defined(OPENSSL_SYS_WIN32)
36 typedef struct _SW_U64 {
37 SW_U32 low32;
38 SW_U32 high32;
39 } SW_U64; /* 64 bit integer */
40#elif defined(OPENSSL_SYS_MACINTOSH_CLASSIC)
41 typedef longlong SW_U64
42#else /* Unix variants */
43 typedef struct _SW_U64 {
44 SW_U32 low32;
45 SW_U32 high32;
46 } SW_U64; /* 64 bit integer */
47#endif
48
49/* status codes */
50#define SW_OK (0L)
51#define SW_ERR_BASE (-10000L)
52#define SW_ERR_NO_CARD (SW_ERR_BASE-1) /* The Card is not present */
53#define SW_ERR_CARD_NOT_READY (SW_ERR_BASE-2) /* The card has not powered */
54 /* up yet */
55#define SW_ERR_TIME_OUT (SW_ERR_BASE-3) /* Execution of a command */
56 /* time out */
57#define SW_ERR_NO_EXECUTE (SW_ERR_BASE-4) /* The Card failed to */
58 /* execute the command */
59#define SW_ERR_INPUT_NULL_PTR (SW_ERR_BASE-5) /* a required pointer is */
60 /* NULL */
61#define SW_ERR_INPUT_SIZE (SW_ERR_BASE-6) /* size is invalid, too */
62 /* small, too large. */
63#define SW_ERR_INVALID_HANDLE (SW_ERR_BASE-7) /* Invalid SW_ACC_CONTEXT */
64 /* handle */
65#define SW_ERR_PENDING (SW_ERR_BASE-8) /* A request is already out- */
66 /* standing at this */
67 /* context handle */
68#define SW_ERR_AVAILABLE (SW_ERR_BASE-9) /* A result is available. */
69#define SW_ERR_NO_PENDING (SW_ERR_BASE-10)/* No request is pending. */
70#define SW_ERR_NO_MEMORY (SW_ERR_BASE-11)/* Not enough memory */
71#define SW_ERR_BAD_ALGORITHM (SW_ERR_BASE-12)/* Invalid algorithm type */
72 /* in SW_PARAM structure */
73#define SW_ERR_MISSING_KEY (SW_ERR_BASE-13)/* No key is associated with */
74 /* context. */
75 /* swAttachKeyParam() is */
76 /* not called. */
77#define SW_ERR_KEY_CMD_MISMATCH \
78 (SW_ERR_BASE-14)/* Cannot perform requested */
79 /* SW_COMMAND_CODE since */
80 /* key attached via */
81 /* swAttachKeyParam() */
82 /* cannot be used for this*/
83 /* SW_COMMAND_CODE. */
84#define SW_ERR_NOT_IMPLEMENTED \
85 (SW_ERR_BASE-15)/* Not implemented */
86#define SW_ERR_BAD_COMMAND (SW_ERR_BASE-16)/* Bad command code */
87#define SW_ERR_BAD_ITEM_SIZE (SW_ERR_BASE-17)/* too small or too large in */
88 /* the "initems" or */
89 /* "outitems". */
90#define SW_ERR_BAD_ACCNUM (SW_ERR_BASE-18)/* Bad accelerator number */
91#define SW_ERR_SELFTEST_FAIL (SW_ERR_BASE-19)/* At least one of the self */
92 /* test fail, look at the */
93 /* selfTestBitmap in */
94 /* SW_ACCELERATOR_INFO for*/
95 /* details. */
96#define SW_ERR_MISALIGN (SW_ERR_BASE-20)/* Certain alogrithms require*/
97 /* key materials aligned */
98 /* in certain order, e.g. */
99 /* 128 bit for CRT */
100#define SW_ERR_OUTPUT_NULL_PTR \
101 (SW_ERR_BASE-21)/* a required pointer is */
102 /* NULL */
103#define SW_ERR_OUTPUT_SIZE \
104 (SW_ERR_BASE-22)/* size is invalid, too */
105 /* small, too large. */
106#define SW_ERR_FIRMWARE_CHECKSUM \
107 (SW_ERR_BASE-23)/* firmware checksum mismatch*/
108 /* download failed. */
109#define SW_ERR_UNKNOWN_FIRMWARE \
110 (SW_ERR_BASE-24)/* unknown firmware error */
111#define SW_ERR_INTERRUPT (SW_ERR_BASE-25)/* request is abort when */
112 /* it's waiting to be */
113 /* completed. */
114#define SW_ERR_NVWRITE_FAIL (SW_ERR_BASE-26)/* error in writing to Non- */
115 /* volatile memory */
116#define SW_ERR_NVWRITE_RANGE (SW_ERR_BASE-27)/* out of range error in */
117 /* writing to NV memory */
118#define SW_ERR_RNG_ERROR (SW_ERR_BASE-28)/* Random Number Generation */
119 /* failure */
120#define SW_ERR_DSS_FAILURE (SW_ERR_BASE-29)/* DSS Sign or Verify failure*/
121#define SW_ERR_MODEXP_FAILURE (SW_ERR_BASE-30)/* Failure in various math */
122 /* calculations */
123#define SW_ERR_ONBOARD_MEMORY (SW_ERR_BASE-31)/* Error in accessing on - */
124 /* board memory */
125#define SW_ERR_FIRMWARE_VERSION \
126 (SW_ERR_BASE-32)/* Wrong version in firmware */
127 /* update */
128#define SW_ERR_ZERO_WORKING_ACCELERATOR \
129 (SW_ERR_BASE-44)/* All accelerators are bad */
130
131
132 /* algorithm type */
133#define SW_ALG_CRT 1
134#define SW_ALG_EXP 2
135#define SW_ALG_DSA 3
136#define SW_ALG_NVDATA 4
137
138 /* command code */
139#define SW_CMD_MODEXP_CRT 1 /* perform Modular Exponentiation using */
140 /* Chinese Remainder Theorem (CRT) */
141#define SW_CMD_MODEXP 2 /* perform Modular Exponentiation */
142#define SW_CMD_DSS_SIGN 3 /* perform DSS sign */
143#define SW_CMD_DSS_VERIFY 4 /* perform DSS verify */
144#define SW_CMD_RAND 5 /* perform random number generation */
145#define SW_CMD_NVREAD 6 /* perform read to nonvolatile RAM */
146#define SW_CMD_NVWRITE 7 /* perform write to nonvolatile RAM */
147
148typedef SW_U32 SW_ALGTYPE; /* alogrithm type */
149typedef SW_U32 SW_STATE; /* state */
150typedef SW_U32 SW_COMMAND_CODE; /* command code */
151typedef SW_U32 SW_COMMAND_BITMAP[4]; /* bitmap */
152
153typedef struct _SW_LARGENUMBER {
154 SW_U32 nbytes; /* number of bytes in the buffer "value" */
155 SW_BYTE* value; /* the large integer as a string of */
156 /* bytes in network (big endian) order */
157} SW_LARGENUMBER;
158
159#if defined(OPENSSL_SYS_WIN32)
160 #include <windows.h>
161 typedef HANDLE SW_OSHANDLE; /* handle to kernel object */
162 #define SW_OS_INVALID_HANDLE INVALID_HANDLE_VALUE
163 #define SW_CALLCONV _stdcall
164#elif defined(OPENSSL_SYS_MACINTOSH_CLASSIC)
165 /* async callback mechanisms */
166 /* swiftCallbackLevel */
167 #define SW_MAC_CALLBACK_LEVEL_NO 0
168 #define SW_MAC_CALLBACK_LEVEL_HARDWARE 1 /* from the hardware ISR */
169 #define SW_MAC_CALLBACK_LEVEL_SECONDARY 2 /* as secondary ISR */
170 typedef int SW_MAC_CALLBACK_LEVEL;
171 typedef int SW_OSHANDLE;
172 #define SW_OS_INVALID_HANDLE (-1)
173 #define SW_CALLCONV
174#else /* Unix variants */
175 typedef int SW_OSHANDLE; /* handle to driver */
176 #define SW_OS_INVALID_HANDLE (-1)
177 #define SW_CALLCONV
178#endif
179
180typedef struct _SW_CRT {
181 SW_LARGENUMBER p; /* prime number p */
182 SW_LARGENUMBER q; /* prime number q */
183 SW_LARGENUMBER dmp1; /* exponent1 */
184 SW_LARGENUMBER dmq1; /* exponent2 */
185 SW_LARGENUMBER iqmp; /* CRT coefficient */
186} SW_CRT;
187
188typedef struct _SW_EXP {
189 SW_LARGENUMBER modulus; /* modulus */
190 SW_LARGENUMBER exponent;/* exponent */
191} SW_EXP;
192
193typedef struct _SW_DSA {
194 SW_LARGENUMBER p; /* */
195 SW_LARGENUMBER q; /* */
196 SW_LARGENUMBER g; /* */
197 SW_LARGENUMBER key; /* private/public key */
198} SW_DSA;
199
200typedef struct _SW_NVDATA {
201 SW_U32 accnum; /* accelerator board number */
202 SW_U32 offset; /* offset in byte */
203} SW_NVDATA;
204
205typedef struct _SW_PARAM {
206 SW_ALGTYPE type; /* type of the alogrithm */
207 union {
208 SW_CRT crt;
209 SW_EXP exp;
210 SW_DSA dsa;
211 SW_NVDATA nvdata;
212 } up;
213} SW_PARAM;
214
215typedef SW_U32 SW_CONTEXT_HANDLE; /* opaque context handle */
216
217
218/* Now the OpenSSL bits, these function types are the for the function
219 * pointers that will bound into the Rainbow shared libraries. */
220typedef SW_STATUS SW_CALLCONV t_swAcquireAccContext(SW_CONTEXT_HANDLE *hac);
221typedef SW_STATUS SW_CALLCONV t_swAttachKeyParam(SW_CONTEXT_HANDLE hac,
222 SW_PARAM *key_params);
223typedef SW_STATUS SW_CALLCONV t_swSimpleRequest(SW_CONTEXT_HANDLE hac,
224 SW_COMMAND_CODE cmd,
225 SW_LARGENUMBER pin[],
226 SW_U32 pin_count,
227 SW_LARGENUMBER pout[],
228 SW_U32 pout_count);
229typedef SW_STATUS SW_CALLCONV t_swReleaseAccContext(SW_CONTEXT_HANDLE hac);
230
231#ifdef __cplusplus
232}
233#endif /* __cplusplus */
234
diff --git a/src/lib/libcrypto/engine/vendor_defns/hw_4758_cca.h b/src/lib/libcrypto/engine/vendor_defns/hw_4758_cca.h
deleted file mode 100644
index 296636e81a..0000000000
--- a/src/lib/libcrypto/engine/vendor_defns/hw_4758_cca.h
+++ /dev/null
@@ -1,149 +0,0 @@
1/**********************************************************************/
2/* */
3/* Prototypes of the CCA verbs used by the 4758 CCA openssl driver */
4/* */
5/* Maurice Gittens <maurice@gittens.nl> */
6/* */
7/**********************************************************************/
8
9#ifndef __HW_4758_CCA__
10#define __HW_4758_CCA__
11
12/*
13 * Only WIN32 support for now
14 */
15#if defined(WIN32)
16
17 #define CCA_LIB_NAME "CSUNSAPI"
18
19 #define CSNDPKX "CSNDPKX_32"
20 #define CSNDKRR "CSNDKRR_32"
21 #define CSNDPKE "CSNDPKE_32"
22 #define CSNDPKD "CSNDPKD_32"
23 #define CSNDDSV "CSNDDSV_32"
24 #define CSNDDSG "CSNDDSG_32"
25 #define CSNBRNG "CSNBRNG_32"
26
27 #define SECURITYAPI __stdcall
28#else
29 /* Fixme!!
30 Find out the values of these constants for other platforms.
31 */
32 #define CCA_LIB_NAME "CSUNSAPI"
33
34 #define CSNDPKX "CSNDPKX"
35 #define CSNDKRR "CSNDKRR"
36 #define CSNDPKE "CSNDPKE"
37 #define CSNDPKD "CSNDPKD"
38 #define CSNDDSV "CSNDDSV"
39 #define CSNDDSG "CSNDDSG"
40 #define CSNBRNG "CSNBRNG"
41
42 #define SECURITYAPI
43#endif
44
45/*
46 * security API prototypes
47 */
48
49/* PKA Key Record Read */
50typedef void (SECURITYAPI *F_KEYRECORDREAD)
51 (long * return_code,
52 long * reason_code,
53 long * exit_data_length,
54 unsigned char * exit_data,
55 long * rule_array_count,
56 unsigned char * rule_array,
57 unsigned char * key_label,
58 long * key_token_length,
59 unsigned char * key_token);
60
61/* Random Number Generate */
62typedef void (SECURITYAPI *F_RANDOMNUMBERGENERATE)
63 (long * return_code,
64 long * reason_code,
65 long * exit_data_length,
66 unsigned char * exit_data,
67 unsigned char * form,
68 unsigned char * random_number);
69
70/* Digital Signature Generate */
71typedef void (SECURITYAPI *F_DIGITALSIGNATUREGENERATE)
72 (long * return_code,
73 long * reason_code,
74 long * exit_data_length,
75 unsigned char * exit_data,
76 long * rule_array_count,
77 unsigned char * rule_array,
78 long * PKA_private_key_id_length,
79 unsigned char * PKA_private_key_id,
80 long * hash_length,
81 unsigned char * hash,
82 long * signature_field_length,
83 long * signature_bit_length,
84 unsigned char * signature_field);
85
86/* Digital Signature Verify */
87typedef void (SECURITYAPI *F_DIGITALSIGNATUREVERIFY)(
88 long * return_code,
89 long * reason_code,
90 long * exit_data_length,
91 unsigned char * exit_data,
92 long * rule_array_count,
93 unsigned char * rule_array,
94 long * PKA_public_key_id_length,
95 unsigned char * PKA_public_key_id,
96 long * hash_length,
97 unsigned char * hash,
98 long * signature_field_length,
99 unsigned char * signature_field);
100
101/* PKA Public Key Extract */
102typedef void (SECURITYAPI *F_PUBLICKEYEXTRACT)(
103 long * return_code,
104 long * reason_code,
105 long * exit_data_length,
106 unsigned char * exit_data,
107 long * rule_array_count,
108 unsigned char * rule_array,
109 long * source_key_identifier_length,
110 unsigned char * source_key_identifier,
111 long * target_key_token_length,
112 unsigned char * target_key_token);
113
114/* PKA Encrypt */
115typedef void (SECURITYAPI *F_PKAENCRYPT)
116 (long * return_code,
117 long * reason_code,
118 long * exit_data_length,
119 unsigned char * exit_data,
120 long * rule_array_count,
121 unsigned char * rule_array,
122 long * key_value_length,
123 unsigned char * key_value,
124 long * data_struct_length,
125 unsigned char * data_struct,
126 long * RSA_public_key_length,
127 unsigned char * RSA_public_key,
128 long * RSA_encipher_length,
129 unsigned char * RSA_encipher );
130
131/* PKA Decrypt */
132typedef void (SECURITYAPI *F_PKADECRYPT)
133 (long * return_code,
134 long * reason_code,
135 long * exit_data_length,
136 unsigned char * exit_data,
137 long * rule_array_count,
138 unsigned char * rule_array,
139 long * enciphered_key_length,
140 unsigned char * enciphered_key,
141 long * data_struct_length,
142 unsigned char * data_struct,
143 long * RSA_private_key_length,
144 unsigned char * RSA_private_key,
145 long * key_value_length,
146 unsigned char * key_value );
147
148
149#endif
diff --git a/src/lib/libcrypto/engine/vendor_defns/hw_ubsec.h b/src/lib/libcrypto/engine/vendor_defns/hw_ubsec.h
deleted file mode 100644
index b6619d40f2..0000000000
--- a/src/lib/libcrypto/engine/vendor_defns/hw_ubsec.h
+++ /dev/null
@@ -1,100 +0,0 @@
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/libcrypto/engine/vendor_defns/hwcryptohook.h b/src/lib/libcrypto/engine/vendor_defns/hwcryptohook.h
deleted file mode 100644
index aaa4d4575e..0000000000
--- a/src/lib/libcrypto/engine/vendor_defns/hwcryptohook.h
+++ /dev/null
@@ -1,486 +0,0 @@
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/libcrypto/engine/vendor_defns/sureware.h b/src/lib/libcrypto/engine/vendor_defns/sureware.h
deleted file mode 100644
index 4bc22027f9..0000000000
--- a/src/lib/libcrypto/engine/vendor_defns/sureware.h
+++ /dev/null
@@ -1,239 +0,0 @@
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 *exponent,
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/libcrypto/err/Makefile.ssl b/src/lib/libcrypto/err/Makefile.ssl
deleted file mode 100644
index b253061d07..0000000000
--- a/src/lib/libcrypto/err/Makefile.ssl
+++ /dev/null
@@ -1,119 +0,0 @@
1#
2# SSLeay/crypto/err/Makefile
3#
4
5DIR= err
6TOP= ../..
7CC= cc
8INCLUDES= -I.. -I$(TOP) -I../../include
9CFLAG=-g
10INSTALL_PREFIX=
11OPENSSLDIR= /usr/local/ssl
12INSTALLTOP=/usr/local/ssl
13MAKE= make -f Makefile.ssl
14MAKEDEPPROG= makedepend
15MAKEDEPEND= $(TOP)/util/domd $(TOP) -MD $(MAKEDEPPROG)
16MAKEFILE= Makefile.ssl
17AR= ar r
18
19CFLAGS= $(INCLUDES) $(CFLAG)
20
21GENERAL=Makefile
22TEST=
23APPS=
24
25LIB=$(TOP)/libcrypto.a
26LIBSRC=err.c err_all.c err_prn.c
27LIBOBJ=err.o err_all.o err_prn.o
28
29SRC= $(LIBSRC)
30
31EXHEADER= err.h
32HEADER= $(EXHEADER)
33
34ALL= $(GENERAL) $(SRC) $(HEADER)
35
36top:
37 (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all)
38
39all: lib
40
41lib: $(LIBOBJ)
42 $(AR) $(LIB) $(LIBOBJ)
43 $(RANLIB) $(LIB) || echo Never mind.
44 @touch lib
45
46files:
47 $(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO
48
49links:
50 @sh $(TOP)/util/point.sh Makefile.ssl Makefile
51 @$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER)
52 @$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST)
53 @$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS)
54
55install:
56 @for i in $(EXHEADER) ; \
57 do \
58 (cp $$i $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i; \
59 chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i ); \
60 done;
61
62tags:
63 ctags $(SRC)
64
65tests:
66
67lint:
68 lint -DLINT $(INCLUDES) $(SRC)>fluff
69
70depend:
71 $(MAKEDEPEND) -- $(CFLAG) $(INCLUDES) $(DEPFLAG) -- $(PROGS) $(LIBSRC)
72
73dclean:
74 $(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
75 mv -f Makefile.new $(MAKEFILE)
76
77clean:
78 rm -f *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff
79
80# DO NOT DELETE THIS LINE -- make depend depends on it.
81
82err.o: ../../e_os.h ../../include/openssl/bio.h ../../include/openssl/buffer.h
83err.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
84err.o: ../../include/openssl/err.h ../../include/openssl/lhash.h
85err.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
86err.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
87err.o: ../../include/openssl/symhacks.h ../cryptlib.h err.c
88err_all.o: ../../include/openssl/aes.h ../../include/openssl/asn1.h
89err_all.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h
90err_all.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
91err_all.o: ../../include/openssl/cast.h ../../include/openssl/conf.h
92err_all.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
93err_all.o: ../../include/openssl/des_old.h ../../include/openssl/dh.h
94err_all.o: ../../include/openssl/dsa.h ../../include/openssl/dso.h
95err_all.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h
96err_all.o: ../../include/openssl/engine.h ../../include/openssl/err.h
97err_all.o: ../../include/openssl/evp.h ../../include/openssl/idea.h
98err_all.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h
99err_all.o: ../../include/openssl/md4.h ../../include/openssl/md5.h
100err_all.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h
101err_all.o: ../../include/openssl/objects.h ../../include/openssl/ocsp.h
102err_all.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
103err_all.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pem2.h
104err_all.o: ../../include/openssl/pkcs12.h ../../include/openssl/pkcs7.h
105err_all.o: ../../include/openssl/rand.h ../../include/openssl/rc2.h
106err_all.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
107err_all.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
108err_all.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
109err_all.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
110err_all.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
111err_all.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
112err_all.o: ../../include/openssl/x509v3.h err_all.c
113err_prn.o: ../../e_os.h ../../include/openssl/bio.h
114err_prn.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
115err_prn.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
116err_prn.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
117err_prn.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
118err_prn.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
119err_prn.o: ../cryptlib.h err_prn.c
diff --git a/src/lib/libcrypto/err/err.c b/src/lib/libcrypto/err/err.c
index 292404a2fb..69713a6e2f 100644
--- a/src/lib/libcrypto/err/err.c
+++ b/src/lib/libcrypto/err/err.c
@@ -56,7 +56,7 @@
56 * [including the GNU Public Licence.] 56 * [including the GNU Public Licence.]
57 */ 57 */
58/* ==================================================================== 58/* ====================================================================
59 * Copyright (c) 1998-2001 The OpenSSL Project. All rights reserved. 59 * Copyright (c) 1998-2006 The OpenSSL Project. All rights reserved.
60 * 60 *
61 * Redistribution and use in source and binary forms, with or without 61 * Redistribution and use in source and binary forms, with or without
62 * modification, are permitted provided that the following conditions 62 * modification, are permitted provided that the following conditions
@@ -119,9 +119,507 @@
119#include <openssl/bio.h> 119#include <openssl/bio.h>
120#include <openssl/err.h> 120#include <openssl/err.h>
121 121
122static unsigned long get_error_values(int inc,int top, 122DECLARE_LHASH_OF(ERR_STRING_DATA);
123 const char **file,int *line, 123DECLARE_LHASH_OF(ERR_STATE);
124 const char **data,int *flags); 124
125static void err_load_strings(int lib, ERR_STRING_DATA *str);
126
127static void ERR_STATE_free(ERR_STATE *s);
128#ifndef OPENSSL_NO_ERR
129static ERR_STRING_DATA ERR_str_libraries[]=
130 {
131{ERR_PACK(ERR_LIB_NONE,0,0) ,"unknown library"},
132{ERR_PACK(ERR_LIB_SYS,0,0) ,"system library"},
133{ERR_PACK(ERR_LIB_BN,0,0) ,"bignum routines"},
134{ERR_PACK(ERR_LIB_RSA,0,0) ,"rsa routines"},
135{ERR_PACK(ERR_LIB_DH,0,0) ,"Diffie-Hellman routines"},
136{ERR_PACK(ERR_LIB_EVP,0,0) ,"digital envelope routines"},
137{ERR_PACK(ERR_LIB_BUF,0,0) ,"memory buffer routines"},
138{ERR_PACK(ERR_LIB_OBJ,0,0) ,"object identifier routines"},
139{ERR_PACK(ERR_LIB_PEM,0,0) ,"PEM routines"},
140{ERR_PACK(ERR_LIB_DSA,0,0) ,"dsa routines"},
141{ERR_PACK(ERR_LIB_X509,0,0) ,"x509 certificate routines"},
142{ERR_PACK(ERR_LIB_ASN1,0,0) ,"asn1 encoding routines"},
143{ERR_PACK(ERR_LIB_CONF,0,0) ,"configuration file routines"},
144{ERR_PACK(ERR_LIB_CRYPTO,0,0) ,"common libcrypto routines"},
145{ERR_PACK(ERR_LIB_EC,0,0) ,"elliptic curve routines"},
146{ERR_PACK(ERR_LIB_SSL,0,0) ,"SSL routines"},
147{ERR_PACK(ERR_LIB_BIO,0,0) ,"BIO routines"},
148{ERR_PACK(ERR_LIB_PKCS7,0,0) ,"PKCS7 routines"},
149{ERR_PACK(ERR_LIB_X509V3,0,0) ,"X509 V3 routines"},
150{ERR_PACK(ERR_LIB_PKCS12,0,0) ,"PKCS12 routines"},
151{ERR_PACK(ERR_LIB_RAND,0,0) ,"random number generator"},
152{ERR_PACK(ERR_LIB_DSO,0,0) ,"DSO support routines"},
153{ERR_PACK(ERR_LIB_TS,0,0) ,"time stamp routines"},
154{ERR_PACK(ERR_LIB_ENGINE,0,0) ,"engine routines"},
155{ERR_PACK(ERR_LIB_OCSP,0,0) ,"OCSP routines"},
156{ERR_PACK(ERR_LIB_FIPS,0,0) ,"FIPS routines"},
157{ERR_PACK(ERR_LIB_CMS,0,0) ,"CMS routines"},
158{ERR_PACK(ERR_LIB_HMAC,0,0) ,"HMAC routines"},
159{0,NULL},
160 };
161
162static ERR_STRING_DATA ERR_str_functs[]=
163 {
164 {ERR_PACK(0,SYS_F_FOPEN,0), "fopen"},
165 {ERR_PACK(0,SYS_F_CONNECT,0), "connect"},
166 {ERR_PACK(0,SYS_F_GETSERVBYNAME,0), "getservbyname"},
167 {ERR_PACK(0,SYS_F_SOCKET,0), "socket"},
168 {ERR_PACK(0,SYS_F_IOCTLSOCKET,0), "ioctlsocket"},
169 {ERR_PACK(0,SYS_F_BIND,0), "bind"},
170 {ERR_PACK(0,SYS_F_LISTEN,0), "listen"},
171 {ERR_PACK(0,SYS_F_ACCEPT,0), "accept"},
172#ifdef OPENSSL_SYS_WINDOWS
173 {ERR_PACK(0,SYS_F_WSASTARTUP,0), "WSAstartup"},
174#endif
175 {ERR_PACK(0,SYS_F_OPENDIR,0), "opendir"},
176 {ERR_PACK(0,SYS_F_FREAD,0), "fread"},
177 {0,NULL},
178 };
179
180static ERR_STRING_DATA ERR_str_reasons[]=
181 {
182{ERR_R_SYS_LIB ,"system lib"},
183{ERR_R_BN_LIB ,"BN lib"},
184{ERR_R_RSA_LIB ,"RSA lib"},
185{ERR_R_DH_LIB ,"DH lib"},
186{ERR_R_EVP_LIB ,"EVP lib"},
187{ERR_R_BUF_LIB ,"BUF lib"},
188{ERR_R_OBJ_LIB ,"OBJ lib"},
189{ERR_R_PEM_LIB ,"PEM lib"},
190{ERR_R_DSA_LIB ,"DSA lib"},
191{ERR_R_X509_LIB ,"X509 lib"},
192{ERR_R_ASN1_LIB ,"ASN1 lib"},
193{ERR_R_CONF_LIB ,"CONF lib"},
194{ERR_R_CRYPTO_LIB ,"CRYPTO lib"},
195{ERR_R_EC_LIB ,"EC lib"},
196{ERR_R_SSL_LIB ,"SSL lib"},
197{ERR_R_BIO_LIB ,"BIO lib"},
198{ERR_R_PKCS7_LIB ,"PKCS7 lib"},
199{ERR_R_X509V3_LIB ,"X509V3 lib"},
200{ERR_R_PKCS12_LIB ,"PKCS12 lib"},
201{ERR_R_RAND_LIB ,"RAND lib"},
202{ERR_R_DSO_LIB ,"DSO lib"},
203{ERR_R_ENGINE_LIB ,"ENGINE lib"},
204{ERR_R_OCSP_LIB ,"OCSP lib"},
205{ERR_R_TS_LIB ,"TS lib"},
206
207{ERR_R_NESTED_ASN1_ERROR ,"nested asn1 error"},
208{ERR_R_BAD_ASN1_OBJECT_HEADER ,"bad asn1 object header"},
209{ERR_R_BAD_GET_ASN1_OBJECT_CALL ,"bad get asn1 object call"},
210{ERR_R_EXPECTING_AN_ASN1_SEQUENCE ,"expecting an asn1 sequence"},
211{ERR_R_ASN1_LENGTH_MISMATCH ,"asn1 length mismatch"},
212{ERR_R_MISSING_ASN1_EOS ,"missing asn1 eos"},
213
214{ERR_R_FATAL ,"fatal"},
215{ERR_R_MALLOC_FAILURE ,"malloc failure"},
216{ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED ,"called a function you should not call"},
217{ERR_R_PASSED_NULL_PARAMETER ,"passed a null parameter"},
218{ERR_R_INTERNAL_ERROR ,"internal error"},
219{ERR_R_DISABLED ,"called a function that was disabled at compile-time"},
220
221{0,NULL},
222 };
223#endif
224
225
226/* Define the predeclared (but externally opaque) "ERR_FNS" type */
227struct st_ERR_FNS
228 {
229 /* Works on the "error_hash" string table */
230 LHASH_OF(ERR_STRING_DATA) *(*cb_err_get)(int create);
231 void (*cb_err_del)(void);
232 ERR_STRING_DATA *(*cb_err_get_item)(const ERR_STRING_DATA *);
233 ERR_STRING_DATA *(*cb_err_set_item)(ERR_STRING_DATA *);
234 ERR_STRING_DATA *(*cb_err_del_item)(ERR_STRING_DATA *);
235 /* Works on the "thread_hash" error-state table */
236 LHASH_OF(ERR_STATE) *(*cb_thread_get)(int create);
237 void (*cb_thread_release)(LHASH_OF(ERR_STATE) **hash);
238 ERR_STATE *(*cb_thread_get_item)(const ERR_STATE *);
239 ERR_STATE *(*cb_thread_set_item)(ERR_STATE *);
240 void (*cb_thread_del_item)(const ERR_STATE *);
241 /* Returns the next available error "library" numbers */
242 int (*cb_get_next_lib)(void);
243 };
244
245/* Predeclarations of the "err_defaults" functions */
246static LHASH_OF(ERR_STRING_DATA) *int_err_get(int create);
247static void int_err_del(void);
248static ERR_STRING_DATA *int_err_get_item(const ERR_STRING_DATA *);
249static ERR_STRING_DATA *int_err_set_item(ERR_STRING_DATA *);
250static ERR_STRING_DATA *int_err_del_item(ERR_STRING_DATA *);
251static LHASH_OF(ERR_STATE) *int_thread_get(int create);
252static void int_thread_release(LHASH_OF(ERR_STATE) **hash);
253static ERR_STATE *int_thread_get_item(const ERR_STATE *);
254static ERR_STATE *int_thread_set_item(ERR_STATE *);
255static void int_thread_del_item(const ERR_STATE *);
256static int int_err_get_next_lib(void);
257/* The static ERR_FNS table using these defaults functions */
258static const ERR_FNS err_defaults =
259 {
260 int_err_get,
261 int_err_del,
262 int_err_get_item,
263 int_err_set_item,
264 int_err_del_item,
265 int_thread_get,
266 int_thread_release,
267 int_thread_get_item,
268 int_thread_set_item,
269 int_thread_del_item,
270 int_err_get_next_lib
271 };
272
273/* The replacable table of ERR_FNS functions we use at run-time */
274static const ERR_FNS *err_fns = NULL;
275
276/* Eg. rather than using "err_get()", use "ERRFN(err_get)()". */
277#define ERRFN(a) err_fns->cb_##a
278
279/* The internal state used by "err_defaults" - as such, the setting, reading,
280 * creating, and deleting of this data should only be permitted via the
281 * "err_defaults" functions. This way, a linked module can completely defer all
282 * ERR state operation (together with requisite locking) to the implementations
283 * and state in the loading application. */
284static LHASH_OF(ERR_STRING_DATA) *int_error_hash = NULL;
285static LHASH_OF(ERR_STATE) *int_thread_hash = NULL;
286static int int_thread_hash_references = 0;
287static int int_err_library_number= ERR_LIB_USER;
288
289/* Internal function that checks whether "err_fns" is set and if not, sets it to
290 * the defaults. */
291static void err_fns_check(void)
292 {
293 if (err_fns) return;
294
295 CRYPTO_w_lock(CRYPTO_LOCK_ERR);
296 if (!err_fns)
297 err_fns = &err_defaults;
298 CRYPTO_w_unlock(CRYPTO_LOCK_ERR);
299 }
300
301/* API functions to get or set the underlying ERR functions. */
302
303const ERR_FNS *ERR_get_implementation(void)
304 {
305 err_fns_check();
306 return err_fns;
307 }
308
309int ERR_set_implementation(const ERR_FNS *fns)
310 {
311 int ret = 0;
312
313 CRYPTO_w_lock(CRYPTO_LOCK_ERR);
314 /* It's too late if 'err_fns' is non-NULL. BTW: not much point setting
315 * an error is there?! */
316 if (!err_fns)
317 {
318 err_fns = fns;
319 ret = 1;
320 }
321 CRYPTO_w_unlock(CRYPTO_LOCK_ERR);
322 return ret;
323 }
324
325/* These are the callbacks provided to "lh_new()" when creating the LHASH tables
326 * internal to the "err_defaults" implementation. */
327
328static unsigned long get_error_values(int inc,int top,const char **file,int *line,
329 const char **data,int *flags);
330
331/* The internal functions used in the "err_defaults" implementation */
332
333static unsigned long err_string_data_hash(const ERR_STRING_DATA *a)
334 {
335 unsigned long ret,l;
336
337 l=a->error;
338 ret=l^ERR_GET_LIB(l)^ERR_GET_FUNC(l);
339 return(ret^ret%19*13);
340 }
341static IMPLEMENT_LHASH_HASH_FN(err_string_data, ERR_STRING_DATA)
342
343static int err_string_data_cmp(const ERR_STRING_DATA *a,
344 const ERR_STRING_DATA *b)
345 {
346 return (int)(a->error - b->error);
347 }
348static IMPLEMENT_LHASH_COMP_FN(err_string_data, ERR_STRING_DATA)
349
350static LHASH_OF(ERR_STRING_DATA) *int_err_get(int create)
351 {
352 LHASH_OF(ERR_STRING_DATA) *ret = NULL;
353
354 CRYPTO_w_lock(CRYPTO_LOCK_ERR);
355 if (!int_error_hash && create)
356 {
357 CRYPTO_push_info("int_err_get (err.c)");
358 int_error_hash = lh_ERR_STRING_DATA_new();
359 CRYPTO_pop_info();
360 }
361 if (int_error_hash)
362 ret = int_error_hash;
363 CRYPTO_w_unlock(CRYPTO_LOCK_ERR);
364
365 return ret;
366 }
367
368static void int_err_del(void)
369 {
370 CRYPTO_w_lock(CRYPTO_LOCK_ERR);
371 if (int_error_hash)
372 {
373 lh_ERR_STRING_DATA_free(int_error_hash);
374 int_error_hash = NULL;
375 }
376 CRYPTO_w_unlock(CRYPTO_LOCK_ERR);
377 }
378
379static ERR_STRING_DATA *int_err_get_item(const ERR_STRING_DATA *d)
380 {
381 ERR_STRING_DATA *p;
382 LHASH_OF(ERR_STRING_DATA) *hash;
383
384 err_fns_check();
385 hash = ERRFN(err_get)(0);
386 if (!hash)
387 return NULL;
388
389 CRYPTO_r_lock(CRYPTO_LOCK_ERR);
390 p = lh_ERR_STRING_DATA_retrieve(hash, d);
391 CRYPTO_r_unlock(CRYPTO_LOCK_ERR);
392
393 return p;
394 }
395
396static ERR_STRING_DATA *int_err_set_item(ERR_STRING_DATA *d)
397 {
398 ERR_STRING_DATA *p;
399 LHASH_OF(ERR_STRING_DATA) *hash;
400
401 err_fns_check();
402 hash = ERRFN(err_get)(1);
403 if (!hash)
404 return NULL;
405
406 CRYPTO_w_lock(CRYPTO_LOCK_ERR);
407 p = lh_ERR_STRING_DATA_insert(hash, d);
408 CRYPTO_w_unlock(CRYPTO_LOCK_ERR);
409
410 return p;
411 }
412
413static ERR_STRING_DATA *int_err_del_item(ERR_STRING_DATA *d)
414 {
415 ERR_STRING_DATA *p;
416 LHASH_OF(ERR_STRING_DATA) *hash;
417
418 err_fns_check();
419 hash = ERRFN(err_get)(0);
420 if (!hash)
421 return NULL;
422
423 CRYPTO_w_lock(CRYPTO_LOCK_ERR);
424 p = lh_ERR_STRING_DATA_delete(hash, d);
425 CRYPTO_w_unlock(CRYPTO_LOCK_ERR);
426
427 return p;
428 }
429
430static unsigned long err_state_hash(const ERR_STATE *a)
431 {
432 return CRYPTO_THREADID_hash(&a->tid) * 13;
433 }
434static IMPLEMENT_LHASH_HASH_FN(err_state, ERR_STATE)
435
436static int err_state_cmp(const ERR_STATE *a, const ERR_STATE *b)
437 {
438 return CRYPTO_THREADID_cmp(&a->tid, &b->tid);
439 }
440static IMPLEMENT_LHASH_COMP_FN(err_state, ERR_STATE)
441
442static LHASH_OF(ERR_STATE) *int_thread_get(int create)
443 {
444 LHASH_OF(ERR_STATE) *ret = NULL;
445
446 CRYPTO_w_lock(CRYPTO_LOCK_ERR);
447 if (!int_thread_hash && create)
448 {
449 CRYPTO_push_info("int_thread_get (err.c)");
450 int_thread_hash = lh_ERR_STATE_new();
451 CRYPTO_pop_info();
452 }
453 if (int_thread_hash)
454 {
455 int_thread_hash_references++;
456 ret = int_thread_hash;
457 }
458 CRYPTO_w_unlock(CRYPTO_LOCK_ERR);
459 return ret;
460 }
461
462static void int_thread_release(LHASH_OF(ERR_STATE) **hash)
463 {
464 int i;
465
466 if (hash == NULL || *hash == NULL)
467 return;
468
469 i = CRYPTO_add(&int_thread_hash_references, -1, CRYPTO_LOCK_ERR);
470
471#ifdef REF_PRINT
472 fprintf(stderr,"%4d:%s\n",int_thread_hash_references,"ERR");
473#endif
474 if (i > 0) return;
475#ifdef REF_CHECK
476 if (i < 0)
477 {
478 fprintf(stderr,"int_thread_release, bad reference count\n");
479 abort(); /* ok */
480 }
481#endif
482 *hash = NULL;
483 }
484
485static ERR_STATE *int_thread_get_item(const ERR_STATE *d)
486 {
487 ERR_STATE *p;
488 LHASH_OF(ERR_STATE) *hash;
489
490 err_fns_check();
491 hash = ERRFN(thread_get)(0);
492 if (!hash)
493 return NULL;
494
495 CRYPTO_r_lock(CRYPTO_LOCK_ERR);
496 p = lh_ERR_STATE_retrieve(hash, d);
497 CRYPTO_r_unlock(CRYPTO_LOCK_ERR);
498
499 ERRFN(thread_release)(&hash);
500 return p;
501 }
502
503static ERR_STATE *int_thread_set_item(ERR_STATE *d)
504 {
505 ERR_STATE *p;
506 LHASH_OF(ERR_STATE) *hash;
507
508 err_fns_check();
509 hash = ERRFN(thread_get)(1);
510 if (!hash)
511 return NULL;
512
513 CRYPTO_w_lock(CRYPTO_LOCK_ERR);
514 p = lh_ERR_STATE_insert(hash, d);
515 CRYPTO_w_unlock(CRYPTO_LOCK_ERR);
516
517 ERRFN(thread_release)(&hash);
518 return p;
519 }
520
521static void int_thread_del_item(const ERR_STATE *d)
522 {
523 ERR_STATE *p;
524 LHASH_OF(ERR_STATE) *hash;
525
526 err_fns_check();
527 hash = ERRFN(thread_get)(0);
528 if (!hash)
529 return;
530
531 CRYPTO_w_lock(CRYPTO_LOCK_ERR);
532 p = lh_ERR_STATE_delete(hash, d);
533 /* make sure we don't leak memory */
534 if (int_thread_hash_references == 1
535 && int_thread_hash && lh_ERR_STATE_num_items(int_thread_hash) == 0)
536 {
537 lh_ERR_STATE_free(int_thread_hash);
538 int_thread_hash = NULL;
539 }
540 CRYPTO_w_unlock(CRYPTO_LOCK_ERR);
541
542 ERRFN(thread_release)(&hash);
543 if (p)
544 ERR_STATE_free(p);
545 }
546
547static int int_err_get_next_lib(void)
548 {
549 int ret;
550
551 CRYPTO_w_lock(CRYPTO_LOCK_ERR);
552 ret = int_err_library_number++;
553 CRYPTO_w_unlock(CRYPTO_LOCK_ERR);
554
555 return ret;
556 }
557
558
559#ifndef OPENSSL_NO_ERR
560#define NUM_SYS_STR_REASONS 127
561#define LEN_SYS_STR_REASON 32
562
563static ERR_STRING_DATA SYS_str_reasons[NUM_SYS_STR_REASONS + 1];
564/* SYS_str_reasons is filled with copies of strerror() results at
565 * initialization.
566 * 'errno' values up to 127 should cover all usual errors,
567 * others will be displayed numerically by ERR_error_string.
568 * It is crucial that we have something for each reason code
569 * that occurs in ERR_str_reasons, or bogus reason strings
570 * will be returned for SYSerr(), which always gets an errno
571 * value and never one of those 'standard' reason codes. */
572
573static void build_SYS_str_reasons(void)
574 {
575 /* OPENSSL_malloc cannot be used here, use static storage instead */
576 static char strerror_tab[NUM_SYS_STR_REASONS][LEN_SYS_STR_REASON];
577 int i;
578 static int init = 1;
579
580 CRYPTO_r_lock(CRYPTO_LOCK_ERR);
581 if (!init)
582 {
583 CRYPTO_r_unlock(CRYPTO_LOCK_ERR);
584 return;
585 }
586
587 CRYPTO_r_unlock(CRYPTO_LOCK_ERR);
588 CRYPTO_w_lock(CRYPTO_LOCK_ERR);
589 if (!init)
590 {
591 CRYPTO_w_unlock(CRYPTO_LOCK_ERR);
592 return;
593 }
594
595 for (i = 1; i <= NUM_SYS_STR_REASONS; i++)
596 {
597 ERR_STRING_DATA *str = &SYS_str_reasons[i - 1];
598
599 str->error = (unsigned long)i;
600 if (str->string == NULL)
601 {
602 char (*dest)[LEN_SYS_STR_REASON] = &(strerror_tab[i - 1]);
603 char *src = strerror(i);
604 if (src != NULL)
605 {
606 strncpy(*dest, src, sizeof *dest);
607 (*dest)[sizeof *dest - 1] = '\0';
608 str->string = *dest;
609 }
610 }
611 if (str->string == NULL)
612 str->string = "unknown";
613 }
614
615 /* Now we still have SYS_str_reasons[NUM_SYS_STR_REASONS] = {0, NULL},
616 * as required by ERR_load_strings. */
617
618 init = 0;
619
620 CRYPTO_w_unlock(CRYPTO_LOCK_ERR);
621 }
622#endif
125 623
126#define err_clear_data(p,i) \ 624#define err_clear_data(p,i) \
127 do { \ 625 do { \
@@ -143,6 +641,68 @@ static unsigned long get_error_values(int inc,int top,
143 (p)->err_line[i]= -1; \ 641 (p)->err_line[i]= -1; \
144 } while(0) 642 } while(0)
145 643
644static void ERR_STATE_free(ERR_STATE *s)
645 {
646 int i;
647
648 if (s == NULL)
649 return;
650
651 for (i=0; i<ERR_NUM_ERRORS; i++)
652 {
653 err_clear_data(s,i);
654 }
655 OPENSSL_free(s);
656 }
657
658void ERR_load_ERR_strings(void)
659 {
660 err_fns_check();
661#ifndef OPENSSL_NO_ERR
662 err_load_strings(0,ERR_str_libraries);
663 err_load_strings(0,ERR_str_reasons);
664 err_load_strings(ERR_LIB_SYS,ERR_str_functs);
665 build_SYS_str_reasons();
666 err_load_strings(ERR_LIB_SYS,SYS_str_reasons);
667#endif
668 }
669
670static void err_load_strings(int lib, ERR_STRING_DATA *str)
671 {
672 while (str->error)
673 {
674 if (lib)
675 str->error|=ERR_PACK(lib,0,0);
676 ERRFN(err_set_item)(str);
677 str++;
678 }
679 }
680
681void ERR_load_strings(int lib, ERR_STRING_DATA *str)
682 {
683 ERR_load_ERR_strings();
684 err_load_strings(lib, str);
685 }
686
687void ERR_unload_strings(int lib, ERR_STRING_DATA *str)
688 {
689 while (str->error)
690 {
691 if (lib)
692 str->error|=ERR_PACK(lib,0,0);
693 ERRFN(err_del_item)(str);
694 str++;
695 }
696 }
697
698void ERR_free_strings(void)
699 {
700 err_fns_check();
701 ERRFN(err_del)();
702 }
703
704/********************************************************/
705
146void ERR_put_error(int lib, int func, int reason, const char *file, 706void ERR_put_error(int lib, int func, int reason, const char *file,
147 int line) 707 int line)
148 { 708 {
@@ -297,6 +857,196 @@ static unsigned long get_error_values(int inc, int top, const char **file, int *
297 return ret; 857 return ret;
298 } 858 }
299 859
860void ERR_error_string_n(unsigned long e, char *buf, size_t len)
861 {
862 char lsbuf[64], fsbuf[64], rsbuf[64];
863 const char *ls,*fs,*rs;
864 unsigned long l,f,r;
865
866 l=ERR_GET_LIB(e);
867 f=ERR_GET_FUNC(e);
868 r=ERR_GET_REASON(e);
869
870 ls=ERR_lib_error_string(e);
871 fs=ERR_func_error_string(e);
872 rs=ERR_reason_error_string(e);
873
874 if (ls == NULL)
875 BIO_snprintf(lsbuf, sizeof(lsbuf), "lib(%lu)", l);
876 if (fs == NULL)
877 BIO_snprintf(fsbuf, sizeof(fsbuf), "func(%lu)", f);
878 if (rs == NULL)
879 BIO_snprintf(rsbuf, sizeof(rsbuf), "reason(%lu)", r);
880
881 BIO_snprintf(buf, len,"error:%08lX:%s:%s:%s", e, ls?ls:lsbuf,
882 fs?fs:fsbuf, rs?rs:rsbuf);
883 if (strlen(buf) == len-1)
884 {
885 /* output may be truncated; make sure we always have 5
886 * colon-separated fields, i.e. 4 colons ... */
887#define NUM_COLONS 4
888 if (len > NUM_COLONS) /* ... if possible */
889 {
890 int i;
891 char *s = buf;
892
893 for (i = 0; i < NUM_COLONS; i++)
894 {
895 char *colon = strchr(s, ':');
896 if (colon == NULL || colon > &buf[len-1] - NUM_COLONS + i)
897 {
898 /* set colon no. i at last possible position
899 * (buf[len-1] is the terminating 0)*/
900 colon = &buf[len-1] - NUM_COLONS + i;
901 *colon = ':';
902 }
903 s = colon + 1;
904 }
905 }
906 }
907 }
908
909/* BAD for multi-threading: uses a local buffer if ret == NULL */
910/* ERR_error_string_n should be used instead for ret != NULL
911 * as ERR_error_string cannot know how large the buffer is */
912char *ERR_error_string(unsigned long e, char *ret)
913 {
914 static char buf[256];
915
916 if (ret == NULL) ret=buf;
917 ERR_error_string_n(e, ret, 256);
918
919 return ret;
920 }
921
922LHASH_OF(ERR_STRING_DATA) *ERR_get_string_table(void)
923 {
924 err_fns_check();
925 return ERRFN(err_get)(0);
926 }
927
928LHASH_OF(ERR_STATE) *ERR_get_err_state_table(void)
929 {
930 err_fns_check();
931 return ERRFN(thread_get)(0);
932 }
933
934void ERR_release_err_state_table(LHASH_OF(ERR_STATE) **hash)
935 {
936 err_fns_check();
937 ERRFN(thread_release)(hash);
938 }
939
940const char *ERR_lib_error_string(unsigned long e)
941 {
942 ERR_STRING_DATA d,*p;
943 unsigned long l;
944
945 err_fns_check();
946 l=ERR_GET_LIB(e);
947 d.error=ERR_PACK(l,0,0);
948 p=ERRFN(err_get_item)(&d);
949 return((p == NULL)?NULL:p->string);
950 }
951
952const char *ERR_func_error_string(unsigned long e)
953 {
954 ERR_STRING_DATA d,*p;
955 unsigned long l,f;
956
957 err_fns_check();
958 l=ERR_GET_LIB(e);
959 f=ERR_GET_FUNC(e);
960 d.error=ERR_PACK(l,f,0);
961 p=ERRFN(err_get_item)(&d);
962 return((p == NULL)?NULL:p->string);
963 }
964
965const char *ERR_reason_error_string(unsigned long e)
966 {
967 ERR_STRING_DATA d,*p=NULL;
968 unsigned long l,r;
969
970 err_fns_check();
971 l=ERR_GET_LIB(e);
972 r=ERR_GET_REASON(e);
973 d.error=ERR_PACK(l,0,r);
974 p=ERRFN(err_get_item)(&d);
975 if (!p)
976 {
977 d.error=ERR_PACK(0,0,r);
978 p=ERRFN(err_get_item)(&d);
979 }
980 return((p == NULL)?NULL:p->string);
981 }
982
983void ERR_remove_thread_state(const CRYPTO_THREADID *id)
984 {
985 ERR_STATE tmp;
986
987 if (id)
988 CRYPTO_THREADID_cpy(&tmp.tid, id);
989 else
990 CRYPTO_THREADID_current(&tmp.tid);
991 err_fns_check();
992 /* thread_del_item automatically destroys the LHASH if the number of
993 * items reaches zero. */
994 ERRFN(thread_del_item)(&tmp);
995 }
996
997#ifndef OPENSSL_NO_DEPRECATED
998void ERR_remove_state(unsigned long pid)
999 {
1000 ERR_remove_thread_state(NULL);
1001 }
1002#endif
1003
1004ERR_STATE *ERR_get_state(void)
1005 {
1006 static ERR_STATE fallback;
1007 ERR_STATE *ret,tmp,*tmpp=NULL;
1008 int i;
1009 CRYPTO_THREADID tid;
1010
1011 err_fns_check();
1012 CRYPTO_THREADID_current(&tid);
1013 CRYPTO_THREADID_cpy(&tmp.tid, &tid);
1014 ret=ERRFN(thread_get_item)(&tmp);
1015
1016 /* ret == the error state, if NULL, make a new one */
1017 if (ret == NULL)
1018 {
1019 ret=(ERR_STATE *)OPENSSL_malloc(sizeof(ERR_STATE));
1020 if (ret == NULL) return(&fallback);
1021 CRYPTO_THREADID_cpy(&ret->tid, &tid);
1022 ret->top=0;
1023 ret->bottom=0;
1024 for (i=0; i<ERR_NUM_ERRORS; i++)
1025 {
1026 ret->err_data[i]=NULL;
1027 ret->err_data_flags[i]=0;
1028 }
1029 tmpp = ERRFN(thread_set_item)(ret);
1030 /* To check if insertion failed, do a get. */
1031 if (ERRFN(thread_get_item)(ret) != ret)
1032 {
1033 ERR_STATE_free(ret); /* could not insert it */
1034 return(&fallback);
1035 }
1036 /* If a race occured in this function and we came second, tmpp
1037 * is the first one that we just replaced. */
1038 if (tmpp)
1039 ERR_STATE_free(tmpp);
1040 }
1041 return ret;
1042 }
1043
1044int ERR_get_next_error_library(void)
1045 {
1046 err_fns_check();
1047 return ERRFN(get_next_lib)();
1048 }
1049
300void ERR_set_error_data(char *data, int flags) 1050void ERR_set_error_data(char *data, int flags)
301 { 1051 {
302 ERR_STATE *es; 1052 ERR_STATE *es;
@@ -383,34 +1133,3 @@ int ERR_pop_to_mark(void)
383 es->err_flags[es->top]&=~ERR_FLAG_MARK; 1133 es->err_flags[es->top]&=~ERR_FLAG_MARK;
384 return 1; 1134 return 1;
385 } 1135 }
386
387#ifdef OPENSSL_FIPS
388
389static ERR_STATE *fget_state(void)
390 {
391 static ERR_STATE fstate;
392 return &fstate;
393 }
394
395ERR_STATE *(*get_state_func)(void) = fget_state;
396void (*remove_state_func)(unsigned long pid);
397
398ERR_STATE *ERR_get_state(void)
399 {
400 return get_state_func();
401 }
402
403void int_ERR_set_state_func(ERR_STATE *(*get_func)(void),
404 void (*remove_func)(unsigned long pid))
405 {
406 get_state_func = get_func;
407 remove_state_func = remove_func;
408 }
409
410void ERR_remove_state(unsigned long pid)
411 {
412 if (remove_state_func)
413 remove_state_func(pid);
414 }
415
416#endif
diff --git a/src/lib/libcrypto/err/err.h b/src/lib/libcrypto/err/err.h
index dcac415231..b9f8c16d47 100644
--- a/src/lib/libcrypto/err/err.h
+++ b/src/lib/libcrypto/err/err.h
@@ -55,6 +55,59 @@
55 * copied and put under another distribution licence 55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.] 56 * [including the GNU Public Licence.]
57 */ 57 */
58/* ====================================================================
59 * Copyright (c) 1998-2006 The OpenSSL Project. All rights reserved.
60 *
61 * Redistribution and use in source and binary forms, with or without
62 * modification, are permitted provided that the following conditions
63 * are met:
64 *
65 * 1. Redistributions of source code must retain the above copyright
66 * notice, this list of conditions and the following disclaimer.
67 *
68 * 2. Redistributions in binary form must reproduce the above copyright
69 * notice, this list of conditions and the following disclaimer in
70 * the documentation and/or other materials provided with the
71 * distribution.
72 *
73 * 3. All advertising materials mentioning features or use of this
74 * software must display the following acknowledgment:
75 * "This product includes software developed by the OpenSSL Project
76 * for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
77 *
78 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
79 * endorse or promote products derived from this software without
80 * prior written permission. For written permission, please contact
81 * openssl-core@openssl.org.
82 *
83 * 5. Products derived from this software may not be called "OpenSSL"
84 * nor may "OpenSSL" appear in their names without prior written
85 * permission of the OpenSSL Project.
86 *
87 * 6. Redistributions of any form whatsoever must retain the following
88 * acknowledgment:
89 * "This product includes software developed by the OpenSSL Project
90 * for use in the OpenSSL Toolkit (http://www.openssl.org/)"
91 *
92 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
93 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
94 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
95 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
96 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
97 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
98 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
99 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
100 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
101 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
102 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
103 * OF THE POSSIBILITY OF SUCH DAMAGE.
104 * ====================================================================
105 *
106 * This product includes cryptographic software written by Eric Young
107 * (eay@cryptsoft.com). This product includes software written by Tim
108 * Hudson (tjh@cryptsoft.com).
109 *
110 */
58 111
59#ifndef HEADER_ERR_H 112#ifndef HEADER_ERR_H
60#define HEADER_ERR_H 113#define HEADER_ERR_H
@@ -94,7 +147,7 @@ extern "C" {
94#define ERR_NUM_ERRORS 16 147#define ERR_NUM_ERRORS 16
95typedef struct err_state_st 148typedef struct err_state_st
96 { 149 {
97 unsigned long pid; 150 CRYPTO_THREADID tid;
98 int err_flags[ERR_NUM_ERRORS]; 151 int err_flags[ERR_NUM_ERRORS];
99 unsigned long err_buffer[ERR_NUM_ERRORS]; 152 unsigned long err_buffer[ERR_NUM_ERRORS];
100 char *err_data[ERR_NUM_ERRORS]; 153 char *err_data[ERR_NUM_ERRORS];
@@ -142,7 +195,9 @@ typedef struct err_state_st
142#define ERR_LIB_STORE 44 195#define ERR_LIB_STORE 44
143#define ERR_LIB_FIPS 45 196#define ERR_LIB_FIPS 45
144#define ERR_LIB_CMS 46 197#define ERR_LIB_CMS 46
145#define ERR_LIB_JPAKE 47 198#define ERR_LIB_TS 47
199#define ERR_LIB_HMAC 48
200#define ERR_LIB_JPAKE 49
146 201
147#define ERR_LIB_USER 128 202#define ERR_LIB_USER 128
148 203
@@ -176,6 +231,8 @@ typedef struct err_state_st
176#define STOREerr(f,r) ERR_PUT_error(ERR_LIB_STORE,(f),(r),__FILE__,__LINE__) 231#define STOREerr(f,r) ERR_PUT_error(ERR_LIB_STORE,(f),(r),__FILE__,__LINE__)
177#define FIPSerr(f,r) ERR_PUT_error(ERR_LIB_FIPS,(f),(r),__FILE__,__LINE__) 232#define FIPSerr(f,r) ERR_PUT_error(ERR_LIB_FIPS,(f),(r),__FILE__,__LINE__)
178#define CMSerr(f,r) ERR_PUT_error(ERR_LIB_CMS,(f),(r),__FILE__,__LINE__) 233#define CMSerr(f,r) ERR_PUT_error(ERR_LIB_CMS,(f),(r),__FILE__,__LINE__)
234#define TSerr(f,r) ERR_PUT_error(ERR_LIB_TS,(f),(r),__FILE__,__LINE__)
235#define HMACerr(f,r) ERR_PUT_error(ERR_LIB_HMAC,(f),(r),__FILE__,__LINE__)
179#define JPAKEerr(f,r) ERR_PUT_error(ERR_LIB_JPAKE,(f),(r),__FILE__,__LINE__) 236#define JPAKEerr(f,r) ERR_PUT_error(ERR_LIB_JPAKE,(f),(r),__FILE__,__LINE__)
180 237
181/* Borland C seems too stupid to be able to shift and do longs in 238/* Borland C seems too stupid to be able to shift and do longs in
@@ -232,6 +289,7 @@ typedef struct err_state_st
232#define ERR_R_ECDSA_LIB ERR_LIB_ECDSA /* 42 */ 289#define ERR_R_ECDSA_LIB ERR_LIB_ECDSA /* 42 */
233#define ERR_R_ECDH_LIB ERR_LIB_ECDH /* 43 */ 290#define ERR_R_ECDH_LIB ERR_LIB_ECDH /* 43 */
234#define ERR_R_STORE_LIB ERR_LIB_STORE /* 44 */ 291#define ERR_R_STORE_LIB ERR_LIB_STORE /* 44 */
292#define ERR_R_TS_LIB ERR_LIB_TS /* 45 */
235 293
236#define ERR_R_NESTED_ASN1_ERROR 58 294#define ERR_R_NESTED_ASN1_ERROR 58
237#define ERR_R_BAD_ASN1_OBJECT_HEADER 59 295#define ERR_R_BAD_ASN1_OBJECT_HEADER 59
@@ -294,13 +352,16 @@ void ERR_load_ERR_strings(void);
294void ERR_load_crypto_strings(void); 352void ERR_load_crypto_strings(void);
295void ERR_free_strings(void); 353void ERR_free_strings(void);
296 354
355void ERR_remove_thread_state(const CRYPTO_THREADID *tid);
356#ifndef OPENSSL_NO_DEPRECATED
297void ERR_remove_state(unsigned long pid); /* if zero we look it up */ 357void ERR_remove_state(unsigned long pid); /* if zero we look it up */
358#endif
298ERR_STATE *ERR_get_state(void); 359ERR_STATE *ERR_get_state(void);
299 360
300#ifndef OPENSSL_NO_LHASH 361#ifndef OPENSSL_NO_LHASH
301LHASH *ERR_get_string_table(void); 362LHASH_OF(ERR_STRING_DATA) *ERR_get_string_table(void);
302LHASH *ERR_get_err_state_table(void); 363LHASH_OF(ERR_STATE) *ERR_get_err_state_table(void);
303void ERR_release_err_state_table(LHASH **hash); 364void ERR_release_err_state_table(LHASH_OF(ERR_STATE) **hash);
304#endif 365#endif
305 366
306int ERR_get_next_error_library(void); 367int ERR_get_next_error_library(void);
@@ -308,12 +369,6 @@ int ERR_get_next_error_library(void);
308int ERR_set_mark(void); 369int ERR_set_mark(void);
309int ERR_pop_to_mark(void); 370int ERR_pop_to_mark(void);
310 371
311#ifdef OPENSSL_FIPS
312void int_ERR_set_state_func(ERR_STATE *(*get_func)(void),
313 void (*remove_func)(unsigned long pid));
314void int_ERR_lib_init(void);
315#endif
316
317/* Already defined in ossl_typ.h */ 372/* Already defined in ossl_typ.h */
318/* typedef struct st_ERR_FNS ERR_FNS; */ 373/* typedef struct st_ERR_FNS ERR_FNS; */
319/* An application can use this function and provide the return value to loaded 374/* An application can use this function and provide the return value to loaded
diff --git a/src/lib/libcrypto/err/err_all.c b/src/lib/libcrypto/err/err_all.c
index f21a5276ed..fc049e8e88 100644
--- a/src/lib/libcrypto/err/err_all.c
+++ b/src/lib/libcrypto/err/err_all.c
@@ -64,6 +64,7 @@
64#endif 64#endif
65#include <openssl/buffer.h> 65#include <openssl/buffer.h>
66#include <openssl/bio.h> 66#include <openssl/bio.h>
67#include <openssl/comp.h>
67#ifndef OPENSSL_NO_RSA 68#ifndef OPENSSL_NO_RSA
68#include <openssl/rsa.h> 69#include <openssl/rsa.h>
69#endif 70#endif
@@ -94,16 +95,14 @@
94#include <openssl/ui.h> 95#include <openssl/ui.h>
95#include <openssl/ocsp.h> 96#include <openssl/ocsp.h>
96#include <openssl/err.h> 97#include <openssl/err.h>
97#ifdef OPENSSL_FIPS 98#include <openssl/ts.h>
98#include <openssl/fips.h>
99#endif
100
101#ifndef OPENSSL_NO_CMS 99#ifndef OPENSSL_NO_CMS
102#include <openssl/cms.h> 100#include <openssl/cms.h>
103#endif 101#endif
104#ifndef OPENSSL_NO_JPAKE 102#ifndef OPENSSL_NO_JPAKE
105#include <openssl/jpake.h> 103#include <openssl/jpake.h>
106#endif 104#endif
105#include <openssl/comp.h>
107 106
108void ERR_load_crypto_strings(void) 107void ERR_load_crypto_strings(void)
109 { 108 {
@@ -127,6 +126,7 @@ void ERR_load_crypto_strings(void)
127 ERR_load_ASN1_strings(); 126 ERR_load_ASN1_strings();
128 ERR_load_CONF_strings(); 127 ERR_load_CONF_strings();
129 ERR_load_CRYPTO_strings(); 128 ERR_load_CRYPTO_strings();
129 ERR_load_COMP_strings();
130#ifndef OPENSSL_NO_EC 130#ifndef OPENSSL_NO_EC
131 ERR_load_EC_strings(); 131 ERR_load_EC_strings();
132#endif 132#endif
@@ -143,19 +143,18 @@ void ERR_load_crypto_strings(void)
143 ERR_load_PKCS12_strings(); 143 ERR_load_PKCS12_strings();
144 ERR_load_RAND_strings(); 144 ERR_load_RAND_strings();
145 ERR_load_DSO_strings(); 145 ERR_load_DSO_strings();
146 ERR_load_TS_strings();
146#ifndef OPENSSL_NO_ENGINE 147#ifndef OPENSSL_NO_ENGINE
147 ERR_load_ENGINE_strings(); 148 ERR_load_ENGINE_strings();
148#endif 149#endif
149 ERR_load_OCSP_strings(); 150 ERR_load_OCSP_strings();
150 ERR_load_UI_strings(); 151 ERR_load_UI_strings();
151#ifdef OPENSSL_FIPS
152 ERR_load_FIPS_strings();
153#endif
154#ifndef OPENSSL_NO_CMS 152#ifndef OPENSSL_NO_CMS
155 ERR_load_CMS_strings(); 153 ERR_load_CMS_strings();
156#endif 154#endif
157#ifndef OPENSSL_NO_JPAKE 155#ifndef OPENSSL_NO_JPAKE
158 ERR_load_JPAKE_strings(); 156 ERR_load_JPAKE_strings();
159#endif 157#endif
158 ERR_load_COMP_strings();
160#endif 159#endif
161 } 160 }
diff --git a/src/lib/libcrypto/err/err_bio.c b/src/lib/libcrypto/err/err_bio.c
deleted file mode 100644
index a42f804840..0000000000
--- a/src/lib/libcrypto/err/err_bio.c
+++ /dev/null
@@ -1,75 +0,0 @@
1/* crypto/err/err_prn.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 "cryptlib.h"
61#include <openssl/lhash.h>
62#include <openssl/crypto.h>
63#include <openssl/buffer.h>
64#include <openssl/err.h>
65
66static int print_bio(const char *str, size_t len, void *bp)
67 {
68 return BIO_write((BIO *)bp, str, len);
69 }
70void ERR_print_errors(BIO *bp)
71 {
72 ERR_print_errors_cb(print_bio, bp);
73 }
74
75
diff --git a/src/lib/libcrypto/err/err_def.c b/src/lib/libcrypto/err/err_def.c
deleted file mode 100644
index 7ed3d84955..0000000000
--- a/src/lib/libcrypto/err/err_def.c
+++ /dev/null
@@ -1,665 +0,0 @@
1/* crypto/err/err_def.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 * Copyright (c) 1998-2001 The OpenSSL Project. All rights reserved.
60 *
61 * Redistribution and use in source and binary forms, with or without
62 * modification, are permitted provided that the following conditions
63 * are met:
64 *
65 * 1. Redistributions of source code must retain the above copyright
66 * notice, this list of conditions and the following disclaimer.
67 *
68 * 2. Redistributions in binary form must reproduce the above copyright
69 * notice, this list of conditions and the following disclaimer in
70 * the documentation and/or other materials provided with the
71 * distribution.
72 *
73 * 3. All advertising materials mentioning features or use of this
74 * software must display the following acknowledgment:
75 * "This product includes software developed by the OpenSSL Project
76 * for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
77 *
78 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
79 * endorse or promote products derived from this software without
80 * prior written permission. For written permission, please contact
81 * openssl-core@openssl.org.
82 *
83 * 5. Products derived from this software may not be called "OpenSSL"
84 * nor may "OpenSSL" appear in their names without prior written
85 * permission of the OpenSSL Project.
86 *
87 * 6. Redistributions of any form whatsoever must retain the following
88 * acknowledgment:
89 * "This product includes software developed by the OpenSSL Project
90 * for use in the OpenSSL Toolkit (http://www.openssl.org/)"
91 *
92 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
93 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
94 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
95 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
96 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
97 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
98 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
99 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
100 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
101 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
102 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
103 * OF THE POSSIBILITY OF SUCH DAMAGE.
104 * ====================================================================
105 *
106 * This product includes cryptographic software written by Eric Young
107 * (eay@cryptsoft.com). This product includes software written by Tim
108 * Hudson (tjh@cryptsoft.com).
109 *
110 */
111
112#include <stdio.h>
113#include <stdarg.h>
114#include <string.h>
115#include "cryptlib.h"
116#include <openssl/lhash.h>
117#include <openssl/crypto.h>
118#include <openssl/buffer.h>
119#include <openssl/bio.h>
120#include <openssl/err.h>
121
122#define err_clear_data(p,i) \
123 do { \
124 if (((p)->err_data[i] != NULL) && \
125 (p)->err_data_flags[i] & ERR_TXT_MALLOCED) \
126 { \
127 OPENSSL_free((p)->err_data[i]); \
128 (p)->err_data[i]=NULL; \
129 } \
130 (p)->err_data_flags[i]=0; \
131 } while(0)
132
133#define err_clear(p,i) \
134 do { \
135 (p)->err_flags[i]=0; \
136 (p)->err_buffer[i]=0; \
137 err_clear_data(p,i); \
138 (p)->err_file[i]=NULL; \
139 (p)->err_line[i]= -1; \
140 } while(0)
141
142static void err_load_strings(int lib, ERR_STRING_DATA *str);
143
144static void ERR_STATE_free(ERR_STATE *s);
145
146/* Define the predeclared (but externally opaque) "ERR_FNS" type */
147struct st_ERR_FNS
148 {
149 /* Works on the "error_hash" string table */
150 LHASH *(*cb_err_get)(int create);
151 void (*cb_err_del)(void);
152 ERR_STRING_DATA *(*cb_err_get_item)(const ERR_STRING_DATA *);
153 ERR_STRING_DATA *(*cb_err_set_item)(ERR_STRING_DATA *);
154 ERR_STRING_DATA *(*cb_err_del_item)(ERR_STRING_DATA *);
155 /* Works on the "thread_hash" error-state table */
156 LHASH *(*cb_thread_get)(int create);
157 void (*cb_thread_release)(LHASH **hash);
158 ERR_STATE *(*cb_thread_get_item)(const ERR_STATE *);
159 ERR_STATE *(*cb_thread_set_item)(ERR_STATE *);
160 void (*cb_thread_del_item)(const ERR_STATE *);
161 /* Returns the next available error "library" numbers */
162 int (*cb_get_next_lib)(void);
163 };
164
165/* Predeclarations of the "err_defaults" functions */
166static LHASH *int_err_get(int create);
167static void int_err_del(void);
168static ERR_STRING_DATA *int_err_get_item(const ERR_STRING_DATA *);
169static ERR_STRING_DATA *int_err_set_item(ERR_STRING_DATA *);
170static ERR_STRING_DATA *int_err_del_item(ERR_STRING_DATA *);
171static LHASH *int_thread_get(int create);
172static void int_thread_release(LHASH **hash);
173static ERR_STATE *int_thread_get_item(const ERR_STATE *);
174static ERR_STATE *int_thread_set_item(ERR_STATE *);
175static void int_thread_del_item(const ERR_STATE *);
176static int int_err_get_next_lib(void);
177/* The static ERR_FNS table using these defaults functions */
178static const ERR_FNS err_defaults =
179 {
180 int_err_get,
181 int_err_del,
182 int_err_get_item,
183 int_err_set_item,
184 int_err_del_item,
185 int_thread_get,
186 int_thread_release,
187 int_thread_get_item,
188 int_thread_set_item,
189 int_thread_del_item,
190 int_err_get_next_lib
191 };
192
193/* The replacable table of ERR_FNS functions we use at run-time */
194static const ERR_FNS *err_fns = NULL;
195
196/* Eg. rather than using "err_get()", use "ERRFN(err_get)()". */
197#define ERRFN(a) err_fns->cb_##a
198
199/* The internal state used by "err_defaults" - as such, the setting, reading,
200 * creating, and deleting of this data should only be permitted via the
201 * "err_defaults" functions. This way, a linked module can completely defer all
202 * ERR state operation (together with requisite locking) to the implementations
203 * and state in the loading application. */
204static LHASH *int_error_hash = NULL;
205static LHASH *int_thread_hash = NULL;
206static int int_thread_hash_references = 0;
207static int int_err_library_number= ERR_LIB_USER;
208
209/* Internal function that checks whether "err_fns" is set and if not, sets it to
210 * the defaults. */
211static void err_fns_check(void)
212 {
213 if (err_fns) return;
214
215 CRYPTO_w_lock(CRYPTO_LOCK_ERR);
216 if (!err_fns)
217 err_fns = &err_defaults;
218 CRYPTO_w_unlock(CRYPTO_LOCK_ERR);
219 }
220
221/* API functions to get or set the underlying ERR functions. */
222
223const ERR_FNS *ERR_get_implementation(void)
224 {
225 err_fns_check();
226 return err_fns;
227 }
228
229int ERR_set_implementation(const ERR_FNS *fns)
230 {
231 int ret = 0;
232
233 CRYPTO_w_lock(CRYPTO_LOCK_ERR);
234 /* It's too late if 'err_fns' is non-NULL. BTW: not much point setting
235 * an error is there?! */
236 if (!err_fns)
237 {
238 err_fns = fns;
239 ret = 1;
240 }
241 CRYPTO_w_unlock(CRYPTO_LOCK_ERR);
242 return ret;
243 }
244
245/* These are the callbacks provided to "lh_new()" when creating the LHASH tables
246 * internal to the "err_defaults" implementation. */
247
248/* static unsigned long err_hash(ERR_STRING_DATA *a); */
249static unsigned long err_hash(const void *a_void);
250/* static int err_cmp(ERR_STRING_DATA *a, ERR_STRING_DATA *b); */
251static int err_cmp(const void *a_void, const void *b_void);
252/* static unsigned long pid_hash(ERR_STATE *pid); */
253static unsigned long pid_hash(const void *pid_void);
254/* static int pid_cmp(ERR_STATE *a,ERR_STATE *pid); */
255static int pid_cmp(const void *a_void,const void *pid_void);
256
257/* The internal functions used in the "err_defaults" implementation */
258
259static LHASH *int_err_get(int create)
260 {
261 LHASH *ret = NULL;
262
263 CRYPTO_w_lock(CRYPTO_LOCK_ERR);
264 if (!int_error_hash && create)
265 {
266 CRYPTO_push_info("int_err_get (err.c)");
267 int_error_hash = lh_new(err_hash, err_cmp);
268 CRYPTO_pop_info();
269 }
270 if (int_error_hash)
271 ret = int_error_hash;
272 CRYPTO_w_unlock(CRYPTO_LOCK_ERR);
273
274 return ret;
275 }
276
277static void int_err_del(void)
278 {
279 CRYPTO_w_lock(CRYPTO_LOCK_ERR);
280 if (int_error_hash)
281 {
282 lh_free(int_error_hash);
283 int_error_hash = NULL;
284 }
285 CRYPTO_w_unlock(CRYPTO_LOCK_ERR);
286 }
287
288static ERR_STRING_DATA *int_err_get_item(const ERR_STRING_DATA *d)
289 {
290 ERR_STRING_DATA *p;
291 LHASH *hash;
292
293 err_fns_check();
294 hash = ERRFN(err_get)(0);
295 if (!hash)
296 return NULL;
297
298 CRYPTO_r_lock(CRYPTO_LOCK_ERR);
299 p = (ERR_STRING_DATA *)lh_retrieve(hash, d);
300 CRYPTO_r_unlock(CRYPTO_LOCK_ERR);
301
302 return p;
303 }
304
305static ERR_STRING_DATA *int_err_set_item(ERR_STRING_DATA *d)
306 {
307 ERR_STRING_DATA *p;
308 LHASH *hash;
309
310 err_fns_check();
311 hash = ERRFN(err_get)(1);
312 if (!hash)
313 return NULL;
314
315 CRYPTO_w_lock(CRYPTO_LOCK_ERR);
316 p = (ERR_STRING_DATA *)lh_insert(hash, d);
317 CRYPTO_w_unlock(CRYPTO_LOCK_ERR);
318
319 return p;
320 }
321
322static ERR_STRING_DATA *int_err_del_item(ERR_STRING_DATA *d)
323 {
324 ERR_STRING_DATA *p;
325 LHASH *hash;
326
327 err_fns_check();
328 hash = ERRFN(err_get)(0);
329 if (!hash)
330 return NULL;
331
332 CRYPTO_w_lock(CRYPTO_LOCK_ERR);
333 p = (ERR_STRING_DATA *)lh_delete(hash, d);
334 CRYPTO_w_unlock(CRYPTO_LOCK_ERR);
335
336 return p;
337 }
338
339static LHASH *int_thread_get(int create)
340 {
341 LHASH *ret = NULL;
342
343 CRYPTO_w_lock(CRYPTO_LOCK_ERR);
344 if (!int_thread_hash && create)
345 {
346 CRYPTO_push_info("int_thread_get (err.c)");
347 int_thread_hash = lh_new(pid_hash, pid_cmp);
348 CRYPTO_pop_info();
349 }
350 if (int_thread_hash)
351 {
352 int_thread_hash_references++;
353 ret = int_thread_hash;
354 }
355 CRYPTO_w_unlock(CRYPTO_LOCK_ERR);
356 return ret;
357 }
358
359static void int_thread_release(LHASH **hash)
360 {
361 int i;
362
363 if (hash == NULL || *hash == NULL)
364 return;
365
366 i = CRYPTO_add(&int_thread_hash_references, -1, CRYPTO_LOCK_ERR);
367
368#ifdef REF_PRINT
369 fprintf(stderr,"%4d:%s\n",int_thread_hash_references,"ERR");
370#endif
371 if (i > 0) return;
372#ifdef REF_CHECK
373 if (i < 0)
374 {
375 fprintf(stderr,"int_thread_release, bad reference count\n");
376 abort(); /* ok */
377 }
378#endif
379 *hash = NULL;
380 }
381
382static ERR_STATE *int_thread_get_item(const ERR_STATE *d)
383 {
384 ERR_STATE *p;
385 LHASH *hash;
386
387 err_fns_check();
388 hash = ERRFN(thread_get)(0);
389 if (!hash)
390 return NULL;
391
392 CRYPTO_r_lock(CRYPTO_LOCK_ERR);
393 p = (ERR_STATE *)lh_retrieve(hash, d);
394 CRYPTO_r_unlock(CRYPTO_LOCK_ERR);
395
396 ERRFN(thread_release)(&hash);
397 return p;
398 }
399
400static ERR_STATE *int_thread_set_item(ERR_STATE *d)
401 {
402 ERR_STATE *p;
403 LHASH *hash;
404
405 err_fns_check();
406 hash = ERRFN(thread_get)(1);
407 if (!hash)
408 return NULL;
409
410 CRYPTO_w_lock(CRYPTO_LOCK_ERR);
411 p = (ERR_STATE *)lh_insert(hash, d);
412 CRYPTO_w_unlock(CRYPTO_LOCK_ERR);
413
414 ERRFN(thread_release)(&hash);
415 return p;
416 }
417
418static void int_thread_del_item(const ERR_STATE *d)
419 {
420 ERR_STATE *p;
421 LHASH *hash;
422
423 err_fns_check();
424 hash = ERRFN(thread_get)(0);
425 if (!hash)
426 return;
427
428 CRYPTO_w_lock(CRYPTO_LOCK_ERR);
429 p = (ERR_STATE *)lh_delete(hash, d);
430 /* make sure we don't leak memory */
431 if (int_thread_hash_references == 1
432 && int_thread_hash && (lh_num_items(int_thread_hash) == 0))
433 {
434 lh_free(int_thread_hash);
435 int_thread_hash = NULL;
436 }
437 CRYPTO_w_unlock(CRYPTO_LOCK_ERR);
438
439 ERRFN(thread_release)(&hash);
440 if (p)
441 ERR_STATE_free(p);
442 }
443
444static int int_err_get_next_lib(void)
445 {
446 int ret;
447
448 CRYPTO_w_lock(CRYPTO_LOCK_ERR);
449 ret = int_err_library_number++;
450 CRYPTO_w_unlock(CRYPTO_LOCK_ERR);
451
452 return ret;
453 }
454
455static void ERR_STATE_free(ERR_STATE *s)
456 {
457 int i;
458
459 if (s == NULL)
460 return;
461
462 for (i=0; i<ERR_NUM_ERRORS; i++)
463 {
464 err_clear_data(s,i);
465 }
466 OPENSSL_free(s);
467 }
468
469static void err_load_strings(int lib, ERR_STRING_DATA *str)
470 {
471 while (str->error)
472 {
473 if (lib)
474 str->error|=ERR_PACK(lib,0,0);
475 ERRFN(err_set_item)(str);
476 str++;
477 }
478 }
479
480void ERR_load_strings(int lib, ERR_STRING_DATA *str)
481 {
482 err_fns_check();
483 err_load_strings(lib, str);
484 }
485
486void ERR_unload_strings(int lib, ERR_STRING_DATA *str)
487 {
488 while (str->error)
489 {
490 if (lib)
491 str->error|=ERR_PACK(lib,0,0);
492 ERRFN(err_del_item)(str);
493 str++;
494 }
495 }
496
497void ERR_free_strings(void)
498 {
499 err_fns_check();
500 ERRFN(err_del)();
501 }
502
503LHASH *ERR_get_string_table(void)
504 {
505 err_fns_check();
506 return ERRFN(err_get)(0);
507 }
508
509LHASH *ERR_get_err_state_table(void)
510 {
511 err_fns_check();
512 return ERRFN(thread_get)(0);
513 }
514
515void ERR_release_err_state_table(LHASH **hash)
516 {
517 err_fns_check();
518 ERRFN(thread_release)(hash);
519 }
520
521const char *ERR_lib_error_string(unsigned long e)
522 {
523 ERR_STRING_DATA d,*p;
524 unsigned long l;
525
526 err_fns_check();
527 l=ERR_GET_LIB(e);
528 d.error=ERR_PACK(l,0,0);
529 p=ERRFN(err_get_item)(&d);
530 return((p == NULL)?NULL:p->string);
531 }
532
533const char *ERR_func_error_string(unsigned long e)
534 {
535 ERR_STRING_DATA d,*p;
536 unsigned long l,f;
537
538 err_fns_check();
539 l=ERR_GET_LIB(e);
540 f=ERR_GET_FUNC(e);
541 d.error=ERR_PACK(l,f,0);
542 p=ERRFN(err_get_item)(&d);
543 return((p == NULL)?NULL:p->string);
544 }
545
546const char *ERR_reason_error_string(unsigned long e)
547 {
548 ERR_STRING_DATA d,*p=NULL;
549 unsigned long l,r;
550
551 err_fns_check();
552 l=ERR_GET_LIB(e);
553 r=ERR_GET_REASON(e);
554 d.error=ERR_PACK(l,0,r);
555 p=ERRFN(err_get_item)(&d);
556 if (!p)
557 {
558 d.error=ERR_PACK(0,0,r);
559 p=ERRFN(err_get_item)(&d);
560 }
561 return((p == NULL)?NULL:p->string);
562 }
563
564/* static unsigned long err_hash(ERR_STRING_DATA *a) */
565static unsigned long err_hash(const void *a_void)
566 {
567 unsigned long ret,l;
568
569 l=((const ERR_STRING_DATA *)a_void)->error;
570 ret=l^ERR_GET_LIB(l)^ERR_GET_FUNC(l);
571 return(ret^ret%19*13);
572 }
573
574/* static int err_cmp(ERR_STRING_DATA *a, ERR_STRING_DATA *b) */
575static int err_cmp(const void *a_void, const void *b_void)
576 {
577 return((int)(((const ERR_STRING_DATA *)a_void)->error -
578 ((const ERR_STRING_DATA *)b_void)->error));
579 }
580
581/* static unsigned long pid_hash(ERR_STATE *a) */
582static unsigned long pid_hash(const void *a_void)
583 {
584 return(((const ERR_STATE *)a_void)->pid*13);
585 }
586
587/* static int pid_cmp(ERR_STATE *a, ERR_STATE *b) */
588static int pid_cmp(const void *a_void, const void *b_void)
589 {
590 return((int)((long)((const ERR_STATE *)a_void)->pid -
591 (long)((const ERR_STATE *)b_void)->pid));
592 }
593#ifdef OPENSSL_FIPS
594static void int_err_remove_state(unsigned long pid)
595#else
596void ERR_remove_state(unsigned long pid)
597#endif
598 {
599 ERR_STATE tmp;
600
601 err_fns_check();
602 if (pid == 0)
603 pid=(unsigned long)CRYPTO_thread_id();
604 tmp.pid=pid;
605 /* thread_del_item automatically destroys the LHASH if the number of
606 * items reaches zero. */
607 ERRFN(thread_del_item)(&tmp);
608 }
609
610#ifdef OPENSSL_FIPS
611 static ERR_STATE *int_err_get_state(void)
612#else
613ERR_STATE *ERR_get_state(void)
614#endif
615 {
616 static ERR_STATE fallback;
617 ERR_STATE *ret,tmp,*tmpp=NULL;
618 int i;
619 unsigned long pid;
620
621 err_fns_check();
622 pid=(unsigned long)CRYPTO_thread_id();
623 tmp.pid=pid;
624 ret=ERRFN(thread_get_item)(&tmp);
625
626 /* ret == the error state, if NULL, make a new one */
627 if (ret == NULL)
628 {
629 ret=(ERR_STATE *)OPENSSL_malloc(sizeof(ERR_STATE));
630 if (ret == NULL) return(&fallback);
631 ret->pid=pid;
632 ret->top=0;
633 ret->bottom=0;
634 for (i=0; i<ERR_NUM_ERRORS; i++)
635 {
636 ret->err_data[i]=NULL;
637 ret->err_data_flags[i]=0;
638 }
639 tmpp = ERRFN(thread_set_item)(ret);
640 /* To check if insertion failed, do a get. */
641 if (ERRFN(thread_get_item)(ret) != ret)
642 {
643 ERR_STATE_free(ret); /* could not insert it */
644 return(&fallback);
645 }
646 /* If a race occured in this function and we came second, tmpp
647 * is the first one that we just replaced. */
648 if (tmpp)
649 ERR_STATE_free(tmpp);
650 }
651 return ret;
652 }
653
654#ifdef OPENSSL_FIPS
655void int_ERR_lib_init(void)
656 {
657 int_ERR_set_state_func(int_err_get_state, int_err_remove_state);
658 }
659#endif
660
661int ERR_get_next_error_library(void)
662 {
663 err_fns_check();
664 return ERRFN(get_next_lib)();
665 }
diff --git a/src/lib/libcrypto/err/err_prn.c b/src/lib/libcrypto/err/err_prn.c
index 4cdf342fa6..a0168ac8ed 100644
--- a/src/lib/libcrypto/err/err_prn.c
+++ b/src/lib/libcrypto/err/err_prn.c
@@ -72,21 +72,29 @@ void ERR_print_errors_cb(int (*cb)(const char *str, size_t len, void *u),
72 const char *file,*data; 72 const char *file,*data;
73 int line,flags; 73 int line,flags;
74 unsigned long es; 74 unsigned long es;
75 CRYPTO_THREADID cur;
75 76
76 es=CRYPTO_thread_id(); 77 CRYPTO_THREADID_current(&cur);
78 es=CRYPTO_THREADID_hash(&cur);
77 while ((l=ERR_get_error_line_data(&file,&line,&data,&flags)) != 0) 79 while ((l=ERR_get_error_line_data(&file,&line,&data,&flags)) != 0)
78 { 80 {
79 ERR_error_string_n(l, buf, sizeof buf); 81 ERR_error_string_n(l, buf, sizeof buf);
80 BIO_snprintf(buf2, sizeof(buf2), "%lu:%s:%s:%d:%s\n", es, buf, 82 BIO_snprintf(buf2, sizeof(buf2), "%lu:%s:%s:%d:%s\n", es, buf,
81 file, line, (flags & ERR_TXT_STRING) ? data : ""); 83 file, line, (flags & ERR_TXT_STRING) ? data : "");
82 cb(buf2, strlen(buf2), u); 84 if (cb(buf2, strlen(buf2), u) <= 0)
85 break; /* abort outputting the error report */
83 } 86 }
84 } 87 }
85 88
86#ifndef OPENSSL_NO_FP_API 89#ifndef OPENSSL_NO_FP_API
87static int print_fp(const char *str, size_t len, void *fp) 90static int print_fp(const char *str, size_t len, void *fp)
88 { 91 {
89 return fwrite(str, 1, len, fp); 92 BIO bio;
93
94 BIO_set(&bio,BIO_s_file());
95 BIO_set_fp(&bio,fp,BIO_NOCLOSE);
96
97 return BIO_printf(&bio, "%s", str);
90 } 98 }
91void ERR_print_errors_fp(FILE *fp) 99void ERR_print_errors_fp(FILE *fp)
92 { 100 {
@@ -94,64 +102,13 @@ void ERR_print_errors_fp(FILE *fp)
94 } 102 }
95#endif 103#endif
96 104
97void ERR_error_string_n(unsigned long e, char *buf, size_t len) 105static int print_bio(const char *str, size_t len, void *bp)
98 { 106 {
99 char lsbuf[64], fsbuf[64], rsbuf[64]; 107 return BIO_write((BIO *)bp, str, len);
100 const char *ls,*fs,*rs;
101 unsigned long l,f,r;
102
103 l=ERR_GET_LIB(e);
104 f=ERR_GET_FUNC(e);
105 r=ERR_GET_REASON(e);
106
107 ls=ERR_lib_error_string(e);
108 fs=ERR_func_error_string(e);
109 rs=ERR_reason_error_string(e);
110
111 if (ls == NULL)
112 BIO_snprintf(lsbuf, sizeof(lsbuf), "lib(%lu)", l);
113 if (fs == NULL)
114 BIO_snprintf(fsbuf, sizeof(fsbuf), "func(%lu)", f);
115 if (rs == NULL)
116 BIO_snprintf(rsbuf, sizeof(rsbuf), "reason(%lu)", r);
117
118 BIO_snprintf(buf, len,"error:%08lX:%s:%s:%s", e, ls?ls:lsbuf,
119 fs?fs:fsbuf, rs?rs:rsbuf);
120 if (strlen(buf) == len-1)
121 {
122 /* output may be truncated; make sure we always have 5
123 * colon-separated fields, i.e. 4 colons ... */
124#define NUM_COLONS 4
125 if (len > NUM_COLONS) /* ... if possible */
126 {
127 int i;
128 char *s = buf;
129
130 for (i = 0; i < NUM_COLONS; i++)
131 {
132 char *colon = strchr(s, ':');
133 if (colon == NULL || colon > &buf[len-1] - NUM_COLONS + i)
134 {
135 /* set colon no. i at last possible position
136 * (buf[len-1] is the terminating 0)*/
137 colon = &buf[len-1] - NUM_COLONS + i;
138 *colon = ':';
139 }
140 s = colon + 1;
141 }
142 }
143 }
144 } 108 }
145 109void ERR_print_errors(BIO *bp)
146/* BAD for multi-threading: uses a local buffer if ret == NULL */
147/* ERR_error_string_n should be used instead for ret != NULL
148 * as ERR_error_string cannot know how large the buffer is */
149char *ERR_error_string(unsigned long e, char *ret)
150 { 110 {
151 static char buf[256]; 111 ERR_print_errors_cb(print_bio, bp);
152
153 if (ret == NULL) ret=buf;
154 ERR_error_string_n(e, ret, 256);
155
156 return ret;
157 } 112 }
113
114
diff --git a/src/lib/libcrypto/err/err_str.c b/src/lib/libcrypto/err/err_str.c
deleted file mode 100644
index d39040888d..0000000000
--- a/src/lib/libcrypto/err/err_str.c
+++ /dev/null
@@ -1,295 +0,0 @@
1/* crypto/err/err_str.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 * Copyright (c) 1998-2001 The OpenSSL Project. All rights reserved.
60 *
61 * Redistribution and use in source and binary forms, with or without
62 * modification, are permitted provided that the following conditions
63 * are met:
64 *
65 * 1. Redistributions of source code must retain the above copyright
66 * notice, this list of conditions and the following disclaimer.
67 *
68 * 2. Redistributions in binary form must reproduce the above copyright
69 * notice, this list of conditions and the following disclaimer in
70 * the documentation and/or other materials provided with the
71 * distribution.
72 *
73 * 3. All advertising materials mentioning features or use of this
74 * software must display the following acknowledgment:
75 * "This product includes software developed by the OpenSSL Project
76 * for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
77 *
78 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
79 * endorse or promote products derived from this software without
80 * prior written permission. For written permission, please contact
81 * openssl-core@openssl.org.
82 *
83 * 5. Products derived from this software may not be called "OpenSSL"
84 * nor may "OpenSSL" appear in their names without prior written
85 * permission of the OpenSSL Project.
86 *
87 * 6. Redistributions of any form whatsoever must retain the following
88 * acknowledgment:
89 * "This product includes software developed by the OpenSSL Project
90 * for use in the OpenSSL Toolkit (http://www.openssl.org/)"
91 *
92 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
93 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
94 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
95 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
96 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
97 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
98 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
99 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
100 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
101 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
102 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
103 * OF THE POSSIBILITY OF SUCH DAMAGE.
104 * ====================================================================
105 *
106 * This product includes cryptographic software written by Eric Young
107 * (eay@cryptsoft.com). This product includes software written by Tim
108 * Hudson (tjh@cryptsoft.com).
109 *
110 */
111
112#include <stdio.h>
113#include <stdarg.h>
114#include <string.h>
115#include "cryptlib.h"
116#include <openssl/lhash.h>
117#include <openssl/crypto.h>
118#include <openssl/buffer.h>
119#include <openssl/bio.h>
120#include <openssl/err.h>
121
122#ifndef OPENSSL_NO_ERR
123static ERR_STRING_DATA ERR_str_libraries[]=
124 {
125{ERR_PACK(ERR_LIB_NONE,0,0) ,"unknown library"},
126{ERR_PACK(ERR_LIB_SYS,0,0) ,"system library"},
127{ERR_PACK(ERR_LIB_BN,0,0) ,"bignum routines"},
128{ERR_PACK(ERR_LIB_RSA,0,0) ,"rsa routines"},
129{ERR_PACK(ERR_LIB_DH,0,0) ,"Diffie-Hellman routines"},
130{ERR_PACK(ERR_LIB_EVP,0,0) ,"digital envelope routines"},
131{ERR_PACK(ERR_LIB_BUF,0,0) ,"memory buffer routines"},
132{ERR_PACK(ERR_LIB_OBJ,0,0) ,"object identifier routines"},
133{ERR_PACK(ERR_LIB_PEM,0,0) ,"PEM routines"},
134{ERR_PACK(ERR_LIB_DSA,0,0) ,"dsa routines"},
135{ERR_PACK(ERR_LIB_X509,0,0) ,"x509 certificate routines"},
136{ERR_PACK(ERR_LIB_ASN1,0,0) ,"asn1 encoding routines"},
137{ERR_PACK(ERR_LIB_CONF,0,0) ,"configuration file routines"},
138{ERR_PACK(ERR_LIB_CRYPTO,0,0) ,"common libcrypto routines"},
139{ERR_PACK(ERR_LIB_EC,0,0) ,"elliptic curve routines"},
140{ERR_PACK(ERR_LIB_SSL,0,0) ,"SSL routines"},
141{ERR_PACK(ERR_LIB_BIO,0,0) ,"BIO routines"},
142{ERR_PACK(ERR_LIB_PKCS7,0,0) ,"PKCS7 routines"},
143{ERR_PACK(ERR_LIB_X509V3,0,0) ,"X509 V3 routines"},
144{ERR_PACK(ERR_LIB_PKCS12,0,0) ,"PKCS12 routines"},
145{ERR_PACK(ERR_LIB_RAND,0,0) ,"random number generator"},
146{ERR_PACK(ERR_LIB_DSO,0,0) ,"DSO support routines"},
147{ERR_PACK(ERR_LIB_ENGINE,0,0) ,"engine routines"},
148{ERR_PACK(ERR_LIB_OCSP,0,0) ,"OCSP routines"},
149{ERR_PACK(ERR_LIB_FIPS,0,0) ,"FIPS routines"},
150{ERR_PACK(ERR_LIB_CMS,0,0) ,"CMS routines"},
151{ERR_PACK(ERR_LIB_JPAKE,0,0) ,"JPAKE routines"},
152{0,NULL},
153 };
154
155static ERR_STRING_DATA ERR_str_functs[]=
156 {
157 {ERR_PACK(0,SYS_F_FOPEN,0), "fopen"},
158 {ERR_PACK(0,SYS_F_CONNECT,0), "connect"},
159 {ERR_PACK(0,SYS_F_GETSERVBYNAME,0), "getservbyname"},
160 {ERR_PACK(0,SYS_F_SOCKET,0), "socket"},
161 {ERR_PACK(0,SYS_F_IOCTLSOCKET,0), "ioctlsocket"},
162 {ERR_PACK(0,SYS_F_BIND,0), "bind"},
163 {ERR_PACK(0,SYS_F_LISTEN,0), "listen"},
164 {ERR_PACK(0,SYS_F_ACCEPT,0), "accept"},
165#ifdef OPENSSL_SYS_WINDOWS
166 {ERR_PACK(0,SYS_F_WSASTARTUP,0), "WSAstartup"},
167#endif
168 {ERR_PACK(0,SYS_F_OPENDIR,0), "opendir"},
169 {ERR_PACK(0,SYS_F_FREAD,0), "fread"},
170 {0,NULL},
171 };
172
173static ERR_STRING_DATA ERR_str_reasons[]=
174 {
175{ERR_R_SYS_LIB ,"system lib"},
176{ERR_R_BN_LIB ,"BN lib"},
177{ERR_R_RSA_LIB ,"RSA lib"},
178{ERR_R_DH_LIB ,"DH lib"},
179{ERR_R_EVP_LIB ,"EVP lib"},
180{ERR_R_BUF_LIB ,"BUF lib"},
181{ERR_R_OBJ_LIB ,"OBJ lib"},
182{ERR_R_PEM_LIB ,"PEM lib"},
183{ERR_R_DSA_LIB ,"DSA lib"},
184{ERR_R_X509_LIB ,"X509 lib"},
185{ERR_R_ASN1_LIB ,"ASN1 lib"},
186{ERR_R_CONF_LIB ,"CONF lib"},
187{ERR_R_CRYPTO_LIB ,"CRYPTO lib"},
188{ERR_R_EC_LIB ,"EC lib"},
189{ERR_R_SSL_LIB ,"SSL lib"},
190{ERR_R_BIO_LIB ,"BIO lib"},
191{ERR_R_PKCS7_LIB ,"PKCS7 lib"},
192{ERR_R_X509V3_LIB ,"X509V3 lib"},
193{ERR_R_PKCS12_LIB ,"PKCS12 lib"},
194{ERR_R_RAND_LIB ,"RAND lib"},
195{ERR_R_DSO_LIB ,"DSO lib"},
196{ERR_R_ENGINE_LIB ,"ENGINE lib"},
197{ERR_R_OCSP_LIB ,"OCSP lib"},
198
199{ERR_R_NESTED_ASN1_ERROR ,"nested asn1 error"},
200{ERR_R_BAD_ASN1_OBJECT_HEADER ,"bad asn1 object header"},
201{ERR_R_BAD_GET_ASN1_OBJECT_CALL ,"bad get asn1 object call"},
202{ERR_R_EXPECTING_AN_ASN1_SEQUENCE ,"expecting an asn1 sequence"},
203{ERR_R_ASN1_LENGTH_MISMATCH ,"asn1 length mismatch"},
204{ERR_R_MISSING_ASN1_EOS ,"missing asn1 eos"},
205
206{ERR_R_FATAL ,"fatal"},
207{ERR_R_MALLOC_FAILURE ,"malloc failure"},
208{ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED ,"called a function you should not call"},
209{ERR_R_PASSED_NULL_PARAMETER ,"passed a null parameter"},
210{ERR_R_INTERNAL_ERROR ,"internal error"},
211{ERR_R_DISABLED ,"called a function that was disabled at compile-time"},
212
213{0,NULL},
214 };
215#endif
216
217#ifndef OPENSSL_NO_ERR
218#define NUM_SYS_STR_REASONS 127
219#define LEN_SYS_STR_REASON 32
220
221static ERR_STRING_DATA SYS_str_reasons[NUM_SYS_STR_REASONS + 1];
222/* SYS_str_reasons is filled with copies of strerror() results at
223 * initialization.
224 * 'errno' values up to 127 should cover all usual errors,
225 * others will be displayed numerically by ERR_error_string.
226 * It is crucial that we have something for each reason code
227 * that occurs in ERR_str_reasons, or bogus reason strings
228 * will be returned for SYSerr, which always gets an errno
229 * value and never one of those 'standard' reason codes. */
230
231static void build_SYS_str_reasons(void)
232 {
233 /* OPENSSL_malloc cannot be used here, use static storage instead */
234 static char strerror_tab[NUM_SYS_STR_REASONS][LEN_SYS_STR_REASON];
235 int i;
236 static int init = 1;
237
238 CRYPTO_r_lock(CRYPTO_LOCK_ERR);
239 if (!init)
240 {
241 CRYPTO_r_unlock(CRYPTO_LOCK_ERR);
242 return;
243 }
244
245 CRYPTO_r_unlock(CRYPTO_LOCK_ERR);
246 CRYPTO_w_lock(CRYPTO_LOCK_ERR);
247 if (!init)
248 {
249 CRYPTO_w_unlock(CRYPTO_LOCK_ERR);
250 return;
251 }
252
253 for (i = 1; i <= NUM_SYS_STR_REASONS; i++)
254 {
255 ERR_STRING_DATA *str = &SYS_str_reasons[i - 1];
256
257 str->error = (unsigned long)i;
258 if (str->string == NULL)
259 {
260 char (*dest)[LEN_SYS_STR_REASON] = &(strerror_tab[i - 1]);
261 char *src = strerror(i);
262 if (src != NULL)
263 {
264 strncpy(*dest, src, sizeof *dest);
265 (*dest)[sizeof *dest - 1] = '\0';
266 str->string = *dest;
267 }
268 }
269 if (str->string == NULL)
270 str->string = "unknown";
271 }
272
273 /* Now we still have SYS_str_reasons[NUM_SYS_STR_REASONS] = {0, NULL},
274 * as required by ERR_load_strings. */
275
276 init = 0;
277
278 CRYPTO_w_unlock(CRYPTO_LOCK_ERR);
279 }
280#endif
281
282void ERR_load_ERR_strings(void)
283 {
284#ifndef OPENSSL_NO_ERR
285 if (ERR_func_error_string(ERR_str_functs[0].error) == NULL)
286 {
287 ERR_load_strings(0,ERR_str_libraries);
288 ERR_load_strings(0,ERR_str_reasons);
289 ERR_load_strings(ERR_LIB_SYS,ERR_str_functs);
290 build_SYS_str_reasons();
291 ERR_load_strings(ERR_LIB_SYS,SYS_str_reasons);
292 }
293#endif
294 }
295
diff --git a/src/lib/libcrypto/err/openssl.ec b/src/lib/libcrypto/err/openssl.ec
index 868826624d..e0554b4342 100644
--- a/src/lib/libcrypto/err/openssl.ec
+++ b/src/lib/libcrypto/err/openssl.ec
@@ -31,13 +31,15 @@ L COMP crypto/comp/comp.h crypto/comp/comp_err.c
31L ECDSA crypto/ecdsa/ecdsa.h crypto/ecdsa/ecs_err.c 31L ECDSA crypto/ecdsa/ecdsa.h crypto/ecdsa/ecs_err.c
32L ECDH crypto/ecdh/ecdh.h crypto/ecdh/ech_err.c 32L ECDH crypto/ecdh/ecdh.h crypto/ecdh/ech_err.c
33L STORE crypto/store/store.h crypto/store/str_err.c 33L STORE crypto/store/store.h crypto/store/str_err.c
34L FIPS fips/fips.h crypto/fips_err.h 34L TS crypto/ts/ts.h crypto/ts/ts_err.c
35L HMAC crypto/hmac/hmac.h crypto/hmac/hmac_err.c
35L CMS crypto/cms/cms.h crypto/cms/cms_err.c 36L CMS crypto/cms/cms.h crypto/cms/cms_err.c
36L JPAKE crypto/jpake/jpake.h crypto/jpake/jpake_err.c 37L JPAKE crypto/jpake/jpake.h crypto/jpake/jpake_err.c
37 38
38# additional header files to be scanned for function names 39# additional header files to be scanned for function names
39L NONE crypto/x509/x509_vfy.h NONE 40L NONE crypto/x509/x509_vfy.h NONE
40L NONE crypto/ec/ec_lcl.h NONE 41L NONE crypto/ec/ec_lcl.h NONE
42L NONE crypto/asn1/asn_lcl.h NONE
41L NONE crypto/cms/cms_lcl.h NONE 43L NONE crypto/cms/cms_lcl.h NONE
42 44
43 45
@@ -71,6 +73,11 @@ R SSL_R_TLSV1_ALERT_INSUFFICIENT_SECURITY 1071
71R SSL_R_TLSV1_ALERT_INTERNAL_ERROR 1080 73R SSL_R_TLSV1_ALERT_INTERNAL_ERROR 1080
72R SSL_R_TLSV1_ALERT_USER_CANCELLED 1090 74R SSL_R_TLSV1_ALERT_USER_CANCELLED 1090
73R SSL_R_TLSV1_ALERT_NO_RENEGOTIATION 1100 75R SSL_R_TLSV1_ALERT_NO_RENEGOTIATION 1100
76R SSL_R_TLSV1_UNSUPPORTED_EXTENSION 1110
77R SSL_R_TLSV1_CERTIFICATE_UNOBTAINABLE 1111
78R SSL_R_TLSV1_UNRECOGNIZED_NAME 1112
79R SSL_R_TLSV1_BAD_CERTIFICATE_STATUS_RESPONSE 1113
80R SSL_R_TLSV1_BAD_CERTIFICATE_HASH_VALUE 1114
74 81
75R RSAREF_R_CONTENT_ENCODING 0x0400 82R RSAREF_R_CONTENT_ENCODING 0x0400
76R RSAREF_R_DATA 0x0401 83R RSAREF_R_DATA 0x0401
diff --git a/src/lib/libcrypto/evp/Makefile b/src/lib/libcrypto/evp/Makefile
index c204f84c1d..82825e5299 100644
--- a/src/lib/libcrypto/evp/Makefile
+++ b/src/lib/libcrypto/evp/Makefile
@@ -18,34 +18,34 @@ TESTDATA=evptests.txt
18APPS= 18APPS=
19 19
20LIB=$(TOP)/libcrypto.a 20LIB=$(TOP)/libcrypto.a
21LIBSRC= encode.c digest.c dig_eng.c evp_enc.c evp_key.c evp_acnf.c evp_cnf.c \ 21LIBSRC= encode.c digest.c evp_enc.c evp_key.c evp_acnf.c \
22 e_des.c e_bf.c e_idea.c e_des3.c e_camellia.c\ 22 e_des.c e_bf.c e_idea.c e_des3.c e_camellia.c\
23 e_rc4.c e_aes.c names.c e_seed.c \ 23 e_rc4.c e_aes.c names.c e_seed.c \
24 e_xcbc_d.c e_rc2.c e_cast.c e_rc5.c enc_min.c \ 24 e_xcbc_d.c e_rc2.c e_cast.c e_rc5.c \
25 m_null.c m_md2.c m_md4.c m_md5.c m_sha.c m_sha1.c \ 25 m_null.c m_md2.c m_md4.c m_md5.c m_sha.c m_sha1.c m_wp.c \
26 m_dss.c m_dss1.c m_mdc2.c m_ripemd.c m_ecdsa.c\ 26 m_dss.c m_dss1.c m_mdc2.c m_ripemd.c m_ecdsa.c\
27 p_open.c p_seal.c p_sign.c p_verify.c p_lib.c p_enc.c p_dec.c \ 27 p_open.c p_seal.c p_sign.c p_verify.c p_lib.c p_enc.c p_dec.c \
28 bio_md.c bio_b64.c bio_enc.c evp_err.c e_null.c \ 28 bio_md.c bio_b64.c bio_enc.c evp_err.c e_null.c \
29 c_all.c c_allc.c c_alld.c evp_lib.c bio_ok.c \ 29 c_all.c c_allc.c c_alld.c evp_lib.c bio_ok.c \
30 evp_pkey.c evp_pbe.c p5_crpt.c p5_crpt2.c \ 30 evp_pkey.c evp_pbe.c p5_crpt.c p5_crpt2.c \
31 e_old.c 31 e_old.c pmeth_lib.c pmeth_fn.c pmeth_gn.c m_sigver.c
32 32
33LIBOBJ= encode.o digest.o dig_eng.o evp_enc.o evp_key.o evp_acnf.o evp_cnf.o \ 33LIBOBJ= encode.o digest.o evp_enc.o evp_key.o evp_acnf.o \
34 e_des.o e_bf.o e_idea.o e_des3.o e_camellia.o\ 34 e_des.o e_bf.o e_idea.o e_des3.o e_camellia.o\
35 e_rc4.o e_aes.o names.o e_seed.o \ 35 e_rc4.o e_aes.o names.o e_seed.o \
36 e_xcbc_d.o e_rc2.o e_cast.o e_rc5.o enc_min.o \ 36 e_xcbc_d.o e_rc2.o e_cast.o e_rc5.o \
37 m_null.o m_md2.o m_md4.o m_md5.o m_sha.o m_sha1.o \ 37 m_null.o m_md2.o m_md4.o m_md5.o m_sha.o m_sha1.o m_wp.o \
38 m_dss.o m_dss1.o m_mdc2.o m_ripemd.o m_ecdsa.o\ 38 m_dss.o m_dss1.o m_mdc2.o m_ripemd.o m_ecdsa.o\
39 p_open.o p_seal.o p_sign.o p_verify.o p_lib.o p_enc.o p_dec.o \ 39 p_open.o p_seal.o p_sign.o p_verify.o p_lib.o p_enc.o p_dec.o \
40 bio_md.o bio_b64.o bio_enc.o evp_err.o e_null.o \ 40 bio_md.o bio_b64.o bio_enc.o evp_err.o e_null.o \
41 c_all.o c_allc.o c_alld.o evp_lib.o bio_ok.o \ 41 c_all.o c_allc.o c_alld.o evp_lib.o bio_ok.o \
42 evp_pkey.o evp_pbe.o p5_crpt.o p5_crpt2.o \ 42 evp_pkey.o evp_pbe.o p5_crpt.o p5_crpt2.o \
43 e_old.o 43 e_old.o pmeth_lib.o pmeth_fn.o pmeth_gn.o m_sigver.o
44 44
45SRC= $(LIBSRC) 45SRC= $(LIBSRC)
46 46
47EXHEADER= evp.h 47EXHEADER= evp.h
48HEADER= $(EXHEADER) 48HEADER= evp_locl.h $(EXHEADER)
49 49
50ALL= $(GENERAL) $(SRC) $(HEADER) 50ALL= $(GENERAL) $(SRC) $(HEADER)
51 51
@@ -55,7 +55,7 @@ top:
55all: lib 55all: lib
56 56
57lib: $(LIBOBJ) 57lib: $(LIBOBJ)
58 $(ARX) $(LIB) $(LIBOBJ) 58 $(AR) $(LIB) $(LIBOBJ)
59 $(RANLIB) $(LIB) || echo Never mind. 59 $(RANLIB) $(LIB) || echo Never mind.
60 @touch lib 60 @touch lib
61 61
@@ -101,201 +101,185 @@ bio_b64.o: ../../e_os.h ../../include/openssl/asn1.h
101bio_b64.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h 101bio_b64.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
102bio_b64.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h 102bio_b64.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
103bio_b64.o: ../../include/openssl/err.h ../../include/openssl/evp.h 103bio_b64.o: ../../include/openssl/err.h ../../include/openssl/evp.h
104bio_b64.o: ../../include/openssl/fips.h ../../include/openssl/lhash.h 104bio_b64.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
105bio_b64.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h 105bio_b64.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
106bio_b64.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h 106bio_b64.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
107bio_b64.o: ../../include/openssl/ossl_typ.h ../../include/openssl/safestack.h 107bio_b64.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
108bio_b64.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 108bio_b64.o: ../../include/openssl/symhacks.h ../cryptlib.h bio_b64.c
109bio_b64.o: ../cryptlib.h bio_b64.c
110bio_enc.o: ../../e_os.h ../../include/openssl/asn1.h 109bio_enc.o: ../../e_os.h ../../include/openssl/asn1.h
111bio_enc.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h 110bio_enc.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
112bio_enc.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h 111bio_enc.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
113bio_enc.o: ../../include/openssl/err.h ../../include/openssl/evp.h 112bio_enc.o: ../../include/openssl/err.h ../../include/openssl/evp.h
114bio_enc.o: ../../include/openssl/fips.h ../../include/openssl/lhash.h 113bio_enc.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
115bio_enc.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h 114bio_enc.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
116bio_enc.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h 115bio_enc.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
117bio_enc.o: ../../include/openssl/ossl_typ.h ../../include/openssl/safestack.h 116bio_enc.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
118bio_enc.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 117bio_enc.o: ../../include/openssl/symhacks.h ../cryptlib.h bio_enc.c
119bio_enc.o: ../cryptlib.h bio_enc.c
120bio_md.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h 118bio_md.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h
121bio_md.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 119bio_md.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
122bio_md.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h 120bio_md.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
123bio_md.o: ../../include/openssl/evp.h ../../include/openssl/fips.h 121bio_md.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h
124bio_md.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h 122bio_md.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
125bio_md.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h 123bio_md.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
126bio_md.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h 124bio_md.o: ../../include/openssl/ossl_typ.h ../../include/openssl/safestack.h
127bio_md.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h 125bio_md.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
128bio_md.o: ../../include/openssl/symhacks.h ../cryptlib.h bio_md.c 126bio_md.o: ../cryptlib.h bio_md.c
129bio_ok.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h 127bio_ok.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h
130bio_ok.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 128bio_ok.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
131bio_ok.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h 129bio_ok.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
132bio_ok.o: ../../include/openssl/evp.h ../../include/openssl/fips.h 130bio_ok.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h
133bio_ok.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h 131bio_ok.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
134bio_ok.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h 132bio_ok.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
135bio_ok.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h 133bio_ok.o: ../../include/openssl/ossl_typ.h ../../include/openssl/rand.h
136bio_ok.o: ../../include/openssl/rand.h ../../include/openssl/safestack.h 134bio_ok.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
137bio_ok.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 135bio_ok.o: ../../include/openssl/symhacks.h ../cryptlib.h bio_ok.c
138bio_ok.o: ../cryptlib.h bio_ok.c
139c_all.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h 136c_all.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h
140c_all.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 137c_all.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
141c_all.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h 138c_all.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h
142c_all.o: ../../include/openssl/ecdh.h ../../include/openssl/ecdsa.h 139c_all.o: ../../include/openssl/ecdh.h ../../include/openssl/ecdsa.h
143c_all.o: ../../include/openssl/engine.h ../../include/openssl/err.h 140c_all.o: ../../include/openssl/engine.h ../../include/openssl/err.h
144c_all.o: ../../include/openssl/evp.h ../../include/openssl/fips.h 141c_all.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h
145c_all.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h 142c_all.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
146c_all.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h 143c_all.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
147c_all.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h 144c_all.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h
148c_all.o: ../../include/openssl/pkcs7.h ../../include/openssl/safestack.h 145c_all.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
149c_all.o: ../../include/openssl/sha.h ../../include/openssl/stack.h 146c_all.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
150c_all.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h 147c_all.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
151c_all.o: ../../include/openssl/x509_vfy.h ../cryptlib.h c_all.c 148c_all.o: ../cryptlib.h c_all.c
152c_allc.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h 149c_allc.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h
153c_allc.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 150c_allc.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
154c_allc.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h 151c_allc.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h
155c_allc.o: ../../include/openssl/ecdh.h ../../include/openssl/ecdsa.h 152c_allc.o: ../../include/openssl/ecdh.h ../../include/openssl/ecdsa.h
156c_allc.o: ../../include/openssl/err.h ../../include/openssl/evp.h 153c_allc.o: ../../include/openssl/err.h ../../include/openssl/evp.h
157c_allc.o: ../../include/openssl/fips.h ../../include/openssl/lhash.h 154c_allc.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
158c_allc.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h 155c_allc.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
159c_allc.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h 156c_allc.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
160c_allc.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs12.h 157c_allc.o: ../../include/openssl/pkcs12.h ../../include/openssl/pkcs7.h
161c_allc.o: ../../include/openssl/pkcs7.h ../../include/openssl/safestack.h 158c_allc.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
162c_allc.o: ../../include/openssl/sha.h ../../include/openssl/stack.h 159c_allc.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
163c_allc.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h 160c_allc.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
164c_allc.o: ../../include/openssl/x509_vfy.h ../cryptlib.h c_allc.c 161c_allc.o: ../cryptlib.h c_allc.c
165c_alld.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h 162c_alld.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h
166c_alld.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 163c_alld.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
167c_alld.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h 164c_alld.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h
168c_alld.o: ../../include/openssl/ecdh.h ../../include/openssl/ecdsa.h 165c_alld.o: ../../include/openssl/ecdh.h ../../include/openssl/ecdsa.h
169c_alld.o: ../../include/openssl/err.h ../../include/openssl/evp.h 166c_alld.o: ../../include/openssl/err.h ../../include/openssl/evp.h
170c_alld.o: ../../include/openssl/fips.h ../../include/openssl/lhash.h 167c_alld.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
171c_alld.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h 168c_alld.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
172c_alld.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h 169c_alld.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
173c_alld.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs12.h 170c_alld.o: ../../include/openssl/pkcs12.h ../../include/openssl/pkcs7.h
174c_alld.o: ../../include/openssl/pkcs7.h ../../include/openssl/safestack.h 171c_alld.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
175c_alld.o: ../../include/openssl/sha.h ../../include/openssl/stack.h 172c_alld.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
176c_alld.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h 173c_alld.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
177c_alld.o: ../../include/openssl/x509_vfy.h ../cryptlib.h c_alld.c 174c_alld.o: ../cryptlib.h c_alld.c
178dig_eng.o: ../../e_os.h ../../include/openssl/asn1.h
179dig_eng.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
180dig_eng.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
181dig_eng.o: ../../include/openssl/ec.h ../../include/openssl/ecdh.h
182dig_eng.o: ../../include/openssl/ecdsa.h ../../include/openssl/engine.h
183dig_eng.o: ../../include/openssl/err.h ../../include/openssl/evp.h
184dig_eng.o: ../../include/openssl/fips.h ../../include/openssl/lhash.h
185dig_eng.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
186dig_eng.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
187dig_eng.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h
188dig_eng.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
189dig_eng.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
190dig_eng.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
191dig_eng.o: ../cryptlib.h dig_eng.c evp_locl.h
192digest.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h 175digest.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h
193digest.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 176digest.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
194digest.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h 177digest.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h
195digest.o: ../../include/openssl/ecdh.h ../../include/openssl/ecdsa.h 178digest.o: ../../include/openssl/ecdh.h ../../include/openssl/ecdsa.h
196digest.o: ../../include/openssl/engine.h ../../include/openssl/err.h 179digest.o: ../../include/openssl/engine.h ../../include/openssl/err.h
197digest.o: ../../include/openssl/evp.h ../../include/openssl/fips.h 180digest.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h
198digest.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h 181digest.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
199digest.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h 182digest.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
200digest.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h 183digest.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h
201digest.o: ../../include/openssl/pkcs7.h ../../include/openssl/safestack.h 184digest.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
202digest.o: ../../include/openssl/sha.h ../../include/openssl/stack.h 185digest.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
203digest.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h 186digest.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
204digest.o: ../../include/openssl/x509_vfy.h ../cryptlib.h digest.c evp_locl.h 187digest.o: ../cryptlib.h digest.c
205e_aes.o: ../../include/openssl/aes.h ../../include/openssl/asn1.h 188e_aes.o: ../../include/openssl/aes.h ../../include/openssl/asn1.h
206e_aes.o: ../../include/openssl/bio.h ../../include/openssl/crypto.h 189e_aes.o: ../../include/openssl/bio.h ../../include/openssl/crypto.h
207e_aes.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h 190e_aes.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
208e_aes.o: ../../include/openssl/evp.h ../../include/openssl/fips.h 191e_aes.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h
209e_aes.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h 192e_aes.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
210e_aes.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h 193e_aes.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
211e_aes.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h 194e_aes.o: ../../include/openssl/ossl_typ.h ../../include/openssl/safestack.h
212e_aes.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h 195e_aes.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h e_aes.c
213e_aes.o: ../../include/openssl/symhacks.h e_aes.c evp_locl.h 196e_aes.o: evp_locl.h
214e_bf.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h 197e_bf.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h
215e_bf.o: ../../include/openssl/blowfish.h ../../include/openssl/buffer.h 198e_bf.o: ../../include/openssl/blowfish.h ../../include/openssl/buffer.h
216e_bf.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h 199e_bf.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
217e_bf.o: ../../include/openssl/err.h ../../include/openssl/evp.h 200e_bf.o: ../../include/openssl/err.h ../../include/openssl/evp.h
218e_bf.o: ../../include/openssl/fips.h ../../include/openssl/lhash.h 201e_bf.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
219e_bf.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h 202e_bf.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
220e_bf.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h 203e_bf.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
221e_bf.o: ../../include/openssl/ossl_typ.h ../../include/openssl/safestack.h 204e_bf.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
222e_bf.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 205e_bf.o: ../../include/openssl/symhacks.h ../cryptlib.h e_bf.c evp_locl.h
223e_bf.o: ../cryptlib.h e_bf.c evp_locl.h 206e_camellia.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
224e_camellia.o: ../../include/openssl/opensslconf.h e_camellia.c 207e_camellia.o: ../../include/openssl/camellia.h ../../include/openssl/crypto.h
208e_camellia.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
209e_camellia.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h
210e_camellia.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
211e_camellia.o: ../../include/openssl/opensslconf.h
212e_camellia.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
213e_camellia.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
214e_camellia.o: ../../include/openssl/symhacks.h e_camellia.c evp_locl.h
225e_cast.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h 215e_cast.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h
226e_cast.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h 216e_cast.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
227e_cast.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h 217e_cast.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
228e_cast.o: ../../include/openssl/err.h ../../include/openssl/evp.h 218e_cast.o: ../../include/openssl/err.h ../../include/openssl/evp.h
229e_cast.o: ../../include/openssl/fips.h ../../include/openssl/lhash.h 219e_cast.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
230e_cast.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h 220e_cast.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
231e_cast.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h 221e_cast.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
232e_cast.o: ../../include/openssl/ossl_typ.h ../../include/openssl/safestack.h 222e_cast.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
233e_cast.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 223e_cast.o: ../../include/openssl/symhacks.h ../cryptlib.h e_cast.c evp_locl.h
234e_cast.o: ../cryptlib.h e_cast.c evp_locl.h
235e_des.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h 224e_des.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h
236e_des.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 225e_des.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
237e_des.o: ../../include/openssl/des.h ../../include/openssl/des_old.h 226e_des.o: ../../include/openssl/des.h ../../include/openssl/des_old.h
238e_des.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h 227e_des.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
239e_des.o: ../../include/openssl/evp.h ../../include/openssl/fips.h 228e_des.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h
240e_des.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h 229e_des.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
241e_des.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h 230e_des.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
242e_des.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h 231e_des.o: ../../include/openssl/ossl_typ.h ../../include/openssl/rand.h
243e_des.o: ../../include/openssl/rand.h ../../include/openssl/safestack.h 232e_des.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
244e_des.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 233e_des.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
245e_des.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h 234e_des.o: ../../include/openssl/ui_compat.h ../cryptlib.h e_des.c evp_locl.h
246e_des.o: ../cryptlib.h e_des.c evp_locl.h
247e_des3.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h 235e_des3.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h
248e_des3.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 236e_des3.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
249e_des3.o: ../../include/openssl/des.h ../../include/openssl/des_old.h 237e_des3.o: ../../include/openssl/des.h ../../include/openssl/des_old.h
250e_des3.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h 238e_des3.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
251e_des3.o: ../../include/openssl/evp.h ../../include/openssl/fips.h 239e_des3.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h
252e_des3.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h 240e_des3.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
253e_des3.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h 241e_des3.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
254e_des3.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h 242e_des3.o: ../../include/openssl/ossl_typ.h ../../include/openssl/rand.h
255e_des3.o: ../../include/openssl/rand.h ../../include/openssl/safestack.h 243e_des3.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
256e_des3.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 244e_des3.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
257e_des3.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h 245e_des3.o: ../../include/openssl/ui_compat.h ../cryptlib.h e_des3.c evp_locl.h
258e_des3.o: ../cryptlib.h e_des3.c evp_locl.h
259e_idea.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h 246e_idea.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h
260e_idea.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 247e_idea.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
261e_idea.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h 248e_idea.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
262e_idea.o: ../../include/openssl/evp.h ../../include/openssl/fips.h 249e_idea.o: ../../include/openssl/evp.h ../../include/openssl/idea.h
263e_idea.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h 250e_idea.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
264e_idea.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h 251e_idea.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
265e_idea.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h 252e_idea.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
266e_idea.o: ../../include/openssl/ossl_typ.h ../../include/openssl/safestack.h 253e_idea.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
267e_idea.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 254e_idea.o: ../../include/openssl/symhacks.h ../cryptlib.h e_idea.c evp_locl.h
268e_idea.o: ../cryptlib.h e_idea.c evp_locl.h
269e_null.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h 255e_null.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h
270e_null.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 256e_null.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
271e_null.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h 257e_null.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
272e_null.o: ../../include/openssl/evp.h ../../include/openssl/fips.h 258e_null.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h
273e_null.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h 259e_null.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
274e_null.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h 260e_null.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
275e_null.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h 261e_null.o: ../../include/openssl/ossl_typ.h ../../include/openssl/safestack.h
276e_null.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h 262e_null.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
277e_null.o: ../../include/openssl/symhacks.h ../cryptlib.h e_null.c 263e_null.o: ../cryptlib.h e_null.c
278e_old.o: e_old.c 264e_old.o: e_old.c
279e_rc2.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h 265e_rc2.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h
280e_rc2.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 266e_rc2.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
281e_rc2.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h 267e_rc2.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
282e_rc2.o: ../../include/openssl/evp.h ../../include/openssl/fips.h 268e_rc2.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h
283e_rc2.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h 269e_rc2.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
284e_rc2.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h 270e_rc2.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
285e_rc2.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h 271e_rc2.o: ../../include/openssl/ossl_typ.h ../../include/openssl/rc2.h
286e_rc2.o: ../../include/openssl/rc2.h ../../include/openssl/safestack.h 272e_rc2.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
287e_rc2.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 273e_rc2.o: ../../include/openssl/symhacks.h ../cryptlib.h e_rc2.c evp_locl.h
288e_rc2.o: ../cryptlib.h e_rc2.c evp_locl.h
289e_rc4.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h 274e_rc4.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h
290e_rc4.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 275e_rc4.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
291e_rc4.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h 276e_rc4.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
292e_rc4.o: ../../include/openssl/evp.h ../../include/openssl/fips.h 277e_rc4.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h
293e_rc4.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h 278e_rc4.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
294e_rc4.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h 279e_rc4.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
295e_rc4.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h 280e_rc4.o: ../../include/openssl/ossl_typ.h ../../include/openssl/rc4.h
296e_rc4.o: ../../include/openssl/rc4.h ../../include/openssl/safestack.h 281e_rc4.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
297e_rc4.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 282e_rc4.o: ../../include/openssl/symhacks.h ../cryptlib.h e_rc4.c
298e_rc4.o: ../cryptlib.h e_rc4.c evp_locl.h
299e_rc5.o: ../../e_os.h ../../include/openssl/bio.h 283e_rc5.o: ../../e_os.h ../../include/openssl/bio.h
300e_rc5.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 284e_rc5.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
301e_rc5.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h 285e_rc5.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
@@ -306,256 +290,221 @@ e_rc5.o: ../../include/openssl/symhacks.h ../cryptlib.h e_rc5.c
306e_seed.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h 290e_seed.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
307e_seed.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h 291e_seed.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
308e_seed.o: ../../include/openssl/err.h ../../include/openssl/evp.h 292e_seed.o: ../../include/openssl/err.h ../../include/openssl/evp.h
309e_seed.o: ../../include/openssl/fips.h ../../include/openssl/lhash.h 293e_seed.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
310e_seed.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h 294e_seed.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
311e_seed.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h 295e_seed.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
312e_seed.o: ../../include/openssl/ossl_typ.h ../../include/openssl/safestack.h 296e_seed.o: ../../include/openssl/safestack.h ../../include/openssl/seed.h
313e_seed.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 297e_seed.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
314e_seed.o: e_seed.c 298e_seed.o: e_seed.c evp_locl.h
315e_xcbc_d.o: ../../e_os.h ../../include/openssl/asn1.h 299e_xcbc_d.o: ../../e_os.h ../../include/openssl/asn1.h
316e_xcbc_d.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h 300e_xcbc_d.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
317e_xcbc_d.o: ../../include/openssl/crypto.h ../../include/openssl/des.h 301e_xcbc_d.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
318e_xcbc_d.o: ../../include/openssl/des_old.h ../../include/openssl/e_os2.h 302e_xcbc_d.o: ../../include/openssl/des_old.h ../../include/openssl/e_os2.h
319e_xcbc_d.o: ../../include/openssl/err.h ../../include/openssl/evp.h 303e_xcbc_d.o: ../../include/openssl/err.h ../../include/openssl/evp.h
320e_xcbc_d.o: ../../include/openssl/fips.h ../../include/openssl/lhash.h 304e_xcbc_d.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
321e_xcbc_d.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h 305e_xcbc_d.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
322e_xcbc_d.o: ../../include/openssl/opensslconf.h
323e_xcbc_d.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h 306e_xcbc_d.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
324e_xcbc_d.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h 307e_xcbc_d.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
325e_xcbc_d.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h 308e_xcbc_d.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
326e_xcbc_d.o: ../../include/openssl/ui_compat.h ../cryptlib.h e_xcbc_d.c 309e_xcbc_d.o: ../../include/openssl/ui_compat.h ../cryptlib.h e_xcbc_d.c
327enc_min.o: ../../e_os.h ../../include/openssl/asn1.h 310e_xcbc_d.o: evp_locl.h
328enc_min.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
329enc_min.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
330enc_min.o: ../../include/openssl/ec.h ../../include/openssl/ecdh.h
331enc_min.o: ../../include/openssl/ecdsa.h ../../include/openssl/engine.h
332enc_min.o: ../../include/openssl/err.h ../../include/openssl/evp.h
333enc_min.o: ../../include/openssl/fips.h ../../include/openssl/lhash.h
334enc_min.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
335enc_min.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
336enc_min.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h
337enc_min.o: ../../include/openssl/rand.h ../../include/openssl/safestack.h
338enc_min.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
339enc_min.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h
340enc_min.o: ../../include/openssl/x509_vfy.h ../cryptlib.h enc_min.c evp_locl.h
341encode.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h 311encode.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h
342encode.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 312encode.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
343encode.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h 313encode.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
344encode.o: ../../include/openssl/evp.h ../../include/openssl/fips.h 314encode.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h
345encode.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h 315encode.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
346encode.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h 316encode.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
347encode.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h 317encode.o: ../../include/openssl/ossl_typ.h ../../include/openssl/safestack.h
348encode.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h 318encode.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
349encode.o: ../../include/openssl/symhacks.h ../cryptlib.h encode.c 319encode.o: ../cryptlib.h encode.c
350evp_acnf.o: ../../e_os.h ../../include/openssl/asn1.h 320evp_acnf.o: ../../e_os.h ../../include/openssl/asn1.h
351evp_acnf.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h 321evp_acnf.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
352evp_acnf.o: ../../include/openssl/conf.h ../../include/openssl/crypto.h 322evp_acnf.o: ../../include/openssl/conf.h ../../include/openssl/crypto.h
353evp_acnf.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h 323evp_acnf.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
354evp_acnf.o: ../../include/openssl/evp.h ../../include/openssl/fips.h 324evp_acnf.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h
355evp_acnf.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h 325evp_acnf.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
356evp_acnf.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h 326evp_acnf.o: ../../include/openssl/opensslconf.h
357evp_acnf.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h 327evp_acnf.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
358evp_acnf.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h 328evp_acnf.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
359evp_acnf.o: ../../include/openssl/symhacks.h ../cryptlib.h evp_acnf.c 329evp_acnf.o: ../../include/openssl/symhacks.h ../cryptlib.h evp_acnf.c
360evp_cnf.o: ../../e_os.h ../../include/openssl/asn1.h
361evp_cnf.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
362evp_cnf.o: ../../include/openssl/conf.h ../../include/openssl/crypto.h
363evp_cnf.o: ../../include/openssl/dso.h ../../include/openssl/e_os2.h
364evp_cnf.o: ../../include/openssl/ec.h ../../include/openssl/ecdh.h
365evp_cnf.o: ../../include/openssl/ecdsa.h ../../include/openssl/err.h
366evp_cnf.o: ../../include/openssl/evp.h ../../include/openssl/fips.h
367evp_cnf.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
368evp_cnf.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
369evp_cnf.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
370evp_cnf.o: ../../include/openssl/pkcs7.h ../../include/openssl/safestack.h
371evp_cnf.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
372evp_cnf.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h
373evp_cnf.o: ../../include/openssl/x509_vfy.h ../../include/openssl/x509v3.h
374evp_cnf.o: ../cryptlib.h evp_cnf.c
375evp_enc.o: ../../e_os.h ../../include/openssl/asn1.h 330evp_enc.o: ../../e_os.h ../../include/openssl/asn1.h
376evp_enc.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h 331evp_enc.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
377evp_enc.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h 332evp_enc.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
378evp_enc.o: ../../include/openssl/ec.h ../../include/openssl/ecdh.h 333evp_enc.o: ../../include/openssl/ec.h ../../include/openssl/ecdh.h
379evp_enc.o: ../../include/openssl/ecdsa.h ../../include/openssl/engine.h 334evp_enc.o: ../../include/openssl/ecdsa.h ../../include/openssl/engine.h
380evp_enc.o: ../../include/openssl/err.h ../../include/openssl/evp.h 335evp_enc.o: ../../include/openssl/err.h ../../include/openssl/evp.h
381evp_enc.o: ../../include/openssl/fips.h ../../include/openssl/lhash.h 336evp_enc.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
382evp_enc.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h 337evp_enc.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
383evp_enc.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h 338evp_enc.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
384evp_enc.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h 339evp_enc.o: ../../include/openssl/pkcs7.h ../../include/openssl/rand.h
385evp_enc.o: ../../include/openssl/rand.h ../../include/openssl/safestack.h 340evp_enc.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
386evp_enc.o: ../../include/openssl/sha.h ../../include/openssl/stack.h 341evp_enc.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
387evp_enc.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h 342evp_enc.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
388evp_enc.o: ../../include/openssl/x509_vfy.h ../cryptlib.h evp_enc.c evp_locl.h 343evp_enc.o: ../cryptlib.h evp_enc.c evp_locl.h
389evp_err.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h 344evp_err.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
390evp_err.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h 345evp_err.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
391evp_err.o: ../../include/openssl/err.h ../../include/openssl/evp.h 346evp_err.o: ../../include/openssl/err.h ../../include/openssl/evp.h
392evp_err.o: ../../include/openssl/fips.h ../../include/openssl/lhash.h 347evp_err.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
393evp_err.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h 348evp_err.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
394evp_err.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h 349evp_err.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
395evp_err.o: ../../include/openssl/ossl_typ.h ../../include/openssl/safestack.h 350evp_err.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
396evp_err.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 351evp_err.o: ../../include/openssl/symhacks.h evp_err.c
397evp_err.o: evp_err.c
398evp_key.o: ../../e_os.h ../../include/openssl/asn1.h 352evp_key.o: ../../e_os.h ../../include/openssl/asn1.h
399evp_key.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h 353evp_key.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
400evp_key.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h 354evp_key.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
401evp_key.o: ../../include/openssl/ec.h ../../include/openssl/ecdh.h 355evp_key.o: ../../include/openssl/ec.h ../../include/openssl/ecdh.h
402evp_key.o: ../../include/openssl/ecdsa.h ../../include/openssl/err.h 356evp_key.o: ../../include/openssl/ecdsa.h ../../include/openssl/err.h
403evp_key.o: ../../include/openssl/evp.h ../../include/openssl/fips.h 357evp_key.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h
404evp_key.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h 358evp_key.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
405evp_key.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h 359evp_key.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
406evp_key.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h 360evp_key.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h
407evp_key.o: ../../include/openssl/pkcs7.h ../../include/openssl/safestack.h 361evp_key.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
408evp_key.o: ../../include/openssl/sha.h ../../include/openssl/stack.h 362evp_key.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
409evp_key.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h 363evp_key.o: ../../include/openssl/ui.h ../../include/openssl/x509.h
410evp_key.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h 364evp_key.o: ../../include/openssl/x509_vfy.h ../cryptlib.h evp_key.c
411evp_key.o: ../cryptlib.h evp_key.c
412evp_lib.o: ../../e_os.h ../../include/openssl/asn1.h 365evp_lib.o: ../../e_os.h ../../include/openssl/asn1.h
413evp_lib.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h 366evp_lib.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
414evp_lib.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h 367evp_lib.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
415evp_lib.o: ../../include/openssl/err.h ../../include/openssl/evp.h 368evp_lib.o: ../../include/openssl/err.h ../../include/openssl/evp.h
416evp_lib.o: ../../include/openssl/fips.h ../../include/openssl/lhash.h 369evp_lib.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
417evp_lib.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h 370evp_lib.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
418evp_lib.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h 371evp_lib.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
419evp_lib.o: ../../include/openssl/ossl_typ.h ../../include/openssl/safestack.h 372evp_lib.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
420evp_lib.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 373evp_lib.o: ../../include/openssl/symhacks.h ../cryptlib.h evp_lib.c
421evp_lib.o: ../cryptlib.h evp_lib.c
422evp_pbe.o: ../../e_os.h ../../include/openssl/asn1.h 374evp_pbe.o: ../../e_os.h ../../include/openssl/asn1.h
423evp_pbe.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h 375evp_pbe.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
424evp_pbe.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h 376evp_pbe.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
425evp_pbe.o: ../../include/openssl/ec.h ../../include/openssl/ecdh.h 377evp_pbe.o: ../../include/openssl/ec.h ../../include/openssl/ecdh.h
426evp_pbe.o: ../../include/openssl/ecdsa.h ../../include/openssl/err.h 378evp_pbe.o: ../../include/openssl/ecdsa.h ../../include/openssl/err.h
427evp_pbe.o: ../../include/openssl/evp.h ../../include/openssl/fips.h 379evp_pbe.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h
428evp_pbe.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h 380evp_pbe.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
429evp_pbe.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h 381evp_pbe.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
430evp_pbe.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h 382evp_pbe.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs12.h
431evp_pbe.o: ../../include/openssl/pkcs7.h ../../include/openssl/safestack.h 383evp_pbe.o: ../../include/openssl/pkcs7.h ../../include/openssl/safestack.h
432evp_pbe.o: ../../include/openssl/sha.h ../../include/openssl/stack.h 384evp_pbe.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
433evp_pbe.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h 385evp_pbe.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h
434evp_pbe.o: ../../include/openssl/x509_vfy.h ../cryptlib.h evp_pbe.c 386evp_pbe.o: ../../include/openssl/x509_vfy.h ../cryptlib.h evp_pbe.c
435evp_pkey.o: ../../e_os.h ../../include/openssl/asn1.h 387evp_pkey.o: ../../e_os.h ../../include/openssl/asn1.h
436evp_pkey.o: ../../include/openssl/bio.h ../../include/openssl/bn.h 388evp_pkey.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
437evp_pkey.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 389evp_pkey.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
438evp_pkey.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
439evp_pkey.o: ../../include/openssl/ec.h ../../include/openssl/ecdh.h 390evp_pkey.o: ../../include/openssl/ec.h ../../include/openssl/ecdh.h
440evp_pkey.o: ../../include/openssl/ecdsa.h ../../include/openssl/err.h 391evp_pkey.o: ../../include/openssl/ecdsa.h ../../include/openssl/err.h
441evp_pkey.o: ../../include/openssl/evp.h ../../include/openssl/fips.h 392evp_pkey.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h
442evp_pkey.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h 393evp_pkey.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
443evp_pkey.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h 394evp_pkey.o: ../../include/openssl/opensslconf.h
444evp_pkey.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h 395evp_pkey.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
445evp_pkey.o: ../../include/openssl/pkcs7.h ../../include/openssl/rand.h 396evp_pkey.o: ../../include/openssl/pkcs7.h ../../include/openssl/rand.h
446evp_pkey.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h 397evp_pkey.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
447evp_pkey.o: ../../include/openssl/sha.h ../../include/openssl/stack.h 398evp_pkey.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
448evp_pkey.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h 399evp_pkey.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
449evp_pkey.o: ../../include/openssl/x509_vfy.h ../cryptlib.h evp_pkey.c 400evp_pkey.o: ../asn1/asn1_locl.h ../cryptlib.h evp_pkey.c
450m_dss.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h 401m_dss.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h
451m_dss.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 402m_dss.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
452m_dss.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h 403m_dss.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
453m_dss.o: ../../include/openssl/ec.h ../../include/openssl/ecdh.h 404m_dss.o: ../../include/openssl/ec.h ../../include/openssl/ecdh.h
454m_dss.o: ../../include/openssl/ecdsa.h ../../include/openssl/err.h 405m_dss.o: ../../include/openssl/ecdsa.h ../../include/openssl/err.h
455m_dss.o: ../../include/openssl/evp.h ../../include/openssl/fips.h 406m_dss.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h
456m_dss.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h 407m_dss.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
457m_dss.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h 408m_dss.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
458m_dss.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h 409m_dss.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h
459m_dss.o: ../../include/openssl/pkcs7.h ../../include/openssl/safestack.h 410m_dss.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
460m_dss.o: ../../include/openssl/sha.h ../../include/openssl/stack.h 411m_dss.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
461m_dss.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h 412m_dss.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
462m_dss.o: ../../include/openssl/x509_vfy.h ../cryptlib.h m_dss.c 413m_dss.o: ../cryptlib.h m_dss.c
463m_dss1.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h 414m_dss1.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h
464m_dss1.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 415m_dss1.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
465m_dss1.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h 416m_dss1.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
466m_dss1.o: ../../include/openssl/ec.h ../../include/openssl/ecdh.h 417m_dss1.o: ../../include/openssl/ec.h ../../include/openssl/ecdh.h
467m_dss1.o: ../../include/openssl/ecdsa.h ../../include/openssl/err.h 418m_dss1.o: ../../include/openssl/ecdsa.h ../../include/openssl/err.h
468m_dss1.o: ../../include/openssl/evp.h ../../include/openssl/fips.h 419m_dss1.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h
469m_dss1.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h 420m_dss1.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
470m_dss1.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h 421m_dss1.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
471m_dss1.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h 422m_dss1.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h
472m_dss1.o: ../../include/openssl/pkcs7.h ../../include/openssl/safestack.h 423m_dss1.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
473m_dss1.o: ../../include/openssl/sha.h ../../include/openssl/stack.h 424m_dss1.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
474m_dss1.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h 425m_dss1.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
475m_dss1.o: ../../include/openssl/x509_vfy.h ../cryptlib.h m_dss1.c 426m_dss1.o: ../cryptlib.h m_dss1.c
476m_ecdsa.o: ../../e_os.h ../../include/openssl/asn1.h 427m_ecdsa.o: ../../e_os.h ../../include/openssl/asn1.h
477m_ecdsa.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h 428m_ecdsa.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
478m_ecdsa.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h 429m_ecdsa.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
479m_ecdsa.o: ../../include/openssl/ec.h ../../include/openssl/ecdh.h 430m_ecdsa.o: ../../include/openssl/ec.h ../../include/openssl/ecdh.h
480m_ecdsa.o: ../../include/openssl/ecdsa.h ../../include/openssl/err.h 431m_ecdsa.o: ../../include/openssl/ecdsa.h ../../include/openssl/err.h
481m_ecdsa.o: ../../include/openssl/evp.h ../../include/openssl/fips.h 432m_ecdsa.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h
482m_ecdsa.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h 433m_ecdsa.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
483m_ecdsa.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h 434m_ecdsa.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
484m_ecdsa.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h 435m_ecdsa.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h
485m_ecdsa.o: ../../include/openssl/pkcs7.h ../../include/openssl/safestack.h 436m_ecdsa.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
486m_ecdsa.o: ../../include/openssl/sha.h ../../include/openssl/stack.h 437m_ecdsa.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
487m_ecdsa.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h 438m_ecdsa.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
488m_ecdsa.o: ../../include/openssl/x509_vfy.h ../cryptlib.h m_ecdsa.c 439m_ecdsa.o: ../cryptlib.h m_ecdsa.c
489m_md2.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h 440m_md2.o: ../../e_os.h ../../include/openssl/bio.h
490m_md2.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 441m_md2.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
491m_md2.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h 442m_md2.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
492m_md2.o: ../../include/openssl/ecdh.h ../../include/openssl/ecdsa.h 443m_md2.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
493m_md2.o: ../../include/openssl/err.h ../../include/openssl/evp.h
494m_md2.o: ../../include/openssl/fips.h ../../include/openssl/lhash.h
495m_md2.o: ../../include/openssl/md2.h ../../include/openssl/obj_mac.h
496m_md2.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
497m_md2.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h 444m_md2.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
498m_md2.o: ../../include/openssl/pkcs7.h ../../include/openssl/rsa.h 445m_md2.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
499m_md2.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h 446m_md2.o: ../../include/openssl/symhacks.h ../cryptlib.h m_md2.c
500m_md2.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
501m_md2.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
502m_md2.o: ../cryptlib.h evp_locl.h m_md2.c
503m_md4.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h 447m_md4.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h
504m_md4.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 448m_md4.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
505m_md4.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h 449m_md4.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h
506m_md4.o: ../../include/openssl/ecdh.h ../../include/openssl/ecdsa.h 450m_md4.o: ../../include/openssl/ecdh.h ../../include/openssl/ecdsa.h
507m_md4.o: ../../include/openssl/err.h ../../include/openssl/evp.h 451m_md4.o: ../../include/openssl/err.h ../../include/openssl/evp.h
508m_md4.o: ../../include/openssl/fips.h ../../include/openssl/lhash.h 452m_md4.o: ../../include/openssl/lhash.h ../../include/openssl/md4.h
509m_md4.o: ../../include/openssl/md4.h ../../include/openssl/obj_mac.h 453m_md4.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
510m_md4.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h 454m_md4.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
511m_md4.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h 455m_md4.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h
512m_md4.o: ../../include/openssl/pkcs7.h ../../include/openssl/rsa.h 456m_md4.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
513m_md4.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h 457m_md4.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
514m_md4.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 458m_md4.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h
515m_md4.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h 459m_md4.o: ../../include/openssl/x509_vfy.h ../cryptlib.h m_md4.c
516m_md4.o: ../cryptlib.h evp_locl.h m_md4.c
517m_md5.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h 460m_md5.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h
518m_md5.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 461m_md5.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
519m_md5.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h 462m_md5.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h
520m_md5.o: ../../include/openssl/ecdh.h ../../include/openssl/ecdsa.h 463m_md5.o: ../../include/openssl/ecdh.h ../../include/openssl/ecdsa.h
521m_md5.o: ../../include/openssl/err.h ../../include/openssl/evp.h 464m_md5.o: ../../include/openssl/err.h ../../include/openssl/evp.h
522m_md5.o: ../../include/openssl/fips.h ../../include/openssl/lhash.h 465m_md5.o: ../../include/openssl/lhash.h ../../include/openssl/md5.h
523m_md5.o: ../../include/openssl/md5.h ../../include/openssl/obj_mac.h 466m_md5.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
524m_md5.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h 467m_md5.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
525m_md5.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h 468m_md5.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h
526m_md5.o: ../../include/openssl/pkcs7.h ../../include/openssl/rsa.h 469m_md5.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
527m_md5.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h 470m_md5.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
528m_md5.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 471m_md5.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h
529m_md5.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h 472m_md5.o: ../../include/openssl/x509_vfy.h ../cryptlib.h m_md5.c
530m_md5.o: ../cryptlib.h evp_locl.h m_md5.c 473m_mdc2.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h
531m_mdc2.o: ../../e_os.h ../../include/openssl/bio.h
532m_mdc2.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 474m_mdc2.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
533m_mdc2.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h 475m_mdc2.o: ../../include/openssl/des.h ../../include/openssl/des_old.h
534m_mdc2.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h 476m_mdc2.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h
535m_mdc2.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h 477m_mdc2.o: ../../include/openssl/ecdh.h ../../include/openssl/ecdsa.h
536m_mdc2.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h 478m_mdc2.o: ../../include/openssl/err.h ../../include/openssl/evp.h
537m_mdc2.o: ../../include/openssl/symhacks.h ../cryptlib.h evp_locl.h m_mdc2.c 479m_mdc2.o: ../../include/openssl/lhash.h ../../include/openssl/mdc2.h
480m_mdc2.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
481m_mdc2.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
482m_mdc2.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h
483m_mdc2.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
484m_mdc2.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
485m_mdc2.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
486m_mdc2.o: ../../include/openssl/ui_compat.h ../../include/openssl/x509.h
487m_mdc2.o: ../../include/openssl/x509_vfy.h ../cryptlib.h m_mdc2.c
538m_null.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h 488m_null.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h
539m_null.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 489m_null.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
540m_null.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h 490m_null.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h
541m_null.o: ../../include/openssl/ecdh.h ../../include/openssl/ecdsa.h 491m_null.o: ../../include/openssl/ecdh.h ../../include/openssl/ecdsa.h
542m_null.o: ../../include/openssl/err.h ../../include/openssl/evp.h 492m_null.o: ../../include/openssl/err.h ../../include/openssl/evp.h
543m_null.o: ../../include/openssl/fips.h ../../include/openssl/lhash.h 493m_null.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
544m_null.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h 494m_null.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
545m_null.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h 495m_null.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
546m_null.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h 496m_null.o: ../../include/openssl/pkcs7.h ../../include/openssl/safestack.h
547m_null.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h 497m_null.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
548m_null.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 498m_null.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h
549m_null.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h 499m_null.o: ../../include/openssl/x509_vfy.h ../cryptlib.h m_null.c
550m_null.o: ../cryptlib.h m_null.c
551m_ripemd.o: ../../e_os.h ../../include/openssl/asn1.h 500m_ripemd.o: ../../e_os.h ../../include/openssl/asn1.h
552m_ripemd.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h 501m_ripemd.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
553m_ripemd.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h 502m_ripemd.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
554m_ripemd.o: ../../include/openssl/ec.h ../../include/openssl/ecdh.h 503m_ripemd.o: ../../include/openssl/ec.h ../../include/openssl/ecdh.h
555m_ripemd.o: ../../include/openssl/ecdsa.h ../../include/openssl/err.h 504m_ripemd.o: ../../include/openssl/ecdsa.h ../../include/openssl/err.h
556m_ripemd.o: ../../include/openssl/evp.h ../../include/openssl/fips.h 505m_ripemd.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h
557m_ripemd.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h 506m_ripemd.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
558m_ripemd.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h 507m_ripemd.o: ../../include/openssl/opensslconf.h
559m_ripemd.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h 508m_ripemd.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
560m_ripemd.o: ../../include/openssl/pkcs7.h ../../include/openssl/ripemd.h 509m_ripemd.o: ../../include/openssl/pkcs7.h ../../include/openssl/ripemd.h
561m_ripemd.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h 510m_ripemd.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
@@ -567,62 +516,87 @@ m_sha.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
567m_sha.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h 516m_sha.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h
568m_sha.o: ../../include/openssl/ecdh.h ../../include/openssl/ecdsa.h 517m_sha.o: ../../include/openssl/ecdh.h ../../include/openssl/ecdsa.h
569m_sha.o: ../../include/openssl/err.h ../../include/openssl/evp.h 518m_sha.o: ../../include/openssl/err.h ../../include/openssl/evp.h
570m_sha.o: ../../include/openssl/fips.h ../../include/openssl/lhash.h 519m_sha.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
571m_sha.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h 520m_sha.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
572m_sha.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h 521m_sha.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
573m_sha.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h 522m_sha.o: ../../include/openssl/pkcs7.h ../../include/openssl/rsa.h
574m_sha.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h 523m_sha.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
575m_sha.o: ../../include/openssl/sha.h ../../include/openssl/stack.h 524m_sha.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
576m_sha.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h 525m_sha.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
577m_sha.o: ../../include/openssl/x509_vfy.h ../cryptlib.h evp_locl.h m_sha.c 526m_sha.o: ../cryptlib.h m_sha.c
578m_sha1.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h 527m_sha1.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h
579m_sha1.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 528m_sha1.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
580m_sha1.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h 529m_sha1.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h
581m_sha1.o: ../../include/openssl/ecdh.h ../../include/openssl/ecdsa.h 530m_sha1.o: ../../include/openssl/ecdh.h ../../include/openssl/ecdsa.h
582m_sha1.o: ../../include/openssl/err.h ../../include/openssl/evp.h 531m_sha1.o: ../../include/openssl/err.h ../../include/openssl/evp.h
583m_sha1.o: ../../include/openssl/fips.h ../../include/openssl/lhash.h 532m_sha1.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
584m_sha1.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h 533m_sha1.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
585m_sha1.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h 534m_sha1.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
586m_sha1.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h 535m_sha1.o: ../../include/openssl/pkcs7.h ../../include/openssl/rsa.h
587m_sha1.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h 536m_sha1.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
588m_sha1.o: ../../include/openssl/sha.h ../../include/openssl/stack.h 537m_sha1.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
589m_sha1.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h 538m_sha1.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
590m_sha1.o: ../../include/openssl/x509_vfy.h ../cryptlib.h m_sha1.c 539m_sha1.o: ../cryptlib.h m_sha1.c
540m_sigver.o: ../../e_os.h ../../include/openssl/asn1.h
541m_sigver.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
542m_sigver.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
543m_sigver.o: ../../include/openssl/ec.h ../../include/openssl/ecdh.h
544m_sigver.o: ../../include/openssl/ecdsa.h ../../include/openssl/err.h
545m_sigver.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h
546m_sigver.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
547m_sigver.o: ../../include/openssl/opensslconf.h
548m_sigver.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
549m_sigver.o: ../../include/openssl/pkcs7.h ../../include/openssl/safestack.h
550m_sigver.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
551m_sigver.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h
552m_sigver.o: ../../include/openssl/x509_vfy.h ../cryptlib.h evp_locl.h
553m_sigver.o: m_sigver.c
554m_wp.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h
555m_wp.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
556m_wp.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h
557m_wp.o: ../../include/openssl/ecdh.h ../../include/openssl/ecdsa.h
558m_wp.o: ../../include/openssl/err.h ../../include/openssl/evp.h
559m_wp.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
560m_wp.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
561m_wp.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
562m_wp.o: ../../include/openssl/pkcs7.h ../../include/openssl/safestack.h
563m_wp.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
564m_wp.o: ../../include/openssl/symhacks.h ../../include/openssl/whrlpool.h
565m_wp.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
566m_wp.o: ../cryptlib.h m_wp.c
591names.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h 567names.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h
592names.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 568names.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
593names.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h 569names.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h
594names.o: ../../include/openssl/ecdh.h ../../include/openssl/ecdsa.h 570names.o: ../../include/openssl/ecdh.h ../../include/openssl/ecdsa.h
595names.o: ../../include/openssl/err.h ../../include/openssl/evp.h 571names.o: ../../include/openssl/err.h ../../include/openssl/evp.h
596names.o: ../../include/openssl/fips.h ../../include/openssl/lhash.h 572names.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
597names.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h 573names.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
598names.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h 574names.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
599names.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h 575names.o: ../../include/openssl/pkcs7.h ../../include/openssl/safestack.h
600names.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h 576names.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
601names.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 577names.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h
602names.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h 578names.o: ../../include/openssl/x509_vfy.h ../cryptlib.h names.c
603names.o: ../cryptlib.h names.c
604p5_crpt.o: ../../e_os.h ../../include/openssl/asn1.h 579p5_crpt.o: ../../e_os.h ../../include/openssl/asn1.h
605p5_crpt.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h 580p5_crpt.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
606p5_crpt.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h 581p5_crpt.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
607p5_crpt.o: ../../include/openssl/ec.h ../../include/openssl/ecdh.h 582p5_crpt.o: ../../include/openssl/ec.h ../../include/openssl/ecdh.h
608p5_crpt.o: ../../include/openssl/ecdsa.h ../../include/openssl/err.h 583p5_crpt.o: ../../include/openssl/ecdsa.h ../../include/openssl/err.h
609p5_crpt.o: ../../include/openssl/evp.h ../../include/openssl/fips.h 584p5_crpt.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h
610p5_crpt.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h 585p5_crpt.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
611p5_crpt.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h 586p5_crpt.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
612p5_crpt.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h 587p5_crpt.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h
613p5_crpt.o: ../../include/openssl/pkcs7.h ../../include/openssl/safestack.h 588p5_crpt.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
614p5_crpt.o: ../../include/openssl/sha.h ../../include/openssl/stack.h 589p5_crpt.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
615p5_crpt.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h 590p5_crpt.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
616p5_crpt.o: ../../include/openssl/x509_vfy.h ../cryptlib.h p5_crpt.c 591p5_crpt.o: ../cryptlib.h p5_crpt.c
617p5_crpt2.o: ../../e_os.h ../../include/openssl/asn1.h 592p5_crpt2.o: ../../e_os.h ../../include/openssl/asn1.h
618p5_crpt2.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h 593p5_crpt2.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
619p5_crpt2.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h 594p5_crpt2.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
620p5_crpt2.o: ../../include/openssl/ec.h ../../include/openssl/ecdh.h 595p5_crpt2.o: ../../include/openssl/ec.h ../../include/openssl/ecdh.h
621p5_crpt2.o: ../../include/openssl/ecdsa.h ../../include/openssl/err.h 596p5_crpt2.o: ../../include/openssl/ecdsa.h ../../include/openssl/err.h
622p5_crpt2.o: ../../include/openssl/evp.h ../../include/openssl/fips.h 597p5_crpt2.o: ../../include/openssl/evp.h ../../include/openssl/hmac.h
623p5_crpt2.o: ../../include/openssl/hmac.h ../../include/openssl/lhash.h 598p5_crpt2.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
624p5_crpt2.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h 599p5_crpt2.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
625p5_crpt2.o: ../../include/openssl/opensslconf.h
626p5_crpt2.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h 600p5_crpt2.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
627p5_crpt2.o: ../../include/openssl/pkcs7.h ../../include/openssl/safestack.h 601p5_crpt2.o: ../../include/openssl/pkcs7.h ../../include/openssl/safestack.h
628p5_crpt2.o: ../../include/openssl/sha.h ../../include/openssl/stack.h 602p5_crpt2.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
@@ -633,37 +607,35 @@ p_dec.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
633p_dec.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h 607p_dec.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h
634p_dec.o: ../../include/openssl/ecdh.h ../../include/openssl/ecdsa.h 608p_dec.o: ../../include/openssl/ecdh.h ../../include/openssl/ecdsa.h
635p_dec.o: ../../include/openssl/err.h ../../include/openssl/evp.h 609p_dec.o: ../../include/openssl/err.h ../../include/openssl/evp.h
636p_dec.o: ../../include/openssl/fips.h ../../include/openssl/lhash.h 610p_dec.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
637p_dec.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h 611p_dec.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
638p_dec.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h 612p_dec.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
639p_dec.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h 613p_dec.o: ../../include/openssl/pkcs7.h ../../include/openssl/rand.h
640p_dec.o: ../../include/openssl/rand.h ../../include/openssl/rsa.h 614p_dec.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
641p_dec.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h 615p_dec.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
642p_dec.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 616p_dec.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h
643p_dec.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h 617p_dec.o: ../../include/openssl/x509_vfy.h ../cryptlib.h p_dec.c
644p_dec.o: ../cryptlib.h p_dec.c
645p_enc.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h 618p_enc.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h
646p_enc.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 619p_enc.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
647p_enc.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h 620p_enc.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h
648p_enc.o: ../../include/openssl/ecdh.h ../../include/openssl/ecdsa.h 621p_enc.o: ../../include/openssl/ecdh.h ../../include/openssl/ecdsa.h
649p_enc.o: ../../include/openssl/err.h ../../include/openssl/evp.h 622p_enc.o: ../../include/openssl/err.h ../../include/openssl/evp.h
650p_enc.o: ../../include/openssl/fips.h ../../include/openssl/lhash.h 623p_enc.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
651p_enc.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h 624p_enc.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
652p_enc.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h 625p_enc.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
653p_enc.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h 626p_enc.o: ../../include/openssl/pkcs7.h ../../include/openssl/rand.h
654p_enc.o: ../../include/openssl/rand.h ../../include/openssl/rsa.h 627p_enc.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
655p_enc.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h 628p_enc.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
656p_enc.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 629p_enc.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h
657p_enc.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h 630p_enc.o: ../../include/openssl/x509_vfy.h ../cryptlib.h p_enc.c
658p_enc.o: ../cryptlib.h p_enc.c
659p_lib.o: ../../e_os.h ../../include/openssl/asn1.h 631p_lib.o: ../../e_os.h ../../include/openssl/asn1.h
660p_lib.o: ../../include/openssl/asn1_mac.h ../../include/openssl/bio.h 632p_lib.o: ../../include/openssl/asn1_mac.h ../../include/openssl/bio.h
661p_lib.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h 633p_lib.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
662p_lib.o: ../../include/openssl/crypto.h ../../include/openssl/dh.h 634p_lib.o: ../../include/openssl/crypto.h ../../include/openssl/dh.h
663p_lib.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h 635p_lib.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
664p_lib.o: ../../include/openssl/ec.h ../../include/openssl/ecdh.h 636p_lib.o: ../../include/openssl/ec.h ../../include/openssl/ecdh.h
665p_lib.o: ../../include/openssl/ecdsa.h ../../include/openssl/err.h 637p_lib.o: ../../include/openssl/ecdsa.h ../../include/openssl/engine.h
666p_lib.o: ../../include/openssl/evp.h ../../include/openssl/fips.h 638p_lib.o: ../../include/openssl/err.h ../../include/openssl/evp.h
667p_lib.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h 639p_lib.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
668p_lib.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h 640p_lib.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
669p_lib.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h 641p_lib.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
@@ -671,57 +643,91 @@ p_lib.o: ../../include/openssl/pkcs7.h ../../include/openssl/rsa.h
671p_lib.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h 643p_lib.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
672p_lib.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 644p_lib.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
673p_lib.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h 645p_lib.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
674p_lib.o: ../cryptlib.h p_lib.c 646p_lib.o: ../asn1/asn1_locl.h ../cryptlib.h p_lib.c
675p_open.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h 647p_open.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h
676p_open.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 648p_open.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
677p_open.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h 649p_open.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h
678p_open.o: ../../include/openssl/ecdh.h ../../include/openssl/ecdsa.h 650p_open.o: ../../include/openssl/ecdh.h ../../include/openssl/ecdsa.h
679p_open.o: ../../include/openssl/err.h ../../include/openssl/evp.h 651p_open.o: ../../include/openssl/err.h ../../include/openssl/evp.h
680p_open.o: ../../include/openssl/fips.h ../../include/openssl/lhash.h 652p_open.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
681p_open.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h 653p_open.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
682p_open.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h 654p_open.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
683p_open.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h 655p_open.o: ../../include/openssl/pkcs7.h ../../include/openssl/rsa.h
684p_open.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h 656p_open.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
685p_open.o: ../../include/openssl/sha.h ../../include/openssl/stack.h 657p_open.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
686p_open.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h 658p_open.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
687p_open.o: ../../include/openssl/x509_vfy.h ../cryptlib.h p_open.c 659p_open.o: ../cryptlib.h p_open.c
688p_seal.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h 660p_seal.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h
689p_seal.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 661p_seal.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
690p_seal.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h 662p_seal.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h
691p_seal.o: ../../include/openssl/ecdh.h ../../include/openssl/ecdsa.h 663p_seal.o: ../../include/openssl/ecdh.h ../../include/openssl/ecdsa.h
692p_seal.o: ../../include/openssl/err.h ../../include/openssl/evp.h 664p_seal.o: ../../include/openssl/err.h ../../include/openssl/evp.h
693p_seal.o: ../../include/openssl/fips.h ../../include/openssl/lhash.h 665p_seal.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
694p_seal.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h 666p_seal.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
695p_seal.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h 667p_seal.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
696p_seal.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h 668p_seal.o: ../../include/openssl/pkcs7.h ../../include/openssl/rand.h
697p_seal.o: ../../include/openssl/rand.h ../../include/openssl/rsa.h 669p_seal.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
698p_seal.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h 670p_seal.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
699p_seal.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 671p_seal.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h
700p_seal.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h 672p_seal.o: ../../include/openssl/x509_vfy.h ../cryptlib.h p_seal.c
701p_seal.o: ../cryptlib.h p_seal.c
702p_sign.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h 673p_sign.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h
703p_sign.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 674p_sign.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
704p_sign.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h 675p_sign.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h
705p_sign.o: ../../include/openssl/ecdh.h ../../include/openssl/ecdsa.h 676p_sign.o: ../../include/openssl/ecdh.h ../../include/openssl/ecdsa.h
706p_sign.o: ../../include/openssl/err.h ../../include/openssl/evp.h 677p_sign.o: ../../include/openssl/err.h ../../include/openssl/evp.h
707p_sign.o: ../../include/openssl/fips.h ../../include/openssl/lhash.h 678p_sign.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
708p_sign.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h 679p_sign.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
709p_sign.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h 680p_sign.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
710p_sign.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h 681p_sign.o: ../../include/openssl/pkcs7.h ../../include/openssl/safestack.h
711p_sign.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h 682p_sign.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
712p_sign.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 683p_sign.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h
713p_sign.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h 684p_sign.o: ../../include/openssl/x509_vfy.h ../cryptlib.h p_sign.c
714p_sign.o: ../cryptlib.h p_sign.c
715p_verify.o: ../../e_os.h ../../include/openssl/asn1.h 685p_verify.o: ../../e_os.h ../../include/openssl/asn1.h
716p_verify.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h 686p_verify.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
717p_verify.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h 687p_verify.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
718p_verify.o: ../../include/openssl/ec.h ../../include/openssl/ecdh.h 688p_verify.o: ../../include/openssl/ec.h ../../include/openssl/ecdh.h
719p_verify.o: ../../include/openssl/ecdsa.h ../../include/openssl/err.h 689p_verify.o: ../../include/openssl/ecdsa.h ../../include/openssl/err.h
720p_verify.o: ../../include/openssl/evp.h ../../include/openssl/fips.h 690p_verify.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h
721p_verify.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h 691p_verify.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
722p_verify.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h 692p_verify.o: ../../include/openssl/opensslconf.h
723p_verify.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h 693p_verify.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
724p_verify.o: ../../include/openssl/pkcs7.h ../../include/openssl/safestack.h 694p_verify.o: ../../include/openssl/pkcs7.h ../../include/openssl/safestack.h
725p_verify.o: ../../include/openssl/sha.h ../../include/openssl/stack.h 695p_verify.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
726p_verify.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h 696p_verify.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h
727p_verify.o: ../../include/openssl/x509_vfy.h ../cryptlib.h p_verify.c 697p_verify.o: ../../include/openssl/x509_vfy.h ../cryptlib.h p_verify.c
698pmeth_fn.o: ../../e_os.h ../../include/openssl/asn1.h
699pmeth_fn.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
700pmeth_fn.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
701pmeth_fn.o: ../../include/openssl/err.h ../../include/openssl/evp.h
702pmeth_fn.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
703pmeth_fn.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
704pmeth_fn.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
705pmeth_fn.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
706pmeth_fn.o: ../../include/openssl/symhacks.h ../cryptlib.h evp_locl.h
707pmeth_fn.o: pmeth_fn.c
708pmeth_gn.o: ../../e_os.h ../../include/openssl/asn1.h
709pmeth_gn.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
710pmeth_gn.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
711pmeth_gn.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
712pmeth_gn.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h
713pmeth_gn.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
714pmeth_gn.o: ../../include/openssl/opensslconf.h
715pmeth_gn.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
716pmeth_gn.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
717pmeth_gn.o: ../../include/openssl/symhacks.h ../cryptlib.h evp_locl.h
718pmeth_gn.o: pmeth_gn.c
719pmeth_lib.o: ../../e_os.h ../../include/openssl/asn1.h
720pmeth_lib.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
721pmeth_lib.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
722pmeth_lib.o: ../../include/openssl/ec.h ../../include/openssl/ecdh.h
723pmeth_lib.o: ../../include/openssl/ecdsa.h ../../include/openssl/engine.h
724pmeth_lib.o: ../../include/openssl/err.h ../../include/openssl/evp.h
725pmeth_lib.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
726pmeth_lib.o: ../../include/openssl/objects.h
727pmeth_lib.o: ../../include/openssl/opensslconf.h
728pmeth_lib.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
729pmeth_lib.o: ../../include/openssl/pkcs7.h ../../include/openssl/safestack.h
730pmeth_lib.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
731pmeth_lib.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h
732pmeth_lib.o: ../../include/openssl/x509_vfy.h ../asn1/asn1_locl.h ../cryptlib.h
733pmeth_lib.o: evp_locl.h pmeth_lib.c
diff --git a/src/lib/libcrypto/evp/Makefile.ssl b/src/lib/libcrypto/evp/Makefile.ssl
deleted file mode 100644
index f33aebd33a..0000000000
--- a/src/lib/libcrypto/evp/Makefile.ssl
+++ /dev/null
@@ -1,1059 +0,0 @@
1#
2# SSLeay/crypto/evp/Makefile
3#
4
5DIR= evp
6TOP= ../..
7CC= cc
8INCLUDES= -I.. -I$(TOP) -I../../include
9CFLAG=-g
10INSTALL_PREFIX=
11OPENSSLDIR= /usr/local/ssl
12INSTALLTOP=/usr/local/ssl
13MAKE= make -f Makefile.ssl
14MAKEDEPPROG= makedepend
15MAKEDEPEND= $(TOP)/util/domd $(TOP) -MD $(MAKEDEPPROG)
16MAKEFILE= Makefile.ssl
17AR= ar r
18
19CFLAGS= $(INCLUDES) $(CFLAG)
20
21GENERAL=Makefile
22TEST=evp_test.c
23TESTDATA=evptests.txt
24APPS=
25
26LIB=$(TOP)/libcrypto.a
27LIBSRC= encode.c digest.c evp_enc.c evp_key.c evp_acnf.c \
28 e_des.c e_bf.c e_idea.c e_des3.c \
29 e_rc4.c e_aes.c names.c \
30 e_xcbc_d.c e_rc2.c e_cast.c e_rc5.c \
31 m_null.c m_md2.c m_md4.c m_md5.c m_sha.c m_sha1.c \
32 m_dss.c m_dss1.c m_mdc2.c m_ripemd.c \
33 p_open.c p_seal.c p_sign.c p_verify.c p_lib.c p_enc.c p_dec.c \
34 bio_md.c bio_b64.c bio_enc.c evp_err.c e_null.c \
35 c_all.c c_allc.c c_alld.c evp_lib.c bio_ok.c \
36 evp_pkey.c evp_pbe.c p5_crpt.c p5_crpt2.c
37
38LIBOBJ= encode.o digest.o evp_enc.o evp_key.o evp_acnf.o \
39 e_des.o e_bf.o e_idea.o e_des3.o \
40 e_rc4.o e_aes.o names.o \
41 e_xcbc_d.o e_rc2.o e_cast.o e_rc5.o \
42 m_null.o m_md2.o m_md4.o m_md5.o m_sha.o m_sha1.o \
43 m_dss.o m_dss1.o m_mdc2.o m_ripemd.o \
44 p_open.o p_seal.o p_sign.o p_verify.o p_lib.o p_enc.o p_dec.o \
45 bio_md.o bio_b64.o bio_enc.o evp_err.o e_null.o \
46 c_all.o c_allc.o c_alld.o evp_lib.o bio_ok.o \
47 evp_pkey.o evp_pbe.o p5_crpt.o p5_crpt2.o
48
49SRC= $(LIBSRC)
50
51EXHEADER= evp.h
52HEADER= $(EXHEADER)
53
54ALL= $(GENERAL) $(SRC) $(HEADER)
55
56top:
57 (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all)
58
59all: lib
60
61lib: $(LIBOBJ)
62 $(AR) $(LIB) $(LIBOBJ)
63 $(RANLIB) $(LIB) || echo Never mind.
64 @touch lib
65
66files:
67 $(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO
68
69links:
70 @sh $(TOP)/util/point.sh Makefile.ssl Makefile
71 @$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER)
72 @$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST)
73 cp $(TESTDATA) ../../test
74 @$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS)
75
76install:
77 @for i in $(EXHEADER) ; \
78 do \
79 (cp $$i $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i; \
80 chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i ); \
81 done;
82
83tags:
84 ctags $(SRC)
85
86tests:
87
88lint:
89 lint -DLINT $(INCLUDES) $(SRC)>fluff
90
91depend:
92 $(MAKEDEPEND) -- $(CFLAG) $(INCLUDES) $(DEPFLAG) -- $(LIBSRC)
93
94dclean:
95 $(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
96 mv -f Makefile.new $(MAKEFILE)
97
98clean:
99 rm -f *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff
100
101# DO NOT DELETE THIS LINE -- make depend depends on it.
102
103bio_b64.o: ../../e_os.h ../../include/openssl/aes.h
104bio_b64.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
105bio_b64.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
106bio_b64.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
107bio_b64.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
108bio_b64.o: ../../include/openssl/des_old.h ../../include/openssl/dh.h
109bio_b64.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
110bio_b64.o: ../../include/openssl/err.h ../../include/openssl/evp.h
111bio_b64.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h
112bio_b64.o: ../../include/openssl/md2.h ../../include/openssl/md4.h
113bio_b64.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
114bio_b64.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
115bio_b64.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
116bio_b64.o: ../../include/openssl/ossl_typ.h ../../include/openssl/rc2.h
117bio_b64.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
118bio_b64.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
119bio_b64.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
120bio_b64.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
121bio_b64.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
122bio_b64.o: ../cryptlib.h bio_b64.c
123bio_enc.o: ../../e_os.h ../../include/openssl/aes.h
124bio_enc.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
125bio_enc.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
126bio_enc.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
127bio_enc.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
128bio_enc.o: ../../include/openssl/des_old.h ../../include/openssl/dh.h
129bio_enc.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
130bio_enc.o: ../../include/openssl/err.h ../../include/openssl/evp.h
131bio_enc.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h
132bio_enc.o: ../../include/openssl/md2.h ../../include/openssl/md4.h
133bio_enc.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
134bio_enc.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
135bio_enc.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
136bio_enc.o: ../../include/openssl/ossl_typ.h ../../include/openssl/rc2.h
137bio_enc.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
138bio_enc.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
139bio_enc.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
140bio_enc.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
141bio_enc.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
142bio_enc.o: ../cryptlib.h bio_enc.c
143bio_md.o: ../../e_os.h ../../include/openssl/aes.h ../../include/openssl/asn1.h
144bio_md.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h
145bio_md.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
146bio_md.o: ../../include/openssl/cast.h ../../include/openssl/crypto.h
147bio_md.o: ../../include/openssl/des.h ../../include/openssl/des_old.h
148bio_md.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
149bio_md.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
150bio_md.o: ../../include/openssl/evp.h ../../include/openssl/idea.h
151bio_md.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h
152bio_md.o: ../../include/openssl/md4.h ../../include/openssl/md5.h
153bio_md.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h
154bio_md.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
155bio_md.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
156bio_md.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h
157bio_md.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h
158bio_md.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
159bio_md.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
160bio_md.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
161bio_md.o: ../../include/openssl/ui_compat.h ../cryptlib.h bio_md.c
162bio_ok.o: ../../e_os.h ../../include/openssl/aes.h ../../include/openssl/asn1.h
163bio_ok.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h
164bio_ok.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
165bio_ok.o: ../../include/openssl/cast.h ../../include/openssl/crypto.h
166bio_ok.o: ../../include/openssl/des.h ../../include/openssl/des_old.h
167bio_ok.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
168bio_ok.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
169bio_ok.o: ../../include/openssl/evp.h ../../include/openssl/idea.h
170bio_ok.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h
171bio_ok.o: ../../include/openssl/md4.h ../../include/openssl/md5.h
172bio_ok.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h
173bio_ok.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
174bio_ok.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
175bio_ok.o: ../../include/openssl/rand.h ../../include/openssl/rc2.h
176bio_ok.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
177bio_ok.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
178bio_ok.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
179bio_ok.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
180bio_ok.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
181bio_ok.o: ../cryptlib.h bio_ok.c
182c_all.o: ../../e_os.h ../../include/openssl/aes.h ../../include/openssl/asn1.h
183c_all.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h
184c_all.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
185c_all.o: ../../include/openssl/cast.h ../../include/openssl/crypto.h
186c_all.o: ../../include/openssl/des.h ../../include/openssl/des_old.h
187c_all.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
188c_all.o: ../../include/openssl/e_os2.h ../../include/openssl/engine.h
189c_all.o: ../../include/openssl/err.h ../../include/openssl/evp.h
190c_all.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h
191c_all.o: ../../include/openssl/md2.h ../../include/openssl/md4.h
192c_all.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
193c_all.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
194c_all.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
195c_all.o: ../../include/openssl/ossl_typ.h ../../include/openssl/rand.h
196c_all.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h
197c_all.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h
198c_all.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
199c_all.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
200c_all.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
201c_all.o: ../../include/openssl/ui_compat.h ../cryptlib.h c_all.c
202c_allc.o: ../../e_os.h ../../include/openssl/aes.h ../../include/openssl/asn1.h
203c_allc.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h
204c_allc.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
205c_allc.o: ../../include/openssl/cast.h ../../include/openssl/crypto.h
206c_allc.o: ../../include/openssl/des.h ../../include/openssl/des_old.h
207c_allc.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
208c_allc.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
209c_allc.o: ../../include/openssl/evp.h ../../include/openssl/idea.h
210c_allc.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h
211c_allc.o: ../../include/openssl/md4.h ../../include/openssl/md5.h
212c_allc.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h
213c_allc.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
214c_allc.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
215c_allc.o: ../../include/openssl/pkcs12.h ../../include/openssl/pkcs7.h
216c_allc.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h
217c_allc.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h
218c_allc.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
219c_allc.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
220c_allc.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
221c_allc.o: ../../include/openssl/ui_compat.h ../../include/openssl/x509.h
222c_allc.o: ../../include/openssl/x509_vfy.h ../cryptlib.h c_allc.c
223c_alld.o: ../../e_os.h ../../include/openssl/aes.h ../../include/openssl/asn1.h
224c_alld.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h
225c_alld.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
226c_alld.o: ../../include/openssl/cast.h ../../include/openssl/crypto.h
227c_alld.o: ../../include/openssl/des.h ../../include/openssl/des_old.h
228c_alld.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
229c_alld.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
230c_alld.o: ../../include/openssl/evp.h ../../include/openssl/idea.h
231c_alld.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h
232c_alld.o: ../../include/openssl/md4.h ../../include/openssl/md5.h
233c_alld.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h
234c_alld.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
235c_alld.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
236c_alld.o: ../../include/openssl/pkcs12.h ../../include/openssl/pkcs7.h
237c_alld.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h
238c_alld.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h
239c_alld.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
240c_alld.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
241c_alld.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
242c_alld.o: ../../include/openssl/ui_compat.h ../../include/openssl/x509.h
243c_alld.o: ../../include/openssl/x509_vfy.h ../cryptlib.h c_alld.c
244digest.o: ../../e_os.h ../../include/openssl/aes.h ../../include/openssl/asn1.h
245digest.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h
246digest.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
247digest.o: ../../include/openssl/cast.h ../../include/openssl/crypto.h
248digest.o: ../../include/openssl/des.h ../../include/openssl/des_old.h
249digest.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
250digest.o: ../../include/openssl/e_os2.h ../../include/openssl/engine.h
251digest.o: ../../include/openssl/err.h ../../include/openssl/evp.h
252digest.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h
253digest.o: ../../include/openssl/md2.h ../../include/openssl/md4.h
254digest.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
255digest.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
256digest.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
257digest.o: ../../include/openssl/ossl_typ.h ../../include/openssl/rand.h
258digest.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h
259digest.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h
260digest.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
261digest.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
262digest.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
263digest.o: ../../include/openssl/ui_compat.h ../cryptlib.h digest.c
264e_aes.o: ../../include/openssl/aes.h ../../include/openssl/asn1.h
265e_aes.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h
266e_aes.o: ../../include/openssl/bn.h ../../include/openssl/cast.h
267e_aes.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
268e_aes.o: ../../include/openssl/des_old.h ../../include/openssl/dh.h
269e_aes.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
270e_aes.o: ../../include/openssl/err.h ../../include/openssl/evp.h
271e_aes.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h
272e_aes.o: ../../include/openssl/md2.h ../../include/openssl/md4.h
273e_aes.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
274e_aes.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
275e_aes.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
276e_aes.o: ../../include/openssl/ossl_typ.h ../../include/openssl/rc2.h
277e_aes.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
278e_aes.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
279e_aes.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
280e_aes.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
281e_aes.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h e_aes.c
282e_aes.o: evp_locl.h
283e_bf.o: ../../e_os.h ../../include/openssl/aes.h ../../include/openssl/asn1.h
284e_bf.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h
285e_bf.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
286e_bf.o: ../../include/openssl/cast.h ../../include/openssl/crypto.h
287e_bf.o: ../../include/openssl/des.h ../../include/openssl/des_old.h
288e_bf.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
289e_bf.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
290e_bf.o: ../../include/openssl/evp.h ../../include/openssl/idea.h
291e_bf.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h
292e_bf.o: ../../include/openssl/md4.h ../../include/openssl/md5.h
293e_bf.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h
294e_bf.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
295e_bf.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
296e_bf.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h
297e_bf.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h
298e_bf.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
299e_bf.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
300e_bf.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
301e_bf.o: ../../include/openssl/ui_compat.h ../cryptlib.h e_bf.c evp_locl.h
302e_cast.o: ../../e_os.h ../../include/openssl/aes.h ../../include/openssl/asn1.h
303e_cast.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h
304e_cast.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
305e_cast.o: ../../include/openssl/cast.h ../../include/openssl/crypto.h
306e_cast.o: ../../include/openssl/des.h ../../include/openssl/des_old.h
307e_cast.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
308e_cast.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
309e_cast.o: ../../include/openssl/evp.h ../../include/openssl/idea.h
310e_cast.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h
311e_cast.o: ../../include/openssl/md4.h ../../include/openssl/md5.h
312e_cast.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h
313e_cast.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
314e_cast.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
315e_cast.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h
316e_cast.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h
317e_cast.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
318e_cast.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
319e_cast.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
320e_cast.o: ../../include/openssl/ui_compat.h ../cryptlib.h e_cast.c evp_locl.h
321e_des.o: ../../e_os.h ../../include/openssl/aes.h ../../include/openssl/asn1.h
322e_des.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h
323e_des.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
324e_des.o: ../../include/openssl/cast.h ../../include/openssl/crypto.h
325e_des.o: ../../include/openssl/des.h ../../include/openssl/des_old.h
326e_des.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
327e_des.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
328e_des.o: ../../include/openssl/evp.h ../../include/openssl/idea.h
329e_des.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h
330e_des.o: ../../include/openssl/md4.h ../../include/openssl/md5.h
331e_des.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h
332e_des.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
333e_des.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
334e_des.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h
335e_des.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h
336e_des.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
337e_des.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
338e_des.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
339e_des.o: ../../include/openssl/ui_compat.h ../cryptlib.h e_des.c evp_locl.h
340e_des3.o: ../../e_os.h ../../include/openssl/aes.h ../../include/openssl/asn1.h
341e_des3.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h
342e_des3.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
343e_des3.o: ../../include/openssl/cast.h ../../include/openssl/crypto.h
344e_des3.o: ../../include/openssl/des.h ../../include/openssl/des_old.h
345e_des3.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
346e_des3.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
347e_des3.o: ../../include/openssl/evp.h ../../include/openssl/idea.h
348e_des3.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h
349e_des3.o: ../../include/openssl/md4.h ../../include/openssl/md5.h
350e_des3.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h
351e_des3.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
352e_des3.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
353e_des3.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h
354e_des3.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h
355e_des3.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
356e_des3.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
357e_des3.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
358e_des3.o: ../../include/openssl/ui_compat.h ../cryptlib.h e_des3.c evp_locl.h
359e_idea.o: ../../e_os.h ../../include/openssl/aes.h ../../include/openssl/asn1.h
360e_idea.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h
361e_idea.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
362e_idea.o: ../../include/openssl/cast.h ../../include/openssl/crypto.h
363e_idea.o: ../../include/openssl/des.h ../../include/openssl/des_old.h
364e_idea.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
365e_idea.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
366e_idea.o: ../../include/openssl/evp.h ../../include/openssl/idea.h
367e_idea.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h
368e_idea.o: ../../include/openssl/md4.h ../../include/openssl/md5.h
369e_idea.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h
370e_idea.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
371e_idea.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
372e_idea.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h
373e_idea.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h
374e_idea.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
375e_idea.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
376e_idea.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
377e_idea.o: ../../include/openssl/ui_compat.h ../cryptlib.h e_idea.c evp_locl.h
378e_null.o: ../../e_os.h ../../include/openssl/aes.h ../../include/openssl/asn1.h
379e_null.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h
380e_null.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
381e_null.o: ../../include/openssl/cast.h ../../include/openssl/crypto.h
382e_null.o: ../../include/openssl/des.h ../../include/openssl/des_old.h
383e_null.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
384e_null.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
385e_null.o: ../../include/openssl/evp.h ../../include/openssl/idea.h
386e_null.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h
387e_null.o: ../../include/openssl/md4.h ../../include/openssl/md5.h
388e_null.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h
389e_null.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
390e_null.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
391e_null.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h
392e_null.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h
393e_null.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
394e_null.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
395e_null.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
396e_null.o: ../../include/openssl/ui_compat.h ../cryptlib.h e_null.c
397e_rc2.o: ../../e_os.h ../../include/openssl/aes.h ../../include/openssl/asn1.h
398e_rc2.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h
399e_rc2.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
400e_rc2.o: ../../include/openssl/cast.h ../../include/openssl/crypto.h
401e_rc2.o: ../../include/openssl/des.h ../../include/openssl/des_old.h
402e_rc2.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
403e_rc2.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
404e_rc2.o: ../../include/openssl/evp.h ../../include/openssl/idea.h
405e_rc2.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h
406e_rc2.o: ../../include/openssl/md4.h ../../include/openssl/md5.h
407e_rc2.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h
408e_rc2.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
409e_rc2.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
410e_rc2.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h
411e_rc2.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h
412e_rc2.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
413e_rc2.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
414e_rc2.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
415e_rc2.o: ../../include/openssl/ui_compat.h ../cryptlib.h e_rc2.c evp_locl.h
416e_rc4.o: ../../e_os.h ../../include/openssl/aes.h ../../include/openssl/asn1.h
417e_rc4.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h
418e_rc4.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
419e_rc4.o: ../../include/openssl/cast.h ../../include/openssl/crypto.h
420e_rc4.o: ../../include/openssl/des.h ../../include/openssl/des_old.h
421e_rc4.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
422e_rc4.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
423e_rc4.o: ../../include/openssl/evp.h ../../include/openssl/idea.h
424e_rc4.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h
425e_rc4.o: ../../include/openssl/md4.h ../../include/openssl/md5.h
426e_rc4.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h
427e_rc4.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
428e_rc4.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
429e_rc4.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h
430e_rc4.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h
431e_rc4.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
432e_rc4.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
433e_rc4.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
434e_rc4.o: ../../include/openssl/ui_compat.h ../cryptlib.h e_rc4.c
435e_rc5.o: ../../e_os.h ../../include/openssl/aes.h ../../include/openssl/asn1.h
436e_rc5.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h
437e_rc5.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
438e_rc5.o: ../../include/openssl/cast.h ../../include/openssl/crypto.h
439e_rc5.o: ../../include/openssl/des.h ../../include/openssl/des_old.h
440e_rc5.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
441e_rc5.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
442e_rc5.o: ../../include/openssl/evp.h ../../include/openssl/idea.h
443e_rc5.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h
444e_rc5.o: ../../include/openssl/md4.h ../../include/openssl/md5.h
445e_rc5.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h
446e_rc5.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
447e_rc5.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
448e_rc5.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h
449e_rc5.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h
450e_rc5.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
451e_rc5.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
452e_rc5.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
453e_rc5.o: ../../include/openssl/ui_compat.h ../cryptlib.h e_rc5.c evp_locl.h
454e_xcbc_d.o: ../../e_os.h ../../include/openssl/aes.h
455e_xcbc_d.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
456e_xcbc_d.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
457e_xcbc_d.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
458e_xcbc_d.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
459e_xcbc_d.o: ../../include/openssl/des_old.h ../../include/openssl/dh.h
460e_xcbc_d.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
461e_xcbc_d.o: ../../include/openssl/err.h ../../include/openssl/evp.h
462e_xcbc_d.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h
463e_xcbc_d.o: ../../include/openssl/md2.h ../../include/openssl/md4.h
464e_xcbc_d.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
465e_xcbc_d.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
466e_xcbc_d.o: ../../include/openssl/opensslconf.h
467e_xcbc_d.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
468e_xcbc_d.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h
469e_xcbc_d.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h
470e_xcbc_d.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
471e_xcbc_d.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
472e_xcbc_d.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
473e_xcbc_d.o: ../../include/openssl/ui_compat.h ../cryptlib.h e_xcbc_d.c
474encode.o: ../../e_os.h ../../include/openssl/aes.h ../../include/openssl/asn1.h
475encode.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h
476encode.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
477encode.o: ../../include/openssl/cast.h ../../include/openssl/crypto.h
478encode.o: ../../include/openssl/des.h ../../include/openssl/des_old.h
479encode.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
480encode.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
481encode.o: ../../include/openssl/evp.h ../../include/openssl/idea.h
482encode.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h
483encode.o: ../../include/openssl/md4.h ../../include/openssl/md5.h
484encode.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h
485encode.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
486encode.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
487encode.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h
488encode.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h
489encode.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
490encode.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
491encode.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
492encode.o: ../../include/openssl/ui_compat.h ../cryptlib.h encode.c
493evp_acnf.o: ../../e_os.h ../../include/openssl/aes.h
494evp_acnf.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
495evp_acnf.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
496evp_acnf.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
497evp_acnf.o: ../../include/openssl/conf.h ../../include/openssl/crypto.h
498evp_acnf.o: ../../include/openssl/des.h ../../include/openssl/des_old.h
499evp_acnf.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
500evp_acnf.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
501evp_acnf.o: ../../include/openssl/evp.h ../../include/openssl/idea.h
502evp_acnf.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h
503evp_acnf.o: ../../include/openssl/md4.h ../../include/openssl/md5.h
504evp_acnf.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h
505evp_acnf.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
506evp_acnf.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
507evp_acnf.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h
508evp_acnf.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h
509evp_acnf.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
510evp_acnf.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
511evp_acnf.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
512evp_acnf.o: ../../include/openssl/ui_compat.h ../cryptlib.h evp_acnf.c
513evp_enc.o: ../../e_os.h ../../include/openssl/aes.h
514evp_enc.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
515evp_enc.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
516evp_enc.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
517evp_enc.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
518evp_enc.o: ../../include/openssl/des_old.h ../../include/openssl/dh.h
519evp_enc.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
520evp_enc.o: ../../include/openssl/engine.h ../../include/openssl/err.h
521evp_enc.o: ../../include/openssl/evp.h ../../include/openssl/idea.h
522evp_enc.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h
523evp_enc.o: ../../include/openssl/md4.h ../../include/openssl/md5.h
524evp_enc.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h
525evp_enc.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
526evp_enc.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
527evp_enc.o: ../../include/openssl/rand.h ../../include/openssl/rc2.h
528evp_enc.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
529evp_enc.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
530evp_enc.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
531evp_enc.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
532evp_enc.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
533evp_enc.o: ../cryptlib.h evp_enc.c evp_locl.h
534evp_err.o: ../../include/openssl/aes.h ../../include/openssl/asn1.h
535evp_err.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h
536evp_err.o: ../../include/openssl/bn.h ../../include/openssl/cast.h
537evp_err.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
538evp_err.o: ../../include/openssl/des_old.h ../../include/openssl/dh.h
539evp_err.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
540evp_err.o: ../../include/openssl/err.h ../../include/openssl/evp.h
541evp_err.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h
542evp_err.o: ../../include/openssl/md2.h ../../include/openssl/md4.h
543evp_err.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
544evp_err.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
545evp_err.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
546evp_err.o: ../../include/openssl/ossl_typ.h ../../include/openssl/rc2.h
547evp_err.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
548evp_err.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
549evp_err.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
550evp_err.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
551evp_err.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
552evp_err.o: evp_err.c
553evp_key.o: ../../e_os.h ../../include/openssl/aes.h
554evp_key.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
555evp_key.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
556evp_key.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
557evp_key.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
558evp_key.o: ../../include/openssl/des_old.h ../../include/openssl/dh.h
559evp_key.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
560evp_key.o: ../../include/openssl/err.h ../../include/openssl/evp.h
561evp_key.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h
562evp_key.o: ../../include/openssl/md2.h ../../include/openssl/md4.h
563evp_key.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
564evp_key.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
565evp_key.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
566evp_key.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h
567evp_key.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h
568evp_key.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h
569evp_key.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
570evp_key.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
571evp_key.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
572evp_key.o: ../../include/openssl/ui_compat.h ../../include/openssl/x509.h
573evp_key.o: ../../include/openssl/x509_vfy.h ../cryptlib.h evp_key.c
574evp_lib.o: ../../e_os.h ../../include/openssl/aes.h
575evp_lib.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
576evp_lib.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
577evp_lib.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
578evp_lib.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
579evp_lib.o: ../../include/openssl/des_old.h ../../include/openssl/dh.h
580evp_lib.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
581evp_lib.o: ../../include/openssl/err.h ../../include/openssl/evp.h
582evp_lib.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h
583evp_lib.o: ../../include/openssl/md2.h ../../include/openssl/md4.h
584evp_lib.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
585evp_lib.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
586evp_lib.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
587evp_lib.o: ../../include/openssl/ossl_typ.h ../../include/openssl/rc2.h
588evp_lib.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
589evp_lib.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
590evp_lib.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
591evp_lib.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
592evp_lib.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
593evp_lib.o: ../cryptlib.h evp_lib.c
594evp_pbe.o: ../../e_os.h ../../include/openssl/aes.h
595evp_pbe.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
596evp_pbe.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
597evp_pbe.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
598evp_pbe.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
599evp_pbe.o: ../../include/openssl/des_old.h ../../include/openssl/dh.h
600evp_pbe.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
601evp_pbe.o: ../../include/openssl/err.h ../../include/openssl/evp.h
602evp_pbe.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h
603evp_pbe.o: ../../include/openssl/md2.h ../../include/openssl/md4.h
604evp_pbe.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
605evp_pbe.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
606evp_pbe.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
607evp_pbe.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h
608evp_pbe.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h
609evp_pbe.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h
610evp_pbe.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
611evp_pbe.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
612evp_pbe.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
613evp_pbe.o: ../../include/openssl/ui_compat.h ../../include/openssl/x509.h
614evp_pbe.o: ../../include/openssl/x509_vfy.h ../cryptlib.h evp_pbe.c
615evp_pkey.o: ../../e_os.h ../../include/openssl/aes.h
616evp_pkey.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
617evp_pkey.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
618evp_pkey.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
619evp_pkey.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
620evp_pkey.o: ../../include/openssl/des_old.h ../../include/openssl/dh.h
621evp_pkey.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
622evp_pkey.o: ../../include/openssl/err.h ../../include/openssl/evp.h
623evp_pkey.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h
624evp_pkey.o: ../../include/openssl/md2.h ../../include/openssl/md4.h
625evp_pkey.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
626evp_pkey.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
627evp_pkey.o: ../../include/openssl/opensslconf.h
628evp_pkey.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
629evp_pkey.o: ../../include/openssl/pkcs7.h ../../include/openssl/rand.h
630evp_pkey.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h
631evp_pkey.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h
632evp_pkey.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
633evp_pkey.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
634evp_pkey.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
635evp_pkey.o: ../../include/openssl/ui_compat.h ../../include/openssl/x509.h
636evp_pkey.o: ../../include/openssl/x509_vfy.h ../cryptlib.h evp_pkey.c
637m_dss.o: ../../e_os.h ../../include/openssl/aes.h ../../include/openssl/asn1.h
638m_dss.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h
639m_dss.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
640m_dss.o: ../../include/openssl/cast.h ../../include/openssl/crypto.h
641m_dss.o: ../../include/openssl/des.h ../../include/openssl/des_old.h
642m_dss.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
643m_dss.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
644m_dss.o: ../../include/openssl/evp.h ../../include/openssl/idea.h
645m_dss.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h
646m_dss.o: ../../include/openssl/md4.h ../../include/openssl/md5.h
647m_dss.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h
648m_dss.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
649m_dss.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
650m_dss.o: ../../include/openssl/pkcs7.h ../../include/openssl/rc2.h
651m_dss.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
652m_dss.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
653m_dss.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
654m_dss.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
655m_dss.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
656m_dss.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
657m_dss.o: ../cryptlib.h m_dss.c
658m_dss1.o: ../../e_os.h ../../include/openssl/aes.h ../../include/openssl/asn1.h
659m_dss1.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h
660m_dss1.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
661m_dss1.o: ../../include/openssl/cast.h ../../include/openssl/crypto.h
662m_dss1.o: ../../include/openssl/des.h ../../include/openssl/des_old.h
663m_dss1.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
664m_dss1.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
665m_dss1.o: ../../include/openssl/evp.h ../../include/openssl/idea.h
666m_dss1.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h
667m_dss1.o: ../../include/openssl/md4.h ../../include/openssl/md5.h
668m_dss1.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h
669m_dss1.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
670m_dss1.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
671m_dss1.o: ../../include/openssl/pkcs7.h ../../include/openssl/rc2.h
672m_dss1.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
673m_dss1.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
674m_dss1.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
675m_dss1.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
676m_dss1.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
677m_dss1.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
678m_dss1.o: ../cryptlib.h m_dss1.c
679m_md2.o: ../../e_os.h ../../include/openssl/aes.h ../../include/openssl/asn1.h
680m_md2.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h
681m_md2.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
682m_md2.o: ../../include/openssl/cast.h ../../include/openssl/crypto.h
683m_md2.o: ../../include/openssl/des.h ../../include/openssl/des_old.h
684m_md2.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
685m_md2.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
686m_md2.o: ../../include/openssl/evp.h ../../include/openssl/idea.h
687m_md2.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h
688m_md2.o: ../../include/openssl/md4.h ../../include/openssl/md5.h
689m_md2.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h
690m_md2.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
691m_md2.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
692m_md2.o: ../../include/openssl/pkcs7.h ../../include/openssl/rc2.h
693m_md2.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
694m_md2.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
695m_md2.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
696m_md2.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
697m_md2.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
698m_md2.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
699m_md2.o: ../cryptlib.h m_md2.c
700m_md4.o: ../../e_os.h ../../include/openssl/aes.h ../../include/openssl/asn1.h
701m_md4.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h
702m_md4.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
703m_md4.o: ../../include/openssl/cast.h ../../include/openssl/crypto.h
704m_md4.o: ../../include/openssl/des.h ../../include/openssl/des_old.h
705m_md4.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
706m_md4.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
707m_md4.o: ../../include/openssl/evp.h ../../include/openssl/idea.h
708m_md4.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h
709m_md4.o: ../../include/openssl/md4.h ../../include/openssl/md5.h
710m_md4.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h
711m_md4.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
712m_md4.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
713m_md4.o: ../../include/openssl/pkcs7.h ../../include/openssl/rc2.h
714m_md4.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
715m_md4.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
716m_md4.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
717m_md4.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
718m_md4.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
719m_md4.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
720m_md4.o: ../cryptlib.h m_md4.c
721m_md5.o: ../../e_os.h ../../include/openssl/aes.h ../../include/openssl/asn1.h
722m_md5.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h
723m_md5.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
724m_md5.o: ../../include/openssl/cast.h ../../include/openssl/crypto.h
725m_md5.o: ../../include/openssl/des.h ../../include/openssl/des_old.h
726m_md5.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
727m_md5.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
728m_md5.o: ../../include/openssl/evp.h ../../include/openssl/idea.h
729m_md5.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h
730m_md5.o: ../../include/openssl/md4.h ../../include/openssl/md5.h
731m_md5.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h
732m_md5.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
733m_md5.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
734m_md5.o: ../../include/openssl/pkcs7.h ../../include/openssl/rc2.h
735m_md5.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
736m_md5.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
737m_md5.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
738m_md5.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
739m_md5.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
740m_md5.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
741m_md5.o: ../cryptlib.h m_md5.c
742m_mdc2.o: ../../e_os.h ../../include/openssl/aes.h ../../include/openssl/asn1.h
743m_mdc2.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h
744m_mdc2.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
745m_mdc2.o: ../../include/openssl/cast.h ../../include/openssl/crypto.h
746m_mdc2.o: ../../include/openssl/des.h ../../include/openssl/des_old.h
747m_mdc2.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
748m_mdc2.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
749m_mdc2.o: ../../include/openssl/evp.h ../../include/openssl/idea.h
750m_mdc2.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h
751m_mdc2.o: ../../include/openssl/md4.h ../../include/openssl/md5.h
752m_mdc2.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h
753m_mdc2.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
754m_mdc2.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
755m_mdc2.o: ../../include/openssl/pkcs7.h ../../include/openssl/rc2.h
756m_mdc2.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
757m_mdc2.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
758m_mdc2.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
759m_mdc2.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
760m_mdc2.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
761m_mdc2.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
762m_mdc2.o: ../cryptlib.h m_mdc2.c
763m_null.o: ../../e_os.h ../../include/openssl/aes.h ../../include/openssl/asn1.h
764m_null.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h
765m_null.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
766m_null.o: ../../include/openssl/cast.h ../../include/openssl/crypto.h
767m_null.o: ../../include/openssl/des.h ../../include/openssl/des_old.h
768m_null.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
769m_null.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
770m_null.o: ../../include/openssl/evp.h ../../include/openssl/idea.h
771m_null.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h
772m_null.o: ../../include/openssl/md4.h ../../include/openssl/md5.h
773m_null.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h
774m_null.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
775m_null.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
776m_null.o: ../../include/openssl/pkcs7.h ../../include/openssl/rc2.h
777m_null.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
778m_null.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
779m_null.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
780m_null.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
781m_null.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
782m_null.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
783m_null.o: ../cryptlib.h m_null.c
784m_ripemd.o: ../../e_os.h ../../include/openssl/aes.h
785m_ripemd.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
786m_ripemd.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
787m_ripemd.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
788m_ripemd.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
789m_ripemd.o: ../../include/openssl/des_old.h ../../include/openssl/dh.h
790m_ripemd.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
791m_ripemd.o: ../../include/openssl/err.h ../../include/openssl/evp.h
792m_ripemd.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h
793m_ripemd.o: ../../include/openssl/md2.h ../../include/openssl/md4.h
794m_ripemd.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
795m_ripemd.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
796m_ripemd.o: ../../include/openssl/opensslconf.h
797m_ripemd.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
798m_ripemd.o: ../../include/openssl/pkcs7.h ../../include/openssl/rc2.h
799m_ripemd.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
800m_ripemd.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
801m_ripemd.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
802m_ripemd.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
803m_ripemd.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
804m_ripemd.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
805m_ripemd.o: ../cryptlib.h m_ripemd.c
806m_sha.o: ../../e_os.h ../../include/openssl/aes.h ../../include/openssl/asn1.h
807m_sha.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h
808m_sha.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
809m_sha.o: ../../include/openssl/cast.h ../../include/openssl/crypto.h
810m_sha.o: ../../include/openssl/des.h ../../include/openssl/des_old.h
811m_sha.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
812m_sha.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
813m_sha.o: ../../include/openssl/evp.h ../../include/openssl/idea.h
814m_sha.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h
815m_sha.o: ../../include/openssl/md4.h ../../include/openssl/md5.h
816m_sha.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h
817m_sha.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
818m_sha.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
819m_sha.o: ../../include/openssl/pkcs7.h ../../include/openssl/rc2.h
820m_sha.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
821m_sha.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
822m_sha.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
823m_sha.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
824m_sha.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
825m_sha.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
826m_sha.o: ../cryptlib.h m_sha.c
827m_sha1.o: ../../e_os.h ../../include/openssl/aes.h ../../include/openssl/asn1.h
828m_sha1.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h
829m_sha1.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
830m_sha1.o: ../../include/openssl/cast.h ../../include/openssl/crypto.h
831m_sha1.o: ../../include/openssl/des.h ../../include/openssl/des_old.h
832m_sha1.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
833m_sha1.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
834m_sha1.o: ../../include/openssl/evp.h ../../include/openssl/idea.h
835m_sha1.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h
836m_sha1.o: ../../include/openssl/md4.h ../../include/openssl/md5.h
837m_sha1.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h
838m_sha1.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
839m_sha1.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
840m_sha1.o: ../../include/openssl/pkcs7.h ../../include/openssl/rc2.h
841m_sha1.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
842m_sha1.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
843m_sha1.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
844m_sha1.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
845m_sha1.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
846m_sha1.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
847m_sha1.o: ../cryptlib.h m_sha1.c
848names.o: ../../e_os.h ../../include/openssl/aes.h ../../include/openssl/asn1.h
849names.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h
850names.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
851names.o: ../../include/openssl/cast.h ../../include/openssl/crypto.h
852names.o: ../../include/openssl/des.h ../../include/openssl/des_old.h
853names.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
854names.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
855names.o: ../../include/openssl/evp.h ../../include/openssl/idea.h
856names.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h
857names.o: ../../include/openssl/md4.h ../../include/openssl/md5.h
858names.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h
859names.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
860names.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
861names.o: ../../include/openssl/pkcs7.h ../../include/openssl/rc2.h
862names.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
863names.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
864names.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
865names.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
866names.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
867names.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
868names.o: ../cryptlib.h names.c
869p5_crpt.o: ../../e_os.h ../../include/openssl/aes.h
870p5_crpt.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
871p5_crpt.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
872p5_crpt.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
873p5_crpt.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
874p5_crpt.o: ../../include/openssl/des_old.h ../../include/openssl/dh.h
875p5_crpt.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
876p5_crpt.o: ../../include/openssl/err.h ../../include/openssl/evp.h
877p5_crpt.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h
878p5_crpt.o: ../../include/openssl/md2.h ../../include/openssl/md4.h
879p5_crpt.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
880p5_crpt.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
881p5_crpt.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
882p5_crpt.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h
883p5_crpt.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h
884p5_crpt.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h
885p5_crpt.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
886p5_crpt.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
887p5_crpt.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
888p5_crpt.o: ../../include/openssl/ui_compat.h ../../include/openssl/x509.h
889p5_crpt.o: ../../include/openssl/x509_vfy.h ../cryptlib.h p5_crpt.c
890p5_crpt2.o: ../../e_os.h ../../include/openssl/aes.h
891p5_crpt2.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
892p5_crpt2.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
893p5_crpt2.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
894p5_crpt2.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
895p5_crpt2.o: ../../include/openssl/des_old.h ../../include/openssl/dh.h
896p5_crpt2.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
897p5_crpt2.o: ../../include/openssl/err.h ../../include/openssl/evp.h
898p5_crpt2.o: ../../include/openssl/hmac.h ../../include/openssl/idea.h
899p5_crpt2.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h
900p5_crpt2.o: ../../include/openssl/md4.h ../../include/openssl/md5.h
901p5_crpt2.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h
902p5_crpt2.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
903p5_crpt2.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
904p5_crpt2.o: ../../include/openssl/pkcs7.h ../../include/openssl/rc2.h
905p5_crpt2.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
906p5_crpt2.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
907p5_crpt2.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
908p5_crpt2.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
909p5_crpt2.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
910p5_crpt2.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
911p5_crpt2.o: ../cryptlib.h p5_crpt2.c
912p_dec.o: ../../e_os.h ../../include/openssl/aes.h ../../include/openssl/asn1.h
913p_dec.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h
914p_dec.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
915p_dec.o: ../../include/openssl/cast.h ../../include/openssl/crypto.h
916p_dec.o: ../../include/openssl/des.h ../../include/openssl/des_old.h
917p_dec.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
918p_dec.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
919p_dec.o: ../../include/openssl/evp.h ../../include/openssl/idea.h
920p_dec.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h
921p_dec.o: ../../include/openssl/md4.h ../../include/openssl/md5.h
922p_dec.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h
923p_dec.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
924p_dec.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
925p_dec.o: ../../include/openssl/pkcs7.h ../../include/openssl/rand.h
926p_dec.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h
927p_dec.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h
928p_dec.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
929p_dec.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
930p_dec.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
931p_dec.o: ../../include/openssl/ui_compat.h ../../include/openssl/x509.h
932p_dec.o: ../../include/openssl/x509_vfy.h ../cryptlib.h p_dec.c
933p_enc.o: ../../e_os.h ../../include/openssl/aes.h ../../include/openssl/asn1.h
934p_enc.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h
935p_enc.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
936p_enc.o: ../../include/openssl/cast.h ../../include/openssl/crypto.h
937p_enc.o: ../../include/openssl/des.h ../../include/openssl/des_old.h
938p_enc.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
939p_enc.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
940p_enc.o: ../../include/openssl/evp.h ../../include/openssl/idea.h
941p_enc.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h
942p_enc.o: ../../include/openssl/md4.h ../../include/openssl/md5.h
943p_enc.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h
944p_enc.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
945p_enc.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
946p_enc.o: ../../include/openssl/pkcs7.h ../../include/openssl/rand.h
947p_enc.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h
948p_enc.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h
949p_enc.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
950p_enc.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
951p_enc.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
952p_enc.o: ../../include/openssl/ui_compat.h ../../include/openssl/x509.h
953p_enc.o: ../../include/openssl/x509_vfy.h ../cryptlib.h p_enc.c
954p_lib.o: ../../e_os.h ../../include/openssl/aes.h ../../include/openssl/asn1.h
955p_lib.o: ../../include/openssl/asn1_mac.h ../../include/openssl/bio.h
956p_lib.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
957p_lib.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
958p_lib.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
959p_lib.o: ../../include/openssl/des_old.h ../../include/openssl/dh.h
960p_lib.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
961p_lib.o: ../../include/openssl/err.h ../../include/openssl/evp.h
962p_lib.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h
963p_lib.o: ../../include/openssl/md2.h ../../include/openssl/md4.h
964p_lib.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
965p_lib.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
966p_lib.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
967p_lib.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h
968p_lib.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h
969p_lib.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h
970p_lib.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
971p_lib.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
972p_lib.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
973p_lib.o: ../../include/openssl/ui_compat.h ../../include/openssl/x509.h
974p_lib.o: ../../include/openssl/x509_vfy.h ../cryptlib.h p_lib.c
975p_open.o: ../../e_os.h ../../include/openssl/aes.h ../../include/openssl/asn1.h
976p_open.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h
977p_open.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
978p_open.o: ../../include/openssl/cast.h ../../include/openssl/crypto.h
979p_open.o: ../../include/openssl/des.h ../../include/openssl/des_old.h
980p_open.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
981p_open.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
982p_open.o: ../../include/openssl/evp.h ../../include/openssl/idea.h
983p_open.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h
984p_open.o: ../../include/openssl/md4.h ../../include/openssl/md5.h
985p_open.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h
986p_open.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
987p_open.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
988p_open.o: ../../include/openssl/pkcs7.h ../../include/openssl/rc2.h
989p_open.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
990p_open.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
991p_open.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
992p_open.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
993p_open.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
994p_open.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
995p_open.o: ../cryptlib.h p_open.c
996p_seal.o: ../../e_os.h ../../include/openssl/aes.h ../../include/openssl/asn1.h
997p_seal.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h
998p_seal.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
999p_seal.o: ../../include/openssl/cast.h ../../include/openssl/crypto.h
1000p_seal.o: ../../include/openssl/des.h ../../include/openssl/des_old.h
1001p_seal.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
1002p_seal.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
1003p_seal.o: ../../include/openssl/evp.h ../../include/openssl/idea.h
1004p_seal.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h
1005p_seal.o: ../../include/openssl/md4.h ../../include/openssl/md5.h
1006p_seal.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h
1007p_seal.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
1008p_seal.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
1009p_seal.o: ../../include/openssl/pkcs7.h ../../include/openssl/rand.h
1010p_seal.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h
1011p_seal.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h
1012p_seal.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
1013p_seal.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
1014p_seal.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
1015p_seal.o: ../../include/openssl/ui_compat.h ../../include/openssl/x509.h
1016p_seal.o: ../../include/openssl/x509_vfy.h ../cryptlib.h p_seal.c
1017p_sign.o: ../../e_os.h ../../include/openssl/aes.h ../../include/openssl/asn1.h
1018p_sign.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h
1019p_sign.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
1020p_sign.o: ../../include/openssl/cast.h ../../include/openssl/crypto.h
1021p_sign.o: ../../include/openssl/des.h ../../include/openssl/des_old.h
1022p_sign.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
1023p_sign.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
1024p_sign.o: ../../include/openssl/evp.h ../../include/openssl/idea.h
1025p_sign.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h
1026p_sign.o: ../../include/openssl/md4.h ../../include/openssl/md5.h
1027p_sign.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h
1028p_sign.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
1029p_sign.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
1030p_sign.o: ../../include/openssl/pkcs7.h ../../include/openssl/rc2.h
1031p_sign.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
1032p_sign.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
1033p_sign.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
1034p_sign.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
1035p_sign.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
1036p_sign.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
1037p_sign.o: ../cryptlib.h p_sign.c
1038p_verify.o: ../../e_os.h ../../include/openssl/aes.h
1039p_verify.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
1040p_verify.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
1041p_verify.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
1042p_verify.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
1043p_verify.o: ../../include/openssl/des_old.h ../../include/openssl/dh.h
1044p_verify.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
1045p_verify.o: ../../include/openssl/err.h ../../include/openssl/evp.h
1046p_verify.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h
1047p_verify.o: ../../include/openssl/md2.h ../../include/openssl/md4.h
1048p_verify.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
1049p_verify.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
1050p_verify.o: ../../include/openssl/opensslconf.h
1051p_verify.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
1052p_verify.o: ../../include/openssl/pkcs7.h ../../include/openssl/rc2.h
1053p_verify.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
1054p_verify.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
1055p_verify.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
1056p_verify.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
1057p_verify.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
1058p_verify.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
1059p_verify.o: ../cryptlib.h p_verify.c
diff --git a/src/lib/libcrypto/evp/bio_b64.c b/src/lib/libcrypto/evp/bio_b64.c
index fa5cbc7eb1..72a2a67277 100644
--- a/src/lib/libcrypto/evp/bio_b64.c
+++ b/src/lib/libcrypto/evp/bio_b64.c
@@ -64,7 +64,7 @@
64 64
65static int b64_write(BIO *h, const char *buf, int num); 65static int b64_write(BIO *h, const char *buf, int num);
66static int b64_read(BIO *h, char *buf, int size); 66static int b64_read(BIO *h, char *buf, int size);
67/*static int b64_puts(BIO *h, const char *str); */ 67static int b64_puts(BIO *h, const char *str);
68/*static int b64_gets(BIO *h, char *str, int size); */ 68/*static int b64_gets(BIO *h, char *str, int size); */
69static long b64_ctrl(BIO *h, int cmd, long arg1, void *arg2); 69static long b64_ctrl(BIO *h, int cmd, long arg1, void *arg2);
70static int b64_new(BIO *h); 70static int b64_new(BIO *h);
@@ -96,7 +96,7 @@ static BIO_METHOD methods_b64=
96 BIO_TYPE_BASE64,"base64 encoding", 96 BIO_TYPE_BASE64,"base64 encoding",
97 b64_write, 97 b64_write,
98 b64_read, 98 b64_read,
99 NULL, /* b64_puts, */ 99 b64_puts,
100 NULL, /* b64_gets, */ 100 NULL, /* b64_gets, */
101 b64_ctrl, 101 b64_ctrl,
102 b64_new, 102 b64_new,
@@ -127,6 +127,7 @@ static int b64_new(BIO *bi)
127 bi->init=1; 127 bi->init=1;
128 bi->ptr=(char *)ctx; 128 bi->ptr=(char *)ctx;
129 bi->flags=0; 129 bi->flags=0;
130 bi->num = 0;
130 return(1); 131 return(1);
131 } 132 }
132 133
@@ -151,6 +152,8 @@ static int b64_read(BIO *b, char *out, int outl)
151 152
152 if ((ctx == NULL) || (b->next_bio == NULL)) return(0); 153 if ((ctx == NULL) || (b->next_bio == NULL)) return(0);
153 154
155 BIO_clear_retry_flags(b);
156
154 if (ctx->encode != B64_DECODE) 157 if (ctx->encode != B64_DECODE)
155 { 158 {
156 ctx->encode=B64_DECODE; 159 ctx->encode=B64_DECODE;
@@ -163,6 +166,7 @@ static int b64_read(BIO *b, char *out, int outl)
163 /* First check if there are bytes decoded/encoded */ 166 /* First check if there are bytes decoded/encoded */
164 if (ctx->buf_len > 0) 167 if (ctx->buf_len > 0)
165 { 168 {
169 OPENSSL_assert(ctx->buf_len >= ctx->buf_off);
166 i=ctx->buf_len-ctx->buf_off; 170 i=ctx->buf_len-ctx->buf_off;
167 if (i > outl) i=outl; 171 if (i > outl) i=outl;
168 OPENSSL_assert(ctx->buf_off+i < (int)sizeof(ctx->buf)); 172 OPENSSL_assert(ctx->buf_off+i < (int)sizeof(ctx->buf));
@@ -184,7 +188,6 @@ static int b64_read(BIO *b, char *out, int outl)
184 ret_code=0; 188 ret_code=0;
185 while (outl > 0) 189 while (outl > 0)
186 { 190 {
187
188 if (ctx->cont <= 0) 191 if (ctx->cont <= 0)
189 break; 192 break;
190 193
@@ -195,7 +198,7 @@ static int b64_read(BIO *b, char *out, int outl)
195 { 198 {
196 ret_code=i; 199 ret_code=i;
197 200
198 /* Should be continue next time we are called? */ 201 /* Should we continue next time we are called? */
199 if (!BIO_should_retry(b->next_bio)) 202 if (!BIO_should_retry(b->next_bio))
200 { 203 {
201 ctx->cont=i; 204 ctx->cont=i;
@@ -285,19 +288,27 @@ static int b64_read(BIO *b, char *out, int outl)
285 continue; 288 continue;
286 } 289 }
287 else 290 else
291 {
288 ctx->tmp_len=0; 292 ctx->tmp_len=0;
289 } 293 }
290 /* If buffer isn't full and we can retry then 294 }
291 * restart to read in more data.
292 */
293 else if ((i < B64_BLOCK_SIZE) && (ctx->cont > 0)) 295 else if ((i < B64_BLOCK_SIZE) && (ctx->cont > 0))
296 {
297 /* If buffer isn't full and we can retry then
298 * restart to read in more data.
299 */
294 continue; 300 continue;
301 }
295 302
296 if (BIO_get_flags(b) & BIO_FLAGS_BASE64_NO_NL) 303 if (BIO_get_flags(b) & BIO_FLAGS_BASE64_NO_NL)
297 { 304 {
298 int z,jj; 305 int z,jj;
299 306
307#if 0
300 jj=(i>>2)<<2; 308 jj=(i>>2)<<2;
309#else
310 jj = i & ~3; /* process per 4 */
311#endif
301 z=EVP_DecodeBlock((unsigned char *)ctx->buf, 312 z=EVP_DecodeBlock((unsigned char *)ctx->buf,
302 (unsigned char *)ctx->tmp,jj); 313 (unsigned char *)ctx->tmp,jj);
303 if (jj > 2) 314 if (jj > 2)
@@ -313,18 +324,15 @@ static int b64_read(BIO *b, char *out, int outl)
313 * number consumed */ 324 * number consumed */
314 if (jj != i) 325 if (jj != i)
315 { 326 {
316 memcpy((unsigned char *)ctx->tmp, 327 memmove(ctx->tmp, &ctx->tmp[jj], i-jj);
317 (unsigned char *)&(ctx->tmp[jj]),i-jj);
318 ctx->tmp_len=i-jj; 328 ctx->tmp_len=i-jj;
319 } 329 }
320 ctx->buf_len=0; 330 ctx->buf_len=0;
321 if (z > 0) 331 if (z > 0)
322 { 332 {
323 ctx->buf_len=z; 333 ctx->buf_len=z;
324 i=1;
325 } 334 }
326 else 335 i=z;
327 i=z;
328 } 336 }
329 else 337 else
330 { 338 {
@@ -357,14 +365,16 @@ static int b64_read(BIO *b, char *out, int outl)
357 outl-=i; 365 outl-=i;
358 out+=i; 366 out+=i;
359 } 367 }
360 BIO_clear_retry_flags(b); 368 /* BIO_clear_retry_flags(b); */
361 BIO_copy_next_retry(b); 369 BIO_copy_next_retry(b);
362 return((ret == 0)?ret_code:ret); 370 return((ret == 0)?ret_code:ret);
363 } 371 }
364 372
365static int b64_write(BIO *b, const char *in, int inl) 373static int b64_write(BIO *b, const char *in, int inl)
366 { 374 {
367 int ret=inl,n,i; 375 int ret=0;
376 int n;
377 int i;
368 BIO_B64_CTX *ctx; 378 BIO_B64_CTX *ctx;
369 379
370 ctx=(BIO_B64_CTX *)b->ptr; 380 ctx=(BIO_B64_CTX *)b->ptr;
@@ -379,6 +389,9 @@ static int b64_write(BIO *b, const char *in, int inl)
379 EVP_EncodeInit(&(ctx->base64)); 389 EVP_EncodeInit(&(ctx->base64));
380 } 390 }
381 391
392 OPENSSL_assert(ctx->buf_off < (int)sizeof(ctx->buf));
393 OPENSSL_assert(ctx->buf_len <= (int)sizeof(ctx->buf));
394 OPENSSL_assert(ctx->buf_len >= ctx->buf_off);
382 n=ctx->buf_len-ctx->buf_off; 395 n=ctx->buf_len-ctx->buf_off;
383 while (n > 0) 396 while (n > 0)
384 { 397 {
@@ -388,7 +401,10 @@ static int b64_write(BIO *b, const char *in, int inl)
388 BIO_copy_next_retry(b); 401 BIO_copy_next_retry(b);
389 return(i); 402 return(i);
390 } 403 }
404 OPENSSL_assert(i <= n);
391 ctx->buf_off+=i; 405 ctx->buf_off+=i;
406 OPENSSL_assert(ctx->buf_off <= (int)sizeof(ctx->buf));
407 OPENSSL_assert(ctx->buf_len >= ctx->buf_off);
392 n-=i; 408 n-=i;
393 } 409 }
394 /* at this point all pending data has been written */ 410 /* at this point all pending data has been written */
@@ -405,18 +421,19 @@ static int b64_write(BIO *b, const char *in, int inl)
405 { 421 {
406 if (ctx->tmp_len > 0) 422 if (ctx->tmp_len > 0)
407 { 423 {
424 OPENSSL_assert(ctx->tmp_len <= 3);
408 n=3-ctx->tmp_len; 425 n=3-ctx->tmp_len;
409 /* There's a teoretical possibility for this */ 426 /* There's a theoretical possibility for this */
410 if (n > inl) 427 if (n > inl)
411 n=inl; 428 n=inl;
412 memcpy(&(ctx->tmp[ctx->tmp_len]),in,n); 429 memcpy(&(ctx->tmp[ctx->tmp_len]),in,n);
413 ctx->tmp_len+=n; 430 ctx->tmp_len+=n;
431 ret += n;
414 if (ctx->tmp_len < 3) 432 if (ctx->tmp_len < 3)
415 break; 433 break;
416 ctx->buf_len=EVP_EncodeBlock( 434 ctx->buf_len=EVP_EncodeBlock((unsigned char *)ctx->buf,(unsigned char *)ctx->tmp,ctx->tmp_len);
417 (unsigned char *)ctx->buf, 435 OPENSSL_assert(ctx->buf_len <= (int)sizeof(ctx->buf));
418 (unsigned char *)ctx->tmp, 436 OPENSSL_assert(ctx->buf_len >= ctx->buf_off);
419 ctx->tmp_len);
420 /* Since we're now done using the temporary 437 /* Since we're now done using the temporary
421 buffer, the length should be 0'd */ 438 buffer, the length should be 0'd */
422 ctx->tmp_len=0; 439 ctx->tmp_len=0;
@@ -425,14 +442,16 @@ static int b64_write(BIO *b, const char *in, int inl)
425 { 442 {
426 if (n < 3) 443 if (n < 3)
427 { 444 {
428 memcpy(&(ctx->tmp[0]),in,n); 445 memcpy(ctx->tmp,in,n);
429 ctx->tmp_len=n; 446 ctx->tmp_len=n;
447 ret += n;
430 break; 448 break;
431 } 449 }
432 n-=n%3; 450 n-=n%3;
433 ctx->buf_len=EVP_EncodeBlock( 451 ctx->buf_len=EVP_EncodeBlock((unsigned char *)ctx->buf,(const unsigned char *)in,n);
434 (unsigned char *)ctx->buf, 452 OPENSSL_assert(ctx->buf_len <= (int)sizeof(ctx->buf));
435 (unsigned char *)in,n); 453 OPENSSL_assert(ctx->buf_len >= ctx->buf_off);
454 ret += n;
436 } 455 }
437 } 456 }
438 else 457 else
@@ -440,6 +459,9 @@ static int b64_write(BIO *b, const char *in, int inl)
440 EVP_EncodeUpdate(&(ctx->base64), 459 EVP_EncodeUpdate(&(ctx->base64),
441 (unsigned char *)ctx->buf,&ctx->buf_len, 460 (unsigned char *)ctx->buf,&ctx->buf_len,
442 (unsigned char *)in,n); 461 (unsigned char *)in,n);
462 OPENSSL_assert(ctx->buf_len <= (int)sizeof(ctx->buf));
463 OPENSSL_assert(ctx->buf_len >= ctx->buf_off);
464 ret += n;
443 } 465 }
444 inl-=n; 466 inl-=n;
445 in+=n; 467 in+=n;
@@ -454,8 +476,11 @@ static int b64_write(BIO *b, const char *in, int inl)
454 BIO_copy_next_retry(b); 476 BIO_copy_next_retry(b);
455 return((ret == 0)?i:ret); 477 return((ret == 0)?i:ret);
456 } 478 }
479 OPENSSL_assert(i <= n);
457 n-=i; 480 n-=i;
458 ctx->buf_off+=i; 481 ctx->buf_off+=i;
482 OPENSSL_assert(ctx->buf_off <= (int)sizeof(ctx->buf));
483 OPENSSL_assert(ctx->buf_len >= ctx->buf_off);
459 } 484 }
460 ctx->buf_len=0; 485 ctx->buf_len=0;
461 ctx->buf_off=0; 486 ctx->buf_off=0;
@@ -486,6 +511,7 @@ static long b64_ctrl(BIO *b, int cmd, long num, void *ptr)
486 ret=BIO_ctrl(b->next_bio,cmd,num,ptr); 511 ret=BIO_ctrl(b->next_bio,cmd,num,ptr);
487 break; 512 break;
488 case BIO_CTRL_WPENDING: /* More to write in buffer */ 513 case BIO_CTRL_WPENDING: /* More to write in buffer */
514 OPENSSL_assert(ctx->buf_len >= ctx->buf_off);
489 ret=ctx->buf_len-ctx->buf_off; 515 ret=ctx->buf_len-ctx->buf_off;
490 if ((ret == 0) && (ctx->encode != B64_NONE) 516 if ((ret == 0) && (ctx->encode != B64_NONE)
491 && (ctx->base64.num != 0)) 517 && (ctx->base64.num != 0))
@@ -494,6 +520,7 @@ static long b64_ctrl(BIO *b, int cmd, long num, void *ptr)
494 ret=BIO_ctrl(b->next_bio,cmd,num,ptr); 520 ret=BIO_ctrl(b->next_bio,cmd,num,ptr);
495 break; 521 break;
496 case BIO_CTRL_PENDING: /* More to read in buffer */ 522 case BIO_CTRL_PENDING: /* More to read in buffer */
523 OPENSSL_assert(ctx->buf_len >= ctx->buf_off);
497 ret=ctx->buf_len-ctx->buf_off; 524 ret=ctx->buf_len-ctx->buf_off;
498 if (ret <= 0) 525 if (ret <= 0)
499 ret=BIO_ctrl(b->next_bio,cmd,num,ptr); 526 ret=BIO_ctrl(b->next_bio,cmd,num,ptr);
@@ -565,3 +592,7 @@ static long b64_callback_ctrl(BIO *b, int cmd, bio_info_cb *fp)
565 return(ret); 592 return(ret);
566 } 593 }
567 594
595static int b64_puts(BIO *b, const char *str)
596 {
597 return b64_write(b,str,strlen(str));
598 }
diff --git a/src/lib/libcrypto/evp/bio_enc.c b/src/lib/libcrypto/evp/bio_enc.c
index f6ac94c6e1..b6efb5fbc4 100644
--- a/src/lib/libcrypto/evp/bio_enc.c
+++ b/src/lib/libcrypto/evp/bio_enc.c
@@ -361,8 +361,10 @@ again:
361 case BIO_CTRL_DUP: 361 case BIO_CTRL_DUP:
362 dbio=(BIO *)ptr; 362 dbio=(BIO *)ptr;
363 dctx=(BIO_ENC_CTX *)dbio->ptr; 363 dctx=(BIO_ENC_CTX *)dbio->ptr;
364 memcpy(&(dctx->cipher),&(ctx->cipher),sizeof(ctx->cipher)); 364 EVP_CIPHER_CTX_init(&dctx->cipher);
365 dbio->init=1; 365 ret = EVP_CIPHER_CTX_copy(&dctx->cipher,&ctx->cipher);
366 if (ret)
367 dbio->init=1;
366 break; 368 break;
367 default: 369 default:
368 ret=BIO_ctrl(b->next_bio,cmd,num,ptr); 370 ret=BIO_ctrl(b->next_bio,cmd,num,ptr);
diff --git a/src/lib/libcrypto/evp/bio_md.c b/src/lib/libcrypto/evp/bio_md.c
index ed5c1135fd..9841e32e1a 100644
--- a/src/lib/libcrypto/evp/bio_md.c
+++ b/src/lib/libcrypto/evp/bio_md.c
@@ -130,8 +130,8 @@ static int md_read(BIO *b, char *out, int outl)
130 { 130 {
131 if (ret > 0) 131 if (ret > 0)
132 { 132 {
133 EVP_DigestUpdate(ctx,(unsigned char *)out, 133 if (EVP_DigestUpdate(ctx,(unsigned char *)out,
134 (unsigned int)ret); 134 (unsigned int)ret)<=0) return (-1);
135 } 135 }
136 } 136 }
137 BIO_clear_retry_flags(b); 137 BIO_clear_retry_flags(b);
@@ -157,8 +157,11 @@ static int md_write(BIO *b, const char *in, int inl)
157 (unsigned int)ret); 157 (unsigned int)ret);
158 } 158 }
159 } 159 }
160 BIO_clear_retry_flags(b); 160 if(b->next_bio != NULL)
161 BIO_copy_next_retry(b); 161 {
162 BIO_clear_retry_flags(b);
163 BIO_copy_next_retry(b);
164 }
162 return(ret); 165 return(ret);
163 } 166 }
164 167
@@ -194,6 +197,7 @@ static long md_ctrl(BIO *b, int cmd, long num, void *ptr)
194 case BIO_C_GET_MD_CTX: 197 case BIO_C_GET_MD_CTX:
195 pctx=ptr; 198 pctx=ptr;
196 *pctx=ctx; 199 *pctx=ctx;
200 b->init = 1;
197 break; 201 break;
198 case BIO_C_SET_MD_CTX: 202 case BIO_C_SET_MD_CTX:
199 if (b->init) 203 if (b->init)
@@ -249,7 +253,9 @@ static int md_gets(BIO *bp, char *buf, int size)
249 ctx=bp->ptr; 253 ctx=bp->ptr;
250 if (size < ctx->digest->md_size) 254 if (size < ctx->digest->md_size)
251 return(0); 255 return(0);
252 EVP_DigestFinal_ex(ctx,(unsigned char *)buf,&ret); 256 if (EVP_DigestFinal_ex(ctx,(unsigned char *)buf,&ret)<=0)
257 return -1;
258
253 return((int)ret); 259 return((int)ret);
254 } 260 }
255 261
diff --git a/src/lib/libcrypto/evp/c_all.c b/src/lib/libcrypto/evp/c_all.c
index a5da52e62d..766c4cecdf 100644
--- a/src/lib/libcrypto/evp/c_all.c
+++ b/src/lib/libcrypto/evp/c_all.c
@@ -83,7 +83,7 @@ void OPENSSL_add_all_algorithms_noconf(void)
83 OpenSSL_add_all_ciphers(); 83 OpenSSL_add_all_ciphers();
84 OpenSSL_add_all_digests(); 84 OpenSSL_add_all_digests();
85#ifndef OPENSSL_NO_ENGINE 85#ifndef OPENSSL_NO_ENGINE
86# if defined(__OpenBSD__) || defined(__FreeBSD__) 86# if defined(__OpenBSD__) || defined(__FreeBSD__) || defined(HAVE_CRYPTODEV)
87 ENGINE_setup_bsd_cryptodev(); 87 ENGINE_setup_bsd_cryptodev();
88# endif 88# endif
89#endif 89#endif
diff --git a/src/lib/libcrypto/evp/c_allc.c b/src/lib/libcrypto/evp/c_allc.c
index 7054d8125d..c5f9268378 100644
--- a/src/lib/libcrypto/evp/c_allc.c
+++ b/src/lib/libcrypto/evp/c_allc.c
@@ -71,6 +71,8 @@ void OpenSSL_add_all_ciphers(void)
71 EVP_add_cipher(EVP_des_cfb8()); 71 EVP_add_cipher(EVP_des_cfb8());
72 EVP_add_cipher(EVP_des_ede_cfb()); 72 EVP_add_cipher(EVP_des_ede_cfb());
73 EVP_add_cipher(EVP_des_ede3_cfb()); 73 EVP_add_cipher(EVP_des_ede3_cfb());
74 EVP_add_cipher(EVP_des_ede3_cfb1());
75 EVP_add_cipher(EVP_des_ede3_cfb8());
74 76
75 EVP_add_cipher(EVP_des_ofb()); 77 EVP_add_cipher(EVP_des_ofb());
76 EVP_add_cipher(EVP_des_ede_ofb()); 78 EVP_add_cipher(EVP_des_ede_ofb());
@@ -219,7 +221,4 @@ void OpenSSL_add_all_ciphers(void)
219 EVP_add_cipher_alias(SN_camellia_256_cbc,"CAMELLIA256"); 221 EVP_add_cipher_alias(SN_camellia_256_cbc,"CAMELLIA256");
220 EVP_add_cipher_alias(SN_camellia_256_cbc,"camellia256"); 222 EVP_add_cipher_alias(SN_camellia_256_cbc,"camellia256");
221#endif 223#endif
222
223 PKCS12_PBE_add();
224 PKCS5_PBE_add();
225 } 224 }
diff --git a/src/lib/libcrypto/evp/c_alld.c b/src/lib/libcrypto/evp/c_alld.c
index d270b0ee03..311e1fe2f8 100644
--- a/src/lib/libcrypto/evp/c_alld.c
+++ b/src/lib/libcrypto/evp/c_alld.c
@@ -64,9 +64,6 @@
64 64
65void OpenSSL_add_all_digests(void) 65void OpenSSL_add_all_digests(void)
66 { 66 {
67#ifndef OPENSSL_NO_MD2
68 EVP_add_digest(EVP_md2());
69#endif
70#ifndef OPENSSL_NO_MD4 67#ifndef OPENSSL_NO_MD4
71 EVP_add_digest(EVP_md4()); 68 EVP_add_digest(EVP_md4());
72#endif 69#endif
@@ -81,7 +78,7 @@ void OpenSSL_add_all_digests(void)
81 EVP_add_digest(EVP_dss()); 78 EVP_add_digest(EVP_dss());
82#endif 79#endif
83#endif 80#endif
84#ifndef OPENSSL_NO_SHA 81#if !defined(OPENSSL_NO_SHA) && !defined(OPENSSL_NO_SHA1)
85 EVP_add_digest(EVP_sha1()); 82 EVP_add_digest(EVP_sha1());
86 EVP_add_digest_alias(SN_sha1,"ssl3-sha1"); 83 EVP_add_digest_alias(SN_sha1,"ssl3-sha1");
87 EVP_add_digest_alias(SN_sha1WithRSAEncryption,SN_sha1WithRSA); 84 EVP_add_digest_alias(SN_sha1WithRSAEncryption,SN_sha1WithRSA);
@@ -111,4 +108,7 @@ void OpenSSL_add_all_digests(void)
111 EVP_add_digest(EVP_sha384()); 108 EVP_add_digest(EVP_sha384());
112 EVP_add_digest(EVP_sha512()); 109 EVP_add_digest(EVP_sha512());
113#endif 110#endif
111#ifndef OPENSSL_NO_WHIRLPOOL
112 EVP_add_digest(EVP_whirlpool());
113#endif
114 } 114 }
diff --git a/src/lib/libcrypto/evp/dig_eng.c b/src/lib/libcrypto/evp/dig_eng.c
deleted file mode 100644
index 64cdf9366c..0000000000
--- a/src/lib/libcrypto/evp/dig_eng.c
+++ /dev/null
@@ -1,180 +0,0 @@
1/* crypto/evp/digest.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 * Copyright (c) 1998-2001 The OpenSSL Project. All rights reserved.
60 *
61 * Redistribution and use in source and binary forms, with or without
62 * modification, are permitted provided that the following conditions
63 * are met:
64 *
65 * 1. Redistributions of source code must retain the above copyright
66 * notice, this list of conditions and the following disclaimer.
67 *
68 * 2. Redistributions in binary form must reproduce the above copyright
69 * notice, this list of conditions and the following disclaimer in
70 * the documentation and/or other materials provided with the
71 * distribution.
72 *
73 * 3. All advertising materials mentioning features or use of this
74 * software must display the following acknowledgment:
75 * "This product includes software developed by the OpenSSL Project
76 * for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
77 *
78 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
79 * endorse or promote products derived from this software without
80 * prior written permission. For written permission, please contact
81 * openssl-core@openssl.org.
82 *
83 * 5. Products derived from this software may not be called "OpenSSL"
84 * nor may "OpenSSL" appear in their names without prior written
85 * permission of the OpenSSL Project.
86 *
87 * 6. Redistributions of any form whatsoever must retain the following
88 * acknowledgment:
89 * "This product includes software developed by the OpenSSL Project
90 * for use in the OpenSSL Toolkit (http://www.openssl.org/)"
91 *
92 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
93 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
94 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
95 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
96 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
97 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
98 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
99 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
100 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
101 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
102 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
103 * OF THE POSSIBILITY OF SUCH DAMAGE.
104 * ====================================================================
105 *
106 * This product includes cryptographic software written by Eric Young
107 * (eay@cryptsoft.com). This product includes software written by Tim
108 * Hudson (tjh@cryptsoft.com).
109 *
110 */
111
112#include <stdio.h>
113#include "cryptlib.h"
114#include <openssl/objects.h>
115#include <openssl/evp.h>
116#ifndef OPENSSL_NO_ENGINE
117#include <openssl/engine.h>
118#endif
119#include "evp_locl.h"
120
121#ifndef OPENSSL_NO_ENGINE
122
123#ifdef OPENSSL_FIPS
124
125static int do_evp_md_engine_full(EVP_MD_CTX *ctx, const EVP_MD **ptype, ENGINE *impl)
126 {
127 if (*ptype)
128 {
129 /* Ensure an ENGINE left lying around from last time is cleared
130 * (the previous check attempted to avoid this if the same
131 * ENGINE and EVP_MD could be used). */
132 if(ctx->engine)
133 ENGINE_finish(ctx->engine);
134 if(impl)
135 {
136 if (!ENGINE_init(impl))
137 {
138 EVPerr(EVP_F_DO_EVP_MD_ENGINE_FULL,EVP_R_INITIALIZATION_ERROR);
139 return 0;
140 }
141 }
142 else
143 /* Ask if an ENGINE is reserved for this job */
144 impl = ENGINE_get_digest_engine((*ptype)->type);
145 if(impl)
146 {
147 /* There's an ENGINE for this job ... (apparently) */
148 const EVP_MD *d = ENGINE_get_digest(impl, (*ptype)->type);
149 if(!d)
150 {
151 /* Same comment from evp_enc.c */
152 EVPerr(EVP_F_DO_EVP_MD_ENGINE_FULL,EVP_R_INITIALIZATION_ERROR);
153 return 0;
154 }
155 /* We'll use the ENGINE's private digest definition */
156 *ptype = d;
157 /* Store the ENGINE functional reference so we know
158 * 'type' came from an ENGINE and we need to release
159 * it when done. */
160 ctx->engine = impl;
161 }
162 else
163 ctx->engine = NULL;
164 }
165 else
166 if(!ctx->digest)
167 {
168 EVPerr(EVP_F_DO_EVP_MD_ENGINE_FULL,EVP_R_NO_DIGEST_SET);
169 return 0;
170 }
171 return 1;
172 }
173
174void int_EVP_MD_init_engine_callbacks(void)
175 {
176 int_EVP_MD_set_engine_callbacks(
177 ENGINE_init, ENGINE_finish, do_evp_md_engine_full);
178 }
179#endif
180#endif
diff --git a/src/lib/libcrypto/evp/digest.c b/src/lib/libcrypto/evp/digest.c
index 3bc2d1295c..982ba2b136 100644
--- a/src/lib/libcrypto/evp/digest.c
+++ b/src/lib/libcrypto/evp/digest.c
@@ -116,7 +116,6 @@
116#ifndef OPENSSL_NO_ENGINE 116#ifndef OPENSSL_NO_ENGINE
117#include <openssl/engine.h> 117#include <openssl/engine.h>
118#endif 118#endif
119#include "evp_locl.h"
120 119
121void EVP_MD_CTX_init(EVP_MD_CTX *ctx) 120void EVP_MD_CTX_init(EVP_MD_CTX *ctx)
122 { 121 {
@@ -127,7 +126,8 @@ EVP_MD_CTX *EVP_MD_CTX_create(void)
127 { 126 {
128 EVP_MD_CTX *ctx=OPENSSL_malloc(sizeof *ctx); 127 EVP_MD_CTX *ctx=OPENSSL_malloc(sizeof *ctx);
129 128
130 EVP_MD_CTX_init(ctx); 129 if (ctx)
130 EVP_MD_CTX_init(ctx);
131 131
132 return ctx; 132 return ctx;
133 } 133 }
@@ -138,77 +138,18 @@ int EVP_DigestInit(EVP_MD_CTX *ctx, const EVP_MD *type)
138 return EVP_DigestInit_ex(ctx, type, NULL); 138 return EVP_DigestInit_ex(ctx, type, NULL);
139 } 139 }
140 140
141#ifdef OPENSSL_FIPS 141int EVP_DigestInit_ex(EVP_MD_CTX *ctx, const EVP_MD *type, ENGINE *impl)
142
143/* The purpose of these is to trap programs that attempt to use non FIPS
144 * algorithms in FIPS mode and ignore the errors.
145 */
146
147static int bad_init(EVP_MD_CTX *ctx)
148 { FIPS_ERROR_IGNORED("Digest init"); return 0;}
149
150static int bad_update(EVP_MD_CTX *ctx,const void *data,size_t count)
151 { FIPS_ERROR_IGNORED("Digest update"); return 0;}
152
153static int bad_final(EVP_MD_CTX *ctx,unsigned char *md)
154 { FIPS_ERROR_IGNORED("Digest Final"); return 0;}
155
156static const EVP_MD bad_md =
157 { 142 {
158 0, 143 EVP_MD_CTX_clear_flags(ctx,EVP_MD_CTX_FLAG_CLEANED);
159 0,
160 0,
161 0,
162 bad_init,
163 bad_update,
164 bad_final,
165 NULL,
166 NULL,
167 NULL,
168 0,
169 {0,0,0,0},
170 };
171
172#endif
173
174#ifndef OPENSSL_NO_ENGINE 144#ifndef OPENSSL_NO_ENGINE
175 145 /* Whether it's nice or not, "Inits" can be used on "Final"'d contexts
176#ifdef OPENSSL_FIPS 146 * so this context may already have an ENGINE! Try to avoid releasing
177 147 * the previous handle, re-querying for an ENGINE, and having a
178static int do_engine_null(ENGINE *impl) { return 0;} 148 * reinitialisation, when it may all be unecessary. */
179static int do_evp_md_engine_null(EVP_MD_CTX *ctx, 149 if (ctx->engine && ctx->digest && (!type ||
180 const EVP_MD **ptype, ENGINE *impl) 150 (type && (type->type == ctx->digest->type))))
181 { return 1; } 151 goto skip_to_init;
182 152 if (type)
183static int (*do_engine_init)(ENGINE *impl)
184 = do_engine_null;
185
186static int (*do_engine_finish)(ENGINE *impl)
187 = do_engine_null;
188
189static int (*do_evp_md_engine)
190 (EVP_MD_CTX *ctx, const EVP_MD **ptype, ENGINE *impl)
191 = do_evp_md_engine_null;
192
193void int_EVP_MD_set_engine_callbacks(
194 int (*eng_md_init)(ENGINE *impl),
195 int (*eng_md_fin)(ENGINE *impl),
196 int (*eng_md_evp)
197 (EVP_MD_CTX *ctx, const EVP_MD **ptype, ENGINE *impl))
198 {
199 do_engine_init = eng_md_init;
200 do_engine_finish = eng_md_fin;
201 do_evp_md_engine = eng_md_evp;
202 }
203
204#else
205
206#define do_engine_init ENGINE_init
207#define do_engine_finish ENGINE_finish
208
209static int do_evp_md_engine(EVP_MD_CTX *ctx, const EVP_MD **ptype, ENGINE *impl)
210 {
211 if (*ptype)
212 { 153 {
213 /* Ensure an ENGINE left lying around from last time is cleared 154 /* Ensure an ENGINE left lying around from last time is cleared
214 * (the previous check attempted to avoid this if the same 155 * (the previous check attempted to avoid this if the same
@@ -219,25 +160,26 @@ static int do_evp_md_engine(EVP_MD_CTX *ctx, const EVP_MD **ptype, ENGINE *impl)
219 { 160 {
220 if (!ENGINE_init(impl)) 161 if (!ENGINE_init(impl))
221 { 162 {
222 EVPerr(EVP_F_DO_EVP_MD_ENGINE,EVP_R_INITIALIZATION_ERROR); 163 EVPerr(EVP_F_EVP_DIGESTINIT_EX,EVP_R_INITIALIZATION_ERROR);
223 return 0; 164 return 0;
224 } 165 }
225 } 166 }
226 else 167 else
227 /* Ask if an ENGINE is reserved for this job */ 168 /* Ask if an ENGINE is reserved for this job */
228 impl = ENGINE_get_digest_engine((*ptype)->type); 169 impl = ENGINE_get_digest_engine(type->type);
229 if(impl) 170 if(impl)
230 { 171 {
231 /* There's an ENGINE for this job ... (apparently) */ 172 /* There's an ENGINE for this job ... (apparently) */
232 const EVP_MD *d = ENGINE_get_digest(impl, (*ptype)->type); 173 const EVP_MD *d = ENGINE_get_digest(impl, type->type);
233 if(!d) 174 if(!d)
234 { 175 {
235 /* Same comment from evp_enc.c */ 176 /* Same comment from evp_enc.c */
236 EVPerr(EVP_F_DO_EVP_MD_ENGINE,EVP_R_INITIALIZATION_ERROR); 177 EVPerr(EVP_F_EVP_DIGESTINIT_EX,EVP_R_INITIALIZATION_ERROR);
178 ENGINE_finish(impl);
237 return 0; 179 return 0;
238 } 180 }
239 /* We'll use the ENGINE's private digest definition */ 181 /* We'll use the ENGINE's private digest definition */
240 *ptype = d; 182 type = d;
241 /* Store the ENGINE functional reference so we know 183 /* Store the ENGINE functional reference so we know
242 * 'type' came from an ENGINE and we need to release 184 * 'type' came from an ENGINE and we need to release
243 * it when done. */ 185 * it when done. */
@@ -249,71 +191,46 @@ static int do_evp_md_engine(EVP_MD_CTX *ctx, const EVP_MD **ptype, ENGINE *impl)
249 else 191 else
250 if(!ctx->digest) 192 if(!ctx->digest)
251 { 193 {
252 EVPerr(EVP_F_DO_EVP_MD_ENGINE,EVP_R_NO_DIGEST_SET); 194 EVPerr(EVP_F_EVP_DIGESTINIT_EX,EVP_R_NO_DIGEST_SET);
253 return 0; 195 return 0;
254 } 196 }
255 return 1;
256 }
257
258#endif
259
260#endif
261
262int EVP_DigestInit_ex(EVP_MD_CTX *ctx, const EVP_MD *type, ENGINE *impl)
263 {
264 M_EVP_MD_CTX_clear_flags(ctx,EVP_MD_CTX_FLAG_CLEANED);
265#ifdef OPENSSL_FIPS
266 if(FIPS_selftest_failed())
267 {
268 FIPSerr(FIPS_F_EVP_DIGESTINIT_EX,FIPS_R_FIPS_SELFTEST_FAILED);
269 ctx->digest = &bad_md;
270 return 0;
271 }
272#endif
273#ifndef OPENSSL_NO_ENGINE
274 /* Whether it's nice or not, "Inits" can be used on "Final"'d contexts
275 * so this context may already have an ENGINE! Try to avoid releasing
276 * the previous handle, re-querying for an ENGINE, and having a
277 * reinitialisation, when it may all be unecessary. */
278 if (ctx->engine && ctx->digest && (!type ||
279 (type && (type->type == ctx->digest->type))))
280 goto skip_to_init;
281 if (!do_evp_md_engine(ctx, &type, impl))
282 return 0;
283#endif 197#endif
284 if (ctx->digest != type) 198 if (ctx->digest != type)
285 { 199 {
286#ifdef OPENSSL_FIPS 200 if (ctx->digest && ctx->digest->ctx_size)
287 if (FIPS_mode()) 201 OPENSSL_free(ctx->md_data);
202 ctx->digest=type;
203 if (!(ctx->flags & EVP_MD_CTX_FLAG_NO_INIT) && type->ctx_size)
288 { 204 {
289 if (!(type->flags & EVP_MD_FLAG_FIPS) 205 ctx->update = type->update;
290 && !(ctx->flags & EVP_MD_CTX_FLAG_NON_FIPS_ALLOW)) 206 ctx->md_data=OPENSSL_malloc(type->ctx_size);
207 if (ctx->md_data == NULL)
291 { 208 {
292 EVPerr(EVP_F_EVP_DIGESTINIT_EX, EVP_R_DISABLED_FOR_FIPS); 209 EVPerr(EVP_F_EVP_DIGESTINIT_EX,
293 ctx->digest = &bad_md; 210 ERR_R_MALLOC_FAILURE);
294 return 0; 211 return 0;
295 } 212 }
296 } 213 }
297#endif
298 if (ctx->digest && ctx->digest->ctx_size)
299 OPENSSL_free(ctx->md_data);
300 ctx->digest=type;
301 if (type->ctx_size)
302 ctx->md_data=OPENSSL_malloc(type->ctx_size);
303 } 214 }
304#ifndef OPENSSL_NO_ENGINE 215#ifndef OPENSSL_NO_ENGINE
305 skip_to_init: 216skip_to_init:
306#endif 217#endif
218 if (ctx->pctx)
219 {
220 int r;
221 r = EVP_PKEY_CTX_ctrl(ctx->pctx, -1, EVP_PKEY_OP_TYPE_SIG,
222 EVP_PKEY_CTRL_DIGESTINIT, 0, ctx);
223 if (r <= 0 && (r != -2))
224 return 0;
225 }
226 if (ctx->flags & EVP_MD_CTX_FLAG_NO_INIT)
227 return 1;
307 return ctx->digest->init(ctx); 228 return ctx->digest->init(ctx);
308 } 229 }
309 230
310int EVP_DigestUpdate(EVP_MD_CTX *ctx, const void *data, 231int EVP_DigestUpdate(EVP_MD_CTX *ctx, const void *data, size_t count)
311 size_t count)
312 { 232 {
313#ifdef OPENSSL_FIPS 233 return ctx->update(ctx,data,count);
314 FIPS_selftest_check();
315#endif
316 return ctx->digest->update(ctx,data,count);
317 } 234 }
318 235
319/* The caller can assume that this removes any secret data from the context */ 236/* The caller can assume that this removes any secret data from the context */
@@ -329,9 +246,6 @@ int EVP_DigestFinal(EVP_MD_CTX *ctx, unsigned char *md, unsigned int *size)
329int EVP_DigestFinal_ex(EVP_MD_CTX *ctx, unsigned char *md, unsigned int *size) 246int EVP_DigestFinal_ex(EVP_MD_CTX *ctx, unsigned char *md, unsigned int *size)
330 { 247 {
331 int ret; 248 int ret;
332#ifdef OPENSSL_FIPS
333 FIPS_selftest_check();
334#endif
335 249
336 OPENSSL_assert(ctx->digest->md_size <= EVP_MAX_MD_SIZE); 250 OPENSSL_assert(ctx->digest->md_size <= EVP_MAX_MD_SIZE);
337 ret=ctx->digest->final(ctx,md); 251 ret=ctx->digest->final(ctx,md);
@@ -340,7 +254,7 @@ int EVP_DigestFinal_ex(EVP_MD_CTX *ctx, unsigned char *md, unsigned int *size)
340 if (ctx->digest->cleanup) 254 if (ctx->digest->cleanup)
341 { 255 {
342 ctx->digest->cleanup(ctx); 256 ctx->digest->cleanup(ctx);
343 M_EVP_MD_CTX_set_flags(ctx,EVP_MD_CTX_FLAG_CLEANED); 257 EVP_MD_CTX_set_flags(ctx,EVP_MD_CTX_FLAG_CLEANED);
344 } 258 }
345 memset(ctx->md_data,0,ctx->digest->ctx_size); 259 memset(ctx->md_data,0,ctx->digest->ctx_size);
346 return ret; 260 return ret;
@@ -362,7 +276,7 @@ int EVP_MD_CTX_copy_ex(EVP_MD_CTX *out, const EVP_MD_CTX *in)
362 } 276 }
363#ifndef OPENSSL_NO_ENGINE 277#ifndef OPENSSL_NO_ENGINE
364 /* Make sure it's safe to copy a digest context using an ENGINE */ 278 /* Make sure it's safe to copy a digest context using an ENGINE */
365 if (in->engine && !do_engine_init(in->engine)) 279 if (in->engine && !ENGINE_init(in->engine))
366 { 280 {
367 EVPerr(EVP_F_EVP_MD_CTX_COPY_EX,ERR_R_ENGINE_LIB); 281 EVPerr(EVP_F_EVP_MD_CTX_COPY_EX,ERR_R_ENGINE_LIB);
368 return 0; 282 return 0;
@@ -372,19 +286,40 @@ int EVP_MD_CTX_copy_ex(EVP_MD_CTX *out, const EVP_MD_CTX *in)
372 if (out->digest == in->digest) 286 if (out->digest == in->digest)
373 { 287 {
374 tmp_buf = out->md_data; 288 tmp_buf = out->md_data;
375 M_EVP_MD_CTX_set_flags(out,EVP_MD_CTX_FLAG_REUSE); 289 EVP_MD_CTX_set_flags(out,EVP_MD_CTX_FLAG_REUSE);
376 } 290 }
377 else tmp_buf = NULL; 291 else tmp_buf = NULL;
378 EVP_MD_CTX_cleanup(out); 292 EVP_MD_CTX_cleanup(out);
379 memcpy(out,in,sizeof *out); 293 memcpy(out,in,sizeof *out);
380 294
381 if (out->digest->ctx_size) 295 if (in->md_data && out->digest->ctx_size)
382 { 296 {
383 if (tmp_buf) out->md_data = tmp_buf; 297 if (tmp_buf)
384 else out->md_data=OPENSSL_malloc(out->digest->ctx_size); 298 out->md_data = tmp_buf;
299 else
300 {
301 out->md_data=OPENSSL_malloc(out->digest->ctx_size);
302 if (!out->md_data)
303 {
304 EVPerr(EVP_F_EVP_MD_CTX_COPY_EX,ERR_R_MALLOC_FAILURE);
305 return 0;
306 }
307 }
385 memcpy(out->md_data,in->md_data,out->digest->ctx_size); 308 memcpy(out->md_data,in->md_data,out->digest->ctx_size);
386 } 309 }
387 310
311 out->update = in->update;
312
313 if (in->pctx)
314 {
315 out->pctx = EVP_PKEY_CTX_dup(in->pctx);
316 if (!out->pctx)
317 {
318 EVP_MD_CTX_cleanup(out);
319 return 0;
320 }
321 }
322
388 if (out->digest->copy) 323 if (out->digest->copy)
389 return out->digest->copy(out,in); 324 return out->digest->copy(out,in);
390 325
@@ -398,7 +333,7 @@ int EVP_Digest(const void *data, size_t count,
398 int ret; 333 int ret;
399 334
400 EVP_MD_CTX_init(&ctx); 335 EVP_MD_CTX_init(&ctx);
401 M_EVP_MD_CTX_set_flags(&ctx,EVP_MD_CTX_FLAG_ONESHOT); 336 EVP_MD_CTX_set_flags(&ctx,EVP_MD_CTX_FLAG_ONESHOT);
402 ret=EVP_DigestInit_ex(&ctx, type, impl) 337 ret=EVP_DigestInit_ex(&ctx, type, impl)
403 && EVP_DigestUpdate(&ctx, data, count) 338 && EVP_DigestUpdate(&ctx, data, count)
404 && EVP_DigestFinal_ex(&ctx, md, size); 339 && EVP_DigestFinal_ex(&ctx, md, size);
@@ -420,19 +355,21 @@ int EVP_MD_CTX_cleanup(EVP_MD_CTX *ctx)
420 * because sometimes only copies of the context are ever finalised. 355 * because sometimes only copies of the context are ever finalised.
421 */ 356 */
422 if (ctx->digest && ctx->digest->cleanup 357 if (ctx->digest && ctx->digest->cleanup
423 && !M_EVP_MD_CTX_test_flags(ctx,EVP_MD_CTX_FLAG_CLEANED)) 358 && !EVP_MD_CTX_test_flags(ctx,EVP_MD_CTX_FLAG_CLEANED))
424 ctx->digest->cleanup(ctx); 359 ctx->digest->cleanup(ctx);
425 if (ctx->digest && ctx->digest->ctx_size && ctx->md_data 360 if (ctx->digest && ctx->digest->ctx_size && ctx->md_data
426 && !M_EVP_MD_CTX_test_flags(ctx, EVP_MD_CTX_FLAG_REUSE)) 361 && !EVP_MD_CTX_test_flags(ctx, EVP_MD_CTX_FLAG_REUSE))
427 { 362 {
428 OPENSSL_cleanse(ctx->md_data,ctx->digest->ctx_size); 363 OPENSSL_cleanse(ctx->md_data,ctx->digest->ctx_size);
429 OPENSSL_free(ctx->md_data); 364 OPENSSL_free(ctx->md_data);
430 } 365 }
366 if (ctx->pctx)
367 EVP_PKEY_CTX_free(ctx->pctx);
431#ifndef OPENSSL_NO_ENGINE 368#ifndef OPENSSL_NO_ENGINE
432 if(ctx->engine) 369 if(ctx->engine)
433 /* The EVP_MD we used belongs to an ENGINE, release the 370 /* The EVP_MD we used belongs to an ENGINE, release the
434 * functional reference we held for this reason. */ 371 * functional reference we held for this reason. */
435 do_engine_finish(ctx->engine); 372 ENGINE_finish(ctx->engine);
436#endif 373#endif
437 memset(ctx,'\0',sizeof *ctx); 374 memset(ctx,'\0',sizeof *ctx);
438 375
diff --git a/src/lib/libcrypto/evp/e_aes.c b/src/lib/libcrypto/evp/e_aes.c
index c9a5ee8d75..bd6c0a3a62 100644
--- a/src/lib/libcrypto/evp/e_aes.c
+++ b/src/lib/libcrypto/evp/e_aes.c
@@ -69,29 +69,32 @@ typedef struct
69 69
70IMPLEMENT_BLOCK_CIPHER(aes_128, ks, AES, EVP_AES_KEY, 70IMPLEMENT_BLOCK_CIPHER(aes_128, ks, AES, EVP_AES_KEY,
71 NID_aes_128, 16, 16, 16, 128, 71 NID_aes_128, 16, 16, 16, 128,
72 EVP_CIPH_FLAG_FIPS|EVP_CIPH_FLAG_DEFAULT_ASN1, 72 0, aes_init_key, NULL,
73 aes_init_key, 73 EVP_CIPHER_set_asn1_iv,
74 NULL, NULL, NULL, NULL) 74 EVP_CIPHER_get_asn1_iv,
75 NULL)
75IMPLEMENT_BLOCK_CIPHER(aes_192, ks, AES, EVP_AES_KEY, 76IMPLEMENT_BLOCK_CIPHER(aes_192, ks, AES, EVP_AES_KEY,
76 NID_aes_192, 16, 24, 16, 128, 77 NID_aes_192, 16, 24, 16, 128,
77 EVP_CIPH_FLAG_FIPS|EVP_CIPH_FLAG_DEFAULT_ASN1, 78 0, aes_init_key, NULL,
78 aes_init_key, 79 EVP_CIPHER_set_asn1_iv,
79 NULL, NULL, NULL, NULL) 80 EVP_CIPHER_get_asn1_iv,
81 NULL)
80IMPLEMENT_BLOCK_CIPHER(aes_256, ks, AES, EVP_AES_KEY, 82IMPLEMENT_BLOCK_CIPHER(aes_256, ks, AES, EVP_AES_KEY,
81 NID_aes_256, 16, 32, 16, 128, 83 NID_aes_256, 16, 32, 16, 128,
82 EVP_CIPH_FLAG_FIPS|EVP_CIPH_FLAG_DEFAULT_ASN1, 84 0, aes_init_key, NULL,
83 aes_init_key, 85 EVP_CIPHER_set_asn1_iv,
84 NULL, NULL, NULL, NULL) 86 EVP_CIPHER_get_asn1_iv,
87 NULL)
85 88
86#define IMPLEMENT_AES_CFBR(ksize,cbits,flags) IMPLEMENT_CFBR(aes,AES,EVP_AES_KEY,ks,ksize,cbits,16,flags) 89#define IMPLEMENT_AES_CFBR(ksize,cbits) IMPLEMENT_CFBR(aes,AES,EVP_AES_KEY,ks,ksize,cbits,16)
87 90
88IMPLEMENT_AES_CFBR(128,1,EVP_CIPH_FLAG_FIPS) 91IMPLEMENT_AES_CFBR(128,1)
89IMPLEMENT_AES_CFBR(192,1,EVP_CIPH_FLAG_FIPS) 92IMPLEMENT_AES_CFBR(192,1)
90IMPLEMENT_AES_CFBR(256,1,EVP_CIPH_FLAG_FIPS) 93IMPLEMENT_AES_CFBR(256,1)
91 94
92IMPLEMENT_AES_CFBR(128,8,EVP_CIPH_FLAG_FIPS) 95IMPLEMENT_AES_CFBR(128,8)
93IMPLEMENT_AES_CFBR(192,8,EVP_CIPH_FLAG_FIPS) 96IMPLEMENT_AES_CFBR(192,8)
94IMPLEMENT_AES_CFBR(256,8,EVP_CIPH_FLAG_FIPS) 97IMPLEMENT_AES_CFBR(256,8)
95 98
96static int aes_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key, 99static int aes_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key,
97 const unsigned char *iv, int enc) 100 const unsigned char *iv, int enc)
diff --git a/src/lib/libcrypto/evp/e_des.c b/src/lib/libcrypto/evp/e_des.c
index 04376df232..ca009f2c52 100644
--- a/src/lib/libcrypto/evp/e_des.c
+++ b/src/lib/libcrypto/evp/e_des.c
@@ -72,7 +72,7 @@ static int des_ctrl(EVP_CIPHER_CTX *c, int type, int arg, void *ptr);
72/* Because of various casts and different names can't use IMPLEMENT_BLOCK_CIPHER */ 72/* Because of various casts and different names can't use IMPLEMENT_BLOCK_CIPHER */
73 73
74static int des_ecb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, 74static int des_ecb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
75 const unsigned char *in, unsigned int inl) 75 const unsigned char *in, size_t inl)
76{ 76{
77 BLOCK_CIPHER_ecb_loop() 77 BLOCK_CIPHER_ecb_loop()
78 DES_ecb_encrypt((DES_cblock *)(in + i), (DES_cblock *)(out + i), ctx->cipher_data, ctx->encrypt); 78 DES_ecb_encrypt((DES_cblock *)(in + i), (DES_cblock *)(out + i), ctx->cipher_data, ctx->encrypt);
@@ -80,24 +80,52 @@ static int des_ecb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
80} 80}
81 81
82static int des_ofb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, 82static int des_ofb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
83 const unsigned char *in, unsigned int inl) 83 const unsigned char *in, size_t inl)
84{ 84{
85 DES_ofb64_encrypt(in, out, (long)inl, ctx->cipher_data, (DES_cblock *)ctx->iv, &ctx->num); 85 while(inl>=EVP_MAXCHUNK)
86 {
87 DES_ofb64_encrypt(in, out, (long)EVP_MAXCHUNK, ctx->cipher_data,
88 (DES_cblock *)ctx->iv, &ctx->num);
89 inl-=EVP_MAXCHUNK;
90 in +=EVP_MAXCHUNK;
91 out+=EVP_MAXCHUNK;
92 }
93 if (inl)
94 DES_ofb64_encrypt(in, out, (long)inl, ctx->cipher_data,
95 (DES_cblock *)ctx->iv, &ctx->num);
86 return 1; 96 return 1;
87} 97}
88 98
89static int des_cbc_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, 99static int des_cbc_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
90 const unsigned char *in, unsigned int inl) 100 const unsigned char *in, size_t inl)
91{ 101{
92 DES_ncbc_encrypt(in, out, (long)inl, ctx->cipher_data, 102 while(inl>=EVP_MAXCHUNK)
93 (DES_cblock *)ctx->iv, ctx->encrypt); 103 {
104 DES_ncbc_encrypt(in, out, (long)EVP_MAXCHUNK, ctx->cipher_data,
105 (DES_cblock *)ctx->iv, ctx->encrypt);
106 inl-=EVP_MAXCHUNK;
107 in +=EVP_MAXCHUNK;
108 out+=EVP_MAXCHUNK;
109 }
110 if (inl)
111 DES_ncbc_encrypt(in, out, (long)inl, ctx->cipher_data,
112 (DES_cblock *)ctx->iv, ctx->encrypt);
94 return 1; 113 return 1;
95} 114}
96 115
97static int des_cfb64_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, 116static int des_cfb64_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
98 const unsigned char *in, unsigned int inl) 117 const unsigned char *in, size_t inl)
99{ 118{
100 DES_cfb64_encrypt(in, out, (long)inl, ctx->cipher_data, 119 while(inl>=EVP_MAXCHUNK)
120 {
121 DES_cfb64_encrypt(in,out, (long)EVP_MAXCHUNK, ctx->cipher_data,
122 (DES_cblock *)ctx->iv, &ctx->num, ctx->encrypt);
123 inl-=EVP_MAXCHUNK;
124 in +=EVP_MAXCHUNK;
125 out+=EVP_MAXCHUNK;
126 }
127 if (inl)
128 DES_cfb64_encrypt(in, out, (long)inl, ctx->cipher_data,
101 (DES_cblock *)ctx->iv, &ctx->num, ctx->encrypt); 129 (DES_cblock *)ctx->iv, &ctx->num, ctx->encrypt);
102 return 1; 130 return 1;
103} 131}
@@ -105,45 +133,62 @@ static int des_cfb64_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
105/* Although we have a CFB-r implementation for DES, it doesn't pack the right 133/* Although we have a CFB-r implementation for DES, it doesn't pack the right
106 way, so wrap it here */ 134 way, so wrap it here */
107static int des_cfb1_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, 135static int des_cfb1_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
108 const unsigned char *in, unsigned int inl) 136 const unsigned char *in, size_t inl)
109 { 137 {
110 unsigned int n; 138 size_t n,chunk=EVP_MAXCHUNK/8;
111 unsigned char c[1],d[1]; 139 unsigned char c[1],d[1];
112 140
113 for(n=0 ; n < inl ; ++n) 141 if (inl<chunk) chunk=inl;
142
143 while (inl && inl>=chunk)
114 { 144 {
115 c[0]=(in[n/8]&(1 << (7-n%8))) ? 0x80 : 0; 145 for(n=0 ; n < chunk*8; ++n)
116 DES_cfb_encrypt(c,d,1,1,ctx->cipher_data,(DES_cblock *)ctx->iv, 146 {
147 c[0]=(in[n/8]&(1 << (7-n%8))) ? 0x80 : 0;
148 DES_cfb_encrypt(c,d,1,1,ctx->cipher_data,(DES_cblock *)ctx->iv,
117 ctx->encrypt); 149 ctx->encrypt);
118 out[n/8]=(out[n/8]&~(0x80 >> (n%8)))|((d[0]&0x80) >> (n%8)); 150 out[n/8]=(out[n/8]&~(0x80 >> (unsigned int)(n%8))) |
151 ((d[0]&0x80) >> (unsigned int)(n%8));
152 }
153 inl-=chunk;
154 in +=chunk;
155 out+=chunk;
156 if (inl<chunk) chunk=inl;
119 } 157 }
158
120 return 1; 159 return 1;
121 } 160 }
122 161
123static int des_cfb8_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, 162static int des_cfb8_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
124 const unsigned char *in, unsigned int inl) 163 const unsigned char *in, size_t inl)
125 { 164 {
126 DES_cfb_encrypt(in,out,8,inl,ctx->cipher_data,(DES_cblock *)ctx->iv, 165 while (inl>=EVP_MAXCHUNK)
127 ctx->encrypt); 166 {
167 DES_cfb_encrypt(in,out,8,(long)EVP_MAXCHUNK,ctx->cipher_data,
168 (DES_cblock *)ctx->iv,ctx->encrypt);
169 inl-=EVP_MAXCHUNK;
170 in +=EVP_MAXCHUNK;
171 out+=EVP_MAXCHUNK;
172 }
173 if (inl)
174 DES_cfb_encrypt(in,out,8,(long)inl,ctx->cipher_data,
175 (DES_cblock *)ctx->iv,ctx->encrypt);
128 return 1; 176 return 1;
129 } 177 }
130 178
131BLOCK_CIPHER_defs(des, DES_key_schedule, NID_des, 8, 8, 8, 64, 179BLOCK_CIPHER_defs(des, DES_key_schedule, NID_des, 8, 8, 8, 64,
132 EVP_CIPH_RAND_KEY, 180 EVP_CIPH_RAND_KEY, des_init_key, NULL,
133 des_init_key, NULL,
134 EVP_CIPHER_set_asn1_iv, 181 EVP_CIPHER_set_asn1_iv,
135 EVP_CIPHER_get_asn1_iv, 182 EVP_CIPHER_get_asn1_iv,
136 des_ctrl) 183 des_ctrl)
137 184
138BLOCK_CIPHER_def_cfb(des,DES_key_schedule,NID_des,8,8,1, 185BLOCK_CIPHER_def_cfb(des,DES_key_schedule,NID_des,8,8,1,
139 EVP_CIPH_RAND_KEY, 186 EVP_CIPH_RAND_KEY, des_init_key,NULL,
140 des_init_key, NULL,
141 EVP_CIPHER_set_asn1_iv, 187 EVP_CIPHER_set_asn1_iv,
142 EVP_CIPHER_get_asn1_iv,des_ctrl) 188 EVP_CIPHER_get_asn1_iv,des_ctrl)
143 189
144BLOCK_CIPHER_def_cfb(des,DES_key_schedule,NID_des,8,8,8, 190BLOCK_CIPHER_def_cfb(des,DES_key_schedule,NID_des,8,8,8,
145 EVP_CIPH_RAND_KEY, 191 EVP_CIPH_RAND_KEY,des_init_key,NULL,
146 des_init_key,NULL,
147 EVP_CIPHER_set_asn1_iv, 192 EVP_CIPHER_set_asn1_iv,
148 EVP_CIPHER_get_asn1_iv,des_ctrl) 193 EVP_CIPHER_get_asn1_iv,des_ctrl)
149 194
diff --git a/src/lib/libcrypto/evp/e_des3.c b/src/lib/libcrypto/evp/e_des3.c
index f910af19b1..3232cfe024 100644
--- a/src/lib/libcrypto/evp/e_des3.c
+++ b/src/lib/libcrypto/evp/e_des3.c
@@ -85,7 +85,7 @@ typedef struct
85/* Because of various casts and different args can't use IMPLEMENT_BLOCK_CIPHER */ 85/* Because of various casts and different args can't use IMPLEMENT_BLOCK_CIPHER */
86 86
87static int des_ede_ecb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, 87static int des_ede_ecb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
88 const unsigned char *in, unsigned int inl) 88 const unsigned char *in, size_t inl)
89{ 89{
90 BLOCK_CIPHER_ecb_loop() 90 BLOCK_CIPHER_ecb_loop()
91 DES_ecb3_encrypt((const_DES_cblock *)(in + i), 91 DES_ecb3_encrypt((const_DES_cblock *)(in + i),
@@ -97,48 +97,80 @@ static int des_ede_ecb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
97} 97}
98 98
99static int des_ede_ofb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, 99static int des_ede_ofb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
100 const unsigned char *in, unsigned int inl) 100 const unsigned char *in, size_t inl)
101{ 101{
102 DES_ede3_ofb64_encrypt(in, out, (long)inl, 102 if (inl>=EVP_MAXCHUNK)
103 {
104 DES_ede3_ofb64_encrypt(in, out, (long)EVP_MAXCHUNK,
103 &data(ctx)->ks1, &data(ctx)->ks2, &data(ctx)->ks3, 105 &data(ctx)->ks1, &data(ctx)->ks2, &data(ctx)->ks3,
104 (DES_cblock *)ctx->iv, &ctx->num); 106 (DES_cblock *)ctx->iv, &ctx->num);
107 inl-=EVP_MAXCHUNK;
108 in +=EVP_MAXCHUNK;
109 out+=EVP_MAXCHUNK;
110 }
111 if (inl)
112 DES_ede3_ofb64_encrypt(in, out, (long)inl,
113 &data(ctx)->ks1, &data(ctx)->ks2, &data(ctx)->ks3,
114 (DES_cblock *)ctx->iv, &ctx->num);
115
105 return 1; 116 return 1;
106} 117}
107 118
108static int des_ede_cbc_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, 119static int des_ede_cbc_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
109 const unsigned char *in, unsigned int inl) 120 const unsigned char *in, size_t inl)
110{ 121{
111#ifdef KSSL_DEBUG 122#ifdef KSSL_DEBUG
112 { 123 {
113 int i; 124 int i;
114 printf("des_ede_cbc_cipher(ctx=%lx, buflen=%d)\n", (unsigned long)ctx, ctx->buf_len); 125 char *cp;
126 printf("des_ede_cbc_cipher(ctx=%lx, buflen=%d)\n", ctx, ctx->buf_len);
115 printf("\t iv= "); 127 printf("\t iv= ");
116 for(i=0;i<8;i++) 128 for(i=0;i<8;i++)
117 printf("%02X",ctx->iv[i]); 129 printf("%02X",ctx->iv[i]);
118 printf("\n"); 130 printf("\n");
119 } 131 }
120#endif /* KSSL_DEBUG */ 132#endif /* KSSL_DEBUG */
121 DES_ede3_cbc_encrypt(in, out, (long)inl, 133 if (inl>=EVP_MAXCHUNK)
134 {
135 DES_ede3_cbc_encrypt(in, out, (long)EVP_MAXCHUNK,
122 &data(ctx)->ks1, &data(ctx)->ks2, &data(ctx)->ks3, 136 &data(ctx)->ks1, &data(ctx)->ks2, &data(ctx)->ks3,
123 (DES_cblock *)ctx->iv, ctx->encrypt); 137 (DES_cblock *)ctx->iv, ctx->encrypt);
138 inl-=EVP_MAXCHUNK;
139 in +=EVP_MAXCHUNK;
140 out+=EVP_MAXCHUNK;
141 }
142 if (inl)
143 DES_ede3_cbc_encrypt(in, out, (long)inl,
144 &data(ctx)->ks1, &data(ctx)->ks2, &data(ctx)->ks3,
145 (DES_cblock *)ctx->iv, ctx->encrypt);
124 return 1; 146 return 1;
125} 147}
126 148
127static int des_ede_cfb64_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, 149static int des_ede_cfb64_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
128 const unsigned char *in, unsigned int inl) 150 const unsigned char *in, size_t inl)
129{ 151{
130 DES_ede3_cfb64_encrypt(in, out, (long)inl, 152 if (inl>=EVP_MAXCHUNK)
153 {
154 DES_ede3_cfb64_encrypt(in, out, (long)EVP_MAXCHUNK,
131 &data(ctx)->ks1, &data(ctx)->ks2, &data(ctx)->ks3, 155 &data(ctx)->ks1, &data(ctx)->ks2, &data(ctx)->ks3,
132 (DES_cblock *)ctx->iv, &ctx->num, ctx->encrypt); 156 (DES_cblock *)ctx->iv, &ctx->num, ctx->encrypt);
157 inl-=EVP_MAXCHUNK;
158 in +=EVP_MAXCHUNK;
159 out+=EVP_MAXCHUNK;
160 }
161 if (inl)
162 DES_ede3_cfb64_encrypt(in, out, (long)inl,
163 &data(ctx)->ks1, &data(ctx)->ks2, &data(ctx)->ks3,
164 (DES_cblock *)ctx->iv, &ctx->num, ctx->encrypt);
133 return 1; 165 return 1;
134} 166}
135 167
136/* Although we have a CFB-r implementation for 3-DES, it doesn't pack the right 168/* Although we have a CFB-r implementation for 3-DES, it doesn't pack the right
137 way, so wrap it here */ 169 way, so wrap it here */
138static int des_ede3_cfb1_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, 170static int des_ede3_cfb1_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
139 const unsigned char *in, unsigned int inl) 171 const unsigned char *in, size_t inl)
140 { 172 {
141 unsigned int n; 173 size_t n;
142 unsigned char c[1],d[1]; 174 unsigned char c[1],d[1];
143 175
144 for(n=0 ; n < inl ; ++n) 176 for(n=0 ; n < inl ; ++n)
@@ -147,25 +179,36 @@ static int des_ede3_cfb1_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
147 DES_ede3_cfb_encrypt(c,d,1,1, 179 DES_ede3_cfb_encrypt(c,d,1,1,
148 &data(ctx)->ks1,&data(ctx)->ks2,&data(ctx)->ks3, 180 &data(ctx)->ks1,&data(ctx)->ks2,&data(ctx)->ks3,
149 (DES_cblock *)ctx->iv,ctx->encrypt); 181 (DES_cblock *)ctx->iv,ctx->encrypt);
150 out[n/8]=(out[n/8]&~(0x80 >> (n%8)))|((d[0]&0x80) >> (n%8)); 182 out[n/8]=(out[n/8]&~(0x80 >> (unsigned int)(n%8))) |
183 ((d[0]&0x80) >> (unsigned int)(n%8));
151 } 184 }
152 185
153 return 1; 186 return 1;
154 } 187 }
155 188
156static int des_ede3_cfb8_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, 189static int des_ede3_cfb8_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
157 const unsigned char *in, unsigned int inl) 190 const unsigned char *in, size_t inl)
158 { 191 {
159 DES_ede3_cfb_encrypt(in,out,8,inl, 192 while (inl>=EVP_MAXCHUNK)
193 {
194 DES_ede3_cfb_encrypt(in,out,8,(long)EVP_MAXCHUNK,
160 &data(ctx)->ks1,&data(ctx)->ks2,&data(ctx)->ks3, 195 &data(ctx)->ks1,&data(ctx)->ks2,&data(ctx)->ks3,
161 (DES_cblock *)ctx->iv,ctx->encrypt); 196 (DES_cblock *)ctx->iv,ctx->encrypt);
197 inl-=EVP_MAXCHUNK;
198 in +=EVP_MAXCHUNK;
199 out+=EVP_MAXCHUNK;
200 }
201 if (inl)
202 DES_ede3_cfb_encrypt(in,out,8,(long)inl,
203 &data(ctx)->ks1,&data(ctx)->ks2,&data(ctx)->ks3,
204 (DES_cblock *)ctx->iv,ctx->encrypt);
162 return 1; 205 return 1;
163 } 206 }
164 207
165BLOCK_CIPHER_defs(des_ede, DES_EDE_KEY, NID_des_ede, 8, 16, 8, 64, 208BLOCK_CIPHER_defs(des_ede, DES_EDE_KEY, NID_des_ede, 8, 16, 8, 64,
166 EVP_CIPH_RAND_KEY|EVP_CIPH_FLAG_FIPS|EVP_CIPH_FLAG_DEFAULT_ASN1, 209 EVP_CIPH_RAND_KEY, des_ede_init_key, NULL,
167 des_ede_init_key, 210 EVP_CIPHER_set_asn1_iv,
168 NULL, NULL, NULL, 211 EVP_CIPHER_get_asn1_iv,
169 des3_ctrl) 212 des3_ctrl)
170 213
171#define des_ede3_cfb64_cipher des_ede_cfb64_cipher 214#define des_ede3_cfb64_cipher des_ede_cfb64_cipher
@@ -174,21 +217,21 @@ BLOCK_CIPHER_defs(des_ede, DES_EDE_KEY, NID_des_ede, 8, 16, 8, 64,
174#define des_ede3_ecb_cipher des_ede_ecb_cipher 217#define des_ede3_ecb_cipher des_ede_ecb_cipher
175 218
176BLOCK_CIPHER_defs(des_ede3, DES_EDE_KEY, NID_des_ede3, 8, 24, 8, 64, 219BLOCK_CIPHER_defs(des_ede3, DES_EDE_KEY, NID_des_ede3, 8, 24, 8, 64,
177 EVP_CIPH_RAND_KEY|EVP_CIPH_FLAG_FIPS|EVP_CIPH_FLAG_DEFAULT_ASN1, 220 EVP_CIPH_RAND_KEY, des_ede3_init_key, NULL,
178 des_ede3_init_key, 221 EVP_CIPHER_set_asn1_iv,
179 NULL, NULL, NULL, 222 EVP_CIPHER_get_asn1_iv,
180 des3_ctrl) 223 des3_ctrl)
181 224
182BLOCK_CIPHER_def_cfb(des_ede3,DES_EDE_KEY,NID_des_ede3,24,8,1, 225BLOCK_CIPHER_def_cfb(des_ede3,DES_EDE_KEY,NID_des_ede3,24,8,1,
183 EVP_CIPH_RAND_KEY|EVP_CIPH_FLAG_FIPS|EVP_CIPH_FLAG_DEFAULT_ASN1, 226 EVP_CIPH_RAND_KEY, des_ede3_init_key,NULL,
184 des_ede3_init_key, 227 EVP_CIPHER_set_asn1_iv,
185 NULL, NULL, NULL, 228 EVP_CIPHER_get_asn1_iv,
186 des3_ctrl) 229 des3_ctrl)
187 230
188BLOCK_CIPHER_def_cfb(des_ede3,DES_EDE_KEY,NID_des_ede3,24,8,8, 231BLOCK_CIPHER_def_cfb(des_ede3,DES_EDE_KEY,NID_des_ede3,24,8,8,
189 EVP_CIPH_RAND_KEY|EVP_CIPH_FLAG_FIPS|EVP_CIPH_FLAG_DEFAULT_ASN1, 232 EVP_CIPH_RAND_KEY, des_ede3_init_key,NULL,
190 des_ede3_init_key, 233 EVP_CIPHER_set_asn1_iv,
191 NULL, NULL, NULL, 234 EVP_CIPHER_get_asn1_iv,
192 des3_ctrl) 235 des3_ctrl)
193 236
194static int des_ede_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key, 237static int des_ede_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key,
@@ -215,7 +258,7 @@ static int des_ede3_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key,
215#ifdef KSSL_DEBUG 258#ifdef KSSL_DEBUG
216 { 259 {
217 int i; 260 int i;
218 printf("des_ede3_init_key(ctx=%lx)\n", (unsigned long)ctx); 261 printf("des_ede3_init_key(ctx=%lx)\n", ctx);
219 printf("\tKEY= "); 262 printf("\tKEY= ");
220 for(i=0;i<24;i++) printf("%02X",key[i]); printf("\n"); 263 for(i=0;i<24;i++) printf("%02X",key[i]); printf("\n");
221 printf("\t IV= "); 264 printf("\t IV= ");
diff --git a/src/lib/libcrypto/evp/e_idea.c b/src/lib/libcrypto/evp/e_idea.c
index 48c33a774a..806b080360 100644
--- a/src/lib/libcrypto/evp/e_idea.c
+++ b/src/lib/libcrypto/evp/e_idea.c
@@ -73,7 +73,7 @@ static int idea_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key,
73 */ 73 */
74 74
75static int idea_ecb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, 75static int idea_ecb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
76 const unsigned char *in, unsigned int inl) 76 const unsigned char *in, size_t inl)
77{ 77{
78 BLOCK_CIPHER_ecb_loop() 78 BLOCK_CIPHER_ecb_loop()
79 idea_ecb_encrypt(in + i, out + i, ctx->cipher_data); 79 idea_ecb_encrypt(in + i, out + i, ctx->cipher_data);
diff --git a/src/lib/libcrypto/evp/e_null.c b/src/lib/libcrypto/evp/e_null.c
index 0872d733e4..7cf50e1416 100644
--- a/src/lib/libcrypto/evp/e_null.c
+++ b/src/lib/libcrypto/evp/e_null.c
@@ -64,12 +64,12 @@
64static int null_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key, 64static int null_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key,
65 const unsigned char *iv,int enc); 65 const unsigned char *iv,int enc);
66static int null_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, 66static int null_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
67 const unsigned char *in, unsigned int inl); 67 const unsigned char *in, size_t inl);
68static const EVP_CIPHER n_cipher= 68static const EVP_CIPHER n_cipher=
69 { 69 {
70 NID_undef, 70 NID_undef,
71 1,0,0, 71 1,0,0,
72 EVP_CIPH_FLAG_FIPS, 72 0,
73 null_init_key, 73 null_init_key,
74 null_cipher, 74 null_cipher,
75 NULL, 75 NULL,
@@ -93,10 +93,10 @@ static int null_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key,
93 } 93 }
94 94
95static int null_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, 95static int null_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
96 const unsigned char *in, unsigned int inl) 96 const unsigned char *in, size_t inl)
97 { 97 {
98 if (in != out) 98 if (in != out)
99 memcpy((char *)out,(const char *)in,(size_t)inl); 99 memcpy((char *)out,(const char *)in,inl);
100 return 1; 100 return 1;
101 } 101 }
102 102
diff --git a/src/lib/libcrypto/evp/e_rc2.c b/src/lib/libcrypto/evp/e_rc2.c
index d37726ffae..f78d781129 100644
--- a/src/lib/libcrypto/evp/e_rc2.c
+++ b/src/lib/libcrypto/evp/e_rc2.c
@@ -223,6 +223,11 @@ static int rc2_ctrl(EVP_CIPHER_CTX *c, int type, int arg, void *ptr)
223 return 1; 223 return 1;
224 } 224 }
225 return 0; 225 return 0;
226#ifdef PBE_PRF_TEST
227 case EVP_CTRL_PBE_PRF_NID:
228 *(int *)ptr = NID_hmacWithMD5;
229 return 1;
230#endif
226 231
227 default: 232 default:
228 return -1; 233 return -1;
diff --git a/src/lib/libcrypto/evp/e_rc4.c b/src/lib/libcrypto/evp/e_rc4.c
index 55baad7446..8b5175e0fd 100644
--- a/src/lib/libcrypto/evp/e_rc4.c
+++ b/src/lib/libcrypto/evp/e_rc4.c
@@ -64,7 +64,6 @@
64#include <openssl/evp.h> 64#include <openssl/evp.h>
65#include <openssl/objects.h> 65#include <openssl/objects.h>
66#include <openssl/rc4.h> 66#include <openssl/rc4.h>
67#include "evp_locl.h"
68 67
69/* FIXME: surely this is available elsewhere? */ 68/* FIXME: surely this is available elsewhere? */
70#define EVP_RC4_KEY_SIZE 16 69#define EVP_RC4_KEY_SIZE 16
@@ -79,7 +78,7 @@ typedef struct
79static int rc4_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key, 78static int rc4_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key,
80 const unsigned char *iv,int enc); 79 const unsigned char *iv,int enc);
81static int rc4_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, 80static int rc4_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
82 const unsigned char *in, unsigned int inl); 81 const unsigned char *in, size_t inl);
83static const EVP_CIPHER r4_cipher= 82static const EVP_CIPHER r4_cipher=
84 { 83 {
85 NID_rc4, 84 NID_rc4,
@@ -129,7 +128,7 @@ static int rc4_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key,
129 } 128 }
130 129
131static int rc4_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, 130static int rc4_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
132 const unsigned char *in, unsigned int inl) 131 const unsigned char *in, size_t inl)
133 { 132 {
134 RC4(&data(ctx)->ks,inl,in,out); 133 RC4(&data(ctx)->ks,inl,in,out);
135 return 1; 134 return 1;
diff --git a/src/lib/libcrypto/evp/e_xcbc_d.c b/src/lib/libcrypto/evp/e_xcbc_d.c
index 8832da2433..250e88c8c5 100644
--- a/src/lib/libcrypto/evp/e_xcbc_d.c
+++ b/src/lib/libcrypto/evp/e_xcbc_d.c
@@ -63,12 +63,13 @@
63 63
64#include <openssl/evp.h> 64#include <openssl/evp.h>
65#include <openssl/objects.h> 65#include <openssl/objects.h>
66#include "evp_locl.h"
66#include <openssl/des.h> 67#include <openssl/des.h>
67 68
68static int desx_cbc_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key, 69static int desx_cbc_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key,
69 const unsigned char *iv,int enc); 70 const unsigned char *iv,int enc);
70static int desx_cbc_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, 71static int desx_cbc_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
71 const unsigned char *in, unsigned int inl); 72 const unsigned char *in, size_t inl);
72 73
73 74
74typedef struct 75typedef struct
@@ -113,13 +114,25 @@ static int desx_cbc_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key,
113 } 114 }
114 115
115static int desx_cbc_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, 116static int desx_cbc_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
116 const unsigned char *in, unsigned int inl) 117 const unsigned char *in, size_t inl)
117 { 118 {
118 DES_xcbc_encrypt(in,out,inl,&data(ctx)->ks, 119 while (inl>=EVP_MAXCHUNK)
120 {
121 DES_xcbc_encrypt(in,out,(long)EVP_MAXCHUNK,&data(ctx)->ks,
119 (DES_cblock *)&(ctx->iv[0]), 122 (DES_cblock *)&(ctx->iv[0]),
120 &data(ctx)->inw, 123 &data(ctx)->inw,
121 &data(ctx)->outw, 124 &data(ctx)->outw,
122 ctx->encrypt); 125 ctx->encrypt);
126 inl-=EVP_MAXCHUNK;
127 in +=EVP_MAXCHUNK;
128 out+=EVP_MAXCHUNK;
129 }
130 if (inl)
131 DES_xcbc_encrypt(in,out,(long)inl,&data(ctx)->ks,
132 (DES_cblock *)&(ctx->iv[0]),
133 &data(ctx)->inw,
134 &data(ctx)->outw,
135 ctx->encrypt);
123 return 1; 136 return 1;
124 } 137 }
125#endif 138#endif
diff --git a/src/lib/libcrypto/evp/enc_min.c b/src/lib/libcrypto/evp/enc_min.c
deleted file mode 100644
index 7fba38ee24..0000000000
--- a/src/lib/libcrypto/evp/enc_min.c
+++ /dev/null
@@ -1,390 +0,0 @@
1/* crypto/evp/enc_min.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 "cryptlib.h"
61#include <openssl/evp.h>
62#include <openssl/err.h>
63#include <openssl/rand.h>
64#ifndef OPENSSL_NO_ENGINE
65#include <openssl/engine.h>
66#endif
67#include "evp_locl.h"
68
69void EVP_CIPHER_CTX_init(EVP_CIPHER_CTX *ctx)
70 {
71#ifdef OPENSSL_FIPS
72 FIPS_selftest_check();
73#endif
74 memset(ctx,0,sizeof(EVP_CIPHER_CTX));
75 /* ctx->cipher=NULL; */
76 }
77
78#ifdef OPENSSL_FIPS
79
80/* The purpose of these is to trap programs that attempt to use non FIPS
81 * algorithms in FIPS mode and ignore the errors.
82 */
83
84static int bad_init(EVP_CIPHER_CTX *ctx, const unsigned char *key,
85 const unsigned char *iv, int enc)
86 { FIPS_ERROR_IGNORED("Cipher init"); return 0;}
87
88static int bad_do_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
89 const unsigned char *in, unsigned int inl)
90 { FIPS_ERROR_IGNORED("Cipher update"); return 0;}
91
92/* NB: no cleanup because it is allowed after failed init */
93
94static int bad_set_asn1(EVP_CIPHER_CTX *ctx, ASN1_TYPE *typ)
95 { FIPS_ERROR_IGNORED("Cipher set_asn1"); return 0;}
96static int bad_get_asn1(EVP_CIPHER_CTX *ctx, ASN1_TYPE *typ)
97 { FIPS_ERROR_IGNORED("Cipher get_asn1"); return 0;}
98static int bad_ctrl(EVP_CIPHER_CTX *ctx, int type, int arg, void *ptr)
99 { FIPS_ERROR_IGNORED("Cipher ctrl"); return 0;}
100
101static const EVP_CIPHER bad_cipher =
102 {
103 0,
104 0,
105 0,
106 0,
107 0,
108 bad_init,
109 bad_do_cipher,
110 NULL,
111 0,
112 bad_set_asn1,
113 bad_get_asn1,
114 bad_ctrl,
115 NULL
116 };
117
118#endif
119
120#ifndef OPENSSL_NO_ENGINE
121
122#ifdef OPENSSL_FIPS
123
124static int do_engine_null(ENGINE *impl) { return 0;}
125static int do_evp_enc_engine_null(EVP_CIPHER_CTX *ctx,
126 const EVP_CIPHER **pciph, ENGINE *impl)
127 { return 1; }
128
129static int (*do_engine_finish)(ENGINE *impl)
130 = do_engine_null;
131
132static int (*do_evp_enc_engine)
133 (EVP_CIPHER_CTX *ctx, const EVP_CIPHER **pciph, ENGINE *impl)
134 = do_evp_enc_engine_null;
135
136void int_EVP_CIPHER_set_engine_callbacks(
137 int (*eng_ciph_fin)(ENGINE *impl),
138 int (*eng_ciph_evp)
139 (EVP_CIPHER_CTX *ctx, const EVP_CIPHER **pciph, ENGINE *impl))
140 {
141 do_engine_finish = eng_ciph_fin;
142 do_evp_enc_engine = eng_ciph_evp;
143 }
144
145#else
146
147#define do_engine_finish ENGINE_finish
148
149static int do_evp_enc_engine(EVP_CIPHER_CTX *ctx, const EVP_CIPHER **pcipher, ENGINE *impl)
150 {
151 if(impl)
152 {
153 if (!ENGINE_init(impl))
154 {
155 EVPerr(EVP_F_DO_EVP_ENC_ENGINE, EVP_R_INITIALIZATION_ERROR);
156 return 0;
157 }
158 }
159 else
160 /* Ask if an ENGINE is reserved for this job */
161 impl = ENGINE_get_cipher_engine((*pcipher)->nid);
162 if(impl)
163 {
164 /* There's an ENGINE for this job ... (apparently) */
165 const EVP_CIPHER *c = ENGINE_get_cipher(impl, (*pcipher)->nid);
166 if(!c)
167 {
168 /* One positive side-effect of US's export
169 * control history, is that we should at least
170 * be able to avoid using US mispellings of
171 * "initialisation"? */
172 EVPerr(EVP_F_DO_EVP_ENC_ENGINE, EVP_R_INITIALIZATION_ERROR);
173 return 0;
174 }
175 /* We'll use the ENGINE's private cipher definition */
176 *pcipher = c;
177 /* Store the ENGINE functional reference so we know
178 * 'cipher' came from an ENGINE and we need to release
179 * it when done. */
180 ctx->engine = impl;
181 }
182 else
183 ctx->engine = NULL;
184 return 1;
185 }
186
187#endif
188
189#endif
190
191int EVP_CipherInit_ex(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher, ENGINE *impl,
192 const unsigned char *key, const unsigned char *iv, int enc)
193 {
194 if (enc == -1)
195 enc = ctx->encrypt;
196 else
197 {
198 if (enc)
199 enc = 1;
200 ctx->encrypt = enc;
201 }
202#ifdef OPENSSL_FIPS
203 if(FIPS_selftest_failed())
204 {
205 FIPSerr(FIPS_F_EVP_CIPHERINIT_EX,FIPS_R_FIPS_SELFTEST_FAILED);
206 ctx->cipher = &bad_cipher;
207 return 0;
208 }
209#endif
210#ifndef OPENSSL_NO_ENGINE
211 /* Whether it's nice or not, "Inits" can be used on "Final"'d contexts
212 * so this context may already have an ENGINE! Try to avoid releasing
213 * the previous handle, re-querying for an ENGINE, and having a
214 * reinitialisation, when it may all be unecessary. */
215 if (ctx->engine && ctx->cipher && (!cipher ||
216 (cipher && (cipher->nid == ctx->cipher->nid))))
217 goto skip_to_init;
218#endif
219 if (cipher)
220 {
221 /* Ensure a context left lying around from last time is cleared
222 * (the previous check attempted to avoid this if the same
223 * ENGINE and EVP_CIPHER could be used). */
224 EVP_CIPHER_CTX_cleanup(ctx);
225
226 /* Restore encrypt field: it is zeroed by cleanup */
227 ctx->encrypt = enc;
228#ifndef OPENSSL_NO_ENGINE
229 if (!do_evp_enc_engine(ctx, &cipher, impl))
230 return 0;
231#endif
232
233 ctx->cipher=cipher;
234 if (ctx->cipher->ctx_size)
235 {
236 ctx->cipher_data=OPENSSL_malloc(ctx->cipher->ctx_size);
237 if (!ctx->cipher_data)
238 {
239 EVPerr(EVP_F_EVP_CIPHERINIT_EX, ERR_R_MALLOC_FAILURE);
240 return 0;
241 }
242 }
243 else
244 {
245 ctx->cipher_data = NULL;
246 }
247 ctx->key_len = cipher->key_len;
248 ctx->flags = 0;
249 if(ctx->cipher->flags & EVP_CIPH_CTRL_INIT)
250 {
251 if(!EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_INIT, 0, NULL))
252 {
253 EVPerr(EVP_F_EVP_CIPHERINIT_EX, EVP_R_INITIALIZATION_ERROR);
254 return 0;
255 }
256 }
257 }
258 else if(!ctx->cipher)
259 {
260 EVPerr(EVP_F_EVP_CIPHERINIT_EX, EVP_R_NO_CIPHER_SET);
261 return 0;
262 }
263#ifndef OPENSSL_NO_ENGINE
264skip_to_init:
265#endif
266 /* we assume block size is a power of 2 in *cryptUpdate */
267 OPENSSL_assert(ctx->cipher->block_size == 1
268 || ctx->cipher->block_size == 8
269 || ctx->cipher->block_size == 16);
270
271 if(!(EVP_CIPHER_CTX_flags(ctx) & EVP_CIPH_CUSTOM_IV)) {
272 switch(EVP_CIPHER_CTX_mode(ctx)) {
273
274 case EVP_CIPH_STREAM_CIPHER:
275 case EVP_CIPH_ECB_MODE:
276 break;
277
278 case EVP_CIPH_CFB_MODE:
279 case EVP_CIPH_OFB_MODE:
280
281 ctx->num = 0;
282
283 case EVP_CIPH_CBC_MODE:
284
285 OPENSSL_assert(EVP_CIPHER_CTX_iv_length(ctx) <=
286 (int)sizeof(ctx->iv));
287 if(iv) memcpy(ctx->oiv, iv, EVP_CIPHER_CTX_iv_length(ctx));
288 memcpy(ctx->iv, ctx->oiv, EVP_CIPHER_CTX_iv_length(ctx));
289 break;
290
291 default:
292 return 0;
293 break;
294 }
295 }
296
297#ifdef OPENSSL_FIPS
298 /* After 'key' is set no further parameters changes are permissible.
299 * So only check for non FIPS enabling at this point.
300 */
301 if (key && FIPS_mode())
302 {
303 if (!(ctx->cipher->flags & EVP_CIPH_FLAG_FIPS)
304 & !(ctx->flags & EVP_CIPH_FLAG_NON_FIPS_ALLOW))
305 {
306 EVPerr(EVP_F_EVP_CIPHERINIT_EX, EVP_R_DISABLED_FOR_FIPS);
307#if 0
308 ERR_add_error_data(2, "cipher=",
309 EVP_CIPHER_name(ctx->cipher));
310#endif
311 ctx->cipher = &bad_cipher;
312 return 0;
313 }
314 }
315#endif
316
317 if(key || (ctx->cipher->flags & EVP_CIPH_ALWAYS_CALL_INIT)) {
318 if(!ctx->cipher->init(ctx,key,iv,enc)) return 0;
319 }
320 ctx->buf_len=0;
321 ctx->final_used=0;
322 ctx->block_mask=ctx->cipher->block_size-1;
323 return 1;
324 }
325
326int EVP_CIPHER_CTX_cleanup(EVP_CIPHER_CTX *c)
327 {
328 if (c->cipher != NULL)
329 {
330 if(c->cipher->cleanup && !c->cipher->cleanup(c))
331 return 0;
332 /* Cleanse cipher context data */
333 if (c->cipher_data)
334 OPENSSL_cleanse(c->cipher_data, c->cipher->ctx_size);
335 }
336 if (c->cipher_data)
337 OPENSSL_free(c->cipher_data);
338#ifndef OPENSSL_NO_ENGINE
339 if (c->engine)
340 /* The EVP_CIPHER we used belongs to an ENGINE, release the
341 * functional reference we held for this reason. */
342 do_engine_finish(c->engine);
343#endif
344 memset(c,0,sizeof(EVP_CIPHER_CTX));
345 return 1;
346 }
347
348int EVP_Cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, unsigned int inl)
349 {
350#ifdef OPENSSL_FIPS
351 FIPS_selftest_check();
352#endif
353 return ctx->cipher->do_cipher(ctx,out,in,inl);
354 }
355
356int EVP_CIPHER_CTX_ctrl(EVP_CIPHER_CTX *ctx, int type, int arg, void *ptr)
357{
358 int ret;
359 if(!ctx->cipher) {
360 EVPerr(EVP_F_EVP_CIPHER_CTX_CTRL, EVP_R_NO_CIPHER_SET);
361 return 0;
362 }
363
364 if(!ctx->cipher->ctrl) {
365 EVPerr(EVP_F_EVP_CIPHER_CTX_CTRL, EVP_R_CTRL_NOT_IMPLEMENTED);
366 return 0;
367 }
368
369 ret = ctx->cipher->ctrl(ctx, type, arg, ptr);
370 if(ret == -1) {
371 EVPerr(EVP_F_EVP_CIPHER_CTX_CTRL, EVP_R_CTRL_OPERATION_NOT_IMPLEMENTED);
372 return 0;
373 }
374 return ret;
375}
376
377unsigned long EVP_CIPHER_CTX_flags(const EVP_CIPHER_CTX *ctx)
378 {
379 return ctx->cipher->flags;
380 }
381
382int EVP_CIPHER_CTX_iv_length(const EVP_CIPHER_CTX *ctx)
383 {
384 return ctx->cipher->iv_len;
385 }
386
387int EVP_CIPHER_nid(const EVP_CIPHER *cipher)
388 {
389 return cipher->nid;
390 }
diff --git a/src/lib/libcrypto/evp/encode.c b/src/lib/libcrypto/evp/encode.c
index 5921f0d710..b42c747249 100644
--- a/src/lib/libcrypto/evp/encode.c
+++ b/src/lib/libcrypto/evp/encode.c
@@ -85,7 +85,7 @@
85#define CHUNKS_PER_LINE (64/4) 85#define CHUNKS_PER_LINE (64/4)
86#define CHAR_PER_LINE (64+1) 86#define CHAR_PER_LINE (64+1)
87 87
88static unsigned char data_bin2ascii[65]="ABCDEFGHIJKLMNOPQRSTUVWXYZ\ 88static const unsigned char data_bin2ascii[65]="ABCDEFGHIJKLMNOPQRSTUVWXYZ\
89abcdefghijklmnopqrstuvwxyz0123456789+/"; 89abcdefghijklmnopqrstuvwxyz0123456789+/";
90 90
91/* 0xF0 is a EOLN 91/* 0xF0 is a EOLN
@@ -102,7 +102,7 @@ abcdefghijklmnopqrstuvwxyz0123456789+/";
102#define B64_ERROR 0xFF 102#define B64_ERROR 0xFF
103#define B64_NOT_BASE64(a) (((a)|0x13) == 0xF3) 103#define B64_NOT_BASE64(a) (((a)|0x13) == 0xF3)
104 104
105static unsigned char data_ascii2bin[128]={ 105static const unsigned char data_ascii2bin[128]={
106 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, 106 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
107 0xFF,0xE0,0xF0,0xFF,0xFF,0xF1,0xFF,0xFF, 107 0xFF,0xE0,0xF0,0xFF,0xFF,0xF1,0xFF,0xFF,
108 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, 108 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
diff --git a/src/lib/libcrypto/evp/evp.h b/src/lib/libcrypto/evp/evp.h
index 82b5862ce7..da93e945f5 100644
--- a/src/lib/libcrypto/evp/evp.h
+++ b/src/lib/libcrypto/evp/evp.h
@@ -75,10 +75,6 @@
75#include <openssl/bio.h> 75#include <openssl/bio.h>
76#endif 76#endif
77 77
78#ifdef OPENSSL_FIPS
79#include <openssl/fips.h>
80#endif
81
82/* 78/*
83#define EVP_RC2_KEY_SIZE 16 79#define EVP_RC2_KEY_SIZE 16
84#define EVP_RC4_KEY_SIZE 16 80#define EVP_RC4_KEY_SIZE 16
@@ -119,6 +115,7 @@
119#define EVP_PKEY_DSA4 NID_dsaWithSHA1_2 115#define EVP_PKEY_DSA4 NID_dsaWithSHA1_2
120#define EVP_PKEY_DH NID_dhKeyAgreement 116#define EVP_PKEY_DH NID_dhKeyAgreement
121#define EVP_PKEY_EC NID_X9_62_id_ecPublicKey 117#define EVP_PKEY_EC NID_X9_62_id_ecPublicKey
118#define EVP_PKEY_HMAC NID_hmac
122 119
123#ifdef __cplusplus 120#ifdef __cplusplus
124extern "C" { 121extern "C" {
@@ -132,6 +129,8 @@ struct evp_pkey_st
132 int type; 129 int type;
133 int save_type; 130 int save_type;
134 int references; 131 int references;
132 const EVP_PKEY_ASN1_METHOD *ameth;
133 ENGINE *engine;
135 union { 134 union {
136 char *ptr; 135 char *ptr;
137#ifndef OPENSSL_NO_RSA 136#ifndef OPENSSL_NO_RSA
@@ -156,73 +155,6 @@ struct evp_pkey_st
156#define EVP_PKEY_MO_ENCRYPT 0x0004 155#define EVP_PKEY_MO_ENCRYPT 0x0004
157#define EVP_PKEY_MO_DECRYPT 0x0008 156#define EVP_PKEY_MO_DECRYPT 0x0008
158 157
159#if 0
160/* This structure is required to tie the message digest and signing together.
161 * The lookup can be done by md/pkey_method, oid, oid/pkey_method, or
162 * oid, md and pkey.
163 * This is required because for various smart-card perform the digest and
164 * signing/verification on-board. To handle this case, the specific
165 * EVP_MD and EVP_PKEY_METHODs need to be closely associated.
166 * When a PKEY is created, it will have a EVP_PKEY_METHOD associated with it.
167 * This can either be software or a token to provide the required low level
168 * routines.
169 */
170typedef struct evp_pkey_md_st
171 {
172 int oid;
173 EVP_MD *md;
174 EVP_PKEY_METHOD *pkey;
175 } EVP_PKEY_MD;
176
177#define EVP_rsa_md2() \
178 EVP_PKEY_MD_add(NID_md2WithRSAEncryption,\
179 EVP_rsa_pkcs1(),EVP_md2())
180#define EVP_rsa_md5() \
181 EVP_PKEY_MD_add(NID_md5WithRSAEncryption,\
182 EVP_rsa_pkcs1(),EVP_md5())
183#define EVP_rsa_sha0() \
184 EVP_PKEY_MD_add(NID_shaWithRSAEncryption,\
185 EVP_rsa_pkcs1(),EVP_sha())
186#define EVP_rsa_sha1() \
187 EVP_PKEY_MD_add(NID_sha1WithRSAEncryption,\
188 EVP_rsa_pkcs1(),EVP_sha1())
189#define EVP_rsa_ripemd160() \
190 EVP_PKEY_MD_add(NID_ripemd160WithRSA,\
191 EVP_rsa_pkcs1(),EVP_ripemd160())
192#define EVP_rsa_mdc2() \
193 EVP_PKEY_MD_add(NID_mdc2WithRSA,\
194 EVP_rsa_octet_string(),EVP_mdc2())
195#define EVP_dsa_sha() \
196 EVP_PKEY_MD_add(NID_dsaWithSHA,\
197 EVP_dsa(),EVP_sha())
198#define EVP_dsa_sha1() \
199 EVP_PKEY_MD_add(NID_dsaWithSHA1,\
200 EVP_dsa(),EVP_sha1())
201
202typedef struct evp_pkey_method_st
203 {
204 char *name;
205 int flags;
206 int type; /* RSA, DSA, an SSLeay specific constant */
207 int oid; /* For the pub-key type */
208 int encrypt_oid; /* pub/priv key encryption */
209
210 int (*sign)();
211 int (*verify)();
212 struct {
213 int (*set)(); /* get and/or set the underlying type */
214 int (*get)();
215 int (*encrypt)();
216 int (*decrypt)();
217 int (*i2d)();
218 int (*d2i)();
219 int (*dup)();
220 } pub,priv;
221 int (*set_asn1_parameters)();
222 int (*get_asn1_parameters)();
223 } EVP_PKEY_METHOD;
224#endif
225
226#ifndef EVP_MD 158#ifndef EVP_MD
227struct env_md_st 159struct env_md_st
228 { 160 {
@@ -245,6 +177,8 @@ struct env_md_st
245 int required_pkey_type[5]; /*EVP_PKEY_xxx */ 177 int required_pkey_type[5]; /*EVP_PKEY_xxx */
246 int block_size; 178 int block_size;
247 int ctx_size; /* how big does the ctx->md_data need to be */ 179 int ctx_size; /* how big does the ctx->md_data need to be */
180 /* control function */
181 int (*md_ctrl)(EVP_MD_CTX *ctx, int cmd, int p1, void *p2);
248 } /* EVP_MD */; 182 } /* EVP_MD */;
249 183
250typedef int evp_sign_method(int type,const unsigned char *m, 184typedef int evp_sign_method(int type,const unsigned char *m,
@@ -254,18 +188,42 @@ typedef int evp_verify_method(int type,const unsigned char *m,
254 unsigned int m_length,const unsigned char *sigbuf, 188 unsigned int m_length,const unsigned char *sigbuf,
255 unsigned int siglen, void *key); 189 unsigned int siglen, void *key);
256 190
257typedef struct
258 {
259 EVP_MD_CTX *mctx;
260 void *key;
261 } EVP_MD_SVCTX;
262
263#define EVP_MD_FLAG_ONESHOT 0x0001 /* digest can only handle a single 191#define EVP_MD_FLAG_ONESHOT 0x0001 /* digest can only handle a single
264 * block */ 192 * block */
265 193
266#define EVP_MD_FLAG_FIPS 0x0400 /* Note if suitable for use in FIPS mode */ 194#define EVP_MD_FLAG_PKEY_DIGEST 0x0002 /* digest is a "clone" digest used
195 * which is a copy of an existing
196 * one for a specific public key type.
197 * EVP_dss1() etc */
198
199/* Digest uses EVP_PKEY_METHOD for signing instead of MD specific signing */
200
201#define EVP_MD_FLAG_PKEY_METHOD_SIGNATURE 0x0004
202
203/* DigestAlgorithmIdentifier flags... */
204
205#define EVP_MD_FLAG_DIGALGID_MASK 0x0018
267 206
268#define EVP_MD_FLAG_SVCTX 0x0800 /* pass EVP_MD_SVCTX to sign/verify */ 207/* NULL or absent parameter accepted. Use NULL */
208
209#define EVP_MD_FLAG_DIGALGID_NULL 0x0000
210
211/* NULL or absent parameter accepted. Use NULL for PKCS#1 otherwise absent */
212
213#define EVP_MD_FLAG_DIGALGID_ABSENT 0x0008
214
215/* Custom handling via ctrl */
216
217#define EVP_MD_FLAG_DIGALGID_CUSTOM 0x0018
218
219/* Digest ctrls */
220
221#define EVP_MD_CTRL_DIGALGID 0x1
222#define EVP_MD_CTRL_MICALG 0x2
223
224/* Minimum Algorithm specific ctrl value */
225
226#define EVP_MD_CTRL_ALG_CTRL 0x1000
269 227
270#define EVP_PKEY_NULL_method NULL,NULL,{0,0,0,0} 228#define EVP_PKEY_NULL_method NULL,NULL,{0,0,0,0}
271 229
@@ -307,6 +265,10 @@ struct env_md_ctx_st
307 ENGINE *engine; /* functional reference if 'digest' is ENGINE-provided */ 265 ENGINE *engine; /* functional reference if 'digest' is ENGINE-provided */
308 unsigned long flags; 266 unsigned long flags;
309 void *md_data; 267 void *md_data;
268 /* Public key context for sign/verify */
269 EVP_PKEY_CTX *pctx;
270 /* Update function: usually copied from EVP_MD */
271 int (*update)(EVP_MD_CTX *ctx,const void *data,size_t count);
310 } /* EVP_MD_CTX */; 272 } /* EVP_MD_CTX */;
311 273
312/* values for EVP_MD_CTX flags */ 274/* values for EVP_MD_CTX flags */
@@ -317,17 +279,23 @@ struct env_md_ctx_st
317 * cleaned */ 279 * cleaned */
318#define EVP_MD_CTX_FLAG_REUSE 0x0004 /* Don't free up ctx->md_data 280#define EVP_MD_CTX_FLAG_REUSE 0x0004 /* Don't free up ctx->md_data
319 * in EVP_MD_CTX_cleanup */ 281 * in EVP_MD_CTX_cleanup */
282/* FIPS and pad options are ignored in 1.0.0, definitions are here
283 * so we don't accidentally reuse the values for other purposes.
284 */
285
320#define EVP_MD_CTX_FLAG_NON_FIPS_ALLOW 0x0008 /* Allow use of non FIPS digest 286#define EVP_MD_CTX_FLAG_NON_FIPS_ALLOW 0x0008 /* Allow use of non FIPS digest
321 * in FIPS mode */ 287 * in FIPS mode */
322 288
289/* The following PAD options are also currently ignored in 1.0.0, digest
290 * parameters are handled through EVP_DigestSign*() and EVP_DigestVerify*()
291 * instead.
292 */
323#define EVP_MD_CTX_FLAG_PAD_MASK 0xF0 /* RSA mode to use */ 293#define EVP_MD_CTX_FLAG_PAD_MASK 0xF0 /* RSA mode to use */
324#define EVP_MD_CTX_FLAG_PAD_PKCS1 0x00 /* PKCS#1 v1.5 mode */ 294#define EVP_MD_CTX_FLAG_PAD_PKCS1 0x00 /* PKCS#1 v1.5 mode */
325#define EVP_MD_CTX_FLAG_PAD_X931 0x10 /* X9.31 mode */ 295#define EVP_MD_CTX_FLAG_PAD_X931 0x10 /* X9.31 mode */
326#define EVP_MD_CTX_FLAG_PAD_PSS 0x20 /* PSS mode */ 296#define EVP_MD_CTX_FLAG_PAD_PSS 0x20 /* PSS mode */
327#define M_EVP_MD_CTX_FLAG_PSS_SALT(ctx) \ 297
328 ((ctx->flags>>16) &0xFFFF) /* seed length */ 298#define EVP_MD_CTX_FLAG_NO_INIT 0x0100 /* Don't initialize md_data */
329#define EVP_MD_CTX_FLAG_PSS_MDLEN 0xFFFF /* salt len same as digest */
330#define EVP_MD_CTX_FLAG_PSS_MREC 0xFFFE /* salt max or auto recovered */
331 299
332struct evp_cipher_st 300struct evp_cipher_st
333 { 301 {
@@ -339,7 +307,7 @@ struct evp_cipher_st
339 int (*init)(EVP_CIPHER_CTX *ctx, const unsigned char *key, 307 int (*init)(EVP_CIPHER_CTX *ctx, const unsigned char *key,
340 const unsigned char *iv, int enc); /* init key */ 308 const unsigned char *iv, int enc); /* init key */
341 int (*do_cipher)(EVP_CIPHER_CTX *ctx, unsigned char *out, 309 int (*do_cipher)(EVP_CIPHER_CTX *ctx, unsigned char *out,
342 const unsigned char *in, unsigned int inl);/* encrypt/decrypt data */ 310 const unsigned char *in, size_t inl);/* encrypt/decrypt data */
343 int (*cleanup)(EVP_CIPHER_CTX *); /* cleanup ctx */ 311 int (*cleanup)(EVP_CIPHER_CTX *); /* cleanup ctx */
344 int ctx_size; /* how big ctx->cipher_data needs to be */ 312 int ctx_size; /* how big ctx->cipher_data needs to be */
345 int (*set_asn1_parameters)(EVP_CIPHER_CTX *, ASN1_TYPE *); /* Populate a ASN1_TYPE with parameters */ 313 int (*set_asn1_parameters)(EVP_CIPHER_CTX *, ASN1_TYPE *); /* Populate a ASN1_TYPE with parameters */
@@ -357,7 +325,7 @@ struct evp_cipher_st
357#define EVP_CIPH_CBC_MODE 0x2 325#define EVP_CIPH_CBC_MODE 0x2
358#define EVP_CIPH_CFB_MODE 0x3 326#define EVP_CIPH_CFB_MODE 0x3
359#define EVP_CIPH_OFB_MODE 0x4 327#define EVP_CIPH_OFB_MODE 0x4
360#define EVP_CIPH_MODE 0x7 328#define EVP_CIPH_MODE 0xF0007
361/* Set if variable length cipher */ 329/* Set if variable length cipher */
362#define EVP_CIPH_VARIABLE_LENGTH 0x8 330#define EVP_CIPH_VARIABLE_LENGTH 0x8
363/* Set if the iv handling should be done by the cipher itself */ 331/* Set if the iv handling should be done by the cipher itself */
@@ -372,10 +340,8 @@ struct evp_cipher_st
372#define EVP_CIPH_NO_PADDING 0x100 340#define EVP_CIPH_NO_PADDING 0x100
373/* cipher handles random key generation */ 341/* cipher handles random key generation */
374#define EVP_CIPH_RAND_KEY 0x200 342#define EVP_CIPH_RAND_KEY 0x200
375/* Note if suitable for use in FIPS mode */ 343/* cipher has its own additional copying logic */
376#define EVP_CIPH_FLAG_FIPS 0x400 344#define EVP_CIPH_CUSTOM_COPY 0x400
377/* Allow non FIPS cipher in FIPS mode */
378#define EVP_CIPH_FLAG_NON_FIPS_ALLOW 0x800
379/* Allow use default ASN1 get/set iv */ 345/* Allow use default ASN1 get/set iv */
380#define EVP_CIPH_FLAG_DEFAULT_ASN1 0x1000 346#define EVP_CIPH_FLAG_DEFAULT_ASN1 0x1000
381/* Buffer length in bits not bytes: CFB1 mode only */ 347/* Buffer length in bits not bytes: CFB1 mode only */
@@ -389,8 +355,10 @@ struct evp_cipher_st
389#define EVP_CTRL_SET_RC2_KEY_BITS 0x3 355#define EVP_CTRL_SET_RC2_KEY_BITS 0x3
390#define EVP_CTRL_GET_RC5_ROUNDS 0x4 356#define EVP_CTRL_GET_RC5_ROUNDS 0x4
391#define EVP_CTRL_SET_RC5_ROUNDS 0x5 357#define EVP_CTRL_SET_RC5_ROUNDS 0x5
392#define EVP_CTRL_SET_ACSS_MODE 0x6 358#define EVP_CTRL_RAND_KEY 0x6
393#define EVP_CTRL_RAND_KEY 0x7 359#define EVP_CTRL_PBE_PRF_NID 0x7
360#define EVP_CTRL_COPY 0x8
361#define EVP_CTRL_SET_ACSS_MODE 0x9
394 362
395typedef struct evp_cipher_info_st 363typedef struct evp_cipher_info_st
396 { 364 {
@@ -463,26 +431,15 @@ typedef int (EVP_PBE_KEYGEN)(EVP_CIPHER_CTX *ctx, const char *pass, int passlen,
463#define EVP_get_cipherbynid(a) EVP_get_cipherbyname(OBJ_nid2sn(a)) 431#define EVP_get_cipherbynid(a) EVP_get_cipherbyname(OBJ_nid2sn(a))
464#define EVP_get_cipherbyobj(a) EVP_get_cipherbynid(OBJ_obj2nid(a)) 432#define EVP_get_cipherbyobj(a) EVP_get_cipherbynid(OBJ_obj2nid(a))
465 433
466/* Macros to reduce FIPS dependencies: do NOT use in applications */
467#define M_EVP_MD_size(e) ((e)->md_size)
468#define M_EVP_MD_block_size(e) ((e)->block_size)
469#define M_EVP_MD_CTX_set_flags(ctx,flgs) ((ctx)->flags|=(flgs))
470#define M_EVP_MD_CTX_clear_flags(ctx,flgs) ((ctx)->flags&=~(flgs))
471#define M_EVP_MD_CTX_test_flags(ctx,flgs) ((ctx)->flags&(flgs))
472#define M_EVP_MD_type(e) ((e)->type)
473#define M_EVP_MD_CTX_type(e) M_EVP_MD_type(M_EVP_MD_CTX_md(e))
474#define M_EVP_MD_CTX_md(e) ((e)->digest)
475
476#define M_EVP_CIPHER_CTX_set_flags(ctx,flgs) ((ctx)->flags|=(flgs))
477
478int EVP_MD_type(const EVP_MD *md); 434int EVP_MD_type(const EVP_MD *md);
479#define EVP_MD_nid(e) EVP_MD_type(e) 435#define EVP_MD_nid(e) EVP_MD_type(e)
480#define EVP_MD_name(e) OBJ_nid2sn(EVP_MD_nid(e)) 436#define EVP_MD_name(e) OBJ_nid2sn(EVP_MD_nid(e))
481int EVP_MD_pkey_type(const EVP_MD *md); 437int EVP_MD_pkey_type(const EVP_MD *md);
482int EVP_MD_size(const EVP_MD *md); 438int EVP_MD_size(const EVP_MD *md);
483int EVP_MD_block_size(const EVP_MD *md); 439int EVP_MD_block_size(const EVP_MD *md);
440unsigned long EVP_MD_flags(const EVP_MD *md);
484 441
485const EVP_MD * EVP_MD_CTX_md(const EVP_MD_CTX *ctx); 442const EVP_MD *EVP_MD_CTX_md(const EVP_MD_CTX *ctx);
486#define EVP_MD_CTX_size(e) EVP_MD_size(EVP_MD_CTX_md(e)) 443#define EVP_MD_CTX_size(e) EVP_MD_size(EVP_MD_CTX_md(e))
487#define EVP_MD_CTX_block_size(e) EVP_MD_block_size(EVP_MD_CTX_md(e)) 444#define EVP_MD_CTX_block_size(e) EVP_MD_block_size(EVP_MD_CTX_md(e))
488#define EVP_MD_CTX_type(e) EVP_MD_type(EVP_MD_CTX_md(e)) 445#define EVP_MD_CTX_type(e) EVP_MD_type(EVP_MD_CTX_md(e))
@@ -500,6 +457,7 @@ int EVP_CIPHER_CTX_nid(const EVP_CIPHER_CTX *ctx);
500int EVP_CIPHER_CTX_block_size(const EVP_CIPHER_CTX *ctx); 457int EVP_CIPHER_CTX_block_size(const EVP_CIPHER_CTX *ctx);
501int EVP_CIPHER_CTX_key_length(const EVP_CIPHER_CTX *ctx); 458int EVP_CIPHER_CTX_key_length(const EVP_CIPHER_CTX *ctx);
502int EVP_CIPHER_CTX_iv_length(const EVP_CIPHER_CTX *ctx); 459int EVP_CIPHER_CTX_iv_length(const EVP_CIPHER_CTX *ctx);
460int EVP_CIPHER_CTX_copy(EVP_CIPHER_CTX *out, const EVP_CIPHER_CTX *in);
503void * EVP_CIPHER_CTX_get_app_data(const EVP_CIPHER_CTX *ctx); 461void * EVP_CIPHER_CTX_get_app_data(const EVP_CIPHER_CTX *ctx);
504void EVP_CIPHER_CTX_set_app_data(EVP_CIPHER_CTX *ctx, void *data); 462void EVP_CIPHER_CTX_set_app_data(EVP_CIPHER_CTX *ctx, void *data);
505#define EVP_CIPHER_CTX_type(c) EVP_CIPHER_type(EVP_CIPHER_CTX_cipher(c)) 463#define EVP_CIPHER_CTX_type(c) EVP_CIPHER_type(EVP_CIPHER_CTX_cipher(c))
@@ -517,6 +475,8 @@ unsigned long EVP_CIPHER_CTX_flags(const EVP_CIPHER_CTX *ctx);
517#define EVP_VerifyUpdate(a,b,c) EVP_DigestUpdate(a,b,c) 475#define EVP_VerifyUpdate(a,b,c) EVP_DigestUpdate(a,b,c)
518#define EVP_OpenUpdate(a,b,c,d,e) EVP_DecryptUpdate(a,b,c,d,e) 476#define EVP_OpenUpdate(a,b,c,d,e) EVP_DecryptUpdate(a,b,c,d,e)
519#define EVP_SealUpdate(a,b,c,d,e) EVP_EncryptUpdate(a,b,c,d,e) 477#define EVP_SealUpdate(a,b,c,d,e) EVP_EncryptUpdate(a,b,c,d,e)
478#define EVP_DigestSignUpdate(a,b,c) EVP_DigestUpdate(a,b,c)
479#define EVP_DigestVerifyUpdate(a,b,c) EVP_DigestUpdate(a,b,c)
520 480
521#ifdef CONST_STRICT 481#ifdef CONST_STRICT
522void BIO_set_md(BIO *,const EVP_MD *md); 482void BIO_set_md(BIO *,const EVP_MD *md);
@@ -563,6 +523,7 @@ int EVP_DigestInit(EVP_MD_CTX *ctx, const EVP_MD *type);
563int EVP_DigestFinal(EVP_MD_CTX *ctx,unsigned char *md,unsigned int *s); 523int EVP_DigestFinal(EVP_MD_CTX *ctx,unsigned char *md,unsigned int *s);
564 524
565int EVP_read_pw_string(char *buf,int length,const char *prompt,int verify); 525int EVP_read_pw_string(char *buf,int length,const char *prompt,int verify);
526int EVP_read_pw_string_min(char *buf,int minlen,int maxlen,const char *prompt,int verify);
566void EVP_set_pw_prompt(const char *prompt); 527void EVP_set_pw_prompt(const char *prompt);
567char * EVP_get_pw_prompt(void); 528char * EVP_get_pw_prompt(void);
568 529
@@ -609,6 +570,16 @@ int EVP_SignFinal(EVP_MD_CTX *ctx,unsigned char *md,unsigned int *s,
609int EVP_VerifyFinal(EVP_MD_CTX *ctx,const unsigned char *sigbuf, 570int EVP_VerifyFinal(EVP_MD_CTX *ctx,const unsigned char *sigbuf,
610 unsigned int siglen,EVP_PKEY *pkey); 571 unsigned int siglen,EVP_PKEY *pkey);
611 572
573int EVP_DigestSignInit(EVP_MD_CTX *ctx, EVP_PKEY_CTX **pctx,
574 const EVP_MD *type, ENGINE *e, EVP_PKEY *pkey);
575int EVP_DigestSignFinal(EVP_MD_CTX *ctx,
576 unsigned char *sigret, size_t *siglen);
577
578int EVP_DigestVerifyInit(EVP_MD_CTX *ctx, EVP_PKEY_CTX **pctx,
579 const EVP_MD *type, ENGINE *e, EVP_PKEY *pkey);
580int EVP_DigestVerifyFinal(EVP_MD_CTX *ctx,
581 unsigned char *sig, size_t siglen);
582
612int EVP_OpenInit(EVP_CIPHER_CTX *ctx,const EVP_CIPHER *type, 583int EVP_OpenInit(EVP_CIPHER_CTX *ctx,const EVP_CIPHER *type,
613 const unsigned char *ek, int ekl, const unsigned char *iv, 584 const unsigned char *ek, int ekl, const unsigned char *iv,
614 EVP_PKEY *priv); 585 EVP_PKEY *priv);
@@ -681,6 +652,9 @@ const EVP_MD *EVP_mdc2(void);
681#ifndef OPENSSL_NO_RIPEMD 652#ifndef OPENSSL_NO_RIPEMD
682const EVP_MD *EVP_ripemd160(void); 653const EVP_MD *EVP_ripemd160(void);
683#endif 654#endif
655#ifndef OPENSSL_NO_WHIRLPOOL
656const EVP_MD *EVP_whirlpool(void);
657#endif
684const EVP_CIPHER *EVP_enc_null(void); /* does nothing :-) */ 658const EVP_CIPHER *EVP_enc_null(void); /* does nothing :-) */
685#ifndef OPENSSL_NO_DES 659#ifndef OPENSSL_NO_DES
686const EVP_CIPHER *EVP_des_ecb(void); 660const EVP_CIPHER *EVP_des_ecb(void);
@@ -851,16 +825,31 @@ const EVP_CIPHER *EVP_get_cipherbyname(const char *name);
851const EVP_MD *EVP_get_digestbyname(const char *name); 825const EVP_MD *EVP_get_digestbyname(const char *name);
852void EVP_cleanup(void); 826void EVP_cleanup(void);
853 827
854int EVP_PKEY_decrypt(unsigned char *dec_key, 828void EVP_CIPHER_do_all(void (*fn)(const EVP_CIPHER *ciph,
829 const char *from, const char *to, void *x), void *arg);
830void EVP_CIPHER_do_all_sorted(void (*fn)(const EVP_CIPHER *ciph,
831 const char *from, const char *to, void *x), void *arg);
832
833void EVP_MD_do_all(void (*fn)(const EVP_MD *ciph,
834 const char *from, const char *to, void *x), void *arg);
835void EVP_MD_do_all_sorted(void (*fn)(const EVP_MD *ciph,
836 const char *from, const char *to, void *x), void *arg);
837
838int EVP_PKEY_decrypt_old(unsigned char *dec_key,
855 const unsigned char *enc_key,int enc_key_len, 839 const unsigned char *enc_key,int enc_key_len,
856 EVP_PKEY *private_key); 840 EVP_PKEY *private_key);
857int EVP_PKEY_encrypt(unsigned char *enc_key, 841int EVP_PKEY_encrypt_old(unsigned char *enc_key,
858 const unsigned char *key,int key_len, 842 const unsigned char *key,int key_len,
859 EVP_PKEY *pub_key); 843 EVP_PKEY *pub_key);
860int EVP_PKEY_type(int type); 844int EVP_PKEY_type(int type);
845int EVP_PKEY_id(const EVP_PKEY *pkey);
846int EVP_PKEY_base_id(const EVP_PKEY *pkey);
861int EVP_PKEY_bits(EVP_PKEY *pkey); 847int EVP_PKEY_bits(EVP_PKEY *pkey);
862int EVP_PKEY_size(EVP_PKEY *pkey); 848int EVP_PKEY_size(EVP_PKEY *pkey);
863int EVP_PKEY_assign(EVP_PKEY *pkey,int type,char *key); 849int EVP_PKEY_set_type(EVP_PKEY *pkey,int type);
850int EVP_PKEY_set_type_str(EVP_PKEY *pkey, const char *str, int len);
851int EVP_PKEY_assign(EVP_PKEY *pkey,int type,void *key);
852void * EVP_PKEY_get0(EVP_PKEY *pkey);
864 853
865#ifndef OPENSSL_NO_RSA 854#ifndef OPENSSL_NO_RSA
866struct rsa_st; 855struct rsa_st;
@@ -903,6 +892,15 @@ int EVP_PKEY_cmp_parameters(const EVP_PKEY *a, const EVP_PKEY *b);
903 892
904int EVP_PKEY_cmp(const EVP_PKEY *a, const EVP_PKEY *b); 893int EVP_PKEY_cmp(const EVP_PKEY *a, const EVP_PKEY *b);
905 894
895int EVP_PKEY_print_public(BIO *out, const EVP_PKEY *pkey,
896 int indent, ASN1_PCTX *pctx);
897int EVP_PKEY_print_private(BIO *out, const EVP_PKEY *pkey,
898 int indent, ASN1_PCTX *pctx);
899int EVP_PKEY_print_params(BIO *out, const EVP_PKEY *pkey,
900 int indent, ASN1_PCTX *pctx);
901
902int EVP_PKEY_get_default_digest_nid(EVP_PKEY *pkey, int *pnid);
903
906int EVP_CIPHER_type(const EVP_CIPHER *ctx); 904int EVP_CIPHER_type(const EVP_CIPHER *ctx);
907 905
908/* calls methods */ 906/* calls methods */
@@ -920,6 +918,10 @@ int PKCS5_PBE_keyivgen(EVP_CIPHER_CTX *ctx, const char *pass, int passlen,
920int PKCS5_PBKDF2_HMAC_SHA1(const char *pass, int passlen, 918int PKCS5_PBKDF2_HMAC_SHA1(const char *pass, int passlen,
921 const unsigned char *salt, int saltlen, int iter, 919 const unsigned char *salt, int saltlen, int iter,
922 int keylen, unsigned char *out); 920 int keylen, unsigned char *out);
921int PKCS5_PBKDF2_HMAC(const char *pass, int passlen,
922 const unsigned char *salt, int saltlen, int iter,
923 const EVP_MD *digest,
924 int keylen, unsigned char *out);
923int PKCS5_v2_PBE_keyivgen(EVP_CIPHER_CTX *ctx, const char *pass, int passlen, 925int PKCS5_v2_PBE_keyivgen(EVP_CIPHER_CTX *ctx, const char *pass, int passlen,
924 ASN1_TYPE *param, const EVP_CIPHER *cipher, const EVP_MD *md, 926 ASN1_TYPE *param, const EVP_CIPHER *cipher, const EVP_MD *md,
925 int en_de); 927 int en_de);
@@ -928,27 +930,260 @@ void PKCS5_PBE_add(void);
928 930
929int EVP_PBE_CipherInit (ASN1_OBJECT *pbe_obj, const char *pass, int passlen, 931int EVP_PBE_CipherInit (ASN1_OBJECT *pbe_obj, const char *pass, int passlen,
930 ASN1_TYPE *param, EVP_CIPHER_CTX *ctx, int en_de); 932 ASN1_TYPE *param, EVP_CIPHER_CTX *ctx, int en_de);
933
934/* PBE type */
935
936/* Can appear as the outermost AlgorithmIdentifier */
937#define EVP_PBE_TYPE_OUTER 0x0
938/* Is an PRF type OID */
939#define EVP_PBE_TYPE_PRF 0x1
940
941int EVP_PBE_alg_add_type(int pbe_type, int pbe_nid, int cipher_nid, int md_nid,
942 EVP_PBE_KEYGEN *keygen);
931int EVP_PBE_alg_add(int nid, const EVP_CIPHER *cipher, const EVP_MD *md, 943int EVP_PBE_alg_add(int nid, const EVP_CIPHER *cipher, const EVP_MD *md,
932 EVP_PBE_KEYGEN *keygen); 944 EVP_PBE_KEYGEN *keygen);
945int EVP_PBE_find(int type, int pbe_nid,
946 int *pcnid, int *pmnid, EVP_PBE_KEYGEN **pkeygen);
933void EVP_PBE_cleanup(void); 947void EVP_PBE_cleanup(void);
934 948
935#ifdef OPENSSL_FIPS 949#define ASN1_PKEY_ALIAS 0x1
936#ifndef OPENSSL_NO_ENGINE 950#define ASN1_PKEY_DYNAMIC 0x2
937void int_EVP_MD_set_engine_callbacks( 951#define ASN1_PKEY_SIGPARAM_NULL 0x4
938 int (*eng_md_init)(ENGINE *impl), 952
939 int (*eng_md_fin)(ENGINE *impl), 953#define ASN1_PKEY_CTRL_PKCS7_SIGN 0x1
940 int (*eng_md_evp) 954#define ASN1_PKEY_CTRL_PKCS7_ENCRYPT 0x2
941 (EVP_MD_CTX *ctx, const EVP_MD **ptype, ENGINE *impl)); 955#define ASN1_PKEY_CTRL_DEFAULT_MD_NID 0x3
942void int_EVP_MD_init_engine_callbacks(void); 956#define ASN1_PKEY_CTRL_CMS_SIGN 0x5
943void int_EVP_CIPHER_set_engine_callbacks( 957#define ASN1_PKEY_CTRL_CMS_ENVELOPE 0x7
944 int (*eng_ciph_fin)(ENGINE *impl), 958
945 int (*eng_ciph_evp) 959int EVP_PKEY_asn1_get_count(void);
946 (EVP_CIPHER_CTX *ctx, const EVP_CIPHER **pciph, ENGINE *impl)); 960const EVP_PKEY_ASN1_METHOD *EVP_PKEY_asn1_get0(int idx);
947void int_EVP_CIPHER_init_engine_callbacks(void); 961const EVP_PKEY_ASN1_METHOD *EVP_PKEY_asn1_find(ENGINE **pe, int type);
948#endif 962const EVP_PKEY_ASN1_METHOD *EVP_PKEY_asn1_find_str(ENGINE **pe,
949#endif 963 const char *str, int len);
964int EVP_PKEY_asn1_add0(const EVP_PKEY_ASN1_METHOD *ameth);
965int EVP_PKEY_asn1_add_alias(int to, int from);
966int EVP_PKEY_asn1_get0_info(int *ppkey_id, int *pkey_base_id, int *ppkey_flags,
967 const char **pinfo, const char **ppem_str,
968 const EVP_PKEY_ASN1_METHOD *ameth);
969
970const EVP_PKEY_ASN1_METHOD* EVP_PKEY_get0_asn1(EVP_PKEY *pkey);
971EVP_PKEY_ASN1_METHOD* EVP_PKEY_asn1_new(int id, int flags,
972 const char *pem_str, const char *info);
973void EVP_PKEY_asn1_copy(EVP_PKEY_ASN1_METHOD *dst,
974 const EVP_PKEY_ASN1_METHOD *src);
975void EVP_PKEY_asn1_free(EVP_PKEY_ASN1_METHOD *ameth);
976void EVP_PKEY_asn1_set_public(EVP_PKEY_ASN1_METHOD *ameth,
977 int (*pub_decode)(EVP_PKEY *pk, X509_PUBKEY *pub),
978 int (*pub_encode)(X509_PUBKEY *pub, const EVP_PKEY *pk),
979 int (*pub_cmp)(const EVP_PKEY *a, const EVP_PKEY *b),
980 int (*pub_print)(BIO *out, const EVP_PKEY *pkey, int indent,
981 ASN1_PCTX *pctx),
982 int (*pkey_size)(const EVP_PKEY *pk),
983 int (*pkey_bits)(const EVP_PKEY *pk));
984void EVP_PKEY_asn1_set_private(EVP_PKEY_ASN1_METHOD *ameth,
985 int (*priv_decode)(EVP_PKEY *pk, PKCS8_PRIV_KEY_INFO *p8inf),
986 int (*priv_encode)(PKCS8_PRIV_KEY_INFO *p8, const EVP_PKEY *pk),
987 int (*priv_print)(BIO *out, const EVP_PKEY *pkey, int indent,
988 ASN1_PCTX *pctx));
989void EVP_PKEY_asn1_set_param(EVP_PKEY_ASN1_METHOD *ameth,
990 int (*param_decode)(EVP_PKEY *pkey,
991 const unsigned char **pder, int derlen),
992 int (*param_encode)(const EVP_PKEY *pkey, unsigned char **pder),
993 int (*param_missing)(const EVP_PKEY *pk),
994 int (*param_copy)(EVP_PKEY *to, const EVP_PKEY *from),
995 int (*param_cmp)(const EVP_PKEY *a, const EVP_PKEY *b),
996 int (*param_print)(BIO *out, const EVP_PKEY *pkey, int indent,
997 ASN1_PCTX *pctx));
998
999void EVP_PKEY_asn1_set_free(EVP_PKEY_ASN1_METHOD *ameth,
1000 void (*pkey_free)(EVP_PKEY *pkey));
1001void EVP_PKEY_asn1_set_ctrl(EVP_PKEY_ASN1_METHOD *ameth,
1002 int (*pkey_ctrl)(EVP_PKEY *pkey, int op,
1003 long arg1, void *arg2));
1004
1005
1006#define EVP_PKEY_OP_UNDEFINED 0
1007#define EVP_PKEY_OP_PARAMGEN (1<<1)
1008#define EVP_PKEY_OP_KEYGEN (1<<2)
1009#define EVP_PKEY_OP_SIGN (1<<3)
1010#define EVP_PKEY_OP_VERIFY (1<<4)
1011#define EVP_PKEY_OP_VERIFYRECOVER (1<<5)
1012#define EVP_PKEY_OP_SIGNCTX (1<<6)
1013#define EVP_PKEY_OP_VERIFYCTX (1<<7)
1014#define EVP_PKEY_OP_ENCRYPT (1<<8)
1015#define EVP_PKEY_OP_DECRYPT (1<<9)
1016#define EVP_PKEY_OP_DERIVE (1<<10)
1017
1018#define EVP_PKEY_OP_TYPE_SIG \
1019 (EVP_PKEY_OP_SIGN | EVP_PKEY_OP_VERIFY | EVP_PKEY_OP_VERIFYRECOVER \
1020 | EVP_PKEY_OP_SIGNCTX | EVP_PKEY_OP_VERIFYCTX)
1021
1022#define EVP_PKEY_OP_TYPE_CRYPT \
1023 (EVP_PKEY_OP_ENCRYPT | EVP_PKEY_OP_DECRYPT)
1024
1025#define EVP_PKEY_OP_TYPE_NOGEN \
1026 (EVP_PKEY_OP_SIG | EVP_PKEY_OP_CRYPT | EVP_PKEY_OP_DERIVE)
1027
1028#define EVP_PKEY_OP_TYPE_GEN \
1029 (EVP_PKEY_OP_PARAMGEN | EVP_PKEY_OP_KEYGEN)
1030
1031#define EVP_PKEY_CTX_set_signature_md(ctx, md) \
1032 EVP_PKEY_CTX_ctrl(ctx, -1, EVP_PKEY_OP_TYPE_SIG, \
1033 EVP_PKEY_CTRL_MD, 0, (void *)md)
1034
1035#define EVP_PKEY_CTRL_MD 1
1036#define EVP_PKEY_CTRL_PEER_KEY 2
1037
1038#define EVP_PKEY_CTRL_PKCS7_ENCRYPT 3
1039#define EVP_PKEY_CTRL_PKCS7_DECRYPT 4
1040
1041#define EVP_PKEY_CTRL_PKCS7_SIGN 5
1042
1043#define EVP_PKEY_CTRL_SET_MAC_KEY 6
1044
1045#define EVP_PKEY_CTRL_DIGESTINIT 7
1046
1047/* Used by GOST key encryption in TLS */
1048#define EVP_PKEY_CTRL_SET_IV 8
1049
1050#define EVP_PKEY_CTRL_CMS_ENCRYPT 9
1051#define EVP_PKEY_CTRL_CMS_DECRYPT 10
1052#define EVP_PKEY_CTRL_CMS_SIGN 11
1053
1054#define EVP_PKEY_ALG_CTRL 0x1000
1055
1056
1057#define EVP_PKEY_FLAG_AUTOARGLEN 2
1058
1059const EVP_PKEY_METHOD *EVP_PKEY_meth_find(int type);
1060EVP_PKEY_METHOD* EVP_PKEY_meth_new(int id, int flags);
1061void EVP_PKEY_meth_free(EVP_PKEY_METHOD *pmeth);
1062int EVP_PKEY_meth_add0(const EVP_PKEY_METHOD *pmeth);
1063
1064EVP_PKEY_CTX *EVP_PKEY_CTX_new(EVP_PKEY *pkey, ENGINE *e);
1065EVP_PKEY_CTX *EVP_PKEY_CTX_new_id(int id, ENGINE *e);
1066EVP_PKEY_CTX *EVP_PKEY_CTX_dup(EVP_PKEY_CTX *ctx);
1067void EVP_PKEY_CTX_free(EVP_PKEY_CTX *ctx);
1068
1069int EVP_PKEY_CTX_ctrl(EVP_PKEY_CTX *ctx, int keytype, int optype,
1070 int cmd, int p1, void *p2);
1071int EVP_PKEY_CTX_ctrl_str(EVP_PKEY_CTX *ctx, const char *type,
1072 const char *value);
1073
1074int EVP_PKEY_CTX_get_operation(EVP_PKEY_CTX *ctx);
1075void EVP_PKEY_CTX_set0_keygen_info(EVP_PKEY_CTX *ctx, int *dat, int datlen);
1076
1077EVP_PKEY *EVP_PKEY_new_mac_key(int type, ENGINE *e,
1078 unsigned char *key, int keylen);
1079
1080void EVP_PKEY_CTX_set_data(EVP_PKEY_CTX *ctx, void *data);
1081void *EVP_PKEY_CTX_get_data(EVP_PKEY_CTX *ctx);
1082EVP_PKEY *EVP_PKEY_CTX_get0_pkey(EVP_PKEY_CTX *ctx);
1083
1084EVP_PKEY *EVP_PKEY_CTX_get0_peerkey(EVP_PKEY_CTX *ctx);
1085
1086void EVP_PKEY_CTX_set_app_data(EVP_PKEY_CTX *ctx, void *data);
1087void *EVP_PKEY_CTX_get_app_data(EVP_PKEY_CTX *ctx);
1088
1089int EVP_PKEY_sign_init(EVP_PKEY_CTX *ctx);
1090int EVP_PKEY_sign(EVP_PKEY_CTX *ctx,
1091 unsigned char *sig, size_t *siglen,
1092 const unsigned char *tbs, size_t tbslen);
1093int EVP_PKEY_verify_init(EVP_PKEY_CTX *ctx);
1094int EVP_PKEY_verify(EVP_PKEY_CTX *ctx,
1095 const unsigned char *sig, size_t siglen,
1096 const unsigned char *tbs, size_t tbslen);
1097int EVP_PKEY_verify_recover_init(EVP_PKEY_CTX *ctx);
1098int EVP_PKEY_verify_recover(EVP_PKEY_CTX *ctx,
1099 unsigned char *rout, size_t *routlen,
1100 const unsigned char *sig, size_t siglen);
1101int EVP_PKEY_encrypt_init(EVP_PKEY_CTX *ctx);
1102int EVP_PKEY_encrypt(EVP_PKEY_CTX *ctx,
1103 unsigned char *out, size_t *outlen,
1104 const unsigned char *in, size_t inlen);
1105int EVP_PKEY_decrypt_init(EVP_PKEY_CTX *ctx);
1106int EVP_PKEY_decrypt(EVP_PKEY_CTX *ctx,
1107 unsigned char *out, size_t *outlen,
1108 const unsigned char *in, size_t inlen);
1109
1110int EVP_PKEY_derive_init(EVP_PKEY_CTX *ctx);
1111int EVP_PKEY_derive_set_peer(EVP_PKEY_CTX *ctx, EVP_PKEY *peer);
1112int EVP_PKEY_derive(EVP_PKEY_CTX *ctx, unsigned char *key, size_t *keylen);
1113
1114typedef int EVP_PKEY_gen_cb(EVP_PKEY_CTX *ctx);
1115
1116int EVP_PKEY_paramgen_init(EVP_PKEY_CTX *ctx);
1117int EVP_PKEY_paramgen(EVP_PKEY_CTX *ctx, EVP_PKEY **ppkey);
1118int EVP_PKEY_keygen_init(EVP_PKEY_CTX *ctx);
1119int EVP_PKEY_keygen(EVP_PKEY_CTX *ctx, EVP_PKEY **ppkey);
1120
1121void EVP_PKEY_CTX_set_cb(EVP_PKEY_CTX *ctx, EVP_PKEY_gen_cb *cb);
1122EVP_PKEY_gen_cb *EVP_PKEY_CTX_get_cb(EVP_PKEY_CTX *ctx);
1123
1124int EVP_PKEY_CTX_get_keygen_info(EVP_PKEY_CTX *ctx, int idx);
1125
1126void EVP_PKEY_meth_set_init(EVP_PKEY_METHOD *pmeth,
1127 int (*init)(EVP_PKEY_CTX *ctx));
1128
1129void EVP_PKEY_meth_set_copy(EVP_PKEY_METHOD *pmeth,
1130 int (*copy)(EVP_PKEY_CTX *dst, EVP_PKEY_CTX *src));
1131
1132void EVP_PKEY_meth_set_cleanup(EVP_PKEY_METHOD *pmeth,
1133 void (*cleanup)(EVP_PKEY_CTX *ctx));
1134
1135void EVP_PKEY_meth_set_paramgen(EVP_PKEY_METHOD *pmeth,
1136 int (*paramgen_init)(EVP_PKEY_CTX *ctx),
1137 int (*paramgen)(EVP_PKEY_CTX *ctx, EVP_PKEY *pkey));
1138
1139void EVP_PKEY_meth_set_keygen(EVP_PKEY_METHOD *pmeth,
1140 int (*keygen_init)(EVP_PKEY_CTX *ctx),
1141 int (*keygen)(EVP_PKEY_CTX *ctx, EVP_PKEY *pkey));
950 1142
951void EVP_add_alg_module(void); 1143void EVP_PKEY_meth_set_sign(EVP_PKEY_METHOD *pmeth,
1144 int (*sign_init)(EVP_PKEY_CTX *ctx),
1145 int (*sign)(EVP_PKEY_CTX *ctx, unsigned char *sig, size_t *siglen,
1146 const unsigned char *tbs, size_t tbslen));
1147
1148void EVP_PKEY_meth_set_verify(EVP_PKEY_METHOD *pmeth,
1149 int (*verify_init)(EVP_PKEY_CTX *ctx),
1150 int (*verify)(EVP_PKEY_CTX *ctx, const unsigned char *sig, size_t siglen,
1151 const unsigned char *tbs, size_t tbslen));
1152
1153void EVP_PKEY_meth_set_verify_recover(EVP_PKEY_METHOD *pmeth,
1154 int (*verify_recover_init)(EVP_PKEY_CTX *ctx),
1155 int (*verify_recover)(EVP_PKEY_CTX *ctx,
1156 unsigned char *sig, size_t *siglen,
1157 const unsigned char *tbs, size_t tbslen));
1158
1159void EVP_PKEY_meth_set_signctx(EVP_PKEY_METHOD *pmeth,
1160 int (*signctx_init)(EVP_PKEY_CTX *ctx, EVP_MD_CTX *mctx),
1161 int (*signctx)(EVP_PKEY_CTX *ctx, unsigned char *sig, size_t *siglen,
1162 EVP_MD_CTX *mctx));
1163
1164void EVP_PKEY_meth_set_verifyctx(EVP_PKEY_METHOD *pmeth,
1165 int (*verifyctx_init)(EVP_PKEY_CTX *ctx, EVP_MD_CTX *mctx),
1166 int (*verifyctx)(EVP_PKEY_CTX *ctx, const unsigned char *sig,int siglen,
1167 EVP_MD_CTX *mctx));
1168
1169void EVP_PKEY_meth_set_encrypt(EVP_PKEY_METHOD *pmeth,
1170 int (*encrypt_init)(EVP_PKEY_CTX *ctx),
1171 int (*encryptfn)(EVP_PKEY_CTX *ctx, unsigned char *out, size_t *outlen,
1172 const unsigned char *in, size_t inlen));
1173
1174void EVP_PKEY_meth_set_decrypt(EVP_PKEY_METHOD *pmeth,
1175 int (*decrypt_init)(EVP_PKEY_CTX *ctx),
1176 int (*decrypt)(EVP_PKEY_CTX *ctx, unsigned char *out, size_t *outlen,
1177 const unsigned char *in, size_t inlen));
1178
1179void EVP_PKEY_meth_set_derive(EVP_PKEY_METHOD *pmeth,
1180 int (*derive_init)(EVP_PKEY_CTX *ctx),
1181 int (*derive)(EVP_PKEY_CTX *ctx, unsigned char *key, size_t *keylen));
1182
1183void EVP_PKEY_meth_set_ctrl(EVP_PKEY_METHOD *pmeth,
1184 int (*ctrl)(EVP_PKEY_CTX *ctx, int type, int p1, void *p2),
1185 int (*ctrl_str)(EVP_PKEY_CTX *ctx,
1186 const char *type, const char *value));
952 1187
953/* BEGIN ERROR CODES */ 1188/* BEGIN ERROR CODES */
954/* The following lines are auto generated by the script mkerr.pl. Any changes 1189/* The following lines are auto generated by the script mkerr.pl. Any changes
@@ -961,46 +1196,66 @@ void ERR_load_EVP_strings(void);
961/* Function codes. */ 1196/* Function codes. */
962#define EVP_F_AESNI_INIT_KEY 165 1197#define EVP_F_AESNI_INIT_KEY 165
963#define EVP_F_AES_INIT_KEY 133 1198#define EVP_F_AES_INIT_KEY 133
964#define EVP_F_ALG_MODULE_INIT 138
965#define EVP_F_CAMELLIA_INIT_KEY 159 1199#define EVP_F_CAMELLIA_INIT_KEY 159
966#define EVP_F_D2I_PKEY 100 1200#define EVP_F_D2I_PKEY 100
967#define EVP_F_DO_EVP_ENC_ENGINE 140 1201#define EVP_F_DO_SIGVER_INIT 161
968#define EVP_F_DO_EVP_ENC_ENGINE_FULL 141
969#define EVP_F_DO_EVP_MD_ENGINE 139
970#define EVP_F_DO_EVP_MD_ENGINE_FULL 142
971#define EVP_F_DSAPKEY2PKCS8 134 1202#define EVP_F_DSAPKEY2PKCS8 134
972#define EVP_F_DSA_PKEY2PKCS8 135 1203#define EVP_F_DSA_PKEY2PKCS8 135
973#define EVP_F_ECDSA_PKEY2PKCS8 129 1204#define EVP_F_ECDSA_PKEY2PKCS8 129
974#define EVP_F_ECKEY_PKEY2PKCS8 132 1205#define EVP_F_ECKEY_PKEY2PKCS8 132
975#define EVP_F_EVP_CIPHERINIT 137
976#define EVP_F_EVP_CIPHERINIT_EX 123 1206#define EVP_F_EVP_CIPHERINIT_EX 123
1207#define EVP_F_EVP_CIPHER_CTX_COPY 163
977#define EVP_F_EVP_CIPHER_CTX_CTRL 124 1208#define EVP_F_EVP_CIPHER_CTX_CTRL 124
978#define EVP_F_EVP_CIPHER_CTX_SET_KEY_LENGTH 122 1209#define EVP_F_EVP_CIPHER_CTX_SET_KEY_LENGTH 122
979#define EVP_F_EVP_DECRYPTFINAL_EX 101 1210#define EVP_F_EVP_DECRYPTFINAL_EX 101
980#define EVP_F_EVP_DIGESTINIT 136
981#define EVP_F_EVP_DIGESTINIT_EX 128 1211#define EVP_F_EVP_DIGESTINIT_EX 128
982#define EVP_F_EVP_ENCRYPTFINAL_EX 127 1212#define EVP_F_EVP_ENCRYPTFINAL_EX 127
983#define EVP_F_EVP_MD_CTX_COPY_EX 110 1213#define EVP_F_EVP_MD_CTX_COPY_EX 110
1214#define EVP_F_EVP_MD_SIZE 162
984#define EVP_F_EVP_OPENINIT 102 1215#define EVP_F_EVP_OPENINIT 102
985#define EVP_F_EVP_PBE_ALG_ADD 115 1216#define EVP_F_EVP_PBE_ALG_ADD 115
1217#define EVP_F_EVP_PBE_ALG_ADD_TYPE 160
986#define EVP_F_EVP_PBE_CIPHERINIT 116 1218#define EVP_F_EVP_PBE_CIPHERINIT 116
987#define EVP_F_EVP_PKCS82PKEY 111 1219#define EVP_F_EVP_PKCS82PKEY 111
1220#define EVP_F_EVP_PKCS82PKEY_BROKEN 136
988#define EVP_F_EVP_PKEY2PKCS8_BROKEN 113 1221#define EVP_F_EVP_PKEY2PKCS8_BROKEN 113
989#define EVP_F_EVP_PKEY_COPY_PARAMETERS 103 1222#define EVP_F_EVP_PKEY_COPY_PARAMETERS 103
1223#define EVP_F_EVP_PKEY_CTX_CTRL 137
1224#define EVP_F_EVP_PKEY_CTX_CTRL_STR 150
1225#define EVP_F_EVP_PKEY_CTX_DUP 156
990#define EVP_F_EVP_PKEY_DECRYPT 104 1226#define EVP_F_EVP_PKEY_DECRYPT 104
1227#define EVP_F_EVP_PKEY_DECRYPT_INIT 138
1228#define EVP_F_EVP_PKEY_DECRYPT_OLD 151
1229#define EVP_F_EVP_PKEY_DERIVE 153
1230#define EVP_F_EVP_PKEY_DERIVE_INIT 154
1231#define EVP_F_EVP_PKEY_DERIVE_SET_PEER 155
991#define EVP_F_EVP_PKEY_ENCRYPT 105 1232#define EVP_F_EVP_PKEY_ENCRYPT 105
1233#define EVP_F_EVP_PKEY_ENCRYPT_INIT 139
1234#define EVP_F_EVP_PKEY_ENCRYPT_OLD 152
992#define EVP_F_EVP_PKEY_GET1_DH 119 1235#define EVP_F_EVP_PKEY_GET1_DH 119
993#define EVP_F_EVP_PKEY_GET1_DSA 120 1236#define EVP_F_EVP_PKEY_GET1_DSA 120
994#define EVP_F_EVP_PKEY_GET1_ECDSA 130 1237#define EVP_F_EVP_PKEY_GET1_ECDSA 130
995#define EVP_F_EVP_PKEY_GET1_EC_KEY 131 1238#define EVP_F_EVP_PKEY_GET1_EC_KEY 131
996#define EVP_F_EVP_PKEY_GET1_RSA 121 1239#define EVP_F_EVP_PKEY_GET1_RSA 121
1240#define EVP_F_EVP_PKEY_KEYGEN 146
1241#define EVP_F_EVP_PKEY_KEYGEN_INIT 147
997#define EVP_F_EVP_PKEY_NEW 106 1242#define EVP_F_EVP_PKEY_NEW 106
1243#define EVP_F_EVP_PKEY_PARAMGEN 148
1244#define EVP_F_EVP_PKEY_PARAMGEN_INIT 149
1245#define EVP_F_EVP_PKEY_SIGN 140
1246#define EVP_F_EVP_PKEY_SIGN_INIT 141
1247#define EVP_F_EVP_PKEY_VERIFY 142
1248#define EVP_F_EVP_PKEY_VERIFY_INIT 143
1249#define EVP_F_EVP_PKEY_VERIFY_RECOVER 144
1250#define EVP_F_EVP_PKEY_VERIFY_RECOVER_INIT 145
998#define EVP_F_EVP_RIJNDAEL 126 1251#define EVP_F_EVP_RIJNDAEL 126
999#define EVP_F_EVP_SIGNFINAL 107 1252#define EVP_F_EVP_SIGNFINAL 107
1000#define EVP_F_EVP_VERIFYFINAL 108 1253#define EVP_F_EVP_VERIFYFINAL 108
1254#define EVP_F_INT_CTX_NEW 157
1001#define EVP_F_PKCS5_PBE_KEYIVGEN 117 1255#define EVP_F_PKCS5_PBE_KEYIVGEN 117
1002#define EVP_F_PKCS5_V2_PBE_KEYIVGEN 118 1256#define EVP_F_PKCS5_V2_PBE_KEYIVGEN 118
1003#define EVP_F_PKCS8_SET_BROKEN 112 1257#define EVP_F_PKCS8_SET_BROKEN 112
1258#define EVP_F_PKEY_SET_TYPE 158
1004#define EVP_F_RC2_MAGIC_TO_METH 109 1259#define EVP_F_RC2_MAGIC_TO_METH 109
1005#define EVP_F_RC5_CTRL 125 1260#define EVP_F_RC5_CTRL 125
1006 1261
@@ -1012,41 +1267,52 @@ void ERR_load_EVP_strings(void);
1012#define EVP_R_BAD_KEY_LENGTH 137 1267#define EVP_R_BAD_KEY_LENGTH 137
1013#define EVP_R_BN_DECODE_ERROR 112 1268#define EVP_R_BN_DECODE_ERROR 112
1014#define EVP_R_BN_PUBKEY_ERROR 113 1269#define EVP_R_BN_PUBKEY_ERROR 113
1270#define EVP_R_BUFFER_TOO_SMALL 155
1015#define EVP_R_CAMELLIA_KEY_SETUP_FAILED 157 1271#define EVP_R_CAMELLIA_KEY_SETUP_FAILED 157
1016#define EVP_R_CIPHER_PARAMETER_ERROR 122 1272#define EVP_R_CIPHER_PARAMETER_ERROR 122
1273#define EVP_R_COMMAND_NOT_SUPPORTED 147
1017#define EVP_R_CTRL_NOT_IMPLEMENTED 132 1274#define EVP_R_CTRL_NOT_IMPLEMENTED 132
1018#define EVP_R_CTRL_OPERATION_NOT_IMPLEMENTED 133 1275#define EVP_R_CTRL_OPERATION_NOT_IMPLEMENTED 133
1019#define EVP_R_DATA_NOT_MULTIPLE_OF_BLOCK_LENGTH 138 1276#define EVP_R_DATA_NOT_MULTIPLE_OF_BLOCK_LENGTH 138
1020#define EVP_R_DECODE_ERROR 114 1277#define EVP_R_DECODE_ERROR 114
1021#define EVP_R_DIFFERENT_KEY_TYPES 101 1278#define EVP_R_DIFFERENT_KEY_TYPES 101
1022#define EVP_R_DISABLED_FOR_FIPS 144 1279#define EVP_R_DIFFERENT_PARAMETERS 153
1023#define EVP_R_ENCODE_ERROR 115 1280#define EVP_R_ENCODE_ERROR 115
1024#define EVP_R_ERROR_LOADING_SECTION 145
1025#define EVP_R_ERROR_SETTING_FIPS_MODE 146
1026#define EVP_R_EVP_PBE_CIPHERINIT_ERROR 119 1281#define EVP_R_EVP_PBE_CIPHERINIT_ERROR 119
1027#define EVP_R_EXPECTING_AN_RSA_KEY 127 1282#define EVP_R_EXPECTING_AN_RSA_KEY 127
1028#define EVP_R_EXPECTING_A_DH_KEY 128 1283#define EVP_R_EXPECTING_A_DH_KEY 128
1029#define EVP_R_EXPECTING_A_DSA_KEY 129 1284#define EVP_R_EXPECTING_A_DSA_KEY 129
1030#define EVP_R_EXPECTING_A_ECDSA_KEY 141 1285#define EVP_R_EXPECTING_A_ECDSA_KEY 141
1031#define EVP_R_EXPECTING_A_EC_KEY 142 1286#define EVP_R_EXPECTING_A_EC_KEY 142
1032#define EVP_R_FIPS_MODE_NOT_SUPPORTED 147
1033#define EVP_R_INITIALIZATION_ERROR 134 1287#define EVP_R_INITIALIZATION_ERROR 134
1034#define EVP_R_INPUT_NOT_INITIALIZED 111 1288#define EVP_R_INPUT_NOT_INITIALIZED 111
1035#define EVP_R_INVALID_FIPS_MODE 148 1289#define EVP_R_INVALID_DIGEST 152
1036#define EVP_R_INVALID_KEY_LENGTH 130 1290#define EVP_R_INVALID_KEY_LENGTH 130
1291#define EVP_R_INVALID_OPERATION 148
1037#define EVP_R_IV_TOO_LARGE 102 1292#define EVP_R_IV_TOO_LARGE 102
1038#define EVP_R_KEYGEN_FAILURE 120 1293#define EVP_R_KEYGEN_FAILURE 120
1294#define EVP_R_MESSAGE_DIGEST_IS_NULL 159
1295#define EVP_R_METHOD_NOT_SUPPORTED 144
1039#define EVP_R_MISSING_PARAMETERS 103 1296#define EVP_R_MISSING_PARAMETERS 103
1040#define EVP_R_NO_CIPHER_SET 131 1297#define EVP_R_NO_CIPHER_SET 131
1298#define EVP_R_NO_DEFAULT_DIGEST 158
1041#define EVP_R_NO_DIGEST_SET 139 1299#define EVP_R_NO_DIGEST_SET 139
1042#define EVP_R_NO_DSA_PARAMETERS 116 1300#define EVP_R_NO_DSA_PARAMETERS 116
1301#define EVP_R_NO_KEY_SET 154
1302#define EVP_R_NO_OPERATION_SET 149
1043#define EVP_R_NO_SIGN_FUNCTION_CONFIGURED 104 1303#define EVP_R_NO_SIGN_FUNCTION_CONFIGURED 104
1044#define EVP_R_NO_VERIFY_FUNCTION_CONFIGURED 105 1304#define EVP_R_NO_VERIFY_FUNCTION_CONFIGURED 105
1305#define EVP_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE 150
1306#define EVP_R_OPERATON_NOT_INITIALIZED 151
1045#define EVP_R_PKCS8_UNKNOWN_BROKEN_TYPE 117 1307#define EVP_R_PKCS8_UNKNOWN_BROKEN_TYPE 117
1308#define EVP_R_PRIVATE_KEY_DECODE_ERROR 145
1309#define EVP_R_PRIVATE_KEY_ENCODE_ERROR 146
1046#define EVP_R_PUBLIC_KEY_NOT_RSA 106 1310#define EVP_R_PUBLIC_KEY_NOT_RSA 106
1047#define EVP_R_UNKNOWN_OPTION 149 1311#define EVP_R_UNKNOWN_CIPHER 160
1312#define EVP_R_UNKNOWN_DIGEST 161
1048#define EVP_R_UNKNOWN_PBE_ALGORITHM 121 1313#define EVP_R_UNKNOWN_PBE_ALGORITHM 121
1049#define EVP_R_UNSUPORTED_NUMBER_OF_ROUNDS 135 1314#define EVP_R_UNSUPORTED_NUMBER_OF_ROUNDS 135
1315#define EVP_R_UNSUPPORTED_ALGORITHM 156
1050#define EVP_R_UNSUPPORTED_CIPHER 107 1316#define EVP_R_UNSUPPORTED_CIPHER 107
1051#define EVP_R_UNSUPPORTED_KEYLENGTH 123 1317#define EVP_R_UNSUPPORTED_KEYLENGTH 123
1052#define EVP_R_UNSUPPORTED_KEY_DERIVATION_FUNCTION 124 1318#define EVP_R_UNSUPPORTED_KEY_DERIVATION_FUNCTION 124
@@ -1056,7 +1322,6 @@ void ERR_load_EVP_strings(void);
1056#define EVP_R_UNSUPPORTED_SALT_TYPE 126 1322#define EVP_R_UNSUPPORTED_SALT_TYPE 126
1057#define EVP_R_WRONG_FINAL_BLOCK_LENGTH 109 1323#define EVP_R_WRONG_FINAL_BLOCK_LENGTH 109
1058#define EVP_R_WRONG_PUBLIC_KEY_TYPE 110 1324#define EVP_R_WRONG_PUBLIC_KEY_TYPE 110
1059#define EVP_R_SEED_KEY_SETUP_FAILED 162
1060 1325
1061#ifdef __cplusplus 1326#ifdef __cplusplus
1062} 1327}
diff --git a/src/lib/libcrypto/evp/evp_cnf.c b/src/lib/libcrypto/evp/evp_cnf.c
deleted file mode 100644
index 2e4db30235..0000000000
--- a/src/lib/libcrypto/evp/evp_cnf.c
+++ /dev/null
@@ -1,125 +0,0 @@
1/* evp_cnf.c */
2/* Written by Stephen Henson (steve@openssl.org) for the OpenSSL
3 * project 2007.
4 */
5/* ====================================================================
6 * Copyright (c) 2007 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 * licensing@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 <stdio.h>
60#include <ctype.h>
61#include <openssl/crypto.h>
62#include "cryptlib.h"
63#include <openssl/conf.h>
64#include <openssl/dso.h>
65#include <openssl/x509.h>
66#include <openssl/x509v3.h>
67#ifdef OPENSSL_FIPS
68#include <openssl/fips.h>
69#endif
70
71
72/* Algorithm configuration module. */
73
74static int alg_module_init(CONF_IMODULE *md, const CONF *cnf)
75 {
76 int i;
77 const char *oid_section;
78 STACK_OF(CONF_VALUE) *sktmp;
79 CONF_VALUE *oval;
80 oid_section = CONF_imodule_get_value(md);
81 if(!(sktmp = NCONF_get_section(cnf, oid_section)))
82 {
83 EVPerr(EVP_F_ALG_MODULE_INIT, EVP_R_ERROR_LOADING_SECTION);
84 return 0;
85 }
86 for(i = 0; i < sk_CONF_VALUE_num(sktmp); i++)
87 {
88 oval = sk_CONF_VALUE_value(sktmp, i);
89 if (!strcmp(oval->name, "fips_mode"))
90 {
91 int m;
92 if (!X509V3_get_value_bool(oval, &m))
93 {
94 EVPerr(EVP_F_ALG_MODULE_INIT, EVP_R_INVALID_FIPS_MODE);
95 return 0;
96 }
97 if (m > 0)
98 {
99#ifdef OPENSSL_FIPS
100 if (!FIPS_mode() && !FIPS_mode_set(1))
101 {
102 EVPerr(EVP_F_ALG_MODULE_INIT, EVP_R_ERROR_SETTING_FIPS_MODE);
103 return 0;
104 }
105#else
106 EVPerr(EVP_F_ALG_MODULE_INIT, EVP_R_FIPS_MODE_NOT_SUPPORTED);
107 return 0;
108#endif
109 }
110 }
111 else
112 {
113 EVPerr(EVP_F_ALG_MODULE_INIT, EVP_R_UNKNOWN_OPTION);
114 ERR_add_error_data(4, "name=", oval->name,
115 ", value=", oval->value);
116 }
117
118 }
119 return 1;
120 }
121
122void EVP_add_alg_module(void)
123 {
124 CONF_module_add("alg_section", alg_module_init, 0);
125 }
diff --git a/src/lib/libcrypto/evp/evp_enc.c b/src/lib/libcrypto/evp/evp_enc.c
index 30e0ca4d9f..bead6a2170 100644
--- a/src/lib/libcrypto/evp/evp_enc.c
+++ b/src/lib/libcrypto/evp/evp_enc.c
@@ -66,16 +66,14 @@
66#endif 66#endif
67#include "evp_locl.h" 67#include "evp_locl.h"
68 68
69#ifdef OPENSSL_FIPS
70 #define M_do_cipher(ctx, out, in, inl) \
71 EVP_Cipher(ctx,out,in,inl)
72#else
73 #define M_do_cipher(ctx, out, in, inl) \
74 ctx->cipher->do_cipher(ctx,out,in,inl)
75#endif
76
77const char EVP_version[]="EVP" OPENSSL_VERSION_PTEXT; 69const char EVP_version[]="EVP" OPENSSL_VERSION_PTEXT;
78 70
71void EVP_CIPHER_CTX_init(EVP_CIPHER_CTX *ctx)
72 {
73 memset(ctx,0,sizeof(EVP_CIPHER_CTX));
74 /* ctx->cipher=NULL; */
75 }
76
79EVP_CIPHER_CTX *EVP_CIPHER_CTX_new(void) 77EVP_CIPHER_CTX *EVP_CIPHER_CTX_new(void)
80 { 78 {
81 EVP_CIPHER_CTX *ctx=OPENSSL_malloc(sizeof *ctx); 79 EVP_CIPHER_CTX *ctx=OPENSSL_malloc(sizeof *ctx);
@@ -92,6 +90,144 @@ int EVP_CipherInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher,
92 return EVP_CipherInit_ex(ctx,cipher,NULL,key,iv,enc); 90 return EVP_CipherInit_ex(ctx,cipher,NULL,key,iv,enc);
93 } 91 }
94 92
93int EVP_CipherInit_ex(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher, ENGINE *impl,
94 const unsigned char *key, const unsigned char *iv, int enc)
95 {
96 if (enc == -1)
97 enc = ctx->encrypt;
98 else
99 {
100 if (enc)
101 enc = 1;
102 ctx->encrypt = enc;
103 }
104#ifndef OPENSSL_NO_ENGINE
105 /* Whether it's nice or not, "Inits" can be used on "Final"'d contexts
106 * so this context may already have an ENGINE! Try to avoid releasing
107 * the previous handle, re-querying for an ENGINE, and having a
108 * reinitialisation, when it may all be unecessary. */
109 if (ctx->engine && ctx->cipher && (!cipher ||
110 (cipher && (cipher->nid == ctx->cipher->nid))))
111 goto skip_to_init;
112#endif
113 if (cipher)
114 {
115 /* Ensure a context left lying around from last time is cleared
116 * (the previous check attempted to avoid this if the same
117 * ENGINE and EVP_CIPHER could be used). */
118 EVP_CIPHER_CTX_cleanup(ctx);
119
120 /* Restore encrypt field: it is zeroed by cleanup */
121 ctx->encrypt = enc;
122#ifndef OPENSSL_NO_ENGINE
123 if(impl)
124 {
125 if (!ENGINE_init(impl))
126 {
127 EVPerr(EVP_F_EVP_CIPHERINIT_EX, EVP_R_INITIALIZATION_ERROR);
128 return 0;
129 }
130 }
131 else
132 /* Ask if an ENGINE is reserved for this job */
133 impl = ENGINE_get_cipher_engine(cipher->nid);
134 if(impl)
135 {
136 /* There's an ENGINE for this job ... (apparently) */
137 const EVP_CIPHER *c = ENGINE_get_cipher(impl, cipher->nid);
138 if(!c)
139 {
140 /* One positive side-effect of US's export
141 * control history, is that we should at least
142 * be able to avoid using US mispellings of
143 * "initialisation"? */
144 EVPerr(EVP_F_EVP_CIPHERINIT_EX, EVP_R_INITIALIZATION_ERROR);
145 return 0;
146 }
147 /* We'll use the ENGINE's private cipher definition */
148 cipher = c;
149 /* Store the ENGINE functional reference so we know
150 * 'cipher' came from an ENGINE and we need to release
151 * it when done. */
152 ctx->engine = impl;
153 }
154 else
155 ctx->engine = NULL;
156#endif
157
158 ctx->cipher=cipher;
159 if (ctx->cipher->ctx_size)
160 {
161 ctx->cipher_data=OPENSSL_malloc(ctx->cipher->ctx_size);
162 if (!ctx->cipher_data)
163 {
164 EVPerr(EVP_F_EVP_CIPHERINIT_EX, ERR_R_MALLOC_FAILURE);
165 return 0;
166 }
167 }
168 else
169 {
170 ctx->cipher_data = NULL;
171 }
172 ctx->key_len = cipher->key_len;
173 ctx->flags = 0;
174 if(ctx->cipher->flags & EVP_CIPH_CTRL_INIT)
175 {
176 if(!EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_INIT, 0, NULL))
177 {
178 EVPerr(EVP_F_EVP_CIPHERINIT_EX, EVP_R_INITIALIZATION_ERROR);
179 return 0;
180 }
181 }
182 }
183 else if(!ctx->cipher)
184 {
185 EVPerr(EVP_F_EVP_CIPHERINIT_EX, EVP_R_NO_CIPHER_SET);
186 return 0;
187 }
188#ifndef OPENSSL_NO_ENGINE
189skip_to_init:
190#endif
191 /* we assume block size is a power of 2 in *cryptUpdate */
192 OPENSSL_assert(ctx->cipher->block_size == 1
193 || ctx->cipher->block_size == 8
194 || ctx->cipher->block_size == 16);
195
196 if(!(EVP_CIPHER_CTX_flags(ctx) & EVP_CIPH_CUSTOM_IV)) {
197 switch(EVP_CIPHER_CTX_mode(ctx)) {
198
199 case EVP_CIPH_STREAM_CIPHER:
200 case EVP_CIPH_ECB_MODE:
201 break;
202
203 case EVP_CIPH_CFB_MODE:
204 case EVP_CIPH_OFB_MODE:
205
206 ctx->num = 0;
207
208 case EVP_CIPH_CBC_MODE:
209
210 OPENSSL_assert(EVP_CIPHER_CTX_iv_length(ctx) <=
211 (int)sizeof(ctx->iv));
212 if(iv) memcpy(ctx->oiv, iv, EVP_CIPHER_CTX_iv_length(ctx));
213 memcpy(ctx->iv, ctx->oiv, EVP_CIPHER_CTX_iv_length(ctx));
214 break;
215
216 default:
217 return 0;
218 break;
219 }
220 }
221
222 if(key || (ctx->cipher->flags & EVP_CIPH_ALWAYS_CALL_INIT)) {
223 if(!ctx->cipher->init(ctx,key,iv,enc)) return 0;
224 }
225 ctx->buf_len=0;
226 ctx->final_used=0;
227 ctx->block_mask=ctx->cipher->block_size-1;
228 return 1;
229 }
230
95int EVP_CipherUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl, 231int EVP_CipherUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl,
96 const unsigned char *in, int inl) 232 const unsigned char *in, int inl)
97 { 233 {
@@ -151,7 +287,7 @@ int EVP_EncryptUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl,
151 287
152 if(ctx->buf_len == 0 && (inl&(ctx->block_mask)) == 0) 288 if(ctx->buf_len == 0 && (inl&(ctx->block_mask)) == 0)
153 { 289 {
154 if(M_do_cipher(ctx,out,in,inl)) 290 if(ctx->cipher->do_cipher(ctx,out,in,inl))
155 { 291 {
156 *outl=inl; 292 *outl=inl;
157 return 1; 293 return 1;
@@ -178,7 +314,7 @@ int EVP_EncryptUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl,
178 { 314 {
179 j=bl-i; 315 j=bl-i;
180 memcpy(&(ctx->buf[i]),in,j); 316 memcpy(&(ctx->buf[i]),in,j);
181 if(!M_do_cipher(ctx,out,ctx->buf,bl)) return 0; 317 if(!ctx->cipher->do_cipher(ctx,out,ctx->buf,bl)) return 0;
182 inl-=j; 318 inl-=j;
183 in+=j; 319 in+=j;
184 out+=bl; 320 out+=bl;
@@ -191,7 +327,7 @@ int EVP_EncryptUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl,
191 inl-=i; 327 inl-=i;
192 if (inl > 0) 328 if (inl > 0)
193 { 329 {
194 if(!M_do_cipher(ctx,out,in,inl)) return 0; 330 if(!ctx->cipher->do_cipher(ctx,out,in,inl)) return 0;
195 *outl+=inl; 331 *outl+=inl;
196 } 332 }
197 333
@@ -235,7 +371,7 @@ int EVP_EncryptFinal_ex(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl)
235 n=b-bl; 371 n=b-bl;
236 for (i=bl; i<b; i++) 372 for (i=bl; i<b; i++)
237 ctx->buf[i]=n; 373 ctx->buf[i]=n;
238 ret=M_do_cipher(ctx,out,ctx->buf,b); 374 ret=ctx->cipher->do_cipher(ctx,out,ctx->buf,b);
239 375
240 376
241 if(ret) 377 if(ret)
@@ -357,6 +493,28 @@ void EVP_CIPHER_CTX_free(EVP_CIPHER_CTX *ctx)
357 } 493 }
358 } 494 }
359 495
496int EVP_CIPHER_CTX_cleanup(EVP_CIPHER_CTX *c)
497 {
498 if (c->cipher != NULL)
499 {
500 if(c->cipher->cleanup && !c->cipher->cleanup(c))
501 return 0;
502 /* Cleanse cipher context data */
503 if (c->cipher_data)
504 OPENSSL_cleanse(c->cipher_data, c->cipher->ctx_size);
505 }
506 if (c->cipher_data)
507 OPENSSL_free(c->cipher_data);
508#ifndef OPENSSL_NO_ENGINE
509 if (c->engine)
510 /* The EVP_CIPHER we used belongs to an ENGINE, release the
511 * functional reference we held for this reason. */
512 ENGINE_finish(c->engine);
513#endif
514 memset(c,0,sizeof(EVP_CIPHER_CTX));
515 return 1;
516 }
517
360int EVP_CIPHER_CTX_set_key_length(EVP_CIPHER_CTX *c, int keylen) 518int EVP_CIPHER_CTX_set_key_length(EVP_CIPHER_CTX *c, int keylen)
361 { 519 {
362 if(c->cipher->flags & EVP_CIPH_CUSTOM_KEY_LENGTH) 520 if(c->cipher->flags & EVP_CIPH_CUSTOM_KEY_LENGTH)
@@ -378,6 +536,27 @@ int EVP_CIPHER_CTX_set_padding(EVP_CIPHER_CTX *ctx, int pad)
378 return 1; 536 return 1;
379 } 537 }
380 538
539int EVP_CIPHER_CTX_ctrl(EVP_CIPHER_CTX *ctx, int type, int arg, void *ptr)
540{
541 int ret;
542 if(!ctx->cipher) {
543 EVPerr(EVP_F_EVP_CIPHER_CTX_CTRL, EVP_R_NO_CIPHER_SET);
544 return 0;
545 }
546
547 if(!ctx->cipher->ctrl) {
548 EVPerr(EVP_F_EVP_CIPHER_CTX_CTRL, EVP_R_CTRL_NOT_IMPLEMENTED);
549 return 0;
550 }
551
552 ret = ctx->cipher->ctrl(ctx, type, arg, ptr);
553 if(ret == -1) {
554 EVPerr(EVP_F_EVP_CIPHER_CTX_CTRL, EVP_R_CTRL_OPERATION_NOT_IMPLEMENTED);
555 return 0;
556 }
557 return ret;
558}
559
381int EVP_CIPHER_CTX_rand_key(EVP_CIPHER_CTX *ctx, unsigned char *key) 560int EVP_CIPHER_CTX_rand_key(EVP_CIPHER_CTX *ctx, unsigned char *key)
382 { 561 {
383 if (ctx->cipher->flags & EVP_CIPH_RAND_KEY) 562 if (ctx->cipher->flags & EVP_CIPH_RAND_KEY)
@@ -387,54 +566,38 @@ int EVP_CIPHER_CTX_rand_key(EVP_CIPHER_CTX *ctx, unsigned char *key)
387 return 1; 566 return 1;
388 } 567 }
389 568
390#ifndef OPENSSL_NO_ENGINE 569int EVP_CIPHER_CTX_copy(EVP_CIPHER_CTX *out, const EVP_CIPHER_CTX *in)
391
392#ifdef OPENSSL_FIPS
393
394static int do_evp_enc_engine_full(EVP_CIPHER_CTX *ctx, const EVP_CIPHER **pcipher, ENGINE *impl)
395 { 570 {
396 if(impl) 571 if ((in == NULL) || (in->cipher == NULL))
397 { 572 {
398 if (!ENGINE_init(impl)) 573 EVPerr(EVP_F_EVP_CIPHER_CTX_COPY,EVP_R_INPUT_NOT_INITIALIZED);
399 { 574 return 0;
400 EVPerr(EVP_F_DO_EVP_ENC_ENGINE_FULL, EVP_R_INITIALIZATION_ERROR);
401 return 0;
402 }
403 } 575 }
404 else 576#ifndef OPENSSL_NO_ENGINE
405 /* Ask if an ENGINE is reserved for this job */ 577 /* Make sure it's safe to copy a cipher context using an ENGINE */
406 impl = ENGINE_get_cipher_engine((*pcipher)->nid); 578 if (in->engine && !ENGINE_init(in->engine))
407 if(impl) 579 {
580 EVPerr(EVP_F_EVP_CIPHER_CTX_COPY,ERR_R_ENGINE_LIB);
581 return 0;
582 }
583#endif
584
585 EVP_CIPHER_CTX_cleanup(out);
586 memcpy(out,in,sizeof *out);
587
588 if (in->cipher_data && in->cipher->ctx_size)
408 { 589 {
409 /* There's an ENGINE for this job ... (apparently) */ 590 out->cipher_data=OPENSSL_malloc(in->cipher->ctx_size);
410 const EVP_CIPHER *c = ENGINE_get_cipher(impl, (*pcipher)->nid); 591 if (!out->cipher_data)
411 if(!c)
412 { 592 {
413 /* One positive side-effect of US's export 593 EVPerr(EVP_F_EVP_CIPHER_CTX_COPY,ERR_R_MALLOC_FAILURE);
414 * control history, is that we should at least
415 * be able to avoid using US mispellings of
416 * "initialisation"? */
417 EVPerr(EVP_F_DO_EVP_ENC_ENGINE_FULL, EVP_R_INITIALIZATION_ERROR);
418 return 0; 594 return 0;
419 } 595 }
420 /* We'll use the ENGINE's private cipher definition */ 596 memcpy(out->cipher_data,in->cipher_data,in->cipher->ctx_size);
421 *pcipher = c;
422 /* Store the ENGINE functional reference so we know
423 * 'cipher' came from an ENGINE and we need to release
424 * it when done. */
425 ctx->engine = impl;
426 } 597 }
427 else
428 ctx->engine = NULL;
429 return 1;
430 }
431 598
432void int_EVP_CIPHER_init_engine_callbacks(void) 599 if (in->cipher->flags & EVP_CIPH_CUSTOM_COPY)
433 { 600 return in->cipher->ctrl((EVP_CIPHER_CTX *)in, EVP_CTRL_COPY, 0, out);
434 int_EVP_CIPHER_set_engine_callbacks( 601 return 1;
435 ENGINE_finish, do_evp_enc_engine_full);
436 } 602 }
437 603
438#endif
439
440#endif
diff --git a/src/lib/libcrypto/evp/evp_err.c b/src/lib/libcrypto/evp/evp_err.c
index ec2d127cd8..6b585c7483 100644
--- a/src/lib/libcrypto/evp/evp_err.c
+++ b/src/lib/libcrypto/evp/evp_err.c
@@ -1,6 +1,6 @@
1/* crypto/evp/evp_err.c */ 1/* crypto/evp/evp_err.c */
2/* ==================================================================== 2/* ====================================================================
3 * Copyright (c) 1999-2007 The OpenSSL Project. All rights reserved. 3 * Copyright (c) 1999-2008 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
@@ -72,46 +72,66 @@ static ERR_STRING_DATA EVP_str_functs[]=
72 { 72 {
73{ERR_FUNC(EVP_F_AESNI_INIT_KEY), "AESNI_INIT_KEY"}, 73{ERR_FUNC(EVP_F_AESNI_INIT_KEY), "AESNI_INIT_KEY"},
74{ERR_FUNC(EVP_F_AES_INIT_KEY), "AES_INIT_KEY"}, 74{ERR_FUNC(EVP_F_AES_INIT_KEY), "AES_INIT_KEY"},
75{ERR_FUNC(EVP_F_ALG_MODULE_INIT), "ALG_MODULE_INIT"},
76{ERR_FUNC(EVP_F_CAMELLIA_INIT_KEY), "CAMELLIA_INIT_KEY"}, 75{ERR_FUNC(EVP_F_CAMELLIA_INIT_KEY), "CAMELLIA_INIT_KEY"},
77{ERR_FUNC(EVP_F_D2I_PKEY), "D2I_PKEY"}, 76{ERR_FUNC(EVP_F_D2I_PKEY), "D2I_PKEY"},
78{ERR_FUNC(EVP_F_DO_EVP_ENC_ENGINE), "DO_EVP_ENC_ENGINE"}, 77{ERR_FUNC(EVP_F_DO_SIGVER_INIT), "DO_SIGVER_INIT"},
79{ERR_FUNC(EVP_F_DO_EVP_ENC_ENGINE_FULL), "DO_EVP_ENC_ENGINE_FULL"},
80{ERR_FUNC(EVP_F_DO_EVP_MD_ENGINE), "DO_EVP_MD_ENGINE"},
81{ERR_FUNC(EVP_F_DO_EVP_MD_ENGINE_FULL), "DO_EVP_MD_ENGINE_FULL"},
82{ERR_FUNC(EVP_F_DSAPKEY2PKCS8), "DSAPKEY2PKCS8"}, 78{ERR_FUNC(EVP_F_DSAPKEY2PKCS8), "DSAPKEY2PKCS8"},
83{ERR_FUNC(EVP_F_DSA_PKEY2PKCS8), "DSA_PKEY2PKCS8"}, 79{ERR_FUNC(EVP_F_DSA_PKEY2PKCS8), "DSA_PKEY2PKCS8"},
84{ERR_FUNC(EVP_F_ECDSA_PKEY2PKCS8), "ECDSA_PKEY2PKCS8"}, 80{ERR_FUNC(EVP_F_ECDSA_PKEY2PKCS8), "ECDSA_PKEY2PKCS8"},
85{ERR_FUNC(EVP_F_ECKEY_PKEY2PKCS8), "ECKEY_PKEY2PKCS8"}, 81{ERR_FUNC(EVP_F_ECKEY_PKEY2PKCS8), "ECKEY_PKEY2PKCS8"},
86{ERR_FUNC(EVP_F_EVP_CIPHERINIT), "EVP_CipherInit"},
87{ERR_FUNC(EVP_F_EVP_CIPHERINIT_EX), "EVP_CipherInit_ex"}, 82{ERR_FUNC(EVP_F_EVP_CIPHERINIT_EX), "EVP_CipherInit_ex"},
83{ERR_FUNC(EVP_F_EVP_CIPHER_CTX_COPY), "EVP_CIPHER_CTX_copy"},
88{ERR_FUNC(EVP_F_EVP_CIPHER_CTX_CTRL), "EVP_CIPHER_CTX_ctrl"}, 84{ERR_FUNC(EVP_F_EVP_CIPHER_CTX_CTRL), "EVP_CIPHER_CTX_ctrl"},
89{ERR_FUNC(EVP_F_EVP_CIPHER_CTX_SET_KEY_LENGTH), "EVP_CIPHER_CTX_set_key_length"}, 85{ERR_FUNC(EVP_F_EVP_CIPHER_CTX_SET_KEY_LENGTH), "EVP_CIPHER_CTX_set_key_length"},
90{ERR_FUNC(EVP_F_EVP_DECRYPTFINAL_EX), "EVP_DecryptFinal_ex"}, 86{ERR_FUNC(EVP_F_EVP_DECRYPTFINAL_EX), "EVP_DecryptFinal_ex"},
91{ERR_FUNC(EVP_F_EVP_DIGESTINIT), "EVP_DigestInit"},
92{ERR_FUNC(EVP_F_EVP_DIGESTINIT_EX), "EVP_DigestInit_ex"}, 87{ERR_FUNC(EVP_F_EVP_DIGESTINIT_EX), "EVP_DigestInit_ex"},
93{ERR_FUNC(EVP_F_EVP_ENCRYPTFINAL_EX), "EVP_EncryptFinal_ex"}, 88{ERR_FUNC(EVP_F_EVP_ENCRYPTFINAL_EX), "EVP_EncryptFinal_ex"},
94{ERR_FUNC(EVP_F_EVP_MD_CTX_COPY_EX), "EVP_MD_CTX_copy_ex"}, 89{ERR_FUNC(EVP_F_EVP_MD_CTX_COPY_EX), "EVP_MD_CTX_copy_ex"},
90{ERR_FUNC(EVP_F_EVP_MD_SIZE), "EVP_MD_SIZE"},
95{ERR_FUNC(EVP_F_EVP_OPENINIT), "EVP_OpenInit"}, 91{ERR_FUNC(EVP_F_EVP_OPENINIT), "EVP_OpenInit"},
96{ERR_FUNC(EVP_F_EVP_PBE_ALG_ADD), "EVP_PBE_alg_add"}, 92{ERR_FUNC(EVP_F_EVP_PBE_ALG_ADD), "EVP_PBE_alg_add"},
93{ERR_FUNC(EVP_F_EVP_PBE_ALG_ADD_TYPE), "EVP_PBE_alg_add_type"},
97{ERR_FUNC(EVP_F_EVP_PBE_CIPHERINIT), "EVP_PBE_CipherInit"}, 94{ERR_FUNC(EVP_F_EVP_PBE_CIPHERINIT), "EVP_PBE_CipherInit"},
98{ERR_FUNC(EVP_F_EVP_PKCS82PKEY), "EVP_PKCS82PKEY"}, 95{ERR_FUNC(EVP_F_EVP_PKCS82PKEY), "EVP_PKCS82PKEY"},
96{ERR_FUNC(EVP_F_EVP_PKCS82PKEY_BROKEN), "EVP_PKCS82PKEY_BROKEN"},
99{ERR_FUNC(EVP_F_EVP_PKEY2PKCS8_BROKEN), "EVP_PKEY2PKCS8_broken"}, 97{ERR_FUNC(EVP_F_EVP_PKEY2PKCS8_BROKEN), "EVP_PKEY2PKCS8_broken"},
100{ERR_FUNC(EVP_F_EVP_PKEY_COPY_PARAMETERS), "EVP_PKEY_copy_parameters"}, 98{ERR_FUNC(EVP_F_EVP_PKEY_COPY_PARAMETERS), "EVP_PKEY_copy_parameters"},
99{ERR_FUNC(EVP_F_EVP_PKEY_CTX_CTRL), "EVP_PKEY_CTX_ctrl"},
100{ERR_FUNC(EVP_F_EVP_PKEY_CTX_CTRL_STR), "EVP_PKEY_CTX_ctrl_str"},
101{ERR_FUNC(EVP_F_EVP_PKEY_CTX_DUP), "EVP_PKEY_CTX_dup"},
101{ERR_FUNC(EVP_F_EVP_PKEY_DECRYPT), "EVP_PKEY_decrypt"}, 102{ERR_FUNC(EVP_F_EVP_PKEY_DECRYPT), "EVP_PKEY_decrypt"},
103{ERR_FUNC(EVP_F_EVP_PKEY_DECRYPT_INIT), "EVP_PKEY_decrypt_init"},
104{ERR_FUNC(EVP_F_EVP_PKEY_DECRYPT_OLD), "EVP_PKEY_decrypt_old"},
105{ERR_FUNC(EVP_F_EVP_PKEY_DERIVE), "EVP_PKEY_derive"},
106{ERR_FUNC(EVP_F_EVP_PKEY_DERIVE_INIT), "EVP_PKEY_derive_init"},
107{ERR_FUNC(EVP_F_EVP_PKEY_DERIVE_SET_PEER), "EVP_PKEY_derive_set_peer"},
102{ERR_FUNC(EVP_F_EVP_PKEY_ENCRYPT), "EVP_PKEY_encrypt"}, 108{ERR_FUNC(EVP_F_EVP_PKEY_ENCRYPT), "EVP_PKEY_encrypt"},
109{ERR_FUNC(EVP_F_EVP_PKEY_ENCRYPT_INIT), "EVP_PKEY_encrypt_init"},
110{ERR_FUNC(EVP_F_EVP_PKEY_ENCRYPT_OLD), "EVP_PKEY_encrypt_old"},
103{ERR_FUNC(EVP_F_EVP_PKEY_GET1_DH), "EVP_PKEY_get1_DH"}, 111{ERR_FUNC(EVP_F_EVP_PKEY_GET1_DH), "EVP_PKEY_get1_DH"},
104{ERR_FUNC(EVP_F_EVP_PKEY_GET1_DSA), "EVP_PKEY_get1_DSA"}, 112{ERR_FUNC(EVP_F_EVP_PKEY_GET1_DSA), "EVP_PKEY_get1_DSA"},
105{ERR_FUNC(EVP_F_EVP_PKEY_GET1_ECDSA), "EVP_PKEY_GET1_ECDSA"}, 113{ERR_FUNC(EVP_F_EVP_PKEY_GET1_ECDSA), "EVP_PKEY_GET1_ECDSA"},
106{ERR_FUNC(EVP_F_EVP_PKEY_GET1_EC_KEY), "EVP_PKEY_get1_EC_KEY"}, 114{ERR_FUNC(EVP_F_EVP_PKEY_GET1_EC_KEY), "EVP_PKEY_get1_EC_KEY"},
107{ERR_FUNC(EVP_F_EVP_PKEY_GET1_RSA), "EVP_PKEY_get1_RSA"}, 115{ERR_FUNC(EVP_F_EVP_PKEY_GET1_RSA), "EVP_PKEY_get1_RSA"},
116{ERR_FUNC(EVP_F_EVP_PKEY_KEYGEN), "EVP_PKEY_keygen"},
117{ERR_FUNC(EVP_F_EVP_PKEY_KEYGEN_INIT), "EVP_PKEY_keygen_init"},
108{ERR_FUNC(EVP_F_EVP_PKEY_NEW), "EVP_PKEY_new"}, 118{ERR_FUNC(EVP_F_EVP_PKEY_NEW), "EVP_PKEY_new"},
119{ERR_FUNC(EVP_F_EVP_PKEY_PARAMGEN), "EVP_PKEY_paramgen"},
120{ERR_FUNC(EVP_F_EVP_PKEY_PARAMGEN_INIT), "EVP_PKEY_paramgen_init"},
121{ERR_FUNC(EVP_F_EVP_PKEY_SIGN), "EVP_PKEY_sign"},
122{ERR_FUNC(EVP_F_EVP_PKEY_SIGN_INIT), "EVP_PKEY_sign_init"},
123{ERR_FUNC(EVP_F_EVP_PKEY_VERIFY), "EVP_PKEY_verify"},
124{ERR_FUNC(EVP_F_EVP_PKEY_VERIFY_INIT), "EVP_PKEY_verify_init"},
125{ERR_FUNC(EVP_F_EVP_PKEY_VERIFY_RECOVER), "EVP_PKEY_verify_recover"},
126{ERR_FUNC(EVP_F_EVP_PKEY_VERIFY_RECOVER_INIT), "EVP_PKEY_verify_recover_init"},
109{ERR_FUNC(EVP_F_EVP_RIJNDAEL), "EVP_RIJNDAEL"}, 127{ERR_FUNC(EVP_F_EVP_RIJNDAEL), "EVP_RIJNDAEL"},
110{ERR_FUNC(EVP_F_EVP_SIGNFINAL), "EVP_SignFinal"}, 128{ERR_FUNC(EVP_F_EVP_SIGNFINAL), "EVP_SignFinal"},
111{ERR_FUNC(EVP_F_EVP_VERIFYFINAL), "EVP_VerifyFinal"}, 129{ERR_FUNC(EVP_F_EVP_VERIFYFINAL), "EVP_VerifyFinal"},
130{ERR_FUNC(EVP_F_INT_CTX_NEW), "INT_CTX_NEW"},
112{ERR_FUNC(EVP_F_PKCS5_PBE_KEYIVGEN), "PKCS5_PBE_keyivgen"}, 131{ERR_FUNC(EVP_F_PKCS5_PBE_KEYIVGEN), "PKCS5_PBE_keyivgen"},
113{ERR_FUNC(EVP_F_PKCS5_V2_PBE_KEYIVGEN), "PKCS5_v2_PBE_keyivgen"}, 132{ERR_FUNC(EVP_F_PKCS5_V2_PBE_KEYIVGEN), "PKCS5_v2_PBE_keyivgen"},
114{ERR_FUNC(EVP_F_PKCS8_SET_BROKEN), "PKCS8_set_broken"}, 133{ERR_FUNC(EVP_F_PKCS8_SET_BROKEN), "PKCS8_set_broken"},
134{ERR_FUNC(EVP_F_PKEY_SET_TYPE), "PKEY_SET_TYPE"},
115{ERR_FUNC(EVP_F_RC2_MAGIC_TO_METH), "RC2_MAGIC_TO_METH"}, 135{ERR_FUNC(EVP_F_RC2_MAGIC_TO_METH), "RC2_MAGIC_TO_METH"},
116{ERR_FUNC(EVP_F_RC5_CTRL), "RC5_CTRL"}, 136{ERR_FUNC(EVP_F_RC5_CTRL), "RC5_CTRL"},
117{0,NULL} 137{0,NULL}
@@ -126,42 +146,52 @@ static ERR_STRING_DATA EVP_str_reasons[]=
126{ERR_REASON(EVP_R_BAD_KEY_LENGTH) ,"bad key length"}, 146{ERR_REASON(EVP_R_BAD_KEY_LENGTH) ,"bad key length"},
127{ERR_REASON(EVP_R_BN_DECODE_ERROR) ,"bn decode error"}, 147{ERR_REASON(EVP_R_BN_DECODE_ERROR) ,"bn decode error"},
128{ERR_REASON(EVP_R_BN_PUBKEY_ERROR) ,"bn pubkey error"}, 148{ERR_REASON(EVP_R_BN_PUBKEY_ERROR) ,"bn pubkey error"},
149{ERR_REASON(EVP_R_BUFFER_TOO_SMALL) ,"buffer too small"},
129{ERR_REASON(EVP_R_CAMELLIA_KEY_SETUP_FAILED),"camellia key setup failed"}, 150{ERR_REASON(EVP_R_CAMELLIA_KEY_SETUP_FAILED),"camellia key setup failed"},
130{ERR_REASON(EVP_R_CIPHER_PARAMETER_ERROR),"cipher parameter error"}, 151{ERR_REASON(EVP_R_CIPHER_PARAMETER_ERROR),"cipher parameter error"},
152{ERR_REASON(EVP_R_COMMAND_NOT_SUPPORTED) ,"command not supported"},
131{ERR_REASON(EVP_R_CTRL_NOT_IMPLEMENTED) ,"ctrl not implemented"}, 153{ERR_REASON(EVP_R_CTRL_NOT_IMPLEMENTED) ,"ctrl not implemented"},
132{ERR_REASON(EVP_R_CTRL_OPERATION_NOT_IMPLEMENTED),"ctrl operation not implemented"}, 154{ERR_REASON(EVP_R_CTRL_OPERATION_NOT_IMPLEMENTED),"ctrl operation not implemented"},
133{ERR_REASON(EVP_R_DATA_NOT_MULTIPLE_OF_BLOCK_LENGTH),"data not multiple of block length"}, 155{ERR_REASON(EVP_R_DATA_NOT_MULTIPLE_OF_BLOCK_LENGTH),"data not multiple of block length"},
134{ERR_REASON(EVP_R_DECODE_ERROR) ,"decode error"}, 156{ERR_REASON(EVP_R_DECODE_ERROR) ,"decode error"},
135{ERR_REASON(EVP_R_DIFFERENT_KEY_TYPES) ,"different key types"}, 157{ERR_REASON(EVP_R_DIFFERENT_KEY_TYPES) ,"different key types"},
136{ERR_REASON(EVP_R_DISABLED_FOR_FIPS) ,"disabled for fips"}, 158{ERR_REASON(EVP_R_DIFFERENT_PARAMETERS) ,"different parameters"},
137{ERR_REASON(EVP_R_ENCODE_ERROR) ,"encode error"}, 159{ERR_REASON(EVP_R_ENCODE_ERROR) ,"encode error"},
138{ERR_REASON(EVP_R_ERROR_LOADING_SECTION) ,"error loading section"},
139{ERR_REASON(EVP_R_ERROR_SETTING_FIPS_MODE),"error setting fips mode"},
140{ERR_REASON(EVP_R_EVP_PBE_CIPHERINIT_ERROR),"evp pbe cipherinit error"}, 160{ERR_REASON(EVP_R_EVP_PBE_CIPHERINIT_ERROR),"evp pbe cipherinit error"},
141{ERR_REASON(EVP_R_EXPECTING_AN_RSA_KEY) ,"expecting an rsa key"}, 161{ERR_REASON(EVP_R_EXPECTING_AN_RSA_KEY) ,"expecting an rsa key"},
142{ERR_REASON(EVP_R_EXPECTING_A_DH_KEY) ,"expecting a dh key"}, 162{ERR_REASON(EVP_R_EXPECTING_A_DH_KEY) ,"expecting a dh key"},
143{ERR_REASON(EVP_R_EXPECTING_A_DSA_KEY) ,"expecting a dsa key"}, 163{ERR_REASON(EVP_R_EXPECTING_A_DSA_KEY) ,"expecting a dsa key"},
144{ERR_REASON(EVP_R_EXPECTING_A_ECDSA_KEY) ,"expecting a ecdsa key"}, 164{ERR_REASON(EVP_R_EXPECTING_A_ECDSA_KEY) ,"expecting a ecdsa key"},
145{ERR_REASON(EVP_R_EXPECTING_A_EC_KEY) ,"expecting a ec key"}, 165{ERR_REASON(EVP_R_EXPECTING_A_EC_KEY) ,"expecting a ec key"},
146{ERR_REASON(EVP_R_FIPS_MODE_NOT_SUPPORTED),"fips mode not supported"},
147{ERR_REASON(EVP_R_INITIALIZATION_ERROR) ,"initialization error"}, 166{ERR_REASON(EVP_R_INITIALIZATION_ERROR) ,"initialization error"},
148{ERR_REASON(EVP_R_INPUT_NOT_INITIALIZED) ,"input not initialized"}, 167{ERR_REASON(EVP_R_INPUT_NOT_INITIALIZED) ,"input not initialized"},
149{ERR_REASON(EVP_R_INVALID_FIPS_MODE) ,"invalid fips mode"}, 168{ERR_REASON(EVP_R_INVALID_DIGEST) ,"invalid digest"},
150{ERR_REASON(EVP_R_INVALID_KEY_LENGTH) ,"invalid key length"}, 169{ERR_REASON(EVP_R_INVALID_KEY_LENGTH) ,"invalid key length"},
170{ERR_REASON(EVP_R_INVALID_OPERATION) ,"invalid operation"},
151{ERR_REASON(EVP_R_IV_TOO_LARGE) ,"iv too large"}, 171{ERR_REASON(EVP_R_IV_TOO_LARGE) ,"iv too large"},
152{ERR_REASON(EVP_R_KEYGEN_FAILURE) ,"keygen failure"}, 172{ERR_REASON(EVP_R_KEYGEN_FAILURE) ,"keygen failure"},
173{ERR_REASON(EVP_R_MESSAGE_DIGEST_IS_NULL),"message digest is null"},
174{ERR_REASON(EVP_R_METHOD_NOT_SUPPORTED) ,"method not supported"},
153{ERR_REASON(EVP_R_MISSING_PARAMETERS) ,"missing parameters"}, 175{ERR_REASON(EVP_R_MISSING_PARAMETERS) ,"missing parameters"},
154{ERR_REASON(EVP_R_NO_CIPHER_SET) ,"no cipher set"}, 176{ERR_REASON(EVP_R_NO_CIPHER_SET) ,"no cipher set"},
177{ERR_REASON(EVP_R_NO_DEFAULT_DIGEST) ,"no default digest"},
155{ERR_REASON(EVP_R_NO_DIGEST_SET) ,"no digest set"}, 178{ERR_REASON(EVP_R_NO_DIGEST_SET) ,"no digest set"},
156{ERR_REASON(EVP_R_NO_DSA_PARAMETERS) ,"no dsa parameters"}, 179{ERR_REASON(EVP_R_NO_DSA_PARAMETERS) ,"no dsa parameters"},
180{ERR_REASON(EVP_R_NO_KEY_SET) ,"no key set"},
181{ERR_REASON(EVP_R_NO_OPERATION_SET) ,"no operation set"},
157{ERR_REASON(EVP_R_NO_SIGN_FUNCTION_CONFIGURED),"no sign function configured"}, 182{ERR_REASON(EVP_R_NO_SIGN_FUNCTION_CONFIGURED),"no sign function configured"},
158{ERR_REASON(EVP_R_NO_VERIFY_FUNCTION_CONFIGURED),"no verify function configured"}, 183{ERR_REASON(EVP_R_NO_VERIFY_FUNCTION_CONFIGURED),"no verify function configured"},
184{ERR_REASON(EVP_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE),"operation not supported for this keytype"},
185{ERR_REASON(EVP_R_OPERATON_NOT_INITIALIZED),"operaton not initialized"},
159{ERR_REASON(EVP_R_PKCS8_UNKNOWN_BROKEN_TYPE),"pkcs8 unknown broken type"}, 186{ERR_REASON(EVP_R_PKCS8_UNKNOWN_BROKEN_TYPE),"pkcs8 unknown broken type"},
187{ERR_REASON(EVP_R_PRIVATE_KEY_DECODE_ERROR),"private key decode error"},
188{ERR_REASON(EVP_R_PRIVATE_KEY_ENCODE_ERROR),"private key encode error"},
160{ERR_REASON(EVP_R_PUBLIC_KEY_NOT_RSA) ,"public key not rsa"}, 189{ERR_REASON(EVP_R_PUBLIC_KEY_NOT_RSA) ,"public key not rsa"},
161{ERR_REASON(EVP_R_SEED_KEY_SETUP_FAILED) ,"seed key setup failed"}, 190{ERR_REASON(EVP_R_UNKNOWN_CIPHER) ,"unknown cipher"},
162{ERR_REASON(EVP_R_UNKNOWN_OPTION) ,"unknown option"}, 191{ERR_REASON(EVP_R_UNKNOWN_DIGEST) ,"unknown digest"},
163{ERR_REASON(EVP_R_UNKNOWN_PBE_ALGORITHM) ,"unknown pbe algorithm"}, 192{ERR_REASON(EVP_R_UNKNOWN_PBE_ALGORITHM) ,"unknown pbe algorithm"},
164{ERR_REASON(EVP_R_UNSUPORTED_NUMBER_OF_ROUNDS),"unsuported number of rounds"}, 193{ERR_REASON(EVP_R_UNSUPORTED_NUMBER_OF_ROUNDS),"unsuported number of rounds"},
194{ERR_REASON(EVP_R_UNSUPPORTED_ALGORITHM) ,"unsupported algorithm"},
165{ERR_REASON(EVP_R_UNSUPPORTED_CIPHER) ,"unsupported cipher"}, 195{ERR_REASON(EVP_R_UNSUPPORTED_CIPHER) ,"unsupported cipher"},
166{ERR_REASON(EVP_R_UNSUPPORTED_KEYLENGTH) ,"unsupported keylength"}, 196{ERR_REASON(EVP_R_UNSUPPORTED_KEYLENGTH) ,"unsupported keylength"},
167{ERR_REASON(EVP_R_UNSUPPORTED_KEY_DERIVATION_FUNCTION),"unsupported key derivation function"}, 197{ERR_REASON(EVP_R_UNSUPPORTED_KEY_DERIVATION_FUNCTION),"unsupported key derivation function"},
diff --git a/src/lib/libcrypto/evp/evp_key.c b/src/lib/libcrypto/evp/evp_key.c
index 361ea69ab6..839d6a3a16 100644
--- a/src/lib/libcrypto/evp/evp_key.c
+++ b/src/lib/libcrypto/evp/evp_key.c
@@ -90,6 +90,11 @@ char *EVP_get_pw_prompt(void)
90 * this function will fail */ 90 * this function will fail */
91int EVP_read_pw_string(char *buf, int len, const char *prompt, int verify) 91int EVP_read_pw_string(char *buf, int len, const char *prompt, int verify)
92 { 92 {
93 return EVP_read_pw_string_min(buf, 0, len, prompt, verify);
94 }
95
96int EVP_read_pw_string_min(char *buf, int min, int len, const char *prompt, int verify)
97 {
93 int ret; 98 int ret;
94 char buff[BUFSIZ]; 99 char buff[BUFSIZ];
95 UI *ui; 100 UI *ui;
@@ -97,10 +102,10 @@ int EVP_read_pw_string(char *buf, int len, const char *prompt, int verify)
97 if ((prompt == NULL) && (prompt_string[0] != '\0')) 102 if ((prompt == NULL) && (prompt_string[0] != '\0'))
98 prompt=prompt_string; 103 prompt=prompt_string;
99 ui = UI_new(); 104 ui = UI_new();
100 UI_add_input_string(ui,prompt,0,buf,0,(len>=BUFSIZ)?BUFSIZ-1:len); 105 UI_add_input_string(ui,prompt,0,buf,min,(len>=BUFSIZ)?BUFSIZ-1:len);
101 if (verify) 106 if (verify)
102 UI_add_verify_string(ui,prompt,0, 107 UI_add_verify_string(ui,prompt,0,
103 buff,0,(len>=BUFSIZ)?BUFSIZ-1:len,buf); 108 buff,min,(len>=BUFSIZ)?BUFSIZ-1:len,buf);
104 ret = UI_process(ui); 109 ret = UI_process(ui);
105 UI_free(ui); 110 UI_free(ui);
106 OPENSSL_cleanse(buff,BUFSIZ); 111 OPENSSL_cleanse(buff,BUFSIZ);
diff --git a/src/lib/libcrypto/evp/evp_lib.c b/src/lib/libcrypto/evp/evp_lib.c
index 174cf6c594..40951a04f0 100644
--- a/src/lib/libcrypto/evp/evp_lib.c
+++ b/src/lib/libcrypto/evp/evp_lib.c
@@ -67,8 +67,6 @@ int EVP_CIPHER_param_to_asn1(EVP_CIPHER_CTX *c, ASN1_TYPE *type)
67 67
68 if (c->cipher->set_asn1_parameters != NULL) 68 if (c->cipher->set_asn1_parameters != NULL)
69 ret=c->cipher->set_asn1_parameters(c,type); 69 ret=c->cipher->set_asn1_parameters(c,type);
70 else if (c->cipher->flags & EVP_CIPH_FLAG_DEFAULT_ASN1)
71 ret=EVP_CIPHER_set_asn1_iv(c, type);
72 else 70 else
73 ret=-1; 71 ret=-1;
74 return(ret); 72 return(ret);
@@ -80,8 +78,6 @@ int EVP_CIPHER_asn1_to_param(EVP_CIPHER_CTX *c, ASN1_TYPE *type)
80 78
81 if (c->cipher->get_asn1_parameters != NULL) 79 if (c->cipher->get_asn1_parameters != NULL)
82 ret=c->cipher->get_asn1_parameters(c,type); 80 ret=c->cipher->get_asn1_parameters(c,type);
83 else if (c->cipher->flags & EVP_CIPH_FLAG_DEFAULT_ASN1)
84 ret=EVP_CIPHER_get_asn1_iv(c, type);
85 else 81 else
86 ret=-1; 82 ret=-1;
87 return(ret); 83 return(ret);
@@ -163,6 +159,12 @@ int EVP_CIPHER_type(const EVP_CIPHER *ctx)
163 159
164 return NID_des_cfb64; 160 return NID_des_cfb64;
165 161
162 case NID_des_ede3_cfb64:
163 case NID_des_ede3_cfb8:
164 case NID_des_ede3_cfb1:
165
166 return NID_des_cfb64;
167
166 default: 168 default:
167 /* Check it has an OID and it is valid */ 169 /* Check it has an OID and it is valid */
168 otmp = OBJ_nid2obj(nid); 170 otmp = OBJ_nid2obj(nid);
@@ -182,6 +184,11 @@ int EVP_CIPHER_CTX_block_size(const EVP_CIPHER_CTX *ctx)
182 return ctx->cipher->block_size; 184 return ctx->cipher->block_size;
183 } 185 }
184 186
187int EVP_Cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, unsigned int inl)
188 {
189 return ctx->cipher->do_cipher(ctx,out,in,inl);
190 }
191
185const EVP_CIPHER *EVP_CIPHER_CTX_cipher(const EVP_CIPHER_CTX *ctx) 192const EVP_CIPHER *EVP_CIPHER_CTX_cipher(const EVP_CIPHER_CTX *ctx)
186 { 193 {
187 return ctx->cipher; 194 return ctx->cipher;
@@ -192,6 +199,11 @@ unsigned long EVP_CIPHER_flags(const EVP_CIPHER *cipher)
192 return cipher->flags; 199 return cipher->flags;
193 } 200 }
194 201
202unsigned long EVP_CIPHER_CTX_flags(const EVP_CIPHER_CTX *ctx)
203 {
204 return ctx->cipher->flags;
205 }
206
195void *EVP_CIPHER_CTX_get_app_data(const EVP_CIPHER_CTX *ctx) 207void *EVP_CIPHER_CTX_get_app_data(const EVP_CIPHER_CTX *ctx)
196 { 208 {
197 return ctx->app_data; 209 return ctx->app_data;
@@ -207,6 +219,11 @@ int EVP_CIPHER_iv_length(const EVP_CIPHER *cipher)
207 return cipher->iv_len; 219 return cipher->iv_len;
208 } 220 }
209 221
222int EVP_CIPHER_CTX_iv_length(const EVP_CIPHER_CTX *ctx)
223 {
224 return ctx->cipher->iv_len;
225 }
226
210int EVP_CIPHER_key_length(const EVP_CIPHER *cipher) 227int EVP_CIPHER_key_length(const EVP_CIPHER *cipher)
211 { 228 {
212 return cipher->key_len; 229 return cipher->key_len;
@@ -217,6 +234,11 @@ int EVP_CIPHER_CTX_key_length(const EVP_CIPHER_CTX *ctx)
217 return ctx->key_len; 234 return ctx->key_len;
218 } 235 }
219 236
237int EVP_CIPHER_nid(const EVP_CIPHER *cipher)
238 {
239 return cipher->nid;
240 }
241
220int EVP_CIPHER_CTX_nid(const EVP_CIPHER_CTX *ctx) 242int EVP_CIPHER_CTX_nid(const EVP_CIPHER_CTX *ctx)
221 { 243 {
222 return ctx->cipher->nid; 244 return ctx->cipher->nid;
@@ -239,11 +261,23 @@ int EVP_MD_pkey_type(const EVP_MD *md)
239 261
240int EVP_MD_size(const EVP_MD *md) 262int EVP_MD_size(const EVP_MD *md)
241 { 263 {
264 if (!md)
265 {
266 EVPerr(EVP_F_EVP_MD_SIZE, EVP_R_MESSAGE_DIGEST_IS_NULL);
267 return -1;
268 }
242 return md->md_size; 269 return md->md_size;
243 } 270 }
244 271
245const EVP_MD * EVP_MD_CTX_md(const EVP_MD_CTX *ctx) 272unsigned long EVP_MD_flags(const EVP_MD *md)
273 {
274 return md->flags;
275 }
276
277const EVP_MD *EVP_MD_CTX_md(const EVP_MD_CTX *ctx)
246 { 278 {
279 if (!ctx)
280 return NULL;
247 return ctx->digest; 281 return ctx->digest;
248 } 282 }
249 283
diff --git a/src/lib/libcrypto/evp/evp_locl.h b/src/lib/libcrypto/evp/evp_locl.h
index eabcc96f30..292d74c188 100644
--- a/src/lib/libcrypto/evp/evp_locl.h
+++ b/src/lib/libcrypto/evp/evp_locl.h
@@ -61,38 +61,66 @@
61/* Wrapper functions for each cipher mode */ 61/* Wrapper functions for each cipher mode */
62 62
63#define BLOCK_CIPHER_ecb_loop() \ 63#define BLOCK_CIPHER_ecb_loop() \
64 unsigned int i, bl; \ 64 size_t i, bl; \
65 bl = ctx->cipher->block_size;\ 65 bl = ctx->cipher->block_size;\
66 if(inl < bl) return 1;\ 66 if(inl < bl) return 1;\
67 inl -= bl; \ 67 inl -= bl; \
68 for(i=0; i <= inl; i+=bl) 68 for(i=0; i <= inl; i+=bl)
69 69
70#define BLOCK_CIPHER_func_ecb(cname, cprefix, kstruct, ksched) \ 70#define BLOCK_CIPHER_func_ecb(cname, cprefix, kstruct, ksched) \
71static int cname##_ecb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, unsigned int inl) \ 71static int cname##_ecb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, size_t inl) \
72{\ 72{\
73 BLOCK_CIPHER_ecb_loop() \ 73 BLOCK_CIPHER_ecb_loop() \
74 cprefix##_ecb_encrypt(in + i, out + i, &((kstruct *)ctx->cipher_data)->ksched, ctx->encrypt);\ 74 cprefix##_ecb_encrypt(in + i, out + i, &((kstruct *)ctx->cipher_data)->ksched, ctx->encrypt);\
75 return 1;\ 75 return 1;\
76} 76}
77 77
78#define EVP_MAXCHUNK ((size_t)1<<(sizeof(long)*8-2))
79
78#define BLOCK_CIPHER_func_ofb(cname, cprefix, cbits, kstruct, ksched) \ 80#define BLOCK_CIPHER_func_ofb(cname, cprefix, cbits, kstruct, ksched) \
79static int cname##_ofb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, unsigned int inl) \ 81static int cname##_ofb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, size_t inl) \
80{\ 82{\
81 cprefix##_ofb##cbits##_encrypt(in, out, (long)inl, &((kstruct *)ctx->cipher_data)->ksched, ctx->iv, &ctx->num);\ 83 while(inl>=EVP_MAXCHUNK)\
84 {\
85 cprefix##_ofb##cbits##_encrypt(in, out, (long)EVP_MAXCHUNK, &((kstruct *)ctx->cipher_data)->ksched, ctx->iv, &ctx->num);\
86 inl-=EVP_MAXCHUNK;\
87 in +=EVP_MAXCHUNK;\
88 out+=EVP_MAXCHUNK;\
89 }\
90 if (inl)\
91 cprefix##_ofb##cbits##_encrypt(in, out, (long)inl, &((kstruct *)ctx->cipher_data)->ksched, ctx->iv, &ctx->num);\
82 return 1;\ 92 return 1;\
83} 93}
84 94
85#define BLOCK_CIPHER_func_cbc(cname, cprefix, kstruct, ksched) \ 95#define BLOCK_CIPHER_func_cbc(cname, cprefix, kstruct, ksched) \
86static int cname##_cbc_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, unsigned int inl) \ 96static int cname##_cbc_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, size_t inl) \
87{\ 97{\
88 cprefix##_cbc_encrypt(in, out, (long)inl, &((kstruct *)ctx->cipher_data)->ksched, ctx->iv, ctx->encrypt);\ 98 while(inl>=EVP_MAXCHUNK) \
99 {\
100 cprefix##_cbc_encrypt(in, out, (long)EVP_MAXCHUNK, &((kstruct *)ctx->cipher_data)->ksched, ctx->iv, ctx->encrypt);\
101 inl-=EVP_MAXCHUNK;\
102 in +=EVP_MAXCHUNK;\
103 out+=EVP_MAXCHUNK;\
104 }\
105 if (inl)\
106 cprefix##_cbc_encrypt(in, out, (long)inl, &((kstruct *)ctx->cipher_data)->ksched, ctx->iv, ctx->encrypt);\
89 return 1;\ 107 return 1;\
90} 108}
91 109
92#define BLOCK_CIPHER_func_cfb(cname, cprefix, cbits, kstruct, ksched) \ 110#define BLOCK_CIPHER_func_cfb(cname, cprefix, cbits, kstruct, ksched) \
93static int cname##_cfb##cbits##_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, unsigned int inl) \ 111static int cname##_cfb##cbits##_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, size_t inl) \
94{\ 112{\
95 cprefix##_cfb##cbits##_encrypt(in, out, (long)((cbits==1) && !(ctx->flags & EVP_CIPH_FLAG_LENGTH_BITS) ?inl*8:inl), &((kstruct *)ctx->cipher_data)->ksched, ctx->iv, &ctx->num, ctx->encrypt);\ 113 size_t chunk=EVP_MAXCHUNK;\
114 if (cbits==1) chunk>>=3;\
115 if (inl<chunk) chunk=inl;\
116 while(inl && inl>=chunk)\
117 {\
118 cprefix##_cfb##cbits##_encrypt(in, out, (long)((cbits==1) && !(ctx->flags & EVP_CIPH_FLAG_LENGTH_BITS) ?inl*8:inl), &((kstruct *)ctx->cipher_data)->ksched, ctx->iv, &ctx->num, ctx->encrypt);\
119 inl-=chunk;\
120 in +=chunk;\
121 out+=chunk;\
122 if(inl<chunk) chunk=inl;\
123 }\
96 return 1;\ 124 return 1;\
97} 125}
98 126
@@ -139,10 +167,10 @@ BLOCK_CIPHER_def1(cname, ofb##cbits, ofb, OFB, kstruct, nid, 1, \
139 get_asn1, ctrl) 167 get_asn1, ctrl)
140 168
141#define BLOCK_CIPHER_def_ecb(cname, kstruct, nid, block_size, key_len, \ 169#define BLOCK_CIPHER_def_ecb(cname, kstruct, nid, block_size, key_len, \
142 iv_len, flags, init_key, cleanup, set_asn1, \ 170 flags, init_key, cleanup, set_asn1, \
143 get_asn1, ctrl) \ 171 get_asn1, ctrl) \
144BLOCK_CIPHER_def1(cname, ecb, ecb, ECB, kstruct, nid, block_size, key_len, \ 172BLOCK_CIPHER_def1(cname, ecb, ecb, ECB, kstruct, nid, block_size, key_len, \
145 iv_len, flags, init_key, cleanup, set_asn1, get_asn1, ctrl) 173 0, flags, init_key, cleanup, set_asn1, get_asn1, ctrl)
146 174
147#define BLOCK_CIPHER_defs(cname, kstruct, \ 175#define BLOCK_CIPHER_defs(cname, kstruct, \
148 nid, block_size, key_len, iv_len, cbits, flags, \ 176 nid, block_size, key_len, iv_len, cbits, flags, \
@@ -153,7 +181,7 @@ BLOCK_CIPHER_def_cfb(cname, kstruct, nid, key_len, iv_len, cbits, \
153 flags, init_key, cleanup, set_asn1, get_asn1, ctrl) \ 181 flags, init_key, cleanup, set_asn1, get_asn1, ctrl) \
154BLOCK_CIPHER_def_ofb(cname, kstruct, nid, key_len, iv_len, cbits, \ 182BLOCK_CIPHER_def_ofb(cname, kstruct, nid, key_len, iv_len, cbits, \
155 flags, init_key, cleanup, set_asn1, get_asn1, ctrl) \ 183 flags, init_key, cleanup, set_asn1, get_asn1, ctrl) \
156BLOCK_CIPHER_def_ecb(cname, kstruct, nid, block_size, key_len, iv_len, flags, \ 184BLOCK_CIPHER_def_ecb(cname, kstruct, nid, block_size, key_len, flags, \
157 init_key, cleanup, set_asn1, get_asn1, ctrl) 185 init_key, cleanup, set_asn1, get_asn1, ctrl)
158 186
159 187
@@ -226,27 +254,92 @@ const EVP_CIPHER *EVP_##cname##_ecb(void) { return &cname##_ecb; }
226 254
227#define EVP_C_DATA(kstruct, ctx) ((kstruct *)(ctx)->cipher_data) 255#define EVP_C_DATA(kstruct, ctx) ((kstruct *)(ctx)->cipher_data)
228 256
229#define IMPLEMENT_CFBR(cipher,cprefix,kstruct,ksched,keysize,cbits,iv_len,fl) \ 257#define IMPLEMENT_CFBR(cipher,cprefix,kstruct,ksched,keysize,cbits,iv_len) \
230 BLOCK_CIPHER_func_cfb(cipher##_##keysize,cprefix,cbits,kstruct,ksched) \ 258 BLOCK_CIPHER_func_cfb(cipher##_##keysize,cprefix,cbits,kstruct,ksched) \
231 BLOCK_CIPHER_def_cfb(cipher##_##keysize,kstruct, \ 259 BLOCK_CIPHER_def_cfb(cipher##_##keysize,kstruct, \
232 NID_##cipher##_##keysize, keysize/8, iv_len, cbits, \ 260 NID_##cipher##_##keysize, keysize/8, iv_len, cbits, \
233 (fl)|EVP_CIPH_FLAG_DEFAULT_ASN1, \ 261 0, cipher##_init_key, NULL, \
234 cipher##_init_key, NULL, NULL, NULL, NULL) 262 EVP_CIPHER_set_asn1_iv, \
235 263 EVP_CIPHER_get_asn1_iv, \
236#ifdef OPENSSL_FIPS 264 NULL)
237#define RC2_set_key private_RC2_set_key 265
238#define RC4_set_key private_RC4_set_key 266struct evp_pkey_ctx_st
239#define CAST_set_key private_CAST_set_key 267 {
240#define RC5_32_set_key private_RC5_32_set_key 268 /* Method associated with this operation */
241#define BF_set_key private_BF_set_key 269 const EVP_PKEY_METHOD *pmeth;
242#define Camellia_set_key private_Camellia_set_key 270 /* Engine that implements this method or NULL if builtin */
243#define idea_set_encrypt_key private_idea_set_encrypt_key 271 ENGINE *engine;
244 272 /* Key: may be NULL */
245#define MD5_Init private_MD5_Init 273 EVP_PKEY *pkey;
246#define MD4_Init private_MD4_Init 274 /* Peer key for key agreement, may be NULL */
247#define MD2_Init private_MD2_Init 275 EVP_PKEY *peerkey;
248#define MDC2_Init private_MDC2_Init 276 /* Actual operation */
249#define SHA_Init private_SHA_Init 277 int operation;
250 278 /* Algorithm specific data */
251#endif 279 void *data;
280 /* Application specific data */
281 void *app_data;
282 /* Keygen callback */
283 EVP_PKEY_gen_cb *pkey_gencb;
284 /* implementation specific keygen data */
285 int *keygen_info;
286 int keygen_info_count;
287 } /* EVP_PKEY_CTX */;
288
289#define EVP_PKEY_FLAG_DYNAMIC 1
290
291struct evp_pkey_method_st
292 {
293 int pkey_id;
294 int flags;
295
296 int (*init)(EVP_PKEY_CTX *ctx);
297 int (*copy)(EVP_PKEY_CTX *dst, EVP_PKEY_CTX *src);
298 void (*cleanup)(EVP_PKEY_CTX *ctx);
299
300 int (*paramgen_init)(EVP_PKEY_CTX *ctx);
301 int (*paramgen)(EVP_PKEY_CTX *ctx, EVP_PKEY *pkey);
302
303 int (*keygen_init)(EVP_PKEY_CTX *ctx);
304 int (*keygen)(EVP_PKEY_CTX *ctx, EVP_PKEY *pkey);
305
306 int (*sign_init)(EVP_PKEY_CTX *ctx);
307 int (*sign)(EVP_PKEY_CTX *ctx, unsigned char *sig, size_t *siglen,
308 const unsigned char *tbs, size_t tbslen);
309
310 int (*verify_init)(EVP_PKEY_CTX *ctx);
311 int (*verify)(EVP_PKEY_CTX *ctx,
312 const unsigned char *sig, size_t siglen,
313 const unsigned char *tbs, size_t tbslen);
314
315 int (*verify_recover_init)(EVP_PKEY_CTX *ctx);
316 int (*verify_recover)(EVP_PKEY_CTX *ctx,
317 unsigned char *rout, size_t *routlen,
318 const unsigned char *sig, size_t siglen);
319
320 int (*signctx_init)(EVP_PKEY_CTX *ctx, EVP_MD_CTX *mctx);
321 int (*signctx)(EVP_PKEY_CTX *ctx, unsigned char *sig, size_t *siglen,
322 EVP_MD_CTX *mctx);
323
324 int (*verifyctx_init)(EVP_PKEY_CTX *ctx, EVP_MD_CTX *mctx);
325 int (*verifyctx)(EVP_PKEY_CTX *ctx, const unsigned char *sig,int siglen,
326 EVP_MD_CTX *mctx);
327
328 int (*encrypt_init)(EVP_PKEY_CTX *ctx);
329 int (*encrypt)(EVP_PKEY_CTX *ctx, unsigned char *out, size_t *outlen,
330 const unsigned char *in, size_t inlen);
331
332 int (*decrypt_init)(EVP_PKEY_CTX *ctx);
333 int (*decrypt)(EVP_PKEY_CTX *ctx, unsigned char *out, size_t *outlen,
334 const unsigned char *in, size_t inlen);
335
336 int (*derive_init)(EVP_PKEY_CTX *ctx);
337 int (*derive)(EVP_PKEY_CTX *ctx, unsigned char *key, size_t *keylen);
338
339 int (*ctrl)(EVP_PKEY_CTX *ctx, int type, int p1, void *p2);
340 int (*ctrl_str)(EVP_PKEY_CTX *ctx, const char *type, const char *value);
341
342
343 } /* EVP_PKEY_METHOD */;
252 344
345void evp_pkey_set_cb_translate(BN_GENCB *cb, EVP_PKEY_CTX *ctx);
diff --git a/src/lib/libcrypto/evp/evp_pbe.c b/src/lib/libcrypto/evp/evp_pbe.c
index 5e830be65f..c9d932d205 100644
--- a/src/lib/libcrypto/evp/evp_pbe.c
+++ b/src/lib/libcrypto/evp/evp_pbe.c
@@ -3,7 +3,7 @@
3 * project 1999. 3 * project 1999.
4 */ 4 */
5/* ==================================================================== 5/* ====================================================================
6 * Copyright (c) 1999 The OpenSSL Project. All rights reserved. 6 * Copyright (c) 1999-2006 The OpenSSL Project. All rights reserved.
7 * 7 *
8 * Redistribution and use in source and binary forms, with or without 8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions 9 * modification, are permitted provided that the following conditions
@@ -59,79 +59,253 @@
59#include <stdio.h> 59#include <stdio.h>
60#include "cryptlib.h" 60#include "cryptlib.h"
61#include <openssl/evp.h> 61#include <openssl/evp.h>
62#include <openssl/pkcs12.h>
62#include <openssl/x509.h> 63#include <openssl/x509.h>
63 64
64/* Password based encryption (PBE) functions */ 65/* Password based encryption (PBE) functions */
65 66
66static STACK *pbe_algs; 67DECLARE_STACK_OF(EVP_PBE_CTL)
68static STACK_OF(EVP_PBE_CTL) *pbe_algs;
67 69
68/* Setup a cipher context from a PBE algorithm */ 70/* Setup a cipher context from a PBE algorithm */
69 71
70typedef struct { 72typedef struct
71int pbe_nid; 73 {
72const EVP_CIPHER *cipher; 74 int pbe_type;
73const EVP_MD *md; 75 int pbe_nid;
74EVP_PBE_KEYGEN *keygen; 76 int cipher_nid;
75} EVP_PBE_CTL; 77 int md_nid;
78 EVP_PBE_KEYGEN *keygen;
79 } EVP_PBE_CTL;
76 80
77int EVP_PBE_CipherInit(ASN1_OBJECT *pbe_obj, const char *pass, int passlen, 81static const EVP_PBE_CTL builtin_pbe[] =
78 ASN1_TYPE *param, EVP_CIPHER_CTX *ctx, int en_de) 82 {
79{ 83 {EVP_PBE_TYPE_OUTER, NID_pbeWithMD2AndDES_CBC,
84 NID_des_cbc, NID_md2, PKCS5_PBE_keyivgen},
85 {EVP_PBE_TYPE_OUTER, NID_pbeWithMD5AndDES_CBC,
86 NID_des_cbc, NID_md5, PKCS5_PBE_keyivgen},
87 {EVP_PBE_TYPE_OUTER, NID_pbeWithSHA1AndRC2_CBC,
88 NID_rc2_64_cbc, NID_sha1, PKCS5_PBE_keyivgen},
80 89
81 EVP_PBE_CTL *pbetmp, pbelu; 90 {EVP_PBE_TYPE_OUTER, NID_pbe_WithSHA1And128BitRC4,
82 int i; 91 NID_rc4, NID_sha1, PKCS12_PBE_keyivgen},
83 pbelu.pbe_nid = OBJ_obj2nid(pbe_obj); 92 {EVP_PBE_TYPE_OUTER, NID_pbe_WithSHA1And40BitRC4,
84 if (pbelu.pbe_nid != NID_undef) i = sk_find(pbe_algs, (char *)&pbelu); 93 NID_rc4_40, NID_sha1, PKCS12_PBE_keyivgen},
85 else i = -1; 94 {EVP_PBE_TYPE_OUTER, NID_pbe_WithSHA1And3_Key_TripleDES_CBC,
95 NID_des_ede3_cbc, NID_sha1, PKCS12_PBE_keyivgen},
96 {EVP_PBE_TYPE_OUTER, NID_pbe_WithSHA1And2_Key_TripleDES_CBC,
97 NID_des_ede_cbc, NID_sha1, PKCS12_PBE_keyivgen},
98 {EVP_PBE_TYPE_OUTER, NID_pbe_WithSHA1And128BitRC2_CBC,
99 NID_rc2_cbc, NID_sha1, PKCS12_PBE_keyivgen},
100 {EVP_PBE_TYPE_OUTER, NID_pbe_WithSHA1And40BitRC2_CBC,
101 NID_rc2_40_cbc, NID_sha1, PKCS12_PBE_keyivgen},
102
103#ifndef OPENSSL_NO_HMAC
104 {EVP_PBE_TYPE_OUTER, NID_pbes2, -1, -1, PKCS5_v2_PBE_keyivgen},
105#endif
106 {EVP_PBE_TYPE_OUTER, NID_pbeWithMD2AndRC2_CBC,
107 NID_rc2_64_cbc, NID_md2, PKCS5_PBE_keyivgen},
108 {EVP_PBE_TYPE_OUTER, NID_pbeWithMD5AndRC2_CBC,
109 NID_rc2_64_cbc, NID_md5, PKCS5_PBE_keyivgen},
110 {EVP_PBE_TYPE_OUTER, NID_pbeWithSHA1AndDES_CBC,
111 NID_des_cbc, NID_sha1, PKCS5_PBE_keyivgen},
112
113
114 {EVP_PBE_TYPE_PRF, NID_hmacWithSHA1, -1, NID_sha1, 0},
115 {EVP_PBE_TYPE_PRF, NID_hmacWithMD5, -1, NID_md5, 0},
116 {EVP_PBE_TYPE_PRF, NID_hmacWithSHA224, -1, NID_sha224, 0},
117 {EVP_PBE_TYPE_PRF, NID_hmacWithSHA256, -1, NID_sha256, 0},
118 {EVP_PBE_TYPE_PRF, NID_hmacWithSHA384, -1, NID_sha384, 0},
119 {EVP_PBE_TYPE_PRF, NID_hmacWithSHA512, -1, NID_sha512, 0},
120 {EVP_PBE_TYPE_PRF, NID_id_HMACGostR3411_94, -1, NID_id_GostR3411_94, 0},
121 };
122
123#ifdef TEST
124int main(int argc, char **argv)
125 {
126 int i, nid_md, nid_cipher;
127 EVP_PBE_CTL *tpbe, *tpbe2;
128 /*OpenSSL_add_all_algorithms();*/
129
130 for (i = 0; i < sizeof(builtin_pbe)/sizeof(EVP_PBE_CTL); i++)
131 {
132 tpbe = builtin_pbe + i;
133 fprintf(stderr, "%d %d %s ", tpbe->pbe_type, tpbe->pbe_nid,
134 OBJ_nid2sn(tpbe->pbe_nid));
135 if (EVP_PBE_find(tpbe->pbe_type, tpbe->pbe_nid,
136 &nid_cipher ,&nid_md,0))
137 fprintf(stderr, "Found %s %s\n",
138 OBJ_nid2sn(nid_cipher),
139 OBJ_nid2sn(nid_md));
140 else
141 fprintf(stderr, "Find ERROR!!\n");
142 }
143
144 return 0;
145 }
146#endif
147
148
149
150int EVP_PBE_CipherInit(ASN1_OBJECT *pbe_obj, const char *pass, int passlen,
151 ASN1_TYPE *param, EVP_CIPHER_CTX *ctx, int en_de)
152 {
153 const EVP_CIPHER *cipher;
154 const EVP_MD *md;
155 int cipher_nid, md_nid;
156 EVP_PBE_KEYGEN *keygen;
86 157
87 if (i == -1) { 158 if (!EVP_PBE_find(EVP_PBE_TYPE_OUTER, OBJ_obj2nid(pbe_obj),
159 &cipher_nid, &md_nid, &keygen))
160 {
88 char obj_tmp[80]; 161 char obj_tmp[80];
89 EVPerr(EVP_F_EVP_PBE_CIPHERINIT,EVP_R_UNKNOWN_PBE_ALGORITHM); 162 EVPerr(EVP_F_EVP_PBE_CIPHERINIT,EVP_R_UNKNOWN_PBE_ALGORITHM);
90 if (!pbe_obj) BUF_strlcpy (obj_tmp, "NULL", sizeof obj_tmp); 163 if (!pbe_obj) BUF_strlcpy (obj_tmp, "NULL", sizeof obj_tmp);
91 else i2t_ASN1_OBJECT(obj_tmp, sizeof obj_tmp, pbe_obj); 164 else i2t_ASN1_OBJECT(obj_tmp, sizeof obj_tmp, pbe_obj);
92 ERR_add_error_data(2, "TYPE=", obj_tmp); 165 ERR_add_error_data(2, "TYPE=", obj_tmp);
93 return 0; 166 return 0;
94 } 167 }
95 if(!pass) passlen = 0; 168
96 else if (passlen == -1) passlen = strlen(pass); 169 if(!pass)
97 pbetmp = (EVP_PBE_CTL *)sk_value (pbe_algs, i); 170 passlen = 0;
98 i = (*pbetmp->keygen)(ctx, pass, passlen, param, pbetmp->cipher, 171 else if (passlen == -1)
99 pbetmp->md, en_de); 172 passlen = strlen(pass);
100 if (!i) { 173
174 if (cipher_nid == -1)
175 cipher = NULL;
176 else
177 {
178 cipher = EVP_get_cipherbynid(cipher_nid);
179 if (!cipher)
180 {
181 EVPerr(EVP_F_EVP_PBE_CIPHERINIT,EVP_R_UNKNOWN_CIPHER);
182 return 0;
183 }
184 }
185
186 if (md_nid == -1)
187 md = NULL;
188 else
189 {
190 md = EVP_get_digestbynid(md_nid);
191 if (!md)
192 {
193 EVPerr(EVP_F_EVP_PBE_CIPHERINIT,EVP_R_UNKNOWN_DIGEST);
194 return 0;
195 }
196 }
197
198 if (!keygen(ctx, pass, passlen, param, cipher, md, en_de))
199 {
101 EVPerr(EVP_F_EVP_PBE_CIPHERINIT,EVP_R_KEYGEN_FAILURE); 200 EVPerr(EVP_F_EVP_PBE_CIPHERINIT,EVP_R_KEYGEN_FAILURE);
102 return 0; 201 return 0;
103 } 202 }
104 return 1; 203 return 1;
105} 204}
106 205
107static int pbe_cmp(const char * const *a, const char * const *b) 206DECLARE_OBJ_BSEARCH_CMP_FN(EVP_PBE_CTL, EVP_PBE_CTL, pbe2);
108{ 207
109 const EVP_PBE_CTL * const *pbe1 = (const EVP_PBE_CTL * const *) a, 208static int pbe2_cmp(const EVP_PBE_CTL *pbe1, const EVP_PBE_CTL *pbe2)
110 * const *pbe2 = (const EVP_PBE_CTL * const *)b; 209 {
111 return ((*pbe1)->pbe_nid - (*pbe2)->pbe_nid); 210 int ret = pbe1->pbe_type - pbe2->pbe_type;
112} 211 if (ret)
212 return ret;
213 else
214 return pbe1->pbe_nid - pbe2->pbe_nid;
215 }
216
217IMPLEMENT_OBJ_BSEARCH_CMP_FN(EVP_PBE_CTL, EVP_PBE_CTL, pbe2);
218
219static int pbe_cmp(const EVP_PBE_CTL * const *a, const EVP_PBE_CTL * const *b)
220 {
221 int ret = (*a)->pbe_type - (*b)->pbe_type;
222 if (ret)
223 return ret;
224 else
225 return (*a)->pbe_nid - (*b)->pbe_nid;
226 }
113 227
114/* Add a PBE algorithm */ 228/* Add a PBE algorithm */
115 229
116int EVP_PBE_alg_add(int nid, const EVP_CIPHER *cipher, const EVP_MD *md, 230int EVP_PBE_alg_add_type(int pbe_type, int pbe_nid, int cipher_nid, int md_nid,
117 EVP_PBE_KEYGEN *keygen) 231 EVP_PBE_KEYGEN *keygen)
118{ 232 {
119 EVP_PBE_CTL *pbe_tmp; 233 EVP_PBE_CTL *pbe_tmp;
120 if (!pbe_algs) pbe_algs = sk_new(pbe_cmp); 234 if (!pbe_algs)
121 if (!(pbe_tmp = (EVP_PBE_CTL*) OPENSSL_malloc (sizeof(EVP_PBE_CTL)))) { 235 pbe_algs = sk_EVP_PBE_CTL_new(pbe_cmp);
122 EVPerr(EVP_F_EVP_PBE_ALG_ADD,ERR_R_MALLOC_FAILURE); 236 if (!(pbe_tmp = (EVP_PBE_CTL*) OPENSSL_malloc (sizeof(EVP_PBE_CTL))))
237 {
238 EVPerr(EVP_F_EVP_PBE_ALG_ADD_TYPE,ERR_R_MALLOC_FAILURE);
123 return 0; 239 return 0;
124 } 240 }
125 pbe_tmp->pbe_nid = nid; 241 pbe_tmp->pbe_type = pbe_type;
126 pbe_tmp->cipher = cipher; 242 pbe_tmp->pbe_nid = pbe_nid;
127 pbe_tmp->md = md; 243 pbe_tmp->cipher_nid = cipher_nid;
244 pbe_tmp->md_nid = md_nid;
128 pbe_tmp->keygen = keygen; 245 pbe_tmp->keygen = keygen;
129 sk_push (pbe_algs, (char *)pbe_tmp); 246
247
248 sk_EVP_PBE_CTL_push (pbe_algs, pbe_tmp);
130 return 1; 249 return 1;
131} 250 }
251
252int EVP_PBE_alg_add(int nid, const EVP_CIPHER *cipher, const EVP_MD *md,
253 EVP_PBE_KEYGEN *keygen)
254 {
255 int cipher_nid, md_nid;
256 if (cipher)
257 cipher_nid = EVP_CIPHER_type(cipher);
258 else
259 cipher_nid = -1;
260 if (md)
261 md_nid = EVP_MD_type(md);
262 else
263 md_nid = -1;
264
265 return EVP_PBE_alg_add_type(EVP_PBE_TYPE_OUTER, nid,
266 cipher_nid, md_nid, keygen);
267 }
268
269int EVP_PBE_find(int type, int pbe_nid,
270 int *pcnid, int *pmnid, EVP_PBE_KEYGEN **pkeygen)
271 {
272 EVP_PBE_CTL *pbetmp = NULL, pbelu;
273 int i;
274 if (pbe_nid == NID_undef)
275 return 0;
276
277 pbelu.pbe_type = type;
278 pbelu.pbe_nid = pbe_nid;
279
280 if (pbe_algs)
281 {
282 i = sk_EVP_PBE_CTL_find(pbe_algs, &pbelu);
283 if (i != -1)
284 pbetmp = sk_EVP_PBE_CTL_value (pbe_algs, i);
285 }
286 if (pbetmp == NULL)
287 {
288 pbetmp = OBJ_bsearch_pbe2(&pbelu, builtin_pbe,
289 sizeof(builtin_pbe)/sizeof(EVP_PBE_CTL));
290 }
291 if (pbetmp == NULL)
292 return 0;
293 if (pcnid)
294 *pcnid = pbetmp->cipher_nid;
295 if (pmnid)
296 *pmnid = pbetmp->md_nid;
297 if (pkeygen)
298 *pkeygen = pbetmp->keygen;
299 return 1;
300 }
301
302static void free_evp_pbe_ctl(EVP_PBE_CTL *pbe)
303 {
304 OPENSSL_freeFunc(pbe);
305 }
132 306
133void EVP_PBE_cleanup(void) 307void EVP_PBE_cleanup(void)
134{ 308 {
135 sk_pop_free(pbe_algs, OPENSSL_freeFunc); 309 sk_EVP_PBE_CTL_pop_free(pbe_algs, free_evp_pbe_ctl);
136 pbe_algs = NULL; 310 pbe_algs = NULL;
137} 311 }
diff --git a/src/lib/libcrypto/evp/evp_pkey.c b/src/lib/libcrypto/evp/evp_pkey.c
index 10d9e9e772..ceebf69284 100644
--- a/src/lib/libcrypto/evp/evp_pkey.c
+++ b/src/lib/libcrypto/evp/evp_pkey.c
@@ -3,7 +3,7 @@
3 * project 1999. 3 * project 1999.
4 */ 4 */
5/* ==================================================================== 5/* ====================================================================
6 * Copyright (c) 1999-2002 The OpenSSL Project. All rights reserved. 6 * Copyright (c) 1999-2005 The OpenSSL Project. All rights reserved.
7 * 7 *
8 * Redistribution and use in source and binary forms, with or without 8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions 9 * modification, are permitted provided that the following conditions
@@ -61,287 +61,52 @@
61#include "cryptlib.h" 61#include "cryptlib.h"
62#include <openssl/x509.h> 62#include <openssl/x509.h>
63#include <openssl/rand.h> 63#include <openssl/rand.h>
64#ifndef OPENSSL_NO_RSA 64#include "asn1_locl.h"
65#include <openssl/rsa.h>
66#endif
67#ifndef OPENSSL_NO_DSA
68#include <openssl/dsa.h>
69#endif
70#include <openssl/bn.h>
71
72#ifndef OPENSSL_NO_DSA
73static int dsa_pkey2pkcs8(PKCS8_PRIV_KEY_INFO *p8inf, EVP_PKEY *pkey);
74#endif
75#ifndef OPENSSL_NO_EC
76static int eckey_pkey2pkcs8(PKCS8_PRIV_KEY_INFO *p8inf, EVP_PKEY *pkey);
77#endif
78 65
79/* Extract a private key from a PKCS8 structure */ 66/* Extract a private key from a PKCS8 structure */
80 67
81EVP_PKEY *EVP_PKCS82PKEY(PKCS8_PRIV_KEY_INFO *p8) 68EVP_PKEY *EVP_PKCS82PKEY(PKCS8_PRIV_KEY_INFO *p8)
82{ 69{
83 EVP_PKEY *pkey = NULL; 70 EVP_PKEY *pkey = NULL;
84#ifndef OPENSSL_NO_RSA 71 ASN1_OBJECT *algoid;
85 RSA *rsa = NULL;
86#endif
87#ifndef OPENSSL_NO_DSA
88 DSA *dsa = NULL;
89 ASN1_TYPE *t1, *t2;
90 ASN1_INTEGER *privkey;
91 STACK_OF(ASN1_TYPE) *ndsa = NULL;
92#endif
93#ifndef OPENSSL_NO_EC
94 EC_KEY *eckey = NULL;
95 const unsigned char *p_tmp;
96#endif
97#if !defined(OPENSSL_NO_DSA) || !defined(OPENSSL_NO_EC)
98 ASN1_TYPE *param = NULL;
99 BN_CTX *ctx = NULL;
100 int plen;
101#endif
102 X509_ALGOR *a;
103 const unsigned char *p;
104 const unsigned char *cp;
105 int pkeylen;
106 int nid;
107 char obj_tmp[80]; 72 char obj_tmp[80];
108 73
109 if(p8->pkey->type == V_ASN1_OCTET_STRING) { 74 if (!PKCS8_pkey_get0(&algoid, NULL, NULL, NULL, p8))
110 p8->broken = PKCS8_OK; 75 return NULL;
111 p = p8->pkey->value.octet_string->data; 76
112 pkeylen = p8->pkey->value.octet_string->length;
113 } else {
114 p8->broken = PKCS8_NO_OCTET;
115 p = p8->pkey->value.sequence->data;
116 pkeylen = p8->pkey->value.sequence->length;
117 }
118 if (!(pkey = EVP_PKEY_new())) { 77 if (!(pkey = EVP_PKEY_new())) {
119 EVPerr(EVP_F_EVP_PKCS82PKEY,ERR_R_MALLOC_FAILURE); 78 EVPerr(EVP_F_EVP_PKCS82PKEY,ERR_R_MALLOC_FAILURE);
120 return NULL; 79 return NULL;
121 } 80 }
122 a = p8->pkeyalg;
123 nid = OBJ_obj2nid(a->algorithm);
124 switch(nid)
125 {
126#ifndef OPENSSL_NO_RSA
127 case NID_rsaEncryption:
128 cp = p;
129 if (!(rsa = d2i_RSAPrivateKey (NULL,&cp, pkeylen))) {
130 EVPerr(EVP_F_EVP_PKCS82PKEY, EVP_R_DECODE_ERROR);
131 return NULL;
132 }
133 EVP_PKEY_assign_RSA (pkey, rsa);
134 break;
135#endif
136#ifndef OPENSSL_NO_DSA
137 case NID_dsa:
138 /* PKCS#8 DSA is weird: you just get a private key integer
139 * and parameters in the AlgorithmIdentifier the pubkey must
140 * be recalculated.
141 */
142
143 /* Check for broken DSA PKCS#8, UGH! */
144 if(*p == (V_ASN1_SEQUENCE|V_ASN1_CONSTRUCTED)) {
145 if(!(ndsa = ASN1_seq_unpack_ASN1_TYPE(p, pkeylen,
146 d2i_ASN1_TYPE,
147 ASN1_TYPE_free))) {
148 EVPerr(EVP_F_EVP_PKCS82PKEY, EVP_R_DECODE_ERROR);
149 goto dsaerr;
150 }
151 if(sk_ASN1_TYPE_num(ndsa) != 2 ) {
152 EVPerr(EVP_F_EVP_PKCS82PKEY, EVP_R_DECODE_ERROR);
153 goto dsaerr;
154 }
155 /* Handle Two broken types:
156 * SEQUENCE {parameters, priv_key}
157 * SEQUENCE {pub_key, priv_key}
158 */
159
160 t1 = sk_ASN1_TYPE_value(ndsa, 0);
161 t2 = sk_ASN1_TYPE_value(ndsa, 1);
162 if(t1->type == V_ASN1_SEQUENCE) {
163 p8->broken = PKCS8_EMBEDDED_PARAM;
164 param = t1;
165 } else if(a->parameter->type == V_ASN1_SEQUENCE) {
166 p8->broken = PKCS8_NS_DB;
167 param = a->parameter;
168 } else {
169 EVPerr(EVP_F_EVP_PKCS82PKEY, EVP_R_DECODE_ERROR);
170 goto dsaerr;
171 }
172
173 if(t2->type != V_ASN1_INTEGER) {
174 EVPerr(EVP_F_EVP_PKCS82PKEY, EVP_R_DECODE_ERROR);
175 goto dsaerr;
176 }
177 privkey = t2->value.integer;
178 } else {
179 if (!(privkey=d2i_ASN1_INTEGER (NULL, &p, pkeylen))) {
180 EVPerr(EVP_F_EVP_PKCS82PKEY, EVP_R_DECODE_ERROR);
181 goto dsaerr;
182 }
183 param = p8->pkeyalg->parameter;
184 }
185 if (!param || (param->type != V_ASN1_SEQUENCE)) {
186 EVPerr(EVP_F_EVP_PKCS82PKEY, EVP_R_DECODE_ERROR);
187 goto dsaerr;
188 }
189 cp = p = param->value.sequence->data;
190 plen = param->value.sequence->length;
191 if (!(dsa = d2i_DSAparams (NULL, &cp, plen))) {
192 EVPerr(EVP_F_EVP_PKCS82PKEY, EVP_R_DECODE_ERROR);
193 goto dsaerr;
194 }
195 /* We have parameters now set private key */
196 if (!(dsa->priv_key = ASN1_INTEGER_to_BN(privkey, NULL))) {
197 EVPerr(EVP_F_EVP_PKCS82PKEY,EVP_R_BN_DECODE_ERROR);
198 goto dsaerr;
199 }
200 /* Calculate public key (ouch!) */
201 if (!(dsa->pub_key = BN_new())) {
202 EVPerr(EVP_F_EVP_PKCS82PKEY,ERR_R_MALLOC_FAILURE);
203 goto dsaerr;
204 }
205 if (!(ctx = BN_CTX_new())) {
206 EVPerr(EVP_F_EVP_PKCS82PKEY,ERR_R_MALLOC_FAILURE);
207 goto dsaerr;
208 }
209
210 if (!BN_mod_exp(dsa->pub_key, dsa->g,
211 dsa->priv_key, dsa->p, ctx)) {
212
213 EVPerr(EVP_F_EVP_PKCS82PKEY,EVP_R_BN_PUBKEY_ERROR);
214 goto dsaerr;
215 }
216 81
217 EVP_PKEY_assign_DSA(pkey, dsa); 82 if (!EVP_PKEY_set_type(pkey, OBJ_obj2nid(algoid)))
218 BN_CTX_free (ctx);
219 if(ndsa) sk_ASN1_TYPE_pop_free(ndsa, ASN1_TYPE_free);
220 else ASN1_INTEGER_free(privkey);
221 break;
222 dsaerr:
223 BN_CTX_free (ctx);
224 sk_ASN1_TYPE_pop_free(ndsa, ASN1_TYPE_free);
225 DSA_free(dsa);
226 EVP_PKEY_free(pkey);
227 return NULL;
228 break;
229#endif
230#ifndef OPENSSL_NO_EC
231 case NID_X9_62_id_ecPublicKey:
232 p_tmp = p;
233 /* extract the ec parameters */
234 param = p8->pkeyalg->parameter;
235
236 if (!param || ((param->type != V_ASN1_SEQUENCE) &&
237 (param->type != V_ASN1_OBJECT)))
238 { 83 {
239 EVPerr(EVP_F_EVP_PKCS82PKEY, EVP_R_DECODE_ERROR); 84 EVPerr(EVP_F_EVP_PKCS82PKEY, EVP_R_UNSUPPORTED_PRIVATE_KEY_ALGORITHM);
240 goto ecerr; 85 i2t_ASN1_OBJECT(obj_tmp, 80, algoid);
86 ERR_add_error_data(2, "TYPE=", obj_tmp);
87 goto error;
241 } 88 }
242 89
243 if (param->type == V_ASN1_SEQUENCE) 90 if (pkey->ameth->priv_decode)
244 { 91 {
245 cp = p = param->value.sequence->data; 92 if (!pkey->ameth->priv_decode(pkey, p8))
246 plen = param->value.sequence->length;
247
248 if (!(eckey = d2i_ECParameters(NULL, &cp, plen)))
249 { 93 {
250 EVPerr(EVP_F_EVP_PKCS82PKEY, 94 EVPerr(EVP_F_EVP_PKCS82PKEY,
251 EVP_R_DECODE_ERROR); 95 EVP_R_PRIVATE_KEY_DECODE_ERROR);
252 goto ecerr; 96 goto error;
253 } 97 }
254 } 98 }
255 else 99 else
256 { 100 {
257 EC_GROUP *group; 101 EVPerr(EVP_F_EVP_PKCS82PKEY, EVP_R_METHOD_NOT_SUPPORTED);
258 cp = p = param->value.object->data; 102 goto error;
259 plen = param->value.object->length;
260
261 /* type == V_ASN1_OBJECT => the parameters are given
262 * by an asn1 OID
263 */
264 if ((eckey = EC_KEY_new()) == NULL)
265 {
266 EVPerr(EVP_F_EVP_PKCS82PKEY,
267 ERR_R_MALLOC_FAILURE);
268 goto ecerr;
269 }
270 group = EC_GROUP_new_by_curve_name(OBJ_obj2nid(a->parameter->value.object));
271 if (group == NULL)
272 goto ecerr;
273 EC_GROUP_set_asn1_flag(group, OPENSSL_EC_NAMED_CURVE);
274 if (EC_KEY_set_group(eckey, group) == 0)
275 goto ecerr;
276 EC_GROUP_free(group);
277 }
278
279 /* We have parameters now set private key */
280 if (!d2i_ECPrivateKey(&eckey, &p_tmp, pkeylen))
281 {
282 EVPerr(EVP_F_EVP_PKCS82PKEY, EVP_R_DECODE_ERROR);
283 goto ecerr;
284 }
285
286 /* calculate public key (if necessary) */
287 if (EC_KEY_get0_public_key(eckey) == NULL)
288 {
289 const BIGNUM *priv_key;
290 const EC_GROUP *group;
291 EC_POINT *pub_key;
292 /* the public key was not included in the SEC1 private
293 * key => calculate the public key */
294 group = EC_KEY_get0_group(eckey);
295 pub_key = EC_POINT_new(group);
296 if (pub_key == NULL)
297 {
298 EVPerr(EVP_F_EVP_PKCS82PKEY, ERR_R_EC_LIB);
299 goto ecerr;
300 }
301 if (!EC_POINT_copy(pub_key, EC_GROUP_get0_generator(group)))
302 {
303 EC_POINT_free(pub_key);
304 EVPerr(EVP_F_EVP_PKCS82PKEY, ERR_R_EC_LIB);
305 goto ecerr;
306 }
307 priv_key = EC_KEY_get0_private_key(eckey);
308 if (!EC_POINT_mul(group, pub_key, priv_key, NULL, NULL, ctx))
309 {
310 EC_POINT_free(pub_key);
311 EVPerr(EVP_F_EVP_PKCS82PKEY, ERR_R_EC_LIB);
312 goto ecerr;
313 }
314 if (EC_KEY_set_public_key(eckey, pub_key) == 0)
315 {
316 EC_POINT_free(pub_key);
317 EVPerr(EVP_F_EVP_PKCS82PKEY, ERR_R_EC_LIB);
318 goto ecerr;
319 }
320 EC_POINT_free(pub_key);
321 } 103 }
322 104
323 EVP_PKEY_assign_EC_KEY(pkey, eckey);
324 if (ctx)
325 BN_CTX_free(ctx);
326 break;
327ecerr:
328 if (ctx)
329 BN_CTX_free(ctx);
330 if (eckey)
331 EC_KEY_free(eckey);
332 if (pkey)
333 EVP_PKEY_free(pkey);
334 return NULL;
335#endif
336 default:
337 EVPerr(EVP_F_EVP_PKCS82PKEY, EVP_R_UNSUPPORTED_PRIVATE_KEY_ALGORITHM);
338 if (!a->algorithm) BUF_strlcpy (obj_tmp, "NULL", sizeof obj_tmp);
339 else i2t_ASN1_OBJECT(obj_tmp, 80, a->algorithm);
340 ERR_add_error_data(2, "TYPE=", obj_tmp);
341 EVP_PKEY_free (pkey);
342 return NULL;
343 }
344 return pkey; 105 return pkey;
106
107 error:
108 EVP_PKEY_free (pkey);
109 return NULL;
345} 110}
346 111
347PKCS8_PRIV_KEY_INFO *EVP_PKEY2PKCS8(EVP_PKEY *pkey) 112PKCS8_PRIV_KEY_INFO *EVP_PKEY2PKCS8(EVP_PKEY *pkey)
@@ -360,59 +125,37 @@ PKCS8_PRIV_KEY_INFO *EVP_PKEY2PKCS8_broken(EVP_PKEY *pkey, int broken)
360 return NULL; 125 return NULL;
361 } 126 }
362 p8->broken = broken; 127 p8->broken = broken;
363 if (!ASN1_INTEGER_set(p8->version, 0)) {
364 EVPerr(EVP_F_EVP_PKEY2PKCS8_BROKEN,ERR_R_MALLOC_FAILURE);
365 PKCS8_PRIV_KEY_INFO_free (p8);
366 return NULL;
367 }
368 if (!(p8->pkeyalg->parameter = ASN1_TYPE_new ())) {
369 EVPerr(EVP_F_EVP_PKEY2PKCS8_BROKEN,ERR_R_MALLOC_FAILURE);
370 PKCS8_PRIV_KEY_INFO_free (p8);
371 return NULL;
372 }
373 p8->pkey->type = V_ASN1_OCTET_STRING;
374 switch (EVP_PKEY_type(pkey->type)) {
375#ifndef OPENSSL_NO_RSA
376 case EVP_PKEY_RSA:
377 128
378 if(p8->broken == PKCS8_NO_OCTET) p8->pkey->type = V_ASN1_SEQUENCE; 129 if (pkey->ameth)
379 130 {
380 p8->pkeyalg->algorithm = OBJ_nid2obj(NID_rsaEncryption); 131 if (pkey->ameth->priv_encode)
381 p8->pkeyalg->parameter->type = V_ASN1_NULL; 132 {
382 if (!ASN1_pack_string_of (EVP_PKEY,pkey, i2d_PrivateKey, 133 if (!pkey->ameth->priv_encode(p8, pkey))
383 &p8->pkey->value.octet_string)) { 134 {
384 EVPerr(EVP_F_EVP_PKEY2PKCS8_BROKEN,ERR_R_MALLOC_FAILURE); 135 EVPerr(EVP_F_EVP_PKEY2PKCS8_BROKEN,
385 PKCS8_PRIV_KEY_INFO_free (p8); 136 EVP_R_PRIVATE_KEY_ENCODE_ERROR);
386 return NULL; 137 goto error;
387 } 138 }
388 break; 139 }
389#endif 140 else
390#ifndef OPENSSL_NO_DSA 141 {
391 case EVP_PKEY_DSA: 142 EVPerr(EVP_F_EVP_PKEY2PKCS8_BROKEN,
392 if(!dsa_pkey2pkcs8(p8, pkey)) { 143 EVP_R_METHOD_NOT_SUPPORTED);
393 PKCS8_PRIV_KEY_INFO_free (p8); 144 goto error;
394 return NULL; 145 }
395 } 146 }
396 147 else
397 break;
398#endif
399#ifndef OPENSSL_NO_EC
400 case EVP_PKEY_EC:
401 if (!eckey_pkey2pkcs8(p8, pkey))
402 { 148 {
403 PKCS8_PRIV_KEY_INFO_free(p8); 149 EVPerr(EVP_F_EVP_PKEY2PKCS8_BROKEN,
404 return(NULL); 150 EVP_R_UNSUPPORTED_PRIVATE_KEY_ALGORITHM);
151 goto error;
405 } 152 }
406 break;
407#endif
408 default:
409 EVPerr(EVP_F_EVP_PKEY2PKCS8_BROKEN, EVP_R_UNSUPPORTED_PRIVATE_KEY_ALGORITHM);
410 PKCS8_PRIV_KEY_INFO_free (p8);
411 return NULL;
412 }
413 RAND_add(p8->pkey->value.octet_string->data, 153 RAND_add(p8->pkey->value.octet_string->data,
414 p8->pkey->value.octet_string->length, 0.0); 154 p8->pkey->value.octet_string->length, 0.0);
415 return p8; 155 return p8;
156 error:
157 PKCS8_PRIV_KEY_INFO_free(p8);
158 return NULL;
416} 159}
417 160
418PKCS8_PRIV_KEY_INFO *PKCS8_set_broken(PKCS8_PRIV_KEY_INFO *p8, int broken) 161PKCS8_PRIV_KEY_INFO *PKCS8_set_broken(PKCS8_PRIV_KEY_INFO *p8, int broken)
@@ -436,301 +179,6 @@ PKCS8_PRIV_KEY_INFO *PKCS8_set_broken(PKCS8_PRIV_KEY_INFO *p8, int broken)
436 } 179 }
437} 180}
438 181
439#ifndef OPENSSL_NO_DSA
440static int dsa_pkey2pkcs8(PKCS8_PRIV_KEY_INFO *p8, EVP_PKEY *pkey)
441{
442 ASN1_STRING *params = NULL;
443 ASN1_INTEGER *prkey = NULL;
444 ASN1_TYPE *ttmp = NULL;
445 STACK_OF(ASN1_TYPE) *ndsa = NULL;
446 unsigned char *p = NULL, *q;
447 int len;
448
449 p8->pkeyalg->algorithm = OBJ_nid2obj(NID_dsa);
450 len = i2d_DSAparams (pkey->pkey.dsa, NULL);
451 if (!(p = OPENSSL_malloc(len))) {
452 EVPerr(EVP_F_DSA_PKEY2PKCS8,ERR_R_MALLOC_FAILURE);
453 goto err;
454 }
455 q = p;
456 i2d_DSAparams (pkey->pkey.dsa, &q);
457 if (!(params = ASN1_STRING_new())) {
458 EVPerr(EVP_F_DSA_PKEY2PKCS8,ERR_R_MALLOC_FAILURE);
459 goto err;
460 }
461 if (!ASN1_STRING_set(params, p, len)) {
462 EVPerr(EVP_F_DSA_PKEY2PKCS8,ERR_R_MALLOC_FAILURE);
463 goto err;
464 }
465 OPENSSL_free(p);
466 p = NULL;
467 /* Get private key into integer */
468 if (!(prkey = BN_to_ASN1_INTEGER (pkey->pkey.dsa->priv_key, NULL))) {
469 EVPerr(EVP_F_DSA_PKEY2PKCS8,EVP_R_ENCODE_ERROR);
470 goto err;
471 }
472
473 switch(p8->broken) {
474
475 case PKCS8_OK:
476 case PKCS8_NO_OCTET:
477
478 if (!ASN1_pack_string_of(ASN1_INTEGER,prkey, i2d_ASN1_INTEGER,
479 &p8->pkey->value.octet_string)) {
480 EVPerr(EVP_F_DSA_PKEY2PKCS8,ERR_R_MALLOC_FAILURE);
481 goto err;
482 }
483
484 M_ASN1_INTEGER_free (prkey);
485 prkey = NULL;
486 p8->pkeyalg->parameter->value.sequence = params;
487 params = NULL;
488 p8->pkeyalg->parameter->type = V_ASN1_SEQUENCE;
489
490 break;
491
492 case PKCS8_NS_DB:
493
494 p8->pkeyalg->parameter->value.sequence = params;
495 params = NULL;
496 p8->pkeyalg->parameter->type = V_ASN1_SEQUENCE;
497 if (!(ndsa = sk_ASN1_TYPE_new_null())) {
498 EVPerr(EVP_F_DSA_PKEY2PKCS8,ERR_R_MALLOC_FAILURE);
499 goto err;
500 }
501 if (!(ttmp = ASN1_TYPE_new())) {
502 EVPerr(EVP_F_DSA_PKEY2PKCS8,ERR_R_MALLOC_FAILURE);
503 goto err;
504 }
505 if (!(ttmp->value.integer =
506 BN_to_ASN1_INTEGER(pkey->pkey.dsa->pub_key, NULL))) {
507 EVPerr(EVP_F_DSA_PKEY2PKCS8,EVP_R_ENCODE_ERROR);
508 goto err;
509 }
510 ttmp->type = V_ASN1_INTEGER;
511 if (!sk_ASN1_TYPE_push(ndsa, ttmp)) {
512 EVPerr(EVP_F_DSA_PKEY2PKCS8,ERR_R_MALLOC_FAILURE);
513 goto err;
514 }
515
516 if (!(ttmp = ASN1_TYPE_new())) {
517 EVPerr(EVP_F_DSA_PKEY2PKCS8,ERR_R_MALLOC_FAILURE);
518 goto err;
519 }
520 ttmp->value.integer = prkey;
521 prkey = NULL;
522 ttmp->type = V_ASN1_INTEGER;
523 if (!sk_ASN1_TYPE_push(ndsa, ttmp)) {
524 EVPerr(EVP_F_DSA_PKEY2PKCS8,ERR_R_MALLOC_FAILURE);
525 goto err;
526 }
527 ttmp = NULL;
528
529 if (!(p8->pkey->value.octet_string = ASN1_OCTET_STRING_new())) {
530 EVPerr(EVP_F_DSA_PKEY2PKCS8,ERR_R_MALLOC_FAILURE);
531 goto err;
532 }
533
534 if (!ASN1_seq_pack_ASN1_TYPE(ndsa, i2d_ASN1_TYPE,
535 &p8->pkey->value.octet_string->data,
536 &p8->pkey->value.octet_string->length)) {
537
538 EVPerr(EVP_F_DSA_PKEY2PKCS8,ERR_R_MALLOC_FAILURE);
539 goto err;
540 }
541 sk_ASN1_TYPE_pop_free(ndsa, ASN1_TYPE_free);
542 break;
543
544 case PKCS8_EMBEDDED_PARAM:
545
546 p8->pkeyalg->parameter->type = V_ASN1_NULL;
547 if (!(ndsa = sk_ASN1_TYPE_new_null())) {
548 EVPerr(EVP_F_DSA_PKEY2PKCS8,ERR_R_MALLOC_FAILURE);
549 goto err;
550 }
551 if (!(ttmp = ASN1_TYPE_new())) {
552 EVPerr(EVP_F_DSA_PKEY2PKCS8,ERR_R_MALLOC_FAILURE);
553 goto err;
554 }
555 ttmp->value.sequence = params;
556 params = NULL;
557 ttmp->type = V_ASN1_SEQUENCE;
558 if (!sk_ASN1_TYPE_push(ndsa, ttmp)) {
559 EVPerr(EVP_F_DSA_PKEY2PKCS8,ERR_R_MALLOC_FAILURE);
560 goto err;
561 }
562
563 if (!(ttmp = ASN1_TYPE_new())) {
564 EVPerr(EVP_F_DSA_PKEY2PKCS8,ERR_R_MALLOC_FAILURE);
565 goto err;
566 }
567 ttmp->value.integer = prkey;
568 prkey = NULL;
569 ttmp->type = V_ASN1_INTEGER;
570 if (!sk_ASN1_TYPE_push(ndsa, ttmp)) {
571 EVPerr(EVP_F_DSA_PKEY2PKCS8,ERR_R_MALLOC_FAILURE);
572 goto err;
573 }
574 ttmp = NULL;
575
576 if (!(p8->pkey->value.octet_string = ASN1_OCTET_STRING_new())) {
577 EVPerr(EVP_F_DSA_PKEY2PKCS8,ERR_R_MALLOC_FAILURE);
578 goto err;
579 }
580
581 if (!ASN1_seq_pack_ASN1_TYPE(ndsa, i2d_ASN1_TYPE,
582 &p8->pkey->value.octet_string->data,
583 &p8->pkey->value.octet_string->length)) {
584
585 EVPerr(EVP_F_DSA_PKEY2PKCS8,ERR_R_MALLOC_FAILURE);
586 goto err;
587 }
588 sk_ASN1_TYPE_pop_free(ndsa, ASN1_TYPE_free);
589 break;
590 }
591 return 1;
592err:
593 if (p != NULL) OPENSSL_free(p);
594 if (params != NULL) ASN1_STRING_free(params);
595 if (prkey != NULL) M_ASN1_INTEGER_free(prkey);
596 if (ttmp != NULL) ASN1_TYPE_free(ttmp);
597 if (ndsa != NULL) sk_ASN1_TYPE_pop_free(ndsa, ASN1_TYPE_free);
598 return 0;
599}
600#endif
601
602#ifndef OPENSSL_NO_EC
603static int eckey_pkey2pkcs8(PKCS8_PRIV_KEY_INFO *p8, EVP_PKEY *pkey)
604{
605 EC_KEY *ec_key;
606 const EC_GROUP *group;
607 unsigned char *p, *pp;
608 int nid, i, ret = 0;
609 unsigned int tmp_flags, old_flags;
610
611 ec_key = pkey->pkey.ec;
612 if (ec_key == NULL || (group = EC_KEY_get0_group(ec_key)) == NULL)
613 {
614 EVPerr(EVP_F_ECKEY_PKEY2PKCS8, EVP_R_MISSING_PARAMETERS);
615 return 0;
616 }
617
618 /* set the ec parameters OID */
619 if (p8->pkeyalg->algorithm)
620 ASN1_OBJECT_free(p8->pkeyalg->algorithm);
621
622 p8->pkeyalg->algorithm = OBJ_nid2obj(NID_X9_62_id_ecPublicKey);
623
624 /* set the ec parameters */
625
626 if (p8->pkeyalg->parameter)
627 {
628 ASN1_TYPE_free(p8->pkeyalg->parameter);
629 p8->pkeyalg->parameter = NULL;
630 }
631
632 if ((p8->pkeyalg->parameter = ASN1_TYPE_new()) == NULL)
633 {
634 EVPerr(EVP_F_ECKEY_PKEY2PKCS8, ERR_R_MALLOC_FAILURE);
635 return 0;
636 }
637
638 if (EC_GROUP_get_asn1_flag(group)
639 && (nid = EC_GROUP_get_curve_name(group)))
640 {
641 /* we have a 'named curve' => just set the OID */
642 p8->pkeyalg->parameter->type = V_ASN1_OBJECT;
643 p8->pkeyalg->parameter->value.object = OBJ_nid2obj(nid);
644 }
645 else /* explicit parameters */
646 {
647 if ((i = i2d_ECParameters(ec_key, NULL)) == 0)
648 {
649 EVPerr(EVP_F_ECKEY_PKEY2PKCS8, ERR_R_EC_LIB);
650 return 0;
651 }
652 if ((p = (unsigned char *) OPENSSL_malloc(i)) == NULL)
653 {
654 EVPerr(EVP_F_ECKEY_PKEY2PKCS8, ERR_R_MALLOC_FAILURE);
655 return 0;
656 }
657 pp = p;
658 if (!i2d_ECParameters(ec_key, &pp))
659 {
660 EVPerr(EVP_F_ECKEY_PKEY2PKCS8, ERR_R_EC_LIB);
661 OPENSSL_free(p);
662 return 0;
663 }
664 p8->pkeyalg->parameter->type = V_ASN1_SEQUENCE;
665 if ((p8->pkeyalg->parameter->value.sequence
666 = ASN1_STRING_new()) == NULL)
667 {
668 EVPerr(EVP_F_ECKEY_PKEY2PKCS8, ERR_R_ASN1_LIB);
669 OPENSSL_free(p);
670 return 0;
671 }
672 ASN1_STRING_set(p8->pkeyalg->parameter->value.sequence, p, i);
673 OPENSSL_free(p);
674 }
675
676 /* set the private key */
677
678 /* do not include the parameters in the SEC1 private key
679 * see PKCS#11 12.11 */
680 old_flags = EC_KEY_get_enc_flags(pkey->pkey.ec);
681 tmp_flags = old_flags | EC_PKEY_NO_PARAMETERS;
682 EC_KEY_set_enc_flags(pkey->pkey.ec, tmp_flags);
683 i = i2d_ECPrivateKey(pkey->pkey.ec, NULL);
684 if (!i)
685 {
686 EC_KEY_set_enc_flags(pkey->pkey.ec, old_flags);
687 EVPerr(EVP_F_ECKEY_PKEY2PKCS8, ERR_R_EC_LIB);
688 return 0;
689 }
690 p = (unsigned char *) OPENSSL_malloc(i);
691 if (!p)
692 {
693 EC_KEY_set_enc_flags(pkey->pkey.ec, old_flags);
694 EVPerr(EVP_F_ECKEY_PKEY2PKCS8, ERR_R_MALLOC_FAILURE);
695 return 0;
696 }
697 pp = p;
698 if (!i2d_ECPrivateKey(pkey->pkey.ec, &pp))
699 {
700 EC_KEY_set_enc_flags(pkey->pkey.ec, old_flags);
701 EVPerr(EVP_F_ECKEY_PKEY2PKCS8, ERR_R_EC_LIB);
702 OPENSSL_free(p);
703 return 0;
704 }
705 /* restore old encoding flags */
706 EC_KEY_set_enc_flags(pkey->pkey.ec, old_flags);
707
708 switch(p8->broken) {
709
710 case PKCS8_OK:
711 p8->pkey->value.octet_string = ASN1_OCTET_STRING_new();
712 if (!p8->pkey->value.octet_string ||
713 !M_ASN1_OCTET_STRING_set(p8->pkey->value.octet_string,
714 (const void *)p, i))
715
716 {
717 EVPerr(EVP_F_ECKEY_PKEY2PKCS8, ERR_R_MALLOC_FAILURE);
718 }
719 else
720 ret = 1;
721 break;
722 case PKCS8_NO_OCTET: /* RSA specific */
723 case PKCS8_NS_DB: /* DSA specific */
724 case PKCS8_EMBEDDED_PARAM: /* DSA specific */
725 default:
726 EVPerr(EVP_F_ECKEY_PKEY2PKCS8,EVP_R_ENCODE_ERROR);
727 }
728 OPENSSL_cleanse(p, (size_t)i);
729 OPENSSL_free(p);
730 return ret;
731}
732#endif
733
734/* EVP_PKEY attribute functions */ 182/* EVP_PKEY attribute functions */
735 183
736int EVP_PKEY_get_attr_count(const EVP_PKEY *key) 184int EVP_PKEY_get_attr_count(const EVP_PKEY *key)
diff --git a/src/lib/libcrypto/evp/evp_test.c b/src/lib/libcrypto/evp/evp_test.c
index 436be20bf1..902efac975 100644
--- a/src/lib/libcrypto/evp/evp_test.c
+++ b/src/lib/libcrypto/evp/evp_test.c
@@ -153,8 +153,8 @@ static void test1(const EVP_CIPHER *c,const unsigned char *key,int kn,
153 153
154 if(kn != c->key_len) 154 if(kn != c->key_len)
155 { 155 {
156 fprintf(stderr,"Key length doesn't match, got %d expected %d\n",kn, 156 fprintf(stderr,"Key length doesn't match, got %d expected %lu\n",kn,
157 c->key_len); 157 (unsigned long)c->key_len);
158 test1_exit(5); 158 test1_exit(5);
159 } 159 }
160 EVP_CIPHER_CTX_init(&ctx); 160 EVP_CIPHER_CTX_init(&ctx);
@@ -441,7 +441,7 @@ int main(int argc,char **argv)
441#endif 441#endif
442 EVP_cleanup(); 442 EVP_cleanup();
443 CRYPTO_cleanup_all_ex_data(); 443 CRYPTO_cleanup_all_ex_data();
444 ERR_remove_state(0); 444 ERR_remove_thread_state(NULL);
445 ERR_free_strings(); 445 ERR_free_strings();
446 CRYPTO_mem_leaks_fp(stderr); 446 CRYPTO_mem_leaks_fp(stderr);
447 447
diff --git a/src/lib/libcrypto/evp/m_dss.c b/src/lib/libcrypto/evp/m_dss.c
index 6b0c0aa7a3..48c2689504 100644
--- a/src/lib/libcrypto/evp/m_dss.c
+++ b/src/lib/libcrypto/evp/m_dss.c
@@ -81,7 +81,7 @@ static const EVP_MD dsa_md=
81 NID_dsaWithSHA, 81 NID_dsaWithSHA,
82 NID_dsaWithSHA, 82 NID_dsaWithSHA,
83 SHA_DIGEST_LENGTH, 83 SHA_DIGEST_LENGTH,
84 EVP_MD_FLAG_FIPS, 84 EVP_MD_FLAG_PKEY_DIGEST,
85 init, 85 init,
86 update, 86 update,
87 final, 87 final,
diff --git a/src/lib/libcrypto/evp/m_dss1.c b/src/lib/libcrypto/evp/m_dss1.c
index da8babc147..4f03fb70e0 100644
--- a/src/lib/libcrypto/evp/m_dss1.c
+++ b/src/lib/libcrypto/evp/m_dss1.c
@@ -68,8 +68,6 @@
68#include <openssl/dsa.h> 68#include <openssl/dsa.h>
69#endif 69#endif
70 70
71#ifndef OPENSSL_FIPS
72
73static int init(EVP_MD_CTX *ctx) 71static int init(EVP_MD_CTX *ctx)
74 { return SHA1_Init(ctx->md_data); } 72 { return SHA1_Init(ctx->md_data); }
75 73
@@ -84,7 +82,7 @@ static const EVP_MD dss1_md=
84 NID_dsa, 82 NID_dsa,
85 NID_dsaWithSHA1, 83 NID_dsaWithSHA1,
86 SHA_DIGEST_LENGTH, 84 SHA_DIGEST_LENGTH,
87 0, 85 EVP_MD_FLAG_PKEY_DIGEST,
88 init, 86 init,
89 update, 87 update,
90 final, 88 final,
@@ -100,4 +98,3 @@ const EVP_MD *EVP_dss1(void)
100 return(&dss1_md); 98 return(&dss1_md);
101 } 99 }
102#endif 100#endif
103#endif
diff --git a/src/lib/libcrypto/evp/m_md2.c b/src/lib/libcrypto/evp/m_md2.c
index 8eee6236ba..5ce849f161 100644
--- a/src/lib/libcrypto/evp/m_md2.c
+++ b/src/lib/libcrypto/evp/m_md2.c
@@ -58,7 +58,6 @@
58 58
59#include <stdio.h> 59#include <stdio.h>
60#include "cryptlib.h" 60#include "cryptlib.h"
61#include "evp_locl.h"
62 61
63#ifndef OPENSSL_NO_MD2 62#ifndef OPENSSL_NO_MD2
64 63
diff --git a/src/lib/libcrypto/evp/m_md4.c b/src/lib/libcrypto/evp/m_md4.c
index 5cd2ab5ade..1e0b7c5b42 100644
--- a/src/lib/libcrypto/evp/m_md4.c
+++ b/src/lib/libcrypto/evp/m_md4.c
@@ -58,7 +58,6 @@
58 58
59#include <stdio.h> 59#include <stdio.h>
60#include "cryptlib.h" 60#include "cryptlib.h"
61#include "evp_locl.h"
62 61
63#ifndef OPENSSL_NO_MD4 62#ifndef OPENSSL_NO_MD4
64 63
diff --git a/src/lib/libcrypto/evp/m_md5.c b/src/lib/libcrypto/evp/m_md5.c
index 6455829671..63c142119e 100644
--- a/src/lib/libcrypto/evp/m_md5.c
+++ b/src/lib/libcrypto/evp/m_md5.c
@@ -62,7 +62,6 @@
62#ifndef OPENSSL_NO_MD5 62#ifndef OPENSSL_NO_MD5
63 63
64#include <openssl/evp.h> 64#include <openssl/evp.h>
65#include "evp_locl.h"
66#include <openssl/objects.h> 65#include <openssl/objects.h>
67#include <openssl/x509.h> 66#include <openssl/x509.h>
68#include <openssl/md5.h> 67#include <openssl/md5.h>
diff --git a/src/lib/libcrypto/evp/m_mdc2.c b/src/lib/libcrypto/evp/m_mdc2.c
index 9f9bcf06ed..b08d559803 100644
--- a/src/lib/libcrypto/evp/m_mdc2.c
+++ b/src/lib/libcrypto/evp/m_mdc2.c
@@ -58,7 +58,6 @@
58 58
59#include <stdio.h> 59#include <stdio.h>
60#include "cryptlib.h" 60#include "cryptlib.h"
61#include "evp_locl.h"
62 61
63#ifndef OPENSSL_NO_MDC2 62#ifndef OPENSSL_NO_MDC2
64 63
@@ -66,7 +65,9 @@
66#include <openssl/objects.h> 65#include <openssl/objects.h>
67#include <openssl/x509.h> 66#include <openssl/x509.h>
68#include <openssl/mdc2.h> 67#include <openssl/mdc2.h>
68#ifndef OPENSSL_NO_RSA
69#include <openssl/rsa.h> 69#include <openssl/rsa.h>
70#endif
70 71
71static int init(EVP_MD_CTX *ctx) 72static int init(EVP_MD_CTX *ctx)
72 { return MDC2_Init(ctx->md_data); } 73 { return MDC2_Init(ctx->md_data); }
diff --git a/src/lib/libcrypto/evp/m_sha.c b/src/lib/libcrypto/evp/m_sha.c
index 3f30dfc579..acccc8f92d 100644
--- a/src/lib/libcrypto/evp/m_sha.c
+++ b/src/lib/libcrypto/evp/m_sha.c
@@ -58,7 +58,6 @@
58 58
59#include <stdio.h> 59#include <stdio.h>
60#include "cryptlib.h" 60#include "cryptlib.h"
61#include "evp_locl.h"
62 61
63#if !defined(OPENSSL_NO_SHA) && !defined(OPENSSL_NO_SHA0) 62#if !defined(OPENSSL_NO_SHA) && !defined(OPENSSL_NO_SHA0)
64 63
diff --git a/src/lib/libcrypto/evp/m_sha1.c b/src/lib/libcrypto/evp/m_sha1.c
index 471ec30be0..9a2790fdea 100644
--- a/src/lib/libcrypto/evp/m_sha1.c
+++ b/src/lib/libcrypto/evp/m_sha1.c
@@ -68,8 +68,6 @@
68#include <openssl/rsa.h> 68#include <openssl/rsa.h>
69#endif 69#endif
70 70
71#ifndef OPENSSL_FIPS
72
73static int init(EVP_MD_CTX *ctx) 71static int init(EVP_MD_CTX *ctx)
74 { return SHA1_Init(ctx->md_data); } 72 { return SHA1_Init(ctx->md_data); }
75 73
@@ -84,7 +82,7 @@ static const EVP_MD sha1_md=
84 NID_sha1, 82 NID_sha1,
85 NID_sha1WithRSAEncryption, 83 NID_sha1WithRSAEncryption,
86 SHA_DIGEST_LENGTH, 84 SHA_DIGEST_LENGTH,
87 0, 85 EVP_MD_FLAG_PKEY_METHOD_SIGNATURE|EVP_MD_FLAG_DIGALGID_ABSENT,
88 init, 86 init,
89 update, 87 update,
90 final, 88 final,
@@ -99,6 +97,7 @@ const EVP_MD *EVP_sha1(void)
99 { 97 {
100 return(&sha1_md); 98 return(&sha1_md);
101 } 99 }
100#endif
102 101
103#ifndef OPENSSL_NO_SHA256 102#ifndef OPENSSL_NO_SHA256
104static int init224(EVP_MD_CTX *ctx) 103static int init224(EVP_MD_CTX *ctx)
@@ -120,7 +119,7 @@ static const EVP_MD sha224_md=
120 NID_sha224, 119 NID_sha224,
121 NID_sha224WithRSAEncryption, 120 NID_sha224WithRSAEncryption,
122 SHA224_DIGEST_LENGTH, 121 SHA224_DIGEST_LENGTH,
123 0, 122 EVP_MD_FLAG_PKEY_METHOD_SIGNATURE|EVP_MD_FLAG_DIGALGID_ABSENT,
124 init224, 123 init224,
125 update256, 124 update256,
126 final256, 125 final256,
@@ -139,7 +138,7 @@ static const EVP_MD sha256_md=
139 NID_sha256, 138 NID_sha256,
140 NID_sha256WithRSAEncryption, 139 NID_sha256WithRSAEncryption,
141 SHA256_DIGEST_LENGTH, 140 SHA256_DIGEST_LENGTH,
142 0, 141 EVP_MD_FLAG_PKEY_METHOD_SIGNATURE|EVP_MD_FLAG_DIGALGID_ABSENT,
143 init256, 142 init256,
144 update256, 143 update256,
145 final256, 144 final256,
@@ -170,7 +169,7 @@ static const EVP_MD sha384_md=
170 NID_sha384, 169 NID_sha384,
171 NID_sha384WithRSAEncryption, 170 NID_sha384WithRSAEncryption,
172 SHA384_DIGEST_LENGTH, 171 SHA384_DIGEST_LENGTH,
173 0, 172 EVP_MD_FLAG_PKEY_METHOD_SIGNATURE|EVP_MD_FLAG_DIGALGID_ABSENT,
174 init384, 173 init384,
175 update512, 174 update512,
176 final512, 175 final512,
@@ -189,7 +188,7 @@ static const EVP_MD sha512_md=
189 NID_sha512, 188 NID_sha512,
190 NID_sha512WithRSAEncryption, 189 NID_sha512WithRSAEncryption,
191 SHA512_DIGEST_LENGTH, 190 SHA512_DIGEST_LENGTH,
192 0, 191 EVP_MD_FLAG_PKEY_METHOD_SIGNATURE|EVP_MD_FLAG_DIGALGID_ABSENT,
193 init512, 192 init512,
194 update512, 193 update512,
195 final512, 194 final512,
@@ -203,7 +202,3 @@ static const EVP_MD sha512_md=
203const EVP_MD *EVP_sha512(void) 202const EVP_MD *EVP_sha512(void)
204 { return(&sha512_md); } 203 { return(&sha512_md); }
205#endif /* ifndef OPENSSL_NO_SHA512 */ 204#endif /* ifndef OPENSSL_NO_SHA512 */
206
207#endif
208
209#endif
diff --git a/src/lib/libcrypto/evp/names.c b/src/lib/libcrypto/evp/names.c
index e2e04c3570..f2869f5c78 100644
--- a/src/lib/libcrypto/evp/names.c
+++ b/src/lib/libcrypto/evp/names.c
@@ -66,35 +66,32 @@ int EVP_add_cipher(const EVP_CIPHER *c)
66 { 66 {
67 int r; 67 int r;
68 68
69#ifdef OPENSSL_FIPS
70 OPENSSL_init();
71#endif
72
73 r=OBJ_NAME_add(OBJ_nid2sn(c->nid),OBJ_NAME_TYPE_CIPHER_METH,(const char *)c); 69 r=OBJ_NAME_add(OBJ_nid2sn(c->nid),OBJ_NAME_TYPE_CIPHER_METH,(const char *)c);
74 if (r == 0) return(0); 70 if (r == 0) return(0);
71 check_defer(c->nid);
75 r=OBJ_NAME_add(OBJ_nid2ln(c->nid),OBJ_NAME_TYPE_CIPHER_METH,(const char *)c); 72 r=OBJ_NAME_add(OBJ_nid2ln(c->nid),OBJ_NAME_TYPE_CIPHER_METH,(const char *)c);
76 return(r); 73 return(r);
77 } 74 }
78 75
76
79int EVP_add_digest(const EVP_MD *md) 77int EVP_add_digest(const EVP_MD *md)
80 { 78 {
81 int r; 79 int r;
82 const char *name; 80 const char *name;
83 81
84#ifdef OPENSSL_FIPS
85 OPENSSL_init();
86#endif
87 name=OBJ_nid2sn(md->type); 82 name=OBJ_nid2sn(md->type);
88 r=OBJ_NAME_add(name,OBJ_NAME_TYPE_MD_METH,(const char *)md); 83 r=OBJ_NAME_add(name,OBJ_NAME_TYPE_MD_METH,(const char *)md);
89 if (r == 0) return(0); 84 if (r == 0) return(0);
85 check_defer(md->type);
90 r=OBJ_NAME_add(OBJ_nid2ln(md->type),OBJ_NAME_TYPE_MD_METH,(const char *)md); 86 r=OBJ_NAME_add(OBJ_nid2ln(md->type),OBJ_NAME_TYPE_MD_METH,(const char *)md);
91 if (r == 0) return(0); 87 if (r == 0) return(0);
92 88
93 if (md->type != md->pkey_type) 89 if (md->pkey_type && md->type != md->pkey_type)
94 { 90 {
95 r=OBJ_NAME_add(OBJ_nid2sn(md->pkey_type), 91 r=OBJ_NAME_add(OBJ_nid2sn(md->pkey_type),
96 OBJ_NAME_TYPE_MD_METH|OBJ_NAME_ALIAS,name); 92 OBJ_NAME_TYPE_MD_METH|OBJ_NAME_ALIAS,name);
97 if (r == 0) return(0); 93 if (r == 0) return(0);
94 check_defer(md->pkey_type);
98 r=OBJ_NAME_add(OBJ_nid2ln(md->pkey_type), 95 r=OBJ_NAME_add(OBJ_nid2ln(md->pkey_type),
99 OBJ_NAME_TYPE_MD_METH|OBJ_NAME_ALIAS,name); 96 OBJ_NAME_TYPE_MD_METH|OBJ_NAME_ALIAS,name);
100 } 97 }
@@ -127,4 +124,78 @@ void EVP_cleanup(void)
127 OBJ_NAME_cleanup(-1); 124 OBJ_NAME_cleanup(-1);
128 125
129 EVP_PBE_cleanup(); 126 EVP_PBE_cleanup();
127 if (obj_cleanup_defer == 2)
128 {
129 obj_cleanup_defer = 0;
130 OBJ_cleanup();
131 }
132 OBJ_sigid_free();
133 }
134
135struct doall_cipher
136 {
137 void *arg;
138 void (*fn)(const EVP_CIPHER *ciph,
139 const char *from, const char *to, void *arg);
140 };
141
142static void do_all_cipher_fn(const OBJ_NAME *nm, void *arg)
143 {
144 struct doall_cipher *dc = arg;
145 if (nm->alias)
146 dc->fn(NULL, nm->name, nm->data, dc->arg);
147 else
148 dc->fn((const EVP_CIPHER *)nm->data, nm->name, NULL, dc->arg);
149 }
150
151void EVP_CIPHER_do_all(void (*fn)(const EVP_CIPHER *ciph,
152 const char *from, const char *to, void *x), void *arg)
153 {
154 struct doall_cipher dc;
155 dc.fn = fn;
156 dc.arg = arg;
157 OBJ_NAME_do_all(OBJ_NAME_TYPE_CIPHER_METH, do_all_cipher_fn, &dc);
158 }
159
160void EVP_CIPHER_do_all_sorted(void (*fn)(const EVP_CIPHER *ciph,
161 const char *from, const char *to, void *x), void *arg)
162 {
163 struct doall_cipher dc;
164 dc.fn = fn;
165 dc.arg = arg;
166 OBJ_NAME_do_all_sorted(OBJ_NAME_TYPE_CIPHER_METH, do_all_cipher_fn,&dc);
167 }
168
169struct doall_md
170 {
171 void *arg;
172 void (*fn)(const EVP_MD *ciph,
173 const char *from, const char *to, void *arg);
174 };
175
176static void do_all_md_fn(const OBJ_NAME *nm, void *arg)
177 {
178 struct doall_md *dc = arg;
179 if (nm->alias)
180 dc->fn(NULL, nm->name, nm->data, dc->arg);
181 else
182 dc->fn((const EVP_MD *)nm->data, nm->name, NULL, dc->arg);
183 }
184
185void EVP_MD_do_all(void (*fn)(const EVP_MD *md,
186 const char *from, const char *to, void *x), void *arg)
187 {
188 struct doall_md dc;
189 dc.fn = fn;
190 dc.arg = arg;
191 OBJ_NAME_do_all(OBJ_NAME_TYPE_MD_METH, do_all_md_fn, &dc);
192 }
193
194void EVP_MD_do_all_sorted(void (*fn)(const EVP_MD *md,
195 const char *from, const char *to, void *x), void *arg)
196 {
197 struct doall_md dc;
198 dc.fn = fn;
199 dc.arg = arg;
200 OBJ_NAME_do_all_sorted(OBJ_NAME_TYPE_MD_METH, do_all_md_fn, &dc);
130 } 201 }
diff --git a/src/lib/libcrypto/evp/p5_crpt.c b/src/lib/libcrypto/evp/p5_crpt.c
index 2a265fdee2..7ecfa8dad9 100644
--- a/src/lib/libcrypto/evp/p5_crpt.c
+++ b/src/lib/libcrypto/evp/p5_crpt.c
@@ -62,42 +62,11 @@
62#include <openssl/x509.h> 62#include <openssl/x509.h>
63#include <openssl/evp.h> 63#include <openssl/evp.h>
64 64
65/* PKCS#5 v1.5 compatible PBE functions: see PKCS#5 v2.0 for more info. 65/* Doesn't do anything now: Builtin PBE algorithms in static table.
66 */ 66 */
67 67
68void PKCS5_PBE_add(void) 68void PKCS5_PBE_add(void)
69{ 69{
70#ifndef OPENSSL_NO_DES
71# ifndef OPENSSL_NO_MD5
72EVP_PBE_alg_add(NID_pbeWithMD5AndDES_CBC, EVP_des_cbc(), EVP_md5(),
73 PKCS5_PBE_keyivgen);
74# endif
75# ifndef OPENSSL_NO_MD2
76EVP_PBE_alg_add(NID_pbeWithMD2AndDES_CBC, EVP_des_cbc(), EVP_md2(),
77 PKCS5_PBE_keyivgen);
78# endif
79# ifndef OPENSSL_NO_SHA
80EVP_PBE_alg_add(NID_pbeWithSHA1AndDES_CBC, EVP_des_cbc(), EVP_sha1(),
81 PKCS5_PBE_keyivgen);
82# endif
83#endif
84#ifndef OPENSSL_NO_RC2
85# ifndef OPENSSL_NO_MD5
86EVP_PBE_alg_add(NID_pbeWithMD5AndRC2_CBC, EVP_rc2_64_cbc(), EVP_md5(),
87 PKCS5_PBE_keyivgen);
88# endif
89# ifndef OPENSSL_NO_MD2
90EVP_PBE_alg_add(NID_pbeWithMD2AndRC2_CBC, EVP_rc2_64_cbc(), EVP_md2(),
91 PKCS5_PBE_keyivgen);
92# endif
93# ifndef OPENSSL_NO_SHA
94EVP_PBE_alg_add(NID_pbeWithSHA1AndRC2_CBC, EVP_rc2_64_cbc(), EVP_sha1(),
95 PKCS5_PBE_keyivgen);
96# endif
97#endif
98#ifndef OPENSSL_NO_HMAC
99EVP_PBE_alg_add(NID_pbes2, NULL, NULL, PKCS5_v2_PBE_keyivgen);
100#endif
101} 70}
102 71
103int PKCS5_PBE_keyivgen(EVP_CIPHER_CTX *cctx, const char *pass, int passlen, 72int PKCS5_PBE_keyivgen(EVP_CIPHER_CTX *cctx, const char *pass, int passlen,
@@ -112,6 +81,7 @@ int PKCS5_PBE_keyivgen(EVP_CIPHER_CTX *cctx, const char *pass, int passlen,
112 int saltlen, iter; 81 int saltlen, iter;
113 unsigned char *salt; 82 unsigned char *salt;
114 const unsigned char *pbuf; 83 const unsigned char *pbuf;
84 int mdsize;
115 85
116 /* Extract useful info from parameter */ 86 /* Extract useful info from parameter */
117 if (param == NULL || param->type != V_ASN1_SEQUENCE || 87 if (param == NULL || param->type != V_ASN1_SEQUENCE ||
@@ -140,9 +110,12 @@ int PKCS5_PBE_keyivgen(EVP_CIPHER_CTX *cctx, const char *pass, int passlen,
140 EVP_DigestUpdate(&ctx, salt, saltlen); 110 EVP_DigestUpdate(&ctx, salt, saltlen);
141 PBEPARAM_free(pbe); 111 PBEPARAM_free(pbe);
142 EVP_DigestFinal_ex(&ctx, md_tmp, NULL); 112 EVP_DigestFinal_ex(&ctx, md_tmp, NULL);
113 mdsize = EVP_MD_size(md);
114 if (mdsize < 0)
115 return 0;
143 for (i = 1; i < iter; i++) { 116 for (i = 1; i < iter; i++) {
144 EVP_DigestInit_ex(&ctx, md, NULL); 117 EVP_DigestInit_ex(&ctx, md, NULL);
145 EVP_DigestUpdate(&ctx, md_tmp, EVP_MD_size(md)); 118 EVP_DigestUpdate(&ctx, md_tmp, mdsize);
146 EVP_DigestFinal_ex (&ctx, md_tmp, NULL); 119 EVP_DigestFinal_ex (&ctx, md_tmp, NULL);
147 } 120 }
148 EVP_MD_CTX_cleanup(&ctx); 121 EVP_MD_CTX_cleanup(&ctx);
diff --git a/src/lib/libcrypto/evp/p5_crpt2.c b/src/lib/libcrypto/evp/p5_crpt2.c
index 6bec77baf9..334379f310 100644
--- a/src/lib/libcrypto/evp/p5_crpt2.c
+++ b/src/lib/libcrypto/evp/p5_crpt2.c
@@ -3,7 +3,7 @@
3 * project 1999. 3 * project 1999.
4 */ 4 */
5/* ==================================================================== 5/* ====================================================================
6 * Copyright (c) 1999 The OpenSSL Project. All rights reserved. 6 * Copyright (c) 1999-2006 The OpenSSL Project. All rights reserved.
7 * 7 *
8 * Redistribution and use in source and binary forms, with or without 8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions 9 * modification, are permitted provided that the following conditions
@@ -71,28 +71,38 @@
71#endif 71#endif
72 72
73/* This is an implementation of PKCS#5 v2.0 password based encryption key 73/* This is an implementation of PKCS#5 v2.0 password based encryption key
74 * derivation function PBKDF2 using the only currently defined function HMAC 74 * derivation function PBKDF2.
75 * with SHA1. Verified against test vectors posted by Peter Gutmann 75 * SHA1 version verified against test vectors posted by Peter Gutmann
76 * <pgut001@cs.auckland.ac.nz> to the PKCS-TNG <pkcs-tng@rsa.com> mailing list. 76 * <pgut001@cs.auckland.ac.nz> to the PKCS-TNG <pkcs-tng@rsa.com> mailing list.
77 */ 77 */
78 78
79int PKCS5_PBKDF2_HMAC_SHA1(const char *pass, int passlen, 79int PKCS5_PBKDF2_HMAC(const char *pass, int passlen,
80 const unsigned char *salt, int saltlen, int iter, 80 const unsigned char *salt, int saltlen, int iter,
81 const EVP_MD *digest,
81 int keylen, unsigned char *out) 82 int keylen, unsigned char *out)
82{ 83 {
83 unsigned char digtmp[SHA_DIGEST_LENGTH], *p, itmp[4]; 84 unsigned char digtmp[EVP_MAX_MD_SIZE], *p, itmp[4];
84 int cplen, j, k, tkeylen; 85 int cplen, j, k, tkeylen, mdlen;
85 unsigned long i = 1; 86 unsigned long i = 1;
86 HMAC_CTX hctx; 87 HMAC_CTX hctx;
87 88
89 mdlen = EVP_MD_size(digest);
90 if (mdlen < 0)
91 return 0;
92
88 HMAC_CTX_init(&hctx); 93 HMAC_CTX_init(&hctx);
89 p = out; 94 p = out;
90 tkeylen = keylen; 95 tkeylen = keylen;
91 if(!pass) passlen = 0; 96 if(!pass)
92 else if(passlen == -1) passlen = strlen(pass); 97 passlen = 0;
93 while(tkeylen) { 98 else if(passlen == -1)
94 if(tkeylen > SHA_DIGEST_LENGTH) cplen = SHA_DIGEST_LENGTH; 99 passlen = strlen(pass);
95 else cplen = tkeylen; 100 while(tkeylen)
101 {
102 if(tkeylen > mdlen)
103 cplen = mdlen;
104 else
105 cplen = tkeylen;
96 /* We are unlikely to ever use more than 256 blocks (5120 bits!) 106 /* We are unlikely to ever use more than 256 blocks (5120 bits!)
97 * but just in case... 107 * but just in case...
98 */ 108 */
@@ -100,20 +110,22 @@ int PKCS5_PBKDF2_HMAC_SHA1(const char *pass, int passlen,
100 itmp[1] = (unsigned char)((i >> 16) & 0xff); 110 itmp[1] = (unsigned char)((i >> 16) & 0xff);
101 itmp[2] = (unsigned char)((i >> 8) & 0xff); 111 itmp[2] = (unsigned char)((i >> 8) & 0xff);
102 itmp[3] = (unsigned char)(i & 0xff); 112 itmp[3] = (unsigned char)(i & 0xff);
103 HMAC_Init_ex(&hctx, pass, passlen, EVP_sha1(), NULL); 113 HMAC_Init_ex(&hctx, pass, passlen, digest, NULL);
104 HMAC_Update(&hctx, salt, saltlen); 114 HMAC_Update(&hctx, salt, saltlen);
105 HMAC_Update(&hctx, itmp, 4); 115 HMAC_Update(&hctx, itmp, 4);
106 HMAC_Final(&hctx, digtmp, NULL); 116 HMAC_Final(&hctx, digtmp, NULL);
107 memcpy(p, digtmp, cplen); 117 memcpy(p, digtmp, cplen);
108 for(j = 1; j < iter; j++) { 118 for(j = 1; j < iter; j++)
109 HMAC(EVP_sha1(), pass, passlen, 119 {
110 digtmp, SHA_DIGEST_LENGTH, digtmp, NULL); 120 HMAC(digest, pass, passlen,
111 for(k = 0; k < cplen; k++) p[k] ^= digtmp[k]; 121 digtmp, mdlen, digtmp, NULL);
112 } 122 for(k = 0; k < cplen; k++)
123 p[k] ^= digtmp[k];
124 }
113 tkeylen-= cplen; 125 tkeylen-= cplen;
114 i++; 126 i++;
115 p+= cplen; 127 p+= cplen;
116 } 128 }
117 HMAC_CTX_cleanup(&hctx); 129 HMAC_CTX_cleanup(&hctx);
118#ifdef DEBUG_PKCS5V2 130#ifdef DEBUG_PKCS5V2
119 fprintf(stderr, "Password:\n"); 131 fprintf(stderr, "Password:\n");
@@ -125,7 +137,15 @@ int PKCS5_PBKDF2_HMAC_SHA1(const char *pass, int passlen,
125 h__dump (out, keylen); 137 h__dump (out, keylen);
126#endif 138#endif
127 return 1; 139 return 1;
128} 140 }
141
142int PKCS5_PBKDF2_HMAC_SHA1(const char *pass, int passlen,
143 const unsigned char *salt, int saltlen, int iter,
144 int keylen, unsigned char *out)
145 {
146 return PKCS5_PBKDF2_HMAC(pass, passlen, salt, saltlen, iter, EVP_sha1(),
147 keylen, out);
148 }
129 149
130#ifdef DO_TEST 150#ifdef DO_TEST
131main() 151main()
@@ -155,6 +175,8 @@ int PKCS5_v2_PBE_keyivgen(EVP_CIPHER_CTX *ctx, const char *pass, int passlen,
155 PBE2PARAM *pbe2 = NULL; 175 PBE2PARAM *pbe2 = NULL;
156 const EVP_CIPHER *cipher; 176 const EVP_CIPHER *cipher;
157 PBKDF2PARAM *kdf = NULL; 177 PBKDF2PARAM *kdf = NULL;
178 const EVP_MD *prfmd;
179 int prf_nid, hmac_md_nid;
158 180
159 if (param == NULL || param->type != V_ASN1_SEQUENCE || 181 if (param == NULL || param->type != V_ASN1_SEQUENCE ||
160 param->value.sequence == NULL) { 182 param->value.sequence == NULL) {
@@ -180,8 +202,7 @@ int PKCS5_v2_PBE_keyivgen(EVP_CIPHER_CTX *ctx, const char *pass, int passlen,
180 /* lets see if we recognise the encryption algorithm. 202 /* lets see if we recognise the encryption algorithm.
181 */ 203 */
182 204
183 cipher = EVP_get_cipherbyname( 205 cipher = EVP_get_cipherbyobj(pbe2->encryption->algorithm);
184 OBJ_nid2sn(OBJ_obj2nid(pbe2->encryption->algorithm)));
185 206
186 if(!cipher) { 207 if(!cipher) {
187 EVPerr(EVP_F_PKCS5_V2_PBE_KEYIVGEN, 208 EVPerr(EVP_F_PKCS5_V2_PBE_KEYIVGEN,
@@ -226,10 +247,23 @@ int PKCS5_v2_PBE_keyivgen(EVP_CIPHER_CTX *ctx, const char *pass, int passlen,
226 goto err; 247 goto err;
227 } 248 }
228 249
229 if(kdf->prf && (OBJ_obj2nid(kdf->prf->algorithm) != NID_hmacWithSHA1)) { 250 if (kdf->prf)
251 prf_nid = OBJ_obj2nid(kdf->prf->algorithm);
252 else
253 prf_nid = NID_hmacWithSHA1;
254
255 if (!EVP_PBE_find(EVP_PBE_TYPE_PRF, prf_nid, NULL, &hmac_md_nid, 0))
256 {
230 EVPerr(EVP_F_PKCS5_V2_PBE_KEYIVGEN, EVP_R_UNSUPPORTED_PRF); 257 EVPerr(EVP_F_PKCS5_V2_PBE_KEYIVGEN, EVP_R_UNSUPPORTED_PRF);
231 goto err; 258 goto err;
232 } 259 }
260
261 prfmd = EVP_get_digestbynid(hmac_md_nid);
262 if (prfmd == NULL)
263 {
264 EVPerr(EVP_F_PKCS5_V2_PBE_KEYIVGEN, EVP_R_UNSUPPORTED_PRF);
265 goto err;
266 }
233 267
234 if(kdf->salt->type != V_ASN1_OCTET_STRING) { 268 if(kdf->salt->type != V_ASN1_OCTET_STRING) {
235 EVPerr(EVP_F_PKCS5_V2_PBE_KEYIVGEN, 269 EVPerr(EVP_F_PKCS5_V2_PBE_KEYIVGEN,
@@ -241,7 +275,9 @@ int PKCS5_v2_PBE_keyivgen(EVP_CIPHER_CTX *ctx, const char *pass, int passlen,
241 salt = kdf->salt->value.octet_string->data; 275 salt = kdf->salt->value.octet_string->data;
242 saltlen = kdf->salt->value.octet_string->length; 276 saltlen = kdf->salt->value.octet_string->length;
243 iter = ASN1_INTEGER_get(kdf->iter); 277 iter = ASN1_INTEGER_get(kdf->iter);
244 PKCS5_PBKDF2_HMAC_SHA1(pass, passlen, salt, saltlen, iter, keylen, key); 278 if(!PKCS5_PBKDF2_HMAC(pass, passlen, salt, saltlen, iter, prfmd,
279 keylen, key))
280 goto err;
245 EVP_CipherInit_ex(ctx, NULL, NULL, key, NULL, en_de); 281 EVP_CipherInit_ex(ctx, NULL, NULL, key, NULL, en_de);
246 OPENSSL_cleanse(key, keylen); 282 OPENSSL_cleanse(key, keylen);
247 PBKDF2PARAM_free(kdf); 283 PBKDF2PARAM_free(kdf);
diff --git a/src/lib/libcrypto/evp/p_dec.c b/src/lib/libcrypto/evp/p_dec.c
index f64901f653..4201dcbad9 100644
--- a/src/lib/libcrypto/evp/p_dec.c
+++ b/src/lib/libcrypto/evp/p_dec.c
@@ -66,7 +66,7 @@
66#include <openssl/objects.h> 66#include <openssl/objects.h>
67#include <openssl/x509.h> 67#include <openssl/x509.h>
68 68
69int EVP_PKEY_decrypt(unsigned char *key, const unsigned char *ek, int ekl, 69int EVP_PKEY_decrypt_old(unsigned char *key, const unsigned char *ek, int ekl,
70 EVP_PKEY *priv) 70 EVP_PKEY *priv)
71 { 71 {
72 int ret= -1; 72 int ret= -1;
@@ -75,7 +75,7 @@ int EVP_PKEY_decrypt(unsigned char *key, const unsigned char *ek, int ekl,
75 if (priv->type != EVP_PKEY_RSA) 75 if (priv->type != EVP_PKEY_RSA)
76 { 76 {
77#endif 77#endif
78 EVPerr(EVP_F_EVP_PKEY_DECRYPT,EVP_R_PUBLIC_KEY_NOT_RSA); 78 EVPerr(EVP_F_EVP_PKEY_DECRYPT_OLD,EVP_R_PUBLIC_KEY_NOT_RSA);
79#ifndef OPENSSL_NO_RSA 79#ifndef OPENSSL_NO_RSA
80 goto err; 80 goto err;
81 } 81 }
diff --git a/src/lib/libcrypto/evp/p_enc.c b/src/lib/libcrypto/evp/p_enc.c
index c2dfdc52ad..b5a3a84c41 100644
--- a/src/lib/libcrypto/evp/p_enc.c
+++ b/src/lib/libcrypto/evp/p_enc.c
@@ -66,7 +66,7 @@
66#include <openssl/objects.h> 66#include <openssl/objects.h>
67#include <openssl/x509.h> 67#include <openssl/x509.h>
68 68
69int EVP_PKEY_encrypt(unsigned char *ek, const unsigned char *key, int key_len, 69int EVP_PKEY_encrypt_old(unsigned char *ek, const unsigned char *key, int key_len,
70 EVP_PKEY *pubk) 70 EVP_PKEY *pubk)
71 { 71 {
72 int ret=0; 72 int ret=0;
@@ -75,7 +75,7 @@ int EVP_PKEY_encrypt(unsigned char *ek, const unsigned char *key, int key_len,
75 if (pubk->type != EVP_PKEY_RSA) 75 if (pubk->type != EVP_PKEY_RSA)
76 { 76 {
77#endif 77#endif
78 EVPerr(EVP_F_EVP_PKEY_ENCRYPT,EVP_R_PUBLIC_KEY_NOT_RSA); 78 EVPerr(EVP_F_EVP_PKEY_ENCRYPT_OLD,EVP_R_PUBLIC_KEY_NOT_RSA);
79#ifndef OPENSSL_NO_RSA 79#ifndef OPENSSL_NO_RSA
80 goto err; 80 goto err;
81 } 81 }
diff --git a/src/lib/libcrypto/evp/p_lib.c b/src/lib/libcrypto/evp/p_lib.c
index 22155ecf62..1916c61699 100644
--- a/src/lib/libcrypto/evp/p_lib.c
+++ b/src/lib/libcrypto/evp/p_lib.c
@@ -74,66 +74,26 @@
74#include <openssl/dh.h> 74#include <openssl/dh.h>
75#endif 75#endif
76 76
77#ifndef OPENSSL_NO_ENGINE
78#include <openssl/engine.h>
79#endif
80
81#include "asn1_locl.h"
82
77static void EVP_PKEY_free_it(EVP_PKEY *x); 83static void EVP_PKEY_free_it(EVP_PKEY *x);
78 84
79int EVP_PKEY_bits(EVP_PKEY *pkey) 85int EVP_PKEY_bits(EVP_PKEY *pkey)
80 { 86 {
81 if (0) 87 if (pkey && pkey->ameth && pkey->ameth->pkey_bits)
82 return 0; 88 return pkey->ameth->pkey_bits(pkey);
83#ifndef OPENSSL_NO_RSA 89 return 0;
84 else if (pkey->type == EVP_PKEY_RSA)
85 return(BN_num_bits(pkey->pkey.rsa->n));
86#endif
87#ifndef OPENSSL_NO_DSA
88 else if (pkey->type == EVP_PKEY_DSA)
89 return(BN_num_bits(pkey->pkey.dsa->p));
90#endif
91#ifndef OPENSSL_NO_EC
92 else if (pkey->type == EVP_PKEY_EC)
93 {
94 BIGNUM *order = BN_new();
95 const EC_GROUP *group;
96 int ret;
97
98 if (!order)
99 {
100 ERR_clear_error();
101 return 0;
102 }
103 group = EC_KEY_get0_group(pkey->pkey.ec);
104 if (!EC_GROUP_get_order(group, order, NULL))
105 {
106 ERR_clear_error();
107 return 0;
108 }
109
110 ret = BN_num_bits(order);
111 BN_free(order);
112 return ret;
113 }
114#endif
115 return(0);
116 } 90 }
117 91
118int EVP_PKEY_size(EVP_PKEY *pkey) 92int EVP_PKEY_size(EVP_PKEY *pkey)
119 { 93 {
120 if (pkey == NULL) 94 if (pkey && pkey->ameth && pkey->ameth->pkey_size)
121 return(0); 95 return pkey->ameth->pkey_size(pkey);
122#ifndef OPENSSL_NO_RSA 96 return 0;
123 if (pkey->type == EVP_PKEY_RSA)
124 return(RSA_size(pkey->pkey.rsa));
125 else
126#endif
127#ifndef OPENSSL_NO_DSA
128 if (pkey->type == EVP_PKEY_DSA)
129 return(DSA_size(pkey->pkey.dsa));
130#endif
131#ifndef OPENSSL_NO_ECDSA
132 if (pkey->type == EVP_PKEY_EC)
133 return(ECDSA_size(pkey->pkey.ec));
134#endif
135
136 return(0);
137 } 97 }
138 98
139int EVP_PKEY_save_parameters(EVP_PKEY *pkey, int mode) 99int EVP_PKEY_save_parameters(EVP_PKEY *pkey, int mode)
@@ -174,88 +134,26 @@ int EVP_PKEY_copy_parameters(EVP_PKEY *to, const EVP_PKEY *from)
174 EVPerr(EVP_F_EVP_PKEY_COPY_PARAMETERS,EVP_R_MISSING_PARAMETERS); 134 EVPerr(EVP_F_EVP_PKEY_COPY_PARAMETERS,EVP_R_MISSING_PARAMETERS);
175 goto err; 135 goto err;
176 } 136 }
177#ifndef OPENSSL_NO_DSA 137 if (from->ameth && from->ameth->param_copy)
178 if (to->type == EVP_PKEY_DSA) 138 return from->ameth->param_copy(to, from);
179 {
180 BIGNUM *a;
181
182 if ((a=BN_dup(from->pkey.dsa->p)) == NULL) goto err;
183 if (to->pkey.dsa->p != NULL) BN_free(to->pkey.dsa->p);
184 to->pkey.dsa->p=a;
185
186 if ((a=BN_dup(from->pkey.dsa->q)) == NULL) goto err;
187 if (to->pkey.dsa->q != NULL) BN_free(to->pkey.dsa->q);
188 to->pkey.dsa->q=a;
189
190 if ((a=BN_dup(from->pkey.dsa->g)) == NULL) goto err;
191 if (to->pkey.dsa->g != NULL) BN_free(to->pkey.dsa->g);
192 to->pkey.dsa->g=a;
193 }
194#endif
195#ifndef OPENSSL_NO_EC
196 if (to->type == EVP_PKEY_EC)
197 {
198 EC_GROUP *group = EC_GROUP_dup(EC_KEY_get0_group(from->pkey.ec));
199 if (group == NULL)
200 goto err;
201 if (EC_KEY_set_group(to->pkey.ec, group) == 0)
202 goto err;
203 EC_GROUP_free(group);
204 }
205#endif
206 return(1);
207err: 139err:
208 return(0); 140 return 0;
209 } 141 }
210 142
211int EVP_PKEY_missing_parameters(const EVP_PKEY *pkey) 143int EVP_PKEY_missing_parameters(const EVP_PKEY *pkey)
212 { 144 {
213#ifndef OPENSSL_NO_DSA 145 if (pkey->ameth && pkey->ameth->param_missing)
214 if (pkey->type == EVP_PKEY_DSA) 146 return pkey->ameth->param_missing(pkey);
215 { 147 return 0;
216 DSA *dsa;
217
218 dsa=pkey->pkey.dsa;
219 if ((dsa->p == NULL) || (dsa->q == NULL) || (dsa->g == NULL))
220 return(1);
221 }
222#endif
223#ifndef OPENSSL_NO_EC
224 if (pkey->type == EVP_PKEY_EC)
225 {
226 if (EC_KEY_get0_group(pkey->pkey.ec) == NULL)
227 return(1);
228 }
229#endif
230
231 return(0);
232 } 148 }
233 149
234int EVP_PKEY_cmp_parameters(const EVP_PKEY *a, const EVP_PKEY *b) 150int EVP_PKEY_cmp_parameters(const EVP_PKEY *a, const EVP_PKEY *b)
235 { 151 {
236#ifndef OPENSSL_NO_DSA 152 if (a->type != b->type)
237 if ((a->type == EVP_PKEY_DSA) && (b->type == EVP_PKEY_DSA)) 153 return -1;
238 { 154 if (a->ameth && a->ameth->param_cmp)
239 if ( BN_cmp(a->pkey.dsa->p,b->pkey.dsa->p) || 155 return a->ameth->param_cmp(a, b);
240 BN_cmp(a->pkey.dsa->q,b->pkey.dsa->q) || 156 return -2;
241 BN_cmp(a->pkey.dsa->g,b->pkey.dsa->g))
242 return(0);
243 else
244 return(1);
245 }
246#endif
247#ifndef OPENSSL_NO_EC
248 if (a->type == EVP_PKEY_EC && b->type == EVP_PKEY_EC)
249 {
250 const EC_GROUP *group_a = EC_KEY_get0_group(a->pkey.ec),
251 *group_b = EC_KEY_get0_group(b->pkey.ec);
252 if (EC_GROUP_cmp(group_a, group_b, NULL))
253 return 0;
254 else
255 return 1;
256 }
257#endif
258 return(-1);
259 } 157 }
260 158
261int EVP_PKEY_cmp(const EVP_PKEY *a, const EVP_PKEY *b) 159int EVP_PKEY_cmp(const EVP_PKEY *a, const EVP_PKEY *b)
@@ -263,51 +161,22 @@ int EVP_PKEY_cmp(const EVP_PKEY *a, const EVP_PKEY *b)
263 if (a->type != b->type) 161 if (a->type != b->type)
264 return -1; 162 return -1;
265 163
266 if (EVP_PKEY_cmp_parameters(a, b) == 0) 164 if (a->ameth)
267 return 0;
268
269 switch (a->type)
270 { 165 {
271#ifndef OPENSSL_NO_RSA 166 int ret;
272 case EVP_PKEY_RSA: 167 /* Compare parameters if the algorithm has them */
273 if (BN_cmp(b->pkey.rsa->n,a->pkey.rsa->n) != 0 168 if (a->ameth->param_cmp)
274 || BN_cmp(b->pkey.rsa->e,a->pkey.rsa->e) != 0)
275 return 0;
276 break;
277#endif
278#ifndef OPENSSL_NO_DSA
279 case EVP_PKEY_DSA:
280 if (BN_cmp(b->pkey.dsa->pub_key,a->pkey.dsa->pub_key) != 0)
281 return 0;
282 break;
283#endif
284#ifndef OPENSSL_NO_EC
285 case EVP_PKEY_EC:
286 {
287 int r;
288 const EC_GROUP *group = EC_KEY_get0_group(b->pkey.ec);
289 const EC_POINT *pa = EC_KEY_get0_public_key(a->pkey.ec),
290 *pb = EC_KEY_get0_public_key(b->pkey.ec);
291 r = EC_POINT_cmp(group, pa, pb, NULL);
292 if (r != 0)
293 { 169 {
294 if (r == 1) 170 ret = a->ameth->param_cmp(a, b);
295 return 0; 171 if (ret <= 0)
296 else 172 return ret;
297 return -2;
298 } 173 }
299 } 174
300 break; 175 if (a->ameth->pub_cmp)
301#endif 176 return a->ameth->pub_cmp(a, b);
302#ifndef OPENSSL_NO_DH
303 case EVP_PKEY_DH:
304 return -2;
305#endif
306 default:
307 return -2;
308 } 177 }
309 178
310 return 1; 179 return -2;
311 } 180 }
312 181
313EVP_PKEY *EVP_PKEY_new(void) 182EVP_PKEY *EVP_PKEY_new(void)
@@ -321,22 +190,87 @@ EVP_PKEY *EVP_PKEY_new(void)
321 return(NULL); 190 return(NULL);
322 } 191 }
323 ret->type=EVP_PKEY_NONE; 192 ret->type=EVP_PKEY_NONE;
193 ret->save_type=EVP_PKEY_NONE;
324 ret->references=1; 194 ret->references=1;
195 ret->ameth=NULL;
196 ret->engine=NULL;
325 ret->pkey.ptr=NULL; 197 ret->pkey.ptr=NULL;
326 ret->attributes=NULL; 198 ret->attributes=NULL;
327 ret->save_parameters=1; 199 ret->save_parameters=1;
328 return(ret); 200 return(ret);
329 } 201 }
330 202
331int EVP_PKEY_assign(EVP_PKEY *pkey, int type, char *key) 203/* Setup a public key ASN1 method and ENGINE from a NID or a string.
204 * If pkey is NULL just return 1 or 0 if the algorithm exists.
205 */
206
207static int pkey_set_type(EVP_PKEY *pkey, int type, const char *str, int len)
332 { 208 {
333 if (pkey == NULL) return(0); 209 const EVP_PKEY_ASN1_METHOD *ameth;
334 if (pkey->pkey.ptr != NULL) 210 ENGINE *e = NULL;
335 EVP_PKEY_free_it(pkey); 211 if (pkey)
336 pkey->type=EVP_PKEY_type(type); 212 {
337 pkey->save_type=type; 213 if (pkey->pkey.ptr)
214 EVP_PKEY_free_it(pkey);
215 /* If key type matches and a method exists then this
216 * lookup has succeeded once so just indicate success.
217 */
218 if ((type == pkey->save_type) && pkey->ameth)
219 return 1;
220#ifndef OPENSSL_NO_ENGINE
221 /* If we have an ENGINE release it */
222 if (pkey->engine)
223 {
224 ENGINE_finish(pkey->engine);
225 pkey->engine = NULL;
226 }
227#endif
228 }
229 if (str)
230 ameth = EVP_PKEY_asn1_find_str(&e, str, len);
231 else
232 ameth = EVP_PKEY_asn1_find(&e, type);
233#ifndef OPENSSL_NO_ENGINE
234 if (!pkey && e)
235 ENGINE_finish(e);
236#endif
237 if (!ameth)
238 {
239 EVPerr(EVP_F_PKEY_SET_TYPE, EVP_R_UNSUPPORTED_ALGORITHM);
240 return 0;
241 }
242 if (pkey)
243 {
244 pkey->ameth = ameth;
245 pkey->engine = e;
246
247 pkey->type = pkey->ameth->pkey_id;
248 pkey->save_type=type;
249 }
250 return 1;
251 }
252
253int EVP_PKEY_set_type(EVP_PKEY *pkey, int type)
254 {
255 return pkey_set_type(pkey, type, NULL, -1);
256 }
257
258int EVP_PKEY_set_type_str(EVP_PKEY *pkey, const char *str, int len)
259 {
260 return pkey_set_type(pkey, EVP_PKEY_NONE, str, len);
261 }
262
263int EVP_PKEY_assign(EVP_PKEY *pkey, int type, void *key)
264 {
265 if (!EVP_PKEY_set_type(pkey, type))
266 return 0;
338 pkey->pkey.ptr=key; 267 pkey->pkey.ptr=key;
339 return(key != NULL); 268 return (key != NULL);
269 }
270
271void *EVP_PKEY_get0(EVP_PKEY *pkey)
272 {
273 return pkey->pkey.ptr;
340 } 274 }
341 275
342#ifndef OPENSSL_NO_RSA 276#ifndef OPENSSL_NO_RSA
@@ -425,24 +359,29 @@ DH *EVP_PKEY_get1_DH(EVP_PKEY *pkey)
425 359
426int EVP_PKEY_type(int type) 360int EVP_PKEY_type(int type)
427 { 361 {
428 switch (type) 362 int ret;
429 { 363 const EVP_PKEY_ASN1_METHOD *ameth;
430 case EVP_PKEY_RSA: 364 ENGINE *e;
431 case EVP_PKEY_RSA2: 365 ameth = EVP_PKEY_asn1_find(&e, type);
432 return(EVP_PKEY_RSA); 366 if (ameth)
433 case EVP_PKEY_DSA: 367 ret = ameth->pkey_id;
434 case EVP_PKEY_DSA1: 368 else
435 case EVP_PKEY_DSA2: 369 ret = NID_undef;
436 case EVP_PKEY_DSA3: 370#ifndef OPENSSL_NO_ENGINE
437 case EVP_PKEY_DSA4: 371 if (e)
438 return(EVP_PKEY_DSA); 372 ENGINE_finish(e);
439 case EVP_PKEY_DH: 373#endif
440 return(EVP_PKEY_DH); 374 return ret;
441 case EVP_PKEY_EC: 375 }
442 return(EVP_PKEY_EC); 376
443 default: 377int EVP_PKEY_id(const EVP_PKEY *pkey)
444 return(NID_undef); 378 {
445 } 379 return pkey->type;
380 }
381
382int EVP_PKEY_base_id(const EVP_PKEY *pkey)
383 {
384 return EVP_PKEY_type(pkey->type);
446 } 385 }
447 386
448void EVP_PKEY_free(EVP_PKEY *x) 387void EVP_PKEY_free(EVP_PKEY *x)
@@ -471,32 +410,57 @@ void EVP_PKEY_free(EVP_PKEY *x)
471 410
472static void EVP_PKEY_free_it(EVP_PKEY *x) 411static void EVP_PKEY_free_it(EVP_PKEY *x)
473 { 412 {
474 switch (x->type) 413 if (x->ameth && x->ameth->pkey_free)
414 x->ameth->pkey_free(x);
415#ifndef OPENSSL_NO_ENGINE
416 if (x->engine)
475 { 417 {
476#ifndef OPENSSL_NO_RSA 418 ENGINE_finish(x->engine);
477 case EVP_PKEY_RSA: 419 x->engine = NULL;
478 case EVP_PKEY_RSA2:
479 RSA_free(x->pkey.rsa);
480 break;
481#endif
482#ifndef OPENSSL_NO_DSA
483 case EVP_PKEY_DSA:
484 case EVP_PKEY_DSA2:
485 case EVP_PKEY_DSA3:
486 case EVP_PKEY_DSA4:
487 DSA_free(x->pkey.dsa);
488 break;
489#endif
490#ifndef OPENSSL_NO_EC
491 case EVP_PKEY_EC:
492 EC_KEY_free(x->pkey.ec);
493 break;
494#endif
495#ifndef OPENSSL_NO_DH
496 case EVP_PKEY_DH:
497 DH_free(x->pkey.dh);
498 break;
499#endif
500 } 420 }
421#endif
422 }
423
424static int unsup_alg(BIO *out, const EVP_PKEY *pkey, int indent,
425 const char *kstr)
426 {
427 BIO_indent(out, indent, 128);
428 BIO_printf(out, "%s algorithm \"%s\" unsupported\n",
429 kstr, OBJ_nid2ln(pkey->type));
430 return 1;
431 }
432
433int EVP_PKEY_print_public(BIO *out, const EVP_PKEY *pkey,
434 int indent, ASN1_PCTX *pctx)
435 {
436 if (pkey->ameth && pkey->ameth->pub_print)
437 return pkey->ameth->pub_print(out, pkey, indent, pctx);
438
439 return unsup_alg(out, pkey, indent, "Public Key");
440 }
441
442int EVP_PKEY_print_private(BIO *out, const EVP_PKEY *pkey,
443 int indent, ASN1_PCTX *pctx)
444 {
445 if (pkey->ameth && pkey->ameth->priv_print)
446 return pkey->ameth->priv_print(out, pkey, indent, pctx);
447
448 return unsup_alg(out, pkey, indent, "Private Key");
449 }
450
451int EVP_PKEY_print_params(BIO *out, const EVP_PKEY *pkey,
452 int indent, ASN1_PCTX *pctx)
453 {
454 if (pkey->ameth && pkey->ameth->param_print)
455 return pkey->ameth->param_print(out, pkey, indent, pctx);
456 return unsup_alg(out, pkey, indent, "Parameters");
457 }
458
459int EVP_PKEY_get_default_digest_nid(EVP_PKEY *pkey, int *pnid)
460 {
461 if (!pkey->ameth || !pkey->ameth->pkey_ctrl)
462 return -2;
463 return pkey->ameth->pkey_ctrl(pkey, ASN1_PKEY_CTRL_DEFAULT_MD_NID,
464 0, pnid);
501 } 465 }
502 466
diff --git a/src/lib/libcrypto/evp/p_open.c b/src/lib/libcrypto/evp/p_open.c
index 9935206d0f..53a59a295c 100644
--- a/src/lib/libcrypto/evp/p_open.c
+++ b/src/lib/libcrypto/evp/p_open.c
@@ -95,7 +95,7 @@ int EVP_OpenInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *type,
95 goto err; 95 goto err;
96 } 96 }
97 97
98 i=EVP_PKEY_decrypt(key,ek,ekl,priv); 98 i=EVP_PKEY_decrypt_old(key,ek,ekl,priv);
99 if ((i <= 0) || !EVP_CIPHER_CTX_set_key_length(ctx, i)) 99 if ((i <= 0) || !EVP_CIPHER_CTX_set_key_length(ctx, i))
100 { 100 {
101 /* ERROR */ 101 /* ERROR */
diff --git a/src/lib/libcrypto/evp/p_seal.c b/src/lib/libcrypto/evp/p_seal.c
index 8cc8fcb0bd..d8324526e7 100644
--- a/src/lib/libcrypto/evp/p_seal.c
+++ b/src/lib/libcrypto/evp/p_seal.c
@@ -87,7 +87,7 @@ int EVP_SealInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *type, unsigned char **ek
87 87
88 for (i=0; i<npubk; i++) 88 for (i=0; i<npubk; i++)
89 { 89 {
90 ekl[i]=EVP_PKEY_encrypt(ek[i],key,EVP_CIPHER_CTX_key_length(ctx), 90 ekl[i]=EVP_PKEY_encrypt_old(ek[i],key,EVP_CIPHER_CTX_key_length(ctx),
91 pubk[i]); 91 pubk[i]);
92 if (ekl[i] <= 0) return(-1); 92 if (ekl[i] <= 0) return(-1);
93 } 93 }
diff --git a/src/lib/libcrypto/evp/p_sign.c b/src/lib/libcrypto/evp/p_sign.c
index bf41a0db68..8df6d48a7e 100644
--- a/src/lib/libcrypto/evp/p_sign.c
+++ b/src/lib/libcrypto/evp/p_sign.c
@@ -84,6 +84,32 @@ int EVP_SignFinal(EVP_MD_CTX *ctx, unsigned char *sigret, unsigned int *siglen,
84 MS_STATIC EVP_MD_CTX tmp_ctx; 84 MS_STATIC EVP_MD_CTX tmp_ctx;
85 85
86 *siglen=0; 86 *siglen=0;
87 EVP_MD_CTX_init(&tmp_ctx);
88 EVP_MD_CTX_copy_ex(&tmp_ctx,ctx);
89 EVP_DigestFinal_ex(&tmp_ctx,&(m[0]),&m_len);
90 EVP_MD_CTX_cleanup(&tmp_ctx);
91
92 if (ctx->digest->flags & EVP_MD_FLAG_PKEY_METHOD_SIGNATURE)
93 {
94 EVP_PKEY_CTX *pkctx = NULL;
95 size_t sltmp = (size_t)EVP_PKEY_size(pkey);
96 i = 0;
97 pkctx = EVP_PKEY_CTX_new(pkey, NULL);
98 if (!pkctx)
99 goto err;
100 if (EVP_PKEY_sign_init(pkctx) <= 0)
101 goto err;
102 if (EVP_PKEY_CTX_set_signature_md(pkctx, ctx->digest) <= 0)
103 goto err;
104 if (EVP_PKEY_sign(pkctx, sigret, &sltmp, m, m_len) <= 0)
105 goto err;
106 *siglen = sltmp;
107 i = 1;
108 err:
109 EVP_PKEY_CTX_free(pkctx);
110 return i;
111 }
112
87 for (i=0; i<4; i++) 113 for (i=0; i<4; i++)
88 { 114 {
89 v=ctx->digest->required_pkey_type[i]; 115 v=ctx->digest->required_pkey_type[i];
@@ -99,28 +125,13 @@ int EVP_SignFinal(EVP_MD_CTX *ctx, unsigned char *sigret, unsigned int *siglen,
99 EVPerr(EVP_F_EVP_SIGNFINAL,EVP_R_WRONG_PUBLIC_KEY_TYPE); 125 EVPerr(EVP_F_EVP_SIGNFINAL,EVP_R_WRONG_PUBLIC_KEY_TYPE);
100 return(0); 126 return(0);
101 } 127 }
128
102 if (ctx->digest->sign == NULL) 129 if (ctx->digest->sign == NULL)
103 { 130 {
104 EVPerr(EVP_F_EVP_SIGNFINAL,EVP_R_NO_SIGN_FUNCTION_CONFIGURED); 131 EVPerr(EVP_F_EVP_SIGNFINAL,EVP_R_NO_SIGN_FUNCTION_CONFIGURED);
105 return(0); 132 return(0);
106 } 133 }
107 EVP_MD_CTX_init(&tmp_ctx); 134 return(ctx->digest->sign(ctx->digest->type,m,m_len,sigret,siglen,
108 EVP_MD_CTX_copy_ex(&tmp_ctx,ctx); 135 pkey->pkey.ptr));
109 if (ctx->digest->flags & EVP_MD_FLAG_SVCTX)
110 {
111 EVP_MD_SVCTX sctmp;
112 sctmp.mctx = &tmp_ctx;
113 sctmp.key = pkey->pkey.ptr;
114 i = ctx->digest->sign(ctx->digest->type,
115 NULL, -1, sigret, siglen, &sctmp);
116 }
117 else
118 {
119 EVP_DigestFinal_ex(&tmp_ctx,&(m[0]),&m_len);
120 i = ctx->digest->sign(ctx->digest->type,m,m_len,sigret,siglen,
121 pkey->pkey.ptr);
122 }
123 EVP_MD_CTX_cleanup(&tmp_ctx);
124 return i;
125 } 136 }
126 137
diff --git a/src/lib/libcrypto/evp/p_verify.c b/src/lib/libcrypto/evp/p_verify.c
index 2d46dffe7e..8db46412f3 100644
--- a/src/lib/libcrypto/evp/p_verify.c
+++ b/src/lib/libcrypto/evp/p_verify.c
@@ -70,6 +70,28 @@ int EVP_VerifyFinal(EVP_MD_CTX *ctx, const unsigned char *sigbuf,
70 int i,ok=0,v; 70 int i,ok=0,v;
71 MS_STATIC EVP_MD_CTX tmp_ctx; 71 MS_STATIC EVP_MD_CTX tmp_ctx;
72 72
73 EVP_MD_CTX_init(&tmp_ctx);
74 EVP_MD_CTX_copy_ex(&tmp_ctx,ctx);
75 EVP_DigestFinal_ex(&tmp_ctx,&(m[0]),&m_len);
76 EVP_MD_CTX_cleanup(&tmp_ctx);
77
78 if (ctx->digest->flags & EVP_MD_FLAG_PKEY_METHOD_SIGNATURE)
79 {
80 EVP_PKEY_CTX *pkctx = NULL;
81 i = -1;
82 pkctx = EVP_PKEY_CTX_new(pkey, NULL);
83 if (!pkctx)
84 goto err;
85 if (EVP_PKEY_verify_init(pkctx) <= 0)
86 goto err;
87 if (EVP_PKEY_CTX_set_signature_md(pkctx, ctx->digest) <= 0)
88 goto err;
89 i = EVP_PKEY_verify(pkctx, sigbuf, siglen, m, m_len);
90 err:
91 EVP_PKEY_CTX_free(pkctx);
92 return i;
93 }
94
73 for (i=0; i<4; i++) 95 for (i=0; i<4; i++)
74 { 96 {
75 v=ctx->digest->required_pkey_type[i]; 97 v=ctx->digest->required_pkey_type[i];
@@ -85,29 +107,13 @@ int EVP_VerifyFinal(EVP_MD_CTX *ctx, const unsigned char *sigbuf,
85 EVPerr(EVP_F_EVP_VERIFYFINAL,EVP_R_WRONG_PUBLIC_KEY_TYPE); 107 EVPerr(EVP_F_EVP_VERIFYFINAL,EVP_R_WRONG_PUBLIC_KEY_TYPE);
86 return(-1); 108 return(-1);
87 } 109 }
88 if (ctx->digest->verify == NULL) 110 if (ctx->digest->verify == NULL)
89 { 111 {
90 EVPerr(EVP_F_EVP_VERIFYFINAL,EVP_R_NO_VERIFY_FUNCTION_CONFIGURED); 112 EVPerr(EVP_F_EVP_VERIFYFINAL,EVP_R_NO_VERIFY_FUNCTION_CONFIGURED);
91 return(0); 113 return(0);
92 } 114 }
93 115
94 EVP_MD_CTX_init(&tmp_ctx); 116 return(ctx->digest->verify(ctx->digest->type,m,m_len,
95 EVP_MD_CTX_copy_ex(&tmp_ctx,ctx); 117 sigbuf,siglen,pkey->pkey.ptr));
96 if (ctx->digest->flags & EVP_MD_FLAG_SVCTX)
97 {
98 EVP_MD_SVCTX sctmp;
99 sctmp.mctx = &tmp_ctx;
100 sctmp.key = pkey->pkey.ptr;
101 i = ctx->digest->verify(ctx->digest->type,
102 NULL, -1, sigbuf, siglen, &sctmp);
103 }
104 else
105 {
106 EVP_DigestFinal_ex(&tmp_ctx,&(m[0]),&m_len);
107 i = ctx->digest->verify(ctx->digest->type,m,m_len,
108 sigbuf,siglen,pkey->pkey.ptr);
109 }
110 EVP_MD_CTX_cleanup(&tmp_ctx);
111 return i;
112 } 118 }
113 119
diff --git a/src/lib/libcrypto/ex_data.c b/src/lib/libcrypto/ex_data.c
index 3b11e7a556..e2bc8298d0 100644
--- a/src/lib/libcrypto/ex_data.c
+++ b/src/lib/libcrypto/ex_data.c
@@ -245,18 +245,21 @@ typedef struct st_ex_class_item {
245static int ex_class = CRYPTO_EX_INDEX_USER; 245static int ex_class = CRYPTO_EX_INDEX_USER;
246 246
247/* The global hash table of EX_CLASS_ITEM items */ 247/* The global hash table of EX_CLASS_ITEM items */
248static LHASH *ex_data = NULL; 248DECLARE_LHASH_OF(EX_CLASS_ITEM);
249static LHASH_OF(EX_CLASS_ITEM) *ex_data = NULL;
249 250
250/* The callbacks required in the "ex_data" hash table */ 251/* The callbacks required in the "ex_data" hash table */
251static unsigned long ex_hash_cb(const void *a_void) 252static unsigned long ex_class_item_hash(const EX_CLASS_ITEM *a)
252 { 253 {
253 return ((const EX_CLASS_ITEM *)a_void)->class_index; 254 return a->class_index;
254 } 255 }
255static int ex_cmp_cb(const void *a_void, const void *b_void) 256static IMPLEMENT_LHASH_HASH_FN(ex_class_item, EX_CLASS_ITEM)
257
258static int ex_class_item_cmp(const EX_CLASS_ITEM *a, const EX_CLASS_ITEM *b)
256 { 259 {
257 return (((const EX_CLASS_ITEM *)a_void)->class_index - 260 return a->class_index - b->class_index;
258 ((const EX_CLASS_ITEM *)b_void)->class_index);
259 } 261 }
262static IMPLEMENT_LHASH_COMP_FN(ex_class_item, EX_CLASS_ITEM)
260 263
261/* Internal functions used by the "impl_default" implementation to access the 264/* Internal functions used by the "impl_default" implementation to access the
262 * state */ 265 * state */
@@ -265,7 +268,8 @@ static int ex_data_check(void)
265 { 268 {
266 int toret = 1; 269 int toret = 1;
267 CRYPTO_w_lock(CRYPTO_LOCK_EX_DATA); 270 CRYPTO_w_lock(CRYPTO_LOCK_EX_DATA);
268 if(!ex_data && ((ex_data = lh_new(ex_hash_cb, ex_cmp_cb)) == NULL)) 271 if(!ex_data
272 && (ex_data = lh_EX_CLASS_ITEM_new()) == NULL)
269 toret = 0; 273 toret = 0;
270 CRYPTO_w_unlock(CRYPTO_LOCK_EX_DATA); 274 CRYPTO_w_unlock(CRYPTO_LOCK_EX_DATA);
271 return toret; 275 return toret;
@@ -298,7 +302,7 @@ static EX_CLASS_ITEM *def_get_class(int class_index)
298 EX_DATA_CHECK(return NULL;) 302 EX_DATA_CHECK(return NULL;)
299 d.class_index = class_index; 303 d.class_index = class_index;
300 CRYPTO_w_lock(CRYPTO_LOCK_EX_DATA); 304 CRYPTO_w_lock(CRYPTO_LOCK_EX_DATA);
301 p = lh_retrieve(ex_data, &d); 305 p = lh_EX_CLASS_ITEM_retrieve(ex_data, &d);
302 if(!p) 306 if(!p)
303 { 307 {
304 gen = OPENSSL_malloc(sizeof(EX_CLASS_ITEM)); 308 gen = OPENSSL_malloc(sizeof(EX_CLASS_ITEM));
@@ -313,7 +317,7 @@ static EX_CLASS_ITEM *def_get_class(int class_index)
313 { 317 {
314 /* Because we're inside the ex_data lock, the 318 /* Because we're inside the ex_data lock, the
315 * return value from the insert will be NULL */ 319 * return value from the insert will be NULL */
316 lh_insert(ex_data, gen); 320 (void)lh_EX_CLASS_ITEM_insert(ex_data, gen);
317 p = gen; 321 p = gen;
318 } 322 }
319 } 323 }
@@ -375,8 +379,8 @@ static int int_new_class(void)
375static void int_cleanup(void) 379static void int_cleanup(void)
376 { 380 {
377 EX_DATA_CHECK(return;) 381 EX_DATA_CHECK(return;)
378 lh_doall(ex_data, def_cleanup_cb); 382 lh_EX_CLASS_ITEM_doall(ex_data, def_cleanup_cb);
379 lh_free(ex_data); 383 lh_EX_CLASS_ITEM_free(ex_data);
380 ex_data = NULL; 384 ex_data = NULL;
381 impl = NULL; 385 impl = NULL;
382 } 386 }
@@ -452,7 +456,7 @@ static int int_dup_ex_data(int class_index, CRYPTO_EX_DATA *to,
452 return 0; 456 return 0;
453 CRYPTO_r_lock(CRYPTO_LOCK_EX_DATA); 457 CRYPTO_r_lock(CRYPTO_LOCK_EX_DATA);
454 mx = sk_CRYPTO_EX_DATA_FUNCS_num(item->meth); 458 mx = sk_CRYPTO_EX_DATA_FUNCS_num(item->meth);
455 j = sk_num(from->sk); 459 j = sk_void_num(from->sk);
456 if(j < mx) 460 if(j < mx)
457 mx = j; 461 mx = j;
458 if(mx > 0) 462 if(mx > 0)
@@ -523,7 +527,7 @@ skip:
523 OPENSSL_free(storage); 527 OPENSSL_free(storage);
524 if(ad->sk) 528 if(ad->sk)
525 { 529 {
526 sk_free(ad->sk); 530 sk_void_free(ad->sk);
527 ad->sk=NULL; 531 ad->sk=NULL;
528 } 532 }
529 } 533 }
@@ -596,24 +600,24 @@ int CRYPTO_set_ex_data(CRYPTO_EX_DATA *ad, int idx, void *val)
596 600
597 if (ad->sk == NULL) 601 if (ad->sk == NULL)
598 { 602 {
599 if ((ad->sk=sk_new_null()) == NULL) 603 if ((ad->sk=sk_void_new_null()) == NULL)
600 { 604 {
601 CRYPTOerr(CRYPTO_F_CRYPTO_SET_EX_DATA,ERR_R_MALLOC_FAILURE); 605 CRYPTOerr(CRYPTO_F_CRYPTO_SET_EX_DATA,ERR_R_MALLOC_FAILURE);
602 return(0); 606 return(0);
603 } 607 }
604 } 608 }
605 i=sk_num(ad->sk); 609 i=sk_void_num(ad->sk);
606 610
607 while (i <= idx) 611 while (i <= idx)
608 { 612 {
609 if (!sk_push(ad->sk,NULL)) 613 if (!sk_void_push(ad->sk,NULL))
610 { 614 {
611 CRYPTOerr(CRYPTO_F_CRYPTO_SET_EX_DATA,ERR_R_MALLOC_FAILURE); 615 CRYPTOerr(CRYPTO_F_CRYPTO_SET_EX_DATA,ERR_R_MALLOC_FAILURE);
612 return(0); 616 return(0);
613 } 617 }
614 i++; 618 i++;
615 } 619 }
616 sk_set(ad->sk,idx,val); 620 sk_void_set(ad->sk,idx,val);
617 return(1); 621 return(1);
618 } 622 }
619 623
@@ -623,10 +627,10 @@ void *CRYPTO_get_ex_data(const CRYPTO_EX_DATA *ad, int idx)
623 { 627 {
624 if (ad->sk == NULL) 628 if (ad->sk == NULL)
625 return(0); 629 return(0);
626 else if (idx >= sk_num(ad->sk)) 630 else if (idx >= sk_void_num(ad->sk))
627 return(0); 631 return(0);
628 else 632 else
629 return(sk_value(ad->sk,idx)); 633 return(sk_void_value(ad->sk,idx));
630 } 634 }
631 635
632IMPLEMENT_STACK_OF(CRYPTO_EX_DATA_FUNCS) 636IMPLEMENT_STACK_OF(CRYPTO_EX_DATA_FUNCS)
diff --git a/src/lib/libcrypto/fips_err.c b/src/lib/libcrypto/fips_err.c
deleted file mode 100644
index 09f11748f6..0000000000
--- a/src/lib/libcrypto/fips_err.c
+++ /dev/null
@@ -1,7 +0,0 @@
1#include <openssl/opensslconf.h>
2
3#ifdef OPENSSL_FIPS
4# include "fips_err.h"
5#else
6static void *dummy=&dummy;
7#endif
diff --git a/src/lib/libcrypto/fips_err.h b/src/lib/libcrypto/fips_err.h
deleted file mode 100644
index b328616858..0000000000
--- a/src/lib/libcrypto/fips_err.h
+++ /dev/null
@@ -1,137 +0,0 @@
1/* crypto/fips_err.h */
2/* ====================================================================
3 * Copyright (c) 1999-2007 The OpenSSL Project. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 *
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in
14 * the documentation and/or other materials provided with the
15 * distribution.
16 *
17 * 3. All advertising materials mentioning features or use of this
18 * software must display the following acknowledgment:
19 * "This product includes software developed by the OpenSSL Project
20 * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
21 *
22 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
23 * endorse or promote products derived from this software without
24 * prior written permission. For written permission, please contact
25 * openssl-core@OpenSSL.org.
26 *
27 * 5. Products derived from this software may not be called "OpenSSL"
28 * nor may "OpenSSL" appear in their names without prior written
29 * permission of the OpenSSL Project.
30 *
31 * 6. Redistributions of any form whatsoever must retain the following
32 * acknowledgment:
33 * "This product includes software developed by the OpenSSL Project
34 * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
35 *
36 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
37 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
38 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
39 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
40 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
41 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
42 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
43 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
44 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
45 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
46 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
47 * OF THE POSSIBILITY OF SUCH DAMAGE.
48 * ====================================================================
49 *
50 * This product includes cryptographic software written by Eric Young
51 * (eay@cryptsoft.com). This product includes software written by Tim
52 * Hudson (tjh@cryptsoft.com).
53 *
54 */
55
56/* NOTE: this file was auto generated by the mkerr.pl script: any changes
57 * made to it will be overwritten when the script next updates this file,
58 * only reason strings will be preserved.
59 */
60
61#include <stdio.h>
62#include <openssl/err.h>
63#include <openssl/fips.h>
64
65/* BEGIN ERROR CODES */
66#ifndef OPENSSL_NO_ERR
67
68#define ERR_FUNC(func) ERR_PACK(ERR_LIB_FIPS,func,0)
69#define ERR_REASON(reason) ERR_PACK(ERR_LIB_FIPS,0,reason)
70
71static ERR_STRING_DATA FIPS_str_functs[]=
72 {
73{ERR_FUNC(FIPS_F_DH_BUILTIN_GENPARAMS), "DH_BUILTIN_GENPARAMS"},
74{ERR_FUNC(FIPS_F_DSA_BUILTIN_PARAMGEN), "DSA_BUILTIN_PARAMGEN"},
75{ERR_FUNC(FIPS_F_DSA_DO_SIGN), "DSA_do_sign"},
76{ERR_FUNC(FIPS_F_DSA_DO_VERIFY), "DSA_do_verify"},
77{ERR_FUNC(FIPS_F_EVP_CIPHERINIT_EX), "EVP_CipherInit_ex"},
78{ERR_FUNC(FIPS_F_EVP_DIGESTINIT_EX), "EVP_DigestInit_ex"},
79{ERR_FUNC(FIPS_F_FIPS_CHECK_DSA), "FIPS_CHECK_DSA"},
80{ERR_FUNC(FIPS_F_FIPS_CHECK_INCORE_FINGERPRINT), "FIPS_CHECK_INCORE_FINGERPRINT"},
81{ERR_FUNC(FIPS_F_FIPS_CHECK_RSA), "FIPS_CHECK_RSA"},
82{ERR_FUNC(FIPS_F_FIPS_DSA_CHECK), "FIPS_DSA_CHECK"},
83{ERR_FUNC(FIPS_F_FIPS_MODE_SET), "FIPS_mode_set"},
84{ERR_FUNC(FIPS_F_FIPS_PKEY_SIGNATURE_TEST), "fips_pkey_signature_test"},
85{ERR_FUNC(FIPS_F_FIPS_SELFTEST_AES), "FIPS_selftest_aes"},
86{ERR_FUNC(FIPS_F_FIPS_SELFTEST_DES), "FIPS_selftest_des"},
87{ERR_FUNC(FIPS_F_FIPS_SELFTEST_DSA), "FIPS_selftest_dsa"},
88{ERR_FUNC(FIPS_F_FIPS_SELFTEST_HMAC), "FIPS_selftest_hmac"},
89{ERR_FUNC(FIPS_F_FIPS_SELFTEST_RNG), "FIPS_selftest_rng"},
90{ERR_FUNC(FIPS_F_FIPS_SELFTEST_SHA1), "FIPS_selftest_sha1"},
91{ERR_FUNC(FIPS_F_HASH_FINAL), "HASH_FINAL"},
92{ERR_FUNC(FIPS_F_RSA_BUILTIN_KEYGEN), "RSA_BUILTIN_KEYGEN"},
93{ERR_FUNC(FIPS_F_RSA_EAY_PRIVATE_DECRYPT), "RSA_EAY_PRIVATE_DECRYPT"},
94{ERR_FUNC(FIPS_F_RSA_EAY_PRIVATE_ENCRYPT), "RSA_EAY_PRIVATE_ENCRYPT"},
95{ERR_FUNC(FIPS_F_RSA_EAY_PUBLIC_DECRYPT), "RSA_EAY_PUBLIC_DECRYPT"},
96{ERR_FUNC(FIPS_F_RSA_EAY_PUBLIC_ENCRYPT), "RSA_EAY_PUBLIC_ENCRYPT"},
97{ERR_FUNC(FIPS_F_RSA_X931_GENERATE_KEY_EX), "RSA_X931_generate_key_ex"},
98{ERR_FUNC(FIPS_F_SSLEAY_RAND_BYTES), "SSLEAY_RAND_BYTES"},
99{0,NULL}
100 };
101
102static ERR_STRING_DATA FIPS_str_reasons[]=
103 {
104{ERR_REASON(FIPS_R_CANNOT_READ_EXE) ,"cannot read exe"},
105{ERR_REASON(FIPS_R_CANNOT_READ_EXE_DIGEST),"cannot read exe digest"},
106{ERR_REASON(FIPS_R_CONTRADICTING_EVIDENCE),"contradicting evidence"},
107{ERR_REASON(FIPS_R_EXE_DIGEST_DOES_NOT_MATCH),"exe digest does not match"},
108{ERR_REASON(FIPS_R_FINGERPRINT_DOES_NOT_MATCH),"fingerprint does not match"},
109{ERR_REASON(FIPS_R_FINGERPRINT_DOES_NOT_MATCH_NONPIC_RELOCATED),"fingerprint does not match nonpic relocated"},
110{ERR_REASON(FIPS_R_FINGERPRINT_DOES_NOT_MATCH_SEGMENT_ALIASING),"fingerprint does not match segment aliasing"},
111{ERR_REASON(FIPS_R_FIPS_MODE_ALREADY_SET),"fips mode already set"},
112{ERR_REASON(FIPS_R_FIPS_SELFTEST_FAILED) ,"fips selftest failed"},
113{ERR_REASON(FIPS_R_INVALID_KEY_LENGTH) ,"invalid key length"},
114{ERR_REASON(FIPS_R_KEY_TOO_SHORT) ,"key too short"},
115{ERR_REASON(FIPS_R_NON_FIPS_METHOD) ,"non fips method"},
116{ERR_REASON(FIPS_R_PAIRWISE_TEST_FAILED) ,"pairwise test failed"},
117{ERR_REASON(FIPS_R_RSA_DECRYPT_ERROR) ,"rsa decrypt error"},
118{ERR_REASON(FIPS_R_RSA_ENCRYPT_ERROR) ,"rsa encrypt error"},
119{ERR_REASON(FIPS_R_SELFTEST_FAILED) ,"selftest failed"},
120{ERR_REASON(FIPS_R_TEST_FAILURE) ,"test failure"},
121{ERR_REASON(FIPS_R_UNSUPPORTED_PLATFORM) ,"unsupported platform"},
122{0,NULL}
123 };
124
125#endif
126
127void ERR_load_FIPS_strings(void)
128 {
129#ifndef OPENSSL_NO_ERR
130
131 if (ERR_func_error_string(FIPS_str_functs[0].error) == NULL)
132 {
133 ERR_load_strings(0,FIPS_str_functs);
134 ERR_load_strings(0,FIPS_str_reasons);
135 }
136#endif
137 }
diff --git a/src/lib/libcrypto/hmac/Makefile.ssl b/src/lib/libcrypto/hmac/Makefile.ssl
deleted file mode 100644
index f1c07322c4..0000000000
--- a/src/lib/libcrypto/hmac/Makefile.ssl
+++ /dev/null
@@ -1,101 +0,0 @@
1#
2# SSLeay/crypto/md/Makefile
3#
4
5DIR= hmac
6TOP= ../..
7CC= cc
8INCLUDES=
9CFLAG=-g
10INSTALL_PREFIX=
11OPENSSLDIR= /usr/local/ssl
12INSTALLTOP=/usr/local/ssl
13MAKE= make -f Makefile.ssl
14MAKEDEPPROG= makedepend
15MAKEDEPEND= $(TOP)/util/domd $(TOP) -MD $(MAKEDEPPROG)
16MAKEFILE= Makefile.ssl
17AR= ar r
18
19CFLAGS= $(INCLUDES) $(CFLAG)
20
21GENERAL=Makefile
22TEST=hmactest.c
23APPS=
24
25LIB=$(TOP)/libcrypto.a
26LIBSRC=hmac.c
27LIBOBJ=hmac.o
28
29SRC= $(LIBSRC)
30
31EXHEADER= hmac.h
32HEADER= $(EXHEADER)
33
34ALL= $(GENERAL) $(SRC) $(HEADER)
35
36top:
37 (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all)
38
39all: lib
40
41lib: $(LIBOBJ)
42 $(AR) $(LIB) $(LIBOBJ)
43 $(RANLIB) $(LIB) || echo Never mind.
44 @touch lib
45
46files:
47 $(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO
48
49links:
50 @sh $(TOP)/util/point.sh Makefile.ssl Makefile
51 @$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER)
52 @$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST)
53 @$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS)
54
55install:
56 @for i in $(EXHEADER) ; \
57 do \
58 (cp $$i $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i; \
59 chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i ); \
60 done;
61
62tags:
63 ctags $(SRC)
64
65tests:
66
67lint:
68 lint -DLINT $(INCLUDES) $(SRC)>fluff
69
70depend:
71 $(MAKEDEPEND) -- $(CFLAG) $(INCLUDES) $(DEPFLAG) -- $(PROGS) $(LIBSRC)
72
73dclean:
74 $(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
75 mv -f Makefile.new $(MAKEFILE)
76
77clean:
78 rm -f *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff
79
80# DO NOT DELETE THIS LINE -- make depend depends on it.
81
82hmac.o: ../../e_os.h ../../include/openssl/aes.h ../../include/openssl/asn1.h
83hmac.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h
84hmac.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
85hmac.o: ../../include/openssl/cast.h ../../include/openssl/crypto.h
86hmac.o: ../../include/openssl/des.h ../../include/openssl/des_old.h
87hmac.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
88hmac.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
89hmac.o: ../../include/openssl/evp.h ../../include/openssl/hmac.h
90hmac.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h
91hmac.o: ../../include/openssl/md2.h ../../include/openssl/md4.h
92hmac.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
93hmac.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
94hmac.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
95hmac.o: ../../include/openssl/ossl_typ.h ../../include/openssl/rc2.h
96hmac.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
97hmac.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
98hmac.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
99hmac.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
100hmac.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
101hmac.o: ../cryptlib.h hmac.c
diff --git a/src/lib/libcrypto/hmac/hmac.c b/src/lib/libcrypto/hmac/hmac.c
index cbc1c76a57..45015fe754 100644
--- a/src/lib/libcrypto/hmac/hmac.c
+++ b/src/lib/libcrypto/hmac/hmac.c
@@ -61,9 +61,7 @@
61#include "cryptlib.h" 61#include "cryptlib.h"
62#include <openssl/hmac.h> 62#include <openssl/hmac.h>
63 63
64#ifndef OPENSSL_FIPS 64int HMAC_Init_ex(HMAC_CTX *ctx, const void *key, int len,
65
66void HMAC_Init_ex(HMAC_CTX *ctx, const void *key, int len,
67 const EVP_MD *md, ENGINE *impl) 65 const EVP_MD *md, ENGINE *impl)
68 { 66 {
69 int i,j,reset=0; 67 int i,j,reset=0;
@@ -84,10 +82,13 @@ void HMAC_Init_ex(HMAC_CTX *ctx, const void *key, int len,
84 OPENSSL_assert(j <= (int)sizeof(ctx->key)); 82 OPENSSL_assert(j <= (int)sizeof(ctx->key));
85 if (j < len) 83 if (j < len)
86 { 84 {
87 EVP_DigestInit_ex(&ctx->md_ctx,md, impl); 85 if (!EVP_DigestInit_ex(&ctx->md_ctx,md, impl))
88 EVP_DigestUpdate(&ctx->md_ctx,key,len); 86 goto err;
89 EVP_DigestFinal_ex(&(ctx->md_ctx),ctx->key, 87 if (!EVP_DigestUpdate(&ctx->md_ctx,key,len))
90 &ctx->key_length); 88 goto err;
89 if (!EVP_DigestFinal_ex(&(ctx->md_ctx),ctx->key,
90 &ctx->key_length))
91 goto err;
91 } 92 }
92 else 93 else
93 { 94 {
@@ -104,31 +105,38 @@ void HMAC_Init_ex(HMAC_CTX *ctx, const void *key, int len,
104 { 105 {
105 for (i=0; i<HMAC_MAX_MD_CBLOCK; i++) 106 for (i=0; i<HMAC_MAX_MD_CBLOCK; i++)
106 pad[i]=0x36^ctx->key[i]; 107 pad[i]=0x36^ctx->key[i];
107 EVP_DigestInit_ex(&ctx->i_ctx,md, impl); 108 if (!EVP_DigestInit_ex(&ctx->i_ctx,md, impl))
108 EVP_DigestUpdate(&ctx->i_ctx,pad,EVP_MD_block_size(md)); 109 goto err;
110 if (!EVP_DigestUpdate(&ctx->i_ctx,pad,EVP_MD_block_size(md)))
111 goto err;
109 112
110 for (i=0; i<HMAC_MAX_MD_CBLOCK; i++) 113 for (i=0; i<HMAC_MAX_MD_CBLOCK; i++)
111 pad[i]=0x5c^ctx->key[i]; 114 pad[i]=0x5c^ctx->key[i];
112 EVP_DigestInit_ex(&ctx->o_ctx,md, impl); 115 if (!EVP_DigestInit_ex(&ctx->o_ctx,md, impl))
113 EVP_DigestUpdate(&ctx->o_ctx,pad,EVP_MD_block_size(md)); 116 goto err;
117 if (!EVP_DigestUpdate(&ctx->o_ctx,pad,EVP_MD_block_size(md)))
118 goto err;
114 } 119 }
115 EVP_MD_CTX_copy_ex(&ctx->md_ctx,&ctx->i_ctx); 120 if (!EVP_MD_CTX_copy_ex(&ctx->md_ctx,&ctx->i_ctx))
121 goto err;
122 return 1;
123 err:
124 return 0;
116 } 125 }
117 126
118void HMAC_Init(HMAC_CTX *ctx, const void *key, int len, 127int HMAC_Init(HMAC_CTX *ctx, const void *key, int len, const EVP_MD *md)
119 const EVP_MD *md)
120 { 128 {
121 if(key && md) 129 if(key && md)
122 HMAC_CTX_init(ctx); 130 HMAC_CTX_init(ctx);
123 HMAC_Init_ex(ctx,key,len,md, NULL); 131 return HMAC_Init_ex(ctx,key,len,md, NULL);
124 } 132 }
125 133
126void HMAC_Update(HMAC_CTX *ctx, const unsigned char *data, size_t len) 134int HMAC_Update(HMAC_CTX *ctx, const unsigned char *data, size_t len)
127 { 135 {
128 EVP_DigestUpdate(&ctx->md_ctx,data,len); 136 return EVP_DigestUpdate(&ctx->md_ctx,data,len);
129 } 137 }
130 138
131void HMAC_Final(HMAC_CTX *ctx, unsigned char *md, unsigned int *len) 139int HMAC_Final(HMAC_CTX *ctx, unsigned char *md, unsigned int *len)
132 { 140 {
133 int j; 141 int j;
134 unsigned int i; 142 unsigned int i;
@@ -136,10 +144,17 @@ void HMAC_Final(HMAC_CTX *ctx, unsigned char *md, unsigned int *len)
136 144
137 j=EVP_MD_block_size(ctx->md); 145 j=EVP_MD_block_size(ctx->md);
138 146
139 EVP_DigestFinal_ex(&ctx->md_ctx,buf,&i); 147 if (!EVP_DigestFinal_ex(&ctx->md_ctx,buf,&i))
140 EVP_MD_CTX_copy_ex(&ctx->md_ctx,&ctx->o_ctx); 148 goto err;
141 EVP_DigestUpdate(&ctx->md_ctx,buf,i); 149 if (!EVP_MD_CTX_copy_ex(&ctx->md_ctx,&ctx->o_ctx))
142 EVP_DigestFinal_ex(&ctx->md_ctx,md,len); 150 goto err;
151 if (!EVP_DigestUpdate(&ctx->md_ctx,buf,i))
152 goto err;
153 if (!EVP_DigestFinal_ex(&ctx->md_ctx,md,len))
154 goto err;
155 return 1;
156 err:
157 return 0;
143 } 158 }
144 159
145void HMAC_CTX_init(HMAC_CTX *ctx) 160void HMAC_CTX_init(HMAC_CTX *ctx)
@@ -149,6 +164,22 @@ void HMAC_CTX_init(HMAC_CTX *ctx)
149 EVP_MD_CTX_init(&ctx->md_ctx); 164 EVP_MD_CTX_init(&ctx->md_ctx);
150 } 165 }
151 166
167int HMAC_CTX_copy(HMAC_CTX *dctx, HMAC_CTX *sctx)
168 {
169 if (!EVP_MD_CTX_copy(&dctx->i_ctx, &sctx->i_ctx))
170 goto err;
171 if (!EVP_MD_CTX_copy(&dctx->o_ctx, &sctx->o_ctx))
172 goto err;
173 if (!EVP_MD_CTX_copy(&dctx->md_ctx, &sctx->md_ctx))
174 goto err;
175 memcpy(dctx->key, sctx->key, HMAC_MAX_MD_CBLOCK);
176 dctx->key_length = sctx->key_length;
177 dctx->md = sctx->md;
178 return 1;
179 err:
180 return 0;
181 }
182
152void HMAC_CTX_cleanup(HMAC_CTX *ctx) 183void HMAC_CTX_cleanup(HMAC_CTX *ctx)
153 { 184 {
154 EVP_MD_CTX_cleanup(&ctx->i_ctx); 185 EVP_MD_CTX_cleanup(&ctx->i_ctx);
@@ -166,11 +197,16 @@ unsigned char *HMAC(const EVP_MD *evp_md, const void *key, int key_len,
166 197
167 if (md == NULL) md=m; 198 if (md == NULL) md=m;
168 HMAC_CTX_init(&c); 199 HMAC_CTX_init(&c);
169 HMAC_Init(&c,key,key_len,evp_md); 200 if (!HMAC_Init(&c,key,key_len,evp_md))
170 HMAC_Update(&c,d,n); 201 goto err;
171 HMAC_Final(&c,md,md_len); 202 if (!HMAC_Update(&c,d,n))
203 goto err;
204 if (!HMAC_Final(&c,md,md_len))
205 goto err;
172 HMAC_CTX_cleanup(&c); 206 HMAC_CTX_cleanup(&c);
173 return(md); 207 return md;
208 err:
209 return NULL;
174 } 210 }
175 211
176void HMAC_CTX_set_flags(HMAC_CTX *ctx, unsigned long flags) 212void HMAC_CTX_set_flags(HMAC_CTX *ctx, unsigned long flags)
@@ -179,5 +215,3 @@ void HMAC_CTX_set_flags(HMAC_CTX *ctx, unsigned long flags)
179 EVP_MD_CTX_set_flags(&ctx->o_ctx, flags); 215 EVP_MD_CTX_set_flags(&ctx->o_ctx, flags);
180 EVP_MD_CTX_set_flags(&ctx->md_ctx, flags); 216 EVP_MD_CTX_set_flags(&ctx->md_ctx, flags);
181 } 217 }
182
183#endif
diff --git a/src/lib/libcrypto/hmac/hmac.h b/src/lib/libcrypto/hmac/hmac.h
index fc38ffb52b..1be0022190 100644
--- a/src/lib/libcrypto/hmac/hmac.h
+++ b/src/lib/libcrypto/hmac/hmac.h
@@ -90,15 +90,16 @@ void HMAC_CTX_cleanup(HMAC_CTX *ctx);
90 90
91#define HMAC_cleanup(ctx) HMAC_CTX_cleanup(ctx) /* deprecated */ 91#define HMAC_cleanup(ctx) HMAC_CTX_cleanup(ctx) /* deprecated */
92 92
93void HMAC_Init(HMAC_CTX *ctx, const void *key, int len, 93int HMAC_Init(HMAC_CTX *ctx, const void *key, int len,
94 const EVP_MD *md); /* deprecated */ 94 const EVP_MD *md); /* deprecated */
95void HMAC_Init_ex(HMAC_CTX *ctx, const void *key, int len, 95int HMAC_Init_ex(HMAC_CTX *ctx, const void *key, int len,
96 const EVP_MD *md, ENGINE *impl); 96 const EVP_MD *md, ENGINE *impl);
97void HMAC_Update(HMAC_CTX *ctx, const unsigned char *data, size_t len); 97int HMAC_Update(HMAC_CTX *ctx, const unsigned char *data, size_t len);
98void HMAC_Final(HMAC_CTX *ctx, unsigned char *md, unsigned int *len); 98int HMAC_Final(HMAC_CTX *ctx, unsigned char *md, unsigned int *len);
99unsigned char *HMAC(const EVP_MD *evp_md, const void *key, int key_len, 99unsigned char *HMAC(const EVP_MD *evp_md, const void *key, int key_len,
100 const unsigned char *d, size_t n, unsigned char *md, 100 const unsigned char *d, size_t n, unsigned char *md,
101 unsigned int *md_len); 101 unsigned int *md_len);
102int HMAC_CTX_copy(HMAC_CTX *dctx, HMAC_CTX *sctx);
102 103
103void HMAC_CTX_set_flags(HMAC_CTX *ctx, unsigned long flags); 104void HMAC_CTX_set_flags(HMAC_CTX *ctx, unsigned long flags);
104 105
diff --git a/src/lib/libcrypto/idea/Makefile.ssl b/src/lib/libcrypto/idea/Makefile.ssl
deleted file mode 100644
index fa016ea399..0000000000
--- a/src/lib/libcrypto/idea/Makefile.ssl
+++ /dev/null
@@ -1,91 +0,0 @@
1#
2# SSLeay/crypto/idea/Makefile
3#
4
5DIR= idea
6TOP= ../..
7CC= cc
8INCLUDES=
9CFLAG=-g
10INSTALL_PREFIX=
11OPENSSLDIR= /usr/local/ssl
12INSTALLTOP=/usr/local/ssl
13MAKE= make -f Makefile.ssl
14MAKEDEPPROG= makedepend
15MAKEDEPEND= $(TOP)/util/domd $(TOP) -MD $(MAKEDEPPROG)
16MAKEFILE= Makefile.ssl
17AR= ar r
18
19CFLAGS= $(INCLUDES) $(CFLAG)
20
21GENERAL=Makefile
22TEST=ideatest.c
23APPS=
24
25LIB=$(TOP)/libcrypto.a
26LIBSRC=i_cbc.c i_cfb64.c i_ofb64.c i_ecb.c i_skey.c
27LIBOBJ=i_cbc.o i_cfb64.o i_ofb64.o i_ecb.o i_skey.o
28
29SRC= $(LIBSRC)
30
31EXHEADER= idea.h
32HEADER= idea_lcl.h $(EXHEADER)
33
34ALL= $(GENERAL) $(SRC) $(HEADER)
35
36top:
37 (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all)
38
39all: lib
40
41lib: $(LIBOBJ)
42 $(AR) $(LIB) $(LIBOBJ)
43 $(RANLIB) $(LIB) || echo Never mind.
44 @touch lib
45
46files:
47 $(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO
48
49links:
50 @sh $(TOP)/util/point.sh Makefile.ssl Makefile
51 @$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER)
52 @$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST)
53 @$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS)
54
55install:
56 @for i in $(EXHEADER) ; \
57 do \
58 (cp $$i $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i; \
59 chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i ); \
60 done;
61
62tags:
63 ctags $(SRC)
64
65tests:
66
67lint:
68 lint -DLINT $(INCLUDES) $(SRC)>fluff
69
70depend:
71 $(MAKEDEPEND) -- $(CFLAG) $(INCLUDES) $(DEPFLAG) -- $(PROGS) $(LIBSRC)
72
73dclean:
74 $(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
75 mv -f Makefile.new $(MAKEFILE)
76
77clean:
78 rm -f *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff
79
80# DO NOT DELETE THIS LINE -- make depend depends on it.
81
82i_cbc.o: ../../include/openssl/idea.h ../../include/openssl/opensslconf.h
83i_cbc.o: i_cbc.c idea_lcl.h
84i_cfb64.o: ../../include/openssl/idea.h ../../include/openssl/opensslconf.h
85i_cfb64.o: i_cfb64.c idea_lcl.h
86i_ecb.o: ../../include/openssl/idea.h ../../include/openssl/opensslconf.h
87i_ecb.o: ../../include/openssl/opensslv.h i_ecb.c idea_lcl.h
88i_ofb64.o: ../../include/openssl/idea.h ../../include/openssl/opensslconf.h
89i_ofb64.o: i_ofb64.c idea_lcl.h
90i_skey.o: ../../include/openssl/idea.h ../../include/openssl/opensslconf.h
91i_skey.o: i_skey.c idea_lcl.h
diff --git a/src/lib/libcrypto/idea/idea.h b/src/lib/libcrypto/idea/idea.h
index a137d4cbce..5782e54b0f 100644
--- a/src/lib/libcrypto/idea/idea.h
+++ b/src/lib/libcrypto/idea/idea.h
@@ -83,11 +83,8 @@ typedef struct idea_key_st
83const char *idea_options(void); 83const char *idea_options(void);
84void idea_ecb_encrypt(const unsigned char *in, unsigned char *out, 84void idea_ecb_encrypt(const unsigned char *in, unsigned char *out,
85 IDEA_KEY_SCHEDULE *ks); 85 IDEA_KEY_SCHEDULE *ks);
86#ifdef OPENSSL_FIPS
87void private_idea_set_encrypt_key(const unsigned char *key, IDEA_KEY_SCHEDULE *ks);
88#endif
89void idea_set_encrypt_key(const unsigned char *key, IDEA_KEY_SCHEDULE *ks); 86void idea_set_encrypt_key(const unsigned char *key, IDEA_KEY_SCHEDULE *ks);
90void idea_set_decrypt_key(const IDEA_KEY_SCHEDULE *ek, IDEA_KEY_SCHEDULE *dk); 87void idea_set_decrypt_key(IDEA_KEY_SCHEDULE *ek, IDEA_KEY_SCHEDULE *dk);
91void idea_cbc_encrypt(const unsigned char *in, unsigned char *out, 88void idea_cbc_encrypt(const unsigned char *in, unsigned char *out,
92 long length, IDEA_KEY_SCHEDULE *ks, unsigned char *iv,int enc); 89 long length, IDEA_KEY_SCHEDULE *ks, unsigned char *iv,int enc);
93void idea_cfb64_encrypt(const unsigned char *in, unsigned char *out, 90void idea_cfb64_encrypt(const unsigned char *in, unsigned char *out,
diff --git a/src/lib/libcrypto/install.com b/src/lib/libcrypto/install.com
index ffad1f97a7..ad3e4d48c7 100644
--- a/src/lib/libcrypto/install.com
+++ b/src/lib/libcrypto/install.com
@@ -3,15 +3,26 @@ $!
3$! Author: Richard Levitte <richard@levitte.org> 3$! Author: Richard Levitte <richard@levitte.org>
4$! Time of creation: 22-MAY-1998 10:13 4$! Time of creation: 22-MAY-1998 10:13
5$! 5$!
6$! Changes by Zoltan Arpadffy <zoli@polarhome.com>
7$!
6$! P1 root of the directory tree 8$! P1 root of the directory tree
7$! 9$!
8$ IF P1 .EQS. "" 10$ IF P1 .EQS. ""
9$ THEN 11$ THEN
10$ WRITE SYS$OUTPUT "First argument missing." 12$ WRITE SYS$OUTPUT "First argument missing."
11$ WRITE SYS$OUTPUT "Should be the directory where you want things installed." 13$ WRITE SYS$OUTPUT -
14 "It should be the directory where you want things installed."
12$ EXIT 15$ EXIT
13$ ENDIF 16$ ENDIF
14$ 17$
18$ IF (F$GETSYI("CPU").LT.128)
19$ THEN
20$ ARCH := VAX
21$ ELSE
22$ ARCH = F$EDIT( F$GETSYI( "ARCH_NAME"), "UPCASE")
23$ IF (ARCH .EQS. "") THEN ARCH = "UNK"
24$ ENDIF
25$
15$ ROOT = F$PARSE(P1,"[]A.;0",,,"SYNTAX_ONLY,NO_CONCEAL") - "A.;0" 26$ ROOT = F$PARSE(P1,"[]A.;0",,,"SYNTAX_ONLY,NO_CONCEAL") - "A.;0"
16$ ROOT_DEV = F$PARSE(ROOT,,,"DEVICE","SYNTAX_ONLY") 27$ ROOT_DEV = F$PARSE(ROOT,,,"DEVICE","SYNTAX_ONLY")
17$ ROOT_DIR = F$PARSE(ROOT,,,"DIRECTORY","SYNTAX_ONLY") - 28$ ROOT_DIR = F$PARSE(ROOT,,,"DIRECTORY","SYNTAX_ONLY") -
@@ -19,30 +30,28 @@ $ ROOT_DIR = F$PARSE(ROOT,,,"DIRECTORY","SYNTAX_ONLY") -
19$ ROOT = ROOT_DEV + "[" + ROOT_DIR 30$ ROOT = ROOT_DEV + "[" + ROOT_DIR
20$ 31$
21$ DEFINE/NOLOG WRK_SSLROOT 'ROOT'.] /TRANS=CONC 32$ DEFINE/NOLOG WRK_SSLROOT 'ROOT'.] /TRANS=CONC
22$ DEFINE/NOLOG WRK_SSLVLIB WRK_SSLROOT:[VAX_LIB] 33$ DEFINE/NOLOG WRK_SSLLIB WRK_SSLROOT:['ARCH'_LIB]
23$ DEFINE/NOLOG WRK_SSLALIB WRK_SSLROOT:[ALPHA_LIB]
24$ DEFINE/NOLOG WRK_SSLINCLUDE WRK_SSLROOT:[INCLUDE] 34$ DEFINE/NOLOG WRK_SSLINCLUDE WRK_SSLROOT:[INCLUDE]
25$ 35$
26$ IF F$PARSE("WRK_SSLROOT:[000000]") .EQS. "" THEN - 36$ IF F$PARSE("WRK_SSLROOT:[000000]") .EQS. "" THEN -
27 CREATE/DIR/LOG WRK_SSLROOT:[000000] 37 CREATE/DIR/LOG WRK_SSLROOT:[000000]
28$ IF F$PARSE("WRK_SSLVLIB:") .EQS. "" THEN - 38$ IF F$PARSE("WRK_SSLLIB:") .EQS. "" THEN -
29 CREATE/DIR/LOG WRK_SSLVLIB: 39 CREATE/DIR/LOG WRK_SSLLIB:
30$ IF F$PARSE("WRK_SSLALIB:") .EQS. "" THEN -
31 CREATE/DIR/LOG WRK_SSLALIB:
32$ IF F$PARSE("WRK_SSLINCLUDE:") .EQS. "" THEN - 40$ IF F$PARSE("WRK_SSLINCLUDE:") .EQS. "" THEN -
33 CREATE/DIR/LOG WRK_SSLINCLUDE: 41 CREATE/DIR/LOG WRK_SSLINCLUDE:
34$ 42$
35$ SDIRS := ,- 43$ SDIRS := ,-
44 _'ARCH',-
36 OBJECTS,- 45 OBJECTS,-
37 MD2,MD4,MD5,SHA,MDC2,HMAC,RIPEMD,- 46 MD2,MD4,MD5,SHA,MDC2,HMAC,RIPEMD,WHRLPOOL,-
38 DES,AES,RC2,RC4,RC5,IDEA,BF,CAST,CAMELLIA,SEED,- 47 DES,AES,RC2,RC4,RC5,IDEA,BF,CAST,CAMELLIA,SEED,-
39 BN,EC,RSA,DSA,ECDSA,DH,ECDH,DSO,ENGINE,- 48 BN,EC,RSA,DSA,ECDSA,DH,ECDH,DSO,ENGINE,-
40 BUFFER,BIO,STACK,LHASH,RAND,ERR,- 49 BUFFER,BIO,STACK,LHASH,RAND,ERR,-
41 EVP,ASN1,PEM,X509,X509V3,CONF,TXT_DB,PKCS7,PKCS12,COMP,OCSP,- 50 EVP,ASN1,PEM,X509,X509V3,CONF,TXT_DB,PKCS7,PKCS12,COMP,OCSP,-
42 UI,KRB5,- 51 UI,KRB5,-
43 STORE,PQUEUE,JPAKE 52 STORE,CMS,PQUEUE,TS,JPAKE
44$ EXHEADER_ := crypto.h,tmdiff.h,opensslv.h,opensslconf.h,ebcdic.h,- 53$ EXHEADER_ := crypto.h,opensslv.h,ebcdic.h,symhacks.h,ossl_typ.h
45 symhacks.h,ossl_typ.h 54$ EXHEADER__'ARCH' := opensslconf.h
46$ EXHEADER_OBJECTS := objects.h,obj_mac.h 55$ EXHEADER_OBJECTS := objects.h,obj_mac.h
47$ EXHEADER_MD2 := md2.h 56$ EXHEADER_MD2 := md2.h
48$ EXHEADER_MD4 := md4.h 57$ EXHEADER_MD4 := md4.h
@@ -51,6 +60,7 @@ $ EXHEADER_SHA := sha.h
51$ EXHEADER_MDC2 := mdc2.h 60$ EXHEADER_MDC2 := mdc2.h
52$ EXHEADER_HMAC := hmac.h 61$ EXHEADER_HMAC := hmac.h
53$ EXHEADER_RIPEMD := ripemd.h 62$ EXHEADER_RIPEMD := ripemd.h
63$ EXHEADER_WHRLPOOL := whrlpool.h
54$ EXHEADER_DES := des.h,des_old.h 64$ EXHEADER_DES := des.h,des_old.h
55$ EXHEADER_AES := aes.h 65$ EXHEADER_AES := aes.h
56$ EXHEADER_RC2 := rc2.h 66$ EXHEADER_RC2 := rc2.h
@@ -61,6 +71,7 @@ $ EXHEADER_BF := blowfish.h
61$ EXHEADER_CAST := cast.h 71$ EXHEADER_CAST := cast.h
62$ EXHEADER_CAMELLIA := camellia.h 72$ EXHEADER_CAMELLIA := camellia.h
63$ EXHEADER_SEED := seed.h 73$ EXHEADER_SEED := seed.h
74$ EXHEADER_MODES := modes.h
64$ EXHEADER_BN := bn.h 75$ EXHEADER_BN := bn.h
65$ EXHEADER_EC := ec.h 76$ EXHEADER_EC := ec.h
66$ EXHEADER_RSA := rsa.h 77$ EXHEADER_RSA := rsa.h
@@ -91,12 +102,13 @@ $ EXHEADER_UI := ui.h,ui_compat.h
91$ EXHEADER_KRB5 := krb5_asn.h 102$ EXHEADER_KRB5 := krb5_asn.h
92$! EXHEADER_STORE := store.h,str_compat.h 103$! EXHEADER_STORE := store.h,str_compat.h
93$ EXHEADER_STORE := store.h 104$ EXHEADER_STORE := store.h
94$ EXHEADER_PQUEUE := pqueue.h,pq_compat.h 105$ EXHEADER_CMS := cms.h
106$ EXHEADER_PQUEUE := pqueue.h
107$ EXHEADER_TS := ts.h
95$ EXHEADER_JPAKE := jpake.h 108$ EXHEADER_JPAKE := jpake.h
96$ LIBS := LIBCRYPTO 109$ LIBS := LIBCRYPTO
97$ 110$
98$ VEXE_DIR := [-.VAX.EXE.CRYPTO] 111$ EXE_DIR := [-.'ARCH'.EXE.CRYPTO]
99$ AEXE_DIR := [-.AXP.EXE.CRYPTO]
100$ 112$
101$ I = 0 113$ I = 0
102$ LOOP_SDIRS: 114$ LOOP_SDIRS:
@@ -108,7 +120,12 @@ $ IF D .EQS. ""
108$ THEN 120$ THEN
109$ COPY 'tmp' WRK_SSLINCLUDE: /LOG 121$ COPY 'tmp' WRK_SSLINCLUDE: /LOG
110$ ELSE 122$ ELSE
111$ COPY [.'D']'tmp' WRK_SSLINCLUDE: /LOG 123$ IF D .EQS. "_''ARCH'"
124$ THEN
125$ COPY [-.'ARCH'.CRYPTO]'tmp' WRK_SSLINCLUDE: /LOG
126$ ELSE
127$ COPY [.'D']'tmp' WRK_SSLINCLUDE: /LOG
128$ ENDIF
112$ ENDIF 129$ ENDIF
113$ SET FILE/PROT=WORLD:RE WRK_SSLINCLUDE:'tmp' 130$ SET FILE/PROT=WORLD:RE WRK_SSLINCLUDE:'tmp'
114$ GOTO LOOP_SDIRS 131$ GOTO LOOP_SDIRS
@@ -120,27 +137,16 @@ $ E = F$EDIT(F$ELEMENT(I, ",", LIBS),"TRIM")
120$ I = I + 1 137$ I = I + 1
121$ IF E .EQS. "," THEN GOTO LOOP_LIB_END 138$ IF E .EQS. "," THEN GOTO LOOP_LIB_END
122$ SET NOON 139$ SET NOON
123$ IF F$SEARCH(VEXE_DIR+E+".OLB") .NES. "" 140$ IF F$SEARCH(EXE_DIR+E+".OLB") .NES. ""
124$ THEN
125$ COPY 'VEXE_DIR''E'.OLB WRK_SSLVLIB:'E'.OLB/log
126$ SET FILE/PROT=W:RE WRK_SSLVLIB:'E'.OLB
127$ ENDIF
128$ ! Preparing for the time when we have shareable images
129$ IF F$SEARCH(VEXE_DIR+E+".EXE") .NES. ""
130$ THEN
131$ COPY 'VEXE_DIR''E'.EXE WRK_SSLVLIB:'E'.EXE/log
132$ SET FILE/PROT=W:RE WRK_SSLVLIB:'E'.EXE
133$ ENDIF
134$ IF F$SEARCH(AEXE_DIR+E+".OLB") .NES. ""
135$ THEN 141$ THEN
136$ COPY 'AEXE_DIR''E'.OLB WRK_SSLALIB:'E'.OLB/log 142$ COPY 'EXE_DIR''E'.OLB WRK_SSLLIB:'E'.OLB/log
137$ SET FILE/PROT=W:RE WRK_SSLALIB:'E'.OLB 143$ SET FILE/PROT=W:RE WRK_SSLLIB:'E'.OLB
138$ ENDIF 144$ ENDIF
139$ ! Preparing for the time when we have shareable images 145$ ! Preparing for the time when we have shareable images
140$ IF F$SEARCH(AEXE_DIR+E+".EXE") .NES. "" 146$ IF F$SEARCH(EXE_DIR+E+".EXE") .NES. ""
141$ THEN 147$ THEN
142$ COPY 'AEXE_DIR''E'.EXE WRK_SSLALIB:'E'.EXE/log 148$ COPY 'EXE_DIR''E'.EXE WRK_SSLLIB:'E'.EXE/log
143$ SET FILE/PROT=W:RE WRK_SSLALIB:'E'.EXE 149$ SET FILE/PROT=W:RE WRK_SSLLIB:'E'.EXE
144$ ENDIF 150$ ENDIF
145$ SET ON 151$ SET ON
146$ GOTO LOOP_LIB 152$ GOTO LOOP_LIB
diff --git a/src/lib/libcrypto/krb5/Makefile.ssl b/src/lib/libcrypto/krb5/Makefile.ssl
deleted file mode 100644
index d9224c0f09..0000000000
--- a/src/lib/libcrypto/krb5/Makefile.ssl
+++ /dev/null
@@ -1,90 +0,0 @@
1#
2# OpenSSL/krb5/Makefile.ssl
3#
4
5DIR= krb5
6TOP= ../..
7CC= cc
8INCLUDES= -I.. -I$(TOP) -I../../include
9CFLAG=-g
10INSTALL_PREFIX=
11OPENSSLDIR= /usr/local/ssl
12INSTALLTOP=/usr/local/ssl
13MAKE= make -f Makefile.ssl
14MAKEDEPPROG= makedepend
15MAKEDEPEND= $(TOP)/util/domd $(TOP) -MD $(MAKEDEPPROG)
16MAKEFILE= Makefile.ssl
17AR= ar r
18
19CFLAGS= $(INCLUDES) $(CFLAG)
20
21GENERAL=Makefile README
22TEST=
23APPS=
24
25LIB=$(TOP)/libcrypto.a
26LIBSRC= krb5_asn.c
27
28LIBOBJ= krb5_asn.o
29
30SRC= $(LIBSRC)
31
32EXHEADER= krb5_asn.h
33HEADER= $(EXHEADER)
34
35ALL= $(GENERAL) $(SRC) $(HEADER)
36
37top:
38 (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all)
39
40all: lib
41
42lib: $(LIBOBJ)
43 $(AR) $(LIB) $(LIBOBJ)
44 $(RANLIB) $(LIB) || echo Never mind.
45 @touch lib
46
47files:
48 $(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO
49
50links:
51 @sh $(TOP)/util/point.sh Makefile.ssl Makefile ;
52 @$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER)
53 @$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST)
54 @$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS)
55
56install:
57 @for i in $(EXHEADER) ; \
58 do \
59 (cp $$i $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i; \
60 chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i ); \
61 done;
62
63tags:
64 ctags $(SRC)
65
66tests:
67
68lint:
69 lint -DLINT $(INCLUDES) $(SRC)>fluff
70
71depend:
72 $(MAKEDEPEND) -- $(CFLAG) $(INCLUDES) $(DEPFLAG) -- $(LIBSRC)
73
74dclean:
75 $(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
76 mv -f Makefile.new $(MAKEFILE)
77
78clean:
79 rm -f *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff
80
81# DO NOT DELETE THIS LINE -- make depend depends on it.
82
83krb5_asn.o: ../../include/openssl/asn1.h ../../include/openssl/asn1t.h
84krb5_asn.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
85krb5_asn.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
86krb5_asn.o: ../../include/openssl/krb5_asn.h
87krb5_asn.o: ../../include/openssl/opensslconf.h
88krb5_asn.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
89krb5_asn.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
90krb5_asn.o: ../../include/openssl/symhacks.h krb5_asn.c
diff --git a/src/lib/libcrypto/lhash/Makefile.ssl b/src/lib/libcrypto/lhash/Makefile.ssl
deleted file mode 100644
index 60e7ee3393..0000000000
--- a/src/lib/libcrypto/lhash/Makefile.ssl
+++ /dev/null
@@ -1,93 +0,0 @@
1#
2# SSLeay/crypto/lhash/Makefile
3#
4
5DIR= lhash
6TOP= ../..
7CC= cc
8INCLUDES=
9CFLAG=-g
10INSTALL_PREFIX=
11OPENSSLDIR= /usr/local/ssl
12INSTALLTOP=/usr/local/ssl
13MAKE= make -f Makefile.ssl
14MAKEDEPPROG= makedepend
15MAKEDEPEND= $(TOP)/util/domd $(TOP) -MD $(MAKEDEPPROG)
16MAKEFILE= Makefile.ssl
17AR= ar r
18
19CFLAGS= $(INCLUDES) $(CFLAG)
20
21GENERAL=Makefile
22TEST=
23APPS=
24
25LIB=$(TOP)/libcrypto.a
26LIBSRC=lhash.c lh_stats.c
27LIBOBJ=lhash.o lh_stats.o
28
29SRC= $(LIBSRC)
30
31EXHEADER= lhash.h
32HEADER= $(EXHEADER)
33
34ALL= $(GENERAL) $(SRC) $(HEADER)
35
36top:
37 (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all)
38
39all: lib
40
41lib: $(LIBOBJ)
42 $(AR) $(LIB) $(LIBOBJ)
43 $(RANLIB) $(LIB) || echo Never mind.
44 @touch lib
45
46files:
47 $(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO
48
49links:
50 @sh $(TOP)/util/point.sh Makefile.ssl Makefile
51 @$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER)
52 @$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST)
53 @$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS)
54
55install:
56 @for i in $(EXHEADER) ; \
57 do \
58 (cp $$i $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i; \
59 chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i ); \
60 done;
61
62tags:
63 ctags $(SRC)
64
65tests:
66
67lint:
68 lint -DLINT $(INCLUDES) $(SRC)>fluff
69
70depend:
71 $(MAKEDEPEND) -- $(CFLAG) $(INCLUDES) $(DEPFLAG) -- $(PROGS) $(LIBSRC)
72
73dclean:
74 $(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
75 mv -f Makefile.new $(MAKEFILE)
76
77clean:
78 rm -f *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff
79
80# DO NOT DELETE THIS LINE -- make depend depends on it.
81
82lh_stats.o: ../../e_os.h ../../include/openssl/bio.h
83lh_stats.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
84lh_stats.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
85lh_stats.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
86lh_stats.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
87lh_stats.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
88lh_stats.o: ../cryptlib.h lh_stats.c
89lhash.o: ../../include/openssl/bio.h ../../include/openssl/crypto.h
90lhash.o: ../../include/openssl/e_os2.h ../../include/openssl/lhash.h
91lhash.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
92lhash.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
93lhash.o: ../../include/openssl/symhacks.h lhash.c
diff --git a/src/lib/libcrypto/lhash/lh_stats.c b/src/lib/libcrypto/lhash/lh_stats.c
index 5aa7766aa6..815615e338 100644
--- a/src/lib/libcrypto/lhash/lh_stats.c
+++ b/src/lib/libcrypto/lhash/lh_stats.c
@@ -139,7 +139,7 @@ void lh_node_usage_stats(LHASH *lh, FILE *out)
139#else 139#else
140 140
141#ifndef OPENSSL_NO_FP_API 141#ifndef OPENSSL_NO_FP_API
142void lh_stats(const LHASH *lh, FILE *fp) 142void lh_stats(const _LHASH *lh, FILE *fp)
143 { 143 {
144 BIO *bp; 144 BIO *bp;
145 145
@@ -151,7 +151,7 @@ void lh_stats(const LHASH *lh, FILE *fp)
151end:; 151end:;
152 } 152 }
153 153
154void lh_node_stats(const LHASH *lh, FILE *fp) 154void lh_node_stats(const _LHASH *lh, FILE *fp)
155 { 155 {
156 BIO *bp; 156 BIO *bp;
157 157
@@ -163,7 +163,7 @@ void lh_node_stats(const LHASH *lh, FILE *fp)
163end:; 163end:;
164 } 164 }
165 165
166void lh_node_usage_stats(const LHASH *lh, FILE *fp) 166void lh_node_usage_stats(const _LHASH *lh, FILE *fp)
167 { 167 {
168 BIO *bp; 168 BIO *bp;
169 169
@@ -177,7 +177,7 @@ end:;
177 177
178#endif 178#endif
179 179
180void lh_stats_bio(const LHASH *lh, BIO *out) 180void lh_stats_bio(const _LHASH *lh, BIO *out)
181 { 181 {
182 BIO_printf(out,"num_items = %lu\n",lh->num_items); 182 BIO_printf(out,"num_items = %lu\n",lh->num_items);
183 BIO_printf(out,"num_nodes = %u\n",lh->num_nodes); 183 BIO_printf(out,"num_nodes = %u\n",lh->num_nodes);
@@ -205,7 +205,7 @@ void lh_stats_bio(const LHASH *lh, BIO *out)
205#endif 205#endif
206 } 206 }
207 207
208void lh_node_stats_bio(const LHASH *lh, BIO *out) 208void lh_node_stats_bio(const _LHASH *lh, BIO *out)
209 { 209 {
210 LHASH_NODE *n; 210 LHASH_NODE *n;
211 unsigned int i,num; 211 unsigned int i,num;
@@ -218,7 +218,7 @@ void lh_node_stats_bio(const LHASH *lh, BIO *out)
218 } 218 }
219 } 219 }
220 220
221void lh_node_usage_stats_bio(const LHASH *lh, BIO *out) 221void lh_node_usage_stats_bio(const _LHASH *lh, BIO *out)
222 { 222 {
223 LHASH_NODE *n; 223 LHASH_NODE *n;
224 unsigned long num; 224 unsigned long num;
diff --git a/src/lib/libcrypto/lhash/lhash.c b/src/lib/libcrypto/lhash/lhash.c
index 04ea80203c..47f748081b 100644
--- a/src/lib/libcrypto/lhash/lhash.c
+++ b/src/lib/libcrypto/lhash/lhash.c
@@ -107,18 +107,18 @@ const char lh_version[]="lhash" OPENSSL_VERSION_PTEXT;
107#define UP_LOAD (2*LH_LOAD_MULT) /* load times 256 (default 2) */ 107#define UP_LOAD (2*LH_LOAD_MULT) /* load times 256 (default 2) */
108#define DOWN_LOAD (LH_LOAD_MULT) /* load times 256 (default 1) */ 108#define DOWN_LOAD (LH_LOAD_MULT) /* load times 256 (default 1) */
109 109
110static void expand(LHASH *lh); 110static void expand(_LHASH *lh);
111static void contract(LHASH *lh); 111static void contract(_LHASH *lh);
112static LHASH_NODE **getrn(LHASH *lh, const void *data, unsigned long *rhash); 112static LHASH_NODE **getrn(_LHASH *lh, const void *data, unsigned long *rhash);
113 113
114LHASH *lh_new(LHASH_HASH_FN_TYPE h, LHASH_COMP_FN_TYPE c) 114_LHASH *lh_new(LHASH_HASH_FN_TYPE h, LHASH_COMP_FN_TYPE c)
115 { 115 {
116 LHASH *ret; 116 _LHASH *ret;
117 int i; 117 int i;
118 118
119 if ((ret=(LHASH *)OPENSSL_malloc(sizeof(LHASH))) == NULL) 119 if ((ret=OPENSSL_malloc(sizeof(_LHASH))) == NULL)
120 goto err0; 120 goto err0;
121 if ((ret->b=(LHASH_NODE **)OPENSSL_malloc(sizeof(LHASH_NODE *)*MIN_NODES)) == NULL) 121 if ((ret->b=OPENSSL_malloc(sizeof(LHASH_NODE *)*MIN_NODES)) == NULL)
122 goto err1; 122 goto err1;
123 for (i=0; i<MIN_NODES; i++) 123 for (i=0; i<MIN_NODES; i++)
124 ret->b[i]=NULL; 124 ret->b[i]=NULL;
@@ -154,7 +154,7 @@ err0:
154 return(NULL); 154 return(NULL);
155 } 155 }
156 156
157void lh_free(LHASH *lh) 157void lh_free(_LHASH *lh)
158 { 158 {
159 unsigned int i; 159 unsigned int i;
160 LHASH_NODE *n,*nn; 160 LHASH_NODE *n,*nn;
@@ -176,7 +176,7 @@ void lh_free(LHASH *lh)
176 OPENSSL_free(lh); 176 OPENSSL_free(lh);
177 } 177 }
178 178
179void *lh_insert(LHASH *lh, void *data) 179void *lh_insert(_LHASH *lh, void *data)
180 { 180 {
181 unsigned long hash; 181 unsigned long hash;
182 LHASH_NODE *nn,**rn; 182 LHASH_NODE *nn,**rn;
@@ -214,7 +214,7 @@ void *lh_insert(LHASH *lh, void *data)
214 return(ret); 214 return(ret);
215 } 215 }
216 216
217void *lh_delete(LHASH *lh, const void *data) 217void *lh_delete(_LHASH *lh, const void *data)
218 { 218 {
219 unsigned long hash; 219 unsigned long hash;
220 LHASH_NODE *nn,**rn; 220 LHASH_NODE *nn,**rn;
@@ -245,7 +245,7 @@ void *lh_delete(LHASH *lh, const void *data)
245 return(ret); 245 return(ret);
246 } 246 }
247 247
248void *lh_retrieve(LHASH *lh, const void *data) 248void *lh_retrieve(_LHASH *lh, const void *data)
249 { 249 {
250 unsigned long hash; 250 unsigned long hash;
251 LHASH_NODE **rn; 251 LHASH_NODE **rn;
@@ -267,12 +267,15 @@ void *lh_retrieve(LHASH *lh, const void *data)
267 return(ret); 267 return(ret);
268 } 268 }
269 269
270static void doall_util_fn(LHASH *lh, int use_arg, LHASH_DOALL_FN_TYPE func, 270static void doall_util_fn(_LHASH *lh, int use_arg, LHASH_DOALL_FN_TYPE func,
271 LHASH_DOALL_ARG_FN_TYPE func_arg, void *arg) 271 LHASH_DOALL_ARG_FN_TYPE func_arg, void *arg)
272 { 272 {
273 int i; 273 int i;
274 LHASH_NODE *a,*n; 274 LHASH_NODE *a,*n;
275 275
276 if (lh == NULL)
277 return;
278
276 /* reverse the order so we search from 'top to bottom' 279 /* reverse the order so we search from 'top to bottom'
277 * We were having memory leaks otherwise */ 280 * We were having memory leaks otherwise */
278 for (i=lh->num_nodes-1; i>=0; i--) 281 for (i=lh->num_nodes-1; i>=0; i--)
@@ -282,6 +285,8 @@ static void doall_util_fn(LHASH *lh, int use_arg, LHASH_DOALL_FN_TYPE func,
282 { 285 {
283 /* 28/05/91 - eay - n added so items can be deleted 286 /* 28/05/91 - eay - n added so items can be deleted
284 * via lh_doall */ 287 * via lh_doall */
288 /* 22/05/08 - ben - eh? since a is not passed,
289 * this should not be needed */
285 n=a->next; 290 n=a->next;
286 if(use_arg) 291 if(use_arg)
287 func_arg(a->data,arg); 292 func_arg(a->data,arg);
@@ -292,17 +297,17 @@ static void doall_util_fn(LHASH *lh, int use_arg, LHASH_DOALL_FN_TYPE func,
292 } 297 }
293 } 298 }
294 299
295void lh_doall(LHASH *lh, LHASH_DOALL_FN_TYPE func) 300void lh_doall(_LHASH *lh, LHASH_DOALL_FN_TYPE func)
296 { 301 {
297 doall_util_fn(lh, 0, func, (LHASH_DOALL_ARG_FN_TYPE)0, NULL); 302 doall_util_fn(lh, 0, func, (LHASH_DOALL_ARG_FN_TYPE)0, NULL);
298 } 303 }
299 304
300void lh_doall_arg(LHASH *lh, LHASH_DOALL_ARG_FN_TYPE func, void *arg) 305void lh_doall_arg(_LHASH *lh, LHASH_DOALL_ARG_FN_TYPE func, void *arg)
301 { 306 {
302 doall_util_fn(lh, 1, (LHASH_DOALL_FN_TYPE)0, func, arg); 307 doall_util_fn(lh, 1, (LHASH_DOALL_FN_TYPE)0, func, arg);
303 } 308 }
304 309
305static void expand(LHASH *lh) 310static void expand(_LHASH *lh)
306 { 311 {
307 LHASH_NODE **n,**n1,**n2,*np; 312 LHASH_NODE **n,**n1,**n2,*np;
308 unsigned int p,i,j; 313 unsigned int p,i,j;
@@ -358,7 +363,7 @@ static void expand(LHASH *lh)
358 } 363 }
359 } 364 }
360 365
361static void contract(LHASH *lh) 366static void contract(_LHASH *lh)
362 { 367 {
363 LHASH_NODE **n,*n1,*np; 368 LHASH_NODE **n,*n1,*np;
364 369
@@ -397,7 +402,7 @@ static void contract(LHASH *lh)
397 } 402 }
398 } 403 }
399 404
400static LHASH_NODE **getrn(LHASH *lh, const void *data, unsigned long *rhash) 405static LHASH_NODE **getrn(_LHASH *lh, const void *data, unsigned long *rhash)
401 { 406 {
402 LHASH_NODE **ret,*n1; 407 LHASH_NODE **ret,*n1;
403 unsigned long hash,nn; 408 unsigned long hash,nn;
@@ -464,7 +469,7 @@ unsigned long lh_strhash(const char *c)
464 return((ret>>16)^ret); 469 return((ret>>16)^ret);
465 } 470 }
466 471
467unsigned long lh_num_items(const LHASH *lh) 472unsigned long lh_num_items(const _LHASH *lh)
468 { 473 {
469 return lh ? lh->num_items : 0; 474 return lh ? lh->num_items : 0;
470 } 475 }
diff --git a/src/lib/libcrypto/lhash/lhash.h b/src/lib/libcrypto/lhash/lhash.h
index d392d0cd80..e7d8763591 100644
--- a/src/lib/libcrypto/lhash/lhash.h
+++ b/src/lib/libcrypto/lhash/lhash.h
@@ -98,42 +98,42 @@ typedef void (*LHASH_DOALL_ARG_FN_TYPE)(void *, void *);
98 * macros if the functions are strictly internal. */ 98 * macros if the functions are strictly internal. */
99 99
100/* First: "hash" functions */ 100/* First: "hash" functions */
101#define DECLARE_LHASH_HASH_FN(f_name,o_type) \ 101#define DECLARE_LHASH_HASH_FN(name, o_type) \
102 unsigned long f_name##_LHASH_HASH(const void *); 102 unsigned long name##_LHASH_HASH(const void *);
103#define IMPLEMENT_LHASH_HASH_FN(f_name,o_type) \ 103#define IMPLEMENT_LHASH_HASH_FN(name, o_type) \
104 unsigned long f_name##_LHASH_HASH(const void *arg) { \ 104 unsigned long name##_LHASH_HASH(const void *arg) { \
105 o_type a = (o_type)arg; \ 105 const o_type *a = arg; \
106 return f_name(a); } 106 return name##_hash(a); }
107#define LHASH_HASH_FN(f_name) f_name##_LHASH_HASH 107#define LHASH_HASH_FN(name) name##_LHASH_HASH
108 108
109/* Second: "compare" functions */ 109/* Second: "compare" functions */
110#define DECLARE_LHASH_COMP_FN(f_name,o_type) \ 110#define DECLARE_LHASH_COMP_FN(name, o_type) \
111 int f_name##_LHASH_COMP(const void *, const void *); 111 int name##_LHASH_COMP(const void *, const void *);
112#define IMPLEMENT_LHASH_COMP_FN(f_name,o_type) \ 112#define IMPLEMENT_LHASH_COMP_FN(name, o_type) \
113 int f_name##_LHASH_COMP(const void *arg1, const void *arg2) { \ 113 int name##_LHASH_COMP(const void *arg1, const void *arg2) { \
114 o_type a = (o_type)arg1; \ 114 const o_type *a = arg1; \
115 o_type b = (o_type)arg2; \ 115 const o_type *b = arg2; \
116 return f_name(a,b); } 116 return name##_cmp(a,b); }
117#define LHASH_COMP_FN(f_name) f_name##_LHASH_COMP 117#define LHASH_COMP_FN(name) name##_LHASH_COMP
118 118
119/* Third: "doall" functions */ 119/* Third: "doall" functions */
120#define DECLARE_LHASH_DOALL_FN(f_name,o_type) \ 120#define DECLARE_LHASH_DOALL_FN(name, o_type) \
121 void f_name##_LHASH_DOALL(void *); 121 void name##_LHASH_DOALL(void *);
122#define IMPLEMENT_LHASH_DOALL_FN(f_name,o_type) \ 122#define IMPLEMENT_LHASH_DOALL_FN(name, o_type) \
123 void f_name##_LHASH_DOALL(void *arg) { \ 123 void name##_LHASH_DOALL(void *arg) { \
124 o_type a = (o_type)arg; \ 124 o_type *a = arg; \
125 f_name(a); } 125 name##_doall(a); }
126#define LHASH_DOALL_FN(f_name) f_name##_LHASH_DOALL 126#define LHASH_DOALL_FN(name) name##_LHASH_DOALL
127 127
128/* Fourth: "doall_arg" functions */ 128/* Fourth: "doall_arg" functions */
129#define DECLARE_LHASH_DOALL_ARG_FN(f_name,o_type,a_type) \ 129#define DECLARE_LHASH_DOALL_ARG_FN(name, o_type, a_type) \
130 void f_name##_LHASH_DOALL_ARG(void *, void *); 130 void name##_LHASH_DOALL_ARG(void *, void *);
131#define IMPLEMENT_LHASH_DOALL_ARG_FN(f_name,o_type,a_type) \ 131#define IMPLEMENT_LHASH_DOALL_ARG_FN(name, o_type, a_type) \
132 void f_name##_LHASH_DOALL_ARG(void *arg1, void *arg2) { \ 132 void name##_LHASH_DOALL_ARG(void *arg1, void *arg2) { \
133 o_type a = (o_type)arg1; \ 133 o_type *a = arg1; \
134 a_type b = (a_type)arg2; \ 134 a_type *b = arg2; \
135 f_name(a,b); } 135 name##_doall_arg(a, b); }
136#define LHASH_DOALL_ARG_FN(f_name) f_name##_LHASH_DOALL_ARG 136#define LHASH_DOALL_ARG_FN(name) name##_LHASH_DOALL_ARG
137 137
138typedef struct lhash_st 138typedef struct lhash_st
139 { 139 {
@@ -163,7 +163,8 @@ typedef struct lhash_st
163 unsigned long num_hash_comps; 163 unsigned long num_hash_comps;
164 164
165 int error; 165 int error;
166 } LHASH; 166 } _LHASH; /* Do not use _LHASH directly, use LHASH_OF
167 * and friends */
167 168
168#define LH_LOAD_MULT 256 169#define LH_LOAD_MULT 256
169 170
@@ -171,27 +172,67 @@ typedef struct lhash_st
171 * in lh_insert(). */ 172 * in lh_insert(). */
172#define lh_error(lh) ((lh)->error) 173#define lh_error(lh) ((lh)->error)
173 174
174LHASH *lh_new(LHASH_HASH_FN_TYPE h, LHASH_COMP_FN_TYPE c); 175_LHASH *lh_new(LHASH_HASH_FN_TYPE h, LHASH_COMP_FN_TYPE c);
175void lh_free(LHASH *lh); 176void lh_free(_LHASH *lh);
176void *lh_insert(LHASH *lh, void *data); 177void *lh_insert(_LHASH *lh, void *data);
177void *lh_delete(LHASH *lh, const void *data); 178void *lh_delete(_LHASH *lh, const void *data);
178void *lh_retrieve(LHASH *lh, const void *data); 179void *lh_retrieve(_LHASH *lh, const void *data);
179void lh_doall(LHASH *lh, LHASH_DOALL_FN_TYPE func); 180void lh_doall(_LHASH *lh, LHASH_DOALL_FN_TYPE func);
180void lh_doall_arg(LHASH *lh, LHASH_DOALL_ARG_FN_TYPE func, void *arg); 181void lh_doall_arg(_LHASH *lh, LHASH_DOALL_ARG_FN_TYPE func, void *arg);
181unsigned long lh_strhash(const char *c); 182unsigned long lh_strhash(const char *c);
182unsigned long lh_num_items(const LHASH *lh); 183unsigned long lh_num_items(const _LHASH *lh);
183 184
184#ifndef OPENSSL_NO_FP_API 185#ifndef OPENSSL_NO_FP_API
185void lh_stats(const LHASH *lh, FILE *out); 186void lh_stats(const _LHASH *lh, FILE *out);
186void lh_node_stats(const LHASH *lh, FILE *out); 187void lh_node_stats(const _LHASH *lh, FILE *out);
187void lh_node_usage_stats(const LHASH *lh, FILE *out); 188void lh_node_usage_stats(const _LHASH *lh, FILE *out);
188#endif 189#endif
189 190
190#ifndef OPENSSL_NO_BIO 191#ifndef OPENSSL_NO_BIO
191void lh_stats_bio(const LHASH *lh, BIO *out); 192void lh_stats_bio(const _LHASH *lh, BIO *out);
192void lh_node_stats_bio(const LHASH *lh, BIO *out); 193void lh_node_stats_bio(const _LHASH *lh, BIO *out);
193void lh_node_usage_stats_bio(const LHASH *lh, BIO *out); 194void lh_node_usage_stats_bio(const _LHASH *lh, BIO *out);
194#endif 195#endif
196
197/* Type checking... */
198
199#define LHASH_OF(type) struct lhash_st_##type
200
201#define DECLARE_LHASH_OF(type) LHASH_OF(type) { int dummy; }
202
203#define CHECKED_LHASH_OF(type,lh) \
204 ((_LHASH *)CHECKED_PTR_OF(LHASH_OF(type),lh))
205
206/* Define wrapper functions. */
207#define LHM_lh_new(type, name) \
208 ((LHASH_OF(type) *)lh_new(LHASH_HASH_FN(name), LHASH_COMP_FN(name)))
209#define LHM_lh_error(type, lh) \
210 lh_error(CHECKED_LHASH_OF(type,lh))
211#define LHM_lh_insert(type, lh, inst) \
212 ((type *)lh_insert(CHECKED_LHASH_OF(type, lh), \
213 CHECKED_PTR_OF(type, inst)))
214#define LHM_lh_retrieve(type, lh, inst) \
215 ((type *)lh_retrieve(CHECKED_LHASH_OF(type, lh), \
216 CHECKED_PTR_OF(type, inst)))
217#define LHM_lh_delete(type, lh, inst) \
218 ((type *)lh_delete(CHECKED_LHASH_OF(type, lh), \
219 CHECKED_PTR_OF(type, inst)))
220#define LHM_lh_doall(type, lh,fn) lh_doall(CHECKED_LHASH_OF(type, lh), fn)
221#define LHM_lh_doall_arg(type, lh, fn, arg_type, arg) \
222 lh_doall_arg(CHECKED_LHASH_OF(type, lh), fn, CHECKED_PTR_OF(arg_type, arg))
223#define LHM_lh_num_items(type, lh) lh_num_items(CHECKED_LHASH_OF(type, lh))
224#define LHM_lh_down_load(type, lh) (CHECKED_LHASH_OF(type, lh)->down_load)
225#define LHM_lh_node_stats_bio(type, lh, out) \
226 lh_node_stats_bio(CHECKED_LHASH_OF(type, lh), out)
227#define LHM_lh_node_usage_stats_bio(type, lh, out) \
228 lh_node_usage_stats_bio(CHECKED_LHASH_OF(type, lh), out)
229#define LHM_lh_stats_bio(type, lh, out) \
230 lh_stats_bio(CHECKED_LHASH_OF(type, lh), out)
231#define LHM_lh_free(type, lh) lh_free(CHECKED_LHASH_OF(type, lh))
232
233DECLARE_LHASH_OF(OPENSSL_STRING);
234DECLARE_LHASH_OF(OPENSSL_CSTRING);
235
195#ifdef __cplusplus 236#ifdef __cplusplus
196} 237}
197#endif 238#endif
diff --git a/src/lib/libcrypto/md2/Makefile.ssl b/src/lib/libcrypto/md2/Makefile.ssl
deleted file mode 100644
index 3206924c90..0000000000
--- a/src/lib/libcrypto/md2/Makefile.ssl
+++ /dev/null
@@ -1,93 +0,0 @@
1#
2# SSLeay/crypto/md/Makefile
3#
4
5DIR= md2
6TOP= ../..
7CC= cc
8INCLUDES=
9CFLAG=-g
10INSTALL_PREFIX=
11OPENSSLDIR= /usr/local/ssl
12INSTALLTOP=/usr/local/ssl
13MAKE= make -f Makefile.ssl
14MAKEDEPPROG= makedepend
15MAKEDEPEND= $(TOP)/util/domd $(TOP) -MD $(MAKEDEPPROG)
16MAKEFILE= Makefile.ssl
17AR= ar r
18
19CFLAGS= $(INCLUDES) $(CFLAG)
20
21GENERAL=Makefile
22TEST=md2test.c
23APPS=
24
25LIB=$(TOP)/libcrypto.a
26LIBSRC=md2_dgst.c md2_one.c
27LIBOBJ=md2_dgst.o md2_one.o
28
29SRC= $(LIBSRC)
30
31EXHEADER= md2.h
32HEADER= $(EXHEADER)
33
34ALL= $(GENERAL) $(SRC) $(HEADER)
35
36top:
37 (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all)
38
39all: lib
40
41lib: $(LIBOBJ)
42 $(AR) $(LIB) $(LIBOBJ)
43 $(RANLIB) $(LIB) || echo Never mind.
44 @touch lib
45
46files:
47 $(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO
48
49links:
50 @sh $(TOP)/util/point.sh Makefile.ssl Makefile
51 @$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER)
52 @$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST)
53 @$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS)
54
55install:
56 @for i in $(EXHEADER) ; \
57 do \
58 (cp $$i $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i; \
59 chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i ); \
60 done;
61
62tags:
63 ctags $(SRC)
64
65tests:
66
67lint:
68 lint -DLINT $(INCLUDES) $(SRC)>fluff
69
70depend:
71 $(MAKEDEPEND) -- $(CFLAG) $(INCLUDES) $(DEPFLAG) -- $(PROGS) $(LIBSRC)
72
73dclean:
74 $(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
75 mv -f Makefile.new $(MAKEFILE)
76
77clean:
78 rm -f *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff
79
80# DO NOT DELETE THIS LINE -- make depend depends on it.
81
82md2_dgst.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
83md2_dgst.o: ../../include/openssl/md2.h ../../include/openssl/opensslconf.h
84md2_dgst.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
85md2_dgst.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
86md2_dgst.o: md2_dgst.c
87md2_one.o: ../../e_os.h ../../include/openssl/bio.h
88md2_one.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
89md2_one.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
90md2_one.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h
91md2_one.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
92md2_one.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
93md2_one.o: ../../include/openssl/symhacks.h ../cryptlib.h md2_one.c
diff --git a/src/lib/libcrypto/md2/md2.h b/src/lib/libcrypto/md2/md2.h
index d59c9f2593..a46120e7d4 100644
--- a/src/lib/libcrypto/md2/md2.h
+++ b/src/lib/libcrypto/md2/md2.h
@@ -81,9 +81,6 @@ typedef struct MD2state_st
81 } MD2_CTX; 81 } MD2_CTX;
82 82
83const char *MD2_options(void); 83const char *MD2_options(void);
84#ifdef OPENSSL_FIPS
85int private_MD2_Init(MD2_CTX *c);
86#endif
87int MD2_Init(MD2_CTX *c); 84int MD2_Init(MD2_CTX *c);
88int MD2_Update(MD2_CTX *c, const unsigned char *data, size_t len); 85int MD2_Update(MD2_CTX *c, const unsigned char *data, size_t len);
89int MD2_Final(unsigned char *md, MD2_CTX *c); 86int MD2_Final(unsigned char *md, MD2_CTX *c);
diff --git a/src/lib/libcrypto/md2/md2_dgst.c b/src/lib/libcrypto/md2/md2_dgst.c
index cc4eeaf7a7..c57b3da288 100644
--- a/src/lib/libcrypto/md2/md2_dgst.c
+++ b/src/lib/libcrypto/md2/md2_dgst.c
@@ -62,11 +62,6 @@
62#include <openssl/md2.h> 62#include <openssl/md2.h>
63#include <openssl/opensslv.h> 63#include <openssl/opensslv.h>
64#include <openssl/crypto.h> 64#include <openssl/crypto.h>
65#ifdef OPENSSL_FIPS
66#include <openssl/fips.h>
67#endif
68
69#include <openssl/err.h>
70 65
71const char MD2_version[]="MD2" OPENSSL_VERSION_PTEXT; 66const char MD2_version[]="MD2" OPENSSL_VERSION_PTEXT;
72 67
@@ -78,7 +73,7 @@ const char MD2_version[]="MD2" OPENSSL_VERSION_PTEXT;
78static void md2_block(MD2_CTX *c, const unsigned char *d); 73static void md2_block(MD2_CTX *c, const unsigned char *d);
79/* The magic S table - I have converted it to hex since it is 74/* The magic S table - I have converted it to hex since it is
80 * basically just a random byte string. */ 75 * basically just a random byte string. */
81static MD2_INT S[256]={ 76static const MD2_INT S[256]={
82 0x29, 0x2E, 0x43, 0xC9, 0xA2, 0xD8, 0x7C, 0x01, 77 0x29, 0x2E, 0x43, 0xC9, 0xA2, 0xD8, 0x7C, 0x01,
83 0x3D, 0x36, 0x54, 0xA1, 0xEC, 0xF0, 0x06, 0x13, 78 0x3D, 0x36, 0x54, 0xA1, 0xEC, 0xF0, 0x06, 0x13,
84 0x62, 0xA7, 0x05, 0xF3, 0xC0, 0xC7, 0x73, 0x8C, 79 0x62, 0xA7, 0x05, 0xF3, 0xC0, 0xC7, 0x73, 0x8C,
@@ -121,7 +116,7 @@ const char *MD2_options(void)
121 return("md2(int)"); 116 return("md2(int)");
122 } 117 }
123 118
124FIPS_NON_FIPS_MD_Init(MD2) 119int MD2_Init(MD2_CTX *c)
125 { 120 {
126 c->num=0; 121 c->num=0;
127 memset(c->state,0,sizeof c->state); 122 memset(c->state,0,sizeof c->state);
diff --git a/src/lib/libcrypto/md32_common.h b/src/lib/libcrypto/md32_common.h
index 61bcd9786f..1cb783944e 100644
--- a/src/lib/libcrypto/md32_common.h
+++ b/src/lib/libcrypto/md32_common.h
@@ -241,11 +241,11 @@
241#ifndef PEDANTIC 241#ifndef PEDANTIC
242# if defined(__GNUC__) && __GNUC__>=2 && !defined(OPENSSL_NO_ASM) && !defined(OPENSSL_NO_INLINE_ASM) 242# if defined(__GNUC__) && __GNUC__>=2 && !defined(OPENSSL_NO_ASM) && !defined(OPENSSL_NO_INLINE_ASM)
243# if defined(__s390x__) 243# if defined(__s390x__)
244# define HOST_c2l(c,l) ({ asm ("lrv %0,0(%1)" \ 244# define HOST_c2l(c,l) ({ asm ("lrv %0,%1" \
245 :"=r"(l) : "r"(c)); \ 245 :"=d"(l) :"m"(*(const unsigned int *)(c)));\
246 (c)+=4; (l); }) 246 (c)+=4; (l); })
247# define HOST_l2c(l,c) ({ asm ("strv %0,0(%1)" \ 247# define HOST_l2c(l,c) ({ asm ("strv %1,%0" \
248 : : "r"(l),"r"(c) : "memory"); \ 248 :"=m"(*(unsigned int *)(c)) :"d"(l));\
249 (c)+=4; (l); }) 249 (c)+=4; (l); })
250# endif 250# endif
251# endif 251# endif
@@ -293,7 +293,7 @@ int HASH_UPDATE (HASH_CTX *c, const void *data_, size_t len)
293 * Wei Dai <weidai@eskimo.com> for pointing it out. */ 293 * Wei Dai <weidai@eskimo.com> for pointing it out. */
294 if (l < c->Nl) /* overflow */ 294 if (l < c->Nl) /* overflow */
295 c->Nh++; 295 c->Nh++;
296 c->Nh+=(len>>29); /* might cause compiler warning on 16-bit */ 296 c->Nh+=(HASH_LONG)(len>>29); /* might cause compiler warning on 16-bit */
297 c->Nl=l; 297 c->Nl=l;
298 298
299 n = c->num; 299 n = c->num;
@@ -331,7 +331,7 @@ int HASH_UPDATE (HASH_CTX *c, const void *data_, size_t len)
331 if (len != 0) 331 if (len != 0)
332 { 332 {
333 p = (unsigned char *)c->data; 333 p = (unsigned char *)c->data;
334 c->num = len; 334 c->num = (unsigned int)len;
335 memcpy (p,data,len); 335 memcpy (p,data,len);
336 } 336 }
337 return 1; 337 return 1;
diff --git a/src/lib/libcrypto/md4/Makefile.ssl b/src/lib/libcrypto/md4/Makefile.ssl
deleted file mode 100644
index 7d2e8d8d3b..0000000000
--- a/src/lib/libcrypto/md4/Makefile.ssl
+++ /dev/null
@@ -1,91 +0,0 @@
1#
2# SSLeay/crypto/md4/Makefile
3#
4
5DIR= md4
6TOP= ../..
7CC= cc
8CPP= $(CC) -E
9INCLUDES=
10CFLAG=-g
11INSTALL_PREFIX=
12OPENSSLDIR= /usr/local/ssl
13INSTALLTOP=/usr/local/ssl
14MAKE= make -f Makefile.ssl
15MAKEDEPPROG= makedepend
16MAKEDEPEND= $(TOP)/util/domd $(TOP) -MD $(MAKEDEPPROG)
17MAKEFILE= Makefile.ssl
18AR= ar r
19
20CFLAGS= $(INCLUDES) $(CFLAG)
21
22GENERAL=Makefile
23TEST=md4test.c
24APPS=md4.c
25
26LIB=$(TOP)/libcrypto.a
27LIBSRC=md4_dgst.c md4_one.c
28LIBOBJ=md4_dgst.o md4_one.o
29
30SRC= $(LIBSRC)
31
32EXHEADER= md4.h
33HEADER= md4_locl.h $(EXHEADER)
34
35ALL= $(GENERAL) $(SRC) $(HEADER)
36
37top:
38 (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all)
39
40all: lib
41
42lib: $(LIBOBJ)
43 $(AR) $(LIB) $(LIBOBJ)
44 $(RANLIB) $(LIB) || echo Never mind.
45 @touch lib
46
47files:
48 $(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO
49
50links:
51 @sh $(TOP)/util/point.sh Makefile.ssl Makefile
52 @$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER)
53 @$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST)
54 @$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS)
55
56install:
57 @for i in $(EXHEADER) ; \
58 do \
59 (cp $$i $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i; \
60 chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i ); \
61 done;
62
63tags:
64 ctags $(SRC)
65
66tests:
67
68lint:
69 lint -DLINT $(INCLUDES) $(SRC)>fluff
70
71depend:
72 $(MAKEDEPEND) -- $(CFLAG) $(INCLUDES) $(DEPFLAG) -- $(PROGS) $(LIBSRC)
73
74dclean:
75 $(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
76 mv -f Makefile.new $(MAKEFILE)
77
78clean:
79 rm -f asm/mx86unix.cpp *.o asm/*.o *.obj lib tags core .pure .nfs* *.old *.bak fluff
80
81# DO NOT DELETE THIS LINE -- make depend depends on it.
82
83md4_dgst.o: ../../include/openssl/e_os2.h ../../include/openssl/md4.h
84md4_dgst.o: ../../include/openssl/opensslconf.h
85md4_dgst.o: ../../include/openssl/opensslv.h ../md32_common.h md4_dgst.c
86md4_dgst.o: md4_locl.h
87md4_one.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
88md4_one.o: ../../include/openssl/md4.h ../../include/openssl/opensslconf.h
89md4_one.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
90md4_one.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
91md4_one.o: md4_one.c
diff --git a/src/lib/libcrypto/md4/md4.h b/src/lib/libcrypto/md4/md4.h
index ba1fe4a6ee..c3ed9b3f75 100644
--- a/src/lib/libcrypto/md4/md4.h
+++ b/src/lib/libcrypto/md4/md4.h
@@ -77,7 +77,7 @@ extern "C" {
77 * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 77 * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
78 */ 78 */
79 79
80#if defined(OPENSSL_SYS_WIN16) || defined(__LP32__) 80#if defined(__LP32__)
81#define MD4_LONG unsigned long 81#define MD4_LONG unsigned long
82#elif defined(OPENSSL_SYS_CRAY) || defined(__ILP64__) 82#elif defined(OPENSSL_SYS_CRAY) || defined(__ILP64__)
83#define MD4_LONG unsigned long 83#define MD4_LONG unsigned long
@@ -105,9 +105,6 @@ typedef struct MD4state_st
105 unsigned int num; 105 unsigned int num;
106 } MD4_CTX; 106 } MD4_CTX;
107 107
108#ifdef OPENSSL_FIPS
109int private_MD4_Init(MD4_CTX *c);
110#endif
111int MD4_Init(MD4_CTX *c); 108int MD4_Init(MD4_CTX *c);
112int MD4_Update(MD4_CTX *c, const void *data, size_t len); 109int MD4_Update(MD4_CTX *c, const void *data, size_t len);
113int MD4_Final(unsigned char *md, MD4_CTX *c); 110int MD4_Final(unsigned char *md, MD4_CTX *c);
diff --git a/src/lib/libcrypto/md4/md4_dgst.c b/src/lib/libcrypto/md4/md4_dgst.c
index 0f5448601d..e0c42e8596 100644
--- a/src/lib/libcrypto/md4/md4_dgst.c
+++ b/src/lib/libcrypto/md4/md4_dgst.c
@@ -59,11 +59,6 @@
59#include <stdio.h> 59#include <stdio.h>
60#include "md4_locl.h" 60#include "md4_locl.h"
61#include <openssl/opensslv.h> 61#include <openssl/opensslv.h>
62#include <openssl/err.h>
63#ifdef OPENSSL_FIPS
64#include <openssl/fips.h>
65#endif
66
67 62
68const char MD4_version[]="MD4" OPENSSL_VERSION_PTEXT; 63const char MD4_version[]="MD4" OPENSSL_VERSION_PTEXT;
69 64
@@ -75,15 +70,13 @@ const char MD4_version[]="MD4" OPENSSL_VERSION_PTEXT;
75#define INIT_DATA_C (unsigned long)0x98badcfeL 70#define INIT_DATA_C (unsigned long)0x98badcfeL
76#define INIT_DATA_D (unsigned long)0x10325476L 71#define INIT_DATA_D (unsigned long)0x10325476L
77 72
78FIPS_NON_FIPS_MD_Init(MD4) 73int MD4_Init(MD4_CTX *c)
79 { 74 {
75 memset (c,0,sizeof(*c));
80 c->A=INIT_DATA_A; 76 c->A=INIT_DATA_A;
81 c->B=INIT_DATA_B; 77 c->B=INIT_DATA_B;
82 c->C=INIT_DATA_C; 78 c->C=INIT_DATA_C;
83 c->D=INIT_DATA_D; 79 c->D=INIT_DATA_D;
84 c->Nl=0;
85 c->Nh=0;
86 c->num=0;
87 return 1; 80 return 1;
88 } 81 }
89 82
diff --git a/src/lib/libcrypto/md5/Makefile.ssl b/src/lib/libcrypto/md5/Makefile.ssl
deleted file mode 100644
index 2361775a2d..0000000000
--- a/src/lib/libcrypto/md5/Makefile.ssl
+++ /dev/null
@@ -1,127 +0,0 @@
1#
2# SSLeay/crypto/md5/Makefile
3#
4
5DIR= md5
6TOP= ../..
7CC= cc
8CPP= $(CC) -E
9INCLUDES=-I.. -I$(TOP) -I../../include
10CFLAG=-g
11INSTALL_PREFIX=
12OPENSSLDIR= /usr/local/ssl
13INSTALLTOP=/usr/local/ssl
14MAKE= make -f Makefile.ssl
15MAKEDEPPROG= makedepend
16MAKEDEPEND= $(TOP)/util/domd $(TOP) -MD $(MAKEDEPPROG)
17MAKEFILE= Makefile.ssl
18AR= ar r
19
20MD5_ASM_OBJ=
21
22CFLAGS= $(INCLUDES) $(CFLAG)
23ASFLAGS= $(INCLUDES) $(ASFLAG)
24
25GENERAL=Makefile
26TEST=md5test.c
27APPS=
28
29LIB=$(TOP)/libcrypto.a
30LIBSRC=md5_dgst.c md5_one.c
31LIBOBJ=md5_dgst.o md5_one.o $(MD5_ASM_OBJ)
32
33SRC= $(LIBSRC)
34
35EXHEADER= md5.h
36HEADER= md5_locl.h $(EXHEADER)
37
38ALL= $(GENERAL) $(SRC) $(HEADER)
39
40top:
41 (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all)
42
43all: lib
44
45lib: $(LIBOBJ)
46 $(AR) $(LIB) $(LIBOBJ)
47 $(RANLIB) $(LIB) || echo Never mind.
48 @touch lib
49
50# elf
51asm/mx86-elf.s: asm/md5-586.pl ../perlasm/x86asm.pl
52 (cd asm; $(PERL) md5-586.pl elf $(CFLAGS) > mx86-elf.s)
53
54# a.out
55asm/mx86-out.o: asm/mx86unix.cpp
56 $(CPP) -DOUT asm/mx86unix.cpp | as -o asm/mx86-out.o
57
58# bsdi
59asm/mx86bsdi.o: asm/mx86unix.cpp
60 $(CPP) -DBSDI asm/mx86unix.cpp | sed 's/ :/:/' | as -o asm/mx86bsdi.o
61
62asm/mx86unix.cpp: asm/md5-586.pl ../perlasm/x86asm.pl
63 (cd asm; $(PERL) md5-586.pl cpp >mx86unix.cpp)
64
65asm/md5-sparcv8plus.o: asm/md5-sparcv9.S
66 $(CC) $(ASFLAGS) -DMD5_BLOCK_DATA_ORDER -c \
67 -o asm/md5-sparcv8plus.o asm/md5-sparcv9.S
68
69# Old GNU assembler doesn't understand V9 instructions, so we
70# hire /usr/ccs/bin/as to do the job. Note that option is called
71# *-gcc27, but even gcc 2>=8 users may experience similar problem
72# if they didn't bother to upgrade GNU assembler. Such users should
73# not choose this option, but be adviced to *remove* GNU assembler
74# or upgrade it.
75asm/md5-sparcv8plus-gcc27.o: asm/md5-sparcv9.S
76 $(CC) $(ASFLAGS) -DMD5_BLOCK_DATA_ORDER -E asm/md5-sparcv9.S | \
77 /usr/ccs/bin/as -xarch=v8plus - -o asm/md5-sparcv8plus-gcc27.o
78
79asm/md5-sparcv9.o: asm/md5-sparcv9.S
80 $(CC) $(ASFLAGS) -DMD5_BLOCK_DATA_ORDER -c \
81 -o asm/md5-sparcv9.o asm/md5-sparcv9.S
82
83files:
84 $(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO
85
86links:
87 @sh $(TOP)/util/point.sh Makefile.ssl Makefile
88 @$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER)
89 @$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST)
90 @$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS)
91
92install:
93 @for i in $(EXHEADER) ; \
94 do \
95 (cp $$i $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i; \
96 chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i ); \
97 done;
98
99tags:
100 ctags $(SRC)
101
102tests:
103
104lint:
105 lint -DLINT $(INCLUDES) $(SRC)>fluff
106
107depend:
108 $(MAKEDEPEND) -- $(CFLAG) $(INCLUDES) $(DEPFLAG) -- $(PROGS) $(LIBSRC)
109
110dclean:
111 $(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
112 mv -f Makefile.new $(MAKEFILE)
113
114clean:
115 rm -f asm/mx86unix.cpp asm/*-elf.* *.o asm/*.o *.obj lib tags core .pure .nfs* *.old *.bak fluff
116
117# DO NOT DELETE THIS LINE -- make depend depends on it.
118
119md5_dgst.o: ../../include/openssl/e_os2.h ../../include/openssl/md5.h
120md5_dgst.o: ../../include/openssl/opensslconf.h
121md5_dgst.o: ../../include/openssl/opensslv.h ../md32_common.h md5_dgst.c
122md5_dgst.o: md5_locl.h
123md5_one.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
124md5_one.o: ../../include/openssl/md5.h ../../include/openssl/opensslconf.h
125md5_one.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
126md5_one.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
127md5_one.o: md5_one.c
diff --git a/src/lib/libcrypto/md5/asm/md5-586.pl b/src/lib/libcrypto/md5/asm/md5-586.pl
index 76ac235f7d..6cb66bb499 100644
--- a/src/lib/libcrypto/md5/asm/md5-586.pl
+++ b/src/lib/libcrypto/md5/asm/md5-586.pl
@@ -7,7 +7,8 @@
7 7
8$normal=0; 8$normal=0;
9 9
10push(@INC,"perlasm","../../perlasm"); 10$0 =~ m/(.*[\/\\])[^\/\\]+$/; $dir=$1;
11push(@INC,"${dir}","${dir}../../perlasm");
11require "x86asm.pl"; 12require "x86asm.pl";
12 13
13&asm_init($ARGV[0],$0); 14&asm_init($ARGV[0],$0);
diff --git a/src/lib/libcrypto/md5/asm/md5-sparcv9.S b/src/lib/libcrypto/md5/asm/md5-sparcv9.S
deleted file mode 100644
index db45aa4c97..0000000000
--- a/src/lib/libcrypto/md5/asm/md5-sparcv9.S
+++ /dev/null
@@ -1,1031 +0,0 @@
1.ident "md5-sparcv9.S, Version 1.0"
2.ident "SPARC V9 ISA artwork by Andy Polyakov <appro@fy.chalmers.se>"
3.file "md5-sparcv9.S"
4
5/*
6 * ====================================================================
7 * Copyright (c) 1999 Andy Polyakov <appro@fy.chalmers.se>.
8 *
9 * Rights for redistribution and usage in source and binary forms are
10 * granted as long as above copyright notices are retained. Warranty
11 * of any kind is (of course:-) disclaimed.
12 * ====================================================================
13 */
14
15/*
16 * This is my modest contribution to OpenSSL project (see
17 * http://www.openssl.org/ for more information about it) and is an
18 * assembler implementation of MD5 block hash function. I've hand-coded
19 * this for the sole reason to reach UltraSPARC-specific "load in
20 * little-endian byte order" instruction. This gives up to 15%
21 * performance improvement for cases when input message is aligned at
22 * 32 bits boundary. The module was tested under both 32 *and* 64 bit
23 * kernels. For updates see http://fy.chalmers.se/~appro/hpe/.
24 *
25 * To compile with SC4.x/SC5.x:
26 *
27 * cc -xarch=v[9|8plus] -DOPENSSL_SYSNAME_ULTRASPARC -DMD5_BLOCK_DATA_ORDER \
28 * -c md5-sparcv9.S
29 *
30 * and with gcc:
31 *
32 * gcc -mcpu=ultrasparc -DOPENSSL_SYSNAME_ULTRASPARC -DMD5_BLOCK_DATA_ORDER \
33 * -c md5-sparcv9.S
34 *
35 * or if above fails (it does if you have gas):
36 *
37 * gcc -E -DOPENSSL_SYSNAMEULTRASPARC -DMD5_BLOCK_DATA_ORDER md5_block.sparc.S | \
38 * as -xarch=v8plus /dev/fd/0 -o md5-sparcv9.o
39 */
40
41#include <openssl/e_os2.h>
42
43#define A %o0
44#define B %o1
45#define C %o2
46#define D %o3
47#define T1 %o4
48#define T2 %o5
49
50#define R0 %l0
51#define R1 %l1
52#define R2 %l2
53#define R3 %l3
54#define R4 %l4
55#define R5 %l5
56#define R6 %l6
57#define R7 %l7
58#define R8 %i3
59#define R9 %i4
60#define R10 %i5
61#define R11 %g1
62#define R12 %g2
63#define R13 %g3
64#define RX %g4
65
66#define Aptr %i0+0
67#define Bptr %i0+4
68#define Cptr %i0+8
69#define Dptr %i0+12
70
71#define Aval R5 /* those not used at the end of the last round */
72#define Bval R6
73#define Cval R7
74#define Dval R8
75
76#if defined(MD5_BLOCK_DATA_ORDER)
77# if defined(OPENSSL_SYSNAME_ULTRASPARC)
78# define LOAD lda
79# define X(i) [%i1+i*4]%asi
80# define md5_block md5_block_asm_data_order_aligned
81# define ASI_PRIMARY_LITTLE 0x88
82# else
83# error "MD5_BLOCK_DATA_ORDER is supported only on UltraSPARC!"
84# endif
85#else
86# define LOAD ld
87# define X(i) [%i1+i*4]
88# define md5_block md5_block_asm_host_order
89#endif
90
91.section ".text",#alloc,#execinstr
92
93#if defined(__SUNPRO_C) && defined(__sparcv9)
94 /* They've said -xarch=v9 at command line */
95 .register %g2,#scratch
96 .register %g3,#scratch
97# define FRAME -192
98#elif defined(__GNUC__) && defined(__arch64__)
99 /* They've said -m64 at command line */
100 .register %g2,#scratch
101 .register %g3,#scratch
102# define FRAME -192
103#else
104# define FRAME -96
105#endif
106
107.align 32
108
109.global md5_block
110md5_block:
111 save %sp,FRAME,%sp
112
113 ld [Dptr],D
114 ld [Cptr],C
115 ld [Bptr],B
116 ld [Aptr],A
117#ifdef ASI_PRIMARY_LITTLE
118 rd %asi,%o7 ! How dare I? Well, I just do:-)
119 wr %g0,ASI_PRIMARY_LITTLE,%asi
120#endif
121 LOAD X(0),R0
122
123.Lmd5_block_loop:
124
125!!!!!!!!Round 0
126
127 xor C,D,T1
128 sethi %hi(0xd76aa478),T2
129 and T1,B,T1
130 or T2,%lo(0xd76aa478),T2 !=
131 xor T1,D,T1
132 add T1,R0,T1
133 LOAD X(1),R1
134 add T1,T2,T1 !=
135 add A,T1,A
136 sll A,7,T2
137 srl A,32-7,A
138 or A,T2,A !=
139 xor B,C,T1
140 add A,B,A
141
142 sethi %hi(0xe8c7b756),T2
143 and T1,A,T1 !=
144 or T2,%lo(0xe8c7b756),T2
145 xor T1,C,T1
146 LOAD X(2),R2
147 add T1,R1,T1 !=
148 add T1,T2,T1
149 add D,T1,D
150 sll D,12,T2
151 srl D,32-12,D !=
152 or D,T2,D
153 xor A,B,T1
154 add D,A,D
155
156 sethi %hi(0x242070db),T2 !=
157 and T1,D,T1
158 or T2,%lo(0x242070db),T2
159 xor T1,B,T1
160 add T1,R2,T1 !=
161 LOAD X(3),R3
162 add T1,T2,T1
163 add C,T1,C
164 sll C,17,T2 !=
165 srl C,32-17,C
166 or C,T2,C
167 xor D,A,T1
168 add C,D,C !=
169
170 sethi %hi(0xc1bdceee),T2
171 and T1,C,T1
172 or T2,%lo(0xc1bdceee),T2
173 xor T1,A,T1 !=
174 add T1,R3,T1
175 LOAD X(4),R4
176 add T1,T2,T1
177 add B,T1,B !=
178 sll B,22,T2
179 srl B,32-22,B
180 or B,T2,B
181 xor C,D,T1 !=
182 add B,C,B
183
184 sethi %hi(0xf57c0faf),T2
185 and T1,B,T1
186 or T2,%lo(0xf57c0faf),T2 !=
187 xor T1,D,T1
188 add T1,R4,T1
189 LOAD X(5),R5
190 add T1,T2,T1 !=
191 add A,T1,A
192 sll A,7,T2
193 srl A,32-7,A
194 or A,T2,A !=
195 xor B,C,T1
196 add A,B,A
197
198 sethi %hi(0x4787c62a),T2
199 and T1,A,T1 !=
200 or T2,%lo(0x4787c62a),T2
201 xor T1,C,T1
202 LOAD X(6),R6
203 add T1,R5,T1 !=
204 add T1,T2,T1
205 add D,T1,D
206 sll D,12,T2
207 srl D,32-12,D !=
208 or D,T2,D
209 xor A,B,T1
210 add D,A,D
211
212 sethi %hi(0xa8304613),T2 !=
213 and T1,D,T1
214 or T2,%lo(0xa8304613),T2
215 xor T1,B,T1
216 add T1,R6,T1 !=
217 LOAD X(7),R7
218 add T1,T2,T1
219 add C,T1,C
220 sll C,17,T2 !=
221 srl C,32-17,C
222 or C,T2,C
223 xor D,A,T1
224 add C,D,C !=
225
226 sethi %hi(0xfd469501),T2
227 and T1,C,T1
228 or T2,%lo(0xfd469501),T2
229 xor T1,A,T1 !=
230 add T1,R7,T1
231 LOAD X(8),R8
232 add T1,T2,T1
233 add B,T1,B !=
234 sll B,22,T2
235 srl B,32-22,B
236 or B,T2,B
237 xor C,D,T1 !=
238 add B,C,B
239
240 sethi %hi(0x698098d8),T2
241 and T1,B,T1
242 or T2,%lo(0x698098d8),T2 !=
243 xor T1,D,T1
244 add T1,R8,T1
245 LOAD X(9),R9
246 add T1,T2,T1 !=
247 add A,T1,A
248 sll A,7,T2
249 srl A,32-7,A
250 or A,T2,A !=
251 xor B,C,T1
252 add A,B,A
253
254 sethi %hi(0x8b44f7af),T2
255 and T1,A,T1 !=
256 or T2,%lo(0x8b44f7af),T2
257 xor T1,C,T1
258 LOAD X(10),R10
259 add T1,R9,T1 !=
260 add T1,T2,T1
261 add D,T1,D
262 sll D,12,T2
263 srl D,32-12,D !=
264 or D,T2,D
265 xor A,B,T1
266 add D,A,D
267
268 sethi %hi(0xffff5bb1),T2 !=
269 and T1,D,T1
270 or T2,%lo(0xffff5bb1),T2
271 xor T1,B,T1
272 add T1,R10,T1 !=
273 LOAD X(11),R11
274 add T1,T2,T1
275 add C,T1,C
276 sll C,17,T2 !=
277 srl C,32-17,C
278 or C,T2,C
279 xor D,A,T1
280 add C,D,C !=
281
282 sethi %hi(0x895cd7be),T2
283 and T1,C,T1
284 or T2,%lo(0x895cd7be),T2
285 xor T1,A,T1 !=
286 add T1,R11,T1
287 LOAD X(12),R12
288 add T1,T2,T1
289 add B,T1,B !=
290 sll B,22,T2
291 srl B,32-22,B
292 or B,T2,B
293 xor C,D,T1 !=
294 add B,C,B
295
296 sethi %hi(0x6b901122),T2
297 and T1,B,T1
298 or T2,%lo(0x6b901122),T2 !=
299 xor T1,D,T1
300 add T1,R12,T1
301 LOAD X(13),R13
302 add T1,T2,T1 !=
303 add A,T1,A
304 sll A,7,T2
305 srl A,32-7,A
306 or A,T2,A !=
307 xor B,C,T1
308 add A,B,A
309
310 sethi %hi(0xfd987193),T2
311 and T1,A,T1 !=
312 or T2,%lo(0xfd987193),T2
313 xor T1,C,T1
314 LOAD X(14),RX
315 add T1,R13,T1 !=
316 add T1,T2,T1
317 add D,T1,D
318 sll D,12,T2
319 srl D,32-12,D !=
320 or D,T2,D
321 xor A,B,T1
322 add D,A,D
323
324 sethi %hi(0xa679438e),T2 !=
325 and T1,D,T1
326 or T2,%lo(0xa679438e),T2
327 xor T1,B,T1
328 add T1,RX,T1 !=
329 LOAD X(15),RX
330 add T1,T2,T1
331 add C,T1,C
332 sll C,17,T2 !=
333 srl C,32-17,C
334 or C,T2,C
335 xor D,A,T1
336 add C,D,C !=
337
338 sethi %hi(0x49b40821),T2
339 and T1,C,T1
340 or T2,%lo(0x49b40821),T2
341 xor T1,A,T1 !=
342 add T1,RX,T1
343 !pre-LOADed X(1),R1
344 add T1,T2,T1
345 add B,T1,B
346 sll B,22,T2 !=
347 srl B,32-22,B
348 or B,T2,B
349 add B,C,B
350
351!!!!!!!!Round 1
352
353 xor B,C,T1 !=
354 sethi %hi(0xf61e2562),T2
355 and T1,D,T1
356 or T2,%lo(0xf61e2562),T2
357 xor T1,C,T1 !=
358 add T1,R1,T1
359 !pre-LOADed X(6),R6
360 add T1,T2,T1
361 add A,T1,A
362 sll A,5,T2 !=
363 srl A,32-5,A
364 or A,T2,A
365 add A,B,A
366
367 xor A,B,T1 !=
368 sethi %hi(0xc040b340),T2
369 and T1,C,T1
370 or T2,%lo(0xc040b340),T2
371 xor T1,B,T1 !=
372 add T1,R6,T1
373 !pre-LOADed X(11),R11
374 add T1,T2,T1
375 add D,T1,D
376 sll D,9,T2 !=
377 srl D,32-9,D
378 or D,T2,D
379 add D,A,D
380
381 xor D,A,T1 !=
382 sethi %hi(0x265e5a51),T2
383 and T1,B,T1
384 or T2,%lo(0x265e5a51),T2
385 xor T1,A,T1 !=
386 add T1,R11,T1
387 !pre-LOADed X(0),R0
388 add T1,T2,T1
389 add C,T1,C
390 sll C,14,T2 !=
391 srl C,32-14,C
392 or C,T2,C
393 add C,D,C
394
395 xor C,D,T1 !=
396 sethi %hi(0xe9b6c7aa),T2
397 and T1,A,T1
398 or T2,%lo(0xe9b6c7aa),T2
399 xor T1,D,T1 !=
400 add T1,R0,T1
401 !pre-LOADed X(5),R5
402 add T1,T2,T1
403 add B,T1,B
404 sll B,20,T2 !=
405 srl B,32-20,B
406 or B,T2,B
407 add B,C,B
408
409 xor B,C,T1 !=
410 sethi %hi(0xd62f105d),T2
411 and T1,D,T1
412 or T2,%lo(0xd62f105d),T2
413 xor T1,C,T1 !=
414 add T1,R5,T1
415 !pre-LOADed X(10),R10
416 add T1,T2,T1
417 add A,T1,A
418 sll A,5,T2 !=
419 srl A,32-5,A
420 or A,T2,A
421 add A,B,A
422
423 xor A,B,T1 !=
424 sethi %hi(0x02441453),T2
425 and T1,C,T1
426 or T2,%lo(0x02441453),T2
427 xor T1,B,T1 !=
428 add T1,R10,T1
429 LOAD X(15),RX
430 add T1,T2,T1
431 add D,T1,D !=
432 sll D,9,T2
433 srl D,32-9,D
434 or D,T2,D
435 add D,A,D !=
436
437 xor D,A,T1
438 sethi %hi(0xd8a1e681),T2
439 and T1,B,T1
440 or T2,%lo(0xd8a1e681),T2 !=
441 xor T1,A,T1
442 add T1,RX,T1
443 !pre-LOADed X(4),R4
444 add T1,T2,T1
445 add C,T1,C !=
446 sll C,14,T2
447 srl C,32-14,C
448 or C,T2,C
449 add C,D,C !=
450
451 xor C,D,T1
452 sethi %hi(0xe7d3fbc8),T2
453 and T1,A,T1
454 or T2,%lo(0xe7d3fbc8),T2 !=
455 xor T1,D,T1
456 add T1,R4,T1
457 !pre-LOADed X(9),R9
458 add T1,T2,T1
459 add B,T1,B !=
460 sll B,20,T2
461 srl B,32-20,B
462 or B,T2,B
463 add B,C,B !=
464
465 xor B,C,T1
466 sethi %hi(0x21e1cde6),T2
467 and T1,D,T1
468 or T2,%lo(0x21e1cde6),T2 !=
469 xor T1,C,T1
470 add T1,R9,T1
471 LOAD X(14),RX
472 add T1,T2,T1 !=
473 add A,T1,A
474 sll A,5,T2
475 srl A,32-5,A
476 or A,T2,A !=
477 add A,B,A
478
479 xor A,B,T1
480 sethi %hi(0xc33707d6),T2
481 and T1,C,T1 !=
482 or T2,%lo(0xc33707d6),T2
483 xor T1,B,T1
484 add T1,RX,T1
485 !pre-LOADed X(3),R3
486 add T1,T2,T1 !=
487 add D,T1,D
488 sll D,9,T2
489 srl D,32-9,D
490 or D,T2,D !=
491 add D,A,D
492
493 xor D,A,T1
494 sethi %hi(0xf4d50d87),T2
495 and T1,B,T1 !=
496 or T2,%lo(0xf4d50d87),T2
497 xor T1,A,T1
498 add T1,R3,T1
499 !pre-LOADed X(8),R8
500 add T1,T2,T1 !=
501 add C,T1,C
502 sll C,14,T2
503 srl C,32-14,C
504 or C,T2,C !=
505 add C,D,C
506
507 xor C,D,T1
508 sethi %hi(0x455a14ed),T2
509 and T1,A,T1 !=
510 or T2,%lo(0x455a14ed),T2
511 xor T1,D,T1
512 add T1,R8,T1
513 !pre-LOADed X(13),R13
514 add T1,T2,T1 !=
515 add B,T1,B
516 sll B,20,T2
517 srl B,32-20,B
518 or B,T2,B !=
519 add B,C,B
520
521 xor B,C,T1
522 sethi %hi(0xa9e3e905),T2
523 and T1,D,T1 !=
524 or T2,%lo(0xa9e3e905),T2
525 xor T1,C,T1
526 add T1,R13,T1
527 !pre-LOADed X(2),R2
528 add T1,T2,T1 !=
529 add A,T1,A
530 sll A,5,T2
531 srl A,32-5,A
532 or A,T2,A !=
533 add A,B,A
534
535 xor A,B,T1
536 sethi %hi(0xfcefa3f8),T2
537 and T1,C,T1 !=
538 or T2,%lo(0xfcefa3f8),T2
539 xor T1,B,T1
540 add T1,R2,T1
541 !pre-LOADed X(7),R7
542 add T1,T2,T1 !=
543 add D,T1,D
544 sll D,9,T2
545 srl D,32-9,D
546 or D,T2,D !=
547 add D,A,D
548
549 xor D,A,T1
550 sethi %hi(0x676f02d9),T2
551 and T1,B,T1 !=
552 or T2,%lo(0x676f02d9),T2
553 xor T1,A,T1
554 add T1,R7,T1
555 !pre-LOADed X(12),R12
556 add T1,T2,T1 !=
557 add C,T1,C
558 sll C,14,T2
559 srl C,32-14,C
560 or C,T2,C !=
561 add C,D,C
562
563 xor C,D,T1
564 sethi %hi(0x8d2a4c8a),T2
565 and T1,A,T1 !=
566 or T2,%lo(0x8d2a4c8a),T2
567 xor T1,D,T1
568 add T1,R12,T1
569 !pre-LOADed X(5),R5
570 add T1,T2,T1 !=
571 add B,T1,B
572 sll B,20,T2
573 srl B,32-20,B
574 or B,T2,B !=
575 add B,C,B
576
577!!!!!!!!Round 2
578
579 xor B,C,T1
580 sethi %hi(0xfffa3942),T2
581 xor T1,D,T1 !=
582 or T2,%lo(0xfffa3942),T2
583 add T1,R5,T1
584 !pre-LOADed X(8),R8
585 add T1,T2,T1
586 add A,T1,A !=
587 sll A,4,T2
588 srl A,32-4,A
589 or A,T2,A
590 add A,B,A !=
591
592 xor A,B,T1
593 sethi %hi(0x8771f681),T2
594 xor T1,C,T1
595 or T2,%lo(0x8771f681),T2 !=
596 add T1,R8,T1
597 !pre-LOADed X(11),R11
598 add T1,T2,T1
599 add D,T1,D
600 sll D,11,T2 !=
601 srl D,32-11,D
602 or D,T2,D
603 add D,A,D
604
605 xor D,A,T1 !=
606 sethi %hi(0x6d9d6122),T2
607 xor T1,B,T1
608 or T2,%lo(0x6d9d6122),T2
609 add T1,R11,T1 !=
610 LOAD X(14),RX
611 add T1,T2,T1
612 add C,T1,C
613 sll C,16,T2 !=
614 srl C,32-16,C
615 or C,T2,C
616 add C,D,C
617
618 xor C,D,T1 !=
619 sethi %hi(0xfde5380c),T2
620 xor T1,A,T1
621 or T2,%lo(0xfde5380c),T2
622 add T1,RX,T1 !=
623 !pre-LOADed X(1),R1
624 add T1,T2,T1
625 add B,T1,B
626 sll B,23,T2
627 srl B,32-23,B !=
628 or B,T2,B
629 add B,C,B
630
631 xor B,C,T1
632 sethi %hi(0xa4beea44),T2 !=
633 xor T1,D,T1
634 or T2,%lo(0xa4beea44),T2
635 add T1,R1,T1
636 !pre-LOADed X(4),R4
637 add T1,T2,T1 !=
638 add A,T1,A
639 sll A,4,T2
640 srl A,32-4,A
641 or A,T2,A !=
642 add A,B,A
643
644 xor A,B,T1
645 sethi %hi(0x4bdecfa9),T2
646 xor T1,C,T1 !=
647 or T2,%lo(0x4bdecfa9),T2
648 add T1,R4,T1
649 !pre-LOADed X(7),R7
650 add T1,T2,T1
651 add D,T1,D !=
652 sll D,11,T2
653 srl D,32-11,D
654 or D,T2,D
655 add D,A,D !=
656
657 xor D,A,T1
658 sethi %hi(0xf6bb4b60),T2
659 xor T1,B,T1
660 or T2,%lo(0xf6bb4b60),T2 !=
661 add T1,R7,T1
662 !pre-LOADed X(10),R10
663 add T1,T2,T1
664 add C,T1,C
665 sll C,16,T2 !=
666 srl C,32-16,C
667 or C,T2,C
668 add C,D,C
669
670 xor C,D,T1 !=
671 sethi %hi(0xbebfbc70),T2
672 xor T1,A,T1
673 or T2,%lo(0xbebfbc70),T2
674 add T1,R10,T1 !=
675 !pre-LOADed X(13),R13
676 add T1,T2,T1
677 add B,T1,B
678 sll B,23,T2
679 srl B,32-23,B !=
680 or B,T2,B
681 add B,C,B
682
683 xor B,C,T1
684 sethi %hi(0x289b7ec6),T2 !=
685 xor T1,D,T1
686 or T2,%lo(0x289b7ec6),T2
687 add T1,R13,T1
688 !pre-LOADed X(0),R0
689 add T1,T2,T1 !=
690 add A,T1,A
691 sll A,4,T2
692 srl A,32-4,A
693 or A,T2,A !=
694 add A,B,A
695
696 xor A,B,T1
697 sethi %hi(0xeaa127fa),T2
698 xor T1,C,T1 !=
699 or T2,%lo(0xeaa127fa),T2
700 add T1,R0,T1
701 !pre-LOADed X(3),R3
702 add T1,T2,T1
703 add D,T1,D !=
704 sll D,11,T2
705 srl D,32-11,D
706 or D,T2,D
707 add D,A,D !=
708
709 xor D,A,T1
710 sethi %hi(0xd4ef3085),T2
711 xor T1,B,T1
712 or T2,%lo(0xd4ef3085),T2 !=
713 add T1,R3,T1
714 !pre-LOADed X(6),R6
715 add T1,T2,T1
716 add C,T1,C
717 sll C,16,T2 !=
718 srl C,32-16,C
719 or C,T2,C
720 add C,D,C
721
722 xor C,D,T1 !=
723 sethi %hi(0x04881d05),T2
724 xor T1,A,T1
725 or T2,%lo(0x04881d05),T2
726 add T1,R6,T1 !=
727 !pre-LOADed X(9),R9
728 add T1,T2,T1
729 add B,T1,B
730 sll B,23,T2
731 srl B,32-23,B !=
732 or B,T2,B
733 add B,C,B
734
735 xor B,C,T1
736 sethi %hi(0xd9d4d039),T2 !=
737 xor T1,D,T1
738 or T2,%lo(0xd9d4d039),T2
739 add T1,R9,T1
740 !pre-LOADed X(12),R12
741 add T1,T2,T1 !=
742 add A,T1,A
743 sll A,4,T2
744 srl A,32-4,A
745 or A,T2,A !=
746 add A,B,A
747
748 xor A,B,T1
749 sethi %hi(0xe6db99e5),T2
750 xor T1,C,T1 !=
751 or T2,%lo(0xe6db99e5),T2
752 add T1,R12,T1
753 LOAD X(15),RX
754 add T1,T2,T1 !=
755 add D,T1,D
756 sll D,11,T2
757 srl D,32-11,D
758 or D,T2,D !=
759 add D,A,D
760
761 xor D,A,T1
762 sethi %hi(0x1fa27cf8),T2
763 xor T1,B,T1 !=
764 or T2,%lo(0x1fa27cf8),T2
765 add T1,RX,T1
766 !pre-LOADed X(2),R2
767 add T1,T2,T1
768 add C,T1,C !=
769 sll C,16,T2
770 srl C,32-16,C
771 or C,T2,C
772 add C,D,C !=
773
774 xor C,D,T1
775 sethi %hi(0xc4ac5665),T2
776 xor T1,A,T1
777 or T2,%lo(0xc4ac5665),T2 !=
778 add T1,R2,T1
779 !pre-LOADed X(0),R0
780 add T1,T2,T1
781 add B,T1,B
782 sll B,23,T2 !=
783 srl B,32-23,B
784 or B,T2,B
785 add B,C,B
786
787!!!!!!!!Round 3
788
789 orn B,D,T1 !=
790 sethi %hi(0xf4292244),T2
791 xor T1,C,T1
792 or T2,%lo(0xf4292244),T2
793 add T1,R0,T1 !=
794 !pre-LOADed X(7),R7
795 add T1,T2,T1
796 add A,T1,A
797 sll A,6,T2
798 srl A,32-6,A !=
799 or A,T2,A
800 add A,B,A
801
802 orn A,C,T1
803 sethi %hi(0x432aff97),T2 !=
804 xor T1,B,T1
805 or T2,%lo(0x432aff97),T2
806 LOAD X(14),RX
807 add T1,R7,T1 !=
808 add T1,T2,T1
809 add D,T1,D
810 sll D,10,T2
811 srl D,32-10,D !=
812 or D,T2,D
813 add D,A,D
814
815 orn D,B,T1
816 sethi %hi(0xab9423a7),T2 !=
817 xor T1,A,T1
818 or T2,%lo(0xab9423a7),T2
819 add T1,RX,T1
820 !pre-LOADed X(5),R5
821 add T1,T2,T1 !=
822 add C,T1,C
823 sll C,15,T2
824 srl C,32-15,C
825 or C,T2,C !=
826 add C,D,C
827
828 orn C,A,T1
829 sethi %hi(0xfc93a039),T2
830 xor T1,D,T1 !=
831 or T2,%lo(0xfc93a039),T2
832 add T1,R5,T1
833 !pre-LOADed X(12),R12
834 add T1,T2,T1
835 add B,T1,B !=
836 sll B,21,T2
837 srl B,32-21,B
838 or B,T2,B
839 add B,C,B !=
840
841 orn B,D,T1
842 sethi %hi(0x655b59c3),T2
843 xor T1,C,T1
844 or T2,%lo(0x655b59c3),T2 !=
845 add T1,R12,T1
846 !pre-LOADed X(3),R3
847 add T1,T2,T1
848 add A,T1,A
849 sll A,6,T2 !=
850 srl A,32-6,A
851 or A,T2,A
852 add A,B,A
853
854 orn A,C,T1 !=
855 sethi %hi(0x8f0ccc92),T2
856 xor T1,B,T1
857 or T2,%lo(0x8f0ccc92),T2
858 add T1,R3,T1 !=
859 !pre-LOADed X(10),R10
860 add T1,T2,T1
861 add D,T1,D
862 sll D,10,T2
863 srl D,32-10,D !=
864 or D,T2,D
865 add D,A,D
866
867 orn D,B,T1
868 sethi %hi(0xffeff47d),T2 !=
869 xor T1,A,T1
870 or T2,%lo(0xffeff47d),T2
871 add T1,R10,T1
872 !pre-LOADed X(1),R1
873 add T1,T2,T1 !=
874 add C,T1,C
875 sll C,15,T2
876 srl C,32-15,C
877 or C,T2,C !=
878 add C,D,C
879
880 orn C,A,T1
881 sethi %hi(0x85845dd1),T2
882 xor T1,D,T1 !=
883 or T2,%lo(0x85845dd1),T2
884 add T1,R1,T1
885 !pre-LOADed X(8),R8
886 add T1,T2,T1
887 add B,T1,B !=
888 sll B,21,T2
889 srl B,32-21,B
890 or B,T2,B
891 add B,C,B !=
892
893 orn B,D,T1
894 sethi %hi(0x6fa87e4f),T2
895 xor T1,C,T1
896 or T2,%lo(0x6fa87e4f),T2 !=
897 add T1,R8,T1
898 LOAD X(15),RX
899 add T1,T2,T1
900 add A,T1,A !=
901 sll A,6,T2
902 srl A,32-6,A
903 or A,T2,A
904 add A,B,A !=
905
906 orn A,C,T1
907 sethi %hi(0xfe2ce6e0),T2
908 xor T1,B,T1
909 or T2,%lo(0xfe2ce6e0),T2 !=
910 add T1,RX,T1
911 !pre-LOADed X(6),R6
912 add T1,T2,T1
913 add D,T1,D
914 sll D,10,T2 !=
915 srl D,32-10,D
916 or D,T2,D
917 add D,A,D
918
919 orn D,B,T1 !=
920 sethi %hi(0xa3014314),T2
921 xor T1,A,T1
922 or T2,%lo(0xa3014314),T2
923 add T1,R6,T1 !=
924 !pre-LOADed X(13),R13
925 add T1,T2,T1
926 add C,T1,C
927 sll C,15,T2
928 srl C,32-15,C !=
929 or C,T2,C
930 add C,D,C
931
932 orn C,A,T1
933 sethi %hi(0x4e0811a1),T2 !=
934 xor T1,D,T1
935 or T2,%lo(0x4e0811a1),T2
936 !pre-LOADed X(4),R4
937 ld [Aptr],Aval
938 add T1,R13,T1 !=
939 add T1,T2,T1
940 add B,T1,B
941 sll B,21,T2
942 srl B,32-21,B !=
943 or B,T2,B
944 add B,C,B
945
946 orn B,D,T1
947 sethi %hi(0xf7537e82),T2 !=
948 xor T1,C,T1
949 or T2,%lo(0xf7537e82),T2
950 !pre-LOADed X(11),R11
951 ld [Dptr],Dval
952 add T1,R4,T1 !=
953 add T1,T2,T1
954 add A,T1,A
955 sll A,6,T2
956 srl A,32-6,A !=
957 or A,T2,A
958 add A,B,A
959
960 orn A,C,T1
961 sethi %hi(0xbd3af235),T2 !=
962 xor T1,B,T1
963 or T2,%lo(0xbd3af235),T2
964 !pre-LOADed X(2),R2
965 ld [Cptr],Cval
966 add T1,R11,T1 !=
967 add T1,T2,T1
968 add D,T1,D
969 sll D,10,T2
970 srl D,32-10,D !=
971 or D,T2,D
972 add D,A,D
973
974 orn D,B,T1
975 sethi %hi(0x2ad7d2bb),T2 !=
976 xor T1,A,T1
977 or T2,%lo(0x2ad7d2bb),T2
978 !pre-LOADed X(9),R9
979 ld [Bptr],Bval
980 add T1,R2,T1 !=
981 add Aval,A,Aval
982 add T1,T2,T1
983 st Aval,[Aptr]
984 add C,T1,C !=
985 sll C,15,T2
986 add Dval,D,Dval
987 srl C,32-15,C
988 or C,T2,C !=
989 st Dval,[Dptr]
990 add C,D,C
991
992 orn C,A,T1
993 sethi %hi(0xeb86d391),T2 !=
994 xor T1,D,T1
995 or T2,%lo(0xeb86d391),T2
996 add T1,R9,T1
997 !pre-LOADed X(0),R0
998 mov Aval,A !=
999 add T1,T2,T1
1000 mov Dval,D
1001 add B,T1,B
1002 sll B,21,T2 !=
1003 add Cval,C,Cval
1004 srl B,32-21,B
1005 st Cval,[Cptr]
1006 or B,T2,B !=
1007 add B,C,B
1008
1009 deccc %i2
1010 mov Cval,C
1011 add B,Bval,B !=
1012 inc 64,%i1
1013 nop
1014 st B,[Bptr]
1015 nop !=
1016
1017#ifdef OPENSSL_SYSNAME_ULTRASPARC
1018 bg,a,pt %icc,.Lmd5_block_loop
1019#else
1020 bg,a .Lmd5_block_loop
1021#endif
1022 LOAD X(0),R0
1023
1024#ifdef ASI_PRIMARY_LITTLE
1025 wr %g0,%o7,%asi
1026#endif
1027 ret
1028 restore %g0,0,%o0
1029
1030.type md5_block,#function
1031.size md5_block,(.-md5_block)
diff --git a/src/lib/libcrypto/md5/md5.h b/src/lib/libcrypto/md5/md5.h
index 0761f84a27..4cbf84386b 100644
--- a/src/lib/libcrypto/md5/md5.h
+++ b/src/lib/libcrypto/md5/md5.h
@@ -77,7 +77,7 @@ extern "C" {
77 * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 77 * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
78 */ 78 */
79 79
80#if defined(OPENSSL_SYS_WIN16) || defined(__LP32__) 80#if defined(__LP32__)
81#define MD5_LONG unsigned long 81#define MD5_LONG unsigned long
82#elif defined(OPENSSL_SYS_CRAY) || defined(__ILP64__) 82#elif defined(OPENSSL_SYS_CRAY) || defined(__ILP64__)
83#define MD5_LONG unsigned long 83#define MD5_LONG unsigned long
@@ -105,9 +105,6 @@ typedef struct MD5state_st
105 unsigned int num; 105 unsigned int num;
106 } MD5_CTX; 106 } MD5_CTX;
107 107
108#ifdef OPENSSL_FIPS
109int private_MD5_Init(MD5_CTX *c);
110#endif
111int MD5_Init(MD5_CTX *c); 108int MD5_Init(MD5_CTX *c);
112int MD5_Update(MD5_CTX *c, const void *data, size_t len); 109int MD5_Update(MD5_CTX *c, const void *data, size_t len);
113int MD5_Final(unsigned char *md, MD5_CTX *c); 110int MD5_Final(unsigned char *md, MD5_CTX *c);
diff --git a/src/lib/libcrypto/md5/md5_dgst.c b/src/lib/libcrypto/md5/md5_dgst.c
index 47bb9020ee..beace632e3 100644
--- a/src/lib/libcrypto/md5/md5_dgst.c
+++ b/src/lib/libcrypto/md5/md5_dgst.c
@@ -59,11 +59,6 @@
59#include <stdio.h> 59#include <stdio.h>
60#include "md5_locl.h" 60#include "md5_locl.h"
61#include <openssl/opensslv.h> 61#include <openssl/opensslv.h>
62#include <openssl/err.h>
63#ifdef OPENSSL_FIPS
64#include <openssl/fips.h>
65#endif
66
67 62
68const char MD5_version[]="MD5" OPENSSL_VERSION_PTEXT; 63const char MD5_version[]="MD5" OPENSSL_VERSION_PTEXT;
69 64
@@ -75,15 +70,13 @@ const char MD5_version[]="MD5" OPENSSL_VERSION_PTEXT;
75#define INIT_DATA_C (unsigned long)0x98badcfeL 70#define INIT_DATA_C (unsigned long)0x98badcfeL
76#define INIT_DATA_D (unsigned long)0x10325476L 71#define INIT_DATA_D (unsigned long)0x10325476L
77 72
78FIPS_NON_FIPS_MD_Init(MD5) 73int MD5_Init(MD5_CTX *c)
79 { 74 {
75 memset (c,0,sizeof(*c));
80 c->A=INIT_DATA_A; 76 c->A=INIT_DATA_A;
81 c->B=INIT_DATA_B; 77 c->B=INIT_DATA_B;
82 c->C=INIT_DATA_C; 78 c->C=INIT_DATA_C;
83 c->D=INIT_DATA_D; 79 c->D=INIT_DATA_D;
84 c->Nl=0;
85 c->Nh=0;
86 c->num=0;
87 return 1; 80 return 1;
88 } 81 }
89 82
diff --git a/src/lib/libcrypto/md5/md5_locl.h b/src/lib/libcrypto/md5/md5_locl.h
index 84e81b960d..968d577995 100644
--- a/src/lib/libcrypto/md5/md5_locl.h
+++ b/src/lib/libcrypto/md5/md5_locl.h
@@ -69,6 +69,8 @@
69# if defined(__i386) || defined(__i386__) || defined(_M_IX86) || defined(__INTEL__) || \ 69# if defined(__i386) || defined(__i386__) || defined(_M_IX86) || defined(__INTEL__) || \
70 defined(__x86_64) || defined(__x86_64__) || defined(_M_AMD64) || defined(_M_X64) 70 defined(__x86_64) || defined(__x86_64__) || defined(_M_AMD64) || defined(_M_X64)
71# define md5_block_data_order md5_block_asm_data_order 71# define md5_block_data_order md5_block_asm_data_order
72# elif defined(__ia64) || defined(__ia64__) || defined(_M_IA64)
73# define md5_block_data_order md5_block_asm_data_order
72# endif 74# endif
73#endif 75#endif
74 76
diff --git a/src/lib/libcrypto/mdc2/Makefile b/src/lib/libcrypto/mdc2/Makefile
index ea25688d88..1d064f17a6 100644
--- a/src/lib/libcrypto/mdc2/Makefile
+++ b/src/lib/libcrypto/mdc2/Makefile
@@ -33,7 +33,7 @@ top:
33all: lib 33all: lib
34 34
35lib: $(LIBOBJ) 35lib: $(LIBOBJ)
36 $(ARX) $(LIB) $(LIBOBJ) 36 $(AR) $(LIB) $(LIBOBJ)
37 $(RANLIB) $(LIB) || echo Never mind. 37 $(RANLIB) $(LIB) || echo Never mind.
38 @touch lib 38 @touch lib
39 39
diff --git a/src/lib/libcrypto/mdc2/Makefile.ssl b/src/lib/libcrypto/mdc2/Makefile.ssl
deleted file mode 100644
index 33f366fb08..0000000000
--- a/src/lib/libcrypto/mdc2/Makefile.ssl
+++ /dev/null
@@ -1,98 +0,0 @@
1#
2# SSLeay/crypto/mdc2/Makefile
3#
4
5DIR= mdc2
6TOP= ../..
7CC= cc
8INCLUDES=
9CFLAG=-g
10INSTALL_PREFIX=
11OPENSSLDIR= /usr/local/ssl
12INSTALLTOP=/usr/local/ssl
13MAKE= make -f Makefile.ssl
14MAKEDEPPROG= makedepend
15MAKEDEPEND= $(TOP)/util/domd $(TOP) -MD $(MAKEDEPPROG)
16MAKEFILE= Makefile.ssl
17AR= ar r
18
19CFLAGS= $(INCLUDES) $(CFLAG)
20
21GENERAL=Makefile
22TEST= mdc2test.c
23APPS=
24
25LIB=$(TOP)/libcrypto.a
26LIBSRC=mdc2dgst.c mdc2_one.c
27LIBOBJ=mdc2dgst.o mdc2_one.o
28
29SRC= $(LIBSRC)
30
31EXHEADER= mdc2.h
32HEADER= $(EXHEADER)
33
34ALL= $(GENERAL) $(SRC) $(HEADER)
35
36top:
37 (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all)
38
39all: lib
40
41lib: $(LIBOBJ)
42 $(AR) $(LIB) $(LIBOBJ)
43 $(RANLIB) $(LIB) || echo Never mind.
44 @touch lib
45
46files:
47 $(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO
48
49links:
50 @sh $(TOP)/util/point.sh Makefile.ssl Makefile
51 @$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER)
52 @$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST)
53 @$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS)
54
55install:
56 @for i in $(EXHEADER) ; \
57 do \
58 (cp $$i $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i; \
59 chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i ); \
60 done;
61
62tags:
63 ctags $(SRC)
64
65tests:
66
67lint:
68 lint -DLINT $(INCLUDES) $(SRC)>fluff
69
70depend:
71 $(MAKEDEPEND) -- $(CFLAG) $(INCLUDES) $(DEPFLAG) -- $(PROGS) $(LIBSRC)
72
73dclean:
74 $(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
75 mv -f Makefile.new $(MAKEFILE)
76
77clean:
78 rm -f *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff
79
80# DO NOT DELETE THIS LINE -- make depend depends on it.
81
82mdc2_one.o: ../../e_os.h ../../include/openssl/bio.h
83mdc2_one.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
84mdc2_one.o: ../../include/openssl/des.h ../../include/openssl/des_old.h
85mdc2_one.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
86mdc2_one.o: ../../include/openssl/lhash.h ../../include/openssl/mdc2.h
87mdc2_one.o: ../../include/openssl/opensslconf.h
88mdc2_one.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
89mdc2_one.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
90mdc2_one.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
91mdc2_one.o: ../cryptlib.h mdc2_one.c
92mdc2dgst.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
93mdc2dgst.o: ../../include/openssl/des_old.h ../../include/openssl/e_os2.h
94mdc2dgst.o: ../../include/openssl/mdc2.h ../../include/openssl/opensslconf.h
95mdc2dgst.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
96mdc2dgst.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
97mdc2dgst.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
98mdc2dgst.o: mdc2dgst.c
diff --git a/src/lib/libcrypto/mdc2/mdc2.h b/src/lib/libcrypto/mdc2/mdc2.h
index 7e1354116a..72778a5212 100644
--- a/src/lib/libcrypto/mdc2/mdc2.h
+++ b/src/lib/libcrypto/mdc2/mdc2.h
@@ -80,9 +80,7 @@ typedef struct mdc2_ctx_st
80 int pad_type; /* either 1 or 2, default 1 */ 80 int pad_type; /* either 1 or 2, default 1 */
81 } MDC2_CTX; 81 } MDC2_CTX;
82 82
83#ifdef OPENSSL_FIPS 83
84int private_MDC2_Init(MDC2_CTX *c);
85#endif
86int MDC2_Init(MDC2_CTX *c); 84int MDC2_Init(MDC2_CTX *c);
87int MDC2_Update(MDC2_CTX *c, const unsigned char *data, size_t len); 85int MDC2_Update(MDC2_CTX *c, const unsigned char *data, size_t len);
88int MDC2_Final(unsigned char *md, MDC2_CTX *c); 86int MDC2_Final(unsigned char *md, MDC2_CTX *c);
diff --git a/src/lib/libcrypto/mem.c b/src/lib/libcrypto/mem.c
index 00ebaf0b9b..8f06d190a1 100644
--- a/src/lib/libcrypto/mem.c
+++ b/src/lib/libcrypto/mem.c
@@ -101,7 +101,7 @@ static void (*free_locked_func)(void *) = free;
101 101
102/* may be changed as long as 'allow_customize_debug' is set */ 102/* may be changed as long as 'allow_customize_debug' is set */
103/* XXX use correct function pointer types */ 103/* XXX use correct function pointer types */
104#if defined(CRYPTO_MDEBUG) && !defined(OPENSSL_FIPS) 104#ifdef CRYPTO_MDEBUG
105/* use default functions from mem_dbg.c */ 105/* use default functions from mem_dbg.c */
106static void (*malloc_debug_func)(void *,int,const char *,int,int) 106static void (*malloc_debug_func)(void *,int,const char *,int,int)
107 = CRYPTO_dbg_malloc; 107 = CRYPTO_dbg_malloc;
@@ -110,14 +110,6 @@ static void (*realloc_debug_func)(void *,void *,int,const char *,int,int)
110static void (*free_debug_func)(void *,int) = CRYPTO_dbg_free; 110static void (*free_debug_func)(void *,int) = CRYPTO_dbg_free;
111static void (*set_debug_options_func)(long) = CRYPTO_dbg_set_options; 111static void (*set_debug_options_func)(long) = CRYPTO_dbg_set_options;
112static long (*get_debug_options_func)(void) = CRYPTO_dbg_get_options; 112static long (*get_debug_options_func)(void) = CRYPTO_dbg_get_options;
113
114static int (*push_info_func)(const char *info, const char *file, int line)
115 = CRYPTO_dbg_push_info;
116static int (*pop_info_func)(void)
117 = CRYPTO_dbg_pop_info;
118static int (*remove_all_info_func)(void)
119 = CRYPTO_dbg_remove_all_info;
120
121#else 113#else
122/* applications can use CRYPTO_malloc_debug_init() to select above case 114/* applications can use CRYPTO_malloc_debug_init() to select above case
123 * at run-time */ 115 * at run-time */
@@ -127,13 +119,6 @@ static void (*realloc_debug_func)(void *,void *,int,const char *,int,int)
127static void (*free_debug_func)(void *,int) = NULL; 119static void (*free_debug_func)(void *,int) = NULL;
128static void (*set_debug_options_func)(long) = NULL; 120static void (*set_debug_options_func)(long) = NULL;
129static long (*get_debug_options_func)(void) = NULL; 121static long (*get_debug_options_func)(void) = NULL;
130
131
132static int (*push_info_func)(const char *info, const char *file, int line)
133 = NULL;
134static int (*pop_info_func)(void) = NULL;
135static int (*remove_all_info_func)(void) = NULL;
136
137#endif 122#endif
138 123
139 124
@@ -209,15 +194,6 @@ int CRYPTO_set_mem_debug_functions(void (*m)(void *,int,const char *,int,int),
209 return 1; 194 return 1;
210 } 195 }
211 196
212void CRYPTO_set_mem_info_functions(
213 int (*push_info_fn)(const char *info, const char *file, int line),
214 int (*pop_info_fn)(void),
215 int (*remove_all_info_fn)(void))
216 {
217 push_info_func = push_info_fn;
218 pop_info_func = pop_info_fn;
219 remove_all_info_func = remove_all_info_fn;
220 }
221 197
222void CRYPTO_get_mem_functions(void *(**m)(size_t), void *(**r)(void *, size_t), 198void CRYPTO_get_mem_functions(void *(**m)(size_t), void *(**r)(void *, size_t),
223 void (**f)(void *)) 199 void (**f)(void *))
@@ -274,7 +250,6 @@ void CRYPTO_get_mem_debug_functions(void (**m)(void *,int,const char *,int,int),
274void *CRYPTO_malloc_locked(int num, const char *file, int line) 250void *CRYPTO_malloc_locked(int num, const char *file, int line)
275 { 251 {
276 void *ret = NULL; 252 void *ret = NULL;
277 extern unsigned char cleanse_ctr;
278 253
279 if (num <= 0) return NULL; 254 if (num <= 0) return NULL;
280 255
@@ -291,11 +266,15 @@ void *CRYPTO_malloc_locked(int num, const char *file, int line)
291 if (malloc_debug_func != NULL) 266 if (malloc_debug_func != NULL)
292 malloc_debug_func(ret, num, file, line, 1); 267 malloc_debug_func(ret, num, file, line, 1);
293 268
269#ifndef OPENSSL_CPUID_OBJ
294 /* Create a dependency on the value of 'cleanse_ctr' so our memory 270 /* Create a dependency on the value of 'cleanse_ctr' so our memory
295 * sanitisation function can't be optimised out. NB: We only do 271 * sanitisation function can't be optimised out. NB: We only do
296 * this for >2Kb so the overhead doesn't bother us. */ 272 * this for >2Kb so the overhead doesn't bother us. */
297 if(ret && (num > 2048)) 273 if(ret && (num > 2048))
274 { extern unsigned char cleanse_ctr;
298 ((unsigned char *)ret)[0] = cleanse_ctr; 275 ((unsigned char *)ret)[0] = cleanse_ctr;
276 }
277#endif
299 278
300 return ret; 279 return ret;
301 } 280 }
@@ -315,7 +294,6 @@ void CRYPTO_free_locked(void *str)
315void *CRYPTO_malloc(int num, const char *file, int line) 294void *CRYPTO_malloc(int num, const char *file, int line)
316 { 295 {
317 void *ret = NULL; 296 void *ret = NULL;
318 extern unsigned char cleanse_ctr;
319 297
320 if (num <= 0) return NULL; 298 if (num <= 0) return NULL;
321 299
@@ -332,12 +310,24 @@ void *CRYPTO_malloc(int num, const char *file, int line)
332 if (malloc_debug_func != NULL) 310 if (malloc_debug_func != NULL)
333 malloc_debug_func(ret, num, file, line, 1); 311 malloc_debug_func(ret, num, file, line, 1);
334 312
313#ifndef OPENSSL_CPUID_OBJ
335 /* Create a dependency on the value of 'cleanse_ctr' so our memory 314 /* Create a dependency on the value of 'cleanse_ctr' so our memory
336 * sanitisation function can't be optimised out. NB: We only do 315 * sanitisation function can't be optimised out. NB: We only do
337 * this for >2Kb so the overhead doesn't bother us. */ 316 * this for >2Kb so the overhead doesn't bother us. */
338 if(ret && (num > 2048)) 317 if(ret && (num > 2048))
318 { extern unsigned char cleanse_ctr;
339 ((unsigned char *)ret)[0] = cleanse_ctr; 319 ((unsigned char *)ret)[0] = cleanse_ctr;
320 }
321#endif
322
323 return ret;
324 }
325char *CRYPTO_strdup(const char *str, const char *file, int line)
326 {
327 size_t len = strlen(str)+1;
328 char *ret = CRYPTO_malloc(len, file, line);
340 329
330 memcpy(ret, str, len);
341 return ret; 331 return ret;
342 } 332 }
343 333
@@ -423,24 +413,3 @@ long CRYPTO_get_mem_debug_options(void)
423 return get_debug_options_func(); 413 return get_debug_options_func();
424 return 0; 414 return 0;
425 } 415 }
426
427int CRYPTO_push_info_(const char *info, const char *file, int line)
428 {
429 if (push_info_func)
430 return push_info_func(info, file, line);
431 return 1;
432 }
433
434int CRYPTO_pop_info(void)
435 {
436 if (pop_info_func)
437 return pop_info_func();
438 return 1;
439 }
440
441int CRYPTO_remove_all_info(void)
442 {
443 if (remove_all_info_func)
444 return remove_all_info_func();
445 return 1;
446 }
diff --git a/src/lib/libcrypto/mem_dbg.c b/src/lib/libcrypto/mem_dbg.c
index c6dee9a92b..ac793397f1 100644
--- a/src/lib/libcrypto/mem_dbg.c
+++ b/src/lib/libcrypto/mem_dbg.c
@@ -55,6 +55,59 @@
55 * copied and put under another distribution licence 55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.] 56 * [including the GNU Public Licence.]
57 */ 57 */
58/* ====================================================================
59 * Copyright (c) 1998-2006 The OpenSSL Project. All rights reserved.
60 *
61 * Redistribution and use in source and binary forms, with or without
62 * modification, are permitted provided that the following conditions
63 * are met:
64 *
65 * 1. Redistributions of source code must retain the above copyright
66 * notice, this list of conditions and the following disclaimer.
67 *
68 * 2. Redistributions in binary form must reproduce the above copyright
69 * notice, this list of conditions and the following disclaimer in
70 * the documentation and/or other materials provided with the
71 * distribution.
72 *
73 * 3. All advertising materials mentioning features or use of this
74 * software must display the following acknowledgment:
75 * "This product includes software developed by the OpenSSL Project
76 * for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
77 *
78 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
79 * endorse or promote products derived from this software without
80 * prior written permission. For written permission, please contact
81 * openssl-core@openssl.org.
82 *
83 * 5. Products derived from this software may not be called "OpenSSL"
84 * nor may "OpenSSL" appear in their names without prior written
85 * permission of the OpenSSL Project.
86 *
87 * 6. Redistributions of any form whatsoever must retain the following
88 * acknowledgment:
89 * "This product includes software developed by the OpenSSL Project
90 * for use in the OpenSSL Toolkit (http://www.openssl.org/)"
91 *
92 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
93 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
94 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
95 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
96 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
97 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
98 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
99 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
100 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
101 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
102 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
103 * OF THE POSSIBILITY OF SUCH DAMAGE.
104 * ====================================================================
105 *
106 * This product includes cryptographic software written by Eric Young
107 * (eay@cryptsoft.com). This product includes software written by Tim
108 * Hudson (tjh@cryptsoft.com).
109 *
110 */
58 111
59#include <stdio.h> 112#include <stdio.h>
60#include <stdlib.h> 113#include <stdlib.h>
@@ -81,8 +134,11 @@ static int mh_mode=CRYPTO_MEM_CHECK_OFF;
81 */ 134 */
82 135
83static unsigned long order = 0; /* number of memory requests */ 136static unsigned long order = 0; /* number of memory requests */
84static LHASH *mh=NULL; /* hash-table of memory requests (address as key); 137
85 * access requires MALLOC2 lock */ 138DECLARE_LHASH_OF(MEM);
139static LHASH_OF(MEM) *mh=NULL; /* hash-table of memory requests
140 * (address as key); access requires
141 * MALLOC2 lock */
86 142
87 143
88typedef struct app_mem_info_st 144typedef struct app_mem_info_st
@@ -93,8 +149,8 @@ typedef struct app_mem_info_st
93 * CRYPTO_pop_info() to pop an entry, 149 * CRYPTO_pop_info() to pop an entry,
94 * CRYPTO_remove_all_info() to pop all entries. 150 * CRYPTO_remove_all_info() to pop all entries.
95 */ 151 */
96 { 152 {
97 unsigned long thread; 153 CRYPTO_THREADID threadid;
98 const char *file; 154 const char *file;
99 int line; 155 int line;
100 const char *info; 156 const char *info;
@@ -104,10 +160,13 @@ typedef struct app_mem_info_st
104 160
105static void app_info_free(APP_INFO *); 161static void app_info_free(APP_INFO *);
106 162
107static LHASH *amih=NULL; /* hash-table with those app_mem_info_st's 163DECLARE_LHASH_OF(APP_INFO);
108 * that are at the top of their thread's stack 164static LHASH_OF(APP_INFO) *amih=NULL; /* hash-table with those
109 * (with `thread' as key); 165 * app_mem_info_st's that are at
110 * access requires MALLOC2 lock */ 166 * the top of their thread's
167 * stack (with `thread' as key);
168 * access requires MALLOC2
169 * lock */
111 170
112typedef struct mem_st 171typedef struct mem_st
113/* memory-block description */ 172/* memory-block description */
@@ -116,7 +175,7 @@ typedef struct mem_st
116 int num; 175 int num;
117 const char *file; 176 const char *file;
118 int line; 177 int line;
119 unsigned long thread; 178 CRYPTO_THREADID threadid;
120 unsigned long order; 179 unsigned long order;
121 time_t time; 180 time_t time;
122 APP_INFO *app_info; 181 APP_INFO *app_info;
@@ -136,11 +195,11 @@ static unsigned int num_disable = 0; /* num_disable > 0
136 * iff 195 * iff
137 * mh_mode == CRYPTO_MEM_CHECK_ON (w/o ..._ENABLE) 196 * mh_mode == CRYPTO_MEM_CHECK_ON (w/o ..._ENABLE)
138 */ 197 */
139static unsigned long disabling_thread = 0; /* Valid iff num_disable > 0. 198
140 * CRYPTO_LOCK_MALLOC2 is locked 199/* Valid iff num_disable > 0. CRYPTO_LOCK_MALLOC2 is locked exactly in this
141 * exactly in this case (by the 200 * case (by the thread named in disabling_thread).
142 * thread named in disabling_thread). 201 */
143 */ 202static CRYPTO_THREADID disabling_threadid;
144 203
145static void app_info_free(APP_INFO *inf) 204static void app_info_free(APP_INFO *inf)
146 { 205 {
@@ -177,7 +236,9 @@ int CRYPTO_mem_ctrl(int mode)
177 case CRYPTO_MEM_CHECK_DISABLE: /* aka MemCheck_off() */ 236 case CRYPTO_MEM_CHECK_DISABLE: /* aka MemCheck_off() */
178 if (mh_mode & CRYPTO_MEM_CHECK_ON) 237 if (mh_mode & CRYPTO_MEM_CHECK_ON)
179 { 238 {
180 if (!num_disable || (disabling_thread != CRYPTO_thread_id())) /* otherwise we already have the MALLOC2 lock */ 239 CRYPTO_THREADID cur;
240 CRYPTO_THREADID_current(&cur);
241 if (!num_disable || CRYPTO_THREADID_cmp(&disabling_threadid, &cur)) /* otherwise we already have the MALLOC2 lock */
181 { 242 {
182 /* Long-time lock CRYPTO_LOCK_MALLOC2 must not be claimed while 243 /* Long-time lock CRYPTO_LOCK_MALLOC2 must not be claimed while
183 * we're holding CRYPTO_LOCK_MALLOC, or we'll deadlock if 244 * we're holding CRYPTO_LOCK_MALLOC, or we'll deadlock if
@@ -195,7 +256,7 @@ int CRYPTO_mem_ctrl(int mode)
195 CRYPTO_w_lock(CRYPTO_LOCK_MALLOC2); 256 CRYPTO_w_lock(CRYPTO_LOCK_MALLOC2);
196 CRYPTO_w_lock(CRYPTO_LOCK_MALLOC); 257 CRYPTO_w_lock(CRYPTO_LOCK_MALLOC);
197 mh_mode &= ~CRYPTO_MEM_CHECK_ENABLE; 258 mh_mode &= ~CRYPTO_MEM_CHECK_ENABLE;
198 disabling_thread=CRYPTO_thread_id(); 259 CRYPTO_THREADID_cpy(&disabling_threadid, &cur);
199 } 260 }
200 num_disable++; 261 num_disable++;
201 } 262 }
@@ -228,10 +289,12 @@ int CRYPTO_is_mem_check_on(void)
228 289
229 if (mh_mode & CRYPTO_MEM_CHECK_ON) 290 if (mh_mode & CRYPTO_MEM_CHECK_ON)
230 { 291 {
292 CRYPTO_THREADID cur;
293 CRYPTO_THREADID_current(&cur);
231 CRYPTO_r_lock(CRYPTO_LOCK_MALLOC); 294 CRYPTO_r_lock(CRYPTO_LOCK_MALLOC);
232 295
233 ret = (mh_mode & CRYPTO_MEM_CHECK_ENABLE) 296 ret = (mh_mode & CRYPTO_MEM_CHECK_ENABLE)
234 || (disabling_thread != CRYPTO_thread_id()); 297 || CRYPTO_THREADID_cmp(&disabling_threadid, &cur);
235 298
236 CRYPTO_r_unlock(CRYPTO_LOCK_MALLOC); 299 CRYPTO_r_unlock(CRYPTO_LOCK_MALLOC);
237 } 300 }
@@ -249,49 +312,49 @@ long CRYPTO_dbg_get_options(void)
249 return options; 312 return options;
250 } 313 }
251 314
252/* static int mem_cmp(MEM *a, MEM *b) */ 315static int mem_cmp(const MEM *a, const MEM *b)
253static int mem_cmp(const void *a_void, const void *b_void)
254 { 316 {
255#ifdef _WIN64 317#ifdef _WIN64
256 const char *a=(const char *)((const MEM *)a_void)->addr, 318 const char *ap=(const char *)a->addr,
257 *b=(const char *)((const MEM *)b_void)->addr; 319 *bp=(const char *)b->addr;
258 if (a==b) return 0; 320 if (ap==bp) return 0;
259 else if (a>b) return 1; 321 else if (ap>bp) return 1;
260 else return -1; 322 else return -1;
261#else 323#else
262 return((const char *)((const MEM *)a_void)->addr 324 return (const char *)a->addr - (const char *)b->addr;
263 - (const char *)((const MEM *)b_void)->addr);
264#endif 325#endif
265 } 326 }
327static IMPLEMENT_LHASH_COMP_FN(mem, MEM)
266 328
267/* static unsigned long mem_hash(MEM *a) */ 329static unsigned long mem_hash(const MEM *a)
268static unsigned long mem_hash(const void *a_void)
269 { 330 {
270 unsigned long ret; 331 unsigned long ret;
271 332
272 ret=(unsigned long)((const MEM *)a_void)->addr; 333 ret=(unsigned long)a->addr;
273 334
274 ret=ret*17851+(ret>>14)*7+(ret>>4)*251; 335 ret=ret*17851+(ret>>14)*7+(ret>>4)*251;
275 return(ret); 336 return(ret);
276 } 337 }
338static IMPLEMENT_LHASH_HASH_FN(mem, MEM)
277 339
278/* static int app_info_cmp(APP_INFO *a, APP_INFO *b) */ 340/* static int app_info_cmp(APP_INFO *a, APP_INFO *b) */
279static int app_info_cmp(const void *a_void, const void *b_void) 341static int app_info_cmp(const void *a_void, const void *b_void)
280 { 342 {
281 return(((const APP_INFO *)a_void)->thread 343 return CRYPTO_THREADID_cmp(&((const APP_INFO *)a_void)->threadid,
282 != ((const APP_INFO *)b_void)->thread); 344 &((const APP_INFO *)b_void)->threadid);
283 } 345 }
346static IMPLEMENT_LHASH_COMP_FN(app_info, APP_INFO)
284 347
285/* static unsigned long app_info_hash(APP_INFO *a) */ 348static unsigned long app_info_hash(const APP_INFO *a)
286static unsigned long app_info_hash(const void *a_void)
287 { 349 {
288 unsigned long ret; 350 unsigned long ret;
289 351
290 ret=(unsigned long)((const APP_INFO *)a_void)->thread; 352 ret = CRYPTO_THREADID_hash(&a->threadid);
291 353 /* This is left in as a "who am I to question legacy?" measure */
292 ret=ret*17851+(ret>>14)*7+(ret>>4)*251; 354 ret=ret*17851+(ret>>14)*7+(ret>>4)*251;
293 return(ret); 355 return(ret);
294 } 356 }
357static IMPLEMENT_LHASH_HASH_FN(app_info, APP_INFO)
295 358
296static APP_INFO *pop_info(void) 359static APP_INFO *pop_info(void)
297 { 360 {
@@ -300,21 +363,22 @@ static APP_INFO *pop_info(void)
300 363
301 if (amih != NULL) 364 if (amih != NULL)
302 { 365 {
303 tmp.thread=CRYPTO_thread_id(); 366 CRYPTO_THREADID_current(&tmp.threadid);
304 if ((ret=(APP_INFO *)lh_delete(amih,&tmp)) != NULL) 367 if ((ret=lh_APP_INFO_delete(amih,&tmp)) != NULL)
305 { 368 {
306 APP_INFO *next=ret->next; 369 APP_INFO *next=ret->next;
307 370
308 if (next != NULL) 371 if (next != NULL)
309 { 372 {
310 next->references++; 373 next->references++;
311 lh_insert(amih,(char *)next); 374 (void)lh_APP_INFO_insert(amih,next);
312 } 375 }
313#ifdef LEVITTE_DEBUG_MEM 376#ifdef LEVITTE_DEBUG_MEM
314 if (ret->thread != tmp.thread) 377 if (CRYPTO_THREADID_cmp(&ret->threadid, &tmp.threadid))
315 { 378 {
316 fprintf(stderr, "pop_info(): deleted info has other thread ID (%lu) than the current thread (%lu)!!!!\n", 379 fprintf(stderr, "pop_info(): deleted info has other thread ID (%lu) than the current thread (%lu)!!!!\n",
317 ret->thread, tmp.thread); 380 CRYPTO_THREADID_hash(&ret->threadid),
381 CRYPTO_THREADID_hash(&tmp.threadid));
318 abort(); 382 abort();
319 } 383 }
320#endif 384#endif
@@ -330,7 +394,7 @@ static APP_INFO *pop_info(void)
330 return(ret); 394 return(ret);
331 } 395 }
332 396
333int CRYPTO_dbg_push_info(const char *info, const char *file, int line) 397int CRYPTO_push_info_(const char *info, const char *file, int line)
334 { 398 {
335 APP_INFO *ami, *amim; 399 APP_INFO *ami, *amim;
336 int ret=0; 400 int ret=0;
@@ -346,7 +410,7 @@ int CRYPTO_dbg_push_info(const char *info, const char *file, int line)
346 } 410 }
347 if (amih == NULL) 411 if (amih == NULL)
348 { 412 {
349 if ((amih=lh_new(app_info_hash, app_info_cmp)) == NULL) 413 if ((amih=lh_APP_INFO_new()) == NULL)
350 { 414 {
351 OPENSSL_free(ami); 415 OPENSSL_free(ami);
352 ret=0; 416 ret=0;
@@ -354,20 +418,21 @@ int CRYPTO_dbg_push_info(const char *info, const char *file, int line)
354 } 418 }
355 } 419 }
356 420
357 ami->thread=CRYPTO_thread_id(); 421 CRYPTO_THREADID_current(&ami->threadid);
358 ami->file=file; 422 ami->file=file;
359 ami->line=line; 423 ami->line=line;
360 ami->info=info; 424 ami->info=info;
361 ami->references=1; 425 ami->references=1;
362 ami->next=NULL; 426 ami->next=NULL;
363 427
364 if ((amim=(APP_INFO *)lh_insert(amih,(char *)ami)) != NULL) 428 if ((amim=lh_APP_INFO_insert(amih,ami)) != NULL)
365 { 429 {
366#ifdef LEVITTE_DEBUG_MEM 430#ifdef LEVITTE_DEBUG_MEM
367 if (ami->thread != amim->thread) 431 if (CRYPTO_THREADID_cmp(&ami->threadid, &amim->threadid))
368 { 432 {
369 fprintf(stderr, "CRYPTO_push_info(): previous info has other thread ID (%lu) than the current thread (%lu)!!!!\n", 433 fprintf(stderr, "CRYPTO_push_info(): previous info has other thread ID (%lu) than the current thread (%lu)!!!!\n",
370 amim->thread, ami->thread); 434 CRYPTO_THREADID_hash(&amim->threadid),
435 CRYPTO_THREADID_hash(&ami->threadid));
371 abort(); 436 abort();
372 } 437 }
373#endif 438#endif
@@ -380,7 +445,7 @@ int CRYPTO_dbg_push_info(const char *info, const char *file, int line)
380 return(ret); 445 return(ret);
381 } 446 }
382 447
383int CRYPTO_dbg_pop_info(void) 448int CRYPTO_pop_info(void)
384 { 449 {
385 int ret=0; 450 int ret=0;
386 451
@@ -395,7 +460,7 @@ int CRYPTO_dbg_pop_info(void)
395 return(ret); 460 return(ret);
396 } 461 }
397 462
398int CRYPTO_dbg_remove_all_info(void) 463int CRYPTO_remove_all_info(void)
399 { 464 {
400 int ret=0; 465 int ret=0;
401 466
@@ -439,7 +504,7 @@ void CRYPTO_dbg_malloc(void *addr, int num, const char *file, int line,
439 } 504 }
440 if (mh == NULL) 505 if (mh == NULL)
441 { 506 {
442 if ((mh=lh_new(mem_hash, mem_cmp)) == NULL) 507 if ((mh=lh_MEM_new()) == NULL)
443 { 508 {
444 OPENSSL_free(addr); 509 OPENSSL_free(addr);
445 OPENSSL_free(m); 510 OPENSSL_free(m);
@@ -453,9 +518,9 @@ void CRYPTO_dbg_malloc(void *addr, int num, const char *file, int line,
453 m->line=line; 518 m->line=line;
454 m->num=num; 519 m->num=num;
455 if (options & V_CRYPTO_MDEBUG_THREAD) 520 if (options & V_CRYPTO_MDEBUG_THREAD)
456 m->thread=CRYPTO_thread_id(); 521 CRYPTO_THREADID_current(&m->threadid);
457 else 522 else
458 m->thread=0; 523 memset(&m->threadid, 0, sizeof(m->threadid));
459 524
460 if (order == break_order_num) 525 if (order == break_order_num)
461 { 526 {
@@ -464,7 +529,7 @@ void CRYPTO_dbg_malloc(void *addr, int num, const char *file, int line,
464 } 529 }
465 m->order=order++; 530 m->order=order++;
466#ifdef LEVITTE_DEBUG_MEM 531#ifdef LEVITTE_DEBUG_MEM
467 fprintf(stderr, "LEVITTE_DEBUG_MEM: [%5d] %c 0x%p (%d)\n", 532 fprintf(stderr, "LEVITTE_DEBUG_MEM: [%5ld] %c 0x%p (%d)\n",
468 m->order, 533 m->order,
469 (before_p & 128) ? '*' : '+', 534 (before_p & 128) ? '*' : '+',
470 m->addr, m->num); 535 m->addr, m->num);
@@ -474,16 +539,16 @@ void CRYPTO_dbg_malloc(void *addr, int num, const char *file, int line,
474 else 539 else
475 m->time=0; 540 m->time=0;
476 541
477 tmp.thread=CRYPTO_thread_id(); 542 CRYPTO_THREADID_current(&tmp.threadid);
478 m->app_info=NULL; 543 m->app_info=NULL;
479 if (amih != NULL 544 if (amih != NULL
480 && (amim=(APP_INFO *)lh_retrieve(amih,(char *)&tmp)) != NULL) 545 && (amim=lh_APP_INFO_retrieve(amih,&tmp)) != NULL)
481 { 546 {
482 m->app_info = amim; 547 m->app_info = amim;
483 amim->references++; 548 amim->references++;
484 } 549 }
485 550
486 if ((mm=(MEM *)lh_insert(mh,(char *)m)) != NULL) 551 if ((mm=lh_MEM_insert(mh, m)) != NULL)
487 { 552 {
488 /* Not good, but don't sweat it */ 553 /* Not good, but don't sweat it */
489 if (mm->app_info != NULL) 554 if (mm->app_info != NULL)
@@ -516,11 +581,11 @@ void CRYPTO_dbg_free(void *addr, int before_p)
516 MemCheck_off(); /* make sure we hold MALLOC2 lock */ 581 MemCheck_off(); /* make sure we hold MALLOC2 lock */
517 582
518 m.addr=addr; 583 m.addr=addr;
519 mp=(MEM *)lh_delete(mh,(char *)&m); 584 mp=lh_MEM_delete(mh,&m);
520 if (mp != NULL) 585 if (mp != NULL)
521 { 586 {
522#ifdef LEVITTE_DEBUG_MEM 587#ifdef LEVITTE_DEBUG_MEM
523 fprintf(stderr, "LEVITTE_DEBUG_MEM: [%5d] - 0x%p (%d)\n", 588 fprintf(stderr, "LEVITTE_DEBUG_MEM: [%5ld] - 0x%p (%d)\n",
524 mp->order, mp->addr, mp->num); 589 mp->order, mp->addr, mp->num);
525#endif 590#endif
526 if (mp->app_info != NULL) 591 if (mp->app_info != NULL)
@@ -566,18 +631,18 @@ void CRYPTO_dbg_realloc(void *addr1, void *addr2, int num,
566 MemCheck_off(); /* make sure we hold MALLOC2 lock */ 631 MemCheck_off(); /* make sure we hold MALLOC2 lock */
567 632
568 m.addr=addr1; 633 m.addr=addr1;
569 mp=(MEM *)lh_delete(mh,(char *)&m); 634 mp=lh_MEM_delete(mh,&m);
570 if (mp != NULL) 635 if (mp != NULL)
571 { 636 {
572#ifdef LEVITTE_DEBUG_MEM 637#ifdef LEVITTE_DEBUG_MEM
573 fprintf(stderr, "LEVITTE_DEBUG_MEM: [%5d] * 0x%p (%d) -> 0x%p (%d)\n", 638 fprintf(stderr, "LEVITTE_DEBUG_MEM: [%5ld] * 0x%p (%d) -> 0x%p (%d)\n",
574 mp->order, 639 mp->order,
575 mp->addr, mp->num, 640 mp->addr, mp->num,
576 addr2, num); 641 addr2, num);
577#endif 642#endif
578 mp->addr=addr2; 643 mp->addr=addr2;
579 mp->num=num; 644 mp->num=num;
580 lh_insert(mh,(char *)mp); 645 (void)lh_MEM_insert(mh,mp);
581 } 646 }
582 647
583 MemCheck_on(); /* release MALLOC2 lock 648 MemCheck_on(); /* release MALLOC2 lock
@@ -596,14 +661,14 @@ typedef struct mem_leak_st
596 long bytes; 661 long bytes;
597 } MEM_LEAK; 662 } MEM_LEAK;
598 663
599static void print_leak(const MEM *m, MEM_LEAK *l) 664static void print_leak_doall_arg(const MEM *m, MEM_LEAK *l)
600 { 665 {
601 char buf[1024]; 666 char buf[1024];
602 char *bufp = buf; 667 char *bufp = buf;
603 APP_INFO *amip; 668 APP_INFO *amip;
604 int ami_cnt; 669 int ami_cnt;
605 struct tm *lcl = NULL; 670 struct tm *lcl = NULL;
606 unsigned long ti; 671 CRYPTO_THREADID ti;
607 672
608#define BUF_REMAIN (sizeof buf - (size_t)(bufp - buf)) 673#define BUF_REMAIN (sizeof buf - (size_t)(bufp - buf))
609 674
@@ -625,7 +690,8 @@ static void print_leak(const MEM *m, MEM_LEAK *l)
625 690
626 if (options & V_CRYPTO_MDEBUG_THREAD) 691 if (options & V_CRYPTO_MDEBUG_THREAD)
627 { 692 {
628 BIO_snprintf(bufp, BUF_REMAIN, "thread=%lu, ", m->thread); 693 BIO_snprintf(bufp, BUF_REMAIN, "thread=%lu, ",
694 CRYPTO_THREADID_hash(&m->threadid));
629 bufp += strlen(bufp); 695 bufp += strlen(bufp);
630 } 696 }
631 697
@@ -642,8 +708,8 @@ static void print_leak(const MEM *m, MEM_LEAK *l)
642 ami_cnt=0; 708 ami_cnt=0;
643 if (!amip) 709 if (!amip)
644 return; 710 return;
645 ti=amip->thread; 711 CRYPTO_THREADID_cpy(&ti, &amip->threadid);
646 712
647 do 713 do
648 { 714 {
649 int buf_len; 715 int buf_len;
@@ -653,7 +719,8 @@ static void print_leak(const MEM *m, MEM_LEAK *l)
653 memset(buf,'>',ami_cnt); 719 memset(buf,'>',ami_cnt);
654 BIO_snprintf(buf + ami_cnt, sizeof buf - ami_cnt, 720 BIO_snprintf(buf + ami_cnt, sizeof buf - ami_cnt,
655 " thread=%lu, file=%s, line=%d, info=\"", 721 " thread=%lu, file=%s, line=%d, info=\"",
656 amip->thread, amip->file, amip->line); 722 CRYPTO_THREADID_hash(&amip->threadid), amip->file,
723 amip->line);
657 buf_len=strlen(buf); 724 buf_len=strlen(buf);
658 info_len=strlen(amip->info); 725 info_len=strlen(amip->info);
659 if (128 - buf_len - 3 < info_len) 726 if (128 - buf_len - 3 < info_len)
@@ -673,8 +740,8 @@ static void print_leak(const MEM *m, MEM_LEAK *l)
673 740
674 amip = amip->next; 741 amip = amip->next;
675 } 742 }
676 while(amip && amip->thread == ti); 743 while(amip && !CRYPTO_THREADID_cmp(&amip->threadid, &ti));
677 744
678#ifdef LEVITTE_DEBUG_MEM 745#ifdef LEVITTE_DEBUG_MEM
679 if (amip) 746 if (amip)
680 { 747 {
@@ -684,7 +751,7 @@ static void print_leak(const MEM *m, MEM_LEAK *l)
684#endif 751#endif
685 } 752 }
686 753
687static IMPLEMENT_LHASH_DOALL_ARG_FN(print_leak, const MEM *, MEM_LEAK *) 754static IMPLEMENT_LHASH_DOALL_ARG_FN(print_leak, const MEM, MEM_LEAK)
688 755
689void CRYPTO_mem_leaks(BIO *b) 756void CRYPTO_mem_leaks(BIO *b)
690 { 757 {
@@ -699,12 +766,15 @@ void CRYPTO_mem_leaks(BIO *b)
699 ml.bytes=0; 766 ml.bytes=0;
700 ml.chunks=0; 767 ml.chunks=0;
701 if (mh != NULL) 768 if (mh != NULL)
702 lh_doall_arg(mh, LHASH_DOALL_ARG_FN(print_leak), 769 lh_MEM_doall_arg(mh, LHASH_DOALL_ARG_FN(print_leak), MEM_LEAK,
703 (char *)&ml); 770 &ml);
704 if (ml.chunks != 0) 771 if (ml.chunks != 0)
705 { 772 {
706 BIO_printf(b,"%ld bytes leaked in %d chunks\n", 773 BIO_printf(b,"%ld bytes leaked in %d chunks\n",
707 ml.bytes,ml.chunks); 774 ml.bytes,ml.chunks);
775#ifdef CRYPTO_MDEBUG_ABORT
776 abort();
777#endif
708 } 778 }
709 else 779 else
710 { 780 {
@@ -717,7 +787,7 @@ void CRYPTO_mem_leaks(BIO *b)
717 * XXX This should be in CRYPTO_mem_leaks_cb, 787 * XXX This should be in CRYPTO_mem_leaks_cb,
718 * and CRYPTO_mem_leaks should be implemented by 788 * and CRYPTO_mem_leaks should be implemented by
719 * using CRYPTO_mem_leaks_cb. 789 * using CRYPTO_mem_leaks_cb.
720 * (Also their should be a variant of lh_doall_arg 790 * (Also there should be a variant of lh_doall_arg
721 * that takes a function pointer instead of a void *; 791 * that takes a function pointer instead of a void *;
722 * this would obviate the ugly and illegal 792 * this would obviate the ugly and illegal
723 * void_fn_to_char kludge in CRYPTO_mem_leaks_cb. 793 * void_fn_to_char kludge in CRYPTO_mem_leaks_cb.
@@ -734,14 +804,14 @@ void CRYPTO_mem_leaks(BIO *b)
734 804
735 if (mh != NULL) 805 if (mh != NULL)
736 { 806 {
737 lh_free(mh); 807 lh_MEM_free(mh);
738 mh = NULL; 808 mh = NULL;
739 } 809 }
740 if (amih != NULL) 810 if (amih != NULL)
741 { 811 {
742 if (lh_num_items(amih) == 0) 812 if (lh_APP_INFO_num_items(amih) == 0)
743 { 813 {
744 lh_free(amih); 814 lh_APP_INFO_free(amih);
745 amih = NULL; 815 amih = NULL;
746 } 816 }
747 } 817 }
@@ -779,40 +849,26 @@ void CRYPTO_mem_leaks_fp(FILE *fp)
779/* NB: The prototypes have been typedef'd to CRYPTO_MEM_LEAK_CB inside crypto.h 849/* NB: The prototypes have been typedef'd to CRYPTO_MEM_LEAK_CB inside crypto.h
780 * If this code is restructured, remove the callback type if it is no longer 850 * If this code is restructured, remove the callback type if it is no longer
781 * needed. -- Geoff Thorpe */ 851 * needed. -- Geoff Thorpe */
782static void cb_leak(const MEM *m, CRYPTO_MEM_LEAK_CB **cb) 852
853/* Can't pass CRYPTO_MEM_LEAK_CB directly to lh_MEM_doall_arg because it
854 * is a function pointer and conversion to void * is prohibited. Instead
855 * pass its address
856 */
857
858typedef CRYPTO_MEM_LEAK_CB *PCRYPTO_MEM_LEAK_CB;
859
860static void cb_leak_doall_arg(const MEM *m, PCRYPTO_MEM_LEAK_CB *cb)
783 { 861 {
784 (**cb)(m->order,m->file,m->line,m->num,m->addr); 862 (*cb)(m->order,m->file,m->line,m->num,m->addr);
785 } 863 }
786 864
787static IMPLEMENT_LHASH_DOALL_ARG_FN(cb_leak, const MEM *, CRYPTO_MEM_LEAK_CB **) 865static IMPLEMENT_LHASH_DOALL_ARG_FN(cb_leak, const MEM, PCRYPTO_MEM_LEAK_CB)
788 866
789void CRYPTO_mem_leaks_cb(CRYPTO_MEM_LEAK_CB *cb) 867void CRYPTO_mem_leaks_cb(CRYPTO_MEM_LEAK_CB *cb)
790 { 868 {
791 if (mh == NULL) return; 869 if (mh == NULL) return;
792 CRYPTO_w_lock(CRYPTO_LOCK_MALLOC2); 870 CRYPTO_w_lock(CRYPTO_LOCK_MALLOC2);
793 lh_doall_arg(mh, LHASH_DOALL_ARG_FN(cb_leak), &cb); 871 lh_MEM_doall_arg(mh, LHASH_DOALL_ARG_FN(cb_leak), PCRYPTO_MEM_LEAK_CB,
872 &cb);
794 CRYPTO_w_unlock(CRYPTO_LOCK_MALLOC2); 873 CRYPTO_w_unlock(CRYPTO_LOCK_MALLOC2);
795 } 874 }
796
797void CRYPTO_malloc_debug_init(void)
798 {
799 CRYPTO_set_mem_debug_functions(
800 CRYPTO_dbg_malloc,
801 CRYPTO_dbg_realloc,
802 CRYPTO_dbg_free,
803 CRYPTO_dbg_set_options,
804 CRYPTO_dbg_get_options);
805 CRYPTO_set_mem_info_functions(
806 CRYPTO_dbg_push_info,
807 CRYPTO_dbg_pop_info,
808 CRYPTO_dbg_remove_all_info);
809 }
810
811char *CRYPTO_strdup(const char *str, const char *file, int line)
812 {
813 size_t len = strlen(str)+1;
814 char *ret = CRYPTO_malloc(len, file, line);
815
816 memcpy(ret, str, len);
817 return ret;
818 }
diff --git a/src/lib/libcrypto/o_init.c b/src/lib/libcrypto/o_init.c
deleted file mode 100644
index 00ed65a6cf..0000000000
--- a/src/lib/libcrypto/o_init.c
+++ /dev/null
@@ -1,86 +0,0 @@
1/* o_init.c */
2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project.
4 */
5/* ====================================================================
6 * Copyright (c) 2007 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 <e_os.h>
60#include <openssl/err.h>
61
62/* Perform any essential OpenSSL initialization operations.
63 * Currently only sets FIPS callbacks
64 */
65
66void OPENSSL_init(void)
67 {
68#ifdef OPENSSL_FIPS
69 static int done = 0;
70 if (!done)
71 {
72 int_ERR_lib_init();
73#ifdef CRYPTO_MDEBUG
74 CRYPTO_malloc_debug_init();
75#endif
76#ifdef OPENSSL_ENGINE
77 int_EVP_MD_init_engine_callbacks();
78 int_EVP_CIPHER_init_engine_callbacks();
79 int_RAND_init_engine_callbacks();
80#endif
81 done = 1;
82 }
83#endif
84 }
85
86
diff --git a/src/lib/libcrypto/o_time.c b/src/lib/libcrypto/o_time.c
index e29091d650..eecbdd19f0 100644
--- a/src/lib/libcrypto/o_time.c
+++ b/src/lib/libcrypto/o_time.c
@@ -2,6 +2,9 @@
2/* Written by Richard Levitte (richard@levitte.org) for the OpenSSL 2/* Written by Richard Levitte (richard@levitte.org) for the OpenSSL
3 * project 2001. 3 * project 2001.
4 */ 4 */
5/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
6 * project 2008.
7 */
5/* ==================================================================== 8/* ====================================================================
6 * Copyright (c) 2001 The OpenSSL Project. All rights reserved. 9 * Copyright (c) 2001 The OpenSSL Project. All rights reserved.
7 * 10 *
@@ -73,7 +76,7 @@ struct tm *OPENSSL_gmtime(const time_t *timer, struct tm *result)
73 { 76 {
74 struct tm *ts = NULL; 77 struct tm *ts = NULL;
75 78
76#if defined(OPENSSL_THREADS) && !defined(OPENSSL_SYS_WIN32) && !defined(OPENSSL_SYS_OS2) && !defined(__CYGWIN32__) && (!defined(OPENSSL_SYS_VMS) || defined(gmtime_r)) && !defined(OPENSSL_SYS_MACOSX) && !defined(OPENSSL_SYS_SUNOS) 79#if defined(OPENSSL_THREADS) && !defined(OPENSSL_SYS_WIN32) && !defined(OPENSSL_SYS_OS2) && (!defined(OPENSSL_SYS_VMS) || defined(gmtime_r)) && !defined(OPENSSL_SYS_MACOSX) && !defined(OPENSSL_SYS_SUNOS)
77 /* should return &data, but doesn't on some systems, 80 /* should return &data, but doesn't on some systems,
78 so we don't even look at the return value */ 81 so we don't even look at the return value */
79 gmtime_r(timer,result); 82 gmtime_r(timer,result);
@@ -214,4 +217,150 @@ struct tm *OPENSSL_gmtime(const time_t *timer, struct tm *result)
214 } 217 }
215#endif 218#endif
216 return ts; 219 return ts;
217 } 220 }
221
222/* Take a tm structure and add an offset to it. This avoids any OS issues
223 * with restricted date types and overflows which cause the year 2038
224 * problem.
225 */
226
227#define SECS_PER_DAY (24 * 60 * 60)
228
229static long date_to_julian(int y, int m, int d);
230static void julian_to_date(long jd, int *y, int *m, int *d);
231
232int OPENSSL_gmtime_adj(struct tm *tm, int off_day, long offset_sec)
233 {
234 int offset_hms, offset_day;
235 long time_jd;
236 int time_year, time_month, time_day;
237 /* split offset into days and day seconds */
238 offset_day = offset_sec / SECS_PER_DAY;
239 /* Avoid sign issues with % operator */
240 offset_hms = offset_sec - (offset_day * SECS_PER_DAY);
241 offset_day += off_day;
242 /* Add current time seconds to offset */
243 offset_hms += tm->tm_hour * 3600 + tm->tm_min * 60 + tm->tm_sec;
244 /* Adjust day seconds if overflow */
245 if (offset_hms >= SECS_PER_DAY)
246 {
247 offset_day++;
248 offset_hms -= SECS_PER_DAY;
249 }
250 else if (offset_hms < 0)
251 {
252 offset_day--;
253 offset_hms += SECS_PER_DAY;
254 }
255
256 /* Convert date of time structure into a Julian day number.
257 */
258
259 time_year = tm->tm_year + 1900;
260 time_month = tm->tm_mon + 1;
261 time_day = tm->tm_mday;
262
263 time_jd = date_to_julian(time_year, time_month, time_day);
264
265 /* Work out Julian day of new date */
266 time_jd += offset_day;
267
268 if (time_jd < 0)
269 return 0;
270
271 /* Convert Julian day back to date */
272
273 julian_to_date(time_jd, &time_year, &time_month, &time_day);
274
275 if (time_year < 1900 || time_year > 9999)
276 return 0;
277
278 /* Update tm structure */
279
280 tm->tm_year = time_year - 1900;
281 tm->tm_mon = time_month - 1;
282 tm->tm_mday = time_day;
283
284 tm->tm_hour = offset_hms / 3600;
285 tm->tm_min = (offset_hms / 60) % 60;
286 tm->tm_sec = offset_hms % 60;
287
288 return 1;
289
290}
291
292/* Convert date to and from julian day
293 * Uses Fliegel & Van Flandern algorithm
294 */
295static long date_to_julian(int y, int m, int d)
296{
297 return (1461 * (y + 4800 + (m - 14) / 12)) / 4 +
298 (367 * (m - 2 - 12 * ((m - 14) / 12))) / 12 -
299 (3 * ((y + 4900 + (m - 14) / 12) / 100)) / 4 +
300 d - 32075;
301}
302
303static void julian_to_date(long jd, int *y, int *m, int *d)
304 {
305 long L = jd + 68569;
306 long n = (4 * L) / 146097;
307 long i, j;
308
309 L = L - (146097 * n + 3) / 4;
310 i = (4000 * (L + 1)) / 1461001;
311 L = L - (1461 * i) / 4 + 31;
312 j = (80 * L) / 2447;
313 *d = L - (2447 * j) / 80;
314 L = j / 11;
315 *m = j + 2 - (12 * L);
316 *y = 100 * (n - 49) + i + L;
317 }
318
319#ifdef OPENSSL_TIME_TEST
320
321#include <stdio.h>
322
323/* Time checking test code. Check times are identical for a wide range of
324 * offsets. This should be run on a machine with 64 bit time_t or it will
325 * trigger the very errors the routines fix.
326 */
327
328int main(int argc, char **argv)
329 {
330 long offset;
331 for (offset = 0; offset < 1000000; offset++)
332 {
333 check_time(offset);
334 check_time(-offset);
335 check_time(offset * 1000);
336 check_time(-offset * 1000);
337 }
338 }
339
340int check_time(long offset)
341 {
342 struct tm tm1, tm2;
343 time_t t1, t2;
344 time(&t1);
345 t2 = t1 + offset;
346 OPENSSL_gmtime(&t2, &tm2);
347 OPENSSL_gmtime(&t1, &tm1);
348 OPENSSL_gmtime_adj(&tm1, 0, offset);
349 if ((tm1.tm_year == tm2.tm_year) &&
350 (tm1.tm_mon == tm2.tm_mon) &&
351 (tm1.tm_mday == tm2.tm_mday) &&
352 (tm1.tm_hour == tm2.tm_hour) &&
353 (tm1.tm_min == tm2.tm_min) &&
354 (tm1.tm_sec == tm2.tm_sec))
355 return 1;
356 fprintf(stderr, "TIME ERROR!!\n");
357 fprintf(stderr, "Time1: %d/%d/%d, %d:%02d:%02d\n",
358 tm2.tm_mday, tm2.tm_mon + 1, tm2.tm_year + 1900,
359 tm2.tm_hour, tm2.tm_min, tm2.tm_sec);
360 fprintf(stderr, "Time2: %d/%d/%d, %d:%02d:%02d\n",
361 tm1.tm_mday, tm1.tm_mon + 1, tm1.tm_year + 1900,
362 tm1.tm_hour, tm1.tm_min, tm1.tm_sec);
363 return 0;
364 }
365
366#endif
diff --git a/src/lib/libcrypto/o_time.h b/src/lib/libcrypto/o_time.h
index e66044626d..e391da7508 100644
--- a/src/lib/libcrypto/o_time.h
+++ b/src/lib/libcrypto/o_time.h
@@ -62,5 +62,6 @@
62#include <time.h> 62#include <time.h>
63 63
64struct tm *OPENSSL_gmtime(const time_t *timer, struct tm *result); 64struct tm *OPENSSL_gmtime(const time_t *timer, struct tm *result);
65int OPENSSL_gmtime_adj(struct tm *tm, int offset_day, long offset_sec);
65 66
66#endif 67#endif
diff --git a/src/lib/libcrypto/objects/Makefile.ssl b/src/lib/libcrypto/objects/Makefile.ssl
deleted file mode 100644
index 3e7a194cf9..0000000000
--- a/src/lib/libcrypto/objects/Makefile.ssl
+++ /dev/null
@@ -1,123 +0,0 @@
1#
2# SSLeay/crypto/objects/Makefile
3#
4
5DIR= objects
6TOP= ../..
7CC= cc
8INCLUDES= -I.. -I$(TOP) -I../../include
9CFLAG=-g
10INSTALL_PREFIX=
11OPENSSLDIR= /usr/local/ssl
12INSTALLTOP=/usr/local/ssl
13MAKE= make -f Makefile.ssl
14MAKEDEPPROG= makedepend
15MAKEDEPEND= $(TOP)/util/domd $(TOP) -MD $(MAKEDEPPROG)
16MAKEFILE= Makefile.ssl
17AR= ar r
18PERL= perl
19
20CFLAGS= $(INCLUDES) $(CFLAG)
21
22GENERAL=Makefile README
23TEST=
24APPS=
25
26LIB=$(TOP)/libcrypto.a
27LIBSRC= o_names.c obj_dat.c obj_lib.c obj_err.c
28LIBOBJ= o_names.o obj_dat.o obj_lib.o obj_err.o
29
30SRC= $(LIBSRC)
31
32EXHEADER= objects.h obj_mac.h
33HEADER= $(EXHEADER) obj_dat.h
34
35ALL= $(GENERAL) $(SRC) $(HEADER)
36
37top:
38 (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all)
39
40all: obj_dat.h lib
41
42lib: $(LIBOBJ)
43 $(AR) $(LIB) $(LIBOBJ)
44 $(RANLIB) $(LIB) || echo Never mind.
45 @touch lib
46
47obj_dat.h: obj_dat.pl obj_mac.h
48 $(PERL) obj_dat.pl obj_mac.h obj_dat.h
49
50# objects.pl both reads and writes obj_mac.num
51obj_mac.h: objects.pl objects.txt obj_mac.num
52 $(PERL) objects.pl objects.txt obj_mac.num obj_mac.h
53
54files:
55 $(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO
56
57links:
58 @sh $(TOP)/util/point.sh Makefile.ssl Makefile
59 @$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER)
60 @$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST)
61 @$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS)
62
63install:
64 @for i in $(EXHEADER) ; \
65 do \
66 (cp $$i $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i; \
67 chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i ); \
68 done;
69
70tags:
71 ctags $(SRC)
72
73tests:
74
75lint:
76 lint -DLINT $(INCLUDES) $(SRC)>fluff
77
78depend:
79 $(MAKEDEPEND) -- $(CFLAG) $(INCLUDES) $(DEPFLAG) -- $(PROGS) $(LIBSRC)
80
81dclean:
82 $(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
83 mv -f Makefile.new $(MAKEFILE)
84
85clean:
86 rm -f *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff
87
88# DO NOT DELETE THIS LINE -- make depend depends on it.
89
90o_names.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
91o_names.o: ../../include/openssl/bn.h ../../include/openssl/crypto.h
92o_names.o: ../../include/openssl/e_os2.h ../../include/openssl/lhash.h
93o_names.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
94o_names.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
95o_names.o: ../../include/openssl/ossl_typ.h ../../include/openssl/safestack.h
96o_names.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
97o_names.o: o_names.c
98obj_dat.o: ../../e_os.h ../../include/openssl/asn1.h
99obj_dat.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
100obj_dat.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
101obj_dat.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
102obj_dat.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
103obj_dat.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
104obj_dat.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
105obj_dat.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
106obj_dat.o: ../../include/openssl/symhacks.h ../cryptlib.h obj_dat.c obj_dat.h
107obj_err.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
108obj_err.o: ../../include/openssl/bn.h ../../include/openssl/crypto.h
109obj_err.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
110obj_err.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
111obj_err.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
112obj_err.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
113obj_err.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
114obj_err.o: ../../include/openssl/symhacks.h obj_err.c
115obj_lib.o: ../../e_os.h ../../include/openssl/asn1.h
116obj_lib.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
117obj_lib.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
118obj_lib.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
119obj_lib.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
120obj_lib.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
121obj_lib.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
122obj_lib.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
123obj_lib.o: ../../include/openssl/symhacks.h ../cryptlib.h obj_lib.c
diff --git a/src/lib/libcrypto/objects/o_names.c b/src/lib/libcrypto/objects/o_names.c
index adb5731f76..84380a96a9 100644
--- a/src/lib/libcrypto/objects/o_names.c
+++ b/src/lib/libcrypto/objects/o_names.c
@@ -22,7 +22,8 @@
22/* I use the ex_data stuff to manage the identifiers for the obj_name_types 22/* I use the ex_data stuff to manage the identifiers for the obj_name_types
23 * that applications may define. I only really use the free function field. 23 * that applications may define. I only really use the free function field.
24 */ 24 */
25static LHASH *names_lh=NULL; 25DECLARE_LHASH_OF(OBJ_NAME);
26static LHASH_OF(OBJ_NAME) *names_lh=NULL;
26static int names_type_num=OBJ_NAME_TYPE_NUM; 27static int names_type_num=OBJ_NAME_TYPE_NUM;
27 28
28typedef struct name_funcs_st 29typedef struct name_funcs_st
@@ -46,11 +47,14 @@ static unsigned long obj_name_hash(const void *a_void);
46/* static int obj_name_cmp(OBJ_NAME *a,OBJ_NAME *b); */ 47/* static int obj_name_cmp(OBJ_NAME *a,OBJ_NAME *b); */
47static int obj_name_cmp(const void *a_void,const void *b_void); 48static int obj_name_cmp(const void *a_void,const void *b_void);
48 49
50static IMPLEMENT_LHASH_HASH_FN(obj_name, OBJ_NAME)
51static IMPLEMENT_LHASH_COMP_FN(obj_name, OBJ_NAME)
52
49int OBJ_NAME_init(void) 53int OBJ_NAME_init(void)
50 { 54 {
51 if (names_lh != NULL) return(1); 55 if (names_lh != NULL) return(1);
52 MemCheck_off(); 56 MemCheck_off();
53 names_lh=lh_new(obj_name_hash, obj_name_cmp); 57 names_lh=lh_OBJ_NAME_new();
54 MemCheck_on(); 58 MemCheck_on();
55 return(names_lh != NULL); 59 return(names_lh != NULL);
56 } 60 }
@@ -164,7 +168,7 @@ const char *OBJ_NAME_get(const char *name, int type)
164 168
165 for (;;) 169 for (;;)
166 { 170 {
167 ret=(OBJ_NAME *)lh_retrieve(names_lh,&on); 171 ret=lh_OBJ_NAME_retrieve(names_lh,&on);
168 if (ret == NULL) return(NULL); 172 if (ret == NULL) return(NULL);
169 if ((ret->alias) && !alias) 173 if ((ret->alias) && !alias)
170 { 174 {
@@ -200,7 +204,7 @@ int OBJ_NAME_add(const char *name, int type, const char *data)
200 onp->type=type; 204 onp->type=type;
201 onp->data=data; 205 onp->data=data;
202 206
203 ret=(OBJ_NAME *)lh_insert(names_lh,onp); 207 ret=lh_OBJ_NAME_insert(names_lh,onp);
204 if (ret != NULL) 208 if (ret != NULL)
205 { 209 {
206 /* free things */ 210 /* free things */
@@ -217,7 +221,7 @@ int OBJ_NAME_add(const char *name, int type, const char *data)
217 } 221 }
218 else 222 else
219 { 223 {
220 if (lh_error(names_lh)) 224 if (lh_OBJ_NAME_error(names_lh))
221 { 225 {
222 /* ERROR */ 226 /* ERROR */
223 return(0); 227 return(0);
@@ -235,7 +239,7 @@ int OBJ_NAME_remove(const char *name, int type)
235 type&= ~OBJ_NAME_ALIAS; 239 type&= ~OBJ_NAME_ALIAS;
236 on.name=name; 240 on.name=name;
237 on.type=type; 241 on.type=type;
238 ret=(OBJ_NAME *)lh_delete(names_lh,&on); 242 ret=lh_OBJ_NAME_delete(names_lh,&on);
239 if (ret != NULL) 243 if (ret != NULL)
240 { 244 {
241 /* free things */ 245 /* free things */
@@ -262,13 +266,13 @@ struct doall
262 void *arg; 266 void *arg;
263 }; 267 };
264 268
265static void do_all_fn(const OBJ_NAME *name,struct doall *d) 269static void do_all_fn_doall_arg(const OBJ_NAME *name,struct doall *d)
266 { 270 {
267 if(name->type == d->type) 271 if(name->type == d->type)
268 d->fn(name,d->arg); 272 d->fn(name,d->arg);
269 } 273 }
270 274
271static IMPLEMENT_LHASH_DOALL_ARG_FN(do_all_fn, const OBJ_NAME *, struct doall *) 275static IMPLEMENT_LHASH_DOALL_ARG_FN(do_all_fn, const OBJ_NAME, struct doall)
272 276
273void OBJ_NAME_do_all(int type,void (*fn)(const OBJ_NAME *,void *arg),void *arg) 277void OBJ_NAME_do_all(int type,void (*fn)(const OBJ_NAME *,void *arg),void *arg)
274 { 278 {
@@ -278,7 +282,8 @@ void OBJ_NAME_do_all(int type,void (*fn)(const OBJ_NAME *,void *arg),void *arg)
278 d.fn=fn; 282 d.fn=fn;
279 d.arg=arg; 283 d.arg=arg;
280 284
281 lh_doall_arg(names_lh,LHASH_DOALL_ARG_FN(do_all_fn),&d); 285 lh_OBJ_NAME_doall_arg(names_lh, LHASH_DOALL_ARG_FN(do_all_fn),
286 struct doall, &d);
282 } 287 }
283 288
284struct doall_sorted 289struct doall_sorted
@@ -313,7 +318,7 @@ void OBJ_NAME_do_all_sorted(int type,void (*fn)(const OBJ_NAME *,void *arg),
313 int n; 318 int n;
314 319
315 d.type=type; 320 d.type=type;
316 d.names=OPENSSL_malloc(lh_num_items(names_lh)*sizeof *d.names); 321 d.names=OPENSSL_malloc(lh_OBJ_NAME_num_items(names_lh)*sizeof *d.names);
317 d.n=0; 322 d.n=0;
318 OBJ_NAME_do_all(type,do_all_sorted_fn,&d); 323 OBJ_NAME_do_all(type,do_all_sorted_fn,&d);
319 324
@@ -327,18 +332,16 @@ void OBJ_NAME_do_all_sorted(int type,void (*fn)(const OBJ_NAME *,void *arg),
327 332
328static int free_type; 333static int free_type;
329 334
330static void names_lh_free(OBJ_NAME *onp) 335static void names_lh_free_doall(OBJ_NAME *onp)
331{ 336 {
332 if(onp == NULL) 337 if (onp == NULL)
333 return; 338 return;
334 339
335 if ((free_type < 0) || (free_type == onp->type)) 340 if (free_type < 0 || free_type == onp->type)
336 {
337 OBJ_NAME_remove(onp->name,onp->type); 341 OBJ_NAME_remove(onp->name,onp->type);
338 }
339 } 342 }
340 343
341static IMPLEMENT_LHASH_DOALL_FN(names_lh_free, OBJ_NAME *) 344static IMPLEMENT_LHASH_DOALL_FN(names_lh_free, OBJ_NAME)
342 345
343static void name_funcs_free(NAME_FUNCS *ptr) 346static void name_funcs_free(NAME_FUNCS *ptr)
344 { 347 {
@@ -352,18 +355,18 @@ void OBJ_NAME_cleanup(int type)
352 if (names_lh == NULL) return; 355 if (names_lh == NULL) return;
353 356
354 free_type=type; 357 free_type=type;
355 down_load=names_lh->down_load; 358 down_load=lh_OBJ_NAME_down_load(names_lh);
356 names_lh->down_load=0; 359 lh_OBJ_NAME_down_load(names_lh)=0;
357 360
358 lh_doall(names_lh,LHASH_DOALL_FN(names_lh_free)); 361 lh_OBJ_NAME_doall(names_lh,LHASH_DOALL_FN(names_lh_free));
359 if (type < 0) 362 if (type < 0)
360 { 363 {
361 lh_free(names_lh); 364 lh_OBJ_NAME_free(names_lh);
362 sk_NAME_FUNCS_pop_free(name_funcs_stack,name_funcs_free); 365 sk_NAME_FUNCS_pop_free(name_funcs_stack,name_funcs_free);
363 names_lh=NULL; 366 names_lh=NULL;
364 name_funcs_stack = NULL; 367 name_funcs_stack = NULL;
365 } 368 }
366 else 369 else
367 names_lh->down_load=down_load; 370 lh_OBJ_NAME_down_load(names_lh)=down_load;
368 } 371 }
369 372
diff --git a/src/lib/libcrypto/objects/obj_dat.c b/src/lib/libcrypto/objects/obj_dat.c
index 7fd7433241..8a342ba3eb 100644
--- a/src/lib/libcrypto/objects/obj_dat.c
+++ b/src/lib/libcrypto/objects/obj_dat.c
@@ -74,16 +74,17 @@
74#define NUM_SN 0 74#define NUM_SN 0
75#define NUM_LN 0 75#define NUM_LN 0
76#define NUM_OBJ 0 76#define NUM_OBJ 0
77static unsigned char lvalues[1]; 77static const unsigned char lvalues[1];
78static ASN1_OBJECT nid_objs[1]; 78static const ASN1_OBJECT nid_objs[1];
79static ASN1_OBJECT *sn_objs[1]; 79static const unsigned int sn_objs[1];
80static ASN1_OBJECT *ln_objs[1]; 80static const unsigned int ln_objs[1];
81static ASN1_OBJECT *obj_objs[1]; 81static const unsigned int obj_objs[1];
82#endif 82#endif
83 83
84static int sn_cmp(const void *a, const void *b); 84DECLARE_OBJ_BSEARCH_CMP_FN(const ASN1_OBJECT *, unsigned int, sn);
85static int ln_cmp(const void *a, const void *b); 85DECLARE_OBJ_BSEARCH_CMP_FN(const ASN1_OBJECT *, unsigned int, ln);
86static int obj_cmp(const void *a, const void *b); 86DECLARE_OBJ_BSEARCH_CMP_FN(const ASN1_OBJECT *, unsigned int, obj);
87
87#define ADDED_DATA 0 88#define ADDED_DATA 0
88#define ADDED_SNAME 1 89#define ADDED_SNAME 1
89#define ADDED_LNAME 2 90#define ADDED_LNAME 2
@@ -94,30 +95,27 @@ typedef struct added_obj_st
94 int type; 95 int type;
95 ASN1_OBJECT *obj; 96 ASN1_OBJECT *obj;
96 } ADDED_OBJ; 97 } ADDED_OBJ;
98DECLARE_LHASH_OF(ADDED_OBJ);
97 99
98static int new_nid=NUM_NID; 100static int new_nid=NUM_NID;
99static LHASH *added=NULL; 101static LHASH_OF(ADDED_OBJ) *added=NULL;
100 102
101static int sn_cmp(const void *a, const void *b) 103static int sn_cmp(const ASN1_OBJECT * const *a, const unsigned int *b)
102 { 104 { return(strcmp((*a)->sn,nid_objs[*b].sn)); }
103 const ASN1_OBJECT * const *ap = a, * const *bp = b;
104 return(strcmp((*ap)->sn,(*bp)->sn));
105 }
106 105
107static int ln_cmp(const void *a, const void *b) 106IMPLEMENT_OBJ_BSEARCH_CMP_FN(const ASN1_OBJECT *, unsigned int, sn);
108 { 107
109 const ASN1_OBJECT * const *ap = a, * const *bp = b; 108static int ln_cmp(const ASN1_OBJECT * const *a, const unsigned int *b)
110 return(strcmp((*ap)->ln,(*bp)->ln)); 109 { return(strcmp((*a)->ln,nid_objs[*b].ln)); }
111 }
112 110
113/* static unsigned long add_hash(ADDED_OBJ *ca) */ 111IMPLEMENT_OBJ_BSEARCH_CMP_FN(const ASN1_OBJECT *, unsigned int, ln);
114static unsigned long add_hash(const void *ca_void) 112
113static unsigned long added_obj_hash(const ADDED_OBJ *ca)
115 { 114 {
116 const ASN1_OBJECT *a; 115 const ASN1_OBJECT *a;
117 int i; 116 int i;
118 unsigned long ret=0; 117 unsigned long ret=0;
119 unsigned char *p; 118 unsigned char *p;
120 const ADDED_OBJ *ca = (const ADDED_OBJ *)ca_void;
121 119
122 a=ca->obj; 120 a=ca->obj;
123 switch (ca->type) 121 switch (ca->type)
@@ -145,14 +143,12 @@ static unsigned long add_hash(const void *ca_void)
145 ret|=ca->type<<30L; 143 ret|=ca->type<<30L;
146 return(ret); 144 return(ret);
147 } 145 }
146static IMPLEMENT_LHASH_HASH_FN(added_obj, ADDED_OBJ)
148 147
149/* static int add_cmp(ADDED_OBJ *ca, ADDED_OBJ *cb) */ 148static int added_obj_cmp(const ADDED_OBJ *ca, const ADDED_OBJ *cb)
150static int add_cmp(const void *ca_void, const void *cb_void)
151 { 149 {
152 ASN1_OBJECT *a,*b; 150 ASN1_OBJECT *a,*b;
153 int i; 151 int i;
154 const ADDED_OBJ *ca = (const ADDED_OBJ *)ca_void;
155 const ADDED_OBJ *cb = (const ADDED_OBJ *)cb_void;
156 152
157 i=ca->type-cb->type; 153 i=ca->type-cb->type;
158 if (i) return(i); 154 if (i) return(i);
@@ -179,15 +175,16 @@ static int add_cmp(const void *ca_void, const void *cb_void)
179 return 0; 175 return 0;
180 } 176 }
181 } 177 }
178static IMPLEMENT_LHASH_COMP_FN(added_obj, ADDED_OBJ)
182 179
183static int init_added(void) 180static int init_added(void)
184 { 181 {
185 if (added != NULL) return(1); 182 if (added != NULL) return(1);
186 added=lh_new(add_hash,add_cmp); 183 added=lh_ADDED_OBJ_new();
187 return(added != NULL); 184 return(added != NULL);
188 } 185 }
189 186
190static void cleanup1(ADDED_OBJ *a) 187static void cleanup1_doall(ADDED_OBJ *a)
191 { 188 {
192 a->obj->nid=0; 189 a->obj->nid=0;
193 a->obj->flags|=ASN1_OBJECT_FLAG_DYNAMIC| 190 a->obj->flags|=ASN1_OBJECT_FLAG_DYNAMIC|
@@ -195,28 +192,46 @@ static void cleanup1(ADDED_OBJ *a)
195 ASN1_OBJECT_FLAG_DYNAMIC_DATA; 192 ASN1_OBJECT_FLAG_DYNAMIC_DATA;
196 } 193 }
197 194
198static void cleanup2(ADDED_OBJ *a) 195static void cleanup2_doall(ADDED_OBJ *a)
199 { a->obj->nid++; } 196 { a->obj->nid++; }
200 197
201static void cleanup3(ADDED_OBJ *a) 198static void cleanup3_doall(ADDED_OBJ *a)
202 { 199 {
203 if (--a->obj->nid == 0) 200 if (--a->obj->nid == 0)
204 ASN1_OBJECT_free(a->obj); 201 ASN1_OBJECT_free(a->obj);
205 OPENSSL_free(a); 202 OPENSSL_free(a);
206 } 203 }
207 204
208static IMPLEMENT_LHASH_DOALL_FN(cleanup1, ADDED_OBJ *) 205static IMPLEMENT_LHASH_DOALL_FN(cleanup1, ADDED_OBJ)
209static IMPLEMENT_LHASH_DOALL_FN(cleanup2, ADDED_OBJ *) 206static IMPLEMENT_LHASH_DOALL_FN(cleanup2, ADDED_OBJ)
210static IMPLEMENT_LHASH_DOALL_FN(cleanup3, ADDED_OBJ *) 207static IMPLEMENT_LHASH_DOALL_FN(cleanup3, ADDED_OBJ)
208
209/* The purpose of obj_cleanup_defer is to avoid EVP_cleanup() attempting
210 * to use freed up OIDs. If neccessary the actual freeing up of OIDs is
211 * delayed.
212 */
213
214int obj_cleanup_defer = 0;
215
216void check_defer(int nid)
217 {
218 if (!obj_cleanup_defer && nid >= NUM_NID)
219 obj_cleanup_defer = 1;
220 }
211 221
212void OBJ_cleanup(void) 222void OBJ_cleanup(void)
213 { 223 {
224 if (obj_cleanup_defer)
225 {
226 obj_cleanup_defer = 2;
227 return ;
228 }
214 if (added == NULL) return; 229 if (added == NULL) return;
215 added->down_load=0; 230 lh_ADDED_OBJ_down_load(added) = 0;
216 lh_doall(added,LHASH_DOALL_FN(cleanup1)); /* zero counters */ 231 lh_ADDED_OBJ_doall(added,LHASH_DOALL_FN(cleanup1)); /* zero counters */
217 lh_doall(added,LHASH_DOALL_FN(cleanup2)); /* set counters */ 232 lh_ADDED_OBJ_doall(added,LHASH_DOALL_FN(cleanup2)); /* set counters */
218 lh_doall(added,LHASH_DOALL_FN(cleanup3)); /* free objects */ 233 lh_ADDED_OBJ_doall(added,LHASH_DOALL_FN(cleanup3)); /* free objects */
219 lh_free(added); 234 lh_ADDED_OBJ_free(added);
220 added=NULL; 235 added=NULL;
221 } 236 }
222 237
@@ -252,7 +267,7 @@ int OBJ_add_object(const ASN1_OBJECT *obj)
252 { 267 {
253 ao[i]->type=i; 268 ao[i]->type=i;
254 ao[i]->obj=o; 269 ao[i]->obj=o;
255 aop=(ADDED_OBJ *)lh_insert(added,ao[i]); 270 aop=lh_ADDED_OBJ_insert(added,ao[i]);
256 /* memory leak, buit should not normally matter */ 271 /* memory leak, buit should not normally matter */
257 if (aop != NULL) 272 if (aop != NULL)
258 OPENSSL_free(aop); 273 OPENSSL_free(aop);
@@ -292,7 +307,7 @@ ASN1_OBJECT *OBJ_nid2obj(int n)
292 ad.type=ADDED_NID; 307 ad.type=ADDED_NID;
293 ad.obj= &ob; 308 ad.obj= &ob;
294 ob.nid=n; 309 ob.nid=n;
295 adp=(ADDED_OBJ *)lh_retrieve(added,&ad); 310 adp=lh_ADDED_OBJ_retrieve(added,&ad);
296 if (adp != NULL) 311 if (adp != NULL)
297 return(adp->obj); 312 return(adp->obj);
298 else 313 else
@@ -324,7 +339,7 @@ const char *OBJ_nid2sn(int n)
324 ad.type=ADDED_NID; 339 ad.type=ADDED_NID;
325 ad.obj= &ob; 340 ad.obj= &ob;
326 ob.nid=n; 341 ob.nid=n;
327 adp=(ADDED_OBJ *)lh_retrieve(added,&ad); 342 adp=lh_ADDED_OBJ_retrieve(added,&ad);
328 if (adp != NULL) 343 if (adp != NULL)
329 return(adp->obj->sn); 344 return(adp->obj->sn);
330 else 345 else
@@ -356,7 +371,7 @@ const char *OBJ_nid2ln(int n)
356 ad.type=ADDED_NID; 371 ad.type=ADDED_NID;
357 ad.obj= &ob; 372 ad.obj= &ob;
358 ob.nid=n; 373 ob.nid=n;
359 adp=(ADDED_OBJ *)lh_retrieve(added,&ad); 374 adp=lh_ADDED_OBJ_retrieve(added,&ad);
360 if (adp != NULL) 375 if (adp != NULL)
361 return(adp->obj->ln); 376 return(adp->obj->ln);
362 else 377 else
@@ -367,9 +382,22 @@ const char *OBJ_nid2ln(int n)
367 } 382 }
368 } 383 }
369 384
385static int obj_cmp(const ASN1_OBJECT * const *ap, const unsigned int *bp)
386 {
387 int j;
388 const ASN1_OBJECT *a= *ap;
389 const ASN1_OBJECT *b= &nid_objs[*bp];
390
391 j=(a->length - b->length);
392 if (j) return(j);
393 return(memcmp(a->data,b->data,a->length));
394 }
395
396IMPLEMENT_OBJ_BSEARCH_CMP_FN(const ASN1_OBJECT *, unsigned int, obj);
397
370int OBJ_obj2nid(const ASN1_OBJECT *a) 398int OBJ_obj2nid(const ASN1_OBJECT *a)
371 { 399 {
372 ASN1_OBJECT **op; 400 const unsigned int *op;
373 ADDED_OBJ ad,*adp; 401 ADDED_OBJ ad,*adp;
374 402
375 if (a == NULL) 403 if (a == NULL)
@@ -381,14 +409,13 @@ int OBJ_obj2nid(const ASN1_OBJECT *a)
381 { 409 {
382 ad.type=ADDED_DATA; 410 ad.type=ADDED_DATA;
383 ad.obj=(ASN1_OBJECT *)a; /* XXX: ugly but harmless */ 411 ad.obj=(ASN1_OBJECT *)a; /* XXX: ugly but harmless */
384 adp=(ADDED_OBJ *)lh_retrieve(added,&ad); 412 adp=lh_ADDED_OBJ_retrieve(added,&ad);
385 if (adp != NULL) return (adp->obj->nid); 413 if (adp != NULL) return (adp->obj->nid);
386 } 414 }
387 op=(ASN1_OBJECT **)OBJ_bsearch((const char *)&a,(const char *)obj_objs, 415 op=OBJ_bsearch_obj(&a, obj_objs, NUM_OBJ);
388 NUM_OBJ, sizeof(ASN1_OBJECT *),obj_cmp);
389 if (op == NULL) 416 if (op == NULL)
390 return(NID_undef); 417 return(NID_undef);
391 return((*op)->nid); 418 return(nid_objs[*op].nid);
392 } 419 }
393 420
394/* Convert an object name into an ASN1_OBJECT 421/* Convert an object name into an ASN1_OBJECT
@@ -441,7 +468,7 @@ int OBJ_obj2txt(char *buf, int buf_len, const ASN1_OBJECT *a, int no_name)
441 int i,n=0,len,nid, first, use_bn; 468 int i,n=0,len,nid, first, use_bn;
442 BIGNUM *bl; 469 BIGNUM *bl;
443 unsigned long l; 470 unsigned long l;
444 unsigned char *p; 471 const unsigned char *p;
445 char tbuf[DECIMAL_SIZE(i)+DECIMAL_SIZE(l)+2]; 472 char tbuf[DECIMAL_SIZE(i)+DECIMAL_SIZE(l)+2];
446 473
447 if ((a == NULL) || (a->data == NULL)) { 474 if ((a == NULL) || (a->data == NULL)) {
@@ -456,10 +483,13 @@ int OBJ_obj2txt(char *buf, int buf_len, const ASN1_OBJECT *a, int no_name)
456 s=OBJ_nid2ln(nid); 483 s=OBJ_nid2ln(nid);
457 if (s == NULL) 484 if (s == NULL)
458 s=OBJ_nid2sn(nid); 485 s=OBJ_nid2sn(nid);
459 if (buf) 486 if (s)
460 BUF_strlcpy(buf,s,buf_len); 487 {
461 n=strlen(s); 488 if (buf)
462 return n; 489 BUF_strlcpy(buf,s,buf_len);
490 n=strlen(s);
491 return n;
492 }
463 } 493 }
464 494
465 495
@@ -607,62 +637,56 @@ int OBJ_txt2nid(const char *s)
607 637
608int OBJ_ln2nid(const char *s) 638int OBJ_ln2nid(const char *s)
609 { 639 {
610 ASN1_OBJECT o,*oo= &o,**op; 640 ASN1_OBJECT o;
641 const ASN1_OBJECT *oo= &o;
611 ADDED_OBJ ad,*adp; 642 ADDED_OBJ ad,*adp;
643 const unsigned int *op;
612 644
613 o.ln=s; 645 o.ln=s;
614 if (added != NULL) 646 if (added != NULL)
615 { 647 {
616 ad.type=ADDED_LNAME; 648 ad.type=ADDED_LNAME;
617 ad.obj= &o; 649 ad.obj= &o;
618 adp=(ADDED_OBJ *)lh_retrieve(added,&ad); 650 adp=lh_ADDED_OBJ_retrieve(added,&ad);
619 if (adp != NULL) return (adp->obj->nid); 651 if (adp != NULL) return (adp->obj->nid);
620 } 652 }
621 op=(ASN1_OBJECT **)OBJ_bsearch((char *)&oo,(char *)ln_objs, NUM_LN, 653 op=OBJ_bsearch_ln(&oo, ln_objs, NUM_LN);
622 sizeof(ASN1_OBJECT *),ln_cmp);
623 if (op == NULL) return(NID_undef); 654 if (op == NULL) return(NID_undef);
624 return((*op)->nid); 655 return(nid_objs[*op].nid);
625 } 656 }
626 657
627int OBJ_sn2nid(const char *s) 658int OBJ_sn2nid(const char *s)
628 { 659 {
629 ASN1_OBJECT o,*oo= &o,**op; 660 ASN1_OBJECT o;
661 const ASN1_OBJECT *oo= &o;
630 ADDED_OBJ ad,*adp; 662 ADDED_OBJ ad,*adp;
663 const unsigned int *op;
631 664
632 o.sn=s; 665 o.sn=s;
633 if (added != NULL) 666 if (added != NULL)
634 { 667 {
635 ad.type=ADDED_SNAME; 668 ad.type=ADDED_SNAME;
636 ad.obj= &o; 669 ad.obj= &o;
637 adp=(ADDED_OBJ *)lh_retrieve(added,&ad); 670 adp=lh_ADDED_OBJ_retrieve(added,&ad);
638 if (adp != NULL) return (adp->obj->nid); 671 if (adp != NULL) return (adp->obj->nid);
639 } 672 }
640 op=(ASN1_OBJECT **)OBJ_bsearch((char *)&oo,(char *)sn_objs,NUM_SN, 673 op=OBJ_bsearch_sn(&oo, sn_objs, NUM_SN);
641 sizeof(ASN1_OBJECT *),sn_cmp);
642 if (op == NULL) return(NID_undef); 674 if (op == NULL) return(NID_undef);
643 return((*op)->nid); 675 return(nid_objs[*op].nid);
644 } 676 }
645 677
646static int obj_cmp(const void *ap, const void *bp) 678const void *OBJ_bsearch_(const void *key, const void *base, int num, int size,
647 { 679 int (*cmp)(const void *, const void *))
648 int j;
649 const ASN1_OBJECT *a= *(ASN1_OBJECT * const *)ap;
650 const ASN1_OBJECT *b= *(ASN1_OBJECT * const *)bp;
651
652 j=(a->length - b->length);
653 if (j) return(j);
654 return(memcmp(a->data,b->data,a->length));
655 }
656
657const char *OBJ_bsearch(const char *key, const char *base, int num, int size,
658 int (*cmp)(const void *, const void *))
659 { 680 {
660 return OBJ_bsearch_ex(key, base, num, size, cmp, 0); 681 return OBJ_bsearch_ex_(key, base, num, size, cmp, 0);
661 } 682 }
662 683
663const char *OBJ_bsearch_ex(const char *key, const char *base, int num, 684const void *OBJ_bsearch_ex_(const void *key, const void *base_, int num,
664 int size, int (*cmp)(const void *, const void *), int flags) 685 int size,
686 int (*cmp)(const void *, const void *),
687 int flags)
665 { 688 {
689 const char *base=base_;
666 int l,h,i=0,c=0; 690 int l,h,i=0,c=0;
667 const char *p = NULL; 691 const char *p = NULL;
668 692
diff --git a/src/lib/libcrypto/objects/obj_dat.pl b/src/lib/libcrypto/objects/obj_dat.pl
index 7de2f77afd..c67f71c327 100644
--- a/src/lib/libcrypto/objects/obj_dat.pl
+++ b/src/lib/libcrypto/objects/obj_dat.pl
@@ -2,9 +2,7 @@
2 2
3# fixes bug in floating point emulation on sparc64 when 3# fixes bug in floating point emulation on sparc64 when
4# this script produces off-by-one output on sparc64 4# this script produces off-by-one output on sparc64
5eval 'use integer;'; 5use integer;
6
7print STDERR "Warning: perl module integer not found.\n" if ($@);
8 6
9sub obj_cmp 7sub obj_cmp
10 { 8 {
@@ -150,13 +148,13 @@ for ($i=0; $i<$n; $i++)
150@a=grep(defined($sn{$nid{$_}}),0 .. $n); 148@a=grep(defined($sn{$nid{$_}}),0 .. $n);
151foreach (sort { $sn{$nid{$a}} cmp $sn{$nid{$b}} } @a) 149foreach (sort { $sn{$nid{$a}} cmp $sn{$nid{$b}} } @a)
152 { 150 {
153 push(@sn,sprintf("&(nid_objs[%2d]),/* \"$sn{$nid{$_}}\" */\n",$_)); 151 push(@sn,sprintf("%2d,\t/* \"$sn{$nid{$_}}\" */\n",$_));
154 } 152 }
155 153
156@a=grep(defined($ln{$nid{$_}}),0 .. $n); 154@a=grep(defined($ln{$nid{$_}}),0 .. $n);
157foreach (sort { $ln{$nid{$a}} cmp $ln{$nid{$b}} } @a) 155foreach (sort { $ln{$nid{$a}} cmp $ln{$nid{$b}} } @a)
158 { 156 {
159 push(@ln,sprintf("&(nid_objs[%2d]),/* \"$ln{$nid{$_}}\" */\n",$_)); 157 push(@ln,sprintf("%2d,\t/* \"$ln{$nid{$_}}\" */\n",$_));
160 } 158 }
161 159
162@a=grep(defined($obj{$nid{$_}}),0 .. $n); 160@a=grep(defined($obj{$nid{$_}}),0 .. $n);
@@ -166,7 +164,7 @@ foreach (sort obj_cmp @a)
166 $v=$objd{$m}; 164 $v=$objd{$m};
167 $v =~ s/L//g; 165 $v =~ s/L//g;
168 $v =~ s/,/ /g; 166 $v =~ s/,/ /g;
169 push(@ob,sprintf("&(nid_objs[%2d]),/* %-32s %s */\n",$_,$m,$v)); 167 push(@ob,sprintf("%2d,\t/* %-32s %s */\n",$_,$m,$v));
170 } 168 }
171 169
172print OUT <<'EOF'; 170print OUT <<'EOF';
@@ -241,11 +239,11 @@ printf OUT "#define NUM_SN %d\n",$#sn+1;
241printf OUT "#define NUM_LN %d\n",$#ln+1; 239printf OUT "#define NUM_LN %d\n",$#ln+1;
242printf OUT "#define NUM_OBJ %d\n\n",$#ob+1; 240printf OUT "#define NUM_OBJ %d\n\n",$#ob+1;
243 241
244printf OUT "static unsigned char lvalues[%d]={\n",$lvalues+1; 242printf OUT "static const unsigned char lvalues[%d]={\n",$lvalues+1;
245print OUT @lvalues; 243print OUT @lvalues;
246print OUT "};\n\n"; 244print OUT "};\n\n";
247 245
248printf OUT "static ASN1_OBJECT nid_objs[NUM_NID]={\n"; 246printf OUT "static const ASN1_OBJECT nid_objs[NUM_NID]={\n";
249foreach (@out) 247foreach (@out)
250 { 248 {
251 if (length($_) > 75) 249 if (length($_) > 75)
@@ -269,15 +267,15 @@ foreach (@out)
269 } 267 }
270print OUT "};\n\n"; 268print OUT "};\n\n";
271 269
272printf OUT "static ASN1_OBJECT *sn_objs[NUM_SN]={\n"; 270printf OUT "static const unsigned int sn_objs[NUM_SN]={\n";
273print OUT @sn; 271print OUT @sn;
274print OUT "};\n\n"; 272print OUT "};\n\n";
275 273
276printf OUT "static ASN1_OBJECT *ln_objs[NUM_LN]={\n"; 274printf OUT "static const unsigned int ln_objs[NUM_LN]={\n";
277print OUT @ln; 275print OUT @ln;
278print OUT "};\n\n"; 276print OUT "};\n\n";
279 277
280printf OUT "static ASN1_OBJECT *obj_objs[NUM_OBJ]={\n"; 278printf OUT "static const unsigned int obj_objs[NUM_OBJ]={\n";
281print OUT @ob; 279print OUT @ob;
282print OUT "};\n\n"; 280print OUT "};\n\n";
283 281
diff --git a/src/lib/libcrypto/objects/obj_err.c b/src/lib/libcrypto/objects/obj_err.c
index 12b48850c6..2e7a034c3f 100644
--- a/src/lib/libcrypto/objects/obj_err.c
+++ b/src/lib/libcrypto/objects/obj_err.c
@@ -1,6 +1,6 @@
1/* crypto/objects/obj_err.c */ 1/* crypto/objects/obj_err.c */
2/* ==================================================================== 2/* ====================================================================
3 * Copyright (c) 1999-2005 The OpenSSL Project. All rights reserved. 3 * Copyright (c) 1999-2006 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
diff --git a/src/lib/libcrypto/objects/obj_lib.c b/src/lib/libcrypto/objects/obj_lib.c
index 706fa0b0e7..23e9d48cdf 100644
--- a/src/lib/libcrypto/objects/obj_lib.c
+++ b/src/lib/libcrypto/objects/obj_lib.c
@@ -66,7 +66,8 @@ ASN1_OBJECT *OBJ_dup(const ASN1_OBJECT *o)
66 { 66 {
67 ASN1_OBJECT *r; 67 ASN1_OBJECT *r;
68 int i; 68 int i;
69 char *ln=NULL; 69 char *ln=NULL,*sn=NULL;
70 unsigned char *data=NULL;
70 71
71 if (o == NULL) return(NULL); 72 if (o == NULL) return(NULL);
72 if (!(o->flags & ASN1_OBJECT_FLAG_DYNAMIC)) 73 if (!(o->flags & ASN1_OBJECT_FLAG_DYNAMIC))
@@ -79,42 +80,42 @@ ASN1_OBJECT *OBJ_dup(const ASN1_OBJECT *o)
79 OBJerr(OBJ_F_OBJ_DUP,ERR_R_ASN1_LIB); 80 OBJerr(OBJ_F_OBJ_DUP,ERR_R_ASN1_LIB);
80 return(NULL); 81 return(NULL);
81 } 82 }
82 r->data=OPENSSL_malloc(o->length); 83 data=OPENSSL_malloc(o->length);
83 if (r->data == NULL) 84 if (data == NULL)
84 goto err; 85 goto err;
85 if (o->data != NULL) 86 if (o->data != NULL)
86 memcpy(r->data,o->data,o->length); 87 memcpy(data,o->data,o->length);
88 /* once data attached to object it remains const */
89 r->data = data;
87 r->length=o->length; 90 r->length=o->length;
88 r->nid=o->nid; 91 r->nid=o->nid;
89 r->ln=r->sn=NULL; 92 r->ln=r->sn=NULL;
90 if (o->ln != NULL) 93 if (o->ln != NULL)
91 { 94 {
92 i=strlen(o->ln)+1; 95 i=strlen(o->ln)+1;
93 r->ln=ln=OPENSSL_malloc(i); 96 ln=OPENSSL_malloc(i);
94 if (r->ln == NULL) goto err; 97 if (ln == NULL) goto err;
95 memcpy(ln,o->ln,i); 98 memcpy(ln,o->ln,i);
99 r->ln=ln;
96 } 100 }
97 101
98 if (o->sn != NULL) 102 if (o->sn != NULL)
99 { 103 {
100 char *s;
101
102 i=strlen(o->sn)+1; 104 i=strlen(o->sn)+1;
103 r->sn=s=OPENSSL_malloc(i); 105 sn=OPENSSL_malloc(i);
104 if (r->sn == NULL) goto err; 106 if (sn == NULL) goto err;
105 memcpy(s,o->sn,i); 107 memcpy(sn,o->sn,i);
108 r->sn=sn;
106 } 109 }
107 r->flags=o->flags|(ASN1_OBJECT_FLAG_DYNAMIC| 110 r->flags=o->flags|(ASN1_OBJECT_FLAG_DYNAMIC|
108 ASN1_OBJECT_FLAG_DYNAMIC_STRINGS|ASN1_OBJECT_FLAG_DYNAMIC_DATA); 111 ASN1_OBJECT_FLAG_DYNAMIC_STRINGS|ASN1_OBJECT_FLAG_DYNAMIC_DATA);
109 return(r); 112 return(r);
110err: 113err:
111 OBJerr(OBJ_F_OBJ_DUP,ERR_R_MALLOC_FAILURE); 114 OBJerr(OBJ_F_OBJ_DUP,ERR_R_MALLOC_FAILURE);
112 if (r != NULL) 115 if (ln != NULL) OPENSSL_free(ln);
113 { 116 if (sn != NULL) OPENSSL_free(sn);
114 if (ln != NULL) OPENSSL_free(ln); 117 if (data != NULL) OPENSSL_free(data);
115 if (r->data != NULL) OPENSSL_free(r->data); 118 if (r != NULL) OPENSSL_free(r);
116 OPENSSL_free(r);
117 }
118 return(NULL); 119 return(NULL);
119 } 120 }
120 121
diff --git a/src/lib/libcrypto/objects/obj_mac.num b/src/lib/libcrypto/objects/obj_mac.num
index e3f56bc52c..8c50aac27f 100644
--- a/src/lib/libcrypto/objects/obj_mac.num
+++ b/src/lib/libcrypto/objects/obj_mac.num
@@ -856,3 +856,37 @@ hmac 855
856LocalKeySet 856 856LocalKeySet 856
857freshest_crl 857 857freshest_crl 857
858id_on_permanentIdentifier 858 858id_on_permanentIdentifier 858
859searchGuide 859
860businessCategory 860
861postalAddress 861
862postOfficeBox 862
863physicalDeliveryOfficeName 863
864telephoneNumber 864
865telexNumber 865
866teletexTerminalIdentifier 866
867facsimileTelephoneNumber 867
868x121Address 868
869internationaliSDNNumber 869
870registeredAddress 870
871destinationIndicator 871
872preferredDeliveryMethod 872
873presentationAddress 873
874supportedApplicationContext 874
875member 875
876owner 876
877roleOccupant 877
878seeAlso 878
879userPassword 879
880userCertificate 880
881cACertificate 881
882authorityRevocationList 882
883certificateRevocationList 883
884crossCertificatePair 884
885enhancedSearchGuide 885
886protocolInformation 886
887distinguishedName 887
888uniqueMember 888
889houseIdentifier 889
890supportedAlgorithms 890
891deltaRevocationList 891
892dmdName 892
diff --git a/src/lib/libcrypto/objects/objects.h b/src/lib/libcrypto/objects/objects.h
index 7242f76fb0..bd0ee52feb 100644
--- a/src/lib/libcrypto/objects/objects.h
+++ b/src/lib/libcrypto/objects/objects.h
@@ -1011,10 +1011,91 @@ int OBJ_txt2nid(const char *s);
1011int OBJ_ln2nid(const char *s); 1011int OBJ_ln2nid(const char *s);
1012int OBJ_sn2nid(const char *s); 1012int OBJ_sn2nid(const char *s);
1013int OBJ_cmp(const ASN1_OBJECT *a,const ASN1_OBJECT *b); 1013int OBJ_cmp(const ASN1_OBJECT *a,const ASN1_OBJECT *b);
1014const char * OBJ_bsearch(const char *key,const char *base,int num,int size, 1014const void * OBJ_bsearch_(const void *key,const void *base,int num,int size,
1015 int (*cmp)(const void *, const void *)); 1015 int (*cmp)(const void *, const void *));
1016const char * OBJ_bsearch_ex(const char *key,const char *base,int num, 1016const void * OBJ_bsearch_ex_(const void *key,const void *base,int num,
1017 int size, int (*cmp)(const void *, const void *), int flags); 1017 int size,
1018 int (*cmp)(const void *, const void *),
1019 int flags);
1020
1021#define _DECLARE_OBJ_BSEARCH_CMP_FN(scope, type1, type2, nm) \
1022 static int nm##_cmp_BSEARCH_CMP_FN(const void *, const void *); \
1023 static int nm##_cmp(type1 const *, type2 const *); \
1024 scope type2 * OBJ_bsearch_##nm(type1 *key, type2 const *base, int num)
1025
1026#define DECLARE_OBJ_BSEARCH_CMP_FN(type1, type2, cmp) \
1027 _DECLARE_OBJ_BSEARCH_CMP_FN(static, type1, type2, cmp)
1028#define DECLARE_OBJ_BSEARCH_GLOBAL_CMP_FN(type1, type2, nm) \
1029 type2 * OBJ_bsearch_##nm(type1 *key, type2 const *base, int num)
1030
1031/*
1032 * Unsolved problem: if a type is actually a pointer type, like
1033 * nid_triple is, then its impossible to get a const where you need
1034 * it. Consider:
1035 *
1036 * typedef int nid_triple[3];
1037 * const void *a_;
1038 * const nid_triple const *a = a_;
1039 *
1040 * The assignement discards a const because what you really want is:
1041 *
1042 * const int const * const *a = a_;
1043 *
1044 * But if you do that, you lose the fact that a is an array of 3 ints,
1045 * which breaks comparison functions.
1046 *
1047 * Thus we end up having to cast, sadly, or unpack the
1048 * declarations. Or, as I finally did in this case, delcare nid_triple
1049 * to be a struct, which it should have been in the first place.
1050 *
1051 * Ben, August 2008.
1052 *
1053 * Also, strictly speaking not all types need be const, but handling
1054 * the non-constness means a lot of complication, and in practice
1055 * comparison routines do always not touch their arguments.
1056 */
1057
1058#define IMPLEMENT_OBJ_BSEARCH_CMP_FN(type1, type2, nm) \
1059 static int nm##_cmp_BSEARCH_CMP_FN(const void *a_, const void *b_) \
1060 { \
1061 type1 const *a = a_; \
1062 type2 const *b = b_; \
1063 return nm##_cmp(a,b); \
1064 } \
1065 static type2 *OBJ_bsearch_##nm(type1 *key, type2 const *base, int num) \
1066 { \
1067 return (type2 *)OBJ_bsearch_(key, base, num, sizeof(type2), \
1068 nm##_cmp_BSEARCH_CMP_FN); \
1069 } \
1070 extern void dummy_prototype(void)
1071
1072#define IMPLEMENT_OBJ_BSEARCH_GLOBAL_CMP_FN(type1, type2, nm) \
1073 static int nm##_cmp_BSEARCH_CMP_FN(const void *a_, const void *b_) \
1074 { \
1075 type1 const *a = a_; \
1076 type2 const *b = b_; \
1077 return nm##_cmp(a,b); \
1078 } \
1079 type2 *OBJ_bsearch_##nm(type1 *key, type2 const *base, int num) \
1080 { \
1081 return (type2 *)OBJ_bsearch_(key, base, num, sizeof(type2), \
1082 nm##_cmp_BSEARCH_CMP_FN); \
1083 } \
1084 extern void dummy_prototype(void)
1085
1086#define OBJ_bsearch(type1,key,type2,base,num,cmp) \
1087 ((type2 *)OBJ_bsearch_(CHECKED_PTR_OF(type1,key),CHECKED_PTR_OF(type2,base), \
1088 num,sizeof(type2), \
1089 ((void)CHECKED_PTR_OF(type1,cmp##_type_1), \
1090 (void)CHECKED_PTR_OF(type2,cmp##_type_2), \
1091 cmp##_BSEARCH_CMP_FN)))
1092
1093#define OBJ_bsearch_ex(type1,key,type2,base,num,cmp,flags) \
1094 ((type2 *)OBJ_bsearch_ex_(CHECKED_PTR_OF(type1,key),CHECKED_PTR_OF(type2,base), \
1095 num,sizeof(type2), \
1096 ((void)CHECKED_PTR_OF(type1,cmp##_type_1), \
1097 (void)type_2=CHECKED_PTR_OF(type2,cmp##_type_2), \
1098 cmp##_BSEARCH_CMP_FN)),flags)
1018 1099
1019int OBJ_new_nid(int num); 1100int OBJ_new_nid(int num);
1020int OBJ_add_object(const ASN1_OBJECT *obj); 1101int OBJ_add_object(const ASN1_OBJECT *obj);
@@ -1022,6 +1103,14 @@ int OBJ_create(const char *oid,const char *sn,const char *ln);
1022void OBJ_cleanup(void ); 1103void OBJ_cleanup(void );
1023int OBJ_create_objects(BIO *in); 1104int OBJ_create_objects(BIO *in);
1024 1105
1106int OBJ_find_sigid_algs(int signid, int *pdig_nid, int *ppkey_nid);
1107int OBJ_find_sigid_by_algs(int *psignid, int dig_nid, int pkey_nid);
1108int OBJ_add_sigid(int signid, int dig_id, int pkey_id);
1109void OBJ_sigid_free(void);
1110
1111extern int obj_cleanup_defer;
1112void check_defer(int nid);
1113
1025/* BEGIN ERROR CODES */ 1114/* BEGIN ERROR CODES */
1026/* The following lines are auto generated by the script mkerr.pl. Any changes 1115/* The following lines are auto generated by the script mkerr.pl. Any changes
1027 * made after this point may be overwritten when the script is next run. 1116 * made after this point may be overwritten when the script is next run.
diff --git a/src/lib/libcrypto/objects/objects.pl b/src/lib/libcrypto/objects/objects.pl
index 76bb8da677..d2bf659d88 100644
--- a/src/lib/libcrypto/objects/objects.pl
+++ b/src/lib/libcrypto/objects/objects.pl
@@ -14,6 +14,8 @@ while(<NUMIN>)
14 $Cname =~ s/^X//; 14 $Cname =~ s/^X//;
15 if (defined($nidn{$mynum})) 15 if (defined($nidn{$mynum}))
16 { die "$ARGV[1]:$o:There's already an object with NID ",$mynum," on line ",$order{$mynum},"\n"; } 16 { die "$ARGV[1]:$o:There's already an object with NID ",$mynum," on line ",$order{$mynum},"\n"; }
17 if (defined($nid{$Cname}))
18 { die "$ARGV[1]:$o:There's already an object with name ",$Cname," on line ",$order{$nid{$Cname}},"\n"; }
17 $nid{$Cname} = $mynum; 19 $nid{$Cname} = $mynum;
18 $nidn{$mynum} = $Cname; 20 $nidn{$mynum} = $Cname;
19 $order{$mynum} = $o; 21 $order{$mynum} = $o;
@@ -102,6 +104,7 @@ while (<IN>)
102 $max_nid++; 104 $max_nid++;
103 $nid{$Cname} = $max_nid; 105 $nid{$Cname} = $max_nid;
104 $nidn{$max_nid} = $Cname; 106 $nidn{$max_nid} = $Cname;
107print STDERR "Added OID $Cname\n";
105 } 108 }
106 $Cname=""; 109 $Cname="";
107 } 110 }
diff --git a/src/lib/libcrypto/objects/objects.txt b/src/lib/libcrypto/objects/objects.txt
index a6a811b8e7..e61fe60cbf 100644
--- a/src/lib/libcrypto/objects/objects.txt
+++ b/src/lib/libcrypto/objects/objects.txt
@@ -20,7 +20,7 @@ identified-organization 132 : certicom-arc
20joint-iso-itu-t 23 : international-organizations : International Organizations 20joint-iso-itu-t 23 : international-organizations : International Organizations
21 21
22international-organizations 43 : wap 22international-organizations 43 : wap
23wap 13 : wap-wsg 23wap 1 : wap-wsg
24 24
25joint-iso-itu-t 5 1 5 : selected-attribute-types : Selected Attribute Types 25joint-iso-itu-t 5 1 5 : selected-attribute-types : Selected Attribute Types
26 26
@@ -664,18 +664,52 @@ X509 5 : : serialNumber
664X509 6 : C : countryName 664X509 6 : C : countryName
665X509 7 : L : localityName 665X509 7 : L : localityName
666X509 8 : ST : stateOrProvinceName 666X509 8 : ST : stateOrProvinceName
667X509 9 : : streetAddress 667X509 9 : street : streetAddress
668X509 10 : O : organizationName 668X509 10 : O : organizationName
669X509 11 : OU : organizationalUnitName 669X509 11 : OU : organizationalUnitName
670X509 12 : : title 670X509 12 : title : title
671X509 13 : : description 671X509 13 : : description
672X509 17 : : postalCode 672X509 14 : : searchGuide
673X509 15 : : businessCategory
674X509 16 : : postalAddress
675X509 17 : : postalCode
676X509 18 : : postOfficeBox
677X509 19 : : physicalDeliveryOfficeName
678X509 20 : : telephoneNumber
679X509 21 : : telexNumber
680X509 22 : : teletexTerminalIdentifier
681X509 23 : : facsimileTelephoneNumber
682X509 24 : : x121Address
683X509 25 : : internationaliSDNNumber
684X509 26 : : registeredAddress
685X509 27 : : destinationIndicator
686X509 28 : : preferredDeliveryMethod
687X509 29 : : presentationAddress
688X509 30 : : supportedApplicationContext
689X509 31 : member :
690X509 32 : owner :
691X509 33 : : roleOccupant
692X509 34 : seeAlso :
693X509 35 : : userPassword
694X509 36 : : userCertificate
695X509 37 : : cACertificate
696X509 38 : : authorityRevocationList
697X509 39 : : certificateRevocationList
698X509 40 : : crossCertificatePair
673X509 41 : name : name 699X509 41 : name : name
674X509 42 : GN : givenName 700X509 42 : GN : givenName
675X509 43 : : initials 701X509 43 : initials : initials
676X509 44 : : generationQualifier 702X509 44 : : generationQualifier
677X509 45 : : x500UniqueIdentifier 703X509 45 : : x500UniqueIdentifier
678X509 46 : dnQualifier : dnQualifier 704X509 46 : dnQualifier : dnQualifier
705X509 47 : : enhancedSearchGuide
706X509 48 : : protocolInformation
707X509 49 : : distinguishedName
708X509 50 : : uniqueMember
709X509 51 : : houseIdentifier
710X509 52 : : supportedAlgorithms
711X509 53 : : deltaRevocationList
712X509 54 : dmdName :
679X509 65 : : pseudonym 713X509 65 : : pseudonym
680X509 72 : role : role 714X509 72 : role : role
681 715
diff --git a/src/lib/libcrypto/ocsp/Makefile.ssl b/src/lib/libcrypto/ocsp/Makefile.ssl
deleted file mode 100644
index 02477be538..0000000000
--- a/src/lib/libcrypto/ocsp/Makefile.ssl
+++ /dev/null
@@ -1,293 +0,0 @@
1#
2# OpenSSL/ocsp/Makefile.ssl
3#
4
5DIR= ocsp
6TOP= ../..
7CC= cc
8INCLUDES= -I.. -I$(TOP) -I../../include
9CFLAG=-g
10INSTALL_PREFIX=
11OPENSSLDIR= /usr/local/ssl
12INSTALLTOP=/usr/local/ssl
13MAKE= make -f Makefile.ssl
14MAKEDEPPROG= makedepend
15MAKEDEPEND= $(TOP)/util/domd $(TOP) -MD $(MAKEDEPPROG)
16MAKEFILE= Makefile.ssl
17AR= ar r
18
19CFLAGS= $(INCLUDES) $(CFLAG)
20
21GENERAL=Makefile README
22TEST=
23APPS=
24
25LIB=$(TOP)/libcrypto.a
26LIBSRC= ocsp_asn.c ocsp_ext.c ocsp_ht.c ocsp_lib.c ocsp_cl.c \
27 ocsp_srv.c ocsp_prn.c ocsp_vfy.c ocsp_err.c
28
29LIBOBJ= ocsp_asn.o ocsp_ext.o ocsp_ht.o ocsp_lib.o ocsp_cl.o \
30 ocsp_srv.o ocsp_prn.o ocsp_vfy.o ocsp_err.o
31
32SRC= $(LIBSRC)
33
34EXHEADER= ocsp.h
35HEADER= $(EXHEADER)
36
37ALL= $(GENERAL) $(SRC) $(HEADER)
38
39top:
40 (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all)
41
42all: lib
43
44lib: $(LIBOBJ)
45 $(AR) $(LIB) $(LIBOBJ)
46 $(RANLIB) $(LIB) || echo Never mind.
47 @touch lib
48
49files:
50 $(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO
51
52links:
53 @sh $(TOP)/util/point.sh Makefile.ssl Makefile ;
54 @$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER)
55 @$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST)
56 @$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS)
57
58install:
59 @for i in $(EXHEADER) ; \
60 do \
61 (cp $$i $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i; \
62 chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i ); \
63 done;
64
65tags:
66 ctags $(SRC)
67
68tests:
69
70lint:
71 lint -DLINT $(INCLUDES) $(SRC)>fluff
72
73depend:
74 $(MAKEDEPEND) -- $(CFLAG) $(INCLUDES) $(DEPFLAG) -- $(LIBSRC)
75
76dclean:
77 $(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
78 mv -f Makefile.new $(MAKEFILE)
79
80clean:
81 rm -f *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff
82
83# DO NOT DELETE THIS LINE -- make depend depends on it.
84
85ocsp_asn.o: ../../include/openssl/aes.h ../../include/openssl/asn1.h
86ocsp_asn.o: ../../include/openssl/asn1t.h ../../include/openssl/bio.h
87ocsp_asn.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
88ocsp_asn.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
89ocsp_asn.o: ../../include/openssl/conf.h ../../include/openssl/crypto.h
90ocsp_asn.o: ../../include/openssl/des.h ../../include/openssl/des_old.h
91ocsp_asn.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
92ocsp_asn.o: ../../include/openssl/e_os2.h ../../include/openssl/evp.h
93ocsp_asn.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h
94ocsp_asn.o: ../../include/openssl/md2.h ../../include/openssl/md4.h
95ocsp_asn.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
96ocsp_asn.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
97ocsp_asn.o: ../../include/openssl/ocsp.h ../../include/openssl/opensslconf.h
98ocsp_asn.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
99ocsp_asn.o: ../../include/openssl/pkcs7.h ../../include/openssl/rc2.h
100ocsp_asn.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
101ocsp_asn.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
102ocsp_asn.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
103ocsp_asn.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
104ocsp_asn.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
105ocsp_asn.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
106ocsp_asn.o: ../../include/openssl/x509v3.h ocsp_asn.c
107ocsp_cl.o: ../../e_os.h ../../include/openssl/aes.h
108ocsp_cl.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
109ocsp_cl.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
110ocsp_cl.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
111ocsp_cl.o: ../../include/openssl/conf.h ../../include/openssl/crypto.h
112ocsp_cl.o: ../../include/openssl/des.h ../../include/openssl/des_old.h
113ocsp_cl.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
114ocsp_cl.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
115ocsp_cl.o: ../../include/openssl/evp.h ../../include/openssl/idea.h
116ocsp_cl.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h
117ocsp_cl.o: ../../include/openssl/md4.h ../../include/openssl/md5.h
118ocsp_cl.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h
119ocsp_cl.o: ../../include/openssl/objects.h ../../include/openssl/ocsp.h
120ocsp_cl.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
121ocsp_cl.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pem.h
122ocsp_cl.o: ../../include/openssl/pem2.h ../../include/openssl/pkcs7.h
123ocsp_cl.o: ../../include/openssl/rand.h ../../include/openssl/rc2.h
124ocsp_cl.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
125ocsp_cl.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
126ocsp_cl.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
127ocsp_cl.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
128ocsp_cl.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
129ocsp_cl.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
130ocsp_cl.o: ../../include/openssl/x509v3.h ../cryptlib.h ocsp_cl.c
131ocsp_err.o: ../../include/openssl/aes.h ../../include/openssl/asn1.h
132ocsp_err.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h
133ocsp_err.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
134ocsp_err.o: ../../include/openssl/cast.h ../../include/openssl/conf.h
135ocsp_err.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
136ocsp_err.o: ../../include/openssl/des_old.h ../../include/openssl/dh.h
137ocsp_err.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
138ocsp_err.o: ../../include/openssl/err.h ../../include/openssl/evp.h
139ocsp_err.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h
140ocsp_err.o: ../../include/openssl/md2.h ../../include/openssl/md4.h
141ocsp_err.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
142ocsp_err.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
143ocsp_err.o: ../../include/openssl/ocsp.h ../../include/openssl/opensslconf.h
144ocsp_err.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
145ocsp_err.o: ../../include/openssl/pkcs7.h ../../include/openssl/rc2.h
146ocsp_err.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
147ocsp_err.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
148ocsp_err.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
149ocsp_err.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
150ocsp_err.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
151ocsp_err.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
152ocsp_err.o: ../../include/openssl/x509v3.h ocsp_err.c
153ocsp_ext.o: ../../e_os.h ../../include/openssl/aes.h
154ocsp_ext.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
155ocsp_ext.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
156ocsp_ext.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
157ocsp_ext.o: ../../include/openssl/conf.h ../../include/openssl/crypto.h
158ocsp_ext.o: ../../include/openssl/des.h ../../include/openssl/des_old.h
159ocsp_ext.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
160ocsp_ext.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
161ocsp_ext.o: ../../include/openssl/evp.h ../../include/openssl/idea.h
162ocsp_ext.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h
163ocsp_ext.o: ../../include/openssl/md4.h ../../include/openssl/md5.h
164ocsp_ext.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h
165ocsp_ext.o: ../../include/openssl/objects.h ../../include/openssl/ocsp.h
166ocsp_ext.o: ../../include/openssl/opensslconf.h
167ocsp_ext.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
168ocsp_ext.o: ../../include/openssl/pkcs7.h ../../include/openssl/rand.h
169ocsp_ext.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h
170ocsp_ext.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h
171ocsp_ext.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
172ocsp_ext.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
173ocsp_ext.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
174ocsp_ext.o: ../../include/openssl/ui_compat.h ../../include/openssl/x509.h
175ocsp_ext.o: ../../include/openssl/x509_vfy.h ../../include/openssl/x509v3.h
176ocsp_ext.o: ../cryptlib.h ocsp_ext.c
177ocsp_ht.o: ../../include/openssl/aes.h ../../include/openssl/asn1.h
178ocsp_ht.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h
179ocsp_ht.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
180ocsp_ht.o: ../../include/openssl/cast.h ../../include/openssl/conf.h
181ocsp_ht.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
182ocsp_ht.o: ../../include/openssl/des_old.h ../../include/openssl/dh.h
183ocsp_ht.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
184ocsp_ht.o: ../../include/openssl/err.h ../../include/openssl/evp.h
185ocsp_ht.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h
186ocsp_ht.o: ../../include/openssl/md2.h ../../include/openssl/md4.h
187ocsp_ht.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
188ocsp_ht.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
189ocsp_ht.o: ../../include/openssl/ocsp.h ../../include/openssl/opensslconf.h
190ocsp_ht.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
191ocsp_ht.o: ../../include/openssl/pkcs7.h ../../include/openssl/rc2.h
192ocsp_ht.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
193ocsp_ht.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
194ocsp_ht.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
195ocsp_ht.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
196ocsp_ht.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
197ocsp_ht.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
198ocsp_ht.o: ../../include/openssl/x509v3.h ocsp_ht.c
199ocsp_lib.o: ../../e_os.h ../../include/openssl/aes.h
200ocsp_lib.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
201ocsp_lib.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
202ocsp_lib.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
203ocsp_lib.o: ../../include/openssl/conf.h ../../include/openssl/crypto.h
204ocsp_lib.o: ../../include/openssl/des.h ../../include/openssl/des_old.h
205ocsp_lib.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
206ocsp_lib.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
207ocsp_lib.o: ../../include/openssl/evp.h ../../include/openssl/idea.h
208ocsp_lib.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h
209ocsp_lib.o: ../../include/openssl/md4.h ../../include/openssl/md5.h
210ocsp_lib.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h
211ocsp_lib.o: ../../include/openssl/objects.h ../../include/openssl/ocsp.h
212ocsp_lib.o: ../../include/openssl/opensslconf.h
213ocsp_lib.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
214ocsp_lib.o: ../../include/openssl/pem.h ../../include/openssl/pem2.h
215ocsp_lib.o: ../../include/openssl/pkcs7.h ../../include/openssl/rand.h
216ocsp_lib.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h
217ocsp_lib.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h
218ocsp_lib.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
219ocsp_lib.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
220ocsp_lib.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
221ocsp_lib.o: ../../include/openssl/ui_compat.h ../../include/openssl/x509.h
222ocsp_lib.o: ../../include/openssl/x509_vfy.h ../../include/openssl/x509v3.h
223ocsp_lib.o: ../cryptlib.h ocsp_lib.c
224ocsp_prn.o: ../../include/openssl/aes.h ../../include/openssl/asn1.h
225ocsp_prn.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h
226ocsp_prn.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
227ocsp_prn.o: ../../include/openssl/cast.h ../../include/openssl/conf.h
228ocsp_prn.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
229ocsp_prn.o: ../../include/openssl/des_old.h ../../include/openssl/dh.h
230ocsp_prn.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
231ocsp_prn.o: ../../include/openssl/err.h ../../include/openssl/evp.h
232ocsp_prn.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h
233ocsp_prn.o: ../../include/openssl/md2.h ../../include/openssl/md4.h
234ocsp_prn.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
235ocsp_prn.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
236ocsp_prn.o: ../../include/openssl/ocsp.h ../../include/openssl/opensslconf.h
237ocsp_prn.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
238ocsp_prn.o: ../../include/openssl/pem.h ../../include/openssl/pem2.h
239ocsp_prn.o: ../../include/openssl/pkcs7.h ../../include/openssl/rc2.h
240ocsp_prn.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
241ocsp_prn.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
242ocsp_prn.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
243ocsp_prn.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
244ocsp_prn.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
245ocsp_prn.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
246ocsp_prn.o: ../../include/openssl/x509v3.h ocsp_prn.c
247ocsp_srv.o: ../../e_os.h ../../include/openssl/aes.h
248ocsp_srv.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
249ocsp_srv.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
250ocsp_srv.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
251ocsp_srv.o: ../../include/openssl/conf.h ../../include/openssl/crypto.h
252ocsp_srv.o: ../../include/openssl/des.h ../../include/openssl/des_old.h
253ocsp_srv.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
254ocsp_srv.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
255ocsp_srv.o: ../../include/openssl/evp.h ../../include/openssl/idea.h
256ocsp_srv.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h
257ocsp_srv.o: ../../include/openssl/md4.h ../../include/openssl/md5.h
258ocsp_srv.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h
259ocsp_srv.o: ../../include/openssl/objects.h ../../include/openssl/ocsp.h
260ocsp_srv.o: ../../include/openssl/opensslconf.h
261ocsp_srv.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
262ocsp_srv.o: ../../include/openssl/pem.h ../../include/openssl/pem2.h
263ocsp_srv.o: ../../include/openssl/pkcs7.h ../../include/openssl/rand.h
264ocsp_srv.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h
265ocsp_srv.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h
266ocsp_srv.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
267ocsp_srv.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
268ocsp_srv.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
269ocsp_srv.o: ../../include/openssl/ui_compat.h ../../include/openssl/x509.h
270ocsp_srv.o: ../../include/openssl/x509_vfy.h ../../include/openssl/x509v3.h
271ocsp_srv.o: ../cryptlib.h ocsp_srv.c
272ocsp_vfy.o: ../../include/openssl/aes.h ../../include/openssl/asn1.h
273ocsp_vfy.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h
274ocsp_vfy.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
275ocsp_vfy.o: ../../include/openssl/cast.h ../../include/openssl/conf.h
276ocsp_vfy.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
277ocsp_vfy.o: ../../include/openssl/des_old.h ../../include/openssl/dh.h
278ocsp_vfy.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
279ocsp_vfy.o: ../../include/openssl/err.h ../../include/openssl/evp.h
280ocsp_vfy.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h
281ocsp_vfy.o: ../../include/openssl/md2.h ../../include/openssl/md4.h
282ocsp_vfy.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
283ocsp_vfy.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
284ocsp_vfy.o: ../../include/openssl/ocsp.h ../../include/openssl/opensslconf.h
285ocsp_vfy.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
286ocsp_vfy.o: ../../include/openssl/pkcs7.h ../../include/openssl/rc2.h
287ocsp_vfy.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
288ocsp_vfy.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
289ocsp_vfy.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
290ocsp_vfy.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
291ocsp_vfy.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
292ocsp_vfy.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
293ocsp_vfy.o: ../../include/openssl/x509v3.h ocsp_vfy.c
diff --git a/src/lib/libcrypto/ocsp/ocsp.h b/src/lib/libcrypto/ocsp/ocsp.h
index a0577a717e..31e45744ba 100644
--- a/src/lib/libcrypto/ocsp/ocsp.h
+++ b/src/lib/libcrypto/ocsp/ocsp.h
@@ -64,6 +64,7 @@
64#ifndef HEADER_OCSP_H 64#ifndef HEADER_OCSP_H
65#define HEADER_OCSP_H 65#define HEADER_OCSP_H
66 66
67#include <openssl/ossl_typ.h>
67#include <openssl/x509.h> 68#include <openssl/x509.h>
68#include <openssl/x509v3.h> 69#include <openssl/x509v3.h>
69#include <openssl/safestack.h> 70#include <openssl/safestack.h>
@@ -394,17 +395,20 @@ typedef struct ocsp_service_locator_st
394#define ASN1_BIT_STRING_digest(data,type,md,len) \ 395#define ASN1_BIT_STRING_digest(data,type,md,len) \
395 ASN1_item_digest(ASN1_ITEM_rptr(ASN1_BIT_STRING),type,data,md,len) 396 ASN1_item_digest(ASN1_ITEM_rptr(ASN1_BIT_STRING),type,data,md,len)
396 397
397#define OCSP_CERTID_dup(cid) ASN1_dup_of(OCSP_CERTID,i2d_OCSP_CERTID,d2i_OCSP_CERTID,cid)
398
399#define OCSP_CERTSTATUS_dup(cs)\ 398#define OCSP_CERTSTATUS_dup(cs)\
400 (OCSP_CERTSTATUS*)ASN1_dup((int(*)())i2d_OCSP_CERTSTATUS,\ 399 (OCSP_CERTSTATUS*)ASN1_dup((int(*)())i2d_OCSP_CERTSTATUS,\
401 (char *(*)())d2i_OCSP_CERTSTATUS,(char *)(cs)) 400 (char *(*)())d2i_OCSP_CERTSTATUS,(char *)(cs))
402 401
402OCSP_CERTID *OCSP_CERTID_dup(OCSP_CERTID *id);
403
403OCSP_RESPONSE *OCSP_sendreq_bio(BIO *b, char *path, OCSP_REQUEST *req); 404OCSP_RESPONSE *OCSP_sendreq_bio(BIO *b, char *path, OCSP_REQUEST *req);
404OCSP_REQ_CTX *OCSP_sendreq_new(BIO *io, char *path, OCSP_REQUEST *req, 405OCSP_REQ_CTX *OCSP_sendreq_new(BIO *io, char *path, OCSP_REQUEST *req,
405 int maxline); 406 int maxline);
406int OCSP_sendreq_nbio(OCSP_RESPONSE **presp, OCSP_REQ_CTX *rctx); 407int OCSP_sendreq_nbio(OCSP_RESPONSE **presp, OCSP_REQ_CTX *rctx);
407void OCSP_REQ_CTX_free(OCSP_REQ_CTX *rctx); 408void OCSP_REQ_CTX_free(OCSP_REQ_CTX *rctx);
409int OCSP_REQ_CTX_set1_req(OCSP_REQ_CTX *rctx, OCSP_REQUEST *req);
410int OCSP_REQ_CTX_add1_header(OCSP_REQ_CTX *rctx,
411 const char *name, const char *value);
408 412
409OCSP_CERTID *OCSP_cert_to_id(const EVP_MD *dgst, X509 *subject, X509 *issuer); 413OCSP_CERTID *OCSP_cert_to_id(const EVP_MD *dgst, X509 *subject, X509 *issuer);
410 414
@@ -474,11 +478,6 @@ int OCSP_basic_sign(OCSP_BASICRESP *brsp,
474 X509 *signer, EVP_PKEY *key, const EVP_MD *dgst, 478 X509 *signer, EVP_PKEY *key, const EVP_MD *dgst,
475 STACK_OF(X509) *certs, unsigned long flags); 479 STACK_OF(X509) *certs, unsigned long flags);
476 480
477ASN1_STRING *ASN1_STRING_encode(ASN1_STRING *s, i2d_of_void *i2d,
478 void *data, STACK_OF(ASN1_OBJECT) *sk);
479#define ASN1_STRING_encode_of(type,s,i2d,data,sk) \
480 ASN1_STRING_encode(s, CHECKED_I2D_OF(type, i2d), data, sk)
481
482X509_EXTENSION *OCSP_crlID_new(char *url, long *n, char *tim); 481X509_EXTENSION *OCSP_crlID_new(char *url, long *n, char *tim);
483 482
484X509_EXTENSION *OCSP_accept_responses_new(char **oids); 483X509_EXTENSION *OCSP_accept_responses_new(char **oids);
@@ -547,9 +546,9 @@ DECLARE_ASN1_FUNCTIONS(OCSP_REQINFO)
547DECLARE_ASN1_FUNCTIONS(OCSP_CRLID) 546DECLARE_ASN1_FUNCTIONS(OCSP_CRLID)
548DECLARE_ASN1_FUNCTIONS(OCSP_SERVICELOC) 547DECLARE_ASN1_FUNCTIONS(OCSP_SERVICELOC)
549 548
550char *OCSP_response_status_str(long s); 549const char *OCSP_response_status_str(long s);
551char *OCSP_cert_status_str(long s); 550const char *OCSP_cert_status_str(long s);
552char *OCSP_crl_reason_str(long s); 551const char *OCSP_crl_reason_str(long s);
553 552
554int OCSP_REQUEST_print(BIO *bp, OCSP_REQUEST* a, unsigned long flags); 553int OCSP_REQUEST_print(BIO *bp, OCSP_REQUEST* a, unsigned long flags);
555int OCSP_RESPONSE_print(BIO *bp, OCSP_RESPONSE* o, unsigned long flags); 554int OCSP_RESPONSE_print(BIO *bp, OCSP_RESPONSE* o, unsigned long flags);
@@ -582,7 +581,8 @@ void ERR_load_OCSP_strings(void);
582#define OCSP_F_OCSP_REQUEST_VERIFY 116 581#define OCSP_F_OCSP_REQUEST_VERIFY 116
583#define OCSP_F_OCSP_RESPONSE_GET1_BASIC 111 582#define OCSP_F_OCSP_RESPONSE_GET1_BASIC 111
584#define OCSP_F_OCSP_SENDREQ_BIO 112 583#define OCSP_F_OCSP_SENDREQ_BIO 112
585#define OCSP_F_PARSE_HTTP_LINE1 117 584#define OCSP_F_OCSP_SENDREQ_NBIO 117
585#define OCSP_F_PARSE_HTTP_LINE1 118
586#define OCSP_F_REQUEST_VERIFY 113 586#define OCSP_F_REQUEST_VERIFY 113
587 587
588/* Reason codes. */ 588/* Reason codes. */
diff --git a/src/lib/libcrypto/ocsp/ocsp_cl.c b/src/lib/libcrypto/ocsp/ocsp_cl.c
index 17bab5fc59..9c14d9da27 100644
--- a/src/lib/libcrypto/ocsp/ocsp_cl.c
+++ b/src/lib/libcrypto/ocsp/ocsp_cl.c
@@ -155,7 +155,6 @@ int OCSP_request_sign(OCSP_REQUEST *req,
155 goto err; 155 goto err;
156 156
157 if (!(req->optionalSignature = sig = OCSP_SIGNATURE_new())) goto err; 157 if (!(req->optionalSignature = sig = OCSP_SIGNATURE_new())) goto err;
158 if (!dgst) dgst = EVP_sha1();
159 if (key) 158 if (key)
160 { 159 {
161 if (!X509_check_private_key(signer, key)) 160 if (!X509_check_private_key(signer, key))
diff --git a/src/lib/libcrypto/ocsp/ocsp_err.c b/src/lib/libcrypto/ocsp/ocsp_err.c
index d2f2e79f44..0cedcea682 100644
--- a/src/lib/libcrypto/ocsp/ocsp_err.c
+++ b/src/lib/libcrypto/ocsp/ocsp_err.c
@@ -1,6 +1,6 @@
1/* crypto/ocsp/ocsp_err.c */ 1/* crypto/ocsp/ocsp_err.c */
2/* ==================================================================== 2/* ====================================================================
3 * Copyright (c) 1999-2007 The OpenSSL Project. All rights reserved. 3 * Copyright (c) 1999-2006 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 OCSP_str_functs[]=
86{ERR_FUNC(OCSP_F_OCSP_REQUEST_VERIFY), "OCSP_request_verify"}, 86{ERR_FUNC(OCSP_F_OCSP_REQUEST_VERIFY), "OCSP_request_verify"},
87{ERR_FUNC(OCSP_F_OCSP_RESPONSE_GET1_BASIC), "OCSP_response_get1_basic"}, 87{ERR_FUNC(OCSP_F_OCSP_RESPONSE_GET1_BASIC), "OCSP_response_get1_basic"},
88{ERR_FUNC(OCSP_F_OCSP_SENDREQ_BIO), "OCSP_sendreq_bio"}, 88{ERR_FUNC(OCSP_F_OCSP_SENDREQ_BIO), "OCSP_sendreq_bio"},
89{ERR_FUNC(OCSP_F_OCSP_SENDREQ_NBIO), "OCSP_sendreq_nbio"},
89{ERR_FUNC(OCSP_F_PARSE_HTTP_LINE1), "PARSE_HTTP_LINE1"}, 90{ERR_FUNC(OCSP_F_PARSE_HTTP_LINE1), "PARSE_HTTP_LINE1"},
90{ERR_FUNC(OCSP_F_REQUEST_VERIFY), "REQUEST_VERIFY"}, 91{ERR_FUNC(OCSP_F_REQUEST_VERIFY), "REQUEST_VERIFY"},
91{0,NULL} 92{0,NULL}
diff --git a/src/lib/libcrypto/ocsp/ocsp_ext.c b/src/lib/libcrypto/ocsp/ocsp_ext.c
index 815cc29d58..ec884cb08f 100644
--- a/src/lib/libcrypto/ocsp/ocsp_ext.c
+++ b/src/lib/libcrypto/ocsp/ocsp_ext.c
@@ -264,7 +264,7 @@ int OCSP_SINGLERESP_add_ext(OCSP_SINGLERESP *x, X509_EXTENSION *ex, int loc)
264 } 264 }
265 265
266/* also CRL Entry Extensions */ 266/* also CRL Entry Extensions */
267 267#if 0
268ASN1_STRING *ASN1_STRING_encode(ASN1_STRING *s, i2d_of_void *i2d, 268ASN1_STRING *ASN1_STRING_encode(ASN1_STRING *s, i2d_of_void *i2d,
269 void *data, STACK_OF(ASN1_OBJECT) *sk) 269 void *data, STACK_OF(ASN1_OBJECT) *sk)
270 { 270 {
@@ -305,6 +305,7 @@ err:
305 if (b) OPENSSL_free(b); 305 if (b) OPENSSL_free(b);
306 return NULL; 306 return NULL;
307 } 307 }
308#endif
308 309
309/* Nonce handling functions */ 310/* Nonce handling functions */
310 311
@@ -442,17 +443,10 @@ X509_EXTENSION *OCSP_crlID_new(char *url, long *n, char *tim)
442 if (!(ASN1_GENERALIZEDTIME_set_string(cid->crlTime, tim))) 443 if (!(ASN1_GENERALIZEDTIME_set_string(cid->crlTime, tim)))
443 goto err; 444 goto err;
444 } 445 }
445 if (!(x = X509_EXTENSION_new())) goto err; 446 x = X509V3_EXT_i2d(NID_id_pkix_OCSP_CrlID, 0, cid);
446 if (!(x->object = OBJ_nid2obj(NID_id_pkix_OCSP_CrlID))) goto err;
447 if (!(ASN1_STRING_encode_of(OCSP_CRLID,x->value,i2d_OCSP_CRLID,cid,
448 NULL)))
449 goto err;
450 OCSP_CRLID_free(cid);
451 return x;
452err: 447err:
453 if (x) X509_EXTENSION_free(x);
454 if (cid) OCSP_CRLID_free(cid); 448 if (cid) OCSP_CRLID_free(cid);
455 return NULL; 449 return x;
456 } 450 }
457 451
458/* AcceptableResponses ::= SEQUENCE OF OBJECT IDENTIFIER */ 452/* AcceptableResponses ::= SEQUENCE OF OBJECT IDENTIFIER */
@@ -470,18 +464,10 @@ X509_EXTENSION *OCSP_accept_responses_new(char **oids)
470 sk_ASN1_OBJECT_push(sk, o); 464 sk_ASN1_OBJECT_push(sk, o);
471 oids++; 465 oids++;
472 } 466 }
473 if (!(x = X509_EXTENSION_new())) goto err; 467 x = X509V3_EXT_i2d(NID_id_pkix_OCSP_acceptableResponses, 0, sk);
474 if (!(x->object = OBJ_nid2obj(NID_id_pkix_OCSP_acceptableResponses)))
475 goto err;
476 if (!(ASN1_STRING_encode_of(ASN1_OBJECT,x->value,i2d_ASN1_OBJECT,NULL,
477 sk)))
478 goto err;
479 sk_ASN1_OBJECT_pop_free(sk, ASN1_OBJECT_free);
480 return x;
481err: 468err:
482 if (x) X509_EXTENSION_free(x);
483 if (sk) sk_ASN1_OBJECT_pop_free(sk, ASN1_OBJECT_free); 469 if (sk) sk_ASN1_OBJECT_pop_free(sk, ASN1_OBJECT_free);
484 return NULL; 470 return x;
485 } 471 }
486 472
487/* ArchiveCutoff ::= GeneralizedTime */ 473/* ArchiveCutoff ::= GeneralizedTime */
@@ -492,16 +478,10 @@ X509_EXTENSION *OCSP_archive_cutoff_new(char* tim)
492 478
493 if (!(gt = ASN1_GENERALIZEDTIME_new())) goto err; 479 if (!(gt = ASN1_GENERALIZEDTIME_new())) goto err;
494 if (!(ASN1_GENERALIZEDTIME_set_string(gt, tim))) goto err; 480 if (!(ASN1_GENERALIZEDTIME_set_string(gt, tim))) goto err;
495 if (!(x = X509_EXTENSION_new())) goto err; 481 x = X509V3_EXT_i2d(NID_id_pkix_OCSP_archiveCutoff, 0, gt);
496 if (!(x->object=OBJ_nid2obj(NID_id_pkix_OCSP_archiveCutoff)))goto err;
497 if (!(ASN1_STRING_encode_of(ASN1_GENERALIZEDTIME,x->value,
498 i2d_ASN1_GENERALIZEDTIME,gt,NULL))) goto err;
499 ASN1_GENERALIZEDTIME_free(gt);
500 return x;
501err: 482err:
502 if (gt) ASN1_GENERALIZEDTIME_free(gt); 483 if (gt) ASN1_GENERALIZEDTIME_free(gt);
503 if (x) X509_EXTENSION_free(x); 484 return x;
504 return NULL;
505 } 485 }
506 486
507/* per ACCESS_DESCRIPTION parameter are oids, of which there are currently 487/* per ACCESS_DESCRIPTION parameter are oids, of which there are currently
@@ -530,16 +510,9 @@ X509_EXTENSION *OCSP_url_svcloc_new(X509_NAME* issuer, char **urls)
530 if (!sk_ACCESS_DESCRIPTION_push(sloc->locator, ad)) goto err; 510 if (!sk_ACCESS_DESCRIPTION_push(sloc->locator, ad)) goto err;
531 urls++; 511 urls++;
532 } 512 }
533 if (!(x = X509_EXTENSION_new())) goto err; 513 x = X509V3_EXT_i2d(NID_id_pkix_OCSP_serviceLocator, 0, sloc);
534 if (!(x->object = OBJ_nid2obj(NID_id_pkix_OCSP_serviceLocator)))
535 goto err;
536 if (!(ASN1_STRING_encode_of(OCSP_SERVICELOC,x->value,
537 i2d_OCSP_SERVICELOC,sloc,NULL))) goto err;
538 OCSP_SERVICELOC_free(sloc);
539 return x;
540err: 514err:
541 if (x) X509_EXTENSION_free(x);
542 if (sloc) OCSP_SERVICELOC_free(sloc); 515 if (sloc) OCSP_SERVICELOC_free(sloc);
543 return NULL; 516 return x;
544 } 517 }
545 518
diff --git a/src/lib/libcrypto/ocsp/ocsp_ht.c b/src/lib/libcrypto/ocsp/ocsp_ht.c
index 6abb30b2c0..12bbfcffd1 100644
--- a/src/lib/libcrypto/ocsp/ocsp_ht.c
+++ b/src/lib/libcrypto/ocsp/ocsp_ht.c
@@ -118,39 +118,65 @@ void OCSP_REQ_CTX_free(OCSP_REQ_CTX *rctx)
118 OPENSSL_free(rctx); 118 OPENSSL_free(rctx);
119 } 119 }
120 120
121OCSP_REQ_CTX *OCSP_sendreq_new(BIO *io, char *path, OCSP_REQUEST *req, 121int OCSP_REQ_CTX_set1_req(OCSP_REQ_CTX *rctx, OCSP_REQUEST *req)
122 int maxline)
123 { 122 {
124 static char post_hdr[] = "POST %s HTTP/1.0\r\n" 123 static const char req_hdr[] =
125 "Content-Type: application/ocsp-request\r\n" 124 "Content-Type: application/ocsp-request\r\n"
126 "Content-Length: %d\r\n\r\n"; 125 "Content-Length: %d\r\n\r\n";
126 if (BIO_printf(rctx->mem, req_hdr, i2d_OCSP_REQUEST(req, NULL)) <= 0)
127 return 0;
128 if (i2d_OCSP_REQUEST_bio(rctx->mem, req) <= 0)
129 return 0;
130 rctx->state = OHS_ASN1_WRITE;
131 rctx->asn1_len = BIO_get_mem_data(rctx->mem, NULL);
132 return 1;
133 }
134
135int OCSP_REQ_CTX_add1_header(OCSP_REQ_CTX *rctx,
136 const char *name, const char *value)
137 {
138 if (!name)
139 return 0;
140 if (BIO_puts(rctx->mem, name) <= 0)
141 return 0;
142 if (value)
143 {
144 if (BIO_write(rctx->mem, ": ", 2) != 2)
145 return 0;
146 if (BIO_puts(rctx->mem, value) <= 0)
147 return 0;
148 }
149 if (BIO_write(rctx->mem, "\r\n", 2) != 2)
150 return 0;
151 return 1;
152 }
153
154OCSP_REQ_CTX *OCSP_sendreq_new(BIO *io, char *path, OCSP_REQUEST *req,
155 int maxline)
156 {
157 static const char post_hdr[] = "POST %s HTTP/1.0\r\n";
127 158
128 OCSP_REQ_CTX *rctx; 159 OCSP_REQ_CTX *rctx;
129 rctx = OPENSSL_malloc(sizeof(OCSP_REQ_CTX)); 160 rctx = OPENSSL_malloc(sizeof(OCSP_REQ_CTX));
130 rctx->state = OHS_FIRSTLINE; 161 rctx->state = OHS_ERROR;
131 rctx->mem = BIO_new(BIO_s_mem()); 162 rctx->mem = BIO_new(BIO_s_mem());
132 rctx->io = io; 163 rctx->io = io;
164 rctx->asn1_len = 0;
133 if (maxline > 0) 165 if (maxline > 0)
134 rctx->iobuflen = maxline; 166 rctx->iobuflen = maxline;
135 else 167 else
136 rctx->iobuflen = OCSP_MAX_LINE_LEN; 168 rctx->iobuflen = OCSP_MAX_LINE_LEN;
137 rctx->iobuf = OPENSSL_malloc(rctx->iobuflen); 169 rctx->iobuf = OPENSSL_malloc(rctx->iobuflen);
170 if (!rctx->iobuf)
171 return 0;
138 if (!path) 172 if (!path)
139 path = "/"; 173 path = "/";
140 174
141 if (BIO_printf(rctx->mem, post_hdr, path, 175 if (BIO_printf(rctx->mem, post_hdr, path) <= 0)
142 i2d_OCSP_REQUEST(req, NULL)) <= 0)
143 {
144 rctx->state = OHS_ERROR;
145 return 0; 176 return 0;
146 } 177
147 if (i2d_OCSP_REQUEST_bio(rctx->mem, req) <= 0) 178 if (req && !OCSP_REQ_CTX_set1_req(rctx, req))
148 {
149 rctx->state = OHS_ERROR;
150 return 0; 179 return 0;
151 }
152 rctx->state = OHS_ASN1_WRITE;
153 rctx->asn1_len = BIO_get_mem_data(rctx->mem, NULL);
154 180
155 return rctx; 181 return rctx;
156 } 182 }
diff --git a/src/lib/libcrypto/ocsp/ocsp_lib.c b/src/lib/libcrypto/ocsp/ocsp_lib.c
index 27450811d7..36905d76cd 100644
--- a/src/lib/libcrypto/ocsp/ocsp_lib.c
+++ b/src/lib/libcrypto/ocsp/ocsp_lib.c
@@ -69,6 +69,7 @@
69#include <openssl/pem.h> 69#include <openssl/pem.h>
70#include <openssl/x509v3.h> 70#include <openssl/x509v3.h>
71#include <openssl/ocsp.h> 71#include <openssl/ocsp.h>
72#include <openssl/asn1t.h>
72 73
73/* Convert a certificate and its issuer to an OCSP_CERTID */ 74/* Convert a certificate and its issuer to an OCSP_CERTID */
74 75
@@ -260,3 +261,5 @@ int OCSP_parse_url(char *url, char **phost, char **pport, char **ppath, int *pss
260 return 0; 261 return 0;
261 262
262 } 263 }
264
265IMPLEMENT_ASN1_DUP_FUNCTION(OCSP_CERTID)
diff --git a/src/lib/libcrypto/ocsp/ocsp_prn.c b/src/lib/libcrypto/ocsp/ocsp_prn.c
index 3dfb51c1e4..1695c9c4ad 100644
--- a/src/lib/libcrypto/ocsp/ocsp_prn.c
+++ b/src/lib/libcrypto/ocsp/ocsp_prn.c
@@ -85,21 +85,21 @@ static int ocsp_certid_print(BIO *bp, OCSP_CERTID* a, int indent)
85typedef struct 85typedef struct
86 { 86 {
87 long t; 87 long t;
88 char *m; 88 const char *m;
89 } OCSP_TBLSTR; 89 } OCSP_TBLSTR;
90 90
91static char *table2string(long s, OCSP_TBLSTR *ts, int len) 91static const char *table2string(long s, const OCSP_TBLSTR *ts, int len)
92{ 92{
93 OCSP_TBLSTR *p; 93 const OCSP_TBLSTR *p;
94 for (p=ts; p < ts + len; p++) 94 for (p=ts; p < ts + len; p++)
95 if (p->t == s) 95 if (p->t == s)
96 return p->m; 96 return p->m;
97 return "(UNKNOWN)"; 97 return "(UNKNOWN)";
98} 98}
99 99
100char *OCSP_response_status_str(long s) 100const char *OCSP_response_status_str(long s)
101 { 101 {
102 static OCSP_TBLSTR rstat_tbl[] = { 102 static const OCSP_TBLSTR rstat_tbl[] = {
103 { OCSP_RESPONSE_STATUS_SUCCESSFUL, "successful" }, 103 { OCSP_RESPONSE_STATUS_SUCCESSFUL, "successful" },
104 { OCSP_RESPONSE_STATUS_MALFORMEDREQUEST, "malformedrequest" }, 104 { OCSP_RESPONSE_STATUS_MALFORMEDREQUEST, "malformedrequest" },
105 { OCSP_RESPONSE_STATUS_INTERNALERROR, "internalerror" }, 105 { OCSP_RESPONSE_STATUS_INTERNALERROR, "internalerror" },
@@ -109,18 +109,18 @@ char *OCSP_response_status_str(long s)
109 return table2string(s, rstat_tbl, 6); 109 return table2string(s, rstat_tbl, 6);
110 } 110 }
111 111
112char *OCSP_cert_status_str(long s) 112const char *OCSP_cert_status_str(long s)
113 { 113 {
114 static OCSP_TBLSTR cstat_tbl[] = { 114 static const OCSP_TBLSTR cstat_tbl[] = {
115 { V_OCSP_CERTSTATUS_GOOD, "good" }, 115 { V_OCSP_CERTSTATUS_GOOD, "good" },
116 { V_OCSP_CERTSTATUS_REVOKED, "revoked" }, 116 { V_OCSP_CERTSTATUS_REVOKED, "revoked" },
117 { V_OCSP_CERTSTATUS_UNKNOWN, "unknown" } }; 117 { V_OCSP_CERTSTATUS_UNKNOWN, "unknown" } };
118 return table2string(s, cstat_tbl, 3); 118 return table2string(s, cstat_tbl, 3);
119 } 119 }
120 120
121char *OCSP_crl_reason_str(long s) 121const char *OCSP_crl_reason_str(long s)
122 { 122 {
123 OCSP_TBLSTR reason_tbl[] = { 123 static const OCSP_TBLSTR reason_tbl[] = {
124 { OCSP_REVOKED_STATUS_UNSPECIFIED, "unspecified" }, 124 { OCSP_REVOKED_STATUS_UNSPECIFIED, "unspecified" },
125 { OCSP_REVOKED_STATUS_KEYCOMPROMISE, "keyCompromise" }, 125 { OCSP_REVOKED_STATUS_KEYCOMPROMISE, "keyCompromise" },
126 { OCSP_REVOKED_STATUS_CACOMPROMISE, "cACompromise" }, 126 { OCSP_REVOKED_STATUS_CACOMPROMISE, "cACompromise" },
@@ -266,15 +266,16 @@ int OCSP_RESPONSE_print(BIO *bp, OCSP_RESPONSE* o, unsigned long flags)
266 if (!ASN1_GENERALIZEDTIME_print(bp,single->nextUpdate)) 266 if (!ASN1_GENERALIZEDTIME_print(bp,single->nextUpdate))
267 goto err; 267 goto err;
268 } 268 }
269 if (!BIO_write(bp,"\n",1)) goto err; 269 if (BIO_write(bp,"\n",1) <= 0) goto err;
270 if (!X509V3_extensions_print(bp, 270 if (!X509V3_extensions_print(bp,
271 "Response Single Extensions", 271 "Response Single Extensions",
272 single->singleExtensions, flags, 8)) 272 single->singleExtensions, flags, 8))
273 goto err; 273 goto err;
274 if (!BIO_write(bp,"\n",1)) goto err; 274 if (BIO_write(bp,"\n",1) <= 0) goto err;
275 } 275 }
276 if (!X509V3_extensions_print(bp, "Response Extensions", 276 if (!X509V3_extensions_print(bp, "Response Extensions",
277 rd->responseExtensions, flags, 4)) 277 rd->responseExtensions, flags, 4))
278 goto err;
278 if(X509_signature_print(bp, br->signatureAlgorithm, br->signature) <= 0) 279 if(X509_signature_print(bp, br->signatureAlgorithm, br->signature) <= 0)
279 goto err; 280 goto err;
280 281
diff --git a/src/lib/libcrypto/ocsp/ocsp_vfy.c b/src/lib/libcrypto/ocsp/ocsp_vfy.c
index 4a0c3870d8..415d67e61c 100644
--- a/src/lib/libcrypto/ocsp/ocsp_vfy.c
+++ b/src/lib/libcrypto/ocsp/ocsp_vfy.c
@@ -308,6 +308,8 @@ static int ocsp_match_issuerid(X509 *cert, OCSP_CERTID *cid,
308 } 308 }
309 309
310 mdlen = EVP_MD_size(dgst); 310 mdlen = EVP_MD_size(dgst);
311 if (mdlen < 0)
312 return -1;
311 if ((cid->issuerNameHash->length != mdlen) || 313 if ((cid->issuerNameHash->length != mdlen) ||
312 (cid->issuerKeyHash->length != mdlen)) 314 (cid->issuerKeyHash->length != mdlen))
313 return 0; 315 return 0;
@@ -316,7 +318,7 @@ static int ocsp_match_issuerid(X509 *cert, OCSP_CERTID *cid,
316 return -1; 318 return -1;
317 if (memcmp(md, cid->issuerNameHash->data, mdlen)) 319 if (memcmp(md, cid->issuerNameHash->data, mdlen))
318 return 0; 320 return 0;
319 X509_pubkey_digest(cert, EVP_sha1(), md, NULL); 321 X509_pubkey_digest(cert, dgst, md, NULL);
320 if (memcmp(md, cid->issuerKeyHash->data, mdlen)) 322 if (memcmp(md, cid->issuerKeyHash->data, mdlen))
321 return 0; 323 return 0;
322 324
diff --git a/src/lib/libcrypto/opensslconf.h.in b/src/lib/libcrypto/opensslconf.h.in
index 1c77f03c3d..97e3745563 100644
--- a/src/lib/libcrypto/opensslconf.h.in
+++ b/src/lib/libcrypto/opensslconf.h.in
@@ -1,20 +1,5 @@
1/* crypto/opensslconf.h.in */ 1/* crypto/opensslconf.h.in */
2 2
3#ifdef OPENSSL_DOING_MAKEDEPEND
4
5/* Include any symbols here that have to be explicitly set to enable a feature
6 * that should be visible to makedepend.
7 *
8 * [Our "make depend" doesn't actually look at this, we use actual build settings
9 * instead; we want to make it easy to remove subdirectories with disabled algorithms.]
10 */
11
12#ifndef OPENSSL_FIPS
13#define OPENSSL_FIPS
14#endif
15
16#endif
17
18/* Generate 80386 code? */ 3/* Generate 80386 code? */
19#undef I386_ONLY 4#undef I386_ONLY
20 5
@@ -78,14 +63,9 @@
78/* Should we define BN_DIV2W here? */ 63/* Should we define BN_DIV2W here? */
79 64
80/* Only one for the following should be defined */ 65/* Only one for the following should be defined */
81/* The prime number generation stuff may not work when
82 * EIGHT_BIT but I don't care since I've only used this mode
83 * for debuging the bignum libraries */
84#undef SIXTY_FOUR_BIT_LONG 66#undef SIXTY_FOUR_BIT_LONG
85#undef SIXTY_FOUR_BIT 67#undef SIXTY_FOUR_BIT
86#define THIRTY_TWO_BIT 68#define THIRTY_TWO_BIT
87#undef SIXTEEN_BIT
88#undef EIGHT_BIT
89#endif 69#endif
90 70
91#if defined(HEADER_RC4_LOCL_H) && !defined(CONFIG_HEADER_RC4_LOCL_H) 71#if defined(HEADER_RC4_LOCL_H) && !defined(CONFIG_HEADER_RC4_LOCL_H)
diff --git a/src/lib/libcrypto/opensslv.h b/src/lib/libcrypto/opensslv.h
index c6207f76b2..2fb110fa0e 100644
--- a/src/lib/libcrypto/opensslv.h
+++ b/src/lib/libcrypto/opensslv.h
@@ -12,7 +12,7 @@
12 * 0.9.3-beta2 0x00903002 (same as ...beta2-dev) 12 * 0.9.3-beta2 0x00903002 (same as ...beta2-dev)
13 * 0.9.3 0x0090300f 13 * 0.9.3 0x0090300f
14 * 0.9.3a 0x0090301f 14 * 0.9.3a 0x0090301f
15 * 0.9.4 0x0090400f 15 * 0.9.4 0x0090400f
16 * 1.2.3z 0x102031af 16 * 1.2.3z 0x102031af
17 * 17 *
18 * For continuity reasons (because 0.9.5 is already out, and is coded 18 * For continuity reasons (because 0.9.5 is already out, and is coded
@@ -25,11 +25,11 @@
25 * (Prior to 0.9.5a beta1, a different scheme was used: MMNNFFRBB for 25 * (Prior to 0.9.5a beta1, a different scheme was used: MMNNFFRBB for
26 * major minor fix final patch/beta) 26 * major minor fix final patch/beta)
27 */ 27 */
28#define OPENSSL_VERSION_NUMBER 0x009080bfL 28#define OPENSSL_VERSION_NUMBER 0x1000001fL
29#ifdef OPENSSL_FIPS 29#ifdef OPENSSL_FIPS
30#define OPENSSL_VERSION_TEXT "OpenSSL 0.9.8k-fips 25 Mar 2009" 30#define OPENSSL_VERSION_TEXT "OpenSSL 1.0.0a-fips 1 Jun 2010"
31#else 31#else
32#define OPENSSL_VERSION_TEXT "OpenSSL 0.9.8k 25 Mar 2009" 32#define OPENSSL_VERSION_TEXT "OpenSSL 1.0.0a 1 Jun 2010"
33#endif 33#endif
34#define OPENSSL_VERSION_PTEXT " part of " OPENSSL_VERSION_TEXT 34#define OPENSSL_VERSION_PTEXT " part of " OPENSSL_VERSION_TEXT
35 35
@@ -83,7 +83,7 @@
83 * should only keep the versions that are binary compatible with the current. 83 * should only keep the versions that are binary compatible with the current.
84 */ 84 */
85#define SHLIB_VERSION_HISTORY "" 85#define SHLIB_VERSION_HISTORY ""
86#define SHLIB_VERSION_NUMBER "0.9.8" 86#define SHLIB_VERSION_NUMBER "1.0.0"
87 87
88 88
89#endif /* HEADER_OPENSSLV_H */ 89#endif /* HEADER_OPENSSLV_H */
diff --git a/src/lib/libcrypto/ossl_typ.h b/src/lib/libcrypto/ossl_typ.h
index 0e7a380880..12bd7014de 100644
--- a/src/lib/libcrypto/ossl_typ.h
+++ b/src/lib/libcrypto/ossl_typ.h
@@ -95,6 +95,8 @@ typedef int ASN1_BOOLEAN;
95typedef int ASN1_NULL; 95typedef int ASN1_NULL;
96#endif 96#endif
97 97
98typedef struct asn1_pctx_st ASN1_PCTX;
99
98#ifdef OPENSSL_SYS_WIN32 100#ifdef OPENSSL_SYS_WIN32
99#undef X509_NAME 101#undef X509_NAME
100#undef X509_EXTENSIONS 102#undef X509_EXTENSIONS
@@ -122,6 +124,11 @@ typedef struct env_md_st EVP_MD;
122typedef struct env_md_ctx_st EVP_MD_CTX; 124typedef struct env_md_ctx_st EVP_MD_CTX;
123typedef struct evp_pkey_st EVP_PKEY; 125typedef struct evp_pkey_st EVP_PKEY;
124 126
127typedef struct evp_pkey_asn1_method_st EVP_PKEY_ASN1_METHOD;
128
129typedef struct evp_pkey_method_st EVP_PKEY_METHOD;
130typedef struct evp_pkey_ctx_st EVP_PKEY_CTX;
131
125typedef struct dh_st DH; 132typedef struct dh_st DH;
126typedef struct dh_method DH_METHOD; 133typedef struct dh_method DH_METHOD;
127 134
@@ -139,11 +146,14 @@ typedef struct ecdsa_method ECDSA_METHOD;
139typedef struct x509_st X509; 146typedef struct x509_st X509;
140typedef struct X509_algor_st X509_ALGOR; 147typedef struct X509_algor_st X509_ALGOR;
141typedef struct X509_crl_st X509_CRL; 148typedef struct X509_crl_st X509_CRL;
149typedef struct x509_crl_method_st X509_CRL_METHOD;
150typedef struct x509_revoked_st X509_REVOKED;
142typedef struct X509_name_st X509_NAME; 151typedef struct X509_name_st X509_NAME;
152typedef struct X509_pubkey_st X509_PUBKEY;
143typedef struct x509_store_st X509_STORE; 153typedef struct x509_store_st X509_STORE;
144typedef struct x509_store_ctx_st X509_STORE_CTX; 154typedef struct x509_store_ctx_st X509_STORE_CTX;
145typedef struct ssl_st SSL; 155
146typedef struct ssl_ctx_st SSL_CTX; 156typedef struct pkcs8_priv_key_info_st PKCS8_PRIV_KEY_INFO;
147 157
148typedef struct v3_ext_ctx X509V3_CTX; 158typedef struct v3_ext_ctx X509V3_CTX;
149typedef struct conf_st CONF; 159typedef struct conf_st CONF;
@@ -157,12 +167,19 @@ typedef struct ui_method_st UI_METHOD;
157typedef struct st_ERR_FNS ERR_FNS; 167typedef struct st_ERR_FNS ERR_FNS;
158 168
159typedef struct engine_st ENGINE; 169typedef struct engine_st ENGINE;
170typedef struct ssl_st SSL;
171typedef struct ssl_ctx_st SSL_CTX;
160 172
161typedef struct X509_POLICY_NODE_st X509_POLICY_NODE; 173typedef struct X509_POLICY_NODE_st X509_POLICY_NODE;
162typedef struct X509_POLICY_LEVEL_st X509_POLICY_LEVEL; 174typedef struct X509_POLICY_LEVEL_st X509_POLICY_LEVEL;
163typedef struct X509_POLICY_TREE_st X509_POLICY_TREE; 175typedef struct X509_POLICY_TREE_st X509_POLICY_TREE;
164typedef struct X509_POLICY_CACHE_st X509_POLICY_CACHE; 176typedef struct X509_POLICY_CACHE_st X509_POLICY_CACHE;
165 177
178typedef struct AUTHORITY_KEYID_st AUTHORITY_KEYID;
179typedef struct DIST_POINT_st DIST_POINT;
180typedef struct ISSUING_DIST_POINT_st ISSUING_DIST_POINT;
181typedef struct NAME_CONSTRAINTS_st NAME_CONSTRAINTS;
182
166 /* If placed in pkcs12.h, we end up with a circular depency with pkcs7.h */ 183 /* If placed in pkcs12.h, we end up with a circular depency with pkcs7.h */
167#define DECLARE_PKCS12_STACK_OF(type) /* Nothing */ 184#define DECLARE_PKCS12_STACK_OF(type) /* Nothing */
168#define IMPLEMENT_PKCS12_STACK_OF(type) /* Nothing */ 185#define IMPLEMENT_PKCS12_STACK_OF(type) /* Nothing */
diff --git a/src/lib/libcrypto/pem/Makefile.ssl b/src/lib/libcrypto/pem/Makefile.ssl
deleted file mode 100644
index d3043eb401..0000000000
--- a/src/lib/libcrypto/pem/Makefile.ssl
+++ /dev/null
@@ -1,336 +0,0 @@
1#
2# SSLeay/crypto/pem/Makefile
3#
4
5DIR= pem
6TOP= ../..
7CC= cc
8INCLUDES= -I.. -I$(TOP) -I../../include
9CFLAG=-g
10INSTALL_PREFIX=
11OPENSSLDIR= /usr/local/ssl
12INSTALLTOP=/usr/local/ssl
13MAKE= make -f Makefile.ssl
14MAKEDEPPROG= makedepend
15MAKEDEPEND= $(TOP)/util/domd $(TOP) -MD $(MAKEDEPPROG)
16MAKEFILE= Makefile.ssl
17AR= ar r
18
19CFLAGS= $(INCLUDES) $(CFLAG)
20
21GENERAL=Makefile
22TEST=
23APPS=
24
25LIB=$(TOP)/libcrypto.a
26LIBSRC= pem_sign.c pem_seal.c pem_info.c pem_lib.c pem_all.c pem_err.c \
27 pem_x509.c pem_xaux.c pem_oth.c pem_pk8.c pem_pkey.c
28
29LIBOBJ= pem_sign.o pem_seal.o pem_info.o pem_lib.o pem_all.o pem_err.o \
30 pem_x509.o pem_xaux.o pem_oth.o pem_pk8.o pem_pkey.o
31
32SRC= $(LIBSRC)
33
34EXHEADER= pem.h pem2.h
35HEADER= $(EXHEADER)
36
37ALL= $(GENERAL) $(SRC) $(HEADER)
38
39top:
40 (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all)
41
42all: lib
43
44lib: $(LIBOBJ)
45 $(AR) $(LIB) $(LIBOBJ)
46 $(RANLIB) $(LIB) || echo Never mind.
47 @touch lib
48
49files:
50 $(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO
51
52links: $(EXHEADER)
53 @sh $(TOP)/util/point.sh Makefile.ssl Makefile
54 @$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER)
55 @$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST)
56 @$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS)
57
58install:
59 @for i in $(EXHEADER) ; \
60 do \
61 (cp $$i $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i; \
62 chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i ); \
63 done;
64
65tags:
66 ctags $(SRC)
67
68tests:
69
70lint:
71 lint -DLINT $(INCLUDES) $(SRC)>fluff
72
73depend:
74 $(MAKEDEPEND) -- $(CFLAG) $(INCLUDES) $(DEPFLAG) -- $(LIBSRC)
75
76dclean:
77 $(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
78 mv -f Makefile.new $(MAKEFILE)
79
80clean:
81 rm -f *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff
82
83# DO NOT DELETE THIS LINE -- make depend depends on it.
84
85pem_all.o: ../../e_os.h ../../include/openssl/aes.h
86pem_all.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
87pem_all.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
88pem_all.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
89pem_all.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
90pem_all.o: ../../include/openssl/des_old.h ../../include/openssl/dh.h
91pem_all.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
92pem_all.o: ../../include/openssl/err.h ../../include/openssl/evp.h
93pem_all.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h
94pem_all.o: ../../include/openssl/md2.h ../../include/openssl/md4.h
95pem_all.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
96pem_all.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
97pem_all.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
98pem_all.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pem.h
99pem_all.o: ../../include/openssl/pem2.h ../../include/openssl/pkcs7.h
100pem_all.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h
101pem_all.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h
102pem_all.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
103pem_all.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
104pem_all.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
105pem_all.o: ../../include/openssl/ui_compat.h ../../include/openssl/x509.h
106pem_all.o: ../../include/openssl/x509_vfy.h ../cryptlib.h pem_all.c
107pem_err.o: ../../include/openssl/aes.h ../../include/openssl/asn1.h
108pem_err.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h
109pem_err.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
110pem_err.o: ../../include/openssl/cast.h ../../include/openssl/crypto.h
111pem_err.o: ../../include/openssl/des.h ../../include/openssl/des_old.h
112pem_err.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
113pem_err.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
114pem_err.o: ../../include/openssl/evp.h ../../include/openssl/idea.h
115pem_err.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h
116pem_err.o: ../../include/openssl/md4.h ../../include/openssl/md5.h
117pem_err.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h
118pem_err.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
119pem_err.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
120pem_err.o: ../../include/openssl/pem.h ../../include/openssl/pem2.h
121pem_err.o: ../../include/openssl/pkcs7.h ../../include/openssl/rc2.h
122pem_err.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
123pem_err.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
124pem_err.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
125pem_err.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
126pem_err.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
127pem_err.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
128pem_err.o: pem_err.c
129pem_info.o: ../../e_os.h ../../include/openssl/aes.h
130pem_info.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
131pem_info.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
132pem_info.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
133pem_info.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
134pem_info.o: ../../include/openssl/des_old.h ../../include/openssl/dh.h
135pem_info.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
136pem_info.o: ../../include/openssl/err.h ../../include/openssl/evp.h
137pem_info.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h
138pem_info.o: ../../include/openssl/md2.h ../../include/openssl/md4.h
139pem_info.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
140pem_info.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
141pem_info.o: ../../include/openssl/opensslconf.h
142pem_info.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
143pem_info.o: ../../include/openssl/pem.h ../../include/openssl/pem2.h
144pem_info.o: ../../include/openssl/pkcs7.h ../../include/openssl/rc2.h
145pem_info.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
146pem_info.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
147pem_info.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
148pem_info.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
149pem_info.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
150pem_info.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
151pem_info.o: ../cryptlib.h pem_info.c
152pem_lib.o: ../../e_os.h ../../include/openssl/aes.h
153pem_lib.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
154pem_lib.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
155pem_lib.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
156pem_lib.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
157pem_lib.o: ../../include/openssl/des_old.h ../../include/openssl/dh.h
158pem_lib.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
159pem_lib.o: ../../include/openssl/err.h ../../include/openssl/evp.h
160pem_lib.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h
161pem_lib.o: ../../include/openssl/md2.h ../../include/openssl/md4.h
162pem_lib.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
163pem_lib.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
164pem_lib.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
165pem_lib.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pem.h
166pem_lib.o: ../../include/openssl/pem2.h ../../include/openssl/pkcs12.h
167pem_lib.o: ../../include/openssl/pkcs7.h ../../include/openssl/rand.h
168pem_lib.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h
169pem_lib.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h
170pem_lib.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
171pem_lib.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
172pem_lib.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
173pem_lib.o: ../../include/openssl/ui_compat.h ../../include/openssl/x509.h
174pem_lib.o: ../../include/openssl/x509_vfy.h ../cryptlib.h pem_lib.c
175pem_oth.o: ../../e_os.h ../../include/openssl/aes.h
176pem_oth.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
177pem_oth.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
178pem_oth.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
179pem_oth.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
180pem_oth.o: ../../include/openssl/des_old.h ../../include/openssl/dh.h
181pem_oth.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
182pem_oth.o: ../../include/openssl/err.h ../../include/openssl/evp.h
183pem_oth.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h
184pem_oth.o: ../../include/openssl/md2.h ../../include/openssl/md4.h
185pem_oth.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
186pem_oth.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
187pem_oth.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
188pem_oth.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pem.h
189pem_oth.o: ../../include/openssl/pem2.h ../../include/openssl/pkcs7.h
190pem_oth.o: ../../include/openssl/rand.h ../../include/openssl/rc2.h
191pem_oth.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
192pem_oth.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
193pem_oth.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
194pem_oth.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
195pem_oth.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
196pem_oth.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
197pem_oth.o: ../cryptlib.h pem_oth.c
198pem_pk8.o: ../../e_os.h ../../include/openssl/aes.h
199pem_pk8.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
200pem_pk8.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
201pem_pk8.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
202pem_pk8.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
203pem_pk8.o: ../../include/openssl/des_old.h ../../include/openssl/dh.h
204pem_pk8.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
205pem_pk8.o: ../../include/openssl/err.h ../../include/openssl/evp.h
206pem_pk8.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h
207pem_pk8.o: ../../include/openssl/md2.h ../../include/openssl/md4.h
208pem_pk8.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
209pem_pk8.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
210pem_pk8.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
211pem_pk8.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pem.h
212pem_pk8.o: ../../include/openssl/pem2.h ../../include/openssl/pkcs12.h
213pem_pk8.o: ../../include/openssl/pkcs7.h ../../include/openssl/rand.h
214pem_pk8.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h
215pem_pk8.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h
216pem_pk8.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
217pem_pk8.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
218pem_pk8.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
219pem_pk8.o: ../../include/openssl/ui_compat.h ../../include/openssl/x509.h
220pem_pk8.o: ../../include/openssl/x509_vfy.h ../cryptlib.h pem_pk8.c
221pem_pkey.o: ../../e_os.h ../../include/openssl/aes.h
222pem_pkey.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
223pem_pkey.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
224pem_pkey.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
225pem_pkey.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
226pem_pkey.o: ../../include/openssl/des_old.h ../../include/openssl/dh.h
227pem_pkey.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
228pem_pkey.o: ../../include/openssl/err.h ../../include/openssl/evp.h
229pem_pkey.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h
230pem_pkey.o: ../../include/openssl/md2.h ../../include/openssl/md4.h
231pem_pkey.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
232pem_pkey.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
233pem_pkey.o: ../../include/openssl/opensslconf.h
234pem_pkey.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
235pem_pkey.o: ../../include/openssl/pem.h ../../include/openssl/pem2.h
236pem_pkey.o: ../../include/openssl/pkcs12.h ../../include/openssl/pkcs7.h
237pem_pkey.o: ../../include/openssl/rand.h ../../include/openssl/rc2.h
238pem_pkey.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
239pem_pkey.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
240pem_pkey.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
241pem_pkey.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
242pem_pkey.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
243pem_pkey.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
244pem_pkey.o: ../cryptlib.h pem_pkey.c
245pem_seal.o: ../../e_os.h ../../include/openssl/aes.h
246pem_seal.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
247pem_seal.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
248pem_seal.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
249pem_seal.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
250pem_seal.o: ../../include/openssl/des_old.h ../../include/openssl/dh.h
251pem_seal.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
252pem_seal.o: ../../include/openssl/err.h ../../include/openssl/evp.h
253pem_seal.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h
254pem_seal.o: ../../include/openssl/md2.h ../../include/openssl/md4.h
255pem_seal.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
256pem_seal.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
257pem_seal.o: ../../include/openssl/opensslconf.h
258pem_seal.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
259pem_seal.o: ../../include/openssl/pem.h ../../include/openssl/pem2.h
260pem_seal.o: ../../include/openssl/pkcs7.h ../../include/openssl/rand.h
261pem_seal.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h
262pem_seal.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h
263pem_seal.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
264pem_seal.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
265pem_seal.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
266pem_seal.o: ../../include/openssl/ui_compat.h ../../include/openssl/x509.h
267pem_seal.o: ../../include/openssl/x509_vfy.h ../cryptlib.h pem_seal.c
268pem_sign.o: ../../e_os.h ../../include/openssl/aes.h
269pem_sign.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
270pem_sign.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
271pem_sign.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
272pem_sign.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
273pem_sign.o: ../../include/openssl/des_old.h ../../include/openssl/dh.h
274pem_sign.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
275pem_sign.o: ../../include/openssl/err.h ../../include/openssl/evp.h
276pem_sign.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h
277pem_sign.o: ../../include/openssl/md2.h ../../include/openssl/md4.h
278pem_sign.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
279pem_sign.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
280pem_sign.o: ../../include/openssl/opensslconf.h
281pem_sign.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
282pem_sign.o: ../../include/openssl/pem.h ../../include/openssl/pem2.h
283pem_sign.o: ../../include/openssl/pkcs7.h ../../include/openssl/rand.h
284pem_sign.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h
285pem_sign.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h
286pem_sign.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
287pem_sign.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
288pem_sign.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
289pem_sign.o: ../../include/openssl/ui_compat.h ../../include/openssl/x509.h
290pem_sign.o: ../../include/openssl/x509_vfy.h ../cryptlib.h pem_sign.c
291pem_x509.o: ../../e_os.h ../../include/openssl/aes.h
292pem_x509.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
293pem_x509.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
294pem_x509.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
295pem_x509.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
296pem_x509.o: ../../include/openssl/des_old.h ../../include/openssl/dh.h
297pem_x509.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
298pem_x509.o: ../../include/openssl/err.h ../../include/openssl/evp.h
299pem_x509.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h
300pem_x509.o: ../../include/openssl/md2.h ../../include/openssl/md4.h
301pem_x509.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
302pem_x509.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
303pem_x509.o: ../../include/openssl/opensslconf.h
304pem_x509.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
305pem_x509.o: ../../include/openssl/pem.h ../../include/openssl/pem2.h
306pem_x509.o: ../../include/openssl/pkcs7.h ../../include/openssl/rc2.h
307pem_x509.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
308pem_x509.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
309pem_x509.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
310pem_x509.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
311pem_x509.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
312pem_x509.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
313pem_x509.o: ../cryptlib.h pem_x509.c
314pem_xaux.o: ../../e_os.h ../../include/openssl/aes.h
315pem_xaux.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
316pem_xaux.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
317pem_xaux.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
318pem_xaux.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
319pem_xaux.o: ../../include/openssl/des_old.h ../../include/openssl/dh.h
320pem_xaux.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
321pem_xaux.o: ../../include/openssl/err.h ../../include/openssl/evp.h
322pem_xaux.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h
323pem_xaux.o: ../../include/openssl/md2.h ../../include/openssl/md4.h
324pem_xaux.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
325pem_xaux.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
326pem_xaux.o: ../../include/openssl/opensslconf.h
327pem_xaux.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
328pem_xaux.o: ../../include/openssl/pem.h ../../include/openssl/pem2.h
329pem_xaux.o: ../../include/openssl/pkcs7.h ../../include/openssl/rc2.h
330pem_xaux.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
331pem_xaux.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
332pem_xaux.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
333pem_xaux.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
334pem_xaux.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
335pem_xaux.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
336pem_xaux.o: ../cryptlib.h pem_xaux.c
diff --git a/src/lib/libcrypto/pem/pem.h b/src/lib/libcrypto/pem/pem.h
index 6c193f1cbf..8a6ababe3a 100644
--- a/src/lib/libcrypto/pem/pem.h
+++ b/src/lib/libcrypto/pem/pem.h
@@ -134,6 +134,7 @@ extern "C" {
134#define PEM_STRING_ECDSA_PUBLIC "ECDSA PUBLIC KEY" 134#define PEM_STRING_ECDSA_PUBLIC "ECDSA PUBLIC KEY"
135#define PEM_STRING_ECPARAMETERS "EC PARAMETERS" 135#define PEM_STRING_ECPARAMETERS "EC PARAMETERS"
136#define PEM_STRING_ECPRIVATEKEY "EC PRIVATE KEY" 136#define PEM_STRING_ECPRIVATEKEY "EC PRIVATE KEY"
137#define PEM_STRING_PARAMETERS "PARAMETERS"
137#define PEM_STRING_CMS "CMS" 138#define PEM_STRING_CMS "CMS"
138 139
139 /* Note that this structure is initialised by PEM_SealInit and cleaned up 140 /* Note that this structure is initialised by PEM_SealInit and cleaned up
@@ -183,11 +184,8 @@ typedef struct pem_ctx_st
183 int num_recipient; 184 int num_recipient;
184 PEM_USER **recipient; 185 PEM_USER **recipient;
185 186
186#ifndef OPENSSL_NO_STACK 187 /* XXX(ben): don#t think this is used!
187 STACK *x509_chain; /* certificate chain */ 188 STACK *x509_chain; / * certificate chain */
188#else
189 char *x509_chain; /* certificate chain */
190#endif
191 EVP_MD *md; /* signature type */ 189 EVP_MD *md; /* signature type */
192 190
193 int md_enc; /* is the md encrypted or not? */ 191 int md_enc; /* is the md encrypted or not? */
@@ -224,28 +222,19 @@ typedef struct pem_ctx_st
224#define IMPLEMENT_PEM_read_fp(name, type, str, asn1) \ 222#define IMPLEMENT_PEM_read_fp(name, type, str, asn1) \
225type *PEM_read_##name(FILE *fp, type **x, pem_password_cb *cb, void *u)\ 223type *PEM_read_##name(FILE *fp, type **x, pem_password_cb *cb, void *u)\
226{ \ 224{ \
227 return (type*)PEM_ASN1_read(CHECKED_D2I_OF(type, d2i_##asn1), \ 225return PEM_ASN1_read((d2i_of_void *)d2i_##asn1, str,fp,(void **)x,cb,u); \
228 str, fp, \
229 CHECKED_PPTR_OF(type, x), \
230 cb, u); \
231} 226}
232 227
233#define IMPLEMENT_PEM_write_fp(name, type, str, asn1) \ 228#define IMPLEMENT_PEM_write_fp(name, type, str, asn1) \
234int PEM_write_##name(FILE *fp, type *x) \ 229int PEM_write_##name(FILE *fp, type *x) \
235{ \ 230{ \
236 return PEM_ASN1_write(CHECKED_I2D_OF(type, i2d_##asn1), \ 231return PEM_ASN1_write((i2d_of_void *)i2d_##asn1,str,fp,x,NULL,NULL,0,NULL,NULL); \
237 str, fp, \
238 CHECKED_PTR_OF(type, x), \
239 NULL, NULL, 0, NULL, NULL); \
240} 232}
241 233
242#define IMPLEMENT_PEM_write_fp_const(name, type, str, asn1) \ 234#define IMPLEMENT_PEM_write_fp_const(name, type, str, asn1) \
243int PEM_write_##name(FILE *fp, const type *x) \ 235int PEM_write_##name(FILE *fp, const type *x) \
244{ \ 236{ \
245 return PEM_ASN1_write(CHECKED_I2D_OF(const type, i2d_##asn1), \ 237return PEM_ASN1_write((i2d_of_void *)i2d_##asn1,str,fp,(void *)x,NULL,NULL,0,NULL,NULL); \
246 str, fp, \
247 CHECKED_PTR_OF(const type, x), \
248 NULL, NULL, 0, NULL, NULL); \
249} 238}
250 239
251#define IMPLEMENT_PEM_write_cb_fp(name, type, str, asn1) \ 240#define IMPLEMENT_PEM_write_cb_fp(name, type, str, asn1) \
@@ -253,10 +242,7 @@ int PEM_write_##name(FILE *fp, type *x, const EVP_CIPHER *enc, \
253 unsigned char *kstr, int klen, pem_password_cb *cb, \ 242 unsigned char *kstr, int klen, pem_password_cb *cb, \
254 void *u) \ 243 void *u) \
255 { \ 244 { \
256 return PEM_ASN1_write(CHECKED_I2D_OF(type, i2d_##asn1), \ 245 return PEM_ASN1_write((i2d_of_void *)i2d_##asn1,str,fp,x,enc,kstr,klen,cb,u); \
257 str, fp, \
258 CHECKED_PTR_OF(type, x), \
259 enc, kstr, klen, cb, u); \
260 } 246 }
261 247
262#define IMPLEMENT_PEM_write_cb_fp_const(name, type, str, asn1) \ 248#define IMPLEMENT_PEM_write_cb_fp_const(name, type, str, asn1) \
@@ -264,10 +250,7 @@ int PEM_write_##name(FILE *fp, type *x, const EVP_CIPHER *enc, \
264 unsigned char *kstr, int klen, pem_password_cb *cb, \ 250 unsigned char *kstr, int klen, pem_password_cb *cb, \
265 void *u) \ 251 void *u) \
266 { \ 252 { \
267 return PEM_ASN1_write(CHECKED_I2D_OF(const type, i2d_##asn1), \ 253 return PEM_ASN1_write((i2d_of_void *)i2d_##asn1,str,fp,x,enc,kstr,klen,cb,u); \
268 str, fp, \
269 CHECKED_PTR_OF(const type, x), \
270 enc, kstr, klen, cb, u); \
271 } 254 }
272 255
273#endif 256#endif
@@ -275,48 +258,33 @@ int PEM_write_##name(FILE *fp, type *x, const EVP_CIPHER *enc, \
275#define IMPLEMENT_PEM_read_bio(name, type, str, asn1) \ 258#define IMPLEMENT_PEM_read_bio(name, type, str, asn1) \
276type *PEM_read_bio_##name(BIO *bp, type **x, pem_password_cb *cb, void *u)\ 259type *PEM_read_bio_##name(BIO *bp, type **x, pem_password_cb *cb, void *u)\
277{ \ 260{ \
278 return (type*)PEM_ASN1_read_bio(CHECKED_D2I_OF(type, d2i_##asn1), \ 261return PEM_ASN1_read_bio((d2i_of_void *)d2i_##asn1, str,bp,(void **)x,cb,u); \
279 str, bp, \
280 CHECKED_PPTR_OF(type, x), \
281 cb, u); \
282} 262}
283 263
284#define IMPLEMENT_PEM_write_bio(name, type, str, asn1) \ 264#define IMPLEMENT_PEM_write_bio(name, type, str, asn1) \
285int PEM_write_bio_##name(BIO *bp, type *x) \ 265int PEM_write_bio_##name(BIO *bp, type *x) \
286{ \ 266{ \
287 return PEM_ASN1_write_bio(CHECKED_I2D_OF(type, i2d_##asn1), \ 267return PEM_ASN1_write_bio((i2d_of_void *)i2d_##asn1,str,bp,x,NULL,NULL,0,NULL,NULL); \
288 str, bp, \
289 CHECKED_PTR_OF(type, x), \
290 NULL, NULL, 0, NULL, NULL); \
291} 268}
292 269
293#define IMPLEMENT_PEM_write_bio_const(name, type, str, asn1) \ 270#define IMPLEMENT_PEM_write_bio_const(name, type, str, asn1) \
294int PEM_write_bio_##name(BIO *bp, const type *x) \ 271int PEM_write_bio_##name(BIO *bp, const type *x) \
295{ \ 272{ \
296 return PEM_ASN1_write_bio(CHECKED_I2D_OF(const type, i2d_##asn1), \ 273return PEM_ASN1_write_bio((i2d_of_void *)i2d_##asn1,str,bp,(void *)x,NULL,NULL,0,NULL,NULL); \
297 str, bp, \
298 CHECKED_PTR_OF(const type, x), \
299 NULL, NULL, 0, NULL, NULL); \
300} 274}
301 275
302#define IMPLEMENT_PEM_write_cb_bio(name, type, str, asn1) \ 276#define IMPLEMENT_PEM_write_cb_bio(name, type, str, asn1) \
303int PEM_write_bio_##name(BIO *bp, type *x, const EVP_CIPHER *enc, \ 277int PEM_write_bio_##name(BIO *bp, type *x, const EVP_CIPHER *enc, \
304 unsigned char *kstr, int klen, pem_password_cb *cb, void *u) \ 278 unsigned char *kstr, int klen, pem_password_cb *cb, void *u) \
305 { \ 279 { \
306 return PEM_ASN1_write_bio(CHECKED_I2D_OF(type, i2d_##asn1), \ 280 return PEM_ASN1_write_bio((i2d_of_void *)i2d_##asn1,str,bp,x,enc,kstr,klen,cb,u); \
307 str, bp, \
308 CHECKED_PTR_OF(type, x), \
309 enc, kstr, klen, cb, u); \
310 } 281 }
311 282
312#define IMPLEMENT_PEM_write_cb_bio_const(name, type, str, asn1) \ 283#define IMPLEMENT_PEM_write_cb_bio_const(name, type, str, asn1) \
313int PEM_write_bio_##name(BIO *bp, type *x, const EVP_CIPHER *enc, \ 284int PEM_write_bio_##name(BIO *bp, type *x, const EVP_CIPHER *enc, \
314 unsigned char *kstr, int klen, pem_password_cb *cb, void *u) \ 285 unsigned char *kstr, int klen, pem_password_cb *cb, void *u) \
315 { \ 286 { \
316 return PEM_ASN1_write_bio(CHECKED_I2D_OF(const type, i2d_##asn1), \ 287 return PEM_ASN1_write_bio((i2d_of_void *)i2d_##asn1,str,bp,(void *)x,enc,kstr,klen,cb,u); \
317 str, bp, \
318 CHECKED_PTR_OF(const type, x), \
319 enc, kstr, klen, cb, u); \
320 } 288 }
321 289
322#define IMPLEMENT_PEM_write(name, type, str, asn1) \ 290#define IMPLEMENT_PEM_write(name, type, str, asn1) \
@@ -353,11 +321,10 @@ int PEM_write_bio_##name(BIO *bp, type *x, const EVP_CIPHER *enc, \
353 321
354/* These are the same except they are for the declarations */ 322/* These are the same except they are for the declarations */
355 323
356#if defined(OPENSSL_SYS_WIN16) || defined(OPENSSL_NO_FP_API) 324#if defined(OPENSSL_NO_FP_API)
357 325
358#define DECLARE_PEM_read_fp(name, type) /**/ 326#define DECLARE_PEM_read_fp(name, type) /**/
359#define DECLARE_PEM_write_fp(name, type) /**/ 327#define DECLARE_PEM_write_fp(name, type) /**/
360#define DECLARE_PEM_write_fp_const(name, type) /**/
361#define DECLARE_PEM_write_cb_fp(name, type) /**/ 328#define DECLARE_PEM_write_cb_fp(name, type) /**/
362 329
363#else 330#else
@@ -428,138 +395,6 @@ int PEM_write_bio_##name(BIO *bp, type *x, const EVP_CIPHER *enc, \
428 DECLARE_PEM_read(name, type) \ 395 DECLARE_PEM_read(name, type) \
429 DECLARE_PEM_write_cb(name, type) 396 DECLARE_PEM_write_cb(name, type)
430 397
431#ifdef SSLEAY_MACROS
432
433#define PEM_write_SSL_SESSION(fp,x) \
434 PEM_ASN1_write((int (*)())i2d_SSL_SESSION, \
435 PEM_STRING_SSL_SESSION,fp, (char *)x, NULL,NULL,0,NULL,NULL)
436#define PEM_write_X509(fp,x) \
437 PEM_ASN1_write((int (*)())i2d_X509,PEM_STRING_X509,fp, \
438 (char *)x, NULL,NULL,0,NULL,NULL)
439#define PEM_write_X509_REQ(fp,x) PEM_ASN1_write( \
440 (int (*)())i2d_X509_REQ,PEM_STRING_X509_REQ,fp,(char *)x, \
441 NULL,NULL,0,NULL,NULL)
442#define PEM_write_X509_CRL(fp,x) \
443 PEM_ASN1_write((int (*)())i2d_X509_CRL,PEM_STRING_X509_CRL, \
444 fp,(char *)x, NULL,NULL,0,NULL,NULL)
445#define PEM_write_RSAPrivateKey(fp,x,enc,kstr,klen,cb,u) \
446 PEM_ASN1_write((int (*)())i2d_RSAPrivateKey,PEM_STRING_RSA,fp,\
447 (char *)x,enc,kstr,klen,cb,u)
448#define PEM_write_RSAPublicKey(fp,x) \
449 PEM_ASN1_write((int (*)())i2d_RSAPublicKey,\
450 PEM_STRING_RSA_PUBLIC,fp,(char *)x,NULL,NULL,0,NULL,NULL)
451#define PEM_write_DSAPrivateKey(fp,x,enc,kstr,klen,cb,u) \
452 PEM_ASN1_write((int (*)())i2d_DSAPrivateKey,PEM_STRING_DSA,fp,\
453 (char *)x,enc,kstr,klen,cb,u)
454#define PEM_write_PrivateKey(bp,x,enc,kstr,klen,cb,u) \
455 PEM_ASN1_write((int (*)())i2d_PrivateKey,\
456 (((x)->type == EVP_PKEY_DSA)?PEM_STRING_DSA:PEM_STRING_RSA),\
457 bp,(char *)x,enc,kstr,klen,cb,u)
458#define PEM_write_PKCS7(fp,x) \
459 PEM_ASN1_write((int (*)())i2d_PKCS7,PEM_STRING_PKCS7,fp, \
460 (char *)x, NULL,NULL,0,NULL,NULL)
461#define PEM_write_DHparams(fp,x) \
462 PEM_ASN1_write((int (*)())i2d_DHparams,PEM_STRING_DHPARAMS,fp,\
463 (char *)x,NULL,NULL,0,NULL,NULL)
464
465#define PEM_write_NETSCAPE_CERT_SEQUENCE(fp,x) \
466 PEM_ASN1_write((int (*)())i2d_NETSCAPE_CERT_SEQUENCE, \
467 PEM_STRING_X509,fp, \
468 (char *)x, NULL,NULL,0,NULL,NULL)
469
470#define PEM_read_SSL_SESSION(fp,x,cb,u) (SSL_SESSION *)PEM_ASN1_read( \
471 (char *(*)())d2i_SSL_SESSION,PEM_STRING_SSL_SESSION,fp,(char **)x,cb,u)
472#define PEM_read_X509(fp,x,cb,u) (X509 *)PEM_ASN1_read( \
473 (char *(*)())d2i_X509,PEM_STRING_X509,fp,(char **)x,cb,u)
474#define PEM_read_X509_REQ(fp,x,cb,u) (X509_REQ *)PEM_ASN1_read( \
475 (char *(*)())d2i_X509_REQ,PEM_STRING_X509_REQ,fp,(char **)x,cb,u)
476#define PEM_read_X509_CRL(fp,x,cb,u) (X509_CRL *)PEM_ASN1_read( \
477 (char *(*)())d2i_X509_CRL,PEM_STRING_X509_CRL,fp,(char **)x,cb,u)
478#define PEM_read_RSAPrivateKey(fp,x,cb,u) (RSA *)PEM_ASN1_read( \
479 (char *(*)())d2i_RSAPrivateKey,PEM_STRING_RSA,fp,(char **)x,cb,u)
480#define PEM_read_RSAPublicKey(fp,x,cb,u) (RSA *)PEM_ASN1_read( \
481 (char *(*)())d2i_RSAPublicKey,PEM_STRING_RSA_PUBLIC,fp,(char **)x,cb,u)
482#define PEM_read_DSAPrivateKey(fp,x,cb,u) (DSA *)PEM_ASN1_read( \
483 (char *(*)())d2i_DSAPrivateKey,PEM_STRING_DSA,fp,(char **)x,cb,u)
484#define PEM_read_PrivateKey(fp,x,cb,u) (EVP_PKEY *)PEM_ASN1_read( \
485 (char *(*)())d2i_PrivateKey,PEM_STRING_EVP_PKEY,fp,(char **)x,cb,u)
486#define PEM_read_PKCS7(fp,x,cb,u) (PKCS7 *)PEM_ASN1_read( \
487 (char *(*)())d2i_PKCS7,PEM_STRING_PKCS7,fp,(char **)x,cb,u)
488#define PEM_read_DHparams(fp,x,cb,u) (DH *)PEM_ASN1_read( \
489 (char *(*)())d2i_DHparams,PEM_STRING_DHPARAMS,fp,(char **)x,cb,u)
490
491#define PEM_read_NETSCAPE_CERT_SEQUENCE(fp,x,cb,u) \
492 (NETSCAPE_CERT_SEQUENCE *)PEM_ASN1_read( \
493 (char *(*)())d2i_NETSCAPE_CERT_SEQUENCE,PEM_STRING_X509,fp,\
494 (char **)x,cb,u)
495
496#define PEM_write_bio_X509(bp,x) \
497 PEM_ASN1_write_bio((int (*)())i2d_X509,PEM_STRING_X509,bp, \
498 (char *)x, NULL,NULL,0,NULL,NULL)
499#define PEM_write_bio_X509_REQ(bp,x) PEM_ASN1_write_bio( \
500 (int (*)())i2d_X509_REQ,PEM_STRING_X509_REQ,bp,(char *)x, \
501 NULL,NULL,0,NULL,NULL)
502#define PEM_write_bio_X509_CRL(bp,x) \
503 PEM_ASN1_write_bio((int (*)())i2d_X509_CRL,PEM_STRING_X509_CRL,\
504 bp,(char *)x, NULL,NULL,0,NULL,NULL)
505#define PEM_write_bio_RSAPrivateKey(bp,x,enc,kstr,klen,cb,u) \
506 PEM_ASN1_write_bio((int (*)())i2d_RSAPrivateKey,PEM_STRING_RSA,\
507 bp,(char *)x,enc,kstr,klen,cb,u)
508#define PEM_write_bio_RSAPublicKey(bp,x) \
509 PEM_ASN1_write_bio((int (*)())i2d_RSAPublicKey, \
510 PEM_STRING_RSA_PUBLIC,\
511 bp,(char *)x,NULL,NULL,0,NULL,NULL)
512#define PEM_write_bio_DSAPrivateKey(bp,x,enc,kstr,klen,cb,u) \
513 PEM_ASN1_write_bio((int (*)())i2d_DSAPrivateKey,PEM_STRING_DSA,\
514 bp,(char *)x,enc,kstr,klen,cb,u)
515#define PEM_write_bio_PrivateKey(bp,x,enc,kstr,klen,cb,u) \
516 PEM_ASN1_write_bio((int (*)())i2d_PrivateKey,\
517 (((x)->type == EVP_PKEY_DSA)?PEM_STRING_DSA:PEM_STRING_RSA),\
518 bp,(char *)x,enc,kstr,klen,cb,u)
519#define PEM_write_bio_PKCS7(bp,x) \
520 PEM_ASN1_write_bio((int (*)())i2d_PKCS7,PEM_STRING_PKCS7,bp, \
521 (char *)x, NULL,NULL,0,NULL,NULL)
522#define PEM_write_bio_DHparams(bp,x) \
523 PEM_ASN1_write_bio((int (*)())i2d_DHparams,PEM_STRING_DHPARAMS,\
524 bp,(char *)x,NULL,NULL,0,NULL,NULL)
525#define PEM_write_bio_DSAparams(bp,x) \
526 PEM_ASN1_write_bio((int (*)())i2d_DSAparams, \
527 PEM_STRING_DSAPARAMS,bp,(char *)x,NULL,NULL,0,NULL,NULL)
528
529#define PEM_write_bio_NETSCAPE_CERT_SEQUENCE(bp,x) \
530 PEM_ASN1_write_bio((int (*)())i2d_NETSCAPE_CERT_SEQUENCE, \
531 PEM_STRING_X509,bp, \
532 (char *)x, NULL,NULL,0,NULL,NULL)
533
534#define PEM_read_bio_X509(bp,x,cb,u) (X509 *)PEM_ASN1_read_bio( \
535 (char *(*)())d2i_X509,PEM_STRING_X509,bp,(char **)x,cb,u)
536#define PEM_read_bio_X509_REQ(bp,x,cb,u) (X509_REQ *)PEM_ASN1_read_bio( \
537 (char *(*)())d2i_X509_REQ,PEM_STRING_X509_REQ,bp,(char **)x,cb,u)
538#define PEM_read_bio_X509_CRL(bp,x,cb,u) (X509_CRL *)PEM_ASN1_read_bio( \
539 (char *(*)())d2i_X509_CRL,PEM_STRING_X509_CRL,bp,(char **)x,cb,u)
540#define PEM_read_bio_RSAPrivateKey(bp,x,cb,u) (RSA *)PEM_ASN1_read_bio( \
541 (char *(*)())d2i_RSAPrivateKey,PEM_STRING_RSA,bp,(char **)x,cb,u)
542#define PEM_read_bio_RSAPublicKey(bp,x,cb,u) (RSA *)PEM_ASN1_read_bio( \
543 (char *(*)())d2i_RSAPublicKey,PEM_STRING_RSA_PUBLIC,bp,(char **)x,cb,u)
544#define PEM_read_bio_DSAPrivateKey(bp,x,cb,u) (DSA *)PEM_ASN1_read_bio( \
545 (char *(*)())d2i_DSAPrivateKey,PEM_STRING_DSA,bp,(char **)x,cb,u)
546#define PEM_read_bio_PrivateKey(bp,x,cb,u) (EVP_PKEY *)PEM_ASN1_read_bio( \
547 (char *(*)())d2i_PrivateKey,PEM_STRING_EVP_PKEY,bp,(char **)x,cb,u)
548
549#define PEM_read_bio_PKCS7(bp,x,cb,u) (PKCS7 *)PEM_ASN1_read_bio( \
550 (char *(*)())d2i_PKCS7,PEM_STRING_PKCS7,bp,(char **)x,cb,u)
551#define PEM_read_bio_DHparams(bp,x,cb,u) (DH *)PEM_ASN1_read_bio( \
552 (char *(*)())d2i_DHparams,PEM_STRING_DHPARAMS,bp,(char **)x,cb,u)
553#define PEM_read_bio_DSAparams(bp,x,cb,u) (DSA *)PEM_ASN1_read_bio( \
554 (char *(*)())d2i_DSAparams,PEM_STRING_DSAPARAMS,bp,(char **)x,cb,u)
555
556#define PEM_read_bio_NETSCAPE_CERT_SEQUENCE(bp,x,cb,u) \
557 (NETSCAPE_CERT_SEQUENCE *)PEM_ASN1_read_bio( \
558 (char *(*)())d2i_NETSCAPE_CERT_SEQUENCE,PEM_STRING_X509,bp,\
559 (char **)x,cb,u)
560
561#endif
562
563#if 1 398#if 1
564/* "userdata": new with OpenSSL 0.9.4 */ 399/* "userdata": new with OpenSSL 0.9.4 */
565typedef int pem_password_cb(char *buf, int size, int rwflag, void *userdata); 400typedef int pem_password_cb(char *buf, int size, int rwflag, void *userdata);
@@ -581,40 +416,25 @@ int PEM_bytes_read_bio(unsigned char **pdata, long *plen, char **pnm, const char
581 pem_password_cb *cb, void *u); 416 pem_password_cb *cb, void *u);
582void * PEM_ASN1_read_bio(d2i_of_void *d2i, const char *name, BIO *bp, 417void * PEM_ASN1_read_bio(d2i_of_void *d2i, const char *name, BIO *bp,
583 void **x, pem_password_cb *cb, void *u); 418 void **x, pem_password_cb *cb, void *u);
584 419int PEM_ASN1_write_bio(i2d_of_void *i2d,const char *name,BIO *bp, void *x,
585#define PEM_ASN1_read_bio_of(type,d2i,name,bp,x,cb,u) \
586 ((type*)PEM_ASN1_read_bio(CHECKED_D2I_OF(type, d2i), \
587 name, bp, \
588 CHECKED_PPTR_OF(type, x), \
589 cb, u))
590
591int PEM_ASN1_write_bio(i2d_of_void *i2d,const char *name,BIO *bp,char *x,
592 const EVP_CIPHER *enc,unsigned char *kstr,int klen, 420 const EVP_CIPHER *enc,unsigned char *kstr,int klen,
593 pem_password_cb *cb, void *u); 421 pem_password_cb *cb, void *u);
594 422
595#define PEM_ASN1_write_bio_of(type,i2d,name,bp,x,enc,kstr,klen,cb,u) \
596 (PEM_ASN1_write_bio(CHECKED_I2D_OF(type, i2d), \
597 name, bp, \
598 CHECKED_PTR_OF(type, x), \
599 enc, kstr, klen, cb, u))
600
601STACK_OF(X509_INFO) * PEM_X509_INFO_read_bio(BIO *bp, STACK_OF(X509_INFO) *sk, pem_password_cb *cb, void *u); 423STACK_OF(X509_INFO) * PEM_X509_INFO_read_bio(BIO *bp, STACK_OF(X509_INFO) *sk, pem_password_cb *cb, void *u);
602int PEM_X509_INFO_write_bio(BIO *bp,X509_INFO *xi, EVP_CIPHER *enc, 424int PEM_X509_INFO_write_bio(BIO *bp,X509_INFO *xi, EVP_CIPHER *enc,
603 unsigned char *kstr, int klen, pem_password_cb *cd, void *u); 425 unsigned char *kstr, int klen, pem_password_cb *cd, void *u);
604#endif 426#endif
605 427
606#ifndef OPENSSL_SYS_WIN16
607int PEM_read(FILE *fp, char **name, char **header, 428int PEM_read(FILE *fp, char **name, char **header,
608 unsigned char **data,long *len); 429 unsigned char **data,long *len);
609int PEM_write(FILE *fp,char *name,char *hdr,unsigned char *data,long len); 430int PEM_write(FILE *fp,char *name,char *hdr,unsigned char *data,long len);
610void * PEM_ASN1_read(d2i_of_void *d2i, const char *name, FILE *fp, void **x, 431void * PEM_ASN1_read(d2i_of_void *d2i, const char *name, FILE *fp, void **x,
611 pem_password_cb *cb, void *u); 432 pem_password_cb *cb, void *u);
612int PEM_ASN1_write(i2d_of_void *i2d,const char *name,FILE *fp, 433int PEM_ASN1_write(i2d_of_void *i2d,const char *name,FILE *fp,
613 char *x,const EVP_CIPHER *enc,unsigned char *kstr, 434 void *x,const EVP_CIPHER *enc,unsigned char *kstr,
614 int klen,pem_password_cb *callback, void *u); 435 int klen,pem_password_cb *callback, void *u);
615STACK_OF(X509_INFO) * PEM_X509_INFO_read(FILE *fp, STACK_OF(X509_INFO) *sk, 436STACK_OF(X509_INFO) * PEM_X509_INFO_read(FILE *fp, STACK_OF(X509_INFO) *sk,
616 pem_password_cb *cb, void *u); 437 pem_password_cb *cb, void *u);
617#endif
618 438
619int PEM_SealInit(PEM_ENCODE_SEAL_CTX *ctx, EVP_CIPHER *type, 439int PEM_SealInit(PEM_ENCODE_SEAL_CTX *ctx, EVP_CIPHER *type,
620 EVP_MD *md_type, unsigned char **ek, int *ekl, 440 EVP_MD *md_type, unsigned char **ek, int *ekl,
@@ -633,7 +453,6 @@ int PEM_def_callback(char *buf, int num, int w, void *key);
633void PEM_proc_type(char *buf, int type); 453void PEM_proc_type(char *buf, int type);
634void PEM_dek_info(char *buf, const char *type, int len, char *str); 454void PEM_dek_info(char *buf, const char *type, int len, char *str);
635 455
636#ifndef SSLEAY_MACROS
637 456
638#include <openssl/symhacks.h> 457#include <openssl/symhacks.h>
639 458
@@ -719,7 +538,21 @@ EVP_PKEY *d2i_PKCS8PrivateKey_fp(FILE *fp, EVP_PKEY **x, pem_password_cb *cb, vo
719int PEM_write_PKCS8PrivateKey(FILE *fp,EVP_PKEY *x,const EVP_CIPHER *enc, 538int PEM_write_PKCS8PrivateKey(FILE *fp,EVP_PKEY *x,const EVP_CIPHER *enc,
720 char *kstr,int klen, pem_password_cb *cd, void *u); 539 char *kstr,int klen, pem_password_cb *cd, void *u);
721 540
722#endif /* SSLEAY_MACROS */ 541EVP_PKEY *PEM_read_bio_Parameters(BIO *bp, EVP_PKEY **x);
542int PEM_write_bio_Parameters(BIO *bp, EVP_PKEY *x);
543
544
545EVP_PKEY *b2i_PrivateKey(const unsigned char **in, long length);
546EVP_PKEY *b2i_PublicKey(const unsigned char **in, long length);
547EVP_PKEY *b2i_PrivateKey_bio(BIO *in);
548EVP_PKEY *b2i_PublicKey_bio(BIO *in);
549int i2b_PrivateKey_bio(BIO *out, EVP_PKEY *pk);
550int i2b_PublicKey_bio(BIO *out, EVP_PKEY *pk);
551#ifndef OPENSSL_NO_RC4
552EVP_PKEY *b2i_PVK_bio(BIO *in, pem_password_cb *cb, void *u);
553int i2b_PVK_bio(BIO *out, EVP_PKEY *pk, int enclevel,
554 pem_password_cb *cb, void *u);
555#endif
723 556
724 557
725/* BEGIN ERROR CODES */ 558/* BEGIN ERROR CODES */
@@ -731,10 +564,22 @@ void ERR_load_PEM_strings(void);
731/* Error codes for the PEM functions. */ 564/* Error codes for the PEM functions. */
732 565
733/* Function codes. */ 566/* Function codes. */
567#define PEM_F_B2I_DSS 127
568#define PEM_F_B2I_PVK_BIO 128
569#define PEM_F_B2I_RSA 129
570#define PEM_F_CHECK_BITLEN_DSA 130
571#define PEM_F_CHECK_BITLEN_RSA 131
734#define PEM_F_D2I_PKCS8PRIVATEKEY_BIO 120 572#define PEM_F_D2I_PKCS8PRIVATEKEY_BIO 120
735#define PEM_F_D2I_PKCS8PRIVATEKEY_FP 121 573#define PEM_F_D2I_PKCS8PRIVATEKEY_FP 121
574#define PEM_F_DO_B2I 132
575#define PEM_F_DO_B2I_BIO 133
576#define PEM_F_DO_BLOB_HEADER 134
736#define PEM_F_DO_PK8PKEY 126 577#define PEM_F_DO_PK8PKEY 126
737#define PEM_F_DO_PK8PKEY_FP 125 578#define PEM_F_DO_PK8PKEY_FP 125
579#define PEM_F_DO_PVK_BODY 135
580#define PEM_F_DO_PVK_HEADER 136
581#define PEM_F_I2B_PVK 137
582#define PEM_F_I2B_PVK_BIO 138
738#define PEM_F_LOAD_IV 101 583#define PEM_F_LOAD_IV 101
739#define PEM_F_PEM_ASN1_READ 102 584#define PEM_F_PEM_ASN1_READ 102
740#define PEM_F_PEM_ASN1_READ_BIO 103 585#define PEM_F_PEM_ASN1_READ_BIO 103
@@ -747,6 +592,7 @@ void ERR_load_PEM_strings(void);
747#define PEM_F_PEM_PK8PKEY 119 592#define PEM_F_PEM_PK8PKEY 119
748#define PEM_F_PEM_READ 108 593#define PEM_F_PEM_READ 108
749#define PEM_F_PEM_READ_BIO 109 594#define PEM_F_PEM_READ_BIO 109
595#define PEM_F_PEM_READ_BIO_PARAMETERS 140
750#define PEM_F_PEM_READ_BIO_PRIVATEKEY 123 596#define PEM_F_PEM_READ_BIO_PRIVATEKEY 123
751#define PEM_F_PEM_READ_PRIVATEKEY 124 597#define PEM_F_PEM_READ_PRIVATEKEY 124
752#define PEM_F_PEM_SEALFINAL 110 598#define PEM_F_PEM_SEALFINAL 110
@@ -754,6 +600,7 @@ void ERR_load_PEM_strings(void);
754#define PEM_F_PEM_SIGNFINAL 112 600#define PEM_F_PEM_SIGNFINAL 112
755#define PEM_F_PEM_WRITE 113 601#define PEM_F_PEM_WRITE 113
756#define PEM_F_PEM_WRITE_BIO 114 602#define PEM_F_PEM_WRITE_BIO 114
603#define PEM_F_PEM_WRITE_PRIVATEKEY 139
757#define PEM_F_PEM_X509_INFO_READ 115 604#define PEM_F_PEM_X509_INFO_READ 115
758#define PEM_F_PEM_X509_INFO_READ_BIO 116 605#define PEM_F_PEM_X509_INFO_READ_BIO 116
759#define PEM_F_PEM_X509_INFO_WRITE_BIO 117 606#define PEM_F_PEM_X509_INFO_WRITE_BIO 117
@@ -763,18 +610,30 @@ void ERR_load_PEM_strings(void);
763#define PEM_R_BAD_DECRYPT 101 610#define PEM_R_BAD_DECRYPT 101
764#define PEM_R_BAD_END_LINE 102 611#define PEM_R_BAD_END_LINE 102
765#define PEM_R_BAD_IV_CHARS 103 612#define PEM_R_BAD_IV_CHARS 103
613#define PEM_R_BAD_MAGIC_NUMBER 116
766#define PEM_R_BAD_PASSWORD_READ 104 614#define PEM_R_BAD_PASSWORD_READ 104
615#define PEM_R_BAD_VERSION_NUMBER 117
616#define PEM_R_BIO_WRITE_FAILURE 118
617#define PEM_R_CIPHER_IS_NULL 127
767#define PEM_R_ERROR_CONVERTING_PRIVATE_KEY 115 618#define PEM_R_ERROR_CONVERTING_PRIVATE_KEY 115
619#define PEM_R_EXPECTING_PRIVATE_KEY_BLOB 119
620#define PEM_R_EXPECTING_PUBLIC_KEY_BLOB 120
621#define PEM_R_INCONSISTENT_HEADER 121
622#define PEM_R_KEYBLOB_HEADER_PARSE_ERROR 122
623#define PEM_R_KEYBLOB_TOO_SHORT 123
768#define PEM_R_NOT_DEK_INFO 105 624#define PEM_R_NOT_DEK_INFO 105
769#define PEM_R_NOT_ENCRYPTED 106 625#define PEM_R_NOT_ENCRYPTED 106
770#define PEM_R_NOT_PROC_TYPE 107 626#define PEM_R_NOT_PROC_TYPE 107
771#define PEM_R_NO_START_LINE 108 627#define PEM_R_NO_START_LINE 108
772#define PEM_R_PROBLEMS_GETTING_PASSWORD 109 628#define PEM_R_PROBLEMS_GETTING_PASSWORD 109
773#define PEM_R_PUBLIC_KEY_NO_RSA 110 629#define PEM_R_PUBLIC_KEY_NO_RSA 110
630#define PEM_R_PVK_DATA_TOO_SHORT 124
631#define PEM_R_PVK_TOO_SHORT 125
774#define PEM_R_READ_KEY 111 632#define PEM_R_READ_KEY 111
775#define PEM_R_SHORT_HEADER 112 633#define PEM_R_SHORT_HEADER 112
776#define PEM_R_UNSUPPORTED_CIPHER 113 634#define PEM_R_UNSUPPORTED_CIPHER 113
777#define PEM_R_UNSUPPORTED_ENCRYPTION 114 635#define PEM_R_UNSUPPORTED_ENCRYPTION 114
636#define PEM_R_UNSUPPORTED_KEY_COMPONENTS 126
778 637
779#ifdef __cplusplus 638#ifdef __cplusplus
780} 639}
diff --git a/src/lib/libcrypto/pem/pem_all.c b/src/lib/libcrypto/pem/pem_all.c
index 69dd19bf2e..3e7a6093ad 100644
--- a/src/lib/libcrypto/pem/pem_all.c
+++ b/src/lib/libcrypto/pem/pem_all.c
@@ -110,7 +110,6 @@
110 */ 110 */
111 111
112#include <stdio.h> 112#include <stdio.h>
113#undef SSLEAY_MACROS
114#include "cryptlib.h" 113#include "cryptlib.h"
115#include <openssl/bio.h> 114#include <openssl/bio.h>
116#include <openssl/evp.h> 115#include <openssl/evp.h>
@@ -194,49 +193,7 @@ RSA *PEM_read_RSAPrivateKey(FILE *fp, RSA **rsa, pem_password_cb *cb,
194 193
195#endif 194#endif
196 195
197#ifdef OPENSSL_FIPS
198
199int PEM_write_bio_RSAPrivateKey(BIO *bp, RSA *x, const EVP_CIPHER *enc,
200 unsigned char *kstr, int klen,
201 pem_password_cb *cb, void *u)
202{
203 EVP_PKEY *k;
204 int ret;
205 k = EVP_PKEY_new();
206 if (!k)
207 return 0;
208 EVP_PKEY_set1_RSA(k, x);
209
210 ret = PEM_write_bio_PrivateKey(bp, k, enc, kstr, klen, cb, u);
211 EVP_PKEY_free(k);
212 return ret;
213}
214
215#ifndef OPENSSL_NO_FP_API
216int PEM_write_RSAPrivateKey(FILE *fp, RSA *x, const EVP_CIPHER *enc,
217 unsigned char *kstr, int klen,
218 pem_password_cb *cb, void *u)
219{
220 EVP_PKEY *k;
221 int ret;
222 k = EVP_PKEY_new();
223 if (!k)
224 return 0;
225
226 EVP_PKEY_set1_RSA(k, x);
227
228 ret = PEM_write_PrivateKey(fp, k, enc, kstr, klen, cb, u);
229 EVP_PKEY_free(k);
230 return ret;
231}
232#endif
233
234#else
235
236IMPLEMENT_PEM_write_cb_const(RSAPrivateKey, RSA, PEM_STRING_RSA, RSAPrivateKey) 196IMPLEMENT_PEM_write_cb_const(RSAPrivateKey, RSA, PEM_STRING_RSA, RSAPrivateKey)
237
238#endif
239
240IMPLEMENT_PEM_rw_const(RSAPublicKey, RSA, PEM_STRING_RSA_PUBLIC, RSAPublicKey) 197IMPLEMENT_PEM_rw_const(RSAPublicKey, RSA, PEM_STRING_RSA_PUBLIC, RSAPublicKey)
241IMPLEMENT_PEM_rw(RSA_PUBKEY, RSA, PEM_STRING_PUBLIC, RSA_PUBKEY) 198IMPLEMENT_PEM_rw(RSA_PUBKEY, RSA, PEM_STRING_PUBLIC, RSA_PUBKEY)
242 199
@@ -263,50 +220,10 @@ DSA *PEM_read_bio_DSAPrivateKey(BIO *bp, DSA **dsa, pem_password_cb *cb,
263{ 220{
264 EVP_PKEY *pktmp; 221 EVP_PKEY *pktmp;
265 pktmp = PEM_read_bio_PrivateKey(bp, NULL, cb, u); 222 pktmp = PEM_read_bio_PrivateKey(bp, NULL, cb, u);
266 return pkey_get_dsa(pktmp, dsa); 223 return pkey_get_dsa(pktmp, dsa); /* will free pktmp */
267} 224}
268 225
269#ifdef OPENSSL_FIPS
270
271int PEM_write_bio_DSAPrivateKey(BIO *bp, DSA *x, const EVP_CIPHER *enc,
272 unsigned char *kstr, int klen,
273 pem_password_cb *cb, void *u)
274{
275 EVP_PKEY *k;
276 int ret;
277 k = EVP_PKEY_new();
278 if (!k)
279 return 0;
280 EVP_PKEY_set1_DSA(k, x);
281
282 ret = PEM_write_bio_PrivateKey(bp, k, enc, kstr, klen, cb, u);
283 EVP_PKEY_free(k);
284 return ret;
285}
286
287#ifndef OPENSSL_NO_FP_API
288int PEM_write_DSAPrivateKey(FILE *fp, DSA *x, const EVP_CIPHER *enc,
289 unsigned char *kstr, int klen,
290 pem_password_cb *cb, void *u)
291{
292 EVP_PKEY *k;
293 int ret;
294 k = EVP_PKEY_new();
295 if (!k)
296 return 0;
297 EVP_PKEY_set1_DSA(k, x);
298 ret = PEM_write_PrivateKey(fp, k, enc, kstr, klen, cb, u);
299 EVP_PKEY_free(k);
300 return ret;
301}
302#endif
303
304#else
305
306IMPLEMENT_PEM_write_cb_const(DSAPrivateKey, DSA, PEM_STRING_DSA, DSAPrivateKey) 226IMPLEMENT_PEM_write_cb_const(DSAPrivateKey, DSA, PEM_STRING_DSA, DSAPrivateKey)
307
308#endif
309
310IMPLEMENT_PEM_rw(DSA_PUBKEY, DSA, PEM_STRING_PUBLIC, DSA_PUBKEY) 227IMPLEMENT_PEM_rw(DSA_PUBKEY, DSA, PEM_STRING_PUBLIC, DSA_PUBKEY)
311 228
312#ifndef OPENSSL_NO_FP_API 229#ifndef OPENSSL_NO_FP_API
@@ -316,7 +233,7 @@ DSA *PEM_read_DSAPrivateKey(FILE *fp, DSA **dsa, pem_password_cb *cb,
316{ 233{
317 EVP_PKEY *pktmp; 234 EVP_PKEY *pktmp;
318 pktmp = PEM_read_PrivateKey(fp, NULL, cb, u); 235 pktmp = PEM_read_PrivateKey(fp, NULL, cb, u);
319 return pkey_get_dsa(pktmp, dsa); 236 return pkey_get_dsa(pktmp, dsa); /* will free pktmp */
320} 237}
321 238
322#endif 239#endif
@@ -347,54 +264,13 @@ EC_KEY *PEM_read_bio_ECPrivateKey(BIO *bp, EC_KEY **key, pem_password_cb *cb,
347{ 264{
348 EVP_PKEY *pktmp; 265 EVP_PKEY *pktmp;
349 pktmp = PEM_read_bio_PrivateKey(bp, NULL, cb, u); 266 pktmp = PEM_read_bio_PrivateKey(bp, NULL, cb, u);
350 return pkey_get_eckey(pktmp, key); 267 return pkey_get_eckey(pktmp, key); /* will free pktmp */
351} 268}
352 269
353IMPLEMENT_PEM_rw_const(ECPKParameters, EC_GROUP, PEM_STRING_ECPARAMETERS, ECPKParameters) 270IMPLEMENT_PEM_rw_const(ECPKParameters, EC_GROUP, PEM_STRING_ECPARAMETERS, ECPKParameters)
354 271
355
356
357#ifdef OPENSSL_FIPS
358
359int PEM_write_bio_ECPrivateKey(BIO *bp, EC_KEY *x, const EVP_CIPHER *enc,
360 unsigned char *kstr, int klen,
361 pem_password_cb *cb, void *u)
362{
363 EVP_PKEY *k;
364 int ret;
365 k = EVP_PKEY_new();
366 if (!k)
367 return 0;
368 EVP_PKEY_set1_EC_KEY(k, x);
369
370 ret = PEM_write_bio_PrivateKey(bp, k, enc, kstr, klen, cb, u);
371 EVP_PKEY_free(k);
372 return ret;
373}
374
375#ifndef OPENSSL_NO_FP_API
376int PEM_write_ECPrivateKey(FILE *fp, EC_KEY *x, const EVP_CIPHER *enc,
377 unsigned char *kstr, int klen,
378 pem_password_cb *cb, void *u)
379{
380 EVP_PKEY *k;
381 int ret;
382 k = EVP_PKEY_new();
383 if (!k)
384 return 0;
385 EVP_PKEY_set1_EC_KEY(k, x);
386 ret = PEM_write_PrivateKey(fp, k, enc, kstr, klen, cb, u);
387 EVP_PKEY_free(k);
388 return ret;
389}
390#endif
391
392#else
393
394IMPLEMENT_PEM_write_cb(ECPrivateKey, EC_KEY, PEM_STRING_ECPRIVATEKEY, ECPrivateKey) 272IMPLEMENT_PEM_write_cb(ECPrivateKey, EC_KEY, PEM_STRING_ECPRIVATEKEY, ECPrivateKey)
395 273
396#endif
397
398IMPLEMENT_PEM_rw(EC_PUBKEY, EC_KEY, PEM_STRING_PUBLIC, EC_PUBKEY) 274IMPLEMENT_PEM_rw(EC_PUBKEY, EC_KEY, PEM_STRING_PUBLIC, EC_PUBKEY)
399 275
400#ifndef OPENSSL_NO_FP_API 276#ifndef OPENSSL_NO_FP_API
@@ -404,7 +280,7 @@ EC_KEY *PEM_read_ECPrivateKey(FILE *fp, EC_KEY **eckey, pem_password_cb *cb,
404{ 280{
405 EVP_PKEY *pktmp; 281 EVP_PKEY *pktmp;
406 pktmp = PEM_read_PrivateKey(fp, NULL, cb, u); 282 pktmp = PEM_read_PrivateKey(fp, NULL, cb, u);
407 return pkey_get_eckey(pktmp, eckey); 283 return pkey_get_eckey(pktmp, eckey); /* will free pktmp */
408} 284}
409 285
410#endif 286#endif
@@ -417,66 +293,4 @@ IMPLEMENT_PEM_rw_const(DHparams, DH, PEM_STRING_DHPARAMS, DHparams)
417 293
418#endif 294#endif
419 295
420
421/* The PrivateKey case is not that straightforward.
422 * IMPLEMENT_PEM_rw_cb(PrivateKey, EVP_PKEY, PEM_STRING_EVP_PKEY, PrivateKey)
423 * does not work, RSA and DSA keys have specific strings.
424 * (When reading, parameter PEM_STRING_EVP_PKEY is a wildcard for anything
425 * appropriate.)
426 */
427
428#ifdef OPENSSL_FIPS
429
430static const char *pkey_str(EVP_PKEY *x)
431 {
432 switch (x->type)
433 {
434 case EVP_PKEY_RSA:
435 return PEM_STRING_RSA;
436
437 case EVP_PKEY_DSA:
438 return PEM_STRING_DSA;
439
440 case EVP_PKEY_EC:
441 return PEM_STRING_ECPRIVATEKEY;
442
443 default:
444 return NULL;
445 }
446 }
447
448
449int PEM_write_bio_PrivateKey(BIO *bp, EVP_PKEY *x, const EVP_CIPHER *enc,
450 unsigned char *kstr, int klen,
451 pem_password_cb *cb, void *u)
452 {
453 if (FIPS_mode())
454 return PEM_write_bio_PKCS8PrivateKey(bp, x, enc,
455 (char *)kstr, klen, cb, u);
456 else
457 return PEM_ASN1_write_bio((i2d_of_void *)i2d_PrivateKey,
458 pkey_str(x), bp,(char *)x,enc,kstr,klen,cb,u);
459 }
460
461#ifndef OPENSSL_NO_FP_API
462int PEM_write_PrivateKey(FILE *fp, EVP_PKEY *x, const EVP_CIPHER *enc,
463 unsigned char *kstr, int klen,
464 pem_password_cb *cb, void *u)
465 {
466 if (FIPS_mode())
467 return PEM_write_PKCS8PrivateKey(fp, x, enc,
468 (char *)kstr, klen, cb, u);
469 else
470 return PEM_ASN1_write((i2d_of_void *)i2d_PrivateKey,
471 pkey_str(x), fp,(char *)x,enc,kstr,klen,cb,u);
472 }
473#endif
474
475#else
476IMPLEMENT_PEM_write_cb(PrivateKey, EVP_PKEY, ((x->type == EVP_PKEY_DSA)?PEM_STRING_DSA:\
477 (x->type == EVP_PKEY_RSA)?PEM_STRING_RSA:PEM_STRING_ECPRIVATEKEY), PrivateKey)
478
479#endif
480
481IMPLEMENT_PEM_rw(PUBKEY, EVP_PKEY, PEM_STRING_PUBLIC, PUBKEY) 296IMPLEMENT_PEM_rw(PUBKEY, EVP_PKEY, PEM_STRING_PUBLIC, PUBKEY)
482
diff --git a/src/lib/libcrypto/pem/pem_err.c b/src/lib/libcrypto/pem/pem_err.c
index 3133563d77..d644aeedd4 100644
--- a/src/lib/libcrypto/pem/pem_err.c
+++ b/src/lib/libcrypto/pem/pem_err.c
@@ -1,6 +1,6 @@
1/* crypto/pem/pem_err.c */ 1/* crypto/pem/pem_err.c */
2/* ==================================================================== 2/* ====================================================================
3 * Copyright (c) 1999-2005 The OpenSSL Project. All rights reserved. 3 * Copyright (c) 1999-2007 The OpenSSL Project. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
@@ -70,10 +70,22 @@
70 70
71static ERR_STRING_DATA PEM_str_functs[]= 71static ERR_STRING_DATA PEM_str_functs[]=
72 { 72 {
73{ERR_FUNC(PEM_F_B2I_DSS), "B2I_DSS"},
74{ERR_FUNC(PEM_F_B2I_PVK_BIO), "b2i_PVK_bio"},
75{ERR_FUNC(PEM_F_B2I_RSA), "B2I_RSA"},
76{ERR_FUNC(PEM_F_CHECK_BITLEN_DSA), "CHECK_BITLEN_DSA"},
77{ERR_FUNC(PEM_F_CHECK_BITLEN_RSA), "CHECK_BITLEN_RSA"},
73{ERR_FUNC(PEM_F_D2I_PKCS8PRIVATEKEY_BIO), "d2i_PKCS8PrivateKey_bio"}, 78{ERR_FUNC(PEM_F_D2I_PKCS8PRIVATEKEY_BIO), "d2i_PKCS8PrivateKey_bio"},
74{ERR_FUNC(PEM_F_D2I_PKCS8PRIVATEKEY_FP), "d2i_PKCS8PrivateKey_fp"}, 79{ERR_FUNC(PEM_F_D2I_PKCS8PRIVATEKEY_FP), "d2i_PKCS8PrivateKey_fp"},
80{ERR_FUNC(PEM_F_DO_B2I), "DO_B2I"},
81{ERR_FUNC(PEM_F_DO_B2I_BIO), "DO_B2I_BIO"},
82{ERR_FUNC(PEM_F_DO_BLOB_HEADER), "DO_BLOB_HEADER"},
75{ERR_FUNC(PEM_F_DO_PK8PKEY), "DO_PK8PKEY"}, 83{ERR_FUNC(PEM_F_DO_PK8PKEY), "DO_PK8PKEY"},
76{ERR_FUNC(PEM_F_DO_PK8PKEY_FP), "DO_PK8PKEY_FP"}, 84{ERR_FUNC(PEM_F_DO_PK8PKEY_FP), "DO_PK8PKEY_FP"},
85{ERR_FUNC(PEM_F_DO_PVK_BODY), "DO_PVK_BODY"},
86{ERR_FUNC(PEM_F_DO_PVK_HEADER), "DO_PVK_HEADER"},
87{ERR_FUNC(PEM_F_I2B_PVK), "I2B_PVK"},
88{ERR_FUNC(PEM_F_I2B_PVK_BIO), "i2b_PVK_bio"},
77{ERR_FUNC(PEM_F_LOAD_IV), "LOAD_IV"}, 89{ERR_FUNC(PEM_F_LOAD_IV), "LOAD_IV"},
78{ERR_FUNC(PEM_F_PEM_ASN1_READ), "PEM_ASN1_read"}, 90{ERR_FUNC(PEM_F_PEM_ASN1_READ), "PEM_ASN1_read"},
79{ERR_FUNC(PEM_F_PEM_ASN1_READ_BIO), "PEM_ASN1_read_bio"}, 91{ERR_FUNC(PEM_F_PEM_ASN1_READ_BIO), "PEM_ASN1_read_bio"},
@@ -86,6 +98,7 @@ static ERR_STRING_DATA PEM_str_functs[]=
86{ERR_FUNC(PEM_F_PEM_PK8PKEY), "PEM_PK8PKEY"}, 98{ERR_FUNC(PEM_F_PEM_PK8PKEY), "PEM_PK8PKEY"},
87{ERR_FUNC(PEM_F_PEM_READ), "PEM_read"}, 99{ERR_FUNC(PEM_F_PEM_READ), "PEM_read"},
88{ERR_FUNC(PEM_F_PEM_READ_BIO), "PEM_read_bio"}, 100{ERR_FUNC(PEM_F_PEM_READ_BIO), "PEM_read_bio"},
101{ERR_FUNC(PEM_F_PEM_READ_BIO_PARAMETERS), "PEM_read_bio_Parameters"},
89{ERR_FUNC(PEM_F_PEM_READ_BIO_PRIVATEKEY), "PEM_READ_BIO_PRIVATEKEY"}, 102{ERR_FUNC(PEM_F_PEM_READ_BIO_PRIVATEKEY), "PEM_READ_BIO_PRIVATEKEY"},
90{ERR_FUNC(PEM_F_PEM_READ_PRIVATEKEY), "PEM_READ_PRIVATEKEY"}, 103{ERR_FUNC(PEM_F_PEM_READ_PRIVATEKEY), "PEM_READ_PRIVATEKEY"},
91{ERR_FUNC(PEM_F_PEM_SEALFINAL), "PEM_SealFinal"}, 104{ERR_FUNC(PEM_F_PEM_SEALFINAL), "PEM_SealFinal"},
@@ -93,6 +106,7 @@ static ERR_STRING_DATA PEM_str_functs[]=
93{ERR_FUNC(PEM_F_PEM_SIGNFINAL), "PEM_SignFinal"}, 106{ERR_FUNC(PEM_F_PEM_SIGNFINAL), "PEM_SignFinal"},
94{ERR_FUNC(PEM_F_PEM_WRITE), "PEM_write"}, 107{ERR_FUNC(PEM_F_PEM_WRITE), "PEM_write"},
95{ERR_FUNC(PEM_F_PEM_WRITE_BIO), "PEM_write_bio"}, 108{ERR_FUNC(PEM_F_PEM_WRITE_BIO), "PEM_write_bio"},
109{ERR_FUNC(PEM_F_PEM_WRITE_PRIVATEKEY), "PEM_WRITE_PRIVATEKEY"},
96{ERR_FUNC(PEM_F_PEM_X509_INFO_READ), "PEM_X509_INFO_read"}, 110{ERR_FUNC(PEM_F_PEM_X509_INFO_READ), "PEM_X509_INFO_read"},
97{ERR_FUNC(PEM_F_PEM_X509_INFO_READ_BIO), "PEM_X509_INFO_read_bio"}, 111{ERR_FUNC(PEM_F_PEM_X509_INFO_READ_BIO), "PEM_X509_INFO_read_bio"},
98{ERR_FUNC(PEM_F_PEM_X509_INFO_WRITE_BIO), "PEM_X509_INFO_write_bio"}, 112{ERR_FUNC(PEM_F_PEM_X509_INFO_WRITE_BIO), "PEM_X509_INFO_write_bio"},
@@ -105,18 +119,30 @@ static ERR_STRING_DATA PEM_str_reasons[]=
105{ERR_REASON(PEM_R_BAD_DECRYPT) ,"bad decrypt"}, 119{ERR_REASON(PEM_R_BAD_DECRYPT) ,"bad decrypt"},
106{ERR_REASON(PEM_R_BAD_END_LINE) ,"bad end line"}, 120{ERR_REASON(PEM_R_BAD_END_LINE) ,"bad end line"},
107{ERR_REASON(PEM_R_BAD_IV_CHARS) ,"bad iv chars"}, 121{ERR_REASON(PEM_R_BAD_IV_CHARS) ,"bad iv chars"},
122{ERR_REASON(PEM_R_BAD_MAGIC_NUMBER) ,"bad magic number"},
108{ERR_REASON(PEM_R_BAD_PASSWORD_READ) ,"bad password read"}, 123{ERR_REASON(PEM_R_BAD_PASSWORD_READ) ,"bad password read"},
124{ERR_REASON(PEM_R_BAD_VERSION_NUMBER) ,"bad version number"},
125{ERR_REASON(PEM_R_BIO_WRITE_FAILURE) ,"bio write failure"},
126{ERR_REASON(PEM_R_CIPHER_IS_NULL) ,"cipher is null"},
109{ERR_REASON(PEM_R_ERROR_CONVERTING_PRIVATE_KEY),"error converting private key"}, 127{ERR_REASON(PEM_R_ERROR_CONVERTING_PRIVATE_KEY),"error converting private key"},
128{ERR_REASON(PEM_R_EXPECTING_PRIVATE_KEY_BLOB),"expecting private key blob"},
129{ERR_REASON(PEM_R_EXPECTING_PUBLIC_KEY_BLOB),"expecting public key blob"},
130{ERR_REASON(PEM_R_INCONSISTENT_HEADER) ,"inconsistent header"},
131{ERR_REASON(PEM_R_KEYBLOB_HEADER_PARSE_ERROR),"keyblob header parse error"},
132{ERR_REASON(PEM_R_KEYBLOB_TOO_SHORT) ,"keyblob too short"},
110{ERR_REASON(PEM_R_NOT_DEK_INFO) ,"not dek info"}, 133{ERR_REASON(PEM_R_NOT_DEK_INFO) ,"not dek info"},
111{ERR_REASON(PEM_R_NOT_ENCRYPTED) ,"not encrypted"}, 134{ERR_REASON(PEM_R_NOT_ENCRYPTED) ,"not encrypted"},
112{ERR_REASON(PEM_R_NOT_PROC_TYPE) ,"not proc type"}, 135{ERR_REASON(PEM_R_NOT_PROC_TYPE) ,"not proc type"},
113{ERR_REASON(PEM_R_NO_START_LINE) ,"no start line"}, 136{ERR_REASON(PEM_R_NO_START_LINE) ,"no start line"},
114{ERR_REASON(PEM_R_PROBLEMS_GETTING_PASSWORD),"problems getting password"}, 137{ERR_REASON(PEM_R_PROBLEMS_GETTING_PASSWORD),"problems getting password"},
115{ERR_REASON(PEM_R_PUBLIC_KEY_NO_RSA) ,"public key no rsa"}, 138{ERR_REASON(PEM_R_PUBLIC_KEY_NO_RSA) ,"public key no rsa"},
139{ERR_REASON(PEM_R_PVK_DATA_TOO_SHORT) ,"pvk data too short"},
140{ERR_REASON(PEM_R_PVK_TOO_SHORT) ,"pvk too short"},
116{ERR_REASON(PEM_R_READ_KEY) ,"read key"}, 141{ERR_REASON(PEM_R_READ_KEY) ,"read key"},
117{ERR_REASON(PEM_R_SHORT_HEADER) ,"short header"}, 142{ERR_REASON(PEM_R_SHORT_HEADER) ,"short header"},
118{ERR_REASON(PEM_R_UNSUPPORTED_CIPHER) ,"unsupported cipher"}, 143{ERR_REASON(PEM_R_UNSUPPORTED_CIPHER) ,"unsupported cipher"},
119{ERR_REASON(PEM_R_UNSUPPORTED_ENCRYPTION),"unsupported encryption"}, 144{ERR_REASON(PEM_R_UNSUPPORTED_ENCRYPTION),"unsupported encryption"},
145{ERR_REASON(PEM_R_UNSUPPORTED_KEY_COMPONENTS),"unsupported key components"},
120{0,NULL} 146{0,NULL}
121 }; 147 };
122 148
diff --git a/src/lib/libcrypto/pem/pem_info.c b/src/lib/libcrypto/pem/pem_info.c
index 3a273f6f70..1b2be527ed 100644
--- a/src/lib/libcrypto/pem/pem_info.c
+++ b/src/lib/libcrypto/pem/pem_info.c
@@ -98,8 +98,8 @@ STACK_OF(X509_INFO) *PEM_X509_INFO_read_bio(BIO *bp, STACK_OF(X509_INFO) *sk, pe
98 long len,error=0; 98 long len,error=0;
99 int ok=0; 99 int ok=0;
100 STACK_OF(X509_INFO) *ret=NULL; 100 STACK_OF(X509_INFO) *ret=NULL;
101 unsigned int i,raw; 101 unsigned int i,raw,ptype;
102 d2i_of_void *d2i; 102 d2i_of_void *d2i = 0;
103 103
104 if (sk == NULL) 104 if (sk == NULL)
105 { 105 {
@@ -116,6 +116,7 @@ STACK_OF(X509_INFO) *PEM_X509_INFO_read_bio(BIO *bp, STACK_OF(X509_INFO) *sk, pe
116 for (;;) 116 for (;;)
117 { 117 {
118 raw=0; 118 raw=0;
119 ptype = 0;
119 i=PEM_read_bio(bp,&name,&header,&data,&len); 120 i=PEM_read_bio(bp,&name,&header,&data,&len);
120 if (i == 0) 121 if (i == 0)
121 { 122 {
@@ -166,7 +167,6 @@ start:
166#ifndef OPENSSL_NO_RSA 167#ifndef OPENSSL_NO_RSA
167 if (strcmp(name,PEM_STRING_RSA) == 0) 168 if (strcmp(name,PEM_STRING_RSA) == 0)
168 { 169 {
169 d2i=(D2I_OF(void))d2i_RSAPrivateKey;
170 if (xi->x_pkey != NULL) 170 if (xi->x_pkey != NULL)
171 { 171 {
172 if (!sk_X509_INFO_push(ret,xi)) goto err; 172 if (!sk_X509_INFO_push(ret,xi)) goto err;
@@ -178,10 +178,8 @@ start:
178 xi->enc_len=0; 178 xi->enc_len=0;
179 179
180 xi->x_pkey=X509_PKEY_new(); 180 xi->x_pkey=X509_PKEY_new();
181 if ((xi->x_pkey->dec_pkey=EVP_PKEY_new()) == NULL) 181 ptype=EVP_PKEY_RSA;
182 goto err; 182 pp=&xi->x_pkey->dec_pkey;
183 xi->x_pkey->dec_pkey->type=EVP_PKEY_RSA;
184 pp=&(xi->x_pkey->dec_pkey->pkey.rsa);
185 if ((int)strlen(header) > 10) /* assume encrypted */ 183 if ((int)strlen(header) > 10) /* assume encrypted */
186 raw=1; 184 raw=1;
187 } 185 }
@@ -202,10 +200,8 @@ start:
202 xi->enc_len=0; 200 xi->enc_len=0;
203 201
204 xi->x_pkey=X509_PKEY_new(); 202 xi->x_pkey=X509_PKEY_new();
205 if ((xi->x_pkey->dec_pkey=EVP_PKEY_new()) == NULL) 203 ptype = EVP_PKEY_DSA;
206 goto err; 204 pp=&xi->x_pkey->dec_pkey;
207 xi->x_pkey->dec_pkey->type=EVP_PKEY_DSA;
208 pp=&xi->x_pkey->dec_pkey->pkey.dsa;
209 if ((int)strlen(header) > 10) /* assume encrypted */ 205 if ((int)strlen(header) > 10) /* assume encrypted */
210 raw=1; 206 raw=1;
211 } 207 }
@@ -226,10 +222,8 @@ start:
226 xi->enc_len=0; 222 xi->enc_len=0;
227 223
228 xi->x_pkey=X509_PKEY_new(); 224 xi->x_pkey=X509_PKEY_new();
229 if ((xi->x_pkey->dec_pkey=EVP_PKEY_new()) == NULL) 225 ptype = EVP_PKEY_EC;
230 goto err; 226 pp=&xi->x_pkey->dec_pkey;
231 xi->x_pkey->dec_pkey->type=EVP_PKEY_EC;
232 pp=&(xi->x_pkey->dec_pkey->pkey.ec);
233 if ((int)strlen(header) > 10) /* assume encrypted */ 227 if ((int)strlen(header) > 10) /* assume encrypted */
234 raw=1; 228 raw=1;
235 } 229 }
@@ -251,7 +245,15 @@ start:
251 if (!PEM_do_header(&cipher,data,&len,cb,u)) 245 if (!PEM_do_header(&cipher,data,&len,cb,u))
252 goto err; 246 goto err;
253 p=data; 247 p=data;
254 if (d2i(pp,&p,len) == NULL) 248 if (ptype)
249 {
250 if (!d2i_PrivateKey(ptype, pp, &p, len))
251 {
252 PEMerr(PEM_F_PEM_X509_INFO_READ_BIO,ERR_R_ASN1_LIB);
253 goto err;
254 }
255 }
256 else if (d2i(pp,&p,len) == NULL)
255 { 257 {
256 PEMerr(PEM_F_PEM_X509_INFO_READ_BIO,ERR_R_ASN1_LIB); 258 PEMerr(PEM_F_PEM_X509_INFO_READ_BIO,ERR_R_ASN1_LIB);
257 goto err; 259 goto err;
@@ -337,6 +339,12 @@ int PEM_X509_INFO_write_bio(BIO *bp, X509_INFO *xi, EVP_CIPHER *enc,
337 { 339 {
338 if ( (xi->enc_data!=NULL) && (xi->enc_len>0) ) 340 if ( (xi->enc_data!=NULL) && (xi->enc_len>0) )
339 { 341 {
342 if (enc == NULL)
343 {
344 PEMerr(PEM_F_PEM_X509_INFO_WRITE_BIO,PEM_R_CIPHER_IS_NULL);
345 goto err;
346 }
347
340 /* copy from weirdo names into more normal things */ 348 /* copy from weirdo names into more normal things */
341 iv=xi->enc_cipher.iv; 349 iv=xi->enc_cipher.iv;
342 data=(unsigned char *)xi->enc_data; 350 data=(unsigned char *)xi->enc_data;
diff --git a/src/lib/libcrypto/pem/pem_lib.c b/src/lib/libcrypto/pem/pem_lib.c
index cbafefe416..42e4861bc1 100644
--- a/src/lib/libcrypto/pem/pem_lib.c
+++ b/src/lib/libcrypto/pem/pem_lib.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/buffer.h> 62#include <openssl/buffer.h>
62#include <openssl/objects.h> 63#include <openssl/objects.h>
@@ -65,9 +66,13 @@
65#include <openssl/x509.h> 66#include <openssl/x509.h>
66#include <openssl/pem.h> 67#include <openssl/pem.h>
67#include <openssl/pkcs12.h> 68#include <openssl/pkcs12.h>
69#include "asn1_locl.h"
68#ifndef OPENSSL_NO_DES 70#ifndef OPENSSL_NO_DES
69#include <openssl/des.h> 71#include <openssl/des.h>
70#endif 72#endif
73#ifndef OPENSSL_NO_ENGINE
74#include <openssl/engine.h>
75#endif
71 76
72const char PEM_version[]="PEM" OPENSSL_VERSION_PTEXT; 77const char PEM_version[]="PEM" OPENSSL_VERSION_PTEXT;
73 78
@@ -75,6 +80,7 @@ const char PEM_version[]="PEM" OPENSSL_VERSION_PTEXT;
75 80
76static int load_iv(char **fromp,unsigned char *to, int num); 81static int load_iv(char **fromp,unsigned char *to, int num);
77static int check_pem(const char *nm, const char *name); 82static int check_pem(const char *nm, const char *name);
83int pem_check_suffix(const char *pem_str, const char *suffix);
78 84
79int PEM_def_callback(char *buf, int num, int w, void *key) 85int PEM_def_callback(char *buf, int num, int w, void *key)
80 { 86 {
@@ -99,7 +105,7 @@ int PEM_def_callback(char *buf, int num, int w, void *key)
99 105
100 for (;;) 106 for (;;)
101 { 107 {
102 i=EVP_read_pw_string(buf,num,prompt,w); 108 i=EVP_read_pw_string_min(buf,MIN_LENGTH,num,prompt,w);
103 if (i != 0) 109 if (i != 0)
104 { 110 {
105 PEMerr(PEM_F_PEM_DEF_CALLBACK,PEM_R_PROBLEMS_GETTING_PASSWORD); 111 PEMerr(PEM_F_PEM_DEF_CALLBACK,PEM_R_PROBLEMS_GETTING_PASSWORD);
@@ -183,20 +189,54 @@ static int check_pem(const char *nm, const char *name)
183 189
184 /* Make PEM_STRING_EVP_PKEY match any private key */ 190 /* Make PEM_STRING_EVP_PKEY match any private key */
185 191
186 if(!strcmp(nm,PEM_STRING_PKCS8) && 192 if(!strcmp(name,PEM_STRING_EVP_PKEY))
187 !strcmp(name,PEM_STRING_EVP_PKEY)) return 1; 193 {
188 194 int slen;
189 if(!strcmp(nm,PEM_STRING_PKCS8INF) && 195 const EVP_PKEY_ASN1_METHOD *ameth;
190 !strcmp(name,PEM_STRING_EVP_PKEY)) return 1; 196 if(!strcmp(nm,PEM_STRING_PKCS8))
191 197 return 1;
192 if(!strcmp(nm,PEM_STRING_RSA) && 198 if(!strcmp(nm,PEM_STRING_PKCS8INF))
193 !strcmp(name,PEM_STRING_EVP_PKEY)) return 1; 199 return 1;
200 slen = pem_check_suffix(nm, "PRIVATE KEY");
201 if (slen > 0)
202 {
203 /* NB: ENGINE implementations wont contain
204 * a deprecated old private key decode function
205 * so don't look for them.
206 */
207 ameth = EVP_PKEY_asn1_find_str(NULL, nm, slen);
208 if (ameth && ameth->old_priv_decode)
209 return 1;
210 }
211 return 0;
212 }
194 213
195 if(!strcmp(nm,PEM_STRING_DSA) && 214 if(!strcmp(name,PEM_STRING_PARAMETERS))
196 !strcmp(name,PEM_STRING_EVP_PKEY)) return 1; 215 {
216 int slen;
217 const EVP_PKEY_ASN1_METHOD *ameth;
218 slen = pem_check_suffix(nm, "PARAMETERS");
219 if (slen > 0)
220 {
221 ENGINE *e;
222 ameth = EVP_PKEY_asn1_find_str(&e, nm, slen);
223 if (ameth)
224 {
225 int r;
226 if (ameth->param_decode)
227 r = 1;
228 else
229 r = 0;
230#ifndef OPENSSL_NO_ENGINE
231 if (e)
232 ENGINE_finish(e);
233#endif
234 return r;
235 }
236 }
237 return 0;
238 }
197 239
198 if(!strcmp(nm,PEM_STRING_ECPRIVATEKEY) &&
199 !strcmp(name,PEM_STRING_EVP_PKEY)) return 1;
200 /* Permit older strings */ 240 /* Permit older strings */
201 241
202 if(!strcmp(nm,PEM_STRING_X509_OLD) && 242 if(!strcmp(nm,PEM_STRING_X509_OLD) &&
@@ -219,6 +259,14 @@ static int check_pem(const char *nm, const char *name)
219 if(!strcmp(nm, PEM_STRING_PKCS7_SIGNED) && 259 if(!strcmp(nm, PEM_STRING_PKCS7_SIGNED) &&
220 !strcmp(name, PEM_STRING_PKCS7)) return 1; 260 !strcmp(name, PEM_STRING_PKCS7)) return 1;
221 261
262#ifndef OPENSSL_NO_CMS
263 if(!strcmp(nm, PEM_STRING_X509) &&
264 !strcmp(name, PEM_STRING_CMS)) return 1;
265 /* Allow CMS to be read from PKCS#7 headers */
266 if(!strcmp(nm, PEM_STRING_PKCS7) &&
267 !strcmp(name, PEM_STRING_CMS)) return 1;
268#endif
269
222 return 0; 270 return 0;
223} 271}
224 272
@@ -264,7 +312,7 @@ err:
264 312
265#ifndef OPENSSL_NO_FP_API 313#ifndef OPENSSL_NO_FP_API
266int PEM_ASN1_write(i2d_of_void *i2d, const char *name, FILE *fp, 314int PEM_ASN1_write(i2d_of_void *i2d, const char *name, FILE *fp,
267 char *x, const EVP_CIPHER *enc, unsigned char *kstr, 315 void *x, const EVP_CIPHER *enc, unsigned char *kstr,
268 int klen, pem_password_cb *callback, void *u) 316 int klen, pem_password_cb *callback, void *u)
269 { 317 {
270 BIO *b; 318 BIO *b;
@@ -283,7 +331,7 @@ int PEM_ASN1_write(i2d_of_void *i2d, const char *name, FILE *fp,
283#endif 331#endif
284 332
285int PEM_ASN1_write_bio(i2d_of_void *i2d, const char *name, BIO *bp, 333int PEM_ASN1_write_bio(i2d_of_void *i2d, const char *name, BIO *bp,
286 char *x, const EVP_CIPHER *enc, unsigned char *kstr, 334 void *x, const EVP_CIPHER *enc, unsigned char *kstr,
287 int klen, pem_password_cb *callback, void *u) 335 int klen, pem_password_cb *callback, void *u)
288 { 336 {
289 EVP_CIPHER_CTX ctx; 337 EVP_CIPHER_CTX ctx;
@@ -782,3 +830,25 @@ err:
782 BUF_MEM_free(dataB); 830 BUF_MEM_free(dataB);
783 return(0); 831 return(0);
784 } 832 }
833
834/* Check pem string and return prefix length.
835 * If for example the pem_str == "RSA PRIVATE KEY" and suffix = "PRIVATE KEY"
836 * the return value is 3 for the string "RSA".
837 */
838
839int pem_check_suffix(const char *pem_str, const char *suffix)
840 {
841 int pem_len = strlen(pem_str);
842 int suffix_len = strlen(suffix);
843 const char *p;
844 if (suffix_len + 1 >= pem_len)
845 return 0;
846 p = pem_str + pem_len - suffix_len;
847 if (strcmp(p, suffix))
848 return 0;
849 p--;
850 if (*p != ' ')
851 return 0;
852 return p - pem_str;
853 }
854
diff --git a/src/lib/libcrypto/pem/pem_pkey.c b/src/lib/libcrypto/pem/pem_pkey.c
index 4da4c31ce5..8ecf24903b 100644
--- a/src/lib/libcrypto/pem/pem_pkey.c
+++ b/src/lib/libcrypto/pem/pem_pkey.c
@@ -65,7 +65,12 @@
65#include <openssl/x509.h> 65#include <openssl/x509.h>
66#include <openssl/pkcs12.h> 66#include <openssl/pkcs12.h>
67#include <openssl/pem.h> 67#include <openssl/pem.h>
68#ifndef OPENSSL_NO_ENGINE
69#include <openssl/engine.h>
70#endif
71#include "asn1_locl.h"
68 72
73int pem_check_suffix(const char *pem_str, const char *suffix);
69 74
70EVP_PKEY *PEM_read_bio_PrivateKey(BIO *bp, EVP_PKEY **x, pem_password_cb *cb, void *u) 75EVP_PKEY *PEM_read_bio_PrivateKey(BIO *bp, EVP_PKEY **x, pem_password_cb *cb, void *u)
71 { 76 {
@@ -73,19 +78,14 @@ EVP_PKEY *PEM_read_bio_PrivateKey(BIO *bp, EVP_PKEY **x, pem_password_cb *cb, vo
73 const unsigned char *p=NULL; 78 const unsigned char *p=NULL;
74 unsigned char *data=NULL; 79 unsigned char *data=NULL;
75 long len; 80 long len;
81 int slen;
76 EVP_PKEY *ret=NULL; 82 EVP_PKEY *ret=NULL;
77 83
78 if (!PEM_bytes_read_bio(&data, &len, &nm, PEM_STRING_EVP_PKEY, bp, cb, u)) 84 if (!PEM_bytes_read_bio(&data, &len, &nm, PEM_STRING_EVP_PKEY, bp, cb, u))
79 return NULL; 85 return NULL;
80 p = data; 86 p = data;
81 87
82 if (strcmp(nm,PEM_STRING_RSA) == 0) 88 if (strcmp(nm,PEM_STRING_PKCS8INF) == 0) {
83 ret=d2i_PrivateKey(EVP_PKEY_RSA,x,&p,len);
84 else if (strcmp(nm,PEM_STRING_DSA) == 0)
85 ret=d2i_PrivateKey(EVP_PKEY_DSA,x,&p,len);
86 else if (strcmp(nm,PEM_STRING_ECPRIVATEKEY) == 0)
87 ret=d2i_PrivateKey(EVP_PKEY_EC,x,&p,len);
88 else if (strcmp(nm,PEM_STRING_PKCS8INF) == 0) {
89 PKCS8_PRIV_KEY_INFO *p8inf; 89 PKCS8_PRIV_KEY_INFO *p8inf;
90 p8inf=d2i_PKCS8_PRIV_KEY_INFO(NULL, &p, len); 90 p8inf=d2i_PKCS8_PRIV_KEY_INFO(NULL, &p, len);
91 if(!p8inf) goto p8err; 91 if(!p8inf) goto p8err;
@@ -119,7 +119,14 @@ EVP_PKEY *PEM_read_bio_PrivateKey(BIO *bp, EVP_PKEY **x, pem_password_cb *cb, vo
119 *x = ret; 119 *x = ret;
120 } 120 }
121 PKCS8_PRIV_KEY_INFO_free(p8inf); 121 PKCS8_PRIV_KEY_INFO_free(p8inf);
122 } 122 } else if ((slen = pem_check_suffix(nm, "PRIVATE KEY")) > 0)
123 {
124 const EVP_PKEY_ASN1_METHOD *ameth;
125 ameth = EVP_PKEY_asn1_find_str(NULL, nm, slen);
126 if (!ameth || !ameth->old_priv_decode)
127 goto p8err;
128 ret=d2i_PrivateKey(ameth->pkey_id,x,&p,len);
129 }
123p8err: 130p8err:
124 if (ret == NULL) 131 if (ret == NULL)
125 PEMerr(PEM_F_PEM_READ_BIO_PRIVATEKEY,ERR_R_ASN1_LIB); 132 PEMerr(PEM_F_PEM_READ_BIO_PRIVATEKEY,ERR_R_ASN1_LIB);
@@ -130,6 +137,74 @@ err:
130 return(ret); 137 return(ret);
131 } 138 }
132 139
140int PEM_write_bio_PrivateKey(BIO *bp, EVP_PKEY *x, const EVP_CIPHER *enc,
141 unsigned char *kstr, int klen,
142 pem_password_cb *cb, void *u)
143 {
144 char pem_str[80];
145 if (!x->ameth || x->ameth->priv_encode)
146 return PEM_write_bio_PKCS8PrivateKey(bp, x, enc,
147 (char *)kstr, klen,
148 cb, u);
149
150 BIO_snprintf(pem_str, 80, "%s PRIVATE KEY", x->ameth->pem_str);
151 return PEM_ASN1_write_bio((i2d_of_void *)i2d_PrivateKey,
152 pem_str,bp,x,enc,kstr,klen,cb,u);
153 }
154
155EVP_PKEY *PEM_read_bio_Parameters(BIO *bp, EVP_PKEY **x)
156 {
157 char *nm=NULL;
158 const unsigned char *p=NULL;
159 unsigned char *data=NULL;
160 long len;
161 int slen;
162 EVP_PKEY *ret=NULL;
163
164 if (!PEM_bytes_read_bio(&data, &len, &nm, PEM_STRING_PARAMETERS,
165 bp, 0, NULL))
166 return NULL;
167 p = data;
168
169 if ((slen = pem_check_suffix(nm, "PARAMETERS")) > 0)
170 {
171 ret = EVP_PKEY_new();
172 if (!ret)
173 goto err;
174 if (!EVP_PKEY_set_type_str(ret, nm, slen)
175 || !ret->ameth->param_decode
176 || !ret->ameth->param_decode(ret, &p, len))
177 {
178 EVP_PKEY_free(ret);
179 ret = NULL;
180 goto err;
181 }
182 if(x)
183 {
184 if(*x) EVP_PKEY_free((EVP_PKEY *)*x);
185 *x = ret;
186 }
187 }
188err:
189 if (ret == NULL)
190 PEMerr(PEM_F_PEM_READ_BIO_PARAMETERS,ERR_R_ASN1_LIB);
191 OPENSSL_free(nm);
192 OPENSSL_free(data);
193 return(ret);
194 }
195
196int PEM_write_bio_Parameters(BIO *bp, EVP_PKEY *x)
197 {
198 char pem_str[80];
199 if (!x->ameth || !x->ameth->param_encode)
200 return 0;
201
202 BIO_snprintf(pem_str, 80, "%s PARAMETERS", x->ameth->pem_str);
203 return PEM_ASN1_write_bio(
204 (i2d_of_void *)x->ameth->param_encode,
205 pem_str,bp,x,NULL,NULL,0,0,NULL);
206 }
207
133#ifndef OPENSSL_NO_FP_API 208#ifndef OPENSSL_NO_FP_API
134EVP_PKEY *PEM_read_PrivateKey(FILE *fp, EVP_PKEY **x, pem_password_cb *cb, void *u) 209EVP_PKEY *PEM_read_PrivateKey(FILE *fp, EVP_PKEY **x, pem_password_cb *cb, void *u)
135 { 210 {
@@ -146,4 +221,22 @@ EVP_PKEY *PEM_read_PrivateKey(FILE *fp, EVP_PKEY **x, pem_password_cb *cb, void
146 BIO_free(b); 221 BIO_free(b);
147 return(ret); 222 return(ret);
148 } 223 }
224
225int PEM_write_PrivateKey(FILE *fp, EVP_PKEY *x, const EVP_CIPHER *enc,
226 unsigned char *kstr, int klen,
227 pem_password_cb *cb, void *u)
228 {
229 BIO *b;
230 int ret;
231
232 if ((b=BIO_new_fp(fp, BIO_NOCLOSE)) == NULL)
233 {
234 PEMerr(PEM_F_PEM_WRITE_PRIVATEKEY,ERR_R_BUF_LIB);
235 return 0;
236 }
237 ret=PEM_write_bio_PrivateKey(b, x, enc, kstr, klen, cb, u);
238 BIO_free(b);
239 return ret;
240 }
241
149#endif 242#endif
diff --git a/src/lib/libcrypto/pem/pem_seal.c b/src/lib/libcrypto/pem/pem_seal.c
index 4e554e5481..59690b56ae 100644
--- a/src/lib/libcrypto/pem/pem_seal.c
+++ b/src/lib/libcrypto/pem/pem_seal.c
@@ -100,7 +100,7 @@ int PEM_SealInit(PEM_ENCODE_SEAL_CTX *ctx, EVP_CIPHER *type, EVP_MD *md_type,
100 100
101 EVP_CIPHER_CTX_init(&ctx->cipher); 101 EVP_CIPHER_CTX_init(&ctx->cipher);
102 ret=EVP_SealInit(&ctx->cipher,type,ek,ekl,iv,pubk,npubk); 102 ret=EVP_SealInit(&ctx->cipher,type,ek,ekl,iv,pubk,npubk);
103 if (!ret) goto err; 103 if (ret <= 0) goto err;
104 104
105 /* base64 encode the keys */ 105 /* base64 encode the keys */
106 for (i=0; i<npubk; i++) 106 for (i=0; i<npubk; i++)
diff --git a/src/lib/libcrypto/pem/pem_x509.c b/src/lib/libcrypto/pem/pem_x509.c
index 3f709f13e6..b531057dc9 100644
--- a/src/lib/libcrypto/pem/pem_x509.c
+++ b/src/lib/libcrypto/pem/pem_x509.c
@@ -57,7 +57,6 @@
57 */ 57 */
58 58
59#include <stdio.h> 59#include <stdio.h>
60#undef SSLEAY_MACROS
61#include "cryptlib.h" 60#include "cryptlib.h"
62#include <openssl/bio.h> 61#include <openssl/bio.h>
63#include <openssl/evp.h> 62#include <openssl/evp.h>
diff --git a/src/lib/libcrypto/pem/pem_xaux.c b/src/lib/libcrypto/pem/pem_xaux.c
index 7cc7491009..328f796200 100644
--- a/src/lib/libcrypto/pem/pem_xaux.c
+++ b/src/lib/libcrypto/pem/pem_xaux.c
@@ -57,7 +57,6 @@
57 */ 57 */
58 58
59#include <stdio.h> 59#include <stdio.h>
60#undef SSLEAY_MACROS
61#include "cryptlib.h" 60#include "cryptlib.h"
62#include <openssl/bio.h> 61#include <openssl/bio.h>
63#include <openssl/evp.h> 62#include <openssl/evp.h>
diff --git a/src/lib/libcrypto/perlasm/alpha.pl b/src/lib/libcrypto/perlasm/alpha.pl
deleted file mode 100644
index 3dac571743..0000000000
--- a/src/lib/libcrypto/perlasm/alpha.pl
+++ /dev/null
@@ -1,434 +0,0 @@
1#!/usr/local/bin/perl
2
3package alpha;
4use Carp qw(croak cluck);
5
6$label="100";
7
8$n_debug=0;
9$smear_regs=1;
10$reg_alloc=1;
11
12$align="3";
13$com_start="#";
14
15sub main'asm_init_output { @out=(); }
16sub main'asm_get_output { return(@out); }
17sub main'get_labels { return(@labels); }
18sub main'external_label { push(@labels,@_); }
19
20# General registers
21
22%regs=( 'r0', '$0',
23 'r1', '$1',
24 'r2', '$2',
25 'r3', '$3',
26 'r4', '$4',
27 'r5', '$5',
28 'r6', '$6',
29 'r7', '$7',
30 'r8', '$8',
31 'r9', '$22',
32 'r10', '$23',
33 'r11', '$24',
34 'r12', '$25',
35 'r13', '$27',
36 'r14', '$28',
37 'r15', '$21', # argc == 5
38 'r16', '$20', # argc == 4
39 'r17', '$19', # argc == 3
40 'r18', '$18', # argc == 2
41 'r19', '$17', # argc == 1
42 'r20', '$16', # argc == 0
43 'r21', '$9', # save 0
44 'r22', '$10', # save 1
45 'r23', '$11', # save 2
46 'r24', '$12', # save 3
47 'r25', '$13', # save 4
48 'r26', '$14', # save 5
49
50 'a0', '$16',
51 'a1', '$17',
52 'a2', '$18',
53 'a3', '$19',
54 'a4', '$20',
55 'a5', '$21',
56
57 's0', '$9',
58 's1', '$10',
59 's2', '$11',
60 's3', '$12',
61 's4', '$13',
62 's5', '$14',
63 'zero', '$31',
64 'sp', '$30',
65 );
66
67$main'reg_s0="r21";
68$main'reg_s1="r22";
69$main'reg_s2="r23";
70$main'reg_s3="r24";
71$main'reg_s4="r25";
72$main'reg_s5="r26";
73
74@reg=( '$0', '$1' ,'$2' ,'$3' ,'$4' ,'$5' ,'$6' ,'$7' ,'$8',
75 '$22','$23','$24','$25','$20','$21','$27','$28');
76
77
78sub main'sub { &out3("subq",@_); }
79sub main'add { &out3("addq",@_); }
80sub main'mov { &out3("bis",$_[0],$_[0],$_[1]); }
81sub main'or { &out3("bis",@_); }
82sub main'bis { &out3("bis",@_); }
83sub main'br { &out1("br",@_); }
84sub main'ld { &out2("ldq",@_); }
85sub main'st { &out2("stq",@_); }
86sub main'cmpult { &out3("cmpult",@_); }
87sub main'cmplt { &out3("cmplt",@_); }
88sub main'bgt { &out2("bgt",@_); }
89sub main'ble { &out2("ble",@_); }
90sub main'blt { &out2("blt",@_); }
91sub main'mul { &out3("mulq",@_); }
92sub main'muh { &out3("umulh",@_); }
93
94$main'QWS=8;
95
96sub main'asm_add
97 {
98 push(@out,@_);
99 }
100
101sub main'asm_finish
102 {
103 &main'file_end();
104 print &main'asm_get_output();
105 }
106
107sub main'asm_init
108 {
109 ($type,$fn)=@_;
110 $filename=$fn;
111
112 &main'asm_init_output();
113 &main'comment("Don't even think of reading this code");
114 &main'comment("It was automatically generated by $filename");
115 &main'comment("Which is a perl program used to generate the alpha assember.");
116 &main'comment("eric <eay\@cryptsoft.com>");
117 &main'comment("");
118
119 $filename =~ s/\.pl$//;
120 &main'file($filename);
121 }
122
123sub conv
124 {
125 local($r)=@_;
126 local($v);
127
128 return($regs{$r}) if defined($regs{$r});
129 return($r);
130 }
131
132sub main'QWPw
133 {
134 local($off,$reg)=@_;
135
136 return(&main'QWP($off*8,$reg));
137 }
138
139sub main'QWP
140 {
141 local($off,$reg)=@_;
142
143 $ret="$off(".&conv($reg).")";
144 return($ret);
145 }
146
147sub out3
148 {
149 local($name,$p1,$p2,$p3)=@_;
150
151 $p1=&conv($p1);
152 $p2=&conv($p2);
153 $p3=&conv($p3);
154 push(@out,"\t$name\t");
155 $l=length($p1)+1;
156 push(@out,$p1.",");
157 $ll=3-($l+9)/8;
158 $tmp1=sprintf("\t" x $ll);
159 push(@out,$tmp1);
160
161 $l=length($p2)+1;
162 push(@out,$p2.",");
163 $ll=3-($l+9)/8;
164 $tmp1=sprintf("\t" x $ll);
165 push(@out,$tmp1);
166
167 push(@out,&conv($p3)."\n");
168 }
169
170sub out2
171 {
172 local($name,$p1,$p2,$p3)=@_;
173
174 $p1=&conv($p1);
175 $p2=&conv($p2);
176 push(@out,"\t$name\t");
177 $l=length($p1)+1;
178 push(@out,$p1.",");
179 $ll=3-($l+9)/8;
180 $tmp1=sprintf("\t" x $ll);
181 push(@out,$tmp1);
182
183 push(@out,&conv($p2)."\n");
184 }
185
186sub out1
187 {
188 local($name,$p1)=@_;
189
190 $p1=&conv($p1);
191 push(@out,"\t$name\t".$p1."\n");
192 }
193
194sub out0
195 {
196 push(@out,"\t$_[0]\n");
197 }
198
199sub main'file
200 {
201 local($file)=@_;
202
203 local($tmp)=<<"EOF";
204 # DEC Alpha assember
205 # Generated from perl scripts contains in SSLeay
206 .file 1 "$file.s"
207 .set noat
208EOF
209 push(@out,$tmp);
210 }
211
212sub main'function_begin
213 {
214 local($func)=@_;
215
216print STDERR "$func\n";
217 local($tmp)=<<"EOF";
218 .text
219 .align $align
220 .globl $func
221 .ent $func
222${func}:
223${func}..ng:
224 .frame \$30,0,\$26,0
225 .prologue 0
226EOF
227 push(@out,$tmp);
228 $stack=0;
229 }
230
231sub main'function_end
232 {
233 local($func)=@_;
234
235 local($tmp)=<<"EOF";
236 ret \$31,(\$26),1
237 .end $func
238EOF
239 push(@out,$tmp);
240 $stack=0;
241 %label=();
242 }
243
244sub main'function_end_A
245 {
246 local($func)=@_;
247
248 local($tmp)=<<"EOF";
249 ret \$31,(\$26),1
250EOF
251 push(@out,$tmp);
252 }
253
254sub main'function_end_B
255 {
256 local($func)=@_;
257
258 $func=$under.$func;
259
260 push(@out,"\t.end $func\n");
261 $stack=0;
262 %label=();
263 }
264
265sub main'wparam
266 {
267 local($num)=@_;
268
269 if ($num < 6)
270 {
271 $num=20-$num;
272 return("r$num");
273 }
274 else
275 { return(&main'QWP($stack+$num*8,"sp")); }
276 }
277
278sub main'stack_push
279 {
280 local($num)=@_;
281 $stack+=$num*8;
282 &main'sub("sp",$num*8,"sp");
283 }
284
285sub main'stack_pop
286 {
287 local($num)=@_;
288 $stack-=$num*8;
289 &main'add("sp",$num*8,"sp");
290 }
291
292sub main'swtmp
293 {
294 return(&main'QWP(($_[0])*8,"sp"));
295 }
296
297# Should use swtmp, which is above sp. Linix can trash the stack above esp
298#sub main'wtmp
299# {
300# local($num)=@_;
301#
302# return(&main'QWP(-($num+1)*4,"esp","",0));
303# }
304
305sub main'comment
306 {
307 foreach (@_)
308 {
309 if (/^\s*$/)
310 { push(@out,"\n"); }
311 else
312 { push(@out,"\t$com_start $_ $com_end\n"); }
313 }
314 }
315
316sub main'label
317 {
318 if (!defined($label{$_[0]}))
319 {
320 $label{$_[0]}=$label;
321 $label++;
322 }
323 return('$'.$label{$_[0]});
324 }
325
326sub main'set_label
327 {
328 if (!defined($label{$_[0]}))
329 {
330 $label{$_[0]}=$label;
331 $label++;
332 }
333# push(@out,".align $align\n") if ($_[1] != 0);
334 push(@out,'$'."$label{$_[0]}:\n");
335 }
336
337sub main'file_end
338 {
339 }
340
341sub main'data_word
342 {
343 push(@out,"\t.long $_[0]\n");
344 }
345
346@pool_free=();
347@pool_taken=();
348$curr_num=0;
349$max=0;
350
351sub main'init_pool
352 {
353 local($args)=@_;
354 local($i);
355
356 @pool_free=();
357 for ($i=(14+(6-$args)); $i >= 0; $i--)
358 {
359 push(@pool_free,"r$i");
360 }
361 print STDERR "START :register pool:@pool_free\n";
362 $curr_num=$max=0;
363 }
364
365sub main'fin_pool
366 {
367 printf STDERR "END %2d:register pool:@pool_free\n",$max;
368 }
369
370sub main'GR
371 {
372 local($r)=@_;
373 local($i,@n,$_);
374
375 foreach (@pool_free)
376 {
377 if ($r ne $_)
378 { push(@n,$_); }
379 else
380 {
381 $curr_num++;
382 $max=$curr_num if ($curr_num > $max);
383 }
384 }
385 @pool_free=@n;
386print STDERR "GR:@pool_free\n" if $reg_alloc;
387 return(@_);
388 }
389
390sub main'NR
391 {
392 local($num)=@_;
393 local(@ret);
394
395 $num=1 if $num == 0;
396 ($#pool_free >= ($num-1)) || croak "out of registers: want $num, have @pool_free";
397 while ($num > 0)
398 {
399 push(@ret,pop @pool_free);
400 $curr_num++;
401 $max=$curr_num if ($curr_num > $max);
402 $num--
403 }
404 print STDERR "nr @ret\n" if $n_debug;
405print STDERR "NR:@pool_free\n" if $reg_alloc;
406 return(@ret);
407
408 }
409
410sub main'FR
411 {
412 local(@r)=@_;
413 local(@a,$v,$w);
414
415 print STDERR "fr @r\n" if $n_debug;
416# cluck "fr @r";
417 for $w (@pool_free)
418 {
419 foreach $v (@r)
420 {
421 croak "double register free of $v (@pool_free)" if $w eq $v;
422 }
423 }
424 foreach $v (@r)
425 {
426 croak "bad argument to FR" if ($v !~ /^r\d+$/);
427 if ($smear_regs)
428 { unshift(@pool_free,$v); }
429 else { push(@pool_free,$v); }
430 $curr_num--;
431 }
432print STDERR "FR:@pool_free\n" if $reg_alloc;
433 }
4341;
diff --git a/src/lib/libcrypto/perlasm/x86_64-xlate.pl b/src/lib/libcrypto/perlasm/x86_64-xlate.pl
index 74153b017d..8153a92a7b 100755
--- a/src/lib/libcrypto/perlasm/x86_64-xlate.pl
+++ b/src/lib/libcrypto/perlasm/x86_64-xlate.pl
@@ -1,6 +1,6 @@
1#!/usr/bin/env perl 1#!/usr/bin/env perl
2 2
3# Ascetic x86_64 AT&T to MASM assembler translator by <appro>. 3# Ascetic x86_64 AT&T to MASM/NASM assembler translator by <appro>.
4# 4#
5# Why AT&T to MASM and not vice versa? Several reasons. Because AT&T 5# Why AT&T to MASM and not vice versa? Several reasons. Because AT&T
6# format is way easier to parse. Because it's simpler to "gear" from 6# format is way easier to parse. Because it's simpler to "gear" from
@@ -20,12 +20,11 @@
20# Currently recognized limitations: 20# Currently recognized limitations:
21# 21#
22# - can't use multiple ops per line; 22# - can't use multiple ops per line;
23# - indirect calls and jumps are not supported;
24# 23#
25# Dual-ABI styling rules. 24# Dual-ABI styling rules.
26# 25#
27# 1. Adhere to Unix register and stack layout [see the end for 26# 1. Adhere to Unix register and stack layout [see cross-reference
28# explanation]. 27# ABI "card" at the end for explanation].
29# 2. Forget about "red zone," stick to more traditional blended 28# 2. Forget about "red zone," stick to more traditional blended
30# stack frame allocation. If volatile storage is actually required 29# stack frame allocation. If volatile storage is actually required
31# that is. If not, just leave the stack as is. 30# that is. If not, just leave the stack as is.
@@ -42,21 +41,26 @@
42# 6. Don't use [or hand-code with .byte] "rep ret." "ret" mnemonic is 41# 6. Don't use [or hand-code with .byte] "rep ret." "ret" mnemonic is
43# required to identify the spots, where to inject Win64 epilogue! 42# required to identify the spots, where to inject Win64 epilogue!
44# But on the pros, it's then prefixed with rep automatically:-) 43# But on the pros, it's then prefixed with rep automatically:-)
45# 7. Due to MASM limitations [and certain general counter-intuitivity 44# 7. Stick to explicit ip-relative addressing. If you have to use
46# of ip-relative addressing] generation of position-independent 45# GOTPCREL addressing, stick to mov symbol@GOTPCREL(%rip),%r??.
47# code is assisted by synthetic directive, .picmeup, which puts 46# Both are recognized and translated to proper Win64 addressing
48# address of the *next* instruction into target register. 47# modes. To support legacy code a synthetic directive, .picmeup,
48# is implemented. It puts address of the *next* instruction into
49# target register, e.g.:
49# 50#
50# Example 1:
51# .picmeup %rax 51# .picmeup %rax
52# lea .Label-.(%rax),%rax 52# lea .Label-.(%rax),%rax
53# Example 2: 53#
54# .picmeup %rcx 54# 8. In order to provide for structured exception handling unified
55# .Lpic_point: 55# Win64 prologue copies %rsp value to %rax. For further details
56# ... 56# see SEH paragraph at the end.
57# lea .Label-.Lpic_point(%rcx),%rbp 57# 9. .init segment is allowed to contain calls to functions only.
58 58# a. If function accepts more than 4 arguments *and* >4th argument
59my $output = shift; 59# is declared as non 64-bit value, do clear its upper part.
60
61my $flavour = shift;
62my $output = shift;
63if ($flavour =~ /\./) { $output = $flavour; undef $flavour; }
60 64
61{ my ($stddev,$stdino,@junk)=stat(STDOUT); 65{ my ($stddev,$stdino,@junk)=stat(STDOUT);
62 my ($outdev,$outino,@junk)=stat($output); 66 my ($outdev,$outino,@junk)=stat($output);
@@ -65,13 +69,40 @@ my $output = shift;
65 if ($stddev!=$outdev || $stdino!=$outino); 69 if ($stddev!=$outdev || $stdino!=$outino);
66} 70}
67 71
72my $gas=1; $gas=0 if ($output =~ /\.asm$/);
73my $elf=1; $elf=0 if (!$gas);
74my $win64=0;
75my $prefix="";
76my $decor=".L";
77
68my $masmref=8 + 50727*2**-32; # 8.00.50727 shipped with VS2005 78my $masmref=8 + 50727*2**-32; # 8.00.50727 shipped with VS2005
69my $masm=$masmref if ($output =~ /\.asm/); 79my $masm=0;
70if ($masm && `ml64 2>&1` =~ m/Version ([0-9]+)\.([0-9]+)(\.([0-9]+))?/) 80my $PTR=" PTR";
71{ $masm=$1 + $2*2**-16 + $4*2**-32; } 81
82my $nasmref=2.03;
83my $nasm=0;
84
85if ($flavour eq "mingw64") { $gas=1; $elf=0; $win64=1;
86 $prefix=`echo __USER_LABEL_PREFIX__ | $ENV{CC} -E -P -`;
87 chomp($prefix);
88 }
89elsif ($flavour eq "macosx") { $gas=1; $elf=0; $prefix="_"; $decor="L\$"; }
90elsif ($flavour eq "masm") { $gas=0; $elf=0; $masm=$masmref; $win64=1; $decor="\$L\$"; }
91elsif ($flavour eq "nasm") { $gas=0; $elf=0; $nasm=$nasmref; $win64=1; $decor="\$L\$"; $PTR=""; }
92elsif (!$gas)
93{ if ($ENV{ASM} =~ m/nasm/ && `nasm -v` =~ m/version ([0-9]+)\.([0-9]+)/i)
94 { $nasm = $1 + $2*0.01; $PTR=""; }
95 elsif (`ml64 2>&1` =~ m/Version ([0-9]+)\.([0-9]+)(\.([0-9]+))?/)
96 { $masm = $1 + $2*2**-16 + $4*2**-32; }
97 die "no assembler found on %PATH" if (!($nasm || $masm));
98 $win64=1;
99 $elf=0;
100 $decor="\$L\$";
101}
72 102
73my $current_segment; 103my $current_segment;
74my $current_function; 104my $current_function;
105my %globals;
75 106
76{ package opcode; # pick up opcodes 107{ package opcode; # pick up opcodes
77 sub re { 108 sub re {
@@ -88,8 +119,10 @@ my $current_function;
88 if ($self->{op} =~ /^(movz)b.*/) { # movz is pain... 119 if ($self->{op} =~ /^(movz)b.*/) { # movz is pain...
89 $self->{op} = $1; 120 $self->{op} = $1;
90 $self->{sz} = "b"; 121 $self->{sz} = "b";
91 } elsif ($self->{op} =~ /call/) { 122 } elsif ($self->{op} =~ /call|jmp/) {
92 $self->{sz} = "" 123 $self->{sz} = "";
124 } elsif ($self->{op} =~ /^p/ && $' !~ /^(ush|op)/) { # SSEn
125 $self->{sz} = "";
93 } elsif ($self->{op} =~ /([a-z]{3,})([qlwb])$/) { 126 } elsif ($self->{op} =~ /([a-z]{3,})([qlwb])$/) {
94 $self->{op} = $1; 127 $self->{op} = $1;
95 $self->{sz} = $2; 128 $self->{sz} = $2;
@@ -105,13 +138,20 @@ my $current_function;
105 } 138 }
106 sub out { 139 sub out {
107 my $self = shift; 140 my $self = shift;
108 if (!$masm) { 141 if ($gas) {
109 if ($self->{op} eq "movz") { # movz is pain... 142 if ($self->{op} eq "movz") { # movz is pain...
110 sprintf "%s%s%s",$self->{op},$self->{sz},shift; 143 sprintf "%s%s%s",$self->{op},$self->{sz},shift;
111 } elsif ($self->{op} =~ /^set/) { 144 } elsif ($self->{op} =~ /^set/) {
112 "$self->{op}"; 145 "$self->{op}";
113 } elsif ($self->{op} eq "ret") { 146 } elsif ($self->{op} eq "ret") {
114 ".byte 0xf3,0xc3"; 147 my $epilogue = "";
148 if ($win64 && $current_function->{abi} eq "svr4") {
149 $epilogue = "movq 8(%rsp),%rdi\n\t" .
150 "movq 16(%rsp),%rsi\n\t";
151 }
152 $epilogue . ".byte 0xf3,0xc3";
153 } elsif ($self->{op} eq "call" && !$elf && $current_segment eq ".init") {
154 ".p2align\t3\n\t.quad";
115 } else { 155 } else {
116 "$self->{op}$self->{sz}"; 156 "$self->{op}$self->{sz}";
117 } 157 }
@@ -119,15 +159,25 @@ my $current_function;
119 $self->{op} =~ s/^movz/movzx/; 159 $self->{op} =~ s/^movz/movzx/;
120 if ($self->{op} eq "ret") { 160 if ($self->{op} eq "ret") {
121 $self->{op} = ""; 161 $self->{op} = "";
122 if ($current_function->{abi} eq "svr4") { 162 if ($win64 && $current_function->{abi} eq "svr4") {
123 $self->{op} = "mov rdi,QWORD PTR 8[rsp]\t;WIN64 epilogue\n\t". 163 $self->{op} = "mov rdi,QWORD${PTR}[8+rsp]\t;WIN64 epilogue\n\t".
124 "mov rsi,QWORD PTR 16[rsp]\n\t"; 164 "mov rsi,QWORD${PTR}[16+rsp]\n\t";
125 } 165 }
126 $self->{op} .= "DB\t0F3h,0C3h\t\t;repret"; 166 $self->{op} .= "DB\t0F3h,0C3h\t\t;repret";
127 } 167 } elsif ($self->{op} =~ /^(pop|push)f/) {
168 $self->{op} .= $self->{sz};
169 } elsif ($self->{op} eq "call" && $current_segment eq ".CRT\$XCU") {
170 $self->{op} = "ALIGN\t8\n\tDQ";
171 }
128 $self->{op}; 172 $self->{op};
129 } 173 }
130 } 174 }
175 sub mnemonic {
176 my $self=shift;
177 my $op=shift;
178 $self->{op}=$op if (defined($op));
179 $self->{op};
180 }
131} 181}
132{ package const; # pick up constants, which start with $ 182{ package const; # pick up constants, which start with $
133 sub re { 183 sub re {
@@ -145,14 +195,15 @@ my $current_function;
145 sub out { 195 sub out {
146 my $self = shift; 196 my $self = shift;
147 197
148 if (!$masm) { 198 if ($gas) {
149 # Solaris /usr/ccs/bin/as can't handle multiplications 199 # Solaris /usr/ccs/bin/as can't handle multiplications
150 # in $self->{value} 200 # in $self->{value}
151 $self->{value} =~ s/(?<![0-9a-f])(0[x0-9a-f]+)/oct($1)/egi; 201 $self->{value} =~ s/(?<![\w\$\.])(0x?[0-9a-f]+)/oct($1)/egi;
152 $self->{value} =~ s/([0-9]+\s*[\*\/\%]\s*[0-9]+)/eval($1)/eg; 202 $self->{value} =~ s/([0-9]+\s*[\*\/\%]\s*[0-9]+)/eval($1)/eg;
153 sprintf "\$%s",$self->{value}; 203 sprintf "\$%s",$self->{value};
154 } else { 204 } else {
155 $self->{value} =~ s/0x([0-9a-f]+)/0$1h/ig; 205 $self->{value} =~ s/(0b[0-1]+)/oct($1)/eig;
206 $self->{value} =~ s/0x([0-9a-f]+)/0$1h/ig if ($masm);
156 sprintf "%s",$self->{value}; 207 sprintf "%s",$self->{value};
157 } 208 }
158 } 209 }
@@ -163,14 +214,20 @@ my $current_function;
163 local *line = shift; 214 local *line = shift;
164 undef $ret; 215 undef $ret;
165 216
166 if ($line =~ /^([^\(,]*)\(([%\w,]+)\)/ && 217 # optional * ---vvv--- appears in indirect jmp/call
218 if ($line =~ /^(\*?)([^\(,]*)\(([%\w,]+)\)/ &&
167 !($line =~ /^PIC_(GOT|PLT)/)) { 219 !($line =~ /^PIC_(GOT|PLT)/)) {
168 $self->{label} = $1; 220 $self->{asterisk} = $1;
169 ($self->{base},$self->{index},$self->{scale})=split(/,/,$2); 221 $self->{label} = $2;
222 ($self->{base},$self->{index},$self->{scale})=split(/,/,$3);
170 $self->{scale} = 1 if (!defined($self->{scale})); 223 $self->{scale} = 1 if (!defined($self->{scale}));
171 $ret = $self; 224 $ret = $self;
172 $line = substr($line,@+[0]); $line =~ s/^\s+//; 225 $line = substr($line,@+[0]); $line =~ s/^\s+//;
173 226
227 if ($win64 && $self->{label} =~ s/\@GOTPCREL//) {
228 die if (opcode->mnemonic() ne "mov");
229 opcode->mnemonic("lea");
230 }
174 $self->{base} =~ s/^%//; 231 $self->{base} =~ s/^%//;
175 $self->{index} =~ s/^%// if (defined($self->{index})); 232 $self->{index} =~ s/^%// if (defined($self->{index}));
176 } 233 }
@@ -181,42 +238,50 @@ my $current_function;
181 my $self = shift; 238 my $self = shift;
182 my $sz = shift; 239 my $sz = shift;
183 240
241 $self->{label} =~ s/([_a-z][_a-z0-9]*)/$globals{$1} or $1/gei;
242 $self->{label} =~ s/\.L/$decor/g;
243
184 # Silently convert all EAs to 64-bit. This is required for 244 # Silently convert all EAs to 64-bit. This is required for
185 # elder GNU assembler and results in more compact code, 245 # elder GNU assembler and results in more compact code,
186 # *but* most importantly AES module depends on this feature! 246 # *but* most importantly AES module depends on this feature!
187 $self->{index} =~ s/^[er](.?[0-9xpi])[d]?$/r\1/; 247 $self->{index} =~ s/^[er](.?[0-9xpi])[d]?$/r\1/;
188 $self->{base} =~ s/^[er](.?[0-9xpi])[d]?$/r\1/; 248 $self->{base} =~ s/^[er](.?[0-9xpi])[d]?$/r\1/;
189 249
190 if (!$masm) { 250 if ($gas) {
191 # Solaris /usr/ccs/bin/as can't handle multiplications 251 # Solaris /usr/ccs/bin/as can't handle multiplications
192 # in $self->{label} 252 # in $self->{label}, new gas requires sign extension...
193 $self->{label} =~ s/(?<![0-9a-f])(0[x0-9a-f]+)/oct($1)/egi; 253 use integer;
254 $self->{label} =~ s/(?<![\w\$\.])(0x?[0-9a-f]+)/oct($1)/egi;
194 $self->{label} =~ s/([0-9]+\s*[\*\/\%]\s*[0-9]+)/eval($1)/eg; 255 $self->{label} =~ s/([0-9]+\s*[\*\/\%]\s*[0-9]+)/eval($1)/eg;
256 $self->{label} =~ s/([0-9]+)/$1<<32>>32/eg;
257 $self->{label} =~ s/^___imp_/__imp__/ if ($flavour eq "mingw64");
195 258
196 if (defined($self->{index})) { 259 if (defined($self->{index})) {
197 sprintf "%s(%%%s,%%%s,%d)", 260 sprintf "%s%s(%%%s,%%%s,%d)",$self->{asterisk},
198 $self->{label},$self->{base}, 261 $self->{label},$self->{base},
199 $self->{index},$self->{scale}; 262 $self->{index},$self->{scale};
200 } else { 263 } else {
201 sprintf "%s(%%%s)", $self->{label},$self->{base}; 264 sprintf "%s%s(%%%s)", $self->{asterisk},$self->{label},$self->{base};
202 } 265 }
203 } else { 266 } else {
204 %szmap = ( b=>"BYTE", w=>"WORD", l=>"DWORD", q=>"QWORD" ); 267 %szmap = ( b=>"BYTE$PTR", w=>"WORD$PTR", l=>"DWORD$PTR", q=>"QWORD$PTR" );
205 268
206 $self->{label} =~ s/\./\$/g; 269 $self->{label} =~ s/\./\$/g;
207 $self->{label} =~ s/0x([0-9a-f]+)/0$1h/ig; 270 $self->{label} =~ s/(?<![\w\$\.])0x([0-9a-f]+)/0$1h/ig;
208 $self->{label} = "($self->{label})" if ($self->{label} =~ /[\*\+\-\/]/); 271 $self->{label} = "($self->{label})" if ($self->{label} =~ /[\*\+\-\/]/);
272 $sz="q" if ($self->{asterisk});
209 273
210 if (defined($self->{index})) { 274 if (defined($self->{index})) {
211 sprintf "%s PTR %s[%s*%d+%s]",$szmap{$sz}, 275 sprintf "%s[%s%s*%d+%s]",$szmap{$sz},
212 $self->{label}, 276 $self->{label}?"$self->{label}+":"",
213 $self->{index},$self->{scale}, 277 $self->{index},$self->{scale},
214 $self->{base}; 278 $self->{base};
215 } elsif ($self->{base} eq "rip") { 279 } elsif ($self->{base} eq "rip") {
216 sprintf "%s PTR %s",$szmap{$sz},$self->{label}; 280 sprintf "%s[%s]",$szmap{$sz},$self->{label};
217 } else { 281 } else {
218 sprintf "%s PTR %s[%s]",$szmap{$sz}, 282 sprintf "%s[%s%s]",$szmap{$sz},
219 $self->{label},$self->{base}; 283 $self->{label}?"$self->{label}+":"",
284 $self->{base};
220 } 285 }
221 } 286 }
222 } 287 }
@@ -228,9 +293,11 @@ my $current_function;
228 local *line = shift; 293 local *line = shift;
229 undef $ret; 294 undef $ret;
230 295
231 if ($line =~ /^%(\w+)/) { 296 # optional * ---vvv--- appears in indirect jmp/call
297 if ($line =~ /^(\*?)%(\w+)/) {
232 bless $self,$class; 298 bless $self,$class;
233 $self->{value} = $1; 299 $self->{asterisk} = $1;
300 $self->{value} = $2;
234 $ret = $self; 301 $ret = $self;
235 $line = substr($line,@+[0]); $line =~ s/^\s+//; 302 $line = substr($line,@+[0]); $line =~ s/^\s+//;
236 } 303 }
@@ -253,7 +320,8 @@ my $current_function;
253 } 320 }
254 sub out { 321 sub out {
255 my $self = shift; 322 my $self = shift;
256 sprintf $masm?"%s":"%%%s",$self->{value}; 323 if ($gas) { sprintf "%s%%%s",$self->{asterisk},$self->{value}; }
324 else { $self->{value}; }
257 } 325 }
258} 326}
259{ package label; # pick up labels, which end with : 327{ package label; # pick up labels, which end with :
@@ -262,37 +330,63 @@ my $current_function;
262 local *line = shift; 330 local *line = shift;
263 undef $ret; 331 undef $ret;
264 332
265 if ($line =~ /(^[\.\w]+\:)/) { 333 if ($line =~ /(^[\.\w]+)\:/) {
266 $self->{value} = $1; 334 $self->{value} = $1;
267 $ret = $self; 335 $ret = $self;
268 $line = substr($line,@+[0]); $line =~ s/^\s+//; 336 $line = substr($line,@+[0]); $line =~ s/^\s+//;
269 337
270 $self->{value} =~ s/\.L/\$L/ if ($masm); 338 $self->{value} =~ s/^\.L/$decor/;
271 } 339 }
272 $ret; 340 $ret;
273 } 341 }
274 sub out { 342 sub out {
275 my $self = shift; 343 my $self = shift;
276 344
277 if (!$masm) { 345 if ($gas) {
278 $self->{value}; 346 my $func = ($globals{$self->{value}} or $self->{value}) . ":";
279 } elsif ($self->{value} ne "$current_function->{name}:") { 347 if ($win64 &&
280 $self->{value}; 348 $current_function->{name} eq $self->{value} &&
281 } elsif ($current_function->{abi} eq "svr4") { 349 $current_function->{abi} eq "svr4") {
282 my $func = "$current_function->{name} PROC\n". 350 $func .= "\n";
283 " mov QWORD PTR 8[rsp],rdi\t;WIN64 prologue\n". 351 $func .= " movq %rdi,8(%rsp)\n";
284 " mov QWORD PTR 16[rsp],rsi\n"; 352 $func .= " movq %rsi,16(%rsp)\n";
353 $func .= " movq %rsp,%rax\n";
354 $func .= "${decor}SEH_begin_$current_function->{name}:\n";
355 my $narg = $current_function->{narg};
356 $narg=6 if (!defined($narg));
357 $func .= " movq %rcx,%rdi\n" if ($narg>0);
358 $func .= " movq %rdx,%rsi\n" if ($narg>1);
359 $func .= " movq %r8,%rdx\n" if ($narg>2);
360 $func .= " movq %r9,%rcx\n" if ($narg>3);
361 $func .= " movq 40(%rsp),%r8\n" if ($narg>4);
362 $func .= " movq 48(%rsp),%r9\n" if ($narg>5);
363 }
364 $func;
365 } elsif ($self->{value} ne "$current_function->{name}") {
366 $self->{value} .= ":" if ($masm && $ret!~m/^\$/);
367 $self->{value} . ":";
368 } elsif ($win64 && $current_function->{abi} eq "svr4") {
369 my $func = "$current_function->{name}" .
370 ($nasm ? ":" : "\tPROC $current_function->{scope}") .
371 "\n";
372 $func .= " mov QWORD${PTR}[8+rsp],rdi\t;WIN64 prologue\n";
373 $func .= " mov QWORD${PTR}[16+rsp],rsi\n";
374 $func .= " mov rax,rsp\n";
375 $func .= "${decor}SEH_begin_$current_function->{name}:";
376 $func .= ":" if ($masm);
377 $func .= "\n";
285 my $narg = $current_function->{narg}; 378 my $narg = $current_function->{narg};
286 $narg=6 if (!defined($narg)); 379 $narg=6 if (!defined($narg));
287 $func .= " mov rdi,rcx\n" if ($narg>0); 380 $func .= " mov rdi,rcx\n" if ($narg>0);
288 $func .= " mov rsi,rdx\n" if ($narg>1); 381 $func .= " mov rsi,rdx\n" if ($narg>1);
289 $func .= " mov rdx,r8\n" if ($narg>2); 382 $func .= " mov rdx,r8\n" if ($narg>2);
290 $func .= " mov rcx,r9\n" if ($narg>3); 383 $func .= " mov rcx,r9\n" if ($narg>3);
291 $func .= " mov r8,QWORD PTR 40[rsp]\n" if ($narg>4); 384 $func .= " mov r8,QWORD${PTR}[40+rsp]\n" if ($narg>4);
292 $func .= " mov r9,QWORD PTR 48[rsp]\n" if ($narg>5); 385 $func .= " mov r9,QWORD${PTR}[48+rsp]\n" if ($narg>5);
293 $func .= "\n"; 386 $func .= "\n";
294 } else { 387 } else {
295 "$current_function->{name} PROC"; 388 "$current_function->{name}".
389 ($nasm ? ":" : "\tPROC $current_function->{scope}");
296 } 390 }
297 } 391 }
298} 392}
@@ -307,13 +401,19 @@ my $current_function;
307 $ret = $self; 401 $ret = $self;
308 $line = substr($line,@+[0]); $line =~ s/^\s+//; 402 $line = substr($line,@+[0]); $line =~ s/^\s+//;
309 403
310 $self->{value} =~ s/\.L/\$L/g if ($masm); 404 $self->{value} =~ s/\@PLT// if (!$elf);
405 $self->{value} =~ s/([_a-z][_a-z0-9]*)/$globals{$1} or $1/gei;
406 $self->{value} =~ s/\.L/$decor/g;
311 } 407 }
312 $ret; 408 $ret;
313 } 409 }
314 sub out { 410 sub out {
315 my $self = shift; 411 my $self = shift;
316 $self->{value}; 412 if ($nasm && opcode->mnemonic()=~m/^j/) {
413 "NEAR ".$self->{value};
414 } else {
415 $self->{value};
416 }
317 } 417 }
318} 418}
319{ package directive; # pick up directives, which start with . 419{ package directive; # pick up directives, which start with .
@@ -333,89 +433,181 @@ my $current_function;
333 "%r14"=>0x01358d4c, "%r15"=>0x013d8d4c ); 433 "%r14"=>0x01358d4c, "%r15"=>0x013d8d4c );
334 434
335 if ($line =~ /^\s*(\.\w+)/) { 435 if ($line =~ /^\s*(\.\w+)/) {
336 if (!$masm) {
337 $self->{value} = $1;
338 $line =~ s/\@abi\-omnipotent/\@function/;
339 $line =~ s/\@function.*/\@function/;
340 if ($line =~ /\.picmeup\s+(%r[\w]+)/i) {
341 $self->{value} = sprintf "\t.long\t0x%x,0x90000000",$opcode{$1};
342 } elsif ($line =~ /\.asciz\s+"(.*)"$/) {
343 $self->{value} = ".byte\t".join(",",unpack("C*",$1),0);
344 } elsif ($line =~ /\.extern/) {
345 $self->{value} = ""; # swallow extern
346 } else {
347 $self->{value} = $line;
348 }
349 $line = "";
350 return $self;
351 }
352
353 $dir = $1; 436 $dir = $1;
354 $ret = $self; 437 $ret = $self;
355 undef $self->{value}; 438 undef $self->{value};
356 $line = substr($line,@+[0]); $line =~ s/^\s+//; 439 $line = substr($line,@+[0]); $line =~ s/^\s+//;
440
357 SWITCH: for ($dir) { 441 SWITCH: for ($dir) {
358 /\.(text)/ 442 /\.picmeup/ && do { if ($line =~ /(%r[\w]+)/i) {
359 && do { my $v=undef; 443 $dir="\t.long";
360 $v="$current_segment\tENDS\n" if ($current_segment); 444 $line=sprintf "0x%x,0x90000000",$opcode{$1};
361 $current_segment = "_$1\$"; 445 }
362 $current_segment =~ tr/[a-z]/[A-Z]/; 446 last;
363 $v.="$current_segment\tSEGMENT "; 447 };
364 $v.=$masm>=$masmref ? "ALIGN(64)" : "PAGE"; 448 /\.global|\.globl|\.extern/
365 $v.=" 'CODE'"; 449 && do { $globals{$line} = $prefix . $line;
366 $self->{value} = $v; 450 $line = $globals{$line} if ($prefix);
367 last; 451 last;
368 }; 452 };
369 /\.extern/ && do { $self->{value} = "EXTRN\t".$line.":BYTE"; last; };
370 /\.globl/ && do { $self->{value} = "PUBLIC\t".$line; last; };
371 /\.type/ && do { ($sym,$type,$narg) = split(',',$line); 453 /\.type/ && do { ($sym,$type,$narg) = split(',',$line);
372 if ($type eq "\@function") { 454 if ($type eq "\@function") {
373 undef $current_function; 455 undef $current_function;
374 $current_function->{name} = $sym; 456 $current_function->{name} = $sym;
375 $current_function->{abi} = "svr4"; 457 $current_function->{abi} = "svr4";
376 $current_function->{narg} = $narg; 458 $current_function->{narg} = $narg;
459 $current_function->{scope} = defined($globals{$sym})?"PUBLIC":"PRIVATE";
377 } elsif ($type eq "\@abi-omnipotent") { 460 } elsif ($type eq "\@abi-omnipotent") {
378 undef $current_function; 461 undef $current_function;
379 $current_function->{name} = $sym; 462 $current_function->{name} = $sym;
463 $current_function->{scope} = defined($globals{$sym})?"PUBLIC":"PRIVATE";
464 }
465 $line =~ s/\@abi\-omnipotent/\@function/;
466 $line =~ s/\@function.*/\@function/;
467 last;
468 };
469 /\.asciz/ && do { if ($line =~ /^"(.*)"$/) {
470 $dir = ".byte";
471 $line = join(",",unpack("C*",$1),0);
380 } 472 }
381 last; 473 last;
382 }; 474 };
475 /\.rva|\.long|\.quad/
476 && do { $line =~ s/([_a-z][_a-z0-9]*)/$globals{$1} or $1/gei;
477 $line =~ s/\.L/$decor/g;
478 last;
479 };
480 }
481
482 if ($gas) {
483 $self->{value} = $dir . "\t" . $line;
484
485 if ($dir =~ /\.extern/) {
486 $self->{value} = ""; # swallow extern
487 } elsif (!$elf && $dir =~ /\.type/) {
488 $self->{value} = "";
489 $self->{value} = ".def\t" . ($globals{$1} or $1) . ";\t" .
490 (defined($globals{$1})?".scl 2;":".scl 3;") .
491 "\t.type 32;\t.endef"
492 if ($win64 && $line =~ /([^,]+),\@function/);
493 } elsif (!$elf && $dir =~ /\.size/) {
494 $self->{value} = "";
495 if (defined($current_function)) {
496 $self->{value} .= "${decor}SEH_end_$current_function->{name}:"
497 if ($win64 && $current_function->{abi} eq "svr4");
498 undef $current_function;
499 }
500 } elsif (!$elf && $dir =~ /\.align/) {
501 $self->{value} = ".p2align\t" . (log($line)/log(2));
502 } elsif ($dir eq ".section") {
503 $current_segment=$line;
504 if (!$elf && $current_segment eq ".init") {
505 if ($flavour eq "macosx") { $self->{value} = ".mod_init_func"; }
506 elsif ($flavour eq "mingw64") { $self->{value} = ".section\t.ctors"; }
507 }
508 } elsif ($dir =~ /\.(text|data)/) {
509 $current_segment=".$1";
510 }
511 $line = "";
512 return $self;
513 }
514
515 # non-gas case or nasm/masm
516 SWITCH: for ($dir) {
517 /\.text/ && do { my $v=undef;
518 if ($nasm) {
519 $v="section .text code align=64\n";
520 } else {
521 $v="$current_segment\tENDS\n" if ($current_segment);
522 $current_segment = ".text\$";
523 $v.="$current_segment\tSEGMENT ";
524 $v.=$masm>=$masmref ? "ALIGN(64)" : "PAGE";
525 $v.=" 'CODE'";
526 }
527 $self->{value} = $v;
528 last;
529 };
530 /\.data/ && do { my $v=undef;
531 if ($nasm) {
532 $v="section .data data align=8\n";
533 } else {
534 $v="$current_segment\tENDS\n" if ($current_segment);
535 $current_segment = "_DATA";
536 $v.="$current_segment\tSEGMENT";
537 }
538 $self->{value} = $v;
539 last;
540 };
541 /\.section/ && do { my $v=undef;
542 $line =~ s/([^,]*).*/$1/;
543 $line = ".CRT\$XCU" if ($line eq ".init");
544 if ($nasm) {
545 $v="section $line";
546 if ($line=~/\.([px])data/) {
547 $v.=" rdata align=";
548 $v.=$1 eq "p"? 4 : 8;
549 }
550 } else {
551 $v="$current_segment\tENDS\n" if ($current_segment);
552 $v.="$line\tSEGMENT";
553 if ($line=~/\.([px])data/) {
554 $v.=" READONLY";
555 $v.=" ALIGN(".($1 eq "p" ? 4 : 8).")" if ($masm>=$masmref);
556 }
557 }
558 $current_segment = $line;
559 $self->{value} = $v;
560 last;
561 };
562 /\.extern/ && do { $self->{value} = "EXTERN\t".$line;
563 $self->{value} .= ":NEAR" if ($masm);
564 last;
565 };
566 /\.globl|.global/
567 && do { $self->{value} = $masm?"PUBLIC":"global";
568 $self->{value} .= "\t".$line;
569 last;
570 };
383 /\.size/ && do { if (defined($current_function)) { 571 /\.size/ && do { if (defined($current_function)) {
384 $self->{value}="$current_function->{name}\tENDP"; 572 undef $self->{value};
573 if ($current_function->{abi} eq "svr4") {
574 $self->{value}="${decor}SEH_end_$current_function->{name}:";
575 $self->{value}.=":\n" if($masm);
576 }
577 $self->{value}.="$current_function->{name}\tENDP" if($masm);
385 undef $current_function; 578 undef $current_function;
386 } 579 }
387 last; 580 last;
388 }; 581 };
389 /\.align/ && do { $self->{value} = "ALIGN\t".$line; last; }; 582 /\.align/ && do { $self->{value} = "ALIGN\t".$line; last; };
390 /\.(byte|value|long|quad)/ 583 /\.(value|long|rva|quad)/
391 && do { my @arr = split(',',$line); 584 && do { my $sz = substr($1,0,1);
392 my $sz = substr($1,0,1); 585 my @arr = split(/,\s*/,$line);
393 my $last = pop(@arr); 586 my $last = pop(@arr);
394 my $conv = sub { my $var=shift; 587 my $conv = sub { my $var=shift;
395 if ($var=~s/0x([0-9a-f]+)/0$1h/i) { $var; } 588 $var=~s/^(0b[0-1]+)/oct($1)/eig;
396 else { sprintf"0%Xh",$var; } 589 $var=~s/^0x([0-9a-f]+)/0$1h/ig if ($masm);
590 if ($sz eq "D" && ($current_segment=~/.[px]data/ || $dir eq ".rva"))
591 { $var=~s/([_a-z\$\@][_a-z0-9\$\@]*)/$nasm?"$1 wrt ..imagebase":"imagerel $1"/egi; }
592 $var;
397 }; 593 };
398 594
399 $sz =~ tr/bvlq/BWDQ/; 595 $sz =~ tr/bvlrq/BWDDQ/;
400 $self->{value} = "\tD$sz\t"; 596 $self->{value} = "\tD$sz\t";
401 for (@arr) { $self->{value} .= &$conv($_).","; } 597 for (@arr) { $self->{value} .= &$conv($_).","; }
402 $self->{value} .= &$conv($last); 598 $self->{value} .= &$conv($last);
403 last; 599 last;
404 }; 600 };
405 /\.picmeup/ && do { $self->{value} = sprintf"\tDD\t 0%Xh,090000000h",$opcode{$line}; 601 /\.byte/ && do { my @str=split(/,\s*/,$line);
406 last; 602 map(s/(0b[0-1]+)/oct($1)/eig,@str);
407 }; 603 map(s/0x([0-9a-f]+)/0$1h/ig,@str) if ($masm);
408 /\.asciz/ && do { if ($line =~ /^"(.*)"$/) { 604 while ($#str>15) {
409 my @str=unpack("C*",$1);
410 push @str,0;
411 while ($#str>15) {
412 $self->{value}.="DB\t"
413 .join(",",@str[0..15])."\n";
414 foreach (0..15) { shift @str; }
415 }
416 $self->{value}.="DB\t" 605 $self->{value}.="DB\t"
417 .join(",",@str) if (@str); 606 .join(",",@str[0..15])."\n";
607 foreach (0..15) { shift @str; }
418 } 608 }
609 $self->{value}.="DB\t"
610 .join(",",@str) if (@str);
419 last; 611 last;
420 }; 612 };
421 } 613 }
@@ -432,6 +624,15 @@ my $current_function;
432 624
433print "#include <machine/asm.h>\n"; 625print "#include <machine/asm.h>\n";
434 626
627if ($nasm) {
628 print <<___;
629default rel
630___
631} elsif ($masm) {
632 print <<___;
633OPTION DOTNAME
634___
635}
435while($line=<>) { 636while($line=<>) {
436 637
437 chomp($line); 638 chomp($line);
@@ -442,43 +643,42 @@ while($line=<>) {
442 643
443 undef $label; 644 undef $label;
444 undef $opcode; 645 undef $opcode;
445 undef $dst;
446 undef $src;
447 undef $sz; 646 undef $sz;
647 undef @args;
448 648
449 if ($label=label->re(\$line)) { print $label->out(); } 649 if ($label=label->re(\$line)) { print $label->out(); }
450 650
451 if (directive->re(\$line)) { 651 if (directive->re(\$line)) {
452 printf "%s",directive->out(); 652 printf "%s",directive->out();
453 } elsif ($opcode=opcode->re(\$line)) { ARGUMENT: { 653 } elsif ($opcode=opcode->re(\$line)) { ARGUMENT: while (1) {
454 654 my $arg;
455 if ($src=register->re(\$line)) { opcode->size($src->size()); }
456 elsif ($src=const->re(\$line)) { }
457 elsif ($src=ea->re(\$line)) { }
458 elsif ($src=expr->re(\$line)) { }
459 655
460 last ARGUMENT if ($line !~ /^,/); 656 if ($arg=register->re(\$line)) { opcode->size($arg->size()); }
657 elsif ($arg=const->re(\$line)) { }
658 elsif ($arg=ea->re(\$line)) { }
659 elsif ($arg=expr->re(\$line)) { }
660 else { last ARGUMENT; }
461 661
462 $line = substr($line,1); $line =~ s/^\s+//; 662 push @args,$arg;
463 663
464 if ($dst=register->re(\$line)) { opcode->size($dst->size()); } 664 last ARGUMENT if ($line !~ /^,/);
465 elsif ($dst=const->re(\$line)) { }
466 elsif ($dst=ea->re(\$line)) { }
467 665
666 $line =~ s/^,\s*//;
468 } # ARGUMENT: 667 } # ARGUMENT:
469 668
470 $sz=opcode->size(); 669 $sz=opcode->size();
471 670
472 if (defined($dst)) { 671 if ($#args>=0) {
473 if (!$masm) { 672 my $insn;
474 printf "\t%s\t%s,%s", $opcode->out($dst->size()), 673 if ($gas) {
475 $src->out($sz),$dst->out($sz); 674 $insn = $opcode->out($#args>=1?$args[$#args]->size():$sz);
476 } else { 675 } else {
477 printf "\t%s\t%s,%s", $opcode->out(), 676 $insn = $opcode->out();
478 $dst->out($sz),$src->out($sz); 677 $insn .= $sz if (map($_->out() =~ /x?mm/,@args));
678 @args = reverse(@args);
679 undef $sz if ($nasm && $opcode->mnemonic() eq "lea");
479 } 680 }
480 } elsif (defined($src)) { 681 printf "\t%s\t%s",$insn,join(",",map($_->out($sz),@args));
481 printf "\t%s\t%s",$opcode->out(),$src->out($sz);
482 } else { 682 } else {
483 printf "\t%s",$opcode->out(); 683 printf "\t%s",$opcode->out();
484 } 684 }
@@ -487,11 +687,12 @@ while($line=<>) {
487 print $line,"\n"; 687 print $line,"\n";
488} 688}
489 689
490print "\n$current_segment\tENDS\nEND\n" if ($masm); 690print "\n$current_segment\tENDS\n" if ($current_segment && $masm);
691print "END\n" if ($masm);
491 692
492close STDOUT; 693close STDOUT;
493 694
494################################################# 695 #################################################
495# Cross-reference x86_64 ABI "card" 696# Cross-reference x86_64 ABI "card"
496# 697#
497# Unix Win64 698# Unix Win64
@@ -555,3 +756,161 @@ close STDOUT;
555# movq 16(%rsp),%rsi 756# movq 16(%rsp),%rsi
556# endif 757# endif
557# ret 758# ret
759#
760 #################################################
761# Win64 SEH, Structured Exception Handling.
762#
763# Unlike on Unix systems(*) lack of Win64 stack unwinding information
764# has undesired side-effect at run-time: if an exception is raised in
765# assembler subroutine such as those in question (basically we're
766# referring to segmentation violations caused by malformed input
767# parameters), the application is briskly terminated without invoking
768# any exception handlers, most notably without generating memory dump
769# or any user notification whatsoever. This poses a problem. It's
770# possible to address it by registering custom language-specific
771# handler that would restore processor context to the state at
772# subroutine entry point and return "exception is not handled, keep
773# unwinding" code. Writing such handler can be a challenge... But it's
774# doable, though requires certain coding convention. Consider following
775# snippet:
776#
777# .type function,@function
778# function:
779# movq %rsp,%rax # copy rsp to volatile register
780# pushq %r15 # save non-volatile registers
781# pushq %rbx
782# pushq %rbp
783# movq %rsp,%r11
784# subq %rdi,%r11 # prepare [variable] stack frame
785# andq $-64,%r11
786# movq %rax,0(%r11) # check for exceptions
787# movq %r11,%rsp # allocate [variable] stack frame
788# movq %rax,0(%rsp) # save original rsp value
789# magic_point:
790# ...
791# movq 0(%rsp),%rcx # pull original rsp value
792# movq -24(%rcx),%rbp # restore non-volatile registers
793# movq -16(%rcx),%rbx
794# movq -8(%rcx),%r15
795# movq %rcx,%rsp # restore original rsp
796# ret
797# .size function,.-function
798#
799# The key is that up to magic_point copy of original rsp value remains
800# in chosen volatile register and no non-volatile register, except for
801# rsp, is modified. While past magic_point rsp remains constant till
802# the very end of the function. In this case custom language-specific
803# exception handler would look like this:
804#
805# EXCEPTION_DISPOSITION handler (EXCEPTION_RECORD *rec,ULONG64 frame,
806# CONTEXT *context,DISPATCHER_CONTEXT *disp)
807# { ULONG64 *rsp = (ULONG64 *)context->Rax;
808# if (context->Rip >= magic_point)
809# { rsp = ((ULONG64 **)context->Rsp)[0];
810# context->Rbp = rsp[-3];
811# context->Rbx = rsp[-2];
812# context->R15 = rsp[-1];
813# }
814# context->Rsp = (ULONG64)rsp;
815# context->Rdi = rsp[1];
816# context->Rsi = rsp[2];
817#
818# memcpy (disp->ContextRecord,context,sizeof(CONTEXT));
819# RtlVirtualUnwind(UNW_FLAG_NHANDLER,disp->ImageBase,
820# dips->ControlPc,disp->FunctionEntry,disp->ContextRecord,
821# &disp->HandlerData,&disp->EstablisherFrame,NULL);
822# return ExceptionContinueSearch;
823# }
824#
825# It's appropriate to implement this handler in assembler, directly in
826# function's module. In order to do that one has to know members'
827# offsets in CONTEXT and DISPATCHER_CONTEXT structures and some constant
828# values. Here they are:
829#
830# CONTEXT.Rax 120
831# CONTEXT.Rcx 128
832# CONTEXT.Rdx 136
833# CONTEXT.Rbx 144
834# CONTEXT.Rsp 152
835# CONTEXT.Rbp 160
836# CONTEXT.Rsi 168
837# CONTEXT.Rdi 176
838# CONTEXT.R8 184
839# CONTEXT.R9 192
840# CONTEXT.R10 200
841# CONTEXT.R11 208
842# CONTEXT.R12 216
843# CONTEXT.R13 224
844# CONTEXT.R14 232
845# CONTEXT.R15 240
846# CONTEXT.Rip 248
847# CONTEXT.Xmm6 512
848# sizeof(CONTEXT) 1232
849# DISPATCHER_CONTEXT.ControlPc 0
850# DISPATCHER_CONTEXT.ImageBase 8
851# DISPATCHER_CONTEXT.FunctionEntry 16
852# DISPATCHER_CONTEXT.EstablisherFrame 24
853# DISPATCHER_CONTEXT.TargetIp 32
854# DISPATCHER_CONTEXT.ContextRecord 40
855# DISPATCHER_CONTEXT.LanguageHandler 48
856# DISPATCHER_CONTEXT.HandlerData 56
857# UNW_FLAG_NHANDLER 0
858# ExceptionContinueSearch 1
859#
860# In order to tie the handler to the function one has to compose
861# couple of structures: one for .xdata segment and one for .pdata.
862#
863# UNWIND_INFO structure for .xdata segment would be
864#
865# function_unwind_info:
866# .byte 9,0,0,0
867# .rva handler
868#
869# This structure designates exception handler for a function with
870# zero-length prologue, no stack frame or frame register.
871#
872# To facilitate composing of .pdata structures, auto-generated "gear"
873# prologue copies rsp value to rax and denotes next instruction with
874# .LSEH_begin_{function_name} label. This essentially defines the SEH
875# styling rule mentioned in the beginning. Position of this label is
876# chosen in such manner that possible exceptions raised in the "gear"
877# prologue would be accounted to caller and unwound from latter's frame.
878# End of function is marked with respective .LSEH_end_{function_name}
879# label. To summarize, .pdata segment would contain
880#
881# .rva .LSEH_begin_function
882# .rva .LSEH_end_function
883# .rva function_unwind_info
884#
885# Reference to functon_unwind_info from .xdata segment is the anchor.
886# In case you wonder why references are 32-bit .rvas and not 64-bit
887# .quads. References put into these two segments are required to be
888# *relative* to the base address of the current binary module, a.k.a.
889# image base. No Win64 module, be it .exe or .dll, can be larger than
890# 2GB and thus such relative references can be and are accommodated in
891# 32 bits.
892#
893# Having reviewed the example function code, one can argue that "movq
894# %rsp,%rax" above is redundant. It is not! Keep in mind that on Unix
895# rax would contain an undefined value. If this "offends" you, use
896# another register and refrain from modifying rax till magic_point is
897# reached, i.e. as if it was a non-volatile register. If more registers
898# are required prior [variable] frame setup is completed, note that
899# nobody says that you can have only one "magic point." You can
900# "liberate" non-volatile registers by denoting last stack off-load
901# instruction and reflecting it in finer grade unwind logic in handler.
902# After all, isn't it why it's called *language-specific* handler...
903#
904# Attentive reader can notice that exceptions would be mishandled in
905# auto-generated "gear" epilogue. Well, exception effectively can't
906# occur there, because if memory area used by it was subject to
907# segmentation violation, then it would be raised upon call to the
908# function (and as already mentioned be accounted to caller, which is
909# not a problem). If you're still not comfortable, then define tail
910# "magic point" just prior ret instruction and have handler treat it...
911#
912# (*) Note that we're talking about run-time, not debug-time. Lack of
913# unwind information makes debugging hard on both Windows and
914# Unix. "Unlike" referes to the fact that on Unix signal handler
915# will always be invoked, core dumped and appropriate exit code
916# returned to parent (for user notification).
diff --git a/src/lib/libcrypto/perlasm/x86asm.pl b/src/lib/libcrypto/perlasm/x86asm.pl
index f535c9c7fa..4756a28e59 100644
--- a/src/lib/libcrypto/perlasm/x86asm.pl
+++ b/src/lib/libcrypto/perlasm/x86asm.pl
@@ -1,136 +1,221 @@
1#!/usr/local/bin/perl 1#!/usr/bin/env perl
2 2
3# require 'x86asm.pl'; 3# require 'x86asm.pl';
4# &asm_init("cpp","des-586.pl"); 4# &asm_init(<flavor>,"des-586.pl"[,$i386only]);
5# XXX 5# &function_begin("foo");
6# XXX 6# ...
7# main'asm_finish 7# &function_end("foo");
8 8# &asm_finish
9sub main'asm_finish 9
10 { 10$out=();
11 &file_end(); 11$i386=0;
12 &asm_finish_cpp() if $cpp; 12
13 print &asm_get_output(); 13# AUTOLOAD is this context has quite unpleasant side effect, namely
14 } 14# that typos in function calls effectively go to assembler output,
15 15# but on the pros side we don't have to implement one subroutine per
16sub main'asm_init 16# each opcode...
17 { 17sub ::AUTOLOAD
18 ($type,$fn,$i386)=@_; 18{ my $opcode = $AUTOLOAD;
19 $filename=$fn; 19
20 20 die "more than 4 arguments passed to $opcode" if ($#_>3);
21 $elf=$cpp=$coff=$aout=$win32=$netware=$mwerks=$openbsd=0; 21
22 if ( ($type eq "elf")) 22 $opcode =~ s/.*:://;
23 { $elf=1; require "x86unix.pl"; } 23 if ($opcode =~ /^push/) { $stack+=4; }
24 elsif ( ($type eq "openbsd-elf")) 24 elsif ($opcode =~ /^pop/) { $stack-=4; }
25 { $openbsd=$elf=1; require "x86unix.pl"; } 25
26 elsif ( ($type eq "openbsd-a.out")) 26 &generic($opcode,@_) or die "undefined subroutine \&$AUTOLOAD";
27 { $openbsd=1; require "x86unix.pl"; } 27}
28 elsif ( ($type eq "a.out")) 28
29 { $aout=1; require "x86unix.pl"; } 29sub ::emit
30 elsif ( ($type eq "coff" or $type eq "gaswin")) 30{ my $opcode=shift;
31 { $coff=1; require "x86unix.pl"; } 31
32 elsif ( ($type eq "cpp")) 32 if ($#_==-1) { push(@out,"\t$opcode\n"); }
33 { $cpp=1; require "x86unix.pl"; } 33 else { push(@out,"\t$opcode\t".join(',',@_)."\n"); }
34 elsif ( ($type eq "win32")) 34}
35 { $win32=1; require "x86ms.pl"; } 35
36 elsif ( ($type eq "win32n")) 36sub ::emitraw
37 { $win32=1; require "x86nasm.pl"; } 37{ my $opcode=shift;
38 elsif ( ($type eq "nw-nasm")) 38
39 { $netware=1; require "x86nasm.pl"; } 39 if ($#_==-1) { push(@out,"$opcode\n"); }
40 elsif ( ($type eq "nw-mwasm")) 40 else { push(@out,"$opcode\t".join(',',@_)."\n"); }
41 { $netware=1; $mwerks=1; require "x86nasm.pl"; } 41}
42 else 42
43 { 43sub ::LB
44 print STDERR <<"EOF"; 44{ $_[0] =~ m/^e?([a-d])x$/o or die "$_[0] does not have a 'low byte'";
45 $1."l";
46}
47sub ::HB
48{ $_[0] =~ m/^e?([a-d])x$/o or die "$_[0] does not have a 'high byte'";
49 $1."h";
50}
51sub ::stack_push{ my $num=$_[0]*4; $stack+=$num; &sub("esp",$num); }
52sub ::stack_pop { my $num=$_[0]*4; $stack-=$num; &add("esp",$num); }
53sub ::blindpop { &pop($_[0]); $stack+=4; }
54sub ::wparam { &DWP($stack+4*$_[0],"esp"); }
55sub ::swtmp { &DWP(4*$_[0],"esp"); }
56
57sub ::bswap
58{ if ($i386) # emulate bswap for i386
59 { &comment("bswap @_");
60 &xchg(&HB(@_),&LB(@_));
61 &ror (@_,16);
62 &xchg(&HB(@_),&LB(@_));
63 }
64 else
65 { &generic("bswap",@_); }
66}
67# These are made-up opcodes introduced over the years essentially
68# by ignorance, just alias them to real ones...
69sub ::movb { &mov(@_); }
70sub ::xorb { &xor(@_); }
71sub ::rotl { &rol(@_); }
72sub ::rotr { &ror(@_); }
73sub ::exch { &xchg(@_); }
74sub ::halt { &hlt; }
75sub ::movz { &movzx(@_); }
76sub ::pushf { &pushfd; }
77sub ::popf { &popfd; }
78
79# 3 argument instructions
80sub ::movq
81{ my($p1,$p2,$optimize)=@_;
82
83 if ($optimize && $p1=~/^mm[0-7]$/ && $p2=~/^mm[0-7]$/)
84 # movq between mmx registers can sink Intel CPUs
85 { &::pshufw($p1,$p2,0xe4); }
86 else
87 { &::generic("movq",@_); }
88}
89
90# label management
91$lbdecor="L"; # local label decoration, set by package
92$label="000";
93
94sub ::islabel # see is argument is a known label
95{ my $i;
96 foreach $i (values %label) { return $i if ($i eq $_[0]); }
97 $label{$_[0]}; # can be undef
98}
99
100sub ::label # instantiate a function-scope label
101{ if (!defined($label{$_[0]}))
102 { $label{$_[0]}="${lbdecor}${label}${_[0]}"; $label++; }
103 $label{$_[0]};
104}
105
106sub ::LABEL # instantiate a file-scope label
107{ $label{$_[0]}=$_[1] if (!defined($label{$_[0]}));
108 $label{$_[0]};
109}
110
111sub ::static_label { &::LABEL($_[0],$lbdecor.$_[0]); }
112
113sub ::set_label_B { push(@out,"@_:\n"); }
114sub ::set_label
115{ my $label=&::label($_[0]);
116 &::align($_[1]) if ($_[1]>1);
117 &::set_label_B($label);
118 $label;
119}
120
121sub ::wipe_labels # wipes function-scope labels
122{ foreach $i (keys %label)
123 { delete $label{$i} if ($label{$i} =~ /^\Q${lbdecor}\E[0-9]{3}/); }
124}
125
126# subroutine management
127sub ::function_begin
128{ &function_begin_B(@_);
129 $stack=4;
130 &push("ebp");
131 &push("ebx");
132 &push("esi");
133 &push("edi");
134}
135
136sub ::function_end
137{ &pop("edi");
138 &pop("esi");
139 &pop("ebx");
140 &pop("ebp");
141 &ret();
142 &function_end_B(@_);
143 $stack=0;
144 &wipe_labels();
145}
146
147sub ::function_end_A
148{ &pop("edi");
149 &pop("esi");
150 &pop("ebx");
151 &pop("ebp");
152 &ret();
153 $stack+=16; # readjust esp as if we didn't pop anything
154}
155
156sub ::asciz
157{ my @str=unpack("C*",shift);
158 push @str,0;
159 while ($#str>15) {
160 &data_byte(@str[0..15]);
161 foreach (0..15) { shift @str; }
162 }
163 &data_byte(@str) if (@str);
164}
165
166sub ::asm_finish
167{ &file_end();
168 print @out;
169}
170
171sub ::asm_init
172{ my ($type,$fn,$cpu)=@_;
173
174 $filename=$fn;
175 $i386=$cpu;
176
177 $elf=$cpp=$coff=$aout=$macosx=$win32=$netware=$mwerks=$openbsd=0;
178 if (($type eq "elf"))
179 { $elf=1; require "x86gas.pl"; }
180 elsif (($type eq "a\.out"))
181 { $aout=1; require "x86gas.pl"; }
182 elsif (($type eq "coff" or $type eq "gaswin"))
183 { $coff=1; require "x86gas.pl"; }
184 elsif (($type eq "win32n"))
185 { $win32=1; require "x86nasm.pl"; }
186 elsif (($type eq "nw-nasm"))
187 { $netware=1; require "x86nasm.pl"; }
188 #elsif (($type eq "nw-mwasm"))
189 #{ $netware=1; $mwerks=1; require "x86nasm.pl"; }
190 elsif (($type eq "win32"))
191 { $win32=1; require "x86masm.pl"; }
192 elsif (($type eq "macosx"))
193 { $aout=1; $macosx=1; require "x86gas.pl"; }
194 elsif (($type eq "openbsd-elf"))
195 { $openbsd=$elf=1; require "x86gas.pl"; }
196 elsif (($type eq "openbsd-a.out"))
197 { $openbsd=1; require "x86gas.pl"; }
198 else
199 { print STDERR <<"EOF";
45Pick one target type from 200Pick one target type from
46 elf - Linux, FreeBSD, Solaris x86, etc. 201 elf - Linux, FreeBSD, Solaris x86, etc.
47 a.out - OpenBSD, DJGPP, etc. 202 a.out - DJGPP, elder OpenBSD, etc.
48 coff - GAS/COFF such as Win32 targets 203 coff - GAS/COFF such as Win32 targets
49 win32 - Windows 95/Windows NT
50 win32n - Windows 95/Windows NT NASM format 204 win32n - Windows 95/Windows NT NASM format
51 openbsd-elf - OpenBSD elf 205 openbsd-elf - OpenBSD elf
52 openbsd-a.out - OpenBSD a.out 206 openbsd-a.out - OpenBSD a.out
53 nw-nasm - NetWare NASM format 207 nw-nasm - NetWare NASM format
54 nw-mwasm- NetWare Metrowerks Assembler 208 macosx - Mac OS X
55EOF 209EOF
56 exit(1); 210 exit(1);
57 } 211 }
58 212
59 $pic=0; 213 $pic=0;
60 for (@ARGV) { $pic=1 if (/\-[fK]PIC/i); } 214 for (@ARGV) { $pic=1 if (/\-[fK]PIC/i); }
61 215
62 &asm_init_output(); 216 ::emitraw("#include <machine/asm.h>\n") if $openbsd;
63 217 $filename =~ s/\.pl$//;
64&comment("Don't even think of reading this code"); 218 &file($filename);
65&comment("It was automatically generated by $filename"); 219}
66&comment("Which is a perl program used to generate the x86 assember for");
67&comment("any of ELF, a.out, COFF, Win32, ...");
68&comment("eric <eay\@cryptsoft.com>");
69&comment("");
70
71 $filename =~ s/\.pl$//;
72 &file($filename);
73 }
74
75sub asm_finish_cpp
76 {
77 return unless $cpp;
78
79 local($tmp,$i);
80 foreach $i (&get_labels())
81 {
82 $tmp.="#define $i _$i\n";
83 }
84 print <<"EOF";
85/* Run the C pre-processor over this file with one of the following defined
86 * ELF - elf object files,
87 * OUT - a.out object files,
88 * BSDI - BSDI style a.out object files
89 * SOL - Solaris style elf
90 */
91
92#define TYPE(a,b) .type a,b
93#define SIZE(a,b) .size a,b
94
95#if defined(OUT) || (defined(BSDI) && !defined(ELF))
96$tmp
97#endif
98
99#ifdef OUT
100#define OK 1
101#define ALIGN 4
102#if defined(__CYGWIN__) || defined(__DJGPP__) || (__MINGW32__)
103#undef SIZE
104#undef TYPE
105#define SIZE(a,b)
106#define TYPE(a,b) .def a; .scl 2; .type 32; .endef
107#endif /* __CYGWIN || __DJGPP */
108#endif
109
110#if defined(BSDI) && !defined(ELF)
111#define OK 1
112#define ALIGN 4
113#undef SIZE
114#undef TYPE
115#define SIZE(a,b)
116#define TYPE(a,b)
117#endif
118
119#if defined(ELF) || defined(SOL)
120#define OK 1
121#define ALIGN 16
122#endif
123
124#ifndef OK
125You need to define one of
126ELF - elf systems - linux-elf, NetBSD and DG-UX
127OUT - a.out systems - linux-a.out and FreeBSD
128SOL - solaris systems, which are elf with strange comment lines
129BSDI - a.out with a very primative version of as.
130#endif
131
132/* Let the Assembler begin :-) */
133EOF
134 }
135 220
1361; 2211;
diff --git a/src/lib/libcrypto/perlasm/x86gas.pl b/src/lib/libcrypto/perlasm/x86gas.pl
index 6eab727fd4..15e17f25d0 100644
--- a/src/lib/libcrypto/perlasm/x86gas.pl
+++ b/src/lib/libcrypto/perlasm/x86gas.pl
@@ -180,7 +180,16 @@ sub ::align
180sub ::picmeup 180sub ::picmeup
181{ my($dst,$sym,$base,$reflabel)=@_; 181{ my($dst,$sym,$base,$reflabel)=@_;
182 182
183 if ($::pic && ($::elf || $::aout)) 183 if ($::openbsd)
184 { &::emitraw("#ifdef PIC");
185 &::emitraw("PIC_PROLOGUE");
186 &::mov($dst, &::DWP("PIC_GOT($sym)"));
187 &::emitraw("PIC_EPILOGUE");
188 &::emitraw("#else /* PIC */");
189 &::lea($dst,&::DWP($sym));
190 &::emitraw("#endif /* PIC */");
191 }
192 elsif ($::pic && ($::elf || $::aout))
184 { if (!defined($base)) 193 { if (!defined($base))
185 { &::call(&::label("PIC_me_up")); 194 { &::call(&::label("PIC_me_up"));
186 &::set_label("PIC_me_up"); 195 &::set_label("PIC_me_up");
@@ -206,7 +215,18 @@ sub ::picmeup
206sub ::initseg 215sub ::initseg
207{ my $f=$nmdecor.shift; 216{ my $f=$nmdecor.shift;
208 217
209 if ($::elf) 218 if ($::openbsd)
219 { $initseg.=<<___;
220.section .init
221PIC_PROLOGUE
222 call PIC_PLT($f)
223PIC_EPILOGUE
224 jmp .Linitalign
225.align $align
226.Linitalign:
227___
228 }
229 elsif ($::elf)
210 { $initseg.=<<___; 230 { $initseg.=<<___;
211.section .init 231.section .init
212 call $f 232 call $f
diff --git a/src/lib/libcrypto/perlasm/x86ms.pl b/src/lib/libcrypto/perlasm/x86ms.pl
deleted file mode 100644
index a0be2934c2..0000000000
--- a/src/lib/libcrypto/perlasm/x86ms.pl
+++ /dev/null
@@ -1,472 +0,0 @@
1#!/usr/local/bin/perl
2
3package x86ms;
4
5$label="L000";
6
7%lb=( 'eax', 'al',
8 'ebx', 'bl',
9 'ecx', 'cl',
10 'edx', 'dl',
11 'ax', 'al',
12 'bx', 'bl',
13 'cx', 'cl',
14 'dx', 'dl',
15 );
16
17%hb=( 'eax', 'ah',
18 'ebx', 'bh',
19 'ecx', 'ch',
20 'edx', 'dh',
21 'ax', 'ah',
22 'bx', 'bh',
23 'cx', 'ch',
24 'dx', 'dh',
25 );
26
27sub main'asm_init_output { @out=(); }
28sub main'asm_get_output { return(@out); }
29sub main'get_labels { return(@labels); }
30sub main'external_label
31{
32 push(@labels,@_);
33 foreach (@_) {
34 push(@out, "EXTRN\t_$_:DWORD\n");
35 }
36}
37
38sub main'LB
39 {
40 (defined($lb{$_[0]})) || die "$_[0] does not have a 'low byte'\n";
41 return($lb{$_[0]});
42 }
43
44sub main'HB
45 {
46 (defined($hb{$_[0]})) || die "$_[0] does not have a 'high byte'\n";
47 return($hb{$_[0]});
48 }
49
50sub main'BP
51 {
52 &get_mem("BYTE",@_);
53 }
54
55sub main'DWP
56 {
57 &get_mem("DWORD",@_);
58 }
59
60sub main'QWP
61 {
62 &get_mem("QWORD",@_);
63 }
64
65sub main'BC
66 {
67 return @_;
68 }
69
70sub main'DWC
71 {
72 return @_;
73 }
74
75sub main'stack_push
76 {
77 local($num)=@_;
78 $stack+=$num*4;
79 &main'sub("esp",$num*4);
80 }
81
82sub main'stack_pop
83 {
84 local($num)=@_;
85 $stack-=$num*4;
86 &main'add("esp",$num*4);
87 }
88
89sub get_mem
90 {
91 local($size,$addr,$reg1,$reg2,$idx)=@_;
92 local($t,$post);
93 local($ret)="$size PTR ";
94
95 $addr =~ s/^\s+//;
96 if ($addr =~ /^(.+)\+(.+)$/)
97 {
98 $reg2=&conv($1);
99 $addr="_$2";
100 }
101 elsif ($addr =~ /^[_a-z][_a-z0-9]*$/i)
102 {
103 $addr="_$addr";
104 }
105
106 if ($addr =~ /^.+\-.+$/) { $addr="($addr)"; }
107
108 $reg1="$regs{$reg1}" if defined($regs{$reg1});
109 $reg2="$regs{$reg2}" if defined($regs{$reg2});
110 if (($addr ne "") && ($addr ne 0))
111 {
112 if ($addr !~ /^-/)
113 { $ret.=$addr; }
114 else { $post=$addr; }
115 }
116 if ($reg2 ne "")
117 {
118 $t="";
119 $t="*$idx" if ($idx != 0);
120 $reg1="+".$reg1 if ("$reg1$post" ne "");
121 $ret.="[$reg2$t$reg1$post]";
122 }
123 else
124 {
125 $ret.="[$reg1$post]"
126 }
127 $ret =~ s/\[\]//; # in case $addr was the only argument
128 return($ret);
129 }
130
131sub main'mov { &out2("mov",@_); }
132sub main'movb { &out2("mov",@_); }
133sub main'and { &out2("and",@_); }
134sub main'or { &out2("or",@_); }
135sub main'shl { &out2("shl",@_); }
136sub main'shr { &out2("shr",@_); }
137sub main'xor { &out2("xor",@_); }
138sub main'xorb { &out2("xor",@_); }
139sub main'add { &out2("add",@_); }
140sub main'adc { &out2("adc",@_); }
141sub main'sub { &out2("sub",@_); }
142sub main'sbb { &out2("sbb",@_); }
143sub main'rotl { &out2("rol",@_); }
144sub main'rotr { &out2("ror",@_); }
145sub main'exch { &out2("xchg",@_); }
146sub main'cmp { &out2("cmp",@_); }
147sub main'lea { &out2("lea",@_); }
148sub main'mul { &out1("mul",@_); }
149sub main'imul { &out2("imul",@_); }
150sub main'div { &out1("div",@_); }
151sub main'dec { &out1("dec",@_); }
152sub main'inc { &out1("inc",@_); }
153sub main'jmp { &out1("jmp",@_); }
154sub main'jmp_ptr { &out1p("jmp",@_); }
155sub main'je { &out1("je",@_); }
156sub main'jle { &out1("jle",@_); }
157sub main'jz { &out1("jz",@_); }
158sub main'jge { &out1("jge",@_); }
159sub main'jl { &out1("jl",@_); }
160sub main'ja { &out1("ja",@_); }
161sub main'jae { &out1("jae",@_); }
162sub main'jb { &out1("jb",@_); }
163sub main'jbe { &out1("jbe",@_); }
164sub main'jc { &out1("jc",@_); }
165sub main'jnc { &out1("jnc",@_); }
166sub main'jnz { &out1("jnz",@_); }
167sub main'jne { &out1("jne",@_); }
168sub main'jno { &out1("jno",@_); }
169sub main'push { &out1("push",@_); $stack+=4; }
170sub main'pop { &out1("pop",@_); $stack-=4; }
171sub main'pushf { &out0("pushfd"); $stack+=4; }
172sub main'popf { &out0("popfd"); $stack-=4; }
173sub main'bswap { &out1("bswap",@_); &using486(); }
174sub main'not { &out1("not",@_); }
175sub main'call { &out1("call",($_[0]=~/^\$L/?'':'_').$_[0]); }
176sub main'call_ptr { &out1p("call",@_); }
177sub main'ret { &out0("ret"); }
178sub main'nop { &out0("nop"); }
179sub main'test { &out2("test",@_); }
180sub main'bt { &out2("bt",@_); }
181sub main'leave { &out0("leave"); }
182sub main'cpuid { &out0("DW\t0A20Fh"); }
183sub main'rdtsc { &out0("DW\t0310Fh"); }
184sub main'halt { &out0("hlt"); }
185sub main'movz { &out2("movzx",@_); }
186sub main'neg { &out1("neg",@_); }
187sub main'cld { &out0("cld"); }
188
189# SSE2
190sub main'emms { &out0("emms"); }
191sub main'movd { &out2("movd",@_); }
192sub main'movq { &out2("movq",@_); }
193sub main'movdqu { &out2("movdqu",@_); }
194sub main'movdqa { &out2("movdqa",@_); }
195sub main'movdq2q{ &out2("movdq2q",@_); }
196sub main'movq2dq{ &out2("movq2dq",@_); }
197sub main'paddq { &out2("paddq",@_); }
198sub main'pmuludq{ &out2("pmuludq",@_); }
199sub main'psrlq { &out2("psrlq",@_); }
200sub main'psllq { &out2("psllq",@_); }
201sub main'pxor { &out2("pxor",@_); }
202sub main'por { &out2("por",@_); }
203sub main'pand { &out2("pand",@_); }
204
205sub out2
206 {
207 local($name,$p1,$p2)=@_;
208 local($l,$t,$line);
209
210 $line="\t$name\t";
211 $t=&conv($p1).",";
212 $l=length($t);
213 $line.="$t";
214 $l=4-($l+9)/8;
215 $line.="\t" x $l;
216 $line.=&conv($p2);
217 if ($line=~/\bxmm[0-7]\b/i) { $line=~s/\b[A-Z]+WORD\s+PTR/XMMWORD PTR/i; }
218 push(@out,$line."\n");
219 }
220
221sub out0
222 {
223 local($name)=@_;
224
225 push(@out,"\t$name\n");
226 }
227
228sub out1
229 {
230 local($name,$p1)=@_;
231 local($l,$t);
232
233 push(@out,"\t$name\t".&conv($p1)."\n");
234 }
235
236sub conv
237 {
238 local($p)=@_;
239
240 $p =~ s/0x([0-9A-Fa-f]+)/0$1h/;
241 return $p;
242 }
243
244sub using486
245 {
246 return if $using486;
247 $using486++;
248 grep(s/\.386/\.486/,@out);
249 }
250
251sub main'file
252 {
253 local($file)=@_;
254
255 local($tmp)=<<"EOF";
256 TITLE $file.asm
257 .386
258.model FLAT
259_TEXT\$ SEGMENT PAGE 'CODE'
260
261EOF
262 push(@out,$tmp);
263 }
264
265sub main'function_begin
266 {
267 local($func,$extra)=@_;
268
269 push(@labels,$func);
270
271 local($tmp)=<<"EOF";
272PUBLIC _$func
273$extra
274_$func PROC NEAR
275 push ebp
276 push ebx
277 push esi
278 push edi
279EOF
280 push(@out,$tmp);
281 $stack=20;
282 }
283
284sub main'function_begin_B
285 {
286 local($func,$extra)=@_;
287
288 local($tmp)=<<"EOF";
289PUBLIC _$func
290$extra
291_$func PROC NEAR
292EOF
293 push(@out,$tmp);
294 $stack=4;
295 }
296
297sub main'function_end
298 {
299 local($func)=@_;
300
301 local($tmp)=<<"EOF";
302 pop edi
303 pop esi
304 pop ebx
305 pop ebp
306 ret
307_$func ENDP
308EOF
309 push(@out,$tmp);
310 $stack=0;
311 %label=();
312 }
313
314sub main'function_end_B
315 {
316 local($func)=@_;
317
318 local($tmp)=<<"EOF";
319_$func ENDP
320EOF
321 push(@out,$tmp);
322 $stack=0;
323 %label=();
324 }
325
326sub main'function_end_A
327 {
328 local($func)=@_;
329
330 local($tmp)=<<"EOF";
331 pop edi
332 pop esi
333 pop ebx
334 pop ebp
335 ret
336EOF
337 push(@out,$tmp);
338 }
339
340sub main'file_end
341 {
342 # try to detect if SSE2 or MMX extensions were used...
343 my $xmmheader=<<___;
344.686
345.XMM
346IF \@Version LT 800
347XMMWORD STRUCT 16
348 DQ 2 dup (?)
349XMMWORD ENDS
350ENDIF
351___
352 if (grep {/\b[x]?mm[0-7]\b/i} @out) {
353 grep {s/\.[3-7]86/$xmmheader/} @out;
354 }
355 push(@out,"_TEXT\$ ENDS\n");
356 push(@out,"END\n");
357 }
358
359sub main'wparam
360 {
361 local($num)=@_;
362
363 return(&main'DWP($stack+$num*4,"esp","",0));
364 }
365
366sub main'swtmp
367 {
368 return(&main'DWP($_[0]*4,"esp","",0));
369 }
370
371# Should use swtmp, which is above esp. Linix can trash the stack above esp
372#sub main'wtmp
373# {
374# local($num)=@_;
375#
376# return(&main'DWP(-(($num+1)*4),"esp","",0));
377# }
378
379sub main'comment
380 {
381 foreach (@_)
382 {
383 push(@out,"\t; $_\n");
384 }
385 }
386
387sub main'public_label
388 {
389 $label{$_[0]}="_$_[0]" if (!defined($label{$_[0]}));
390 push(@out,"PUBLIC\t$label{$_[0]}\n");
391 }
392
393sub main'label
394 {
395 if (!defined($label{$_[0]}))
396 {
397 $label{$_[0]}="\$${label}${_[0]}";
398 $label++;
399 }
400 return($label{$_[0]});
401 }
402
403sub main'set_label
404 {
405 if (!defined($label{$_[0]}))
406 {
407 $label{$_[0]}="\$${label}${_[0]}";
408 $label++;
409 }
410 if ($_[1]!=0 && $_[1]>1)
411 {
412 main'align($_[1]);
413 }
414 if((defined $_[2]) && ($_[2] == 1))
415 {
416 push(@out,"$label{$_[0]}::\n");
417 }
418 elsif ($label{$_[0]} !~ /^\$/)
419 {
420 push(@out,"$label{$_[0]}\tLABEL PTR\n");
421 }
422 else
423 {
424 push(@out,"$label{$_[0]}:\n");
425 }
426 }
427
428sub main'data_byte
429 {
430 push(@out,"\tDB\t".join(',',@_)."\n");
431 }
432
433sub main'data_word
434 {
435 push(@out,"\tDD\t".join(',',@_)."\n");
436 }
437
438sub main'align
439 {
440 push(@out,"\tALIGN\t$_[0]\n");
441 }
442
443sub out1p
444 {
445 local($name,$p1)=@_;
446 local($l,$t);
447
448 push(@out,"\t$name\t".&conv($p1)."\n");
449 }
450
451sub main'picmeup
452 {
453 local($dst,$sym)=@_;
454 &main'lea($dst,&main'DWP($sym));
455 }
456
457sub main'blindpop { &out1("pop",@_); }
458
459sub main'initseg
460 {
461 local($f)=@_;
462 local($tmp)=<<___;
463OPTION DOTNAME
464.CRT\$XCU SEGMENT DWORD PUBLIC 'DATA'
465EXTRN _$f:NEAR
466DD _$f
467.CRT\$XCU ENDS
468___
469 push(@out,$tmp);
470 }
471
4721;
diff --git a/src/lib/libcrypto/perlasm/x86nasm.pl b/src/lib/libcrypto/perlasm/x86nasm.pl
index fa38f89c09..ce2bed9bb2 100644
--- a/src/lib/libcrypto/perlasm/x86nasm.pl
+++ b/src/lib/libcrypto/perlasm/x86nasm.pl
@@ -1,455 +1,166 @@
1#!/usr/local/bin/perl 1#!/usr/bin/env perl
2 2
3package x86nasm; 3package x86nasm;
4 4
5$label="L000"; 5*out=\@::out;
6$under=($main'netware)?'':'_';
7 6
8%lb=( 'eax', 'al', 7$::lbdecor="L\$"; # local label decoration
9 'ebx', 'bl', 8$nmdecor=$::netware?"":"_"; # external name decoration
10 'ecx', 'cl', 9$drdecor=$::mwerks?".":""; # directive decoration
11 'edx', 'dl',
12 'ax', 'al',
13 'bx', 'bl',
14 'cx', 'cl',
15 'dx', 'dl',
16 );
17 10
18%hb=( 'eax', 'ah', 11$initseg="";
19 'ebx', 'bh',
20 'ecx', 'ch',
21 'edx', 'dh',
22 'ax', 'ah',
23 'bx', 'bh',
24 'cx', 'ch',
25 'dx', 'dh',
26 );
27 12
28sub main'asm_init_output { @out=(); } 13sub ::generic
29sub main'asm_get_output { return(@out); } 14{ my $opcode=shift;
30sub main'get_labels { return(@labels); } 15 my $tmp;
31 16
32sub main'external_label 17 if (!$::mwerks)
33{ 18 { if ($opcode =~ m/^j/o && $#_==0) # optimize jumps
34 push(@labels,@_); 19 { $_[0] = "NEAR $_[0]"; }
35 foreach (@_) { 20 elsif ($opcode eq "lea" && $#_==1) # wipe storage qualifier from lea
36 push(@out,".") if ($main'mwerks); 21 { $_[1] =~ s/^[^\[]*\[/\[/o; }
37 push(@out, "extern\t${under}$_\n"); 22 }
38 } 23 &::emit($opcode,@_);
24 1;
39} 25}
40 26#
41sub main'LB 27# opcodes not covered by ::generic above, mostly inconsistent namings...
42 { 28#
43 (defined($lb{$_[0]})) || die "$_[0] does not have a 'low byte'\n"; 29sub ::call { &::emit("call",(&::islabel($_[0]) or "$nmdecor$_[0]")); }
44 return($lb{$_[0]}); 30sub ::call_ptr { &::emit("call",@_); }
45 } 31sub ::jmp_ptr { &::emit("jmp",@_); }
46
47sub main'HB
48 {
49 (defined($hb{$_[0]})) || die "$_[0] does not have a 'high byte'\n";
50 return($hb{$_[0]});
51 }
52
53sub main'BP
54 {
55 &get_mem("BYTE",@_);
56 }
57
58sub main'DWP
59 {
60 &get_mem("DWORD",@_);
61 }
62
63sub main'QWP
64 {
65 &get_mem("",@_);
66 }
67
68sub main'BC
69 {
70 return (($main'mwerks)?"":"BYTE ")."@_";
71 }
72
73sub main'DWC
74 {
75 return (($main'mwerks)?"":"DWORD ")."@_";
76 }
77
78sub main'stack_push
79 {
80 my($num)=@_;
81 $stack+=$num*4;
82 &main'sub("esp",$num*4);
83 }
84
85sub main'stack_pop
86 {
87 my($num)=@_;
88 $stack-=$num*4;
89 &main'add("esp",$num*4);
90 }
91 32
92sub get_mem 33sub get_mem
93 { 34{ my($size,$addr,$reg1,$reg2,$idx)=@_;
94 my($size,$addr,$reg1,$reg2,$idx)=@_; 35 my($post,$ret);
95 my($t,$post); 36
96 my($ret)=$size; 37 if ($size ne "")
97 if ($ret ne "") 38 { $ret .= "$size";
98 { 39 $ret .= " PTR" if ($::mwerks);
99 $ret .= " PTR" if ($main'mwerks); 40 $ret .= " ";
100 $ret .= " "; 41 }
101 } 42 $ret .= "[";
102 $ret .= "["; 43
103 $addr =~ s/^\s+//; 44 $addr =~ s/^\s+//;
104 if ($addr =~ /^(.+)\+(.+)$/) 45 # prepend global references with optional underscore
105 { 46 $addr =~ s/^([^\+\-0-9][^\+\-]*)/::islabel($1) or "$nmdecor$1"/ige;
106 $reg2=&conv($1); 47 # put address arithmetic expression in parenthesis
107 $addr="$under$2"; 48 $addr="($addr)" if ($addr =~ /^.+[\-\+].+$/);
108 } 49
109 elsif ($addr =~ /^[_a-z][_a-z0-9]*$/i) 50 if (($addr ne "") && ($addr ne 0))
110 { 51 { if ($addr !~ /^-/) { $ret .= "$addr+"; }
111 $addr="$under$addr"; 52 else { $post=$addr; }
112 } 53 }
113 54
114 if ($addr =~ /^.+\-.+$/) { $addr="($addr)"; } 55 if ($reg2 ne "")
115 56 { $idx!=0 or $idx=1;
116 $reg1="$regs{$reg1}" if defined($regs{$reg1}); 57 $ret .= "$reg2*$idx";
117 $reg2="$regs{$reg2}" if defined($regs{$reg2}); 58 $ret .= "+$reg1" if ($reg1 ne "");
118 if (($addr ne "") && ($addr ne 0)) 59 }
119 { 60 else
120 if ($addr !~ /^-/) 61 { $ret .= "$reg1"; }
121 { $ret.="${addr}+"; } 62
122 else { $post=$addr; } 63 $ret .= "$post]";
123 } 64 $ret =~ s/\+\]/]/; # in case $addr was the only argument
124 if ($reg2 ne "") 65
125 { 66 $ret;
126 $t=""; 67}
127 $t="*$idx" if ($idx != 0); 68sub ::BP { &get_mem("BYTE",@_); }
128 $reg1="+".$reg1 if ("$reg1$post" ne ""); 69sub ::DWP { &get_mem("DWORD",@_); }
129 $ret.="$reg2$t$reg1$post]"; 70sub ::QWP { &get_mem("",@_); }
130 } 71sub ::BC { (($::mwerks)?"":"BYTE ")."@_"; }
131 else 72sub ::DWC { (($::mwerks)?"":"DWORD ")."@_"; }
132 { 73
133 $ret.="$reg1$post]" 74sub ::file
134 } 75{ if ($::mwerks) { push(@out,".section\t.text,64\n"); }
135 $ret =~ s/\+\]/]/; # in case $addr was the only argument 76 else
136 return($ret); 77 { my $tmp=<<___;
137 } 78%ifidn __OUTPUT_FORMAT__,obj
138 79section code use32 class=code align=64
139sub main'mov { &out2("mov",@_); } 80%elifidn __OUTPUT_FORMAT__,win32
140sub main'movb { &out2("mov",@_); } 81\$\@feat.00 equ 1
141sub main'and { &out2("and",@_); } 82section .text code align=64
142sub main'or { &out2("or",@_); }
143sub main'shl { &out2("shl",@_); }
144sub main'shr { &out2("shr",@_); }
145sub main'xor { &out2("xor",@_); }
146sub main'xorb { &out2("xor",@_); }
147sub main'add { &out2("add",@_); }
148sub main'adc { &out2("adc",@_); }
149sub main'sub { &out2("sub",@_); }
150sub main'sbb { &out2("sbb",@_); }
151sub main'rotl { &out2("rol",@_); }
152sub main'rotr { &out2("ror",@_); }
153sub main'exch { &out2("xchg",@_); }
154sub main'cmp { &out2("cmp",@_); }
155sub main'lea { &out2("lea",@_); }
156sub main'mul { &out1("mul",@_); }
157sub main'imul { &out2("imul",@_); }
158sub main'div { &out1("div",@_); }
159sub main'dec { &out1("dec",@_); }
160sub main'inc { &out1("inc",@_); }
161sub main'jmp { &out1("jmp",@_); }
162sub main'jmp_ptr { &out1p("jmp",@_); }
163
164# This is a bit of a kludge: declare all branches as NEAR.
165$near=($main'mwerks)?'':'NEAR';
166sub main'je { &out1("je $near",@_); }
167sub main'jle { &out1("jle $near",@_); }
168sub main'jz { &out1("jz $near",@_); }
169sub main'jge { &out1("jge $near",@_); }
170sub main'jl { &out1("jl $near",@_); }
171sub main'ja { &out1("ja $near",@_); }
172sub main'jae { &out1("jae $near",@_); }
173sub main'jb { &out1("jb $near",@_); }
174sub main'jbe { &out1("jbe $near",@_); }
175sub main'jc { &out1("jc $near",@_); }
176sub main'jnc { &out1("jnc $near",@_); }
177sub main'jnz { &out1("jnz $near",@_); }
178sub main'jne { &out1("jne $near",@_); }
179sub main'jno { &out1("jno $near",@_); }
180
181sub main'push { &out1("push",@_); $stack+=4; }
182sub main'pop { &out1("pop",@_); $stack-=4; }
183sub main'pushf { &out0("pushfd"); $stack+=4; }
184sub main'popf { &out0("popfd"); $stack-=4; }
185sub main'bswap { &out1("bswap",@_); &using486(); }
186sub main'not { &out1("not",@_); }
187sub main'call { &out1("call",($_[0]=~/^\@L/?'':$under).$_[0]); }
188sub main'call_ptr { &out1p("call",@_); }
189sub main'ret { &out0("ret"); }
190sub main'nop { &out0("nop"); }
191sub main'test { &out2("test",@_); }
192sub main'bt { &out2("bt",@_); }
193sub main'leave { &out0("leave"); }
194sub main'cpuid { &out0("cpuid"); }
195sub main'rdtsc { &out0("rdtsc"); }
196sub main'halt { &out0("hlt"); }
197sub main'movz { &out2("movzx",@_); }
198sub main'neg { &out1("neg",@_); }
199sub main'cld { &out0("cld"); }
200
201# SSE2
202sub main'emms { &out0("emms"); }
203sub main'movd { &out2("movd",@_); }
204sub main'movq { &out2("movq",@_); }
205sub main'movdqu { &out2("movdqu",@_); }
206sub main'movdqa { &out2("movdqa",@_); }
207sub main'movdq2q{ &out2("movdq2q",@_); }
208sub main'movq2dq{ &out2("movq2dq",@_); }
209sub main'paddq { &out2("paddq",@_); }
210sub main'pmuludq{ &out2("pmuludq",@_); }
211sub main'psrlq { &out2("psrlq",@_); }
212sub main'psllq { &out2("psllq",@_); }
213sub main'pxor { &out2("pxor",@_); }
214sub main'por { &out2("por",@_); }
215sub main'pand { &out2("pand",@_); }
216
217sub out2
218 {
219 my($name,$p1,$p2)=@_;
220 my($l,$t);
221
222 push(@out,"\t$name\t");
223 if (!$main'mwerks and $name eq "lea")
224 {
225 $p1 =~ s/^[^\[]*\[/\[/;
226 $p2 =~ s/^[^\[]*\[/\[/;
227 }
228 $t=&conv($p1).",";
229 $l=length($t);
230 push(@out,$t);
231 $l=4-($l+9)/8;
232 push(@out,"\t" x $l);
233 push(@out,&conv($p2));
234 push(@out,"\n");
235 }
236
237sub out0
238 {
239 my($name)=@_;
240
241 push(@out,"\t$name\n");
242 }
243
244sub out1
245 {
246 my($name,$p1)=@_;
247 my($l,$t);
248 push(@out,"\t$name\t".&conv($p1)."\n");
249 }
250
251sub conv
252 {
253 my($p)=@_;
254 $p =~ s/0x([0-9A-Fa-f]+)/0$1h/;
255 return $p;
256 }
257
258sub using486
259 {
260 return if $using486;
261 $using486++;
262 grep(s/\.386/\.486/,@out);
263 }
264
265sub main'file
266 {
267 if ($main'mwerks) { push(@out,".section\t.text\n"); }
268 else {
269 local $tmp=<<___;
270%ifdef __omf__
271section code use32 class=code
272%else 83%else
273section .text 84section .text code
274%endif 85%endif
275___ 86___
276 push(@out,$tmp);
277 }
278 }
279
280sub main'function_begin
281 {
282 my($func,$extra)=@_;
283
284 push(@labels,$func);
285 push(@out,".") if ($main'mwerks);
286 my($tmp)=<<"EOF";
287global $under$func
288$under$func:
289 push ebp
290 push ebx
291 push esi
292 push edi
293EOF
294 push(@out,$tmp);
295 $stack=20;
296 }
297
298sub main'function_begin_B
299 {
300 my($func,$extra)=@_;
301 push(@out,".") if ($main'mwerks);
302 my($tmp)=<<"EOF";
303global $under$func
304$under$func:
305EOF
306 push(@out,$tmp);
307 $stack=4;
308 }
309
310sub main'function_end
311 {
312 my($func)=@_;
313
314 my($tmp)=<<"EOF";
315 pop edi
316 pop esi
317 pop ebx
318 pop ebp
319 ret
320EOF
321 push(@out,$tmp); 87 push(@out,$tmp);
322 $stack=0; 88 }
323 %label=(); 89}
324 }
325
326sub main'function_end_B
327 {
328 $stack=0;
329 %label=();
330 }
331
332sub main'function_end_A
333 {
334 my($func)=@_;
335
336 my($tmp)=<<"EOF";
337 pop edi
338 pop esi
339 pop ebx
340 pop ebp
341 ret
342EOF
343 push(@out,$tmp);
344 }
345
346sub main'file_end
347 {
348 }
349
350sub main'wparam
351 {
352 my($num)=@_;
353
354 return(&main'DWP($stack+$num*4,"esp","",0));
355 }
356 90
357sub main'swtmp 91sub ::function_begin_B
358 { 92{ my $func=shift;
359 return(&main'DWP($_[0]*4,"esp","",0)); 93 my $global=($func !~ /^_/);
360 } 94 my $begin="${::lbdecor}_${func}_begin";
361 95
362# Should use swtmp, which is above esp. Linix can trash the stack above esp 96 $begin =~ s/^\@/./ if ($::mwerks); # the torture never stops
363#sub main'wtmp
364# {
365# my($num)=@_;
366#
367# return(&main'DWP(-(($num+1)*4),"esp","",0));
368# }
369 97
370sub main'comment 98 &::LABEL($func,$global?"$begin":"$nmdecor$func");
371 { 99 $func=$nmdecor.$func;
372 foreach (@_)
373 {
374 push(@out,"\t; $_\n");
375 }
376 }
377 100
378sub main'public_label 101 push(@out,"${drdecor}global $func\n") if ($global);
379 { 102 push(@out,"${drdecor}align 16\n");
380 $label{$_[0]}="${under}${_[0]}" if (!defined($label{$_[0]})); 103 push(@out,"$func:\n");
381 push(@out,".") if ($main'mwerks); 104 push(@out,"$begin:\n") if ($global);
382 push(@out,"global\t$label{$_[0]}\n"); 105 $::stack=4;
383 } 106}
384 107
385sub main'label 108sub ::function_end_B
386 { 109{ $::stack=0;
387 if (!defined($label{$_[0]})) 110 &::wipe_labels();
388 { 111}
389 $label{$_[0]}="\@${label}${_[0]}";
390 $label++;
391 }
392 return($label{$_[0]});
393 }
394 112
395sub main'set_label 113sub ::file_end
396 { 114{ if (grep {/\b${nmdecor}OPENSSL_ia32cap_P\b/i} @out)
397 if (!defined($label{$_[0]})) 115 { my $comm=<<___;
398 { 116${drdecor}segment .bss
399 $label{$_[0]}="\@${label}${_[0]}"; 117${drdecor}common ${nmdecor}OPENSSL_ia32cap_P 4
400 $label++; 118___
401 } 119 # comment out OPENSSL_ia32cap_P declarations
402 if ($_[1]!=0 && $_[1]>1) 120 grep {s/(^extern\s+${nmdecor}OPENSSL_ia32cap_P)/\;$1/} @out;
403 { 121 push (@out,$comm)
404 main'align($_[1]); 122 }
405 } 123 push (@out,$initseg) if ($initseg);
406 push(@out,"$label{$_[0]}:\n"); 124}
407 }
408 125
409sub main'data_byte 126sub ::comment { foreach (@_) { push(@out,"\t; $_\n"); } }
410 {
411 push(@out,(($main'mwerks)?".byte\t":"DB\t").join(',',@_)."\n");
412 }
413 127
414sub main'data_word 128sub ::external_label
415 { 129{ foreach(@_)
416 push(@out,(($main'mwerks)?".long\t":"DD\t").join(',',@_)."\n"); 130 { push(@out,"${drdecor}extern\t".&::LABEL($_,$nmdecor.$_)."\n"); }
417 } 131}
418 132
419sub main'align 133sub ::public_label
420 { 134{ push(@out,"${drdecor}global\t".&::LABEL($_[0],$nmdecor.$_[0])."\n"); }
421 push(@out,".") if ($main'mwerks);
422 push(@out,"align\t$_[0]\n");
423 }
424 135
425sub out1p 136sub ::data_byte
426 { 137{ push(@out,(($::mwerks)?".byte\t":"db\t").join(',',@_)."\n"); }
427 my($name,$p1)=@_;
428 my($l,$t);
429 138
430 push(@out,"\t$name\t".&conv($p1)."\n"); 139sub ::data_word
431 } 140{ push(@out,(($::mwerks)?".long\t":"dd\t").join(',',@_)."\n"); }
432 141
433sub main'picmeup 142sub ::align
434 { 143{ push(@out,"${drdecor}align\t$_[0]\n"); }
435 local($dst,$sym)=@_;
436 &main'lea($dst,&main'DWP($sym));
437 }
438 144
439sub main'blindpop { &out1("pop",@_); } 145sub ::picmeup
146{ my($dst,$sym)=@_;
147 &::lea($dst,&::DWP($sym));
148}
440 149
441sub main'initseg 150sub ::initseg
442 { 151{ my $f=$nmdecor.shift;
443 local($f)=@_; 152 if ($::win32)
444 if ($main'win32) 153 { $initseg=<<___;
445 { 154segment .CRT\$XCU data align=4
446 local($tmp)=<<___; 155extern $f
447segment .CRT\$XCU data 156dd $f
448extern $under$f
449DD $under$f
450___ 157___
451 push(@out,$tmp); 158 }
452 } 159}
453 } 160
161sub ::dataseg
162{ if ($mwerks) { push(@out,".section\t.data,4\n"); }
163 else { push(@out,"section\t.data align=4\n"); }
164}
454 165
4551; 1661;
diff --git a/src/lib/libcrypto/perlasm/x86unix.pl b/src/lib/libcrypto/perlasm/x86unix.pl
deleted file mode 100644
index ae8f0964dc..0000000000
--- a/src/lib/libcrypto/perlasm/x86unix.pl
+++ /dev/null
@@ -1,808 +0,0 @@
1#!/usr/local/bin/perl
2
3package x86unix; # GAS actually...
4
5$label="L000";
6$const="";
7$constl=0;
8
9$align=($main'aout)?"4":"16";
10$under=($main'aout or $main'coff)?"_":"";
11$dot=($main'aout)?"":".";
12$com_start="#" if ($main'aout or $main'coff);
13
14sub main'asm_init_output { @out=(); }
15sub main'asm_get_output { return(@out); }
16sub main'get_labels { return(@labels); }
17sub main'external_label { push(@labels,@_); }
18
19if ($main'openbsd)
20 {
21 $com_start='/*';
22 $com_end='*/';
23 }
24
25if ($main'cpp)
26 {
27 $align="ALIGN";
28 $under="";
29 $com_start='/*';
30 $com_end='*/';
31 }
32
33%lb=( 'eax', '%al',
34 'ebx', '%bl',
35 'ecx', '%cl',
36 'edx', '%dl',
37 'ax', '%al',
38 'bx', '%bl',
39 'cx', '%cl',
40 'dx', '%dl',
41 );
42
43%hb=( 'eax', '%ah',
44 'ebx', '%bh',
45 'ecx', '%ch',
46 'edx', '%dh',
47 'ax', '%ah',
48 'bx', '%bh',
49 'cx', '%ch',
50 'dx', '%dh',
51 );
52
53%regs=( 'eax', '%eax',
54 'ebx', '%ebx',
55 'ecx', '%ecx',
56 'edx', '%edx',
57 'esi', '%esi',
58 'edi', '%edi',
59 'ebp', '%ebp',
60 'esp', '%esp',
61
62 'mm0', '%mm0',
63 'mm1', '%mm1',
64 'mm2', '%mm2',
65 'mm3', '%mm3',
66 'mm4', '%mm4',
67 'mm5', '%mm5',
68 'mm6', '%mm6',
69 'mm7', '%mm7',
70
71 'xmm0', '%xmm0',
72 'xmm1', '%xmm1',
73 'xmm2', '%xmm2',
74 'xmm3', '%xmm3',
75 'xmm4', '%xmm4',
76 'xmm5', '%xmm5',
77 'xmm6', '%xmm6',
78 'xmm7', '%xmm7',
79 );
80
81%reg_val=(
82 'eax', 0x00,
83 'ebx', 0x03,
84 'ecx', 0x01,
85 'edx', 0x02,
86 'esi', 0x06,
87 'edi', 0x07,
88 'ebp', 0x05,
89 'esp', 0x04,
90 );
91
92sub main'LB
93 {
94 (defined($lb{$_[0]})) || die "$_[0] does not have a 'low byte'\n";
95 return($lb{$_[0]});
96 }
97
98sub main'HB
99 {
100 (defined($hb{$_[0]})) || die "$_[0] does not have a 'high byte'\n";
101 return($hb{$_[0]});
102 }
103
104sub main'DWP
105 {
106 local($addr,$reg1,$reg2,$idx)=@_;
107
108 $ret="";
109 $addr =~ s/(^|[+ \t])([A-Za-z_]+[A-Za-z0-9_]+)($|[+ \t])/$1$under$2$3/;
110 $reg1="$regs{$reg1}" if defined($regs{$reg1});
111 $reg2="$regs{$reg2}" if defined($regs{$reg2});
112 $ret.=$addr if ($addr ne "") && ($addr ne 0);
113 if ($reg2 ne "")
114 {
115 if($idx ne "" && $idx != 0)
116 { $ret.="($reg1,$reg2,$idx)"; }
117 else
118 { $ret.="($reg1,$reg2)"; }
119 }
120 elsif ($reg1 ne "")
121 { $ret.="($reg1)" }
122 return($ret);
123 }
124
125sub main'QWP
126 {
127 return(&main'DWP(@_));
128 }
129
130sub main'BP
131 {
132 return(&main'DWP(@_));
133 }
134
135sub main'BC
136 {
137 return @_;
138 }
139
140sub main'DWC
141 {
142 return @_;
143 }
144
145#sub main'BP
146# {
147# local($addr,$reg1,$reg2,$idx)=@_;
148#
149# $ret="";
150#
151# $addr =~ s/(^|[+ \t])([A-Za-z_]+)($|[+ \t])/$1$under$2$3/;
152# $reg1="$regs{$reg1}" if defined($regs{$reg1});
153# $reg2="$regs{$reg2}" if defined($regs{$reg2});
154# $ret.=$addr if ($addr ne "") && ($addr ne 0);
155# if ($reg2 ne "")
156# { $ret.="($reg1,$reg2,$idx)"; }
157# else
158# { $ret.="($reg1)" }
159# return($ret);
160# }
161
162sub main'mov { &out2("movl",@_); }
163sub main'movb { &out2("movb",@_); }
164sub main'and { &out2("andl",@_); }
165sub main'or { &out2("orl",@_); }
166sub main'shl { &out2("sall",@_); }
167sub main'shr { &out2("shrl",@_); }
168sub main'xor { &out2("xorl",@_); }
169sub main'xorb { &out2("xorb",@_); }
170sub main'add { &out2($_[0]=~/%[a-d][lh]/?"addb":"addl",@_); }
171sub main'adc { &out2("adcl",@_); }
172sub main'sub { &out2("subl",@_); }
173sub main'sbb { &out2("sbbl",@_); }
174sub main'rotl { &out2("roll",@_); }
175sub main'rotr { &out2("rorl",@_); }
176sub main'exch { &out2($_[0]=~/%[a-d][lh]/?"xchgb":"xchgl",@_); }
177sub main'cmp { &out2("cmpl",@_); }
178sub main'lea { &out2("leal",@_); }
179sub main'mul { &out1("mull",@_); }
180sub main'imul { &out2("imull",@_); }
181sub main'div { &out1("divl",@_); }
182sub main'jmp { &out1("jmp",@_); }
183sub main'jmp_ptr { &out1p("jmp",@_); }
184sub main'je { &out1("je",@_); }
185sub main'jle { &out1("jle",@_); }
186sub main'jne { &out1("jne",@_); }
187sub main'jnz { &out1("jnz",@_); }
188sub main'jz { &out1("jz",@_); }
189sub main'jge { &out1("jge",@_); }
190sub main'jl { &out1("jl",@_); }
191sub main'ja { &out1("ja",@_); }
192sub main'jae { &out1("jae",@_); }
193sub main'jb { &out1("jb",@_); }
194sub main'jbe { &out1("jbe",@_); }
195sub main'jc { &out1("jc",@_); }
196sub main'jnc { &out1("jnc",@_); }
197sub main'jno { &out1("jno",@_); }
198sub main'dec { &out1("decl",@_); }
199sub main'inc { &out1($_[0]=~/%[a-d][hl]/?"incb":"incl",@_); }
200sub main'push { &out1("pushl",@_); $stack+=4; }
201sub main'pop { &out1("popl",@_); $stack-=4; }
202sub main'pushf { &out0("pushfl"); $stack+=4; }
203sub main'popf { &out0("popfl"); $stack-=4; }
204sub main'not { &out1("notl",@_); }
205sub main'call { my $pre=$under;
206 foreach $i (%label)
207 { if ($label{$i} eq $_[0]) { $pre=''; last; } }
208 &out1("call",$pre.$_[0]);
209 }
210sub main'call_ptr { &out1p("call",@_); }
211sub main'ret { &out0("ret"); }
212sub main'nop { &out0("nop"); }
213sub main'test { &out2("testl",@_); }
214sub main'bt { &out2("btl",@_); }
215sub main'leave { &out0("leave"); }
216sub main'cpuid { &out0(".byte\t0x0f,0xa2"); }
217sub main'rdtsc { &out0(".byte\t0x0f,0x31"); }
218sub main'halt { &out0("hlt"); }
219sub main'movz { &out2("movzbl",@_); }
220sub main'neg { &out1("negl",@_); }
221sub main'cld { &out0("cld"); }
222
223# SSE2
224sub main'emms { &out0("emms"); }
225sub main'movd { &out2("movd",@_); }
226sub main'movdqu { &out2("movdqu",@_); }
227sub main'movdqa { &out2("movdqa",@_); }
228sub main'movdq2q{ &out2("movdq2q",@_); }
229sub main'movq2dq{ &out2("movq2dq",@_); }
230sub main'paddq { &out2("paddq",@_); }
231sub main'pmuludq{ &out2("pmuludq",@_); }
232sub main'psrlq { &out2("psrlq",@_); }
233sub main'psllq { &out2("psllq",@_); }
234sub main'pxor { &out2("pxor",@_); }
235sub main'por { &out2("por",@_); }
236sub main'pand { &out2("pand",@_); }
237sub main'movq {
238 local($p1,$p2,$optimize)=@_;
239 if ($optimize && $p1=~/^mm[0-7]$/ && $p2=~/^mm[0-7]$/)
240 # movq between mmx registers can sink Intel CPUs
241 { push(@out,"\tpshufw\t\$0xe4,%$p2,%$p1\n"); }
242 else { &out2("movq",@_); }
243 }
244
245# The bswapl instruction is new for the 486. Emulate if i386.
246sub main'bswap
247 {
248 if ($main'i386)
249 {
250 &main'comment("bswapl @_");
251 &main'exch(main'HB(@_),main'LB(@_));
252 &main'rotr(@_,16);
253 &main'exch(main'HB(@_),main'LB(@_));
254 }
255 else
256 {
257 &out1("bswapl",@_);
258 }
259 }
260
261sub out2
262 {
263 local($name,$p1,$p2)=@_;
264 local($l,$ll,$t);
265 local(%special)=( "roll",0xD1C0,"rorl",0xD1C8,
266 "rcll",0xD1D0,"rcrl",0xD1D8,
267 "shll",0xD1E0,"shrl",0xD1E8,
268 "sarl",0xD1F8);
269
270 if ((defined($special{$name})) && defined($regs{$p1}) && ($p2 == 1))
271 {
272 $op=$special{$name}|$reg_val{$p1};
273 $tmp1=sprintf(".byte %d\n",($op>>8)&0xff);
274 $tmp2=sprintf(".byte %d\t",$op &0xff);
275 push(@out,$tmp1);
276 push(@out,$tmp2);
277
278 $p2=&conv($p2);
279 $p1=&conv($p1);
280 &main'comment("$name $p2 $p1");
281 return;
282 }
283
284 push(@out,"\t$name\t");
285 $t=&conv($p2).",";
286 $l=length($t);
287 push(@out,$t);
288 $ll=4-($l+9)/8;
289 $tmp1=sprintf("\t" x $ll);
290 push(@out,$tmp1);
291 push(@out,&conv($p1)."\n");
292 }
293
294sub out1
295 {
296 local($name,$p1)=@_;
297 local($l,$t);
298 local(%special)=("bswapl",0x0FC8);
299
300 if ((defined($special{$name})) && defined($regs{$p1}))
301 {
302 $op=$special{$name}|$reg_val{$p1};
303 $tmp1=sprintf(".byte %d\n",($op>>8)&0xff);
304 $tmp2=sprintf(".byte %d\t",$op &0xff);
305 push(@out,$tmp1);
306 push(@out,$tmp2);
307
308 $p2=&conv($p2);
309 $p1=&conv($p1);
310 &main'comment("$name $p2 $p1");
311 return;
312 }
313
314 push(@out,"\t$name\t".&conv($p1)."\n");
315 }
316
317sub out1p
318 {
319 local($name,$p1)=@_;
320 local($l,$t);
321
322 push(@out,"\t$name\t*".&conv($p1)."\n");
323 }
324
325sub out0
326 {
327 push(@out,"\t$_[0]\n");
328 }
329
330sub conv
331 {
332 local($p)=@_;
333
334# $p =~ s/0x([0-9A-Fa-f]+)/0$1h/;
335
336 $p=$regs{$p} if (defined($regs{$p}));
337
338 $p =~ s/^(-{0,1}[0-9A-Fa-f]+)$/\$$1/;
339 $p =~ s/^(0x[0-9A-Fa-f]+)$/\$$1/;
340 return $p;
341 }
342
343sub main'file
344 {
345 local($file)=@_;
346
347 if ($main'openbsd)
348 { push(@out,"#include <machine/asm.h>\n"); }
349
350 local($tmp)=<<"EOF";
351 .file "$file.s"
352EOF
353 push(@out,$tmp);
354 }
355
356sub main'function_begin
357 {
358 local($func,$junk,$llabel)=@_;
359
360 &main'external_label($func);
361 $func=$under.$func;
362
363 if ($main'openbsd)
364 {
365 push (@out, "\nENTRY($func)\n");
366 push (@out, "$llabel:\n") if $llabel;
367 goto skip;
368 }
369
370 local($tmp)=<<"EOF";
371.text
372.globl $func
373EOF
374 push(@out,$tmp);
375 if ($main'cpp)
376 { $tmp=push(@out,"TYPE($func,\@function)\n"); }
377 elsif ($main'coff)
378 { $tmp=push(@out,".def\t$func;\t.scl\t2;\t.type\t32;\t.endef\n"); }
379 elsif ($main'aout and !$main'pic)
380 { }
381 else { $tmp=push(@out,".type\t$func,\@function\n"); }
382 push(@out,".align\t$align\n");
383 push(@out,"$func:\n");
384skip:
385 $tmp=<<"EOF";
386 pushl %ebp
387 pushl %ebx
388 pushl %esi
389 pushl %edi
390
391EOF
392 push(@out,$tmp);
393 $stack=20;
394 }
395
396sub main'function_begin_B
397 {
398 local($func,$extra)=@_;
399
400 &main'external_label($func);
401 $func=$under.$func;
402
403 if ($main'openbsd)
404 { push(@out, "\nENTRY($func)\n"); goto skip; }
405
406 local($tmp)=<<"EOF";
407.text
408.globl $func
409EOF
410 push(@out,$tmp);
411 if ($main'cpp)
412 { push(@out,"TYPE($func,\@function)\n"); }
413 elsif ($main'coff)
414 { $tmp=push(@out,".def\t$func;\t.scl\t2;\t.type\t32;\t.endef\n"); }
415 elsif ($main'aout and !$main'pic)
416 { }
417 else { push(@out,".type $func,\@function\n"); }
418 push(@out,".align\t$align\n");
419 push(@out,"$func:\n");
420skip:
421 $stack=4;
422 }
423
424# Like function_begin_B but with static linkage
425sub main'function_begin_C
426 {
427 local($func,$extra)=@_;
428
429 &main'external_label($func);
430 $func=$under.$func;
431
432 if ($main'openbsd)
433 {
434 local($tmp)=<<"EOF";
435.text
436_ALIGN_TEXT
437.type $func,\@function
438$func:
439EOF
440 push(@out, $tmp);
441 goto skip;
442 }
443
444 local($tmp)=<<"EOF";
445.text
446.globl $func
447EOF
448 push(@out,$tmp);
449 if ($main'cpp)
450 { push(@out,"TYPE($func,\@function)\n"); }
451 elsif ($main'coff)
452 { $tmp=push(@out,".def\t$func;\t.scl\t2;\t.type\t32;\t.endef\n"); }
453 elsif ($main'aout and !$main'pic)
454 { }
455 else { push(@out,".type $func,\@function\n"); }
456 push(@out,".align\t$align\n");
457 push(@out,"$func:\n");
458skip:
459 $stack=4;
460 }
461
462sub main'function_end
463 {
464 local($func)=@_;
465
466 $func=$under.$func;
467
468 local($tmp)=<<"EOF";
469 popl %edi
470 popl %esi
471 popl %ebx
472 popl %ebp
473 ret
474${dot}L_${func}_end:
475EOF
476 push(@out,$tmp);
477
478 if ($main'cpp)
479 { push(@out,"SIZE($func,${dot}L_${func}_end-$func)\n"); }
480 elsif ($main'coff or $main'aout)
481 { }
482 else { push(@out,".size\t$func,${dot}L_${func}_end-$func\n"); }
483 push(@out,".ident \"$func\"\n");
484 $stack=0;
485 %label=();
486 }
487
488sub main'function_end_A
489 {
490 local($func)=@_;
491
492 local($tmp)=<<"EOF";
493 popl %edi
494 popl %esi
495 popl %ebx
496 popl %ebp
497 ret
498EOF
499 push(@out,$tmp);
500 }
501
502sub main'function_end_B
503 {
504 local($func)=@_;
505
506 $func=$under.$func;
507
508 push(@out,"${dot}L_${func}_end:\n");
509 if ($main'cpp)
510 { push(@out,"SIZE($func,${dot}L_${func}_end-$func)\n"); }
511 elsif ($main'coff or $main'aout)
512 { }
513 else { push(@out,".size\t$func,${dot}L_${func}_end-$func\n"); }
514 push(@out,".ident \"$func\"\n");
515 $stack=0;
516 %label=();
517 }
518
519sub main'function_end_C { function_end_B(@_); }
520
521sub main'wparam
522 {
523 local($num)=@_;
524
525 return(&main'DWP($stack+$num*4,"esp","",0));
526 }
527
528sub main'stack_push
529 {
530 local($num)=@_;
531 $stack+=$num*4;
532 &main'sub("esp",$num*4);
533 }
534
535sub main'stack_pop
536 {
537 local($num)=@_;
538 $stack-=$num*4;
539 &main'add("esp",$num*4);
540 }
541
542sub main'swtmp
543 {
544 return(&main'DWP($_[0]*4,"esp","",0));
545 }
546
547# Should use swtmp, which is above esp. Linix can trash the stack above esp
548#sub main'wtmp
549# {
550# local($num)=@_;
551#
552# return(&main'DWP(-($num+1)*4,"esp","",0));
553# }
554
555sub main'comment
556 {
557 if (!defined($com_start) or (!$main'openbsd && $main'elf))
558 { # Regarding $main'elf above...
559 # GNU and SVR4 as'es use different comment delimiters,
560 push(@out,"\n"); # so we just skip ELF comments...
561 return;
562 }
563 foreach (@_)
564 {
565 if (/^\s*$/)
566 { push(@out,"\n"); }
567 else
568 { push(@out,"\t$com_start $_ $com_end\n"); }
569 }
570 }
571
572sub main'public_label
573 {
574 $label{$_[0]}="${under}${_[0]}" if (!defined($label{$_[0]}));
575 push(@out,".globl\t$label{$_[0]}\n");
576 }
577
578sub main'label
579 {
580 if (!defined($label{$_[0]}))
581 {
582 $label{$_[0]}="${dot}${label}${_[0]}";
583 $label++;
584 }
585 return($label{$_[0]});
586 }
587
588sub main'set_label
589 {
590 if (!defined($label{$_[0]}))
591 {
592 $label{$_[0]}="${dot}${label}${_[0]}";
593 $label++;
594 }
595 if ($_[1]!=0)
596 {
597 if ($_[1]>1) { main'align($_[1]); }
598 else
599 {
600 if ($main'openbsd)
601 { push(@out,"_ALIGN_TEXT\n"); }
602 else
603 { push(@out,".align $align\n"); }
604 }
605 }
606 push(@out,"$label{$_[0]}:\n");
607 }
608
609sub main'file_end
610 {
611 # try to detect if SSE2 or MMX extensions were used on ELF platform...
612 if ($main'elf && grep {/\b%[x]*mm[0-7]\b|OPENSSL_ia32cap_P\b/i} @out) {
613 local($tmp);
614
615 push (@out,"\n.section\t.bss\n");
616 push (@out,".comm\t${under}OPENSSL_ia32cap_P,4,4\n");
617
618 return;
619 }
620
621 if ($const ne "")
622 {
623 push(@out,".section .rodata\n");
624 push(@out,$const);
625 $const="";
626 }
627 }
628
629sub main'data_byte
630 {
631 push(@out,"\t.byte\t".join(',',@_)."\n");
632 }
633
634sub main'data_word
635 {
636 push(@out,"\t.long\t".join(',',@_)."\n");
637 }
638
639sub main'align
640 {
641 my $val=$_[0],$p2,$i;
642 if ($main'aout) {
643 for ($p2=0;$val!=0;$val>>=1) { $p2++; }
644 $val=$p2-1;
645 $val.=",0x90";
646 }
647 push(@out,".align\t$val\n");
648 if ($main'openbsd)
649 { push(@out,"_ALIGN_TEXT\n"); }
650 else
651 { push(@out,".align $tval\n"); }
652 }
653
654# debug output functions: puts, putx, printf
655
656sub main'puts
657 {
658 &pushvars();
659 &main'push('$Lstring' . ++$constl);
660 &main'call('puts');
661 $stack-=4;
662 &main'add("esp",4);
663 &popvars();
664
665 $const .= "Lstring$constl:\n\t.string \"@_[0]\"\n";
666 }
667
668sub main'putx
669 {
670 &pushvars();
671 &main'push($_[0]);
672 &main'push('$Lstring' . ++$constl);
673 &main'call('printf');
674 &main'add("esp",8);
675 $stack-=8;
676 &popvars();
677
678 $const .= "Lstring$constl:\n\t.string \"\%X\"\n";
679 }
680
681sub main'printf
682 {
683 $ostack = $stack;
684 &pushvars();
685 for ($i = @_ - 1; $i >= 0; $i--)
686 {
687 if ($i == 0) # change this to support %s format strings
688 {
689 &main'push('$Lstring' . ++$constl);
690 $const .= "Lstring$constl:\n\t.string \"@_[$i]\"\n";
691 }
692 else
693 {
694 if ($_[$i] =~ /([0-9]*)\(%esp\)/)
695 {
696 &main'push(($1 + $stack - $ostack) . '(%esp)');
697 }
698 else
699 {
700 &main'push($_[$i]);
701 }
702 }
703 }
704 &main'call('printf');
705 $stack-=4*@_;
706 &main'add("esp",4*@_);
707 &popvars();
708 }
709
710sub pushvars
711 {
712 &main'pushf();
713 &main'push("edx");
714 &main'push("ecx");
715 &main'push("eax");
716 }
717
718sub popvars
719 {
720 &main'pop("eax");
721 &main'pop("ecx");
722 &main'pop("edx");
723 &main'popf();
724 }
725
726sub main'picmeup
727 {
728 local($dst,$sym)=@_;
729 if ($main'cpp)
730 {
731 local($tmp)=<<___;
732#if (defined(ELF) || defined(SOL)) && defined(PIC)
733 call 1f
7341: popl $regs{$dst}
735 addl \$_GLOBAL_OFFSET_TABLE_+[.-1b],$regs{$dst}
736 movl $sym\@GOT($regs{$dst}),$regs{$dst}
737#else
738 leal $sym,$regs{$dst}
739#endif
740___
741 push(@out,$tmp);
742 }
743 elsif ($main'openbsd)
744 {
745 push(@out, "#ifdef PIC\n");
746 push(@out, "\tPIC_PROLOGUE\n");
747 &main'mov($dst,"PIC_GOT($sym)");
748 push(@out, "\tPIC_EPILOGUE\n");
749 push(@out, "#else\n");
750 &main'lea($dst,&main'DWP($sym));
751 push(@out, "#endif\n");
752 }
753 elsif ($main'pic && ($main'elf || $main'aout))
754 {
755 &main'call(&main'label("PIC_me_up"));
756 &main'set_label("PIC_me_up");
757 &main'blindpop($dst);
758 &main'add($dst,"\$${under}_GLOBAL_OFFSET_TABLE_+[.-".
759 &main'label("PIC_me_up") . "]");
760 &main'mov($dst,&main'DWP($under.$sym."\@GOT",$dst));
761 }
762 else
763 {
764 &main'lea($dst,&main'DWP($sym));
765 }
766 }
767
768sub main'blindpop { &out1("popl",@_); }
769
770sub main'initseg
771 {
772 local($f)=@_;
773 local($tmp);
774 if ($main'elf)
775 {
776 $tmp=<<___;
777.section .init
778 PIC_PROLOGUE
779 call PIC_PLT($under$f)
780 PIC_EPILOGUE
781 jmp .Linitalign
782.align $align
783.Linitalign:
784___
785 }
786 elsif ($main'coff)
787 {
788 $tmp=<<___; # applies to both Cygwin and Mingw
789.section .ctors
790.long $under$f
791___
792 }
793 elsif ($main'aout)
794 {
795 local($ctor)="${under}_GLOBAL_\$I\$$f";
796 $tmp=".text\n";
797 $tmp.=".type $ctor,\@function\n" if ($main'pic);
798 $tmp.=<<___; # OpenBSD way...
799.globl $ctor
800.align 2
801$ctor:
802 jmp $under$f
803___
804 }
805 push(@out,$tmp) if ($tmp);
806 }
807
8081;
diff --git a/src/lib/libcrypto/pkcs12/Makefile.ssl b/src/lib/libcrypto/pkcs12/Makefile.ssl
deleted file mode 100644
index a6e47b4085..0000000000
--- a/src/lib/libcrypto/pkcs12/Makefile.ssl
+++ /dev/null
@@ -1,417 +0,0 @@
1#
2# SSLeay/crypto/pkcs12/Makefile
3#
4
5DIR= pkcs12
6TOP= ../..
7CC= cc
8INCLUDES= -I.. -I$(TOP) -I../../include
9CFLAG=-g
10INSTALL_PREFIX=
11OPENSSLDIR= /usr/local/ssl
12INSTALLTOP=/usr/local/ssl
13MAKE= make -f Makefile.ssl
14MAKEDEPPROG= makedepend
15MAKEDEPEND= $(TOP)/util/domd $(TOP) -MD $(MAKEDEPPROG)
16MAKEFILE= Makefile.ssl
17AR= ar r
18
19CFLAGS= $(INCLUDES) $(CFLAG)
20
21GENERAL=Makefile
22TEST=
23APPS=
24
25LIB=$(TOP)/libcrypto.a
26LIBSRC= p12_add.c p12_asn.c p12_attr.c p12_crpt.c p12_crt.c p12_decr.c \
27 p12_init.c p12_key.c p12_kiss.c p12_mutl.c\
28 p12_utl.c p12_npas.c pk12err.c p12_p8d.c p12_p8e.c
29LIBOBJ= p12_add.o p12_asn.o p12_attr.o p12_crpt.o p12_crt.o p12_decr.o \
30 p12_init.o p12_key.o p12_kiss.o p12_mutl.o\
31 p12_utl.o p12_npas.o pk12err.o p12_p8d.o p12_p8e.o
32
33SRC= $(LIBSRC)
34
35EXHEADER= pkcs12.h
36HEADER= $(EXHEADER)
37
38ALL= $(GENERAL) $(SRC) $(HEADER)
39
40top:
41 (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all)
42
43test:
44
45all: lib
46
47lib: $(LIBOBJ)
48 $(AR) $(LIB) $(LIBOBJ)
49 $(RANLIB) $(LIB) || echo Never mind.
50 @touch lib
51
52files:
53 $(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO
54
55links:
56 @sh $(TOP)/util/point.sh Makefile.ssl Makefile
57 @$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER)
58 @$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST)
59 @$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS)
60
61install:
62 @for i in $(EXHEADER) ; \
63 do \
64 (cp $$i $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i; \
65 chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i ); \
66 done;
67
68tags:
69 ctags $(SRC)
70
71tests:
72
73lint:
74 lint -DLINT $(INCLUDES) $(SRC)>fluff
75
76depend:
77 $(MAKEDEPEND) -- $(CFLAG) $(INCLUDES) $(DEPFLAG) -- $(PROGS) $(LIBSRC)
78
79dclean:
80 $(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
81 mv -f Makefile.new $(MAKEFILE)
82
83clean:
84 rm -f *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff
85
86# DO NOT DELETE THIS LINE -- make depend depends on it.
87
88p12_add.o: ../../e_os.h ../../include/openssl/aes.h
89p12_add.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
90p12_add.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
91p12_add.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
92p12_add.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
93p12_add.o: ../../include/openssl/des_old.h ../../include/openssl/dh.h
94p12_add.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
95p12_add.o: ../../include/openssl/err.h ../../include/openssl/evp.h
96p12_add.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h
97p12_add.o: ../../include/openssl/md2.h ../../include/openssl/md4.h
98p12_add.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
99p12_add.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
100p12_add.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
101p12_add.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs12.h
102p12_add.o: ../../include/openssl/pkcs7.h ../../include/openssl/rc2.h
103p12_add.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
104p12_add.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
105p12_add.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
106p12_add.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
107p12_add.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
108p12_add.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
109p12_add.o: ../cryptlib.h p12_add.c
110p12_asn.o: ../../e_os.h ../../include/openssl/aes.h
111p12_asn.o: ../../include/openssl/asn1.h ../../include/openssl/asn1t.h
112p12_asn.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h
113p12_asn.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
114p12_asn.o: ../../include/openssl/cast.h ../../include/openssl/crypto.h
115p12_asn.o: ../../include/openssl/des.h ../../include/openssl/des_old.h
116p12_asn.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
117p12_asn.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
118p12_asn.o: ../../include/openssl/evp.h ../../include/openssl/idea.h
119p12_asn.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h
120p12_asn.o: ../../include/openssl/md4.h ../../include/openssl/md5.h
121p12_asn.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h
122p12_asn.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
123p12_asn.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
124p12_asn.o: ../../include/openssl/pkcs12.h ../../include/openssl/pkcs7.h
125p12_asn.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h
126p12_asn.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h
127p12_asn.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
128p12_asn.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
129p12_asn.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
130p12_asn.o: ../../include/openssl/ui_compat.h ../../include/openssl/x509.h
131p12_asn.o: ../../include/openssl/x509_vfy.h ../cryptlib.h p12_asn.c
132p12_attr.o: ../../e_os.h ../../include/openssl/aes.h
133p12_attr.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
134p12_attr.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
135p12_attr.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
136p12_attr.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
137p12_attr.o: ../../include/openssl/des_old.h ../../include/openssl/dh.h
138p12_attr.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
139p12_attr.o: ../../include/openssl/err.h ../../include/openssl/evp.h
140p12_attr.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h
141p12_attr.o: ../../include/openssl/md2.h ../../include/openssl/md4.h
142p12_attr.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
143p12_attr.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
144p12_attr.o: ../../include/openssl/opensslconf.h
145p12_attr.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
146p12_attr.o: ../../include/openssl/pkcs12.h ../../include/openssl/pkcs7.h
147p12_attr.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h
148p12_attr.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h
149p12_attr.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
150p12_attr.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
151p12_attr.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
152p12_attr.o: ../../include/openssl/ui_compat.h ../../include/openssl/x509.h
153p12_attr.o: ../../include/openssl/x509_vfy.h ../cryptlib.h p12_attr.c
154p12_crpt.o: ../../e_os.h ../../include/openssl/aes.h
155p12_crpt.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
156p12_crpt.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
157p12_crpt.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
158p12_crpt.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
159p12_crpt.o: ../../include/openssl/des_old.h ../../include/openssl/dh.h
160p12_crpt.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
161p12_crpt.o: ../../include/openssl/err.h ../../include/openssl/evp.h
162p12_crpt.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h
163p12_crpt.o: ../../include/openssl/md2.h ../../include/openssl/md4.h
164p12_crpt.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
165p12_crpt.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
166p12_crpt.o: ../../include/openssl/opensslconf.h
167p12_crpt.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
168p12_crpt.o: ../../include/openssl/pkcs12.h ../../include/openssl/pkcs7.h
169p12_crpt.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h
170p12_crpt.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h
171p12_crpt.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
172p12_crpt.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
173p12_crpt.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
174p12_crpt.o: ../../include/openssl/ui_compat.h ../../include/openssl/x509.h
175p12_crpt.o: ../../include/openssl/x509_vfy.h ../cryptlib.h p12_crpt.c
176p12_crt.o: ../../e_os.h ../../include/openssl/aes.h
177p12_crt.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
178p12_crt.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
179p12_crt.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
180p12_crt.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
181p12_crt.o: ../../include/openssl/des_old.h ../../include/openssl/dh.h
182p12_crt.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
183p12_crt.o: ../../include/openssl/err.h ../../include/openssl/evp.h
184p12_crt.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h
185p12_crt.o: ../../include/openssl/md2.h ../../include/openssl/md4.h
186p12_crt.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
187p12_crt.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
188p12_crt.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
189p12_crt.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs12.h
190p12_crt.o: ../../include/openssl/pkcs7.h ../../include/openssl/rc2.h
191p12_crt.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
192p12_crt.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
193p12_crt.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
194p12_crt.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
195p12_crt.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
196p12_crt.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
197p12_crt.o: ../cryptlib.h p12_crt.c
198p12_decr.o: ../../e_os.h ../../include/openssl/aes.h
199p12_decr.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
200p12_decr.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
201p12_decr.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
202p12_decr.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
203p12_decr.o: ../../include/openssl/des_old.h ../../include/openssl/dh.h
204p12_decr.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
205p12_decr.o: ../../include/openssl/err.h ../../include/openssl/evp.h
206p12_decr.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h
207p12_decr.o: ../../include/openssl/md2.h ../../include/openssl/md4.h
208p12_decr.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
209p12_decr.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
210p12_decr.o: ../../include/openssl/opensslconf.h
211p12_decr.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
212p12_decr.o: ../../include/openssl/pkcs12.h ../../include/openssl/pkcs7.h
213p12_decr.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h
214p12_decr.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h
215p12_decr.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
216p12_decr.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
217p12_decr.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
218p12_decr.o: ../../include/openssl/ui_compat.h ../../include/openssl/x509.h
219p12_decr.o: ../../include/openssl/x509_vfy.h ../cryptlib.h p12_decr.c
220p12_init.o: ../../e_os.h ../../include/openssl/aes.h
221p12_init.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
222p12_init.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
223p12_init.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
224p12_init.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
225p12_init.o: ../../include/openssl/des_old.h ../../include/openssl/dh.h
226p12_init.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
227p12_init.o: ../../include/openssl/err.h ../../include/openssl/evp.h
228p12_init.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h
229p12_init.o: ../../include/openssl/md2.h ../../include/openssl/md4.h
230p12_init.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
231p12_init.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
232p12_init.o: ../../include/openssl/opensslconf.h
233p12_init.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
234p12_init.o: ../../include/openssl/pkcs12.h ../../include/openssl/pkcs7.h
235p12_init.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h
236p12_init.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h
237p12_init.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
238p12_init.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
239p12_init.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
240p12_init.o: ../../include/openssl/ui_compat.h ../../include/openssl/x509.h
241p12_init.o: ../../include/openssl/x509_vfy.h ../cryptlib.h p12_init.c
242p12_key.o: ../../e_os.h ../../include/openssl/aes.h
243p12_key.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
244p12_key.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
245p12_key.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
246p12_key.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
247p12_key.o: ../../include/openssl/des_old.h ../../include/openssl/dh.h
248p12_key.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
249p12_key.o: ../../include/openssl/err.h ../../include/openssl/evp.h
250p12_key.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h
251p12_key.o: ../../include/openssl/md2.h ../../include/openssl/md4.h
252p12_key.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
253p12_key.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
254p12_key.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
255p12_key.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs12.h
256p12_key.o: ../../include/openssl/pkcs7.h ../../include/openssl/rc2.h
257p12_key.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
258p12_key.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
259p12_key.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
260p12_key.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
261p12_key.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
262p12_key.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
263p12_key.o: ../cryptlib.h p12_key.c
264p12_kiss.o: ../../e_os.h ../../include/openssl/aes.h
265p12_kiss.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
266p12_kiss.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
267p12_kiss.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
268p12_kiss.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
269p12_kiss.o: ../../include/openssl/des_old.h ../../include/openssl/dh.h
270p12_kiss.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
271p12_kiss.o: ../../include/openssl/err.h ../../include/openssl/evp.h
272p12_kiss.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h
273p12_kiss.o: ../../include/openssl/md2.h ../../include/openssl/md4.h
274p12_kiss.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
275p12_kiss.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
276p12_kiss.o: ../../include/openssl/opensslconf.h
277p12_kiss.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
278p12_kiss.o: ../../include/openssl/pkcs12.h ../../include/openssl/pkcs7.h
279p12_kiss.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h
280p12_kiss.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h
281p12_kiss.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
282p12_kiss.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
283p12_kiss.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
284p12_kiss.o: ../../include/openssl/ui_compat.h ../../include/openssl/x509.h
285p12_kiss.o: ../../include/openssl/x509_vfy.h ../cryptlib.h p12_kiss.c
286p12_mutl.o: ../../e_os.h ../../include/openssl/aes.h
287p12_mutl.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
288p12_mutl.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
289p12_mutl.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
290p12_mutl.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
291p12_mutl.o: ../../include/openssl/des_old.h ../../include/openssl/dh.h
292p12_mutl.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
293p12_mutl.o: ../../include/openssl/err.h ../../include/openssl/evp.h
294p12_mutl.o: ../../include/openssl/hmac.h ../../include/openssl/idea.h
295p12_mutl.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h
296p12_mutl.o: ../../include/openssl/md4.h ../../include/openssl/md5.h
297p12_mutl.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h
298p12_mutl.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
299p12_mutl.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
300p12_mutl.o: ../../include/openssl/pkcs12.h ../../include/openssl/pkcs7.h
301p12_mutl.o: ../../include/openssl/rand.h ../../include/openssl/rc2.h
302p12_mutl.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
303p12_mutl.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
304p12_mutl.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
305p12_mutl.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
306p12_mutl.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
307p12_mutl.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
308p12_mutl.o: ../cryptlib.h p12_mutl.c
309p12_npas.o: ../../include/openssl/aes.h ../../include/openssl/asn1.h
310p12_npas.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h
311p12_npas.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
312p12_npas.o: ../../include/openssl/cast.h ../../include/openssl/crypto.h
313p12_npas.o: ../../include/openssl/des.h ../../include/openssl/des_old.h
314p12_npas.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
315p12_npas.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
316p12_npas.o: ../../include/openssl/evp.h ../../include/openssl/idea.h
317p12_npas.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h
318p12_npas.o: ../../include/openssl/md4.h ../../include/openssl/md5.h
319p12_npas.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h
320p12_npas.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
321p12_npas.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
322p12_npas.o: ../../include/openssl/pem.h ../../include/openssl/pem2.h
323p12_npas.o: ../../include/openssl/pkcs12.h ../../include/openssl/pkcs7.h
324p12_npas.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h
325p12_npas.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h
326p12_npas.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
327p12_npas.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
328p12_npas.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
329p12_npas.o: ../../include/openssl/ui_compat.h ../../include/openssl/x509.h
330p12_npas.o: ../../include/openssl/x509_vfy.h p12_npas.c
331p12_p8d.o: ../../e_os.h ../../include/openssl/aes.h
332p12_p8d.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
333p12_p8d.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
334p12_p8d.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
335p12_p8d.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
336p12_p8d.o: ../../include/openssl/des_old.h ../../include/openssl/dh.h
337p12_p8d.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
338p12_p8d.o: ../../include/openssl/err.h ../../include/openssl/evp.h
339p12_p8d.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h
340p12_p8d.o: ../../include/openssl/md2.h ../../include/openssl/md4.h
341p12_p8d.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
342p12_p8d.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
343p12_p8d.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
344p12_p8d.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs12.h
345p12_p8d.o: ../../include/openssl/pkcs7.h ../../include/openssl/rc2.h
346p12_p8d.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
347p12_p8d.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
348p12_p8d.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
349p12_p8d.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
350p12_p8d.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
351p12_p8d.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
352p12_p8d.o: ../cryptlib.h p12_p8d.c
353p12_p8e.o: ../../e_os.h ../../include/openssl/aes.h
354p12_p8e.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
355p12_p8e.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
356p12_p8e.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
357p12_p8e.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
358p12_p8e.o: ../../include/openssl/des_old.h ../../include/openssl/dh.h
359p12_p8e.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
360p12_p8e.o: ../../include/openssl/err.h ../../include/openssl/evp.h
361p12_p8e.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h
362p12_p8e.o: ../../include/openssl/md2.h ../../include/openssl/md4.h
363p12_p8e.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
364p12_p8e.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
365p12_p8e.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
366p12_p8e.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs12.h
367p12_p8e.o: ../../include/openssl/pkcs7.h ../../include/openssl/rc2.h
368p12_p8e.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
369p12_p8e.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
370p12_p8e.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
371p12_p8e.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
372p12_p8e.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
373p12_p8e.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
374p12_p8e.o: ../cryptlib.h p12_p8e.c
375p12_utl.o: ../../e_os.h ../../include/openssl/aes.h
376p12_utl.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
377p12_utl.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
378p12_utl.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
379p12_utl.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
380p12_utl.o: ../../include/openssl/des_old.h ../../include/openssl/dh.h
381p12_utl.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
382p12_utl.o: ../../include/openssl/err.h ../../include/openssl/evp.h
383p12_utl.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h
384p12_utl.o: ../../include/openssl/md2.h ../../include/openssl/md4.h
385p12_utl.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
386p12_utl.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
387p12_utl.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
388p12_utl.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs12.h
389p12_utl.o: ../../include/openssl/pkcs7.h ../../include/openssl/rc2.h
390p12_utl.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
391p12_utl.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
392p12_utl.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
393p12_utl.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
394p12_utl.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
395p12_utl.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
396p12_utl.o: ../cryptlib.h p12_utl.c
397pk12err.o: ../../include/openssl/aes.h ../../include/openssl/asn1.h
398pk12err.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h
399pk12err.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
400pk12err.o: ../../include/openssl/cast.h ../../include/openssl/crypto.h
401pk12err.o: ../../include/openssl/des.h ../../include/openssl/des_old.h
402pk12err.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
403pk12err.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
404pk12err.o: ../../include/openssl/evp.h ../../include/openssl/idea.h
405pk12err.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h
406pk12err.o: ../../include/openssl/md4.h ../../include/openssl/md5.h
407pk12err.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h
408pk12err.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
409pk12err.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
410pk12err.o: ../../include/openssl/pkcs12.h ../../include/openssl/pkcs7.h
411pk12err.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h
412pk12err.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h
413pk12err.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
414pk12err.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
415pk12err.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
416pk12err.o: ../../include/openssl/ui_compat.h ../../include/openssl/x509.h
417pk12err.o: ../../include/openssl/x509_vfy.h pk12err.c
diff --git a/src/lib/libcrypto/pkcs12/p12_add.c b/src/lib/libcrypto/pkcs12/p12_add.c
index 1f3e378f5c..27ac5facfa 100644
--- a/src/lib/libcrypto/pkcs12/p12_add.c
+++ b/src/lib/libcrypto/pkcs12/p12_add.c
@@ -106,6 +106,7 @@ PKCS12_SAFEBAG *PKCS12_MAKE_SHKEYBAG(int pbe_nid, const char *pass,
106 PKCS8_PRIV_KEY_INFO *p8) 106 PKCS8_PRIV_KEY_INFO *p8)
107{ 107{
108 PKCS12_SAFEBAG *bag; 108 PKCS12_SAFEBAG *bag;
109 const EVP_CIPHER *pbe_ciph;
109 110
110 /* Set up the safe bag */ 111 /* Set up the safe bag */
111 if (!(bag = PKCS12_SAFEBAG_new())) { 112 if (!(bag = PKCS12_SAFEBAG_new())) {
@@ -114,8 +115,14 @@ PKCS12_SAFEBAG *PKCS12_MAKE_SHKEYBAG(int pbe_nid, const char *pass,
114 } 115 }
115 116
116 bag->type = OBJ_nid2obj(NID_pkcs8ShroudedKeyBag); 117 bag->type = OBJ_nid2obj(NID_pkcs8ShroudedKeyBag);
118
119 pbe_ciph = EVP_get_cipherbynid(pbe_nid);
120
121 if (pbe_ciph)
122 pbe_nid = -1;
123
117 if (!(bag->value.shkeybag = 124 if (!(bag->value.shkeybag =
118 PKCS8_encrypt(pbe_nid, NULL, pass, passlen, salt, saltlen, iter, 125 PKCS8_encrypt(pbe_nid, pbe_ciph, pass, passlen, salt, saltlen, iter,
119 p8))) { 126 p8))) {
120 PKCS12err(PKCS12_F_PKCS12_MAKE_SHKEYBAG, ERR_R_MALLOC_FAILURE); 127 PKCS12err(PKCS12_F_PKCS12_MAKE_SHKEYBAG, ERR_R_MALLOC_FAILURE);
121 return NULL; 128 return NULL;
@@ -164,6 +171,7 @@ PKCS7 *PKCS12_pack_p7encdata(int pbe_nid, const char *pass, int passlen,
164{ 171{
165 PKCS7 *p7; 172 PKCS7 *p7;
166 X509_ALGOR *pbe; 173 X509_ALGOR *pbe;
174 const EVP_CIPHER *pbe_ciph;
167 if (!(p7 = PKCS7_new())) { 175 if (!(p7 = PKCS7_new())) {
168 PKCS12err(PKCS12_F_PKCS12_PACK_P7ENCDATA, ERR_R_MALLOC_FAILURE); 176 PKCS12err(PKCS12_F_PKCS12_PACK_P7ENCDATA, ERR_R_MALLOC_FAILURE);
169 return NULL; 177 return NULL;
@@ -173,7 +181,15 @@ PKCS7 *PKCS12_pack_p7encdata(int pbe_nid, const char *pass, int passlen,
173 PKCS12_R_ERROR_SETTING_ENCRYPTED_DATA_TYPE); 181 PKCS12_R_ERROR_SETTING_ENCRYPTED_DATA_TYPE);
174 return NULL; 182 return NULL;
175 } 183 }
176 if (!(pbe = PKCS5_pbe_set(pbe_nid, iter, salt, saltlen))) { 184
185 pbe_ciph = EVP_get_cipherbynid(pbe_nid);
186
187 if (pbe_ciph)
188 pbe = PKCS5_pbe2_set(pbe_ciph, iter, salt, saltlen);
189 else
190 pbe = PKCS5_pbe_set(pbe_nid, iter, salt, saltlen);
191
192 if (!pbe) {
177 PKCS12err(PKCS12_F_PKCS12_PACK_P7ENCDATA, ERR_R_MALLOC_FAILURE); 193 PKCS12err(PKCS12_F_PKCS12_PACK_P7ENCDATA, ERR_R_MALLOC_FAILURE);
178 return NULL; 194 return NULL;
179 } 195 }
diff --git a/src/lib/libcrypto/pkcs12/p12_attr.c b/src/lib/libcrypto/pkcs12/p12_attr.c
index 68d6c5ad15..e4d9c25647 100644
--- a/src/lib/libcrypto/pkcs12/p12_attr.c
+++ b/src/lib/libcrypto/pkcs12/p12_attr.c
@@ -139,7 +139,7 @@ char *PKCS12_get_friendlyname(PKCS12_SAFEBAG *bag)
139 ASN1_TYPE *atype; 139 ASN1_TYPE *atype;
140 if (!(atype = PKCS12_get_attr(bag, NID_friendlyName))) return NULL; 140 if (!(atype = PKCS12_get_attr(bag, NID_friendlyName))) return NULL;
141 if (atype->type != V_ASN1_BMPSTRING) return NULL; 141 if (atype->type != V_ASN1_BMPSTRING) return NULL;
142 return uni2asc(atype->value.bmpstring->data, 142 return OPENSSL_uni2asc(atype->value.bmpstring->data,
143 atype->value.bmpstring->length); 143 atype->value.bmpstring->length);
144} 144}
145 145
diff --git a/src/lib/libcrypto/pkcs12/p12_crpt.c b/src/lib/libcrypto/pkcs12/p12_crpt.c
index f8b952e27e..b71d07b4d0 100644
--- a/src/lib/libcrypto/pkcs12/p12_crpt.c
+++ b/src/lib/libcrypto/pkcs12/p12_crpt.c
@@ -60,28 +60,10 @@
60#include "cryptlib.h" 60#include "cryptlib.h"
61#include <openssl/pkcs12.h> 61#include <openssl/pkcs12.h>
62 62
63/* PKCS#12 specific PBE functions */ 63/* PKCS#12 PBE algorithms now in static table */
64 64
65void PKCS12_PBE_add(void) 65void PKCS12_PBE_add(void)
66{ 66{
67#ifndef OPENSSL_NO_RC4
68EVP_PBE_alg_add(NID_pbe_WithSHA1And128BitRC4, EVP_rc4(), EVP_sha1(),
69 PKCS12_PBE_keyivgen);
70EVP_PBE_alg_add(NID_pbe_WithSHA1And40BitRC4, EVP_rc4_40(), EVP_sha1(),
71 PKCS12_PBE_keyivgen);
72#endif
73#ifndef OPENSSL_NO_DES
74EVP_PBE_alg_add(NID_pbe_WithSHA1And3_Key_TripleDES_CBC,
75 EVP_des_ede3_cbc(), EVP_sha1(), PKCS12_PBE_keyivgen);
76EVP_PBE_alg_add(NID_pbe_WithSHA1And2_Key_TripleDES_CBC,
77 EVP_des_ede_cbc(), EVP_sha1(), PKCS12_PBE_keyivgen);
78#endif
79#ifndef OPENSSL_NO_RC2
80EVP_PBE_alg_add(NID_pbe_WithSHA1And128BitRC2_CBC, EVP_rc2_cbc(),
81 EVP_sha1(), PKCS12_PBE_keyivgen);
82EVP_PBE_alg_add(NID_pbe_WithSHA1And40BitRC2_CBC, EVP_rc2_40_cbc(),
83 EVP_sha1(), PKCS12_PBE_keyivgen);
84#endif
85} 67}
86 68
87int PKCS12_PBE_keyivgen(EVP_CIPHER_CTX *ctx, const char *pass, int passlen, 69int PKCS12_PBE_keyivgen(EVP_CIPHER_CTX *ctx, const char *pass, int passlen,
diff --git a/src/lib/libcrypto/pkcs12/p12_crt.c b/src/lib/libcrypto/pkcs12/p12_crt.c
index 9522342fa5..96b131defa 100644
--- a/src/lib/libcrypto/pkcs12/p12_crt.c
+++ b/src/lib/libcrypto/pkcs12/p12_crt.c
@@ -59,10 +59,6 @@
59#include <stdio.h> 59#include <stdio.h>
60#include "cryptlib.h" 60#include "cryptlib.h"
61#include <openssl/pkcs12.h> 61#include <openssl/pkcs12.h>
62#ifdef OPENSSL_FIPS
63#include <openssl/fips.h>
64#endif
65
66 62
67 63
68static int pkcs12_add_bag(STACK_OF(PKCS12_SAFEBAG) **pbags, PKCS12_SAFEBAG *bag); 64static int pkcs12_add_bag(STACK_OF(PKCS12_SAFEBAG) **pbags, PKCS12_SAFEBAG *bag);
@@ -94,14 +90,7 @@ PKCS12 *PKCS12_create(char *pass, char *name, EVP_PKEY *pkey, X509 *cert,
94 90
95 /* Set defaults */ 91 /* Set defaults */
96 if (!nid_cert) 92 if (!nid_cert)
97 {
98#ifdef OPENSSL_FIPS
99 if (FIPS_mode())
100 nid_cert = NID_pbe_WithSHA1And3_Key_TripleDES_CBC;
101 else
102#endif
103 nid_cert = NID_pbe_WithSHA1And40BitRC2_CBC; 93 nid_cert = NID_pbe_WithSHA1And40BitRC2_CBC;
104 }
105 if (!nid_key) 94 if (!nid_key)
106 nid_key = NID_pbe_WithSHA1And3_Key_TripleDES_CBC; 95 nid_key = NID_pbe_WithSHA1And3_Key_TripleDES_CBC;
107 if (!iter) 96 if (!iter)
diff --git a/src/lib/libcrypto/pkcs12/p12_key.c b/src/lib/libcrypto/pkcs12/p12_key.c
index 9e57eee4a4..a29794bbbc 100644
--- a/src/lib/libcrypto/pkcs12/p12_key.c
+++ b/src/lib/libcrypto/pkcs12/p12_key.c
@@ -81,15 +81,18 @@ int PKCS12_key_gen_asc(const char *pass, int passlen, unsigned char *salt,
81 int ret; 81 int ret;
82 unsigned char *unipass; 82 unsigned char *unipass;
83 int uniplen; 83 int uniplen;
84
84 if(!pass) { 85 if(!pass) {
85 unipass = NULL; 86 unipass = NULL;
86 uniplen = 0; 87 uniplen = 0;
87 } else if (!asc2uni(pass, passlen, &unipass, &uniplen)) { 88 } else if (!OPENSSL_asc2uni(pass, passlen, &unipass, &uniplen)) {
88 PKCS12err(PKCS12_F_PKCS12_KEY_GEN_ASC,ERR_R_MALLOC_FAILURE); 89 PKCS12err(PKCS12_F_PKCS12_KEY_GEN_ASC,ERR_R_MALLOC_FAILURE);
89 return 0; 90 return 0;
90 } 91 }
91 ret = PKCS12_key_gen_uni(unipass, uniplen, salt, saltlen, 92 ret = PKCS12_key_gen_uni(unipass, uniplen, salt, saltlen,
92 id, iter, n, out, md_type); 93 id, iter, n, out, md_type);
94 if (ret <= 0)
95 return 0;
93 if(unipass) { 96 if(unipass) {
94 OPENSSL_cleanse(unipass, uniplen); /* Clear password from memory */ 97 OPENSSL_cleanse(unipass, uniplen); /* Clear password from memory */
95 OPENSSL_free(unipass); 98 OPENSSL_free(unipass);
@@ -129,6 +132,8 @@ int PKCS12_key_gen_uni(unsigned char *pass, int passlen, unsigned char *salt,
129#endif 132#endif
130 v = EVP_MD_block_size (md_type); 133 v = EVP_MD_block_size (md_type);
131 u = EVP_MD_size (md_type); 134 u = EVP_MD_size (md_type);
135 if (u < 0)
136 return 0;
132 D = OPENSSL_malloc (v); 137 D = OPENSSL_malloc (v);
133 Ai = OPENSSL_malloc (u); 138 Ai = OPENSSL_malloc (u);
134 B = OPENSSL_malloc (v + 1); 139 B = OPENSSL_malloc (v + 1);
diff --git a/src/lib/libcrypto/pkcs12/p12_kiss.c b/src/lib/libcrypto/pkcs12/p12_kiss.c
index 5c4c6ec988..292cc3ed4a 100644
--- a/src/lib/libcrypto/pkcs12/p12_kiss.c
+++ b/src/lib/libcrypto/pkcs12/p12_kiss.c
@@ -63,16 +63,13 @@
63/* Simplified PKCS#12 routines */ 63/* Simplified PKCS#12 routines */
64 64
65static int parse_pk12( PKCS12 *p12, const char *pass, int passlen, 65static int parse_pk12( PKCS12 *p12, const char *pass, int passlen,
66 EVP_PKEY **pkey, X509 **cert, STACK_OF(X509) **ca); 66 EVP_PKEY **pkey, STACK_OF(X509) *ocerts);
67 67
68static int parse_bags( STACK_OF(PKCS12_SAFEBAG) *bags, const char *pass, 68static int parse_bags( STACK_OF(PKCS12_SAFEBAG) *bags, const char *pass,
69 int passlen, EVP_PKEY **pkey, X509 **cert, 69 int passlen, EVP_PKEY **pkey, STACK_OF(X509) *ocerts);
70 STACK_OF(X509) **ca, ASN1_OCTET_STRING **keyid,
71 char *keymatch);
72 70
73static int parse_bag( PKCS12_SAFEBAG *bag, const char *pass, int passlen, 71static int parse_bag( PKCS12_SAFEBAG *bag, const char *pass, int passlen,
74 EVP_PKEY **pkey, X509 **cert, STACK_OF(X509) **ca, 72 EVP_PKEY **pkey, STACK_OF(X509) *ocerts);
75 ASN1_OCTET_STRING **keyid, char *keymatch);
76 73
77/* Parse and decrypt a PKCS#12 structure returning user key, user cert 74/* Parse and decrypt a PKCS#12 structure returning user key, user cert
78 * and other (CA) certs. Note either ca should be NULL, *ca should be NULL, 75 * and other (CA) certs. Note either ca should be NULL, *ca should be NULL,
@@ -83,24 +80,20 @@ static int parse_bag( PKCS12_SAFEBAG *bag, const char *pass, int passlen,
83int PKCS12_parse(PKCS12 *p12, const char *pass, EVP_PKEY **pkey, X509 **cert, 80int PKCS12_parse(PKCS12 *p12, const char *pass, EVP_PKEY **pkey, X509 **cert,
84 STACK_OF(X509) **ca) 81 STACK_OF(X509) **ca)
85{ 82{
86 83 STACK_OF(X509) *ocerts = NULL;
84 X509 *x = NULL;
87 /* Check for NULL PKCS12 structure */ 85 /* Check for NULL PKCS12 structure */
88 86
89 if(!p12) { 87 if(!p12)
88 {
90 PKCS12err(PKCS12_F_PKCS12_PARSE,PKCS12_R_INVALID_NULL_PKCS12_POINTER); 89 PKCS12err(PKCS12_F_PKCS12_PARSE,PKCS12_R_INVALID_NULL_PKCS12_POINTER);
91 return 0; 90 return 0;
92 }
93
94 /* Allocate stack for ca certificates if needed */
95 if ((ca != NULL) && (*ca == NULL)) {
96 if (!(*ca = sk_X509_new_null())) {
97 PKCS12err(PKCS12_F_PKCS12_PARSE,ERR_R_MALLOC_FAILURE);
98 return 0;
99 } 91 }
100 }
101 92
102 if(pkey) *pkey = NULL; 93 if(pkey)
103 if(cert) *cert = NULL; 94 *pkey = NULL;
95 if(cert)
96 *cert = NULL;
104 97
105 /* Check the mac */ 98 /* Check the mac */
106 99
@@ -122,19 +115,61 @@ int PKCS12_parse(PKCS12 *p12, const char *pass, EVP_PKEY **pkey, X509 **cert,
122 goto err; 115 goto err;
123 } 116 }
124 117
125 if (!parse_pk12 (p12, pass, -1, pkey, cert, ca)) 118 /* Allocate stack for other certificates */
119 ocerts = sk_X509_new_null();
120
121 if (!ocerts)
122 {
123 PKCS12err(PKCS12_F_PKCS12_PARSE,ERR_R_MALLOC_FAILURE);
124 return 0;
125 }
126
127 if (!parse_pk12 (p12, pass, -1, pkey, ocerts))
126 { 128 {
127 PKCS12err(PKCS12_F_PKCS12_PARSE,PKCS12_R_PARSE_ERROR); 129 PKCS12err(PKCS12_F_PKCS12_PARSE,PKCS12_R_PARSE_ERROR);
128 goto err; 130 goto err;
129 } 131 }
130 132
133 while ((x = sk_X509_pop(ocerts)))
134 {
135 if (pkey && *pkey && cert && !*cert)
136 {
137 if (X509_check_private_key(x, *pkey))
138 {
139 *cert = x;
140 x = NULL;
141 }
142 }
143
144 if (ca && x)
145 {
146 if (!*ca)
147 *ca = sk_X509_new_null();
148 if (!*ca)
149 goto err;
150 if (!sk_X509_push(*ca, x))
151 goto err;
152 x = NULL;
153 }
154 if (x)
155 X509_free(x);
156 }
157
158 if (ocerts)
159 sk_X509_pop_free(ocerts, X509_free);
160
131 return 1; 161 return 1;
132 162
133 err: 163 err:
134 164
135 if (pkey && *pkey) EVP_PKEY_free(*pkey); 165 if (pkey && *pkey)
136 if (cert && *cert) X509_free(*cert); 166 EVP_PKEY_free(*pkey);
137 if (ca) sk_X509_pop_free(*ca, X509_free); 167 if (cert && *cert)
168 X509_free(*cert);
169 if (x)
170 X509_free(*cert);
171 if (ocerts)
172 sk_X509_pop_free(ocerts, X509_free);
138 return 0; 173 return 0;
139 174
140} 175}
@@ -142,15 +177,13 @@ int PKCS12_parse(PKCS12 *p12, const char *pass, EVP_PKEY **pkey, X509 **cert,
142/* Parse the outer PKCS#12 structure */ 177/* Parse the outer PKCS#12 structure */
143 178
144static int parse_pk12(PKCS12 *p12, const char *pass, int passlen, 179static int parse_pk12(PKCS12 *p12, const char *pass, int passlen,
145 EVP_PKEY **pkey, X509 **cert, STACK_OF(X509) **ca) 180 EVP_PKEY **pkey, STACK_OF(X509) *ocerts)
146{ 181{
147 STACK_OF(PKCS7) *asafes; 182 STACK_OF(PKCS7) *asafes;
148 STACK_OF(PKCS12_SAFEBAG) *bags; 183 STACK_OF(PKCS12_SAFEBAG) *bags;
149 int i, bagnid; 184 int i, bagnid;
150 PKCS7 *p7; 185 PKCS7 *p7;
151 ASN1_OCTET_STRING *keyid = NULL;
152 186
153 char keymatch = 0;
154 if (!(asafes = PKCS12_unpack_authsafes (p12))) return 0; 187 if (!(asafes = PKCS12_unpack_authsafes (p12))) return 0;
155 for (i = 0; i < sk_PKCS7_num (asafes); i++) { 188 for (i = 0; i < sk_PKCS7_num (asafes); i++) {
156 p7 = sk_PKCS7_value (asafes, i); 189 p7 = sk_PKCS7_value (asafes, i);
@@ -164,8 +197,7 @@ static int parse_pk12(PKCS12 *p12, const char *pass, int passlen,
164 sk_PKCS7_pop_free(asafes, PKCS7_free); 197 sk_PKCS7_pop_free(asafes, PKCS7_free);
165 return 0; 198 return 0;
166 } 199 }
167 if (!parse_bags(bags, pass, passlen, pkey, cert, ca, 200 if (!parse_bags(bags, pass, passlen, pkey, ocerts)) {
168 &keyid, &keymatch)) {
169 sk_PKCS12_SAFEBAG_pop_free(bags, PKCS12_SAFEBAG_free); 201 sk_PKCS12_SAFEBAG_pop_free(bags, PKCS12_SAFEBAG_free);
170 sk_PKCS7_pop_free(asafes, PKCS7_free); 202 sk_PKCS7_pop_free(asafes, PKCS7_free);
171 return 0; 203 return 0;
@@ -173,89 +205,65 @@ static int parse_pk12(PKCS12 *p12, const char *pass, int passlen,
173 sk_PKCS12_SAFEBAG_pop_free(bags, PKCS12_SAFEBAG_free); 205 sk_PKCS12_SAFEBAG_pop_free(bags, PKCS12_SAFEBAG_free);
174 } 206 }
175 sk_PKCS7_pop_free(asafes, PKCS7_free); 207 sk_PKCS7_pop_free(asafes, PKCS7_free);
176 if (keyid) M_ASN1_OCTET_STRING_free(keyid);
177 return 1; 208 return 1;
178} 209}
179 210
180 211
181static int parse_bags(STACK_OF(PKCS12_SAFEBAG) *bags, const char *pass, 212static int parse_bags(STACK_OF(PKCS12_SAFEBAG) *bags, const char *pass,
182 int passlen, EVP_PKEY **pkey, X509 **cert, 213 int passlen, EVP_PKEY **pkey, STACK_OF(X509) *ocerts)
183 STACK_OF(X509) **ca, ASN1_OCTET_STRING **keyid,
184 char *keymatch)
185{ 214{
186 int i; 215 int i;
187 for (i = 0; i < sk_PKCS12_SAFEBAG_num(bags); i++) { 216 for (i = 0; i < sk_PKCS12_SAFEBAG_num(bags); i++) {
188 if (!parse_bag(sk_PKCS12_SAFEBAG_value (bags, i), 217 if (!parse_bag(sk_PKCS12_SAFEBAG_value (bags, i),
189 pass, passlen, pkey, cert, ca, keyid, 218 pass, passlen, pkey, ocerts))
190 keymatch)) return 0; 219 return 0;
191 } 220 }
192 return 1; 221 return 1;
193} 222}
194 223
195#define MATCH_KEY 0x1
196#define MATCH_CERT 0x2
197#define MATCH_ALL 0x3
198
199static int parse_bag(PKCS12_SAFEBAG *bag, const char *pass, int passlen, 224static int parse_bag(PKCS12_SAFEBAG *bag, const char *pass, int passlen,
200 EVP_PKEY **pkey, X509 **cert, STACK_OF(X509) **ca, 225 EVP_PKEY **pkey, STACK_OF(X509) *ocerts)
201 ASN1_OCTET_STRING **keyid,
202 char *keymatch)
203{ 226{
204 PKCS8_PRIV_KEY_INFO *p8; 227 PKCS8_PRIV_KEY_INFO *p8;
205 X509 *x509; 228 X509 *x509;
206 ASN1_OCTET_STRING *lkey = NULL, *ckid = NULL;
207 ASN1_TYPE *attrib; 229 ASN1_TYPE *attrib;
208 ASN1_BMPSTRING *fname = NULL; 230 ASN1_BMPSTRING *fname = NULL;
231 ASN1_OCTET_STRING *lkid = NULL;
209 232
210 if ((attrib = PKCS12_get_attr (bag, NID_friendlyName))) 233 if ((attrib = PKCS12_get_attr (bag, NID_friendlyName)))
211 fname = attrib->value.bmpstring; 234 fname = attrib->value.bmpstring;
212 235
213 if ((attrib = PKCS12_get_attr (bag, NID_localKeyID))) { 236 if ((attrib = PKCS12_get_attr (bag, NID_localKeyID)))
214 lkey = attrib->value.octet_string; 237 lkid = attrib->value.octet_string;
215 ckid = lkey;
216 }
217 238
218 /* Check for any local key id matching (if needed) */
219 if (lkey && ((*keymatch & MATCH_ALL) != MATCH_ALL)) {
220 if (*keyid) {
221 if (M_ASN1_OCTET_STRING_cmp(*keyid, lkey)) lkey = NULL;
222 } else {
223 if (!(*keyid = M_ASN1_OCTET_STRING_dup(lkey))) {
224 PKCS12err(PKCS12_F_PARSE_BAG,ERR_R_MALLOC_FAILURE);
225 return 0;
226 }
227 }
228 }
229
230 switch (M_PKCS12_bag_type(bag)) 239 switch (M_PKCS12_bag_type(bag))
231 { 240 {
232 case NID_keyBag: 241 case NID_keyBag:
233 if (!lkey || !pkey) return 1; 242 if (!pkey || *pkey)
234 if (!(*pkey = EVP_PKCS82PKEY(bag->value.keybag))) return 0; 243 return 1;
235 *keymatch |= MATCH_KEY; 244 if (!(*pkey = EVP_PKCS82PKEY(bag->value.keybag)))
245 return 0;
236 break; 246 break;
237 247
238 case NID_pkcs8ShroudedKeyBag: 248 case NID_pkcs8ShroudedKeyBag:
239 if (!lkey || !pkey) return 1; 249 if (!pkey || *pkey)
250 return 1;
240 if (!(p8 = PKCS12_decrypt_skey(bag, pass, passlen))) 251 if (!(p8 = PKCS12_decrypt_skey(bag, pass, passlen)))
241 return 0; 252 return 0;
242 *pkey = EVP_PKCS82PKEY(p8); 253 *pkey = EVP_PKCS82PKEY(p8);
243 PKCS8_PRIV_KEY_INFO_free(p8); 254 PKCS8_PRIV_KEY_INFO_free(p8);
244 if (!(*pkey)) return 0; 255 if (!(*pkey)) return 0;
245 *keymatch |= MATCH_KEY;
246 break; 256 break;
247 257
248 case NID_certBag: 258 case NID_certBag:
249 if (M_PKCS12_cert_bag_type(bag) != NID_x509Certificate ) 259 if (M_PKCS12_cert_bag_type(bag) != NID_x509Certificate )
250 return 1; 260 return 1;
251 if (!(x509 = PKCS12_certbag2x509(bag))) return 0; 261 if (!(x509 = PKCS12_certbag2x509(bag)))
252 if(ckid) 262 return 0;
263 if(lkid && !X509_keyid_set1(x509, lkid->data, lkid->length))
253 { 264 {
254 if (!X509_keyid_set1(x509, ckid->data, ckid->length)) 265 X509_free(x509);
255 { 266 return 0;
256 X509_free(x509);
257 return 0;
258 }
259 } 267 }
260 if(fname) { 268 if(fname) {
261 int len, r; 269 int len, r;
@@ -272,20 +280,17 @@ static int parse_bag(PKCS12_SAFEBAG *bag, const char *pass, int passlen,
272 } 280 }
273 } 281 }
274 282
283 if(!sk_X509_push(ocerts, x509))
284 {
285 X509_free(x509);
286 return 0;
287 }
275 288
276 if (lkey) {
277 *keymatch |= MATCH_CERT;
278 if (cert) *cert = x509;
279 else X509_free(x509);
280 } else {
281 if(ca) sk_X509_push (*ca, x509);
282 else X509_free(x509);
283 }
284 break; 289 break;
285 290
286 case NID_safeContentsBag: 291 case NID_safeContentsBag:
287 return parse_bags(bag->value.safes, pass, passlen, 292 return parse_bags(bag->value.safes, pass, passlen,
288 pkey, cert, ca, keyid, keymatch); 293 pkey, ocerts);
289 break; 294 break;
290 295
291 default: 296 default:
diff --git a/src/lib/libcrypto/pkcs12/p12_mutl.c b/src/lib/libcrypto/pkcs12/p12_mutl.c
index 70bfef6e5d..9ab740d51f 100644
--- a/src/lib/libcrypto/pkcs12/p12_mutl.c
+++ b/src/lib/libcrypto/pkcs12/p12_mutl.c
@@ -71,6 +71,7 @@ int PKCS12_gen_mac(PKCS12 *p12, const char *pass, int passlen,
71 HMAC_CTX hmac; 71 HMAC_CTX hmac;
72 unsigned char key[EVP_MAX_MD_SIZE], *salt; 72 unsigned char key[EVP_MAX_MD_SIZE], *salt;
73 int saltlen, iter; 73 int saltlen, iter;
74 int md_size;
74 75
75 if (!PKCS7_type_is_data(p12->authsafes)) 76 if (!PKCS7_type_is_data(p12->authsafes))
76 { 77 {
@@ -87,13 +88,16 @@ int PKCS12_gen_mac(PKCS12 *p12, const char *pass, int passlen,
87 PKCS12err(PKCS12_F_PKCS12_GEN_MAC,PKCS12_R_UNKNOWN_DIGEST_ALGORITHM); 88 PKCS12err(PKCS12_F_PKCS12_GEN_MAC,PKCS12_R_UNKNOWN_DIGEST_ALGORITHM);
88 return 0; 89 return 0;
89 } 90 }
91 md_size = EVP_MD_size(md_type);
92 if (md_size < 0)
93 return 0;
90 if(!PKCS12_key_gen (pass, passlen, salt, saltlen, PKCS12_MAC_ID, iter, 94 if(!PKCS12_key_gen (pass, passlen, salt, saltlen, PKCS12_MAC_ID, iter,
91 EVP_MD_size(md_type), key, md_type)) { 95 md_size, key, md_type)) {
92 PKCS12err(PKCS12_F_PKCS12_GEN_MAC,PKCS12_R_KEY_GEN_ERROR); 96 PKCS12err(PKCS12_F_PKCS12_GEN_MAC,PKCS12_R_KEY_GEN_ERROR);
93 return 0; 97 return 0;
94 } 98 }
95 HMAC_CTX_init(&hmac); 99 HMAC_CTX_init(&hmac);
96 HMAC_Init_ex(&hmac, key, EVP_MD_size(md_type), md_type, NULL); 100 HMAC_Init_ex(&hmac, key, md_size, md_type, NULL);
97 HMAC_Update(&hmac, p12->authsafes->d.data->data, 101 HMAC_Update(&hmac, p12->authsafes->d.data->data,
98 p12->authsafes->d.data->length); 102 p12->authsafes->d.data->length);
99 HMAC_Final(&hmac, mac, maclen); 103 HMAC_Final(&hmac, mac, maclen);
diff --git a/src/lib/libcrypto/pkcs12/p12_npas.c b/src/lib/libcrypto/pkcs12/p12_npas.c
index 47e5e9c377..2f71355150 100644
--- a/src/lib/libcrypto/pkcs12/p12_npas.c
+++ b/src/lib/libcrypto/pkcs12/p12_npas.c
@@ -120,8 +120,13 @@ static int newpass_p12(PKCS12 *p12, char *oldpass, char *newpass)
120 bags = PKCS12_unpack_p7data(p7); 120 bags = PKCS12_unpack_p7data(p7);
121 } else if (bagnid == NID_pkcs7_encrypted) { 121 } else if (bagnid == NID_pkcs7_encrypted) {
122 bags = PKCS12_unpack_p7encdata(p7, oldpass, -1); 122 bags = PKCS12_unpack_p7encdata(p7, oldpass, -1);
123 alg_get(p7->d.encrypted->enc_data->algorithm, 123 if (!alg_get(p7->d.encrypted->enc_data->algorithm,
124 &pbe_nid, &pbe_iter, &pbe_saltlen); 124 &pbe_nid, &pbe_iter, &pbe_saltlen))
125 {
126 sk_PKCS12_SAFEBAG_pop_free(bags,
127 PKCS12_SAFEBAG_free);
128 bags = NULL;
129 }
125 } else continue; 130 } else continue;
126 if (!bags) { 131 if (!bags) {
127 sk_PKCS7_pop_free(asafes, PKCS7_free); 132 sk_PKCS7_pop_free(asafes, PKCS7_free);
@@ -193,7 +198,9 @@ static int newpass_bag(PKCS12_SAFEBAG *bag, char *oldpass, char *newpass)
193 if(M_PKCS12_bag_type(bag) != NID_pkcs8ShroudedKeyBag) return 1; 198 if(M_PKCS12_bag_type(bag) != NID_pkcs8ShroudedKeyBag) return 1;
194 199
195 if (!(p8 = PKCS8_decrypt(bag->value.shkeybag, oldpass, -1))) return 0; 200 if (!(p8 = PKCS8_decrypt(bag->value.shkeybag, oldpass, -1))) return 0;
196 alg_get(bag->value.shkeybag->algor, &p8_nid, &p8_iter, &p8_saltlen); 201 if (!alg_get(bag->value.shkeybag->algor, &p8_nid, &p8_iter,
202 &p8_saltlen))
203 return 0;
197 if(!(p8new = PKCS8_encrypt(p8_nid, NULL, newpass, -1, NULL, p8_saltlen, 204 if(!(p8new = PKCS8_encrypt(p8_nid, NULL, newpass, -1, NULL, p8_saltlen,
198 p8_iter, p8))) return 0; 205 p8_iter, p8))) return 0;
199 X509_SIG_free(bag->value.shkeybag); 206 X509_SIG_free(bag->value.shkeybag);
@@ -208,9 +215,11 @@ static int alg_get(X509_ALGOR *alg, int *pnid, int *piter, int *psaltlen)
208 215
209 p = alg->parameter->value.sequence->data; 216 p = alg->parameter->value.sequence->data;
210 pbe = d2i_PBEPARAM(NULL, &p, alg->parameter->value.sequence->length); 217 pbe = d2i_PBEPARAM(NULL, &p, alg->parameter->value.sequence->length);
218 if (!pbe)
219 return 0;
211 *pnid = OBJ_obj2nid(alg->algorithm); 220 *pnid = OBJ_obj2nid(alg->algorithm);
212 *piter = ASN1_INTEGER_get(pbe->iter); 221 *piter = ASN1_INTEGER_get(pbe->iter);
213 *psaltlen = pbe->salt->length; 222 *psaltlen = pbe->salt->length;
214 PBEPARAM_free(pbe); 223 PBEPARAM_free(pbe);
215 return 0; 224 return 1;
216} 225}
diff --git a/src/lib/libcrypto/pkcs12/p12_utl.c b/src/lib/libcrypto/pkcs12/p12_utl.c
index ca30ac4f6d..59c6f453f6 100644
--- a/src/lib/libcrypto/pkcs12/p12_utl.c
+++ b/src/lib/libcrypto/pkcs12/p12_utl.c
@@ -62,7 +62,7 @@
62 62
63/* Cheap and nasty Unicode stuff */ 63/* Cheap and nasty Unicode stuff */
64 64
65unsigned char *asc2uni(const char *asc, int asclen, unsigned char **uni, int *unilen) 65unsigned char *OPENSSL_asc2uni(const char *asc, int asclen, unsigned char **uni, int *unilen)
66{ 66{
67 int ulen, i; 67 int ulen, i;
68 unsigned char *unitmp; 68 unsigned char *unitmp;
@@ -81,7 +81,7 @@ unsigned char *asc2uni(const char *asc, int asclen, unsigned char **uni, int *un
81 return unitmp; 81 return unitmp;
82} 82}
83 83
84char *uni2asc(unsigned char *uni, int unilen) 84char *OPENSSL_uni2asc(unsigned char *uni, int unilen)
85{ 85{
86 int asclen, i; 86 int asclen, i;
87 char *asctmp; 87 char *asctmp;
diff --git a/src/lib/libcrypto/pkcs12/pk12err.c b/src/lib/libcrypto/pkcs12/pk12err.c
index 07a1fb6907..f6ddf2df12 100644
--- a/src/lib/libcrypto/pkcs12/pk12err.c
+++ b/src/lib/libcrypto/pkcs12/pk12err.c
@@ -1,6 +1,6 @@
1/* crypto/pkcs12/pk12err.c */ 1/* crypto/pkcs12/pk12err.c */
2/* ==================================================================== 2/* ====================================================================
3 * Copyright (c) 1999-2005 The OpenSSL Project. All rights reserved. 3 * Copyright (c) 1999-2006 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
diff --git a/src/lib/libcrypto/pkcs12/pkcs12.h b/src/lib/libcrypto/pkcs12/pkcs12.h
index 4bee605dc0..b17eb9f42b 100644
--- a/src/lib/libcrypto/pkcs12/pkcs12.h
+++ b/src/lib/libcrypto/pkcs12/pkcs12.h
@@ -108,8 +108,6 @@ PKCS12_MAC_DATA *mac;
108PKCS7 *authsafes; 108PKCS7 *authsafes;
109} PKCS12; 109} PKCS12;
110 110
111PREDECLARE_STACK_OF(PKCS12_SAFEBAG)
112
113typedef struct { 111typedef struct {
114ASN1_OBJECT *type; 112ASN1_OBJECT *type;
115union { 113union {
@@ -232,8 +230,8 @@ int PKCS12_set_mac(PKCS12 *p12, const char *pass, int passlen,
232 const EVP_MD *md_type); 230 const EVP_MD *md_type);
233int PKCS12_setup_mac(PKCS12 *p12, int iter, unsigned char *salt, 231int PKCS12_setup_mac(PKCS12 *p12, int iter, unsigned char *salt,
234 int saltlen, const EVP_MD *md_type); 232 int saltlen, const EVP_MD *md_type);
235unsigned char *asc2uni(const char *asc, int asclen, unsigned char **uni, int *unilen); 233unsigned char *OPENSSL_asc2uni(const char *asc, int asclen, unsigned char **uni, int *unilen);
236char *uni2asc(unsigned char *uni, int unilen); 234char *OPENSSL_uni2asc(unsigned char *uni, int unilen);
237 235
238DECLARE_ASN1_FUNCTIONS(PKCS12) 236DECLARE_ASN1_FUNCTIONS(PKCS12)
239DECLARE_ASN1_FUNCTIONS(PKCS12_MAC_DATA) 237DECLARE_ASN1_FUNCTIONS(PKCS12_MAC_DATA)
diff --git a/src/lib/libcrypto/pkcs7/Makefile.ssl b/src/lib/libcrypto/pkcs7/Makefile.ssl
deleted file mode 100644
index c3bfc7d560..0000000000
--- a/src/lib/libcrypto/pkcs7/Makefile.ssl
+++ /dev/null
@@ -1,243 +0,0 @@
1#
2# SSLeay/crypto/pkcs7/Makefile
3#
4
5DIR= pkcs7
6TOP= ../..
7CC= cc
8INCLUDES= -I.. -I$(TOP) -I../../include
9CFLAG=-g
10INSTALL_PREFIX=
11OPENSSLDIR= /usr/local/ssl
12INSTALLTOP=/usr/local/ssl
13MAKE= make -f Makefile.ssl
14MAKEDEPPROG= makedepend
15MAKEDEPEND= $(TOP)/util/domd $(TOP) -MD $(MAKEDEPPROG)
16MAKEFILE= Makefile.ssl
17AR= ar r
18
19PEX_LIBS=
20EX_LIBS=
21
22CFLAGS= $(INCLUDES) $(CFLAG)
23
24GENERAL=Makefile README
25TEST=
26APPS=
27
28LIB=$(TOP)/libcrypto.a
29LIBSRC= pk7_asn1.c pk7_lib.c pkcs7err.c pk7_doit.c pk7_smime.c pk7_attr.c \
30 pk7_mime.c
31LIBOBJ= pk7_asn1.o pk7_lib.o pkcs7err.o pk7_doit.o pk7_smime.o pk7_attr.o \
32 pk7_mime.o
33
34SRC= $(LIBSRC)
35
36EXHEADER= pkcs7.h
37HEADER= $(EXHEADER)
38
39ALL= $(GENERAL) $(SRC) $(HEADER)
40
41top:
42 (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all)
43
44test:
45
46all: lib
47
48testapps: enc dec sign verify
49
50enc: enc.o lib
51 $(CC) $(CFLAGS) -o enc enc.o $(PEX_LIBS) $(LIB) $(EX_LIBS)
52
53dec: dec.o lib
54 $(CC) $(CFLAGS) -o dec dec.o $(PEX_LIBS) $(LIB) $(EX_LIBS)
55
56sign: sign.o lib
57 $(CC) $(CFLAGS) -o sign sign.o $(PEX_LIBS) $(LIB) $(EX_LIBS)
58
59verify: verify.o example.o lib
60 $(CC) $(CFLAGS) -o verify verify.o $(PEX_LIBS) example.o $(LIB) $(EX_LIBS)
61
62lib: $(LIBOBJ)
63 $(AR) $(LIB) $(LIBOBJ)
64 $(RANLIB) $(LIB) || echo Never mind.
65 @touch lib
66
67files:
68 $(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO
69
70links:
71 @sh $(TOP)/util/point.sh Makefile.ssl Makefile
72 @$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER)
73 @$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST)
74 @$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS)
75
76install:
77 @for i in $(EXHEADER) ; \
78 do \
79 (cp $$i $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i; \
80 chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i ); \
81 done;
82
83tags:
84 ctags $(SRC)
85
86tests:
87
88lint:
89 lint -DLINT $(INCLUDES) $(SRC)>fluff
90
91depend:
92 $(MAKEDEPEND) -- $(CFLAG) $(INCLUDES) $(DEPFLAG) -- $(PROGS) $(LIBSRC)
93
94dclean:
95 $(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
96 mv -f Makefile.new $(MAKEFILE)
97
98clean:
99 rm -f *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff enc dec sign verify
100
101# DO NOT DELETE THIS LINE -- make depend depends on it.
102
103pk7_asn1.o: ../../e_os.h ../../include/openssl/aes.h
104pk7_asn1.o: ../../include/openssl/asn1.h ../../include/openssl/asn1t.h
105pk7_asn1.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h
106pk7_asn1.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
107pk7_asn1.o: ../../include/openssl/cast.h ../../include/openssl/crypto.h
108pk7_asn1.o: ../../include/openssl/des.h ../../include/openssl/des_old.h
109pk7_asn1.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
110pk7_asn1.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
111pk7_asn1.o: ../../include/openssl/evp.h ../../include/openssl/idea.h
112pk7_asn1.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h
113pk7_asn1.o: ../../include/openssl/md4.h ../../include/openssl/md5.h
114pk7_asn1.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h
115pk7_asn1.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
116pk7_asn1.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
117pk7_asn1.o: ../../include/openssl/pkcs7.h ../../include/openssl/rc2.h
118pk7_asn1.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
119pk7_asn1.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
120pk7_asn1.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
121pk7_asn1.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
122pk7_asn1.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
123pk7_asn1.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
124pk7_asn1.o: ../cryptlib.h pk7_asn1.c
125pk7_attr.o: ../../include/openssl/aes.h ../../include/openssl/asn1.h
126pk7_attr.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h
127pk7_attr.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
128pk7_attr.o: ../../include/openssl/cast.h ../../include/openssl/crypto.h
129pk7_attr.o: ../../include/openssl/des.h ../../include/openssl/des_old.h
130pk7_attr.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
131pk7_attr.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
132pk7_attr.o: ../../include/openssl/evp.h ../../include/openssl/idea.h
133pk7_attr.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h
134pk7_attr.o: ../../include/openssl/md4.h ../../include/openssl/md5.h
135pk7_attr.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h
136pk7_attr.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
137pk7_attr.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
138pk7_attr.o: ../../include/openssl/pem.h ../../include/openssl/pem2.h
139pk7_attr.o: ../../include/openssl/pkcs7.h ../../include/openssl/rc2.h
140pk7_attr.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
141pk7_attr.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
142pk7_attr.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
143pk7_attr.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
144pk7_attr.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
145pk7_attr.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
146pk7_attr.o: pk7_attr.c
147pk7_doit.o: ../../e_os.h ../../include/openssl/aes.h
148pk7_doit.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
149pk7_doit.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
150pk7_doit.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
151pk7_doit.o: ../../include/openssl/conf.h ../../include/openssl/crypto.h
152pk7_doit.o: ../../include/openssl/des.h ../../include/openssl/des_old.h
153pk7_doit.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
154pk7_doit.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
155pk7_doit.o: ../../include/openssl/evp.h ../../include/openssl/idea.h
156pk7_doit.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h
157pk7_doit.o: ../../include/openssl/md4.h ../../include/openssl/md5.h
158pk7_doit.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h
159pk7_doit.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
160pk7_doit.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
161pk7_doit.o: ../../include/openssl/pkcs7.h ../../include/openssl/rand.h
162pk7_doit.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h
163pk7_doit.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h
164pk7_doit.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
165pk7_doit.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
166pk7_doit.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
167pk7_doit.o: ../../include/openssl/ui_compat.h ../../include/openssl/x509.h
168pk7_doit.o: ../../include/openssl/x509_vfy.h ../../include/openssl/x509v3.h
169pk7_doit.o: ../cryptlib.h pk7_doit.c
170pk7_lib.o: ../../e_os.h ../../include/openssl/aes.h
171pk7_lib.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
172pk7_lib.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
173pk7_lib.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
174pk7_lib.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
175pk7_lib.o: ../../include/openssl/des_old.h ../../include/openssl/dh.h
176pk7_lib.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
177pk7_lib.o: ../../include/openssl/err.h ../../include/openssl/evp.h
178pk7_lib.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h
179pk7_lib.o: ../../include/openssl/md2.h ../../include/openssl/md4.h
180pk7_lib.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
181pk7_lib.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
182pk7_lib.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
183pk7_lib.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h
184pk7_lib.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h
185pk7_lib.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h
186pk7_lib.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
187pk7_lib.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
188pk7_lib.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
189pk7_lib.o: ../../include/openssl/ui_compat.h ../../include/openssl/x509.h
190pk7_lib.o: ../../include/openssl/x509_vfy.h ../cryptlib.h pk7_lib.c
191pk7_mime.o: ../../e_os.h ../../include/openssl/aes.h
192pk7_mime.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
193pk7_mime.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
194pk7_mime.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
195pk7_mime.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
196pk7_mime.o: ../../include/openssl/des_old.h ../../include/openssl/dh.h
197pk7_mime.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
198pk7_mime.o: ../../include/openssl/err.h ../../include/openssl/evp.h
199pk7_mime.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h
200pk7_mime.o: ../../include/openssl/md2.h ../../include/openssl/md4.h
201pk7_mime.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
202pk7_mime.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
203pk7_mime.o: ../../include/openssl/opensslconf.h
204pk7_mime.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
205pk7_mime.o: ../../include/openssl/pkcs7.h ../../include/openssl/rand.h
206pk7_mime.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h
207pk7_mime.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h
208pk7_mime.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
209pk7_mime.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
210pk7_mime.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
211pk7_mime.o: ../../include/openssl/ui_compat.h ../../include/openssl/x509.h
212pk7_mime.o: ../../include/openssl/x509_vfy.h ../cryptlib.h pk7_mime.c
213pk7_smime.o: ../../e_os.h ../../include/openssl/aes.h
214pk7_smime.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
215pk7_smime.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
216pk7_smime.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
217pk7_smime.o: ../../include/openssl/conf.h ../../include/openssl/crypto.h
218pk7_smime.o: ../../include/openssl/des.h ../../include/openssl/des_old.h
219pk7_smime.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
220pk7_smime.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
221pk7_smime.o: ../../include/openssl/evp.h ../../include/openssl/idea.h
222pk7_smime.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h
223pk7_smime.o: ../../include/openssl/md4.h ../../include/openssl/md5.h
224pk7_smime.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h
225pk7_smime.o: ../../include/openssl/objects.h
226pk7_smime.o: ../../include/openssl/opensslconf.h
227pk7_smime.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
228pk7_smime.o: ../../include/openssl/pkcs7.h ../../include/openssl/rc2.h
229pk7_smime.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
230pk7_smime.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
231pk7_smime.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
232pk7_smime.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
233pk7_smime.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
234pk7_smime.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
235pk7_smime.o: ../../include/openssl/x509v3.h ../cryptlib.h pk7_smime.c
236pkcs7err.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
237pkcs7err.o: ../../include/openssl/bn.h ../../include/openssl/crypto.h
238pkcs7err.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
239pkcs7err.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
240pkcs7err.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
241pkcs7err.o: ../../include/openssl/pkcs7.h ../../include/openssl/safestack.h
242pkcs7err.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
243pkcs7err.o: pkcs7err.c
diff --git a/src/lib/libcrypto/pkcs7/pk7_asn1.c b/src/lib/libcrypto/pkcs7/pk7_asn1.c
index 1f70d31386..b7ec2883cb 100644
--- a/src/lib/libcrypto/pkcs7/pk7_asn1.c
+++ b/src/lib/libcrypto/pkcs7/pk7_asn1.c
@@ -77,10 +77,39 @@ ASN1_ADB(PKCS7) = {
77 ADB_ENTRY(NID_pkcs7_encrypted, ASN1_NDEF_EXP_OPT(PKCS7, d.encrypted, PKCS7_ENCRYPT, 0)) 77 ADB_ENTRY(NID_pkcs7_encrypted, ASN1_NDEF_EXP_OPT(PKCS7, d.encrypted, PKCS7_ENCRYPT, 0))
78} ASN1_ADB_END(PKCS7, 0, type, 0, &p7default_tt, NULL); 78} ASN1_ADB_END(PKCS7, 0, type, 0, &p7default_tt, NULL);
79 79
80ASN1_NDEF_SEQUENCE(PKCS7) = { 80/* PKCS#7 streaming support */
81static int pk7_cb(int operation, ASN1_VALUE **pval, const ASN1_ITEM *it,
82 void *exarg)
83{
84 ASN1_STREAM_ARG *sarg = exarg;
85 PKCS7 **pp7 = (PKCS7 **)pval;
86
87 switch(operation)
88 {
89
90 case ASN1_OP_STREAM_PRE:
91 if (PKCS7_stream(&sarg->boundary, *pp7) <= 0)
92 return 0;
93 case ASN1_OP_DETACHED_PRE:
94 sarg->ndef_bio = PKCS7_dataInit(*pp7, sarg->out);
95 if (!sarg->ndef_bio)
96 return 0;
97 break;
98
99 case ASN1_OP_STREAM_POST:
100 case ASN1_OP_DETACHED_POST:
101 if (PKCS7_dataFinal(*pp7, sarg->ndef_bio) <= 0)
102 return 0;
103 break;
104
105 }
106 return 1;
107}
108
109ASN1_NDEF_SEQUENCE_cb(PKCS7, pk7_cb) = {
81 ASN1_SIMPLE(PKCS7, type, ASN1_OBJECT), 110 ASN1_SIMPLE(PKCS7, type, ASN1_OBJECT),
82 ASN1_ADB_OBJECT(PKCS7) 111 ASN1_ADB_OBJECT(PKCS7)
83}ASN1_NDEF_SEQUENCE_END(PKCS7) 112}ASN1_NDEF_SEQUENCE_END_cb(PKCS7, PKCS7)
84 113
85IMPLEMENT_ASN1_FUNCTIONS(PKCS7) 114IMPLEMENT_ASN1_FUNCTIONS(PKCS7)
86IMPLEMENT_ASN1_NDEF_FUNCTION(PKCS7) 115IMPLEMENT_ASN1_NDEF_FUNCTION(PKCS7)
@@ -98,7 +127,8 @@ ASN1_NDEF_SEQUENCE(PKCS7_SIGNED) = {
98IMPLEMENT_ASN1_FUNCTIONS(PKCS7_SIGNED) 127IMPLEMENT_ASN1_FUNCTIONS(PKCS7_SIGNED)
99 128
100/* Minor tweak to operation: free up EVP_PKEY */ 129/* Minor tweak to operation: free up EVP_PKEY */
101static int si_cb(int operation, ASN1_VALUE **pval, const ASN1_ITEM *it) 130static int si_cb(int operation, ASN1_VALUE **pval, const ASN1_ITEM *it,
131 void *exarg)
102{ 132{
103 if(operation == ASN1_OP_FREE_POST) { 133 if(operation == ASN1_OP_FREE_POST) {
104 PKCS7_SIGNER_INFO *si = (PKCS7_SIGNER_INFO *)*pval; 134 PKCS7_SIGNER_INFO *si = (PKCS7_SIGNER_INFO *)*pval;
@@ -140,7 +170,8 @@ ASN1_NDEF_SEQUENCE(PKCS7_ENVELOPE) = {
140IMPLEMENT_ASN1_FUNCTIONS(PKCS7_ENVELOPE) 170IMPLEMENT_ASN1_FUNCTIONS(PKCS7_ENVELOPE)
141 171
142/* Minor tweak to operation: free up X509 */ 172/* Minor tweak to operation: free up X509 */
143static int ri_cb(int operation, ASN1_VALUE **pval, const ASN1_ITEM *it) 173static int ri_cb(int operation, ASN1_VALUE **pval, const ASN1_ITEM *it,
174 void *exarg)
144{ 175{
145 if(operation == ASN1_OP_FREE_POST) { 176 if(operation == ASN1_OP_FREE_POST) {
146 PKCS7_RECIP_INFO *ri = (PKCS7_RECIP_INFO *)*pval; 177 PKCS7_RECIP_INFO *ri = (PKCS7_RECIP_INFO *)*pval;
@@ -161,7 +192,7 @@ IMPLEMENT_ASN1_FUNCTIONS(PKCS7_RECIP_INFO)
161ASN1_NDEF_SEQUENCE(PKCS7_ENC_CONTENT) = { 192ASN1_NDEF_SEQUENCE(PKCS7_ENC_CONTENT) = {
162 ASN1_SIMPLE(PKCS7_ENC_CONTENT, content_type, ASN1_OBJECT), 193 ASN1_SIMPLE(PKCS7_ENC_CONTENT, content_type, ASN1_OBJECT),
163 ASN1_SIMPLE(PKCS7_ENC_CONTENT, algorithm, X509_ALGOR), 194 ASN1_SIMPLE(PKCS7_ENC_CONTENT, algorithm, X509_ALGOR),
164 ASN1_IMP_OPT(PKCS7_ENC_CONTENT, enc_data, ASN1_OCTET_STRING, 0) 195 ASN1_IMP_OPT(PKCS7_ENC_CONTENT, enc_data, ASN1_OCTET_STRING_NDEF, 0)
165} ASN1_NDEF_SEQUENCE_END(PKCS7_ENC_CONTENT) 196} ASN1_NDEF_SEQUENCE_END(PKCS7_ENC_CONTENT)
166 197
167IMPLEMENT_ASN1_FUNCTIONS(PKCS7_ENC_CONTENT) 198IMPLEMENT_ASN1_FUNCTIONS(PKCS7_ENC_CONTENT)
@@ -212,3 +243,5 @@ ASN1_ITEM_TEMPLATE(PKCS7_ATTR_VERIFY) =
212 ASN1_EX_TEMPLATE_TYPE(ASN1_TFLG_SEQUENCE_OF | ASN1_TFLG_IMPTAG | ASN1_TFLG_UNIVERSAL, 243 ASN1_EX_TEMPLATE_TYPE(ASN1_TFLG_SEQUENCE_OF | ASN1_TFLG_IMPTAG | ASN1_TFLG_UNIVERSAL,
213 V_ASN1_SET, PKCS7_ATTRIBUTES, X509_ATTRIBUTE) 244 V_ASN1_SET, PKCS7_ATTRIBUTES, X509_ATTRIBUTE)
214ASN1_ITEM_TEMPLATE_END(PKCS7_ATTR_VERIFY) 245ASN1_ITEM_TEMPLATE_END(PKCS7_ATTR_VERIFY)
246
247IMPLEMENT_ASN1_PRINT_FUNCTION(PKCS7)
diff --git a/src/lib/libcrypto/pkcs7/pk7_attr.c b/src/lib/libcrypto/pkcs7/pk7_attr.c
index d549717169..a97db51210 100644
--- a/src/lib/libcrypto/pkcs7/pk7_attr.c
+++ b/src/lib/libcrypto/pkcs7/pk7_attr.c
@@ -60,6 +60,7 @@
60#include <stdlib.h> 60#include <stdlib.h>
61#include <openssl/bio.h> 61#include <openssl/bio.h>
62#include <openssl/asn1.h> 62#include <openssl/asn1.h>
63#include <openssl/asn1t.h>
63#include <openssl/pem.h> 64#include <openssl/pem.h>
64#include <openssl/pkcs7.h> 65#include <openssl/pkcs7.h>
65#include <openssl/x509.h> 66#include <openssl/x509.h>
@@ -68,27 +69,12 @@
68int PKCS7_add_attrib_smimecap(PKCS7_SIGNER_INFO *si, STACK_OF(X509_ALGOR) *cap) 69int PKCS7_add_attrib_smimecap(PKCS7_SIGNER_INFO *si, STACK_OF(X509_ALGOR) *cap)
69{ 70{
70 ASN1_STRING *seq; 71 ASN1_STRING *seq;
71 unsigned char *p, *pp;
72 int len;
73 len=i2d_ASN1_SET_OF_X509_ALGOR(cap,NULL,i2d_X509_ALGOR,
74 V_ASN1_SEQUENCE,V_ASN1_UNIVERSAL,
75 IS_SEQUENCE);
76 if(!(pp=(unsigned char *)OPENSSL_malloc(len))) {
77 PKCS7err(PKCS7_F_PKCS7_ADD_ATTRIB_SMIMECAP,ERR_R_MALLOC_FAILURE);
78 return 0;
79 }
80 p=pp;
81 i2d_ASN1_SET_OF_X509_ALGOR(cap,&p,i2d_X509_ALGOR, V_ASN1_SEQUENCE,
82 V_ASN1_UNIVERSAL, IS_SEQUENCE);
83 if(!(seq = ASN1_STRING_new())) { 72 if(!(seq = ASN1_STRING_new())) {
84 PKCS7err(PKCS7_F_PKCS7_ADD_ATTRIB_SMIMECAP,ERR_R_MALLOC_FAILURE); 73 PKCS7err(PKCS7_F_PKCS7_ADD_ATTRIB_SMIMECAP,ERR_R_MALLOC_FAILURE);
85 return 0; 74 return 0;
86 } 75 }
87 if(!ASN1_STRING_set (seq, pp, len)) { 76 seq->length = ASN1_item_i2d((ASN1_VALUE *)cap,&seq->data,
88 PKCS7err(PKCS7_F_PKCS7_ADD_ATTRIB_SMIMECAP,ERR_R_MALLOC_FAILURE); 77 ASN1_ITEM_rptr(X509_ALGORS));
89 return 0;
90 }
91 OPENSSL_free (pp);
92 return PKCS7_add_signed_attribute(si, NID_SMIMECapabilities, 78 return PKCS7_add_signed_attribute(si, NID_SMIMECapabilities,
93 V_ASN1_SEQUENCE, seq); 79 V_ASN1_SEQUENCE, seq);
94} 80}
@@ -102,10 +88,9 @@ STACK_OF(X509_ALGOR) *PKCS7_get_smimecap(PKCS7_SIGNER_INFO *si)
102 if (!cap || (cap->type != V_ASN1_SEQUENCE)) 88 if (!cap || (cap->type != V_ASN1_SEQUENCE))
103 return NULL; 89 return NULL;
104 p = cap->value.sequence->data; 90 p = cap->value.sequence->data;
105 return d2i_ASN1_SET_OF_X509_ALGOR(NULL, &p, 91 return (STACK_OF(X509_ALGOR) *)
106 cap->value.sequence->length, 92 ASN1_item_d2i(NULL, &p, cap->value.sequence->length,
107 d2i_X509_ALGOR, X509_ALGOR_free, 93 ASN1_ITEM_rptr(X509_ALGORS));
108 V_ASN1_SEQUENCE, V_ASN1_UNIVERSAL);
109 } 94 }
110 95
111/* Basic smime-capabilities OID and optional integer arg */ 96/* Basic smime-capabilities OID and optional integer arg */
@@ -139,3 +124,42 @@ int PKCS7_simple_smimecap(STACK_OF(X509_ALGOR) *sk, int nid, int arg)
139 sk_X509_ALGOR_push (sk, alg); 124 sk_X509_ALGOR_push (sk, alg);
140 return 1; 125 return 1;
141} 126}
127
128int PKCS7_add_attrib_content_type(PKCS7_SIGNER_INFO *si, ASN1_OBJECT *coid)
129 {
130 if (PKCS7_get_signed_attribute(si, NID_pkcs9_contentType))
131 return 0;
132 if (!coid)
133 coid = OBJ_nid2obj(NID_pkcs7_data);
134 return PKCS7_add_signed_attribute(si, NID_pkcs9_contentType,
135 V_ASN1_OBJECT, coid);
136 }
137
138int PKCS7_add0_attrib_signing_time(PKCS7_SIGNER_INFO *si, ASN1_TIME *t)
139 {
140 if (!t && !(t=X509_gmtime_adj(NULL,0)))
141 {
142 PKCS7err(PKCS7_F_PKCS7_ADD0_ATTRIB_SIGNING_TIME,
143 ERR_R_MALLOC_FAILURE);
144 return 0;
145 }
146 return PKCS7_add_signed_attribute(si, NID_pkcs9_signingTime,
147 V_ASN1_UTCTIME, t);
148 }
149
150int PKCS7_add1_attrib_digest(PKCS7_SIGNER_INFO *si,
151 const unsigned char *md, int mdlen)
152 {
153 ASN1_OCTET_STRING *os;
154 os = ASN1_OCTET_STRING_new();
155 if (!os)
156 return 0;
157 if (!ASN1_STRING_set(os, md, mdlen)
158 || !PKCS7_add_signed_attribute(si, NID_pkcs9_messageDigest,
159 V_ASN1_OCTET_STRING, os))
160 {
161 ASN1_OCTET_STRING_free(os);
162 return 0;
163 }
164 return 1;
165 }
diff --git a/src/lib/libcrypto/pkcs7/pk7_doit.c b/src/lib/libcrypto/pkcs7/pk7_doit.c
index a03d7ebedf..451de84489 100644
--- a/src/lib/libcrypto/pkcs7/pk7_doit.c
+++ b/src/lib/libcrypto/pkcs7/pk7_doit.c
@@ -138,6 +138,121 @@ static int PKCS7_bio_add_digest(BIO **pbio, X509_ALGOR *alg)
138 138
139 } 139 }
140 140
141static int pkcs7_encode_rinfo(PKCS7_RECIP_INFO *ri,
142 unsigned char *key, int keylen)
143 {
144 EVP_PKEY_CTX *pctx = NULL;
145 EVP_PKEY *pkey = NULL;
146 unsigned char *ek = NULL;
147 int ret = 0;
148 size_t eklen;
149
150 pkey = X509_get_pubkey(ri->cert);
151
152 if (!pkey)
153 return 0;
154
155 pctx = EVP_PKEY_CTX_new(pkey, NULL);
156 if (!pctx)
157 return 0;
158
159 if (EVP_PKEY_encrypt_init(pctx) <= 0)
160 goto err;
161
162 if (EVP_PKEY_CTX_ctrl(pctx, -1, EVP_PKEY_OP_ENCRYPT,
163 EVP_PKEY_CTRL_PKCS7_ENCRYPT, 0, ri) <= 0)
164 {
165 PKCS7err(PKCS7_F_PKCS7_ENCODE_RINFO, PKCS7_R_CTRL_ERROR);
166 goto err;
167 }
168
169 if (EVP_PKEY_encrypt(pctx, NULL, &eklen, key, keylen) <= 0)
170 goto err;
171
172 ek = OPENSSL_malloc(eklen);
173
174 if (ek == NULL)
175 {
176 PKCS7err(PKCS7_F_PKCS7_ENCODE_RINFO, ERR_R_MALLOC_FAILURE);
177 goto err;
178 }
179
180 if (EVP_PKEY_encrypt(pctx, ek, &eklen, key, keylen) <= 0)
181 goto err;
182
183 ASN1_STRING_set0(ri->enc_key, ek, eklen);
184 ek = NULL;
185
186 ret = 1;
187
188 err:
189 if (pkey)
190 EVP_PKEY_free(pkey);
191 if (pctx)
192 EVP_PKEY_CTX_free(pctx);
193 if (ek)
194 OPENSSL_free(ek);
195 return ret;
196
197 }
198
199
200static int pkcs7_decrypt_rinfo(unsigned char **pek, int *peklen,
201 PKCS7_RECIP_INFO *ri, EVP_PKEY *pkey)
202 {
203 EVP_PKEY_CTX *pctx = NULL;
204 unsigned char *ek = NULL;
205 size_t eklen;
206
207 int ret = 0;
208
209 pctx = EVP_PKEY_CTX_new(pkey, NULL);
210 if (!pctx)
211 return 0;
212
213 if (EVP_PKEY_decrypt_init(pctx) <= 0)
214 goto err;
215
216 if (EVP_PKEY_CTX_ctrl(pctx, -1, EVP_PKEY_OP_DECRYPT,
217 EVP_PKEY_CTRL_PKCS7_DECRYPT, 0, ri) <= 0)
218 {
219 PKCS7err(PKCS7_F_PKCS7_DECRYPT_RINFO, PKCS7_R_CTRL_ERROR);
220 goto err;
221 }
222
223 if (EVP_PKEY_decrypt(pctx, NULL, &eklen,
224 ri->enc_key->data, ri->enc_key->length) <= 0)
225 goto err;
226
227 ek = OPENSSL_malloc(eklen);
228
229 if (ek == NULL)
230 {
231 PKCS7err(PKCS7_F_PKCS7_DECRYPT_RINFO, ERR_R_MALLOC_FAILURE);
232 goto err;
233 }
234
235 if (EVP_PKEY_decrypt(pctx, ek, &eklen,
236 ri->enc_key->data, ri->enc_key->length) <= 0)
237 {
238 PKCS7err(PKCS7_F_PKCS7_DECRYPT_RINFO, ERR_R_EVP_LIB);
239 goto err;
240 }
241
242 ret = 1;
243
244 *pek = ek;
245 *peklen = eklen;
246
247 err:
248 if (pctx)
249 EVP_PKEY_CTX_free(pctx);
250 if (!ret && ek)
251 OPENSSL_free(ek);
252
253 return ret;
254 }
255
141BIO *PKCS7_dataInit(PKCS7 *p7, BIO *bio) 256BIO *PKCS7_dataInit(PKCS7 *p7, BIO *bio)
142 { 257 {
143 int i; 258 int i;
@@ -148,7 +263,6 @@ BIO *PKCS7_dataInit(PKCS7 *p7, BIO *bio)
148 STACK_OF(PKCS7_RECIP_INFO) *rsk=NULL; 263 STACK_OF(PKCS7_RECIP_INFO) *rsk=NULL;
149 X509_ALGOR *xalg=NULL; 264 X509_ALGOR *xalg=NULL;
150 PKCS7_RECIP_INFO *ri=NULL; 265 PKCS7_RECIP_INFO *ri=NULL;
151 EVP_PKEY *pkey;
152 ASN1_OCTET_STRING *os=NULL; 266 ASN1_OCTET_STRING *os=NULL;
153 267
154 i=OBJ_obj2nid(p7->type); 268 i=OBJ_obj2nid(p7->type);
@@ -187,6 +301,8 @@ BIO *PKCS7_dataInit(PKCS7 *p7, BIO *bio)
187 xa = p7->d.digest->md; 301 xa = p7->d.digest->md;
188 os = PKCS7_get_octet_string(p7->d.digest->contents); 302 os = PKCS7_get_octet_string(p7->d.digest->contents);
189 break; 303 break;
304 case NID_pkcs7_data:
305 break;
190 default: 306 default:
191 PKCS7err(PKCS7_F_PKCS7_DATAINIT,PKCS7_R_UNSUPPORTED_CONTENT_TYPE); 307 PKCS7err(PKCS7_F_PKCS7_DATAINIT,PKCS7_R_UNSUPPORTED_CONTENT_TYPE);
192 goto err; 308 goto err;
@@ -204,8 +320,6 @@ BIO *PKCS7_dataInit(PKCS7 *p7, BIO *bio)
204 unsigned char key[EVP_MAX_KEY_LENGTH]; 320 unsigned char key[EVP_MAX_KEY_LENGTH];
205 unsigned char iv[EVP_MAX_IV_LENGTH]; 321 unsigned char iv[EVP_MAX_IV_LENGTH];
206 int keylen,ivlen; 322 int keylen,ivlen;
207 int jj,max;
208 unsigned char *tmp;
209 EVP_CIPHER_CTX *ctx; 323 EVP_CIPHER_CTX *ctx;
210 324
211 if ((btmp=BIO_new(BIO_f_cipher())) == NULL) 325 if ((btmp=BIO_new(BIO_f_cipher())) == NULL)
@@ -234,52 +348,16 @@ BIO *PKCS7_dataInit(PKCS7 *p7, BIO *bio)
234 goto err; 348 goto err;
235 } 349 }
236 if(EVP_CIPHER_param_to_asn1(ctx, xalg->parameter) < 0) 350 if(EVP_CIPHER_param_to_asn1(ctx, xalg->parameter) < 0)
237 goto err; 351 goto err;
238 } 352 }
239 353
240 /* Lets do the pub key stuff :-) */ 354 /* Lets do the pub key stuff :-) */
241 max=0;
242 for (i=0; i<sk_PKCS7_RECIP_INFO_num(rsk); i++) 355 for (i=0; i<sk_PKCS7_RECIP_INFO_num(rsk); i++)
243 { 356 {
244 ri=sk_PKCS7_RECIP_INFO_value(rsk,i); 357 ri=sk_PKCS7_RECIP_INFO_value(rsk,i);
245 if (ri->cert == NULL) 358 if (pkcs7_encode_rinfo(ri, key, keylen) <= 0)
246 {
247 PKCS7err(PKCS7_F_PKCS7_DATAINIT,PKCS7_R_MISSING_CERIPEND_INFO);
248 goto err;
249 }
250 if ((pkey=X509_get_pubkey(ri->cert)) == NULL)
251 goto err;
252 jj=EVP_PKEY_size(pkey);
253 EVP_PKEY_free(pkey);
254 if (max < jj) max=jj;
255 }
256 if ((tmp=(unsigned char *)OPENSSL_malloc(max)) == NULL)
257 {
258 PKCS7err(PKCS7_F_PKCS7_DATAINIT,ERR_R_MALLOC_FAILURE);
259 goto err;
260 }
261 for (i=0; i<sk_PKCS7_RECIP_INFO_num(rsk); i++)
262 {
263 ri=sk_PKCS7_RECIP_INFO_value(rsk,i);
264 if ((pkey=X509_get_pubkey(ri->cert)) == NULL)
265 goto err;
266 jj=EVP_PKEY_encrypt(tmp,key,keylen,pkey);
267 EVP_PKEY_free(pkey);
268 if (jj <= 0)
269 {
270 PKCS7err(PKCS7_F_PKCS7_DATAINIT,ERR_R_EVP_LIB);
271 OPENSSL_free(tmp);
272 goto err; 359 goto err;
273 }
274 if (!M_ASN1_OCTET_STRING_set(ri->enc_key,tmp,jj))
275 {
276 PKCS7err(PKCS7_F_PKCS7_DATAINIT,
277 ERR_R_MALLOC_FAILURE);
278 OPENSSL_free(tmp);
279 goto err;
280 }
281 } 360 }
282 OPENSSL_free(tmp);
283 OPENSSL_cleanse(key, keylen); 361 OPENSSL_cleanse(key, keylen);
284 362
285 if (out == NULL) 363 if (out == NULL)
@@ -303,7 +381,10 @@ BIO *PKCS7_dataInit(PKCS7 *p7, BIO *bio)
303 BIO_set_mem_eof_return(bio,0); 381 BIO_set_mem_eof_return(bio,0);
304 } 382 }
305 } 383 }
306 BIO_push(out,bio); 384 if (out)
385 BIO_push(out,bio);
386 else
387 out = bio;
307 bio=NULL; 388 bio=NULL;
308 if (0) 389 if (0)
309 { 390 {
@@ -333,7 +414,6 @@ BIO *PKCS7_dataDecode(PKCS7 *p7, EVP_PKEY *pkey, BIO *in_bio, X509 *pcert)
333 { 414 {
334 int i,j; 415 int i,j;
335 BIO *out=NULL,*btmp=NULL,*etmp=NULL,*bio=NULL; 416 BIO *out=NULL,*btmp=NULL,*etmp=NULL,*bio=NULL;
336 unsigned char *tmp=NULL;
337 X509_ALGOR *xa; 417 X509_ALGOR *xa;
338 ASN1_OCTET_STRING *data_body=NULL; 418 ASN1_OCTET_STRING *data_body=NULL;
339 const EVP_MD *evp_md; 419 const EVP_MD *evp_md;
@@ -423,7 +503,8 @@ BIO *PKCS7_dataDecode(PKCS7 *p7, EVP_PKEY *pkey, BIO *in_bio, X509 *pcert)
423 int max; 503 int max;
424 X509_OBJECT ret; 504 X509_OBJECT ret;
425#endif 505#endif
426 int jj; 506 unsigned char *ek = NULL;
507 int eklen;
427 508
428 if ((etmp=BIO_new(BIO_f_cipher())) == NULL) 509 if ((etmp=BIO_new(BIO_f_cipher())) == NULL)
429 { 510 {
@@ -438,26 +519,21 @@ BIO *PKCS7_dataDecode(PKCS7 *p7, EVP_PKEY *pkey, BIO *in_bio, X509 *pcert)
438 * (if any) 519 * (if any)
439 */ 520 */
440 521
441 if (pcert) { 522 if (pcert)
442 for (i=0; i<sk_PKCS7_RECIP_INFO_num(rsk); i++) { 523 {
524 for (i=0; i<sk_PKCS7_RECIP_INFO_num(rsk); i++)
525 {
443 ri=sk_PKCS7_RECIP_INFO_value(rsk,i); 526 ri=sk_PKCS7_RECIP_INFO_value(rsk,i);
444 if (!pkcs7_cmp_ri(ri, pcert)) 527 if (!pkcs7_cmp_ri(ri, pcert))
445 break; 528 break;
446 ri=NULL; 529 ri=NULL;
447 } 530 }
448 if (ri == NULL) { 531 if (ri == NULL)
532 {
449 PKCS7err(PKCS7_F_PKCS7_DATADECODE, 533 PKCS7err(PKCS7_F_PKCS7_DATADECODE,
450 PKCS7_R_NO_RECIPIENT_MATCHES_CERTIFICATE); 534 PKCS7_R_NO_RECIPIENT_MATCHES_CERTIFICATE);
451 goto err; 535 goto err;
452 } 536 }
453 }
454
455 jj=EVP_PKEY_size(pkey);
456 tmp=(unsigned char *)OPENSSL_malloc(jj+10);
457 if (tmp == NULL)
458 {
459 PKCS7err(PKCS7_F_PKCS7_DATADECODE,ERR_R_MALLOC_FAILURE);
460 goto err;
461 } 537 }
462 538
463 /* If we haven't got a certificate try each ri in turn */ 539 /* If we haven't got a certificate try each ri in turn */
@@ -467,11 +543,8 @@ BIO *PKCS7_dataDecode(PKCS7 *p7, EVP_PKEY *pkey, BIO *in_bio, X509 *pcert)
467 for (i=0; i<sk_PKCS7_RECIP_INFO_num(rsk); i++) 543 for (i=0; i<sk_PKCS7_RECIP_INFO_num(rsk); i++)
468 { 544 {
469 ri=sk_PKCS7_RECIP_INFO_value(rsk,i); 545 ri=sk_PKCS7_RECIP_INFO_value(rsk,i);
470 jj=EVP_PKEY_decrypt(tmp, 546 if (pkcs7_decrypt_rinfo(&ek, &eklen,
471 M_ASN1_STRING_data(ri->enc_key), 547 ri, pkey) > 0)
472 M_ASN1_STRING_length(ri->enc_key),
473 pkey);
474 if (jj > 0)
475 break; 548 break;
476 ERR_clear_error(); 549 ERR_clear_error();
477 ri = NULL; 550 ri = NULL;
@@ -485,15 +558,8 @@ BIO *PKCS7_dataDecode(PKCS7 *p7, EVP_PKEY *pkey, BIO *in_bio, X509 *pcert)
485 } 558 }
486 else 559 else
487 { 560 {
488 jj=EVP_PKEY_decrypt(tmp, 561 if (pkcs7_decrypt_rinfo(&ek, &eklen, ri, pkey) <= 0)
489 M_ASN1_STRING_data(ri->enc_key),
490 M_ASN1_STRING_length(ri->enc_key), pkey);
491 if (jj <= 0)
492 {
493 PKCS7err(PKCS7_F_PKCS7_DATADECODE,
494 ERR_R_EVP_LIB);
495 goto err; 562 goto err;
496 }
497 } 563 }
498 564
499 evp_ctx=NULL; 565 evp_ctx=NULL;
@@ -503,22 +569,26 @@ BIO *PKCS7_dataDecode(PKCS7 *p7, EVP_PKEY *pkey, BIO *in_bio, X509 *pcert)
503 if (EVP_CIPHER_asn1_to_param(evp_ctx,enc_alg->parameter) < 0) 569 if (EVP_CIPHER_asn1_to_param(evp_ctx,enc_alg->parameter) < 0)
504 goto err; 570 goto err;
505 571
506 if (jj != EVP_CIPHER_CTX_key_length(evp_ctx)) { 572 if (eklen != EVP_CIPHER_CTX_key_length(evp_ctx)) {
507 /* Some S/MIME clients don't use the same key 573 /* Some S/MIME clients don't use the same key
508 * and effective key length. The key length is 574 * and effective key length. The key length is
509 * determined by the size of the decrypted RSA key. 575 * determined by the size of the decrypted RSA key.
510 */ 576 */
511 if(!EVP_CIPHER_CTX_set_key_length(evp_ctx, jj)) 577 if(!EVP_CIPHER_CTX_set_key_length(evp_ctx, eklen))
512 { 578 {
513 PKCS7err(PKCS7_F_PKCS7_DATADECODE, 579 PKCS7err(PKCS7_F_PKCS7_DATADECODE,
514 PKCS7_R_DECRYPTED_KEY_IS_WRONG_LENGTH); 580 PKCS7_R_DECRYPTED_KEY_IS_WRONG_LENGTH);
515 goto err; 581 goto err;
516 } 582 }
517 } 583 }
518 if (EVP_CipherInit_ex(evp_ctx,NULL,NULL,tmp,NULL,0) <= 0) 584 if (EVP_CipherInit_ex(evp_ctx,NULL,NULL,ek,NULL,0) <= 0)
519 goto err; 585 goto err;
520 586
521 OPENSSL_cleanse(tmp,jj); 587 if (ek)
588 {
589 OPENSSL_cleanse(ek,eklen);
590 OPENSSL_free(ek);
591 }
522 592
523 if (out == NULL) 593 if (out == NULL)
524 out=etmp; 594 out=etmp;
@@ -566,8 +636,6 @@ err:
566 if (bio != NULL) BIO_free_all(bio); 636 if (bio != NULL) BIO_free_all(bio);
567 out=NULL; 637 out=NULL;
568 } 638 }
569 if (tmp != NULL)
570 OPENSSL_free(tmp);
571 return(out); 639 return(out);
572 } 640 }
573 641
@@ -594,13 +662,43 @@ static BIO *PKCS7_find_digest(EVP_MD_CTX **pmd, BIO *bio, int nid)
594 return NULL; 662 return NULL;
595 } 663 }
596 664
665static int do_pkcs7_signed_attrib(PKCS7_SIGNER_INFO *si, EVP_MD_CTX *mctx)
666 {
667 unsigned char md_data[EVP_MAX_MD_SIZE];
668 unsigned int md_len;
669
670 /* Add signing time if not already present */
671 if (!PKCS7_get_signed_attribute(si, NID_pkcs9_signingTime))
672 {
673 if (!PKCS7_add0_attrib_signing_time(si, NULL))
674 {
675 PKCS7err(PKCS7_F_DO_PKCS7_SIGNED_ATTRIB,
676 ERR_R_MALLOC_FAILURE);
677 return 0;
678 }
679 }
680
681 /* Add digest */
682 EVP_DigestFinal_ex(mctx, md_data,&md_len);
683 if (!PKCS7_add1_attrib_digest(si, md_data, md_len))
684 {
685 PKCS7err(PKCS7_F_DO_PKCS7_SIGNED_ATTRIB, ERR_R_MALLOC_FAILURE);
686 return 0;
687 }
688
689 /* Now sign the attributes */
690 if (!PKCS7_SIGNER_INFO_sign(si))
691 return 0;
692
693 return 1;
694 }
695
696
597int PKCS7_dataFinal(PKCS7 *p7, BIO *bio) 697int PKCS7_dataFinal(PKCS7 *p7, BIO *bio)
598 { 698 {
599 int ret=0; 699 int ret=0;
600 int i,j; 700 int i,j;
601 BIO *btmp; 701 BIO *btmp;
602 BUF_MEM *buf_mem=NULL;
603 BUF_MEM *buf=NULL;
604 PKCS7_SIGNER_INFO *si; 702 PKCS7_SIGNER_INFO *si;
605 EVP_MD_CTX *mdc,ctx_tmp; 703 EVP_MD_CTX *mdc,ctx_tmp;
606 STACK_OF(X509_ATTRIBUTE) *sk; 704 STACK_OF(X509_ATTRIBUTE) *sk;
@@ -613,24 +711,37 @@ int PKCS7_dataFinal(PKCS7 *p7, BIO *bio)
613 711
614 switch (i) 712 switch (i)
615 { 713 {
714 case NID_pkcs7_data:
715 os = p7->d.data;
716 break;
616 case NID_pkcs7_signedAndEnveloped: 717 case NID_pkcs7_signedAndEnveloped:
617 /* XXXXXXXXXXXXXXXX */ 718 /* XXXXXXXXXXXXXXXX */
618 si_sk=p7->d.signed_and_enveloped->signer_info; 719 si_sk=p7->d.signed_and_enveloped->signer_info;
619 if (!(os=M_ASN1_OCTET_STRING_new())) 720 os = p7->d.signed_and_enveloped->enc_data->enc_data;
721 if (!os)
620 { 722 {
621 PKCS7err(PKCS7_F_PKCS7_DATAFINAL,ERR_R_MALLOC_FAILURE); 723 os=M_ASN1_OCTET_STRING_new();
622 goto err; 724 if (!os)
725 {
726 PKCS7err(PKCS7_F_PKCS7_DATAFINAL,ERR_R_MALLOC_FAILURE);
727 goto err;
728 }
729 p7->d.signed_and_enveloped->enc_data->enc_data=os;
623 } 730 }
624 p7->d.signed_and_enveloped->enc_data->enc_data=os;
625 break; 731 break;
626 case NID_pkcs7_enveloped: 732 case NID_pkcs7_enveloped:
627 /* XXXXXXXXXXXXXXXX */ 733 /* XXXXXXXXXXXXXXXX */
628 if (!(os=M_ASN1_OCTET_STRING_new())) 734 os = p7->d.enveloped->enc_data->enc_data;
735 if (!os)
629 { 736 {
630 PKCS7err(PKCS7_F_PKCS7_DATAFINAL,ERR_R_MALLOC_FAILURE); 737 os=M_ASN1_OCTET_STRING_new();
631 goto err; 738 if (!os)
739 {
740 PKCS7err(PKCS7_F_PKCS7_DATAFINAL,ERR_R_MALLOC_FAILURE);
741 goto err;
742 }
743 p7->d.enveloped->enc_data->enc_data=os;
632 } 744 }
633 p7->d.enveloped->enc_data->enc_data=os;
634 break; 745 break;
635 case NID_pkcs7_signed: 746 case NID_pkcs7_signed:
636 si_sk=p7->d.sign->signer_info; 747 si_sk=p7->d.sign->signer_info;
@@ -652,21 +763,20 @@ int PKCS7_dataFinal(PKCS7 *p7, BIO *bio)
652 } 763 }
653 break; 764 break;
654 765
766 default:
767 PKCS7err(PKCS7_F_PKCS7_DATAFINAL,PKCS7_R_UNSUPPORTED_CONTENT_TYPE);
768 goto err;
655 } 769 }
656 770
657 if (si_sk != NULL) 771 if (si_sk != NULL)
658 { 772 {
659 if ((buf=BUF_MEM_new()) == NULL)
660 {
661 PKCS7err(PKCS7_F_PKCS7_DATAFINAL,ERR_R_BIO_LIB);
662 goto err;
663 }
664 for (i=0; i<sk_PKCS7_SIGNER_INFO_num(si_sk); i++) 773 for (i=0; i<sk_PKCS7_SIGNER_INFO_num(si_sk); i++)
665 { 774 {
666 si=sk_PKCS7_SIGNER_INFO_value(si_sk,i); 775 si=sk_PKCS7_SIGNER_INFO_value(si_sk,i);
667 if (si->pkey == NULL) continue; 776 if (si->pkey == NULL)
777 continue;
668 778
669 j=OBJ_obj2nid(si->digest_alg->algorithm); 779 j = OBJ_obj2nid(si->digest_alg->algorithm);
670 780
671 btmp=bio; 781 btmp=bio;
672 782
@@ -678,97 +788,33 @@ int PKCS7_dataFinal(PKCS7 *p7, BIO *bio)
678 /* We now have the EVP_MD_CTX, lets do the 788 /* We now have the EVP_MD_CTX, lets do the
679 * signing. */ 789 * signing. */
680 EVP_MD_CTX_copy_ex(&ctx_tmp,mdc); 790 EVP_MD_CTX_copy_ex(&ctx_tmp,mdc);
681 if (!BUF_MEM_grow_clean(buf,EVP_PKEY_size(si->pkey)))
682 {
683 PKCS7err(PKCS7_F_PKCS7_DATAFINAL,ERR_R_BIO_LIB);
684 goto err;
685 }
686 791
687 sk=si->auth_attr; 792 sk=si->auth_attr;
688 793
689 /* If there are attributes, we add the digest 794 /* If there are attributes, we add the digest
690 * attribute and only sign the attributes */ 795 * attribute and only sign the attributes */
691 if ((sk != NULL) && (sk_X509_ATTRIBUTE_num(sk) != 0)) 796 if (sk_X509_ATTRIBUTE_num(sk) > 0)
692 { 797 {
693 unsigned char md_data[EVP_MAX_MD_SIZE], *abuf=NULL; 798 if (!do_pkcs7_signed_attrib(si, &ctx_tmp))
694 unsigned int md_len, alen;
695 ASN1_OCTET_STRING *digest;
696 ASN1_UTCTIME *sign_time;
697 const EVP_MD *md_tmp;
698
699 /* Add signing time if not already present */
700 if (!PKCS7_get_signed_attribute(si,
701 NID_pkcs9_signingTime))
702 {
703 if (!(sign_time=X509_gmtime_adj(NULL,0)))
704 {
705 PKCS7err(PKCS7_F_PKCS7_DATAFINAL,
706 ERR_R_MALLOC_FAILURE);
707 goto err;
708 }
709 if (!PKCS7_add_signed_attribute(si,
710 NID_pkcs9_signingTime,
711 V_ASN1_UTCTIME,sign_time))
712 {
713 M_ASN1_UTCTIME_free(sign_time);
714 goto err;
715 }
716 }
717
718 /* Add digest */
719 md_tmp=EVP_MD_CTX_md(&ctx_tmp);
720 EVP_DigestFinal_ex(&ctx_tmp,md_data,&md_len);
721 if (!(digest=M_ASN1_OCTET_STRING_new()))
722 {
723 PKCS7err(PKCS7_F_PKCS7_DATAFINAL,
724 ERR_R_MALLOC_FAILURE);
725 goto err; 799 goto err;
726 } 800 }
727 if (!M_ASN1_OCTET_STRING_set(digest,md_data, 801 else
728 md_len)) 802 {
729 { 803 unsigned char *abuf = NULL;
730 PKCS7err(PKCS7_F_PKCS7_DATAFINAL, 804 unsigned int abuflen;
731 ERR_R_MALLOC_FAILURE); 805 abuflen = EVP_PKEY_size(si->pkey);
732 M_ASN1_OCTET_STRING_free(digest); 806 abuf = OPENSSL_malloc(abuflen);
807 if (!abuf)
733 goto err; 808 goto err;
734 } 809
735 if (!PKCS7_add_signed_attribute(si, 810 if (!EVP_SignFinal(&ctx_tmp, abuf, &abuflen,
736 NID_pkcs9_messageDigest, 811 si->pkey))
737 V_ASN1_OCTET_STRING,digest))
738 { 812 {
739 M_ASN1_OCTET_STRING_free(digest); 813 PKCS7err(PKCS7_F_PKCS7_DATAFINAL,
814 ERR_R_EVP_LIB);
740 goto err; 815 goto err;
741 } 816 }
742 817 ASN1_STRING_set0(si->enc_digest, abuf, abuflen);
743 /* Now sign the attributes */
744 EVP_SignInit_ex(&ctx_tmp,md_tmp,NULL);
745 alen = ASN1_item_i2d((ASN1_VALUE *)sk,&abuf,
746 ASN1_ITEM_rptr(PKCS7_ATTR_SIGN));
747 if(!abuf) goto err;
748 EVP_SignUpdate(&ctx_tmp,abuf,alen);
749 OPENSSL_free(abuf);
750 }
751
752#ifndef OPENSSL_NO_DSA
753 if (si->pkey->type == EVP_PKEY_DSA)
754 ctx_tmp.digest=EVP_dss1();
755#endif
756#ifndef OPENSSL_NO_ECDSA
757 if (si->pkey->type == EVP_PKEY_EC)
758 ctx_tmp.digest=EVP_ecdsa();
759#endif
760
761 if (!EVP_SignFinal(&ctx_tmp,(unsigned char *)buf->data,
762 (unsigned int *)&buf->length,si->pkey))
763 {
764 PKCS7err(PKCS7_F_PKCS7_DATAFINAL,ERR_R_EVP_LIB);
765 goto err;
766 }
767 if (!ASN1_STRING_set(si->enc_digest,
768 (unsigned char *)buf->data,buf->length))
769 {
770 PKCS7err(PKCS7_F_PKCS7_DATAFINAL,ERR_R_ASN1_LIB);
771 goto err;
772 } 818 }
773 } 819 }
774 } 820 }
@@ -783,34 +829,90 @@ int PKCS7_dataFinal(PKCS7 *p7, BIO *bio)
783 M_ASN1_OCTET_STRING_set(p7->d.digest->digest, md_data, md_len); 829 M_ASN1_OCTET_STRING_set(p7->d.digest->digest, md_data, md_len);
784 } 830 }
785 831
786 if (!PKCS7_is_detached(p7)) 832 if (!PKCS7_is_detached(p7) && !(os->flags & ASN1_STRING_FLAG_NDEF))
787 { 833 {
834 char *cont;
835 long contlen;
788 btmp=BIO_find_type(bio,BIO_TYPE_MEM); 836 btmp=BIO_find_type(bio,BIO_TYPE_MEM);
789 if (btmp == NULL) 837 if (btmp == NULL)
790 { 838 {
791 PKCS7err(PKCS7_F_PKCS7_DATAFINAL,PKCS7_R_UNABLE_TO_FIND_MEM_BIO); 839 PKCS7err(PKCS7_F_PKCS7_DATAFINAL,PKCS7_R_UNABLE_TO_FIND_MEM_BIO);
792 goto err; 840 goto err;
793 } 841 }
794 BIO_get_mem_ptr(btmp,&buf_mem); 842 contlen = BIO_get_mem_data(btmp, &cont);
795 /* Mark the BIO read only then we can use its copy of the data 843 /* Mark the BIO read only then we can use its copy of the data
796 * instead of making an extra copy. 844 * instead of making an extra copy.
797 */ 845 */
798 BIO_set_flags(btmp, BIO_FLAGS_MEM_RDONLY); 846 BIO_set_flags(btmp, BIO_FLAGS_MEM_RDONLY);
799 BIO_set_mem_eof_return(btmp, 0); 847 BIO_set_mem_eof_return(btmp, 0);
800 os->data = (unsigned char *)buf_mem->data; 848 ASN1_STRING_set0(os, (unsigned char *)cont, contlen);
801 os->length = buf_mem->length;
802#if 0
803 M_ASN1_OCTET_STRING_set(os,
804 (unsigned char *)buf_mem->data,buf_mem->length);
805#endif
806 } 849 }
807 ret=1; 850 ret=1;
808err: 851err:
809 EVP_MD_CTX_cleanup(&ctx_tmp); 852 EVP_MD_CTX_cleanup(&ctx_tmp);
810 if (buf != NULL) BUF_MEM_free(buf);
811 return(ret); 853 return(ret);
812 } 854 }
813 855
856int PKCS7_SIGNER_INFO_sign(PKCS7_SIGNER_INFO *si)
857 {
858 EVP_MD_CTX mctx;
859 EVP_PKEY_CTX *pctx;
860 unsigned char *abuf = NULL;
861 int alen;
862 size_t siglen;
863 const EVP_MD *md = NULL;
864
865 md = EVP_get_digestbyobj(si->digest_alg->algorithm);
866 if (md == NULL)
867 return 0;
868
869 EVP_MD_CTX_init(&mctx);
870 if (EVP_DigestSignInit(&mctx, &pctx, md,NULL, si->pkey) <= 0)
871 goto err;
872
873 if (EVP_PKEY_CTX_ctrl(pctx, -1, EVP_PKEY_OP_SIGN,
874 EVP_PKEY_CTRL_PKCS7_SIGN, 0, si) <= 0)
875 {
876 PKCS7err(PKCS7_F_PKCS7_SIGNER_INFO_SIGN, PKCS7_R_CTRL_ERROR);
877 goto err;
878 }
879
880 alen = ASN1_item_i2d((ASN1_VALUE *)si->auth_attr,&abuf,
881 ASN1_ITEM_rptr(PKCS7_ATTR_SIGN));
882 if(!abuf)
883 goto err;
884 if (EVP_DigestSignUpdate(&mctx,abuf,alen) <= 0)
885 goto err;
886 OPENSSL_free(abuf);
887 if (EVP_DigestSignFinal(&mctx, NULL, &siglen) <= 0)
888 goto err;
889 abuf = OPENSSL_malloc(siglen);
890 if(!abuf)
891 goto err;
892 if (EVP_DigestSignFinal(&mctx, abuf, &siglen) <= 0)
893 goto err;
894
895 if (EVP_PKEY_CTX_ctrl(pctx, -1, EVP_PKEY_OP_SIGN,
896 EVP_PKEY_CTRL_PKCS7_SIGN, 1, si) <= 0)
897 {
898 PKCS7err(PKCS7_F_PKCS7_SIGNER_INFO_SIGN, PKCS7_R_CTRL_ERROR);
899 goto err;
900 }
901
902 EVP_MD_CTX_cleanup(&mctx);
903
904 ASN1_STRING_set0(si->enc_digest, abuf, siglen);
905
906 return 1;
907
908 err:
909 if (abuf)
910 OPENSSL_free(abuf);
911 EVP_MD_CTX_cleanup(&mctx);
912 return 0;
913
914 }
915
814int PKCS7_dataVerify(X509_STORE *cert_store, X509_STORE_CTX *ctx, BIO *bio, 916int PKCS7_dataVerify(X509_STORE *cert_store, X509_STORE_CTX *ctx, BIO *bio,
815 PKCS7 *p7, PKCS7_SIGNER_INFO *si) 917 PKCS7 *p7, PKCS7_SIGNER_INFO *si)
816 { 918 {
@@ -922,7 +1024,8 @@ int PKCS7_signatureVerify(BIO *bio, PKCS7 *p7, PKCS7_SIGNER_INFO *si,
922 if ((sk != NULL) && (sk_X509_ATTRIBUTE_num(sk) != 0)) 1024 if ((sk != NULL) && (sk_X509_ATTRIBUTE_num(sk) != 0))
923 { 1025 {
924 unsigned char md_dat[EVP_MAX_MD_SIZE], *abuf = NULL; 1026 unsigned char md_dat[EVP_MAX_MD_SIZE], *abuf = NULL;
925 unsigned int md_len, alen; 1027 unsigned int md_len;
1028 int alen;
926 ASN1_OCTET_STRING *message_digest; 1029 ASN1_OCTET_STRING *message_digest;
927 1030
928 EVP_DigestFinal_ex(&mdc_tmp,md_dat,&md_len); 1031 EVP_DigestFinal_ex(&mdc_tmp,md_dat,&md_len);
@@ -954,6 +1057,12 @@ for (ii=0; ii<md_len; ii++) printf("%02X",md_dat[ii]); printf(" calc\n");
954 1057
955 alen = ASN1_item_i2d((ASN1_VALUE *)sk, &abuf, 1058 alen = ASN1_item_i2d((ASN1_VALUE *)sk, &abuf,
956 ASN1_ITEM_rptr(PKCS7_ATTR_VERIFY)); 1059 ASN1_ITEM_rptr(PKCS7_ATTR_VERIFY));
1060 if (alen <= 0)
1061 {
1062 PKCS7err(PKCS7_F_PKCS7_SIGNATUREVERIFY,ERR_R_ASN1_LIB);
1063 ret = -1;
1064 goto err;
1065 }
957 EVP_VerifyUpdate(&mdc_tmp, abuf, alen); 1066 EVP_VerifyUpdate(&mdc_tmp, abuf, alen);
958 1067
959 OPENSSL_free(abuf); 1068 OPENSSL_free(abuf);
@@ -966,12 +1075,6 @@ for (ii=0; ii<md_len; ii++) printf("%02X",md_dat[ii]); printf(" calc\n");
966 ret = -1; 1075 ret = -1;
967 goto err; 1076 goto err;
968 } 1077 }
969#ifndef OPENSSL_NO_DSA
970 if(pkey->type == EVP_PKEY_DSA) mdc_tmp.digest=EVP_dss1();
971#endif
972#ifndef OPENSSL_NO_ECDSA
973 if (pkey->type == EVP_PKEY_EC) mdc_tmp.digest=EVP_ecdsa();
974#endif
975 1078
976 i=EVP_VerifyFinal(&mdc_tmp,os->data,os->length, pkey); 1079 i=EVP_VerifyFinal(&mdc_tmp,os->data,os->length, pkey);
977 EVP_PKEY_free(pkey); 1080 EVP_PKEY_free(pkey);
@@ -1107,8 +1210,9 @@ static int add_attribute(STACK_OF(X509_ATTRIBUTE) **sk, int nid, int atrtype,
1107 1210
1108 if (*sk == NULL) 1211 if (*sk == NULL)
1109 { 1212 {
1110 if (!(*sk = sk_X509_ATTRIBUTE_new_null())) 1213 *sk = sk_X509_ATTRIBUTE_new_null();
1111 return 0; 1214 if (*sk == NULL)
1215 return 0;
1112new_attrib: 1216new_attrib:
1113 if (!(attr=X509_ATTRIBUTE_create(nid,atrtype,value))) 1217 if (!(attr=X509_ATTRIBUTE_create(nid,atrtype,value)))
1114 return 0; 1218 return 0;
diff --git a/src/lib/libcrypto/pkcs7/pk7_lib.c b/src/lib/libcrypto/pkcs7/pk7_lib.c
index f2490941a3..3ca0952792 100644
--- a/src/lib/libcrypto/pkcs7/pk7_lib.c
+++ b/src/lib/libcrypto/pkcs7/pk7_lib.c
@@ -60,6 +60,7 @@
60#include "cryptlib.h" 60#include "cryptlib.h"
61#include <openssl/objects.h> 61#include <openssl/objects.h>
62#include <openssl/x509.h> 62#include <openssl/x509.h>
63#include "asn1_locl.h"
63 64
64long PKCS7_ctrl(PKCS7 *p7, int cmd, long larg, char *parg) 65long PKCS7_ctrl(PKCS7 *p7, int cmd, long larg, char *parg)
65 { 66 {
@@ -314,7 +315,7 @@ int PKCS7_add_certificate(PKCS7 *p7, X509 *x509)
314 *sk=sk_X509_new_null(); 315 *sk=sk_X509_new_null();
315 if (*sk == NULL) 316 if (*sk == NULL)
316 { 317 {
317 PKCS7err(PKCS7_F_PKCS7_ADD_CERTIFICATE,ERR_R_MALLOC_FAILURE); 318 PKCS7err(PKCS7_F_PKCS7_ADD_CERTIFICATE, ERR_R_MALLOC_FAILURE);
318 return 0; 319 return 0;
319 } 320 }
320 CRYPTO_add(&x509->references,1,CRYPTO_LOCK_X509); 321 CRYPTO_add(&x509->references,1,CRYPTO_LOCK_X509);
@@ -365,13 +366,8 @@ int PKCS7_add_crl(PKCS7 *p7, X509_CRL *crl)
365int PKCS7_SIGNER_INFO_set(PKCS7_SIGNER_INFO *p7i, X509 *x509, EVP_PKEY *pkey, 366int PKCS7_SIGNER_INFO_set(PKCS7_SIGNER_INFO *p7i, X509 *x509, EVP_PKEY *pkey,
366 const EVP_MD *dgst) 367 const EVP_MD *dgst)
367 { 368 {
368 int nid; 369 int ret;
369 char is_dsa;
370 370
371 if (pkey->type == EVP_PKEY_DSA || pkey->type == EVP_PKEY_EC)
372 is_dsa = 1;
373 else
374 is_dsa = 0;
375 /* We now need to add another PKCS7_SIGNER_INFO entry */ 371 /* We now need to add another PKCS7_SIGNER_INFO entry */
376 if (!ASN1_INTEGER_set(p7i->version,1)) 372 if (!ASN1_INTEGER_set(p7i->version,1))
377 goto err; 373 goto err;
@@ -391,65 +387,55 @@ int PKCS7_SIGNER_INFO_set(PKCS7_SIGNER_INFO *p7i, X509 *x509, EVP_PKEY *pkey,
391 p7i->pkey=pkey; 387 p7i->pkey=pkey;
392 388
393 /* Set the algorithms */ 389 /* Set the algorithms */
394 if (is_dsa) p7i->digest_alg->algorithm=OBJ_nid2obj(NID_sha1);
395 else
396 p7i->digest_alg->algorithm=OBJ_nid2obj(EVP_MD_type(dgst));
397 390
398 if (p7i->digest_alg->parameter != NULL) 391 X509_ALGOR_set0(p7i->digest_alg, OBJ_nid2obj(EVP_MD_type(dgst)),
399 ASN1_TYPE_free(p7i->digest_alg->parameter); 392 V_ASN1_NULL, NULL);
400 if ((p7i->digest_alg->parameter=ASN1_TYPE_new()) == NULL)
401 goto err;
402 p7i->digest_alg->parameter->type=V_ASN1_NULL;
403 393
404 if (p7i->digest_enc_alg->parameter != NULL) 394 if (pkey->ameth && pkey->ameth->pkey_ctrl)
405 ASN1_TYPE_free(p7i->digest_enc_alg->parameter);
406 nid = EVP_PKEY_type(pkey->type);
407 if (nid == EVP_PKEY_RSA)
408 { 395 {
409 p7i->digest_enc_alg->algorithm=OBJ_nid2obj(NID_rsaEncryption); 396 ret = pkey->ameth->pkey_ctrl(pkey, ASN1_PKEY_CTRL_PKCS7_SIGN,
410 if (!(p7i->digest_enc_alg->parameter=ASN1_TYPE_new())) 397 0, p7i);
411 goto err; 398 if (ret > 0)
412 p7i->digest_enc_alg->parameter->type=V_ASN1_NULL; 399 return 1;
413 } 400 if (ret != -2)
414 else if (nid == EVP_PKEY_DSA) 401 {
415 { 402 PKCS7err(PKCS7_F_PKCS7_SIGNER_INFO_SET,
416#if 1 403 PKCS7_R_SIGNING_CTRL_FAILURE);
417 /* use 'dsaEncryption' OID for compatibility with other software 404 return 0;
418 * (PKCS #7 v1.5 does specify how to handle DSA) ... */ 405 }
419 p7i->digest_enc_alg->algorithm=OBJ_nid2obj(NID_dsa);
420#else
421 /* ... although the 'dsaWithSHA1' OID (as required by RFC 2630 for CMS)
422 * would make more sense. */
423 p7i->digest_enc_alg->algorithm=OBJ_nid2obj(NID_dsaWithSHA1);
424#endif
425 p7i->digest_enc_alg->parameter = NULL; /* special case for DSA: omit 'parameter'! */
426 }
427 else if (nid == EVP_PKEY_EC)
428 {
429 p7i->digest_enc_alg->algorithm=OBJ_nid2obj(NID_ecdsa_with_SHA1);
430 if (!(p7i->digest_enc_alg->parameter=ASN1_TYPE_new()))
431 goto err;
432 p7i->digest_enc_alg->parameter->type=V_ASN1_NULL;
433 } 406 }
434 else 407 PKCS7err(PKCS7_F_PKCS7_SIGNER_INFO_SET,
435 return(0); 408 PKCS7_R_SIGNING_NOT_SUPPORTED_FOR_THIS_KEY_TYPE);
436
437 return(1);
438err: 409err:
439 return(0); 410 return 0;
440 } 411 }
441 412
442PKCS7_SIGNER_INFO *PKCS7_add_signature(PKCS7 *p7, X509 *x509, EVP_PKEY *pkey, 413PKCS7_SIGNER_INFO *PKCS7_add_signature(PKCS7 *p7, X509 *x509, EVP_PKEY *pkey,
443 const EVP_MD *dgst) 414 const EVP_MD *dgst)
444 { 415 {
445 PKCS7_SIGNER_INFO *si; 416 PKCS7_SIGNER_INFO *si = NULL;
417
418 if (dgst == NULL)
419 {
420 int def_nid;
421 if (EVP_PKEY_get_default_digest_nid(pkey, &def_nid) <= 0)
422 goto err;
423 dgst = EVP_get_digestbynid(def_nid);
424 if (dgst == NULL)
425 {
426 PKCS7err(PKCS7_F_PKCS7_ADD_SIGNATURE,
427 PKCS7_R_NO_DEFAULT_DIGEST);
428 goto err;
429 }
430 }
446 431
447 if ((si=PKCS7_SIGNER_INFO_new()) == NULL) goto err; 432 if ((si=PKCS7_SIGNER_INFO_new()) == NULL) goto err;
448 if (!PKCS7_SIGNER_INFO_set(si,x509,pkey,dgst)) goto err; 433 if (!PKCS7_SIGNER_INFO_set(si,x509,pkey,dgst)) goto err;
449 if (!PKCS7_add_signer(p7,si)) goto err; 434 if (!PKCS7_add_signer(p7,si)) goto err;
450 return(si); 435 return(si);
451err: 436err:
452 PKCS7_SIGNER_INFO_free(si); 437 if (si)
438 PKCS7_SIGNER_INFO_free(si);
453 return(NULL); 439 return(NULL);
454 } 440 }
455 441
@@ -485,6 +471,23 @@ STACK_OF(PKCS7_SIGNER_INFO) *PKCS7_get_signer_info(PKCS7 *p7)
485 return(NULL); 471 return(NULL);
486 } 472 }
487 473
474void PKCS7_SIGNER_INFO_get0_algs(PKCS7_SIGNER_INFO *si, EVP_PKEY **pk,
475 X509_ALGOR **pdig, X509_ALGOR **psig)
476 {
477 if (pk)
478 *pk = si->pkey;
479 if (pdig)
480 *pdig = si->digest_alg;
481 if (psig)
482 *psig = si->digest_enc_alg;
483 }
484
485void PKCS7_RECIP_INFO_get0_alg(PKCS7_RECIP_INFO *ri, X509_ALGOR **penc)
486 {
487 if (penc)
488 *penc = ri->key_enc_algor;
489 }
490
488PKCS7_RECIP_INFO *PKCS7_add_recipient(PKCS7 *p7, X509 *x509) 491PKCS7_RECIP_INFO *PKCS7_add_recipient(PKCS7 *p7, X509 *x509)
489 { 492 {
490 PKCS7_RECIP_INFO *ri; 493 PKCS7_RECIP_INFO *ri;
@@ -492,10 +495,11 @@ PKCS7_RECIP_INFO *PKCS7_add_recipient(PKCS7 *p7, X509 *x509)
492 if ((ri=PKCS7_RECIP_INFO_new()) == NULL) goto err; 495 if ((ri=PKCS7_RECIP_INFO_new()) == NULL) goto err;
493 if (!PKCS7_RECIP_INFO_set(ri,x509)) goto err; 496 if (!PKCS7_RECIP_INFO_set(ri,x509)) goto err;
494 if (!PKCS7_add_recipient_info(p7,ri)) goto err; 497 if (!PKCS7_add_recipient_info(p7,ri)) goto err;
495 return(ri); 498 return ri;
496err: 499err:
497 PKCS7_RECIP_INFO_free(ri); 500 if (ri)
498 return(NULL); 501 PKCS7_RECIP_INFO_free(ri);
502 return NULL;
499 } 503 }
500 504
501int PKCS7_add_recipient_info(PKCS7 *p7, PKCS7_RECIP_INFO *ri) 505int PKCS7_add_recipient_info(PKCS7 *p7, PKCS7_RECIP_INFO *ri)
@@ -524,6 +528,8 @@ int PKCS7_add_recipient_info(PKCS7 *p7, PKCS7_RECIP_INFO *ri)
524 528
525int PKCS7_RECIP_INFO_set(PKCS7_RECIP_INFO *p7i, X509 *x509) 529int PKCS7_RECIP_INFO_set(PKCS7_RECIP_INFO *p7i, X509 *x509)
526 { 530 {
531 int ret;
532 EVP_PKEY *pkey = NULL;
527 if (!ASN1_INTEGER_set(p7i->version,0)) 533 if (!ASN1_INTEGER_set(p7i->version,0))
528 return 0; 534 return 0;
529 if (!X509_NAME_set(&p7i->issuer_and_serial->issuer, 535 if (!X509_NAME_set(&p7i->issuer_and_serial->issuer,
@@ -535,14 +541,41 @@ int PKCS7_RECIP_INFO_set(PKCS7_RECIP_INFO *p7i, X509 *x509)
535 M_ASN1_INTEGER_dup(X509_get_serialNumber(x509)))) 541 M_ASN1_INTEGER_dup(X509_get_serialNumber(x509))))
536 return 0; 542 return 0;
537 543
538 X509_ALGOR_free(p7i->key_enc_algor); 544 pkey = X509_get_pubkey(x509);
539 if (!(p7i->key_enc_algor= X509_ALGOR_dup(x509->cert_info->key->algor))) 545
540 return 0; 546 if (!pkey || !pkey->ameth || !pkey->ameth->pkey_ctrl)
547 {
548 PKCS7err(PKCS7_F_PKCS7_RECIP_INFO_SET,
549 PKCS7_R_ENCRYPTION_NOT_SUPPORTED_FOR_THIS_KEY_TYPE);
550 goto err;
551 }
552
553 ret = pkey->ameth->pkey_ctrl(pkey, ASN1_PKEY_CTRL_PKCS7_ENCRYPT,
554 0, p7i);
555 if (ret == -2)
556 {
557 PKCS7err(PKCS7_F_PKCS7_RECIP_INFO_SET,
558 PKCS7_R_ENCRYPTION_NOT_SUPPORTED_FOR_THIS_KEY_TYPE);
559 goto err;
560 }
561 if (ret <= 0)
562 {
563 PKCS7err(PKCS7_F_PKCS7_RECIP_INFO_SET,
564 PKCS7_R_ENCRYPTION_CTRL_FAILURE);
565 goto err;
566 }
567
568 EVP_PKEY_free(pkey);
541 569
542 CRYPTO_add(&x509->references,1,CRYPTO_LOCK_X509); 570 CRYPTO_add(&x509->references,1,CRYPTO_LOCK_X509);
543 p7i->cert=x509; 571 p7i->cert=x509;
544 572
545 return(1); 573 return 1;
574
575 err:
576 if (pkey)
577 EVP_PKEY_free(pkey);
578 return 0;
546 } 579 }
547 580
548X509 *PKCS7_cert_from_signer_info(PKCS7 *p7, PKCS7_SIGNER_INFO *si) 581X509 *PKCS7_cert_from_signer_info(PKCS7 *p7, PKCS7_SIGNER_INFO *si)
@@ -587,3 +620,48 @@ int PKCS7_set_cipher(PKCS7 *p7, const EVP_CIPHER *cipher)
587 return 1; 620 return 1;
588 } 621 }
589 622
623int PKCS7_stream(unsigned char ***boundary, PKCS7 *p7)
624 {
625 ASN1_OCTET_STRING *os = NULL;
626
627 switch (OBJ_obj2nid(p7->type))
628 {
629 case NID_pkcs7_data:
630 os = p7->d.data;
631 break;
632
633 case NID_pkcs7_signedAndEnveloped:
634 os = p7->d.signed_and_enveloped->enc_data->enc_data;
635 if (os == NULL)
636 {
637 os=M_ASN1_OCTET_STRING_new();
638 p7->d.signed_and_enveloped->enc_data->enc_data=os;
639 }
640 break;
641
642 case NID_pkcs7_enveloped:
643 os = p7->d.enveloped->enc_data->enc_data;
644 if (os == NULL)
645 {
646 os=M_ASN1_OCTET_STRING_new();
647 p7->d.enveloped->enc_data->enc_data=os;
648 }
649 break;
650
651 case NID_pkcs7_signed:
652 os=p7->d.sign->contents->d.data;
653 break;
654
655 default:
656 os = NULL;
657 break;
658 }
659
660 if (os == NULL)
661 return 0;
662
663 os->flags |= ASN1_STRING_FLAG_NDEF;
664 *boundary = &os->data;
665
666 return 1;
667 }
diff --git a/src/lib/libcrypto/pkcs7/pk7_mime.c b/src/lib/libcrypto/pkcs7/pk7_mime.c
index bf190360d7..938f79a646 100644
--- a/src/lib/libcrypto/pkcs7/pk7_mime.c
+++ b/src/lib/libcrypto/pkcs7/pk7_mime.c
@@ -50,10 +50,6 @@
50 * OF THE POSSIBILITY OF SUCH DAMAGE. 50 * OF THE POSSIBILITY OF SUCH DAMAGE.
51 * ==================================================================== 51 * ====================================================================
52 * 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 */ 53 */
58 54
59#include <stdio.h> 55#include <stdio.h>
@@ -61,662 +57,41 @@
61#include "cryptlib.h" 57#include "cryptlib.h"
62#include <openssl/rand.h> 58#include <openssl/rand.h>
63#include <openssl/x509.h> 59#include <openssl/x509.h>
60#include <openssl/asn1.h>
64 61
65/* MIME and related routines */ 62/* PKCS#7 wrappers round generalised stream and MIME routines */
66
67/* MIME format structures
68 * Note that all are translated to lower case apart from
69 * parameter values. Quotes are stripped off
70 */
71
72typedef struct {
73char *param_name; /* Param name e.g. "micalg" */
74char *param_value; /* Param value e.g. "sha1" */
75} MIME_PARAM;
76
77DECLARE_STACK_OF(MIME_PARAM)
78IMPLEMENT_STACK_OF(MIME_PARAM)
79
80typedef struct {
81char *name; /* Name of line e.g. "content-type" */
82char *value; /* Value of line e.g. "text/plain" */
83STACK_OF(MIME_PARAM) *params; /* Zero or more parameters */
84} MIME_HEADER;
85 63
86DECLARE_STACK_OF(MIME_HEADER) 64int i2d_PKCS7_bio_stream(BIO *out, PKCS7 *p7, BIO *in, int flags)
87IMPLEMENT_STACK_OF(MIME_HEADER) 65 {
88 66 return i2d_ASN1_bio_stream(out, (ASN1_VALUE *)p7, in, flags,
89static int pkcs7_output_data(BIO *bio, BIO *data, PKCS7 *p7, int flags); 67 ASN1_ITEM_rptr(PKCS7));
90static int B64_write_PKCS7(BIO *bio, PKCS7 *p7);
91static PKCS7 *B64_read_PKCS7(BIO *bio);
92static char * strip_ends(char *name);
93static char * strip_start(char *name);
94static char * strip_end(char *name);
95static MIME_HEADER *mime_hdr_new(char *name, char *value);
96static int mime_hdr_addparam(MIME_HEADER *mhdr, char *name, char *value);
97static STACK_OF(MIME_HEADER) *mime_parse_hdr(BIO *bio);
98static int mime_hdr_cmp(const MIME_HEADER * const *a,
99 const MIME_HEADER * const *b);
100static int mime_param_cmp(const MIME_PARAM * const *a,
101 const MIME_PARAM * const *b);
102static void mime_param_free(MIME_PARAM *param);
103static int mime_bound_check(char *line, int linelen, char *bound, int blen);
104static int multi_split(BIO *bio, char *bound, STACK_OF(BIO) **ret);
105static int strip_eol(char *linebuf, int *plen);
106static MIME_HEADER *mime_hdr_find(STACK_OF(MIME_HEADER) *hdrs, char *name);
107static MIME_PARAM *mime_param_find(MIME_HEADER *hdr, char *name);
108static void mime_hdr_free(MIME_HEADER *hdr);
109
110#define MAX_SMLEN 1024
111#define mime_debug(x) /* x */
112
113/* Base 64 read and write of PKCS#7 structure */
114
115static int B64_write_PKCS7(BIO *bio, PKCS7 *p7)
116{
117 BIO *b64;
118 if(!(b64 = BIO_new(BIO_f_base64()))) {
119 PKCS7err(PKCS7_F_B64_WRITE_PKCS7,ERR_R_MALLOC_FAILURE);
120 return 0;
121 } 68 }
122 bio = BIO_push(b64, bio);
123 i2d_PKCS7_bio(bio, p7);
124 (void)BIO_flush(bio);
125 bio = BIO_pop(bio);
126 BIO_free(b64);
127 return 1;
128}
129 69
130static PKCS7 *B64_read_PKCS7(BIO *bio) 70int PEM_write_bio_PKCS7_stream(BIO *out, PKCS7 *p7, BIO *in, int flags)
131{ 71 {
132 BIO *b64; 72 return PEM_write_bio_ASN1_stream(out, (ASN1_VALUE *) p7, in, flags,
133 PKCS7 *p7; 73 "PKCS7",
134 if(!(b64 = BIO_new(BIO_f_base64()))) { 74 ASN1_ITEM_rptr(PKCS7));
135 PKCS7err(PKCS7_F_B64_READ_PKCS7,ERR_R_MALLOC_FAILURE);
136 return 0;
137 } 75 }
138 bio = BIO_push(b64, bio);
139 if(!(p7 = d2i_PKCS7_bio(bio, NULL)))
140 PKCS7err(PKCS7_F_B64_READ_PKCS7,PKCS7_R_DECODE_ERROR);
141 (void)BIO_flush(bio);
142 bio = BIO_pop(bio);
143 BIO_free(b64);
144 return p7;
145}
146
147/* SMIME sender */
148 76
149int SMIME_write_PKCS7(BIO *bio, PKCS7 *p7, BIO *data, int flags) 77int SMIME_write_PKCS7(BIO *bio, PKCS7 *p7, BIO *data, int flags)
150{
151 char bound[33], c;
152 int i;
153 char *mime_prefix, *mime_eol, *msg_type=NULL;
154 if (flags & PKCS7_NOOLDMIMETYPE)
155 mime_prefix = "application/pkcs7-";
156 else
157 mime_prefix = "application/x-pkcs7-";
158
159 if (flags & PKCS7_CRLFEOL)
160 mime_eol = "\r\n";
161 else
162 mime_eol = "\n";
163 if((flags & PKCS7_DETACHED) && data) {
164 /* We want multipart/signed */
165 /* Generate a random boundary */
166 RAND_pseudo_bytes((unsigned char *)bound, 32);
167 for(i = 0; i < 32; i++) {
168 c = bound[i] & 0xf;
169 if(c < 10) c += '0';
170 else c += 'A' - 10;
171 bound[i] = c;
172 }
173 bound[32] = 0;
174 BIO_printf(bio, "MIME-Version: 1.0%s", mime_eol);
175 BIO_printf(bio, "Content-Type: multipart/signed;");
176 BIO_printf(bio, " protocol=\"%ssignature\";", mime_prefix);
177 BIO_printf(bio, " micalg=sha1; boundary=\"----%s\"%s%s",
178 bound, mime_eol, mime_eol);
179 BIO_printf(bio, "This is an S/MIME signed message%s%s",
180 mime_eol, mime_eol);
181 /* Now write out the first part */
182 BIO_printf(bio, "------%s%s", bound, mime_eol);
183 pkcs7_output_data(bio, data, p7, flags);
184 BIO_printf(bio, "%s------%s%s", mime_eol, bound, mime_eol);
185
186 /* Headers for signature */
187
188 BIO_printf(bio, "Content-Type: %ssignature;", mime_prefix);
189 BIO_printf(bio, " name=\"smime.p7s\"%s", mime_eol);
190 BIO_printf(bio, "Content-Transfer-Encoding: base64%s",
191 mime_eol);
192 BIO_printf(bio, "Content-Disposition: attachment;");
193 BIO_printf(bio, " filename=\"smime.p7s\"%s%s",
194 mime_eol, mime_eol);
195 B64_write_PKCS7(bio, p7);
196 BIO_printf(bio,"%s------%s--%s%s", mime_eol, bound,
197 mime_eol, mime_eol);
198 return 1;
199 }
200
201 /* Determine smime-type header */
202
203 if (PKCS7_type_is_enveloped(p7))
204 msg_type = "enveloped-data";
205 else if (PKCS7_type_is_signed(p7))
206 {
207 /* If we have any signers it is signed-data othewise
208 * certs-only.
209 */
210 STACK_OF(PKCS7_SIGNER_INFO) *sinfos;
211 sinfos = PKCS7_get_signer_info(p7);
212 if (sk_PKCS7_SIGNER_INFO_num(sinfos) > 0)
213 msg_type = "signed-data";
214 else
215 msg_type = "certs-only";
216 }
217 /* MIME headers */
218 BIO_printf(bio, "MIME-Version: 1.0%s", mime_eol);
219 BIO_printf(bio, "Content-Disposition: attachment;");
220 BIO_printf(bio, " filename=\"smime.p7m\"%s", mime_eol);
221 BIO_printf(bio, "Content-Type: %smime;", mime_prefix);
222 if (msg_type)
223 BIO_printf(bio, " smime-type=%s;", msg_type);
224 BIO_printf(bio, " name=\"smime.p7m\"%s", mime_eol);
225 BIO_printf(bio, "Content-Transfer-Encoding: base64%s%s",
226 mime_eol, mime_eol);
227 B64_write_PKCS7(bio, p7);
228 BIO_printf(bio, "%s", mime_eol);
229 return 1;
230}
231
232/* Handle output of PKCS#7 data */
233
234
235static int pkcs7_output_data(BIO *out, BIO *data, PKCS7 *p7, int flags)
236 { 78 {
237 BIO *tmpbio, *p7bio; 79 STACK_OF(X509_ALGOR) *mdalgs;
238 80 int ctype_nid = OBJ_obj2nid(p7->type);
239 if (!(flags & PKCS7_STREAM)) 81 if (ctype_nid == NID_pkcs7_signed)
240 { 82 mdalgs = p7->d.sign->md_algs;
241 SMIME_crlf_copy(data, out, flags); 83 else
242 return 1; 84 mdalgs = NULL;
243 }
244
245 /* Partial sign operation */
246
247 /* Initialize sign operation */
248 p7bio = PKCS7_dataInit(p7, out);
249
250 /* Copy data across, computing digests etc */
251 SMIME_crlf_copy(data, p7bio, flags);
252
253 /* Must be detached */
254 PKCS7_set_detached(p7, 1);
255
256 /* Finalize signatures */
257 PKCS7_dataFinal(p7, p7bio);
258
259 /* Now remove any digests prepended to the BIO */
260 85
261 while (p7bio != out) 86 flags ^= SMIME_OLDMIME;
262 {
263 tmpbio = BIO_pop(p7bio);
264 BIO_free(p7bio);
265 p7bio = tmpbio;
266 }
267 87
268 return 1;
269 88
89 return SMIME_write_ASN1(bio, (ASN1_VALUE *)p7, data, flags,
90 ctype_nid, NID_undef, mdalgs,
91 ASN1_ITEM_rptr(PKCS7));
270 } 92 }
271 93
272/* SMIME reader: handle multipart/signed and opaque signing.
273 * in multipart case the content is placed in a memory BIO
274 * pointed to by "bcont". In opaque this is set to NULL
275 */
276
277PKCS7 *SMIME_read_PKCS7(BIO *bio, BIO **bcont) 94PKCS7 *SMIME_read_PKCS7(BIO *bio, BIO **bcont)
278{
279 BIO *p7in;
280 STACK_OF(MIME_HEADER) *headers = NULL;
281 STACK_OF(BIO) *parts = NULL;
282 MIME_HEADER *hdr;
283 MIME_PARAM *prm;
284 PKCS7 *p7;
285 int ret;
286
287 if(bcont) *bcont = NULL;
288
289 if (!(headers = mime_parse_hdr(bio))) {
290 PKCS7err(PKCS7_F_SMIME_READ_PKCS7,PKCS7_R_MIME_PARSE_ERROR);
291 return NULL;
292 }
293
294 if(!(hdr = mime_hdr_find(headers, "content-type")) || !hdr->value) {
295 sk_MIME_HEADER_pop_free(headers, mime_hdr_free);
296 PKCS7err(PKCS7_F_SMIME_READ_PKCS7, PKCS7_R_NO_CONTENT_TYPE);
297 return NULL;
298 }
299
300 /* Handle multipart/signed */
301
302 if(!strcmp(hdr->value, "multipart/signed")) {
303 /* Split into two parts */
304 prm = mime_param_find(hdr, "boundary");
305 if(!prm || !prm->param_value) {
306 sk_MIME_HEADER_pop_free(headers, mime_hdr_free);
307 PKCS7err(PKCS7_F_SMIME_READ_PKCS7, PKCS7_R_NO_MULTIPART_BOUNDARY);
308 return NULL;
309 }
310 ret = multi_split(bio, prm->param_value, &parts);
311 sk_MIME_HEADER_pop_free(headers, mime_hdr_free);
312 if(!ret || (sk_BIO_num(parts) != 2) ) {
313 PKCS7err(PKCS7_F_SMIME_READ_PKCS7, PKCS7_R_NO_MULTIPART_BODY_FAILURE);
314 sk_BIO_pop_free(parts, BIO_vfree);
315 return NULL;
316 }
317
318 /* Parse the signature piece */
319 p7in = sk_BIO_value(parts, 1);
320
321 if (!(headers = mime_parse_hdr(p7in))) {
322 PKCS7err(PKCS7_F_SMIME_READ_PKCS7,PKCS7_R_MIME_SIG_PARSE_ERROR);
323 sk_BIO_pop_free(parts, BIO_vfree);
324 return NULL;
325 }
326
327 /* Get content type */
328
329 if(!(hdr = mime_hdr_find(headers, "content-type")) ||
330 !hdr->value) {
331 sk_MIME_HEADER_pop_free(headers, mime_hdr_free);
332 PKCS7err(PKCS7_F_SMIME_READ_PKCS7, PKCS7_R_NO_SIG_CONTENT_TYPE);
333 return NULL;
334 }
335
336 if(strcmp(hdr->value, "application/x-pkcs7-signature") &&
337 strcmp(hdr->value, "application/pkcs7-signature")) {
338 sk_MIME_HEADER_pop_free(headers, mime_hdr_free);
339 PKCS7err(PKCS7_F_SMIME_READ_PKCS7,PKCS7_R_SIG_INVALID_MIME_TYPE);
340 ERR_add_error_data(2, "type: ", hdr->value);
341 sk_BIO_pop_free(parts, BIO_vfree);
342 return NULL;
343 }
344 sk_MIME_HEADER_pop_free(headers, mime_hdr_free);
345 /* Read in PKCS#7 */
346 if(!(p7 = B64_read_PKCS7(p7in))) {
347 PKCS7err(PKCS7_F_SMIME_READ_PKCS7,PKCS7_R_PKCS7_SIG_PARSE_ERROR);
348 sk_BIO_pop_free(parts, BIO_vfree);
349 return NULL;
350 }
351
352 if(bcont) {
353 *bcont = sk_BIO_value(parts, 0);
354 BIO_free(p7in);
355 sk_BIO_free(parts);
356 } else sk_BIO_pop_free(parts, BIO_vfree);
357 return p7;
358 }
359
360 /* OK, if not multipart/signed try opaque signature */
361
362 if (strcmp (hdr->value, "application/x-pkcs7-mime") &&
363 strcmp (hdr->value, "application/pkcs7-mime")) {
364 PKCS7err(PKCS7_F_SMIME_READ_PKCS7,PKCS7_R_INVALID_MIME_TYPE);
365 ERR_add_error_data(2, "type: ", hdr->value);
366 sk_MIME_HEADER_pop_free(headers, mime_hdr_free);
367 return NULL;
368 }
369
370 sk_MIME_HEADER_pop_free(headers, mime_hdr_free);
371
372 if(!(p7 = B64_read_PKCS7(bio))) {
373 PKCS7err(PKCS7_F_SMIME_READ_PKCS7, PKCS7_R_PKCS7_PARSE_ERROR);
374 return NULL;
375 }
376 return p7;
377
378}
379
380/* Split a multipart/XXX message body into component parts: result is
381 * canonical parts in a STACK of bios
382 */
383
384static int multi_split(BIO *bio, char *bound, STACK_OF(BIO) **ret)
385{
386 char linebuf[MAX_SMLEN];
387 int len, blen;
388 int eol = 0, next_eol = 0;
389 BIO *bpart = NULL;
390 STACK_OF(BIO) *parts;
391 char state, part, first;
392
393 blen = strlen(bound);
394 part = 0;
395 state = 0;
396 first = 1;
397 parts = sk_BIO_new_null();
398 *ret = parts;
399 while ((len = BIO_gets(bio, linebuf, MAX_SMLEN)) > 0) {
400 state = mime_bound_check(linebuf, len, bound, blen);
401 if(state == 1) {
402 first = 1;
403 part++;
404 } else if(state == 2) {
405 sk_BIO_push(parts, bpart);
406 return 1;
407 } else if(part) {
408 /* Strip CR+LF from linebuf */
409 next_eol = strip_eol(linebuf, &len);
410 if(first) {
411 first = 0;
412 if(bpart) sk_BIO_push(parts, bpart);
413 bpart = BIO_new(BIO_s_mem());
414 BIO_set_mem_eof_return(bpart, 0);
415 } else if (eol)
416 BIO_write(bpart, "\r\n", 2);
417 eol = next_eol;
418 if (len)
419 BIO_write(bpart, linebuf, len);
420 }
421 }
422 return 0;
423}
424
425/* This is the big one: parse MIME header lines up to message body */
426
427#define MIME_INVALID 0
428#define MIME_START 1
429#define MIME_TYPE 2
430#define MIME_NAME 3
431#define MIME_VALUE 4
432#define MIME_QUOTE 5
433#define MIME_COMMENT 6
434
435
436static STACK_OF(MIME_HEADER) *mime_parse_hdr(BIO *bio)
437{
438 char *p, *q, c;
439 char *ntmp;
440 char linebuf[MAX_SMLEN];
441 MIME_HEADER *mhdr = NULL;
442 STACK_OF(MIME_HEADER) *headers;
443 int len, state, save_state = 0;
444
445 headers = sk_MIME_HEADER_new(mime_hdr_cmp);
446 while ((len = BIO_gets(bio, linebuf, MAX_SMLEN)) > 0) {
447 /* If whitespace at line start then continuation line */
448 if(mhdr && isspace((unsigned char)linebuf[0])) state = MIME_NAME;
449 else state = MIME_START;
450 ntmp = NULL;
451 /* Go through all characters */
452 for(p = linebuf, q = linebuf; (c = *p) && (c!='\r') && (c!='\n'); p++) {
453
454 /* State machine to handle MIME headers
455 * if this looks horrible that's because it *is*
456 */
457
458 switch(state) {
459 case MIME_START:
460 if(c == ':') {
461 state = MIME_TYPE;
462 *p = 0;
463 ntmp = strip_ends(q);
464 q = p + 1;
465 }
466 break;
467
468 case MIME_TYPE:
469 if(c == ';') {
470 mime_debug("Found End Value\n");
471 *p = 0;
472 mhdr = mime_hdr_new(ntmp, strip_ends(q));
473 sk_MIME_HEADER_push(headers, mhdr);
474 ntmp = NULL;
475 q = p + 1;
476 state = MIME_NAME;
477 } else if(c == '(') {
478 save_state = state;
479 state = MIME_COMMENT;
480 }
481 break;
482
483 case MIME_COMMENT:
484 if(c == ')') {
485 state = save_state;
486 }
487 break;
488
489 case MIME_NAME:
490 if(c == '=') {
491 state = MIME_VALUE;
492 *p = 0;
493 ntmp = strip_ends(q);
494 q = p + 1;
495 }
496 break ;
497
498 case MIME_VALUE:
499 if(c == ';') {
500 state = MIME_NAME;
501 *p = 0;
502 mime_hdr_addparam(mhdr, ntmp, strip_ends(q));
503 ntmp = NULL;
504 q = p + 1;
505 } else if (c == '"') {
506 mime_debug("Found Quote\n");
507 state = MIME_QUOTE;
508 } else if(c == '(') {
509 save_state = state;
510 state = MIME_COMMENT;
511 }
512 break;
513
514 case MIME_QUOTE:
515 if(c == '"') {
516 mime_debug("Found Match Quote\n");
517 state = MIME_VALUE;
518 }
519 break;
520 }
521 }
522
523 if(state == MIME_TYPE) {
524 mhdr = mime_hdr_new(ntmp, strip_ends(q));
525 sk_MIME_HEADER_push(headers, mhdr);
526 } else if(state == MIME_VALUE)
527 mime_hdr_addparam(mhdr, ntmp, strip_ends(q));
528 if(p == linebuf) break; /* Blank line means end of headers */
529}
530
531return headers;
532
533}
534
535static char *strip_ends(char *name)
536{
537 return strip_end(strip_start(name));
538}
539
540/* Strip a parameter of whitespace from start of param */
541static char *strip_start(char *name)
542{
543 char *p, c;
544 /* Look for first non white space or quote */
545 for(p = name; (c = *p) ;p++) {
546 if(c == '"') {
547 /* Next char is start of string if non null */
548 if(p[1]) return p + 1;
549 /* Else null string */
550 return NULL;
551 }
552 if(!isspace((unsigned char)c)) return p;
553 }
554 return NULL;
555}
556
557/* As above but strip from end of string : maybe should handle brackets? */
558static char *strip_end(char *name)
559{
560 char *p, c;
561 if(!name) return NULL;
562 /* Look for first non white space or quote */
563 for(p = name + strlen(name) - 1; p >= name ;p--) {
564 c = *p;
565 if(c == '"') {
566 if(p - 1 == name) return NULL;
567 *p = 0;
568 return name;
569 }
570 if(isspace((unsigned char)c)) *p = 0;
571 else return name;
572 }
573 return NULL;
574}
575
576static MIME_HEADER *mime_hdr_new(char *name, char *value)
577{
578 MIME_HEADER *mhdr;
579 char *tmpname, *tmpval, *p;
580 int c;
581 if(name) {
582 if(!(tmpname = BUF_strdup(name))) return NULL;
583 for(p = tmpname ; *p; p++) {
584 c = *p;
585 if(isupper(c)) {
586 c = tolower(c);
587 *p = c;
588 }
589 }
590 } else tmpname = NULL;
591 if(value) {
592 if(!(tmpval = BUF_strdup(value))) return NULL;
593 for(p = tmpval ; *p; p++) {
594 c = *p;
595 if(isupper(c)) {
596 c = tolower(c);
597 *p = c;
598 }
599 }
600 } else tmpval = NULL;
601 mhdr = (MIME_HEADER *) OPENSSL_malloc(sizeof(MIME_HEADER));
602 if(!mhdr) return NULL;
603 mhdr->name = tmpname;
604 mhdr->value = tmpval;
605 if(!(mhdr->params = sk_MIME_PARAM_new(mime_param_cmp))) return NULL;
606 return mhdr;
607}
608
609static int mime_hdr_addparam(MIME_HEADER *mhdr, char *name, char *value)
610{
611 char *tmpname, *tmpval, *p;
612 int c;
613 MIME_PARAM *mparam;
614 if(name) {
615 tmpname = BUF_strdup(name);
616 if(!tmpname) return 0;
617 for(p = tmpname ; *p; p++) {
618 c = *p;
619 if(isupper(c)) {
620 c = tolower(c);
621 *p = c;
622 }
623 }
624 } else tmpname = NULL;
625 if(value) {
626 tmpval = BUF_strdup(value);
627 if(!tmpval) return 0;
628 } else tmpval = NULL;
629 /* Parameter values are case sensitive so leave as is */
630 mparam = (MIME_PARAM *) OPENSSL_malloc(sizeof(MIME_PARAM));
631 if(!mparam) return 0;
632 mparam->param_name = tmpname;
633 mparam->param_value = tmpval;
634 sk_MIME_PARAM_push(mhdr->params, mparam);
635 return 1;
636}
637
638static int mime_hdr_cmp(const MIME_HEADER * const *a,
639 const MIME_HEADER * const *b)
640{
641 return(strcmp((*a)->name, (*b)->name));
642}
643
644static int mime_param_cmp(const MIME_PARAM * const *a,
645 const MIME_PARAM * const *b)
646{
647 return(strcmp((*a)->param_name, (*b)->param_name));
648}
649
650/* Find a header with a given name (if possible) */
651
652static MIME_HEADER *mime_hdr_find(STACK_OF(MIME_HEADER) *hdrs, char *name)
653{
654 MIME_HEADER htmp;
655 int idx;
656 htmp.name = name;
657 idx = sk_MIME_HEADER_find(hdrs, &htmp);
658 if(idx < 0) return NULL;
659 return sk_MIME_HEADER_value(hdrs, idx);
660}
661
662static MIME_PARAM *mime_param_find(MIME_HEADER *hdr, char *name)
663{
664 MIME_PARAM param;
665 int idx;
666 param.param_name = name;
667 idx = sk_MIME_PARAM_find(hdr->params, &param);
668 if(idx < 0) return NULL;
669 return sk_MIME_PARAM_value(hdr->params, idx);
670}
671
672static void mime_hdr_free(MIME_HEADER *hdr)
673{
674 if(hdr->name) OPENSSL_free(hdr->name);
675 if(hdr->value) OPENSSL_free(hdr->value);
676 if(hdr->params) sk_MIME_PARAM_pop_free(hdr->params, mime_param_free);
677 OPENSSL_free(hdr);
678}
679
680static void mime_param_free(MIME_PARAM *param)
681{
682 if(param->param_name) OPENSSL_free(param->param_name);
683 if(param->param_value) OPENSSL_free(param->param_value);
684 OPENSSL_free(param);
685}
686
687/* Check for a multipart boundary. Returns:
688 * 0 : no boundary
689 * 1 : part boundary
690 * 2 : final boundary
691 */
692static int mime_bound_check(char *line, int linelen, char *bound, int blen)
693{
694 if(linelen == -1) linelen = strlen(line);
695 if(blen == -1) blen = strlen(bound);
696 /* Quickly eliminate if line length too short */
697 if(blen + 2 > linelen) return 0;
698 /* Check for part boundary */
699 if(!strncmp(line, "--", 2) && !strncmp(line + 2, bound, blen)) {
700 if(!strncmp(line + blen + 2, "--", 2)) return 2;
701 else return 1;
702 }
703 return 0;
704}
705
706static int strip_eol(char *linebuf, int *plen)
707 { 95 {
708 int len = *plen; 96 return (PKCS7 *)SMIME_read_ASN1(bio, bcont, ASN1_ITEM_rptr(PKCS7));
709 char *p, c;
710 int is_eol = 0;
711 p = linebuf + len - 1;
712 for (p = linebuf + len - 1; len > 0; len--, p--)
713 {
714 c = *p;
715 if (c == '\n')
716 is_eol = 1;
717 else if (c != '\r')
718 break;
719 }
720 *plen = len;
721 return is_eol;
722 } 97 }
diff --git a/src/lib/libcrypto/pkcs7/pk7_smime.c b/src/lib/libcrypto/pkcs7/pk7_smime.c
index fd18ec3d95..86742d0dcd 100644
--- a/src/lib/libcrypto/pkcs7/pk7_smime.c
+++ b/src/lib/libcrypto/pkcs7/pk7_smime.c
@@ -63,24 +63,19 @@
63#include <openssl/x509.h> 63#include <openssl/x509.h>
64#include <openssl/x509v3.h> 64#include <openssl/x509v3.h>
65 65
66static int pkcs7_copy_existing_digest(PKCS7 *p7, PKCS7_SIGNER_INFO *si);
67
66PKCS7 *PKCS7_sign(X509 *signcert, EVP_PKEY *pkey, STACK_OF(X509) *certs, 68PKCS7 *PKCS7_sign(X509 *signcert, EVP_PKEY *pkey, STACK_OF(X509) *certs,
67 BIO *data, int flags) 69 BIO *data, int flags)
68{ 70{
69 PKCS7 *p7 = NULL; 71 PKCS7 *p7;
70 PKCS7_SIGNER_INFO *si;
71 BIO *p7bio = NULL;
72 STACK_OF(X509_ALGOR) *smcap = NULL;
73 int i; 72 int i;
74 73
75 if(!X509_check_private_key(signcert, pkey)) { 74 if(!(p7 = PKCS7_new()))
76 PKCS7err(PKCS7_F_PKCS7_SIGN,PKCS7_R_PRIVATE_KEY_DOES_NOT_MATCH_CERTIFICATE); 75 {
77 return NULL;
78 }
79
80 if(!(p7 = PKCS7_new())) {
81 PKCS7err(PKCS7_F_PKCS7_SIGN,ERR_R_MALLOC_FAILURE); 76 PKCS7err(PKCS7_F_PKCS7_SIGN,ERR_R_MALLOC_FAILURE);
82 return NULL; 77 return NULL;
83 } 78 }
84 79
85 if (!PKCS7_set_type(p7, NID_pkcs7_signed)) 80 if (!PKCS7_set_type(p7, NID_pkcs7_signed))
86 goto err; 81 goto err;
@@ -88,82 +83,185 @@ PKCS7 *PKCS7_sign(X509 *signcert, EVP_PKEY *pkey, STACK_OF(X509) *certs,
88 if (!PKCS7_content_new(p7, NID_pkcs7_data)) 83 if (!PKCS7_content_new(p7, NID_pkcs7_data))
89 goto err; 84 goto err;
90 85
91 if (!(si = PKCS7_add_signature(p7,signcert,pkey,EVP_sha1()))) { 86 if (pkey && !PKCS7_sign_add_signer(p7, signcert, pkey, NULL, flags))
92 PKCS7err(PKCS7_F_PKCS7_SIGN,PKCS7_R_PKCS7_ADD_SIGNATURE_ERROR); 87 {
88 PKCS7err(PKCS7_F_PKCS7_SIGN,PKCS7_R_PKCS7_ADD_SIGNER_ERROR);
93 goto err; 89 goto err;
94 } 90 }
95 91
96 if(!(flags & PKCS7_NOCERTS)) { 92 if(!(flags & PKCS7_NOCERTS))
97 if (!PKCS7_add_certificate(p7, signcert)) 93 {
98 goto err; 94 for(i = 0; i < sk_X509_num(certs); i++)
99 if(certs) for(i = 0; i < sk_X509_num(certs); i++) 95 {
100 if (!PKCS7_add_certificate(p7, sk_X509_value(certs, i))) 96 if (!PKCS7_add_certificate(p7, sk_X509_value(certs, i)))
101 goto err; 97 goto err;
102 } 98 }
99 }
103 100
104 if(!(flags & PKCS7_NOATTR)) { 101 if(flags & PKCS7_DETACHED)
105 if (!PKCS7_add_signed_attribute(si, NID_pkcs9_contentType, 102 PKCS7_set_detached(p7, 1);
106 V_ASN1_OBJECT, OBJ_nid2obj(NID_pkcs7_data))) 103
107 goto err; 104 if (flags & (PKCS7_STREAM|PKCS7_PARTIAL))
108 /* Add SMIMECapabilities */ 105 return p7;
109 if(!(flags & PKCS7_NOSMIMECAP)) 106
107 if (PKCS7_final(p7, data, flags))
108 return p7;
109
110 err:
111 PKCS7_free(p7);
112 return NULL;
113}
114
115int PKCS7_final(PKCS7 *p7, BIO *data, int flags)
116 {
117 BIO *p7bio;
118 int ret = 0;
119 if (!(p7bio = PKCS7_dataInit(p7, NULL)))
110 { 120 {
111 if(!(smcap = sk_X509_ALGOR_new_null())) { 121 PKCS7err(PKCS7_F_PKCS7_FINAL,ERR_R_MALLOC_FAILURE);
112 PKCS7err(PKCS7_F_PKCS7_SIGN,ERR_R_MALLOC_FAILURE); 122 return 0;
113 goto err;
114 }
115#ifndef OPENSSL_NO_DES
116 if (!PKCS7_simple_smimecap (smcap, NID_des_ede3_cbc, -1))
117 goto err;
118#endif
119#ifndef OPENSSL_NO_RC2
120 if (!PKCS7_simple_smimecap (smcap, NID_rc2_cbc, 128))
121 goto err;
122 if (!PKCS7_simple_smimecap (smcap, NID_rc2_cbc, 64))
123 goto err;
124#endif
125#ifndef OPENSSL_NO_DES
126 if (!PKCS7_simple_smimecap (smcap, NID_des_cbc, -1))
127 goto err;
128#endif
129#ifndef OPENSSL_NO_RC2
130 if (!PKCS7_simple_smimecap (smcap, NID_rc2_cbc, 40))
131 goto err;
132#endif
133 if (!PKCS7_add_attrib_smimecap (si, smcap))
134 goto err;
135 sk_X509_ALGOR_pop_free(smcap, X509_ALGOR_free);
136 smcap = NULL;
137 } 123 }
138 }
139 124
140 if(flags & PKCS7_DETACHED)PKCS7_set_detached(p7, 1); 125 SMIME_crlf_copy(data, p7bio, flags);
141 126
142 if (flags & PKCS7_STREAM) 127 (void)BIO_flush(p7bio);
143 return p7;
144 128
145 129
146 if (!(p7bio = PKCS7_dataInit(p7, NULL))) { 130 if (!PKCS7_dataFinal(p7,p7bio))
147 PKCS7err(PKCS7_F_PKCS7_SIGN,ERR_R_MALLOC_FAILURE); 131 {
132 PKCS7err(PKCS7_F_PKCS7_FINAL,PKCS7_R_PKCS7_DATASIGN);
148 goto err; 133 goto err;
134 }
135
136 ret = 1;
137
138 err:
139 BIO_free_all(p7bio);
140
141 return ret;
142
149 } 143 }
150 144
151 SMIME_crlf_copy(data, p7bio, flags); 145/* Check to see if a cipher exists and if so add S/MIME capabilities */
152 146
147static int add_cipher_smcap(STACK_OF(X509_ALGOR) *sk, int nid, int arg)
148 {
149 if (EVP_get_cipherbynid(nid))
150 return PKCS7_simple_smimecap(sk, nid, arg);
151 return 1;
152 }
153 153
154 if (!PKCS7_dataFinal(p7,p7bio)) { 154static int add_digest_smcap(STACK_OF(X509_ALGOR) *sk, int nid, int arg)
155 PKCS7err(PKCS7_F_PKCS7_SIGN,PKCS7_R_PKCS7_DATASIGN); 155 {
156 goto err; 156 if (EVP_get_digestbynid(nid))
157 return PKCS7_simple_smimecap(sk, nid, arg);
158 return 1;
157 } 159 }
158 160
159 BIO_free_all(p7bio); 161PKCS7_SIGNER_INFO *PKCS7_sign_add_signer(PKCS7 *p7, X509 *signcert,
160 return p7; 162 EVP_PKEY *pkey, const EVP_MD *md,
161err: 163 int flags)
162 sk_X509_ALGOR_pop_free(smcap, X509_ALGOR_free); 164 {
163 BIO_free_all(p7bio); 165 PKCS7_SIGNER_INFO *si = NULL;
164 PKCS7_free(p7); 166 STACK_OF(X509_ALGOR) *smcap = NULL;
167 if(!X509_check_private_key(signcert, pkey))
168 {
169 PKCS7err(PKCS7_F_PKCS7_SIGN_ADD_SIGNER,
170 PKCS7_R_PRIVATE_KEY_DOES_NOT_MATCH_CERTIFICATE);
171 return NULL;
172 }
173
174 if (!(si = PKCS7_add_signature(p7,signcert,pkey, md)))
175 {
176 PKCS7err(PKCS7_F_PKCS7_SIGN_ADD_SIGNER,
177 PKCS7_R_PKCS7_ADD_SIGNATURE_ERROR);
178 return NULL;
179 }
180
181 if(!(flags & PKCS7_NOCERTS))
182 {
183 if (!PKCS7_add_certificate(p7, signcert))
184 goto err;
185 }
186
187 if(!(flags & PKCS7_NOATTR))
188 {
189 if (!PKCS7_add_attrib_content_type(si, NULL))
190 goto err;
191 /* Add SMIMECapabilities */
192 if(!(flags & PKCS7_NOSMIMECAP))
193 {
194 if(!(smcap = sk_X509_ALGOR_new_null()))
195 {
196 PKCS7err(PKCS7_F_PKCS7_SIGN_ADD_SIGNER,
197 ERR_R_MALLOC_FAILURE);
198 goto err;
199 }
200 if (!add_cipher_smcap(smcap, NID_aes_256_cbc, -1)
201 || !add_digest_smcap(smcap, NID_id_GostR3411_94, -1)
202 || !add_cipher_smcap(smcap, NID_id_Gost28147_89, -1)
203 || !add_cipher_smcap(smcap, NID_aes_192_cbc, -1)
204 || !add_cipher_smcap(smcap, NID_aes_128_cbc, -1)
205 || !add_cipher_smcap(smcap, NID_des_ede3_cbc, -1)
206 || !add_cipher_smcap(smcap, NID_rc2_cbc, 128)
207 || !add_cipher_smcap(smcap, NID_rc2_cbc, 64)
208 || !add_cipher_smcap(smcap, NID_des_cbc, -1)
209 || !add_cipher_smcap(smcap, NID_rc2_cbc, 40)
210 || !PKCS7_add_attrib_smimecap (si, smcap))
211 goto err;
212 sk_X509_ALGOR_pop_free(smcap, X509_ALGOR_free);
213 smcap = NULL;
214 }
215 if (flags & PKCS7_REUSE_DIGEST)
216 {
217 if (!pkcs7_copy_existing_digest(p7, si))
218 goto err;
219 if (!(flags & PKCS7_PARTIAL) &&
220 !PKCS7_SIGNER_INFO_sign(si))
221 goto err;
222 }
223 }
224 return si;
225 err:
226 if (smcap)
227 sk_X509_ALGOR_pop_free(smcap, X509_ALGOR_free);
165 return NULL; 228 return NULL;
166} 229 }
230
231/* Search for a digest matching SignerInfo digest type and if found
232 * copy across.
233 */
234
235static int pkcs7_copy_existing_digest(PKCS7 *p7, PKCS7_SIGNER_INFO *si)
236 {
237 int i;
238 STACK_OF(PKCS7_SIGNER_INFO) *sinfos;
239 PKCS7_SIGNER_INFO *sitmp;
240 ASN1_OCTET_STRING *osdig = NULL;
241 sinfos = PKCS7_get_signer_info(p7);
242 for (i = 0; i < sk_PKCS7_SIGNER_INFO_num(sinfos); i++)
243 {
244 sitmp = sk_PKCS7_SIGNER_INFO_value(sinfos, i);
245 if (si == sitmp)
246 break;
247 if (sk_X509_ATTRIBUTE_num(sitmp->auth_attr) <= 0)
248 continue;
249 if (!OBJ_cmp(si->digest_alg->algorithm,
250 sitmp->digest_alg->algorithm))
251 {
252 osdig = PKCS7_digest_from_attributes(sitmp->auth_attr);
253 break;
254 }
255
256 }
257
258 if (osdig)
259 return PKCS7_add1_attrib_digest(si, osdig->data, osdig->length);
260
261 PKCS7err(PKCS7_F_PKCS7_COPY_EXISTING_DIGEST,
262 PKCS7_R_NO_MATCHING_DIGEST_TYPE_FOUND);
263 return 0;
264 }
167 265
168int PKCS7_verify(PKCS7 *p7, STACK_OF(X509) *certs, X509_STORE *store, 266int PKCS7_verify(PKCS7 *p7, STACK_OF(X509) *certs, X509_STORE *store,
169 BIO *indata, BIO *out, int flags) 267 BIO *indata, BIO *out, int flags)
@@ -354,7 +452,7 @@ STACK_OF(X509) *PKCS7_get0_signers(PKCS7 *p7, STACK_OF(X509) *certs, int flags)
354 452
355 if(sk_PKCS7_SIGNER_INFO_num(sinfos) <= 0) { 453 if(sk_PKCS7_SIGNER_INFO_num(sinfos) <= 0) {
356 PKCS7err(PKCS7_F_PKCS7_GET0_SIGNERS,PKCS7_R_NO_SIGNERS); 454 PKCS7err(PKCS7_F_PKCS7_GET0_SIGNERS,PKCS7_R_NO_SIGNERS);
357 return NULL; 455 return 0;
358 } 456 }
359 457
360 if(!(signers = sk_X509_new_null())) { 458 if(!(signers = sk_X509_new_null())) {
@@ -377,12 +475,12 @@ STACK_OF(X509) *PKCS7_get0_signers(PKCS7 *p7, STACK_OF(X509) *certs, int flags)
377 if (!signer) { 475 if (!signer) {
378 PKCS7err(PKCS7_F_PKCS7_GET0_SIGNERS,PKCS7_R_SIGNER_CERTIFICATE_NOT_FOUND); 476 PKCS7err(PKCS7_F_PKCS7_GET0_SIGNERS,PKCS7_R_SIGNER_CERTIFICATE_NOT_FOUND);
379 sk_X509_free(signers); 477 sk_X509_free(signers);
380 return NULL; 478 return 0;
381 } 479 }
382 480
383 if (!sk_X509_push(signers, signer)) { 481 if (!sk_X509_push(signers, signer)) {
384 sk_X509_free(signers); 482 sk_X509_free(signers);
385 return NULL; 483 return NULL;
386 } 484 }
387 } 485 }
388 return signers; 486 return signers;
@@ -405,7 +503,7 @@ PKCS7 *PKCS7_encrypt(STACK_OF(X509) *certs, BIO *in, const EVP_CIPHER *cipher,
405 503
406 if (!PKCS7_set_type(p7, NID_pkcs7_enveloped)) 504 if (!PKCS7_set_type(p7, NID_pkcs7_enveloped))
407 goto err; 505 goto err;
408 if(!PKCS7_set_cipher(p7, cipher)) { 506 if (!PKCS7_set_cipher(p7, cipher)) {
409 PKCS7err(PKCS7_F_PKCS7_ENCRYPT,PKCS7_R_ERROR_SETTING_CIPHER); 507 PKCS7err(PKCS7_F_PKCS7_ENCRYPT,PKCS7_R_ERROR_SETTING_CIPHER);
410 goto err; 508 goto err;
411 } 509 }
@@ -419,22 +517,11 @@ PKCS7 *PKCS7_encrypt(STACK_OF(X509) *certs, BIO *in, const EVP_CIPHER *cipher,
419 } 517 }
420 } 518 }
421 519
422 if(!(p7bio = PKCS7_dataInit(p7, NULL))) { 520 if (flags & PKCS7_STREAM)
423 PKCS7err(PKCS7_F_PKCS7_ENCRYPT,ERR_R_MALLOC_FAILURE); 521 return p7;
424 goto err;
425 }
426
427 SMIME_crlf_copy(in, p7bio, flags);
428
429 (void)BIO_flush(p7bio);
430
431 if (!PKCS7_dataFinal(p7,p7bio)) {
432 PKCS7err(PKCS7_F_PKCS7_ENCRYPT,PKCS7_R_PKCS7_DATAFINAL_ERROR);
433 goto err;
434 }
435 BIO_free_all(p7bio);
436 522
437 return p7; 523 if (PKCS7_final(p7, in, flags))
524 return p7;
438 525
439 err: 526 err:
440 527
diff --git a/src/lib/libcrypto/pkcs7/pkcs7.h b/src/lib/libcrypto/pkcs7/pkcs7.h
index cc092d262d..e4d443193c 100644
--- a/src/lib/libcrypto/pkcs7/pkcs7.h
+++ b/src/lib/libcrypto/pkcs7/pkcs7.h
@@ -232,6 +232,9 @@ DECLARE_PKCS12_STACK_OF(PKCS7)
232#define PKCS7_type_is_signedAndEnveloped(a) \ 232#define PKCS7_type_is_signedAndEnveloped(a) \
233 (OBJ_obj2nid((a)->type) == NID_pkcs7_signedAndEnveloped) 233 (OBJ_obj2nid((a)->type) == NID_pkcs7_signedAndEnveloped)
234#define PKCS7_type_is_data(a) (OBJ_obj2nid((a)->type) == NID_pkcs7_data) 234#define PKCS7_type_is_data(a) (OBJ_obj2nid((a)->type) == NID_pkcs7_data)
235#define PKCS7_type_is_digest(a) (OBJ_obj2nid((a)->type) == NID_pkcs7_digest)
236#define PKCS7_type_is_encrypted(a) \
237 (OBJ_obj2nid((a)->type) == NID_pkcs7_encrypted)
235 238
236#define PKCS7_type_is_digest(a) (OBJ_obj2nid((a)->type) == NID_pkcs7_digest) 239#define PKCS7_type_is_digest(a) (OBJ_obj2nid((a)->type) == NID_pkcs7_digest)
237 240
@@ -242,14 +245,6 @@ DECLARE_PKCS12_STACK_OF(PKCS7)
242 245
243#define PKCS7_is_detached(p7) (PKCS7_type_is_signed(p7) && PKCS7_get_detached(p7)) 246#define PKCS7_is_detached(p7) (PKCS7_type_is_signed(p7) && PKCS7_get_detached(p7))
244 247
245#ifdef SSLEAY_MACROS
246#ifndef PKCS7_ISSUER_AND_SERIAL_digest
247#define PKCS7_ISSUER_AND_SERIAL_digest(data,type,md,len) \
248 ASN1_digest((int (*)())i2d_PKCS7_ISSUER_AND_SERIAL,type,\
249 (char *)data,md,len)
250#endif
251#endif
252
253/* S/MIME related flags */ 248/* S/MIME related flags */
254 249
255#define PKCS7_TEXT 0x1 250#define PKCS7_TEXT 0x1
@@ -266,6 +261,8 @@ DECLARE_PKCS12_STACK_OF(PKCS7)
266#define PKCS7_CRLFEOL 0x800 261#define PKCS7_CRLFEOL 0x800
267#define PKCS7_STREAM 0x1000 262#define PKCS7_STREAM 0x1000
268#define PKCS7_NOCRL 0x2000 263#define PKCS7_NOCRL 0x2000
264#define PKCS7_PARTIAL 0x4000
265#define PKCS7_REUSE_DIGEST 0x8000
269 266
270/* Flags: for compatibility with older code */ 267/* Flags: for compatibility with older code */
271 268
@@ -281,7 +278,6 @@ DECLARE_PKCS12_STACK_OF(PKCS7)
281 278
282DECLARE_ASN1_FUNCTIONS(PKCS7_ISSUER_AND_SERIAL) 279DECLARE_ASN1_FUNCTIONS(PKCS7_ISSUER_AND_SERIAL)
283 280
284#ifndef SSLEAY_MACROS
285int PKCS7_ISSUER_AND_SERIAL_digest(PKCS7_ISSUER_AND_SERIAL *data,const EVP_MD *type, 281int PKCS7_ISSUER_AND_SERIAL_digest(PKCS7_ISSUER_AND_SERIAL *data,const EVP_MD *type,
286 unsigned char *md,unsigned int *len); 282 unsigned char *md,unsigned int *len);
287#ifndef OPENSSL_NO_FP_API 283#ifndef OPENSSL_NO_FP_API
@@ -291,7 +287,8 @@ int i2d_PKCS7_fp(FILE *fp,PKCS7 *p7);
291PKCS7 *PKCS7_dup(PKCS7 *p7); 287PKCS7 *PKCS7_dup(PKCS7 *p7);
292PKCS7 *d2i_PKCS7_bio(BIO *bp,PKCS7 **p7); 288PKCS7 *d2i_PKCS7_bio(BIO *bp,PKCS7 **p7);
293int i2d_PKCS7_bio(BIO *bp,PKCS7 *p7); 289int i2d_PKCS7_bio(BIO *bp,PKCS7 *p7);
294#endif 290int i2d_PKCS7_bio_stream(BIO *out, PKCS7 *p7, BIO *in, int flags);
291int PEM_write_bio_PKCS7_stream(BIO *out, PKCS7 *p7, BIO *in, int flags);
295 292
296DECLARE_ASN1_FUNCTIONS(PKCS7_SIGNER_INFO) 293DECLARE_ASN1_FUNCTIONS(PKCS7_SIGNER_INFO)
297DECLARE_ASN1_FUNCTIONS(PKCS7_RECIP_INFO) 294DECLARE_ASN1_FUNCTIONS(PKCS7_RECIP_INFO)
@@ -307,6 +304,7 @@ DECLARE_ASN1_ITEM(PKCS7_ATTR_SIGN)
307DECLARE_ASN1_ITEM(PKCS7_ATTR_VERIFY) 304DECLARE_ASN1_ITEM(PKCS7_ATTR_VERIFY)
308 305
309DECLARE_ASN1_NDEF_FUNCTION(PKCS7) 306DECLARE_ASN1_NDEF_FUNCTION(PKCS7)
307DECLARE_ASN1_PRINT_FUNCTION(PKCS7)
310 308
311long PKCS7_ctrl(PKCS7 *p7, int cmd, long larg, char *parg); 309long PKCS7_ctrl(PKCS7 *p7, int cmd, long larg, char *parg);
312 310
@@ -315,6 +313,7 @@ int PKCS7_set0_type_other(PKCS7 *p7, int type, ASN1_TYPE *other);
315int PKCS7_set_content(PKCS7 *p7, PKCS7 *p7_data); 313int PKCS7_set_content(PKCS7 *p7, PKCS7 *p7_data);
316int PKCS7_SIGNER_INFO_set(PKCS7_SIGNER_INFO *p7i, X509 *x509, EVP_PKEY *pkey, 314int PKCS7_SIGNER_INFO_set(PKCS7_SIGNER_INFO *p7i, X509 *x509, EVP_PKEY *pkey,
317 const EVP_MD *dgst); 315 const EVP_MD *dgst);
316int PKCS7_SIGNER_INFO_sign(PKCS7_SIGNER_INFO *si);
318int PKCS7_add_signer(PKCS7 *p7, PKCS7_SIGNER_INFO *p7i); 317int PKCS7_add_signer(PKCS7 *p7, PKCS7_SIGNER_INFO *p7i);
319int PKCS7_add_certificate(PKCS7 *p7, X509 *x509); 318int PKCS7_add_certificate(PKCS7 *p7, X509 *x509);
320int PKCS7_add_crl(PKCS7 *p7, X509_CRL *x509); 319int PKCS7_add_crl(PKCS7 *p7, X509_CRL *x509);
@@ -336,9 +335,13 @@ int PKCS7_set_digest(PKCS7 *p7, const EVP_MD *md);
336STACK_OF(PKCS7_SIGNER_INFO) *PKCS7_get_signer_info(PKCS7 *p7); 335STACK_OF(PKCS7_SIGNER_INFO) *PKCS7_get_signer_info(PKCS7 *p7);
337 336
338PKCS7_RECIP_INFO *PKCS7_add_recipient(PKCS7 *p7, X509 *x509); 337PKCS7_RECIP_INFO *PKCS7_add_recipient(PKCS7 *p7, X509 *x509);
338void PKCS7_SIGNER_INFO_get0_algs(PKCS7_SIGNER_INFO *si, EVP_PKEY **pk,
339 X509_ALGOR **pdig, X509_ALGOR **psig);
340void PKCS7_RECIP_INFO_get0_alg(PKCS7_RECIP_INFO *ri, X509_ALGOR **penc);
339int PKCS7_add_recipient_info(PKCS7 *p7, PKCS7_RECIP_INFO *ri); 341int PKCS7_add_recipient_info(PKCS7 *p7, PKCS7_RECIP_INFO *ri);
340int PKCS7_RECIP_INFO_set(PKCS7_RECIP_INFO *p7i, X509 *x509); 342int PKCS7_RECIP_INFO_set(PKCS7_RECIP_INFO *p7i, X509 *x509);
341int PKCS7_set_cipher(PKCS7 *p7, const EVP_CIPHER *cipher); 343int PKCS7_set_cipher(PKCS7 *p7, const EVP_CIPHER *cipher);
344int PKCS7_stream(unsigned char ***boundary, PKCS7 *p7);
342 345
343PKCS7_ISSUER_AND_SERIAL *PKCS7_get_issuer_and_serial(PKCS7 *p7, int idx); 346PKCS7_ISSUER_AND_SERIAL *PKCS7_get_issuer_and_serial(PKCS7 *p7, int idx);
344ASN1_OCTET_STRING *PKCS7_digest_from_attributes(STACK_OF(X509_ATTRIBUTE) *sk); 347ASN1_OCTET_STRING *PKCS7_digest_from_attributes(STACK_OF(X509_ATTRIBUTE) *sk);
@@ -355,6 +358,12 @@ int PKCS7_set_attributes(PKCS7_SIGNER_INFO *p7si,STACK_OF(X509_ATTRIBUTE) *sk);
355 358
356PKCS7 *PKCS7_sign(X509 *signcert, EVP_PKEY *pkey, STACK_OF(X509) *certs, 359PKCS7 *PKCS7_sign(X509 *signcert, EVP_PKEY *pkey, STACK_OF(X509) *certs,
357 BIO *data, int flags); 360 BIO *data, int flags);
361
362PKCS7_SIGNER_INFO *PKCS7_sign_add_signer(PKCS7 *p7,
363 X509 *signcert, EVP_PKEY *pkey, const EVP_MD *md,
364 int flags);
365
366int PKCS7_final(PKCS7 *p7, BIO *data, int flags);
358int PKCS7_verify(PKCS7 *p7, STACK_OF(X509) *certs, X509_STORE *store, 367int PKCS7_verify(PKCS7 *p7, STACK_OF(X509) *certs, X509_STORE *store,
359 BIO *indata, BIO *out, int flags); 368 BIO *indata, BIO *out, int flags);
360STACK_OF(X509) *PKCS7_get0_signers(PKCS7 *p7, STACK_OF(X509) *certs, int flags); 369STACK_OF(X509) *PKCS7_get0_signers(PKCS7 *p7, STACK_OF(X509) *certs, int flags);
@@ -367,10 +376,16 @@ int PKCS7_add_attrib_smimecap(PKCS7_SIGNER_INFO *si,
367STACK_OF(X509_ALGOR) *PKCS7_get_smimecap(PKCS7_SIGNER_INFO *si); 376STACK_OF(X509_ALGOR) *PKCS7_get_smimecap(PKCS7_SIGNER_INFO *si);
368int PKCS7_simple_smimecap(STACK_OF(X509_ALGOR) *sk, int nid, int arg); 377int PKCS7_simple_smimecap(STACK_OF(X509_ALGOR) *sk, int nid, int arg);
369 378
379int PKCS7_add_attrib_content_type(PKCS7_SIGNER_INFO *si, ASN1_OBJECT *coid);
380int PKCS7_add0_attrib_signing_time(PKCS7_SIGNER_INFO *si, ASN1_TIME *t);
381int PKCS7_add1_attrib_digest(PKCS7_SIGNER_INFO *si,
382 const unsigned char *md, int mdlen);
383
370int SMIME_write_PKCS7(BIO *bio, PKCS7 *p7, BIO *data, int flags); 384int SMIME_write_PKCS7(BIO *bio, PKCS7 *p7, BIO *data, int flags);
371PKCS7 *SMIME_read_PKCS7(BIO *bio, BIO **bcont); 385PKCS7 *SMIME_read_PKCS7(BIO *bio, BIO **bcont);
372int SMIME_crlf_copy(BIO *in, BIO *out, int flags); 386
373int SMIME_text(BIO *in, BIO *out); 387BIO *BIO_new_PKCS7(BIO *out, PKCS7 *p7);
388
374 389
375/* BEGIN ERROR CODES */ 390/* BEGIN ERROR CODES */
376/* The following lines are auto generated by the script mkerr.pl. Any changes 391/* The following lines are auto generated by the script mkerr.pl. Any changes
@@ -383,12 +398,17 @@ void ERR_load_PKCS7_strings(void);
383/* Function codes. */ 398/* Function codes. */
384#define PKCS7_F_B64_READ_PKCS7 120 399#define PKCS7_F_B64_READ_PKCS7 120
385#define PKCS7_F_B64_WRITE_PKCS7 121 400#define PKCS7_F_B64_WRITE_PKCS7 121
401#define PKCS7_F_DO_PKCS7_SIGNED_ATTRIB 136
402#define PKCS7_F_I2D_PKCS7_BIO_STREAM 140
403#define PKCS7_F_PKCS7_ADD0_ATTRIB_SIGNING_TIME 135
386#define PKCS7_F_PKCS7_ADD_ATTRIB_SMIMECAP 118 404#define PKCS7_F_PKCS7_ADD_ATTRIB_SMIMECAP 118
387#define PKCS7_F_PKCS7_ADD_CERTIFICATE 100 405#define PKCS7_F_PKCS7_ADD_CERTIFICATE 100
388#define PKCS7_F_PKCS7_ADD_CRL 101 406#define PKCS7_F_PKCS7_ADD_CRL 101
389#define PKCS7_F_PKCS7_ADD_RECIPIENT_INFO 102 407#define PKCS7_F_PKCS7_ADD_RECIPIENT_INFO 102
408#define PKCS7_F_PKCS7_ADD_SIGNATURE 131
390#define PKCS7_F_PKCS7_ADD_SIGNER 103 409#define PKCS7_F_PKCS7_ADD_SIGNER 103
391#define PKCS7_F_PKCS7_BIO_ADD_DIGEST 125 410#define PKCS7_F_PKCS7_BIO_ADD_DIGEST 125
411#define PKCS7_F_PKCS7_COPY_EXISTING_DIGEST 138
392#define PKCS7_F_PKCS7_CTRL 104 412#define PKCS7_F_PKCS7_CTRL 104
393#define PKCS7_F_PKCS7_DATADECODE 112 413#define PKCS7_F_PKCS7_DATADECODE 112
394#define PKCS7_F_PKCS7_DATAFINAL 128 414#define PKCS7_F_PKCS7_DATAFINAL 128
@@ -396,15 +416,22 @@ void ERR_load_PKCS7_strings(void);
396#define PKCS7_F_PKCS7_DATASIGN 106 416#define PKCS7_F_PKCS7_DATASIGN 106
397#define PKCS7_F_PKCS7_DATAVERIFY 107 417#define PKCS7_F_PKCS7_DATAVERIFY 107
398#define PKCS7_F_PKCS7_DECRYPT 114 418#define PKCS7_F_PKCS7_DECRYPT 114
419#define PKCS7_F_PKCS7_DECRYPT_RINFO 133
420#define PKCS7_F_PKCS7_ENCODE_RINFO 132
399#define PKCS7_F_PKCS7_ENCRYPT 115 421#define PKCS7_F_PKCS7_ENCRYPT 115
422#define PKCS7_F_PKCS7_FINAL 134
400#define PKCS7_F_PKCS7_FIND_DIGEST 127 423#define PKCS7_F_PKCS7_FIND_DIGEST 127
401#define PKCS7_F_PKCS7_GET0_SIGNERS 124 424#define PKCS7_F_PKCS7_GET0_SIGNERS 124
425#define PKCS7_F_PKCS7_RECIP_INFO_SET 130
402#define PKCS7_F_PKCS7_SET_CIPHER 108 426#define PKCS7_F_PKCS7_SET_CIPHER 108
403#define PKCS7_F_PKCS7_SET_CONTENT 109 427#define PKCS7_F_PKCS7_SET_CONTENT 109
404#define PKCS7_F_PKCS7_SET_DIGEST 126 428#define PKCS7_F_PKCS7_SET_DIGEST 126
405#define PKCS7_F_PKCS7_SET_TYPE 110 429#define PKCS7_F_PKCS7_SET_TYPE 110
406#define PKCS7_F_PKCS7_SIGN 116 430#define PKCS7_F_PKCS7_SIGN 116
407#define PKCS7_F_PKCS7_SIGNATUREVERIFY 113 431#define PKCS7_F_PKCS7_SIGNATUREVERIFY 113
432#define PKCS7_F_PKCS7_SIGNER_INFO_SET 129
433#define PKCS7_F_PKCS7_SIGNER_INFO_SIGN 139
434#define PKCS7_F_PKCS7_SIGN_ADD_SIGNER 137
408#define PKCS7_F_PKCS7_SIMPLE_SMIMECAP 119 435#define PKCS7_F_PKCS7_SIMPLE_SMIMECAP 119
409#define PKCS7_F_PKCS7_VERIFY 117 436#define PKCS7_F_PKCS7_VERIFY 117
410#define PKCS7_F_SMIME_READ_PKCS7 122 437#define PKCS7_F_SMIME_READ_PKCS7 122
@@ -415,10 +442,13 @@ void ERR_load_PKCS7_strings(void);
415#define PKCS7_R_CIPHER_HAS_NO_OBJECT_IDENTIFIER 144 442#define PKCS7_R_CIPHER_HAS_NO_OBJECT_IDENTIFIER 144
416#define PKCS7_R_CIPHER_NOT_INITIALIZED 116 443#define PKCS7_R_CIPHER_NOT_INITIALIZED 116
417#define PKCS7_R_CONTENT_AND_DATA_PRESENT 118 444#define PKCS7_R_CONTENT_AND_DATA_PRESENT 118
445#define PKCS7_R_CTRL_ERROR 152
418#define PKCS7_R_DECODE_ERROR 130 446#define PKCS7_R_DECODE_ERROR 130
419#define PKCS7_R_DECRYPTED_KEY_IS_WRONG_LENGTH 100 447#define PKCS7_R_DECRYPTED_KEY_IS_WRONG_LENGTH 100
420#define PKCS7_R_DECRYPT_ERROR 119 448#define PKCS7_R_DECRYPT_ERROR 119
421#define PKCS7_R_DIGEST_FAILURE 101 449#define PKCS7_R_DIGEST_FAILURE 101
450#define PKCS7_R_ENCRYPTION_CTRL_FAILURE 149
451#define PKCS7_R_ENCRYPTION_NOT_SUPPORTED_FOR_THIS_KEY_TYPE 150
422#define PKCS7_R_ERROR_ADDING_RECIPIENT 120 452#define PKCS7_R_ERROR_ADDING_RECIPIENT 120
423#define PKCS7_R_ERROR_SETTING_CIPHER 121 453#define PKCS7_R_ERROR_SETTING_CIPHER 121
424#define PKCS7_R_INVALID_MIME_TYPE 131 454#define PKCS7_R_INVALID_MIME_TYPE 131
@@ -429,6 +459,8 @@ void ERR_load_PKCS7_strings(void);
429#define PKCS7_R_MISSING_CERIPEND_INFO 103 459#define PKCS7_R_MISSING_CERIPEND_INFO 103
430#define PKCS7_R_NO_CONTENT 122 460#define PKCS7_R_NO_CONTENT 122
431#define PKCS7_R_NO_CONTENT_TYPE 135 461#define PKCS7_R_NO_CONTENT_TYPE 135
462#define PKCS7_R_NO_DEFAULT_DIGEST 151
463#define PKCS7_R_NO_MATCHING_DIGEST_TYPE_FOUND 154
432#define PKCS7_R_NO_MULTIPART_BODY_FAILURE 136 464#define PKCS7_R_NO_MULTIPART_BODY_FAILURE 136
433#define PKCS7_R_NO_MULTIPART_BOUNDARY 137 465#define PKCS7_R_NO_MULTIPART_BOUNDARY 137
434#define PKCS7_R_NO_RECIPIENT_MATCHES_CERTIFICATE 115 466#define PKCS7_R_NO_RECIPIENT_MATCHES_CERTIFICATE 115
@@ -438,6 +470,7 @@ void ERR_load_PKCS7_strings(void);
438#define PKCS7_R_NO_SIG_CONTENT_TYPE 138 470#define PKCS7_R_NO_SIG_CONTENT_TYPE 138
439#define PKCS7_R_OPERATION_NOT_SUPPORTED_ON_THIS_TYPE 104 471#define PKCS7_R_OPERATION_NOT_SUPPORTED_ON_THIS_TYPE 104
440#define PKCS7_R_PKCS7_ADD_SIGNATURE_ERROR 124 472#define PKCS7_R_PKCS7_ADD_SIGNATURE_ERROR 124
473#define PKCS7_R_PKCS7_ADD_SIGNER_ERROR 153
441#define PKCS7_R_PKCS7_DATAFINAL 126 474#define PKCS7_R_PKCS7_DATAFINAL 126
442#define PKCS7_R_PKCS7_DATAFINAL_ERROR 125 475#define PKCS7_R_PKCS7_DATAFINAL_ERROR 125
443#define PKCS7_R_PKCS7_DATASIGN 145 476#define PKCS7_R_PKCS7_DATASIGN 145
@@ -446,6 +479,8 @@ void ERR_load_PKCS7_strings(void);
446#define PKCS7_R_PRIVATE_KEY_DOES_NOT_MATCH_CERTIFICATE 127 479#define PKCS7_R_PRIVATE_KEY_DOES_NOT_MATCH_CERTIFICATE 127
447#define PKCS7_R_SIGNATURE_FAILURE 105 480#define PKCS7_R_SIGNATURE_FAILURE 105
448#define PKCS7_R_SIGNER_CERTIFICATE_NOT_FOUND 128 481#define PKCS7_R_SIGNER_CERTIFICATE_NOT_FOUND 128
482#define PKCS7_R_SIGNING_CTRL_FAILURE 147
483#define PKCS7_R_SIGNING_NOT_SUPPORTED_FOR_THIS_KEY_TYPE 148
449#define PKCS7_R_SIG_INVALID_MIME_TYPE 141 484#define PKCS7_R_SIG_INVALID_MIME_TYPE 141
450#define PKCS7_R_SMIME_TEXT_ERROR 129 485#define PKCS7_R_SMIME_TEXT_ERROR 129
451#define PKCS7_R_UNABLE_TO_FIND_CERTIFICATE 106 486#define PKCS7_R_UNABLE_TO_FIND_CERTIFICATE 106
diff --git a/src/lib/libcrypto/pkcs7/pkcs7err.c b/src/lib/libcrypto/pkcs7/pkcs7err.c
index c0e3d4cd33..d0af32a265 100644
--- a/src/lib/libcrypto/pkcs7/pkcs7err.c
+++ b/src/lib/libcrypto/pkcs7/pkcs7err.c
@@ -1,6 +1,6 @@
1/* crypto/pkcs7/pkcs7err.c */ 1/* crypto/pkcs7/pkcs7err.c */
2/* ==================================================================== 2/* ====================================================================
3 * Copyright (c) 1999-2005 The OpenSSL Project. All rights reserved. 3 * Copyright (c) 1999-2007 The OpenSSL Project. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
@@ -72,12 +72,17 @@ static ERR_STRING_DATA PKCS7_str_functs[]=
72 { 72 {
73{ERR_FUNC(PKCS7_F_B64_READ_PKCS7), "B64_READ_PKCS7"}, 73{ERR_FUNC(PKCS7_F_B64_READ_PKCS7), "B64_READ_PKCS7"},
74{ERR_FUNC(PKCS7_F_B64_WRITE_PKCS7), "B64_WRITE_PKCS7"}, 74{ERR_FUNC(PKCS7_F_B64_WRITE_PKCS7), "B64_WRITE_PKCS7"},
75{ERR_FUNC(PKCS7_F_DO_PKCS7_SIGNED_ATTRIB), "DO_PKCS7_SIGNED_ATTRIB"},
76{ERR_FUNC(PKCS7_F_I2D_PKCS7_BIO_STREAM), "i2d_PKCS7_bio_stream"},
77{ERR_FUNC(PKCS7_F_PKCS7_ADD0_ATTRIB_SIGNING_TIME), "PKCS7_add0_attrib_signing_time"},
75{ERR_FUNC(PKCS7_F_PKCS7_ADD_ATTRIB_SMIMECAP), "PKCS7_add_attrib_smimecap"}, 78{ERR_FUNC(PKCS7_F_PKCS7_ADD_ATTRIB_SMIMECAP), "PKCS7_add_attrib_smimecap"},
76{ERR_FUNC(PKCS7_F_PKCS7_ADD_CERTIFICATE), "PKCS7_add_certificate"}, 79{ERR_FUNC(PKCS7_F_PKCS7_ADD_CERTIFICATE), "PKCS7_add_certificate"},
77{ERR_FUNC(PKCS7_F_PKCS7_ADD_CRL), "PKCS7_add_crl"}, 80{ERR_FUNC(PKCS7_F_PKCS7_ADD_CRL), "PKCS7_add_crl"},
78{ERR_FUNC(PKCS7_F_PKCS7_ADD_RECIPIENT_INFO), "PKCS7_add_recipient_info"}, 81{ERR_FUNC(PKCS7_F_PKCS7_ADD_RECIPIENT_INFO), "PKCS7_add_recipient_info"},
82{ERR_FUNC(PKCS7_F_PKCS7_ADD_SIGNATURE), "PKCS7_add_signature"},
79{ERR_FUNC(PKCS7_F_PKCS7_ADD_SIGNER), "PKCS7_add_signer"}, 83{ERR_FUNC(PKCS7_F_PKCS7_ADD_SIGNER), "PKCS7_add_signer"},
80{ERR_FUNC(PKCS7_F_PKCS7_BIO_ADD_DIGEST), "PKCS7_BIO_ADD_DIGEST"}, 84{ERR_FUNC(PKCS7_F_PKCS7_BIO_ADD_DIGEST), "PKCS7_BIO_ADD_DIGEST"},
85{ERR_FUNC(PKCS7_F_PKCS7_COPY_EXISTING_DIGEST), "PKCS7_COPY_EXISTING_DIGEST"},
81{ERR_FUNC(PKCS7_F_PKCS7_CTRL), "PKCS7_ctrl"}, 86{ERR_FUNC(PKCS7_F_PKCS7_CTRL), "PKCS7_ctrl"},
82{ERR_FUNC(PKCS7_F_PKCS7_DATADECODE), "PKCS7_dataDecode"}, 87{ERR_FUNC(PKCS7_F_PKCS7_DATADECODE), "PKCS7_dataDecode"},
83{ERR_FUNC(PKCS7_F_PKCS7_DATAFINAL), "PKCS7_dataFinal"}, 88{ERR_FUNC(PKCS7_F_PKCS7_DATAFINAL), "PKCS7_dataFinal"},
@@ -85,15 +90,22 @@ static ERR_STRING_DATA PKCS7_str_functs[]=
85{ERR_FUNC(PKCS7_F_PKCS7_DATASIGN), "PKCS7_DATASIGN"}, 90{ERR_FUNC(PKCS7_F_PKCS7_DATASIGN), "PKCS7_DATASIGN"},
86{ERR_FUNC(PKCS7_F_PKCS7_DATAVERIFY), "PKCS7_dataVerify"}, 91{ERR_FUNC(PKCS7_F_PKCS7_DATAVERIFY), "PKCS7_dataVerify"},
87{ERR_FUNC(PKCS7_F_PKCS7_DECRYPT), "PKCS7_decrypt"}, 92{ERR_FUNC(PKCS7_F_PKCS7_DECRYPT), "PKCS7_decrypt"},
93{ERR_FUNC(PKCS7_F_PKCS7_DECRYPT_RINFO), "PKCS7_DECRYPT_RINFO"},
94{ERR_FUNC(PKCS7_F_PKCS7_ENCODE_RINFO), "PKCS7_ENCODE_RINFO"},
88{ERR_FUNC(PKCS7_F_PKCS7_ENCRYPT), "PKCS7_encrypt"}, 95{ERR_FUNC(PKCS7_F_PKCS7_ENCRYPT), "PKCS7_encrypt"},
96{ERR_FUNC(PKCS7_F_PKCS7_FINAL), "PKCS7_final"},
89{ERR_FUNC(PKCS7_F_PKCS7_FIND_DIGEST), "PKCS7_FIND_DIGEST"}, 97{ERR_FUNC(PKCS7_F_PKCS7_FIND_DIGEST), "PKCS7_FIND_DIGEST"},
90{ERR_FUNC(PKCS7_F_PKCS7_GET0_SIGNERS), "PKCS7_get0_signers"}, 98{ERR_FUNC(PKCS7_F_PKCS7_GET0_SIGNERS), "PKCS7_get0_signers"},
99{ERR_FUNC(PKCS7_F_PKCS7_RECIP_INFO_SET), "PKCS7_RECIP_INFO_set"},
91{ERR_FUNC(PKCS7_F_PKCS7_SET_CIPHER), "PKCS7_set_cipher"}, 100{ERR_FUNC(PKCS7_F_PKCS7_SET_CIPHER), "PKCS7_set_cipher"},
92{ERR_FUNC(PKCS7_F_PKCS7_SET_CONTENT), "PKCS7_set_content"}, 101{ERR_FUNC(PKCS7_F_PKCS7_SET_CONTENT), "PKCS7_set_content"},
93{ERR_FUNC(PKCS7_F_PKCS7_SET_DIGEST), "PKCS7_set_digest"}, 102{ERR_FUNC(PKCS7_F_PKCS7_SET_DIGEST), "PKCS7_set_digest"},
94{ERR_FUNC(PKCS7_F_PKCS7_SET_TYPE), "PKCS7_set_type"}, 103{ERR_FUNC(PKCS7_F_PKCS7_SET_TYPE), "PKCS7_set_type"},
95{ERR_FUNC(PKCS7_F_PKCS7_SIGN), "PKCS7_sign"}, 104{ERR_FUNC(PKCS7_F_PKCS7_SIGN), "PKCS7_sign"},
96{ERR_FUNC(PKCS7_F_PKCS7_SIGNATUREVERIFY), "PKCS7_signatureVerify"}, 105{ERR_FUNC(PKCS7_F_PKCS7_SIGNATUREVERIFY), "PKCS7_signatureVerify"},
106{ERR_FUNC(PKCS7_F_PKCS7_SIGNER_INFO_SET), "PKCS7_SIGNER_INFO_set"},
107{ERR_FUNC(PKCS7_F_PKCS7_SIGNER_INFO_SIGN), "PKCS7_SIGNER_INFO_sign"},
108{ERR_FUNC(PKCS7_F_PKCS7_SIGN_ADD_SIGNER), "PKCS7_sign_add_signer"},
97{ERR_FUNC(PKCS7_F_PKCS7_SIMPLE_SMIMECAP), "PKCS7_simple_smimecap"}, 109{ERR_FUNC(PKCS7_F_PKCS7_SIMPLE_SMIMECAP), "PKCS7_simple_smimecap"},
98{ERR_FUNC(PKCS7_F_PKCS7_VERIFY), "PKCS7_verify"}, 110{ERR_FUNC(PKCS7_F_PKCS7_VERIFY), "PKCS7_verify"},
99{ERR_FUNC(PKCS7_F_SMIME_READ_PKCS7), "SMIME_read_PKCS7"}, 111{ERR_FUNC(PKCS7_F_SMIME_READ_PKCS7), "SMIME_read_PKCS7"},
@@ -107,10 +119,13 @@ static ERR_STRING_DATA PKCS7_str_reasons[]=
107{ERR_REASON(PKCS7_R_CIPHER_HAS_NO_OBJECT_IDENTIFIER),"cipher has no object identifier"}, 119{ERR_REASON(PKCS7_R_CIPHER_HAS_NO_OBJECT_IDENTIFIER),"cipher has no object identifier"},
108{ERR_REASON(PKCS7_R_CIPHER_NOT_INITIALIZED),"cipher not initialized"}, 120{ERR_REASON(PKCS7_R_CIPHER_NOT_INITIALIZED),"cipher not initialized"},
109{ERR_REASON(PKCS7_R_CONTENT_AND_DATA_PRESENT),"content and data present"}, 121{ERR_REASON(PKCS7_R_CONTENT_AND_DATA_PRESENT),"content and data present"},
122{ERR_REASON(PKCS7_R_CTRL_ERROR) ,"ctrl error"},
110{ERR_REASON(PKCS7_R_DECODE_ERROR) ,"decode error"}, 123{ERR_REASON(PKCS7_R_DECODE_ERROR) ,"decode error"},
111{ERR_REASON(PKCS7_R_DECRYPTED_KEY_IS_WRONG_LENGTH),"decrypted key is wrong length"}, 124{ERR_REASON(PKCS7_R_DECRYPTED_KEY_IS_WRONG_LENGTH),"decrypted key is wrong length"},
112{ERR_REASON(PKCS7_R_DECRYPT_ERROR) ,"decrypt error"}, 125{ERR_REASON(PKCS7_R_DECRYPT_ERROR) ,"decrypt error"},
113{ERR_REASON(PKCS7_R_DIGEST_FAILURE) ,"digest failure"}, 126{ERR_REASON(PKCS7_R_DIGEST_FAILURE) ,"digest failure"},
127{ERR_REASON(PKCS7_R_ENCRYPTION_CTRL_FAILURE),"encryption ctrl failure"},
128{ERR_REASON(PKCS7_R_ENCRYPTION_NOT_SUPPORTED_FOR_THIS_KEY_TYPE),"encryption not supported for this key type"},
114{ERR_REASON(PKCS7_R_ERROR_ADDING_RECIPIENT),"error adding recipient"}, 129{ERR_REASON(PKCS7_R_ERROR_ADDING_RECIPIENT),"error adding recipient"},
115{ERR_REASON(PKCS7_R_ERROR_SETTING_CIPHER),"error setting cipher"}, 130{ERR_REASON(PKCS7_R_ERROR_SETTING_CIPHER),"error setting cipher"},
116{ERR_REASON(PKCS7_R_INVALID_MIME_TYPE) ,"invalid mime type"}, 131{ERR_REASON(PKCS7_R_INVALID_MIME_TYPE) ,"invalid mime type"},
@@ -121,6 +136,8 @@ static ERR_STRING_DATA PKCS7_str_reasons[]=
121{ERR_REASON(PKCS7_R_MISSING_CERIPEND_INFO),"missing ceripend info"}, 136{ERR_REASON(PKCS7_R_MISSING_CERIPEND_INFO),"missing ceripend info"},
122{ERR_REASON(PKCS7_R_NO_CONTENT) ,"no content"}, 137{ERR_REASON(PKCS7_R_NO_CONTENT) ,"no content"},
123{ERR_REASON(PKCS7_R_NO_CONTENT_TYPE) ,"no content type"}, 138{ERR_REASON(PKCS7_R_NO_CONTENT_TYPE) ,"no content type"},
139{ERR_REASON(PKCS7_R_NO_DEFAULT_DIGEST) ,"no default digest"},
140{ERR_REASON(PKCS7_R_NO_MATCHING_DIGEST_TYPE_FOUND),"no matching digest type found"},
124{ERR_REASON(PKCS7_R_NO_MULTIPART_BODY_FAILURE),"no multipart body failure"}, 141{ERR_REASON(PKCS7_R_NO_MULTIPART_BODY_FAILURE),"no multipart body failure"},
125{ERR_REASON(PKCS7_R_NO_MULTIPART_BOUNDARY),"no multipart boundary"}, 142{ERR_REASON(PKCS7_R_NO_MULTIPART_BOUNDARY),"no multipart boundary"},
126{ERR_REASON(PKCS7_R_NO_RECIPIENT_MATCHES_CERTIFICATE),"no recipient matches certificate"}, 143{ERR_REASON(PKCS7_R_NO_RECIPIENT_MATCHES_CERTIFICATE),"no recipient matches certificate"},
@@ -130,6 +147,7 @@ static ERR_STRING_DATA PKCS7_str_reasons[]=
130{ERR_REASON(PKCS7_R_NO_SIG_CONTENT_TYPE) ,"no sig content type"}, 147{ERR_REASON(PKCS7_R_NO_SIG_CONTENT_TYPE) ,"no sig content type"},
131{ERR_REASON(PKCS7_R_OPERATION_NOT_SUPPORTED_ON_THIS_TYPE),"operation not supported on this type"}, 148{ERR_REASON(PKCS7_R_OPERATION_NOT_SUPPORTED_ON_THIS_TYPE),"operation not supported on this type"},
132{ERR_REASON(PKCS7_R_PKCS7_ADD_SIGNATURE_ERROR),"pkcs7 add signature error"}, 149{ERR_REASON(PKCS7_R_PKCS7_ADD_SIGNATURE_ERROR),"pkcs7 add signature error"},
150{ERR_REASON(PKCS7_R_PKCS7_ADD_SIGNER_ERROR),"pkcs7 add signer error"},
133{ERR_REASON(PKCS7_R_PKCS7_DATAFINAL) ,"pkcs7 datafinal"}, 151{ERR_REASON(PKCS7_R_PKCS7_DATAFINAL) ,"pkcs7 datafinal"},
134{ERR_REASON(PKCS7_R_PKCS7_DATAFINAL_ERROR),"pkcs7 datafinal error"}, 152{ERR_REASON(PKCS7_R_PKCS7_DATAFINAL_ERROR),"pkcs7 datafinal error"},
135{ERR_REASON(PKCS7_R_PKCS7_DATASIGN) ,"pkcs7 datasign"}, 153{ERR_REASON(PKCS7_R_PKCS7_DATASIGN) ,"pkcs7 datasign"},
@@ -138,6 +156,8 @@ static ERR_STRING_DATA PKCS7_str_reasons[]=
138{ERR_REASON(PKCS7_R_PRIVATE_KEY_DOES_NOT_MATCH_CERTIFICATE),"private key does not match certificate"}, 156{ERR_REASON(PKCS7_R_PRIVATE_KEY_DOES_NOT_MATCH_CERTIFICATE),"private key does not match certificate"},
139{ERR_REASON(PKCS7_R_SIGNATURE_FAILURE) ,"signature failure"}, 157{ERR_REASON(PKCS7_R_SIGNATURE_FAILURE) ,"signature failure"},
140{ERR_REASON(PKCS7_R_SIGNER_CERTIFICATE_NOT_FOUND),"signer certificate not found"}, 158{ERR_REASON(PKCS7_R_SIGNER_CERTIFICATE_NOT_FOUND),"signer certificate not found"},
159{ERR_REASON(PKCS7_R_SIGNING_CTRL_FAILURE),"signing ctrl failure"},
160{ERR_REASON(PKCS7_R_SIGNING_NOT_SUPPORTED_FOR_THIS_KEY_TYPE),"signing not supported for this key type"},
141{ERR_REASON(PKCS7_R_SIG_INVALID_MIME_TYPE),"sig invalid mime type"}, 161{ERR_REASON(PKCS7_R_SIG_INVALID_MIME_TYPE),"sig invalid mime type"},
142{ERR_REASON(PKCS7_R_SMIME_TEXT_ERROR) ,"smime text error"}, 162{ERR_REASON(PKCS7_R_SMIME_TEXT_ERROR) ,"smime text error"},
143{ERR_REASON(PKCS7_R_UNABLE_TO_FIND_CERTIFICATE),"unable to find certificate"}, 163{ERR_REASON(PKCS7_R_UNABLE_TO_FIND_CERTIFICATE),"unable to find certificate"},
diff --git a/src/lib/libcrypto/pqueue/pq_compat.h b/src/lib/libcrypto/pqueue/pq_compat.h
deleted file mode 100644
index 7b2c32725c..0000000000
--- a/src/lib/libcrypto/pqueue/pq_compat.h
+++ /dev/null
@@ -1,152 +0,0 @@
1/* crypto/pqueue/pqueue_compat.h */
2/*
3 * DTLS implementation written by Nagendra Modadugu
4 * (nagendra@cs.stanford.edu) for the OpenSSL project 2005.
5 */
6/* ====================================================================
7 * Copyright (c) 1999-2005 The OpenSSL Project. All rights reserved.
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
11 * are met:
12 *
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 *
16 * 2. Redistributions in binary form must reproduce the above copyright
17 * notice, this list of conditions and the following disclaimer in
18 * the documentation and/or other materials provided with the
19 * distribution.
20 *
21 * 3. All advertising materials mentioning features or use of this
22 * software must display the following acknowledgment:
23 * "This product includes software developed by the OpenSSL Project
24 * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
25 *
26 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
27 * endorse or promote products derived from this software without
28 * prior written permission. For written permission, please contact
29 * openssl-core@OpenSSL.org.
30 *
31 * 5. Products derived from this software may not be called "OpenSSL"
32 * nor may "OpenSSL" appear in their names without prior written
33 * permission of the OpenSSL Project.
34 *
35 * 6. Redistributions of any form whatsoever must retain the following
36 * acknowledgment:
37 * "This product includes software developed by the OpenSSL Project
38 * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
39 *
40 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
41 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
42 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
43 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
44 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
45 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
46 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
47 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
49 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
50 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
51 * OF THE POSSIBILITY OF SUCH DAMAGE.
52 * ====================================================================
53 *
54 * This product includes cryptographic software written by Eric Young
55 * (eay@cryptsoft.com). This product includes software written by Tim
56 * Hudson (tjh@cryptsoft.com).
57 *
58 */
59
60#ifndef HEADER_PQ_COMPAT_H
61#define HEADER_PQ_COMPAT_H
62
63#include <openssl/opensslconf.h>
64#include <openssl/bn.h>
65
66/*
67 * The purpose of this header file is for supporting 64-bit integer
68 * manipulation on 32-bit (and lower) machines. Currently the only
69 * such environment is VMS, Utrix and those with smaller default integer
70 * sizes than 32 bits. For all such environment, we fall back to using
71 * BIGNUM. We may need to fine tune the conditions for systems that
72 * are incorrectly configured.
73 *
74 * The only clients of this code are (1) pqueue for priority, and
75 * (2) DTLS, for sequence number manipulation.
76 */
77
78#if (defined(THIRTY_TWO_BIT) && !defined(BN_LLONG)) || defined(SIXTEEN_BIT) || defined(EIGHT_BIT)
79
80#define PQ_64BIT_IS_INTEGER 0
81#define PQ_64BIT_IS_BIGNUM 1
82
83#define PQ_64BIT BIGNUM
84#define PQ_64BIT_CTX BN_CTX
85
86#define pq_64bit_init(x) BN_init(x)
87#define pq_64bit_free(x) BN_free(x)
88
89#define pq_64bit_ctx_new(ctx) BN_CTX_new()
90#define pq_64bit_ctx_free(x) BN_CTX_free(x)
91
92#define pq_64bit_assign(x, y) BN_copy(x, y)
93#define pq_64bit_assign_word(x, y) BN_set_word(x, y)
94#define pq_64bit_gt(x, y) BN_ucmp(x, y) >= 1 ? 1 : 0
95#define pq_64bit_eq(x, y) BN_ucmp(x, y) == 0 ? 1 : 0
96#define pq_64bit_add_word(x, w) BN_add_word(x, w)
97#define pq_64bit_sub(r, x, y) BN_sub(r, x, y)
98#define pq_64bit_sub_word(x, w) BN_sub_word(x, w)
99#define pq_64bit_mod(r, x, n, ctx) BN_mod(r, x, n, ctx)
100
101#define pq_64bit_bin2num(bn, bytes, len) BN_bin2bn(bytes, len, bn)
102#define pq_64bit_num2bin(bn, bytes) BN_bn2bin(bn, bytes)
103#define pq_64bit_get_word(x) BN_get_word(x)
104#define pq_64bit_is_bit_set(x, offset) BN_is_bit_set(x, offset)
105#define pq_64bit_lshift(r, x, shift) BN_lshift(r, x, shift)
106#define pq_64bit_set_bit(x, num) BN_set_bit(x, num)
107#define pq_64bit_get_length(x) BN_num_bits((x))
108
109#else
110
111#define PQ_64BIT_IS_INTEGER 1
112#define PQ_64BIT_IS_BIGNUM 0
113
114#if defined(SIXTY_FOUR_BIT)
115#define PQ_64BIT BN_ULONG
116#define PQ_64BIT_PRINT "%lld"
117#elif defined(SIXTY_FOUR_BIT_LONG)
118#define PQ_64BIT BN_ULONG
119#define PQ_64BIT_PRINT "%ld"
120#elif defined(THIRTY_TWO_BIT)
121#define PQ_64BIT BN_ULLONG
122#define PQ_64BIT_PRINT "%lld"
123#endif
124
125#define PQ_64BIT_CTX void
126
127#define pq_64bit_init(x)
128#define pq_64bit_free(x)
129#define pq_64bit_ctx_new(ctx) (ctx)
130#define pq_64bit_ctx_free(x)
131
132#define pq_64bit_assign(x, y) (*(x) = *(y))
133#define pq_64bit_assign_word(x, y) (*(x) = y)
134#define pq_64bit_gt(x, y) (*(x) > *(y))
135#define pq_64bit_eq(x, y) (*(x) == *(y))
136#define pq_64bit_add_word(x, w) (*(x) = (*(x) + (w)))
137#define pq_64bit_sub(r, x, y) (*(r) = (*(x) - *(y)))
138#define pq_64bit_sub_word(x, w) (*(x) = (*(x) - (w)))
139#define pq_64bit_mod(r, x, n, ctx)
140
141#define pq_64bit_bin2num(num, bytes, len) bytes_to_long_long(bytes, num)
142#define pq_64bit_num2bin(num, bytes) long_long_to_bytes(num, bytes)
143#define pq_64bit_get_word(x) *(x)
144#define pq_64bit_lshift(r, x, shift) (*(r) = (*(x) << (shift)))
145#define pq_64bit_set_bit(x, num) do { \
146 PQ_64BIT mask = 1; \
147 mask = mask << (num); \
148 *(x) |= mask; \
149 } while(0)
150#endif /* OPENSSL_SYS_VMS */
151
152#endif
diff --git a/src/lib/libcrypto/rand/Makefile b/src/lib/libcrypto/rand/Makefile
index 30794305cb..27694aa664 100644
--- a/src/lib/libcrypto/rand/Makefile
+++ b/src/lib/libcrypto/rand/Makefile
@@ -17,9 +17,9 @@ TEST= randtest.c
17APPS= 17APPS=
18 18
19LIB=$(TOP)/libcrypto.a 19LIB=$(TOP)/libcrypto.a
20LIBSRC=md_rand.c randfile.c rand_lib.c rand_eng.c rand_err.c rand_egd.c \ 20LIBSRC=md_rand.c randfile.c rand_lib.c rand_err.c rand_egd.c \
21 rand_win.c rand_unix.c rand_os2.c rand_nw.c 21 rand_win.c rand_unix.c rand_os2.c rand_nw.c
22LIBOBJ=md_rand.o randfile.o rand_lib.o rand_eng.o rand_err.o rand_egd.o \ 22LIBOBJ=md_rand.o randfile.o rand_lib.o rand_err.o rand_egd.o \
23 rand_win.o rand_unix.o rand_os2.o rand_nw.o 23 rand_win.o rand_unix.o rand_os2.o rand_nw.o
24 24
25SRC= $(LIBSRC) 25SRC= $(LIBSRC)
@@ -35,7 +35,7 @@ top:
35all: lib 35all: lib
36 36
37lib: $(LIBOBJ) 37lib: $(LIBOBJ)
38 $(ARX) $(LIB) $(LIBOBJ) 38 $(AR) $(LIB) $(LIBOBJ)
39 $(RANLIB) $(LIB) || echo Never mind. 39 $(RANLIB) $(LIB) || echo Never mind.
40 @touch lib 40 @touch lib
41 41
@@ -79,34 +79,17 @@ clean:
79md_rand.o: ../../e_os.h ../../include/openssl/asn1.h 79md_rand.o: ../../e_os.h ../../include/openssl/asn1.h
80md_rand.o: ../../include/openssl/bio.h ../../include/openssl/crypto.h 80md_rand.o: ../../include/openssl/bio.h ../../include/openssl/crypto.h
81md_rand.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h 81md_rand.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
82md_rand.o: ../../include/openssl/evp.h ../../include/openssl/fips.h 82md_rand.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h
83md_rand.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h 83md_rand.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
84md_rand.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h 84md_rand.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
85md_rand.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h 85md_rand.o: ../../include/openssl/ossl_typ.h ../../include/openssl/rand.h
86md_rand.o: ../../include/openssl/rand.h ../../include/openssl/safestack.h 86md_rand.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
87md_rand.o: ../../include/openssl/sha.h ../../include/openssl/stack.h 87md_rand.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
88md_rand.o: ../../include/openssl/symhacks.h md_rand.c rand_lcl.h 88md_rand.o: md_rand.c rand_lcl.h
89rand_egd.o: ../../include/openssl/buffer.h ../../include/openssl/e_os2.h 89rand_egd.o: ../../include/openssl/buffer.h ../../include/openssl/e_os2.h
90rand_egd.o: ../../include/openssl/opensslconf.h 90rand_egd.o: ../../include/openssl/opensslconf.h
91rand_egd.o: ../../include/openssl/ossl_typ.h ../../include/openssl/rand.h 91rand_egd.o: ../../include/openssl/ossl_typ.h ../../include/openssl/rand.h
92rand_egd.o: rand_egd.c 92rand_egd.o: rand_egd.c
93rand_eng.o: ../../e_os.h ../../include/openssl/asn1.h
94rand_eng.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
95rand_eng.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
96rand_eng.o: ../../include/openssl/des_old.h ../../include/openssl/e_os2.h
97rand_eng.o: ../../include/openssl/ec.h ../../include/openssl/ecdh.h
98rand_eng.o: ../../include/openssl/ecdsa.h ../../include/openssl/engine.h
99rand_eng.o: ../../include/openssl/err.h ../../include/openssl/evp.h
100rand_eng.o: ../../include/openssl/fips.h ../../include/openssl/fips_rand.h
101rand_eng.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
102rand_eng.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
103rand_eng.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
104rand_eng.o: ../../include/openssl/pkcs7.h ../../include/openssl/rand.h
105rand_eng.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
106rand_eng.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
107rand_eng.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
108rand_eng.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
109rand_eng.o: ../cryptlib.h rand_eng.c rand_lcl.h
110rand_err.o: ../../include/openssl/bio.h ../../include/openssl/crypto.h 93rand_err.o: ../../include/openssl/bio.h ../../include/openssl/crypto.h
111rand_err.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h 94rand_err.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
112rand_err.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h 95rand_err.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
@@ -116,39 +99,34 @@ rand_err.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
116rand_err.o: rand_err.c 99rand_err.o: rand_err.c
117rand_lib.o: ../../e_os.h ../../include/openssl/asn1.h 100rand_lib.o: ../../e_os.h ../../include/openssl/asn1.h
118rand_lib.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h 101rand_lib.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
119rand_lib.o: ../../include/openssl/crypto.h ../../include/openssl/des.h 102rand_lib.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
120rand_lib.o: ../../include/openssl/des_old.h ../../include/openssl/e_os2.h
121rand_lib.o: ../../include/openssl/ec.h ../../include/openssl/ecdh.h 103rand_lib.o: ../../include/openssl/ec.h ../../include/openssl/ecdh.h
122rand_lib.o: ../../include/openssl/ecdsa.h ../../include/openssl/engine.h 104rand_lib.o: ../../include/openssl/ecdsa.h ../../include/openssl/engine.h
123rand_lib.o: ../../include/openssl/err.h ../../include/openssl/evp.h 105rand_lib.o: ../../include/openssl/err.h ../../include/openssl/evp.h
124rand_lib.o: ../../include/openssl/fips.h ../../include/openssl/fips_rand.h
125rand_lib.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h 106rand_lib.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
126rand_lib.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h 107rand_lib.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
127rand_lib.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h 108rand_lib.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
128rand_lib.o: ../../include/openssl/pkcs7.h ../../include/openssl/rand.h 109rand_lib.o: ../../include/openssl/pkcs7.h ../../include/openssl/rand.h
129rand_lib.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h 110rand_lib.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
130rand_lib.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 111rand_lib.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
131rand_lib.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
132rand_lib.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h 112rand_lib.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
133rand_lib.o: ../cryptlib.h rand_lcl.h rand_lib.c 113rand_lib.o: ../cryptlib.h rand_lib.c
134rand_nw.o: ../../e_os.h ../../include/openssl/asn1.h 114rand_nw.o: ../../e_os.h ../../include/openssl/asn1.h
135rand_nw.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h 115rand_nw.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
136rand_nw.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h 116rand_nw.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
137rand_nw.o: ../../include/openssl/err.h ../../include/openssl/evp.h 117rand_nw.o: ../../include/openssl/err.h ../../include/openssl/evp.h
138rand_nw.o: ../../include/openssl/fips.h ../../include/openssl/lhash.h 118rand_nw.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
139rand_nw.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h 119rand_nw.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
140rand_nw.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h 120rand_nw.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
141rand_nw.o: ../../include/openssl/ossl_typ.h ../../include/openssl/rand.h 121rand_nw.o: ../../include/openssl/rand.h ../../include/openssl/safestack.h
142rand_nw.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h 122rand_nw.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
143rand_nw.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 123rand_nw.o: ../../include/openssl/symhacks.h ../cryptlib.h rand_lcl.h rand_nw.c
144rand_nw.o: ../cryptlib.h rand_lcl.h rand_nw.c
145rand_os2.o: ../../e_os.h ../../include/openssl/asn1.h 124rand_os2.o: ../../e_os.h ../../include/openssl/asn1.h
146rand_os2.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h 125rand_os2.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
147rand_os2.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h 126rand_os2.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
148rand_os2.o: ../../include/openssl/err.h ../../include/openssl/evp.h 127rand_os2.o: ../../include/openssl/err.h ../../include/openssl/evp.h
149rand_os2.o: ../../include/openssl/fips.h ../../include/openssl/lhash.h 128rand_os2.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
150rand_os2.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h 129rand_os2.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
151rand_os2.o: ../../include/openssl/opensslconf.h
152rand_os2.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h 130rand_os2.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
153rand_os2.o: ../../include/openssl/rand.h ../../include/openssl/safestack.h 131rand_os2.o: ../../include/openssl/rand.h ../../include/openssl/safestack.h
154rand_os2.o: ../../include/openssl/sha.h ../../include/openssl/stack.h 132rand_os2.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
@@ -158,8 +136,8 @@ rand_unix.o: ../../e_os.h ../../include/openssl/asn1.h
158rand_unix.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h 136rand_unix.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
159rand_unix.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h 137rand_unix.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
160rand_unix.o: ../../include/openssl/err.h ../../include/openssl/evp.h 138rand_unix.o: ../../include/openssl/err.h ../../include/openssl/evp.h
161rand_unix.o: ../../include/openssl/fips.h ../../include/openssl/lhash.h 139rand_unix.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
162rand_unix.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h 140rand_unix.o: ../../include/openssl/objects.h
163rand_unix.o: ../../include/openssl/opensslconf.h 141rand_unix.o: ../../include/openssl/opensslconf.h
164rand_unix.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h 142rand_unix.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
165rand_unix.o: ../../include/openssl/rand.h ../../include/openssl/safestack.h 143rand_unix.o: ../../include/openssl/rand.h ../../include/openssl/safestack.h
@@ -170,9 +148,8 @@ rand_win.o: ../../e_os.h ../../include/openssl/asn1.h
170rand_win.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h 148rand_win.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
171rand_win.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h 149rand_win.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
172rand_win.o: ../../include/openssl/err.h ../../include/openssl/evp.h 150rand_win.o: ../../include/openssl/err.h ../../include/openssl/evp.h
173rand_win.o: ../../include/openssl/fips.h ../../include/openssl/lhash.h 151rand_win.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
174rand_win.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h 152rand_win.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
175rand_win.o: ../../include/openssl/opensslconf.h
176rand_win.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h 153rand_win.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
177rand_win.o: ../../include/openssl/rand.h ../../include/openssl/safestack.h 154rand_win.o: ../../include/openssl/rand.h ../../include/openssl/safestack.h
178rand_win.o: ../../include/openssl/sha.h ../../include/openssl/stack.h 155rand_win.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
diff --git a/src/lib/libcrypto/rand/Makefile.ssl b/src/lib/libcrypto/rand/Makefile.ssl
deleted file mode 100644
index e5cbe5319c..0000000000
--- a/src/lib/libcrypto/rand/Makefile.ssl
+++ /dev/null
@@ -1,196 +0,0 @@
1#
2# SSLeay/crypto/rand/Makefile
3#
4
5DIR= rand
6TOP= ../..
7CC= cc
8INCLUDES=
9CFLAG=-g
10INSTALL_PREFIX=
11OPENSSLDIR= /usr/local/ssl
12INSTALLTOP=/usr/local/ssl
13MAKE= make -f Makefile.ssl
14MAKEDEPPROG= makedepend
15MAKEDEPEND= $(TOP)/util/domd $(TOP) -MD $(MAKEDEPPROG)
16MAKEFILE= Makefile.ssl
17AR= ar r
18
19CFLAGS= $(INCLUDES) $(CFLAG)
20
21GENERAL=Makefile
22TEST= randtest.c
23APPS=
24
25LIB=$(TOP)/libcrypto.a
26LIBSRC=md_rand.c randfile.c rand_lib.c rand_err.c rand_egd.c \
27 rand_win.c rand_unix.c rand_os2.c
28LIBOBJ=md_rand.o randfile.o rand_lib.o rand_err.o rand_egd.o \
29 rand_win.o rand_unix.o rand_os2.o
30
31SRC= $(LIBSRC)
32
33EXHEADER= rand.h
34HEADER= $(EXHEADER)
35
36ALL= $(GENERAL) $(SRC) $(HEADER)
37
38top:
39 (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all)
40
41all: lib
42
43lib: $(LIBOBJ)
44 $(AR) $(LIB) $(LIBOBJ)
45 $(RANLIB) $(LIB) || echo Never mind.
46 @touch lib
47
48files:
49 $(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO
50
51links:
52 @sh $(TOP)/util/point.sh Makefile.ssl Makefile
53 @$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER)
54 @$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST)
55 @$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS)
56
57install:
58 @for i in $(EXHEADER) ; \
59 do \
60 (cp $$i $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i; \
61 chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i ); \
62 done;
63
64tags:
65 ctags $(SRC)
66
67tests:
68
69lint:
70 lint -DLINT $(INCLUDES) $(SRC)>fluff
71
72depend:
73 $(MAKEDEPEND) -- $(CFLAG) $(INCLUDES) $(DEPFLAG) -- $(PROGS) $(LIBSRC)
74
75dclean:
76 $(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
77 mv -f Makefile.new $(MAKEFILE)
78
79clean:
80 rm -f *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff
81
82# DO NOT DELETE THIS LINE -- make depend depends on it.
83
84md_rand.o: ../../e_os.h ../../include/openssl/aes.h
85md_rand.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
86md_rand.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
87md_rand.o: ../../include/openssl/cast.h ../../include/openssl/crypto.h
88md_rand.o: ../../include/openssl/des.h ../../include/openssl/des_old.h
89md_rand.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
90md_rand.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
91md_rand.o: ../../include/openssl/evp.h ../../include/openssl/idea.h
92md_rand.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h
93md_rand.o: ../../include/openssl/md4.h ../../include/openssl/md5.h
94md_rand.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h
95md_rand.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
96md_rand.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
97md_rand.o: ../../include/openssl/rand.h ../../include/openssl/rc2.h
98md_rand.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
99md_rand.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
100md_rand.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
101md_rand.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
102md_rand.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
103md_rand.o: md_rand.c rand_lcl.h
104rand_egd.o: ../../include/openssl/buffer.h ../../include/openssl/e_os2.h
105rand_egd.o: ../../include/openssl/opensslconf.h
106rand_egd.o: ../../include/openssl/ossl_typ.h ../../include/openssl/rand.h
107rand_egd.o: rand_egd.c
108rand_err.o: ../../include/openssl/bio.h ../../include/openssl/crypto.h
109rand_err.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
110rand_err.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
111rand_err.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
112rand_err.o: ../../include/openssl/rand.h ../../include/openssl/safestack.h
113rand_err.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
114rand_err.o: rand_err.c
115rand_lib.o: ../../e_os.h ../../include/openssl/asn1.h
116rand_lib.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
117rand_lib.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
118rand_lib.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
119rand_lib.o: ../../include/openssl/e_os2.h ../../include/openssl/engine.h
120rand_lib.o: ../../include/openssl/err.h ../../include/openssl/lhash.h
121rand_lib.o: ../../include/openssl/opensslconf.h
122rand_lib.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
123rand_lib.o: ../../include/openssl/rand.h ../../include/openssl/rsa.h
124rand_lib.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
125rand_lib.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
126rand_lib.o: ../cryptlib.h rand_lib.c
127rand_os2.o: ../../e_os.h ../../include/openssl/aes.h
128rand_os2.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
129rand_os2.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
130rand_os2.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
131rand_os2.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
132rand_os2.o: ../../include/openssl/des_old.h ../../include/openssl/dh.h
133rand_os2.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
134rand_os2.o: ../../include/openssl/err.h ../../include/openssl/evp.h
135rand_os2.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h
136rand_os2.o: ../../include/openssl/md2.h ../../include/openssl/md4.h
137rand_os2.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
138rand_os2.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
139rand_os2.o: ../../include/openssl/opensslconf.h
140rand_os2.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
141rand_os2.o: ../../include/openssl/rand.h ../../include/openssl/rc2.h
142rand_os2.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
143rand_os2.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
144rand_os2.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
145rand_os2.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
146rand_os2.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
147rand_os2.o: ../cryptlib.h rand_lcl.h rand_os2.c
148rand_unix.o: ../../e_os.h ../../include/openssl/aes.h
149rand_unix.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
150rand_unix.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
151rand_unix.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
152rand_unix.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
153rand_unix.o: ../../include/openssl/des_old.h ../../include/openssl/dh.h
154rand_unix.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
155rand_unix.o: ../../include/openssl/err.h ../../include/openssl/evp.h
156rand_unix.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h
157rand_unix.o: ../../include/openssl/md2.h ../../include/openssl/md4.h
158rand_unix.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
159rand_unix.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
160rand_unix.o: ../../include/openssl/opensslconf.h
161rand_unix.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
162rand_unix.o: ../../include/openssl/rand.h ../../include/openssl/rc2.h
163rand_unix.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
164rand_unix.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
165rand_unix.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
166rand_unix.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
167rand_unix.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
168rand_unix.o: ../cryptlib.h rand_lcl.h rand_unix.c
169rand_win.o: ../../e_os.h ../../include/openssl/aes.h
170rand_win.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
171rand_win.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
172rand_win.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
173rand_win.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
174rand_win.o: ../../include/openssl/des_old.h ../../include/openssl/dh.h
175rand_win.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
176rand_win.o: ../../include/openssl/err.h ../../include/openssl/evp.h
177rand_win.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h
178rand_win.o: ../../include/openssl/md2.h ../../include/openssl/md4.h
179rand_win.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
180rand_win.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
181rand_win.o: ../../include/openssl/opensslconf.h
182rand_win.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
183rand_win.o: ../../include/openssl/rand.h ../../include/openssl/rc2.h
184rand_win.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
185rand_win.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
186rand_win.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
187rand_win.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
188rand_win.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
189rand_win.o: ../cryptlib.h rand_lcl.h rand_win.c
190randfile.o: ../../e_os.h ../../include/openssl/buffer.h
191randfile.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
192randfile.o: ../../include/openssl/opensslconf.h
193randfile.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
194randfile.o: ../../include/openssl/rand.h ../../include/openssl/safestack.h
195randfile.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
196randfile.o: randfile.c
diff --git a/src/lib/libcrypto/rand/md_rand.c b/src/lib/libcrypto/rand/md_rand.c
index 0f8dd3e00f..88088ce73c 100644
--- a/src/lib/libcrypto/rand/md_rand.c
+++ b/src/lib/libcrypto/rand/md_rand.c
@@ -126,10 +126,6 @@
126 126
127#include <openssl/crypto.h> 127#include <openssl/crypto.h>
128#include <openssl/err.h> 128#include <openssl/err.h>
129#ifdef OPENSSL_FIPS
130#include <openssl/fips.h>
131#endif
132
133 129
134#ifdef BN_DEBUG 130#ifdef BN_DEBUG
135# define PREDICT 131# define PREDICT
@@ -149,7 +145,7 @@ static unsigned int crypto_lock_rand = 0; /* may be set only when a thread
149 * holds CRYPTO_LOCK_RAND 145 * holds CRYPTO_LOCK_RAND
150 * (to prevent double locking) */ 146 * (to prevent double locking) */
151/* access to lockin_thread is synchronized by CRYPTO_LOCK_RAND2 */ 147/* access to lockin_thread is synchronized by CRYPTO_LOCK_RAND2 */
152static unsigned long locking_thread = 0; /* valid iff crypto_lock_rand is set */ 148static CRYPTO_THREADID locking_threadid; /* valid iff crypto_lock_rand is set */
153 149
154 150
155#ifdef PREDICT 151#ifdef PREDICT
@@ -217,8 +213,10 @@ static void ssleay_rand_add(const void *buf, int num, double add)
217 /* check if we already have the lock */ 213 /* check if we already have the lock */
218 if (crypto_lock_rand) 214 if (crypto_lock_rand)
219 { 215 {
216 CRYPTO_THREADID cur;
217 CRYPTO_THREADID_current(&cur);
220 CRYPTO_r_lock(CRYPTO_LOCK_RAND2); 218 CRYPTO_r_lock(CRYPTO_LOCK_RAND2);
221 do_not_lock = (locking_thread == CRYPTO_thread_id()); 219 do_not_lock = !CRYPTO_THREADID_cmp(&locking_threadid, &cur);
222 CRYPTO_r_unlock(CRYPTO_LOCK_RAND2); 220 CRYPTO_r_unlock(CRYPTO_LOCK_RAND2);
223 } 221 }
224 else 222 else
@@ -274,8 +272,16 @@ static void ssleay_rand_add(const void *buf, int num, double add)
274 } 272 }
275 else 273 else
276 MD_Update(&m,&(state[st_idx]),j); 274 MD_Update(&m,&(state[st_idx]),j);
277 275
276 /* DO NOT REMOVE THE FOLLOWING CALL TO MD_Update()! */
278 MD_Update(&m,buf,j); 277 MD_Update(&m,buf,j);
278 /* We know that line may cause programs such as
279 purify and valgrind to complain about use of
280 uninitialized data. The problem is not, it's
281 with the caller. Removing that line will make
282 sure you get really bad randomness and thereby
283 other problems such as very insecure keys. */
284
279 MD_Update(&m,(unsigned char *)&(md_c[0]),sizeof(md_c)); 285 MD_Update(&m,(unsigned char *)&(md_c[0]),sizeof(md_c));
280 MD_Final(&m,local_md); 286 MD_Final(&m,local_md);
281 md_c[1]++; 287 md_c[1]++;
@@ -336,14 +342,6 @@ static int ssleay_rand_bytes(unsigned char *buf, int num)
336#endif 342#endif
337 int do_stir_pool = 0; 343 int do_stir_pool = 0;
338 344
339#ifdef OPENSSL_FIPS
340 if(FIPS_mode())
341 {
342 FIPSerr(FIPS_F_SSLEAY_RAND_BYTES,FIPS_R_NON_FIPS_METHOD);
343 return 0;
344 }
345#endif
346
347#ifdef PREDICT 345#ifdef PREDICT
348 if (rand_predictable) 346 if (rand_predictable)
349 { 347 {
@@ -384,7 +382,7 @@ static int ssleay_rand_bytes(unsigned char *buf, int num)
384 382
385 /* prevent ssleay_rand_bytes() from trying to obtain the lock again */ 383 /* prevent ssleay_rand_bytes() from trying to obtain the lock again */
386 CRYPTO_w_lock(CRYPTO_LOCK_RAND2); 384 CRYPTO_w_lock(CRYPTO_LOCK_RAND2);
387 locking_thread = CRYPTO_thread_id(); 385 CRYPTO_THREADID_current(&locking_threadid);
388 CRYPTO_w_unlock(CRYPTO_LOCK_RAND2); 386 CRYPTO_w_unlock(CRYPTO_LOCK_RAND2);
389 crypto_lock_rand = 1; 387 crypto_lock_rand = 1;
390 388
@@ -476,9 +474,15 @@ static int ssleay_rand_bytes(unsigned char *buf, int num)
476#endif 474#endif
477 MD_Update(&m,local_md,MD_DIGEST_LENGTH); 475 MD_Update(&m,local_md,MD_DIGEST_LENGTH);
478 MD_Update(&m,(unsigned char *)&(md_c[0]),sizeof(md_c)); 476 MD_Update(&m,(unsigned char *)&(md_c[0]),sizeof(md_c));
479#ifndef PURIFY 477
480 MD_Update(&m,buf,j); /* purify complains */ 478#ifndef PURIFY /* purify complains */
479 /* DO NOT REMOVE THE FOLLOWING CALL TO MD_Update()! */
480 MD_Update(&m,buf,j);
481 /* We know that line may cause programs such as
482 purify and valgrind to complain about use of
483 uninitialized data. */
481#endif 484#endif
485
482 k=(st_idx+MD_DIGEST_LENGTH/2)-st_num; 486 k=(st_idx+MD_DIGEST_LENGTH/2)-st_num;
483 if (k > 0) 487 if (k > 0)
484 { 488 {
@@ -539,15 +543,17 @@ static int ssleay_rand_pseudo_bytes(unsigned char *buf, int num)
539 543
540static int ssleay_rand_status(void) 544static int ssleay_rand_status(void)
541 { 545 {
546 CRYPTO_THREADID cur;
542 int ret; 547 int ret;
543 int do_not_lock; 548 int do_not_lock;
544 549
550 CRYPTO_THREADID_current(&cur);
545 /* check if we already have the lock 551 /* check if we already have the lock
546 * (could happen if a RAND_poll() implementation calls RAND_status()) */ 552 * (could happen if a RAND_poll() implementation calls RAND_status()) */
547 if (crypto_lock_rand) 553 if (crypto_lock_rand)
548 { 554 {
549 CRYPTO_r_lock(CRYPTO_LOCK_RAND2); 555 CRYPTO_r_lock(CRYPTO_LOCK_RAND2);
550 do_not_lock = (locking_thread == CRYPTO_thread_id()); 556 do_not_lock = !CRYPTO_THREADID_cmp(&locking_threadid, &cur);
551 CRYPTO_r_unlock(CRYPTO_LOCK_RAND2); 557 CRYPTO_r_unlock(CRYPTO_LOCK_RAND2);
552 } 558 }
553 else 559 else
@@ -559,7 +565,7 @@ static int ssleay_rand_status(void)
559 565
560 /* prevent ssleay_rand_bytes() from trying to obtain the lock again */ 566 /* prevent ssleay_rand_bytes() from trying to obtain the lock again */
561 CRYPTO_w_lock(CRYPTO_LOCK_RAND2); 567 CRYPTO_w_lock(CRYPTO_LOCK_RAND2);
562 locking_thread = CRYPTO_thread_id(); 568 CRYPTO_THREADID_cpy(&locking_threadid, &cur);
563 CRYPTO_w_unlock(CRYPTO_LOCK_RAND2); 569 CRYPTO_w_unlock(CRYPTO_LOCK_RAND2);
564 crypto_lock_rand = 1; 570 crypto_lock_rand = 1;
565 } 571 }
diff --git a/src/lib/libcrypto/rand/rand.h b/src/lib/libcrypto/rand/rand.h
index ea89153cba..ac6c021763 100644
--- a/src/lib/libcrypto/rand/rand.h
+++ b/src/lib/libcrypto/rand/rand.h
@@ -72,7 +72,7 @@ extern "C" {
72#endif 72#endif
73 73
74#if defined(OPENSSL_FIPS) 74#if defined(OPENSSL_FIPS)
75#define FIPS_RAND_SIZE_T int 75#define FIPS_RAND_SIZE_T size_t
76#endif 76#endif
77 77
78/* Already defined in ossl_typ.h */ 78/* Already defined in ossl_typ.h */
@@ -111,15 +111,6 @@ int RAND_query_egd_bytes(const char *path, unsigned char *buf, int bytes);
111int RAND_egd(const char *path); 111int RAND_egd(const char *path);
112int RAND_egd_bytes(const char *path,int bytes); 112int RAND_egd_bytes(const char *path,int bytes);
113int RAND_poll(void); 113int RAND_poll(void);
114#ifndef OPENSSL_NO_ENGINE
115#ifdef OPENSSL_FIPS
116void int_RAND_init_engine_callbacks(void);
117void int_RAND_set_callbacks(
118 int (*set_rand_func)(const RAND_METHOD *meth,
119 const RAND_METHOD **pmeth),
120 const RAND_METHOD *(*get_rand_func)(const RAND_METHOD **pmeth));
121#endif
122#endif
123 114
124#if defined(OPENSSL_SYS_WINDOWS) || defined(OPENSSL_SYS_WIN32) 115#if defined(OPENSSL_SYS_WINDOWS) || defined(OPENSSL_SYS_WIN32)
125 116
@@ -137,29 +128,11 @@ void ERR_load_RAND_strings(void);
137/* Error codes for the RAND functions. */ 128/* Error codes for the RAND functions. */
138 129
139/* Function codes. */ 130/* Function codes. */
140#define RAND_F_ENG_RAND_GET_RAND_METHOD 108
141#define RAND_F_FIPS_RAND 103
142#define RAND_F_FIPS_RAND_BYTES 102
143#define RAND_F_FIPS_RAND_GET_RAND_METHOD 109
144#define RAND_F_FIPS_RAND_SET_DT 106
145#define RAND_F_FIPS_SET_DT 104
146#define RAND_F_FIPS_SET_PRNG_SEED 107
147#define RAND_F_FIPS_SET_TEST_MODE 105
148#define RAND_F_RAND_GET_RAND_METHOD 101 131#define RAND_F_RAND_GET_RAND_METHOD 101
149#define RAND_F_SSLEAY_RAND_BYTES 100 132#define RAND_F_SSLEAY_RAND_BYTES 100
150 133
151/* Reason codes. */ 134/* Reason codes. */
152#define RAND_R_NON_FIPS_METHOD 105
153#define RAND_R_NOT_IN_TEST_MODE 106
154#define RAND_R_NO_KEY_SET 107
155#define RAND_R_PRNG_ASKING_FOR_TOO_MUCH 101
156#define RAND_R_PRNG_ERROR 108
157#define RAND_R_PRNG_KEYED 109
158#define RAND_R_PRNG_NOT_REKEYED 102
159#define RAND_R_PRNG_NOT_RESEEDED 103
160#define RAND_R_PRNG_NOT_SEEDED 100 135#define RAND_R_PRNG_NOT_SEEDED 100
161#define RAND_R_PRNG_SEED_MUST_NOT_MATCH_KEY 110
162#define RAND_R_PRNG_STUCK 104
163 136
164#ifdef __cplusplus 137#ifdef __cplusplus
165} 138}
diff --git a/src/lib/libcrypto/rand/rand_egd.c b/src/lib/libcrypto/rand/rand_egd.c
index 50bce6caba..d53b916ebe 100644
--- a/src/lib/libcrypto/rand/rand_egd.c
+++ b/src/lib/libcrypto/rand/rand_egd.c
@@ -95,7 +95,7 @@
95 * RAND_egd() is a wrapper for RAND_egd_bytes() with numbytes=255. 95 * RAND_egd() is a wrapper for RAND_egd_bytes() with numbytes=255.
96 */ 96 */
97 97
98#if defined(OPENSSL_SYS_WIN32) || defined(OPENSSL_SYS_VMS) || defined(OPENSSL_SYS_MSDOS) || defined(OPENSSL_SYS_VXWORKS) || defined(OPENSSL_SYS_NETWARE) || defined(OPENSSL_SYS_VOS) 98#if defined(OPENSSL_SYS_WIN32) || defined(OPENSSL_SYS_VMS) || defined(OPENSSL_SYS_MSDOS) || defined(OPENSSL_SYS_VXWORKS) || defined(OPENSSL_SYS_NETWARE) || defined(OPENSSL_SYS_VOS) || defined(OPENSSL_SYS_BEOS)
99int RAND_query_egd_bytes(const char *path, unsigned char *buf, int bytes) 99int RAND_query_egd_bytes(const char *path, unsigned char *buf, int bytes)
100 { 100 {
101 return(-1); 101 return(-1);
diff --git a/src/lib/libcrypto/rand/rand_eng.c b/src/lib/libcrypto/rand/rand_eng.c
deleted file mode 100644
index 1669cef43c..0000000000
--- a/src/lib/libcrypto/rand/rand_eng.c
+++ /dev/null
@@ -1,152 +0,0 @@
1/* crypto/rand/rand_lib.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 <time.h>
61#include "cryptlib.h"
62#include "rand_lcl.h"
63#include <openssl/rand.h>
64#ifdef OPENSSL_FIPS
65#include <openssl/fips.h>
66#include <openssl/fips_rand.h>
67#endif
68
69#ifndef OPENSSL_NO_ENGINE
70#include <openssl/engine.h>
71#endif
72
73#if defined(OPENSSL_FIPS) && !defined(OPENSSL_NO_ENGINE)
74
75/* non-NULL if default_RAND_meth is ENGINE-provided */
76static ENGINE *funct_ref =NULL;
77
78int eng_RAND_set_rand_method(const RAND_METHOD *meth, const RAND_METHOD **pmeth)
79 {
80 if(funct_ref)
81 {
82 ENGINE_finish(funct_ref);
83 funct_ref = NULL;
84 }
85 *pmeth = meth;
86 return 1;
87 }
88
89const RAND_METHOD *eng_RAND_get_rand_method(const RAND_METHOD **pmeth)
90 {
91 if (!*pmeth)
92 {
93 ENGINE *e = ENGINE_get_default_RAND();
94 if(e)
95 {
96 *pmeth = ENGINE_get_RAND(e);
97 if(!*pmeth)
98 {
99 ENGINE_finish(e);
100 e = NULL;
101 }
102 }
103 if(e)
104 funct_ref = e;
105 else
106 if(FIPS_mode())
107 *pmeth=FIPS_rand_method();
108 else
109 *pmeth = RAND_SSLeay();
110 }
111
112 if(FIPS_mode()
113 && *pmeth != FIPS_rand_check())
114 {
115 RANDerr(RAND_F_ENG_RAND_GET_RAND_METHOD,RAND_R_NON_FIPS_METHOD);
116 return 0;
117 }
118
119 return *pmeth;
120 }
121
122int RAND_set_rand_engine(ENGINE *engine)
123 {
124 const RAND_METHOD *tmp_meth = NULL;
125 if(engine)
126 {
127 if(!ENGINE_init(engine))
128 return 0;
129 tmp_meth = ENGINE_get_RAND(engine);
130 if(!tmp_meth)
131 {
132 ENGINE_finish(engine);
133 return 0;
134 }
135 }
136 /* This function releases any prior ENGINE so call it first */
137 RAND_set_rand_method(tmp_meth);
138 funct_ref = engine;
139 return 1;
140 }
141
142void int_RAND_init_engine_callbacks(void)
143 {
144 static int done = 0;
145 if (done)
146 return;
147 int_RAND_set_callbacks(eng_RAND_set_rand_method,
148 eng_RAND_get_rand_method);
149 done = 1;
150 }
151
152#endif
diff --git a/src/lib/libcrypto/rand/rand_err.c b/src/lib/libcrypto/rand/rand_err.c
index 829fb44d77..03cda4dd92 100644
--- a/src/lib/libcrypto/rand/rand_err.c
+++ b/src/lib/libcrypto/rand/rand_err.c
@@ -1,6 +1,6 @@
1/* crypto/rand/rand_err.c */ 1/* crypto/rand/rand_err.c */
2/* ==================================================================== 2/* ====================================================================
3 * Copyright (c) 1999-2007 The OpenSSL Project. All rights reserved. 3 * Copyright (c) 1999-2006 The OpenSSL Project. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
@@ -70,14 +70,6 @@
70 70
71static ERR_STRING_DATA RAND_str_functs[]= 71static ERR_STRING_DATA RAND_str_functs[]=
72 { 72 {
73{ERR_FUNC(RAND_F_ENG_RAND_GET_RAND_METHOD), "ENG_RAND_GET_RAND_METHOD"},
74{ERR_FUNC(RAND_F_FIPS_RAND), "FIPS_RAND"},
75{ERR_FUNC(RAND_F_FIPS_RAND_BYTES), "FIPS_RAND_BYTES"},
76{ERR_FUNC(RAND_F_FIPS_RAND_GET_RAND_METHOD), "FIPS_RAND_GET_RAND_METHOD"},
77{ERR_FUNC(RAND_F_FIPS_RAND_SET_DT), "FIPS_RAND_SET_DT"},
78{ERR_FUNC(RAND_F_FIPS_SET_DT), "FIPS_SET_DT"},
79{ERR_FUNC(RAND_F_FIPS_SET_PRNG_SEED), "FIPS_SET_PRNG_SEED"},
80{ERR_FUNC(RAND_F_FIPS_SET_TEST_MODE), "FIPS_SET_TEST_MODE"},
81{ERR_FUNC(RAND_F_RAND_GET_RAND_METHOD), "RAND_get_rand_method"}, 73{ERR_FUNC(RAND_F_RAND_GET_RAND_METHOD), "RAND_get_rand_method"},
82{ERR_FUNC(RAND_F_SSLEAY_RAND_BYTES), "SSLEAY_RAND_BYTES"}, 74{ERR_FUNC(RAND_F_SSLEAY_RAND_BYTES), "SSLEAY_RAND_BYTES"},
83{0,NULL} 75{0,NULL}
@@ -85,17 +77,7 @@ static ERR_STRING_DATA RAND_str_functs[]=
85 77
86static ERR_STRING_DATA RAND_str_reasons[]= 78static ERR_STRING_DATA RAND_str_reasons[]=
87 { 79 {
88{ERR_REASON(RAND_R_NON_FIPS_METHOD) ,"non fips method"},
89{ERR_REASON(RAND_R_NOT_IN_TEST_MODE) ,"not in test mode"},
90{ERR_REASON(RAND_R_NO_KEY_SET) ,"no key set"},
91{ERR_REASON(RAND_R_PRNG_ASKING_FOR_TOO_MUCH),"prng asking for too much"},
92{ERR_REASON(RAND_R_PRNG_ERROR) ,"prng error"},
93{ERR_REASON(RAND_R_PRNG_KEYED) ,"prng keyed"},
94{ERR_REASON(RAND_R_PRNG_NOT_REKEYED) ,"prng not rekeyed"},
95{ERR_REASON(RAND_R_PRNG_NOT_RESEEDED) ,"prng not reseeded"},
96{ERR_REASON(RAND_R_PRNG_NOT_SEEDED) ,"PRNG not seeded"}, 80{ERR_REASON(RAND_R_PRNG_NOT_SEEDED) ,"PRNG not seeded"},
97{ERR_REASON(RAND_R_PRNG_SEED_MUST_NOT_MATCH_KEY),"prng seed must not match key"},
98{ERR_REASON(RAND_R_PRNG_STUCK) ,"prng stuck"},
99{0,NULL} 81{0,NULL}
100 }; 82 };
101 83
diff --git a/src/lib/libcrypto/rand/rand_lcl.h b/src/lib/libcrypto/rand/rand_lcl.h
index 18cc9b1e4a..618a8ec899 100644
--- a/src/lib/libcrypto/rand/rand_lcl.h
+++ b/src/lib/libcrypto/rand/rand_lcl.h
@@ -154,16 +154,5 @@
154#define MD(a,b,c) EVP_Digest(a,b,c,NULL,EVP_md2(), NULL) 154#define MD(a,b,c) EVP_Digest(a,b,c,NULL,EVP_md2(), NULL)
155#endif 155#endif
156 156
157#ifndef OPENSSL_NO_ENGINE
158void int_RAND_set_callbacks(
159 int (*set_rand_func)(const RAND_METHOD *meth,
160 const RAND_METHOD **pmeth),
161 const RAND_METHOD *(*get_rand_func)
162 (const RAND_METHOD **pmeth));
163int eng_RAND_set_rand_method(const RAND_METHOD *meth,
164 const RAND_METHOD **pmeth);
165const RAND_METHOD *eng_RAND_get_rand_method(const RAND_METHOD **pmeth);
166#endif
167
168 157
169#endif 158#endif
diff --git a/src/lib/libcrypto/rand/rand_lib.c b/src/lib/libcrypto/rand/rand_lib.c
index da6b4e0e86..513e338985 100644
--- a/src/lib/libcrypto/rand/rand_lib.c
+++ b/src/lib/libcrypto/rand/rand_lib.c
@@ -60,82 +60,15 @@
60#include <time.h> 60#include <time.h>
61#include "cryptlib.h" 61#include "cryptlib.h"
62#include <openssl/rand.h> 62#include <openssl/rand.h>
63#include "rand_lcl.h"
64#ifdef OPENSSL_FIPS
65#include <openssl/fips.h>
66#include <openssl/fips_rand.h>
67#endif
68
69#ifndef OPENSSL_NO_ENGINE 63#ifndef OPENSSL_NO_ENGINE
70#include <openssl/engine.h> 64#include <openssl/engine.h>
71#endif 65#endif
72 66
73static const RAND_METHOD *default_RAND_meth = NULL;
74
75#ifdef OPENSSL_FIPS
76
77static int fips_RAND_set_rand_method(const RAND_METHOD *meth,
78 const RAND_METHOD **pmeth)
79 {
80 *pmeth = meth;
81 return 1;
82 }
83
84static const RAND_METHOD *fips_RAND_get_rand_method(const RAND_METHOD **pmeth)
85 {
86 if (!*pmeth)
87 {
88 if(FIPS_mode())
89 *pmeth=FIPS_rand_method();
90 else
91 *pmeth = RAND_SSLeay();
92 }
93
94 if(FIPS_mode()
95 && *pmeth != FIPS_rand_check())
96 {
97 RANDerr(RAND_F_FIPS_RAND_GET_RAND_METHOD,RAND_R_NON_FIPS_METHOD);
98 return 0;
99 }
100
101 return *pmeth;
102 }
103
104static int (*RAND_set_rand_method_func)(const RAND_METHOD *meth,
105 const RAND_METHOD **pmeth)
106 = fips_RAND_set_rand_method;
107static const RAND_METHOD *(*RAND_get_rand_method_func)
108 (const RAND_METHOD **pmeth)
109 = fips_RAND_get_rand_method;
110
111#ifndef OPENSSL_NO_ENGINE
112void int_RAND_set_callbacks(
113 int (*set_rand_func)(const RAND_METHOD *meth,
114 const RAND_METHOD **pmeth),
115 const RAND_METHOD *(*get_rand_func)
116 (const RAND_METHOD **pmeth))
117 {
118 RAND_set_rand_method_func = set_rand_func;
119 RAND_get_rand_method_func = get_rand_func;
120 }
121#endif
122
123int RAND_set_rand_method(const RAND_METHOD *meth)
124 {
125 return RAND_set_rand_method_func(meth, &default_RAND_meth);
126 }
127
128const RAND_METHOD *RAND_get_rand_method(void)
129 {
130 return RAND_get_rand_method_func(&default_RAND_meth);
131 }
132
133#else
134
135#ifndef OPENSSL_NO_ENGINE 67#ifndef OPENSSL_NO_ENGINE
136/* non-NULL if default_RAND_meth is ENGINE-provided */ 68/* non-NULL if default_RAND_meth is ENGINE-provided */
137static ENGINE *funct_ref =NULL; 69static ENGINE *funct_ref =NULL;
138#endif 70#endif
71static const RAND_METHOD *default_RAND_meth = NULL;
139 72
140int RAND_set_rand_method(const RAND_METHOD *meth) 73int RAND_set_rand_method(const RAND_METHOD *meth)
141 { 74 {
@@ -196,8 +129,6 @@ int RAND_set_rand_engine(ENGINE *engine)
196 } 129 }
197#endif 130#endif
198 131
199#endif
200
201void RAND_cleanup(void) 132void RAND_cleanup(void)
202 { 133 {
203 const RAND_METHOD *meth = RAND_get_rand_method(); 134 const RAND_METHOD *meth = RAND_get_rand_method();
diff --git a/src/lib/libcrypto/rand/rand_os2.c b/src/lib/libcrypto/rand/rand_os2.c
index c3e36d4e5e..fc1e78b179 100644
--- a/src/lib/libcrypto/rand/rand_os2.c
+++ b/src/lib/libcrypto/rand/rand_os2.c
@@ -78,8 +78,10 @@ typedef struct _CPUUTIL {
78 ULONG ulIntrHigh; /* High 32 bits of interrupt time */ 78 ULONG ulIntrHigh; /* High 32 bits of interrupt time */
79} CPUUTIL; 79} CPUUTIL;
80 80
81#ifndef __KLIBC__
81APIRET APIENTRY(*DosPerfSysCall) (ULONG ulCommand, ULONG ulParm1, ULONG ulParm2, ULONG ulParm3) = NULL; 82APIRET APIENTRY(*DosPerfSysCall) (ULONG ulCommand, ULONG ulParm1, ULONG ulParm2, ULONG ulParm3) = NULL;
82APIRET APIENTRY(*DosQuerySysState) (ULONG func, ULONG arg1, ULONG pid, ULONG _res_, PVOID buf, ULONG bufsz) = NULL; 83APIRET APIENTRY(*DosQuerySysState) (ULONG func, ULONG arg1, ULONG pid, ULONG _res_, PVOID buf, ULONG bufsz) = NULL;
84#endif
83HMODULE hDoscalls = 0; 85HMODULE hDoscalls = 0;
84 86
85int RAND_poll(void) 87int RAND_poll(void)
@@ -91,6 +93,7 @@ int RAND_poll(void)
91 if (hDoscalls == 0) { 93 if (hDoscalls == 0) {
92 ULONG rc = DosLoadModule(failed_module, sizeof(failed_module), "DOSCALLS", &hDoscalls); 94 ULONG rc = DosLoadModule(failed_module, sizeof(failed_module), "DOSCALLS", &hDoscalls);
93 95
96#ifndef __KLIBC__
94 if (rc == 0) { 97 if (rc == 0) {
95 rc = DosQueryProcAddr(hDoscalls, 976, NULL, (PFN *)&DosPerfSysCall); 98 rc = DosQueryProcAddr(hDoscalls, 976, NULL, (PFN *)&DosPerfSysCall);
96 99
@@ -102,6 +105,7 @@ int RAND_poll(void)
102 if (rc) 105 if (rc)
103 DosQuerySysState = NULL; 106 DosQuerySysState = NULL;
104 } 107 }
108#endif
105 } 109 }
106 110
107 /* Sample the hi-res timer, runs at around 1.1 MHz */ 111 /* Sample the hi-res timer, runs at around 1.1 MHz */
@@ -122,7 +126,9 @@ int RAND_poll(void)
122 RAND_add(&util, sizeof(util), 10); 126 RAND_add(&util, sizeof(util), 10);
123 } 127 }
124 else { 128 else {
129#ifndef __KLIBC__
125 DosPerfSysCall = NULL; 130 DosPerfSysCall = NULL;
131#endif
126 } 132 }
127 } 133 }
128 134
diff --git a/src/lib/libcrypto/rand/rand_unix.c b/src/lib/libcrypto/rand/rand_unix.c
index 58c6173094..4bb9666e49 100644
--- a/src/lib/libcrypto/rand/rand_unix.c
+++ b/src/lib/libcrypto/rand/rand_unix.c
@@ -133,7 +133,50 @@
133# define FD_SETSIZE (8*sizeof(fd_set)) 133# define FD_SETSIZE (8*sizeof(fd_set))
134#endif 134#endif
135 135
136#ifdef __OpenBSD__ 136#ifdef __VOS__
137int RAND_poll(void)
138{
139 unsigned char buf[ENTROPY_NEEDED];
140 pid_t curr_pid;
141 uid_t curr_uid;
142 static int first=1;
143 int i;
144 long rnd = 0;
145 struct timespec ts;
146 unsigned seed;
147
148/* The VOS random() function starts from a static seed so its
149 initial value is predictable. If random() returns the
150 initial value, reseed it with dynamic data. The VOS
151 real-time clock has a granularity of 1 nsec so it should be
152 reasonably difficult to predict its exact value. Do not
153 gratuitously reseed the PRNG because other code in this
154 process or thread may be using it. */
155
156 if (first) {
157 first = 0;
158 rnd = random ();
159 if (rnd == 1804289383) {
160 clock_gettime (CLOCK_REALTIME, &ts);
161 curr_pid = getpid();
162 curr_uid = getuid();
163 seed = ts.tv_sec ^ ts.tv_nsec ^ curr_pid ^ curr_uid;
164 srandom (seed);
165 }
166 }
167
168 for (i = 0; i < sizeof(buf); i++) {
169 if (i % 4 == 0)
170 rnd = random();
171 buf[i] = rnd;
172 rnd >>= 8;
173 }
174 RAND_add(buf, sizeof(buf), ENTROPY_NEEDED);
175 memset(buf, 0, sizeof(buf));
176
177 return 1;
178}
179#elif defined __OpenBSD__
137int RAND_poll(void) 180int RAND_poll(void)
138{ 181{
139 unsigned char buf[ENTROPY_NEEDED]; 182 unsigned char buf[ENTROPY_NEEDED];
@@ -157,7 +200,7 @@ int RAND_poll(void)
157 static const char *randomfiles[] = { DEVRANDOM }; 200 static const char *randomfiles[] = { DEVRANDOM };
158 struct stat randomstats[sizeof(randomfiles)/sizeof(randomfiles[0])]; 201 struct stat randomstats[sizeof(randomfiles)/sizeof(randomfiles[0])];
159 int fd; 202 int fd;
160 size_t i; 203 unsigned int i;
161#endif 204#endif
162#ifdef DEVRANDOM_EGD 205#ifdef DEVRANDOM_EGD
163 static const char *egdsockets[] = { DEVRANDOM_EGD, NULL }; 206 static const char *egdsockets[] = { DEVRANDOM_EGD, NULL };
@@ -170,7 +213,8 @@ int RAND_poll(void)
170 * have this. Use /dev/urandom if you can as /dev/random may block 213 * have this. Use /dev/urandom if you can as /dev/random may block
171 * if it runs out of random entries. */ 214 * if it runs out of random entries. */
172 215
173 for (i=0; i<sizeof(randomfiles)/sizeof(randomfiles[0]) && n < ENTROPY_NEEDED; i++) 216 for (i = 0; (i < sizeof(randomfiles)/sizeof(randomfiles[0])) &&
217 (n < ENTROPY_NEEDED); i++)
174 { 218 {
175 if ((fd = open(randomfiles[i], O_RDONLY 219 if ((fd = open(randomfiles[i], O_RDONLY
176#ifdef O_NONBLOCK 220#ifdef O_NONBLOCK
@@ -187,7 +231,7 @@ int RAND_poll(void)
187 { 231 {
188 int usec = 10*1000; /* spend 10ms on each file */ 232 int usec = 10*1000; /* spend 10ms on each file */
189 int r; 233 int r;
190 size_t j; 234 unsigned int j;
191 struct stat *st=&randomstats[i]; 235 struct stat *st=&randomstats[i];
192 236
193 /* Avoid using same input... Used to be O_NOFOLLOW 237 /* Avoid using same input... Used to be O_NOFOLLOW
@@ -205,7 +249,12 @@ int RAND_poll(void)
205 { 249 {
206 int try_read = 0; 250 int try_read = 0;
207 251
208#if defined(OPENSSL_SYS_LINUX) 252#if defined(OPENSSL_SYS_BEOS_R5)
253 /* select() is broken in BeOS R5, so we simply
254 * try to read something and snooze if we couldn't */
255 try_read = 1;
256
257#elif defined(OPENSSL_SYS_LINUX)
209 /* use poll() */ 258 /* use poll() */
210 struct pollfd pset; 259 struct pollfd pset;
211 260
@@ -252,6 +301,10 @@ int RAND_poll(void)
252 r = read(fd,(unsigned char *)tmpbuf+n, ENTROPY_NEEDED-n); 301 r = read(fd,(unsigned char *)tmpbuf+n, ENTROPY_NEEDED-n);
253 if (r > 0) 302 if (r > 0)
254 n += r; 303 n += r;
304#if defined(OPENSSL_SYS_BEOS_R5)
305 if (r == 0)
306 snooze(t.tv_usec);
307#endif
255 } 308 }
256 else 309 else
257 r = -1; 310 r = -1;
@@ -305,6 +358,14 @@ int RAND_poll(void)
305 l=time(NULL); 358 l=time(NULL);
306 RAND_add(&l,sizeof(l),0.0); 359 RAND_add(&l,sizeof(l),0.0);
307 360
361#if defined(OPENSSL_SYS_BEOS)
362 {
363 system_info sysInfo;
364 get_system_info(&sysInfo);
365 RAND_add(&sysInfo,sizeof(sysInfo),0);
366 }
367#endif
368
308#if defined(DEVRANDOM) || defined(DEVRANDOM_EGD) 369#if defined(DEVRANDOM) || defined(DEVRANDOM_EGD)
309 return 1; 370 return 1;
310#else 371#else
diff --git a/src/lib/libcrypto/rand/rand_win.c b/src/lib/libcrypto/rand/rand_win.c
index 00dbe4232c..5d134e186b 100644
--- a/src/lib/libcrypto/rand/rand_win.c
+++ b/src/lib/libcrypto/rand/rand_win.c
@@ -463,7 +463,7 @@ int RAND_poll(void)
463 PROCESSENTRY32 p; 463 PROCESSENTRY32 p;
464 THREADENTRY32 t; 464 THREADENTRY32 t;
465 MODULEENTRY32 m; 465 MODULEENTRY32 m;
466 DWORD stoptime = 0; 466 DWORD starttime = 0;
467 467
468 snap = (CREATETOOLHELP32SNAPSHOT) 468 snap = (CREATETOOLHELP32SNAPSHOT)
469 GetProcAddress(kernel, "CreateToolhelp32Snapshot"); 469 GetProcAddress(kernel, "CreateToolhelp32Snapshot");
@@ -494,12 +494,29 @@ int RAND_poll(void)
494 * each entry. Consider each field a source of 1 byte 494 * each entry. Consider each field a source of 1 byte
495 * of entropy. 495 * of entropy.
496 */ 496 */
497 ZeroMemory(&hlist, sizeof(HEAPLIST32));
497 hlist.dwSize = sizeof(HEAPLIST32); 498 hlist.dwSize = sizeof(HEAPLIST32);
498 if (good) stoptime = GetTickCount() + MAXDELAY; 499 if (good) starttime = GetTickCount();
500#ifdef _MSC_VER
499 if (heaplist_first(handle, &hlist)) 501 if (heaplist_first(handle, &hlist))
502 {
503 /*
504 following discussion on dev ML, exception on WinCE (or other Win
505 platform) is theoretically of unknown origin; prevent infinite
506 loop here when this theoretical case occurs; otherwise cope with
507 the expected (MSDN documented) exception-throwing behaviour of
508 Heap32Next() on WinCE.
509
510 based on patch in original message by Tanguy Fautré (2009/03/02)
511 Subject: RAND_poll() and CreateToolhelp32Snapshot() stability
512 */
513 int ex_cnt_limit = 42;
500 do 514 do
501 { 515 {
502 RAND_add(&hlist, hlist.dwSize, 3); 516 RAND_add(&hlist, hlist.dwSize, 3);
517 __try
518 {
519 ZeroMemory(&hentry, sizeof(HEAPENTRY32));
503 hentry.dwSize = sizeof(HEAPENTRY32); 520 hentry.dwSize = sizeof(HEAPENTRY32);
504 if (heap_first(&hentry, 521 if (heap_first(&hentry,
505 hlist.th32ProcessID, 522 hlist.th32ProcessID,
@@ -510,10 +527,42 @@ int RAND_poll(void)
510 RAND_add(&hentry, 527 RAND_add(&hentry,
511 hentry.dwSize, 5); 528 hentry.dwSize, 5);
512 while (heap_next(&hentry) 529 while (heap_next(&hentry)
530 && (!good || (GetTickCount()-starttime)<MAXDELAY)
513 && --entrycnt > 0); 531 && --entrycnt > 0);
514 } 532 }
515 } while (heaplist_next(handle, 533 }
516 &hlist) && GetTickCount() < stoptime); 534 __except (EXCEPTION_EXECUTE_HANDLER)
535 {
536 /* ignore access violations when walking the heap list */
537 ex_cnt_limit--;
538 }
539 } while (heaplist_next(handle, &hlist)
540 && (!good || (GetTickCount()-starttime)<MAXDELAY)
541 && ex_cnt_limit > 0);
542 }
543
544#else
545 if (heaplist_first(handle, &hlist))
546 {
547 do
548 {
549 RAND_add(&hlist, hlist.dwSize, 3);
550 hentry.dwSize = sizeof(HEAPENTRY32);
551 if (heap_first(&hentry,
552 hlist.th32ProcessID,
553 hlist.th32HeapID))
554 {
555 int entrycnt = 80;
556 do
557 RAND_add(&hentry,
558 hentry.dwSize, 5);
559 while (heap_next(&hentry)
560 && --entrycnt > 0);
561 }
562 } while (heaplist_next(handle, &hlist)
563 && (!good || (GetTickCount()-starttime)<MAXDELAY));
564 }
565#endif
517 566
518 /* process walking */ 567 /* process walking */
519 /* PROCESSENTRY32 contains 9 fields that will change 568 /* PROCESSENTRY32 contains 9 fields that will change
@@ -522,11 +571,11 @@ int RAND_poll(void)
522 */ 571 */
523 p.dwSize = sizeof(PROCESSENTRY32); 572 p.dwSize = sizeof(PROCESSENTRY32);
524 573
525 if (good) stoptime = GetTickCount() + MAXDELAY; 574 if (good) starttime = GetTickCount();
526 if (process_first(handle, &p)) 575 if (process_first(handle, &p))
527 do 576 do
528 RAND_add(&p, p.dwSize, 9); 577 RAND_add(&p, p.dwSize, 9);
529 while (process_next(handle, &p) && GetTickCount() < stoptime); 578 while (process_next(handle, &p) && (!good || (GetTickCount()-starttime)<MAXDELAY));
530 579
531 /* thread walking */ 580 /* thread walking */
532 /* THREADENTRY32 contains 6 fields that will change 581 /* THREADENTRY32 contains 6 fields that will change
@@ -534,11 +583,11 @@ int RAND_poll(void)
534 * 1 byte of entropy. 583 * 1 byte of entropy.
535 */ 584 */
536 t.dwSize = sizeof(THREADENTRY32); 585 t.dwSize = sizeof(THREADENTRY32);
537 if (good) stoptime = GetTickCount() + MAXDELAY; 586 if (good) starttime = GetTickCount();
538 if (thread_first(handle, &t)) 587 if (thread_first(handle, &t))
539 do 588 do
540 RAND_add(&t, t.dwSize, 6); 589 RAND_add(&t, t.dwSize, 6);
541 while (thread_next(handle, &t) && GetTickCount() < stoptime); 590 while (thread_next(handle, &t) && (!good || (GetTickCount()-starttime)<MAXDELAY));
542 591
543 /* module walking */ 592 /* module walking */
544 /* MODULEENTRY32 contains 9 fields that will change 593 /* MODULEENTRY32 contains 9 fields that will change
@@ -546,12 +595,12 @@ int RAND_poll(void)
546 * 1 byte of entropy. 595 * 1 byte of entropy.
547 */ 596 */
548 m.dwSize = sizeof(MODULEENTRY32); 597 m.dwSize = sizeof(MODULEENTRY32);
549 if (good) stoptime = GetTickCount() + MAXDELAY; 598 if (good) starttime = GetTickCount();
550 if (module_first(handle, &m)) 599 if (module_first(handle, &m))
551 do 600 do
552 RAND_add(&m, m.dwSize, 9); 601 RAND_add(&m, m.dwSize, 9);
553 while (module_next(handle, &m) 602 while (module_next(handle, &m)
554 && (GetTickCount() < stoptime)); 603 && (!good || (GetTickCount()-starttime)<MAXDELAY));
555 if (close_snap) 604 if (close_snap)
556 close_snap(handle); 605 close_snap(handle);
557 else 606 else
@@ -701,7 +750,7 @@ static void readscreen(void)
701 int y; /* y-coordinate of screen lines to grab */ 750 int y; /* y-coordinate of screen lines to grab */
702 int n = 16; /* number of screen lines to grab at a time */ 751 int n = 16; /* number of screen lines to grab at a time */
703 752
704 if (GetVersion() >= 0x80000000 || !OPENSSL_isservice()) 753 if (GetVersion() < 0x80000000 && OPENSSL_isservice()>0)
705 return; 754 return;
706 755
707 /* Create a screen DC and a memory DC compatible to screen DC */ 756 /* Create a screen DC and a memory DC compatible to screen DC */
diff --git a/src/lib/libcrypto/rand/randfile.c b/src/lib/libcrypto/rand/randfile.c
index d108353bbc..4ed40b7b70 100644
--- a/src/lib/libcrypto/rand/randfile.c
+++ b/src/lib/libcrypto/rand/randfile.c
@@ -75,9 +75,7 @@
75#ifndef NO_SYS_TYPES_H 75#ifndef NO_SYS_TYPES_H
76# include <sys/types.h> 76# include <sys/types.h>
77#endif 77#endif
78#ifdef MAC_OS_pre_X 78#ifndef OPENSSL_NO_POSIX_IO
79# include <stat.h>
80#else
81# include <sys/stat.h> 79# include <sys/stat.h>
82#endif 80#endif
83 81
@@ -111,14 +109,26 @@ int RAND_load_file(const char *file, long bytes)
111 * if bytes == -1, read complete file. */ 109 * if bytes == -1, read complete file. */
112 110
113 MS_STATIC unsigned char buf[BUFSIZE]; 111 MS_STATIC unsigned char buf[BUFSIZE];
112#ifndef OPENSSL_NO_POSIX_IO
114 struct stat sb; 113 struct stat sb;
114#endif
115 int i,ret=0,n; 115 int i,ret=0,n;
116 FILE *in; 116 FILE *in;
117 117
118 if (file == NULL) return(0); 118 if (file == NULL) return(0);
119 119
120#ifndef OPENSSL_NO_POSIX_IO
121#ifdef PURIFY
122 /* struct stat can have padding and unused fields that may not be
123 * initialized in the call to stat(). We need to clear the entire
124 * structure before calling RAND_add() to avoid complaints from
125 * applications such as Valgrind.
126 */
127 memset(&sb, 0, sizeof(sb));
128#endif
120 if (stat(file,&sb) < 0) return(0); 129 if (stat(file,&sb) < 0) return(0);
121 RAND_add(&sb,sizeof(sb),0.0); 130 RAND_add(&sb,sizeof(sb),0.0);
131#endif
122 if (bytes == 0) return(ret); 132 if (bytes == 0) return(ret);
123 133
124#ifdef OPENSSL_SYS_VMS 134#ifdef OPENSSL_SYS_VMS
@@ -127,7 +137,7 @@ int RAND_load_file(const char *file, long bytes)
127 in=fopen(file,"rb"); 137 in=fopen(file,"rb");
128#endif 138#endif
129 if (in == NULL) goto err; 139 if (in == NULL) goto err;
130#if defined(S_IFBLK) && defined(S_IFCHR) 140#if defined(S_IFBLK) && defined(S_IFCHR) && !defined(OPNESSL_NO_POSIX_IO)
131 if (sb.st_mode & (S_IFBLK | S_IFCHR)) { 141 if (sb.st_mode & (S_IFBLK | S_IFCHR)) {
132 /* this file is a device. we don't want read an infinite number 142 /* this file is a device. we don't want read an infinite number
133 * of bytes from a random device, nor do we want to use buffered 143 * of bytes from a random device, nor do we want to use buffered
@@ -170,12 +180,13 @@ int RAND_write_file(const char *file)
170 int i,ret=0,rand_err=0; 180 int i,ret=0,rand_err=0;
171 FILE *out = NULL; 181 FILE *out = NULL;
172 int n; 182 int n;
183#ifndef OPENSSL_NO_POSIX_IO
173 struct stat sb; 184 struct stat sb;
174 185
175 i=stat(file,&sb); 186 i=stat(file,&sb);
176 if (i != -1) { 187 if (i != -1) {
177#if defined(S_IFBLK) && defined(S_IFCHR) 188#if defined(S_ISBLK) && defined(S_ISCHR)
178 if (sb.st_mode & (S_IFBLK | S_IFCHR)) { 189 if (S_ISBLK(sb.st_mode) || S_ISCHR(sb.st_mode)) {
179 /* this file is a device. we don't write back to it. 190 /* this file is a device. we don't write back to it.
180 * we "succeed" on the assumption this is some sort 191 * we "succeed" on the assumption this is some sort
181 * of random device. Otherwise attempting to write to 192 * of random device. Otherwise attempting to write to
@@ -185,14 +196,16 @@ int RAND_write_file(const char *file)
185 } 196 }
186#endif 197#endif
187 } 198 }
199#endif
188 200
189#if defined(O_CREAT) && !defined(OPENSSL_SYS_WIN32) && !defined(OPENSSL_SYS_VMS) 201#if defined(O_CREAT) && !defined(OPENSSL_NO_POSIX_IO) && !defined(OPENSSL_SYS_VMS)
190 { 202 {
191 /* For some reason Win32 can't write to files created this way */ 203#ifndef O_BINARY
192 204#define O_BINARY 0
205#endif
193 /* chmod(..., 0600) is too late to protect the file, 206 /* chmod(..., 0600) is too late to protect the file,
194 * permissions should be restrictive from the start */ 207 * permissions should be restrictive from the start */
195 int fd = open(file, O_CREAT, 0600); 208 int fd = open(file, O_WRONLY|O_CREAT|O_BINARY, 0600);
196 if (fd != -1) 209 if (fd != -1)
197 out = fdopen(fd, "wb"); 210 out = fdopen(fd, "wb");
198 } 211 }
diff --git a/src/lib/libcrypto/rc2/Makefile.ssl b/src/lib/libcrypto/rc2/Makefile.ssl
deleted file mode 100644
index 98d5960d5d..0000000000
--- a/src/lib/libcrypto/rc2/Makefile.ssl
+++ /dev/null
@@ -1,91 +0,0 @@
1#
2# SSLeay/crypto/rc2/Makefile
3#
4
5DIR= rc2
6TOP= ../..
7CC= cc
8INCLUDES=
9CFLAG=-g
10INSTALL_PREFIX=
11OPENSSLDIR= /usr/local/ssl
12INSTALLTOP=/usr/local/ssl
13MAKE= make -f Makefile.ssl
14MAKEDEPPROG= makedepend
15MAKEDEPEND= $(TOP)/util/domd $(TOP) -MD $(MAKEDEPPROG)
16MAKEFILE= Makefile.ssl
17AR= ar r
18
19CFLAGS= $(INCLUDES) $(CFLAG)
20
21GENERAL=Makefile
22TEST=rc2test.c
23APPS=
24
25LIB=$(TOP)/libcrypto.a
26LIBSRC=rc2_ecb.c rc2_skey.c rc2_cbc.c rc2cfb64.c rc2ofb64.c
27LIBOBJ=rc2_ecb.o rc2_skey.o rc2_cbc.o rc2cfb64.o rc2ofb64.o
28
29SRC= $(LIBSRC)
30
31EXHEADER= rc2.h
32HEADER= rc2_locl.h $(EXHEADER)
33
34ALL= $(GENERAL) $(SRC) $(HEADER)
35
36top:
37 (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all)
38
39all: lib
40
41lib: $(LIBOBJ)
42 $(AR) $(LIB) $(LIBOBJ)
43 $(RANLIB) $(LIB) || echo Never mind.
44 @touch lib
45
46files:
47 $(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO
48
49links:
50 @sh $(TOP)/util/point.sh Makefile.ssl Makefile
51 @$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER)
52 @$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST)
53 @$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS)
54
55install:
56 @for i in $(EXHEADER) ; \
57 do \
58 (cp $$i $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i; \
59 chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i ); \
60 done;
61
62tags:
63 ctags $(SRC)
64
65tests:
66
67lint:
68 lint -DLINT $(INCLUDES) $(SRC)>fluff
69
70depend:
71 $(MAKEDEPEND) -- $(CFLAG) $(INCLUDES) $(DEPFLAG) -- $(PROGS) $(LIBSRC)
72
73dclean:
74 $(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
75 mv -f Makefile.new $(MAKEFILE)
76
77clean:
78 rm -f *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff
79
80# DO NOT DELETE THIS LINE -- make depend depends on it.
81
82rc2_cbc.o: ../../include/openssl/opensslconf.h ../../include/openssl/rc2.h
83rc2_cbc.o: rc2_cbc.c rc2_locl.h
84rc2_ecb.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
85rc2_ecb.o: ../../include/openssl/rc2.h rc2_ecb.c rc2_locl.h
86rc2_skey.o: ../../include/openssl/opensslconf.h ../../include/openssl/rc2.h
87rc2_skey.o: rc2_locl.h rc2_skey.c
88rc2cfb64.o: ../../include/openssl/opensslconf.h ../../include/openssl/rc2.h
89rc2cfb64.o: rc2_locl.h rc2cfb64.c
90rc2ofb64.o: ../../include/openssl/opensslconf.h ../../include/openssl/rc2.h
91rc2ofb64.o: rc2_locl.h rc2ofb64.c
diff --git a/src/lib/libcrypto/rc2/rc2.h b/src/lib/libcrypto/rc2/rc2.h
index e542ec94ff..34c8362317 100644
--- a/src/lib/libcrypto/rc2/rc2.h
+++ b/src/lib/libcrypto/rc2/rc2.h
@@ -79,9 +79,7 @@ typedef struct rc2_key_st
79 RC2_INT data[64]; 79 RC2_INT data[64];
80 } RC2_KEY; 80 } RC2_KEY;
81 81
82#ifdef OPENSSL_FIPS 82
83void private_RC2_set_key(RC2_KEY *key, int len, const unsigned char *data,int bits);
84#endif
85void RC2_set_key(RC2_KEY *key, int len, const unsigned char *data,int bits); 83void RC2_set_key(RC2_KEY *key, int len, const unsigned char *data,int bits);
86void RC2_ecb_encrypt(const unsigned char *in,unsigned char *out,RC2_KEY *key, 84void RC2_ecb_encrypt(const unsigned char *in,unsigned char *out,RC2_KEY *key,
87 int enc); 85 int enc);
diff --git a/src/lib/libcrypto/rc2/rc2_skey.c b/src/lib/libcrypto/rc2/rc2_skey.c
index 4e000e5b99..0150b0e035 100644
--- a/src/lib/libcrypto/rc2/rc2_skey.c
+++ b/src/lib/libcrypto/rc2/rc2_skey.c
@@ -57,14 +57,9 @@
57 */ 57 */
58 58
59#include <openssl/rc2.h> 59#include <openssl/rc2.h>
60#include <openssl/crypto.h>
61#ifdef OPENSSL_FIPS
62#include <openssl/fips.h>
63#endif
64
65#include "rc2_locl.h" 60#include "rc2_locl.h"
66 61
67static unsigned char key_table[256]={ 62static const unsigned char key_table[256]={
68 0xd9,0x78,0xf9,0xc4,0x19,0xdd,0xb5,0xed,0x28,0xe9,0xfd,0x79, 63 0xd9,0x78,0xf9,0xc4,0x19,0xdd,0xb5,0xed,0x28,0xe9,0xfd,0x79,
69 0x4a,0xa0,0xd8,0x9d,0xc6,0x7e,0x37,0x83,0x2b,0x76,0x53,0x8e, 64 0x4a,0xa0,0xd8,0x9d,0xc6,0x7e,0x37,0x83,0x2b,0x76,0x53,0x8e,
70 0x62,0x4c,0x64,0x88,0x44,0x8b,0xfb,0xa2,0x17,0x9a,0x59,0xf5, 65 0x62,0x4c,0x64,0x88,0x44,0x8b,0xfb,0xa2,0x17,0x9a,0x59,0xf5,
@@ -99,20 +94,8 @@ static unsigned char key_table[256]={
99 * BSAFE uses the 'retarded' version. What I previously shipped is 94 * BSAFE uses the 'retarded' version. What I previously shipped is
100 * the same as specifying 1024 for the 'bits' parameter. Bsafe uses 95 * the same as specifying 1024 for the 'bits' parameter. Bsafe uses
101 * a version where the bits parameter is the same as len*8 */ 96 * a version where the bits parameter is the same as len*8 */
102
103#ifdef OPENSSL_FIPS
104void RC2_set_key(RC2_KEY *key, int len, const unsigned char *data, int bits) 97void RC2_set_key(RC2_KEY *key, int len, const unsigned char *data, int bits)
105 { 98 {
106 if (FIPS_mode())
107 FIPS_BAD_ABORT(RC2)
108 private_RC2_set_key(key, len, data, bits);
109 }
110void private_RC2_set_key(RC2_KEY *key, int len, const unsigned char *data,
111 int bits)
112#else
113void RC2_set_key(RC2_KEY *key, int len, const unsigned char *data, int bits)
114#endif
115 {
116 int i,j; 99 int i,j;
117 unsigned char *k; 100 unsigned char *k;
118 RC2_INT *ki; 101 RC2_INT *ki;
diff --git a/src/lib/libcrypto/rc4/Makefile.ssl b/src/lib/libcrypto/rc4/Makefile.ssl
deleted file mode 100644
index 3e602662be..0000000000
--- a/src/lib/libcrypto/rc4/Makefile.ssl
+++ /dev/null
@@ -1,110 +0,0 @@
1#
2# SSLeay/crypto/rc4/Makefile
3#
4
5DIR= rc4
6TOP= ../..
7CC= cc
8CPP= $(CC) -E
9INCLUDES=
10CFLAG=-g
11INSTALL_PREFIX=
12OPENSSLDIR= /usr/local/ssl
13INSTALLTOP=/usr/local/ssl
14MAKE= make -f Makefile.ssl
15MAKEDEPPROG= makedepend
16MAKEDEPEND= $(TOP)/util/domd $(TOP) -MD $(MAKEDEPPROG)
17MAKEFILE= Makefile.ssl
18AR= ar r
19
20RC4_ENC=rc4_enc.o
21# or use
22#RC4_ENC=asm/rx86-elf.o
23#RC4_ENC=asm/rx86-out.o
24#RC4_ENC=asm/rx86-sol.o
25#RC4_ENC=asm/rx86bdsi.o
26
27CFLAGS= $(INCLUDES) $(CFLAG)
28ASFLAGS= $(INCLUDES) $(ASFLAG)
29
30GENERAL=Makefile
31TEST=rc4test.c
32APPS=
33
34LIB=$(TOP)/libcrypto.a
35LIBSRC=rc4_skey.c rc4_enc.c
36LIBOBJ=rc4_skey.o $(RC4_ENC)
37
38SRC= $(LIBSRC)
39
40EXHEADER= rc4.h
41HEADER= $(EXHEADER) rc4_locl.h
42
43ALL= $(GENERAL) $(SRC) $(HEADER)
44
45top:
46 (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all)
47
48all: lib
49
50lib: $(LIBOBJ)
51 $(AR) $(LIB) $(LIBOBJ)
52 $(RANLIB) $(LIB) || echo Never mind.
53 @touch lib
54
55# elf
56asm/rx86-elf.s: asm/rc4-586.pl ../perlasm/x86asm.pl
57 (cd asm; $(PERL) rc4-586.pl elf $(CFLAGS) > rx86-elf.s)
58
59# a.out
60asm/rx86-out.o: asm/rx86unix.cpp
61 $(CPP) -DOUT asm/rx86unix.cpp | as -o asm/rx86-out.o
62
63# bsdi
64asm/rx86bsdi.o: asm/rx86unix.cpp
65 $(CPP) -DBSDI asm/rx86unix.cpp | sed 's/ :/:/' | as -o asm/rx86bsdi.o
66
67asm/rx86unix.cpp: asm/rc4-586.pl ../perlasm/x86asm.pl
68 (cd asm; $(PERL) rc4-586.pl cpp >rx86unix.cpp)
69
70files:
71 $(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO
72
73links:
74 @sh $(TOP)/util/point.sh Makefile.ssl Makefile
75 @$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER)
76 @$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST)
77 @$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS)
78
79install:
80 @for i in $(EXHEADER) ; \
81 do \
82 (cp $$i $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i; \
83 chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i ); \
84 done;
85
86tags:
87 ctags $(SRC)
88
89tests:
90
91lint:
92 lint -DLINT $(INCLUDES) $(SRC)>fluff
93
94depend:
95 $(MAKEDEPEND) -- $(CFLAG) $(INCLUDES) $(DEPFLAG) -- $(PROGS) $(LIBSRC)
96
97dclean:
98 $(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
99 mv -f Makefile.new $(MAKEFILE)
100
101clean:
102 rm -f asm/rx86unix.cpp asm/*-elf.* *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff asm/*.o
103
104# DO NOT DELETE THIS LINE -- make depend depends on it.
105
106rc4_enc.o: ../../include/openssl/opensslconf.h ../../include/openssl/rc4.h
107rc4_enc.o: rc4_enc.c rc4_locl.h
108rc4_skey.o: ../../include/openssl/opensslconf.h
109rc4_skey.o: ../../include/openssl/opensslv.h ../../include/openssl/rc4.h
110rc4_skey.o: rc4_locl.h rc4_skey.c
diff --git a/src/lib/libcrypto/rc4/asm/rc4-586.pl b/src/lib/libcrypto/rc4/asm/rc4-586.pl
index ef7eee766c..38a44a70ef 100644
--- a/src/lib/libcrypto/rc4/asm/rc4-586.pl
+++ b/src/lib/libcrypto/rc4/asm/rc4-586.pl
@@ -1,14 +1,21 @@
1#!/usr/local/bin/perl 1#!/usr/bin/env perl
2
3# ====================================================================
4# [Re]written by Andy Polyakov <appro@fy.chalmers.se> for the OpenSSL
5# project. The module is, however, dual licensed under OpenSSL and
6# CRYPTOGAMS licenses depending on where you obtain it. For further
7# details see http://www.openssl.org/~appro/cryptogams/.
8# ====================================================================
2 9
3# At some point it became apparent that the original SSLeay RC4 10# At some point it became apparent that the original SSLeay RC4
4# assembler implementation performs suboptimaly on latest IA-32 11# assembler implementation performs suboptimally on latest IA-32
5# microarchitectures. After re-tuning performance has changed as 12# microarchitectures. After re-tuning performance has changed as
6# following: 13# following:
7# 14#
8# Pentium +0% 15# Pentium -10%
9# Pentium III +17% 16# Pentium III +12%
10# AMD +52%(*) 17# AMD +50%(*)
11# P4 +180%(**) 18# P4 +250%(**)
12# 19#
13# (*) This number is actually a trade-off:-) It's possible to 20# (*) This number is actually a trade-off:-) It's possible to
14# achieve +72%, but at the cost of -48% off PIII performance. 21# achieve +72%, but at the cost of -48% off PIII performance.
@@ -17,214 +24,247 @@
17# For reference! This code delivers ~80% of rc4-amd64.pl 24# For reference! This code delivers ~80% of rc4-amd64.pl
18# performance on the same Opteron machine. 25# performance on the same Opteron machine.
19# (**) This number requires compressed key schedule set up by 26# (**) This number requires compressed key schedule set up by
20# RC4_set_key and therefore doesn't apply to 0.9.7 [option for 27# RC4_set_key [see commentary below for further details].
21# compressed key schedule is implemented in 0.9.8 and later,
22# see commentary section in rc4_skey.c for further details].
23# 28#
24# <appro@fy.chalmers.se> 29# <appro@fy.chalmers.se>
25 30
26push(@INC,"perlasm","../../perlasm"); 31$0 =~ m/(.*[\/\\])[^\/\\]+$/; $dir=$1;
32push(@INC,"${dir}","${dir}../../perlasm");
27require "x86asm.pl"; 33require "x86asm.pl";
28 34
29&asm_init($ARGV[0],"rc4-586.pl"); 35&asm_init($ARGV[0],"rc4-586.pl");
30 36
31$x="eax"; 37$xx="eax";
32$y="ebx"; 38$yy="ebx";
33$tx="ecx"; 39$tx="ecx";
34$ty="edx"; 40$ty="edx";
35$in="esi"; 41$inp="esi";
36$out="edi"; 42$out="ebp";
37$d="ebp"; 43$dat="edi";
38 44
39&RC4("RC4"); 45sub RC4_loop {
40 46 my $i=shift;
41&asm_finish(); 47 my $func = ($i==0)?*mov:*or;
42 48
43sub RC4_loop 49 &add (&LB($yy),&LB($tx));
44 { 50 &mov ($ty,&DWP(0,$dat,$yy,4));
45 local($n,$p,$char)=@_; 51 &mov (&DWP(0,$dat,$yy,4),$tx);
46 52 &mov (&DWP(0,$dat,$xx,4),$ty);
47 &comment("Round $n"); 53 &add ($ty,$tx);
48 54 &inc (&LB($xx));
49 if ($char) 55 &and ($ty,0xff);
50 { 56 &ror ($out,8) if ($i!=0);
51 if ($p >= 0) 57 if ($i<3) {
52 { 58 &mov ($tx,&DWP(0,$dat,$xx,4));
53 &mov($ty, &swtmp(2)); 59 } else {
54 &cmp($ty, $in); 60 &mov ($tx,&wparam(3)); # reload [re-biased] out
55 &jbe(&label("finished"));
56 &inc($in);
57 }
58 else
59 {
60 &add($ty, 8);
61 &inc($in);
62 &cmp($ty, $in);
63 &jb(&label("finished"));
64 &mov(&swtmp(2), $ty);
65 }
66 }
67 # Moved out
68 # &mov( $tx, &DWP(0,$d,$x,4)) if $p < 0;
69
70 &add( &LB($y), &LB($tx));
71 &mov( $ty, &DWP(0,$d,$y,4));
72 # XXX
73 &mov( &DWP(0,$d,$x,4),$ty);
74 &add( $ty, $tx);
75 &mov( &DWP(0,$d,$y,4),$tx);
76 &and( $ty, 0xff);
77 &inc( &LB($x)); # NEXT ROUND
78 &mov( $tx, &DWP(0,$d,$x,4)) if $p < 1; # NEXT ROUND
79 &mov( $ty, &DWP(0,$d,$ty,4));
80
81 if (!$char)
82 {
83 #moved up into last round
84 if ($p >= 1)
85 {
86 &add( $out, 8)
87 }
88 &movb( &BP($n,"esp","",0), &LB($ty));
89 }
90 else
91 {
92 # Note in+=8 has occured
93 &movb( &HB($ty), &BP(-1,$in,"",0));
94 # XXX
95 &xorb(&LB($ty), &HB($ty));
96 # XXX
97 &movb(&BP($n,$out,"",0),&LB($ty));
98 }
99 } 61 }
100 62 &$func ($out,&DWP(0,$dat,$ty,4));
101 63}
102sub RC4 64
103 { 65# void RC4(RC4_KEY *key,size_t len,const unsigned char *inp,unsigned char *out);
104 local($name)=@_; 66&function_begin("RC4");
105 67 &mov ($dat,&wparam(0)); # load key schedule pointer
106 &function_begin_B($name,""); 68 &mov ($ty, &wparam(1)); # load len
107 69 &mov ($inp,&wparam(2)); # load inp
108 &mov($ty,&wparam(1)); # len 70 &mov ($out,&wparam(3)); # load out
109 &cmp($ty,0); 71
110 &jne(&label("proceed")); 72 &xor ($xx,$xx); # avoid partial register stalls
111 &ret(); 73 &xor ($yy,$yy);
112 &set_label("proceed"); 74
113 75 &cmp ($ty,0); # safety net
114 &comment(""); 76 &je (&label("abort"));
115 77
116 &push("ebp"); 78 &mov (&LB($xx),&BP(0,$dat)); # load key->x
117 &push("ebx"); 79 &mov (&LB($yy),&BP(4,$dat)); # load key->y
118 &push("esi"); 80 &add ($dat,8);
119 &xor( $x, $x); # avoid partial register stalls 81
120 &push("edi"); 82 &lea ($tx,&DWP(0,$inp,$ty));
121 &xor( $y, $y); # avoid partial register stalls 83 &sub ($out,$inp); # re-bias out
122 &mov( $d, &wparam(0)); # key 84 &mov (&wparam(1),$tx); # save input+len
123 &mov( $in, &wparam(2)); 85
124 86 &inc (&LB($xx));
125 &movb( &LB($x), &BP(0,$d,"",1)); 87
126 &movb( &LB($y), &BP(4,$d,"",1)); 88 # detect compressed key schedule...
127 89 &cmp (&DWP(256,$dat),-1);
128 &mov( $out, &wparam(3)); 90 &je (&label("RC4_CHAR"));
129 &inc( &LB($x)); 91
130 92 &mov ($tx,&DWP(0,$dat,$xx,4));
131 &stack_push(3); # 3 temp variables 93
132 &add( $d, 8); 94 &and ($ty,-4); # how many 4-byte chunks?
133 95 &jz (&label("loop1"));
134 # detect compressed schedule, see commentary section in rc4_skey.c... 96
135 # in 0.9.7 context ~50 bytes below RC4_CHAR label remain redundant, 97 &lea ($ty,&DWP(-4,$inp,$ty));
136 # as compressed key schedule is set up in 0.9.8 and later. 98 &mov (&wparam(2),$ty); # save input+(len/4)*4-4
137 &cmp(&DWP(256,$d),-1); 99 &mov (&wparam(3),$out); # $out as accumulator in this loop
138 &je(&label("RC4_CHAR")); 100
139 101 &set_label("loop4",16);
140 &lea( $ty, &DWP(-8,$ty,$in)); 102 for ($i=0;$i<4;$i++) { RC4_loop($i); }
141 103 &ror ($out,8);
142 # check for 0 length input 104 &xor ($out,&DWP(0,$inp));
143 105 &cmp ($inp,&wparam(2)); # compare to input+(len/4)*4-4
144 &mov( &swtmp(2), $ty); # this is now address to exit at 106 &mov (&DWP(0,$tx,$inp),$out);# $tx holds re-biased out here
145 &mov( $tx, &DWP(0,$d,$x,4)); 107 &lea ($inp,&DWP(4,$inp));
146 108 &mov ($tx,&DWP(0,$dat,$xx,4));
147 &cmp( $ty, $in); 109 &jb (&label("loop4"));
148 &jb( &label("end")); # less than 8 bytes 110
149 111 &cmp ($inp,&wparam(1)); # compare to input+len
150 &set_label("start"); 112 &je (&label("done"));
151 113 &mov ($out,&wparam(3)); # restore $out
152 # filling DELAY SLOT 114
153 &add( $in, 8); 115 &set_label("loop1",16);
154 116 &add (&LB($yy),&LB($tx));
155 &RC4_loop(0,-1,0); 117 &mov ($ty,&DWP(0,$dat,$yy,4));
156 &RC4_loop(1,0,0); 118 &mov (&DWP(0,$dat,$yy,4),$tx);
157 &RC4_loop(2,0,0); 119 &mov (&DWP(0,$dat,$xx,4),$ty);
158 &RC4_loop(3,0,0); 120 &add ($ty,$tx);
159 &RC4_loop(4,0,0); 121 &inc (&LB($xx));
160 &RC4_loop(5,0,0); 122 &and ($ty,0xff);
161 &RC4_loop(6,0,0); 123 &mov ($ty,&DWP(0,$dat,$ty,4));
162 &RC4_loop(7,1,0); 124 &xor (&LB($ty),&BP(0,$inp));
163 125 &lea ($inp,&DWP(1,$inp));
164 &comment("apply the cipher text"); 126 &mov ($tx,&DWP(0,$dat,$xx,4));
165 # xor the cipher data with input 127 &cmp ($inp,&wparam(1)); # compare to input+len
166 128 &mov (&BP(-1,$out,$inp),&LB($ty));
167 #&add( $out, 8); #moved up into last round 129 &jb (&label("loop1"));
168 130
169 &mov( $tx, &swtmp(0)); 131 &jmp (&label("done"));
170 &mov( $ty, &DWP(-8,$in,"",0)); 132
171 &xor( $tx, $ty); 133# this is essentially Intel P4 specific codepath...
172 &mov( $ty, &DWP(-4,$in,"",0)); 134&set_label("RC4_CHAR",16);
173 &mov( &DWP(-8,$out,"",0), $tx); 135 &movz ($tx,&BP(0,$dat,$xx));
174 &mov( $tx, &swtmp(1));
175 &xor( $tx, $ty);
176 &mov( $ty, &swtmp(2)); # load end ptr;
177 &mov( &DWP(-4,$out,"",0), $tx);
178 &mov( $tx, &DWP(0,$d,$x,4));
179 &cmp($in, $ty);
180 &jbe(&label("start"));
181
182 &set_label("end");
183
184 # There is quite a bit of extra crap in RC4_loop() for this
185 # first round
186 &RC4_loop(0,-1,1);
187 &RC4_loop(1,0,1);
188 &RC4_loop(2,0,1);
189 &RC4_loop(3,0,1);
190 &RC4_loop(4,0,1);
191 &RC4_loop(5,0,1);
192 &RC4_loop(6,1,1);
193
194 &jmp(&label("finished"));
195
196 &align(16);
197 # this is essentially Intel P4 specific codepath, see rc4_skey.c,
198 # and is engaged in 0.9.8 and later context...
199 &set_label("RC4_CHAR");
200
201 &lea ($ty,&DWP(0,$in,$ty));
202 &mov (&swtmp(2),$ty);
203 &movz ($tx,&BP(0,$d,$x));
204
205 # strangely enough unrolled loop performs over 20% slower... 136 # strangely enough unrolled loop performs over 20% slower...
206 &set_label("RC4_CHAR_loop"); 137 &set_label("cloop1");
207 &add (&LB($y),&LB($tx)); 138 &add (&LB($yy),&LB($tx));
208 &movz ($ty,&BP(0,$d,$y)); 139 &movz ($ty,&BP(0,$dat,$yy));
209 &movb (&BP(0,$d,$y),&LB($tx)); 140 &mov (&BP(0,$dat,$yy),&LB($tx));
210 &movb (&BP(0,$d,$x),&LB($ty)); 141 &mov (&BP(0,$dat,$xx),&LB($ty));
211 &add (&LB($ty),&LB($tx)); 142 &add (&LB($ty),&LB($tx));
212 &movz ($ty,&BP(0,$d,$ty)); 143 &movz ($ty,&BP(0,$dat,$ty));
213 &add (&LB($x),1); 144 &add (&LB($xx),1);
214 &xorb (&LB($ty),&BP(0,$in)); 145 &xor (&LB($ty),&BP(0,$inp));
215 &lea ($in,&DWP(1,$in)); 146 &lea ($inp,&DWP(1,$inp));
216 &movz ($tx,&BP(0,$d,$x)); 147 &movz ($tx,&BP(0,$dat,$xx));
217 &cmp ($in,&swtmp(2)); 148 &cmp ($inp,&wparam(1));
218 &movb (&BP(0,$out),&LB($ty)); 149 &mov (&BP(-1,$out,$inp),&LB($ty));
219 &lea ($out,&DWP(1,$out)); 150 &jb (&label("cloop1"));
220 &jb (&label("RC4_CHAR_loop")); 151
221 152&set_label("done");
222 &set_label("finished"); 153 &dec (&LB($xx));
223 &dec( $x); 154 &mov (&BP(-4,$dat),&LB($yy)); # save key->y
224 &stack_pop(3); 155 &mov (&BP(-8,$dat),&LB($xx)); # save key->x
225 &movb( &BP(-4,$d,"",0),&LB($y)); 156&set_label("abort");
226 &movb( &BP(-8,$d,"",0),&LB($x)); 157&function_end("RC4");
227 158
228 &function_end($name); 159########################################################################
229 } 160
161$inp="esi";
162$out="edi";
163$idi="ebp";
164$ido="ecx";
165$idx="edx";
166
167&external_label("OPENSSL_ia32cap_P");
168
169# void RC4_set_key(RC4_KEY *key,int len,const unsigned char *data);
170&function_begin("RC4_set_key");
171 &mov ($out,&wparam(0)); # load key
172 &mov ($idi,&wparam(1)); # load len
173 &mov ($inp,&wparam(2)); # load data
174 &picmeup($idx,"OPENSSL_ia32cap_P");
175
176 &lea ($out,&DWP(2*4,$out)); # &key->data
177 &lea ($inp,&DWP(0,$inp,$idi)); # $inp to point at the end
178 &neg ($idi);
179 &xor ("eax","eax");
180 &mov (&DWP(-4,$out),$idi); # borrow key->y
181
182 &bt (&DWP(0,$idx),20); # check for bit#20
183 &jc (&label("c1stloop"));
184
185&set_label("w1stloop",16);
186 &mov (&DWP(0,$out,"eax",4),"eax"); # key->data[i]=i;
187 &add (&LB("eax"),1); # i++;
188 &jnc (&label("w1stloop"));
189
190 &xor ($ido,$ido);
191 &xor ($idx,$idx);
192
193&set_label("w2ndloop",16);
194 &mov ("eax",&DWP(0,$out,$ido,4));
195 &add (&LB($idx),&BP(0,$inp,$idi));
196 &add (&LB($idx),&LB("eax"));
197 &add ($idi,1);
198 &mov ("ebx",&DWP(0,$out,$idx,4));
199 &jnz (&label("wnowrap"));
200 &mov ($idi,&DWP(-4,$out));
201 &set_label("wnowrap");
202 &mov (&DWP(0,$out,$idx,4),"eax");
203 &mov (&DWP(0,$out,$ido,4),"ebx");
204 &add (&LB($ido),1);
205 &jnc (&label("w2ndloop"));
206&jmp (&label("exit"));
207
208# Unlike all other x86 [and x86_64] implementations, Intel P4 core
209# [including EM64T] was found to perform poorly with above "32-bit" key
210# schedule, a.k.a. RC4_INT. Performance improvement for IA-32 hand-coded
211# assembler turned out to be 3.5x if re-coded for compressed 8-bit one,
212# a.k.a. RC4_CHAR! It's however inappropriate to just switch to 8-bit
213# schedule for x86[_64], because non-P4 implementations suffer from
214# significant performance losses then, e.g. PIII exhibits >2x
215# deterioration, and so does Opteron. In order to assure optimal
216# all-round performance, we detect P4 at run-time and set up compressed
217# key schedule, which is recognized by RC4 procedure.
218
219&set_label("c1stloop",16);
220 &mov (&BP(0,$out,"eax"),&LB("eax")); # key->data[i]=i;
221 &add (&LB("eax"),1); # i++;
222 &jnc (&label("c1stloop"));
223
224 &xor ($ido,$ido);
225 &xor ($idx,$idx);
226 &xor ("ebx","ebx");
227
228&set_label("c2ndloop",16);
229 &mov (&LB("eax"),&BP(0,$out,$ido));
230 &add (&LB($idx),&BP(0,$inp,$idi));
231 &add (&LB($idx),&LB("eax"));
232 &add ($idi,1);
233 &mov (&LB("ebx"),&BP(0,$out,$idx));
234 &jnz (&label("cnowrap"));
235 &mov ($idi,&DWP(-4,$out));
236 &set_label("cnowrap");
237 &mov (&BP(0,$out,$idx),&LB("eax"));
238 &mov (&BP(0,$out,$ido),&LB("ebx"));
239 &add (&LB($ido),1);
240 &jnc (&label("c2ndloop"));
241
242 &mov (&DWP(256,$out),-1); # mark schedule as compressed
243
244&set_label("exit");
245 &xor ("eax","eax");
246 &mov (&DWP(-8,$out),"eax"); # key->x=0;
247 &mov (&DWP(-4,$out),"eax"); # key->y=0;
248&function_end("RC4_set_key");
249
250# const char *RC4_options(void);
251&function_begin_B("RC4_options");
252 &call (&label("pic_point"));
253&set_label("pic_point");
254 &blindpop("eax");
255 &lea ("eax",&DWP(&label("opts")."-".&label("pic_point"),"eax"));
256 &picmeup("edx","OPENSSL_ia32cap_P");
257 &bt (&DWP(0,"edx"),20);
258 &jnc (&label("skip"));
259 &add ("eax",12);
260 &set_label("skip");
261 &ret ();
262&set_label("opts",64);
263&asciz ("rc4(4x,int)");
264&asciz ("rc4(1x,char)");
265&asciz ("RC4 for x86, CRYPTOGAMS by <appro\@openssl.org>");
266&align (64);
267&function_end_B("RC4_options");
268
269&asm_finish();
230 270
diff --git a/src/lib/libcrypto/rc4/asm/rc4-amd64.pl b/src/lib/libcrypto/rc4/asm/rc4-amd64.pl
deleted file mode 100755
index 9e0da8af99..0000000000
--- a/src/lib/libcrypto/rc4/asm/rc4-amd64.pl
+++ /dev/null
@@ -1,227 +0,0 @@
1#!/usr/bin/env perl
2#
3# ====================================================================
4# Written by Andy Polyakov <appro@fy.chalmers.se> for the OpenSSL
5# project. Rights for redistribution and usage in source and binary
6# forms are granted according to the OpenSSL license.
7# ====================================================================
8#
9# 2.22x RC4 tune-up:-) It should be noted though that my hand [as in
10# "hand-coded assembler"] doesn't stand for the whole improvement
11# coefficient. It turned out that eliminating RC4_CHAR from config
12# line results in ~40% improvement (yes, even for C implementation).
13# Presumably it has everything to do with AMD cache architecture and
14# RAW or whatever penalties. Once again! The module *requires* config
15# line *without* RC4_CHAR! As for coding "secret," I bet on partial
16# register arithmetics. For example instead of 'inc %r8; and $255,%r8'
17# I simply 'inc %r8b'. Even though optimization manual discourages
18# to operate on partial registers, it turned out to be the best bet.
19# At least for AMD... How IA32E would perform remains to be seen...
20
21# As was shown by Marc Bevand reordering of couple of load operations
22# results in even higher performance gain of 3.3x:-) At least on
23# Opteron... For reference, 1x in this case is RC4_CHAR C-code
24# compiled with gcc 3.3.2, which performs at ~54MBps per 1GHz clock.
25# Latter means that if you want to *estimate* what to expect from
26# *your* CPU, then multiply 54 by 3.3 and clock frequency in GHz.
27
28# Intel P4 EM64T core was found to run the AMD64 code really slow...
29# The only way to achieve comparable performance on P4 is to keep
30# RC4_CHAR. Kind of ironic, huh? As it's apparently impossible to
31# compose blended code, which would perform even within 30% marginal
32# on either AMD and Intel platforms, I implement both cases. See
33# rc4_skey.c for further details... This applies to 0.9.8 and later.
34# In 0.9.7 context RC4_CHAR codepath is never engaged and ~70 bytes
35# of code remain redundant.
36
37$output=shift;
38
39$win64a=1 if ($output =~ /win64a.[s|asm]/);
40
41open STDOUT,">$output" || die "can't open $output: $!";
42
43if (defined($win64a)) {
44 $dat="%rcx"; # arg1
45 $len="%rdx"; # arg2
46 $inp="%rsi"; # r8, arg3 moves here
47 $out="%rdi"; # r9, arg4 moves here
48} else {
49 $dat="%rdi"; # arg1
50 $len="%rsi"; # arg2
51 $inp="%rdx"; # arg3
52 $out="%rcx"; # arg4
53}
54
55$XX="%r10";
56$TX="%r8";
57$YY="%r11";
58$TY="%r9";
59
60sub PTR() {
61 my $ret=shift;
62 if (defined($win64a)) {
63 $ret =~ s/\[([\S]+)\+([\S]+)\]/[$2+$1]/g; # [%rN+%rM*4]->[%rM*4+%rN]
64 $ret =~ s/:([^\[]+)\[([^\]]+)\]/:[$2+$1]/g; # :off[ea]->:[ea+off]
65 } else {
66 $ret =~ s/[\+\*]/,/g; # [%rN+%rM*4]->[%rN,%rM,4]
67 $ret =~ s/\[([^\]]+)\]/($1)/g; # [%rN]->(%rN)
68 }
69 $ret;
70}
71
72$code=<<___ if (!defined($win64a));
73.text
74
75.globl RC4
76.type RC4,\@function
77.align 16
78RC4: or $len,$len
79 jne .Lentry
80 repret
81.Lentry:
82___
83$code=<<___ if (defined($win64a));
84_TEXT SEGMENT
85PUBLIC RC4
86ALIGN 16
87RC4 PROC
88 or $len,$len
89 jne .Lentry
90 repret
91.Lentry:
92 push %rdi
93 push %rsi
94 sub \$40,%rsp
95 mov %r8,$inp
96 mov %r9,$out
97___
98$code.=<<___;
99 add \$8,$dat
100 movl `&PTR("DWORD:-8[$dat]")`,$XX#d
101 movl `&PTR("DWORD:-4[$dat]")`,$YY#d
102 cmpl \$-1,`&PTR("DWORD:256[$dat]")`
103 je .LRC4_CHAR
104 test \$-8,$len
105 jz .Lloop1
106.align 16
107.Lloop8:
108 inc $XX#b
109 movl `&PTR("DWORD:[$dat+$XX*4]")`,$TX#d
110 add $TX#b,$YY#b
111 movl `&PTR("DWORD:[$dat+$YY*4]")`,$TY#d
112 movl $TX#d,`&PTR("DWORD:[$dat+$YY*4]")`
113 movl $TY#d,`&PTR("DWORD:[$dat+$XX*4]")`
114 add $TX#b,$TY#b
115 inc $XX#b
116 movl `&PTR("DWORD:[$dat+$XX*4]")`,$TX#d
117 movb `&PTR("BYTE:[$dat+$TY*4]")`,%al
118___
119for ($i=1;$i<=6;$i++) {
120$code.=<<___;
121 add $TX#b,$YY#b
122 ror \$8,%rax
123 movl `&PTR("DWORD:[$dat+$YY*4]")`,$TY#d
124 movl $TX#d,`&PTR("DWORD:[$dat+$YY*4]")`
125 movl $TY#d,`&PTR("DWORD:[$dat+$XX*4]")`
126 add $TX#b,$TY#b
127 inc $XX#b
128 movl `&PTR("DWORD:[$dat+$XX*4]")`,$TX#d
129 movb `&PTR("BYTE:[$dat+$TY*4]")`,%al
130___
131}
132$code.=<<___;
133 add $TX#b,$YY#b
134 ror \$8,%rax
135 movl `&PTR("DWORD:[$dat+$YY*4]")`,$TY#d
136 movl $TX#d,`&PTR("DWORD:[$dat+$YY*4]")`
137 movl $TY#d,`&PTR("DWORD:[$dat+$XX*4]")`
138 sub \$8,$len
139 add $TY#b,$TX#b
140 movb `&PTR("BYTE:[$dat+$TX*4]")`,%al
141 ror \$8,%rax
142 add \$8,$inp
143 add \$8,$out
144
145 xor `&PTR("QWORD:-8[$inp]")`,%rax
146 mov %rax,`&PTR("QWORD:-8[$out]")`
147
148 test \$-8,$len
149 jnz .Lloop8
150 cmp \$0,$len
151 jne .Lloop1
152.Lexit:
153 movl $XX#d,`&PTR("DWORD:-8[$dat]")`
154 movl $YY#d,`&PTR("DWORD:-4[$dat]")`
155___
156$code.=<<___ if (defined($win64a));
157 add \$40,%rsp
158 pop %rsi
159 pop %rdi
160___
161$code.=<<___;
162 repret
163.align 16
164.Lloop1:
165 movzb `&PTR("BYTE:[$inp]")`,%eax
166 inc $XX#b
167 movl `&PTR("DWORD:[$dat+$XX*4]")`,$TX#d
168 add $TX#b,$YY#b
169 movl `&PTR("DWORD:[$dat+$YY*4]")`,$TY#d
170 movl $TX#d,`&PTR("DWORD:[$dat+$YY*4]")`
171 movl $TY#d,`&PTR("DWORD:[$dat+$XX*4]")`
172 add $TY#b,$TX#b
173 movl `&PTR("DWORD:[$dat+$TX*4]")`,$TY#d
174 xor $TY,%rax
175 inc $inp
176 movb %al,`&PTR("BYTE:[$out]")`
177 inc $out
178 dec $len
179 jnz .Lloop1
180 jmp .Lexit
181
182.align 16
183.LRC4_CHAR:
184 inc $XX#b
185 movzb `&PTR("BYTE:[$dat+$XX]")`,$TX#d
186 add $TX#b,$YY#b
187 movzb `&PTR("BYTE:[$dat+$YY]")`,$TY#d
188 movb $TX#b,`&PTR("BYTE:[$dat+$YY]")`
189 movb $TY#b,`&PTR("BYTE:[$dat+$XX]")`
190 add $TX#b,$TY#b
191 movzb `&PTR("BYTE:[$dat+$TY]")`,$TY#d
192 xorb `&PTR("BYTE:[$inp]")`,$TY#b
193 movb $TY#b,`&PTR("BYTE:[$out]")`
194 inc $inp
195 inc $out
196 dec $len
197 jnz .LRC4_CHAR
198 jmp .Lexit
199___
200$code.=<<___ if (defined($win64a));
201RC4 ENDP
202_TEXT ENDS
203END
204___
205$code.=<<___ if (!defined($win64a));
206.size RC4,.-RC4
207___
208
209$code =~ s/#([bwd])/$1/gm;
210$code =~ s/\`([^\`]*)\`/eval $1/gem;
211
212if (defined($win64a)) {
213 $code =~ s/\.align/ALIGN/gm;
214 $code =~ s/[\$%]//gm;
215 $code =~ s/\.L/\$L/gm;
216 $code =~ s/([\w]+)([\s]+)([\S]+),([\S]+)/$1$2$4,$3/gm;
217 $code =~ s/([QD]*WORD|BYTE):/$1 PTR/gm;
218 $code =~ s/mov[bwlq]/mov/gm;
219 $code =~ s/movzb/movzx/gm;
220 $code =~ s/repret/DB\t0F3h,0C3h/gm;
221 $code =~ s/cmpl/cmp/gm;
222 $code =~ s/xorb/xor/gm;
223} else {
224 $code =~ s/([QD]*WORD|BYTE)://gm;
225 $code =~ s/repret/.byte\t0xF3,0xC3/gm;
226}
227print $code;
diff --git a/src/lib/libcrypto/rc4/asm/rc4-ia64.S b/src/lib/libcrypto/rc4/asm/rc4-ia64.S
deleted file mode 100644
index 8210c47d04..0000000000
--- a/src/lib/libcrypto/rc4/asm/rc4-ia64.S
+++ /dev/null
@@ -1,159 +0,0 @@
1// ====================================================================
2// Written by Andy Polyakov <appro@fy.chalmers.se> for the OpenSSL
3// project.
4//
5// Rights for redistribution and usage in source and binary forms are
6// granted according to the OpenSSL license. Warranty of any kind is
7// disclaimed.
8// ====================================================================
9
10.ident "rc4-ia64.S, Version 2.0"
11.ident "IA-64 ISA artwork by Andy Polyakov <appro@fy.chalmers.se>"
12
13// What's wrong with compiler generated code? Because of the nature of
14// C language, compiler doesn't [dare to] reorder load and stores. But
15// being memory-bound, RC4 should benefit from reorder [on in-order-
16// execution core such as IA-64]. But what can we reorder? At the very
17// least we can safely reorder references to key schedule in respect
18// to input and output streams. Secondly, from the first [close] glance
19// it appeared that it's possible to pull up some references to
20// elements of the key schedule itself. Original rationale ["prior
21// loads are not safe only for "degenerated" key schedule, when some
22// elements equal to the same value"] was kind of sloppy. I should have
23// formulated as it really was: if we assume that pulling up reference
24// to key[x+1] is not safe, then it would mean that key schedule would
25// "degenerate," which is never the case. The problem is that this
26// holds true in respect to references to key[x], but not to key[y].
27// Legitimate "collisions" do occur within every 256^2 bytes window.
28// Fortunately there're enough free instruction slots to keep prior
29// reference to key[x+1], detect "collision" and compensate for it.
30// All this without sacrificing a single clock cycle:-) Throughput is
31// ~210MBps on 900MHz CPU, which is is >3x faster than gcc generated
32// code and +30% - if compared to HP-UX C. Unrolling loop below should
33// give >30% on top of that...
34
35.text
36.explicit
37
38#if defined(_HPUX_SOURCE) && !defined(_LP64)
39# define ADDP addp4
40#else
41# define ADDP add
42#endif
43
44#ifndef SZ
45#define SZ 4 // this is set to sizeof(RC4_INT)
46#endif
47// SZ==4 seems to be optimal. At least SZ==8 is not any faster, not for
48// assembler implementation, while SZ==1 code is ~30% slower.
49#if SZ==1 // RC4_INT is unsigned char
50# define LDKEY ld1
51# define STKEY st1
52# define OFF 0
53#elif SZ==4 // RC4_INT is unsigned int
54# define LDKEY ld4
55# define STKEY st4
56# define OFF 2
57#elif SZ==8 // RC4_INT is unsigned long
58# define LDKEY ld8
59# define STKEY st8
60# define OFF 3
61#endif
62
63out=r8; // [expanded] output pointer
64inp=r9; // [expanded] output pointer
65prsave=r10;
66key=r28; // [expanded] pointer to RC4_KEY
67ksch=r29; // (key->data+255)[&~(sizeof(key->data)-1)]
68xx=r30;
69yy=r31;
70
71// void RC4(RC4_KEY *key,size_t len,const void *inp,void *out);
72.global RC4#
73.proc RC4#
74.align 32
75.skip 16
76RC4:
77 .prologue
78 .save ar.pfs,r2
79{ .mii; alloc r2=ar.pfs,4,12,0,16
80 .save pr,prsave
81 mov prsave=pr
82 ADDP key=0,in0 };;
83{ .mib; cmp.eq p6,p0=0,in1 // len==0?
84 .save ar.lc,r3
85 mov r3=ar.lc
86(p6) br.ret.spnt.many b0 };; // emergency exit
87
88 .body
89 .rotr dat[4],key_x[4],tx[2],rnd[2],key_y[2],ty[1];
90
91{ .mib; LDKEY xx=[key],SZ // load key->x
92 add in1=-1,in1 // adjust len for loop counter
93 nop.b 0 }
94{ .mib; ADDP inp=0,in2
95 ADDP out=0,in3
96 brp.loop.imp .Ltop,.Lexit-16 };;
97{ .mmi; LDKEY yy=[key] // load key->y
98 add ksch=SZ,key
99 mov ar.lc=in1 }
100{ .mmi; mov key_y[1]=r0 // guarantee inequality
101 // in first iteration
102 add xx=1,xx
103 mov pr.rot=1<<16 };;
104{ .mii; nop.m 0
105 dep key_x[1]=xx,r0,OFF,8
106 mov ar.ec=3 };; // note that epilogue counter
107 // is off by 1. I compensate
108 // for this at exit...
109.Ltop:
110// The loop is scheduled for 4*(n+2) spin-rate on Itanium 2, which
111// theoretically gives asymptotic performance of clock frequency
112// divided by 4 bytes per seconds, or 400MBps on 1.6GHz CPU. This is
113// for sizeof(RC4_INT)==4. For smaller RC4_INT STKEY inadvertently
114// splits the last bundle and you end up with 5*n spin-rate:-(
115// Originally the loop was scheduled for 3*n and relied on key
116// schedule to be aligned at 256*sizeof(RC4_INT) boundary. But
117// *(out++)=dat, which maps to st1, had same effect [inadvertent
118// bundle split] and holded the loop back. Rescheduling for 4*n
119// made it possible to eliminate dependence on specific alignment
120// and allow OpenSSH keep "abusing" our API. Reaching for 3*n would
121// require unrolling, sticking to variable shift instruction for
122// collecting output [to avoid starvation for integer shifter] and
123// copying of key schedule to controlled place in stack [so that
124// deposit instruction can serve as substitute for whole
125// key->data+((x&255)<<log2(sizeof(key->data[0])))]...
126{ .mmi; (p19) st1 [out]=dat[3],1 // *(out++)=dat
127 (p16) add xx=1,xx // x++
128 (p18) dep rnd[1]=rnd[1],r0,OFF,8 } // ((tx+ty)&255)<<OFF
129{ .mmi; (p16) add key_x[1]=ksch,key_x[1] // &key[xx&255]
130 (p17) add key_y[1]=ksch,key_y[1] };; // &key[yy&255]
131{ .mmi; (p16) LDKEY tx[0]=[key_x[1]] // tx=key[xx]
132 (p17) LDKEY ty[0]=[key_y[1]] // ty=key[yy]
133 (p16) dep key_x[0]=xx,r0,OFF,8 } // (xx&255)<<OFF
134{ .mmi; (p18) add rnd[1]=ksch,rnd[1] // &key[(tx+ty)&255]
135 (p16) cmp.ne.unc p20,p21=key_x[1],key_y[1] };;
136{ .mmi; (p18) LDKEY rnd[1]=[rnd[1]] // rnd=key[(tx+ty)&255]
137 (p16) ld1 dat[0]=[inp],1 } // dat=*(inp++)
138.pred.rel "mutex",p20,p21
139{ .mmi; (p21) add yy=yy,tx[1] // (p16)
140 (p20) add yy=yy,tx[0] // (p16) y+=tx
141 (p21) mov tx[0]=tx[1] };; // (p16)
142{ .mmi; (p17) STKEY [key_y[1]]=tx[1] // key[yy]=tx
143 (p17) STKEY [key_x[2]]=ty[0] // key[xx]=ty
144 (p16) dep key_y[0]=yy,r0,OFF,8 } // &key[yy&255]
145{ .mmb; (p17) add rnd[0]=tx[1],ty[0] // tx+=ty
146 (p18) xor dat[2]=dat[2],rnd[1] // dat^=rnd
147 br.ctop.sptk .Ltop };;
148.Lexit:
149{ .mib; STKEY [key]=yy,-SZ // save key->y
150 mov pr=prsave,0x1ffff
151 nop.b 0 }
152{ .mib; st1 [out]=dat[3],1 // compensate for truncated
153 // epilogue counter
154 add xx=-1,xx
155 nop.b 0 };;
156{ .mib; STKEY [key]=xx // save key->x
157 mov ar.lc=r3
158 br.ret.sptk.many b0 };;
159.endp RC4#
diff --git a/src/lib/libcrypto/rc4/asm/rc4-x86_64.pl b/src/lib/libcrypto/rc4/asm/rc4-x86_64.pl
index 3a54623495..544386bf53 100755
--- a/src/lib/libcrypto/rc4/asm/rc4-x86_64.pl
+++ b/src/lib/libcrypto/rc4/asm/rc4-x86_64.pl
@@ -58,14 +58,18 @@
58# fit for Core2 and therefore the code was modified to skip cloop8 on 58# fit for Core2 and therefore the code was modified to skip cloop8 on
59# this CPU. 59# this CPU.
60 60
61$output=shift; 61$flavour = shift;
62$output = shift;
63if ($flavour =~ /\./) { $output = $flavour; undef $flavour; }
64
65$win64=0; $win64=1 if ($flavour =~ /[nm]asm|mingw64/ || $output =~ /\.asm$/);
62 66
63$0 =~ m/(.*[\/\\])[^\/\\]+$/; $dir=$1; 67$0 =~ m/(.*[\/\\])[^\/\\]+$/; $dir=$1;
64( $xlate="${dir}x86_64-xlate.pl" and -f $xlate ) or 68( $xlate="${dir}x86_64-xlate.pl" and -f $xlate ) or
65( $xlate="${dir}../../perlasm/x86_64-xlate.pl" and -f $xlate) or 69( $xlate="${dir}../../perlasm/x86_64-xlate.pl" and -f $xlate) or
66die "can't locate x86_64-xlate.pl"; 70die "can't locate x86_64-xlate.pl";
67 71
68open STDOUT,"| $^X $xlate $output"; 72open STDOUT,"| $^X $xlate $flavour $output";
69 73
70$dat="%rdi"; # arg1 74$dat="%rdi"; # arg1
71$len="%rsi"; # arg2 75$len="%rsi"; # arg2
@@ -87,8 +91,10 @@ RC4: or $len,$len
87 jne .Lentry 91 jne .Lentry
88 ret 92 ret
89.Lentry: 93.Lentry:
94 push %rbx
90 push %r12 95 push %r12
91 push %r13 96 push %r13
97.Lprologue:
92 98
93 add \$8,$dat 99 add \$8,$dat
94 movl -8($dat),$XX[0]#d 100 movl -8($dat),$XX[0]#d
@@ -133,16 +139,8 @@ $code.=<<___;
133 jnz .Lloop8 139 jnz .Lloop8
134 cmp \$0,$len 140 cmp \$0,$len
135 jne .Lloop1 141 jne .Lloop1
136___ 142 jmp .Lexit
137$code.=<<___;
138.Lexit:
139 sub \$1,$XX[0]#b
140 movl $XX[0]#d,-8($dat)
141 movl $YY#d,-4($dat)
142 143
143 pop %r13
144 pop %r12
145 ret
146.align 16 144.align 16
147.Lloop1: 145.Lloop1:
148 add $TX[0]#b,$YY#b 146 add $TX[0]#b,$YY#b
@@ -167,9 +165,8 @@ $code.=<<___;
167 movzb ($dat,$XX[0]),$TX[0]#d 165 movzb ($dat,$XX[0]),$TX[0]#d
168 test \$-8,$len 166 test \$-8,$len
169 jz .Lcloop1 167 jz .Lcloop1
170 cmp \$0,260($dat) 168 cmpl \$0,260($dat)
171 jnz .Lcloop1 169 jnz .Lcloop1
172 push %rbx
173 jmp .Lcloop8 170 jmp .Lcloop8
174.align 16 171.align 16
175.Lcloop8: 172.Lcloop8:
@@ -224,7 +221,6 @@ $code.=<<___;
224 221
225 test \$-8,$len 222 test \$-8,$len
226 jnz .Lcloop8 223 jnz .Lcloop8
227 pop %rbx
228 cmp \$0,$len 224 cmp \$0,$len
229 jne .Lcloop1 225 jne .Lcloop1
230 jmp .Lexit 226 jmp .Lexit
@@ -249,6 +245,19 @@ $code.=<<___;
249 sub \$1,$len 245 sub \$1,$len
250 jnz .Lcloop1 246 jnz .Lcloop1
251 jmp .Lexit 247 jmp .Lexit
248
249.align 16
250.Lexit:
251 sub \$1,$XX[0]#b
252 movl $XX[0]#d,-8($dat)
253 movl $YY#d,-4($dat)
254
255 mov (%rsp),%r13
256 mov 8(%rsp),%r12
257 mov 16(%rsp),%rbx
258 add \$24,%rsp
259.Lepilogue:
260 ret
252.size RC4,.-RC4 261.size RC4,.-RC4
253___ 262___
254 263
@@ -269,6 +278,7 @@ RC4_set_key:
269 xor $ido,$ido 278 xor $ido,$ido
270 xor %r10,%r10 279 xor %r10,%r10
271 xor %r11,%r11 280 xor %r11,%r11
281
272 mov PIC_GOT(OPENSSL_ia32cap_P),$idx#d 282 mov PIC_GOT(OPENSSL_ia32cap_P),$idx#d
273 bt \$20,$idx#d 283 bt \$20,$idx#d
274 jnc .Lw1stloop 284 jnc .Lw1stloop
@@ -332,11 +342,10 @@ RC4_set_key:
332.size RC4_set_key,.-RC4_set_key 342.size RC4_set_key,.-RC4_set_key
333 343
334.globl RC4_options 344.globl RC4_options
335.type RC4_options,\@function,0 345.type RC4_options,\@abi-omnipotent
336.align 16 346.align 16
337RC4_options: 347RC4_options:
338 .picmeup %rax 348 lea .Lopts(%rip),%rax
339 lea .Lopts-.(%rax),%rax
340 mov PIC_GOT(OPENSSL_ia32cap_P),%edx 349 mov PIC_GOT(OPENSSL_ia32cap_P),%edx
341 bt \$20,%edx 350 bt \$20,%edx
342 jnc .Ldone 351 jnc .Ldone
@@ -356,9 +365,139 @@ RC4_options:
356.size RC4_options,.-RC4_options 365.size RC4_options,.-RC4_options
357___ 366___
358 367
359$code =~ s/#([bwd])/$1/gm; 368# EXCEPTION_DISPOSITION handler (EXCEPTION_RECORD *rec,ULONG64 frame,
369# CONTEXT *context,DISPATCHER_CONTEXT *disp)
370if ($win64) {
371$rec="%rcx";
372$frame="%rdx";
373$context="%r8";
374$disp="%r9";
375
376$code.=<<___;
377.extern __imp_RtlVirtualUnwind
378.type stream_se_handler,\@abi-omnipotent
379.align 16
380stream_se_handler:
381 push %rsi
382 push %rdi
383 push %rbx
384 push %rbp
385 push %r12
386 push %r13
387 push %r14
388 push %r15
389 pushfq
390 sub \$64,%rsp
391
392 mov 120($context),%rax # pull context->Rax
393 mov 248($context),%rbx # pull context->Rip
394
395 lea .Lprologue(%rip),%r10
396 cmp %r10,%rbx # context->Rip<prologue label
397 jb .Lin_prologue
398
399 mov 152($context),%rax # pull context->Rsp
400
401 lea .Lepilogue(%rip),%r10
402 cmp %r10,%rbx # context->Rip>=epilogue label
403 jae .Lin_prologue
404
405 lea 24(%rax),%rax
406
407 mov -8(%rax),%rbx
408 mov -16(%rax),%r12
409 mov -24(%rax),%r13
410 mov %rbx,144($context) # restore context->Rbx
411 mov %r12,216($context) # restore context->R12
412 mov %r13,224($context) # restore context->R13
413
414.Lin_prologue:
415 mov 8(%rax),%rdi
416 mov 16(%rax),%rsi
417 mov %rax,152($context) # restore context->Rsp
418 mov %rsi,168($context) # restore context->Rsi
419 mov %rdi,176($context) # restore context->Rdi
420
421 jmp .Lcommon_seh_exit
422.size stream_se_handler,.-stream_se_handler
423
424.type key_se_handler,\@abi-omnipotent
425.align 16
426key_se_handler:
427 push %rsi
428 push %rdi
429 push %rbx
430 push %rbp
431 push %r12
432 push %r13
433 push %r14
434 push %r15
435 pushfq
436 sub \$64,%rsp
437
438 mov 152($context),%rax # pull context->Rsp
439 mov 8(%rax),%rdi
440 mov 16(%rax),%rsi
441 mov %rsi,168($context) # restore context->Rsi
442 mov %rdi,176($context) # restore context->Rdi
360 443
361$code =~ s/RC4_set_key/private_RC4_set_key/g if ($ENV{FIPSCANLIB} ne ""); 444.Lcommon_seh_exit:
445
446 mov 40($disp),%rdi # disp->ContextRecord
447 mov $context,%rsi # context
448 mov \$154,%ecx # sizeof(CONTEXT)
449 .long 0xa548f3fc # cld; rep movsq
450
451 mov $disp,%rsi
452 xor %rcx,%rcx # arg1, UNW_FLAG_NHANDLER
453 mov 8(%rsi),%rdx # arg2, disp->ImageBase
454 mov 0(%rsi),%r8 # arg3, disp->ControlPc
455 mov 16(%rsi),%r9 # arg4, disp->FunctionEntry
456 mov 40(%rsi),%r10 # disp->ContextRecord
457 lea 56(%rsi),%r11 # &disp->HandlerData
458 lea 24(%rsi),%r12 # &disp->EstablisherFrame
459 mov %r10,32(%rsp) # arg5
460 mov %r11,40(%rsp) # arg6
461 mov %r12,48(%rsp) # arg7
462 mov %rcx,56(%rsp) # arg8, (NULL)
463 call *__imp_RtlVirtualUnwind(%rip)
464
465 mov \$1,%eax # ExceptionContinueSearch
466 add \$64,%rsp
467 popfq
468 pop %r15
469 pop %r14
470 pop %r13
471 pop %r12
472 pop %rbp
473 pop %rbx
474 pop %rdi
475 pop %rsi
476 ret
477.size key_se_handler,.-key_se_handler
478
479.section .pdata
480.align 4
481 .rva .LSEH_begin_RC4
482 .rva .LSEH_end_RC4
483 .rva .LSEH_info_RC4
484
485 .rva .LSEH_begin_RC4_set_key
486 .rva .LSEH_end_RC4_set_key
487 .rva .LSEH_info_RC4_set_key
488
489.section .xdata
490.align 8
491.LSEH_info_RC4:
492 .byte 9,0,0,0
493 .rva stream_se_handler
494.LSEH_info_RC4_set_key:
495 .byte 9,0,0,0
496 .rva key_se_handler
497___
498}
499
500$code =~ s/#([bwd])/$1/gm;
362 501
363print $code; 502print $code;
364 503
diff --git a/src/lib/libcrypto/rc4/rc4.h b/src/lib/libcrypto/rc4/rc4.h
index 2d8620d33b..29d1acccf5 100644
--- a/src/lib/libcrypto/rc4/rc4.h
+++ b/src/lib/libcrypto/rc4/rc4.h
@@ -64,6 +64,8 @@
64#error RC4 is disabled. 64#error RC4 is disabled.
65#endif 65#endif
66 66
67#include <stddef.h>
68
67#ifdef __cplusplus 69#ifdef __cplusplus
68extern "C" { 70extern "C" {
69#endif 71#endif
@@ -76,11 +78,8 @@ typedef struct rc4_key_st
76 78
77 79
78const char *RC4_options(void); 80const char *RC4_options(void);
79#ifdef OPENSSL_FIPS
80void private_RC4_set_key(RC4_KEY *key, int len, const unsigned char *data);
81#endif
82void RC4_set_key(RC4_KEY *key, int len, const unsigned char *data); 81void RC4_set_key(RC4_KEY *key, int len, const unsigned char *data);
83void RC4(RC4_KEY *key, unsigned long len, const unsigned char *indata, 82void RC4(RC4_KEY *key, size_t len, const unsigned char *indata,
84 unsigned char *outdata); 83 unsigned char *outdata);
85 84
86#ifdef __cplusplus 85#ifdef __cplusplus
diff --git a/src/lib/libcrypto/rc4/rc4_enc.c b/src/lib/libcrypto/rc4/rc4_enc.c
index 0660ea60a2..8c4fc6c7a3 100644
--- a/src/lib/libcrypto/rc4/rc4_enc.c
+++ b/src/lib/libcrypto/rc4/rc4_enc.c
@@ -67,12 +67,12 @@
67 * Date: Wed, 14 Sep 1994 06:35:31 GMT 67 * Date: Wed, 14 Sep 1994 06:35:31 GMT
68 */ 68 */
69 69
70void RC4(RC4_KEY *key, unsigned long len, const unsigned char *indata, 70void RC4(RC4_KEY *key, size_t len, const unsigned char *indata,
71 unsigned char *outdata) 71 unsigned char *outdata)
72 { 72 {
73 register RC4_INT *d; 73 register RC4_INT *d;
74 register RC4_INT x,y,tx,ty; 74 register RC4_INT x,y,tx,ty;
75 int i; 75 size_t i;
76 76
77 x=key->x; 77 x=key->x;
78 y=key->y; 78 y=key->y;
@@ -120,8 +120,8 @@ void RC4(RC4_KEY *key, unsigned long len, const unsigned char *indata,
120 (RC4_CHUNK)d[(tx+ty)&0xff]\ 120 (RC4_CHUNK)d[(tx+ty)&0xff]\
121 ) 121 )
122 122
123 if ( ( ((unsigned long)indata & (sizeof(RC4_CHUNK)-1)) | 123 if ( ( ((size_t)indata & (sizeof(RC4_CHUNK)-1)) |
124 ((unsigned long)outdata & (sizeof(RC4_CHUNK)-1)) ) == 0 ) 124 ((size_t)outdata & (sizeof(RC4_CHUNK)-1)) ) == 0 )
125 { 125 {
126 RC4_CHUNK ichunk,otp; 126 RC4_CHUNK ichunk,otp;
127 const union { long one; char little; } is_endian = {1}; 127 const union { long one; char little; } is_endian = {1};
@@ -157,7 +157,7 @@ void RC4(RC4_KEY *key, unsigned long len, const unsigned char *indata,
157 if (!is_endian.little) 157 if (!is_endian.little)
158 { /* BIG-ENDIAN CASE */ 158 { /* BIG-ENDIAN CASE */
159# define BESHFT(c) (((sizeof(RC4_CHUNK)-(c)-1)*8)&(sizeof(RC4_CHUNK)*8-1)) 159# define BESHFT(c) (((sizeof(RC4_CHUNK)-(c)-1)*8)&(sizeof(RC4_CHUNK)*8-1))
160 for (;len&~(sizeof(RC4_CHUNK)-1);len-=sizeof(RC4_CHUNK)) 160 for (;len&(0-sizeof(RC4_CHUNK));len-=sizeof(RC4_CHUNK))
161 { 161 {
162 ichunk = *(RC4_CHUNK *)indata; 162 ichunk = *(RC4_CHUNK *)indata;
163 otp = RC4_STEP<<BESHFT(0); 163 otp = RC4_STEP<<BESHFT(0);
@@ -210,7 +210,7 @@ void RC4(RC4_KEY *key, unsigned long len, const unsigned char *indata,
210 else 210 else
211 { /* LITTLE-ENDIAN CASE */ 211 { /* LITTLE-ENDIAN CASE */
212# define LESHFT(c) (((c)*8)&(sizeof(RC4_CHUNK)*8-1)) 212# define LESHFT(c) (((c)*8)&(sizeof(RC4_CHUNK)*8-1))
213 for (;len&~(sizeof(RC4_CHUNK)-1);len-=sizeof(RC4_CHUNK)) 213 for (;len&(0-sizeof(RC4_CHUNK));len-=sizeof(RC4_CHUNK))
214 { 214 {
215 ichunk = *(RC4_CHUNK *)indata; 215 ichunk = *(RC4_CHUNK *)indata;
216 otp = RC4_STEP; 216 otp = RC4_STEP;
@@ -276,7 +276,7 @@ void RC4(RC4_KEY *key, unsigned long len, const unsigned char *indata,
276#define RC4_LOOP(a,b,i) LOOP(a[i],b[i]) 276#define RC4_LOOP(a,b,i) LOOP(a[i],b[i])
277#endif 277#endif
278 278
279 i=(int)(len>>3L); 279 i=len>>3;
280 if (i) 280 if (i)
281 { 281 {
282 for (;;) 282 for (;;)
@@ -296,7 +296,7 @@ void RC4(RC4_KEY *key, unsigned long len, const unsigned char *indata,
296 if (--i == 0) break; 296 if (--i == 0) break;
297 } 297 }
298 } 298 }
299 i=(int)len&0x07; 299 i=len&0x07;
300 if (i) 300 if (i)
301 { 301 {
302 for (;;) 302 for (;;)
diff --git a/src/lib/libcrypto/rc4/rc4_fblk.c b/src/lib/libcrypto/rc4/rc4_fblk.c
deleted file mode 100644
index 1b2a42979b..0000000000
--- a/src/lib/libcrypto/rc4/rc4_fblk.c
+++ /dev/null
@@ -1,75 +0,0 @@
1/* crypto/rc4/rc4_fblk.c */
2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project.
4 */
5/* ====================================================================
6 * Copyright (c) 2008 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 * licensing@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
54
55#include <openssl/rc4.h>
56#include "rc4_locl.h"
57#include <openssl/opensslv.h>
58#include <openssl/crypto.h>
59#ifdef OPENSSL_FIPS
60#include <openssl/fips.h>
61#endif
62
63/* FIPS mode blocking for RC4 has to be done separately since RC4_set_key
64 * may be implemented in an assembly language file.
65 */
66
67#ifdef OPENSSL_FIPS
68void RC4_set_key(RC4_KEY *key, int len, const unsigned char *data)
69 {
70 if (FIPS_mode())
71 FIPS_BAD_ABORT(RC4)
72 private_RC4_set_key(key, len, data);
73 }
74#endif
75
diff --git a/src/lib/libcrypto/rc4/rc4_skey.c b/src/lib/libcrypto/rc4/rc4_skey.c
index 4478d1a4b3..b22c40b0bd 100644
--- a/src/lib/libcrypto/rc4/rc4_skey.c
+++ b/src/lib/libcrypto/rc4/rc4_skey.c
@@ -59,11 +59,6 @@
59#include <openssl/rc4.h> 59#include <openssl/rc4.h>
60#include "rc4_locl.h" 60#include "rc4_locl.h"
61#include <openssl/opensslv.h> 61#include <openssl/opensslv.h>
62#include <openssl/crypto.h>
63#ifdef OPENSSL_FIPS
64#include <openssl/fips.h>
65#endif
66
67 62
68const char RC4_version[]="RC4" OPENSSL_VERSION_PTEXT; 63const char RC4_version[]="RC4" OPENSSL_VERSION_PTEXT;
69 64
@@ -90,11 +85,7 @@ const char *RC4_options(void)
90 * Date: Wed, 14 Sep 1994 06:35:31 GMT 85 * Date: Wed, 14 Sep 1994 06:35:31 GMT
91 */ 86 */
92 87
93#ifdef OPENSSL_FIPS
94void private_RC4_set_key(RC4_KEY *key, int len, const unsigned char *data)
95#else
96void RC4_set_key(RC4_KEY *key, int len, const unsigned char *data) 88void RC4_set_key(RC4_KEY *key, int len, const unsigned char *data)
97#endif
98 { 89 {
99 register RC4_INT tmp; 90 register RC4_INT tmp;
100 register int id1,id2; 91 register int id1,id2;
@@ -128,20 +119,14 @@ void RC4_set_key(RC4_KEY *key, int len, const unsigned char *data)
128 * implementations suffer from significant performance 119 * implementations suffer from significant performance
129 * losses then, e.g. PIII exhibits >2x deterioration, 120 * losses then, e.g. PIII exhibits >2x deterioration,
130 * and so does Opteron. In order to assure optimal 121 * and so does Opteron. In order to assure optimal
131 * all-round performance, we detect P4 at run-time by 122 * all-round performance, let us [try to] detect P4 at
132 * checking upon reserved bit 20 in CPU capability 123 * run-time by checking upon HTT bit in CPU capability
133 * vector and set up compressed key schedule, which is 124 * vector and set up compressed key schedule, which is
134 * recognized by correspondingly updated assembler 125 * recognized by correspondingly updated assembler
135 * module... Bit 20 is set up by OPENSSL_ia32_cpuid. 126 * module...
136 *
137 * <appro@fy.chalmers.se> 127 * <appro@fy.chalmers.se>
138 */ 128 */
139#ifdef OPENSSL_FIPS
140 unsigned long *ia32cap_ptr = OPENSSL_ia32cap_loc();
141 if (ia32cap_ptr && (*ia32cap_ptr & (1<<28))) {
142#else
143 if (OPENSSL_ia32cap_P & (1<<28)) { 129 if (OPENSSL_ia32cap_P & (1<<28)) {
144#endif
145 unsigned char *cp=(unsigned char *)d; 130 unsigned char *cp=(unsigned char *)d;
146 131
147 for (i=0;i<256;i++) cp[i]=i; 132 for (i=0;i<256;i++) cp[i]=i;
diff --git a/src/lib/libcrypto/rc4/rc4test.c b/src/lib/libcrypto/rc4/rc4test.c
index 54b597fa26..633a79e758 100644
--- a/src/lib/libcrypto/rc4/rc4test.c
+++ b/src/lib/libcrypto/rc4/rc4test.c
@@ -114,8 +114,8 @@ static unsigned char output[7][30]={
114 114
115int main(int argc, char *argv[]) 115int main(int argc, char *argv[])
116 { 116 {
117 int err=0; 117 int i,err=0;
118 unsigned int i, j; 118 int j;
119 unsigned char *p; 119 unsigned char *p;
120 RC4_KEY key; 120 RC4_KEY key;
121 unsigned char obuf[512]; 121 unsigned char obuf[512];
@@ -129,12 +129,12 @@ int main(int argc, char *argv[])
129 { 129 {
130 printf("error calculating RC4\n"); 130 printf("error calculating RC4\n");
131 printf("output:"); 131 printf("output:");
132 for (j=0; j<data_len[i]+1U; j++) 132 for (j=0; j<data_len[i]+1; j++)
133 printf(" %02x",obuf[j]); 133 printf(" %02x",obuf[j]);
134 printf("\n"); 134 printf("\n");
135 printf("expect:"); 135 printf("expect:");
136 p= &(output[i][0]); 136 p= &(output[i][0]);
137 for (j=0; j<data_len[i]+1U; j++) 137 for (j=0; j<data_len[i]+1; j++)
138 printf(" %02x",*(p++)); 138 printf(" %02x",*(p++));
139 printf("\n"); 139 printf("\n");
140 err++; 140 err++;
@@ -180,12 +180,12 @@ int main(int argc, char *argv[])
180 { 180 {
181 printf("error in RC4 multi-call processing\n"); 181 printf("error in RC4 multi-call processing\n");
182 printf("output:"); 182 printf("output:");
183 for (j=0; j<data_len[3]+1U; j++) 183 for (j=0; j<data_len[3]+1; j++)
184 printf(" %02x",obuf[j]); 184 printf(" %02x",obuf[j]);
185 printf("\n"); 185 printf("\n");
186 printf("expect:"); 186 printf("expect:");
187 p= &(output[3][0]); 187 p= &(output[3][0]);
188 for (j=0; j<data_len[3]+1U; j++) 188 for (j=0; j<data_len[3]+1; j++)
189 printf(" %02x",*(p++)); 189 printf(" %02x",*(p++));
190 err++; 190 err++;
191 } 191 }
@@ -216,11 +216,11 @@ int main(int argc, char *argv[])
216 if (memcmp(md,expected,sizeof(md))) { 216 if (memcmp(md,expected,sizeof(md))) {
217 printf("error in RC4 bulk test\n"); 217 printf("error in RC4 bulk test\n");
218 printf("output:"); 218 printf("output:");
219 for (j=0; j<sizeof(md); j++) 219 for (j=0; j<(int)sizeof(md); j++)
220 printf(" %02x",md[j]); 220 printf(" %02x",md[j]);
221 printf("\n"); 221 printf("\n");
222 printf("expect:"); 222 printf("expect:");
223 for (j=0; j<sizeof(md); j++) 223 for (j=0; j<(int)sizeof(md); j++)
224 printf(" %02x",expected[j]); 224 printf(" %02x",expected[j]);
225 printf("\n"); 225 printf("\n");
226 err++; 226 err++;
diff --git a/src/lib/libcrypto/rc5/Makefile.ssl b/src/lib/libcrypto/rc5/Makefile.ssl
deleted file mode 100644
index 3f9632f8f7..0000000000
--- a/src/lib/libcrypto/rc5/Makefile.ssl
+++ /dev/null
@@ -1,108 +0,0 @@
1#
2# SSLeay/crypto/rc5/Makefile
3#
4
5DIR= rc5
6TOP= ../..
7CC= cc
8CPP= $(CC) -E
9INCLUDES=
10CFLAG=-g
11INSTALL_PREFIX=
12OPENSSLDIR= /usr/local/ssl
13INSTALLTOP=/usr/local/ssl
14MAKE= make -f Makefile.ssl
15MAKEDEPPROG= makedepend
16MAKEDEPEND= $(TOP)/util/domd $(TOP) -MD $(MAKEDEPPROG)
17MAKEFILE= Makefile.ssl
18AR= ar r
19
20RC5_ENC= rc5_enc.o
21# or use
22#DES_ENC= r586-elf.o
23
24CFLAGS= $(INCLUDES) $(CFLAG)
25ASFLAGS= $(INCLUDES) $(ASFLAG)
26
27GENERAL=Makefile
28TEST=rc5test.c
29APPS=
30
31LIB=$(TOP)/libcrypto.a
32LIBSRC=rc5_skey.c rc5_ecb.c rc5_enc.c rc5cfb64.c rc5ofb64.c
33LIBOBJ=rc5_skey.o rc5_ecb.o $(RC5_ENC) rc5cfb64.o rc5ofb64.o
34
35SRC= $(LIBSRC)
36
37EXHEADER= rc5.h
38HEADER= rc5_locl.h $(EXHEADER)
39
40ALL= $(GENERAL) $(SRC) $(HEADER)
41
42top:
43 (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all)
44
45all: lib
46
47lib: $(LIBOBJ)
48 $(AR) $(LIB) $(LIBOBJ)
49 $(RANLIB) $(LIB) || echo Never mind.
50 @touch lib
51
52# elf
53asm/r586-elf.s: asm/rc5-586.pl ../perlasm/x86asm.pl ../perlasm/cbc.pl
54 (cd asm; $(PERL) rc5-586.pl elf $(CFLAGS) > r586-elf.s)
55
56# a.out
57asm/r586-out.o: asm/r586unix.cpp
58 $(CPP) -DOUT asm/r586unix.cpp | as -o asm/r586-out.o
59
60# bsdi
61asm/r586bsdi.o: asm/r586unix.cpp
62 $(CPP) -DBSDI asm/r586unix.cpp | sed 's/ :/:/' | as -o asm/r586bsdi.o
63
64asm/r586unix.cpp: asm/rc5-586.pl ../perlasm/x86asm.pl ../perlasm/cbc.pl
65 (cd asm; $(PERL) rc5-586.pl cpp >r586unix.cpp)
66
67files:
68 $(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO
69
70links:
71 @sh $(TOP)/util/point.sh Makefile.ssl Makefile
72 @$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER)
73 @$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST)
74 @$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS)
75
76install:
77 @for i in $(EXHEADER) ; \
78 do \
79 (cp $$i $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i; \
80 chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i ); \
81 done;
82
83tags:
84 ctags $(SRC)
85
86tests:
87
88lint:
89 lint -DLINT $(INCLUDES) $(SRC)>fluff
90
91depend:
92 $(MAKEDEPEND) -- $(CFLAG) $(INCLUDES) $(DEPFLAG) -- $(PROGS) $(LIBSRC)
93
94dclean:
95 $(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
96 mv -f Makefile.new $(MAKEFILE)
97
98clean:
99 rm -f asm/r586unix.cpp asm/*-elf.* *.o asm/*.o *.obj lib tags core .pure .nfs* *.old *.bak fluff
100
101# DO NOT DELETE THIS LINE -- make depend depends on it.
102
103rc5_ecb.o: ../../include/openssl/opensslv.h ../../include/openssl/rc5.h
104rc5_ecb.o: rc5_ecb.c rc5_locl.h
105rc5_enc.o: ../../include/openssl/rc5.h rc5_enc.c rc5_locl.h
106rc5_skey.o: ../../include/openssl/rc5.h rc5_locl.h rc5_skey.c
107rc5cfb64.o: ../../include/openssl/rc5.h rc5_locl.h rc5cfb64.c
108rc5ofb64.o: ../../include/openssl/rc5.h rc5_locl.h rc5ofb64.c
diff --git a/src/lib/libcrypto/rc5/rc5.h b/src/lib/libcrypto/rc5/rc5.h
index f73a2a02a4..4b3c153b50 100644
--- a/src/lib/libcrypto/rc5/rc5.h
+++ b/src/lib/libcrypto/rc5/rc5.h
@@ -94,10 +94,7 @@ typedef struct rc5_key_st
94 RC5_32_INT data[2*(RC5_16_ROUNDS+1)]; 94 RC5_32_INT data[2*(RC5_16_ROUNDS+1)];
95 } RC5_32_KEY; 95 } RC5_32_KEY;
96 96
97#ifdef OPENSSL_FIPS 97
98void private_RC5_32_set_key(RC5_32_KEY *key, int len, const unsigned char *data,
99 int rounds);
100#endif
101void RC5_32_set_key(RC5_32_KEY *key, int len, const unsigned char *data, 98void RC5_32_set_key(RC5_32_KEY *key, int len, const unsigned char *data,
102 int rounds); 99 int rounds);
103void RC5_32_ecb_encrypt(const unsigned char *in,unsigned char *out,RC5_32_KEY *key, 100void RC5_32_ecb_encrypt(const unsigned char *in,unsigned char *out,RC5_32_KEY *key,
diff --git a/src/lib/libcrypto/ripemd/Makefile.ssl b/src/lib/libcrypto/ripemd/Makefile.ssl
deleted file mode 100644
index f22ac790ae..0000000000
--- a/src/lib/libcrypto/ripemd/Makefile.ssl
+++ /dev/null
@@ -1,108 +0,0 @@
1#
2# SSLeay/crypto/ripemd/Makefile
3#
4
5DIR= ripemd
6TOP= ../..
7CC= cc
8CPP= $(CC) -E
9INCLUDES=
10CFLAG=-g
11INSTALL_PREFIX=
12OPENSSLDIR= /usr/local/ssl
13INSTALLTOP=/usr/local/ssl
14MAKE= make -f Makefile.ssl
15MAKEDEPPROG= makedepend
16MAKEDEPEND= $(TOP)/util/domd $(TOP) -MD $(MAKEDEPPROG)
17MAKEFILE= Makefile.ssl
18AR= ar r
19
20RIP_ASM_OBJ=
21
22CFLAGS= $(INCLUDES) $(CFLAG)
23ASFLAGS= $(INCLUDES) $(ASFLAG)
24
25GENERAL=Makefile
26TEST=rmdtest.c
27APPS=
28
29LIB=$(TOP)/libcrypto.a
30LIBSRC=rmd_dgst.c rmd_one.c
31LIBOBJ=rmd_dgst.o rmd_one.o $(RMD160_ASM_OBJ)
32
33SRC= $(LIBSRC)
34
35EXHEADER= ripemd.h
36HEADER= rmd_locl.h rmdconst.h $(EXHEADER)
37
38ALL= $(GENERAL) $(SRC) $(HEADER)
39
40top:
41 (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all)
42
43all: lib
44
45lib: $(LIBOBJ)
46 $(AR) $(LIB) $(LIBOBJ)
47 $(RANLIB) $(LIB) || echo Never mind.
48 @touch lib
49
50# elf
51asm/rm86-elf.s: asm/rmd-586.pl ../perlasm/x86asm.pl
52 (cd asm; $(PERL) rmd-586.pl elf $(CFLAGS) > rm86-elf.s)
53
54# a.out
55asm/rm86-out.o: asm/rm86unix.cpp
56 $(CPP) -DOUT asm/rm86unix.cpp | as -o asm/rm86-out.o
57
58# bsdi
59asm/rm86bsdi.o: asm/rm86unix.cpp
60 $(CPP) -DBSDI asm/rm86unix.cpp | sed 's/ :/:/' | as -o asm/rm86bsdi.o
61
62asm/rm86unix.cpp: asm/rmd-586.pl ../perlasm/x86asm.pl
63 (cd asm; $(PERL) rmd-586.pl cpp >rm86unix.cpp)
64
65files:
66 $(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO
67
68links:
69 @sh $(TOP)/util/point.sh Makefile.ssl Makefile
70 @$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER)
71 @$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST)
72 @$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS)
73
74install:
75 @for i in $(EXHEADER) ; \
76 do \
77 (cp $$i $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i; \
78 chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i ); \
79 done;
80
81tags:
82 ctags $(SRC)
83
84tests:
85
86lint:
87 lint -DLINT $(INCLUDES) $(SRC)>fluff
88
89depend:
90 $(MAKEDEPEND) -- $(CFLAG) $(INCLUDES) $(DEPFLAG) -- $(PROGS) $(LIBSRC)
91
92dclean:
93 $(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
94 mv -f Makefile.new $(MAKEFILE)
95
96clean:
97 rm -f asm/rm86unix.cpp asm/*-elf.* *.o asm/*.o *.obj lib tags core .pure .nfs* *.old *.bak fluff
98
99# DO NOT DELETE THIS LINE -- make depend depends on it.
100
101rmd_dgst.o: ../../include/openssl/e_os2.h ../../include/openssl/opensslconf.h
102rmd_dgst.o: ../../include/openssl/opensslv.h ../../include/openssl/ripemd.h
103rmd_dgst.o: ../md32_common.h rmd_dgst.c rmd_locl.h rmdconst.h
104rmd_one.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
105rmd_one.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
106rmd_one.o: ../../include/openssl/ripemd.h ../../include/openssl/safestack.h
107rmd_one.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
108rmd_one.o: rmd_one.c
diff --git a/src/lib/libcrypto/ripemd/asm/rmd-586.pl b/src/lib/libcrypto/ripemd/asm/rmd-586.pl
index 4f3c4c967f..e8b2bc2db2 100644
--- a/src/lib/libcrypto/ripemd/asm/rmd-586.pl
+++ b/src/lib/libcrypto/ripemd/asm/rmd-586.pl
@@ -5,7 +5,8 @@
5 5
6$normal=0; 6$normal=0;
7 7
8push(@INC,"perlasm","../../perlasm"); 8$0 =~ m/(.*[\/\\])[^\/\\]+$/; $dir=$1;
9push(@INC,"${dir}","${dir}../../perlasm");
9require "x86asm.pl"; 10require "x86asm.pl";
10 11
11&asm_init($ARGV[0],$0); 12&asm_init($ARGV[0],$0);
diff --git a/src/lib/libcrypto/ripemd/ripemd.h b/src/lib/libcrypto/ripemd/ripemd.h
index 3b6d04386d..5942eb6180 100644
--- a/src/lib/libcrypto/ripemd/ripemd.h
+++ b/src/lib/libcrypto/ripemd/ripemd.h
@@ -70,7 +70,7 @@ extern "C" {
70#error RIPEMD is disabled. 70#error RIPEMD is disabled.
71#endif 71#endif
72 72
73#if defined(OPENSSL_SYS_WIN16) || defined(__LP32__) 73#if defined(__LP32__)
74#define RIPEMD160_LONG unsigned long 74#define RIPEMD160_LONG unsigned long
75#elif defined(OPENSSL_SYS_CRAY) || defined(__ILP64__) 75#elif defined(OPENSSL_SYS_CRAY) || defined(__ILP64__)
76#define RIPEMD160_LONG unsigned long 76#define RIPEMD160_LONG unsigned long
@@ -90,9 +90,7 @@ typedef struct RIPEMD160state_st
90 RIPEMD160_LONG data[RIPEMD160_LBLOCK]; 90 RIPEMD160_LONG data[RIPEMD160_LBLOCK];
91 unsigned int num; 91 unsigned int num;
92 } RIPEMD160_CTX; 92 } RIPEMD160_CTX;
93#ifdef OPENSSL_FIPS 93
94int private_RIPEMD160_Init(RIPEMD160_CTX *c);
95#endif
96int RIPEMD160_Init(RIPEMD160_CTX *c); 94int RIPEMD160_Init(RIPEMD160_CTX *c);
97int RIPEMD160_Update(RIPEMD160_CTX *c, const void *data, size_t len); 95int RIPEMD160_Update(RIPEMD160_CTX *c, const void *data, size_t len);
98int RIPEMD160_Final(unsigned char *md, RIPEMD160_CTX *c); 96int RIPEMD160_Final(unsigned char *md, RIPEMD160_CTX *c);
diff --git a/src/lib/libcrypto/ripemd/rmd_dgst.c b/src/lib/libcrypto/ripemd/rmd_dgst.c
index a845e17ed8..2097a66c03 100644
--- a/src/lib/libcrypto/ripemd/rmd_dgst.c
+++ b/src/lib/libcrypto/ripemd/rmd_dgst.c
@@ -59,11 +59,6 @@
59#include <stdio.h> 59#include <stdio.h>
60#include "rmd_locl.h" 60#include "rmd_locl.h"
61#include <openssl/opensslv.h> 61#include <openssl/opensslv.h>
62#include <openssl/err.h>
63#ifdef OPENSSL_FIPS
64#include <openssl/fips.h>
65#endif
66
67 62
68const char RMD160_version[]="RIPE-MD160" OPENSSL_VERSION_PTEXT; 63const char RMD160_version[]="RIPE-MD160" OPENSSL_VERSION_PTEXT;
69 64
@@ -74,16 +69,14 @@ const char RMD160_version[]="RIPE-MD160" OPENSSL_VERSION_PTEXT;
74 void ripemd160_block(RIPEMD160_CTX *c, unsigned long *p,size_t num); 69 void ripemd160_block(RIPEMD160_CTX *c, unsigned long *p,size_t num);
75# endif 70# endif
76 71
77FIPS_NON_FIPS_MD_Init(RIPEMD160) 72int RIPEMD160_Init(RIPEMD160_CTX *c)
78 { 73 {
74 memset (c,0,sizeof(*c));
79 c->A=RIPEMD160_A; 75 c->A=RIPEMD160_A;
80 c->B=RIPEMD160_B; 76 c->B=RIPEMD160_B;
81 c->C=RIPEMD160_C; 77 c->C=RIPEMD160_C;
82 c->D=RIPEMD160_D; 78 c->D=RIPEMD160_D;
83 c->E=RIPEMD160_E; 79 c->E=RIPEMD160_E;
84 c->Nl=0;
85 c->Nh=0;
86 c->num=0;
87 return 1; 80 return 1;
88 } 81 }
89 82
diff --git a/src/lib/libcrypto/ripemd/rmd_locl.h b/src/lib/libcrypto/ripemd/rmd_locl.h
index ce12a8000e..f14b346e66 100644
--- a/src/lib/libcrypto/ripemd/rmd_locl.h
+++ b/src/lib/libcrypto/ripemd/rmd_locl.h
@@ -72,7 +72,7 @@
72 */ 72 */
73#ifdef RMD160_ASM 73#ifdef RMD160_ASM
74# if defined(__i386) || defined(__i386__) || defined(_M_IX86) || defined(__INTEL__) 74# if defined(__i386) || defined(__i386__) || defined(_M_IX86) || defined(__INTEL__)
75# define ripemd160_block_host_order ripemd160_block_asm_data_order 75# define ripemd160_block_data_order ripemd160_block_asm_data_order
76# endif 76# endif
77#endif 77#endif
78 78
diff --git a/src/lib/libcrypto/rsa/Makefile b/src/lib/libcrypto/rsa/Makefile
index 7b1fd6428c..bb64223e05 100644
--- a/src/lib/libcrypto/rsa/Makefile
+++ b/src/lib/libcrypto/rsa/Makefile
@@ -19,10 +19,12 @@ APPS=
19LIB=$(TOP)/libcrypto.a 19LIB=$(TOP)/libcrypto.a
20LIBSRC= rsa_eay.c rsa_gen.c rsa_lib.c rsa_sign.c rsa_saos.c rsa_err.c \ 20LIBSRC= rsa_eay.c rsa_gen.c rsa_lib.c rsa_sign.c rsa_saos.c rsa_err.c \
21 rsa_pk1.c rsa_ssl.c rsa_none.c rsa_oaep.c rsa_chk.c rsa_null.c \ 21 rsa_pk1.c rsa_ssl.c rsa_none.c rsa_oaep.c rsa_chk.c rsa_null.c \
22 rsa_pss.c rsa_x931.c rsa_x931g.c rsa_asn1.c rsa_depr.c rsa_eng.c 22 rsa_pss.c rsa_x931.c rsa_asn1.c rsa_depr.c rsa_ameth.c rsa_prn.c \
23 rsa_pmeth.c
23LIBOBJ= rsa_eay.o rsa_gen.o rsa_lib.o rsa_sign.o rsa_saos.o rsa_err.o \ 24LIBOBJ= rsa_eay.o rsa_gen.o rsa_lib.o rsa_sign.o rsa_saos.o rsa_err.o \
24 rsa_pk1.o rsa_ssl.o rsa_none.o rsa_oaep.o rsa_chk.o rsa_null.o \ 25 rsa_pk1.o rsa_ssl.o rsa_none.o rsa_oaep.o rsa_chk.o rsa_null.o \
25 rsa_pss.o rsa_x931.o rsa_x931g.o rsa_asn1.o rsa_depr.o rsa_eng.o 26 rsa_pss.o rsa_x931.o rsa_asn1.o rsa_depr.o rsa_ameth.o rsa_prn.o \
27 rsa_pmeth.o
26 28
27SRC= $(LIBSRC) 29SRC= $(LIBSRC)
28 30
@@ -37,7 +39,7 @@ top:
37all: lib 39all: lib
38 40
39lib: $(LIBOBJ) 41lib: $(LIBOBJ)
40 $(ARX) $(LIB) $(LIBOBJ) 42 $(AR) $(LIB) $(LIBOBJ)
41 $(RANLIB) $(LIB) || echo Never mind. 43 $(RANLIB) $(LIB) || echo Never mind.
42 @touch lib 44 @touch lib
43 45
@@ -78,6 +80,22 @@ clean:
78 80
79# DO NOT DELETE THIS LINE -- make depend depends on it. 81# DO NOT DELETE THIS LINE -- make depend depends on it.
80 82
83rsa_ameth.o: ../../e_os.h ../../include/openssl/asn1.h
84rsa_ameth.o: ../../include/openssl/asn1t.h ../../include/openssl/bio.h
85rsa_ameth.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
86rsa_ameth.o: ../../include/openssl/cms.h ../../include/openssl/crypto.h
87rsa_ameth.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h
88rsa_ameth.o: ../../include/openssl/ecdh.h ../../include/openssl/ecdsa.h
89rsa_ameth.o: ../../include/openssl/err.h ../../include/openssl/evp.h
90rsa_ameth.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
91rsa_ameth.o: ../../include/openssl/objects.h
92rsa_ameth.o: ../../include/openssl/opensslconf.h
93rsa_ameth.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
94rsa_ameth.o: ../../include/openssl/pkcs7.h ../../include/openssl/rsa.h
95rsa_ameth.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
96rsa_ameth.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
97rsa_ameth.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
98rsa_ameth.o: ../asn1/asn1_locl.h ../cryptlib.h rsa_ameth.c
81rsa_asn1.o: ../../e_os.h ../../include/openssl/asn1.h 99rsa_asn1.o: ../../e_os.h ../../include/openssl/asn1.h
82rsa_asn1.o: ../../include/openssl/asn1t.h ../../include/openssl/bio.h 100rsa_asn1.o: ../../include/openssl/asn1t.h ../../include/openssl/bio.h
83rsa_asn1.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h 101rsa_asn1.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
@@ -114,21 +132,6 @@ rsa_eay.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
114rsa_eay.o: ../../include/openssl/rand.h ../../include/openssl/rsa.h 132rsa_eay.o: ../../include/openssl/rand.h ../../include/openssl/rsa.h
115rsa_eay.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h 133rsa_eay.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
116rsa_eay.o: ../../include/openssl/symhacks.h ../cryptlib.h rsa_eay.c 134rsa_eay.o: ../../include/openssl/symhacks.h ../cryptlib.h rsa_eay.c
117rsa_eng.o: ../../e_os.h ../../include/openssl/asn1.h
118rsa_eng.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
119rsa_eng.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
120rsa_eng.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h
121rsa_eng.o: ../../include/openssl/ecdh.h ../../include/openssl/ecdsa.h
122rsa_eng.o: ../../include/openssl/engine.h ../../include/openssl/err.h
123rsa_eng.o: ../../include/openssl/evp.h ../../include/openssl/fips.h
124rsa_eng.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
125rsa_eng.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
126rsa_eng.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
127rsa_eng.o: ../../include/openssl/pkcs7.h ../../include/openssl/rand.h
128rsa_eng.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
129rsa_eng.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
130rsa_eng.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h
131rsa_eng.o: ../../include/openssl/x509_vfy.h ../cryptlib.h rsa_eng.c
132rsa_err.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h 135rsa_err.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
133rsa_err.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h 136rsa_err.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
134rsa_err.o: ../../include/openssl/err.h ../../include/openssl/lhash.h 137rsa_err.o: ../../include/openssl/err.h ../../include/openssl/lhash.h
@@ -151,15 +154,15 @@ rsa_lib.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
151rsa_lib.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h 154rsa_lib.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h
152rsa_lib.o: ../../include/openssl/ecdh.h ../../include/openssl/ecdsa.h 155rsa_lib.o: ../../include/openssl/ecdh.h ../../include/openssl/ecdsa.h
153rsa_lib.o: ../../include/openssl/engine.h ../../include/openssl/err.h 156rsa_lib.o: ../../include/openssl/engine.h ../../include/openssl/err.h
154rsa_lib.o: ../../include/openssl/evp.h ../../include/openssl/fips.h 157rsa_lib.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h
155rsa_lib.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h 158rsa_lib.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
156rsa_lib.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h 159rsa_lib.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
157rsa_lib.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h 160rsa_lib.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h
158rsa_lib.o: ../../include/openssl/pkcs7.h ../../include/openssl/rand.h 161rsa_lib.o: ../../include/openssl/rand.h ../../include/openssl/rsa.h
159rsa_lib.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h 162rsa_lib.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
160rsa_lib.o: ../../include/openssl/sha.h ../../include/openssl/stack.h 163rsa_lib.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
161rsa_lib.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h 164rsa_lib.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
162rsa_lib.o: ../../include/openssl/x509_vfy.h ../cryptlib.h rsa_lib.c 165rsa_lib.o: ../cryptlib.h rsa_lib.c
163rsa_none.o: ../../e_os.h ../../include/openssl/asn1.h 166rsa_none.o: ../../e_os.h ../../include/openssl/asn1.h
164rsa_none.o: ../../include/openssl/bio.h ../../include/openssl/bn.h 167rsa_none.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
165rsa_none.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 168rsa_none.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
@@ -182,9 +185,9 @@ rsa_oaep.o: ../../e_os.h ../../include/openssl/asn1.h
182rsa_oaep.o: ../../include/openssl/bio.h ../../include/openssl/bn.h 185rsa_oaep.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
183rsa_oaep.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 186rsa_oaep.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
184rsa_oaep.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h 187rsa_oaep.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
185rsa_oaep.o: ../../include/openssl/evp.h ../../include/openssl/fips.h 188rsa_oaep.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h
186rsa_oaep.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h 189rsa_oaep.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
187rsa_oaep.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h 190rsa_oaep.o: ../../include/openssl/opensslconf.h
188rsa_oaep.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h 191rsa_oaep.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
189rsa_oaep.o: ../../include/openssl/rand.h ../../include/openssl/rsa.h 192rsa_oaep.o: ../../include/openssl/rand.h ../../include/openssl/rsa.h
190rsa_oaep.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h 193rsa_oaep.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
@@ -199,27 +202,50 @@ rsa_pk1.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
199rsa_pk1.o: ../../include/openssl/rand.h ../../include/openssl/rsa.h 202rsa_pk1.o: ../../include/openssl/rand.h ../../include/openssl/rsa.h
200rsa_pk1.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h 203rsa_pk1.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
201rsa_pk1.o: ../../include/openssl/symhacks.h ../cryptlib.h rsa_pk1.c 204rsa_pk1.o: ../../include/openssl/symhacks.h ../cryptlib.h rsa_pk1.c
205rsa_pmeth.o: ../../e_os.h ../../include/openssl/asn1.h
206rsa_pmeth.o: ../../include/openssl/asn1t.h ../../include/openssl/bio.h
207rsa_pmeth.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
208rsa_pmeth.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
209rsa_pmeth.o: ../../include/openssl/ec.h ../../include/openssl/ecdh.h
210rsa_pmeth.o: ../../include/openssl/ecdsa.h ../../include/openssl/err.h
211rsa_pmeth.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h
212rsa_pmeth.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
213rsa_pmeth.o: ../../include/openssl/opensslconf.h
214rsa_pmeth.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
215rsa_pmeth.o: ../../include/openssl/pkcs7.h ../../include/openssl/rsa.h
216rsa_pmeth.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
217rsa_pmeth.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
218rsa_pmeth.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
219rsa_pmeth.o: ../cryptlib.h ../evp/evp_locl.h rsa_locl.h rsa_pmeth.c
220rsa_prn.o: ../../e_os.h ../../include/openssl/asn1.h
221rsa_prn.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
222rsa_prn.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
223rsa_prn.o: ../../include/openssl/err.h ../../include/openssl/evp.h
224rsa_prn.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
225rsa_prn.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
226rsa_prn.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
227rsa_prn.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
228rsa_prn.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
229rsa_prn.o: ../cryptlib.h rsa_prn.c
202rsa_pss.o: ../../e_os.h ../../include/openssl/asn1.h 230rsa_pss.o: ../../e_os.h ../../include/openssl/asn1.h
203rsa_pss.o: ../../include/openssl/bio.h ../../include/openssl/bn.h 231rsa_pss.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
204rsa_pss.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 232rsa_pss.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
205rsa_pss.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h 233rsa_pss.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
206rsa_pss.o: ../../include/openssl/evp.h ../../include/openssl/fips.h 234rsa_pss.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h
207rsa_pss.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h 235rsa_pss.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
208rsa_pss.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h 236rsa_pss.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
209rsa_pss.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h 237rsa_pss.o: ../../include/openssl/ossl_typ.h ../../include/openssl/rand.h
210rsa_pss.o: ../../include/openssl/rand.h ../../include/openssl/rsa.h 238rsa_pss.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
211rsa_pss.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h 239rsa_pss.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
212rsa_pss.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 240rsa_pss.o: ../../include/openssl/symhacks.h ../cryptlib.h rsa_pss.c
213rsa_pss.o: ../cryptlib.h rsa_pss.c
214rsa_saos.o: ../../e_os.h ../../include/openssl/asn1.h 241rsa_saos.o: ../../e_os.h ../../include/openssl/asn1.h
215rsa_saos.o: ../../include/openssl/bio.h ../../include/openssl/bn.h 242rsa_saos.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
216rsa_saos.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 243rsa_saos.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
217rsa_saos.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h 244rsa_saos.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h
218rsa_saos.o: ../../include/openssl/ecdh.h ../../include/openssl/ecdsa.h 245rsa_saos.o: ../../include/openssl/ecdh.h ../../include/openssl/ecdsa.h
219rsa_saos.o: ../../include/openssl/err.h ../../include/openssl/evp.h 246rsa_saos.o: ../../include/openssl/err.h ../../include/openssl/evp.h
220rsa_saos.o: ../../include/openssl/fips.h ../../include/openssl/lhash.h 247rsa_saos.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
221rsa_saos.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h 248rsa_saos.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
222rsa_saos.o: ../../include/openssl/opensslconf.h
223rsa_saos.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h 249rsa_saos.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
224rsa_saos.o: ../../include/openssl/pkcs7.h ../../include/openssl/rsa.h 250rsa_saos.o: ../../include/openssl/pkcs7.h ../../include/openssl/rsa.h
225rsa_saos.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h 251rsa_saos.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
@@ -232,15 +258,14 @@ rsa_sign.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
232rsa_sign.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h 258rsa_sign.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h
233rsa_sign.o: ../../include/openssl/ecdh.h ../../include/openssl/ecdsa.h 259rsa_sign.o: ../../include/openssl/ecdh.h ../../include/openssl/ecdsa.h
234rsa_sign.o: ../../include/openssl/err.h ../../include/openssl/evp.h 260rsa_sign.o: ../../include/openssl/err.h ../../include/openssl/evp.h
235rsa_sign.o: ../../include/openssl/fips.h ../../include/openssl/lhash.h 261rsa_sign.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
236rsa_sign.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h 262rsa_sign.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
237rsa_sign.o: ../../include/openssl/opensslconf.h
238rsa_sign.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h 263rsa_sign.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
239rsa_sign.o: ../../include/openssl/pkcs7.h ../../include/openssl/rsa.h 264rsa_sign.o: ../../include/openssl/pkcs7.h ../../include/openssl/rsa.h
240rsa_sign.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h 265rsa_sign.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
241rsa_sign.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 266rsa_sign.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
242rsa_sign.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h 267rsa_sign.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
243rsa_sign.o: ../cryptlib.h rsa_sign.c 268rsa_sign.o: ../cryptlib.h rsa_locl.h rsa_sign.c
244rsa_ssl.o: ../../e_os.h ../../include/openssl/asn1.h 269rsa_ssl.o: ../../e_os.h ../../include/openssl/asn1.h
245rsa_ssl.o: ../../include/openssl/bio.h ../../include/openssl/bn.h 270rsa_ssl.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
246rsa_ssl.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 271rsa_ssl.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
@@ -260,11 +285,3 @@ rsa_x931.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
260rsa_x931.o: ../../include/openssl/rand.h ../../include/openssl/rsa.h 285rsa_x931.o: ../../include/openssl/rand.h ../../include/openssl/rsa.h
261rsa_x931.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h 286rsa_x931.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
262rsa_x931.o: ../../include/openssl/symhacks.h ../cryptlib.h rsa_x931.c 287rsa_x931.o: ../../include/openssl/symhacks.h ../cryptlib.h rsa_x931.c
263rsa_x931g.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
264rsa_x931g.o: ../../include/openssl/bn.h ../../include/openssl/crypto.h
265rsa_x931g.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
266rsa_x931g.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
267rsa_x931g.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
268rsa_x931g.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
269rsa_x931g.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
270rsa_x931g.o: rsa_x931g.c
diff --git a/src/lib/libcrypto/rsa/Makefile.ssl b/src/lib/libcrypto/rsa/Makefile.ssl
deleted file mode 100644
index 8089344a04..0000000000
--- a/src/lib/libcrypto/rsa/Makefile.ssl
+++ /dev/null
@@ -1,241 +0,0 @@
1#
2# SSLeay/crypto/rsa/Makefile
3#
4
5DIR= rsa
6TOP= ../..
7CC= cc
8INCLUDES= -I.. -I$(TOP) -I../../include
9CFLAG=-g
10INSTALL_PREFIX=
11OPENSSLDIR= /usr/local/ssl
12INSTALLTOP=/usr/local/ssl
13MAKE= make -f Makefile.ssl
14MAKEDEPPROG= makedepend
15MAKEDEPEND= $(TOP)/util/domd $(TOP) -MD $(MAKEDEPPROG)
16MAKEFILE= Makefile.ssl
17AR= ar r
18
19CFLAGS= $(INCLUDES) $(CFLAG)
20
21GENERAL=Makefile
22TEST=rsa_test.c
23APPS=
24
25LIB=$(TOP)/libcrypto.a
26LIBSRC= rsa_eay.c rsa_gen.c rsa_lib.c rsa_sign.c rsa_saos.c rsa_err.c \
27 rsa_pk1.c rsa_ssl.c rsa_none.c rsa_oaep.c rsa_chk.c rsa_null.c \
28 rsa_asn1.c
29LIBOBJ= rsa_eay.o rsa_gen.o rsa_lib.o rsa_sign.o rsa_saos.o rsa_err.o \
30 rsa_pk1.o rsa_ssl.o rsa_none.o rsa_oaep.o rsa_chk.o rsa_null.o \
31 rsa_asn1.o
32
33SRC= $(LIBSRC)
34
35EXHEADER= rsa.h
36HEADER= $(EXHEADER)
37
38ALL= $(GENERAL) $(SRC) $(HEADER)
39
40top:
41 (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all)
42
43all: lib
44
45lib: $(LIBOBJ)
46 $(AR) $(LIB) $(LIBOBJ)
47 $(RANLIB) $(LIB) || echo Never mind.
48 @touch lib
49
50files:
51 $(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO
52
53links:
54 @sh $(TOP)/util/point.sh Makefile.ssl Makefile
55 @$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER)
56 @$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST)
57 @$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS)
58
59install:
60 @for i in $(EXHEADER) ; \
61 do \
62 (cp $$i $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i; \
63 chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i ); \
64 done;
65
66tags:
67 ctags $(SRC)
68
69tests:
70
71lint:
72 lint -DLINT $(INCLUDES) $(SRC)>fluff
73
74depend:
75 $(MAKEDEPEND) -- $(CFLAG) $(INCLUDES) $(DEPFLAG) -- $(PROGS) $(LIBSRC)
76
77dclean:
78 $(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
79 mv -f Makefile.new $(MAKEFILE)
80
81clean:
82 rm -f *.o */*.o *.obj lib tags core .pure .nfs* *.old *.bak fluff
83
84# DO NOT DELETE THIS LINE -- make depend depends on it.
85
86rsa_asn1.o: ../../e_os.h ../../include/openssl/asn1.h
87rsa_asn1.o: ../../include/openssl/asn1t.h ../../include/openssl/bio.h
88rsa_asn1.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
89rsa_asn1.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
90rsa_asn1.o: ../../include/openssl/err.h ../../include/openssl/lhash.h
91rsa_asn1.o: ../../include/openssl/opensslconf.h
92rsa_asn1.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
93rsa_asn1.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
94rsa_asn1.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
95rsa_asn1.o: ../cryptlib.h rsa_asn1.c
96rsa_chk.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
97rsa_chk.o: ../../include/openssl/bn.h ../../include/openssl/crypto.h
98rsa_chk.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
99rsa_chk.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
100rsa_chk.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
101rsa_chk.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
102rsa_chk.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
103rsa_chk.o: rsa_chk.c
104rsa_eay.o: ../../e_os.h ../../include/openssl/asn1.h
105rsa_eay.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
106rsa_eay.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
107rsa_eay.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
108rsa_eay.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
109rsa_eay.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
110rsa_eay.o: ../../include/openssl/rand.h ../../include/openssl/rsa.h
111rsa_eay.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
112rsa_eay.o: ../../include/openssl/symhacks.h ../cryptlib.h rsa_eay.c
113rsa_err.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
114rsa_err.o: ../../include/openssl/bn.h ../../include/openssl/crypto.h
115rsa_err.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
116rsa_err.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
117rsa_err.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
118rsa_err.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
119rsa_err.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
120rsa_err.o: rsa_err.c
121rsa_gen.o: ../../e_os.h ../../include/openssl/asn1.h
122rsa_gen.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
123rsa_gen.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
124rsa_gen.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
125rsa_gen.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
126rsa_gen.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
127rsa_gen.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
128rsa_gen.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
129rsa_gen.o: ../cryptlib.h rsa_gen.c
130rsa_lib.o: ../../e_os.h ../../include/openssl/asn1.h
131rsa_lib.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
132rsa_lib.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
133rsa_lib.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
134rsa_lib.o: ../../include/openssl/e_os2.h ../../include/openssl/engine.h
135rsa_lib.o: ../../include/openssl/err.h ../../include/openssl/lhash.h
136rsa_lib.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
137rsa_lib.o: ../../include/openssl/ossl_typ.h ../../include/openssl/rand.h
138rsa_lib.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
139rsa_lib.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
140rsa_lib.o: ../../include/openssl/ui.h ../cryptlib.h rsa_lib.c
141rsa_none.o: ../../e_os.h ../../include/openssl/asn1.h
142rsa_none.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
143rsa_none.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
144rsa_none.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
145rsa_none.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
146rsa_none.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
147rsa_none.o: ../../include/openssl/rand.h ../../include/openssl/rsa.h
148rsa_none.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
149rsa_none.o: ../../include/openssl/symhacks.h ../cryptlib.h rsa_none.c
150rsa_null.o: ../../e_os.h ../../include/openssl/asn1.h
151rsa_null.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
152rsa_null.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
153rsa_null.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
154rsa_null.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
155rsa_null.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
156rsa_null.o: ../../include/openssl/rand.h ../../include/openssl/rsa.h
157rsa_null.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
158rsa_null.o: ../../include/openssl/symhacks.h ../cryptlib.h rsa_null.c
159rsa_oaep.o: ../../e_os.h ../../include/openssl/aes.h
160rsa_oaep.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
161rsa_oaep.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
162rsa_oaep.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
163rsa_oaep.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
164rsa_oaep.o: ../../include/openssl/des_old.h ../../include/openssl/dh.h
165rsa_oaep.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
166rsa_oaep.o: ../../include/openssl/err.h ../../include/openssl/evp.h
167rsa_oaep.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h
168rsa_oaep.o: ../../include/openssl/md2.h ../../include/openssl/md4.h
169rsa_oaep.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
170rsa_oaep.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
171rsa_oaep.o: ../../include/openssl/opensslconf.h
172rsa_oaep.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
173rsa_oaep.o: ../../include/openssl/rand.h ../../include/openssl/rc2.h
174rsa_oaep.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
175rsa_oaep.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
176rsa_oaep.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
177rsa_oaep.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
178rsa_oaep.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
179rsa_oaep.o: ../cryptlib.h rsa_oaep.c
180rsa_pk1.o: ../../e_os.h ../../include/openssl/asn1.h
181rsa_pk1.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
182rsa_pk1.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
183rsa_pk1.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
184rsa_pk1.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
185rsa_pk1.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
186rsa_pk1.o: ../../include/openssl/rand.h ../../include/openssl/rsa.h
187rsa_pk1.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
188rsa_pk1.o: ../../include/openssl/symhacks.h ../cryptlib.h rsa_pk1.c
189rsa_saos.o: ../../e_os.h ../../include/openssl/aes.h
190rsa_saos.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
191rsa_saos.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
192rsa_saos.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
193rsa_saos.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
194rsa_saos.o: ../../include/openssl/des_old.h ../../include/openssl/dh.h
195rsa_saos.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
196rsa_saos.o: ../../include/openssl/err.h ../../include/openssl/evp.h
197rsa_saos.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h
198rsa_saos.o: ../../include/openssl/md2.h ../../include/openssl/md4.h
199rsa_saos.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
200rsa_saos.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
201rsa_saos.o: ../../include/openssl/opensslconf.h
202rsa_saos.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
203rsa_saos.o: ../../include/openssl/pkcs7.h ../../include/openssl/rc2.h
204rsa_saos.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
205rsa_saos.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
206rsa_saos.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
207rsa_saos.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
208rsa_saos.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
209rsa_saos.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
210rsa_saos.o: ../cryptlib.h rsa_saos.c
211rsa_sign.o: ../../e_os.h ../../include/openssl/aes.h
212rsa_sign.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
213rsa_sign.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
214rsa_sign.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
215rsa_sign.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
216rsa_sign.o: ../../include/openssl/des_old.h ../../include/openssl/dh.h
217rsa_sign.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
218rsa_sign.o: ../../include/openssl/err.h ../../include/openssl/evp.h
219rsa_sign.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h
220rsa_sign.o: ../../include/openssl/md2.h ../../include/openssl/md4.h
221rsa_sign.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
222rsa_sign.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
223rsa_sign.o: ../../include/openssl/opensslconf.h
224rsa_sign.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
225rsa_sign.o: ../../include/openssl/pkcs7.h ../../include/openssl/rc2.h
226rsa_sign.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
227rsa_sign.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
228rsa_sign.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
229rsa_sign.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
230rsa_sign.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
231rsa_sign.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
232rsa_sign.o: ../cryptlib.h rsa_sign.c
233rsa_ssl.o: ../../e_os.h ../../include/openssl/asn1.h
234rsa_ssl.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
235rsa_ssl.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
236rsa_ssl.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
237rsa_ssl.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
238rsa_ssl.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
239rsa_ssl.o: ../../include/openssl/rand.h ../../include/openssl/rsa.h
240rsa_ssl.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
241rsa_ssl.o: ../../include/openssl/symhacks.h ../cryptlib.h rsa_ssl.c
diff --git a/src/lib/libcrypto/rsa/rsa.h b/src/lib/libcrypto/rsa/rsa.h
index 5bb932ae15..cf74343657 100644
--- a/src/lib/libcrypto/rsa/rsa.h
+++ b/src/lib/libcrypto/rsa/rsa.h
@@ -74,25 +74,6 @@
74#error RSA is disabled. 74#error RSA is disabled.
75#endif 75#endif
76 76
77/* If this flag is set the RSA method is FIPS compliant and can be used
78 * in FIPS mode. This is set in the validated module method. If an
79 * application sets this flag in its own methods it is its reposibility
80 * to ensure the result is compliant.
81 */
82
83#define RSA_FLAG_FIPS_METHOD 0x0400
84
85/* If this flag is set the operations normally disabled in FIPS mode are
86 * permitted it is then the applications responsibility to ensure that the
87 * usage is compliant.
88 */
89
90#define RSA_FLAG_NON_FIPS_ALLOW 0x0400
91
92#ifdef OPENSSL_FIPS
93#define FIPS_RSA_SIZE_T int
94#endif
95
96#ifdef __cplusplus 77#ifdef __cplusplus
97extern "C" { 78extern "C" {
98#endif 79#endif
@@ -136,7 +117,8 @@ struct rsa_meth_st
136 unsigned char *sigret, unsigned int *siglen, const RSA *rsa); 117 unsigned char *sigret, unsigned int *siglen, const RSA *rsa);
137 int (*rsa_verify)(int dtype, 118 int (*rsa_verify)(int dtype,
138 const unsigned char *m, unsigned int m_length, 119 const unsigned char *m, unsigned int m_length,
139 unsigned char *sigbuf, unsigned int siglen, const RSA *rsa); 120 const unsigned char *sigbuf, unsigned int siglen,
121 const RSA *rsa);
140/* If this callback is NULL, the builtin software RSA key-gen will be used. This 122/* If this callback is NULL, the builtin software RSA key-gen will be used. This
141 * is for behavioural compatibility whilst the code gets rewired, but one day 123 * is for behavioural compatibility whilst the code gets rewired, but one day
142 * it would be nice to assume there are no such things as "builtin software" 124 * it would be nice to assume there are no such things as "builtin software"
@@ -182,8 +164,6 @@ struct rsa_st
182# define OPENSSL_RSA_MAX_MODULUS_BITS 16384 164# define OPENSSL_RSA_MAX_MODULUS_BITS 16384
183#endif 165#endif
184 166
185#define OPENSSL_RSA_FIPS_MIN_MODULUS_BITS 1024
186
187#ifndef OPENSSL_RSA_SMALL_MODULUS_BITS 167#ifndef OPENSSL_RSA_SMALL_MODULUS_BITS
188# define OPENSSL_RSA_SMALL_MODULUS_BITS 3072 168# define OPENSSL_RSA_SMALL_MODULUS_BITS 3072
189#endif 169#endif
@@ -238,11 +218,37 @@ struct rsa_st
238#endif 218#endif
239 219
240 220
221#define EVP_PKEY_CTX_set_rsa_padding(ctx, pad) \
222 EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_RSA, -1, EVP_PKEY_CTRL_RSA_PADDING, \
223 pad, NULL)
224
225#define EVP_PKEY_CTX_set_rsa_pss_saltlen(ctx, len) \
226 EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_RSA, \
227 (EVP_PKEY_OP_SIGN|EVP_PKEY_OP_VERIFY), \
228 EVP_PKEY_CTRL_RSA_PSS_SALTLEN, \
229 len, NULL)
230
231#define EVP_PKEY_CTX_set_rsa_keygen_bits(ctx, bits) \
232 EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_RSA, EVP_PKEY_OP_KEYGEN, \
233 EVP_PKEY_CTRL_RSA_KEYGEN_BITS, bits, NULL)
234
235#define EVP_PKEY_CTX_set_rsa_keygen_pubexp(ctx, pubexp) \
236 EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_RSA, EVP_PKEY_OP_KEYGEN, \
237 EVP_PKEY_CTRL_RSA_KEYGEN_PUBEXP, 0, pubexp)
238
239#define EVP_PKEY_CTRL_RSA_PADDING (EVP_PKEY_ALG_CTRL + 1)
240#define EVP_PKEY_CTRL_RSA_PSS_SALTLEN (EVP_PKEY_ALG_CTRL + 2)
241
242#define EVP_PKEY_CTRL_RSA_KEYGEN_BITS (EVP_PKEY_ALG_CTRL + 3)
243#define EVP_PKEY_CTRL_RSA_KEYGEN_PUBEXP (EVP_PKEY_ALG_CTRL + 4)
244
241#define RSA_PKCS1_PADDING 1 245#define RSA_PKCS1_PADDING 1
242#define RSA_SSLV23_PADDING 2 246#define RSA_SSLV23_PADDING 2
243#define RSA_NO_PADDING 3 247#define RSA_NO_PADDING 3
244#define RSA_PKCS1_OAEP_PADDING 4 248#define RSA_PKCS1_OAEP_PADDING 4
245#define RSA_X931_PADDING 5 249#define RSA_X931_PADDING 5
250/* EVP_PKEY_ only */
251#define RSA_PKCS1_PSS_PADDING 6
246 252
247#define RSA_PKCS1_PADDING_SIZE 11 253#define RSA_PKCS1_PADDING_SIZE 11
248 254
@@ -261,11 +267,6 @@ RSA * RSA_generate_key(int bits, unsigned long e,void
261 267
262/* New version */ 268/* New version */
263int RSA_generate_key_ex(RSA *rsa, int bits, BIGNUM *e, BN_GENCB *cb); 269int RSA_generate_key_ex(RSA *rsa, int bits, BIGNUM *e, BN_GENCB *cb);
264int RSA_X931_derive_ex(RSA *rsa, BIGNUM *p1, BIGNUM *p2, BIGNUM *q1, BIGNUM *q2,
265 const BIGNUM *Xp1, const BIGNUM *Xp2, const BIGNUM *Xp,
266 const BIGNUM *Xq1, const BIGNUM *Xq2, const BIGNUM *Xq,
267 const BIGNUM *e, BN_GENCB *cb);
268int RSA_X931_generate_key_ex(RSA *rsa, int bits, const BIGNUM *e, BN_GENCB *cb);
269 270
270int RSA_check_key(const RSA *); 271int RSA_check_key(const RSA *);
271 /* next 4 return -1 on error */ 272 /* next 4 return -1 on error */
@@ -283,11 +284,6 @@ int RSA_up_ref(RSA *r);
283 284
284int RSA_flags(const RSA *r); 285int RSA_flags(const RSA *r);
285 286
286#ifdef OPENSSL_FIPS
287RSA *FIPS_rsa_new(void);
288void FIPS_rsa_free(RSA *r);
289#endif
290
291void RSA_set_default_method(const RSA_METHOD *meth); 287void RSA_set_default_method(const RSA_METHOD *meth);
292const RSA_METHOD *RSA_get_default_method(void); 288const RSA_METHOD *RSA_get_default_method(void);
293const RSA_METHOD *RSA_get_method(const RSA *rsa); 289const RSA_METHOD *RSA_get_method(const RSA *rsa);
@@ -333,7 +329,7 @@ RSA *d2i_Netscape_RSA(RSA **a, const unsigned char **pp, long length,
333int RSA_sign(int type, const unsigned char *m, unsigned int m_length, 329int RSA_sign(int type, const unsigned char *m, unsigned int m_length,
334 unsigned char *sigret, unsigned int *siglen, RSA *rsa); 330 unsigned char *sigret, unsigned int *siglen, RSA *rsa);
335int RSA_verify(int type, const unsigned char *m, unsigned int m_length, 331int RSA_verify(int type, const unsigned char *m, unsigned int m_length,
336 unsigned char *sigbuf, unsigned int siglen, RSA *rsa); 332 const unsigned char *sigbuf, unsigned int siglen, RSA *rsa);
337 333
338/* The following 2 function sign and verify a ASN1_OCTET_STRING 334/* The following 2 function sign and verify a ASN1_OCTET_STRING
339 * object inside PKCS#1 padded RSA encryption */ 335 * object inside PKCS#1 padded RSA encryption */
@@ -401,9 +397,15 @@ void ERR_load_RSA_strings(void);
401/* Error codes for the RSA functions. */ 397/* Error codes for the RSA functions. */
402 398
403/* Function codes. */ 399/* Function codes. */
404#define RSA_F_FIPS_RSA_SIGN 140 400#define RSA_F_CHECK_PADDING_MD 140
405#define RSA_F_FIPS_RSA_VERIFY 141 401#define RSA_F_DO_RSA_PRINT 146
402#define RSA_F_INT_RSA_VERIFY 145
406#define RSA_F_MEMORY_LOCK 100 403#define RSA_F_MEMORY_LOCK 100
404#define RSA_F_OLD_RSA_PRIV_DECODE 147
405#define RSA_F_PKEY_RSA_CTRL 143
406#define RSA_F_PKEY_RSA_CTRL_STR 144
407#define RSA_F_PKEY_RSA_SIGN 142
408#define RSA_F_PKEY_RSA_VERIFYRECOVER 141
407#define RSA_F_RSA_BUILTIN_KEYGEN 129 409#define RSA_F_RSA_BUILTIN_KEYGEN 129
408#define RSA_F_RSA_CHECK_KEY 123 410#define RSA_F_RSA_CHECK_KEY 123
409#define RSA_F_RSA_EAY_PRIVATE_DECRYPT 101 411#define RSA_F_RSA_EAY_PRIVATE_DECRYPT 101
@@ -434,11 +436,10 @@ void ERR_load_RSA_strings(void);
434#define RSA_F_RSA_PADDING_CHECK_X931 128 436#define RSA_F_RSA_PADDING_CHECK_X931 128
435#define RSA_F_RSA_PRINT 115 437#define RSA_F_RSA_PRINT 115
436#define RSA_F_RSA_PRINT_FP 116 438#define RSA_F_RSA_PRINT_FP 116
437#define RSA_F_RSA_PRIVATE_ENCRYPT 137 439#define RSA_F_RSA_PRIV_DECODE 137
438#define RSA_F_RSA_PUBLIC_DECRYPT 138 440#define RSA_F_RSA_PRIV_ENCODE 138
441#define RSA_F_RSA_PUB_DECODE 139
439#define RSA_F_RSA_SETUP_BLINDING 136 442#define RSA_F_RSA_SETUP_BLINDING 136
440#define RSA_F_RSA_SET_DEFAULT_METHOD 139
441#define RSA_F_RSA_SET_METHOD 142
442#define RSA_F_RSA_SIGN 117 443#define RSA_F_RSA_SIGN 117
443#define RSA_F_RSA_SIGN_ASN1_OCTET_STRING 118 444#define RSA_F_RSA_SIGN_ASN1_OCTET_STRING 118
444#define RSA_F_RSA_VERIFY 119 445#define RSA_F_RSA_VERIFY 119
@@ -464,20 +465,25 @@ void ERR_load_RSA_strings(void);
464#define RSA_R_DMQ1_NOT_CONGRUENT_TO_D 125 465#define RSA_R_DMQ1_NOT_CONGRUENT_TO_D 125
465#define RSA_R_D_E_NOT_CONGRUENT_TO_1 123 466#define RSA_R_D_E_NOT_CONGRUENT_TO_1 123
466#define RSA_R_FIRST_OCTET_INVALID 133 467#define RSA_R_FIRST_OCTET_INVALID 133
468#define RSA_R_ILLEGAL_OR_UNSUPPORTED_PADDING_MODE 144
469#define RSA_R_INVALID_DIGEST_LENGTH 143
467#define RSA_R_INVALID_HEADER 137 470#define RSA_R_INVALID_HEADER 137
471#define RSA_R_INVALID_KEYBITS 145
468#define RSA_R_INVALID_MESSAGE_LENGTH 131 472#define RSA_R_INVALID_MESSAGE_LENGTH 131
469#define RSA_R_INVALID_PADDING 138 473#define RSA_R_INVALID_PADDING 138
474#define RSA_R_INVALID_PADDING_MODE 141
475#define RSA_R_INVALID_PSS_SALTLEN 146
470#define RSA_R_INVALID_TRAILER 139 476#define RSA_R_INVALID_TRAILER 139
477#define RSA_R_INVALID_X931_DIGEST 142
471#define RSA_R_IQMP_NOT_INVERSE_OF_Q 126 478#define RSA_R_IQMP_NOT_INVERSE_OF_Q 126
472#define RSA_R_KEY_SIZE_TOO_SMALL 120 479#define RSA_R_KEY_SIZE_TOO_SMALL 120
473#define RSA_R_LAST_OCTET_INVALID 134 480#define RSA_R_LAST_OCTET_INVALID 134
474#define RSA_R_MODULUS_TOO_LARGE 105 481#define RSA_R_MODULUS_TOO_LARGE 105
475#define RSA_R_NON_FIPS_METHOD 141
476#define RSA_R_NO_PUBLIC_EXPONENT 140 482#define RSA_R_NO_PUBLIC_EXPONENT 140
477#define RSA_R_NULL_BEFORE_BLOCK_MISSING 113 483#define RSA_R_NULL_BEFORE_BLOCK_MISSING 113
478#define RSA_R_N_DOES_NOT_EQUAL_P_Q 127 484#define RSA_R_N_DOES_NOT_EQUAL_P_Q 127
479#define RSA_R_OAEP_DECODING_ERROR 121 485#define RSA_R_OAEP_DECODING_ERROR 121
480#define RSA_R_OPERATION_NOT_ALLOWED_IN_FIPS_MODE 142 486#define RSA_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE 148
481#define RSA_R_PADDING_CHECK_FAILED 114 487#define RSA_R_PADDING_CHECK_FAILED 114
482#define RSA_R_P_NOT_PRIME 128 488#define RSA_R_P_NOT_PRIME 128
483#define RSA_R_Q_NOT_PRIME 129 489#define RSA_R_Q_NOT_PRIME 129
@@ -488,6 +494,7 @@ void ERR_load_RSA_strings(void);
488#define RSA_R_THE_ASN1_OBJECT_IDENTIFIER_IS_NOT_KNOWN_FOR_THIS_MD 116 494#define RSA_R_THE_ASN1_OBJECT_IDENTIFIER_IS_NOT_KNOWN_FOR_THIS_MD 116
489#define RSA_R_UNKNOWN_ALGORITHM_TYPE 117 495#define RSA_R_UNKNOWN_ALGORITHM_TYPE 117
490#define RSA_R_UNKNOWN_PADDING_TYPE 118 496#define RSA_R_UNKNOWN_PADDING_TYPE 118
497#define RSA_R_VALUE_MISSING 147
491#define RSA_R_WRONG_SIGNATURE_LENGTH 119 498#define RSA_R_WRONG_SIGNATURE_LENGTH 119
492 499
493#ifdef __cplusplus 500#ifdef __cplusplus
diff --git a/src/lib/libcrypto/rsa/rsa_asn1.c b/src/lib/libcrypto/rsa/rsa_asn1.c
index 6e8a803e81..4efca8cdc8 100644
--- a/src/lib/libcrypto/rsa/rsa_asn1.c
+++ b/src/lib/libcrypto/rsa/rsa_asn1.c
@@ -3,7 +3,7 @@
3 * project 2000. 3 * project 2000.
4 */ 4 */
5/* ==================================================================== 5/* ====================================================================
6 * Copyright (c) 2000 The OpenSSL Project. All rights reserved. 6 * Copyright (c) 2000-2005 The OpenSSL Project. All rights reserved.
7 * 7 *
8 * Redistribution and use in source and binary forms, with or without 8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions 9 * modification, are permitted provided that the following conditions
@@ -62,19 +62,9 @@
62#include <openssl/rsa.h> 62#include <openssl/rsa.h>
63#include <openssl/asn1t.h> 63#include <openssl/asn1t.h>
64 64
65static ASN1_METHOD method={
66 (I2D_OF(void)) i2d_RSAPrivateKey,
67 (D2I_OF(void)) d2i_RSAPrivateKey,
68 (void *(*)(void)) RSA_new,
69 (void (*)(void *)) RSA_free};
70
71ASN1_METHOD *RSAPrivateKey_asn1_meth(void)
72 {
73 return(&method);
74 }
75
76/* Override the default free and new methods */ 65/* Override the default free and new methods */
77static int rsa_cb(int operation, ASN1_VALUE **pval, const ASN1_ITEM *it) 66static int rsa_cb(int operation, ASN1_VALUE **pval, const ASN1_ITEM *it,
67 void *exarg)
78{ 68{
79 if(operation == ASN1_OP_NEW_PRE) { 69 if(operation == ASN1_OP_NEW_PRE) {
80 *pval = (ASN1_VALUE *)RSA_new(); 70 *pval = (ASN1_VALUE *)RSA_new();
diff --git a/src/lib/libcrypto/rsa/rsa_eay.c b/src/lib/libcrypto/rsa/rsa_eay.c
index 04ec789ee9..c5eaeeae6b 100644
--- a/src/lib/libcrypto/rsa/rsa_eay.c
+++ b/src/lib/libcrypto/rsa/rsa_eay.c
@@ -115,7 +115,7 @@
115#include <openssl/rsa.h> 115#include <openssl/rsa.h>
116#include <openssl/rand.h> 116#include <openssl/rand.h>
117 117
118#if !defined(RSA_NULL) && !defined(OPENSSL_FIPS) 118#ifndef RSA_NULL
119 119
120static int RSA_eay_public_encrypt(int flen, const unsigned char *from, 120static int RSA_eay_public_encrypt(int flen, const unsigned char *from,
121 unsigned char *to, RSA *rsa,int padding); 121 unsigned char *to, RSA *rsa,int padding);
@@ -256,6 +256,7 @@ static BN_BLINDING *rsa_get_blinding(RSA *rsa, int *local, BN_CTX *ctx)
256{ 256{
257 BN_BLINDING *ret; 257 BN_BLINDING *ret;
258 int got_write_lock = 0; 258 int got_write_lock = 0;
259 CRYPTO_THREADID cur;
259 260
260 CRYPTO_r_lock(CRYPTO_LOCK_RSA); 261 CRYPTO_r_lock(CRYPTO_LOCK_RSA);
261 262
@@ -273,7 +274,8 @@ static BN_BLINDING *rsa_get_blinding(RSA *rsa, int *local, BN_CTX *ctx)
273 if (ret == NULL) 274 if (ret == NULL)
274 goto err; 275 goto err;
275 276
276 if (BN_BLINDING_get_thread_id(ret) == CRYPTO_thread_id()) 277 CRYPTO_THREADID_current(&cur);
278 if (!CRYPTO_THREADID_cmp(&cur, BN_BLINDING_thread_id(ret)))
277 { 279 {
278 /* rsa->blinding is ours! */ 280 /* rsa->blinding is ours! */
279 281
@@ -353,28 +355,6 @@ static int RSA_eay_private_encrypt(int flen, const unsigned char *from,
353 int local_blinding = 0; 355 int local_blinding = 0;
354 BN_BLINDING *blinding = NULL; 356 BN_BLINDING *blinding = NULL;
355 357
356 if (BN_num_bits(rsa->n) > OPENSSL_RSA_MAX_MODULUS_BITS)
357 {
358 RSAerr(RSA_F_RSA_EAY_PUBLIC_ENCRYPT, RSA_R_MODULUS_TOO_LARGE);
359 return -1;
360 }
361
362 if (BN_ucmp(rsa->n, rsa->e) <= 0)
363 {
364 RSAerr(RSA_F_RSA_EAY_PUBLIC_ENCRYPT, RSA_R_BAD_E_VALUE);
365 return -1;
366 }
367
368 /* for large moduli, enforce exponent limit */
369 if (BN_num_bits(rsa->n) > OPENSSL_RSA_SMALL_MODULUS_BITS)
370 {
371 if (BN_num_bits(rsa->e) > OPENSSL_RSA_MAX_PUBEXP_BITS)
372 {
373 RSAerr(RSA_F_RSA_EAY_PUBLIC_ENCRYPT, RSA_R_BAD_E_VALUE);
374 return -1;
375 }
376 }
377
378 if ((ctx=BN_CTX_new()) == NULL) goto err; 358 if ((ctx=BN_CTX_new()) == NULL) goto err;
379 BN_CTX_start(ctx); 359 BN_CTX_start(ctx);
380 f = BN_CTX_get(ctx); 360 f = BN_CTX_get(ctx);
diff --git a/src/lib/libcrypto/rsa/rsa_eng.c b/src/lib/libcrypto/rsa/rsa_eng.c
deleted file mode 100644
index 383a7045b2..0000000000
--- a/src/lib/libcrypto/rsa/rsa_eng.c
+++ /dev/null
@@ -1,348 +0,0 @@
1/* crypto/rsa/rsa_lib.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 <openssl/crypto.h>
61#include "cryptlib.h"
62#include <openssl/lhash.h>
63#include <openssl/bn.h>
64#include <openssl/rsa.h>
65#include <openssl/rand.h>
66#ifndef OPENSSL_NO_ENGINE
67#include <openssl/engine.h>
68#endif
69
70const char RSA_version[]="RSA" OPENSSL_VERSION_PTEXT;
71
72static const RSA_METHOD *default_RSA_meth=NULL;
73
74RSA *RSA_new(void)
75 {
76 RSA *r=RSA_new_method(NULL);
77
78 return r;
79 }
80
81void RSA_set_default_method(const RSA_METHOD *meth)
82 {
83#ifdef OPENSSL_FIPS
84 if (FIPS_mode() && !(meth->flags & RSA_FLAG_FIPS_METHOD))
85 {
86 RSAerr(RSA_F_RSA_SET_DEFAULT_METHOD, RSA_R_NON_FIPS_METHOD);
87 return;
88 }
89#endif
90 default_RSA_meth = meth;
91 }
92
93const RSA_METHOD *RSA_get_default_method(void)
94 {
95 if (default_RSA_meth == NULL)
96 {
97#ifdef RSA_NULL
98 default_RSA_meth=RSA_null_method();
99#else
100#if 0 /* was: #ifdef RSAref */
101 default_RSA_meth=RSA_PKCS1_RSAref();
102#else
103 default_RSA_meth=RSA_PKCS1_SSLeay();
104#endif
105#endif
106 }
107
108 return default_RSA_meth;
109 }
110
111const RSA_METHOD *RSA_get_method(const RSA *rsa)
112 {
113 return rsa->meth;
114 }
115
116int RSA_set_method(RSA *rsa, const RSA_METHOD *meth)
117 {
118 /* NB: The caller is specifically setting a method, so it's not up to us
119 * to deal with which ENGINE it comes from. */
120 const RSA_METHOD *mtmp;
121#ifdef OPENSSL_FIPS
122 if (FIPS_mode() && !(meth->flags & RSA_FLAG_FIPS_METHOD))
123 {
124 RSAerr(RSA_F_RSA_SET_METHOD, RSA_R_NON_FIPS_METHOD);
125 return 0;
126 }
127#endif
128 mtmp = rsa->meth;
129 if (mtmp->finish) mtmp->finish(rsa);
130#ifndef OPENSSL_NO_ENGINE
131 if (rsa->engine)
132 {
133 ENGINE_finish(rsa->engine);
134 rsa->engine = NULL;
135 }
136#endif
137 rsa->meth = meth;
138 if (meth->init) meth->init(rsa);
139 return 1;
140 }
141
142RSA *RSA_new_method(ENGINE *engine)
143 {
144 RSA *ret;
145
146 ret=(RSA *)OPENSSL_malloc(sizeof(RSA));
147 if (ret == NULL)
148 {
149 RSAerr(RSA_F_RSA_NEW_METHOD,ERR_R_MALLOC_FAILURE);
150 return NULL;
151 }
152
153 ret->meth = RSA_get_default_method();
154#ifndef OPENSSL_NO_ENGINE
155 if (engine)
156 {
157 if (!ENGINE_init(engine))
158 {
159 RSAerr(RSA_F_RSA_NEW_METHOD, ERR_R_ENGINE_LIB);
160 OPENSSL_free(ret);
161 return NULL;
162 }
163 ret->engine = engine;
164 }
165 else
166 ret->engine = ENGINE_get_default_RSA();
167 if(ret->engine)
168 {
169 ret->meth = ENGINE_get_RSA(ret->engine);
170 if(!ret->meth)
171 {
172 RSAerr(RSA_F_RSA_NEW_METHOD,
173 ERR_R_ENGINE_LIB);
174 ENGINE_finish(ret->engine);
175 OPENSSL_free(ret);
176 return NULL;
177 }
178 }
179#endif
180#ifdef OPENSSL_FIPS
181 if (FIPS_mode() && !(ret->meth->flags & RSA_FLAG_FIPS_METHOD))
182 {
183 RSAerr(RSA_F_RSA_NEW_METHOD, RSA_R_NON_FIPS_METHOD);
184#ifndef OPENSSL_NO_ENGINE
185 if (ret->engine)
186 ENGINE_finish(ret->engine);
187#endif
188 OPENSSL_free(ret);
189 return NULL;
190 }
191#endif
192
193 ret->pad=0;
194 ret->version=0;
195 ret->n=NULL;
196 ret->e=NULL;
197 ret->d=NULL;
198 ret->p=NULL;
199 ret->q=NULL;
200 ret->dmp1=NULL;
201 ret->dmq1=NULL;
202 ret->iqmp=NULL;
203 ret->references=1;
204 ret->_method_mod_n=NULL;
205 ret->_method_mod_p=NULL;
206 ret->_method_mod_q=NULL;
207 ret->blinding=NULL;
208 ret->mt_blinding=NULL;
209 ret->bignum_data=NULL;
210 ret->flags=ret->meth->flags;
211 CRYPTO_new_ex_data(CRYPTO_EX_INDEX_RSA, ret, &ret->ex_data);
212 if ((ret->meth->init != NULL) && !ret->meth->init(ret))
213 {
214#ifndef OPENSSL_NO_ENGINE
215 if (ret->engine)
216 ENGINE_finish(ret->engine);
217#endif
218 CRYPTO_free_ex_data(CRYPTO_EX_INDEX_RSA, ret, &ret->ex_data);
219 OPENSSL_free(ret);
220 ret=NULL;
221 }
222 return(ret);
223 }
224
225void RSA_free(RSA *r)
226 {
227 int i;
228
229 if (r == NULL) return;
230
231 i=CRYPTO_add(&r->references,-1,CRYPTO_LOCK_RSA);
232#ifdef REF_PRINT
233 REF_PRINT("RSA",r);
234#endif
235 if (i > 0) return;
236#ifdef REF_CHECK
237 if (i < 0)
238 {
239 fprintf(stderr,"RSA_free, bad reference count\n");
240 abort();
241 }
242#endif
243
244 if (r->meth->finish)
245 r->meth->finish(r);
246#ifndef OPENSSL_NO_ENGINE
247 if (r->engine)
248 ENGINE_finish(r->engine);
249#endif
250
251 CRYPTO_free_ex_data(CRYPTO_EX_INDEX_RSA, r, &r->ex_data);
252
253 if (r->n != NULL) BN_clear_free(r->n);
254 if (r->e != NULL) BN_clear_free(r->e);
255 if (r->d != NULL) BN_clear_free(r->d);
256 if (r->p != NULL) BN_clear_free(r->p);
257 if (r->q != NULL) BN_clear_free(r->q);
258 if (r->dmp1 != NULL) BN_clear_free(r->dmp1);
259 if (r->dmq1 != NULL) BN_clear_free(r->dmq1);
260 if (r->iqmp != NULL) BN_clear_free(r->iqmp);
261 if (r->blinding != NULL) BN_BLINDING_free(r->blinding);
262 if (r->mt_blinding != NULL) BN_BLINDING_free(r->mt_blinding);
263 if (r->bignum_data != NULL) OPENSSL_free_locked(r->bignum_data);
264 OPENSSL_free(r);
265 }
266
267int RSA_up_ref(RSA *r)
268 {
269 int i = CRYPTO_add(&r->references, 1, CRYPTO_LOCK_RSA);
270#ifdef REF_PRINT
271 REF_PRINT("RSA",r);
272#endif
273#ifdef REF_CHECK
274 if (i < 2)
275 {
276 fprintf(stderr, "RSA_up_ref, bad reference count\n");
277 abort();
278 }
279#endif
280 return ((i > 1) ? 1 : 0);
281 }
282
283int RSA_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func,
284 CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func)
285 {
286 return CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_RSA, argl, argp,
287 new_func, dup_func, free_func);
288 }
289
290int RSA_set_ex_data(RSA *r, int idx, void *arg)
291 {
292 return(CRYPTO_set_ex_data(&r->ex_data,idx,arg));
293 }
294
295void *RSA_get_ex_data(const RSA *r, int idx)
296 {
297 return(CRYPTO_get_ex_data(&r->ex_data,idx));
298 }
299
300int RSA_flags(const RSA *r)
301 {
302 return((r == NULL)?0:r->meth->flags);
303 }
304
305int RSA_memory_lock(RSA *r)
306 {
307 int i,j,k,off;
308 char *p;
309 BIGNUM *bn,**t[6],*b;
310 BN_ULONG *ul;
311
312 if (r->d == NULL) return(1);
313 t[0]= &r->d;
314 t[1]= &r->p;
315 t[2]= &r->q;
316 t[3]= &r->dmp1;
317 t[4]= &r->dmq1;
318 t[5]= &r->iqmp;
319 k=sizeof(BIGNUM)*6;
320 off=k/sizeof(BN_ULONG)+1;
321 j=1;
322 for (i=0; i<6; i++)
323 j+= (*t[i])->top;
324 if ((p=OPENSSL_malloc_locked((off+j)*sizeof(BN_ULONG))) == NULL)
325 {
326 RSAerr(RSA_F_RSA_MEMORY_LOCK,ERR_R_MALLOC_FAILURE);
327 return(0);
328 }
329 bn=(BIGNUM *)p;
330 ul=(BN_ULONG *)&(p[off]);
331 for (i=0; i<6; i++)
332 {
333 b= *(t[i]);
334 *(t[i])= &(bn[i]);
335 memcpy((char *)&(bn[i]),(char *)b,sizeof(BIGNUM));
336 bn[i].flags=BN_FLG_STATIC_DATA;
337 bn[i].d=ul;
338 memcpy((char *)ul,b->d,sizeof(BN_ULONG)*b->top);
339 ul+=b->top;
340 BN_clear_free(b);
341 }
342
343 /* I should fix this so it can still be done */
344 r->flags&= ~(RSA_FLAG_CACHE_PRIVATE|RSA_FLAG_CACHE_PUBLIC);
345
346 r->bignum_data=p;
347 return(1);
348 }
diff --git a/src/lib/libcrypto/rsa/rsa_err.c b/src/lib/libcrypto/rsa/rsa_err.c
index 501f5ea389..cf9f1106b0 100644
--- a/src/lib/libcrypto/rsa/rsa_err.c
+++ b/src/lib/libcrypto/rsa/rsa_err.c
@@ -1,6 +1,6 @@
1/* crypto/rsa/rsa_err.c */ 1/* crypto/rsa/rsa_err.c */
2/* ==================================================================== 2/* ====================================================================
3 * Copyright (c) 1999-2007 The OpenSSL Project. All rights reserved. 3 * Copyright (c) 1999-2008 The OpenSSL Project. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
@@ -70,9 +70,15 @@
70 70
71static ERR_STRING_DATA RSA_str_functs[]= 71static ERR_STRING_DATA RSA_str_functs[]=
72 { 72 {
73{ERR_FUNC(RSA_F_FIPS_RSA_SIGN), "FIPS_RSA_SIGN"}, 73{ERR_FUNC(RSA_F_CHECK_PADDING_MD), "CHECK_PADDING_MD"},
74{ERR_FUNC(RSA_F_FIPS_RSA_VERIFY), "FIPS_RSA_VERIFY"}, 74{ERR_FUNC(RSA_F_DO_RSA_PRINT), "DO_RSA_PRINT"},
75{ERR_FUNC(RSA_F_INT_RSA_VERIFY), "INT_RSA_VERIFY"},
75{ERR_FUNC(RSA_F_MEMORY_LOCK), "MEMORY_LOCK"}, 76{ERR_FUNC(RSA_F_MEMORY_LOCK), "MEMORY_LOCK"},
77{ERR_FUNC(RSA_F_OLD_RSA_PRIV_DECODE), "OLD_RSA_PRIV_DECODE"},
78{ERR_FUNC(RSA_F_PKEY_RSA_CTRL), "PKEY_RSA_CTRL"},
79{ERR_FUNC(RSA_F_PKEY_RSA_CTRL_STR), "PKEY_RSA_CTRL_STR"},
80{ERR_FUNC(RSA_F_PKEY_RSA_SIGN), "PKEY_RSA_SIGN"},
81{ERR_FUNC(RSA_F_PKEY_RSA_VERIFYRECOVER), "PKEY_RSA_VERIFYRECOVER"},
76{ERR_FUNC(RSA_F_RSA_BUILTIN_KEYGEN), "RSA_BUILTIN_KEYGEN"}, 82{ERR_FUNC(RSA_F_RSA_BUILTIN_KEYGEN), "RSA_BUILTIN_KEYGEN"},
77{ERR_FUNC(RSA_F_RSA_CHECK_KEY), "RSA_check_key"}, 83{ERR_FUNC(RSA_F_RSA_CHECK_KEY), "RSA_check_key"},
78{ERR_FUNC(RSA_F_RSA_EAY_PRIVATE_DECRYPT), "RSA_EAY_PRIVATE_DECRYPT"}, 84{ERR_FUNC(RSA_F_RSA_EAY_PRIVATE_DECRYPT), "RSA_EAY_PRIVATE_DECRYPT"},
@@ -103,11 +109,10 @@ static ERR_STRING_DATA RSA_str_functs[]=
103{ERR_FUNC(RSA_F_RSA_PADDING_CHECK_X931), "RSA_padding_check_X931"}, 109{ERR_FUNC(RSA_F_RSA_PADDING_CHECK_X931), "RSA_padding_check_X931"},
104{ERR_FUNC(RSA_F_RSA_PRINT), "RSA_print"}, 110{ERR_FUNC(RSA_F_RSA_PRINT), "RSA_print"},
105{ERR_FUNC(RSA_F_RSA_PRINT_FP), "RSA_print_fp"}, 111{ERR_FUNC(RSA_F_RSA_PRINT_FP), "RSA_print_fp"},
106{ERR_FUNC(RSA_F_RSA_PRIVATE_ENCRYPT), "RSA_private_encrypt"}, 112{ERR_FUNC(RSA_F_RSA_PRIV_DECODE), "RSA_PRIV_DECODE"},
107{ERR_FUNC(RSA_F_RSA_PUBLIC_DECRYPT), "RSA_public_decrypt"}, 113{ERR_FUNC(RSA_F_RSA_PRIV_ENCODE), "RSA_PRIV_ENCODE"},
114{ERR_FUNC(RSA_F_RSA_PUB_DECODE), "RSA_PUB_DECODE"},
108{ERR_FUNC(RSA_F_RSA_SETUP_BLINDING), "RSA_setup_blinding"}, 115{ERR_FUNC(RSA_F_RSA_SETUP_BLINDING), "RSA_setup_blinding"},
109{ERR_FUNC(RSA_F_RSA_SET_DEFAULT_METHOD), "RSA_set_default_method"},
110{ERR_FUNC(RSA_F_RSA_SET_METHOD), "RSA_set_method"},
111{ERR_FUNC(RSA_F_RSA_SIGN), "RSA_sign"}, 116{ERR_FUNC(RSA_F_RSA_SIGN), "RSA_sign"},
112{ERR_FUNC(RSA_F_RSA_SIGN_ASN1_OCTET_STRING), "RSA_sign_ASN1_OCTET_STRING"}, 117{ERR_FUNC(RSA_F_RSA_SIGN_ASN1_OCTET_STRING), "RSA_sign_ASN1_OCTET_STRING"},
113{ERR_FUNC(RSA_F_RSA_VERIFY), "RSA_verify"}, 118{ERR_FUNC(RSA_F_RSA_VERIFY), "RSA_verify"},
@@ -136,20 +141,25 @@ static ERR_STRING_DATA RSA_str_reasons[]=
136{ERR_REASON(RSA_R_DMQ1_NOT_CONGRUENT_TO_D),"dmq1 not congruent to d"}, 141{ERR_REASON(RSA_R_DMQ1_NOT_CONGRUENT_TO_D),"dmq1 not congruent to d"},
137{ERR_REASON(RSA_R_D_E_NOT_CONGRUENT_TO_1),"d e not congruent to 1"}, 142{ERR_REASON(RSA_R_D_E_NOT_CONGRUENT_TO_1),"d e not congruent to 1"},
138{ERR_REASON(RSA_R_FIRST_OCTET_INVALID) ,"first octet invalid"}, 143{ERR_REASON(RSA_R_FIRST_OCTET_INVALID) ,"first octet invalid"},
144{ERR_REASON(RSA_R_ILLEGAL_OR_UNSUPPORTED_PADDING_MODE),"illegal or unsupported padding mode"},
145{ERR_REASON(RSA_R_INVALID_DIGEST_LENGTH) ,"invalid digest length"},
139{ERR_REASON(RSA_R_INVALID_HEADER) ,"invalid header"}, 146{ERR_REASON(RSA_R_INVALID_HEADER) ,"invalid header"},
147{ERR_REASON(RSA_R_INVALID_KEYBITS) ,"invalid keybits"},
140{ERR_REASON(RSA_R_INVALID_MESSAGE_LENGTH),"invalid message length"}, 148{ERR_REASON(RSA_R_INVALID_MESSAGE_LENGTH),"invalid message length"},
141{ERR_REASON(RSA_R_INVALID_PADDING) ,"invalid padding"}, 149{ERR_REASON(RSA_R_INVALID_PADDING) ,"invalid padding"},
150{ERR_REASON(RSA_R_INVALID_PADDING_MODE) ,"invalid padding mode"},
151{ERR_REASON(RSA_R_INVALID_PSS_SALTLEN) ,"invalid pss saltlen"},
142{ERR_REASON(RSA_R_INVALID_TRAILER) ,"invalid trailer"}, 152{ERR_REASON(RSA_R_INVALID_TRAILER) ,"invalid trailer"},
153{ERR_REASON(RSA_R_INVALID_X931_DIGEST) ,"invalid x931 digest"},
143{ERR_REASON(RSA_R_IQMP_NOT_INVERSE_OF_Q) ,"iqmp not inverse of q"}, 154{ERR_REASON(RSA_R_IQMP_NOT_INVERSE_OF_Q) ,"iqmp not inverse of q"},
144{ERR_REASON(RSA_R_KEY_SIZE_TOO_SMALL) ,"key size too small"}, 155{ERR_REASON(RSA_R_KEY_SIZE_TOO_SMALL) ,"key size too small"},
145{ERR_REASON(RSA_R_LAST_OCTET_INVALID) ,"last octet invalid"}, 156{ERR_REASON(RSA_R_LAST_OCTET_INVALID) ,"last octet invalid"},
146{ERR_REASON(RSA_R_MODULUS_TOO_LARGE) ,"modulus too large"}, 157{ERR_REASON(RSA_R_MODULUS_TOO_LARGE) ,"modulus too large"},
147{ERR_REASON(RSA_R_NON_FIPS_METHOD) ,"non fips method"},
148{ERR_REASON(RSA_R_NO_PUBLIC_EXPONENT) ,"no public exponent"}, 158{ERR_REASON(RSA_R_NO_PUBLIC_EXPONENT) ,"no public exponent"},
149{ERR_REASON(RSA_R_NULL_BEFORE_BLOCK_MISSING),"null before block missing"}, 159{ERR_REASON(RSA_R_NULL_BEFORE_BLOCK_MISSING),"null before block missing"},
150{ERR_REASON(RSA_R_N_DOES_NOT_EQUAL_P_Q) ,"n does not equal p q"}, 160{ERR_REASON(RSA_R_N_DOES_NOT_EQUAL_P_Q) ,"n does not equal p q"},
151{ERR_REASON(RSA_R_OAEP_DECODING_ERROR) ,"oaep decoding error"}, 161{ERR_REASON(RSA_R_OAEP_DECODING_ERROR) ,"oaep decoding error"},
152{ERR_REASON(RSA_R_OPERATION_NOT_ALLOWED_IN_FIPS_MODE),"operation not allowed in fips mode"}, 162{ERR_REASON(RSA_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE),"operation not supported for this keytype"},
153{ERR_REASON(RSA_R_PADDING_CHECK_FAILED) ,"padding check failed"}, 163{ERR_REASON(RSA_R_PADDING_CHECK_FAILED) ,"padding check failed"},
154{ERR_REASON(RSA_R_P_NOT_PRIME) ,"p not prime"}, 164{ERR_REASON(RSA_R_P_NOT_PRIME) ,"p not prime"},
155{ERR_REASON(RSA_R_Q_NOT_PRIME) ,"q not prime"}, 165{ERR_REASON(RSA_R_Q_NOT_PRIME) ,"q not prime"},
@@ -160,6 +170,7 @@ static ERR_STRING_DATA RSA_str_reasons[]=
160{ERR_REASON(RSA_R_THE_ASN1_OBJECT_IDENTIFIER_IS_NOT_KNOWN_FOR_THIS_MD),"the asn1 object identifier is not known for this md"}, 170{ERR_REASON(RSA_R_THE_ASN1_OBJECT_IDENTIFIER_IS_NOT_KNOWN_FOR_THIS_MD),"the asn1 object identifier is not known for this md"},
161{ERR_REASON(RSA_R_UNKNOWN_ALGORITHM_TYPE),"unknown algorithm type"}, 171{ERR_REASON(RSA_R_UNKNOWN_ALGORITHM_TYPE),"unknown algorithm type"},
162{ERR_REASON(RSA_R_UNKNOWN_PADDING_TYPE) ,"unknown padding type"}, 172{ERR_REASON(RSA_R_UNKNOWN_PADDING_TYPE) ,"unknown padding type"},
173{ERR_REASON(RSA_R_VALUE_MISSING) ,"value missing"},
163{ERR_REASON(RSA_R_WRONG_SIGNATURE_LENGTH),"wrong signature length"}, 174{ERR_REASON(RSA_R_WRONG_SIGNATURE_LENGTH),"wrong signature length"},
164{0,NULL} 175{0,NULL}
165 }; 176 };
diff --git a/src/lib/libcrypto/rsa/rsa_gen.c b/src/lib/libcrypto/rsa/rsa_gen.c
index 41278f83c6..767f7ab682 100644
--- a/src/lib/libcrypto/rsa/rsa_gen.c
+++ b/src/lib/libcrypto/rsa/rsa_gen.c
@@ -68,8 +68,6 @@
68#include <openssl/bn.h> 68#include <openssl/bn.h>
69#include <openssl/rsa.h> 69#include <openssl/rsa.h>
70 70
71#ifndef OPENSSL_FIPS
72
73static int rsa_builtin_keygen(RSA *rsa, int bits, BIGNUM *e_value, BN_GENCB *cb); 71static int rsa_builtin_keygen(RSA *rsa, int bits, BIGNUM *e_value, BN_GENCB *cb);
74 72
75/* NB: this wrapper would normally be placed in rsa_lib.c and the static 73/* NB: this wrapper would normally be placed in rsa_lib.c and the static
@@ -219,4 +217,3 @@ err:
219 return ok; 217 return ok;
220 } 218 }
221 219
222#endif
diff --git a/src/lib/libcrypto/rsa/rsa_lib.c b/src/lib/libcrypto/rsa/rsa_lib.c
index 5714841f4c..de45088d76 100644
--- a/src/lib/libcrypto/rsa/rsa_lib.c
+++ b/src/lib/libcrypto/rsa/rsa_lib.c
@@ -67,6 +67,224 @@
67#include <openssl/engine.h> 67#include <openssl/engine.h>
68#endif 68#endif
69 69
70const char RSA_version[]="RSA" OPENSSL_VERSION_PTEXT;
71
72static const RSA_METHOD *default_RSA_meth=NULL;
73
74RSA *RSA_new(void)
75 {
76 RSA *r=RSA_new_method(NULL);
77
78 return r;
79 }
80
81void RSA_set_default_method(const RSA_METHOD *meth)
82 {
83 default_RSA_meth = meth;
84 }
85
86const RSA_METHOD *RSA_get_default_method(void)
87 {
88 if (default_RSA_meth == NULL)
89 {
90#ifdef RSA_NULL
91 default_RSA_meth=RSA_null_method();
92#else
93#if 0 /* was: #ifdef RSAref */
94 default_RSA_meth=RSA_PKCS1_RSAref();
95#else
96 default_RSA_meth=RSA_PKCS1_SSLeay();
97#endif
98#endif
99 }
100
101 return default_RSA_meth;
102 }
103
104const RSA_METHOD *RSA_get_method(const RSA *rsa)
105 {
106 return rsa->meth;
107 }
108
109int RSA_set_method(RSA *rsa, const RSA_METHOD *meth)
110 {
111 /* NB: The caller is specifically setting a method, so it's not up to us
112 * to deal with which ENGINE it comes from. */
113 const RSA_METHOD *mtmp;
114 mtmp = rsa->meth;
115 if (mtmp->finish) mtmp->finish(rsa);
116#ifndef OPENSSL_NO_ENGINE
117 if (rsa->engine)
118 {
119 ENGINE_finish(rsa->engine);
120 rsa->engine = NULL;
121 }
122#endif
123 rsa->meth = meth;
124 if (meth->init) meth->init(rsa);
125 return 1;
126 }
127
128RSA *RSA_new_method(ENGINE *engine)
129 {
130 RSA *ret;
131
132 ret=(RSA *)OPENSSL_malloc(sizeof(RSA));
133 if (ret == NULL)
134 {
135 RSAerr(RSA_F_RSA_NEW_METHOD,ERR_R_MALLOC_FAILURE);
136 return NULL;
137 }
138
139 ret->meth = RSA_get_default_method();
140#ifndef OPENSSL_NO_ENGINE
141 if (engine)
142 {
143 if (!ENGINE_init(engine))
144 {
145 RSAerr(RSA_F_RSA_NEW_METHOD, ERR_R_ENGINE_LIB);
146 OPENSSL_free(ret);
147 return NULL;
148 }
149 ret->engine = engine;
150 }
151 else
152 ret->engine = ENGINE_get_default_RSA();
153 if(ret->engine)
154 {
155 ret->meth = ENGINE_get_RSA(ret->engine);
156 if(!ret->meth)
157 {
158 RSAerr(RSA_F_RSA_NEW_METHOD,
159 ERR_R_ENGINE_LIB);
160 ENGINE_finish(ret->engine);
161 OPENSSL_free(ret);
162 return NULL;
163 }
164 }
165#endif
166
167 ret->pad=0;
168 ret->version=0;
169 ret->n=NULL;
170 ret->e=NULL;
171 ret->d=NULL;
172 ret->p=NULL;
173 ret->q=NULL;
174 ret->dmp1=NULL;
175 ret->dmq1=NULL;
176 ret->iqmp=NULL;
177 ret->references=1;
178 ret->_method_mod_n=NULL;
179 ret->_method_mod_p=NULL;
180 ret->_method_mod_q=NULL;
181 ret->blinding=NULL;
182 ret->mt_blinding=NULL;
183 ret->bignum_data=NULL;
184 ret->flags=ret->meth->flags;
185 if (!CRYPTO_new_ex_data(CRYPTO_EX_INDEX_RSA, ret, &ret->ex_data))
186 {
187#ifndef OPENSSL_NO_ENGINE
188 if (ret->engine)
189 ENGINE_finish(ret->engine);
190#endif
191 OPENSSL_free(ret);
192 return(NULL);
193 }
194
195 if ((ret->meth->init != NULL) && !ret->meth->init(ret))
196 {
197#ifndef OPENSSL_NO_ENGINE
198 if (ret->engine)
199 ENGINE_finish(ret->engine);
200#endif
201 CRYPTO_free_ex_data(CRYPTO_EX_INDEX_RSA, ret, &ret->ex_data);
202 OPENSSL_free(ret);
203 ret=NULL;
204 }
205 return(ret);
206 }
207
208void RSA_free(RSA *r)
209 {
210 int i;
211
212 if (r == NULL) return;
213
214 i=CRYPTO_add(&r->references,-1,CRYPTO_LOCK_RSA);
215#ifdef REF_PRINT
216 REF_PRINT("RSA",r);
217#endif
218 if (i > 0) return;
219#ifdef REF_CHECK
220 if (i < 0)
221 {
222 fprintf(stderr,"RSA_free, bad reference count\n");
223 abort();
224 }
225#endif
226
227 if (r->meth->finish)
228 r->meth->finish(r);
229#ifndef OPENSSL_NO_ENGINE
230 if (r->engine)
231 ENGINE_finish(r->engine);
232#endif
233
234 CRYPTO_free_ex_data(CRYPTO_EX_INDEX_RSA, r, &r->ex_data);
235
236 if (r->n != NULL) BN_clear_free(r->n);
237 if (r->e != NULL) BN_clear_free(r->e);
238 if (r->d != NULL) BN_clear_free(r->d);
239 if (r->p != NULL) BN_clear_free(r->p);
240 if (r->q != NULL) BN_clear_free(r->q);
241 if (r->dmp1 != NULL) BN_clear_free(r->dmp1);
242 if (r->dmq1 != NULL) BN_clear_free(r->dmq1);
243 if (r->iqmp != NULL) BN_clear_free(r->iqmp);
244 if (r->blinding != NULL) BN_BLINDING_free(r->blinding);
245 if (r->mt_blinding != NULL) BN_BLINDING_free(r->mt_blinding);
246 if (r->bignum_data != NULL) OPENSSL_free_locked(r->bignum_data);
247 OPENSSL_free(r);
248 }
249
250int RSA_up_ref(RSA *r)
251 {
252 int i = CRYPTO_add(&r->references, 1, CRYPTO_LOCK_RSA);
253#ifdef REF_PRINT
254 REF_PRINT("RSA",r);
255#endif
256#ifdef REF_CHECK
257 if (i < 2)
258 {
259 fprintf(stderr, "RSA_up_ref, bad reference count\n");
260 abort();
261 }
262#endif
263 return ((i > 1) ? 1 : 0);
264 }
265
266int RSA_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func,
267 CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func)
268 {
269 return CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_RSA, argl, argp,
270 new_func, dup_func, free_func);
271 }
272
273int RSA_set_ex_data(RSA *r, int idx, void *arg)
274 {
275 return(CRYPTO_set_ex_data(&r->ex_data,idx,arg));
276 }
277
278void *RSA_get_ex_data(const RSA *r, int idx)
279 {
280 return(CRYPTO_get_ex_data(&r->ex_data,idx));
281 }
282
283int RSA_size(const RSA *r)
284 {
285 return(BN_num_bytes(r->n));
286 }
287
70int RSA_public_encrypt(int flen, const unsigned char *from, unsigned char *to, 288int RSA_public_encrypt(int flen, const unsigned char *from, unsigned char *to,
71 RSA *rsa, int padding) 289 RSA *rsa, int padding)
72 { 290 {
@@ -76,13 +294,6 @@ int RSA_public_encrypt(int flen, const unsigned char *from, unsigned char *to,
76int RSA_private_encrypt(int flen, const unsigned char *from, unsigned char *to, 294int RSA_private_encrypt(int flen, const unsigned char *from, unsigned char *to,
77 RSA *rsa, int padding) 295 RSA *rsa, int padding)
78 { 296 {
79#ifdef OPENSSL_FIPS
80 if(FIPS_mode() && !(rsa->flags & RSA_FLAG_NON_FIPS_ALLOW))
81 {
82 RSAerr(RSA_F_RSA_PRIVATE_ENCRYPT, RSA_R_OPERATION_NOT_ALLOWED_IN_FIPS_MODE);
83 return 0;
84 }
85#endif
86 return(rsa->meth->rsa_priv_enc(flen, from, to, rsa, padding)); 297 return(rsa->meth->rsa_priv_enc(flen, from, to, rsa, padding));
87 } 298 }
88 299
@@ -95,19 +306,12 @@ int RSA_private_decrypt(int flen, const unsigned char *from, unsigned char *to,
95int RSA_public_decrypt(int flen, const unsigned char *from, unsigned char *to, 306int RSA_public_decrypt(int flen, const unsigned char *from, unsigned char *to,
96 RSA *rsa, int padding) 307 RSA *rsa, int padding)
97 { 308 {
98#ifdef OPENSSL_FIPS
99 if(FIPS_mode() && !(rsa->flags & RSA_FLAG_NON_FIPS_ALLOW))
100 {
101 RSAerr(RSA_F_RSA_PUBLIC_DECRYPT, RSA_R_OPERATION_NOT_ALLOWED_IN_FIPS_MODE);
102 return 0;
103 }
104#endif
105 return(rsa->meth->rsa_pub_dec(flen, from, to, rsa, padding)); 309 return(rsa->meth->rsa_pub_dec(flen, from, to, rsa, padding));
106 } 310 }
107 311
108int RSA_size(const RSA *r) 312int RSA_flags(const RSA *r)
109 { 313 {
110 return(BN_num_bytes(r->n)); 314 return((r == NULL)?0:r->meth->flags);
111 } 315 }
112 316
113void RSA_blinding_off(RSA *rsa) 317void RSA_blinding_off(RSA *rsa)
@@ -222,7 +426,7 @@ BN_BLINDING *RSA_setup_blinding(RSA *rsa, BN_CTX *in_ctx)
222 RSAerr(RSA_F_RSA_SETUP_BLINDING, ERR_R_BN_LIB); 426 RSAerr(RSA_F_RSA_SETUP_BLINDING, ERR_R_BN_LIB);
223 goto err; 427 goto err;
224 } 428 }
225 BN_BLINDING_set_thread_id(ret, CRYPTO_thread_id()); 429 CRYPTO_THREADID_current(BN_BLINDING_thread_id(ret));
226err: 430err:
227 BN_CTX_end(ctx); 431 BN_CTX_end(ctx);
228 if (in_ctx == NULL) 432 if (in_ctx == NULL)
@@ -232,3 +436,48 @@ err:
232 436
233 return ret; 437 return ret;
234} 438}
439
440int RSA_memory_lock(RSA *r)
441 {
442 int i,j,k,off;
443 char *p;
444 BIGNUM *bn,**t[6],*b;
445 BN_ULONG *ul;
446
447 if (r->d == NULL) return(1);
448 t[0]= &r->d;
449 t[1]= &r->p;
450 t[2]= &r->q;
451 t[3]= &r->dmp1;
452 t[4]= &r->dmq1;
453 t[5]= &r->iqmp;
454 k=sizeof(BIGNUM)*6;
455 off=k/sizeof(BN_ULONG)+1;
456 j=1;
457 for (i=0; i<6; i++)
458 j+= (*t[i])->top;
459 if ((p=OPENSSL_malloc_locked((off+j)*sizeof(BN_ULONG))) == NULL)
460 {
461 RSAerr(RSA_F_RSA_MEMORY_LOCK,ERR_R_MALLOC_FAILURE);
462 return(0);
463 }
464 bn=(BIGNUM *)p;
465 ul=(BN_ULONG *)&(p[off]);
466 for (i=0; i<6; i++)
467 {
468 b= *(t[i]);
469 *(t[i])= &(bn[i]);
470 memcpy((char *)&(bn[i]),(char *)b,sizeof(BIGNUM));
471 bn[i].flags=BN_FLG_STATIC_DATA;
472 bn[i].d=ul;
473 memcpy((char *)ul,b->d,sizeof(BN_ULONG)*b->top);
474 ul+=b->top;
475 BN_clear_free(b);
476 }
477
478 /* I should fix this so it can still be done */
479 r->flags&= ~(RSA_FLAG_CACHE_PRIVATE|RSA_FLAG_CACHE_PUBLIC);
480
481 r->bignum_data=p;
482 return(1);
483 }
diff --git a/src/lib/libcrypto/rsa/rsa_oaep.c b/src/lib/libcrypto/rsa/rsa_oaep.c
index 4d30c9d2d3..e238d10e5c 100644
--- a/src/lib/libcrypto/rsa/rsa_oaep.c
+++ b/src/lib/libcrypto/rsa/rsa_oaep.c
@@ -28,7 +28,7 @@
28#include <openssl/rand.h> 28#include <openssl/rand.h>
29#include <openssl/sha.h> 29#include <openssl/sha.h>
30 30
31int MGF1(unsigned char *mask, long len, 31static int MGF1(unsigned char *mask, long len,
32 const unsigned char *seed, long seedlen); 32 const unsigned char *seed, long seedlen);
33 33
34int RSA_padding_add_PKCS1_OAEP(unsigned char *to, int tlen, 34int RSA_padding_add_PKCS1_OAEP(unsigned char *to, int tlen,
@@ -52,13 +52,6 @@ int RSA_padding_add_PKCS1_OAEP(unsigned char *to, int tlen,
52 return 0; 52 return 0;
53 } 53 }
54 54
55 dbmask = OPENSSL_malloc(emlen - SHA_DIGEST_LENGTH);
56 if (dbmask == NULL)
57 {
58 RSAerr(RSA_F_RSA_PADDING_ADD_PKCS1_OAEP, ERR_R_MALLOC_FAILURE);
59 return 0;
60 }
61
62 to[0] = 0; 55 to[0] = 0;
63 seed = to + 1; 56 seed = to + 1;
64 db = to + SHA_DIGEST_LENGTH + 1; 57 db = to + SHA_DIGEST_LENGTH + 1;
@@ -76,11 +69,20 @@ int RSA_padding_add_PKCS1_OAEP(unsigned char *to, int tlen,
76 20); 69 20);
77#endif 70#endif
78 71
79 MGF1(dbmask, emlen - SHA_DIGEST_LENGTH, seed, SHA_DIGEST_LENGTH); 72 dbmask = OPENSSL_malloc(emlen - SHA_DIGEST_LENGTH);
73 if (dbmask == NULL)
74 {
75 RSAerr(RSA_F_RSA_PADDING_ADD_PKCS1_OAEP, ERR_R_MALLOC_FAILURE);
76 return 0;
77 }
78
79 if (MGF1(dbmask, emlen - SHA_DIGEST_LENGTH, seed, SHA_DIGEST_LENGTH) < 0)
80 return 0;
80 for (i = 0; i < emlen - SHA_DIGEST_LENGTH; i++) 81 for (i = 0; i < emlen - SHA_DIGEST_LENGTH; i++)
81 db[i] ^= dbmask[i]; 82 db[i] ^= dbmask[i];
82 83
83 MGF1(seedmask, SHA_DIGEST_LENGTH, db, emlen - SHA_DIGEST_LENGTH); 84 if (MGF1(seedmask, SHA_DIGEST_LENGTH, db, emlen - SHA_DIGEST_LENGTH) < 0)
85 return 0;
84 for (i = 0; i < SHA_DIGEST_LENGTH; i++) 86 for (i = 0; i < SHA_DIGEST_LENGTH; i++)
85 seed[i] ^= seedmask[i]; 87 seed[i] ^= seedmask[i];
86 88
@@ -133,11 +135,13 @@ int RSA_padding_check_PKCS1_OAEP(unsigned char *to, int tlen,
133 135
134 maskeddb = padded_from + SHA_DIGEST_LENGTH; 136 maskeddb = padded_from + SHA_DIGEST_LENGTH;
135 137
136 MGF1(seed, SHA_DIGEST_LENGTH, maskeddb, dblen); 138 if (MGF1(seed, SHA_DIGEST_LENGTH, maskeddb, dblen))
139 return -1;
137 for (i = 0; i < SHA_DIGEST_LENGTH; i++) 140 for (i = 0; i < SHA_DIGEST_LENGTH; i++)
138 seed[i] ^= padded_from[i]; 141 seed[i] ^= padded_from[i];
139 142
140 MGF1(db, dblen, seed, SHA_DIGEST_LENGTH); 143 if (MGF1(db, dblen, seed, SHA_DIGEST_LENGTH))
144 return -1;
141 for (i = 0; i < dblen; i++) 145 for (i = 0; i < dblen; i++)
142 db[i] ^= maskeddb[i]; 146 db[i] ^= maskeddb[i];
143 147
@@ -187,7 +191,9 @@ int PKCS1_MGF1(unsigned char *mask, long len,
187 int mdlen; 191 int mdlen;
188 192
189 EVP_MD_CTX_init(&c); 193 EVP_MD_CTX_init(&c);
190 mdlen = M_EVP_MD_size(dgst); 194 mdlen = EVP_MD_size(dgst);
195 if (mdlen < 0)
196 return -1;
191 for (i = 0; outlen < len; i++) 197 for (i = 0; outlen < len; i++)
192 { 198 {
193 cnt[0] = (unsigned char)((i >> 24) & 255); 199 cnt[0] = (unsigned char)((i >> 24) & 255);
@@ -213,7 +219,8 @@ int PKCS1_MGF1(unsigned char *mask, long len,
213 return 0; 219 return 0;
214 } 220 }
215 221
216int MGF1(unsigned char *mask, long len, const unsigned char *seed, long seedlen) 222static int MGF1(unsigned char *mask, long len, const unsigned char *seed,
223 long seedlen)
217 { 224 {
218 return PKCS1_MGF1(mask, len, seed, seedlen, EVP_sha1()); 225 return PKCS1_MGF1(mask, len, seed, seedlen, EVP_sha1());
219 } 226 }
diff --git a/src/lib/libcrypto/rsa/rsa_sign.c b/src/lib/libcrypto/rsa/rsa_sign.c
index 5488c06f6d..0be4ec7fb0 100644
--- a/src/lib/libcrypto/rsa/rsa_sign.c
+++ b/src/lib/libcrypto/rsa/rsa_sign.c
@@ -62,6 +62,7 @@
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 "rsa_locl.h"
65 66
66/* Size of an SSL signature: MD5+SHA1 */ 67/* Size of an SSL signature: MD5+SHA1 */
67#define SSL_SIG_LENGTH 36 68#define SSL_SIG_LENGTH 36
@@ -90,14 +91,6 @@ int RSA_sign(int type, const unsigned char *m, unsigned int m_len,
90 i = SSL_SIG_LENGTH; 91 i = SSL_SIG_LENGTH;
91 s = m; 92 s = m;
92 } else { 93 } else {
93 /* NB: in FIPS mode block anything that isn't a TLS signature */
94#ifdef OPENSSL_FIPS
95 if(FIPS_mode() && !(rsa->flags & RSA_FLAG_NON_FIPS_ALLOW))
96 {
97 RSAerr(RSA_F_RSA_SIGN, RSA_R_OPERATION_NOT_ALLOWED_IN_FIPS_MODE);
98 return 0;
99 }
100#endif
101 sig.algor= &algor; 94 sig.algor= &algor;
102 sig.algor->algorithm=OBJ_nid2obj(type); 95 sig.algor->algorithm=OBJ_nid2obj(type);
103 if (sig.algor->algorithm == NULL) 96 if (sig.algor->algorithm == NULL)
@@ -150,8 +143,11 @@ int RSA_sign(int type, const unsigned char *m, unsigned int m_len,
150 return(ret); 143 return(ret);
151 } 144 }
152 145
153int RSA_verify(int dtype, const unsigned char *m, unsigned int m_len, 146int int_rsa_verify(int dtype, const unsigned char *m,
154 unsigned char *sigbuf, unsigned int siglen, RSA *rsa) 147 unsigned int m_len,
148 unsigned char *rm, size_t *prm_len,
149 const unsigned char *sigbuf, size_t siglen,
150 RSA *rsa)
155 { 151 {
156 int i,ret=0,sigtype; 152 int i,ret=0,sigtype;
157 unsigned char *s; 153 unsigned char *s;
@@ -159,38 +155,30 @@ int RSA_verify(int dtype, const unsigned char *m, unsigned int m_len,
159 155
160 if (siglen != (unsigned int)RSA_size(rsa)) 156 if (siglen != (unsigned int)RSA_size(rsa))
161 { 157 {
162 RSAerr(RSA_F_RSA_VERIFY,RSA_R_WRONG_SIGNATURE_LENGTH); 158 RSAerr(RSA_F_INT_RSA_VERIFY,RSA_R_WRONG_SIGNATURE_LENGTH);
163 return(0); 159 return(0);
164 } 160 }
165 161
166 if((rsa->flags & RSA_FLAG_SIGN_VER) && rsa->meth->rsa_verify) 162 if((dtype == NID_md5_sha1) && rm)
167 { 163 {
168 return rsa->meth->rsa_verify(dtype, m, m_len, 164 i = RSA_public_decrypt((int)siglen,
169 sigbuf, siglen, rsa); 165 sigbuf,rm,rsa,RSA_PKCS1_PADDING);
166 if (i <= 0)
167 return 0;
168 *prm_len = i;
169 return 1;
170 } 170 }
171 171
172 s=(unsigned char *)OPENSSL_malloc((unsigned int)siglen); 172 s=(unsigned char *)OPENSSL_malloc((unsigned int)siglen);
173 if (s == NULL) 173 if (s == NULL)
174 { 174 {
175 RSAerr(RSA_F_RSA_VERIFY,ERR_R_MALLOC_FAILURE); 175 RSAerr(RSA_F_INT_RSA_VERIFY,ERR_R_MALLOC_FAILURE);
176 goto err; 176 goto err;
177 } 177 }
178 if(dtype == NID_md5_sha1) 178 if((dtype == NID_md5_sha1) && (m_len != SSL_SIG_LENGTH) ) {
179 { 179 RSAerr(RSA_F_INT_RSA_VERIFY,RSA_R_INVALID_MESSAGE_LENGTH);
180 if (m_len != SSL_SIG_LENGTH)
181 {
182 RSAerr(RSA_F_RSA_VERIFY,RSA_R_INVALID_MESSAGE_LENGTH);
183 goto err; 180 goto err;
184 } 181 }
185 }
186 /* NB: in FIPS mode block anything that isn't a TLS signature */
187#ifdef OPENSSL_FIPS
188 else if(FIPS_mode() && !(rsa->flags & RSA_FLAG_NON_FIPS_ALLOW))
189 {
190 RSAerr(RSA_F_RSA_VERIFY, RSA_R_OPERATION_NOT_ALLOWED_IN_FIPS_MODE);
191 return 0;
192 }
193#endif
194 i=RSA_public_decrypt((int)siglen,sigbuf,s,rsa,RSA_PKCS1_PADDING); 182 i=RSA_public_decrypt((int)siglen,sigbuf,s,rsa,RSA_PKCS1_PADDING);
195 183
196 if (i <= 0) goto err; 184 if (i <= 0) goto err;
@@ -198,7 +186,7 @@ int RSA_verify(int dtype, const unsigned char *m, unsigned int m_len,
198 /* Special case: SSL signature */ 186 /* Special case: SSL signature */
199 if(dtype == NID_md5_sha1) { 187 if(dtype == NID_md5_sha1) {
200 if((i != SSL_SIG_LENGTH) || memcmp(s, m, SSL_SIG_LENGTH)) 188 if((i != SSL_SIG_LENGTH) || memcmp(s, m, SSL_SIG_LENGTH))
201 RSAerr(RSA_F_RSA_VERIFY,RSA_R_BAD_SIGNATURE); 189 RSAerr(RSA_F_INT_RSA_VERIFY,RSA_R_BAD_SIGNATURE);
202 else ret = 1; 190 else ret = 1;
203 } else { 191 } else {
204 const unsigned char *p=s; 192 const unsigned char *p=s;
@@ -209,7 +197,7 @@ int RSA_verify(int dtype, const unsigned char *m, unsigned int m_len,
209 /* Excess data can be used to create forgeries */ 197 /* Excess data can be used to create forgeries */
210 if(p != s+i) 198 if(p != s+i)
211 { 199 {
212 RSAerr(RSA_F_RSA_VERIFY,RSA_R_BAD_SIGNATURE); 200 RSAerr(RSA_F_INT_RSA_VERIFY,RSA_R_BAD_SIGNATURE);
213 goto err; 201 goto err;
214 } 202 }
215 203
@@ -218,7 +206,7 @@ int RSA_verify(int dtype, const unsigned char *m, unsigned int m_len,
218 if(sig->algor->parameter 206 if(sig->algor->parameter
219 && ASN1_TYPE_get(sig->algor->parameter) != V_ASN1_NULL) 207 && ASN1_TYPE_get(sig->algor->parameter) != V_ASN1_NULL)
220 { 208 {
221 RSAerr(RSA_F_RSA_VERIFY,RSA_R_BAD_SIGNATURE); 209 RSAerr(RSA_F_INT_RSA_VERIFY,RSA_R_BAD_SIGNATURE);
222 goto err; 210 goto err;
223 } 211 }
224 212
@@ -244,15 +232,30 @@ int RSA_verify(int dtype, const unsigned char *m, unsigned int m_len,
244 } 232 }
245 else 233 else
246 { 234 {
247 RSAerr(RSA_F_RSA_VERIFY, 235 RSAerr(RSA_F_INT_RSA_VERIFY,
248 RSA_R_ALGORITHM_MISMATCH); 236 RSA_R_ALGORITHM_MISMATCH);
249 goto err; 237 goto err;
250 } 238 }
251 } 239 }
252 if ( ((unsigned int)sig->digest->length != m_len) || 240 if (rm)
241 {
242 const EVP_MD *md;
243 md = EVP_get_digestbynid(dtype);
244 if (md && (EVP_MD_size(md) != sig->digest->length))
245 RSAerr(RSA_F_INT_RSA_VERIFY,
246 RSA_R_INVALID_DIGEST_LENGTH);
247 else
248 {
249 memcpy(rm, sig->digest->data,
250 sig->digest->length);
251 *prm_len = sig->digest->length;
252 ret = 1;
253 }
254 }
255 else if (((unsigned int)sig->digest->length != m_len) ||
253 (memcmp(m,sig->digest->data,m_len) != 0)) 256 (memcmp(m,sig->digest->data,m_len) != 0))
254 { 257 {
255 RSAerr(RSA_F_RSA_VERIFY,RSA_R_BAD_SIGNATURE); 258 RSAerr(RSA_F_INT_RSA_VERIFY,RSA_R_BAD_SIGNATURE);
256 } 259 }
257 else 260 else
258 ret=1; 261 ret=1;
@@ -267,3 +270,16 @@ err:
267 return(ret); 270 return(ret);
268 } 271 }
269 272
273int RSA_verify(int dtype, const unsigned char *m, unsigned int m_len,
274 const unsigned char *sigbuf, unsigned int siglen,
275 RSA *rsa)
276 {
277
278 if((rsa->flags & RSA_FLAG_SIGN_VER) && rsa->meth->rsa_verify)
279 {
280 return rsa->meth->rsa_verify(dtype, m, m_len,
281 sigbuf, siglen, rsa);
282 }
283
284 return int_rsa_verify(dtype, m, m_len, NULL, NULL, sigbuf, siglen, rsa);
285 }
diff --git a/src/lib/libcrypto/rsa/rsa_test.c b/src/lib/libcrypto/rsa/rsa_test.c
index 4080de8bcf..c8705a0f6e 100644
--- a/src/lib/libcrypto/rsa/rsa_test.c
+++ b/src/lib/libcrypto/rsa/rsa_test.c
@@ -328,7 +328,7 @@ int main(int argc, char *argv[])
328 } 328 }
329 329
330 CRYPTO_cleanup_all_ex_data(); 330 CRYPTO_cleanup_all_ex_data();
331 ERR_remove_state(0); 331 ERR_remove_thread_state(NULL);
332 332
333 CRYPTO_mem_leaks_fp(stderr); 333 CRYPTO_mem_leaks_fp(stderr);
334 334
diff --git a/src/lib/libcrypto/rsa/rsa_x931g.c b/src/lib/libcrypto/rsa/rsa_x931g.c
deleted file mode 100644
index bf94f8be7a..0000000000
--- a/src/lib/libcrypto/rsa/rsa_x931g.c
+++ /dev/null
@@ -1,255 +0,0 @@
1/* crypto/rsa/rsa_gen.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 <string.h>
61#include <time.h>
62#include <openssl/err.h>
63#include <openssl/bn.h>
64#include <openssl/rsa.h>
65
66#ifndef OPENSSL_FIPS
67
68/* X9.31 RSA key derivation and generation */
69
70int RSA_X931_derive_ex(RSA *rsa, BIGNUM *p1, BIGNUM *p2, BIGNUM *q1, BIGNUM *q2,
71 const BIGNUM *Xp1, const BIGNUM *Xp2, const BIGNUM *Xp,
72 const BIGNUM *Xq1, const BIGNUM *Xq2, const BIGNUM *Xq,
73 const BIGNUM *e, BN_GENCB *cb)
74 {
75 BIGNUM *r0=NULL,*r1=NULL,*r2=NULL,*r3=NULL;
76 BN_CTX *ctx=NULL,*ctx2=NULL;
77
78 if (!rsa)
79 goto err;
80
81 ctx = BN_CTX_new();
82 if (!ctx)
83 goto err;
84 BN_CTX_start(ctx);
85
86 r0 = BN_CTX_get(ctx);
87 r1 = BN_CTX_get(ctx);
88 r2 = BN_CTX_get(ctx);
89 r3 = BN_CTX_get(ctx);
90
91 if (r3 == NULL)
92 goto err;
93 if (!rsa->e)
94 {
95 rsa->e = BN_dup(e);
96 if (!rsa->e)
97 goto err;
98 }
99 else
100 e = rsa->e;
101
102 /* If not all parameters present only calculate what we can.
103 * This allows test programs to output selective parameters.
104 */
105
106 if (Xp && !rsa->p)
107 {
108 rsa->p = BN_new();
109 if (!rsa->p)
110 goto err;
111
112 if (!BN_X931_derive_prime_ex(rsa->p, p1, p2,
113 Xp, Xp1, Xp2, e, ctx, cb))
114 goto err;
115 }
116
117 if (Xq && !rsa->q)
118 {
119 rsa->q = BN_new();
120 if (!rsa->q)
121 goto err;
122 if (!BN_X931_derive_prime_ex(rsa->q, q1, q2,
123 Xq, Xq1, Xq2, e, ctx, cb))
124 goto err;
125 }
126
127 if (!rsa->p || !rsa->q)
128 {
129 BN_CTX_end(ctx);
130 BN_CTX_free(ctx);
131 return 2;
132 }
133
134 /* Since both primes are set we can now calculate all remaining
135 * components.
136 */
137
138 /* calculate n */
139 rsa->n=BN_new();
140 if (rsa->n == NULL)
141 goto err;
142 if (!BN_mul(rsa->n,rsa->p,rsa->q,ctx))
143 goto err;
144
145 /* calculate d */
146 if (!BN_sub(r1,rsa->p,BN_value_one()))
147 goto err; /* p-1 */
148 if (!BN_sub(r2,rsa->q,BN_value_one()))
149 goto err; /* q-1 */
150 if (!BN_mul(r0,r1,r2,ctx))
151 goto err; /* (p-1)(q-1) */
152
153 if (!BN_gcd(r3, r1, r2, ctx))
154 goto err;
155
156 if (!BN_div(r0, NULL, r0, r3, ctx))
157 goto err; /* LCM((p-1)(q-1)) */
158
159 ctx2 = BN_CTX_new();
160 if (!ctx2)
161 goto err;
162
163 rsa->d=BN_mod_inverse(NULL,rsa->e,r0,ctx2); /* d */
164 if (rsa->d == NULL)
165 goto err;
166
167 /* calculate d mod (p-1) */
168 rsa->dmp1=BN_new();
169 if (rsa->dmp1 == NULL)
170 goto err;
171 if (!BN_mod(rsa->dmp1,rsa->d,r1,ctx))
172 goto err;
173
174 /* calculate d mod (q-1) */
175 rsa->dmq1=BN_new();
176 if (rsa->dmq1 == NULL)
177 goto err;
178 if (!BN_mod(rsa->dmq1,rsa->d,r2,ctx))
179 goto err;
180
181 /* calculate inverse of q mod p */
182 rsa->iqmp=BN_mod_inverse(NULL,rsa->q,rsa->p,ctx2);
183
184 err:
185 if (ctx)
186 {
187 BN_CTX_end(ctx);
188 BN_CTX_free(ctx);
189 }
190 if (ctx2)
191 BN_CTX_free(ctx2);
192 /* If this is set all calls successful */
193 if (rsa && rsa->iqmp != NULL)
194 return 1;
195
196 return 0;
197
198 }
199
200int RSA_X931_generate_key_ex(RSA *rsa, int bits, const BIGNUM *e, BN_GENCB *cb)
201 {
202 int ok = 0;
203 BIGNUM *Xp = NULL, *Xq = NULL;
204 BN_CTX *ctx = NULL;
205
206 ctx = BN_CTX_new();
207 if (!ctx)
208 goto error;
209
210 BN_CTX_start(ctx);
211 Xp = BN_CTX_get(ctx);
212 Xq = BN_CTX_get(ctx);
213 if (!BN_X931_generate_Xpq(Xp, Xq, bits, ctx))
214 goto error;
215
216 rsa->p = BN_new();
217 rsa->q = BN_new();
218 if (!rsa->p || !rsa->q)
219 goto error;
220
221 /* Generate two primes from Xp, Xq */
222
223 if (!BN_X931_generate_prime_ex(rsa->p, NULL, NULL, NULL, NULL, Xp,
224 e, ctx, cb))
225 goto error;
226
227 if (!BN_X931_generate_prime_ex(rsa->q, NULL, NULL, NULL, NULL, Xq,
228 e, ctx, cb))
229 goto error;
230
231 /* Since rsa->p and rsa->q are valid this call will just derive
232 * remaining RSA components.
233 */
234
235 if (!RSA_X931_derive_ex(rsa, NULL, NULL, NULL, NULL,
236 NULL, NULL, NULL, NULL, NULL, NULL, e, cb))
237 goto error;
238
239 ok = 1;
240
241 error:
242 if (ctx)
243 {
244 BN_CTX_end(ctx);
245 BN_CTX_free(ctx);
246 }
247
248 if (ok)
249 return 1;
250
251 return 0;
252
253 }
254
255#endif
diff --git a/src/lib/libcrypto/sha/Makefile.ssl b/src/lib/libcrypto/sha/Makefile.ssl
deleted file mode 100644
index 4ba201c787..0000000000
--- a/src/lib/libcrypto/sha/Makefile.ssl
+++ /dev/null
@@ -1,116 +0,0 @@
1#
2# SSLeay/crypto/sha/Makefile
3#
4
5DIR= sha
6TOP= ../..
7CC= cc
8CPP= $(CC) -E
9INCLUDES=
10CFLAG=-g
11INSTALL_PREFIX=
12OPENSSLDIR= /usr/local/ssl
13INSTALLTOP=/usr/local/ssl
14MAKE= make -f Makefile.ssl
15MAKEDEPPROG= makedepend
16MAKEDEPEND= $(TOP)/util/domd $(TOP) -MD $(MAKEDEPPROG)
17MAKEFILE= Makefile.ssl
18AR= ar r
19
20SHA1_ASM_OBJ=
21
22CFLAGS= $(INCLUDES) $(CFLAG)
23ASFLAGS= $(INCLUDES) $(ASFLAG)
24
25GENERAL=Makefile
26TEST=shatest.c sha1test.c
27APPS=
28
29LIB=$(TOP)/libcrypto.a
30LIBSRC=sha_dgst.c sha1dgst.c sha_one.c sha1_one.c
31LIBOBJ=sha_dgst.o sha1dgst.o sha_one.o sha1_one.o $(SHA1_ASM_OBJ)
32
33SRC= $(LIBSRC)
34
35EXHEADER= sha.h
36HEADER= sha_locl.h $(EXHEADER)
37
38ALL= $(GENERAL) $(SRC) $(HEADER)
39
40top:
41 (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all)
42
43all: lib
44
45lib: $(LIBOBJ)
46 $(AR) $(LIB) $(LIBOBJ)
47 $(RANLIB) $(LIB) || echo Never mind.
48 @touch lib
49
50# elf
51asm/sx86-elf.s: asm/sha1-586.pl ../perlasm/x86asm.pl
52 (cd asm; $(PERL) sha1-586.pl elf $(CFLAGS) $(PROCESSOR) > sx86-elf.s)
53
54# a.out
55asm/sx86-out.o: asm/sx86unix.cpp
56 $(CPP) -DOUT asm/sx86unix.cpp | as -o asm/sx86-out.o
57
58# bsdi
59asm/sx86bsdi.o: asm/sx86unix.cpp
60 $(CPP) -DBSDI asm/sx86unix.cpp | sed 's/ :/:/' | as -o asm/sx86bsdi.o
61
62asm/sx86unix.cpp: asm/sha1-586.pl ../perlasm/x86asm.pl
63 (cd asm; $(PERL) sha1-586.pl cpp $(PROCESSOR) >sx86unix.cpp)
64
65files:
66 $(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO
67
68links:
69 @sh $(TOP)/util/point.sh Makefile.ssl Makefile
70 @$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER)
71 @$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST)
72 @$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS)
73
74install:
75 @for i in $(EXHEADER) ; \
76 do \
77 (cp $$i $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i; \
78 chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i ); \
79 done;
80
81tags:
82 ctags $(SRC)
83
84tests:
85
86lint:
87 lint -DLINT $(INCLUDES) $(SRC)>fluff
88
89depend:
90 $(MAKEDEPEND) -- $(CFLAG) $(INCLUDES) $(DEPFLAG) -- $(PROGS) $(LIBSRC)
91
92dclean:
93 $(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
94 mv -f Makefile.new $(MAKEFILE)
95
96clean:
97 rm -f asm/sx86unix.cpp asm/*-elf.* *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff asm/*.o
98
99# DO NOT DELETE THIS LINE -- make depend depends on it.
100
101sha1_one.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
102sha1_one.o: ../../include/openssl/opensslconf.h
103sha1_one.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
104sha1_one.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
105sha1_one.o: ../../include/openssl/symhacks.h sha1_one.c
106sha1dgst.o: ../../include/openssl/e_os2.h ../../include/openssl/opensslconf.h
107sha1dgst.o: ../../include/openssl/opensslv.h ../../include/openssl/sha.h
108sha1dgst.o: ../md32_common.h sha1dgst.c sha_locl.h
109sha_dgst.o: ../../include/openssl/e_os2.h ../../include/openssl/opensslconf.h
110sha_dgst.o: ../../include/openssl/opensslv.h ../../include/openssl/sha.h
111sha_dgst.o: ../md32_common.h sha_dgst.c sha_locl.h
112sha_one.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
113sha_one.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
114sha_one.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
115sha_one.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
116sha_one.o: sha_one.c
diff --git a/src/lib/libcrypto/sha/asm/sha1-586.pl b/src/lib/libcrypto/sha/asm/sha1-586.pl
index a787dd37da..a1f876281a 100644
--- a/src/lib/libcrypto/sha/asm/sha1-586.pl
+++ b/src/lib/libcrypto/sha/asm/sha1-586.pl
@@ -215,5 +215,6 @@ sub BODY_40_59
215 215
216 &stack_pop(16); 216 &stack_pop(16);
217&function_end("sha1_block_data_order"); 217&function_end("sha1_block_data_order");
218&asciz("SHA1 block transform for x86, CRYPTOGAMS by <appro\@openssl.org>");
218 219
219&asm_finish(); 220&asm_finish();
diff --git a/src/lib/libcrypto/sha/asm/sha512-sse2.pl b/src/lib/libcrypto/sha/asm/sha512-sse2.pl
deleted file mode 100644
index 10902bf673..0000000000
--- a/src/lib/libcrypto/sha/asm/sha512-sse2.pl
+++ /dev/null
@@ -1,404 +0,0 @@
1#!/usr/bin/env perl
2#
3# ====================================================================
4# Written by Andy Polyakov <appro@fy.chalmers.se> for the OpenSSL
5# project. Rights for redistribution and usage in source and binary
6# forms are granted according to the OpenSSL license.
7# ====================================================================
8#
9# SHA512_Transform_SSE2.
10#
11# As the name suggests, this is an IA-32 SSE2 implementation of
12# SHA512_Transform. Motivating factor for the undertaken effort was that
13# SHA512 was observed to *consistently* perform *significantly* poorer
14# than SHA256 [2x and slower is common] on 32-bit platforms. On 64-bit
15# platforms on the other hand SHA512 tend to outperform SHA256 [~50%
16# seem to be common improvement factor]. All this is perfectly natural,
17# as SHA512 is a 64-bit algorithm. But isn't IA-32 SSE2 essentially
18# a 64-bit instruction set? Is it rich enough to implement SHA512?
19# If answer was "no," then you wouldn't have been reading this...
20#
21# Throughput performance in MBps (larger is better):
22#
23# 2.4GHz P4 1.4GHz AMD32 1.4GHz AMD64(*)
24# SHA256/gcc(*) 54 43 59
25# SHA512/gcc 17 23 92
26# SHA512/sse2 61(**) 57(**)
27# SHA512/icc 26 28
28# SHA256/icc(*) 65 54
29#
30# (*) AMD64 and SHA256 numbers are presented mostly for amusement or
31# reference purposes.
32# (**) I.e. it gives ~2-3x speed-up if compared with compiler generated
33# code. One can argue that hand-coded *non*-SSE2 implementation
34# would perform better than compiler generated one as well, and
35# that comparison is therefore not exactly fair. Well, as SHA512
36# puts enormous pressure on IA-32 GP register bank, I reckon that
37# hand-coded version wouldn't perform significantly better than
38# one compiled with icc, ~20% perhaps... So that this code would
39# still outperform it with distinguishing marginal. But feel free
40# to prove me wrong:-)
41# <appro@fy.chalmers.se>
42push(@INC,"perlasm","../../perlasm");
43require "x86asm.pl";
44
45&asm_init($ARGV[0],"sha512-sse2.pl",$ARGV[$#ARGV] eq "386");
46
47$K512="esi"; # K512[80] table, found at the end...
48#$W512="esp"; # $W512 is not just W512[16]: it comprises *two* copies
49 # of W512[16] and a copy of A-H variables...
50$W512_SZ=8*(16+16+8); # see above...
51#$Kidx="ebx"; # index in K512 table, advances from 0 to 80...
52$Widx="edx"; # index in W512, wraps around at 16...
53$data="edi"; # 16 qwords of input data...
54$A="mm0"; # B-D and
55$E="mm1"; # F-H are allocated dynamically...
56$Aoff=256+0; # A-H offsets relative to $W512...
57$Boff=256+8;
58$Coff=256+16;
59$Doff=256+24;
60$Eoff=256+32;
61$Foff=256+40;
62$Goff=256+48;
63$Hoff=256+56;
64
65sub SHA2_ROUND()
66{ local ($kidx,$widx)=@_;
67
68 # One can argue that one could reorder instructions for better
69 # performance. Well, I tried and it doesn't seem to make any
70 # noticeable difference. Modern out-of-order execution cores
71 # reorder instructions to their liking in either case and they
72 # apparently do decent job. So we can keep the code more
73 # readable/regular/comprehensible:-)
74
75 # I adhere to 64-bit %mmX registers in order to avoid/not care
76 # about #GP exceptions on misaligned 128-bit access, most
77 # notably in paddq with memory operand. Not to mention that
78 # SSE2 intructions operating on %mmX can be scheduled every
79 # cycle [and not every second one if operating on %xmmN].
80
81 &movq ("mm4",&QWP($Foff,$W512)); # load f
82 &movq ("mm5",&QWP($Goff,$W512)); # load g
83 &movq ("mm6",&QWP($Hoff,$W512)); # load h
84
85 &movq ("mm2",$E); # %mm2 is sliding right
86 &movq ("mm3",$E); # %mm3 is sliding left
87 &psrlq ("mm2",14);
88 &psllq ("mm3",23);
89 &movq ("mm7","mm2"); # %mm7 is T1
90 &pxor ("mm7","mm3");
91 &psrlq ("mm2",4);
92 &psllq ("mm3",23);
93 &pxor ("mm7","mm2");
94 &pxor ("mm7","mm3");
95 &psrlq ("mm2",23);
96 &psllq ("mm3",4);
97 &pxor ("mm7","mm2");
98 &pxor ("mm7","mm3"); # T1=Sigma1_512(e)
99
100 &movq (&QWP($Foff,$W512),$E); # f = e
101 &movq (&QWP($Goff,$W512),"mm4"); # g = f
102 &movq (&QWP($Hoff,$W512),"mm5"); # h = g
103
104 &pxor ("mm4","mm5"); # f^=g
105 &pand ("mm4",$E); # f&=e
106 &pxor ("mm4","mm5"); # f^=g
107 &paddq ("mm7","mm4"); # T1+=Ch(e,f,g)
108
109 &movq ("mm2",&QWP($Boff,$W512)); # load b
110 &movq ("mm3",&QWP($Coff,$W512)); # load c
111 &movq ($E,&QWP($Doff,$W512)); # e = d
112
113 &paddq ("mm7","mm6"); # T1+=h
114 &paddq ("mm7",&QWP(0,$K512,$kidx,8)); # T1+=K512[i]
115 &paddq ("mm7",&QWP(0,$W512,$widx,8)); # T1+=W512[i]
116 &paddq ($E,"mm7"); # e += T1
117
118 &movq ("mm4",$A); # %mm4 is sliding right
119 &movq ("mm5",$A); # %mm5 is sliding left
120 &psrlq ("mm4",28);
121 &psllq ("mm5",25);
122 &movq ("mm6","mm4"); # %mm6 is T2
123 &pxor ("mm6","mm5");
124 &psrlq ("mm4",6);
125 &psllq ("mm5",5);
126 &pxor ("mm6","mm4");
127 &pxor ("mm6","mm5");
128 &psrlq ("mm4",5);
129 &psllq ("mm5",6);
130 &pxor ("mm6","mm4");
131 &pxor ("mm6","mm5"); # T2=Sigma0_512(a)
132
133 &movq (&QWP($Boff,$W512),$A); # b = a
134 &movq (&QWP($Coff,$W512),"mm2"); # c = b
135 &movq (&QWP($Doff,$W512),"mm3"); # d = c
136
137 &movq ("mm4",$A); # %mm4=a
138 &por ($A,"mm3"); # a=a|c
139 &pand ("mm4","mm3"); # %mm4=a&c
140 &pand ($A,"mm2"); # a=(a|c)&b
141 &por ("mm4",$A); # %mm4=(a&c)|((a|c)&b)
142 &paddq ("mm6","mm4"); # T2+=Maj(a,b,c)
143
144 &movq ($A,"mm7"); # a=T1
145 &paddq ($A,"mm6"); # a+=T2
146}
147
148$func="sha512_block_sse2";
149
150&function_begin_B($func);
151 if (0) {# Caller is expected to check if it's appropriate to
152 # call this routine. Below 3 lines are retained for
153 # debugging purposes...
154 &picmeup("eax","OPENSSL_ia32cap");
155 &bt (&DWP(0,"eax"),26);
156 &jnc ("SHA512_Transform");
157 }
158
159 &push ("ebp");
160 &mov ("ebp","esp");
161 &push ("ebx");
162 &push ("esi");
163 &push ("edi");
164
165 &mov ($Widx,&DWP(8,"ebp")); # A-H state, 1st arg
166 &mov ($data,&DWP(12,"ebp")); # input data, 2nd arg
167 &call (&label("pic_point")); # make it PIC!
168&set_label("pic_point");
169 &blindpop($K512);
170 &lea ($K512,&DWP(&label("K512")."-".&label("pic_point"),$K512));
171
172 $W512 = "esp"; # start using %esp as W512
173 &sub ($W512,$W512_SZ);
174 &and ($W512,-16); # ensure 128-bit alignment
175
176 # make private copy of A-H
177 # v assume the worst and stick to unaligned load
178 &movdqu ("xmm0",&QWP(0,$Widx));
179 &movdqu ("xmm1",&QWP(16,$Widx));
180 &movdqu ("xmm2",&QWP(32,$Widx));
181 &movdqu ("xmm3",&QWP(48,$Widx));
182
183&align(8);
184&set_label("_chunk_loop");
185
186 &movdqa (&QWP($Aoff,$W512),"xmm0"); # a,b
187 &movdqa (&QWP($Coff,$W512),"xmm1"); # c,d
188 &movdqa (&QWP($Eoff,$W512),"xmm2"); # e,f
189 &movdqa (&QWP($Goff,$W512),"xmm3"); # g,h
190
191 &xor ($Widx,$Widx);
192
193 &movdq2q($A,"xmm0"); # load a
194 &movdq2q($E,"xmm2"); # load e
195
196 # Why aren't loops unrolled? It makes sense to unroll if
197 # execution time for loop body is comparable with branch
198 # penalties and/or if whole data-set resides in register bank.
199 # Neither is case here... Well, it would be possible to
200 # eliminate few store operations, but it would hardly affect
201 # so to say stop-watch performance, as there is a lot of
202 # available memory slots to fill. It will only relieve some
203 # pressure off memory bus...
204
205 # flip input stream byte order...
206 &mov ("eax",&DWP(0,$data,$Widx,8));
207 &mov ("ebx",&DWP(4,$data,$Widx,8));
208 &bswap ("eax");
209 &bswap ("ebx");
210 &mov (&DWP(0,$W512,$Widx,8),"ebx"); # W512[i]
211 &mov (&DWP(4,$W512,$Widx,8),"eax");
212 &mov (&DWP(128+0,$W512,$Widx,8),"ebx"); # copy of W512[i]
213 &mov (&DWP(128+4,$W512,$Widx,8),"eax");
214
215&align(8);
216&set_label("_1st_loop"); # 0-15
217 # flip input stream byte order...
218 &mov ("eax",&DWP(0+8,$data,$Widx,8));
219 &mov ("ebx",&DWP(4+8,$data,$Widx,8));
220 &bswap ("eax");
221 &bswap ("ebx");
222 &mov (&DWP(0+8,$W512,$Widx,8),"ebx"); # W512[i]
223 &mov (&DWP(4+8,$W512,$Widx,8),"eax");
224 &mov (&DWP(128+0+8,$W512,$Widx,8),"ebx"); # copy of W512[i]
225 &mov (&DWP(128+4+8,$W512,$Widx,8),"eax");
226&set_label("_1st_looplet");
227 &SHA2_ROUND($Widx,$Widx); &inc($Widx);
228
229&cmp ($Widx,15)
230&jl (&label("_1st_loop"));
231&je (&label("_1st_looplet")); # playing similar trick on 2nd loop
232 # does not improve performance...
233
234 $Kidx = "ebx"; # start using %ebx as Kidx
235 &mov ($Kidx,$Widx);
236
237&align(8);
238&set_label("_2nd_loop"); # 16-79
239 &and($Widx,0xf);
240
241 # 128-bit fragment! I update W512[i] and W512[i+1] in
242 # parallel:-) Note that I refer to W512[(i&0xf)+N] and not to
243 # W512[(i+N)&0xf]! This is exactly what I maintain the second
244 # copy of W512[16] for...
245 &movdqu ("xmm0",&QWP(8*1,$W512,$Widx,8)); # s0=W512[i+1]
246 &movdqa ("xmm2","xmm0"); # %xmm2 is sliding right
247 &movdqa ("xmm3","xmm0"); # %xmm3 is sliding left
248 &psrlq ("xmm2",1);
249 &psllq ("xmm3",56);
250 &movdqa ("xmm0","xmm2");
251 &pxor ("xmm0","xmm3");
252 &psrlq ("xmm2",6);
253 &psllq ("xmm3",7);
254 &pxor ("xmm0","xmm2");
255 &pxor ("xmm0","xmm3");
256 &psrlq ("xmm2",1);
257 &pxor ("xmm0","xmm2"); # s0 = sigma0_512(s0);
258
259 &movdqa ("xmm1",&QWP(8*14,$W512,$Widx,8)); # s1=W512[i+14]
260 &movdqa ("xmm4","xmm1"); # %xmm4 is sliding right
261 &movdqa ("xmm5","xmm1"); # %xmm5 is sliding left
262 &psrlq ("xmm4",6);
263 &psllq ("xmm5",3);
264 &movdqa ("xmm1","xmm4");
265 &pxor ("xmm1","xmm5");
266 &psrlq ("xmm4",13);
267 &psllq ("xmm5",42);
268 &pxor ("xmm1","xmm4");
269 &pxor ("xmm1","xmm5");
270 &psrlq ("xmm4",42);
271 &pxor ("xmm1","xmm4"); # s1 = sigma1_512(s1);
272
273 # + have to explictly load W512[i+9] as it's not 128-bit
274 # v aligned and paddq would throw an exception...
275 &movdqu ("xmm6",&QWP(8*9,$W512,$Widx,8));
276 &paddq ("xmm0","xmm1"); # s0 += s1
277 &paddq ("xmm0","xmm6"); # s0 += W512[i+9]
278 &paddq ("xmm0",&QWP(0,$W512,$Widx,8)); # s0 += W512[i]
279
280 &movdqa (&QWP(0,$W512,$Widx,8),"xmm0"); # W512[i] = s0
281 &movdqa (&QWP(16*8,$W512,$Widx,8),"xmm0"); # copy of W512[i]
282
283 # as the above fragment was 128-bit, we "owe" 2 rounds...
284 &SHA2_ROUND($Kidx,$Widx); &inc($Kidx); &inc($Widx);
285 &SHA2_ROUND($Kidx,$Widx); &inc($Kidx); &inc($Widx);
286
287&cmp ($Kidx,80);
288&jl (&label("_2nd_loop"));
289
290 # update A-H state
291 &mov ($Widx,&DWP(8,"ebp")); # A-H state, 1st arg
292 &movq (&QWP($Aoff,$W512),$A); # write out a
293 &movq (&QWP($Eoff,$W512),$E); # write out e
294 &movdqu ("xmm0",&QWP(0,$Widx));
295 &movdqu ("xmm1",&QWP(16,$Widx));
296 &movdqu ("xmm2",&QWP(32,$Widx));
297 &movdqu ("xmm3",&QWP(48,$Widx));
298 &paddq ("xmm0",&QWP($Aoff,$W512)); # 128-bit additions...
299 &paddq ("xmm1",&QWP($Coff,$W512));
300 &paddq ("xmm2",&QWP($Eoff,$W512));
301 &paddq ("xmm3",&QWP($Goff,$W512));
302 &movdqu (&QWP(0,$Widx),"xmm0");
303 &movdqu (&QWP(16,$Widx),"xmm1");
304 &movdqu (&QWP(32,$Widx),"xmm2");
305 &movdqu (&QWP(48,$Widx),"xmm3");
306
307&add ($data,16*8); # advance input data pointer
308&dec (&DWP(16,"ebp")); # decrement 3rd arg
309&jnz (&label("_chunk_loop"));
310
311 # epilogue
312 &emms (); # required for at least ELF and Win32 ABIs
313 &mov ("edi",&DWP(-12,"ebp"));
314 &mov ("esi",&DWP(-8,"ebp"));
315 &mov ("ebx",&DWP(-4,"ebp"));
316 &leave ();
317&ret ();
318
319&align(64);
320&set_label("K512"); # Yes! I keep it in the code segment!
321 &data_word(0xd728ae22,0x428a2f98); # u64
322 &data_word(0x23ef65cd,0x71374491); # u64
323 &data_word(0xec4d3b2f,0xb5c0fbcf); # u64
324 &data_word(0x8189dbbc,0xe9b5dba5); # u64
325 &data_word(0xf348b538,0x3956c25b); # u64
326 &data_word(0xb605d019,0x59f111f1); # u64
327 &data_word(0xaf194f9b,0x923f82a4); # u64
328 &data_word(0xda6d8118,0xab1c5ed5); # u64
329 &data_word(0xa3030242,0xd807aa98); # u64
330 &data_word(0x45706fbe,0x12835b01); # u64
331 &data_word(0x4ee4b28c,0x243185be); # u64
332 &data_word(0xd5ffb4e2,0x550c7dc3); # u64
333 &data_word(0xf27b896f,0x72be5d74); # u64
334 &data_word(0x3b1696b1,0x80deb1fe); # u64
335 &data_word(0x25c71235,0x9bdc06a7); # u64
336 &data_word(0xcf692694,0xc19bf174); # u64
337 &data_word(0x9ef14ad2,0xe49b69c1); # u64
338 &data_word(0x384f25e3,0xefbe4786); # u64
339 &data_word(0x8b8cd5b5,0x0fc19dc6); # u64
340 &data_word(0x77ac9c65,0x240ca1cc); # u64
341 &data_word(0x592b0275,0x2de92c6f); # u64
342 &data_word(0x6ea6e483,0x4a7484aa); # u64
343 &data_word(0xbd41fbd4,0x5cb0a9dc); # u64
344 &data_word(0x831153b5,0x76f988da); # u64
345 &data_word(0xee66dfab,0x983e5152); # u64
346 &data_word(0x2db43210,0xa831c66d); # u64
347 &data_word(0x98fb213f,0xb00327c8); # u64
348 &data_word(0xbeef0ee4,0xbf597fc7); # u64
349 &data_word(0x3da88fc2,0xc6e00bf3); # u64
350 &data_word(0x930aa725,0xd5a79147); # u64
351 &data_word(0xe003826f,0x06ca6351); # u64
352 &data_word(0x0a0e6e70,0x14292967); # u64
353 &data_word(0x46d22ffc,0x27b70a85); # u64
354 &data_word(0x5c26c926,0x2e1b2138); # u64
355 &data_word(0x5ac42aed,0x4d2c6dfc); # u64
356 &data_word(0x9d95b3df,0x53380d13); # u64
357 &data_word(0x8baf63de,0x650a7354); # u64
358 &data_word(0x3c77b2a8,0x766a0abb); # u64
359 &data_word(0x47edaee6,0x81c2c92e); # u64
360 &data_word(0x1482353b,0x92722c85); # u64
361 &data_word(0x4cf10364,0xa2bfe8a1); # u64
362 &data_word(0xbc423001,0xa81a664b); # u64
363 &data_word(0xd0f89791,0xc24b8b70); # u64
364 &data_word(0x0654be30,0xc76c51a3); # u64
365 &data_word(0xd6ef5218,0xd192e819); # u64
366 &data_word(0x5565a910,0xd6990624); # u64
367 &data_word(0x5771202a,0xf40e3585); # u64
368 &data_word(0x32bbd1b8,0x106aa070); # u64
369 &data_word(0xb8d2d0c8,0x19a4c116); # u64
370 &data_word(0x5141ab53,0x1e376c08); # u64
371 &data_word(0xdf8eeb99,0x2748774c); # u64
372 &data_word(0xe19b48a8,0x34b0bcb5); # u64
373 &data_word(0xc5c95a63,0x391c0cb3); # u64
374 &data_word(0xe3418acb,0x4ed8aa4a); # u64
375 &data_word(0x7763e373,0x5b9cca4f); # u64
376 &data_word(0xd6b2b8a3,0x682e6ff3); # u64
377 &data_word(0x5defb2fc,0x748f82ee); # u64
378 &data_word(0x43172f60,0x78a5636f); # u64
379 &data_word(0xa1f0ab72,0x84c87814); # u64
380 &data_word(0x1a6439ec,0x8cc70208); # u64
381 &data_word(0x23631e28,0x90befffa); # u64
382 &data_word(0xde82bde9,0xa4506ceb); # u64
383 &data_word(0xb2c67915,0xbef9a3f7); # u64
384 &data_word(0xe372532b,0xc67178f2); # u64
385 &data_word(0xea26619c,0xca273ece); # u64
386 &data_word(0x21c0c207,0xd186b8c7); # u64
387 &data_word(0xcde0eb1e,0xeada7dd6); # u64
388 &data_word(0xee6ed178,0xf57d4f7f); # u64
389 &data_word(0x72176fba,0x06f067aa); # u64
390 &data_word(0xa2c898a6,0x0a637dc5); # u64
391 &data_word(0xbef90dae,0x113f9804); # u64
392 &data_word(0x131c471b,0x1b710b35); # u64
393 &data_word(0x23047d84,0x28db77f5); # u64
394 &data_word(0x40c72493,0x32caab7b); # u64
395 &data_word(0x15c9bebc,0x3c9ebe0a); # u64
396 &data_word(0x9c100d4c,0x431d67c4); # u64
397 &data_word(0xcb3e42b6,0x4cc5d4be); # u64
398 &data_word(0xfc657e2a,0x597f299c); # u64
399 &data_word(0x3ad6faec,0x5fcb6fab); # u64
400 &data_word(0x4a475817,0x6c44198c); # u64
401
402&function_end_B($func);
403
404&asm_finish();
diff --git a/src/lib/libcrypto/sha/sha.h b/src/lib/libcrypto/sha/sha.h
index 47a2c29f66..16cacf9fc0 100644
--- a/src/lib/libcrypto/sha/sha.h
+++ b/src/lib/libcrypto/sha/sha.h
@@ -81,7 +81,7 @@ extern "C" {
81 * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 81 * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
82 */ 82 */
83 83
84#if defined(OPENSSL_SYS_WIN16) || defined(__LP32__) 84#if defined(__LP32__)
85#define SHA_LONG unsigned long 85#define SHA_LONG unsigned long
86#elif defined(OPENSSL_SYS_CRAY) || defined(__ILP64__) 86#elif defined(OPENSSL_SYS_CRAY) || defined(__ILP64__)
87#define SHA_LONG unsigned long 87#define SHA_LONG unsigned long
@@ -106,9 +106,6 @@ typedef struct SHAstate_st
106 } SHA_CTX; 106 } SHA_CTX;
107 107
108#ifndef OPENSSL_NO_SHA0 108#ifndef OPENSSL_NO_SHA0
109#ifdef OPENSSL_FIPS
110int private_SHA_Init(SHA_CTX *c);
111#endif
112int SHA_Init(SHA_CTX *c); 109int SHA_Init(SHA_CTX *c);
113int SHA_Update(SHA_CTX *c, const void *data, size_t len); 110int SHA_Update(SHA_CTX *c, const void *data, size_t len);
114int SHA_Final(unsigned char *md, SHA_CTX *c); 111int SHA_Final(unsigned char *md, SHA_CTX *c);
diff --git a/src/lib/libcrypto/sha/sha1_one.c b/src/lib/libcrypto/sha/sha1_one.c
index 4831174198..7c65b60276 100644
--- a/src/lib/libcrypto/sha/sha1_one.c
+++ b/src/lib/libcrypto/sha/sha1_one.c
@@ -61,7 +61,7 @@
61#include <openssl/sha.h> 61#include <openssl/sha.h>
62#include <openssl/crypto.h> 62#include <openssl/crypto.h>
63 63
64#if !defined(OPENSSL_NO_SHA1) 64#ifndef OPENSSL_NO_SHA1
65unsigned char *SHA1(const unsigned char *d, size_t n, unsigned char *md) 65unsigned char *SHA1(const unsigned char *d, size_t n, unsigned char *md)
66 { 66 {
67 SHA_CTX c; 67 SHA_CTX c;
diff --git a/src/lib/libcrypto/sha/sha1dgst.c b/src/lib/libcrypto/sha/sha1dgst.c
index d31f0781a0..50d1925cde 100644
--- a/src/lib/libcrypto/sha/sha1dgst.c
+++ b/src/lib/libcrypto/sha/sha1dgst.c
@@ -63,10 +63,6 @@
63#define SHA_1 63#define SHA_1
64 64
65#include <openssl/opensslv.h> 65#include <openssl/opensslv.h>
66#ifdef OPENSSL_FIPS
67#include <openssl/fips.h>
68#endif
69
70 66
71const char SHA1_version[]="SHA1" OPENSSL_VERSION_PTEXT; 67const char SHA1_version[]="SHA1" OPENSSL_VERSION_PTEXT;
72 68
diff --git a/src/lib/libcrypto/sha/sha1s.cpp b/src/lib/libcrypto/sha/sha1s.cpp
deleted file mode 100644
index af23d1e0f2..0000000000
--- a/src/lib/libcrypto/sha/sha1s.cpp
+++ /dev/null
@@ -1,82 +0,0 @@
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/sha.h>
36
37#define sha1_block_x86 sha1_block_asm_data_order
38extern "C" {
39void sha1_block_x86(SHA_CTX *ctx, unsigned char *buffer,int num);
40}
41
42void main(int argc,char *argv[])
43 {
44 unsigned char buffer[64*256];
45 SHA_CTX ctx;
46 unsigned long s1,s2,e1,e2;
47 unsigned char k[16];
48 unsigned long data[2];
49 unsigned char iv[8];
50 int i,num=0,numm;
51 int j=0;
52
53 if (argc >= 2)
54 num=atoi(argv[1]);
55
56 if (num == 0) num=16;
57 if (num > 250) num=16;
58 numm=num+2;
59#if 0
60 num*=64;
61 numm*=64;
62#endif
63
64 for (j=0; j<6; j++)
65 {
66 for (i=0; i<10; i++) /**/
67 {
68 sha1_block_x86(&ctx,buffer,numm);
69 GetTSC(s1);
70 sha1_block_x86(&ctx,buffer,numm);
71 GetTSC(e1);
72 GetTSC(s2);
73 sha1_block_x86(&ctx,buffer,num);
74 GetTSC(e2);
75 sha1_block_x86(&ctx,buffer,num);
76 }
77
78 printf("sha1 (%d bytes) %d %d (%.2f)\n",num*64,
79 e1-s1,e2-s2,(double)((e1-s1)-(e2-s2))/2);
80 }
81 }
82
diff --git a/src/lib/libcrypto/sha/sha_dgst.c b/src/lib/libcrypto/sha/sha_dgst.c
index 598f4d721a..70eb56032c 100644
--- a/src/lib/libcrypto/sha/sha_dgst.c
+++ b/src/lib/libcrypto/sha/sha_dgst.c
@@ -57,12 +57,6 @@
57 */ 57 */
58 58
59#include <openssl/opensslconf.h> 59#include <openssl/opensslconf.h>
60#include <openssl/crypto.h>
61#ifdef OPENSSL_FIPS
62#include <openssl/fips.h>
63#endif
64
65#include <openssl/err.h>
66#if !defined(OPENSSL_NO_SHA0) && !defined(OPENSSL_NO_SHA) 60#if !defined(OPENSSL_NO_SHA0) && !defined(OPENSSL_NO_SHA)
67 61
68#undef SHA_1 62#undef SHA_1
diff --git a/src/lib/libcrypto/sha/sha_locl.h b/src/lib/libcrypto/sha/sha_locl.h
index da46ddfe79..672c26eee1 100644
--- a/src/lib/libcrypto/sha/sha_locl.h
+++ b/src/lib/libcrypto/sha/sha_locl.h
@@ -122,23 +122,14 @@ void sha1_block_data_order (SHA_CTX *c, const void *p,size_t num);
122#define INIT_DATA_h3 0x10325476UL 122#define INIT_DATA_h3 0x10325476UL
123#define INIT_DATA_h4 0xc3d2e1f0UL 123#define INIT_DATA_h4 0xc3d2e1f0UL
124 124
125#if defined(SHA_0) && defined(OPENSSL_FIPS)
126FIPS_NON_FIPS_MD_Init(SHA)
127#else
128int HASH_INIT (SHA_CTX *c) 125int HASH_INIT (SHA_CTX *c)
129#endif
130 { 126 {
131#if defined(SHA_1) && defined(OPENSSL_FIPS) 127 memset (c,0,sizeof(*c));
132 FIPS_selftest_check();
133#endif
134 c->h0=INIT_DATA_h0; 128 c->h0=INIT_DATA_h0;
135 c->h1=INIT_DATA_h1; 129 c->h1=INIT_DATA_h1;
136 c->h2=INIT_DATA_h2; 130 c->h2=INIT_DATA_h2;
137 c->h3=INIT_DATA_h3; 131 c->h3=INIT_DATA_h3;
138 c->h4=INIT_DATA_h4; 132 c->h4=INIT_DATA_h4;
139 c->Nl=0;
140 c->Nh=0;
141 c->num=0;
142 return 1; 133 return 1;
143 } 134 }
144 135
diff --git a/src/lib/libcrypto/sha/shatest.c b/src/lib/libcrypto/sha/shatest.c
index ed0fe06a7b..27614646d1 100644
--- a/src/lib/libcrypto/sha/shatest.c
+++ b/src/lib/libcrypto/sha/shatest.c
@@ -123,9 +123,9 @@ int main(int argc, char *argv[])
123 i=1; 123 i=1;
124 while (*P != NULL) 124 while (*P != NULL)
125 { 125 {
126 EVP_Digest(*P,strlen((char *)*P),md,NULL,EVP_sha(), NULL); 126 EVP_Digest(*P,strlen(*P),md,NULL,EVP_sha(), NULL);
127 p=pt(md); 127 p=pt(md);
128 if (strcmp(p,(char *)*R) != 0) 128 if (strcmp(p,*R) != 0)
129 { 129 {
130 printf("error calculating SHA on '%s'\n",*P); 130 printf("error calculating SHA on '%s'\n",*P);
131 printf("got %s instead of %s\n",p,*R); 131 printf("got %s instead of %s\n",p,*R);
diff --git a/src/lib/libcrypto/stack/Makefile.ssl b/src/lib/libcrypto/stack/Makefile.ssl
deleted file mode 100644
index 7120fb804a..0000000000
--- a/src/lib/libcrypto/stack/Makefile.ssl
+++ /dev/null
@@ -1,88 +0,0 @@
1#
2# SSLeay/crypto/stack/Makefile
3#
4
5DIR= stack
6TOP= ../..
7CC= cc
8INCLUDES=
9CFLAG=-g
10INSTALL_PREFIX=
11OPENSSLDIR= /usr/local/ssl
12INSTALLTOP=/usr/local/ssl
13MAKE= make -f Makefile.ssl
14MAKEDEPPROG= makedepend
15MAKEDEPEND= $(TOP)/util/domd $(TOP) -MD $(MAKEDEPPROG)
16MAKEFILE= Makefile.ssl
17AR= ar r
18
19CFLAGS= $(INCLUDES) $(CFLAG)
20
21GENERAL=Makefile
22TEST=
23APPS=
24
25LIB=$(TOP)/libcrypto.a
26LIBSRC=stack.c
27LIBOBJ=stack.o
28
29SRC= $(LIBSRC)
30
31EXHEADER= stack.h safestack.h
32HEADER= $(EXHEADER)
33
34ALL= $(GENERAL) $(SRC) $(HEADER)
35
36top:
37 (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all)
38
39all: lib
40
41lib: $(LIBOBJ)
42 $(AR) $(LIB) $(LIBOBJ)
43 $(RANLIB) $(LIB) || echo Never mind.
44 @touch lib
45
46files:
47 $(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO
48
49links:
50 @sh $(TOP)/util/point.sh Makefile.ssl Makefile
51 @$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER)
52 @$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST)
53 @$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS)
54
55install:
56 @for i in $(EXHEADER) ; \
57 do \
58 (cp $$i $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i; \
59 chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i ); \
60 done;
61
62tags:
63 ctags $(SRC)
64
65tests:
66
67lint:
68 lint -DLINT $(INCLUDES) $(SRC)>fluff
69
70depend:
71 $(MAKEDEPEND) -- $(CFLAG) $(INCLUDES) $(DEPFLAG) -- $(PROGS) $(LIBSRC)
72
73dclean:
74 $(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
75 mv -f Makefile.new $(MAKEFILE)
76
77clean:
78 rm -f *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff
79
80# DO NOT DELETE THIS LINE -- make depend depends on it.
81
82stack.o: ../../e_os.h ../../include/openssl/bio.h
83stack.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
84stack.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
85stack.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
86stack.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
87stack.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
88stack.o: ../cryptlib.h stack.c
diff --git a/src/lib/libcrypto/stack/safestack.h b/src/lib/libcrypto/stack/safestack.h
index 40b17902e0..891cb84a51 100644
--- a/src/lib/libcrypto/stack/safestack.h
+++ b/src/lib/libcrypto/stack/safestack.h
@@ -57,18 +57,27 @@
57 57
58#include <openssl/stack.h> 58#include <openssl/stack.h>
59 59
60#ifdef DEBUG_SAFESTACK
61
62#ifndef CHECKED_PTR_OF 60#ifndef CHECKED_PTR_OF
63#define CHECKED_PTR_OF(type, p) \ 61#define CHECKED_PTR_OF(type, p) \
64 ((void*) (1 ? p : (type*)0)) 62 ((void*) (1 ? p : (type*)0))
65#endif 63#endif
66 64
65/* In C++ we get problems because an explicit cast is needed from (void *)
66 * we use CHECKED_STACK_OF to ensure the correct type is passed in the macros
67 * below.
68 */
69
70#define CHECKED_STACK_OF(type, p) \
71 ((_STACK*) (1 ? p : (STACK_OF(type)*)0))
72
67#define CHECKED_SK_FREE_FUNC(type, p) \ 73#define CHECKED_SK_FREE_FUNC(type, p) \
68 ((void (*)(void *)) ((1 ? p : (void (*)(type *))0))) 74 ((void (*)(void *)) ((1 ? p : (void (*)(type *))0)))
69 75
76#define CHECKED_SK_FREE_FUNC2(type, p) \
77 ((void (*)(void *)) ((1 ? p : (void (*)(type))0)))
78
70#define CHECKED_SK_CMP_FUNC(type, p) \ 79#define CHECKED_SK_CMP_FUNC(type, p) \
71 ((int (*)(const char * const *, const char * const *)) \ 80 ((int (*)(const void *, const void *)) \
72 ((1 ? p : (int (*)(const type * const *, const type * const *))0))) 81 ((1 ? p : (int (*)(const type * const *, const type * const *))0)))
73 82
74#define STACK_OF(type) struct stack_st_##type 83#define STACK_OF(type) struct stack_st_##type
@@ -77,11 +86,51 @@
77#define DECLARE_STACK_OF(type) \ 86#define DECLARE_STACK_OF(type) \
78STACK_OF(type) \ 87STACK_OF(type) \
79 { \ 88 { \
80 STACK stack; \ 89 _STACK stack; \
90 };
91#define DECLARE_SPECIAL_STACK_OF(type, type2) \
92STACK_OF(type) \
93 { \
94 _STACK stack; \
81 }; 95 };
82 96
83#define IMPLEMENT_STACK_OF(type) /* nada (obsolete in new safestack approach)*/ 97#define IMPLEMENT_STACK_OF(type) /* nada (obsolete in new safestack approach)*/
84 98
99
100/* Strings are special: normally an lhash entry will point to a single
101 * (somewhat) mutable object. In the case of strings:
102 *
103 * a) Instead of a single char, there is an array of chars, NUL-terminated.
104 * b) The string may have be immutable.
105 *
106 * So, they need their own declarations. Especially important for
107 * type-checking tools, such as Deputy.
108 *
109o * In practice, however, it appears to be hard to have a const
110 * string. For now, I'm settling for dealing with the fact it is a
111 * string at all.
112 */
113typedef char *OPENSSL_STRING;
114
115typedef const char *OPENSSL_CSTRING;
116
117/* Confusingly, LHASH_OF(STRING) deals with char ** throughout, but
118 * STACK_OF(STRING) is really more like STACK_OF(char), only, as
119 * mentioned above, instead of a single char each entry is a
120 * NUL-terminated array of chars. So, we have to implement STRING
121 * specially for STACK_OF. This is dealt with in the autogenerated
122 * macros below.
123 */
124
125DECLARE_SPECIAL_STACK_OF(OPENSSL_STRING, char)
126
127/* Similarly, we sometimes use a block of characters, NOT
128 * nul-terminated. These should also be distinguished from "normal"
129 * stacks. */
130
131typedef void *OPENSSL_BLOCK;
132DECLARE_SPECIAL_STACK_OF(OPENSSL_BLOCK, void)
133
85/* SKM_sk_... stack macros are internal to safestack.h: 134/* SKM_sk_... stack macros are internal to safestack.h:
86 * never use them directly, use sk_<type>_... instead */ 135 * never use them directly, use sk_<type>_... instead */
87#define SKM_sk_new(type, cmp) \ 136#define SKM_sk_new(type, cmp) \
@@ -89,52 +138,55 @@ STACK_OF(type) \
89#define SKM_sk_new_null(type) \ 138#define SKM_sk_new_null(type) \
90 ((STACK_OF(type) *)sk_new_null()) 139 ((STACK_OF(type) *)sk_new_null())
91#define SKM_sk_free(type, st) \ 140#define SKM_sk_free(type, st) \
92 sk_free(CHECKED_PTR_OF(STACK_OF(type), st)) 141 sk_free(CHECKED_STACK_OF(type, st))
93#define SKM_sk_num(type, st) \ 142#define SKM_sk_num(type, st) \
94 sk_num(CHECKED_PTR_OF(STACK_OF(type), st)) 143 sk_num(CHECKED_STACK_OF(type, st))
95#define SKM_sk_value(type, st,i) \ 144#define SKM_sk_value(type, st,i) \
96 ((type *)sk_value(CHECKED_PTR_OF(STACK_OF(type), st), i)) 145 ((type *)sk_value(CHECKED_STACK_OF(type, st), i))
97#define SKM_sk_set(type, st,i,val) \ 146#define SKM_sk_set(type, st,i,val) \
98 sk_set(CHECKED_PTR_OF(STACK_OF(type), st), i, CHECKED_PTR_OF(type, val)) 147 sk_set(CHECKED_STACK_OF(type, st), i, CHECKED_PTR_OF(type, val))
99#define SKM_sk_zero(type, st) \ 148#define SKM_sk_zero(type, st) \
100 sk_zero(CHECKED_PTR_OF(STACK_OF(type), st)) 149 sk_zero(CHECKED_STACK_OF(type, st))
101#define SKM_sk_push(type, st,val) \ 150#define SKM_sk_push(type, st, val) \
102 sk_push(CHECKED_PTR_OF(STACK_OF(type), st), CHECKED_PTR_OF(type, val)) 151 sk_push(CHECKED_STACK_OF(type, st), CHECKED_PTR_OF(type, val))
103#define SKM_sk_unshift(type, st,val) \ 152#define SKM_sk_unshift(type, st, val) \
104 sk_unshift(CHECKED_PTR_OF(STACK_OF(type), st), CHECKED_PTR_OF(type, val)) 153 sk_unshift(CHECKED_STACK_OF(type, st), CHECKED_PTR_OF(type, val))
105#define SKM_sk_find(type, st,val) \ 154#define SKM_sk_find(type, st, val) \
106 sk_find(CHECKED_PTR_OF(STACK_OF(type), st), CHECKED_PTR_OF(type, val)) 155 sk_find(CHECKED_STACK_OF(type, st), CHECKED_PTR_OF(type, val))
107#define SKM_sk_delete(type, st,i) \ 156#define SKM_sk_find_ex(type, st, val) \
108 (type *)sk_delete(CHECKED_PTR_OF(STACK_OF(type), st), i) 157 sk_find_ex(CHECKED_STACK_OF(type, st), \
109#define SKM_sk_delete_ptr(type, st,ptr) \ 158 CHECKED_PTR_OF(type, val))
110 (type *)sk_delete_ptr(CHECKED_PTR_OF(STACK_OF(type), st), CHECKED_PTR_OF(type, ptr)) 159#define SKM_sk_delete(type, st, i) \
111#define SKM_sk_insert(type, st,val,i) \ 160 (type *)sk_delete(CHECKED_STACK_OF(type, st), i)
112 sk_insert(CHECKED_PTR_OF(STACK_OF(type), st), CHECKED_PTR_OF(type, val), i) 161#define SKM_sk_delete_ptr(type, st, ptr) \
113#define SKM_sk_set_cmp_func(type, st,cmp) \ 162 (type *)sk_delete_ptr(CHECKED_STACK_OF(type, st), CHECKED_PTR_OF(type, ptr))
163#define SKM_sk_insert(type, st,val, i) \
164 sk_insert(CHECKED_STACK_OF(type, st), CHECKED_PTR_OF(type, val), i)
165#define SKM_sk_set_cmp_func(type, st, cmp) \
114 ((int (*)(const type * const *,const type * const *)) \ 166 ((int (*)(const type * const *,const type * const *)) \
115 sk_set_cmp_func(CHECKED_PTR_OF(STACK_OF(type), st), CHECKED_SK_CMP_FUNC(type, cmp))) 167 sk_set_cmp_func(CHECKED_STACK_OF(type, st), CHECKED_SK_CMP_FUNC(type, cmp)))
116#define SKM_sk_dup(type, st) \ 168#define SKM_sk_dup(type, st) \
117 (STACK_OF(type) *)sk_dup(CHECKED_PTR_OF(STACK_OF(type), st)) 169 (STACK_OF(type) *)sk_dup(CHECKED_STACK_OF(type, st))
118#define SKM_sk_pop_free(type, st,free_func) \ 170#define SKM_sk_pop_free(type, st, free_func) \
119 sk_pop_free(CHECKED_PTR_OF(STACK_OF(type), st), CHECKED_SK_FREE_FUNC(type, free_func)) 171 sk_pop_free(CHECKED_STACK_OF(type, st), CHECKED_SK_FREE_FUNC(type, free_func))
120#define SKM_sk_shift(type, st) \ 172#define SKM_sk_shift(type, st) \
121 (type *)sk_shift(CHECKED_PTR_OF(STACK_OF(type), st)) 173 (type *)sk_shift(CHECKED_STACK_OF(type, st))
122#define SKM_sk_pop(type, st) \ 174#define SKM_sk_pop(type, st) \
123 (type *)sk_pop(CHECKED_PTR_OF(STACK_OF(type), st)) 175 (type *)sk_pop(CHECKED_STACK_OF(type, st))
124#define SKM_sk_sort(type, st) \ 176#define SKM_sk_sort(type, st) \
125 sk_sort(CHECKED_PTR_OF(STACK_OF(type), st)) 177 sk_sort(CHECKED_STACK_OF(type, st))
126#define SKM_sk_is_sorted(type, st) \ 178#define SKM_sk_is_sorted(type, st) \
127 sk_is_sorted(CHECKED_PTR_OF(STACK_OF(type), st)) 179 sk_is_sorted(CHECKED_STACK_OF(type, st))
128 180
129#define SKM_ASN1_SET_OF_d2i(type, st, pp, length, d2i_func, free_func, ex_tag, ex_class) \ 181#define SKM_ASN1_SET_OF_d2i(type, st, pp, length, d2i_func, free_func, ex_tag, ex_class) \
130 (STACK_OF(type) *)d2i_ASN1_SET(CHECKED_PTR_OF(STACK_OF(type), st), \ 182 (STACK_OF(type) *)d2i_ASN1_SET((STACK_OF(OPENSSL_BLOCK) **)CHECKED_STACK_OF(type, st), \
131 pp, length, \ 183 pp, length, \
132 CHECKED_D2I_OF(type, d2i_func), \ 184 CHECKED_D2I_OF(type, d2i_func), \
133 CHECKED_SK_FREE_FUNC(type, free_func), \ 185 CHECKED_SK_FREE_FUNC(type, free_func), \
134 ex_tag, ex_class) 186 ex_tag, ex_class)
135 187
136#define SKM_ASN1_SET_OF_i2d(type, st, pp, i2d_func, ex_tag, ex_class, is_set) \ 188#define SKM_ASN1_SET_OF_i2d(type, st, pp, i2d_func, ex_tag, ex_class, is_set) \
137 i2d_ASN1_SET(CHECKED_PTR_OF(STACK_OF(type), st), pp, \ 189 i2d_ASN1_SET((STACK_OF(OPENSSL_BLOCK) *)CHECKED_STACK_OF(type, st), pp, \
138 CHECKED_I2D_OF(type, i2d_func), \ 190 CHECKED_I2D_OF(type, i2d_func), \
139 ex_tag, ex_class, is_set) 191 ex_tag, ex_class, is_set)
140 192
@@ -151,72 +203,8 @@ STACK_OF(type) \
151 CHECKED_SK_FREE_FUNC(type, free_func), \ 203 CHECKED_SK_FREE_FUNC(type, free_func), \
152 pass, passlen, oct, seq) 204 pass, passlen, oct, seq)
153 205
154#else
155
156#define STACK_OF(type) STACK
157#define PREDECLARE_STACK_OF(type) /* nada */
158#define DECLARE_STACK_OF(type) /* nada */
159#define IMPLEMENT_STACK_OF(type) /* nada */
160
161#define SKM_sk_new(type, cmp) \
162 sk_new((int (*)(const char * const *, const char * const *))(cmp))
163#define SKM_sk_new_null(type) \
164 sk_new_null()
165#define SKM_sk_free(type, st) \
166 sk_free(st)
167#define SKM_sk_num(type, st) \
168 sk_num(st)
169#define SKM_sk_value(type, st,i) \
170 ((type *)sk_value(st, i))
171#define SKM_sk_set(type, st,i,val) \
172 ((type *)sk_set(st, i,(char *)val))
173#define SKM_sk_zero(type, st) \
174 sk_zero(st)
175#define SKM_sk_push(type, st,val) \
176 sk_push(st, (char *)val)
177#define SKM_sk_unshift(type, st,val) \
178 sk_unshift(st, (char *)val)
179#define SKM_sk_find(type, st,val) \
180 sk_find(st, (char *)val)
181#define SKM_sk_delete(type, st,i) \
182 ((type *)sk_delete(st, i))
183#define SKM_sk_delete_ptr(type, st,ptr) \
184 ((type *)sk_delete_ptr(st,(char *)ptr))
185#define SKM_sk_insert(type, st,val,i) \
186 sk_insert(st, (char *)val, i)
187#define SKM_sk_set_cmp_func(type, st,cmp) \
188 ((int (*)(const type * const *,const type * const *)) \
189 sk_set_cmp_func(st, (int (*)(const char * const *, const char * const *))(cmp)))
190#define SKM_sk_dup(type, st) \
191 sk_dup(st)
192#define SKM_sk_pop_free(type, st,free_func) \
193 sk_pop_free(st, (void (*)(void *))free_func)
194#define SKM_sk_shift(type, st) \
195 ((type *)sk_shift(st))
196#define SKM_sk_pop(type, st) \
197 ((type *)sk_pop(st))
198#define SKM_sk_sort(type, st) \
199 sk_sort(st)
200#define SKM_sk_is_sorted(type, st) \
201 sk_is_sorted(st)
202
203#define SKM_ASN1_SET_OF_d2i(type, st, pp, length, d2i_func, free_func, ex_tag, ex_class) \
204 d2i_ASN1_SET(st,pp,length, (void *(*)(void ** ,const unsigned char ** ,long))d2i_func, (void (*)(void *))free_func, ex_tag,ex_class)
205#define SKM_ASN1_SET_OF_i2d(type, st, pp, i2d_func, ex_tag, ex_class, is_set) \
206 i2d_ASN1_SET(st,pp,(int (*)(void *, unsigned char **))i2d_func,ex_tag,ex_class,is_set)
207
208#define SKM_ASN1_seq_pack(type, st, i2d_func, buf, len) \
209 ASN1_seq_pack(st, (int (*)(void *, unsigned char **))i2d_func, buf, len)
210#define SKM_ASN1_seq_unpack(type, buf, len, d2i_func, free_func) \
211 ASN1_seq_unpack(buf,len,(void *(*)(void **,const unsigned char **,long))d2i_func, (void(*)(void *))free_func)
212
213#define SKM_PKCS12_decrypt_d2i(type, algor, d2i_func, free_func, pass, passlen, oct, seq) \
214 ((STACK *)PKCS12_decrypt_d2i(algor,(char *(*)())d2i_func, (void(*)(void *))free_func,pass,passlen,oct,seq))
215
216#endif
217
218/* This block of defines is updated by util/mkstack.pl, please do not touch! */ 206/* This block of defines is updated by util/mkstack.pl, please do not touch! */
219#define sk_ACCESS_DESCRIPTION_new(st) SKM_sk_new(ACCESS_DESCRIPTION, (st)) 207#define sk_ACCESS_DESCRIPTION_new(cmp) SKM_sk_new(ACCESS_DESCRIPTION, (cmp))
220#define sk_ACCESS_DESCRIPTION_new_null() SKM_sk_new_null(ACCESS_DESCRIPTION) 208#define sk_ACCESS_DESCRIPTION_new_null() SKM_sk_new_null(ACCESS_DESCRIPTION)
221#define sk_ACCESS_DESCRIPTION_free(st) SKM_sk_free(ACCESS_DESCRIPTION, (st)) 209#define sk_ACCESS_DESCRIPTION_free(st) SKM_sk_free(ACCESS_DESCRIPTION, (st))
222#define sk_ACCESS_DESCRIPTION_num(st) SKM_sk_num(ACCESS_DESCRIPTION, (st)) 210#define sk_ACCESS_DESCRIPTION_num(st) SKM_sk_num(ACCESS_DESCRIPTION, (st))
@@ -238,7 +226,7 @@ STACK_OF(type) \
238#define sk_ACCESS_DESCRIPTION_sort(st) SKM_sk_sort(ACCESS_DESCRIPTION, (st)) 226#define sk_ACCESS_DESCRIPTION_sort(st) SKM_sk_sort(ACCESS_DESCRIPTION, (st))
239#define sk_ACCESS_DESCRIPTION_is_sorted(st) SKM_sk_is_sorted(ACCESS_DESCRIPTION, (st)) 227#define sk_ACCESS_DESCRIPTION_is_sorted(st) SKM_sk_is_sorted(ACCESS_DESCRIPTION, (st))
240 228
241#define sk_ASIdOrRange_new(st) SKM_sk_new(ASIdOrRange, (st)) 229#define sk_ASIdOrRange_new(cmp) SKM_sk_new(ASIdOrRange, (cmp))
242#define sk_ASIdOrRange_new_null() SKM_sk_new_null(ASIdOrRange) 230#define sk_ASIdOrRange_new_null() SKM_sk_new_null(ASIdOrRange)
243#define sk_ASIdOrRange_free(st) SKM_sk_free(ASIdOrRange, (st)) 231#define sk_ASIdOrRange_free(st) SKM_sk_free(ASIdOrRange, (st))
244#define sk_ASIdOrRange_num(st) SKM_sk_num(ASIdOrRange, (st)) 232#define sk_ASIdOrRange_num(st) SKM_sk_num(ASIdOrRange, (st))
@@ -260,7 +248,7 @@ STACK_OF(type) \
260#define sk_ASIdOrRange_sort(st) SKM_sk_sort(ASIdOrRange, (st)) 248#define sk_ASIdOrRange_sort(st) SKM_sk_sort(ASIdOrRange, (st))
261#define sk_ASIdOrRange_is_sorted(st) SKM_sk_is_sorted(ASIdOrRange, (st)) 249#define sk_ASIdOrRange_is_sorted(st) SKM_sk_is_sorted(ASIdOrRange, (st))
262 250
263#define sk_ASN1_GENERALSTRING_new(st) SKM_sk_new(ASN1_GENERALSTRING, (st)) 251#define sk_ASN1_GENERALSTRING_new(cmp) SKM_sk_new(ASN1_GENERALSTRING, (cmp))
264#define sk_ASN1_GENERALSTRING_new_null() SKM_sk_new_null(ASN1_GENERALSTRING) 252#define sk_ASN1_GENERALSTRING_new_null() SKM_sk_new_null(ASN1_GENERALSTRING)
265#define sk_ASN1_GENERALSTRING_free(st) SKM_sk_free(ASN1_GENERALSTRING, (st)) 253#define sk_ASN1_GENERALSTRING_free(st) SKM_sk_free(ASN1_GENERALSTRING, (st))
266#define sk_ASN1_GENERALSTRING_num(st) SKM_sk_num(ASN1_GENERALSTRING, (st)) 254#define sk_ASN1_GENERALSTRING_num(st) SKM_sk_num(ASN1_GENERALSTRING, (st))
@@ -282,7 +270,7 @@ STACK_OF(type) \
282#define sk_ASN1_GENERALSTRING_sort(st) SKM_sk_sort(ASN1_GENERALSTRING, (st)) 270#define sk_ASN1_GENERALSTRING_sort(st) SKM_sk_sort(ASN1_GENERALSTRING, (st))
283#define sk_ASN1_GENERALSTRING_is_sorted(st) SKM_sk_is_sorted(ASN1_GENERALSTRING, (st)) 271#define sk_ASN1_GENERALSTRING_is_sorted(st) SKM_sk_is_sorted(ASN1_GENERALSTRING, (st))
284 272
285#define sk_ASN1_INTEGER_new(st) SKM_sk_new(ASN1_INTEGER, (st)) 273#define sk_ASN1_INTEGER_new(cmp) SKM_sk_new(ASN1_INTEGER, (cmp))
286#define sk_ASN1_INTEGER_new_null() SKM_sk_new_null(ASN1_INTEGER) 274#define sk_ASN1_INTEGER_new_null() SKM_sk_new_null(ASN1_INTEGER)
287#define sk_ASN1_INTEGER_free(st) SKM_sk_free(ASN1_INTEGER, (st)) 275#define sk_ASN1_INTEGER_free(st) SKM_sk_free(ASN1_INTEGER, (st))
288#define sk_ASN1_INTEGER_num(st) SKM_sk_num(ASN1_INTEGER, (st)) 276#define sk_ASN1_INTEGER_num(st) SKM_sk_num(ASN1_INTEGER, (st))
@@ -304,7 +292,7 @@ STACK_OF(type) \
304#define sk_ASN1_INTEGER_sort(st) SKM_sk_sort(ASN1_INTEGER, (st)) 292#define sk_ASN1_INTEGER_sort(st) SKM_sk_sort(ASN1_INTEGER, (st))
305#define sk_ASN1_INTEGER_is_sorted(st) SKM_sk_is_sorted(ASN1_INTEGER, (st)) 293#define sk_ASN1_INTEGER_is_sorted(st) SKM_sk_is_sorted(ASN1_INTEGER, (st))
306 294
307#define sk_ASN1_OBJECT_new(st) SKM_sk_new(ASN1_OBJECT, (st)) 295#define sk_ASN1_OBJECT_new(cmp) SKM_sk_new(ASN1_OBJECT, (cmp))
308#define sk_ASN1_OBJECT_new_null() SKM_sk_new_null(ASN1_OBJECT) 296#define sk_ASN1_OBJECT_new_null() SKM_sk_new_null(ASN1_OBJECT)
309#define sk_ASN1_OBJECT_free(st) SKM_sk_free(ASN1_OBJECT, (st)) 297#define sk_ASN1_OBJECT_free(st) SKM_sk_free(ASN1_OBJECT, (st))
310#define sk_ASN1_OBJECT_num(st) SKM_sk_num(ASN1_OBJECT, (st)) 298#define sk_ASN1_OBJECT_num(st) SKM_sk_num(ASN1_OBJECT, (st))
@@ -326,7 +314,7 @@ STACK_OF(type) \
326#define sk_ASN1_OBJECT_sort(st) SKM_sk_sort(ASN1_OBJECT, (st)) 314#define sk_ASN1_OBJECT_sort(st) SKM_sk_sort(ASN1_OBJECT, (st))
327#define sk_ASN1_OBJECT_is_sorted(st) SKM_sk_is_sorted(ASN1_OBJECT, (st)) 315#define sk_ASN1_OBJECT_is_sorted(st) SKM_sk_is_sorted(ASN1_OBJECT, (st))
328 316
329#define sk_ASN1_STRING_TABLE_new(st) SKM_sk_new(ASN1_STRING_TABLE, (st)) 317#define sk_ASN1_STRING_TABLE_new(cmp) SKM_sk_new(ASN1_STRING_TABLE, (cmp))
330#define sk_ASN1_STRING_TABLE_new_null() SKM_sk_new_null(ASN1_STRING_TABLE) 318#define sk_ASN1_STRING_TABLE_new_null() SKM_sk_new_null(ASN1_STRING_TABLE)
331#define sk_ASN1_STRING_TABLE_free(st) SKM_sk_free(ASN1_STRING_TABLE, (st)) 319#define sk_ASN1_STRING_TABLE_free(st) SKM_sk_free(ASN1_STRING_TABLE, (st))
332#define sk_ASN1_STRING_TABLE_num(st) SKM_sk_num(ASN1_STRING_TABLE, (st)) 320#define sk_ASN1_STRING_TABLE_num(st) SKM_sk_num(ASN1_STRING_TABLE, (st))
@@ -348,7 +336,7 @@ STACK_OF(type) \
348#define sk_ASN1_STRING_TABLE_sort(st) SKM_sk_sort(ASN1_STRING_TABLE, (st)) 336#define sk_ASN1_STRING_TABLE_sort(st) SKM_sk_sort(ASN1_STRING_TABLE, (st))
349#define sk_ASN1_STRING_TABLE_is_sorted(st) SKM_sk_is_sorted(ASN1_STRING_TABLE, (st)) 337#define sk_ASN1_STRING_TABLE_is_sorted(st) SKM_sk_is_sorted(ASN1_STRING_TABLE, (st))
350 338
351#define sk_ASN1_TYPE_new(st) SKM_sk_new(ASN1_TYPE, (st)) 339#define sk_ASN1_TYPE_new(cmp) SKM_sk_new(ASN1_TYPE, (cmp))
352#define sk_ASN1_TYPE_new_null() SKM_sk_new_null(ASN1_TYPE) 340#define sk_ASN1_TYPE_new_null() SKM_sk_new_null(ASN1_TYPE)
353#define sk_ASN1_TYPE_free(st) SKM_sk_free(ASN1_TYPE, (st)) 341#define sk_ASN1_TYPE_free(st) SKM_sk_free(ASN1_TYPE, (st))
354#define sk_ASN1_TYPE_num(st) SKM_sk_num(ASN1_TYPE, (st)) 342#define sk_ASN1_TYPE_num(st) SKM_sk_num(ASN1_TYPE, (st))
@@ -370,7 +358,29 @@ STACK_OF(type) \
370#define sk_ASN1_TYPE_sort(st) SKM_sk_sort(ASN1_TYPE, (st)) 358#define sk_ASN1_TYPE_sort(st) SKM_sk_sort(ASN1_TYPE, (st))
371#define sk_ASN1_TYPE_is_sorted(st) SKM_sk_is_sorted(ASN1_TYPE, (st)) 359#define sk_ASN1_TYPE_is_sorted(st) SKM_sk_is_sorted(ASN1_TYPE, (st))
372 360
373#define sk_ASN1_VALUE_new(st) SKM_sk_new(ASN1_VALUE, (st)) 361#define sk_ASN1_UTF8STRING_new(cmp) SKM_sk_new(ASN1_UTF8STRING, (cmp))
362#define sk_ASN1_UTF8STRING_new_null() SKM_sk_new_null(ASN1_UTF8STRING)
363#define sk_ASN1_UTF8STRING_free(st) SKM_sk_free(ASN1_UTF8STRING, (st))
364#define sk_ASN1_UTF8STRING_num(st) SKM_sk_num(ASN1_UTF8STRING, (st))
365#define sk_ASN1_UTF8STRING_value(st, i) SKM_sk_value(ASN1_UTF8STRING, (st), (i))
366#define sk_ASN1_UTF8STRING_set(st, i, val) SKM_sk_set(ASN1_UTF8STRING, (st), (i), (val))
367#define sk_ASN1_UTF8STRING_zero(st) SKM_sk_zero(ASN1_UTF8STRING, (st))
368#define sk_ASN1_UTF8STRING_push(st, val) SKM_sk_push(ASN1_UTF8STRING, (st), (val))
369#define sk_ASN1_UTF8STRING_unshift(st, val) SKM_sk_unshift(ASN1_UTF8STRING, (st), (val))
370#define sk_ASN1_UTF8STRING_find(st, val) SKM_sk_find(ASN1_UTF8STRING, (st), (val))
371#define sk_ASN1_UTF8STRING_find_ex(st, val) SKM_sk_find_ex(ASN1_UTF8STRING, (st), (val))
372#define sk_ASN1_UTF8STRING_delete(st, i) SKM_sk_delete(ASN1_UTF8STRING, (st), (i))
373#define sk_ASN1_UTF8STRING_delete_ptr(st, ptr) SKM_sk_delete_ptr(ASN1_UTF8STRING, (st), (ptr))
374#define sk_ASN1_UTF8STRING_insert(st, val, i) SKM_sk_insert(ASN1_UTF8STRING, (st), (val), (i))
375#define sk_ASN1_UTF8STRING_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(ASN1_UTF8STRING, (st), (cmp))
376#define sk_ASN1_UTF8STRING_dup(st) SKM_sk_dup(ASN1_UTF8STRING, st)
377#define sk_ASN1_UTF8STRING_pop_free(st, free_func) SKM_sk_pop_free(ASN1_UTF8STRING, (st), (free_func))
378#define sk_ASN1_UTF8STRING_shift(st) SKM_sk_shift(ASN1_UTF8STRING, (st))
379#define sk_ASN1_UTF8STRING_pop(st) SKM_sk_pop(ASN1_UTF8STRING, (st))
380#define sk_ASN1_UTF8STRING_sort(st) SKM_sk_sort(ASN1_UTF8STRING, (st))
381#define sk_ASN1_UTF8STRING_is_sorted(st) SKM_sk_is_sorted(ASN1_UTF8STRING, (st))
382
383#define sk_ASN1_VALUE_new(cmp) SKM_sk_new(ASN1_VALUE, (cmp))
374#define sk_ASN1_VALUE_new_null() SKM_sk_new_null(ASN1_VALUE) 384#define sk_ASN1_VALUE_new_null() SKM_sk_new_null(ASN1_VALUE)
375#define sk_ASN1_VALUE_free(st) SKM_sk_free(ASN1_VALUE, (st)) 385#define sk_ASN1_VALUE_free(st) SKM_sk_free(ASN1_VALUE, (st))
376#define sk_ASN1_VALUE_num(st) SKM_sk_num(ASN1_VALUE, (st)) 386#define sk_ASN1_VALUE_num(st) SKM_sk_num(ASN1_VALUE, (st))
@@ -392,7 +402,7 @@ STACK_OF(type) \
392#define sk_ASN1_VALUE_sort(st) SKM_sk_sort(ASN1_VALUE, (st)) 402#define sk_ASN1_VALUE_sort(st) SKM_sk_sort(ASN1_VALUE, (st))
393#define sk_ASN1_VALUE_is_sorted(st) SKM_sk_is_sorted(ASN1_VALUE, (st)) 403#define sk_ASN1_VALUE_is_sorted(st) SKM_sk_is_sorted(ASN1_VALUE, (st))
394 404
395#define sk_BIO_new(st) SKM_sk_new(BIO, (st)) 405#define sk_BIO_new(cmp) SKM_sk_new(BIO, (cmp))
396#define sk_BIO_new_null() SKM_sk_new_null(BIO) 406#define sk_BIO_new_null() SKM_sk_new_null(BIO)
397#define sk_BIO_free(st) SKM_sk_free(BIO, (st)) 407#define sk_BIO_free(st) SKM_sk_free(BIO, (st))
398#define sk_BIO_num(st) SKM_sk_num(BIO, (st)) 408#define sk_BIO_num(st) SKM_sk_num(BIO, (st))
@@ -414,7 +424,51 @@ STACK_OF(type) \
414#define sk_BIO_sort(st) SKM_sk_sort(BIO, (st)) 424#define sk_BIO_sort(st) SKM_sk_sort(BIO, (st))
415#define sk_BIO_is_sorted(st) SKM_sk_is_sorted(BIO, (st)) 425#define sk_BIO_is_sorted(st) SKM_sk_is_sorted(BIO, (st))
416 426
417#define sk_CMS_CertificateChoices_new(st) SKM_sk_new(CMS_CertificateChoices, (st)) 427#define sk_BY_DIR_ENTRY_new(cmp) SKM_sk_new(BY_DIR_ENTRY, (cmp))
428#define sk_BY_DIR_ENTRY_new_null() SKM_sk_new_null(BY_DIR_ENTRY)
429#define sk_BY_DIR_ENTRY_free(st) SKM_sk_free(BY_DIR_ENTRY, (st))
430#define sk_BY_DIR_ENTRY_num(st) SKM_sk_num(BY_DIR_ENTRY, (st))
431#define sk_BY_DIR_ENTRY_value(st, i) SKM_sk_value(BY_DIR_ENTRY, (st), (i))
432#define sk_BY_DIR_ENTRY_set(st, i, val) SKM_sk_set(BY_DIR_ENTRY, (st), (i), (val))
433#define sk_BY_DIR_ENTRY_zero(st) SKM_sk_zero(BY_DIR_ENTRY, (st))
434#define sk_BY_DIR_ENTRY_push(st, val) SKM_sk_push(BY_DIR_ENTRY, (st), (val))
435#define sk_BY_DIR_ENTRY_unshift(st, val) SKM_sk_unshift(BY_DIR_ENTRY, (st), (val))
436#define sk_BY_DIR_ENTRY_find(st, val) SKM_sk_find(BY_DIR_ENTRY, (st), (val))
437#define sk_BY_DIR_ENTRY_find_ex(st, val) SKM_sk_find_ex(BY_DIR_ENTRY, (st), (val))
438#define sk_BY_DIR_ENTRY_delete(st, i) SKM_sk_delete(BY_DIR_ENTRY, (st), (i))
439#define sk_BY_DIR_ENTRY_delete_ptr(st, ptr) SKM_sk_delete_ptr(BY_DIR_ENTRY, (st), (ptr))
440#define sk_BY_DIR_ENTRY_insert(st, val, i) SKM_sk_insert(BY_DIR_ENTRY, (st), (val), (i))
441#define sk_BY_DIR_ENTRY_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(BY_DIR_ENTRY, (st), (cmp))
442#define sk_BY_DIR_ENTRY_dup(st) SKM_sk_dup(BY_DIR_ENTRY, st)
443#define sk_BY_DIR_ENTRY_pop_free(st, free_func) SKM_sk_pop_free(BY_DIR_ENTRY, (st), (free_func))
444#define sk_BY_DIR_ENTRY_shift(st) SKM_sk_shift(BY_DIR_ENTRY, (st))
445#define sk_BY_DIR_ENTRY_pop(st) SKM_sk_pop(BY_DIR_ENTRY, (st))
446#define sk_BY_DIR_ENTRY_sort(st) SKM_sk_sort(BY_DIR_ENTRY, (st))
447#define sk_BY_DIR_ENTRY_is_sorted(st) SKM_sk_is_sorted(BY_DIR_ENTRY, (st))
448
449#define sk_BY_DIR_HASH_new(cmp) SKM_sk_new(BY_DIR_HASH, (cmp))
450#define sk_BY_DIR_HASH_new_null() SKM_sk_new_null(BY_DIR_HASH)
451#define sk_BY_DIR_HASH_free(st) SKM_sk_free(BY_DIR_HASH, (st))
452#define sk_BY_DIR_HASH_num(st) SKM_sk_num(BY_DIR_HASH, (st))
453#define sk_BY_DIR_HASH_value(st, i) SKM_sk_value(BY_DIR_HASH, (st), (i))
454#define sk_BY_DIR_HASH_set(st, i, val) SKM_sk_set(BY_DIR_HASH, (st), (i), (val))
455#define sk_BY_DIR_HASH_zero(st) SKM_sk_zero(BY_DIR_HASH, (st))
456#define sk_BY_DIR_HASH_push(st, val) SKM_sk_push(BY_DIR_HASH, (st), (val))
457#define sk_BY_DIR_HASH_unshift(st, val) SKM_sk_unshift(BY_DIR_HASH, (st), (val))
458#define sk_BY_DIR_HASH_find(st, val) SKM_sk_find(BY_DIR_HASH, (st), (val))
459#define sk_BY_DIR_HASH_find_ex(st, val) SKM_sk_find_ex(BY_DIR_HASH, (st), (val))
460#define sk_BY_DIR_HASH_delete(st, i) SKM_sk_delete(BY_DIR_HASH, (st), (i))
461#define sk_BY_DIR_HASH_delete_ptr(st, ptr) SKM_sk_delete_ptr(BY_DIR_HASH, (st), (ptr))
462#define sk_BY_DIR_HASH_insert(st, val, i) SKM_sk_insert(BY_DIR_HASH, (st), (val), (i))
463#define sk_BY_DIR_HASH_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(BY_DIR_HASH, (st), (cmp))
464#define sk_BY_DIR_HASH_dup(st) SKM_sk_dup(BY_DIR_HASH, st)
465#define sk_BY_DIR_HASH_pop_free(st, free_func) SKM_sk_pop_free(BY_DIR_HASH, (st), (free_func))
466#define sk_BY_DIR_HASH_shift(st) SKM_sk_shift(BY_DIR_HASH, (st))
467#define sk_BY_DIR_HASH_pop(st) SKM_sk_pop(BY_DIR_HASH, (st))
468#define sk_BY_DIR_HASH_sort(st) SKM_sk_sort(BY_DIR_HASH, (st))
469#define sk_BY_DIR_HASH_is_sorted(st) SKM_sk_is_sorted(BY_DIR_HASH, (st))
470
471#define sk_CMS_CertificateChoices_new(cmp) SKM_sk_new(CMS_CertificateChoices, (cmp))
418#define sk_CMS_CertificateChoices_new_null() SKM_sk_new_null(CMS_CertificateChoices) 472#define sk_CMS_CertificateChoices_new_null() SKM_sk_new_null(CMS_CertificateChoices)
419#define sk_CMS_CertificateChoices_free(st) SKM_sk_free(CMS_CertificateChoices, (st)) 473#define sk_CMS_CertificateChoices_free(st) SKM_sk_free(CMS_CertificateChoices, (st))
420#define sk_CMS_CertificateChoices_num(st) SKM_sk_num(CMS_CertificateChoices, (st)) 474#define sk_CMS_CertificateChoices_num(st) SKM_sk_num(CMS_CertificateChoices, (st))
@@ -436,7 +490,7 @@ STACK_OF(type) \
436#define sk_CMS_CertificateChoices_sort(st) SKM_sk_sort(CMS_CertificateChoices, (st)) 490#define sk_CMS_CertificateChoices_sort(st) SKM_sk_sort(CMS_CertificateChoices, (st))
437#define sk_CMS_CertificateChoices_is_sorted(st) SKM_sk_is_sorted(CMS_CertificateChoices, (st)) 491#define sk_CMS_CertificateChoices_is_sorted(st) SKM_sk_is_sorted(CMS_CertificateChoices, (st))
438 492
439#define sk_CMS_RecipientInfo_new(st) SKM_sk_new(CMS_RecipientInfo, (st)) 493#define sk_CMS_RecipientInfo_new(cmp) SKM_sk_new(CMS_RecipientInfo, (cmp))
440#define sk_CMS_RecipientInfo_new_null() SKM_sk_new_null(CMS_RecipientInfo) 494#define sk_CMS_RecipientInfo_new_null() SKM_sk_new_null(CMS_RecipientInfo)
441#define sk_CMS_RecipientInfo_free(st) SKM_sk_free(CMS_RecipientInfo, (st)) 495#define sk_CMS_RecipientInfo_free(st) SKM_sk_free(CMS_RecipientInfo, (st))
442#define sk_CMS_RecipientInfo_num(st) SKM_sk_num(CMS_RecipientInfo, (st)) 496#define sk_CMS_RecipientInfo_num(st) SKM_sk_num(CMS_RecipientInfo, (st))
@@ -458,7 +512,7 @@ STACK_OF(type) \
458#define sk_CMS_RecipientInfo_sort(st) SKM_sk_sort(CMS_RecipientInfo, (st)) 512#define sk_CMS_RecipientInfo_sort(st) SKM_sk_sort(CMS_RecipientInfo, (st))
459#define sk_CMS_RecipientInfo_is_sorted(st) SKM_sk_is_sorted(CMS_RecipientInfo, (st)) 513#define sk_CMS_RecipientInfo_is_sorted(st) SKM_sk_is_sorted(CMS_RecipientInfo, (st))
460 514
461#define sk_CMS_RevocationInfoChoice_new(st) SKM_sk_new(CMS_RevocationInfoChoice, (st)) 515#define sk_CMS_RevocationInfoChoice_new(cmp) SKM_sk_new(CMS_RevocationInfoChoice, (cmp))
462#define sk_CMS_RevocationInfoChoice_new_null() SKM_sk_new_null(CMS_RevocationInfoChoice) 516#define sk_CMS_RevocationInfoChoice_new_null() SKM_sk_new_null(CMS_RevocationInfoChoice)
463#define sk_CMS_RevocationInfoChoice_free(st) SKM_sk_free(CMS_RevocationInfoChoice, (st)) 517#define sk_CMS_RevocationInfoChoice_free(st) SKM_sk_free(CMS_RevocationInfoChoice, (st))
464#define sk_CMS_RevocationInfoChoice_num(st) SKM_sk_num(CMS_RevocationInfoChoice, (st)) 518#define sk_CMS_RevocationInfoChoice_num(st) SKM_sk_num(CMS_RevocationInfoChoice, (st))
@@ -480,7 +534,7 @@ STACK_OF(type) \
480#define sk_CMS_RevocationInfoChoice_sort(st) SKM_sk_sort(CMS_RevocationInfoChoice, (st)) 534#define sk_CMS_RevocationInfoChoice_sort(st) SKM_sk_sort(CMS_RevocationInfoChoice, (st))
481#define sk_CMS_RevocationInfoChoice_is_sorted(st) SKM_sk_is_sorted(CMS_RevocationInfoChoice, (st)) 535#define sk_CMS_RevocationInfoChoice_is_sorted(st) SKM_sk_is_sorted(CMS_RevocationInfoChoice, (st))
482 536
483#define sk_CMS_SignerInfo_new(st) SKM_sk_new(CMS_SignerInfo, (st)) 537#define sk_CMS_SignerInfo_new(cmp) SKM_sk_new(CMS_SignerInfo, (cmp))
484#define sk_CMS_SignerInfo_new_null() SKM_sk_new_null(CMS_SignerInfo) 538#define sk_CMS_SignerInfo_new_null() SKM_sk_new_null(CMS_SignerInfo)
485#define sk_CMS_SignerInfo_free(st) SKM_sk_free(CMS_SignerInfo, (st)) 539#define sk_CMS_SignerInfo_free(st) SKM_sk_free(CMS_SignerInfo, (st))
486#define sk_CMS_SignerInfo_num(st) SKM_sk_num(CMS_SignerInfo, (st)) 540#define sk_CMS_SignerInfo_num(st) SKM_sk_num(CMS_SignerInfo, (st))
@@ -502,7 +556,7 @@ STACK_OF(type) \
502#define sk_CMS_SignerInfo_sort(st) SKM_sk_sort(CMS_SignerInfo, (st)) 556#define sk_CMS_SignerInfo_sort(st) SKM_sk_sort(CMS_SignerInfo, (st))
503#define sk_CMS_SignerInfo_is_sorted(st) SKM_sk_is_sorted(CMS_SignerInfo, (st)) 557#define sk_CMS_SignerInfo_is_sorted(st) SKM_sk_is_sorted(CMS_SignerInfo, (st))
504 558
505#define sk_CONF_IMODULE_new(st) SKM_sk_new(CONF_IMODULE, (st)) 559#define sk_CONF_IMODULE_new(cmp) SKM_sk_new(CONF_IMODULE, (cmp))
506#define sk_CONF_IMODULE_new_null() SKM_sk_new_null(CONF_IMODULE) 560#define sk_CONF_IMODULE_new_null() SKM_sk_new_null(CONF_IMODULE)
507#define sk_CONF_IMODULE_free(st) SKM_sk_free(CONF_IMODULE, (st)) 561#define sk_CONF_IMODULE_free(st) SKM_sk_free(CONF_IMODULE, (st))
508#define sk_CONF_IMODULE_num(st) SKM_sk_num(CONF_IMODULE, (st)) 562#define sk_CONF_IMODULE_num(st) SKM_sk_num(CONF_IMODULE, (st))
@@ -524,7 +578,7 @@ STACK_OF(type) \
524#define sk_CONF_IMODULE_sort(st) SKM_sk_sort(CONF_IMODULE, (st)) 578#define sk_CONF_IMODULE_sort(st) SKM_sk_sort(CONF_IMODULE, (st))
525#define sk_CONF_IMODULE_is_sorted(st) SKM_sk_is_sorted(CONF_IMODULE, (st)) 579#define sk_CONF_IMODULE_is_sorted(st) SKM_sk_is_sorted(CONF_IMODULE, (st))
526 580
527#define sk_CONF_MODULE_new(st) SKM_sk_new(CONF_MODULE, (st)) 581#define sk_CONF_MODULE_new(cmp) SKM_sk_new(CONF_MODULE, (cmp))
528#define sk_CONF_MODULE_new_null() SKM_sk_new_null(CONF_MODULE) 582#define sk_CONF_MODULE_new_null() SKM_sk_new_null(CONF_MODULE)
529#define sk_CONF_MODULE_free(st) SKM_sk_free(CONF_MODULE, (st)) 583#define sk_CONF_MODULE_free(st) SKM_sk_free(CONF_MODULE, (st))
530#define sk_CONF_MODULE_num(st) SKM_sk_num(CONF_MODULE, (st)) 584#define sk_CONF_MODULE_num(st) SKM_sk_num(CONF_MODULE, (st))
@@ -546,7 +600,7 @@ STACK_OF(type) \
546#define sk_CONF_MODULE_sort(st) SKM_sk_sort(CONF_MODULE, (st)) 600#define sk_CONF_MODULE_sort(st) SKM_sk_sort(CONF_MODULE, (st))
547#define sk_CONF_MODULE_is_sorted(st) SKM_sk_is_sorted(CONF_MODULE, (st)) 601#define sk_CONF_MODULE_is_sorted(st) SKM_sk_is_sorted(CONF_MODULE, (st))
548 602
549#define sk_CONF_VALUE_new(st) SKM_sk_new(CONF_VALUE, (st)) 603#define sk_CONF_VALUE_new(cmp) SKM_sk_new(CONF_VALUE, (cmp))
550#define sk_CONF_VALUE_new_null() SKM_sk_new_null(CONF_VALUE) 604#define sk_CONF_VALUE_new_null() SKM_sk_new_null(CONF_VALUE)
551#define sk_CONF_VALUE_free(st) SKM_sk_free(CONF_VALUE, (st)) 605#define sk_CONF_VALUE_free(st) SKM_sk_free(CONF_VALUE, (st))
552#define sk_CONF_VALUE_num(st) SKM_sk_num(CONF_VALUE, (st)) 606#define sk_CONF_VALUE_num(st) SKM_sk_num(CONF_VALUE, (st))
@@ -568,7 +622,7 @@ STACK_OF(type) \
568#define sk_CONF_VALUE_sort(st) SKM_sk_sort(CONF_VALUE, (st)) 622#define sk_CONF_VALUE_sort(st) SKM_sk_sort(CONF_VALUE, (st))
569#define sk_CONF_VALUE_is_sorted(st) SKM_sk_is_sorted(CONF_VALUE, (st)) 623#define sk_CONF_VALUE_is_sorted(st) SKM_sk_is_sorted(CONF_VALUE, (st))
570 624
571#define sk_CRYPTO_EX_DATA_FUNCS_new(st) SKM_sk_new(CRYPTO_EX_DATA_FUNCS, (st)) 625#define sk_CRYPTO_EX_DATA_FUNCS_new(cmp) SKM_sk_new(CRYPTO_EX_DATA_FUNCS, (cmp))
572#define sk_CRYPTO_EX_DATA_FUNCS_new_null() SKM_sk_new_null(CRYPTO_EX_DATA_FUNCS) 626#define sk_CRYPTO_EX_DATA_FUNCS_new_null() SKM_sk_new_null(CRYPTO_EX_DATA_FUNCS)
573#define sk_CRYPTO_EX_DATA_FUNCS_free(st) SKM_sk_free(CRYPTO_EX_DATA_FUNCS, (st)) 627#define sk_CRYPTO_EX_DATA_FUNCS_free(st) SKM_sk_free(CRYPTO_EX_DATA_FUNCS, (st))
574#define sk_CRYPTO_EX_DATA_FUNCS_num(st) SKM_sk_num(CRYPTO_EX_DATA_FUNCS, (st)) 628#define sk_CRYPTO_EX_DATA_FUNCS_num(st) SKM_sk_num(CRYPTO_EX_DATA_FUNCS, (st))
@@ -590,7 +644,7 @@ STACK_OF(type) \
590#define sk_CRYPTO_EX_DATA_FUNCS_sort(st) SKM_sk_sort(CRYPTO_EX_DATA_FUNCS, (st)) 644#define sk_CRYPTO_EX_DATA_FUNCS_sort(st) SKM_sk_sort(CRYPTO_EX_DATA_FUNCS, (st))
591#define sk_CRYPTO_EX_DATA_FUNCS_is_sorted(st) SKM_sk_is_sorted(CRYPTO_EX_DATA_FUNCS, (st)) 645#define sk_CRYPTO_EX_DATA_FUNCS_is_sorted(st) SKM_sk_is_sorted(CRYPTO_EX_DATA_FUNCS, (st))
592 646
593#define sk_CRYPTO_dynlock_new(st) SKM_sk_new(CRYPTO_dynlock, (st)) 647#define sk_CRYPTO_dynlock_new(cmp) SKM_sk_new(CRYPTO_dynlock, (cmp))
594#define sk_CRYPTO_dynlock_new_null() SKM_sk_new_null(CRYPTO_dynlock) 648#define sk_CRYPTO_dynlock_new_null() SKM_sk_new_null(CRYPTO_dynlock)
595#define sk_CRYPTO_dynlock_free(st) SKM_sk_free(CRYPTO_dynlock, (st)) 649#define sk_CRYPTO_dynlock_free(st) SKM_sk_free(CRYPTO_dynlock, (st))
596#define sk_CRYPTO_dynlock_num(st) SKM_sk_num(CRYPTO_dynlock, (st)) 650#define sk_CRYPTO_dynlock_num(st) SKM_sk_num(CRYPTO_dynlock, (st))
@@ -612,7 +666,7 @@ STACK_OF(type) \
612#define sk_CRYPTO_dynlock_sort(st) SKM_sk_sort(CRYPTO_dynlock, (st)) 666#define sk_CRYPTO_dynlock_sort(st) SKM_sk_sort(CRYPTO_dynlock, (st))
613#define sk_CRYPTO_dynlock_is_sorted(st) SKM_sk_is_sorted(CRYPTO_dynlock, (st)) 667#define sk_CRYPTO_dynlock_is_sorted(st) SKM_sk_is_sorted(CRYPTO_dynlock, (st))
614 668
615#define sk_DIST_POINT_new(st) SKM_sk_new(DIST_POINT, (st)) 669#define sk_DIST_POINT_new(cmp) SKM_sk_new(DIST_POINT, (cmp))
616#define sk_DIST_POINT_new_null() SKM_sk_new_null(DIST_POINT) 670#define sk_DIST_POINT_new_null() SKM_sk_new_null(DIST_POINT)
617#define sk_DIST_POINT_free(st) SKM_sk_free(DIST_POINT, (st)) 671#define sk_DIST_POINT_free(st) SKM_sk_free(DIST_POINT, (st))
618#define sk_DIST_POINT_num(st) SKM_sk_num(DIST_POINT, (st)) 672#define sk_DIST_POINT_num(st) SKM_sk_num(DIST_POINT, (st))
@@ -634,7 +688,7 @@ STACK_OF(type) \
634#define sk_DIST_POINT_sort(st) SKM_sk_sort(DIST_POINT, (st)) 688#define sk_DIST_POINT_sort(st) SKM_sk_sort(DIST_POINT, (st))
635#define sk_DIST_POINT_is_sorted(st) SKM_sk_is_sorted(DIST_POINT, (st)) 689#define sk_DIST_POINT_is_sorted(st) SKM_sk_is_sorted(DIST_POINT, (st))
636 690
637#define sk_ENGINE_new(st) SKM_sk_new(ENGINE, (st)) 691#define sk_ENGINE_new(cmp) SKM_sk_new(ENGINE, (cmp))
638#define sk_ENGINE_new_null() SKM_sk_new_null(ENGINE) 692#define sk_ENGINE_new_null() SKM_sk_new_null(ENGINE)
639#define sk_ENGINE_free(st) SKM_sk_free(ENGINE, (st)) 693#define sk_ENGINE_free(st) SKM_sk_free(ENGINE, (st))
640#define sk_ENGINE_num(st) SKM_sk_num(ENGINE, (st)) 694#define sk_ENGINE_num(st) SKM_sk_num(ENGINE, (st))
@@ -656,7 +710,7 @@ STACK_OF(type) \
656#define sk_ENGINE_sort(st) SKM_sk_sort(ENGINE, (st)) 710#define sk_ENGINE_sort(st) SKM_sk_sort(ENGINE, (st))
657#define sk_ENGINE_is_sorted(st) SKM_sk_is_sorted(ENGINE, (st)) 711#define sk_ENGINE_is_sorted(st) SKM_sk_is_sorted(ENGINE, (st))
658 712
659#define sk_ENGINE_CLEANUP_ITEM_new(st) SKM_sk_new(ENGINE_CLEANUP_ITEM, (st)) 713#define sk_ENGINE_CLEANUP_ITEM_new(cmp) SKM_sk_new(ENGINE_CLEANUP_ITEM, (cmp))
660#define sk_ENGINE_CLEANUP_ITEM_new_null() SKM_sk_new_null(ENGINE_CLEANUP_ITEM) 714#define sk_ENGINE_CLEANUP_ITEM_new_null() SKM_sk_new_null(ENGINE_CLEANUP_ITEM)
661#define sk_ENGINE_CLEANUP_ITEM_free(st) SKM_sk_free(ENGINE_CLEANUP_ITEM, (st)) 715#define sk_ENGINE_CLEANUP_ITEM_free(st) SKM_sk_free(ENGINE_CLEANUP_ITEM, (st))
662#define sk_ENGINE_CLEANUP_ITEM_num(st) SKM_sk_num(ENGINE_CLEANUP_ITEM, (st)) 716#define sk_ENGINE_CLEANUP_ITEM_num(st) SKM_sk_num(ENGINE_CLEANUP_ITEM, (st))
@@ -678,7 +732,117 @@ STACK_OF(type) \
678#define sk_ENGINE_CLEANUP_ITEM_sort(st) SKM_sk_sort(ENGINE_CLEANUP_ITEM, (st)) 732#define sk_ENGINE_CLEANUP_ITEM_sort(st) SKM_sk_sort(ENGINE_CLEANUP_ITEM, (st))
679#define sk_ENGINE_CLEANUP_ITEM_is_sorted(st) SKM_sk_is_sorted(ENGINE_CLEANUP_ITEM, (st)) 733#define sk_ENGINE_CLEANUP_ITEM_is_sorted(st) SKM_sk_is_sorted(ENGINE_CLEANUP_ITEM, (st))
680 734
681#define sk_GENERAL_NAME_new(st) SKM_sk_new(GENERAL_NAME, (st)) 735#define sk_ESS_CERT_ID_new(cmp) SKM_sk_new(ESS_CERT_ID, (cmp))
736#define sk_ESS_CERT_ID_new_null() SKM_sk_new_null(ESS_CERT_ID)
737#define sk_ESS_CERT_ID_free(st) SKM_sk_free(ESS_CERT_ID, (st))
738#define sk_ESS_CERT_ID_num(st) SKM_sk_num(ESS_CERT_ID, (st))
739#define sk_ESS_CERT_ID_value(st, i) SKM_sk_value(ESS_CERT_ID, (st), (i))
740#define sk_ESS_CERT_ID_set(st, i, val) SKM_sk_set(ESS_CERT_ID, (st), (i), (val))
741#define sk_ESS_CERT_ID_zero(st) SKM_sk_zero(ESS_CERT_ID, (st))
742#define sk_ESS_CERT_ID_push(st, val) SKM_sk_push(ESS_CERT_ID, (st), (val))
743#define sk_ESS_CERT_ID_unshift(st, val) SKM_sk_unshift(ESS_CERT_ID, (st), (val))
744#define sk_ESS_CERT_ID_find(st, val) SKM_sk_find(ESS_CERT_ID, (st), (val))
745#define sk_ESS_CERT_ID_find_ex(st, val) SKM_sk_find_ex(ESS_CERT_ID, (st), (val))
746#define sk_ESS_CERT_ID_delete(st, i) SKM_sk_delete(ESS_CERT_ID, (st), (i))
747#define sk_ESS_CERT_ID_delete_ptr(st, ptr) SKM_sk_delete_ptr(ESS_CERT_ID, (st), (ptr))
748#define sk_ESS_CERT_ID_insert(st, val, i) SKM_sk_insert(ESS_CERT_ID, (st), (val), (i))
749#define sk_ESS_CERT_ID_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(ESS_CERT_ID, (st), (cmp))
750#define sk_ESS_CERT_ID_dup(st) SKM_sk_dup(ESS_CERT_ID, st)
751#define sk_ESS_CERT_ID_pop_free(st, free_func) SKM_sk_pop_free(ESS_CERT_ID, (st), (free_func))
752#define sk_ESS_CERT_ID_shift(st) SKM_sk_shift(ESS_CERT_ID, (st))
753#define sk_ESS_CERT_ID_pop(st) SKM_sk_pop(ESS_CERT_ID, (st))
754#define sk_ESS_CERT_ID_sort(st) SKM_sk_sort(ESS_CERT_ID, (st))
755#define sk_ESS_CERT_ID_is_sorted(st) SKM_sk_is_sorted(ESS_CERT_ID, (st))
756
757#define sk_EVP_MD_new(cmp) SKM_sk_new(EVP_MD, (cmp))
758#define sk_EVP_MD_new_null() SKM_sk_new_null(EVP_MD)
759#define sk_EVP_MD_free(st) SKM_sk_free(EVP_MD, (st))
760#define sk_EVP_MD_num(st) SKM_sk_num(EVP_MD, (st))
761#define sk_EVP_MD_value(st, i) SKM_sk_value(EVP_MD, (st), (i))
762#define sk_EVP_MD_set(st, i, val) SKM_sk_set(EVP_MD, (st), (i), (val))
763#define sk_EVP_MD_zero(st) SKM_sk_zero(EVP_MD, (st))
764#define sk_EVP_MD_push(st, val) SKM_sk_push(EVP_MD, (st), (val))
765#define sk_EVP_MD_unshift(st, val) SKM_sk_unshift(EVP_MD, (st), (val))
766#define sk_EVP_MD_find(st, val) SKM_sk_find(EVP_MD, (st), (val))
767#define sk_EVP_MD_find_ex(st, val) SKM_sk_find_ex(EVP_MD, (st), (val))
768#define sk_EVP_MD_delete(st, i) SKM_sk_delete(EVP_MD, (st), (i))
769#define sk_EVP_MD_delete_ptr(st, ptr) SKM_sk_delete_ptr(EVP_MD, (st), (ptr))
770#define sk_EVP_MD_insert(st, val, i) SKM_sk_insert(EVP_MD, (st), (val), (i))
771#define sk_EVP_MD_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(EVP_MD, (st), (cmp))
772#define sk_EVP_MD_dup(st) SKM_sk_dup(EVP_MD, st)
773#define sk_EVP_MD_pop_free(st, free_func) SKM_sk_pop_free(EVP_MD, (st), (free_func))
774#define sk_EVP_MD_shift(st) SKM_sk_shift(EVP_MD, (st))
775#define sk_EVP_MD_pop(st) SKM_sk_pop(EVP_MD, (st))
776#define sk_EVP_MD_sort(st) SKM_sk_sort(EVP_MD, (st))
777#define sk_EVP_MD_is_sorted(st) SKM_sk_is_sorted(EVP_MD, (st))
778
779#define sk_EVP_PBE_CTL_new(cmp) SKM_sk_new(EVP_PBE_CTL, (cmp))
780#define sk_EVP_PBE_CTL_new_null() SKM_sk_new_null(EVP_PBE_CTL)
781#define sk_EVP_PBE_CTL_free(st) SKM_sk_free(EVP_PBE_CTL, (st))
782#define sk_EVP_PBE_CTL_num(st) SKM_sk_num(EVP_PBE_CTL, (st))
783#define sk_EVP_PBE_CTL_value(st, i) SKM_sk_value(EVP_PBE_CTL, (st), (i))
784#define sk_EVP_PBE_CTL_set(st, i, val) SKM_sk_set(EVP_PBE_CTL, (st), (i), (val))
785#define sk_EVP_PBE_CTL_zero(st) SKM_sk_zero(EVP_PBE_CTL, (st))
786#define sk_EVP_PBE_CTL_push(st, val) SKM_sk_push(EVP_PBE_CTL, (st), (val))
787#define sk_EVP_PBE_CTL_unshift(st, val) SKM_sk_unshift(EVP_PBE_CTL, (st), (val))
788#define sk_EVP_PBE_CTL_find(st, val) SKM_sk_find(EVP_PBE_CTL, (st), (val))
789#define sk_EVP_PBE_CTL_find_ex(st, val) SKM_sk_find_ex(EVP_PBE_CTL, (st), (val))
790#define sk_EVP_PBE_CTL_delete(st, i) SKM_sk_delete(EVP_PBE_CTL, (st), (i))
791#define sk_EVP_PBE_CTL_delete_ptr(st, ptr) SKM_sk_delete_ptr(EVP_PBE_CTL, (st), (ptr))
792#define sk_EVP_PBE_CTL_insert(st, val, i) SKM_sk_insert(EVP_PBE_CTL, (st), (val), (i))
793#define sk_EVP_PBE_CTL_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(EVP_PBE_CTL, (st), (cmp))
794#define sk_EVP_PBE_CTL_dup(st) SKM_sk_dup(EVP_PBE_CTL, st)
795#define sk_EVP_PBE_CTL_pop_free(st, free_func) SKM_sk_pop_free(EVP_PBE_CTL, (st), (free_func))
796#define sk_EVP_PBE_CTL_shift(st) SKM_sk_shift(EVP_PBE_CTL, (st))
797#define sk_EVP_PBE_CTL_pop(st) SKM_sk_pop(EVP_PBE_CTL, (st))
798#define sk_EVP_PBE_CTL_sort(st) SKM_sk_sort(EVP_PBE_CTL, (st))
799#define sk_EVP_PBE_CTL_is_sorted(st) SKM_sk_is_sorted(EVP_PBE_CTL, (st))
800
801#define sk_EVP_PKEY_ASN1_METHOD_new(cmp) SKM_sk_new(EVP_PKEY_ASN1_METHOD, (cmp))
802#define sk_EVP_PKEY_ASN1_METHOD_new_null() SKM_sk_new_null(EVP_PKEY_ASN1_METHOD)
803#define sk_EVP_PKEY_ASN1_METHOD_free(st) SKM_sk_free(EVP_PKEY_ASN1_METHOD, (st))
804#define sk_EVP_PKEY_ASN1_METHOD_num(st) SKM_sk_num(EVP_PKEY_ASN1_METHOD, (st))
805#define sk_EVP_PKEY_ASN1_METHOD_value(st, i) SKM_sk_value(EVP_PKEY_ASN1_METHOD, (st), (i))
806#define sk_EVP_PKEY_ASN1_METHOD_set(st, i, val) SKM_sk_set(EVP_PKEY_ASN1_METHOD, (st), (i), (val))
807#define sk_EVP_PKEY_ASN1_METHOD_zero(st) SKM_sk_zero(EVP_PKEY_ASN1_METHOD, (st))
808#define sk_EVP_PKEY_ASN1_METHOD_push(st, val) SKM_sk_push(EVP_PKEY_ASN1_METHOD, (st), (val))
809#define sk_EVP_PKEY_ASN1_METHOD_unshift(st, val) SKM_sk_unshift(EVP_PKEY_ASN1_METHOD, (st), (val))
810#define sk_EVP_PKEY_ASN1_METHOD_find(st, val) SKM_sk_find(EVP_PKEY_ASN1_METHOD, (st), (val))
811#define sk_EVP_PKEY_ASN1_METHOD_find_ex(st, val) SKM_sk_find_ex(EVP_PKEY_ASN1_METHOD, (st), (val))
812#define sk_EVP_PKEY_ASN1_METHOD_delete(st, i) SKM_sk_delete(EVP_PKEY_ASN1_METHOD, (st), (i))
813#define sk_EVP_PKEY_ASN1_METHOD_delete_ptr(st, ptr) SKM_sk_delete_ptr(EVP_PKEY_ASN1_METHOD, (st), (ptr))
814#define sk_EVP_PKEY_ASN1_METHOD_insert(st, val, i) SKM_sk_insert(EVP_PKEY_ASN1_METHOD, (st), (val), (i))
815#define sk_EVP_PKEY_ASN1_METHOD_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(EVP_PKEY_ASN1_METHOD, (st), (cmp))
816#define sk_EVP_PKEY_ASN1_METHOD_dup(st) SKM_sk_dup(EVP_PKEY_ASN1_METHOD, st)
817#define sk_EVP_PKEY_ASN1_METHOD_pop_free(st, free_func) SKM_sk_pop_free(EVP_PKEY_ASN1_METHOD, (st), (free_func))
818#define sk_EVP_PKEY_ASN1_METHOD_shift(st) SKM_sk_shift(EVP_PKEY_ASN1_METHOD, (st))
819#define sk_EVP_PKEY_ASN1_METHOD_pop(st) SKM_sk_pop(EVP_PKEY_ASN1_METHOD, (st))
820#define sk_EVP_PKEY_ASN1_METHOD_sort(st) SKM_sk_sort(EVP_PKEY_ASN1_METHOD, (st))
821#define sk_EVP_PKEY_ASN1_METHOD_is_sorted(st) SKM_sk_is_sorted(EVP_PKEY_ASN1_METHOD, (st))
822
823#define sk_EVP_PKEY_METHOD_new(cmp) SKM_sk_new(EVP_PKEY_METHOD, (cmp))
824#define sk_EVP_PKEY_METHOD_new_null() SKM_sk_new_null(EVP_PKEY_METHOD)
825#define sk_EVP_PKEY_METHOD_free(st) SKM_sk_free(EVP_PKEY_METHOD, (st))
826#define sk_EVP_PKEY_METHOD_num(st) SKM_sk_num(EVP_PKEY_METHOD, (st))
827#define sk_EVP_PKEY_METHOD_value(st, i) SKM_sk_value(EVP_PKEY_METHOD, (st), (i))
828#define sk_EVP_PKEY_METHOD_set(st, i, val) SKM_sk_set(EVP_PKEY_METHOD, (st), (i), (val))
829#define sk_EVP_PKEY_METHOD_zero(st) SKM_sk_zero(EVP_PKEY_METHOD, (st))
830#define sk_EVP_PKEY_METHOD_push(st, val) SKM_sk_push(EVP_PKEY_METHOD, (st), (val))
831#define sk_EVP_PKEY_METHOD_unshift(st, val) SKM_sk_unshift(EVP_PKEY_METHOD, (st), (val))
832#define sk_EVP_PKEY_METHOD_find(st, val) SKM_sk_find(EVP_PKEY_METHOD, (st), (val))
833#define sk_EVP_PKEY_METHOD_find_ex(st, val) SKM_sk_find_ex(EVP_PKEY_METHOD, (st), (val))
834#define sk_EVP_PKEY_METHOD_delete(st, i) SKM_sk_delete(EVP_PKEY_METHOD, (st), (i))
835#define sk_EVP_PKEY_METHOD_delete_ptr(st, ptr) SKM_sk_delete_ptr(EVP_PKEY_METHOD, (st), (ptr))
836#define sk_EVP_PKEY_METHOD_insert(st, val, i) SKM_sk_insert(EVP_PKEY_METHOD, (st), (val), (i))
837#define sk_EVP_PKEY_METHOD_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(EVP_PKEY_METHOD, (st), (cmp))
838#define sk_EVP_PKEY_METHOD_dup(st) SKM_sk_dup(EVP_PKEY_METHOD, st)
839#define sk_EVP_PKEY_METHOD_pop_free(st, free_func) SKM_sk_pop_free(EVP_PKEY_METHOD, (st), (free_func))
840#define sk_EVP_PKEY_METHOD_shift(st) SKM_sk_shift(EVP_PKEY_METHOD, (st))
841#define sk_EVP_PKEY_METHOD_pop(st) SKM_sk_pop(EVP_PKEY_METHOD, (st))
842#define sk_EVP_PKEY_METHOD_sort(st) SKM_sk_sort(EVP_PKEY_METHOD, (st))
843#define sk_EVP_PKEY_METHOD_is_sorted(st) SKM_sk_is_sorted(EVP_PKEY_METHOD, (st))
844
845#define sk_GENERAL_NAME_new(cmp) SKM_sk_new(GENERAL_NAME, (cmp))
682#define sk_GENERAL_NAME_new_null() SKM_sk_new_null(GENERAL_NAME) 846#define sk_GENERAL_NAME_new_null() SKM_sk_new_null(GENERAL_NAME)
683#define sk_GENERAL_NAME_free(st) SKM_sk_free(GENERAL_NAME, (st)) 847#define sk_GENERAL_NAME_free(st) SKM_sk_free(GENERAL_NAME, (st))
684#define sk_GENERAL_NAME_num(st) SKM_sk_num(GENERAL_NAME, (st)) 848#define sk_GENERAL_NAME_num(st) SKM_sk_num(GENERAL_NAME, (st))
@@ -700,7 +864,7 @@ STACK_OF(type) \
700#define sk_GENERAL_NAME_sort(st) SKM_sk_sort(GENERAL_NAME, (st)) 864#define sk_GENERAL_NAME_sort(st) SKM_sk_sort(GENERAL_NAME, (st))
701#define sk_GENERAL_NAME_is_sorted(st) SKM_sk_is_sorted(GENERAL_NAME, (st)) 865#define sk_GENERAL_NAME_is_sorted(st) SKM_sk_is_sorted(GENERAL_NAME, (st))
702 866
703#define sk_GENERAL_NAMES_new(st) SKM_sk_new(GENERAL_NAMES, (st)) 867#define sk_GENERAL_NAMES_new(cmp) SKM_sk_new(GENERAL_NAMES, (cmp))
704#define sk_GENERAL_NAMES_new_null() SKM_sk_new_null(GENERAL_NAMES) 868#define sk_GENERAL_NAMES_new_null() SKM_sk_new_null(GENERAL_NAMES)
705#define sk_GENERAL_NAMES_free(st) SKM_sk_free(GENERAL_NAMES, (st)) 869#define sk_GENERAL_NAMES_free(st) SKM_sk_free(GENERAL_NAMES, (st))
706#define sk_GENERAL_NAMES_num(st) SKM_sk_num(GENERAL_NAMES, (st)) 870#define sk_GENERAL_NAMES_num(st) SKM_sk_num(GENERAL_NAMES, (st))
@@ -722,7 +886,7 @@ STACK_OF(type) \
722#define sk_GENERAL_NAMES_sort(st) SKM_sk_sort(GENERAL_NAMES, (st)) 886#define sk_GENERAL_NAMES_sort(st) SKM_sk_sort(GENERAL_NAMES, (st))
723#define sk_GENERAL_NAMES_is_sorted(st) SKM_sk_is_sorted(GENERAL_NAMES, (st)) 887#define sk_GENERAL_NAMES_is_sorted(st) SKM_sk_is_sorted(GENERAL_NAMES, (st))
724 888
725#define sk_GENERAL_SUBTREE_new(st) SKM_sk_new(GENERAL_SUBTREE, (st)) 889#define sk_GENERAL_SUBTREE_new(cmp) SKM_sk_new(GENERAL_SUBTREE, (cmp))
726#define sk_GENERAL_SUBTREE_new_null() SKM_sk_new_null(GENERAL_SUBTREE) 890#define sk_GENERAL_SUBTREE_new_null() SKM_sk_new_null(GENERAL_SUBTREE)
727#define sk_GENERAL_SUBTREE_free(st) SKM_sk_free(GENERAL_SUBTREE, (st)) 891#define sk_GENERAL_SUBTREE_free(st) SKM_sk_free(GENERAL_SUBTREE, (st))
728#define sk_GENERAL_SUBTREE_num(st) SKM_sk_num(GENERAL_SUBTREE, (st)) 892#define sk_GENERAL_SUBTREE_num(st) SKM_sk_num(GENERAL_SUBTREE, (st))
@@ -744,7 +908,7 @@ STACK_OF(type) \
744#define sk_GENERAL_SUBTREE_sort(st) SKM_sk_sort(GENERAL_SUBTREE, (st)) 908#define sk_GENERAL_SUBTREE_sort(st) SKM_sk_sort(GENERAL_SUBTREE, (st))
745#define sk_GENERAL_SUBTREE_is_sorted(st) SKM_sk_is_sorted(GENERAL_SUBTREE, (st)) 909#define sk_GENERAL_SUBTREE_is_sorted(st) SKM_sk_is_sorted(GENERAL_SUBTREE, (st))
746 910
747#define sk_IPAddressFamily_new(st) SKM_sk_new(IPAddressFamily, (st)) 911#define sk_IPAddressFamily_new(cmp) SKM_sk_new(IPAddressFamily, (cmp))
748#define sk_IPAddressFamily_new_null() SKM_sk_new_null(IPAddressFamily) 912#define sk_IPAddressFamily_new_null() SKM_sk_new_null(IPAddressFamily)
749#define sk_IPAddressFamily_free(st) SKM_sk_free(IPAddressFamily, (st)) 913#define sk_IPAddressFamily_free(st) SKM_sk_free(IPAddressFamily, (st))
750#define sk_IPAddressFamily_num(st) SKM_sk_num(IPAddressFamily, (st)) 914#define sk_IPAddressFamily_num(st) SKM_sk_num(IPAddressFamily, (st))
@@ -766,7 +930,7 @@ STACK_OF(type) \
766#define sk_IPAddressFamily_sort(st) SKM_sk_sort(IPAddressFamily, (st)) 930#define sk_IPAddressFamily_sort(st) SKM_sk_sort(IPAddressFamily, (st))
767#define sk_IPAddressFamily_is_sorted(st) SKM_sk_is_sorted(IPAddressFamily, (st)) 931#define sk_IPAddressFamily_is_sorted(st) SKM_sk_is_sorted(IPAddressFamily, (st))
768 932
769#define sk_IPAddressOrRange_new(st) SKM_sk_new(IPAddressOrRange, (st)) 933#define sk_IPAddressOrRange_new(cmp) SKM_sk_new(IPAddressOrRange, (cmp))
770#define sk_IPAddressOrRange_new_null() SKM_sk_new_null(IPAddressOrRange) 934#define sk_IPAddressOrRange_new_null() SKM_sk_new_null(IPAddressOrRange)
771#define sk_IPAddressOrRange_free(st) SKM_sk_free(IPAddressOrRange, (st)) 935#define sk_IPAddressOrRange_free(st) SKM_sk_free(IPAddressOrRange, (st))
772#define sk_IPAddressOrRange_num(st) SKM_sk_num(IPAddressOrRange, (st)) 936#define sk_IPAddressOrRange_num(st) SKM_sk_num(IPAddressOrRange, (st))
@@ -788,7 +952,7 @@ STACK_OF(type) \
788#define sk_IPAddressOrRange_sort(st) SKM_sk_sort(IPAddressOrRange, (st)) 952#define sk_IPAddressOrRange_sort(st) SKM_sk_sort(IPAddressOrRange, (st))
789#define sk_IPAddressOrRange_is_sorted(st) SKM_sk_is_sorted(IPAddressOrRange, (st)) 953#define sk_IPAddressOrRange_is_sorted(st) SKM_sk_is_sorted(IPAddressOrRange, (st))
790 954
791#define sk_KRB5_APREQBODY_new(st) SKM_sk_new(KRB5_APREQBODY, (st)) 955#define sk_KRB5_APREQBODY_new(cmp) SKM_sk_new(KRB5_APREQBODY, (cmp))
792#define sk_KRB5_APREQBODY_new_null() SKM_sk_new_null(KRB5_APREQBODY) 956#define sk_KRB5_APREQBODY_new_null() SKM_sk_new_null(KRB5_APREQBODY)
793#define sk_KRB5_APREQBODY_free(st) SKM_sk_free(KRB5_APREQBODY, (st)) 957#define sk_KRB5_APREQBODY_free(st) SKM_sk_free(KRB5_APREQBODY, (st))
794#define sk_KRB5_APREQBODY_num(st) SKM_sk_num(KRB5_APREQBODY, (st)) 958#define sk_KRB5_APREQBODY_num(st) SKM_sk_num(KRB5_APREQBODY, (st))
@@ -810,7 +974,7 @@ STACK_OF(type) \
810#define sk_KRB5_APREQBODY_sort(st) SKM_sk_sort(KRB5_APREQBODY, (st)) 974#define sk_KRB5_APREQBODY_sort(st) SKM_sk_sort(KRB5_APREQBODY, (st))
811#define sk_KRB5_APREQBODY_is_sorted(st) SKM_sk_is_sorted(KRB5_APREQBODY, (st)) 975#define sk_KRB5_APREQBODY_is_sorted(st) SKM_sk_is_sorted(KRB5_APREQBODY, (st))
812 976
813#define sk_KRB5_AUTHDATA_new(st) SKM_sk_new(KRB5_AUTHDATA, (st)) 977#define sk_KRB5_AUTHDATA_new(cmp) SKM_sk_new(KRB5_AUTHDATA, (cmp))
814#define sk_KRB5_AUTHDATA_new_null() SKM_sk_new_null(KRB5_AUTHDATA) 978#define sk_KRB5_AUTHDATA_new_null() SKM_sk_new_null(KRB5_AUTHDATA)
815#define sk_KRB5_AUTHDATA_free(st) SKM_sk_free(KRB5_AUTHDATA, (st)) 979#define sk_KRB5_AUTHDATA_free(st) SKM_sk_free(KRB5_AUTHDATA, (st))
816#define sk_KRB5_AUTHDATA_num(st) SKM_sk_num(KRB5_AUTHDATA, (st)) 980#define sk_KRB5_AUTHDATA_num(st) SKM_sk_num(KRB5_AUTHDATA, (st))
@@ -832,7 +996,7 @@ STACK_OF(type) \
832#define sk_KRB5_AUTHDATA_sort(st) SKM_sk_sort(KRB5_AUTHDATA, (st)) 996#define sk_KRB5_AUTHDATA_sort(st) SKM_sk_sort(KRB5_AUTHDATA, (st))
833#define sk_KRB5_AUTHDATA_is_sorted(st) SKM_sk_is_sorted(KRB5_AUTHDATA, (st)) 997#define sk_KRB5_AUTHDATA_is_sorted(st) SKM_sk_is_sorted(KRB5_AUTHDATA, (st))
834 998
835#define sk_KRB5_AUTHENTBODY_new(st) SKM_sk_new(KRB5_AUTHENTBODY, (st)) 999#define sk_KRB5_AUTHENTBODY_new(cmp) SKM_sk_new(KRB5_AUTHENTBODY, (cmp))
836#define sk_KRB5_AUTHENTBODY_new_null() SKM_sk_new_null(KRB5_AUTHENTBODY) 1000#define sk_KRB5_AUTHENTBODY_new_null() SKM_sk_new_null(KRB5_AUTHENTBODY)
837#define sk_KRB5_AUTHENTBODY_free(st) SKM_sk_free(KRB5_AUTHENTBODY, (st)) 1001#define sk_KRB5_AUTHENTBODY_free(st) SKM_sk_free(KRB5_AUTHENTBODY, (st))
838#define sk_KRB5_AUTHENTBODY_num(st) SKM_sk_num(KRB5_AUTHENTBODY, (st)) 1002#define sk_KRB5_AUTHENTBODY_num(st) SKM_sk_num(KRB5_AUTHENTBODY, (st))
@@ -854,7 +1018,7 @@ STACK_OF(type) \
854#define sk_KRB5_AUTHENTBODY_sort(st) SKM_sk_sort(KRB5_AUTHENTBODY, (st)) 1018#define sk_KRB5_AUTHENTBODY_sort(st) SKM_sk_sort(KRB5_AUTHENTBODY, (st))
855#define sk_KRB5_AUTHENTBODY_is_sorted(st) SKM_sk_is_sorted(KRB5_AUTHENTBODY, (st)) 1019#define sk_KRB5_AUTHENTBODY_is_sorted(st) SKM_sk_is_sorted(KRB5_AUTHENTBODY, (st))
856 1020
857#define sk_KRB5_CHECKSUM_new(st) SKM_sk_new(KRB5_CHECKSUM, (st)) 1021#define sk_KRB5_CHECKSUM_new(cmp) SKM_sk_new(KRB5_CHECKSUM, (cmp))
858#define sk_KRB5_CHECKSUM_new_null() SKM_sk_new_null(KRB5_CHECKSUM) 1022#define sk_KRB5_CHECKSUM_new_null() SKM_sk_new_null(KRB5_CHECKSUM)
859#define sk_KRB5_CHECKSUM_free(st) SKM_sk_free(KRB5_CHECKSUM, (st)) 1023#define sk_KRB5_CHECKSUM_free(st) SKM_sk_free(KRB5_CHECKSUM, (st))
860#define sk_KRB5_CHECKSUM_num(st) SKM_sk_num(KRB5_CHECKSUM, (st)) 1024#define sk_KRB5_CHECKSUM_num(st) SKM_sk_num(KRB5_CHECKSUM, (st))
@@ -876,7 +1040,7 @@ STACK_OF(type) \
876#define sk_KRB5_CHECKSUM_sort(st) SKM_sk_sort(KRB5_CHECKSUM, (st)) 1040#define sk_KRB5_CHECKSUM_sort(st) SKM_sk_sort(KRB5_CHECKSUM, (st))
877#define sk_KRB5_CHECKSUM_is_sorted(st) SKM_sk_is_sorted(KRB5_CHECKSUM, (st)) 1041#define sk_KRB5_CHECKSUM_is_sorted(st) SKM_sk_is_sorted(KRB5_CHECKSUM, (st))
878 1042
879#define sk_KRB5_ENCDATA_new(st) SKM_sk_new(KRB5_ENCDATA, (st)) 1043#define sk_KRB5_ENCDATA_new(cmp) SKM_sk_new(KRB5_ENCDATA, (cmp))
880#define sk_KRB5_ENCDATA_new_null() SKM_sk_new_null(KRB5_ENCDATA) 1044#define sk_KRB5_ENCDATA_new_null() SKM_sk_new_null(KRB5_ENCDATA)
881#define sk_KRB5_ENCDATA_free(st) SKM_sk_free(KRB5_ENCDATA, (st)) 1045#define sk_KRB5_ENCDATA_free(st) SKM_sk_free(KRB5_ENCDATA, (st))
882#define sk_KRB5_ENCDATA_num(st) SKM_sk_num(KRB5_ENCDATA, (st)) 1046#define sk_KRB5_ENCDATA_num(st) SKM_sk_num(KRB5_ENCDATA, (st))
@@ -898,7 +1062,7 @@ STACK_OF(type) \
898#define sk_KRB5_ENCDATA_sort(st) SKM_sk_sort(KRB5_ENCDATA, (st)) 1062#define sk_KRB5_ENCDATA_sort(st) SKM_sk_sort(KRB5_ENCDATA, (st))
899#define sk_KRB5_ENCDATA_is_sorted(st) SKM_sk_is_sorted(KRB5_ENCDATA, (st)) 1063#define sk_KRB5_ENCDATA_is_sorted(st) SKM_sk_is_sorted(KRB5_ENCDATA, (st))
900 1064
901#define sk_KRB5_ENCKEY_new(st) SKM_sk_new(KRB5_ENCKEY, (st)) 1065#define sk_KRB5_ENCKEY_new(cmp) SKM_sk_new(KRB5_ENCKEY, (cmp))
902#define sk_KRB5_ENCKEY_new_null() SKM_sk_new_null(KRB5_ENCKEY) 1066#define sk_KRB5_ENCKEY_new_null() SKM_sk_new_null(KRB5_ENCKEY)
903#define sk_KRB5_ENCKEY_free(st) SKM_sk_free(KRB5_ENCKEY, (st)) 1067#define sk_KRB5_ENCKEY_free(st) SKM_sk_free(KRB5_ENCKEY, (st))
904#define sk_KRB5_ENCKEY_num(st) SKM_sk_num(KRB5_ENCKEY, (st)) 1068#define sk_KRB5_ENCKEY_num(st) SKM_sk_num(KRB5_ENCKEY, (st))
@@ -920,7 +1084,7 @@ STACK_OF(type) \
920#define sk_KRB5_ENCKEY_sort(st) SKM_sk_sort(KRB5_ENCKEY, (st)) 1084#define sk_KRB5_ENCKEY_sort(st) SKM_sk_sort(KRB5_ENCKEY, (st))
921#define sk_KRB5_ENCKEY_is_sorted(st) SKM_sk_is_sorted(KRB5_ENCKEY, (st)) 1085#define sk_KRB5_ENCKEY_is_sorted(st) SKM_sk_is_sorted(KRB5_ENCKEY, (st))
922 1086
923#define sk_KRB5_PRINCNAME_new(st) SKM_sk_new(KRB5_PRINCNAME, (st)) 1087#define sk_KRB5_PRINCNAME_new(cmp) SKM_sk_new(KRB5_PRINCNAME, (cmp))
924#define sk_KRB5_PRINCNAME_new_null() SKM_sk_new_null(KRB5_PRINCNAME) 1088#define sk_KRB5_PRINCNAME_new_null() SKM_sk_new_null(KRB5_PRINCNAME)
925#define sk_KRB5_PRINCNAME_free(st) SKM_sk_free(KRB5_PRINCNAME, (st)) 1089#define sk_KRB5_PRINCNAME_free(st) SKM_sk_free(KRB5_PRINCNAME, (st))
926#define sk_KRB5_PRINCNAME_num(st) SKM_sk_num(KRB5_PRINCNAME, (st)) 1090#define sk_KRB5_PRINCNAME_num(st) SKM_sk_num(KRB5_PRINCNAME, (st))
@@ -942,7 +1106,7 @@ STACK_OF(type) \
942#define sk_KRB5_PRINCNAME_sort(st) SKM_sk_sort(KRB5_PRINCNAME, (st)) 1106#define sk_KRB5_PRINCNAME_sort(st) SKM_sk_sort(KRB5_PRINCNAME, (st))
943#define sk_KRB5_PRINCNAME_is_sorted(st) SKM_sk_is_sorted(KRB5_PRINCNAME, (st)) 1107#define sk_KRB5_PRINCNAME_is_sorted(st) SKM_sk_is_sorted(KRB5_PRINCNAME, (st))
944 1108
945#define sk_KRB5_TKTBODY_new(st) SKM_sk_new(KRB5_TKTBODY, (st)) 1109#define sk_KRB5_TKTBODY_new(cmp) SKM_sk_new(KRB5_TKTBODY, (cmp))
946#define sk_KRB5_TKTBODY_new_null() SKM_sk_new_null(KRB5_TKTBODY) 1110#define sk_KRB5_TKTBODY_new_null() SKM_sk_new_null(KRB5_TKTBODY)
947#define sk_KRB5_TKTBODY_free(st) SKM_sk_free(KRB5_TKTBODY, (st)) 1111#define sk_KRB5_TKTBODY_free(st) SKM_sk_free(KRB5_TKTBODY, (st))
948#define sk_KRB5_TKTBODY_num(st) SKM_sk_num(KRB5_TKTBODY, (st)) 1112#define sk_KRB5_TKTBODY_num(st) SKM_sk_num(KRB5_TKTBODY, (st))
@@ -964,7 +1128,29 @@ STACK_OF(type) \
964#define sk_KRB5_TKTBODY_sort(st) SKM_sk_sort(KRB5_TKTBODY, (st)) 1128#define sk_KRB5_TKTBODY_sort(st) SKM_sk_sort(KRB5_TKTBODY, (st))
965#define sk_KRB5_TKTBODY_is_sorted(st) SKM_sk_is_sorted(KRB5_TKTBODY, (st)) 1129#define sk_KRB5_TKTBODY_is_sorted(st) SKM_sk_is_sorted(KRB5_TKTBODY, (st))
966 1130
967#define sk_MIME_HEADER_new(st) SKM_sk_new(MIME_HEADER, (st)) 1131#define sk_MEM_OBJECT_DATA_new(cmp) SKM_sk_new(MEM_OBJECT_DATA, (cmp))
1132#define sk_MEM_OBJECT_DATA_new_null() SKM_sk_new_null(MEM_OBJECT_DATA)
1133#define sk_MEM_OBJECT_DATA_free(st) SKM_sk_free(MEM_OBJECT_DATA, (st))
1134#define sk_MEM_OBJECT_DATA_num(st) SKM_sk_num(MEM_OBJECT_DATA, (st))
1135#define sk_MEM_OBJECT_DATA_value(st, i) SKM_sk_value(MEM_OBJECT_DATA, (st), (i))
1136#define sk_MEM_OBJECT_DATA_set(st, i, val) SKM_sk_set(MEM_OBJECT_DATA, (st), (i), (val))
1137#define sk_MEM_OBJECT_DATA_zero(st) SKM_sk_zero(MEM_OBJECT_DATA, (st))
1138#define sk_MEM_OBJECT_DATA_push(st, val) SKM_sk_push(MEM_OBJECT_DATA, (st), (val))
1139#define sk_MEM_OBJECT_DATA_unshift(st, val) SKM_sk_unshift(MEM_OBJECT_DATA, (st), (val))
1140#define sk_MEM_OBJECT_DATA_find(st, val) SKM_sk_find(MEM_OBJECT_DATA, (st), (val))
1141#define sk_MEM_OBJECT_DATA_find_ex(st, val) SKM_sk_find_ex(MEM_OBJECT_DATA, (st), (val))
1142#define sk_MEM_OBJECT_DATA_delete(st, i) SKM_sk_delete(MEM_OBJECT_DATA, (st), (i))
1143#define sk_MEM_OBJECT_DATA_delete_ptr(st, ptr) SKM_sk_delete_ptr(MEM_OBJECT_DATA, (st), (ptr))
1144#define sk_MEM_OBJECT_DATA_insert(st, val, i) SKM_sk_insert(MEM_OBJECT_DATA, (st), (val), (i))
1145#define sk_MEM_OBJECT_DATA_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(MEM_OBJECT_DATA, (st), (cmp))
1146#define sk_MEM_OBJECT_DATA_dup(st) SKM_sk_dup(MEM_OBJECT_DATA, st)
1147#define sk_MEM_OBJECT_DATA_pop_free(st, free_func) SKM_sk_pop_free(MEM_OBJECT_DATA, (st), (free_func))
1148#define sk_MEM_OBJECT_DATA_shift(st) SKM_sk_shift(MEM_OBJECT_DATA, (st))
1149#define sk_MEM_OBJECT_DATA_pop(st) SKM_sk_pop(MEM_OBJECT_DATA, (st))
1150#define sk_MEM_OBJECT_DATA_sort(st) SKM_sk_sort(MEM_OBJECT_DATA, (st))
1151#define sk_MEM_OBJECT_DATA_is_sorted(st) SKM_sk_is_sorted(MEM_OBJECT_DATA, (st))
1152
1153#define sk_MIME_HEADER_new(cmp) SKM_sk_new(MIME_HEADER, (cmp))
968#define sk_MIME_HEADER_new_null() SKM_sk_new_null(MIME_HEADER) 1154#define sk_MIME_HEADER_new_null() SKM_sk_new_null(MIME_HEADER)
969#define sk_MIME_HEADER_free(st) SKM_sk_free(MIME_HEADER, (st)) 1155#define sk_MIME_HEADER_free(st) SKM_sk_free(MIME_HEADER, (st))
970#define sk_MIME_HEADER_num(st) SKM_sk_num(MIME_HEADER, (st)) 1156#define sk_MIME_HEADER_num(st) SKM_sk_num(MIME_HEADER, (st))
@@ -986,51 +1172,7 @@ STACK_OF(type) \
986#define sk_MIME_HEADER_sort(st) SKM_sk_sort(MIME_HEADER, (st)) 1172#define sk_MIME_HEADER_sort(st) SKM_sk_sort(MIME_HEADER, (st))
987#define sk_MIME_HEADER_is_sorted(st) SKM_sk_is_sorted(MIME_HEADER, (st)) 1173#define sk_MIME_HEADER_is_sorted(st) SKM_sk_is_sorted(MIME_HEADER, (st))
988 1174
989#define sk_MIME_HEADER_new(st) SKM_sk_new(MIME_HEADER, (st)) 1175#define sk_MIME_PARAM_new(cmp) SKM_sk_new(MIME_PARAM, (cmp))
990#define sk_MIME_HEADER_new_null() SKM_sk_new_null(MIME_HEADER)
991#define sk_MIME_HEADER_free(st) SKM_sk_free(MIME_HEADER, (st))
992#define sk_MIME_HEADER_num(st) SKM_sk_num(MIME_HEADER, (st))
993#define sk_MIME_HEADER_value(st, i) SKM_sk_value(MIME_HEADER, (st), (i))
994#define sk_MIME_HEADER_set(st, i, val) SKM_sk_set(MIME_HEADER, (st), (i), (val))
995#define sk_MIME_HEADER_zero(st) SKM_sk_zero(MIME_HEADER, (st))
996#define sk_MIME_HEADER_push(st, val) SKM_sk_push(MIME_HEADER, (st), (val))
997#define sk_MIME_HEADER_unshift(st, val) SKM_sk_unshift(MIME_HEADER, (st), (val))
998#define sk_MIME_HEADER_find(st, val) SKM_sk_find(MIME_HEADER, (st), (val))
999#define sk_MIME_HEADER_find_ex(st, val) SKM_sk_find_ex(MIME_HEADER, (st), (val))
1000#define sk_MIME_HEADER_delete(st, i) SKM_sk_delete(MIME_HEADER, (st), (i))
1001#define sk_MIME_HEADER_delete_ptr(st, ptr) SKM_sk_delete_ptr(MIME_HEADER, (st), (ptr))
1002#define sk_MIME_HEADER_insert(st, val, i) SKM_sk_insert(MIME_HEADER, (st), (val), (i))
1003#define sk_MIME_HEADER_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(MIME_HEADER, (st), (cmp))
1004#define sk_MIME_HEADER_dup(st) SKM_sk_dup(MIME_HEADER, st)
1005#define sk_MIME_HEADER_pop_free(st, free_func) SKM_sk_pop_free(MIME_HEADER, (st), (free_func))
1006#define sk_MIME_HEADER_shift(st) SKM_sk_shift(MIME_HEADER, (st))
1007#define sk_MIME_HEADER_pop(st) SKM_sk_pop(MIME_HEADER, (st))
1008#define sk_MIME_HEADER_sort(st) SKM_sk_sort(MIME_HEADER, (st))
1009#define sk_MIME_HEADER_is_sorted(st) SKM_sk_is_sorted(MIME_HEADER, (st))
1010
1011#define sk_MIME_PARAM_new(st) SKM_sk_new(MIME_PARAM, (st))
1012#define sk_MIME_PARAM_new_null() SKM_sk_new_null(MIME_PARAM)
1013#define sk_MIME_PARAM_free(st) SKM_sk_free(MIME_PARAM, (st))
1014#define sk_MIME_PARAM_num(st) SKM_sk_num(MIME_PARAM, (st))
1015#define sk_MIME_PARAM_value(st, i) SKM_sk_value(MIME_PARAM, (st), (i))
1016#define sk_MIME_PARAM_set(st, i, val) SKM_sk_set(MIME_PARAM, (st), (i), (val))
1017#define sk_MIME_PARAM_zero(st) SKM_sk_zero(MIME_PARAM, (st))
1018#define sk_MIME_PARAM_push(st, val) SKM_sk_push(MIME_PARAM, (st), (val))
1019#define sk_MIME_PARAM_unshift(st, val) SKM_sk_unshift(MIME_PARAM, (st), (val))
1020#define sk_MIME_PARAM_find(st, val) SKM_sk_find(MIME_PARAM, (st), (val))
1021#define sk_MIME_PARAM_find_ex(st, val) SKM_sk_find_ex(MIME_PARAM, (st), (val))
1022#define sk_MIME_PARAM_delete(st, i) SKM_sk_delete(MIME_PARAM, (st), (i))
1023#define sk_MIME_PARAM_delete_ptr(st, ptr) SKM_sk_delete_ptr(MIME_PARAM, (st), (ptr))
1024#define sk_MIME_PARAM_insert(st, val, i) SKM_sk_insert(MIME_PARAM, (st), (val), (i))
1025#define sk_MIME_PARAM_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(MIME_PARAM, (st), (cmp))
1026#define sk_MIME_PARAM_dup(st) SKM_sk_dup(MIME_PARAM, st)
1027#define sk_MIME_PARAM_pop_free(st, free_func) SKM_sk_pop_free(MIME_PARAM, (st), (free_func))
1028#define sk_MIME_PARAM_shift(st) SKM_sk_shift(MIME_PARAM, (st))
1029#define sk_MIME_PARAM_pop(st) SKM_sk_pop(MIME_PARAM, (st))
1030#define sk_MIME_PARAM_sort(st) SKM_sk_sort(MIME_PARAM, (st))
1031#define sk_MIME_PARAM_is_sorted(st) SKM_sk_is_sorted(MIME_PARAM, (st))
1032
1033#define sk_MIME_PARAM_new(st) SKM_sk_new(MIME_PARAM, (st))
1034#define sk_MIME_PARAM_new_null() SKM_sk_new_null(MIME_PARAM) 1176#define sk_MIME_PARAM_new_null() SKM_sk_new_null(MIME_PARAM)
1035#define sk_MIME_PARAM_free(st) SKM_sk_free(MIME_PARAM, (st)) 1177#define sk_MIME_PARAM_free(st) SKM_sk_free(MIME_PARAM, (st))
1036#define sk_MIME_PARAM_num(st) SKM_sk_num(MIME_PARAM, (st)) 1178#define sk_MIME_PARAM_num(st) SKM_sk_num(MIME_PARAM, (st))
@@ -1052,7 +1194,7 @@ STACK_OF(type) \
1052#define sk_MIME_PARAM_sort(st) SKM_sk_sort(MIME_PARAM, (st)) 1194#define sk_MIME_PARAM_sort(st) SKM_sk_sort(MIME_PARAM, (st))
1053#define sk_MIME_PARAM_is_sorted(st) SKM_sk_is_sorted(MIME_PARAM, (st)) 1195#define sk_MIME_PARAM_is_sorted(st) SKM_sk_is_sorted(MIME_PARAM, (st))
1054 1196
1055#define sk_NAME_FUNCS_new(st) SKM_sk_new(NAME_FUNCS, (st)) 1197#define sk_NAME_FUNCS_new(cmp) SKM_sk_new(NAME_FUNCS, (cmp))
1056#define sk_NAME_FUNCS_new_null() SKM_sk_new_null(NAME_FUNCS) 1198#define sk_NAME_FUNCS_new_null() SKM_sk_new_null(NAME_FUNCS)
1057#define sk_NAME_FUNCS_free(st) SKM_sk_free(NAME_FUNCS, (st)) 1199#define sk_NAME_FUNCS_free(st) SKM_sk_free(NAME_FUNCS, (st))
1058#define sk_NAME_FUNCS_num(st) SKM_sk_num(NAME_FUNCS, (st)) 1200#define sk_NAME_FUNCS_num(st) SKM_sk_num(NAME_FUNCS, (st))
@@ -1074,7 +1216,7 @@ STACK_OF(type) \
1074#define sk_NAME_FUNCS_sort(st) SKM_sk_sort(NAME_FUNCS, (st)) 1216#define sk_NAME_FUNCS_sort(st) SKM_sk_sort(NAME_FUNCS, (st))
1075#define sk_NAME_FUNCS_is_sorted(st) SKM_sk_is_sorted(NAME_FUNCS, (st)) 1217#define sk_NAME_FUNCS_is_sorted(st) SKM_sk_is_sorted(NAME_FUNCS, (st))
1076 1218
1077#define sk_OCSP_CERTID_new(st) SKM_sk_new(OCSP_CERTID, (st)) 1219#define sk_OCSP_CERTID_new(cmp) SKM_sk_new(OCSP_CERTID, (cmp))
1078#define sk_OCSP_CERTID_new_null() SKM_sk_new_null(OCSP_CERTID) 1220#define sk_OCSP_CERTID_new_null() SKM_sk_new_null(OCSP_CERTID)
1079#define sk_OCSP_CERTID_free(st) SKM_sk_free(OCSP_CERTID, (st)) 1221#define sk_OCSP_CERTID_free(st) SKM_sk_free(OCSP_CERTID, (st))
1080#define sk_OCSP_CERTID_num(st) SKM_sk_num(OCSP_CERTID, (st)) 1222#define sk_OCSP_CERTID_num(st) SKM_sk_num(OCSP_CERTID, (st))
@@ -1096,7 +1238,7 @@ STACK_OF(type) \
1096#define sk_OCSP_CERTID_sort(st) SKM_sk_sort(OCSP_CERTID, (st)) 1238#define sk_OCSP_CERTID_sort(st) SKM_sk_sort(OCSP_CERTID, (st))
1097#define sk_OCSP_CERTID_is_sorted(st) SKM_sk_is_sorted(OCSP_CERTID, (st)) 1239#define sk_OCSP_CERTID_is_sorted(st) SKM_sk_is_sorted(OCSP_CERTID, (st))
1098 1240
1099#define sk_OCSP_ONEREQ_new(st) SKM_sk_new(OCSP_ONEREQ, (st)) 1241#define sk_OCSP_ONEREQ_new(cmp) SKM_sk_new(OCSP_ONEREQ, (cmp))
1100#define sk_OCSP_ONEREQ_new_null() SKM_sk_new_null(OCSP_ONEREQ) 1242#define sk_OCSP_ONEREQ_new_null() SKM_sk_new_null(OCSP_ONEREQ)
1101#define sk_OCSP_ONEREQ_free(st) SKM_sk_free(OCSP_ONEREQ, (st)) 1243#define sk_OCSP_ONEREQ_free(st) SKM_sk_free(OCSP_ONEREQ, (st))
1102#define sk_OCSP_ONEREQ_num(st) SKM_sk_num(OCSP_ONEREQ, (st)) 1244#define sk_OCSP_ONEREQ_num(st) SKM_sk_num(OCSP_ONEREQ, (st))
@@ -1118,7 +1260,7 @@ STACK_OF(type) \
1118#define sk_OCSP_ONEREQ_sort(st) SKM_sk_sort(OCSP_ONEREQ, (st)) 1260#define sk_OCSP_ONEREQ_sort(st) SKM_sk_sort(OCSP_ONEREQ, (st))
1119#define sk_OCSP_ONEREQ_is_sorted(st) SKM_sk_is_sorted(OCSP_ONEREQ, (st)) 1261#define sk_OCSP_ONEREQ_is_sorted(st) SKM_sk_is_sorted(OCSP_ONEREQ, (st))
1120 1262
1121#define sk_OCSP_RESPID_new(st) SKM_sk_new(OCSP_RESPID, (st)) 1263#define sk_OCSP_RESPID_new(cmp) SKM_sk_new(OCSP_RESPID, (cmp))
1122#define sk_OCSP_RESPID_new_null() SKM_sk_new_null(OCSP_RESPID) 1264#define sk_OCSP_RESPID_new_null() SKM_sk_new_null(OCSP_RESPID)
1123#define sk_OCSP_RESPID_free(st) SKM_sk_free(OCSP_RESPID, (st)) 1265#define sk_OCSP_RESPID_free(st) SKM_sk_free(OCSP_RESPID, (st))
1124#define sk_OCSP_RESPID_num(st) SKM_sk_num(OCSP_RESPID, (st)) 1266#define sk_OCSP_RESPID_num(st) SKM_sk_num(OCSP_RESPID, (st))
@@ -1140,7 +1282,7 @@ STACK_OF(type) \
1140#define sk_OCSP_RESPID_sort(st) SKM_sk_sort(OCSP_RESPID, (st)) 1282#define sk_OCSP_RESPID_sort(st) SKM_sk_sort(OCSP_RESPID, (st))
1141#define sk_OCSP_RESPID_is_sorted(st) SKM_sk_is_sorted(OCSP_RESPID, (st)) 1283#define sk_OCSP_RESPID_is_sorted(st) SKM_sk_is_sorted(OCSP_RESPID, (st))
1142 1284
1143#define sk_OCSP_SINGLERESP_new(st) SKM_sk_new(OCSP_SINGLERESP, (st)) 1285#define sk_OCSP_SINGLERESP_new(cmp) SKM_sk_new(OCSP_SINGLERESP, (cmp))
1144#define sk_OCSP_SINGLERESP_new_null() SKM_sk_new_null(OCSP_SINGLERESP) 1286#define sk_OCSP_SINGLERESP_new_null() SKM_sk_new_null(OCSP_SINGLERESP)
1145#define sk_OCSP_SINGLERESP_free(st) SKM_sk_free(OCSP_SINGLERESP, (st)) 1287#define sk_OCSP_SINGLERESP_free(st) SKM_sk_free(OCSP_SINGLERESP, (st))
1146#define sk_OCSP_SINGLERESP_num(st) SKM_sk_num(OCSP_SINGLERESP, (st)) 1288#define sk_OCSP_SINGLERESP_num(st) SKM_sk_num(OCSP_SINGLERESP, (st))
@@ -1162,7 +1304,7 @@ STACK_OF(type) \
1162#define sk_OCSP_SINGLERESP_sort(st) SKM_sk_sort(OCSP_SINGLERESP, (st)) 1304#define sk_OCSP_SINGLERESP_sort(st) SKM_sk_sort(OCSP_SINGLERESP, (st))
1163#define sk_OCSP_SINGLERESP_is_sorted(st) SKM_sk_is_sorted(OCSP_SINGLERESP, (st)) 1305#define sk_OCSP_SINGLERESP_is_sorted(st) SKM_sk_is_sorted(OCSP_SINGLERESP, (st))
1164 1306
1165#define sk_PKCS12_SAFEBAG_new(st) SKM_sk_new(PKCS12_SAFEBAG, (st)) 1307#define sk_PKCS12_SAFEBAG_new(cmp) SKM_sk_new(PKCS12_SAFEBAG, (cmp))
1166#define sk_PKCS12_SAFEBAG_new_null() SKM_sk_new_null(PKCS12_SAFEBAG) 1308#define sk_PKCS12_SAFEBAG_new_null() SKM_sk_new_null(PKCS12_SAFEBAG)
1167#define sk_PKCS12_SAFEBAG_free(st) SKM_sk_free(PKCS12_SAFEBAG, (st)) 1309#define sk_PKCS12_SAFEBAG_free(st) SKM_sk_free(PKCS12_SAFEBAG, (st))
1168#define sk_PKCS12_SAFEBAG_num(st) SKM_sk_num(PKCS12_SAFEBAG, (st)) 1310#define sk_PKCS12_SAFEBAG_num(st) SKM_sk_num(PKCS12_SAFEBAG, (st))
@@ -1184,7 +1326,7 @@ STACK_OF(type) \
1184#define sk_PKCS12_SAFEBAG_sort(st) SKM_sk_sort(PKCS12_SAFEBAG, (st)) 1326#define sk_PKCS12_SAFEBAG_sort(st) SKM_sk_sort(PKCS12_SAFEBAG, (st))
1185#define sk_PKCS12_SAFEBAG_is_sorted(st) SKM_sk_is_sorted(PKCS12_SAFEBAG, (st)) 1327#define sk_PKCS12_SAFEBAG_is_sorted(st) SKM_sk_is_sorted(PKCS12_SAFEBAG, (st))
1186 1328
1187#define sk_PKCS7_new(st) SKM_sk_new(PKCS7, (st)) 1329#define sk_PKCS7_new(cmp) SKM_sk_new(PKCS7, (cmp))
1188#define sk_PKCS7_new_null() SKM_sk_new_null(PKCS7) 1330#define sk_PKCS7_new_null() SKM_sk_new_null(PKCS7)
1189#define sk_PKCS7_free(st) SKM_sk_free(PKCS7, (st)) 1331#define sk_PKCS7_free(st) SKM_sk_free(PKCS7, (st))
1190#define sk_PKCS7_num(st) SKM_sk_num(PKCS7, (st)) 1332#define sk_PKCS7_num(st) SKM_sk_num(PKCS7, (st))
@@ -1206,7 +1348,7 @@ STACK_OF(type) \
1206#define sk_PKCS7_sort(st) SKM_sk_sort(PKCS7, (st)) 1348#define sk_PKCS7_sort(st) SKM_sk_sort(PKCS7, (st))
1207#define sk_PKCS7_is_sorted(st) SKM_sk_is_sorted(PKCS7, (st)) 1349#define sk_PKCS7_is_sorted(st) SKM_sk_is_sorted(PKCS7, (st))
1208 1350
1209#define sk_PKCS7_RECIP_INFO_new(st) SKM_sk_new(PKCS7_RECIP_INFO, (st)) 1351#define sk_PKCS7_RECIP_INFO_new(cmp) SKM_sk_new(PKCS7_RECIP_INFO, (cmp))
1210#define sk_PKCS7_RECIP_INFO_new_null() SKM_sk_new_null(PKCS7_RECIP_INFO) 1352#define sk_PKCS7_RECIP_INFO_new_null() SKM_sk_new_null(PKCS7_RECIP_INFO)
1211#define sk_PKCS7_RECIP_INFO_free(st) SKM_sk_free(PKCS7_RECIP_INFO, (st)) 1353#define sk_PKCS7_RECIP_INFO_free(st) SKM_sk_free(PKCS7_RECIP_INFO, (st))
1212#define sk_PKCS7_RECIP_INFO_num(st) SKM_sk_num(PKCS7_RECIP_INFO, (st)) 1354#define sk_PKCS7_RECIP_INFO_num(st) SKM_sk_num(PKCS7_RECIP_INFO, (st))
@@ -1228,7 +1370,7 @@ STACK_OF(type) \
1228#define sk_PKCS7_RECIP_INFO_sort(st) SKM_sk_sort(PKCS7_RECIP_INFO, (st)) 1370#define sk_PKCS7_RECIP_INFO_sort(st) SKM_sk_sort(PKCS7_RECIP_INFO, (st))
1229#define sk_PKCS7_RECIP_INFO_is_sorted(st) SKM_sk_is_sorted(PKCS7_RECIP_INFO, (st)) 1371#define sk_PKCS7_RECIP_INFO_is_sorted(st) SKM_sk_is_sorted(PKCS7_RECIP_INFO, (st))
1230 1372
1231#define sk_PKCS7_SIGNER_INFO_new(st) SKM_sk_new(PKCS7_SIGNER_INFO, (st)) 1373#define sk_PKCS7_SIGNER_INFO_new(cmp) SKM_sk_new(PKCS7_SIGNER_INFO, (cmp))
1232#define sk_PKCS7_SIGNER_INFO_new_null() SKM_sk_new_null(PKCS7_SIGNER_INFO) 1374#define sk_PKCS7_SIGNER_INFO_new_null() SKM_sk_new_null(PKCS7_SIGNER_INFO)
1233#define sk_PKCS7_SIGNER_INFO_free(st) SKM_sk_free(PKCS7_SIGNER_INFO, (st)) 1375#define sk_PKCS7_SIGNER_INFO_free(st) SKM_sk_free(PKCS7_SIGNER_INFO, (st))
1234#define sk_PKCS7_SIGNER_INFO_num(st) SKM_sk_num(PKCS7_SIGNER_INFO, (st)) 1376#define sk_PKCS7_SIGNER_INFO_num(st) SKM_sk_num(PKCS7_SIGNER_INFO, (st))
@@ -1250,7 +1392,7 @@ STACK_OF(type) \
1250#define sk_PKCS7_SIGNER_INFO_sort(st) SKM_sk_sort(PKCS7_SIGNER_INFO, (st)) 1392#define sk_PKCS7_SIGNER_INFO_sort(st) SKM_sk_sort(PKCS7_SIGNER_INFO, (st))
1251#define sk_PKCS7_SIGNER_INFO_is_sorted(st) SKM_sk_is_sorted(PKCS7_SIGNER_INFO, (st)) 1393#define sk_PKCS7_SIGNER_INFO_is_sorted(st) SKM_sk_is_sorted(PKCS7_SIGNER_INFO, (st))
1252 1394
1253#define sk_POLICYINFO_new(st) SKM_sk_new(POLICYINFO, (st)) 1395#define sk_POLICYINFO_new(cmp) SKM_sk_new(POLICYINFO, (cmp))
1254#define sk_POLICYINFO_new_null() SKM_sk_new_null(POLICYINFO) 1396#define sk_POLICYINFO_new_null() SKM_sk_new_null(POLICYINFO)
1255#define sk_POLICYINFO_free(st) SKM_sk_free(POLICYINFO, (st)) 1397#define sk_POLICYINFO_free(st) SKM_sk_free(POLICYINFO, (st))
1256#define sk_POLICYINFO_num(st) SKM_sk_num(POLICYINFO, (st)) 1398#define sk_POLICYINFO_num(st) SKM_sk_num(POLICYINFO, (st))
@@ -1272,7 +1414,7 @@ STACK_OF(type) \
1272#define sk_POLICYINFO_sort(st) SKM_sk_sort(POLICYINFO, (st)) 1414#define sk_POLICYINFO_sort(st) SKM_sk_sort(POLICYINFO, (st))
1273#define sk_POLICYINFO_is_sorted(st) SKM_sk_is_sorted(POLICYINFO, (st)) 1415#define sk_POLICYINFO_is_sorted(st) SKM_sk_is_sorted(POLICYINFO, (st))
1274 1416
1275#define sk_POLICYQUALINFO_new(st) SKM_sk_new(POLICYQUALINFO, (st)) 1417#define sk_POLICYQUALINFO_new(cmp) SKM_sk_new(POLICYQUALINFO, (cmp))
1276#define sk_POLICYQUALINFO_new_null() SKM_sk_new_null(POLICYQUALINFO) 1418#define sk_POLICYQUALINFO_new_null() SKM_sk_new_null(POLICYQUALINFO)
1277#define sk_POLICYQUALINFO_free(st) SKM_sk_free(POLICYQUALINFO, (st)) 1419#define sk_POLICYQUALINFO_free(st) SKM_sk_free(POLICYQUALINFO, (st))
1278#define sk_POLICYQUALINFO_num(st) SKM_sk_num(POLICYQUALINFO, (st)) 1420#define sk_POLICYQUALINFO_num(st) SKM_sk_num(POLICYQUALINFO, (st))
@@ -1294,7 +1436,7 @@ STACK_OF(type) \
1294#define sk_POLICYQUALINFO_sort(st) SKM_sk_sort(POLICYQUALINFO, (st)) 1436#define sk_POLICYQUALINFO_sort(st) SKM_sk_sort(POLICYQUALINFO, (st))
1295#define sk_POLICYQUALINFO_is_sorted(st) SKM_sk_is_sorted(POLICYQUALINFO, (st)) 1437#define sk_POLICYQUALINFO_is_sorted(st) SKM_sk_is_sorted(POLICYQUALINFO, (st))
1296 1438
1297#define sk_POLICY_MAPPING_new(st) SKM_sk_new(POLICY_MAPPING, (st)) 1439#define sk_POLICY_MAPPING_new(cmp) SKM_sk_new(POLICY_MAPPING, (cmp))
1298#define sk_POLICY_MAPPING_new_null() SKM_sk_new_null(POLICY_MAPPING) 1440#define sk_POLICY_MAPPING_new_null() SKM_sk_new_null(POLICY_MAPPING)
1299#define sk_POLICY_MAPPING_free(st) SKM_sk_free(POLICY_MAPPING, (st)) 1441#define sk_POLICY_MAPPING_free(st) SKM_sk_free(POLICY_MAPPING, (st))
1300#define sk_POLICY_MAPPING_num(st) SKM_sk_num(POLICY_MAPPING, (st)) 1442#define sk_POLICY_MAPPING_num(st) SKM_sk_num(POLICY_MAPPING, (st))
@@ -1316,7 +1458,7 @@ STACK_OF(type) \
1316#define sk_POLICY_MAPPING_sort(st) SKM_sk_sort(POLICY_MAPPING, (st)) 1458#define sk_POLICY_MAPPING_sort(st) SKM_sk_sort(POLICY_MAPPING, (st))
1317#define sk_POLICY_MAPPING_is_sorted(st) SKM_sk_is_sorted(POLICY_MAPPING, (st)) 1459#define sk_POLICY_MAPPING_is_sorted(st) SKM_sk_is_sorted(POLICY_MAPPING, (st))
1318 1460
1319#define sk_SSL_CIPHER_new(st) SKM_sk_new(SSL_CIPHER, (st)) 1461#define sk_SSL_CIPHER_new(cmp) SKM_sk_new(SSL_CIPHER, (cmp))
1320#define sk_SSL_CIPHER_new_null() SKM_sk_new_null(SSL_CIPHER) 1462#define sk_SSL_CIPHER_new_null() SKM_sk_new_null(SSL_CIPHER)
1321#define sk_SSL_CIPHER_free(st) SKM_sk_free(SSL_CIPHER, (st)) 1463#define sk_SSL_CIPHER_free(st) SKM_sk_free(SSL_CIPHER, (st))
1322#define sk_SSL_CIPHER_num(st) SKM_sk_num(SSL_CIPHER, (st)) 1464#define sk_SSL_CIPHER_num(st) SKM_sk_num(SSL_CIPHER, (st))
@@ -1338,7 +1480,7 @@ STACK_OF(type) \
1338#define sk_SSL_CIPHER_sort(st) SKM_sk_sort(SSL_CIPHER, (st)) 1480#define sk_SSL_CIPHER_sort(st) SKM_sk_sort(SSL_CIPHER, (st))
1339#define sk_SSL_CIPHER_is_sorted(st) SKM_sk_is_sorted(SSL_CIPHER, (st)) 1481#define sk_SSL_CIPHER_is_sorted(st) SKM_sk_is_sorted(SSL_CIPHER, (st))
1340 1482
1341#define sk_SSL_COMP_new(st) SKM_sk_new(SSL_COMP, (st)) 1483#define sk_SSL_COMP_new(cmp) SKM_sk_new(SSL_COMP, (cmp))
1342#define sk_SSL_COMP_new_null() SKM_sk_new_null(SSL_COMP) 1484#define sk_SSL_COMP_new_null() SKM_sk_new_null(SSL_COMP)
1343#define sk_SSL_COMP_free(st) SKM_sk_free(SSL_COMP, (st)) 1485#define sk_SSL_COMP_free(st) SKM_sk_free(SSL_COMP, (st))
1344#define sk_SSL_COMP_num(st) SKM_sk_num(SSL_COMP, (st)) 1486#define sk_SSL_COMP_num(st) SKM_sk_num(SSL_COMP, (st))
@@ -1360,7 +1502,51 @@ STACK_OF(type) \
1360#define sk_SSL_COMP_sort(st) SKM_sk_sort(SSL_COMP, (st)) 1502#define sk_SSL_COMP_sort(st) SKM_sk_sort(SSL_COMP, (st))
1361#define sk_SSL_COMP_is_sorted(st) SKM_sk_is_sorted(SSL_COMP, (st)) 1503#define sk_SSL_COMP_is_sorted(st) SKM_sk_is_sorted(SSL_COMP, (st))
1362 1504
1363#define sk_STORE_OBJECT_new(st) SKM_sk_new(STORE_OBJECT, (st)) 1505#define sk_STACK_OF_X509_NAME_ENTRY_new(cmp) SKM_sk_new(STACK_OF_X509_NAME_ENTRY, (cmp))
1506#define sk_STACK_OF_X509_NAME_ENTRY_new_null() SKM_sk_new_null(STACK_OF_X509_NAME_ENTRY)
1507#define sk_STACK_OF_X509_NAME_ENTRY_free(st) SKM_sk_free(STACK_OF_X509_NAME_ENTRY, (st))
1508#define sk_STACK_OF_X509_NAME_ENTRY_num(st) SKM_sk_num(STACK_OF_X509_NAME_ENTRY, (st))
1509#define sk_STACK_OF_X509_NAME_ENTRY_value(st, i) SKM_sk_value(STACK_OF_X509_NAME_ENTRY, (st), (i))
1510#define sk_STACK_OF_X509_NAME_ENTRY_set(st, i, val) SKM_sk_set(STACK_OF_X509_NAME_ENTRY, (st), (i), (val))
1511#define sk_STACK_OF_X509_NAME_ENTRY_zero(st) SKM_sk_zero(STACK_OF_X509_NAME_ENTRY, (st))
1512#define sk_STACK_OF_X509_NAME_ENTRY_push(st, val) SKM_sk_push(STACK_OF_X509_NAME_ENTRY, (st), (val))
1513#define sk_STACK_OF_X509_NAME_ENTRY_unshift(st, val) SKM_sk_unshift(STACK_OF_X509_NAME_ENTRY, (st), (val))
1514#define sk_STACK_OF_X509_NAME_ENTRY_find(st, val) SKM_sk_find(STACK_OF_X509_NAME_ENTRY, (st), (val))
1515#define sk_STACK_OF_X509_NAME_ENTRY_find_ex(st, val) SKM_sk_find_ex(STACK_OF_X509_NAME_ENTRY, (st), (val))
1516#define sk_STACK_OF_X509_NAME_ENTRY_delete(st, i) SKM_sk_delete(STACK_OF_X509_NAME_ENTRY, (st), (i))
1517#define sk_STACK_OF_X509_NAME_ENTRY_delete_ptr(st, ptr) SKM_sk_delete_ptr(STACK_OF_X509_NAME_ENTRY, (st), (ptr))
1518#define sk_STACK_OF_X509_NAME_ENTRY_insert(st, val, i) SKM_sk_insert(STACK_OF_X509_NAME_ENTRY, (st), (val), (i))
1519#define sk_STACK_OF_X509_NAME_ENTRY_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(STACK_OF_X509_NAME_ENTRY, (st), (cmp))
1520#define sk_STACK_OF_X509_NAME_ENTRY_dup(st) SKM_sk_dup(STACK_OF_X509_NAME_ENTRY, st)
1521#define sk_STACK_OF_X509_NAME_ENTRY_pop_free(st, free_func) SKM_sk_pop_free(STACK_OF_X509_NAME_ENTRY, (st), (free_func))
1522#define sk_STACK_OF_X509_NAME_ENTRY_shift(st) SKM_sk_shift(STACK_OF_X509_NAME_ENTRY, (st))
1523#define sk_STACK_OF_X509_NAME_ENTRY_pop(st) SKM_sk_pop(STACK_OF_X509_NAME_ENTRY, (st))
1524#define sk_STACK_OF_X509_NAME_ENTRY_sort(st) SKM_sk_sort(STACK_OF_X509_NAME_ENTRY, (st))
1525#define sk_STACK_OF_X509_NAME_ENTRY_is_sorted(st) SKM_sk_is_sorted(STACK_OF_X509_NAME_ENTRY, (st))
1526
1527#define sk_STORE_ATTR_INFO_new(cmp) SKM_sk_new(STORE_ATTR_INFO, (cmp))
1528#define sk_STORE_ATTR_INFO_new_null() SKM_sk_new_null(STORE_ATTR_INFO)
1529#define sk_STORE_ATTR_INFO_free(st) SKM_sk_free(STORE_ATTR_INFO, (st))
1530#define sk_STORE_ATTR_INFO_num(st) SKM_sk_num(STORE_ATTR_INFO, (st))
1531#define sk_STORE_ATTR_INFO_value(st, i) SKM_sk_value(STORE_ATTR_INFO, (st), (i))
1532#define sk_STORE_ATTR_INFO_set(st, i, val) SKM_sk_set(STORE_ATTR_INFO, (st), (i), (val))
1533#define sk_STORE_ATTR_INFO_zero(st) SKM_sk_zero(STORE_ATTR_INFO, (st))
1534#define sk_STORE_ATTR_INFO_push(st, val) SKM_sk_push(STORE_ATTR_INFO, (st), (val))
1535#define sk_STORE_ATTR_INFO_unshift(st, val) SKM_sk_unshift(STORE_ATTR_INFO, (st), (val))
1536#define sk_STORE_ATTR_INFO_find(st, val) SKM_sk_find(STORE_ATTR_INFO, (st), (val))
1537#define sk_STORE_ATTR_INFO_find_ex(st, val) SKM_sk_find_ex(STORE_ATTR_INFO, (st), (val))
1538#define sk_STORE_ATTR_INFO_delete(st, i) SKM_sk_delete(STORE_ATTR_INFO, (st), (i))
1539#define sk_STORE_ATTR_INFO_delete_ptr(st, ptr) SKM_sk_delete_ptr(STORE_ATTR_INFO, (st), (ptr))
1540#define sk_STORE_ATTR_INFO_insert(st, val, i) SKM_sk_insert(STORE_ATTR_INFO, (st), (val), (i))
1541#define sk_STORE_ATTR_INFO_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(STORE_ATTR_INFO, (st), (cmp))
1542#define sk_STORE_ATTR_INFO_dup(st) SKM_sk_dup(STORE_ATTR_INFO, st)
1543#define sk_STORE_ATTR_INFO_pop_free(st, free_func) SKM_sk_pop_free(STORE_ATTR_INFO, (st), (free_func))
1544#define sk_STORE_ATTR_INFO_shift(st) SKM_sk_shift(STORE_ATTR_INFO, (st))
1545#define sk_STORE_ATTR_INFO_pop(st) SKM_sk_pop(STORE_ATTR_INFO, (st))
1546#define sk_STORE_ATTR_INFO_sort(st) SKM_sk_sort(STORE_ATTR_INFO, (st))
1547#define sk_STORE_ATTR_INFO_is_sorted(st) SKM_sk_is_sorted(STORE_ATTR_INFO, (st))
1548
1549#define sk_STORE_OBJECT_new(cmp) SKM_sk_new(STORE_OBJECT, (cmp))
1364#define sk_STORE_OBJECT_new_null() SKM_sk_new_null(STORE_OBJECT) 1550#define sk_STORE_OBJECT_new_null() SKM_sk_new_null(STORE_OBJECT)
1365#define sk_STORE_OBJECT_free(st) SKM_sk_free(STORE_OBJECT, (st)) 1551#define sk_STORE_OBJECT_free(st) SKM_sk_free(STORE_OBJECT, (st))
1366#define sk_STORE_OBJECT_num(st) SKM_sk_num(STORE_OBJECT, (st)) 1552#define sk_STORE_OBJECT_num(st) SKM_sk_num(STORE_OBJECT, (st))
@@ -1382,7 +1568,7 @@ STACK_OF(type) \
1382#define sk_STORE_OBJECT_sort(st) SKM_sk_sort(STORE_OBJECT, (st)) 1568#define sk_STORE_OBJECT_sort(st) SKM_sk_sort(STORE_OBJECT, (st))
1383#define sk_STORE_OBJECT_is_sorted(st) SKM_sk_is_sorted(STORE_OBJECT, (st)) 1569#define sk_STORE_OBJECT_is_sorted(st) SKM_sk_is_sorted(STORE_OBJECT, (st))
1384 1570
1385#define sk_SXNETID_new(st) SKM_sk_new(SXNETID, (st)) 1571#define sk_SXNETID_new(cmp) SKM_sk_new(SXNETID, (cmp))
1386#define sk_SXNETID_new_null() SKM_sk_new_null(SXNETID) 1572#define sk_SXNETID_new_null() SKM_sk_new_null(SXNETID)
1387#define sk_SXNETID_free(st) SKM_sk_free(SXNETID, (st)) 1573#define sk_SXNETID_free(st) SKM_sk_free(SXNETID, (st))
1388#define sk_SXNETID_num(st) SKM_sk_num(SXNETID, (st)) 1574#define sk_SXNETID_num(st) SKM_sk_num(SXNETID, (st))
@@ -1404,7 +1590,7 @@ STACK_OF(type) \
1404#define sk_SXNETID_sort(st) SKM_sk_sort(SXNETID, (st)) 1590#define sk_SXNETID_sort(st) SKM_sk_sort(SXNETID, (st))
1405#define sk_SXNETID_is_sorted(st) SKM_sk_is_sorted(SXNETID, (st)) 1591#define sk_SXNETID_is_sorted(st) SKM_sk_is_sorted(SXNETID, (st))
1406 1592
1407#define sk_UI_STRING_new(st) SKM_sk_new(UI_STRING, (st)) 1593#define sk_UI_STRING_new(cmp) SKM_sk_new(UI_STRING, (cmp))
1408#define sk_UI_STRING_new_null() SKM_sk_new_null(UI_STRING) 1594#define sk_UI_STRING_new_null() SKM_sk_new_null(UI_STRING)
1409#define sk_UI_STRING_free(st) SKM_sk_free(UI_STRING, (st)) 1595#define sk_UI_STRING_free(st) SKM_sk_free(UI_STRING, (st))
1410#define sk_UI_STRING_num(st) SKM_sk_num(UI_STRING, (st)) 1596#define sk_UI_STRING_num(st) SKM_sk_num(UI_STRING, (st))
@@ -1426,7 +1612,7 @@ STACK_OF(type) \
1426#define sk_UI_STRING_sort(st) SKM_sk_sort(UI_STRING, (st)) 1612#define sk_UI_STRING_sort(st) SKM_sk_sort(UI_STRING, (st))
1427#define sk_UI_STRING_is_sorted(st) SKM_sk_is_sorted(UI_STRING, (st)) 1613#define sk_UI_STRING_is_sorted(st) SKM_sk_is_sorted(UI_STRING, (st))
1428 1614
1429#define sk_X509_new(st) SKM_sk_new(X509, (st)) 1615#define sk_X509_new(cmp) SKM_sk_new(X509, (cmp))
1430#define sk_X509_new_null() SKM_sk_new_null(X509) 1616#define sk_X509_new_null() SKM_sk_new_null(X509)
1431#define sk_X509_free(st) SKM_sk_free(X509, (st)) 1617#define sk_X509_free(st) SKM_sk_free(X509, (st))
1432#define sk_X509_num(st) SKM_sk_num(X509, (st)) 1618#define sk_X509_num(st) SKM_sk_num(X509, (st))
@@ -1448,7 +1634,7 @@ STACK_OF(type) \
1448#define sk_X509_sort(st) SKM_sk_sort(X509, (st)) 1634#define sk_X509_sort(st) SKM_sk_sort(X509, (st))
1449#define sk_X509_is_sorted(st) SKM_sk_is_sorted(X509, (st)) 1635#define sk_X509_is_sorted(st) SKM_sk_is_sorted(X509, (st))
1450 1636
1451#define sk_X509V3_EXT_METHOD_new(st) SKM_sk_new(X509V3_EXT_METHOD, (st)) 1637#define sk_X509V3_EXT_METHOD_new(cmp) SKM_sk_new(X509V3_EXT_METHOD, (cmp))
1452#define sk_X509V3_EXT_METHOD_new_null() SKM_sk_new_null(X509V3_EXT_METHOD) 1638#define sk_X509V3_EXT_METHOD_new_null() SKM_sk_new_null(X509V3_EXT_METHOD)
1453#define sk_X509V3_EXT_METHOD_free(st) SKM_sk_free(X509V3_EXT_METHOD, (st)) 1639#define sk_X509V3_EXT_METHOD_free(st) SKM_sk_free(X509V3_EXT_METHOD, (st))
1454#define sk_X509V3_EXT_METHOD_num(st) SKM_sk_num(X509V3_EXT_METHOD, (st)) 1640#define sk_X509V3_EXT_METHOD_num(st) SKM_sk_num(X509V3_EXT_METHOD, (st))
@@ -1470,7 +1656,7 @@ STACK_OF(type) \
1470#define sk_X509V3_EXT_METHOD_sort(st) SKM_sk_sort(X509V3_EXT_METHOD, (st)) 1656#define sk_X509V3_EXT_METHOD_sort(st) SKM_sk_sort(X509V3_EXT_METHOD, (st))
1471#define sk_X509V3_EXT_METHOD_is_sorted(st) SKM_sk_is_sorted(X509V3_EXT_METHOD, (st)) 1657#define sk_X509V3_EXT_METHOD_is_sorted(st) SKM_sk_is_sorted(X509V3_EXT_METHOD, (st))
1472 1658
1473#define sk_X509_ALGOR_new(st) SKM_sk_new(X509_ALGOR, (st)) 1659#define sk_X509_ALGOR_new(cmp) SKM_sk_new(X509_ALGOR, (cmp))
1474#define sk_X509_ALGOR_new_null() SKM_sk_new_null(X509_ALGOR) 1660#define sk_X509_ALGOR_new_null() SKM_sk_new_null(X509_ALGOR)
1475#define sk_X509_ALGOR_free(st) SKM_sk_free(X509_ALGOR, (st)) 1661#define sk_X509_ALGOR_free(st) SKM_sk_free(X509_ALGOR, (st))
1476#define sk_X509_ALGOR_num(st) SKM_sk_num(X509_ALGOR, (st)) 1662#define sk_X509_ALGOR_num(st) SKM_sk_num(X509_ALGOR, (st))
@@ -1492,7 +1678,7 @@ STACK_OF(type) \
1492#define sk_X509_ALGOR_sort(st) SKM_sk_sort(X509_ALGOR, (st)) 1678#define sk_X509_ALGOR_sort(st) SKM_sk_sort(X509_ALGOR, (st))
1493#define sk_X509_ALGOR_is_sorted(st) SKM_sk_is_sorted(X509_ALGOR, (st)) 1679#define sk_X509_ALGOR_is_sorted(st) SKM_sk_is_sorted(X509_ALGOR, (st))
1494 1680
1495#define sk_X509_ATTRIBUTE_new(st) SKM_sk_new(X509_ATTRIBUTE, (st)) 1681#define sk_X509_ATTRIBUTE_new(cmp) SKM_sk_new(X509_ATTRIBUTE, (cmp))
1496#define sk_X509_ATTRIBUTE_new_null() SKM_sk_new_null(X509_ATTRIBUTE) 1682#define sk_X509_ATTRIBUTE_new_null() SKM_sk_new_null(X509_ATTRIBUTE)
1497#define sk_X509_ATTRIBUTE_free(st) SKM_sk_free(X509_ATTRIBUTE, (st)) 1683#define sk_X509_ATTRIBUTE_free(st) SKM_sk_free(X509_ATTRIBUTE, (st))
1498#define sk_X509_ATTRIBUTE_num(st) SKM_sk_num(X509_ATTRIBUTE, (st)) 1684#define sk_X509_ATTRIBUTE_num(st) SKM_sk_num(X509_ATTRIBUTE, (st))
@@ -1514,7 +1700,7 @@ STACK_OF(type) \
1514#define sk_X509_ATTRIBUTE_sort(st) SKM_sk_sort(X509_ATTRIBUTE, (st)) 1700#define sk_X509_ATTRIBUTE_sort(st) SKM_sk_sort(X509_ATTRIBUTE, (st))
1515#define sk_X509_ATTRIBUTE_is_sorted(st) SKM_sk_is_sorted(X509_ATTRIBUTE, (st)) 1701#define sk_X509_ATTRIBUTE_is_sorted(st) SKM_sk_is_sorted(X509_ATTRIBUTE, (st))
1516 1702
1517#define sk_X509_CRL_new(st) SKM_sk_new(X509_CRL, (st)) 1703#define sk_X509_CRL_new(cmp) SKM_sk_new(X509_CRL, (cmp))
1518#define sk_X509_CRL_new_null() SKM_sk_new_null(X509_CRL) 1704#define sk_X509_CRL_new_null() SKM_sk_new_null(X509_CRL)
1519#define sk_X509_CRL_free(st) SKM_sk_free(X509_CRL, (st)) 1705#define sk_X509_CRL_free(st) SKM_sk_free(X509_CRL, (st))
1520#define sk_X509_CRL_num(st) SKM_sk_num(X509_CRL, (st)) 1706#define sk_X509_CRL_num(st) SKM_sk_num(X509_CRL, (st))
@@ -1536,7 +1722,7 @@ STACK_OF(type) \
1536#define sk_X509_CRL_sort(st) SKM_sk_sort(X509_CRL, (st)) 1722#define sk_X509_CRL_sort(st) SKM_sk_sort(X509_CRL, (st))
1537#define sk_X509_CRL_is_sorted(st) SKM_sk_is_sorted(X509_CRL, (st)) 1723#define sk_X509_CRL_is_sorted(st) SKM_sk_is_sorted(X509_CRL, (st))
1538 1724
1539#define sk_X509_EXTENSION_new(st) SKM_sk_new(X509_EXTENSION, (st)) 1725#define sk_X509_EXTENSION_new(cmp) SKM_sk_new(X509_EXTENSION, (cmp))
1540#define sk_X509_EXTENSION_new_null() SKM_sk_new_null(X509_EXTENSION) 1726#define sk_X509_EXTENSION_new_null() SKM_sk_new_null(X509_EXTENSION)
1541#define sk_X509_EXTENSION_free(st) SKM_sk_free(X509_EXTENSION, (st)) 1727#define sk_X509_EXTENSION_free(st) SKM_sk_free(X509_EXTENSION, (st))
1542#define sk_X509_EXTENSION_num(st) SKM_sk_num(X509_EXTENSION, (st)) 1728#define sk_X509_EXTENSION_num(st) SKM_sk_num(X509_EXTENSION, (st))
@@ -1558,7 +1744,7 @@ STACK_OF(type) \
1558#define sk_X509_EXTENSION_sort(st) SKM_sk_sort(X509_EXTENSION, (st)) 1744#define sk_X509_EXTENSION_sort(st) SKM_sk_sort(X509_EXTENSION, (st))
1559#define sk_X509_EXTENSION_is_sorted(st) SKM_sk_is_sorted(X509_EXTENSION, (st)) 1745#define sk_X509_EXTENSION_is_sorted(st) SKM_sk_is_sorted(X509_EXTENSION, (st))
1560 1746
1561#define sk_X509_INFO_new(st) SKM_sk_new(X509_INFO, (st)) 1747#define sk_X509_INFO_new(cmp) SKM_sk_new(X509_INFO, (cmp))
1562#define sk_X509_INFO_new_null() SKM_sk_new_null(X509_INFO) 1748#define sk_X509_INFO_new_null() SKM_sk_new_null(X509_INFO)
1563#define sk_X509_INFO_free(st) SKM_sk_free(X509_INFO, (st)) 1749#define sk_X509_INFO_free(st) SKM_sk_free(X509_INFO, (st))
1564#define sk_X509_INFO_num(st) SKM_sk_num(X509_INFO, (st)) 1750#define sk_X509_INFO_num(st) SKM_sk_num(X509_INFO, (st))
@@ -1580,7 +1766,7 @@ STACK_OF(type) \
1580#define sk_X509_INFO_sort(st) SKM_sk_sort(X509_INFO, (st)) 1766#define sk_X509_INFO_sort(st) SKM_sk_sort(X509_INFO, (st))
1581#define sk_X509_INFO_is_sorted(st) SKM_sk_is_sorted(X509_INFO, (st)) 1767#define sk_X509_INFO_is_sorted(st) SKM_sk_is_sorted(X509_INFO, (st))
1582 1768
1583#define sk_X509_LOOKUP_new(st) SKM_sk_new(X509_LOOKUP, (st)) 1769#define sk_X509_LOOKUP_new(cmp) SKM_sk_new(X509_LOOKUP, (cmp))
1584#define sk_X509_LOOKUP_new_null() SKM_sk_new_null(X509_LOOKUP) 1770#define sk_X509_LOOKUP_new_null() SKM_sk_new_null(X509_LOOKUP)
1585#define sk_X509_LOOKUP_free(st) SKM_sk_free(X509_LOOKUP, (st)) 1771#define sk_X509_LOOKUP_free(st) SKM_sk_free(X509_LOOKUP, (st))
1586#define sk_X509_LOOKUP_num(st) SKM_sk_num(X509_LOOKUP, (st)) 1772#define sk_X509_LOOKUP_num(st) SKM_sk_num(X509_LOOKUP, (st))
@@ -1602,7 +1788,7 @@ STACK_OF(type) \
1602#define sk_X509_LOOKUP_sort(st) SKM_sk_sort(X509_LOOKUP, (st)) 1788#define sk_X509_LOOKUP_sort(st) SKM_sk_sort(X509_LOOKUP, (st))
1603#define sk_X509_LOOKUP_is_sorted(st) SKM_sk_is_sorted(X509_LOOKUP, (st)) 1789#define sk_X509_LOOKUP_is_sorted(st) SKM_sk_is_sorted(X509_LOOKUP, (st))
1604 1790
1605#define sk_X509_NAME_new(st) SKM_sk_new(X509_NAME, (st)) 1791#define sk_X509_NAME_new(cmp) SKM_sk_new(X509_NAME, (cmp))
1606#define sk_X509_NAME_new_null() SKM_sk_new_null(X509_NAME) 1792#define sk_X509_NAME_new_null() SKM_sk_new_null(X509_NAME)
1607#define sk_X509_NAME_free(st) SKM_sk_free(X509_NAME, (st)) 1793#define sk_X509_NAME_free(st) SKM_sk_free(X509_NAME, (st))
1608#define sk_X509_NAME_num(st) SKM_sk_num(X509_NAME, (st)) 1794#define sk_X509_NAME_num(st) SKM_sk_num(X509_NAME, (st))
@@ -1624,7 +1810,7 @@ STACK_OF(type) \
1624#define sk_X509_NAME_sort(st) SKM_sk_sort(X509_NAME, (st)) 1810#define sk_X509_NAME_sort(st) SKM_sk_sort(X509_NAME, (st))
1625#define sk_X509_NAME_is_sorted(st) SKM_sk_is_sorted(X509_NAME, (st)) 1811#define sk_X509_NAME_is_sorted(st) SKM_sk_is_sorted(X509_NAME, (st))
1626 1812
1627#define sk_X509_NAME_ENTRY_new(st) SKM_sk_new(X509_NAME_ENTRY, (st)) 1813#define sk_X509_NAME_ENTRY_new(cmp) SKM_sk_new(X509_NAME_ENTRY, (cmp))
1628#define sk_X509_NAME_ENTRY_new_null() SKM_sk_new_null(X509_NAME_ENTRY) 1814#define sk_X509_NAME_ENTRY_new_null() SKM_sk_new_null(X509_NAME_ENTRY)
1629#define sk_X509_NAME_ENTRY_free(st) SKM_sk_free(X509_NAME_ENTRY, (st)) 1815#define sk_X509_NAME_ENTRY_free(st) SKM_sk_free(X509_NAME_ENTRY, (st))
1630#define sk_X509_NAME_ENTRY_num(st) SKM_sk_num(X509_NAME_ENTRY, (st)) 1816#define sk_X509_NAME_ENTRY_num(st) SKM_sk_num(X509_NAME_ENTRY, (st))
@@ -1646,7 +1832,7 @@ STACK_OF(type) \
1646#define sk_X509_NAME_ENTRY_sort(st) SKM_sk_sort(X509_NAME_ENTRY, (st)) 1832#define sk_X509_NAME_ENTRY_sort(st) SKM_sk_sort(X509_NAME_ENTRY, (st))
1647#define sk_X509_NAME_ENTRY_is_sorted(st) SKM_sk_is_sorted(X509_NAME_ENTRY, (st)) 1833#define sk_X509_NAME_ENTRY_is_sorted(st) SKM_sk_is_sorted(X509_NAME_ENTRY, (st))
1648 1834
1649#define sk_X509_OBJECT_new(st) SKM_sk_new(X509_OBJECT, (st)) 1835#define sk_X509_OBJECT_new(cmp) SKM_sk_new(X509_OBJECT, (cmp))
1650#define sk_X509_OBJECT_new_null() SKM_sk_new_null(X509_OBJECT) 1836#define sk_X509_OBJECT_new_null() SKM_sk_new_null(X509_OBJECT)
1651#define sk_X509_OBJECT_free(st) SKM_sk_free(X509_OBJECT, (st)) 1837#define sk_X509_OBJECT_free(st) SKM_sk_free(X509_OBJECT, (st))
1652#define sk_X509_OBJECT_num(st) SKM_sk_num(X509_OBJECT, (st)) 1838#define sk_X509_OBJECT_num(st) SKM_sk_num(X509_OBJECT, (st))
@@ -1668,7 +1854,7 @@ STACK_OF(type) \
1668#define sk_X509_OBJECT_sort(st) SKM_sk_sort(X509_OBJECT, (st)) 1854#define sk_X509_OBJECT_sort(st) SKM_sk_sort(X509_OBJECT, (st))
1669#define sk_X509_OBJECT_is_sorted(st) SKM_sk_is_sorted(X509_OBJECT, (st)) 1855#define sk_X509_OBJECT_is_sorted(st) SKM_sk_is_sorted(X509_OBJECT, (st))
1670 1856
1671#define sk_X509_POLICY_DATA_new(st) SKM_sk_new(X509_POLICY_DATA, (st)) 1857#define sk_X509_POLICY_DATA_new(cmp) SKM_sk_new(X509_POLICY_DATA, (cmp))
1672#define sk_X509_POLICY_DATA_new_null() SKM_sk_new_null(X509_POLICY_DATA) 1858#define sk_X509_POLICY_DATA_new_null() SKM_sk_new_null(X509_POLICY_DATA)
1673#define sk_X509_POLICY_DATA_free(st) SKM_sk_free(X509_POLICY_DATA, (st)) 1859#define sk_X509_POLICY_DATA_free(st) SKM_sk_free(X509_POLICY_DATA, (st))
1674#define sk_X509_POLICY_DATA_num(st) SKM_sk_num(X509_POLICY_DATA, (st)) 1860#define sk_X509_POLICY_DATA_num(st) SKM_sk_num(X509_POLICY_DATA, (st))
@@ -1690,7 +1876,7 @@ STACK_OF(type) \
1690#define sk_X509_POLICY_DATA_sort(st) SKM_sk_sort(X509_POLICY_DATA, (st)) 1876#define sk_X509_POLICY_DATA_sort(st) SKM_sk_sort(X509_POLICY_DATA, (st))
1691#define sk_X509_POLICY_DATA_is_sorted(st) SKM_sk_is_sorted(X509_POLICY_DATA, (st)) 1877#define sk_X509_POLICY_DATA_is_sorted(st) SKM_sk_is_sorted(X509_POLICY_DATA, (st))
1692 1878
1693#define sk_X509_POLICY_NODE_new(st) SKM_sk_new(X509_POLICY_NODE, (st)) 1879#define sk_X509_POLICY_NODE_new(cmp) SKM_sk_new(X509_POLICY_NODE, (cmp))
1694#define sk_X509_POLICY_NODE_new_null() SKM_sk_new_null(X509_POLICY_NODE) 1880#define sk_X509_POLICY_NODE_new_null() SKM_sk_new_null(X509_POLICY_NODE)
1695#define sk_X509_POLICY_NODE_free(st) SKM_sk_free(X509_POLICY_NODE, (st)) 1881#define sk_X509_POLICY_NODE_free(st) SKM_sk_free(X509_POLICY_NODE, (st))
1696#define sk_X509_POLICY_NODE_num(st) SKM_sk_num(X509_POLICY_NODE, (st)) 1882#define sk_X509_POLICY_NODE_num(st) SKM_sk_num(X509_POLICY_NODE, (st))
@@ -1712,29 +1898,7 @@ STACK_OF(type) \
1712#define sk_X509_POLICY_NODE_sort(st) SKM_sk_sort(X509_POLICY_NODE, (st)) 1898#define sk_X509_POLICY_NODE_sort(st) SKM_sk_sort(X509_POLICY_NODE, (st))
1713#define sk_X509_POLICY_NODE_is_sorted(st) SKM_sk_is_sorted(X509_POLICY_NODE, (st)) 1899#define sk_X509_POLICY_NODE_is_sorted(st) SKM_sk_is_sorted(X509_POLICY_NODE, (st))
1714 1900
1715#define sk_X509_POLICY_REF_new(st) SKM_sk_new(X509_POLICY_REF, (st)) 1901#define sk_X509_PURPOSE_new(cmp) SKM_sk_new(X509_PURPOSE, (cmp))
1716#define sk_X509_POLICY_REF_new_null() SKM_sk_new_null(X509_POLICY_REF)
1717#define sk_X509_POLICY_REF_free(st) SKM_sk_free(X509_POLICY_REF, (st))
1718#define sk_X509_POLICY_REF_num(st) SKM_sk_num(X509_POLICY_REF, (st))
1719#define sk_X509_POLICY_REF_value(st, i) SKM_sk_value(X509_POLICY_REF, (st), (i))
1720#define sk_X509_POLICY_REF_set(st, i, val) SKM_sk_set(X509_POLICY_REF, (st), (i), (val))
1721#define sk_X509_POLICY_REF_zero(st) SKM_sk_zero(X509_POLICY_REF, (st))
1722#define sk_X509_POLICY_REF_push(st, val) SKM_sk_push(X509_POLICY_REF, (st), (val))
1723#define sk_X509_POLICY_REF_unshift(st, val) SKM_sk_unshift(X509_POLICY_REF, (st), (val))
1724#define sk_X509_POLICY_REF_find(st, val) SKM_sk_find(X509_POLICY_REF, (st), (val))
1725#define sk_X509_POLICY_REF_find_ex(st, val) SKM_sk_find_ex(X509_POLICY_REF, (st), (val))
1726#define sk_X509_POLICY_REF_delete(st, i) SKM_sk_delete(X509_POLICY_REF, (st), (i))
1727#define sk_X509_POLICY_REF_delete_ptr(st, ptr) SKM_sk_delete_ptr(X509_POLICY_REF, (st), (ptr))
1728#define sk_X509_POLICY_REF_insert(st, val, i) SKM_sk_insert(X509_POLICY_REF, (st), (val), (i))
1729#define sk_X509_POLICY_REF_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(X509_POLICY_REF, (st), (cmp))
1730#define sk_X509_POLICY_REF_dup(st) SKM_sk_dup(X509_POLICY_REF, st)
1731#define sk_X509_POLICY_REF_pop_free(st, free_func) SKM_sk_pop_free(X509_POLICY_REF, (st), (free_func))
1732#define sk_X509_POLICY_REF_shift(st) SKM_sk_shift(X509_POLICY_REF, (st))
1733#define sk_X509_POLICY_REF_pop(st) SKM_sk_pop(X509_POLICY_REF, (st))
1734#define sk_X509_POLICY_REF_sort(st) SKM_sk_sort(X509_POLICY_REF, (st))
1735#define sk_X509_POLICY_REF_is_sorted(st) SKM_sk_is_sorted(X509_POLICY_REF, (st))
1736
1737#define sk_X509_PURPOSE_new(st) SKM_sk_new(X509_PURPOSE, (st))
1738#define sk_X509_PURPOSE_new_null() SKM_sk_new_null(X509_PURPOSE) 1902#define sk_X509_PURPOSE_new_null() SKM_sk_new_null(X509_PURPOSE)
1739#define sk_X509_PURPOSE_free(st) SKM_sk_free(X509_PURPOSE, (st)) 1903#define sk_X509_PURPOSE_free(st) SKM_sk_free(X509_PURPOSE, (st))
1740#define sk_X509_PURPOSE_num(st) SKM_sk_num(X509_PURPOSE, (st)) 1904#define sk_X509_PURPOSE_num(st) SKM_sk_num(X509_PURPOSE, (st))
@@ -1756,7 +1920,7 @@ STACK_OF(type) \
1756#define sk_X509_PURPOSE_sort(st) SKM_sk_sort(X509_PURPOSE, (st)) 1920#define sk_X509_PURPOSE_sort(st) SKM_sk_sort(X509_PURPOSE, (st))
1757#define sk_X509_PURPOSE_is_sorted(st) SKM_sk_is_sorted(X509_PURPOSE, (st)) 1921#define sk_X509_PURPOSE_is_sorted(st) SKM_sk_is_sorted(X509_PURPOSE, (st))
1758 1922
1759#define sk_X509_REVOKED_new(st) SKM_sk_new(X509_REVOKED, (st)) 1923#define sk_X509_REVOKED_new(cmp) SKM_sk_new(X509_REVOKED, (cmp))
1760#define sk_X509_REVOKED_new_null() SKM_sk_new_null(X509_REVOKED) 1924#define sk_X509_REVOKED_new_null() SKM_sk_new_null(X509_REVOKED)
1761#define sk_X509_REVOKED_free(st) SKM_sk_free(X509_REVOKED, (st)) 1925#define sk_X509_REVOKED_free(st) SKM_sk_free(X509_REVOKED, (st))
1762#define sk_X509_REVOKED_num(st) SKM_sk_num(X509_REVOKED, (st)) 1926#define sk_X509_REVOKED_num(st) SKM_sk_num(X509_REVOKED, (st))
@@ -1778,7 +1942,7 @@ STACK_OF(type) \
1778#define sk_X509_REVOKED_sort(st) SKM_sk_sort(X509_REVOKED, (st)) 1942#define sk_X509_REVOKED_sort(st) SKM_sk_sort(X509_REVOKED, (st))
1779#define sk_X509_REVOKED_is_sorted(st) SKM_sk_is_sorted(X509_REVOKED, (st)) 1943#define sk_X509_REVOKED_is_sorted(st) SKM_sk_is_sorted(X509_REVOKED, (st))
1780 1944
1781#define sk_X509_TRUST_new(st) SKM_sk_new(X509_TRUST, (st)) 1945#define sk_X509_TRUST_new(cmp) SKM_sk_new(X509_TRUST, (cmp))
1782#define sk_X509_TRUST_new_null() SKM_sk_new_null(X509_TRUST) 1946#define sk_X509_TRUST_new_null() SKM_sk_new_null(X509_TRUST)
1783#define sk_X509_TRUST_free(st) SKM_sk_free(X509_TRUST, (st)) 1947#define sk_X509_TRUST_free(st) SKM_sk_free(X509_TRUST, (st))
1784#define sk_X509_TRUST_num(st) SKM_sk_num(X509_TRUST, (st)) 1948#define sk_X509_TRUST_num(st) SKM_sk_num(X509_TRUST, (st))
@@ -1800,7 +1964,7 @@ STACK_OF(type) \
1800#define sk_X509_TRUST_sort(st) SKM_sk_sort(X509_TRUST, (st)) 1964#define sk_X509_TRUST_sort(st) SKM_sk_sort(X509_TRUST, (st))
1801#define sk_X509_TRUST_is_sorted(st) SKM_sk_is_sorted(X509_TRUST, (st)) 1965#define sk_X509_TRUST_is_sorted(st) SKM_sk_is_sorted(X509_TRUST, (st))
1802 1966
1803#define sk_X509_VERIFY_PARAM_new(st) SKM_sk_new(X509_VERIFY_PARAM, (st)) 1967#define sk_X509_VERIFY_PARAM_new(cmp) SKM_sk_new(X509_VERIFY_PARAM, (cmp))
1804#define sk_X509_VERIFY_PARAM_new_null() SKM_sk_new_null(X509_VERIFY_PARAM) 1968#define sk_X509_VERIFY_PARAM_new_null() SKM_sk_new_null(X509_VERIFY_PARAM)
1805#define sk_X509_VERIFY_PARAM_free(st) SKM_sk_free(X509_VERIFY_PARAM, (st)) 1969#define sk_X509_VERIFY_PARAM_free(st) SKM_sk_free(X509_VERIFY_PARAM, (st))
1806#define sk_X509_VERIFY_PARAM_num(st) SKM_sk_num(X509_VERIFY_PARAM, (st)) 1970#define sk_X509_VERIFY_PARAM_num(st) SKM_sk_num(X509_VERIFY_PARAM, (st))
@@ -1822,6 +1986,125 @@ STACK_OF(type) \
1822#define sk_X509_VERIFY_PARAM_sort(st) SKM_sk_sort(X509_VERIFY_PARAM, (st)) 1986#define sk_X509_VERIFY_PARAM_sort(st) SKM_sk_sort(X509_VERIFY_PARAM, (st))
1823#define sk_X509_VERIFY_PARAM_is_sorted(st) SKM_sk_is_sorted(X509_VERIFY_PARAM, (st)) 1987#define sk_X509_VERIFY_PARAM_is_sorted(st) SKM_sk_is_sorted(X509_VERIFY_PARAM, (st))
1824 1988
1989#define sk_nid_triple_new(cmp) SKM_sk_new(nid_triple, (cmp))
1990#define sk_nid_triple_new_null() SKM_sk_new_null(nid_triple)
1991#define sk_nid_triple_free(st) SKM_sk_free(nid_triple, (st))
1992#define sk_nid_triple_num(st) SKM_sk_num(nid_triple, (st))
1993#define sk_nid_triple_value(st, i) SKM_sk_value(nid_triple, (st), (i))
1994#define sk_nid_triple_set(st, i, val) SKM_sk_set(nid_triple, (st), (i), (val))
1995#define sk_nid_triple_zero(st) SKM_sk_zero(nid_triple, (st))
1996#define sk_nid_triple_push(st, val) SKM_sk_push(nid_triple, (st), (val))
1997#define sk_nid_triple_unshift(st, val) SKM_sk_unshift(nid_triple, (st), (val))
1998#define sk_nid_triple_find(st, val) SKM_sk_find(nid_triple, (st), (val))
1999#define sk_nid_triple_find_ex(st, val) SKM_sk_find_ex(nid_triple, (st), (val))
2000#define sk_nid_triple_delete(st, i) SKM_sk_delete(nid_triple, (st), (i))
2001#define sk_nid_triple_delete_ptr(st, ptr) SKM_sk_delete_ptr(nid_triple, (st), (ptr))
2002#define sk_nid_triple_insert(st, val, i) SKM_sk_insert(nid_triple, (st), (val), (i))
2003#define sk_nid_triple_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(nid_triple, (st), (cmp))
2004#define sk_nid_triple_dup(st) SKM_sk_dup(nid_triple, st)
2005#define sk_nid_triple_pop_free(st, free_func) SKM_sk_pop_free(nid_triple, (st), (free_func))
2006#define sk_nid_triple_shift(st) SKM_sk_shift(nid_triple, (st))
2007#define sk_nid_triple_pop(st) SKM_sk_pop(nid_triple, (st))
2008#define sk_nid_triple_sort(st) SKM_sk_sort(nid_triple, (st))
2009#define sk_nid_triple_is_sorted(st) SKM_sk_is_sorted(nid_triple, (st))
2010
2011#define sk_void_new(cmp) SKM_sk_new(void, (cmp))
2012#define sk_void_new_null() SKM_sk_new_null(void)
2013#define sk_void_free(st) SKM_sk_free(void, (st))
2014#define sk_void_num(st) SKM_sk_num(void, (st))
2015#define sk_void_value(st, i) SKM_sk_value(void, (st), (i))
2016#define sk_void_set(st, i, val) SKM_sk_set(void, (st), (i), (val))
2017#define sk_void_zero(st) SKM_sk_zero(void, (st))
2018#define sk_void_push(st, val) SKM_sk_push(void, (st), (val))
2019#define sk_void_unshift(st, val) SKM_sk_unshift(void, (st), (val))
2020#define sk_void_find(st, val) SKM_sk_find(void, (st), (val))
2021#define sk_void_find_ex(st, val) SKM_sk_find_ex(void, (st), (val))
2022#define sk_void_delete(st, i) SKM_sk_delete(void, (st), (i))
2023#define sk_void_delete_ptr(st, ptr) SKM_sk_delete_ptr(void, (st), (ptr))
2024#define sk_void_insert(st, val, i) SKM_sk_insert(void, (st), (val), (i))
2025#define sk_void_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(void, (st), (cmp))
2026#define sk_void_dup(st) SKM_sk_dup(void, st)
2027#define sk_void_pop_free(st, free_func) SKM_sk_pop_free(void, (st), (free_func))
2028#define sk_void_shift(st) SKM_sk_shift(void, (st))
2029#define sk_void_pop(st) SKM_sk_pop(void, (st))
2030#define sk_void_sort(st) SKM_sk_sort(void, (st))
2031#define sk_void_is_sorted(st) SKM_sk_is_sorted(void, (st))
2032
2033#define sk_OPENSSL_BLOCK_new(cmp) ((STACK_OF(OPENSSL_BLOCK) *)sk_new(CHECKED_SK_CMP_FUNC(void, cmp)))
2034#define sk_OPENSSL_BLOCK_new_null() ((STACK_OF(OPENSSL_BLOCK) *)sk_new_null())
2035#define sk_OPENSSL_BLOCK_push(st, val) sk_push(CHECKED_PTR_OF(STACK_OF(OPENSSL_BLOCK), st), CHECKED_PTR_OF(void, val))
2036#define sk_OPENSSL_BLOCK_find(st, val) sk_find(CHECKED_PTR_OF(STACK_OF(OPENSSL_BLOCK), st), CHECKED_PTR_OF(void, val))
2037#define sk_OPENSSL_BLOCK_value(st, i) ((OPENSSL_BLOCK)sk_value(CHECKED_PTR_OF(STACK_OF(OPENSSL_BLOCK), st), i))
2038#define sk_OPENSSL_BLOCK_num(st) SKM_sk_num(OPENSSL_BLOCK, st)
2039#define sk_OPENSSL_BLOCK_pop_free(st, free_func) sk_pop_free(CHECKED_PTR_OF(STACK_OF(OPENSSL_BLOCK), st), CHECKED_SK_FREE_FUNC2(OPENSSL_BLOCK, free_func))
2040#define sk_OPENSSL_BLOCK_insert(st, val, i) sk_insert(CHECKED_PTR_OF(STACK_OF(OPENSSL_BLOCK), st), CHECKED_PTR_OF(void, val), i)
2041#define sk_OPENSSL_BLOCK_free(st) SKM_sk_free(OPENSSL_BLOCK, st)
2042#define sk_OPENSSL_BLOCK_set(st, i, val) sk_set((_STACK *)CHECKED_PTR_OF(STACK_OF(OPENSSL_BLOCK), st), i, CHECKED_PTR_OF(void, val))
2043#define sk_OPENSSL_BLOCK_zero(st) SKM_sk_zero(OPENSSL_BLOCK, (st))
2044#define sk_OPENSSL_BLOCK_unshift(st, val) sk_unshift((_STACK *)CHECKED_PTR_OF(STACK_OF(OPENSSL_BLOCK), st), CHECKED_PTR_OF(void, val))
2045#define sk_OPENSSL_BLOCK_find_ex(st, val) sk_find_ex((_STACK *)CHECKED_CONST_PTR_OF(STACK_OF(OPENSSL_BLOCK), st), CHECKED_CONST_PTR_OF(void, val))
2046#define sk_OPENSSL_BLOCK_delete(st, i) SKM_sk_delete(OPENSSL_BLOCK, (st), (i))
2047#define sk_OPENSSL_BLOCK_delete_ptr(st, ptr) (OPENSSL_BLOCK *)sk_delete_ptr((_STACK *)CHECKED_PTR_OF(STACK_OF(OPENSSL_BLOCK), st), CHECKED_PTR_OF(void, ptr))
2048#define sk_OPENSSL_BLOCK_set_cmp_func(st, cmp) \
2049 ((int (*)(const void * const *,const void * const *)) \
2050 sk_set_cmp_func((_STACK *)CHECKED_PTR_OF(STACK_OF(OPENSSL_BLOCK), st), CHECKED_SK_CMP_FUNC(void, cmp)))
2051#define sk_OPENSSL_BLOCK_dup(st) SKM_sk_dup(OPENSSL_BLOCK, st)
2052#define sk_OPENSSL_BLOCK_shift(st) SKM_sk_shift(OPENSSL_BLOCK, (st))
2053#define sk_OPENSSL_BLOCK_pop(st) (void *)sk_pop((_STACK *)CHECKED_PTR_OF(STACK_OF(OPENSSL_BLOCK), st))
2054#define sk_OPENSSL_BLOCK_sort(st) SKM_sk_sort(OPENSSL_BLOCK, (st))
2055#define sk_OPENSSL_BLOCK_is_sorted(st) SKM_sk_is_sorted(OPENSSL_BLOCK, (st))
2056
2057
2058#define sk_OPENSSL_PSTRING_new(cmp) ((STACK_OF(OPENSSL_PSTRING) *)sk_new(CHECKED_SK_CMP_FUNC(OPENSSL_STRING, cmp)))
2059#define sk_OPENSSL_PSTRING_new_null() ((STACK_OF(OPENSSL_PSTRING) *)sk_new_null())
2060#define sk_OPENSSL_PSTRING_push(st, val) sk_push(CHECKED_PTR_OF(STACK_OF(OPENSSL_PSTRING), st), CHECKED_PTR_OF(OPENSSL_STRING, val))
2061#define sk_OPENSSL_PSTRING_find(st, val) sk_find(CHECKED_PTR_OF(STACK_OF(OPENSSL_PSTRING), st), CHECKED_PTR_OF(OPENSSL_STRING, val))
2062#define sk_OPENSSL_PSTRING_value(st, i) ((OPENSSL_PSTRING)sk_value(CHECKED_PTR_OF(STACK_OF(OPENSSL_PSTRING), st), i))
2063#define sk_OPENSSL_PSTRING_num(st) SKM_sk_num(OPENSSL_PSTRING, st)
2064#define sk_OPENSSL_PSTRING_pop_free(st, free_func) sk_pop_free(CHECKED_PTR_OF(STACK_OF(OPENSSL_PSTRING), st), CHECKED_SK_FREE_FUNC2(OPENSSL_PSTRING, free_func))
2065#define sk_OPENSSL_PSTRING_insert(st, val, i) sk_insert(CHECKED_PTR_OF(STACK_OF(OPENSSL_PSTRING), st), CHECKED_PTR_OF(OPENSSL_STRING, val), i)
2066#define sk_OPENSSL_PSTRING_free(st) SKM_sk_free(OPENSSL_PSTRING, st)
2067#define sk_OPENSSL_PSTRING_set(st, i, val) sk_set((_STACK *)CHECKED_PTR_OF(STACK_OF(OPENSSL_PSTRING), st), i, CHECKED_PTR_OF(OPENSSL_STRING, val))
2068#define sk_OPENSSL_PSTRING_zero(st) SKM_sk_zero(OPENSSL_PSTRING, (st))
2069#define sk_OPENSSL_PSTRING_unshift(st, val) sk_unshift((_STACK *)CHECKED_PTR_OF(STACK_OF(OPENSSL_PSTRING), st), CHECKED_PTR_OF(OPENSSL_STRING, val))
2070#define sk_OPENSSL_PSTRING_find_ex(st, val) sk_find_ex((_STACK *)CHECKED_CONST_PTR_OF(STACK_OF(OPENSSL_PSTRING), st), CHECKED_CONST_PTR_OF(OPENSSL_STRING, val))
2071#define sk_OPENSSL_PSTRING_delete(st, i) SKM_sk_delete(OPENSSL_PSTRING, (st), (i))
2072#define sk_OPENSSL_PSTRING_delete_ptr(st, ptr) (OPENSSL_PSTRING *)sk_delete_ptr((_STACK *)CHECKED_PTR_OF(STACK_OF(OPENSSL_PSTRING), st), CHECKED_PTR_OF(OPENSSL_STRING, ptr))
2073#define sk_OPENSSL_PSTRING_set_cmp_func(st, cmp) \
2074 ((int (*)(const OPENSSL_STRING * const *,const OPENSSL_STRING * const *)) \
2075 sk_set_cmp_func((_STACK *)CHECKED_PTR_OF(STACK_OF(OPENSSL_PSTRING), st), CHECKED_SK_CMP_FUNC(OPENSSL_STRING, cmp)))
2076#define sk_OPENSSL_PSTRING_dup(st) SKM_sk_dup(OPENSSL_PSTRING, st)
2077#define sk_OPENSSL_PSTRING_shift(st) SKM_sk_shift(OPENSSL_PSTRING, (st))
2078#define sk_OPENSSL_PSTRING_pop(st) (OPENSSL_STRING *)sk_pop((_STACK *)CHECKED_PTR_OF(STACK_OF(OPENSSL_PSTRING), st))
2079#define sk_OPENSSL_PSTRING_sort(st) SKM_sk_sort(OPENSSL_PSTRING, (st))
2080#define sk_OPENSSL_PSTRING_is_sorted(st) SKM_sk_is_sorted(OPENSSL_PSTRING, (st))
2081
2082
2083#define sk_OPENSSL_STRING_new(cmp) ((STACK_OF(OPENSSL_STRING) *)sk_new(CHECKED_SK_CMP_FUNC(char, cmp)))
2084#define sk_OPENSSL_STRING_new_null() ((STACK_OF(OPENSSL_STRING) *)sk_new_null())
2085#define sk_OPENSSL_STRING_push(st, val) sk_push(CHECKED_PTR_OF(STACK_OF(OPENSSL_STRING), st), CHECKED_PTR_OF(char, val))
2086#define sk_OPENSSL_STRING_find(st, val) sk_find(CHECKED_PTR_OF(STACK_OF(OPENSSL_STRING), st), CHECKED_PTR_OF(char, val))
2087#define sk_OPENSSL_STRING_value(st, i) ((OPENSSL_STRING)sk_value(CHECKED_PTR_OF(STACK_OF(OPENSSL_STRING), st), i))
2088#define sk_OPENSSL_STRING_num(st) SKM_sk_num(OPENSSL_STRING, st)
2089#define sk_OPENSSL_STRING_pop_free(st, free_func) sk_pop_free(CHECKED_PTR_OF(STACK_OF(OPENSSL_STRING), st), CHECKED_SK_FREE_FUNC2(OPENSSL_STRING, free_func))
2090#define sk_OPENSSL_STRING_insert(st, val, i) sk_insert(CHECKED_PTR_OF(STACK_OF(OPENSSL_STRING), st), CHECKED_PTR_OF(char, val), i)
2091#define sk_OPENSSL_STRING_free(st) SKM_sk_free(OPENSSL_STRING, st)
2092#define sk_OPENSSL_STRING_set(st, i, val) sk_set((_STACK *)CHECKED_PTR_OF(STACK_OF(OPENSSL_STRING), st), i, CHECKED_PTR_OF(char, val))
2093#define sk_OPENSSL_STRING_zero(st) SKM_sk_zero(OPENSSL_STRING, (st))
2094#define sk_OPENSSL_STRING_unshift(st, val) sk_unshift((_STACK *)CHECKED_PTR_OF(STACK_OF(OPENSSL_STRING), st), CHECKED_PTR_OF(char, val))
2095#define sk_OPENSSL_STRING_find_ex(st, val) sk_find_ex((_STACK *)CHECKED_CONST_PTR_OF(STACK_OF(OPENSSL_STRING), st), CHECKED_CONST_PTR_OF(char, val))
2096#define sk_OPENSSL_STRING_delete(st, i) SKM_sk_delete(OPENSSL_STRING, (st), (i))
2097#define sk_OPENSSL_STRING_delete_ptr(st, ptr) (OPENSSL_STRING *)sk_delete_ptr((_STACK *)CHECKED_PTR_OF(STACK_OF(OPENSSL_STRING), st), CHECKED_PTR_OF(char, ptr))
2098#define sk_OPENSSL_STRING_set_cmp_func(st, cmp) \
2099 ((int (*)(const char * const *,const char * const *)) \
2100 sk_set_cmp_func((_STACK *)CHECKED_PTR_OF(STACK_OF(OPENSSL_STRING), st), CHECKED_SK_CMP_FUNC(char, cmp)))
2101#define sk_OPENSSL_STRING_dup(st) SKM_sk_dup(OPENSSL_STRING, st)
2102#define sk_OPENSSL_STRING_shift(st) SKM_sk_shift(OPENSSL_STRING, (st))
2103#define sk_OPENSSL_STRING_pop(st) (char *)sk_pop((_STACK *)CHECKED_PTR_OF(STACK_OF(OPENSSL_STRING), st))
2104#define sk_OPENSSL_STRING_sort(st) SKM_sk_sort(OPENSSL_STRING, (st))
2105#define sk_OPENSSL_STRING_is_sorted(st) SKM_sk_is_sorted(OPENSSL_STRING, (st))
2106
2107
1825#define d2i_ASN1_SET_OF_ACCESS_DESCRIPTION(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \ 2108#define d2i_ASN1_SET_OF_ACCESS_DESCRIPTION(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \
1826 SKM_ASN1_SET_OF_d2i(ACCESS_DESCRIPTION, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class)) 2109 SKM_ASN1_SET_OF_d2i(ACCESS_DESCRIPTION, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class))
1827#define i2d_ASN1_SET_OF_ACCESS_DESCRIPTION(st, pp, i2d_func, ex_tag, ex_class, is_set) \ 2110#define i2d_ASN1_SET_OF_ACCESS_DESCRIPTION(st, pp, i2d_func, ex_tag, ex_class, is_set) \
@@ -1858,6 +2141,15 @@ STACK_OF(type) \
1858#define ASN1_seq_unpack_ASN1_TYPE(buf, len, d2i_func, free_func) \ 2141#define ASN1_seq_unpack_ASN1_TYPE(buf, len, d2i_func, free_func) \
1859 SKM_ASN1_seq_unpack(ASN1_TYPE, (buf), (len), (d2i_func), (free_func)) 2142 SKM_ASN1_seq_unpack(ASN1_TYPE, (buf), (len), (d2i_func), (free_func))
1860 2143
2144#define d2i_ASN1_SET_OF_ASN1_UTF8STRING(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \
2145 SKM_ASN1_SET_OF_d2i(ASN1_UTF8STRING, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class))
2146#define i2d_ASN1_SET_OF_ASN1_UTF8STRING(st, pp, i2d_func, ex_tag, ex_class, is_set) \
2147 SKM_ASN1_SET_OF_i2d(ASN1_UTF8STRING, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set))
2148#define ASN1_seq_pack_ASN1_UTF8STRING(st, i2d_func, buf, len) \
2149 SKM_ASN1_seq_pack(ASN1_UTF8STRING, (st), (i2d_func), (buf), (len))
2150#define ASN1_seq_unpack_ASN1_UTF8STRING(buf, len, d2i_func, free_func) \
2151 SKM_ASN1_seq_unpack(ASN1_UTF8STRING, (buf), (len), (d2i_func), (free_func))
2152
1861#define d2i_ASN1_SET_OF_DIST_POINT(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \ 2153#define d2i_ASN1_SET_OF_DIST_POINT(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \
1862 SKM_ASN1_SET_OF_d2i(DIST_POINT, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class)) 2154 SKM_ASN1_SET_OF_d2i(DIST_POINT, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class))
1863#define i2d_ASN1_SET_OF_DIST_POINT(st, pp, i2d_func, ex_tag, ex_class, is_set) \ 2155#define i2d_ASN1_SET_OF_DIST_POINT(st, pp, i2d_func, ex_tag, ex_class, is_set) \
@@ -1867,6 +2159,24 @@ STACK_OF(type) \
1867#define ASN1_seq_unpack_DIST_POINT(buf, len, d2i_func, free_func) \ 2159#define ASN1_seq_unpack_DIST_POINT(buf, len, d2i_func, free_func) \
1868 SKM_ASN1_seq_unpack(DIST_POINT, (buf), (len), (d2i_func), (free_func)) 2160 SKM_ASN1_seq_unpack(DIST_POINT, (buf), (len), (d2i_func), (free_func))
1869 2161
2162#define d2i_ASN1_SET_OF_ESS_CERT_ID(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \
2163 SKM_ASN1_SET_OF_d2i(ESS_CERT_ID, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class))
2164#define i2d_ASN1_SET_OF_ESS_CERT_ID(st, pp, i2d_func, ex_tag, ex_class, is_set) \
2165 SKM_ASN1_SET_OF_i2d(ESS_CERT_ID, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set))
2166#define ASN1_seq_pack_ESS_CERT_ID(st, i2d_func, buf, len) \
2167 SKM_ASN1_seq_pack(ESS_CERT_ID, (st), (i2d_func), (buf), (len))
2168#define ASN1_seq_unpack_ESS_CERT_ID(buf, len, d2i_func, free_func) \
2169 SKM_ASN1_seq_unpack(ESS_CERT_ID, (buf), (len), (d2i_func), (free_func))
2170
2171#define d2i_ASN1_SET_OF_EVP_MD(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \
2172 SKM_ASN1_SET_OF_d2i(EVP_MD, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class))
2173#define i2d_ASN1_SET_OF_EVP_MD(st, pp, i2d_func, ex_tag, ex_class, is_set) \
2174 SKM_ASN1_SET_OF_i2d(EVP_MD, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set))
2175#define ASN1_seq_pack_EVP_MD(st, i2d_func, buf, len) \
2176 SKM_ASN1_seq_pack(EVP_MD, (st), (i2d_func), (buf), (len))
2177#define ASN1_seq_unpack_EVP_MD(buf, len, d2i_func, free_func) \
2178 SKM_ASN1_seq_unpack(EVP_MD, (buf), (len), (d2i_func), (free_func))
2179
1870#define d2i_ASN1_SET_OF_GENERAL_NAME(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \ 2180#define d2i_ASN1_SET_OF_GENERAL_NAME(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \
1871 SKM_ASN1_SET_OF_d2i(GENERAL_NAME, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class)) 2181 SKM_ASN1_SET_OF_d2i(GENERAL_NAME, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class))
1872#define i2d_ASN1_SET_OF_GENERAL_NAME(st, pp, i2d_func, ex_tag, ex_class, is_set) \ 2182#define i2d_ASN1_SET_OF_GENERAL_NAME(st, pp, i2d_func, ex_tag, ex_class, is_set) \
@@ -2025,6 +2335,240 @@ STACK_OF(type) \
2025 2335
2026#define PKCS12_decrypt_d2i_PKCS7(algor, d2i_func, free_func, pass, passlen, oct, seq) \ 2336#define PKCS12_decrypt_d2i_PKCS7(algor, d2i_func, free_func, pass, passlen, oct, seq) \
2027 SKM_PKCS12_decrypt_d2i(PKCS7, (algor), (d2i_func), (free_func), (pass), (passlen), (oct), (seq)) 2337 SKM_PKCS12_decrypt_d2i(PKCS7, (algor), (d2i_func), (free_func), (pass), (passlen), (oct), (seq))
2338
2339#define lh_ADDED_OBJ_new() LHM_lh_new(ADDED_OBJ,added_obj)
2340#define lh_ADDED_OBJ_insert(lh,inst) LHM_lh_insert(ADDED_OBJ,lh,inst)
2341#define lh_ADDED_OBJ_retrieve(lh,inst) LHM_lh_retrieve(ADDED_OBJ,lh,inst)
2342#define lh_ADDED_OBJ_delete(lh,inst) LHM_lh_delete(ADDED_OBJ,lh,inst)
2343#define lh_ADDED_OBJ_doall(lh,fn) LHM_lh_doall(ADDED_OBJ,lh,fn)
2344#define lh_ADDED_OBJ_doall_arg(lh,fn,arg_type,arg) \
2345 LHM_lh_doall_arg(ADDED_OBJ,lh,fn,arg_type,arg)
2346#define lh_ADDED_OBJ_error(lh) LHM_lh_error(ADDED_OBJ,lh)
2347#define lh_ADDED_OBJ_num_items(lh) LHM_lh_num_items(ADDED_OBJ,lh)
2348#define lh_ADDED_OBJ_down_load(lh) LHM_lh_down_load(ADDED_OBJ,lh)
2349#define lh_ADDED_OBJ_node_stats_bio(lh,out) \
2350 LHM_lh_node_stats_bio(ADDED_OBJ,lh,out)
2351#define lh_ADDED_OBJ_node_usage_stats_bio(lh,out) \
2352 LHM_lh_node_usage_stats_bio(ADDED_OBJ,lh,out)
2353#define lh_ADDED_OBJ_stats_bio(lh,out) \
2354 LHM_lh_stats_bio(ADDED_OBJ,lh,out)
2355#define lh_ADDED_OBJ_free(lh) LHM_lh_free(ADDED_OBJ,lh)
2356
2357#define lh_APP_INFO_new() LHM_lh_new(APP_INFO,app_info)
2358#define lh_APP_INFO_insert(lh,inst) LHM_lh_insert(APP_INFO,lh,inst)
2359#define lh_APP_INFO_retrieve(lh,inst) LHM_lh_retrieve(APP_INFO,lh,inst)
2360#define lh_APP_INFO_delete(lh,inst) LHM_lh_delete(APP_INFO,lh,inst)
2361#define lh_APP_INFO_doall(lh,fn) LHM_lh_doall(APP_INFO,lh,fn)
2362#define lh_APP_INFO_doall_arg(lh,fn,arg_type,arg) \
2363 LHM_lh_doall_arg(APP_INFO,lh,fn,arg_type,arg)
2364#define lh_APP_INFO_error(lh) LHM_lh_error(APP_INFO,lh)
2365#define lh_APP_INFO_num_items(lh) LHM_lh_num_items(APP_INFO,lh)
2366#define lh_APP_INFO_down_load(lh) LHM_lh_down_load(APP_INFO,lh)
2367#define lh_APP_INFO_node_stats_bio(lh,out) \
2368 LHM_lh_node_stats_bio(APP_INFO,lh,out)
2369#define lh_APP_INFO_node_usage_stats_bio(lh,out) \
2370 LHM_lh_node_usage_stats_bio(APP_INFO,lh,out)
2371#define lh_APP_INFO_stats_bio(lh,out) \
2372 LHM_lh_stats_bio(APP_INFO,lh,out)
2373#define lh_APP_INFO_free(lh) LHM_lh_free(APP_INFO,lh)
2374
2375#define lh_CONF_VALUE_new() LHM_lh_new(CONF_VALUE,conf_value)
2376#define lh_CONF_VALUE_insert(lh,inst) LHM_lh_insert(CONF_VALUE,lh,inst)
2377#define lh_CONF_VALUE_retrieve(lh,inst) LHM_lh_retrieve(CONF_VALUE,lh,inst)
2378#define lh_CONF_VALUE_delete(lh,inst) LHM_lh_delete(CONF_VALUE,lh,inst)
2379#define lh_CONF_VALUE_doall(lh,fn) LHM_lh_doall(CONF_VALUE,lh,fn)
2380#define lh_CONF_VALUE_doall_arg(lh,fn,arg_type,arg) \
2381 LHM_lh_doall_arg(CONF_VALUE,lh,fn,arg_type,arg)
2382#define lh_CONF_VALUE_error(lh) LHM_lh_error(CONF_VALUE,lh)
2383#define lh_CONF_VALUE_num_items(lh) LHM_lh_num_items(CONF_VALUE,lh)
2384#define lh_CONF_VALUE_down_load(lh) LHM_lh_down_load(CONF_VALUE,lh)
2385#define lh_CONF_VALUE_node_stats_bio(lh,out) \
2386 LHM_lh_node_stats_bio(CONF_VALUE,lh,out)
2387#define lh_CONF_VALUE_node_usage_stats_bio(lh,out) \
2388 LHM_lh_node_usage_stats_bio(CONF_VALUE,lh,out)
2389#define lh_CONF_VALUE_stats_bio(lh,out) \
2390 LHM_lh_stats_bio(CONF_VALUE,lh,out)
2391#define lh_CONF_VALUE_free(lh) LHM_lh_free(CONF_VALUE,lh)
2392
2393#define lh_ENGINE_PILE_new() LHM_lh_new(ENGINE_PILE,engine_pile)
2394#define lh_ENGINE_PILE_insert(lh,inst) LHM_lh_insert(ENGINE_PILE,lh,inst)
2395#define lh_ENGINE_PILE_retrieve(lh,inst) LHM_lh_retrieve(ENGINE_PILE,lh,inst)
2396#define lh_ENGINE_PILE_delete(lh,inst) LHM_lh_delete(ENGINE_PILE,lh,inst)
2397#define lh_ENGINE_PILE_doall(lh,fn) LHM_lh_doall(ENGINE_PILE,lh,fn)
2398#define lh_ENGINE_PILE_doall_arg(lh,fn,arg_type,arg) \
2399 LHM_lh_doall_arg(ENGINE_PILE,lh,fn,arg_type,arg)
2400#define lh_ENGINE_PILE_error(lh) LHM_lh_error(ENGINE_PILE,lh)
2401#define lh_ENGINE_PILE_num_items(lh) LHM_lh_num_items(ENGINE_PILE,lh)
2402#define lh_ENGINE_PILE_down_load(lh) LHM_lh_down_load(ENGINE_PILE,lh)
2403#define lh_ENGINE_PILE_node_stats_bio(lh,out) \
2404 LHM_lh_node_stats_bio(ENGINE_PILE,lh,out)
2405#define lh_ENGINE_PILE_node_usage_stats_bio(lh,out) \
2406 LHM_lh_node_usage_stats_bio(ENGINE_PILE,lh,out)
2407#define lh_ENGINE_PILE_stats_bio(lh,out) \
2408 LHM_lh_stats_bio(ENGINE_PILE,lh,out)
2409#define lh_ENGINE_PILE_free(lh) LHM_lh_free(ENGINE_PILE,lh)
2410
2411#define lh_ERR_STATE_new() LHM_lh_new(ERR_STATE,err_state)
2412#define lh_ERR_STATE_insert(lh,inst) LHM_lh_insert(ERR_STATE,lh,inst)
2413#define lh_ERR_STATE_retrieve(lh,inst) LHM_lh_retrieve(ERR_STATE,lh,inst)
2414#define lh_ERR_STATE_delete(lh,inst) LHM_lh_delete(ERR_STATE,lh,inst)
2415#define lh_ERR_STATE_doall(lh,fn) LHM_lh_doall(ERR_STATE,lh,fn)
2416#define lh_ERR_STATE_doall_arg(lh,fn,arg_type,arg) \
2417 LHM_lh_doall_arg(ERR_STATE,lh,fn,arg_type,arg)
2418#define lh_ERR_STATE_error(lh) LHM_lh_error(ERR_STATE,lh)
2419#define lh_ERR_STATE_num_items(lh) LHM_lh_num_items(ERR_STATE,lh)
2420#define lh_ERR_STATE_down_load(lh) LHM_lh_down_load(ERR_STATE,lh)
2421#define lh_ERR_STATE_node_stats_bio(lh,out) \
2422 LHM_lh_node_stats_bio(ERR_STATE,lh,out)
2423#define lh_ERR_STATE_node_usage_stats_bio(lh,out) \
2424 LHM_lh_node_usage_stats_bio(ERR_STATE,lh,out)
2425#define lh_ERR_STATE_stats_bio(lh,out) \
2426 LHM_lh_stats_bio(ERR_STATE,lh,out)
2427#define lh_ERR_STATE_free(lh) LHM_lh_free(ERR_STATE,lh)
2428
2429#define lh_ERR_STRING_DATA_new() LHM_lh_new(ERR_STRING_DATA,err_string_data)
2430#define lh_ERR_STRING_DATA_insert(lh,inst) LHM_lh_insert(ERR_STRING_DATA,lh,inst)
2431#define lh_ERR_STRING_DATA_retrieve(lh,inst) LHM_lh_retrieve(ERR_STRING_DATA,lh,inst)
2432#define lh_ERR_STRING_DATA_delete(lh,inst) LHM_lh_delete(ERR_STRING_DATA,lh,inst)
2433#define lh_ERR_STRING_DATA_doall(lh,fn) LHM_lh_doall(ERR_STRING_DATA,lh,fn)
2434#define lh_ERR_STRING_DATA_doall_arg(lh,fn,arg_type,arg) \
2435 LHM_lh_doall_arg(ERR_STRING_DATA,lh,fn,arg_type,arg)
2436#define lh_ERR_STRING_DATA_error(lh) LHM_lh_error(ERR_STRING_DATA,lh)
2437#define lh_ERR_STRING_DATA_num_items(lh) LHM_lh_num_items(ERR_STRING_DATA,lh)
2438#define lh_ERR_STRING_DATA_down_load(lh) LHM_lh_down_load(ERR_STRING_DATA,lh)
2439#define lh_ERR_STRING_DATA_node_stats_bio(lh,out) \
2440 LHM_lh_node_stats_bio(ERR_STRING_DATA,lh,out)
2441#define lh_ERR_STRING_DATA_node_usage_stats_bio(lh,out) \
2442 LHM_lh_node_usage_stats_bio(ERR_STRING_DATA,lh,out)
2443#define lh_ERR_STRING_DATA_stats_bio(lh,out) \
2444 LHM_lh_stats_bio(ERR_STRING_DATA,lh,out)
2445#define lh_ERR_STRING_DATA_free(lh) LHM_lh_free(ERR_STRING_DATA,lh)
2446
2447#define lh_EX_CLASS_ITEM_new() LHM_lh_new(EX_CLASS_ITEM,ex_class_item)
2448#define lh_EX_CLASS_ITEM_insert(lh,inst) LHM_lh_insert(EX_CLASS_ITEM,lh,inst)
2449#define lh_EX_CLASS_ITEM_retrieve(lh,inst) LHM_lh_retrieve(EX_CLASS_ITEM,lh,inst)
2450#define lh_EX_CLASS_ITEM_delete(lh,inst) LHM_lh_delete(EX_CLASS_ITEM,lh,inst)
2451#define lh_EX_CLASS_ITEM_doall(lh,fn) LHM_lh_doall(EX_CLASS_ITEM,lh,fn)
2452#define lh_EX_CLASS_ITEM_doall_arg(lh,fn,arg_type,arg) \
2453 LHM_lh_doall_arg(EX_CLASS_ITEM,lh,fn,arg_type,arg)
2454#define lh_EX_CLASS_ITEM_error(lh) LHM_lh_error(EX_CLASS_ITEM,lh)
2455#define lh_EX_CLASS_ITEM_num_items(lh) LHM_lh_num_items(EX_CLASS_ITEM,lh)
2456#define lh_EX_CLASS_ITEM_down_load(lh) LHM_lh_down_load(EX_CLASS_ITEM,lh)
2457#define lh_EX_CLASS_ITEM_node_stats_bio(lh,out) \
2458 LHM_lh_node_stats_bio(EX_CLASS_ITEM,lh,out)
2459#define lh_EX_CLASS_ITEM_node_usage_stats_bio(lh,out) \
2460 LHM_lh_node_usage_stats_bio(EX_CLASS_ITEM,lh,out)
2461#define lh_EX_CLASS_ITEM_stats_bio(lh,out) \
2462 LHM_lh_stats_bio(EX_CLASS_ITEM,lh,out)
2463#define lh_EX_CLASS_ITEM_free(lh) LHM_lh_free(EX_CLASS_ITEM,lh)
2464
2465#define lh_FUNCTION_new() LHM_lh_new(FUNCTION,function)
2466#define lh_FUNCTION_insert(lh,inst) LHM_lh_insert(FUNCTION,lh,inst)
2467#define lh_FUNCTION_retrieve(lh,inst) LHM_lh_retrieve(FUNCTION,lh,inst)
2468#define lh_FUNCTION_delete(lh,inst) LHM_lh_delete(FUNCTION,lh,inst)
2469#define lh_FUNCTION_doall(lh,fn) LHM_lh_doall(FUNCTION,lh,fn)
2470#define lh_FUNCTION_doall_arg(lh,fn,arg_type,arg) \
2471 LHM_lh_doall_arg(FUNCTION,lh,fn,arg_type,arg)
2472#define lh_FUNCTION_error(lh) LHM_lh_error(FUNCTION,lh)
2473#define lh_FUNCTION_num_items(lh) LHM_lh_num_items(FUNCTION,lh)
2474#define lh_FUNCTION_down_load(lh) LHM_lh_down_load(FUNCTION,lh)
2475#define lh_FUNCTION_node_stats_bio(lh,out) \
2476 LHM_lh_node_stats_bio(FUNCTION,lh,out)
2477#define lh_FUNCTION_node_usage_stats_bio(lh,out) \
2478 LHM_lh_node_usage_stats_bio(FUNCTION,lh,out)
2479#define lh_FUNCTION_stats_bio(lh,out) \
2480 LHM_lh_stats_bio(FUNCTION,lh,out)
2481#define lh_FUNCTION_free(lh) LHM_lh_free(FUNCTION,lh)
2482
2483#define lh_MEM_new() LHM_lh_new(MEM,mem)
2484#define lh_MEM_insert(lh,inst) LHM_lh_insert(MEM,lh,inst)
2485#define lh_MEM_retrieve(lh,inst) LHM_lh_retrieve(MEM,lh,inst)
2486#define lh_MEM_delete(lh,inst) LHM_lh_delete(MEM,lh,inst)
2487#define lh_MEM_doall(lh,fn) LHM_lh_doall(MEM,lh,fn)
2488#define lh_MEM_doall_arg(lh,fn,arg_type,arg) \
2489 LHM_lh_doall_arg(MEM,lh,fn,arg_type,arg)
2490#define lh_MEM_error(lh) LHM_lh_error(MEM,lh)
2491#define lh_MEM_num_items(lh) LHM_lh_num_items(MEM,lh)
2492#define lh_MEM_down_load(lh) LHM_lh_down_load(MEM,lh)
2493#define lh_MEM_node_stats_bio(lh,out) \
2494 LHM_lh_node_stats_bio(MEM,lh,out)
2495#define lh_MEM_node_usage_stats_bio(lh,out) \
2496 LHM_lh_node_usage_stats_bio(MEM,lh,out)
2497#define lh_MEM_stats_bio(lh,out) \
2498 LHM_lh_stats_bio(MEM,lh,out)
2499#define lh_MEM_free(lh) LHM_lh_free(MEM,lh)
2500
2501#define lh_OBJ_NAME_new() LHM_lh_new(OBJ_NAME,obj_name)
2502#define lh_OBJ_NAME_insert(lh,inst) LHM_lh_insert(OBJ_NAME,lh,inst)
2503#define lh_OBJ_NAME_retrieve(lh,inst) LHM_lh_retrieve(OBJ_NAME,lh,inst)
2504#define lh_OBJ_NAME_delete(lh,inst) LHM_lh_delete(OBJ_NAME,lh,inst)
2505#define lh_OBJ_NAME_doall(lh,fn) LHM_lh_doall(OBJ_NAME,lh,fn)
2506#define lh_OBJ_NAME_doall_arg(lh,fn,arg_type,arg) \
2507 LHM_lh_doall_arg(OBJ_NAME,lh,fn,arg_type,arg)
2508#define lh_OBJ_NAME_error(lh) LHM_lh_error(OBJ_NAME,lh)
2509#define lh_OBJ_NAME_num_items(lh) LHM_lh_num_items(OBJ_NAME,lh)
2510#define lh_OBJ_NAME_down_load(lh) LHM_lh_down_load(OBJ_NAME,lh)
2511#define lh_OBJ_NAME_node_stats_bio(lh,out) \
2512 LHM_lh_node_stats_bio(OBJ_NAME,lh,out)
2513#define lh_OBJ_NAME_node_usage_stats_bio(lh,out) \
2514 LHM_lh_node_usage_stats_bio(OBJ_NAME,lh,out)
2515#define lh_OBJ_NAME_stats_bio(lh,out) \
2516 LHM_lh_stats_bio(OBJ_NAME,lh,out)
2517#define lh_OBJ_NAME_free(lh) LHM_lh_free(OBJ_NAME,lh)
2518
2519#define lh_OPENSSL_CSTRING_new() LHM_lh_new(OPENSSL_CSTRING,openssl_cstring)
2520#define lh_OPENSSL_CSTRING_insert(lh,inst) LHM_lh_insert(OPENSSL_CSTRING,lh,inst)
2521#define lh_OPENSSL_CSTRING_retrieve(lh,inst) LHM_lh_retrieve(OPENSSL_CSTRING,lh,inst)
2522#define lh_OPENSSL_CSTRING_delete(lh,inst) LHM_lh_delete(OPENSSL_CSTRING,lh,inst)
2523#define lh_OPENSSL_CSTRING_doall(lh,fn) LHM_lh_doall(OPENSSL_CSTRING,lh,fn)
2524#define lh_OPENSSL_CSTRING_doall_arg(lh,fn,arg_type,arg) \
2525 LHM_lh_doall_arg(OPENSSL_CSTRING,lh,fn,arg_type,arg)
2526#define lh_OPENSSL_CSTRING_error(lh) LHM_lh_error(OPENSSL_CSTRING,lh)
2527#define lh_OPENSSL_CSTRING_num_items(lh) LHM_lh_num_items(OPENSSL_CSTRING,lh)
2528#define lh_OPENSSL_CSTRING_down_load(lh) LHM_lh_down_load(OPENSSL_CSTRING,lh)
2529#define lh_OPENSSL_CSTRING_node_stats_bio(lh,out) \
2530 LHM_lh_node_stats_bio(OPENSSL_CSTRING,lh,out)
2531#define lh_OPENSSL_CSTRING_node_usage_stats_bio(lh,out) \
2532 LHM_lh_node_usage_stats_bio(OPENSSL_CSTRING,lh,out)
2533#define lh_OPENSSL_CSTRING_stats_bio(lh,out) \
2534 LHM_lh_stats_bio(OPENSSL_CSTRING,lh,out)
2535#define lh_OPENSSL_CSTRING_free(lh) LHM_lh_free(OPENSSL_CSTRING,lh)
2536
2537#define lh_OPENSSL_STRING_new() LHM_lh_new(OPENSSL_STRING,openssl_string)
2538#define lh_OPENSSL_STRING_insert(lh,inst) LHM_lh_insert(OPENSSL_STRING,lh,inst)
2539#define lh_OPENSSL_STRING_retrieve(lh,inst) LHM_lh_retrieve(OPENSSL_STRING,lh,inst)
2540#define lh_OPENSSL_STRING_delete(lh,inst) LHM_lh_delete(OPENSSL_STRING,lh,inst)
2541#define lh_OPENSSL_STRING_doall(lh,fn) LHM_lh_doall(OPENSSL_STRING,lh,fn)
2542#define lh_OPENSSL_STRING_doall_arg(lh,fn,arg_type,arg) \
2543 LHM_lh_doall_arg(OPENSSL_STRING,lh,fn,arg_type,arg)
2544#define lh_OPENSSL_STRING_error(lh) LHM_lh_error(OPENSSL_STRING,lh)
2545#define lh_OPENSSL_STRING_num_items(lh) LHM_lh_num_items(OPENSSL_STRING,lh)
2546#define lh_OPENSSL_STRING_down_load(lh) LHM_lh_down_load(OPENSSL_STRING,lh)
2547#define lh_OPENSSL_STRING_node_stats_bio(lh,out) \
2548 LHM_lh_node_stats_bio(OPENSSL_STRING,lh,out)
2549#define lh_OPENSSL_STRING_node_usage_stats_bio(lh,out) \
2550 LHM_lh_node_usage_stats_bio(OPENSSL_STRING,lh,out)
2551#define lh_OPENSSL_STRING_stats_bio(lh,out) \
2552 LHM_lh_stats_bio(OPENSSL_STRING,lh,out)
2553#define lh_OPENSSL_STRING_free(lh) LHM_lh_free(OPENSSL_STRING,lh)
2554
2555#define lh_SSL_SESSION_new() LHM_lh_new(SSL_SESSION,ssl_session)
2556#define lh_SSL_SESSION_insert(lh,inst) LHM_lh_insert(SSL_SESSION,lh,inst)
2557#define lh_SSL_SESSION_retrieve(lh,inst) LHM_lh_retrieve(SSL_SESSION,lh,inst)
2558#define lh_SSL_SESSION_delete(lh,inst) LHM_lh_delete(SSL_SESSION,lh,inst)
2559#define lh_SSL_SESSION_doall(lh,fn) LHM_lh_doall(SSL_SESSION,lh,fn)
2560#define lh_SSL_SESSION_doall_arg(lh,fn,arg_type,arg) \
2561 LHM_lh_doall_arg(SSL_SESSION,lh,fn,arg_type,arg)
2562#define lh_SSL_SESSION_error(lh) LHM_lh_error(SSL_SESSION,lh)
2563#define lh_SSL_SESSION_num_items(lh) LHM_lh_num_items(SSL_SESSION,lh)
2564#define lh_SSL_SESSION_down_load(lh) LHM_lh_down_load(SSL_SESSION,lh)
2565#define lh_SSL_SESSION_node_stats_bio(lh,out) \
2566 LHM_lh_node_stats_bio(SSL_SESSION,lh,out)
2567#define lh_SSL_SESSION_node_usage_stats_bio(lh,out) \
2568 LHM_lh_node_usage_stats_bio(SSL_SESSION,lh,out)
2569#define lh_SSL_SESSION_stats_bio(lh,out) \
2570 LHM_lh_stats_bio(SSL_SESSION,lh,out)
2571#define lh_SSL_SESSION_free(lh) LHM_lh_free(SSL_SESSION,lh)
2028/* End of util/mkstack.pl block, you may now edit :-) */ 2572/* End of util/mkstack.pl block, you may now edit :-) */
2029 2573
2030#endif /* !defined HEADER_SAFESTACK_H */ 2574#endif /* !defined HEADER_SAFESTACK_H */
diff --git a/src/lib/libcrypto/stack/stack.c b/src/lib/libcrypto/stack/stack.c
index 378bd7c796..76cf1a1168 100644
--- a/src/lib/libcrypto/stack/stack.c
+++ b/src/lib/libcrypto/stack/stack.c
@@ -77,10 +77,10 @@ const char STACK_version[]="Stack" OPENSSL_VERSION_PTEXT;
77 77
78#include <errno.h> 78#include <errno.h>
79 79
80int (*sk_set_cmp_func(STACK *sk, int (*c)(const char * const *,const char * const *))) 80int (*sk_set_cmp_func(_STACK *sk, int (*c)(const void *, const void *)))
81 (const char * const *, const char * const *) 81 (const void *, const void *)
82 { 82 {
83 int (*old)(const char * const *,const char * const *)=sk->comp; 83 int (*old)(const void *,const void *)=sk->comp;
84 84
85 if (sk->comp != c) 85 if (sk->comp != c)
86 sk->sorted=0; 86 sk->sorted=0;
@@ -89,9 +89,9 @@ int (*sk_set_cmp_func(STACK *sk, int (*c)(const char * const *,const char * cons
89 return old; 89 return old;
90 } 90 }
91 91
92STACK *sk_dup(STACK *sk) 92_STACK *sk_dup(_STACK *sk)
93 { 93 {
94 STACK *ret; 94 _STACK *ret;
95 char **s; 95 char **s;
96 96
97 if ((ret=sk_new(sk->comp)) == NULL) goto err; 97 if ((ret=sk_new(sk->comp)) == NULL) goto err;
@@ -112,19 +112,19 @@ err:
112 return(NULL); 112 return(NULL);
113 } 113 }
114 114
115STACK *sk_new_null(void) 115_STACK *sk_new_null(void)
116 { 116 {
117 return sk_new((int (*)(const char * const *, const char * const *))0); 117 return sk_new((int (*)(const void *, const void *))0);
118 } 118 }
119 119
120STACK *sk_new(int (*c)(const char * const *, const char * const *)) 120_STACK *sk_new(int (*c)(const void *, const void *))
121 { 121 {
122 STACK *ret; 122 _STACK *ret;
123 int i; 123 int i;
124 124
125 if ((ret=(STACK *)OPENSSL_malloc(sizeof(STACK))) == NULL) 125 if ((ret=OPENSSL_malloc(sizeof(_STACK))) == NULL)
126 goto err; 126 goto err;
127 if ((ret->data=(char **)OPENSSL_malloc(sizeof(char *)*MIN_NODES)) == NULL) 127 if ((ret->data=OPENSSL_malloc(sizeof(char *)*MIN_NODES)) == NULL)
128 goto err; 128 goto err;
129 for (i=0; i<MIN_NODES; i++) 129 for (i=0; i<MIN_NODES; i++)
130 ret->data[i]=NULL; 130 ret->data[i]=NULL;
@@ -139,14 +139,14 @@ err:
139 return(NULL); 139 return(NULL);
140 } 140 }
141 141
142int sk_insert(STACK *st, char *data, int loc) 142int sk_insert(_STACK *st, void *data, int loc)
143 { 143 {
144 char **s; 144 char **s;
145 145
146 if(st == NULL) return 0; 146 if(st == NULL) return 0;
147 if (st->num_alloc <= st->num+1) 147 if (st->num_alloc <= st->num+1)
148 { 148 {
149 s=(char **)OPENSSL_realloc((char *)st->data, 149 s=OPENSSL_realloc((char *)st->data,
150 (unsigned int)sizeof(char *)*st->num_alloc*2); 150 (unsigned int)sizeof(char *)*st->num_alloc*2);
151 if (s == NULL) 151 if (s == NULL)
152 return(0); 152 return(0);
@@ -160,14 +160,14 @@ int sk_insert(STACK *st, char *data, int loc)
160 int i; 160 int i;
161 char **f,**t; 161 char **f,**t;
162 162
163 f=(char **)st->data; 163 f=st->data;
164 t=(char **)&(st->data[1]); 164 t=&(st->data[1]);
165 for (i=st->num; i>=loc; i--) 165 for (i=st->num; i>=loc; i--)
166 t[i]=f[i]; 166 t[i]=f[i];
167 167
168#ifdef undef /* no memmove on sunos :-( */ 168#ifdef undef /* no memmove on sunos :-( */
169 memmove( (char *)&(st->data[loc+1]), 169 memmove(&(st->data[loc+1]),
170 (char *)&(st->data[loc]), 170 &(st->data[loc]),
171 sizeof(char *)*(st->num-loc)); 171 sizeof(char *)*(st->num-loc));
172#endif 172#endif
173 st->data[loc]=data; 173 st->data[loc]=data;
@@ -177,7 +177,7 @@ int sk_insert(STACK *st, char *data, int loc)
177 return(st->num); 177 return(st->num);
178 } 178 }
179 179
180char *sk_delete_ptr(STACK *st, char *p) 180void *sk_delete_ptr(_STACK *st, void *p)
181 { 181 {
182 int i; 182 int i;
183 183
@@ -187,7 +187,7 @@ char *sk_delete_ptr(STACK *st, char *p)
187 return(NULL); 187 return(NULL);
188 } 188 }
189 189
190char *sk_delete(STACK *st, int loc) 190void *sk_delete(_STACK *st, int loc)
191 { 191 {
192 char *ret; 192 char *ret;
193 int i,j; 193 int i,j;
@@ -210,11 +210,11 @@ char *sk_delete(STACK *st, int loc)
210 return(ret); 210 return(ret);
211 } 211 }
212 212
213static int internal_find(STACK *st, char *data, int ret_val_options) 213static int internal_find(_STACK *st, void *data, int ret_val_options)
214 { 214 {
215 char **r; 215 const void * const *r;
216 int i; 216 int i;
217 int (*comp_func)(const void *,const void *); 217
218 if(st == NULL) return -1; 218 if(st == NULL) return -1;
219 219
220 if (st->comp == NULL) 220 if (st->comp == NULL)
@@ -226,53 +226,46 @@ static int internal_find(STACK *st, char *data, int ret_val_options)
226 } 226 }
227 sk_sort(st); 227 sk_sort(st);
228 if (data == NULL) return(-1); 228 if (data == NULL) return(-1);
229 /* This (and the "qsort" below) are the two places in OpenSSL 229 r=OBJ_bsearch_ex_(&data,st->data,st->num,sizeof(void *),st->comp,
230 * where we need to convert from our standard (type **,type **) 230 ret_val_options);
231 * compare callback type to the (void *,void *) type required by
232 * bsearch. However, the "data" it is being called(back) with are
233 * not (type *) pointers, but the *pointers* to (type *) pointers,
234 * so we get our extra level of pointer dereferencing that way. */
235 comp_func=(int (*)(const void *,const void *))(st->comp);
236 r=(char **)OBJ_bsearch_ex((char *)&data,(char *)st->data,
237 st->num,sizeof(char *),comp_func,ret_val_options);
238 if (r == NULL) return(-1); 231 if (r == NULL) return(-1);
239 return((int)(r-st->data)); 232 return (int)((char **)r-st->data);
240 } 233 }
241 234
242int sk_find(STACK *st, char *data) 235int sk_find(_STACK *st, void *data)
243 { 236 {
244 return internal_find(st, data, OBJ_BSEARCH_FIRST_VALUE_ON_MATCH); 237 return internal_find(st, data, OBJ_BSEARCH_FIRST_VALUE_ON_MATCH);
245 } 238 }
246int sk_find_ex(STACK *st, char *data) 239int sk_find_ex(_STACK *st, void *data)
247 { 240 {
248 return internal_find(st, data, OBJ_BSEARCH_VALUE_ON_NOMATCH); 241 return internal_find(st, data, OBJ_BSEARCH_VALUE_ON_NOMATCH);
249 } 242 }
250 243
251int sk_push(STACK *st, char *data) 244int sk_push(_STACK *st, void *data)
252 { 245 {
253 return(sk_insert(st,data,st->num)); 246 return(sk_insert(st,data,st->num));
254 } 247 }
255 248
256int sk_unshift(STACK *st, char *data) 249int sk_unshift(_STACK *st, void *data)
257 { 250 {
258 return(sk_insert(st,data,0)); 251 return(sk_insert(st,data,0));
259 } 252 }
260 253
261char *sk_shift(STACK *st) 254void *sk_shift(_STACK *st)
262 { 255 {
263 if (st == NULL) return(NULL); 256 if (st == NULL) return(NULL);
264 if (st->num <= 0) return(NULL); 257 if (st->num <= 0) return(NULL);
265 return(sk_delete(st,0)); 258 return(sk_delete(st,0));
266 } 259 }
267 260
268char *sk_pop(STACK *st) 261void *sk_pop(_STACK *st)
269 { 262 {
270 if (st == NULL) return(NULL); 263 if (st == NULL) return(NULL);
271 if (st->num <= 0) return(NULL); 264 if (st->num <= 0) return(NULL);
272 return(sk_delete(st,st->num-1)); 265 return(sk_delete(st,st->num-1));
273 } 266 }
274 267
275void sk_zero(STACK *st) 268void sk_zero(_STACK *st)
276 { 269 {
277 if (st == NULL) return; 270 if (st == NULL) return;
278 if (st->num <= 0) return; 271 if (st->num <= 0) return;
@@ -280,7 +273,7 @@ void sk_zero(STACK *st)
280 st->num=0; 273 st->num=0;
281 } 274 }
282 275
283void sk_pop_free(STACK *st, void (*func)(void *)) 276void sk_pop_free(_STACK *st, void (*func)(void *))
284 { 277 {
285 int i; 278 int i;
286 279
@@ -291,32 +284,32 @@ void sk_pop_free(STACK *st, void (*func)(void *))
291 sk_free(st); 284 sk_free(st);
292 } 285 }
293 286
294void sk_free(STACK *st) 287void sk_free(_STACK *st)
295 { 288 {
296 if (st == NULL) return; 289 if (st == NULL) return;
297 if (st->data != NULL) OPENSSL_free(st->data); 290 if (st->data != NULL) OPENSSL_free(st->data);
298 OPENSSL_free(st); 291 OPENSSL_free(st);
299 } 292 }
300 293
301int sk_num(const STACK *st) 294int sk_num(const _STACK *st)
302{ 295{
303 if(st == NULL) return -1; 296 if(st == NULL) return -1;
304 return st->num; 297 return st->num;
305} 298}
306 299
307char *sk_value(const STACK *st, int i) 300void *sk_value(const _STACK *st, int i)
308{ 301{
309 if(!st || (i < 0) || (i >= st->num)) return NULL; 302 if(!st || (i < 0) || (i >= st->num)) return NULL;
310 return st->data[i]; 303 return st->data[i];
311} 304}
312 305
313char *sk_set(STACK *st, int i, char *value) 306void *sk_set(_STACK *st, int i, void *value)
314{ 307{
315 if(!st || (i < 0) || (i >= st->num)) return NULL; 308 if(!st || (i < 0) || (i >= st->num)) return NULL;
316 return (st->data[i] = value); 309 return (st->data[i] = value);
317} 310}
318 311
319void sk_sort(STACK *st) 312void sk_sort(_STACK *st)
320 { 313 {
321 if (st && !st->sorted) 314 if (st && !st->sorted)
322 { 315 {
@@ -333,7 +326,7 @@ void sk_sort(STACK *st)
333 } 326 }
334 } 327 }
335 328
336int sk_is_sorted(const STACK *st) 329int sk_is_sorted(const _STACK *st)
337 { 330 {
338 if (!st) 331 if (!st)
339 return 1; 332 return 1;
diff --git a/src/lib/libcrypto/stack/stack.h b/src/lib/libcrypto/stack/stack.h
index 5cbb116a8b..ce35e554eb 100644
--- a/src/lib/libcrypto/stack/stack.h
+++ b/src/lib/libcrypto/stack/stack.h
@@ -70,37 +70,36 @@ typedef struct stack_st
70 int sorted; 70 int sorted;
71 71
72 int num_alloc; 72 int num_alloc;
73 int (*comp)(const char * const *, const char * const *); 73 int (*comp)(const void *, const void *);
74 } STACK; 74 } _STACK; /* Use STACK_OF(...) instead */
75 75
76#define M_sk_num(sk) ((sk) ? (sk)->num:-1) 76#define M_sk_num(sk) ((sk) ? (sk)->num:-1)
77#define M_sk_value(sk,n) ((sk) ? (sk)->data[n] : NULL) 77#define M_sk_value(sk,n) ((sk) ? (sk)->data[n] : NULL)
78 78
79int sk_num(const STACK *); 79int sk_num(const _STACK *);
80char *sk_value(const STACK *, int); 80void *sk_value(const _STACK *, int);
81 81
82char *sk_set(STACK *, int, char *); 82void *sk_set(_STACK *, int, void *);
83 83
84STACK *sk_new(int (*cmp)(const char * const *, const char * const *)); 84_STACK *sk_new(int (*cmp)(const void *, const void *));
85STACK *sk_new_null(void); 85_STACK *sk_new_null(void);
86void sk_free(STACK *); 86void sk_free(_STACK *);
87void sk_pop_free(STACK *st, void (*func)(void *)); 87void sk_pop_free(_STACK *st, void (*func)(void *));
88int sk_insert(STACK *sk,char *data,int where); 88int sk_insert(_STACK *sk, void *data, int where);
89char *sk_delete(STACK *st,int loc); 89void *sk_delete(_STACK *st, int loc);
90char *sk_delete_ptr(STACK *st, char *p); 90void *sk_delete_ptr(_STACK *st, void *p);
91int sk_find(STACK *st,char *data); 91int sk_find(_STACK *st, void *data);
92int sk_find_ex(STACK *st,char *data); 92int sk_find_ex(_STACK *st, void *data);
93int sk_push(STACK *st,char *data); 93int sk_push(_STACK *st, void *data);
94int sk_unshift(STACK *st,char *data); 94int sk_unshift(_STACK *st, void *data);
95char *sk_shift(STACK *st); 95void *sk_shift(_STACK *st);
96char *sk_pop(STACK *st); 96void *sk_pop(_STACK *st);
97void sk_zero(STACK *st); 97void sk_zero(_STACK *st);
98int (*sk_set_cmp_func(STACK *sk, int (*c)(const char * const *, 98int (*sk_set_cmp_func(_STACK *sk, int (*c)(const void *, const void *)))
99 const char * const *))) 99 (const void *, const void *);
100 (const char * const *, const char * const *); 100_STACK *sk_dup(_STACK *st);
101STACK *sk_dup(STACK *st); 101void sk_sort(_STACK *st);
102void sk_sort(STACK *st); 102int sk_is_sorted(const _STACK *st);
103int sk_is_sorted(const STACK *st);
104 103
105#ifdef __cplusplus 104#ifdef __cplusplus
106} 105}
diff --git a/src/lib/libcrypto/symhacks.h b/src/lib/libcrypto/symhacks.h
index 8728e6124d..3fd4a81692 100644
--- a/src/lib/libcrypto/symhacks.h
+++ b/src/lib/libcrypto/symhacks.h
@@ -60,12 +60,13 @@
60/* Hacks to solve the problem with linkers incapable of handling very long 60/* Hacks to solve the problem with linkers incapable of handling very long
61 symbol names. In the case of VMS, the limit is 31 characters on VMS for 61 symbol names. In the case of VMS, the limit is 31 characters on VMS for
62 VAX. */ 62 VAX. */
63/* Note that this affects util/libeay.num and util/ssleay.num... you may
64 change those manually, but that's not recommended, as those files are
65 controlled centrally and updated on Unix, and the central definition
66 may disagree with yours, which in turn may come with shareable library
67 incompatibilities. */
63#ifdef OPENSSL_SYS_VMS 68#ifdef OPENSSL_SYS_VMS
64 69
65/* Hack a long name in crypto/cryptlib.c */
66#undef int_CRYPTO_set_do_dynlock_callback
67#define int_CRYPTO_set_do_dynlock_callback int_CRYPTO_set_do_dynlock_cb
68
69/* Hack a long name in crypto/ex_data.c */ 70/* Hack a long name in crypto/ex_data.c */
70#undef CRYPTO_get_ex_data_implementation 71#undef CRYPTO_get_ex_data_implementation
71#define CRYPTO_get_ex_data_implementation CRYPTO_get_ex_data_impl 72#define CRYPTO_get_ex_data_implementation CRYPTO_get_ex_data_impl
@@ -137,6 +138,8 @@
137#define X509_policy_node_get0_qualifiers X509_pcy_node_get0_qualifiers 138#define X509_policy_node_get0_qualifiers X509_pcy_node_get0_qualifiers
138#undef X509_STORE_CTX_get_explicit_policy 139#undef X509_STORE_CTX_get_explicit_policy
139#define X509_STORE_CTX_get_explicit_policy X509_STORE_CTX_get_expl_policy 140#define X509_STORE_CTX_get_explicit_policy X509_STORE_CTX_get_expl_policy
141#undef X509_STORE_CTX_get0_current_issuer
142#define X509_STORE_CTX_get0_current_issuer X509_STORE_CTX_get0_cur_issuer
140 143
141/* Hack some long CRYPTO names */ 144/* Hack some long CRYPTO names */
142#undef CRYPTO_set_dynlock_destroy_callback 145#undef CRYPTO_set_dynlock_destroy_callback
@@ -144,9 +147,9 @@
144#undef CRYPTO_set_dynlock_create_callback 147#undef CRYPTO_set_dynlock_create_callback
145#define CRYPTO_set_dynlock_create_callback CRYPTO_set_dynlock_create_cb 148#define CRYPTO_set_dynlock_create_callback CRYPTO_set_dynlock_create_cb
146#undef CRYPTO_set_dynlock_lock_callback 149#undef CRYPTO_set_dynlock_lock_callback
147#define CRYPTO_set_dynlock_lock_callback CRYPTO_set_dynlock_lock_cb 150#define CRYPTO_set_dynlock_lock_callback CRYPTO_set_dynlock_lock_cb
148#undef CRYPTO_get_dynlock_lock_callback 151#undef CRYPTO_get_dynlock_lock_callback
149#define CRYPTO_get_dynlock_lock_callback CRYPTO_get_dynlock_lock_cb 152#define CRYPTO_get_dynlock_lock_callback CRYPTO_get_dynlock_lock_cb
150#undef CRYPTO_get_dynlock_destroy_callback 153#undef CRYPTO_get_dynlock_destroy_callback
151#define CRYPTO_get_dynlock_destroy_callback CRYPTO_get_dynlock_destroy_cb 154#define CRYPTO_get_dynlock_destroy_callback CRYPTO_get_dynlock_destroy_cb
152#undef CRYPTO_get_dynlock_create_callback 155#undef CRYPTO_get_dynlock_create_callback
@@ -158,7 +161,7 @@
158 161
159/* Hack some long SSL names */ 162/* Hack some long SSL names */
160#undef SSL_CTX_set_default_verify_paths 163#undef SSL_CTX_set_default_verify_paths
161#define SSL_CTX_set_default_verify_paths SSL_CTX_set_def_verify_paths 164#define SSL_CTX_set_default_verify_paths SSL_CTX_set_def_verify_paths
162#undef SSL_get_ex_data_X509_STORE_CTX_idx 165#undef SSL_get_ex_data_X509_STORE_CTX_idx
163#define SSL_get_ex_data_X509_STORE_CTX_idx SSL_get_ex_d_X509_STORE_CTX_idx 166#define SSL_get_ex_data_X509_STORE_CTX_idx SSL_get_ex_d_X509_STORE_CTX_idx
164#undef SSL_add_file_cert_subjects_to_stack 167#undef SSL_add_file_cert_subjects_to_stack
@@ -168,21 +171,38 @@
168#undef SSL_CTX_use_certificate_chain_file 171#undef SSL_CTX_use_certificate_chain_file
169#define SSL_CTX_use_certificate_chain_file SSL_CTX_use_cert_chain_file 172#define SSL_CTX_use_certificate_chain_file SSL_CTX_use_cert_chain_file
170#undef SSL_CTX_set_cert_verify_callback 173#undef SSL_CTX_set_cert_verify_callback
171#define SSL_CTX_set_cert_verify_callback SSL_CTX_set_cert_verify_cb 174#define SSL_CTX_set_cert_verify_callback SSL_CTX_set_cert_verify_cb
172#undef SSL_CTX_set_default_passwd_cb_userdata 175#undef SSL_CTX_set_default_passwd_cb_userdata
173#define SSL_CTX_set_default_passwd_cb_userdata SSL_CTX_set_def_passwd_cb_ud 176#define SSL_CTX_set_default_passwd_cb_userdata SSL_CTX_set_def_passwd_cb_ud
174#undef SSL_COMP_get_compression_methods 177#undef SSL_COMP_get_compression_methods
175#define SSL_COMP_get_compression_methods SSL_COMP_get_compress_methods 178#define SSL_COMP_get_compression_methods SSL_COMP_get_compress_methods
176 179
180#undef ssl_add_clienthello_renegotiate_ext
181#define ssl_add_clienthello_renegotiate_ext ssl_add_clienthello_reneg_ext
182#undef ssl_add_serverhello_renegotiate_ext
183#define ssl_add_serverhello_renegotiate_ext ssl_add_serverhello_reneg_ext
184#undef ssl_parse_clienthello_renegotiate_ext
185#define ssl_parse_clienthello_renegotiate_ext ssl_parse_clienthello_reneg_ext
186#undef ssl_parse_serverhello_renegotiate_ext
187#define ssl_parse_serverhello_renegotiate_ext ssl_parse_serverhello_reneg_ext
188
177/* Hack some long ENGINE names */ 189/* Hack some long ENGINE names */
178#undef ENGINE_get_default_BN_mod_exp_crt 190#undef ENGINE_get_default_BN_mod_exp_crt
179#define ENGINE_get_default_BN_mod_exp_crt ENGINE_get_def_BN_mod_exp_crt 191#define ENGINE_get_default_BN_mod_exp_crt ENGINE_get_def_BN_mod_exp_crt
180#undef ENGINE_set_default_BN_mod_exp_crt 192#undef ENGINE_set_default_BN_mod_exp_crt
181#define ENGINE_set_default_BN_mod_exp_crt ENGINE_set_def_BN_mod_exp_crt 193#define ENGINE_set_default_BN_mod_exp_crt ENGINE_set_def_BN_mod_exp_crt
182#undef ENGINE_set_load_privkey_function 194#undef ENGINE_set_load_privkey_function
183#define ENGINE_set_load_privkey_function ENGINE_set_load_privkey_fn 195#define ENGINE_set_load_privkey_function ENGINE_set_load_privkey_fn
184#undef ENGINE_get_load_privkey_function 196#undef ENGINE_get_load_privkey_function
185#define ENGINE_get_load_privkey_function ENGINE_get_load_privkey_fn 197#define ENGINE_get_load_privkey_function ENGINE_get_load_privkey_fn
198#undef ENGINE_unregister_pkey_asn1_meths
199#define ENGINE_unregister_pkey_asn1_meths ENGINE_unreg_pkey_asn1_meths
200#undef ENGINE_register_all_pkey_asn1_meths
201#define ENGINE_register_all_pkey_asn1_meths ENGINE_reg_all_pkey_asn1_meths
202#undef ENGINE_set_default_pkey_asn1_meths
203#define ENGINE_set_default_pkey_asn1_meths ENGINE_set_def_pkey_asn1_meths
204#undef ENGINE_get_pkey_asn1_meth_engine
205#define ENGINE_get_pkey_asn1_meth_engine ENGINE_get_pkey_asn1_meth_eng
186#undef ENGINE_set_load_ssl_client_cert_function 206#undef ENGINE_set_load_ssl_client_cert_function
187#define ENGINE_set_load_ssl_client_cert_function \ 207#define ENGINE_set_load_ssl_client_cert_function \
188 ENGINE_set_ld_ssl_clnt_cert_fn 208 ENGINE_set_ld_ssl_clnt_cert_fn
@@ -191,7 +211,7 @@
191 211
192/* Hack some long OCSP names */ 212/* Hack some long OCSP names */
193#undef OCSP_REQUEST_get_ext_by_critical 213#undef OCSP_REQUEST_get_ext_by_critical
194#define OCSP_REQUEST_get_ext_by_critical OCSP_REQUEST_get_ext_by_crit 214#define OCSP_REQUEST_get_ext_by_critical OCSP_REQUEST_get_ext_by_crit
195#undef OCSP_BASICRESP_get_ext_by_critical 215#undef OCSP_BASICRESP_get_ext_by_critical
196#define OCSP_BASICRESP_get_ext_by_critical OCSP_BASICRESP_get_ext_by_crit 216#define OCSP_BASICRESP_get_ext_by_critical OCSP_BASICRESP_get_ext_by_crit
197#undef OCSP_SINGLERESP_get_ext_by_critical 217#undef OCSP_SINGLERESP_get_ext_by_critical
@@ -208,6 +228,8 @@
208#define OPENSSL_add_all_algorithms_noconf OPENSSL_add_all_algo_noconf 228#define OPENSSL_add_all_algorithms_noconf OPENSSL_add_all_algo_noconf
209#undef OPENSSL_add_all_algorithms_conf 229#undef OPENSSL_add_all_algorithms_conf
210#define OPENSSL_add_all_algorithms_conf OPENSSL_add_all_algo_conf 230#define OPENSSL_add_all_algorithms_conf OPENSSL_add_all_algo_conf
231#undef EVP_PKEY_meth_set_verify_recover
232#define EVP_PKEY_meth_set_verify_recover EVP_PKEY_meth_set_vrfy_recover
211 233
212/* Hack some long EC names */ 234/* Hack some long EC names */
213#undef EC_GROUP_set_point_conversion_form 235#undef EC_GROUP_set_point_conversion_form
@@ -236,15 +258,15 @@
236#define EC_POINT_set_compressed_coordinates_GF2m \ 258#define EC_POINT_set_compressed_coordinates_GF2m \
237 EC_POINT_set_compr_coords_GF2m 259 EC_POINT_set_compr_coords_GF2m
238#undef ec_GF2m_simple_group_clear_finish 260#undef ec_GF2m_simple_group_clear_finish
239#define ec_GF2m_simple_group_clear_finish ec_GF2m_simple_grp_clr_finish 261#define ec_GF2m_simple_group_clear_finish ec_GF2m_simple_grp_clr_finish
240#undef ec_GF2m_simple_group_check_discriminant 262#undef ec_GF2m_simple_group_check_discriminant
241#define ec_GF2m_simple_group_check_discriminant ec_GF2m_simple_grp_chk_discrim 263#define ec_GF2m_simple_group_check_discriminant ec_GF2m_simple_grp_chk_discrim
242#undef ec_GF2m_simple_point_clear_finish 264#undef ec_GF2m_simple_point_clear_finish
243#define ec_GF2m_simple_point_clear_finish ec_GF2m_simple_pt_clr_finish 265#define ec_GF2m_simple_point_clear_finish ec_GF2m_simple_pt_clr_finish
244#undef ec_GF2m_simple_point_set_to_infinity 266#undef ec_GF2m_simple_point_set_to_infinity
245#define ec_GF2m_simple_point_set_to_infinity ec_GF2m_simple_pt_set_to_inf 267#define ec_GF2m_simple_point_set_to_infinity ec_GF2m_simple_pt_set_to_inf
246#undef ec_GF2m_simple_points_make_affine 268#undef ec_GF2m_simple_points_make_affine
247#define ec_GF2m_simple_points_make_affine ec_GF2m_simple_pts_make_affine 269#define ec_GF2m_simple_points_make_affine ec_GF2m_simple_pts_make_affine
248#undef ec_GF2m_simple_point_set_affine_coordinates 270#undef ec_GF2m_simple_point_set_affine_coordinates
249#define ec_GF2m_simple_point_set_affine_coordinates \ 271#define ec_GF2m_simple_point_set_affine_coordinates \
250 ec_GF2m_smp_pt_set_af_coords 272 ec_GF2m_smp_pt_set_af_coords
@@ -259,19 +281,19 @@
259#undef ec_GFp_simple_group_get_curve_GFp 281#undef ec_GFp_simple_group_get_curve_GFp
260#define ec_GFp_simple_group_get_curve_GFp ec_GFp_simple_grp_get_curve_GFp 282#define ec_GFp_simple_group_get_curve_GFp ec_GFp_simple_grp_get_curve_GFp
261#undef ec_GFp_simple_group_clear_finish 283#undef ec_GFp_simple_group_clear_finish
262#define ec_GFp_simple_group_clear_finish ec_GFp_simple_grp_clear_finish 284#define ec_GFp_simple_group_clear_finish ec_GFp_simple_grp_clear_finish
263#undef ec_GFp_simple_group_set_generator 285#undef ec_GFp_simple_group_set_generator
264#define ec_GFp_simple_group_set_generator ec_GFp_simple_grp_set_generator 286#define ec_GFp_simple_group_set_generator ec_GFp_simple_grp_set_generator
265#undef ec_GFp_simple_group_get0_generator 287#undef ec_GFp_simple_group_get0_generator
266#define ec_GFp_simple_group_get0_generator ec_GFp_simple_grp_gt0_generator 288#define ec_GFp_simple_group_get0_generator ec_GFp_simple_grp_gt0_generator
267#undef ec_GFp_simple_group_get_cofactor 289#undef ec_GFp_simple_group_get_cofactor
268#define ec_GFp_simple_group_get_cofactor ec_GFp_simple_grp_get_cofactor 290#define ec_GFp_simple_group_get_cofactor ec_GFp_simple_grp_get_cofactor
269#undef ec_GFp_simple_point_clear_finish 291#undef ec_GFp_simple_point_clear_finish
270#define ec_GFp_simple_point_clear_finish ec_GFp_simple_pt_clear_finish 292#define ec_GFp_simple_point_clear_finish ec_GFp_simple_pt_clear_finish
271#undef ec_GFp_simple_point_set_to_infinity 293#undef ec_GFp_simple_point_set_to_infinity
272#define ec_GFp_simple_point_set_to_infinity ec_GFp_simple_pt_set_to_inf 294#define ec_GFp_simple_point_set_to_infinity ec_GFp_simple_pt_set_to_inf
273#undef ec_GFp_simple_points_make_affine 295#undef ec_GFp_simple_points_make_affine
274#define ec_GFp_simple_points_make_affine ec_GFp_simple_pts_make_affine 296#define ec_GFp_simple_points_make_affine ec_GFp_simple_pts_make_affine
275#undef ec_GFp_simple_group_get_curve_GFp 297#undef ec_GFp_simple_group_get_curve_GFp
276#define ec_GFp_simple_group_get_curve_GFp ec_GFp_simple_grp_get_curve_GFp 298#define ec_GFp_simple_group_get_curve_GFp ec_GFp_simple_grp_get_curve_GFp
277#undef ec_GFp_simple_set_Jprojective_coordinates_GFp 299#undef ec_GFp_simple_set_Jprojective_coordinates_GFp
@@ -351,6 +373,14 @@
351#undef STORE_method_get_unlock_store_function 373#undef STORE_method_get_unlock_store_function
352#define STORE_method_get_unlock_store_function STORE_meth_get_unlock_store_fn 374#define STORE_method_get_unlock_store_function STORE_meth_get_unlock_store_fn
353 375
376/* Hack some long TS names */
377#undef TS_RESP_CTX_set_status_info_cond
378#define TS_RESP_CTX_set_status_info_cond TS_RESP_CTX_set_stat_info_cond
379#undef TS_RESP_CTX_set_clock_precision_digits
380#define TS_RESP_CTX_set_clock_precision_digits TS_RESP_CTX_set_clk_prec_digits
381#undef TS_CONF_set_clock_precision_digits
382#define TS_CONF_set_clock_precision_digits TS_CONF_set_clk_prec_digits
383
354/* Hack some long CMS names */ 384/* Hack some long CMS names */
355#undef CMS_RecipientInfo_ktri_get0_algs 385#undef CMS_RecipientInfo_ktri_get0_algs
356#define CMS_RecipientInfo_ktri_get0_algs CMS_RecipInfo_ktri_get0_algs 386#define CMS_RecipientInfo_ktri_get0_algs CMS_RecipInfo_ktri_get0_algs
@@ -365,24 +395,34 @@
365#undef cms_SignerIdentifier_get0_signer_id 395#undef cms_SignerIdentifier_get0_signer_id
366#define cms_SignerIdentifier_get0_signer_id cms_SignerId_get0_signer_id 396#define cms_SignerIdentifier_get0_signer_id cms_SignerId_get0_signer_id
367 397
398/* Hack some long DTLS1 names */
399#undef dtls1_retransmit_buffered_messages
400#define dtls1_retransmit_buffered_messages dtls1_retransmit_buffered_msgs
401
402/* Hack some long UI names */
403#undef UI_method_get_prompt_constructor
404#define UI_method_get_prompt_constructor UI_method_get_prompt_constructr
405#undef UI_method_set_prompt_constructor
406#define UI_method_set_prompt_constructor UI_method_set_prompt_constructr
407
368#endif /* defined OPENSSL_SYS_VMS */ 408#endif /* defined OPENSSL_SYS_VMS */
369 409
370 410
371/* Case insensiteve linking causes problems.... */ 411/* Case insensitive linking causes problems.... */
372#if defined(OPENSSL_SYS_WIN16) || defined(OPENSSL_SYS_VMS) || defined(OPENSSL_SYS_OS2) 412#if defined(OPENSSL_SYS_VMS) || defined(OPENSSL_SYS_OS2)
373#undef ERR_load_CRYPTO_strings 413#undef ERR_load_CRYPTO_strings
374#define ERR_load_CRYPTO_strings ERR_load_CRYPTOlib_strings 414#define ERR_load_CRYPTO_strings ERR_load_CRYPTOlib_strings
375#undef OCSP_crlID_new 415#undef OCSP_crlID_new
376#define OCSP_crlID_new OCSP_crlID2_new 416#define OCSP_crlID_new OCSP_crlID2_new
377 417
378#undef d2i_ECPARAMETERS 418#undef d2i_ECPARAMETERS
379#define d2i_ECPARAMETERS d2i_UC_ECPARAMETERS 419#define d2i_ECPARAMETERS d2i_UC_ECPARAMETERS
380#undef i2d_ECPARAMETERS 420#undef i2d_ECPARAMETERS
381#define i2d_ECPARAMETERS i2d_UC_ECPARAMETERS 421#define i2d_ECPARAMETERS i2d_UC_ECPARAMETERS
382#undef d2i_ECPKPARAMETERS 422#undef d2i_ECPKPARAMETERS
383#define d2i_ECPKPARAMETERS d2i_UC_ECPKPARAMETERS 423#define d2i_ECPKPARAMETERS d2i_UC_ECPKPARAMETERS
384#undef i2d_ECPKPARAMETERS 424#undef i2d_ECPKPARAMETERS
385#define i2d_ECPKPARAMETERS i2d_UC_ECPKPARAMETERS 425#define i2d_ECPKPARAMETERS i2d_UC_ECPKPARAMETERS
386 426
387/* These functions do not seem to exist! However, I'm paranoid... 427/* These functions do not seem to exist! However, I'm paranoid...
388 Original command in x509v3.h: 428 Original command in x509v3.h:
@@ -391,19 +431,19 @@
391 hide them a little, by giving them an extra 'o' at the 431 hide them a little, by giving them an extra 'o' at the
392 beginning of the name... */ 432 beginning of the name... */
393#undef X509v3_cleanup_extensions 433#undef X509v3_cleanup_extensions
394#define X509v3_cleanup_extensions oX509v3_cleanup_extensions 434#define X509v3_cleanup_extensions oX509v3_cleanup_extensions
395#undef X509v3_add_extension 435#undef X509v3_add_extension
396#define X509v3_add_extension oX509v3_add_extension 436#define X509v3_add_extension oX509v3_add_extension
397#undef X509v3_add_netscape_extensions 437#undef X509v3_add_netscape_extensions
398#define X509v3_add_netscape_extensions oX509v3_add_netscape_extensions 438#define X509v3_add_netscape_extensions oX509v3_add_netscape_extensions
399#undef X509v3_add_standard_extensions 439#undef X509v3_add_standard_extensions
400#define X509v3_add_standard_extensions oX509v3_add_standard_extensions 440#define X509v3_add_standard_extensions oX509v3_add_standard_extensions
401 441
442/* This one clashes with CMS_data_create */
443#undef cms_Data_create
444#define cms_Data_create priv_cms_Data_create
402 445
403#endif 446#endif
404 447
405 448
406#endif /* ! defined HEADER_VMS_IDHACKS_H */ 449#endif /* ! defined HEADER_VMS_IDHACKS_H */
407/* This one clashes with CMS_data_create */
408#undef cms_Data_create
409#define cms_Data_create priv_cms_Data_create
diff --git a/src/lib/libcrypto/threads/mttest.c b/src/lib/libcrypto/threads/mttest.c
index f6f3df4b6a..eba7aa8a6e 100644
--- a/src/lib/libcrypto/threads/mttest.c
+++ b/src/lib/libcrypto/threads/mttest.c
@@ -117,11 +117,13 @@ void solaris_locking_callback(int mode,int type,char *file,int line);
117void win32_locking_callback(int mode,int type,char *file,int line); 117void win32_locking_callback(int mode,int type,char *file,int line);
118void pthreads_locking_callback(int mode,int type,char *file,int line); 118void pthreads_locking_callback(int mode,int type,char *file,int line);
119void netware_locking_callback(int mode,int type,char *file,int line); 119void netware_locking_callback(int mode,int type,char *file,int line);
120void beos_locking_callback(int mode,int type,const char *file,int line);
120 121
121unsigned long irix_thread_id(void ); 122unsigned long irix_thread_id(void );
122unsigned long solaris_thread_id(void ); 123unsigned long solaris_thread_id(void );
123unsigned long pthreads_thread_id(void ); 124unsigned long pthreads_thread_id(void );
124unsigned long netware_thread_id(void ); 125unsigned long netware_thread_id(void );
126unsigned long beos_thread_id(void );
125 127
126#if defined(OPENSSL_SYS_NETWARE) 128#if defined(OPENSSL_SYS_NETWARE)
127static MPKMutex *lock_cs; 129static MPKMutex *lock_cs;
@@ -1209,3 +1211,100 @@ unsigned long netware_thread_id(void)
1209 return(ret); 1211 return(ret);
1210} 1212}
1211#endif /* NETWARE */ 1213#endif /* NETWARE */
1214
1215#ifdef BEOS_THREADS
1216
1217#include <Locker.h>
1218
1219static BLocker** lock_cs;
1220static long* lock_count;
1221
1222void thread_setup(void)
1223 {
1224 int i;
1225
1226 lock_cs=(BLocker**)OPENSSL_malloc(CRYPTO_num_locks() * sizeof(BLocker*));
1227 lock_count=(long*)OPENSSL_malloc(CRYPTO_num_locks() * sizeof(long));
1228 for (i=0; i<CRYPTO_num_locks(); i++)
1229 {
1230 lock_count[i]=0;
1231 lock_cs[i] = new BLocker(CRYPTO_get_lock_name(i));
1232 }
1233
1234 CRYPTO_set_id_callback((unsigned long (*)())beos_thread_id);
1235 CRYPTO_set_locking_callback(beos_locking_callback);
1236 }
1237
1238void thread_cleanup(void)
1239 {
1240 int i;
1241
1242 CRYPTO_set_locking_callback(NULL);
1243 fprintf(stderr,"cleanup\n");
1244 for (i=0; i<CRYPTO_num_locks(); i++)
1245 {
1246 delete lock_cs[i];
1247 fprintf(stderr,"%8ld:%s\n",lock_count[i],
1248 CRYPTO_get_lock_name(i));
1249 }
1250 OPENSSL_free(lock_cs);
1251 OPENSSL_free(lock_count);
1252
1253 fprintf(stderr,"done cleanup\n");
1254 }
1255
1256void beos_locking_callback(int mode, int type, const char *file, int line)
1257 {
1258#if 0
1259 fprintf(stderr,"thread=%4d mode=%s lock=%s %s:%d\n",
1260 CRYPTO_thread_id(),
1261 (mode&CRYPTO_LOCK)?"l":"u",
1262 (type&CRYPTO_READ)?"r":"w",file,line);
1263#endif
1264 if (mode & CRYPTO_LOCK)
1265 {
1266 lock_cs[type]->Lock();
1267 lock_count[type]++;
1268 }
1269 else
1270 {
1271 lock_cs[type]->Unlock();
1272 }
1273 }
1274
1275void do_threads(SSL_CTX *s_ctx, SSL_CTX *c_ctx)
1276 {
1277 SSL_CTX *ssl_ctx[2];
1278 thread_id thread_ctx[MAX_THREAD_NUMBER];
1279 int i;
1280
1281 ssl_ctx[0]=s_ctx;
1282 ssl_ctx[1]=c_ctx;
1283
1284 for (i=0; i<thread_number; i++)
1285 {
1286 thread_ctx[i] = spawn_thread((thread_func)ndoit,
1287 NULL, B_NORMAL_PRIORITY, (void *)ssl_ctx);
1288 resume_thread(thread_ctx[i]);
1289 }
1290
1291 printf("waiting...\n");
1292 for (i=0; i<thread_number; i++)
1293 {
1294 status_t result;
1295 wait_for_thread(thread_ctx[i], &result);
1296 }
1297
1298 printf("beos threads done (%d,%d)\n",
1299 s_ctx->references,c_ctx->references);
1300 }
1301
1302unsigned long beos_thread_id(void)
1303 {
1304 unsigned long ret;
1305
1306 ret=(unsigned long)find_thread(NULL);
1307 return(ret);
1308 }
1309
1310#endif /* BEOS_THREADS */
diff --git a/src/lib/libcrypto/threads/pthreads-vms.com b/src/lib/libcrypto/threads/pthreads-vms.com
index 63f5b8cc2e..1cf92bdf57 100644
--- a/src/lib/libcrypto/threads/pthreads-vms.com
+++ b/src/lib/libcrypto/threads/pthreads-vms.com
@@ -2,8 +2,13 @@ $! To compile mttest on VMS.
2$! 2$!
3$! WARNING: only tested with DEC C so far. 3$! WARNING: only tested with DEC C so far.
4$ 4$
5$ arch := vax 5$ if (f$getsyi("cpu").lt.128)
6$ if f$getsyi("CPU") .ge. 128 then arch := axp 6$ then
7$ arch := VAX
8$ else
9$ arch = f$edit( f$getsyi( "ARCH_NAME"), "UPCASE")
10$ if (arch .eqs. "") then arch = "UNK"
11$ endif
7$ define/user openssl [--.include.openssl] 12$ define/user openssl [--.include.openssl]
8$ cc/def=PTHREADS mttest.c 13$ cc/def=PTHREADS mttest.c
9$ link mttest,[--.'arch'.exe.ssl]libssl/lib,[--.'arch'.exe.crypto]libcrypto/lib 14$ link mttest,[--.'arch'.exe.ssl]libssl/lib,[--.'arch'.exe.crypto]libcrypto/lib
diff --git a/src/lib/libcrypto/tmdiff.c b/src/lib/libcrypto/tmdiff.c
deleted file mode 100644
index 1c6e052ac9..0000000000
--- a/src/lib/libcrypto/tmdiff.c
+++ /dev/null
@@ -1,260 +0,0 @@
1/* crypto/tmdiff.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#include <stdio.h>
59#include <stdlib.h>
60#include "cryptlib.h"
61#include <openssl/tmdiff.h>
62#if !defined(OPENSSL_SYS_MSDOS)
63#include OPENSSL_UNISTD
64#endif
65
66#ifdef TIMEB
67#undef OPENSSL_SYS_WIN32
68#undef TIMES
69#endif
70
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)
72# define TIMES
73#endif
74
75#ifdef OPENSSL_SYS_NETWARE
76#undef TIMES
77#endif
78
79#if !defined(_IRIX) || defined (OPENSSL_SYS_NETWARE)
80# include <time.h>
81#endif
82#ifdef TIMES
83# include <sys/types.h>
84# include <sys/times.h>
85#endif
86
87/* Depending on the VMS version, the tms structure is perhaps defined.
88 The __TMS macro will show if it was. If it wasn't defined, we should
89 undefine TIMES, since that tells the rest of the program how things
90 should be handled. -- Richard Levitte */
91#if defined(OPENSSL_SYS_VMS_DECC) && !defined(__TMS)
92#undef TIMES
93#endif
94
95#if defined(sun) || defined(__ultrix)
96#define _POSIX_SOURCE
97#include <limits.h>
98#include <sys/param.h>
99#endif
100
101#if !defined(TIMES) && !defined(OPENSSL_SYS_VXWORKS) && !defined(OPENSSL_SYS_NETWARE)
102#include <sys/timeb.h>
103#endif
104
105#ifdef OPENSSL_SYS_WIN32
106#include <windows.h>
107#endif
108
109/* The following if from times(3) man page. It may need to be changed */
110#ifndef HZ
111# if defined(_SC_CLK_TCK) \
112 && (!defined(OPENSSL_SYS_VMS) || __CTRL_VER >= 70000000)
113/* # define HZ ((double)sysconf(_SC_CLK_TCK)) */
114# define HZ sysconf(_SC_CLK_TCK)
115# else
116# ifndef CLK_TCK
117# ifndef _BSD_CLK_TCK_ /* FreeBSD hack */
118# define HZ 100.0
119# else /* _BSD_CLK_TCK_ */
120# define HZ ((double)_BSD_CLK_TCK_)
121# endif
122# else /* CLK_TCK */
123# define HZ ((double)CLK_TCK)
124# endif
125# endif
126#endif
127
128struct ms_tm
129 {
130#ifdef TIMES
131 struct tms ms_tms;
132#else
133# ifdef OPENSSL_SYS_WIN32
134 HANDLE thread_id;
135 FILETIME ms_win32;
136# elif defined (OPENSSL_SYS_NETWARE)
137 clock_t ms_clock;
138# else
139# ifdef OPENSSL_SYS_VXWORKS
140 unsigned long ticks;
141# else
142 struct timeb ms_timeb;
143# endif
144# endif
145#endif
146 };
147
148MS_TM *ms_time_new(void)
149 {
150 MS_TM *ret;
151
152 ret=(MS_TM *)OPENSSL_malloc(sizeof(MS_TM));
153 if (ret == NULL)
154 return(NULL);
155 memset(ret,0,sizeof(MS_TM));
156#ifdef OPENSSL_SYS_WIN32
157 ret->thread_id=GetCurrentThread();
158#endif
159 return ret;
160 }
161
162void ms_time_free(MS_TM *a)
163 {
164 if (a != NULL)
165 OPENSSL_free(a);
166 }
167
168void ms_time_get(MS_TM *tm)
169 {
170#ifdef OPENSSL_SYS_WIN32
171 FILETIME tmpa,tmpb,tmpc;
172#endif
173
174#ifdef TIMES
175 times(&tm->ms_tms);
176#else
177# ifdef OPENSSL_SYS_WIN32
178 GetThreadTimes(tm->thread_id,&tmpa,&tmpb,&tmpc,&(tm->ms_win32));
179# elif defined (OPENSSL_SYS_NETWARE)
180 tm->ms_clock = clock();
181# else
182# ifdef OPENSSL_SYS_VXWORKS
183 tm->ticks = tickGet();
184# else
185 ftime(&tm->ms_timeb);
186# endif
187# endif
188#endif
189 }
190
191double ms_time_diff(MS_TM *a, MS_TM *b)
192 {
193 double ret;
194
195#ifdef TIMES
196 ret = HZ;
197 ret = (b->ms_tms.tms_utime-a->ms_tms.tms_utime) / ret;
198#else
199# ifdef OPENSSL_SYS_WIN32
200 {
201#ifdef __GNUC__
202 signed long long la,lb;
203#else
204 signed _int64 la,lb;
205#endif
206 la=a->ms_win32.dwHighDateTime;
207 lb=b->ms_win32.dwHighDateTime;
208 la<<=32;
209 lb<<=32;
210 la+=a->ms_win32.dwLowDateTime;
211 lb+=b->ms_win32.dwLowDateTime;
212 ret=((double)(lb-la))/1e7;
213 }
214# elif defined (OPENSSL_SYS_NETWARE)
215 ret= (double)(b->ms_clock - a->ms_clock);
216# else
217# ifdef OPENSSL_SYS_VXWORKS
218 ret = (double)(b->ticks - a->ticks) / (double)sysClkRateGet();
219# else
220 ret= (double)(b->ms_timeb.time-a->ms_timeb.time)+
221 (((double)b->ms_timeb.millitm)-
222 ((double)a->ms_timeb.millitm))/1000.0;
223# endif
224# endif
225#endif
226 return((ret < 0.0000001)?0.0000001:ret);
227 }
228
229int ms_time_cmp(const MS_TM *a, const MS_TM *b)
230 {
231 double d;
232 int ret;
233
234#ifdef TIMES
235 d = HZ;
236 d = (b->ms_tms.tms_utime-a->ms_tms.tms_utime) / d;
237#else
238# ifdef OPENSSL_SYS_WIN32
239 d =(b->ms_win32.dwHighDateTime&0x000fffff)*10+b->ms_win32.dwLowDateTime/1e7;
240 d-=(a->ms_win32.dwHighDateTime&0x000fffff)*10+a->ms_win32.dwLowDateTime/1e7;
241# elif defined (OPENSSL_SYS_NETWARE)
242 d= (double)(b->ms_clock - a->ms_clock);
243# else
244# ifdef OPENSSL_SYS_VXWORKS
245 d = (b->ticks - a->ticks);
246# else
247 d= (double)(b->ms_timeb.time-a->ms_timeb.time)+
248 (((double)b->ms_timeb.millitm)-(double)a->ms_timeb.millitm)/1000.0;
249# endif
250# endif
251#endif
252 if (d == 0.0)
253 ret=0;
254 else if (d < 0)
255 ret= -1;
256 else
257 ret=1;
258 return(ret);
259 }
260
diff --git a/src/lib/libcrypto/tmdiff.h b/src/lib/libcrypto/tmdiff.h
deleted file mode 100644
index af5c41c649..0000000000
--- a/src/lib/libcrypto/tmdiff.h
+++ /dev/null
@@ -1,93 +0,0 @@
1/* crypto/tmdiff.h */
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/* Header for dynamic hash table routines
60 * Author - Eric Young
61 */
62/* ... erm yeah, "dynamic hash tables" you say?
63 *
64 * And what would dynamic hash tables have to do with any of this code *now*?
65 * AFAICS, this code is only referenced by crypto/bn/exp.c which is an unused
66 * file that I doubt compiles any more. speed.c is the only thing that could
67 * use this (and it has nothing to do with hash tables), yet it instead has its
68 * own duplication of all this stuff and looks, if anything, more complete. See
69 * the corresponding note in apps/speed.c.
70 * The Bemused - Geoff
71 */
72
73#ifndef HEADER_TMDIFF_H
74#define HEADER_TMDIFF_H
75
76#ifdef __cplusplus
77extern "C" {
78#endif
79
80typedef struct ms_tm MS_TM;
81
82MS_TM *ms_time_new(void );
83void ms_time_free(MS_TM *a);
84void ms_time_get(MS_TM *a);
85double ms_time_diff(MS_TM *start, MS_TM *end);
86int ms_time_cmp(const MS_TM *ap, const MS_TM *bp);
87
88#ifdef __cplusplus
89}
90#endif
91
92#endif
93
diff --git a/src/lib/libcrypto/ts/ts_rsp_verify.c b/src/lib/libcrypto/ts/ts_rsp_verify.c
index e1f3b534af..ed0252d7d7 100644
--- a/src/lib/libcrypto/ts/ts_rsp_verify.c
+++ b/src/lib/libcrypto/ts/ts_rsp_verify.c
@@ -509,15 +509,17 @@ static int TS_check_status_info(TS_RESP *response)
509 TS_failure_info[i].code)) 509 TS_failure_info[i].code))
510 { 510 {
511 if (!first) 511 if (!first)
512 strcpy(failure_text, ","); 512 strlcat(failure_text, ",",
513 TS_STATUS_BUF_SIZE);
513 else 514 else
514 first = 0; 515 first = 0;
515 strcat(failure_text, TS_failure_info[i].text); 516 strlcat(failure_text, TS_failure_info[i].text,
517 TS_STATUS_BUF_SIZE);
516 } 518 }
517 } 519 }
518 } 520 }
519 if (failure_text[0] == '\0') 521 if (failure_text[0] == '\0')
520 strcpy(failure_text, "unspecified"); 522 strlcpy(failure_text, "unspecified", TS_STATUS_BUF_SIZE);
521 523
522 /* Making up the error string. */ 524 /* Making up the error string. */
523 TSerr(TS_F_TS_CHECK_STATUS_INFO, TS_R_NO_TIME_STAMP_TOKEN); 525 TSerr(TS_F_TS_CHECK_STATUS_INFO, TS_R_NO_TIME_STAMP_TOKEN);
diff --git a/src/lib/libcrypto/txt_db/Makefile.ssl b/src/lib/libcrypto/txt_db/Makefile.ssl
deleted file mode 100644
index 6221dfae4d..0000000000
--- a/src/lib/libcrypto/txt_db/Makefile.ssl
+++ /dev/null
@@ -1,88 +0,0 @@
1#
2# SSLeay/crypto/txt_db/Makefile
3#
4
5DIR= txt_db
6TOP= ../..
7CC= cc
8INCLUDES=
9CFLAG=-g
10INSTALL_PREFIX=
11OPENSSLDIR= /usr/local/ssl
12INSTALLTOP=/usr/local/ssl
13MAKE= make -f Makefile.ssl
14MAKEDEPPROG= makedepend
15MAKEDEPEND= $(TOP)/util/domd $(TOP) -MD $(MAKEDEPPROG)
16MAKEFILE= Makefile.ssl
17AR= ar r
18
19CFLAGS= $(INCLUDES) $(CFLAG)
20
21GENERAL=Makefile
22TEST=
23APPS=
24
25LIB=$(TOP)/libcrypto.a
26LIBSRC=txt_db.c
27LIBOBJ=txt_db.o
28
29SRC= $(LIBSRC)
30
31EXHEADER= txt_db.h
32HEADER= $(EXHEADER)
33
34ALL= $(GENERAL) $(SRC) $(HEADER)
35
36top:
37 (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all)
38
39all: lib
40
41lib: $(LIBOBJ)
42 $(AR) $(LIB) $(LIBOBJ)
43 $(RANLIB) $(LIB) || echo Never mind.
44 @touch lib
45
46files:
47 $(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO
48
49links:
50 @sh $(TOP)/util/point.sh Makefile.ssl Makefile
51 @$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER)
52 @$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST)
53 @$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS)
54
55install:
56 @for i in $(EXHEADER) ; \
57 do \
58 (cp $$i $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i; \
59 chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i ); \
60 done;
61
62tags:
63 ctags $(SRC)
64
65tests:
66
67lint:
68 lint -DLINT $(INCLUDES) $(SRC)>fluff
69
70depend:
71 $(MAKEDEPEND) -- $(CFLAG) $(INCLUDES) $(DEPFLAG) -- $(PROGS) $(LIBSRC)
72
73dclean:
74 $(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
75 mv -f Makefile.new $(MAKEFILE)
76
77clean:
78 rm -f *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff
79
80# DO NOT DELETE THIS LINE -- make depend depends on it.
81
82txt_db.o: ../../e_os.h ../../include/openssl/bio.h
83txt_db.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
84txt_db.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
85txt_db.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
86txt_db.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
87txt_db.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
88txt_db.o: ../../include/openssl/txt_db.h ../cryptlib.h txt_db.c
diff --git a/src/lib/libcrypto/txt_db/txt_db.c b/src/lib/libcrypto/txt_db/txt_db.c
index 3ed5f72ee9..6f2ce3b5a4 100644
--- a/src/lib/libcrypto/txt_db/txt_db.c
+++ b/src/lib/libcrypto/txt_db/txt_db.c
@@ -77,22 +77,23 @@ TXT_DB *TXT_DB_read(BIO *in, int num)
77 int i,add,n; 77 int i,add,n;
78 int size=BUFSIZE; 78 int size=BUFSIZE;
79 int offset=0; 79 int offset=0;
80 char *p,**pp,*f; 80 char *p,*f;
81 OPENSSL_STRING *pp;
81 BUF_MEM *buf=NULL; 82 BUF_MEM *buf=NULL;
82 83
83 if ((buf=BUF_MEM_new()) == NULL) goto err; 84 if ((buf=BUF_MEM_new()) == NULL) goto err;
84 if (!BUF_MEM_grow(buf,size)) goto err; 85 if (!BUF_MEM_grow(buf,size)) goto err;
85 86
86 if ((ret=(TXT_DB *)OPENSSL_malloc(sizeof(TXT_DB))) == NULL) 87 if ((ret=OPENSSL_malloc(sizeof(TXT_DB))) == NULL)
87 goto err; 88 goto err;
88 ret->num_fields=num; 89 ret->num_fields=num;
89 ret->index=NULL; 90 ret->index=NULL;
90 ret->qual=NULL; 91 ret->qual=NULL;
91 if ((ret->data=sk_new_null()) == NULL) 92 if ((ret->data=sk_OPENSSL_PSTRING_new_null()) == NULL)
92 goto err; 93 goto err;
93 if ((ret->index=(LHASH **)OPENSSL_malloc(sizeof(LHASH *)*num)) == NULL) 94 if ((ret->index=OPENSSL_malloc(sizeof(*ret->index)*num)) == NULL)
94 goto err; 95 goto err;
95 if ((ret->qual=(int (**)(char **))OPENSSL_malloc(sizeof(int (**)(char **))*num)) == NULL) 96 if ((ret->qual=OPENSSL_malloc(sizeof(*(ret->qual))*num)) == NULL)
96 goto err; 97 goto err;
97 for (i=0; i<num; i++) 98 for (i=0; i<num; i++)
98 { 99 {
@@ -122,7 +123,7 @@ TXT_DB *TXT_DB_read(BIO *in, int num)
122 else 123 else
123 { 124 {
124 buf->data[offset-1]='\0'; /* blat the '\n' */ 125 buf->data[offset-1]='\0'; /* blat the '\n' */
125 if (!(p=(char *)OPENSSL_malloc(add+offset))) goto err; 126 if (!(p=OPENSSL_malloc(add+offset))) goto err;
126 offset=0; 127 offset=0;
127 } 128 }
128 pp=(char **)p; 129 pp=(char **)p;
@@ -155,16 +156,16 @@ TXT_DB *TXT_DB_read(BIO *in, int num)
155 *(p++)='\0'; 156 *(p++)='\0';
156 if ((n != num) || (*f != '\0')) 157 if ((n != num) || (*f != '\0'))
157 { 158 {
158#if !defined(OPENSSL_NO_STDIO) && !defined(OPENSSL_SYS_WIN16) /* temporaty fix :-( */ 159#if !defined(OPENSSL_NO_STDIO) && !defined(OPENSSL_SYS_WIN16) /* temporary fix :-( */
159 fprintf(stderr,"wrong number of fields on line %ld (looking for field %d, got %d, '%s' left)\n",ln,num,n,f); 160 fprintf(stderr,"wrong number of fields on line %ld (looking for field %d, got %d, '%s' left)\n",ln,num,n,f);
160#endif 161#endif
161 er=2; 162 er=2;
162 goto err; 163 goto err;
163 } 164 }
164 pp[n]=p; 165 pp[n]=p;
165 if (!sk_push(ret->data,(char *)pp)) 166 if (!sk_OPENSSL_PSTRING_push(ret->data,pp))
166 { 167 {
167#if !defined(OPENSSL_NO_STDIO) && !defined(OPENSSL_SYS_WIN16) /* temporaty fix :-( */ 168#if !defined(OPENSSL_NO_STDIO) && !defined(OPENSSL_SYS_WIN16) /* temporary fix :-( */
168 fprintf(stderr,"failure in sk_push\n"); 169 fprintf(stderr,"failure in sk_push\n");
169#endif 170#endif
170 er=2; 171 er=2;
@@ -181,7 +182,7 @@ err:
181#endif 182#endif
182 if (ret != NULL) 183 if (ret != NULL)
183 { 184 {
184 if (ret->data != NULL) sk_free(ret->data); 185 if (ret->data != NULL) sk_OPENSSL_PSTRING_free(ret->data);
185 if (ret->index != NULL) OPENSSL_free(ret->index); 186 if (ret->index != NULL) OPENSSL_free(ret->index);
186 if (ret->qual != NULL) OPENSSL_free(ret->qual); 187 if (ret->qual != NULL) OPENSSL_free(ret->qual);
187 if (ret != NULL) OPENSSL_free(ret); 188 if (ret != NULL) OPENSSL_free(ret);
@@ -192,10 +193,10 @@ err:
192 return(ret); 193 return(ret);
193 } 194 }
194 195
195char **TXT_DB_get_by_index(TXT_DB *db, int idx, char **value) 196OPENSSL_STRING *TXT_DB_get_by_index(TXT_DB *db, int idx, OPENSSL_STRING *value)
196 { 197 {
197 char **ret; 198 OPENSSL_STRING *ret;
198 LHASH *lh; 199 LHASH_OF(OPENSSL_STRING) *lh;
199 200
200 if (idx >= db->num_fields) 201 if (idx >= db->num_fields)
201 { 202 {
@@ -208,16 +209,16 @@ char **TXT_DB_get_by_index(TXT_DB *db, int idx, char **value)
208 db->error=DB_ERROR_NO_INDEX; 209 db->error=DB_ERROR_NO_INDEX;
209 return(NULL); 210 return(NULL);
210 } 211 }
211 ret=(char **)lh_retrieve(lh,value); 212 ret=lh_OPENSSL_STRING_retrieve(lh,value);
212 db->error=DB_ERROR_OK; 213 db->error=DB_ERROR_OK;
213 return(ret); 214 return(ret);
214 } 215 }
215 216
216int TXT_DB_create_index(TXT_DB *db, int field, int (*qual)(char **), 217int TXT_DB_create_index(TXT_DB *db, int field, int (*qual)(OPENSSL_STRING *),
217 LHASH_HASH_FN_TYPE hash, LHASH_COMP_FN_TYPE cmp) 218 LHASH_HASH_FN_TYPE hash, LHASH_COMP_FN_TYPE cmp)
218 { 219 {
219 LHASH *idx; 220 LHASH_OF(OPENSSL_STRING) *idx;
220 char **r; 221 OPENSSL_STRING *r;
221 int i,n; 222 int i,n;
222 223
223 if (field >= db->num_fields) 224 if (field >= db->num_fields)
@@ -225,26 +226,27 @@ int TXT_DB_create_index(TXT_DB *db, int field, int (*qual)(char **),
225 db->error=DB_ERROR_INDEX_OUT_OF_RANGE; 226 db->error=DB_ERROR_INDEX_OUT_OF_RANGE;
226 return(0); 227 return(0);
227 } 228 }
228 if ((idx=lh_new(hash,cmp)) == NULL) 229 /* FIXME: we lose type checking at this point */
230 if ((idx=(LHASH_OF(OPENSSL_STRING) *)lh_new(hash,cmp)) == NULL)
229 { 231 {
230 db->error=DB_ERROR_MALLOC; 232 db->error=DB_ERROR_MALLOC;
231 return(0); 233 return(0);
232 } 234 }
233 n=sk_num(db->data); 235 n=sk_OPENSSL_PSTRING_num(db->data);
234 for (i=0; i<n; i++) 236 for (i=0; i<n; i++)
235 { 237 {
236 r=(char **)sk_value(db->data,i); 238 r=sk_OPENSSL_PSTRING_value(db->data,i);
237 if ((qual != NULL) && (qual(r) == 0)) continue; 239 if ((qual != NULL) && (qual(r) == 0)) continue;
238 if ((r=lh_insert(idx,r)) != NULL) 240 if ((r=lh_OPENSSL_STRING_insert(idx,r)) != NULL)
239 { 241 {
240 db->error=DB_ERROR_INDEX_CLASH; 242 db->error=DB_ERROR_INDEX_CLASH;
241 db->arg1=sk_find(db->data,(char *)r); 243 db->arg1=sk_OPENSSL_PSTRING_find(db->data,r);
242 db->arg2=i; 244 db->arg2=i;
243 lh_free(idx); 245 lh_OPENSSL_STRING_free(idx);
244 return(0); 246 return(0);
245 } 247 }
246 } 248 }
247 if (db->index[field] != NULL) lh_free(db->index[field]); 249 if (db->index[field] != NULL) lh_OPENSSL_STRING_free(db->index[field]);
248 db->index[field]=idx; 250 db->index[field]=idx;
249 db->qual[field]=qual; 251 db->qual[field]=qual;
250 return(1); 252 return(1);
@@ -259,11 +261,11 @@ long TXT_DB_write(BIO *out, TXT_DB *db)
259 261
260 if ((buf=BUF_MEM_new()) == NULL) 262 if ((buf=BUF_MEM_new()) == NULL)
261 goto err; 263 goto err;
262 n=sk_num(db->data); 264 n=sk_OPENSSL_PSTRING_num(db->data);
263 nn=db->num_fields; 265 nn=db->num_fields;
264 for (i=0; i<n; i++) 266 for (i=0; i<n; i++)
265 { 267 {
266 pp=(char **)sk_value(db->data,i); 268 pp=sk_OPENSSL_PSTRING_value(db->data,i);
267 269
268 l=0; 270 l=0;
269 for (j=0; j<nn; j++) 271 for (j=0; j<nn; j++)
@@ -298,10 +300,10 @@ err:
298 return(ret); 300 return(ret);
299 } 301 }
300 302
301int TXT_DB_insert(TXT_DB *db, char **row) 303int TXT_DB_insert(TXT_DB *db, OPENSSL_STRING *row)
302 { 304 {
303 int i; 305 int i;
304 char **r; 306 OPENSSL_STRING *r;
305 307
306 for (i=0; i<db->num_fields; i++) 308 for (i=0; i<db->num_fields; i++)
307 { 309 {
@@ -309,7 +311,7 @@ int TXT_DB_insert(TXT_DB *db, char **row)
309 { 311 {
310 if ((db->qual[i] != NULL) && 312 if ((db->qual[i] != NULL) &&
311 (db->qual[i](row) == 0)) continue; 313 (db->qual[i](row) == 0)) continue;
312 r=(char **)lh_retrieve(db->index[i],row); 314 r=lh_OPENSSL_STRING_retrieve(db->index[i],row);
313 if (r != NULL) 315 if (r != NULL)
314 { 316 {
315 db->error=DB_ERROR_INDEX_CLASH; 317 db->error=DB_ERROR_INDEX_CLASH;
@@ -320,7 +322,7 @@ int TXT_DB_insert(TXT_DB *db, char **row)
320 } 322 }
321 } 323 }
322 /* We have passed the index checks, now just append and insert */ 324 /* We have passed the index checks, now just append and insert */
323 if (!sk_push(db->data,(char *)row)) 325 if (!sk_OPENSSL_PSTRING_push(db->data,row))
324 { 326 {
325 db->error=DB_ERROR_MALLOC; 327 db->error=DB_ERROR_MALLOC;
326 goto err; 328 goto err;
@@ -332,7 +334,7 @@ int TXT_DB_insert(TXT_DB *db, char **row)
332 { 334 {
333 if ((db->qual[i] != NULL) && 335 if ((db->qual[i] != NULL) &&
334 (db->qual[i](row) == 0)) continue; 336 (db->qual[i](row) == 0)) continue;
335 lh_insert(db->index[i],row); 337 (void)lh_OPENSSL_STRING_insert(db->index[i],row);
336 } 338 }
337 } 339 }
338 return(1); 340 return(1);
@@ -351,18 +353,18 @@ void TXT_DB_free(TXT_DB *db)
351 if (db->index != NULL) 353 if (db->index != NULL)
352 { 354 {
353 for (i=db->num_fields-1; i>=0; i--) 355 for (i=db->num_fields-1; i>=0; i--)
354 if (db->index[i] != NULL) lh_free(db->index[i]); 356 if (db->index[i] != NULL) lh_OPENSSL_STRING_free(db->index[i]);
355 OPENSSL_free(db->index); 357 OPENSSL_free(db->index);
356 } 358 }
357 if (db->qual != NULL) 359 if (db->qual != NULL)
358 OPENSSL_free(db->qual); 360 OPENSSL_free(db->qual);
359 if (db->data != NULL) 361 if (db->data != NULL)
360 { 362 {
361 for (i=sk_num(db->data)-1; i>=0; i--) 363 for (i=sk_OPENSSL_PSTRING_num(db->data)-1; i>=0; i--)
362 { 364 {
363 /* check if any 'fields' have been allocated 365 /* check if any 'fields' have been allocated
364 * from outside of the initial block */ 366 * from outside of the initial block */
365 p=(char **)sk_value(db->data,i); 367 p=sk_OPENSSL_PSTRING_value(db->data,i);
366 max=p[db->num_fields]; /* last address */ 368 max=p[db->num_fields]; /* last address */
367 if (max == NULL) /* new row */ 369 if (max == NULL) /* new row */
368 { 370 {
@@ -378,9 +380,9 @@ void TXT_DB_free(TXT_DB *db)
378 OPENSSL_free(p[n]); 380 OPENSSL_free(p[n]);
379 } 381 }
380 } 382 }
381 OPENSSL_free(sk_value(db->data,i)); 383 OPENSSL_free(sk_OPENSSL_PSTRING_value(db->data,i));
382 } 384 }
383 sk_free(db->data); 385 sk_OPENSSL_PSTRING_free(db->data);
384 } 386 }
385 OPENSSL_free(db); 387 OPENSSL_free(db);
386 } 388 }
diff --git a/src/lib/libcrypto/txt_db/txt_db.h b/src/lib/libcrypto/txt_db/txt_db.h
index 307e1ba23f..6abe435bc8 100644
--- a/src/lib/libcrypto/txt_db/txt_db.h
+++ b/src/lib/libcrypto/txt_db/txt_db.h
@@ -77,16 +77,19 @@
77extern "C" { 77extern "C" {
78#endif 78#endif
79 79
80typedef OPENSSL_STRING *OPENSSL_PSTRING;
81DECLARE_SPECIAL_STACK_OF(OPENSSL_PSTRING, OPENSSL_STRING)
82
80typedef struct txt_db_st 83typedef struct txt_db_st
81 { 84 {
82 int num_fields; 85 int num_fields;
83 STACK /* char ** */ *data; 86 STACK_OF(OPENSSL_PSTRING) *data;
84 LHASH **index; 87 LHASH_OF(OPENSSL_STRING) **index;
85 int (**qual)(char **); 88 int (**qual)(OPENSSL_STRING *);
86 long error; 89 long error;
87 long arg1; 90 long arg1;
88 long arg2; 91 long arg2;
89 char **arg_row; 92 OPENSSL_STRING *arg_row;
90 } TXT_DB; 93 } TXT_DB;
91 94
92#ifndef OPENSSL_NO_BIO 95#ifndef OPENSSL_NO_BIO
@@ -96,11 +99,11 @@ long TXT_DB_write(BIO *out, TXT_DB *db);
96TXT_DB *TXT_DB_read(char *in, int num); 99TXT_DB *TXT_DB_read(char *in, int num);
97long TXT_DB_write(char *out, TXT_DB *db); 100long TXT_DB_write(char *out, TXT_DB *db);
98#endif 101#endif
99int TXT_DB_create_index(TXT_DB *db,int field,int (*qual)(char **), 102int TXT_DB_create_index(TXT_DB *db,int field,int (*qual)(OPENSSL_STRING *),
100 LHASH_HASH_FN_TYPE hash, LHASH_COMP_FN_TYPE cmp); 103 LHASH_HASH_FN_TYPE hash, LHASH_COMP_FN_TYPE cmp);
101void TXT_DB_free(TXT_DB *db); 104void TXT_DB_free(TXT_DB *db);
102char **TXT_DB_get_by_index(TXT_DB *db, int idx, char **value); 105OPENSSL_STRING *TXT_DB_get_by_index(TXT_DB *db, int idx, OPENSSL_STRING *value);
103int TXT_DB_insert(TXT_DB *db,char **value); 106int TXT_DB_insert(TXT_DB *db, OPENSSL_STRING *value);
104 107
105#ifdef __cplusplus 108#ifdef __cplusplus
106} 109}
diff --git a/src/lib/libcrypto/ui/Makefile.ssl b/src/lib/libcrypto/ui/Makefile.ssl
deleted file mode 100644
index ba46951d1c..0000000000
--- a/src/lib/libcrypto/ui/Makefile.ssl
+++ /dev/null
@@ -1,117 +0,0 @@
1#
2# OpenSSL/crypto/ui/Makefile
3#
4
5DIR= ui
6TOP= ../..
7CC= cc
8INCLUDES= -I.. -I$(TOP) -I../../include
9CFLAG=-g
10INSTALL_PREFIX=
11OPENSSLDIR= /usr/local/ssl
12INSTALLTOP=/usr/local/ssl
13MAKE= make -f Makefile.ssl
14MAKEDEPPROG= makedepend
15MAKEDEPEND= $(TOP)/util/domd $(TOP) -MD $(MAKEDEPPROG)
16MAKEFILE= Makefile.ssl
17AR= ar r
18
19CFLAGS= $(INCLUDES) $(CFLAG)
20
21GENERAL=Makefile
22#TEST= uitest.c
23TEST=
24APPS=
25
26COMPATSRC= ui_compat.c
27COMPATOBJ= ui_compat.o
28
29LIB=$(TOP)/libcrypto.a
30LIBSRC= ui_err.c ui_lib.c ui_openssl.c ui_util.c $(COMPATSRC)
31LIBOBJ= ui_err.o ui_lib.o ui_openssl.o ui_util.o $(COMPATOBJ)
32
33SRC= $(LIBSRC)
34
35EXHEADER= ui.h ui_compat.h
36HEADER= $(EXHEADER) ui_locl.h
37
38ALL= $(GENERAL) $(SRC) $(HEADER)
39
40top:
41 (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all)
42
43all: lib
44
45lib: $(LIBOBJ)
46 $(AR) $(LIB) $(LIBOBJ)
47 $(RANLIB) $(LIB) || echo Never mind.
48 @touch lib
49
50files:
51 $(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO
52
53links:
54 @sh $(TOP)/util/point.sh Makefile.ssl Makefile
55 @$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER)
56 @$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST)
57 @$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS)
58
59install:
60 @for i in $(EXHEADER) ; \
61 do \
62 (cp $$i $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i; \
63 chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i ); \
64 done;
65
66tags:
67 ctags $(SRC)
68
69tests:
70
71lint:
72 lint -DLINT $(INCLUDES) $(SRC)>fluff
73
74depend:
75 $(MAKEDEPEND) -- $(CFLAG) $(INCLUDES) $(DEPFLAG) -- $(PROGS) $(LIBSRC)
76
77dclean:
78 $(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
79 mv -f Makefile.new $(MAKEFILE)
80
81clean:
82 rm -f *.o */*.o *.obj lib tags core .pure .nfs* *.old *.bak fluff
83
84# DO NOT DELETE THIS LINE -- make depend depends on it.
85
86ui_compat.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
87ui_compat.o: ../../include/openssl/opensslconf.h
88ui_compat.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
89ui_compat.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
90ui_compat.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
91ui_compat.o: ui_compat.c
92ui_err.o: ../../include/openssl/bio.h ../../include/openssl/crypto.h
93ui_err.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
94ui_err.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
95ui_err.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
96ui_err.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
97ui_err.o: ../../include/openssl/ui.h ui_err.c
98ui_lib.o: ../../e_os.h ../../include/openssl/bio.h
99ui_lib.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
100ui_lib.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
101ui_lib.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
102ui_lib.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
103ui_lib.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
104ui_lib.o: ../../include/openssl/ui.h ../cryptlib.h ui_lib.c ui_locl.h
105ui_openssl.o: ../../e_os.h ../../include/openssl/bio.h
106ui_openssl.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
107ui_openssl.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
108ui_openssl.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
109ui_openssl.o: ../../include/openssl/opensslv.h
110ui_openssl.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
111ui_openssl.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
112ui_openssl.o: ../cryptlib.h ui_locl.h ui_openssl.c
113ui_util.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
114ui_util.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
115ui_util.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
116ui_util.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
117ui_util.o: ui_util.c
diff --git a/src/lib/libcrypto/ui/ui.h b/src/lib/libcrypto/ui/ui.h
index 018296412b..2b1cfa2289 100644
--- a/src/lib/libcrypto/ui/ui.h
+++ b/src/lib/libcrypto/ui/ui.h
@@ -287,8 +287,8 @@ UI_METHOD *UI_OpenSSL(void);
287/* The UI_STRING type is the data structure that contains all the needed info 287/* The UI_STRING type is the data structure that contains all the needed info
288 about a string or a prompt, including test data for a verification prompt. 288 about a string or a prompt, including test data for a verification prompt.
289*/ 289*/
290DECLARE_STACK_OF(UI_STRING)
291typedef struct ui_string_st UI_STRING; 290typedef struct ui_string_st UI_STRING;
291DECLARE_STACK_OF(UI_STRING)
292 292
293/* The different types of strings that are currently supported. 293/* The different types of strings that are currently supported.
294 This is only needed by method authors. */ 294 This is only needed by method authors. */
@@ -310,11 +310,13 @@ int UI_method_set_writer(UI_METHOD *method, int (*writer)(UI *ui, UI_STRING *uis
310int UI_method_set_flusher(UI_METHOD *method, int (*flusher)(UI *ui)); 310int UI_method_set_flusher(UI_METHOD *method, int (*flusher)(UI *ui));
311int UI_method_set_reader(UI_METHOD *method, int (*reader)(UI *ui, UI_STRING *uis)); 311int UI_method_set_reader(UI_METHOD *method, int (*reader)(UI *ui, UI_STRING *uis));
312int UI_method_set_closer(UI_METHOD *method, int (*closer)(UI *ui)); 312int UI_method_set_closer(UI_METHOD *method, int (*closer)(UI *ui));
313int UI_method_set_prompt_constructor(UI_METHOD *method, char *(*prompt_constructor)(UI* ui, const char* object_desc, const char* object_name));
313int (*UI_method_get_opener(UI_METHOD *method))(UI*); 314int (*UI_method_get_opener(UI_METHOD *method))(UI*);
314int (*UI_method_get_writer(UI_METHOD *method))(UI*,UI_STRING*); 315int (*UI_method_get_writer(UI_METHOD *method))(UI*,UI_STRING*);
315int (*UI_method_get_flusher(UI_METHOD *method))(UI*); 316int (*UI_method_get_flusher(UI_METHOD *method))(UI*);
316int (*UI_method_get_reader(UI_METHOD *method))(UI*,UI_STRING*); 317int (*UI_method_get_reader(UI_METHOD *method))(UI*,UI_STRING*);
317int (*UI_method_get_closer(UI_METHOD *method))(UI*); 318int (*UI_method_get_closer(UI_METHOD *method))(UI*);
319char* (*UI_method_get_prompt_constructor(UI_METHOD *method))(UI*, const char*, const char*);
318 320
319/* The following functions are helpers for method writers to access relevant 321/* The following functions are helpers for method writers to access relevant
320 data from a UI_STRING. */ 322 data from a UI_STRING. */
diff --git a/src/lib/libcrypto/ui/ui_err.c b/src/lib/libcrypto/ui/ui_err.c
index 786bd0dbc3..a6b96299a0 100644
--- a/src/lib/libcrypto/ui/ui_err.c
+++ b/src/lib/libcrypto/ui/ui_err.c
@@ -1,6 +1,6 @@
1/* crypto/ui/ui_err.c */ 1/* crypto/ui/ui_err.c */
2/* ==================================================================== 2/* ====================================================================
3 * Copyright (c) 1999-2005 The OpenSSL Project. All rights reserved. 3 * Copyright (c) 1999-2006 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
diff --git a/src/lib/libcrypto/ui/ui_lib.c b/src/lib/libcrypto/ui/ui_lib.c
index ac0100808f..a8abc27064 100644
--- a/src/lib/libcrypto/ui/ui_lib.c
+++ b/src/lib/libcrypto/ui/ui_lib.c
@@ -693,6 +693,17 @@ int UI_method_set_closer(UI_METHOD *method, int (*closer)(UI *ui))
693 return -1; 693 return -1;
694 } 694 }
695 695
696int UI_method_set_prompt_constructor(UI_METHOD *method, char *(*prompt_constructor)(UI* ui, const char* object_desc, const char* object_name))
697 {
698 if (method)
699 {
700 method->ui_construct_prompt = prompt_constructor;
701 return 0;
702 }
703 else
704 return -1;
705 }
706
696int (*UI_method_get_opener(UI_METHOD *method))(UI*) 707int (*UI_method_get_opener(UI_METHOD *method))(UI*)
697 { 708 {
698 if (method) 709 if (method)
@@ -733,6 +744,14 @@ int (*UI_method_get_closer(UI_METHOD *method))(UI*)
733 return NULL; 744 return NULL;
734 } 745 }
735 746
747char* (*UI_method_get_prompt_constructor(UI_METHOD *method))(UI*, const char*, const char*)
748 {
749 if (method)
750 return method->ui_construct_prompt;
751 else
752 return NULL;
753 }
754
736enum UI_string_types UI_get_string_type(UI_STRING *uis) 755enum UI_string_types UI_get_string_type(UI_STRING *uis)
737 { 756 {
738 if (!uis) 757 if (!uis)
diff --git a/src/lib/libcrypto/ui/ui_openssl.c b/src/lib/libcrypto/ui/ui_openssl.c
index 5fbedf6ff8..1e3dba0833 100644
--- a/src/lib/libcrypto/ui/ui_openssl.c
+++ b/src/lib/libcrypto/ui/ui_openssl.c
@@ -122,7 +122,9 @@
122 * sigaction and fileno included. -pedantic would be more appropriate for 122 * sigaction and fileno included. -pedantic would be more appropriate for
123 * the intended purposes, but we can't prevent users from adding -ansi. 123 * the intended purposes, but we can't prevent users from adding -ansi.
124 */ 124 */
125#define _POSIX_C_SOURCE 1 125#ifndef _POSIX_C_SOURCE
126#define _POSIX_C_SOURCE 2
127#endif
126#include <signal.h> 128#include <signal.h>
127#include <stdio.h> 129#include <stdio.h>
128#include <string.h> 130#include <string.h>
@@ -297,7 +299,7 @@ static int is_a_tty;
297 299
298/* Declare static functions */ 300/* Declare static functions */
299#if !defined(OPENSSL_SYS_WIN16) && !defined(OPENSSL_SYS_WINCE) 301#if !defined(OPENSSL_SYS_WIN16) && !defined(OPENSSL_SYS_WINCE)
300static void read_till_nl(FILE *); 302static int read_till_nl(FILE *);
301static void recsig(int); 303static void recsig(int);
302static void pushsig(void); 304static void pushsig(void);
303static void popsig(void); 305static void popsig(void);
@@ -390,7 +392,7 @@ static int read_string(UI *ui, UI_STRING *uis)
390 392
391#if !defined(OPENSSL_SYS_WIN16) && !defined(OPENSSL_SYS_WINCE) 393#if !defined(OPENSSL_SYS_WIN16) && !defined(OPENSSL_SYS_WINCE)
392/* Internal functions to read a string without echoing */ 394/* Internal functions to read a string without echoing */
393static void read_till_nl(FILE *in) 395static int read_till_nl(FILE *in)
394 { 396 {
395#define SIZE 4 397#define SIZE 4
396 char buf[SIZE+1]; 398 char buf[SIZE+1];
@@ -399,6 +401,7 @@ static void read_till_nl(FILE *in)
399 if (fgets(buf,sizeof(buf),in) == NULL) 401 if (fgets(buf,sizeof(buf),in) == NULL)
400 break; 402 break;
401 } while (strchr(buf,'\n') == NULL); 403 } while (strchr(buf,'\n') == NULL);
404 return 1;
402 } 405 }
403 406
404static volatile sig_atomic_t intr_signal; 407static volatile sig_atomic_t intr_signal;
@@ -446,7 +449,8 @@ static int read_string_inner(UI *ui, UI_STRING *uis, int echo, int strip_nl)
446 *p='\0'; 449 *p='\0';
447 } 450 }
448 else 451 else
449 read_till_nl(tty_in); 452 if (!read_till_nl(tty_in))
453 goto error;
450 if (UI_set_result(ui, uis, result) >= 0) 454 if (UI_set_result(ui, uis, result) >= 0)
451 ok=1; 455 ok=1;
452 456
@@ -474,7 +478,7 @@ static int open_console(UI *ui)
474 CRYPTO_w_lock(CRYPTO_LOCK_UI); 478 CRYPTO_w_lock(CRYPTO_LOCK_UI);
475 is_a_tty = 1; 479 is_a_tty = 1;
476 480
477#if defined(OPENSSL_SYS_MACINTOSH_CLASSIC) || defined(OPENSSL_SYS_VXWORKS) || defined(OPENSSL_SYS_NETWARE) 481#if defined(OPENSSL_SYS_MACINTOSH_CLASSIC) || defined(OPENSSL_SYS_VXWORKS) || defined(OPENSSL_SYS_NETWARE) || defined(OPENSSL_SYS_BEOS)
478 tty_in=stdin; 482 tty_in=stdin;
479 tty_out=stderr; 483 tty_out=stderr;
480#else 484#else
diff --git a/src/lib/libcrypto/util/arx.pl b/src/lib/libcrypto/util/arx.pl
deleted file mode 100644
index ce62625c33..0000000000
--- a/src/lib/libcrypto/util/arx.pl
+++ /dev/null
@@ -1,15 +0,0 @@
1#!/bin/perl
2
3# Simple perl script to wrap round "ar" program and exclude any
4# object files in the environment variable EXCL_OBJ
5
6map { s/^.*\/([^\/]*)$/$1/ ; $EXCL{$_} = 1} split(' ', $ENV{EXCL_OBJ});
7
8#my @ks = keys %EXCL;
9#print STDERR "Excluding: @ks \n";
10
11my @ARGS = grep { !exists $EXCL{$_} } @ARGV;
12
13system @ARGS;
14
15exit $? >> 8;
diff --git a/src/lib/libcrypto/util/checkhash.pl b/src/lib/libcrypto/util/checkhash.pl
deleted file mode 100644
index c61fa72178..0000000000
--- a/src/lib/libcrypto/util/checkhash.pl
+++ /dev/null
@@ -1,222 +0,0 @@
1#!/usr/bin/env perl -w
2
3my $package = caller;
4
5if (!(defined $package))
6 {
7 my $retval = check_hashes(@ARGV);
8 exit $retval;
9 }
10
111;
12
13sub check_hashes
14 {
15
16 my @args = @_;
17
18 my $change_dir = "";
19 my $check_program = "sha/fips_standalone_sha1";
20
21 my $verbose = 0;
22 my $badfiles = 0;
23 my $rebuild = 0;
24 my $force_rewrite = 0;
25 my $hash_file = "fipshashes.c";
26 my $recurse = 0;
27
28 my @fingerprint_files;
29
30 while (@args)
31 {
32 my $arg = $args[0];
33 if ($arg eq "-chdir")
34 {
35 shift @args;
36 $change_dir = shift @args;
37 }
38 elsif ($arg eq "-rebuild")
39 {
40 shift @args;
41 $rebuild = 1;
42 }
43 elsif ($arg eq "-verbose")
44 {
45 shift @args;
46 $verbose = 1;
47 }
48 elsif ($arg eq "-force-rewrite")
49 {
50 shift @args;
51 $force_rewrite = 1;
52 }
53 elsif ($arg eq "-hash_file")
54 {
55 shift @args;
56 $hash_file = shift @args;
57 }
58 elsif ($arg eq "-recurse")
59 {
60 shift @args;
61 $recurse = 1;
62 }
63 elsif ($arg eq "-program_path")
64 {
65 shift @args;
66 $check_program = shift @args;
67 }
68 else
69 {
70 print STDERR "Unknown Option $arg";
71 return 1;
72 }
73
74 }
75
76 chdir $change_dir if $change_dir ne "";
77
78 if ($recurse)
79 {
80 @fingerprint_files = ("fingerprint.sha1",
81 <*/fingerprint.sha1>);
82 }
83 else
84 {
85 push @fingerprint_files, $hash_file;
86 }
87
88 foreach $fp (@fingerprint_files)
89 {
90 if (!open(IN, "$fp"))
91 {
92 print STDERR "Can't open file $fp";
93 return 1;
94 }
95 print STDERR "Opening Fingerprint file $fp\n" if $verbose;
96 my $dir = $fp;
97 $dir =~ s/[^\/]*$//;
98 while (<IN>)
99 {
100 chomp;
101 if (!(($file, $hash) = /^\"HMAC-SHA1\((.*)\)\s*=\s*(\w*)\",$/))
102 {
103 /^\"/ || next;
104 print STDERR "FATAL: Invalid syntax in file $fp\n";
105 print STDERR "Line:\n$_\n";
106 fatal_error();
107 return 1;
108 }
109 if (!$rebuild && length($hash) != 40)
110 {
111 print STDERR "FATAL: Invalid hash length in $fp for file $file\n";
112 fatal_error();
113 return 1;
114 }
115 push @hashed_files, "$dir$file";
116 if (exists $hashes{"$dir$file"})
117 {
118 print STDERR "FATAL: Duplicate Hash file $dir$file\n";
119 fatal_error();
120 return 1;
121 }
122 if (! -r "$dir$file")
123 {
124 print STDERR "FATAL: Can't access $dir$file\n";
125 fatal_error();
126 return 1;
127 }
128 $hashes{"$dir$file"} = $hash;
129 }
130 close IN;
131 }
132
133 @checked_hashes = `$check_program @hashed_files`;
134
135 if ($? != 0)
136 {
137 print STDERR "Error running hash program $check_program\n";
138 fatal_error();
139 return 1;
140 }
141
142 if (@checked_hashes != @hashed_files)
143 {
144 print STDERR "FATAL: hash count incorrect\n";
145 fatal_error();
146 return 1;
147 }
148
149 foreach (@checked_hashes)
150 {
151 chomp;
152 if (!(($file, $hash) = /^HMAC-SHA1\((.*)\)\s*=\s*(\w*)$/))
153 {
154 print STDERR "FATAL: Invalid syntax in file $fp\n";
155 print STDERR "Line:\n$_\n";
156 fatal_error();
157 return 1;
158 }
159 if (length($hash) != 40)
160 {
161 print STDERR "FATAL: Invalid hash length for file $file\n";
162 fatal_error();
163 return 1;
164 }
165 if ($hash ne $hashes{$file})
166 {
167 if ($rebuild)
168 {
169 print STDERR "Updating hash on file $file\n";
170 $hashes{$file} = $hash;
171 }
172 else
173 {
174 print STDERR "Hash check failed for file $file\n";
175 }
176 $badfiles++;
177 }
178 elsif ($verbose)
179 { print "Hash Check OK for $file\n";}
180 }
181
182
183 if ($badfiles && !$rebuild)
184 {
185 print STDERR "FATAL: hash mismatch on $badfiles files\n";
186 fatal_error();
187 return 1;
188 }
189
190 if ($badfiles || $force_rewrite)
191 {
192 print "Updating Hash file $hash_file\n";
193 if (!open(OUT, ">$hash_file"))
194 {
195 print STDERR "Error rewriting $hash_file";
196 return 1;
197 }
198 print OUT "const char * const FIPS_source_hashes[] = {\n";
199 foreach (@hashed_files)
200 {
201 print OUT "\"HMAC-SHA1($_)= $hashes{$_}\",\n";
202 }
203 print OUT "};\n";
204 close OUT;
205 }
206
207 if (!$badfiles)
208 {
209 print "FIPS hash check successful\n";
210 }
211
212 return 0;
213
214 }
215
216
217sub fatal_error
218 {
219 print STDERR "*** Your source code does not match the FIPS validated source ***\n";
220 }
221
222
diff --git a/src/lib/libcrypto/util/ck_errf.pl b/src/lib/libcrypto/util/ck_errf.pl
index 344b422c34..f13af5c50b 100644
--- a/src/lib/libcrypto/util/ck_errf.pl
+++ b/src/lib/libcrypto/util/ck_errf.pl
@@ -7,8 +7,16 @@
7# perl util/ck_errf.pl */*.c */*/*.c 7# perl util/ck_errf.pl */*.c */*/*.c
8# 8#
9 9
10my $err_strict = 0;
11my $bad = 0;
12
10foreach $file (@ARGV) 13foreach $file (@ARGV)
11 { 14 {
15 if ($file eq "-strict")
16 {
17 $err_strict = 1;
18 next;
19 }
12 open(IN,"<$file") || die "unable to open $file\n"; 20 open(IN,"<$file") || die "unable to open $file\n";
13 $func=""; 21 $func="";
14 while (<IN>) 22 while (<IN>)
@@ -20,13 +28,13 @@ foreach $file (@ARGV)
20 $func = $1; 28 $func = $1;
21 $func =~ tr/A-Z/a-z/; 29 $func =~ tr/A-Z/a-z/;
22 } 30 }
23 if (/([A-Z0-9]+)err\(([^,]+)/) 31 if (/([A-Z0-9]+)err\(([^,]+)/ && ! /ckerr_ignore/)
24 { 32 {
25 $errlib=$1; 33 $errlib=$1;
26 $n=$2; 34 $n=$2;
27 35
28 if ($func eq "") 36 if ($func eq "")
29 { print "$file:$.:???:$n\n"; next; } 37 { print "$file:$.:???:$n\n"; $bad = 1; next; }
30 38
31 if ($n !~ /([^_]+)_F_(.+)$/) 39 if ($n !~ /([^_]+)_F_(.+)$/)
32 { 40 {
@@ -37,14 +45,20 @@ foreach $file (@ARGV)
37 $n=$2; 45 $n=$2;
38 46
39 if ($lib ne $errlib) 47 if ($lib ne $errlib)
40 { print "$file:$.:$func:$n [${errlib}err]\n"; next; } 48 { print "$file:$.:$func:$n [${errlib}err]\n"; $bad = 1; next; }
41 49
42 $n =~ tr/A-Z/a-z/; 50 $n =~ tr/A-Z/a-z/;
43 if (($n ne $func) && ($errlib ne "SYS")) 51 if (($n ne $func) && ($errlib ne "SYS"))
44 { print "$file:$.:$func:$n\n"; next; } 52 { print "$file:$.:$func:$n\n"; $bad = 1; next; }
45 # print "$func:$1\n"; 53 # print "$func:$1\n";
46 } 54 }
47 } 55 }
48 close(IN); 56 close(IN);
49 } 57 }
50 58
59if ($bad && $err_strict)
60 {
61 print STDERR "FATAL: error discrepancy\n";
62 exit 1;
63 }
64
diff --git a/src/lib/libcrypto/util/clean-depend.pl b/src/lib/libcrypto/util/clean-depend.pl
index 2b2bdb4048..d3525b0ed0 100644
--- a/src/lib/libcrypto/util/clean-depend.pl
+++ b/src/lib/libcrypto/util/clean-depend.pl
@@ -42,6 +42,7 @@ foreach $file (sort keys %files) {
42 my @deps = map { $_ =~ s/^\.\///; $_ } @{$files{$file}}; 42 my @deps = map { $_ =~ s/^\.\///; $_ } @{$files{$file}};
43 43
44 foreach $dep (sort @deps) { 44 foreach $dep (sort @deps) {
45 $dep=~s/^\.\///;
45 next if $prevdep eq $dep; # to exterminate duplicates... 46 next if $prevdep eq $dep; # to exterminate duplicates...
46 $prevdep = $dep; 47 $prevdep = $dep;
47 $len=0 if $len+length($dep)+1 >= 80; 48 $len=0 if $len+length($dep)+1 >= 80;
diff --git a/src/lib/libcrypto/util/copy.pl b/src/lib/libcrypto/util/copy.pl
index e20b45530a..eba6d5815e 100644
--- a/src/lib/libcrypto/util/copy.pl
+++ b/src/lib/libcrypto/util/copy.pl
@@ -8,9 +8,16 @@ use Fcntl;
8# Perl script 'copy' comment. On Windows the built in "copy" command also 8# Perl script 'copy' comment. On Windows the built in "copy" command also
9# copies timestamps: this messes up Makefile dependencies. 9# copies timestamps: this messes up Makefile dependencies.
10 10
11my $stripcr = 0;
12
11my $arg; 13my $arg;
12 14
13foreach $arg (@ARGV) { 15foreach $arg (@ARGV) {
16 if ($arg eq "-stripcr")
17 {
18 $stripcr = 1;
19 next;
20 }
14 $arg =~ s|\\|/|g; # compensate for bug/feature in cygwin glob... 21 $arg =~ s|\\|/|g; # compensate for bug/feature in cygwin glob...
15 foreach (glob $arg) 22 foreach (glob $arg)
16 { 23 {
@@ -49,6 +56,10 @@ foreach (@filelist)
49 || die "Can't Open $dfile"; 56 || die "Can't Open $dfile";
50 while (sysread IN, $buf, 10240) 57 while (sysread IN, $buf, 10240)
51 { 58 {
59 if ($stripcr)
60 {
61 $buf =~ tr/\015//d;
62 }
52 syswrite(OUT, $buf, length($buf)); 63 syswrite(OUT, $buf, length($buf));
53 } 64 }
54 close(IN); 65 close(IN);
diff --git a/src/lib/libcrypto/util/cygwin.sh b/src/lib/libcrypto/util/cygwin.sh
index 89d1dda95b..a4f2e740b4 100644
--- a/src/lib/libcrypto/util/cygwin.sh
+++ b/src/lib/libcrypto/util/cygwin.sh
@@ -7,7 +7,7 @@
7# Uncomment when debugging 7# Uncomment when debugging
8#set -x 8#set -x
9 9
10CONFIG_OPTIONS="--prefix=/usr shared no-idea no-rc5 no-mdc2" 10CONFIG_OPTIONS="--prefix=/usr shared zlib no-idea no-rc5"
11INSTALL_PREFIX=/tmp/install 11INSTALL_PREFIX=/tmp/install
12 12
13VERSION= 13VERSION=
@@ -66,7 +66,7 @@ function create_cygwin_readme()
66 66
67 ./config ${CONFIG_OPTIONS} 67 ./config ${CONFIG_OPTIONS}
68 68
69 The IDEA, RC5 and MDC2 algorithms are disabled due to patent and/or 69 The IDEA and RC5 algorithms are disabled due to patent and/or
70 licensing issues. 70 licensing issues.
71 EOF 71 EOF
72} 72}
diff --git a/src/lib/libcrypto/util/domd b/src/lib/libcrypto/util/domd
index 560ebeaf82..bab48cb7a2 100644
--- a/src/lib/libcrypto/util/domd
+++ b/src/lib/libcrypto/util/domd
@@ -14,7 +14,7 @@ if [ "$MAKEDEPEND" = "" ]; then MAKEDEPEND=makedepend; fi
14cp Makefile Makefile.save 14cp Makefile 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 expr "$MAKEDEPEND" : '.*gcc$' > /dev/null; then
18 args="" 18 args=""
19 while [ $# -gt 0 ]; do 19 while [ $# -gt 0 ]; do
20 if [ "$1" != "--" ]; then args="$args $1"; fi 20 if [ "$1" != "--" ]; then args="$args $1"; fi
@@ -22,13 +22,17 @@ if [ "$MAKEDEPEND" = "gcc" ]; then
22 done 22 done
23 sed -e '/^# DO NOT DELETE.*/,$d' < Makefile > Makefile.tmp 23 sed -e '/^# DO NOT DELETE.*/,$d' < Makefile > Makefile.tmp
24 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
25 ${CC:-gcc} -D OPENSSL_DOING_MAKEDEPEND -M $args >> Makefile.tmp 25 ${MAKEDEPEND} -Werror -D OPENSSL_DOING_MAKEDEPEND -M $args >> Makefile.tmp || exit 1
26 ${PERL} $TOP/util/clean-depend.pl < Makefile.tmp > Makefile.new 26 ${PERL} $TOP/util/clean-depend.pl < Makefile.tmp > Makefile.new
27 RC=$?
27 rm -f Makefile.tmp 28 rm -f Makefile.tmp
28else 29else
29 ${MAKEDEPEND} -D OPENSSL_DOING_MAKEDEPEND $@ 30 ${MAKEDEPEND} -D OPENSSL_DOING_MAKEDEPEND $@ && \
30 ${PERL} $TOP/util/clean-depend.pl < Makefile > Makefile.new 31 ${PERL} $TOP/util/clean-depend.pl < Makefile > Makefile.new
32 RC=$?
31fi 33fi
32mv Makefile.new Makefile 34mv Makefile.new Makefile
33# unfake the presence of Kerberos 35# unfake the presence of Kerberos
34rm $TOP/krb5.h 36rm $TOP/krb5.h
37
38exit $RC
diff --git a/src/lib/libcrypto/util/fipslink.pl b/src/lib/libcrypto/util/fipslink.pl
deleted file mode 100644
index 3597bc1740..0000000000
--- a/src/lib/libcrypto/util/fipslink.pl
+++ /dev/null
@@ -1,78 +0,0 @@
1#!/usr/bin/perl
2
3sub check_env
4 {
5 my @ret;
6 foreach (@_)
7 {
8 die "Environment variable $_ not defined!\n" unless exists $ENV{$_};
9 push @ret, $ENV{$_};
10 }
11 return @ret;
12 }
13
14
15my ($fips_cc,$fips_cc_args, $fips_link,$fips_target, $fips_libdir, $sha1_exe)
16 = check_env("FIPS_CC", "FIPS_CC_ARGS", "FIPS_LINK", "FIPS_TARGET",
17 "FIPSLIB_D", "FIPS_SHA1_EXE");
18
19
20
21if (exists $ENV{"PREMAIN_DSO_EXE"})
22 {
23 $fips_premain_dso = $ENV{"PREMAIN_DSO_EXE"};
24 }
25 else
26 {
27 $fips_premain_dso = "";
28 }
29
30check_hash($sha1_exe, "fips_premain.c");
31check_hash($sha1_exe, "fipscanister.lib");
32
33
34print "Integrity check OK\n";
35
36print "$fips_cc $fips_cc_args $fips_libdir/fips_premain.c\n";
37system "$fips_cc $fips_cc_args $fips_libdir/fips_premain.c";
38die "First stage Compile failure" if $? != 0;
39
40print "$fips_link @ARGV\n";
41system "$fips_link @ARGV";
42die "First stage Link failure" if $? != 0;
43
44
45print "$fips_premain_dso $fips_target\n";
46$fips_hash=`$fips_premain_dso $fips_target`;
47chomp $fips_hash;
48die "Get hash failure" if $? != 0;
49
50
51print "$fips_cc -DHMAC_SHA1_SIG=\\\"$fips_hash\\\" $fips_cc_args $fips_libdir/fips_premain.c\n";
52system "$fips_cc -DHMAC_SHA1_SIG=\\\"$fips_hash\\\" $fips_cc_args $fips_libdir/fips_premain.c";
53die "Second stage Compile failure" if $? != 0;
54
55
56print "$fips_link @ARGV\n";
57system "$fips_link @ARGV";
58die "Second stage Link failure" if $? != 0;
59
60sub check_hash
61 {
62 my ($sha1_exe, $filename) = @_;
63 my ($hashfile, $hashval);
64
65 open(IN, "${fips_libdir}/${filename}.sha1") || die "Cannot open file hash file ${fips_libdir}/${filename}.sha1";
66 $hashfile = <IN>;
67 close IN;
68 $hashval = `$sha1_exe ${fips_libdir}/$filename`;
69 chomp $hashfile;
70 chomp $hashval;
71 $hashfile =~ s/^.*=\s+//;
72 $hashval =~ s/^.*=\s+//;
73 die "Invalid hash syntax in file" if (length($hashfile) != 40);
74 die "Invalid hash received for file" if (length($hashval) != 40);
75 die "***HASH VALUE MISMATCH FOR FILE $filename ***" if ($hashval ne $hashfile);
76 }
77
78
diff --git a/src/lib/libcrypto/util/libeay.num b/src/lib/libcrypto/util/libeay.num
index 0bad595233..c68047e955 100644
--- a/src/lib/libcrypto/util/libeay.num
+++ b/src/lib/libcrypto/util/libeay.num
@@ -1,9 +1,9 @@
1SSLeay 1 EXIST::FUNCTION: 1SSLeay 1 EXIST::FUNCTION:
2SSLeay_version 2 EXIST::FUNCTION: 2SSLeay_version 2 EXIST::FUNCTION:
3ASN1_BIT_STRING_asn1_meth 3 EXIST::FUNCTION: 3ASN1_BIT_STRING_asn1_meth 3 NOEXIST::FUNCTION:
4ASN1_HEADER_free 4 EXIST::FUNCTION: 4ASN1_HEADER_free 4 NOEXIST::FUNCTION:
5ASN1_HEADER_new 5 EXIST::FUNCTION: 5ASN1_HEADER_new 5 NOEXIST::FUNCTION:
6ASN1_IA5STRING_asn1_meth 6 EXIST::FUNCTION: 6ASN1_IA5STRING_asn1_meth 6 NOEXIST::FUNCTION:
7ASN1_INTEGER_get 7 EXIST::FUNCTION: 7ASN1_INTEGER_get 7 EXIST::FUNCTION:
8ASN1_INTEGER_set 8 EXIST::FUNCTION: 8ASN1_INTEGER_set 8 EXIST::FUNCTION:
9ASN1_INTEGER_to_BN 9 EXIST::FUNCTION: 9ASN1_INTEGER_to_BN 9 EXIST::FUNCTION:
@@ -75,8 +75,8 @@ BIO_new 78 EXIST::FUNCTION:
75BIO_new_accept 79 EXIST::FUNCTION: 75BIO_new_accept 79 EXIST::FUNCTION:
76BIO_new_connect 80 EXIST::FUNCTION: 76BIO_new_connect 80 EXIST::FUNCTION:
77BIO_new_fd 81 EXIST::FUNCTION: 77BIO_new_fd 81 EXIST::FUNCTION:
78BIO_new_file 82 EXIST:!WIN16:FUNCTION:FP_API 78BIO_new_file 82 EXIST::FUNCTION:FP_API
79BIO_new_fp 83 EXIST:!WIN16:FUNCTION:FP_API 79BIO_new_fp 83 EXIST::FUNCTION:FP_API
80BIO_new_socket 84 EXIST::FUNCTION: 80BIO_new_socket 84 EXIST::FUNCTION:
81BIO_pop 85 EXIST::FUNCTION: 81BIO_pop 85 EXIST::FUNCTION:
82BIO_printf 86 EXIST::FUNCTION: 82BIO_printf 86 EXIST::FUNCTION:
@@ -86,7 +86,7 @@ BIO_read 89 EXIST::FUNCTION:
86BIO_s_accept 90 EXIST::FUNCTION: 86BIO_s_accept 90 EXIST::FUNCTION:
87BIO_s_connect 91 EXIST::FUNCTION: 87BIO_s_connect 91 EXIST::FUNCTION:
88BIO_s_fd 92 EXIST::FUNCTION: 88BIO_s_fd 92 EXIST::FUNCTION:
89BIO_s_file 93 EXIST:!WIN16:FUNCTION:FP_API 89BIO_s_file 93 EXIST::FUNCTION:FP_API
90BIO_s_mem 95 EXIST::FUNCTION: 90BIO_s_mem 95 EXIST::FUNCTION:
91BIO_s_null 96 EXIST::FUNCTION: 91BIO_s_null 96 EXIST::FUNCTION:
92BIO_s_proxy_client 97 NOEXIST::FUNCTION: 92BIO_s_proxy_client 97 NOEXIST::FUNCTION:
@@ -172,7 +172,7 @@ CRYPTO_dbg_realloc 179 EXIST::FUNCTION:
172CRYPTO_dbg_remalloc 180 NOEXIST::FUNCTION: 172CRYPTO_dbg_remalloc 180 NOEXIST::FUNCTION:
173CRYPTO_free 181 EXIST::FUNCTION: 173CRYPTO_free 181 EXIST::FUNCTION:
174CRYPTO_get_add_lock_callback 182 EXIST::FUNCTION: 174CRYPTO_get_add_lock_callback 182 EXIST::FUNCTION:
175CRYPTO_get_id_callback 183 EXIST::FUNCTION: 175CRYPTO_get_id_callback 183 EXIST::FUNCTION:DEPRECATED
176CRYPTO_get_lock_name 184 EXIST::FUNCTION: 176CRYPTO_get_lock_name 184 EXIST::FUNCTION:
177CRYPTO_get_locking_callback 185 EXIST::FUNCTION: 177CRYPTO_get_locking_callback 185 EXIST::FUNCTION:
178CRYPTO_get_mem_functions 186 EXIST::FUNCTION: 178CRYPTO_get_mem_functions 186 EXIST::FUNCTION:
@@ -185,10 +185,10 @@ CRYPTO_mem_leaks_fp 192 EXIST::FUNCTION:FP_API
185CRYPTO_realloc 193 EXIST::FUNCTION: 185CRYPTO_realloc 193 EXIST::FUNCTION:
186CRYPTO_remalloc 194 EXIST::FUNCTION: 186CRYPTO_remalloc 194 EXIST::FUNCTION:
187CRYPTO_set_add_lock_callback 195 EXIST::FUNCTION: 187CRYPTO_set_add_lock_callback 195 EXIST::FUNCTION:
188CRYPTO_set_id_callback 196 EXIST::FUNCTION: 188CRYPTO_set_id_callback 196 EXIST::FUNCTION:DEPRECATED
189CRYPTO_set_locking_callback 197 EXIST::FUNCTION: 189CRYPTO_set_locking_callback 197 EXIST::FUNCTION:
190CRYPTO_set_mem_functions 198 EXIST::FUNCTION: 190CRYPTO_set_mem_functions 198 EXIST::FUNCTION:
191CRYPTO_thread_id 199 EXIST::FUNCTION: 191CRYPTO_thread_id 199 EXIST::FUNCTION:DEPRECATED
192DH_check 200 EXIST::FUNCTION:DH 192DH_check 200 EXIST::FUNCTION:DH
193DH_compute_key 201 EXIST::FUNCTION:DH 193DH_compute_key 201 EXIST::FUNCTION:DH
194DH_free 202 EXIST::FUNCTION:DH 194DH_free 202 EXIST::FUNCTION:DH
@@ -243,7 +243,7 @@ ERR_print_errors 250 EXIST::FUNCTION:BIO
243ERR_print_errors_fp 251 EXIST::FUNCTION:FP_API 243ERR_print_errors_fp 251 EXIST::FUNCTION:FP_API
244ERR_put_error 252 EXIST::FUNCTION: 244ERR_put_error 252 EXIST::FUNCTION:
245ERR_reason_error_string 253 EXIST::FUNCTION: 245ERR_reason_error_string 253 EXIST::FUNCTION:
246ERR_remove_state 254 EXIST::FUNCTION: 246ERR_remove_state 254 EXIST::FUNCTION:DEPRECATED
247EVP_BytesToKey 255 EXIST::FUNCTION: 247EVP_BytesToKey 255 EXIST::FUNCTION:
248EVP_CIPHER_CTX_cleanup 256 EXIST::FUNCTION: 248EVP_CIPHER_CTX_cleanup 256 EXIST::FUNCTION:
249EVP_CipherFinal 257 EXIST::FUNCTION: 249EVP_CipherFinal 257 EXIST::FUNCTION:
@@ -343,7 +343,7 @@ NETSCAPE_SPKI_new 350 EXIST::FUNCTION:
343NETSCAPE_SPKI_sign 351 EXIST::FUNCTION:EVP 343NETSCAPE_SPKI_sign 351 EXIST::FUNCTION:EVP
344NETSCAPE_SPKI_verify 352 EXIST::FUNCTION:EVP 344NETSCAPE_SPKI_verify 352 EXIST::FUNCTION:EVP
345OBJ_add_object 353 EXIST::FUNCTION: 345OBJ_add_object 353 EXIST::FUNCTION:
346OBJ_bsearch 354 EXIST::FUNCTION: 346OBJ_bsearch 354 NOEXIST::FUNCTION:
347OBJ_cleanup 355 EXIST::FUNCTION: 347OBJ_cleanup 355 EXIST::FUNCTION:
348OBJ_cmp 356 EXIST::FUNCTION: 348OBJ_cmp 356 EXIST::FUNCTION:
349OBJ_create 357 EXIST::FUNCTION: 349OBJ_create 357 EXIST::FUNCTION:
@@ -356,9 +356,9 @@ OBJ_nid2sn 363 EXIST::FUNCTION:
356OBJ_obj2nid 364 EXIST::FUNCTION: 356OBJ_obj2nid 364 EXIST::FUNCTION:
357OBJ_sn2nid 365 EXIST::FUNCTION: 357OBJ_sn2nid 365 EXIST::FUNCTION:
358OBJ_txt2nid 366 EXIST::FUNCTION: 358OBJ_txt2nid 366 EXIST::FUNCTION:
359PEM_ASN1_read 367 EXIST:!WIN16:FUNCTION: 359PEM_ASN1_read 367 EXIST::FUNCTION:
360PEM_ASN1_read_bio 368 EXIST::FUNCTION:BIO 360PEM_ASN1_read_bio 368 EXIST::FUNCTION:BIO
361PEM_ASN1_write 369 EXIST:!WIN16:FUNCTION: 361PEM_ASN1_write 369 EXIST::FUNCTION:
362PEM_ASN1_write_bio 370 EXIST::FUNCTION:BIO 362PEM_ASN1_write_bio 370 EXIST::FUNCTION:BIO
363PEM_SealFinal 371 EXIST::FUNCTION:RSA 363PEM_SealFinal 371 EXIST::FUNCTION:RSA
364PEM_SealInit 372 EXIST::FUNCTION:RSA 364PEM_SealInit 372 EXIST::FUNCTION:RSA
@@ -366,14 +366,14 @@ PEM_SealUpdate 373 EXIST::FUNCTION:RSA
366PEM_SignFinal 374 EXIST::FUNCTION: 366PEM_SignFinal 374 EXIST::FUNCTION:
367PEM_SignInit 375 EXIST::FUNCTION: 367PEM_SignInit 375 EXIST::FUNCTION:
368PEM_SignUpdate 376 EXIST::FUNCTION: 368PEM_SignUpdate 376 EXIST::FUNCTION:
369PEM_X509_INFO_read 377 EXIST:!WIN16:FUNCTION: 369PEM_X509_INFO_read 377 EXIST::FUNCTION:
370PEM_X509_INFO_read_bio 378 EXIST::FUNCTION:BIO 370PEM_X509_INFO_read_bio 378 EXIST::FUNCTION:BIO
371PEM_X509_INFO_write_bio 379 EXIST::FUNCTION:BIO 371PEM_X509_INFO_write_bio 379 EXIST::FUNCTION:BIO
372PEM_dek_info 380 EXIST::FUNCTION: 372PEM_dek_info 380 EXIST::FUNCTION:
373PEM_do_header 381 EXIST::FUNCTION: 373PEM_do_header 381 EXIST::FUNCTION:
374PEM_get_EVP_CIPHER_INFO 382 EXIST::FUNCTION: 374PEM_get_EVP_CIPHER_INFO 382 EXIST::FUNCTION:
375PEM_proc_type 383 EXIST::FUNCTION: 375PEM_proc_type 383 EXIST::FUNCTION:
376PEM_read 384 EXIST:!WIN16:FUNCTION: 376PEM_read 384 EXIST::FUNCTION:
377PEM_read_DHparams 385 EXIST:!WIN16:FUNCTION:DH 377PEM_read_DHparams 385 EXIST:!WIN16:FUNCTION:DH
378PEM_read_DSAPrivateKey 386 EXIST:!WIN16:FUNCTION:DSA 378PEM_read_DSAPrivateKey 386 EXIST:!WIN16:FUNCTION:DSA
379PEM_read_DSAparams 387 EXIST:!WIN16:FUNCTION:DSA 379PEM_read_DSAparams 387 EXIST:!WIN16:FUNCTION:DSA
@@ -393,7 +393,7 @@ PEM_read_bio_RSAPrivateKey 400 EXIST::FUNCTION:RSA
393PEM_read_bio_X509 401 EXIST::FUNCTION: 393PEM_read_bio_X509 401 EXIST::FUNCTION:
394PEM_read_bio_X509_CRL 402 EXIST::FUNCTION: 394PEM_read_bio_X509_CRL 402 EXIST::FUNCTION:
395PEM_read_bio_X509_REQ 403 EXIST::FUNCTION: 395PEM_read_bio_X509_REQ 403 EXIST::FUNCTION:
396PEM_write 404 EXIST:!WIN16:FUNCTION: 396PEM_write 404 EXIST::FUNCTION:
397PEM_write_DHparams 405 EXIST:!WIN16:FUNCTION:DH 397PEM_write_DHparams 405 EXIST:!WIN16:FUNCTION:DH
398PEM_write_DSAPrivateKey 406 EXIST:!WIN16:FUNCTION:DSA 398PEM_write_DSAPrivateKey 406 EXIST:!WIN16:FUNCTION:DSA
399PEM_write_DSAparams 407 EXIST:!WIN16:FUNCTION:DSA 399PEM_write_DSAparams 407 EXIST:!WIN16:FUNCTION:DSA
@@ -469,7 +469,7 @@ RC2_set_key 476 EXIST::FUNCTION:RC2
469RC4 477 EXIST::FUNCTION:RC4 469RC4 477 EXIST::FUNCTION:RC4
470RC4_options 478 EXIST::FUNCTION:RC4 470RC4_options 478 EXIST::FUNCTION:RC4
471RC4_set_key 479 EXIST::FUNCTION:RC4 471RC4_set_key 479 EXIST::FUNCTION:RC4
472RSAPrivateKey_asn1_meth 480 EXIST::FUNCTION:RSA 472RSAPrivateKey_asn1_meth 480 NOEXIST::FUNCTION:
473RSAPrivateKey_dup 481 EXIST::FUNCTION:RSA 473RSAPrivateKey_dup 481 EXIST::FUNCTION:RSA
474RSAPublicKey_dup 482 EXIST::FUNCTION:RSA 474RSAPublicKey_dup 482 EXIST::FUNCTION:RSA
475RSA_PKCS1_SSLeay 483 EXIST::FUNCTION:RSA 475RSA_PKCS1_SSLeay 483 EXIST::FUNCTION:RSA
@@ -624,7 +624,7 @@ X509_STORE_set_default_paths 630 EXIST::FUNCTION:STDIO
624X509_VAL_free 631 EXIST::FUNCTION: 624X509_VAL_free 631 EXIST::FUNCTION:
625X509_VAL_new 632 EXIST::FUNCTION: 625X509_VAL_new 632 EXIST::FUNCTION:
626X509_add_ext 633 EXIST::FUNCTION: 626X509_add_ext 633 EXIST::FUNCTION:
627X509_asn1_meth 634 EXIST::FUNCTION: 627X509_asn1_meth 634 NOEXIST::FUNCTION:
628X509_certificate_type 635 EXIST::FUNCTION: 628X509_certificate_type 635 EXIST::FUNCTION:
629X509_check_private_key 636 EXIST::FUNCTION: 629X509_check_private_key 636 EXIST::FUNCTION:
630X509_cmp_current_time 637 EXIST::FUNCTION: 630X509_cmp_current_time 637 EXIST::FUNCTION:
@@ -704,7 +704,7 @@ bn_sqr_words 710 EXIST::FUNCTION:
704_ossl_old_crypt 711 EXIST:!NeXT,!PERL5:FUNCTION:DES 704_ossl_old_crypt 711 EXIST:!NeXT,!PERL5:FUNCTION:DES
705d2i_ASN1_BIT_STRING 712 EXIST::FUNCTION: 705d2i_ASN1_BIT_STRING 712 EXIST::FUNCTION:
706d2i_ASN1_BOOLEAN 713 EXIST::FUNCTION: 706d2i_ASN1_BOOLEAN 713 EXIST::FUNCTION:
707d2i_ASN1_HEADER 714 EXIST::FUNCTION: 707d2i_ASN1_HEADER 714 NOEXIST::FUNCTION:
708d2i_ASN1_IA5STRING 715 EXIST::FUNCTION: 708d2i_ASN1_IA5STRING 715 EXIST::FUNCTION:
709d2i_ASN1_INTEGER 716 EXIST::FUNCTION: 709d2i_ASN1_INTEGER 716 EXIST::FUNCTION:
710d2i_ASN1_OBJECT 717 EXIST::FUNCTION: 710d2i_ASN1_OBJECT 717 EXIST::FUNCTION:
@@ -809,7 +809,7 @@ i2a_ASN1_OBJECT 816 EXIST::FUNCTION:BIO
809i2a_ASN1_STRING 817 EXIST::FUNCTION:BIO 809i2a_ASN1_STRING 817 EXIST::FUNCTION:BIO
810i2d_ASN1_BIT_STRING 818 EXIST::FUNCTION: 810i2d_ASN1_BIT_STRING 818 EXIST::FUNCTION:
811i2d_ASN1_BOOLEAN 819 EXIST::FUNCTION: 811i2d_ASN1_BOOLEAN 819 EXIST::FUNCTION:
812i2d_ASN1_HEADER 820 EXIST::FUNCTION: 812i2d_ASN1_HEADER 820 NOEXIST::FUNCTION:
813i2d_ASN1_IA5STRING 821 EXIST::FUNCTION: 813i2d_ASN1_IA5STRING 821 EXIST::FUNCTION:
814i2d_ASN1_INTEGER 822 EXIST::FUNCTION: 814i2d_ASN1_INTEGER 822 EXIST::FUNCTION:
815i2d_ASN1_OBJECT 823 EXIST::FUNCTION: 815i2d_ASN1_OBJECT 823 EXIST::FUNCTION:
@@ -950,9 +950,9 @@ ERR_get_next_error_library 966 EXIST::FUNCTION:
950EVP_PKEY_cmp_parameters 967 EXIST::FUNCTION: 950EVP_PKEY_cmp_parameters 967 EXIST::FUNCTION:
951HMAC_cleanup 968 NOEXIST::FUNCTION: 951HMAC_cleanup 968 NOEXIST::FUNCTION:
952BIO_ptr_ctrl 969 EXIST::FUNCTION: 952BIO_ptr_ctrl 969 EXIST::FUNCTION:
953BIO_new_file_internal 970 EXIST:WIN16:FUNCTION:FP_API 953BIO_new_file_internal 970 NOEXIST::FUNCTION:
954BIO_new_fp_internal 971 EXIST:WIN16:FUNCTION:FP_API 954BIO_new_fp_internal 971 NOEXIST::FUNCTION:
955BIO_s_file_internal 972 EXIST:WIN16:FUNCTION:FP_API 955BIO_s_file_internal 972 NOEXIST::FUNCTION:
956BN_BLINDING_convert 973 EXIST::FUNCTION: 956BN_BLINDING_convert 973 EXIST::FUNCTION:
957BN_BLINDING_invert 974 EXIST::FUNCTION: 957BN_BLINDING_invert 974 EXIST::FUNCTION:
958BN_BLINDING_update 975 EXIST::FUNCTION: 958BN_BLINDING_update 975 EXIST::FUNCTION:
@@ -984,8 +984,8 @@ BIO_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:
987ERR_load_CRYPTO_strings 1009 EXIST:!OS2,!VMS,!WIN16:FUNCTION: 987ERR_load_CRYPTO_strings 1009 EXIST:!OS2,!VMS:FUNCTION:
988ERR_load_CRYPTOlib_strings 1009 EXIST:OS2,VMS,WIN16:FUNCTION: 988ERR_load_CRYPTOlib_strings 1009 EXIST:OS2,VMS:FUNCTION:
989EVP_PKEY_bits 1010 EXIST::FUNCTION: 989EVP_PKEY_bits 1010 EXIST::FUNCTION:
990MD5_Transform 1011 EXIST::FUNCTION:MD5 990MD5_Transform 1011 EXIST::FUNCTION:MD5
991SHA1_Transform 1012 EXIST::FUNCTION:SHA,SHA1 991SHA1_Transform 1012 EXIST::FUNCTION:SHA,SHA1
@@ -1117,11 +1117,11 @@ COMP_compress_block 1144 EXIST::FUNCTION:
1117COMP_expand_block 1145 EXIST::FUNCTION: 1117COMP_expand_block 1145 EXIST::FUNCTION:
1118COMP_rle 1146 EXIST::FUNCTION: 1118COMP_rle 1146 EXIST::FUNCTION:
1119COMP_zlib 1147 EXIST::FUNCTION: 1119COMP_zlib 1147 EXIST::FUNCTION:
1120ms_time_diff 1148 EXIST::FUNCTION: 1120ms_time_diff 1148 NOEXIST::FUNCTION:
1121ms_time_new 1149 EXIST::FUNCTION: 1121ms_time_new 1149 NOEXIST::FUNCTION:
1122ms_time_free 1150 EXIST::FUNCTION: 1122ms_time_free 1150 NOEXIST::FUNCTION:
1123ms_time_cmp 1151 EXIST::FUNCTION: 1123ms_time_cmp 1151 NOEXIST::FUNCTION:
1124ms_time_get 1152 EXIST::FUNCTION: 1124ms_time_get 1152 NOEXIST::FUNCTION:
1125PKCS7_set_attributes 1153 EXIST::FUNCTION: 1125PKCS7_set_attributes 1153 EXIST::FUNCTION:
1126PKCS7_set_signed_attributes 1154 EXIST::FUNCTION: 1126PKCS7_set_signed_attributes 1154 EXIST::FUNCTION:
1127X509_ATTRIBUTE_create 1155 EXIST::FUNCTION: 1127X509_ATTRIBUTE_create 1155 EXIST::FUNCTION:
@@ -1255,8 +1255,8 @@ PKCS12_gen_mac 1278 EXIST::FUNCTION:
1255PKCS12_verify_mac 1279 EXIST::FUNCTION: 1255PKCS12_verify_mac 1279 EXIST::FUNCTION:
1256PKCS12_set_mac 1280 EXIST::FUNCTION: 1256PKCS12_set_mac 1280 EXIST::FUNCTION:
1257PKCS12_setup_mac 1281 EXIST::FUNCTION: 1257PKCS12_setup_mac 1281 EXIST::FUNCTION:
1258asc2uni 1282 EXIST::FUNCTION: 1258OPENSSL_asc2uni 1282 EXIST::FUNCTION:
1259uni2asc 1283 EXIST::FUNCTION: 1259OPENSSL_uni2asc 1283 EXIST::FUNCTION:
1260i2d_PKCS12_BAGS 1284 EXIST::FUNCTION: 1260i2d_PKCS12_BAGS 1284 EXIST::FUNCTION:
1261PKCS12_BAGS_new 1285 EXIST::FUNCTION: 1261PKCS12_BAGS_new 1285 EXIST::FUNCTION:
1262d2i_PKCS12_BAGS 1286 EXIST::FUNCTION: 1262d2i_PKCS12_BAGS 1286 EXIST::FUNCTION:
@@ -2081,7 +2081,7 @@ NETSCAPE_SPKAC_it 2641 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIA
2081NETSCAPE_SPKAC_it 2641 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION: 2081NETSCAPE_SPKAC_it 2641 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:
2082X509_REVOKED_it 2642 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE: 2082X509_REVOKED_it 2642 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:
2083X509_REVOKED_it 2642 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION: 2083X509_REVOKED_it 2642 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:
2084ASN1_STRING_encode 2643 EXIST::FUNCTION: 2084ASN1_STRING_encode 2643 NOEXIST::FUNCTION:
2085EVP_aes_128_ecb 2644 EXIST::FUNCTION:AES 2085EVP_aes_128_ecb 2644 EXIST::FUNCTION:AES
2086KRB5_AUTHENT_free 2645 EXIST::FUNCTION: 2086KRB5_AUTHENT_free 2645 EXIST::FUNCTION:
2087OCSP_BASICRESP_get_ext_by_critical 2646 EXIST:!VMS:FUNCTION: 2087OCSP_BASICRESP_get_ext_by_critical 2646 EXIST:!VMS:FUNCTION:
@@ -2732,8 +2732,8 @@ EC_POINT_point2oct 3178 EXIST::FUNCTION:EC
2732KRB5_APREQ_free 3179 EXIST::FUNCTION: 2732KRB5_APREQ_free 3179 EXIST::FUNCTION:
2733ASN1_OBJECT_it 3180 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE: 2733ASN1_OBJECT_it 3180 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:
2734ASN1_OBJECT_it 3180 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION: 2734ASN1_OBJECT_it 3180 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:
2735OCSP_crlID_new 3181 EXIST:!OS2,!VMS,!WIN16:FUNCTION: 2735OCSP_crlID_new 3181 EXIST:!OS2,!VMS:FUNCTION:
2736OCSP_crlID2_new 3181 EXIST:OS2,VMS,WIN16:FUNCTION: 2736OCSP_crlID2_new 3181 EXIST:OS2,VMS: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:ENGINE 2739ENGINE_set_default_string 3184 EXIST::FUNCTION:ENGINE
@@ -2804,57 +2804,57 @@ OPENSSL_cleanse 3245 EXIST::FUNCTION:
2804ENGINE_setup_bsd_cryptodev 3246 EXIST:__FreeBSD__:FUNCTION:ENGINE 2804ENGINE_setup_bsd_cryptodev 3246 EXIST:__FreeBSD__:FUNCTION:ENGINE
2805ERR_release_err_state_table 3247 EXIST::FUNCTION:LHASH 2805ERR_release_err_state_table 3247 EXIST::FUNCTION:LHASH
2806EVP_aes_128_cfb8 3248 EXIST::FUNCTION:AES 2806EVP_aes_128_cfb8 3248 EXIST::FUNCTION:AES
2807FIPS_corrupt_rsa 3249 EXIST:OPENSSL_FIPS:FUNCTION: 2807FIPS_corrupt_rsa 3249 NOEXIST::FUNCTION:
2808FIPS_selftest_des 3250 EXIST:OPENSSL_FIPS:FUNCTION: 2808FIPS_selftest_des 3250 NOEXIST::FUNCTION:
2809EVP_aes_128_cfb1 3251 EXIST::FUNCTION:AES 2809EVP_aes_128_cfb1 3251 EXIST::FUNCTION:AES
2810EVP_aes_192_cfb8 3252 EXIST::FUNCTION:AES 2810EVP_aes_192_cfb8 3252 EXIST::FUNCTION:AES
2811FIPS_mode_set 3253 EXIST:OPENSSL_FIPS:FUNCTION: 2811FIPS_mode_set 3253 NOEXIST::FUNCTION:
2812FIPS_selftest_dsa 3254 EXIST:OPENSSL_FIPS:FUNCTION: 2812FIPS_selftest_dsa 3254 NOEXIST::FUNCTION:
2813EVP_aes_256_cfb8 3255 EXIST::FUNCTION:AES 2813EVP_aes_256_cfb8 3255 EXIST::FUNCTION:AES
2814FIPS_allow_md5 3256 NOEXIST::FUNCTION: 2814FIPS_allow_md5 3256 NOEXIST::FUNCTION:
2815DES_ede3_cfb_encrypt 3257 EXIST::FUNCTION:DES 2815DES_ede3_cfb_encrypt 3257 EXIST::FUNCTION:DES
2816EVP_des_ede3_cfb8 3258 EXIST::FUNCTION:DES 2816EVP_des_ede3_cfb8 3258 EXIST::FUNCTION:DES
2817FIPS_rand_seeded 3259 NOEXIST::FUNCTION: 2817FIPS_rand_seeded 3259 NOEXIST::FUNCTION:
2818AES_cfbr_encrypt_block 3260 EXIST::FUNCTION:AES 2818AES_cfbr_encrypt_block 3260 NOEXIST::FUNCTION:
2819AES_cfb8_encrypt 3261 EXIST::FUNCTION:AES 2819AES_cfb8_encrypt 3261 EXIST::FUNCTION:AES
2820FIPS_rand_seed 3262 EXIST:OPENSSL_FIPS:FUNCTION: 2820FIPS_rand_seed 3262 NOEXIST::FUNCTION:
2821FIPS_corrupt_des 3263 EXIST:OPENSSL_FIPS:FUNCTION: 2821FIPS_corrupt_des 3263 NOEXIST::FUNCTION:
2822EVP_aes_192_cfb1 3264 EXIST::FUNCTION:AES 2822EVP_aes_192_cfb1 3264 EXIST::FUNCTION:AES
2823FIPS_selftest_aes 3265 EXIST:OPENSSL_FIPS:FUNCTION: 2823FIPS_selftest_aes 3265 NOEXIST::FUNCTION:
2824FIPS_set_prng_key 3266 NOEXIST::FUNCTION: 2824FIPS_set_prng_key 3266 NOEXIST::FUNCTION:
2825EVP_des_cfb8 3267 EXIST::FUNCTION:DES 2825EVP_des_cfb8 3267 EXIST::FUNCTION:DES
2826FIPS_corrupt_dsa 3268 EXIST:OPENSSL_FIPS:FUNCTION: 2826FIPS_corrupt_dsa 3268 NOEXIST::FUNCTION:
2827FIPS_test_mode 3269 NOEXIST::FUNCTION: 2827FIPS_test_mode 3269 NOEXIST::FUNCTION:
2828FIPS_rand_method 3270 EXIST:OPENSSL_FIPS:FUNCTION: 2828FIPS_rand_method 3270 NOEXIST::FUNCTION:
2829EVP_aes_256_cfb1 3271 EXIST::FUNCTION:AES 2829EVP_aes_256_cfb1 3271 EXIST::FUNCTION:AES
2830ERR_load_FIPS_strings 3272 EXIST:OPENSSL_FIPS:FUNCTION: 2830ERR_load_FIPS_strings 3272 NOEXIST::FUNCTION:
2831FIPS_corrupt_aes 3273 EXIST:OPENSSL_FIPS:FUNCTION: 2831FIPS_corrupt_aes 3273 NOEXIST::FUNCTION:
2832FIPS_selftest_sha1 3274 EXIST:OPENSSL_FIPS:FUNCTION: 2832FIPS_selftest_sha1 3274 NOEXIST::FUNCTION:
2833FIPS_selftest_rsa 3275 EXIST:OPENSSL_FIPS:FUNCTION: 2833FIPS_selftest_rsa 3275 NOEXIST::FUNCTION:
2834FIPS_corrupt_sha1 3276 EXIST:OPENSSL_FIPS:FUNCTION: 2834FIPS_corrupt_sha1 3276 NOEXIST::FUNCTION:
2835EVP_des_cfb1 3277 EXIST::FUNCTION:DES 2835EVP_des_cfb1 3277 EXIST::FUNCTION:DES
2836FIPS_dsa_check 3278 NOEXIST::FUNCTION: 2836FIPS_dsa_check 3278 NOEXIST::FUNCTION:
2837AES_cfb1_encrypt 3279 EXIST::FUNCTION:AES 2837AES_cfb1_encrypt 3279 EXIST::FUNCTION:AES
2838EVP_des_ede3_cfb1 3280 EXIST::FUNCTION:DES 2838EVP_des_ede3_cfb1 3280 EXIST::FUNCTION:DES
2839FIPS_rand_check 3281 EXIST:OPENSSL_FIPS:FUNCTION: 2839FIPS_rand_check 3281 NOEXIST::FUNCTION:
2840FIPS_md5_allowed 3282 NOEXIST::FUNCTION: 2840FIPS_md5_allowed 3282 NOEXIST::FUNCTION:
2841FIPS_mode 3283 EXIST:OPENSSL_FIPS:FUNCTION: 2841FIPS_mode 3283 NOEXIST::FUNCTION:
2842FIPS_selftest_failed 3284 EXIST:OPENSSL_FIPS:FUNCTION: 2842FIPS_selftest_failed 3284 NOEXIST::FUNCTION:
2843sk_is_sorted 3285 EXIST::FUNCTION: 2843sk_is_sorted 3285 EXIST::FUNCTION:
2844X509_check_ca 3286 EXIST::FUNCTION: 2844X509_check_ca 3286 EXIST::FUNCTION:
2845private_idea_set_encrypt_key 3287 EXIST:OPENSSL_FIPS:FUNCTION:IDEA 2845private_idea_set_encrypt_key 3287 NOEXIST::FUNCTION:
2846HMAC_CTX_set_flags 3288 EXIST::FUNCTION:HMAC 2846HMAC_CTX_set_flags 3288 EXIST::FUNCTION:HMAC
2847private_SHA_Init 3289 EXIST:OPENSSL_FIPS:FUNCTION:SHA,SHA0 2847private_SHA_Init 3289 NOEXIST::FUNCTION:
2848private_CAST_set_key 3290 EXIST:OPENSSL_FIPS:FUNCTION:CAST 2848private_CAST_set_key 3290 NOEXIST::FUNCTION:
2849private_RIPEMD160_Init 3291 EXIST:OPENSSL_FIPS:FUNCTION:RIPEMD 2849private_RIPEMD160_Init 3291 NOEXIST::FUNCTION:
2850private_RC5_32_set_key 3292 EXIST:OPENSSL_FIPS:FUNCTION:RC5 2850private_RC5_32_set_key 3292 NOEXIST::FUNCTION:
2851private_MD5_Init 3293 EXIST:OPENSSL_FIPS:FUNCTION:MD5 2851private_MD5_Init 3293 NOEXIST::FUNCTION:
2852private_RC4_set_key 3294 EXIST:OPENSSL_FIPS:FUNCTION:RC4 2852private_RC4_set_key 3294 NOEXIST::FUNCTION:
2853private_MDC2_Init 3295 EXIST:OPENSSL_FIPS:FUNCTION:MDC2 2853private_MDC2_Init 3295 NOEXIST::FUNCTION:
2854private_RC2_set_key 3296 EXIST:OPENSSL_FIPS:FUNCTION:RC2 2854private_RC2_set_key 3296 NOEXIST::FUNCTION:
2855private_MD4_Init 3297 EXIST:OPENSSL_FIPS:FUNCTION:MD4 2855private_MD4_Init 3297 NOEXIST::FUNCTION:
2856private_BF_set_key 3298 EXIST:OPENSSL_FIPS:FUNCTION:BF 2856private_BF_set_key 3298 NOEXIST::FUNCTION:
2857private_MD2_Init 3299 EXIST:OPENSSL_FIPS:FUNCTION:MD2 2857private_MD2_Init 3299 NOEXIST::FUNCTION:
2858d2i_PROXY_CERT_INFO_EXTENSION 3300 EXIST::FUNCTION: 2858d2i_PROXY_CERT_INFO_EXTENSION 3300 EXIST::FUNCTION:
2859PROXY_POLICY_it 3301 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE: 2859PROXY_POLICY_it 3301 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:
2860PROXY_POLICY_it 3301 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION: 2860PROXY_POLICY_it 3301 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:
@@ -2868,13 +2868,13 @@ PROXY_CERT_INFO_EXTENSION_it 3307 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTI
2868PROXY_POLICY_free 3308 EXIST::FUNCTION: 2868PROXY_POLICY_free 3308 EXIST::FUNCTION:
2869PROXY_POLICY_new 3309 EXIST::FUNCTION: 2869PROXY_POLICY_new 3309 EXIST::FUNCTION:
2870BN_MONT_CTX_set_locked 3310 EXIST::FUNCTION: 2870BN_MONT_CTX_set_locked 3310 EXIST::FUNCTION:
2871FIPS_selftest_rng 3311 EXIST:OPENSSL_FIPS:FUNCTION: 2871FIPS_selftest_rng 3311 NOEXIST::FUNCTION:
2872EVP_sha384 3312 EXIST::FUNCTION:SHA,SHA512 2872EVP_sha384 3312 EXIST:!VMSVAX:FUNCTION:SHA,SHA512
2873EVP_sha512 3313 EXIST::FUNCTION:SHA,SHA512 2873EVP_sha512 3313 EXIST:!VMSVAX:FUNCTION:SHA,SHA512
2874EVP_sha224 3314 EXIST::FUNCTION:SHA,SHA256 2874EVP_sha224 3314 EXIST::FUNCTION:SHA,SHA256
2875EVP_sha256 3315 EXIST::FUNCTION:SHA,SHA256 2875EVP_sha256 3315 EXIST::FUNCTION:SHA,SHA256
2876FIPS_selftest_hmac 3316 EXIST:OPENSSL_FIPS:FUNCTION: 2876FIPS_selftest_hmac 3316 NOEXIST::FUNCTION:
2877FIPS_corrupt_rng 3317 EXIST:OPENSSL_FIPS:FUNCTION: 2877FIPS_corrupt_rng 3317 NOEXIST::FUNCTION:
2878BN_mod_exp_mont_consttime 3318 EXIST::FUNCTION: 2878BN_mod_exp_mont_consttime 3318 EXIST::FUNCTION:
2879RSA_X931_hash_id 3319 EXIST::FUNCTION:RSA 2879RSA_X931_hash_id 3319 EXIST::FUNCTION:RSA
2880RSA_padding_check_X931 3320 EXIST::FUNCTION:RSA 2880RSA_padding_check_X931 3320 EXIST::FUNCTION:RSA
@@ -2882,7 +2882,7 @@ RSA_verify_PKCS1_PSS 3321 EXIST::FUNCTION:RSA
2882RSA_padding_add_X931 3322 EXIST::FUNCTION:RSA 2882RSA_padding_add_X931 3322 EXIST::FUNCTION:RSA
2883RSA_padding_add_PKCS1_PSS 3323 EXIST::FUNCTION:RSA 2883RSA_padding_add_PKCS1_PSS 3323 EXIST::FUNCTION:RSA
2884PKCS1_MGF1 3324 EXIST::FUNCTION:RSA 2884PKCS1_MGF1 3324 EXIST::FUNCTION:RSA
2885BN_X931_generate_Xpq 3325 EXIST::FUNCTION: 2885BN_X931_generate_Xpq 3325 NOEXIST::FUNCTION:
2886RSA_X931_generate_key 3326 NOEXIST::FUNCTION: 2886RSA_X931_generate_key 3326 NOEXIST::FUNCTION:
2887BN_X931_derive_prime 3327 NOEXIST::FUNCTION: 2887BN_X931_derive_prime 3327 NOEXIST::FUNCTION:
2888BN_X931_generate_prime 3328 NOEXIST::FUNCTION: 2888BN_X931_generate_prime 3328 NOEXIST::FUNCTION:
@@ -2893,43 +2893,43 @@ ERR_set_mark 3332 EXIST::FUNCTION:
2893X509_STORE_CTX_set0_crls 3333 EXIST::FUNCTION: 2893X509_STORE_CTX_set0_crls 3333 EXIST::FUNCTION:
2894ENGINE_set_STORE 3334 EXIST::FUNCTION:ENGINE 2894ENGINE_set_STORE 3334 EXIST::FUNCTION:ENGINE
2895ENGINE_register_ECDSA 3335 EXIST::FUNCTION:ENGINE 2895ENGINE_register_ECDSA 3335 EXIST::FUNCTION:ENGINE
2896STORE_method_set_list_start_function 3336 EXIST:!VMS:FUNCTION: 2896STORE_meth_set_list_start_fn 3336 NOEXIST::FUNCTION:
2897STORE_meth_set_list_start_fn 3336 EXIST:VMS:FUNCTION: 2897STORE_method_set_list_start_function 3336 NOEXIST::FUNCTION:
2898BN_BLINDING_invert_ex 3337 EXIST::FUNCTION: 2898BN_BLINDING_invert_ex 3337 EXIST::FUNCTION:
2899NAME_CONSTRAINTS_free 3338 EXIST::FUNCTION: 2899NAME_CONSTRAINTS_free 3338 EXIST::FUNCTION:
2900STORE_ATTR_INFO_set_number 3339 EXIST::FUNCTION: 2900STORE_ATTR_INFO_set_number 3339 NOEXIST::FUNCTION:
2901BN_BLINDING_get_thread_id 3340 EXIST::FUNCTION: 2901BN_BLINDING_get_thread_id 3340 EXIST::FUNCTION:DEPRECATED
2902X509_STORE_CTX_set0_param 3341 EXIST::FUNCTION: 2902X509_STORE_CTX_set0_param 3341 EXIST::FUNCTION:
2903POLICY_MAPPING_it 3342 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE: 2903POLICY_MAPPING_it 3342 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:
2904POLICY_MAPPING_it 3342 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION: 2904POLICY_MAPPING_it 3342 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:
2905STORE_parse_attrs_start 3343 EXIST::FUNCTION: 2905STORE_parse_attrs_start 3343 NOEXIST::FUNCTION:
2906POLICY_CONSTRAINTS_free 3344 EXIST::FUNCTION: 2906POLICY_CONSTRAINTS_free 3344 EXIST::FUNCTION:
2907EVP_PKEY_add1_attr_by_NID 3345 EXIST::FUNCTION: 2907EVP_PKEY_add1_attr_by_NID 3345 EXIST::FUNCTION:
2908BN_nist_mod_192 3346 EXIST::FUNCTION: 2908BN_nist_mod_192 3346 EXIST::FUNCTION:
2909EC_GROUP_get_trinomial_basis 3347 EXIST::FUNCTION:EC 2909EC_GROUP_get_trinomial_basis 3347 EXIST::FUNCTION:EC
2910STORE_set_method 3348 EXIST::FUNCTION: 2910STORE_set_method 3348 NOEXIST::FUNCTION:
2911GENERAL_SUBTREE_free 3349 EXIST::FUNCTION: 2911GENERAL_SUBTREE_free 3349 EXIST::FUNCTION:
2912NAME_CONSTRAINTS_it 3350 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE: 2912NAME_CONSTRAINTS_it 3350 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:
2913NAME_CONSTRAINTS_it 3350 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION: 2913NAME_CONSTRAINTS_it 3350 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:
2914ECDH_get_default_method 3351 EXIST::FUNCTION:ECDH 2914ECDH_get_default_method 3351 EXIST::FUNCTION:ECDH
2915PKCS12_add_safe 3352 EXIST::FUNCTION: 2915PKCS12_add_safe 3352 EXIST::FUNCTION:
2916EC_KEY_new_by_curve_name 3353 EXIST::FUNCTION:EC 2916EC_KEY_new_by_curve_name 3353 EXIST::FUNCTION:EC
2917STORE_method_get_update_store_function 3354 EXIST:!VMS:FUNCTION: 2917STORE_meth_get_update_store_fn 3354 NOEXIST::FUNCTION:
2918STORE_meth_get_update_store_fn 3354 EXIST:VMS:FUNCTION: 2918STORE_method_get_update_store_function 3354 NOEXIST::FUNCTION:
2919ENGINE_register_ECDH 3355 EXIST::FUNCTION:ENGINE 2919ENGINE_register_ECDH 3355 EXIST::FUNCTION:ENGINE
2920SHA512_Update 3356 EXIST::FUNCTION:SHA,SHA512 2920SHA512_Update 3356 EXIST:!VMSVAX:FUNCTION:SHA,SHA512
2921i2d_ECPrivateKey 3357 EXIST::FUNCTION:EC 2921i2d_ECPrivateKey 3357 EXIST::FUNCTION:EC
2922BN_get0_nist_prime_192 3358 EXIST::FUNCTION: 2922BN_get0_nist_prime_192 3358 EXIST::FUNCTION:
2923STORE_modify_certificate 3359 EXIST::FUNCTION: 2923STORE_modify_certificate 3359 NOEXIST::FUNCTION:
2924EC_POINT_set_affine_coordinates_GF2m 3360 EXIST:!VMS:FUNCTION:EC 2924EC_POINT_set_affine_coordinates_GF2m 3360 EXIST:!VMS:FUNCTION:EC
2925EC_POINT_set_affine_coords_GF2m 3360 EXIST:VMS:FUNCTION:EC 2925EC_POINT_set_affine_coords_GF2m 3360 EXIST:VMS:FUNCTION:EC
2926BN_GF2m_mod_exp_arr 3361 EXIST::FUNCTION: 2926BN_GF2m_mod_exp_arr 3361 EXIST::FUNCTION:
2927STORE_ATTR_INFO_modify_number 3362 EXIST::FUNCTION: 2927STORE_ATTR_INFO_modify_number 3362 NOEXIST::FUNCTION:
2928X509_keyid_get0 3363 EXIST::FUNCTION: 2928X509_keyid_get0 3363 EXIST::FUNCTION:
2929ENGINE_load_gmp 3364 EXIST::FUNCTION:ENGINE,GMP,STATIC_ENGINE 2929ENGINE_load_gmp 3364 EXIST::FUNCTION:ENGINE,GMP,STATIC_ENGINE
2930pitem_new 3365 EXIST::FUNCTION: 2930pitem_new 3365 EXIST::FUNCTION:
2931BN_GF2m_mod_mul_arr 3366 EXIST::FUNCTION: 2931BN_GF2m_mod_mul_arr 3366 EXIST::FUNCTION:
2932STORE_list_public_key_endp 3367 EXIST::FUNCTION: 2932STORE_list_public_key_endp 3367 NOEXIST::FUNCTION:
2933o2i_ECPublicKey 3368 EXIST::FUNCTION:EC 2933o2i_ECPublicKey 3368 EXIST::FUNCTION:EC
2934EC_KEY_copy 3369 EXIST::FUNCTION:EC 2934EC_KEY_copy 3369 EXIST::FUNCTION:EC
2935BIO_dump_fp 3370 EXIST::FUNCTION:FP_API 2935BIO_dump_fp 3370 EXIST::FUNCTION:FP_API
@@ -2938,25 +2938,25 @@ EC_GROUP_check_discriminant 3372 EXIST::FUNCTION:EC
2938i2o_ECPublicKey 3373 EXIST::FUNCTION:EC 2938i2o_ECPublicKey 3373 EXIST::FUNCTION:EC
2939EC_KEY_precompute_mult 3374 EXIST::FUNCTION:EC 2939EC_KEY_precompute_mult 3374 EXIST::FUNCTION:EC
2940a2i_IPADDRESS 3375 EXIST::FUNCTION: 2940a2i_IPADDRESS 3375 EXIST::FUNCTION:
2941STORE_method_set_initialise_function 3376 EXIST:!VMS:FUNCTION: 2941STORE_meth_set_initialise_fn 3376 NOEXIST::FUNCTION:
2942STORE_meth_set_initialise_fn 3376 EXIST:VMS:FUNCTION: 2942STORE_method_set_initialise_function 3376 NOEXIST::FUNCTION:
2943X509_STORE_CTX_set_depth 3377 EXIST::FUNCTION: 2943X509_STORE_CTX_set_depth 3377 EXIST::FUNCTION:
2944X509_VERIFY_PARAM_inherit 3378 EXIST::FUNCTION: 2944X509_VERIFY_PARAM_inherit 3378 EXIST::FUNCTION:
2945EC_POINT_point2bn 3379 EXIST::FUNCTION:EC 2945EC_POINT_point2bn 3379 EXIST::FUNCTION:EC
2946STORE_ATTR_INFO_set_dn 3380 EXIST::FUNCTION: 2946STORE_ATTR_INFO_set_dn 3380 NOEXIST::FUNCTION:
2947X509_policy_tree_get0_policies 3381 EXIST::FUNCTION: 2947X509_policy_tree_get0_policies 3381 EXIST::FUNCTION:
2948EC_GROUP_new_curve_GF2m 3382 EXIST::FUNCTION:EC 2948EC_GROUP_new_curve_GF2m 3382 EXIST::FUNCTION:EC
2949STORE_destroy_method 3383 EXIST::FUNCTION: 2949STORE_destroy_method 3383 NOEXIST::FUNCTION:
2950ENGINE_unregister_STORE 3384 EXIST::FUNCTION:ENGINE 2950ENGINE_unregister_STORE 3384 EXIST::FUNCTION:ENGINE
2951EVP_PKEY_get1_EC_KEY 3385 EXIST::FUNCTION:EC 2951EVP_PKEY_get1_EC_KEY 3385 EXIST::FUNCTION:EC
2952STORE_ATTR_INFO_get0_number 3386 EXIST::FUNCTION: 2952STORE_ATTR_INFO_get0_number 3386 NOEXIST::FUNCTION:
2953ENGINE_get_default_ECDH 3387 EXIST::FUNCTION:ENGINE 2953ENGINE_get_default_ECDH 3387 EXIST::FUNCTION:ENGINE
2954EC_KEY_get_conv_form 3388 EXIST::FUNCTION:EC 2954EC_KEY_get_conv_form 3388 EXIST::FUNCTION:EC
2955ASN1_OCTET_STRING_NDEF_it 3389 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE: 2955ASN1_OCTET_STRING_NDEF_it 3389 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:
2956ASN1_OCTET_STRING_NDEF_it 3389 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION: 2956ASN1_OCTET_STRING_NDEF_it 3389 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:
2957STORE_delete_public_key 3390 EXIST::FUNCTION: 2957STORE_delete_public_key 3390 NOEXIST::FUNCTION:
2958STORE_get_public_key 3391 EXIST::FUNCTION: 2958STORE_get_public_key 3391 NOEXIST::FUNCTION:
2959STORE_modify_arbitrary 3392 EXIST::FUNCTION: 2959STORE_modify_arbitrary 3392 NOEXIST::FUNCTION:
2960ENGINE_get_static_state 3393 EXIST::FUNCTION:ENGINE 2960ENGINE_get_static_state 3393 EXIST::FUNCTION:ENGINE
2961pqueue_iterator 3394 EXIST::FUNCTION: 2961pqueue_iterator 3394 EXIST::FUNCTION:
2962ECDSA_SIG_new 3395 EXIST::FUNCTION:ECDSA 2962ECDSA_SIG_new 3395 EXIST::FUNCTION:ECDSA
@@ -2965,14 +2965,14 @@ BN_GF2m_mod_sqr 3397 EXIST::FUNCTION:
2965EC_POINT_bn2point 3398 EXIST::FUNCTION:EC 2965EC_POINT_bn2point 3398 EXIST::FUNCTION:EC
2966X509_VERIFY_PARAM_set_depth 3399 EXIST::FUNCTION: 2966X509_VERIFY_PARAM_set_depth 3399 EXIST::FUNCTION:
2967EC_KEY_set_asn1_flag 3400 EXIST::FUNCTION:EC 2967EC_KEY_set_asn1_flag 3400 EXIST::FUNCTION:EC
2968STORE_get_method 3401 EXIST::FUNCTION: 2968STORE_get_method 3401 NOEXIST::FUNCTION:
2969EC_KEY_get_key_method_data 3402 EXIST::FUNCTION:EC 2969EC_KEY_get_key_method_data 3402 EXIST::FUNCTION:EC
2970ECDSA_sign_ex 3403 EXIST::FUNCTION:ECDSA 2970ECDSA_sign_ex 3403 EXIST::FUNCTION:ECDSA
2971STORE_parse_attrs_end 3404 EXIST::FUNCTION: 2971STORE_parse_attrs_end 3404 NOEXIST::FUNCTION:
2972EC_GROUP_get_point_conversion_form 3405 EXIST:!VMS:FUNCTION:EC 2972EC_GROUP_get_point_conversion_form 3405 EXIST:!VMS:FUNCTION:EC
2973EC_GROUP_get_point_conv_form 3405 EXIST:VMS:FUNCTION:EC 2973EC_GROUP_get_point_conv_form 3405 EXIST:VMS:FUNCTION:EC
2974STORE_method_set_store_function 3406 EXIST::FUNCTION: 2974STORE_method_set_store_function 3406 NOEXIST::FUNCTION:
2975STORE_ATTR_INFO_in 3407 EXIST::FUNCTION: 2975STORE_ATTR_INFO_in 3407 NOEXIST::FUNCTION:
2976PEM_read_bio_ECPKParameters 3408 EXIST::FUNCTION:EC 2976PEM_read_bio_ECPKParameters 3408 EXIST::FUNCTION:EC
2977EC_GROUP_get_pentanomial_basis 3409 EXIST::FUNCTION:EC 2977EC_GROUP_get_pentanomial_basis 3409 EXIST::FUNCTION:EC
2978EVP_PKEY_add1_attr_by_txt 3410 EXIST::FUNCTION: 2978EVP_PKEY_add1_attr_by_txt 3410 EXIST::FUNCTION:
@@ -2980,7 +2980,7 @@ BN_BLINDING_set_flags 3411 EXIST::FUNCTION:
2980X509_VERIFY_PARAM_set1_policies 3412 EXIST::FUNCTION: 2980X509_VERIFY_PARAM_set1_policies 3412 EXIST::FUNCTION:
2981X509_VERIFY_PARAM_set1_name 3413 EXIST::FUNCTION: 2981X509_VERIFY_PARAM_set1_name 3413 EXIST::FUNCTION:
2982X509_VERIFY_PARAM_set_purpose 3414 EXIST::FUNCTION: 2982X509_VERIFY_PARAM_set_purpose 3414 EXIST::FUNCTION:
2983STORE_get_number 3415 EXIST::FUNCTION: 2983STORE_get_number 3415 NOEXIST::FUNCTION:
2984ECDSA_sign_setup 3416 EXIST::FUNCTION:ECDSA 2984ECDSA_sign_setup 3416 EXIST::FUNCTION:ECDSA
2985BN_GF2m_mod_solve_quad_arr 3417 EXIST::FUNCTION: 2985BN_GF2m_mod_solve_quad_arr 3417 EXIST::FUNCTION:
2986EC_KEY_up_ref 3418 EXIST::FUNCTION:EC 2986EC_KEY_up_ref 3418 EXIST::FUNCTION:EC
@@ -2988,14 +2988,14 @@ POLICY_MAPPING_free 3419 EXIST::FUNCTION:
2988BN_GF2m_mod_div 3420 EXIST::FUNCTION: 2988BN_GF2m_mod_div 3420 EXIST::FUNCTION:
2989X509_VERIFY_PARAM_set_flags 3421 EXIST::FUNCTION: 2989X509_VERIFY_PARAM_set_flags 3421 EXIST::FUNCTION:
2990EC_KEY_free 3422 EXIST::FUNCTION:EC 2990EC_KEY_free 3422 EXIST::FUNCTION:EC
2991STORE_method_set_list_next_function 3423 EXIST:!VMS:FUNCTION: 2991STORE_meth_set_list_next_fn 3423 NOEXIST::FUNCTION:
2992STORE_meth_set_list_next_fn 3423 EXIST:VMS:FUNCTION: 2992STORE_method_set_list_next_function 3423 NOEXIST::FUNCTION:
2993PEM_write_bio_ECPrivateKey 3424 EXIST::FUNCTION:EC 2993PEM_write_bio_ECPrivateKey 3424 EXIST::FUNCTION:EC
2994d2i_EC_PUBKEY 3425 EXIST::FUNCTION:EC 2994d2i_EC_PUBKEY 3425 EXIST::FUNCTION:EC
2995STORE_method_get_generate_function 3426 EXIST:!VMS:FUNCTION: 2995STORE_meth_get_generate_fn 3426 NOEXIST::FUNCTION:
2996STORE_meth_get_generate_fn 3426 EXIST:VMS:FUNCTION: 2996STORE_method_get_generate_function 3426 NOEXIST::FUNCTION:
2997STORE_method_set_list_end_function 3427 EXIST:!VMS:FUNCTION: 2997STORE_meth_set_list_end_fn 3427 NOEXIST::FUNCTION:
2998STORE_meth_set_list_end_fn 3427 EXIST:VMS:FUNCTION: 2998STORE_method_set_list_end_function 3427 NOEXIST::FUNCTION:
2999pqueue_print 3428 EXIST::FUNCTION: 2999pqueue_print 3428 EXIST::FUNCTION:
3000EC_GROUP_have_precompute_mult 3429 EXIST::FUNCTION:EC 3000EC_GROUP_have_precompute_mult 3429 EXIST::FUNCTION:EC
3001EC_KEY_print_fp 3430 EXIST::FUNCTION:EC,FP_API 3001EC_KEY_print_fp 3430 EXIST::FUNCTION:EC,FP_API
@@ -3003,8 +3003,8 @@ BN_GF2m_mod_arr 3431 EXIST::FUNCTION:
3003PEM_write_bio_X509_CERT_PAIR 3432 EXIST::FUNCTION: 3003PEM_write_bio_X509_CERT_PAIR 3432 EXIST::FUNCTION:
3004EVP_PKEY_cmp 3433 EXIST::FUNCTION: 3004EVP_PKEY_cmp 3433 EXIST::FUNCTION:
3005X509_policy_level_node_count 3434 EXIST::FUNCTION: 3005X509_policy_level_node_count 3434 EXIST::FUNCTION:
3006STORE_new_engine 3435 EXIST::FUNCTION: 3006STORE_new_engine 3435 NOEXIST::FUNCTION:
3007STORE_list_public_key_start 3436 EXIST::FUNCTION: 3007STORE_list_public_key_start 3436 NOEXIST::FUNCTION:
3008X509_VERIFY_PARAM_new 3437 EXIST::FUNCTION: 3008X509_VERIFY_PARAM_new 3437 EXIST::FUNCTION:
3009ECDH_get_ex_data 3438 EXIST::FUNCTION:ECDH 3009ECDH_get_ex_data 3438 EXIST::FUNCTION:ECDH
3010EVP_PKEY_get_attr 3439 EXIST::FUNCTION: 3010EVP_PKEY_get_attr 3439 EXIST::FUNCTION:
@@ -3014,11 +3014,11 @@ ECDH_OpenSSL 3442 EXIST::FUNCTION:ECDH
3014EC_KEY_set_conv_form 3443 EXIST::FUNCTION:EC 3014EC_KEY_set_conv_form 3443 EXIST::FUNCTION:EC
3015EC_POINT_dup 3444 EXIST::FUNCTION:EC 3015EC_POINT_dup 3444 EXIST::FUNCTION:EC
3016GENERAL_SUBTREE_new 3445 EXIST::FUNCTION: 3016GENERAL_SUBTREE_new 3445 EXIST::FUNCTION:
3017STORE_list_crl_endp 3446 EXIST::FUNCTION: 3017STORE_list_crl_endp 3446 NOEXIST::FUNCTION:
3018EC_get_builtin_curves 3447 EXIST::FUNCTION:EC 3018EC_get_builtin_curves 3447 EXIST::FUNCTION:EC
3019X509_policy_node_get0_qualifiers 3448 EXIST:!VMS:FUNCTION: 3019X509_policy_node_get0_qualifiers 3448 EXIST:!VMS:FUNCTION:
3020X509_pcy_node_get0_qualifiers 3448 EXIST:VMS:FUNCTION: 3020X509_pcy_node_get0_qualifiers 3448 EXIST:VMS:FUNCTION:
3021STORE_list_crl_end 3449 EXIST::FUNCTION: 3021STORE_list_crl_end 3449 NOEXIST::FUNCTION:
3022EVP_PKEY_set1_EC_KEY 3450 EXIST::FUNCTION:EC 3022EVP_PKEY_set1_EC_KEY 3450 EXIST::FUNCTION:EC
3023BN_GF2m_mod_sqrt_arr 3451 EXIST::FUNCTION: 3023BN_GF2m_mod_sqrt_arr 3451 EXIST::FUNCTION:
3024i2d_ECPrivateKey_bio 3452 EXIST::FUNCTION:BIO,EC 3024i2d_ECPrivateKey_bio 3452 EXIST::FUNCTION:BIO,EC
@@ -3026,60 +3026,60 @@ ECPKParameters_print_fp 3453 EXIST::FUNCTION:EC,FP_API
3026pqueue_find 3454 EXIST::FUNCTION: 3026pqueue_find 3454 EXIST::FUNCTION:
3027ECDSA_SIG_free 3455 EXIST::FUNCTION:ECDSA 3027ECDSA_SIG_free 3455 EXIST::FUNCTION:ECDSA
3028PEM_write_bio_ECPKParameters 3456 EXIST::FUNCTION:EC 3028PEM_write_bio_ECPKParameters 3456 EXIST::FUNCTION:EC
3029STORE_method_set_ctrl_function 3457 EXIST::FUNCTION: 3029STORE_method_set_ctrl_function 3457 NOEXIST::FUNCTION:
3030STORE_list_public_key_end 3458 EXIST::FUNCTION: 3030STORE_list_public_key_end 3458 NOEXIST::FUNCTION:
3031EC_KEY_set_private_key 3459 EXIST::FUNCTION:EC 3031EC_KEY_set_private_key 3459 EXIST::FUNCTION:EC
3032pqueue_peek 3460 EXIST::FUNCTION: 3032pqueue_peek 3460 EXIST::FUNCTION:
3033STORE_get_arbitrary 3461 EXIST::FUNCTION: 3033STORE_get_arbitrary 3461 NOEXIST::FUNCTION:
3034STORE_store_crl 3462 EXIST::FUNCTION: 3034STORE_store_crl 3462 NOEXIST::FUNCTION:
3035X509_policy_node_get0_policy 3463 EXIST::FUNCTION: 3035X509_policy_node_get0_policy 3463 EXIST::FUNCTION:
3036PKCS12_add_safes 3464 EXIST::FUNCTION: 3036PKCS12_add_safes 3464 EXIST::FUNCTION:
3037BN_BLINDING_convert_ex 3465 EXIST::FUNCTION: 3037BN_BLINDING_convert_ex 3465 EXIST::FUNCTION:
3038X509_policy_tree_free 3466 EXIST::FUNCTION: 3038X509_policy_tree_free 3466 EXIST::FUNCTION:
3039OPENSSL_ia32cap_loc 3467 EXIST::FUNCTION: 3039OPENSSL_ia32cap_loc 3467 EXIST::FUNCTION:
3040BN_GF2m_poly2arr 3468 EXIST::FUNCTION: 3040BN_GF2m_poly2arr 3468 EXIST::FUNCTION:
3041STORE_ctrl 3469 EXIST::FUNCTION: 3041STORE_ctrl 3469 NOEXIST::FUNCTION:
3042STORE_ATTR_INFO_compare 3470 EXIST::FUNCTION: 3042STORE_ATTR_INFO_compare 3470 NOEXIST::FUNCTION:
3043BN_get0_nist_prime_224 3471 EXIST::FUNCTION: 3043BN_get0_nist_prime_224 3471 EXIST::FUNCTION:
3044i2d_ECParameters 3472 EXIST::FUNCTION:EC 3044i2d_ECParameters 3472 EXIST::FUNCTION:EC
3045i2d_ECPKParameters 3473 EXIST::FUNCTION:EC 3045i2d_ECPKParameters 3473 EXIST::FUNCTION:EC
3046BN_GENCB_call 3474 EXIST::FUNCTION: 3046BN_GENCB_call 3474 EXIST::FUNCTION:
3047d2i_ECPKParameters 3475 EXIST::FUNCTION:EC 3047d2i_ECPKParameters 3475 EXIST::FUNCTION:EC
3048STORE_method_set_generate_function 3476 EXIST:!VMS:FUNCTION: 3048STORE_meth_set_generate_fn 3476 NOEXIST::FUNCTION:
3049STORE_meth_set_generate_fn 3476 EXIST:VMS:FUNCTION: 3049STORE_method_set_generate_function 3476 NOEXIST::FUNCTION:
3050ENGINE_set_ECDH 3477 EXIST::FUNCTION:ENGINE 3050ENGINE_set_ECDH 3477 EXIST::FUNCTION:ENGINE
3051NAME_CONSTRAINTS_new 3478 EXIST::FUNCTION: 3051NAME_CONSTRAINTS_new 3478 EXIST::FUNCTION:
3052SHA256_Init 3479 EXIST::FUNCTION:SHA,SHA256 3052SHA256_Init 3479 EXIST::FUNCTION:SHA,SHA256
3053EC_KEY_get0_public_key 3480 EXIST::FUNCTION:EC 3053EC_KEY_get0_public_key 3480 EXIST::FUNCTION:EC
3054PEM_write_bio_EC_PUBKEY 3481 EXIST::FUNCTION:EC 3054PEM_write_bio_EC_PUBKEY 3481 EXIST::FUNCTION:EC
3055STORE_ATTR_INFO_set_cstr 3482 EXIST::FUNCTION: 3055STORE_ATTR_INFO_set_cstr 3482 NOEXIST::FUNCTION:
3056STORE_list_crl_next 3483 EXIST::FUNCTION: 3056STORE_list_crl_next 3483 NOEXIST::FUNCTION:
3057STORE_ATTR_INFO_in_range 3484 EXIST::FUNCTION: 3057STORE_ATTR_INFO_in_range 3484 NOEXIST::FUNCTION:
3058ECParameters_print 3485 EXIST::FUNCTION:BIO,EC 3058ECParameters_print 3485 EXIST::FUNCTION:BIO,EC
3059STORE_method_set_delete_function 3486 EXIST:!VMS:FUNCTION: 3059STORE_meth_set_delete_fn 3486 NOEXIST::FUNCTION:
3060STORE_meth_set_delete_fn 3486 EXIST:VMS:FUNCTION: 3060STORE_method_set_delete_function 3486 NOEXIST::FUNCTION:
3061STORE_list_certificate_next 3487 EXIST::FUNCTION: 3061STORE_list_certificate_next 3487 NOEXIST::FUNCTION:
3062ASN1_generate_nconf 3488 EXIST::FUNCTION: 3062ASN1_generate_nconf 3488 EXIST::FUNCTION:
3063BUF_memdup 3489 EXIST::FUNCTION: 3063BUF_memdup 3489 EXIST::FUNCTION:
3064BN_GF2m_mod_mul 3490 EXIST::FUNCTION: 3064BN_GF2m_mod_mul 3490 EXIST::FUNCTION:
3065STORE_method_get_list_next_function 3491 EXIST:!VMS:FUNCTION: 3065STORE_meth_get_list_next_fn 3491 NOEXIST::FUNCTION:
3066STORE_meth_get_list_next_fn 3491 EXIST:VMS:FUNCTION: 3066STORE_method_get_list_next_function 3491 NOEXIST::FUNCTION:
3067STORE_ATTR_INFO_get0_dn 3492 EXIST::FUNCTION: 3067STORE_ATTR_INFO_get0_dn 3492 NOEXIST::FUNCTION:
3068STORE_list_private_key_next 3493 EXIST::FUNCTION: 3068STORE_list_private_key_next 3493 NOEXIST::FUNCTION:
3069EC_GROUP_set_seed 3494 EXIST::FUNCTION:EC 3069EC_GROUP_set_seed 3494 EXIST::FUNCTION:EC
3070X509_VERIFY_PARAM_set_trust 3495 EXIST::FUNCTION: 3070X509_VERIFY_PARAM_set_trust 3495 EXIST::FUNCTION:
3071STORE_ATTR_INFO_free 3496 EXIST::FUNCTION: 3071STORE_ATTR_INFO_free 3496 NOEXIST::FUNCTION:
3072STORE_get_private_key 3497 EXIST::FUNCTION: 3072STORE_get_private_key 3497 NOEXIST::FUNCTION:
3073EVP_PKEY_get_attr_count 3498 EXIST::FUNCTION: 3073EVP_PKEY_get_attr_count 3498 EXIST::FUNCTION:
3074STORE_ATTR_INFO_new 3499 EXIST::FUNCTION: 3074STORE_ATTR_INFO_new 3499 NOEXIST::FUNCTION:
3075EC_GROUP_get_curve_GF2m 3500 EXIST::FUNCTION:EC 3075EC_GROUP_get_curve_GF2m 3500 EXIST::FUNCTION:EC
3076STORE_method_set_revoke_function 3501 EXIST:!VMS:FUNCTION: 3076STORE_meth_set_revoke_fn 3501 NOEXIST::FUNCTION:
3077STORE_meth_set_revoke_fn 3501 EXIST:VMS:FUNCTION: 3077STORE_method_set_revoke_function 3501 NOEXIST::FUNCTION:
3078STORE_store_number 3502 EXIST::FUNCTION: 3078STORE_store_number 3502 NOEXIST::FUNCTION:
3079BN_is_prime_ex 3503 EXIST::FUNCTION: 3079BN_is_prime_ex 3503 EXIST::FUNCTION:
3080STORE_revoke_public_key 3504 EXIST::FUNCTION: 3080STORE_revoke_public_key 3504 NOEXIST::FUNCTION:
3081X509_STORE_CTX_get0_param 3505 EXIST::FUNCTION: 3081X509_STORE_CTX_get0_param 3505 EXIST::FUNCTION:
3082STORE_delete_arbitrary 3506 EXIST::FUNCTION: 3082STORE_delete_arbitrary 3506 NOEXIST::FUNCTION:
3083PEM_read_X509_CERT_PAIR 3507 EXIST:!WIN16:FUNCTION: 3083PEM_read_X509_CERT_PAIR 3507 EXIST:!WIN16:FUNCTION:
3084X509_STORE_set_depth 3508 EXIST::FUNCTION: 3084X509_STORE_set_depth 3508 EXIST::FUNCTION:
3085ECDSA_get_ex_data 3509 EXIST::FUNCTION:ECDSA 3085ECDSA_get_ex_data 3509 EXIST::FUNCTION:ECDSA
@@ -3087,40 +3087,40 @@ SHA224 3510 EXIST::FUNCTION:SHA,SHA256
3087BIO_dump_indent_fp 3511 EXIST::FUNCTION:FP_API 3087BIO_dump_indent_fp 3511 EXIST::FUNCTION:FP_API
3088EC_KEY_set_group 3512 EXIST::FUNCTION:EC 3088EC_KEY_set_group 3512 EXIST::FUNCTION:EC
3089BUF_strndup 3513 EXIST::FUNCTION: 3089BUF_strndup 3513 EXIST::FUNCTION:
3090STORE_list_certificate_start 3514 EXIST::FUNCTION: 3090STORE_list_certificate_start 3514 NOEXIST::FUNCTION:
3091BN_GF2m_mod 3515 EXIST::FUNCTION: 3091BN_GF2m_mod 3515 EXIST::FUNCTION:
3092X509_REQ_check_private_key 3516 EXIST::FUNCTION: 3092X509_REQ_check_private_key 3516 EXIST::FUNCTION:
3093EC_GROUP_get_seed_len 3517 EXIST::FUNCTION:EC 3093EC_GROUP_get_seed_len 3517 EXIST::FUNCTION:EC
3094ERR_load_STORE_strings 3518 EXIST::FUNCTION: 3094ERR_load_STORE_strings 3518 NOEXIST::FUNCTION:
3095PEM_read_bio_EC_PUBKEY 3519 EXIST::FUNCTION:EC 3095PEM_read_bio_EC_PUBKEY 3519 EXIST::FUNCTION:EC
3096STORE_list_private_key_end 3520 EXIST::FUNCTION: 3096STORE_list_private_key_end 3520 NOEXIST::FUNCTION:
3097i2d_EC_PUBKEY 3521 EXIST::FUNCTION:EC 3097i2d_EC_PUBKEY 3521 EXIST::FUNCTION:EC
3098ECDSA_get_default_method 3522 EXIST::FUNCTION:ECDSA 3098ECDSA_get_default_method 3522 EXIST::FUNCTION:ECDSA
3099ASN1_put_eoc 3523 EXIST::FUNCTION: 3099ASN1_put_eoc 3523 EXIST::FUNCTION:
3100X509_STORE_CTX_get_explicit_policy 3524 EXIST:!VMS:FUNCTION: 3100X509_STORE_CTX_get_explicit_policy 3524 EXIST:!VMS:FUNCTION:
3101X509_STORE_CTX_get_expl_policy 3524 EXIST:VMS:FUNCTION: 3101X509_STORE_CTX_get_expl_policy 3524 EXIST:VMS:FUNCTION:
3102X509_VERIFY_PARAM_table_cleanup 3525 EXIST::FUNCTION: 3102X509_VERIFY_PARAM_table_cleanup 3525 EXIST::FUNCTION:
3103STORE_modify_private_key 3526 EXIST::FUNCTION: 3103STORE_modify_private_key 3526 NOEXIST::FUNCTION:
3104X509_VERIFY_PARAM_free 3527 EXIST::FUNCTION: 3104X509_VERIFY_PARAM_free 3527 EXIST::FUNCTION:
3105EC_METHOD_get_field_type 3528 EXIST::FUNCTION:EC 3105EC_METHOD_get_field_type 3528 EXIST::FUNCTION:EC
3106EC_GFp_nist_method 3529 EXIST::FUNCTION:EC 3106EC_GFp_nist_method 3529 EXIST::FUNCTION:EC
3107STORE_method_set_modify_function 3530 EXIST:!VMS:FUNCTION: 3107STORE_meth_set_modify_fn 3530 NOEXIST::FUNCTION:
3108STORE_meth_set_modify_fn 3530 EXIST:VMS:FUNCTION: 3108STORE_method_set_modify_function 3530 NOEXIST::FUNCTION:
3109STORE_parse_attrs_next 3531 EXIST::FUNCTION: 3109STORE_parse_attrs_next 3531 NOEXIST::FUNCTION:
3110ENGINE_load_padlock 3532 EXIST::FUNCTION:ENGINE 3110ENGINE_load_padlock 3532 EXIST::FUNCTION:ENGINE,STATIC_ENGINE
3111EC_GROUP_set_curve_name 3533 EXIST::FUNCTION:EC 3111EC_GROUP_set_curve_name 3533 EXIST::FUNCTION:EC
3112X509_CERT_PAIR_it 3534 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE: 3112X509_CERT_PAIR_it 3534 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:
3113X509_CERT_PAIR_it 3534 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION: 3113X509_CERT_PAIR_it 3534 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:
3114STORE_method_get_revoke_function 3535 EXIST:!VMS:FUNCTION: 3114STORE_meth_get_revoke_fn 3535 NOEXIST::FUNCTION:
3115STORE_meth_get_revoke_fn 3535 EXIST:VMS:FUNCTION: 3115STORE_method_get_revoke_function 3535 NOEXIST::FUNCTION:
3116STORE_method_set_get_function 3536 EXIST::FUNCTION: 3116STORE_method_set_get_function 3536 NOEXIST::FUNCTION:
3117STORE_modify_number 3537 EXIST::FUNCTION: 3117STORE_modify_number 3537 NOEXIST::FUNCTION:
3118STORE_method_get_store_function 3538 EXIST::FUNCTION: 3118STORE_method_get_store_function 3538 NOEXIST::FUNCTION:
3119STORE_store_private_key 3539 EXIST::FUNCTION: 3119STORE_store_private_key 3539 NOEXIST::FUNCTION:
3120BN_GF2m_mod_sqr_arr 3540 EXIST::FUNCTION: 3120BN_GF2m_mod_sqr_arr 3540 EXIST::FUNCTION:
3121RSA_setup_blinding 3541 EXIST::FUNCTION:RSA 3121RSA_setup_blinding 3541 EXIST::FUNCTION:RSA
3122BIO_s_datagram 3542 EXIST::FUNCTION:DGRAM 3122BIO_s_datagram 3542 EXIST::FUNCTION:DGRAM
3123STORE_Memory 3543 EXIST::FUNCTION: 3123STORE_Memory 3543 NOEXIST::FUNCTION:
3124sk_find_ex 3544 EXIST::FUNCTION: 3124sk_find_ex 3544 EXIST::FUNCTION:
3125EC_GROUP_set_curve_GF2m 3545 EXIST::FUNCTION:EC 3125EC_GROUP_set_curve_GF2m 3545 EXIST::FUNCTION:EC
3126ENGINE_set_default_ECDSA 3546 EXIST::FUNCTION:ENGINE 3126ENGINE_set_default_ECDSA 3546 EXIST::FUNCTION:ENGINE
@@ -3128,69 +3128,69 @@ POLICY_CONSTRAINTS_new 3547 EXIST::FUNCTION:
3128BN_GF2m_mod_sqrt 3548 EXIST::FUNCTION: 3128BN_GF2m_mod_sqrt 3548 EXIST::FUNCTION:
3129ECDH_set_default_method 3549 EXIST::FUNCTION:ECDH 3129ECDH_set_default_method 3549 EXIST::FUNCTION:ECDH
3130EC_KEY_generate_key 3550 EXIST::FUNCTION:EC 3130EC_KEY_generate_key 3550 EXIST::FUNCTION:EC
3131SHA384_Update 3551 EXIST::FUNCTION:SHA,SHA512 3131SHA384_Update 3551 EXIST:!VMSVAX:FUNCTION:SHA,SHA512
3132BN_GF2m_arr2poly 3552 EXIST::FUNCTION: 3132BN_GF2m_arr2poly 3552 EXIST::FUNCTION:
3133STORE_method_get_get_function 3553 EXIST::FUNCTION: 3133STORE_method_get_get_function 3553 NOEXIST::FUNCTION:
3134STORE_method_set_cleanup_function 3554 EXIST:!VMS:FUNCTION: 3134STORE_meth_set_cleanup_fn 3554 NOEXIST::FUNCTION:
3135STORE_meth_set_cleanup_fn 3554 EXIST:VMS:FUNCTION: 3135STORE_method_set_cleanup_function 3554 NOEXIST::FUNCTION:
3136EC_GROUP_check 3555 EXIST::FUNCTION:EC 3136EC_GROUP_check 3555 EXIST::FUNCTION:EC
3137d2i_ECPrivateKey_bio 3556 EXIST::FUNCTION:BIO,EC 3137d2i_ECPrivateKey_bio 3556 EXIST::FUNCTION:BIO,EC
3138EC_KEY_insert_key_method_data 3557 EXIST::FUNCTION:EC 3138EC_KEY_insert_key_method_data 3557 EXIST::FUNCTION:EC
3139STORE_method_get_lock_store_function 3558 EXIST:!VMS:FUNCTION: 3139STORE_meth_get_lock_store_fn 3558 NOEXIST::FUNCTION:
3140STORE_meth_get_lock_store_fn 3558 EXIST:VMS:FUNCTION: 3140STORE_method_get_lock_store_function 3558 NOEXIST::FUNCTION:
3141X509_VERIFY_PARAM_get_depth 3559 EXIST::FUNCTION: 3141X509_VERIFY_PARAM_get_depth 3559 EXIST::FUNCTION:
3142SHA224_Final 3560 EXIST::FUNCTION:SHA,SHA256 3142SHA224_Final 3560 EXIST::FUNCTION:SHA,SHA256
3143STORE_method_set_update_store_function 3561 EXIST:!VMS:FUNCTION: 3143STORE_meth_set_update_store_fn 3561 NOEXIST::FUNCTION:
3144STORE_meth_set_update_store_fn 3561 EXIST:VMS:FUNCTION: 3144STORE_method_set_update_store_function 3561 NOEXIST::FUNCTION:
3145SHA224_Update 3562 EXIST::FUNCTION:SHA,SHA256 3145SHA224_Update 3562 EXIST::FUNCTION:SHA,SHA256
3146d2i_ECPrivateKey 3563 EXIST::FUNCTION:EC 3146d2i_ECPrivateKey 3563 EXIST::FUNCTION:EC
3147ASN1_item_ndef_i2d 3564 EXIST::FUNCTION: 3147ASN1_item_ndef_i2d 3564 EXIST::FUNCTION:
3148STORE_delete_private_key 3565 EXIST::FUNCTION: 3148STORE_delete_private_key 3565 NOEXIST::FUNCTION:
3149ERR_pop_to_mark 3566 EXIST::FUNCTION: 3149ERR_pop_to_mark 3566 EXIST::FUNCTION:
3150ENGINE_register_all_STORE 3567 EXIST::FUNCTION:ENGINE 3150ENGINE_register_all_STORE 3567 EXIST::FUNCTION:ENGINE
3151X509_policy_level_get0_node 3568 EXIST::FUNCTION: 3151X509_policy_level_get0_node 3568 EXIST::FUNCTION:
3152i2d_PKCS7_NDEF 3569 EXIST::FUNCTION: 3152i2d_PKCS7_NDEF 3569 EXIST::FUNCTION:
3153EC_GROUP_get_degree 3570 EXIST::FUNCTION:EC 3153EC_GROUP_get_degree 3570 EXIST::FUNCTION:EC
3154ASN1_generate_v3 3571 EXIST::FUNCTION: 3154ASN1_generate_v3 3571 EXIST::FUNCTION:
3155STORE_ATTR_INFO_modify_cstr 3572 EXIST::FUNCTION: 3155STORE_ATTR_INFO_modify_cstr 3572 NOEXIST::FUNCTION:
3156X509_policy_tree_level_count 3573 EXIST::FUNCTION: 3156X509_policy_tree_level_count 3573 EXIST::FUNCTION:
3157BN_GF2m_add 3574 EXIST::FUNCTION: 3157BN_GF2m_add 3574 EXIST::FUNCTION:
3158EC_KEY_get0_group 3575 EXIST::FUNCTION:EC 3158EC_KEY_get0_group 3575 EXIST::FUNCTION:EC
3159STORE_generate_crl 3576 EXIST::FUNCTION: 3159STORE_generate_crl 3576 NOEXIST::FUNCTION:
3160STORE_store_public_key 3577 EXIST::FUNCTION: 3160STORE_store_public_key 3577 NOEXIST::FUNCTION:
3161X509_CERT_PAIR_free 3578 EXIST::FUNCTION: 3161X509_CERT_PAIR_free 3578 EXIST::FUNCTION:
3162STORE_revoke_private_key 3579 EXIST::FUNCTION: 3162STORE_revoke_private_key 3579 NOEXIST::FUNCTION:
3163BN_nist_mod_224 3580 EXIST::FUNCTION: 3163BN_nist_mod_224 3580 EXIST::FUNCTION:
3164SHA512_Final 3581 EXIST::FUNCTION:SHA,SHA512 3164SHA512_Final 3581 EXIST:!VMSVAX:FUNCTION:SHA,SHA512
3165STORE_ATTR_INFO_modify_dn 3582 EXIST::FUNCTION: 3165STORE_ATTR_INFO_modify_dn 3582 NOEXIST::FUNCTION:
3166STORE_method_get_initialise_function 3583 EXIST:!VMS:FUNCTION: 3166STORE_meth_get_initialise_fn 3583 NOEXIST::FUNCTION:
3167STORE_meth_get_initialise_fn 3583 EXIST:VMS:FUNCTION: 3167STORE_method_get_initialise_function 3583 NOEXIST::FUNCTION:
3168STORE_delete_number 3584 EXIST::FUNCTION: 3168STORE_delete_number 3584 NOEXIST::FUNCTION:
3169i2d_EC_PUBKEY_bio 3585 EXIST::FUNCTION:BIO,EC 3169i2d_EC_PUBKEY_bio 3585 EXIST::FUNCTION:BIO,EC
3170BIO_dgram_non_fatal_error 3586 EXIST::FUNCTION: 3170BIO_dgram_non_fatal_error 3586 EXIST::FUNCTION:
3171EC_GROUP_get_asn1_flag 3587 EXIST::FUNCTION:EC 3171EC_GROUP_get_asn1_flag 3587 EXIST::FUNCTION:EC
3172STORE_ATTR_INFO_in_ex 3588 EXIST::FUNCTION: 3172STORE_ATTR_INFO_in_ex 3588 NOEXIST::FUNCTION:
3173STORE_list_crl_start 3589 EXIST::FUNCTION: 3173STORE_list_crl_start 3589 NOEXIST::FUNCTION:
3174ECDH_get_ex_new_index 3590 EXIST::FUNCTION:ECDH 3174ECDH_get_ex_new_index 3590 EXIST::FUNCTION:ECDH
3175STORE_method_get_modify_function 3591 EXIST:!VMS:FUNCTION: 3175STORE_meth_get_modify_fn 3591 NOEXIST::FUNCTION:
3176STORE_meth_get_modify_fn 3591 EXIST:VMS:FUNCTION: 3176STORE_method_get_modify_function 3591 NOEXIST::FUNCTION:
3177v2i_ASN1_BIT_STRING 3592 EXIST::FUNCTION: 3177v2i_ASN1_BIT_STRING 3592 EXIST::FUNCTION:
3178STORE_store_certificate 3593 EXIST::FUNCTION: 3178STORE_store_certificate 3593 NOEXIST::FUNCTION:
3179OBJ_bsearch_ex 3594 EXIST::FUNCTION: 3179OBJ_bsearch_ex 3594 NOEXIST::FUNCTION:
3180X509_STORE_CTX_set_default 3595 EXIST::FUNCTION: 3180X509_STORE_CTX_set_default 3595 EXIST::FUNCTION:
3181STORE_ATTR_INFO_set_sha1str 3596 EXIST::FUNCTION: 3181STORE_ATTR_INFO_set_sha1str 3596 NOEXIST::FUNCTION:
3182BN_GF2m_mod_inv 3597 EXIST::FUNCTION: 3182BN_GF2m_mod_inv 3597 EXIST::FUNCTION:
3183BN_GF2m_mod_exp 3598 EXIST::FUNCTION: 3183BN_GF2m_mod_exp 3598 EXIST::FUNCTION:
3184STORE_modify_public_key 3599 EXIST::FUNCTION: 3184STORE_modify_public_key 3599 NOEXIST::FUNCTION:
3185STORE_method_get_list_start_function 3600 EXIST:!VMS:FUNCTION: 3185STORE_meth_get_list_start_fn 3600 NOEXIST::FUNCTION:
3186STORE_meth_get_list_start_fn 3600 EXIST:VMS:FUNCTION: 3186STORE_method_get_list_start_function 3600 NOEXIST::FUNCTION:
3187EC_GROUP_get0_seed 3601 EXIST::FUNCTION:EC 3187EC_GROUP_get0_seed 3601 EXIST::FUNCTION:EC
3188STORE_store_arbitrary 3602 EXIST::FUNCTION: 3188STORE_store_arbitrary 3602 NOEXIST::FUNCTION:
3189STORE_method_set_unlock_store_function 3603 EXIST:!VMS:FUNCTION: 3189STORE_meth_set_unlock_store_fn 3603 NOEXIST::FUNCTION:
3190STORE_meth_set_unlock_store_fn 3603 EXIST:VMS:FUNCTION: 3190STORE_method_set_unlock_store_function 3603 NOEXIST::FUNCTION:
3191BN_GF2m_mod_div_arr 3604 EXIST::FUNCTION: 3191BN_GF2m_mod_div_arr 3604 EXIST::FUNCTION:
3192ENGINE_set_ECDSA 3605 EXIST::FUNCTION:ENGINE 3192ENGINE_set_ECDSA 3605 EXIST::FUNCTION:ENGINE
3193STORE_create_method 3606 EXIST::FUNCTION: 3193STORE_create_method 3606 NOEXIST::FUNCTION:
3194ECPKParameters_print 3607 EXIST::FUNCTION:BIO,EC 3194ECPKParameters_print 3607 EXIST::FUNCTION:BIO,EC
3195EC_KEY_get0_private_key 3608 EXIST::FUNCTION:EC 3195EC_KEY_get0_private_key 3608 EXIST::FUNCTION:EC
3196PEM_write_EC_PUBKEY 3609 EXIST:!WIN16:FUNCTION:EC 3196PEM_write_EC_PUBKEY 3609 EXIST:!WIN16:FUNCTION:EC
@@ -3198,7 +3198,7 @@ X509_VERIFY_PARAM_set1 3610 EXIST::FUNCTION:
3198ECDH_set_method 3611 EXIST::FUNCTION:ECDH 3198ECDH_set_method 3611 EXIST::FUNCTION:ECDH
3199v2i_GENERAL_NAME_ex 3612 EXIST::FUNCTION: 3199v2i_GENERAL_NAME_ex 3612 EXIST::FUNCTION:
3200ECDH_set_ex_data 3613 EXIST::FUNCTION:ECDH 3200ECDH_set_ex_data 3613 EXIST::FUNCTION:ECDH
3201STORE_generate_key 3614 EXIST::FUNCTION: 3201STORE_generate_key 3614 NOEXIST::FUNCTION:
3202BN_nist_mod_521 3615 EXIST::FUNCTION: 3202BN_nist_mod_521 3615 EXIST::FUNCTION:
3203X509_policy_tree_get0_level 3616 EXIST::FUNCTION: 3203X509_policy_tree_get0_level 3616 EXIST::FUNCTION:
3204EC_GROUP_set_point_conversion_form 3617 EXIST:!VMS:FUNCTION:EC 3204EC_GROUP_set_point_conversion_form 3617 EXIST:!VMS:FUNCTION:EC
@@ -3206,7 +3206,7 @@ EC_GROUP_set_point_conv_form 3617 EXIST:VMS:FUNCTION:EC
3206PEM_read_EC_PUBKEY 3618 EXIST:!WIN16:FUNCTION:EC 3206PEM_read_EC_PUBKEY 3618 EXIST:!WIN16:FUNCTION:EC
3207i2d_ECDSA_SIG 3619 EXIST::FUNCTION:ECDSA 3207i2d_ECDSA_SIG 3619 EXIST::FUNCTION:ECDSA
3208ECDSA_OpenSSL 3620 EXIST::FUNCTION:ECDSA 3208ECDSA_OpenSSL 3620 EXIST::FUNCTION:ECDSA
3209STORE_delete_crl 3621 EXIST::FUNCTION: 3209STORE_delete_crl 3621 NOEXIST::FUNCTION:
3210EC_KEY_get_enc_flags 3622 EXIST::FUNCTION:EC 3210EC_KEY_get_enc_flags 3622 EXIST::FUNCTION:EC
3211ASN1_const_check_infinite_end 3623 EXIST::FUNCTION: 3211ASN1_const_check_infinite_end 3623 EXIST::FUNCTION:
3212EVP_PKEY_delete_attr 3624 EXIST::FUNCTION: 3212EVP_PKEY_delete_attr 3624 EXIST::FUNCTION:
@@ -3214,31 +3214,31 @@ ECDSA_set_default_method 3625 EXIST::FUNCTION:ECDSA
3214EC_POINT_set_compressed_coordinates_GF2m 3626 EXIST:!VMS:FUNCTION:EC 3214EC_POINT_set_compressed_coordinates_GF2m 3626 EXIST:!VMS:FUNCTION:EC
3215EC_POINT_set_compr_coords_GF2m 3626 EXIST:VMS:FUNCTION:EC 3215EC_POINT_set_compr_coords_GF2m 3626 EXIST:VMS:FUNCTION:EC
3216EC_GROUP_cmp 3627 EXIST::FUNCTION:EC 3216EC_GROUP_cmp 3627 EXIST::FUNCTION:EC
3217STORE_revoke_certificate 3628 EXIST::FUNCTION: 3217STORE_revoke_certificate 3628 NOEXIST::FUNCTION:
3218BN_get0_nist_prime_256 3629 EXIST::FUNCTION: 3218BN_get0_nist_prime_256 3629 EXIST::FUNCTION:
3219STORE_method_get_delete_function 3630 EXIST:!VMS:FUNCTION: 3219STORE_meth_get_delete_fn 3630 NOEXIST::FUNCTION:
3220STORE_meth_get_delete_fn 3630 EXIST:VMS:FUNCTION: 3220STORE_method_get_delete_function 3630 NOEXIST::FUNCTION:
3221SHA224_Init 3631 EXIST::FUNCTION:SHA,SHA256 3221SHA224_Init 3631 EXIST::FUNCTION:SHA,SHA256
3222PEM_read_ECPrivateKey 3632 EXIST:!WIN16:FUNCTION:EC 3222PEM_read_ECPrivateKey 3632 EXIST:!WIN16:FUNCTION:EC
3223SHA512_Init 3633 EXIST::FUNCTION:SHA,SHA512 3223SHA512_Init 3633 EXIST:!VMSVAX:FUNCTION:SHA,SHA512
3224STORE_parse_attrs_endp 3634 EXIST::FUNCTION: 3224STORE_parse_attrs_endp 3634 NOEXIST::FUNCTION:
3225BN_set_negative 3635 EXIST::FUNCTION: 3225BN_set_negative 3635 EXIST::FUNCTION:
3226ERR_load_ECDSA_strings 3636 EXIST::FUNCTION:ECDSA 3226ERR_load_ECDSA_strings 3636 EXIST::FUNCTION:ECDSA
3227EC_GROUP_get_basis_type 3637 EXIST::FUNCTION:EC 3227EC_GROUP_get_basis_type 3637 EXIST::FUNCTION:EC
3228STORE_list_public_key_next 3638 EXIST::FUNCTION: 3228STORE_list_public_key_next 3638 NOEXIST::FUNCTION:
3229i2v_ASN1_BIT_STRING 3639 EXIST::FUNCTION: 3229i2v_ASN1_BIT_STRING 3639 EXIST::FUNCTION:
3230STORE_OBJECT_free 3640 EXIST::FUNCTION: 3230STORE_OBJECT_free 3640 NOEXIST::FUNCTION:
3231BN_nist_mod_384 3641 EXIST::FUNCTION: 3231BN_nist_mod_384 3641 EXIST::FUNCTION:
3232i2d_X509_CERT_PAIR 3642 EXIST::FUNCTION: 3232i2d_X509_CERT_PAIR 3642 EXIST::FUNCTION:
3233PEM_write_ECPKParameters 3643 EXIST:!WIN16:FUNCTION:EC 3233PEM_write_ECPKParameters 3643 EXIST:!WIN16:FUNCTION:EC
3234ECDH_compute_key 3644 EXIST::FUNCTION:ECDH 3234ECDH_compute_key 3644 EXIST::FUNCTION:ECDH
3235STORE_ATTR_INFO_get0_sha1str 3645 EXIST::FUNCTION: 3235STORE_ATTR_INFO_get0_sha1str 3645 NOEXIST::FUNCTION:
3236ENGINE_register_all_ECDH 3646 EXIST::FUNCTION:ENGINE 3236ENGINE_register_all_ECDH 3646 EXIST::FUNCTION:ENGINE
3237pqueue_pop 3647 EXIST::FUNCTION: 3237pqueue_pop 3647 EXIST::FUNCTION:
3238STORE_ATTR_INFO_get0_cstr 3648 EXIST::FUNCTION: 3238STORE_ATTR_INFO_get0_cstr 3648 NOEXIST::FUNCTION:
3239POLICY_CONSTRAINTS_it 3649 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE: 3239POLICY_CONSTRAINTS_it 3649 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:
3240POLICY_CONSTRAINTS_it 3649 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION: 3240POLICY_CONSTRAINTS_it 3649 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:
3241STORE_get_ex_new_index 3650 EXIST::FUNCTION: 3241STORE_get_ex_new_index 3650 NOEXIST::FUNCTION:
3242EVP_PKEY_get_attr_by_OBJ 3651 EXIST::FUNCTION: 3242EVP_PKEY_get_attr_by_OBJ 3651 EXIST::FUNCTION:
3243X509_VERIFY_PARAM_add0_policy 3652 EXIST::FUNCTION: 3243X509_VERIFY_PARAM_add0_policy 3652 EXIST::FUNCTION:
3244BN_GF2m_mod_solve_quad 3653 EXIST::FUNCTION: 3244BN_GF2m_mod_solve_quad 3653 EXIST::FUNCTION:
@@ -3259,20 +3259,20 @@ EC_KEY_set_enc_flags 3665 EXIST::FUNCTION:EC
3259ECDSA_verify 3666 EXIST::FUNCTION:ECDSA 3259ECDSA_verify 3666 EXIST::FUNCTION:ECDSA
3260EC_POINT_point2hex 3667 EXIST::FUNCTION:EC 3260EC_POINT_point2hex 3667 EXIST::FUNCTION:EC
3261ENGINE_get_STORE 3668 EXIST::FUNCTION:ENGINE 3261ENGINE_get_STORE 3668 EXIST::FUNCTION:ENGINE
3262SHA512 3669 EXIST::FUNCTION:SHA,SHA512 3262SHA512 3669 EXIST:!VMSVAX:FUNCTION:SHA,SHA512
3263STORE_get_certificate 3670 EXIST::FUNCTION: 3263STORE_get_certificate 3670 NOEXIST::FUNCTION:
3264ECDSA_do_sign_ex 3671 EXIST::FUNCTION:ECDSA 3264ECDSA_do_sign_ex 3671 EXIST::FUNCTION:ECDSA
3265ECDSA_do_verify 3672 EXIST::FUNCTION:ECDSA 3265ECDSA_do_verify 3672 EXIST::FUNCTION:ECDSA
3266d2i_ECPrivateKey_fp 3673 EXIST::FUNCTION:EC,FP_API 3266d2i_ECPrivateKey_fp 3673 EXIST::FUNCTION:EC,FP_API
3267STORE_delete_certificate 3674 EXIST::FUNCTION: 3267STORE_delete_certificate 3674 NOEXIST::FUNCTION:
3268SHA512_Transform 3675 EXIST::FUNCTION:SHA,SHA512 3268SHA512_Transform 3675 EXIST:!VMSVAX:FUNCTION:SHA,SHA512
3269X509_STORE_set1_param 3676 EXIST::FUNCTION: 3269X509_STORE_set1_param 3676 EXIST::FUNCTION:
3270STORE_method_get_ctrl_function 3677 EXIST::FUNCTION: 3270STORE_method_get_ctrl_function 3677 NOEXIST::FUNCTION:
3271STORE_free 3678 EXIST::FUNCTION: 3271STORE_free 3678 NOEXIST::FUNCTION:
3272PEM_write_ECPrivateKey 3679 EXIST:!WIN16:FUNCTION:EC 3272PEM_write_ECPrivateKey 3679 EXIST:!WIN16:FUNCTION:EC
3273STORE_method_get_unlock_store_function 3680 EXIST:!VMS:FUNCTION: 3273STORE_meth_get_unlock_store_fn 3680 NOEXIST::FUNCTION:
3274STORE_meth_get_unlock_store_fn 3680 EXIST:VMS:FUNCTION: 3274STORE_method_get_unlock_store_function 3680 NOEXIST::FUNCTION:
3275STORE_get_ex_data 3681 EXIST::FUNCTION: 3275STORE_get_ex_data 3681 NOEXIST::FUNCTION:
3276EC_KEY_set_public_key 3682 EXIST::FUNCTION:EC 3276EC_KEY_set_public_key 3682 EXIST::FUNCTION:EC
3277PEM_read_ECPKParameters 3683 EXIST:!WIN16:FUNCTION:EC 3277PEM_read_ECPKParameters 3683 EXIST:!WIN16:FUNCTION:EC
3278X509_CERT_PAIR_new 3684 EXIST::FUNCTION: 3278X509_CERT_PAIR_new 3684 EXIST::FUNCTION:
@@ -3282,8 +3282,8 @@ DSA_generate_parameters_ex 3687 EXIST::FUNCTION:DSA
3282ECParameters_print_fp 3688 EXIST::FUNCTION:EC,FP_API 3282ECParameters_print_fp 3688 EXIST::FUNCTION:EC,FP_API
3283X509V3_NAME_from_section 3689 EXIST::FUNCTION: 3283X509V3_NAME_from_section 3689 EXIST::FUNCTION:
3284EVP_PKEY_add1_attr 3690 EXIST::FUNCTION: 3284EVP_PKEY_add1_attr 3690 EXIST::FUNCTION:
3285STORE_modify_crl 3691 EXIST::FUNCTION: 3285STORE_modify_crl 3691 NOEXIST::FUNCTION:
3286STORE_list_private_key_start 3692 EXIST::FUNCTION: 3286STORE_list_private_key_start 3692 NOEXIST::FUNCTION:
3287POLICY_MAPPINGS_it 3693 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE: 3287POLICY_MAPPINGS_it 3693 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:
3288POLICY_MAPPINGS_it 3693 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION: 3288POLICY_MAPPINGS_it 3693 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:
3289GENERAL_SUBTREE_it 3694 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE: 3289GENERAL_SUBTREE_it 3694 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:
@@ -3292,7 +3292,7 @@ EC_GROUP_get_curve_name 3695 EXIST::FUNCTION:EC
3292PEM_write_X509_CERT_PAIR 3696 EXIST:!WIN16:FUNCTION: 3292PEM_write_X509_CERT_PAIR 3696 EXIST:!WIN16:FUNCTION:
3293BIO_dump_indent_cb 3697 EXIST::FUNCTION: 3293BIO_dump_indent_cb 3697 EXIST::FUNCTION:
3294d2i_X509_CERT_PAIR 3698 EXIST::FUNCTION: 3294d2i_X509_CERT_PAIR 3698 EXIST::FUNCTION:
3295STORE_list_private_key_endp 3699 EXIST::FUNCTION: 3295STORE_list_private_key_endp 3699 NOEXIST::FUNCTION:
3296asn1_const_Finish 3700 EXIST::FUNCTION: 3296asn1_const_Finish 3700 EXIST::FUNCTION:
3297i2d_EC_PUBKEY_fp 3701 EXIST::FUNCTION:EC,FP_API 3297i2d_EC_PUBKEY_fp 3701 EXIST::FUNCTION:EC,FP_API
3298BN_nist_mod_256 3702 EXIST::FUNCTION: 3298BN_nist_mod_256 3702 EXIST::FUNCTION:
@@ -3302,47 +3302,47 @@ BN_BLINDING_create_param 3705 EXIST::FUNCTION:
3302ECDSA_size 3706 EXIST::FUNCTION:ECDSA 3302ECDSA_size 3706 EXIST::FUNCTION:ECDSA
3303d2i_EC_PUBKEY_bio 3707 EXIST::FUNCTION:BIO,EC 3303d2i_EC_PUBKEY_bio 3707 EXIST::FUNCTION:BIO,EC
3304BN_get0_nist_prime_521 3708 EXIST::FUNCTION: 3304BN_get0_nist_prime_521 3708 EXIST::FUNCTION:
3305STORE_ATTR_INFO_modify_sha1str 3709 EXIST::FUNCTION: 3305STORE_ATTR_INFO_modify_sha1str 3709 NOEXIST::FUNCTION:
3306BN_generate_prime_ex 3710 EXIST::FUNCTION: 3306BN_generate_prime_ex 3710 EXIST::FUNCTION:
3307EC_GROUP_new_by_curve_name 3711 EXIST::FUNCTION:EC 3307EC_GROUP_new_by_curve_name 3711 EXIST::FUNCTION:EC
3308SHA256_Final 3712 EXIST::FUNCTION:SHA,SHA256 3308SHA256_Final 3712 EXIST::FUNCTION:SHA,SHA256
3309DH_generate_parameters_ex 3713 EXIST::FUNCTION:DH 3309DH_generate_parameters_ex 3713 EXIST::FUNCTION:DH
3310PEM_read_bio_ECPrivateKey 3714 EXIST::FUNCTION:EC 3310PEM_read_bio_ECPrivateKey 3714 EXIST::FUNCTION:EC
3311STORE_method_get_cleanup_function 3715 EXIST:!VMS:FUNCTION: 3311STORE_meth_get_cleanup_fn 3715 NOEXIST::FUNCTION:
3312STORE_meth_get_cleanup_fn 3715 EXIST:VMS:FUNCTION: 3312STORE_method_get_cleanup_function 3715 NOEXIST::FUNCTION:
3313ENGINE_get_ECDH 3716 EXIST::FUNCTION:ENGINE 3313ENGINE_get_ECDH 3716 EXIST::FUNCTION:ENGINE
3314d2i_ECDSA_SIG 3717 EXIST::FUNCTION:ECDSA 3314d2i_ECDSA_SIG 3717 EXIST::FUNCTION:ECDSA
3315BN_is_prime_fasttest_ex 3718 EXIST::FUNCTION: 3315BN_is_prime_fasttest_ex 3718 EXIST::FUNCTION:
3316ECDSA_sign 3719 EXIST::FUNCTION:ECDSA 3316ECDSA_sign 3719 EXIST::FUNCTION:ECDSA
3317X509_policy_check 3720 EXIST::FUNCTION: 3317X509_policy_check 3720 EXIST::FUNCTION:
3318EVP_PKEY_get_attr_by_NID 3721 EXIST::FUNCTION: 3318EVP_PKEY_get_attr_by_NID 3721 EXIST::FUNCTION:
3319STORE_set_ex_data 3722 EXIST::FUNCTION: 3319STORE_set_ex_data 3722 NOEXIST::FUNCTION:
3320ENGINE_get_ECDSA 3723 EXIST::FUNCTION:ENGINE 3320ENGINE_get_ECDSA 3723 EXIST::FUNCTION:ENGINE
3321EVP_ecdsa 3724 EXIST::FUNCTION:SHA 3321EVP_ecdsa 3724 EXIST::FUNCTION:SHA
3322BN_BLINDING_get_flags 3725 EXIST::FUNCTION: 3322BN_BLINDING_get_flags 3725 EXIST::FUNCTION:
3323PKCS12_add_cert 3726 EXIST::FUNCTION: 3323PKCS12_add_cert 3726 EXIST::FUNCTION:
3324STORE_OBJECT_new 3727 EXIST::FUNCTION: 3324STORE_OBJECT_new 3727 NOEXIST::FUNCTION:
3325ERR_load_ECDH_strings 3728 EXIST::FUNCTION:ECDH 3325ERR_load_ECDH_strings 3728 EXIST::FUNCTION:ECDH
3326EC_KEY_dup 3729 EXIST::FUNCTION:EC 3326EC_KEY_dup 3729 EXIST::FUNCTION:EC
3327EVP_CIPHER_CTX_rand_key 3730 EXIST::FUNCTION: 3327EVP_CIPHER_CTX_rand_key 3730 EXIST::FUNCTION:
3328ECDSA_set_method 3731 EXIST::FUNCTION:ECDSA 3328ECDSA_set_method 3731 EXIST::FUNCTION:ECDSA
3329a2i_IPADDRESS_NC 3732 EXIST::FUNCTION: 3329a2i_IPADDRESS_NC 3732 EXIST::FUNCTION:
3330d2i_ECParameters 3733 EXIST::FUNCTION:EC 3330d2i_ECParameters 3733 EXIST::FUNCTION:EC
3331STORE_list_certificate_end 3734 EXIST::FUNCTION: 3331STORE_list_certificate_end 3734 NOEXIST::FUNCTION:
3332STORE_get_crl 3735 EXIST::FUNCTION: 3332STORE_get_crl 3735 NOEXIST::FUNCTION:
3333X509_POLICY_NODE_print 3736 EXIST::FUNCTION: 3333X509_POLICY_NODE_print 3736 EXIST::FUNCTION:
3334SHA384_Init 3737 EXIST::FUNCTION:SHA,SHA512 3334SHA384_Init 3737 EXIST:!VMSVAX:FUNCTION:SHA,SHA512
3335EC_GF2m_simple_method 3738 EXIST::FUNCTION:EC 3335EC_GF2m_simple_method 3738 EXIST::FUNCTION:EC
3336ECDSA_set_ex_data 3739 EXIST::FUNCTION:ECDSA 3336ECDSA_set_ex_data 3739 EXIST::FUNCTION:ECDSA
3337SHA384_Final 3740 EXIST::FUNCTION:SHA,SHA512 3337SHA384_Final 3740 EXIST:!VMSVAX:FUNCTION:SHA,SHA512
3338PKCS7_set_digest 3741 EXIST::FUNCTION: 3338PKCS7_set_digest 3741 EXIST::FUNCTION:
3339EC_KEY_print 3742 EXIST::FUNCTION:BIO,EC 3339EC_KEY_print 3742 EXIST::FUNCTION:BIO,EC
3340STORE_method_set_lock_store_function 3743 EXIST:!VMS:FUNCTION: 3340STORE_meth_set_lock_store_fn 3743 NOEXIST::FUNCTION:
3341STORE_meth_set_lock_store_fn 3743 EXIST:VMS:FUNCTION: 3341STORE_method_set_lock_store_function 3743 NOEXIST::FUNCTION:
3342ECDSA_get_ex_new_index 3744 EXIST::FUNCTION:ECDSA 3342ECDSA_get_ex_new_index 3744 EXIST::FUNCTION:ECDSA
3343SHA384 3745 EXIST::FUNCTION:SHA,SHA512 3343SHA384 3745 EXIST:!VMSVAX:FUNCTION:SHA,SHA512
3344POLICY_MAPPING_new 3746 EXIST::FUNCTION: 3344POLICY_MAPPING_new 3746 EXIST::FUNCTION:
3345STORE_list_certificate_endp 3747 EXIST::FUNCTION: 3345STORE_list_certificate_endp 3747 NOEXIST::FUNCTION:
3346X509_STORE_CTX_get0_policy_tree 3748 EXIST::FUNCTION: 3346X509_STORE_CTX_get0_policy_tree 3748 EXIST::FUNCTION:
3347EC_GROUP_set_asn1_flag 3749 EXIST::FUNCTION:EC 3347EC_GROUP_set_asn1_flag 3749 EXIST::FUNCTION:EC
3348EC_KEY_check_key 3750 EXIST::FUNCTION:EC 3348EC_KEY_check_key 3750 EXIST::FUNCTION:EC
@@ -3350,13 +3350,13 @@ d2i_EC_PUBKEY_fp 3751 EXIST::FUNCTION:EC,FP_API
3350PKCS7_set0_type_other 3752 EXIST::FUNCTION: 3350PKCS7_set0_type_other 3752 EXIST::FUNCTION:
3351PEM_read_bio_X509_CERT_PAIR 3753 EXIST::FUNCTION: 3351PEM_read_bio_X509_CERT_PAIR 3753 EXIST::FUNCTION:
3352pqueue_next 3754 EXIST::FUNCTION: 3352pqueue_next 3754 EXIST::FUNCTION:
3353STORE_method_get_list_end_function 3755 EXIST:!VMS:FUNCTION: 3353STORE_meth_get_list_end_fn 3755 NOEXIST::FUNCTION:
3354STORE_meth_get_list_end_fn 3755 EXIST:VMS:FUNCTION: 3354STORE_method_get_list_end_function 3755 NOEXIST::FUNCTION:
3355EVP_PKEY_add1_attr_by_OBJ 3756 EXIST::FUNCTION: 3355EVP_PKEY_add1_attr_by_OBJ 3756 EXIST::FUNCTION:
3356X509_VERIFY_PARAM_set_time 3757 EXIST::FUNCTION: 3356X509_VERIFY_PARAM_set_time 3757 EXIST::FUNCTION:
3357pqueue_new 3758 EXIST::FUNCTION: 3357pqueue_new 3758 EXIST::FUNCTION:
3358ENGINE_set_default_ECDH 3759 EXIST::FUNCTION:ENGINE 3358ENGINE_set_default_ECDH 3759 EXIST::FUNCTION:ENGINE
3359STORE_new_method 3760 EXIST::FUNCTION: 3359STORE_new_method 3760 NOEXIST::FUNCTION:
3360PKCS12_add_key 3761 EXIST::FUNCTION: 3360PKCS12_add_key 3761 EXIST::FUNCTION:
3361DSO_merge 3762 EXIST::FUNCTION: 3361DSO_merge 3762 EXIST::FUNCTION:
3362EC_POINT_hex2point 3763 EXIST::FUNCTION:EC 3362EC_POINT_hex2point 3763 EXIST::FUNCTION:EC
@@ -3366,7 +3366,7 @@ pqueue_insert 3766 EXIST::FUNCTION:
3366pitem_free 3767 EXIST::FUNCTION: 3366pitem_free 3767 EXIST::FUNCTION:
3367BN_GF2m_mod_inv_arr 3768 EXIST::FUNCTION: 3367BN_GF2m_mod_inv_arr 3768 EXIST::FUNCTION:
3368ENGINE_unregister_ECDSA 3769 EXIST::FUNCTION:ENGINE 3368ENGINE_unregister_ECDSA 3769 EXIST::FUNCTION:ENGINE
3369BN_BLINDING_set_thread_id 3770 EXIST::FUNCTION: 3369BN_BLINDING_set_thread_id 3770 EXIST::FUNCTION:DEPRECATED
3370get_rfc3526_prime_8192 3771 EXIST::FUNCTION: 3370get_rfc3526_prime_8192 3771 EXIST::FUNCTION:
3371X509_VERIFY_PARAM_clear_flags 3772 EXIST::FUNCTION: 3371X509_VERIFY_PARAM_clear_flags 3772 EXIST::FUNCTION:
3372get_rfc2409_prime_1024 3773 EXIST::FUNCTION: 3372get_rfc2409_prime_1024 3773 EXIST::FUNCTION:
@@ -3385,7 +3385,7 @@ Camellia_cfb128_encrypt 3785 EXIST::FUNCTION:CAMELLIA
3385Camellia_cfb1_encrypt 3786 EXIST::FUNCTION:CAMELLIA 3385Camellia_cfb1_encrypt 3786 EXIST::FUNCTION:CAMELLIA
3386Camellia_cfb8_encrypt 3787 EXIST::FUNCTION:CAMELLIA 3386Camellia_cfb8_encrypt 3787 EXIST::FUNCTION:CAMELLIA
3387Camellia_ctr128_encrypt 3788 EXIST::FUNCTION:CAMELLIA 3387Camellia_ctr128_encrypt 3788 EXIST::FUNCTION:CAMELLIA
3388Camellia_cfbr_encrypt_block 3789 EXIST::FUNCTION:CAMELLIA 3388Camellia_cfbr_encrypt_block 3789 NOEXIST::FUNCTION:
3389Camellia_decrypt 3790 EXIST::FUNCTION:CAMELLIA 3389Camellia_decrypt 3790 EXIST::FUNCTION:CAMELLIA
3390Camellia_ecb_encrypt 3791 EXIST::FUNCTION:CAMELLIA 3390Camellia_ecb_encrypt 3791 EXIST::FUNCTION:CAMELLIA
3391Camellia_encrypt 3792 EXIST::FUNCTION:CAMELLIA 3391Camellia_encrypt 3792 EXIST::FUNCTION:CAMELLIA
@@ -3585,7 +3585,7 @@ CMS_data_create 3975 EXIST::FUNCTION:CMS
3585i2d_CMS_bio 3976 EXIST::FUNCTION:CMS 3585i2d_CMS_bio 3976 EXIST::FUNCTION:CMS
3586CMS_EncryptedData_set1_key 3977 EXIST::FUNCTION:CMS 3586CMS_EncryptedData_set1_key 3977 EXIST::FUNCTION:CMS
3587CMS_decrypt 3978 EXIST::FUNCTION:CMS 3587CMS_decrypt 3978 EXIST::FUNCTION:CMS
3588int_smime_write_ASN1 3979 EXIST::FUNCTION: 3588int_smime_write_ASN1 3979 NOEXIST::FUNCTION:
3589CMS_unsigned_delete_attr 3980 EXIST::FUNCTION:CMS 3589CMS_unsigned_delete_attr 3980 EXIST::FUNCTION:CMS
3590CMS_unsigned_get_attr_count 3981 EXIST::FUNCTION:CMS 3590CMS_unsigned_get_attr_count 3981 EXIST::FUNCTION:CMS
3591CMS_add_smimecap 3982 EXIST::FUNCTION:CMS 3591CMS_add_smimecap 3982 EXIST::FUNCTION:CMS
@@ -3657,53 +3657,52 @@ ENGINE_set_ld_ssl_clnt_cert_fn 4044 EXIST:VMS:FUNCTION:ENGINE
3657ENGINE_get_ssl_client_cert_function 4045 EXIST:!VMS:FUNCTION:ENGINE 3657ENGINE_get_ssl_client_cert_function 4045 EXIST:!VMS:FUNCTION:ENGINE
3658ENGINE_get_ssl_client_cert_fn 4045 EXIST:VMS:FUNCTION:ENGINE 3658ENGINE_get_ssl_client_cert_fn 4045 EXIST:VMS:FUNCTION:ENGINE
3659ENGINE_load_ssl_client_cert 4046 EXIST::FUNCTION:ENGINE 3659ENGINE_load_ssl_client_cert 4046 EXIST::FUNCTION:ENGINE
3660ENGINE_load_capi 4047 EXIST::FUNCTION:CAPIENG,ENGINE 3660ENGINE_load_capi 4047 EXIST::FUNCTION:ENGINE,STATIC_ENGINE
3661OPENSSL_isservice 4048 EXIST::FUNCTION: 3661OPENSSL_isservice 4048 EXIST::FUNCTION:
3662FIPS_dsa_sig_decode 4049 EXIST:OPENSSL_FIPS:FUNCTION:DSA 3662FIPS_dsa_sig_decode 4049 NOEXIST::FUNCTION:
3663EVP_CIPHER_CTX_clear_flags 4050 EXIST::FUNCTION: 3663EVP_CIPHER_CTX_clear_flags 4050 EXIST::FUNCTION:
3664FIPS_rand_status 4051 EXIST:OPENSSL_FIPS:FUNCTION: 3664FIPS_rand_status 4051 NOEXIST::FUNCTION:
3665FIPS_rand_set_key 4052 EXIST:OPENSSL_FIPS:FUNCTION: 3665FIPS_rand_set_key 4052 NOEXIST::FUNCTION:
3666CRYPTO_set_mem_info_functions 4053 EXIST::FUNCTION: 3666CRYPTO_set_mem_info_functions 4053 NOEXIST::FUNCTION:
3667RSA_X931_generate_key_ex 4054 EXIST::FUNCTION:RSA 3667RSA_X931_generate_key_ex 4054 NOEXIST::FUNCTION:
3668int_ERR_set_state_func 4055 EXIST:OPENSSL_FIPS:FUNCTION: 3668int_ERR_set_state_func 4055 NOEXIST::FUNCTION:
3669int_EVP_MD_set_engine_callbacks 4056 EXIST:OPENSSL_FIPS:FUNCTION:ENGINE 3669int_EVP_MD_set_engine_callbacks 4056 NOEXIST::FUNCTION:
3670int_CRYPTO_set_do_dynlock_callback 4057 EXIST:!VMS:FUNCTION: 3670int_CRYPTO_set_do_dynlock_callback 4057 NOEXIST::FUNCTION:
3671int_CRYPTO_set_do_dynlock_cb 4057 EXIST:VMS:FUNCTION: 3671FIPS_rng_stick 4058 NOEXIST::FUNCTION:
3672FIPS_rng_stick 4058 EXIST:OPENSSL_FIPS:FUNCTION:
3673EVP_CIPHER_CTX_set_flags 4059 EXIST::FUNCTION: 3672EVP_CIPHER_CTX_set_flags 4059 EXIST::FUNCTION:
3674BN_X931_generate_prime_ex 4060 EXIST::FUNCTION: 3673BN_X931_generate_prime_ex 4060 NOEXIST::FUNCTION:
3675FIPS_selftest_check 4061 EXIST:OPENSSL_FIPS:FUNCTION: 3674FIPS_selftest_check 4061 NOEXIST::FUNCTION:
3676FIPS_rand_set_dt 4062 EXIST:OPENSSL_FIPS:FUNCTION: 3675FIPS_rand_set_dt 4062 NOEXIST::FUNCTION:
3677CRYPTO_dbg_pop_info 4063 EXIST::FUNCTION: 3676CRYPTO_dbg_pop_info 4063 NOEXIST::FUNCTION:
3678FIPS_dsa_free 4064 EXIST:OPENSSL_FIPS:FUNCTION:DSA 3677FIPS_dsa_free 4064 NOEXIST::FUNCTION:
3679RSA_X931_derive_ex 4065 EXIST::FUNCTION:RSA 3678RSA_X931_derive_ex 4065 NOEXIST::FUNCTION:
3680FIPS_rsa_new 4066 EXIST:OPENSSL_FIPS:FUNCTION:RSA 3679FIPS_rsa_new 4066 NOEXIST::FUNCTION:
3681FIPS_rand_bytes 4067 EXIST:OPENSSL_FIPS:FUNCTION: 3680FIPS_rand_bytes 4067 NOEXIST::FUNCTION:
3682fips_cipher_test 4068 EXIST:OPENSSL_FIPS:FUNCTION: 3681fips_cipher_test 4068 NOEXIST::FUNCTION:
3683EVP_CIPHER_CTX_test_flags 4069 EXIST::FUNCTION: 3682EVP_CIPHER_CTX_test_flags 4069 EXIST::FUNCTION:
3684CRYPTO_malloc_debug_init 4070 EXIST::FUNCTION: 3683CRYPTO_malloc_debug_init 4070 NOEXIST::FUNCTION:
3685CRYPTO_dbg_push_info 4071 EXIST::FUNCTION: 3684CRYPTO_dbg_push_info 4071 NOEXIST::FUNCTION:
3686FIPS_corrupt_rsa_keygen 4072 EXIST:OPENSSL_FIPS:FUNCTION: 3685FIPS_corrupt_rsa_keygen 4072 NOEXIST::FUNCTION:
3687FIPS_dh_new 4073 EXIST:OPENSSL_FIPS:FUNCTION:DH 3686FIPS_dh_new 4073 NOEXIST::FUNCTION:
3688FIPS_corrupt_dsa_keygen 4074 EXIST:OPENSSL_FIPS:FUNCTION: 3687FIPS_corrupt_dsa_keygen 4074 NOEXIST::FUNCTION:
3689FIPS_dh_free 4075 EXIST:OPENSSL_FIPS:FUNCTION:DH 3688FIPS_dh_free 4075 NOEXIST::FUNCTION:
3690fips_pkey_signature_test 4076 EXIST:OPENSSL_FIPS:FUNCTION: 3689fips_pkey_signature_test 4076 NOEXIST::FUNCTION:
3691EVP_add_alg_module 4077 EXIST::FUNCTION: 3690EVP_add_alg_module 4077 NOEXIST::FUNCTION:
3692int_RAND_init_engine_callbacks 4078 EXIST:OPENSSL_FIPS:FUNCTION:ENGINE 3691int_RAND_init_engine_callbacks 4078 NOEXIST::FUNCTION:
3693int_EVP_CIPHER_set_engine_callbacks 4079 EXIST:OPENSSL_FIPS:FUNCTION:ENGINE 3692int_EVP_CIPHER_set_engine_callbacks 4079 NOEXIST::FUNCTION:
3694int_EVP_MD_init_engine_callbacks 4080 EXIST:OPENSSL_FIPS:FUNCTION:ENGINE 3693int_EVP_MD_init_engine_callbacks 4080 NOEXIST::FUNCTION:
3695FIPS_rand_test_mode 4081 EXIST:OPENSSL_FIPS:FUNCTION: 3694FIPS_rand_test_mode 4081 NOEXIST::FUNCTION:
3696FIPS_rand_reset 4082 EXIST:OPENSSL_FIPS:FUNCTION: 3695FIPS_rand_reset 4082 NOEXIST::FUNCTION:
3697FIPS_dsa_new 4083 EXIST:OPENSSL_FIPS:FUNCTION:DSA 3696FIPS_dsa_new 4083 NOEXIST::FUNCTION:
3698int_RAND_set_callbacks 4084 EXIST:OPENSSL_FIPS:FUNCTION:ENGINE 3697int_RAND_set_callbacks 4084 NOEXIST::FUNCTION:
3699BN_X931_derive_prime_ex 4085 EXIST::FUNCTION: 3698BN_X931_derive_prime_ex 4085 NOEXIST::FUNCTION:
3700int_ERR_lib_init 4086 EXIST:OPENSSL_FIPS:FUNCTION: 3699int_ERR_lib_init 4086 NOEXIST::FUNCTION:
3701int_EVP_CIPHER_init_engine_callbacks 4087 EXIST:OPENSSL_FIPS:FUNCTION:ENGINE 3700int_EVP_CIPHER_init_engine_callbacks 4087 NOEXIST::FUNCTION:
3702FIPS_rsa_free 4088 EXIST:OPENSSL_FIPS:FUNCTION:RSA 3701FIPS_rsa_free 4088 NOEXIST::FUNCTION:
3703FIPS_dsa_sig_encode 4089 EXIST:OPENSSL_FIPS:FUNCTION:DSA 3702FIPS_dsa_sig_encode 4089 NOEXIST::FUNCTION:
3704CRYPTO_dbg_remove_all_info 4090 EXIST::FUNCTION: 3703CRYPTO_dbg_remove_all_info 4090 NOEXIST::FUNCTION:
3705OPENSSL_init 4091 EXIST::FUNCTION: 3704OPENSSL_init 4091 NOEXIST::FUNCTION:
3706private_Camellia_set_key 4092 EXIST:OPENSSL_FIPS:FUNCTION:CAMELLIA 3705private_Camellia_set_key 4092 NOEXIST::FUNCTION:
3707CRYPTO_strdup 4093 EXIST::FUNCTION: 3706CRYPTO_strdup 4093 EXIST::FUNCTION:
3708JPAKE_STEP3A_process 4094 EXIST::FUNCTION:JPAKE 3707JPAKE_STEP3A_process 4094 EXIST::FUNCTION:JPAKE
3709JPAKE_STEP1_release 4095 EXIST::FUNCTION:JPAKE 3708JPAKE_STEP1_release 4095 EXIST::FUNCTION:JPAKE
@@ -3725,4 +3724,458 @@ JPAKE_STEP2_release 4110 EXIST::FUNCTION:JPAKE
3725JPAKE_STEP3A_init 4111 EXIST::FUNCTION:JPAKE 3724JPAKE_STEP3A_init 4111 EXIST::FUNCTION:JPAKE
3726ERR_load_JPAKE_strings 4112 EXIST::FUNCTION:JPAKE 3725ERR_load_JPAKE_strings 4112 EXIST::FUNCTION:JPAKE
3727JPAKE_STEP2_init 4113 EXIST::FUNCTION:JPAKE 3726JPAKE_STEP2_init 4113 EXIST::FUNCTION:JPAKE
3728ENGINE_load_aesni 4114 EXIST::FUNCTION:ENGINE 3727pqueue_size 4114 EXIST::FUNCTION:
3728i2d_TS_ACCURACY 4115 EXIST::FUNCTION:
3729i2d_TS_MSG_IMPRINT_fp 4116 EXIST::FUNCTION:
3730i2d_TS_MSG_IMPRINT 4117 EXIST::FUNCTION:
3731EVP_PKEY_print_public 4118 EXIST::FUNCTION:
3732EVP_PKEY_CTX_new 4119 EXIST::FUNCTION:
3733i2d_TS_TST_INFO 4120 EXIST::FUNCTION:
3734EVP_PKEY_asn1_find 4121 EXIST::FUNCTION:
3735DSO_METHOD_beos 4122 EXIST::FUNCTION:
3736TS_CONF_load_cert 4123 EXIST::FUNCTION:
3737TS_REQ_get_ext 4124 EXIST::FUNCTION:
3738EVP_PKEY_sign_init 4125 EXIST::FUNCTION:
3739ASN1_item_print 4126 EXIST::FUNCTION:
3740TS_TST_INFO_set_nonce 4127 EXIST::FUNCTION:
3741TS_RESP_dup 4128 EXIST::FUNCTION:
3742ENGINE_register_pkey_meths 4129 EXIST::FUNCTION:ENGINE
3743EVP_PKEY_asn1_add0 4130 EXIST::FUNCTION:
3744PKCS7_add0_attrib_signing_time 4131 EXIST::FUNCTION:
3745i2d_TS_TST_INFO_fp 4132 EXIST::FUNCTION:
3746BIO_asn1_get_prefix 4133 EXIST::FUNCTION:
3747TS_TST_INFO_set_time 4134 EXIST::FUNCTION:
3748EVP_PKEY_meth_set_decrypt 4135 EXIST::FUNCTION:
3749EVP_PKEY_set_type_str 4136 EXIST::FUNCTION:
3750EVP_PKEY_CTX_get_keygen_info 4137 EXIST::FUNCTION:
3751TS_REQ_set_policy_id 4138 EXIST::FUNCTION:
3752d2i_TS_RESP_fp 4139 EXIST::FUNCTION:
3753ENGINE_get_pkey_asn1_meth_engine 4140 EXIST:!VMS:FUNCTION:ENGINE
3754ENGINE_get_pkey_asn1_meth_eng 4140 EXIST:VMS:FUNCTION:ENGINE
3755WHIRLPOOL_Init 4141 EXIST:!VMSVAX:FUNCTION:WHIRLPOOL
3756TS_RESP_set_status_info 4142 EXIST::FUNCTION:
3757EVP_PKEY_keygen 4143 EXIST::FUNCTION:
3758EVP_DigestSignInit 4144 EXIST::FUNCTION:
3759TS_ACCURACY_set_millis 4145 EXIST::FUNCTION:
3760TS_REQ_dup 4146 EXIST::FUNCTION:
3761GENERAL_NAME_dup 4147 EXIST::FUNCTION:
3762ASN1_SEQUENCE_ANY_it 4148 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:
3763ASN1_SEQUENCE_ANY_it 4148 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:
3764WHIRLPOOL 4149 EXIST:!VMSVAX:FUNCTION:WHIRLPOOL
3765X509_STORE_get1_crls 4150 EXIST::FUNCTION:
3766ENGINE_get_pkey_asn1_meth 4151 EXIST::FUNCTION:ENGINE
3767EVP_PKEY_asn1_new 4152 EXIST::FUNCTION:
3768BIO_new_NDEF 4153 EXIST::FUNCTION:
3769ENGINE_get_pkey_meth 4154 EXIST::FUNCTION:ENGINE
3770TS_MSG_IMPRINT_set_algo 4155 EXIST::FUNCTION:
3771i2d_TS_TST_INFO_bio 4156 EXIST::FUNCTION:
3772TS_TST_INFO_set_ordering 4157 EXIST::FUNCTION:
3773TS_TST_INFO_get_ext_by_OBJ 4158 EXIST::FUNCTION:
3774CRYPTO_THREADID_set_pointer 4159 EXIST::FUNCTION:
3775TS_CONF_get_tsa_section 4160 EXIST::FUNCTION:
3776SMIME_write_ASN1 4161 EXIST::FUNCTION:
3777TS_RESP_CTX_set_signer_key 4162 EXIST::FUNCTION:
3778EVP_PKEY_encrypt_old 4163 EXIST::FUNCTION:
3779EVP_PKEY_encrypt_init 4164 EXIST::FUNCTION:
3780CRYPTO_THREADID_cpy 4165 EXIST::FUNCTION:
3781ASN1_PCTX_get_cert_flags 4166 EXIST::FUNCTION:
3782i2d_ESS_SIGNING_CERT 4167 EXIST::FUNCTION:
3783TS_CONF_load_key 4168 EXIST::FUNCTION:
3784i2d_ASN1_SEQUENCE_ANY 4169 EXIST::FUNCTION:
3785d2i_TS_MSG_IMPRINT_bio 4170 EXIST::FUNCTION:
3786EVP_PKEY_asn1_set_public 4171 EXIST::FUNCTION:
3787b2i_PublicKey_bio 4172 EXIST::FUNCTION:
3788BIO_asn1_set_prefix 4173 EXIST::FUNCTION:
3789EVP_PKEY_new_mac_key 4174 EXIST::FUNCTION:
3790BIO_new_CMS 4175 EXIST::FUNCTION:CMS
3791CRYPTO_THREADID_cmp 4176 EXIST::FUNCTION:
3792TS_REQ_ext_free 4177 EXIST::FUNCTION:
3793EVP_PKEY_asn1_set_free 4178 EXIST::FUNCTION:
3794EVP_PKEY_get0_asn1 4179 EXIST::FUNCTION:
3795d2i_NETSCAPE_X509 4180 EXIST::FUNCTION:
3796EVP_PKEY_verify_recover_init 4181 EXIST::FUNCTION:
3797EVP_PKEY_CTX_set_data 4182 EXIST::FUNCTION:
3798EVP_PKEY_keygen_init 4183 EXIST::FUNCTION:
3799TS_RESP_CTX_set_status_info 4184 EXIST::FUNCTION:
3800TS_MSG_IMPRINT_get_algo 4185 EXIST::FUNCTION:
3801TS_REQ_print_bio 4186 EXIST::FUNCTION:
3802EVP_PKEY_CTX_ctrl_str 4187 EXIST::FUNCTION:
3803EVP_PKEY_get_default_digest_nid 4188 EXIST::FUNCTION:
3804PEM_write_bio_PKCS7_stream 4189 EXIST::FUNCTION:
3805TS_MSG_IMPRINT_print_bio 4190 EXIST::FUNCTION:
3806BN_asc2bn 4191 EXIST::FUNCTION:
3807TS_REQ_get_policy_id 4192 EXIST::FUNCTION:
3808ENGINE_set_default_pkey_asn1_meths 4193 EXIST:!VMS:FUNCTION:ENGINE
3809ENGINE_set_def_pkey_asn1_meths 4193 EXIST:VMS:FUNCTION:ENGINE
3810d2i_TS_ACCURACY 4194 EXIST::FUNCTION:
3811DSO_global_lookup 4195 EXIST::FUNCTION:
3812TS_CONF_set_tsa_name 4196 EXIST::FUNCTION:
3813i2d_ASN1_SET_ANY 4197 EXIST::FUNCTION:
3814ENGINE_load_gost 4198 EXIST::FUNCTION:ENGINE,GOST,STATIC_ENGINE
3815WHIRLPOOL_BitUpdate 4199 EXIST:!VMSVAX:FUNCTION:WHIRLPOOL
3816ASN1_PCTX_get_flags 4200 EXIST::FUNCTION:
3817TS_TST_INFO_get_ext_by_NID 4201 EXIST::FUNCTION:
3818TS_RESP_new 4202 EXIST::FUNCTION:
3819ESS_CERT_ID_dup 4203 EXIST::FUNCTION:
3820TS_STATUS_INFO_dup 4204 EXIST::FUNCTION:
3821TS_REQ_delete_ext 4205 EXIST::FUNCTION:
3822EVP_DigestVerifyFinal 4206 EXIST::FUNCTION:
3823EVP_PKEY_print_params 4207 EXIST::FUNCTION:
3824i2d_CMS_bio_stream 4208 EXIST::FUNCTION:CMS
3825TS_REQ_get_msg_imprint 4209 EXIST::FUNCTION:
3826OBJ_find_sigid_by_algs 4210 EXIST::FUNCTION:
3827TS_TST_INFO_get_serial 4211 EXIST::FUNCTION:
3828TS_REQ_get_nonce 4212 EXIST::FUNCTION:
3829X509_PUBKEY_set0_param 4213 EXIST::FUNCTION:
3830EVP_PKEY_CTX_set0_keygen_info 4214 EXIST::FUNCTION:
3831DIST_POINT_set_dpname 4215 EXIST::FUNCTION:
3832i2d_ISSUING_DIST_POINT 4216 EXIST::FUNCTION:
3833ASN1_SET_ANY_it 4217 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:
3834ASN1_SET_ANY_it 4217 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:
3835EVP_PKEY_CTX_get_data 4218 EXIST::FUNCTION:
3836TS_STATUS_INFO_print_bio 4219 EXIST::FUNCTION:
3837EVP_PKEY_derive_init 4220 EXIST::FUNCTION:
3838d2i_TS_TST_INFO 4221 EXIST::FUNCTION:
3839EVP_PKEY_asn1_add_alias 4222 EXIST::FUNCTION:
3840d2i_TS_RESP_bio 4223 EXIST::FUNCTION:
3841OTHERNAME_cmp 4224 EXIST::FUNCTION:
3842GENERAL_NAME_set0_value 4225 EXIST::FUNCTION:
3843PKCS7_RECIP_INFO_get0_alg 4226 EXIST::FUNCTION:
3844TS_RESP_CTX_new 4227 EXIST::FUNCTION:
3845TS_RESP_set_tst_info 4228 EXIST::FUNCTION:
3846PKCS7_final 4229 EXIST::FUNCTION:
3847EVP_PKEY_base_id 4230 EXIST::FUNCTION:
3848TS_RESP_CTX_set_signer_cert 4231 EXIST::FUNCTION:
3849TS_REQ_set_msg_imprint 4232 EXIST::FUNCTION:
3850EVP_PKEY_CTX_ctrl 4233 EXIST::FUNCTION:
3851TS_CONF_set_digests 4234 EXIST::FUNCTION:
3852d2i_TS_MSG_IMPRINT 4235 EXIST::FUNCTION:
3853EVP_PKEY_meth_set_ctrl 4236 EXIST::FUNCTION:
3854TS_REQ_get_ext_by_NID 4237 EXIST::FUNCTION:
3855PKCS5_pbe_set0_algor 4238 EXIST::FUNCTION:
3856BN_BLINDING_thread_id 4239 EXIST::FUNCTION:
3857TS_ACCURACY_new 4240 EXIST::FUNCTION:
3858X509_CRL_METHOD_free 4241 EXIST::FUNCTION:
3859ASN1_PCTX_get_nm_flags 4242 EXIST::FUNCTION:
3860EVP_PKEY_meth_set_sign 4243 EXIST::FUNCTION:
3861CRYPTO_THREADID_current 4244 EXIST::FUNCTION:
3862EVP_PKEY_decrypt_init 4245 EXIST::FUNCTION:
3863NETSCAPE_X509_free 4246 EXIST::FUNCTION:
3864i2b_PVK_bio 4247 EXIST::FUNCTION:RC4
3865EVP_PKEY_print_private 4248 EXIST::FUNCTION:
3866GENERAL_NAME_get0_value 4249 EXIST::FUNCTION:
3867b2i_PVK_bio 4250 EXIST::FUNCTION:RC4
3868ASN1_UTCTIME_adj 4251 EXIST::FUNCTION:
3869TS_TST_INFO_new 4252 EXIST::FUNCTION:
3870EVP_MD_do_all_sorted 4253 EXIST::FUNCTION:
3871TS_CONF_set_default_engine 4254 EXIST::FUNCTION:
3872TS_ACCURACY_set_seconds 4255 EXIST::FUNCTION:
3873TS_TST_INFO_get_time 4256 EXIST::FUNCTION:
3874PKCS8_pkey_get0 4257 EXIST::FUNCTION:
3875EVP_PKEY_asn1_get0 4258 EXIST::FUNCTION:
3876OBJ_add_sigid 4259 EXIST::FUNCTION:
3877PKCS7_SIGNER_INFO_sign 4260 EXIST::FUNCTION:
3878EVP_PKEY_paramgen_init 4261 EXIST::FUNCTION:
3879EVP_PKEY_sign 4262 EXIST::FUNCTION:
3880OBJ_sigid_free 4263 EXIST::FUNCTION:
3881EVP_PKEY_meth_set_init 4264 EXIST::FUNCTION:
3882d2i_ESS_ISSUER_SERIAL 4265 EXIST::FUNCTION:
3883ISSUING_DIST_POINT_new 4266 EXIST::FUNCTION:
3884ASN1_TIME_adj 4267 EXIST::FUNCTION:
3885TS_OBJ_print_bio 4268 EXIST::FUNCTION:
3886EVP_PKEY_meth_set_verify_recover 4269 EXIST:!VMS:FUNCTION:
3887EVP_PKEY_meth_set_vrfy_recover 4269 EXIST:VMS:FUNCTION:
3888TS_RESP_get_status_info 4270 EXIST::FUNCTION:
3889CMS_stream 4271 EXIST::FUNCTION:CMS
3890EVP_PKEY_CTX_set_cb 4272 EXIST::FUNCTION:
3891PKCS7_to_TS_TST_INFO 4273 EXIST::FUNCTION:
3892ASN1_PCTX_get_oid_flags 4274 EXIST::FUNCTION:
3893TS_TST_INFO_add_ext 4275 EXIST::FUNCTION:
3894EVP_PKEY_meth_set_derive 4276 EXIST::FUNCTION:
3895i2d_TS_RESP_fp 4277 EXIST::FUNCTION:
3896i2d_TS_MSG_IMPRINT_bio 4278 EXIST::FUNCTION:
3897TS_RESP_CTX_set_accuracy 4279 EXIST::FUNCTION:
3898TS_REQ_set_nonce 4280 EXIST::FUNCTION:
3899ESS_CERT_ID_new 4281 EXIST::FUNCTION:
3900ENGINE_pkey_asn1_find_str 4282 EXIST::FUNCTION:ENGINE
3901TS_REQ_get_ext_count 4283 EXIST::FUNCTION:
3902BUF_reverse 4284 EXIST::FUNCTION:
3903TS_TST_INFO_print_bio 4285 EXIST::FUNCTION:
3904d2i_ISSUING_DIST_POINT 4286 EXIST::FUNCTION:
3905ENGINE_get_pkey_meths 4287 EXIST::FUNCTION:ENGINE
3906i2b_PrivateKey_bio 4288 EXIST::FUNCTION:
3907i2d_TS_RESP 4289 EXIST::FUNCTION:
3908b2i_PublicKey 4290 EXIST::FUNCTION:
3909TS_VERIFY_CTX_cleanup 4291 EXIST::FUNCTION:
3910TS_STATUS_INFO_free 4292 EXIST::FUNCTION:
3911TS_RESP_verify_token 4293 EXIST::FUNCTION:
3912OBJ_bsearch_ex_ 4294 EXIST::FUNCTION:
3913ASN1_bn_print 4295 EXIST::FUNCTION:BIO
3914EVP_PKEY_asn1_get_count 4296 EXIST::FUNCTION:
3915ENGINE_register_pkey_asn1_meths 4297 EXIST::FUNCTION:ENGINE
3916ASN1_PCTX_set_nm_flags 4298 EXIST::FUNCTION:
3917EVP_DigestVerifyInit 4299 EXIST::FUNCTION:
3918ENGINE_set_default_pkey_meths 4300 EXIST::FUNCTION:ENGINE
3919TS_TST_INFO_get_policy_id 4301 EXIST::FUNCTION:
3920TS_REQ_get_cert_req 4302 EXIST::FUNCTION:
3921X509_CRL_set_meth_data 4303 EXIST::FUNCTION:
3922PKCS8_pkey_set0 4304 EXIST::FUNCTION:
3923ASN1_STRING_copy 4305 EXIST::FUNCTION:
3924d2i_TS_TST_INFO_fp 4306 EXIST::FUNCTION:
3925X509_CRL_match 4307 EXIST::FUNCTION:
3926EVP_PKEY_asn1_set_private 4308 EXIST::FUNCTION:
3927TS_TST_INFO_get_ext_d2i 4309 EXIST::FUNCTION:
3928TS_RESP_CTX_add_policy 4310 EXIST::FUNCTION:
3929d2i_TS_RESP 4311 EXIST::FUNCTION:
3930TS_CONF_load_certs 4312 EXIST::FUNCTION:
3931TS_TST_INFO_get_msg_imprint 4313 EXIST::FUNCTION:
3932ERR_load_TS_strings 4314 EXIST::FUNCTION:
3933TS_TST_INFO_get_version 4315 EXIST::FUNCTION:
3934EVP_PKEY_CTX_dup 4316 EXIST::FUNCTION:
3935EVP_PKEY_meth_set_verify 4317 EXIST::FUNCTION:
3936i2b_PublicKey_bio 4318 EXIST::FUNCTION:
3937TS_CONF_set_certs 4319 EXIST::FUNCTION:
3938EVP_PKEY_asn1_get0_info 4320 EXIST::FUNCTION:
3939TS_VERIFY_CTX_free 4321 EXIST::FUNCTION:
3940TS_REQ_get_ext_by_critical 4322 EXIST::FUNCTION:
3941TS_RESP_CTX_set_serial_cb 4323 EXIST::FUNCTION:
3942X509_CRL_get_meth_data 4324 EXIST::FUNCTION:
3943TS_RESP_CTX_set_time_cb 4325 EXIST::FUNCTION:
3944TS_MSG_IMPRINT_get_msg 4326 EXIST::FUNCTION:
3945TS_TST_INFO_ext_free 4327 EXIST::FUNCTION:
3946TS_REQ_get_version 4328 EXIST::FUNCTION:
3947TS_REQ_add_ext 4329 EXIST::FUNCTION:
3948EVP_PKEY_CTX_set_app_data 4330 EXIST::FUNCTION:
3949OBJ_bsearch_ 4331 EXIST::FUNCTION:
3950EVP_PKEY_meth_set_verifyctx 4332 EXIST::FUNCTION:
3951i2d_PKCS7_bio_stream 4333 EXIST::FUNCTION:
3952CRYPTO_THREADID_set_numeric 4334 EXIST::FUNCTION:
3953PKCS7_sign_add_signer 4335 EXIST::FUNCTION:
3954d2i_TS_TST_INFO_bio 4336 EXIST::FUNCTION:
3955TS_TST_INFO_get_ordering 4337 EXIST::FUNCTION:
3956TS_RESP_print_bio 4338 EXIST::FUNCTION:
3957TS_TST_INFO_get_exts 4339 EXIST::FUNCTION:
3958HMAC_CTX_copy 4340 EXIST::FUNCTION:HMAC
3959PKCS5_pbe2_set_iv 4341 EXIST::FUNCTION:
3960ENGINE_get_pkey_asn1_meths 4342 EXIST::FUNCTION:ENGINE
3961b2i_PrivateKey 4343 EXIST::FUNCTION:
3962EVP_PKEY_CTX_get_app_data 4344 EXIST::FUNCTION:
3963TS_REQ_set_cert_req 4345 EXIST::FUNCTION:
3964CRYPTO_THREADID_set_callback 4346 EXIST::FUNCTION:
3965TS_CONF_set_serial 4347 EXIST::FUNCTION:
3966TS_TST_INFO_free 4348 EXIST::FUNCTION:
3967d2i_TS_REQ_fp 4349 EXIST::FUNCTION:
3968TS_RESP_verify_response 4350 EXIST::FUNCTION:
3969i2d_ESS_ISSUER_SERIAL 4351 EXIST::FUNCTION:
3970TS_ACCURACY_get_seconds 4352 EXIST::FUNCTION:
3971EVP_CIPHER_do_all 4353 EXIST::FUNCTION:
3972b2i_PrivateKey_bio 4354 EXIST::FUNCTION:
3973OCSP_CERTID_dup 4355 EXIST::FUNCTION:
3974X509_PUBKEY_get0_param 4356 EXIST::FUNCTION:
3975TS_MSG_IMPRINT_dup 4357 EXIST::FUNCTION:
3976PKCS7_print_ctx 4358 EXIST::FUNCTION:
3977i2d_TS_REQ_bio 4359 EXIST::FUNCTION:
3978EVP_whirlpool 4360 EXIST:!VMSVAX:FUNCTION:WHIRLPOOL
3979EVP_PKEY_asn1_set_param 4361 EXIST::FUNCTION:
3980EVP_PKEY_meth_set_encrypt 4362 EXIST::FUNCTION:
3981ASN1_PCTX_set_flags 4363 EXIST::FUNCTION:
3982i2d_ESS_CERT_ID 4364 EXIST::FUNCTION:
3983TS_VERIFY_CTX_new 4365 EXIST::FUNCTION:
3984TS_RESP_CTX_set_extension_cb 4366 EXIST::FUNCTION:
3985ENGINE_register_all_pkey_meths 4367 EXIST::FUNCTION:ENGINE
3986TS_RESP_CTX_set_status_info_cond 4368 EXIST:!VMS:FUNCTION:
3987TS_RESP_CTX_set_stat_info_cond 4368 EXIST:VMS:FUNCTION:
3988EVP_PKEY_verify 4369 EXIST::FUNCTION:
3989WHIRLPOOL_Final 4370 EXIST:!VMSVAX:FUNCTION:WHIRLPOOL
3990X509_CRL_METHOD_new 4371 EXIST::FUNCTION:
3991EVP_DigestSignFinal 4372 EXIST::FUNCTION:
3992TS_RESP_CTX_set_def_policy 4373 EXIST::FUNCTION:
3993NETSCAPE_X509_it 4374 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:
3994NETSCAPE_X509_it 4374 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:
3995TS_RESP_create_response 4375 EXIST::FUNCTION:
3996PKCS7_SIGNER_INFO_get0_algs 4376 EXIST::FUNCTION:
3997TS_TST_INFO_get_nonce 4377 EXIST::FUNCTION:
3998EVP_PKEY_decrypt_old 4378 EXIST::FUNCTION:
3999TS_TST_INFO_set_policy_id 4379 EXIST::FUNCTION:
4000TS_CONF_set_ess_cert_id_chain 4380 EXIST::FUNCTION:
4001EVP_PKEY_CTX_get0_pkey 4381 EXIST::FUNCTION:
4002d2i_TS_REQ 4382 EXIST::FUNCTION:
4003EVP_PKEY_asn1_find_str 4383 EXIST::FUNCTION:
4004BIO_f_asn1 4384 EXIST::FUNCTION:
4005ESS_SIGNING_CERT_new 4385 EXIST::FUNCTION:
4006EVP_PBE_find 4386 EXIST::FUNCTION:
4007X509_CRL_get0_by_cert 4387 EXIST::FUNCTION:
4008EVP_PKEY_derive 4388 EXIST::FUNCTION:
4009i2d_TS_REQ 4389 EXIST::FUNCTION:
4010TS_TST_INFO_delete_ext 4390 EXIST::FUNCTION:
4011ESS_ISSUER_SERIAL_free 4391 EXIST::FUNCTION:
4012ASN1_PCTX_set_str_flags 4392 EXIST::FUNCTION:
4013ENGINE_get_pkey_asn1_meth_str 4393 EXIST::FUNCTION:ENGINE
4014TS_CONF_set_signer_key 4394 EXIST::FUNCTION:
4015TS_ACCURACY_get_millis 4395 EXIST::FUNCTION:
4016TS_RESP_get_token 4396 EXIST::FUNCTION:
4017TS_ACCURACY_dup 4397 EXIST::FUNCTION:
4018ENGINE_register_all_pkey_asn1_meths 4398 EXIST:!VMS:FUNCTION:ENGINE
4019ENGINE_reg_all_pkey_asn1_meths 4398 EXIST:VMS:FUNCTION:ENGINE
4020X509_CRL_set_default_method 4399 EXIST::FUNCTION:
4021CRYPTO_THREADID_hash 4400 EXIST::FUNCTION:
4022CMS_ContentInfo_print_ctx 4401 EXIST::FUNCTION:CMS
4023TS_RESP_free 4402 EXIST::FUNCTION:
4024ISSUING_DIST_POINT_free 4403 EXIST::FUNCTION:
4025ESS_ISSUER_SERIAL_new 4404 EXIST::FUNCTION:
4026CMS_add1_crl 4405 EXIST::FUNCTION:CMS
4027PKCS7_add1_attrib_digest 4406 EXIST::FUNCTION:
4028TS_RESP_CTX_add_md 4407 EXIST::FUNCTION:
4029TS_TST_INFO_dup 4408 EXIST::FUNCTION:
4030ENGINE_set_pkey_asn1_meths 4409 EXIST::FUNCTION:ENGINE
4031PEM_write_bio_Parameters 4410 EXIST::FUNCTION:
4032TS_TST_INFO_get_accuracy 4411 EXIST::FUNCTION:
4033X509_CRL_get0_by_serial 4412 EXIST::FUNCTION:
4034TS_TST_INFO_set_version 4413 EXIST::FUNCTION:
4035TS_RESP_CTX_get_tst_info 4414 EXIST::FUNCTION:
4036TS_RESP_verify_signature 4415 EXIST::FUNCTION:
4037CRYPTO_THREADID_get_callback 4416 EXIST::FUNCTION:
4038TS_TST_INFO_get_tsa 4417 EXIST::FUNCTION:
4039TS_STATUS_INFO_new 4418 EXIST::FUNCTION:
4040EVP_PKEY_CTX_get_cb 4419 EXIST::FUNCTION:
4041TS_REQ_get_ext_d2i 4420 EXIST::FUNCTION:
4042GENERAL_NAME_set0_othername 4421 EXIST::FUNCTION:
4043TS_TST_INFO_get_ext_count 4422 EXIST::FUNCTION:
4044TS_RESP_CTX_get_request 4423 EXIST::FUNCTION:
4045i2d_NETSCAPE_X509 4424 EXIST::FUNCTION:
4046ENGINE_get_pkey_meth_engine 4425 EXIST::FUNCTION:ENGINE
4047EVP_PKEY_meth_set_signctx 4426 EXIST::FUNCTION:
4048EVP_PKEY_asn1_copy 4427 EXIST::FUNCTION:
4049ASN1_TYPE_cmp 4428 EXIST::FUNCTION:
4050EVP_CIPHER_do_all_sorted 4429 EXIST::FUNCTION:
4051EVP_PKEY_CTX_free 4430 EXIST::FUNCTION:
4052ISSUING_DIST_POINT_it 4431 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:
4053ISSUING_DIST_POINT_it 4431 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:
4054d2i_TS_MSG_IMPRINT_fp 4432 EXIST::FUNCTION:
4055X509_STORE_get1_certs 4433 EXIST::FUNCTION:
4056EVP_PKEY_CTX_get_operation 4434 EXIST::FUNCTION:
4057d2i_ESS_SIGNING_CERT 4435 EXIST::FUNCTION:
4058TS_CONF_set_ordering 4436 EXIST::FUNCTION:
4059EVP_PBE_alg_add_type 4437 EXIST::FUNCTION:
4060TS_REQ_set_version 4438 EXIST::FUNCTION:
4061EVP_PKEY_get0 4439 EXIST::FUNCTION:
4062BIO_asn1_set_suffix 4440 EXIST::FUNCTION:
4063i2d_TS_STATUS_INFO 4441 EXIST::FUNCTION:
4064EVP_MD_do_all 4442 EXIST::FUNCTION:
4065TS_TST_INFO_set_accuracy 4443 EXIST::FUNCTION:
4066PKCS7_add_attrib_content_type 4444 EXIST::FUNCTION:
4067ERR_remove_thread_state 4445 EXIST::FUNCTION:
4068EVP_PKEY_meth_add0 4446 EXIST::FUNCTION:
4069TS_TST_INFO_set_tsa 4447 EXIST::FUNCTION:
4070EVP_PKEY_meth_new 4448 EXIST::FUNCTION:
4071WHIRLPOOL_Update 4449 EXIST:!VMSVAX:FUNCTION:WHIRLPOOL
4072TS_CONF_set_accuracy 4450 EXIST::FUNCTION:
4073ASN1_PCTX_set_oid_flags 4451 EXIST::FUNCTION:
4074ESS_SIGNING_CERT_dup 4452 EXIST::FUNCTION:
4075d2i_TS_REQ_bio 4453 EXIST::FUNCTION:
4076X509_time_adj_ex 4454 EXIST::FUNCTION:
4077TS_RESP_CTX_add_flags 4455 EXIST::FUNCTION:
4078d2i_TS_STATUS_INFO 4456 EXIST::FUNCTION:
4079TS_MSG_IMPRINT_set_msg 4457 EXIST::FUNCTION:
4080BIO_asn1_get_suffix 4458 EXIST::FUNCTION:
4081TS_REQ_free 4459 EXIST::FUNCTION:
4082EVP_PKEY_meth_free 4460 EXIST::FUNCTION:
4083TS_REQ_get_exts 4461 EXIST::FUNCTION:
4084TS_RESP_CTX_set_clock_precision_digits 4462 EXIST:!VMS:FUNCTION:
4085TS_RESP_CTX_set_clk_prec_digits 4462 EXIST:VMS:FUNCTION:
4086TS_RESP_CTX_add_failure_info 4463 EXIST::FUNCTION:
4087i2d_TS_RESP_bio 4464 EXIST::FUNCTION:
4088EVP_PKEY_CTX_get0_peerkey 4465 EXIST::FUNCTION:
4089PEM_write_bio_CMS_stream 4466 EXIST::FUNCTION:CMS
4090TS_REQ_new 4467 EXIST::FUNCTION:
4091TS_MSG_IMPRINT_new 4468 EXIST::FUNCTION:
4092EVP_PKEY_meth_find 4469 EXIST::FUNCTION:
4093EVP_PKEY_id 4470 EXIST::FUNCTION:
4094TS_TST_INFO_set_serial 4471 EXIST::FUNCTION:
4095a2i_GENERAL_NAME 4472 EXIST::FUNCTION:
4096TS_CONF_set_crypto_device 4473 EXIST::FUNCTION:
4097EVP_PKEY_verify_init 4474 EXIST::FUNCTION:
4098TS_CONF_set_policies 4475 EXIST::FUNCTION:
4099ASN1_PCTX_new 4476 EXIST::FUNCTION:
4100ESS_CERT_ID_free 4477 EXIST::FUNCTION:
4101ENGINE_unregister_pkey_meths 4478 EXIST::FUNCTION:ENGINE
4102TS_MSG_IMPRINT_free 4479 EXIST::FUNCTION:
4103TS_VERIFY_CTX_init 4480 EXIST::FUNCTION:
4104PKCS7_stream 4481 EXIST::FUNCTION:
4105TS_RESP_CTX_set_certs 4482 EXIST::FUNCTION:
4106TS_CONF_set_def_policy 4483 EXIST::FUNCTION:
4107ASN1_GENERALIZEDTIME_adj 4484 EXIST::FUNCTION:
4108NETSCAPE_X509_new 4485 EXIST::FUNCTION:
4109TS_ACCURACY_free 4486 EXIST::FUNCTION:
4110TS_RESP_get_tst_info 4487 EXIST::FUNCTION:
4111EVP_PKEY_derive_set_peer 4488 EXIST::FUNCTION:
4112PEM_read_bio_Parameters 4489 EXIST::FUNCTION:
4113TS_CONF_set_clock_precision_digits 4490 EXIST:!VMS:FUNCTION:
4114TS_CONF_set_clk_prec_digits 4490 EXIST:VMS:FUNCTION:
4115ESS_ISSUER_SERIAL_dup 4491 EXIST::FUNCTION:
4116TS_ACCURACY_get_micros 4492 EXIST::FUNCTION:
4117ASN1_PCTX_get_str_flags 4493 EXIST::FUNCTION:
4118NAME_CONSTRAINTS_check 4494 EXIST::FUNCTION:
4119ASN1_BIT_STRING_check 4495 EXIST::FUNCTION:
4120X509_check_akid 4496 EXIST::FUNCTION:
4121ENGINE_unregister_pkey_asn1_meths 4497 EXIST:!VMS:FUNCTION:ENGINE
4122ENGINE_unreg_pkey_asn1_meths 4497 EXIST:VMS:FUNCTION:ENGINE
4123ASN1_PCTX_free 4498 EXIST::FUNCTION:
4124PEM_write_bio_ASN1_stream 4499 EXIST::FUNCTION:
4125i2d_ASN1_bio_stream 4500 EXIST::FUNCTION:
4126TS_X509_ALGOR_print_bio 4501 EXIST::FUNCTION:
4127EVP_PKEY_meth_set_cleanup 4502 EXIST::FUNCTION:
4128EVP_PKEY_asn1_free 4503 EXIST::FUNCTION:
4129ESS_SIGNING_CERT_free 4504 EXIST::FUNCTION:
4130TS_TST_INFO_set_msg_imprint 4505 EXIST::FUNCTION:
4131GENERAL_NAME_cmp 4506 EXIST::FUNCTION:
4132d2i_ASN1_SET_ANY 4507 EXIST::FUNCTION:
4133ENGINE_set_pkey_meths 4508 EXIST::FUNCTION:ENGINE
4134i2d_TS_REQ_fp 4509 EXIST::FUNCTION:
4135d2i_ASN1_SEQUENCE_ANY 4510 EXIST::FUNCTION:
4136GENERAL_NAME_get0_otherName 4511 EXIST::FUNCTION:
4137d2i_ESS_CERT_ID 4512 EXIST::FUNCTION:
4138OBJ_find_sigid_algs 4513 EXIST::FUNCTION:
4139EVP_PKEY_meth_set_keygen 4514 EXIST::FUNCTION:
4140PKCS5_PBKDF2_HMAC 4515 EXIST::FUNCTION:
4141EVP_PKEY_paramgen 4516 EXIST::FUNCTION:
4142EVP_PKEY_meth_set_paramgen 4517 EXIST::FUNCTION:
4143BIO_new_PKCS7 4518 EXIST::FUNCTION:
4144EVP_PKEY_verify_recover 4519 EXIST::FUNCTION:
4145TS_ext_print_bio 4520 EXIST::FUNCTION:
4146TS_ASN1_INTEGER_print_bio 4521 EXIST::FUNCTION:
4147check_defer 4522 EXIST::FUNCTION:
4148DSO_pathbyaddr 4523 EXIST::FUNCTION:
4149EVP_PKEY_set_type 4524 EXIST::FUNCTION:
4150TS_ACCURACY_set_micros 4525 EXIST::FUNCTION:
4151TS_REQ_to_TS_VERIFY_CTX 4526 EXIST::FUNCTION:
4152EVP_PKEY_meth_set_copy 4527 EXIST::FUNCTION:
4153ASN1_PCTX_set_cert_flags 4528 EXIST::FUNCTION:
4154TS_TST_INFO_get_ext 4529 EXIST::FUNCTION:
4155EVP_PKEY_asn1_set_ctrl 4530 EXIST::FUNCTION:
4156TS_TST_INFO_get_ext_by_critical 4531 EXIST::FUNCTION:
4157EVP_PKEY_CTX_new_id 4532 EXIST::FUNCTION:
4158TS_REQ_get_ext_by_OBJ 4533 EXIST::FUNCTION:
4159TS_CONF_set_signer_cert 4534 EXIST::FUNCTION:
4160X509_NAME_hash_old 4535 EXIST::FUNCTION:
4161ASN1_TIME_set_string 4536 EXIST::FUNCTION:
4162EVP_MD_flags 4537 EXIST::FUNCTION:
4163TS_RESP_CTX_free 4538 EXIST::FUNCTION:
4164DSAparams_dup 4539 EXIST::FUNCTION:DSA
4165DHparams_dup 4540 EXIST::FUNCTION:DH
4166OCSP_REQ_CTX_add1_header 4541 EXIST::FUNCTION:
4167OCSP_REQ_CTX_set1_req 4542 EXIST::FUNCTION:
4168X509_STORE_set_verify_cb 4543 EXIST::FUNCTION:
4169X509_STORE_CTX_get0_current_crl 4544 EXIST::FUNCTION:
4170X509_STORE_CTX_get0_parent_ctx 4545 EXIST::FUNCTION:
4171X509_STORE_CTX_get0_current_issuer 4546 EXIST:!VMS:FUNCTION:
4172X509_STORE_CTX_get0_cur_issuer 4546 EXIST:VMS:FUNCTION:
4173X509_issuer_name_hash_old 4547 EXIST::FUNCTION:MD5
4174X509_subject_name_hash_old 4548 EXIST::FUNCTION:MD5
4175EVP_CIPHER_CTX_copy 4549 EXIST::FUNCTION:
4176UI_method_get_prompt_constructor 4550 EXIST:!VMS:FUNCTION:
4177UI_method_get_prompt_constructr 4550 EXIST:VMS:FUNCTION:
4178UI_method_set_prompt_constructor 4551 EXIST:!VMS:FUNCTION:
4179UI_method_set_prompt_constructr 4551 EXIST:VMS:FUNCTION:
4180EVP_read_pw_string_min 4552 EXIST::FUNCTION:
4181ENGINE_load_aesni 4553 EXIST::FUNCTION:ENGINE
diff --git a/src/lib/libcrypto/util/mk1mf.pl b/src/lib/libcrypto/util/mk1mf.pl
index 4c16f1dc9e..780029a03f 100644
--- a/src/lib/libcrypto/util/mk1mf.pl
+++ b/src/lib/libcrypto/util/mk1mf.pl
@@ -6,36 +6,56 @@
6# 6#
7 7
8$INSTALLTOP="/usr/local/ssl"; 8$INSTALLTOP="/usr/local/ssl";
9$OPENSSLDIR="/usr/local/ssl";
9$OPTIONS=""; 10$OPTIONS="";
10$ssl_version=""; 11$ssl_version="";
11$banner="\t\@echo Building OpenSSL"; 12$banner="\t\@echo Building OpenSSL";
12 13
13my $no_static_engine = 0; 14my $no_static_engine = 1;
14my $engines = ""; 15my $engines = "";
15local $zlib_opt = 0; # 0 = no zlib, 1 = static, 2 = dynamic 16local $zlib_opt = 0; # 0 = no zlib, 1 = static, 2 = dynamic
16local $zlib_lib = ""; 17local $zlib_lib = "";
18local $perl_asm = 0; # 1 to autobuild asm files from perl scripts
19
20# Options to import from top level Makefile
21
22my %mf_import = (
23 VERSION => \$ssl_version,
24 OPTIONS => \$OPTIONS,
25 INSTALLTOP => \$INSTALLTOP,
26 OPENSSLDIR => \$OPENSSLDIR,
27 PLATFORM => \$mf_platform,
28 CFLAG => \$mf_cflag,
29 DEPFLAG => \$mf_depflag,
30 CPUID_OBJ => \$mf_cpuid_asm,
31 BN_ASM => \$mf_bn_asm,
32 DES_ENC => \$mf_des_asm,
33 AES_ENC => \$mf_aes_asm,
34 BF_ENC => \$mf_bf_asm,
35 CAST_ENC => \$mf_cast_asm,
36 RC4_ENC => \$mf_rc4_asm,
37 RC5_ENC => \$mf_rc5_asm,
38 MD5_ASM_OBJ => \$mf_md5_asm,
39 SHA1_ASM_OBJ => \$mf_sha_asm,
40 RMD160_ASM_OBJ => \$mf_rmd_asm,
41 WP_ASM_OBJ => \$mf_wp_asm,
42 CMLL_ENC => \$mf_cm_asm
43);
17 44
18local $fips_canister_path = "";
19my $fips_premain_dso_exe_path = "";
20my $fips_premain_c_path = "";
21my $fips_sha1_exe_path = "";
22
23local $fipscanisterbuild = 0;
24local $fipsdso = 0;
25
26my $fipslibdir = "";
27my $baseaddr = "";
28
29my $ex_l_libs = "";
30 45
31open(IN,"<Makefile") || die "unable to open Makefile!\n"; 46open(IN,"<Makefile") || die "unable to open Makefile!\n";
32while(<IN>) { 47while(<IN>) {
33 $ssl_version=$1 if (/^VERSION=(.*)$/); 48 my ($mf_opt, $mf_ref);
34 $OPTIONS=$1 if (/^OPTIONS=(.*)$/); 49 while (($mf_opt, $mf_ref) = each %mf_import) {
35 $INSTALLTOP=$1 if (/^INSTALLTOP=(.*$)/); 50 if (/^$mf_opt\s*=\s*(.*)$/) {
51 $$mf_ref = $1;
52 }
53 }
36} 54}
37close(IN); 55close(IN);
38 56
57$debug = 1 if $mf_platform =~ /^debug-/;
58
39die "Makefile is not the toplevel Makefile!\n" if $ssl_version eq ""; 59die "Makefile is not the toplevel Makefile!\n" if $ssl_version eq "";
40 60
41$infile="MINFO"; 61$infile="MINFO";
@@ -58,6 +78,7 @@ $infile="MINFO";
58 "netware-libc", "CodeWarrior for NetWare - LibC - with WinSock Sockets", 78 "netware-libc", "CodeWarrior for NetWare - LibC - with WinSock Sockets",
59 "netware-libc-bsdsock", "CodeWarrior for NetWare - LibC - with BSD Sockets", 79 "netware-libc-bsdsock", "CodeWarrior for NetWare - LibC - with BSD Sockets",
60 "default","cc under unix", 80 "default","cc under unix",
81 "auto", "auto detect from top level Makefile"
61 ); 82 );
62 83
63$platform=""; 84$platform="";
@@ -144,6 +165,12 @@ $bin_dir=(defined($VARS{'BIN'}))?$VARS{'BIN'}:'';
144$NT=0; 165$NT=0;
145 166
146push(@INC,"util/pl","pl"); 167push(@INC,"util/pl","pl");
168
169if ($platform eq "auto") {
170 $platform = $mf_platform;
171 print STDERR "Imported platform $mf_platform\n";
172}
173
147if (($platform =~ /VC-(.+)/)) 174if (($platform =~ /VC-(.+)/))
148 { 175 {
149 $FLAVOR=$1; 176 $FLAVOR=$1;
@@ -228,13 +255,12 @@ $cflags.=" -DOPENSSL_NO_DES" if $no_des;
228$cflags.=" -DOPENSSL_NO_RSA" if $no_rsa; 255$cflags.=" -DOPENSSL_NO_RSA" if $no_rsa;
229$cflags.=" -DOPENSSL_NO_DSA" if $no_dsa; 256$cflags.=" -DOPENSSL_NO_DSA" if $no_dsa;
230$cflags.=" -DOPENSSL_NO_DH" if $no_dh; 257$cflags.=" -DOPENSSL_NO_DH" if $no_dh;
258$cflags.=" -DOPENSSL_NO_WHIRLPOOL" if $no_whirlpool;
231$cflags.=" -DOPENSSL_NO_SOCK" if $no_sock; 259$cflags.=" -DOPENSSL_NO_SOCK" if $no_sock;
232$cflags.=" -DOPENSSL_NO_SSL2" if $no_ssl2; 260$cflags.=" -DOPENSSL_NO_SSL2" if $no_ssl2;
233$cflags.=" -DOPENSSL_NO_SSL3" if $no_ssl3; 261$cflags.=" -DOPENSSL_NO_SSL3" if $no_ssl3;
234$cflags.=" -DOPENSSL_NO_TLSEXT" if $no_tlsext; 262$cflags.=" -DOPENSSL_NO_TLSEXT" if $no_tlsext;
235$cflags.=" -DOPENSSL_NO_CMS" if $no_cms; 263$cflags.=" -DOPENSSL_NO_CMS" if $no_cms;
236$cflags.=" -DOPENSSL_NO_JPAKE" if $no_jpake;
237$cflags.=" -DOPENSSL_NO_CAPIENG" if $no_capieng;
238$cflags.=" -DOPENSSL_NO_ERR" if $no_err; 264$cflags.=" -DOPENSSL_NO_ERR" if $no_err;
239$cflags.=" -DOPENSSL_NO_KRB5" if $no_krb5; 265$cflags.=" -DOPENSSL_NO_KRB5" if $no_krb5;
240$cflags.=" -DOPENSSL_NO_EC" if $no_ec; 266$cflags.=" -DOPENSSL_NO_EC" if $no_ec;
@@ -242,7 +268,7 @@ $cflags.=" -DOPENSSL_NO_ECDSA" if $no_ecdsa;
242$cflags.=" -DOPENSSL_NO_ECDH" if $no_ecdh; 268$cflags.=" -DOPENSSL_NO_ECDH" if $no_ecdh;
243$cflags.=" -DOPENSSL_NO_ENGINE" if $no_engine; 269$cflags.=" -DOPENSSL_NO_ENGINE" if $no_engine;
244$cflags.=" -DOPENSSL_NO_HW" if $no_hw; 270$cflags.=" -DOPENSSL_NO_HW" if $no_hw;
245$cflags.=" -DOPENSSL_FIPS" if $fips; 271$cflags.=" -DOPENSSL_NO_JPAKE" if $no_jpake;
246$cflags.= " -DZLIB" if $zlib_opt; 272$cflags.= " -DZLIB" if $zlib_opt;
247$cflags.= " -DZLIB_SHARED" if $zlib_opt == 2; 273$cflags.= " -DZLIB_SHARED" if $zlib_opt == 2;
248 274
@@ -264,9 +290,9 @@ else
264 290
265$ex_libs="$l_flags$ex_libs" if ($l_flags ne ""); 291$ex_libs="$l_flags$ex_libs" if ($l_flags ne "");
266 292
293
267%shlib_ex_cflags=("SSL" => " -DOPENSSL_BUILD_SHLIBSSL", 294%shlib_ex_cflags=("SSL" => " -DOPENSSL_BUILD_SHLIBSSL",
268 "CRYPTO" => " -DOPENSSL_BUILD_SHLIBCRYPTO", 295 "CRYPTO" => " -DOPENSSL_BUILD_SHLIBCRYPTO");
269 "FIPS" => " -DOPENSSL_BUILD_SHLIBCRYPTO");
270 296
271if ($msdos) 297if ($msdos)
272 { 298 {
@@ -280,6 +306,7 @@ if ($msdos)
280$link="$bin_dir$link" if ($link !~ /^\$/); 306$link="$bin_dir$link" if ($link !~ /^\$/);
281 307
282$INSTALLTOP =~ s|/|$o|g; 308$INSTALLTOP =~ s|/|$o|g;
309$OPENSSLDIR =~ s|/|$o|g;
283 310
284############################################# 311#############################################
285# We parse in input file and 'store' info for later printing. 312# We parse in input file and 'store' info for later printing.
@@ -294,21 +321,11 @@ for (;;)
294 { 321 {
295 if ($lib ne "") 322 if ($lib ne "")
296 { 323 {
297 if ($fips && $dir =~ /^fips/) 324 $uc=$lib;
298 { 325 $uc =~ s/^lib(.*)\.a/$1/;
299 $uc = "FIPS"; 326 $uc =~ tr/a-z/A-Z/;
300 } 327 $lib_nam{$uc}=$uc;
301 else 328 $lib_obj{$uc}.=$libobj." ";
302 {
303 $uc=$lib;
304 $uc =~ s/^lib(.*)\.a/$1/;
305 $uc =~ tr/a-z/A-Z/;
306 }
307 if (($uc ne "FIPS") || $fipscanisterbuild)
308 {
309 $lib_nam{$uc}=$uc;
310 $lib_obj{$uc}.=$libobj." ";
311 }
312 } 329 }
313 last if ($val eq "FINISHED"); 330 last if ($val eq "FINISHED");
314 $lib=""; 331 $lib="";
@@ -351,130 +368,11 @@ for (;;)
351 if ($key eq "LIBNAMES" && $dir eq "engines" && $no_static_engine) 368 if ($key eq "LIBNAMES" && $dir eq "engines" && $no_static_engine)
352 { $engines.=$val } 369 { $engines.=$val }
353 370
354 if ($key eq "FIPS_EX_OBJ")
355 {
356 $fips_ex_obj=&var_add("crypto",$val,0);
357 }
358
359 if ($key eq "FIPSLIBDIR")
360 {
361 $fipslibdir=$val;
362 $fipslibdir =~ s/\/$//;
363 $fipslibdir =~ s/\//$o/g;
364 }
365
366 if ($key eq "BASEADDR")
367 { $baseaddr=$val;}
368
369 if (!($_=<IN>)) 371 if (!($_=<IN>))
370 { $_="RELATIVE_DIRECTORY=FINISHED\n"; } 372 { $_="RELATIVE_DIRECTORY=FINISHED\n"; }
371 } 373 }
372close(IN); 374close(IN);
373 375
374if ($fips)
375 {
376
377 foreach (split " ", $fips_ex_obj)
378 {
379 $fips_exclude_obj{$1} = 1 if (/\/([^\/]*)$/);
380 }
381
382 $fips_exclude_obj{"cpu_win32"} = 1;
383 $fips_exclude_obj{"bn_asm"} = 1;
384 $fips_exclude_obj{"des_enc"} = 1;
385 $fips_exclude_obj{"fcrypt_b"} = 1;
386 $fips_exclude_obj{"aes_core"} = 1;
387 $fips_exclude_obj{"aes_cbc"} = 1;
388
389 my @ltmp = split " ", $lib_obj{"CRYPTO"};
390
391
392 $lib_obj{"CRYPTO"} = "";
393
394 foreach(@ltmp)
395 {
396 if (/\/([^\/]*)$/ && exists $fips_exclude_obj{$1})
397 {
398 if ($fipscanisterbuild)
399 {
400 $lib_obj{"FIPS"} .= "$_ ";
401 }
402 }
403 else
404 {
405 $lib_obj{"CRYPTO"} .= "$_ ";
406 }
407 }
408
409 }
410
411if ($fipscanisterbuild)
412 {
413 $fips_canister_path = "\$(LIB_D)${o}fipscanister.lib" if $fips_canister_path eq "";
414 $fips_premain_c_path = "\$(LIB_D)${o}fips_premain.c";
415 }
416else
417 {
418 if ($fips_canister_path eq "")
419 {
420 $fips_canister_path = "\$(FIPSLIB_D)${o}fipscanister.lib";
421 }
422
423 if ($fips_premain_c_path eq "")
424 {
425 $fips_premain_c_path = "\$(FIPSLIB_D)${o}fips_premain.c";
426 }
427 }
428
429if ($fips)
430 {
431 if ($fips_sha1_exe_path eq "")
432 {
433 $fips_sha1_exe_path =
434 "\$(BIN_D)${o}fips_standalone_sha1$exep";
435 }
436 }
437 else
438 {
439 $fips_sha1_exe_path = "";
440 }
441
442if ($fips_premain_dso_exe_path eq "")
443 {
444 $fips_premain_dso_exe_path = "\$(BIN_D)${o}fips_premain_dso$exep";
445 }
446
447# $ex_build_targets .= "\$(BIN_D)${o}\$(E_PREMAIN_DSO)$exep" if ($fips);
448
449#$ex_l_libs .= " \$(L_FIPS)" if $fipsdso;
450
451if ($fips)
452 {
453 if (!$shlib)
454 {
455 $ex_build_targets .= " \$(LIB_D)$o$crypto_compat \$(PREMAIN_DSO_EXE)";
456 $ex_l_libs .= " \$(O_FIPSCANISTER)";
457 $ex_libs_dep .= " \$(O_FIPSCANISTER)" if $fipscanisterbuild;
458 }
459 if ($fipscanisterbuild)
460 {
461 $fipslibdir = "\$(LIB_D)";
462 }
463 else
464 {
465 if ($fipslibdir eq "")
466 {
467 open (IN, "util/fipslib_path.txt") || fipslib_error();
468 $fipslibdir = <IN>;
469 chomp $fipslibdir;
470 close IN;
471 }
472 fips_check_files($fipslibdir,
473 "fipscanister.lib", "fipscanister.lib.sha1",
474 "fips_premain.c", "fips_premain.c.sha1");
475 }
476 }
477
478if ($shlib) 376if ($shlib)
479 { 377 {
480 $extra_install= <<"EOF"; 378 $extra_install= <<"EOF";
@@ -520,6 +418,7 @@ $defs .= $preamble if defined $preamble;
520 418
521$defs.= <<"EOF"; 419$defs.= <<"EOF";
522INSTALLTOP=$INSTALLTOP 420INSTALLTOP=$INSTALLTOP
421OPENSSLDIR=$OPENSSLDIR
523 422
524# Set your compiler options 423# Set your compiler options
525PLATFORM=$platform 424PLATFORM=$platform
@@ -540,32 +439,6 @@ SRC_D=$src_dir
540LINK=$link 439LINK=$link
541LFLAGS=$lflags 440LFLAGS=$lflags
542RSC=$rsc 441RSC=$rsc
543FIPSLINK=\$(PERL) util${o}fipslink.pl
544
545AES_ASM_OBJ=$aes_asm_obj
546AES_ASM_SRC=$aes_asm_src
547BN_ASM_OBJ=$bn_asm_obj
548BN_ASM_SRC=$bn_asm_src
549BNCO_ASM_OBJ=$bnco_asm_obj
550BNCO_ASM_SRC=$bnco_asm_src
551DES_ENC_OBJ=$des_enc_obj
552DES_ENC_SRC=$des_enc_src
553BF_ENC_OBJ=$bf_enc_obj
554BF_ENC_SRC=$bf_enc_src
555CAST_ENC_OBJ=$cast_enc_obj
556CAST_ENC_SRC=$cast_enc_src
557RC4_ENC_OBJ=$rc4_enc_obj
558RC4_ENC_SRC=$rc4_enc_src
559RC5_ENC_OBJ=$rc5_enc_obj
560RC5_ENC_SRC=$rc5_enc_src
561MD5_ASM_OBJ=$md5_asm_obj
562MD5_ASM_SRC=$md5_asm_src
563SHA1_ASM_OBJ=$sha1_asm_obj
564SHA1_ASM_SRC=$sha1_asm_src
565RMD160_ASM_OBJ=$rmd160_asm_obj
566RMD160_ASM_SRC=$rmd160_asm_src
567CPUID_ASM_OBJ=$cpuid_asm_obj
568CPUID_ASM_SRC=$cpuid_asm_src
569 442
570# The output directory for everything intersting 443# The output directory for everything intersting
571OUT_D=$out_dir 444OUT_D=$out_dir
@@ -584,17 +457,6 @@ MKLIB=$bin_dir$mklib
584MLFLAGS=$mlflags 457MLFLAGS=$mlflags
585ASM=$bin_dir$asm 458ASM=$bin_dir$asm
586 459
587# FIPS validated module and support file locations
588
589E_PREMAIN_DSO=fips_premain_dso
590
591FIPSLIB_D=$fipslibdir
592BASEADDR=$baseaddr
593FIPS_PREMAIN_SRC=$fips_premain_c_path
594O_FIPSCANISTER=$fips_canister_path
595FIPS_SHA1_EXE=$fips_sha1_exe_path
596PREMAIN_DSO_EXE=$fips_premain_dso_exe_path
597
598###################################################### 460######################################################
599# You should not need to touch anything below this point 461# You should not need to touch anything below this point
600###################################################### 462######################################################
@@ -602,7 +464,6 @@ PREMAIN_DSO_EXE=$fips_premain_dso_exe_path
602E_EXE=openssl 464E_EXE=openssl
603SSL=$ssl 465SSL=$ssl
604CRYPTO=$crypto 466CRYPTO=$crypto
605LIBFIPS=libosslfips
606 467
607# BIN_D - Binary output directory 468# BIN_D - Binary output directory
608# TEST_D - Binary test file output directory 469# TEST_D - Binary test file output directory
@@ -623,14 +484,12 @@ INCL_D=\$(TMP_D)
623 484
624O_SSL= \$(LIB_D)$o$plib\$(SSL)$shlibp 485O_SSL= \$(LIB_D)$o$plib\$(SSL)$shlibp
625O_CRYPTO= \$(LIB_D)$o$plib\$(CRYPTO)$shlibp 486O_CRYPTO= \$(LIB_D)$o$plib\$(CRYPTO)$shlibp
626O_FIPS= \$(LIB_D)$o$plib\$(LIBFIPS)$shlibp
627SO_SSL= $plib\$(SSL)$so_shlibp 487SO_SSL= $plib\$(SSL)$so_shlibp
628SO_CRYPTO= $plib\$(CRYPTO)$so_shlibp 488SO_CRYPTO= $plib\$(CRYPTO)$so_shlibp
629L_SSL= \$(LIB_D)$o$plib\$(SSL)$libp 489L_SSL= \$(LIB_D)$o$plib\$(SSL)$libp
630L_CRYPTO= \$(LIB_D)$o$plib\$(CRYPTO)$libp 490L_CRYPTO= \$(LIB_D)$o$plib\$(CRYPTO)$libp
631L_FIPS= \$(LIB_D)$o$plib\$(LIBFIPS)$libp
632 491
633L_LIBS= \$(L_SSL) \$(L_CRYPTO) $ex_l_libs 492L_LIBS= \$(L_SSL) \$(L_CRYPTO)
634 493
635###################################################### 494######################################################
636# Don't touch anything below this point 495# Don't touch anything below this point
@@ -640,13 +499,13 @@ INC=-I\$(INC_D) -I\$(INCL_D)
640APP_CFLAGS=\$(INC) \$(CFLAG) \$(APP_CFLAG) 499APP_CFLAGS=\$(INC) \$(CFLAG) \$(APP_CFLAG)
641LIB_CFLAGS=\$(INC) \$(CFLAG) \$(LIB_CFLAG) 500LIB_CFLAGS=\$(INC) \$(CFLAG) \$(LIB_CFLAG)
642SHLIB_CFLAGS=\$(INC) \$(CFLAG) \$(LIB_CFLAG) \$(SHLIB_CFLAG) 501SHLIB_CFLAGS=\$(INC) \$(CFLAG) \$(LIB_CFLAG) \$(SHLIB_CFLAG)
643LIBS_DEP=\$(O_CRYPTO) \$(O_SSL) $ex_libs_dep 502LIBS_DEP=\$(O_CRYPTO) \$(O_SSL)
644 503
645############################################# 504#############################################
646EOF 505EOF
647 506
648$rules=<<"EOF"; 507$rules=<<"EOF";
649all: banner \$(TMP_D) \$(BIN_D) \$(TEST_D) \$(LIB_D) \$(INCO_D) headers \$(FIPS_SHA1_EXE) lib exe $ex_build_targets 508all: banner \$(TMP_D) \$(BIN_D) \$(TEST_D) \$(LIB_D) \$(INCO_D) headers lib exe
650 509
651banner: 510banner:
652$banner 511$banner
@@ -683,8 +542,9 @@ install: all
683 \$(MKDIR) \"\$(INSTALLTOP)${o}include${o}openssl\" 542 \$(MKDIR) \"\$(INSTALLTOP)${o}include${o}openssl\"
684 \$(MKDIR) \"\$(INSTALLTOP)${o}lib\" 543 \$(MKDIR) \"\$(INSTALLTOP)${o}lib\"
685 \$(CP) \"\$(INCO_D)${o}*.\[ch\]\" \"\$(INSTALLTOP)${o}include${o}openssl\" 544 \$(CP) \"\$(INCO_D)${o}*.\[ch\]\" \"\$(INSTALLTOP)${o}include${o}openssl\"
686 \$(CP) \"\$(BIN_D)$o\$(E_EXE)$exep\" \"\$(INSTALLTOP)${o}bin\" 545 \$(CP) \"\$(BIN_D)$o\$(E_EXE)$exep \$(INSTALLTOP)${o}bin\"
687 \$(CP) \"apps${o}openssl.cnf\" \"\$(INSTALLTOP)\" 546 \$(MKDIR) \"\$(OPENSSLDIR)\"
547 \$(CP) apps${o}openssl.cnf \"\$(OPENSSLDIR)\"
688$extra_install 548$extra_install
689 549
690 550
@@ -761,26 +621,6 @@ $rules.=&do_compile_rule("\$(OBJ_D)",$test,"\$(APP_CFLAGS)");
761$defs.=&do_defs("E_OBJ",$e_exe,"\$(OBJ_D)",$obj); 621$defs.=&do_defs("E_OBJ",$e_exe,"\$(OBJ_D)",$obj);
762$rules.=&do_compile_rule("\$(OBJ_D)",$e_exe,'-DMONOLITH $(APP_CFLAGS)'); 622$rules.=&do_compile_rule("\$(OBJ_D)",$e_exe,'-DMONOLITH $(APP_CFLAGS)');
763 623
764# Special case rules for fips_start and fips_end fips_premain_dso
765
766if ($fips)
767 {
768 if ($fipscanisterbuild)
769 {
770 $rules.=&cc_compile_target("\$(OBJ_D)${o}fips_start$obj",
771 "fips${o}fips_canister.c",
772 "-DFIPS_START \$(SHLIB_CFLAGS)");
773 $rules.=&cc_compile_target("\$(OBJ_D)${o}fips_end$obj",
774 "fips${o}fips_canister.c", "\$(SHLIB_CFLAGS)");
775 }
776 $rules.=&cc_compile_target("\$(OBJ_D)${o}fips_standalone_sha1$obj",
777 "fips${o}sha${o}fips_standalone_sha1.c",
778 "\$(SHLIB_CFLAGS)");
779 $rules.=&cc_compile_target("\$(OBJ_D)${o}\$(E_PREMAIN_DSO)$obj",
780 "fips${o}fips_premain.c",
781 "-DFINGERPRINT_PREMAIN_DSO_LOAD \$(SHLIB_CFLAGS)");
782 }
783
784foreach (values %lib_nam) 624foreach (values %lib_nam)
785 { 625 {
786 $lib_obj=$lib_obj{$_}; 626 $lib_obj=$lib_obj{$_};
@@ -792,78 +632,14 @@ foreach (values %lib_nam)
792 next; 632 next;
793 } 633 }
794 634
795 if ((!$fips && ($_ eq "CRYPTO")) || ($fips && ($_ eq "FIPS")))
796 {
797 if ($cpuid_asm_obj ne "")
798 {
799 $lib_obj =~ s/(\S*\/cryptlib\S*)/$1 \$(CPUID_ASM_OBJ)/;
800 $rules.=&do_asm_rule($cpuid_asm_obj,$cpuid_asm_src);
801 }
802 if ($aes_asm_obj ne "")
803 {
804 $lib_obj =~ s/\s(\S*\/aes_core\S*)/ \$(AES_ASM_OBJ)/;
805 $lib_obj =~ s/\s\S*\/aes_cbc\S*//;
806 $rules.=&do_asm_rule($aes_asm_obj,$aes_asm_src);
807 }
808 if ($sha1_asm_obj ne "")
809 {
810 $lib_obj =~ s/\s(\S*\/sha1dgst\S*)/ $1 \$(SHA1_ASM_OBJ)/;
811 $rules.=&do_asm_rule($sha1_asm_obj,$sha1_asm_src);
812 }
813 if ($bn_asm_obj ne "")
814 {
815 $lib_obj =~ s/\s\S*\/bn_asm\S*/ \$(BN_ASM_OBJ)/;
816 $rules.=&do_asm_rule($bn_asm_obj,$bn_asm_src);
817 }
818 if ($bnco_asm_obj ne "")
819 {
820 $lib_obj .= "\$(BNCO_ASM_OBJ)";
821 $rules.=&do_asm_rule($bnco_asm_obj,$bnco_asm_src);
822 }
823 if ($des_enc_obj ne "")
824 {
825 $lib_obj =~ s/\s\S*des_enc\S*/ \$(DES_ENC_OBJ)/;
826 $lib_obj =~ s/\s\S*\/fcrypt_b\S*\s*/ /;
827 $rules.=&do_asm_rule($des_enc_obj,$des_enc_src);
828 }
829 }
830 if (($bf_enc_obj ne "") && ($_ eq "CRYPTO"))
831 {
832 $lib_obj =~ s/\s\S*\/bf_enc\S*/ \$(BF_ENC_OBJ)/;
833 $rules.=&do_asm_rule($bf_enc_obj,$bf_enc_src);
834 }
835 if (($cast_enc_obj ne "") && ($_ eq "CRYPTO"))
836 {
837 $lib_obj =~ s/(\s\S*\/c_enc\S*)/ \$(CAST_ENC_OBJ)/;
838 $rules.=&do_asm_rule($cast_enc_obj,$cast_enc_src);
839 }
840 if (($rc4_enc_obj ne "") && ($_ eq "CRYPTO"))
841 {
842 $lib_obj =~ s/\s\S*\/rc4_enc\S*/ \$(RC4_ENC_OBJ)/;
843 $rules.=&do_asm_rule($rc4_enc_obj,$rc4_enc_src);
844 }
845 if (($rc5_enc_obj ne "") && ($_ eq "CRYPTO"))
846 {
847 $lib_obj =~ s/\s\S*\/rc5_enc\S*/ \$(RC5_ENC_OBJ)/;
848 $rules.=&do_asm_rule($rc5_enc_obj,$rc5_enc_src);
849 }
850 if (($md5_asm_obj ne "") && ($_ eq "CRYPTO"))
851 {
852 $lib_obj =~ s/\s(\S*\/md5_dgst\S*)/ $1 \$(MD5_ASM_OBJ)/;
853 $rules.=&do_asm_rule($md5_asm_obj,$md5_asm_src);
854 }
855 if (($rmd160_asm_obj ne "") && ($_ eq "CRYPTO"))
856 {
857 $lib_obj =~ s/\s(\S*\/rmd_dgst\S*)/ $1 \$(RMD160_ASM_OBJ)/;
858 $rules.=&do_asm_rule($rmd160_asm_obj,$rmd160_asm_src);
859 }
860 $defs.=&do_defs(${_}."OBJ",$lib_obj,"\$(OBJ_D)",$obj); 635 $defs.=&do_defs(${_}."OBJ",$lib_obj,"\$(OBJ_D)",$obj);
861 $lib=($slib)?" \$(SHLIB_CFLAGS)".$shlib_ex_cflags{$_}:" \$(LIB_CFLAGS)"; 636 $lib=($slib)?" \$(SHLIB_CFLAGS)".$shlib_ex_cflags{$_}:" \$(LIB_CFLAGS)";
862 $rules.=&do_compile_rule("\$(OBJ_D)",$lib_obj{$_},$lib); 637 $rules.=&do_compile_rule("\$(OBJ_D)",$lib_obj{$_},$lib);
863 } 638 }
864 639
865# hack to add version info on MSVC 640# hack to add version info on MSVC
866if (($platform eq "VC-WIN32") || ($platform eq "VC-NT")) { 641if (($platform eq "VC-WIN32") || ($platform eq "VC-WIN64A")
642 || ($platform eq "VC-WIN64I") || ($platform eq "VC-NT")) {
867 $rules.= <<"EOF"; 643 $rules.= <<"EOF";
868\$(OBJ_D)\\\$(CRYPTO).res: ms\\version32.rc 644\$(OBJ_D)\\\$(CRYPTO).res: ms\\version32.rc
869 \$(RSC) /fo"\$(OBJ_D)\\\$(CRYPTO).res" /d CRYPTO ms\\version32.rc 645 \$(RSC) /fo"\$(OBJ_D)\\\$(CRYPTO).res" /d CRYPTO ms\\version32.rc
@@ -871,43 +647,15 @@ if (($platform eq "VC-WIN32") || ($platform eq "VC-NT")) {
871\$(OBJ_D)\\\$(SSL).res: ms\\version32.rc 647\$(OBJ_D)\\\$(SSL).res: ms\\version32.rc
872 \$(RSC) /fo"\$(OBJ_D)\\\$(SSL).res" /d SSL ms\\version32.rc 648 \$(RSC) /fo"\$(OBJ_D)\\\$(SSL).res" /d SSL ms\\version32.rc
873 649
874\$(OBJ_D)\\\$(LIBFIPS).res: ms\\version32.rc
875 \$(RSC) /fo"\$(OBJ_D)\\\$(LIBFIPS).res" /d FIPS ms\\version32.rc
876
877EOF 650EOF
878} 651}
879 652
880$defs.=&do_defs("T_EXE",$test,"\$(TEST_D)",$exep); 653$defs.=&do_defs("T_EXE",$test,"\$(TEST_D)",$exep);
881foreach (split(/\s+/,$test)) 654foreach (split(/\s+/,$test))
882 { 655 {
883 my $t_libs;
884 $t=&bname($_); 656 $t=&bname($_);
885 my $ltype;
886 # Check to see if test program is FIPS
887 if ($fips && /fips/)
888 {
889 # If fipsdso link to libosslfips.dll
890 # otherwise perform static link to
891 # $(O_FIPSCANISTER)
892 if ($fipsdso)
893 {
894 $t_libs = "\$(L_FIPS)";
895 $ltype = 0;
896 }
897 else
898 {
899 $t_libs = "\$(O_FIPSCANISTER)";
900 $ltype = 2;
901 }
902 }
903 else
904 {
905 $t_libs = "\$(L_LIBS)";
906 $ltype = 0;
907 }
908
909 $tt="\$(OBJ_D)${o}$t${obj}"; 657 $tt="\$(OBJ_D)${o}$t${obj}";
910 $rules.=&do_link_rule("\$(TEST_D)$o$t$exep",$tt,"\$(LIBS_DEP)","$t_libs \$(EX_LIBS)", $ltype); 658 $rules.=&do_link_rule("\$(TEST_D)$o$t$exep",$tt,"\$(LIBS_DEP)","\$(L_LIBS) \$(EX_LIBS)");
911 } 659 }
912 660
913$defs.=&do_defs("E_SHLIB",$engines,"\$(ENG_D)",$shlibp); 661$defs.=&do_defs("E_SHLIB",$engines,"\$(ENG_D)",$shlibp);
@@ -921,69 +669,9 @@ foreach (split(/\s+/,$engines))
921 669
922 670
923$rules.= &do_lib_rule("\$(SSLOBJ)","\$(O_SSL)",$ssl,$shlib,"\$(SO_SSL)"); 671$rules.= &do_lib_rule("\$(SSLOBJ)","\$(O_SSL)",$ssl,$shlib,"\$(SO_SSL)");
672$rules.= &do_lib_rule("\$(CRYPTOOBJ)","\$(O_CRYPTO)",$crypto,$shlib,"\$(SO_CRYPTO)");
924 673
925if ($fips) 674$rules.=&do_link_rule("\$(BIN_D)$o\$(E_EXE)$exep","\$(E_OBJ)","\$(LIBS_DEP)","\$(L_LIBS) \$(EX_LIBS)");
926 {
927 if ($shlib)
928 {
929 if ($fipsdso)
930 {
931 $rules.= &do_lib_rule("\$(CRYPTOOBJ)",
932 "\$(O_CRYPTO)", "$crypto",
933 $shlib, "", "");
934 $rules.= &do_lib_rule(
935 "\$(O_FIPSCANISTER)",
936 "\$(O_FIPS)", "\$(LIBFIPS)",
937 $shlib, "\$(SO_CRYPTO)", "\$(BASEADDR)");
938 $rules.= &do_sdef_rule();
939 }
940 else
941 {
942 $rules.= &do_lib_rule(
943 "\$(CRYPTOOBJ) \$(O_FIPSCANISTER)",
944 "\$(O_CRYPTO)", "$crypto",
945 $shlib, "\$(SO_CRYPTO)", "\$(BASEADDR)");
946 }
947 }
948 else
949 {
950 $rules.= &do_lib_rule("\$(CRYPTOOBJ)",
951 "\$(O_CRYPTO)",$crypto,$shlib,"\$(SO_CRYPTO)", "");
952 $rules.= &do_lib_rule("\$(CRYPTOOBJ) \$(FIPSOBJ)",
953 "\$(LIB_D)$o$crypto_compat",$crypto,$shlib,"\$(SO_CRYPTO)", "");
954 }
955 }
956 else
957 {
958 $rules.= &do_lib_rule("\$(CRYPTOOBJ)","\$(O_CRYPTO)",$crypto,$shlib,
959 "\$(SO_CRYPTO)");
960 }
961
962if ($fips)
963 {
964 if ($fipscanisterbuild)
965 {
966 $rules.= &do_rlink_rule("\$(O_FIPSCANISTER)",
967 "\$(OBJ_D)${o}fips_start$obj",
968 "\$(FIPSOBJ)",
969 "\$(OBJ_D)${o}fips_end$obj",
970 "\$(FIPS_SHA1_EXE)", "");
971 $rules.=&do_link_rule("\$(FIPS_SHA1_EXE)",
972 "\$(OBJ_D)${o}fips_standalone_sha1$obj \$(OBJ_D)${o}sha1dgst$obj \$(SHA1_ASM_OBJ)",
973 "","\$(EX_LIBS)", 1);
974 }
975 else
976 {
977 $rules.=&do_link_rule("\$(FIPS_SHA1_EXE)",
978 "\$(OBJ_D)${o}fips_standalone_sha1$obj \$(O_FIPSCANISTER)",
979 "","", 1);
980
981 }
982 $rules.=&do_link_rule("\$(PREMAIN_DSO_EXE)","\$(OBJ_D)${o}\$(E_PREMAIN_DSO)$obj \$(CRYPTOOBJ) \$(O_FIPSCANISTER)","","\$(EX_LIBS)", 1);
983
984 }
985
986$rules.=&do_link_rule("\$(BIN_D)$o\$(E_EXE)$exep","\$(E_OBJ)","\$(LIBS_DEP)","\$(L_LIBS) \$(EX_LIBS)", ($fips && !$shlib) ? 2 : 0);
987 675
988print $defs; 676print $defs;
989 677
@@ -1022,7 +710,6 @@ sub var_add
1022 return("") if $no_ec && $dir =~ /\/ec/; 710 return("") if $no_ec && $dir =~ /\/ec/;
1023 return("") if $no_cms && $dir =~ /\/cms/; 711 return("") if $no_cms && $dir =~ /\/cms/;
1024 return("") if $no_jpake && $dir =~ /\/jpake/; 712 return("") if $no_jpake && $dir =~ /\/jpake/;
1025 return("") if !$fips && $dir =~ /^fips/;
1026 if ($no_des && $dir =~ /\/des/) 713 if ($no_des && $dir =~ /\/des/)
1027 { 714 {
1028 if ($val =~ /read_pwd/) 715 if ($val =~ /read_pwd/)
@@ -1034,6 +721,7 @@ sub var_add
1034 return("") if $no_sock && $dir =~ /\/proxy/; 721 return("") if $no_sock && $dir =~ /\/proxy/;
1035 return("") if $no_bf && $dir =~ /\/bf/; 722 return("") if $no_bf && $dir =~ /\/bf/;
1036 return("") if $no_cast && $dir =~ /\/cast/; 723 return("") if $no_cast && $dir =~ /\/cast/;
724 return("") if $no_whirlpool && $dir =~ /\/whrlpool/;
1037 725
1038 $val =~ s/^\s*(.*)\s*$/$1/; 726 $val =~ s/^\s*(.*)\s*$/$1/;
1039 @a=split(/\s+/,$val); 727 @a=split(/\s+/,$val);
@@ -1051,8 +739,8 @@ sub var_add
1051 @a=grep(!/^e_camellia$/,@a) if $no_camellia; 739 @a=grep(!/^e_camellia$/,@a) if $no_camellia;
1052 @a=grep(!/^e_seed$/,@a) if $no_seed; 740 @a=grep(!/^e_seed$/,@a) if $no_seed;
1053 741
1054 @a=grep(!/(^s2_)|(^s23_)/,@a) if $no_ssl2; 742 #@a=grep(!/(^s2_)|(^s23_)/,@a) if $no_ssl2;
1055 @a=grep(!/(^s3_)|(^s23_)/,@a) if $no_ssl3; 743 #@a=grep(!/(^s3_)|(^s23_)/,@a) if $no_ssl3;
1056 744
1057 @a=grep(!/(_sock$)|(_acpt$)|(_conn$)|(^pxy_)/,@a) if $no_sock; 745 @a=grep(!/(_sock$)|(_acpt$)|(_conn$)|(^pxy_)/,@a) if $no_sock;
1058 746
@@ -1126,6 +814,7 @@ sub do_defs
1126 else { $pf=$postfix; } 814 else { $pf=$postfix; }
1127 if ($_ =~ /BN_ASM/) { $t="$_ "; } 815 if ($_ =~ /BN_ASM/) { $t="$_ "; }
1128 elsif ($_ =~ /BNCO_ASM/){ $t="$_ "; } 816 elsif ($_ =~ /BNCO_ASM/){ $t="$_ "; }
817 elsif ($_ =~ /AES_ASM/){ $t="$_ "; }
1129 elsif ($_ =~ /DES_ENC/) { $t="$_ "; } 818 elsif ($_ =~ /DES_ENC/) { $t="$_ "; }
1130 elsif ($_ =~ /BF_ENC/) { $t="$_ "; } 819 elsif ($_ =~ /BF_ENC/) { $t="$_ "; }
1131 elsif ($_ =~ /CAST_ENC/){ $t="$_ "; } 820 elsif ($_ =~ /CAST_ENC/){ $t="$_ "; }
@@ -1133,8 +822,8 @@ sub do_defs
1133 elsif ($_ =~ /RC5_ENC/) { $t="$_ "; } 822 elsif ($_ =~ /RC5_ENC/) { $t="$_ "; }
1134 elsif ($_ =~ /MD5_ASM/) { $t="$_ "; } 823 elsif ($_ =~ /MD5_ASM/) { $t="$_ "; }
1135 elsif ($_ =~ /SHA1_ASM/){ $t="$_ "; } 824 elsif ($_ =~ /SHA1_ASM/){ $t="$_ "; }
1136 elsif ($_ =~ /AES_ASM/){ $t="$_ "; }
1137 elsif ($_ =~ /RMD160_ASM/){ $t="$_ "; } 825 elsif ($_ =~ /RMD160_ASM/){ $t="$_ "; }
826 elsif ($_ =~ /WHIRLPOOL_ASM/){ $t="$_ "; }
1138 elsif ($_ =~ /CPUID_ASM/){ $t="$_ "; } 827 elsif ($_ =~ /CPUID_ASM/){ $t="$_ "; }
1139 else { $t="$location${o}$_$pf "; } 828 else { $t="$location${o}$_$pf "; }
1140 829
@@ -1142,7 +831,7 @@ sub do_defs
1142 $ret.=$t; 831 $ret.=$t;
1143 } 832 }
1144 # hack to add version info on MSVC 833 # hack to add version info on MSVC
1145 if ($shlib && (($platform eq "VC-WIN32") || ($platform eq "VC-NT"))) 834 if ($shlib && (($platform eq "VC-WIN32") || ($platfrom eq "VC-WIN64I") || ($platform eq "VC-WIN64A") || ($platform eq "VC-NT")))
1146 { 835 {
1147 if ($var eq "CRYPTOOBJ") 836 if ($var eq "CRYPTOOBJ")
1148 { $ret.="\$(OBJ_D)\\\$(CRYPTO).res "; } 837 { $ret.="\$(OBJ_D)\\\$(CRYPTO).res "; }
@@ -1162,6 +851,13 @@ sub bname
1162 return($ret); 851 return($ret);
1163 } 852 }
1164 853
854# return the leading path
855sub dname
856 {
857 my $ret=shift;
858 $ret =~ s/(^.*)[\\\/][^\\\/]+$/$1/;
859 return($ret);
860 }
1165 861
1166############################################################## 862##############################################################
1167# do a rule for each file that says 'compile' to new direcory 863# do a rule for each file that says 'compile' to new direcory
@@ -1169,19 +865,61 @@ sub bname
1169sub do_compile_rule 865sub do_compile_rule
1170 { 866 {
1171 local($to,$files,$ex)=@_; 867 local($to,$files,$ex)=@_;
1172 local($ret,$_,$n); 868 local($ret,$_,$n,$d,$s);
1173 869
1174 $files =~ s/\//$o/g if $o ne '/'; 870 $files =~ s/\//$o/g if $o ne '/';
1175 foreach (split(/\s+/,$files)) 871 foreach (split(/\s+/,$files))
1176 { 872 {
1177 $n=&bname($_); 873 $n=&bname($_);
1178 $ret.=&cc_compile_target("$to${o}$n$obj","${_}.c",$ex) 874 $d=&dname($_);
875 if (-f "${_}.c")
876 {
877 $ret.=&cc_compile_target("$to${o}$n$obj","${_}.c",$ex)
878 }
879 elsif (-f ($s="${d}${o}asm${o}${n}.pl") or
880 ($s=~s/sha256/sha512/ and -f $s) or
881 -f ($s="${d}${o}${n}.pl"))
882 {
883 $ret.=&perlasm_compile_target("$to${o}$n$obj",$s,$n);
884 }
885 elsif (-f ($s="${d}${o}asm${o}${n}.S") or
886 -f ($s="${d}${o}${n}.S"))
887 {
888 $ret.=&Sasm_compile_target("$to${o}$n$obj",$s,$n);
889 }
890 else { die "no rule for $_"; }
1179 } 891 }
1180 return($ret); 892 return($ret);
1181 } 893 }
1182 894
1183############################################################## 895##############################################################
1184# do a rule for each file that says 'compile' to new direcory 896# do a rule for each file that says 'compile' to new direcory
897sub perlasm_compile_target
898 {
899 my($target,$source,$bname)=@_;
900 my($ret);
901
902 $bname =~ s/(.*)\.[^\.]$/$1/;
903 $ret ="\$(TMP_D)$o$bname.asm: $source\n";
904 $ret.="\t\$(PERL) $source $asmtype \$(CFLAG) >\$\@\n\n";
905 $ret.="$target: \$(TMP_D)$o$bname.asm\n";
906 $ret.="\t\$(ASM) $afile\$\@ \$(TMP_D)$o$bname.asm\n\n";
907 return($ret);
908 }
909
910sub Sasm_compile_target
911 {
912 my($target,$source,$bname)=@_;
913 my($ret);
914
915 $bname =~ s/(.*)\.[^\.]$/$1/;
916 $ret ="\$(TMP_D)$o$bname.asm: $source\n";
917 $ret.="\t\$(CC) -E \$(CFLAG) $source >\$\@\n\n";
918 $ret.="$target: \$(TMP_D)$o$bname.asm\n";
919 $ret.="\t\$(ASM) $afile\$\@ \$(TMP_D)$o$bname.asm\n\n";
920 return($ret);
921 }
922
1185sub cc_compile_target 923sub cc_compile_target
1186 { 924 {
1187 local($target,$source,$ex_flags)=@_; 925 local($target,$source,$ex_flags)=@_;
@@ -1204,13 +942,25 @@ sub do_asm_rule
1204 $target =~ s/\//$o/g if $o ne "/"; 942 $target =~ s/\//$o/g if $o ne "/";
1205 $src =~ s/\//$o/g if $o ne "/"; 943 $src =~ s/\//$o/g if $o ne "/";
1206 944
1207 @s=split(/\s+/,$src);
1208 @t=split(/\s+/,$target); 945 @t=split(/\s+/,$target);
946 @s=split(/\s+/,$src);
947
1209 948
1210 for ($i=0; $i<=$#s; $i++) 949 for ($i=0; $i<=$#s; $i++)
1211 { 950 {
1212 $ret.="$t[$i]: $s[$i]\n"; 951 my $objfile = $t[$i];
1213 $ret.="\t\$(ASM) $afile$t[$i] \$(SRC_D)$o$s[$i]\n\n"; 952 my $srcfile = $s[$i];
953
954 if ($perl_asm == 1)
955 {
956 my $plasm = $objfile;
957 $plasm =~ s/${obj}/.pl/;
958 $ret.="$srcfile: $plasm\n";
959 $ret.="\t\$(PERL) $plasm $asmtype \$(CFLAG) >$srcfile\n\n";
960 }
961
962 $ret.="$objfile: $srcfile\n";
963 $ret.="\t\$(ASM) $afile$objfile \$(SRC_D)$o$srcfile\n\n";
1214 } 964 }
1215 return($ret); 965 return($ret);
1216 } 966 }
@@ -1274,6 +1024,7 @@ sub read_options
1274 "no-sha1" => \$no_sha1, 1024 "no-sha1" => \$no_sha1,
1275 "no-ripemd" => \$no_ripemd, 1025 "no-ripemd" => \$no_ripemd,
1276 "no-mdc2" => \$no_mdc2, 1026 "no-mdc2" => \$no_mdc2,
1027 "no-whirlpool" => \$no_whirlpool,
1277 "no-patents" => 1028 "no-patents" =>
1278 [\$no_rc2, \$no_rc4, \$no_rc5, \$no_idea, \$no_rsa], 1029 [\$no_rc2, \$no_rc4, \$no_rc5, \$no_idea, \$no_rsa],
1279 "no-rsa" => \$no_rsa, 1030 "no-rsa" => \$no_rsa,
@@ -1282,7 +1033,6 @@ sub read_options
1282 "no-hmac" => \$no_hmac, 1033 "no-hmac" => \$no_hmac,
1283 "no-asm" => \$no_asm, 1034 "no-asm" => \$no_asm,
1284 "nasm" => \$nasm, 1035 "nasm" => \$nasm,
1285 "ml64" => \$ml64,
1286 "nw-nasm" => \$nw_nasm, 1036 "nw-nasm" => \$nw_nasm,
1287 "nw-mwasm" => \$nw_mwasm, 1037 "nw-mwasm" => \$nw_mwasm,
1288 "gaswin" => \$gaswin, 1038 "gaswin" => \$gaswin,
@@ -1291,7 +1041,6 @@ sub read_options
1291 "no-tlsext" => \$no_tlsext, 1041 "no-tlsext" => \$no_tlsext,
1292 "no-cms" => \$no_cms, 1042 "no-cms" => \$no_cms,
1293 "no-jpake" => \$no_jpake, 1043 "no-jpake" => \$no_jpake,
1294 "no-capieng" => \$no_capieng,
1295 "no-err" => \$no_err, 1044 "no-err" => \$no_err,
1296 "no-sock" => \$no_sock, 1045 "no-sock" => \$no_sock,
1297 "no-krb5" => \$no_krb5, 1046 "no-krb5" => \$no_krb5,
@@ -1316,11 +1065,9 @@ sub read_options
1316 "no-rfc3779" => 0, 1065 "no-rfc3779" => 0,
1317 "no-montasm" => 0, 1066 "no-montasm" => 0,
1318 "no-shared" => 0, 1067 "no-shared" => 0,
1068 "no-store" => 0,
1319 "no-zlib" => 0, 1069 "no-zlib" => 0,
1320 "no-zlib-dynamic" => 0, 1070 "no-zlib-dynamic" => 0,
1321 "fips" => \$fips,
1322 "fipscanisterbuild" => [\$fips, \$fipscanisterbuild],
1323 "fipsdso" => [\$fips, \$fipscanisterbuild, \$fipsdso],
1324 ); 1071 );
1325 1072
1326 if (exists $valid_options{$_}) 1073 if (exists $valid_options{$_})
@@ -1397,31 +1144,3 @@ sub read_options
1397 else { return(0); } 1144 else { return(0); }
1398 return(1); 1145 return(1);
1399 } 1146 }
1400
1401sub fipslib_error
1402 {
1403 print STDERR "***FIPS module directory sanity check failed***\n";
1404 print STDERR "FIPS module build failed, or was deleted\n";
1405 print STDERR "Please rebuild FIPS module.\n";
1406 exit 1;
1407 }
1408
1409sub fips_check_files
1410 {
1411 my $dir = shift @_;
1412 my $ret = 1;
1413 if (!-d $dir)
1414 {
1415 print STDERR "FIPS module directory $dir does not exist\n";
1416 fipslib_error();
1417 }
1418 foreach (@_)
1419 {
1420 if (!-f "$dir${o}$_")
1421 {
1422 print STDERR "FIPS module file $_ does not exist!\n";
1423 $ret = 0;
1424 }
1425 }
1426 fipslib_error() if ($ret == 0);
1427 }
diff --git a/src/lib/libcrypto/util/mkdef.pl b/src/lib/libcrypto/util/mkdef.pl
index 5ae9ebb619..a4a17e3ae9 100644
--- a/src/lib/libcrypto/util/mkdef.pl
+++ b/src/lib/libcrypto/util/mkdef.pl
@@ -69,7 +69,7 @@ my $do_ctestall = 0;
69my $do_checkexist = 0; 69my $do_checkexist = 0;
70 70
71my $VMSVAX=0; 71my $VMSVAX=0;
72my $VMSAlpha=0; 72my $VMSNonVAX=0;
73my $VMS=0; 73my $VMS=0;
74my $W32=0; 74my $W32=0;
75my $W16=0; 75my $W16=0;
@@ -79,12 +79,13 @@ my $OS2=0;
79my $safe_stack_def = 0; 79my $safe_stack_def = 0;
80 80
81my @known_platforms = ( "__FreeBSD__", "PERL5", "NeXT", 81my @known_platforms = ( "__FreeBSD__", "PERL5", "NeXT",
82 "EXPORT_VAR_AS_FUNCTION", "ZLIB", "OPENSSL_FIPS"); 82 "EXPORT_VAR_AS_FUNCTION", "ZLIB" );
83my @known_ossl_platforms = ( "VMS", "WIN16", "WIN32", "WINNT", "OS2" ); 83my @known_ossl_platforms = ( "VMS", "WIN16", "WIN32", "WINNT", "OS2" );
84my @known_algorithms = ( "RC2", "RC4", "RC5", "IDEA", "DES", "BF", 84my @known_algorithms = ( "RC2", "RC4", "RC5", "IDEA", "DES", "BF",
85 "CAST", "MD2", "MD4", "MD5", "SHA", "SHA0", "SHA1", 85 "CAST", "MD2", "MD4", "MD5", "SHA", "SHA0", "SHA1",
86 "SHA256", "SHA512", "RIPEMD", 86 "SHA256", "SHA512", "RIPEMD",
87 "MDC2", "RSA", "DSA", "DH", "EC", "ECDH", "ECDSA", "HMAC", "AES", "CAMELLIA", "SEED", 87 "MDC2", "WHIRLPOOL", "RSA", "DSA", "DH", "EC", "ECDH", "ECDSA",
88 "HMAC", "AES", "CAMELLIA", "SEED", "GOST",
88 # Envelope "algorithms" 89 # Envelope "algorithms"
89 "EVP", "X509", "ASN1_TYPEDEFS", 90 "EVP", "X509", "ASN1_TYPEDEFS",
90 # Helper "algorithms" 91 # Helper "algorithms"
@@ -94,14 +95,16 @@ my @known_algorithms = ( "RC2", "RC4", "RC5", "IDEA", "DES", "BF",
94 "FP_API", "STDIO", "SOCK", "KRB5", "DGRAM", 95 "FP_API", "STDIO", "SOCK", "KRB5", "DGRAM",
95 # Engines 96 # Engines
96 "STATIC_ENGINE", "ENGINE", "HW", "GMP", 97 "STATIC_ENGINE", "ENGINE", "HW", "GMP",
97 # RFC3779 support 98 # RFC3779
98 "RFC3779", 99 "RFC3779",
99 # TLS extension support 100 # TLS
100 "TLSEXT", 101 "TLSEXT", "PSK",
101 # CMS 102 # CMS
102 "CMS", 103 "CMS",
103 # CryptoAPI Engine 104 # CryptoAPI Engine
104 "CAPIENG", 105 "CAPIENG",
106 # SSL v2
107 "SSL2",
105 # JPAKE 108 # JPAKE
106 "JPAKE", 109 "JPAKE",
107 # Deprecated functions 110 # Deprecated functions
@@ -118,14 +121,15 @@ close(IN);
118# defined with ifndef(NO_XXX) are not included in the .def file, and everything 121# defined with ifndef(NO_XXX) are not included in the .def file, and everything
119# in directory xxx is ignored. 122# in directory xxx is ignored.
120my $no_rc2; my $no_rc4; my $no_rc5; my $no_idea; my $no_des; my $no_bf; 123my $no_rc2; my $no_rc4; my $no_rc5; my $no_idea; my $no_des; my $no_bf;
121my $no_cast; 124my $no_cast; my $no_whirlpool; my $no_camellia; my $no_seed;
122my $no_md2; my $no_md4; my $no_md5; my $no_sha; my $no_ripemd; my $no_mdc2; 125my $no_md2; my $no_md4; my $no_md5; my $no_sha; my $no_ripemd; my $no_mdc2;
123my $no_rsa; my $no_dsa; my $no_dh; my $no_hmac=0; my $no_aes; my $no_krb5; 126my $no_rsa; my $no_dsa; my $no_dh; my $no_hmac=0; my $no_aes; my $no_krb5;
124my $no_ec; my $no_ecdsa; my $no_ecdh; my $no_engine; my $no_hw; my $no_camellia; 127my $no_ec; my $no_ecdsa; my $no_ecdh; my $no_engine; my $no_hw;
125my $no_seed; 128my $no_fp_api; my $no_static_engine=1; my $no_gmp; my $no_deprecated;
126my $no_fp_api; my $no_static_engine; my $no_gmp; my $no_deprecated; 129my $no_rfc3779; my $no_psk; my $no_tlsext; my $no_cms; my $no_capieng;
127my $no_rfc3779; my $no_tlsext; my $no_cms; my $no_capieng; my $no_jpake; 130my $no_jpake; my $no_ssl2;
128my $fips; 131
132my $zlib;
129 133
130 134
131foreach (@ARGV, split(/ /, $options)) 135foreach (@ARGV, split(/ /, $options))
@@ -141,17 +145,15 @@ foreach (@ARGV, split(/ /, $options))
141 $VMS=1; 145 $VMS=1;
142 $VMSVAX=1; 146 $VMSVAX=1;
143 } 147 }
144 if ($_ eq "VMS-Alpha") { 148 if ($_ eq "VMS-NonVAX") {
145 $VMS=1; 149 $VMS=1;
146 $VMSAlpha=1; 150 $VMSNonVAX=1;
147 } 151 }
148 $VMS=1 if $_ eq "VMS"; 152 $VMS=1 if $_ eq "VMS";
149 $OS2=1 if $_ eq "OS2"; 153 $OS2=1 if $_ eq "OS2";
150 $fips=1 if /^fips/; 154 if ($_ eq "zlib" || $_ eq "enable-zlib" || $_ eq "zlib-dynamic"
151 155 || $_ eq "enable-zlib-dynamic") {
152 if ($_ eq "zlib" || $_ eq "zlib-dynamic" 156 $zlib = 1;
153 || $_ eq "enable-zlib-dynamic") {
154 $zlib = 1;
155 } 157 }
156 158
157 $do_ssl=1 if $_ eq "ssleay"; 159 $do_ssl=1 if $_ eq "ssleay";
@@ -180,6 +182,7 @@ foreach (@ARGV, split(/ /, $options))
180 elsif (/^no-des$/) { $no_des=1; $no_mdc2=1; } 182 elsif (/^no-des$/) { $no_des=1; $no_mdc2=1; }
181 elsif (/^no-bf$/) { $no_bf=1; } 183 elsif (/^no-bf$/) { $no_bf=1; }
182 elsif (/^no-cast$/) { $no_cast=1; } 184 elsif (/^no-cast$/) { $no_cast=1; }
185 elsif (/^no-whirlpool$/) { $no_whirlpool=1; }
183 elsif (/^no-md2$/) { $no_md2=1; } 186 elsif (/^no-md2$/) { $no_md2=1; }
184 elsif (/^no-md4$/) { $no_md4=1; } 187 elsif (/^no-md4$/) { $no_md4=1; }
185 elsif (/^no-md5$/) { $no_md5=1; } 188 elsif (/^no-md5$/) { $no_md5=1; }
@@ -212,6 +215,7 @@ foreach (@ARGV, split(/ /, $options))
212 elsif (/^no-rfc3779$/) { $no_rfc3779=1; } 215 elsif (/^no-rfc3779$/) { $no_rfc3779=1; }
213 elsif (/^no-tlsext$/) { $no_tlsext=1; } 216 elsif (/^no-tlsext$/) { $no_tlsext=1; }
214 elsif (/^no-cms$/) { $no_cms=1; } 217 elsif (/^no-cms$/) { $no_cms=1; }
218 elsif (/^no-ssl2$/) { $no_ssl2=1; }
215 elsif (/^no-capieng$/) { $no_capieng=1; } 219 elsif (/^no-capieng$/) { $no_capieng=1; }
216 elsif (/^no-jpake$/) { $no_jpake=1; } 220 elsif (/^no-jpake$/) { $no_jpake=1; }
217 } 221 }
@@ -260,6 +264,7 @@ $crypto.=" crypto/rc5/rc5.h" ; # unless $no_rc5;
260$crypto.=" crypto/rc2/rc2.h" ; # unless $no_rc2; 264$crypto.=" crypto/rc2/rc2.h" ; # unless $no_rc2;
261$crypto.=" crypto/bf/blowfish.h" ; # unless $no_bf; 265$crypto.=" crypto/bf/blowfish.h" ; # unless $no_bf;
262$crypto.=" crypto/cast/cast.h" ; # unless $no_cast; 266$crypto.=" crypto/cast/cast.h" ; # unless $no_cast;
267$crypto.=" crypto/whrlpool/whrlpool.h" ;
263$crypto.=" crypto/md2/md2.h" ; # unless $no_md2; 268$crypto.=" crypto/md2/md2.h" ; # unless $no_md2;
264$crypto.=" crypto/md4/md4.h" ; # unless $no_md4; 269$crypto.=" crypto/md4/md4.h" ; # unless $no_md4;
265$crypto.=" crypto/md5/md5.h" ; # unless $no_md5; 270$crypto.=" crypto/md5/md5.h" ; # unless $no_md5;
@@ -301,17 +306,16 @@ $crypto.=" crypto/pkcs12/pkcs12.h";
301$crypto.=" crypto/x509/x509.h"; 306$crypto.=" crypto/x509/x509.h";
302$crypto.=" crypto/x509/x509_vfy.h"; 307$crypto.=" crypto/x509/x509_vfy.h";
303$crypto.=" crypto/x509v3/x509v3.h"; 308$crypto.=" crypto/x509v3/x509v3.h";
309$crypto.=" crypto/ts/ts.h";
304$crypto.=" crypto/rand/rand.h"; 310$crypto.=" crypto/rand/rand.h";
305$crypto.=" crypto/comp/comp.h" ; # unless $no_comp; 311$crypto.=" crypto/comp/comp.h" ; # unless $no_comp;
306$crypto.=" crypto/ocsp/ocsp.h"; 312$crypto.=" crypto/ocsp/ocsp.h";
307$crypto.=" crypto/ui/ui.h crypto/ui/ui_compat.h"; 313$crypto.=" crypto/ui/ui.h crypto/ui/ui_compat.h";
308$crypto.=" crypto/krb5/krb5_asn.h"; 314$crypto.=" crypto/krb5/krb5_asn.h";
309$crypto.=" crypto/tmdiff.h"; 315#$crypto.=" crypto/store/store.h";
310$crypto.=" crypto/store/store.h";
311$crypto.=" crypto/pqueue/pqueue.h"; 316$crypto.=" crypto/pqueue/pqueue.h";
312$crypto.=" crypto/cms/cms.h"; 317$crypto.=" crypto/cms/cms.h";
313$crypto.=" crypto/jpake/jpake.h"; 318$crypto.=" crypto/jpake/jpake.h";
314$crypto.=" fips/fips.h fips/rand/fips_rand.h";
315 319
316my $symhacks="crypto/symhacks.h"; 320my $symhacks="crypto/symhacks.h";
317 321
@@ -885,6 +889,7 @@ sub do_defs
885 s/\{\}/\(\)/gs; 889 s/\{\}/\(\)/gs;
886 890
887 s/STACK_OF\(\)/void/gs; 891 s/STACK_OF\(\)/void/gs;
892 s/LHASH_OF\(\)/void/gs;
888 893
889 print STDERR "DEBUG: \$_ = \"$_\"\n" if $debug; 894 print STDERR "DEBUG: \$_ = \"$_\"\n" if $debug;
890 if (/^\#INFO:([^:]*):(.*)$/) { 895 if (/^\#INFO:([^:]*):(.*)$/) {
@@ -961,6 +966,25 @@ sub do_defs
961 $platform{"PEM_write_NS_CERT_SEQ"} = "VMS"; 966 $platform{"PEM_write_NS_CERT_SEQ"} = "VMS";
962 $platform{"PEM_read_P8_PRIV_KEY_INFO"} = "VMS"; 967 $platform{"PEM_read_P8_PRIV_KEY_INFO"} = "VMS";
963 $platform{"PEM_write_P8_PRIV_KEY_INFO"} = "VMS"; 968 $platform{"PEM_write_P8_PRIV_KEY_INFO"} = "VMS";
969 $platform{"EVP_sha384"} = "!VMSVAX";
970 $platform{"EVP_sha512"} = "!VMSVAX";
971 $platform{"SHA384_Init"} = "!VMSVAX";
972 $platform{"SHA384_Transform"} = "!VMSVAX";
973 $platform{"SHA384_Update"} = "!VMSVAX";
974 $platform{"SHA384_Final"} = "!VMSVAX";
975 $platform{"SHA384"} = "!VMSVAX";
976 $platform{"SHA512_Init"} = "!VMSVAX";
977 $platform{"SHA512_Transform"} = "!VMSVAX";
978 $platform{"SHA512_Update"} = "!VMSVAX";
979 $platform{"SHA512_Final"} = "!VMSVAX";
980 $platform{"SHA512"} = "!VMSVAX";
981 $platform{"WHIRLPOOL_Init"} = "!VMSVAX";
982 $platform{"WHIRLPOOL"} = "!VMSVAX";
983 $platform{"WHIRLPOOL_BitUpdate"} = "!VMSVAX";
984 $platform{"EVP_whirlpool"} = "!VMSVAX";
985 $platform{"WHIRLPOOL_Final"} = "!VMSVAX";
986 $platform{"WHIRLPOOL_Update"} = "!VMSVAX";
987
964 988
965 # Info we know about 989 # Info we know about
966 990
@@ -1085,6 +1109,8 @@ sub is_valid
1085 1109
1086 if ($platforms) { 1110 if ($platforms) {
1087 # platforms 1111 # platforms
1112 if ($keyword eq "VMSVAX" && $VMSVAX) { return 1; }
1113 if ($keyword eq "VMSNonVAX" && $VMSNonVAX) { return 1; }
1088 if ($keyword eq "VMS" && $VMS) { return 1; } 1114 if ($keyword eq "VMS" && $VMS) { return 1; }
1089 if ($keyword eq "WIN32" && $W32) { return 1; } 1115 if ($keyword eq "WIN32" && $W32) { return 1; }
1090 if ($keyword eq "WIN16" && $W16) { return 1; } 1116 if ($keyword eq "WIN16" && $W16) { return 1; }
@@ -1097,9 +1123,6 @@ sub is_valid
1097 if ($keyword eq "EXPORT_VAR_AS_FUNCTION" && ($VMSVAX || $W32 || $W16)) { 1123 if ($keyword eq "EXPORT_VAR_AS_FUNCTION" && ($VMSVAX || $W32 || $W16)) {
1098 return 1; 1124 return 1;
1099 } 1125 }
1100 if ($keyword eq "OPENSSL_FIPS" && $fips) {
1101 return 1;
1102 }
1103 if ($keyword eq "ZLIB" && $zlib) { return 1; } 1126 if ($keyword eq "ZLIB" && $zlib) { return 1; }
1104 return 0; 1127 return 0;
1105 } else { 1128 } else {
@@ -1117,6 +1140,7 @@ sub is_valid
1117 if ($keyword eq "SHA" && $no_sha) { return 0; } 1140 if ($keyword eq "SHA" && $no_sha) { return 0; }
1118 if ($keyword eq "RIPEMD" && $no_ripemd) { return 0; } 1141 if ($keyword eq "RIPEMD" && $no_ripemd) { return 0; }
1119 if ($keyword eq "MDC2" && $no_mdc2) { return 0; } 1142 if ($keyword eq "MDC2" && $no_mdc2) { return 0; }
1143 if ($keyword eq "WHIRLPOOL" && $no_whirlpool) { return 0; }
1120 if ($keyword eq "RSA" && $no_rsa) { return 0; } 1144 if ($keyword eq "RSA" && $no_rsa) { return 0; }
1121 if ($keyword eq "DSA" && $no_dsa) { return 0; } 1145 if ($keyword eq "DSA" && $no_dsa) { return 0; }
1122 if ($keyword eq "DH" && $no_dh) { return 0; } 1146 if ($keyword eq "DH" && $no_dh) { return 0; }
@@ -1143,7 +1167,9 @@ sub is_valid
1143 if ($keyword eq "GMP" && $no_gmp) { return 0; } 1167 if ($keyword eq "GMP" && $no_gmp) { return 0; }
1144 if ($keyword eq "RFC3779" && $no_rfc3779) { return 0; } 1168 if ($keyword eq "RFC3779" && $no_rfc3779) { return 0; }
1145 if ($keyword eq "TLSEXT" && $no_tlsext) { return 0; } 1169 if ($keyword eq "TLSEXT" && $no_tlsext) { return 0; }
1170 if ($keyword eq "PSK" && $no_psk) { return 0; }
1146 if ($keyword eq "CMS" && $no_cms) { return 0; } 1171 if ($keyword eq "CMS" && $no_cms) { return 0; }
1172 if ($keyword eq "SSL2" && $no_ssl2) { return 0; }
1147 if ($keyword eq "CAPIENG" && $no_capieng) { return 0; } 1173 if ($keyword eq "CAPIENG" && $no_capieng) { return 0; }
1148 if ($keyword eq "JPAKE" && $no_jpake) { return 0; } 1174 if ($keyword eq "JPAKE" && $no_jpake) { return 0; }
1149 if ($keyword eq "DEPRECATED" && $no_deprecated) { return 0; } 1175 if ($keyword eq "DEPRECATED" && $no_deprecated) { return 0; }
diff --git a/src/lib/libcrypto/util/mkerr.pl b/src/lib/libcrypto/util/mkerr.pl
index 554bebb159..15b774f277 100644
--- a/src/lib/libcrypto/util/mkerr.pl
+++ b/src/lib/libcrypto/util/mkerr.pl
@@ -1,6 +1,7 @@
1#!/usr/local/bin/perl -w 1#!/usr/local/bin/perl -w
2 2
3my $config = "crypto/err/openssl.ec"; 3my $config = "crypto/err/openssl.ec";
4my $hprefix = "openssl/";
4my $debug = 0; 5my $debug = 0;
5my $rebuild = 0; 6my $rebuild = 0;
6my $static = 1; 7my $static = 1;
@@ -12,11 +13,16 @@ my $staticloader = "";
12my $pack_errcode; 13my $pack_errcode;
13my $load_errcode; 14my $load_errcode;
14 15
16my $errcount;
17
15while (@ARGV) { 18while (@ARGV) {
16 my $arg = $ARGV[0]; 19 my $arg = $ARGV[0];
17 if($arg eq "-conf") { 20 if($arg eq "-conf") {
18 shift @ARGV; 21 shift @ARGV;
19 $config = shift @ARGV; 22 $config = shift @ARGV;
23 } elsif($arg eq "-hprefix") {
24 shift @ARGV;
25 $hprefix = shift @ARGV;
20 } elsif($arg eq "-debug") { 26 } elsif($arg eq "-debug") {
21 $debug = 1; 27 $debug = 1;
22 shift @ARGV; 28 shift @ARGV;
@@ -38,14 +44,78 @@ while (@ARGV) {
38 } elsif($arg eq "-write") { 44 } elsif($arg eq "-write") {
39 $dowrite = 1; 45 $dowrite = 1;
40 shift @ARGV; 46 shift @ARGV;
47 } elsif($arg eq "-help" || $arg eq "-h" || $arg eq "-?" || $arg eq "--help") {
48 print STDERR <<"EOF";
49mkerr.pl [options] ...
50
51Options:
52
53 -conf F Use the config file F instead of the default one:
54 crypto/err/openssl.ec
55
56 -hprefix P Prepend the filenames in generated #include <header>
57 statements with prefix P. Default: 'openssl/' (without
58 the quotes, naturally)
59
60 -debug Turn on debugging verbose output on stderr.
61
62 -rebuild Rebuild all header and C source files, irrespective of the
63 fact if any error or function codes have been added/removed.
64 Default: only update files for libraries which saw change
65 (of course, this requires '-write' as well, or no
66 files will be touched!)
67
68 -recurse scan a preconfigured set of directories / files for error and
69 function codes:
70 (<crypto/*.c>, <crypto/*/*.c>, <ssl/*.c>, <apps/*.c>)
71 When this option is NOT specified, the filelist is taken from
72 the commandline instead. Here, wildcards may be embedded. (Be
73 sure to escape those to prevent the shell from expanding them
74 for you when you wish mkerr.pl to do so instead.)
75 Default: take file list to scan from the command line.
76
77 -reindex Discard the numeric values previously assigned to the error
78 and function codes as extracted from the scanned header files;
79 instead renumber all of them starting from 100. (Note that
80 the numbers assigned through 'R' records in the config file
81 remain intact.)
82 Default: keep previously assigned numbers. (You are warned
83 when collisions are detected.)
84
85 -nostatic Generates a different source code, where these additional
86 functions are generated for each library specified in the
87 config file:
88 void ERR_load_<LIB>_strings(void);
89 void ERR_unload_<LIB>_strings(void);
90 void ERR_<LIB>_error(int f, int r, char *fn, int ln);
91 #define <LIB>err(f,r) ERR_<LIB>_error(f,r,__FILE__,__LINE__)
92 while the code facilitates the use of these in an environment
93 where the error support routines are dynamically loaded at
94 runtime.
95 Default: 'static' code generation.
96
97 -staticloader Prefix generated functions with the 'static' scope modifier.
98 Default: don't write any scope modifier prefix.
99
100 -write Actually (over)write the generated code to the header and C
101 source files as assigned to each library through the config
102 file.
103 Default: don't write.
104
105 -help / -h / -? / --help Show this help text.
106
107 ... Additional arguments are added to the file list to scan,
108 assuming '-recurse' was NOT specified on the command line.
109
110EOF
111 exit 1;
41 } else { 112 } else {
42 last; 113 last;
43 } 114 }
44} 115}
45 116
46if($recurse) { 117if($recurse) {
47 @source = ( <crypto/*.c>, <crypto/*/*.c>, <ssl/*.c>, 118 @source = (<crypto/*.c>, <crypto/*/*.c>, <ssl/*.c>);
48 <fips/*.c>, <fips/*/*.c>);
49} else { 119} else {
50 @source = @ARGV; 120 @source = @ARGV;
51} 121}
@@ -64,8 +134,8 @@ while(<IN>)
64 $cskip{$3} = $1; 134 $cskip{$3} = $1;
65 if($3 ne "NONE") { 135 if($3 ne "NONE") {
66 $csrc{$1} = $3; 136 $csrc{$1} = $3;
67 $fmax{$1} = 99; 137 $fmax{$1} = 100;
68 $rmax{$1} = 99; 138 $rmax{$1} = 100;
69 $fassigned{$1} = ":"; 139 $fassigned{$1} = ":";
70 $rassigned{$1} = ":"; 140 $rassigned{$1} = ":";
71 $fnew{$1} = 0; 141 $fnew{$1} = 0;
@@ -191,7 +261,8 @@ while (($hdr, $lib) = each %libinc)
191 if($1 eq "R") { 261 if($1 eq "R") {
192 $rcodes{$name} = $code; 262 $rcodes{$name} = $code;
193 if ($rassigned{$lib} =~ /:$code:/) { 263 if ($rassigned{$lib} =~ /:$code:/) {
194 print STDERR "!! ERROR: $lib reason code $code assigned twice\n"; 264 print STDERR "!! ERROR: $lib reason code $code assigned twice (collision at $name)\n";
265 ++$errcount;
195 } 266 }
196 $rassigned{$lib} .= "$code:"; 267 $rassigned{$lib} .= "$code:";
197 if(!(exists $rextra{$name}) && 268 if(!(exists $rextra{$name}) &&
@@ -200,7 +271,8 @@ while (($hdr, $lib) = each %libinc)
200 } 271 }
201 } else { 272 } else {
202 if ($fassigned{$lib} =~ /:$code:/) { 273 if ($fassigned{$lib} =~ /:$code:/) {
203 print STDERR "!! ERROR: $lib function code $code assigned twice\n"; 274 print STDERR "!! ERROR: $lib function code $code assigned twice (collision at $name)\n";
275 ++$errcount;
204 } 276 }
205 $fassigned{$lib} .= "$code:"; 277 $fassigned{$lib} .= "$code:";
206 if($code > $fmax{$lib}) { 278 if($code > $fmax{$lib}) {
@@ -231,6 +303,7 @@ while (($hdr, $lib) = each %libinc)
231 if ($rmax{$lib} >= 1000) { 303 if ($rmax{$lib} >= 1000) {
232 print STDERR "!! ERROR: SSL error codes 1000+ are reserved for alerts.\n"; 304 print STDERR "!! ERROR: SSL error codes 1000+ are reserved for alerts.\n";
233 print STDERR "!! Any new alerts must be added to $config.\n"; 305 print STDERR "!! Any new alerts must be added to $config.\n";
306 ++$errcount;
234 print STDERR "\n"; 307 print STDERR "\n";
235 } 308 }
236 } 309 }
@@ -255,6 +328,9 @@ foreach $file (@source) {
255 print STDERR "File loaded: ".$file."\r" if $debug; 328 print STDERR "File loaded: ".$file."\r" if $debug;
256 open(IN, "<$file") || die "Can't open source file $file\n"; 329 open(IN, "<$file") || die "Can't open source file $file\n";
257 while(<IN>) { 330 while(<IN>) {
331 # skip obsoleted source files entirely!
332 last if(/^#error\s+obsolete/);
333
258 if(/(([A-Z0-9]+)_F_([A-Z0-9_]+))/) { 334 if(/(([A-Z0-9]+)_F_([A-Z0-9_]+))/) {
259 next unless exists $csrc{$2}; 335 next unless exists $csrc{$2};
260 next if($1 eq "BIO_F_BUFFER_CTX"); 336 next if($1 eq "BIO_F_BUFFER_CTX");
@@ -264,6 +340,7 @@ foreach $file (@source) {
264 $fnew{$2}++; 340 $fnew{$2}++;
265 } 341 }
266 $notrans{$1} = 1 unless exists $ftrans{$3}; 342 $notrans{$1} = 1 unless exists $ftrans{$3};
343 print STDERR "Function: $1\t= $fcodes{$1} (lib: $2, name: $3)\n" if $debug;
267 } 344 }
268 if(/(([A-Z0-9]+)_R_[A-Z0-9_]+)/) { 345 if(/(([A-Z0-9]+)_R_[A-Z0-9_]+)/) {
269 next unless exists $csrc{$2}; 346 next unless exists $csrc{$2};
@@ -272,6 +349,7 @@ foreach $file (@source) {
272 $rcodes{$1} = "X"; 349 $rcodes{$1} = "X";
273 $rnew{$2}++; 350 $rnew{$2}++;
274 } 351 }
352 print STDERR "Reason: $1\t= $rcodes{$1} (lib: $2)\n" if $debug;
275 } 353 }
276 } 354 }
277 close IN; 355 close IN;
@@ -313,7 +391,7 @@ foreach $lib (keys %csrc)
313 } else { 391 } else {
314 push @out, 392 push @out,
315"/* ====================================================================\n", 393"/* ====================================================================\n",
316" * Copyright (c) 2001-2008 The OpenSSL Project. All rights reserved.\n", 394" * Copyright (c) 2001-2010 The OpenSSL Project. All rights reserved.\n",
317" *\n", 395" *\n",
318" * Redistribution and use in source and binary forms, with or without\n", 396" * Redistribution and use in source and binary forms, with or without\n",
319" * modification, are permitted provided that the following conditions\n", 397" * modification, are permitted provided that the following conditions\n",
@@ -369,6 +447,10 @@ foreach $lib (keys %csrc)
369"#ifndef HEADER_${lib}_ERR_H\n", 447"#ifndef HEADER_${lib}_ERR_H\n",
370"#define HEADER_${lib}_ERR_H\n", 448"#define HEADER_${lib}_ERR_H\n",
371"\n", 449"\n",
450"#ifdef __cplusplus\n",
451"extern \"C\" {\n",
452"#endif\n",
453"\n",
372"/* BEGIN ERROR CODES */\n"; 454"/* BEGIN ERROR CODES */\n";
373 } 455 }
374 open (OUT, ">$hfile") || die "Can't Open File $hfile for writing\n"; 456 open (OUT, ">$hfile") || die "Can't Open File $hfile for writing\n";
@@ -455,14 +537,21 @@ EOF
455 if (/\b(${lib}_R_\w*)\b.*\"(.*)\"/) { 537 if (/\b(${lib}_R_\w*)\b.*\"(.*)\"/) {
456 $err_reason_strings{$1} = $2; 538 $err_reason_strings{$1} = $2;
457 } 539 }
540 if (/\b${lib}_F_(\w*)\b.*\"(.*)\"/) {
541 if (!exists $ftrans{$1} && ($1 ne $2)) {
542 print STDERR "WARNING: Mismatched function string $2\n";
543 $ftrans{$1} = $2;
544 }
545 }
458 } 546 }
459 close(IN); 547 close(IN);
460 } 548 }
461 549
550
462 my $hincf; 551 my $hincf;
463 if($static) { 552 if($static) {
464 $hfile =~ /([^\/]+)$/; 553 $hfile =~ /([^\/]+)$/;
465 $hincf = "<openssl/$1>"; 554 $hincf = "<${hprefix}$1>";
466 } else { 555 } else {
467 $hincf = "\"$hfile\""; 556 $hincf = "\"$hfile\"";
468 } 557 }
@@ -487,7 +576,7 @@ EOF
487 print OUT <<"EOF"; 576 print OUT <<"EOF";
488/* $cfile */ 577/* $cfile */
489/* ==================================================================== 578/* ====================================================================
490 * Copyright (c) 1999-2008 The OpenSSL Project. All rights reserved. 579 * Copyright (c) 1999-2010 The OpenSSL Project. All rights reserved.
491 * 580 *
492 * Redistribution and use in source and binary forms, with or without 581 * Redistribution and use in source and binary forms, with or without
493 * modification, are permitted provided that the following conditions 582 * modification, are permitted provided that the following conditions
@@ -713,3 +802,9 @@ if($debug && defined(@runref) ) {
713 print STDERR "$_\n"; 802 print STDERR "$_\n";
714 } 803 }
715} 804}
805
806if($errcount) {
807 print STDERR "There were errors, failing...\n\n";
808 exit $errcount;
809}
810
diff --git a/src/lib/libcrypto/util/mkfiles.pl b/src/lib/libcrypto/util/mkfiles.pl
index 67fb8694c8..6d15831450 100644
--- a/src/lib/libcrypto/util/mkfiles.pl
+++ b/src/lib/libcrypto/util/mkfiles.pl
@@ -26,6 +26,7 @@ my @dirs = (
26"crypto/aes", 26"crypto/aes",
27"crypto/camellia", 27"crypto/camellia",
28"crypto/seed", 28"crypto/seed",
29"crypto/modes",
29"crypto/bn", 30"crypto/bn",
30"crypto/rsa", 31"crypto/rsa",
31"crypto/dsa", 32"crypto/dsa",
@@ -46,6 +47,7 @@ my @dirs = (
46"crypto/pem", 47"crypto/pem",
47"crypto/x509", 48"crypto/x509",
48"crypto/x509v3", 49"crypto/x509v3",
50"crypto/cms",
49"crypto/conf", 51"crypto/conf",
50"crypto/jpake", 52"crypto/jpake",
51"crypto/txt_db", 53"crypto/txt_db",
@@ -56,25 +58,20 @@ my @dirs = (
56"crypto/ocsp", 58"crypto/ocsp",
57"crypto/ui", 59"crypto/ui",
58"crypto/krb5", 60"crypto/krb5",
59"crypto/store", 61#"crypto/store",
60"crypto/pqueue", 62"crypto/pqueue",
61"crypto/cms", 63"crypto/whrlpool",
62"fips", 64"crypto/ts",
63"fips/aes",
64"fips/des",
65"fips/dsa",
66"fips/dh",
67"fips/hmac",
68"fips/rand",
69"fips/rsa",
70"fips/sha",
71"ssl", 65"ssl",
72"apps", 66"apps",
73"engines", 67"engines",
68"engines/ccgost",
74"test", 69"test",
75"tools" 70"tools"
76); 71);
77 72
73%top;
74
78foreach (@dirs) { 75foreach (@dirs) {
79 &files_dir ($_, "Makefile"); 76 &files_dir ($_, "Makefile");
80} 77}
@@ -118,8 +115,8 @@ while (<IN>)
118 $o =~ s/\s+$//; 115 $o =~ s/\s+$//;
119 $o =~ s/\s+/ /g; 116 $o =~ s/\s+/ /g;
120 117
121 $o =~ s/\$[({]([^)}]+)[)}]/$sym{$1}/g; 118 $o =~ s/\$[({]([^)}]+)[)}]/$top{$1} or $sym{$1}/ge;
122 $sym{$s}=$o; 119 $sym{$s}=($top{$s} or $o);
123 } 120 }
124 } 121 }
125 122
@@ -129,6 +126,15 @@ foreach (sort keys %sym)
129 { 126 {
130 print "$_=$sym{$_}\n"; 127 print "$_=$sym{$_}\n";
131 } 128 }
129if ($dir eq "." && defined($sym{"BUILDENV"}))
130 {
131 foreach (split(' ',$sym{"BUILDENV"}))
132 {
133 /^(.+)=/;
134 $top{$1}=$sym{$1};
135 }
136 }
137
132print "RELATIVE_DIRECTORY=\n"; 138print "RELATIVE_DIRECTORY=\n";
133 139
134close (IN); 140close (IN);
diff --git a/src/lib/libcrypto/util/mklink.pl b/src/lib/libcrypto/util/mklink.pl
index eacc327882..61db12c68f 100644
--- a/src/lib/libcrypto/util/mklink.pl
+++ b/src/lib/libcrypto/util/mklink.pl
@@ -15,21 +15,13 @@
15# Apart from this, this script should be able to handle even the most 15# Apart from this, this script should be able to handle even the most
16# pathological cases. 16# pathological cases.
17 17
18my $pwd; 18use Cwd;
19eval 'use Cwd;';
20if ($@)
21 {
22 $pwd = `pwd`;
23 }
24else
25 {
26 $pwd = getcwd();
27 }
28 19
29my $from = shift; 20my $from = shift;
30my @files = @ARGV; 21my @files = @ARGV;
31 22
32my @from_path = split(/[\\\/]/, $from); 23my @from_path = split(/[\\\/]/, $from);
24my $pwd = getcwd();
33chomp($pwd); 25chomp($pwd);
34my @pwd_path = split(/[\\\/]/, $pwd); 26my @pwd_path = split(/[\\\/]/, $pwd);
35 27
@@ -59,6 +51,7 @@ my $to = join('/', @to_path);
59 51
60my $file; 52my $file;
61$symlink_exists=eval {symlink("",""); 1}; 53$symlink_exists=eval {symlink("",""); 1};
54if ($^O eq "msys") { $symlink_exists=0 };
62foreach $file (@files) { 55foreach $file (@files) {
63 my $err = ""; 56 my $err = "";
64 if ($symlink_exists) { 57 if ($symlink_exists) {
diff --git a/src/lib/libcrypto/util/mksdef.pl b/src/lib/libcrypto/util/mksdef.pl
deleted file mode 100644
index 065dc675f1..0000000000
--- a/src/lib/libcrypto/util/mksdef.pl
+++ /dev/null
@@ -1,87 +0,0 @@
1
2# Perl script to split libeay32.def into two distinct DEF files for use in
3# fipdso mode. It works out symbols in each case by running "link" command and
4# parsing the output to find the list of missing symbols then splitting
5# libeay32.def based on the result.
6
7
8# Get list of unknown symbols
9
10my @deferr = `link @ARGV`;
11
12my $preamble = "";
13my @fipsdll;
14my @fipsrest;
15my %nosym;
16
17# Add symbols to a hash for easy lookup
18
19foreach (@deferr)
20 {
21 if (/^.*symbol (\S+)$/)
22 {
23 $nosym{$1} = 1;
24 }
25 }
26
27open (IN, "ms/libeay32.def") || die "Can't Open DEF file for spliting";
28
29my $started = 0;
30
31# Parse libeay32.def into two arrays depending on whether the symbol matches
32# the missing list.
33
34
35foreach (<IN>)
36 {
37 if (/^\s*(\S+)\s*(\@\S+)\s*$/)
38 {
39 $started = 1;
40 if (exists $nosym{$1})
41 {
42 push @fipsrest, $_;
43 }
44 else
45 {
46 my $imptmp = sprintf " %-39s %s\n",
47 "$1=libosslfips.$1", $2;
48 push @fipsrest, $imptmp;
49 push @fipsdll, "\t$1\n";
50 }
51 }
52 $preamble .= $_ unless $started;
53 }
54
55close IN;
56
57# Hack! Add some additional exports needed for libcryptofips.dll
58#
59
60push @fipsdll, "\tOPENSSL_showfatal\n";
61push @fipsdll, "\tOPENSSL_cpuid_setup\n";
62
63# Write out DEF files for each array
64
65write_def("ms/libosslfips.def", "LIBOSSLFIPS", $preamble, \@fipsdll);
66write_def("ms/libeayfips.def", "", $preamble, \@fipsrest);
67
68
69sub write_def
70 {
71 my ($fnam, $defname, $preamble, $rdefs) = @_;
72 open (OUT, ">$fnam") || die "Can't Open DEF file $fnam for Writing\n";
73
74 if ($defname ne "")
75 {
76 $preamble =~ s/LIBEAY32/$defname/g;
77 $preamble =~ s/LIBEAY/$defname/g;
78 }
79 print OUT $preamble;
80 foreach (@$rdefs)
81 {
82 print OUT $_;
83 }
84 close OUT;
85 }
86
87
diff --git a/src/lib/libcrypto/util/mkstack.pl b/src/lib/libcrypto/util/mkstack.pl
index 2a968f395f..6a43757c95 100644
--- a/src/lib/libcrypto/util/mkstack.pl
+++ b/src/lib/libcrypto/util/mkstack.pl
@@ -21,7 +21,7 @@ while (@ARGV) {
21} 21}
22 22
23 23
24@source = (<crypto/*.[ch]>, <crypto/*/*.[ch]>, <ssl/*.[ch]>); 24@source = (<crypto/*.[ch]>, <crypto/*/*.[ch]>, <ssl/*.[ch]>, <apps/*.[ch]>);
25foreach $file (@source) { 25foreach $file (@source) {
26 next if -l $file; 26 next if -l $file;
27 27
@@ -31,11 +31,19 @@ foreach $file (@source) {
31 while(<IN>) { 31 while(<IN>) {
32 if (/^DECLARE_STACK_OF\(([^)]+)\)/) { 32 if (/^DECLARE_STACK_OF\(([^)]+)\)/) {
33 push @stacklst, $1; 33 push @stacklst, $1;
34 } if (/^DECLARE_ASN1_SET_OF\(([^)]+)\)/) { 34 }
35 if (/^DECLARE_SPECIAL_STACK_OF\(([^,\s]+)\s*,\s*([^>\s]+)\)/) {
36 push @sstacklst, [$1, $2];
37 }
38 if (/^DECLARE_ASN1_SET_OF\(([^)]+)\)/) {
35 push @asn1setlst, $1; 39 push @asn1setlst, $1;
36 } if (/^DECLARE_PKCS12_STACK_OF\(([^)]+)\)/) { 40 }
41 if (/^DECLARE_PKCS12_STACK_OF\(([^)]+)\)/) {
37 push @p12stklst, $1; 42 push @p12stklst, $1;
38 } 43 }
44 if (/^DECLARE_LHASH_OF\(([^)]+)\)/) {
45 push @lhashlst, $1;
46 }
39 } 47 }
40 close(IN); 48 close(IN);
41} 49}
@@ -65,7 +73,7 @@ while(<IN>) {
65 foreach $type_thing (sort @stacklst) { 73 foreach $type_thing (sort @stacklst) {
66 $new_stackfile .= <<EOF; 74 $new_stackfile .= <<EOF;
67 75
68#define sk_${type_thing}_new(st) SKM_sk_new($type_thing, (st)) 76#define sk_${type_thing}_new(cmp) SKM_sk_new($type_thing, (cmp))
69#define sk_${type_thing}_new_null() SKM_sk_new_null($type_thing) 77#define sk_${type_thing}_new_null() SKM_sk_new_null($type_thing)
70#define sk_${type_thing}_free(st) SKM_sk_free($type_thing, (st)) 78#define sk_${type_thing}_free(st) SKM_sk_free($type_thing, (st))
71#define sk_${type_thing}_num(st) SKM_sk_num($type_thing, (st)) 79#define sk_${type_thing}_num(st) SKM_sk_num($type_thing, (st))
@@ -88,6 +96,39 @@ while(<IN>) {
88#define sk_${type_thing}_is_sorted(st) SKM_sk_is_sorted($type_thing, (st)) 96#define sk_${type_thing}_is_sorted(st) SKM_sk_is_sorted($type_thing, (st))
89EOF 97EOF
90 } 98 }
99
100 foreach $type_thing (sort @sstacklst) {
101 my $t1 = $type_thing->[0];
102 my $t2 = $type_thing->[1];
103 $new_stackfile .= <<EOF;
104
105#define sk_${t1}_new(cmp) ((STACK_OF($t1) *)sk_new(CHECKED_SK_CMP_FUNC($t2, cmp)))
106#define sk_${t1}_new_null() ((STACK_OF($t1) *)sk_new_null())
107#define sk_${t1}_push(st, val) sk_push(CHECKED_PTR_OF(STACK_OF($t1), st), CHECKED_PTR_OF($t2, val))
108#define sk_${t1}_find(st, val) sk_find(CHECKED_PTR_OF(STACK_OF($t1), st), CHECKED_PTR_OF($t2, val))
109#define sk_${t1}_value(st, i) (($t1)sk_value(CHECKED_PTR_OF(STACK_OF($t1), st), i))
110#define sk_${t1}_num(st) SKM_sk_num($t1, st)
111#define sk_${t1}_pop_free(st, free_func) sk_pop_free(CHECKED_PTR_OF(STACK_OF($t1), st), CHECKED_SK_FREE_FUNC2($t1, free_func))
112#define sk_${t1}_insert(st, val, i) sk_insert(CHECKED_PTR_OF(STACK_OF($t1), st), CHECKED_PTR_OF($t2, val), i)
113#define sk_${t1}_free(st) SKM_sk_free(${t1}, st)
114#define sk_${t1}_set(st, i, val) sk_set((_STACK *)CHECKED_PTR_OF(STACK_OF($t1), st), i, CHECKED_PTR_OF($t2, val))
115#define sk_${t1}_zero(st) SKM_sk_zero($t1, (st))
116#define sk_${t1}_unshift(st, val) sk_unshift((_STACK *)CHECKED_PTR_OF(STACK_OF($t1), st), CHECKED_PTR_OF($t2, val))
117#define sk_${t1}_find_ex(st, val) sk_find_ex((_STACK *)CHECKED_CONST_PTR_OF(STACK_OF($t1), st), CHECKED_CONST_PTR_OF($t2, val))
118#define sk_${t1}_delete(st, i) SKM_sk_delete($t1, (st), (i))
119#define sk_${t1}_delete_ptr(st, ptr) ($t1 *)sk_delete_ptr((_STACK *)CHECKED_PTR_OF(STACK_OF($t1), st), CHECKED_PTR_OF($t2, ptr))
120#define sk_${t1}_set_cmp_func(st, cmp) \\
121 ((int (*)(const $t2 * const *,const $t2 * const *)) \\
122 sk_set_cmp_func((_STACK *)CHECKED_PTR_OF(STACK_OF($t1), st), CHECKED_SK_CMP_FUNC($t2, cmp)))
123#define sk_${t1}_dup(st) SKM_sk_dup($t1, st)
124#define sk_${t1}_shift(st) SKM_sk_shift($t1, (st))
125#define sk_${t1}_pop(st) ($t2 *)sk_pop((_STACK *)CHECKED_PTR_OF(STACK_OF($t1), st))
126#define sk_${t1}_sort(st) SKM_sk_sort($t1, (st))
127#define sk_${t1}_is_sorted(st) SKM_sk_is_sorted($t1, (st))
128
129EOF
130 }
131
91 foreach $type_thing (sort @asn1setlst) { 132 foreach $type_thing (sort @asn1setlst) {
92 $new_stackfile .= <<EOF; 133 $new_stackfile .= <<EOF;
93 134
@@ -108,6 +149,31 @@ EOF
108 SKM_PKCS12_decrypt_d2i($type_thing, (algor), (d2i_func), (free_func), (pass), (passlen), (oct), (seq)) 149 SKM_PKCS12_decrypt_d2i($type_thing, (algor), (d2i_func), (free_func), (pass), (passlen), (oct), (seq))
109EOF 150EOF
110 } 151 }
152
153 foreach $type_thing (sort @lhashlst) {
154 my $lc_tt = lc $type_thing;
155 $new_stackfile .= <<EOF;
156
157#define lh_${type_thing}_new() LHM_lh_new(${type_thing},${lc_tt})
158#define lh_${type_thing}_insert(lh,inst) LHM_lh_insert(${type_thing},lh,inst)
159#define lh_${type_thing}_retrieve(lh,inst) LHM_lh_retrieve(${type_thing},lh,inst)
160#define lh_${type_thing}_delete(lh,inst) LHM_lh_delete(${type_thing},lh,inst)
161#define lh_${type_thing}_doall(lh,fn) LHM_lh_doall(${type_thing},lh,fn)
162#define lh_${type_thing}_doall_arg(lh,fn,arg_type,arg) \\
163 LHM_lh_doall_arg(${type_thing},lh,fn,arg_type,arg)
164#define lh_${type_thing}_error(lh) LHM_lh_error(${type_thing},lh)
165#define lh_${type_thing}_num_items(lh) LHM_lh_num_items(${type_thing},lh)
166#define lh_${type_thing}_down_load(lh) LHM_lh_down_load(${type_thing},lh)
167#define lh_${type_thing}_node_stats_bio(lh,out) \\
168 LHM_lh_node_stats_bio(${type_thing},lh,out)
169#define lh_${type_thing}_node_usage_stats_bio(lh,out) \\
170 LHM_lh_node_usage_stats_bio(${type_thing},lh,out)
171#define lh_${type_thing}_stats_bio(lh,out) \\
172 LHM_lh_stats_bio(${type_thing},lh,out)
173#define lh_${type_thing}_free(lh) LHM_lh_free(${type_thing},lh)
174EOF
175 }
176
111 $new_stackfile .= "/* End of util/mkstack.pl block, you may now edit :-) */\n"; 177 $new_stackfile .= "/* End of util/mkstack.pl block, you may now edit :-) */\n";
112 $inside_block = 2; 178 $inside_block = 2;
113} 179}
diff --git a/src/lib/libcrypto/util/pl/BC-16.pl b/src/lib/libcrypto/util/pl/BC-16.pl
deleted file mode 100644
index 8030653daa..0000000000
--- a/src/lib/libcrypto/util/pl/BC-16.pl
+++ /dev/null
@@ -1,151 +0,0 @@
1#!/usr/local/bin/perl
2# VCw16lib.pl - the file for Visual C++ 1.52b for windows, static libraries
3#
4
5$o='\\';
6$cp='copy';
7$rm='del';
8
9# C compiler stuff
10$cc='bcc';
11
12if ($debug)
13 { $op="-v "; }
14else { $op="-O "; }
15
16$cflags="-d -ml $op -DL_ENDIAN";
17# I add the stack opt
18$base_lflags="/c /C";
19$lflags="$base_lflags";
20
21if ($win16)
22 {
23 $shlib=1;
24 $cflags.=" -DOPENSSL_SYSNAME_WIN16";
25 $app_cflag="-W";
26 $lib_cflag="-WD";
27 $lflags.="/Twe";
28 }
29else
30 {
31 $cflags.=" -DOENSSL_SYSNAME_MSDOS";
32 $lflags.=" /Tde";
33 }
34
35if ($shlib)
36 {
37 $mlflags=" /Twd $base_lflags"; # stack if defined in .def file
38 $libs="libw ldllcew";
39 $no_asm=1;
40 }
41else
42 { $mlflags=''; }
43
44$obj='.obj';
45$ofile="-o";
46
47# EXE linking stuff
48$link="tlink";
49$efile="";
50$exep='.exe';
51$ex_libs="CL";
52$ex_libs.=$no_sock?"":" winsock.lib";
53
54$app_ex_obj="C0L.obj ";
55$shlib_ex_obj="" if ($shlib);
56
57# static library stuff
58$mklib='tlib';
59$ranlib='echo no ranlib';
60$plib="";
61$libp=".lib";
62$shlibp=($shlib)?".dll":".lib";
63$lfile='';
64
65$asm='bcc -c -B -Tml';
66$afile='/o';
67if ($no_asm || $fips)
68 {
69 $bn_asm_obj='';
70 $bn_asm_src='';
71 }
72elsif ($asmbits == 32)
73 {
74 $bn_asm_obj='crypto\bn\asm\x86w32.obj';
75 $bn_asm_src='crypto\bn\asm\x86w32.asm';
76 }
77else
78 {
79 $bn_asm_obj='crypto\bn\asm\x86w16.obj';
80 $bn_asm_src='crypto\bn\asm\x86w16.asm';
81 }
82
83sub do_lib_rule
84 {
85 local($target,$name,$shlib)=@_;
86 local($ret,$Name);
87
88 $taget =~ s/\//$o/g if $o ne '/';
89 ($Name=$name) =~ tr/a-z/A-Z/;
90
91 $ret.="$target: \$(${Name}OBJ)\n";
92 $ret.="\t\$(RM) \$(O_$Name)\n";
93
94 # Due to a pathetic line length limit, I unwrap the args.
95 local($lib_names)="";
96 local($dll_names)="";
97 foreach $_ (sort split(/\s+/,$Vars{"${Name}OBJ"}))
98 {
99 $lib_names.=" +$_ &\n";
100 $dll_names.=" $_\n";
101 }
102
103 if (!$shlib)
104 {
105 $ret.="\t\$(MKLIB) $target & <<|\n$lib_names\n,\n|\n";
106 }
107 else
108 {
109 local($ex)=($Name eq "SSL")?' $(L_CRYPTO) winsock':"";
110 $ret.="\t\$(LINK) \$(MLFLAGS) @&&|\n";
111 $ret.=$dll_names;
112 $ret.="\n $target\n\n $ex $libs\nms$o${name}16.def;\n|\n";
113 ($out_lib=$target) =~ s/O_/L_/;
114 $ret.="\timplib /nowep $out_lib $target\n\n";
115 }
116 $ret.="\n";
117 return($ret);
118 }
119
120sub do_link_rule
121 {
122 local($target,$files,$dep_libs,$libs,$sha1file,$openssl)=@_;
123 local($ret,$f,$_,@f);
124
125 $file =~ s/\//$o/g if $o ne '/';
126 $n=&bname($target);
127 $ret.="$target: $files $dep_libs\n";
128 $ret.=" \$(LINK) @&&|";
129
130 # Due to a pathetic line length limit, I have to unwrap the args.
131 $ret.=" \$(LFLAGS) ";
132 if ($files =~ /\(([^)]*)\)$/)
133 {
134 $ret.=" \$(APP_EX_OBJ)";
135 foreach $_ (sort split(/\s+/,$Vars{$1}))
136 { $ret.="\n $r $_ +"; }
137 chop($ret);
138 $ret.="\n";
139 }
140 else
141 { $ret.="\n $r \$(APP_EX_OBJ) $files\n"; }
142 $ret.=" $target\n\n $libs\n\n|\n";
143 if (defined $sha1file)
144 {
145 $ret.=" $openssl sha1 -hmac etaonrishdlcupfm -binary $target > $sha1file";
146 }
147 $ret.="\n";
148 return($ret);
149 }
150
1511;
diff --git a/src/lib/libcrypto/util/pl/BC-32.pl b/src/lib/libcrypto/util/pl/BC-32.pl
index 99b8c058d2..1f1e13fb40 100644
--- a/src/lib/libcrypto/util/pl/BC-32.pl
+++ b/src/lib/libcrypto/util/pl/BC-32.pl
@@ -117,7 +117,7 @@ ___
117 else 117 else
118 { 118 {
119 local($ex)=($target =~ /O_SSL/)?' $(L_CRYPTO)':''; 119 local($ex)=($target =~ /O_SSL/)?' $(L_CRYPTO)':'';
120 $ex.=' wsock32.lib gdi32.lib'; 120 $ex.=' ws2_32.lib gdi32.lib';
121 $ret.="\t\$(LINK) \$(MLFLAGS) $efile$target /def:ms/${Name}.def @<<\n \$(SHLIB_EX_OBJ) $objs $ex\n<<\n"; 121 $ret.="\t\$(LINK) \$(MLFLAGS) $efile$target /def:ms/${Name}.def @<<\n \$(SHLIB_EX_OBJ) $objs $ex\n<<\n";
122 } 122 }
123 $ret.="\n"; 123 $ret.="\n";
diff --git a/src/lib/libcrypto/util/pl/Mingw32.pl b/src/lib/libcrypto/util/pl/Mingw32.pl
index 8f0483fb93..fe3fb27a78 100644
--- a/src/lib/libcrypto/util/pl/Mingw32.pl
+++ b/src/lib/libcrypto/util/pl/Mingw32.pl
@@ -19,7 +19,7 @@ $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 -march=i486 -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 {
@@ -43,8 +43,6 @@ if ($gaswin and !$no_asm)
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 $cpuid_asm_obj='$(OBJ_D)\cpu-win32.o';
47 $cpuid_asm_src='crypto/cpu-win32.s';
48 $cflags.=" -DBN_ASM -DMD5_ASM -DSHA1_ASM -DOPENSSL_BN_ASM_PART_WORDS"; 46 $cflags.=" -DBN_ASM -DMD5_ASM -DSHA1_ASM -DOPENSSL_BN_ASM_PART_WORDS";
49 } 47 }
50 48
@@ -57,7 +55,7 @@ $link='${CC}';
57$lflags='${CFLAGS}'; 55$lflags='${CFLAGS}';
58$efile='-o '; 56$efile='-o ';
59$exep=''; 57$exep='';
60$ex_libs="-lwsock32 -lgdi32"; 58$ex_libs="-lws2_32 -lgdi32";
61 59
62# static library stuff 60# static library stuff
63$mklib='ar r'; 61$mklib='ar r';
diff --git a/src/lib/libcrypto/util/pl/VC-16.pl b/src/lib/libcrypto/util/pl/VC-16.pl
deleted file mode 100644
index 564ba3fd08..0000000000
--- a/src/lib/libcrypto/util/pl/VC-16.pl
+++ /dev/null
@@ -1,177 +0,0 @@
1#!/usr/local/bin/perl
2# VCw16lib.pl - the file for Visual C++ 1.52b for windows, static libraries
3#
4
5$ssl= "ssleay16";
6$crypto="libeay16";
7
8$o='\\';
9$cp='copy';
10$rm='del';
11
12# C compiler stuff
13$cc='cl';
14
15$out_def="out16";
16$tmp_def="tmp16";
17$inc_def="inc16";
18
19if ($debug)
20 {
21 $op="/Od /Zi /Zd";
22 $base_lflags="/CO";
23 }
24else {
25 $op="/G2 /f- /Ocgnotb2";
26 }
27$base_lflags.=" /FARCALL /NOLOGO /NOD /SEG:1024 /ONERROR:NOEXE /NOE /PACKC:60000";
28if ($win16) { $base_lflags.=" /PACKD:60000"; }
29
30$cflags="/ALw /Gx- /Gt256 /Gf $op /W3 /WX -DL_ENDIAN /nologo";
31# I add the stack opt
32$lflags="$base_lflags /STACK:20000";
33
34if ($win16)
35 {
36 $cflags.=" -DOPENSSL_SYSNAME_WIN16";
37 $app_cflag="/Gw /FPi87";
38 $lib_cflag="/Gw";
39 $lib_cflag.=" -D_WINDLL -D_DLL" if $shlib;
40 $lib_cflag.=" -DWIN16TTY" if !$shlib;
41 $lflags.=" /ALIGN:256";
42 $ex_libs.="oldnames llibcewq libw";
43 }
44else
45 {
46 $no_sock=1;
47 $cflags.=" -DMSDOS";
48 $lflags.=" /EXEPACK";
49 $ex_libs.="oldnames.lib llibce.lib";
50 }
51
52if ($shlib)
53 {
54 $mlflags="$base_lflags";
55 $libs="oldnames ldllcew libw";
56 $shlib_ex_obj="";
57# $no_asm=1;
58 $out_def="out16dll";
59 $tmp_def="tmp16dll";
60 }
61else
62 { $mlflags=''; }
63
64$app_ex_obj="";
65
66$obj='.obj';
67$ofile="/Fo";
68
69# EXE linking stuff
70$link="link";
71$efile="";
72$exep='.exe';
73$ex_libs.=$no_sock?"":" winsock";
74
75# static library stuff
76$mklib='lib /PAGESIZE:1024';
77$ranlib='';
78$plib="";
79$libp=".lib";
80$shlibp=($shlib)?".dll":".lib";
81$lfile='';
82
83$asm='ml /Cp /c /Cx';
84$afile='/Fo';
85
86$bn_asm_obj='';
87$bn_asm_src='';
88$des_enc_obj='';
89$des_enc_src='';
90$bf_enc_obj='';
91$bf_enc_src='';
92
93if (!$no_asm && !$fips)
94 {
95 if ($asmbits == 32)
96 {
97 $bn_asm_obj='crypto\bn\asm\x86w32.obj';
98 $bn_asm_src='crypto\bn\asm\x86w32.asm';
99 }
100 else
101 {
102 $bn_asm_obj='crypto\bn\asm\x86w16.obj';
103 $bn_asm_src='crypto\bn\asm\x86w16.asm';
104 }
105 }
106
107sub do_lib_rule
108 {
109 local($objs,$target,$name,$shlib)=@_;
110 local($ret,$Name);
111
112 $taget =~ s/\//$o/g if $o ne '/';
113 ($Name=$name) =~ tr/a-z/A-Z/;
114
115# $target="\$(LIB_D)$o$target";
116 $ret.="$target: $objs\n";
117# $ret.="\t\$(RM) \$(O_$Name)\n";
118
119 # Due to a pathetic line length limit, I unwrap the args.
120 local($lib_names)="";
121 local($dll_names)=" \$(SHLIB_EX_OBJ) +\n";
122 ($obj)= ($objs =~ /\((.*)\)/);
123 foreach $_ (sort split(/\s+/,$Vars{$obj}))
124 {
125 $lib_names.="+$_ &\n";
126 $dll_names.=" $_ +\n";
127 }
128
129 if (!$shlib)
130 {
131 $ret.="\tdel $target\n";
132 $ret.="\t\$(MKLIB) @<<\n$target\ny\n$lib_names\n\n<<\n";
133 }
134 else
135 {
136 local($ex)=($target =~ /O_SSL/)?'$(L_CRYPTO)':"";
137 $ex.=' winsock';
138 $ret.="\t\$(LINK) \$(MLFLAGS) @<<\n";
139 $ret.=$dll_names;
140 $ret.="\n $target\n\n $ex $libs\nms$o${name}.def;\n<<\n";
141 ($out_lib=$target) =~ s/O_/L_/;
142 $ret.="\timplib /noignorecase /nowep $out_lib $target\n";
143 }
144 $ret.="\n";
145 return($ret);
146 }
147
148sub do_link_rule
149 {
150 local($target,$files,$dep_libs,$libs,$sha1file,$openssl)=@_;
151 local($ret,$f,$_,@f);
152
153 $file =~ s/\//$o/g if $o ne '/';
154 $n=&bname($targer);
155 $ret.="$target: $files $dep_libs\n";
156 $ret.=" \$(LINK) \$(LFLAGS) @<<\n";
157
158 # Due to a pathetic line length limit, I have to unwrap the args.
159 if ($files =~ /\(([^)]*)\)$/)
160 {
161 @a=('$(APP_EX_OBJ)');
162 push(@a,sort split(/\s+/,$Vars{$1}));
163 for $_ (@a)
164 { $ret.=" $_ +\n"; }
165 }
166 else
167 { $ret.=" \$(APP_EX_OBJ) $files"; }
168 $ret.="\n $target\n\n $libs\n\n<<\n";
169 if (defined $sha1file)
170 {
171 $ret.=" $openssl sha1 -hmac etaonrishdlcupfm -binary $target > $sha1file";
172 }
173 $ret.="\n";
174 return($ret);
175 }
176
1771;
diff --git a/src/lib/libcrypto/util/pl/VC-32-GMAKE.pl b/src/lib/libcrypto/util/pl/VC-32-GMAKE.pl
deleted file mode 100644
index b5bbcac6c2..0000000000
--- a/src/lib/libcrypto/util/pl/VC-32-GMAKE.pl
+++ /dev/null
@@ -1,222 +0,0 @@
1#!/usr/local/bin/perl
2# VCw32lib.pl - the file for Visual C++ 4.[01] for windows NT, static libraries
3#
4
5
6if ($fips && !$shlib)
7 {
8 $crypto="libeayfips32";
9 $crypto_compat = "libeaycompat32.lib";
10 }
11else
12 {
13 $crypto="libeay32";
14 }
15$ssl= "ssleay32";
16
17$o='/';
18#$cp='copy nul+'; # Timestamps get stuffed otherwise
19#$rm='del';
20
21$cp='cp';
22$rm='rm';
23
24$zlib_lib="zlib1.lib";
25
26# C compiler stuff
27$cc='cl';
28$cflags=' -MD -W3 -WX -Ox -O2 -Ob2 -Gs0 -GF -Gy -nologo -DOPENSSL_SYSNAME_WIN32 -DWIN32_LEAN_AND_MEAN -DL_ENDIAN -DDSO_WIN32';
29$cflags.=' -D_CRT_SECURE_NO_DEPRECATE'; # shut up VC8
30$cflags.=' -D_CRT_NONSTDC_NO_DEPRECATE'; # shut up VC8
31$lflags="-nologo -subsystem:console -machine:I386 -opt:ref";
32$mlflags='';
33
34$out_def="gmout32";
35$tmp_def="gmtmp32";
36$inc_def="gminc32";
37
38if ($debug)
39 {
40 $cflags=" -MDd -W3 -WX -Zi -Yd -Od -nologo -DOPENSSL_SYSNAME_WIN32 -D_DEBUG -DL_ENDIAN -DWIN32_LEAN_AND_MEAN -DDEBUG -DDSO_WIN32";
41 $lflags.=" -debug";
42 $mlflags.=' -debug';
43 }
44$cflags .= " -DOPENSSL_SYSNAME_WINNT" if $NT == 1;
45
46$obj='.obj';
47$ofile="-Fo";
48
49# EXE linking stuff
50$link="link";
51$efile="-out:";
52$exep='.exe';
53if ($no_sock)
54 { $ex_libs=""; }
55else { $ex_libs="wsock32.lib user32.lib gdi32.lib"; }
56
57# static library stuff
58$mklib='lib';
59$ranlib='';
60$plib="";
61$libp=".lib";
62$shlibp=($shlib)?".dll":".lib";
63$lfile='-out:';
64
65$shlib_ex_obj="";
66$app_ex_obj="setargv.obj";
67if ($nasm) {
68 $asm='nasmw -f win32';
69 $afile='-o ';
70} else {
71 $asm='ml -Cp -coff -c -Cx';
72 $asm.=" -Zi" if $debug;
73 $afile='-Fo';
74}
75
76$bn_asm_obj='';
77$bn_asm_src='';
78$des_enc_obj='';
79$des_enc_src='';
80$bf_enc_obj='';
81$bf_enc_src='';
82
83if (!$no_asm && !$fips)
84 {
85 $bn_asm_obj='crypto/bn/asm/bn_win32.obj';
86 $bn_asm_src='crypto/bn/asm/bn_win32.asm';
87 $des_enc_obj='crypto/des/asm/d_win32.obj crypto/des/asm/y_win32.obj';
88 $des_enc_src='crypto/des/asm/d_win32.asm crypto/des/asm/y_win32.asm';
89 $bf_enc_obj='crypto/bf/asm/b_win32.obj';
90 $bf_enc_src='crypto/bf/asm/b_win32.asm';
91 $cast_enc_obj='crypto/cast/asm/c_win32.obj';
92 $cast_enc_src='crypto/cast/asm/c_win32.asm';
93 $rc4_enc_obj='crypto/rc4/asm/r4_win32.obj';
94 $rc4_enc_src='crypto/rc4/asm/r4_win32.asm';
95 $rc5_enc_obj='crypto/rc5/asm/r5_win32.obj';
96 $rc5_enc_src='crypto/rc5/asm/r5_win32.asm';
97 $md5_asm_obj='crypto/md5/asm/m5_win32.obj';
98 $md5_asm_src='crypto/md5/asm/m5_win32.asm';
99 $sha1_asm_obj='crypto/sha/asm/s1_win32.obj';
100 $sha1_asm_src='crypto/sha/asm/s1_win32.asm';
101 $rmd160_asm_obj='crypto/ripemd/asm/rm_win32.obj';
102 $rmd160_asm_src='crypto/ripemd/asm/rm_win32.asm';
103 $cflags.=" -DBN_ASM -DMD5_ASM -DSHA1_ASM -DRMD160_ASM";
104 }
105
106if ($shlib)
107 {
108 $mlflags.=" $lflags -dll";
109# $cflags =~ s| -MD| -MT|;
110 $lib_cflag=" -D_WINDLL";
111 $out_def="gmout32dll";
112 $tmp_def="gmtmp32dll";
113 }
114
115$cflags.=" -Fd$out_def";
116
117sub do_lib_rule
118 {
119 local($objs,$target,$name,$shlib,$ign,$base_addr, $fips_get_sig, $fips_premain_src)=@_;
120 local($ret,$Name);
121
122 $taget =~ s/\//$o/g if $o ne '/';
123 ($Name=$name) =~ tr/a-z/A-Z/;
124 my $base_arg;
125 if ($base_addr ne "")
126 {
127 $base_arg= " -base:$base_addr";
128 }
129 else
130 {
131 $base_arg = "";
132 }
133
134
135# $target="\$(LIB_D)$o$target";
136 if (!$shlib)
137 {
138# $ret.="\t\$(RM) \$(O_$Name)\n";
139 $ret.="$target: $objs\n";
140 $ex =' advapi32.lib';
141 $ret.="\t\$(MKLIB) $lfile$target $objs $ex\n\n";
142 }
143 else
144 {
145 local($ex)=($target =~ /O_SSL/)?' $(L_CRYPTO)':'';
146 $ex.=' wsock32.lib gdi32.lib advapi32.lib user32.lib';
147 $ex.=" $zlib_lib" if $zlib_opt == 1 && $target =~ /O_CRYPTO/;
148 if (defined $fips_get_sig)
149 {
150 $ret.="$target: \$(O_FIPSCANISTER) $objs $fips_get_sig\n";
151 $ret.="\tFIPS_LINK=\$(LINK) ";
152 $ret.="FIPS_CC=\$(CC) ";
153 $ret.="FIPS_CC_ARGS=\"-Fo\$(OBJ_D)${o}fips_premain.obj \$(SHLIB_CFLAGS) -c\" ";
154 $ret.="FIPS_PREMAIN_DSO=$fips_get_sig ";
155 $ret.="FIPS_TARGET=$target ";
156 $ret.="FIPS_LIBDIR=\$(FIPSLIB_D) ";
157 $ret.="\$(FIPSLINK) \$(MLFLAGS) $base_arg $efile$target ";
158 $ret.="-def:ms/${Name}.def \$(SHLIB_EX_OBJ) $objs ";
159 $ret.="\$(OBJ_D)${o}fips_premain.obj $ex\n\n";
160 }
161 else
162 {
163 $ret.="$target: $objs\n";
164 $ret.="\t\$(LINK) \$(MLFLAGS) $base_arg $efile$target /def:ms/${Name}.def \$(SHLIB_EX_OBJ) $objs $ex\n\n";
165 }
166 }
167 $ret.="\n";
168 return($ret);
169 }
170
171sub do_link_rule
172 {
173 local($target,$files,$dep_libs,$libs,$standalone)=@_;
174 local($ret,$_);
175 $file =~ s/\//$o/g if $o ne '/';
176 $n=&bname($targer);
177 if ($standalone)
178 {
179 $ret.="$target: $files $dep_libs\n";
180 $ret.="\t\$(LINK) \$(LFLAGS) $efile$target ";
181 $ret.="$files $libs\n\n";
182 }
183 elsif ($fips && !$shlib)
184 {
185 $ret.="$target: \$(O_FIPSCANISTER) $files $dep_libs\n";
186 $ret.="\tFIPS_LINK=\$(LINK) ";
187 $ret.="FIPS_CC=\$(CC) ";
188 $ret.="FIPS_CC_ARGS=\"-Fo\$(OBJ_D)${o}fips_premain.obj \$(SHLIB_CFLAGS) -c\" ";
189 $ret.="FIPS_PREMAIN_DSO= ";
190 $ret.="FIPS_TARGET=$target ";
191 $ret.="FIPS_LIBDIR=\$(FIPSLIB_D) ";
192 $ret.=" \$(FIPSLINK) \$(LFLAGS) $efile$target ";
193 $ret.="\$(APP_EX_OBJ) $files \$(OBJ_D)${o}fips_premain.obj $libs\n\n";
194 }
195 else
196 {
197 $ret.="$target: $files $dep_libs\n";
198 $ret.="\t\$(LINK) \$(LFLAGS) $efile$target ";
199 $ret.="\$(APP_EX_OBJ) $files $libs\n\n";
200 }
201 $ret.="\n";
202 return($ret);
203 }
204
205sub do_rlink_rule
206 {
207 local($target,$files,$check_hash, $deps)=@_;
208 local($ret,$_);
209
210 $file =~ s/\//$o/g if $o ne '/';
211 $n=&bname($targer);
212 $ret.="$target: $check_hash $files $deps\n";
213 $ret.="\t\$(PERL) util${o}checkhash.pl -chdir fips-1.0 -program_path ..$o$check_hash\n";
214 $ret.="\t\$(MKCANISTER) $target $files\n";
215 $ret.="\t$check_hash $target > $target.sha1\n";
216 $ret.="\t\$(CP) fips-1.0${o}fips_premain.c \$(FIPSLIB_D)\n";
217 $ret.="\t$check_hash \$(FIPSLIB_D)${o}fips_premain.c > \$(FIPSLIB_D)${o}fips_premain.c.sha1\n\n";
218 return($ret);
219 }
220
221
2221;
diff --git a/src/lib/libcrypto/util/pl/VC-32.pl b/src/lib/libcrypto/util/pl/VC-32.pl
index 8eb3c6c4bd..c3e29fda96 100644
--- a/src/lib/libcrypto/util/pl/VC-32.pl
+++ b/src/lib/libcrypto/util/pl/VC-32.pl
@@ -4,21 +4,7 @@
4# 4#
5 5
6$ssl= "ssleay32"; 6$ssl= "ssleay32";
7 7$crypto="libeay32";
8if ($fips && !$shlib)
9 {
10 $crypto="libeayfips32";
11 $crypto_compat = "libeaycompat32.lib";
12 }
13else
14 {
15 $crypto="libeay32";
16 }
17
18if ($fipscanisterbuild)
19 {
20 $fips_canister_path = "\$(LIB_D)\\fipscanister.lib";
21 }
22 8
23$o='\\'; 9$o='\\';
24$cp='$(PERL) util/copy.pl'; 10$cp='$(PERL) util/copy.pl';
@@ -27,6 +13,10 @@ $rm='del /Q';
27 13
28$zlib_lib="zlib1.lib"; 14$zlib_lib="zlib1.lib";
29 15
16# Santize -L options for ms link
17$l_flags =~ s/-L("\[^"]+")/\/libpath:$1/g;
18$l_flags =~ s/-L(\S+)/\/libpath:$1/g;
19
30# C compiler stuff 20# C compiler stuff
31$cc='cl'; 21$cc='cl';
32if ($FLAVOR =~ /WIN64/) 22if ($FLAVOR =~ /WIN64/)
@@ -42,14 +32,28 @@ if ($FLAVOR =~ /WIN64/)
42 # per 0.9.8 release remaining warnings were explicitly examined and 32 # per 0.9.8 release remaining warnings were explicitly examined and
43 # considered safe to ignore. 33 # considered safe to ignore.
44 # 34 #
45 $base_cflags=' /W3 /Gs0 /GF /Gy /nologo -DWIN32_LEAN_AND_MEAN -DL_ENDIAN -DDSO_WIN32 -DOPENSSL_SYSNAME_WIN32 -DOPENSSL_SYSNAME_WINNT -DUNICODE -D_UNICODE'; 35 $base_cflags= " $mf_cflag";
46 $base_cflags.=' -D_CRT_SECURE_NO_DEPRECATE'; # shut up VC8
47 $base_cflags.=' -D_CRT_NONSTDC_NO_DEPRECATE'; # shut up VC8
48 my $f = $shlib?' /MD':' /MT'; 36 my $f = $shlib?' /MD':' /MT';
49 $lib_cflag='/Zl' if (!$shlib); # remove /DEFAULTLIBs from static lib 37 $lib_cflag='/Zl' if (!$shlib); # remove /DEFAULTLIBs from static lib
50 $opt_cflags=$f.' /Ox'; 38 $opt_cflags=$f.' /Ox';
51 $dbg_cflags=$f.'d /Od -DDEBUG -D_DEBUG'; 39 $dbg_cflags=$f.'d /Od -DDEBUG -D_DEBUG';
52 $lflags="/nologo /subsystem:console /opt:ref"; 40 $lflags="/nologo /subsystem:console /opt:ref";
41
42 *::perlasm_compile_target = sub {
43 my ($target,$source,$bname)=@_;
44 my $ret;
45
46 $bname =~ s/(.*)\.[^\.]$/$1/;
47 $ret=<<___;
48\$(TMP_D)$o$bname.asm: $source
49 set ASM=\$(ASM)
50 \$(PERL) $source \$\@
51
52$target: \$(TMP_D)$o$bname.asm
53 \$(ASM) $afile\$\@ \$(TMP_D)$o$bname.asm
54
55___
56 }
53 } 57 }
54elsif ($FLAVOR =~ /CE/) 58elsif ($FLAVOR =~ /CE/)
55 { 59 {
@@ -99,18 +103,18 @@ elsif ($FLAVOR =~ /CE/)
99 } 103 }
100 104
101 $cc='$(CC)'; 105 $cc='$(CC)';
102 $base_cflags=' /W3 /WX /GF /Gy /nologo -DUNICODE -D_UNICODE -DOPENSSL_SYSNAME_WINCE -DWIN32_LEAN_AND_MEAN -DL_ENDIAN -DDSO_WIN32 -DNO_CHMOD -I$(WCECOMPAT)/include -DOPENSSL_SMALL_FOOTPRINT'; 106 $base_cflags=' /W3 /WX /GF /Gy /nologo -DUNICODE -D_UNICODE -DOPENSSL_SYSNAME_WINCE -DWIN32_LEAN_AND_MEAN -DL_ENDIAN -DDSO_WIN32 -DNO_CHMOD -DOPENSSL_SMALL_FOOTPRINT';
103 $base_cflags.=" $wcecdefs"; 107 $base_cflags.=" $wcecdefs";
108 $base_cflags.=' -I$(WCECOMPAT)/include' if (defined($ENV{'WCECOMPAT'}));
109 $base_cflags.=' -I$(PORTSDK_LIBPATH)/../../include' if (defined($ENV{'PORTSDK_LIBPATH'}));
104 $opt_cflags=' /MC /O1i'; # optimize for space, but with intrinsics... 110 $opt_cflags=' /MC /O1i'; # optimize for space, but with intrinsics...
105 $dbg_clfags=' /MC /Od -DDEBUG -D_DEBUG'; 111 $dbg_clfags=' /MC /Od -DDEBUG -D_DEBUG';
106 $lflags="/nologo /opt:ref $wcelflag"; 112 $lflags="/nologo /opt:ref $wcelflag";
107 } 113 }
108else # Win32 114else # Win32
109 { 115 {
110 $base_cflags=' /W3 /WX /Gs0 /GF /Gy /nologo -DOPENSSL_SYSNAME_WIN32 -DWIN32_LEAN_AND_MEAN -DL_ENDIAN -DDSO_WIN32'; 116 $base_cflags= " $mf_cflag";
111 $base_cflags.=' -D_CRT_SECURE_NO_DEPRECATE'; # shut up VC8 117 my $f = $shlib?' /MD':' /MT';
112 $base_cflags.=' -D_CRT_NONSTDC_NO_DEPRECATE'; # shut up VC8
113 my $f = $shlib || $fips ?' /MD':' /MT';
114 $lib_cflag='/Zl' if (!$shlib); # remove /DEFAULTLIBs from static lib 118 $lib_cflag='/Zl' if (!$shlib); # remove /DEFAULTLIBs from static lib
115 $opt_cflags=$f.' /Ox /O2 /Ob2'; 119 $opt_cflags=$f.' /Ox /O2 /Ob2';
116 $dbg_cflags=$f.'d /Od -DDEBUG -D_DEBUG'; 120 $dbg_cflags=$f.'d /Od -DDEBUG -D_DEBUG';
@@ -118,22 +122,28 @@ else # Win32
118 } 122 }
119$mlflags=''; 123$mlflags='';
120 124
121$out_def="out32"; $out_def.='_$(TARGETCPU)' if ($FLAVOR =~ /CE/); 125$out_def ="out32"; $out_def.="dll" if ($shlib);
122$tmp_def="tmp32"; $tmp_def.='_$(TARGETCPU)' if ($FLAVOR =~ /CE/); 126 $out_def.='_$(TARGETCPU)' if ($FLAVOR =~ /CE/);
127$tmp_def ="tmp32"; $tmp_def.="dll" if ($shlib);
128 $tmp_def.='_$(TARGETCPU)' if ($FLAVOR =~ /CE/);
123$inc_def="inc32"; 129$inc_def="inc32";
124 130
125if ($debug) 131if ($debug)
126 { 132 {
127 $cflags=$dbg_cflags.$base_cflags; 133 $cflags=$dbg_cflags.$base_cflags;
128 $lflags.=" /debug";
129 $mlflags.=' /debug';
130 } 134 }
131else 135else
132 { 136 {
133 $cflags=$opt_cflags.$base_cflags; 137 $cflags=$opt_cflags.$base_cflags;
134 } 138 }
135 139
140# generate symbols.pdb unconditionally
141$app_cflag.=" /Zi /Fd$tmp_def/app";
142$lib_cflag.=" /Zi /Fd$tmp_def/lib";
143$lflags.=" /debug";
144
136$obj='.obj'; 145$obj='.obj';
146$asm_suffix='.asm';
137$ofile="/Fo"; 147$ofile="/Fo";
138 148
139# EXE linking stuff 149# EXE linking stuff
@@ -143,26 +153,23 @@ $efile="/out:";
143$exep='.exe'; 153$exep='.exe';
144if ($no_sock) { $ex_libs=''; } 154if ($no_sock) { $ex_libs=''; }
145elsif ($FLAVOR =~ /CE/) { $ex_libs='winsock.lib'; } 155elsif ($FLAVOR =~ /CE/) { $ex_libs='winsock.lib'; }
146else { $ex_libs='wsock32.lib'; } 156else { $ex_libs='ws2_32.lib'; }
147 157
148if ($FLAVOR =~ /CE/) 158if ($FLAVOR =~ /CE/)
149 { 159 {
150 $ex_libs.=' $(WCECOMPAT)/lib/wcecompatex.lib'; 160 $ex_libs.=' $(WCECOMPAT)/lib/wcecompatex.lib' if (defined($ENV{'WCECOMPAT'}));
161 $ex_libs.=' $(PORTSDK_LIBPATH)/portlib.lib' if (defined($ENV{'PORTSDK_LIBPATH'}));
151 $ex_libs.=' /nodefaultlib:oldnames.lib coredll.lib corelibc.lib' if ($ENV{'TARGETCPU'} eq "X86"); 162 $ex_libs.=' /nodefaultlib:oldnames.lib coredll.lib corelibc.lib' if ($ENV{'TARGETCPU'} eq "X86");
152 } 163 }
153else 164else
154 { 165 {
155 $ex_libs.=' gdi32.lib crypt32.lib advapi32.lib user32.lib'; 166 $ex_libs.=' gdi32.lib advapi32.lib crypt32.lib user32.lib';
156 $ex_libs.=' bufferoverflowu.lib' if ($FLAVOR =~ /WIN64/); 167 $ex_libs.=' bufferoverflowu.lib' if ($FLAVOR =~ /WIN64/ and `cl 2>&1` =~ /14\.00\.4[0-9]{4}\./);
168 # WIN32 UNICODE build gets linked with unicows.lib for
169 # backward compatibility with Win9x.
170 $ex_libs="unicows.lib $ex_libs" if ($FLAVOR =~ /WIN32/ and $cflags =~ /\-DUNICODE/);
157 } 171 }
158 172
159# As native NT API is pure UNICODE, our WIN-NT build defaults to UNICODE,
160# but gets linked with unicows.lib to ensure backward compatibility.
161if ($FLAVOR =~ /NT/)
162 {
163 $cflags.=" -DOPENSSL_SYSNAME_WINNT -DUNICODE -D_UNICODE";
164 $ex_libs="unicows.lib $ex_libs";
165 }
166# static library stuff 173# static library stuff
167$mklib='lib /nologo'; 174$mklib='lib /nologo';
168$ranlib=''; 175$ranlib='';
@@ -173,23 +180,30 @@ $lfile='/out:';
173 180
174$shlib_ex_obj=""; 181$shlib_ex_obj="";
175$app_ex_obj="setargv.obj" if ($FLAVOR !~ /CE/); 182$app_ex_obj="setargv.obj" if ($FLAVOR !~ /CE/);
176if ($nasm) { 183if ($FLAVOR =~ /WIN64A/) {
184 if (`nasm -v 2>NUL` =~ /NASM version ([0-9]+\.[0-9]+)/ && $1 >= 2.0) {
185 $asm='nasm -f win64 -DNEAR -Ox -g';
186 $afile='-o ';
187 } else {
188 $asm='ml64 /c /Cp /Cx /Zi';
189 $afile='/Fo';
190 }
191} elsif ($FLAVOR =~ /WIN64I/) {
192 $asm='ias -d debug';
193 $afile="-o ";
194} elsif ($nasm) {
177 my $ver=`nasm -v 2>NUL`; 195 my $ver=`nasm -v 2>NUL`;
178 my $vew=`nasmw -v 2>NUL`; 196 my $vew=`nasmw -v 2>NUL`;
179 # pick newest version 197 # pick newest version
180 $asm=($ver gt $vew?"nasm":"nasmw")." -f win32"; 198 $asm=($ver gt $vew?"nasm":"nasmw")." -f win32";
199 $asmtype="win32n";
181 $afile='-o '; 200 $afile='-o ';
182} elsif ($ml64) {
183 $asm='ml64 /c /Cp /Cx';
184 $asm.=' /Zi' if $debug;
185 $afile='/Fo';
186} else { 201} else {
187 $asm='ml /nologo /Cp /coff /c /Cx'; 202 $asm='ml /nologo /Cp /coff /c /Cx /Zi';
188 $asm.=" /Zi" if $debug;
189 $afile='/Fo'; 203 $afile='/Fo';
204 $asmtype="win32";
190} 205}
191 206
192$aes_asm_obj='';
193$bn_asm_obj=''; 207$bn_asm_obj='';
194$bn_asm_src=''; 208$bn_asm_src='';
195$des_enc_obj=''; 209$des_enc_obj='';
@@ -198,56 +212,26 @@ $bf_enc_obj='';
198$bf_enc_src=''; 212$bf_enc_src='';
199 213
200if (!$no_asm) 214if (!$no_asm)
201 {
202 if ($FLAVOR =~ "WIN32")
203 {
204 $aes_asm_obj='crypto\aes\asm\a_win32.obj';
205 $aes_asm_src='crypto\aes\asm\a_win32.asm';
206 $bn_asm_obj='crypto\bn\asm\bn_win32.obj crypto\bn\asm\mt_win32.obj';
207 $bn_asm_src='crypto\bn\asm\bn_win32.asm crypto\bn\asm\mt_win32.asm';
208 $bnco_asm_obj='crypto\bn\asm\co_win32.obj';
209 $bnco_asm_src='crypto\bn\asm\co_win32.asm';
210 $des_enc_obj='crypto\des\asm\d_win32.obj crypto\des\asm\y_win32.obj';
211 $des_enc_src='crypto\des\asm\d_win32.asm crypto\des\asm\y_win32.asm';
212 $bf_enc_obj='crypto\bf\asm\b_win32.obj';
213 $bf_enc_src='crypto\bf\asm\b_win32.asm';
214 $cast_enc_obj='crypto\cast\asm\c_win32.obj';
215 $cast_enc_src='crypto\cast\asm\c_win32.asm';
216 $rc4_enc_obj='crypto\rc4\asm\r4_win32.obj';
217 $rc4_enc_src='crypto\rc4\asm\r4_win32.asm';
218 $rc5_enc_obj='crypto\rc5\asm\r5_win32.obj';
219 $rc5_enc_src='crypto\rc5\asm\r5_win32.asm';
220 $md5_asm_obj='crypto\md5\asm\m5_win32.obj';
221 $md5_asm_src='crypto\md5\asm\m5_win32.asm';
222 $sha1_asm_obj='crypto\sha\asm\s1_win32.obj crypto\sha\asm\sha512-sse2.obj';
223 $sha1_asm_src='crypto\sha\asm\s1_win32.asm crypto\sha\asm\sha512-sse2.asm';
224 $rmd160_asm_obj='crypto\ripemd\asm\rm_win32.obj';
225 $rmd160_asm_src='crypto\ripemd\asm\rm_win32.asm';
226 $cpuid_asm_obj='crypto\cpu_win32.obj';
227 $cpuid_asm_src='crypto\cpu_win32.asm';
228 $cflags.=" -DOPENSSL_CPUID_OBJ -DOPENSSL_IA32_SSE2 -DAES_ASM -DBN_ASM -DOPENSSL_BN_ASM_PART_WORDS -DOPENSSL_BN_ASM_MONT -DMD5_ASM -DSHA1_ASM -DRMD160_ASM";
229 }
230 elsif ($FLAVOR =~ "WIN64A")
231 { 215 {
232 $aes_asm_obj='$(OBJ_D)\aes-x86_64.obj'; 216 win32_import_asm($mf_bn_asm, "bn", \$bn_asm_obj, \$bn_asm_src);
233 $aes_asm_src='crypto\aes\asm\aes-x86_64.asm'; 217 win32_import_asm($mf_aes_asm, "aes", \$aes_asm_obj, \$aes_asm_src);
234 $bn_asm_obj='$(OBJ_D)\x86_64-mont.obj $(OBJ_D)\bn_asm.obj'; 218 win32_import_asm($mf_des_asm, "des", \$des_enc_obj, \$des_enc_src);
235 $bn_asm_src='crypto\bn\asm\x86_64-mont.asm'; 219 win32_import_asm($mf_bf_asm, "bf", \$bf_enc_obj, \$bf_enc_src);
236 $sha1_asm_obj='$(OBJ_D)\sha1-x86_64.obj $(OBJ_D)\sha256-x86_64.obj $(OBJ_D)\sha512-x86_64.obj'; 220 win32_import_asm($mf_cast_asm, "cast", \$cast_enc_obj, \$cast_enc_src);
237 $sha1_asm_src='crypto\sha\asm\sha1-x86_64.asm crypto\sha\asm\sha256-x86_64.asm crypto\sha\asm\sha512-x86_64.asm'; 221 win32_import_asm($mf_rc4_asm, "rc4", \$rc4_enc_obj, \$rc4_enc_src);
238 $cpuid_asm_obj='$(OBJ_D)\cpuid-x86_64.obj'; 222 win32_import_asm($mf_rc5_asm, "rc5", \$rc5_enc_obj, \$rc5_enc_src);
239 $cpuid_asm_src='crypto\cpuid-x86_64.asm'; 223 win32_import_asm($mf_md5_asm, "md5", \$md5_asm_obj, \$md5_asm_src);
240 $cflags.=" -DOPENSSL_CPUID_OBJ -DAES_ASM -DOPENSSL_BN_ASM_MONT -DSHA1_ASM -DSHA256_ASM -DSHA512_ASM"; 224 win32_import_asm($mf_sha_asm, "sha", \$sha1_asm_obj, \$sha1_asm_src);
225 win32_import_asm($mf_rmd_asm, "ripemd", \$rmd160_asm_obj, \$rmd160_asm_src);
226 win32_import_asm($mf_wp_asm, "whrlpool", \$whirlpool_asm_obj, \$whirlpool_asm_src);
227 win32_import_asm($mf_cpuid_asm, "", \$cpuid_asm_obj, \$cpuid_asm_src);
228 $perl_asm = 1;
241 } 229 }
242 }
243 230
244if ($shlib && $FLAVOR !~ /CE/) 231if ($shlib && $FLAVOR !~ /CE/)
245 { 232 {
246 $mlflags.=" $lflags /dll"; 233 $mlflags.=" $lflags /dll";
247# $cflags =~ s| /MD| /MT|; 234 $lib_cflag.=" -D_WINDLL";
248 $lib_cflag=" -D_WINDLL";
249 $out_def="out32dll";
250 $tmp_def="tmp32dll";
251 # 235 #
252 # Engage Applink... 236 # Engage Applink...
253 # 237 #
@@ -267,8 +251,8 @@ $(INCO_D)\applink.c: ms\applink.c
267EXHEADER= $(EXHEADER) $(INCO_D)\applink.c 251EXHEADER= $(EXHEADER) $(INCO_D)\applink.c
268 252
269LIBS_DEP=$(LIBS_DEP) $(OBJ_D)\applink.obj 253LIBS_DEP=$(LIBS_DEP) $(OBJ_D)\applink.obj
254CRYPTOOBJ=$(OBJ_D)\uplink.obj $(CRYPTOOBJ)
270___ 255___
271$banner .= "CRYPTOOBJ=\$(OBJ_D)\\uplink.obj \$(CRYPTOOBJ)\n";
272 $banner.=<<'___' if ($FLAVOR =~ /WIN64/); 256 $banner.=<<'___' if ($FLAVOR =~ /WIN64/);
273CRYPTOOBJ=ms\uptable.obj $(CRYPTOOBJ) 257CRYPTOOBJ=ms\uptable.obj $(CRYPTOOBJ)
274___ 258___
@@ -276,119 +260,35 @@ ___
276elsif ($shlib && $FLAVOR =~ /CE/) 260elsif ($shlib && $FLAVOR =~ /CE/)
277 { 261 {
278 $mlflags.=" $lflags /dll"; 262 $mlflags.=" $lflags /dll";
279 $lib_cflag=" -D_WINDLL -D_DLL"; 263 $lflags.=' /entry:mainCRTstartup' if(defined($ENV{'PORTSDK_LIBPATH'}));
280 $out_def='out32dll_$(TARGETCPU)'; 264 $lib_cflag.=" -D_WINDLL -D_DLL";
281 $tmp_def='tmp32dll_$(TARGETCPU)';
282 } 265 }
283 266
284$cflags.=" /Fd$out_def";
285
286sub do_lib_rule 267sub do_lib_rule
287 { 268 {
288 my($objs,$target,$name,$shlib,$ign,$base_addr) = @_; 269 local($objs,$target,$name,$shlib)=@_;
289 local($ret); 270 local($ret);
290 271
291 $taget =~ s/\//$o/g if $o ne '/'; 272 $taget =~ s/\//$o/g if $o ne '/';
292 my $base_arg; 273 if ($name ne "")
293 if ($base_addr ne "")
294 {
295 $base_arg= " /base:$base_addr";
296 }
297 else
298 {
299 $base_arg = "";
300 }
301 if ($target =~ /O_CRYPTO/ && $fipsdso)
302 {
303 $name = "/def:ms/libeayfips.def";
304 }
305 elsif ($name ne "")
306 { 274 {
307 $name =~ tr/a-z/A-Z/; 275 $name =~ tr/a-z/A-Z/;
308 $name = "/def:ms/${name}.def"; 276 $name = "/def:ms/${name}.def";
309 } 277 }
278
310# $target="\$(LIB_D)$o$target"; 279# $target="\$(LIB_D)$o$target";
311# $ret.="$target: $objs\n"; 280 $ret.="$target: $objs\n";
312 if (!$shlib) 281 if (!$shlib)
313 { 282 {
314# $ret.="\t\$(RM) \$(O_$Name)\n"; 283# $ret.="\t\$(RM) \$(O_$Name)\n";
315 $ex =' '; 284 $ret.="\t\$(MKLIB) $lfile$target @<<\n $objs\n<<\n";
316 $ret.="$target: $objs\n";
317 $ret.="\t\$(MKLIB) $lfile$target @<<\n $objs $ex\n<<\n";
318 } 285 }
319 else 286 else
320 { 287 {
321 my $ex = ""; 288 local($ex)=($target =~ /O_CRYPTO/)?'':' $(L_CRYPTO)';
322 if ($target =~ /O_SSL/)
323 {
324 $ex .= " \$(L_CRYPTO)";
325 #$ex .= " \$(L_FIPS)" if $fipsdso;
326 }
327 my $fipstarget;
328 if ($fipsdso)
329 {
330 $fipstarget = "O_FIPS";
331 }
332 else
333 {
334 $fipstarget = "O_CRYPTO";
335 }
336
337
338 if ($name eq "")
339 {
340 $ex.=' bufferoverflowu.lib' if ($FLAVOR =~ /WIN64/);
341 if ($target =~ /capi/)
342 {
343 $ex.=' crypt32.lib advapi32.lib';
344 }
345 }
346 elsif ($FLAVOR =~ /CE/)
347 {
348 $ex.=' winsock.lib $(WCECOMPAT)/lib/wcecompatex.lib';
349 }
350 else
351 {
352 $ex.=' unicows.lib' if ($FLAVOR =~ /NT/);
353 $ex.=' wsock32.lib gdi32.lib advapi32.lib user32.lib';
354 $ex.=' crypt32.lib';
355 $ex.=' bufferoverflowu.lib' if ($FLAVOR =~ /WIN64/);
356 }
357 $ex.=" $zlib_lib" if $zlib_opt == 1 && $target =~ /O_CRYPTO/; 289 $ex.=" $zlib_lib" if $zlib_opt == 1 && $target =~ /O_CRYPTO/;
358 290 $ret.="\t\$(LINK) \$(MLFLAGS) $efile$target $name @<<\n \$(SHLIB_EX_OBJ) $objs $ex \$(EX_LIBS)\n<<\n";
359 if ($fips && $target =~ /$fipstarget/) 291 $ret.="\tIF EXIST \$@.manifest mt -nologo -manifest \$@.manifest -outputresource:\$@;2\n\n";
360 {
361 $ex.= $mwex unless $fipscanisterbuild;
362 $ret.="$target: $objs \$(PREMAIN_DSO_EXE)";
363 if ($fipsdso)
364 {
365 $ex.=" \$(OBJ_D)\\\$(LIBFIPS).res";
366 $ret.=" \$(OBJ_D)\\\$(LIBFIPS).res";
367 $ret.=" ms/\$(LIBFIPS).def";
368 }
369 $ret.="\n\tSET FIPS_LINK=\$(LINK)\n";
370 $ret.="\tSET FIPS_CC=\$(CC)\n";
371 $ret.="\tSET FIPS_CC_ARGS=/Fo\$(OBJ_D)${o}fips_premain.obj \$(SHLIB_CFLAGS) -c\n";
372 $ret.="\tSET PREMAIN_DSO_EXE=\$(PREMAIN_DSO_EXE)\n";
373 $ret.="\tSET FIPS_SHA1_EXE=\$(FIPS_SHA1_EXE)\n";
374 $ret.="\tSET FIPS_TARGET=$target\n";
375 $ret.="\tSET FIPSLIB_D=\$(FIPSLIB_D)\n";
376 $ret.="\t\$(FIPSLINK) \$(MLFLAGS) /map $base_arg $efile$target ";
377 $ret.="$name @<<\n \$(SHLIB_EX_OBJ) $objs ";
378 $ret.="\$(OBJ_D)${o}fips_premain.obj $ex\n<<\n";
379 }
380 else
381 {
382 $ret.="$target: $objs";
383 if ($target =~ /O_CRYPTO/ && $fipsdso)
384 {
385 $ret .= " \$(O_FIPS)";
386 $ex .= " \$(L_FIPS)";
387 }
388 $ret.="\n\t\$(LINK) \$(MLFLAGS) $efile$target $name @<<\n \$(SHLIB_EX_OBJ) $objs $ex\n<<\n";
389 }
390
391 $ret.="\tIF EXIST \$@.manifest mt -nologo -manifest \$@.manifest -outputresource:\$@;2\n\n";
392 } 292 }
393 $ret.="\n"; 293 $ret.="\n";
394 return($ret); 294 return($ret);
@@ -396,64 +296,43 @@ sub do_lib_rule
396 296
397sub do_link_rule 297sub do_link_rule
398 { 298 {
399 my($target,$files,$dep_libs,$libs,$standalone)=@_; 299 local($target,$files,$dep_libs,$libs)=@_;
400 local($ret,$_); 300 local($ret,$_);
301
401 $file =~ s/\//$o/g if $o ne '/'; 302 $file =~ s/\//$o/g if $o ne '/';
402 $n=&bname($targer); 303 $n=&bname($targer);
403 $ret.="$target: $files $dep_libs\n"; 304 $ret.="$target: $files $dep_libs\n";
404 if ($standalone == 1) 305 $ret.="\t\$(LINK) \$(LFLAGS) $efile$target @<<\n";
405 { 306 $ret.=" \$(APP_EX_OBJ) $files $libs\n<<\n";
406 $ret.=" \$(LINK) \$(LFLAGS) $efile$target @<<\n\t"; 307 $ret.="\tIF EXIST \$@.manifest mt -nologo -manifest \$@.manifest -outputresource:\$@;1\n\n";
407 $ret.= "\$(EX_LIBS) " if ($files =~ /O_FIPSCANISTER/ && !$fipscanisterbuild); 308 return($ret);
408 $ret.="$files $libs\n<<\n"; 309 }
409 } 310
410 elsif ($standalone == 2) 311sub win32_import_asm
312 {
313 my ($mf_var, $asm_name, $oref, $sref) = @_;
314 my $asm_dir;
315 if ($asm_name eq "")
411 { 316 {
412 $ret.="\tSET FIPS_LINK=\$(LINK)\n"; 317 $asm_dir = "crypto\\";
413 $ret.="\tSET FIPS_CC=\$(CC)\n";
414 $ret.="\tSET FIPS_CC_ARGS=/Fo\$(OBJ_D)${o}fips_premain.obj \$(SHLIB_CFLAGS) -c\n";
415 $ret.="\tSET PREMAIN_DSO_EXE=\n";
416 $ret.="\tSET FIPS_TARGET=$target\n";
417 $ret.="\tSET FIPS_SHA1_EXE=\$(FIPS_SHA1_EXE)\n";
418 $ret.="\tSET FIPSLIB_D=\$(FIPSLIB_D)\n";
419 $ret.="\t\$(FIPSLINK) \$(LFLAGS) /map $efile$target @<<\n";
420 $ret.="\t\$(APP_EX_OBJ) $files \$(OBJ_D)${o}fips_premain.obj $libs\n<<\n";
421 } 318 }
422 else 319 else
423 { 320 {
424 $ret.="\t\$(LINK) \$(LFLAGS) $efile$target @<<\n"; 321 $asm_dir = "crypto\\$asm_name\\asm\\";
425 $ret.="\t\$(APP_EX_OBJ) $files $libs\n<<\n";
426 } 322 }
427 $ret.="\tIF EXIST \$@.manifest mt -nologo -manifest \$@.manifest -outputresource:\$@;1\n\n";
428 return($ret);
429 }
430 323
431sub do_rlink_rule 324 $$oref = "";
432 { 325 $mf_var =~ s/\.o$/.obj/g;
433 local($target,$rl_start, $rl_mid, $rl_end,$dep_libs,$libs)=@_;
434 local($ret,$_);
435 my $files = "$rl_start $rl_mid $rl_end";
436 326
437 $file =~ s/\//$o/g if $o ne '/'; 327 foreach (split(/ /, $mf_var))
438 $n=&bname($targer); 328 {
439 $ret.="$target: $files $dep_libs \$(FIPS_SHA1_EXE)\n"; 329 $$oref .= $asm_dir . $_ . " ";
440 $ret.="\t\$(PERL) ms\\segrenam.pl \$\$a $rl_start\n"; 330 }
441 $ret.="\t\$(PERL) ms\\segrenam.pl \$\$b $rl_mid\n"; 331 $$oref =~ s/ $//;
442 $ret.="\t\$(PERL) ms\\segrenam.pl \$\$c $rl_end\n"; 332 $$sref = $$oref;
443 $ret.="\t\$(MKLIB) $lfile$target @<<\n\t$files\n<<\n"; 333 $$sref =~ s/\.obj/.asm/g;
444 $ret.="\t\$(FIPS_SHA1_EXE) $target > ${target}.sha1\n";
445 $ret.="\t\$(PERL) util${o}copy.pl -stripcr fips${o}fips_premain.c \$(LIB_D)${o}fips_premain.c\n";
446 $ret.="\t\$(CP) fips${o}fips_premain.c.sha1 \$(LIB_D)${o}fips_premain.c.sha1\n";
447 $ret.="\n";
448 return($ret);
449 }
450 334
451sub do_sdef_rule
452 {
453 my $ret = "ms/\$(LIBFIPS).def: \$(O_FIPSCANISTER)\n";
454 $ret.="\t\$(PERL) util/mksdef.pl \$(MLFLAGS) /out:dummy.dll /def:ms/libeay32.def @<<\n \$(O_FIPSCANISTER)\n<<\n";
455 $ret.="\n";
456 return $ret;
457 } 335 }
458 336
337
4591; 3381;
diff --git a/src/lib/libcrypto/util/pl/VC-CE.pl b/src/lib/libcrypto/util/pl/VC-CE.pl
deleted file mode 100644
index 2fd0c4dd32..0000000000
--- a/src/lib/libcrypto/util/pl/VC-CE.pl
+++ /dev/null
@@ -1,116 +0,0 @@
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="";
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,$sha1file,$openssl)=@_;
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";
108 if (defined $sha1file)
109 {
110 $ret.=" $openssl sha1 -hmac etaonrishdlcupfm -binary $target > $sha1file";
111 }
112 $ret.="\n";
113 return($ret);
114 }
115
1161;
diff --git a/src/lib/libcrypto/util/pod2man.pl b/src/lib/libcrypto/util/pod2man.pl
index 546d1ec186..025d914f2e 100644
--- a/src/lib/libcrypto/util/pod2man.pl
+++ b/src/lib/libcrypto/util/pod2man.pl
@@ -425,7 +425,7 @@ if ($name ne 'something') {
425 } 425 }
426 next if /^=cut\b/; # DB_File and Net::Ping have =cut before NAME 426 next if /^=cut\b/; # DB_File and Net::Ping have =cut before NAME
427 next if /^=pod\b/; # It is OK to have =pod before NAME 427 next if /^=pod\b/; # It is OK to have =pod before NAME
428 next if /^=for\s+comment\b/; # It is OK to have =for comment before NAME 428 next if /^=(for|begin|end)\s+comment\b/; # It is OK to have =for =begin or =end comment before NAME
429 die "$0: Invalid man page - 1st pod line is not NAME in $ARGV[0]\n" unless $lax; 429 die "$0: Invalid man page - 1st pod line is not NAME in $ARGV[0]\n" unless $lax;
430 } 430 }
431 die "$0: Invalid man page - no documentation in $ARGV[0]\n" unless $lax; 431 die "$0: Invalid man page - no documentation in $ARGV[0]\n" unless $lax;
diff --git a/src/lib/libcrypto/util/point.sh b/src/lib/libcrypto/util/point.sh
index 4790e08f8a..da39899cb1 100644
--- a/src/lib/libcrypto/util/point.sh
+++ b/src/lib/libcrypto/util/point.sh
@@ -1,7 +1,7 @@
1#!/bin/sh 1#!/bin/sh
2 2
3rm -f "$2" 3rm -f "$2"
4if test "$OSTYPE" = msdosdjgpp; then 4if test "$OSTYPE" = msdosdjgpp || test "x$PLATFORM" = xmingw ; then
5 cp "$1" "$2" 5 cp "$1" "$2"
6else 6else
7 ln -s "$1" "$2" 7 ln -s "$1" "$2"
diff --git a/src/lib/libcrypto/util/selftest.pl b/src/lib/libcrypto/util/selftest.pl
index 4778c5ab01..7b32e9f4ff 100644
--- a/src/lib/libcrypto/util/selftest.pl
+++ b/src/lib/libcrypto/util/selftest.pl
@@ -78,7 +78,7 @@ print OUT "\n";
78 78
79print "Checking compiler...\n"; 79print "Checking compiler...\n";
80if (open(TEST,">cctest.c")) { 80if (open(TEST,">cctest.c")) {
81 print TEST "#include <stdio.h>\n#include <errno.h>\nmain(){printf(\"Hello world\\n\");}\n"; 81 print TEST "#include <stdio.h>\n#include <stdlib.h>\n#include <errno.h>\nmain(){printf(\"Hello world\\n\");}\n";
82 close(TEST); 82 close(TEST);
83 system("$cc -o cctest cctest.c"); 83 system("$cc -o cctest cctest.c");
84 if (`./cctest` !~ /Hello world/) { 84 if (`./cctest` !~ /Hello world/) {
@@ -96,7 +96,7 @@ if (open(TEST,">cctest.c")) {
96 print OUT "Can't create cctest.c\n"; 96 print OUT "Can't create cctest.c\n";
97} 97}
98if (open(TEST,">cctest.c")) { 98if (open(TEST,">cctest.c")) {
99 print TEST "#include <openssl/opensslv.h>\nmain(){printf(OPENSSL_VERSION_TEXT);}\n"; 99 print TEST "#include <stdio.h>\n#include <stdlib.h>\n#include <openssl/opensslv.h>\nmain(){printf(OPENSSL_VERSION_TEXT);}\n";
100 close(TEST); 100 close(TEST);
101 system("$cc -o cctest -Iinclude cctest.c"); 101 system("$cc -o cctest -Iinclude cctest.c");
102 $cctest = `./cctest`; 102 $cctest = `./cctest`;
diff --git a/src/lib/libcrypto/util/ssleay.num b/src/lib/libcrypto/util/ssleay.num
index 2055cc1597..15a58e7b13 100644
--- a/src/lib/libcrypto/util/ssleay.num
+++ b/src/lib/libcrypto/util/ssleay.num
@@ -98,9 +98,9 @@ SSLeay_add_ssl_algorithms 109 NOEXIST::FUNCTION:
98SSLv23_client_method 110 EXIST::FUNCTION:RSA 98SSLv23_client_method 110 EXIST::FUNCTION:RSA
99SSLv23_method 111 EXIST::FUNCTION:RSA 99SSLv23_method 111 EXIST::FUNCTION:RSA
100SSLv23_server_method 112 EXIST::FUNCTION:RSA 100SSLv23_server_method 112 EXIST::FUNCTION:RSA
101SSLv2_client_method 113 EXIST::FUNCTION:RSA 101SSLv2_client_method 113 EXIST::FUNCTION:RSA,SSL2
102SSLv2_method 114 EXIST::FUNCTION:RSA 102SSLv2_method 114 EXIST::FUNCTION:RSA,SSL2
103SSLv2_server_method 115 EXIST::FUNCTION:RSA 103SSLv2_server_method 115 EXIST::FUNCTION:RSA,SSL2
104SSLv3_client_method 116 EXIST::FUNCTION: 104SSLv3_client_method 116 EXIST::FUNCTION:
105SSLv3_method 117 EXIST::FUNCTION: 105SSLv3_method 117 EXIST::FUNCTION:
106SSLv3_server_method 118 EXIST::FUNCTION: 106SSLv3_server_method 118 EXIST::FUNCTION:
@@ -117,8 +117,8 @@ SSL_CIPHER_get_bits 128 EXIST::FUNCTION:
117SSL_CIPHER_get_version 129 EXIST::FUNCTION: 117SSL_CIPHER_get_version 129 EXIST::FUNCTION:
118SSL_CIPHER_get_name 130 EXIST::FUNCTION: 118SSL_CIPHER_get_name 130 EXIST::FUNCTION:
119BIO_ssl_shutdown 131 EXIST::FUNCTION:BIO 119BIO_ssl_shutdown 131 EXIST::FUNCTION:BIO
120SSL_SESSION_cmp 132 EXIST::FUNCTION: 120SSL_SESSION_cmp 132 NOEXIST::FUNCTION:
121SSL_SESSION_hash 133 EXIST::FUNCTION: 121SSL_SESSION_hash 133 NOEXIST::FUNCTION:
122SSL_SESSION_get_time 134 EXIST::FUNCTION: 122SSL_SESSION_get_time 134 EXIST::FUNCTION:
123SSL_SESSION_set_time 135 EXIST::FUNCTION: 123SSL_SESSION_set_time 135 EXIST::FUNCTION:
124SSL_SESSION_get_timeout 136 EXIST::FUNCTION: 124SSL_SESSION_get_timeout 136 EXIST::FUNCTION:
@@ -242,3 +242,20 @@ SSL_set_SSL_CTX 290 EXIST::FUNCTION:
242SSL_get_servername 291 EXIST::FUNCTION:TLSEXT 242SSL_get_servername 291 EXIST::FUNCTION:TLSEXT
243SSL_get_servername_type 292 EXIST::FUNCTION:TLSEXT 243SSL_get_servername_type 292 EXIST::FUNCTION:TLSEXT
244SSL_CTX_set_client_cert_engine 293 EXIST::FUNCTION:ENGINE 244SSL_CTX_set_client_cert_engine 293 EXIST::FUNCTION:ENGINE
245SSL_CTX_use_psk_identity_hint 294 EXIST::FUNCTION:PSK
246SSL_CTX_set_psk_client_callback 295 EXIST::FUNCTION:PSK
247PEM_write_bio_SSL_SESSION 296 EXIST::FUNCTION:
248SSL_get_psk_identity_hint 297 EXIST::FUNCTION:PSK
249SSL_set_psk_server_callback 298 EXIST::FUNCTION:PSK
250SSL_use_psk_identity_hint 299 EXIST::FUNCTION:PSK
251SSL_set_psk_client_callback 300 EXIST::FUNCTION:PSK
252PEM_read_SSL_SESSION 301 EXIST:!WIN16:FUNCTION:
253PEM_read_bio_SSL_SESSION 302 EXIST::FUNCTION:
254SSL_CTX_set_psk_server_callback 303 EXIST::FUNCTION:PSK
255SSL_get_psk_identity 304 EXIST::FUNCTION:PSK
256PEM_write_SSL_SESSION 305 EXIST:!WIN16:FUNCTION:
257SSL_set_session_ticket_ext 306 EXIST::FUNCTION:
258SSL_set_session_secret_cb 307 EXIST::FUNCTION:
259SSL_set_session_ticket_ext_cb 308 EXIST::FUNCTION:
260SSL_set1_param 309 EXIST::FUNCTION:
261SSL_CTX_set1_param 310 EXIST::FUNCTION:
diff --git a/src/lib/libcrypto/x509/Makefile.ssl b/src/lib/libcrypto/x509/Makefile.ssl
deleted file mode 100644
index 3a3452536c..0000000000
--- a/src/lib/libcrypto/x509/Makefile.ssl
+++ /dev/null
@@ -1,594 +0,0 @@
1#
2# SSLeay/crypto/x509/Makefile
3#
4
5DIR= x509
6TOP= ../..
7CC= cc
8INCLUDES= -I.. -I$(TOP) -I../../include
9CFLAG=-g
10INSTALL_PREFIX=
11OPENSSLDIR= /usr/local/ssl
12INSTALLTOP=/usr/local/ssl
13MAKE= make -f Makefile.ssl
14MAKEDEPPROG= makedepend
15MAKEDEPEND= $(TOP)/util/domd $(TOP) -MD $(MAKEDEPPROG)
16MAKEFILE= Makefile.ssl
17AR= ar r
18
19CFLAGS= $(INCLUDES) $(CFLAG)
20
21GENERAL=Makefile README
22TEST=
23APPS=
24
25LIB=$(TOP)/libcrypto.a
26LIBSRC= x509_def.c x509_d2.c x509_r2x.c x509_cmp.c \
27 x509_obj.c x509_req.c x509spki.c x509_vfy.c \
28 x509_set.c x509cset.c x509rset.c x509_err.c \
29 x509name.c x509_v3.c x509_ext.c x509_att.c \
30 x509type.c x509_lu.c x_all.c x509_txt.c \
31 x509_trs.c by_file.c by_dir.c
32LIBOBJ= x509_def.o x509_d2.o x509_r2x.o x509_cmp.o \
33 x509_obj.o x509_req.o x509spki.o x509_vfy.o \
34 x509_set.o x509cset.o x509rset.o x509_err.o \
35 x509name.o x509_v3.o x509_ext.o x509_att.o \
36 x509type.o x509_lu.o x_all.o x509_txt.o \
37 x509_trs.o by_file.o by_dir.o
38
39SRC= $(LIBSRC)
40
41EXHEADER= x509.h x509_vfy.h
42HEADER= $(EXHEADER)
43
44ALL= $(GENERAL) $(SRC) $(HEADER)
45
46top:
47 (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all)
48
49all: lib
50
51lib: $(LIBOBJ)
52 $(AR) $(LIB) $(LIBOBJ)
53 $(RANLIB) $(LIB) || echo Never mind.
54 @touch lib
55
56files:
57 $(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO
58
59links:
60 @sh $(TOP)/util/point.sh Makefile.ssl Makefile
61 @$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER)
62 @$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST)
63 @$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS)
64
65install:
66 @for i in $(EXHEADER) ; \
67 do \
68 (cp $$i $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i; \
69 chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i ); \
70 done;
71
72tags:
73 ctags $(SRC)
74
75tests:
76
77lint:
78 lint -DLINT $(INCLUDES) $(SRC)>fluff
79
80depend:
81 $(MAKEDEPEND) -- $(CFLAG) $(INCLUDES) $(DEPFLAG) -- $(PROGS) $(LIBSRC)
82
83dclean:
84 $(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
85 mv -f Makefile.new $(MAKEFILE)
86
87clean:
88 rm -f *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff
89
90# DO NOT DELETE THIS LINE -- make depend depends on it.
91
92by_dir.o: ../../e_os.h ../../include/openssl/aes.h ../../include/openssl/asn1.h
93by_dir.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h
94by_dir.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
95by_dir.o: ../../include/openssl/cast.h ../../include/openssl/crypto.h
96by_dir.o: ../../include/openssl/des.h ../../include/openssl/des_old.h
97by_dir.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
98by_dir.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
99by_dir.o: ../../include/openssl/evp.h ../../include/openssl/idea.h
100by_dir.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h
101by_dir.o: ../../include/openssl/md4.h ../../include/openssl/md5.h
102by_dir.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h
103by_dir.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
104by_dir.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
105by_dir.o: ../../include/openssl/pkcs7.h ../../include/openssl/rc2.h
106by_dir.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
107by_dir.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
108by_dir.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
109by_dir.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
110by_dir.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
111by_dir.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
112by_dir.o: ../cryptlib.h by_dir.c
113by_file.o: ../../e_os.h ../../include/openssl/aes.h
114by_file.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
115by_file.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
116by_file.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
117by_file.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
118by_file.o: ../../include/openssl/des_old.h ../../include/openssl/dh.h
119by_file.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
120by_file.o: ../../include/openssl/err.h ../../include/openssl/evp.h
121by_file.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h
122by_file.o: ../../include/openssl/md2.h ../../include/openssl/md4.h
123by_file.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
124by_file.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
125by_file.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
126by_file.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pem.h
127by_file.o: ../../include/openssl/pem2.h ../../include/openssl/pkcs7.h
128by_file.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h
129by_file.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h
130by_file.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
131by_file.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
132by_file.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
133by_file.o: ../../include/openssl/ui_compat.h ../../include/openssl/x509.h
134by_file.o: ../../include/openssl/x509_vfy.h ../cryptlib.h by_file.c
135x509_att.o: ../../e_os.h ../../include/openssl/aes.h
136x509_att.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
137x509_att.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
138x509_att.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
139x509_att.o: ../../include/openssl/conf.h ../../include/openssl/crypto.h
140x509_att.o: ../../include/openssl/des.h ../../include/openssl/des_old.h
141x509_att.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
142x509_att.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
143x509_att.o: ../../include/openssl/evp.h ../../include/openssl/idea.h
144x509_att.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h
145x509_att.o: ../../include/openssl/md4.h ../../include/openssl/md5.h
146x509_att.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h
147x509_att.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
148x509_att.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
149x509_att.o: ../../include/openssl/pkcs7.h ../../include/openssl/rc2.h
150x509_att.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
151x509_att.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
152x509_att.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
153x509_att.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
154x509_att.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
155x509_att.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
156x509_att.o: ../../include/openssl/x509v3.h ../cryptlib.h x509_att.c
157x509_cmp.o: ../../e_os.h ../../include/openssl/aes.h
158x509_cmp.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
159x509_cmp.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
160x509_cmp.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
161x509_cmp.o: ../../include/openssl/conf.h ../../include/openssl/crypto.h
162x509_cmp.o: ../../include/openssl/des.h ../../include/openssl/des_old.h
163x509_cmp.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
164x509_cmp.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
165x509_cmp.o: ../../include/openssl/evp.h ../../include/openssl/idea.h
166x509_cmp.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h
167x509_cmp.o: ../../include/openssl/md4.h ../../include/openssl/md5.h
168x509_cmp.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h
169x509_cmp.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
170x509_cmp.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
171x509_cmp.o: ../../include/openssl/pkcs7.h ../../include/openssl/rc2.h
172x509_cmp.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
173x509_cmp.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
174x509_cmp.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
175x509_cmp.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
176x509_cmp.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
177x509_cmp.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
178x509_cmp.o: ../../include/openssl/x509v3.h ../cryptlib.h x509_cmp.c
179x509_d2.o: ../../e_os.h ../../include/openssl/aes.h
180x509_d2.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
181x509_d2.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
182x509_d2.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
183x509_d2.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
184x509_d2.o: ../../include/openssl/des_old.h ../../include/openssl/dh.h
185x509_d2.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
186x509_d2.o: ../../include/openssl/err.h ../../include/openssl/evp.h
187x509_d2.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h
188x509_d2.o: ../../include/openssl/md2.h ../../include/openssl/md4.h
189x509_d2.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
190x509_d2.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
191x509_d2.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
192x509_d2.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h
193x509_d2.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h
194x509_d2.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h
195x509_d2.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
196x509_d2.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
197x509_d2.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
198x509_d2.o: ../../include/openssl/ui_compat.h ../../include/openssl/x509.h
199x509_d2.o: ../../include/openssl/x509_vfy.h ../cryptlib.h x509_d2.c
200x509_def.o: ../../e_os.h ../../include/openssl/aes.h
201x509_def.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
202x509_def.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
203x509_def.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
204x509_def.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
205x509_def.o: ../../include/openssl/des_old.h ../../include/openssl/dh.h
206x509_def.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
207x509_def.o: ../../include/openssl/err.h ../../include/openssl/evp.h
208x509_def.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h
209x509_def.o: ../../include/openssl/md2.h ../../include/openssl/md4.h
210x509_def.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
211x509_def.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
212x509_def.o: ../../include/openssl/opensslconf.h
213x509_def.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
214x509_def.o: ../../include/openssl/pkcs7.h ../../include/openssl/rc2.h
215x509_def.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
216x509_def.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
217x509_def.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
218x509_def.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
219x509_def.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
220x509_def.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
221x509_def.o: ../cryptlib.h x509_def.c
222x509_err.o: ../../include/openssl/aes.h ../../include/openssl/asn1.h
223x509_err.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h
224x509_err.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
225x509_err.o: ../../include/openssl/cast.h ../../include/openssl/crypto.h
226x509_err.o: ../../include/openssl/des.h ../../include/openssl/des_old.h
227x509_err.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
228x509_err.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
229x509_err.o: ../../include/openssl/evp.h ../../include/openssl/idea.h
230x509_err.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h
231x509_err.o: ../../include/openssl/md4.h ../../include/openssl/md5.h
232x509_err.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h
233x509_err.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
234x509_err.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
235x509_err.o: ../../include/openssl/pkcs7.h ../../include/openssl/rc2.h
236x509_err.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
237x509_err.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
238x509_err.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
239x509_err.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
240x509_err.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
241x509_err.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
242x509_err.o: x509_err.c
243x509_ext.o: ../../e_os.h ../../include/openssl/aes.h
244x509_ext.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
245x509_ext.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
246x509_ext.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
247x509_ext.o: ../../include/openssl/conf.h ../../include/openssl/crypto.h
248x509_ext.o: ../../include/openssl/des.h ../../include/openssl/des_old.h
249x509_ext.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
250x509_ext.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
251x509_ext.o: ../../include/openssl/evp.h ../../include/openssl/idea.h
252x509_ext.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h
253x509_ext.o: ../../include/openssl/md4.h ../../include/openssl/md5.h
254x509_ext.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h
255x509_ext.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
256x509_ext.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
257x509_ext.o: ../../include/openssl/pkcs7.h ../../include/openssl/rc2.h
258x509_ext.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
259x509_ext.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
260x509_ext.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
261x509_ext.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
262x509_ext.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
263x509_ext.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
264x509_ext.o: ../../include/openssl/x509v3.h ../cryptlib.h x509_ext.c
265x509_lu.o: ../../e_os.h ../../include/openssl/aes.h
266x509_lu.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
267x509_lu.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
268x509_lu.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
269x509_lu.o: ../../include/openssl/conf.h ../../include/openssl/crypto.h
270x509_lu.o: ../../include/openssl/des.h ../../include/openssl/des_old.h
271x509_lu.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
272x509_lu.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
273x509_lu.o: ../../include/openssl/evp.h ../../include/openssl/idea.h
274x509_lu.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h
275x509_lu.o: ../../include/openssl/md4.h ../../include/openssl/md5.h
276x509_lu.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h
277x509_lu.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
278x509_lu.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
279x509_lu.o: ../../include/openssl/pkcs7.h ../../include/openssl/rc2.h
280x509_lu.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
281x509_lu.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
282x509_lu.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
283x509_lu.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
284x509_lu.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
285x509_lu.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
286x509_lu.o: ../../include/openssl/x509v3.h ../cryptlib.h x509_lu.c
287x509_obj.o: ../../e_os.h ../../include/openssl/aes.h
288x509_obj.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
289x509_obj.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
290x509_obj.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
291x509_obj.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
292x509_obj.o: ../../include/openssl/des_old.h ../../include/openssl/dh.h
293x509_obj.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
294x509_obj.o: ../../include/openssl/err.h ../../include/openssl/evp.h
295x509_obj.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h
296x509_obj.o: ../../include/openssl/md2.h ../../include/openssl/md4.h
297x509_obj.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
298x509_obj.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
299x509_obj.o: ../../include/openssl/opensslconf.h
300x509_obj.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
301x509_obj.o: ../../include/openssl/pkcs7.h ../../include/openssl/rc2.h
302x509_obj.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
303x509_obj.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
304x509_obj.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
305x509_obj.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
306x509_obj.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
307x509_obj.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
308x509_obj.o: ../cryptlib.h x509_obj.c
309x509_r2x.o: ../../e_os.h ../../include/openssl/aes.h
310x509_r2x.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
311x509_r2x.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
312x509_r2x.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
313x509_r2x.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
314x509_r2x.o: ../../include/openssl/des_old.h ../../include/openssl/dh.h
315x509_r2x.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
316x509_r2x.o: ../../include/openssl/err.h ../../include/openssl/evp.h
317x509_r2x.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h
318x509_r2x.o: ../../include/openssl/md2.h ../../include/openssl/md4.h
319x509_r2x.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
320x509_r2x.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
321x509_r2x.o: ../../include/openssl/opensslconf.h
322x509_r2x.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
323x509_r2x.o: ../../include/openssl/pkcs7.h ../../include/openssl/rc2.h
324x509_r2x.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
325x509_r2x.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
326x509_r2x.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
327x509_r2x.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
328x509_r2x.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
329x509_r2x.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
330x509_r2x.o: ../cryptlib.h x509_r2x.c
331x509_req.o: ../../e_os.h ../../include/openssl/aes.h
332x509_req.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
333x509_req.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
334x509_req.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
335x509_req.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
336x509_req.o: ../../include/openssl/des_old.h ../../include/openssl/dh.h
337x509_req.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
338x509_req.o: ../../include/openssl/err.h ../../include/openssl/evp.h
339x509_req.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h
340x509_req.o: ../../include/openssl/md2.h ../../include/openssl/md4.h
341x509_req.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
342x509_req.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
343x509_req.o: ../../include/openssl/opensslconf.h
344x509_req.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
345x509_req.o: ../../include/openssl/pem.h ../../include/openssl/pem2.h
346x509_req.o: ../../include/openssl/pkcs7.h ../../include/openssl/rc2.h
347x509_req.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
348x509_req.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
349x509_req.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
350x509_req.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
351x509_req.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
352x509_req.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
353x509_req.o: ../cryptlib.h x509_req.c
354x509_set.o: ../../e_os.h ../../include/openssl/aes.h
355x509_set.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
356x509_set.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
357x509_set.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
358x509_set.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
359x509_set.o: ../../include/openssl/des_old.h ../../include/openssl/dh.h
360x509_set.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
361x509_set.o: ../../include/openssl/err.h ../../include/openssl/evp.h
362x509_set.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h
363x509_set.o: ../../include/openssl/md2.h ../../include/openssl/md4.h
364x509_set.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
365x509_set.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
366x509_set.o: ../../include/openssl/opensslconf.h
367x509_set.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
368x509_set.o: ../../include/openssl/pkcs7.h ../../include/openssl/rc2.h
369x509_set.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
370x509_set.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
371x509_set.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
372x509_set.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
373x509_set.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
374x509_set.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
375x509_set.o: ../cryptlib.h x509_set.c
376x509_trs.o: ../../e_os.h ../../include/openssl/aes.h
377x509_trs.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
378x509_trs.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
379x509_trs.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
380x509_trs.o: ../../include/openssl/conf.h ../../include/openssl/crypto.h
381x509_trs.o: ../../include/openssl/des.h ../../include/openssl/des_old.h
382x509_trs.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
383x509_trs.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
384x509_trs.o: ../../include/openssl/evp.h ../../include/openssl/idea.h
385x509_trs.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h
386x509_trs.o: ../../include/openssl/md4.h ../../include/openssl/md5.h
387x509_trs.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h
388x509_trs.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
389x509_trs.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
390x509_trs.o: ../../include/openssl/pkcs7.h ../../include/openssl/rc2.h
391x509_trs.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
392x509_trs.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
393x509_trs.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
394x509_trs.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
395x509_trs.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
396x509_trs.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
397x509_trs.o: ../../include/openssl/x509v3.h ../cryptlib.h x509_trs.c
398x509_txt.o: ../../e_os.h ../../include/openssl/aes.h
399x509_txt.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
400x509_txt.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
401x509_txt.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
402x509_txt.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
403x509_txt.o: ../../include/openssl/des_old.h ../../include/openssl/dh.h
404x509_txt.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
405x509_txt.o: ../../include/openssl/err.h ../../include/openssl/evp.h
406x509_txt.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h
407x509_txt.o: ../../include/openssl/md2.h ../../include/openssl/md4.h
408x509_txt.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
409x509_txt.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
410x509_txt.o: ../../include/openssl/opensslconf.h
411x509_txt.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
412x509_txt.o: ../../include/openssl/pkcs7.h ../../include/openssl/rc2.h
413x509_txt.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
414x509_txt.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
415x509_txt.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
416x509_txt.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
417x509_txt.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
418x509_txt.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
419x509_txt.o: ../cryptlib.h x509_txt.c
420x509_v3.o: ../../e_os.h ../../include/openssl/aes.h
421x509_v3.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
422x509_v3.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
423x509_v3.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
424x509_v3.o: ../../include/openssl/conf.h ../../include/openssl/crypto.h
425x509_v3.o: ../../include/openssl/des.h ../../include/openssl/des_old.h
426x509_v3.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
427x509_v3.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
428x509_v3.o: ../../include/openssl/evp.h ../../include/openssl/idea.h
429x509_v3.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h
430x509_v3.o: ../../include/openssl/md4.h ../../include/openssl/md5.h
431x509_v3.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h
432x509_v3.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
433x509_v3.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
434x509_v3.o: ../../include/openssl/pkcs7.h ../../include/openssl/rc2.h
435x509_v3.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
436x509_v3.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
437x509_v3.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
438x509_v3.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
439x509_v3.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
440x509_v3.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
441x509_v3.o: ../../include/openssl/x509v3.h ../cryptlib.h x509_v3.c
442x509_vfy.o: ../../e_os.h ../../include/openssl/aes.h
443x509_vfy.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
444x509_vfy.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
445x509_vfy.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
446x509_vfy.o: ../../include/openssl/conf.h ../../include/openssl/crypto.h
447x509_vfy.o: ../../include/openssl/des.h ../../include/openssl/des_old.h
448x509_vfy.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
449x509_vfy.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
450x509_vfy.o: ../../include/openssl/evp.h ../../include/openssl/idea.h
451x509_vfy.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h
452x509_vfy.o: ../../include/openssl/md4.h ../../include/openssl/md5.h
453x509_vfy.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h
454x509_vfy.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
455x509_vfy.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
456x509_vfy.o: ../../include/openssl/pkcs7.h ../../include/openssl/rc2.h
457x509_vfy.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
458x509_vfy.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
459x509_vfy.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
460x509_vfy.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
461x509_vfy.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
462x509_vfy.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
463x509_vfy.o: ../../include/openssl/x509v3.h ../cryptlib.h x509_vfy.c
464x509cset.o: ../../e_os.h ../../include/openssl/aes.h
465x509cset.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
466x509cset.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
467x509cset.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
468x509cset.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
469x509cset.o: ../../include/openssl/des_old.h ../../include/openssl/dh.h
470x509cset.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
471x509cset.o: ../../include/openssl/err.h ../../include/openssl/evp.h
472x509cset.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h
473x509cset.o: ../../include/openssl/md2.h ../../include/openssl/md4.h
474x509cset.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
475x509cset.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
476x509cset.o: ../../include/openssl/opensslconf.h
477x509cset.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
478x509cset.o: ../../include/openssl/pkcs7.h ../../include/openssl/rc2.h
479x509cset.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
480x509cset.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
481x509cset.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
482x509cset.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
483x509cset.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
484x509cset.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
485x509cset.o: ../cryptlib.h x509cset.c
486x509name.o: ../../e_os.h ../../include/openssl/aes.h
487x509name.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
488x509name.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
489x509name.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
490x509name.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
491x509name.o: ../../include/openssl/des_old.h ../../include/openssl/dh.h
492x509name.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
493x509name.o: ../../include/openssl/err.h ../../include/openssl/evp.h
494x509name.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h
495x509name.o: ../../include/openssl/md2.h ../../include/openssl/md4.h
496x509name.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
497x509name.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
498x509name.o: ../../include/openssl/opensslconf.h
499x509name.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
500x509name.o: ../../include/openssl/pkcs7.h ../../include/openssl/rc2.h
501x509name.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
502x509name.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
503x509name.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
504x509name.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
505x509name.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
506x509name.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
507x509name.o: ../cryptlib.h x509name.c
508x509rset.o: ../../e_os.h ../../include/openssl/aes.h
509x509rset.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
510x509rset.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
511x509rset.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
512x509rset.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
513x509rset.o: ../../include/openssl/des_old.h ../../include/openssl/dh.h
514x509rset.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
515x509rset.o: ../../include/openssl/err.h ../../include/openssl/evp.h
516x509rset.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h
517x509rset.o: ../../include/openssl/md2.h ../../include/openssl/md4.h
518x509rset.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
519x509rset.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
520x509rset.o: ../../include/openssl/opensslconf.h
521x509rset.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
522x509rset.o: ../../include/openssl/pkcs7.h ../../include/openssl/rc2.h
523x509rset.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
524x509rset.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
525x509rset.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
526x509rset.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
527x509rset.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
528x509rset.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
529x509rset.o: ../cryptlib.h x509rset.c
530x509spki.o: ../../e_os.h ../../include/openssl/aes.h
531x509spki.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
532x509spki.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
533x509spki.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
534x509spki.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
535x509spki.o: ../../include/openssl/des_old.h ../../include/openssl/dh.h
536x509spki.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
537x509spki.o: ../../include/openssl/err.h ../../include/openssl/evp.h
538x509spki.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h
539x509spki.o: ../../include/openssl/md2.h ../../include/openssl/md4.h
540x509spki.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
541x509spki.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
542x509spki.o: ../../include/openssl/opensslconf.h
543x509spki.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
544x509spki.o: ../../include/openssl/pkcs7.h ../../include/openssl/rc2.h
545x509spki.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
546x509spki.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
547x509spki.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
548x509spki.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
549x509spki.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
550x509spki.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
551x509spki.o: ../cryptlib.h x509spki.c
552x509type.o: ../../e_os.h ../../include/openssl/aes.h
553x509type.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
554x509type.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
555x509type.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
556x509type.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
557x509type.o: ../../include/openssl/des_old.h ../../include/openssl/dh.h
558x509type.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
559x509type.o: ../../include/openssl/err.h ../../include/openssl/evp.h
560x509type.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h
561x509type.o: ../../include/openssl/md2.h ../../include/openssl/md4.h
562x509type.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
563x509type.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
564x509type.o: ../../include/openssl/opensslconf.h
565x509type.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
566x509type.o: ../../include/openssl/pkcs7.h ../../include/openssl/rc2.h
567x509type.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
568x509type.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
569x509type.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
570x509type.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
571x509type.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
572x509type.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
573x509type.o: ../cryptlib.h x509type.c
574x_all.o: ../../e_os.h ../../include/openssl/aes.h ../../include/openssl/asn1.h
575x_all.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h
576x_all.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
577x_all.o: ../../include/openssl/cast.h ../../include/openssl/crypto.h
578x_all.o: ../../include/openssl/des.h ../../include/openssl/des_old.h
579x_all.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
580x_all.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
581x_all.o: ../../include/openssl/evp.h ../../include/openssl/idea.h
582x_all.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h
583x_all.o: ../../include/openssl/md4.h ../../include/openssl/md5.h
584x_all.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h
585x_all.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
586x_all.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
587x_all.o: ../../include/openssl/pkcs7.h ../../include/openssl/rc2.h
588x_all.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
589x_all.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
590x_all.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
591x_all.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
592x_all.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
593x_all.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
594x_all.o: ../cryptlib.h x_all.c
diff --git a/src/lib/libcrypto/x509/by_dir.c b/src/lib/libcrypto/x509/by_dir.c
index 341e0ba6a4..27ca5150c1 100644
--- a/src/lib/libcrypto/x509/by_dir.c
+++ b/src/lib/libcrypto/x509/by_dir.c
@@ -65,28 +65,36 @@
65#ifndef NO_SYS_TYPES_H 65#ifndef NO_SYS_TYPES_H
66# include <sys/types.h> 66# include <sys/types.h>
67#endif 67#endif
68#ifdef MAC_OS_pre_X 68#ifndef OPENSSL_NO_POSIX_IO
69# include <stat.h>
70#else
71# include <sys/stat.h> 69# include <sys/stat.h>
72#endif 70#endif
73 71
74#include <openssl/lhash.h> 72#include <openssl/lhash.h>
75#include <openssl/x509.h> 73#include <openssl/x509.h>
76 74
77#ifdef _WIN32 75
78#define stat _stat 76typedef struct lookup_dir_hashes_st
79#endif 77 {
78 unsigned long hash;
79 int suffix;
80 } BY_DIR_HASH;
81
82typedef struct lookup_dir_entry_st
83 {
84 char *dir;
85 int dir_type;
86 STACK_OF(BY_DIR_HASH) *hashes;
87 } BY_DIR_ENTRY;
80 88
81typedef struct lookup_dir_st 89typedef struct lookup_dir_st
82 { 90 {
83 BUF_MEM *buffer; 91 BUF_MEM *buffer;
84 int num_dirs; 92 STACK_OF(BY_DIR_ENTRY) *dirs;
85 char **dirs;
86 int *dirs_type;
87 int num_dirs_alloced;
88 } BY_DIR; 93 } BY_DIR;
89 94
95DECLARE_STACK_OF(BY_DIR_HASH)
96DECLARE_STACK_OF(BY_DIR_ENTRY)
97
90static int dir_ctrl(X509_LOOKUP *ctx, int cmd, const char *argp, long argl, 98static int dir_ctrl(X509_LOOKUP *ctx, int cmd, const char *argp, long argl,
91 char **ret); 99 char **ret);
92static int new_dir(X509_LOOKUP *lu); 100static int new_dir(X509_LOOKUP *lu);
@@ -127,7 +135,7 @@ static int dir_ctrl(X509_LOOKUP *ctx, int cmd, const char *argp, long argl,
127 case X509_L_ADD_DIR: 135 case X509_L_ADD_DIR:
128 if (argl == X509_FILETYPE_DEFAULT) 136 if (argl == X509_FILETYPE_DEFAULT)
129 { 137 {
130 dir=(char *)Getenv(X509_get_default_cert_dir_env()); 138 dir=(char *)getenv(X509_get_default_cert_dir_env());
131 if (dir) 139 if (dir)
132 ret=add_cert_dir(ld,dir,X509_FILETYPE_PEM); 140 ret=add_cert_dir(ld,dir,X509_FILETYPE_PEM);
133 else 141 else
@@ -156,34 +164,51 @@ static int new_dir(X509_LOOKUP *lu)
156 OPENSSL_free(a); 164 OPENSSL_free(a);
157 return(0); 165 return(0);
158 } 166 }
159 a->num_dirs=0;
160 a->dirs=NULL; 167 a->dirs=NULL;
161 a->dirs_type=NULL;
162 a->num_dirs_alloced=0;
163 lu->method_data=(char *)a; 168 lu->method_data=(char *)a;
164 return(1); 169 return(1);
165 } 170 }
166 171
172static void by_dir_hash_free(BY_DIR_HASH *hash)
173 {
174 OPENSSL_free(hash);
175 }
176
177static int by_dir_hash_cmp(const BY_DIR_HASH * const *a,
178 const BY_DIR_HASH * const *b)
179 {
180 if ((*a)->hash > (*b)->hash)
181 return 1;
182 if ((*a)->hash < (*b)->hash)
183 return -1;
184 return 0;
185 }
186
187static void by_dir_entry_free(BY_DIR_ENTRY *ent)
188 {
189 if (ent->dir)
190 OPENSSL_free(ent->dir);
191 if (ent->hashes)
192 sk_BY_DIR_HASH_pop_free(ent->hashes, by_dir_hash_free);
193 OPENSSL_free(ent);
194 }
195
167static void free_dir(X509_LOOKUP *lu) 196static void free_dir(X509_LOOKUP *lu)
168 { 197 {
169 BY_DIR *a; 198 BY_DIR *a;
170 int i;
171 199
172 a=(BY_DIR *)lu->method_data; 200 a=(BY_DIR *)lu->method_data;
173 for (i=0; i<a->num_dirs; i++) 201 if (a->dirs != NULL)
174 if (a->dirs[i] != NULL) OPENSSL_free(a->dirs[i]); 202 sk_BY_DIR_ENTRY_pop_free(a->dirs, by_dir_entry_free);
175 if (a->dirs != NULL) OPENSSL_free(a->dirs); 203 if (a->buffer != NULL)
176 if (a->dirs_type != NULL) OPENSSL_free(a->dirs_type); 204 BUF_MEM_free(a->buffer);
177 if (a->buffer != NULL) BUF_MEM_free(a->buffer);
178 OPENSSL_free(a); 205 OPENSSL_free(a);
179 } 206 }
180 207
181static int add_cert_dir(BY_DIR *ctx, const char *dir, int type) 208static int add_cert_dir(BY_DIR *ctx, const char *dir, int type)
182 { 209 {
183 int j,len; 210 int j,len;
184 int *ip;
185 const char *s,*ss,*p; 211 const char *s,*ss,*p;
186 char **pp;
187 212
188 if (dir == NULL || !*dir) 213 if (dir == NULL || !*dir)
189 { 214 {
@@ -197,49 +222,52 @@ static int add_cert_dir(BY_DIR *ctx, const char *dir, int type)
197 { 222 {
198 if ((*p == LIST_SEPARATOR_CHAR) || (*p == '\0')) 223 if ((*p == LIST_SEPARATOR_CHAR) || (*p == '\0'))
199 { 224 {
225 BY_DIR_ENTRY *ent;
200 ss=s; 226 ss=s;
201 s=p+1; 227 s=p+1;
202 len=(int)(p-ss); 228 len=(int)(p-ss);
203 if (len == 0) continue; 229 if (len == 0) continue;
204 for (j=0; j<ctx->num_dirs; j++) 230 for (j=0; j < sk_BY_DIR_ENTRY_num(ctx->dirs); j++)
205 if (strlen(ctx->dirs[j]) == (size_t)len && 231 {
206 strncmp(ctx->dirs[j],ss,(unsigned int)len) == 0) 232 ent = sk_BY_DIR_ENTRY_value(ctx->dirs, j);
233 if (strlen(ent->dir) == (size_t)len &&
234 strncmp(ent->dir,ss,(unsigned int)len) == 0)
207 break; 235 break;
208 if (j<ctx->num_dirs) 236 }
237 if (j < sk_BY_DIR_ENTRY_num(ctx->dirs))
209 continue; 238 continue;
210 if (ctx->num_dirs_alloced < (ctx->num_dirs+1)) 239 if (ctx->dirs == NULL)
211 { 240 {
212 ctx->num_dirs_alloced+=10; 241 ctx->dirs = sk_BY_DIR_ENTRY_new_null();
213 pp=(char **)OPENSSL_malloc(ctx->num_dirs_alloced* 242 if (!ctx->dirs)
214 sizeof(char *));
215 ip=(int *)OPENSSL_malloc(ctx->num_dirs_alloced*
216 sizeof(int));
217 if ((pp == NULL) || (ip == NULL))
218 { 243 {
219 X509err(X509_F_ADD_CERT_DIR,ERR_R_MALLOC_FAILURE); 244 X509err(X509_F_ADD_CERT_DIR,ERR_R_MALLOC_FAILURE);
220 return(0); 245 return 0;
221 } 246 }
222 memcpy(pp,ctx->dirs,(ctx->num_dirs_alloced-10)*
223 sizeof(char *));
224 memcpy(ip,ctx->dirs_type,(ctx->num_dirs_alloced-10)*
225 sizeof(int));
226 if (ctx->dirs != NULL)
227 OPENSSL_free(ctx->dirs);
228 if (ctx->dirs_type != NULL)
229 OPENSSL_free(ctx->dirs_type);
230 ctx->dirs=pp;
231 ctx->dirs_type=ip;
232 } 247 }
233 ctx->dirs_type[ctx->num_dirs]=type; 248 ent = OPENSSL_malloc(sizeof(BY_DIR_ENTRY));
234 ctx->dirs[ctx->num_dirs]=(char *)OPENSSL_malloc((unsigned int)len+1); 249 if (!ent)
235 if (ctx->dirs[ctx->num_dirs] == NULL) return(0); 250 return 0;
236 strncpy(ctx->dirs[ctx->num_dirs],ss,(unsigned int)len); 251 ent->dir_type = type;
237 ctx->dirs[ctx->num_dirs][len]='\0'; 252 ent->hashes = sk_BY_DIR_HASH_new(by_dir_hash_cmp);
238 ctx->num_dirs++; 253 ent->dir = OPENSSL_malloc((unsigned int)len+1);
254 if (!ent->dir || !ent->hashes)
255 {
256 by_dir_entry_free(ent);
257 return 0;
258 }
259 strncpy(ent->dir,ss,(unsigned int)len);
260 ent->dir[len] = '\0';
261 if (!sk_BY_DIR_ENTRY_push(ctx->dirs, ent))
262 {
263 by_dir_entry_free(ent);
264 return 0;
265 }
239 } 266 }
240 if (*p == '\0') break; 267 if (*p == '\0')
268 break;
241 } 269 }
242 return(1); 270 return 1;
243 } 271 }
244 272
245static int get_cert_by_subject(X509_LOOKUP *xl, int type, X509_NAME *name, 273static int get_cert_by_subject(X509_LOOKUP *xl, int type, X509_NAME *name,
@@ -260,7 +288,6 @@ static int get_cert_by_subject(X509_LOOKUP *xl, int type, X509_NAME *name,
260 int i,j,k; 288 int i,j,k;
261 unsigned long h; 289 unsigned long h;
262 BUF_MEM *b=NULL; 290 BUF_MEM *b=NULL;
263 struct stat st;
264 X509_OBJECT stmp,*tmp; 291 X509_OBJECT stmp,*tmp;
265 const char *postfix=""; 292 const char *postfix="";
266 293
@@ -296,20 +323,45 @@ static int get_cert_by_subject(X509_LOOKUP *xl, int type, X509_NAME *name,
296 ctx=(BY_DIR *)xl->method_data; 323 ctx=(BY_DIR *)xl->method_data;
297 324
298 h=X509_NAME_hash(name); 325 h=X509_NAME_hash(name);
299 for (i=0; i<ctx->num_dirs; i++) 326 for (i=0; i < sk_BY_DIR_ENTRY_num(ctx->dirs); i++)
300 { 327 {
301 j=strlen(ctx->dirs[i])+1+8+6+1+1; 328 BY_DIR_ENTRY *ent;
329 int idx;
330 BY_DIR_HASH htmp, *hent;
331 ent = sk_BY_DIR_ENTRY_value(ctx->dirs, i);
332 j=strlen(ent->dir)+1+8+6+1+1;
302 if (!BUF_MEM_grow(b,j)) 333 if (!BUF_MEM_grow(b,j))
303 { 334 {
304 X509err(X509_F_GET_CERT_BY_SUBJECT,ERR_R_MALLOC_FAILURE); 335 X509err(X509_F_GET_CERT_BY_SUBJECT,ERR_R_MALLOC_FAILURE);
305 goto finish; 336 goto finish;
306 } 337 }
307 k=0; 338 if (type == X509_LU_CRL && ent->hashes)
339 {
340 htmp.hash = h;
341 CRYPTO_r_lock(CRYPTO_LOCK_X509_STORE);
342 idx = sk_BY_DIR_HASH_find(ent->hashes, &htmp);
343 if (idx >= 0)
344 {
345 hent = sk_BY_DIR_HASH_value(ent->hashes, idx);
346 k = hent->suffix;
347 }
348 else
349 {
350 hent = NULL;
351 k=0;
352 }
353 CRYPTO_r_unlock(CRYPTO_LOCK_X509_STORE);
354 }
355 else
356 {
357 k = 0;
358 hent = NULL;
359 }
308 for (;;) 360 for (;;)
309 { 361 {
310 char c = '/'; 362 char c = '/';
311#ifdef OPENSSL_SYS_VMS 363#ifdef OPENSSL_SYS_VMS
312 c = ctx->dirs[i][strlen(ctx->dirs[i])-1]; 364 c = ent->dir[strlen(ent->dir)-1];
313 if (c != ':' && c != '>' && c != ']') 365 if (c != ':' && c != '>' && c != ']')
314 { 366 {
315 /* If no separator is present, we assume the 367 /* If no separator is present, we assume the
@@ -330,41 +382,86 @@ static int get_cert_by_subject(X509_LOOKUP *xl, int type, X509_NAME *name,
330 /* This is special. When c == '\0', no 382 /* This is special. When c == '\0', no
331 directory separator should be added. */ 383 directory separator should be added. */
332 BIO_snprintf(b->data,b->max, 384 BIO_snprintf(b->data,b->max,
333 "%s%08lx.%s%d",ctx->dirs[i],h, 385 "%s%08lx.%s%d",ent->dir,h,
334 postfix,k); 386 postfix,k);
335 } 387 }
336 else 388 else
337 { 389 {
338 BIO_snprintf(b->data,b->max, 390 BIO_snprintf(b->data,b->max,
339 "%s%c%08lx.%s%d",ctx->dirs[i],c,h, 391 "%s%c%08lx.%s%d",ent->dir,c,h,
340 postfix,k); 392 postfix,k);
341 } 393 }
342 k++; 394#ifndef OPENSSL_NO_POSIX_IO
395#ifdef _WIN32
396#define stat _stat
397#endif
398 {
399 struct stat st;
343 if (stat(b->data,&st) < 0) 400 if (stat(b->data,&st) < 0)
344 break; 401 break;
402 }
403#endif
345 /* found one. */ 404 /* found one. */
346 if (type == X509_LU_X509) 405 if (type == X509_LU_X509)
347 { 406 {
348 if ((X509_load_cert_file(xl,b->data, 407 if ((X509_load_cert_file(xl,b->data,
349 ctx->dirs_type[i])) == 0) 408 ent->dir_type)) == 0)
350 break; 409 break;
351 } 410 }
352 else if (type == X509_LU_CRL) 411 else if (type == X509_LU_CRL)
353 { 412 {
354 if ((X509_load_crl_file(xl,b->data, 413 if ((X509_load_crl_file(xl,b->data,
355 ctx->dirs_type[i])) == 0) 414 ent->dir_type)) == 0)
356 break; 415 break;
357 } 416 }
358 /* else case will caught higher up */ 417 /* else case will caught higher up */
418 k++;
359 } 419 }
360 420
361 /* we have added it to the cache so now pull 421 /* we have added it to the cache so now pull
362 * it out again */ 422 * it out again */
363 CRYPTO_r_lock(CRYPTO_LOCK_X509_STORE); 423 CRYPTO_w_lock(CRYPTO_LOCK_X509_STORE);
364 j = sk_X509_OBJECT_find(xl->store_ctx->objs,&stmp); 424 j = sk_X509_OBJECT_find(xl->store_ctx->objs,&stmp);
365 if(j != -1) tmp=sk_X509_OBJECT_value(xl->store_ctx->objs,j); 425 if(j != -1) tmp=sk_X509_OBJECT_value(xl->store_ctx->objs,j);
366 else tmp = NULL; 426 else tmp = NULL;
367 CRYPTO_r_unlock(CRYPTO_LOCK_X509_STORE); 427 CRYPTO_w_unlock(CRYPTO_LOCK_X509_STORE);
428
429
430 /* If a CRL, update the last file suffix added for this */
431
432 if (type == X509_LU_CRL)
433 {
434 CRYPTO_w_lock(CRYPTO_LOCK_X509_STORE);
435 /* Look for entry again in case another thread added
436 * an entry first.
437 */
438 if (!hent)
439 {
440 htmp.hash = h;
441 idx = sk_BY_DIR_HASH_find(ent->hashes, &htmp);
442 if (idx >= 0)
443 hent =
444 sk_BY_DIR_HASH_value(ent->hashes, idx);
445 }
446 if (!hent)
447 {
448 hent = OPENSSL_malloc(sizeof(BY_DIR_HASH));
449 hent->hash = h;
450 hent->suffix = k;
451 if (!sk_BY_DIR_HASH_push(ent->hashes, hent))
452 {
453 CRYPTO_w_unlock(CRYPTO_LOCK_X509_STORE);
454 OPENSSL_free(hent);
455 ok = 0;
456 goto finish;
457 }
458 }
459 else if (hent->suffix < k)
460 hent->suffix = k;
461
462 CRYPTO_w_unlock(CRYPTO_LOCK_X509_STORE);
463
464 }
368 465
369 if (tmp != NULL) 466 if (tmp != NULL)
370 { 467 {
@@ -383,4 +480,3 @@ finish:
383 if (b != NULL) BUF_MEM_free(b); 480 if (b != NULL) BUF_MEM_free(b);
384 return(ok); 481 return(ok);
385 } 482 }
386
diff --git a/src/lib/libcrypto/x509/by_file.c b/src/lib/libcrypto/x509/by_file.c
index a5e0d4aefa..57b08ee094 100644
--- a/src/lib/libcrypto/x509/by_file.c
+++ b/src/lib/libcrypto/x509/by_file.c
@@ -100,7 +100,7 @@ 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 file = (char *)Getenv(X509_get_default_cert_file_env()); 103 file = (char *)getenv(X509_get_default_cert_file_env());
104 if (file) 104 if (file)
105 ok = (X509_load_cert_crl_file(ctx,file, 105 ok = (X509_load_cert_crl_file(ctx,file,
106 X509_FILETYPE_PEM) != 0); 106 X509_FILETYPE_PEM) != 0);
diff --git a/src/lib/libcrypto/x509/x509.h b/src/lib/libcrypto/x509/x509.h
index e71b5257e5..604f4fb27f 100644
--- a/src/lib/libcrypto/x509/x509.h
+++ b/src/lib/libcrypto/x509/x509.h
@@ -116,6 +116,7 @@ extern "C" {
116/* Under Win32 these are defined in wincrypt.h */ 116/* Under Win32 these are defined in wincrypt.h */
117#undef X509_NAME 117#undef X509_NAME
118#undef X509_CERT_PAIR 118#undef X509_CERT_PAIR
119#undef X509_EXTENSIONS
119#endif 120#endif
120 121
121#define X509_FILETYPE_PEM 1 122#define X509_FILETYPE_PEM 1
@@ -156,12 +157,12 @@ typedef struct X509_val_st
156 ASN1_TIME *notAfter; 157 ASN1_TIME *notAfter;
157 } X509_VAL; 158 } X509_VAL;
158 159
159typedef struct X509_pubkey_st 160struct X509_pubkey_st
160 { 161 {
161 X509_ALGOR *algor; 162 X509_ALGOR *algor;
162 ASN1_BIT_STRING *public_key; 163 ASN1_BIT_STRING *public_key;
163 EVP_PKEY *pkey; 164 EVP_PKEY *pkey;
164 } X509_PUBKEY; 165 };
165 166
166typedef struct X509_sig_st 167typedef struct X509_sig_st
167 { 168 {
@@ -190,7 +191,9 @@ struct X509_name_st
190#else 191#else
191 char *bytes; 192 char *bytes;
192#endif 193#endif
193 unsigned long hash; /* Keep the hash around for lookups */ 194/* unsigned long hash; Keep the hash around for lookups */
195 unsigned char *canon_enc;
196 int canon_enclen;
194 } /* X509_NAME */; 197 } /* X509_NAME */;
195 198
196DECLARE_STACK_OF(X509_NAME) 199DECLARE_STACK_OF(X509_NAME)
@@ -289,8 +292,11 @@ struct x509_st
289 unsigned long ex_xkusage; 292 unsigned long ex_xkusage;
290 unsigned long ex_nscert; 293 unsigned long ex_nscert;
291 ASN1_OCTET_STRING *skid; 294 ASN1_OCTET_STRING *skid;
292 struct AUTHORITY_KEYID_st *akid; 295 AUTHORITY_KEYID *akid;
293 X509_POLICY_CACHE *policy_cache; 296 X509_POLICY_CACHE *policy_cache;
297 STACK_OF(DIST_POINT) *crldp;
298 STACK_OF(GENERAL_NAME) *altname;
299 NAME_CONSTRAINTS *nc;
294#ifndef OPENSSL_NO_RFC3779 300#ifndef OPENSSL_NO_RFC3779
295 STACK_OF(IPAddressFamily) *rfc3779_addr; 301 STACK_OF(IPAddressFamily) *rfc3779_addr;
296 struct ASIdentifiers_st *rfc3779_asid; 302 struct ASIdentifiers_st *rfc3779_asid;
@@ -333,10 +339,11 @@ typedef struct x509_cert_pair_st {
333#define X509_TRUST_OBJECT_SIGN 5 339#define X509_TRUST_OBJECT_SIGN 5
334#define X509_TRUST_OCSP_SIGN 6 340#define X509_TRUST_OCSP_SIGN 6
335#define X509_TRUST_OCSP_REQUEST 7 341#define X509_TRUST_OCSP_REQUEST 7
342#define X509_TRUST_TSA 8
336 343
337/* Keep these up to date! */ 344/* Keep these up to date! */
338#define X509_TRUST_MIN 1 345#define X509_TRUST_MIN 1
339#define X509_TRUST_MAX 7 346#define X509_TRUST_MAX 8
340 347
341 348
342/* trust_flags values */ 349/* trust_flags values */
@@ -423,13 +430,17 @@ typedef struct x509_cert_pair_st {
423 XN_FLAG_FN_LN | \ 430 XN_FLAG_FN_LN | \
424 XN_FLAG_FN_ALIGN) 431 XN_FLAG_FN_ALIGN)
425 432
426typedef struct X509_revoked_st 433struct x509_revoked_st
427 { 434 {
428 ASN1_INTEGER *serialNumber; 435 ASN1_INTEGER *serialNumber;
429 ASN1_TIME *revocationDate; 436 ASN1_TIME *revocationDate;
430 STACK_OF(X509_EXTENSION) /* optional */ *extensions; 437 STACK_OF(X509_EXTENSION) /* optional */ *extensions;
438 /* Set up if indirect CRL */
439 STACK_OF(GENERAL_NAME) *issuer;
440 /* Revocation reason */
441 int reason;
431 int sequence; /* load sequence */ 442 int sequence; /* load sequence */
432 } X509_REVOKED; 443 };
433 444
434DECLARE_STACK_OF(X509_REVOKED) 445DECLARE_STACK_OF(X509_REVOKED)
435DECLARE_ASN1_SET_OF(X509_REVOKED) 446DECLARE_ASN1_SET_OF(X509_REVOKED)
@@ -453,6 +464,22 @@ struct X509_crl_st
453 X509_ALGOR *sig_alg; 464 X509_ALGOR *sig_alg;
454 ASN1_BIT_STRING *signature; 465 ASN1_BIT_STRING *signature;
455 int references; 466 int references;
467 int flags;
468 /* Copies of various extensions */
469 AUTHORITY_KEYID *akid;
470 ISSUING_DIST_POINT *idp;
471 /* Convenient breakdown of IDP */
472 int idp_flags;
473 int idp_reasons;
474 /* CRL and base CRL numbers for delta processing */
475 ASN1_INTEGER *crl_number;
476 ASN1_INTEGER *base_crl_number;
477#ifndef OPENSSL_NO_SHA
478 unsigned char sha1_hash[SHA_DIGEST_LENGTH];
479#endif
480 STACK_OF(GENERAL_NAMES) *issuers;
481 const X509_CRL_METHOD *meth;
482 void *meth_data;
456 } /* X509_CRL */; 483 } /* X509_CRL */;
457 484
458DECLARE_STACK_OF(X509_CRL) 485DECLARE_STACK_OF(X509_CRL)
@@ -551,18 +578,19 @@ X509_ALGOR *prf;
551 578
552/* PKCS#8 private key info structure */ 579/* PKCS#8 private key info structure */
553 580
554typedef struct pkcs8_priv_key_info_st 581struct pkcs8_priv_key_info_st
555 { 582 {
556 int broken; /* Flag for various broken formats */ 583 int broken; /* Flag for various broken formats */
557#define PKCS8_OK 0 584#define PKCS8_OK 0
558#define PKCS8_NO_OCTET 1 585#define PKCS8_NO_OCTET 1
559#define PKCS8_EMBEDDED_PARAM 2 586#define PKCS8_EMBEDDED_PARAM 2
560#define PKCS8_NS_DB 3 587#define PKCS8_NS_DB 3
588#define PKCS8_NEG_PRIVKEY 4
561 ASN1_INTEGER *version; 589 ASN1_INTEGER *version;
562 X509_ALGOR *pkeyalg; 590 X509_ALGOR *pkeyalg;
563 ASN1_TYPE *pkey; /* Should be OCTET STRING but some are broken */ 591 ASN1_TYPE *pkey; /* Should be OCTET STRING but some are broken */
564 STACK_OF(X509_ATTRIBUTE) *attributes; 592 STACK_OF(X509_ATTRIBUTE) *attributes;
565 } PKCS8_PRIV_KEY_INFO; 593 };
566 594
567#ifdef __cplusplus 595#ifdef __cplusplus
568} 596}
@@ -575,151 +603,6 @@ typedef struct pkcs8_priv_key_info_st
575extern "C" { 603extern "C" {
576#endif 604#endif
577 605
578#ifdef SSLEAY_MACROS
579#define X509_verify(a,r) ASN1_verify((int (*)())i2d_X509_CINF,a->sig_alg,\
580 a->signature,(char *)a->cert_info,r)
581#define X509_REQ_verify(a,r) ASN1_verify((int (*)())i2d_X509_REQ_INFO, \
582 a->sig_alg,a->signature,(char *)a->req_info,r)
583#define X509_CRL_verify(a,r) ASN1_verify((int (*)())i2d_X509_CRL_INFO, \
584 a->sig_alg, a->signature,(char *)a->crl,r)
585
586#define X509_sign(x,pkey,md) \
587 ASN1_sign((int (*)())i2d_X509_CINF, x->cert_info->signature, \
588 x->sig_alg, x->signature, (char *)x->cert_info,pkey,md)
589#define X509_REQ_sign(x,pkey,md) \
590 ASN1_sign((int (*)())i2d_X509_REQ_INFO,x->sig_alg, NULL, \
591 x->signature, (char *)x->req_info,pkey,md)
592#define X509_CRL_sign(x,pkey,md) \
593 ASN1_sign((int (*)())i2d_X509_CRL_INFO,x->crl->sig_alg,x->sig_alg, \
594 x->signature, (char *)x->crl,pkey,md)
595#define NETSCAPE_SPKI_sign(x,pkey,md) \
596 ASN1_sign((int (*)())i2d_NETSCAPE_SPKAC, x->sig_algor,NULL, \
597 x->signature, (char *)x->spkac,pkey,md)
598
599#define X509_dup(x509) (X509 *)ASN1_dup((int (*)())i2d_X509, \
600 (char *(*)())d2i_X509,(char *)x509)
601#define X509_ATTRIBUTE_dup(xa) (X509_ATTRIBUTE *)ASN1_dup(\
602 (int (*)())i2d_X509_ATTRIBUTE, \
603 (char *(*)())d2i_X509_ATTRIBUTE,(char *)xa)
604#define X509_EXTENSION_dup(ex) (X509_EXTENSION *)ASN1_dup( \
605 (int (*)())i2d_X509_EXTENSION, \
606 (char *(*)())d2i_X509_EXTENSION,(char *)ex)
607#define d2i_X509_fp(fp,x509) (X509 *)ASN1_d2i_fp((char *(*)())X509_new, \
608 (char *(*)())d2i_X509, (fp),(unsigned char **)(x509))
609#define i2d_X509_fp(fp,x509) ASN1_i2d_fp(i2d_X509,fp,(unsigned char *)x509)
610#define d2i_X509_bio(bp,x509) (X509 *)ASN1_d2i_bio((char *(*)())X509_new, \
611 (char *(*)())d2i_X509, (bp),(unsigned char **)(x509))
612#define i2d_X509_bio(bp,x509) ASN1_i2d_bio(i2d_X509,bp,(unsigned char *)x509)
613
614#define X509_CRL_dup(crl) (X509_CRL *)ASN1_dup((int (*)())i2d_X509_CRL, \
615 (char *(*)())d2i_X509_CRL,(char *)crl)
616#define d2i_X509_CRL_fp(fp,crl) (X509_CRL *)ASN1_d2i_fp((char *(*)()) \
617 X509_CRL_new,(char *(*)())d2i_X509_CRL, (fp),\
618 (unsigned char **)(crl))
619#define i2d_X509_CRL_fp(fp,crl) ASN1_i2d_fp(i2d_X509_CRL,fp,\
620 (unsigned char *)crl)
621#define d2i_X509_CRL_bio(bp,crl) (X509_CRL *)ASN1_d2i_bio((char *(*)()) \
622 X509_CRL_new,(char *(*)())d2i_X509_CRL, (bp),\
623 (unsigned char **)(crl))
624#define i2d_X509_CRL_bio(bp,crl) ASN1_i2d_bio(i2d_X509_CRL,bp,\
625 (unsigned char *)crl)
626
627#define PKCS7_dup(p7) (PKCS7 *)ASN1_dup((int (*)())i2d_PKCS7, \
628 (char *(*)())d2i_PKCS7,(char *)p7)
629#define d2i_PKCS7_fp(fp,p7) (PKCS7 *)ASN1_d2i_fp((char *(*)()) \
630 PKCS7_new,(char *(*)())d2i_PKCS7, (fp),\
631 (unsigned char **)(p7))
632#define i2d_PKCS7_fp(fp,p7) ASN1_i2d_fp(i2d_PKCS7,fp,\
633 (unsigned char *)p7)
634#define d2i_PKCS7_bio(bp,p7) (PKCS7 *)ASN1_d2i_bio((char *(*)()) \
635 PKCS7_new,(char *(*)())d2i_PKCS7, (bp),\
636 (unsigned char **)(p7))
637#define i2d_PKCS7_bio(bp,p7) ASN1_i2d_bio(i2d_PKCS7,bp,\
638 (unsigned char *)p7)
639
640#define X509_REQ_dup(req) (X509_REQ *)ASN1_dup((int (*)())i2d_X509_REQ, \
641 (char *(*)())d2i_X509_REQ,(char *)req)
642#define d2i_X509_REQ_fp(fp,req) (X509_REQ *)ASN1_d2i_fp((char *(*)())\
643 X509_REQ_new, (char *(*)())d2i_X509_REQ, (fp),\
644 (unsigned char **)(req))
645#define i2d_X509_REQ_fp(fp,req) ASN1_i2d_fp(i2d_X509_REQ,fp,\
646 (unsigned char *)req)
647#define d2i_X509_REQ_bio(bp,req) (X509_REQ *)ASN1_d2i_bio((char *(*)())\
648 X509_REQ_new, (char *(*)())d2i_X509_REQ, (bp),\
649 (unsigned char **)(req))
650#define i2d_X509_REQ_bio(bp,req) ASN1_i2d_bio(i2d_X509_REQ,bp,\
651 (unsigned char *)req)
652
653#define RSAPublicKey_dup(rsa) (RSA *)ASN1_dup((int (*)())i2d_RSAPublicKey, \
654 (char *(*)())d2i_RSAPublicKey,(char *)rsa)
655#define RSAPrivateKey_dup(rsa) (RSA *)ASN1_dup((int (*)())i2d_RSAPrivateKey, \
656 (char *(*)())d2i_RSAPrivateKey,(char *)rsa)
657
658#define d2i_RSAPrivateKey_fp(fp,rsa) (RSA *)ASN1_d2i_fp((char *(*)())\
659 RSA_new,(char *(*)())d2i_RSAPrivateKey, (fp), \
660 (unsigned char **)(rsa))
661#define i2d_RSAPrivateKey_fp(fp,rsa) ASN1_i2d_fp(i2d_RSAPrivateKey,fp, \
662 (unsigned char *)rsa)
663#define d2i_RSAPrivateKey_bio(bp,rsa) (RSA *)ASN1_d2i_bio((char *(*)())\
664 RSA_new,(char *(*)())d2i_RSAPrivateKey, (bp), \
665 (unsigned char **)(rsa))
666#define i2d_RSAPrivateKey_bio(bp,rsa) ASN1_i2d_bio(i2d_RSAPrivateKey,bp, \
667 (unsigned char *)rsa)
668
669#define d2i_RSAPublicKey_fp(fp,rsa) (RSA *)ASN1_d2i_fp((char *(*)())\
670 RSA_new,(char *(*)())d2i_RSAPublicKey, (fp), \
671 (unsigned char **)(rsa))
672#define i2d_RSAPublicKey_fp(fp,rsa) ASN1_i2d_fp(i2d_RSAPublicKey,fp, \
673 (unsigned char *)rsa)
674#define d2i_RSAPublicKey_bio(bp,rsa) (RSA *)ASN1_d2i_bio((char *(*)())\
675 RSA_new,(char *(*)())d2i_RSAPublicKey, (bp), \
676 (unsigned char **)(rsa))
677#define i2d_RSAPublicKey_bio(bp,rsa) ASN1_i2d_bio(i2d_RSAPublicKey,bp, \
678 (unsigned char *)rsa)
679
680#define d2i_DSAPrivateKey_fp(fp,dsa) (DSA *)ASN1_d2i_fp((char *(*)())\
681 DSA_new,(char *(*)())d2i_DSAPrivateKey, (fp), \
682 (unsigned char **)(dsa))
683#define i2d_DSAPrivateKey_fp(fp,dsa) ASN1_i2d_fp(i2d_DSAPrivateKey,fp, \
684 (unsigned char *)dsa)
685#define d2i_DSAPrivateKey_bio(bp,dsa) (DSA *)ASN1_d2i_bio((char *(*)())\
686 DSA_new,(char *(*)())d2i_DSAPrivateKey, (bp), \
687 (unsigned char **)(dsa))
688#define i2d_DSAPrivateKey_bio(bp,dsa) ASN1_i2d_bio(i2d_DSAPrivateKey,bp, \
689 (unsigned char *)dsa)
690
691#define d2i_ECPrivateKey_fp(fp,ecdsa) (EC_KEY *)ASN1_d2i_fp((char *(*)())\
692 EC_KEY_new,(char *(*)())d2i_ECPrivateKey, (fp), \
693 (unsigned char **)(ecdsa))
694#define i2d_ECPrivateKey_fp(fp,ecdsa) ASN1_i2d_fp(i2d_ECPrivateKey,fp, \
695 (unsigned char *)ecdsa)
696#define d2i_ECPrivateKey_bio(bp,ecdsa) (EC_KEY *)ASN1_d2i_bio((char *(*)())\
697 EC_KEY_new,(char *(*)())d2i_ECPrivateKey, (bp), \
698 (unsigned char **)(ecdsa))
699#define i2d_ECPrivateKey_bio(bp,ecdsa) ASN1_i2d_bio(i2d_ECPrivateKey,bp, \
700 (unsigned char *)ecdsa)
701
702#define X509_ALGOR_dup(xn) (X509_ALGOR *)ASN1_dup((int (*)())i2d_X509_ALGOR,\
703 (char *(*)())d2i_X509_ALGOR,(char *)xn)
704
705#define X509_NAME_dup(xn) (X509_NAME *)ASN1_dup((int (*)())i2d_X509_NAME, \
706 (char *(*)())d2i_X509_NAME,(char *)xn)
707#define X509_NAME_ENTRY_dup(ne) (X509_NAME_ENTRY *)ASN1_dup( \
708 (int (*)())i2d_X509_NAME_ENTRY, \
709 (char *(*)())d2i_X509_NAME_ENTRY,\
710 (char *)ne)
711
712#define X509_digest(data,type,md,len) \
713 ASN1_digest((int (*)())i2d_X509,type,(char *)data,md,len)
714#define X509_NAME_digest(data,type,md,len) \
715 ASN1_digest((int (*)())i2d_X509_NAME,type,(char *)data,md,len)
716#ifndef PKCS7_ISSUER_AND_SERIAL_digest
717#define PKCS7_ISSUER_AND_SERIAL_digest(data,type,md,len) \
718 ASN1_digest((int (*)())i2d_PKCS7_ISSUER_AND_SERIAL,type,\
719 (char *)data,md,len)
720#endif
721#endif
722
723#define X509_EXT_PACK_UNKNOWN 1 606#define X509_EXT_PACK_UNKNOWN 1
724#define X509_EXT_PACK_STRING 2 607#define X509_EXT_PACK_STRING 2
725 608
@@ -740,6 +623,18 @@ extern "C" {
740#define X509_CRL_get_issuer(x) ((x)->crl->issuer) 623#define X509_CRL_get_issuer(x) ((x)->crl->issuer)
741#define X509_CRL_get_REVOKED(x) ((x)->crl->revoked) 624#define X509_CRL_get_REVOKED(x) ((x)->crl->revoked)
742 625
626void X509_CRL_set_default_method(const X509_CRL_METHOD *meth);
627X509_CRL_METHOD *X509_CRL_METHOD_new(
628 int (*crl_init)(X509_CRL *crl),
629 int (*crl_free)(X509_CRL *crl),
630 int (*crl_lookup)(X509_CRL *crl, X509_REVOKED **ret,
631 ASN1_INTEGER *ser, X509_NAME *issuer),
632 int (*crl_verify)(X509_CRL *crl, EVP_PKEY *pk));
633void X509_CRL_METHOD_free(X509_CRL_METHOD *m);
634
635void X509_CRL_set_meth_data(X509_CRL *crl, void *dat);
636void *X509_CRL_get_meth_data(X509_CRL *crl);
637
743/* This one is only used so that a binary form can output, as in 638/* This one is only used so that a binary form can output, as in
744 * i2d_X509_NAME(X509_get_X509_PUBKEY(x),&buf) */ 639 * i2d_X509_NAME(X509_get_X509_PUBKEY(x),&buf) */
745#define X509_get_X509_PUBKEY(x) ((x)->cert_info->key) 640#define X509_get_X509_PUBKEY(x) ((x)->cert_info->key)
@@ -747,7 +642,6 @@ extern "C" {
747 642
748const char *X509_verify_cert_error_string(long n); 643const char *X509_verify_cert_error_string(long n);
749 644
750#ifndef SSLEAY_MACROS
751#ifndef OPENSSL_NO_EVP 645#ifndef OPENSSL_NO_EVP
752int X509_verify(X509 *a, EVP_PKEY *r); 646int X509_verify(X509 *a, EVP_PKEY *r);
753 647
@@ -872,11 +766,11 @@ void X509_ALGOR_get0(ASN1_OBJECT **paobj, int *pptype, void **ppval,
872X509_NAME *X509_NAME_dup(X509_NAME *xn); 766X509_NAME *X509_NAME_dup(X509_NAME *xn);
873X509_NAME_ENTRY *X509_NAME_ENTRY_dup(X509_NAME_ENTRY *ne); 767X509_NAME_ENTRY *X509_NAME_ENTRY_dup(X509_NAME_ENTRY *ne);
874 768
875#endif /* !SSLEAY_MACROS */ 769int X509_cmp_time(const ASN1_TIME *s, time_t *t);
876 770int X509_cmp_current_time(const ASN1_TIME *s);
877int X509_cmp_time(ASN1_TIME *s, time_t *t);
878int X509_cmp_current_time(ASN1_TIME *s);
879ASN1_TIME * X509_time_adj(ASN1_TIME *s, long adj, time_t *t); 771ASN1_TIME * X509_time_adj(ASN1_TIME *s, long adj, time_t *t);
772ASN1_TIME * X509_time_adj_ex(ASN1_TIME *s,
773 int offset_day, long offset_sec, time_t *t);
880ASN1_TIME * X509_gmtime_adj(ASN1_TIME *s, long adj); 774ASN1_TIME * X509_gmtime_adj(ASN1_TIME *s, long adj);
881 775
882const char * X509_get_default_cert_area(void ); 776const char * X509_get_default_cert_area(void );
@@ -964,6 +858,9 @@ DECLARE_ASN1_FUNCTIONS(X509_CRL_INFO)
964DECLARE_ASN1_FUNCTIONS(X509_CRL) 858DECLARE_ASN1_FUNCTIONS(X509_CRL)
965 859
966int X509_CRL_add0_revoked(X509_CRL *crl, X509_REVOKED *rev); 860int X509_CRL_add0_revoked(X509_CRL *crl, X509_REVOKED *rev);
861int X509_CRL_get0_by_serial(X509_CRL *crl,
862 X509_REVOKED **ret, ASN1_INTEGER *serial);
863int X509_CRL_get0_by_cert(X509_CRL *crl, X509_REVOKED **ret, X509 *x);
967 864
968X509_PKEY * X509_PKEY_new(void ); 865X509_PKEY * X509_PKEY_new(void );
969void X509_PKEY_free(X509_PKEY *a); 866void X509_PKEY_free(X509_PKEY *a);
@@ -1007,8 +904,8 @@ int X509_set_issuer_name(X509 *x, X509_NAME *name);
1007X509_NAME * X509_get_issuer_name(X509 *a); 904X509_NAME * X509_get_issuer_name(X509 *a);
1008int X509_set_subject_name(X509 *x, X509_NAME *name); 905int X509_set_subject_name(X509 *x, X509_NAME *name);
1009X509_NAME * X509_get_subject_name(X509 *a); 906X509_NAME * X509_get_subject_name(X509 *a);
1010int X509_set_notBefore(X509 *x, ASN1_TIME *tm); 907int X509_set_notBefore(X509 *x, const ASN1_TIME *tm);
1011int X509_set_notAfter(X509 *x, ASN1_TIME *tm); 908int X509_set_notAfter(X509 *x, const ASN1_TIME *tm);
1012int X509_set_pubkey(X509 *x, EVP_PKEY *pkey); 909int X509_set_pubkey(X509 *x, EVP_PKEY *pkey);
1013EVP_PKEY * X509_get_pubkey(X509 *x); 910EVP_PKEY * X509_get_pubkey(X509 *x);
1014ASN1_BIT_STRING * X509_get0_pubkey_bitstr(const X509 *x); 911ASN1_BIT_STRING * X509_get0_pubkey_bitstr(const X509 *x);
@@ -1045,8 +942,8 @@ int X509_REQ_add1_attr_by_txt(X509_REQ *req,
1045 942
1046int X509_CRL_set_version(X509_CRL *x, long version); 943int X509_CRL_set_version(X509_CRL *x, long version);
1047int X509_CRL_set_issuer_name(X509_CRL *x, X509_NAME *name); 944int X509_CRL_set_issuer_name(X509_CRL *x, X509_NAME *name);
1048int X509_CRL_set_lastUpdate(X509_CRL *x, ASN1_TIME *tm); 945int X509_CRL_set_lastUpdate(X509_CRL *x, const ASN1_TIME *tm);
1049int X509_CRL_set_nextUpdate(X509_CRL *x, ASN1_TIME *tm); 946int X509_CRL_set_nextUpdate(X509_CRL *x, const ASN1_TIME *tm);
1050int X509_CRL_sort(X509_CRL *crl); 947int X509_CRL_sort(X509_CRL *crl);
1051 948
1052int X509_REVOKED_set_serialNumber(X509_REVOKED *x, ASN1_INTEGER *serial); 949int X509_REVOKED_set_serialNumber(X509_REVOKED *x, ASN1_INTEGER *serial);
@@ -1065,11 +962,18 @@ unsigned long X509_issuer_name_hash(X509 *a);
1065int X509_subject_name_cmp(const X509 *a, const X509 *b); 962int X509_subject_name_cmp(const X509 *a, const X509 *b);
1066unsigned long X509_subject_name_hash(X509 *x); 963unsigned long X509_subject_name_hash(X509 *x);
1067 964
965#ifndef OPENSSL_NO_MD5
966unsigned long X509_issuer_name_hash_old(X509 *a);
967unsigned long X509_subject_name_hash_old(X509 *x);
968#endif
969
1068int X509_cmp(const X509 *a, const X509 *b); 970int X509_cmp(const X509 *a, const X509 *b);
1069int X509_NAME_cmp(const X509_NAME *a, const X509_NAME *b); 971int X509_NAME_cmp(const X509_NAME *a, const X509_NAME *b);
1070unsigned long X509_NAME_hash(X509_NAME *x); 972unsigned long X509_NAME_hash(X509_NAME *x);
973unsigned long X509_NAME_hash_old(X509_NAME *x);
1071 974
1072int X509_CRL_cmp(const X509_CRL *a, const X509_CRL *b); 975int X509_CRL_cmp(const X509_CRL *a, const X509_CRL *b);
976int X509_CRL_match(const X509_CRL *a, const X509_CRL *b);
1073#ifndef OPENSSL_NO_FP_API 977#ifndef OPENSSL_NO_FP_API
1074int X509_print_ex_fp(FILE *bp,X509 *x, unsigned long nmflag, unsigned long cflag); 978int X509_print_ex_fp(FILE *bp,X509 *x, unsigned long nmflag, unsigned long cflag);
1075int X509_print_fp(FILE *bp,X509 *x); 979int X509_print_fp(FILE *bp,X509 *x);
@@ -1245,9 +1149,16 @@ DECLARE_ASN1_FUNCTIONS(PBEPARAM)
1245DECLARE_ASN1_FUNCTIONS(PBE2PARAM) 1149DECLARE_ASN1_FUNCTIONS(PBE2PARAM)
1246DECLARE_ASN1_FUNCTIONS(PBKDF2PARAM) 1150DECLARE_ASN1_FUNCTIONS(PBKDF2PARAM)
1247 1151
1248X509_ALGOR *PKCS5_pbe_set(int alg, int iter, unsigned char *salt, int saltlen); 1152int PKCS5_pbe_set0_algor(X509_ALGOR *algor, int alg, int iter,
1153 const unsigned char *salt, int saltlen);
1154
1155X509_ALGOR *PKCS5_pbe_set(int alg, int iter,
1156 const unsigned char *salt, int saltlen);
1249X509_ALGOR *PKCS5_pbe2_set(const EVP_CIPHER *cipher, int iter, 1157X509_ALGOR *PKCS5_pbe2_set(const EVP_CIPHER *cipher, int iter,
1250 unsigned char *salt, int saltlen); 1158 unsigned char *salt, int saltlen);
1159X509_ALGOR *PKCS5_pbe2_set_iv(const EVP_CIPHER *cipher, int iter,
1160 unsigned char *salt, int saltlen,
1161 unsigned char *aiv, int prf_nid);
1251 1162
1252/* PKCS#8 utilities */ 1163/* PKCS#8 utilities */
1253 1164
@@ -1258,6 +1169,22 @@ PKCS8_PRIV_KEY_INFO *EVP_PKEY2PKCS8(EVP_PKEY *pkey);
1258PKCS8_PRIV_KEY_INFO *EVP_PKEY2PKCS8_broken(EVP_PKEY *pkey, int broken); 1169PKCS8_PRIV_KEY_INFO *EVP_PKEY2PKCS8_broken(EVP_PKEY *pkey, int broken);
1259PKCS8_PRIV_KEY_INFO *PKCS8_set_broken(PKCS8_PRIV_KEY_INFO *p8, int broken); 1170PKCS8_PRIV_KEY_INFO *PKCS8_set_broken(PKCS8_PRIV_KEY_INFO *p8, int broken);
1260 1171
1172int PKCS8_pkey_set0(PKCS8_PRIV_KEY_INFO *priv, ASN1_OBJECT *aobj,
1173 int version, int ptype, void *pval,
1174 unsigned char *penc, int penclen);
1175int PKCS8_pkey_get0(ASN1_OBJECT **ppkalg,
1176 const unsigned char **pk, int *ppklen,
1177 X509_ALGOR **pa,
1178 PKCS8_PRIV_KEY_INFO *p8);
1179
1180int X509_PUBKEY_set0_param(X509_PUBKEY *pub, ASN1_OBJECT *aobj,
1181 int ptype, void *pval,
1182 unsigned char *penc, int penclen);
1183int X509_PUBKEY_get0_param(ASN1_OBJECT **ppkalg,
1184 const unsigned char **pk, int *ppklen,
1185 X509_ALGOR **pa,
1186 X509_PUBKEY *pub);
1187
1261int X509_check_trust(X509 *x, int id, int flags); 1188int X509_check_trust(X509 *x, int id, int flags);
1262int X509_TRUST_get_count(void); 1189int X509_TRUST_get_count(void);
1263X509_TRUST * X509_TRUST_get0(int idx); 1190X509_TRUST * X509_TRUST_get0(int idx);
@@ -1337,7 +1264,10 @@ void ERR_load_X509_strings(void);
1337#define X509_R_KEY_VALUES_MISMATCH 116 1264#define X509_R_KEY_VALUES_MISMATCH 116
1338#define X509_R_LOADING_CERT_DIR 103 1265#define X509_R_LOADING_CERT_DIR 103
1339#define X509_R_LOADING_DEFAULTS 104 1266#define X509_R_LOADING_DEFAULTS 104
1267#define X509_R_METHOD_NOT_SUPPORTED 124
1340#define X509_R_NO_CERT_SET_FOR_US_TO_VERIFY 105 1268#define X509_R_NO_CERT_SET_FOR_US_TO_VERIFY 105
1269#define X509_R_PUBLIC_KEY_DECODE_ERROR 125
1270#define X509_R_PUBLIC_KEY_ENCODE_ERROR 126
1341#define X509_R_SHOULD_RETRY 106 1271#define X509_R_SHOULD_RETRY 106
1342#define X509_R_UNABLE_TO_FIND_PARAMETERS_IN_CHAIN 107 1272#define X509_R_UNABLE_TO_FIND_PARAMETERS_IN_CHAIN 107
1343#define X509_R_UNABLE_TO_GET_CERTS_PUBLIC_KEY 108 1273#define X509_R_UNABLE_TO_GET_CERTS_PUBLIC_KEY 108
diff --git a/src/lib/libcrypto/x509/x509_cmp.c b/src/lib/libcrypto/x509/x509_cmp.c
index 2faf92514a..4bc9da07e0 100644
--- a/src/lib/libcrypto/x509/x509_cmp.c
+++ b/src/lib/libcrypto/x509/x509_cmp.c
@@ -116,6 +116,13 @@ int X509_CRL_cmp(const X509_CRL *a, const X509_CRL *b)
116 return(X509_NAME_cmp(a->crl->issuer,b->crl->issuer)); 116 return(X509_NAME_cmp(a->crl->issuer,b->crl->issuer));
117 } 117 }
118 118
119#ifndef OPENSSL_NO_SHA
120int X509_CRL_match(const X509_CRL *a, const X509_CRL *b)
121 {
122 return memcmp(a->sha1_hash, b->sha1_hash, 20);
123 }
124#endif
125
119X509_NAME *X509_get_issuer_name(X509 *a) 126X509_NAME *X509_get_issuer_name(X509 *a)
120 { 127 {
121 return(a->cert_info->issuer); 128 return(a->cert_info->issuer);
@@ -126,6 +133,13 @@ unsigned long X509_issuer_name_hash(X509 *x)
126 return(X509_NAME_hash(x->cert_info->issuer)); 133 return(X509_NAME_hash(x->cert_info->issuer));
127 } 134 }
128 135
136#ifndef OPENSSL_NO_MD5
137unsigned long X509_issuer_name_hash_old(X509 *x)
138 {
139 return(X509_NAME_hash_old(x->cert_info->issuer));
140 }
141#endif
142
129X509_NAME *X509_get_subject_name(X509 *a) 143X509_NAME *X509_get_subject_name(X509 *a)
130 { 144 {
131 return(a->cert_info->subject); 145 return(a->cert_info->subject);
@@ -141,6 +155,13 @@ unsigned long X509_subject_name_hash(X509 *x)
141 return(X509_NAME_hash(x->cert_info->subject)); 155 return(X509_NAME_hash(x->cert_info->subject));
142 } 156 }
143 157
158#ifndef OPENSSL_NO_MD5
159unsigned long X509_subject_name_hash_old(X509 *x)
160 {
161 return(X509_NAME_hash_old(x->cert_info->subject));
162 }
163#endif
164
144#ifndef OPENSSL_NO_SHA 165#ifndef OPENSSL_NO_SHA
145/* Compare two certificates: they must be identical for 166/* Compare two certificates: they must be identical for
146 * this to work. NB: Although "cmp" operations are generally 167 * this to work. NB: Although "cmp" operations are generally
@@ -162,177 +183,63 @@ int X509_cmp(const X509 *a, const X509 *b)
162#endif 183#endif
163 184
164 185
165/* Case insensitive string comparision */ 186int X509_NAME_cmp(const X509_NAME *a, const X509_NAME *b)
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 { 187 {
221 int ca, cb; 188 int ret;
222
223 /* compare character */
224 ca = tolower(*pa);
225 cb = tolower(*pb);
226 if (ca != cb)
227 return (ca - cb);
228 189
229 pa++; pb++; 190 /* Ensure canonical encoding is present and up to date */
230 la--; lb--;
231 191
232 if (la <= 0 || lb <= 0) 192 if (!a->canon_enc || a->modified)
233 break; 193 {
194 ret = i2d_X509_NAME((X509_NAME *)a, NULL);
195 if (ret < 0)
196 return -2;
197 }
234 198
235 /* is white space next character ? */ 199 if (!b->canon_enc || b->modified)
236 if (isspace(*pa) && isspace(*pb))
237 { 200 {
238 /* skip remaining white spaces */ 201 ret = i2d_X509_NAME((X509_NAME *)b, NULL);
239 while (la > 0 && isspace(*pa)) 202 if (ret < 0)
240 { 203 return -2;
241 la--;
242 pa++;
243 }
244 while (lb > 0 && isspace(*pb))
245 {
246 lb--;
247 pb++;
248 }
249 } 204 }
250 }
251 if (la > 0 || lb > 0)
252 return la - lb;
253 205
254 return 0; 206 ret = a->canon_enclen - b->canon_enclen;
255}
256 207
257static int asn1_string_memcmp(ASN1_STRING *a, ASN1_STRING *b) 208 if (ret)
258 { 209 return ret;
259 int j;
260 j = a->length - b->length;
261 if (j)
262 return j;
263 return memcmp(a->data, b->data, a->length);
264 }
265 210
266#define STR_TYPE_CMP (B_ASN1_PRINTABLESTRING|B_ASN1_T61STRING|B_ASN1_UTF8STRING) 211 return memcmp(a->canon_enc, b->canon_enc, a->canon_enclen);
267 212
268int X509_NAME_cmp(const X509_NAME *a, const X509_NAME *b) 213 }
269 {
270 int i,j;
271 X509_NAME_ENTRY *na,*nb;
272 214
273 unsigned long nabit, nbbit; 215unsigned long X509_NAME_hash(X509_NAME *x)
216 {
217 unsigned long ret=0;
218 unsigned char md[SHA_DIGEST_LENGTH];
274 219
275 j = sk_X509_NAME_ENTRY_num(a->entries) 220 /* Make sure X509_NAME structure contains valid cached encoding */
276 - sk_X509_NAME_ENTRY_num(b->entries); 221 i2d_X509_NAME(x,NULL);
277 if (j) 222 EVP_Digest(x->canon_enc, x->canon_enclen, md, NULL, EVP_sha1(), NULL);
278 return j;
279 for (i=sk_X509_NAME_ENTRY_num(a->entries)-1; i>=0; i--)
280 {
281 na=sk_X509_NAME_ENTRY_value(a->entries,i);
282 nb=sk_X509_NAME_ENTRY_value(b->entries,i);
283 j=na->value->type-nb->value->type;
284 if (j)
285 {
286 nabit = ASN1_tag2bit(na->value->type);
287 nbbit = ASN1_tag2bit(nb->value->type);
288 if (!(nabit & STR_TYPE_CMP) ||
289 !(nbbit & STR_TYPE_CMP))
290 return j;
291 if (!asn1_string_memcmp(na->value, nb->value))
292 j = 0;
293 }
294 else if (na->value->type == V_ASN1_PRINTABLESTRING)
295 j=nocase_spacenorm_cmp(na->value, nb->value);
296 else if (na->value->type == V_ASN1_IA5STRING
297 && OBJ_obj2nid(na->object) == NID_pkcs9_emailAddress)
298 j=nocase_cmp(na->value, nb->value);
299 else
300 j = asn1_string_memcmp(na->value, nb->value);
301 if (j) return(j);
302 j=na->set-nb->set;
303 if (j) return(j);
304 }
305 223
306 /* We will check the object types after checking the values 224 ret=( ((unsigned long)md[0] )|((unsigned long)md[1]<<8L)|
307 * since the values will more often be different than the object 225 ((unsigned long)md[2]<<16L)|((unsigned long)md[3]<<24L)
308 * types. */ 226 )&0xffffffffL;
309 for (i=sk_X509_NAME_ENTRY_num(a->entries)-1; i>=0; i--) 227 return(ret);
310 {
311 na=sk_X509_NAME_ENTRY_value(a->entries,i);
312 nb=sk_X509_NAME_ENTRY_value(b->entries,i);
313 j=OBJ_cmp(na->object,nb->object);
314 if (j) return(j);
315 }
316 return(0);
317 } 228 }
318 229
230
319#ifndef OPENSSL_NO_MD5 231#ifndef OPENSSL_NO_MD5
320/* I now DER encode the name and hash it. Since I cache the DER encoding, 232/* I now DER encode the name and hash it. Since I cache the DER encoding,
321 * this is reasonably efficient. */ 233 * this is reasonably efficient. */
322unsigned long X509_NAME_hash(X509_NAME *x) 234
235unsigned long X509_NAME_hash_old(X509_NAME *x)
323 { 236 {
324 unsigned long ret=0; 237 unsigned long ret=0;
325 unsigned char md[16]; 238 unsigned char md[16];
326 EVP_MD_CTX md_ctx;
327 239
328 /* Make sure X509_NAME structure contains valid cached encoding */ 240 /* Make sure X509_NAME structure contains valid cached encoding */
329 i2d_X509_NAME(x,NULL); 241 i2d_X509_NAME(x,NULL);
330 EVP_MD_CTX_init(&md_ctx); 242 EVP_Digest(x->bytes->data, x->bytes->length, md, NULL, EVP_md5(), NULL);
331 EVP_MD_CTX_set_flags(&md_ctx, EVP_MD_CTX_FLAG_NON_FIPS_ALLOW);
332 EVP_DigestInit_ex(&md_ctx, EVP_md5(), NULL);
333 EVP_DigestUpdate(&md_ctx, x->bytes->data, x->bytes->length);
334 EVP_DigestFinal_ex(&md_ctx,md,NULL);
335 EVP_MD_CTX_cleanup(&md_ctx);
336 243
337 ret=( ((unsigned long)md[0] )|((unsigned long)md[1]<<8L)| 244 ret=( ((unsigned long)md[0] )|((unsigned long)md[1]<<8L)|
338 ((unsigned long)md[2]<<16L)|((unsigned long)md[3]<<24L) 245 ((unsigned long)md[2]<<16L)|((unsigned long)md[3]<<24L)
@@ -393,14 +300,19 @@ ASN1_BIT_STRING *X509_get0_pubkey_bitstr(const X509 *x)
393 300
394int X509_check_private_key(X509 *x, EVP_PKEY *k) 301int X509_check_private_key(X509 *x, EVP_PKEY *k)
395 { 302 {
396 EVP_PKEY *xk=NULL; 303 EVP_PKEY *xk;
397 int ok=0; 304 int ret;
398 305
399 xk=X509_get_pubkey(x); 306 xk=X509_get_pubkey(x);
400 switch (EVP_PKEY_cmp(xk, k)) 307
308 if (xk)
309 ret = EVP_PKEY_cmp(xk, k);
310 else
311 ret = -2;
312
313 switch (ret)
401 { 314 {
402 case 1: 315 case 1:
403 ok=1;
404 break; 316 break;
405 case 0: 317 case 0:
406 X509err(X509_F_X509_CHECK_PRIVATE_KEY,X509_R_KEY_VALUES_MISMATCH); 318 X509err(X509_F_X509_CHECK_PRIVATE_KEY,X509_R_KEY_VALUES_MISMATCH);
@@ -409,24 +321,11 @@ int X509_check_private_key(X509 *x, EVP_PKEY *k)
409 X509err(X509_F_X509_CHECK_PRIVATE_KEY,X509_R_KEY_TYPE_MISMATCH); 321 X509err(X509_F_X509_CHECK_PRIVATE_KEY,X509_R_KEY_TYPE_MISMATCH);
410 break; 322 break;
411 case -2: 323 case -2:
412#ifndef OPENSSL_NO_EC
413 if (k->type == EVP_PKEY_EC)
414 {
415 X509err(X509_F_X509_CHECK_PRIVATE_KEY, ERR_R_EC_LIB);
416 break;
417 }
418#endif
419#ifndef OPENSSL_NO_DH
420 if (k->type == EVP_PKEY_DH)
421 {
422 /* No idea */
423 X509err(X509_F_X509_CHECK_PRIVATE_KEY,X509_R_CANT_CHECK_DH_KEY);
424 break;
425 }
426#endif
427 X509err(X509_F_X509_CHECK_PRIVATE_KEY,X509_R_UNKNOWN_KEY_TYPE); 324 X509err(X509_F_X509_CHECK_PRIVATE_KEY,X509_R_UNKNOWN_KEY_TYPE);
428 } 325 }
429 326 if (xk)
430 EVP_PKEY_free(xk); 327 EVP_PKEY_free(xk);
431 return(ok); 328 if (ret > 0)
329 return 1;
330 return 0;
432 } 331 }
diff --git a/src/lib/libcrypto/x509/x509_err.c b/src/lib/libcrypto/x509/x509_err.c
index fb377292da..a01402f416 100644
--- a/src/lib/libcrypto/x509/x509_err.c
+++ b/src/lib/libcrypto/x509/x509_err.c
@@ -1,6 +1,6 @@
1/* crypto/x509/x509_err.c */ 1/* crypto/x509/x509_err.c */
2/* ==================================================================== 2/* ====================================================================
3 * Copyright (c) 1999-2005 The OpenSSL Project. All rights reserved. 3 * Copyright (c) 1999-2006 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
@@ -132,7 +132,10 @@ static ERR_STRING_DATA X509_str_reasons[]=
132{ERR_REASON(X509_R_KEY_VALUES_MISMATCH) ,"key values mismatch"}, 132{ERR_REASON(X509_R_KEY_VALUES_MISMATCH) ,"key values mismatch"},
133{ERR_REASON(X509_R_LOADING_CERT_DIR) ,"loading cert dir"}, 133{ERR_REASON(X509_R_LOADING_CERT_DIR) ,"loading cert dir"},
134{ERR_REASON(X509_R_LOADING_DEFAULTS) ,"loading defaults"}, 134{ERR_REASON(X509_R_LOADING_DEFAULTS) ,"loading defaults"},
135{ERR_REASON(X509_R_METHOD_NOT_SUPPORTED) ,"method not supported"},
135{ERR_REASON(X509_R_NO_CERT_SET_FOR_US_TO_VERIFY),"no cert set for us to verify"}, 136{ERR_REASON(X509_R_NO_CERT_SET_FOR_US_TO_VERIFY),"no cert set for us to verify"},
137{ERR_REASON(X509_R_PUBLIC_KEY_DECODE_ERROR),"public key decode error"},
138{ERR_REASON(X509_R_PUBLIC_KEY_ENCODE_ERROR),"public key encode error"},
136{ERR_REASON(X509_R_SHOULD_RETRY) ,"should retry"}, 139{ERR_REASON(X509_R_SHOULD_RETRY) ,"should retry"},
137{ERR_REASON(X509_R_UNABLE_TO_FIND_PARAMETERS_IN_CHAIN),"unable to find parameters in chain"}, 140{ERR_REASON(X509_R_UNABLE_TO_FIND_PARAMETERS_IN_CHAIN),"unable to find parameters in chain"},
138{ERR_REASON(X509_R_UNABLE_TO_GET_CERTS_PUBLIC_KEY),"unable to get certs public key"}, 141{ERR_REASON(X509_R_UNABLE_TO_GET_CERTS_PUBLIC_KEY),"unable to get certs public key"},
diff --git a/src/lib/libcrypto/x509/x509_lu.c b/src/lib/libcrypto/x509/x509_lu.c
index cd2cfb6d85..3a6e04a1de 100644
--- a/src/lib/libcrypto/x509/x509_lu.c
+++ b/src/lib/libcrypto/x509/x509_lu.c
@@ -196,9 +196,17 @@ X509_STORE *X509_STORE_new(void)
196 ret->get_crl = 0; 196 ret->get_crl = 0;
197 ret->check_crl = 0; 197 ret->check_crl = 0;
198 ret->cert_crl = 0; 198 ret->cert_crl = 0;
199 ret->lookup_certs = 0;
200 ret->lookup_crls = 0;
199 ret->cleanup = 0; 201 ret->cleanup = 0;
200 202
201 CRYPTO_new_ex_data(CRYPTO_EX_INDEX_X509_STORE, ret, &ret->ex_data); 203 if (!CRYPTO_new_ex_data(CRYPTO_EX_INDEX_X509_STORE, ret, &ret->ex_data))
204 {
205 sk_X509_OBJECT_free(ret->objs);
206 OPENSSL_free(ret);
207 return NULL;
208 }
209
202 ret->references=1; 210 ret->references=1;
203 return ret; 211 return ret;
204 } 212 }
@@ -286,9 +294,11 @@ int X509_STORE_get_by_subject(X509_STORE_CTX *vs, int type, X509_NAME *name,
286 X509_OBJECT stmp,*tmp; 294 X509_OBJECT stmp,*tmp;
287 int i,j; 295 int i,j;
288 296
297 CRYPTO_w_lock(CRYPTO_LOCK_X509_STORE);
289 tmp=X509_OBJECT_retrieve_by_subject(ctx->objs,type,name); 298 tmp=X509_OBJECT_retrieve_by_subject(ctx->objs,type,name);
299 CRYPTO_w_unlock(CRYPTO_LOCK_X509_STORE);
290 300
291 if (tmp == NULL) 301 if (tmp == NULL || type == X509_LU_CRL)
292 { 302 {
293 for (i=vs->current_method; i<sk_X509_LOOKUP_num(ctx->get_cert_methods); i++) 303 for (i=vs->current_method; i<sk_X509_LOOKUP_num(ctx->get_cert_methods); i++)
294 { 304 {
@@ -340,7 +350,6 @@ int X509_STORE_add_cert(X509_STORE *ctx, X509 *x)
340 350
341 X509_OBJECT_up_ref_count(obj); 351 X509_OBJECT_up_ref_count(obj);
342 352
343
344 if (X509_OBJECT_retrieve_match(ctx->objs, obj)) 353 if (X509_OBJECT_retrieve_match(ctx->objs, obj))
345 { 354 {
346 X509_OBJECT_free_contents(obj); 355 X509_OBJECT_free_contents(obj);
@@ -414,14 +423,15 @@ void X509_OBJECT_free_contents(X509_OBJECT *a)
414 } 423 }
415 } 424 }
416 425
417int X509_OBJECT_idx_by_subject(STACK_OF(X509_OBJECT) *h, int type, 426static int x509_object_idx_cnt(STACK_OF(X509_OBJECT) *h, int type,
418 X509_NAME *name) 427 X509_NAME *name, int *pnmatch)
419 { 428 {
420 X509_OBJECT stmp; 429 X509_OBJECT stmp;
421 X509 x509_s; 430 X509 x509_s;
422 X509_CINF cinf_s; 431 X509_CINF cinf_s;
423 X509_CRL crl_s; 432 X509_CRL crl_s;
424 X509_CRL_INFO crl_info_s; 433 X509_CRL_INFO crl_info_s;
434 int idx;
425 435
426 stmp.type=type; 436 stmp.type=type;
427 switch (type) 437 switch (type)
@@ -441,41 +451,169 @@ int X509_OBJECT_idx_by_subject(STACK_OF(X509_OBJECT) *h, int type,
441 return -1; 451 return -1;
442 } 452 }
443 453
444 return sk_X509_OBJECT_find(h,&stmp); 454 idx = sk_X509_OBJECT_find(h,&stmp);
455 if (idx >= 0 && pnmatch)
456 {
457 int tidx;
458 const X509_OBJECT *tobj, *pstmp;
459 *pnmatch = 1;
460 pstmp = &stmp;
461 for (tidx = idx + 1; tidx < sk_X509_OBJECT_num(h); tidx++)
462 {
463 tobj = sk_X509_OBJECT_value(h, tidx);
464 if (x509_object_cmp(&tobj, &pstmp))
465 break;
466 (*pnmatch)++;
467 }
468 }
469 return idx;
470 }
471
472
473int X509_OBJECT_idx_by_subject(STACK_OF(X509_OBJECT) *h, int type,
474 X509_NAME *name)
475 {
476 return x509_object_idx_cnt(h, type, name, NULL);
445 } 477 }
446 478
447X509_OBJECT *X509_OBJECT_retrieve_by_subject(STACK_OF(X509_OBJECT) *h, int type, 479X509_OBJECT *X509_OBJECT_retrieve_by_subject(STACK_OF(X509_OBJECT) *h, int type,
448 X509_NAME *name) 480 X509_NAME *name)
449{ 481 {
450 int idx; 482 int idx;
451 idx = X509_OBJECT_idx_by_subject(h, type, name); 483 idx = X509_OBJECT_idx_by_subject(h, type, name);
452 if (idx==-1) return NULL; 484 if (idx==-1) return NULL;
453 return sk_X509_OBJECT_value(h, idx); 485 return sk_X509_OBJECT_value(h, idx);
454} 486 }
487
488STACK_OF(X509)* X509_STORE_get1_certs(X509_STORE_CTX *ctx, X509_NAME *nm)
489 {
490 int i, idx, cnt;
491 STACK_OF(X509) *sk;
492 X509 *x;
493 X509_OBJECT *obj;
494 sk = sk_X509_new_null();
495 CRYPTO_w_lock(CRYPTO_LOCK_X509_STORE);
496 idx = x509_object_idx_cnt(ctx->ctx->objs, X509_LU_X509, nm, &cnt);
497 if (idx < 0)
498 {
499 /* Nothing found in cache: do lookup to possibly add new
500 * objects to cache
501 */
502 X509_OBJECT xobj;
503 CRYPTO_w_unlock(CRYPTO_LOCK_X509_STORE);
504 if (!X509_STORE_get_by_subject(ctx, X509_LU_X509, nm, &xobj))
505 {
506 sk_X509_free(sk);
507 return NULL;
508 }
509 X509_OBJECT_free_contents(&xobj);
510 CRYPTO_w_lock(CRYPTO_LOCK_X509_STORE);
511 idx = x509_object_idx_cnt(ctx->ctx->objs,X509_LU_X509,nm, &cnt);
512 if (idx < 0)
513 {
514 CRYPTO_w_unlock(CRYPTO_LOCK_X509_STORE);
515 sk_X509_free(sk);
516 return NULL;
517 }
518 }
519 for (i = 0; i < cnt; i++, idx++)
520 {
521 obj = sk_X509_OBJECT_value(ctx->ctx->objs, idx);
522 x = obj->data.x509;
523 CRYPTO_add(&x->references, 1, CRYPTO_LOCK_X509);
524 if (!sk_X509_push(sk, x))
525 {
526 CRYPTO_w_unlock(CRYPTO_LOCK_X509_STORE);
527 X509_free(x);
528 sk_X509_pop_free(sk, X509_free);
529 return NULL;
530 }
531 }
532 CRYPTO_w_unlock(CRYPTO_LOCK_X509_STORE);
533 return sk;
534
535 }
536
537STACK_OF(X509_CRL)* X509_STORE_get1_crls(X509_STORE_CTX *ctx, X509_NAME *nm)
538 {
539 int i, idx, cnt;
540 STACK_OF(X509_CRL) *sk;
541 X509_CRL *x;
542 X509_OBJECT *obj, xobj;
543 sk = sk_X509_CRL_new_null();
544 CRYPTO_w_lock(CRYPTO_LOCK_X509_STORE);
545 /* Check cache first */
546 idx = x509_object_idx_cnt(ctx->ctx->objs, X509_LU_CRL, nm, &cnt);
547
548 /* Always do lookup to possibly add new CRLs to cache
549 */
550 CRYPTO_w_unlock(CRYPTO_LOCK_X509_STORE);
551 if (!X509_STORE_get_by_subject(ctx, X509_LU_CRL, nm, &xobj))
552 {
553 sk_X509_CRL_free(sk);
554 return NULL;
555 }
556 X509_OBJECT_free_contents(&xobj);
557 CRYPTO_w_lock(CRYPTO_LOCK_X509_STORE);
558 idx = x509_object_idx_cnt(ctx->ctx->objs,X509_LU_CRL, nm, &cnt);
559 if (idx < 0)
560 {
561 CRYPTO_w_unlock(CRYPTO_LOCK_X509_STORE);
562 sk_X509_CRL_free(sk);
563 return NULL;
564 }
565
566 for (i = 0; i < cnt; i++, idx++)
567 {
568 obj = sk_X509_OBJECT_value(ctx->ctx->objs, idx);
569 x = obj->data.crl;
570 CRYPTO_add(&x->references, 1, CRYPTO_LOCK_X509_CRL);
571 if (!sk_X509_CRL_push(sk, x))
572 {
573 CRYPTO_w_unlock(CRYPTO_LOCK_X509_STORE);
574 X509_CRL_free(x);
575 sk_X509_CRL_pop_free(sk, X509_CRL_free);
576 return NULL;
577 }
578 }
579 CRYPTO_w_unlock(CRYPTO_LOCK_X509_STORE);
580 return sk;
581 }
455 582
456X509_OBJECT *X509_OBJECT_retrieve_match(STACK_OF(X509_OBJECT) *h, X509_OBJECT *x) 583X509_OBJECT *X509_OBJECT_retrieve_match(STACK_OF(X509_OBJECT) *h, X509_OBJECT *x)
457{ 584 {
458 int idx, i; 585 int idx, i;
459 X509_OBJECT *obj; 586 X509_OBJECT *obj;
460 idx = sk_X509_OBJECT_find(h, x); 587 idx = sk_X509_OBJECT_find(h, x);
461 if (idx == -1) return NULL; 588 if (idx == -1) return NULL;
462 if (x->type != X509_LU_X509) return sk_X509_OBJECT_value(h, idx); 589 if ((x->type != X509_LU_X509) && (x->type != X509_LU_CRL))
590 return sk_X509_OBJECT_value(h, idx);
463 for (i = idx; i < sk_X509_OBJECT_num(h); i++) 591 for (i = idx; i < sk_X509_OBJECT_num(h); i++)
464 { 592 {
465 obj = sk_X509_OBJECT_value(h, i); 593 obj = sk_X509_OBJECT_value(h, i);
466 if (x509_object_cmp((const X509_OBJECT **)&obj, (const X509_OBJECT **)&x)) 594 if (x509_object_cmp((const X509_OBJECT **)&obj, (const X509_OBJECT **)&x))
467 return NULL; 595 return NULL;
468 if ((x->type != X509_LU_X509) || !X509_cmp(obj->data.x509, x->data.x509)) 596 if (x->type == X509_LU_X509)
597 {
598 if (!X509_cmp(obj->data.x509, x->data.x509))
599 return obj;
600 }
601 else if (x->type == X509_LU_CRL)
602 {
603 if (!X509_CRL_match(obj->data.crl, x->data.crl))
604 return obj;
605 }
606 else
469 return obj; 607 return obj;
470 } 608 }
471 return NULL; 609 return NULL;
472} 610 }
473 611
474 612
475/* Try to get issuer certificate from store. Due to limitations 613/* Try to get issuer certificate from store. Due to limitations
476 * of the API this can only retrieve a single certificate matching 614 * of the API this can only retrieve a single certificate matching
477 * a given subject name. However it will fill the cache with all 615 * a given subject name. However it will fill the cache with all
478 * matching certificates, so we can examine the cache for all 616 * matching certificates, so we can examine the cache for all
479 * matches. 617 * matches.
480 * 618 *
481 * Return values are: 619 * Return values are:
@@ -483,13 +621,11 @@ X509_OBJECT *X509_OBJECT_retrieve_match(STACK_OF(X509_OBJECT) *h, X509_OBJECT *x
483 * 0 certificate not found. 621 * 0 certificate not found.
484 * -1 some other error. 622 * -1 some other error.
485 */ 623 */
486
487
488int X509_STORE_CTX_get1_issuer(X509 **issuer, X509_STORE_CTX *ctx, X509 *x) 624int X509_STORE_CTX_get1_issuer(X509 **issuer, X509_STORE_CTX *ctx, X509 *x)
489{ 625 {
490 X509_NAME *xn; 626 X509_NAME *xn;
491 X509_OBJECT obj, *pobj; 627 X509_OBJECT obj, *pobj;
492 int i, ok, idx; 628 int i, ok, idx, ret;
493 xn=X509_get_issuer_name(x); 629 xn=X509_get_issuer_name(x);
494 ok=X509_STORE_get_by_subject(ctx,X509_LU_X509,xn,&obj); 630 ok=X509_STORE_get_by_subject(ctx,X509_LU_X509,xn,&obj);
495 if (ok != X509_LU_X509) 631 if (ok != X509_LU_X509)
@@ -515,27 +651,34 @@ int X509_STORE_CTX_get1_issuer(X509 **issuer, X509_STORE_CTX *ctx, X509 *x)
515 return 1; 651 return 1;
516 } 652 }
517 X509_OBJECT_free_contents(&obj); 653 X509_OBJECT_free_contents(&obj);
518 /* Else find index of first matching cert */
519 idx = X509_OBJECT_idx_by_subject(ctx->ctx->objs, X509_LU_X509, xn);
520 /* This shouldn't normally happen since we already have one match */
521 if (idx == -1) return 0;
522 654
523 /* Look through all matching certificates for a suitable issuer */ 655 /* Else find index of first cert accepted by 'check_issued' */
524 for (i = idx; i < sk_X509_OBJECT_num(ctx->ctx->objs); i++) 656 ret = 0;
657 CRYPTO_w_lock(CRYPTO_LOCK_X509_STORE);
658 idx = X509_OBJECT_idx_by_subject(ctx->ctx->objs, X509_LU_X509, xn);
659 if (idx != -1) /* should be true as we've had at least one match */
525 { 660 {
526 pobj = sk_X509_OBJECT_value(ctx->ctx->objs, i); 661 /* Look through all matching certs for suitable issuer */
527 /* See if we've ran out of matches */ 662 for (i = idx; i < sk_X509_OBJECT_num(ctx->ctx->objs); i++)
528 if (pobj->type != X509_LU_X509) return 0;
529 if (X509_NAME_cmp(xn, X509_get_subject_name(pobj->data.x509))) return 0;
530 if (ctx->check_issued(ctx, x, pobj->data.x509))
531 { 663 {
532 *issuer = pobj->data.x509; 664 pobj = sk_X509_OBJECT_value(ctx->ctx->objs, i);
533 X509_OBJECT_up_ref_count(pobj); 665 /* See if we've run past the matches */
534 return 1; 666 if (pobj->type != X509_LU_X509)
667 break;
668 if (X509_NAME_cmp(xn, X509_get_subject_name(pobj->data.x509)))
669 break;
670 if (ctx->check_issued(ctx, x, pobj->data.x509))
671 {
672 *issuer = pobj->data.x509;
673 X509_OBJECT_up_ref_count(pobj);
674 ret = 1;
675 break;
676 }
535 } 677 }
536 } 678 }
537 return 0; 679 CRYPTO_w_unlock(CRYPTO_LOCK_X509_STORE);
538} 680 return ret;
681 }
539 682
540int X509_STORE_set_flags(X509_STORE *ctx, unsigned long flags) 683int X509_STORE_set_flags(X509_STORE *ctx, unsigned long flags)
541 { 684 {
@@ -563,5 +706,11 @@ int X509_STORE_set1_param(X509_STORE *ctx, X509_VERIFY_PARAM *param)
563 return X509_VERIFY_PARAM_set1(ctx->param, param); 706 return X509_VERIFY_PARAM_set1(ctx->param, param);
564 } 707 }
565 708
709void X509_STORE_set_verify_cb(X509_STORE *ctx,
710 int (*verify_cb)(int, X509_STORE_CTX *))
711 {
712 ctx->verify_cb = verify_cb;
713 }
714
566IMPLEMENT_STACK_OF(X509_LOOKUP) 715IMPLEMENT_STACK_OF(X509_LOOKUP)
567IMPLEMENT_STACK_OF(X509_OBJECT) 716IMPLEMENT_STACK_OF(X509_OBJECT)
diff --git a/src/lib/libcrypto/x509/x509_obj.c b/src/lib/libcrypto/x509/x509_obj.c
index 1e718f76eb..21fed9f838 100644
--- a/src/lib/libcrypto/x509/x509_obj.c
+++ b/src/lib/libcrypto/x509/x509_obj.c
@@ -72,7 +72,7 @@ int i;
72 char *p; 72 char *p;
73 unsigned char *q; 73 unsigned char *q;
74 BUF_MEM *b=NULL; 74 BUF_MEM *b=NULL;
75 static char hex[17]="0123456789ABCDEF"; 75 static const char hex[17]="0123456789ABCDEF";
76 int gs_doit[4]; 76 int gs_doit[4];
77 char tmp_buf[80]; 77 char tmp_buf[80];
78#ifdef CHARSET_EBCDIC 78#ifdef CHARSET_EBCDIC
diff --git a/src/lib/libcrypto/x509/x509_req.c b/src/lib/libcrypto/x509/x509_req.c
index 3872e1fb64..48183dc00c 100644
--- a/src/lib/libcrypto/x509/x509_req.c
+++ b/src/lib/libcrypto/x509/x509_req.c
@@ -61,6 +61,7 @@
61#include <openssl/bn.h> 61#include <openssl/bn.h>
62#include <openssl/evp.h> 62#include <openssl/evp.h>
63#include <openssl/asn1.h> 63#include <openssl/asn1.h>
64#include <openssl/asn1t.h>
64#include <openssl/x509.h> 65#include <openssl/x509.h>
65#include <openssl/objects.h> 66#include <openssl/objects.h>
66#include <openssl/buffer.h> 67#include <openssl/buffer.h>
@@ -205,10 +206,9 @@ STACK_OF(X509_EXTENSION) *X509_REQ_get_extensions(X509_REQ *req)
205 if(!ext || (ext->type != V_ASN1_SEQUENCE)) 206 if(!ext || (ext->type != V_ASN1_SEQUENCE))
206 return NULL; 207 return NULL;
207 p = ext->value.sequence->data; 208 p = ext->value.sequence->data;
208 return d2i_ASN1_SET_OF_X509_EXTENSION(NULL, &p, 209 return (STACK_OF(X509_EXTENSION) *)
209 ext->value.sequence->length, 210 ASN1_item_d2i(NULL, &p, ext->value.sequence->length,
210 d2i_X509_EXTENSION, X509_EXTENSION_free, 211 ASN1_ITEM_rptr(X509_EXTENSIONS));
211 V_ASN1_SEQUENCE, V_ASN1_UNIVERSAL);
212} 212}
213 213
214/* Add a STACK_OF extensions to a certificate request: allow alternative OIDs 214/* Add a STACK_OF extensions to a certificate request: allow alternative OIDs
@@ -218,8 +218,6 @@ STACK_OF(X509_EXTENSION) *X509_REQ_get_extensions(X509_REQ *req)
218int X509_REQ_add_extensions_nid(X509_REQ *req, STACK_OF(X509_EXTENSION) *exts, 218int X509_REQ_add_extensions_nid(X509_REQ *req, STACK_OF(X509_EXTENSION) *exts,
219 int nid) 219 int nid)
220{ 220{
221 unsigned char *p = NULL, *q;
222 long len;
223 ASN1_TYPE *at = NULL; 221 ASN1_TYPE *at = NULL;
224 X509_ATTRIBUTE *attr = NULL; 222 X509_ATTRIBUTE *attr = NULL;
225 if(!(at = ASN1_TYPE_new()) || 223 if(!(at = ASN1_TYPE_new()) ||
@@ -227,15 +225,10 @@ int X509_REQ_add_extensions_nid(X509_REQ *req, STACK_OF(X509_EXTENSION) *exts,
227 225
228 at->type = V_ASN1_SEQUENCE; 226 at->type = V_ASN1_SEQUENCE;
229 /* Generate encoding of extensions */ 227 /* Generate encoding of extensions */
230 len = i2d_ASN1_SET_OF_X509_EXTENSION(exts, NULL, i2d_X509_EXTENSION, 228 at->value.sequence->length =
231 V_ASN1_SEQUENCE, V_ASN1_UNIVERSAL, IS_SEQUENCE); 229 ASN1_item_i2d((ASN1_VALUE *)exts,
232 if(!(p = OPENSSL_malloc(len))) goto err; 230 &at->value.sequence->data,
233 q = p; 231 ASN1_ITEM_rptr(X509_EXTENSIONS));
234 i2d_ASN1_SET_OF_X509_EXTENSION(exts, &q, i2d_X509_EXTENSION,
235 V_ASN1_SEQUENCE, V_ASN1_UNIVERSAL, IS_SEQUENCE);
236 at->value.sequence->data = p;
237 p = NULL;
238 at->value.sequence->length = len;
239 if(!(attr = X509_ATTRIBUTE_new())) goto err; 232 if(!(attr = X509_ATTRIBUTE_new())) goto err;
240 if(!(attr->value.set = sk_ASN1_TYPE_new_null())) goto err; 233 if(!(attr->value.set = sk_ASN1_TYPE_new_null())) goto err;
241 if(!sk_ASN1_TYPE_push(attr->value.set, at)) goto err; 234 if(!sk_ASN1_TYPE_push(attr->value.set, at)) goto err;
@@ -250,7 +243,6 @@ int X509_REQ_add_extensions_nid(X509_REQ *req, STACK_OF(X509_EXTENSION) *exts,
250 if(!sk_X509_ATTRIBUTE_push(req->req_info->attributes, attr)) goto err; 243 if(!sk_X509_ATTRIBUTE_push(req->req_info->attributes, attr)) goto err;
251 return 1; 244 return 1;
252 err: 245 err:
253 if(p) OPENSSL_free(p);
254 X509_ATTRIBUTE_free(attr); 246 X509_ATTRIBUTE_free(attr);
255 ASN1_TYPE_free(at); 247 ASN1_TYPE_free(at);
256 return 0; 248 return 0;
diff --git a/src/lib/libcrypto/x509/x509_set.c b/src/lib/libcrypto/x509/x509_set.c
index aaf61ca062..4b94fc5847 100644
--- a/src/lib/libcrypto/x509/x509_set.c
+++ b/src/lib/libcrypto/x509/x509_set.c
@@ -104,7 +104,7 @@ int X509_set_subject_name(X509 *x, X509_NAME *name)
104 return(X509_NAME_set(&x->cert_info->subject,name)); 104 return(X509_NAME_set(&x->cert_info->subject,name));
105 } 105 }
106 106
107int X509_set_notBefore(X509 *x, ASN1_TIME *tm) 107int X509_set_notBefore(X509 *x, const ASN1_TIME *tm)
108 { 108 {
109 ASN1_TIME *in; 109 ASN1_TIME *in;
110 110
@@ -122,7 +122,7 @@ int X509_set_notBefore(X509 *x, ASN1_TIME *tm)
122 return(in != NULL); 122 return(in != NULL);
123 } 123 }
124 124
125int X509_set_notAfter(X509 *x, ASN1_TIME *tm) 125int X509_set_notAfter(X509 *x, const ASN1_TIME *tm)
126 { 126 {
127 ASN1_TIME *in; 127 ASN1_TIME *in;
128 128
diff --git a/src/lib/libcrypto/x509/x509_trs.c b/src/lib/libcrypto/x509/x509_trs.c
index ed18700585..a6cb9c8b1b 100644
--- a/src/lib/libcrypto/x509/x509_trs.c
+++ b/src/lib/libcrypto/x509/x509_trs.c
@@ -84,7 +84,8 @@ static X509_TRUST trstandard[] = {
84{X509_TRUST_EMAIL, 0, trust_1oidany, "S/MIME email", NID_email_protect, NULL}, 84{X509_TRUST_EMAIL, 0, trust_1oidany, "S/MIME email", NID_email_protect, NULL},
85{X509_TRUST_OBJECT_SIGN, 0, trust_1oidany, "Object Signer", NID_code_sign, NULL}, 85{X509_TRUST_OBJECT_SIGN, 0, trust_1oidany, "Object Signer", NID_code_sign, NULL},
86{X509_TRUST_OCSP_SIGN, 0, trust_1oid, "OCSP responder", NID_OCSP_sign, NULL}, 86{X509_TRUST_OCSP_SIGN, 0, trust_1oid, "OCSP responder", NID_OCSP_sign, NULL},
87{X509_TRUST_OCSP_REQUEST, 0, trust_1oid, "OCSP request", NID_ad_OCSP, NULL} 87{X509_TRUST_OCSP_REQUEST, 0, trust_1oid, "OCSP request", NID_ad_OCSP, NULL},
88{X509_TRUST_TSA, 0, trust_1oidany, "TSA server", NID_time_stamp, NULL}
88}; 89};
89 90
90#define X509_TRUST_COUNT (sizeof(trstandard)/sizeof(X509_TRUST)) 91#define X509_TRUST_COUNT (sizeof(trstandard)/sizeof(X509_TRUST))
diff --git a/src/lib/libcrypto/x509/x509_txt.c b/src/lib/libcrypto/x509/x509_txt.c
index 73a8ec726f..c44f753c46 100644
--- a/src/lib/libcrypto/x509/x509_txt.c
+++ b/src/lib/libcrypto/x509/x509_txt.c
@@ -162,8 +162,28 @@ const char *X509_verify_cert_error_string(long n)
162 return("invalid or inconsistent certificate policy extension"); 162 return("invalid or inconsistent certificate policy extension");
163 case X509_V_ERR_NO_EXPLICIT_POLICY: 163 case X509_V_ERR_NO_EXPLICIT_POLICY:
164 return("no explicit policy"); 164 return("no explicit policy");
165 case X509_V_ERR_UNNESTED_RESOURCE: 165 case X509_V_ERR_DIFFERENT_CRL_SCOPE:
166 return("RFC 3779 resource not subset of parent's resources"); 166 return("Different CRL scope");
167 case X509_V_ERR_UNSUPPORTED_EXTENSION_FEATURE:
168 return("Unsupported extension feature");
169 case X509_V_ERR_UNNESTED_RESOURCE:
170 return("RFC 3779 resource not subset of parent's resources");
171
172 case X509_V_ERR_PERMITTED_VIOLATION:
173 return("permitted subtree violation");
174 case X509_V_ERR_EXCLUDED_VIOLATION:
175 return("excluded subtree violation");
176 case X509_V_ERR_SUBTREE_MINMAX:
177 return("name constraints minimum and maximum not supported");
178 case X509_V_ERR_UNSUPPORTED_CONSTRAINT_TYPE:
179 return("unsupported name constraint type");
180 case X509_V_ERR_UNSUPPORTED_CONSTRAINT_SYNTAX:
181 return("unsupported or invalid name constraint syntax");
182 case X509_V_ERR_UNSUPPORTED_NAME_SYNTAX:
183 return("unsupported or invalid name syntax");
184 case X509_V_ERR_CRL_PATH_VALIDATION_ERROR:
185 return("CRL path validation error");
186
167 default: 187 default:
168 BIO_snprintf(buf,sizeof buf,"error number %ld",n); 188 BIO_snprintf(buf,sizeof buf,"error number %ld",n);
169 return(buf); 189 return(buf);
diff --git a/src/lib/libcrypto/x509/x509_vfy.c b/src/lib/libcrypto/x509/x509_vfy.c
index 336c40ddd7..87ebf62525 100644
--- a/src/lib/libcrypto/x509/x509_vfy.c
+++ b/src/lib/libcrypto/x509/x509_vfy.c
@@ -70,14 +70,70 @@
70#include <openssl/x509v3.h> 70#include <openssl/x509v3.h>
71#include <openssl/objects.h> 71#include <openssl/objects.h>
72 72
73/* CRL score values */
74
75/* No unhandled critical extensions */
76
77#define CRL_SCORE_NOCRITICAL 0x100
78
79/* certificate is within CRL scope */
80
81#define CRL_SCORE_SCOPE 0x080
82
83/* CRL times valid */
84
85#define CRL_SCORE_TIME 0x040
86
87/* Issuer name matches certificate */
88
89#define CRL_SCORE_ISSUER_NAME 0x020
90
91/* If this score or above CRL is probably valid */
92
93#define CRL_SCORE_VALID (CRL_SCORE_NOCRITICAL|CRL_SCORE_TIME|CRL_SCORE_SCOPE)
94
95/* CRL issuer is certificate issuer */
96
97#define CRL_SCORE_ISSUER_CERT 0x018
98
99/* CRL issuer is on certificate path */
100
101#define CRL_SCORE_SAME_PATH 0x008
102
103/* CRL issuer matches CRL AKID */
104
105#define CRL_SCORE_AKID 0x004
106
107/* Have a delta CRL with valid times */
108
109#define CRL_SCORE_TIME_DELTA 0x002
110
73static int null_callback(int ok,X509_STORE_CTX *e); 111static int null_callback(int ok,X509_STORE_CTX *e);
74static int check_issued(X509_STORE_CTX *ctx, X509 *x, X509 *issuer); 112static int check_issued(X509_STORE_CTX *ctx, X509 *x, X509 *issuer);
75static X509 *find_issuer(X509_STORE_CTX *ctx, STACK_OF(X509) *sk, X509 *x); 113static X509 *find_issuer(X509_STORE_CTX *ctx, STACK_OF(X509) *sk, X509 *x);
76static int check_chain_extensions(X509_STORE_CTX *ctx); 114static int check_chain_extensions(X509_STORE_CTX *ctx);
115static int check_name_constraints(X509_STORE_CTX *ctx);
77static int check_trust(X509_STORE_CTX *ctx); 116static int check_trust(X509_STORE_CTX *ctx);
78static int check_revocation(X509_STORE_CTX *ctx); 117static int check_revocation(X509_STORE_CTX *ctx);
79static int check_cert(X509_STORE_CTX *ctx); 118static int check_cert(X509_STORE_CTX *ctx);
80static int check_policy(X509_STORE_CTX *ctx); 119static int check_policy(X509_STORE_CTX *ctx);
120
121static int get_crl_score(X509_STORE_CTX *ctx, X509 **pissuer,
122 unsigned int *preasons,
123 X509_CRL *crl, X509 *x);
124static int get_crl_delta(X509_STORE_CTX *ctx,
125 X509_CRL **pcrl, X509_CRL **pdcrl, X509 *x);
126static void get_delta_sk(X509_STORE_CTX *ctx, X509_CRL **dcrl, int *pcrl_score,
127 X509_CRL *base, STACK_OF(X509_CRL) *crls);
128static void crl_akid_check(X509_STORE_CTX *ctx, X509_CRL *crl,
129 X509 **pissuer, int *pcrl_score);
130static int crl_crldp_check(X509 *x, X509_CRL *crl, int crl_score,
131 unsigned int *preasons);
132static int check_crl_path(X509_STORE_CTX *ctx, X509 *x);
133static int check_crl_chain(X509_STORE_CTX *ctx,
134 STACK_OF(X509) *cert_path,
135 STACK_OF(X509) *crl_path);
136
81static int internal_verify(X509_STORE_CTX *ctx); 137static int internal_verify(X509_STORE_CTX *ctx);
82const char X509_version[]="X.509" OPENSSL_VERSION_PTEXT; 138const char X509_version[]="X.509" OPENSSL_VERSION_PTEXT;
83 139
@@ -289,6 +345,12 @@ int X509_verify_cert(X509_STORE_CTX *ctx)
289 345
290 if (!ok) goto end; 346 if (!ok) goto end;
291 347
348 /* Check name constraints */
349
350 ok = check_name_constraints(ctx);
351
352 if (!ok) goto end;
353
292 /* The chain extensions are OK: check trust */ 354 /* The chain extensions are OK: check trust */
293 355
294 if (param->trust > 0) ok = check_trust(ctx); 356 if (param->trust > 0) ok = check_trust(ctx);
@@ -398,8 +460,8 @@ static int check_chain_extensions(X509_STORE_CTX *ctx)
398 X509 *x; 460 X509 *x;
399 int (*cb)(int xok,X509_STORE_CTX *xctx); 461 int (*cb)(int xok,X509_STORE_CTX *xctx);
400 int proxy_path_length = 0; 462 int proxy_path_length = 0;
401 int allow_proxy_certs = 463 int purpose;
402 !!(ctx->param->flags & X509_V_FLAG_ALLOW_PROXY_CERTS); 464 int allow_proxy_certs;
403 cb=ctx->verify_cb; 465 cb=ctx->verify_cb;
404 466
405 /* must_be_ca can have 1 of 3 values: 467 /* must_be_ca can have 1 of 3 values:
@@ -412,10 +474,22 @@ static int check_chain_extensions(X509_STORE_CTX *ctx)
412 */ 474 */
413 must_be_ca = -1; 475 must_be_ca = -1;
414 476
415 /* A hack to keep people who don't want to modify their software 477 /* CRL path validation */
416 happy */ 478 if (ctx->parent)
417 if (getenv("OPENSSL_ALLOW_PROXY_CERTS")) 479 {
418 allow_proxy_certs = 1; 480 allow_proxy_certs = 0;
481 purpose = X509_PURPOSE_CRL_SIGN;
482 }
483 else
484 {
485 allow_proxy_certs =
486 !!(ctx->param->flags & X509_V_FLAG_ALLOW_PROXY_CERTS);
487 /* A hack to keep people who don't want to modify their
488 software happy */
489 if (getenv("OPENSSL_ALLOW_PROXY_CERTS"))
490 allow_proxy_certs = 1;
491 purpose = ctx->param->purpose;
492 }
419 493
420 /* Check all untrusted certificates */ 494 /* Check all untrusted certificates */
421 for (i = 0; i < ctx->last_untrusted; i++) 495 for (i = 0; i < ctx->last_untrusted; i++)
@@ -482,8 +556,7 @@ static int check_chain_extensions(X509_STORE_CTX *ctx)
482 } 556 }
483 if (ctx->param->purpose > 0) 557 if (ctx->param->purpose > 0)
484 { 558 {
485 ret = X509_check_purpose(x, ctx->param->purpose, 559 ret = X509_check_purpose(x, purpose, must_be_ca > 0);
486 must_be_ca > 0);
487 if ((ret == 0) 560 if ((ret == 0)
488 || ((ctx->param->flags & X509_V_FLAG_X509_STRICT) 561 || ((ctx->param->flags & X509_V_FLAG_X509_STRICT)
489 && (ret != 1))) 562 && (ret != 1)))
@@ -536,6 +609,42 @@ static int check_chain_extensions(X509_STORE_CTX *ctx)
536#endif 609#endif
537} 610}
538 611
612static int check_name_constraints(X509_STORE_CTX *ctx)
613 {
614 X509 *x;
615 int i, j, rv;
616 /* Check name constraints for all certificates */
617 for (i = sk_X509_num(ctx->chain) - 1; i >= 0; i--)
618 {
619 x = sk_X509_value(ctx->chain, i);
620 /* Ignore self issued certs unless last in chain */
621 if (i && (x->ex_flags & EXFLAG_SI))
622 continue;
623 /* Check against constraints for all certificates higher in
624 * chain including trust anchor. Trust anchor not strictly
625 * speaking needed but if it includes constraints it is to be
626 * assumed it expects them to be obeyed.
627 */
628 for (j = sk_X509_num(ctx->chain) - 1; j > i; j--)
629 {
630 NAME_CONSTRAINTS *nc = sk_X509_value(ctx->chain, j)->nc;
631 if (nc)
632 {
633 rv = NAME_CONSTRAINTS_check(x, nc);
634 if (rv != X509_V_OK)
635 {
636 ctx->error = rv;
637 ctx->error_depth = i;
638 ctx->current_cert = x;
639 if (!ctx->verify_cb(0,ctx))
640 return 0;
641 }
642 }
643 }
644 }
645 return 1;
646 }
647
539static int check_trust(X509_STORE_CTX *ctx) 648static int check_trust(X509_STORE_CTX *ctx)
540{ 649{
541#ifdef OPENSSL_NO_CHAIN_VERIFY 650#ifdef OPENSSL_NO_CHAIN_VERIFY
@@ -570,7 +679,12 @@ static int check_revocation(X509_STORE_CTX *ctx)
570 if (ctx->param->flags & X509_V_FLAG_CRL_CHECK_ALL) 679 if (ctx->param->flags & X509_V_FLAG_CRL_CHECK_ALL)
571 last = sk_X509_num(ctx->chain) - 1; 680 last = sk_X509_num(ctx->chain) - 1;
572 else 681 else
682 {
683 /* If checking CRL paths this isn't the EE certificate */
684 if (ctx->parent)
685 return 1;
573 last = 0; 686 last = 0;
687 }
574 for(i = 0; i <= last; i++) 688 for(i = 0; i <= last; i++)
575 { 689 {
576 ctx->error_depth = i; 690 ctx->error_depth = i;
@@ -582,30 +696,65 @@ static int check_revocation(X509_STORE_CTX *ctx)
582 696
583static int check_cert(X509_STORE_CTX *ctx) 697static int check_cert(X509_STORE_CTX *ctx)
584 { 698 {
585 X509_CRL *crl = NULL; 699 X509_CRL *crl = NULL, *dcrl = NULL;
586 X509 *x; 700 X509 *x;
587 int ok, cnum; 701 int ok, cnum;
588 cnum = ctx->error_depth; 702 cnum = ctx->error_depth;
589 x = sk_X509_value(ctx->chain, cnum); 703 x = sk_X509_value(ctx->chain, cnum);
590 ctx->current_cert = x; 704 ctx->current_cert = x;
591 /* Try to retrieve relevant CRL */ 705 ctx->current_issuer = NULL;
592 ok = ctx->get_crl(ctx, &crl, x); 706 ctx->current_reasons = 0;
593 /* If error looking up CRL, nothing we can do except 707 while (ctx->current_reasons != CRLDP_ALL_REASONS)
594 * notify callback
595 */
596 if(!ok)
597 { 708 {
598 ctx->error = X509_V_ERR_UNABLE_TO_GET_CRL; 709 /* Try to retrieve relevant CRL */
599 ok = ctx->verify_cb(0, ctx); 710 if (ctx->get_crl)
600 goto err; 711 ok = ctx->get_crl(ctx, &crl, x);
712 else
713 ok = get_crl_delta(ctx, &crl, &dcrl, x);
714 /* If error looking up CRL, nothing we can do except
715 * notify callback
716 */
717 if(!ok)
718 {
719 ctx->error = X509_V_ERR_UNABLE_TO_GET_CRL;
720 ok = ctx->verify_cb(0, ctx);
721 goto err;
722 }
723 ctx->current_crl = crl;
724 ok = ctx->check_crl(ctx, crl);
725 if (!ok)
726 goto err;
727
728 if (dcrl)
729 {
730 ok = ctx->check_crl(ctx, dcrl);
731 if (!ok)
732 goto err;
733 ok = ctx->cert_crl(ctx, dcrl, x);
734 if (!ok)
735 goto err;
736 }
737 else
738 ok = 1;
739
740 /* Don't look in full CRL if delta reason is removefromCRL */
741 if (ok != 2)
742 {
743 ok = ctx->cert_crl(ctx, crl, x);
744 if (!ok)
745 goto err;
746 }
747
748 X509_CRL_free(crl);
749 X509_CRL_free(dcrl);
750 crl = NULL;
751 dcrl = NULL;
601 } 752 }
602 ctx->current_crl = crl;
603 ok = ctx->check_crl(ctx, crl);
604 if (!ok) goto err;
605 ok = ctx->cert_crl(ctx, crl, x);
606 err: 753 err:
607 ctx->current_crl = NULL;
608 X509_CRL_free(crl); 754 X509_CRL_free(crl);
755 X509_CRL_free(dcrl);
756
757 ctx->current_crl = NULL;
609 return ok; 758 return ok;
610 759
611 } 760 }
@@ -616,7 +765,8 @@ static int check_crl_time(X509_STORE_CTX *ctx, X509_CRL *crl, int notify)
616 { 765 {
617 time_t *ptime; 766 time_t *ptime;
618 int i; 767 int i;
619 ctx->current_crl = crl; 768 if (notify)
769 ctx->current_crl = crl;
620 if (ctx->param->flags & X509_V_FLAG_USE_CHECK_TIME) 770 if (ctx->param->flags & X509_V_FLAG_USE_CHECK_TIME)
621 ptime = &ctx->param->check_time; 771 ptime = &ctx->param->check_time;
622 else 772 else
@@ -625,15 +775,19 @@ static int check_crl_time(X509_STORE_CTX *ctx, X509_CRL *crl, int notify)
625 i=X509_cmp_time(X509_CRL_get_lastUpdate(crl), ptime); 775 i=X509_cmp_time(X509_CRL_get_lastUpdate(crl), ptime);
626 if (i == 0) 776 if (i == 0)
627 { 777 {
778 if (!notify)
779 return 0;
628 ctx->error=X509_V_ERR_ERROR_IN_CRL_LAST_UPDATE_FIELD; 780 ctx->error=X509_V_ERR_ERROR_IN_CRL_LAST_UPDATE_FIELD;
629 if (!notify || !ctx->verify_cb(0, ctx)) 781 if (!ctx->verify_cb(0, ctx))
630 return 0; 782 return 0;
631 } 783 }
632 784
633 if (i > 0) 785 if (i > 0)
634 { 786 {
787 if (!notify)
788 return 0;
635 ctx->error=X509_V_ERR_CRL_NOT_YET_VALID; 789 ctx->error=X509_V_ERR_CRL_NOT_YET_VALID;
636 if (!notify || !ctx->verify_cb(0, ctx)) 790 if (!ctx->verify_cb(0, ctx))
637 return 0; 791 return 0;
638 } 792 }
639 793
@@ -643,92 +797,545 @@ static int check_crl_time(X509_STORE_CTX *ctx, X509_CRL *crl, int notify)
643 797
644 if (i == 0) 798 if (i == 0)
645 { 799 {
800 if (!notify)
801 return 0;
646 ctx->error=X509_V_ERR_ERROR_IN_CRL_NEXT_UPDATE_FIELD; 802 ctx->error=X509_V_ERR_ERROR_IN_CRL_NEXT_UPDATE_FIELD;
647 if (!notify || !ctx->verify_cb(0, ctx)) 803 if (!ctx->verify_cb(0, ctx))
648 return 0; 804 return 0;
649 } 805 }
650 806 /* Ignore expiry of base CRL is delta is valid */
651 if (i < 0) 807 if ((i < 0) && !(ctx->current_crl_score & CRL_SCORE_TIME_DELTA))
652 { 808 {
809 if (!notify)
810 return 0;
653 ctx->error=X509_V_ERR_CRL_HAS_EXPIRED; 811 ctx->error=X509_V_ERR_CRL_HAS_EXPIRED;
654 if (!notify || !ctx->verify_cb(0, ctx)) 812 if (!ctx->verify_cb(0, ctx))
655 return 0; 813 return 0;
656 } 814 }
657 } 815 }
658 816
659 ctx->current_crl = NULL; 817 if (notify)
818 ctx->current_crl = NULL;
660 819
661 return 1; 820 return 1;
662 } 821 }
663 822
664/* Lookup CRLs from the supplied list. Look for matching isser name 823static int get_crl_sk(X509_STORE_CTX *ctx, X509_CRL **pcrl, X509_CRL **pdcrl,
665 * and validity. If we can't find a valid CRL return the last one 824 X509 **pissuer, int *pscore, unsigned int *preasons,
666 * with matching name. This gives more meaningful error codes. Otherwise 825 STACK_OF(X509_CRL) *crls)
667 * we'd get a CRL not found error if a CRL existed with matching name but
668 * was invalid.
669 */
670
671static int get_crl_sk(X509_STORE_CTX *ctx, X509_CRL **pcrl,
672 X509_NAME *nm, STACK_OF(X509_CRL) *crls)
673 { 826 {
674 int i; 827 int i, crl_score, best_score = *pscore;
828 unsigned int reasons, best_reasons = 0;
829 X509 *x = ctx->current_cert;
675 X509_CRL *crl, *best_crl = NULL; 830 X509_CRL *crl, *best_crl = NULL;
831 X509 *crl_issuer = NULL, *best_crl_issuer = NULL;
832
676 for (i = 0; i < sk_X509_CRL_num(crls); i++) 833 for (i = 0; i < sk_X509_CRL_num(crls); i++)
677 { 834 {
678 crl = sk_X509_CRL_value(crls, i); 835 crl = sk_X509_CRL_value(crls, i);
679 if (X509_NAME_cmp(nm, X509_CRL_get_issuer(crl))) 836 reasons = *preasons;
680 continue; 837 crl_score = get_crl_score(ctx, &crl_issuer, &reasons, crl, x);
681 if (check_crl_time(ctx, crl, 0)) 838
839 if (crl_score > best_score)
682 { 840 {
683 *pcrl = crl; 841 best_crl = crl;
684 CRYPTO_add(&crl->references, 1, CRYPTO_LOCK_X509); 842 best_crl_issuer = crl_issuer;
685 return 1; 843 best_score = crl_score;
844 best_reasons = reasons;
686 } 845 }
687 best_crl = crl;
688 } 846 }
847
689 if (best_crl) 848 if (best_crl)
690 { 849 {
850 if (*pcrl)
851 X509_CRL_free(*pcrl);
691 *pcrl = best_crl; 852 *pcrl = best_crl;
692 CRYPTO_add(&best_crl->references, 1, CRYPTO_LOCK_X509); 853 *pissuer = best_crl_issuer;
854 *pscore = best_score;
855 *preasons = best_reasons;
856 CRYPTO_add(&best_crl->references, 1, CRYPTO_LOCK_X509_CRL);
857 if (*pdcrl)
858 {
859 X509_CRL_free(*pdcrl);
860 *pdcrl = NULL;
861 }
862 get_delta_sk(ctx, pdcrl, pscore, best_crl, crls);
693 } 863 }
694 864
865 if (best_score >= CRL_SCORE_VALID)
866 return 1;
867
695 return 0; 868 return 0;
696 } 869 }
697 870
698/* Retrieve CRL corresponding to certificate: currently just a 871/* Compare two CRL extensions for delta checking purposes. They should be
699 * subject lookup: maybe use AKID later... 872 * both present or both absent. If both present all fields must be identical.
700 */ 873 */
701static int get_crl(X509_STORE_CTX *ctx, X509_CRL **pcrl, X509 *x) 874
875static int crl_extension_match(X509_CRL *a, X509_CRL *b, int nid)
702 { 876 {
703 int ok; 877 ASN1_OCTET_STRING *exta, *extb;
704 X509_CRL *crl = NULL; 878 int i;
705 X509_OBJECT xobj; 879 i = X509_CRL_get_ext_by_NID(a, nid, 0);
706 X509_NAME *nm; 880 if (i >= 0)
707 nm = X509_get_issuer_name(x);
708 ok = get_crl_sk(ctx, &crl, nm, ctx->crls);
709 if (ok)
710 { 881 {
711 *pcrl = crl; 882 /* Can't have multiple occurrences */
883 if (X509_CRL_get_ext_by_NID(a, nid, i) != -1)
884 return 0;
885 exta = X509_EXTENSION_get_data(X509_CRL_get_ext(a, i));
886 }
887 else
888 exta = NULL;
889
890 i = X509_CRL_get_ext_by_NID(b, nid, 0);
891
892 if (i >= 0)
893 {
894
895 if (X509_CRL_get_ext_by_NID(b, nid, i) != -1)
896 return 0;
897 extb = X509_EXTENSION_get_data(X509_CRL_get_ext(b, i));
898 }
899 else
900 extb = NULL;
901
902 if (!exta && !extb)
712 return 1; 903 return 1;
904
905 if (!exta || !extb)
906 return 0;
907
908
909 if (ASN1_OCTET_STRING_cmp(exta, extb))
910 return 0;
911
912 return 1;
913 }
914
915/* See if a base and delta are compatible */
916
917static int check_delta_base(X509_CRL *delta, X509_CRL *base)
918 {
919 /* Delta CRL must be a delta */
920 if (!delta->base_crl_number)
921 return 0;
922 /* Base must have a CRL number */
923 if (!base->crl_number)
924 return 0;
925 /* Issuer names must match */
926 if (X509_NAME_cmp(X509_CRL_get_issuer(base),
927 X509_CRL_get_issuer(delta)))
928 return 0;
929 /* AKID and IDP must match */
930 if (!crl_extension_match(delta, base, NID_authority_key_identifier))
931 return 0;
932 if (!crl_extension_match(delta, base, NID_issuing_distribution_point))
933 return 0;
934 /* Delta CRL base number must not exceed Full CRL number. */
935 if (ASN1_INTEGER_cmp(delta->base_crl_number, base->crl_number) > 0)
936 return 0;
937 /* Delta CRL number must exceed full CRL number */
938 if (ASN1_INTEGER_cmp(delta->crl_number, base->crl_number) > 0)
939 return 1;
940 return 0;
941 }
942
943/* For a given base CRL find a delta... maybe extend to delta scoring
944 * or retrieve a chain of deltas...
945 */
946
947static void get_delta_sk(X509_STORE_CTX *ctx, X509_CRL **dcrl, int *pscore,
948 X509_CRL *base, STACK_OF(X509_CRL) *crls)
949 {
950 X509_CRL *delta;
951 int i;
952 if (!(ctx->param->flags & X509_V_FLAG_USE_DELTAS))
953 return;
954 if (!((ctx->current_cert->ex_flags | base->flags) & EXFLAG_FRESHEST))
955 return;
956 for (i = 0; i < sk_X509_CRL_num(crls); i++)
957 {
958 delta = sk_X509_CRL_value(crls, i);
959 if (check_delta_base(delta, base))
960 {
961 if (check_crl_time(ctx, delta, 0))
962 *pscore |= CRL_SCORE_TIME_DELTA;
963 CRYPTO_add(&delta->references, 1, CRYPTO_LOCK_X509_CRL);
964 *dcrl = delta;
965 return;
966 }
967 }
968 *dcrl = NULL;
969 }
970
971/* For a given CRL return how suitable it is for the supplied certificate 'x'.
972 * The return value is a mask of several criteria.
973 * If the issuer is not the certificate issuer this is returned in *pissuer.
974 * The reasons mask is also used to determine if the CRL is suitable: if
975 * no new reasons the CRL is rejected, otherwise reasons is updated.
976 */
977
978static int get_crl_score(X509_STORE_CTX *ctx, X509 **pissuer,
979 unsigned int *preasons,
980 X509_CRL *crl, X509 *x)
981 {
982
983 int crl_score = 0;
984 unsigned int tmp_reasons = *preasons, crl_reasons;
985
986 /* First see if we can reject CRL straight away */
987
988 /* Invalid IDP cannot be processed */
989 if (crl->idp_flags & IDP_INVALID)
990 return 0;
991 /* Reason codes or indirect CRLs need extended CRL support */
992 if (!(ctx->param->flags & X509_V_FLAG_EXTENDED_CRL_SUPPORT))
993 {
994 if (crl->idp_flags & (IDP_INDIRECT | IDP_REASONS))
995 return 0;
996 }
997 else if (crl->idp_flags & IDP_REASONS)
998 {
999 /* If no new reasons reject */
1000 if (!(crl->idp_reasons & ~tmp_reasons))
1001 return 0;
1002 }
1003 /* Don't process deltas at this stage */
1004 else if (crl->base_crl_number)
1005 return 0;
1006 /* If issuer name doesn't match certificate need indirect CRL */
1007 if (X509_NAME_cmp(X509_get_issuer_name(x), X509_CRL_get_issuer(crl)))
1008 {
1009 if (!(crl->idp_flags & IDP_INDIRECT))
1010 return 0;
1011 }
1012 else
1013 crl_score |= CRL_SCORE_ISSUER_NAME;
1014
1015 if (!(crl->flags & EXFLAG_CRITICAL))
1016 crl_score |= CRL_SCORE_NOCRITICAL;
1017
1018 /* Check expiry */
1019 if (check_crl_time(ctx, crl, 0))
1020 crl_score |= CRL_SCORE_TIME;
1021
1022 /* Check authority key ID and locate certificate issuer */
1023 crl_akid_check(ctx, crl, pissuer, &crl_score);
1024
1025 /* If we can't locate certificate issuer at this point forget it */
1026
1027 if (!(crl_score & CRL_SCORE_AKID))
1028 return 0;
1029
1030 /* Check cert for matching CRL distribution points */
1031
1032 if (crl_crldp_check(x, crl, crl_score, &crl_reasons))
1033 {
1034 /* If no new reasons reject */
1035 if (!(crl_reasons & ~tmp_reasons))
1036 return 0;
1037 tmp_reasons |= crl_reasons;
1038 crl_score |= CRL_SCORE_SCOPE;
713 } 1039 }
714 1040
715 ok = X509_STORE_get_by_subject(ctx, X509_LU_CRL, nm, &xobj); 1041 *preasons = tmp_reasons;
1042
1043 return crl_score;
1044
1045 }
1046
1047static void crl_akid_check(X509_STORE_CTX *ctx, X509_CRL *crl,
1048 X509 **pissuer, int *pcrl_score)
1049 {
1050 X509 *crl_issuer = NULL;
1051 X509_NAME *cnm = X509_CRL_get_issuer(crl);
1052 int cidx = ctx->error_depth;
1053 int i;
716 1054
717 if (!ok) 1055 if (cidx != sk_X509_num(ctx->chain) - 1)
1056 cidx++;
1057
1058 crl_issuer = sk_X509_value(ctx->chain, cidx);
1059
1060 if (X509_check_akid(crl_issuer, crl->akid) == X509_V_OK)
718 { 1061 {
719 /* If we got a near match from get_crl_sk use that */ 1062 if (*pcrl_score & CRL_SCORE_ISSUER_NAME)
720 if (crl)
721 { 1063 {
722 *pcrl = crl; 1064 *pcrl_score |= CRL_SCORE_AKID|CRL_SCORE_ISSUER_CERT;
723 return 1; 1065 *pissuer = crl_issuer;
1066 return;
1067 }
1068 }
1069
1070 for (cidx++; cidx < sk_X509_num(ctx->chain); cidx++)
1071 {
1072 crl_issuer = sk_X509_value(ctx->chain, cidx);
1073 if (X509_NAME_cmp(X509_get_subject_name(crl_issuer), cnm))
1074 continue;
1075 if (X509_check_akid(crl_issuer, crl->akid) == X509_V_OK)
1076 {
1077 *pcrl_score |= CRL_SCORE_AKID|CRL_SCORE_SAME_PATH;
1078 *pissuer = crl_issuer;
1079 return;
1080 }
1081 }
1082
1083 /* Anything else needs extended CRL support */
1084
1085 if (!(ctx->param->flags & X509_V_FLAG_EXTENDED_CRL_SUPPORT))
1086 return;
1087
1088 /* Otherwise the CRL issuer is not on the path. Look for it in the
1089 * set of untrusted certificates.
1090 */
1091 for (i = 0; i < sk_X509_num(ctx->untrusted); i++)
1092 {
1093 crl_issuer = sk_X509_value(ctx->untrusted, i);
1094 if (X509_NAME_cmp(X509_get_subject_name(crl_issuer), cnm))
1095 continue;
1096 if (X509_check_akid(crl_issuer, crl->akid) == X509_V_OK)
1097 {
1098 *pissuer = crl_issuer;
1099 *pcrl_score |= CRL_SCORE_AKID;
1100 return;
724 } 1101 }
1102 }
1103 }
1104
1105/* Check the path of a CRL issuer certificate. This creates a new
1106 * X509_STORE_CTX and populates it with most of the parameters from the
1107 * parent. This could be optimised somewhat since a lot of path checking
1108 * will be duplicated by the parent, but this will rarely be used in
1109 * practice.
1110 */
1111
1112static int check_crl_path(X509_STORE_CTX *ctx, X509 *x)
1113 {
1114 X509_STORE_CTX crl_ctx;
1115 int ret;
1116 /* Don't allow recursive CRL path validation */
1117 if (ctx->parent)
725 return 0; 1118 return 0;
1119 if (!X509_STORE_CTX_init(&crl_ctx, ctx->ctx, x, ctx->untrusted))
1120 return -1;
1121
1122 crl_ctx.crls = ctx->crls;
1123 /* Copy verify params across */
1124 X509_STORE_CTX_set0_param(&crl_ctx, ctx->param);
1125
1126 crl_ctx.parent = ctx;
1127 crl_ctx.verify_cb = ctx->verify_cb;
1128
1129 /* Verify CRL issuer */
1130 ret = X509_verify_cert(&crl_ctx);
1131
1132 if (ret <= 0)
1133 goto err;
1134
1135 /* Check chain is acceptable */
1136
1137 ret = check_crl_chain(ctx, ctx->chain, crl_ctx.chain);
1138 err:
1139 X509_STORE_CTX_cleanup(&crl_ctx);
1140 return ret;
1141 }
1142
1143/* RFC3280 says nothing about the relationship between CRL path
1144 * and certificate path, which could lead to situations where a
1145 * certificate could be revoked or validated by a CA not authorised
1146 * to do so. RFC5280 is more strict and states that the two paths must
1147 * end in the same trust anchor, though some discussions remain...
1148 * until this is resolved we use the RFC5280 version
1149 */
1150
1151static int check_crl_chain(X509_STORE_CTX *ctx,
1152 STACK_OF(X509) *cert_path,
1153 STACK_OF(X509) *crl_path)
1154 {
1155 X509 *cert_ta, *crl_ta;
1156 cert_ta = sk_X509_value(cert_path, sk_X509_num(cert_path) - 1);
1157 crl_ta = sk_X509_value(crl_path, sk_X509_num(crl_path) - 1);
1158 if (!X509_cmp(cert_ta, crl_ta))
1159 return 1;
1160 return 0;
1161 }
1162
1163/* Check for match between two dist point names: three separate cases.
1164 * 1. Both are relative names and compare X509_NAME types.
1165 * 2. One full, one relative. Compare X509_NAME to GENERAL_NAMES.
1166 * 3. Both are full names and compare two GENERAL_NAMES.
1167 * 4. One is NULL: automatic match.
1168 */
1169
1170
1171static int idp_check_dp(DIST_POINT_NAME *a, DIST_POINT_NAME *b)
1172 {
1173 X509_NAME *nm = NULL;
1174 GENERAL_NAMES *gens = NULL;
1175 GENERAL_NAME *gena, *genb;
1176 int i, j;
1177 if (!a || !b)
1178 return 1;
1179 if (a->type == 1)
1180 {
1181 if (!a->dpname)
1182 return 0;
1183 /* Case 1: two X509_NAME */
1184 if (b->type == 1)
1185 {
1186 if (!b->dpname)
1187 return 0;
1188 if (!X509_NAME_cmp(a->dpname, b->dpname))
1189 return 1;
1190 else
1191 return 0;
1192 }
1193 /* Case 2: set name and GENERAL_NAMES appropriately */
1194 nm = a->dpname;
1195 gens = b->name.fullname;
1196 }
1197 else if (b->type == 1)
1198 {
1199 if (!b->dpname)
1200 return 0;
1201 /* Case 2: set name and GENERAL_NAMES appropriately */
1202 gens = a->name.fullname;
1203 nm = b->dpname;
726 } 1204 }
727 1205
728 *pcrl = xobj.data.crl; 1206 /* Handle case 2 with one GENERAL_NAMES and one X509_NAME */
1207 if (nm)
1208 {
1209 for (i = 0; i < sk_GENERAL_NAME_num(gens); i++)
1210 {
1211 gena = sk_GENERAL_NAME_value(gens, i);
1212 if (gena->type != GEN_DIRNAME)
1213 continue;
1214 if (!X509_NAME_cmp(nm, gena->d.directoryName))
1215 return 1;
1216 }
1217 return 0;
1218 }
1219
1220 /* Else case 3: two GENERAL_NAMES */
1221
1222 for (i = 0; i < sk_GENERAL_NAME_num(a->name.fullname); i++)
1223 {
1224 gena = sk_GENERAL_NAME_value(a->name.fullname, i);
1225 for (j = 0; j < sk_GENERAL_NAME_num(b->name.fullname); j++)
1226 {
1227 genb = sk_GENERAL_NAME_value(b->name.fullname, j);
1228 if (!GENERAL_NAME_cmp(gena, genb))
1229 return 1;
1230 }
1231 }
1232
1233 return 0;
1234
1235 }
1236
1237static int crldp_check_crlissuer(DIST_POINT *dp, X509_CRL *crl, int crl_score)
1238 {
1239 int i;
1240 X509_NAME *nm = X509_CRL_get_issuer(crl);
1241 /* If no CRLissuer return is successful iff don't need a match */
1242 if (!dp->CRLissuer)
1243 return !!(crl_score & CRL_SCORE_ISSUER_NAME);
1244 for (i = 0; i < sk_GENERAL_NAME_num(dp->CRLissuer); i++)
1245 {
1246 GENERAL_NAME *gen = sk_GENERAL_NAME_value(dp->CRLissuer, i);
1247 if (gen->type != GEN_DIRNAME)
1248 continue;
1249 if (!X509_NAME_cmp(gen->d.directoryName, nm))
1250 return 1;
1251 }
1252 return 0;
1253 }
1254
1255/* Check CRLDP and IDP */
1256
1257static int crl_crldp_check(X509 *x, X509_CRL *crl, int crl_score,
1258 unsigned int *preasons)
1259 {
1260 int i;
1261 if (crl->idp_flags & IDP_ONLYATTR)
1262 return 0;
1263 if (x->ex_flags & EXFLAG_CA)
1264 {
1265 if (crl->idp_flags & IDP_ONLYUSER)
1266 return 0;
1267 }
1268 else
1269 {
1270 if (crl->idp_flags & IDP_ONLYCA)
1271 return 0;
1272 }
1273 *preasons = crl->idp_reasons;
1274 for (i = 0; i < sk_DIST_POINT_num(x->crldp); i++)
1275 {
1276 DIST_POINT *dp = sk_DIST_POINT_value(x->crldp, i);
1277 if (crldp_check_crlissuer(dp, crl, crl_score))
1278 {
1279 if (!crl->idp ||
1280 idp_check_dp(dp->distpoint, crl->idp->distpoint))
1281 {
1282 *preasons &= dp->dp_reasons;
1283 return 1;
1284 }
1285 }
1286 }
1287 if ((!crl->idp || !crl->idp->distpoint) && (crl_score & CRL_SCORE_ISSUER_NAME))
1288 return 1;
1289 return 0;
1290 }
1291
1292/* Retrieve CRL corresponding to current certificate.
1293 * If deltas enabled try to find a delta CRL too
1294 */
1295
1296static int get_crl_delta(X509_STORE_CTX *ctx,
1297 X509_CRL **pcrl, X509_CRL **pdcrl, X509 *x)
1298 {
1299 int ok;
1300 X509 *issuer = NULL;
1301 int crl_score = 0;
1302 unsigned int reasons;
1303 X509_CRL *crl = NULL, *dcrl = NULL;
1304 STACK_OF(X509_CRL) *skcrl;
1305 X509_NAME *nm = X509_get_issuer_name(x);
1306 reasons = ctx->current_reasons;
1307 ok = get_crl_sk(ctx, &crl, &dcrl,
1308 &issuer, &crl_score, &reasons, ctx->crls);
1309
1310 if (ok)
1311 goto done;
1312
1313 /* Lookup CRLs from store */
1314
1315 skcrl = ctx->lookup_crls(ctx, nm);
1316
1317 /* If no CRLs found and a near match from get_crl_sk use that */
1318 if (!skcrl && crl)
1319 goto done;
1320
1321 get_crl_sk(ctx, &crl, &dcrl, &issuer, &crl_score, &reasons, skcrl);
1322
1323 sk_X509_CRL_pop_free(skcrl, X509_CRL_free);
1324
1325 done:
1326
1327 /* If we got any kind of CRL use it and return success */
729 if (crl) 1328 if (crl)
730 X509_CRL_free(crl); 1329 {
731 return 1; 1330 ctx->current_issuer = issuer;
1331 ctx->current_crl_score = crl_score;
1332 ctx->current_reasons = reasons;
1333 *pcrl = crl;
1334 *pdcrl = dcrl;
1335 return 1;
1336 }
1337
1338 return 0;
732 } 1339 }
733 1340
734/* Check CRL validity */ 1341/* Check CRL validity */
@@ -739,10 +1346,14 @@ static int check_crl(X509_STORE_CTX *ctx, X509_CRL *crl)
739 int ok = 0, chnum, cnum; 1346 int ok = 0, chnum, cnum;
740 cnum = ctx->error_depth; 1347 cnum = ctx->error_depth;
741 chnum = sk_X509_num(ctx->chain) - 1; 1348 chnum = sk_X509_num(ctx->chain) - 1;
742 /* Find CRL issuer: if not last certificate then issuer 1349 /* if we have an alternative CRL issuer cert use that */
1350 if (ctx->current_issuer)
1351 issuer = ctx->current_issuer;
1352
1353 /* Else find CRL issuer: if not last certificate then issuer
743 * is next certificate in chain. 1354 * is next certificate in chain.
744 */ 1355 */
745 if(cnum < chnum) 1356 else if (cnum < chnum)
746 issuer = sk_X509_value(ctx->chain, cnum + 1); 1357 issuer = sk_X509_value(ctx->chain, cnum + 1);
747 else 1358 else
748 { 1359 {
@@ -758,13 +1369,52 @@ static int check_crl(X509_STORE_CTX *ctx, X509_CRL *crl)
758 1369
759 if(issuer) 1370 if(issuer)
760 { 1371 {
761 /* Check for cRLSign bit if keyUsage present */ 1372 /* Skip most tests for deltas because they have already
762 if ((issuer->ex_flags & EXFLAG_KUSAGE) && 1373 * been done
763 !(issuer->ex_kusage & KU_CRL_SIGN)) 1374 */
1375 if (!crl->base_crl_number)
764 { 1376 {
765 ctx->error = X509_V_ERR_KEYUSAGE_NO_CRL_SIGN; 1377 /* Check for cRLSign bit if keyUsage present */
766 ok = ctx->verify_cb(0, ctx); 1378 if ((issuer->ex_flags & EXFLAG_KUSAGE) &&
767 if(!ok) goto err; 1379 !(issuer->ex_kusage & KU_CRL_SIGN))
1380 {
1381 ctx->error = X509_V_ERR_KEYUSAGE_NO_CRL_SIGN;
1382 ok = ctx->verify_cb(0, ctx);
1383 if(!ok) goto err;
1384 }
1385
1386 if (!(ctx->current_crl_score & CRL_SCORE_SCOPE))
1387 {
1388 ctx->error = X509_V_ERR_DIFFERENT_CRL_SCOPE;
1389 ok = ctx->verify_cb(0, ctx);
1390 if(!ok) goto err;
1391 }
1392
1393 if (!(ctx->current_crl_score & CRL_SCORE_SAME_PATH))
1394 {
1395 if (check_crl_path(ctx, ctx->current_issuer) <= 0)
1396 {
1397 ctx->error = X509_V_ERR_CRL_PATH_VALIDATION_ERROR;
1398 ok = ctx->verify_cb(0, ctx);
1399 if(!ok) goto err;
1400 }
1401 }
1402
1403 if (crl->idp_flags & IDP_INVALID)
1404 {
1405 ctx->error = X509_V_ERR_INVALID_EXTENSION;
1406 ok = ctx->verify_cb(0, ctx);
1407 if(!ok) goto err;
1408 }
1409
1410
1411 }
1412
1413 if (!(ctx->current_crl_score & CRL_SCORE_TIME))
1414 {
1415 ok = check_crl_time(ctx, crl, 1);
1416 if (!ok)
1417 goto err;
768 } 1418 }
769 1419
770 /* Attempt to get issuer certificate public key */ 1420 /* Attempt to get issuer certificate public key */
@@ -788,10 +1438,6 @@ static int check_crl(X509_STORE_CTX *ctx, X509_CRL *crl)
788 } 1438 }
789 } 1439 }
790 1440
791 ok = check_crl_time(ctx, crl, 1);
792 if (!ok)
793 goto err;
794
795 ok = 1; 1441 ok = 1;
796 1442
797 err: 1443 err:
@@ -802,62 +1448,43 @@ static int check_crl(X509_STORE_CTX *ctx, X509_CRL *crl)
802/* Check certificate against CRL */ 1448/* Check certificate against CRL */
803static int cert_crl(X509_STORE_CTX *ctx, X509_CRL *crl, X509 *x) 1449static int cert_crl(X509_STORE_CTX *ctx, X509_CRL *crl, X509 *x)
804 { 1450 {
805 int idx, ok; 1451 int ok;
806 X509_REVOKED rtmp; 1452 X509_REVOKED *rev;
807 STACK_OF(X509_EXTENSION) *exts; 1453 /* The rules changed for this... previously if a CRL contained
808 X509_EXTENSION *ext; 1454 * unhandled critical extensions it could still be used to indicate
809 /* Look for serial number of certificate in CRL */ 1455 * a certificate was revoked. This has since been changed since
810 rtmp.serialNumber = X509_get_serialNumber(x); 1456 * critical extension can change the meaning of CRL entries.
811 /* Sort revoked into serial number order if not already sorted. 1457 */
812 * Do this under a lock to avoid race condition. 1458 if (crl->flags & EXFLAG_CRITICAL)
813 */
814 if (!sk_X509_REVOKED_is_sorted(crl->crl->revoked))
815 { 1459 {
816 CRYPTO_w_lock(CRYPTO_LOCK_X509_CRL); 1460 if (ctx->param->flags & X509_V_FLAG_IGNORE_CRITICAL)
817 sk_X509_REVOKED_sort(crl->crl->revoked); 1461 return 1;
818 CRYPTO_w_unlock(CRYPTO_LOCK_X509_CRL); 1462 ctx->error = X509_V_ERR_UNHANDLED_CRITICAL_CRL_EXTENSION;
1463 ok = ctx->verify_cb(0, ctx);
1464 if(!ok)
1465 return 0;
819 } 1466 }
820 idx = sk_X509_REVOKED_find(crl->crl->revoked, &rtmp); 1467 /* Look for serial number of certificate in CRL
821 /* If found assume revoked: want something cleverer than 1468 * If found make sure reason is not removeFromCRL.
822 * this to handle entry extensions in V2 CRLs.
823 */ 1469 */
824 if(idx >= 0) 1470 if (X509_CRL_get0_by_cert(crl, &rev, x))
825 { 1471 {
1472 if (rev->reason == CRL_REASON_REMOVE_FROM_CRL)
1473 return 2;
826 ctx->error = X509_V_ERR_CERT_REVOKED; 1474 ctx->error = X509_V_ERR_CERT_REVOKED;
827 ok = ctx->verify_cb(0, ctx); 1475 ok = ctx->verify_cb(0, ctx);
828 if (!ok) return 0; 1476 if (!ok)
1477 return 0;
829 } 1478 }
830 1479
831 if (ctx->param->flags & X509_V_FLAG_IGNORE_CRITICAL)
832 return 1;
833
834 /* See if we have any critical CRL extensions: since we
835 * currently don't handle any CRL extensions the CRL must be
836 * rejected.
837 * This code accesses the X509_CRL structure directly: applications
838 * shouldn't do this.
839 */
840
841 exts = crl->crl->extensions;
842
843 for (idx = 0; idx < sk_X509_EXTENSION_num(exts); idx++)
844 {
845 ext = sk_X509_EXTENSION_value(exts, idx);
846 if (ext->critical > 0)
847 {
848 ctx->error =
849 X509_V_ERR_UNHANDLED_CRITICAL_CRL_EXTENSION;
850 ok = ctx->verify_cb(0, ctx);
851 if(!ok) return 0;
852 break;
853 }
854 }
855 return 1; 1480 return 1;
856 } 1481 }
857 1482
858static int check_policy(X509_STORE_CTX *ctx) 1483static int check_policy(X509_STORE_CTX *ctx)
859 { 1484 {
860 int ret; 1485 int ret;
1486 if (ctx->parent)
1487 return 1;
861 ret = X509_policy_check(&ctx->tree, &ctx->explicit_policy, ctx->chain, 1488 ret = X509_policy_check(&ctx->tree, &ctx->explicit_policy, ctx->chain,
862 ctx->param->policies, ctx->param->flags); 1489 ctx->param->policies, ctx->param->flags);
863 if (ret == 0) 1490 if (ret == 0)
@@ -880,7 +1507,8 @@ static int check_policy(X509_STORE_CTX *ctx)
880 continue; 1507 continue;
881 ctx->current_cert = x; 1508 ctx->current_cert = x;
882 ctx->error = X509_V_ERR_INVALID_POLICY_EXTENSION; 1509 ctx->error = X509_V_ERR_INVALID_POLICY_EXTENSION;
883 ret = ctx->verify_cb(0, ctx); 1510 if(!ctx->verify_cb(0, ctx))
1511 return 0;
884 } 1512 }
885 return 1; 1513 return 1;
886 } 1514 }
@@ -986,7 +1614,12 @@ static int internal_verify(X509_STORE_CTX *ctx)
986 while (n >= 0) 1614 while (n >= 0)
987 { 1615 {
988 ctx->error_depth=n; 1616 ctx->error_depth=n;
989 if (!xs->valid) 1617
1618 /* Skip signature check for self signed certificates unless
1619 * explicitly asked for. It doesn't add any security and
1620 * just wastes time.
1621 */
1622 if (!xs->valid && (xs != xi || (ctx->param->flags & X509_V_FLAG_CHECK_SS_SIGNATURE)))
990 { 1623 {
991 if ((pkey=X509_get_pubkey(xi)) == NULL) 1624 if ((pkey=X509_get_pubkey(xi)) == NULL)
992 { 1625 {
@@ -996,13 +1629,6 @@ static int internal_verify(X509_STORE_CTX *ctx)
996 if (!ok) goto end; 1629 if (!ok) goto end;
997 } 1630 }
998 else if (X509_verify(xs,pkey) <= 0) 1631 else if (X509_verify(xs,pkey) <= 0)
999 /* XXX For the final trusted self-signed cert,
1000 * this is a waste of time. That check should
1001 * optional so that e.g. 'openssl x509' can be
1002 * used to detect invalid self-signatures, but
1003 * we don't verify again and again in SSL
1004 * handshakes and the like once the cert has
1005 * been declared trusted. */
1006 { 1632 {
1007 ctx->error=X509_V_ERR_CERT_SIGNATURE_FAILURE; 1633 ctx->error=X509_V_ERR_CERT_SIGNATURE_FAILURE;
1008 ctx->current_cert=xs; 1634 ctx->current_cert=xs;
@@ -1041,12 +1667,12 @@ end:
1041 return ok; 1667 return ok;
1042 } 1668 }
1043 1669
1044int X509_cmp_current_time(ASN1_TIME *ctm) 1670int X509_cmp_current_time(const ASN1_TIME *ctm)
1045{ 1671{
1046 return X509_cmp_time(ctm, NULL); 1672 return X509_cmp_time(ctm, NULL);
1047} 1673}
1048 1674
1049int X509_cmp_time(ASN1_TIME *ctm, time_t *cmp_time) 1675int X509_cmp_time(const ASN1_TIME *ctm, time_t *cmp_time)
1050 { 1676 {
1051 char *str; 1677 char *str;
1052 ASN1_TIME atm; 1678 ASN1_TIME atm;
@@ -1101,6 +1727,7 @@ int X509_cmp_time(ASN1_TIME *ctm, time_t *cmp_time)
1101 offset= -offset; 1727 offset= -offset;
1102 } 1728 }
1103 atm.type=ctm->type; 1729 atm.type=ctm->type;
1730 atm.flags = 0;
1104 atm.length=sizeof(buff2); 1731 atm.length=sizeof(buff2);
1105 atm.data=(unsigned char *)buff2; 1732 atm.data=(unsigned char *)buff2;
1106 1733
@@ -1129,19 +1756,28 @@ ASN1_TIME *X509_gmtime_adj(ASN1_TIME *s, long adj)
1129 return X509_time_adj(s, adj, NULL); 1756 return X509_time_adj(s, adj, NULL);
1130} 1757}
1131 1758
1132ASN1_TIME *X509_time_adj(ASN1_TIME *s, long adj, time_t *in_tm) 1759ASN1_TIME *X509_time_adj(ASN1_TIME *s, long offset_sec, time_t *in_tm)
1760 {
1761 return X509_time_adj_ex(s, 0, offset_sec, in_tm);
1762 }
1763
1764ASN1_TIME *X509_time_adj_ex(ASN1_TIME *s,
1765 int offset_day, long offset_sec, time_t *in_tm)
1133 { 1766 {
1134 time_t t; 1767 time_t t;
1135 int type = -1;
1136 1768
1137 if (in_tm) t = *in_tm; 1769 if (in_tm) t = *in_tm;
1138 else time(&t); 1770 else time(&t);
1139 1771
1140 t+=adj; 1772 if (s && !(s->flags & ASN1_STRING_FLAG_MSTRING))
1141 if (s) type = s->type; 1773 {
1142 if (type == V_ASN1_UTCTIME) return ASN1_UTCTIME_set(s,t); 1774 if (s->type == V_ASN1_UTCTIME)
1143 if (type == V_ASN1_GENERALIZEDTIME) return ASN1_GENERALIZEDTIME_set(s, t); 1775 return ASN1_UTCTIME_adj(s,t, offset_day, offset_sec);
1144 return ASN1_TIME_set(s, t); 1776 if (s->type == V_ASN1_GENERALIZEDTIME)
1777 return ASN1_GENERALIZEDTIME_adj(s, t, offset_day,
1778 offset_sec);
1779 }
1780 return ASN1_TIME_adj(s, t, offset_day, offset_sec);
1145 } 1781 }
1146 1782
1147int X509_get_pubkey_parameters(EVP_PKEY *pkey, STACK_OF(X509) *chain) 1783int X509_get_pubkey_parameters(EVP_PKEY *pkey, STACK_OF(X509) *chain)
@@ -1244,6 +1880,21 @@ STACK_OF(X509) *X509_STORE_CTX_get1_chain(X509_STORE_CTX *ctx)
1244 return chain; 1880 return chain;
1245 } 1881 }
1246 1882
1883X509 *X509_STORE_CTX_get0_current_issuer(X509_STORE_CTX *ctx)
1884 {
1885 return ctx->current_issuer;
1886 }
1887
1888X509_CRL *X509_STORE_CTX_get0_current_crl(X509_STORE_CTX *ctx)
1889 {
1890 return ctx->current_crl;
1891 }
1892
1893X509_STORE_CTX *X509_STORE_CTX_get0_parent_ctx(X509_STORE_CTX *ctx)
1894 {
1895 return ctx->parent;
1896 }
1897
1247void X509_STORE_CTX_set_cert(X509_STORE_CTX *ctx, X509 *x) 1898void X509_STORE_CTX_set_cert(X509_STORE_CTX *ctx, X509 *x)
1248 { 1899 {
1249 ctx->cert=x; 1900 ctx->cert=x;
@@ -1365,6 +2016,7 @@ int X509_STORE_CTX_init(X509_STORE_CTX *ctx, X509_STORE *store, X509 *x509,
1365 ctx->current_cert=NULL; 2016 ctx->current_cert=NULL;
1366 ctx->current_issuer=NULL; 2017 ctx->current_issuer=NULL;
1367 ctx->tree = NULL; 2018 ctx->tree = NULL;
2019 ctx->parent = NULL;
1368 2020
1369 ctx->param = X509_VERIFY_PARAM_new(); 2021 ctx->param = X509_VERIFY_PARAM_new();
1370 2022
@@ -1430,7 +2082,7 @@ int X509_STORE_CTX_init(X509_STORE_CTX *ctx, X509_STORE *store, X509 *x509,
1430 if (store && store->get_crl) 2082 if (store && store->get_crl)
1431 ctx->get_crl = store->get_crl; 2083 ctx->get_crl = store->get_crl;
1432 else 2084 else
1433 ctx->get_crl = get_crl; 2085 ctx->get_crl = NULL;
1434 2086
1435 if (store && store->check_crl) 2087 if (store && store->check_crl)
1436 ctx->check_crl = store->check_crl; 2088 ctx->check_crl = store->check_crl;
@@ -1442,6 +2094,16 @@ int X509_STORE_CTX_init(X509_STORE_CTX *ctx, X509_STORE *store, X509 *x509,
1442 else 2094 else
1443 ctx->cert_crl = cert_crl; 2095 ctx->cert_crl = cert_crl;
1444 2096
2097 if (store && store->lookup_certs)
2098 ctx->lookup_certs = store->lookup_certs;
2099 else
2100 ctx->lookup_certs = X509_STORE_get1_certs;
2101
2102 if (store && store->lookup_crls)
2103 ctx->lookup_crls = store->lookup_crls;
2104 else
2105 ctx->lookup_crls = X509_STORE_get1_crls;
2106
1445 ctx->check_policy = check_policy; 2107 ctx->check_policy = check_policy;
1446 2108
1447 2109
@@ -1474,7 +2136,8 @@ void X509_STORE_CTX_cleanup(X509_STORE_CTX *ctx)
1474 if (ctx->cleanup) ctx->cleanup(ctx); 2136 if (ctx->cleanup) ctx->cleanup(ctx);
1475 if (ctx->param != NULL) 2137 if (ctx->param != NULL)
1476 { 2138 {
1477 X509_VERIFY_PARAM_free(ctx->param); 2139 if (ctx->parent == NULL)
2140 X509_VERIFY_PARAM_free(ctx->param);
1478 ctx->param=NULL; 2141 ctx->param=NULL;
1479 } 2142 }
1480 if (ctx->tree != NULL) 2143 if (ctx->tree != NULL)
diff --git a/src/lib/libcrypto/x509/x509_vfy.h b/src/lib/libcrypto/x509/x509_vfy.h
index 76c76e1719..fe09b30aaa 100644
--- a/src/lib/libcrypto/x509/x509_vfy.h
+++ b/src/lib/libcrypto/x509/x509_vfy.h
@@ -77,6 +77,7 @@
77extern "C" { 77extern "C" {
78#endif 78#endif
79 79
80#if 0
80/* Outer object */ 81/* Outer object */
81typedef struct x509_hash_dir_st 82typedef struct x509_hash_dir_st
82 { 83 {
@@ -85,6 +86,7 @@ typedef struct x509_hash_dir_st
85 int *dirs_type; 86 int *dirs_type;
86 int num_dirs_alloced; 87 int num_dirs_alloced;
87 } X509_HASH_DIR_CTX; 88 } X509_HASH_DIR_CTX;
89#endif
88 90
89typedef struct x509_file_st 91typedef struct x509_file_st
90 { 92 {
@@ -198,6 +200,8 @@ struct x509_store_st
198 int (*get_crl)(X509_STORE_CTX *ctx, X509_CRL **crl, X509 *x); /* retrieve CRL */ 200 int (*get_crl)(X509_STORE_CTX *ctx, X509_CRL **crl, X509 *x); /* retrieve CRL */
199 int (*check_crl)(X509_STORE_CTX *ctx, X509_CRL *crl); /* Check CRL validity */ 201 int (*check_crl)(X509_STORE_CTX *ctx, X509_CRL *crl); /* Check CRL validity */
200 int (*cert_crl)(X509_STORE_CTX *ctx, X509_CRL *crl, X509 *x); /* Check certificate against CRL */ 202 int (*cert_crl)(X509_STORE_CTX *ctx, X509_CRL *crl, X509 *x); /* Check certificate against CRL */
203 STACK_OF(X509) * (*lookup_certs)(X509_STORE_CTX *ctx, X509_NAME *nm);
204 STACK_OF(X509_CRL) * (*lookup_crls)(X509_STORE_CTX *ctx, X509_NAME *nm);
201 int (*cleanup)(X509_STORE_CTX *ctx); 205 int (*cleanup)(X509_STORE_CTX *ctx);
202 206
203 CRYPTO_EX_DATA ex_data; 207 CRYPTO_EX_DATA ex_data;
@@ -246,6 +250,8 @@ struct x509_store_ctx_st /* X509_STORE_CTX */
246 int (*check_crl)(X509_STORE_CTX *ctx, X509_CRL *crl); /* Check CRL validity */ 250 int (*check_crl)(X509_STORE_CTX *ctx, X509_CRL *crl); /* Check CRL validity */
247 int (*cert_crl)(X509_STORE_CTX *ctx, X509_CRL *crl, X509 *x); /* Check certificate against CRL */ 251 int (*cert_crl)(X509_STORE_CTX *ctx, X509_CRL *crl, X509 *x); /* Check certificate against CRL */
248 int (*check_policy)(X509_STORE_CTX *ctx); 252 int (*check_policy)(X509_STORE_CTX *ctx);
253 STACK_OF(X509) * (*lookup_certs)(X509_STORE_CTX *ctx, X509_NAME *nm);
254 STACK_OF(X509_CRL) * (*lookup_crls)(X509_STORE_CTX *ctx, X509_NAME *nm);
249 int (*cleanup)(X509_STORE_CTX *ctx); 255 int (*cleanup)(X509_STORE_CTX *ctx);
250 256
251 /* The following is built up */ 257 /* The following is built up */
@@ -263,6 +269,11 @@ struct x509_store_ctx_st /* X509_STORE_CTX */
263 X509 *current_issuer; /* cert currently being tested as valid issuer */ 269 X509 *current_issuer; /* cert currently being tested as valid issuer */
264 X509_CRL *current_crl; /* current CRL */ 270 X509_CRL *current_crl; /* current CRL */
265 271
272 int current_crl_score; /* score of current CRL */
273 unsigned int current_reasons; /* Reason mask */
274
275 X509_STORE_CTX *parent; /* For CRL path validation: parent context */
276
266 CRYPTO_EX_DATA ex_data; 277 CRYPTO_EX_DATA ex_data;
267 } /* X509_STORE_CTX */; 278 } /* X509_STORE_CTX */;
268 279
@@ -330,8 +341,18 @@ void X509_STORE_CTX_set_depth(X509_STORE_CTX *ctx, int depth);
330#define X509_V_ERR_INVALID_EXTENSION 41 341#define X509_V_ERR_INVALID_EXTENSION 41
331#define X509_V_ERR_INVALID_POLICY_EXTENSION 42 342#define X509_V_ERR_INVALID_POLICY_EXTENSION 42
332#define X509_V_ERR_NO_EXPLICIT_POLICY 43 343#define X509_V_ERR_NO_EXPLICIT_POLICY 43
344#define X509_V_ERR_DIFFERENT_CRL_SCOPE 44
345#define X509_V_ERR_UNSUPPORTED_EXTENSION_FEATURE 45
346
347#define X509_V_ERR_UNNESTED_RESOURCE 46
333 348
334#define X509_V_ERR_UNNESTED_RESOURCE 44 349#define X509_V_ERR_PERMITTED_VIOLATION 47
350#define X509_V_ERR_EXCLUDED_VIOLATION 48
351#define X509_V_ERR_SUBTREE_MINMAX 49
352#define X509_V_ERR_UNSUPPORTED_CONSTRAINT_TYPE 51
353#define X509_V_ERR_UNSUPPORTED_CONSTRAINT_SYNTAX 52
354#define X509_V_ERR_UNSUPPORTED_NAME_SYNTAX 53
355#define X509_V_ERR_CRL_PATH_VALIDATION_ERROR 54
335 356
336/* The application is not happy */ 357/* The application is not happy */
337#define X509_V_ERR_APPLICATION_VERIFICATION 50 358#define X509_V_ERR_APPLICATION_VERIFICATION 50
@@ -362,6 +383,13 @@ void X509_STORE_CTX_set_depth(X509_STORE_CTX *ctx, int depth);
362#define X509_V_FLAG_INHIBIT_MAP 0x400 383#define X509_V_FLAG_INHIBIT_MAP 0x400
363/* Notify callback that policy is OK */ 384/* Notify callback that policy is OK */
364#define X509_V_FLAG_NOTIFY_POLICY 0x800 385#define X509_V_FLAG_NOTIFY_POLICY 0x800
386/* Extended CRL features such as indirect CRLs, alternate CRL signing keys */
387#define X509_V_FLAG_EXTENDED_CRL_SUPPORT 0x1000
388/* Delta CRL support */
389#define X509_V_FLAG_USE_DELTAS 0x2000
390/* Check selfsigned CA signature */
391#define X509_V_FLAG_CHECK_SS_SIGNATURE 0x4000
392
365 393
366#define X509_VP_FLAG_DEFAULT 0x1 394#define X509_VP_FLAG_DEFAULT 0x1
367#define X509_VP_FLAG_OVERWRITE 0x2 395#define X509_VP_FLAG_OVERWRITE 0x2
@@ -384,11 +412,16 @@ void X509_OBJECT_free_contents(X509_OBJECT *a);
384X509_STORE *X509_STORE_new(void ); 412X509_STORE *X509_STORE_new(void );
385void X509_STORE_free(X509_STORE *v); 413void X509_STORE_free(X509_STORE *v);
386 414
415STACK_OF(X509)* X509_STORE_get1_certs(X509_STORE_CTX *st, X509_NAME *nm);
416STACK_OF(X509_CRL)* X509_STORE_get1_crls(X509_STORE_CTX *st, X509_NAME *nm);
387int X509_STORE_set_flags(X509_STORE *ctx, unsigned long flags); 417int X509_STORE_set_flags(X509_STORE *ctx, unsigned long flags);
388int X509_STORE_set_purpose(X509_STORE *ctx, int purpose); 418int X509_STORE_set_purpose(X509_STORE *ctx, int purpose);
389int X509_STORE_set_trust(X509_STORE *ctx, int trust); 419int X509_STORE_set_trust(X509_STORE *ctx, int trust);
390int X509_STORE_set1_param(X509_STORE *ctx, X509_VERIFY_PARAM *pm); 420int X509_STORE_set1_param(X509_STORE *ctx, X509_VERIFY_PARAM *pm);
391 421
422void X509_STORE_set_verify_cb(X509_STORE *ctx,
423 int (*verify_cb)(int, X509_STORE_CTX *));
424
392X509_STORE_CTX *X509_STORE_CTX_new(void); 425X509_STORE_CTX *X509_STORE_CTX_new(void);
393 426
394int X509_STORE_CTX_get1_issuer(X509 **issuer, X509_STORE_CTX *ctx, X509 *x); 427int X509_STORE_CTX_get1_issuer(X509 **issuer, X509_STORE_CTX *ctx, X509 *x);
@@ -447,6 +480,9 @@ int X509_STORE_CTX_get_error(X509_STORE_CTX *ctx);
447void X509_STORE_CTX_set_error(X509_STORE_CTX *ctx,int s); 480void X509_STORE_CTX_set_error(X509_STORE_CTX *ctx,int s);
448int X509_STORE_CTX_get_error_depth(X509_STORE_CTX *ctx); 481int X509_STORE_CTX_get_error_depth(X509_STORE_CTX *ctx);
449X509 * X509_STORE_CTX_get_current_cert(X509_STORE_CTX *ctx); 482X509 * X509_STORE_CTX_get_current_cert(X509_STORE_CTX *ctx);
483X509 *X509_STORE_CTX_get0_current_issuer(X509_STORE_CTX *ctx);
484X509_CRL *X509_STORE_CTX_get0_current_crl(X509_STORE_CTX *ctx);
485X509_STORE_CTX *X509_STORE_CTX_get0_parent_ctx(X509_STORE_CTX *ctx);
450STACK_OF(X509) *X509_STORE_CTX_get_chain(X509_STORE_CTX *ctx); 486STACK_OF(X509) *X509_STORE_CTX_get_chain(X509_STORE_CTX *ctx);
451STACK_OF(X509) *X509_STORE_CTX_get1_chain(X509_STORE_CTX *ctx); 487STACK_OF(X509) *X509_STORE_CTX_get1_chain(X509_STORE_CTX *ctx);
452void X509_STORE_CTX_set_cert(X509_STORE_CTX *c,X509 *x); 488void X509_STORE_CTX_set_cert(X509_STORE_CTX *c,X509 *x);
diff --git a/src/lib/libcrypto/x509/x509cset.c b/src/lib/libcrypto/x509/x509cset.c
index 7f4004b291..3109defb0b 100644
--- a/src/lib/libcrypto/x509/x509cset.c
+++ b/src/lib/libcrypto/x509/x509cset.c
@@ -81,7 +81,7 @@ int X509_CRL_set_issuer_name(X509_CRL *x, X509_NAME *name)
81 } 81 }
82 82
83 83
84int X509_CRL_set_lastUpdate(X509_CRL *x, ASN1_TIME *tm) 84int X509_CRL_set_lastUpdate(X509_CRL *x, const ASN1_TIME *tm)
85 { 85 {
86 ASN1_TIME *in; 86 ASN1_TIME *in;
87 87
@@ -99,7 +99,7 @@ int X509_CRL_set_lastUpdate(X509_CRL *x, ASN1_TIME *tm)
99 return(in != NULL); 99 return(in != NULL);
100 } 100 }
101 101
102int X509_CRL_set_nextUpdate(X509_CRL *x, ASN1_TIME *tm) 102int X509_CRL_set_nextUpdate(X509_CRL *x, const ASN1_TIME *tm)
103 { 103 {
104 ASN1_TIME *in; 104 ASN1_TIME *in;
105 105
diff --git a/src/lib/libcrypto/x509/x509name.c b/src/lib/libcrypto/x509/x509name.c
index 068abfe5f0..27bc4dc9a3 100644
--- a/src/lib/libcrypto/x509/x509name.c
+++ b/src/lib/libcrypto/x509/x509name.c
@@ -356,7 +356,7 @@ int X509_NAME_ENTRY_set_data(X509_NAME_ENTRY *ne, int type,
356 return ASN1_STRING_set_by_NID(&ne->value, bytes, 356 return ASN1_STRING_set_by_NID(&ne->value, bytes,
357 len, type, 357 len, type,
358 OBJ_obj2nid(ne->object)) ? 1 : 0; 358 OBJ_obj2nid(ne->object)) ? 1 : 0;
359 if (len < 0) len=strlen((char *)bytes); 359 if (len < 0) len=strlen((const char *)bytes);
360 i=ASN1_STRING_set(ne->value,bytes,len); 360 i=ASN1_STRING_set(ne->value,bytes,len);
361 if (!i) return(0); 361 if (!i) return(0);
362 if (type != V_ASN1_UNDEF) 362 if (type != V_ASN1_UNDEF)
diff --git a/src/lib/libcrypto/x509/x509type.c b/src/lib/libcrypto/x509/x509type.c
index 2cd994c5b0..3385ad3f67 100644
--- a/src/lib/libcrypto/x509/x509type.c
+++ b/src/lib/libcrypto/x509/x509type.c
@@ -91,6 +91,10 @@ int X509_certificate_type(X509 *x, EVP_PKEY *pkey)
91 break; 91 break;
92 case EVP_PKEY_DH: 92 case EVP_PKEY_DH:
93 ret=EVP_PK_DH|EVP_PKT_EXCH; 93 ret=EVP_PK_DH|EVP_PKT_EXCH;
94 break;
95 case NID_id_GostR3410_94:
96 case NID_id_GostR3410_2001:
97 ret=EVP_PKT_EXCH|EVP_PKT_SIGN;
94 break; 98 break;
95 default: 99 default:
96 break; 100 break;
diff --git a/src/lib/libcrypto/x509/x_all.c b/src/lib/libcrypto/x509/x_all.c
index 9039caad60..ebae30b701 100644
--- a/src/lib/libcrypto/x509/x_all.c
+++ b/src/lib/libcrypto/x509/x_all.c
@@ -57,7 +57,6 @@
57 */ 57 */
58 58
59#include <stdio.h> 59#include <stdio.h>
60#undef SSLEAY_MACROS
61#include <openssl/stack.h> 60#include <openssl/stack.h>
62#include "cryptlib.h" 61#include "cryptlib.h"
63#include <openssl/buffer.h> 62#include <openssl/buffer.h>
@@ -83,12 +82,6 @@ int X509_REQ_verify(X509_REQ *a, EVP_PKEY *r)
83 a->sig_alg,a->signature,a->req_info,r)); 82 a->sig_alg,a->signature,a->req_info,r));
84 } 83 }
85 84
86int X509_CRL_verify(X509_CRL *a, EVP_PKEY *r)
87 {
88 return(ASN1_item_verify(ASN1_ITEM_rptr(X509_CRL_INFO),
89 a->sig_alg, a->signature,a->crl,r));
90 }
91
92int NETSCAPE_SPKI_verify(NETSCAPE_SPKI *a, EVP_PKEY *r) 85int NETSCAPE_SPKI_verify(NETSCAPE_SPKI *a, EVP_PKEY *r)
93 { 86 {
94 return(ASN1_item_verify(ASN1_ITEM_rptr(NETSCAPE_SPKAC), 87 return(ASN1_item_verify(ASN1_ITEM_rptr(NETSCAPE_SPKAC),
diff --git a/src/lib/libcrypto/x509v3/Makefile.ssl b/src/lib/libcrypto/x509v3/Makefile.ssl
deleted file mode 100644
index 66df90c346..0000000000
--- a/src/lib/libcrypto/x509v3/Makefile.ssl
+++ /dev/null
@@ -1,603 +0,0 @@
1#
2# SSLeay/crypto/x509v3/Makefile
3#
4
5DIR= x509v3
6TOP= ../..
7CC= cc
8INCLUDES= -I.. -I$(TOP) -I../../include
9CFLAG=-g
10INSTALL_PREFIX=
11OPENSSLDIR= /usr/local/ssl
12INSTALLTOP=/usr/local/ssl
13MAKE= make -f Makefile.ssl
14MAKEDEPPROG= makedepend
15MAKEDEPEND= $(TOP)/util/domd $(TOP) -MD $(MAKEDEPPROG)
16MAKEFILE= Makefile.ssl
17AR= ar r
18
19CFLAGS= $(INCLUDES) $(CFLAG)
20
21GENERAL=Makefile README
22TEST=
23APPS=
24
25LIB=$(TOP)/libcrypto.a
26LIBSRC= v3_bcons.c v3_bitst.c v3_conf.c v3_extku.c v3_ia5.c v3_lib.c \
27v3_prn.c v3_utl.c v3err.c v3_genn.c v3_alt.c v3_skey.c v3_akey.c v3_pku.c \
28v3_int.c v3_enum.c v3_sxnet.c v3_cpols.c v3_crld.c v3_purp.c v3_info.c \
29v3_ocsp.c v3_akeya.c
30LIBOBJ= v3_bcons.o v3_bitst.o v3_conf.o v3_extku.o v3_ia5.o v3_lib.o \
31v3_prn.o v3_utl.o v3err.o v3_genn.o v3_alt.o v3_skey.o v3_akey.o v3_pku.o \
32v3_int.o v3_enum.o v3_sxnet.o v3_cpols.o v3_crld.o v3_purp.o v3_info.o \
33v3_ocsp.o v3_akeya.o
34
35SRC= $(LIBSRC)
36
37EXHEADER= x509v3.h
38HEADER= $(EXHEADER)
39
40ALL= $(GENERAL) $(SRC) $(HEADER)
41
42top:
43 (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all)
44
45all: lib
46
47lib: $(LIBOBJ)
48 $(AR) $(LIB) $(LIBOBJ)
49 $(RANLIB) $(LIB) || echo Never mind.
50 @touch lib
51
52files:
53 $(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO
54
55links:
56 @sh $(TOP)/util/point.sh Makefile.ssl Makefile
57 @$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER)
58 @$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST)
59 @$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS)
60
61install:
62 @for i in $(EXHEADER) ; \
63 do \
64 (cp $$i $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i; \
65 chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i ); \
66 done;
67
68tags:
69 ctags $(SRC)
70
71tests:
72
73lint:
74 lint -DLINT $(INCLUDES) $(SRC)>fluff
75
76depend:
77 $(MAKEDEPEND) -- $(CFLAG) $(INCLUDES) $(DEPFLAG) -- $(PROGS) $(LIBSRC)
78
79dclean:
80 $(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
81 mv -f Makefile.new $(MAKEFILE)
82
83clean:
84 rm -f *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff
85
86# DO NOT DELETE THIS LINE -- make depend depends on it.
87
88v3_akey.o: ../../e_os.h ../../include/openssl/aes.h
89v3_akey.o: ../../include/openssl/asn1.h ../../include/openssl/asn1t.h
90v3_akey.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h
91v3_akey.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
92v3_akey.o: ../../include/openssl/cast.h ../../include/openssl/conf.h
93v3_akey.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
94v3_akey.o: ../../include/openssl/des_old.h ../../include/openssl/dh.h
95v3_akey.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
96v3_akey.o: ../../include/openssl/err.h ../../include/openssl/evp.h
97v3_akey.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h
98v3_akey.o: ../../include/openssl/md2.h ../../include/openssl/md4.h
99v3_akey.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
100v3_akey.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
101v3_akey.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
102v3_akey.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h
103v3_akey.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h
104v3_akey.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h
105v3_akey.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
106v3_akey.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
107v3_akey.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
108v3_akey.o: ../../include/openssl/ui_compat.h ../../include/openssl/x509.h
109v3_akey.o: ../../include/openssl/x509_vfy.h ../../include/openssl/x509v3.h
110v3_akey.o: ../cryptlib.h v3_akey.c
111v3_akeya.o: ../../e_os.h ../../include/openssl/aes.h
112v3_akeya.o: ../../include/openssl/asn1.h ../../include/openssl/asn1t.h
113v3_akeya.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h
114v3_akeya.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
115v3_akeya.o: ../../include/openssl/cast.h ../../include/openssl/conf.h
116v3_akeya.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
117v3_akeya.o: ../../include/openssl/des_old.h ../../include/openssl/dh.h
118v3_akeya.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
119v3_akeya.o: ../../include/openssl/err.h ../../include/openssl/evp.h
120v3_akeya.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h
121v3_akeya.o: ../../include/openssl/md2.h ../../include/openssl/md4.h
122v3_akeya.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
123v3_akeya.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
124v3_akeya.o: ../../include/openssl/opensslconf.h
125v3_akeya.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
126v3_akeya.o: ../../include/openssl/pkcs7.h ../../include/openssl/rc2.h
127v3_akeya.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
128v3_akeya.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
129v3_akeya.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
130v3_akeya.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
131v3_akeya.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
132v3_akeya.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
133v3_akeya.o: ../../include/openssl/x509v3.h ../cryptlib.h v3_akeya.c
134v3_alt.o: ../../e_os.h ../../include/openssl/aes.h ../../include/openssl/asn1.h
135v3_alt.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h
136v3_alt.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
137v3_alt.o: ../../include/openssl/cast.h ../../include/openssl/conf.h
138v3_alt.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
139v3_alt.o: ../../include/openssl/des_old.h ../../include/openssl/dh.h
140v3_alt.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
141v3_alt.o: ../../include/openssl/err.h ../../include/openssl/evp.h
142v3_alt.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h
143v3_alt.o: ../../include/openssl/md2.h ../../include/openssl/md4.h
144v3_alt.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
145v3_alt.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
146v3_alt.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
147v3_alt.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h
148v3_alt.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h
149v3_alt.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h
150v3_alt.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
151v3_alt.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
152v3_alt.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
153v3_alt.o: ../../include/openssl/ui_compat.h ../../include/openssl/x509.h
154v3_alt.o: ../../include/openssl/x509_vfy.h ../../include/openssl/x509v3.h
155v3_alt.o: ../cryptlib.h v3_alt.c
156v3_bcons.o: ../../e_os.h ../../include/openssl/aes.h
157v3_bcons.o: ../../include/openssl/asn1.h ../../include/openssl/asn1t.h
158v3_bcons.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h
159v3_bcons.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
160v3_bcons.o: ../../include/openssl/cast.h ../../include/openssl/conf.h
161v3_bcons.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
162v3_bcons.o: ../../include/openssl/des_old.h ../../include/openssl/dh.h
163v3_bcons.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
164v3_bcons.o: ../../include/openssl/err.h ../../include/openssl/evp.h
165v3_bcons.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h
166v3_bcons.o: ../../include/openssl/md2.h ../../include/openssl/md4.h
167v3_bcons.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
168v3_bcons.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
169v3_bcons.o: ../../include/openssl/opensslconf.h
170v3_bcons.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
171v3_bcons.o: ../../include/openssl/pkcs7.h ../../include/openssl/rc2.h
172v3_bcons.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
173v3_bcons.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
174v3_bcons.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
175v3_bcons.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
176v3_bcons.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
177v3_bcons.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
178v3_bcons.o: ../../include/openssl/x509v3.h ../cryptlib.h v3_bcons.c
179v3_bitst.o: ../../e_os.h ../../include/openssl/aes.h
180v3_bitst.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
181v3_bitst.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
182v3_bitst.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
183v3_bitst.o: ../../include/openssl/conf.h ../../include/openssl/crypto.h
184v3_bitst.o: ../../include/openssl/des.h ../../include/openssl/des_old.h
185v3_bitst.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
186v3_bitst.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
187v3_bitst.o: ../../include/openssl/evp.h ../../include/openssl/idea.h
188v3_bitst.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h
189v3_bitst.o: ../../include/openssl/md4.h ../../include/openssl/md5.h
190v3_bitst.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h
191v3_bitst.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
192v3_bitst.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
193v3_bitst.o: ../../include/openssl/pkcs7.h ../../include/openssl/rc2.h
194v3_bitst.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
195v3_bitst.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
196v3_bitst.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
197v3_bitst.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
198v3_bitst.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
199v3_bitst.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
200v3_bitst.o: ../../include/openssl/x509v3.h ../cryptlib.h v3_bitst.c
201v3_conf.o: ../../e_os.h ../../include/openssl/aes.h
202v3_conf.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
203v3_conf.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
204v3_conf.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
205v3_conf.o: ../../include/openssl/conf.h ../../include/openssl/crypto.h
206v3_conf.o: ../../include/openssl/des.h ../../include/openssl/des_old.h
207v3_conf.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
208v3_conf.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
209v3_conf.o: ../../include/openssl/evp.h ../../include/openssl/idea.h
210v3_conf.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h
211v3_conf.o: ../../include/openssl/md4.h ../../include/openssl/md5.h
212v3_conf.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h
213v3_conf.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
214v3_conf.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
215v3_conf.o: ../../include/openssl/pkcs7.h ../../include/openssl/rc2.h
216v3_conf.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
217v3_conf.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
218v3_conf.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
219v3_conf.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
220v3_conf.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
221v3_conf.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
222v3_conf.o: ../../include/openssl/x509v3.h ../cryptlib.h v3_conf.c
223v3_cpols.o: ../../e_os.h ../../include/openssl/aes.h
224v3_cpols.o: ../../include/openssl/asn1.h ../../include/openssl/asn1t.h
225v3_cpols.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h
226v3_cpols.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
227v3_cpols.o: ../../include/openssl/cast.h ../../include/openssl/conf.h
228v3_cpols.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
229v3_cpols.o: ../../include/openssl/des_old.h ../../include/openssl/dh.h
230v3_cpols.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
231v3_cpols.o: ../../include/openssl/err.h ../../include/openssl/evp.h
232v3_cpols.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h
233v3_cpols.o: ../../include/openssl/md2.h ../../include/openssl/md4.h
234v3_cpols.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
235v3_cpols.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
236v3_cpols.o: ../../include/openssl/opensslconf.h
237v3_cpols.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
238v3_cpols.o: ../../include/openssl/pkcs7.h ../../include/openssl/rc2.h
239v3_cpols.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
240v3_cpols.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
241v3_cpols.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
242v3_cpols.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
243v3_cpols.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
244v3_cpols.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
245v3_cpols.o: ../../include/openssl/x509v3.h ../cryptlib.h v3_cpols.c
246v3_crld.o: ../../e_os.h ../../include/openssl/aes.h
247v3_crld.o: ../../include/openssl/asn1.h ../../include/openssl/asn1t.h
248v3_crld.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h
249v3_crld.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
250v3_crld.o: ../../include/openssl/cast.h ../../include/openssl/conf.h
251v3_crld.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
252v3_crld.o: ../../include/openssl/des_old.h ../../include/openssl/dh.h
253v3_crld.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
254v3_crld.o: ../../include/openssl/err.h ../../include/openssl/evp.h
255v3_crld.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h
256v3_crld.o: ../../include/openssl/md2.h ../../include/openssl/md4.h
257v3_crld.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
258v3_crld.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
259v3_crld.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
260v3_crld.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h
261v3_crld.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h
262v3_crld.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h
263v3_crld.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
264v3_crld.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
265v3_crld.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
266v3_crld.o: ../../include/openssl/ui_compat.h ../../include/openssl/x509.h
267v3_crld.o: ../../include/openssl/x509_vfy.h ../../include/openssl/x509v3.h
268v3_crld.o: ../cryptlib.h v3_crld.c
269v3_enum.o: ../../e_os.h ../../include/openssl/aes.h
270v3_enum.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
271v3_enum.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
272v3_enum.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
273v3_enum.o: ../../include/openssl/conf.h ../../include/openssl/crypto.h
274v3_enum.o: ../../include/openssl/des.h ../../include/openssl/des_old.h
275v3_enum.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
276v3_enum.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
277v3_enum.o: ../../include/openssl/evp.h ../../include/openssl/idea.h
278v3_enum.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h
279v3_enum.o: ../../include/openssl/md4.h ../../include/openssl/md5.h
280v3_enum.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h
281v3_enum.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
282v3_enum.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
283v3_enum.o: ../../include/openssl/pkcs7.h ../../include/openssl/rc2.h
284v3_enum.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
285v3_enum.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
286v3_enum.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
287v3_enum.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
288v3_enum.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
289v3_enum.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
290v3_enum.o: ../../include/openssl/x509v3.h ../cryptlib.h v3_enum.c
291v3_extku.o: ../../e_os.h ../../include/openssl/aes.h
292v3_extku.o: ../../include/openssl/asn1.h ../../include/openssl/asn1t.h
293v3_extku.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h
294v3_extku.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
295v3_extku.o: ../../include/openssl/cast.h ../../include/openssl/conf.h
296v3_extku.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
297v3_extku.o: ../../include/openssl/des_old.h ../../include/openssl/dh.h
298v3_extku.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
299v3_extku.o: ../../include/openssl/err.h ../../include/openssl/evp.h
300v3_extku.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h
301v3_extku.o: ../../include/openssl/md2.h ../../include/openssl/md4.h
302v3_extku.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
303v3_extku.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
304v3_extku.o: ../../include/openssl/opensslconf.h
305v3_extku.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
306v3_extku.o: ../../include/openssl/pkcs7.h ../../include/openssl/rc2.h
307v3_extku.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
308v3_extku.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
309v3_extku.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
310v3_extku.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
311v3_extku.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
312v3_extku.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
313v3_extku.o: ../../include/openssl/x509v3.h ../cryptlib.h v3_extku.c
314v3_genn.o: ../../e_os.h ../../include/openssl/aes.h
315v3_genn.o: ../../include/openssl/asn1.h ../../include/openssl/asn1t.h
316v3_genn.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h
317v3_genn.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
318v3_genn.o: ../../include/openssl/cast.h ../../include/openssl/conf.h
319v3_genn.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
320v3_genn.o: ../../include/openssl/des_old.h ../../include/openssl/dh.h
321v3_genn.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
322v3_genn.o: ../../include/openssl/err.h ../../include/openssl/evp.h
323v3_genn.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h
324v3_genn.o: ../../include/openssl/md2.h ../../include/openssl/md4.h
325v3_genn.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
326v3_genn.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
327v3_genn.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
328v3_genn.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h
329v3_genn.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h
330v3_genn.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h
331v3_genn.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
332v3_genn.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
333v3_genn.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
334v3_genn.o: ../../include/openssl/ui_compat.h ../../include/openssl/x509.h
335v3_genn.o: ../../include/openssl/x509_vfy.h ../../include/openssl/x509v3.h
336v3_genn.o: ../cryptlib.h v3_genn.c
337v3_ia5.o: ../../e_os.h ../../include/openssl/aes.h ../../include/openssl/asn1.h
338v3_ia5.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h
339v3_ia5.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
340v3_ia5.o: ../../include/openssl/cast.h ../../include/openssl/conf.h
341v3_ia5.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
342v3_ia5.o: ../../include/openssl/des_old.h ../../include/openssl/dh.h
343v3_ia5.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
344v3_ia5.o: ../../include/openssl/err.h ../../include/openssl/evp.h
345v3_ia5.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h
346v3_ia5.o: ../../include/openssl/md2.h ../../include/openssl/md4.h
347v3_ia5.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
348v3_ia5.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
349v3_ia5.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
350v3_ia5.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h
351v3_ia5.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h
352v3_ia5.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h
353v3_ia5.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
354v3_ia5.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
355v3_ia5.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
356v3_ia5.o: ../../include/openssl/ui_compat.h ../../include/openssl/x509.h
357v3_ia5.o: ../../include/openssl/x509_vfy.h ../../include/openssl/x509v3.h
358v3_ia5.o: ../cryptlib.h v3_ia5.c
359v3_info.o: ../../e_os.h ../../include/openssl/aes.h
360v3_info.o: ../../include/openssl/asn1.h ../../include/openssl/asn1t.h
361v3_info.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h
362v3_info.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
363v3_info.o: ../../include/openssl/cast.h ../../include/openssl/conf.h
364v3_info.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
365v3_info.o: ../../include/openssl/des_old.h ../../include/openssl/dh.h
366v3_info.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
367v3_info.o: ../../include/openssl/err.h ../../include/openssl/evp.h
368v3_info.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h
369v3_info.o: ../../include/openssl/md2.h ../../include/openssl/md4.h
370v3_info.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
371v3_info.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
372v3_info.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
373v3_info.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h
374v3_info.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h
375v3_info.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h
376v3_info.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
377v3_info.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
378v3_info.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
379v3_info.o: ../../include/openssl/ui_compat.h ../../include/openssl/x509.h
380v3_info.o: ../../include/openssl/x509_vfy.h ../../include/openssl/x509v3.h
381v3_info.o: ../cryptlib.h v3_info.c
382v3_int.o: ../../e_os.h ../../include/openssl/aes.h ../../include/openssl/asn1.h
383v3_int.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h
384v3_int.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
385v3_int.o: ../../include/openssl/cast.h ../../include/openssl/conf.h
386v3_int.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
387v3_int.o: ../../include/openssl/des_old.h ../../include/openssl/dh.h
388v3_int.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
389v3_int.o: ../../include/openssl/err.h ../../include/openssl/evp.h
390v3_int.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h
391v3_int.o: ../../include/openssl/md2.h ../../include/openssl/md4.h
392v3_int.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
393v3_int.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
394v3_int.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
395v3_int.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h
396v3_int.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h
397v3_int.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h
398v3_int.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
399v3_int.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
400v3_int.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
401v3_int.o: ../../include/openssl/ui_compat.h ../../include/openssl/x509.h
402v3_int.o: ../../include/openssl/x509_vfy.h ../../include/openssl/x509v3.h
403v3_int.o: ../cryptlib.h v3_int.c
404v3_lib.o: ../../e_os.h ../../include/openssl/aes.h ../../include/openssl/asn1.h
405v3_lib.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h
406v3_lib.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
407v3_lib.o: ../../include/openssl/cast.h ../../include/openssl/conf.h
408v3_lib.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
409v3_lib.o: ../../include/openssl/des_old.h ../../include/openssl/dh.h
410v3_lib.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
411v3_lib.o: ../../include/openssl/err.h ../../include/openssl/evp.h
412v3_lib.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h
413v3_lib.o: ../../include/openssl/md2.h ../../include/openssl/md4.h
414v3_lib.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
415v3_lib.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
416v3_lib.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
417v3_lib.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h
418v3_lib.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h
419v3_lib.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h
420v3_lib.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
421v3_lib.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
422v3_lib.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
423v3_lib.o: ../../include/openssl/ui_compat.h ../../include/openssl/x509.h
424v3_lib.o: ../../include/openssl/x509_vfy.h ../../include/openssl/x509v3.h
425v3_lib.o: ../cryptlib.h ext_dat.h v3_lib.c
426v3_ocsp.o: ../../e_os.h ../../include/openssl/aes.h
427v3_ocsp.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
428v3_ocsp.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
429v3_ocsp.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
430v3_ocsp.o: ../../include/openssl/conf.h ../../include/openssl/crypto.h
431v3_ocsp.o: ../../include/openssl/des.h ../../include/openssl/des_old.h
432v3_ocsp.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
433v3_ocsp.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
434v3_ocsp.o: ../../include/openssl/evp.h ../../include/openssl/idea.h
435v3_ocsp.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h
436v3_ocsp.o: ../../include/openssl/md4.h ../../include/openssl/md5.h
437v3_ocsp.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h
438v3_ocsp.o: ../../include/openssl/objects.h ../../include/openssl/ocsp.h
439v3_ocsp.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
440v3_ocsp.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h
441v3_ocsp.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h
442v3_ocsp.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h
443v3_ocsp.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
444v3_ocsp.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
445v3_ocsp.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
446v3_ocsp.o: ../../include/openssl/ui_compat.h ../../include/openssl/x509.h
447v3_ocsp.o: ../../include/openssl/x509_vfy.h ../../include/openssl/x509v3.h
448v3_ocsp.o: ../cryptlib.h v3_ocsp.c
449v3_pku.o: ../../e_os.h ../../include/openssl/aes.h ../../include/openssl/asn1.h
450v3_pku.o: ../../include/openssl/asn1t.h ../../include/openssl/bio.h
451v3_pku.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
452v3_pku.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
453v3_pku.o: ../../include/openssl/conf.h ../../include/openssl/crypto.h
454v3_pku.o: ../../include/openssl/des.h ../../include/openssl/des_old.h
455v3_pku.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
456v3_pku.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
457v3_pku.o: ../../include/openssl/evp.h ../../include/openssl/idea.h
458v3_pku.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h
459v3_pku.o: ../../include/openssl/md4.h ../../include/openssl/md5.h
460v3_pku.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h
461v3_pku.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
462v3_pku.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
463v3_pku.o: ../../include/openssl/pkcs7.h ../../include/openssl/rc2.h
464v3_pku.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
465v3_pku.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
466v3_pku.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
467v3_pku.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
468v3_pku.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
469v3_pku.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
470v3_pku.o: ../../include/openssl/x509v3.h ../cryptlib.h v3_pku.c
471v3_prn.o: ../../e_os.h ../../include/openssl/aes.h ../../include/openssl/asn1.h
472v3_prn.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h
473v3_prn.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
474v3_prn.o: ../../include/openssl/cast.h ../../include/openssl/conf.h
475v3_prn.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
476v3_prn.o: ../../include/openssl/des_old.h ../../include/openssl/dh.h
477v3_prn.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
478v3_prn.o: ../../include/openssl/err.h ../../include/openssl/evp.h
479v3_prn.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h
480v3_prn.o: ../../include/openssl/md2.h ../../include/openssl/md4.h
481v3_prn.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
482v3_prn.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
483v3_prn.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
484v3_prn.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h
485v3_prn.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h
486v3_prn.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h
487v3_prn.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
488v3_prn.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
489v3_prn.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
490v3_prn.o: ../../include/openssl/ui_compat.h ../../include/openssl/x509.h
491v3_prn.o: ../../include/openssl/x509_vfy.h ../../include/openssl/x509v3.h
492v3_prn.o: ../cryptlib.h v3_prn.c
493v3_purp.o: ../../e_os.h ../../include/openssl/aes.h
494v3_purp.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
495v3_purp.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
496v3_purp.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
497v3_purp.o: ../../include/openssl/conf.h ../../include/openssl/crypto.h
498v3_purp.o: ../../include/openssl/des.h ../../include/openssl/des_old.h
499v3_purp.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
500v3_purp.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
501v3_purp.o: ../../include/openssl/evp.h ../../include/openssl/idea.h
502v3_purp.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h
503v3_purp.o: ../../include/openssl/md4.h ../../include/openssl/md5.h
504v3_purp.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h
505v3_purp.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
506v3_purp.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
507v3_purp.o: ../../include/openssl/pkcs7.h ../../include/openssl/rc2.h
508v3_purp.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
509v3_purp.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
510v3_purp.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
511v3_purp.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
512v3_purp.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
513v3_purp.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
514v3_purp.o: ../../include/openssl/x509v3.h ../cryptlib.h v3_purp.c
515v3_skey.o: ../../e_os.h ../../include/openssl/aes.h
516v3_skey.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
517v3_skey.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
518v3_skey.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
519v3_skey.o: ../../include/openssl/conf.h ../../include/openssl/crypto.h
520v3_skey.o: ../../include/openssl/des.h ../../include/openssl/des_old.h
521v3_skey.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
522v3_skey.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
523v3_skey.o: ../../include/openssl/evp.h ../../include/openssl/idea.h
524v3_skey.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h
525v3_skey.o: ../../include/openssl/md4.h ../../include/openssl/md5.h
526v3_skey.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h
527v3_skey.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
528v3_skey.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
529v3_skey.o: ../../include/openssl/pkcs7.h ../../include/openssl/rc2.h
530v3_skey.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
531v3_skey.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
532v3_skey.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
533v3_skey.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
534v3_skey.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
535v3_skey.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
536v3_skey.o: ../../include/openssl/x509v3.h ../cryptlib.h v3_skey.c
537v3_sxnet.o: ../../e_os.h ../../include/openssl/aes.h
538v3_sxnet.o: ../../include/openssl/asn1.h ../../include/openssl/asn1t.h
539v3_sxnet.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h
540v3_sxnet.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
541v3_sxnet.o: ../../include/openssl/cast.h ../../include/openssl/conf.h
542v3_sxnet.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
543v3_sxnet.o: ../../include/openssl/des_old.h ../../include/openssl/dh.h
544v3_sxnet.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
545v3_sxnet.o: ../../include/openssl/err.h ../../include/openssl/evp.h
546v3_sxnet.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h
547v3_sxnet.o: ../../include/openssl/md2.h ../../include/openssl/md4.h
548v3_sxnet.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
549v3_sxnet.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
550v3_sxnet.o: ../../include/openssl/opensslconf.h
551v3_sxnet.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
552v3_sxnet.o: ../../include/openssl/pkcs7.h ../../include/openssl/rc2.h
553v3_sxnet.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
554v3_sxnet.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
555v3_sxnet.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
556v3_sxnet.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
557v3_sxnet.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
558v3_sxnet.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
559v3_sxnet.o: ../../include/openssl/x509v3.h ../cryptlib.h v3_sxnet.c
560v3_utl.o: ../../e_os.h ../../include/openssl/aes.h ../../include/openssl/asn1.h
561v3_utl.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h
562v3_utl.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
563v3_utl.o: ../../include/openssl/cast.h ../../include/openssl/conf.h
564v3_utl.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
565v3_utl.o: ../../include/openssl/des_old.h ../../include/openssl/dh.h
566v3_utl.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
567v3_utl.o: ../../include/openssl/err.h ../../include/openssl/evp.h
568v3_utl.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h
569v3_utl.o: ../../include/openssl/md2.h ../../include/openssl/md4.h
570v3_utl.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
571v3_utl.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
572v3_utl.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
573v3_utl.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h
574v3_utl.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h
575v3_utl.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h
576v3_utl.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
577v3_utl.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
578v3_utl.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
579v3_utl.o: ../../include/openssl/ui_compat.h ../../include/openssl/x509.h
580v3_utl.o: ../../include/openssl/x509_vfy.h ../../include/openssl/x509v3.h
581v3_utl.o: ../cryptlib.h v3_utl.c
582v3err.o: ../../include/openssl/aes.h ../../include/openssl/asn1.h
583v3err.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h
584v3err.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
585v3err.o: ../../include/openssl/cast.h ../../include/openssl/conf.h
586v3err.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
587v3err.o: ../../include/openssl/des_old.h ../../include/openssl/dh.h
588v3err.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
589v3err.o: ../../include/openssl/err.h ../../include/openssl/evp.h
590v3err.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h
591v3err.o: ../../include/openssl/md2.h ../../include/openssl/md4.h
592v3err.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
593v3err.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
594v3err.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
595v3err.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h
596v3err.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h
597v3err.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h
598v3err.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
599v3err.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
600v3err.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
601v3err.o: ../../include/openssl/ui_compat.h ../../include/openssl/x509.h
602v3err.o: ../../include/openssl/x509_vfy.h ../../include/openssl/x509v3.h
603v3err.o: v3err.c
diff --git a/src/lib/libcrypto/x509v3/ext_dat.h b/src/lib/libcrypto/x509v3/ext_dat.h
index 3eaec46f8a..76daee6fcd 100644
--- a/src/lib/libcrypto/x509v3/ext_dat.h
+++ b/src/lib/libcrypto/x509v3/ext_dat.h
@@ -61,21 +61,19 @@ extern X509V3_EXT_METHOD v3_bcons, v3_nscert, v3_key_usage, v3_ext_ku;
61extern X509V3_EXT_METHOD v3_pkey_usage_period, v3_sxnet, v3_info, v3_sinfo; 61extern X509V3_EXT_METHOD v3_pkey_usage_period, v3_sxnet, v3_info, v3_sinfo;
62extern X509V3_EXT_METHOD v3_ns_ia5_list[], v3_alt[], v3_skey_id, v3_akey_id; 62extern X509V3_EXT_METHOD v3_ns_ia5_list[], v3_alt[], v3_skey_id, v3_akey_id;
63extern X509V3_EXT_METHOD v3_crl_num, v3_crl_reason, v3_crl_invdate; 63extern X509V3_EXT_METHOD v3_crl_num, v3_crl_reason, v3_crl_invdate;
64extern X509V3_EXT_METHOD v3_delta_crl, v3_cpols, v3_crld; 64extern X509V3_EXT_METHOD v3_delta_crl, v3_cpols, v3_crld, v3_freshest_crl;
65extern X509V3_EXT_METHOD v3_ocsp_nonce, v3_ocsp_accresp, v3_ocsp_acutoff; 65extern X509V3_EXT_METHOD v3_ocsp_nonce, v3_ocsp_accresp, v3_ocsp_acutoff;
66extern X509V3_EXT_METHOD v3_ocsp_crlid, v3_ocsp_nocheck, v3_ocsp_serviceloc; 66extern X509V3_EXT_METHOD v3_ocsp_crlid, v3_ocsp_nocheck, v3_ocsp_serviceloc;
67extern X509V3_EXT_METHOD v3_crl_hold, v3_pci; 67extern X509V3_EXT_METHOD v3_crl_hold, v3_pci;
68extern X509V3_EXT_METHOD v3_policy_mappings, v3_policy_constraints; 68extern X509V3_EXT_METHOD v3_policy_mappings, v3_policy_constraints;
69extern X509V3_EXT_METHOD v3_name_constraints, v3_inhibit_anyp; 69extern X509V3_EXT_METHOD v3_name_constraints, v3_inhibit_anyp, v3_idp;
70#ifndef OPENSSL_NO_RFC3779
71extern X509V3_EXT_METHOD v3_addr, v3_asid; 70extern X509V3_EXT_METHOD v3_addr, v3_asid;
72#endif
73 71
74/* This table will be searched using OBJ_bsearch so it *must* kept in 72/* This table will be searched using OBJ_bsearch so it *must* kept in
75 * order of the ext_nid values. 73 * order of the ext_nid values.
76 */ 74 */
77 75
78static X509V3_EXT_METHOD *standard_exts[] = { 76static const X509V3_EXT_METHOD *standard_exts[] = {
79&v3_nscert, 77&v3_nscert,
80&v3_ns_ia5_list[0], 78&v3_ns_ia5_list[0],
81&v3_ns_ia5_list[1], 79&v3_ns_ia5_list[1],
@@ -122,7 +120,10 @@ static X509V3_EXT_METHOD *standard_exts[] = {
122&v3_pci, 120&v3_pci,
123&v3_name_constraints, 121&v3_name_constraints,
124&v3_policy_mappings, 122&v3_policy_mappings,
125&v3_inhibit_anyp 123&v3_inhibit_anyp,
124&v3_idp,
125&v3_alt[2],
126&v3_freshest_crl,
126}; 127};
127 128
128/* Number of standard extensions */ 129/* Number of standard extensions */
diff --git a/src/lib/libcrypto/x509v3/pcy_data.c b/src/lib/libcrypto/x509v3/pcy_data.c
index fb392b901f..3444b03195 100644
--- a/src/lib/libcrypto/x509v3/pcy_data.c
+++ b/src/lib/libcrypto/x509v3/pcy_data.c
@@ -82,17 +82,21 @@ void policy_data_free(X509_POLICY_DATA *data)
82 * another source. 82 * another source.
83 */ 83 */
84 84
85X509_POLICY_DATA *policy_data_new(POLICYINFO *policy, ASN1_OBJECT *id, int crit) 85X509_POLICY_DATA *policy_data_new(POLICYINFO *policy,
86 const ASN1_OBJECT *cid, int crit)
86 { 87 {
87 X509_POLICY_DATA *ret; 88 X509_POLICY_DATA *ret;
88 if (!policy && !id) 89 ASN1_OBJECT *id;
90 if (!policy && !cid)
89 return NULL; 91 return NULL;
90 if (id) 92 if (cid)
91 { 93 {
92 id = OBJ_dup(id); 94 id = OBJ_dup(cid);
93 if (!id) 95 if (!id)
94 return NULL; 96 return NULL;
95 } 97 }
98 else
99 id = NULL;
96 ret = OPENSSL_malloc(sizeof(X509_POLICY_DATA)); 100 ret = OPENSSL_malloc(sizeof(X509_POLICY_DATA));
97 if (!ret) 101 if (!ret)
98 return NULL; 102 return NULL;
diff --git a/src/lib/libcrypto/x509v3/pcy_tree.c b/src/lib/libcrypto/x509v3/pcy_tree.c
index 6c87a7f506..92f6b24556 100644
--- a/src/lib/libcrypto/x509v3/pcy_tree.c
+++ b/src/lib/libcrypto/x509v3/pcy_tree.c
@@ -62,6 +62,75 @@
62 62
63#include "pcy_int.h" 63#include "pcy_int.h"
64 64
65/* Enable this to print out the complete policy tree at various point during
66 * evaluation.
67 */
68
69/*#define OPENSSL_POLICY_DEBUG*/
70
71#ifdef OPENSSL_POLICY_DEBUG
72
73static void expected_print(BIO *err, X509_POLICY_LEVEL *lev,
74 X509_POLICY_NODE *node, int indent)
75 {
76 if ( (lev->flags & X509_V_FLAG_INHIBIT_MAP)
77 || !(node->data->flags & POLICY_DATA_FLAG_MAP_MASK))
78 BIO_puts(err, " Not Mapped\n");
79 else
80 {
81 int i;
82 STACK_OF(ASN1_OBJECT) *pset = node->data->expected_policy_set;
83 ASN1_OBJECT *oid;
84 BIO_puts(err, " Expected: ");
85 for (i = 0; i < sk_ASN1_OBJECT_num(pset); i++)
86 {
87 oid = sk_ASN1_OBJECT_value(pset, i);
88 if (i)
89 BIO_puts(err, ", ");
90 i2a_ASN1_OBJECT(err, oid);
91 }
92 BIO_puts(err, "\n");
93 }
94 }
95
96static void tree_print(char *str, X509_POLICY_TREE *tree,
97 X509_POLICY_LEVEL *curr)
98 {
99 X509_POLICY_LEVEL *plev;
100 X509_POLICY_NODE *node;
101 int i;
102 BIO *err;
103 err = BIO_new_fp(stderr, BIO_NOCLOSE);
104 if (!curr)
105 curr = tree->levels + tree->nlevel;
106 else
107 curr++;
108 BIO_printf(err, "Level print after %s\n", str);
109 BIO_printf(err, "Printing Up to Level %ld\n", curr - tree->levels);
110 for (plev = tree->levels; plev != curr; plev++)
111 {
112 BIO_printf(err, "Level %ld, flags = %x\n",
113 plev - tree->levels, plev->flags);
114 for (i = 0; i < sk_X509_POLICY_NODE_num(plev->nodes); i++)
115 {
116 node = sk_X509_POLICY_NODE_value(plev->nodes, i);
117 X509_POLICY_NODE_print(err, node, 2);
118 expected_print(err, plev, node, 2);
119 BIO_printf(err, " Flags: %x\n", node->data->flags);
120 }
121 if (plev->anyPolicy)
122 X509_POLICY_NODE_print(err, plev->anyPolicy, 2);
123 }
124
125 BIO_free(err);
126
127 }
128#else
129
130#define tree_print(a,b,c) /* */
131
132#endif
133
65/* Initialize policy tree. Return values: 134/* Initialize policy tree. Return values:
66 * 0 Some internal error occured. 135 * 0 Some internal error occured.
67 * -1 Inconsistent or invalid extensions in certificates. 136 * -1 Inconsistent or invalid extensions in certificates.
@@ -87,8 +156,10 @@ static int tree_init(X509_POLICY_TREE **ptree, STACK_OF(X509) *certs,
87 *ptree = NULL; 156 *ptree = NULL;
88 n = sk_X509_num(certs); 157 n = sk_X509_num(certs);
89 158
159#if 0
90 /* Disable policy mapping for now... */ 160 /* Disable policy mapping for now... */
91 flags |= X509_V_FLAG_INHIBIT_MAP; 161 flags |= X509_V_FLAG_INHIBIT_MAP;
162#endif
92 163
93 if (flags & X509_V_FLAG_EXPLICIT_POLICY) 164 if (flags & X509_V_FLAG_EXPLICIT_POLICY)
94 explicit_policy = 0; 165 explicit_policy = 0;
@@ -160,7 +231,7 @@ static int tree_init(X509_POLICY_TREE **ptree, STACK_OF(X509) *certs,
160 tree->auth_policies = NULL; 231 tree->auth_policies = NULL;
161 tree->user_policies = NULL; 232 tree->user_policies = NULL;
162 233
163 if (!tree) 234 if (!tree->levels)
164 { 235 {
165 OPENSSL_free(tree); 236 OPENSSL_free(tree);
166 return 0; 237 return 0;
@@ -184,7 +255,6 @@ static int tree_init(X509_POLICY_TREE **ptree, STACK_OF(X509) *certs,
184 level++; 255 level++;
185 x = sk_X509_value(certs, i); 256 x = sk_X509_value(certs, i);
186 cache = policy_cache_set(x); 257 cache = policy_cache_set(x);
187
188 CRYPTO_add(&x->references, 1, CRYPTO_LOCK_X509); 258 CRYPTO_add(&x->references, 1, CRYPTO_LOCK_X509);
189 level->cert = x; 259 level->cert = x;
190 260
@@ -213,13 +283,13 @@ static int tree_init(X509_POLICY_TREE **ptree, STACK_OF(X509) *certs,
213 level->flags |= X509_V_FLAG_INHIBIT_MAP; 283 level->flags |= X509_V_FLAG_INHIBIT_MAP;
214 else 284 else
215 { 285 {
216 map_skip--; 286 if (!(x->ex_flags & EXFLAG_SI))
287 map_skip--;
217 if ((cache->map_skip >= 0) 288 if ((cache->map_skip >= 0)
218 && (cache->map_skip < map_skip)) 289 && (cache->map_skip < map_skip))
219 map_skip = cache->map_skip; 290 map_skip = cache->map_skip;
220 } 291 }
221 292
222
223 } 293 }
224 294
225 *ptree = tree; 295 *ptree = tree;
@@ -237,7 +307,32 @@ static int tree_init(X509_POLICY_TREE **ptree, STACK_OF(X509) *certs,
237 307
238 } 308 }
239 309
240/* This corresponds to RFC3280 XXXX XXXXX: 310static int tree_link_matching_nodes(X509_POLICY_LEVEL *curr,
311 const X509_POLICY_DATA *data)
312 {
313 X509_POLICY_LEVEL *last = curr - 1;
314 X509_POLICY_NODE *node;
315 int i, matched = 0;
316 /* Iterate through all in nodes linking matches */
317 for (i = 0; i < sk_X509_POLICY_NODE_num(last->nodes); i++)
318 {
319 node = sk_X509_POLICY_NODE_value(last->nodes, i);
320 if (policy_node_match(last, node, data->valid_policy))
321 {
322 if (!level_add_node(curr, data, node, NULL))
323 return 0;
324 matched = 1;
325 }
326 }
327 if (!matched && last->anyPolicy)
328 {
329 if (!level_add_node(curr, data, last->anyPolicy, NULL))
330 return 0;
331 }
332 return 1;
333 }
334
335/* This corresponds to RFC3280 6.1.3(d)(1):
241 * link any data from CertificatePolicies onto matching parent 336 * link any data from CertificatePolicies onto matching parent
242 * or anyPolicy if no match. 337 * or anyPolicy if no match.
243 */ 338 */
@@ -248,7 +343,6 @@ static int tree_link_nodes(X509_POLICY_LEVEL *curr,
248 int i; 343 int i;
249 X509_POLICY_LEVEL *last; 344 X509_POLICY_LEVEL *last;
250 X509_POLICY_DATA *data; 345 X509_POLICY_DATA *data;
251 X509_POLICY_NODE *parent;
252 last = curr - 1; 346 last = curr - 1;
253 for (i = 0; i < sk_X509_POLICY_DATA_num(cache->data); i++) 347 for (i = 0; i < sk_X509_POLICY_DATA_num(cache->data); i++)
254 { 348 {
@@ -261,40 +355,109 @@ static int tree_link_nodes(X509_POLICY_LEVEL *curr,
261 * link because then it will have the mapping flags 355 * link because then it will have the mapping flags
262 * right and we can prune it later. 356 * right and we can prune it later.
263 */ 357 */
358#if 0
264 if ((data->flags & POLICY_DATA_FLAG_MAPPED_ANY) 359 if ((data->flags & POLICY_DATA_FLAG_MAPPED_ANY)
265 && !(curr->flags & X509_V_FLAG_INHIBIT_ANY)) 360 && !(curr->flags & X509_V_FLAG_INHIBIT_ANY))
266 continue; 361 continue;
267 /* Look for matching node in parent */ 362#endif
268 parent = level_find_node(last, data->valid_policy); 363 /* Look for matching nodes in previous level */
269 /* If no match link to anyPolicy */ 364 if (!tree_link_matching_nodes(curr, data))
270 if (!parent)
271 parent = last->anyPolicy;
272 if (parent && !level_add_node(curr, data, parent, NULL))
273 return 0; 365 return 0;
274 } 366 }
275 return 1; 367 return 1;
276 } 368 }
277 369
278/* This corresponds to RFC3280 XXXX XXXXX: 370/* This corresponds to RFC3280 6.1.3(d)(2):
279 * Create new data for any unmatched policies in the parent and link 371 * Create new data for any unmatched policies in the parent and link
280 * to anyPolicy. 372 * to anyPolicy.
281 */ 373 */
282 374
375static int tree_add_unmatched(X509_POLICY_LEVEL *curr,
376 const X509_POLICY_CACHE *cache,
377 const ASN1_OBJECT *id,
378 X509_POLICY_NODE *node,
379 X509_POLICY_TREE *tree)
380 {
381 X509_POLICY_DATA *data;
382 if (id == NULL)
383 id = node->data->valid_policy;
384 /* Create a new node with qualifiers from anyPolicy and
385 * id from unmatched node.
386 */
387 data = policy_data_new(NULL, id, node_critical(node));
388
389 if (data == NULL)
390 return 0;
391 /* Curr may not have anyPolicy */
392 data->qualifier_set = cache->anyPolicy->qualifier_set;
393 data->flags |= POLICY_DATA_FLAG_SHARED_QUALIFIERS;
394 if (!level_add_node(curr, data, node, tree))
395 {
396 policy_data_free(data);
397 return 0;
398 }
399
400 return 1;
401 }
402
403static int tree_link_unmatched(X509_POLICY_LEVEL *curr,
404 const X509_POLICY_CACHE *cache,
405 X509_POLICY_NODE *node,
406 X509_POLICY_TREE *tree)
407 {
408 const X509_POLICY_LEVEL *last = curr - 1;
409 int i;
410
411 if ( (last->flags & X509_V_FLAG_INHIBIT_MAP)
412 || !(node->data->flags & POLICY_DATA_FLAG_MAPPED))
413 {
414 /* If no policy mapping: matched if one child present */
415 if (node->nchild)
416 return 1;
417 if (!tree_add_unmatched(curr, cache, NULL, node, tree))
418 return 0;
419 /* Add it */
420 }
421 else
422 {
423 /* If mapping: matched if one child per expected policy set */
424 STACK_OF(ASN1_OBJECT) *expset = node->data->expected_policy_set;
425 if (node->nchild == sk_ASN1_OBJECT_num(expset))
426 return 1;
427 /* Locate unmatched nodes */
428 for (i = 0; i < sk_ASN1_OBJECT_num(expset); i++)
429 {
430 ASN1_OBJECT *oid = sk_ASN1_OBJECT_value(expset, i);
431 if (level_find_node(curr, node, oid))
432 continue;
433 if (!tree_add_unmatched(curr, cache, oid, node, tree))
434 return 0;
435 }
436
437 }
438
439 return 1;
440
441 }
442
283static int tree_link_any(X509_POLICY_LEVEL *curr, 443static int tree_link_any(X509_POLICY_LEVEL *curr,
284 const X509_POLICY_CACHE *cache, 444 const X509_POLICY_CACHE *cache,
285 X509_POLICY_TREE *tree) 445 X509_POLICY_TREE *tree)
286 { 446 {
287 int i; 447 int i;
288 X509_POLICY_DATA *data; 448 /*X509_POLICY_DATA *data;*/
289 X509_POLICY_NODE *node; 449 X509_POLICY_NODE *node;
290 X509_POLICY_LEVEL *last; 450 X509_POLICY_LEVEL *last = curr - 1;
291
292 last = curr - 1;
293 451
294 for (i = 0; i < sk_X509_POLICY_NODE_num(last->nodes); i++) 452 for (i = 0; i < sk_X509_POLICY_NODE_num(last->nodes); i++)
295 { 453 {
296 node = sk_X509_POLICY_NODE_value(last->nodes, i); 454 node = sk_X509_POLICY_NODE_value(last->nodes, i);
297 455
456 if (!tree_link_unmatched(curr, cache, node, tree))
457 return 0;
458
459#if 0
460
298 /* Skip any node with any children: we only want unmathced 461 /* Skip any node with any children: we only want unmathced
299 * nodes. 462 * nodes.
300 * 463 *
@@ -303,6 +466,7 @@ static int tree_link_any(X509_POLICY_LEVEL *curr,
303 */ 466 */
304 if (node->nchild) 467 if (node->nchild)
305 continue; 468 continue;
469
306 /* Create a new node with qualifiers from anyPolicy and 470 /* Create a new node with qualifiers from anyPolicy and
307 * id from unmatched node. 471 * id from unmatched node.
308 */ 472 */
@@ -319,6 +483,9 @@ static int tree_link_any(X509_POLICY_LEVEL *curr,
319 policy_data_free(data); 483 policy_data_free(data);
320 return 0; 484 return 0;
321 } 485 }
486
487#endif
488
322 } 489 }
323 /* Finally add link to anyPolicy */ 490 /* Finally add link to anyPolicy */
324 if (last->anyPolicy) 491 if (last->anyPolicy)
@@ -337,30 +504,36 @@ static int tree_link_any(X509_POLICY_LEVEL *curr,
337 504
338static int tree_prune(X509_POLICY_TREE *tree, X509_POLICY_LEVEL *curr) 505static int tree_prune(X509_POLICY_TREE *tree, X509_POLICY_LEVEL *curr)
339 { 506 {
507 STACK_OF(X509_POLICY_NODE) *nodes;
340 X509_POLICY_NODE *node; 508 X509_POLICY_NODE *node;
341 int i; 509 int i;
342 for (i = sk_X509_POLICY_NODE_num(curr->nodes) - 1; i >= 0; i--) 510 nodes = curr->nodes;
511 if (curr->flags & X509_V_FLAG_INHIBIT_MAP)
343 { 512 {
344 node = sk_X509_POLICY_NODE_value(curr->nodes, i); 513 for (i = sk_X509_POLICY_NODE_num(nodes) - 1; i >= 0; i--)
345 /* Delete any mapped data: see RFC3280 XXXX */
346 if (node->data->flags & POLICY_DATA_FLAG_MAP_MASK)
347 { 514 {
348 node->parent->nchild--; 515 node = sk_X509_POLICY_NODE_value(nodes, i);
349 OPENSSL_free(node); 516 /* Delete any mapped data: see RFC3280 XXXX */
350 (void)sk_X509_POLICY_NODE_delete(curr->nodes, i); 517 if (node->data->flags & POLICY_DATA_FLAG_MAP_MASK)
518 {
519 node->parent->nchild--;
520 OPENSSL_free(node);
521 (void)sk_X509_POLICY_NODE_delete(nodes,i);
522 }
351 } 523 }
352 } 524 }
353 525
354 for(;;) { 526 for(;;) {
355 --curr; 527 --curr;
356 for (i = sk_X509_POLICY_NODE_num(curr->nodes) - 1; i >= 0; i--) 528 nodes = curr->nodes;
529 for (i = sk_X509_POLICY_NODE_num(nodes) - 1; i >= 0; i--)
357 { 530 {
358 node = sk_X509_POLICY_NODE_value(curr->nodes, i); 531 node = sk_X509_POLICY_NODE_value(nodes, i);
359 if (node->nchild == 0) 532 if (node->nchild == 0)
360 { 533 {
361 node->parent->nchild--; 534 node->parent->nchild--;
362 OPENSSL_free(node); 535 OPENSSL_free(node);
363 (void)sk_X509_POLICY_NODE_delete(curr->nodes, i); 536 (void)sk_X509_POLICY_NODE_delete(nodes, i);
364 } 537 }
365 } 538 }
366 if (curr->anyPolicy && !curr->anyPolicy->nchild) 539 if (curr->anyPolicy && !curr->anyPolicy->nchild)
@@ -536,6 +709,7 @@ static int tree_evaluate(X509_POLICY_TREE *tree)
536 if (!(curr->flags & X509_V_FLAG_INHIBIT_ANY) 709 if (!(curr->flags & X509_V_FLAG_INHIBIT_ANY)
537 && !tree_link_any(curr, cache, tree)) 710 && !tree_link_any(curr, cache, tree))
538 return 0; 711 return 0;
712 tree_print("before tree_prune()", tree, curr);
539 ret = tree_prune(tree, curr); 713 ret = tree_prune(tree, curr);
540 if (ret != 1) 714 if (ret != 1)
541 return ret; 715 return ret;
@@ -604,7 +778,6 @@ int X509_policy_check(X509_POLICY_TREE **ptree, int *pexplicit_policy,
604 *pexplicit_policy = 0; 778 *pexplicit_policy = 0;
605 ret = tree_init(&tree, certs, flags); 779 ret = tree_init(&tree, certs, flags);
606 780
607
608 switch (ret) 781 switch (ret)
609 { 782 {
610 783
@@ -613,6 +786,10 @@ int X509_policy_check(X509_POLICY_TREE **ptree, int *pexplicit_policy,
613 return 1; 786 return 1;
614 787
615 /* Some internal error */ 788 /* Some internal error */
789 case -1:
790 return -1;
791
792 /* Some internal error */
616 case 0: 793 case 0:
617 return 0; 794 return 0;
618 795
@@ -646,6 +823,8 @@ int X509_policy_check(X509_POLICY_TREE **ptree, int *pexplicit_policy,
646 if (!tree) goto error; 823 if (!tree) goto error;
647 ret = tree_evaluate(tree); 824 ret = tree_evaluate(tree);
648 825
826 tree_print("tree_evaluate()", tree, NULL);
827
649 if (ret <= 0) 828 if (ret <= 0)
650 goto error; 829 goto error;
651 830
diff --git a/src/lib/libcrypto/x509v3/v3_addr.c b/src/lib/libcrypto/x509v3/v3_addr.c
index efdf7c3ba7..9087d66e0a 100644
--- a/src/lib/libcrypto/x509v3/v3_addr.c
+++ b/src/lib/libcrypto/x509v3/v3_addr.c
@@ -236,7 +236,7 @@ static int i2r_IPAddressOrRanges(BIO *out,
236/* 236/*
237 * i2r handler for an IPAddrBlocks extension. 237 * i2r handler for an IPAddrBlocks extension.
238 */ 238 */
239static int i2r_IPAddrBlocks(X509V3_EXT_METHOD *method, 239static int i2r_IPAddrBlocks(const X509V3_EXT_METHOD *method,
240 void *ext, 240 void *ext,
241 BIO *out, 241 BIO *out,
242 int indent) 242 int indent)
@@ -315,8 +315,7 @@ static int IPAddressOrRange_cmp(const IPAddressOrRange *a,
315 const int length) 315 const int length)
316{ 316{
317 unsigned char addr_a[ADDR_RAW_BUF_LEN], addr_b[ADDR_RAW_BUF_LEN]; 317 unsigned char addr_a[ADDR_RAW_BUF_LEN], addr_b[ADDR_RAW_BUF_LEN];
318 int prefixlen_a = 0; 318 int prefixlen_a = 0, prefixlen_b = 0;
319 int prefixlen_b = 0;
320 int r; 319 int r;
321 320
322 switch (a->type) { 321 switch (a->type) {
@@ -596,10 +595,10 @@ static IPAddressOrRanges *make_prefix_or_range(IPAddrBlocks *addr,
596 return NULL; 595 return NULL;
597 switch (afi) { 596 switch (afi) {
598 case IANA_AFI_IPV4: 597 case IANA_AFI_IPV4:
599 (void)sk_IPAddressOrRange_set_cmp_func(aors, v4IPAddressOrRange_cmp); 598 sk_IPAddressOrRange_set_cmp_func(aors, v4IPAddressOrRange_cmp);
600 break; 599 break;
601 case IANA_AFI_IPV6: 600 case IANA_AFI_IPV6:
602 (void)sk_IPAddressOrRange_set_cmp_func(aors, v6IPAddressOrRange_cmp); 601 sk_IPAddressOrRange_set_cmp_func(aors, v6IPAddressOrRange_cmp);
603 break; 602 break;
604 } 603 }
605 f->ipAddressChoice->type = IPAddressChoice_addressesOrRanges; 604 f->ipAddressChoice->type = IPAddressChoice_addressesOrRanges;
@@ -856,7 +855,7 @@ static int IPAddressOrRanges_canonize(IPAddressOrRanges *aors,
856 if (!make_addressRange(&merged, a_min, b_max, length)) 855 if (!make_addressRange(&merged, a_min, b_max, length))
857 return 0; 856 return 0;
858 sk_IPAddressOrRange_set(aors, i, merged); 857 sk_IPAddressOrRange_set(aors, i, merged);
859 (void)sk_IPAddressOrRange_delete(aors, i + 1); 858 sk_IPAddressOrRange_delete(aors, i + 1);
860 IPAddressOrRange_free(a); 859 IPAddressOrRange_free(a);
861 IPAddressOrRange_free(b); 860 IPAddressOrRange_free(b);
862 --i; 861 --i;
@@ -880,7 +879,7 @@ int v3_addr_canonize(IPAddrBlocks *addr)
880 v3_addr_get_afi(f))) 879 v3_addr_get_afi(f)))
881 return 0; 880 return 0;
882 } 881 }
883 (void)sk_IPAddressFamily_set_cmp_func(addr, IPAddressFamily_cmp); 882 sk_IPAddressFamily_set_cmp_func(addr, IPAddressFamily_cmp);
884 sk_IPAddressFamily_sort(addr); 883 sk_IPAddressFamily_sort(addr);
885 OPENSSL_assert(v3_addr_is_canonical(addr)); 884 OPENSSL_assert(v3_addr_is_canonical(addr));
886 return 1; 885 return 1;
@@ -889,7 +888,7 @@ int v3_addr_canonize(IPAddrBlocks *addr)
889/* 888/*
890 * v2i handler for the IPAddrBlocks extension. 889 * v2i handler for the IPAddrBlocks extension.
891 */ 890 */
892static void *v2i_IPAddrBlocks(struct v3_ext_method *method, 891static void *v2i_IPAddrBlocks(const struct v3_ext_method *method,
893 struct v3_ext_ctx *ctx, 892 struct v3_ext_ctx *ctx,
894 STACK_OF(CONF_VALUE) *values) 893 STACK_OF(CONF_VALUE) *values)
895{ 894{
@@ -1125,7 +1124,7 @@ int v3_addr_subset(IPAddrBlocks *a, IPAddrBlocks *b)
1125 return 1; 1124 return 1;
1126 if (b == NULL || v3_addr_inherits(a) || v3_addr_inherits(b)) 1125 if (b == NULL || v3_addr_inherits(a) || v3_addr_inherits(b))
1127 return 0; 1126 return 0;
1128 (void)sk_IPAddressFamily_set_cmp_func(b, IPAddressFamily_cmp); 1127 sk_IPAddressFamily_set_cmp_func(b, IPAddressFamily_cmp);
1129 for (i = 0; i < sk_IPAddressFamily_num(a); i++) { 1128 for (i = 0; i < sk_IPAddressFamily_num(a); i++) {
1130 IPAddressFamily *fa = sk_IPAddressFamily_value(a, i); 1129 IPAddressFamily *fa = sk_IPAddressFamily_value(a, i);
1131 int j = sk_IPAddressFamily_find(b, fa); 1130 int j = sk_IPAddressFamily_find(b, fa);
@@ -1167,7 +1166,7 @@ static int v3_addr_validate_path_internal(X509_STORE_CTX *ctx,
1167{ 1166{
1168 IPAddrBlocks *child = NULL; 1167 IPAddrBlocks *child = NULL;
1169 int i, j, ret = 1; 1168 int i, j, ret = 1;
1170 X509 *x = NULL; 1169 X509 *x;
1171 1170
1172 OPENSSL_assert(chain != NULL && sk_X509_num(chain) > 0); 1171 OPENSSL_assert(chain != NULL && sk_X509_num(chain) > 0);
1173 OPENSSL_assert(ctx != NULL || ext != NULL); 1172 OPENSSL_assert(ctx != NULL || ext != NULL);
@@ -1180,6 +1179,7 @@ static int v3_addr_validate_path_internal(X509_STORE_CTX *ctx,
1180 */ 1179 */
1181 if (ext != NULL) { 1180 if (ext != NULL) {
1182 i = -1; 1181 i = -1;
1182 x = NULL;
1183 } else { 1183 } else {
1184 i = 0; 1184 i = 0;
1185 x = sk_X509_value(chain, i); 1185 x = sk_X509_value(chain, i);
@@ -1189,7 +1189,7 @@ static int v3_addr_validate_path_internal(X509_STORE_CTX *ctx,
1189 } 1189 }
1190 if (!v3_addr_is_canonical(ext)) 1190 if (!v3_addr_is_canonical(ext))
1191 validation_err(X509_V_ERR_INVALID_EXTENSION); 1191 validation_err(X509_V_ERR_INVALID_EXTENSION);
1192 (void)sk_IPAddressFamily_set_cmp_func(ext, IPAddressFamily_cmp); 1192 sk_IPAddressFamily_set_cmp_func(ext, IPAddressFamily_cmp);
1193 if ((child = sk_IPAddressFamily_dup(ext)) == NULL) { 1193 if ((child = sk_IPAddressFamily_dup(ext)) == NULL) {
1194 X509V3err(X509V3_F_V3_ADDR_VALIDATE_PATH_INTERNAL, ERR_R_MALLOC_FAILURE); 1194 X509V3err(X509V3_F_V3_ADDR_VALIDATE_PATH_INTERNAL, ERR_R_MALLOC_FAILURE);
1195 ret = 0; 1195 ret = 0;
@@ -1215,7 +1215,7 @@ static int v3_addr_validate_path_internal(X509_STORE_CTX *ctx,
1215 } 1215 }
1216 continue; 1216 continue;
1217 } 1217 }
1218 (void)sk_IPAddressFamily_set_cmp_func(x->rfc3779_addr, IPAddressFamily_cmp); 1218 sk_IPAddressFamily_set_cmp_func(x->rfc3779_addr, IPAddressFamily_cmp);
1219 for (j = 0; j < sk_IPAddressFamily_num(child); j++) { 1219 for (j = 0; j < sk_IPAddressFamily_num(child); j++) {
1220 IPAddressFamily *fc = sk_IPAddressFamily_value(child, j); 1220 IPAddressFamily *fc = sk_IPAddressFamily_value(child, j);
1221 int k = sk_IPAddressFamily_find(x->rfc3779_addr, fc); 1221 int k = sk_IPAddressFamily_find(x->rfc3779_addr, fc);
@@ -1242,6 +1242,7 @@ static int v3_addr_validate_path_internal(X509_STORE_CTX *ctx,
1242 /* 1242 /*
1243 * Trust anchor can't inherit. 1243 * Trust anchor can't inherit.
1244 */ 1244 */
1245 OPENSSL_assert(x != NULL);
1245 if (x->rfc3779_addr != NULL) { 1246 if (x->rfc3779_addr != NULL) {
1246 for (j = 0; j < sk_IPAddressFamily_num(x->rfc3779_addr); j++) { 1247 for (j = 0; j < sk_IPAddressFamily_num(x->rfc3779_addr); j++) {
1247 IPAddressFamily *fp = sk_IPAddressFamily_value(x->rfc3779_addr, j); 1248 IPAddressFamily *fp = sk_IPAddressFamily_value(x->rfc3779_addr, j);
diff --git a/src/lib/libcrypto/x509v3/v3_alt.c b/src/lib/libcrypto/x509v3/v3_alt.c
index 75fda7f268..91aefcddc1 100644
--- a/src/lib/libcrypto/x509v3/v3_alt.c
+++ b/src/lib/libcrypto/x509v3/v3_alt.c
@@ -82,6 +82,12 @@ NULL, NULL, NULL},
82(X509V3_EXT_I2V)i2v_GENERAL_NAMES, 82(X509V3_EXT_I2V)i2v_GENERAL_NAMES,
83(X509V3_EXT_V2I)v2i_issuer_alt, 83(X509V3_EXT_V2I)v2i_issuer_alt,
84NULL, NULL, NULL}, 84NULL, NULL, NULL},
85
86{ NID_certificate_issuer, 0, ASN1_ITEM_ref(GENERAL_NAMES),
870,0,0,0,
880,0,
89(X509V3_EXT_I2V)i2v_GENERAL_NAMES,
90NULL, NULL, NULL, NULL},
85}; 91};
86 92
87STACK_OF(CONF_VALUE) *i2v_GENERAL_NAMES(X509V3_EXT_METHOD *method, 93STACK_OF(CONF_VALUE) *i2v_GENERAL_NAMES(X509V3_EXT_METHOD *method,
@@ -147,9 +153,9 @@ STACK_OF(CONF_VALUE) *i2v_GENERAL_NAME(X509V3_EXT_METHOD *method,
147 BIO_snprintf(htmp, sizeof htmp, 153 BIO_snprintf(htmp, sizeof htmp,
148 "%X", p[0] << 8 | p[1]); 154 "%X", p[0] << 8 | p[1]);
149 p += 2; 155 p += 2;
150 strlcat(oline, htmp, sizeof oline); 156 strlcat(oline, htmp, sizeof(oline));
151 if (i != 7) 157 if (i != 7)
152 strlcat(oline, ":", sizeof oline); 158 strlcat(oline, ":", sizeof(oline));
153 } 159 }
154 } 160 }
155 else 161 else
@@ -360,6 +366,7 @@ static int copy_email(X509V3_CTX *ctx, GENERAL_NAMES *gens, int move_p)
360 if (move_p) 366 if (move_p)
361 { 367 {
362 X509_NAME_delete_entry(nm, i); 368 X509_NAME_delete_entry(nm, i);
369 X509_NAME_ENTRY_free(ne);
363 i--; 370 i--;
364 } 371 }
365 if(!email || !(gen = GENERAL_NAME_new())) { 372 if(!email || !(gen = GENERAL_NAME_new())) {
@@ -386,8 +393,8 @@ static int copy_email(X509V3_CTX *ctx, GENERAL_NAMES *gens, int move_p)
386 393
387} 394}
388 395
389GENERAL_NAMES *v2i_GENERAL_NAMES(X509V3_EXT_METHOD *method, 396GENERAL_NAMES *v2i_GENERAL_NAMES(const X509V3_EXT_METHOD *method,
390 X509V3_CTX *ctx, STACK_OF(CONF_VALUE) *nval) 397 X509V3_CTX *ctx, STACK_OF(CONF_VALUE) *nval)
391{ 398{
392 GENERAL_NAME *gen; 399 GENERAL_NAME *gen;
393 GENERAL_NAMES *gens = NULL; 400 GENERAL_NAMES *gens = NULL;
@@ -408,28 +415,22 @@ GENERAL_NAMES *v2i_GENERAL_NAMES(X509V3_EXT_METHOD *method,
408 return NULL; 415 return NULL;
409} 416}
410 417
411GENERAL_NAME *v2i_GENERAL_NAME(X509V3_EXT_METHOD *method, X509V3_CTX *ctx, 418GENERAL_NAME *v2i_GENERAL_NAME(const X509V3_EXT_METHOD *method, X509V3_CTX *ctx,
412 CONF_VALUE *cnf) 419 CONF_VALUE *cnf)
413 { 420 {
414 return v2i_GENERAL_NAME_ex(NULL, method, ctx, cnf, 0); 421 return v2i_GENERAL_NAME_ex(NULL, method, ctx, cnf, 0);
415 } 422 }
416 423
417GENERAL_NAME *v2i_GENERAL_NAME_ex(GENERAL_NAME *out, 424GENERAL_NAME *a2i_GENERAL_NAME(GENERAL_NAME *out,
418 X509V3_EXT_METHOD *method, X509V3_CTX *ctx, 425 const X509V3_EXT_METHOD *method, X509V3_CTX *ctx,
419 CONF_VALUE *cnf, int is_nc) 426 int gen_type, char *value, int is_nc)
420 { 427 {
421 char is_string = 0; 428 char is_string = 0;
422 int type;
423 GENERAL_NAME *gen = NULL; 429 GENERAL_NAME *gen = NULL;
424 430
425 char *name, *value;
426
427 name = cnf->name;
428 value = cnf->value;
429
430 if(!value) 431 if(!value)
431 { 432 {
432 X509V3err(X509V3_F_V2I_GENERAL_NAME_EX,X509V3_R_MISSING_VALUE); 433 X509V3err(X509V3_F_A2I_GENERAL_NAME,X509V3_R_MISSING_VALUE);
433 return NULL; 434 return NULL;
434 } 435 }
435 436
@@ -440,74 +441,62 @@ GENERAL_NAME *v2i_GENERAL_NAME_ex(GENERAL_NAME *out,
440 gen = GENERAL_NAME_new(); 441 gen = GENERAL_NAME_new();
441 if(gen == NULL) 442 if(gen == NULL)
442 { 443 {
443 X509V3err(X509V3_F_V2I_GENERAL_NAME_EX,ERR_R_MALLOC_FAILURE); 444 X509V3err(X509V3_F_A2I_GENERAL_NAME,ERR_R_MALLOC_FAILURE);
444 return NULL; 445 return NULL;
445 } 446 }
446 } 447 }
447 448
448 if(!name_cmp(name, "email")) 449 switch (gen_type)
449 {
450 is_string = 1;
451 type = GEN_EMAIL;
452 }
453 else if(!name_cmp(name, "URI"))
454 {
455 is_string = 1;
456 type = GEN_URI;
457 }
458 else if(!name_cmp(name, "DNS"))
459 { 450 {
451 case GEN_URI:
452 case GEN_EMAIL:
453 case GEN_DNS:
460 is_string = 1; 454 is_string = 1;
461 type = GEN_DNS; 455 break;
462 } 456
463 else if(!name_cmp(name, "RID")) 457 case GEN_RID:
464 { 458 {
465 ASN1_OBJECT *obj; 459 ASN1_OBJECT *obj;
466 if(!(obj = OBJ_txt2obj(value,0))) 460 if(!(obj = OBJ_txt2obj(value,0)))
467 { 461 {
468 X509V3err(X509V3_F_V2I_GENERAL_NAME_EX,X509V3_R_BAD_OBJECT); 462 X509V3err(X509V3_F_A2I_GENERAL_NAME,X509V3_R_BAD_OBJECT);
469 ERR_add_error_data(2, "value=", value); 463 ERR_add_error_data(2, "value=", value);
470 goto err; 464 goto err;
471 } 465 }
472 gen->d.rid = obj; 466 gen->d.rid = obj;
473 type = GEN_RID;
474 } 467 }
475 else if(!name_cmp(name, "IP")) 468 break;
476 { 469
470 case GEN_IPADD:
477 if (is_nc) 471 if (is_nc)
478 gen->d.ip = a2i_IPADDRESS_NC(value); 472 gen->d.ip = a2i_IPADDRESS_NC(value);
479 else 473 else
480 gen->d.ip = a2i_IPADDRESS(value); 474 gen->d.ip = a2i_IPADDRESS(value);
481 if(gen->d.ip == NULL) 475 if(gen->d.ip == NULL)
482 { 476 {
483 X509V3err(X509V3_F_V2I_GENERAL_NAME_EX,X509V3_R_BAD_IP_ADDRESS); 477 X509V3err(X509V3_F_A2I_GENERAL_NAME,X509V3_R_BAD_IP_ADDRESS);
484 ERR_add_error_data(2, "value=", value); 478 ERR_add_error_data(2, "value=", value);
485 goto err; 479 goto err;
486 } 480 }
487 type = GEN_IPADD; 481 break;
488 } 482
489 else if(!name_cmp(name, "dirName")) 483 case GEN_DIRNAME:
490 {
491 type = GEN_DIRNAME;
492 if (!do_dirname(gen, value, ctx)) 484 if (!do_dirname(gen, value, ctx))
493 { 485 {
494 X509V3err(X509V3_F_V2I_GENERAL_NAME_EX,X509V3_R_DIRNAME_ERROR); 486 X509V3err(X509V3_F_A2I_GENERAL_NAME,X509V3_R_DIRNAME_ERROR);
495 goto err; 487 goto err;
496 } 488 }
497 } 489 break;
498 else if(!name_cmp(name, "otherName")) 490
499 { 491 case GEN_OTHERNAME:
500 if (!do_othername(gen, value, ctx)) 492 if (!do_othername(gen, value, ctx))
501 { 493 {
502 X509V3err(X509V3_F_V2I_GENERAL_NAME_EX,X509V3_R_OTHERNAME_ERROR); 494 X509V3err(X509V3_F_A2I_GENERAL_NAME,X509V3_R_OTHERNAME_ERROR);
503 goto err; 495 goto err;
504 } 496 }
505 type = GEN_OTHERNAME; 497 break;
506 } 498 default:
507 else 499 X509V3err(X509V3_F_A2I_GENERAL_NAME,X509V3_R_UNSUPPORTED_TYPE);
508 {
509 X509V3err(X509V3_F_V2I_GENERAL_NAME_EX,X509V3_R_UNSUPPORTED_OPTION);
510 ERR_add_error_data(2, "name=", name);
511 goto err; 500 goto err;
512 } 501 }
513 502
@@ -517,12 +506,12 @@ GENERAL_NAME *v2i_GENERAL_NAME_ex(GENERAL_NAME *out,
517 !ASN1_STRING_set(gen->d.ia5, (unsigned char*)value, 506 !ASN1_STRING_set(gen->d.ia5, (unsigned char*)value,
518 strlen(value))) 507 strlen(value)))
519 { 508 {
520 X509V3err(X509V3_F_V2I_GENERAL_NAME_EX,ERR_R_MALLOC_FAILURE); 509 X509V3err(X509V3_F_A2I_GENERAL_NAME,ERR_R_MALLOC_FAILURE);
521 goto err; 510 goto err;
522 } 511 }
523 } 512 }
524 513
525 gen->type = type; 514 gen->type = gen_type;
526 515
527 return gen; 516 return gen;
528 517
@@ -532,6 +521,48 @@ GENERAL_NAME *v2i_GENERAL_NAME_ex(GENERAL_NAME *out,
532 return NULL; 521 return NULL;
533 } 522 }
534 523
524GENERAL_NAME *v2i_GENERAL_NAME_ex(GENERAL_NAME *out,
525 const X509V3_EXT_METHOD *method,
526 X509V3_CTX *ctx, CONF_VALUE *cnf, int is_nc)
527 {
528 int type;
529
530 char *name, *value;
531
532 name = cnf->name;
533 value = cnf->value;
534
535 if(!value)
536 {
537 X509V3err(X509V3_F_V2I_GENERAL_NAME_EX,X509V3_R_MISSING_VALUE);
538 return NULL;
539 }
540
541 if(!name_cmp(name, "email"))
542 type = GEN_EMAIL;
543 else if(!name_cmp(name, "URI"))
544 type = GEN_URI;
545 else if(!name_cmp(name, "DNS"))
546 type = GEN_DNS;
547 else if(!name_cmp(name, "RID"))
548 type = GEN_RID;
549 else if(!name_cmp(name, "IP"))
550 type = GEN_IPADD;
551 else if(!name_cmp(name, "dirName"))
552 type = GEN_DIRNAME;
553 else if(!name_cmp(name, "otherName"))
554 type = GEN_OTHERNAME;
555 else
556 {
557 X509V3err(X509V3_F_V2I_GENERAL_NAME_EX,X509V3_R_UNSUPPORTED_OPTION);
558 ERR_add_error_data(2, "name=", name);
559 return NULL;
560 }
561
562 return a2i_GENERAL_NAME(out, method, ctx, type, value, is_nc);
563
564 }
565
535static int do_othername(GENERAL_NAME *gen, char *value, X509V3_CTX *ctx) 566static int do_othername(GENERAL_NAME *gen, char *value, X509V3_CTX *ctx)
536 { 567 {
537 char *objtmp = NULL, *p; 568 char *objtmp = NULL, *p;
@@ -577,6 +608,7 @@ static int do_dirname(GENERAL_NAME *gen, char *value, X509V3_CTX *ctx)
577 if (!ret) 608 if (!ret)
578 X509_NAME_free(nm); 609 X509_NAME_free(nm);
579 gen->d.dirn = nm; 610 gen->d.dirn = nm;
611 X509V3_section_free(ctx, sk);
580 612
581 return ret; 613 return ret;
582 } 614 }
diff --git a/src/lib/libcrypto/x509v3/v3_asid.c b/src/lib/libcrypto/x509v3/v3_asid.c
index abd497ed1f..56702f86b9 100644
--- a/src/lib/libcrypto/x509v3/v3_asid.c
+++ b/src/lib/libcrypto/x509v3/v3_asid.c
@@ -152,7 +152,7 @@ static int i2r_ASIdentifierChoice(BIO *out,
152/* 152/*
153 * i2r method for an ASIdentifier extension. 153 * i2r method for an ASIdentifier extension.
154 */ 154 */
155static int i2r_ASIdentifiers(X509V3_EXT_METHOD *method, 155static int i2r_ASIdentifiers(const X509V3_EXT_METHOD *method,
156 void *ext, 156 void *ext,
157 BIO *out, 157 BIO *out,
158 int indent) 158 int indent)
@@ -466,7 +466,7 @@ static int ASIdentifierChoice_canonize(ASIdentifierChoice *choice)
466 break; 466 break;
467 } 467 }
468 ASIdOrRange_free(b); 468 ASIdOrRange_free(b);
469 (void)sk_ASIdOrRange_delete(choice->u.asIdsOrRanges, i + 1); 469 sk_ASIdOrRange_delete(choice->u.asIdsOrRanges, i + 1);
470 i--; 470 i--;
471 continue; 471 continue;
472 } 472 }
@@ -495,7 +495,7 @@ int v3_asid_canonize(ASIdentifiers *asid)
495/* 495/*
496 * v2i method for an ASIdentifier extension. 496 * v2i method for an ASIdentifier extension.
497 */ 497 */
498static void *v2i_ASIdentifiers(struct v3_ext_method *method, 498static void *v2i_ASIdentifiers(const struct v3_ext_method *method,
499 struct v3_ext_ctx *ctx, 499 struct v3_ext_ctx *ctx,
500 STACK_OF(CONF_VALUE) *values) 500 STACK_OF(CONF_VALUE) *values)
501{ 501{
@@ -707,7 +707,7 @@ static int v3_asid_validate_path_internal(X509_STORE_CTX *ctx,
707{ 707{
708 ASIdOrRanges *child_as = NULL, *child_rdi = NULL; 708 ASIdOrRanges *child_as = NULL, *child_rdi = NULL;
709 int i, ret = 1, inherit_as = 0, inherit_rdi = 0; 709 int i, ret = 1, inherit_as = 0, inherit_rdi = 0;
710 X509 *x = NULL; 710 X509 *x;
711 711
712 assert(chain != NULL && sk_X509_num(chain) > 0); 712 assert(chain != NULL && sk_X509_num(chain) > 0);
713 assert(ctx != NULL || ext != NULL); 713 assert(ctx != NULL || ext != NULL);
@@ -720,6 +720,7 @@ static int v3_asid_validate_path_internal(X509_STORE_CTX *ctx,
720 */ 720 */
721 if (ext != NULL) { 721 if (ext != NULL) {
722 i = -1; 722 i = -1;
723 x = NULL;
723 } else { 724 } else {
724 i = 0; 725 i = 0;
725 x = sk_X509_value(chain, i); 726 x = sk_X509_value(chain, i);
@@ -799,6 +800,7 @@ static int v3_asid_validate_path_internal(X509_STORE_CTX *ctx,
799 /* 800 /*
800 * Trust anchor can't inherit. 801 * Trust anchor can't inherit.
801 */ 802 */
803 assert(x != NULL);
802 if (x->rfc3779_asid != NULL) { 804 if (x->rfc3779_asid != NULL) {
803 if (x->rfc3779_asid->asnum != NULL && 805 if (x->rfc3779_asid->asnum != NULL &&
804 x->rfc3779_asid->asnum->type == ASIdentifierChoice_inherit) 806 x->rfc3779_asid->asnum->type == ASIdentifierChoice_inherit)
diff --git a/src/lib/libcrypto/x509v3/v3_conf.c b/src/lib/libcrypto/x509v3/v3_conf.c
index 11eb6b7fd5..6730f9a6ee 100644
--- a/src/lib/libcrypto/x509v3/v3_conf.c
+++ b/src/lib/libcrypto/x509v3/v3_conf.c
@@ -72,14 +72,14 @@ static X509_EXTENSION *do_ext_nconf(CONF *conf, X509V3_CTX *ctx, int ext_nid, in
72static X509_EXTENSION *v3_generic_extension(const char *ext, char *value, int crit, int type, X509V3_CTX *ctx); 72static X509_EXTENSION *v3_generic_extension(const char *ext, char *value, int crit, int type, X509V3_CTX *ctx);
73static char *conf_lhash_get_string(void *db, char *section, char *value); 73static char *conf_lhash_get_string(void *db, char *section, char *value);
74static STACK_OF(CONF_VALUE) *conf_lhash_get_section(void *db, char *section); 74static STACK_OF(CONF_VALUE) *conf_lhash_get_section(void *db, char *section);
75static X509_EXTENSION *do_ext_i2d(X509V3_EXT_METHOD *method, int ext_nid, 75static X509_EXTENSION *do_ext_i2d(const X509V3_EXT_METHOD *method, int ext_nid,
76 int crit, void *ext_struc); 76 int crit, void *ext_struc);
77static unsigned char *generic_asn1(char *value, X509V3_CTX *ctx, long *ext_len); 77static unsigned char *generic_asn1(char *value, X509V3_CTX *ctx, long *ext_len);
78/* CONF *conf: Config file */ 78/* CONF *conf: Config file */
79/* char *name: Name */ 79/* char *name: Name */
80/* char *value: Value */ 80/* char *value: Value */
81X509_EXTENSION *X509V3_EXT_nconf(CONF *conf, X509V3_CTX *ctx, char *name, 81X509_EXTENSION *X509V3_EXT_nconf(CONF *conf, X509V3_CTX *ctx, char *name,
82 char *value) 82 char *value)
83 { 83 {
84 int crit; 84 int crit;
85 int ext_type; 85 int ext_type;
@@ -99,7 +99,7 @@ X509_EXTENSION *X509V3_EXT_nconf(CONF *conf, X509V3_CTX *ctx, char *name,
99/* CONF *conf: Config file */ 99/* CONF *conf: Config file */
100/* char *value: Value */ 100/* char *value: Value */
101X509_EXTENSION *X509V3_EXT_nconf_nid(CONF *conf, X509V3_CTX *ctx, int ext_nid, 101X509_EXTENSION *X509V3_EXT_nconf_nid(CONF *conf, X509V3_CTX *ctx, int ext_nid,
102 char *value) 102 char *value)
103 { 103 {
104 int crit; 104 int crit;
105 int ext_type; 105 int ext_type;
@@ -113,9 +113,9 @@ X509_EXTENSION *X509V3_EXT_nconf_nid(CONF *conf, X509V3_CTX *ctx, int ext_nid,
113/* CONF *conf: Config file */ 113/* CONF *conf: Config file */
114/* char *value: Value */ 114/* char *value: Value */
115static X509_EXTENSION *do_ext_nconf(CONF *conf, X509V3_CTX *ctx, int ext_nid, 115static X509_EXTENSION *do_ext_nconf(CONF *conf, X509V3_CTX *ctx, int ext_nid,
116 int crit, char *value) 116 int crit, char *value)
117 { 117 {
118 X509V3_EXT_METHOD *method; 118 const X509V3_EXT_METHOD *method;
119 X509_EXTENSION *ext; 119 X509_EXTENSION *ext;
120 STACK_OF(CONF_VALUE) *nval; 120 STACK_OF(CONF_VALUE) *nval;
121 void *ext_struc; 121 void *ext_struc;
@@ -172,8 +172,8 @@ static X509_EXTENSION *do_ext_nconf(CONF *conf, X509V3_CTX *ctx, int ext_nid,
172 172
173 } 173 }
174 174
175static X509_EXTENSION *do_ext_i2d(X509V3_EXT_METHOD *method, int ext_nid, 175static X509_EXTENSION *do_ext_i2d(const X509V3_EXT_METHOD *method, int ext_nid,
176 int crit, void *ext_struc) 176 int crit, void *ext_struc)
177 { 177 {
178 unsigned char *ext_der; 178 unsigned char *ext_der;
179 int ext_len; 179 int ext_len;
@@ -214,7 +214,7 @@ static X509_EXTENSION *do_ext_i2d(X509V3_EXT_METHOD *method, int ext_nid,
214 214
215X509_EXTENSION *X509V3_EXT_i2d(int ext_nid, int crit, void *ext_struc) 215X509_EXTENSION *X509V3_EXT_i2d(int ext_nid, int crit, void *ext_struc)
216 { 216 {
217 X509V3_EXT_METHOD *method; 217 const X509V3_EXT_METHOD *method;
218 if (!(method = X509V3_EXT_get_nid(ext_nid))) { 218 if (!(method = X509V3_EXT_get_nid(ext_nid))) {
219 X509V3err(X509V3_F_X509V3_EXT_I2D,X509V3_R_UNKNOWN_EXTENSION); 219 X509V3err(X509V3_F_X509V3_EXT_I2D,X509V3_R_UNKNOWN_EXTENSION);
220 return NULL; 220 return NULL;
@@ -258,7 +258,8 @@ static int v3_check_generic(char **value)
258 258
259/* Create a generic extension: for now just handle DER type */ 259/* Create a generic extension: for now just handle DER type */
260static X509_EXTENSION *v3_generic_extension(const char *ext, char *value, 260static X509_EXTENSION *v3_generic_extension(const char *ext, char *value,
261 int crit, int gen_type, X509V3_CTX *ctx) 261 int crit, int gen_type,
262 X509V3_CTX *ctx)
262 { 263 {
263 unsigned char *ext_der=NULL; 264 unsigned char *ext_der=NULL;
264 long ext_len; 265 long ext_len;
@@ -322,7 +323,7 @@ static unsigned char *generic_asn1(char *value, X509V3_CTX *ctx, long *ext_len)
322 323
323 324
324int X509V3_EXT_add_nconf_sk(CONF *conf, X509V3_CTX *ctx, char *section, 325int X509V3_EXT_add_nconf_sk(CONF *conf, X509V3_CTX *ctx, char *section,
325 STACK_OF(X509_EXTENSION) **sk) 326 STACK_OF(X509_EXTENSION) **sk)
326 { 327 {
327 X509_EXTENSION *ext; 328 X509_EXTENSION *ext;
328 STACK_OF(CONF_VALUE) *nval; 329 STACK_OF(CONF_VALUE) *nval;
@@ -343,7 +344,7 @@ int X509V3_EXT_add_nconf_sk(CONF *conf, X509V3_CTX *ctx, char *section,
343/* Convenience functions to add extensions to a certificate, CRL and request */ 344/* Convenience functions to add extensions to a certificate, CRL and request */
344 345
345int X509V3_EXT_add_nconf(CONF *conf, X509V3_CTX *ctx, char *section, 346int X509V3_EXT_add_nconf(CONF *conf, X509V3_CTX *ctx, char *section,
346 X509 *cert) 347 X509 *cert)
347 { 348 {
348 STACK_OF(X509_EXTENSION) **sk = NULL; 349 STACK_OF(X509_EXTENSION) **sk = NULL;
349 if (cert) 350 if (cert)
@@ -354,7 +355,7 @@ int X509V3_EXT_add_nconf(CONF *conf, X509V3_CTX *ctx, char *section,
354/* Same as above but for a CRL */ 355/* Same as above but for a CRL */
355 356
356int X509V3_EXT_CRL_add_nconf(CONF *conf, X509V3_CTX *ctx, char *section, 357int X509V3_EXT_CRL_add_nconf(CONF *conf, X509V3_CTX *ctx, char *section,
357 X509_CRL *crl) 358 X509_CRL *crl)
358 { 359 {
359 STACK_OF(X509_EXTENSION) **sk = NULL; 360 STACK_OF(X509_EXTENSION) **sk = NULL;
360 if (crl) 361 if (crl)
@@ -443,7 +444,7 @@ void X509V3_set_nconf(X509V3_CTX *ctx, CONF *conf)
443 } 444 }
444 445
445void X509V3_set_ctx(X509V3_CTX *ctx, X509 *issuer, X509 *subj, X509_REQ *req, 446void X509V3_set_ctx(X509V3_CTX *ctx, X509 *issuer, X509 *subj, X509_REQ *req,
446 X509_CRL *crl, int flags) 447 X509_CRL *crl, int flags)
447 { 448 {
448 ctx->issuer_cert = issuer; 449 ctx->issuer_cert = issuer;
449 ctx->subject_cert = subj; 450 ctx->subject_cert = subj;
@@ -454,8 +455,8 @@ void X509V3_set_ctx(X509V3_CTX *ctx, X509 *issuer, X509 *subj, X509_REQ *req,
454 455
455/* Old conf compatibility functions */ 456/* Old conf compatibility functions */
456 457
457X509_EXTENSION *X509V3_EXT_conf(LHASH *conf, X509V3_CTX *ctx, char *name, 458X509_EXTENSION *X509V3_EXT_conf(LHASH_OF(CONF_VALUE) *conf, X509V3_CTX *ctx,
458 char *value) 459 char *name, char *value)
459 { 460 {
460 CONF ctmp; 461 CONF ctmp;
461 CONF_set_nconf(&ctmp, conf); 462 CONF_set_nconf(&ctmp, conf);
@@ -464,8 +465,8 @@ X509_EXTENSION *X509V3_EXT_conf(LHASH *conf, X509V3_CTX *ctx, char *name,
464 465
465/* LHASH *conf: Config file */ 466/* LHASH *conf: Config file */
466/* char *value: Value */ 467/* char *value: Value */
467X509_EXTENSION *X509V3_EXT_conf_nid(LHASH *conf, X509V3_CTX *ctx, int ext_nid, 468X509_EXTENSION *X509V3_EXT_conf_nid(LHASH_OF(CONF_VALUE) *conf, X509V3_CTX *ctx,
468 char *value) 469 int ext_nid, char *value)
469 { 470 {
470 CONF ctmp; 471 CONF ctmp;
471 CONF_set_nconf(&ctmp, conf); 472 CONF_set_nconf(&ctmp, conf);
@@ -489,14 +490,14 @@ NULL,
489NULL 490NULL
490}; 491};
491 492
492void X509V3_set_conf_lhash(X509V3_CTX *ctx, LHASH *lhash) 493void X509V3_set_conf_lhash(X509V3_CTX *ctx, LHASH_OF(CONF_VALUE) *lhash)
493 { 494 {
494 ctx->db_meth = &conf_lhash_method; 495 ctx->db_meth = &conf_lhash_method;
495 ctx->db = lhash; 496 ctx->db = lhash;
496 } 497 }
497 498
498int X509V3_EXT_add_conf(LHASH *conf, X509V3_CTX *ctx, char *section, 499int X509V3_EXT_add_conf(LHASH_OF(CONF_VALUE) *conf, X509V3_CTX *ctx,
499 X509 *cert) 500 char *section, X509 *cert)
500 { 501 {
501 CONF ctmp; 502 CONF ctmp;
502 CONF_set_nconf(&ctmp, conf); 503 CONF_set_nconf(&ctmp, conf);
@@ -505,8 +506,8 @@ int X509V3_EXT_add_conf(LHASH *conf, X509V3_CTX *ctx, char *section,
505 506
506/* Same as above but for a CRL */ 507/* Same as above but for a CRL */
507 508
508int X509V3_EXT_CRL_add_conf(LHASH *conf, X509V3_CTX *ctx, char *section, 509int X509V3_EXT_CRL_add_conf(LHASH_OF(CONF_VALUE) *conf, X509V3_CTX *ctx,
509 X509_CRL *crl) 510 char *section, X509_CRL *crl)
510 { 511 {
511 CONF ctmp; 512 CONF ctmp;
512 CONF_set_nconf(&ctmp, conf); 513 CONF_set_nconf(&ctmp, conf);
@@ -515,8 +516,8 @@ int X509V3_EXT_CRL_add_conf(LHASH *conf, X509V3_CTX *ctx, char *section,
515 516
516/* Add extensions to certificate request */ 517/* Add extensions to certificate request */
517 518
518int X509V3_EXT_REQ_add_conf(LHASH *conf, X509V3_CTX *ctx, char *section, 519int X509V3_EXT_REQ_add_conf(LHASH_OF(CONF_VALUE) *conf, X509V3_CTX *ctx,
519 X509_REQ *req) 520 char *section, X509_REQ *req)
520 { 521 {
521 CONF ctmp; 522 CONF ctmp;
522 CONF_set_nconf(&ctmp, conf); 523 CONF_set_nconf(&ctmp, conf);
diff --git a/src/lib/libcrypto/x509v3/v3_cpols.c b/src/lib/libcrypto/x509v3/v3_cpols.c
index ad0506d75c..1f0798b946 100644
--- a/src/lib/libcrypto/x509v3/v3_cpols.c
+++ b/src/lib/libcrypto/x509v3/v3_cpols.c
@@ -450,5 +450,8 @@ void X509_POLICY_NODE_print(BIO *out, X509_POLICY_NODE *node, int indent)
450 else 450 else
451 BIO_printf(out, "%*sNo Qualifiers\n", indent + 2, ""); 451 BIO_printf(out, "%*sNo Qualifiers\n", indent + 2, "");
452 } 452 }
453 453
454
454IMPLEMENT_STACK_OF(X509_POLICY_NODE) 455IMPLEMENT_STACK_OF(X509_POLICY_NODE)
456IMPLEMENT_STACK_OF(X509_POLICY_DATA)
457
diff --git a/src/lib/libcrypto/x509v3/v3_crld.c b/src/lib/libcrypto/x509v3/v3_crld.c
index 181a8977b1..790a6dd032 100644
--- a/src/lib/libcrypto/x509v3/v3_crld.c
+++ b/src/lib/libcrypto/x509v3/v3_crld.c
@@ -3,7 +3,7 @@
3 * project 1999. 3 * project 1999.
4 */ 4 */
5/* ==================================================================== 5/* ====================================================================
6 * Copyright (c) 1999 The OpenSSL Project. All rights reserved. 6 * Copyright (c) 1999-2008 The OpenSSL Project. All rights reserved.
7 * 7 *
8 * Redistribution and use in source and binary forms, with or without 8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions 9 * modification, are permitted provided that the following conditions
@@ -63,45 +63,254 @@
63#include <openssl/asn1t.h> 63#include <openssl/asn1t.h>
64#include <openssl/x509v3.h> 64#include <openssl/x509v3.h>
65 65
66static STACK_OF(CONF_VALUE) *i2v_crld(X509V3_EXT_METHOD *method, 66static void *v2i_crld(const X509V3_EXT_METHOD *method,
67 STACK_OF(DIST_POINT) *crld, STACK_OF(CONF_VALUE) *extlist); 67 X509V3_CTX *ctx, STACK_OF(CONF_VALUE) *nval);
68static STACK_OF(DIST_POINT) *v2i_crld(X509V3_EXT_METHOD *method, 68static int i2r_crldp(const X509V3_EXT_METHOD *method, void *pcrldp, BIO *out,
69 X509V3_CTX *ctx, STACK_OF(CONF_VALUE) *nval); 69 int indent);
70 70
71const X509V3_EXT_METHOD v3_crld = { 71const X509V3_EXT_METHOD v3_crld =
72NID_crl_distribution_points, X509V3_EXT_MULTILINE, ASN1_ITEM_ref(CRL_DIST_POINTS), 72 {
730,0,0,0, 73 NID_crl_distribution_points, 0, ASN1_ITEM_ref(CRL_DIST_POINTS),
740,0, 74 0,0,0,0,
75(X509V3_EXT_I2V)i2v_crld, 75 0,0,
76(X509V3_EXT_V2I)v2i_crld, 76 0,
770,0, 77 v2i_crld,
78NULL 78 i2r_crldp,0,
79 NULL
80 };
81
82const X509V3_EXT_METHOD v3_freshest_crl =
83 {
84 NID_freshest_crl, 0, ASN1_ITEM_ref(CRL_DIST_POINTS),
85 0,0,0,0,
86 0,0,
87 0,
88 v2i_crld,
89 i2r_crldp,0,
90 NULL
91 };
92
93static STACK_OF(GENERAL_NAME) *gnames_from_sectname(X509V3_CTX *ctx, char *sect)
94 {
95 STACK_OF(CONF_VALUE) *gnsect;
96 STACK_OF(GENERAL_NAME) *gens;
97 if (*sect == '@')
98 gnsect = X509V3_get_section(ctx, sect + 1);
99 else
100 gnsect = X509V3_parse_list(sect);
101 if (!gnsect)
102 {
103 X509V3err(X509V3_F_GNAMES_FROM_SECTNAME,
104 X509V3_R_SECTION_NOT_FOUND);
105 return NULL;
106 }
107 gens = v2i_GENERAL_NAMES(NULL, ctx, gnsect);
108 if (*sect == '@')
109 X509V3_section_free(ctx, gnsect);
110 else
111 sk_CONF_VALUE_pop_free(gnsect, X509V3_conf_free);
112 return gens;
113 }
114
115static int set_dist_point_name(DIST_POINT_NAME **pdp, X509V3_CTX *ctx,
116 CONF_VALUE *cnf)
117 {
118 STACK_OF(GENERAL_NAME) *fnm = NULL;
119 STACK_OF(X509_NAME_ENTRY) *rnm = NULL;
120 if (!strncmp(cnf->name, "fullname", 9))
121 {
122 fnm = gnames_from_sectname(ctx, cnf->value);
123 if (!fnm)
124 goto err;
125 }
126 else if (!strcmp(cnf->name, "relativename"))
127 {
128 int ret;
129 STACK_OF(CONF_VALUE) *dnsect;
130 X509_NAME *nm;
131 nm = X509_NAME_new();
132 if (!nm)
133 return -1;
134 dnsect = X509V3_get_section(ctx, cnf->value);
135 if (!dnsect)
136 {
137 X509V3err(X509V3_F_SET_DIST_POINT_NAME,
138 X509V3_R_SECTION_NOT_FOUND);
139 return -1;
140 }
141 ret = X509V3_NAME_from_section(nm, dnsect, MBSTRING_ASC);
142 X509V3_section_free(ctx, dnsect);
143 rnm = nm->entries;
144 nm->entries = NULL;
145 X509_NAME_free(nm);
146 if (!ret || sk_X509_NAME_ENTRY_num(rnm) <= 0)
147 goto err;
148 /* Since its a name fragment can't have more than one
149 * RDNSequence
150 */
151 if (sk_X509_NAME_ENTRY_value(rnm,
152 sk_X509_NAME_ENTRY_num(rnm) - 1)->set)
153 {
154 X509V3err(X509V3_F_SET_DIST_POINT_NAME,
155 X509V3_R_INVALID_MULTIPLE_RDNS);
156 goto err;
157 }
158 }
159 else
160 return 0;
161
162 if (*pdp)
163 {
164 X509V3err(X509V3_F_SET_DIST_POINT_NAME,
165 X509V3_R_DISTPOINT_ALREADY_SET);
166 goto err;
167 }
168
169 *pdp = DIST_POINT_NAME_new();
170 if (!*pdp)
171 goto err;
172 if (fnm)
173 {
174 (*pdp)->type = 0;
175 (*pdp)->name.fullname = fnm;
176 }
177 else
178 {
179 (*pdp)->type = 1;
180 (*pdp)->name.relativename = rnm;
181 }
182
183 return 1;
184
185 err:
186 if (fnm)
187 sk_GENERAL_NAME_pop_free(fnm, GENERAL_NAME_free);
188 if (rnm)
189 sk_X509_NAME_ENTRY_pop_free(rnm, X509_NAME_ENTRY_free);
190 return -1;
191 }
192
193static const BIT_STRING_BITNAME reason_flags[] = {
194{0, "Unused", "unused"},
195{1, "Key Compromise", "keyCompromise"},
196{2, "CA Compromise", "CACompromise"},
197{3, "Affiliation Changed", "affiliationChanged"},
198{4, "Superseded", "superseded"},
199{5, "Cessation Of Operation", "cessationOfOperation"},
200{6, "Certificate Hold", "certificateHold"},
201{7, "Privilege Withdrawn", "privilegeWithdrawn"},
202{8, "AA Compromise", "AACompromise"},
203{-1, NULL, NULL}
79}; 204};
80 205
81static STACK_OF(CONF_VALUE) *i2v_crld(X509V3_EXT_METHOD *method, 206static int set_reasons(ASN1_BIT_STRING **preas, char *value)
82 STACK_OF(DIST_POINT) *crld, STACK_OF(CONF_VALUE) *exts) 207 {
83{ 208 STACK_OF(CONF_VALUE) *rsk = NULL;
84 DIST_POINT *point; 209 const BIT_STRING_BITNAME *pbn;
210 const char *bnam;
211 int i, ret = 0;
212 rsk = X509V3_parse_list(value);
213 if (!rsk)
214 return 0;
215 if (*preas)
216 return 0;
217 for (i = 0; i < sk_CONF_VALUE_num(rsk); i++)
218 {
219 bnam = sk_CONF_VALUE_value(rsk, i)->name;
220 if (!*preas)
221 {
222 *preas = ASN1_BIT_STRING_new();
223 if (!*preas)
224 goto err;
225 }
226 for (pbn = reason_flags; pbn->lname; pbn++)
227 {
228 if (!strcmp(pbn->sname, bnam))
229 {
230 if (!ASN1_BIT_STRING_set_bit(*preas,
231 pbn->bitnum, 1))
232 goto err;
233 break;
234 }
235 }
236 if (!pbn->lname)
237 goto err;
238 }
239 ret = 1;
240
241 err:
242 sk_CONF_VALUE_pop_free(rsk, X509V3_conf_free);
243 return ret;
244 }
245
246static int print_reasons(BIO *out, const char *rname,
247 ASN1_BIT_STRING *rflags, int indent)
248 {
249 int first = 1;
250 const BIT_STRING_BITNAME *pbn;
251 BIO_printf(out, "%*s%s:\n%*s", indent, "", rname, indent + 2, "");
252 for (pbn = reason_flags; pbn->lname; pbn++)
253 {
254 if (ASN1_BIT_STRING_get_bit(rflags, pbn->bitnum))
255 {
256 if (first)
257 first = 0;
258 else
259 BIO_puts(out, ", ");
260 BIO_puts(out, pbn->lname);
261 }
262 }
263 if (first)
264 BIO_puts(out, "<EMPTY>\n");
265 else
266 BIO_puts(out, "\n");
267 return 1;
268 }
269
270static DIST_POINT *crldp_from_section(X509V3_CTX *ctx,
271 STACK_OF(CONF_VALUE) *nval)
272 {
85 int i; 273 int i;
86 for(i = 0; i < sk_DIST_POINT_num(crld); i++) { 274 CONF_VALUE *cnf;
87 point = sk_DIST_POINT_value(crld, i); 275 DIST_POINT *point = NULL;
88 if(point->distpoint) { 276 point = DIST_POINT_new();
89 if(point->distpoint->type == 0) 277 if (!point)
90 exts = i2v_GENERAL_NAMES(NULL, 278 goto err;
91 point->distpoint->name.fullname, exts); 279 for(i = 0; i < sk_CONF_VALUE_num(nval); i++)
92 else X509V3_add_value("RelativeName","<UNSUPPORTED>", &exts); 280 {
281 int ret;
282 cnf = sk_CONF_VALUE_value(nval, i);
283 ret = set_dist_point_name(&point->distpoint, ctx, cnf);
284 if (ret > 0)
285 continue;
286 if (ret < 0)
287 goto err;
288 if (!strcmp(cnf->name, "reasons"))
289 {
290 if (!set_reasons(&point->reasons, cnf->value))
291 goto err;
292 }
293 else if (!strcmp(cnf->name, "CRLissuer"))
294 {
295 point->CRLissuer =
296 gnames_from_sectname(ctx, cnf->value);
297 if (!point->CRLissuer)
298 goto err;
299 }
93 } 300 }
94 if(point->reasons) 301
95 X509V3_add_value("reasons","<UNSUPPORTED>", &exts); 302 return point;
96 if(point->CRLissuer) 303
97 X509V3_add_value("CRLissuer","<UNSUPPORTED>", &exts); 304
305 err:
306 if (point)
307 DIST_POINT_free(point);
308 return NULL;
98 } 309 }
99 return exts;
100}
101 310
102static STACK_OF(DIST_POINT) *v2i_crld(X509V3_EXT_METHOD *method, 311static void *v2i_crld(const X509V3_EXT_METHOD *method,
103 X509V3_CTX *ctx, STACK_OF(CONF_VALUE) *nval) 312 X509V3_CTX *ctx, STACK_OF(CONF_VALUE) *nval)
104{ 313 {
105 STACK_OF(DIST_POINT) *crld = NULL; 314 STACK_OF(DIST_POINT) *crld = NULL;
106 GENERAL_NAMES *gens = NULL; 315 GENERAL_NAMES *gens = NULL;
107 GENERAL_NAME *gen = NULL; 316 GENERAL_NAME *gen = NULL;
@@ -111,19 +320,44 @@ static STACK_OF(DIST_POINT) *v2i_crld(X509V3_EXT_METHOD *method,
111 for(i = 0; i < sk_CONF_VALUE_num(nval); i++) { 320 for(i = 0; i < sk_CONF_VALUE_num(nval); i++) {
112 DIST_POINT *point; 321 DIST_POINT *point;
113 cnf = sk_CONF_VALUE_value(nval, i); 322 cnf = sk_CONF_VALUE_value(nval, i);
114 if(!(gen = v2i_GENERAL_NAME(method, ctx, cnf))) goto err; 323 if (!cnf->value)
115 if(!(gens = GENERAL_NAMES_new())) goto merr; 324 {
116 if(!sk_GENERAL_NAME_push(gens, gen)) goto merr; 325 STACK_OF(CONF_VALUE) *dpsect;
117 gen = NULL; 326 dpsect = X509V3_get_section(ctx, cnf->name);
118 if(!(point = DIST_POINT_new())) goto merr; 327 if (!dpsect)
119 if(!sk_DIST_POINT_push(crld, point)) { 328 goto err;
120 DIST_POINT_free(point); 329 point = crldp_from_section(ctx, dpsect);
121 goto merr; 330 X509V3_section_free(ctx, dpsect);
122 } 331 if (!point)
123 if(!(point->distpoint = DIST_POINT_NAME_new())) goto merr; 332 goto err;
124 point->distpoint->name.fullname = gens; 333 if(!sk_DIST_POINT_push(crld, point))
125 point->distpoint->type = 0; 334 {
126 gens = NULL; 335 DIST_POINT_free(point);
336 goto merr;
337 }
338 }
339 else
340 {
341 if(!(gen = v2i_GENERAL_NAME(method, ctx, cnf)))
342 goto err;
343 if(!(gens = GENERAL_NAMES_new()))
344 goto merr;
345 if(!sk_GENERAL_NAME_push(gens, gen))
346 goto merr;
347 gen = NULL;
348 if(!(point = DIST_POINT_new()))
349 goto merr;
350 if(!sk_DIST_POINT_push(crld, point))
351 {
352 DIST_POINT_free(point);
353 goto merr;
354 }
355 if(!(point->distpoint = DIST_POINT_NAME_new()))
356 goto merr;
357 point->distpoint->name.fullname = gens;
358 point->distpoint->type = 0;
359 gens = NULL;
360 }
127 } 361 }
128 return crld; 362 return crld;
129 363
@@ -139,11 +373,31 @@ static STACK_OF(DIST_POINT) *v2i_crld(X509V3_EXT_METHOD *method,
139IMPLEMENT_STACK_OF(DIST_POINT) 373IMPLEMENT_STACK_OF(DIST_POINT)
140IMPLEMENT_ASN1_SET_OF(DIST_POINT) 374IMPLEMENT_ASN1_SET_OF(DIST_POINT)
141 375
376static int dpn_cb(int operation, ASN1_VALUE **pval, const ASN1_ITEM *it,
377 void *exarg)
378 {
379 DIST_POINT_NAME *dpn = (DIST_POINT_NAME *)*pval;
380
381 switch(operation)
382 {
383 case ASN1_OP_NEW_POST:
384 dpn->dpname = NULL;
385 break;
386
387 case ASN1_OP_FREE_POST:
388 if (dpn->dpname)
389 X509_NAME_free(dpn->dpname);
390 break;
391 }
392 return 1;
393 }
394
142 395
143ASN1_CHOICE(DIST_POINT_NAME) = { 396ASN1_CHOICE_cb(DIST_POINT_NAME, dpn_cb) = {
144 ASN1_IMP_SEQUENCE_OF(DIST_POINT_NAME, name.fullname, GENERAL_NAME, 0), 397 ASN1_IMP_SEQUENCE_OF(DIST_POINT_NAME, name.fullname, GENERAL_NAME, 0),
145 ASN1_IMP_SET_OF(DIST_POINT_NAME, name.relativename, X509_NAME_ENTRY, 1) 398 ASN1_IMP_SET_OF(DIST_POINT_NAME, name.relativename, X509_NAME_ENTRY, 1)
146} ASN1_CHOICE_END(DIST_POINT_NAME) 399} ASN1_CHOICE_END_cb(DIST_POINT_NAME, DIST_POINT_NAME, type)
400
147 401
148IMPLEMENT_ASN1_FUNCTIONS(DIST_POINT_NAME) 402IMPLEMENT_ASN1_FUNCTIONS(DIST_POINT_NAME)
149 403
@@ -160,3 +414,203 @@ ASN1_ITEM_TEMPLATE(CRL_DIST_POINTS) =
160ASN1_ITEM_TEMPLATE_END(CRL_DIST_POINTS) 414ASN1_ITEM_TEMPLATE_END(CRL_DIST_POINTS)
161 415
162IMPLEMENT_ASN1_FUNCTIONS(CRL_DIST_POINTS) 416IMPLEMENT_ASN1_FUNCTIONS(CRL_DIST_POINTS)
417
418ASN1_SEQUENCE(ISSUING_DIST_POINT) = {
419 ASN1_EXP_OPT(ISSUING_DIST_POINT, distpoint, DIST_POINT_NAME, 0),
420 ASN1_IMP_OPT(ISSUING_DIST_POINT, onlyuser, ASN1_FBOOLEAN, 1),
421 ASN1_IMP_OPT(ISSUING_DIST_POINT, onlyCA, ASN1_FBOOLEAN, 2),
422 ASN1_IMP_OPT(ISSUING_DIST_POINT, onlysomereasons, ASN1_BIT_STRING, 3),
423 ASN1_IMP_OPT(ISSUING_DIST_POINT, indirectCRL, ASN1_FBOOLEAN, 4),
424 ASN1_IMP_OPT(ISSUING_DIST_POINT, onlyattr, ASN1_FBOOLEAN, 5)
425} ASN1_SEQUENCE_END(ISSUING_DIST_POINT)
426
427IMPLEMENT_ASN1_FUNCTIONS(ISSUING_DIST_POINT)
428
429static int i2r_idp(const X509V3_EXT_METHOD *method, void *pidp, BIO *out,
430 int indent);
431static void *v2i_idp(const X509V3_EXT_METHOD *method, X509V3_CTX *ctx,
432 STACK_OF(CONF_VALUE) *nval);
433
434const X509V3_EXT_METHOD v3_idp =
435 {
436 NID_issuing_distribution_point, X509V3_EXT_MULTILINE,
437 ASN1_ITEM_ref(ISSUING_DIST_POINT),
438 0,0,0,0,
439 0,0,
440 0,
441 v2i_idp,
442 i2r_idp,0,
443 NULL
444 };
445
446static void *v2i_idp(const X509V3_EXT_METHOD *method, X509V3_CTX *ctx,
447 STACK_OF(CONF_VALUE) *nval)
448 {
449 ISSUING_DIST_POINT *idp = NULL;
450 CONF_VALUE *cnf;
451 char *name, *val;
452 int i, ret;
453 idp = ISSUING_DIST_POINT_new();
454 if (!idp)
455 goto merr;
456 for(i = 0; i < sk_CONF_VALUE_num(nval); i++)
457 {
458 cnf = sk_CONF_VALUE_value(nval, i);
459 name = cnf->name;
460 val = cnf->value;
461 ret = set_dist_point_name(&idp->distpoint, ctx, cnf);
462 if (ret > 0)
463 continue;
464 if (ret < 0)
465 goto err;
466 if (!strcmp(name, "onlyuser"))
467 {
468 if (!X509V3_get_value_bool(cnf, &idp->onlyuser))
469 goto err;
470 }
471 else if (!strcmp(name, "onlyCA"))
472 {
473 if (!X509V3_get_value_bool(cnf, &idp->onlyCA))
474 goto err;
475 }
476 else if (!strcmp(name, "onlyAA"))
477 {
478 if (!X509V3_get_value_bool(cnf, &idp->onlyattr))
479 goto err;
480 }
481 else if (!strcmp(name, "indirectCRL"))
482 {
483 if (!X509V3_get_value_bool(cnf, &idp->indirectCRL))
484 goto err;
485 }
486 else if (!strcmp(name, "onlysomereasons"))
487 {
488 if (!set_reasons(&idp->onlysomereasons, val))
489 goto err;
490 }
491 else
492 {
493 X509V3err(X509V3_F_V2I_IDP, X509V3_R_INVALID_NAME);
494 X509V3_conf_err(cnf);
495 goto err;
496 }
497 }
498 return idp;
499
500 merr:
501 X509V3err(X509V3_F_V2I_IDP,ERR_R_MALLOC_FAILURE);
502 err:
503 ISSUING_DIST_POINT_free(idp);
504 return NULL;
505 }
506
507static int print_gens(BIO *out, STACK_OF(GENERAL_NAME) *gens, int indent)
508 {
509 int i;
510 for (i = 0; i < sk_GENERAL_NAME_num(gens); i++)
511 {
512 BIO_printf(out, "%*s", indent + 2, "");
513 GENERAL_NAME_print(out, sk_GENERAL_NAME_value(gens, i));
514 BIO_puts(out, "\n");
515 }
516 return 1;
517 }
518
519static int print_distpoint(BIO *out, DIST_POINT_NAME *dpn, int indent)
520 {
521 if (dpn->type == 0)
522 {
523 BIO_printf(out, "%*sFull Name:\n", indent, "");
524 print_gens(out, dpn->name.fullname, indent);
525 }
526 else
527 {
528 X509_NAME ntmp;
529 ntmp.entries = dpn->name.relativename;
530 BIO_printf(out, "%*sRelative Name:\n%*s",
531 indent, "", indent + 2, "");
532 X509_NAME_print_ex(out, &ntmp, 0, XN_FLAG_ONELINE);
533 BIO_puts(out, "\n");
534 }
535 return 1;
536 }
537
538static int i2r_idp(const X509V3_EXT_METHOD *method, void *pidp, BIO *out,
539 int indent)
540 {
541 ISSUING_DIST_POINT *idp = pidp;
542 if (idp->distpoint)
543 print_distpoint(out, idp->distpoint, indent);
544 if (idp->onlyuser > 0)
545 BIO_printf(out, "%*sOnly User Certificates\n", indent, "");
546 if (idp->onlyCA > 0)
547 BIO_printf(out, "%*sOnly CA Certificates\n", indent, "");
548 if (idp->indirectCRL > 0)
549 BIO_printf(out, "%*sIndirect CRL\n", indent, "");
550 if (idp->onlysomereasons)
551 print_reasons(out, "Only Some Reasons",
552 idp->onlysomereasons, indent);
553 if (idp->onlyattr > 0)
554 BIO_printf(out, "%*sOnly Attribute Certificates\n", indent, "");
555 if (!idp->distpoint && (idp->onlyuser <= 0) && (idp->onlyCA <= 0)
556 && (idp->indirectCRL <= 0) && !idp->onlysomereasons
557 && (idp->onlyattr <= 0))
558 BIO_printf(out, "%*s<EMPTY>\n", indent, "");
559
560 return 1;
561 }
562
563static int i2r_crldp(const X509V3_EXT_METHOD *method, void *pcrldp, BIO *out,
564 int indent)
565 {
566 STACK_OF(DIST_POINT) *crld = pcrldp;
567 DIST_POINT *point;
568 int i;
569 for(i = 0; i < sk_DIST_POINT_num(crld); i++)
570 {
571 BIO_puts(out, "\n");
572 point = sk_DIST_POINT_value(crld, i);
573 if(point->distpoint)
574 print_distpoint(out, point->distpoint, indent);
575 if(point->reasons)
576 print_reasons(out, "Reasons", point->reasons,
577 indent);
578 if(point->CRLissuer)
579 {
580 BIO_printf(out, "%*sCRL Issuer:\n", indent, "");
581 print_gens(out, point->CRLissuer, indent);
582 }
583 }
584 return 1;
585 }
586
587int DIST_POINT_set_dpname(DIST_POINT_NAME *dpn, X509_NAME *iname)
588 {
589 int i;
590 STACK_OF(X509_NAME_ENTRY) *frag;
591 X509_NAME_ENTRY *ne;
592 if (!dpn || (dpn->type != 1))
593 return 1;
594 frag = dpn->name.relativename;
595 dpn->dpname = X509_NAME_dup(iname);
596 if (!dpn->dpname)
597 return 0;
598 for (i = 0; i < sk_X509_NAME_ENTRY_num(frag); i++)
599 {
600 ne = sk_X509_NAME_ENTRY_value(frag, i);
601 if (!X509_NAME_add_entry(dpn->dpname, ne, -1, i ? 0 : 1))
602 {
603 X509_NAME_free(dpn->dpname);
604 dpn->dpname = NULL;
605 return 0;
606 }
607 }
608 /* generate cached encoding of name */
609 if (i2d_X509_NAME(dpn->dpname, NULL) < 0)
610 {
611 X509_NAME_free(dpn->dpname);
612 dpn->dpname = NULL;
613 return 0;
614 }
615 return 1;
616 }
diff --git a/src/lib/libcrypto/x509v3/v3_enum.c b/src/lib/libcrypto/x509v3/v3_enum.c
index 36576eaa4d..c0575e368d 100644
--- a/src/lib/libcrypto/x509v3/v3_enum.c
+++ b/src/lib/libcrypto/x509v3/v3_enum.c
@@ -61,14 +61,17 @@
61#include <openssl/x509v3.h> 61#include <openssl/x509v3.h>
62 62
63static ENUMERATED_NAMES crl_reasons[] = { 63static ENUMERATED_NAMES crl_reasons[] = {
64{0, "Unspecified", "unspecified"}, 64{CRL_REASON_UNSPECIFIED, "Unspecified", "unspecified"},
65{1, "Key Compromise", "keyCompromise"}, 65{CRL_REASON_KEY_COMPROMISE, "Key Compromise", "keyCompromise"},
66{2, "CA Compromise", "CACompromise"}, 66{CRL_REASON_CA_COMPROMISE, "CA Compromise", "CACompromise"},
67{3, "Affiliation Changed", "affiliationChanged"}, 67{CRL_REASON_AFFILIATION_CHANGED, "Affiliation Changed", "affiliationChanged"},
68{4, "Superseded", "superseded"}, 68{CRL_REASON_SUPERSEDED, "Superseded", "superseded"},
69{5, "Cessation Of Operation", "cessationOfOperation"}, 69{CRL_REASON_CESSATION_OF_OPERATION,
70{6, "Certificate Hold", "certificateHold"}, 70 "Cessation Of Operation", "cessationOfOperation"},
71{8, "Remove From CRL", "removeFromCRL"}, 71{CRL_REASON_CERTIFICATE_HOLD, "Certificate Hold", "certificateHold"},
72{CRL_REASON_REMOVE_FROM_CRL, "Remove From CRL", "removeFromCRL"},
73{CRL_REASON_PRIVILEGE_WITHDRAWN, "Privilege Withdrawn", "privilegeWithdrawn"},
74{CRL_REASON_AA_COMPROMISE, "AA Compromise", "AACompromise"},
72{-1, NULL, NULL} 75{-1, NULL, NULL}
73}; 76};
74 77
diff --git a/src/lib/libcrypto/x509v3/v3_extku.c b/src/lib/libcrypto/x509v3/v3_extku.c
index c0d14500ed..1c66532757 100644
--- a/src/lib/libcrypto/x509v3/v3_extku.c
+++ b/src/lib/libcrypto/x509v3/v3_extku.c
@@ -63,9 +63,10 @@
63#include <openssl/conf.h> 63#include <openssl/conf.h>
64#include <openssl/x509v3.h> 64#include <openssl/x509v3.h>
65 65
66static void *v2i_EXTENDED_KEY_USAGE(X509V3_EXT_METHOD *method, 66static void *v2i_EXTENDED_KEY_USAGE(const X509V3_EXT_METHOD *method,
67 X509V3_CTX *ctx, STACK_OF(CONF_VALUE) *nval); 67 X509V3_CTX *ctx,
68static STACK_OF(CONF_VALUE) *i2v_EXTENDED_KEY_USAGE(X509V3_EXT_METHOD *method, 68 STACK_OF(CONF_VALUE) *nval);
69static STACK_OF(CONF_VALUE) *i2v_EXTENDED_KEY_USAGE(const X509V3_EXT_METHOD *method,
69 void *eku, STACK_OF(CONF_VALUE) *extlist); 70 void *eku, STACK_OF(CONF_VALUE) *extlist);
70 71
71const X509V3_EXT_METHOD v3_ext_ku = { 72const X509V3_EXT_METHOD v3_ext_ku = {
@@ -97,8 +98,9 @@ ASN1_ITEM_TEMPLATE_END(EXTENDED_KEY_USAGE)
97 98
98IMPLEMENT_ASN1_FUNCTIONS(EXTENDED_KEY_USAGE) 99IMPLEMENT_ASN1_FUNCTIONS(EXTENDED_KEY_USAGE)
99 100
100static STACK_OF(CONF_VALUE) *i2v_EXTENDED_KEY_USAGE(X509V3_EXT_METHOD *method, 101static STACK_OF(CONF_VALUE) *
101 void *a, STACK_OF(CONF_VALUE) *ext_list) 102 i2v_EXTENDED_KEY_USAGE(const X509V3_EXT_METHOD *method, void *a,
103 STACK_OF(CONF_VALUE) *ext_list)
102{ 104{
103 EXTENDED_KEY_USAGE *eku = a; 105 EXTENDED_KEY_USAGE *eku = a;
104 int i; 106 int i;
@@ -112,8 +114,8 @@ static STACK_OF(CONF_VALUE) *i2v_EXTENDED_KEY_USAGE(X509V3_EXT_METHOD *method,
112 return ext_list; 114 return ext_list;
113} 115}
114 116
115static void *v2i_EXTENDED_KEY_USAGE(X509V3_EXT_METHOD *method, 117static void *v2i_EXTENDED_KEY_USAGE(const X509V3_EXT_METHOD *method,
116 X509V3_CTX *ctx, STACK_OF(CONF_VALUE) *nval) 118 X509V3_CTX *ctx, STACK_OF(CONF_VALUE) *nval)
117{ 119{
118 EXTENDED_KEY_USAGE *extku; 120 EXTENDED_KEY_USAGE *extku;
119 char *extval; 121 char *extval;
diff --git a/src/lib/libcrypto/x509v3/v3_genn.c b/src/lib/libcrypto/x509v3/v3_genn.c
index 84b4b1c881..b628357301 100644
--- a/src/lib/libcrypto/x509v3/v3_genn.c
+++ b/src/lib/libcrypto/x509v3/v3_genn.c
@@ -3,7 +3,7 @@
3 * project 1999. 3 * project 1999.
4 */ 4 */
5/* ==================================================================== 5/* ====================================================================
6 * Copyright (c) 1999 The OpenSSL Project. All rights reserved. 6 * Copyright (c) 1999-2008 The OpenSSL Project. All rights reserved.
7 * 7 *
8 * Redistribution and use in source and binary forms, with or without 8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions 9 * modification, are permitted provided that the following conditions
@@ -99,3 +99,154 @@ ASN1_ITEM_TEMPLATE(GENERAL_NAMES) =
99ASN1_ITEM_TEMPLATE_END(GENERAL_NAMES) 99ASN1_ITEM_TEMPLATE_END(GENERAL_NAMES)
100 100
101IMPLEMENT_ASN1_FUNCTIONS(GENERAL_NAMES) 101IMPLEMENT_ASN1_FUNCTIONS(GENERAL_NAMES)
102
103GENERAL_NAME *GENERAL_NAME_dup(GENERAL_NAME *a)
104 {
105 return (GENERAL_NAME *) ASN1_dup((i2d_of_void *) i2d_GENERAL_NAME,
106 (d2i_of_void *) d2i_GENERAL_NAME,
107 (char *) a);
108 }
109
110/* Returns 0 if they are equal, != 0 otherwise. */
111int GENERAL_NAME_cmp(GENERAL_NAME *a, GENERAL_NAME *b)
112 {
113 int result = -1;
114
115 if (!a || !b || a->type != b->type) return -1;
116 switch(a->type)
117 {
118 case GEN_X400:
119 case GEN_EDIPARTY:
120 result = ASN1_TYPE_cmp(a->d.other, b->d.other);
121 break;
122
123 case GEN_OTHERNAME:
124 result = OTHERNAME_cmp(a->d.otherName, b->d.otherName);
125 break;
126
127 case GEN_EMAIL:
128 case GEN_DNS:
129 case GEN_URI:
130 result = ASN1_STRING_cmp(a->d.ia5, b->d.ia5);
131 break;
132
133 case GEN_DIRNAME:
134 result = X509_NAME_cmp(a->d.dirn, b->d.dirn);
135 break;
136
137 case GEN_IPADD:
138 result = ASN1_OCTET_STRING_cmp(a->d.ip, b->d.ip);
139 break;
140
141 case GEN_RID:
142 result = OBJ_cmp(a->d.rid, b->d.rid);
143 break;
144 }
145 return result;
146 }
147
148/* Returns 0 if they are equal, != 0 otherwise. */
149int OTHERNAME_cmp(OTHERNAME *a, OTHERNAME *b)
150 {
151 int result = -1;
152
153 if (!a || !b) return -1;
154 /* Check their type first. */
155 if ((result = OBJ_cmp(a->type_id, b->type_id)) != 0)
156 return result;
157 /* Check the value. */
158 result = ASN1_TYPE_cmp(a->value, b->value);
159 return result;
160 }
161
162void GENERAL_NAME_set0_value(GENERAL_NAME *a, int type, void *value)
163 {
164 switch(type)
165 {
166 case GEN_X400:
167 case GEN_EDIPARTY:
168 a->d.other = value;
169 break;
170
171 case GEN_OTHERNAME:
172 a->d.otherName = value;
173 break;
174
175 case GEN_EMAIL:
176 case GEN_DNS:
177 case GEN_URI:
178 a->d.ia5 = value;
179 break;
180
181 case GEN_DIRNAME:
182 a->d.dirn = value;
183 break;
184
185 case GEN_IPADD:
186 a->d.ip = value;
187 break;
188
189 case GEN_RID:
190 a->d.rid = value;
191 break;
192 }
193 a->type = type;
194 }
195
196void *GENERAL_NAME_get0_value(GENERAL_NAME *a, int *ptype)
197 {
198 if (ptype)
199 *ptype = a->type;
200 switch(a->type)
201 {
202 case GEN_X400:
203 case GEN_EDIPARTY:
204 return a->d.other;
205
206 case GEN_OTHERNAME:
207 return a->d.otherName;
208
209 case GEN_EMAIL:
210 case GEN_DNS:
211 case GEN_URI:
212 return a->d.ia5;
213
214 case GEN_DIRNAME:
215 return a->d.dirn;
216
217 case GEN_IPADD:
218 return a->d.ip;
219
220 case GEN_RID:
221 return a->d.rid;
222
223 default:
224 return NULL;
225 }
226 }
227
228int GENERAL_NAME_set0_othername(GENERAL_NAME *gen,
229 ASN1_OBJECT *oid, ASN1_TYPE *value)
230 {
231 OTHERNAME *oth;
232 oth = OTHERNAME_new();
233 if (!oth)
234 return 0;
235 oth->type_id = oid;
236 oth->value = value;
237 GENERAL_NAME_set0_value(gen, GEN_OTHERNAME, oth);
238 return 1;
239 }
240
241int GENERAL_NAME_get0_otherName(GENERAL_NAME *gen,
242 ASN1_OBJECT **poid, ASN1_TYPE **pvalue)
243 {
244 if (gen->type != GEN_OTHERNAME)
245 return 0;
246 if (poid)
247 *poid = gen->d.otherName->type_id;
248 if (pvalue)
249 *pvalue = gen->d.otherName->value;
250 return 1;
251 }
252
diff --git a/src/lib/libcrypto/x509v3/v3_lib.c b/src/lib/libcrypto/x509v3/v3_lib.c
index df3a48f43e..0f1e1d4422 100644
--- a/src/lib/libcrypto/x509v3/v3_lib.c
+++ b/src/lib/libcrypto/x509v3/v3_lib.c
@@ -84,20 +84,24 @@ int X509V3_EXT_add(X509V3_EXT_METHOD *ext)
84} 84}
85 85
86static int ext_cmp(const X509V3_EXT_METHOD * const *a, 86static int ext_cmp(const X509V3_EXT_METHOD * const *a,
87 const X509V3_EXT_METHOD * const *b) 87 const X509V3_EXT_METHOD * const *b)
88{ 88{
89 return ((*a)->ext_nid - (*b)->ext_nid); 89 return ((*a)->ext_nid - (*b)->ext_nid);
90} 90}
91 91
92X509V3_EXT_METHOD *X509V3_EXT_get_nid(int nid) 92DECLARE_OBJ_BSEARCH_CMP_FN(const X509V3_EXT_METHOD *, const X509V3_EXT_METHOD *,
93 ext);
94IMPLEMENT_OBJ_BSEARCH_CMP_FN(const X509V3_EXT_METHOD *,
95 const X509V3_EXT_METHOD *, ext);
96
97const X509V3_EXT_METHOD *X509V3_EXT_get_nid(int nid)
93{ 98{
94 X509V3_EXT_METHOD tmp, *t = &tmp, **ret; 99 X509V3_EXT_METHOD tmp;
100 const X509V3_EXT_METHOD *t = &tmp, * const *ret;
95 int idx; 101 int idx;
96 if(nid < 0) return NULL; 102 if(nid < 0) return NULL;
97 tmp.ext_nid = nid; 103 tmp.ext_nid = nid;
98 ret = (X509V3_EXT_METHOD **) OBJ_bsearch((char *)&t, 104 ret = OBJ_bsearch_ext(&t, standard_exts, STANDARD_EXTENSION_COUNT);
99 (char *)standard_exts, STANDARD_EXTENSION_COUNT,
100 sizeof(X509V3_EXT_METHOD *), (int (*)(const void *, const void *))ext_cmp);
101 if(ret) return *ret; 105 if(ret) return *ret;
102 if(!ext_list) return NULL; 106 if(!ext_list) return NULL;
103 idx = sk_X509V3_EXT_METHOD_find(ext_list, &tmp); 107 idx = sk_X509V3_EXT_METHOD_find(ext_list, &tmp);
@@ -105,7 +109,7 @@ X509V3_EXT_METHOD *X509V3_EXT_get_nid(int nid)
105 return sk_X509V3_EXT_METHOD_value(ext_list, idx); 109 return sk_X509V3_EXT_METHOD_value(ext_list, idx);
106} 110}
107 111
108X509V3_EXT_METHOD *X509V3_EXT_get(X509_EXTENSION *ext) 112const X509V3_EXT_METHOD *X509V3_EXT_get(X509_EXTENSION *ext)
109{ 113{
110 int nid; 114 int nid;
111 if((nid = OBJ_obj2nid(ext->object)) == NID_undef) return NULL; 115 if((nid = OBJ_obj2nid(ext->object)) == NID_undef) return NULL;
@@ -122,7 +126,9 @@ int X509V3_EXT_add_list(X509V3_EXT_METHOD *extlist)
122 126
123int X509V3_EXT_add_alias(int nid_to, int nid_from) 127int X509V3_EXT_add_alias(int nid_to, int nid_from)
124{ 128{
125 X509V3_EXT_METHOD *ext, *tmpext; 129 const X509V3_EXT_METHOD *ext;
130 X509V3_EXT_METHOD *tmpext;
131
126 if(!(ext = X509V3_EXT_get_nid(nid_from))) { 132 if(!(ext = X509V3_EXT_get_nid(nid_from))) {
127 X509V3err(X509V3_F_X509V3_EXT_ADD_ALIAS,X509V3_R_EXTENSION_NOT_FOUND); 133 X509V3err(X509V3_F_X509V3_EXT_ADD_ALIAS,X509V3_R_EXTENSION_NOT_FOUND);
128 return 0; 134 return 0;
@@ -161,7 +167,7 @@ int X509V3_add_standard_extensions(void)
161 167
162void *X509V3_EXT_d2i(X509_EXTENSION *ext) 168void *X509V3_EXT_d2i(X509_EXTENSION *ext)
163{ 169{
164 X509V3_EXT_METHOD *method; 170 const X509V3_EXT_METHOD *method;
165 const unsigned char *p; 171 const unsigned char *p;
166 172
167 if(!(method = X509V3_EXT_get(ext))) return NULL; 173 if(!(method = X509V3_EXT_get(ext))) return NULL;
diff --git a/src/lib/libcrypto/x509v3/v3_ocsp.c b/src/lib/libcrypto/x509v3/v3_ocsp.c
index e426ea930c..0c165af314 100644
--- a/src/lib/libcrypto/x509v3/v3_ocsp.c
+++ b/src/lib/libcrypto/x509v3/v3_ocsp.c
@@ -68,19 +68,26 @@
68/* OCSP extensions and a couple of CRL entry extensions 68/* OCSP extensions and a couple of CRL entry extensions
69 */ 69 */
70 70
71static int i2r_ocsp_crlid(X509V3_EXT_METHOD *method, void *nonce, BIO *out, int indent); 71static int i2r_ocsp_crlid(const X509V3_EXT_METHOD *method, void *nonce,
72static int i2r_ocsp_acutoff(X509V3_EXT_METHOD *method, void *nonce, BIO *out, int indent); 72 BIO *out, int indent);
73static int i2r_object(X509V3_EXT_METHOD *method, void *obj, BIO *out, int indent); 73static int i2r_ocsp_acutoff(const X509V3_EXT_METHOD *method, void *nonce,
74 BIO *out, int indent);
75static int i2r_object(const X509V3_EXT_METHOD *method, void *obj, BIO *out,
76 int indent);
74 77
75static void *ocsp_nonce_new(void); 78static void *ocsp_nonce_new(void);
76static int i2d_ocsp_nonce(void *a, unsigned char **pp); 79static int i2d_ocsp_nonce(void *a, unsigned char **pp);
77static void *d2i_ocsp_nonce(void *a, const unsigned char **pp, long length); 80static void *d2i_ocsp_nonce(void *a, const unsigned char **pp, long length);
78static void ocsp_nonce_free(void *a); 81static void ocsp_nonce_free(void *a);
79static int i2r_ocsp_nonce(X509V3_EXT_METHOD *method, void *nonce, BIO *out, int indent); 82static int i2r_ocsp_nonce(const X509V3_EXT_METHOD *method, void *nonce,
83 BIO *out, int indent);
80 84
81static int i2r_ocsp_nocheck(X509V3_EXT_METHOD *method, void *nocheck, BIO *out, int indent); 85static int i2r_ocsp_nocheck(const X509V3_EXT_METHOD *method,
82static void *s2i_ocsp_nocheck(X509V3_EXT_METHOD *method, X509V3_CTX *ctx, const char *str); 86 void *nocheck, BIO *out, int indent);
83static int i2r_ocsp_serviceloc(X509V3_EXT_METHOD *method, void *in, BIO *bp, int ind); 87static void *s2i_ocsp_nocheck(const X509V3_EXT_METHOD *method, X509V3_CTX *ctx,
88 const char *str);
89static int i2r_ocsp_serviceloc(const X509V3_EXT_METHOD *method, void *in,
90 BIO *bp, int ind);
84 91
85const X509V3_EXT_METHOD v3_ocsp_crlid = { 92const X509V3_EXT_METHOD v3_ocsp_crlid = {
86 NID_id_pkix_OCSP_CrlID, 0, ASN1_ITEM_ref(OCSP_CRLID), 93 NID_id_pkix_OCSP_CrlID, 0, ASN1_ITEM_ref(OCSP_CRLID),
@@ -148,44 +155,47 @@ const X509V3_EXT_METHOD v3_ocsp_serviceloc = {
148 NULL 155 NULL
149}; 156};
150 157
151static int i2r_ocsp_crlid(X509V3_EXT_METHOD *method, void *in, BIO *bp, int ind) 158static int i2r_ocsp_crlid(const X509V3_EXT_METHOD *method, void *in, BIO *bp,
159 int ind)
152{ 160{
153 OCSP_CRLID *a = in; 161 OCSP_CRLID *a = in;
154 if (a->crlUrl) 162 if (a->crlUrl)
155 { 163 {
156 if (!BIO_printf(bp, "%*scrlUrl: ", ind, "")) goto err; 164 if (BIO_printf(bp, "%*scrlUrl: ", ind, "") <= 0) goto err;
157 if (!ASN1_STRING_print(bp, (ASN1_STRING*)a->crlUrl)) goto err; 165 if (!ASN1_STRING_print(bp, (ASN1_STRING*)a->crlUrl)) goto err;
158 if (!BIO_write(bp, "\n", 1)) goto err; 166 if (BIO_write(bp, "\n", 1) <= 0) goto err;
159 } 167 }
160 if (a->crlNum) 168 if (a->crlNum)
161 { 169 {
162 if (!BIO_printf(bp, "%*scrlNum: ", ind, "")) goto err; 170 if (BIO_printf(bp, "%*scrlNum: ", ind, "") <= 0) goto err;
163 if (!i2a_ASN1_INTEGER(bp, a->crlNum)) goto err; 171 if (i2a_ASN1_INTEGER(bp, a->crlNum) <= 0) goto err;
164 if (!BIO_write(bp, "\n", 1)) goto err; 172 if (BIO_write(bp, "\n", 1) <= 0) goto err;
165 } 173 }
166 if (a->crlTime) 174 if (a->crlTime)
167 { 175 {
168 if (!BIO_printf(bp, "%*scrlTime: ", ind, "")) goto err; 176 if (BIO_printf(bp, "%*scrlTime: ", ind, "") <= 0) goto err;
169 if (!ASN1_GENERALIZEDTIME_print(bp, a->crlTime)) goto err; 177 if (!ASN1_GENERALIZEDTIME_print(bp, a->crlTime)) goto err;
170 if (!BIO_write(bp, "\n", 1)) goto err; 178 if (BIO_write(bp, "\n", 1) <= 0) goto err;
171 } 179 }
172 return 1; 180 return 1;
173 err: 181 err:
174 return 0; 182 return 0;
175} 183}
176 184
177static int i2r_ocsp_acutoff(X509V3_EXT_METHOD *method, void *cutoff, BIO *bp, int ind) 185static int i2r_ocsp_acutoff(const X509V3_EXT_METHOD *method, void *cutoff,
186 BIO *bp, int ind)
178{ 187{
179 if (!BIO_printf(bp, "%*s", ind, "")) return 0; 188 if (BIO_printf(bp, "%*s", ind, "") <= 0) return 0;
180 if(!ASN1_GENERALIZEDTIME_print(bp, cutoff)) return 0; 189 if(!ASN1_GENERALIZEDTIME_print(bp, cutoff)) return 0;
181 return 1; 190 return 1;
182} 191}
183 192
184 193
185static int i2r_object(X509V3_EXT_METHOD *method, void *oid, BIO *bp, int ind) 194static int i2r_object(const X509V3_EXT_METHOD *method, void *oid, BIO *bp,
195 int ind)
186{ 196{
187 if (!BIO_printf(bp, "%*s", ind, "")) return 0; 197 if (BIO_printf(bp, "%*s", ind, "") <= 0) return 0;
188 if(!i2a_ASN1_OBJECT(bp, oid)) return 0; 198 if(i2a_ASN1_OBJECT(bp, oid) <= 0) return 0;
189 return 1; 199 return 1;
190} 200}
191 201
@@ -232,7 +242,8 @@ static void ocsp_nonce_free(void *a)
232 M_ASN1_OCTET_STRING_free(a); 242 M_ASN1_OCTET_STRING_free(a);
233} 243}
234 244
235static int i2r_ocsp_nonce(X509V3_EXT_METHOD *method, void *nonce, BIO *out, int indent) 245static int i2r_ocsp_nonce(const X509V3_EXT_METHOD *method, void *nonce,
246 BIO *out, int indent)
236{ 247{
237 if(BIO_printf(out, "%*s", indent, "") <= 0) return 0; 248 if(BIO_printf(out, "%*s", indent, "") <= 0) return 0;
238 if(i2a_ASN1_STRING(out, nonce, V_ASN1_OCTET_STRING) <= 0) return 0; 249 if(i2a_ASN1_STRING(out, nonce, V_ASN1_OCTET_STRING) <= 0) return 0;
@@ -241,17 +252,20 @@ static int i2r_ocsp_nonce(X509V3_EXT_METHOD *method, void *nonce, BIO *out, int
241 252
242/* Nocheck is just a single NULL. Don't print anything and always set it */ 253/* Nocheck is just a single NULL. Don't print anything and always set it */
243 254
244static int i2r_ocsp_nocheck(X509V3_EXT_METHOD *method, void *nocheck, BIO *out, int indent) 255static int i2r_ocsp_nocheck(const X509V3_EXT_METHOD *method, void *nocheck,
256 BIO *out, int indent)
245{ 257{
246 return 1; 258 return 1;
247} 259}
248 260
249static void *s2i_ocsp_nocheck(X509V3_EXT_METHOD *method, X509V3_CTX *ctx, const char *str) 261static void *s2i_ocsp_nocheck(const X509V3_EXT_METHOD *method, X509V3_CTX *ctx,
262 const char *str)
250{ 263{
251 return ASN1_NULL_new(); 264 return ASN1_NULL_new();
252} 265}
253 266
254static int i2r_ocsp_serviceloc(X509V3_EXT_METHOD *method, void *in, BIO *bp, int ind) 267static int i2r_ocsp_serviceloc(const X509V3_EXT_METHOD *method, void *in,
268 BIO *bp, int ind)
255 { 269 {
256 int i; 270 int i;
257 OCSP_SERVICELOC *a = in; 271 OCSP_SERVICELOC *a = in;
diff --git a/src/lib/libcrypto/x509v3/v3_prn.c b/src/lib/libcrypto/x509v3/v3_prn.c
index c1bb17f105..3146218708 100644
--- a/src/lib/libcrypto/x509v3/v3_prn.c
+++ b/src/lib/libcrypto/x509v3/v3_prn.c
@@ -110,7 +110,7 @@ int X509V3_EXT_print(BIO *out, X509_EXTENSION *ext, unsigned long flag, int inde
110 void *ext_str = NULL; 110 void *ext_str = NULL;
111 char *value = NULL; 111 char *value = NULL;
112 const unsigned char *p; 112 const unsigned char *p;
113 X509V3_EXT_METHOD *method; 113 const X509V3_EXT_METHOD *method;
114 STACK_OF(CONF_VALUE) *nval = NULL; 114 STACK_OF(CONF_VALUE) *nval = NULL;
115 int ok = 1; 115 int ok = 1;
116 116
diff --git a/src/lib/libcrypto/x509v3/v3_purp.c b/src/lib/libcrypto/x509v3/v3_purp.c
index e18751e01c..181bd34979 100644
--- a/src/lib/libcrypto/x509v3/v3_purp.c
+++ b/src/lib/libcrypto/x509v3/v3_purp.c
@@ -71,6 +71,7 @@ static int purpose_smime(const X509 *x, int ca);
71static int check_purpose_smime_sign(const X509_PURPOSE *xp, const X509 *x, int ca); 71static int check_purpose_smime_sign(const X509_PURPOSE *xp, const X509 *x, int ca);
72static int check_purpose_smime_encrypt(const X509_PURPOSE *xp, const X509 *x, int ca); 72static int check_purpose_smime_encrypt(const X509_PURPOSE *xp, const X509 *x, int ca);
73static int check_purpose_crl_sign(const X509_PURPOSE *xp, const X509 *x, int ca); 73static int check_purpose_crl_sign(const X509_PURPOSE *xp, const X509 *x, int ca);
74static int check_purpose_timestamp_sign(const X509_PURPOSE *xp, const X509 *x, int ca);
74static int no_check(const X509_PURPOSE *xp, const X509 *x, int ca); 75static int no_check(const X509_PURPOSE *xp, const X509 *x, int ca);
75static int ocsp_helper(const X509_PURPOSE *xp, const X509 *x, int ca); 76static int ocsp_helper(const X509_PURPOSE *xp, const X509 *x, int ca);
76 77
@@ -87,6 +88,7 @@ static X509_PURPOSE xstandard[] = {
87 {X509_PURPOSE_CRL_SIGN, X509_TRUST_COMPAT, 0, check_purpose_crl_sign, "CRL signing", "crlsign", NULL}, 88 {X509_PURPOSE_CRL_SIGN, X509_TRUST_COMPAT, 0, check_purpose_crl_sign, "CRL signing", "crlsign", NULL},
88 {X509_PURPOSE_ANY, X509_TRUST_DEFAULT, 0, no_check, "Any Purpose", "any", NULL}, 89 {X509_PURPOSE_ANY, X509_TRUST_DEFAULT, 0, no_check, "Any Purpose", "any", NULL},
89 {X509_PURPOSE_OCSP_HELPER, X509_TRUST_COMPAT, 0, ocsp_helper, "OCSP helper", "ocsphelper", NULL}, 90 {X509_PURPOSE_OCSP_HELPER, X509_TRUST_COMPAT, 0, ocsp_helper, "OCSP helper", "ocsphelper", NULL},
91 {X509_PURPOSE_TIMESTAMP_SIGN, X509_TRUST_TSA, 0, check_purpose_timestamp_sign, "Time Stamp signing", "timestampsign", NULL},
90}; 92};
91 93
92#define X509_PURPOSE_COUNT (sizeof(xstandard)/sizeof(X509_PURPOSE)) 94#define X509_PURPOSE_COUNT (sizeof(xstandard)/sizeof(X509_PURPOSE))
@@ -265,11 +267,14 @@ int X509_PURPOSE_get_trust(X509_PURPOSE *xp)
265 return xp->trust; 267 return xp->trust;
266} 268}
267 269
268static int nid_cmp(int *a, int *b) 270static int nid_cmp(const int *a, const int *b)
269 { 271 {
270 return *a - *b; 272 return *a - *b;
271 } 273 }
272 274
275DECLARE_OBJ_BSEARCH_CMP_FN(int, int, nid);
276IMPLEMENT_OBJ_BSEARCH_CMP_FN(int, int, nid);
277
273int X509_supported_extension(X509_EXTENSION *ex) 278int X509_supported_extension(X509_EXTENSION *ex)
274 { 279 {
275 /* This table is a list of the NIDs of supported extensions: 280 /* This table is a list of the NIDs of supported extensions:
@@ -280,7 +285,7 @@ int X509_supported_extension(X509_EXTENSION *ex)
280 * searched using bsearch. 285 * searched using bsearch.
281 */ 286 */
282 287
283 static int supported_nids[] = { 288 static const int supported_nids[] = {
284 NID_netscape_cert_type, /* 71 */ 289 NID_netscape_cert_type, /* 71 */
285 NID_key_usage, /* 83 */ 290 NID_key_usage, /* 83 */
286 NID_subject_alt_name, /* 85 */ 291 NID_subject_alt_name, /* 85 */
@@ -292,24 +297,62 @@ int X509_supported_extension(X509_EXTENSION *ex)
292 NID_sbgp_autonomousSysNum, /* 291 */ 297 NID_sbgp_autonomousSysNum, /* 291 */
293#endif 298#endif
294 NID_policy_constraints, /* 401 */ 299 NID_policy_constraints, /* 401 */
295 NID_proxyCertInfo, /* 661 */ 300 NID_proxyCertInfo, /* 663 */
301 NID_name_constraints, /* 666 */
302 NID_policy_mappings, /* 747 */
296 NID_inhibit_any_policy /* 748 */ 303 NID_inhibit_any_policy /* 748 */
297 }; 304 };
298 305
299 int ex_nid; 306 int ex_nid = OBJ_obj2nid(X509_EXTENSION_get_object(ex));
300
301 ex_nid = OBJ_obj2nid(X509_EXTENSION_get_object(ex));
302 307
303 if (ex_nid == NID_undef) 308 if (ex_nid == NID_undef)
304 return 0; 309 return 0;
305 310
306 if (OBJ_bsearch((char *)&ex_nid, (char *)supported_nids, 311 if (OBJ_bsearch_nid(&ex_nid, supported_nids,
307 sizeof(supported_nids)/sizeof(int), sizeof(int), 312 sizeof(supported_nids)/sizeof(int)))
308 (int (*)(const void *, const void *))nid_cmp))
309 return 1; 313 return 1;
310 return 0; 314 return 0;
311 } 315 }
312 316
317static void setup_dp(X509 *x, DIST_POINT *dp)
318 {
319 X509_NAME *iname = NULL;
320 int i;
321 if (dp->reasons)
322 {
323 if (dp->reasons->length > 0)
324 dp->dp_reasons = dp->reasons->data[0];
325 if (dp->reasons->length > 1)
326 dp->dp_reasons |= (dp->reasons->data[1] << 8);
327 dp->dp_reasons &= CRLDP_ALL_REASONS;
328 }
329 else
330 dp->dp_reasons = CRLDP_ALL_REASONS;
331 if (!dp->distpoint || (dp->distpoint->type != 1))
332 return;
333 for (i = 0; i < sk_GENERAL_NAME_num(dp->CRLissuer); i++)
334 {
335 GENERAL_NAME *gen = sk_GENERAL_NAME_value(dp->CRLissuer, i);
336 if (gen->type == GEN_DIRNAME)
337 {
338 iname = gen->d.directoryName;
339 break;
340 }
341 }
342 if (!iname)
343 iname = X509_get_issuer_name(x);
344
345 DIST_POINT_set_dpname(dp->distpoint, iname);
346
347 }
348
349static void setup_crldp(X509 *x)
350 {
351 int i;
352 x->crldp = X509_get_ext_d2i(x, NID_crl_distribution_points, NULL, NULL);
353 for (i = 0; i < sk_DIST_POINT_num(x->crldp); i++)
354 setup_dp(x, sk_DIST_POINT_value(x->crldp, i));
355 }
313 356
314static void x509v3_cache_extensions(X509 *x) 357static void x509v3_cache_extensions(X509 *x)
315{ 358{
@@ -417,16 +460,25 @@ static void x509v3_cache_extensions(X509 *x)
417 } 460 }
418 x->skid =X509_get_ext_d2i(x, NID_subject_key_identifier, NULL, NULL); 461 x->skid =X509_get_ext_d2i(x, NID_subject_key_identifier, NULL, NULL);
419 x->akid =X509_get_ext_d2i(x, NID_authority_key_identifier, NULL, NULL); 462 x->akid =X509_get_ext_d2i(x, NID_authority_key_identifier, NULL, NULL);
463 x->altname = X509_get_ext_d2i(x, NID_subject_alt_name, NULL, NULL);
464 x->nc = X509_get_ext_d2i(x, NID_name_constraints, &i, NULL);
465 if (!x->nc && (i != -1))
466 x->ex_flags |= EXFLAG_INVALID;
467 setup_crldp(x);
468
420#ifndef OPENSSL_NO_RFC3779 469#ifndef OPENSSL_NO_RFC3779
421 x->rfc3779_addr =X509_get_ext_d2i(x, NID_sbgp_ipAddrBlock, NULL, NULL); 470 x->rfc3779_addr =X509_get_ext_d2i(x, NID_sbgp_ipAddrBlock, NULL, NULL);
422 x->rfc3779_asid =X509_get_ext_d2i(x, NID_sbgp_autonomousSysNum, 471 x->rfc3779_asid =X509_get_ext_d2i(x, NID_sbgp_autonomousSysNum,
423 NULL, NULL); 472 NULL, NULL);
424#endif 473#endif
425 for (i = 0; i < X509_get_ext_count(x); i++) 474 for (i = 0; i < X509_get_ext_count(x); i++)
426 { 475 {
427 ex = X509_get_ext(x, i); 476 ex = X509_get_ext(x, i);
428 if (!X509_EXTENSION_get_critical(ex)) 477 if (!X509_EXTENSION_get_critical(ex))
429 continue; 478 continue;
479 if (OBJ_obj2nid(X509_EXTENSION_get_object(ex))
480 == NID_freshest_crl)
481 x->ex_flags |= EXFLAG_FRESHEST;
430 if (!X509_supported_extension(ex)) 482 if (!X509_supported_extension(ex))
431 { 483 {
432 x->ex_flags |= EXFLAG_CRITICAL; 484 x->ex_flags |= EXFLAG_CRITICAL;
@@ -594,6 +646,41 @@ static int ocsp_helper(const X509_PURPOSE *xp, const X509 *x, int ca)
594 return 1; 646 return 1;
595} 647}
596 648
649static int check_purpose_timestamp_sign(const X509_PURPOSE *xp, const X509 *x,
650 int ca)
651{
652 int i_ext;
653
654 /* If ca is true we must return if this is a valid CA certificate. */
655 if (ca) return check_ca(x);
656
657 /*
658 * Check the optional key usage field:
659 * if Key Usage is present, it must be one of digitalSignature
660 * and/or nonRepudiation (other values are not consistent and shall
661 * be rejected).
662 */
663 if ((x->ex_flags & EXFLAG_KUSAGE)
664 && ((x->ex_kusage & ~(KU_NON_REPUDIATION | KU_DIGITAL_SIGNATURE)) ||
665 !(x->ex_kusage & (KU_NON_REPUDIATION | KU_DIGITAL_SIGNATURE))))
666 return 0;
667
668 /* Only time stamp key usage is permitted and it's required. */
669 if (!(x->ex_flags & EXFLAG_XKUSAGE) || x->ex_xkusage != XKU_TIMESTAMP)
670 return 0;
671
672 /* Extended Key Usage MUST be critical */
673 i_ext = X509_get_ext_by_NID((X509 *) x, NID_ext_key_usage, 0);
674 if (i_ext >= 0)
675 {
676 X509_EXTENSION *ext = X509_get_ext((X509 *) x, i_ext);
677 if (!X509_EXTENSION_get_critical(ext))
678 return 0;
679 }
680
681 return 1;
682}
683
597static int no_check(const X509_PURPOSE *xp, const X509 *x, int ca) 684static int no_check(const X509_PURPOSE *xp, const X509 *x, int ca)
598{ 685{
599 return 1; 686 return 1;
@@ -618,39 +705,14 @@ int X509_check_issued(X509 *issuer, X509 *subject)
618 return X509_V_ERR_SUBJECT_ISSUER_MISMATCH; 705 return X509_V_ERR_SUBJECT_ISSUER_MISMATCH;
619 x509v3_cache_extensions(issuer); 706 x509v3_cache_extensions(issuer);
620 x509v3_cache_extensions(subject); 707 x509v3_cache_extensions(subject);
621 if(subject->akid) { 708
622 /* Check key ids (if present) */ 709 if(subject->akid)
623 if(subject->akid->keyid && issuer->skid && 710 {
624 ASN1_OCTET_STRING_cmp(subject->akid->keyid, issuer->skid) ) 711 int ret = X509_check_akid(issuer, subject->akid);
625 return X509_V_ERR_AKID_SKID_MISMATCH; 712 if (ret != X509_V_OK)
626 /* Check serial number */ 713 return ret;
627 if(subject->akid->serial &&
628 ASN1_INTEGER_cmp(X509_get_serialNumber(issuer),
629 subject->akid->serial))
630 return X509_V_ERR_AKID_ISSUER_SERIAL_MISMATCH;
631 /* Check issuer name */
632 if(subject->akid->issuer) {
633 /* Ugh, for some peculiar reason AKID includes
634 * SEQUENCE OF GeneralName. So look for a DirName.
635 * There may be more than one but we only take any
636 * notice of the first.
637 */
638 GENERAL_NAMES *gens;
639 GENERAL_NAME *gen;
640 X509_NAME *nm = NULL;
641 int i;
642 gens = subject->akid->issuer;
643 for(i = 0; i < sk_GENERAL_NAME_num(gens); i++) {
644 gen = sk_GENERAL_NAME_value(gens, i);
645 if(gen->type == GEN_DIRNAME) {
646 nm = gen->d.dirn;
647 break;
648 }
649 }
650 if(nm && X509_NAME_cmp(nm, X509_get_issuer_name(issuer)))
651 return X509_V_ERR_AKID_ISSUER_SERIAL_MISMATCH;
652 } 714 }
653 } 715
654 if(subject->ex_flags & EXFLAG_PROXY) 716 if(subject->ex_flags & EXFLAG_PROXY)
655 { 717 {
656 if(ku_reject(issuer, KU_DIGITAL_SIGNATURE)) 718 if(ku_reject(issuer, KU_DIGITAL_SIGNATURE))
@@ -661,3 +723,45 @@ int X509_check_issued(X509 *issuer, X509 *subject)
661 return X509_V_OK; 723 return X509_V_OK;
662} 724}
663 725
726int X509_check_akid(X509 *issuer, AUTHORITY_KEYID *akid)
727 {
728
729 if(!akid)
730 return X509_V_OK;
731
732 /* Check key ids (if present) */
733 if(akid->keyid && issuer->skid &&
734 ASN1_OCTET_STRING_cmp(akid->keyid, issuer->skid) )
735 return X509_V_ERR_AKID_SKID_MISMATCH;
736 /* Check serial number */
737 if(akid->serial &&
738 ASN1_INTEGER_cmp(X509_get_serialNumber(issuer), akid->serial))
739 return X509_V_ERR_AKID_ISSUER_SERIAL_MISMATCH;
740 /* Check issuer name */
741 if(akid->issuer)
742 {
743 /* Ugh, for some peculiar reason AKID includes
744 * SEQUENCE OF GeneralName. So look for a DirName.
745 * There may be more than one but we only take any
746 * notice of the first.
747 */
748 GENERAL_NAMES *gens;
749 GENERAL_NAME *gen;
750 X509_NAME *nm = NULL;
751 int i;
752 gens = akid->issuer;
753 for(i = 0; i < sk_GENERAL_NAME_num(gens); i++)
754 {
755 gen = sk_GENERAL_NAME_value(gens, i);
756 if(gen->type == GEN_DIRNAME)
757 {
758 nm = gen->d.dirn;
759 break;
760 }
761 }
762 if(nm && X509_NAME_cmp(nm, X509_get_issuer_name(issuer)))
763 return X509_V_ERR_AKID_ISSUER_SERIAL_MISMATCH;
764 }
765 return X509_V_OK;
766 }
767
diff --git a/src/lib/libcrypto/x509v3/v3_utl.c b/src/lib/libcrypto/x509v3/v3_utl.c
index 2cb53008e3..e030234540 100644
--- a/src/lib/libcrypto/x509v3/v3_utl.c
+++ b/src/lib/libcrypto/x509v3/v3_utl.c
@@ -67,9 +67,9 @@
67 67
68static char *strip_spaces(char *name); 68static char *strip_spaces(char *name);
69static int sk_strcmp(const char * const *a, const char * const *b); 69static int sk_strcmp(const char * const *a, const char * const *b);
70static STACK *get_email(X509_NAME *name, GENERAL_NAMES *gens); 70static STACK_OF(OPENSSL_STRING) *get_email(X509_NAME *name, GENERAL_NAMES *gens);
71static void str_free(void *str); 71static void str_free(OPENSSL_STRING str);
72static int append_ia5(STACK **sk, ASN1_IA5STRING *email); 72static int append_ia5(STACK_OF(OPENSSL_STRING) **sk, ASN1_IA5STRING *email);
73 73
74static int ipv4_from_asc(unsigned char *v4, const char *in); 74static int ipv4_from_asc(unsigned char *v4, const char *in);
75static int ipv6_from_asc(unsigned char *v6, const char *in); 75static int ipv6_from_asc(unsigned char *v6, const char *in);
@@ -344,7 +344,7 @@ static char *strip_spaces(char *name)
344 char *p, *q; 344 char *p, *q;
345 /* Skip over leading spaces */ 345 /* Skip over leading spaces */
346 p = name; 346 p = name;
347 while(isspace((unsigned char)*p)) p++; 347 while(*p && isspace((unsigned char)*p)) p++;
348 if(!*p) return NULL; 348 if(!*p) return NULL;
349 q = p + strlen(p) - 1; 349 q = p + strlen(p) - 1;
350 while((q != p) && isspace((unsigned char)*q)) q--; 350 while((q != p) && isspace((unsigned char)*q)) q--;
@@ -360,10 +360,10 @@ static char *strip_spaces(char *name)
360 * @@@ (Contents of buffer are always kept in ASCII, also on EBCDIC machines) 360 * @@@ (Contents of buffer are always kept in ASCII, also on EBCDIC machines)
361 */ 361 */
362 362
363char *hex_to_string(unsigned char *buffer, long len) 363char *hex_to_string(const unsigned char *buffer, long len)
364{ 364{
365 char *tmp, *q; 365 char *tmp, *q;
366 unsigned char *p; 366 const unsigned char *p;
367 int i; 367 int i;
368 const static char hexdig[] = "0123456789ABCDEF"; 368 const static char hexdig[] = "0123456789ABCDEF";
369 if(!buffer || !len) return NULL; 369 if(!buffer || !len) return NULL;
@@ -389,7 +389,7 @@ char *hex_to_string(unsigned char *buffer, long len)
389 * a buffer 389 * a buffer
390 */ 390 */
391 391
392unsigned char *string_to_hex(char *str, long *len) 392unsigned char *string_to_hex(const char *str, long *len)
393{ 393{
394 unsigned char *hexbuf, *q; 394 unsigned char *hexbuf, *q;
395 unsigned char ch, cl, *p; 395 unsigned char ch, cl, *p;
@@ -463,21 +463,23 @@ static int sk_strcmp(const char * const *a, const char * const *b)
463 return strcmp(*a, *b); 463 return strcmp(*a, *b);
464} 464}
465 465
466STACK *X509_get1_email(X509 *x) 466STACK_OF(OPENSSL_STRING) *X509_get1_email(X509 *x)
467{ 467{
468 GENERAL_NAMES *gens; 468 GENERAL_NAMES *gens;
469 STACK *ret; 469 STACK_OF(OPENSSL_STRING) *ret;
470
470 gens = X509_get_ext_d2i(x, NID_subject_alt_name, NULL, NULL); 471 gens = X509_get_ext_d2i(x, NID_subject_alt_name, NULL, NULL);
471 ret = get_email(X509_get_subject_name(x), gens); 472 ret = get_email(X509_get_subject_name(x), gens);
472 sk_GENERAL_NAME_pop_free(gens, GENERAL_NAME_free); 473 sk_GENERAL_NAME_pop_free(gens, GENERAL_NAME_free);
473 return ret; 474 return ret;
474} 475}
475 476
476STACK *X509_get1_ocsp(X509 *x) 477STACK_OF(OPENSSL_STRING) *X509_get1_ocsp(X509 *x)
477{ 478{
478 AUTHORITY_INFO_ACCESS *info; 479 AUTHORITY_INFO_ACCESS *info;
479 STACK *ret = NULL; 480 STACK_OF(OPENSSL_STRING) *ret = NULL;
480 int i; 481 int i;
482
481 info = X509_get_ext_d2i(x, NID_info_access, NULL, NULL); 483 info = X509_get_ext_d2i(x, NID_info_access, NULL, NULL);
482 if (!info) 484 if (!info)
483 return NULL; 485 return NULL;
@@ -497,11 +499,12 @@ STACK *X509_get1_ocsp(X509 *x)
497 return ret; 499 return ret;
498} 500}
499 501
500STACK *X509_REQ_get1_email(X509_REQ *x) 502STACK_OF(OPENSSL_STRING) *X509_REQ_get1_email(X509_REQ *x)
501{ 503{
502 GENERAL_NAMES *gens; 504 GENERAL_NAMES *gens;
503 STACK_OF(X509_EXTENSION) *exts; 505 STACK_OF(X509_EXTENSION) *exts;
504 STACK *ret; 506 STACK_OF(OPENSSL_STRING) *ret;
507
505 exts = X509_REQ_get_extensions(x); 508 exts = X509_REQ_get_extensions(x);
506 gens = X509V3_get_d2i(exts, NID_subject_alt_name, NULL, NULL); 509 gens = X509V3_get_d2i(exts, NID_subject_alt_name, NULL, NULL);
507 ret = get_email(X509_REQ_get_subject_name(x), gens); 510 ret = get_email(X509_REQ_get_subject_name(x), gens);
@@ -511,9 +514,9 @@ STACK *X509_REQ_get1_email(X509_REQ *x)
511} 514}
512 515
513 516
514static STACK *get_email(X509_NAME *name, GENERAL_NAMES *gens) 517static STACK_OF(OPENSSL_STRING) *get_email(X509_NAME *name, GENERAL_NAMES *gens)
515{ 518{
516 STACK *ret = NULL; 519 STACK_OF(OPENSSL_STRING) *ret = NULL;
517 X509_NAME_ENTRY *ne; 520 X509_NAME_ENTRY *ne;
518 ASN1_IA5STRING *email; 521 ASN1_IA5STRING *email;
519 GENERAL_NAME *gen; 522 GENERAL_NAME *gen;
@@ -536,23 +539,23 @@ static STACK *get_email(X509_NAME *name, GENERAL_NAMES *gens)
536 return ret; 539 return ret;
537} 540}
538 541
539static void str_free(void *str) 542static void str_free(OPENSSL_STRING str)
540{ 543{
541 OPENSSL_free(str); 544 OPENSSL_free(str);
542} 545}
543 546
544static int append_ia5(STACK **sk, ASN1_IA5STRING *email) 547static int append_ia5(STACK_OF(OPENSSL_STRING) **sk, ASN1_IA5STRING *email)
545{ 548{
546 char *emtmp; 549 char *emtmp;
547 /* First some sanity checks */ 550 /* First some sanity checks */
548 if(email->type != V_ASN1_IA5STRING) return 1; 551 if(email->type != V_ASN1_IA5STRING) return 1;
549 if(!email->data || !email->length) return 1; 552 if(!email->data || !email->length) return 1;
550 if(!*sk) *sk = sk_new(sk_strcmp); 553 if(!*sk) *sk = sk_OPENSSL_STRING_new(sk_strcmp);
551 if(!*sk) return 0; 554 if(!*sk) return 0;
552 /* Don't add duplicates */ 555 /* Don't add duplicates */
553 if(sk_find(*sk, (char *)email->data) != -1) return 1; 556 if(sk_OPENSSL_STRING_find(*sk, (char *)email->data) != -1) return 1;
554 emtmp = BUF_strdup((char *)email->data); 557 emtmp = BUF_strdup((char *)email->data);
555 if(!emtmp || !sk_push(*sk, emtmp)) { 558 if(!emtmp || !sk_OPENSSL_STRING_push(*sk, emtmp)) {
556 X509_email_free(*sk); 559 X509_email_free(*sk);
557 *sk = NULL; 560 *sk = NULL;
558 return 0; 561 return 0;
@@ -560,9 +563,9 @@ static int append_ia5(STACK **sk, ASN1_IA5STRING *email)
560 return 1; 563 return 1;
561} 564}
562 565
563void X509_email_free(STACK *sk) 566void X509_email_free(STACK_OF(OPENSSL_STRING) *sk)
564{ 567{
565 sk_pop_free(sk, str_free); 568 sk_OPENSSL_STRING_pop_free(sk, str_free);
566} 569}
567 570
568/* Convert IP addresses both IPv4 and IPv6 into an 571/* Convert IP addresses both IPv4 and IPv6 into an
diff --git a/src/lib/libcrypto/x509v3/v3err.c b/src/lib/libcrypto/x509v3/v3err.c
index d538ad8b80..f9f6f1f91f 100644
--- a/src/lib/libcrypto/x509v3/v3err.c
+++ b/src/lib/libcrypto/x509v3/v3err.c
@@ -1,6 +1,6 @@
1/* crypto/x509v3/v3err.c */ 1/* crypto/x509v3/v3err.c */
2/* ==================================================================== 2/* ====================================================================
3 * Copyright (c) 1999-2005 The OpenSSL Project. All rights reserved. 3 * Copyright (c) 1999-2007 The OpenSSL Project. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
@@ -70,6 +70,7 @@
70 70
71static ERR_STRING_DATA X509V3_str_functs[]= 71static ERR_STRING_DATA X509V3_str_functs[]=
72 { 72 {
73{ERR_FUNC(X509V3_F_A2I_GENERAL_NAME), "A2I_GENERAL_NAME"},
73{ERR_FUNC(X509V3_F_ASIDENTIFIERCHOICE_CANONIZE), "ASIDENTIFIERCHOICE_CANONIZE"}, 74{ERR_FUNC(X509V3_F_ASIDENTIFIERCHOICE_CANONIZE), "ASIDENTIFIERCHOICE_CANONIZE"},
74{ERR_FUNC(X509V3_F_ASIDENTIFIERCHOICE_IS_CANONICAL), "ASIDENTIFIERCHOICE_IS_CANONICAL"}, 75{ERR_FUNC(X509V3_F_ASIDENTIFIERCHOICE_IS_CANONICAL), "ASIDENTIFIERCHOICE_IS_CANONICAL"},
75{ERR_FUNC(X509V3_F_COPY_EMAIL), "COPY_EMAIL"}, 76{ERR_FUNC(X509V3_F_COPY_EMAIL), "COPY_EMAIL"},
@@ -79,6 +80,7 @@ static ERR_STRING_DATA X509V3_str_functs[]=
79{ERR_FUNC(X509V3_F_DO_EXT_I2D), "DO_EXT_I2D"}, 80{ERR_FUNC(X509V3_F_DO_EXT_I2D), "DO_EXT_I2D"},
80{ERR_FUNC(X509V3_F_DO_EXT_NCONF), "DO_EXT_NCONF"}, 81{ERR_FUNC(X509V3_F_DO_EXT_NCONF), "DO_EXT_NCONF"},
81{ERR_FUNC(X509V3_F_DO_I2V_NAME_CONSTRAINTS), "DO_I2V_NAME_CONSTRAINTS"}, 82{ERR_FUNC(X509V3_F_DO_I2V_NAME_CONSTRAINTS), "DO_I2V_NAME_CONSTRAINTS"},
83{ERR_FUNC(X509V3_F_GNAMES_FROM_SECTNAME), "GNAMES_FROM_SECTNAME"},
82{ERR_FUNC(X509V3_F_HEX_TO_STRING), "hex_to_string"}, 84{ERR_FUNC(X509V3_F_HEX_TO_STRING), "hex_to_string"},
83{ERR_FUNC(X509V3_F_I2S_ASN1_ENUMERATED), "i2s_ASN1_ENUMERATED"}, 85{ERR_FUNC(X509V3_F_I2S_ASN1_ENUMERATED), "i2s_ASN1_ENUMERATED"},
84{ERR_FUNC(X509V3_F_I2S_ASN1_IA5STRING), "I2S_ASN1_IA5STRING"}, 86{ERR_FUNC(X509V3_F_I2S_ASN1_IA5STRING), "I2S_ASN1_IA5STRING"},
@@ -95,6 +97,7 @@ static ERR_STRING_DATA X509V3_str_functs[]=
95{ERR_FUNC(X509V3_F_S2I_ASN1_OCTET_STRING), "s2i_ASN1_OCTET_STRING"}, 97{ERR_FUNC(X509V3_F_S2I_ASN1_OCTET_STRING), "s2i_ASN1_OCTET_STRING"},
96{ERR_FUNC(X509V3_F_S2I_ASN1_SKEY_ID), "S2I_ASN1_SKEY_ID"}, 98{ERR_FUNC(X509V3_F_S2I_ASN1_SKEY_ID), "S2I_ASN1_SKEY_ID"},
97{ERR_FUNC(X509V3_F_S2I_SKEY_ID), "S2I_SKEY_ID"}, 99{ERR_FUNC(X509V3_F_S2I_SKEY_ID), "S2I_SKEY_ID"},
100{ERR_FUNC(X509V3_F_SET_DIST_POINT_NAME), "SET_DIST_POINT_NAME"},
98{ERR_FUNC(X509V3_F_STRING_TO_HEX), "string_to_hex"}, 101{ERR_FUNC(X509V3_F_STRING_TO_HEX), "string_to_hex"},
99{ERR_FUNC(X509V3_F_SXNET_ADD_ID_ASC), "SXNET_add_id_asc"}, 102{ERR_FUNC(X509V3_F_SXNET_ADD_ID_ASC), "SXNET_add_id_asc"},
100{ERR_FUNC(X509V3_F_SXNET_ADD_ID_INTEGER), "SXNET_add_id_INTEGER"}, 103{ERR_FUNC(X509V3_F_SXNET_ADD_ID_INTEGER), "SXNET_add_id_INTEGER"},
@@ -110,6 +113,7 @@ static ERR_STRING_DATA X509V3_str_functs[]=
110{ERR_FUNC(X509V3_F_V2I_EXTENDED_KEY_USAGE), "V2I_EXTENDED_KEY_USAGE"}, 113{ERR_FUNC(X509V3_F_V2I_EXTENDED_KEY_USAGE), "V2I_EXTENDED_KEY_USAGE"},
111{ERR_FUNC(X509V3_F_V2I_GENERAL_NAMES), "v2i_GENERAL_NAMES"}, 114{ERR_FUNC(X509V3_F_V2I_GENERAL_NAMES), "v2i_GENERAL_NAMES"},
112{ERR_FUNC(X509V3_F_V2I_GENERAL_NAME_EX), "v2i_GENERAL_NAME_ex"}, 115{ERR_FUNC(X509V3_F_V2I_GENERAL_NAME_EX), "v2i_GENERAL_NAME_ex"},
116{ERR_FUNC(X509V3_F_V2I_IDP), "V2I_IDP"},
113{ERR_FUNC(X509V3_F_V2I_IPADDRBLOCKS), "V2I_IPADDRBLOCKS"}, 117{ERR_FUNC(X509V3_F_V2I_IPADDRBLOCKS), "V2I_IPADDRBLOCKS"},
114{ERR_FUNC(X509V3_F_V2I_ISSUER_ALT), "V2I_ISSUER_ALT"}, 118{ERR_FUNC(X509V3_F_V2I_ISSUER_ALT), "V2I_ISSUER_ALT"},
115{ERR_FUNC(X509V3_F_V2I_NAME_CONSTRAINTS), "V2I_NAME_CONSTRAINTS"}, 119{ERR_FUNC(X509V3_F_V2I_NAME_CONSTRAINTS), "V2I_NAME_CONSTRAINTS"},
@@ -141,6 +145,7 @@ static ERR_STRING_DATA X509V3_str_reasons[]=
141{ERR_REASON(X509V3_R_BN_DEC2BN_ERROR) ,"bn dec2bn error"}, 145{ERR_REASON(X509V3_R_BN_DEC2BN_ERROR) ,"bn dec2bn error"},
142{ERR_REASON(X509V3_R_BN_TO_ASN1_INTEGER_ERROR),"bn to asn1 integer error"}, 146{ERR_REASON(X509V3_R_BN_TO_ASN1_INTEGER_ERROR),"bn to asn1 integer error"},
143{ERR_REASON(X509V3_R_DIRNAME_ERROR) ,"dirname error"}, 147{ERR_REASON(X509V3_R_DIRNAME_ERROR) ,"dirname error"},
148{ERR_REASON(X509V3_R_DISTPOINT_ALREADY_SET),"distpoint already set"},
144{ERR_REASON(X509V3_R_DUPLICATE_ZONE_ID) ,"duplicate zone id"}, 149{ERR_REASON(X509V3_R_DUPLICATE_ZONE_ID) ,"duplicate zone id"},
145{ERR_REASON(X509V3_R_ERROR_CONVERTING_ZONE),"error converting zone"}, 150{ERR_REASON(X509V3_R_ERROR_CONVERTING_ZONE),"error converting zone"},
146{ERR_REASON(X509V3_R_ERROR_CREATING_EXTENSION),"error creating extension"}, 151{ERR_REASON(X509V3_R_ERROR_CREATING_EXTENSION),"error creating extension"},
@@ -154,6 +159,7 @@ static ERR_STRING_DATA X509V3_str_reasons[]=
154{ERR_REASON(X509V3_R_ILLEGAL_EMPTY_EXTENSION),"illegal empty extension"}, 159{ERR_REASON(X509V3_R_ILLEGAL_EMPTY_EXTENSION),"illegal empty extension"},
155{ERR_REASON(X509V3_R_ILLEGAL_HEX_DIGIT) ,"illegal hex digit"}, 160{ERR_REASON(X509V3_R_ILLEGAL_HEX_DIGIT) ,"illegal hex digit"},
156{ERR_REASON(X509V3_R_INCORRECT_POLICY_SYNTAX_TAG),"incorrect policy syntax tag"}, 161{ERR_REASON(X509V3_R_INCORRECT_POLICY_SYNTAX_TAG),"incorrect policy syntax tag"},
162{ERR_REASON(X509V3_R_INVALID_MULTIPLE_RDNS),"invalid multiple rdns"},
157{ERR_REASON(X509V3_R_INVALID_ASNUMBER) ,"invalid asnumber"}, 163{ERR_REASON(X509V3_R_INVALID_ASNUMBER) ,"invalid asnumber"},
158{ERR_REASON(X509V3_R_INVALID_ASRANGE) ,"invalid asrange"}, 164{ERR_REASON(X509V3_R_INVALID_ASRANGE) ,"invalid asrange"},
159{ERR_REASON(X509V3_R_INVALID_BOOLEAN_STRING),"invalid boolean string"}, 165{ERR_REASON(X509V3_R_INVALID_BOOLEAN_STRING),"invalid boolean string"},
@@ -187,9 +193,9 @@ static ERR_STRING_DATA X509V3_str_reasons[]=
187{ERR_REASON(X509V3_R_ODD_NUMBER_OF_DIGITS),"odd number of digits"}, 193{ERR_REASON(X509V3_R_ODD_NUMBER_OF_DIGITS),"odd number of digits"},
188{ERR_REASON(X509V3_R_OPERATION_NOT_DEFINED),"operation not defined"}, 194{ERR_REASON(X509V3_R_OPERATION_NOT_DEFINED),"operation not defined"},
189{ERR_REASON(X509V3_R_OTHERNAME_ERROR) ,"othername error"}, 195{ERR_REASON(X509V3_R_OTHERNAME_ERROR) ,"othername error"},
190{ERR_REASON(X509V3_R_POLICY_LANGUAGE_ALREADTY_DEFINED),"policy language alreadty defined"}, 196{ERR_REASON(X509V3_R_POLICY_LANGUAGE_ALREADY_DEFINED),"policy language already defined"},
191{ERR_REASON(X509V3_R_POLICY_PATH_LENGTH) ,"policy path length"}, 197{ERR_REASON(X509V3_R_POLICY_PATH_LENGTH) ,"policy path length"},
192{ERR_REASON(X509V3_R_POLICY_PATH_LENGTH_ALREADTY_DEFINED),"policy path length alreadty defined"}, 198{ERR_REASON(X509V3_R_POLICY_PATH_LENGTH_ALREADY_DEFINED),"policy path length already defined"},
193{ERR_REASON(X509V3_R_POLICY_SYNTAX_NOT_CURRENTLY_SUPPORTED),"policy syntax not currently supported"}, 199{ERR_REASON(X509V3_R_POLICY_SYNTAX_NOT_CURRENTLY_SUPPORTED),"policy syntax not currently supported"},
194{ERR_REASON(X509V3_R_POLICY_WHEN_PROXY_LANGUAGE_REQUIRES_NO_POLICY),"policy when proxy language requires no policy"}, 200{ERR_REASON(X509V3_R_POLICY_WHEN_PROXY_LANGUAGE_REQUIRES_NO_POLICY),"policy when proxy language requires no policy"},
195{ERR_REASON(X509V3_R_SECTION_NOT_FOUND) ,"section not found"}, 201{ERR_REASON(X509V3_R_SECTION_NOT_FOUND) ,"section not found"},
@@ -200,6 +206,7 @@ static ERR_STRING_DATA X509V3_str_reasons[]=
200{ERR_REASON(X509V3_R_UNKNOWN_EXTENSION_NAME),"unknown extension name"}, 206{ERR_REASON(X509V3_R_UNKNOWN_EXTENSION_NAME),"unknown extension name"},
201{ERR_REASON(X509V3_R_UNKNOWN_OPTION) ,"unknown option"}, 207{ERR_REASON(X509V3_R_UNKNOWN_OPTION) ,"unknown option"},
202{ERR_REASON(X509V3_R_UNSUPPORTED_OPTION) ,"unsupported option"}, 208{ERR_REASON(X509V3_R_UNSUPPORTED_OPTION) ,"unsupported option"},
209{ERR_REASON(X509V3_R_UNSUPPORTED_TYPE) ,"unsupported type"},
203{ERR_REASON(X509V3_R_USER_TOO_LONG) ,"user too long"}, 210{ERR_REASON(X509V3_R_USER_TOO_LONG) ,"user too long"},
204{0,NULL} 211{0,NULL}
205 }; 212 };
diff --git a/src/lib/libcrypto/x509v3/x509v3.h b/src/lib/libcrypto/x509v3/x509v3.h
index 9ef83da755..b308abe7cd 100644
--- a/src/lib/libcrypto/x509v3/x509v3.h
+++ b/src/lib/libcrypto/x509v3/x509v3.h
@@ -76,12 +76,19 @@ typedef void * (*X509V3_EXT_NEW)(void);
76typedef void (*X509V3_EXT_FREE)(void *); 76typedef void (*X509V3_EXT_FREE)(void *);
77typedef void * (*X509V3_EXT_D2I)(void *, const unsigned char ** , long); 77typedef void * (*X509V3_EXT_D2I)(void *, const unsigned char ** , long);
78typedef int (*X509V3_EXT_I2D)(void *, unsigned char **); 78typedef int (*X509V3_EXT_I2D)(void *, unsigned char **);
79typedef STACK_OF(CONF_VALUE) * (*X509V3_EXT_I2V)(struct v3_ext_method *method, void *ext, STACK_OF(CONF_VALUE) *extlist); 79typedef STACK_OF(CONF_VALUE) *
80typedef void * (*X509V3_EXT_V2I)(struct v3_ext_method *method, struct v3_ext_ctx *ctx, STACK_OF(CONF_VALUE) *values); 80 (*X509V3_EXT_I2V)(const struct v3_ext_method *method, void *ext,
81typedef char * (*X509V3_EXT_I2S)(struct v3_ext_method *method, void *ext); 81 STACK_OF(CONF_VALUE) *extlist);
82typedef void * (*X509V3_EXT_S2I)(struct v3_ext_method *method, struct v3_ext_ctx *ctx, const char *str); 82typedef void * (*X509V3_EXT_V2I)(const struct v3_ext_method *method,
83typedef int (*X509V3_EXT_I2R)(struct v3_ext_method *method, void *ext, BIO *out, int indent); 83 struct v3_ext_ctx *ctx,
84typedef void * (*X509V3_EXT_R2I)(struct v3_ext_method *method, struct v3_ext_ctx *ctx, const char *str); 84 STACK_OF(CONF_VALUE) *values);
85typedef char * (*X509V3_EXT_I2S)(const struct v3_ext_method *method, void *ext);
86typedef void * (*X509V3_EXT_S2I)(const struct v3_ext_method *method,
87 struct v3_ext_ctx *ctx, const char *str);
88typedef int (*X509V3_EXT_I2R)(const struct v3_ext_method *method, void *ext,
89 BIO *out, int indent);
90typedef void * (*X509V3_EXT_R2I)(const struct v3_ext_method *method,
91 struct v3_ext_ctx *ctx, const char *str);
85 92
86/* V3 extension structure */ 93/* V3 extension structure */
87 94
@@ -220,24 +227,41 @@ union {
220 GENERAL_NAMES *fullname; 227 GENERAL_NAMES *fullname;
221 STACK_OF(X509_NAME_ENTRY) *relativename; 228 STACK_OF(X509_NAME_ENTRY) *relativename;
222} name; 229} name;
230/* If relativename then this contains the full distribution point name */
231X509_NAME *dpname;
223} DIST_POINT_NAME; 232} DIST_POINT_NAME;
224 233/* All existing reasons */
225typedef struct DIST_POINT_st { 234#define CRLDP_ALL_REASONS 0x807f
235
236#define CRL_REASON_NONE -1
237#define CRL_REASON_UNSPECIFIED 0
238#define CRL_REASON_KEY_COMPROMISE 1
239#define CRL_REASON_CA_COMPROMISE 2
240#define CRL_REASON_AFFILIATION_CHANGED 3
241#define CRL_REASON_SUPERSEDED 4
242#define CRL_REASON_CESSATION_OF_OPERATION 5
243#define CRL_REASON_CERTIFICATE_HOLD 6
244#define CRL_REASON_REMOVE_FROM_CRL 8
245#define CRL_REASON_PRIVILEGE_WITHDRAWN 9
246#define CRL_REASON_AA_COMPROMISE 10
247
248struct DIST_POINT_st {
226DIST_POINT_NAME *distpoint; 249DIST_POINT_NAME *distpoint;
227ASN1_BIT_STRING *reasons; 250ASN1_BIT_STRING *reasons;
228GENERAL_NAMES *CRLissuer; 251GENERAL_NAMES *CRLissuer;
229} DIST_POINT; 252int dp_reasons;
253};
230 254
231typedef STACK_OF(DIST_POINT) CRL_DIST_POINTS; 255typedef STACK_OF(DIST_POINT) CRL_DIST_POINTS;
232 256
233DECLARE_STACK_OF(DIST_POINT) 257DECLARE_STACK_OF(DIST_POINT)
234DECLARE_ASN1_SET_OF(DIST_POINT) 258DECLARE_ASN1_SET_OF(DIST_POINT)
235 259
236typedef struct AUTHORITY_KEYID_st { 260struct AUTHORITY_KEYID_st {
237ASN1_OCTET_STRING *keyid; 261ASN1_OCTET_STRING *keyid;
238GENERAL_NAMES *issuer; 262GENERAL_NAMES *issuer;
239ASN1_INTEGER *serial; 263ASN1_INTEGER *serial;
240} AUTHORITY_KEYID; 264};
241 265
242/* Strong extranet structures */ 266/* Strong extranet structures */
243 267
@@ -303,10 +327,10 @@ typedef struct GENERAL_SUBTREE_st {
303 327
304DECLARE_STACK_OF(GENERAL_SUBTREE) 328DECLARE_STACK_OF(GENERAL_SUBTREE)
305 329
306typedef struct NAME_CONSTRAINTS_st { 330struct NAME_CONSTRAINTS_st {
307 STACK_OF(GENERAL_SUBTREE) *permittedSubtrees; 331 STACK_OF(GENERAL_SUBTREE) *permittedSubtrees;
308 STACK_OF(GENERAL_SUBTREE) *excludedSubtrees; 332 STACK_OF(GENERAL_SUBTREE) *excludedSubtrees;
309} NAME_CONSTRAINTS; 333};
310 334
311typedef struct POLICY_CONSTRAINTS_st { 335typedef struct POLICY_CONSTRAINTS_st {
312 ASN1_INTEGER *requireExplicitPolicy; 336 ASN1_INTEGER *requireExplicitPolicy;
@@ -329,6 +353,31 @@ typedef struct PROXY_CERT_INFO_EXTENSION_st
329DECLARE_ASN1_FUNCTIONS(PROXY_POLICY) 353DECLARE_ASN1_FUNCTIONS(PROXY_POLICY)
330DECLARE_ASN1_FUNCTIONS(PROXY_CERT_INFO_EXTENSION) 354DECLARE_ASN1_FUNCTIONS(PROXY_CERT_INFO_EXTENSION)
331 355
356struct ISSUING_DIST_POINT_st
357 {
358 DIST_POINT_NAME *distpoint;
359 int onlyuser;
360 int onlyCA;
361 ASN1_BIT_STRING *onlysomereasons;
362 int indirectCRL;
363 int onlyattr;
364 };
365
366/* Values in idp_flags field */
367/* IDP present */
368#define IDP_PRESENT 0x1
369/* IDP values inconsistent */
370#define IDP_INVALID 0x2
371/* onlyuser true */
372#define IDP_ONLYUSER 0x4
373/* onlyCA true */
374#define IDP_ONLYCA 0x8
375/* onlyattr true */
376#define IDP_ONLYATTR 0x10
377/* indirectCRL true */
378#define IDP_INDIRECT 0x20
379/* onlysomereasons present */
380#define IDP_REASONS 0x40
332 381
333#define X509V3_conf_err(val) ERR_add_error_data(6, "section:", val->section, \ 382#define X509V3_conf_err(val) ERR_add_error_data(6, "section:", val->section, \
334",name:", val->name, ",value:", val->value); 383",name:", val->name, ",value:", val->value);
@@ -373,6 +422,7 @@ DECLARE_ASN1_FUNCTIONS(PROXY_CERT_INFO_EXTENSION)
373#define EXFLAG_PROXY 0x400 422#define EXFLAG_PROXY 0x400
374 423
375#define EXFLAG_INVALID_POLICY 0x800 424#define EXFLAG_INVALID_POLICY 0x800
425#define EXFLAG_FRESHEST 0x1000
376 426
377#define KU_DIGITAL_SIGNATURE 0x0080 427#define KU_DIGITAL_SIGNATURE 0x0080
378#define KU_NON_REPUDIATION 0x0040 428#define KU_NON_REPUDIATION 0x0040
@@ -424,9 +474,10 @@ typedef struct x509_purpose_st {
424#define X509_PURPOSE_CRL_SIGN 6 474#define X509_PURPOSE_CRL_SIGN 6
425#define X509_PURPOSE_ANY 7 475#define X509_PURPOSE_ANY 7
426#define X509_PURPOSE_OCSP_HELPER 8 476#define X509_PURPOSE_OCSP_HELPER 8
477#define X509_PURPOSE_TIMESTAMP_SIGN 9
427 478
428#define X509_PURPOSE_MIN 1 479#define X509_PURPOSE_MIN 1
429#define X509_PURPOSE_MAX 8 480#define X509_PURPOSE_MAX 9
430 481
431/* Flags for X509V3_EXT_print() */ 482/* Flags for X509V3_EXT_print() */
432 483
@@ -471,6 +522,9 @@ DECLARE_ASN1_FUNCTIONS(AUTHORITY_KEYID)
471DECLARE_ASN1_FUNCTIONS(PKEY_USAGE_PERIOD) 522DECLARE_ASN1_FUNCTIONS(PKEY_USAGE_PERIOD)
472 523
473DECLARE_ASN1_FUNCTIONS(GENERAL_NAME) 524DECLARE_ASN1_FUNCTIONS(GENERAL_NAME)
525GENERAL_NAME *GENERAL_NAME_dup(GENERAL_NAME *a);
526int GENERAL_NAME_cmp(GENERAL_NAME *a, GENERAL_NAME *b);
527
474 528
475 529
476ASN1_BIT_STRING *v2i_ASN1_BIT_STRING(X509V3_EXT_METHOD *method, 530ASN1_BIT_STRING *v2i_ASN1_BIT_STRING(X509V3_EXT_METHOD *method,
@@ -486,11 +540,18 @@ DECLARE_ASN1_FUNCTIONS(GENERAL_NAMES)
486 540
487STACK_OF(CONF_VALUE) *i2v_GENERAL_NAMES(X509V3_EXT_METHOD *method, 541STACK_OF(CONF_VALUE) *i2v_GENERAL_NAMES(X509V3_EXT_METHOD *method,
488 GENERAL_NAMES *gen, STACK_OF(CONF_VALUE) *extlist); 542 GENERAL_NAMES *gen, STACK_OF(CONF_VALUE) *extlist);
489GENERAL_NAMES *v2i_GENERAL_NAMES(X509V3_EXT_METHOD *method, 543GENERAL_NAMES *v2i_GENERAL_NAMES(const X509V3_EXT_METHOD *method,
490 X509V3_CTX *ctx, STACK_OF(CONF_VALUE) *nval); 544 X509V3_CTX *ctx, STACK_OF(CONF_VALUE) *nval);
491 545
492DECLARE_ASN1_FUNCTIONS(OTHERNAME) 546DECLARE_ASN1_FUNCTIONS(OTHERNAME)
493DECLARE_ASN1_FUNCTIONS(EDIPARTYNAME) 547DECLARE_ASN1_FUNCTIONS(EDIPARTYNAME)
548int OTHERNAME_cmp(OTHERNAME *a, OTHERNAME *b);
549void GENERAL_NAME_set0_value(GENERAL_NAME *a, int type, void *value);
550void *GENERAL_NAME_get0_value(GENERAL_NAME *a, int *ptype);
551int GENERAL_NAME_set0_othername(GENERAL_NAME *gen,
552 ASN1_OBJECT *oid, ASN1_TYPE *value);
553int GENERAL_NAME_get0_otherName(GENERAL_NAME *gen,
554 ASN1_OBJECT **poid, ASN1_TYPE **pvalue);
494 555
495char *i2s_ASN1_OCTET_STRING(X509V3_EXT_METHOD *method, ASN1_OCTET_STRING *ia5); 556char *i2s_ASN1_OCTET_STRING(X509V3_EXT_METHOD *method, ASN1_OCTET_STRING *ia5);
496ASN1_OCTET_STRING *s2i_ASN1_OCTET_STRING(X509V3_EXT_METHOD *method, X509V3_CTX *ctx, char *str); 557ASN1_OCTET_STRING *s2i_ASN1_OCTET_STRING(X509V3_EXT_METHOD *method, X509V3_CTX *ctx, char *str);
@@ -507,6 +568,11 @@ DECLARE_ASN1_FUNCTIONS(NOTICEREF)
507DECLARE_ASN1_FUNCTIONS(CRL_DIST_POINTS) 568DECLARE_ASN1_FUNCTIONS(CRL_DIST_POINTS)
508DECLARE_ASN1_FUNCTIONS(DIST_POINT) 569DECLARE_ASN1_FUNCTIONS(DIST_POINT)
509DECLARE_ASN1_FUNCTIONS(DIST_POINT_NAME) 570DECLARE_ASN1_FUNCTIONS(DIST_POINT_NAME)
571DECLARE_ASN1_FUNCTIONS(ISSUING_DIST_POINT)
572
573int DIST_POINT_set_dpname(DIST_POINT_NAME *dpn, X509_NAME *iname);
574
575int NAME_CONSTRAINTS_check(X509 *x, NAME_CONSTRAINTS *nc);
510 576
511DECLARE_ASN1_FUNCTIONS(ACCESS_DESCRIPTION) 577DECLARE_ASN1_FUNCTIONS(ACCESS_DESCRIPTION)
512DECLARE_ASN1_FUNCTIONS(AUTHORITY_INFO_ACCESS) 578DECLARE_ASN1_FUNCTIONS(AUTHORITY_INFO_ACCESS)
@@ -524,11 +590,16 @@ DECLARE_ASN1_ALLOC_FUNCTIONS(NAME_CONSTRAINTS)
524DECLARE_ASN1_ALLOC_FUNCTIONS(POLICY_CONSTRAINTS) 590DECLARE_ASN1_ALLOC_FUNCTIONS(POLICY_CONSTRAINTS)
525DECLARE_ASN1_ITEM(POLICY_CONSTRAINTS) 591DECLARE_ASN1_ITEM(POLICY_CONSTRAINTS)
526 592
593GENERAL_NAME *a2i_GENERAL_NAME(GENERAL_NAME *out,
594 const X509V3_EXT_METHOD *method, X509V3_CTX *ctx,
595 int gen_type, char *value, int is_nc);
596
527#ifdef HEADER_CONF_H 597#ifdef HEADER_CONF_H
528GENERAL_NAME *v2i_GENERAL_NAME(X509V3_EXT_METHOD *method, X509V3_CTX *ctx, 598GENERAL_NAME *v2i_GENERAL_NAME(const X509V3_EXT_METHOD *method, X509V3_CTX *ctx,
529 CONF_VALUE *cnf); 599 CONF_VALUE *cnf);
530GENERAL_NAME *v2i_GENERAL_NAME_ex(GENERAL_NAME *out, X509V3_EXT_METHOD *method, 600GENERAL_NAME *v2i_GENERAL_NAME_ex(GENERAL_NAME *out,
531 X509V3_CTX *ctx, CONF_VALUE *cnf, int is_nc); 601 const X509V3_EXT_METHOD *method,
602 X509V3_CTX *ctx, CONF_VALUE *cnf, int is_nc);
532void X509V3_conf_free(CONF_VALUE *val); 603void X509V3_conf_free(CONF_VALUE *val);
533 604
534X509_EXTENSION *X509V3_EXT_nconf_nid(CONF *conf, X509V3_CTX *ctx, int ext_nid, char *value); 605X509_EXTENSION *X509V3_EXT_nconf_nid(CONF *conf, X509V3_CTX *ctx, int ext_nid, char *value);
@@ -538,18 +609,23 @@ int X509V3_EXT_add_nconf(CONF *conf, X509V3_CTX *ctx, char *section, X509 *cert)
538int X509V3_EXT_REQ_add_nconf(CONF *conf, X509V3_CTX *ctx, char *section, X509_REQ *req); 609int X509V3_EXT_REQ_add_nconf(CONF *conf, X509V3_CTX *ctx, char *section, X509_REQ *req);
539int X509V3_EXT_CRL_add_nconf(CONF *conf, X509V3_CTX *ctx, char *section, X509_CRL *crl); 610int X509V3_EXT_CRL_add_nconf(CONF *conf, X509V3_CTX *ctx, char *section, X509_CRL *crl);
540 611
541X509_EXTENSION *X509V3_EXT_conf_nid(LHASH *conf, X509V3_CTX *ctx, int ext_nid, char *value); 612X509_EXTENSION *X509V3_EXT_conf_nid(LHASH_OF(CONF_VALUE) *conf, X509V3_CTX *ctx,
542X509_EXTENSION *X509V3_EXT_conf(LHASH *conf, X509V3_CTX *ctx, char *name, char *value); 613 int ext_nid, char *value);
543int X509V3_EXT_add_conf(LHASH *conf, X509V3_CTX *ctx, char *section, X509 *cert); 614X509_EXTENSION *X509V3_EXT_conf(LHASH_OF(CONF_VALUE) *conf, X509V3_CTX *ctx,
544int X509V3_EXT_REQ_add_conf(LHASH *conf, X509V3_CTX *ctx, char *section, X509_REQ *req); 615 char *name, char *value);
545int X509V3_EXT_CRL_add_conf(LHASH *conf, X509V3_CTX *ctx, char *section, X509_CRL *crl); 616int X509V3_EXT_add_conf(LHASH_OF(CONF_VALUE) *conf, X509V3_CTX *ctx,
617 char *section, X509 *cert);
618int X509V3_EXT_REQ_add_conf(LHASH_OF(CONF_VALUE) *conf, X509V3_CTX *ctx,
619 char *section, X509_REQ *req);
620int X509V3_EXT_CRL_add_conf(LHASH_OF(CONF_VALUE) *conf, X509V3_CTX *ctx,
621 char *section, X509_CRL *crl);
546 622
547int X509V3_add_value_bool_nf(char *name, int asn1_bool, 623int X509V3_add_value_bool_nf(char *name, int asn1_bool,
548 STACK_OF(CONF_VALUE) **extlist); 624 STACK_OF(CONF_VALUE) **extlist);
549int X509V3_get_value_bool(CONF_VALUE *value, int *asn1_bool); 625int X509V3_get_value_bool(CONF_VALUE *value, int *asn1_bool);
550int X509V3_get_value_int(CONF_VALUE *value, ASN1_INTEGER **aint); 626int X509V3_get_value_int(CONF_VALUE *value, ASN1_INTEGER **aint);
551void X509V3_set_nconf(X509V3_CTX *ctx, CONF *conf); 627void X509V3_set_nconf(X509V3_CTX *ctx, CONF *conf);
552void X509V3_set_conf_lhash(X509V3_CTX *ctx, LHASH *lhash); 628void X509V3_set_conf_lhash(X509V3_CTX *ctx, LHASH_OF(CONF_VALUE) *lhash);
553#endif 629#endif
554 630
555char * X509V3_get_string(X509V3_CTX *ctx, char *name, char *section); 631char * X509V3_get_string(X509V3_CTX *ctx, char *name, char *section);
@@ -576,8 +652,8 @@ int X509V3_EXT_add_list(X509V3_EXT_METHOD *extlist);
576int X509V3_EXT_add_alias(int nid_to, int nid_from); 652int X509V3_EXT_add_alias(int nid_to, int nid_from);
577void X509V3_EXT_cleanup(void); 653void X509V3_EXT_cleanup(void);
578 654
579X509V3_EXT_METHOD *X509V3_EXT_get(X509_EXTENSION *ext); 655const X509V3_EXT_METHOD *X509V3_EXT_get(X509_EXTENSION *ext);
580X509V3_EXT_METHOD *X509V3_EXT_get_nid(int nid); 656const X509V3_EXT_METHOD *X509V3_EXT_get_nid(int nid);
581int X509V3_add_standard_extensions(void); 657int X509V3_add_standard_extensions(void);
582STACK_OF(CONF_VALUE) *X509V3_parse_list(const char *line); 658STACK_OF(CONF_VALUE) *X509V3_parse_list(const char *line);
583void *X509V3_EXT_d2i(X509_EXTENSION *ext); 659void *X509V3_EXT_d2i(X509_EXTENSION *ext);
@@ -587,8 +663,8 @@ void *X509V3_get_d2i(STACK_OF(X509_EXTENSION) *x, int nid, int *crit, int *idx);
587X509_EXTENSION *X509V3_EXT_i2d(int ext_nid, int crit, void *ext_struc); 663X509_EXTENSION *X509V3_EXT_i2d(int ext_nid, int crit, void *ext_struc);
588int X509V3_add1_i2d(STACK_OF(X509_EXTENSION) **x, int nid, void *value, int crit, unsigned long flags); 664int X509V3_add1_i2d(STACK_OF(X509_EXTENSION) **x, int nid, void *value, int crit, unsigned long flags);
589 665
590char *hex_to_string(unsigned char *buffer, long len); 666char *hex_to_string(const unsigned char *buffer, long len);
591unsigned char *string_to_hex(char *str, long *len); 667unsigned char *string_to_hex(const char *str, long *len);
592int name_cmp(const char *name, const char *cmp); 668int name_cmp(const char *name, const char *cmp);
593 669
594void X509V3_EXT_val_prn(BIO *out, STACK_OF(CONF_VALUE) *val, int indent, 670void X509V3_EXT_val_prn(BIO *out, STACK_OF(CONF_VALUE) *val, int indent,
@@ -603,6 +679,7 @@ int X509_check_purpose(X509 *x, int id, int ca);
603int X509_supported_extension(X509_EXTENSION *ex); 679int X509_supported_extension(X509_EXTENSION *ex);
604int X509_PURPOSE_set(int *p, int purpose); 680int X509_PURPOSE_set(int *p, int purpose);
605int X509_check_issued(X509 *issuer, X509 *subject); 681int X509_check_issued(X509 *issuer, X509 *subject);
682int X509_check_akid(X509 *issuer, AUTHORITY_KEYID *akid);
606int X509_PURPOSE_get_count(void); 683int X509_PURPOSE_get_count(void);
607X509_PURPOSE * X509_PURPOSE_get0(int idx); 684X509_PURPOSE * X509_PURPOSE_get0(int idx);
608int X509_PURPOSE_get_by_sname(char *sname); 685int X509_PURPOSE_get_by_sname(char *sname);
@@ -616,10 +693,10 @@ int X509_PURPOSE_get_trust(X509_PURPOSE *xp);
616void X509_PURPOSE_cleanup(void); 693void X509_PURPOSE_cleanup(void);
617int X509_PURPOSE_get_id(X509_PURPOSE *); 694int X509_PURPOSE_get_id(X509_PURPOSE *);
618 695
619STACK *X509_get1_email(X509 *x); 696STACK_OF(OPENSSL_STRING) *X509_get1_email(X509 *x);
620STACK *X509_REQ_get1_email(X509_REQ *x); 697STACK_OF(OPENSSL_STRING) *X509_REQ_get1_email(X509_REQ *x);
621void X509_email_free(STACK *sk); 698void X509_email_free(STACK_OF(OPENSSL_STRING) *sk);
622STACK *X509_get1_ocsp(X509 *x); 699STACK_OF(OPENSSL_STRING) *X509_get1_ocsp(X509 *x);
623 700
624ASN1_OCTET_STRING *a2i_IPADDRESS(const char *ipasc); 701ASN1_OCTET_STRING *a2i_IPADDRESS(const char *ipasc);
625ASN1_OCTET_STRING *a2i_IPADDRESS_NC(const char *ipasc); 702ASN1_OCTET_STRING *a2i_IPADDRESS_NC(const char *ipasc);
@@ -628,6 +705,7 @@ int X509V3_NAME_from_section(X509_NAME *nm, STACK_OF(CONF_VALUE)*dn_sk,
628 unsigned long chtype); 705 unsigned long chtype);
629 706
630void X509_POLICY_NODE_print(BIO *out, X509_POLICY_NODE *node, int indent); 707void X509_POLICY_NODE_print(BIO *out, X509_POLICY_NODE *node, int indent);
708DECLARE_STACK_OF(X509_POLICY_NODE)
631 709
632#ifndef OPENSSL_NO_RFC3779 710#ifndef OPENSSL_NO_RFC3779
633 711
@@ -787,8 +865,9 @@ void ERR_load_X509V3_strings(void);
787/* Error codes for the X509V3 functions. */ 865/* Error codes for the X509V3 functions. */
788 866
789/* Function codes. */ 867/* Function codes. */
790#define X509V3_F_ASIDENTIFIERCHOICE_CANONIZE 156 868#define X509V3_F_A2I_GENERAL_NAME 164
791#define X509V3_F_ASIDENTIFIERCHOICE_IS_CANONICAL 157 869#define X509V3_F_ASIDENTIFIERCHOICE_CANONIZE 161
870#define X509V3_F_ASIDENTIFIERCHOICE_IS_CANONICAL 162
792#define X509V3_F_COPY_EMAIL 122 871#define X509V3_F_COPY_EMAIL 122
793#define X509V3_F_COPY_ISSUER 123 872#define X509V3_F_COPY_ISSUER 123
794#define X509V3_F_DO_DIRNAME 144 873#define X509V3_F_DO_DIRNAME 144
@@ -796,6 +875,7 @@ void ERR_load_X509V3_strings(void);
796#define X509V3_F_DO_EXT_I2D 135 875#define X509V3_F_DO_EXT_I2D 135
797#define X509V3_F_DO_EXT_NCONF 151 876#define X509V3_F_DO_EXT_NCONF 151
798#define X509V3_F_DO_I2V_NAME_CONSTRAINTS 148 877#define X509V3_F_DO_I2V_NAME_CONSTRAINTS 148
878#define X509V3_F_GNAMES_FROM_SECTNAME 156
799#define X509V3_F_HEX_TO_STRING 111 879#define X509V3_F_HEX_TO_STRING 111
800#define X509V3_F_I2S_ASN1_ENUMERATED 121 880#define X509V3_F_I2S_ASN1_ENUMERATED 121
801#define X509V3_F_I2S_ASN1_IA5STRING 149 881#define X509V3_F_I2S_ASN1_IA5STRING 149
@@ -812,13 +892,14 @@ void ERR_load_X509V3_strings(void);
812#define X509V3_F_S2I_ASN1_OCTET_STRING 112 892#define X509V3_F_S2I_ASN1_OCTET_STRING 112
813#define X509V3_F_S2I_ASN1_SKEY_ID 114 893#define X509V3_F_S2I_ASN1_SKEY_ID 114
814#define X509V3_F_S2I_SKEY_ID 115 894#define X509V3_F_S2I_SKEY_ID 115
895#define X509V3_F_SET_DIST_POINT_NAME 158
815#define X509V3_F_STRING_TO_HEX 113 896#define X509V3_F_STRING_TO_HEX 113
816#define X509V3_F_SXNET_ADD_ID_ASC 125 897#define X509V3_F_SXNET_ADD_ID_ASC 125
817#define X509V3_F_SXNET_ADD_ID_INTEGER 126 898#define X509V3_F_SXNET_ADD_ID_INTEGER 126
818#define X509V3_F_SXNET_ADD_ID_ULONG 127 899#define X509V3_F_SXNET_ADD_ID_ULONG 127
819#define X509V3_F_SXNET_GET_ID_ASC 128 900#define X509V3_F_SXNET_GET_ID_ASC 128
820#define X509V3_F_SXNET_GET_ID_ULONG 129 901#define X509V3_F_SXNET_GET_ID_ULONG 129
821#define X509V3_F_V2I_ASIDENTIFIERS 158 902#define X509V3_F_V2I_ASIDENTIFIERS 163
822#define X509V3_F_V2I_ASN1_BIT_STRING 101 903#define X509V3_F_V2I_ASN1_BIT_STRING 101
823#define X509V3_F_V2I_AUTHORITY_INFO_ACCESS 139 904#define X509V3_F_V2I_AUTHORITY_INFO_ACCESS 139
824#define X509V3_F_V2I_AUTHORITY_KEYID 119 905#define X509V3_F_V2I_AUTHORITY_KEYID 119
@@ -827,6 +908,7 @@ void ERR_load_X509V3_strings(void);
827#define X509V3_F_V2I_EXTENDED_KEY_USAGE 103 908#define X509V3_F_V2I_EXTENDED_KEY_USAGE 103
828#define X509V3_F_V2I_GENERAL_NAMES 118 909#define X509V3_F_V2I_GENERAL_NAMES 118
829#define X509V3_F_V2I_GENERAL_NAME_EX 117 910#define X509V3_F_V2I_GENERAL_NAME_EX 117
911#define X509V3_F_V2I_IDP 157
830#define X509V3_F_V2I_IPADDRBLOCKS 159 912#define X509V3_F_V2I_IPADDRBLOCKS 159
831#define X509V3_F_V2I_ISSUER_ALT 153 913#define X509V3_F_V2I_ISSUER_ALT 153
832#define X509V3_F_V2I_NAME_CONSTRAINTS 147 914#define X509V3_F_V2I_NAME_CONSTRAINTS 147
@@ -855,6 +937,7 @@ void ERR_load_X509V3_strings(void);
855#define X509V3_R_BN_DEC2BN_ERROR 100 937#define X509V3_R_BN_DEC2BN_ERROR 100
856#define X509V3_R_BN_TO_ASN1_INTEGER_ERROR 101 938#define X509V3_R_BN_TO_ASN1_INTEGER_ERROR 101
857#define X509V3_R_DIRNAME_ERROR 149 939#define X509V3_R_DIRNAME_ERROR 149
940#define X509V3_R_DISTPOINT_ALREADY_SET 160
858#define X509V3_R_DUPLICATE_ZONE_ID 133 941#define X509V3_R_DUPLICATE_ZONE_ID 133
859#define X509V3_R_ERROR_CONVERTING_ZONE 131 942#define X509V3_R_ERROR_CONVERTING_ZONE 131
860#define X509V3_R_ERROR_CREATING_EXTENSION 144 943#define X509V3_R_ERROR_CREATING_EXTENSION 144
@@ -868,12 +951,13 @@ void ERR_load_X509V3_strings(void);
868#define X509V3_R_ILLEGAL_EMPTY_EXTENSION 151 951#define X509V3_R_ILLEGAL_EMPTY_EXTENSION 151
869#define X509V3_R_ILLEGAL_HEX_DIGIT 113 952#define X509V3_R_ILLEGAL_HEX_DIGIT 113
870#define X509V3_R_INCORRECT_POLICY_SYNTAX_TAG 152 953#define X509V3_R_INCORRECT_POLICY_SYNTAX_TAG 152
871#define X509V3_R_INVALID_ASNUMBER 160 954#define X509V3_R_INVALID_MULTIPLE_RDNS 161
872#define X509V3_R_INVALID_ASRANGE 161 955#define X509V3_R_INVALID_ASNUMBER 162
956#define X509V3_R_INVALID_ASRANGE 163
873#define X509V3_R_INVALID_BOOLEAN_STRING 104 957#define X509V3_R_INVALID_BOOLEAN_STRING 104
874#define X509V3_R_INVALID_EXTENSION_STRING 105 958#define X509V3_R_INVALID_EXTENSION_STRING 105
875#define X509V3_R_INVALID_INHERITANCE 162 959#define X509V3_R_INVALID_INHERITANCE 165
876#define X509V3_R_INVALID_IPADDRESS 163 960#define X509V3_R_INVALID_IPADDRESS 166
877#define X509V3_R_INVALID_NAME 106 961#define X509V3_R_INVALID_NAME 106
878#define X509V3_R_INVALID_NULL_ARGUMENT 107 962#define X509V3_R_INVALID_NULL_ARGUMENT 107
879#define X509V3_R_INVALID_NULL_NAME 108 963#define X509V3_R_INVALID_NULL_NAME 108
@@ -901,9 +985,9 @@ void ERR_load_X509V3_strings(void);
901#define X509V3_R_ODD_NUMBER_OF_DIGITS 112 985#define X509V3_R_ODD_NUMBER_OF_DIGITS 112
902#define X509V3_R_OPERATION_NOT_DEFINED 148 986#define X509V3_R_OPERATION_NOT_DEFINED 148
903#define X509V3_R_OTHERNAME_ERROR 147 987#define X509V3_R_OTHERNAME_ERROR 147
904#define X509V3_R_POLICY_LANGUAGE_ALREADTY_DEFINED 155 988#define X509V3_R_POLICY_LANGUAGE_ALREADY_DEFINED 155
905#define X509V3_R_POLICY_PATH_LENGTH 156 989#define X509V3_R_POLICY_PATH_LENGTH 156
906#define X509V3_R_POLICY_PATH_LENGTH_ALREADTY_DEFINED 157 990#define X509V3_R_POLICY_PATH_LENGTH_ALREADY_DEFINED 157
907#define X509V3_R_POLICY_SYNTAX_NOT_CURRENTLY_SUPPORTED 158 991#define X509V3_R_POLICY_SYNTAX_NOT_CURRENTLY_SUPPORTED 158
908#define X509V3_R_POLICY_WHEN_PROXY_LANGUAGE_REQUIRES_NO_POLICY 159 992#define X509V3_R_POLICY_WHEN_PROXY_LANGUAGE_REQUIRES_NO_POLICY 159
909#define X509V3_R_SECTION_NOT_FOUND 150 993#define X509V3_R_SECTION_NOT_FOUND 150
@@ -914,6 +998,7 @@ void ERR_load_X509V3_strings(void);
914#define X509V3_R_UNKNOWN_EXTENSION_NAME 130 998#define X509V3_R_UNKNOWN_EXTENSION_NAME 130
915#define X509V3_R_UNKNOWN_OPTION 120 999#define X509V3_R_UNKNOWN_OPTION 120
916#define X509V3_R_UNSUPPORTED_OPTION 117 1000#define X509V3_R_UNSUPPORTED_OPTION 117
1001#define X509V3_R_UNSUPPORTED_TYPE 167
917#define X509V3_R_USER_TOO_LONG 132 1002#define X509V3_R_USER_TOO_LONG 132
918 1003
919#ifdef __cplusplus 1004#ifdef __cplusplus
diff --git a/src/lib/libcrypto/x86_64cpuid.pl b/src/lib/libcrypto/x86_64cpuid.pl
index 8946b464a8..b771a8539d 100644
--- a/src/lib/libcrypto/x86_64cpuid.pl
+++ b/src/lib/libcrypto/x86_64cpuid.pl
@@ -1,110 +1,38 @@
1#!/usr/bin/env perl 1#!/usr/bin/env perl
2 2
3$output=shift; 3$flavour = shift;
4$masm=1 if ($output =~ /\.asm/); 4$output = shift;
5open STDOUT,">$output" || die "can't open $output: $!"; 5if ($flavour =~ /\./) { $output = $flavour; undef $flavour; }
6
7print<<___ if(defined($masm));
8_TEXT SEGMENT
9PUBLIC OPENSSL_rdtsc
10
11PUBLIC OPENSSL_atomic_add
12ALIGN 16
13OPENSSL_atomic_add PROC
14 mov eax,DWORD PTR[rcx]
15\$Lspin: lea r8,DWORD PTR[rdx+rax]
16lock cmpxchg DWORD PTR[rcx],r8d
17 jne \$Lspin
18 mov eax,r8d
19 cdqe
20 ret
21OPENSSL_atomic_add ENDP
22
23PUBLIC OPENSSL_wipe_cpu
24ALIGN 16
25OPENSSL_wipe_cpu PROC
26 pxor xmm0,xmm0
27 pxor xmm1,xmm1
28 pxor xmm2,xmm2
29 pxor xmm3,xmm3
30 pxor xmm4,xmm4
31 pxor xmm5,xmm5
32 xor rcx,rcx
33 xor rdx,rdx
34 xor r8,r8
35 xor r9,r9
36 xor r10,r10
37 xor r11,r11
38 lea rax,QWORD PTR[rsp+8]
39 ret
40OPENSSL_wipe_cpu ENDP
41_TEXT ENDS
42 6
43CRT\$XIU SEGMENT 7$win64=0; $win64=1 if ($flavour =~ /[nm]asm|mingw64/ || $output =~ /\.asm$/);
44EXTRN OPENSSL_cpuid_setup:PROC
45DQ OPENSSL_cpuid_setup
46CRT\$XIU ENDS
47 8
48___ 9$0 =~ m/(.*[\/\\])[^\/\\]+$/; $dir=$1;
49print<<___ if(!defined($masm)); 10open STDOUT,"| $^X ${dir}perlasm/x86_64-xlate.pl $flavour $output";
11
12if ($win64) { $arg1="%rcx"; $arg2="%rdx"; }
13else { $arg1="%rdi"; $arg2="%rsi"; }
14print<<___;
50#include <machine/asm.h> 15#include <machine/asm.h>
16.extern OPENSSL_cpuid_setup
17.section .init
18 call PIC_PLT(OPENSSL_cpuid_setup)
51 19
52.text 20.text
53 21
54.globl OPENSSL_atomic_add 22.globl OPENSSL_atomic_add
55.type OPENSSL_atomic_add,\@function 23.type OPENSSL_atomic_add,\@abi-omnipotent
56.align 16 24.align 16
57OPENSSL_atomic_add: 25OPENSSL_atomic_add:
58 movl (%rdi),%eax 26 movl ($arg1),%eax
59.Lspin: leaq (%rsi,%rax),%r8 27.Lspin: leaq ($arg2,%rax),%r8
60lock; cmpxchgl %r8d,(%rdi) 28 .byte 0xf0 # lock
29 cmpxchgl %r8d,($arg1)
61 jne .Lspin 30 jne .Lspin
62 movl %r8d,%eax 31 movl %r8d,%eax
63 .byte 0x48,0x98 32 .byte 0x48,0x98 # cltq/cdqe
64 ret 33 ret
65.size OPENSSL_atomic_add,.-OPENSSL_atomic_add 34.size OPENSSL_atomic_add,.-OPENSSL_atomic_add
66 35
67.globl OPENSSL_wipe_cpu
68.type OPENSSL_wipe_cpu,\@function
69.align 16
70OPENSSL_wipe_cpu:
71 pxor %xmm0,%xmm0
72 pxor %xmm1,%xmm1
73 pxor %xmm2,%xmm2
74 pxor %xmm3,%xmm3
75 pxor %xmm4,%xmm4
76 pxor %xmm5,%xmm5
77 pxor %xmm6,%xmm6
78 pxor %xmm7,%xmm7
79 pxor %xmm8,%xmm8
80 pxor %xmm9,%xmm9
81 pxor %xmm10,%xmm10
82 pxor %xmm11,%xmm11
83 pxor %xmm12,%xmm12
84 pxor %xmm13,%xmm13
85 pxor %xmm14,%xmm14
86 pxor %xmm15,%xmm15
87 xorq %rcx,%rcx
88 xorq %rdx,%rdx
89 xorq %rsi,%rsi
90 xorq %rdi,%rdi
91 xorq %r8,%r8
92 xorq %r9,%r9
93 xorq %r10,%r10
94 xorq %r11,%r11
95 leaq 8(%rsp),%rax
96 ret
97.size OPENSSL_wipe_cpu,.-OPENSSL_wipe_cpu
98
99.section .init
100 call PIC_PLT(OPENSSL_cpuid_setup)
101
102___
103
104open STDOUT,"| $^X perlasm/x86_64-xlate.pl $output";
105print<<___;
106.text
107
108.globl OPENSSL_rdtsc 36.globl OPENSSL_rdtsc
109.type OPENSSL_rdtsc,\@abi-omnipotent 37.type OPENSSL_rdtsc,\@abi-omnipotent
110.align 16 38.align 16
@@ -123,6 +51,8 @@ OPENSSL_ia32_cpuid:
123 51
124 xor %eax,%eax 52 xor %eax,%eax
125 cpuid 53 cpuid
54 mov %eax,%r11d # max value for standard query level
55
126 xor %eax,%eax 56 xor %eax,%eax
127 cmp \$0x756e6547,%ebx # "Genu" 57 cmp \$0x756e6547,%ebx # "Genu"
128 setne %al 58 setne %al
@@ -132,8 +62,54 @@ OPENSSL_ia32_cpuid:
132 or %eax,%r9d 62 or %eax,%r9d
133 cmp \$0x6c65746e,%ecx # "ntel" 63 cmp \$0x6c65746e,%ecx # "ntel"
134 setne %al 64 setne %al
135 or %eax,%r9d 65 or %eax,%r9d # 0 indicates Intel CPU
66 jz .Lintel
67
68 cmp \$0x68747541,%ebx # "Auth"
69 setne %al
70 mov %eax,%r10d
71 cmp \$0x69746E65,%edx # "enti"
72 setne %al
73 or %eax,%r10d
74 cmp \$0x444D4163,%ecx # "cAMD"
75 setne %al
76 or %eax,%r10d # 0 indicates AMD CPU
77 jnz .Lintel
78
79 # AMD specific
80 mov \$0x80000000,%eax
81 cpuid
82 cmp \$0x80000008,%eax
83 jb .Lintel
84
85 mov \$0x80000008,%eax
86 cpuid
87 movzb %cl,%r10 # number of cores - 1
88 inc %r10 # number of cores
89
90 mov \$1,%eax
91 cpuid
92 bt \$28,%edx # test hyper-threading bit
93 jnc .Ldone
94 shr \$16,%ebx # number of logical processors
95 cmp %r10b,%bl
96 ja .Ldone
97 and \$0xefffffff,%edx # ~(1<<28)
98 jmp .Ldone
99
100.Lintel:
101 cmp \$4,%r11d
102 mov \$-1,%r10d
103 jb .Lnocacheinfo
104
105 mov \$4,%eax
106 mov \$0,%ecx # query L1D
107 cpuid
108 mov %eax,%r10d
109 shr \$14,%r10d
110 and \$0xfff,%r10d # number of cores -1 per L1D
136 111
112.Lnocacheinfo:
137 mov \$1,%eax 113 mov \$1,%eax
138 cpuid 114 cpuid
139 cmp \$0,%r9d 115 cmp \$0,%r9d
@@ -146,6 +122,11 @@ OPENSSL_ia32_cpuid:
146.Lnotintel: 122.Lnotintel:
147 bt \$28,%edx # test hyper-threading bit 123 bt \$28,%edx # test hyper-threading bit
148 jnc .Ldone 124 jnc .Ldone
125 and \$0xefffffff,%edx # ~(1<<28)
126 cmp \$0,%r10d
127 je .Ldone
128
129 or \$0x10000000,%edx # 1<<28
149 shr \$16,%ebx 130 shr \$16,%ebx
150 cmp \$1,%bl # see if cache is shared 131 cmp \$1,%bl # see if cache is shared
151 ja .Ldone 132 ja .Ldone
@@ -157,5 +138,96 @@ OPENSSL_ia32_cpuid:
157 or %rcx,%rax 138 or %rcx,%rax
158 ret 139 ret
159.size OPENSSL_ia32_cpuid,.-OPENSSL_ia32_cpuid 140.size OPENSSL_ia32_cpuid,.-OPENSSL_ia32_cpuid
141
142.globl OPENSSL_cleanse
143.type OPENSSL_cleanse,\@abi-omnipotent
144.align 16
145OPENSSL_cleanse:
146 xor %rax,%rax
147 cmp \$15,$arg2
148 jae .Lot
149 cmp \$0,$arg2
150 je .Lret
151.Little:
152 mov %al,($arg1)
153 sub \$1,$arg2
154 lea 1($arg1),$arg1
155 jnz .Little
156.Lret:
157 ret
158.align 16
159.Lot:
160 test \$7,$arg1
161 jz .Laligned
162 mov %al,($arg1)
163 lea -1($arg2),$arg2
164 lea 1($arg1),$arg1
165 jmp .Lot
166.Laligned:
167 mov %rax,($arg1)
168 lea -8($arg2),$arg2
169 test \$-8,$arg2
170 lea 8($arg1),$arg1
171 jnz .Laligned
172 cmp \$0,$arg2
173 jne .Little
174 ret
175.size OPENSSL_cleanse,.-OPENSSL_cleanse
176___
177
178print<<___ if (!$win64);
179.globl OPENSSL_wipe_cpu
180.type OPENSSL_wipe_cpu,\@abi-omnipotent
181.align 16
182OPENSSL_wipe_cpu:
183 pxor %xmm0,%xmm0
184 pxor %xmm1,%xmm1
185 pxor %xmm2,%xmm2
186 pxor %xmm3,%xmm3
187 pxor %xmm4,%xmm4
188 pxor %xmm5,%xmm5
189 pxor %xmm6,%xmm6
190 pxor %xmm7,%xmm7
191 pxor %xmm8,%xmm8
192 pxor %xmm9,%xmm9
193 pxor %xmm10,%xmm10
194 pxor %xmm11,%xmm11
195 pxor %xmm12,%xmm12
196 pxor %xmm13,%xmm13
197 pxor %xmm14,%xmm14
198 pxor %xmm15,%xmm15
199 xorq %rcx,%rcx
200 xorq %rdx,%rdx
201 xorq %rsi,%rsi
202 xorq %rdi,%rdi
203 xorq %r8,%r8
204 xorq %r9,%r9
205 xorq %r10,%r10
206 xorq %r11,%r11
207 leaq 8(%rsp),%rax
208 ret
209.size OPENSSL_wipe_cpu,.-OPENSSL_wipe_cpu
160___ 210___
211print<<___ if ($win64);
212.globl OPENSSL_wipe_cpu
213.type OPENSSL_wipe_cpu,\@abi-omnipotent
214.align 16
215OPENSSL_wipe_cpu:
216 pxor %xmm0,%xmm0
217 pxor %xmm1,%xmm1
218 pxor %xmm2,%xmm2
219 pxor %xmm3,%xmm3
220 pxor %xmm4,%xmm4
221 pxor %xmm5,%xmm5
222 xorq %rcx,%rcx
223 xorq %rdx,%rdx
224 xorq %r8,%r8
225 xorq %r9,%r9
226 xorq %r10,%r10
227 xorq %r11,%r11
228 leaq 8(%rsp),%rax
229 ret
230.size OPENSSL_wipe_cpu,.-OPENSSL_wipe_cpu
231___
232
161close STDOUT; # flush 233close STDOUT; # flush